wireguard-tools: add tunlink option for hostroute
[openwrt/staging/mkresin.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-gs-minibox-v32.c
1 /*
2 * Atheros GS_MINIBOX_V3.2 reference board support
3 *
4 * Copyright (c) 2018 OpenWRT.org
5 * Copyright (c) 2013 The Linux Foundation. All rights reserved.
6 * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 *
20 */
21
22 #include <linux/pci.h>
23 #include <linux/platform_device.h>
24 #include <linux/ath9k_platform.h>
25 #include <linux/ar8216_platform.h>
26
27 #include <asm/mach-ath79/ar71xx_regs.h>
28
29 #include "common.h"
30 #include "dev-eth.h"
31 #include "dev-ap9x-pci.h"
32 #include "dev-gpio-buttons.h"
33 #include "dev-leds-gpio.h"
34 #include "dev-m25p80.h"
35 #include "dev-spi.h"
36 #include "dev-usb.h"
37 #include "dev-wmac.h"
38 #include "machtypes.h"
39 #include "pci.h"
40
41 #define GS_MINIBOX_V3_GPIO_LED_STATUS 14
42 #define GS_MINIBOX_V3_GPIO_BTN_RST 17
43 #define GS_MINIBOX_V3_KEYS_POLL_INTERVAL 20 /* msecs */
44 #define GS_MINIBOX_V3_KEYS_DEBOUNCE_INTERVAL (3 * GS_MINIBOX_V3_KEYS_POLL_INTERVAL)
45 #define GS_MINIBOX_V3_MAC0_OFFSET 0
46 #define GS_MINIBOX_V3_MAC1_OFFSET 6
47 #define GS_MINIBOX_V3_WMAC_CALDATA_OFFSET 0x1000
48
49 static const char *gs_minibox_v3_part_probes[] = {
50 "tp-link",
51 NULL,
52 };
53
54 static struct flash_platform_data gs_minibox_v3_flash_data = {
55 .part_probes = gs_minibox_v3_part_probes,
56 };
57
58 static struct gpio_led gs_minibox_v3_leds_gpio[] __initdata = {
59 {
60 .name = "minibox_v3.2:green:system",
61 .gpio = GS_MINIBOX_V3_GPIO_LED_STATUS,
62 .active_low = 1,
63 },
64 };
65
66 static struct gpio_keys_button gs_minibox_v3_gpio_keys[] __initdata = {
67 {
68 .desc = "reset button",
69 .type = EV_KEY,
70 .code = KEY_RESTART,
71 .debounce_interval = GS_MINIBOX_V3_KEYS_DEBOUNCE_INTERVAL,
72 .gpio = GS_MINIBOX_V3_GPIO_BTN_RST,
73 .active_low = 1,
74 },
75 };
76
77 static void __init gs_minibox_v3_gpio_led_setup(void)
78 {
79 ath79_register_leds_gpio(-1, ARRAY_SIZE(gs_minibox_v3_leds_gpio),
80 gs_minibox_v3_leds_gpio);
81 ath79_register_gpio_keys_polled(-1, GS_MINIBOX_V3_KEYS_POLL_INTERVAL,
82 ARRAY_SIZE(gs_minibox_v3_gpio_keys),
83 gs_minibox_v3_gpio_keys);
84 }
85
86 static void __init gs_minibox_v3_setup(void)
87 {
88 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
89
90 ath79_register_m25p80(&gs_minibox_v3_flash_data);
91 gs_minibox_v3_gpio_led_setup();
92
93 ath79_register_usb();
94
95 ath79_register_wmac(art + GS_MINIBOX_V3_WMAC_CALDATA_OFFSET, NULL);
96 ath79_register_mdio(0, 0x0);
97 ath79_register_mdio(1, 0x0);
98
99 ath79_init_mac(ath79_eth0_data.mac_addr, art + GS_MINIBOX_V3_MAC0_OFFSET, 0);
100 ath79_init_mac(ath79_eth1_data.mac_addr, art + GS_MINIBOX_V3_MAC1_OFFSET, 0);
101
102 /* WAN port */
103 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
104 ath79_eth0_data.speed = SPEED_100;
105 ath79_eth0_data.duplex = DUPLEX_FULL;
106 ath79_eth0_data.phy_mask = BIT(4);
107 ath79_register_eth(0);
108
109 /* LAN ports */
110 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
111 ath79_eth1_data.speed = SPEED_1000;
112 ath79_eth1_data.duplex = DUPLEX_FULL;
113 ath79_switch_data.phy_poll_mask |= BIT(4);
114 ath79_switch_data.phy4_mii_en = 1;
115 ath79_register_eth(1);
116
117 ath79_register_pci();
118 }
119
120 MIPS_MACHINE(ATH79_MACH_GS_MINIBOX_V32, "MINIBOX-V3.2", "Minibox V3.2",
121 gs_minibox_v3_setup);