[v2,1/3] ASoC: max98090: read micbias from device property
diff mbox

Message ID 1432836048-102175-1-git-send-email-yang.a.fang@intel.com
State New
Headers show

Commit Message

yang.a.fang@intel.com May 28, 2015, 6 p.m. UTC
From: "Fang, Yang A" <yang.a.fang@intel.com>

This patch reads max98090 micbias from acpi or dt

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 .../devicetree/bindings/sound/max98090.txt         |    2 ++
 sound/soc/codecs/max98090.c                        |    8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

Comments

Mark Brown May 29, 2015, 9:58 a.m. UTC | #1
On Thu, May 28, 2015 at 11:00:46AM -0700, yang.a.fang@intel.com wrote:

>  - maxim,dmic-freq: Frequency at which to clock DMIC
>  
> +- maxim,micbias: Micbias voltage applies to the analog mic

This needs to be more specific about what the value is - it looks like
it's the value to be written into a particular register?

> +	err = device_property_read_u32(codec->dev, "maxim,micbias", &micbias);
> +	if (err || micbias < M98090_MBVSEL_2V2  || micbias > M98090_MBVSEL_2V8)
> +		micbias = M98090_MBVSEL_2V8;

We should be logging an error if we read and out of range value here -
it's expected that the value might be missing but if we manage to read
something and it's invalid we should say so rather than silently ignore
it.
yang.a.fang@intel.com May 29, 2015, 5:37 p.m. UTC | #2
> -----Original Message-----
> From: Mark Brown [mailto:broonie@kernel.org]
> Sent: Friday, May 29, 2015 2:59 AM
> To: Fang, Yang A
> Cc: lgirdwood@gmail.com; alsa-devel@alsa-project.org;
> dgreid@chromium.org; Nujella, Sathyanarayana;
> kevin.strasser@linux.intel.com; Sripathi, Srinivas; Iriawan, Denny; Jain,
> Praveen K; Koul, Vinod
> Subject: Re: [PATCH v2 1/3] ASoC: max98090: read micbias from device
> property
> 
> On Thu, May 28, 2015 at 11:00:46AM -0700, yang.a.fang@intel.com wrote:
> 
> >  - maxim,dmic-freq: Frequency at which to clock DMIC
> >
> > +- maxim,micbias: Micbias voltage applies to the analog mic
> 
> This needs to be more specific about what the value is - it looks like it's the
> value to be written into a particular register?
> 
Yes it is written into the register. I will put more information

> > +	err = device_property_read_u32(codec->dev, "maxim,micbias",
> &micbias);
> > +	if (err || micbias < M98090_MBVSEL_2V2  || micbias >
> M98090_MBVSEL_2V8)
> > +		micbias = M98090_MBVSEL_2V8;
> 
> We should be logging an error if we read and out of range value here - it's
> expected that the value might be missing but if we manage to read
> something and it's invalid we should say so rather than silently ignore it.
Okay, will put log if out of range .

Patch
diff mbox

diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt
index aa802a2..eecb710 100644
--- a/Documentation/devicetree/bindings/sound/max98090.txt
+++ b/Documentation/devicetree/bindings/sound/max98090.txt
@@ -18,6 +18,8 @@  Optional properties:
 
 - maxim,dmic-freq: Frequency at which to clock DMIC
 
+- maxim,micbias: Micbias voltage applies to the analog mic
+
 Pins on the device (for linking into audio routes):
 
   * MIC1
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index c230626..4b61db7 100644
--- a/sound/soc/codecs/max98090.c
+++ b/sound/soc/codecs/max98090.c
@@ -2419,6 +2419,8 @@  static int max98090_probe(struct snd_soc_codec *codec)
 	struct max98090_cdata *cdata;
 	enum max98090_type devtype;
 	int ret = 0;
+	int err;
+	unsigned int micbias;
 
 	dev_dbg(codec->dev, "max98090_probe\n");
 
@@ -2503,8 +2505,12 @@  static int max98090_probe(struct snd_soc_codec *codec)
 	snd_soc_write(codec, M98090_REG_BIAS_CONTROL,
 		M98090_VCM_MODE_MASK);
 
+	err = device_property_read_u32(codec->dev, "maxim,micbias", &micbias);
+	if (err || micbias < M98090_MBVSEL_2V2  || micbias > M98090_MBVSEL_2V8)
+		micbias = M98090_MBVSEL_2V8;
+
 	snd_soc_update_bits(codec, M98090_REG_MIC_BIAS_VOLTAGE,
-		M98090_MBVSEL_MASK, M98090_MBVSEL_2V8);
+		M98090_MBVSEL_MASK, micbias);
 
 	max98090_add_widgets(codec);