blob: add2f703204fae66cefbe2e8261bed4b63348f93 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Tony Lindgrendbdf9ced2005-07-10 19:58:11 +01002 * linux/arch/arm/mach-omap1/board-h3.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * This file contains OMAP1710 H3 specific code.
5 *
6 * Copyright (C) 2004 Texas Instruments, Inc.
7 * Copyright (C) 2002 MontaVista Software, Inc.
8 * Copyright (C) 2001 RidgeRun, Inc.
9 * Author: RidgeRun, Inc.
10 * Greg Lonnon (glonnon@ridgerun.com) or info@ridgerun.com
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <linux/types.h>
18#include <linux/init.h>
19#include <linux/major.h>
20#include <linux/kernel.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010021#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/errno.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010023#include <linux/workqueue.h>
David Brownell8056c6c2007-10-13 23:56:30 +020024#include <linux/i2c.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/mtd/mtd.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010026#include <linux/mtd/nand.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/mtd/partitions.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010028#include <linux/input.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30#include <asm/setup.h>
31#include <asm/page.h>
32#include <asm/hardware.h>
David Brownell8056c6c2007-10-13 23:56:30 +020033#include <asm/gpio.h>
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/flash.h>
38#include <asm/mach/map.h>
39
David Brownell8056c6c2007-10-13 23:56:30 +020040#include <asm/arch/tps65010.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010041#include <asm/arch/gpioexpander.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <asm/arch/irqs.h>
43#include <asm/arch/mux.h>
44#include <asm/arch/tc.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010045#include <asm/arch/irda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <asm/arch/usb.h>
Tony Lindgren9b6553c2006-04-02 17:46:30 +010047#include <asm/arch/keypad.h>
48#include <asm/arch/dma.h>
Tony Lindgrend48af152005-07-10 19:58:17 +010049#include <asm/arch/common.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51extern int omap_gpio_init(void);
52
Tony Lindgren9b6553c2006-04-02 17:46:30 +010053static int h3_keymap[] = {
54 KEY(0, 0, KEY_LEFT),
55 KEY(0, 1, KEY_RIGHT),
56 KEY(0, 2, KEY_3),
57 KEY(0, 3, KEY_F10),
58 KEY(0, 4, KEY_F5),
59 KEY(0, 5, KEY_9),
60 KEY(1, 0, KEY_DOWN),
61 KEY(1, 1, KEY_UP),
62 KEY(1, 2, KEY_2),
63 KEY(1, 3, KEY_F9),
64 KEY(1, 4, KEY_F7),
65 KEY(1, 5, KEY_0),
66 KEY(2, 0, KEY_ENTER),
67 KEY(2, 1, KEY_6),
68 KEY(2, 2, KEY_1),
69 KEY(2, 3, KEY_F2),
70 KEY(2, 4, KEY_F6),
71 KEY(2, 5, KEY_HOME),
72 KEY(3, 0, KEY_8),
73 KEY(3, 1, KEY_5),
74 KEY(3, 2, KEY_F12),
75 KEY(3, 3, KEY_F3),
76 KEY(3, 4, KEY_F8),
77 KEY(3, 5, KEY_END),
78 KEY(4, 0, KEY_7),
79 KEY(4, 1, KEY_4),
80 KEY(4, 2, KEY_F11),
81 KEY(4, 3, KEY_F1),
82 KEY(4, 4, KEY_F4),
83 KEY(4, 5, KEY_ESC),
84 KEY(5, 0, KEY_F13),
85 KEY(5, 1, KEY_F14),
86 KEY(5, 2, KEY_F15),
87 KEY(5, 3, KEY_F16),
88 KEY(5, 4, KEY_SLEEP),
89 0
90};
91
92
93static struct mtd_partition nor_partitions[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 /* bootloader (U-Boot, etc) in first sector */
95 {
96 .name = "bootloader",
97 .offset = 0,
98 .size = SZ_128K,
99 .mask_flags = MTD_WRITEABLE, /* force read-only */
100 },
101 /* bootloader params in the next sector */
102 {
103 .name = "params",
104 .offset = MTDPART_OFS_APPEND,
105 .size = SZ_128K,
106 .mask_flags = 0,
107 },
108 /* kernel */
109 {
110 .name = "kernel",
111 .offset = MTDPART_OFS_APPEND,
112 .size = SZ_2M,
113 .mask_flags = 0
114 },
115 /* file system */
116 {
117 .name = "filesystem",
118 .offset = MTDPART_OFS_APPEND,
119 .size = MTDPART_SIZ_FULL,
120 .mask_flags = 0
121 }
122};
123
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100124static struct flash_platform_data nor_data = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 .map_name = "cfi_probe",
126 .width = 2,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100127 .parts = nor_partitions,
128 .nr_parts = ARRAY_SIZE(nor_partitions),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129};
130
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100131static struct resource nor_resource = {
Tony Lindgren7c38cf02005-09-08 23:07:38 +0100132 /* This is on CS3, wherever it's mapped */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 .flags = IORESOURCE_MEM,
134};
135
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100136static struct platform_device nor_device = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 .name = "omapflash",
138 .id = 0,
139 .dev = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100140 .platform_data = &nor_data,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 },
142 .num_resources = 1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100143 .resource = &nor_resource,
144};
145
146static struct mtd_partition nand_partitions[] = {
147#if 0
148 /* REVISIT: enable these partitions if you make NAND BOOT work */
149 {
150 .name = "xloader",
151 .offset = 0,
152 .size = 64 * 1024,
153 .mask_flags = MTD_WRITEABLE, /* force read-only */
154 },
155 {
156 .name = "bootloader",
157 .offset = MTDPART_OFS_APPEND,
158 .size = 256 * 1024,
159 .mask_flags = MTD_WRITEABLE, /* force read-only */
160 },
161 {
162 .name = "params",
163 .offset = MTDPART_OFS_APPEND,
164 .size = 192 * 1024,
165 },
166 {
167 .name = "kernel",
168 .offset = MTDPART_OFS_APPEND,
169 .size = 2 * SZ_1M,
170 },
171#endif
172 {
173 .name = "filesystem",
174 .size = MTDPART_SIZ_FULL,
175 .offset = MTDPART_OFS_APPEND,
176 },
177};
178
179/* dip switches control NAND chip access: 8 bit, 16 bit, or neither */
180static struct nand_platform_data nand_data = {
181 .options = NAND_SAMSUNG_LP_OPTIONS,
182 .parts = nand_partitions,
183 .nr_parts = ARRAY_SIZE(nand_partitions),
184};
185
186static struct resource nand_resource = {
187 .flags = IORESOURCE_MEM,
188};
189
190static struct platform_device nand_device = {
191 .name = "omapnand",
192 .id = 0,
193 .dev = {
194 .platform_data = &nand_data,
195 },
196 .num_resources = 1,
197 .resource = &nand_resource,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198};
199
200static struct resource smc91x_resources[] = {
201 [0] = {
202 .start = OMAP1710_ETHR_START, /* Physical */
203 .end = OMAP1710_ETHR_START + 0xf,
204 .flags = IORESOURCE_MEM,
205 },
206 [1] = {
207 .start = OMAP_GPIO_IRQ(40),
208 .end = OMAP_GPIO_IRQ(40),
209 .flags = IORESOURCE_IRQ,
210 },
211};
212
213static struct platform_device smc91x_device = {
214 .name = "smc91x",
215 .id = 0,
216 .num_resources = ARRAY_SIZE(smc91x_resources),
217 .resource = smc91x_resources,
218};
219
220#define GPTIMER_BASE 0xFFFB1400
221#define GPTIMER_REGS(x) (0xFFFB1400 + (x * 0x800))
222#define GPTIMER_REGS_SIZE 0x46
223
224static struct resource intlat_resources[] = {
225 [0] = {
226 .start = GPTIMER_REGS(0), /* Physical */
227 .end = GPTIMER_REGS(0) + GPTIMER_REGS_SIZE,
228 .flags = IORESOURCE_MEM,
229 },
230 [1] = {
231 .start = INT_1610_GPTIMER1,
232 .end = INT_1610_GPTIMER1,
233 .flags = IORESOURCE_IRQ,
234 },
235};
236
237static struct platform_device intlat_device = {
238 .name = "omap_intlat",
239 .id = 0,
240 .num_resources = ARRAY_SIZE(intlat_resources),
241 .resource = intlat_resources,
242};
243
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100244static struct resource h3_kp_resources[] = {
245 [0] = {
246 .start = INT_KEYBOARD,
247 .end = INT_KEYBOARD,
248 .flags = IORESOURCE_IRQ,
249 },
250};
251
252static struct omap_kp_platform_data h3_kp_data = {
Komal Shah4d246072006-09-29 01:59:20 -0700253 .rows = 8,
254 .cols = 8,
255 .keymap = h3_keymap,
256 .keymapsize = ARRAY_SIZE(h3_keymap),
257 .rep = 1,
258 .delay = 9,
259 .dbounce = 1,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100260};
261
262static struct platform_device h3_kp_device = {
263 .name = "omap-keypad",
264 .id = -1,
265 .dev = {
266 .platform_data = &h3_kp_data,
267 },
268 .num_resources = ARRAY_SIZE(h3_kp_resources),
269 .resource = h3_kp_resources,
270};
271
272
273/* Select between the IrDA and aGPS module
274 */
275static int h3_select_irda(struct device *dev, int state)
276{
277 unsigned char expa;
278 int err = 0;
279
280 if ((err = read_gpio_expa(&expa, 0x26))) {
281 printk(KERN_ERR "Error reading from I/O EXPANDER \n");
282 return err;
283 }
284
285 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
286 if (state & IR_SEL) { /* IrDA */
287 if ((err = write_gpio_expa(expa | 0x40, 0x26))) {
288 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
289 return err;
290 }
291 } else {
292 if ((err = write_gpio_expa(expa & ~0x40, 0x26))) {
293 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
294 return err;
295 }
296 }
297 return err;
298}
299
Dirk Behme666cd172007-01-25 16:26:46 -0800300static void set_trans_mode(struct work_struct *work)
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100301{
Dirk Behme666cd172007-01-25 16:26:46 -0800302 struct omap_irda_config *irda_config =
303 container_of(work, struct omap_irda_config, gpio_expa.work);
304 int mode = irda_config->mode;
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100305 unsigned char expa;
306 int err = 0;
307
308 if ((err = read_gpio_expa(&expa, 0x27)) != 0) {
309 printk(KERN_ERR "Error reading from I/O expander\n");
310 }
311
312 expa &= ~0x03;
313
Dirk Behme666cd172007-01-25 16:26:46 -0800314 if (mode & IR_SIRMODE) {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100315 expa |= 0x01;
316 } else { /* MIR/FIR */
317 expa |= 0x03;
318 }
319
320 if ((err = write_gpio_expa(expa, 0x27)) != 0) {
321 printk(KERN_ERR "Error writing to I/O expander\n");
322 }
323}
324
325static int h3_transceiver_mode(struct device *dev, int mode)
326{
327 struct omap_irda_config *irda_config = dev->platform_data;
328
Dirk Behme666cd172007-01-25 16:26:46 -0800329 irda_config->mode = mode;
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100330 cancel_delayed_work(&irda_config->gpio_expa);
Dirk Behme666cd172007-01-25 16:26:46 -0800331 PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode);
David Howells6d5aefb2006-12-05 19:36:26 +0000332 schedule_delayed_work(&irda_config->gpio_expa, 0);
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100333
334 return 0;
335}
336
337static struct omap_irda_config h3_irda_data = {
338 .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
339 .transceiver_mode = h3_transceiver_mode,
340 .select_irda = h3_select_irda,
341 .rx_channel = OMAP_DMA_UART3_RX,
342 .tx_channel = OMAP_DMA_UART3_TX,
343 .dest_start = UART3_THR,
344 .src_start = UART3_RHR,
345 .tx_trigger = 0,
346 .rx_trigger = 0,
347};
348
349static struct resource h3_irda_resources[] = {
350 [0] = {
351 .start = INT_UART3,
352 .end = INT_UART3,
353 .flags = IORESOURCE_IRQ,
354 },
355};
356
357static struct platform_device h3_irda_device = {
358 .name = "omapirda",
359 .id = 0,
360 .dev = {
361 .platform_data = &h3_irda_data,
362 },
363 .num_resources = ARRAY_SIZE(h3_irda_resources),
364 .resource = h3_irda_resources,
365};
366
367static struct platform_device h3_lcd_device = {
368 .name = "lcd_h3",
369 .id = -1,
370};
371
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372static struct platform_device *devices[] __initdata = {
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100373 &nor_device,
374 &nand_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 &smc91x_device,
376 &intlat_device,
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100377 &h3_irda_device,
378 &h3_kp_device,
379 &h3_lcd_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380};
381
382static struct omap_usb_config h3_usb_config __initdata = {
383 /* usb1 has a Mini-AB port and external isp1301 transceiver */
384 .otg = 2,
385
386#ifdef CONFIG_USB_GADGET_OMAP
387 .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
388#elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
389 /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
390 .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
391#endif
392
393 .pins[1] = 3,
394};
395
Tony Lindgren7c38cf02005-09-08 23:07:38 +0100396static struct omap_mmc_config h3_mmc_config __initdata = {
397 .mmc[0] = {
398 .enabled = 1,
399 .power_pin = -1, /* tps65010 GPIO4 */
400 .switch_pin = OMAP_MPUIO(1),
401 },
402};
403
Tony Lindgren3179a012005-11-10 14:26:48 +0000404static struct omap_uart_config h3_uart_config __initdata = {
405 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
406};
407
408static struct omap_lcd_config h3_lcd_config __initdata = {
Tony Lindgren3179a012005-11-10 14:26:48 +0000409 .ctrl_name = "internal",
410};
411
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412static struct omap_board_config_kernel h3_config[] = {
Tony Lindgren3179a012005-11-10 14:26:48 +0000413 { OMAP_TAG_USB, &h3_usb_config },
414 { OMAP_TAG_MMC, &h3_mmc_config },
415 { OMAP_TAG_UART, &h3_uart_config },
416 { OMAP_TAG_LCD, &h3_lcd_config },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417};
418
David Brownell8056c6c2007-10-13 23:56:30 +0200419static struct i2c_board_info __initdata h3_i2c_board_info[] = {
420 {
421 I2C_BOARD_INFO("tps65010", 0x48),
422 .type = "tps65013",
423 /* .irq = OMAP_GPIO_IRQ(??), */
424 },
425 /* TODO when driver support is ready:
426 * - isp1301 OTG transceiver
427 * - optional ov9640 camera sensor at 0x30
428 * - ...
429 */
430};
431
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100432#define H3_NAND_RB_GPIO_PIN 10
433
434static int nand_dev_ready(struct nand_platform_data *data)
435{
436 return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
437}
438
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439static void __init h3_init(void)
440{
Tony Lindgren9b6553c2006-04-02 17:46:30 +0100441 /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
442 * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
443 * notice whether a NAND chip is enabled at probe time.
444 *
445 * H3 support NAND-boot, with a dip switch to put NOR on CS2B and NAND
446 * (which on H2 may be 16bit) on CS3. Try detecting that in code here,
447 * to avoid probing every possible flash configuration...
448 */
449 nor_resource.end = nor_resource.start = omap_cs3_phys();
450 nor_resource.end += SZ_32M - 1;
451
452 nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
453 nand_resource.end += SZ_4K - 1;
454 if (!(omap_request_gpio(H3_NAND_RB_GPIO_PIN)))
455 nand_data.dev_ready = nand_dev_ready;
456
457 /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
458 /* GPIO10 pullup/down register, Enable pullup on GPIO10 */
459 omap_cfg_reg(V2_1710_GPIO10);
460
461 platform_add_devices(devices, ARRAY_SIZE(devices));
Tony Lindgren7c38cf02005-09-08 23:07:38 +0100462 omap_board_config = h3_config;
463 omap_board_config_size = ARRAY_SIZE(h3_config);
Tony Lindgren3179a012005-11-10 14:26:48 +0000464 omap_serial_init();
David Brownell8056c6c2007-10-13 23:56:30 +0200465
466 /* FIXME setup irq for tps65013 chip */
467 i2c_register_board_info(1, h3_i2c_board_info,
468 ARRAY_SIZE(h3_i2c_board_info));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469}
470
471static void __init h3_init_smc91x(void)
472{
473 omap_cfg_reg(W15_1710_GPIO40);
474 if (omap_request_gpio(40) < 0) {
475 printk("Error requesting gpio 40 for smc91x irq\n");
476 return;
477 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478}
479
David Brownell277d58e2006-12-06 17:13:59 -0800480static void __init h3_init_irq(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481{
Tony Lindgren87bd63f2006-02-08 22:06:46 +0000482 omap1_init_common_hw();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 omap_init_irq();
484 omap_gpio_init();
485 h3_init_smc91x();
486}
487
488static void __init h3_map_io(void)
489{
Tony Lindgren87bd63f2006-02-08 22:06:46 +0000490 omap1_map_common_io();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491}
492
David Brownell8056c6c2007-10-13 23:56:30 +0200493#ifdef CONFIG_TPS65010
494static int __init h3_tps_init(void)
495{
496 if (!machine_is_omap_h3())
497 return 0;
498
499 /* gpio4 for SD, gpio3 for VDD_DSP */
500 /* FIXME send power to DSP iff it's configured */
501
502 /* Enable LOW_PWR */
503 tps65013_set_low_pwr(ON);
504
505 return 0;
506}
507fs_initcall(h3_tps_init);
508#endif
509
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100511 /* Maintainer: Texas Instruments, Inc. */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100512 .phys_io = 0xfff00000,
513 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
514 .boot_params = 0x10000100,
515 .map_io = h3_map_io,
516 .init_irq = h3_init_irq,
517 .init_machine = h3_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 .timer = &omap_timer,
519MACHINE_END