2 * HiWiFi HC6361 board support
4 * Copyright (C) 2012-2013 eric
5 * Copyright (C) 2014 Yousong Zhou <yszhou4tech@gmail.com>
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 <linux/gpio.h>
13 #include <linux/proc_fs.h>
15 #include <asm/mach-ath79/ath79.h>
16 #include <asm/mach-ath79/ar71xx_regs.h>
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
22 #include "dev-m25p80.h"
25 #include "machtypes.h"
27 #define HIWIFI_HC6361_GPIO_LED_WLAN_2P4 0 /* 2.4G WLAN LED */
28 #define HIWIFI_HC6361_GPIO_LED_SYSTEM 1 /* System LED */
29 #define HIWIFI_HC6361_GPIO_LED_INTERNET 27 /* Internet LED */
31 #define HIWIFI_HC6361_GPIO_USBPOWER 20 /* USB power control */
32 #define HIWIFI_HC6361_GPIO_BTN_RST 11 /* Reset button */
34 #define HIWIFI_HC6361_KEYS_POLL_INTERVAL 20 /* msecs */
35 #define HIWIFI_HC6361_KEYS_DEBOUNCE_INTERVAL \
36 (3 * HIWIFI_HC6361_KEYS_POLL_INTERVAL)
38 static struct gpio_led hiwifi_leds_gpio
[] __initdata
= {
40 .name
= "hiwifi:blue:wlan-2p4",
41 .gpio
= HIWIFI_HC6361_GPIO_LED_WLAN_2P4
,
44 .name
= "hiwifi:blue:system",
45 .gpio
= HIWIFI_HC6361_GPIO_LED_SYSTEM
,
48 .name
= "hiwifi:blue:internet",
49 .gpio
= HIWIFI_HC6361_GPIO_LED_INTERNET
,
54 static struct gpio_keys_button hiwifi_gpio_keys
[] __initdata
= {
59 .debounce_interval
= HIWIFI_HC6361_KEYS_DEBOUNCE_INTERVAL
,
60 .gpio
= HIWIFI_HC6361_GPIO_BTN_RST
,
65 static void __init
get_mac_from_bdinfo(u8
*mac
, void *bdinfo
)
67 if (sscanf(bdinfo
, "fac_mac = %2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx",
68 &mac
[0], &mac
[1], &mac
[2], &mac
[3],
69 &mac
[4], &mac
[5]) == 6) {
73 printk(KERN_WARNING
"Parsing MAC address failed.\n");
74 memcpy(mac
, "\x00\xba\xbe\x00\x00\x00", 6);
77 static void __init
hiwifi_hc6361_setup(void)
79 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
82 ath79_setup_ar933x_phy4_switch(false, false);
84 ath79_register_m25p80(NULL
);
85 ath79_gpio_function_enable(
86 AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
87 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
88 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
89 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
90 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
92 ath79_register_leds_gpio(-1, ARRAY_SIZE(hiwifi_leds_gpio
),
94 ath79_register_gpio_keys_polled(-1, HIWIFI_HC6361_KEYS_POLL_INTERVAL
,
95 ARRAY_SIZE(hiwifi_gpio_keys
),
97 gpio_request_one(HIWIFI_HC6361_GPIO_USBPOWER
,
98 GPIOF_OUT_INIT_HIGH
| GPIOF_EXPORT_DIR_FIXED
,
100 ath79_register_usb();
102 get_mac_from_bdinfo(mac
, (void *) KSEG1ADDR(0x1f010180));
103 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 1);
104 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 0);
106 ath79_register_mdio(0, 0x0);
108 ath79_register_eth(1);
109 ath79_register_eth(0);
111 ath79_register_wmac(ee
, mac
);
114 MIPS_MACHINE(ATH79_MACH_HIWIFI_HC6361
, "HiWiFi-HC6361",
115 "HiWiFi HC6361", hiwifi_hc6361_setup
);