Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/board-rx51-flash.c |
| 3 | * |
| 4 | * Copyright (C) 2008-2009 Nokia |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/input.h> |
| 15 | #include <linux/spi/spi.h> |
| 16 | #include <linux/i2c.h> |
| 17 | #include <linux/i2c/twl4030.h> |
| 18 | #include <linux/clk.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <linux/regulator/machine.h> |
| 21 | #include <linux/gpio.h> |
| 22 | |
| 23 | #include <mach/mcspi.h> |
| 24 | #include <mach/mux.h> |
| 25 | #include <mach/board.h> |
| 26 | #include <mach/common.h> |
| 27 | #include <mach/dma.h> |
| 28 | #include <mach/gpmc.h> |
| 29 | #include <mach/keypad.h> |
Juha Yrjola | aa62e90 | 2009-05-28 13:23:52 -0700 | [diff] [blame] | 30 | #include <mach/onenand.h> |
Tony Lindgren | 1a48e15 | 2009-05-28 13:23:52 -0700 | [diff] [blame] | 31 | #include <mach/gpmc-smc91x.h> |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 32 | |
| 33 | #include "mmc-twl4030.h" |
| 34 | |
Adrian Hunter | f52eeee | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 35 | #define SYSTEM_REV_B_USES_VAUX3 0x1699 |
| 36 | #define SYSTEM_REV_S_USES_VAUX3 0x8 |
| 37 | |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 38 | static int rx51_keymap[] = { |
| 39 | KEY(0, 0, KEY_Q), |
Amit Kucheria | acf442d | 2009-10-05 21:43:44 -0700 | [diff] [blame^] | 40 | KEY(0, 1, KEY_O), |
| 41 | KEY(0, 2, KEY_P), |
| 42 | KEY(0, 3, KEY_COMMA), |
| 43 | KEY(0, 4, KEY_BACKSPACE), |
| 44 | KEY(0, 6, KEY_A), |
| 45 | KEY(0, 7, KEY_S), |
| 46 | KEY(1, 0, KEY_W), |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 47 | KEY(1, 1, KEY_D), |
Amit Kucheria | acf442d | 2009-10-05 21:43:44 -0700 | [diff] [blame^] | 48 | KEY(1, 2, KEY_F), |
| 49 | KEY(1, 3, KEY_G), |
| 50 | KEY(1, 4, KEY_H), |
| 51 | KEY(1, 5, KEY_J), |
| 52 | KEY(1, 6, KEY_K), |
| 53 | KEY(1, 7, KEY_L), |
| 54 | KEY(2, 0, KEY_E), |
| 55 | KEY(2, 1, KEY_DOT), |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 56 | KEY(2, 2, KEY_UP), |
Amit Kucheria | acf442d | 2009-10-05 21:43:44 -0700 | [diff] [blame^] | 57 | KEY(2, 3, KEY_ENTER), |
| 58 | KEY(2, 5, KEY_Z), |
| 59 | KEY(2, 6, KEY_X), |
| 60 | KEY(2, 7, KEY_C), |
| 61 | KEY(3, 0, KEY_R), |
| 62 | KEY(3, 1, KEY_V), |
| 63 | KEY(3, 2, KEY_B), |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 64 | KEY(3, 3, KEY_N), |
Amit Kucheria | acf442d | 2009-10-05 21:43:44 -0700 | [diff] [blame^] | 65 | KEY(3, 4, KEY_M), |
| 66 | KEY(3, 5, KEY_SPACE), |
| 67 | KEY(3, 6, KEY_SPACE), |
| 68 | KEY(3, 7, KEY_LEFT), |
| 69 | KEY(4, 0, KEY_T), |
| 70 | KEY(4, 1, KEY_DOWN), |
| 71 | KEY(4, 2, KEY_RIGHT), |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 72 | KEY(4, 4, KEY_LEFTCTRL), |
Amit Kucheria | acf442d | 2009-10-05 21:43:44 -0700 | [diff] [blame^] | 73 | KEY(4, 5, KEY_RIGHTALT), |
| 74 | KEY(4, 6, KEY_LEFTSHIFT), |
| 75 | KEY(5, 0, KEY_Y), |
| 76 | KEY(6, 0, KEY_U), |
| 77 | KEY(7, 0, KEY_I), |
| 78 | KEY(7, 1, KEY_F7), |
| 79 | KEY(7, 2, KEY_F8), |
| 80 | KEY(0xff, 2, KEY_F9), |
| 81 | KEY(0xff, 4, KEY_F10), |
| 82 | KEY(0xff, 5, KEY_F11), |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | static struct twl4030_keypad_data rx51_kp_data = { |
| 86 | .rows = 8, |
| 87 | .cols = 8, |
| 88 | .keymap = rx51_keymap, |
| 89 | .keymapsize = ARRAY_SIZE(rx51_keymap), |
| 90 | .rep = 1, |
| 91 | }; |
| 92 | |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 93 | static struct twl4030_madc_platform_data rx51_madc_data = { |
| 94 | .irq_line = 1, |
| 95 | }; |
| 96 | |
| 97 | static struct twl4030_hsmmc_info mmc[] = { |
| 98 | { |
| 99 | .name = "external", |
| 100 | .mmc = 1, |
| 101 | .wires = 4, |
| 102 | .cover_only = true, |
| 103 | .gpio_cd = 160, |
| 104 | .gpio_wp = -EINVAL, |
| 105 | }, |
| 106 | { |
| 107 | .name = "internal", |
| 108 | .mmc = 2, |
| 109 | .wires = 8, |
| 110 | .gpio_cd = -EINVAL, |
| 111 | .gpio_wp = -EINVAL, |
| 112 | }, |
| 113 | {} /* Terminator */ |
| 114 | }; |
| 115 | |
| 116 | static struct regulator_consumer_supply rx51_vmmc1_supply = { |
| 117 | .supply = "vmmc", |
| 118 | }; |
| 119 | |
| 120 | static struct regulator_consumer_supply rx51_vmmc2_supply = { |
| 121 | .supply = "vmmc", |
| 122 | }; |
| 123 | |
| 124 | static struct regulator_consumer_supply rx51_vsim_supply = { |
| 125 | .supply = "vmmc_aux", |
| 126 | }; |
| 127 | |
| 128 | static struct regulator_init_data rx51_vaux1 = { |
| 129 | .constraints = { |
| 130 | .name = "V28", |
| 131 | .min_uV = 2800000, |
| 132 | .max_uV = 2800000, |
| 133 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 134 | | REGULATOR_MODE_STANDBY, |
| 135 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 136 | | REGULATOR_CHANGE_STATUS, |
| 137 | }, |
| 138 | }; |
| 139 | |
| 140 | static struct regulator_init_data rx51_vaux2 = { |
| 141 | .constraints = { |
| 142 | .name = "VCSI", |
| 143 | .min_uV = 1800000, |
| 144 | .max_uV = 1800000, |
| 145 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 146 | | REGULATOR_MODE_STANDBY, |
| 147 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 148 | | REGULATOR_CHANGE_STATUS, |
| 149 | }, |
| 150 | }; |
| 151 | |
| 152 | /* VAUX3 - adds more power to VIO_18 rail */ |
Adrian Hunter | f52eeee | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 153 | static struct regulator_init_data rx51_vaux3_cam = { |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 154 | .constraints = { |
| 155 | .name = "VCAM_DIG_18", |
| 156 | .min_uV = 1800000, |
| 157 | .max_uV = 1800000, |
| 158 | .apply_uV = true, |
| 159 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 160 | | REGULATOR_MODE_STANDBY, |
| 161 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 162 | | REGULATOR_CHANGE_STATUS, |
| 163 | }, |
| 164 | }; |
| 165 | |
Adrian Hunter | f52eeee | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 166 | static struct regulator_init_data rx51_vaux3_mmc = { |
| 167 | .constraints = { |
| 168 | .name = "VMMC2_30", |
| 169 | .min_uV = 2800000, |
| 170 | .max_uV = 3000000, |
| 171 | .apply_uV = true, |
| 172 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 173 | | REGULATOR_MODE_STANDBY, |
| 174 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 175 | | REGULATOR_CHANGE_MODE |
| 176 | | REGULATOR_CHANGE_STATUS, |
| 177 | }, |
| 178 | .num_consumer_supplies = 1, |
| 179 | .consumer_supplies = &rx51_vmmc2_supply, |
| 180 | }; |
| 181 | |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 182 | static struct regulator_init_data rx51_vaux4 = { |
| 183 | .constraints = { |
| 184 | .name = "VCAM_ANA_28", |
| 185 | .min_uV = 2800000, |
| 186 | .max_uV = 2800000, |
| 187 | .apply_uV = true, |
| 188 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 189 | | REGULATOR_MODE_STANDBY, |
| 190 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 191 | | REGULATOR_CHANGE_STATUS, |
| 192 | }, |
| 193 | }; |
| 194 | |
| 195 | static struct regulator_init_data rx51_vmmc1 = { |
| 196 | .constraints = { |
| 197 | .min_uV = 1850000, |
| 198 | .max_uV = 3150000, |
| 199 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 200 | | REGULATOR_MODE_STANDBY, |
| 201 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 202 | | REGULATOR_CHANGE_MODE |
| 203 | | REGULATOR_CHANGE_STATUS, |
| 204 | }, |
| 205 | .num_consumer_supplies = 1, |
| 206 | .consumer_supplies = &rx51_vmmc1_supply, |
| 207 | }; |
| 208 | |
| 209 | static struct regulator_init_data rx51_vmmc2 = { |
| 210 | .constraints = { |
| 211 | .name = "VMMC2_30", |
| 212 | .min_uV = 1850000, |
| 213 | .max_uV = 3150000, |
| 214 | .apply_uV = true, |
| 215 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 216 | | REGULATOR_MODE_STANDBY, |
| 217 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 218 | | REGULATOR_CHANGE_MODE |
| 219 | | REGULATOR_CHANGE_STATUS, |
| 220 | }, |
| 221 | .num_consumer_supplies = 1, |
| 222 | .consumer_supplies = &rx51_vmmc2_supply, |
| 223 | }; |
| 224 | |
| 225 | static struct regulator_init_data rx51_vsim = { |
| 226 | .constraints = { |
| 227 | .name = "VMMC2_IO_18", |
| 228 | .min_uV = 1800000, |
| 229 | .max_uV = 1800000, |
| 230 | .apply_uV = true, |
| 231 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 232 | | REGULATOR_MODE_STANDBY, |
| 233 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 234 | | REGULATOR_CHANGE_STATUS, |
| 235 | }, |
| 236 | .num_consumer_supplies = 1, |
| 237 | .consumer_supplies = &rx51_vsim_supply, |
| 238 | }; |
| 239 | |
| 240 | static struct regulator_init_data rx51_vdac = { |
| 241 | .constraints = { |
| 242 | .min_uV = 1800000, |
| 243 | .max_uV = 1800000, |
| 244 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 245 | | REGULATOR_MODE_STANDBY, |
| 246 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 247 | | REGULATOR_CHANGE_MODE |
| 248 | | REGULATOR_CHANGE_STATUS, |
| 249 | }, |
| 250 | }; |
| 251 | |
| 252 | static int rx51_twlgpio_setup(struct device *dev, unsigned gpio, unsigned n) |
| 253 | { |
| 254 | /* FIXME this gpio setup is just a placeholder for now */ |
| 255 | gpio_request(gpio + 6, "backlight_pwm"); |
| 256 | gpio_direction_output(gpio + 6, 0); |
| 257 | gpio_request(gpio + 7, "speaker_en"); |
| 258 | gpio_direction_output(gpio + 7, 1); |
| 259 | |
| 260 | /* set up MMC adapters, linking their regulators to them */ |
| 261 | twl4030_mmc_init(mmc); |
| 262 | rx51_vmmc1_supply.dev = mmc[0].dev; |
| 263 | rx51_vmmc2_supply.dev = mmc[1].dev; |
| 264 | rx51_vsim_supply.dev = mmc[1].dev; |
| 265 | |
| 266 | return 0; |
| 267 | } |
| 268 | |
| 269 | static struct twl4030_gpio_platform_data rx51_gpio_data = { |
| 270 | .gpio_base = OMAP_MAX_GPIO_LINES, |
| 271 | .irq_base = TWL4030_GPIO_IRQ_BASE, |
| 272 | .irq_end = TWL4030_GPIO_IRQ_END, |
| 273 | .pulldowns = BIT(0) | BIT(1) | BIT(2) | BIT(3) |
| 274 | | BIT(4) | BIT(5) |
| 275 | | BIT(8) | BIT(9) | BIT(10) | BIT(11) |
| 276 | | BIT(12) | BIT(13) | BIT(14) | BIT(15) |
| 277 | | BIT(16) | BIT(17) , |
| 278 | .setup = rx51_twlgpio_setup, |
| 279 | }; |
| 280 | |
Roger Quadros | dfc27b3 | 2009-08-10 14:49:51 +0300 | [diff] [blame] | 281 | static struct twl4030_usb_data rx51_usb_data = { |
| 282 | .usb_mode = T2_USB_MODE_ULPI, |
| 283 | }; |
| 284 | |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 285 | static struct twl4030_platform_data rx51_twldata = { |
| 286 | .irq_base = TWL4030_IRQ_BASE, |
| 287 | .irq_end = TWL4030_IRQ_END, |
| 288 | |
| 289 | /* platform_data for children goes here */ |
| 290 | .gpio = &rx51_gpio_data, |
| 291 | .keypad = &rx51_kp_data, |
| 292 | .madc = &rx51_madc_data, |
Roger Quadros | dfc27b3 | 2009-08-10 14:49:51 +0300 | [diff] [blame] | 293 | .usb = &rx51_usb_data, |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 294 | |
| 295 | .vaux1 = &rx51_vaux1, |
| 296 | .vaux2 = &rx51_vaux2, |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 297 | .vaux4 = &rx51_vaux4, |
| 298 | .vmmc1 = &rx51_vmmc1, |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 299 | .vsim = &rx51_vsim, |
| 300 | .vdac = &rx51_vdac, |
| 301 | }; |
| 302 | |
| 303 | static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_1[] = { |
| 304 | { |
| 305 | I2C_BOARD_INFO("twl5030", 0x48), |
| 306 | .flags = I2C_CLIENT_WAKE, |
| 307 | .irq = INT_34XX_SYS_NIRQ, |
| 308 | .platform_data = &rx51_twldata, |
| 309 | }, |
| 310 | }; |
| 311 | |
| 312 | static int __init rx51_i2c_init(void) |
| 313 | { |
Adrian Hunter | f52eeee | 2009-05-28 14:04:04 -0700 | [diff] [blame] | 314 | if ((system_rev >= SYSTEM_REV_S_USES_VAUX3 && system_rev < 0x100) || |
| 315 | system_rev >= SYSTEM_REV_B_USES_VAUX3) |
| 316 | rx51_twldata.vaux3 = &rx51_vaux3_mmc; |
| 317 | else { |
| 318 | rx51_twldata.vaux3 = &rx51_vaux3_cam; |
| 319 | rx51_twldata.vmmc2 = &rx51_vmmc2; |
| 320 | } |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 321 | omap_register_i2c_bus(1, 2600, rx51_peripherals_i2c_board_info_1, |
| 322 | ARRAY_SIZE(rx51_peripherals_i2c_board_info_1)); |
| 323 | omap_register_i2c_bus(2, 100, NULL, 0); |
| 324 | omap_register_i2c_bus(3, 400, NULL, 0); |
| 325 | return 0; |
| 326 | } |
| 327 | |
Juha Yrjola | aa62e90 | 2009-05-28 13:23:52 -0700 | [diff] [blame] | 328 | #if defined(CONFIG_MTD_ONENAND_OMAP2) || \ |
| 329 | defined(CONFIG_MTD_ONENAND_OMAP2_MODULE) |
| 330 | |
| 331 | static struct mtd_partition onenand_partitions[] = { |
| 332 | { |
| 333 | .name = "bootloader", |
| 334 | .offset = 0, |
| 335 | .size = 0x20000, |
| 336 | .mask_flags = MTD_WRITEABLE, /* Force read-only */ |
| 337 | }, |
| 338 | { |
| 339 | .name = "config", |
| 340 | .offset = MTDPART_OFS_APPEND, |
| 341 | .size = 0x60000, |
| 342 | }, |
| 343 | { |
| 344 | .name = "log", |
| 345 | .offset = MTDPART_OFS_APPEND, |
| 346 | .size = 0x40000, |
| 347 | }, |
| 348 | { |
| 349 | .name = "kernel", |
| 350 | .offset = MTDPART_OFS_APPEND, |
| 351 | .size = 0x200000, |
| 352 | }, |
| 353 | { |
| 354 | .name = "initfs", |
| 355 | .offset = MTDPART_OFS_APPEND, |
| 356 | .size = 0x200000, |
| 357 | }, |
| 358 | { |
| 359 | .name = "rootfs", |
| 360 | .offset = MTDPART_OFS_APPEND, |
| 361 | .size = MTDPART_SIZ_FULL, |
| 362 | }, |
| 363 | }; |
| 364 | |
| 365 | static struct omap_onenand_platform_data board_onenand_data = { |
| 366 | .cs = 0, |
| 367 | .gpio_irq = 65, |
| 368 | .parts = onenand_partitions, |
| 369 | .nr_parts = ARRAY_SIZE(onenand_partitions), |
Adrian Hunter | c8e6488 | 2009-06-23 13:30:25 +0300 | [diff] [blame] | 370 | .flags = ONENAND_SYNC_READWRITE, |
Juha Yrjola | aa62e90 | 2009-05-28 13:23:52 -0700 | [diff] [blame] | 371 | }; |
| 372 | |
| 373 | static void __init board_onenand_init(void) |
| 374 | { |
| 375 | gpmc_onenand_init(&board_onenand_data); |
| 376 | } |
| 377 | |
| 378 | #else |
| 379 | |
| 380 | static inline void board_onenand_init(void) |
| 381 | { |
| 382 | } |
| 383 | |
| 384 | #endif |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 385 | |
Tony Lindgren | 1a48e15 | 2009-05-28 13:23:52 -0700 | [diff] [blame] | 386 | #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) |
| 387 | |
| 388 | static struct omap_smc91x_platform_data board_smc91x_data = { |
| 389 | .cs = 1, |
| 390 | .gpio_irq = 54, |
| 391 | .gpio_pwrdwn = 86, |
| 392 | .gpio_reset = 164, |
| 393 | .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL, |
| 394 | }; |
| 395 | |
| 396 | static void __init board_smc91x_init(void) |
| 397 | { |
| 398 | omap_cfg_reg(U8_34XX_GPIO54_DOWN); |
| 399 | omap_cfg_reg(G25_34XX_GPIO86_OUT); |
| 400 | omap_cfg_reg(H19_34XX_GPIO164_OUT); |
| 401 | |
| 402 | gpmc_smc91x_init(&board_smc91x_data); |
| 403 | } |
| 404 | |
| 405 | #else |
| 406 | |
| 407 | static inline void board_smc91x_init(void) |
| 408 | { |
| 409 | } |
| 410 | |
| 411 | #endif |
| 412 | |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 413 | void __init rx51_peripherals_init(void) |
| 414 | { |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 415 | rx51_i2c_init(); |
Juha Yrjola | aa62e90 | 2009-05-28 13:23:52 -0700 | [diff] [blame] | 416 | board_onenand_init(); |
Tony Lindgren | 1a48e15 | 2009-05-28 13:23:52 -0700 | [diff] [blame] | 417 | board_smc91x_init(); |
Lauri Leukkunen | ffe7f95 | 2009-03-23 18:38:17 -0700 | [diff] [blame] | 418 | } |
| 419 | |