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/platform_device.h>
16 #include <linux/ath9k_platform.h>
17 #include <asm/mach-ath79/ar71xx_regs.h>
18 #include <asm/mach-ath79/ath79.h>
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
24 #include "dev-m25p80.h"
27 #include "machtypes.h"
29 #define GL_AR300_GPIO_LED_WLAN 13
30 #define GL_AR300_GPIO_LED_WAN 14
31 #define GL_AR300_GPIO_BTN_RESET 16
34 #define GL_AR300_KEYS_POLL_INTERVAL 20 /* msecs */
35 #define GL_AR300_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR300_KEYS_POLL_INTERVAL)
37 #define GL_AR300_MAC0_OFFSET 0x0000
38 #define GL_AR300_MAC1_OFFSET 0x0000
39 #define GL_AR300_CALDATA_OFFSET 0x1000
40 #define GL_AR300_WMAC_MAC_OFFSET 0x0000
42 static struct gpio_led gl_ar300_leds_gpio[] __initdata = {
44 .name = "gl_ar300:wlan",
45 .gpio = GL_AR300_GPIO_LED_WLAN,
49 .name = "gl_ar300:wan",
50 .gpio = GL_AR300_GPIO_LED_WAN,
55 static struct gpio_keys_button gl_ar300_gpio_keys[] __initdata = {
60 .debounce_interval = GL_AR300_KEYS_DEBOUNCE_INTERVAL,
61 .gpio = GL_AR300_GPIO_BTN_RESET,
66 static void __init gl_ar300_setup(void)
69 /* ART base address */
70 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
73 ath79_register_m25p80(NULL);
75 /* register gpio LEDs and keys */
76 ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar300_leds_gpio),
78 ath79_register_gpio_keys_polled(-1, GL_AR300_KEYS_POLL_INTERVAL,
79 ARRAY_SIZE(gl_ar300_gpio_keys),
84 ath79_register_mdio(1, 0x0);
86 /* register eth0 as WAN, eth1 as LAN */
87 ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR300_MAC0_OFFSET, 0);
88 ath79_switch_data.phy4_mii_en = 1;
89 ath79_switch_data.phy_poll_mask = BIT(4);
90 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
91 ath79_eth0_data.phy_mask = BIT(4);
92 ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
93 ath79_register_eth(0);
95 ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR300_MAC1_OFFSET, 0);
96 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
97 ath79_register_eth(1);
99 /* register wireless mac with cal data */
100 ath79_register_wmac(art + GL_AR300_CALDATA_OFFSET, art + GL_AR300_WMAC_MAC_OFFSET);
103 MIPS_MACHINE(ATH79_MACH_GL_AR300, "GL-AR300", "GL AR300",gl_ar300_setup);