2 * EnGenius ENS202EXT board support
4 * Copyright (C) 2017 Marty Plummer <netz.kernel@gmail.com>
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.
11 #include <linux/gpio.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/platform_device.h>
16 #include <asm/mach-ath79/ar71xx_regs.h>
17 #include <asm/mach-ath79/ath79.h>
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
25 #include "machtypes.h"
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
34 #define ENS202_GPIO_BTN_RESET 1
36 #define ENS202_KEYS_POLL_INTERVAL 20 /* msecs */
37 #define ENS202_KEYS_DEBOUNCE_INTERVAL (3 * ENS202_KEYS_POLL_INTERVAL)
39 static struct gpio_led ens202_leds_gpio[] __initdata = {
41 .name = "engenius:amber:wlan1",
42 .gpio = ENS202_GPIO_LED_WLAN1,
45 .name = "engenius:red:wlan2",
46 .gpio = ENS202_GPIO_LED_WLAN2,
49 .name = "engenius:amber:wlan3",
50 .gpio = ENS202_GPIO_LED_WLAN3,
53 .name = "engenius:green:wlan4",
54 .gpio = ENS202_GPIO_LED_WLAN4,
57 .name = "engenius:amber:power",
58 .gpio = ENS202_GPIO_LED_POWER,
63 static struct gpio_keys_button ens202_gpio_keys[] __initdata = {
68 .debounce_interval = ENS202_KEYS_DEBOUNCE_INTERVAL,
69 .gpio = ENS202_GPIO_BTN_RESET,
74 static void __init ens202_setup(void)
76 const char *nvram = (char *) KSEG1ADDR(0x1f040000);
79 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
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);
88 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
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);
96 ath79_register_leds_gpio(-1, ARRAY_SIZE(ens202_leds_gpio),
98 ath79_register_gpio_keys_polled(-1, ENS202_KEYS_POLL_INTERVAL,
99 ARRAY_SIZE(ens202_gpio_keys),
102 ath79_register_m25p80(NULL);
104 ath79_register_wmac(art + 0x1000, NULL);
106 ath79_register_mdio(1, 0);
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;
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;
119 ath79_register_eth(0);
120 ath79_register_eth(1);
123 MIPS_MACHINE(ATH79_MACH_ENS202EXT, "ENS202EXT", "EnGenius ENS202EXT",