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>
48 extern int omap_gpio_init(void);
50 static int h3_keymap[] = {
90 static struct mtd_partition nor_partitions[] = {
91 /* bootloader (U-Boot, etc) in first sector */
96 .mask_flags = MTD_WRITEABLE, /* force read-only */
98 /* bootloader params in the next sector */
101 .offset = MTDPART_OFS_APPEND,
108 .offset = MTDPART_OFS_APPEND,
114 .name = "filesystem",
115 .offset = MTDPART_OFS_APPEND,
116 .size = MTDPART_SIZ_FULL,
121 static struct flash_platform_data nor_data = {
122 .map_name = "cfi_probe",
124 .parts = nor_partitions,
125 .nr_parts = ARRAY_SIZE(nor_partitions),
128 static struct resource nor_resource = {
129 /* This is on CS3, wherever it's mapped */
130 .flags = IORESOURCE_MEM,
133 static struct platform_device nor_device = {
137 .platform_data = &nor_data,
140 .resource = &nor_resource,
143 static struct mtd_partition nand_partitions[] = {
145 /* REVISIT: enable these partitions if you make NAND BOOT work */
150 .mask_flags = MTD_WRITEABLE, /* force read-only */
153 .name = "bootloader",
154 .offset = MTDPART_OFS_APPEND,
156 .mask_flags = MTD_WRITEABLE, /* force read-only */
160 .offset = MTDPART_OFS_APPEND,
165 .offset = MTDPART_OFS_APPEND,
170 .name = "filesystem",
171 .size = MTDPART_SIZ_FULL,
172 .offset = MTDPART_OFS_APPEND,
176 /* dip switches control NAND chip access: 8 bit, 16 bit, or neither */
177 static struct nand_platform_data nand_data = {
178 .options = NAND_SAMSUNG_LP_OPTIONS,
179 .parts = nand_partitions,
180 .nr_parts = ARRAY_SIZE(nand_partitions),
183 static struct resource nand_resource = {
184 .flags = IORESOURCE_MEM,
187 static struct platform_device nand_device = {
191 .platform_data = &nand_data,
194 .resource = &nand_resource,
197 static struct resource smc91x_resources[] = {
199 .start = OMAP1710_ETHR_START, /* Physical */
200 .end = OMAP1710_ETHR_START + 0xf,
201 .flags = IORESOURCE_MEM,
204 .start = OMAP_GPIO_IRQ(40),
205 .end = OMAP_GPIO_IRQ(40),
206 .flags = IORESOURCE_IRQ,
210 static struct platform_device smc91x_device = {
213 .num_resources = ARRAY_SIZE(smc91x_resources),
214 .resource = smc91x_resources,
217 #define GPTIMER_BASE 0xFFFB1400
218 #define GPTIMER_REGS(x) (0xFFFB1400 + (x * 0x800))
219 #define GPTIMER_REGS_SIZE 0x46
221 static struct resource intlat_resources[] = {
223 .start = GPTIMER_REGS(0), /* Physical */
224 .end = GPTIMER_REGS(0) + GPTIMER_REGS_SIZE,
225 .flags = IORESOURCE_MEM,
228 .start = INT_1610_GPTIMER1,
229 .end = INT_1610_GPTIMER1,
230 .flags = IORESOURCE_IRQ,
234 static struct platform_device intlat_device = {
235 .name = "omap_intlat",
237 .num_resources = ARRAY_SIZE(intlat_resources),
238 .resource = intlat_resources,
241 static struct resource h3_kp_resources[] = {
243 .start = INT_KEYBOARD,
245 .flags = IORESOURCE_IRQ,
249 static struct omap_kp_platform_data h3_kp_data = {
253 .keymapsize = ARRAY_SIZE(h3_keymap),
259 static struct platform_device h3_kp_device = {
260 .name = "omap-keypad",
263 .platform_data = &h3_kp_data,
265 .num_resources = ARRAY_SIZE(h3_kp_resources),
266 .resource = h3_kp_resources,
270 /* Select between the IrDA and aGPS module
272 static int h3_select_irda(struct device *dev, int state)
277 if ((err = read_gpio_expa(&expa, 0x26))) {
278 printk(KERN_ERR "Error reading from I/O EXPANDER \n");
282 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
283 if (state & IR_SEL) { /* IrDA */
284 if ((err = write_gpio_expa(expa | 0x40, 0x26))) {
285 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
289 if ((err = write_gpio_expa(expa & ~0x40, 0x26))) {
290 printk(KERN_ERR "Error writing to I/O EXPANDER \n");
297 static void set_trans_mode(void *data)
303 if ((err = read_gpio_expa(&expa, 0x27)) != 0) {
304 printk(KERN_ERR "Error reading from I/O expander\n");
309 if (*mode & IR_SIRMODE) {
311 } else { /* MIR/FIR */
315 if ((err = write_gpio_expa(expa, 0x27)) != 0) {
316 printk(KERN_ERR "Error writing to I/O expander\n");
320 static int h3_transceiver_mode(struct device *dev, int mode)
322 struct omap_irda_config *irda_config = dev->platform_data;
324 cancel_delayed_work(&irda_config->gpio_expa);
325 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
326 schedule_work(&irda_config->gpio_expa);
331 static struct omap_irda_config h3_irda_data = {
332 .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
333 .transceiver_mode = h3_transceiver_mode,
334 .select_irda = h3_select_irda,
335 .rx_channel = OMAP_DMA_UART3_RX,
336 .tx_channel = OMAP_DMA_UART3_TX,
337 .dest_start = UART3_THR,
338 .src_start = UART3_RHR,
343 static struct resource h3_irda_resources[] = {
347 .flags = IORESOURCE_IRQ,
351 static struct platform_device h3_irda_device = {
355 .platform_data = &h3_irda_data,
357 .num_resources = ARRAY_SIZE(h3_irda_resources),
358 .resource = h3_irda_resources,
361 static struct platform_device h3_lcd_device = {
366 static struct platform_device *devices[] __initdata = {
376 static struct omap_usb_config h3_usb_config __initdata = {
377 /* usb1 has a Mini-AB port and external isp1301 transceiver */
380 #ifdef CONFIG_USB_GADGET_OMAP
381 .hmc_mode = 19, /* 0:host(off) 1:dev|otg 2:disabled */
382 #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
383 /* NONSTANDARD CABLE NEEDED (B-to-Mini-B) */
384 .hmc_mode = 20, /* 1:dev|otg(off) 1:host 2:disabled */
390 static struct omap_mmc_config h3_mmc_config __initdata = {
393 .power_pin = -1, /* tps65010 GPIO4 */
394 .switch_pin = OMAP_MPUIO(1),
398 static struct omap_uart_config h3_uart_config __initdata = {
399 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
402 static struct omap_lcd_config h3_lcd_config __initdata = {
403 .ctrl_name = "internal",
406 static struct omap_board_config_kernel h3_config[] = {
407 { OMAP_TAG_USB, &h3_usb_config },
408 { OMAP_TAG_MMC, &h3_mmc_config },
409 { OMAP_TAG_UART, &h3_uart_config },
410 { OMAP_TAG_LCD, &h3_lcd_config },
413 #define H3_NAND_RB_GPIO_PIN 10
415 static int nand_dev_ready(struct nand_platform_data *data)
417 return omap_get_gpio_datain(H3_NAND_RB_GPIO_PIN);
420 static void __init h3_init(void)
422 /* Here we assume the NOR boot config: NOR on CS3 (possibly swapped
423 * to address 0 by a dip switch), NAND on CS2B. The NAND driver will
424 * notice whether a NAND chip is enabled at probe time.
426 * H3 support NAND-boot, with a dip switch to put NOR on CS2B and NAND
427 * (which on H2 may be 16bit) on CS3. Try detecting that in code here,
428 * to avoid probing every possible flash configuration...
430 nor_resource.end = nor_resource.start = omap_cs3_phys();
431 nor_resource.end += SZ_32M - 1;
433 nand_resource.end = nand_resource.start = OMAP_CS2B_PHYS;
434 nand_resource.end += SZ_4K - 1;
435 if (!(omap_request_gpio(H3_NAND_RB_GPIO_PIN)))
436 nand_data.dev_ready = nand_dev_ready;
438 /* GPIO10 Func_MUX_CTRL reg bit 29:27, Configure V2 to mode1 as GPIO */
439 /* GPIO10 pullup/down register, Enable pullup on GPIO10 */
440 omap_cfg_reg(V2_1710_GPIO10);
442 platform_add_devices(devices, ARRAY_SIZE(devices));
443 omap_board_config = h3_config;
444 omap_board_config_size = ARRAY_SIZE(h3_config);
448 static void __init h3_init_smc91x(void)
450 omap_cfg_reg(W15_1710_GPIO40);
451 if (omap_request_gpio(40) < 0) {
452 printk("Error requesting gpio 40 for smc91x irq\n");
457 void h3_init_irq(void)
459 omap1_init_common_hw();
465 static void __init h3_map_io(void)
467 omap1_map_common_io();
470 MACHINE_START(OMAP_H3, "TI OMAP1710 H3 board")
471 /* Maintainer: Texas Instruments, Inc. */
472 .phys_io = 0xfff00000,
473 .io_pg_offst = ((0xfef00000) >> 18) & 0xfffc,
474 .boot_params = 0x10000100,
476 .init_irq = h3_init_irq,
477 .init_machine = h3_init,
478 .timer = &omap_timer,