2 * linux/arch/arm/mach-omap1/board-palmz71.c
4 * Modified from board-generic.c
6 * Support for the Palm Zire71 PDA.
8 * Original version : Laurent Gonzalez
10 * Modified for zire71 : Marek Vasut
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.
17 #include <linux/delay.h>
18 #include <linux/gpio.h>
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>
29 #include <linux/mtd/physmap.h>
30 #include <linux/omapfb.h>
31 #include <linux/spi/spi.h>
32 #include <linux/spi/ads7846.h>
33 #include <linux/platform_data/omap1_bl.h>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
37 #include <asm/mach/map.h>
39 #include <plat/flash.h>
43 #include <plat/irda.h>
44 #include <linux/platform_data/keypad-omap.h>
46 #include <mach/hardware.h>
51 #define PALMZ71_USBDETECT_GPIO 0
52 #define PALMZ71_PENIRQ_GPIO 6
53 #define PALMZ71_MMC_WP_GPIO 8
54 #define PALMZ71_HDQ_GPIO 11
56 #define PALMZ71_HOTSYNC_GPIO OMAP_MPUIO(1)
57 #define PALMZ71_CABLE_GPIO OMAP_MPUIO(2)
58 #define PALMZ71_SLIDER_GPIO OMAP_MPUIO(3)
59 #define PALMZ71_MMC_IN_GPIO OMAP_MPUIO(4)
61 static const unsigned int palmz71_keymap[] = {
72 KEY(0, 2, KEY_CAMERA),
75 static const struct matrix_keymap_data palmz71_keymap_data = {
76 .keymap = palmz71_keymap,
77 .keymap_size = ARRAY_SIZE(palmz71_keymap),
80 static struct omap_kp_platform_data palmz71_kp_data = {
83 .keymap_data = &palmz71_keymap_data,
88 static struct resource palmz71_kp_resources[] = {
90 .start = INT_KEYBOARD,
92 .flags = IORESOURCE_IRQ,
96 static struct platform_device palmz71_kp_device = {
97 .name = "omap-keypad",
100 .platform_data = &palmz71_kp_data,
102 .num_resources = ARRAY_SIZE(palmz71_kp_resources),
103 .resource = palmz71_kp_resources,
106 static struct mtd_partition palmz71_rom_partitions[] = {
107 /* PalmOS "Small ROM", contains the bootloader and the debugger */
112 .mask_flags = MTD_WRITEABLE,
114 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
119 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
120 * 0x7b0000 bytes in the English-only ("enUS") version.
123 .mask_flags = MTD_WRITEABLE,
127 static struct physmap_flash_data palmz71_rom_data = {
129 .set_vpp = omap1_set_vpp,
130 .parts = palmz71_rom_partitions,
131 .nr_parts = ARRAY_SIZE(palmz71_rom_partitions),
134 static struct resource palmz71_rom_resource = {
135 .start = OMAP_CS0_PHYS,
136 .end = OMAP_CS0_PHYS + SZ_8M - 1,
137 .flags = IORESOURCE_MEM,
140 static struct platform_device palmz71_rom_device = {
141 .name = "physmap-flash",
144 .platform_data = &palmz71_rom_data,
147 .resource = &palmz71_rom_resource,
150 static struct platform_device palmz71_lcd_device = {
151 .name = "lcd_palmz71",
155 static struct omap_irda_config palmz71_irda_config = {
156 .transceiver_cap = IR_SIRMODE,
157 .rx_channel = OMAP_DMA_UART3_RX,
158 .tx_channel = OMAP_DMA_UART3_TX,
159 .dest_start = UART3_THR,
160 .src_start = UART3_RHR,
165 static struct resource palmz71_irda_resources[] = {
169 .flags = IORESOURCE_IRQ,
173 static struct platform_device palmz71_irda_device = {
177 .platform_data = &palmz71_irda_config,
179 .num_resources = ARRAY_SIZE(palmz71_irda_resources),
180 .resource = palmz71_irda_resources,
183 static struct platform_device palmz71_spi_device = {
184 .name = "spi_palmz71",
188 static struct omap_backlight_config palmz71_backlight_config = {
189 .default_intensity = 0xa0,
192 static struct platform_device palmz71_backlight_device = {
196 .platform_data = &palmz71_backlight_config,
200 static struct platform_device *devices[] __initdata = {
204 &palmz71_irda_device,
206 &palmz71_backlight_device,
210 palmz71_get_pendown_state(void)
212 return !gpio_get_value(PALMZ71_PENIRQ_GPIO);
215 static const struct ads7846_platform_data palmz71_ts_info = {
217 .vref_delay_usecs = 100, /* internal, no capacitor */
220 .get_pendown_state = palmz71_get_pendown_state,
223 static struct spi_board_info __initdata palmz71_boardinfo[] = { {
224 /* MicroWire (bus 2) CS0 has an ads7846e */
225 .modalias = "ads7846",
226 .platform_data = &palmz71_ts_info,
227 .max_speed_hz = 120000 /* max sample rate at 3V */
228 * 26 /* command + data + overhead */,
233 static struct omap_usb_config palmz71_usb_config __initdata = {
234 .register_dev = 1, /* Mini-B only receptacle */
239 static struct omap_lcd_config palmz71_lcd_config __initdata = {
240 .ctrl_name = "internal",
244 palmz71_powercable(int irq, void *dev_id)
246 if (gpio_get_value(PALMZ71_USBDETECT_GPIO)) {
247 printk(KERN_INFO "PM: Power cable connected\n");
248 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
249 IRQ_TYPE_EDGE_FALLING);
251 printk(KERN_INFO "PM: Power cable disconnected\n");
252 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
253 IRQ_TYPE_EDGE_RISING);
259 omap_mpu_wdt_mode(int mode)
262 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
264 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
265 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
270 palmz71_gpio_setup(int early)
273 /* Only set GPIO1 so we have a working serial */
274 gpio_direction_output(1, 1);
276 /* Set MMC/SD host WP pin as input */
277 if (gpio_request(PALMZ71_MMC_WP_GPIO, "MMC WP") < 0) {
278 printk(KERN_ERR "Could not reserve WP GPIO!\n");
281 gpio_direction_input(PALMZ71_MMC_WP_GPIO);
283 /* Monitor the Power-cable-connected signal */
284 if (gpio_request(PALMZ71_USBDETECT_GPIO, "USB detect") < 0) {
286 "Could not reserve cable signal GPIO!\n");
289 gpio_direction_input(PALMZ71_USBDETECT_GPIO);
290 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO),
291 palmz71_powercable, 0, "palmz71-cable", NULL))
293 "IRQ request for power cable failed!\n");
294 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO), NULL);
299 omap_palmz71_init(void)
301 /* mux pins for uarts */
302 omap_cfg_reg(UART1_TX);
303 omap_cfg_reg(UART1_RTS);
304 omap_cfg_reg(UART2_TX);
305 omap_cfg_reg(UART2_RTS);
306 omap_cfg_reg(UART3_TX);
307 omap_cfg_reg(UART3_RX);
309 palmz71_gpio_setup(1);
310 omap_mpu_wdt_mode(0);
312 platform_add_devices(devices, ARRAY_SIZE(devices));
314 palmz71_boardinfo[0].irq = gpio_to_irq(PALMZ71_PENIRQ_GPIO);
315 spi_register_board_info(palmz71_boardinfo,
316 ARRAY_SIZE(palmz71_boardinfo));
317 omap1_usb_init(&palmz71_usb_config);
319 omap_register_i2c_bus(1, 100, NULL, 0);
320 palmz71_gpio_setup(0);
322 omapfb_set_lcd_config(&palmz71_lcd_config);
325 MACHINE_START(OMAP_PALMZ71, "OMAP310 based Palm Zire71")
326 .atag_offset = 0x100,
327 .map_io = omap15xx_map_io,
328 .init_early = omap1_init_early,
329 .reserve = omap_reserve,
330 .init_irq = omap1_init_irq,
331 .init_machine = omap_palmz71_init,
332 .init_late = omap1_init_late,
333 .timer = &omap1_timer,
334 .restart = omap1_restart,