2 * EW Dorin board support
3 * (based on Atheros Ref. Design AP121)
4 * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2012-2017 Embedded Wireless GmbH www.80211.de
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 <asm/mach-ath79/ath79.h>
13 #include <asm/mach-ath79/ar71xx_regs.h>
16 #include "dev-gpio-buttons.h"
17 #include "dev-leds-gpio.h"
18 #include "dev-m25p80.h"
22 #include "machtypes.h"
24 #define DORIN_KEYS_POLL_INTERVAL 20 /* msecs */
25 #define DORIN_KEYS_DEBOUNCE_INTERVAL (3 * DORIN_KEYS_POLL_INTERVAL)
27 #define DORIN_CALDATA_OFFSET 0x1000
28 #define DORIN_WMAC_MAC_OFFSET 0x1002
30 #define DORIN_GPIO_LED_STATUS 21
32 #define DORIN_GPIO_BTN_JUMPSTART 11
33 #define DORIN_GPIO_BTN_RESET 6
35 static struct gpio_led dorin_leds_gpio
[] __initdata
= {
37 .name
= "dorin:green:status",
38 .gpio
= DORIN_GPIO_LED_STATUS
,
43 static struct gpio_keys_button dorin_gpio_keys
[] __initdata
= {
45 .desc
= "jumpstart button",
47 .code
= KEY_WPS_BUTTON
,
48 .debounce_interval
= DORIN_KEYS_DEBOUNCE_INTERVAL
,
49 .gpio
= DORIN_GPIO_BTN_JUMPSTART
,
53 .desc
= "reset button",
56 .debounce_interval
= DORIN_KEYS_DEBOUNCE_INTERVAL
,
57 .gpio
= DORIN_GPIO_BTN_RESET
,
62 static void __init
ew_dorin_setup(void)
64 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
67 ath79_register_m25p80(NULL
);
71 if (ar93xx_wmac_read_mac_address(mac
)) {
72 ath79_register_wmac(NULL
, NULL
);
74 ath79_register_wmac(art
+ DORIN_CALDATA_OFFSET
,
75 art
+ DORIN_WMAC_MAC_OFFSET
);
76 memcpy(mac
, art
+ DORIN_WMAC_MAC_OFFSET
, sizeof(mac
));
80 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 0);
82 ath79_register_mdio(0, 0x0);
85 ath79_register_eth(1);
87 ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio
),
89 ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL
,
90 ARRAY_SIZE(dorin_gpio_keys
),
94 MIPS_MACHINE(ATH79_MACH_EW_DORIN
, "EW-DORIN", "EmbWir-Dorin",
98 static void __init
ew_dorin_router_setup(void)
100 u8
*art
= (u8
*) KSEG1ADDR(0x1fff0000);
103 ath79_register_m25p80(NULL
);
105 ath79_register_usb();
107 if (ar93xx_wmac_read_mac_address(mac
)) {
108 ath79_register_wmac(NULL
, NULL
);
110 ath79_register_wmac(art
+ DORIN_CALDATA_OFFSET
,
111 art
+ DORIN_WMAC_MAC_OFFSET
);
112 memcpy(mac
, art
+ DORIN_WMAC_MAC_OFFSET
, sizeof(mac
));
116 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 0);
119 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
120 ath79_setup_ar933x_phy4_switch(true, true);
122 ath79_register_mdio(0, 0x0);
125 ath79_register_eth(1);
128 ath79_register_eth(0);
130 ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio
),
132 ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL
,
133 ARRAY_SIZE(dorin_gpio_keys
),
137 MIPS_MACHINE(ATH79_MACH_EW_DORIN_ROUTER
, "EW-DORIN-ROUTER",
138 "EmbWir-Dorin-Router", ew_dorin_router_setup
);