2 * NC-LINK SMART-300 board support
4 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
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.
12 #include <linux/platform_device.h>
13 #include <linux/gpio.h>
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
16 #include <asm/mach-ath79/ag71xx_platform.h>
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "dev-m25p80.h"
24 #include "machtypes.h"
26 #define SMART_300_GPIO_LED_WLAN 13
27 #define SMART_300_GPIO_LED_WAN 18
28 #define SMART_300_GPIO_LED_LAN4 19
29 #define SMART_300_GPIO_LED_LAN3 12
30 #define SMART_300_GPIO_LED_LAN2 21
31 #define SMART_300_GPIO_LED_LAN1 20
32 #define SMART_300_GPIO_LED_SYSTEM 15
33 #define SMART_300_GPIO_LED_POWER 14
35 #define SMART_300_GPIO_BTN_RESET 17
36 #define SMART_300_GPIO_SW_RFKILL 16
38 #define SMART_300_KEYS_POLL_INTERVAL 20 /* msecs */
39 #define SMART_300_KEYS_DEBOUNCE_INTERVAL (3 * SMART_300_KEYS_POLL_INTERVAL)
41 #define SMART_300_GPIO_MASK 0x007fffff
43 static const char *smart_300_part_probes[] = {
48 static struct flash_platform_data smart_300_flash_data = {
49 .part_probes = smart_300_part_probes,
52 static struct gpio_led smart_300_leds_gpio[] __initdata = {
54 .name = "nc-link:green:lan1",
55 .gpio = SMART_300_GPIO_LED_LAN1,
58 .name = "nc-link:green:lan2",
59 .gpio = SMART_300_GPIO_LED_LAN2,
62 .name = "nc-link:green:lan3",
63 .gpio = SMART_300_GPIO_LED_LAN3,
66 .name = "nc-link:green:lan4",
67 .gpio = SMART_300_GPIO_LED_LAN4,
70 .name = "nc-link:green:system",
71 .gpio = SMART_300_GPIO_LED_SYSTEM,
74 .name = "nc-link:green:wan",
75 .gpio = SMART_300_GPIO_LED_WAN,
78 .name = "nc-link:green:wlan",
79 .gpio = SMART_300_GPIO_LED_WLAN,
84 static struct gpio_keys_button smart_300_gpio_keys[] __initdata = {
89 .debounce_interval = SMART_300_KEYS_DEBOUNCE_INTERVAL,
90 .gpio = SMART_300_GPIO_BTN_RESET,
95 static void __init smart_300_setup(void)
97 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
98 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
100 ath79_register_leds_gpio(-1, ARRAY_SIZE(smart_300_leds_gpio),
101 smart_300_leds_gpio);
103 ath79_register_gpio_keys_polled(1, SMART_300_KEYS_POLL_INTERVAL,
104 ARRAY_SIZE(smart_300_gpio_keys),
105 smart_300_gpio_keys);
107 ath79_register_m25p80(&smart_300_flash_data);
109 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
111 ath79_register_mdio(1, 0x0);
113 ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
114 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
116 /* GMAC0 is connected to the PHY0 of the internal switch */
117 ath79_switch_data.phy4_mii_en = 1;
118 ath79_switch_data.phy_poll_mask = BIT(4);
119 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
120 ath79_eth0_data.phy_mask = BIT(4);
121 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
122 ath79_register_eth(0);
124 /* GMAC1 is connected to the internal switch */
125 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
126 ath79_register_eth(1);
128 ath79_register_wmac(ee, mac);
130 gpio_request(SMART_300_GPIO_LED_POWER, "power");
131 gpio_direction_output(SMART_300_GPIO_LED_POWER, GPIOF_OUT_INIT_LOW);
134 MIPS_MACHINE(ATH79_MACH_SMART_300, "SMART-300", "NC-LINK SMART-300",