Root/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-dir-615-h1.c

1/*
2 * D-Link DIR-615 H1
3 *
4 * Copyright (C) 2012 Mikko Hissa <mikko.hissa@uta.fi>
5 *
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.
9 */
10
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>
18
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>
24
25#include "devices.h"
26
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 */
30
31#define DIR_615_H1_GPIO_LED_STATUS_AMBER 7
32#define DIR_615_H1_GPIO_LED_STATUS_GREEN 9
33
34#define DIR_615_H1_GPIO_BUTTON_RESET 10 /* active low */
35#define DIR_615_H1_GPIO_BUTTON_WPS 0 /* active low */
36
37#define DIR_615_H1_KEYS_POLL_INTERVAL 20
38#define DIR_615_H1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615_H1_KEYS_POLL_INTERVAL)
39
40static struct gpio_led dir_615_h1_leds_gpio[] __initdata = {
41    {
42        .name = "d-link:amber:status",
43        .gpio = DIR_615_H1_GPIO_LED_STATUS_AMBER,
44    }, {
45        .name = "d-link:green:status",
46        .gpio = DIR_615_H1_GPIO_LED_STATUS_GREEN,
47    }, {
48        .name = "d-link:amber:wan",
49        .gpio = DIR_615_H1_GPIO_LED_WAN_AMBER,
50        .active_low = 1,
51    }, {
52        .name = "d-link:green:wan",
53        .gpio = DIR_615_H1_GPIO_LED_WAN_GREEN,
54        .active_low = 1,
55    }, {
56        .name = "d-link:blue:wps",
57        .gpio = DIR_615_H1_GPIO_LED_WPS_BLUE,
58        .active_low = 1,
59    }
60};
61
62static struct gpio_keys_button dir_615_h1_gpio_buttons[] __initdata = {
63    {
64        .desc = "reset",
65        .type = EV_KEY,
66        .code = KEY_RESTART,
67        .debounce_interval = DIR_615_H1_KEYS_DEBOUNCE_INTERVAL,
68        .gpio = DIR_615_H1_GPIO_BUTTON_RESET,
69        .active_low = 1,
70    }, {
71        .desc = "wps",
72        .type = EV_KEY,
73        .code = KEY_WPS_BUTTON,
74        .debounce_interval = DIR_615_H1_KEYS_DEBOUNCE_INTERVAL,
75        .gpio = DIR_615_H1_GPIO_BUTTON_WPS,
76        .active_low = 1,
77    }
78};
79
80const struct flash_platform_data dir615h1_flash = {
81    .type = "mx25l3205d",
82};
83
84struct spi_board_info dir615h1_spi_slave_info[] __initdata = {
85    {
86        .modalias = "m25p80",
87        .platform_data = &dir615h1_flash,
88        .irq = -1,
89        .max_speed_hz = 10000000,
90        .bus_num = 0,
91        .chip_select = 0,
92    },
93};
94
95static void __init dir615h1_init(void)
96{
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();
109}
110
111MIPS_MACHINE(RAMIPS_MACH_DIR_615_H1, "DIR-615-H1", "D-Link DIR-615 H1",
112         dir615h1_init);
113

Archive Download this file



interactive