OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * GL.iNet GL-X1200 board support |
||
3 | * |
||
4 | * Copyright (C) 2018 wellnw <guilin.wang@gl-inet.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 | #include <linux/pci.h> |
||
11 | #include <linux/phy.h> |
||
12 | #include <linux/gpio.h> |
||
13 | #include <linux/platform_device.h> |
||
14 | #include <linux/ath9k_platform.h> |
||
15 | #include <linux/ar8216_platform.h> |
||
16 | #include <linux/etherdevice.h> |
||
17 | |||
18 | #include <asm/mach-ath79/ath79.h> |
||
19 | #include <asm/mach-ath79/irq.h> |
||
20 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
21 | |||
22 | #include <linux/platform_data/phy-at803x.h> |
||
23 | |||
24 | #include "common.h" |
||
25 | #include "dev-ap9x-pci.h" |
||
26 | #include "dev-eth.h" |
||
27 | #include "dev-gpio-buttons.h" |
||
28 | #include "dev-leds-gpio.h" |
||
29 | #include "dev-spi.h" |
||
30 | #include "dev-m25p80.h" |
||
31 | #include "dev-wmac.h" |
||
32 | #include "dev-usb.h" |
||
33 | #include "machtypes.h" |
||
34 | #include "pci.h" |
||
35 | |||
36 | #define GL_X1200_KEYS_POLL_INTERVAL 20 |
||
37 | #define GL_X1200_KEYS_DEBOUNCE_INTERVAL (3 * GL_X1200_KEYS_POLL_INTERVAL) |
||
38 | |||
39 | #define GL_X1200_GPIO_LED_WLAN2G 19 |
||
40 | #define GL_X1200_GPIO_LED_WLAN5G 20 |
||
41 | #define GL_X1200_GPIO_LED_POWER 8 |
||
42 | #define GL_X1200_GPIO_USB_POWER 7 |
||
43 | |||
44 | #define GL_X1200_GPIO_BTN_RESET 2 |
||
45 | |||
46 | #define GL_X1200_MAC0_OFFSET 0x0000 |
||
47 | #define GL_X1200_WMAC_CALDATA_OFFSET 0x1000 |
||
48 | #define GL_X1200_PCI_CALDATA_OFFSET 0x5000 |
||
49 | |||
50 | static struct spi_board_info gl_x1200_spi_info[] = { |
||
51 | { |
||
52 | .bus_num = 0, |
||
53 | .chip_select = 0, |
||
54 | .max_speed_hz = 25000000, |
||
55 | .modalias = "m25p80", |
||
56 | .platform_data = NULL, |
||
57 | }, |
||
58 | { |
||
59 | .bus_num = 0, |
||
60 | .chip_select = 1, |
||
61 | .max_speed_hz = 25000000, |
||
62 | .modalias = "generic-spinand-controller", |
||
63 | .platform_data = NULL, |
||
64 | } |
||
65 | }; |
||
66 | |||
67 | static struct ath79_spi_platform_data gl_x1200_spi_data = { |
||
68 | .bus_num = 0, |
||
69 | .num_chipselect = 2, |
||
70 | }; |
||
71 | |||
72 | static struct gpio_led gl_x1200_leds_gpio[] __initdata = { |
||
73 | { |
||
74 | .name = "gl-x1200:green:power", |
||
75 | .gpio = GL_X1200_GPIO_LED_POWER, |
||
76 | .default_state = LEDS_GPIO_DEFSTATE_KEEP, |
||
77 | .active_low = 1, |
||
78 | },{ |
||
79 | .name = "gl-x1200:green:usbpower", |
||
80 | .gpio = GL_X1200_GPIO_USB_POWER, |
||
81 | .active_low = 1, |
||
82 | },{ |
||
83 | .name = "gl-x1200:green:wlan2g", |
||
84 | .gpio = GL_X1200_GPIO_LED_WLAN2G, |
||
85 | .active_low = 1, |
||
86 | },{ |
||
87 | .name = "gl-x1200:green:wlan5g", |
||
88 | .gpio = GL_X1200_GPIO_LED_WLAN5G, |
||
89 | .active_low = 0, |
||
90 | } |
||
91 | }; |
||
92 | |||
93 | static struct gpio_keys_button gl_x1200_gpio_keys[] __initdata = { |
||
94 | { |
||
95 | .desc = "reset", |
||
96 | .type = EV_KEY, |
||
97 | .code = KEY_RESTART, |
||
98 | .debounce_interval = GL_X1200_KEYS_DEBOUNCE_INTERVAL, |
||
99 | .gpio = GL_X1200_GPIO_BTN_RESET, |
||
100 | .active_low = 1, |
||
101 | }, |
||
102 | }; |
||
103 | |||
104 | static struct ar8327_pad_cfg gl_x1200_ar8327_pad0_cfg = { |
||
105 | .mode = AR8327_PAD_MAC_SGMII, |
||
106 | .sgmii_delay_en = true, |
||
107 | }; |
||
108 | |||
109 | static struct ar8327_platform_data gl_x1200_ar8327_data = { |
||
110 | .pad0_cfg = &gl_x1200_ar8327_pad0_cfg, |
||
111 | .port0_cfg = { |
||
112 | .force_link = 1, |
||
113 | .speed = AR8327_PORT_SPEED_1000, |
||
114 | .duplex = 1, |
||
115 | .txpause = 1, |
||
116 | .rxpause = 1, |
||
117 | }, |
||
118 | }; |
||
119 | |||
120 | |||
121 | static struct mdio_board_info gl_x1200_mdio0_info[] = { |
||
122 | { |
||
123 | .bus_id = "ag71xx-mdio.0", |
||
124 | .phy_addr = 0, |
||
125 | .platform_data = &gl_x1200_ar8327_data, |
||
126 | }, |
||
127 | }; |
||
128 | |||
129 | static void __init gl_x1200_setup(void) |
||
130 | { |
||
131 | u8 *eeprom = (u8 *) KSEG1ADDR(0x1f050000); |
||
132 | |||
133 | ath79_register_spi(&gl_x1200_spi_data, gl_x1200_spi_info, 2); |
||
134 | |||
135 | ath79_init_mac(ath79_eth0_data.mac_addr, |
||
136 | eeprom + GL_X1200_MAC0_OFFSET, 0); |
||
137 | |||
138 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII; |
||
139 | ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; |
||
140 | ath79_eth0_data.phy_mask = BIT(0); |
||
141 | |||
142 | mdiobus_register_board_info(gl_x1200_mdio0_info, |
||
143 | ARRAY_SIZE(gl_x1200_mdio0_info)); |
||
144 | ath79_register_mdio(0, 0x00); |
||
145 | ath79_register_eth(0); |
||
146 | ath79_register_usb(); |
||
147 | |||
148 | //disable JTAG Function |
||
149 | ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE); |
||
150 | |||
151 | ath79_register_wmac(eeprom + GL_X1200_WMAC_CALDATA_OFFSET, NULL); |
||
152 | ap91_pci_init(eeprom + GL_X1200_PCI_CALDATA_OFFSET, NULL); |
||
153 | |||
154 | ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_x1200_leds_gpio), |
||
155 | gl_x1200_leds_gpio); |
||
156 | |||
157 | ath79_register_gpio_keys_polled(-1, GL_X1200_KEYS_POLL_INTERVAL, |
||
158 | ARRAY_SIZE(gl_x1200_gpio_keys), |
||
159 | gl_x1200_gpio_keys); |
||
160 | } |
||
161 | |||
162 | MIPS_MACHINE(ATH79_MACH_GL_X1200, "GL-X1200", "GL-X1200", |
||
163 | gl_x1200_setup); |