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" |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 43 | |
David Anders | 4415beb | 2010-10-07 19:36:30 +0000 | [diff] [blame] | 44 | #define GPIO_HUB_POWER 1 |
| 45 | #define GPIO_HUB_NRESET 62 |
| 46 | |
Ricardo Salveti de Araujo | 3da434a | 2010-09-23 18:22:49 -0700 | [diff] [blame] | 47 | static struct gpio_led gpio_leds[] = { |
| 48 | { |
| 49 | .name = "pandaboard::status1", |
| 50 | .default_trigger = "heartbeat", |
| 51 | .gpio = 7, |
| 52 | }, |
| 53 | { |
| 54 | .name = "pandaboard::status2", |
| 55 | .default_trigger = "mmc0", |
| 56 | .gpio = 8, |
| 57 | }, |
| 58 | }; |
| 59 | |
| 60 | static struct gpio_led_platform_data gpio_led_info = { |
| 61 | .leds = gpio_leds, |
| 62 | .num_leds = ARRAY_SIZE(gpio_leds), |
| 63 | }; |
| 64 | |
| 65 | static struct platform_device leds_gpio = { |
| 66 | .name = "leds-gpio", |
| 67 | .id = -1, |
| 68 | .dev = { |
| 69 | .platform_data = &gpio_led_info, |
| 70 | }, |
| 71 | }; |
| 72 | |
| 73 | static struct platform_device *panda_devices[] __initdata = { |
| 74 | &leds_gpio, |
| 75 | }; |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 76 | |
| 77 | static void __init omap4_panda_init_irq(void) |
| 78 | { |
| 79 | omap2_init_common_hw(NULL, NULL); |
| 80 | gic_init_irq(); |
| 81 | omap_gpio_init(); |
| 82 | } |
| 83 | |
David Anders | 4415beb | 2010-10-07 19:36:30 +0000 | [diff] [blame] | 84 | static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = { |
| 85 | .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY, |
| 86 | .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN, |
| 87 | .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN, |
| 88 | .phy_reset = false, |
| 89 | .reset_gpio_port[0] = -EINVAL, |
| 90 | .reset_gpio_port[1] = -EINVAL, |
| 91 | .reset_gpio_port[2] = -EINVAL |
| 92 | }; |
| 93 | |
| 94 | static void __init omap4_ehci_init(void) |
| 95 | { |
| 96 | int ret; |
| 97 | |
| 98 | |
| 99 | /* disable the power to the usb hub prior to init */ |
| 100 | ret = gpio_request(GPIO_HUB_POWER, "hub_power"); |
| 101 | if (ret) { |
| 102 | pr_err("Cannot request GPIO %d\n", GPIO_HUB_POWER); |
| 103 | goto error1; |
| 104 | } |
| 105 | gpio_export(GPIO_HUB_POWER, 0); |
| 106 | gpio_direction_output(GPIO_HUB_POWER, 0); |
| 107 | gpio_set_value(GPIO_HUB_POWER, 0); |
| 108 | |
| 109 | /* reset phy+hub */ |
| 110 | ret = gpio_request(GPIO_HUB_NRESET, "hub_nreset"); |
| 111 | if (ret) { |
| 112 | pr_err("Cannot request GPIO %d\n", GPIO_HUB_NRESET); |
| 113 | goto error2; |
| 114 | } |
| 115 | gpio_export(GPIO_HUB_NRESET, 0); |
| 116 | gpio_direction_output(GPIO_HUB_NRESET, 0); |
| 117 | gpio_set_value(GPIO_HUB_NRESET, 0); |
| 118 | gpio_set_value(GPIO_HUB_NRESET, 1); |
| 119 | |
| 120 | usb_ehci_init(&ehci_pdata); |
| 121 | |
| 122 | /* enable power to hub */ |
| 123 | gpio_set_value(GPIO_HUB_POWER, 1); |
| 124 | return; |
| 125 | |
| 126 | error2: |
| 127 | gpio_free(GPIO_HUB_POWER); |
| 128 | error1: |
| 129 | pr_err("Unable to initialize EHCI power/reset\n"); |
| 130 | return; |
| 131 | |
| 132 | } |
| 133 | |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 134 | static struct omap_musb_board_data musb_board_data = { |
| 135 | .interface_type = MUSB_INTERFACE_UTMI, |
| 136 | .mode = MUSB_PERIPHERAL, |
| 137 | .power = 100, |
| 138 | }; |
| 139 | |
| 140 | static struct omap2_hsmmc_info mmc[] = { |
| 141 | { |
| 142 | .mmc = 1, |
Sukumar Ghorai | 3a63833 | 2010-09-15 14:49:23 +0000 | [diff] [blame] | 143 | .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 144 | .gpio_wp = -EINVAL, |
| 145 | }, |
| 146 | {} /* Terminator */ |
| 147 | }; |
| 148 | |
| 149 | static struct regulator_consumer_supply omap4_panda_vmmc_supply[] = { |
| 150 | { |
| 151 | .supply = "vmmc", |
| 152 | .dev_name = "mmci-omap-hs.0", |
| 153 | }, |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 154 | }; |
| 155 | |
| 156 | static int omap4_twl6030_hsmmc_late_init(struct device *dev) |
| 157 | { |
| 158 | int ret = 0; |
| 159 | struct platform_device *pdev = container_of(dev, |
| 160 | struct platform_device, dev); |
| 161 | struct omap_mmc_platform_data *pdata = dev->platform_data; |
| 162 | |
| 163 | /* Setting MMC1 Card detect Irq */ |
| 164 | if (pdev->id == 0) |
| 165 | pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE + |
| 166 | MMCDETECT_INTR_OFFSET; |
| 167 | return ret; |
| 168 | } |
| 169 | |
| 170 | static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) |
| 171 | { |
David Anders | b9b5262 | 2010-10-07 19:36:29 +0000 | [diff] [blame] | 172 | struct omap_mmc_platform_data *pdata; |
| 173 | |
| 174 | /* dev can be null if CONFIG_MMC_OMAP_HS is not set */ |
| 175 | if (!dev) { |
| 176 | pr_err("Failed omap4_twl6030_hsmmc_set_late_init\n"); |
| 177 | return; |
| 178 | } |
| 179 | pdata = dev->platform_data; |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 180 | |
| 181 | pdata->init = omap4_twl6030_hsmmc_late_init; |
| 182 | } |
| 183 | |
| 184 | static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers) |
| 185 | { |
| 186 | struct omap2_hsmmc_info *c; |
| 187 | |
| 188 | omap2_hsmmc_init(controllers); |
| 189 | for (c = controllers; c->mmc; c++) |
| 190 | omap4_twl6030_hsmmc_set_late_init(c->dev); |
| 191 | |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | static struct regulator_init_data omap4_panda_vaux1 = { |
| 196 | .constraints = { |
| 197 | .min_uV = 1000000, |
| 198 | .max_uV = 3000000, |
| 199 | .apply_uV = true, |
| 200 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 201 | | REGULATOR_MODE_STANDBY, |
| 202 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 203 | | REGULATOR_CHANGE_MODE |
| 204 | | REGULATOR_CHANGE_STATUS, |
| 205 | }, |
| 206 | }; |
| 207 | |
| 208 | static struct regulator_init_data omap4_panda_vaux2 = { |
| 209 | .constraints = { |
| 210 | .min_uV = 1200000, |
| 211 | .max_uV = 2800000, |
| 212 | .apply_uV = true, |
| 213 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 214 | | REGULATOR_MODE_STANDBY, |
| 215 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 216 | | REGULATOR_CHANGE_MODE |
| 217 | | REGULATOR_CHANGE_STATUS, |
| 218 | }, |
| 219 | }; |
| 220 | |
| 221 | static struct regulator_init_data omap4_panda_vaux3 = { |
| 222 | .constraints = { |
| 223 | .min_uV = 1000000, |
| 224 | .max_uV = 3000000, |
| 225 | .apply_uV = true, |
| 226 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 227 | | REGULATOR_MODE_STANDBY, |
| 228 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 229 | | REGULATOR_CHANGE_MODE |
| 230 | | REGULATOR_CHANGE_STATUS, |
| 231 | }, |
| 232 | }; |
| 233 | |
| 234 | /* VMMC1 for MMC1 card */ |
| 235 | static struct regulator_init_data omap4_panda_vmmc = { |
| 236 | .constraints = { |
| 237 | .min_uV = 1200000, |
| 238 | .max_uV = 3000000, |
| 239 | .apply_uV = true, |
| 240 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 241 | | REGULATOR_MODE_STANDBY, |
| 242 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 243 | | REGULATOR_CHANGE_MODE |
| 244 | | REGULATOR_CHANGE_STATUS, |
| 245 | }, |
David Anders | 191183b | 2010-10-07 19:36:28 +0000 | [diff] [blame] | 246 | .num_consumer_supplies = 1, |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 247 | .consumer_supplies = omap4_panda_vmmc_supply, |
| 248 | }; |
| 249 | |
| 250 | static struct regulator_init_data omap4_panda_vpp = { |
| 251 | .constraints = { |
| 252 | .min_uV = 1800000, |
| 253 | .max_uV = 2500000, |
| 254 | .apply_uV = true, |
| 255 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 256 | | REGULATOR_MODE_STANDBY, |
| 257 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 258 | | REGULATOR_CHANGE_MODE |
| 259 | | REGULATOR_CHANGE_STATUS, |
| 260 | }, |
| 261 | }; |
| 262 | |
| 263 | static struct regulator_init_data omap4_panda_vusim = { |
| 264 | .constraints = { |
| 265 | .min_uV = 1200000, |
| 266 | .max_uV = 2900000, |
| 267 | .apply_uV = true, |
| 268 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 269 | | REGULATOR_MODE_STANDBY, |
| 270 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 271 | | REGULATOR_CHANGE_MODE |
| 272 | | REGULATOR_CHANGE_STATUS, |
| 273 | }, |
| 274 | }; |
| 275 | |
| 276 | static struct regulator_init_data omap4_panda_vana = { |
| 277 | .constraints = { |
| 278 | .min_uV = 2100000, |
| 279 | .max_uV = 2100000, |
| 280 | .apply_uV = true, |
| 281 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 282 | | REGULATOR_MODE_STANDBY, |
| 283 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 284 | | REGULATOR_CHANGE_STATUS, |
| 285 | }, |
| 286 | }; |
| 287 | |
| 288 | static struct regulator_init_data omap4_panda_vcxio = { |
| 289 | .constraints = { |
| 290 | .min_uV = 1800000, |
| 291 | .max_uV = 1800000, |
| 292 | .apply_uV = true, |
| 293 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 294 | | REGULATOR_MODE_STANDBY, |
| 295 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 296 | | REGULATOR_CHANGE_STATUS, |
| 297 | }, |
| 298 | }; |
| 299 | |
| 300 | static struct regulator_init_data omap4_panda_vdac = { |
| 301 | .constraints = { |
| 302 | .min_uV = 1800000, |
| 303 | .max_uV = 1800000, |
| 304 | .apply_uV = true, |
| 305 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 306 | | REGULATOR_MODE_STANDBY, |
| 307 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 308 | | REGULATOR_CHANGE_STATUS, |
| 309 | }, |
| 310 | }; |
| 311 | |
| 312 | static struct regulator_init_data omap4_panda_vusb = { |
| 313 | .constraints = { |
| 314 | .min_uV = 3300000, |
| 315 | .max_uV = 3300000, |
| 316 | .apply_uV = true, |
| 317 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 318 | | REGULATOR_MODE_STANDBY, |
| 319 | .valid_ops_mask = REGULATOR_CHANGE_MODE |
| 320 | | REGULATOR_CHANGE_STATUS, |
| 321 | }, |
| 322 | }; |
| 323 | |
| 324 | static struct twl4030_platform_data omap4_panda_twldata = { |
| 325 | .irq_base = TWL6030_IRQ_BASE, |
| 326 | .irq_end = TWL6030_IRQ_END, |
| 327 | |
| 328 | /* Regulators */ |
| 329 | .vmmc = &omap4_panda_vmmc, |
| 330 | .vpp = &omap4_panda_vpp, |
| 331 | .vusim = &omap4_panda_vusim, |
| 332 | .vana = &omap4_panda_vana, |
| 333 | .vcxio = &omap4_panda_vcxio, |
| 334 | .vdac = &omap4_panda_vdac, |
| 335 | .vusb = &omap4_panda_vusb, |
| 336 | .vaux1 = &omap4_panda_vaux1, |
| 337 | .vaux2 = &omap4_panda_vaux2, |
| 338 | .vaux3 = &omap4_panda_vaux3, |
| 339 | }; |
| 340 | |
| 341 | static struct i2c_board_info __initdata omap4_panda_i2c_boardinfo[] = { |
| 342 | { |
| 343 | I2C_BOARD_INFO("twl6030", 0x48), |
| 344 | .flags = I2C_CLIENT_WAKE, |
| 345 | .irq = OMAP44XX_IRQ_SYS_1N, |
| 346 | .platform_data = &omap4_panda_twldata, |
| 347 | }, |
| 348 | }; |
| 349 | static int __init omap4_panda_i2c_init(void) |
| 350 | { |
| 351 | /* |
| 352 | * Phoenix Audio IC needs I2C1 to |
| 353 | * start with 400 KHz or less |
| 354 | */ |
| 355 | omap_register_i2c_bus(1, 400, omap4_panda_i2c_boardinfo, |
| 356 | ARRAY_SIZE(omap4_panda_i2c_boardinfo)); |
| 357 | omap_register_i2c_bus(2, 400, NULL, 0); |
| 358 | omap_register_i2c_bus(3, 400, NULL, 0); |
| 359 | omap_register_i2c_bus(4, 400, NULL, 0); |
| 360 | return 0; |
| 361 | } |
| 362 | static void __init omap4_panda_init(void) |
| 363 | { |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 364 | omap4_panda_i2c_init(); |
Ricardo Salveti de Araujo | 3da434a | 2010-09-23 18:22:49 -0700 | [diff] [blame] | 365 | platform_add_devices(panda_devices, ARRAY_SIZE(panda_devices)); |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 366 | omap_serial_init(); |
| 367 | omap4_twl6030_hsmmc_init(mmc); |
| 368 | /* OMAP4 Panda uses internal transceiver so register nop transceiver */ |
| 369 | usb_nop_xceiv_register(); |
David Anders | 4415beb | 2010-10-07 19:36:30 +0000 | [diff] [blame] | 370 | omap4_ehci_init(); |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 371 | /* FIXME: allow multi-omap to boot until musb is updated for omap4 */ |
| 372 | if (!cpu_is_omap44xx()) |
| 373 | usb_musb_init(&musb_board_data); |
| 374 | } |
| 375 | |
| 376 | static void __init omap4_panda_map_io(void) |
| 377 | { |
| 378 | omap2_set_globals_443x(); |
| 379 | omap44xx_map_common_io(); |
| 380 | } |
| 381 | |
| 382 | MACHINE_START(OMAP4_PANDA, "OMAP4 Panda board") |
| 383 | /* Maintainer: David Anders - Texas Instruments Inc */ |
David Anders | b075f58 | 2010-08-02 13:18:05 +0300 | [diff] [blame] | 384 | .boot_params = 0x80000100, |
| 385 | .map_io = omap4_panda_map_io, |
| 386 | .init_irq = omap4_panda_init_irq, |
| 387 | .init_machine = omap4_panda_init, |
| 388 | .timer = &omap_timer, |
| 389 | MACHINE_END |