2 * D-Link DIR-615 rev. E4 board support
4 * Copyright (C) 2010 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-ar71xx/ar71xx.h>
19 #include "dev-m25p80.h"
20 #include "dev-ap91-pci.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
25 #define DIR_615_E4_GPIO_LED_WPS 0
26 #define DIR_615_E4_GPIO_LED_POWER_AMBER 1
27 #define DIR_615_E4_GPIO_LED_POWER_GREEN 6
28 #define DIR_615_E4_GPIO_LED_WAN_AMBER 7
29 #define DIR_615_E4_GPIO_LED_WAN_GREEN 17
30 #define DIR_615_E4_GPIO_LED_LAN1_GREEN 13
31 #define DIR_615_E4_GPIO_LED_LAN2_GREEN 14
32 #define DIR_615_E4_GPIO_LED_LAN3_GREEN 15
33 #define DIR_615_E4_GPIO_LED_LAN4_GREEN 16
35 #define DIR_615_E4_GPIO_BTN_RESET 8
36 #define DIR_615_E4_GPIO_BTN_WPS 12
38 #define DIR_615_E4_KEYS_POLL_INTERVAL 20
39 #define DIR_615_E4_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615_E4_KEYS_POLL_INTERVAL)
41 #define DIR_615_E4_NVRAM_ADDR 0x1f030000
42 #define DIR_615_E4_NVRAM_SIZE 0x10000
44 #ifdef CONFIG_MTD_PARTITIONS
45 static struct mtd_partition dir_615_e4_partitions
[] = {
50 .mask_flags
= MTD_WRITEABLE
,
67 .mask_flags
= MTD_WRITEABLE
,
72 .mask_flags
= MTD_WRITEABLE
,
79 #endif /* CONFIG_MTD_PARTITIONS */
81 static struct flash_platform_data dir_615_e4_flash_data
= {
82 #ifdef CONFIG_MTD_PARTITIONS
83 .parts
= dir_615_e4_partitions
,
84 .nr_parts
= ARRAY_SIZE(dir_615_e4_partitions
),
89 static struct gpio_led dir_615_e4_leds_gpio
[] __initdata
= {
91 .name
= "d-link:green:power",
92 .gpio
= DIR_615_E4_GPIO_LED_POWER_GREEN
,
94 .name
= "d-link:amber:power",
95 .gpio
= DIR_615_E4_GPIO_LED_POWER_AMBER
,
97 .name
= "d-link:green:wan",
98 .gpio
= DIR_615_E4_GPIO_LED_WAN_GREEN
,
101 .name
= "d-link:amber:wan",
102 .gpio
= DIR_615_E4_GPIO_LED_WAN_AMBER
,
104 .name
= "d-link:green:lan1",
105 .gpio
= DIR_615_E4_GPIO_LED_LAN1_GREEN
,
108 .name
= "d-link:green:lan2",
109 .gpio
= DIR_615_E4_GPIO_LED_LAN2_GREEN
,
112 .name
= "d-link:green:lan3",
113 .gpio
= DIR_615_E4_GPIO_LED_LAN3_GREEN
,
116 .name
= "d-link:green:lan4",
117 .gpio
= DIR_615_E4_GPIO_LED_LAN4_GREEN
,
120 .name
= "d-link:blue:wps",
121 .gpio
= DIR_615_E4_GPIO_LED_WPS
,
126 static struct gpio_keys_button dir_615_e4_gpio_keys
[] __initdata
= {
131 .debounce_interval
= DIR_615_E4_KEYS_DEBOUNCE_INTERVAL
,
132 .gpio
= DIR_615_E4_GPIO_BTN_RESET
,
137 .code
= KEY_WPS_BUTTON
,
138 .debounce_interval
= DIR_615_E4_KEYS_DEBOUNCE_INTERVAL
,
139 .gpio
= DIR_615_E4_GPIO_BTN_WPS
,
144 static void __init
dir_615_e4_setup(void)
146 const char *nvram
= (char *) KSEG1ADDR(DIR_615_E4_NVRAM_ADDR
);
147 u8
*ee
= (u8
*) KSEG1ADDR(0x1fff1000);
151 if (nvram_parse_mac_addr(nvram
, DIR_615_E4_NVRAM_SIZE
,
152 "lan_mac=", mac_buff
) == 0) {
153 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac_buff
, 0);
154 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, mac_buff
, 1);
158 ar71xx_add_device_m25p80(&dir_615_e4_flash_data
);
160 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_615_e4_leds_gpio
),
161 dir_615_e4_leds_gpio
);
163 ar71xx_register_gpio_keys_polled(-1, DIR_615_E4_KEYS_POLL_INTERVAL
,
164 ARRAY_SIZE(dir_615_e4_gpio_keys
),
165 dir_615_e4_gpio_keys
);
167 ar71xx_init_mac(ar71xx_eth0_data
.mac_addr
, mac
, 0);
168 ar71xx_init_mac(ar71xx_eth1_data
.mac_addr
, mac
, 1);
170 ar71xx_add_device_mdio(0, 0x0);
173 ar71xx_add_device_eth(1);
176 ar71xx_add_device_eth(0);
178 ap91_pci_setup_wmac_led_pin(1);
179 ap91_pci_init(ee
, mac
);
182 MIPS_MACHINE(AR71XX_MACH_DIR_615_E4
, "DIR-615-E4", "D-Link DIR-615 rev. E4",