2 * ALFA NETWORK Tube2H board support
4 * Copyright (C) 2014 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"
22 #include "machtypes.h"
24 #define TUBE2H_GPIO_LED_SIGNAL4 0
25 #define TUBE2H_GPIO_LED_SIGNAL3 1
26 #define TUBE2H_GPIO_LED_SIGNAL2 13
27 #define TUBE2H_GPIO_LED_LAN 17
28 #define TUBE2H_GPIO_LED_SIGNAL1 27
29 #define TUBE2H_GPIO_EXT_LNA 28
31 #define TUBE2H_GPIO_WDT_EN 22
32 #define TUBE2H_GPIO_WDT_IN 18
34 #define TUBE2H_GPIO_BTN_RESET 12
36 #define TUBE2H_KEYS_POLL_INTERVAL 20 /* msecs */
37 #define TUBE2H_KEYS_DEBOUNCE_INTERVAL (3 * TUBE2H_KEYS_POLL_INTERVAL)
39 #define TUBE2H_ART_ADDRESS 0x1fff0000
40 #define TUBE2H_LAN_MAC_OFFSET 0x06
41 #define TUBE2H_CALDATA_OFFSET 0x1000
43 static struct gpio_led tube2h_leds_gpio
[] __initdata
= {
45 .name
= "alfa:blue:lan",
46 .gpio
= TUBE2H_GPIO_LED_LAN
,
50 .name
= "alfa:red:signal1",
51 .gpio
= TUBE2H_GPIO_LED_SIGNAL1
,
55 .name
= "alfa:orange:signal2",
56 .gpio
= TUBE2H_GPIO_LED_SIGNAL2
,
60 .name
= "alfa:green:signal3",
61 .gpio
= TUBE2H_GPIO_LED_SIGNAL3
,
65 .name
= "alfa:green:signal4",
66 .gpio
= TUBE2H_GPIO_LED_SIGNAL4
,
71 static struct gpio_keys_button tube2h_gpio_keys
[] __initdata
= {
73 .desc
= "Reset button",
76 .debounce_interval
= TUBE2H_KEYS_DEBOUNCE_INTERVAL
,
77 .gpio
= TUBE2H_GPIO_BTN_RESET
,
82 static void __init
tube2h_setup(void)
84 u8
*art
= (u8
*) KSEG1ADDR(TUBE2H_ART_ADDRESS
);
87 ath79_gpio_function_disable(AR933X_GPIO_FUNC_JTAG_DISABLE
|
88 AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
89 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
90 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
91 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
92 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
94 /* Ensure that GPIO26 and GPIO27 are controllable by software */
95 t
= ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP
);
96 t
|= AR933X_BOOTSTRAP_MDIO_GPIO_EN
;
97 ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP
, t
);
99 gpio_request_one(TUBE2H_GPIO_EXT_LNA
,
100 GPIOF_OUT_INIT_HIGH
| GPIOF_EXPORT_DIR_FIXED
,
103 gpio_request_one(TUBE2H_GPIO_WDT_IN
,
104 GPIOF_OUT_INIT_LOW
| GPIOF_EXPORT_DIR_FIXED
,
107 gpio_request_one(TUBE2H_GPIO_WDT_EN
,
108 GPIOF_OUT_INIT_LOW
| GPIOF_EXPORT_DIR_FIXED
,
111 ath79_register_wmac(art
+ TUBE2H_CALDATA_OFFSET
, NULL
);
113 ath79_register_m25p80(NULL
);
115 ath79_register_leds_gpio(-1, ARRAY_SIZE(tube2h_leds_gpio
),
117 ath79_register_gpio_keys_polled(-1, TUBE2H_KEYS_POLL_INTERVAL
,
118 ARRAY_SIZE(tube2h_gpio_keys
),
121 ath79_init_mac(ath79_eth0_data
.mac_addr
,
122 art
+ TUBE2H_LAN_MAC_OFFSET
, 0);
123 ath79_register_mdio(0, 0x0);
124 ath79_register_eth(0);
127 MIPS_MACHINE(ATH79_MACH_TUBE2H
, "TUBE2H", "ALFA NETWORK Tube2H",