2 * linux/arch/arm/mach-omap2/board-h4.c
4 * Copyright (C) 2005 Nokia Corporation
5 * Author: Paul Mundt <paul.mundt@nokia.com>
7 * Modified from mach-omap/omap1/board-generic.c
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/platform_device.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/delay.h>
20 #include <linux/workqueue.h>
21 #include <linux/input.h>
22 #include <linux/err.h>
23 #include <linux/clk.h>
25 #include <asm/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/flash.h>
31 #include <asm/arch/gpio.h>
32 #include <asm/arch/gpioexpander.h>
33 #include <asm/arch/mux.h>
34 #include <asm/arch/usb.h>
35 #include <asm/arch/irda.h>
36 #include <asm/arch/board.h>
37 #include <asm/arch/common.h>
38 #include <asm/arch/keypad.h>
39 #include <asm/arch/menelaus.h>
40 #include <asm/arch/dma.h>
41 #include <asm/arch/gpmc.h>
42 #include "prcm-regs.h"
45 #include <asm/delay.h>
48 #define H4_SMC91X_CS 1
50 static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
51 static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
53 static int h4_keymap[] = {
87 static struct mtd_partition h4_partitions[] = {
88 /* bootloader (U-Boot, etc) in first sector */
93 .mask_flags = MTD_WRITEABLE, /* force read-only */
95 /* bootloader params in the next sector */
98 .offset = MTDPART_OFS_APPEND,
105 .offset = MTDPART_OFS_APPEND,
111 .name = "filesystem",
112 .offset = MTDPART_OFS_APPEND,
113 .size = MTDPART_SIZ_FULL,
118 static struct flash_platform_data h4_flash_data = {
119 .map_name = "cfi_probe",
121 .parts = h4_partitions,
122 .nr_parts = ARRAY_SIZE(h4_partitions),
125 static struct resource h4_flash_resource = {
126 .flags = IORESOURCE_MEM,
129 static struct platform_device h4_flash_device = {
133 .platform_data = &h4_flash_data,
136 .resource = &h4_flash_resource,
139 /* Select between the IrDA and aGPS module
141 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
142 static int h4_select_irda(struct device *dev, int state)
147 if ((err = read_gpio_expa(&expa, 0x21))) {
148 printk(KERN_ERR "Error reading from I/O expander\n");
152 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
153 if (state & IR_SEL) { /* IrDa */
154 if ((err = write_gpio_expa(expa | 0x01, 0x21))) {
155 printk(KERN_ERR "Error writing to I/O expander\n");
159 if ((err = write_gpio_expa(expa & ~0x01, 0x21))) {
160 printk(KERN_ERR "Error writing to I/O expander\n");
167 static void set_trans_mode(void *data)
173 if ((err = read_gpio_expa(&expa, 0x20)) != 0) {
174 printk(KERN_ERR "Error reading from I/O expander\n");
179 if (!(*mode & IR_SIRMODE)) { /* MIR/FIR */
183 if ((err = write_gpio_expa(expa, 0x20)) != 0) {
184 printk(KERN_ERR "Error writing to I/O expander\n");
188 static int h4_transceiver_mode(struct device *dev, int mode)
190 struct omap_irda_config *irda_config = dev->platform_data;
192 cancel_delayed_work(&irda_config->gpio_expa);
193 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
194 #error this is not permitted - mode is an argument variable
195 schedule_delayed_work(&irda_config->gpio_expa, 0);
200 static int h4_select_irda(struct device *dev, int state) { return 0; }
201 static int h4_transceiver_mode(struct device *dev, int mode) { return 0; }
204 static struct omap_irda_config h4_irda_data = {
205 .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
206 .transceiver_mode = h4_transceiver_mode,
207 .select_irda = h4_select_irda,
208 .rx_channel = OMAP24XX_DMA_UART3_RX,
209 .tx_channel = OMAP24XX_DMA_UART3_TX,
210 .dest_start = OMAP_UART3_BASE,
211 .src_start = OMAP_UART3_BASE,
212 .tx_trigger = OMAP24XX_DMA_UART3_TX,
213 .rx_trigger = OMAP24XX_DMA_UART3_RX,
216 static struct resource h4_irda_resources[] = {
218 .start = INT_24XX_UART3_IRQ,
219 .end = INT_24XX_UART3_IRQ,
220 .flags = IORESOURCE_IRQ,
224 static struct platform_device h4_irda_device = {
228 .platform_data = &h4_irda_data,
231 .resource = h4_irda_resources,
234 static struct omap_kp_platform_data h4_kp_data = {
238 .keymapsize = ARRAY_SIZE(h4_keymap),
240 .row_gpios = row_gpios,
241 .col_gpios = col_gpios,
244 static struct platform_device h4_kp_device = {
245 .name = "omap-keypad",
248 .platform_data = &h4_kp_data,
252 static struct platform_device h4_lcd_device = {
257 static struct platform_device *h4_devices[] __initdata = {
264 /* 2420 Sysboot setup (2430 is different) */
265 static u32 get_sysboot_value(void)
267 return (omap_readl(OMAP242X_CONTROL_STATUS) & 0xFFF);
270 /* FIXME: This function should be moved to some other file, gpmc.c? */
272 /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
274 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
275 * correctly. The macro needs to look at production_id not just hawkeye.
277 static u32 is_gpmc_muxed(void)
280 mux = get_sysboot_value();
281 if ((mux & 0xF) == 0xd)
282 return 1; /* NAND config (could be either) */
283 if (mux & 0x2) /* if mux'ed */
289 static inline void __init h4_init_debug(void)
292 unsigned long cs_mem_base;
293 unsigned int muxed, rate;
296 eth_cs = H4_SMC91X_CS;
298 l3ck = clk_get(NULL, "core_l3_ck");
302 rate = clk_get_rate(l3ck);
309 /* Make sure CS1 timings are correct */
310 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
313 if (rate >= 160000000) {
314 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
315 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
316 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
317 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
318 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
319 } else if (rate >= 130000000) {
320 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
321 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
322 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
323 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
324 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
325 } else {/* rate = 100000000 */
326 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
327 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
328 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
329 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
330 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
333 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
334 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
340 omap_cfg_reg(M15_24XX_GPIO92);
341 if (debug_card_init(cs_mem_base, OMAP24XX_ETHR_GPIO_IRQ) < 0)
342 gpmc_cs_free(eth_cs);
345 static void __init h4_init_flash(void)
349 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
350 printk("Can't request GPMC CS for flash\n");
353 h4_flash_resource.start = base;
354 h4_flash_resource.end = base + SZ_64M - 1;
357 static void __init omap_h4_init_irq(void)
359 omap2_init_common_hw();
365 static struct omap_uart_config h4_uart_config __initdata = {
366 #ifdef CONFIG_MACH_OMAP2_H4_USB1
367 .enabled_uarts = ((1 << 0) | (1 << 1)),
369 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
373 static struct omap_mmc_config h4_mmc_config __initdata = {
383 static struct omap_lcd_config h4_lcd_config __initdata = {
384 .ctrl_name = "internal",
387 static struct omap_usb_config h4_usb_config __initdata = {
388 #ifdef CONFIG_MACH_OMAP2_H4_USB1
389 /* NOTE: usb1 could also be used with 3 wire signaling */
393 #ifdef CONFIG_MACH_OMAP_H4_OTG
394 /* S1.10 ON -- USB OTG port
395 * usb0 switched to Mini-AB port and isp1301 transceiver;
396 * S2.POS3 = OFF, S2.POS4 = ON ... to allow battery charging
400 #ifdef CONFIG_USB_GADGET_OMAP
401 /* use OTG cable, or standard A-to-MiniB */
402 .hmc_mode = 0x14, /* 0:dev/otg 1:host 2:disable */
403 #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
404 /* use OTG cable, or NONSTANDARD (B-to-MiniB) */
405 .hmc_mode = 0x11, /* 0:host 1:host 2:disable */
409 /* S1.10 OFF -- usb "download port"
410 * usb0 switched to Mini-B port and isp1105 transceiver;
411 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
415 // .hmc_mode = 0x14, /* 0:dev 1:host 2:disable */
416 .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */
420 static struct omap_board_config_kernel h4_config[] = {
421 { OMAP_TAG_UART, &h4_uart_config },
422 { OMAP_TAG_MMC, &h4_mmc_config },
423 { OMAP_TAG_LCD, &h4_lcd_config },
424 { OMAP_TAG_USB, &h4_usb_config },
427 #ifdef CONFIG_MACH_OMAP_H4_TUSB
429 #include <linux/usb/musb.h>
431 static struct musb_hdrc_platform_data tusb_data = {
433 .min_power = 25, /* x2 = 50 mA drawn from VBUS as peripheral */
435 /* 1.8V supplied by Menelaus, other voltages supplied by VBAT;
440 static void __init tusb_evm_setup(void)
442 static char announce[] __initdata =
443 KERN_INFO "TUSB 6010 EVM\n";
445 unsigned dmachan = 0;
447 /* There are at least 32 different combinations of boards that
448 * are loosely called "H4", with a 2420 ... different OMAP chip
449 * revisions (with pin mux changes for DMAREQ, GPMC errata, etc),
450 * modifications of the CPU board, mainboard, EVM, TUSB etc.
451 * Plus omap2422, omap2423, etc.
453 * So you might need to tweak this setup to make the TUSB EVM
454 * behave on your particular setup ...
457 /* Already set up: GPMC AD[0..15], CLK, nOE, nWE, nADV_ALE */
458 omap_cfg_reg(E2_GPMC_NCS2);
459 omap_cfg_reg(L2_GPMC_NCS7);
460 omap_cfg_reg(M1_GPMC_WAIT2);
462 switch ((system_rev >> 8) & 0x0f) {
465 /* Assume early board revision without optional ES2.0
466 * rework to swap J15 & AA10 so DMAREQ0 works
468 omap_cfg_reg(AA10_242X_GPIO13);
470 // omap_cfg_reg(J15_24XX_DMAREQ0);
473 /* Later Menelaus boards can support all 6 DMA request
474 * lines, at the price of boot flash A23-A26.
476 omap_cfg_reg(J15_24XX_GPIO99);
478 dmachan = (1 << 1) | (1 << 0);
479 #if !(defined(CONFIG_MTD_OMAP_NOR) || defined(CONFIG_MTD_OMAP_NOR_MODULE))
480 dmachan |= (1 << 5) | (1 << 4) (1 << 3) | (1 << 2);
485 if (tusb6010_setup_interface(&tusb_data,
486 TUSB6010_REFCLK_24, /* waitpin */ 2,
487 /* async cs */ 2, /* sync cs */ 7,
494 static void __init omap_h4_init(void)
497 * Make sure the serial ports are muxed on at this point.
498 * You have to mux them off in device drivers later on
501 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
502 omap_cfg_reg(K15_24XX_UART3_TX);
503 omap_cfg_reg(K14_24XX_UART3_RX);
506 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
507 if (omap_has_menelaus()) {
514 #ifdef CONFIG_MACH_OMAP2_H4_USB1
515 /* S3.3 controls whether these pins are for UART2 or USB1 */
516 omap_cfg_reg(N14_24XX_USB1_SE0);
517 omap_cfg_reg(P15_24XX_USB1_DAT);
518 omap_cfg_reg(W20_24XX_USB1_TXEN);
519 omap_cfg_reg(V19_24XX_USB1_RCV);
522 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
523 omap_board_config = h4_config;
524 omap_board_config_size = ARRAY_SIZE(h4_config);
527 /* smc91x, debug leds, ps/2, extra uarts */
530 #ifdef CONFIG_MACH_OMAP_H4_TUSB
536 static void __init omap_h4_map_io(void)
538 omap2_map_common_io();
541 MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
542 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
543 .phys_io = 0x48000000,
544 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
545 .boot_params = 0x80000100,
546 .map_io = omap_h4_map_io,
547 .init_irq = omap_h4_init_irq,
548 .init_machine = omap_h4_init,
549 .timer = &omap_timer,