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