OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * TP-LINK TL-WR1041 v2 board support |
||
3 | * |
||
4 | * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org> |
||
5 | * Copyright (C) 2011-2012 Anan Huang <axishero@foxmail.com> |
||
6 | * |
||
7 | * This program is free software; you can redistribute it and/or modify it |
||
8 | * under the terms of the GNU General Public License version 2 as published |
||
9 | * by the Free Software Foundation. |
||
10 | */ |
||
11 | |||
12 | #include <linux/pci.h> |
||
13 | #include <linux/phy.h> |
||
14 | #include <linux/platform_device.h> |
||
15 | #include <linux/ath9k_platform.h> |
||
16 | #include <linux/ar8216_platform.h> |
||
17 | |||
18 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
19 | |||
20 | #include "common.h" |
||
21 | #include "dev-ap9x-pci.h" |
||
22 | #include "dev-eth.h" |
||
23 | #include "dev-gpio-buttons.h" |
||
24 | #include "dev-leds-gpio.h" |
||
25 | #include "dev-m25p80.h" |
||
26 | #include "dev-spi.h" |
||
27 | #include "dev-wmac.h" |
||
28 | #include "machtypes.h" |
||
29 | |||
30 | #define TL_WR1041NV2_GPIO_BTN_RESET 14 |
||
31 | #define TL_WR1041NV2_GPIO_LED_WPS 13 |
||
32 | #define TL_WR1041NV2_GPIO_LED_WLAN 11 |
||
33 | |||
34 | #define TL_WR1041NV2_GPIO_LED_SYSTEM 12 |
||
35 | |||
36 | #define TL_WR1041NV2_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
37 | #define TL_WR1041NV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1041NV2_KEYS_POLL_INTERVAL) |
||
38 | |||
39 | #define TL_WR1041NV2_PCIE_CALDATA_OFFSET 0x5000 |
||
40 | |||
41 | static const char *tl_wr1041nv2_part_probes[] = { |
||
42 | "tp-link", |
||
43 | NULL, |
||
44 | }; |
||
45 | |||
46 | static struct flash_platform_data tl_wr1041nv2_flash_data = { |
||
47 | .part_probes = tl_wr1041nv2_part_probes, |
||
48 | }; |
||
49 | |||
50 | static struct gpio_led tl_wr1041nv2_leds_gpio[] __initdata = { |
||
51 | { |
||
52 | .name = "tp-link:green:system", |
||
53 | .gpio = TL_WR1041NV2_GPIO_LED_SYSTEM, |
||
54 | .active_low = 1, |
||
55 | }, { |
||
56 | .name = "tp-link:green:wps", |
||
57 | .gpio = TL_WR1041NV2_GPIO_LED_WPS, |
||
58 | .active_low = 1, |
||
59 | }, { |
||
60 | .name = "tp-link:green:wlan", |
||
61 | .gpio = TL_WR1041NV2_GPIO_LED_WLAN, |
||
62 | .active_low = 1, |
||
63 | } |
||
64 | }; |
||
65 | |||
66 | static struct gpio_keys_button tl_wr1041nv2_gpio_keys[] __initdata = { |
||
67 | { |
||
68 | .desc = "reset", |
||
69 | .type = EV_KEY, |
||
70 | .code = KEY_RESTART, |
||
71 | .debounce_interval = TL_WR1041NV2_KEYS_DEBOUNCE_INTERVAL, |
||
72 | .gpio = TL_WR1041NV2_GPIO_BTN_RESET, |
||
73 | .active_low = 1, |
||
74 | } |
||
75 | }; |
||
76 | |||
77 | static const struct ar8327_led_info tl_wr1041n_leds_ar8327[] = { |
||
78 | AR8327_LED_INFO(PHY0_0, HW, "tp-link:green:wan"), |
||
79 | AR8327_LED_INFO(PHY1_0, HW, "tp-link:green:lan1"), |
||
80 | AR8327_LED_INFO(PHY2_0, HW, "tp-link:green:lan2"), |
||
81 | AR8327_LED_INFO(PHY3_0, HW, "tp-link:green:lan3"), |
||
82 | AR8327_LED_INFO(PHY4_0, HW, "tp-link:green:lan4"), |
||
83 | }; |
||
84 | |||
85 | static struct ar8327_led_cfg wr1041n_v2_ar8327_led_cfg = { |
||
86 | .led_ctrl0 = 0xcf35cf35, /* LED0: blink at 10/100/1000M */ |
||
87 | .led_ctrl1 = 0xcf35cf35, /* LED1: blink at 10/100/1000M: anyway, no LED1 on tl-wr1041n */ |
||
88 | .led_ctrl2 = 0xcf35cf35, /* LED2: blink at 10/100/1000M: anyway, no LED2 on tl-wr1041n */ |
||
89 | .led_ctrl3 = 0x03ffff00, /* Pattern enabled for LED 0-2 of port 1-3 */ |
||
90 | .open_drain = true, |
||
91 | }; |
||
92 | |||
93 | static struct ar8327_pad_cfg db120_ar8327_pad0_cfg = { |
||
94 | .mode = AR8327_PAD_MAC_RGMII, |
||
95 | .txclk_delay_en = true, |
||
96 | .rxclk_delay_en = true, |
||
97 | .txclk_delay_sel = AR8327_CLK_DELAY_SEL1, |
||
98 | .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2, |
||
99 | }; |
||
100 | |||
101 | static struct ar8327_platform_data db120_ar8327_data = { |
||
102 | .pad0_cfg = &db120_ar8327_pad0_cfg, |
||
103 | .port0_cfg = { |
||
104 | .force_link = 1, |
||
105 | .speed = AR8327_PORT_SPEED_1000, |
||
106 | .duplex = 1, |
||
107 | .txpause = 1, |
||
108 | .rxpause = 1, |
||
109 | }, |
||
110 | .led_cfg = &wr1041n_v2_ar8327_led_cfg, |
||
111 | .num_leds = ARRAY_SIZE(tl_wr1041n_leds_ar8327), |
||
112 | .leds = tl_wr1041n_leds_ar8327 |
||
113 | }; |
||
114 | |||
115 | static struct mdio_board_info db120_mdio0_info[] = { |
||
116 | { |
||
117 | .bus_id = "ag71xx-mdio.0", |
||
3 | office | 118 | .phy_addr = 0, |
1 | office | 119 | .platform_data = &db120_ar8327_data, |
120 | }, |
||
121 | }; |
||
122 | |||
123 | static void __init tl_wr1041nv2_setup(void) |
||
124 | { |
||
125 | u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); |
||
126 | u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); |
||
127 | |||
128 | ath79_register_m25p80(&tl_wr1041nv2_flash_data); |
||
129 | |||
130 | ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1041nv2_leds_gpio), |
||
131 | tl_wr1041nv2_leds_gpio); |
||
132 | ath79_register_gpio_keys_polled(-1, TL_WR1041NV2_KEYS_POLL_INTERVAL, |
||
133 | ARRAY_SIZE(tl_wr1041nv2_gpio_keys), |
||
134 | tl_wr1041nv2_gpio_keys); |
||
135 | ath79_register_wmac(ee, mac); |
||
136 | |||
137 | ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 | |
||
138 | AR934X_ETH_CFG_SW_ONLY_MODE); |
||
139 | |||
140 | ath79_register_mdio(1, 0x0); |
||
141 | ath79_register_mdio(0, 0x0); |
||
142 | |||
143 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1); |
||
144 | |||
145 | mdiobus_register_board_info(db120_mdio0_info, |
||
146 | ARRAY_SIZE(db120_mdio0_info)); |
||
147 | |||
148 | /* GMAC0 is connected to an AR8327 switch */ |
||
149 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
||
150 | ath79_eth0_data.phy_mask = BIT(0); |
||
151 | ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; |
||
152 | ath79_eth0_pll_data.pll_1000 = 0x06000000; |
||
153 | ath79_register_eth(0); |
||
154 | } |
||
155 | |||
156 | MIPS_MACHINE(ATH79_MACH_TL_WR1041N_V2, "TL-WR1041N-v2", |
||
157 | "TP-LINK TL-WR1041N v2", tl_wr1041nv2_setup); |