aca238abe1b4fc96378767f92c59a8686bfea902
[openwrt.git] / target / linux / ramips / files-3.7 / arch / mips / ralink / rt305x / mach-air3gii.c
1 /*
2  *  AirLive Air3GII board support
3  *
4  *  Copyright (C) 2012 Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
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
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/spi/spi.h>
15 #include <linux/spi/flash.h>
16
17 #include <asm/mach-ralink/machine.h>
18 #include <asm/mach-ralink/dev-gpio-buttons.h>
19 #include <asm/mach-ralink/dev-gpio-leds.h>
20 #include <asm/mach-ralink/rt305x.h>
21 #include <asm/mach-ralink/rt305x_regs.h>
22
23 #include "devices.h"
24
25 #define AIR3GII_GPIO_BUTTON_WPS 7
26
27 #define AIR3GII_GPIO_LED_WLAN   8
28 #define AIR3GII_GPIO_LED_MOBILE 9
29
30 #define AIR3GII_KEYS_POLL_INTERVAL   20
31 #define AIR3GII_KEYS_DEBOUNCE_INTERVAL (3 * AIR3GII_KEYS_POLL_INTERVAL)
32
33 const struct flash_platform_data air3gii_flash = {
34         .type           = "en25q32b",
35 };
36
37 struct spi_board_info air3gii_spi_slave_info[] __initdata = {
38         {
39                 .modalias       = "m25p80",
40                 .platform_data  = &air3gii_flash,
41                 .irq            = -1,
42                 .max_speed_hz   = 10000000,
43                 .bus_num        = 0,
44                 .chip_select    = 0,
45         },
46 };
47
48 static struct gpio_led air3gii_leds_gpio[] __initdata = {
49         {
50                 .name           = "airlive:green:wlan",
51                 .gpio           = AIR3GII_GPIO_LED_WLAN,
52                 .active_low     = 0,
53         }, {
54                 .name           = "airlive:green:mobile",
55                 .gpio           = AIR3GII_GPIO_LED_MOBILE,
56                 .active_low     = 1,
57         }
58 };
59
60 static struct gpio_keys_button air3gii_gpio_buttons[] __initdata = {
61         {
62                 .desc           = "wps",
63                 .type           = EV_KEY,
64                 .code           = KEY_WPS_BUTTON,
65                 .debounce_interval = AIR3GII_KEYS_DEBOUNCE_INTERVAL,
66                 .gpio           = AIR3GII_GPIO_BUTTON_WPS,
67                 .active_low     = 1,
68         }
69 };
70
71 static void __init air3gii_init(void)
72 {
73         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
74
75         rt305x_register_spi(air3gii_spi_slave_info,
76                             ARRAY_SIZE(air3gii_spi_slave_info));
77
78         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
79         rt305x_register_ethernet();
80
81         ramips_register_gpio_leds(-1, ARRAY_SIZE(air3gii_leds_gpio),
82                                   air3gii_leds_gpio);
83
84         ramips_register_gpio_buttons(-1, AIR3GII_KEYS_POLL_INTERVAL,
85                                      ARRAY_SIZE(air3gii_gpio_buttons),
86                                      air3gii_gpio_buttons);
87
88         rt305x_register_wifi();
89         rt305x_register_wdt();
90         rt305x_register_usb();
91 }
92
93 MIPS_MACHINE(RAMIPS_MACH_AIR3GII, "AIR3GII", "AirLive Air3GII",
94                 air3gii_init);