2 * D-Link DIR-615 rev C1 board support
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
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-ar913x-wmac.h"
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
25 #define DIR_615C1_GPIO_LED_ORANGE_STATUS 1 /* ORANGE:STATUS:TRICOLOR */
26 #define DIR_615C1_GPIO_LED_BLUE_WPS 3 /* BLUE:WPS */
27 #define DIR_615C1_GPIO_LED_GREEN_WAN 4 /* GREEN:WAN:TRICOLOR */
28 #define DIR_615C1_GPIO_LED_GREEN_WANCPU 5 /* GREEN:WAN:CPU:TRICOLOR */
29 #define DIR_615C1_GPIO_LED_GREEN_WLAN 6 /* GREEN:WLAN */
30 #define DIR_615C1_GPIO_LED_GREEN_STATUS 14 /* GREEN:STATUS:TRICOLOR */
31 #define DIR_615C1_GPIO_LED_ORANGE_WAN 15 /* ORANGE:WAN:TRICOLOR */
33 /* buttons may need refinement */
35 #define DIR_615C1_GPIO_BTN_WPS 12
36 #define DIR_615C1_GPIO_BTN_RESET 21
38 #define DIR_615C1_BUTTONS_POLL_INTERVAL 20
40 #define DIR_615C1_CONFIG_ADDR 0x1f020000
41 #define DIR_615C1_CONFIG_SIZE 0x10000
43 #ifdef CONFIG_MTD_PARTITIONS
44 static struct mtd_partition dir_615c1_partitions[] = {
49 .mask_flags = MTD_WRITEABLE,
66 .mask_flags = MTD_WRITEABLE,
73 #endif /* CONFIG_MTD_PARTITIONS */
75 static struct flash_platform_data dir_615c1_flash_data = {
76 #ifdef CONFIG_MTD_PARTITIONS
77 .parts = dir_615c1_partitions,
78 .nr_parts = ARRAY_SIZE(dir_615c1_partitions),
82 static struct gpio_led dir_615c1_leds_gpio[] __initdata = {
84 .name = "dir-615c1:orange:status",
85 .gpio = DIR_615C1_GPIO_LED_ORANGE_STATUS,
88 .name = "dir-615c1:blue:wps",
89 .gpio = DIR_615C1_GPIO_LED_BLUE_WPS,
92 .name = "dir-615c1:green:wan",
93 .gpio = DIR_615C1_GPIO_LED_GREEN_WAN,
96 .name = "dir-615c1:green:wancpu",
97 .gpio = DIR_615C1_GPIO_LED_GREEN_WANCPU,
100 .name = "dir-615c1:green:wlan",
101 .gpio = DIR_615C1_GPIO_LED_GREEN_WLAN,
104 .name = "dir-615c1:green:status",
105 .gpio = DIR_615C1_GPIO_LED_GREEN_STATUS,
108 .name = "dir-615c1:orange:wan",
109 .gpio = DIR_615C1_GPIO_LED_ORANGE_WAN,
115 static struct gpio_button dir_615c1_gpio_buttons[] __initdata = {
121 .gpio = DIR_615C1_GPIO_BTN_RESET,
127 .gpio = DIR_615C1_GPIO_BTN_WPS,
131 static void __init dir_615c1_setup(void)
133 const char *config = (char *) KSEG1ADDR(DIR_615C1_CONFIG_ADDR);
134 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
138 if (nvram_parse_mac_addr(config, DIR_615C1_CONFIG_SIZE,
139 "lan_mac=", mac) == 0) {
140 ar71xx_set_mac_base(mac);
144 ar71xx_add_device_mdio(0x0);
146 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
147 ar71xx_eth0_data.phy_mask = 0xf;
148 ar71xx_eth0_data.speed = SPEED_100;
149 ar71xx_eth0_data.duplex = DUPLEX_FULL;
151 ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
152 ar71xx_eth1_data.phy_mask = 0x10;
154 ar71xx_add_device_eth(0);
155 ar71xx_add_device_eth(1);
157 ar71xx_add_device_m25p80(&dir_615c1_flash_data);
159 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(dir_615c1_leds_gpio),
160 dir_615c1_leds_gpio);
162 ar71xx_add_device_gpio_buttons(-1, DIR_615C1_BUTTONS_POLL_INTERVAL,
163 ARRAY_SIZE(dir_615c1_gpio_buttons),
164 dir_615c1_gpio_buttons);
166 ar913x_add_device_wmac(eeprom, wlan_mac);
169 MIPS_MACHINE(AR71XX_MACH_DIR_615_C1, "DIR-615-C1", "D-Link DIR-615 rev. C1",