2 * DLink DIR-505 A1 board support
4 * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
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>
13 #include <asm/mach-ath79/ath79.h>
14 #include <asm/mach-ath79/ar71xx_regs.h>
18 #include "dev-gpio-buttons.h"
19 #include "dev-leds-gpio.h"
20 #include "dev-m25p80.h"
23 #include "machtypes.h"
25 #define DIR_505A1_GPIO_BTN_WPS 11 /* verify */
26 #define DIR_505A1_GPIO_BTN_RESET 12 /* verify */
28 #define DIR_505A1_GPIO_LED_RED 26 /* unused, fyi */
29 #define DIR_505A1_GPIO_LED_GREEN 27
31 #define DIR_505A1_GPIO_WAN_LED_ENABLE 1
33 #define DIR_505A1_KEYS_POLL_INTERVAL 20 /* msecs */
34 #define DIR_505A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_505A1_KEYS_POLL_INTERVAL)
36 #define DIR_505A1_ART_ADDRESS 0x1f010000
37 #define DIR_505A1_CALDATA_OFFSET 0x1000
39 #define DIR_505A1_MAC_PART_ADDRESS 0x1f020000
40 #define DIR_505A1_LAN_MAC_OFFSET 0x04
41 #define DIR_505A1_WAN_MAC_OFFSET 0x16
43 static struct gpio_led dir_505_a1_leds_gpio[] __initdata = {
45 .name = "d-link:green:power",
46 .gpio = DIR_505A1_GPIO_LED_GREEN,
49 .name = "d-link:red:status",
50 .gpio = DIR_505A1_GPIO_LED_RED,
55 static struct gpio_keys_button dir_505_a1_gpio_keys[] __initdata = {
57 .desc = "Reset button",
60 .debounce_interval = DIR_505A1_KEYS_DEBOUNCE_INTERVAL,
61 .gpio = DIR_505A1_GPIO_BTN_RESET,
66 .code = KEY_WPS_BUTTON,
67 .debounce_interval = DIR_505A1_KEYS_DEBOUNCE_INTERVAL,
68 .gpio = DIR_505A1_GPIO_BTN_WPS,
73 static void __init dir_505_a1_setup(void)
75 u8 *art = (u8 *) KSEG1ADDR(DIR_505A1_ART_ADDRESS);
76 u8 *mac = (u8 *) KSEG1ADDR(DIR_505A1_MAC_PART_ADDRESS);
80 ath79_setup_ar933x_phy4_switch(false, false);
82 ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
83 AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
84 AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
85 AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
86 AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
88 gpio_request_one(DIR_505A1_GPIO_WAN_LED_ENABLE,
89 GPIOF_OUT_INIT_LOW, "WAN LED enable");
91 ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_505_a1_leds_gpio),
92 dir_505_a1_leds_gpio);
94 ath79_register_gpio_keys_polled(1, DIR_505A1_KEYS_POLL_INTERVAL,
95 ARRAY_SIZE(dir_505_a1_gpio_keys),
96 dir_505_a1_gpio_keys);
98 ath79_register_m25p80(NULL);
100 ath79_register_usb();
102 ath79_parse_ascii_mac(mac + DIR_505A1_LAN_MAC_OFFSET, lan_mac);
103 ath79_parse_ascii_mac(mac + DIR_505A1_WAN_MAC_OFFSET, wan_mac);
105 ath79_init_mac(ath79_eth0_data.mac_addr, wan_mac, 0);
106 ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
108 ath79_register_mdio(0, 0x0);
109 ath79_register_eth(1);
110 ath79_register_eth(0);
112 ath79_register_wmac(art + DIR_505A1_CALDATA_OFFSET, lan_mac);
115 MIPS_MACHINE(ATH79_MACH_DIR_505_A1, "DIR-505-A1",
116 "D-Link DIR-505 rev. A1", dir_505_a1_setup);