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