ar8216: Fix problem with AR8337 MAC swap handling
[openwrt/svn-archive/archive.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-f9k1115v2.c
1 /*
2 * Belkin AC1750DB (F9K1115V2) board support
3 *
4 * Copyright (C) 2014 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/gpio.h>
13 #include <linux/platform_device.h>
14 #include <linux/ar8216_platform.h>
15
16 #include <asm/mach-ath79/ar71xx_regs.h>
17
18 #include "common.h"
19 #include "pci.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-eth.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
24 #include "dev-usb.h"
25 #include "dev-wmac.h"
26 #include "machtypes.h"
27
28 #define F9K1115V2_GPIO_LED_USB2 4
29 #define F9K1115V2_GPIO_LED_WPS_AMBER 14
30 #define F9K1115V2_GPIO_LED_STATUS_AMBER 15
31 #define F9K1115V2_GPIO_LED_WPS_BLUE 19
32 #define F9K1115V2_GPIO_LED_STATUS_BLUE 20
33
34 #define F9K1115V2_GPIO_BTN_WPS 16
35 #define F9K1115V2_GPIO_BTN_RESET 17
36
37 #define F9K1115V2_GPIO_USB2_POWER 21
38
39 #define F9K1115V2_KEYS_POLL_INTERVAL 20 /* msecs */
40 #define F9K1115V2_KEYS_DEBOUNCE_INTERVAL (3 * F9K1115V2_KEYS_POLL_INTERVAL)
41
42 #define F9K1115V2_WAN_MAC_OFFSET 0
43 #define F9K1115V2_LAN_MAC_OFFSET 6
44 #define F9K1115V2_WMAC_CALDATA_OFFSET 0x1000
45 #define F9K1115V2_PCIE_CALDATA_OFFSET 0x5000
46
47 static struct gpio_led f9k1115v2_leds_gpio[] __initdata = {
48 {
49 .name = "belkin:amber:status",
50 .gpio = F9K1115V2_GPIO_LED_STATUS_AMBER,
51 .active_low = 1,
52 },
53 {
54 .name = "belkin:blue:status",
55 .gpio = F9K1115V2_GPIO_LED_STATUS_BLUE,
56 .active_low = 1,
57 },
58 {
59 .name = "belkin:blue:wps",
60 .gpio = F9K1115V2_GPIO_LED_WPS_BLUE,
61 .active_low = 1,
62 },
63 {
64 .name = "belkin:amber:wps",
65 .gpio = F9K1115V2_GPIO_LED_WPS_AMBER,
66 .active_low = 1,
67 },
68 {
69 .name = "belkin:green:usb2",
70 .gpio = F9K1115V2_GPIO_LED_USB2,
71 .active_low = 1,
72 },
73 };
74
75 static struct gpio_keys_button f9k1115v2_gpio_keys[] __initdata = {
76 {
77 .desc = "Reset button",
78 .type = EV_KEY,
79 .code = KEY_RESTART,
80 .debounce_interval = F9K1115V2_KEYS_DEBOUNCE_INTERVAL,
81 .gpio = F9K1115V2_GPIO_BTN_RESET,
82 .active_low = 1,
83 },
84 {
85 .desc = "WPS button",
86 .type = EV_KEY,
87 .code = KEY_WPS_BUTTON,
88 .debounce_interval = F9K1115V2_KEYS_DEBOUNCE_INTERVAL,
89 .gpio = F9K1115V2_GPIO_BTN_WPS,
90 .active_low = 1,
91 },
92 };
93
94 static struct ar8327_pad_cfg f9k1115v2_ar8327_pad0_cfg = {
95 /* Use the RGMII interface for the GMAC0 of the AR8337 switch */
96 .mode = AR8327_PAD_MAC_RGMII,
97 .txclk_delay_en = true,
98 .rxclk_delay_en = true,
99 .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
100 .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
101 .mac06_exchange_en = true,
102 };
103
104 static struct ar8327_pad_cfg f9k1115v2_ar8327_pad6_cfg = {
105 /* Use the SGMII interface for the GMAC6 of the AR8337 switch */
106 .mode = AR8327_PAD_MAC_SGMII,
107 .rxclk_delay_en = true,
108 .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
109 };
110
111 static struct ar8327_platform_data f9k1115v2_ar8327_data = {
112 .pad0_cfg = &f9k1115v2_ar8327_pad0_cfg,
113 .pad6_cfg = &f9k1115v2_ar8327_pad6_cfg,
114 .port0_cfg = {
115 .force_link = 1,
116 .speed = AR8327_PORT_SPEED_1000,
117 .duplex = 1,
118 .txpause = 1,
119 .rxpause = 1,
120 },
121 .port6_cfg = {
122 .force_link = 1,
123 .speed = AR8327_PORT_SPEED_1000,
124 .duplex = 1,
125 .txpause = 1,
126 .rxpause = 1,
127 },
128 };
129
130 static struct mdio_board_info f9k1115v2_mdio0_info[] = {
131 {
132 .bus_id = "ag71xx-mdio.0",
133 .phy_addr = 0,
134 .platform_data = &f9k1115v2_ar8327_data,
135 },
136 };
137
138 static void __init f9k1115v2_setup(void)
139 {
140 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
141
142 ath79_register_m25p80(NULL);
143
144 ath79_register_leds_gpio(-1, ARRAY_SIZE(f9k1115v2_leds_gpio),
145 f9k1115v2_leds_gpio);
146 ath79_register_gpio_keys_polled(-1, F9K1115V2_KEYS_POLL_INTERVAL,
147 ARRAY_SIZE(f9k1115v2_gpio_keys),
148 f9k1115v2_gpio_keys);
149
150 ath79_register_wmac(art + F9K1115V2_WMAC_CALDATA_OFFSET, NULL);
151
152 ath79_register_mdio(0, 0x0);
153 mdiobus_register_board_info(f9k1115v2_mdio0_info,
154 ARRAY_SIZE(f9k1115v2_mdio0_info));
155
156 ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
157
158 ath79_init_mac(ath79_eth0_data.mac_addr,
159 art + F9K1115V2_WAN_MAC_OFFSET, 0);
160
161 ath79_init_mac(ath79_eth1_data.mac_addr,
162 art + F9K1115V2_LAN_MAC_OFFSET, 0);
163
164 ath79_eth0_pll_data.pll_1000 = 0xa6000000;
165 ath79_eth1_pll_data.pll_1000 = 0x03000101;
166
167 /* GMAC0 is connected to the RMGII interface */
168 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
169 ath79_eth0_data.phy_mask = BIT(0);
170 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
171
172 ath79_register_eth(0);
173
174 /* GMAC1 is connected to the SGMII interface */
175 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
176 ath79_eth1_data.speed = SPEED_1000;
177 ath79_eth1_data.duplex = DUPLEX_FULL;
178
179 ath79_register_eth(1);
180
181 ath79_register_pci();
182
183 ath79_register_usb();
184 gpio_request_one(F9K1115V2_GPIO_USB2_POWER,
185 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
186 "USB2 power");
187 }
188
189 MIPS_MACHINE(ATH79_MACH_F9K1115V2, "F9K1115V2", "Belkin AC1750DB",
190 f9k1115v2_setup);