OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * YunCore T830 board support |
||
3 | * |
||
4 | * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com> |
||
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 | #include <linux/platform_device.h> |
||
13 | |||
14 | #include <asm/mach-ath79/ath79.h> |
||
15 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
16 | |||
17 | #include "common.h" |
||
18 | #include "dev-eth.h" |
||
19 | #include "dev-gpio-buttons.h" |
||
20 | #include "dev-leds-gpio.h" |
||
21 | #include "dev-m25p80.h" |
||
22 | #include "dev-usb.h" |
||
23 | #include "dev-wmac.h" |
||
24 | #include "machtypes.h" |
||
25 | |||
26 | #define T830_GPIO_LED_LAN1 16 |
||
27 | #define T830_GPIO_LED_LAN2 15 |
||
28 | #define T830_GPIO_LED_LAN3 14 |
||
29 | #define T830_GPIO_LED_LAN4 11 |
||
30 | #define T830_GPIO_LED_USB 13 |
||
31 | #define T830_GPIO_LED_WAN 4 |
||
32 | #define T830_GPIO_LED_WLAN 12 |
||
33 | |||
34 | #define T830_GPIO_BTN_RESET 17 |
||
35 | |||
36 | #define T830_KEYS_POLL_INTERVAL 20 /* msec */ |
||
37 | #define T830_KEYS_DEBOUNCE_INTERVAL (3 * T830_KEYS_POLL_INTERVAL) |
||
38 | |||
39 | #define T830_WMAC_CALDATA_OFFSET 0x1000 |
||
40 | |||
41 | static struct gpio_led t830_gpio_leds[] __initdata = { |
||
42 | { |
||
43 | .name = "t830:green:lan1", |
||
44 | .gpio = T830_GPIO_LED_LAN1, |
||
45 | .active_low = 1, |
||
46 | }, { |
||
47 | .name = "t830:green:lan2", |
||
48 | .gpio = T830_GPIO_LED_LAN2, |
||
49 | .active_low = 1, |
||
50 | }, { |
||
51 | .name = "t830:green:lan3", |
||
52 | .gpio = T830_GPIO_LED_LAN3, |
||
53 | .active_low = 1, |
||
54 | }, { |
||
55 | .name = "t830:green:lan4", |
||
56 | .gpio = T830_GPIO_LED_LAN4, |
||
57 | .active_low = 1, |
||
58 | }, { |
||
59 | .name = "t830:green:usb", |
||
60 | .gpio = T830_GPIO_LED_USB, |
||
61 | .active_low = 1, |
||
62 | .default_state = LEDS_GPIO_DEFSTATE_KEEP, |
||
63 | }, { |
||
64 | .name = "t830:green:wan", |
||
65 | .gpio = T830_GPIO_LED_WAN, |
||
66 | .active_low = 1, |
||
67 | }, { |
||
68 | .name = "t830:green:wlan", |
||
69 | .gpio = T830_GPIO_LED_WLAN, |
||
70 | .active_low = 1, |
||
71 | }, |
||
72 | }; |
||
73 | |||
74 | static struct gpio_keys_button t830_gpio_keys[] __initdata = { |
||
75 | { |
||
76 | .desc = "reset", |
||
77 | .type = EV_KEY, |
||
78 | .code = KEY_RESTART, |
||
79 | .debounce_interval = T830_KEYS_DEBOUNCE_INTERVAL, |
||
80 | .gpio = T830_GPIO_BTN_RESET, |
||
81 | .active_low = 1, |
||
82 | }, |
||
83 | }; |
||
84 | |||
85 | static void __init t830_setup(void) |
||
86 | { |
||
87 | u8 *art = (u8 *) KSEG1ADDR(0x1fff1000); |
||
88 | u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000); |
||
89 | |||
90 | ath79_register_m25p80(NULL); |
||
91 | |||
92 | ath79_setup_ar933x_phy4_switch(false, false); |
||
93 | |||
94 | ath79_register_mdio(0, 0x0); |
||
95 | |||
96 | ath79_switch_data.phy4_mii_en = 1; |
||
97 | ath79_switch_data.phy_poll_mask |= BIT(4); |
||
98 | |||
99 | /* LAN */ |
||
100 | ath79_eth1_data.duplex = DUPLEX_FULL; |
||
101 | ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; |
||
102 | ath79_init_mac(ath79_eth1_data.mac_addr, mac + 6, 0); |
||
103 | ath79_register_eth(1); |
||
104 | |||
105 | /* WAN */ |
||
106 | ath79_eth0_data.duplex = DUPLEX_FULL; |
||
107 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; |
||
108 | ath79_eth0_data.phy_mask = BIT(4); |
||
109 | ath79_eth0_data.speed = SPEED_100; |
||
110 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0); |
||
111 | ath79_register_eth(0); |
||
112 | |||
113 | ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE, |
||
114 | AR934X_GPIO_FUNC_CLK_OBS4_EN); |
||
115 | |||
116 | ath79_register_leds_gpio(-1, ARRAY_SIZE(t830_gpio_leds), |
||
117 | t830_gpio_leds); |
||
118 | |||
119 | ath79_register_gpio_keys_polled(-1, T830_KEYS_POLL_INTERVAL, |
||
120 | ARRAY_SIZE(t830_gpio_keys), |
||
121 | t830_gpio_keys); |
||
122 | |||
123 | ath79_register_usb(); |
||
124 | ath79_register_wmac(art, NULL); |
||
125 | } |
||
126 | |||
127 | MIPS_MACHINE(ATH79_MACH_T830, "T830", "YunCore T830", t830_setup); |