blob: b63350bc88fd2c6f90f062597804a033ab083cdb [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>
Russell King2f8163b2011-07-26 10:53:52 +010015#include <linux/gpio.h>
Marek Vasutdc563b42006-12-06 17:14:07 -080016#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/platform_device.h>
19#include <linux/notifier.h>
20#include <linux/clk.h>
21#include <linux/input.h>
22#include <linux/interrupt.h>
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/partitions.h>
Ladislav Michl561b0362010-02-15 10:03:32 -080025#include <linux/mtd/physmap.h>
Marek Vasutdc563b42006-12-06 17:14:07 -080026#include <linux/leds.h>
Tomi Valkeinenddba6c72011-09-20 15:23:13 +030027#include <linux/omapfb.h>
Marek Vasutdc563b42006-12-06 17:14:07 -080028
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/hardware.h>
Marek Vasutdc563b42006-12-06 17:14:07 -080030#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
Marek Vasutdc563b42006-12-06 17:14:07 -080033
Tony Lindgrence491cf2009-10-20 09:40:47 -070034#include <plat/led.h>
Ladislav Michl561b0362010-02-15 10:03:32 -080035#include <plat/flash.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070036#include <plat/mux.h>
37#include <plat/usb.h>
38#include <plat/dma.h>
39#include <plat/tc.h>
40#include <plat/board.h>
41#include <plat/irda.h>
42#include <plat/keypad.h>
Tony Lindgren4e653312011-11-10 22:45:17 +010043#include "common.h"
Marek Vasutdc563b42006-12-06 17:14:07 -080044
Marek Vasutdc563b42006-12-06 17:14:07 -080045#include <linux/spi/spi.h>
46#include <linux/spi/ads7846.h>
47
Tony Lindgrenb2830812009-03-23 18:07:35 -070048#define PALMTT_USBDETECT_GPIO 0
49#define PALMTT_CABLE_GPIO 1
50#define PALMTT_LED_GPIO 3
51#define PALMTT_PENIRQ_GPIO 6
52#define PALMTT_MMC_WP_GPIO 8
53#define PALMTT_HDQ_GPIO 11
54
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000055static const unsigned int palmtt_keymap[] = {
Marek Vasutdc563b42006-12-06 17:14:07 -080056 KEY(0, 0, KEY_ESC),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000057 KEY(1, 0, KEY_SPACE),
58 KEY(2, 0, KEY_LEFTCTRL),
59 KEY(3, 0, KEY_TAB),
60 KEY(4, 0, KEY_ENTER),
61 KEY(0, 1, KEY_LEFT),
Marek Vasutdc563b42006-12-06 17:14:07 -080062 KEY(1, 1, KEY_DOWN),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000063 KEY(2, 1, KEY_UP),
64 KEY(3, 1, KEY_RIGHT),
65 KEY(0, 2, KEY_SLEEP),
66 KEY(4, 2, KEY_Y),
Marek Vasutdc563b42006-12-06 17:14:07 -080067};
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
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000139static const struct matrix_keymap_data palmtt_keymap_data = {
140 .keymap = palmtt_keymap,
141 .keymap_size = ARRAY_SIZE(palmtt_keymap),
142};
143
Marek Vasutdc563b42006-12-06 17:14:07 -0800144static struct omap_kp_platform_data palmtt_kp_data = {
145 .rows = 6,
146 .cols = 3,
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000147 .keymap_data = &palmtt_keymap_data,
Marek Vasutdc563b42006-12-06 17:14:07 -0800148};
149
150static struct platform_device palmtt_kp_device = {
151 .name = "omap-keypad",
152 .id = -1,
153 .dev = {
154 .platform_data = &palmtt_kp_data,
155 },
156 .num_resources = ARRAY_SIZE(palmtt_kp_resources),
157 .resource = palmtt_kp_resources,
158};
159
160static struct platform_device palmtt_lcd_device = {
161 .name = "lcd_palmtt",
162 .id = -1,
163};
164static struct omap_irda_config palmtt_irda_config = {
165 .transceiver_cap = IR_SIRMODE,
166 .rx_channel = OMAP_DMA_UART3_RX,
167 .tx_channel = OMAP_DMA_UART3_TX,
168 .dest_start = UART3_THR,
169 .src_start = UART3_RHR,
170 .tx_trigger = 0,
171 .rx_trigger = 0,
172};
173
174static struct resource palmtt_irda_resources[] = {
175 [0] = {
176 .start = INT_UART3,
177 .end = INT_UART3,
178 .flags = IORESOURCE_IRQ,
179 },
180};
181
182static struct platform_device palmtt_irda_device = {
183 .name = "omapirda",
184 .id = -1,
185 .dev = {
186 .platform_data = &palmtt_irda_config,
187 },
188 .num_resources = ARRAY_SIZE(palmtt_irda_resources),
189 .resource = palmtt_irda_resources,
190};
191
192static struct platform_device palmtt_spi_device = {
193 .name = "spi_palmtt",
194 .id = -1,
195};
196
197static struct omap_backlight_config palmtt_backlight_config = {
198 .default_intensity = 0xa0,
199};
200
201static struct platform_device palmtt_backlight_device = {
202 .name = "omap-bl",
203 .id = -1,
204 .dev = {
205 .platform_data= &palmtt_backlight_config,
206 },
207};
208
209static struct omap_led_config palmtt_led_config[] = {
210 {
211 .cdev = {
212 .name = "palmtt:led0",
213 },
214 .gpio = PALMTT_LED_GPIO,
215 },
216};
217
218static struct omap_led_platform_data palmtt_led_data = {
219 .nr_leds = ARRAY_SIZE(palmtt_led_config),
220 .leds = palmtt_led_config,
221};
222
223static struct platform_device palmtt_led_device = {
224 .name = "omap-led",
225 .id = -1,
226 .dev = {
227 .platform_data = &palmtt_led_data,
228 },
229};
230
231static struct platform_device *palmtt_devices[] __initdata = {
232 &palmtt_flash_device,
Marek Vasutdc563b42006-12-06 17:14:07 -0800233 &palmtt_kp_device,
234 &palmtt_lcd_device,
235 &palmtt_irda_device,
236 &palmtt_spi_device,
237 &palmtt_backlight_device,
238 &palmtt_led_device,
239};
240
241static int palmtt_get_pendown_state(void)
242{
David Brownell0b84b5c2008-12-10 17:35:25 -0800243 return !gpio_get_value(6);
Marek Vasutdc563b42006-12-06 17:14:07 -0800244}
245
246static const struct ads7846_platform_data palmtt_ts_info = {
247 .model = 7846,
248 .vref_delay_usecs = 100, /* internal, no capacitor */
249 .x_plate_ohms = 419,
250 .y_plate_ohms = 486,
251 .get_pendown_state = palmtt_get_pendown_state,
252};
253
254static struct spi_board_info __initdata palmtt_boardinfo[] = {
255 {
256 /* MicroWire (bus 2) CS0 has an ads7846e */
257 .modalias = "ads7846",
258 .platform_data = &palmtt_ts_info,
259 .irq = OMAP_GPIO_IRQ(6),
260 .max_speed_hz = 120000 /* max sample rate at 3V */
261 * 26 /* command + data + overhead */,
262 .bus_num = 2,
263 .chip_select = 0,
264 }
265};
266
Marek Vasutdc563b42006-12-06 17:14:07 -0800267static 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
Marek Vasutdc563b42006-12-06 17:14:07 -0800277static void __init omap_mpu_wdt_mode(int mode) {
278 if (mode)
279 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
280 else {
281 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
282 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
283 }
284}
285
286static void __init omap_palmtt_init(void)
287{
Janusz Krzysztofikc33da3a2009-10-22 14:47:42 -0700288 /* mux pins for uarts */
289 omap_cfg_reg(UART1_TX);
290 omap_cfg_reg(UART1_RTS);
291 omap_cfg_reg(UART2_TX);
292 omap_cfg_reg(UART2_RTS);
293 omap_cfg_reg(UART3_TX);
294 omap_cfg_reg(UART3_RX);
295
Marek Vasutdc563b42006-12-06 17:14:07 -0800296 omap_mpu_wdt_mode(0);
297
Marek Vasutdc563b42006-12-06 17:14:07 -0800298 platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices));
299
300 spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
301 omap_serial_init();
Tony Lindgrendd0cdd82010-07-05 16:31:30 +0300302 omap1_usb_init(&palmtt_usb_config);
Jarkko Nikula1ed16a82007-11-07 06:54:32 +0200303 omap_register_i2c_bus(1, 100, NULL, 0);
Tomi Valkeinenddba6c72011-09-20 15:23:13 +0300304
305 omapfb_set_lcd_config(&palmtt_lcd_config);
Marek Vasutdc563b42006-12-06 17:14:07 -0800306}
307
Marek Vasutdc563b42006-12-06 17:14:07 -0800308MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
Nicolas Pitre246e3892011-07-05 22:38:15 -0400309 .atag_offset = 0x100,
Tony Lindgren7b88e622011-10-05 15:14:02 -0700310 .map_io = omap15xx_map_io,
311 .init_early = omap1_init_early,
Russell King71ee7da2010-05-23 10:18:16 +0100312 .reserve = omap_reserve,
Tony Lindgren7b88e622011-10-05 15:14:02 -0700313 .init_irq = omap1_init_irq,
Marek Vasutdc563b42006-12-06 17:14:07 -0800314 .init_machine = omap_palmtt_init,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700315 .timer = &omap1_timer,
Russell Kingbaa95882011-11-05 17:06:28 +0000316 .restart = omap1_restart,
Marek Vasutdc563b42006-12-06 17:14:07 -0800317MACHINE_END