ar71xx: add v4.14 support
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-gs-oolite-v5-2.c
1 /*
2 * GainStrong Oolite V5.2 module and development board support
3 *
4 * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.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 <linux/gpio.h>
12 #include <linux/platform_device.h>
13
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
16
17 #include "common.h"
18 #include "dev-eth.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
22 #include "dev-usb.h"
23 #include "dev-wmac.h"
24 #include "machtypes.h"
25 #include "pci.h"
26
27 #define GS_OOLITE_V5_2_DEV_GPIO_BTN_RESET 17
28 #define GS_OOLITE_V5_2_DEV_GPIO_LED_SYSTEM 13
29
30 #define GS_KEYS_POLL_INTERVAL 20 /* msec */
31 #define GS_KEYS_DEBOUNCE_INTERVAL (3 * GS_KEYS_POLL_INTERVAL)
32
33 #define GS_OOLITE_V5_2_WMAC_CALDATA_OFFSET 0x1000
34
35 static const char *gs_oolite_v5_2_part_probes[] = {
36 "tp-link",
37 NULL,
38 };
39
40 static struct flash_platform_data gs_oolite_v5_2_flash_data = {
41 .part_probes = gs_oolite_v5_2_part_probes,
42 };
43
44 static struct gpio_led gs_oolite_v5_2_dev_gpio_leds[] __initdata = {
45 {
46 .name = "oolite-v5.2-dev:blue:system",
47 .gpio = GS_OOLITE_V5_2_DEV_GPIO_LED_SYSTEM,
48 .active_low = 0,
49 },
50 };
51
52 static struct gpio_keys_button gs_oolite_v5_2_dev_gpio_keys[] __initdata = {
53 {
54 .desc = "reset",
55 .type = EV_KEY,
56 .code = KEY_RESTART,
57 .debounce_interval = GS_KEYS_DEBOUNCE_INTERVAL,
58 .gpio = GS_OOLITE_V5_2_DEV_GPIO_BTN_RESET,
59 .active_low = 1,
60 },
61 };
62
63 static void __init gs_oolite_v5_2_setup(void)
64 {
65 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
66
67 ath79_register_m25p80(&gs_oolite_v5_2_flash_data);
68
69 ath79_setup_ar933x_phy4_switch(false, false);
70
71 ath79_register_mdio(0, 0x0);
72
73 ath79_switch_data.phy4_mii_en = 1;
74 ath79_switch_data.phy_poll_mask |= BIT(4);
75
76 /* LAN */
77 ath79_eth1_data.duplex = DUPLEX_FULL;
78 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
79 ath79_init_mac(ath79_eth1_data.mac_addr, art + 6, 0);
80 ath79_register_eth(1);
81
82 /* WAN */
83 ath79_eth0_data.duplex = DUPLEX_FULL;
84 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
85 ath79_eth0_data.phy_mask = BIT(4);
86 ath79_eth0_data.speed = SPEED_100;
87 ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
88 ath79_register_eth(0);
89
90 ath79_register_pci();
91 ath79_register_usb();
92 ath79_register_wmac(art + GS_OOLITE_V5_2_WMAC_CALDATA_OFFSET, NULL);
93 }
94
95 static void __init gs_oolite_v5_2_dev_setup(void)
96 {
97 gs_oolite_v5_2_setup();
98
99 ath79_register_leds_gpio(-1, ARRAY_SIZE(gs_oolite_v5_2_dev_gpio_leds),
100 gs_oolite_v5_2_dev_gpio_leds);
101
102 ath79_register_gpio_keys_polled(-1, GS_KEYS_POLL_INTERVAL,
103 ARRAY_SIZE(gs_oolite_v5_2_dev_gpio_keys),
104 gs_oolite_v5_2_dev_gpio_keys);
105 }
106
107 MIPS_MACHINE(ATH79_MACH_GS_OOLITE_V5_2, "OOLITE-V5-2",
108 "GainStrong Oolite V5.2", gs_oolite_v5_2_setup);
109
110 MIPS_MACHINE(ATH79_MACH_GS_OOLITE_V5_2_DEV, "OOLITE-V5-2-DEV",
111 "GainStrong Oolite V5.2-Dev", gs_oolite_v5_2_dev_setup);