Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / arm / mach-omap1 / board-h3.c
blob20f95a973878f2bc793f799acd5fb55f60f96284
1 /*
2 * linux/arch/arm/mach-omap1/board-h3.c
4 * This file contains OMAP1710 H3 specific code.
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
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.
17 #include <linux/types.h>
18 #include <linux/init.h>
19 #include <linux/major.h>
20 #include <linux/kernel.h>
21 #include <linux/platform_device.h>
22 #include <linux/errno.h>
23 #include <linux/workqueue.h>
24 #include <linux/i2c.h>
25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/nand.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/input.h>
29 <<<<<<< HEAD:arch/arm/mach-omap1/board-h3.c
30 =======
31 #include <linux/spi/spi.h>
32 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-omap1/board-h3.c
33 #include <linux/i2c/tps65010.h>
35 #include <asm/setup.h>
36 #include <asm/page.h>
37 #include <asm/hardware.h>
38 #include <asm/gpio.h>
40 #include <asm/mach-types.h>
41 #include <asm/mach/arch.h>
42 #include <asm/mach/flash.h>
43 #include <asm/mach/map.h>
45 #include <asm/arch/gpioexpander.h>
46 #include <asm/arch/irqs.h>
47 #include <asm/arch/mux.h>
48 #include <asm/arch/tc.h>
49 #include <asm/arch/nand.h>
50 #include <asm/arch/irda.h>
51 #include <asm/arch/usb.h>
52 #include <asm/arch/keypad.h>
53 #include <asm/arch/dma.h>
54 #include <asm/arch/common.h>
55 #include <asm/arch/mcbsp.h>
56 #include <asm/arch/omap-alsa.h>
58 <<<<<<< HEAD:arch/arm/mach-omap1/board-h3.c
59 =======
60 #define H3_TS_GPIO 48
62 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-omap1/board-h3.c
63 static int h3_keymap[] = {
64 KEY(0, 0, KEY_LEFT),
65 KEY(0, 1, KEY_RIGHT),
66 KEY(0, 2, KEY_3),
67 KEY(0, 3, KEY_F10),
68 KEY(0, 4, KEY_F5),
69 KEY(0, 5, KEY_9),
70 KEY(1, 0, KEY_DOWN),
71 KEY(1, 1, KEY_UP),
72 KEY(1, 2, KEY_2),
73 KEY(1, 3, KEY_F9),
74 KEY(1, 4, KEY_F7),
75 KEY(1, 5, KEY_0),
76 KEY(2, 0, KEY_ENTER),
77 KEY(2, 1, KEY_6),
78 KEY(2, 2, KEY_1),
79 KEY(2, 3, KEY_F2),
80 KEY(2, 4, KEY_F6),
81 KEY(2, 5, KEY_HOME),
82 KEY(3, 0, KEY_8),
83 KEY(3, 1, KEY_5),
84 KEY(3, 2, KEY_F12),
85 KEY(3, 3, KEY_F3),
86 KEY(3, 4, KEY_F8),
87 KEY(3, 5, KEY_END),
88 KEY(4, 0, KEY_7),
89 KEY(4, 1, KEY_4),
90 KEY(4, 2, KEY_F11),
91 KEY(4, 3, KEY_F1),
92 KEY(4, 4, KEY_F4),
93 KEY(4, 5, KEY_ESC),
94 KEY(5, 0, KEY_F13),
95 KEY(5, 1, KEY_F14),
96 KEY(5, 2, KEY_F15),
97 KEY(5, 3, KEY_F16),
98 KEY(5, 4, KEY_SLEEP),
103 static struct mtd_partition nor_partitions[] = {
104 /* bootloader (U-Boot, etc) in first sector */
106 .name = "bootloader",
107 .offset = 0,
108 .size = SZ_128K,
109 .mask_flags = MTD_WRITEABLE, /* force read-only */
111 /* bootloader params in the next sector */
113 .name = "params",
114 .offset = MTDPART_OFS_APPEND,
115 .size = SZ_128K,
116 .mask_flags = 0,
118 /* kernel */
120 .name = "kernel",
121 .offset = MTDPART_OFS_APPEND,
122 .size = SZ_2M,
123 .mask_flags = 0
125 /* file system */
127 .name = "filesystem",
128 .offset = MTDPART_OFS_APPEND,
129 .size = MTDPART_SIZ_FULL,
130 .mask_flags = 0
134 static struct flash_platform_data nor_data = {
135 .map_name = "cfi_probe",
136 .width = 2,
137 .parts = nor_partitions,
138 .nr_parts = ARRAY_SIZE(nor_partitions),
141 static struct resource nor_resource = {
142 /* This is on CS3, wherever it's mapped */
143 .flags = IORESOURCE_MEM,
146 static struct platform_device nor_device = {
147 .name = "omapflash",
148 .id = 0,
149 .dev = {
150 .platform_data = &nor_data,
152 .num_resources = 1,
153 .resource = &nor_resource,
156 static struct mtd_partition nand_partitions[] = {
157 #if 0
158 /* REVISIT: enable these partitions if you make NAND BOOT work */
160 .name = "xloader",
161 .offset = 0,
162 .size = 64 * 1024,
163 .mask_flags = MTD_WRITEABLE, /* force read-only */
166 .name = "bootloader",
167 .offset = MTDPART_OFS_APPEND,
168 .size = 256 * 1024,
169 .mask_flags = MTD_WRITEABLE, /* force read-only */
172 .name = "params",
173 .offset = MTDPART_OFS_APPEND,
174 .size = 192 * 1024,
177 .name = "kernel",
178 .offset = MTDPART_OFS_APPEND,
179 .size = 2 * SZ_1M,
181 #endif
183 .name = "filesystem",
184 .size = MTDPART_SIZ_FULL,
185 .offset = MTDPART_OFS_APPEND,
189 /* dip switches control NAND chip access: 8 bit, 16 bit, or neither */
190 static struct omap_nand_platform_data nand_data = {
191 .options = NAND_SAMSUNG_LP_OPTIONS,
192 .parts = nand_partitions,
193 .nr_parts = ARRAY_SIZE(nand_partitions),
196 static struct resource nand_resource = {
197 .flags = IORESOURCE_MEM,
200 static struct platform_device nand_device = {
201 .name = "omapnand",
202 .id = 0,
203 .dev = {
204 .platform_data = &nand_data,
206 .num_resources = 1,
207 .resource = &nand_resource,
210 static struct resource smc91x_resources[] = {
211 [0] = {
212 .start = OMAP1710_ETHR_START, /* Physical */
213 .end = OMAP1710_ETHR_START + 0xf,
214 .flags = IORESOURCE_MEM,
216 [1] = {
217 .start = OMAP_GPIO_IRQ(40),
218 .end = OMAP_GPIO_IRQ(40),
219 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
223 static struct platform_device smc91x_device = {
224 .name = "smc91x",
225 .id = 0,
226 .num_resources = ARRAY_SIZE(smc91x_resources),
227 .resource = smc91x_resources,
230 #define GPTIMER_BASE 0xFFFB1400
231 #define GPTIMER_REGS(x) (0xFFFB1400 + (x * 0x800))
232 #define GPTIMER_REGS_SIZE 0x46
234 static struct resource intlat_resources[] = {
235 [0] = {
236 .start = GPTIMER_REGS(0), /* Physical */
237 .end = GPTIMER_REGS(0) + GPTIMER_REGS_SIZE,
238 .flags = IORESOURCE_MEM,
240 [1] = {
241 .start = INT_1610_GPTIMER1,
242 .end = INT_1610_GPTIMER1,
243 .flags = IORESOURCE_IRQ,
247 static struct platform_device intlat_device = {
248 .name = "omap_intlat",
249 .id = 0,
250 .num_resources = ARRAY_SIZE(intlat_resources),
251 .resource = intlat_resources,
254 static struct resource h3_kp_resources[] = {
255 [0] = {
256 .start = INT_KEYBOARD,
257 .end = INT_KEYBOARD,
258 .flags = IORESOURCE_IRQ,
262 static struct omap_kp_platform_data h3_kp_data = {
263 .rows = 8,
264 .cols = 8,
265 .keymap = h3_keymap,
266 .keymapsize = ARRAY_SIZE(h3_keymap),
267 .rep = 1,
268 .delay = 9,
269 .dbounce = 1,
272 static struct platform_device h3_kp_device = {
273 .name = "omap-keypad",
274 .id = -1,
275 .dev = {
276 .platform_data = &h3_kp_data,
278 .num_resources = ARRAY_SIZE(h3_kp_resources),
279 .resource = h3_kp_resources,
283 /* Select between the IrDA and aGPS module
285 static int h3_select_irda(struct device *dev, int state)
287 unsigned char expa;
288 int err = 0;
290 if ((err = read_gpio_expa(&expa, 0x26))) {
291 printk(KERN_ERR "Error reading from I/O EXPANDER \n");
292 return err;
295 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
296 if (state & IR_SEL) { /* IrDA */
297 if ((err = write_gpio_expa(expa | 0x40, 0x26))) {
298 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
299 return err;
301 } else {
302 if ((err = write_gpio_expa(expa & ~0x40, 0x26))) {
303 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
304 return err;
307 return err;
310 static void set_trans_mode(struct work_struct *work)
312 struct omap_irda_config *irda_config =
313 container_of(work, struct omap_irda_config, gpio_expa.work);
314 int mode = irda_config->mode;
315 unsigned char expa;
316 int err = 0;
318 if ((err = read_gpio_expa(&expa, 0x27)) != 0) {
319 printk(KERN_ERR "Error reading from I/O expander\n");
322 expa &= ~0x03;
324 if (mode & IR_SIRMODE) {
325 expa |= 0x01;
326 } else { /* MIR/FIR */
327 expa |= 0x03;
330 if ((err = write_gpio_expa(expa, 0x27)) != 0) {
331 printk(KERN_ERR "Error writing to I/O expander\n");
335 static int h3_transceiver_mode(struct device *dev, int mode)
337 struct omap_irda_config *irda_config = dev->platform_data;
339 irda_config->mode = mode;
340 cancel_delayed_work(&irda_config->gpio_expa);
341 PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode);
342 schedule_delayed_work(&irda_config->gpio_expa, 0);
344 return 0;
347 static struct omap_irda_config h3_irda_data = {
348 .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
349 .transceiver_mode = h3_transceiver_mode,
350 .select_irda = h3_select_irda,
351 .rx_channel = OMAP_DMA_UART3_RX,
352 .tx_channel = OMAP_DMA_UART3_TX,
353 .dest_start = UART3_THR,
354 .src_start = UART3_RHR,
355 .tx_trigger = 0,
356 .rx_trigger = 0,
359 static struct resource h3_irda_resources[] = {
360 [0] = {
361 .start = INT_UART3,
362 .end = INT_UART3,
363 .flags = IORESOURCE_IRQ,
367 static u64 irda_dmamask = 0xffffffff;
369 static struct platform_device h3_irda_device = {
370 .name = "omapirda",
371 .id = 0,
372 .dev = {
373 .platform_data = &h3_irda_data,
374 .dma_mask = &irda_dmamask,
376 .num_resources = ARRAY_SIZE(h3_irda_resources),
377 .resource = h3_irda_resources,
380 static struct platform_device h3_lcd_device = {
381 .name = "lcd_h3",
382 .id = -1,
385 <<<<<<< HEAD:arch/arm/mach-omap1/board-h3.c
386 =======
387 static struct spi_board_info h3_spi_board_info[] __initdata = {
388 [0] = {
389 .modalias = "tsc2101",
390 .bus_num = 2,
391 .chip_select = 0,
392 .irq = OMAP_GPIO_IRQ(H3_TS_GPIO),
393 .max_speed_hz = 16000000,
394 /* .platform_data = &tsc_platform_data, */
398 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-omap1/board-h3.c
399 static struct omap_mcbsp_reg_cfg mcbsp_regs = {
400 .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
401 .spcr1 = RINTM(3) | RRST,
402 .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
403 RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(1),
404 .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
405 .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
406 XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(1) | XFIG,
407 .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
408 .srgr1 = FWID(15),
409 .srgr2 = GSYNC | CLKSP | FSGM | FPER(31),
411 .pcr0 = CLKRM | SCLKME | FSXP | FSRP | CLKXP | CLKRP,
412 /*.pcr0 = CLKXP | CLKRP,*/ /* mcbsp: slave */
415 static struct omap_alsa_codec_config alsa_config = {
416 .name = "H3 TSC2101",
417 .mcbsp_regs_alsa = &mcbsp_regs,
418 .codec_configure_dev = NULL, /* tsc2101_configure, */
419 .codec_set_samplerate = NULL, /* tsc2101_set_samplerate, */
420 .codec_clock_setup = NULL, /* tsc2101_clock_setup, */
421 .codec_clock_on = NULL, /* tsc2101_clock_on, */
422 .codec_clock_off = NULL, /* tsc2101_clock_off, */
423 .get_default_samplerate = NULL, /* tsc2101_get_default_samplerate, */
426 static struct platform_device h3_mcbsp1_device = {
427 .name = "omap_alsa_mcbsp",
428 .id = 1,
429 .dev = {
430 .platform_data = &alsa_config,
434 static struct platform_device *devices[] __initdata = {
435 &nor_device,
436 &nand_device,
437 &smc91x_device,
438 &intlat_device,
439 &h3_irda_device,
440 &h3_kp_device,
441 &h3_lcd_device,
442 &h3_mcbsp1_device,
445 static struct omap_usb_config h3_usb_config __initdata = {
446 /* usb1 has a Mini-AB port and external isp1301 transceiver */
447 .otg = 2,
449 #ifdef CONFIG_USB_GADGET_OMAP
450 .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
451 #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
452 /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
453 .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
454 #endif
456 .pins[1] = 3,
459 static struct omap_mmc_config h3_mmc_config __initdata = {
460 .mmc[0] = {
461 .enabled = 1,
462 .wire4 = 1,
466 extern struct omap_mmc_platform_data h3_mmc_data;
468 static struct omap_uart_config h3_uart_config __initdata = {
469 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
472 static struct omap_lcd_config h3_lcd_config __initdata = {
473 .ctrl_name = "internal",
476 static struct omap_board_config_kernel h3_config[] __initdata = {
477 { OMAP_TAG_USB, &h3_usb_config },
478 { OMAP_TAG_MMC, &h3_mmc_config },
479 { OMAP_TAG_UART, &h3_uart_config },
480 { OMAP_TAG_LCD, &h3_lcd_config },
483 <<<<<<< HEAD:arch/arm/mach-omap1/board-h3.c
484 =======
485 static struct i2c_board_info __initdata h3_i2c_board_info[] = {
487 I2C_BOARD_INFO("tps65010", 0x48),
488 .type = "tps65013",
489 /* .irq = OMAP_GPIO_IRQ(??), */
493 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/arm/mach-omap1/board-h3.c
494 static struct omap_gpio_switch h3_gpio_switches[] __initdata = {
496 .name = "mmc_slot",
497 .gpio = OMAP_MPUIO(1),
498 .type = OMAP_GPIO_SWITCH_TYPE_COVER,
499 .debounce_rising = 100,
500 .debounce_falling = 0,
501 .notify = h3_mmc_slot_cover_handler,
502 .notify_data = NULL,
506 #define H3_NAND_RB_GPIO_PIN 10
508 static int nand_dev_ready(struct omap_nand_platform_data *data)
510 return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
513 static void __init h3_init(void)
515 /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
516 * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
517 * notice whether a NAND chip is enabled at probe time.
519 * H3 support NAND-boot, with a dip switch to put NOR on CS2B and NAND
520 * (which on H2 may be 16bit) on CS3. Try detecting that in code here,
521 * to avoid probing every possible flash configuration...
523 nor_resource.end = nor_resource.start = omap_cs3_phys();
524 nor_resource.end += SZ_32M - 1;
526 nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
527 nand_resource.end += SZ_4K - 1;
528 if (!(omap_request_gpio(H3_NAND_RB_GPIO_PIN)))
529 nand_data.dev_ready = nand_dev_ready;
531 /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
532 /* GPIO10 pullup/down register, Enable pullup on GPIO10 */
533 omap_cfg_reg(V2_1710_GPIO10);
535 platform_add_devices(devices, ARRAY_SIZE(devices));
536 spi_register_board_info(h3_spi_board_info,
537 ARRAY_SIZE(h3_spi_board_info));
538 omap_board_config = h3_config;
539 omap_board_config_size = ARRAY_SIZE(h3_config);
540 omap_serial_init();
541 omap_register_i2c_bus(1, 100, h3_i2c_board_info,
542 ARRAY_SIZE(h3_i2c_board_info));
543 h3_mmc_init();
546 static void __init h3_init_smc91x(void)
548 omap_cfg_reg(W15_1710_GPIO40);
549 if (omap_request_gpio(40) < 0) {
550 printk("Error requesting gpio 40 for smc91x irq\n");
551 return;
555 static void __init h3_init_irq(void)
557 omap1_init_common_hw();
558 omap_init_irq();
559 omap_gpio_init();
560 h3_init_smc91x();
563 static void __init h3_map_io(void)
565 omap1_map_common_io();
568 MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
569 /* Maintainer: Texas Instruments, Inc. */
570 .phys_io = 0xfff00000,
571 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
572 .boot_params = 0x10000100,
573 .map_io = h3_map_io,
574 .init_irq = h3_init_irq,
575 .init_machine = h3_init,
576 .timer = &omap_timer,
577 MACHINE_END