diff mbox

[v2] mfd: arizona: Add DT options for max_channels_clocked and PDM speaker config

Message ID 1472635543-21577-1-git-send-email-rf@opensource.wolfsonmicro.com
State Superseded, archived
Headers show

Commit Message

Richard Fitzgerald Aug. 31, 2016, 9:25 a.m. UTC
This patch adds DT settings for the max_channels_clocked, spk_fmt and
spk_mute pdata.

Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
---
 Documentation/devicetree/bindings/mfd/arizona.txt | 11 ++++++++
 drivers/mfd/arizona-core.c                        | 31 +++++++++++++++++++++++
 2 files changed, 42 insertions(+)

Comments

Lee Jones Aug. 31, 2016, 12:15 p.m. UTC | #1
Requires a DT Ack.

On Wed, 31 Aug 2016, Richard Fitzgerald wrote:

> This patch adds DT settings for the max_channels_clocked, spk_fmt and
> spk_mute pdata.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> ---
>  Documentation/devicetree/bindings/mfd/arizona.txt | 11 ++++++++
>  drivers/mfd/arizona-core.c                        | 31 +++++++++++++++++++++++
>  2 files changed, 42 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> index a6e2ea41..6eaf006 100644
> --- a/Documentation/devicetree/bindings/mfd/arizona.txt
> +++ b/Documentation/devicetree/bindings/mfd/arizona.txt
> @@ -85,6 +85,17 @@ Optional properties:
>      present, the number of values should be less than or equal to the
>      number of inputs, unspecified inputs will use the chip default.
>  
> +  - wlf,max-channels-clocked : The maximum number of channels to be clocked on
> +    each AIF, useful for I2S systems with multiple data lines being mastered.
> +    Specify one cell for each AIF, specify zero for AIFs that should be handled
> +    normally.
> +
> +  - wlf,spk-fmt : PDM speaker data format, must contain 2 cells (OUT5 and OUT6).
> +    See the datasheet for values.
> +
> +  - wlf,spk-mute : PDM speaker mute setting, must contain 2 cells (OUT5 and OUT6).
> +    See the datasheet for values.
> +
>    - DCVDD-supply, MICVDD-supply : Power supplies, only need to be specified if
>      they are being externally supplied. As covered in
>      Documentation/devicetree/bindings/regulator/regulator.txt
> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index b95ff2d..36a9633 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -816,6 +816,37 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
>  		count++;
>  	}
>  
> +	count = 0;
> +	of_property_for_each_u32(arizona->dev->of_node,
> +				 "wlf,max-channels-clocked",
> +				 prop, cur, val) {
> +		if (count == ARRAY_SIZE(pdata->max_channels_clocked))
> +			break;
> +
> +		pdata->max_channels_clocked[count] = val;
> +		count++;
> +	}
> +
> +	count = 0;
> +	of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-fmt", prop,
> +				 cur, val) {
> +		if (count == ARRAY_SIZE(pdata->spk_fmt))
> +			break;
> +
> +		pdata->spk_fmt[count] = val;
> +		count++;
> +	}
> +
> +	count = 0;
> +	of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-mute", prop,
> +				 cur, val) {
> +		if (count == ARRAY_SIZE(pdata->spk_mute))
> +			break;
> +
> +		pdata->spk_mute[count] = val;
> +		count++;
> +	}
> +
>  	return 0;
>  }
>
Rob Herring Sept. 2, 2016, 3:34 p.m. UTC | #2
On Wed, Aug 31, 2016 at 10:25:43AM +0100, Richard Fitzgerald wrote:
> This patch adds DT settings for the max_channels_clocked, spk_fmt and
> spk_mute pdata.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> ---
>  Documentation/devicetree/bindings/mfd/arizona.txt | 11 ++++++++

Binding looks fine, but...

>  drivers/mfd/arizona-core.c                        | 31 +++++++++++++++++++++++
>  2 files changed, 42 insertions(+)

> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index b95ff2d..36a9633 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -816,6 +816,37 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
>  		count++;
>  	}
>  
> +	count = 0;
> +	of_property_for_each_u32(arizona->dev->of_node,
> +				 "wlf,max-channels-clocked",
> +				 prop, cur, val) {
> +		if (count == ARRAY_SIZE(pdata->max_channels_clocked))
> +			break;
> +
> +		pdata->max_channels_clocked[count] = val;
> +		count++;
> +	}

of_property_read_u32_array doesn't work for you?

> +
> +	count = 0;
> +	of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-fmt", prop,
> +				 cur, val) {
> +		if (count == ARRAY_SIZE(pdata->spk_fmt))
> +			break;
> +
> +		pdata->spk_fmt[count] = val;
> +		count++;
> +	}
> +
> +	count = 0;
> +	of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-mute", prop,
> +				 cur, val) {
> +		if (count == ARRAY_SIZE(pdata->spk_mute))
> +			break;
> +
> +		pdata->spk_mute[count] = val;
> +		count++;
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Fitzgerald Sept. 2, 2016, 3:56 p.m. UTC | #3
On Fri, 2016-09-02 at 10:34 -0500, Rob Herring wrote:
> On Wed, Aug 31, 2016 at 10:25:43AM +0100, Richard Fitzgerald wrote:
> > This patch adds DT settings for the max_channels_clocked, spk_fmt and
> > spk_mute pdata.
> > 
> > Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> > ---
> >  Documentation/devicetree/bindings/mfd/arizona.txt | 11 ++++++++
> 
> Binding looks fine, but...
> 
> >  drivers/mfd/arizona-core.c                        | 31 +++++++++++++++++++++++
> >  2 files changed, 42 insertions(+)
> 
> > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> > index b95ff2d..36a9633 100644
> > --- a/drivers/mfd/arizona-core.c
> > +++ b/drivers/mfd/arizona-core.c
> > @@ -816,6 +816,37 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
> >  		count++;
> >  	}
> >  
> > +	count = 0;
> > +	of_property_for_each_u32(arizona->dev->of_node,
> > +				 "wlf,max-channels-clocked",
> > +				 prop, cur, val) {
> > +		if (count == ARRAY_SIZE(pdata->max_channels_clocked))
> > +			break;
> > +
> > +		pdata->max_channels_clocked[count] = val;
> > +		count++;
> > +	}
> 
> of_property_read_u32_array doesn't work for you?

No, it doesn't, because it doesn't read a variable-sized array.

> 
> > +
> > +	count = 0;
> > +	of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-fmt", prop,
> > +				 cur, val) {
> > +		if (count == ARRAY_SIZE(pdata->spk_fmt))
> > +			break;
> > +
> > +		pdata->spk_fmt[count] = val;
> > +		count++;
> > +	}
> > +
> > +	count = 0;
> > +	of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-mute", prop,
> > +				 cur, val) {
> > +		if (count == ARRAY_SIZE(pdata->spk_mute))
> > +			break;
> > +
> > +		pdata->spk_mute[count] = val;
> > +		count++;
> > +	}
> > +
> >  	return 0;
> >  }
> >  
> > -- 
> > 1.9.1
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe devicetree" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rob Herring Sept. 2, 2016, 5:51 p.m. UTC | #4
On Fri, Sep 2, 2016 at 10:56 AM, Richard Fitzgerald
<rf@opensource.wolfsonmicro.com> wrote:
> On Fri, 2016-09-02 at 10:34 -0500, Rob Herring wrote:
>> On Wed, Aug 31, 2016 at 10:25:43AM +0100, Richard Fitzgerald wrote:
>> > This patch adds DT settings for the max_channels_clocked, spk_fmt and
>> > spk_mute pdata.
>> >
>> > Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
>> > ---
>> >  Documentation/devicetree/bindings/mfd/arizona.txt | 11 ++++++++
>>
>> Binding looks fine, but...
>>
>> >  drivers/mfd/arizona-core.c                        | 31 +++++++++++++++++++++++
>> >  2 files changed, 42 insertions(+)
>>
>> > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
>> > index b95ff2d..36a9633 100644
>> > --- a/drivers/mfd/arizona-core.c
>> > +++ b/drivers/mfd/arizona-core.c
>> > @@ -816,6 +816,37 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
>> >             count++;
>> >     }
>> >
>> > +   count = 0;
>> > +   of_property_for_each_u32(arizona->dev->of_node,
>> > +                            "wlf,max-channels-clocked",
>> > +                            prop, cur, val) {
>> > +           if (count == ARRAY_SIZE(pdata->max_channels_clocked))
>> > +                   break;
>> > +
>> > +           pdata->max_channels_clocked[count] = val;
>> > +           count++;
>> > +   }
>>
>> of_property_read_u32_array doesn't work for you?
>
> No, it doesn't, because it doesn't read a variable-sized array.

But the next 2 loops are fixed with 2 elements, right? They should be
converted. If not fixed size, you have the same pattern repeated 3
times.

Maybe we should fix of_property_read_u32_array to be more flexible and
return an array less than a max size. Not sure if anyone relies on
that case failing though, so leaving the 1st loop is fine.

Rob

>> > +   count = 0;
>> > +   of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-fmt", prop,
>> > +                            cur, val) {
>> > +           if (count == ARRAY_SIZE(pdata->spk_fmt))
>> > +                   break;
>> > +
>> > +           pdata->spk_fmt[count] = val;
>> > +           count++;
>> > +   }
>> > +
>> > +   count = 0;
>> > +   of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-mute", prop,
>> > +                            cur, val) {
>> > +           if (count == ARRAY_SIZE(pdata->spk_mute))
>> > +                   break;
>> > +
>> > +           pdata->spk_mute[count] = val;
>> > +           count++;
>> > +   }
>> > +
>> >     return 0;
>> >  }
>> >
>> > --
>> > 1.9.1
>> >
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe devicetree" in
>> > the body of a message to majordomo@vger.kernel.org
>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Fitzgerald Sept. 5, 2016, 9:22 a.m. UTC | #5
On Fri, 2016-09-02 at 12:51 -0500, Rob Herring wrote:
> On Fri, Sep 2, 2016 at 10:56 AM, Richard Fitzgerald
> <rf@opensource.wolfsonmicro.com> wrote:
> > On Fri, 2016-09-02 at 10:34 -0500, Rob Herring wrote:
> >> On Wed, Aug 31, 2016 at 10:25:43AM +0100, Richard Fitzgerald wrote:
> >> > This patch adds DT settings for the max_channels_clocked, spk_fmt and
> >> > spk_mute pdata.
> >> >
> >> > Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
> >> > ---
> >> >  Documentation/devicetree/bindings/mfd/arizona.txt | 11 ++++++++
> >>
> >> Binding looks fine, but...
> >>
> >> >  drivers/mfd/arizona-core.c                        | 31 +++++++++++++++++++++++
> >> >  2 files changed, 42 insertions(+)
> >>
> >> > diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> >> > index b95ff2d..36a9633 100644
> >> > --- a/drivers/mfd/arizona-core.c
> >> > +++ b/drivers/mfd/arizona-core.c
> >> > @@ -816,6 +816,37 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
> >> >             count++;
> >> >     }
> >> >
> >> > +   count = 0;
> >> > +   of_property_for_each_u32(arizona->dev->of_node,
> >> > +                            "wlf,max-channels-clocked",
> >> > +                            prop, cur, val) {
> >> > +           if (count == ARRAY_SIZE(pdata->max_channels_clocked))
> >> > +                   break;
> >> > +
> >> > +           pdata->max_channels_clocked[count] = val;
> >> > +           count++;
> >> > +   }
> >>
> >> of_property_read_u32_array doesn't work for you?
> >
> > No, it doesn't, because it doesn't read a variable-sized array.
> 
> But the next 2 loops are fixed with 2 elements, right? They should be

Ok, that's true the code is flexible size (because the number of AIFs
and the number of outputs varies between codecs, and the number actually
in use also varies) but the binding documentation I pulled in hasn't
been updated to match the code.

> converted. If not fixed size, you have the same pattern repeated 3
> times.

We originally had duplicated DT code in our driver factored out into
functions but this was rejected by mfd maintainer in favour of only
using the standard functions and duplicating code if necessary. I didn't
upstream that original patch so I don't know now what the justification
was.

> 
> Maybe we should fix of_property_read_u32_array to be more flexible and
> return an array less than a max size. Not sure if anyone relies on
> that case failing though, so leaving the 1st loop is fine.
> 
> Rob
> 
> >> > +   count = 0;
> >> > +   of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-fmt", prop,
> >> > +                            cur, val) {
> >> > +           if (count == ARRAY_SIZE(pdata->spk_fmt))
> >> > +                   break;
> >> > +
> >> > +           pdata->spk_fmt[count] = val;
> >> > +           count++;
> >> > +   }
> >> > +
> >> > +   count = 0;
> >> > +   of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-mute", prop,
> >> > +                            cur, val) {
> >> > +           if (count == ARRAY_SIZE(pdata->spk_mute))
> >> > +                   break;
> >> > +
> >> > +           pdata->spk_mute[count] = val;
> >> > +           count++;
> >> > +   }
> >> > +
> >> >     return 0;
> >> >  }
> >> >
> >> > --
> >> > 1.9.1
> >> >
> >> > --
> >> > To unsubscribe from this list: send the line "unsubscribe devicetree" in
> >> > the body of a message to majordomo@vger.kernel.org
> >> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> >


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index a6e2ea41..6eaf006 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -85,6 +85,17 @@  Optional properties:
     present, the number of values should be less than or equal to the
     number of inputs, unspecified inputs will use the chip default.
 
+  - wlf,max-channels-clocked : The maximum number of channels to be clocked on
+    each AIF, useful for I2S systems with multiple data lines being mastered.
+    Specify one cell for each AIF, specify zero for AIFs that should be handled
+    normally.
+
+  - wlf,spk-fmt : PDM speaker data format, must contain 2 cells (OUT5 and OUT6).
+    See the datasheet for values.
+
+  - wlf,spk-mute : PDM speaker mute setting, must contain 2 cells (OUT5 and OUT6).
+    See the datasheet for values.
+
   - DCVDD-supply, MICVDD-supply : Power supplies, only need to be specified if
     they are being externally supplied. As covered in
     Documentation/devicetree/bindings/regulator/regulator.txt
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index b95ff2d..36a9633 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -816,6 +816,37 @@  static int arizona_of_get_core_pdata(struct arizona *arizona)
 		count++;
 	}
 
+	count = 0;
+	of_property_for_each_u32(arizona->dev->of_node,
+				 "wlf,max-channels-clocked",
+				 prop, cur, val) {
+		if (count == ARRAY_SIZE(pdata->max_channels_clocked))
+			break;
+
+		pdata->max_channels_clocked[count] = val;
+		count++;
+	}
+
+	count = 0;
+	of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-fmt", prop,
+				 cur, val) {
+		if (count == ARRAY_SIZE(pdata->spk_fmt))
+			break;
+
+		pdata->spk_fmt[count] = val;
+		count++;
+	}
+
+	count = 0;
+	of_property_for_each_u32(arizona->dev->of_node, "wlf,spk-mute", prop,
+				 cur, val) {
+		if (count == ARRAY_SIZE(pdata->spk_mute))
+			break;
+
+		pdata->spk_mute[count] = val;
+		count++;
+	}
+
 	return 0;
 }