[alsa-devel] [PATCH 4/4] ASoC: adau17x1: Add option to provide platform data via DT

Lars-Peter Clausen lars at metafoo.de
Thu Feb 4 22:01:16 CET 2016


At least a bit of commit message would be nice.

On 02/02/2016 03:31 PM, Andreas Irestål wrote:
> Signed-off-by: Andreas Irestål <andire at axis.com>
> ---
>  .../devicetree/bindings/sound/adi,adau17x1.txt     |  33 ++++++
>  include/dt-bindings/sound/adau17x1.h               |  14 +++
>  sound/soc/codecs/adau1761.c                        | 131 +++++++++++++++++++++
>  sound/soc/codecs/adau1781.c                        |  57 +++++++++
>  4 files changed, 235 insertions(+)
>  create mode 100644 include/dt-bindings/sound/adau17x1.h
> 
> diff --git a/Documentation/devicetree/bindings/sound/adi,adau17x1.txt b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
> index 90f3ac3..296b417 100644
> --- a/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
> +++ b/Documentation/devicetree/bindings/sound/adi,adau17x1.txt
> @@ -12,10 +12,43 @@ Required properties:
>   - reg:			The i2c address. Value depends on the state of ADDR0
>  			and ADDR1, as wired in hardware.
>  
> +Optional properties:
> +
> + - input-differential	bool to set if the input is differential
> + - digital-microphone	bool to set if there is a digital microphone connected
> +			to the digmic/jackdet pin.
> + - micbias-vg		Microphone bias voltage
> +	MICBIAS_0_90_AVDD - 0.9 * AVDD
> +	MICBIAS_0_65_AVDD - 0.65 * AVDD
> +
> +Optional properties (ADAU1361/ADAU1461/ADAU1761/ADAU1961 only)
> +
> + - jack-detection	If present, configures codec to use the digmic/jackdet
> +			pin for jack detection. must provide one of
> +			JACKDETECT_ACTIVE_LO or JACKDETECT_ACTIVE_HI followed
> +			by debounce time in ms, which must be 5, 10, 20, or 40.
> +
> + - lineout-mode		Set output mode of the lineout pins.
> + - headphone-mode	Set output mode of the headphone pins.

These properties all need a vendor prefix ("adi,").

[...]
> +
> +static void adau1761_pdata_from_of(struct snd_soc_codec *codec,
> +				   struct adau1761_platform_data *pdata)
> +{
> +	struct device_node *np = codec->dev->of_node;
> +	uint32_t val;
> +	uint32_t debounce_pars[2];
> +
> +	if (of_get_property(np, "input-differential", NULL))

There is a helper function for this of_property_read_bool().

> +		pdata->input_differential = 1;
> +	else
> +		pdata->input_differential = 0;
> +
[...]
> +
>  static int adau1761_codec_probe(struct snd_soc_codec *codec)
>  {
>  	struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
>  	struct adau1761_platform_data *pdata = codec->dev->platform_data;
>  	struct adau *adau = snd_soc_codec_get_drvdata(codec);
> +	struct device_node *np = codec->dev->of_node;
> +	struct adau1761_platform_data *of_pdata;
>  	int ret;
>  
> +	if (!pdata && np && of_device_is_available(np)) {
> +		of_pdata = devm_kzalloc(codec->dev, sizeof(*of_pdata), 
> +			GFP_KERNEL);
> +		if (!of_pdata)
> +			return -ENOMEM;
> +		adau1761_pdata_from_of(codec, of_pdata);
> +		pdata = of_pdata;
> +		codec->dev->platform_data = pdata;

The parsing should be done in the main probe function. This will make sure
that we propagate errors up the stack the right way.

> +	}




More information about the Alsa-devel mailing list