]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap1/board-palmte.c
25bbb22564650e67029e6099e9fce6b3006328b8
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap1 / board-palmte.c
1 /*
2  * linux/arch/arm/mach-omap1/board-palmte.c
3  *
4  * Modified from board-generic.c
5  *
6  * Support for the Palm Tungsten E PDA.
7  *
8  * Original version : Laurent Gonzalez
9  *
10  * Maintainters : http://palmtelinux.sf.net
11  *                palmtelinux-developpers@lists.sf.net
12  *
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.
16  */
17
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>
24
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>
30
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>
40
41 static void __init omap_palmte_init_irq(void)
42 {
43         omap1_init_common_hw();
44         omap_init_irq();
45         omap_gpio_init();
46 }
47
48 static int palmte_keymap[] = {
49         KEY(0, 0, KEY_F1),
50         KEY(0, 1, KEY_F2),
51         KEY(0, 2, KEY_F3),
52         KEY(0, 3, KEY_F4),
53         KEY(0, 4, KEY_POWER),
54         KEY(1, 0, KEY_LEFT),
55         KEY(1, 1, KEY_DOWN),
56         KEY(1, 2, KEY_UP),
57         KEY(1, 3, KEY_RIGHT),
58         KEY(1, 4, KEY_CENTER),
59         0,
60 };
61
62 static struct omap_kp_platform_data palmte_kp_data = {
63         .rows   = 8,
64         .cols   = 8,
65         .keymap = palmte_keymap,
66         .rep    = 1,
67 };
68
69 static struct resource palmte_kp_resources[] = {
70         [0]     = {
71                 .start  = INT_KEYBOARD,
72                 .end    = INT_KEYBOARD,
73                 .flags  = IORESOURCE_IRQ,
74         },
75 };
76
77 static struct platform_device palmte_kp_device = {
78         .name           = "omap-keypad",
79         .id             = -1,
80         .dev            = {
81                 .platform_data  = &palmte_kp_data,
82         },
83         .num_resources  = ARRAY_SIZE(palmte_kp_resources),
84         .resource       = palmte_kp_resources,
85 };
86
87 static struct mtd_partition palmte_rom_partitions[] = {
88         /* PalmOS "Small ROM", contains the bootloader and the debugger */
89         {
90                 .name           = "smallrom",
91                 .offset         = 0,
92                 .size           = 0xa000,
93                 .mask_flags     = MTD_WRITEABLE,
94         },
95         /* PalmOS "Big ROM", a filesystem with all the OS code and data */
96         {
97                 .name           = "bigrom",
98                 .offset         = SZ_128K,
99                 /*
100                  * 0x5f0000 bytes big in the multi-language ("EFIGS") version,
101                  * 0x7b0000 bytes in the English-only ("enUS") version.
102                  */
103                 .size           = 0x7b0000,
104                 .mask_flags     = MTD_WRITEABLE,
105         },
106 };
107
108 static struct flash_platform_data palmte_rom_data = {
109         .map_name       = "map_rom",
110         .width          = 2,
111         .parts          = palmte_rom_partitions,
112         .nr_parts       = ARRAY_SIZE(palmte_rom_partitions),
113 };
114
115 static struct resource palmte_rom_resource = {
116         .start          = OMAP_CS0_PHYS,
117         .end            = OMAP_CS0_PHYS + SZ_8M - 1,
118         .flags          = IORESOURCE_MEM,
119 };
120
121 static struct platform_device palmte_rom_device = {
122         .name           = "omapflash",
123         .id             = -1,
124         .dev            = {
125                 .platform_data  = &palmte_rom_data,
126         },
127         .num_resources  = 1,
128         .resource       = &palmte_rom_resource,
129 };
130
131 static struct platform_device palmte_lcd_device = {
132         .name           = "lcd_palmte",
133         .id             = -1,
134 };
135
136 static struct omap_backlight_config palmte_backlight_config = {
137         .default_intensity      = 0xa0,
138 };
139
140 static struct platform_device palmte_backlight_device = {
141         .name           = "omap-bl",
142         .id             = -1,
143         .dev            = {
144                 .platform_data  = &palmte_backlight_config,
145         },
146 };
147
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,
154         .tx_trigger             = 0,
155         .rx_trigger             = 0,
156 };
157
158 static struct resource palmte_irda_resources[] = {
159         [0]     = {
160                 .start  = INT_UART3,
161                 .end    = INT_UART3,
162                 .flags  = IORESOURCE_IRQ,
163         },
164 };
165
166 static struct platform_device palmte_irda_device = {
167         .name           = "omapirda",
168         .id             = -1,
169         .dev            = {
170                 .platform_data  = &palmte_irda_config,
171         },
172         .num_resources  = ARRAY_SIZE(palmte_irda_resources),
173         .resource       = palmte_irda_resources,
174 };
175
176 static struct platform_device *devices[] __initdata = {
177         &palmte_rom_device,
178         &palmte_kp_device,
179         &palmte_lcd_device,
180         &palmte_backlight_device,
181         &palmte_irda_device,
182 };
183
184 static struct omap_usb_config palmte_usb_config __initdata = {
185         .register_dev   = 1,    /* Mini-B only receptacle */
186         .hmc_mode       = 0,
187         .pins[0]        = 2,
188 };
189
190 static struct omap_mmc_config palmte_mmc_config __initdata = {
191         .mmc[0]         = {
192                 .enabled        = 1,
193                 .wp_pin         = PALMTE_MMC_WP_GPIO,
194                 .power_pin      = PALMTE_MMC_POWER_GPIO,
195                 .switch_pin     = PALMTE_MMC_SWITCH_GPIO,
196         },
197 };
198
199 static struct omap_lcd_config palmte_lcd_config __initdata = {
200         .ctrl_name      = "internal",
201 };
202
203 static struct omap_uart_config palmte_uart_config __initdata = {
204         .enabled_uarts = (1 << 0) | (1 << 1) | (0 << 2),
205 };
206
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 },
212 };
213
214 /* Periodically check for changes on important input pins */
215 struct timer_list palmte_pin_timer;
216 int prev_power, prev_headphones;
217
218 static void palmte_pin_handler(unsigned long data) {
219         int power, headphones;
220
221         power = !omap_get_gpio_datain(PALMTE_DC_GPIO);
222         headphones = omap_get_gpio_datain(PALMTE_HEADPHONES_GPIO);
223
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");
228
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");
237         }
238
239         prev_power = power;
240         prev_headphones = headphones;
241         mod_timer(&palmte_pin_timer, jiffies + msecs_to_jiffies(500));
242 }
243
244 static void __init palmte_gpio_setup(void)
245 {
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");
249                 return;
250         }
251         omap_set_gpio_direction(PALMTE_PINTDAV_GPIO, 1);
252
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");
258                 return;
259         }
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);
263
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");
267                 return;
268         }
269         omap_set_gpio_direction(PALMTE_SPEAKER_GPIO, 0);
270
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");
274                 return;
275         }
276         omap_set_gpio_direction(PALMTE_HEADPHONES_GPIO, 1);
277
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);
282 }
283
284 static void __init omap_palmte_init(void)
285 {
286         omap_board_config = palmte_config;
287         omap_board_config_size = ARRAY_SIZE(palmte_config);
288
289         platform_add_devices(devices, ARRAY_SIZE(devices));
290
291         omap_serial_init();
292         palmte_gpio_setup();
293 }
294
295 static void __init omap_palmte_map_io(void)
296 {
297         omap1_map_common_io();
298 }
299
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,
308 MACHINE_END