ar71xx: fix LED names for GL Innovations boards
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-gl-ar150.c
1 /*
2 * GL_ar150 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_AR150_GPIO_LED_WLAN 0
27 #define GL_AR150_GPIO_LED_LAN 13
28 #define GL_AR150_GPIO_LED_WAN 15
29
30 #define GL_AR150_GPIO_BIN_USB 6
31 #define GL_AR150_GPIO_BTN_MANUAL 7
32 #define GL_AR150_GPIO_BTN_AUTO 8
33 #define GL_AR150_GPIO_BTN_RESET 11
34
35 #define GL_AR150_KEYS_POLL_INTERVAL 20 /* msecs */
36 #define GL_AR150_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR150_KEYS_POLL_INTERVAL)
37
38 #define GL_AR150_MAC0_OFFSET 0x0000
39 #define GL_AR150_MAC1_OFFSET 0x0000
40 #define GL_AR150_CALDATA_OFFSET 0x1000
41 #define GL_AR150_WMAC_MAC_OFFSET 0x0000
42
43 static struct gpio_led gl_ar150_leds_gpio[] __initdata = {
44 {
45 .name = "gl-ar150:wlan",
46 .gpio = GL_AR150_GPIO_LED_WLAN,
47 .active_low = 0,
48 },
49 {
50 .name = "gl-ar150:lan",
51 .gpio = GL_AR150_GPIO_LED_LAN,
52 .active_low = 0,
53 },
54 {
55 .name = "gl-ar150:wan",
56 .gpio = GL_AR150_GPIO_LED_WAN,
57 .active_low = 0,
58 .default_state = 1,
59 },
60 };
61
62 static struct gpio_keys_button gl_ar150_gpio_keys[] __initdata = {
63 {
64 .desc = "BTN_7",
65 .type = EV_KEY,
66 .code = BTN_7,
67 .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
68 .gpio = GL_AR150_GPIO_BTN_MANUAL,
69 .active_low = 0,
70 },
71 {
72 .desc = "BTN_8",
73 .type = EV_KEY,
74 .code = BTN_8,
75 .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
76 .gpio = GL_AR150_GPIO_BTN_AUTO,
77 .active_low = 0,
78 },
79 {
80 .desc = "reset",
81 .type = EV_KEY,
82 .code = KEY_RESTART,
83 .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
84 .gpio = GL_AR150_GPIO_BTN_RESET,
85 .active_low = 0,
86 },
87 };
88
89 static void __init gl_ar150_setup(void)
90 {
91
92 /* ART base address */
93 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
94
95 /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
96 ath79_setup_ar933x_phy4_switch(false, false);
97
98 /* register flash. */
99 ath79_register_m25p80(NULL);
100
101 /* register gpio LEDs and keys */
102 ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar150_leds_gpio),
103 gl_ar150_leds_gpio);
104 ath79_register_gpio_keys_polled(-1, GL_AR150_KEYS_POLL_INTERVAL,
105 ARRAY_SIZE(gl_ar150_gpio_keys),
106 gl_ar150_gpio_keys);
107
108 /* enable usb */
109 gpio_request_one(GL_AR150_GPIO_BIN_USB,
110 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
111 "USB power");
112 ath79_register_usb();
113
114 /* register eth0 as WAN, eth1 as LAN */
115 ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR150_MAC0_OFFSET, 0);
116 ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR150_MAC1_OFFSET, 0);
117 ath79_register_mdio(0, 0x0);
118 ath79_register_eth(0);
119 ath79_register_eth(1);
120
121 /* register wireless mac with cal data */
122 ath79_register_wmac(art + GL_AR150_CALDATA_OFFSET, art + GL_AR150_WMAC_MAC_OFFSET);
123 }
124
125 MIPS_MACHINE(ATH79_MACH_GL_AR150, "GL-AR150", "GL AR150",gl_ar150_setup);