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
27 #define DIR_600_A1_GPIO_LED_LAN1 13
28 #define DIR_600_A1_GPIO_LED_LAN2 14
29 #define DIR_600_A1_GPIO_LED_LAN3 15
30 #define DIR_600_A1_GPIO_LED_LAN4 16
31 #define DIR_600_A1_GPIO_LED_WAN_AMBER 7
32 #define DIR_600_A1_GPIO_LED_WAN_GREEN 17
34 #define DIR_600_A1_GPIO_BTN_RESET 8
35 #define DIR_600_A1_GPIO_BTN_WPS 12
37 #define DIR_600_A1_KEYS_POLL_INTERVAL 20 /* msecs */
38 #define DIR_600_A1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_600_A1_KEYS_POLL_INTERVAL)
40 #define DIR_600_A1_NVRAM_ADDR 0x1f030000
41 #define DIR_600_A1_NVRAM_SIZE 0x10000
43 #ifdef CONFIG_MTD_PARTITIONS
44 static struct mtd_partition dir_600_a1_partitions
[] = {
49 .mask_flags
= MTD_WRITEABLE
,
66 .mask_flags
= MTD_WRITEABLE
,
71 .mask_flags
= MTD_WRITEABLE
,
78 #endif /* CONFIG_MTD_PARTITIONS */
80 static struct flash_platform_data dir_600_a1_flash_data
= {
81 #ifdef CONFIG_MTD_PARTITIONS
82 .parts
= dir_600_a1_partitions
,
83 .nr_parts
= ARRAY_SIZE(dir_600_a1_partitions
),
87 static struct gpio_led dir_600_a1_leds_gpio
[] __initdata
= {
89 .name
= "d-link:green:power",
90 .gpio
= DIR_600_A1_GPIO_LED_POWER_GREEN
,
92 .name
= "d-link:amber:power",
93 .gpio
= DIR_600_A1_GPIO_LED_POWER_AMBER
,
95 .name
= "d-link:amber:wan",
96 .gpio
= DIR_600_A1_GPIO_LED_WAN_AMBER
,
98 .name
= "d-link:green:wan",
99 .gpio
= DIR_600_A1_GPIO_LED_WAN_GREEN
,
102 .name
= "d-link:green:lan1",
103 .gpio
= DIR_600_A1_GPIO_LED_LAN1
,
106 .name
= "d-link:green:lan2",
107 .gpio
= DIR_600_A1_GPIO_LED_LAN2
,
110 .name
= "d-link:green:lan3",
111 .gpio
= DIR_600_A1_GPIO_LED_LAN3
,
114 .name
= "d-link:green:lan4",
115 .gpio
= DIR_600_A1_GPIO_LED_LAN4
,
118 .name
= "d-link:blue:wps",
119 .gpio
= DIR_600_A1_GPIO_LED_WPS
,
124 static struct gpio_keys_button dir_600_a1_gpio_keys
[] __initdata
= {
129 .debounce_interval
= DIR_600_A1_KEYS_DEBOUNCE_INTERVAL
,
130 .gpio
= DIR_600_A1_GPIO_BTN_RESET
,
135 .code
= KEY_WPS_BUTTON
,
136 .debounce_interval
= DIR_600_A1_KEYS_DEBOUNCE_INTERVAL
,
137 .gpio
= DIR_600_A1_GPIO_BTN_WPS
,
142 static void __init
dir_600_a1_setup(void)
144 const char *nvram
= (char *) KSEG1ADDR(DIR_600_A1_NVRAM_ADDR
);
145 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
149 if (nvram_parse_mac_addr(nvram
, DIR_600_A1_NVRAM_SIZE
,
150 "lan_mac=", mac_buff
) == 0) {
151 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac_buff
, 0);
152 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, mac_buff
, 1);
156 ar71xx_add_device_m25p80(&dir_600_a1_flash_data
);
158 ar71xx_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN
|
159 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN
|
160 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN
|
161 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN
|
162 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN
);
164 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_600_a1_leds_gpio
),
165 dir_600_a1_leds_gpio
);
167 ar71xx_register_gpio_keys_polled(-1, DIR_600_A1_KEYS_POLL_INTERVAL
,
168 ARRAY_SIZE(dir_600_a1_gpio_keys
),
169 dir_600_a1_gpio_keys
);
171 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac
, 0);
172 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, mac
, 1);
174 ar71xx_add_device_mdio(0, 0x0);
177 ar71xx_add_device_eth(1);
180 ar71xx_add_device_eth(0);
182 ap91_pci_init(ee
, mac
);
185 MIPS_MACHINE(AR71XX_MACH_DIR_600_A1
, "DIR-600-A1", "D-Link DIR-600 rev. A1",