linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: twl6040-vibra: Update for device tree support
@ 2012-05-16 11:19 Peter Ujfalusi
  2012-05-16 19:35 ` Dmitry Torokhov
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Ujfalusi @ 2012-05-16 11:19 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mark Brown, Liam Girdwood, Benoit Cousson, linux-kernel,
	devicetree-discuss, peter.ujfalusi

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>
---
Hi Dmitry,

There were a long discussion regarding of the originally planned DT support for
the twl6040 (MFD) chip over alsa-devel:
http://mailman.alsa-project.org/pipermail/alsa-devel/2012-May/051730.html

As a consequence I needed to change how this MFD device will be represented in
DT.
We will no longer load the child devices via DT, but use mfd_add_devices() will
create the child devices needed.
If we boot with DT the vibra will not have pdata and it will use the parent
device's node to get the needed parameters.

This patch is based on:
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git:next branch

The DT support for the twl6040 (v3) has been sent and I'm waiting for a review:
http://marc.info/?l=linux-kernel&m=133716693518701&w=2

Best Regards,
Peter

 .../devicetree/bindings/input/twl6040-vibra.txt    |   37 -----------------
 drivers/input/misc/twl6040-vibra.c                 |   42 ++++++++++++--------
 2 files changed, 25 insertions(+), 54 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/twl6040-vibra.txt

diff --git a/Documentation/devicetree/bindings/input/twl6040-vibra.txt b/Documentation/devicetree/bindings/input/twl6040-vibra.txt
deleted file mode 100644
index 5b1918b..0000000
--- a/Documentation/devicetree/bindings/input/twl6040-vibra.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-Vibra driver for the twl6040 family
-
-The vibra driver is a child of the twl6040 MFD dirver.
-Documentation/devicetree/bindings/mfd/twl6040.txt
-
-Required properties:
-- compatible : Must be "ti,twl6040-vibra";
-- interrupts: 4, Vibra overcurrent interrupt
-- vddvibl-supply: Regulator supplying the left vibra motor
-- vddvibr-supply: Regulator supplying the right vibra motor
-- vibldrv_res: Board specific left driver resistance
-- vibrdrv_res: Board specific right driver resistance
-- viblmotor_res: Board specific left motor resistance
-- vibrmotor_res: Board specific right motor resistance
-
-Optional properties:
-- vddvibl_uV: If the vddvibl default voltage need to be changed
-- vddvibr_uV: If the vddvibr default voltage need to be changed
-
-Example:
-/*
- * 8-channel high quality low-power audio codec
- * http://www.ti.com/lit/ds/symlink/twl6040.pdf
- */
-twl6040: twl6040@4b {
-	...
-	twl6040_vibra: twl6040@1 {
-		compatible = "ti,twl6040-vibra";
-		interrupts = <4>;
-		vddvibl-supply = <&vbat>;
-		vddvibr-supply = <&vbat>;
-		vibldrv_res = <8>;
-		vibrdrv_res = <3>;
-		viblmotor_res = <10>;
-		vibrmotor_res = <10>;
-	};
-};
diff --git a/drivers/input/misc/twl6040-vibra.c b/drivers/input/misc/twl6040-vibra.c
index c34f6c0..4d36666 100644
--- a/drivers/input/misc/twl6040-vibra.c
+++ b/drivers/input/misc/twl6040-vibra.c
@@ -259,13 +259,15 @@ static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops, twl6040_vibra_suspend, NULL);
 static int __devinit twl6040_vibra_probe(struct platform_device *pdev)
 {
 	struct twl6040_vibra_data *pdata = pdev->dev.platform_data;
-	struct device_node *node = pdev->dev.of_node;
+	struct device *twl6040_core_dev = pdev->dev.parent;
+	struct device_node *twl6040_core_node = of_find_node_by_name(
+					twl6040_core_dev->of_node, "vibra");
 	struct vibra_info *info;
 	int vddvibl_uV = 0;
 	int vddvibr_uV = 0;
 	int ret;
 
-	if (!pdata && !node) {
+	if (!pdata && !twl6040_core_node) {
 		dev_err(&pdev->dev, "platform_data not available\n");
 		return -EINVAL;
 	}
@@ -287,14 +289,18 @@ static int __devinit twl6040_vibra_probe(struct platform_device *pdev)
 		vddvibl_uV = pdata->vddvibl_uV;
 		vddvibr_uV = pdata->vddvibr_uV;
 	} else {
-		of_property_read_u32(node, "vibldrv_res", &info->vibldrv_res);
-		of_property_read_u32(node, "vibrdrv_res", &info->vibrdrv_res);
-		of_property_read_u32(node, "viblmotor_res",
+		of_property_read_u32(twl6040_core_node, "ti,vibldrv-res",
+				     &info->vibldrv_res);
+		of_property_read_u32(twl6040_core_node, "ti,vibrdrv-res",
+				     &info->vibrdrv_res);
+		of_property_read_u32(twl6040_core_node, "ti,viblmotor-res",
 				     &info->viblmotor_res);
-		of_property_read_u32(node, "vibrmotor_res",
+		of_property_read_u32(twl6040_core_node, "ti,vibrmotor-res",
 				     &info->vibrmotor_res);
-		of_property_read_u32(node, "vddvibl_uV", &vddvibl_uV);
-		of_property_read_u32(node, "vddvibr_uV", &vddvibr_uV);
+		of_property_read_u32(twl6040_core_node, "ti,vddvibl-uV",
+				     &vddvibl_uV);
+		of_property_read_u32(twl6040_core_node, "ti,vddvibr-uV",
+				     &vddvibr_uV);
 	}
 
 	if ((!info->vibldrv_res && !info->viblmotor_res) ||
@@ -351,8 +357,17 @@ static int __devinit twl6040_vibra_probe(struct platform_device *pdev)
 
 	info->supplies[0].supply = "vddvibl";
 	info->supplies[1].supply = "vddvibr";
-	ret = regulator_bulk_get(info->dev, ARRAY_SIZE(info->supplies),
-				 info->supplies);
+	/*
+	 * When booted with Device tree the regulators are attached to the
+	 * parent device (twl6040 MFD core)
+	 */
+	if (pdata)
+		ret = regulator_bulk_get(info->dev, ARRAY_SIZE(info->supplies),
+					info->supplies);
+	else
+		ret = regulator_bulk_get(twl6040_core_dev,
+					 ARRAY_SIZE(info->supplies),
+					 info->supplies);
 	if (ret) {
 		dev_err(info->dev, "couldn't get regulators %d\n", ret);
 		goto err_regulator;
@@ -418,12 +433,6 @@ static int __devexit twl6040_vibra_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static const struct of_device_id twl6040_vibra_of_match[] = {
-	{.compatible = "ti,twl6040-vibra", },
-	{ },
-};
-MODULE_DEVICE_TABLE(of, twl6040_vibra_of_match);
-
 static struct platform_driver twl6040_vibra_driver = {
 	.probe		= twl6040_vibra_probe,
 	.remove		= __devexit_p(twl6040_vibra_remove),
@@ -431,7 +440,6 @@ static struct platform_driver twl6040_vibra_driver = {
 		.name	= "twl6040-vibra",
 		.owner	= THIS_MODULE,
 		.pm	= &twl6040_vibra_pm_ops,
-		.of_match_table = twl6040_vibra_of_match,
 	},
 };
 module_platform_driver(twl6040_vibra_driver);
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: twl6040-vibra: Update for device tree support
  2012-05-16 11:19 [PATCH] Input: twl6040-vibra: Update for device tree support Peter Ujfalusi
@ 2012-05-16 19:35 ` Dmitry Torokhov
  2012-05-16 19:55   ` Ujfalusi, Peter
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2012-05-16 19:35 UTC (permalink / raw)
  To: Peter Ujfalusi
  Cc: Mark Brown, Liam Girdwood, Benoit Cousson, linux-kernel,
	devicetree-discuss

Hi Peter,

On Wed, May 16, 2012 at 02:19:46PM +0300, Peter Ujfalusi wrote:
> 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.

So in this case why don't you have parent parse all DT data and
construct instance of pdata for vibra driver to consume?

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: twl6040-vibra: Update for device tree support
  2012-05-16 19:35 ` Dmitry Torokhov
@ 2012-05-16 19:55   ` Ujfalusi, Peter
  2012-05-17  0:59     ` Dmitry Torokhov
  2012-05-21  5:32     ` Dmitry Torokhov
  0 siblings, 2 replies; 5+ messages in thread
From: Ujfalusi, Peter @ 2012-05-16 19:55 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Mark Brown, Liam Girdwood, Benoit Cousson, linux-kernel,
	devicetree-discuss

Hi Dmitry,

On Wed, May 16, 2012 at 10:35 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> So in this case why don't you have parent parse all DT data and
> construct instance of pdata for vibra driver to consume?

If there is a need to change the parameters (add new ones for example)
for the vibra driver in this way the change in code only need to be
done in the vibra driver.
If the MFD core would construct the pdata, in this case I would need
to modify both the MFD core and vibra driver.

-- 
Péter

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: twl6040-vibra: Update for device tree support
  2012-05-16 19:55   ` Ujfalusi, Peter
@ 2012-05-17  0:59     ` Dmitry Torokhov
  2012-05-21  5:32     ` Dmitry Torokhov
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2012-05-17  0:59 UTC (permalink / raw)
  To: Ujfalusi, Peter
  Cc: Mark Brown, Liam Girdwood, Benoit Cousson, linux-kernel,
	devicetree-discuss

"Ujfalusi, Peter" <peter.ujfalusi@ti.com> wrote:

>Hi Dmitry,
>
>On Wed, May 16, 2012 at 10:35 PM, Dmitry Torokhov
><dmitry.torokhov@gmail.com> wrote:
>> So in this case why don't you have parent parse all DT data and
>> construct instance of pdata for vibra driver to consume?
>
>If there is a need to change the parameters (add new ones for example)
>for the vibra driver in this way the change in code only need to be
>done in the vibra driver.
>If the MFD core would construct the pdata, in this case I would need
>to modify both the MFD core and vibra driver.
>

Ok, fair enough.

Thanks.


--
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: twl6040-vibra: Update for device tree support
  2012-05-16 19:55   ` Ujfalusi, Peter
  2012-05-17  0:59     ` Dmitry Torokhov
@ 2012-05-21  5:32     ` Dmitry Torokhov
  1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Torokhov @ 2012-05-21  5:32 UTC (permalink / raw)
  To: Ujfalusi, Peter
  Cc: Mark Brown, Liam Girdwood, Benoit Cousson, linux-kernel,
	devicetree-discuss

On Wed, May 16, 2012 at 10:55:13PM +0300, Ujfalusi, Peter wrote:
> Hi Dmitry,
> 
> On Wed, May 16, 2012 at 10:35 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > So in this case why don't you have parent parse all DT data and
> > construct instance of pdata for vibra driver to consume?
> 
> If there is a need to change the parameters (add new ones for example)
> for the vibra driver in this way the change in code only need to be
> done in the vibra driver.
> If the MFD core would construct the pdata, in this case I would need
> to modify both the MFD core and vibra driver.

Hmm, I am getting:

  CC      drivers/input/misc/twl6040-vibra.o
drivers/input/misc/twl6040-vibra.c: In function ‘twl6040_vibra_probe’:
drivers/input/misc/twl6040-vibra.c:263:9: error: implicit declaration of
function ‘of_find_node_by_name’ [-Werror=implicit-function-declaration]
drivers/input/misc/twl6040-vibra.c:263:42: warning: initialization makes
pointer from integer without a cast [enabled by default]
cc1: some warnings being treated as errors
make[1]: *** [drivers/input/misc/twl6040-vibra.o] Error 1
make: *** [drivers/input/misc/twl6040-vibra.o] Error 2


it looks like there is no stub for of_find_node_by_name().

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-21  5:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-16 11:19 [PATCH] Input: twl6040-vibra: Update for device tree support Peter Ujfalusi
2012-05-16 19:35 ` Dmitry Torokhov
2012-05-16 19:55   ` Ujfalusi, Peter
2012-05-17  0:59     ` Dmitry Torokhov
2012-05-21  5:32     ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).