Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: twl6040-vibra - update for device tree support

The twl6040 DT support implementation has been changed from the
originally planned. None of the child devices going to have
compatible_of property which means that the child devices of twl6040
will be created as traditional MFD devices. The mfd core driver will
decide (based on the DT blob) to create a device for the twl6040-vibra
or not. If the DT blob has 'vibra' section the device will be created
without pdata. In this case the vibra driver will reach up to the
parent node to get the needed properties.

With DT booted kernel we no longer be able to link the regulators to
the vibra driver, they can be only linked to the MFD device (probed
via DT). From the vibra driver we ned to use pdev->dev.parent to get
the regulators.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

authored by

Peter Ujfalusi and committed by
Dmitry Torokhov
e7ec014a 32edbf56

+24 -55
-37
Documentation/devicetree/bindings/input/twl6040-vibra.txt
··· 1 - Vibra driver for the twl6040 family 2 - 3 - The vibra driver is a child of the twl6040 MFD dirver. 4 - Documentation/devicetree/bindings/mfd/twl6040.txt 5 - 6 - Required properties: 7 - - compatible : Must be "ti,twl6040-vibra"; 8 - - interrupts: 4, Vibra overcurrent interrupt 9 - - vddvibl-supply: Regulator supplying the left vibra motor 10 - - vddvibr-supply: Regulator supplying the right vibra motor 11 - - vibldrv_res: Board specific left driver resistance 12 - - vibrdrv_res: Board specific right driver resistance 13 - - viblmotor_res: Board specific left motor resistance 14 - - vibrmotor_res: Board specific right motor resistance 15 - 16 - Optional properties: 17 - - vddvibl_uV: If the vddvibl default voltage need to be changed 18 - - vddvibr_uV: If the vddvibr default voltage need to be changed 19 - 20 - Example: 21 - /* 22 - * 8-channel high quality low-power audio codec 23 - * http://www.ti.com/lit/ds/symlink/twl6040.pdf 24 - */ 25 - twl6040: twl6040@4b { 26 - ... 27 - twl6040_vibra: twl6040@1 { 28 - compatible = "ti,twl6040-vibra"; 29 - interrupts = <4>; 30 - vddvibl-supply = <&vbat>; 31 - vddvibr-supply = <&vbat>; 32 - vibldrv_res = <8>; 33 - vibrdrv_res = <3>; 34 - viblmotor_res = <10>; 35 - vibrmotor_res = <10>; 36 - }; 37 - };
+24 -18
drivers/input/misc/twl6040-vibra.c
··· 251 251 252 252 return 0; 253 253 } 254 - 255 254 #endif 256 255 257 256 static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL); ··· 258 259 static int __devinit twl6040_vibra_probe(struct platform_device *pdev) 259 260 { 260 261 struct twl6040_vibra_data *pdata = pdev->dev.platform_data; 261 - struct device_node *node = pdev->dev.of_node; 262 + struct device *twl6040_core_dev = pdev->dev.parent; 263 + struct device_node *twl6040_core_node = NULL; 262 264 struct vibra_info *info; 263 265 int vddvibl_uV = 0; 264 266 int vddvibr_uV = 0; 265 267 int ret; 266 268 267 - if (!pdata && !node) { 269 + #ifdef CONFIG_OF 270 + twl6040_core_node = of_find_node_by_name(twl6040_core_dev->of_node, 271 + "vibra"); 272 + #endif 273 + 274 + if (!pdata && !twl6040_core_node) { 268 275 dev_err(&pdev->dev, "platform_data not available\n"); 269 276 return -EINVAL; 270 277 } ··· 292 287 vddvibl_uV = pdata->vddvibl_uV; 293 288 vddvibr_uV = pdata->vddvibr_uV; 294 289 } else { 295 - of_property_read_u32(node, "vibldrv_res", &info->vibldrv_res); 296 - of_property_read_u32(node, "vibrdrv_res", &info->vibrdrv_res); 297 - of_property_read_u32(node, "viblmotor_res", 290 + of_property_read_u32(twl6040_core_node, "ti,vibldrv-res", 291 + &info->vibldrv_res); 292 + of_property_read_u32(twl6040_core_node, "ti,vibrdrv-res", 293 + &info->vibrdrv_res); 294 + of_property_read_u32(twl6040_core_node, "ti,viblmotor-res", 298 295 &info->viblmotor_res); 299 - of_property_read_u32(node, "vibrmotor_res", 296 + of_property_read_u32(twl6040_core_node, "ti,vibrmotor-res", 300 297 &info->vibrmotor_res); 301 - of_property_read_u32(node, "vddvibl_uV", &vddvibl_uV); 302 - of_property_read_u32(node, "vddvibr_uV", &vddvibr_uV); 298 + of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV", 299 + &vddvibl_uV); 300 + of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV", 301 + &vddvibr_uV); 303 302 } 304 303 305 304 if ((!info->vibldrv_res && !info->viblmotor_res) || ··· 360 351 361 352 info->supplies[0].supply = "vddvibl"; 362 353 info->supplies[1].supply = "vddvibr"; 363 - ret = regulator_bulk_get(info->dev, ARRAY_SIZE(info->supplies), 364 - info->supplies); 354 + /* 355 + * When booted with Device tree the regulators are attached to the 356 + * parent device (twl6040 MFD core) 357 + */ 358 + ret = regulator_bulk_get(pdata ? info->dev : twl6040_core_dev, 359 + ARRAY_SIZE(info->supplies), info->supplies); 365 360 if (ret) { 366 361 dev_err(info->dev, "couldn't get regulators %d\n", ret); 367 362 goto err_regulator; ··· 431 418 return 0; 432 419 } 433 420 434 - static const struct of_device_id twl6040_vibra_of_match[] = { 435 - {.compatible = "ti,twl6040-vibra", }, 436 - { }, 437 - }; 438 - MODULE_DEVICE_TABLE(of, twl6040_vibra_of_match); 439 - 440 421 static struct platform_driver twl6040_vibra_driver = { 441 422 .probe = twl6040_vibra_probe, 442 423 .remove = __devexit_p(twl6040_vibra_remove), ··· 438 431 .name = "twl6040-vibra", 439 432 .owner = THIS_MODULE, 440 433 .pm = &twl6040_vibra_pm_ops, 441 - .of_match_table = twl6040_vibra_of_match, 442 434 }, 443 435 }; 444 436 module_platform_driver(twl6040_vibra_driver);