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/mtd/mtd.h>
25 #include <linux/mtd/nand.h>
26 #include <linux/mtd/partitions.h>
27 #include <linux/input.h>
29 #include <asm/setup.h>
31 #include <asm/hardware.h>
32 #include <asm/mach-types.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/flash.h>
35 #include <asm/mach/map.h>
37 #include <asm/arch/gpio.h>
38 #include <asm/arch/gpioexpander.h>
39 #include <asm/arch/irqs.h>
40 #include <asm/arch/mux.h>
41 #include <asm/arch/tc.h>
42 #include <asm/arch/irda.h>
43 #include <asm/arch/usb.h>
44 #include <asm/arch/keypad.h>
45 #include <asm/arch/dma.h>
46 #include <asm/arch/common.h>
47 #include <asm/arch/mcbsp.h>
48 #include <asm/arch/omap-alsa.h>
50 extern int omap_gpio_init(void);
52 static int h3_keymap[] = {
92 static struct mtd_partition nor_partitions[] = {
93 /* bootloader (U-Boot, etc) in first sector */
98 .mask_flags = MTD_WRITEABLE, /* force read-only */
100 /* bootloader params in the next sector */
103 .offset = MTDPART_OFS_APPEND,
110 .offset = MTDPART_OFS_APPEND,
116 .name = "filesystem",
117 .offset = MTDPART_OFS_APPEND,
118 .size = MTDPART_SIZ_FULL,
123 static struct flash_platform_data nor_data = {
124 .map_name = "cfi_probe",
126 .parts = nor_partitions,
127 .nr_parts = ARRAY_SIZE(nor_partitions),
130 static struct resource nor_resource = {
131 /* This is on CS3, wherever it's mapped */
132 .flags = IORESOURCE_MEM,
135 static struct platform_device nor_device = {
139 .platform_data = &nor_data,
142 .resource = &nor_resource,
145 static struct mtd_partition nand_partitions[] = {
147 /* REVISIT: enable these partitions if you make NAND BOOT work */
152 .mask_flags = MTD_WRITEABLE, /* force read-only */
155 .name = "bootloader",
156 .offset = MTDPART_OFS_APPEND,
158 .mask_flags = MTD_WRITEABLE, /* force read-only */
162 .offset = MTDPART_OFS_APPEND,
167 .offset = MTDPART_OFS_APPEND,
172 .name = "filesystem",
173 .size = MTDPART_SIZ_FULL,
174 .offset = MTDPART_OFS_APPEND,
178 /* dip switches control NAND chip access: 8 bit, 16 bit, or neither */
179 static struct nand_platform_data nand_data = {
180 .options = NAND_SAMSUNG_LP_OPTIONS,
181 .parts = nand_partitions,
182 .nr_parts = ARRAY_SIZE(nand_partitions),
185 static struct resource nand_resource = {
186 .flags = IORESOURCE_MEM,
189 static struct platform_device nand_device = {
193 .platform_data = &nand_data,
196 .resource = &nand_resource,
199 static struct resource smc91x_resources[] = {
201 .start = OMAP1710_ETHR_START, /* Physical */
202 .end = OMAP1710_ETHR_START + 0xf,
203 .flags = IORESOURCE_MEM,
206 .start = OMAP_GPIO_IRQ(40),
207 .end = OMAP_GPIO_IRQ(40),
208 .flags = IORESOURCE_IRQ,
212 static struct platform_device smc91x_device = {
215 .num_resources = ARRAY_SIZE(smc91x_resources),
216 .resource = smc91x_resources,
219 #define GPTIMER_BASE 0xFFFB1400
220 #define GPTIMER_REGS(x) (0xFFFB1400 + (x * 0x800))
221 #define GPTIMER_REGS_SIZE 0x46
223 static struct resource intlat_resources[] = {
225 .start = GPTIMER_REGS(0), /* Physical */
226 .end = GPTIMER_REGS(0) + GPTIMER_REGS_SIZE,
227 .flags = IORESOURCE_MEM,
230 .start = INT_1610_GPTIMER1,
231 .end = INT_1610_GPTIMER1,
232 .flags = IORESOURCE_IRQ,
236 static struct platform_device intlat_device = {
237 .name = "omap_intlat",
239 .num_resources = ARRAY_SIZE(intlat_resources),
240 .resource = intlat_resources,
243 static struct resource h3_kp_resources[] = {
245 .start = INT_KEYBOARD,
247 .flags = IORESOURCE_IRQ,
251 static struct omap_kp_platform_data h3_kp_data = {
255 .keymapsize = ARRAY_SIZE(h3_keymap),
261 static struct platform_device h3_kp_device = {
262 .name = "omap-keypad",
265 .platform_data = &h3_kp_data,
267 .num_resources = ARRAY_SIZE(h3_kp_resources),
268 .resource = h3_kp_resources,
272 /* Select between the IrDA and aGPS module
274 static int h3_select_irda(struct device *dev, int state)
279 if ((err = read_gpio_expa(&expa, 0x26))) {
280 printk(KERN_ERR "Error reading from I/O EXPANDER \n");
284 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
285 if (state & IR_SEL) { /* IrDA */
286 if ((err = write_gpio_expa(expa | 0x40, 0x26))) {
287 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
291 if ((err = write_gpio_expa(expa & ~0x40, 0x26))) {
292 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
299 static void set_trans_mode(void *data)
305 if ((err = read_gpio_expa(&expa, 0x27)) != 0) {
306 printk(KERN_ERR "Error reading from I/O expander\n");
311 if (*mode & IR_SIRMODE) {
313 } else { /* MIR/FIR */
317 if ((err = write_gpio_expa(expa, 0x27)) != 0) {
318 printk(KERN_ERR "Error writing to I/O expander\n");
322 static int h3_transceiver_mode(struct device *dev, int mode)
324 struct omap_irda_config *irda_config = dev->platform_data;
326 cancel_delayed_work(&irda_config->gpio_expa);
327 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
328 schedule_work(&irda_config->gpio_expa);
333 static struct omap_irda_config h3_irda_data = {
334 .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
335 .transceiver_mode = h3_transceiver_mode,
336 .select_irda = h3_select_irda,
337 .rx_channel = OMAP_DMA_UART3_RX,
338 .tx_channel = OMAP_DMA_UART3_TX,
339 .dest_start = UART3_THR,
340 .src_start = UART3_RHR,
345 static struct resource h3_irda_resources[] = {
349 .flags = IORESOURCE_IRQ,
353 static u64 irda_dmamask = 0xffffffff;
355 static struct platform_device h3_irda_device = {
359 .platform_data = &h3_irda_data,
360 .dma_mask = &irda_dmamask,
362 .num_resources = ARRAY_SIZE(h3_irda_resources),
363 .resource = h3_irda_resources,
366 static struct platform_device h3_lcd_device = {
371 static struct omap_mcbsp_reg_cfg mcbsp_regs = {
372 .spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
373 .spcr1 = RINTM(3) | RRST,
374 .rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
375 RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(1),
376 .rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
377 .xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
378 XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(1) | XFIG,
379 .xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
381 .srgr2 = GSYNC | CLKSP | FSGM | FPER(31),
383 .pcr0 = CLKRM | SCLKME | FSXP | FSRP | CLKXP | CLKRP,
384 //.pcr0 = CLKXP | CLKRP, /* mcbsp: slave */
387 static struct omap_alsa_codec_config alsa_config = {
388 .name = "H3 TSC2101",
389 .mcbsp_regs_alsa = &mcbsp_regs,
390 .codec_configure_dev = NULL, // tsc2101_configure,
391 .codec_set_samplerate = NULL, // tsc2101_set_samplerate,
392 .codec_clock_setup = NULL, // tsc2101_clock_setup,
393 .codec_clock_on = NULL, // tsc2101_clock_on,
394 .codec_clock_off = NULL, // tsc2101_clock_off,
395 .get_default_samplerate = NULL, // tsc2101_get_default_samplerate,
398 static struct platform_device h3_mcbsp1_device = {
399 .name = "omap_alsa_mcbsp",
402 .platform_data = &alsa_config,
406 static struct platform_device *devices[] __initdata = {
417 static struct omap_usb_config h3_usb_config __initdata = {
418 /* usb1 has a Mini-AB port and external isp1301 transceiver */
421 #ifdef CONFIG_USB_GADGET_OMAP
422 .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
423 #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
424 /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
425 .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
431 static struct omap_mmc_config h3_mmc_config __initdata = {
434 .power_pin = -1, /* tps65010 GPIO4 */
435 .switch_pin = OMAP_MPUIO(1),
439 static struct omap_uart_config h3_uart_config __initdata = {
440 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
443 static struct omap_lcd_config h3_lcd_config __initdata = {
444 .ctrl_name = "internal",
447 static struct omap_board_config_kernel h3_config[] = {
448 { OMAP_TAG_USB, &h3_usb_config },
449 { OMAP_TAG_MMC, &h3_mmc_config },
450 { OMAP_TAG_UART, &h3_uart_config },
451 { OMAP_TAG_LCD, &h3_lcd_config },
454 #define H3_NAND_RB_GPIO_PIN 10
456 static int nand_dev_ready(struct nand_platform_data *data)
458 return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
461 static void __init h3_init(void)
463 /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
464 * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
465 * notice whether a NAND chip is enabled at probe time.
467 * H3 support NAND-boot, with a dip switch to put NOR on CS2B and NAND
468 * (which on H2 may be 16bit) on CS3. Try detecting that in code here,
469 * to avoid probing every possible flash configuration...
471 nor_resource.end = nor_resource.start = omap_cs3_phys();
472 nor_resource.end += SZ_32M - 1;
474 nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
475 nand_resource.end += SZ_4K - 1;
476 if (!(omap_request_gpio(H3_NAND_RB_GPIO_PIN)))
477 nand_data.dev_ready = nand_dev_ready;
479 /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
480 /* GPIO10 pullup/down register, Enable pullup on GPIO10 */
481 omap_cfg_reg(V2_1710_GPIO10);
483 platform_add_devices(devices, ARRAY_SIZE(devices));
484 omap_board_config = h3_config;
485 omap_board_config_size = ARRAY_SIZE(h3_config);
489 static void __init h3_init_smc91x(void)
491 omap_cfg_reg(W15_1710_GPIO40);
492 if (omap_request_gpio(40) < 0) {
493 printk("Error requesting gpio 40 for smc91x irq\n");
498 void h3_init_irq(void)
500 omap1_init_common_hw();
506 static void __init h3_map_io(void)
508 omap1_map_common_io();
511 MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
512 /* Maintainer: Texas Instruments, Inc. */
513 .phys_io = 0xfff00000,
514 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
515 .boot_params = 0x10000100,
517 .init_irq = h3_init_irq,
518 .init_machine = h3_init,
519 .timer = &omap_timer,