blob: d972cf941b76f86472a9191e1a2d9789d92e69a6 [file] [log] [blame]
Marek Vasutdc563b42006-12-06 17:14:07 -08001/*
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
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/hardware.h>
Marek Vasutdc563b42006-12-06 17:14:07 -080027#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29#include <asm/mach/map.h>
30#include <asm/mach/flash.h>
31
Russell Kinga09e64f2008-08-05 16:14:15 +010032#include <mach/led.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010033#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>
Marek Vasutdc563b42006-12-06 17:14:07 -080042
Marek Vasutdc563b42006-12-06 17:14:07 -080043#include <linux/spi/spi.h>
44#include <linux/spi/ads7846.h>
45
Tony Lindgrenb2830812009-03-23 18:07:35 -070046#define PALMTT_USBDETECT_GPIO 0
47#define PALMTT_CABLE_GPIO 1
48#define PALMTT_LED_GPIO 3
49#define PALMTT_PENIRQ_GPIO 6
50#define PALMTT_MMC_WP_GPIO 8
51#define PALMTT_HDQ_GPIO 11
52
Marek Vasutdc563b42006-12-06 17:14:07 -080053static int palmtt_keymap[] = {
54 KEY(0, 0, KEY_ESC),
55 KEY(0, 1, KEY_SPACE),
56 KEY(0, 2, KEY_LEFTCTRL),
57 KEY(0, 3, KEY_TAB),
58 KEY(0, 4, KEY_ENTER),
59 KEY(1, 0, KEY_LEFT),
60 KEY(1, 1, KEY_DOWN),
61 KEY(1, 2, KEY_UP),
62 KEY(1, 3, KEY_RIGHT),
63 KEY(2, 0, KEY_SLEEP),
64 KEY(2, 4, KEY_Y),
65 0
66};
67
68static struct mtd_partition palmtt_partitions[] = {
69 {
70 .name = "write8k",
71 .offset = 0,
72 .size = SZ_8K,
73 .mask_flags = 0,
74 },
75 {
76 .name = "PalmOS-BootLoader(ro)",
77 .offset = SZ_8K,
78 .size = 7 * SZ_8K,
79 .mask_flags = MTD_WRITEABLE,
80 },
81 {
82 .name = "u-boot",
83 .offset = MTDPART_OFS_APPEND,
84 .size = 8 * SZ_8K,
85 .mask_flags = 0,
86 },
87 {
88 .name = "PalmOS-FS(ro)",
89 .offset = MTDPART_OFS_APPEND,
90 .size = 7 * SZ_1M + 4 * SZ_64K - 16 * SZ_8K,
91 .mask_flags = MTD_WRITEABLE,
92 },
93 {
94 .name = "u-boot(rez)",
95 .offset = MTDPART_OFS_APPEND,
96 .size = SZ_128K,
97 .mask_flags = 0
98 },
99 {
100 .name = "empty",
101 .offset = MTDPART_OFS_APPEND,
102 .size = MTDPART_SIZ_FULL,
103 .mask_flags = 0
104 }
105};
106
107static struct flash_platform_data palmtt_flash_data = {
108 .map_name = "cfi_probe",
109 .width = 2,
110 .parts = palmtt_partitions,
111 .nr_parts = ARRAY_SIZE(palmtt_partitions),
112};
113
114static struct resource palmtt_flash_resource = {
115 .start = OMAP_CS0_PHYS,
116 .end = OMAP_CS0_PHYS + SZ_8M - 1,
117 .flags = IORESOURCE_MEM,
118};
119
120static struct platform_device palmtt_flash_device = {
121 .name = "omapflash",
122 .id = 0,
123 .dev = {
124 .platform_data = &palmtt_flash_data,
125 },
126 .num_resources = 1,
127 .resource = &palmtt_flash_resource,
128};
129
Marek Vasutdc563b42006-12-06 17:14:07 -0800130static struct resource palmtt_kp_resources[] = {
131 [0] = {
132 .start = INT_KEYBOARD,
133 .end = INT_KEYBOARD,
134 .flags = IORESOURCE_IRQ,
135 },
136};
137
138static struct omap_kp_platform_data palmtt_kp_data = {
139 .rows = 6,
140 .cols = 3,
141 .keymap = palmtt_keymap,
142};
143
144static struct platform_device palmtt_kp_device = {
145 .name = "omap-keypad",
146 .id = -1,
147 .dev = {
148 .platform_data = &palmtt_kp_data,
149 },
150 .num_resources = ARRAY_SIZE(palmtt_kp_resources),
151 .resource = palmtt_kp_resources,
152};
153
154static struct platform_device palmtt_lcd_device = {
155 .name = "lcd_palmtt",
156 .id = -1,
157};
158static struct omap_irda_config palmtt_irda_config = {
159 .transceiver_cap = IR_SIRMODE,
160 .rx_channel = OMAP_DMA_UART3_RX,
161 .tx_channel = OMAP_DMA_UART3_TX,
162 .dest_start = UART3_THR,
163 .src_start = UART3_RHR,
164 .tx_trigger = 0,
165 .rx_trigger = 0,
166};
167
168static struct resource palmtt_irda_resources[] = {
169 [0] = {
170 .start = INT_UART3,
171 .end = INT_UART3,
172 .flags = IORESOURCE_IRQ,
173 },
174};
175
176static struct platform_device palmtt_irda_device = {
177 .name = "omapirda",
178 .id = -1,
179 .dev = {
180 .platform_data = &palmtt_irda_config,
181 },
182 .num_resources = ARRAY_SIZE(palmtt_irda_resources),
183 .resource = palmtt_irda_resources,
184};
185
186static struct platform_device palmtt_spi_device = {
187 .name = "spi_palmtt",
188 .id = -1,
189};
190
191static struct omap_backlight_config palmtt_backlight_config = {
192 .default_intensity = 0xa0,
193};
194
195static struct platform_device palmtt_backlight_device = {
196 .name = "omap-bl",
197 .id = -1,
198 .dev = {
199 .platform_data= &palmtt_backlight_config,
200 },
201};
202
203static struct omap_led_config palmtt_led_config[] = {
204 {
205 .cdev = {
206 .name = "palmtt:led0",
207 },
208 .gpio = PALMTT_LED_GPIO,
209 },
210};
211
212static struct omap_led_platform_data palmtt_led_data = {
213 .nr_leds = ARRAY_SIZE(palmtt_led_config),
214 .leds = palmtt_led_config,
215};
216
217static struct platform_device palmtt_led_device = {
218 .name = "omap-led",
219 .id = -1,
220 .dev = {
221 .platform_data = &palmtt_led_data,
222 },
223};
224
225static struct platform_device *palmtt_devices[] __initdata = {
226 &palmtt_flash_device,
Marek Vasutdc563b42006-12-06 17:14:07 -0800227 &palmtt_kp_device,
228 &palmtt_lcd_device,
229 &palmtt_irda_device,
230 &palmtt_spi_device,
231 &palmtt_backlight_device,
232 &palmtt_led_device,
233};
234
235static int palmtt_get_pendown_state(void)
236{
David Brownell0b84b5c2008-12-10 17:35:25 -0800237 return !gpio_get_value(6);
Marek Vasutdc563b42006-12-06 17:14:07 -0800238}
239
240static const struct ads7846_platform_data palmtt_ts_info = {
241 .model = 7846,
242 .vref_delay_usecs = 100, /* internal, no capacitor */
243 .x_plate_ohms = 419,
244 .y_plate_ohms = 486,
245 .get_pendown_state = palmtt_get_pendown_state,
246};
247
248static struct spi_board_info __initdata palmtt_boardinfo[] = {
249 {
250 /* MicroWire (bus 2) CS0 has an ads7846e */
251 .modalias = "ads7846",
252 .platform_data = &palmtt_ts_info,
253 .irq = OMAP_GPIO_IRQ(6),
254 .max_speed_hz = 120000 /* max sample rate at 3V */
255 * 26 /* command + data + overhead */,
256 .bus_num = 2,
257 .chip_select = 0,
258 }
259};
260
261static void __init omap_palmtt_init_irq(void)
262{
263 omap1_init_common_hw();
264 omap_init_irq();
265}
266
267static struct omap_usb_config palmtt_usb_config __initdata = {
268 .register_dev = 1,
269 .hmc_mode = 0,
270 .pins[0] = 2,
271};
272
273static struct omap_lcd_config palmtt_lcd_config __initdata = {
274 .ctrl_name = "internal",
275};
276
Tony Lindgrene27a93a2007-12-18 20:58:32 -0800277static struct omap_board_config_kernel palmtt_config[] __initdata = {
Tony Lindgrena5246262006-12-07 13:58:17 -0800278 { OMAP_TAG_LCD, &palmtt_lcd_config },
Marek Vasutdc563b42006-12-06 17:14:07 -0800279};
280
281static void __init omap_mpu_wdt_mode(int mode) {
282 if (mode)
283 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
284 else {
285 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
286 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
287 }
288}
289
290static void __init omap_palmtt_init(void)
291{
Janusz Krzysztofikc33da3a2009-10-22 14:47:42 -0700292 /* mux pins for uarts */
293 omap_cfg_reg(UART1_TX);
294 omap_cfg_reg(UART1_RTS);
295 omap_cfg_reg(UART2_TX);
296 omap_cfg_reg(UART2_RTS);
297 omap_cfg_reg(UART3_TX);
298 omap_cfg_reg(UART3_RX);
299
Marek Vasutdc563b42006-12-06 17:14:07 -0800300 omap_mpu_wdt_mode(0);
301
302 omap_board_config = palmtt_config;
303 omap_board_config_size = ARRAY_SIZE(palmtt_config);
304
305 platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices));
306
307 spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
308 omap_serial_init();
Felipe Balbib0b5aa32009-03-23 18:07:49 -0700309 omap_usb_init(&palmtt_usb_config);
Jarkko Nikula1ed16a82007-11-07 06:54:32 +0200310 omap_register_i2c_bus(1, 100, NULL, 0);
Marek Vasutdc563b42006-12-06 17:14:07 -0800311}
312
313static void __init omap_palmtt_map_io(void)
314{
315 omap1_map_common_io();
316}
317
318MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
319 .phys_io = 0xfff00000,
320 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
321 .boot_params = 0x10000100,
322 .map_io = omap_palmtt_map_io,
323 .init_irq = omap_palmtt_init_irq,
324 .init_machine = omap_palmtt_init,
325 .timer = &omap_timer,
326MACHINE_END