OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * Mifi 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 | |||
16 | #include <asm/mach-ath79/ath79.h> |
||
17 | |||
18 | #include "dev-eth.h" |
||
19 | #include "dev-gpio-buttons.h" |
||
20 | #include "dev-leds-gpio.h" |
||
21 | #include "dev-m25p80.h" |
||
22 | #include "dev-usb.h" |
||
23 | #include "dev-wmac.h" |
||
24 | #include "machtypes.h" |
||
25 | |||
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 |
||
31 | |||
32 | #define GL_MIFI_GPIO_BTN_RESET 11 |
||
33 | |||
34 | #define GL_MIFI_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
35 | #define GL_MIFI_KEYS_DEBOUNCE_INTERVAL (3 * GL_MIFI_KEYS_POLL_INTERVAL) |
||
36 | |||
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 |
||
41 | |||
42 | static struct gpio_led gl_mifi_leds_gpio[] __initdata = { |
||
43 | { |
||
44 | .name = "gl-mifi:green:wan", |
||
45 | .gpio = GL_MIFI_GPIO_LED_WAN, |
||
46 | .active_low = 0, |
||
47 | }, |
||
48 | { |
||
49 | .name = "gl-mifi:green:lan", |
||
50 | .gpio = GL_MIFI_GPIO_LED_LAN, |
||
51 | .active_low = 0, |
||
52 | }, |
||
53 | { |
||
54 | .name = "gl-mifi:green:wlan", |
||
55 | .gpio = GL_MIFI_GPIO_LED_WLAN, |
||
56 | .active_low = 0, |
||
57 | }, |
||
58 | { |
||
59 | .name = "gl-mifi:green:net", |
||
60 | .gpio = GL_MIFI_GPIO_LED_NET, |
||
61 | .active_low = 0, |
||
62 | }, |
||
63 | { |
||
64 | .name = "gl-mifi:green:3gcontrol", |
||
65 | .gpio = GL_MIFI_GPIO_LED_3GCONTROL, |
||
66 | .active_low = 0, |
||
67 | } |
||
68 | }; |
||
69 | |||
70 | static struct gpio_keys_button gl_mifi_gpio_keys[] __initdata = { |
||
71 | { |
||
72 | .desc = "reset", |
||
73 | .type = EV_KEY, |
||
74 | .code = KEY_RESTART, |
||
75 | .debounce_interval = GL_MIFI_KEYS_DEBOUNCE_INTERVAL, |
||
76 | .gpio = GL_MIFI_GPIO_BTN_RESET, |
||
77 | .active_low = 0, |
||
78 | }, |
||
79 | }; |
||
80 | |||
81 | static void __init gl_mifi_setup(void) |
||
82 | { |
||
83 | |||
84 | /* ART base address */ |
||
85 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
||
86 | |||
87 | /* disable PHY_SWAP and PHY_ADDR_SWAP bits */ |
||
88 | ath79_setup_ar933x_phy4_switch(false, false); |
||
89 | |||
90 | /* register flash. */ |
||
91 | ath79_register_m25p80(NULL); |
||
92 | |||
93 | /* register gpio LEDs and keys */ |
||
94 | ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_mifi_leds_gpio), |
||
95 | gl_mifi_leds_gpio); |
||
96 | ath79_register_gpio_keys_polled(-1, GL_MIFI_KEYS_POLL_INTERVAL, |
||
97 | ARRAY_SIZE(gl_mifi_gpio_keys), |
||
98 | gl_mifi_gpio_keys); |
||
99 | |||
100 | /* enable usb */ |
||
101 | ath79_register_usb(); |
||
102 | |||
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); |
||
109 | |||
110 | /* register wireless mac with cal data */ |
||
111 | ath79_register_wmac(art + GL_MIFI_CALDATA_OFFSET, art + GL_MIFI_WMAC_MAC_OFFSET); |
||
112 | } |
||
113 | |||
114 | MIPS_MACHINE(ATH79_MACH_GL_MIFI, "GL-MIFI", "GL.iNet GL-MIFI", gl_mifi_setup); |