2 * ALFA Network R36A board support
4 * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com>
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>
12 #include <linux/platform_device.h>
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
24 #include "machtypes.h"
26 #define R36A_GPIO_LED_LAN 4
27 #define R36A_GPIO_LED_STATUS 14
28 #define R36A_GPIO_LED_USB 12
29 #define R36A_GPIO_LED_WAN 16
30 #define R36A_GPIO_LED_WLAN 15
32 #define R36A_GPIO_WDT_EN 1
33 #define R36A_GPIO_WDT_IN 0
34 #define R36A_GPIO_USB_PWR 3
36 #define R36A_GPIO_BTN_RESET 2
37 #define R36A_GPIO_BTN_RFKILL 17
39 #define R36A_KEYS_POLL_INTERVAL 20
40 #define R36A_KEYS_DEBOUNCE_INTERVAL (3 * R36A_KEYS_POLL_INTERVAL)
42 #define R36A_WMAC_CALDATA_OFFSET 0x1000
44 static struct gpio_led r36a_leds_gpio[] __initdata = {
46 .name = "r36a:blue:lan",
47 .gpio = R36A_GPIO_LED_LAN,
50 .name = "r36a:blue:status",
51 .gpio = R36A_GPIO_LED_STATUS,
54 .name = "r36a:blue:usb",
55 .gpio = R36A_GPIO_LED_USB,
58 .name = "r36a:blue:wan",
59 .gpio = R36A_GPIO_LED_WAN,
62 .name = "r36a:blue:wlan",
63 .gpio = R36A_GPIO_LED_WLAN,
68 static struct gpio_keys_button r36a_gpio_keys[] __initdata = {
73 .debounce_interval = R36A_KEYS_DEBOUNCE_INTERVAL,
74 .gpio = R36A_GPIO_BTN_RESET,
80 .debounce_interval = R36A_KEYS_DEBOUNCE_INTERVAL,
81 .gpio = R36A_GPIO_BTN_RFKILL,
86 static void __init r36a_setup(void)
88 u8 *art = (u8 *) KSEG1ADDR(0x1f070000);
90 ath79_register_m25p80(NULL);
92 ath79_setup_ar933x_phy4_switch(false, false);
94 ath79_register_mdio(0, 0x0);
96 ath79_switch_data.phy4_mii_en = 1;
97 ath79_switch_data.phy_poll_mask = 0xf7;
100 ath79_eth0_data.duplex = DUPLEX_FULL;
101 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
102 ath79_eth0_data.phy_mask = BIT(4);
103 ath79_eth0_data.speed = SPEED_100;
104 ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
105 ath79_register_eth(0);
108 ath79_eth1_data.duplex = DUPLEX_FULL;
109 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
110 ath79_init_mac(ath79_eth1_data.mac_addr, art, 1);
111 ath79_register_eth(1);
113 /* Disable JTAG (enables GPIO0-3) */
114 ath79_gpio_function_enable(AR934X_GPIO_FUNC_JTAG_DISABLE);
116 ath79_register_leds_gpio(-1, ARRAY_SIZE(r36a_leds_gpio),
119 ath79_register_gpio_keys_polled(-1, R36A_KEYS_POLL_INTERVAL,
120 ARRAY_SIZE(r36a_gpio_keys),
123 gpio_request_one(R36A_GPIO_WDT_IN,
124 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
127 gpio_request_one(R36A_GPIO_WDT_EN,
128 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
131 gpio_request_one(R36A_GPIO_USB_PWR,
132 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
135 ath79_register_wmac(art + R36A_WMAC_CALDATA_OFFSET, NULL);
137 ath79_register_usb();
140 MIPS_MACHINE(ATH79_MACH_R36A, "R36A", "ALFA Network R36A", r36a_setup);