| .. | .. |
|---|
| 3 | 3 | * |
|---|
| 4 | 4 | * Initial code: Syed Mohammed Khasim |
|---|
| 5 | 5 | * |
|---|
| 6 | | - * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com |
|---|
| 6 | + * Copyright (C) 2009 Texas Instruments Incorporated - https://www.ti.com |
|---|
| 7 | 7 | * |
|---|
| 8 | 8 | * This file is licensed under the terms of the GNU General Public License |
|---|
| 9 | 9 | * version 2. This program is licensed "as is" without any warranty of |
|---|
| .. | .. |
|---|
| 21 | 21 | #include <linux/platform_data/mtd-davinci.h> |
|---|
| 22 | 22 | #include <linux/platform_data/mtd-davinci-aemif.h> |
|---|
| 23 | 23 | #include <linux/platform_data/ti-aemif.h> |
|---|
| 24 | +#include <linux/regulator/fixed.h> |
|---|
| 24 | 25 | #include <linux/regulator/machine.h> |
|---|
| 25 | 26 | |
|---|
| 26 | 27 | #include <asm/mach-types.h> |
|---|
| 27 | 28 | #include <asm/mach/arch.h> |
|---|
| 28 | 29 | |
|---|
| 29 | 30 | #include <mach/common.h> |
|---|
| 30 | | -#include "cp_intc.h" |
|---|
| 31 | 31 | #include <mach/da8xx.h> |
|---|
| 32 | 32 | #include <mach/mux.h> |
|---|
| 33 | 33 | |
|---|
| .. | .. |
|---|
| 134 | 134 | static struct gpiod_lookup_table mmc_gpios_table = { |
|---|
| 135 | 135 | .dev_id = "da830-mmc.0", |
|---|
| 136 | 136 | .table = { |
|---|
| 137 | | - GPIO_LOOKUP("davinci_gpio.0", DA850_HAWK_MMCSD_CD_PIN, "cd", |
|---|
| 137 | + GPIO_LOOKUP("davinci_gpio", DA850_HAWK_MMCSD_CD_PIN, "cd", |
|---|
| 138 | 138 | GPIO_ACTIVE_LOW), |
|---|
| 139 | | - GPIO_LOOKUP("davinci_gpio.0", DA850_HAWK_MMCSD_WP_PIN, "wp", |
|---|
| 139 | + GPIO_LOOKUP("davinci_gpio", DA850_HAWK_MMCSD_WP_PIN, "wp", |
|---|
| 140 | 140 | GPIO_ACTIVE_LOW), |
|---|
| 141 | 141 | }, |
|---|
| 142 | 142 | }; |
|---|
| .. | .. |
|---|
| 206 | 206 | .core_chipsel = 1, |
|---|
| 207 | 207 | .parts = omapl138_hawk_nandflash_partition, |
|---|
| 208 | 208 | .nr_parts = ARRAY_SIZE(omapl138_hawk_nandflash_partition), |
|---|
| 209 | | - .ecc_mode = NAND_ECC_HW, |
|---|
| 209 | + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, |
|---|
| 210 | 210 | .ecc_bits = 4, |
|---|
| 211 | 211 | .bbt_options = NAND_BBT_USE_FLASH, |
|---|
| 212 | 212 | .options = NAND_BUSWIDTH_16, |
|---|
| .. | .. |
|---|
| 294 | 294 | return platform_device_register(&omapl138_hawk_aemif_device); |
|---|
| 295 | 295 | } |
|---|
| 296 | 296 | |
|---|
| 297 | | -static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id); |
|---|
| 298 | | -static da8xx_ocic_handler_t hawk_usb_ocic_handler; |
|---|
| 299 | | - |
|---|
| 300 | 297 | static const short da850_hawk_usb11_pins[] = { |
|---|
| 301 | 298 | DA850_GPIO2_4, DA850_GPIO6_13, |
|---|
| 302 | 299 | -1 |
|---|
| 303 | 300 | }; |
|---|
| 304 | 301 | |
|---|
| 305 | | -static int hawk_usb_set_power(unsigned port, int on) |
|---|
| 306 | | -{ |
|---|
| 307 | | - gpio_set_value(DA850_USB1_VBUS_PIN, on); |
|---|
| 308 | | - return 0; |
|---|
| 309 | | -} |
|---|
| 302 | +static struct regulator_consumer_supply hawk_usb_supplies[] = { |
|---|
| 303 | + REGULATOR_SUPPLY("vbus", NULL), |
|---|
| 304 | +}; |
|---|
| 310 | 305 | |
|---|
| 311 | | -static int hawk_usb_get_power(unsigned port) |
|---|
| 312 | | -{ |
|---|
| 313 | | - return gpio_get_value(DA850_USB1_VBUS_PIN); |
|---|
| 314 | | -} |
|---|
| 306 | +static struct regulator_init_data hawk_usb_vbus_data = { |
|---|
| 307 | + .consumer_supplies = hawk_usb_supplies, |
|---|
| 308 | + .num_consumer_supplies = ARRAY_SIZE(hawk_usb_supplies), |
|---|
| 309 | + .constraints = { |
|---|
| 310 | + .valid_ops_mask = REGULATOR_CHANGE_STATUS, |
|---|
| 311 | + }, |
|---|
| 312 | +}; |
|---|
| 315 | 313 | |
|---|
| 316 | | -static int hawk_usb_get_oci(unsigned port) |
|---|
| 317 | | -{ |
|---|
| 318 | | - return !gpio_get_value(DA850_USB1_OC_PIN); |
|---|
| 319 | | -} |
|---|
| 314 | +static struct fixed_voltage_config hawk_usb_vbus = { |
|---|
| 315 | + .supply_name = "vbus", |
|---|
| 316 | + .microvolts = 3300000, |
|---|
| 317 | + .init_data = &hawk_usb_vbus_data, |
|---|
| 318 | +}; |
|---|
| 320 | 319 | |
|---|
| 321 | | -static int hawk_usb_ocic_notify(da8xx_ocic_handler_t handler) |
|---|
| 322 | | -{ |
|---|
| 323 | | - int irq = gpio_to_irq(DA850_USB1_OC_PIN); |
|---|
| 324 | | - int error = 0; |
|---|
| 320 | +static struct platform_device hawk_usb_vbus_device = { |
|---|
| 321 | + .name = "reg-fixed-voltage", |
|---|
| 322 | + .id = 0, |
|---|
| 323 | + .dev = { |
|---|
| 324 | + .platform_data = &hawk_usb_vbus, |
|---|
| 325 | + }, |
|---|
| 326 | +}; |
|---|
| 325 | 327 | |
|---|
| 326 | | - if (handler != NULL) { |
|---|
| 327 | | - hawk_usb_ocic_handler = handler; |
|---|
| 328 | +static struct gpiod_lookup_table hawk_usb_oc_gpio_lookup = { |
|---|
| 329 | + .dev_id = "ohci-da8xx", |
|---|
| 330 | + .table = { |
|---|
| 331 | + GPIO_LOOKUP("davinci_gpio", DA850_USB1_OC_PIN, "oc", 0), |
|---|
| 332 | + { } |
|---|
| 333 | + }, |
|---|
| 334 | +}; |
|---|
| 328 | 335 | |
|---|
| 329 | | - error = request_irq(irq, omapl138_hawk_usb_ocic_irq, |
|---|
| 330 | | - IRQF_TRIGGER_RISING | |
|---|
| 331 | | - IRQF_TRIGGER_FALLING, |
|---|
| 332 | | - "OHCI over-current indicator", NULL); |
|---|
| 333 | | - if (error) |
|---|
| 334 | | - pr_err("%s: could not request IRQ to watch " |
|---|
| 335 | | - "over-current indicator changes\n", __func__); |
|---|
| 336 | | - } else { |
|---|
| 337 | | - free_irq(irq, NULL); |
|---|
| 338 | | - } |
|---|
| 339 | | - return error; |
|---|
| 340 | | -} |
|---|
| 336 | +static struct gpiod_lookup_table hawk_usb_vbus_gpio_lookup = { |
|---|
| 337 | + .dev_id = "reg-fixed-voltage.0", |
|---|
| 338 | + .table = { |
|---|
| 339 | + GPIO_LOOKUP("davinci_gpio", DA850_USB1_VBUS_PIN, NULL, 0), |
|---|
| 340 | + { } |
|---|
| 341 | + }, |
|---|
| 342 | +}; |
|---|
| 343 | + |
|---|
| 344 | +static struct gpiod_lookup_table *hawk_usb_gpio_lookups[] = { |
|---|
| 345 | + &hawk_usb_oc_gpio_lookup, |
|---|
| 346 | + &hawk_usb_vbus_gpio_lookup, |
|---|
| 347 | +}; |
|---|
| 341 | 348 | |
|---|
| 342 | 349 | static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = { |
|---|
| 343 | | - .set_power = hawk_usb_set_power, |
|---|
| 344 | | - .get_power = hawk_usb_get_power, |
|---|
| 345 | | - .get_oci = hawk_usb_get_oci, |
|---|
| 346 | | - .ocic_notify = hawk_usb_ocic_notify, |
|---|
| 347 | 350 | /* TPS2087 switch @ 5V */ |
|---|
| 348 | 351 | .potpgt = (3 + 1) / 2, /* 3 ms max */ |
|---|
| 349 | 352 | }; |
|---|
| 350 | | - |
|---|
| 351 | | -static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id) |
|---|
| 352 | | -{ |
|---|
| 353 | | - hawk_usb_ocic_handler(&omapl138_hawk_usb11_pdata, 1); |
|---|
| 354 | | - return IRQ_HANDLED; |
|---|
| 355 | | -} |
|---|
| 356 | 353 | |
|---|
| 357 | 354 | static __init void omapl138_hawk_usb_init(void) |
|---|
| 358 | 355 | { |
|---|
| .. | .. |
|---|
| 369 | 366 | pr_warn("%s: USB PHY CLK registration failed: %d\n", |
|---|
| 370 | 367 | __func__, ret); |
|---|
| 371 | 368 | |
|---|
| 369 | + gpiod_add_lookup_tables(hawk_usb_gpio_lookups, |
|---|
| 370 | + ARRAY_SIZE(hawk_usb_gpio_lookups)); |
|---|
| 371 | + |
|---|
| 372 | 372 | ret = da8xx_register_usb_phy(); |
|---|
| 373 | 373 | if (ret) |
|---|
| 374 | 374 | pr_warn("%s: USB PHY registration failed: %d\n", |
|---|
| 375 | 375 | __func__, ret); |
|---|
| 376 | 376 | |
|---|
| 377 | | - ret = gpio_request_one(DA850_USB1_VBUS_PIN, |
|---|
| 378 | | - GPIOF_DIR_OUT, "USB1 VBUS"); |
|---|
| 379 | | - if (ret < 0) { |
|---|
| 380 | | - pr_err("%s: failed to request GPIO for USB 1.1 port " |
|---|
| 381 | | - "power control: %d\n", __func__, ret); |
|---|
| 377 | + ret = platform_device_register(&hawk_usb_vbus_device); |
|---|
| 378 | + if (ret) { |
|---|
| 379 | + pr_warn("%s: Unable to register the vbus supply\n", __func__); |
|---|
| 382 | 380 | return; |
|---|
| 383 | 381 | } |
|---|
| 384 | 382 | |
|---|
| 385 | | - ret = gpio_request_one(DA850_USB1_OC_PIN, |
|---|
| 386 | | - GPIOF_DIR_IN, "USB1 OC"); |
|---|
| 387 | | - if (ret < 0) { |
|---|
| 388 | | - pr_err("%s: failed to request GPIO for USB 1.1 port " |
|---|
| 389 | | - "over-current indicator: %d\n", __func__, ret); |
|---|
| 390 | | - goto usb11_setup_oc_fail; |
|---|
| 391 | | - } |
|---|
| 392 | | - |
|---|
| 393 | 383 | ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata); |
|---|
| 394 | | - if (ret) { |
|---|
| 384 | + if (ret) |
|---|
| 395 | 385 | pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret); |
|---|
| 396 | | - goto usb11_setup_fail; |
|---|
| 397 | | - } |
|---|
| 398 | 386 | |
|---|
| 399 | 387 | return; |
|---|
| 400 | | - |
|---|
| 401 | | -usb11_setup_fail: |
|---|
| 402 | | - gpio_free(DA850_USB1_OC_PIN); |
|---|
| 403 | | -usb11_setup_oc_fail: |
|---|
| 404 | | - gpio_free(DA850_USB1_VBUS_PIN); |
|---|
| 405 | 388 | } |
|---|
| 406 | 389 | |
|---|
| 407 | 390 | static __init void omapl138_hawk_init(void) |
|---|
| .. | .. |
|---|
| 462 | 445 | MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard") |
|---|
| 463 | 446 | .atag_offset = 0x100, |
|---|
| 464 | 447 | .map_io = omapl138_hawk_map_io, |
|---|
| 465 | | - .init_irq = cp_intc_init, |
|---|
| 448 | + .init_irq = da850_init_irq, |
|---|
| 466 | 449 | .init_time = da850_init_time, |
|---|
| 467 | 450 | .init_machine = omapl138_hawk_init, |
|---|
| 468 | 451 | .init_late = davinci_init_late, |
|---|