ramips: rename dev_gpio_leds.h to dev-gpio-leds.h
[openwrt/svn-archive/archive.git] / target / linux / ramips / files / arch / mips / ralink / rt288x / mach-rt-n15.c
1 /*
2 * Asus RT-N15 board support
3 *
4 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.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/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/leds.h>
17 #include <linux/rtl8366s.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/rt288x.h>
23 #include <asm/mach-ralink/rt288x_regs.h>
24
25 #include "devices.h"
26
27 #define RT_N15_GPIO_LED_POWER 11
28 #define RT_N15_GPIO_BUTTON_WPS 0
29 #define RT_N15_GPIO_BUTTON_RESET 12
30
31 #define RT_N15_GPIO_RTL8366_SCK 2
32 #define RT_N15_GPIO_RTL8366_SDA 1
33
34 #define RT_N15_BUTTONS_POLL_INTERVAL 20
35
36 #ifdef CONFIG_MTD_PARTITIONS
37 static struct mtd_partition rt_n15_partitions[] = {
38 {
39 .name = "u-boot",
40 .offset = 0,
41 .size = 0x030000,
42 .mask_flags = MTD_WRITEABLE,
43 }, {
44 .name = "u-boot-env",
45 .offset = 0x030000,
46 .size = 0x010000,
47 .mask_flags = MTD_WRITEABLE,
48 }, {
49 .name = "factory",
50 .offset = 0x040000,
51 .size = 0x010000,
52 .mask_flags = MTD_WRITEABLE,
53 }, {
54 .name = "kernel",
55 .offset = 0x050000,
56 .size = 0x0b0000,
57 }, {
58 .name = "rootfs",
59 .offset = 0x100000,
60 .size = 0x300000,
61 }, {
62 .name = "openwrt",
63 .offset = 0x050000,
64 .size = 0x3b0000,
65 }
66 };
67 #endif /* CONFIG_MTD_PARTITIONS */
68
69 static struct physmap_flash_data rt_n15_flash_data = {
70 #ifdef CONFIG_MTD_PARTITIONS
71 .nr_parts = ARRAY_SIZE(rt_n15_partitions),
72 .parts = rt_n15_partitions,
73 #endif
74 };
75
76 static struct gpio_led rt_n15_leds_gpio[] __initdata = {
77 {
78 .name = "rt-n15:blue:power",
79 .gpio = RT_N15_GPIO_LED_POWER,
80 .active_low = 1,
81 }
82 };
83
84 static struct gpio_button rt_n15_gpio_buttons[] __initdata = {
85 {
86 .desc = "reset",
87 .type = EV_KEY,
88 .code = BTN_0,
89 .threshold = 3,
90 .gpio = RT_N15_GPIO_BUTTON_RESET,
91 .active_low = 1,
92 }, {
93 .desc = "wps",
94 .type = EV_KEY,
95 .code = BTN_1,
96 .threshold = 3,
97 .gpio = RT_N15_GPIO_BUTTON_WPS,
98 .active_low = 1,
99 }
100 };
101
102 static struct rtl8366s_platform_data rt_n15_rtl8366s_data = {
103 .gpio_sda = RT_N15_GPIO_RTL8366_SDA,
104 .gpio_sck = RT_N15_GPIO_RTL8366_SCK,
105 };
106
107 static struct platform_device rt_n15_rtl8366s_device = {
108 .name = RTL8366S_DRIVER_NAME,
109 .id = -1,
110 .dev = {
111 .platform_data = &rt_n15_rtl8366s_data,
112 }
113 };
114
115 static void __init rt_n15_init(void)
116 {
117 rt288x_gpio_init(RT2880_GPIO_MODE_UART0 | RT2880_GPIO_MODE_I2C);
118
119 rt288x_register_flash(0, &rt_n15_flash_data);
120
121 ramips_register_gpio_leds(-1, ARRAY_SIZE(rt_n15_leds_gpio),
122 rt_n15_leds_gpio);
123
124 ramips_register_gpio_buttons(-1, RT_N15_BUTTONS_POLL_INTERVAL,
125 ARRAY_SIZE(rt_n15_gpio_buttons),
126 rt_n15_gpio_buttons);
127
128 platform_device_register(&rt_n15_rtl8366s_device);
129 }
130
131 MIPS_MACHINE(RAMIPS_MACH_RT_N15, "RT-N15", "Asus RT-N15", rt_n15_init);