OpenWrt – Blame information for rev 2
?pathlinks?
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | office | 1 | /* |
| 2 | * Hak5 LAN Turtle and Packet Squirrel boards support |
||
| 3 | * |
||
| 4 | * Copyright (C) 2018 Sebastian Kinne <seb@hak5.org> |
||
| 5 | * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com> |
||
| 6 | * |
||
| 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. |
||
| 10 | */ |
||
| 11 | |||
| 12 | #include <linux/gpio.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 "machtypes.h" |
||
| 24 | |||
| 25 | #define LAN_TURTLE_GPIO_BTN_RESET 11 |
||
| 26 | #define LAN_TURTLE_GPIO_LED_SYS 13 |
||
| 27 | |||
| 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 |
||
| 36 | |||
| 37 | #define HAK5_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
| 38 | #define HAK5_KEYS_DEBOUNCE_INTERVAL (3 * HAK5_KEYS_POLL_INTERVAL) |
||
| 39 | |||
| 40 | static const char *hak5_part_probes[] = { |
||
| 41 | "tp-link", |
||
| 42 | NULL, |
||
| 43 | }; |
||
| 44 | |||
| 45 | static struct flash_platform_data hak5_flash_data = { |
||
| 46 | .part_probes = hak5_part_probes, |
||
| 47 | }; |
||
| 48 | |||
| 49 | /* LAN Turtle */ |
||
| 50 | static struct gpio_led lan_turtle_leds_gpio[] __initdata = { |
||
| 51 | { |
||
| 52 | .name = "lan-turtle:orange:system", |
||
| 53 | .gpio = LAN_TURTLE_GPIO_LED_SYS, |
||
| 54 | .active_low = 1, |
||
| 55 | }, |
||
| 56 | }; |
||
| 57 | |||
| 58 | static struct gpio_keys_button lan_turtle_gpio_keys[] __initdata = { |
||
| 59 | { |
||
| 60 | .desc = "reset", |
||
| 61 | .type = EV_KEY, |
||
| 62 | .code = KEY_RESTART, |
||
| 63 | .debounce_interval = HAK5_KEYS_DEBOUNCE_INTERVAL, |
||
| 64 | .gpio = LAN_TURTLE_GPIO_BTN_RESET, |
||
| 65 | .active_low = 1, |
||
| 66 | }, |
||
| 67 | }; |
||
| 68 | |||
| 69 | /* Packet Squirrel */ |
||
| 70 | static struct gpio_led packet_squirrel_leds_gpio[] __initdata = { |
||
| 71 | { |
||
| 72 | .name = "packet-squirrel:blue:system", |
||
| 73 | .gpio = PACKET_SQUIRREL_GPIO_LED_B, |
||
| 74 | .active_low = 1, |
||
| 75 | }, { |
||
| 76 | .name = "packet-squirrel:green:system", |
||
| 77 | .gpio = PACKET_SQUIRREL_GPIO_LED_G, |
||
| 78 | .active_low = 1, |
||
| 79 | }, { |
||
| 80 | .name = "packet-squirrel:red:system", |
||
| 81 | .gpio = PACKET_SQUIRREL_GPIO_LED_R, |
||
| 82 | .active_low = 1, |
||
| 83 | }, |
||
| 84 | }; |
||
| 85 | |||
| 86 | static struct gpio_keys_button packet_squirrel_gpio_keys[] __initdata = { |
||
| 87 | { |
||
| 88 | .desc = "reset", |
||
| 89 | .type = EV_KEY, |
||
| 90 | .code = KEY_RESTART, |
||
| 91 | .debounce_interval = HAK5_KEYS_DEBOUNCE_INTERVAL, |
||
| 92 | .gpio = PACKET_SQUIRREL_GPIO_BTN_RESET, |
||
| 93 | .active_low = 1, |
||
| 94 | }, { |
||
| 95 | .desc = "sw1", |
||
| 96 | .type = EV_KEY, |
||
| 97 | .code = BTN_0, |
||
| 98 | .debounce_interval = HAK5_KEYS_DEBOUNCE_INTERVAL, |
||
| 99 | .gpio = PACKET_SQUIRREL_GPIO_BTN_SW1, |
||
| 100 | .active_low = 1, |
||
| 101 | }, { |
||
| 102 | .desc = "sw2", |
||
| 103 | .type = EV_KEY, |
||
| 104 | .code = BTN_1, |
||
| 105 | .debounce_interval = HAK5_KEYS_DEBOUNCE_INTERVAL, |
||
| 106 | .gpio = PACKET_SQUIRREL_GPIO_BTN_SW2, |
||
| 107 | .active_low = 1, |
||
| 108 | }, { |
||
| 109 | .desc = "sw3", |
||
| 110 | .type = EV_KEY, |
||
| 111 | .code = BTN_2, |
||
| 112 | .debounce_interval = HAK5_KEYS_DEBOUNCE_INTERVAL, |
||
| 113 | .gpio = PACKET_SQUIRREL_GPIO_BTN_SW3, |
||
| 114 | .active_low = 1, |
||
| 115 | }, { |
||
| 116 | .desc = "sw4", |
||
| 117 | .type = EV_KEY, |
||
| 118 | .code = BTN_3, |
||
| 119 | .debounce_interval = HAK5_KEYS_DEBOUNCE_INTERVAL, |
||
| 120 | .gpio = PACKET_SQUIRREL_GPIO_BTN_SW4, |
||
| 121 | .active_low = 1, |
||
| 122 | }, |
||
| 123 | }; |
||
| 124 | |||
| 125 | static void __init hak5_common_setup(void) |
||
| 126 | { |
||
| 127 | u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); |
||
| 128 | |||
| 129 | ath79_register_m25p80(&hak5_flash_data); |
||
| 130 | |||
| 131 | ath79_register_mdio(0, 0x0); |
||
| 132 | |||
| 133 | ath79_switch_data.phy_poll_mask = 0xfe; |
||
| 134 | |||
| 135 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1); |
||
| 136 | ath79_register_eth(0); |
||
| 137 | |||
| 138 | ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1); |
||
| 139 | ath79_register_eth(1); |
||
| 140 | |||
| 141 | ath79_register_usb(); |
||
| 142 | |||
| 143 | /* GPIO11/12 */ |
||
| 144 | ath79_gpio_function_disable(AR933X_GPIO_FUNC_UART_RTS_CTS_EN); |
||
| 145 | } |
||
| 146 | |||
| 147 | static void __init lan_turtle_setup(void) |
||
| 148 | { |
||
| 149 | hak5_common_setup(); |
||
| 150 | |||
| 151 | /* GPIO13 */ |
||
| 152 | ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN); |
||
| 153 | |||
| 154 | ath79_register_leds_gpio(-1, ARRAY_SIZE(lan_turtle_leds_gpio), |
||
| 155 | lan_turtle_leds_gpio); |
||
| 156 | |||
| 157 | ath79_register_gpio_keys_polled(-1, HAK5_KEYS_POLL_INTERVAL, |
||
| 158 | ARRAY_SIZE(lan_turtle_gpio_keys), |
||
| 159 | lan_turtle_gpio_keys); |
||
| 160 | } |
||
| 161 | |||
| 162 | static void __init packet_squirrel_setup(void) |
||
| 163 | { |
||
| 164 | hak5_common_setup(); |
||
| 165 | |||
| 166 | ath79_register_leds_gpio(-1, ARRAY_SIZE(packet_squirrel_leds_gpio), |
||
| 167 | packet_squirrel_leds_gpio); |
||
| 168 | |||
| 169 | ath79_register_gpio_keys_polled(-1, HAK5_KEYS_POLL_INTERVAL, |
||
| 170 | ARRAY_SIZE(packet_squirrel_gpio_keys), |
||
| 171 | packet_squirrel_gpio_keys); |
||
| 172 | } |
||
| 173 | |||
| 174 | MIPS_MACHINE(ATH79_MACH_LAN_TURTLE, "LAN-TURTLE", |
||
| 175 | "Hak5 LAN Turtle", lan_turtle_setup); |
||
| 176 | |||
| 177 | MIPS_MACHINE(ATH79_MACH_PACKET_SQUIRREL, "PACKET-SQUIRREL", |
||
| 178 | "Hak5 Packet Squirrel", packet_squirrel_setup); |