OpenWrt – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
4 office 1 /*
2 * GL.iNet GL-X750 board support
3 *
4 * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 */
10  
11 #include <linux/gpio.h>
12 #include <linux/i2c.h>
13 #include <linux/i2c-gpio.h>
14 #include <linux/platform_device.h>
15  
16 #include <asm/mach-ath79/ath79.h>
17 #include <asm/mach-ath79/ar71xx_regs.h>
18  
19 #include "common.h"
20 #include "dev-ap9x-pci.h"
21 #include "dev-eth.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
24 #include "dev-spi.h"
25 #include "dev-usb.h"
26 #include "dev-wmac.h"
27 #include "machtypes.h"
28  
29 #define GL_X750_GPIO_LED_POWER 12
30 #define GL_X750_GPIO_LED_WLAN2G 4
31 #define GL_X750_GPIO_LED_WLAN5G 13
32 #define GL_X750_GPIO_LED_4G 15
33 #define GL_X750_GPIO_LED_WAN 14
34  
35 #define GL_X750_GPIO_BTN_RESET 3
36  
37 //#define GL_X750_GPIO_I2C_SCL 16
38 //#define GL_X750_GPIO_I2C_SDA 1
39 #define GL_X750_GPIO_BLE_RST 1
40  
41 #define GL_X750_GPIO_USB_POWER 2
42 #define GL_X750_GPIO_PCI_POWER 0
43  
44 #define GL_X750_KEYS_POLL_INTERVAL 20
45 #define GL_X750_KEYS_DEBOUNCE_INTERVAL (3 * GL_X750_KEYS_POLL_INTERVAL)
46  
47 #define GL_X750_MAC0_OFFSET 0
48 #define GL_X750_WMAC2G_CALDATA_OFFSET 0x1000
49 #define GL_X750_WMAC5G_CALDATA_OFFSET 0x5000
50  
51 static struct gpio_led gl_x750_leds_gpio[] __initdata = {
52 {
53 .name = "gl-x750:white:power",
54 .gpio = GL_X750_GPIO_LED_POWER,
55 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
56 .active_low = 1,
57 }, {
58 .name = "gl-x750:white:wlan2g",
59 .gpio = GL_X750_GPIO_LED_WLAN2G,
60 .active_low = 1,
61 }, {
62 .name = "gl-x750:white:wlan5g",
63 .gpio = GL_X750_GPIO_LED_WLAN5G,
64 .active_low = 1,
65 },{
66 .name = "gl-x750:white:wan",
67 .gpio = GL_X750_GPIO_LED_WAN,
68 .active_low = 1,
69 }, {
70 .name = "gl-x750:white:4g",
71 .gpio = GL_X750_GPIO_LED_4G,
72 .active_low = 1,
73 },
74 };
75  
76 static struct gpio_keys_button gl_x750_gpio_keys[] __initdata = {
77 {
78 .desc = "reset",
79 .type = EV_KEY,
80 .code = KEY_RESTART,
81 .debounce_interval = GL_X750_KEYS_DEBOUNCE_INTERVAL,
82 .gpio = GL_X750_GPIO_BTN_RESET,
83 .active_low = 1,
84 },
85 };
86  
87 /*static struct i2c_gpio_platform_data gl_x750_i2c_gpio_data = {
88 .sda_pin = GL_X750_GPIO_I2C_SDA,
89 .scl_pin = GL_X750_GPIO_I2C_SCL,
90 };
91  
92 static struct platform_device gl_x750_i2c_gpio = {
93 .name = "i2c-gpio",
94 .id = 0,
95 .dev = {
96 .platform_data = &gl_x750_i2c_gpio_data,
97 },
98 };*/
99  
100 static struct spi_board_info gl_x750_spi_info[] = {
101 {
102 .bus_num = 0,
103 .chip_select = 0,
104 .max_speed_hz = 25000000,
105 .modalias = "m25p80",
106 .platform_data = NULL,
107 },
108 {
109 .bus_num = 0,
110 .chip_select = 1,
111 .max_speed_hz = 25000000,
112 .modalias = "generic-spinand-controller",
113 .platform_data = NULL,
114 }
115 };
116  
117 static struct ath79_spi_platform_data gl_x750_spi_data = {
118 .bus_num = 0,
119 .num_chipselect = 2,
120 };
121  
122 static void __init gl_x750_setup(void)
123 {
124 u8 *art = (u8 *) KSEG1ADDR(0x1f050000);
125  
126 ath79_register_spi(&gl_x750_spi_data, gl_x750_spi_info, 2);
127  
128 ath79_register_mdio(0, 0x0);
129 //ath79_register_mdio(1, 0x0);
130  
131 ath79_switch_data.phy4_mii_en = 1;
132 ath79_switch_data.phy_poll_mask |= BIT(4);
133  
134 /* WAN */
135 ath79_eth0_data.duplex = DUPLEX_FULL;
136 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
137 ath79_eth0_data.phy_mask = BIT(4);
138 ath79_eth0_data.speed = SPEED_100;
139 ath79_init_mac(ath79_eth0_data.mac_addr, art + GL_X750_MAC0_OFFSET, 0);
140 ath79_register_eth(0);
141  
142 /* LAN */
143 ath79_eth1_data.duplex = DUPLEX_FULL;
144 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
145 ath79_eth1_data.speed = SPEED_1000;
146 ath79_init_mac(ath79_eth1_data.mac_addr, art + GL_X750_MAC0_OFFSET, 1);
147 ath79_register_eth(1);
148  
149 /* Disable JTAG (enables GPIO0-3) */
150 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
151  
152 ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_x750_leds_gpio),
153 gl_x750_leds_gpio);
154  
155 ath79_register_gpio_keys_polled(-1, GL_X750_KEYS_POLL_INTERVAL,
156 ARRAY_SIZE(gl_x750_gpio_keys),
157 gl_x750_gpio_keys);
158  
159 gpio_request_one(GL_X750_GPIO_USB_POWER,
160 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
161 "USB power");
162  
163 gpio_request_one(GL_X750_GPIO_PCI_POWER,
164 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
165 "PCI power");
166  
167 gpio_request_one(GL_X750_GPIO_BLE_RST,
168 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
169 "BLE RST");
170  
171 // platform_device_register(&gl_x750_i2c_gpio);
172  
173 ath79_register_usb();
174  
175 ath79_register_wmac(art + GL_X750_WMAC2G_CALDATA_OFFSET, NULL);
176  
177 ap91_pci_init(art + GL_X750_WMAC5G_CALDATA_OFFSET, NULL);
178 }
179  
180 MIPS_MACHINE(ATH79_MACH_GL_X750, "GL-X750", "GL.iNet GL-X750",
181 gl_x750_setup);