2 * DomyWifi DW33D support
4 * Copyright (c) 2012 Qualcomm Atheros
5 * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org>
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include <linux/platform_device.h>
22 #include <linux/ar8216_platform.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/nand.h>
25 #include <linux/platform/ar934x_nfc.h>
27 #include <asm/mach-ath79/ar71xx_regs.h>
31 #include "dev-ap9x-pci.h"
32 #include "dev-gpio-buttons.h"
34 #include "dev-leds-gpio.h"
35 #include "dev-m25p80.h"
39 #include "machtypes.h"
41 #define DW33D_GPIO_LED_MMC 4
42 #define DW33D_GPIO_LED_WLAN_2G 13
43 #define DW33D_GPIO_LED_STATUS 14
44 #define DW33D_GPIO_LED_USB 15
45 #define DW33D_GPIO_LED_INTERNET 22
47 #define DW33D_GPIO_BTN_RESET 17
49 #define DW33D_KEYS_POLL_INTERVAL 20 /* msecs */
50 #define DW33D_KEYS_DEBOUNCE_INTERVAL (3 * DW33D_KEYS_POLL_INTERVAL)
52 #define DW33D_MAC0_OFFSET 0
53 #define DW33D_MAC1_OFFSET 6
54 #define DW33D_WMAC_OFFSET 12
55 #define DW33D_WMAC_CALDATA_OFFSET 0x1000
56 #define DW33D_PCIE_CALDATA_OFFSET 0x5000
58 static struct gpio_led dw33d_leds_gpio[] __initdata = {
60 .name = "dw33d:blue:status",
61 .gpio = DW33D_GPIO_LED_STATUS,
65 .name = "dw33d:blue:mmc",
66 .gpio = DW33D_GPIO_LED_MMC,
70 .name = "dw33d:blue:usb",
71 .gpio = DW33D_GPIO_LED_USB,
75 .name = "dw33d:blue:wlan-2g",
76 .gpio = DW33D_GPIO_LED_WLAN_2G,
80 .name = "dw33d:blue:internet",
81 .gpio = DW33D_GPIO_LED_INTERNET,
86 static struct gpio_keys_button dw33d_gpio_keys[] __initdata = {
88 .desc = "Reset button",
91 .debounce_interval = DW33D_KEYS_DEBOUNCE_INTERVAL,
92 .gpio = DW33D_GPIO_BTN_RESET,
97 /* GMAC6 of the QCA8337 switch is connected to the QCA9558 SoC via SGMII */
98 static struct ar8327_pad_cfg dw33d_qca8337_pad6_cfg = {
99 .mode = AR8327_PAD_MAC_SGMII,
100 .sgmii_delay_en = true,
103 /* GMAC0 of the QCA8337 switch is connected to the QCA9558 SoC via RGMII */
104 static struct ar8327_pad_cfg dw33d_qca8337_pad0_cfg = {
105 .mode = AR8327_PAD_MAC_RGMII,
106 .txclk_delay_en = true,
107 .rxclk_delay_en = true,
108 .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
109 .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
112 static struct ar8327_platform_data dw33d_qca8337_data = {
113 .pad0_cfg = &dw33d_qca8337_pad0_cfg,
114 .pad6_cfg = &dw33d_qca8337_pad6_cfg,
117 .speed = AR8327_PORT_SPEED_1000,
124 .speed = AR8327_PORT_SPEED_1000,
131 static struct mdio_board_info dw33d_mdio0_info[] = {
133 .bus_id = "ag71xx-mdio.0",
135 .platform_data = &dw33d_qca8337_data,
139 static void __init dw33d_setup(void)
141 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
143 ath79_register_m25p80(NULL);
145 ath79_register_leds_gpio(-1, ARRAY_SIZE(dw33d_leds_gpio),
147 ath79_register_gpio_keys_polled(-1, DW33D_KEYS_POLL_INTERVAL,
148 ARRAY_SIZE(dw33d_gpio_keys),
151 ath79_register_usb();
152 ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW);
153 ath79_register_nfc();
154 ath79_register_pci();
156 ath79_register_wmac(art + DW33D_WMAC_CALDATA_OFFSET, art + DW33D_WMAC_OFFSET);
158 ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
160 ath79_register_mdio(0, 0x0);
162 ath79_init_mac(ath79_eth0_data.mac_addr, art + DW33D_MAC0_OFFSET, 0);
163 ath79_init_mac(ath79_eth1_data.mac_addr, art + DW33D_MAC1_OFFSET, 0);
165 mdiobus_register_board_info(dw33d_mdio0_info,
166 ARRAY_SIZE(dw33d_mdio0_info));
168 /* GMAC0 is connected to the RMGII interface */
169 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
170 ath79_eth0_data.phy_mask = BIT(0);
171 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
172 ath79_eth0_pll_data.pll_1000 = 0x56000000;
174 ath79_register_eth(0);
176 /* GMAC1 is connected tot eh SGMII interface */
177 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
178 ath79_eth1_data.speed = SPEED_1000;
179 ath79_eth1_data.duplex = DUPLEX_FULL;
180 ath79_eth1_pll_data.pll_1000 = 0x03000101;
182 ath79_register_eth(1);
185 MIPS_MACHINE(ATH79_MACH_DOMYWIFI_DW33D, "DW33D",