David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Board support file for OMAP4430 based PandaBoard. |
| 3 | * |
| 4 | * Copyright (C) 2010 Texas Instruments |
| 5 | * |
| 6 | * Author: David Anders <x0132446@ti.com> |
| 7 | * |
| 8 | * Based on mach-omap2/board-4430sdp.c |
| 9 | * |
| 10 | * Author: Santosh Shilimkar <santosh.shilimkar@ti.com> |
| 11 | * |
| 12 | * Based on mach-omap2/board-3430sdp.c |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License version 2 as |
| 16 | * published by the Free Software Foundation. |
| 17 | */ |
| 18 | |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/io.h> |
Ricardo Salveti de Araujo | 3da434a | 2010-09-23 18:22:49 -0700 | [diff] [blame] | 23 | #include <linux/leds.h> |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 24 | #include <linux/gpio.h> |
| 25 | #include <linux/usb/otg.h> |
| 26 | #include <linux/i2c/twl.h> |
| 27 | #include <linux/regulator/machine.h> |
| 28 | |
| 29 | #include <mach/hardware.h> |
| 30 | #include <mach/omap4-common.h> |
| 31 | #include <asm/mach-types.h> |
| 32 | #include <asm/mach/arch.h> |
| 33 | #include <asm/mach/map.h> |
| 34 | |
| 35 | #include <plat/board.h> |
| 36 | #include <plat/common.h> |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 37 | #include <plat/usb.h> |
| 38 | #include <plat/mmc.h> |
Manjunath Kondaiah G | 04aeae7 | 2010-10-08 09:58:35 -0700 | [diff] [blame] | 39 | #include "timer-gp.h" |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 40 | |
Paul Walmsley | 4814ced | 2010-10-08 11:40:20 -0600 | [diff] [blame] | 41 | #include "hsmmc.h" |
| 42 | #include "control.h" |
sricharan | fc63de82 | 2010-11-08 19:26:11 +0530 | [diff] [blame] | 43 | #include "mux.h" |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 44 | |
David Anders | 4415beb | 2010-10-07 19:36:30 +0000 | [diff] [blame] | 45 | #define GPIO_HUB_POWER 1 |
| 46 | #define GPIO_HUB_NRESET 62 |
| 47 | |
Ricardo Salveti de Araujo | 3da434a | 2010-09-23 18:22:49 -0700 | [diff] [blame] | 48 | static struct gpio_led gpio_leds[] = { |
| 49 | { |
| 50 | .name = "pandaboard::status1", |
| 51 | .default_trigger = "heartbeat", |
| 52 | .gpio = 7, |
| 53 | }, |
| 54 | { |
| 55 | .name = "pandaboard::status2", |
| 56 | .default_trigger = "mmc0", |
| 57 | .gpio = 8, |
| 58 | }, |
| 59 | }; |
| 60 | |
| 61 | static struct gpio_led_platform_data gpio_led_info = { |
| 62 | .leds = gpio_leds, |
| 63 | .num_leds = ARRAY_SIZE(gpio_leds), |
| 64 | }; |
| 65 | |
| 66 | static struct platform_device leds_gpio = { |
| 67 | .name = "leds-gpio", |
| 68 | .id = -1, |
| 69 | .dev = { |
| 70 | .platform_data = &gpio_led_info, |
| 71 | }, |
| 72 | }; |
| 73 | |
| 74 | static struct platform_device *panda_devices[] __initdata = { |
| 75 | &leds_gpio, |
| 76 | }; |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 77 | |
| 78 | static void __init omap4_panda_init_irq(void) |
| 79 | { |
Paul Walmsley | 4805734 | 2010-12-21 15:25:10 -0700 | [diff] [blame^] | 80 | omap2_init_common_infrastructure(); |
| 81 | omap2_init_common_devices(NULL, NULL); |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 82 | gic_init_irq(); |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 83 | } |
| 84 | |
David Anders | 4415beb | 2010-10-07 19:36:30 +0000 | [diff] [blame] | 85 | static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { |
| 86 | .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, |
| 87 | .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN, |
| 88 | .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN, |
| 89 | .phy_reset = false, |
| 90 | .reset_gpio_port[0] = -EINVAL, |
| 91 | .reset_gpio_port[1] = -EINVAL, |
| 92 | .reset_gpio_port[2] = -EINVAL |
| 93 | }; |
| 94 | |
| 95 | static void __init omap4_ehci_init(void) |
| 96 | { |
| 97 | int ret; |
| 98 | |
| 99 | |
| 100 | /* disable the power to the usb hub prior to init */ |
| 101 | ret = gpio_request(GPIO_HUB_POWER, "hub_power"); |
| 102 | if (ret) { |
| 103 | pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER); |
| 104 | goto error1; |
| 105 | } |
| 106 | gpio_export(GPIO_HUB_POWER, 0); |
| 107 | gpio_direction_output(GPIO_HUB_POWER, 0); |
| 108 | gpio_set_value(GPIO_HUB_POWER, 0); |
| 109 | |
| 110 | /* reset phy+hub */ |
| 111 | ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset"); |
| 112 | if (ret) { |
| 113 | pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET); |
| 114 | goto error2; |
| 115 | } |
| 116 | gpio_export(GPIO_HUB_NRESET, 0); |
| 117 | gpio_direction_output(GPIO_HUB_NRESET, 0); |
| 118 | gpio_set_value(GPIO_HUB_NRESET, 0); |
| 119 | gpio_set_value(GPIO_HUB_NRESET, 1); |
| 120 | |
| 121 | usb_ehci_init(&ehci_pdata); |
| 122 | |
| 123 | /* enable power to hub */ |
| 124 | gpio_set_value(GPIO_HUB_POWER, 1); |
| 125 | return; |
| 126 | |
| 127 | error2: |
| 128 | gpio_free(GPIO_HUB_POWER); |
| 129 | error1: |
| 130 | pr_err("Unable to initialize EHCI power/reset\n"); |
| 131 | return; |
| 132 | |
| 133 | } |
| 134 | |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 135 | static struct omap_musb_board_data musb_board_data = { |
| 136 | .interface_type = MUSB_INTERFACE_UTMI, |
| 137 | .mode = MUSB_PERIPHERAL, |
| 138 | .power = 100, |
| 139 | }; |
| 140 | |
| 141 | static struct omap2_hsmmc_info mmc[] = { |
| 142 | { |
| 143 | .mmc = 1, |
Sukumar Ghorai | 3a63833 | 2010-09-15 14:49:23 +0000 | [diff] [blame] | 144 | .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 145 | .gpio_wp = -EINVAL, |
| 146 | }, |
| 147 | {} /* Terminator */ |
| 148 | }; |
| 149 | |
| 150 | static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = { |
| 151 | { |
| 152 | .supply = "vmmc", |
| 153 | .dev_name = "mmci-omap-hs.0", |
| 154 | }, |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 155 | }; |
| 156 | |
| 157 | static int omap4_twl6030_hsmmc_late_init(struct device *dev) |
| 158 | { |
| 159 | int ret = 0; |
| 160 | struct platform_device *pdev = container_of(dev, |
| 161 | struct platform_device, dev); |
| 162 | struct omap_mmc_platform_data *pdata = dev->platform_data; |
| 163 | |
Menon, Nishanth | bf56f0a | 2010-10-19 09:50:25 -0500 | [diff] [blame] | 164 | if (!pdata) { |
| 165 | dev_err(dev, "%s: NULL platform data\n", __func__); |
| 166 | return -EINVAL; |
| 167 | } |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 168 | /* Setting MMC1 Card detect Irq */ |
Menon, Nishanth | bf56f0a | 2010-10-19 09:50:25 -0500 | [diff] [blame] | 169 | if (pdev->id == 0) { |
| 170 | ret = twl6030_mmc_card_detect_config(); |
| 171 | if (ret) |
| 172 | dev_err(dev, "%s: Error card detect config(%d)\n", |
| 173 | __func__, ret); |
| 174 | else |
| 175 | pdata->slots[0].card_detect = twl6030_mmc_card_detect; |
| 176 | } |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 177 | return ret; |
| 178 | } |
| 179 | |
| 180 | static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) |
| 181 | { |
David Anders | b9b5262 | 2010-10-07 19:36:29 +0000 | [diff] [blame] | 182 | struct omap_mmc_platform_data *pdata; |
| 183 | |
| 184 | /* dev can be null if CONFIG_MMC_OMAP_HS is not set */ |
| 185 | if (!dev) { |
| 186 | pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n"); |
| 187 | return; |
| 188 | } |
| 189 | pdata = dev->platform_data; |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 190 | |
| 191 | pdata->init = omap4_twl6030_hsmmc_late_init; |
| 192 | } |
| 193 | |
| 194 | static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) |
| 195 | { |
| 196 | struct omap2_hsmmc_info *c; |
| 197 | |
| 198 | omap2_hsmmc_init(controllers); |
| 199 | for (c = controllers; c->mmc; c++) |
| 200 | omap4_twl6030_hsmmc_set_late_init(c->dev); |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | static struct regulator_init_data omap4_panda_vaux1 = { |
| 206 | .constraints = { |
| 207 | .min_uV = 1000000, |
| 208 | .max_uV = 3000000, |
| 209 | .apply_uV = true, |
| 210 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 211 | | REGULATOR_MODE_STANDBY, |
| 212 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 213 | | REGULATOR_CHANGE_MODE |
| 214 | | REGULATOR_CHANGE_STATUS, |
| 215 | }, |
| 216 | }; |
| 217 | |
| 218 | static struct regulator_init_data omap4_panda_vaux2 = { |
| 219 | .constraints = { |
| 220 | .min_uV = 1200000, |
| 221 | .max_uV = 2800000, |
| 222 | .apply_uV = true, |
| 223 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 224 | | REGULATOR_MODE_STANDBY, |
| 225 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 226 | | REGULATOR_CHANGE_MODE |
| 227 | | REGULATOR_CHANGE_STATUS, |
| 228 | }, |
| 229 | }; |
| 230 | |
| 231 | static struct regulator_init_data omap4_panda_vaux3 = { |
| 232 | .constraints = { |
| 233 | .min_uV = 1000000, |
| 234 | .max_uV = 3000000, |
| 235 | .apply_uV = true, |
| 236 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 237 | | REGULATOR_MODE_STANDBY, |
| 238 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 239 | | REGULATOR_CHANGE_MODE |
| 240 | | REGULATOR_CHANGE_STATUS, |
| 241 | }, |
| 242 | }; |
| 243 | |
| 244 | /* VMMC1 for MMC1 card */ |
| 245 | static struct regulator_init_data omap4_panda_vmmc = { |
| 246 | .constraints = { |
| 247 | .min_uV = 1200000, |
| 248 | .max_uV = 3000000, |
| 249 | .apply_uV = true, |
| 250 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 251 | | REGULATOR_MODE_STANDBY, |
| 252 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 253 | | REGULATOR_CHANGE_MODE |
| 254 | | REGULATOR_CHANGE_STATUS, |
| 255 | }, |
David Anders | 191183b | 2010-10-07 19:36:28 +0000 | [diff] [blame] | 256 | .num_consumer_supplies = 1, |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 257 | .consumer_supplies = omap4_panda_vmmc_supply, |
| 258 | }; |
| 259 | |
| 260 | static struct regulator_init_data omap4_panda_vpp = { |
| 261 | .constraints = { |
| 262 | .min_uV = 1800000, |
| 263 | .max_uV = 2500000, |
| 264 | .apply_uV = true, |
| 265 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 266 | | REGULATOR_MODE_STANDBY, |
| 267 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 268 | | REGULATOR_CHANGE_MODE |
| 269 | | REGULATOR_CHANGE_STATUS, |
| 270 | }, |
| 271 | }; |
| 272 | |
| 273 | static struct regulator_init_data omap4_panda_vusim = { |
| 274 | .constraints = { |
| 275 | .min_uV = 1200000, |
| 276 | .max_uV = 2900000, |
| 277 | .apply_uV = true, |
| 278 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 279 | | REGULATOR_MODE_STANDBY, |
| 280 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 281 | | REGULATOR_CHANGE_MODE |
| 282 | | REGULATOR_CHANGE_STATUS, |
| 283 | }, |
| 284 | }; |
| 285 | |
| 286 | static struct regulator_init_data omap4_panda_vana = { |
| 287 | .constraints = { |
| 288 | .min_uV = 2100000, |
| 289 | .max_uV = 2100000, |
| 290 | .apply_uV = true, |
| 291 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 292 | | REGULATOR_MODE_STANDBY, |
| 293 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 294 | | REGULATOR_CHANGE_STATUS, |
| 295 | }, |
| 296 | }; |
| 297 | |
| 298 | static struct regulator_init_data omap4_panda_vcxio = { |
| 299 | .constraints = { |
| 300 | .min_uV = 1800000, |
| 301 | .max_uV = 1800000, |
| 302 | .apply_uV = true, |
| 303 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 304 | | REGULATOR_MODE_STANDBY, |
| 305 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 306 | | REGULATOR_CHANGE_STATUS, |
| 307 | }, |
| 308 | }; |
| 309 | |
| 310 | static struct regulator_init_data omap4_panda_vdac = { |
| 311 | .constraints = { |
| 312 | .min_uV = 1800000, |
| 313 | .max_uV = 1800000, |
| 314 | .apply_uV = true, |
| 315 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 316 | | REGULATOR_MODE_STANDBY, |
| 317 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 318 | | REGULATOR_CHANGE_STATUS, |
| 319 | }, |
| 320 | }; |
| 321 | |
| 322 | static struct regulator_init_data omap4_panda_vusb = { |
| 323 | .constraints = { |
| 324 | .min_uV = 3300000, |
| 325 | .max_uV = 3300000, |
| 326 | .apply_uV = true, |
| 327 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 328 | | REGULATOR_MODE_STANDBY, |
| 329 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 330 | | REGULATOR_CHANGE_STATUS, |
| 331 | }, |
| 332 | }; |
| 333 | |
| 334 | static struct twl4030_platform_data omap4_panda_twldata = { |
| 335 | .irq_base = TWL6030_IRQ_BASE, |
| 336 | .irq_end = TWL6030_IRQ_END, |
| 337 | |
| 338 | /* Regulators */ |
| 339 | .vmmc = &omap4_panda_vmmc, |
| 340 | .vpp = &omap4_panda_vpp, |
| 341 | .vusim = &omap4_panda_vusim, |
| 342 | .vana = &omap4_panda_vana, |
| 343 | .vcxio = &omap4_panda_vcxio, |
| 344 | .vdac = &omap4_panda_vdac, |
| 345 | .vusb = &omap4_panda_vusb, |
| 346 | .vaux1 = &omap4_panda_vaux1, |
| 347 | .vaux2 = &omap4_panda_vaux2, |
| 348 | .vaux3 = &omap4_panda_vaux3, |
| 349 | }; |
| 350 | |
| 351 | static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = { |
| 352 | { |
| 353 | I2C_BOARD_INFO("twl6030", 0x48), |
| 354 | .flags = I2C_CLIENT_WAKE, |
| 355 | .irq = OMAP44XX_IRQ_SYS_1N, |
| 356 | .platform_data = &omap4_panda_twldata, |
| 357 | }, |
| 358 | }; |
| 359 | static int __init omap4_panda_i2c_init(void) |
| 360 | { |
| 361 | /* |
| 362 | * Phoenix Audio IC needs I2C1 to |
| 363 | * start with 400 KHz or less |
| 364 | */ |
| 365 | omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo, |
| 366 | ARRAY_SIZE(omap4_panda_i2c_boardinfo)); |
| 367 | omap_register_i2c_bus(2, 400, NULL, 0); |
| 368 | omap_register_i2c_bus(3, 400, NULL, 0); |
| 369 | omap_register_i2c_bus(4, 400, NULL, 0); |
| 370 | return 0; |
| 371 | } |
sricharan | fc63de82 | 2010-11-08 19:26:11 +0530 | [diff] [blame] | 372 | |
| 373 | #ifdef CONFIG_OMAP_MUX |
| 374 | static struct omap_board_mux board_mux[] __initdata = { |
| 375 | { .reg_offset = OMAP_MUX_TERMINATOR }, |
| 376 | }; |
| 377 | #else |
| 378 | #define board_mux NULL |
| 379 | #endif |
| 380 | |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 381 | static void __init omap4_panda_init(void) |
| 382 | { |
sricharan | fc63de82 | 2010-11-08 19:26:11 +0530 | [diff] [blame] | 383 | int package = OMAP_PACKAGE_CBS; |
| 384 | |
| 385 | if (omap_rev() == OMAP4430_REV_ES1_0) |
| 386 | package = OMAP_PACKAGE_CBL; |
| 387 | omap4_mux_init(board_mux, package); |
| 388 | |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 389 | omap4_panda_i2c_init(); |
Ricardo Salveti de Araujo | 3da434a | 2010-09-23 18:22:49 -0700 | [diff] [blame] | 390 | platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices)); |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 391 | omap_serial_init(); |
| 392 | omap4_twl6030_hsmmc_init(mmc); |
| 393 | /* OMAP4 Panda uses internal transceiver so register nop transceiver */ |
| 394 | usb_nop_xceiv_register(); |
David Anders | 4415beb | 2010-10-07 19:36:30 +0000 | [diff] [blame] | 395 | omap4_ehci_init(); |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 396 | /* FIXME: allow multi-omap to boot until musb is updated for omap4 */ |
| 397 | if (!cpu_is_omap44xx()) |
| 398 | usb_musb_init(&musb_board_data); |
| 399 | } |
| 400 | |
| 401 | static void __init omap4_panda_map_io(void) |
| 402 | { |
| 403 | omap2_set_globals_443x(); |
| 404 | omap44xx_map_common_io(); |
| 405 | } |
| 406 | |
| 407 | MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board") |
| 408 | /* Maintainer: David Anders - Texas Instruments Inc */ |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 409 | .boot_params = 0x80000100, |
Raghuveer Murthy | d920e52 | 2010-12-17 18:15:07 -0800 | [diff] [blame] | 410 | .reserve = omap_reserve, |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 411 | .map_io = omap4_panda_map_io, |
| 412 | .init_irq = omap4_panda_init_irq, |
| 413 | .init_machine = omap4_panda_init, |
| 414 | .timer = &omap_timer, |
| 415 | MACHINE_END |