ar71xx: use correct mac on the lan interface on several TP-LINK devices
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-tl-mr3x20.c
1 /*
2  *  TP-LINK TL-MR3220/3420 board support
3  *
4  *  Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify it
7  *  under the terms of the GNU General Public License version 2 as published
8  *  by the Free Software Foundation.
9  */
10
11 #include <linux/gpio.h>
12
13 #include <asm/mach-ar71xx/ar71xx.h>
14
15 #include "machtype.h"
16 #include "devices.h"
17 #include "dev-m25p80.h"
18 #include "dev-ap91-pci.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-usb.h"
22
23 #define TL_MR3X20_GPIO_LED_QSS          0
24 #define TL_MR3X20_GPIO_LED_SYSTEM       1
25 #define TL_MR3X20_GPIO_LED_3G           8
26
27 #define TL_MR3X20_GPIO_BTN_RESET        11
28 #define TL_MR3X20_GPIO_BTN_QSS          12
29
30 #define TL_MR3X20_GPIO_USB_POWER        6
31
32 #define TL_MR3X20_KEYS_POLL_INTERVAL    20      /* msecs */
33 #define TL_MR3X20_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR3X20_KEYS_POLL_INTERVAL)
34
35 static const char *tl_mr3x20_part_probes[] = {
36         "tp-link",
37         NULL,
38 };
39
40 static struct flash_platform_data tl_mr3x20_flash_data = {
41         .part_probes    = tl_mr3x20_part_probes,
42 };
43
44 static struct gpio_led tl_mr3x20_leds_gpio[] __initdata = {
45         {
46                 .name           = "tp-link:green:system",
47                 .gpio           = TL_MR3X20_GPIO_LED_SYSTEM,
48                 .active_low     = 1,
49         }, {
50                 .name           = "tp-link:green:qss",
51                 .gpio           = TL_MR3X20_GPIO_LED_QSS,
52                 .active_low     = 1,
53         }, {
54                 .name           = "tp-link:green:3g",
55                 .gpio           = TL_MR3X20_GPIO_LED_3G,
56                 .active_low     = 1,
57         }
58 };
59
60 static struct gpio_keys_button tl_mr3x20_gpio_keys[] __initdata = {
61         {
62                 .desc           = "reset",
63                 .type           = EV_KEY,
64                 .code           = KEY_RESTART,
65                 .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
66                 .gpio           = TL_MR3X20_GPIO_BTN_RESET,
67                 .active_low     = 1,
68         }, {
69                 .desc           = "qss",
70                 .type           = EV_KEY,
71                 .code           = KEY_WPS_BUTTON,
72                 .debounce_interval = TL_MR3X20_KEYS_DEBOUNCE_INTERVAL,
73                 .gpio           = TL_MR3X20_GPIO_BTN_QSS,
74                 .active_low     = 1,
75         }
76 };
77
78 static void __init tl_mr3x20_setup(void)
79 {
80         u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
81         u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
82
83         /* enable power for the USB port */
84         gpio_request(TL_MR3X20_GPIO_USB_POWER, "USB power");
85         gpio_direction_output(TL_MR3X20_GPIO_USB_POWER, 1);
86
87         ar71xx_add_device_m25p80(&tl_mr3x20_flash_data);
88
89         ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(tl_mr3x20_leds_gpio),
90                                         tl_mr3x20_leds_gpio);
91
92         ar71xx_register_gpio_keys_polled(-1, TL_MR3X20_KEYS_POLL_INTERVAL,
93                                          ARRAY_SIZE(tl_mr3x20_gpio_keys),
94                                          tl_mr3x20_gpio_keys);
95
96         ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 1);
97         ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, -1);
98
99         ar71xx_add_device_mdio(0, 0x0);
100
101         /* LAN ports */
102         ar71xx_add_device_eth(1);
103         /* WAN port */
104         ar71xx_add_device_eth(0);
105
106         ar71xx_add_device_usb();
107
108         ap91_pci_init(ee, mac);
109 }
110
111 static void __init tl_mr3220_setup(void)
112 {
113         tl_mr3x20_setup();
114         ap91_pci_setup_wmac_led_pin(1);
115 }
116
117 MIPS_MACHINE(AR71XX_MACH_TL_MR3220, "TL-MR3220", "TP-LINK TL-MR3220",
118              tl_mr3220_setup);
119
120 static void __init tl_mr3420_setup(void)
121 {
122         tl_mr3x20_setup();
123         ap91_pci_setup_wmac_led_pin(0);
124 }
125
126 MIPS_MACHINE(AR71XX_MACH_TL_MR3420, "TL-MR3420", "TP-LINK TL-MR3420",
127              tl_mr3420_setup);