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>
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/flash.h>
32 #include <mach/control.h>
33 #include <mach/gpio.h>
34 #include <mach/gpioexpander.h>
37 #include <mach/irda.h>
38 #include <mach/board.h>
39 #include <mach/common.h>
40 #include <mach/keypad.h>
41 #include <mach/menelaus.h>
43 #include <mach/gpmc.h>
46 #define H4_SMC91X_CS 1
48 static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
49 static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
51 static int h4_keymap[] = {
85 static struct mtd_partition h4_partitions[] = {
86 /* bootloader (U-Boot, etc) in first sector */
91 .mask_flags = MTD_WRITEABLE, /* force read-only */
93 /* bootloader params in the next sector */
96 .offset = MTDPART_OFS_APPEND,
103 .offset = MTDPART_OFS_APPEND,
109 .name = "filesystem",
110 .offset = MTDPART_OFS_APPEND,
111 .size = MTDPART_SIZ_FULL,
116 static struct flash_platform_data h4_flash_data = {
117 .map_name = "cfi_probe",
119 .parts = h4_partitions,
120 .nr_parts = ARRAY_SIZE(h4_partitions),
123 static struct resource h4_flash_resource = {
124 .flags = IORESOURCE_MEM,
127 static struct platform_device h4_flash_device = {
131 .platform_data = &h4_flash_data,
134 .resource = &h4_flash_resource,
137 /* Select between the IrDA and aGPS module
139 static int h4_select_irda(struct device *dev, int state)
144 if ((err = read_gpio_expa(&expa, 0x21))) {
145 printk(KERN_ERR "Error reading from I/O expander\n");
149 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
150 if (state & IR_SEL) { /* IrDa */
151 if ((err = write_gpio_expa(expa | 0x01, 0x21))) {
152 printk(KERN_ERR "Error writing to I/O expander\n");
156 if ((err = write_gpio_expa(expa & ~0x01, 0x21))) {
157 printk(KERN_ERR "Error writing to I/O expander\n");
164 static void set_trans_mode(struct work_struct *work)
166 struct omap_irda_config *irda_config =
167 container_of(work, struct omap_irda_config, gpio_expa.work);
168 int mode = irda_config->mode;
172 if ((err = read_gpio_expa(&expa, 0x20)) != 0) {
173 printk(KERN_ERR "Error reading from I/O expander\n");
178 if (!(mode & IR_SIRMODE)) { /* MIR/FIR */
182 if ((err = write_gpio_expa(expa, 0x20)) != 0) {
183 printk(KERN_ERR "Error writing to I/O expander\n");
187 static int h4_transceiver_mode(struct device *dev, int mode)
189 struct omap_irda_config *irda_config = dev->platform_data;
191 irda_config->mode = mode;
192 cancel_delayed_work(&irda_config->gpio_expa);
193 PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode);
194 schedule_delayed_work(&irda_config->gpio_expa, 0);
199 static struct omap_irda_config h4_irda_data = {
200 .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
201 .transceiver_mode = h4_transceiver_mode,
202 .select_irda = h4_select_irda,
203 .rx_channel = OMAP24XX_DMA_UART3_RX,
204 .tx_channel = OMAP24XX_DMA_UART3_TX,
205 .dest_start = OMAP_UART3_BASE,
206 .src_start = OMAP_UART3_BASE,
207 .tx_trigger = OMAP24XX_DMA_UART3_TX,
208 .rx_trigger = OMAP24XX_DMA_UART3_RX,
211 static struct resource h4_irda_resources[] = {
213 .start = INT_24XX_UART3_IRQ,
214 .end = INT_24XX_UART3_IRQ,
215 .flags = IORESOURCE_IRQ,
219 static struct platform_device h4_irda_device = {
223 .platform_data = &h4_irda_data,
226 .resource = h4_irda_resources,
229 static struct omap_kp_platform_data h4_kp_data = {
233 .keymapsize = ARRAY_SIZE(h4_keymap),
235 .row_gpios = row_gpios,
236 .col_gpios = col_gpios,
239 static struct platform_device h4_kp_device = {
240 .name = "omap-keypad",
243 .platform_data = &h4_kp_data,
247 static struct platform_device h4_lcd_device = {
252 static struct platform_device *h4_devices[] __initdata = {
259 /* 2420 Sysboot setup (2430 is different) */
260 static u32 get_sysboot_value(void)
262 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
263 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
264 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
265 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
268 /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
270 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
271 * correctly. The macro needs to look at production_id not just hawkeye.
273 static u32 is_gpmc_muxed(void)
276 mux = get_sysboot_value();
277 if ((mux & 0xF) == 0xd)
278 return 1; /* NAND config (could be either) */
279 if (mux & 0x2) /* if mux'ed */
285 static inline void __init h4_init_debug(void)
288 unsigned long cs_mem_base;
289 unsigned int muxed, rate;
290 struct clk *gpmc_fck;
292 eth_cs = H4_SMC91X_CS;
294 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
295 if (IS_ERR(gpmc_fck)) {
300 clk_enable(gpmc_fck);
301 rate = clk_get_rate(gpmc_fck);
302 clk_disable(gpmc_fck);
310 /* Make sure CS1 timings are correct */
311 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
314 if (rate >= 160000000) {
315 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
316 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
317 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
318 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
319 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
320 } else if (rate >= 130000000) {
321 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
322 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
323 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
324 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
325 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
326 } else {/* rate = 100000000 */
327 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
328 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
329 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
330 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
331 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
334 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
335 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
341 omap_cfg_reg(M15_24XX_GPIO92);
342 if (debug_card_init(cs_mem_base, OMAP24XX_ETHR_GPIO_IRQ) < 0)
343 gpmc_cs_free(eth_cs);
346 clk_disable(gpmc_fck);
350 static void __init h4_init_flash(void)
354 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
355 printk("Can't request GPMC CS for flash\n");
358 h4_flash_resource.start = base;
359 h4_flash_resource.end = base + SZ_64M - 1;
362 static void __init omap_h4_init_irq(void)
364 omap2_init_common_hw();
370 static struct omap_uart_config h4_uart_config __initdata = {
371 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
374 static struct omap_mmc_config h4_mmc_config __initdata = {
384 static struct omap_lcd_config h4_lcd_config __initdata = {
385 .ctrl_name = "internal",
388 static struct omap_board_config_kernel h4_config[] = {
389 { OMAP_TAG_UART, &h4_uart_config },
390 { OMAP_TAG_MMC, &h4_mmc_config },
391 { OMAP_TAG_LCD, &h4_lcd_config },
394 static void __init omap_h4_init(void)
397 * Make sure the serial ports are muxed on at this point.
398 * You have to mux them off in device drivers later on
401 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
402 omap_cfg_reg(K15_24XX_UART3_TX);
403 omap_cfg_reg(K14_24XX_UART3_RX);
406 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
407 if (omap_has_menelaus()) {
414 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
415 omap_board_config = h4_config;
416 omap_board_config_size = ARRAY_SIZE(h4_config);
420 static void __init omap_h4_map_io(void)
422 omap2_set_globals_242x();
423 omap2_map_common_io();
426 MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
427 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
428 .phys_io = 0x48000000,
429 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
430 .boot_params = 0x80000100,
431 .map_io = omap_h4_map_io,
432 .init_irq = omap_h4_init_irq,
433 .init_machine = omap_h4_init,
434 .timer = &omap_timer,