2 * D-Link DIR-600 rev. A1 board support
4 * Copyright (C) 2010 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/mtd/mtd.h>
12 #include <linux/mtd/partitions.h>
14 #include <asm/mach-ar71xx/ar71xx.h>
18 #include "dev-m25p80.h"
19 #include "dev-ap91-pci.h"
20 #include "dev-gpio-buttons.h"
21 #include "dev-leds-gpio.h"
24 #define DIR_600_A1_GPIO_LED_WPS 0
25 #define DIR_600_A1_GPIO_LED_POWER_AMBER 1
26 #define DIR_600_A1_GPIO_LED_POWER_GREEN 6
28 #define DIR_600_A1_GPIO_BTN_RESET 8
29 #define DIR_600_A1_GPIO_BTN_WPS 12
31 #define DIR_600_A1_KEYS_POLL_INTERVAL 20 /* msecs */
32 #define DIR_600_A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_600_A1_KEYS_POLL_INTERVAL)
34 #define DIR_600_A1_NVRAM_ADDR 0x1f030000
35 #define DIR_600_A1_NVRAM_SIZE 0x10000
37 #ifdef CONFIG_MTD_PARTITIONS
38 static struct mtd_partition dir_600_a1_partitions[] = {
43 .mask_flags = MTD_WRITEABLE,
60 .mask_flags = MTD_WRITEABLE,
65 .mask_flags = MTD_WRITEABLE,
72 #endif /* CONFIG_MTD_PARTITIONS */
74 static struct flash_platform_data dir_600_a1_flash_data = {
75 #ifdef CONFIG_MTD_PARTITIONS
76 .parts = dir_600_a1_partitions,
77 .nr_parts = ARRAY_SIZE(dir_600_a1_partitions),
81 static struct gpio_led dir_600_a1_leds_gpio[] __initdata = {
83 .name = "dir-600-a1:green:power",
84 .gpio = DIR_600_A1_GPIO_LED_POWER_GREEN,
86 .name = "dir-600-a1:amber:power",
87 .gpio = DIR_600_A1_GPIO_LED_POWER_AMBER,
89 .name = "dir-600-a1:blue:wps",
90 .gpio = DIR_600_A1_GPIO_LED_WPS,
95 static struct gpio_keys_button dir_600_a1_gpio_keys[] __initdata = {
100 .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
101 .gpio = DIR_600_A1_GPIO_BTN_RESET,
106 .code = KEY_WPS_BUTTON,
107 .debounce_interval = DIR_600_A1_KEYS_DEBOUNCE_INTERVAL,
108 .gpio = DIR_600_A1_GPIO_BTN_WPS,
113 static void __init dir_600_a1_setup(void)
115 const char *nvram = (char *) KSEG1ADDR(DIR_600_A1_NVRAM_ADDR);
116 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
120 if (nvram_parse_mac_addr(nvram, DIR_600_A1_NVRAM_SIZE,
121 "lan_mac=", mac_buff) == 0) {
122 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac_buff, 0);
123 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac_buff, 1);
127 ar71xx_add_device_m25p80(&dir_600_a1_flash_data);
129 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio),
130 dir_600_a1_leds_gpio);
132 ar71xx_register_gpio_keys_polled(-1, DIR_600_A1_KEYS_POLL_INTERVAL,
133 ARRAY_SIZE(dir_600_a1_gpio_keys),
134 dir_600_a1_gpio_keys);
136 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0);
137 ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1);
139 ar71xx_add_device_mdio(0, 0x0);
142 ar71xx_add_device_eth(1);
145 ar71xx_add_device_eth(0);
147 ap91_pci_init(ee, mac);
150 MIPS_MACHINE(AR71XX_MACH_DIR_600_A1, "DIR-600-A1", "D-Link DIR-600 rev. A1",