2 * ALFA NETWORK Hornet-UB board support
4 * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
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.
11 #include <linux/gpio.h>
13 #include <asm/mach-ath79/ath79.h>
14 #include <asm/mach-ath79/ar71xx_regs.h>
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
23 #include "machtypes.h"
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
31 #define HORNET_UB_GPIO_BTN_RESET 12
32 #define HORNET_UB_GPIO_BTN_WPS 11
34 #define HORNET_UB_GPIO_USB_POWER 26
36 #define HORNET_UB_KEYS_POLL_INTERVAL 20 /* msecs */
37 #define HORNET_UB_KEYS_DEBOUNCE_INTERVAL (3 * HORNET_UB_KEYS_POLL_INTERVAL)
39 #define HORNET_UB_MAC0_OFFSET 0x0000
40 #define HORNET_UB_MAC1_OFFSET 0x0006
41 #define HORNET_UB_CALDATA_OFFSET 0x1000
43 static struct gpio_led hornet_ub_leds_gpio
[] __initdata
= {
45 .name
= "alfa:blue:lan",
46 .gpio
= HORNET_UB_GPIO_LED_LAN
,
50 .name
= "alfa:blue:usb",
51 .gpio
= HORNET_UB_GPIO_LED_USB
,
55 .name
= "alfa:blue:wan",
56 .gpio
= HORNET_UB_GPIO_LED_WAN
,
60 .name
= "alfa:blue:wlan",
61 .gpio
= HORNET_UB_GPIO_LED_WLAN
,
65 .name
= "alfa:blue:wps",
66 .gpio
= HORNET_UB_GPIO_LED_WPS
,
71 static struct gpio_keys_button hornet_ub_gpio_keys
[] __initdata
= {
75 .code
= KEY_WPS_BUTTON
,
76 .debounce_interval
= HORNET_UB_KEYS_DEBOUNCE_INTERVAL
,
77 .gpio
= HORNET_UB_GPIO_BTN_WPS
,
81 .desc
= "Reset button",
84 .debounce_interval
= HORNET_UB_KEYS_DEBOUNCE_INTERVAL
,
85 .gpio
= HORNET_UB_GPIO_BTN_RESET
,
90 static void __init
hornet_ub_gpio_setup(void)
94 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
95 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
96 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
97 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
98 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
100 t
= ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP
);
101 t
|= AR933X_BOOTSTRAP_MDIO_GPIO_EN
;
102 ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP
, t
);
104 gpio_request_one(HORNET_UB_GPIO_USB_POWER
,
105 GPIOF_OUT_INIT_HIGH
| GPIOF_EXPORT_DIR_FIXED
,
109 static void __init
hornet_ub_setup(void)
111 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
113 hornet_ub_gpio_setup();
115 ath79_register_m25p80(NULL
);
116 ath79_register_leds_gpio(-1, ARRAY_SIZE(hornet_ub_leds_gpio
),
117 hornet_ub_leds_gpio
);
118 ath79_register_gpio_keys_polled(-1, HORNET_UB_KEYS_POLL_INTERVAL
,
119 ARRAY_SIZE(hornet_ub_gpio_keys
),
120 hornet_ub_gpio_keys
);
122 ath79_init_mac(ath79_eth1_data
.mac_addr
,
123 art
+ HORNET_UB_MAC0_OFFSET
, 0);
124 ath79_init_mac(ath79_eth0_data
.mac_addr
,
125 art
+ HORNET_UB_MAC1_OFFSET
, 0);
127 ath79_register_mdio(0, 0x0);
129 ath79_register_eth(1);
130 ath79_register_eth(0);
132 ath79_register_wmac(art
+ HORNET_UB_CALDATA_OFFSET
, NULL
);
133 ath79_register_usb();
136 MIPS_MACHINE(ATH79_MACH_HORNET_UB
, "HORNET-UB", "ALFA NETWORK Hornet-UB",