Root/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-wl-330n.c

1/*
2 * Asus WL_330N board support
3 *
4 * Copyright (C) 2012 Frederic Leroy <fredo@starox.org>
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
16#include <asm/mach-ralink/machine.h>
17#include <asm/mach-ralink/dev-gpio-buttons.h>
18#include <asm/mach-ralink/dev-gpio-leds.h>
19#include <asm/mach-ralink/rt305x.h>
20#include <asm/mach-ralink/rt305x_regs.h>
21
22#include "devices.h"
23
24#define WL_330N_GPIO_BUTTON_RESET 10
25#define WL_330N_GPIO_BUTTON_WPS 0
26#define WL_330N_GPIO_LED_LINK 9
27#define WL_330N_GPIO_LED_POWER 11
28#define WL_330N_KEYS_POLL_INTERVAL 20
29#define WL_330N_KEYS_DEBOUNCE_INTERVAL (3 * WL_330N_KEYS_POLL_INTERVAL)
30
31const struct flash_platform_data wl_330n_flash = {
32    .type = "mx25l3205d",
33};
34
35struct spi_board_info wl_330n_spi_slave_info[] __initdata = {
36    {
37        .modalias = "m25p80",
38        .platform_data = &wl_330n_flash,
39        .irq = -1,
40        .max_speed_hz = 10000000,
41        .bus_num = 0,
42        .chip_select = 0,
43    },
44};
45
46static struct gpio_keys_button wl_330n_gpio_buttons[] __initdata = {
47    {
48        .desc = "reset",
49        .type = EV_KEY,
50        .code = KEY_RESTART,
51        .debounce_interval = WL_330N_KEYS_DEBOUNCE_INTERVAL,
52        .gpio = WL_330N_GPIO_BUTTON_RESET,
53        .active_low = 1,
54    },
55    {
56        .desc = "wps",
57        .type = EV_KEY,
58        .code = KEY_RESTART,
59        .debounce_interval = WL_330N_KEYS_DEBOUNCE_INTERVAL,
60        .gpio = WL_330N_GPIO_BUTTON_WPS,
61        .active_low = 1,
62    }
63};
64
65static struct gpio_led wl_330n_leds_gpio[] __initdata = {
66    {
67        .name = "asus:blue:link",
68        .gpio = WL_330N_GPIO_LED_LINK,
69        .active_low = 1,
70    }, {
71        .name = "asus:blue:power",
72        .gpio = WL_330N_GPIO_LED_POWER,
73        .active_low = 1,
74    }
75};
76
77static void __init wl_330n_init(void)
78{
79    rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
80    rt305x_register_spi(wl_330n_spi_slave_info,
81                ARRAY_SIZE(wl_330n_spi_slave_info));
82    rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
83    rt305x_register_ethernet();
84    ramips_register_gpio_leds(-1, ARRAY_SIZE(wl_330n_leds_gpio),
85                  wl_330n_leds_gpio);
86    ramips_register_gpio_buttons(-1, WL_330N_KEYS_POLL_INTERVAL,
87                     ARRAY_SIZE(wl_330n_gpio_buttons),
88                     wl_330n_gpio_buttons);
89    rt305x_register_wifi();
90    rt305x_register_wdt();
91}
92
93MIPS_MACHINE(RAMIPS_MACH_WL_330N, "WL_330N", "Asus WL-330N",
94         wl_330n_init);
95

Archive Download this file



interactive