2 * GL.iNet GL-AR750S board support
4 * Copyright (C) 2018 luochongjun <luochongjun@gl-inet.com>
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.
11 #include <linux/init.h>
12 #include <linux/pci.h>
13 #include <linux/platform_device.h>
14 #include <linux/ath9k_platform.h>
15 #include <linux/etherdevice.h>
17 #include <linux/i2c.h>
18 #include <linux/i2c-gpio.h>
20 #include <asm/mach-ath79/ath79.h>
21 #include <asm/mach-ath79/irq.h>
22 #include <asm/mach-ath79/ar71xx_regs.h>
24 #include <linux/platform_data/phy-at803x.h>
25 #include <linux/ar8216_platform.h>
28 #include "dev-ap9x-pci.h"
30 #include "dev-gpio-buttons.h"
31 #include "dev-leds-gpio.h"
33 #include "dev-m25p80.h"
36 #include "machtypes.h"
39 #define GL_AR750S_KEYS_POLL_INTERVAL 20
40 #define GL_AR750S_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR750S_KEYS_POLL_INTERVAL)
43 #define GL_AR750S_GPIO_LED_WLAN2G 19
44 #define GL_AR750S_GPIO_LED_WLAN5G 20
45 #define GL_AR750S_GPIO_LED_POWER 1
46 #define GL_AR750S_GPIO_USB_POWER 7
48 #define GL_AR750S_GPIO_BTN_RESET 2
49 #define GL_AR750S_GPIO_BTN_RIGHT 8
51 #define GL_AR750S_MAC0_OFFSET 0x0000
52 #define GL_AR750S_WMAC_CALDATA_OFFSET 0x1000
53 #define GL_AR750S_PCI_CALDATA_OFFSET 0x5000
55 #define GL_AR750S_GPIO_I2C_SDA 5
56 #define GL_AR750S_GPIO_I2C_SCL 21
60 static struct spi_board_info gl_ar750s_spi_info
[] = {
64 .max_speed_hz
= 25000000,
66 .platform_data
= NULL
,
70 static struct ath79_spi_platform_data gl_ar750s_spi_data
= {
75 static struct gpio_led gl_ar750s_leds_gpio
[] __initdata
= {
77 .name
= "gl-ar750s:green:power",
78 .gpio
= GL_AR750S_GPIO_LED_POWER
,
79 .default_state
= LEDS_GPIO_DEFSTATE_KEEP
,
82 .name
= "gl-ar750s:green:usbpower",
83 .gpio
= GL_AR750S_GPIO_USB_POWER
,
86 .name
= "gl-ar750s:green:wlan2g",
87 .gpio
= GL_AR750S_GPIO_LED_WLAN2G
,
90 .name
= "gl-ar750s:green:wlan5g",
91 .gpio
= GL_AR750S_GPIO_LED_WLAN5G
,
96 static struct gpio_keys_button gl_ar750s_gpio_keys
[] __initdata
= {
101 .debounce_interval
= GL_AR750S_KEYS_DEBOUNCE_INTERVAL
,
102 .gpio
= GL_AR750S_GPIO_BTN_RESET
,
108 .debounce_interval
= GL_AR750S_KEYS_DEBOUNCE_INTERVAL
,
109 .gpio
= GL_AR750S_GPIO_BTN_RIGHT
,
114 static struct i2c_gpio_platform_data gl_ar750s_i2c_gpio_data
= {
115 .sda_pin
= GL_AR750S_GPIO_I2C_SDA
,
116 .scl_pin
= GL_AR750S_GPIO_I2C_SCL
,
119 static struct platform_device gl_ar750s_i2c_gpio_device
= {
123 .platform_data
= &gl_ar750s_i2c_gpio_data
,
128 static struct ar8327_pad_cfg gl_ar750s_ar8327_pad0_cfg
= {
129 .mode
= AR8327_PAD_MAC_SGMII
,
130 .sgmii_delay_en
= true,
133 static struct ar8327_platform_data gl_ar750s_ar8327_data
= {
134 .pad0_cfg
= &gl_ar750s_ar8327_pad0_cfg
,
137 .speed
= AR8327_PORT_SPEED_1000
,
145 static struct mdio_board_info gl_ar750s_mdio0_info
[] = {
147 .bus_id
= "ag71xx-mdio.0",
149 .platform_data
= &gl_ar750s_ar8327_data
,
153 static void __init
gl_ar750s_setup(void)
155 u8
*eeprom
= (u8
*) KSEG1ADDR(0x1f050000);
157 ath79_register_spi(&gl_ar750s_spi_data
, gl_ar750s_spi_info
, 1);
159 ath79_init_mac(ath79_eth0_data
.mac_addr
,
160 eeprom
+ GL_AR750S_MAC0_OFFSET
, 0);
162 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_SGMII
;
163 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio0_device
.dev
;
164 ath79_eth0_data
.phy_mask
= BIT(0);
166 mdiobus_register_board_info(gl_ar750s_mdio0_info
,
167 ARRAY_SIZE(gl_ar750s_mdio0_info
));
169 ath79_register_mdio(0, 0x00);
170 ath79_register_eth(0);
173 ath79_register_usb();
176 ath79_register_wmac(eeprom
+ GL_AR750S_WMAC_CALDATA_OFFSET
, NULL
);
179 ap91_pci_init(eeprom
+ GL_AR750S_PCI_CALDATA_OFFSET
, NULL
);
181 platform_device_register(&gl_ar750s_i2c_gpio_device
);
183 ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar750s_leds_gpio
),
184 gl_ar750s_leds_gpio
);
186 ath79_register_gpio_keys_polled(-1, GL_AR750S_KEYS_POLL_INTERVAL
,
187 ARRAY_SIZE(gl_ar750s_gpio_keys
),
188 gl_ar750s_gpio_keys
);
192 MIPS_MACHINE(ATH79_MACH_GL_AR750S
, "GL-AR750S", "GL-AR750S",