ARM: OMAP: boards: Fix OMAP_GPIO_IRQ usage with gpio_to_irq()
[deliverable/linux.git] / arch / arm / mach-omap1 / board-palmz71.c
CommitLineData
ec70e8af
MV
1/*
2 * linux/arch/arm/mach-omap1/board-palmz71.c
3 *
4 * Modified from board-generic.c
5 *
6 * Support for the Palm Zire71 PDA.
7 *
8 * Original version : Laurent Gonzalez
9 *
10 * Modified for zire71 : Marek Vasut
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/delay.h>
2f8163ba 18#include <linux/gpio.h>
ec70e8af
MV
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h>
22#include <linux/notifier.h>
23#include <linux/clk.h>
24#include <linux/irq.h>
25#include <linux/input.h>
26#include <linux/interrupt.h>
27#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h>
561b036a 29#include <linux/mtd/physmap.h>
2e3ee9f4
TL
30#include <linux/spi/spi.h>
31#include <linux/spi/ads7846.h>
ec70e8af 32
ec70e8af
MV
33#include <asm/mach-types.h>
34#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
ec70e8af 36
561b036a 37#include <plat/flash.h>
ce491cf8
TL
38#include <plat/mux.h>
39#include <plat/usb.h>
40#include <plat/dma.h>
41#include <plat/tc.h>
42#include <plat/board.h>
43#include <plat/irda.h>
44#include <plat/keypad.h>
ec70e8af 45
2e3ee9f4
TL
46#include <mach/hardware.h>
47
48#include "common.h"
ec70e8af 49
b2830810
TL
50#define PALMZ71_USBDETECT_GPIO 0
51#define PALMZ71_PENIRQ_GPIO 6
52#define PALMZ71_MMC_WP_GPIO 8
53#define PALMZ71_HDQ_GPIO 11
54
55#define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)
56#define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)
57#define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
58#define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
59
da1f026b 60static const unsigned int palmz71_keymap[] = {
ec70e8af 61 KEY(0, 0, KEY_F1),
da1f026b
JK
62 KEY(1, 0, KEY_F2),
63 KEY(2, 0, KEY_F3),
64 KEY(3, 0, KEY_F4),
65 KEY(4, 0, KEY_POWER),
66 KEY(0, 1, KEY_LEFT),
ec70e8af 67 KEY(1, 1, KEY_DOWN),
da1f026b
JK
68 KEY(2, 1, KEY_UP),
69 KEY(3, 1, KEY_RIGHT),
70 KEY(4, 1, KEY_ENTER),
71 KEY(0, 2, KEY_CAMERA),
72};
73
74static const struct matrix_keymap_data palmz71_keymap_data = {
75 .keymap = palmz71_keymap,
76 .keymap_size = ARRAY_SIZE(palmz71_keymap),
ec70e8af
MV
77};
78
79static struct omap_kp_platform_data palmz71_kp_data = {
80 .rows = 8,
81 .cols = 8,
da1f026b
JK
82 .keymap_data = &palmz71_keymap_data,
83 .rep = true,
ec70e8af
MV
84 .delay = 80,
85};
86
87static struct resource palmz71_kp_resources[] = {
88 [0] = {
89 .start = INT_KEYBOARD,
90 .end = INT_KEYBOARD,
91 .flags = IORESOURCE_IRQ,
92 },
93};
94
95static struct platform_device palmz71_kp_device = {
96 .name = "omap-keypad",
97 .id = -1,
98 .dev = {
99 .platform_data = &palmz71_kp_data,
100 },
101 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
102 .resource = palmz71_kp_resources,
103};
104
105static struct mtd_partition palmz71_rom_partitions[] = {
106 /* PalmOS "Small ROM", contains the bootloader and the debugger */
107 {
108 .name = "smallrom",
109 .offset = 0,
110 .size = 0xa000,
111 .mask_flags = MTD_WRITEABLE,
112 },
113 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
114 {
115 .name = "bigrom",
116 .offset = SZ_128K,
117 /*
118 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
119 * 0x7b0000 bytes in the English-only ("enUS") version.
120 */
121 .size = 0x7b0000,
122 .mask_flags = MTD_WRITEABLE,
123 },
124};
125
561b036a 126static struct physmap_flash_data palmz71_rom_data = {
ec70e8af 127 .width = 2,
561b036a 128 .set_vpp = omap1_set_vpp,
ec70e8af
MV
129 .parts = palmz71_rom_partitions,
130 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
131};
132
133static struct resource palmz71_rom_resource = {
134 .start = OMAP_CS0_PHYS,
135 .end = OMAP_CS0_PHYS + SZ_8M - 1,
136 .flags = IORESOURCE_MEM,
137};
138
139static struct platform_device palmz71_rom_device = {
561b036a 140 .name = "physmap-flash",
ec70e8af
MV
141 .id = -1,
142 .dev = {
143 .platform_data = &palmz71_rom_data,
144 },
145 .num_resources = 1,
146 .resource = &palmz71_rom_resource,
147};
148
149static struct platform_device palmz71_lcd_device = {
150 .name = "lcd_palmz71",
151 .id = -1,
152};
153
154static struct omap_irda_config palmz71_irda_config = {
155 .transceiver_cap = IR_SIRMODE,
156 .rx_channel = OMAP_DMA_UART3_RX,
157 .tx_channel = OMAP_DMA_UART3_TX,
158 .dest_start = UART3_THR,
159 .src_start = UART3_RHR,
160 .tx_trigger = 0,
161 .rx_trigger = 0,
162};
163
164static struct resource palmz71_irda_resources[] = {
165 [0] = {
166 .start = INT_UART3,
167 .end = INT_UART3,
168 .flags = IORESOURCE_IRQ,
169 },
170};
171
172static struct platform_device palmz71_irda_device = {
173 .name = "omapirda",
174 .id = -1,
175 .dev = {
176 .platform_data = &palmz71_irda_config,
177 },
178 .num_resources = ARRAY_SIZE(palmz71_irda_resources),
179 .resource = palmz71_irda_resources,
180};
181
182static struct platform_device palmz71_spi_device = {
183 .name = "spi_palmz71",
184 .id = -1,
185};
186
ec70e8af
MV
187static struct omap_backlight_config palmz71_backlight_config = {
188 .default_intensity = 0xa0,
189};
190
191static struct platform_device palmz71_backlight_device = {
192 .name = "omap-bl",
193 .id = -1,
194 .dev = {
195 .platform_data = &palmz71_backlight_config,
196 },
197};
198
199static struct platform_device *devices[] __initdata = {
200 &palmz71_rom_device,
201 &palmz71_kp_device,
ec70e8af
MV
202 &palmz71_lcd_device,
203 &palmz71_irda_device,
204 &palmz71_spi_device,
205 &palmz71_backlight_device,
206};
207
208static int
209palmz71_get_pendown_state(void)
210{
0b84b5ca 211 return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
ec70e8af
MV
212}
213
214static const struct ads7846_platform_data palmz71_ts_info = {
215 .model = 7846,
216 .vref_delay_usecs = 100, /* internal, no capacitor */
217 .x_plate_ohms = 419,
218 .y_plate_ohms = 486,
219 .get_pendown_state = palmz71_get_pendown_state,
220};
221
222static struct spi_board_info __initdata palmz71_boardinfo[] = { {
223 /* MicroWire (bus 2) CS0 has an ads7846e */
224 .modalias = "ads7846",
225 .platform_data = &palmz71_ts_info,
ec70e8af
MV
226 .max_speed_hz = 120000 /* max sample rate at 3V */
227 * 26 /* command + data + overhead */,
228 .bus_num = 2,
229 .chip_select = 0,
230} };
231
232static struct omap_usb_config palmz71_usb_config __initdata = {
233 .register_dev = 1, /* Mini-B only receptacle */
234 .hmc_mode = 0,
235 .pins[0] = 2,
236};
237
ec70e8af
MV
238static struct omap_lcd_config palmz71_lcd_config __initdata = {
239 .ctrl_name = "internal",
240};
241
e27a93a9 242static struct omap_board_config_kernel palmz71_config[] __initdata = {
ec70e8af 243 {OMAP_TAG_LCD, &palmz71_lcd_config},
ec70e8af
MV
244};
245
246static irqreturn_t
247palmz71_powercable(int irq, void *dev_id)
248{
0b84b5ca 249 if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
ec70e8af 250 printk(KERN_INFO "PM: Power cable connected\n");
6845664a
TG
251 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
252 IRQ_TYPE_EDGE_FALLING);
ec70e8af
MV
253 } else {
254 printk(KERN_INFO "PM: Power cable disconnected\n");
6845664a
TG
255 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
256 IRQ_TYPE_EDGE_RISING);
ec70e8af
MV
257 }
258 return IRQ_HANDLED;
259}
260
261static void __init
262omap_mpu_wdt_mode(int mode)
263{
264 if (mode)
265 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
266 else {
267 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
268 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
269 }
270}
271
272static void __init
273palmz71_gpio_setup(int early)
274{
275 if (early) {
276 /* Only set GPIO1 so we have a working serial */
e918edf7 277 gpio_direction_output(1, 1);
ec70e8af
MV
278 } else {
279 /* Set MMC/SD host WP pin as input */
f2d18fea 280 if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
ec70e8af
MV
281 printk(KERN_ERR "Could not reserve WP GPIO!\n");
282 return;
283 }
40e3925b 284 gpio_direction_input(PALMZ71_MMC_WP_GPIO);
ec70e8af
MV
285
286 /* Monitor the Power-cable-connected signal */
f2d18fea 287 if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
ec70e8af
MV
288 printk(KERN_ERR
289 "Could not reserve cable signal GPIO!\n");
290 return;
291 }
40e3925b 292 gpio_direction_input(PALMZ71_USBDETECT_GPIO);
15f74b03 293 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
ec70e8af
MV
294 palmz71_powercable, IRQF_SAMPLE_RANDOM,
295 "palmz71-cable", 0))
296 printk(KERN_ERR
297 "IRQ request for power cable failed!\n");
15f74b03 298 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), 0);
ec70e8af
MV
299 }
300}
301
302static void __init
303omap_palmz71_init(void)
304{
c33da3a8
JK
305 /* mux pins for uarts */
306 omap_cfg_reg(UART1_TX);
307 omap_cfg_reg(UART1_RTS);
308 omap_cfg_reg(UART2_TX);
309 omap_cfg_reg(UART2_RTS);
310 omap_cfg_reg(UART3_TX);
311 omap_cfg_reg(UART3_RX);
312
ec70e8af
MV
313 palmz71_gpio_setup(1);
314 omap_mpu_wdt_mode(0);
315
316 omap_board_config = palmz71_config;
317 omap_board_config_size = ARRAY_SIZE(palmz71_config);
318
319 platform_add_devices(devices, ARRAY_SIZE(devices));
320
46a0a540 321 palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
ec70e8af
MV
322 spi_register_board_info(palmz71_boardinfo,
323 ARRAY_SIZE(palmz71_boardinfo));
dd0cdd88 324 omap1_usb_init(&palmz71_usb_config);
ec70e8af 325 omap_serial_init();
1ed16a86 326 omap_register_i2c_bus(1, 100, NULL, 0);
ec70e8af
MV
327 palmz71_gpio_setup(0);
328}
329
ec70e8af 330MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
246e389d 331 .atag_offset = 0x100,
7b88e62f
TL
332 .map_io = omap15xx_map_io,
333 .init_early = omap1_init_early,
71ee7dad 334 .reserve = omap_reserve,
7b88e62f 335 .init_irq = omap1_init_irq,
71ee7dad 336 .init_machine = omap_palmz71_init,
e74984e4 337 .timer = &omap1_timer,
baa95883 338 .restart = omap1_restart,
ec70e8af 339MACHINE_END
This page took 0.2996 seconds and 5 git commands to generate.