OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * TP-LINK TL-WR2543N/ND board support |
||
3 | * |
||
4 | * Copyright (C) 2011-2012 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/platform_device.h> |
||
12 | #include <linux/rtl8367.h> |
||
13 | |||
14 | #include <asm/mach-ath79/ath79.h> |
||
15 | |||
16 | #include "dev-eth.h" |
||
17 | #include "dev-ap9x-pci.h" |
||
18 | #include "dev-gpio-buttons.h" |
||
19 | #include "dev-leds-gpio.h" |
||
20 | #include "dev-m25p80.h" |
||
21 | #include "dev-usb.h" |
||
22 | #include "machtypes.h" |
||
23 | |||
24 | #define TL_WR2543N_GPIO_LED_WPS 0 |
||
25 | #define TL_WR2543N_GPIO_LED_USB 8 |
||
26 | |||
27 | /* The WLAN LEDs use GPIOs on the discrete AR9380 wmac */ |
||
28 | #define TL_WR2543N_GPIO_WMAC_LED_WLAN2G 0 |
||
29 | #define TL_WR2543N_GPIO_WMAC_LED_WLAN5G 1 |
||
30 | |||
31 | #define TL_WR2543N_GPIO_BTN_RESET 11 |
||
32 | #define TL_WR2543N_GPIO_BTN_WPS 12 |
||
33 | |||
34 | #define TL_WR2543N_GPIO_RTL8367_SDA 1 |
||
35 | #define TL_WR2543N_GPIO_RTL8367_SCK 6 |
||
36 | |||
37 | #define TL_WR2543N_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
38 | #define TL_WR2543N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR2543N_KEYS_POLL_INTERVAL) |
||
39 | |||
40 | static const char *tl_wr2543n_part_probes[] = { |
||
41 | "tp-link", |
||
42 | NULL, |
||
43 | }; |
||
44 | |||
45 | static struct flash_platform_data tl_wr2543n_flash_data = { |
||
46 | .part_probes = tl_wr2543n_part_probes, |
||
47 | }; |
||
48 | |||
49 | static struct gpio_led tl_wr2543n_leds_gpio[] __initdata = { |
||
50 | { |
||
51 | .name = "tp-link:green:usb", |
||
52 | .gpio = TL_WR2543N_GPIO_LED_USB, |
||
53 | .active_low = 1, |
||
54 | }, { |
||
55 | .name = "tp-link:green:wps", |
||
56 | .gpio = TL_WR2543N_GPIO_LED_WPS, |
||
57 | .active_low = 1, |
||
58 | } |
||
59 | }; |
||
60 | |||
61 | static struct gpio_led tl_wr2543n_wmac_leds_gpio[] = { |
||
62 | { |
||
63 | .name = "tp-link:green:wlan2g", |
||
64 | .gpio = TL_WR2543N_GPIO_WMAC_LED_WLAN2G, |
||
65 | .active_low = 1, |
||
66 | }, |
||
67 | { |
||
68 | .name = "tp-link:green:wlan5g", |
||
69 | .gpio = TL_WR2543N_GPIO_WMAC_LED_WLAN5G, |
||
70 | .active_low = 1, |
||
71 | }, |
||
72 | }; |
||
73 | |||
74 | static struct gpio_keys_button tl_wr2543n_gpio_keys[] __initdata = { |
||
75 | { |
||
76 | .desc = "reset", |
||
77 | .type = EV_KEY, |
||
78 | .code = KEY_RESTART, |
||
79 | .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL, |
||
80 | .gpio = TL_WR2543N_GPIO_BTN_RESET, |
||
81 | .active_low = 1, |
||
82 | }, { |
||
83 | .desc = "wps", |
||
84 | .type = EV_KEY, |
||
85 | .code = KEY_WPS_BUTTON, |
||
86 | .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL, |
||
87 | .gpio = TL_WR2543N_GPIO_BTN_WPS, |
||
88 | .active_low = 1, |
||
89 | } |
||
90 | }; |
||
91 | |||
92 | static struct rtl8367_extif_config tl_wr2543n_rtl8367_extif0_cfg = { |
||
93 | .mode = RTL8367_EXTIF_MODE_RGMII, |
||
94 | .txdelay = 1, |
||
95 | .rxdelay = 0, |
||
96 | .ability = { |
||
97 | .force_mode = 1, |
||
98 | .txpause = 1, |
||
99 | .rxpause = 1, |
||
100 | .link = 1, |
||
101 | .duplex = 1, |
||
102 | .speed = RTL8367_PORT_SPEED_1000, |
||
103 | }, |
||
104 | }; |
||
105 | |||
106 | static struct rtl8367_platform_data tl_wr2543n_rtl8367_data = { |
||
107 | .gpio_sda = TL_WR2543N_GPIO_RTL8367_SDA, |
||
108 | .gpio_sck = TL_WR2543N_GPIO_RTL8367_SCK, |
||
109 | .extif0_cfg = &tl_wr2543n_rtl8367_extif0_cfg, |
||
110 | }; |
||
111 | |||
112 | static struct platform_device tl_wr2543n_rtl8367_device = { |
||
113 | .name = RTL8367_DRIVER_NAME, |
||
114 | .id = -1, |
||
115 | .dev = { |
||
116 | .platform_data = &tl_wr2543n_rtl8367_data, |
||
117 | } |
||
118 | }; |
||
119 | |||
120 | static void __init tl_wr2543n_setup(void) |
||
121 | { |
||
122 | u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); |
||
123 | u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); |
||
124 | |||
125 | ath79_register_m25p80(&tl_wr2543n_flash_data); |
||
126 | ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr2543n_leds_gpio), |
||
127 | tl_wr2543n_leds_gpio); |
||
128 | ath79_register_gpio_keys_polled(-1, TL_WR2543N_KEYS_POLL_INTERVAL, |
||
129 | ARRAY_SIZE(tl_wr2543n_gpio_keys), |
||
130 | tl_wr2543n_gpio_keys); |
||
131 | ath79_register_usb(); |
||
132 | |||
133 | ap9x_pci_setup_wmac_leds(0, tl_wr2543n_wmac_leds_gpio, |
||
134 | ARRAY_SIZE(tl_wr2543n_wmac_leds_gpio)); |
||
135 | ap91_pci_init(eeprom, mac); |
||
136 | |||
137 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1); |
||
138 | ath79_eth0_data.mii_bus_dev = &tl_wr2543n_rtl8367_device.dev; |
||
139 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
||
140 | ath79_eth0_data.speed = SPEED_1000; |
||
141 | ath79_eth0_data.duplex = DUPLEX_FULL; |
||
142 | ath79_eth0_pll_data.pll_1000 = 0x1a000000; |
||
143 | |||
144 | ath79_register_eth(0); |
||
145 | |||
146 | platform_device_register(&tl_wr2543n_rtl8367_device); |
||
147 | } |
||
148 | |||
149 | MIPS_MACHINE(ATH79_MACH_TL_WR2543N, "TL-WR2543N", "TP-LINK TL-WR2543N/ND", |
||
150 | tl_wr2543n_setup); |