2 * ALFA Network AP120C board support
4 * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2016 Luka Perkov <luka@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/init.h>
13 #include <linux/bitops.h>
14 #include <linux/gpio.h>
15 #include <linux/platform_device.h>
16 #include <linux/spi/spi.h>
17 #include <linux/ar8216_platform.h>
18 #include <linux/ath9k_platform.h>
20 #include <asm/mach-ath79/ath79.h>
21 #include <asm/mach-ath79/ar71xx_regs.h>
25 #include "dev-gpio-buttons.h"
26 #include "dev-leds-gpio.h"
27 #include "dev-m25p80.h"
29 #include "dev-ap9x-pci.h"
31 #include "machtypes.h"
33 #define ALFA_AP120C_GPIO_LED 0
35 #define ALFA_AP120C_GPIO_BUTTON_WIFI 16
37 #define ALFA_AP120C_GPIO_WATCH_DOG 20
39 #define ALFA_AP120C_KEYS_POLL_INTERVAL 20 /* msecs */
40 #define ALFA_AP120C_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_AP120C_KEYS_POLL_INTERVAL)
42 #define ALFA_AP120C_MAC_OFFSET 0x1002
43 #define ALFA_AP120C_CAL0_OFFSET 0x1000
45 static struct gpio_keys_button alfa_ap120c_gpio_keys
[] __initdata
= {
47 .desc
= "Wireless button",
50 .debounce_interval
= ALFA_AP120C_KEYS_DEBOUNCE_INTERVAL
,
51 .gpio
= ALFA_AP120C_GPIO_BUTTON_WIFI
,
56 static struct gpio_led alfa_ap120c_leds_gpio
[] __initdata
= {
58 .name
= "ap120c:red:wlan",
59 .gpio
= ALFA_AP120C_GPIO_LED
,
64 static struct ar8327_pad_cfg ap120c_ar8327_pad0_cfg
= {
65 .mode
= AR8327_PAD_MAC_RGMII
,
66 .txclk_delay_en
= true,
67 .rxclk_delay_en
= true,
68 .txclk_delay_sel
= AR8327_CLK_DELAY_SEL1
,
69 .rxclk_delay_sel
= AR8327_CLK_DELAY_SEL2
,
72 static struct ar8327_platform_data ap120c_ar8327_data
= {
73 .pad0_cfg
= &ap120c_ar8327_pad0_cfg
,
76 .speed
= AR8327_PORT_SPEED_1000
,
83 static struct mdio_board_info ap120c_mdio0_info
[] = {
85 .bus_id
= "ag71xx-mdio.0",
87 .platform_data
= &ap120c_ar8327_data
,
91 static struct flash_platform_data flash __initdata
= { NULL
, NULL
, 0 };
93 #define ALFA_AP120C_LAN_PHYMASK BIT(5)
94 #define ALFA_AP120C_MDIO_PHYMASK ALFA_AP120C_LAN_PHYMASK
96 static void __init
alfa_ap120c_init(void)
98 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
101 struct ath9k_platform_data
*pdata
;
103 ath79_register_leds_gpio(-1, ARRAY_SIZE(alfa_ap120c_leds_gpio
),
104 alfa_ap120c_leds_gpio
);
105 ath79_register_gpio_keys_polled(-1, ALFA_AP120C_KEYS_POLL_INTERVAL
,
106 ARRAY_SIZE(alfa_ap120c_gpio_keys
),
107 alfa_ap120c_gpio_keys
);
109 ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN
|
110 AR71XX_GPIO_FUNC_SPI_CS2_EN
);
112 ath79_register_m25p80_multi(&flash
);
114 ath79_init_mac(mac
, art
+ ALFA_AP120C_MAC_OFFSET
, 1);
115 ath79_register_wmac(art
+ ALFA_AP120C_CAL0_OFFSET
, mac
);
117 ath79_init_mac(mac
, art
+ ALFA_AP120C_MAC_OFFSET
, 2);
118 ap91_pci_init(NULL
, mac
);
119 pdata
= ap9x_pci_get_wmac_data(0);
121 pr_err("ap120c: unable to get address of wlan data\n");
124 pdata
->use_eeprom
= true;
126 ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0
|
127 BIT(15) | BIT(17) | BIT(19) | BIT(21));
129 ath79_register_mdio(0, 0x0);
131 ath79_init_mac(ath79_eth0_data
.mac_addr
, art
+ ALFA_AP120C_MAC_OFFSET
, 0);
133 mdiobus_register_board_info(ap120c_mdio0_info
, ARRAY_SIZE(ap120c_mdio0_info
));
135 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_RGMII
;
136 ath79_eth0_data
.phy_mask
= ALFA_AP120C_LAN_PHYMASK
;
138 ath79_eth0_pll_data
.pll_1000
= 0x42000000;
139 ath79_eth0_pll_data
.pll_10
= 0x00001313;
141 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio0_device
.dev
;
143 ath79_register_eth(0);
146 MIPS_MACHINE(ATH79_MACH_ALFA_AP120C
, "ALFA-AP120C", "ALFA Network AP120C",