OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * Zbtlink ZBT-WE1526 board support |
||
3 | * |
||
4 | * Copyright (C) 2016 Piotr Dymacz <pepe2k@gmail.com> |
||
5 | * |
||
6 | * Based on mach-dr531.c and mach-tl-wr841n-v9.c |
||
7 | * |
||
8 | * This program is free software; you can redistribute it and/or modify it |
||
9 | * under the terms of the GNU General Public License version 2 as published |
||
10 | * by the Free Software Foundation. |
||
11 | */ |
||
12 | |||
13 | #include <linux/gpio.h> |
||
14 | #include <linux/platform_device.h> |
||
15 | |||
16 | #include <asm/mach-ath79/ath79.h> |
||
17 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
18 | |||
19 | #include "common.h" |
||
20 | #include "dev-eth.h" |
||
21 | #include "dev-gpio-buttons.h" |
||
22 | #include "dev-leds-gpio.h" |
||
23 | #include "dev-m25p80.h" |
||
24 | #include "dev-usb.h" |
||
25 | #include "dev-wmac.h" |
||
26 | #include "machtypes.h" |
||
27 | |||
28 | #define ZBT_WE1526_GPIO_LED_STATUS 13 |
||
29 | #define ZBT_WE1526_GPIO_LED_LAN1 16 |
||
30 | #define ZBT_WE1526_GPIO_LED_LAN2 15 |
||
31 | #define ZBT_WE1526_GPIO_LED_LAN3 14 |
||
32 | #define ZBT_WE1526_GPIO_LED_LAN4 11 |
||
33 | #define ZBT_WE1526_GPIO_LED_WAN 4 |
||
34 | #define ZBT_WE1526_GPIO_LED_WLAN 12 |
||
35 | |||
36 | #define ZBT_WE1526_GPIO_BTN_RESET 17 |
||
37 | |||
38 | #define ZBT_WE1526_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
39 | #define ZBT_WE1526_KEYS_DEBOUNCE_INTERVAL \ |
||
40 | (3 * ZBT_WE1526_KEYS_POLL_INTERVAL) |
||
41 | |||
42 | #define ZBT_WE1526_MAC0_OFFSET 0x0 |
||
43 | #define ZBT_WE1526_MAC1_OFFSET 0x6 |
||
44 | #define ZBT_WE1526_WMAC_CALDATA_OFFSET 0x1000 |
||
45 | |||
46 | static struct gpio_led zbt_we1526_leds_gpio[] __initdata = { |
||
47 | { |
||
48 | .name = "zbt-we1526:green:status", |
||
49 | .gpio = ZBT_WE1526_GPIO_LED_STATUS, |
||
50 | .active_low = 1, |
||
51 | }, |
||
52 | { |
||
53 | .name = "zbt-we1526:green:lan1", |
||
54 | .gpio = ZBT_WE1526_GPIO_LED_LAN1, |
||
55 | .active_low = 1, |
||
56 | }, |
||
57 | { |
||
58 | .name = "zbt-we1526:green:lan2", |
||
59 | .gpio = ZBT_WE1526_GPIO_LED_LAN2, |
||
60 | .active_low = 1, |
||
61 | }, |
||
62 | { |
||
63 | .name = "zbt-we1526:green:lan3", |
||
64 | .gpio = ZBT_WE1526_GPIO_LED_LAN3, |
||
65 | .active_low = 1, |
||
66 | }, |
||
67 | { |
||
68 | .name = "zbt-we1526:green:lan4", |
||
69 | .gpio = ZBT_WE1526_GPIO_LED_LAN4, |
||
70 | .active_low = 1, |
||
71 | }, |
||
72 | { |
||
73 | .name = "zbt-we1526:green:wan", |
||
74 | .gpio = ZBT_WE1526_GPIO_LED_WAN, |
||
75 | .active_low = 1, |
||
76 | }, |
||
77 | { |
||
78 | .name = "zbt-we1526:green:wlan", |
||
79 | .gpio = ZBT_WE1526_GPIO_LED_WLAN, |
||
80 | .active_low = 1, |
||
81 | }, |
||
82 | }; |
||
83 | |||
84 | static struct gpio_keys_button zbt_we1526_gpio_keys[] __initdata = { |
||
85 | { |
||
86 | .desc = "reset", |
||
87 | .type = EV_KEY, |
||
88 | .code = KEY_RESTART, |
||
89 | .debounce_interval = ZBT_WE1526_KEYS_DEBOUNCE_INTERVAL, |
||
90 | .gpio = ZBT_WE1526_GPIO_BTN_RESET, |
||
91 | .active_low = 1, |
||
92 | }, |
||
93 | }; |
||
94 | |||
95 | static void __init zbt_we1526_gpio_setup(void) |
||
96 | { |
||
97 | /* For LED on GPIO4 */ |
||
98 | ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN); |
||
99 | ath79_gpio_output_select(ZBT_WE1526_GPIO_LED_WAN, 0); |
||
100 | |||
101 | ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_STATUS, true); |
||
102 | ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN1, true); |
||
103 | ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN2, true); |
||
104 | ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN3, true); |
||
105 | ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN4, true); |
||
106 | ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_WAN, true); |
||
107 | ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_WLAN, true); |
||
108 | |||
109 | ath79_register_leds_gpio(-1, ARRAY_SIZE(zbt_we1526_leds_gpio), |
||
110 | zbt_we1526_leds_gpio); |
||
111 | |||
112 | ath79_register_gpio_keys_polled(-1, ZBT_WE1526_KEYS_POLL_INTERVAL, |
||
113 | ARRAY_SIZE(zbt_we1526_gpio_keys), |
||
114 | zbt_we1526_gpio_keys); |
||
115 | } |
||
116 | |||
117 | static void __init zbt_we1526_setup(void) |
||
118 | { |
||
119 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
||
120 | |||
121 | ath79_register_m25p80(NULL); |
||
122 | |||
123 | zbt_we1526_gpio_setup(); |
||
124 | |||
125 | ath79_setup_ar933x_phy4_switch(false, false); |
||
126 | |||
127 | ath79_register_mdio(0, 0x0); |
||
128 | |||
129 | /* LAN */ |
||
130 | ath79_eth1_data.duplex = DUPLEX_FULL; |
||
131 | ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; |
||
132 | ath79_switch_data.phy_poll_mask |= BIT(4); |
||
133 | ath79_init_mac(ath79_eth1_data.mac_addr, |
||
134 | art + ZBT_WE1526_MAC0_OFFSET, 0); |
||
135 | ath79_register_eth(1); |
||
136 | |||
137 | /* WAN */ |
||
138 | ath79_switch_data.phy4_mii_en = 1; |
||
139 | ath79_eth0_data.duplex = DUPLEX_FULL; |
||
140 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; |
||
141 | ath79_eth0_data.phy_mask = BIT(4); |
||
142 | ath79_eth0_data.speed = SPEED_100; |
||
143 | ath79_init_mac(ath79_eth0_data.mac_addr, |
||
144 | art + ZBT_WE1526_MAC1_OFFSET, 0); |
||
145 | ath79_register_eth(0); |
||
146 | |||
147 | ath79_register_wmac(art + ZBT_WE1526_WMAC_CALDATA_OFFSET, NULL); |
||
148 | |||
149 | ath79_register_usb(); |
||
150 | } |
||
151 | |||
152 | MIPS_MACHINE(ATH79_MACH_ZBT_WE1526, "ZBT-WE1526", "Zbtlink ZBT-WE1526", |
||
153 | zbt_we1526_setup); |