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>
16 #include <asm/mach-ath79/ath79.h>
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
24 #include "machtypes.h"
26 #define GL_MIFI_GPIO_LED_WAN 27
27 #define GL_MIFI_GPIO_LED_LAN 16
28 #define GL_MIFI_GPIO_LED_WLAN 1
29 #define GL_MIFI_GPIO_LED_NET 0
30 #define GL_MIFI_GPIO_LED_3GCONTROL 7
32 #define GL_MIFI_GPIO_BTN_RESET 11
34 #define GL_MIFI_KEYS_POLL_INTERVAL 20 /* msecs */
35 #define GL_MIFI_KEYS_DEBOUNCE_INTERVAL (3 * GL_MIFI_KEYS_POLL_INTERVAL)
37 #define GL_MIFI_MAC0_OFFSET 0x0000
38 #define GL_MIFI_MAC1_OFFSET 0x0000
39 #define GL_MIFI_CALDATA_OFFSET 0x1000
40 #define GL_MIFI_WMAC_MAC_OFFSET 0x0000
42 static struct gpio_led gl_mifi_leds_gpio[] __initdata = {
44 .name = "gl-mifi:wan",
45 .gpio = GL_MIFI_GPIO_LED_WAN,
49 .name = "gl-mifi:lan",
50 .gpio = GL_MIFI_GPIO_LED_LAN,
54 .name = "gl-mifi:wlan",
55 .gpio = GL_MIFI_GPIO_LED_WLAN,
59 .name = "gl-mifi:net",
60 .gpio = GL_MIFI_GPIO_LED_NET,
64 .name = "gl-mifi:3gcontrol",
65 .gpio = GL_MIFI_GPIO_LED_3GCONTROL,
70 static struct gpio_keys_button gl_mifi_gpio_keys[] __initdata = {
75 .debounce_interval = GL_MIFI_KEYS_DEBOUNCE_INTERVAL,
76 .gpio = GL_MIFI_GPIO_BTN_RESET,
81 static void __init gl_mifi_setup(void)
84 /* ART base address */
85 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
87 /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
88 ath79_setup_ar933x_phy4_switch(false, false);
91 ath79_register_m25p80(NULL);
93 /* register gpio LEDs and keys */
94 ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_mifi_leds_gpio),
96 ath79_register_gpio_keys_polled(-1, GL_MIFI_KEYS_POLL_INTERVAL,
97 ARRAY_SIZE(gl_mifi_gpio_keys),
101 ath79_register_usb();
103 /* register eth0 as WAN, eth1 as LAN */
104 ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_MIFI_MAC0_OFFSET, 0);
105 ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_MIFI_MAC1_OFFSET, 0);
106 ath79_register_mdio(0, 0x0);
107 ath79_register_eth(0);
108 ath79_register_eth(1);
110 /* register wireless mac with cal data */
111 ath79_register_wmac(art + GL_MIFI_CALDATA_OFFSET, art + GL_MIFI_WMAC_MAC_OFFSET);
114 MIPS_MACHINE(ATH79_MACH_GL_MIFI, "GL-MIFI", "GL-MIFI",gl_mifi_setup);