OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * ALFA Network AP120C board support |
||
3 | * |
||
4 | * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org> |
||
5 | * Copyright (C) 2016 Luka Perkov <luka@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/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> |
||
19 | |||
20 | #include <asm/mach-ath79/ath79.h> |
||
21 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
22 | |||
23 | #include "common.h" |
||
24 | #include "dev-eth.h" |
||
25 | #include "dev-gpio-buttons.h" |
||
26 | #include "dev-leds-gpio.h" |
||
27 | #include "dev-m25p80.h" |
||
28 | #include "dev-spi.h" |
||
29 | #include "dev-ap9x-pci.h" |
||
30 | #include "dev-wmac.h" |
||
31 | #include "machtypes.h" |
||
32 | |||
33 | #define ALFA_AP120C_GPIO_LED 0 |
||
34 | |||
35 | #define ALFA_AP120C_GPIO_BUTTON_WIFI 16 |
||
36 | |||
37 | #define ALFA_AP120C_GPIO_WATCH_DOG 20 |
||
38 | |||
39 | #define ALFA_AP120C_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
40 | #define ALFA_AP120C_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_AP120C_KEYS_POLL_INTERVAL) |
||
41 | |||
42 | #define ALFA_AP120C_MAC_OFFSET 0x1002 |
||
43 | #define ALFA_AP120C_CAL0_OFFSET 0x1000 |
||
44 | |||
45 | static struct gpio_keys_button alfa_ap120c_gpio_keys[] __initdata = { |
||
46 | { |
||
47 | .desc = "Wireless button", |
||
48 | .type = EV_KEY, |
||
49 | .code = KEY_RFKILL, |
||
50 | .debounce_interval = ALFA_AP120C_KEYS_DEBOUNCE_INTERVAL, |
||
51 | .gpio = ALFA_AP120C_GPIO_BUTTON_WIFI, |
||
52 | .active_low = 1, |
||
53 | } |
||
54 | }; |
||
55 | |||
56 | static struct gpio_led alfa_ap120c_leds_gpio[] __initdata = { |
||
57 | { |
||
58 | .name = "ap120c:red:wlan", |
||
59 | .gpio = ALFA_AP120C_GPIO_LED, |
||
60 | .active_low = 0, |
||
61 | } |
||
62 | }; |
||
63 | |||
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, |
||
70 | }; |
||
71 | |||
72 | static struct ar8327_platform_data ap120c_ar8327_data = { |
||
73 | .pad0_cfg = &ap120c_ar8327_pad0_cfg, |
||
74 | .port0_cfg = { |
||
75 | .force_link = 1, |
||
76 | .speed = AR8327_PORT_SPEED_1000, |
||
77 | .duplex = 1, |
||
78 | .txpause = 1, |
||
79 | .rxpause = 1, |
||
80 | }, |
||
81 | }; |
||
82 | |||
83 | static struct mdio_board_info ap120c_mdio0_info[] = { |
||
84 | { |
||
85 | .bus_id = "ag71xx-mdio.0", |
||
86 | .phy_addr = 0, |
||
87 | .platform_data = &ap120c_ar8327_data, |
||
88 | }, |
||
89 | }; |
||
90 | |||
91 | static struct flash_platform_data flash __initdata = { NULL, NULL, 0 }; |
||
92 | |||
93 | #define ALFA_AP120C_LAN_PHYMASK BIT(5) |
||
94 | #define ALFA_AP120C_MDIO_PHYMASK ALFA_AP120C_LAN_PHYMASK |
||
95 | |||
96 | static void __init alfa_ap120c_init(void) |
||
97 | { |
||
98 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
||
99 | u8 mac[ETH_ALEN]; |
||
100 | |||
101 | struct ath9k_platform_data *pdata; |
||
102 | |||
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); |
||
108 | |||
109 | ath79_gpio_function_enable(AR71XX_GPIO_FUNC_SPI_CS1_EN | |
||
110 | AR71XX_GPIO_FUNC_SPI_CS2_EN); |
||
111 | |||
112 | ath79_register_m25p80_multi(&flash); |
||
113 | |||
114 | ath79_init_mac(mac, art + ALFA_AP120C_MAC_OFFSET, 1); |
||
115 | ath79_register_wmac(art + ALFA_AP120C_CAL0_OFFSET, mac); |
||
116 | |||
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); |
||
120 | if (!pdata) { |
||
121 | pr_err("ap120c: unable to get address of wlan data\n"); |
||
122 | return; |
||
123 | } |
||
124 | pdata->use_eeprom = true; |
||
125 | |||
126 | ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 | |
||
127 | BIT(15) | BIT(17) | BIT(19) | BIT(21)); |
||
128 | |||
129 | ath79_register_mdio(0, 0x0); |
||
130 | |||
131 | ath79_init_mac(ath79_eth0_data.mac_addr, art + ALFA_AP120C_MAC_OFFSET, 0); |
||
132 | |||
133 | mdiobus_register_board_info(ap120c_mdio0_info, ARRAY_SIZE(ap120c_mdio0_info)); |
||
134 | |||
135 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
||
136 | ath79_eth0_data.phy_mask = ALFA_AP120C_LAN_PHYMASK; |
||
137 | |||
138 | ath79_eth0_pll_data.pll_1000 = 0x42000000; |
||
139 | ath79_eth0_pll_data.pll_10 = 0x00001313; |
||
140 | |||
141 | ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; |
||
142 | |||
143 | ath79_register_eth(0); |
||
144 | } |
||
145 | |||
146 | MIPS_MACHINE(ATH79_MACH_ALFA_AP120C, "ALFA-AP120C", "ALFA Network AP120C", |
||
147 | alfa_ap120c_init); |