2 * ALFA Network AP121F board support
4 * Copyright (C) 2017 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 AP121F_GPIO_LED_LAN 17
27 #define AP121F_GPIO_LED_VPN 27
28 #define AP121F_GPIO_LED_WLAN 0
30 #define AP121F_GPIO_MICROSD_EN 26
32 #define AP121F_GPIO_BTN_RESET 12
33 #define AP121F_GPIO_BTN_SWITCH 21
35 #define AP121F_KEYS_POLL_INTERVAL 20
36 #define AP121F_KEYS_DEBOUNCE_INTERVAL (3 * AP121F_KEYS_POLL_INTERVAL)
38 #define AP121F_WMAC_CALDATA_OFFSET 0x1000
40 static struct gpio_led ap121f_leds_gpio[] __initdata = {
42 .name = "ap121f:green:lan",
43 .gpio = AP121F_GPIO_LED_LAN,
46 .name = "ap121f:green:vpn",
47 .gpio = AP121F_GPIO_LED_VPN,
50 .name = "ap121f:green:wlan",
51 .gpio = AP121F_GPIO_LED_WLAN,
56 static struct gpio_keys_button ap121f_gpio_keys[] __initdata = {
61 .debounce_interval = AP121F_KEYS_DEBOUNCE_INTERVAL,
62 .gpio = AP121F_GPIO_BTN_RESET,
68 .debounce_interval = AP121F_KEYS_DEBOUNCE_INTERVAL,
69 .gpio = AP121F_GPIO_BTN_SWITCH,
74 static void __init ap121f_setup(void)
76 u8 *art = (u8 *) KSEG1ADDR(0x1f040000);
78 ath79_register_m25p80(NULL);
80 ath79_setup_ar933x_phy4_switch(false, false);
83 ath79_register_mdio(0, 0x0);
84 ath79_init_mac(ath79_eth0_data.mac_addr, art, 0);
85 ath79_register_eth(0);
87 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap121f_leds_gpio),
90 ath79_register_gpio_keys_polled(-1, AP121F_KEYS_POLL_INTERVAL,
91 ARRAY_SIZE(ap121f_gpio_keys),
94 gpio_request_one(AP121F_GPIO_MICROSD_EN,
95 GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
98 ath79_register_wmac(art + AP121F_WMAC_CALDATA_OFFSET, NULL);
100 ath79_register_usb();
103 MIPS_MACHINE(ATH79_MACH_AP121F, "AP121F", "ALFA Network AP121F", ap121f_setup);