blob: 5b8ac0fcf451ba74568d3a6fcc91ae172c52d940 [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>
Tony Lindgren2e3ee9f2012-02-24 10:34:34 -080028#include <linux/spi/spi.h>
29#include <linux/spi/ads7846.h>
Igor Grinbergcc012722012-08-29 02:18:54 +030030#include <linux/platform_data/omap1_bl.h>
Marek Vasutdc563b42006-12-06 17:14:07 -080031
Marek Vasutdc563b42006-12-06 17:14:07 -080032#include <asm/mach-types.h>
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
Marek Vasutdc563b42006-12-06 17:14:07 -080035
Tony Lindgrence491cf2009-10-20 09:40:47 -070036#include <plat/led.h>
Tony Lindgren578fad42012-09-20 11:41:37 -070037#include <mach/flash.h>
Tony Lindgren70c494c2012-09-19 10:46:56 -070038#include <mach/mux.h>
Lokesh Vutla2b6c4e72012-10-15 14:04:53 -070039#include <plat-omap/dma-omap.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070040#include <plat/tc.h>
Tony Lindgren2f7cd572012-09-20 11:41:59 -070041#include <mach/irda.h>
Arnd Bergmann22037472012-08-24 15:21:06 +020042#include <linux/platform_data/keypad-omap.h>
Marek Vasutdc563b42006-12-06 17:14:07 -080043
Tony Lindgren2e3ee9f2012-02-24 10:34:34 -080044#include <mach/hardware.h>
Tony Lindgrenb924b202012-06-04 00:56:15 -070045#include <mach/usb.h>
Tony Lindgren2e3ee9f2012-02-24 10:34:34 -080046
47#include "common.h"
Lokesh Vutla8c4cc002012-10-15 14:01:01 -070048#include "dma.h"
Marek Vasutdc563b42006-12-06 17:14:07 -080049
Tony Lindgrenb2830812009-03-23 18:07:35 -070050#define PALMTT_USBDETECT_GPIO 0
51#define PALMTT_CABLE_GPIO 1
52#define PALMTT_LED_GPIO 3
53#define PALMTT_PENIRQ_GPIO 6
54#define PALMTT_MMC_WP_GPIO 8
55#define PALMTT_HDQ_GPIO 11
56
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000057static const unsigned int palmtt_keymap[] = {
Marek Vasutdc563b42006-12-06 17:14:07 -080058 KEY(0, 0, KEY_ESC),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000059 KEY(1, 0, KEY_SPACE),
60 KEY(2, 0, KEY_LEFTCTRL),
61 KEY(3, 0, KEY_TAB),
62 KEY(4, 0, KEY_ENTER),
63 KEY(0, 1, KEY_LEFT),
Marek Vasutdc563b42006-12-06 17:14:07 -080064 KEY(1, 1, KEY_DOWN),
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +000065 KEY(2, 1, KEY_UP),
66 KEY(3, 1, KEY_RIGHT),
67 KEY(0, 2, KEY_SLEEP),
68 KEY(4, 2, KEY_Y),
Marek Vasutdc563b42006-12-06 17:14:07 -080069};
70
71static struct mtd_partition palmtt_partitions[] = {
72 {
73 .name = "write8k",
74 .offset = 0,
75 .size = SZ_8K,
76 .mask_flags = 0,
77 },
78 {
79 .name = "PalmOS-BootLoader(ro)",
80 .offset = SZ_8K,
81 .size = 7 * SZ_8K,
82 .mask_flags = MTD_WRITEABLE,
83 },
84 {
85 .name = "u-boot",
86 .offset = MTDPART_OFS_APPEND,
87 .size = 8 * SZ_8K,
88 .mask_flags = 0,
89 },
90 {
91 .name = "PalmOS-FS(ro)",
92 .offset = MTDPART_OFS_APPEND,
93 .size = 7 * SZ_1M + 4 * SZ_64K - 16 * SZ_8K,
94 .mask_flags = MTD_WRITEABLE,
95 },
96 {
97 .name = "u-boot(rez)",
98 .offset = MTDPART_OFS_APPEND,
99 .size = SZ_128K,
100 .mask_flags = 0
101 },
102 {
103 .name = "empty",
104 .offset = MTDPART_OFS_APPEND,
105 .size = MTDPART_SIZ_FULL,
106 .mask_flags = 0
107 }
108};
109
Ladislav Michl561b0362010-02-15 10:03:32 -0800110static struct physmap_flash_data palmtt_flash_data = {
Marek Vasutdc563b42006-12-06 17:14:07 -0800111 .width = 2,
Ladislav Michl561b0362010-02-15 10:03:32 -0800112 .set_vpp = omap1_set_vpp,
Marek Vasutdc563b42006-12-06 17:14:07 -0800113 .parts = palmtt_partitions,
114 .nr_parts = ARRAY_SIZE(palmtt_partitions),
115};
116
117static struct resource palmtt_flash_resource = {
118 .start = OMAP_CS0_PHYS,
119 .end = OMAP_CS0_PHYS + SZ_8M - 1,
120 .flags = IORESOURCE_MEM,
121};
122
123static struct platform_device palmtt_flash_device = {
Ladislav Michl561b0362010-02-15 10:03:32 -0800124 .name = "physmap-flash",
Marek Vasutdc563b42006-12-06 17:14:07 -0800125 .id = 0,
126 .dev = {
127 .platform_data = &palmtt_flash_data,
128 },
129 .num_resources = 1,
130 .resource = &palmtt_flash_resource,
131};
132
Marek Vasutdc563b42006-12-06 17:14:07 -0800133static struct resource palmtt_kp_resources[] = {
134 [0] = {
135 .start = INT_KEYBOARD,
136 .end = INT_KEYBOARD,
137 .flags = IORESOURCE_IRQ,
138 },
139};
140
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000141static const struct matrix_keymap_data palmtt_keymap_data = {
142 .keymap = palmtt_keymap,
143 .keymap_size = ARRAY_SIZE(palmtt_keymap),
144};
145
Marek Vasutdc563b42006-12-06 17:14:07 -0800146static struct omap_kp_platform_data palmtt_kp_data = {
147 .rows = 6,
148 .cols = 3,
Janusz Krzysztofikda1f0262010-12-20 21:09:22 +0000149 .keymap_data = &palmtt_keymap_data,
Marek Vasutdc563b42006-12-06 17:14:07 -0800150};
151
152static struct platform_device palmtt_kp_device = {
153 .name = "omap-keypad",
154 .id = -1,
155 .dev = {
156 .platform_data = &palmtt_kp_data,
157 },
158 .num_resources = ARRAY_SIZE(palmtt_kp_resources),
159 .resource = palmtt_kp_resources,
160};
161
162static struct platform_device palmtt_lcd_device = {
163 .name = "lcd_palmtt",
164 .id = -1,
165};
166static struct omap_irda_config palmtt_irda_config = {
167 .transceiver_cap = IR_SIRMODE,
168 .rx_channel = OMAP_DMA_UART3_RX,
169 .tx_channel = OMAP_DMA_UART3_TX,
170 .dest_start = UART3_THR,
171 .src_start = UART3_RHR,
172 .tx_trigger = 0,
173 .rx_trigger = 0,
174};
175
176static struct resource palmtt_irda_resources[] = {
177 [0] = {
178 .start = INT_UART3,
179 .end = INT_UART3,
180 .flags = IORESOURCE_IRQ,
181 },
182};
183
184static struct platform_device palmtt_irda_device = {
185 .name = "omapirda",
186 .id = -1,
187 .dev = {
188 .platform_data = &palmtt_irda_config,
189 },
190 .num_resources = ARRAY_SIZE(palmtt_irda_resources),
191 .resource = palmtt_irda_resources,
192};
193
194static struct platform_device palmtt_spi_device = {
195 .name = "spi_palmtt",
196 .id = -1,
197};
198
199static struct omap_backlight_config palmtt_backlight_config = {
200 .default_intensity = 0xa0,
201};
202
203static struct platform_device palmtt_backlight_device = {
204 .name = "omap-bl",
205 .id = -1,
206 .dev = {
207 .platform_data= &palmtt_backlight_config,
208 },
209};
210
211static struct omap_led_config palmtt_led_config[] = {
212 {
213 .cdev = {
214 .name = "palmtt:led0",
215 },
216 .gpio = PALMTT_LED_GPIO,
217 },
218};
219
220static struct omap_led_platform_data palmtt_led_data = {
221 .nr_leds = ARRAY_SIZE(palmtt_led_config),
222 .leds = palmtt_led_config,
223};
224
225static struct platform_device palmtt_led_device = {
226 .name = "omap-led",
227 .id = -1,
228 .dev = {
229 .platform_data = &palmtt_led_data,
230 },
231};
232
233static struct platform_device *palmtt_devices[] __initdata = {
234 &palmtt_flash_device,
Marek Vasutdc563b42006-12-06 17:14:07 -0800235 &palmtt_kp_device,
236 &palmtt_lcd_device,
237 &palmtt_irda_device,
238 &palmtt_spi_device,
239 &palmtt_backlight_device,
240 &palmtt_led_device,
241};
242
243static int palmtt_get_pendown_state(void)
244{
David Brownell0b84b5c2008-12-10 17:35:25 -0800245 return !gpio_get_value(6);
Marek Vasutdc563b42006-12-06 17:14:07 -0800246}
247
248static const struct ads7846_platform_data palmtt_ts_info = {
249 .model = 7846,
250 .vref_delay_usecs = 100, /* internal, no capacitor */
251 .x_plate_ohms = 419,
252 .y_plate_ohms = 486,
253 .get_pendown_state = palmtt_get_pendown_state,
254};
255
256static struct spi_board_info __initdata palmtt_boardinfo[] = {
257 {
258 /* MicroWire (bus 2) CS0 has an ads7846e */
259 .modalias = "ads7846",
260 .platform_data = &palmtt_ts_info,
Marek Vasutdc563b42006-12-06 17:14:07 -0800261 .max_speed_hz = 120000 /* max sample rate at 3V */
262 * 26 /* command + data + overhead */,
263 .bus_num = 2,
264 .chip_select = 0,
265 }
266};
267
Marek Vasutdc563b42006-12-06 17:14:07 -0800268static 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
Marek Vasutdc563b42006-12-06 17:14:07 -0800278static void __init omap_mpu_wdt_mode(int mode) {
279 if (mode)
280 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
281 else {
282 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
283 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
284 }
285}
286
287static void __init omap_palmtt_init(void)
288{
Janusz Krzysztofikc33da3a2009-10-22 14:47:42 -0700289 /* mux pins for uarts */
290 omap_cfg_reg(UART1_TX);
291 omap_cfg_reg(UART1_RTS);
292 omap_cfg_reg(UART2_TX);
293 omap_cfg_reg(UART2_RTS);
294 omap_cfg_reg(UART3_TX);
295 omap_cfg_reg(UART3_RX);
296
Marek Vasutdc563b42006-12-06 17:14:07 -0800297 omap_mpu_wdt_mode(0);
298
Marek Vasutdc563b42006-12-06 17:14:07 -0800299 platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices));
300
Tarun Kanti DebBarma46a0a542012-03-29 08:41:01 -0700301 palmtt_boardinfo[0].irq = gpio_to_irq(6);
Marek Vasutdc563b42006-12-06 17:14:07 -0800302 spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
303 omap_serial_init();
Tony Lindgrendd0cdd82010-07-05 16:31:30 +0300304 omap1_usb_init(&palmtt_usb_config);
Jarkko Nikula1ed16a82007-11-07 06:54:32 +0200305 omap_register_i2c_bus(1, 100, NULL, 0);
Tomi Valkeinenddba6c72011-09-20 15:23:13 +0300306
307 omapfb_set_lcd_config(&palmtt_lcd_config);
Marek Vasutdc563b42006-12-06 17:14:07 -0800308}
309
Marek Vasutdc563b42006-12-06 17:14:07 -0800310MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
Nicolas Pitre246e3892011-07-05 22:38:15 -0400311 .atag_offset = 0x100,
Tony Lindgren7b88e622011-10-05 15:14:02 -0700312 .map_io = omap15xx_map_io,
313 .init_early = omap1_init_early,
Russell King71ee7da2010-05-23 10:18:16 +0100314 .reserve = omap_reserve,
Tony Lindgren7b88e622011-10-05 15:14:02 -0700315 .init_irq = omap1_init_irq,
Marek Vasutdc563b42006-12-06 17:14:07 -0800316 .init_machine = omap_palmtt_init,
Shawn Guo82c3bd02012-04-26 13:49:29 +0800317 .init_late = omap1_init_late,
Tony Lindgrene74984e2011-03-29 15:54:48 -0700318 .timer = &omap1_timer,
Russell Kingbaa95882011-11-05 17:06:28 +0000319 .restart = omap1_restart,
Marek Vasutdc563b42006-12-06 17:14:07 -0800320MACHINE_END