[alsa-devel] [PATCH] ASoC: twl6040: Support for DT

Peter Ujfalusi peter.ujfalusi at ti.com
Tue May 15 10:00:25 CEST 2012

Hi Mark,

On 05/14/2012 03:11 PM, Mark Brown wrote:
> I'm just not seeing anything in the device tree that abstracts the chip
> top level from the function drivers; if there were then it'd be very
> much easier to see a general use for this.

While we are discussing on how to handle the twl6040 MFD deive via DT
and to whether load the child drivers via DT or to load them via
mfd_add_devices() I came up with this dts entry for the later case
(mfd_add_devices mode):

&i2c1 {
	twl6040: twl at 4b {
		compatible = "ti,twl6040";
		reg = <0x4b>;

		interrupts = <0 119 4>;
		interrupt-parent = <&gic>;
		twl6040,audpwron-gpio = <&gpio4 31 0>;

		vio-supply = <&v1v8>;
		v2v1-supply = <&v2v1>;

		/* regulators for vibra motor */
		vddvibl-supply = <&vbat>;
		vddvibr-supply = <&vbat>;

		vibra {
			/* Vibra driver, motor resistance parameters */
			ti,vibldrv-res = <8>;
			ti,vibrdrv-res = <3>;
			ti,viblmotor-res = <10>;
			ti,vibrmotor-res = <10>;

With this mode:
No need to tell that twl6040 is acts as interrupt controller since the
interrupts it is handling is only for internal functions dispatched via
a single irq line toward the CPU.

The audio (ASoC codec) child is always enabled since it is the main
function of the twl6040.

The tricky part is the vibra: it needs two regulators (to provide power
to the motors). Since the regulators can only be connected to the device
described in dt, this is what I need to do:
to get the vibra parameters (in the twl6040-vibra driver):

struct device_node *node = of_find_node_by_name(
				pdev->dev.parent->of_node, "vibra");

of_property_read_u32(node, "ti,vibldrv-res", &info->vibldrv_res);

To get the regulators needed by the vibra driver when booted with DT:

info->supplies[0].supply = "vddvibl";
info->supplies[1].supply = "vddvibr";
if (!pdata)
	ret = regulator_bulk_get(pdev->dev.parent,
		ARRAY_SIZE(info->supplies), info->supplies);
	ret = regulator_bulk_get(info->dev,
		ARRAY_SIZE(info->supplies), info->supplies);

I need to use the pdev->dev.parent to be able to get the needed
regulators. Is this acceptable?


More information about the Alsa-devel mailing list