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 <mach/flash.h>
41 #include <linux/omap-dma.h>
43 #include <linux/platform_data/keypad-omap.h>
45 #include <mach/hardware.h>
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
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)
60 static const unsigned int palmz71_keymap
[] = {
71 KEY(0, 2, KEY_CAMERA
),
74 static const struct matrix_keymap_data palmz71_keymap_data
= {
75 .keymap
= palmz71_keymap
,
76 .keymap_size
= ARRAY_SIZE(palmz71_keymap
),
79 static struct omap_kp_platform_data palmz71_kp_data
= {
82 .keymap_data
= &palmz71_keymap_data
,
87 static struct resource palmz71_kp_resources
[] = {
89 .start
= INT_KEYBOARD
,
91 .flags
= IORESOURCE_IRQ
,
95 static struct platform_device palmz71_kp_device
= {
96 .name
= "omap-keypad",
99 .platform_data
= &palmz71_kp_data
,
101 .num_resources
= ARRAY_SIZE(palmz71_kp_resources
),
102 .resource
= palmz71_kp_resources
,
105 static struct mtd_partition palmz71_rom_partitions
[] = {
106 /* PalmOS "Small ROM", contains the bootloader and the debugger */
111 .mask_flags
= MTD_WRITEABLE
,
113 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
118 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
119 * 0x7b0000 bytes in the English-only ("enUS") version.
122 .mask_flags
= MTD_WRITEABLE
,
126 static struct physmap_flash_data palmz71_rom_data
= {
128 .set_vpp
= omap1_set_vpp
,
129 .parts
= palmz71_rom_partitions
,
130 .nr_parts
= ARRAY_SIZE(palmz71_rom_partitions
),
133 static struct resource palmz71_rom_resource
= {
134 .start
= OMAP_CS0_PHYS
,
135 .end
= OMAP_CS0_PHYS
+ SZ_8M
- 1,
136 .flags
= IORESOURCE_MEM
,
139 static struct platform_device palmz71_rom_device
= {
140 .name
= "physmap-flash",
143 .platform_data
= &palmz71_rom_data
,
146 .resource
= &palmz71_rom_resource
,
149 static struct platform_device palmz71_lcd_device
= {
150 .name
= "lcd_palmz71",
154 static struct platform_device palmz71_spi_device
= {
155 .name
= "spi_palmz71",
159 static struct omap_backlight_config palmz71_backlight_config
= {
160 .default_intensity
= 0xa0,
163 static struct platform_device palmz71_backlight_device
= {
167 .platform_data
= &palmz71_backlight_config
,
171 static struct platform_device
*devices
[] __initdata
= {
176 &palmz71_backlight_device
,
180 palmz71_get_pendown_state(void)
182 return !gpio_get_value(PALMZ71_PENIRQ_GPIO
);
185 static const struct ads7846_platform_data palmz71_ts_info
= {
187 .vref_delay_usecs
= 100, /* internal, no capacitor */
190 .get_pendown_state
= palmz71_get_pendown_state
,
193 static struct spi_board_info __initdata palmz71_boardinfo
[] = { {
194 /* MicroWire (bus 2) CS0 has an ads7846e */
195 .modalias
= "ads7846",
196 .platform_data
= &palmz71_ts_info
,
197 .max_speed_hz
= 120000 /* max sample rate at 3V */
198 * 26 /* command + data + overhead */,
203 static struct omap_usb_config palmz71_usb_config __initdata
= {
204 .register_dev
= 1, /* Mini-B only receptacle */
209 static struct omap_lcd_config palmz71_lcd_config __initdata
= {
210 .ctrl_name
= "internal",
214 palmz71_powercable(int irq
, void *dev_id
)
216 if (gpio_get_value(PALMZ71_USBDETECT_GPIO
)) {
217 printk(KERN_INFO
"PM: Power cable connected\n");
218 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO
),
219 IRQ_TYPE_EDGE_FALLING
);
221 printk(KERN_INFO
"PM: Power cable disconnected\n");
222 irq_set_irq_type(gpio_to_irq(PALMZ71_USBDETECT_GPIO
),
223 IRQ_TYPE_EDGE_RISING
);
229 omap_mpu_wdt_mode(int mode
)
232 omap_writew(0x8000, OMAP_WDT_TIMER_MODE
);
234 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE
);
235 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE
);
240 palmz71_gpio_setup(int early
)
243 /* Only set GPIO1 so we have a working serial */
244 gpio_direction_output(1, 1);
246 /* Set MMC/SD host WP pin as input */
247 if (gpio_request(PALMZ71_MMC_WP_GPIO
, "MMC WP") < 0) {
248 printk(KERN_ERR
"Could not reserve WP GPIO!\n");
251 gpio_direction_input(PALMZ71_MMC_WP_GPIO
);
253 /* Monitor the Power-cable-connected signal */
254 if (gpio_request(PALMZ71_USBDETECT_GPIO
, "USB detect") < 0) {
256 "Could not reserve cable signal GPIO!\n");
259 gpio_direction_input(PALMZ71_USBDETECT_GPIO
);
260 if (request_irq(gpio_to_irq(PALMZ71_USBDETECT_GPIO
),
261 palmz71_powercable
, 0, "palmz71-cable", NULL
))
263 "IRQ request for power cable failed!\n");
264 palmz71_powercable(gpio_to_irq(PALMZ71_USBDETECT_GPIO
), NULL
);
269 omap_palmz71_init(void)
271 /* mux pins for uarts */
272 omap_cfg_reg(UART1_TX
);
273 omap_cfg_reg(UART1_RTS
);
274 omap_cfg_reg(UART2_TX
);
275 omap_cfg_reg(UART2_RTS
);
276 omap_cfg_reg(UART3_TX
);
277 omap_cfg_reg(UART3_RX
);
279 palmz71_gpio_setup(1);
280 omap_mpu_wdt_mode(0);
282 platform_add_devices(devices
, ARRAY_SIZE(devices
));
284 palmz71_boardinfo
[0].irq
= gpio_to_irq(PALMZ71_PENIRQ_GPIO
);
285 spi_register_board_info(palmz71_boardinfo
,
286 ARRAY_SIZE(palmz71_boardinfo
));
287 omap1_usb_init(&palmz71_usb_config
);
289 omap_register_i2c_bus(1, 100, NULL
, 0);
290 palmz71_gpio_setup(0);
292 omapfb_set_lcd_config(&palmz71_lcd_config
);
295 MACHINE_START(OMAP_PALMZ71
, "OMAP310 based Palm Zire71")
296 .atag_offset
= 0x100,
297 .map_io
= omap15xx_map_io
,
298 .init_early
= omap1_init_early
,
299 .init_irq
= omap1_init_irq
,
300 .init_machine
= omap_palmz71_init
,
301 .init_late
= omap1_init_late
,
302 .init_time
= omap1_timer_init
,
303 .restart
= omap1_restart
,