2 * devolo dLAN Hotspot board support
4 * Copyright (C) 2015 Torsten Schnuis <torsten.schnuis@gik.de>
5 * Copyright (C) 2015 devolo AG
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
12 #include <linux/gpio.h>
14 #include <asm/mach-ath79/ath79.h>
17 #include "dev-gpio-buttons.h"
18 #include "dev-leds-gpio.h"
19 #include "dev-m25p80.h"
22 #include "machtypes.h"
24 #define DLAN_HOTSPOT_GPIO_LED_WIFI 0
26 #define DLAN_HOTSPOT_GPIO_BTN_RESET 11
27 #define DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING 12
28 #define DLAN_HOTSPOT_GPIO_BTN_WIFI 21
30 #define DLAN_HOTSPOT_GPIO_PLC_POWER 22
31 #define DLAN_HOTSPOT_GPIO_PLC_RESET 20
32 #define DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS 18
34 #define DLAN_HOTSPOT_KEYS_POLL_INTERVAL 20 /* msecs */
35 #define DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL (3 * DLAN_HOTSPOT_KEYS_POLL_INTERVAL)
37 #define DLAN_HOTSPOT_ART_ADDRESS 0x1fff0000
38 #define DLAN_HOTSPOT_CALDATA_OFFSET 0x00001000
39 #define DLAN_HOTSPOT_MAC_ADDRESS_OFFSET 0x00001002
41 static struct gpio_led dlan_hotspot_leds_gpio[] __initdata = {
43 .name = "devolo:green:wifi",
44 .gpio = DLAN_HOTSPOT_GPIO_LED_WIFI,
49 static struct gpio_keys_button dlan_hotspot_gpio_keys[] __initdata = {
51 .desc = "Reset button",
54 .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
55 .gpio = DLAN_HOTSPOT_GPIO_BTN_RESET,
59 .desc = "Pairing button",
62 .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
63 .gpio = DLAN_HOTSPOT_GPIO_BTN_PLC_PAIRING,
67 .desc = "WLAN button",
69 .code = KEY_WPS_BUTTON,
70 .debounce_interval = DLAN_HOTSPOT_KEYS_DEBOUNCE_INTERVAL,
71 .gpio = DLAN_HOTSPOT_GPIO_BTN_WIFI,
76 static void __init dlan_hotspot_setup(void)
78 u8 *art = (u8 *) KSEG1ADDR(DLAN_HOTSPOT_ART_ADDRESS);
79 u8 *cal = art + DLAN_HOTSPOT_CALDATA_OFFSET;
80 u8 *wifi_mac = art + DLAN_HOTSPOT_MAC_ADDRESS_OFFSET;
82 /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
83 ath79_setup_ar933x_phy4_switch(false, false);
85 ath79_register_leds_gpio(-1, ARRAY_SIZE(dlan_hotspot_leds_gpio),
86 dlan_hotspot_leds_gpio);
88 ath79_register_gpio_keys_polled(-1, DLAN_HOTSPOT_KEYS_POLL_INTERVAL,
89 ARRAY_SIZE(dlan_hotspot_gpio_keys),
90 dlan_hotspot_gpio_keys);
92 gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_POWER,
93 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
95 gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_RESET,
96 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
98 gpio_request_one(DLAN_HOTSPOT_GPIO_PLC_DISABLE_LEDS,
99 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
102 ath79_register_usb();
104 ath79_register_m25p80(NULL);
106 ath79_init_mac(ath79_eth0_data.mac_addr, wifi_mac, 1);
107 ath79_init_mac(ath79_eth1_data.mac_addr, wifi_mac, 2);
109 ath79_register_mdio(0, 0x0);
110 ath79_register_eth(0);
111 ath79_register_eth(1);
113 ath79_register_wmac(cal, wifi_mac);
116 MIPS_MACHINE(ATH79_MACH_DLAN_HOTSPOT, "dLAN-Hotspot",
117 "dLAN Hotspot", dlan_hotspot_setup);