2 * GLI AR300M(D) board support
4 * Copyright (C) 2011 dongyuqi <729650915@qq.com>
5 * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (C) 2013 alzhao <alzhao@gmail.com>
7 * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
14 #include <linux/gpio.h>
15 #include <linux/pci.h>
17 #include <asm/mach-ath79/ath79.h>
18 #include <asm/mach-ath79/ar71xx_regs.h>
21 #include "dev-ap9x-pci.h"
23 #include "dev-gpio-buttons.h"
24 #include "dev-leds-gpio.h"
25 #include "dev-m25p80.h"
29 #include "machtypes.h"
32 #define GL_AR300M_GPIO_LED_WLAN 14
33 #define GL_AR300M_GPIO_LED_LAN 13
34 #define GL_AR300M_GPIO_LED_SYSTEM 12
35 #define GL_AR300M_GPIO_BTN_RESET 3
36 #define GL_AR300M_GPIO_BTN_LEFT 0
37 #define GL_AR300M_GPIO_BTN_RIGHT 1
39 #define GL_AR300M_KEYS_POLL_INTERVAL 20 /* msecs */
40 #define GL_AR300M_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR300M_KEYS_POLL_INTERVAL)
42 #define GL_AR300M_MAC0_OFFSET 0
43 #define GL_AR300M_MAC1_OFFSET 6
44 #define GL_AR300M_WMAC_CALDATA_OFFSET 0x1000
45 #define GL_AR300M_PCIE_CALDATA_OFFSET 0x5000
47 static struct gpio_led gl_ar300m_leds_gpio[] __initdata = {
49 .name = "gl-ar300m:red:wlan",
50 .gpio = GL_AR300M_GPIO_LED_WLAN,
54 .name = "gl-ar300m:green:lan",
55 .gpio = GL_AR300M_GPIO_LED_LAN,
59 .name = "gl-ar300m:green:system",
60 .gpio = GL_AR300M_GPIO_LED_SYSTEM,
66 static struct gpio_keys_button gl_ar300m_gpio_keys[] __initdata = {
71 .debounce_interval = GL_AR300M_KEYS_DEBOUNCE_INTERVAL,
72 .gpio = GL_AR300M_GPIO_BTN_RESET,
76 .desc = "button right",
79 .debounce_interval = GL_AR300M_KEYS_DEBOUNCE_INTERVAL,
80 .gpio = GL_AR300M_GPIO_BTN_LEFT,
84 .desc = "button left",
87 .debounce_interval = GL_AR300M_KEYS_DEBOUNCE_INTERVAL,
88 .gpio = GL_AR300M_GPIO_BTN_RIGHT,
93 static struct spi_board_info gl_ar300m_spi_info[] = {
97 .max_speed_hz = 25000000,
99 .platform_data = NULL,
104 .max_speed_hz = 25000000,
105 .modalias = "ath79-spinand",
106 .platform_data = NULL,
110 static struct ath79_spi_platform_data gl_ar300m_spi_data = {
115 static void __init gl_ar300m_setup(void)
117 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
120 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
121 ath79_register_spi(&gl_ar300m_spi_data, gl_ar300m_spi_info, 2);
123 /* register gpio LEDs and keys */
124 ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar300m_leds_gpio),
125 gl_ar300m_leds_gpio);
126 ath79_register_gpio_keys_polled(-1, GL_AR300M_KEYS_POLL_INTERVAL,
127 ARRAY_SIZE(gl_ar300m_gpio_keys),
128 gl_ar300m_gpio_keys);
130 ath79_register_mdio(0, 0x0);
133 ath79_init_mac(ath79_eth0_data.mac_addr, art + GL_AR300M_MAC0_OFFSET, 0);
134 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
135 ath79_eth0_data.speed = SPEED_100;
136 ath79_eth0_data.duplex = DUPLEX_FULL;
137 ath79_eth0_data.phy_mask = BIT(4);
138 ath79_register_eth(0);
141 ath79_init_mac(ath79_eth1_data.mac_addr, art + GL_AR300M_MAC1_OFFSET, 0);
142 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
143 ath79_eth1_data.speed = SPEED_1000;
144 ath79_eth1_data.duplex = DUPLEX_FULL;
145 ath79_switch_data.phy_poll_mask |= BIT(4);
146 ath79_switch_data.phy4_mii_en = 1;
147 ath79_register_eth(1);
149 ath79_init_mac(tmpmac, art + GL_AR300M_WMAC_CALDATA_OFFSET + 2, 0);
150 ath79_register_wmac(art + GL_AR300M_WMAC_CALDATA_OFFSET, tmpmac);
153 ath79_register_usb();
155 ath79_register_pci();
158 MIPS_MACHINE(ATH79_MACH_GL_AR300M, "GL-AR300M", "GL.iNet GL-AR300M", gl_ar300m_setup);