ramips: rt305x: add support for the Asus RT-G32 B1 board
[openwrt/staging/lynxis/omap.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-rt-g32-revb.c
1 /*
2 * Asus RT-G32 rev B board support
3 *
4 * Copyright (C) 2011 Sergiy <piratfm@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 #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
18 #include <asm/mach-ralink/machine.h>
19 #include <asm/mach-ralink/dev-gpio-buttons.h>
20 #include <asm/mach-ralink/rt305x.h>
21 #include <asm/mach-ralink/rt305x_regs.h>
22
23 #include "devices.h"
24
25 #define RT_G32B_GPIO_BUTTON_WPS 0 /* active low */
26 #define RT_G32B_GPIO_BUTTON_RESET 10 /* active low */
27
28 #define RT_G32B_BUTTONS_POLL_INTERVAL 20
29
30 #ifdef CONFIG_MTD_PARTITIONS
31 static struct mtd_partition rt_g32b_partitions[] = {
32 {
33 .name = "u-boot",
34 .offset = 0,
35 .size = 0x030000,
36 .mask_flags = MTD_WRITEABLE,
37 }, {
38 .name = "devdata",
39 .offset = 0x030000,
40 .size = 0x010000,
41 .mask_flags = MTD_WRITEABLE,
42 }, {
43 .name = "devconf",
44 .offset = 0x040000,
45 .size = 0x010000,
46 .mask_flags = MTD_WRITEABLE,
47 }, {
48 .name = "kernel",
49 .offset = 0x050000,
50 .size = 0x0d0000,
51 }, {
52 .name = "rootfs",
53 .offset = 0x120000,
54 .size = 0x2e0000,
55 }, {
56 .name = "firmware",
57 .offset = 0x050000,
58 .size = 0x3b0000,
59 }
60 };
61 #endif /* CONFIG_MTD_PARTITIONS */
62
63 const struct flash_platform_data rt_g32b_flash = {
64 .type = "mx25l3205d",
65 #ifdef CONFIG_MTD_PARTITIONS
66 .parts = rt_g32b_partitions,
67 .nr_parts = ARRAY_SIZE(rt_g32b_partitions),
68 #endif
69 };
70
71 struct spi_board_info __initdata rt_g32b_spi_slave_info[] = {
72 {
73 .modalias = "m25p80",
74 .platform_data = &rt_g32b_flash,
75 .irq = -1,
76 .max_speed_hz = 10000000,
77 .bus_num = 0,
78 .chip_select = 0,
79 },
80 };
81
82 static struct gpio_button rt_g32b_gpio_buttons[] __initdata = {
83 {
84 .desc = "reset",
85 .type = EV_KEY,
86 .code = KEY_RESTART,
87 .threshold = 3,
88 .gpio = RT_G32B_GPIO_BUTTON_RESET,
89 .active_low = 1,
90 }, {
91 .desc = "wps",
92 .type = EV_KEY,
93 .code = KEY_WPS_BUTTON,
94 .threshold = 3,
95 .gpio = RT_G32B_GPIO_BUTTON_WPS,
96 .active_low = 1,
97 }
98 };
99
100 static void __init rt_g32b_init(void)
101 {
102 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
103 rt305x_register_spi(rt_g32b_spi_slave_info,
104 ARRAY_SIZE(rt_g32b_spi_slave_info));
105
106 rt305x_register_ethernet();
107 ramips_register_gpio_buttons(-1, RT_G32B_BUTTONS_POLL_INTERVAL,
108 ARRAY_SIZE(rt_g32b_gpio_buttons),
109 rt_g32b_gpio_buttons);
110 rt305x_register_wifi();
111 rt305x_register_wdt();
112 }
113
114 MIPS_MACHINE(RAMIPS_MACH_RT_G32_B1, "RT-G32-B1", "Asus RT-G32 B1",
115 rt_g32b_init);