OpenWrt – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
4 office 1 /*
2 * Ubiquiti UniFi AC (LITE) board support
3 *
4 * Copyright (C) 2015-2016 P. Wassi <p.wassi at gmx.at>
5 *
6 * Derived from: mach-ubnt-xm.c
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12  
13 #include <linux/init.h>
14 #include <linux/pci.h>
15 #include <linux/platform_device.h>
16 #include <linux/ath9k_platform.h>
17 #include <linux/etherdevice.h>
18  
19 #include <linux/i2c.h>
20 #include <linux/i2c-gpio.h>
21  
22 #include <asm/mach-ath79/ath79.h>
23 #include <asm/mach-ath79/irq.h>
24 #include <asm/mach-ath79/ar71xx_regs.h>
25  
26 #include <linux/platform_data/phy-at803x.h>
27 #include <linux/ar8216_platform.h>
28  
29 #include "common.h"
30 #include "dev-ap9x-pci.h"
31 #include "dev-eth.h"
32 #include "dev-gpio-buttons.h"
33 #include "dev-leds-gpio.h"
34 #include "dev-spi.h"
35 #include "dev-m25p80.h"
36 #include "dev-wmac.h"
37 #include "dev-usb.h"
38 #include "machtypes.h"
39  
40  
41 #define GL_AR750S_KEYS_POLL_INTERVAL 20
42 #define GL_AR750S_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR750S_KEYS_POLL_INTERVAL)
43  
44  
45 #define GL_AR750S_GPIO_LED_WLAN2G 19
46 #define GL_AR750S_GPIO_LED_WLAN5G 20
47 #define GL_AR750S_GPIO_LED_POWER 1
48 #define GL_AR750S_GPIO_USB_POWER 7
49  
50 #define GL_AR750S_GPIO_BTN_RESET 2
51 #define GL_AR750S_GPIO_BTN_RIGHT 8
52  
53 #define GL_AR750S_MAC0_OFFSET 0x0000
54 #define GL_AR750S_WMAC_CALDATA_OFFSET 0x1000
55 #define GL_AR750S_PCI_CALDATA_OFFSET 0x5000
56  
57 #define GL_AR750S_GPIO_I2C_SDA 5
58 #define GL_AR750S_GPIO_I2C_SCL 21
59  
60  
61  
62 static struct spi_board_info gl_ar750s_spi_info[] = {
63 {
64 .bus_num = 0,
65 .chip_select = 0,
66 .max_speed_hz = 25000000,
67 .modalias = "m25p80",
68 .platform_data = NULL,
69 },
70 {
71 .bus_num = 0,
72 .chip_select = 1,
73 .max_speed_hz = 25000000,
74 .modalias = "generic-spinand-controller",
75 .platform_data = NULL,
76 }
77 };
78  
79 static struct ath79_spi_platform_data gl_ar750s_spi_data = {
80 .bus_num = 0,
81 .num_chipselect = 2,
82 };
83  
84 static struct gpio_led gl_ar750s_leds_gpio[] __initdata = {
85 {
86 .name = "gl-ar750s:white:power",
87 .gpio = GL_AR750S_GPIO_LED_POWER,
88 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
89 .active_low = 1,
90 },{
91 .name = "gl-ar750s:white:usbpower",
92 .gpio = GL_AR750S_GPIO_USB_POWER,
93 .active_low = 1,
94 },{
95 .name = "gl-ar750s:white:wlan2g",
96 .gpio = GL_AR750S_GPIO_LED_WLAN2G,
97 .active_low = 1,
98 },{
99 .name = "gl-ar750s:white:wlan5g",
100 .gpio = GL_AR750S_GPIO_LED_WLAN5G,
101 .active_low = 0,
102 }
103 };
104  
105 static struct gpio_keys_button gl_ar750s_gpio_keys[] __initdata = {
106 {
107 .desc = "reset",
108 .type = EV_KEY,
109 .code = KEY_RESTART,
110 .debounce_interval = GL_AR750S_KEYS_DEBOUNCE_INTERVAL,
111 .gpio = GL_AR750S_GPIO_BTN_RESET,
112 .active_low = 1,
113 }, {
114 .desc = "right",
115 .type = EV_KEY,
116 .code = BTN_0,
117 .debounce_interval = GL_AR750S_KEYS_DEBOUNCE_INTERVAL,
118 .gpio = GL_AR750S_GPIO_BTN_RIGHT,
119 .active_low = 1,
120 },
121 };
122  
123 static struct i2c_gpio_platform_data gl_ar750s_i2c_gpio_data = {
124 .sda_pin = GL_AR750S_GPIO_I2C_SDA,
125 .scl_pin = GL_AR750S_GPIO_I2C_SCL,
126 };
127  
128 static struct platform_device gl_ar750s_i2c_gpio_device = {
129 .name = "i2c-gpio",
130 .id = 0,
131 .dev = {
132 .platform_data = &gl_ar750s_i2c_gpio_data,
133 }
134  
135 };
136  
137 static struct ar8327_pad_cfg gl_ar750s_ar8327_pad0_cfg = {
138 .mode = AR8327_PAD_MAC_SGMII,
139 .sgmii_delay_en = true,
140 };
141  
142 static struct ar8327_platform_data gl_ar750s_ar8327_data = {
143 .pad0_cfg = &gl_ar750s_ar8327_pad0_cfg,
144 .port0_cfg = {
145 .force_link = 1,
146 .speed = AR8327_PORT_SPEED_1000,
147 .duplex = 1,
148 .txpause = 1,
149 .rxpause = 1,
150 },
151 };
152  
153  
154 static struct mdio_board_info gl_ar750s_mdio0_info[] = {
155 {
156 .bus_id = "ag71xx-mdio.0",
157 .phy_addr = 0,
158 .platform_data = &gl_ar750s_ar8327_data,
159 },
160 };
161  
162 static void __init gl_ar750s_setup(void)
163 {
164 u8 *eeprom = (u8 *) KSEG1ADDR(0x1f050000);
165  
166 ath79_register_spi(&gl_ar750s_spi_data, gl_ar750s_spi_info, 2);
167  
168 ath79_init_mac(ath79_eth0_data.mac_addr,
169 eeprom + GL_AR750S_MAC0_OFFSET, 0);
170  
171 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
172 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
173 ath79_eth0_data.phy_mask = BIT(0);
174  
175 mdiobus_register_board_info(gl_ar750s_mdio0_info,
176 ARRAY_SIZE(gl_ar750s_mdio0_info));
177  
178 ath79_register_mdio(0, 0x00);
179 ath79_register_eth(0);
180  
181  
182 ath79_register_usb();
183  
184  
185 ath79_register_wmac(eeprom + GL_AR750S_WMAC_CALDATA_OFFSET, NULL);
186  
187  
188 ap91_pci_init(eeprom + GL_AR750S_PCI_CALDATA_OFFSET, NULL);
189  
190 platform_device_register(&gl_ar750s_i2c_gpio_device);
191  
192 ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar750s_leds_gpio),
193 gl_ar750s_leds_gpio);
194  
195 ath79_register_gpio_keys_polled(-1, GL_AR750S_KEYS_POLL_INTERVAL,
196 ARRAY_SIZE(gl_ar750s_gpio_keys),
197 gl_ar750s_gpio_keys);
198 }
199  
200  
201 MIPS_MACHINE(ATH79_MACH_GL_AR750S, "GL-AR750S", "GL-AR750S",
202 gl_ar750s_setup);