alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: max98090: read micbias from device property
@ 2015-05-26 23:58 yang.a.fang
  2015-05-26 23:58 ` [PATCH 2/3] ASoC: ts3a227e: use device property api yang.a.fang
                   ` (4 more replies)
  0 siblings, 5 replies; 23+ messages in thread
From: yang.a.fang @ 2015-05-26 23:58 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, Fang, Yang A, praveen.k.jain,
	denny.iriawan, sathyanarayana.nujella, kevin.strasser, dgreid

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>
---
 sound/soc/codecs/max98090.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
index c230626..27df17e 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,13 @@ 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, "max,micbias", &micbias);
+
+	if (err)
+		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);
 
-- 
1.7.9.5

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

* [PATCH 2/3] ASoC: ts3a227e: use device property api
  2015-05-26 23:58 [PATCH 1/3] ASoC: max98090: read micbias from device property yang.a.fang
@ 2015-05-26 23:58 ` yang.a.fang
  2015-05-28  9:29   ` Mark Brown
  2015-05-26 23:58 ` [PATCH 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 23+ messages in thread
From: yang.a.fang @ 2015-05-26 23:58 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, Fang, Yang A, praveen.k.jain,
	denny.iriawan, sathyanarayana.nujella, kevin.strasser, dgreid

From: "Fang, Yang A" <yang.a.fang@intel.com>

replace of_property_read_u32 with device_property_read_u32

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 sound/soc/codecs/ts3a227e.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c
index 9fd80ac..dfb49b3 100644
--- a/sound/soc/codecs/ts3a227e.c
+++ b/sound/soc/codecs/ts3a227e.c
@@ -254,12 +254,12 @@ static const struct regmap_config ts3a227e_regmap_config = {
 	.num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults),
 };
 
-static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np)
+static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device *dev)
 {
 	u32 micbias;
 	int err;
 
-	err = of_property_read_u32(np, "ti,micbias", &micbias);
+	err = device_property_read_u32(dev, "ti,micbias", &micbias);
 	if (!err) {
 		regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3,
 			MICBIAS_SETTING_MASK,
@@ -287,12 +287,10 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 	if (IS_ERR(ts3a227e->regmap))
 		return PTR_ERR(ts3a227e->regmap);
 
-	if (dev->of_node) {
-		ret = ts3a227e_parse_dt(ts3a227e, dev->of_node);
-		if (ret) {
-			dev_err(dev, "Failed to parse device tree: %d\n", ret);
-			return ret;
-		}
+	ret = ts3a227e_parse_dt(ts3a227e, dev);
+	if (ret) {
+		dev_err(dev, "Failed to parse device tree: %d\n", ret);
+		return ret;
 	}
 
 	ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt,
-- 
1.7.9.5

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

* [PATCH 3/3] ASoC: Intel: fixed TI button detection
  2015-05-26 23:58 [PATCH 1/3] ASoC: max98090: read micbias from device property yang.a.fang
  2015-05-26 23:58 ` [PATCH 2/3] ASoC: ts3a227e: use device property api yang.a.fang
@ 2015-05-26 23:58 ` yang.a.fang
  2015-05-27  4:39 ` [PATCH 1/3] ASoC: max98090: read micbias from device property Dylan Reid
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 23+ messages in thread
From: yang.a.fang @ 2015-05-26 23:58 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, Fang, Yang A, praveen.k.jain,
	denny.iriawan, sathyanarayana.nujella, kevin.strasser, dgreid

From: "Fang, Yang A" <yang.a.fang@intel.com>

In order to make TI button interrupt working max98090 codec
Need provide mic bias all the time as long as mic is present
so SHDN and micbias pin are forced on.we also need set max98090
codec bias close or lower than TI bias.We set them in bios/coreboot
kernel reads them from device property

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c |   41 ++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
index 1be0794..8ef947f 100644
--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c
+++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
@@ -101,6 +101,44 @@ static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int cht_ti_jack_event(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+
+	struct snd_soc_jack *jack = (struct snd_soc_jack *)data;
+	struct snd_soc_dai *codec_dai = jack->card->rtd->codec_dai;
+	struct snd_soc_codec *codec = codec_dai->codec;
+	int pin_status;
+
+	if (event & SND_JACK_MICROPHONE) {
+
+		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm, "SHDN");
+
+		if (!pin_status)
+			snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");
+
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+	} else {
+
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+		/**
+		* SHDN is max980090 shutdown pin we can not disable
+		* it in case we are in the middle of playabck or record
+		* we mark it unlock only so dapm will take care of it
+		* next time
+		*/
+		snd_soc_dapm_disable_pin_unlocked(&codec->dapm, "SHDN");
+	}
+
+	return 0;
+}
+
+static struct notifier_block cht_jack_nb = {
+	.notifier_call = cht_ti_jack_event,
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -130,6 +168,9 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 		return ret;
 	}
 
+	if (ctx->ts3a227e_present)
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+
 	return ret;
 }
 
-- 
1.7.9.5

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

* Re: [PATCH 1/3] ASoC: max98090: read micbias from device property
  2015-05-26 23:58 [PATCH 1/3] ASoC: max98090: read micbias from device property yang.a.fang
  2015-05-26 23:58 ` [PATCH 2/3] ASoC: ts3a227e: use device property api yang.a.fang
  2015-05-26 23:58 ` [PATCH 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
@ 2015-05-27  4:39 ` Dylan Reid
  2015-05-27 17:26   ` Yang Fang
  2015-05-28  9:28 ` Mark Brown
  2015-05-28 18:00 ` [PATCH v2 " yang.a.fang
  4 siblings, 1 reply; 23+ messages in thread
From: Dylan Reid @ 2015-05-27  4:39 UTC (permalink / raw)
  To: Yang Fang
  Cc: alsa-devel, Sripathi, Srinivas, Praveen K Jain, Liam Girdwood,
	Denny Iriawan, Mark Brown, Nujella, Sathyanarayana,
	kevin.strasser

On Tue, May 26, 2015 at 4:58 PM,  <yang.a.fang@intel.com> wrote:
> 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>
> ---
>  sound/soc/codecs/max98090.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
> index c230626..27df17e 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,13 @@ 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, "max,micbias", &micbias);

Should this be "maxim,micbias" to be consistent with  "maxim,dmic-freq"?
It should also be added to the Documentation for the max98090, as an
optional parameter.

> +

Extra newline.

> +       if (err)
> +               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);
>
> --
> 1.7.9.5
>

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

* Re: [PATCH 1/3] ASoC: max98090: read micbias from device property
  2015-05-27  4:39 ` [PATCH 1/3] ASoC: max98090: read micbias from device property Dylan Reid
@ 2015-05-27 17:26   ` Yang Fang
  0 siblings, 0 replies; 23+ messages in thread
From: Yang Fang @ 2015-05-27 17:26 UTC (permalink / raw)
  To: Dylan Reid
  Cc: alsa-devel, Sripathi, Srinivas, Praveen K Jain, Liam Girdwood,
	Denny Iriawan, Mark Brown, Nujella, Sathyanarayana,
	kevin.strasser

On Tue, May 26, 2015 at 09:39:54PM -0700, Dylan Reid wrote:
> On Tue, May 26, 2015 at 4:58 PM,  <yang.a.fang@intel.com> wrote:
> > 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>
> > ---
> >  sound/soc/codecs/max98090.c |    9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
> > index c230626..27df17e 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,13 @@ 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, "max,micbias", &micbias);
> 
> Should this be "maxim,micbias" to be consistent with  "maxim,dmic-freq"?
> It should also be added to the Documentation for the max98090, as an
> optional parameter.
Agreed . i will change it in v2 and update the Documentation
> 
> > +
> 
> Extra newline.
will fix in v2
> 
> > +       if (err)
> > +               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);
> >
> > --
> > 1.7.9.5
> >

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

* Re: [PATCH 1/3] ASoC: max98090: read micbias from device property
  2015-05-26 23:58 [PATCH 1/3] ASoC: max98090: read micbias from device property yang.a.fang
                   ` (2 preceding siblings ...)
  2015-05-27  4:39 ` [PATCH 1/3] ASoC: max98090: read micbias from device property Dylan Reid
@ 2015-05-28  9:28 ` Mark Brown
  2015-05-28 18:00 ` [PATCH v2 " yang.a.fang
  4 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2015-05-28  9:28 UTC (permalink / raw)
  To: yang.a.fang
  Cc: alsa-devel, srinivas.sripathi, praveen.k.jain, lgirdwood,
	denny.iriawan, sathyanarayana.nujella, kevin.strasser, dgreid


[-- Attachment #1.1: Type: text/plain, Size: 252 bytes --]

On Tue, May 26, 2015 at 04:58:04PM -0700, yang.a.fang@intel.com wrote:
> From: "Fang, Yang A" <yang.a.fang@intel.com>
> 
> This patch reads max98090 micbias from acpi or dt

This is adding a new DT binding, the DT binding needs to be documented.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH 2/3] ASoC: ts3a227e: use device property api
  2015-05-26 23:58 ` [PATCH 2/3] ASoC: ts3a227e: use device property api yang.a.fang
@ 2015-05-28  9:29   ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2015-05-28  9:29 UTC (permalink / raw)
  To: yang.a.fang
  Cc: alsa-devel, srinivas.sripathi, praveen.k.jain, lgirdwood,
	denny.iriawan, sathyanarayana.nujella, kevin.strasser, dgreid


[-- Attachment #1.1: Type: text/plain, Size: 374 bytes --]

On Tue, May 26, 2015 at 04:58:05PM -0700, yang.a.fang@intel.com wrote:

> -static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np)
> +static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device *dev)

You should rename the function - it's not just parsing DT, it's also
parsing ACPI (and any other firmware interface that comes along) now.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* [PATCH v2 1/3] ASoC: max98090: read micbias from device property
  2015-05-26 23:58 [PATCH 1/3] ASoC: max98090: read micbias from device property yang.a.fang
                   ` (3 preceding siblings ...)
  2015-05-28  9:28 ` Mark Brown
@ 2015-05-28 18:00 ` yang.a.fang
  2015-05-28 18:00   ` [PATCH v2 2/3] ASoC: ts3a227e: use device property api yang.a.fang
                     ` (3 more replies)
  4 siblings, 4 replies; 23+ messages in thread
From: yang.a.fang @ 2015-05-28 18:00 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	denny.iriawan, Fang, Yang A, sathyanarayana.nujella,
	kevin.strasser, dgreid

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(-)

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);
 
-- 
1.7.9.5

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

* [PATCH v2 2/3] ASoC: ts3a227e: use device property api
  2015-05-28 18:00 ` [PATCH v2 " yang.a.fang
@ 2015-05-28 18:00   ` yang.a.fang
  2015-05-28 18:00   ` [PATCH v2 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 23+ messages in thread
From: yang.a.fang @ 2015-05-28 18:00 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	denny.iriawan, Fang, Yang A, sathyanarayana.nujella,
	kevin.strasser, dgreid

From: "Fang, Yang A" <yang.a.fang@intel.com>

replace of_property_read_u32 with device_property_read_u32

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 sound/soc/codecs/ts3a227e.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c
index 9fd80ac..12232d7 100644
--- a/sound/soc/codecs/ts3a227e.c
+++ b/sound/soc/codecs/ts3a227e.c
@@ -254,12 +254,13 @@ static const struct regmap_config ts3a227e_regmap_config = {
 	.num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults),
 };
 
-static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np)
+static int ts3a227e_parse_device_property(struct ts3a227e *ts3a227e,
+				struct device *dev)
 {
 	u32 micbias;
 	int err;
 
-	err = of_property_read_u32(np, "ti,micbias", &micbias);
+	err = device_property_read_u32(dev, "ti,micbias", &micbias);
 	if (!err) {
 		regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3,
 			MICBIAS_SETTING_MASK,
@@ -287,12 +288,10 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 	if (IS_ERR(ts3a227e->regmap))
 		return PTR_ERR(ts3a227e->regmap);
 
-	if (dev->of_node) {
-		ret = ts3a227e_parse_dt(ts3a227e, dev->of_node);
-		if (ret) {
-			dev_err(dev, "Failed to parse device tree: %d\n", ret);
-			return ret;
-		}
+	ret = ts3a227e_parse_device_property(ts3a227e, dev);
+	if (ret) {
+		dev_err(dev, "Failed to parse device property: %d\n", ret);
+		return ret;
 	}
 
 	ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt,
-- 
1.7.9.5

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

* [PATCH v2 3/3] ASoC: Intel: fixed TI button detection
  2015-05-28 18:00 ` [PATCH v2 " yang.a.fang
  2015-05-28 18:00   ` [PATCH v2 2/3] ASoC: ts3a227e: use device property api yang.a.fang
@ 2015-05-28 18:00   ` yang.a.fang
  2015-05-29  9:58   ` [PATCH v2 1/3] ASoC: max98090: read micbias from device property Mark Brown
  2015-05-29 18:56   ` [PATCH v3 " yang.a.fang
  3 siblings, 0 replies; 23+ messages in thread
From: yang.a.fang @ 2015-05-28 18:00 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	denny.iriawan, Fang, Yang A, sathyanarayana.nujella,
	kevin.strasser, dgreid

From: "Fang, Yang A" <yang.a.fang@intel.com>

In order to make TI button interrupt working max98090 codec
Need provide mic bias all the time as long as mic is present
so SHDN and micbias pin are forced on.we also need set max98090
codec bias close or lower than TI bias.We set them in bios/coreboot
kernel reads them from device property

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c |   40 ++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
index 1be0794..3e5842d 100644
--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c
+++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
@@ -101,6 +101,43 @@ static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int cht_ti_jack_event(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+
+	struct snd_soc_jack *jack = (struct snd_soc_jack *)data;
+	struct snd_soc_dai *codec_dai = jack->card->rtd->codec_dai;
+	struct snd_soc_codec *codec = codec_dai->codec;
+	int pin_status;
+
+	if (event & SND_JACK_MICROPHONE) {
+
+		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm, "SHDN");
+		if (!pin_status)
+			snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");
+
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+	} else {
+
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+		/**
+		* SHDN is max980090 shutdown pin we can not disable
+		* it in case we are in the middle of playabck or record
+		* we mark it unlock only so dapm will take care of it
+		* next time
+		*/
+		snd_soc_dapm_disable_pin_unlocked(&codec->dapm, "SHDN");
+	}
+
+	return 0;
+}
+
+static struct notifier_block cht_jack_nb = {
+	.notifier_call = cht_ti_jack_event,
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -130,6 +167,9 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 		return ret;
 	}
 
+	if (ctx->ts3a227e_present)
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+
 	return ret;
 }
 
-- 
1.7.9.5

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

* Re: [PATCH v2 1/3] ASoC: max98090: read micbias from device property
  2015-05-28 18:00 ` [PATCH v2 " yang.a.fang
  2015-05-28 18:00   ` [PATCH v2 2/3] ASoC: ts3a227e: use device property api yang.a.fang
  2015-05-28 18:00   ` [PATCH v2 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
@ 2015-05-29  9:58   ` Mark Brown
  2015-05-29 17:37     ` Fang, Yang A
  2015-05-29 18:56   ` [PATCH v3 " yang.a.fang
  3 siblings, 1 reply; 23+ messages in thread
From: Mark Brown @ 2015-05-29  9:58 UTC (permalink / raw)
  To: yang.a.fang
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	lgirdwood, denny.iriawan, sathyanarayana.nujella, kevin.strasser,
	dgreid


[-- Attachment #1.1: Type: text/plain, Size: 744 bytes --]

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.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH v2 1/3] ASoC: max98090: read micbias from device property
  2015-05-29  9:58   ` [PATCH v2 1/3] ASoC: max98090: read micbias from device property Mark Brown
@ 2015-05-29 17:37     ` Fang, Yang A
  0 siblings, 0 replies; 23+ messages in thread
From: Fang, Yang A @ 2015-05-29 17:37 UTC (permalink / raw)
  To: 'Mark Brown'
  Cc: alsa-devel, Sripathi, Srinivas, Koul, Vinod, Jain, Praveen K,
	lgirdwood, Iriawan, Denny, Nujella, Sathyanarayana,
	kevin.strasser, dgreid



> -----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 .

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

* [PATCH v3 1/3] ASoC: max98090: read micbias from device property
  2015-05-28 18:00 ` [PATCH v2 " yang.a.fang
                     ` (2 preceding siblings ...)
  2015-05-29  9:58   ` [PATCH v2 1/3] ASoC: max98090: read micbias from device property Mark Brown
@ 2015-05-29 18:56   ` yang.a.fang
  2015-05-29 18:56     ` [PATCH v3 2/3] ASoC: ts3a227e: use device property api yang.a.fang
                       ` (2 more replies)
  3 siblings, 3 replies; 23+ messages in thread
From: yang.a.fang @ 2015-05-29 18:56 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	denny.iriawan, Fang, Yang A, sathyanarayana.nujella,
	kevin.strasser, dgreid

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         |    6 ++++++
 sound/soc/codecs/max98090.c                        |   13 ++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt
index aa802a2..4e3be66 100644
--- a/Documentation/devicetree/bindings/sound/max98090.txt
+++ b/Documentation/devicetree/bindings/sound/max98090.txt
@@ -18,6 +18,12 @@ Optional properties:
 
 - maxim,dmic-freq: Frequency at which to clock DMIC
 
+- maxim,micbias: Micbias voltage applies to the analog mic, valid voltages value are:
+	0 - 2.2v
+	1 - 2.55v
+	2 - 2.4v
+	3 - 2.8v
+
 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..679f0a0 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,17 @@ 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_2V8;
+		dev_info(codec->dev, "use default 2.8v micbias\n");
+	} else if (micbias < M98090_MBVSEL_2V2 || micbias > M98090_MBVSEL_2V8) {
+		dev_err(codec->dev, "micbias out of range 0x%x\n", micbias);
+		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);
 
-- 
1.7.9.5

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

* [PATCH v3 2/3] ASoC: ts3a227e: use device property api
  2015-05-29 18:56   ` [PATCH v3 " yang.a.fang
@ 2015-05-29 18:56     ` yang.a.fang
  2015-06-02 17:17       ` Mark Brown
  2015-05-29 18:56     ` [PATCH v3 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
  2015-06-02 17:11     ` [PATCH v3 1/3] ASoC: max98090: read micbias from device property Mark Brown
  2 siblings, 1 reply; 23+ messages in thread
From: yang.a.fang @ 2015-05-29 18:56 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	denny.iriawan, Fang, Yang A, sathyanarayana.nujella,
	kevin.strasser, dgreid

From: "Fang, Yang A" <yang.a.fang@intel.com>

replace of_property_read_u32 with device_property_read_u32

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 sound/soc/codecs/ts3a227e.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/ts3a227e.c b/sound/soc/codecs/ts3a227e.c
index 9fd80ac..12232d7 100644
--- a/sound/soc/codecs/ts3a227e.c
+++ b/sound/soc/codecs/ts3a227e.c
@@ -254,12 +254,13 @@ static const struct regmap_config ts3a227e_regmap_config = {
 	.num_reg_defaults = ARRAY_SIZE(ts3a227e_reg_defaults),
 };
 
-static int ts3a227e_parse_dt(struct ts3a227e *ts3a227e, struct device_node *np)
+static int ts3a227e_parse_device_property(struct ts3a227e *ts3a227e,
+				struct device *dev)
 {
 	u32 micbias;
 	int err;
 
-	err = of_property_read_u32(np, "ti,micbias", &micbias);
+	err = device_property_read_u32(dev, "ti,micbias", &micbias);
 	if (!err) {
 		regmap_update_bits(ts3a227e->regmap, TS3A227E_REG_SETTING_3,
 			MICBIAS_SETTING_MASK,
@@ -287,12 +288,10 @@ static int ts3a227e_i2c_probe(struct i2c_client *i2c,
 	if (IS_ERR(ts3a227e->regmap))
 		return PTR_ERR(ts3a227e->regmap);
 
-	if (dev->of_node) {
-		ret = ts3a227e_parse_dt(ts3a227e, dev->of_node);
-		if (ret) {
-			dev_err(dev, "Failed to parse device tree: %d\n", ret);
-			return ret;
-		}
+	ret = ts3a227e_parse_device_property(ts3a227e, dev);
+	if (ret) {
+		dev_err(dev, "Failed to parse device property: %d\n", ret);
+		return ret;
 	}
 
 	ret = devm_request_threaded_irq(dev, i2c->irq, NULL, ts3a227e_interrupt,
-- 
1.7.9.5

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

* [PATCH v3 3/3] ASoC: Intel: fixed TI button detection
  2015-05-29 18:56   ` [PATCH v3 " yang.a.fang
  2015-05-29 18:56     ` [PATCH v3 2/3] ASoC: ts3a227e: use device property api yang.a.fang
@ 2015-05-29 18:56     ` yang.a.fang
  2015-06-03 18:15       ` Mark Brown
  2015-06-03 22:07       ` [PATCH v4] " yang.a.fang
  2015-06-02 17:11     ` [PATCH v3 1/3] ASoC: max98090: read micbias from device property Mark Brown
  2 siblings, 2 replies; 23+ messages in thread
From: yang.a.fang @ 2015-05-29 18:56 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	denny.iriawan, Fang, Yang A, sathyanarayana.nujella,
	kevin.strasser, dgreid

From: "Fang, Yang A" <yang.a.fang@intel.com>

In order to make TI button interrupt working max98090 codec
Need provide mic bias all the time as long as mic is present
so SHDN and micbias pin are forced on.we also need set max98090
codec bias close or lower than TI bias.We set them in bios/coreboot
kernel reads them from device property

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c |   40 ++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
index 1be0794..3e5842d 100644
--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c
+++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
@@ -101,6 +101,43 @@ static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int cht_ti_jack_event(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+
+	struct snd_soc_jack *jack = (struct snd_soc_jack *)data;
+	struct snd_soc_dai *codec_dai = jack->card->rtd->codec_dai;
+	struct snd_soc_codec *codec = codec_dai->codec;
+	int pin_status;
+
+	if (event & SND_JACK_MICROPHONE) {
+
+		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm, "SHDN");
+		if (!pin_status)
+			snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");
+
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+	} else {
+
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+		/**
+		* SHDN is max980090 shutdown pin we can not disable
+		* it in case we are in the middle of playabck or record
+		* we mark it unlock only so dapm will take care of it
+		* next time
+		*/
+		snd_soc_dapm_disable_pin_unlocked(&codec->dapm, "SHDN");
+	}
+
+	return 0;
+}
+
+static struct notifier_block cht_jack_nb = {
+	.notifier_call = cht_ti_jack_event,
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -130,6 +167,9 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 		return ret;
 	}
 
+	if (ctx->ts3a227e_present)
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+
 	return ret;
 }
 
-- 
1.7.9.5

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

* Re: [PATCH v3 1/3] ASoC: max98090: read micbias from device property
  2015-05-29 18:56   ` [PATCH v3 " yang.a.fang
  2015-05-29 18:56     ` [PATCH v3 2/3] ASoC: ts3a227e: use device property api yang.a.fang
  2015-05-29 18:56     ` [PATCH v3 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
@ 2015-06-02 17:11     ` Mark Brown
  2 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2015-06-02 17:11 UTC (permalink / raw)
  To: yang.a.fang
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	lgirdwood, denny.iriawan, sathyanarayana.nujella, kevin.strasser,
	dgreid


[-- Attachment #1.1: Type: text/plain, Size: 197 bytes --]

On Fri, May 29, 2015 at 11:56:10AM -0700, yang.a.fang@intel.com wrote:
> From: "Fang, Yang A" <yang.a.fang@intel.com>
> 
> This patch reads max98090 micbias from acpi or dt

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH v3 2/3] ASoC: ts3a227e: use device property api
  2015-05-29 18:56     ` [PATCH v3 2/3] ASoC: ts3a227e: use device property api yang.a.fang
@ 2015-06-02 17:17       ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2015-06-02 17:17 UTC (permalink / raw)
  To: yang.a.fang
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	lgirdwood, denny.iriawan, sathyanarayana.nujella, kevin.strasser,
	dgreid


[-- Attachment #1.1: Type: text/plain, Size: 206 bytes --]

On Fri, May 29, 2015 at 11:56:11AM -0700, yang.a.fang@intel.com wrote:
> From: "Fang, Yang A" <yang.a.fang@intel.com>
> 
> replace of_property_read_u32 with device_property_read_u32

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH v3 3/3] ASoC: Intel: fixed TI button detection
  2015-05-29 18:56     ` [PATCH v3 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
@ 2015-06-03 18:15       ` Mark Brown
  2015-06-03 20:54         ` Fang, Yang A
  2015-06-03 22:07       ` [PATCH v4] " yang.a.fang
  1 sibling, 1 reply; 23+ messages in thread
From: Mark Brown @ 2015-06-03 18:15 UTC (permalink / raw)
  To: yang.a.fang
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	lgirdwood, denny.iriawan, sathyanarayana.nujella, kevin.strasser,
	dgreid


[-- Attachment #1.1: Type: text/plain, Size: 1502 bytes --]

On Fri, May 29, 2015 at 11:56:12AM -0700, yang.a.fang@intel.com wrote:

> +	if (event & SND_JACK_MICROPHONE) {
> +
> +		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm, "SHDN");
> +		if (!pin_status)
> +			snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");

This seems wrong - either we need the pin enabled or we don't.  If it's
currently enabled for something transient like playback then it might
get turned off later so we should still force it on.

> +		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
> +		snd_soc_dapm_sync(&codec->dapm);
> +		/**
> +		* SHDN is max980090 shutdown pin we can not disable
> +		* it in case we are in the middle of playabck or record
> +		* we mark it unlock only so dapm will take care of it
> +		* next time
> +		*/
> +		snd_soc_dapm_disable_pin_unlocked(&codec->dapm, "SHDN");

This is wrong, you're mixing locked and unlocked versions of the DAPM
operations which can't be right - the difference between locked and
unlocked versions of the operations is that the locked versions is if
the locks for DAPM are already held and clearly there's no locking code
here.  This last operation shuld be a normal _disable_pin().

I'd also expect it to be before the sync - there's no telling how long
it'll be till the next sync otherwise and no reason to leave the pin
forced on if it's not needed.  If it is in use due to some other thing
then DAPM should ensure that the state doesn't get changed by the
disable.

Indentation is broken for the comment too.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH v3 3/3] ASoC: Intel: fixed TI button detection
  2015-06-03 18:15       ` Mark Brown
@ 2015-06-03 20:54         ` Fang, Yang A
  0 siblings, 0 replies; 23+ messages in thread
From: Fang, Yang A @ 2015-06-03 20:54 UTC (permalink / raw)
  To: 'Mark Brown'
  Cc: alsa-devel, Sripathi, Srinivas, Koul, Vinod, Jain, Praveen K,
	lgirdwood, Iriawan, Denny, Nujella, Sathyanarayana,
	kevin.strasser, dgreid



> -----Original Message-----
> From: Mark Brown [mailto:broonie@kernel.org]
> Sent: Wednesday, June 03, 2015 11:16 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 v3 3/3] ASoC: Intel: fixed TI button detection
> 
> On Fri, May 29, 2015 at 11:56:12AM -0700, yang.a.fang@intel.com wrote:
> 
> > +	if (event & SND_JACK_MICROPHONE) {
> > +
> > +		pin_status = snd_soc_dapm_get_pin_status(&codec->dapm,
> "SHDN");
> > +		if (!pin_status)
> > +			snd_soc_dapm_force_enable_pin(&codec->dapm,
> "SHDN");
> 
> This seems wrong - either we need the pin enabled or we don't.  If it's
> currently enabled for something transient like playback then it might get
> turned off later so we should still force it on.
Got it.  I will remove the condition.
> 
> > +		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
> > +		snd_soc_dapm_sync(&codec->dapm);
> > +		/**
> > +		* SHDN is max980090 shutdown pin we can not disable
> > +		* it in case we are in the middle of playabck or record
> > +		* we mark it unlock only so dapm will take care of it
> > +		* next time
> > +		*/
> > +		snd_soc_dapm_disable_pin_unlocked(&codec->dapm,
> "SHDN");
> 
> This is wrong, you're mixing locked and unlocked versions of the DAPM
> operations which can't be right - the difference between locked and
> unlocked versions of the operations is that the locked versions is if the locks
> for DAPM are already held and clearly there's no locking code here.  This last
> operation shuld be a normal _disable_pin().
> 
Thanks Mark.  I will use snd_soc_dapm_disable_pin
> I'd also expect it to be before the sync - there's no telling how long it'll be till
> the next sync otherwise and no reason to leave the pin forced on if it's not
> needed.  If it is in use due to some other thing then DAPM should ensure
> that the state doesn't get changed by the disable.
> 
I was thinking widget will be disabled right after calling snd_soc_dapm_sync
I just tried to move SHDN before calling snd_soc_dapm_sync  .as you said 
if it is in use dapm will not turn it off immediately  for example if playback is
 ongoing.It will be turned off few seconds after playback stops.

> Indentation is broken for the comment too.
I will remove the comments since I will move the disable SHDN pin code 
before calling snd_soc_dapm_sync

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

* [PATCH v4] ASoC: Intel: fixed TI button detection
  2015-05-29 18:56     ` [PATCH v3 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
  2015-06-03 18:15       ` Mark Brown
@ 2015-06-03 22:07       ` yang.a.fang
  2015-06-15  9:51         ` Mark Brown
  1 sibling, 1 reply; 23+ messages in thread
From: yang.a.fang @ 2015-06-03 22:07 UTC (permalink / raw)
  To: broonie, lgirdwood
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	denny.iriawan, Fang, Yang A, sathyanarayana.nujella,
	kevin.strasser, dgreid

From: "Fang, Yang A" <yang.a.fang@intel.com>

In order to make TI button interrupt working max98090 codec
Need provide mic bias all the time as long as mic is present
so SHDN and micbias pin are forced on.we also need set max98090
codec bias close or lower than TI bias.We set them in bios/coreboot
kernel reads them from device property

Signed-off-by: Fang, Yang A <yang.a.fang@intel.com>
---
 sound/soc/intel/boards/cht_bsw_max98090_ti.c |   30 ++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
index 1be0794..d604ee8 100644
--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c
+++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
@@ -101,6 +101,33 @@ static int cht_aif1_hw_params(struct snd_pcm_substream *substream,
 	return 0;
 }
 
+static int cht_ti_jack_event(struct notifier_block *nb,
+		unsigned long event, void *data)
+{
+
+	struct snd_soc_jack *jack = (struct snd_soc_jack *)data;
+	struct snd_soc_dai *codec_dai = jack->card->rtd->codec_dai;
+	struct snd_soc_codec *codec = codec_dai->codec;
+
+	if (event & SND_JACK_MICROPHONE) {
+
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "SHDN");
+		snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_sync(&codec->dapm);
+	} else {
+
+		snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS");
+		snd_soc_dapm_disable_pin(&codec->dapm, "SHDN");
+		snd_soc_dapm_sync(&codec->dapm);
+	}
+
+	return 0;
+}
+
+static struct notifier_block cht_jack_nb = {
+	.notifier_call = cht_ti_jack_event,
+};
+
 static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 {
 	int ret;
@@ -130,6 +157,9 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
 		return ret;
 	}
 
+	if (ctx->ts3a227e_present)
+		snd_soc_jack_notifier_register(jack, &cht_jack_nb);
+
 	return ret;
 }
 
-- 
1.7.9.5

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

* Re: [PATCH v4] ASoC: Intel: fixed TI button detection
  2015-06-03 22:07       ` [PATCH v4] " yang.a.fang
@ 2015-06-15  9:51         ` Mark Brown
  0 siblings, 0 replies; 23+ messages in thread
From: Mark Brown @ 2015-06-15  9:51 UTC (permalink / raw)
  To: yang.a.fang
  Cc: alsa-devel, srinivas.sripathi, vinod.koul, praveen.k.jain,
	lgirdwood, denny.iriawan, sathyanarayana.nujella, kevin.strasser,
	dgreid


[-- Attachment #1.1: Type: text/plain, Size: 451 bytes --]

On Wed, Jun 03, 2015 at 03:07:41PM -0700, yang.a.fang@intel.com wrote:
> From: "Fang, Yang A" <yang.a.fang@intel.com>
> 
> In order to make TI button interrupt working max98090 codec
> Need provide mic bias all the time as long as mic is present
> so SHDN and micbias pin are forced on.we also need set max98090
> codec bias close or lower than TI bias.We set them in bios/coreboot
> kernel reads them from device property

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: [PATCH 1/3] ASoC: max98090: read micbias from device property
  2015-05-27 21:35 [PATCH " Anish Kumar
@ 2015-05-27 23:40 ` Yang Fang
  0 siblings, 0 replies; 23+ messages in thread
From: Yang Fang @ 2015-05-27 23:40 UTC (permalink / raw)
  To: Anish Kumar
  Cc: alsa-devel, srinivas.sripathi, praveen.k.jain, lgirdwood,
	denny.iriawan, broonie, sathyanarayana.nujella, kevin.strasser

On Wed, May 27, 2015 at 02:35:40PM -0700, Anish Kumar wrote:
> > 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>
> > ---
> >  sound/soc/codecs/max98090.c |    9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
> > index c230626..27df17e 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,13 @@ 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, "max,micbias", &micbias);
> 
>             if (err || micbias < M98090_MBVSEL_2V2 || micbias > M98090_MBVSEL_2V8)
>                  micbias = M98090_MBVSEL_2V8;
> Just stick sanity as well.
thanks.will include in v2. waiting for more comments

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

* Re: [PATCH 1/3] ASoC: max98090: read micbias from device property
@ 2015-05-27 21:35 Anish Kumar
  2015-05-27 23:40 ` Yang Fang
  0 siblings, 1 reply; 23+ messages in thread
From: Anish Kumar @ 2015-05-27 21:35 UTC (permalink / raw)
  To: yang.a.fang, broonie
  Cc: alsa-devel, srinivas.sripathi, praveen.k.jain, lgirdwood,
	denny.iriawan, sathyanarayana.nujella, kevin.strasser

> 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>
> ---
>  sound/soc/codecs/max98090.c |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
> index c230626..27df17e 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,13 @@ 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, "max,micbias", &micbias);

            if (err || micbias < M98090_MBVSEL_2V2 || micbias > M98090_MBVSEL_2V8)
                 micbias = M98090_MBVSEL_2V8;
Just stick sanity as well.

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

end of thread, other threads:[~2015-06-15  9:51 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-26 23:58 [PATCH 1/3] ASoC: max98090: read micbias from device property yang.a.fang
2015-05-26 23:58 ` [PATCH 2/3] ASoC: ts3a227e: use device property api yang.a.fang
2015-05-28  9:29   ` Mark Brown
2015-05-26 23:58 ` [PATCH 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
2015-05-27  4:39 ` [PATCH 1/3] ASoC: max98090: read micbias from device property Dylan Reid
2015-05-27 17:26   ` Yang Fang
2015-05-28  9:28 ` Mark Brown
2015-05-28 18:00 ` [PATCH v2 " yang.a.fang
2015-05-28 18:00   ` [PATCH v2 2/3] ASoC: ts3a227e: use device property api yang.a.fang
2015-05-28 18:00   ` [PATCH v2 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
2015-05-29  9:58   ` [PATCH v2 1/3] ASoC: max98090: read micbias from device property Mark Brown
2015-05-29 17:37     ` Fang, Yang A
2015-05-29 18:56   ` [PATCH v3 " yang.a.fang
2015-05-29 18:56     ` [PATCH v3 2/3] ASoC: ts3a227e: use device property api yang.a.fang
2015-06-02 17:17       ` Mark Brown
2015-05-29 18:56     ` [PATCH v3 3/3] ASoC: Intel: fixed TI button detection yang.a.fang
2015-06-03 18:15       ` Mark Brown
2015-06-03 20:54         ` Fang, Yang A
2015-06-03 22:07       ` [PATCH v4] " yang.a.fang
2015-06-15  9:51         ` Mark Brown
2015-06-02 17:11     ` [PATCH v3 1/3] ASoC: max98090: read micbias from device property Mark Brown
2015-05-27 21:35 [PATCH " Anish Kumar
2015-05-27 23:40 ` Yang Fang

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).