blob: 2a033689f9f4b972b3c9c9a37b6db88d422685dc [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
26#include <asm/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 <asm/arch/led.h>
33#include <asm/arch/mcbsp.h>
34#include <asm/arch/gpio.h>
35#include <asm/arch/mux.h>
36#include <asm/arch/usb.h>
37#include <asm/arch/dma.h>
38#include <asm/arch/tc.h>
39#include <asm/arch/board.h>
40#include <asm/arch/irda.h>
41#include <asm/arch/keypad.h>
42#include <asm/arch/common.h>
43#include <asm/arch/omap-alsa.h>
44
Marek Vasutdc563b42006-12-06 17:14:07 -080045#include <linux/spi/spi.h>
46#include <linux/spi/ads7846.h>
47
48static int palmtt_keymap[] = {
49 KEY(0, 0, KEY_ESC),
50 KEY(0, 1, KEY_SPACE),
51 KEY(0, 2, KEY_LEFTCTRL),
52 KEY(0, 3, KEY_TAB),
53 KEY(0, 4, KEY_ENTER),
54 KEY(1, 0, KEY_LEFT),
55 KEY(1, 1, KEY_DOWN),
56 KEY(1, 2, KEY_UP),
57 KEY(1, 3, KEY_RIGHT),
58 KEY(2, 0, KEY_SLEEP),
59 KEY(2, 4, KEY_Y),
60 0
61};
62
63static struct mtd_partition palmtt_partitions[] = {
64 {
65 .name = "write8k",
66 .offset = 0,
67 .size = SZ_8K,
68 .mask_flags = 0,
69 },
70 {
71 .name = "PalmOS-BootLoader(ro)",
72 .offset = SZ_8K,
73 .size = 7 * SZ_8K,
74 .mask_flags = MTD_WRITEABLE,
75 },
76 {
77 .name = "u-boot",
78 .offset = MTDPART_OFS_APPEND,
79 .size = 8 * SZ_8K,
80 .mask_flags = 0,
81 },
82 {
83 .name = "PalmOS-FS(ro)",
84 .offset = MTDPART_OFS_APPEND,
85 .size = 7 * SZ_1M + 4 * SZ_64K - 16 * SZ_8K,
86 .mask_flags = MTD_WRITEABLE,
87 },
88 {
89 .name = "u-boot(rez)",
90 .offset = MTDPART_OFS_APPEND,
91 .size = SZ_128K,
92 .mask_flags = 0
93 },
94 {
95 .name = "empty",
96 .offset = MTDPART_OFS_APPEND,
97 .size = MTDPART_SIZ_FULL,
98 .mask_flags = 0
99 }
100};
101
102static struct flash_platform_data palmtt_flash_data = {
103 .map_name = "cfi_probe",
104 .width = 2,
105 .parts = palmtt_partitions,
106 .nr_parts = ARRAY_SIZE(palmtt_partitions),
107};
108
109static struct resource palmtt_flash_resource = {
110 .start = OMAP_CS0_PHYS,
111 .end = OMAP_CS0_PHYS + SZ_8M - 1,
112 .flags = IORESOURCE_MEM,
113};
114
115static struct platform_device palmtt_flash_device = {
116 .name = "omapflash",
117 .id = 0,
118 .dev = {
119 .platform_data = &palmtt_flash_data,
120 },
121 .num_resources = 1,
122 .resource = &palmtt_flash_resource,
123};
124
125#define DEFAULT_BITPERSAMPLE 16
126
127static struct omap_mcbsp_reg_cfg mcbsp_regs = {
128 .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
129 .spcr1 = RINTM(3) | RRST,
130 .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
131 RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
132 .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) |
133 RWDLEN1(OMAP_MCBSP_WORD_16),
134 .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
135 XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
136 .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) |
137 XWDLEN1(OMAP_MCBSP_WORD_16),
138 .srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
139 .srgr2 = GSYNC | CLKSP | FSGM |
140 FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
141 .pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
142};
143
144static struct omap_alsa_codec_config alsa_config = {
145 .name = "PalmTT AIC23",
146 .mcbsp_regs_alsa = &mcbsp_regs,
David Cohen6e2d4102007-12-13 22:27:15 -0400147 .codec_configure_dev = NULL, /* aic23_configure, */
148 .codec_set_samplerate = NULL, /* aic23_set_samplerate, */
149 .codec_clock_setup = NULL, /* aic23_clock_setup, */
150 .codec_clock_on = NULL, /* aic23_clock_on, */
151 .codec_clock_off = NULL, /* aic23_clock_off, */
152 .get_default_samplerate = NULL, /* aic23_get_default_samplerate, */
Marek Vasutdc563b42006-12-06 17:14:07 -0800153};
154
155static struct platform_device palmtt_mcbsp1_device = {
156 .name = "omap_alsa_mcbsp",
157 .id = 1,
158 .dev = {
159 .platform_data = &alsa_config,
160 },
161};
162
163static struct resource palmtt_kp_resources[] = {
164 [0] = {
165 .start = INT_KEYBOARD,
166 .end = INT_KEYBOARD,
167 .flags = IORESOURCE_IRQ,
168 },
169};
170
171static struct omap_kp_platform_data palmtt_kp_data = {
172 .rows = 6,
173 .cols = 3,
174 .keymap = palmtt_keymap,
175};
176
177static struct platform_device palmtt_kp_device = {
178 .name = "omap-keypad",
179 .id = -1,
180 .dev = {
181 .platform_data = &palmtt_kp_data,
182 },
183 .num_resources = ARRAY_SIZE(palmtt_kp_resources),
184 .resource = palmtt_kp_resources,
185};
186
187static struct platform_device palmtt_lcd_device = {
188 .name = "lcd_palmtt",
189 .id = -1,
190};
191static struct omap_irda_config palmtt_irda_config = {
192 .transceiver_cap = IR_SIRMODE,
193 .rx_channel = OMAP_DMA_UART3_RX,
194 .tx_channel = OMAP_DMA_UART3_TX,
195 .dest_start = UART3_THR,
196 .src_start = UART3_RHR,
197 .tx_trigger = 0,
198 .rx_trigger = 0,
199};
200
201static struct resource palmtt_irda_resources[] = {
202 [0] = {
203 .start = INT_UART3,
204 .end = INT_UART3,
205 .flags = IORESOURCE_IRQ,
206 },
207};
208
209static struct platform_device palmtt_irda_device = {
210 .name = "omapirda",
211 .id = -1,
212 .dev = {
213 .platform_data = &palmtt_irda_config,
214 },
215 .num_resources = ARRAY_SIZE(palmtt_irda_resources),
216 .resource = palmtt_irda_resources,
217};
218
219static struct platform_device palmtt_spi_device = {
220 .name = "spi_palmtt",
221 .id = -1,
222};
223
224static struct omap_backlight_config palmtt_backlight_config = {
225 .default_intensity = 0xa0,
226};
227
228static struct platform_device palmtt_backlight_device = {
229 .name = "omap-bl",
230 .id = -1,
231 .dev = {
232 .platform_data= &palmtt_backlight_config,
233 },
234};
235
236static struct omap_led_config palmtt_led_config[] = {
237 {
238 .cdev = {
239 .name = "palmtt:led0",
240 },
241 .gpio = PALMTT_LED_GPIO,
242 },
243};
244
245static struct omap_led_platform_data palmtt_led_data = {
246 .nr_leds = ARRAY_SIZE(palmtt_led_config),
247 .leds = palmtt_led_config,
248};
249
250static struct platform_device palmtt_led_device = {
251 .name = "omap-led",
252 .id = -1,
253 .dev = {
254 .platform_data = &palmtt_led_data,
255 },
256};
257
258static struct platform_device *palmtt_devices[] __initdata = {
259 &palmtt_flash_device,
260 &palmtt_mcbsp1_device,
261 &palmtt_kp_device,
262 &palmtt_lcd_device,
263 &palmtt_irda_device,
264 &palmtt_spi_device,
265 &palmtt_backlight_device,
266 &palmtt_led_device,
267};
268
269static int palmtt_get_pendown_state(void)
270{
271 return !omap_get_gpio_datain(6);
272}
273
274static const struct ads7846_platform_data palmtt_ts_info = {
275 .model = 7846,
276 .vref_delay_usecs = 100, /* internal, no capacitor */
277 .x_plate_ohms = 419,
278 .y_plate_ohms = 486,
279 .get_pendown_state = palmtt_get_pendown_state,
280};
281
282static struct spi_board_info __initdata palmtt_boardinfo[] = {
283 {
284 /* MicroWire (bus 2) CS0 has an ads7846e */
285 .modalias = "ads7846",
286 .platform_data = &palmtt_ts_info,
287 .irq = OMAP_GPIO_IRQ(6),
288 .max_speed_hz = 120000 /* max sample rate at 3V */
289 * 26 /* command + data + overhead */,
290 .bus_num = 2,
291 .chip_select = 0,
292 }
293};
294
295static void __init omap_palmtt_init_irq(void)
296{
297 omap1_init_common_hw();
298 omap_init_irq();
299}
300
301static struct omap_usb_config palmtt_usb_config __initdata = {
302 .register_dev = 1,
303 .hmc_mode = 0,
304 .pins[0] = 2,
305};
306
307static struct omap_lcd_config palmtt_lcd_config __initdata = {
308 .ctrl_name = "internal",
309};
310
311static struct omap_uart_config palmtt_uart_config __initdata = {
312 .enabled_uarts = (1 << 0) | (1 << 1) | (0 << 2),
313};
314
Tony Lindgrene27a93a2007-12-18 20:58:32 -0800315static struct omap_board_config_kernel palmtt_config[] __initdata = {
Tony Lindgrena5246262006-12-07 13:58:17 -0800316 { OMAP_TAG_USB, &palmtt_usb_config },
317 { OMAP_TAG_LCD, &palmtt_lcd_config },
Marek Vasutdc563b42006-12-06 17:14:07 -0800318 { OMAP_TAG_UART, &palmtt_uart_config },
319};
320
321static void __init omap_mpu_wdt_mode(int mode) {
322 if (mode)
323 omap_writew(0x8000, OMAP_WDT_TIMER_MODE);
324 else {
325 omap_writew(0x00f5, OMAP_WDT_TIMER_MODE);
326 omap_writew(0x00a0, OMAP_WDT_TIMER_MODE);
327 }
328}
329
330static void __init omap_palmtt_init(void)
331{
332 omap_mpu_wdt_mode(0);
333
334 omap_board_config = palmtt_config;
335 omap_board_config_size = ARRAY_SIZE(palmtt_config);
336
337 platform_add_devices(palmtt_devices, ARRAY_SIZE(palmtt_devices));
338
339 spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
340 omap_serial_init();
Jarkko Nikula1ed16a82007-11-07 06:54:32 +0200341 omap_register_i2c_bus(1, 100, NULL, 0);
Marek Vasutdc563b42006-12-06 17:14:07 -0800342}
343
344static void __init omap_palmtt_map_io(void)
345{
346 omap1_map_common_io();
347}
348
349MACHINE_START(OMAP_PALMTT, "OMAP1510 based Palm Tungsten|T")
350 .phys_io = 0xfff00000,
351 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
352 .boot_params = 0x10000100,
353 .map_io = omap_palmtt_map_io,
354 .init_irq = omap_palmtt_init_irq,
355 .init_machine = omap_palmtt_init,
356 .timer = &omap_timer,
357MACHINE_END