ar71xx: fix section mismatch in TP-Link Archer C7 v4 support
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-smart-300.c
1 /*
2 * NC-LINK SMART-300 board support
3 *
4 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2014 Imre Kaloz <kaloz@openwrt.org>
6 *
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.
10 */
11
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>
17
18 #include "common.h"
19 #include "dev-eth.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "dev-m25p80.h"
23 #include "dev-wmac.h"
24 #include "machtypes.h"
25
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
34
35 #define SMART_300_GPIO_BTN_RESET 17
36 #define SMART_300_GPIO_SW_RFKILL 16
37
38 #define SMART_300_KEYS_POLL_INTERVAL 20 /* msecs */
39 #define SMART_300_KEYS_DEBOUNCE_INTERVAL (3 * SMART_300_KEYS_POLL_INTERVAL)
40
41 #define SMART_300_GPIO_MASK 0x007fffff
42
43 static const char *smart_300_part_probes[] = {
44 "tp-link",
45 NULL,
46 };
47
48 static struct flash_platform_data smart_300_flash_data = {
49 .part_probes = smart_300_part_probes,
50 };
51
52 static struct gpio_led smart_300_leds_gpio[] __initdata = {
53 {
54 .name = "nc-link:green:lan1",
55 .gpio = SMART_300_GPIO_LED_LAN1,
56 .active_low = 1,
57 }, {
58 .name = "nc-link:green:lan2",
59 .gpio = SMART_300_GPIO_LED_LAN2,
60 .active_low = 1,
61 }, {
62 .name = "nc-link:green:lan3",
63 .gpio = SMART_300_GPIO_LED_LAN3,
64 .active_low = 1,
65 }, {
66 .name = "nc-link:green:lan4",
67 .gpio = SMART_300_GPIO_LED_LAN4,
68 .active_low = 1,
69 }, {
70 .name = "nc-link:green:system",
71 .gpio = SMART_300_GPIO_LED_SYSTEM,
72 .active_low = 1,
73 }, {
74 .name = "nc-link:green:wan",
75 .gpio = SMART_300_GPIO_LED_WAN,
76 .active_low = 1,
77 }, {
78 .name = "nc-link:green:wlan",
79 .gpio = SMART_300_GPIO_LED_WLAN,
80 .active_low = 1,
81 },
82 };
83
84 static struct gpio_keys_button smart_300_gpio_keys[] __initdata = {
85 {
86 .desc = "reset",
87 .type = EV_KEY,
88 .code = KEY_RESTART,
89 .debounce_interval = SMART_300_KEYS_DEBOUNCE_INTERVAL,
90 .gpio = SMART_300_GPIO_BTN_RESET,
91 .active_low = 1,
92 }
93 };
94
95 static void __init smart_300_setup(void)
96 {
97 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
98 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
99
100 ath79_register_leds_gpio(-1, ARRAY_SIZE(smart_300_leds_gpio),
101 smart_300_leds_gpio);
102
103 ath79_register_gpio_keys_polled(1, SMART_300_KEYS_POLL_INTERVAL,
104 ARRAY_SIZE(smart_300_gpio_keys),
105 smart_300_gpio_keys);
106
107 ath79_register_m25p80(&smart_300_flash_data);
108
109 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
110
111 ath79_register_mdio(1, 0x0);
112
113 ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1);
114 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
115
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);
123
124 /* GMAC1 is connected to the internal switch */
125 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
126 ath79_register_eth(1);
127
128 ath79_register_wmac(ee, mac);
129
130 gpio_request(SMART_300_GPIO_LED_POWER, "power");
131 gpio_direction_output(SMART_300_GPIO_LED_POWER, GPIOF_OUT_INIT_LOW);
132 }
133
134 MIPS_MACHINE(ATH79_MACH_SMART_300, "SMART-300", "NC-LINK SMART-300",
135 smart_300_setup);