[mx2] vp6500: Add leds and keypad devices.
[openwrt.git] / target / linux / mx2 / files / arch / arm / mach-mx2 / mach-vp6500.c
1 #include <linux/platform_device.h>
2 #include <linux/mtd/mtd.h>
3 #include <linux/mtd/physmap.h>
4 #include <linux/gpio.h>
5 #include <linux/leds.h>
6
7 #include <mach/common.h>
8 #include <mach/hardware.h>
9 #include <asm/mach-types.h>
10 #include <asm/mach/arch.h>
11 #include <asm/mach/time.h>
12 #include <asm/mach/map.h>
13 #include <mach/imx-uart.h>
14 #include <mach/imxfb.h>
15 #include <mach/iomux-mx21.h>
16 #include <mach/board-vp6500.h>
17
18 #include "devices.h"
19
20 #include <linux/input.h>
21 #include <linux/input/matrix_keypad.h>
22 #include <linux/gpio_keys.h>
23
24 static unsigned int vp6500_pins[] = {
25
26 /* UART1 */
27 PE12_PF_UART1_TXD,
28 PE13_PF_UART1_RXD,
29
30 #if 0
31 /* LCDC */
32 PA5_PF_LSCLK,
33 PA6_PF_LD0,
34 PA7_PF_LD1,
35 PA8_PF_LD2,
36 PA9_PF_LD3,
37 PA10_PF_LD4,
38 PA11_PF_LD5,
39 PA12_PF_LD6,
40 PA13_PF_LD7,
41 PA14_PF_LD8,
42 PA15_PF_LD9,
43 PA16_PF_LD10,
44 PA17_PF_LD11,
45 PA18_PF_LD12,
46 PA19_PF_LD13,
47 PA20_PF_LD14,
48 PA21_PF_LD15,
49 PA22_PF_LD16,
50 PA28_PF_HSYNC,
51 PA29_PF_VSYNC,
52 PA30_PF_CONTRAST,
53 PA31_PF_OE_ACD,
54 #endif
55 };
56
57 static struct physmap_flash_data vp6500_flash_data = {
58 .width = 2,
59 };
60
61 static struct resource vp6500_flash_resource = {
62 .start = MX21_CS0_BASE_ADDR,
63 .end = MX21_CS0_BASE_ADDR + SZ_64M - 1,
64 .flags = IORESOURCE_MEM,
65 };
66
67 static struct platform_device vp6500_nor_mtd_device = {
68 .name = "physmap-flash",
69 .id = -1,
70 .dev = {
71 .platform_data = &vp6500_flash_data,
72 },
73 .num_resources = 1,
74 .resource = &vp6500_flash_resource,
75 };
76
77 static struct gpio_led vp6500_leds[] = {
78 {
79 .name = "vp6500:orange:keypad",
80 .gpio = VP6500_GPIO_LED_KEYPAD,
81 },
82 {
83 .name = "vp6500:green:",
84 .gpio = VP6500_GPIO_LED_GREEN,
85 .active_low = 1,
86 .default_state = LEDS_GPIO_DEFSTATE_ON,
87 },
88 {
89 .name = "vp6500:red:",
90 .gpio = VP6500_GPIO_LED_RED,
91 },
92 {
93 .name = "vp6500:red:camera",
94 .gpio = VP6500_GPIO_LED_CAMERA,
95 },
96 };
97
98 static struct gpio_led_platform_data vp6500_leds_data = {
99 .leds = vp6500_leds,
100 .num_leds = ARRAY_SIZE(vp6500_leds),
101 };
102
103 static struct platform_device vp6500_leds_device = {
104 .name = "leds-gpio",
105 .id = -1,
106 .dev = {
107 .platform_data = &vp6500_leds_data,
108 },
109 };
110
111 static const uint32_t vp6500_keypad_keys[] = {
112 KEY(0, 3, KEY_F2),
113 KEY(0, 4, KEY_RIGHT),
114 KEY(1, 0, KEY_ZOOM),
115 KEY(1, 1, KEY_NUMERIC_POUND),
116 KEY(1, 2, KEY_0),
117 KEY(1, 3, KEY_ENTER),
118 KEY(1, 4, KEY_8),
119 KEY(2, 0, KEY_5),
120 KEY(2, 1, KEY_2),
121 KEY(2, 2, KEY_DOWN),
122 KEY(2, 3, KEY_OK),
123 KEY(2, 4, KEY_UP),
124 KEY(3, 0, KEY_CAMERA),
125 KEY(3, 1, KEY_NUMERIC_STAR),
126 KEY(3, 2, KEY_9),
127 KEY(3, 3, KEY_LEFT),
128 KEY(3, 4, KEY_6),
129 KEY(4, 0, KEY_7),
130 KEY(4, 1, KEY_4),
131 KEY(4, 2, KEY_1),
132 KEY(4, 3, KEY_3),
133 KEY(4, 4, KEY_F1),
134 };
135
136 static struct matrix_keymap_data vp6500_keypad_data = {
137 .keymap = vp6500_keypad_keys,
138 .keymap_size = ARRAY_SIZE(vp6500_keypad_keys),
139 };
140
141 static struct resource vp6500_keypad_resources[] = {
142 {
143 .start = MX21_KPP_BASE_ADDR,
144 .end = MX21_KPP_BASE_ADDR + 0x10 - 1,
145 .flags = IORESOURCE_MEM,
146 },
147 {
148 .start = MX21_INT_KPP,
149 .flags = IORESOURCE_IRQ,
150 }
151 };
152
153 static struct platform_device vp6500_keypad_device = {
154 .name = "imx-keypad",
155 .id = 0,
156 .dev = {
157 .platform_data = &vp6500_keypad_data,
158 },
159 .resource = vp6500_keypad_resources,
160 .num_resources = ARRAY_SIZE(vp6500_keypad_resources),
161 };
162
163 static struct gpio_keys_button vp6500_keys = {
164 .gpio = VP6500_GPIO_POWER_KEY,
165 .code = KEY_POWER,
166 .desc = "Power button",
167 .active_low = 1,
168 };
169
170 static struct gpio_keys_platform_data vp6500_key_data = {
171 .buttons = &vp6500_keys,
172 .nbuttons = 1,
173 };
174
175 static struct platform_device vp6500_key_device = {
176 .name = "gpio-keys",
177 .id = -1,
178 .dev = {
179 .platform_data = &vp6500_key_data,
180 },
181 };
182
183 static struct platform_device *platform_devices[] __initdata = {
184 &vp6500_nor_mtd_device,
185 &vp6500_leds_device,
186 &vp6500_keypad_device,
187 &vp6500_key_device,
188 };
189
190 static void __init vp6500_board_init(void)
191 {
192 mxc_gpio_setup_multiple_pins(vp6500_pins, ARRAY_SIZE(vp6500_pins),
193 "vp6500");
194
195 mxc_register_device(&mxc_uart_device0, NULL);
196
197 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
198 }
199
200 static void __init vp6500_timer_init(void)
201 {
202 mx21_clocks_init(32768, 26000000);
203 }
204
205 static struct sys_timer vp6500_timer = {
206 .init = vp6500_timer_init,
207 };
208
209 MACHINE_START(VP6500, "Phillips VP6500")
210 .phys_io = MX21_AIPI_BASE_ADDR,
211 .io_pg_offst = ((MX21_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc,
212 .boot_params = MX21_PHYS_OFFSET + 0x100,
213 .map_io = mx21_map_io,
214 .init_irq = mx21_init_irq,
215 .init_machine = vp6500_board_init,
216 .timer = &vp6500_timer,
217 MACHINE_END
This page took 0.064728 seconds and 5 git commands to generate.