2 * Hak5 LAN Turtle and Packet Squirrel boards support
4 * Copyright (C) 2018 Sebastian Kinne <seb@hak5.org>
5 * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com>
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>
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"
23 #include "machtypes.h"
25 #define LAN_TURTLE_GPIO_BTN_RESET 11
26 #define LAN_TURTLE_GPIO_LED_SYS 13
28 #define PACKET_SQUIRREL_GPIO_BTN_SW1 18
29 #define PACKET_SQUIRREL_GPIO_BTN_SW2 20
30 #define PACKET_SQUIRREL_GPIO_BTN_SW3 21
31 #define PACKET_SQUIRREL_GPIO_BTN_SW4 24
32 #define PACKET_SQUIRREL_GPIO_BTN_RESET 11
33 #define PACKET_SQUIRREL_GPIO_LED_B 23
34 #define PACKET_SQUIRREL_GPIO_LED_G 22
35 #define PACKET_SQUIRREL_GPIO_LED_R 19
37 #define HAK5_KEYS_POLL_INTERVAL 20 /* msecs */
38 #define HAK5_KEYS_DEBOUNCE_INTERVAL (3 * HAK5_KEYS_POLL_INTERVAL)
40 static const char *hak5_part_probes
[] = {
45 static struct flash_platform_data hak5_flash_data
= {
46 .part_probes
= hak5_part_probes
,
50 static struct gpio_led lan_turtle_leds_gpio
[] __initdata
= {
52 .name
= "lan-turtle:orange:system",
53 .gpio
= LAN_TURTLE_GPIO_LED_SYS
,
58 static struct gpio_keys_button lan_turtle_gpio_keys
[] __initdata
= {
63 .debounce_interval
= HAK5_KEYS_DEBOUNCE_INTERVAL
,
64 .gpio
= LAN_TURTLE_GPIO_BTN_RESET
,
70 static struct gpio_led packet_squirrel_leds_gpio
[] __initdata
= {
72 .name
= "packet-squirrel:blue:system",
73 .gpio
= PACKET_SQUIRREL_GPIO_LED_B
,
76 .name
= "packet-squirrel:green:system",
77 .gpio
= PACKET_SQUIRREL_GPIO_LED_G
,
80 .name
= "packet-squirrel:red:system",
81 .gpio
= PACKET_SQUIRREL_GPIO_LED_R
,
86 static struct gpio_keys_button packet_squirrel_gpio_keys
[] __initdata
= {
91 .debounce_interval
= HAK5_KEYS_DEBOUNCE_INTERVAL
,
92 .gpio
= PACKET_SQUIRREL_GPIO_BTN_RESET
,
98 .debounce_interval
= HAK5_KEYS_DEBOUNCE_INTERVAL
,
99 .gpio
= PACKET_SQUIRREL_GPIO_BTN_SW1
,
105 .debounce_interval
= HAK5_KEYS_DEBOUNCE_INTERVAL
,
106 .gpio
= PACKET_SQUIRREL_GPIO_BTN_SW2
,
112 .debounce_interval
= HAK5_KEYS_DEBOUNCE_INTERVAL
,
113 .gpio
= PACKET_SQUIRREL_GPIO_BTN_SW3
,
119 .debounce_interval
= HAK5_KEYS_DEBOUNCE_INTERVAL
,
120 .gpio
= PACKET_SQUIRREL_GPIO_BTN_SW4
,
125 static void __init
hak5_common_setup(void)
127 u8
*mac
= (u8
*) KSEG1ADDR(0x1f01fc00);
129 ath79_register_m25p80(&hak5_flash_data
);
131 ath79_register_mdio(0, 0x0);
133 ath79_switch_data
.phy_poll_mask
= 0xfe;
135 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 1);
136 ath79_register_eth(0);
138 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, -1);
139 ath79_register_eth(1);
141 ath79_register_usb();
144 ath79_gpio_function_disable(AR933X_GPIO_FUNC_UART_RTS_CTS_EN
);
147 static void __init
lan_turtle_setup(void)
152 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN
);
154 ath79_register_leds_gpio(-1, ARRAY_SIZE(lan_turtle_leds_gpio
),
155 lan_turtle_leds_gpio
);
157 ath79_register_gpio_keys_polled(-1, HAK5_KEYS_POLL_INTERVAL
,
158 ARRAY_SIZE(lan_turtle_gpio_keys
),
159 lan_turtle_gpio_keys
);
162 static void __init
packet_squirrel_setup(void)
166 ath79_register_leds_gpio(-1, ARRAY_SIZE(packet_squirrel_leds_gpio
),
167 packet_squirrel_leds_gpio
);
169 ath79_register_gpio_keys_polled(-1, HAK5_KEYS_POLL_INTERVAL
,
170 ARRAY_SIZE(packet_squirrel_gpio_keys
),
171 packet_squirrel_gpio_keys
);
174 MIPS_MACHINE(ATH79_MACH_LAN_TURTLE
, "LAN-TURTLE",
175 "Hak5 LAN Turtle", lan_turtle_setup
);
177 MIPS_MACHINE(ATH79_MACH_PACKET_SQUIRREL
, "PACKET-SQUIRREL",
178 "Hak5 Packet Squirrel", packet_squirrel_setup
);