OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | 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_GPIO_USB_POWER 6 |
||
35 | |||
36 | #define GL_MIFI_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
37 | #define GL_MIFI_KEYS_DEBOUNCE_INTERVAL (3 * GL_MIFI_KEYS_POLL_INTERVAL) |
||
38 | |||
39 | #define GL_MIFI_MAC0_OFFSET 0x0000 |
||
40 | #define GL_MIFI_MAC1_OFFSET 0x0000 |
||
41 | #define GL_MIFI_CALDATA_OFFSET 0x1000 |
||
42 | #define GL_MIFI_WMAC_MAC_OFFSET 0x0000 |
||
43 | |||
44 | static struct gpio_led gl_mifi_leds_gpio[] __initdata = { |
||
45 | { |
||
46 | .name = "gl-mifi:green:wan", |
||
47 | .gpio = GL_MIFI_GPIO_LED_WAN, |
||
48 | .active_low = 0, |
||
49 | }, |
||
50 | { |
||
51 | .name = "gl-mifi:green:lan", |
||
52 | .gpio = GL_MIFI_GPIO_LED_LAN, |
||
53 | .active_low = 0, |
||
54 | }, |
||
55 | { |
||
56 | .name = "gl-mifi:green:wlan", |
||
57 | .gpio = GL_MIFI_GPIO_LED_WLAN, |
||
58 | .active_low = 0, |
||
59 | }, |
||
60 | { |
||
61 | .name = "gl-mifi:green:net", |
||
62 | .gpio = GL_MIFI_GPIO_LED_NET, |
||
63 | .active_low = 0, |
||
64 | }, |
||
65 | { |
||
66 | .name = "gl-mifi:green:3gcontrol", |
||
67 | .gpio = GL_MIFI_GPIO_LED_3GCONTROL, |
||
68 | .active_low = 0, |
||
69 | } |
||
70 | }; |
||
71 | |||
72 | static struct gpio_keys_button gl_mifi_gpio_keys[] __initdata = { |
||
73 | { |
||
74 | .desc = "reset", |
||
75 | .type = EV_KEY, |
||
76 | .code = KEY_RESTART, |
||
77 | .debounce_interval = GL_MIFI_KEYS_DEBOUNCE_INTERVAL, |
||
78 | .gpio = GL_MIFI_GPIO_BTN_RESET, |
||
79 | .active_low = 0, |
||
80 | }, |
||
81 | }; |
||
82 | |||
83 | static void __init gl_mifi_setup(void) |
||
84 | { |
||
85 | |||
86 | /* ART base address */ |
||
87 | u8 *art = (u8 *) KSEG1ADDR(0x1fff0000); |
||
88 | |||
89 | /* disable PHY_SWAP and PHY_ADDR_SWAP bits */ |
||
90 | ath79_setup_ar933x_phy4_switch(false, false); |
||
91 | |||
92 | /* register flash. */ |
||
93 | ath79_register_m25p80(NULL); |
||
94 | |||
95 | /* register gpio LEDs and keys */ |
||
96 | ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_mifi_leds_gpio), |
||
97 | gl_mifi_leds_gpio); |
||
98 | ath79_register_gpio_keys_polled(-1, GL_MIFI_KEYS_POLL_INTERVAL, |
||
99 | ARRAY_SIZE(gl_mifi_gpio_keys), |
||
100 | gl_mifi_gpio_keys); |
||
101 | |||
102 | gpio_request_one(GL_MIFI_GPIO_USB_POWER, |
||
103 | GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED, |
||
104 | "usbpower"); |
||
105 | |||
106 | /* enable usb */ |
||
107 | ath79_register_usb(); |
||
108 | |||
109 | /* register eth0 as WAN, eth1 as LAN */ |
||
110 | ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_MIFI_MAC0_OFFSET, 0); |
||
111 | ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_MIFI_MAC1_OFFSET, 0); |
||
112 | ath79_register_mdio(0, 0x0); |
||
113 | ath79_register_eth(0); |
||
114 | ath79_register_eth(1); |
||
115 | |||
116 | /* register wireless mac with cal data */ |
||
117 | ath79_register_wmac(art + GL_MIFI_CALDATA_OFFSET, art + GL_MIFI_WMAC_MAC_OFFSET); |
||
118 | } |
||
119 | |||
120 | MIPS_MACHINE(ATH79_MACH_GL_MIFI, "GL-MIFI", "GL.iNet GL-MIFI", gl_mifi_setup); |