2 * linux/arch/arm/mach-omap1/board-palmte.c
4 * Modified from board-generic.c
6 * Support for the Palm Tungsten E PDA.
8 * Original version : Laurent Gonzalez
10 * Maintainters : http://palmtelinux.sf.net
11 * palmtelinux-developpers@lists.sf.net
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/input.h>
21 #include <linux/platform_device.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/partitions.h>
25 #include <asm/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/flash.h>
31 #include <asm/arch/gpio.h>
32 #include <asm/arch/mux.h>
33 #include <asm/arch/usb.h>
34 #include <asm/arch/tc.h>
35 #include <asm/arch/dma.h>
36 #include <asm/arch/board.h>
37 #include <asm/arch/irda.h>
38 #include <asm/arch/keypad.h>
39 #include <asm/arch/common.h>
41 static void __init omap_palmte_init_irq(void)
43 omap1_init_common_hw();
48 static int palmte_keymap[] = {
58 KEY(1, 4, KEY_CENTER),
62 static struct omap_kp_platform_data palmte_kp_data = {
65 .keymap = palmte_keymap,
69 static struct resource palmte_kp_resources[] = {
71 .start = INT_KEYBOARD,
73 .flags = IORESOURCE_IRQ,
77 static struct platform_device palmte_kp_device = {
78 .name = "omap-keypad",
81 .platform_data = &palmte_kp_data,
83 .num_resources = ARRAY_SIZE(palmte_kp_resources),
84 .resource = palmte_kp_resources,
87 static struct mtd_partition palmte_rom_partitions[] = {
88 /* PalmOS "Small ROM", contains the bootloader and the debugger */
93 .mask_flags = MTD_WRITEABLE,
95 /* PalmOS "Big ROM", a filesystem with all the OS code and data */
100 * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
101 * 0x7b0000 bytes in the English-only ("enUS") version.
104 .mask_flags = MTD_WRITEABLE,
108 static struct flash_platform_data palmte_rom_data = {
109 .map_name = "map_rom",
111 .parts = palmte_rom_partitions,
112 .nr_parts = ARRAY_SIZE(palmte_rom_partitions),
115 static struct resource palmte_rom_resource = {
116 .start = OMAP_CS0_PHYS,
117 .end = OMAP_CS0_PHYS + SZ_8M - 1,
118 .flags = IORESOURCE_MEM,
121 static struct platform_device palmte_rom_device = {
125 .platform_data = &palmte_rom_data,
128 .resource = &palmte_rom_resource,
131 static struct platform_device palmte_lcd_device = {
132 .name = "lcd_palmte",
136 static struct omap_backlight_config palmte_backlight_config = {
137 .default_intensity = 0xa0,
140 static struct platform_device palmte_backlight_device = {
144 .platform_data = &palmte_backlight_config,
148 static struct omap_irda_config palmte_irda_config = {
149 .transceiver_cap = IR_SIRMODE,
150 .rx_channel = OMAP_DMA_UART3_RX,
151 .tx_channel = OMAP_DMA_UART3_TX,
152 .dest_start = UART3_THR,
153 .src_start = UART3_RHR,
158 static struct resource palmte_irda_resources[] = {
162 .flags = IORESOURCE_IRQ,
166 static struct platform_device palmte_irda_device = {
170 .platform_data = &palmte_irda_config,
172 .num_resources = ARRAY_SIZE(palmte_irda_resources),
173 .resource = palmte_irda_resources,
176 static struct platform_device *devices[] __initdata = {
180 &palmte_backlight_device,
184 static struct omap_usb_config palmte_usb_config __initdata = {
185 .register_dev = 1, /* Mini-B only receptacle */
190 static struct omap_mmc_config palmte_mmc_config __initdata = {
193 .wp_pin = PALMTE_MMC_WP_GPIO,
194 .power_pin = PALMTE_MMC_POWER_GPIO,
195 .switch_pin = PALMTE_MMC_SWITCH_GPIO,
199 static struct omap_lcd_config palmte_lcd_config __initdata = {
200 .ctrl_name = "internal",
203 static struct omap_uart_config palmte_uart_config __initdata = {
204 .enabled_uarts = (1 << 0) | (1 << 1) | (0 << 2),
207 static struct omap_board_config_kernel palmte_config[] = {
208 { OMAP_TAG_USB, &palmte_usb_config },
209 { OMAP_TAG_MMC, &palmte_mmc_config },
210 { OMAP_TAG_LCD, &palmte_lcd_config },
211 { OMAP_TAG_UART, &palmte_uart_config },
214 /* Periodically check for changes on important input pins */
215 struct timer_list palmte_pin_timer;
216 int prev_power, prev_headphones;
218 static void palmte_pin_handler(unsigned long data) {
219 int power, headphones;
221 power = !omap_get_gpio_datain(PALMTE_DC_GPIO);
222 headphones = omap_get_gpio_datain(PALMTE_HEADPHONES_GPIO);
224 if (power && !prev_power)
225 printk(KERN_INFO "PM: cable connected\n");
226 else if (!power && prev_power)
227 printk(KERN_INFO "PM: cable disconnected\n");
229 if (headphones && !prev_headphones) {
230 /* Headphones connected, disable speaker */
231 omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 0);
232 printk(KERN_INFO "PM: speaker off\n");
233 } else if (!headphones && prev_headphones) {
234 /* Headphones unplugged, re-enable speaker */
235 omap_set_gpio_dataout(PALMTE_SPEAKER_GPIO, 1);
236 printk(KERN_INFO "PM: speaker on\n");
240 prev_headphones = headphones;
241 mod_timer(&palmte_pin_timer, jiffies + msecs_to_jiffies(500));
244 static void __init palmte_gpio_setup(void)
246 /* Set TSC2102 PINTDAV pin as input */
247 if (omap_request_gpio(PALMTE_PINTDAV_GPIO)) {
248 printk(KERN_ERR "Could not reserve PINTDAV GPIO!\n");
251 omap_set_gpio_direction(PALMTE_PINTDAV_GPIO, 1);
253 /* Monitor cable-connected signals */
254 if (omap_request_gpio(PALMTE_DC_GPIO) ||
255 omap_request_gpio(PALMTE_USB_OR_DC_GPIO) ||
256 omap_request_gpio(PALMTE_USBDETECT_GPIO)) {
257 printk(KERN_ERR "Could not reserve cable signal GPIO!\n");
260 omap_set_gpio_direction(PALMTE_DC_GPIO, 1);
261 omap_set_gpio_direction(PALMTE_USB_OR_DC_GPIO, 1);
262 omap_set_gpio_direction(PALMTE_USBDETECT_GPIO, 1);
264 /* Set speaker-enable pin as output */
265 if (omap_request_gpio(PALMTE_SPEAKER_GPIO)) {
266 printk(KERN_ERR "Could not reserve speaker GPIO!\n");
269 omap_set_gpio_direction(PALMTE_SPEAKER_GPIO, 0);
271 /* Monitor the headphones-connected signal */
272 if (omap_request_gpio(PALMTE_HEADPHONES_GPIO)) {
273 printk(KERN_ERR "Could not reserve headphones signal GPIO!\n");
276 omap_set_gpio_direction(PALMTE_HEADPHONES_GPIO, 1);
278 prev_power = omap_get_gpio_datain(PALMTE_DC_GPIO);
279 prev_headphones = !omap_get_gpio_datain(PALMTE_HEADPHONES_GPIO);
280 setup_timer(&palmte_pin_timer, palmte_pin_handler, 0);
281 palmte_pin_handler(0);
284 static void __init omap_palmte_init(void)
286 omap_board_config = palmte_config;
287 omap_board_config_size = ARRAY_SIZE(palmte_config);
289 platform_add_devices(devices, ARRAY_SIZE(devices));
295 static void __init omap_palmte_map_io(void)
297 omap1_map_common_io();
300 MACHINE_START(OMAP_PALMTE, "OMAP310 based Palm Tungsten E")
301 .phys_io = 0xfff00000,
302 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
303 .boot_params = 0x10000100,
304 .map_io = omap_palmte_map_io,
305 .init_irq = omap_palmte_init_irq,
306 .init_machine = omap_palmte_init,
307 .timer = &omap_timer,