2 * ALFA Network N5Q 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>
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
23 #include "machtypes.h"
25 #define N5Q_GPIO_LED_LAN 19
26 #define N5Q_GPIO_LED_SIGNAL1 0
27 #define N5Q_GPIO_LED_SIGNAL2 1
28 #define N5Q_GPIO_LED_SIGNAL3 2
29 #define N5Q_GPIO_LED_SIGNAL4 3
30 #define N5Q_GPIO_LED_WAN 18
31 #define N5Q_GPIO_LED_WLAN 12
33 #define N5Q_GPIO_WDT_EN 16
34 #define N5Q_GPIO_WDT_IN 17
36 #define N5Q_GPIO_BTN_RESET 11
38 #define N5Q_MAC0_OFFSET 0
39 #define N5Q_MAC1_OFFSET 6
40 #define N5Q_WMAC_CALDATA_OFFSET 0x1000
42 #define N5Q_KEYS_POLL_INTERVAL 20
43 #define N5Q_KEYS_DEBOUNCE_INTERVAL (3 * N5Q_KEYS_POLL_INTERVAL)
45 static struct gpio_led n5q_leds_gpio
[] __initdata
= {
47 .name
= "n5q:green:lan",
48 .gpio
= N5Q_GPIO_LED_LAN
,
51 .name
= "n5q:red:signal1",
52 .gpio
= N5Q_GPIO_LED_SIGNAL1
,
55 .name
= "n5q:orange:signal2",
56 .gpio
= N5Q_GPIO_LED_SIGNAL2
,
59 .name
= "n5q:green:signal3",
60 .gpio
= N5Q_GPIO_LED_SIGNAL3
,
63 .name
= "n5q:green:signal4",
64 .gpio
= N5Q_GPIO_LED_SIGNAL4
,
67 .name
= "n5q:green:wan",
68 .gpio
= N5Q_GPIO_LED_WAN
,
71 .name
= "n5q:green:wlan",
72 .gpio
= N5Q_GPIO_LED_WLAN
,
77 static struct gpio_keys_button n5q_gpio_keys
[] __initdata
= {
82 .debounce_interval
= N5Q_KEYS_DEBOUNCE_INTERVAL
,
83 .gpio
= N5Q_GPIO_BTN_RESET
,
88 static void __init
n5q_setup(void)
90 u8
*art
= (u8
*) KSEG1ADDR(0x1f070000);
92 ath79_register_m25p80(NULL
);
94 ath79_register_mdio(1, 0x0);
96 ath79_switch_data
.phy4_mii_en
= 1;
97 ath79_switch_data
.phy_poll_mask
= 0xf7;
100 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
101 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
102 ath79_init_mac(ath79_eth1_data
.mac_addr
, art
+ N5Q_MAC1_OFFSET
, 0);
103 ath79_register_eth(1);
106 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
107 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio1_device
.dev
;
108 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
109 ath79_eth0_data
.phy_mask
= BIT(4);
110 ath79_eth0_data
.speed
= SPEED_100
;
111 ath79_init_mac(ath79_eth0_data
.mac_addr
, art
+ N5Q_MAC0_OFFSET
, 0);
112 ath79_register_eth(0);
114 ath79_register_leds_gpio(-1, ARRAY_SIZE(n5q_leds_gpio
),
117 ath79_register_gpio_keys_polled(-1, N5Q_KEYS_POLL_INTERVAL
,
118 ARRAY_SIZE(n5q_gpio_keys
),
121 gpio_request_one(N5Q_GPIO_WDT_IN
,
122 GPIOF_OUT_INIT_LOW
| GPIOF_EXPORT_DIR_FIXED
,
125 gpio_request_one(N5Q_GPIO_WDT_EN
,
126 GPIOF_OUT_INIT_LOW
| GPIOF_EXPORT_DIR_FIXED
,
129 ath79_register_wmac(art
+ N5Q_WMAC_CALDATA_OFFSET
, NULL
);
132 MIPS_MACHINE(ATH79_MACH_N5Q
, "N5Q", "ALFA Network N5Q", n5q_setup
);