2 * ALFA Network AP91-5G 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>
18 #include "dev-ap9x-pci.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "dev-m25p80.h"
23 #include "machtypes.h"
25 #define AP91_5G_GPIO_LED_LAN 17
26 #define AP91_5G_GPIO_LED_SIGNAL1 12
27 #define AP91_5G_GPIO_LED_SIGNAL2 8
28 #define AP91_5G_GPIO_LED_SIGNAL3 6
29 #define AP91_5G_GPIO_LED_SIGNAL4 7
31 #define AP91_5G_GPIO_WDT_EN 1
32 #define AP91_5G_GPIO_WDT_IN 0
34 #define AP91_5G_GPIO_BTN_RESET 11
36 #define AP91_5G_KEYS_POLL_INTERVAL 20
37 #define AP91_5G_KEYS_DEBOUNCE_INTERVAL (3 * AP91_5G_KEYS_POLL_INTERVAL)
39 #define AP91_5G_WMAC_CALDATA_OFFSET 0x1000
41 static struct gpio_led ap91_5g_leds_gpio
[] __initdata
= {
43 .name
= "ap91-5g:green:lan",
44 .gpio
= AP91_5G_GPIO_LED_LAN
,
47 .name
= "ap91-5g:red:signal1",
48 .gpio
= AP91_5G_GPIO_LED_SIGNAL1
,
51 .name
= "ap91-5g:orange:signal2",
52 .gpio
= AP91_5G_GPIO_LED_SIGNAL2
,
55 .name
= "ap91-5g:green:signal3",
56 .gpio
= AP91_5G_GPIO_LED_SIGNAL3
,
59 .name
= "ap91-5g:green:signal4",
60 .gpio
= AP91_5G_GPIO_LED_SIGNAL4
,
65 static struct gpio_keys_button ap91_5g_gpio_keys
[] __initdata
= {
70 .debounce_interval
= AP91_5G_KEYS_DEBOUNCE_INTERVAL
,
71 .gpio
= AP91_5G_GPIO_BTN_RESET
,
76 static void __init
ap91_5g_setup(void)
78 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
80 ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE
,
81 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
83 gpio_set_value(AP91_5G_GPIO_LED_LAN
, 1);
84 gpio_set_value(AP91_5G_GPIO_LED_SIGNAL3
, 1);
85 gpio_set_value(AP91_5G_GPIO_LED_SIGNAL4
, 1);
87 ath79_register_m25p80(NULL
);
89 ath79_register_mdio(0, 0x0);
92 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
93 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
94 ath79_eth0_data
.phy_mask
= BIT(4);
95 ath79_eth0_data
.speed
= SPEED_100
;
96 ath79_init_mac(ath79_eth0_data
.mac_addr
, art
, 0);
97 ath79_register_eth(0);
99 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap91_5g_leds_gpio
),
102 ath79_register_gpio_keys_polled(-1, AP91_5G_KEYS_POLL_INTERVAL
,
103 ARRAY_SIZE(ap91_5g_gpio_keys
),
106 gpio_request_one(AP91_5G_GPIO_WDT_IN
,
107 GPIOF_OUT_INIT_LOW
| GPIOF_EXPORT_DIR_FIXED
,
110 gpio_request_one(AP91_5G_GPIO_WDT_EN
,
111 GPIOF_OUT_INIT_LOW
| GPIOF_EXPORT_DIR_FIXED
,
114 ap91_pci_init(art
+ AP91_5G_WMAC_CALDATA_OFFSET
, NULL
);
117 MIPS_MACHINE(ATH79_MACH_AP91_5G
, "AP91-5G", "ALFA Network AP91-5G",