Root/target/linux/ramips/files/arch/mips/ralink/rt305x/mach-fonera20n.c

1/*
2 * La Fonera20N board support
3 *
4 * Copyright (C) 2009 John Crispin <blogic@openwrt.org>
5 * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
6 *
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.
10 */
11
12#include <linux/init.h>
13#include <linux/platform_device.h>
14
15#include <asm/mach-ralink/machine.h>
16#include <asm/mach-ralink/dev-gpio-buttons.h>
17#include <asm/mach-ralink/dev-gpio-leds.h>
18#include <asm/mach-ralink/rt305x.h>
19#include <asm/mach-ralink/rt305x_regs.h>
20
21#include "devices.h"
22
23#define FONERA20N_GPIO_BUTTON_RESET 12
24#define FONERA20N_GPIO_SWITCH 13
25#define FONERA20N_GPIO_LED_WIFI 7
26#define FONERA20N_GPIO_LED_POWER 9
27#define FONERA20N_GPIO_LED_USB 14
28
29#define FONERA20N_KEYS_POLL_INTERVAL 20
30#define FONERA20N_KEYS_DEBOUNCE_INTERVAL (3 * FONERA20N_KEYS_POLL_INTERVAL)
31
32static struct gpio_led fonera20n_leds_gpio[] __initdata = {
33    {
34        .name = "fonera20n:orange:wifi",
35        .gpio = FONERA20N_GPIO_LED_WIFI,
36        .active_low = 1,
37    }, {
38        .name = "fonera20n:green:power",
39        .gpio = FONERA20N_GPIO_LED_POWER,
40        .active_low = 1,
41    }, {
42        .name = "fonera20n:orange:usb",
43        .gpio = FONERA20N_GPIO_LED_USB,
44        .active_low = 1,
45    }
46};
47
48static struct gpio_keys_button fonera20n_gpio_buttons[] __initdata = {
49    {
50        .desc = "reset",
51        .type = EV_KEY,
52        .code = KEY_RESTART,
53        .debounce_interval = FONERA20N_KEYS_DEBOUNCE_INTERVAL,
54        .gpio = FONERA20N_GPIO_BUTTON_RESET,
55        .active_low = 1,
56    }, {
57        .desc = "switch",
58        .type = EV_KEY,
59        .code = BTN_1,
60        .debounce_interval = FONERA20N_KEYS_DEBOUNCE_INTERVAL,
61        .gpio = FONERA20N_GPIO_SWITCH,
62        .active_low = 1,
63    }
64};
65
66static void __init fonera20n_init(void)
67{
68    rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
69
70    rt305x_register_flash(0);
71
72    ramips_register_gpio_leds(-1, ARRAY_SIZE(fonera20n_leds_gpio),
73                  fonera20n_leds_gpio);
74
75    ramips_register_gpio_buttons(-1, FONERA20N_KEYS_POLL_INTERVAL,
76                     ARRAY_SIZE(fonera20n_gpio_buttons),
77                     fonera20n_gpio_buttons);
78
79    rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
80    rt305x_register_ethernet();
81    rt305x_register_wifi();
82    rt305x_register_wdt();
83    rt305x_register_usb();
84}
85
86MIPS_MACHINE(RAMIPS_MACH_FONERA20N, "FONERA20N", "La Fonera 2.0N",
87         fonera20n_init);
88

Archive Download this file



interactive