Revert "ar71xx: Allow to set the RXDV, RXD, TXD, TXE delays for QCA955x"
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-hornet-ub.c
1 /*
2  *  ALFA NETWORK Hornet-UB board support
3  *
4  *  Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
5  *
6  *  This program is free software; you can redistribute it and/or modify it
7  *  under the terms of the GNU General Public License version 2 as published
8  *  by the Free Software Foundation.
9  */
10
11 #include <linux/gpio.h>
12
13 #include <asm/mach-ath79/ath79.h>
14 #include <asm/mach-ath79/ar71xx_regs.h>
15
16 #include "common.h"
17 #include "dev-eth.h"
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
21 #include "dev-usb.h"
22 #include "dev-wmac.h"
23 #include "machtypes.h"
24
25 #define HORNET_UB_GPIO_LED_WLAN         0
26 #define HORNET_UB_GPIO_LED_USB          1
27 #define HORNET_UB_GPIO_LED_LAN          13
28 #define HORNET_UB_GPIO_LED_WAN          17
29 #define HORNET_UB_GPIO_LED_WPS          27
30 #define HORNET_UB_GPIO_EXT_LNA          28
31
32 #define HORNET_UB_GPIO_BTN_RESET        12
33 #define HORNET_UB_GPIO_BTN_WPS          11
34
35 #define HORNET_UB_GPIO_USB_POWER        26
36
37 #define HORNET_UB_KEYS_POLL_INTERVAL    20      /* msecs */
38 #define HORNET_UB_KEYS_DEBOUNCE_INTERVAL        (3 * HORNET_UB_KEYS_POLL_INTERVAL)
39
40 #define HORNET_UB_MAC0_OFFSET           0x0000
41 #define HORNET_UB_MAC1_OFFSET           0x0006
42 #define HORNET_UB_CALDATA_OFFSET        0x1000
43
44 static struct gpio_led hornet_ub_leds_gpio[] __initdata = {
45         {
46                 .name           = "alfa:blue:lan",
47                 .gpio           = HORNET_UB_GPIO_LED_LAN,
48                 .active_low     = 0,
49         },
50         {
51                 .name           = "alfa:blue:usb",
52                 .gpio           = HORNET_UB_GPIO_LED_USB,
53                 .active_low     = 0,
54         },
55         {
56                 .name           = "alfa:blue:wan",
57                 .gpio           = HORNET_UB_GPIO_LED_WAN,
58                 .active_low     = 1,
59         },
60         {
61                 .name           = "alfa:blue:wlan",
62                 .gpio           = HORNET_UB_GPIO_LED_WLAN,
63                 .active_low     = 0,
64         },
65         {
66                 .name           = "alfa:blue:wps",
67                 .gpio           = HORNET_UB_GPIO_LED_WPS,
68                 .active_low     = 1,
69         },
70 };
71
72 static struct gpio_keys_button hornet_ub_gpio_keys[] __initdata = {
73         {
74                 .desc           = "WPS button",
75                 .type           = EV_KEY,
76                 .code           = KEY_WPS_BUTTON,
77                 .debounce_interval = HORNET_UB_KEYS_DEBOUNCE_INTERVAL,
78                 .gpio           = HORNET_UB_GPIO_BTN_WPS,
79                 .active_low     = 0,
80         },
81         {
82                 .desc           = "Reset button",
83                 .type           = EV_KEY,
84                 .code           = KEY_RESTART,
85                 .debounce_interval = HORNET_UB_KEYS_DEBOUNCE_INTERVAL,
86                 .gpio           = HORNET_UB_GPIO_BTN_RESET,
87                 .active_low     = 1,
88         }
89 };
90
91 static void __init hornet_ub_gpio_setup(void)
92 {
93         u32 t;
94
95         ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
96                                      AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
97                                      AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
98                                      AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
99                                      AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
100
101         t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
102         t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
103         ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
104
105         gpio_request_one(HORNET_UB_GPIO_USB_POWER,
106                          GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
107                          "USB power");
108         gpio_request_one(HORNET_UB_GPIO_EXT_LNA,
109                         GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
110                         "external LNA0");
111
112 }
113
114 static void __init hornet_ub_setup(void)
115 {
116         u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
117
118         hornet_ub_gpio_setup();
119
120         ath79_register_m25p80(NULL);
121         ath79_register_leds_gpio(-1, ARRAY_SIZE(hornet_ub_leds_gpio),
122                                         hornet_ub_leds_gpio);
123         ath79_register_gpio_keys_polled(-1, HORNET_UB_KEYS_POLL_INTERVAL,
124                                          ARRAY_SIZE(hornet_ub_gpio_keys),
125                                          hornet_ub_gpio_keys);
126
127         ath79_init_mac(ath79_eth1_data.mac_addr,
128                         art + HORNET_UB_MAC0_OFFSET, 0);
129         ath79_init_mac(ath79_eth0_data.mac_addr,
130                         art + HORNET_UB_MAC1_OFFSET, 0);
131
132         ath79_register_mdio(0, 0x0);
133
134         ath79_register_eth(1);
135         ath79_register_eth(0);
136
137         ath79_register_wmac(art + HORNET_UB_CALDATA_OFFSET, NULL);
138         ath79_register_usb();
139 }
140
141 MIPS_MACHINE(ATH79_MACH_HORNET_UB, "HORNET-UB", "ALFA NETWORK Hornet-UB",
142              hornet_ub_setup);