wireguard-tools: add tunlink option for hostroute
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-carambola2.c
1 /*
2 * 8devices Carambola2 board support
3 *
4 * Copyright (C) 2013 Darius Augulis <darius@8devices.com>
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 <asm/mach-ath79/ath79.h>
12 #include <asm/mach-ath79/ar71xx_regs.h>
13 #include "common.h"
14 #include "dev-eth.h"
15 #include "dev-gpio-buttons.h"
16 #include "dev-leds-gpio.h"
17 #include "dev-m25p80.h"
18 #include "dev-spi.h"
19 #include "dev-usb.h"
20 #include "dev-wmac.h"
21 #include "machtypes.h"
22
23 #define CARAMBOLA2_GPIO_LED_WLAN 0
24 #define CARAMBOLA2_GPIO_LED_ETH0 14
25 #define CARAMBOLA2_GPIO_LED_ETH1 13
26
27 #define CARAMBOLA2_GPIO_BTN_JUMPSTART 11
28
29 #define CARAMBOLA2_KEYS_POLL_INTERVAL 20 /* msecs */
30 #define CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL (3 * CARAMBOLA2_KEYS_POLL_INTERVAL)
31
32 #define CARAMBOLA2_MAC0_OFFSET 0x0000
33 #define CARAMBOLA2_MAC1_OFFSET 0x0006
34 #define CARAMBOLA2_CALDATA_OFFSET 0x1000
35 #define CARAMBOLA2_WMAC_MAC_OFFSET 0x1002
36
37 static struct gpio_led carambola2_leds_gpio[] __initdata = {
38 {
39 .name = "carambola2:green:wlan",
40 .gpio = CARAMBOLA2_GPIO_LED_WLAN,
41 .active_low = 1,
42 }, {
43 .name = "carambola2:orange:eth0",
44 .gpio = CARAMBOLA2_GPIO_LED_ETH0,
45 .active_low = 0,
46 }, {
47 .name = "carambola2:orange:eth1",
48 .gpio = CARAMBOLA2_GPIO_LED_ETH1,
49 .active_low = 0,
50 }
51 };
52
53 static struct gpio_keys_button carambola2_gpio_keys[] __initdata = {
54 {
55 .desc = "jumpstart button",
56 .type = EV_KEY,
57 .code = KEY_WPS_BUTTON,
58 .debounce_interval = CARAMBOLA2_KEYS_DEBOUNCE_INTERVAL,
59 .gpio = CARAMBOLA2_GPIO_BTN_JUMPSTART,
60 .active_low = 1,
61 },
62 };
63
64 static void __init carambola2_common_setup(void)
65 {
66 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
67
68 ath79_register_m25p80(NULL);
69 ath79_register_wmac(art + CARAMBOLA2_CALDATA_OFFSET,
70 art + CARAMBOLA2_WMAC_MAC_OFFSET);
71
72 ath79_setup_ar933x_phy4_switch(true, true);
73
74 ath79_init_mac(ath79_eth0_data.mac_addr, art + CARAMBOLA2_MAC0_OFFSET, 0);
75 ath79_init_mac(ath79_eth1_data.mac_addr, art + CARAMBOLA2_MAC1_OFFSET, 0);
76
77 ath79_register_mdio(0, 0x0);
78
79 /* LAN ports */
80 ath79_register_eth(1);
81
82 /* WAN port */
83 ath79_register_eth(0);
84 }
85
86 static void __init carambola2_setup(void)
87 {
88 carambola2_common_setup();
89
90 ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
91 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
92 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
93 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
94 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
95
96 ath79_register_leds_gpio(-1, ARRAY_SIZE(carambola2_leds_gpio),
97 carambola2_leds_gpio);
98 ath79_register_gpio_keys_polled(-1, CARAMBOLA2_KEYS_POLL_INTERVAL,
99 ARRAY_SIZE(carambola2_gpio_keys),
100 carambola2_gpio_keys);
101 ath79_register_usb();
102 }
103
104 MIPS_MACHINE(ATH79_MACH_CARAMBOLA2, "CARAMBOLA2", "8devices Carambola2 board",
105 carambola2_setup);