Merge branch 'fix/hda' into topic/hda
[linux-2.6] / arch / arm / mach-omap1 / board-palmtt.c
1 /*
2  * linux/arch/arm/mach-omap1/board-palmtt.c
3  *
4  * Modified from board-palmtt2.c
5  *
6  * Modified and amended for Palm Tungsten|T
7  * by Marek Vasut <marek.vasut@gmail.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  */
13
14 #include <linux/delay.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/notifier.h>
19 #include <linux/clk.h>
20 #include <linux/input.h>
21 #include <linux/interrupt.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/partitions.h>
24 #include <linux/leds.h>
25
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/flash.h>
31
32 #include <mach/led.h>
33 #include <mach/gpio.h>
34 #include <mach/mux.h>
35 #include <mach/usb.h>
36 #include <mach/dma.h>
37 #include <mach/tc.h>
38 #include <mach/board.h>
39 #include <mach/irda.h>
40 #include <mach/keypad.h>
41 #include <mach/common.h>
42
43 #include <linux/spi/spi.h>
44 #include <linux/spi/ads7846.h>
45
46 static int palmtt_keymap[] = {
47         KEY(0, 0, KEY_ESC),
48         KEY(0, 1, KEY_SPACE),
49         KEY(0, 2, KEY_LEFTCTRL),
50         KEY(0, 3, KEY_TAB),
51         KEY(0, 4, KEY_ENTER),
52         KEY(1, 0, KEY_LEFT),
53         KEY(1, 1, KEY_DOWN),
54         KEY(1, 2, KEY_UP),
55         KEY(1, 3, KEY_RIGHT),
56         KEY(2, 0, KEY_SLEEP),
57         KEY(2, 4, KEY_Y),
58         0
59 };
60
61 static struct mtd_partition palmtt_partitions[] = {
62         {
63                 .name           = "write8k",
64                 .offset         = 0,
65                 .size           = SZ_8K,
66                 .mask_flags     = 0,
67         },
68         {
69                 .name           = "PalmOS-BootLoader(ro)",
70                 .offset         = SZ_8K,
71                 .size           = 7 * SZ_8K,
72                 .mask_flags     = MTD_WRITEABLE,
73         },
74         {
75                 .name           = "u-boot",
76                 .offset         = MTDPART_OFS_APPEND,
77                 .size           = 8 * SZ_8K,
78                 .mask_flags     = 0,
79         },
80         {
81                 .name           = "PalmOS-FS(ro)",
82                 .offset         = MTDPART_OFS_APPEND,
83                 .size           = 7 * SZ_1M + 4 * SZ_64K - 16 * SZ_8K,
84                 .mask_flags     = MTD_WRITEABLE,
85         },
86         {
87                 .name           = "u-boot(rez)",
88                 .offset         = MTDPART_OFS_APPEND,
89                 .size           = SZ_128K,
90                 .mask_flags     = 0
91         },
92         {
93                 .name           = "empty",
94                 .offset         = MTDPART_OFS_APPEND,
95                 .size           = MTDPART_SIZ_FULL,
96                 .mask_flags     = 0
97         }
98 };
99
100 static struct flash_platform_data palmtt_flash_data = {
101         .map_name       = "cfi_probe",
102         .width          = 2,
103         .parts          = palmtt_partitions,
104         .nr_parts       = ARRAY_SIZE(palmtt_partitions),
105 };
106
107 static struct resource palmtt_flash_resource = {
108         .start          = OMAP_CS0_PHYS,
109         .end            = OMAP_CS0_PHYS + SZ_8M - 1,
110         .flags          = IORESOURCE_MEM,
111 };
112
113 static struct platform_device palmtt_flash_device = {
114         .name           = "omapflash",
115         .id             = 0,
116         .dev            = {
117                 .platform_data  = &palmtt_flash_data,
118         },
119         .num_resources  = 1,
120         .resource       = &palmtt_flash_resource,
121 };
122
123 static struct resource palmtt_kp_resources[] = {
124         [0] = {
125                 .start  = INT_KEYBOARD,
126                 .end    = INT_KEYBOARD,
127                 .flags  = IORESOURCE_IRQ,
128         },
129 };
130
131 static struct omap_kp_platform_data palmtt_kp_data = {
132         .rows   = 6,
133         .cols   = 3,
134         .keymap = palmtt_keymap,
135 };
136
137 static struct platform_device palmtt_kp_device = {
138         .name           = "omap-keypad",
139         .id             = -1,
140         .dev            = {
141                 .platform_data = &palmtt_kp_data,
142         },
143         .num_resources  = ARRAY_SIZE(palmtt_kp_resources),
144         .resource       = palmtt_kp_resources,
145 };
146
147 static struct platform_device palmtt_lcd_device = {
148         .name           = "lcd_palmtt",
149         .id             = -1,
150 };
151 static struct omap_irda_config palmtt_irda_config = {
152         .transceiver_cap        = IR_SIRMODE,
153         .rx_channel             = OMAP_DMA_UART3_RX,
154         .tx_channel             = OMAP_DMA_UART3_TX,
155         .dest_start             = UART3_THR,
156         .src_start              = UART3_RHR,
157         .tx_trigger             = 0,
158         .rx_trigger             = 0,
159 };
160
161 static struct resource palmtt_irda_resources[] = {
162         [0]     = {
163                 .start  = INT_UART3,
164                 .end    = INT_UART3,
165                 .flags  = IORESOURCE_IRQ,
166         },
167 };
168
169 static struct platform_device palmtt_irda_device = {
170         .name           = "omapirda",
171         .id             = -1,
172         .dev            = {
173                 .platform_data  = &palmtt_irda_config,
174         },
175         .num_resources  = ARRAY_SIZE(palmtt_irda_resources),
176         .resource       = palmtt_irda_resources,
177 };
178
179 static struct platform_device palmtt_spi_device = {
180         .name           = "spi_palmtt",
181         .id             = -1,
182 };
183
184 static struct omap_backlight_config palmtt_backlight_config = {
185         .default_intensity      = 0xa0,
186 };
187
188 static struct platform_device palmtt_backlight_device = {
189         .name           = "omap-bl",
190         .id             = -1,
191         .dev            = {
192                 .platform_data= &palmtt_backlight_config,
193         },
194 };
195
196 static struct omap_led_config palmtt_led_config[] = {
197         {
198                 .cdev   = {
199                         .name   = "palmtt:led0",
200                 },
201                 .gpio   = PALMTT_LED_GPIO,
202         },
203 };
204
205 static struct omap_led_platform_data palmtt_led_data = {
206         .nr_leds        = ARRAY_SIZE(palmtt_led_config),
207         .leds           = palmtt_led_config,
208 };
209
210 static struct platform_device palmtt_led_device = {
211         .name   = "omap-led",
212         .id     = -1,
213         .dev    = {
214                 .platform_data  = &palmtt_led_data,
215         },
216 };
217
218 static struct platform_device *palmtt_devices[] __initdata = {
219         &palmtt_flash_device,
220         &palmtt_kp_device,
221         &palmtt_lcd_device,
222         &palmtt_irda_device,
223         &palmtt_spi_device,
224         &palmtt_backlight_device,
225         &palmtt_led_device,
226 };
227
228 static int palmtt_get_pendown_state(void)
229 {
230         return !gpio_get_value(6);
231 }
232
233 static const struct ads7846_platform_data palmtt_ts_info = {
234         .model                  = 7846,
235         .vref_delay_usecs       = 100,  /* internal, no capacitor */
236         .x_plate_ohms           = 419,
237         .y_plate_ohms           = 486,
238         .get_pendown_state      = palmtt_get_pendown_state,
239 };
240
241 static struct spi_board_info __initdata palmtt_boardinfo[] = {
242         {
243                 /* MicroWire (bus 2) CS0 has an ads7846e */
244                 .modalias       = "ads7846",
245                 .platform_data  = &palmtt_ts_info,
246                 .irq            = OMAP_GPIO_IRQ(6),
247                 .max_speed_hz   = 120000        /* max sample rate at 3V */
248                                         * 26    /* command + data + overhead */,
249                 .bus_num        = 2,
250                 .chip_select    = 0,
251         }
252 };
253
254 static void __init omap_palmtt_init_irq(void)
255 {
256         omap1_init_common_hw();
257         omap_init_irq();
258 }
259
260 static struct omap_usb_config palmtt_usb_config __initdata = {
261         .register_dev   = 1,
262         .hmc_mode       = 0,
263         .pins[0]        = 2,
264 };
265
266 static struct omap_lcd_config palmtt_lcd_config __initdata = {
267         .ctrl_name      = "internal",
268 };
269
270 static struct omap_uart_config palmtt_uart_config __initdata = {
271         .enabled_uarts = (1 << 0) | (1 << 1) | (0 << 2),
272 };
273
274 static struct omap_board_config_kernel palmtt_config[] __initdata = {
275         { OMAP_TAG_USB,         &palmtt_usb_config      },
276         { OMAP_TAG_LCD,         &palmtt_lcd_config      },
277         { OMAP_TAG_UART,        &palmtt_uart_config     },
278 };
279
280 static void __init omap_mpu_wdt_mode(int mode) {
281         if (mode)
282                 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
283         else {
284                 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
285                 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
286         }
287 }
288
289 static void __init omap_palmtt_init(void)
290 {
291         omap_mpu_wdt_mode(0);
292
293         omap_board_config = palmtt_config;
294         omap_board_config_size = ARRAY_SIZE(palmtt_config);
295
296         platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices));
297
298         spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
299         omap_serial_init();
300         omap_register_i2c_bus(1, 100, NULL, 0);
301 }
302
303 static void __init omap_palmtt_map_io(void)
304 {
305         omap1_map_common_io();
306 }
307
308 MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
309         .phys_io        = 0xfff00000,
310         .io_pg_offst    = ((0xfef00000) >> 18) & 0xfffc,
311         .boot_params    = 0x10000100,
312         .map_io         = omap_palmtt_map_io,
313         .init_irq       = omap_palmtt_init_irq,
314         .init_machine   = omap_palmtt_init,
315         .timer          = &omap_timer,
316 MACHINE_END