2 * D-Link DIR-600 rev. A1 board support
4 * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2012 Vadim Girlin <vadimgirlin@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/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
15 #include <asm/mach-ath79/ath79.h>
16 #include <asm/mach-ath79/ar71xx_regs.h>
19 #include "dev-ap9x-pci.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
24 #include "machtypes.h"
27 #define DIR_600_A1_GPIO_LED_WPS 0
28 #define DIR_600_A1_GPIO_LED_POWER_AMBER 1
29 #define DIR_600_A1_GPIO_LED_POWER_GREEN 6
30 #define DIR_600_A1_GPIO_LED_LAN1 13
31 #define DIR_600_A1_GPIO_LED_LAN2 14
32 #define DIR_600_A1_GPIO_LED_LAN3 15
33 #define DIR_600_A1_GPIO_LED_LAN4 16
34 #define DIR_600_A1_GPIO_LED_WAN_AMBER 7
35 #define DIR_600_A1_GPIO_LED_WAN_GREEN 17
37 #define DIR_600_A1_GPIO_BTN_RESET 8
38 #define DIR_600_A1_GPIO_BTN_WPS 12
40 #define DIR_600_A1_KEYS_POLL_INTERVAL 20 /* msecs */
41 #define DIR_600_A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_600_A1_KEYS_POLL_INTERVAL)
43 #define DIR_600_A1_NVRAM_ADDR 0x1f030000
44 #define DIR_600_A1_NVRAM_SIZE 0x10000
46 static struct mtd_partition dir_600_a1_partitions[] = {
51 .mask_flags = MTD_WRITEABLE,
68 .mask_flags = MTD_WRITEABLE,
73 .mask_flags = MTD_WRITEABLE,
81 static struct flash_platform_data dir_600_a1_flash_data = {
82 .parts = dir_600_a1_partitions,
83 .nr_parts = ARRAY_SIZE(dir_600_a1_partitions),
86 static struct gpio_led dir_600_a1_leds_gpio[] __initdata = {
88 .name = "d-link:green:power",
89 .gpio = DIR_600_A1_GPIO_LED_POWER_GREEN,
91 .name = "d-link:amber:power",
92 .gpio = DIR_600_A1_GPIO_LED_POWER_AMBER,
94 .name = "d-link:amber:wan",
95 .gpio = DIR_600_A1_GPIO_LED_WAN_AMBER,
97 .name = "d-link:green:wan",
98 .gpio = DIR_600_A1_GPIO_LED_WAN_GREEN,
101 .name = "d-link:green:lan1",
102 .gpio = DIR_600_A1_GPIO_LED_LAN1,
105 .name = "d-link:green:lan2",
106 .gpio = DIR_600_A1_GPIO_LED_LAN2,
109 .name = "d-link:green:lan3",
110 .gpio = DIR_600_A1_GPIO_LED_LAN3,
113 .name = "d-link:green:lan4",
114 .gpio = DIR_600_A1_GPIO_LED_LAN4,
117 .name = "d-link:blue:wps",
118 .gpio = DIR_600_A1_GPIO_LED_WPS,
123 static struct gpio_keys_button dir_600_a1_gpio_keys[] __initdata = {
128 .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
129 .gpio = DIR_600_A1_GPIO_BTN_RESET,
134 .code = KEY_WPS_BUTTON,
135 .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
136 .gpio = DIR_600_A1_GPIO_BTN_WPS,
141 static void __init dir_600_a1_setup(void)
143 const char *nvram = (char *) KSEG1ADDR(DIR_600_A1_NVRAM_ADDR);
144 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
148 if (ath79_nvram_parse_mac_addr(nvram, DIR_600_A1_NVRAM_SIZE,
149 "lan_mac=", mac_buff) == 0) {
150 ath79_init_mac(ath79_eth0_data.mac_addr, mac_buff, 0);
151 ath79_init_mac(ath79_eth1_data.mac_addr, mac_buff, 1);
155 ath79_register_m25p80(&dir_600_a1_flash_data);
157 ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
158 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
159 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
160 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
161 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
163 ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio),
164 dir_600_a1_leds_gpio);
166 ath79_register_gpio_keys_polled(-1, DIR_600_A1_KEYS_POLL_INTERVAL,
167 ARRAY_SIZE(dir_600_a1_gpio_keys),
168 dir_600_a1_gpio_keys);
170 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
171 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
173 ath79_register_mdio(0, 0x0);
176 ath79_register_eth(1);
179 ath79_register_eth(0);
181 ap91_pci_init(ee, mac);
184 MIPS_MACHINE(ATH79_MACH_DIR_600_A1, "DIR-600-A1", "D-Link DIR-600 rev. A1",
187 static void __init dir_615_e4_setup(void)
190 ap9x_pci_setup_wmac_led_pin(0, 1);
193 MIPS_MACHINE(ATH79_MACH_DIR_615_E4, "DIR-615-E4", "D-Link DIR-615 rev. E4",