Commit e7ec014a47e4d68fc01561d0541a50650646317c

Authored by Peter Ujfalusi
Committed by Dmitry Torokhov
1 parent 32edbf562c

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>

Showing 2 changed files with 24 additions and 55 deletions Side-by-side Diff

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   -};
drivers/input/misc/twl6040-vibra.c
... ... @@ -251,7 +251,6 @@
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 257  
... ... @@ -259,13 +258,19 @@
259 258 static int __devinit twl6040_vibra_probe(struct platform_device *pdev)
260 259 {
261 260 struct twl6040_vibra_data *pdata = pdev->dev.platform_data;
262   - struct device_node *node = pdev->dev.of_node;
  261 + struct device *twl6040_core_dev = pdev->dev.parent;
  262 + struct device_node *twl6040_core_node = NULL;
263 263 struct vibra_info *info;
264 264 int vddvibl_uV = 0;
265 265 int vddvibr_uV = 0;
266 266 int ret;
267 267  
268   - if (!pdata && !node) {
  268 +#ifdef CONFIG_OF
  269 + twl6040_core_node = of_find_node_by_name(twl6040_core_dev->of_node,
  270 + "vibra");
  271 +#endif
  272 +
  273 + if (!pdata && !twl6040_core_node) {
269 274 dev_err(&pdev->dev, "platform_data not available\n");
270 275 return -EINVAL;
271 276 }
272 277  
273 278  
... ... @@ -287,14 +292,18 @@
287 292 vddvibl_uV = pdata->vddvibl_uV;
288 293 vddvibr_uV = pdata->vddvibr_uV;
289 294 } else {
290   - of_property_read_u32(node, "vibldrv_res", &info->vibldrv_res);
291   - of_property_read_u32(node, "vibrdrv_res", &info->vibrdrv_res);
292   - of_property_read_u32(node, "viblmotor_res",
  295 + of_property_read_u32(twl6040_core_node, "ti,vibldrv-res",
  296 + &info->vibldrv_res);
  297 + of_property_read_u32(twl6040_core_node, "ti,vibrdrv-res",
  298 + &info->vibrdrv_res);
  299 + of_property_read_u32(twl6040_core_node, "ti,viblmotor-res",
293 300 &info->viblmotor_res);
294   - of_property_read_u32(node, "vibrmotor_res",
  301 + of_property_read_u32(twl6040_core_node, "ti,vibrmotor-res",
295 302 &info->vibrmotor_res);
296   - of_property_read_u32(node, "vddvibl_uV", &vddvibl_uV);
297   - of_property_read_u32(node, "vddvibr_uV", &vddvibr_uV);
  303 + of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV",
  304 + &vddvibl_uV);
  305 + of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV",
  306 + &vddvibr_uV);
298 307 }
299 308  
300 309 if ((!info->vibldrv_res && !info->viblmotor_res) ||
... ... @@ -351,8 +360,12 @@
351 360  
352 361 info->supplies[0].supply = "vddvibl";
353 362 info->supplies[1].supply = "vddvibr";
354   - ret = regulator_bulk_get(info->dev, ARRAY_SIZE(info->supplies),
355   - info->supplies);
  363 + /*
  364 + * When booted with Device tree the regulators are attached to the
  365 + * parent device (twl6040 MFD core)
  366 + */
  367 + ret = regulator_bulk_get(pdata ? info->dev : twl6040_core_dev,
  368 + ARRAY_SIZE(info->supplies), info->supplies);
356 369 if (ret) {
357 370 dev_err(info->dev, "couldn't get regulators %d\n", ret);
358 371 goto err_regulator;
... ... @@ -418,12 +431,6 @@
418 431 return 0;
419 432 }
420 433  
421   -static const struct of_device_id twl6040_vibra_of_match[] = {
422   - {.compatible = "ti,twl6040-vibra", },
423   - { },
424   -};
425   -MODULE_DEVICE_TABLE(of, twl6040_vibra_of_match);
426   -
427 434 static struct platform_driver twl6040_vibra_driver = {
428 435 .probe = twl6040_vibra_probe,
429 436 .remove = __devexit_p(twl6040_vibra_remove),
... ... @@ -431,7 +438,6 @@
431 438 .name = "twl6040-vibra",
432 439 .owner = THIS_MODULE,
433 440 .pm = &twl6040_vibra_pm_ops,
434   - .of_match_table = twl6040_vibra_of_match,
435 441 },
436 442 };
437 443 module_platform_driver(twl6040_vibra_driver);