4 * Copyright (C) 2012 Mikko Hissa <mikko.hissa@uta.fi>
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/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/spi/spi.h>
14 #include <linux/spi/flash.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/mtd/physmap.h>
19 #include <asm/mach-ralink/machine.h>
20 #include <asm/mach-ralink/dev-gpio-buttons.h>
21 #include <asm/mach-ralink/dev-gpio-leds.h>
22 #include <asm/mach-ralink/rt305x.h>
23 #include <asm/mach-ralink/rt305x_regs.h>
27 #define DIR_615_H1_GPIO_LED_WAN_AMBER 12 /* active low */
28 #define DIR_615_H1_GPIO_LED_WAN_GREEN 13 /* active low */
29 #define DIR_615_H1_GPIO_LED_WPS_BLUE 14 /* active low */
31 #define DIR_615_H1_GPIO_LED_STATUS_AMBER 7
32 #define DIR_615_H1_GPIO_LED_STATUS_GREEN 9
34 #define DIR_615_H1_GPIO_BUTTON_RESET 10 /* active low */
35 #define DIR_615_H1_GPIO_BUTTON_WPS 0 /* active low */
37 #define DIR_615_H1_KEYS_POLL_INTERVAL 20
38 #define DIR_615_H1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615_H1_KEYS_POLL_INTERVAL)
40 static struct gpio_led dir_615_h1_leds_gpio[] __initdata = {
42 .name = "d-link:amber:status",
43 .gpio = DIR_615_H1_GPIO_LED_STATUS_AMBER,
45 .name = "d-link:green:status",
46 .gpio = DIR_615_H1_GPIO_LED_STATUS_GREEN,
48 .name = "d-link:amber:wan",
49 .gpio = DIR_615_H1_GPIO_LED_WAN_AMBER,
52 .name = "d-link:green:wan",
53 .gpio = DIR_615_H1_GPIO_LED_WAN_GREEN,
56 .name = "d-link:blue:wps",
57 .gpio = DIR_615_H1_GPIO_LED_WPS_BLUE,
62 static struct gpio_keys_button dir_615_h1_gpio_buttons[] __initdata = {
67 .debounce_interval = DIR_615_H1_KEYS_DEBOUNCE_INTERVAL,
68 .gpio = DIR_615_H1_GPIO_BUTTON_RESET,
73 .code = KEY_WPS_BUTTON,
74 .debounce_interval = DIR_615_H1_KEYS_DEBOUNCE_INTERVAL,
75 .gpio = DIR_615_H1_GPIO_BUTTON_WPS,
80 const struct flash_platform_data dir615h1_flash = {
84 struct spi_board_info dir615h1_spi_slave_info[] __initdata = {
87 .platform_data = &dir615h1_flash,
89 .max_speed_hz = 10000000,
95 static void __init dir615h1_init(void)
97 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
98 rt305x_register_spi(dir615h1_spi_slave_info,
99 ARRAY_SIZE(dir615h1_spi_slave_info));
100 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
101 rt305x_register_ethernet();
102 ramips_register_gpio_leds(-1, ARRAY_SIZE(dir_615_h1_leds_gpio),
103 dir_615_h1_leds_gpio);
104 ramips_register_gpio_buttons(-1, DIR_615_H1_KEYS_POLL_INTERVAL,
105 ARRAY_SIZE(dir_615_h1_gpio_buttons),
106 dir_615_h1_gpio_buttons);
107 rt305x_register_wifi();
108 rt305x_register_wdt();
111 MIPS_MACHINE(RAMIPS_MACH_DIR_615_H1, "DIR-615-H1", "D-Link DIR-615 H1",