47db6de18840e76007599e0f7f744eedeff4f732
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-gl-ar300.c
1 /*
2 * Domino board support
3 *
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>
8 *
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.
12 */
13
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>
19
20 #include "common.h"
21 #include "dev-eth.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
24 #include "dev-m25p80.h"
25 #include "dev-usb.h"
26 #include "dev-wmac.h"
27 #include "machtypes.h"
28
29 #define GL_AR300_GPIO_LED_WLAN 13
30 #define GL_AR300_GPIO_LED_WAN 14
31 #define GL_AR300_GPIO_BTN_RESET 16
32
33
34 #define GL_AR300_KEYS_POLL_INTERVAL 20 /* msecs */
35 #define GL_AR300_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR300_KEYS_POLL_INTERVAL)
36
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
41
42 static struct gpio_led gl_ar300_leds_gpio[] __initdata = {
43 {
44 .name = "gl_ar300:wlan",
45 .gpio = GL_AR300_GPIO_LED_WLAN,
46 .active_low = 1,
47 },
48 {
49 .name = "gl_ar300:wan",
50 .gpio = GL_AR300_GPIO_LED_WAN,
51 .active_low = 1,
52 },
53 };
54
55 static struct gpio_keys_button gl_ar300_gpio_keys[] __initdata = {
56 {
57 .desc = "reset",
58 .type = EV_KEY,
59 .code = KEY_RESTART,
60 .debounce_interval = GL_AR300_KEYS_DEBOUNCE_INTERVAL,
61 .gpio = GL_AR300_GPIO_BTN_RESET,
62 .active_low = 1,
63 },
64 };
65
66 static void __init gl_ar300_setup(void)
67 {
68
69 /* ART base address */
70 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
71
72 /* register flash. */
73 ath79_register_m25p80(NULL);
74
75 /* register gpio LEDs and keys */
76 ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar300_leds_gpio),
77 gl_ar300_leds_gpio);
78 ath79_register_gpio_keys_polled(-1, GL_AR300_KEYS_POLL_INTERVAL,
79 ARRAY_SIZE(gl_ar300_gpio_keys),
80 gl_ar300_gpio_keys);
81
82 /* enable usb */
83 ath79_register_usb();
84 ath79_register_mdio(1, 0x0);
85
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);
94
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);
98
99 /* register wireless mac with cal data */
100 ath79_register_wmac(art + GL_AR300_CALDATA_OFFSET, art + GL_AR300_WMAC_MAC_OFFSET);
101 }
102
103 MIPS_MACHINE(ATH79_MACH_GL_AR300, "GL-AR300", "GL AR300",gl_ar300_setup);