1 --- a/arch/mips/ath79/mach-ap136.c
2 +++ b/arch/mips/ath79/mach-ap136.c
5 - * Qualcomm Atheros AP136 reference board support
6 + * Atheros AP136 reference board support
8 * Copyright (c) 2012 Qualcomm Atheros
9 * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
14 -#include <linux/pci.h>
15 -#include <linux/ath9k_platform.h>
16 +#include <linux/platform_device.h>
17 +#include <linux/ar8216_platform.h>
19 -#include "machtypes.h"
20 +#include <asm/mach-ath79/ar71xx_regs.h>
23 +#include "dev-ap9x-pci.h"
24 #include "dev-gpio-buttons.h"
26 #include "dev-leds-gpio.h"
28 +#include "dev-m25p80.h"
32 +#include "machtypes.h"
34 -#define AP136_GPIO_LED_STATUS_RED 14
35 -#define AP136_GPIO_LED_STATUS_GREEN 19
36 #define AP136_GPIO_LED_USB 4
37 -#define AP136_GPIO_LED_WLAN_2G 13
38 #define AP136_GPIO_LED_WLAN_5G 12
39 +#define AP136_GPIO_LED_WLAN_2G 13
40 +#define AP136_GPIO_LED_STATUS_RED 14
41 #define AP136_GPIO_LED_WPS_RED 15
42 +#define AP136_GPIO_LED_STATUS_GREEN 19
43 #define AP136_GPIO_LED_WPS_GREEN 20
45 #define AP136_GPIO_BTN_WPS 16
47 #define AP136_KEYS_POLL_INTERVAL 20 /* msecs */
48 #define AP136_KEYS_DEBOUNCE_INTERVAL (3 * AP136_KEYS_POLL_INTERVAL)
50 -#define AP136_WMAC_CALDATA_OFFSET 0x1000
51 -#define AP136_PCIE_CALDATA_OFFSET 0x5000
52 +#define AP136_MAC0_OFFSET 0
53 +#define AP136_MAC1_OFFSET 6
54 +#define AP136_WMAC_CALDATA_OFFSET 0x1000
55 +#define AP136_PCIE_CALDATA_OFFSET 0x5000
57 static struct gpio_led ap136_leds_gpio[] __initdata = {
59 @@ -98,63 +104,106 @@ static struct gpio_keys_button ap136_gpi
63 -static struct ath79_spi_controller_data ap136_spi0_data = {
64 - .cs_type = ATH79_SPI_CS_TYPE_INTERNAL,
66 +static struct ar8327_pad_cfg ap136_ar8327_pad0_cfg = {
67 + .mode = AR8327_PAD_MAC_RGMII,
68 + .txclk_delay_en = true,
69 + .rxclk_delay_en = true,
70 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
71 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
74 -static struct spi_board_info ap136_spi_info[] = {
78 - .max_speed_hz = 25000000,
79 - .modalias = "mx25l6405d",
80 - .controller_data = &ap136_spi0_data,
82 +static struct ar8327_pad_cfg ap136_ar8327_pad6_cfg = {
83 + .mode = AR8327_PAD_MAC_SGMII,
84 + .txclk_delay_en = false,
85 + .rxclk_delay_en = true,
86 + .txclk_delay_sel = AR8327_CLK_DELAY_SEL0,
87 + .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
90 -static struct ath79_spi_platform_data ap136_spi_data = {
92 - .num_chipselect = 1,
93 +static struct ar8327_platform_data ap136_ar8327_data = {
94 + .pad0_cfg = &ap136_ar8327_pad0_cfg,
95 + .pad6_cfg = &ap136_ar8327_pad6_cfg,
98 + .speed = AR8327_PORT_SPEED_1000,
105 + .speed = AR8327_PORT_SPEED_1000,
113 -static struct ath9k_platform_data ap136_ath9k_data;
114 +static struct mdio_board_info ap136_mdio0_info[] = {
116 + .bus_id = "ag71xx-mdio.0",
118 + .platform_data = &ap136_ar8327_data,
122 -static int ap136_pci_plat_dev_init(struct pci_dev *dev)
123 +static void __init ap136_gmac_setup(void)
125 - if (dev->bus->number == 1 && (PCI_SLOT(dev->devfn)) == 0)
126 - dev->dev.platform_data = &ap136_ath9k_data;
127 + void __iomem *base;
132 + base = ioremap(QCA955X_GMAC_BASE, QCA955X_GMAC_SIZE);
134 -static void __init ap136_pci_init(u8 *eeprom)
136 - memcpy(ap136_ath9k_data.eeprom_data, eeprom,
137 - sizeof(ap136_ath9k_data.eeprom_data));
138 + t = __raw_readl(base + QCA955X_GMAC_REG_ETH_CFG);
140 + t &= ~(QCA955X_ETH_CFG_RGMII_EN | QCA955X_ETH_CFG_GE0_SGMII);
141 + t |= QCA955X_ETH_CFG_RGMII_EN;
143 + __raw_writel(t, base + QCA955X_GMAC_REG_ETH_CFG);
145 - ath79_pci_set_plat_dev_init(ap136_pci_plat_dev_init);
146 - ath79_register_pci();
150 -static inline void ap136_pci_init(void) {}
151 -#endif /* CONFIG_PCI */
153 static void __init ap136_setup(void)
155 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
157 + ath79_register_m25p80(NULL);
159 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap136_leds_gpio),
161 ath79_register_gpio_keys_polled(-1, AP136_KEYS_POLL_INTERVAL,
162 ARRAY_SIZE(ap136_gpio_keys),
164 - ath79_register_spi(&ap136_spi_data, ap136_spi_info,
165 - ARRAY_SIZE(ap136_spi_info));
167 ath79_register_usb();
168 - ath79_register_wmac(art + AP136_WMAC_CALDATA_OFFSET);
169 - ap136_pci_init(art + AP136_PCIE_CALDATA_OFFSET);
170 + ath79_register_wmac(art + AP136_WMAC_CALDATA_OFFSET, NULL);
171 + ap91_pci_init(art + AP136_PCIE_CALDATA_OFFSET, NULL);
173 + ap136_gmac_setup();
175 + ath79_register_mdio(0, 0x0);
177 + ath79_init_mac(ath79_eth0_data.mac_addr, art + AP136_MAC0_OFFSET, 0);
179 + mdiobus_register_board_info(ap136_mdio0_info,
180 + ARRAY_SIZE(ap136_mdio0_info));
182 + /* GMAC0 is connected to GMAC0 of the AR8327 switch via RGMII */
183 + ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
184 + ath79_eth0_data.phy_mask = BIT(0);
185 + ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
186 + ath79_eth0_pll_data.pll_1000 = 0xa6000000;
188 + ath79_register_eth(0);
190 + /* GMAC1 is connected to GMAC6 of the AR8327 switch via SGMII */
191 + ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
192 + ath79_eth1_data.speed = SPEED_1000;
193 + ath79_eth1_data.duplex = DUPLEX_FULL;
194 + ath79_eth1_pll_data.pll_1000 = 0x03000101;
196 + ath79_register_eth(1);
199 MIPS_MACHINE(ATH79_MACH_AP136, "AP136", "Atheros AP136 reference board",