Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 1 | /* |
Uwe Zeisberger | f30c226 | 2006-10-03 23:01:26 +0200 | [diff] [blame] | 2 | * linux/arch/arm/mach-omap2/board-h4.c |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2005 Nokia Corporation |
| 5 | * Author: Paul Mundt <paul.mundt@nokia.com> |
| 6 | * |
| 7 | * Modified from mach-omap/omap1/board-generic.c |
| 8 | * |
| 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. |
| 12 | */ |
| 13 | |
| 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> |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 20 | #include <linux/workqueue.h> |
| 21 | #include <linux/input.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 22 | |
| 23 | #include <asm/hardware.h> |
| 24 | #include <asm/mach-types.h> |
| 25 | #include <asm/mach/arch.h> |
| 26 | #include <asm/mach/map.h> |
| 27 | #include <asm/mach/flash.h> |
| 28 | |
| 29 | #include <asm/arch/gpio.h> |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 30 | #include <asm/arch/gpioexpander.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 31 | #include <asm/arch/mux.h> |
| 32 | #include <asm/arch/usb.h> |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 33 | #include <asm/arch/irda.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 34 | #include <asm/arch/board.h> |
| 35 | #include <asm/arch/common.h> |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 36 | #include <asm/arch/keypad.h> |
| 37 | #include <asm/arch/menelaus.h> |
| 38 | #include <asm/arch/dma.h> |
| 39 | #include "prcm-regs.h" |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 40 | |
| 41 | #include <asm/io.h> |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 42 | |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 43 | static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 }; |
| 44 | static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 }; |
| 45 | |
| 46 | static int h4_keymap[] = { |
| 47 | KEY(0, 0, KEY_LEFT), |
| 48 | KEY(0, 1, KEY_RIGHT), |
| 49 | KEY(0, 2, KEY_A), |
| 50 | KEY(0, 3, KEY_B), |
| 51 | KEY(0, 4, KEY_C), |
| 52 | KEY(1, 0, KEY_DOWN), |
| 53 | KEY(1, 1, KEY_UP), |
| 54 | KEY(1, 2, KEY_E), |
| 55 | KEY(1, 3, KEY_F), |
| 56 | KEY(1, 4, KEY_G), |
| 57 | KEY(2, 0, KEY_ENTER), |
| 58 | KEY(2, 1, KEY_I), |
| 59 | KEY(2, 2, KEY_J), |
| 60 | KEY(2, 3, KEY_K), |
| 61 | KEY(2, 4, KEY_3), |
| 62 | KEY(3, 0, KEY_M), |
| 63 | KEY(3, 1, KEY_N), |
| 64 | KEY(3, 2, KEY_O), |
| 65 | KEY(3, 3, KEY_P), |
| 66 | KEY(3, 4, KEY_Q), |
| 67 | KEY(4, 0, KEY_R), |
| 68 | KEY(4, 1, KEY_4), |
| 69 | KEY(4, 2, KEY_T), |
| 70 | KEY(4, 3, KEY_U), |
| 71 | KEY(4, 4, KEY_ENTER), |
| 72 | KEY(5, 0, KEY_V), |
| 73 | KEY(5, 1, KEY_W), |
| 74 | KEY(5, 2, KEY_L), |
| 75 | KEY(5, 3, KEY_S), |
| 76 | KEY(5, 4, KEY_ENTER), |
| 77 | 0 |
| 78 | }; |
| 79 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 80 | static struct mtd_partition h4_partitions[] = { |
| 81 | /* bootloader (U-Boot, etc) in first sector */ |
| 82 | { |
| 83 | .name = "bootloader", |
| 84 | .offset = 0, |
| 85 | .size = SZ_128K, |
| 86 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 87 | }, |
| 88 | /* bootloader params in the next sector */ |
| 89 | { |
| 90 | .name = "params", |
| 91 | .offset = MTDPART_OFS_APPEND, |
| 92 | .size = SZ_128K, |
| 93 | .mask_flags = 0, |
| 94 | }, |
| 95 | /* kernel */ |
| 96 | { |
| 97 | .name = "kernel", |
| 98 | .offset = MTDPART_OFS_APPEND, |
| 99 | .size = SZ_2M, |
| 100 | .mask_flags = 0 |
| 101 | }, |
| 102 | /* file system */ |
| 103 | { |
| 104 | .name = "filesystem", |
| 105 | .offset = MTDPART_OFS_APPEND, |
| 106 | .size = MTDPART_SIZ_FULL, |
| 107 | .mask_flags = 0 |
| 108 | } |
| 109 | }; |
| 110 | |
| 111 | static struct flash_platform_data h4_flash_data = { |
| 112 | .map_name = "cfi_probe", |
| 113 | .width = 2, |
| 114 | .parts = h4_partitions, |
| 115 | .nr_parts = ARRAY_SIZE(h4_partitions), |
| 116 | }; |
| 117 | |
| 118 | static struct resource h4_flash_resource = { |
| 119 | .start = H4_CS0_BASE, |
| 120 | .end = H4_CS0_BASE + SZ_64M - 1, |
| 121 | .flags = IORESOURCE_MEM, |
| 122 | }; |
| 123 | |
| 124 | static struct platform_device h4_flash_device = { |
| 125 | .name = "omapflash", |
| 126 | .id = 0, |
| 127 | .dev = { |
| 128 | .platform_data = &h4_flash_data, |
| 129 | }, |
| 130 | .num_resources = 1, |
| 131 | .resource = &h4_flash_resource, |
| 132 | }; |
| 133 | |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 134 | /* Select between the IrDA and aGPS module |
| 135 | */ |
| 136 | static int h4_select_irda(struct device *dev, int state) |
| 137 | { |
| 138 | unsigned char expa; |
| 139 | int err = 0; |
| 140 | |
| 141 | if ((err = read_gpio_expa(&expa, 0x21))) { |
| 142 | printk(KERN_ERR "Error reading from I/O expander\n"); |
| 143 | return err; |
| 144 | } |
| 145 | |
| 146 | /* 'P6' enable/disable IRDA_TX and IRDA_RX */ |
| 147 | if (state & IR_SEL) { /* IrDa */ |
| 148 | if ((err = write_gpio_expa(expa | 0x01, 0x21))) { |
| 149 | printk(KERN_ERR "Error writing to I/O expander\n"); |
| 150 | return err; |
| 151 | } |
| 152 | } else { |
| 153 | if ((err = write_gpio_expa(expa & ~0x01, 0x21))) { |
| 154 | printk(KERN_ERR "Error writing to I/O expander\n"); |
| 155 | return err; |
| 156 | } |
| 157 | } |
| 158 | return err; |
| 159 | } |
| 160 | |
Dirk Behme | 060ebf9 | 2007-01-25 16:29:17 -0800 | [diff] [blame] | 161 | static void set_trans_mode(struct work_struct *work) |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 162 | { |
Dirk Behme | 060ebf9 | 2007-01-25 16:29:17 -0800 | [diff] [blame] | 163 | struct omap_irda_config *irda_config = |
| 164 | container_of(work, struct omap_irda_config, gpio_expa.work); |
| 165 | int mode = irda_config->mode; |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 166 | unsigned char expa; |
| 167 | int err = 0; |
| 168 | |
| 169 | if ((err = read_gpio_expa(&expa, 0x20)) != 0) { |
| 170 | printk(KERN_ERR "Error reading from I/O expander\n"); |
| 171 | } |
| 172 | |
| 173 | expa &= ~0x01; |
| 174 | |
Dirk Behme | 060ebf9 | 2007-01-25 16:29:17 -0800 | [diff] [blame] | 175 | if (!(mode & IR_SIRMODE)) { /* MIR/FIR */ |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 176 | expa |= 0x01; |
| 177 | } |
| 178 | |
| 179 | if ((err = write_gpio_expa(expa, 0x20)) != 0) { |
| 180 | printk(KERN_ERR "Error writing to I/O expander\n"); |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | static int h4_transceiver_mode(struct device *dev, int mode) |
| 185 | { |
| 186 | struct omap_irda_config *irda_config = dev->platform_data; |
| 187 | |
Dirk Behme | 060ebf9 | 2007-01-25 16:29:17 -0800 | [diff] [blame] | 188 | irda_config->mode = mode; |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 189 | cancel_delayed_work(&irda_config->gpio_expa); |
Dirk Behme | 060ebf9 | 2007-01-25 16:29:17 -0800 | [diff] [blame] | 190 | PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode); |
David Howells | 6d5aefb | 2006-12-05 19:36:26 +0000 | [diff] [blame] | 191 | schedule_delayed_work(&irda_config->gpio_expa, 0); |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | static struct omap_irda_config h4_irda_data = { |
| 197 | .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE, |
| 198 | .transceiver_mode = h4_transceiver_mode, |
| 199 | .select_irda = h4_select_irda, |
| 200 | .rx_channel = OMAP24XX_DMA_UART3_RX, |
| 201 | .tx_channel = OMAP24XX_DMA_UART3_TX, |
| 202 | .dest_start = OMAP_UART3_BASE, |
| 203 | .src_start = OMAP_UART3_BASE, |
| 204 | .tx_trigger = OMAP24XX_DMA_UART3_TX, |
| 205 | .rx_trigger = OMAP24XX_DMA_UART3_RX, |
| 206 | }; |
| 207 | |
| 208 | static struct resource h4_irda_resources[] = { |
| 209 | [0] = { |
| 210 | .start = INT_24XX_UART3_IRQ, |
| 211 | .end = INT_24XX_UART3_IRQ, |
| 212 | .flags = IORESOURCE_IRQ, |
| 213 | }, |
| 214 | }; |
| 215 | |
| 216 | static struct platform_device h4_irda_device = { |
| 217 | .name = "omapirda", |
| 218 | .id = -1, |
| 219 | .dev = { |
| 220 | .platform_data = &h4_irda_data, |
| 221 | }, |
| 222 | .num_resources = 1, |
| 223 | .resource = h4_irda_resources, |
| 224 | }; |
| 225 | |
| 226 | static struct omap_kp_platform_data h4_kp_data = { |
| 227 | .rows = 6, |
| 228 | .cols = 7, |
| 229 | .keymap = h4_keymap, |
Komal Shah | 4d24607 | 2006-09-29 01:59:20 -0700 | [diff] [blame] | 230 | .keymapsize = ARRAY_SIZE(h4_keymap), |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 231 | .rep = 1, |
| 232 | .row_gpios = row_gpios, |
| 233 | .col_gpios = col_gpios, |
| 234 | }; |
| 235 | |
| 236 | static struct platform_device h4_kp_device = { |
| 237 | .name = "omap-keypad", |
| 238 | .id = -1, |
| 239 | .dev = { |
| 240 | .platform_data = &h4_kp_data, |
| 241 | }, |
| 242 | }; |
| 243 | |
| 244 | static struct platform_device h4_lcd_device = { |
| 245 | .name = "lcd_h4", |
| 246 | .id = -1, |
| 247 | }; |
| 248 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 249 | static struct platform_device *h4_devices[] __initdata = { |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 250 | &h4_flash_device, |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 251 | &h4_irda_device, |
| 252 | &h4_kp_device, |
| 253 | &h4_lcd_device, |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 254 | }; |
| 255 | |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 256 | static inline void __init h4_init_debug(void) |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 257 | { |
| 258 | /* Make sure CS1 timings are correct */ |
| 259 | GPMC_CONFIG1_1 = 0x00011200; |
| 260 | GPMC_CONFIG2_1 = 0x001f1f01; |
| 261 | GPMC_CONFIG3_1 = 0x00080803; |
| 262 | GPMC_CONFIG4_1 = 0x1c091c09; |
| 263 | GPMC_CONFIG5_1 = 0x041f1f1f; |
| 264 | GPMC_CONFIG6_1 = 0x000004c4; |
| 265 | GPMC_CONFIG7_1 = 0x00000f40 | (0x08000000 >> 24); |
| 266 | udelay(100); |
| 267 | |
| 268 | omap_cfg_reg(M15_24XX_GPIO92); |
David Brownell | f604931 | 2006-12-06 17:14:03 -0800 | [diff] [blame] | 269 | if (debug_card_init(cs_mem_base, OMAP24XX_ETHR_GPIO_IRQ) < 0) |
| 270 | gpmc_cs_free(eth_cs); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | static void __init omap_h4_init_irq(void) |
| 274 | { |
Tony Lindgren | 18f49ea | 2006-02-08 22:06:47 +0000 | [diff] [blame] | 275 | omap2_init_common_hw(); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 276 | omap_init_irq(); |
| 277 | omap_gpio_init(); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | static struct omap_uart_config h4_uart_config __initdata = { |
| 281 | .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)), |
| 282 | }; |
| 283 | |
| 284 | static struct omap_mmc_config h4_mmc_config __initdata = { |
| 285 | .mmc [0] = { |
| 286 | .enabled = 1, |
| 287 | .wire4 = 1, |
| 288 | .wp_pin = -1, |
| 289 | .power_pin = -1, |
| 290 | .switch_pin = -1, |
| 291 | }, |
| 292 | }; |
| 293 | |
| 294 | static struct omap_lcd_config h4_lcd_config __initdata = { |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 295 | .ctrl_name = "internal", |
| 296 | }; |
| 297 | |
| 298 | static struct omap_board_config_kernel h4_config[] = { |
| 299 | { OMAP_TAG_UART, &h4_uart_config }, |
| 300 | { OMAP_TAG_MMC, &h4_mmc_config }, |
| 301 | { OMAP_TAG_LCD, &h4_lcd_config }, |
| 302 | }; |
| 303 | |
| 304 | static void __init omap_h4_init(void) |
| 305 | { |
| 306 | /* |
| 307 | * Make sure the serial ports are muxed on at this point. |
| 308 | * You have to mux them off in device drivers later on |
| 309 | * if not needed. |
| 310 | */ |
Tony Lindgren | 9b6553c | 2006-04-02 17:46:30 +0100 | [diff] [blame] | 311 | #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE) |
| 312 | omap_cfg_reg(K15_24XX_UART3_TX); |
| 313 | omap_cfg_reg(K14_24XX_UART3_RX); |
| 314 | #endif |
| 315 | |
| 316 | #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE) |
| 317 | if (omap_has_menelaus()) { |
| 318 | row_gpios[5] = 0; |
| 319 | col_gpios[2] = 15; |
| 320 | col_gpios[6] = 18; |
| 321 | } |
| 322 | #endif |
| 323 | |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 324 | platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices)); |
| 325 | omap_board_config = h4_config; |
| 326 | omap_board_config_size = ARRAY_SIZE(h4_config); |
| 327 | omap_serial_init(); |
| 328 | } |
| 329 | |
| 330 | static void __init omap_h4_map_io(void) |
| 331 | { |
Tony Lindgren | 18f49ea | 2006-02-08 22:06:47 +0000 | [diff] [blame] | 332 | omap2_map_common_io(); |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | MACHINE_START(OMAP_H4, "OMAP2420 H4 board") |
| 336 | /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */ |
Tony Lindgren | 1dbae81 | 2005-11-10 14:26:51 +0000 | [diff] [blame] | 337 | .phys_io = 0x48000000, |
| 338 | .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc, |
| 339 | .boot_params = 0x80000100, |
| 340 | .map_io = omap_h4_map_io, |
| 341 | .init_irq = omap_h4_init_irq, |
| 342 | .init_machine = omap_h4_init, |
| 343 | .timer = &omap_timer, |
| 344 | MACHINE_END |