OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * EnGenius ENS202EXT board support |
||
3 | * |
||
4 | * Copyright (C) 2017 Marty Plummer <netz.kernel@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/mtd/mtd.h> |
||
13 | #include <linux/mtd/partitions.h> |
||
14 | #include <linux/platform_device.h> |
||
15 | |||
16 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
17 | #include <asm/mach-ath79/ath79.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-wmac.h" |
||
25 | #include "machtypes.h" |
||
26 | #include "nvram.h" |
||
27 | |||
28 | #define ENS202_GPIO_LED_WLAN4 0 |
||
29 | #define ENS202_GPIO_LED_POWER 14 |
||
30 | #define ENS202_GPIO_LED_WLAN2 16 |
||
31 | #define ENS202_GPIO_LED_WLAN3 17 |
||
32 | #define ENS202_GPIO_LED_WLAN1 18 |
||
33 | |||
34 | #define ENS202_GPIO_BTN_RESET 1 |
||
35 | |||
36 | #define ENS202_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
37 | #define ENS202_KEYS_DEBOUNCE_INTERVAL (3 * ENS202_KEYS_POLL_INTERVAL) |
||
38 | |||
39 | static struct gpio_led ens202_leds_gpio[] __initdata = { |
||
40 | { |
||
41 | .name = "engenius:amber:wlan1", |
||
42 | .gpio = ENS202_GPIO_LED_WLAN1, |
||
43 | .active_low = 1, |
||
44 | }, { |
||
45 | .name = "engenius:red:wlan2", |
||
46 | .gpio = ENS202_GPIO_LED_WLAN2, |
||
47 | .active_low = 1, |
||
48 | }, { |
||
49 | .name = "engenius:amber:wlan3", |
||
50 | .gpio = ENS202_GPIO_LED_WLAN3, |
||
51 | .active_low = 1, |
||
52 | }, { |
||
53 | .name = "engenius:green:wlan4", |
||
54 | .gpio = ENS202_GPIO_LED_WLAN4, |
||
55 | .active_low = 1, |
||
56 | }, { |
||
57 | .name = "engenius:amber:power", |
||
58 | .gpio = ENS202_GPIO_LED_POWER, |
||
59 | .active_low = 1, |
||
60 | } |
||
61 | }; |
||
62 | |||
63 | static struct gpio_keys_button ens202_gpio_keys[] __initdata = { |
||
64 | { |
||
65 | .desc = "reset", |
||
66 | .type = EV_KEY, |
||
67 | .code = KEY_RESTART, |
||
68 | .debounce_interval = ENS202_KEYS_DEBOUNCE_INTERVAL, |
||
69 | .gpio = ENS202_GPIO_BTN_RESET, |
||
70 | .active_low = 1, |
||
71 | } |
||
72 | }; |
||
73 | |||
74 | static void __init ens202_setup(void) |
||
75 | { |
||
76 | const char *nvram = (char *) KSEG1ADDR(0x1f040000); |
||
77 | u8 mac_buff[6]; |
||
78 | u8 *mac = NULL; |
||
79 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
||
80 | |||
81 | if (ath79_nvram_parse_mac_addr(nvram, 0x10000, |
||
82 | "ethaddr=", mac_buff) == 0) { |
||
83 | ath79_init_mac(ath79_eth0_data.mac_addr, mac_buff, 0); |
||
84 | ath79_init_mac(ath79_eth1_data.mac_addr, mac_buff, 1); |
||
85 | mac = mac_buff; |
||
86 | } |
||
87 | |||
88 | ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE); |
||
89 | |||
90 | ath79_gpio_output_select(ENS202_GPIO_LED_POWER, AR934X_GPIO_OUT_GPIO); |
||
91 | ath79_gpio_output_select(ENS202_GPIO_LED_WLAN1, AR934X_GPIO_OUT_GPIO); |
||
92 | ath79_gpio_output_select(ENS202_GPIO_LED_WLAN2, AR934X_GPIO_OUT_GPIO); |
||
93 | ath79_gpio_output_select(ENS202_GPIO_LED_WLAN3, AR934X_GPIO_OUT_GPIO); |
||
94 | ath79_gpio_output_select(ENS202_GPIO_LED_WLAN4, AR934X_GPIO_OUT_GPIO); |
||
95 | |||
96 | ath79_register_leds_gpio(-1, ARRAY_SIZE(ens202_leds_gpio), |
||
97 | ens202_leds_gpio); |
||
98 | ath79_register_gpio_keys_polled(-1, ENS202_KEYS_POLL_INTERVAL, |
||
99 | ARRAY_SIZE(ens202_gpio_keys), |
||
100 | ens202_gpio_keys); |
||
101 | |||
102 | ath79_register_m25p80(NULL); |
||
103 | |||
104 | ath79_register_wmac(art + 0x1000, NULL); |
||
105 | |||
106 | ath79_register_mdio(1, 0); |
||
107 | |||
108 | ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 | |
||
109 | AR934X_ETH_CFG_SW_ONLY_MODE); |
||
110 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII; |
||
111 | ath79_eth0_data.phy_mask = BIT(0); |
||
112 | ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev; |
||
113 | ath79_eth0_pll_data.pll_1000 = 0x06000000; |
||
114 | |||
115 | ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII; |
||
116 | ath79_eth1_data.speed = SPEED_1000; |
||
117 | ath79_eth1_data.duplex = DUPLEX_FULL; |
||
118 | |||
119 | ath79_register_eth(0); |
||
120 | ath79_register_eth(1); |
||
121 | } |
||
122 | |||
123 | MIPS_MACHINE(ATH79_MACH_ENS202EXT, "ENS202EXT", "EnGenius ENS202EXT", |
||
124 | ens202_setup); |