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 #include <linux/spi/spi.h>
30 #include <linux/i2c/tps65010.h>
32 #include <asm/setup.h>
34 #include <mach/hardware.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/flash.h>
40 #include <asm/mach/map.h>
42 #include <mach/gpioexpander.h>
43 #include <mach/irqs.h>
46 #include <mach/nand.h>
47 #include <mach/irda.h>
49 #include <mach/keypad.h>
51 #include <mach/common.h>
52 #include <mach/mcbsp.h>
53 #include <mach/omap-alsa.h>
57 static int h3_keymap[] = {
97 static struct mtd_partition nor_partitions[] = {
98 /* bootloader (U-Boot, etc) in first sector */
100 .name = "bootloader",
103 .mask_flags = MTD_WRITEABLE, /* force read-only */
105 /* bootloader params in the next sector */
108 .offset = MTDPART_OFS_APPEND,
115 .offset = MTDPART_OFS_APPEND,
121 .name = "filesystem",
122 .offset = MTDPART_OFS_APPEND,
123 .size = MTDPART_SIZ_FULL,
128 static struct flash_platform_data nor_data = {
129 .map_name = "cfi_probe",
131 .parts = nor_partitions,
132 .nr_parts = ARRAY_SIZE(nor_partitions),
135 static struct resource nor_resource = {
136 /* This is on CS3, wherever it's mapped */
137 .flags = IORESOURCE_MEM,
140 static struct platform_device nor_device = {
144 .platform_data = &nor_data,
147 .resource = &nor_resource,
150 static struct mtd_partition nand_partitions[] = {
152 /* REVISIT: enable these partitions if you make NAND BOOT work */
157 .mask_flags = MTD_WRITEABLE, /* force read-only */
160 .name = "bootloader",
161 .offset = MTDPART_OFS_APPEND,
163 .mask_flags = MTD_WRITEABLE, /* force read-only */
167 .offset = MTDPART_OFS_APPEND,
172 .offset = MTDPART_OFS_APPEND,
177 .name = "filesystem",
178 .size = MTDPART_SIZ_FULL,
179 .offset = MTDPART_OFS_APPEND,
183 /* dip switches control NAND chip access: 8 bit, 16 bit, or neither */
184 static struct omap_nand_platform_data nand_data = {
185 .options = NAND_SAMSUNG_LP_OPTIONS,
186 .parts = nand_partitions,
187 .nr_parts = ARRAY_SIZE(nand_partitions),
190 static struct resource nand_resource = {
191 .flags = IORESOURCE_MEM,
194 static struct platform_device nand_device = {
198 .platform_data = &nand_data,
201 .resource = &nand_resource,
204 static struct resource smc91x_resources[] = {
206 .start = OMAP1710_ETHR_START, /* Physical */
207 .end = OMAP1710_ETHR_START + 0xf,
208 .flags = IORESOURCE_MEM,
211 .start = OMAP_GPIO_IRQ(40),
212 .end = OMAP_GPIO_IRQ(40),
213 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
217 static struct platform_device smc91x_device = {
220 .num_resources = ARRAY_SIZE(smc91x_resources),
221 .resource = smc91x_resources,
224 #define GPTIMER_BASE 0xFFFB1400
225 #define GPTIMER_REGS(x) (0xFFFB1400 + (x * 0x800))
226 #define GPTIMER_REGS_SIZE 0x46
228 static struct resource intlat_resources[] = {
230 .start = GPTIMER_REGS(0), /* Physical */
231 .end = GPTIMER_REGS(0) + GPTIMER_REGS_SIZE,
232 .flags = IORESOURCE_MEM,
235 .start = INT_1610_GPTIMER1,
236 .end = INT_1610_GPTIMER1,
237 .flags = IORESOURCE_IRQ,
241 static struct platform_device intlat_device = {
242 .name = "omap_intlat",
244 .num_resources = ARRAY_SIZE(intlat_resources),
245 .resource = intlat_resources,
248 static struct resource h3_kp_resources[] = {
250 .start = INT_KEYBOARD,
252 .flags = IORESOURCE_IRQ,
256 static struct omap_kp_platform_data h3_kp_data = {
260 .keymapsize = ARRAY_SIZE(h3_keymap),
266 static struct platform_device h3_kp_device = {
267 .name = "omap-keypad",
270 .platform_data = &h3_kp_data,
272 .num_resources = ARRAY_SIZE(h3_kp_resources),
273 .resource = h3_kp_resources,
277 /* Select between the IrDA and aGPS module
279 static int h3_select_irda(struct device *dev, int state)
284 if ((err = read_gpio_expa(&expa, 0x26))) {
285 printk(KERN_ERR "Error reading from I/O EXPANDER \n");
289 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
290 if (state & IR_SEL) { /* IrDA */
291 if ((err = write_gpio_expa(expa | 0x40, 0x26))) {
292 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
296 if ((err = write_gpio_expa(expa & ~0x40, 0x26))) {
297 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
304 static void set_trans_mode(struct work_struct *work)
306 struct omap_irda_config *irda_config =
307 container_of(work, struct omap_irda_config, gpio_expa.work);
308 int mode = irda_config->mode;
312 if ((err = read_gpio_expa(&expa, 0x27)) != 0) {
313 printk(KERN_ERR "Error reading from I/O expander\n");
318 if (mode & IR_SIRMODE) {
320 } else { /* MIR/FIR */
324 if ((err = write_gpio_expa(expa, 0x27)) != 0) {
325 printk(KERN_ERR "Error writing to I/O expander\n");
329 static int h3_transceiver_mode(struct device *dev, int mode)
331 struct omap_irda_config *irda_config = dev->platform_data;
333 irda_config->mode = mode;
334 cancel_delayed_work(&irda_config->gpio_expa);
335 PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode);
336 schedule_delayed_work(&irda_config->gpio_expa, 0);
341 static struct omap_irda_config h3_irda_data = {
342 .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
343 .transceiver_mode = h3_transceiver_mode,
344 .select_irda = h3_select_irda,
345 .rx_channel = OMAP_DMA_UART3_RX,
346 .tx_channel = OMAP_DMA_UART3_TX,
347 .dest_start = UART3_THR,
348 .src_start = UART3_RHR,
353 static struct resource h3_irda_resources[] = {
357 .flags = IORESOURCE_IRQ,
361 static u64 irda_dmamask = 0xffffffff;
363 static struct platform_device h3_irda_device = {
367 .platform_data = &h3_irda_data,
368 .dma_mask = &irda_dmamask,
370 .num_resources = ARRAY_SIZE(h3_irda_resources),
371 .resource = h3_irda_resources,
374 static struct platform_device h3_lcd_device = {
379 static struct spi_board_info h3_spi_board_info[] __initdata = {
381 .modalias = "tsc2101",
384 .irq = OMAP_GPIO_IRQ(H3_TS_GPIO),
385 .max_speed_hz = 16000000,
386 /* .platform_data = &tsc_platform_data, */
390 static struct omap_mcbsp_reg_cfg mcbsp_regs = {
391 .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
392 .spcr1 = RINTM(3) | RRST,
393 .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
394 RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(1),
395 .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
396 .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
397 XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(1) | XFIG,
398 .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
400 .srgr2 = GSYNC | CLKSP | FSGM | FPER(31),
402 .pcr0 = CLKRM | SCLKME | FSXP | FSRP | CLKXP | CLKRP,
403 /*.pcr0 = CLKXP | CLKRP,*/ /* mcbsp: slave */
406 static struct omap_alsa_codec_config alsa_config = {
407 .name = "H3 TSC2101",
408 .mcbsp_regs_alsa = &mcbsp_regs,
409 .codec_configure_dev = NULL, /* tsc2101_configure, */
410 .codec_set_samplerate = NULL, /* tsc2101_set_samplerate, */
411 .codec_clock_setup = NULL, /* tsc2101_clock_setup, */
412 .codec_clock_on = NULL, /* tsc2101_clock_on, */
413 .codec_clock_off = NULL, /* tsc2101_clock_off, */
414 .get_default_samplerate = NULL, /* tsc2101_get_default_samplerate, */
417 static struct platform_device h3_mcbsp1_device = {
418 .name = "omap_alsa_mcbsp",
421 .platform_data = &alsa_config,
425 static struct platform_device *devices[] __initdata = {
436 static struct omap_usb_config h3_usb_config __initdata = {
437 /* usb1 has a Mini-AB port and external isp1301 transceiver */
440 #ifdef CONFIG_USB_GADGET_OMAP
441 .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
442 #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
443 /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
444 .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
450 static struct omap_mmc_config h3_mmc_config __initdata = {
457 extern struct omap_mmc_platform_data h3_mmc_data;
459 static struct omap_uart_config h3_uart_config __initdata = {
460 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
463 static struct omap_lcd_config h3_lcd_config __initdata = {
464 .ctrl_name = "internal",
467 static struct omap_board_config_kernel h3_config[] __initdata = {
468 { OMAP_TAG_USB, &h3_usb_config },
469 { OMAP_TAG_MMC, &h3_mmc_config },
470 { OMAP_TAG_UART, &h3_uart_config },
471 { OMAP_TAG_LCD, &h3_lcd_config },
474 static struct i2c_board_info __initdata h3_i2c_board_info[] = {
476 I2C_BOARD_INFO("tps65013", 0x48),
477 /* .irq = OMAP_GPIO_IRQ(??), */
480 I2C_BOARD_INFO("isp1301_omap", 0x2d),
481 .irq = OMAP_GPIO_IRQ(14),
485 static struct omap_gpio_switch h3_gpio_switches[] __initdata = {
488 .gpio = OMAP_MPUIO(1),
489 .type = OMAP_GPIO_SWITCH_TYPE_COVER,
490 .debounce_rising = 100,
491 .debounce_falling = 0,
492 .notify = h3_mmc_slot_cover_handler,
497 #define H3_NAND_RB_GPIO_PIN 10
499 static int nand_dev_ready(struct omap_nand_platform_data *data)
501 return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
504 static void __init h3_init(void)
506 /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
507 * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
508 * notice whether a NAND chip is enabled at probe time.
510 * H3 support NAND-boot, with a dip switch to put NOR on CS2B and NAND
511 * (which on H2 may be 16bit) on CS3. Try detecting that in code here,
512 * to avoid probing every possible flash configuration...
514 nor_resource.end = nor_resource.start = omap_cs3_phys();
515 nor_resource.end += SZ_32M - 1;
517 nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
518 nand_resource.end += SZ_4K - 1;
519 if (!(omap_request_gpio(H3_NAND_RB_GPIO_PIN)))
520 nand_data.dev_ready = nand_dev_ready;
522 /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
523 /* GPIO10 pullup/down register, Enable pullup on GPIO10 */
524 omap_cfg_reg(V2_1710_GPIO10);
526 platform_add_devices(devices, ARRAY_SIZE(devices));
527 spi_register_board_info(h3_spi_board_info,
528 ARRAY_SIZE(h3_spi_board_info));
529 omap_board_config = h3_config;
530 omap_board_config_size = ARRAY_SIZE(h3_config);
532 omap_register_i2c_bus(1, 100, h3_i2c_board_info,
533 ARRAY_SIZE(h3_i2c_board_info));
537 static void __init h3_init_smc91x(void)
539 omap_cfg_reg(W15_1710_GPIO40);
540 if (omap_request_gpio(40) < 0) {
541 printk("Error requesting gpio 40 for smc91x irq\n");
546 static void __init h3_init_irq(void)
548 omap1_init_common_hw();
554 static void __init h3_map_io(void)
556 omap1_map_common_io();
559 MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
560 /* Maintainer: Texas Instruments, Inc. */
561 .phys_io = 0xfff00000,
562 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
563 .boot_params = 0x10000100,
565 .init_irq = h3_init_irq,
566 .init_machine = h3_init,
567 .timer = &omap_timer,