Re: [alsa-devel][PATCH 2/3] ASoC: TSCS42xx: Remove Playback/Capture in names

2018-06-20 Thread Steven Eckhoff
On Mon, Jun 18, 2018 at 12:31:54PM +0100, Mark Brown wrote:
> Really?  They're part of the spec so it indicates that the apps have a
> problem...

I apologize for the delayed response.

I am unable to reproduce the issue that I was seeing with controls that
had Playback or Capture in their names. I am going look into this
further.

I was seeing an issue with amixer set where it would not find the
control, but I could use the numid. I wanted to make sure that it would
always work, so I could provide amixer set commands using the name of
the control in our documentation.

Regards,

Steven


Re: [alsa-devel][PATCH 2/3] ASoC: TSCS42xx: Remove Playback/Capture in names

2018-06-20 Thread Steven Eckhoff
On Mon, Jun 18, 2018 at 12:31:54PM +0100, Mark Brown wrote:
> Really?  They're part of the spec so it indicates that the apps have a
> problem...

I apologize for the delayed response.

I am unable to reproduce the issue that I was seeing with controls that
had Playback or Capture in their names. I am going look into this
further.

I was seeing an issue with amixer set where it would not find the
control, but I could use the numid. I wanted to make sure that it would
always work, so I could provide amixer set commands using the name of
the control in our documentation.

Regards,

Steven


[alsa-devel][PATCH 3/3] ASoC: TSCS42xx: Add headphone auto switching

2018-06-04 Thread Steven Eckhoff
Add headphone auto switching controls

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 6 ++
 sound/soc/codecs/tscs42xx.h | 8 
 2 files changed, 14 insertions(+)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index c79c075228a6..4f56d2937a35 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -641,6 +641,12 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
/* Mic Bias */
SOC_SINGLE("Mic Bias Boost Switch", 0x71, 0x07, 1, 0),
 
+   /* Headphone Auto Switching */
+   SOC_SINGLE("Headphone Auto Switching Switch",
+   R_CTL, FB_CTL_HPSWEN, 1, 0),
+   SOC_SINGLE("Headphone Detect Polarity Toggle Switch",
+   R_CTL, FB_CTL_HPSWPOL, 1, 0),
+
/* Coefficient Ram */
COEFF_RAM_CTL("Cascade1L BiQuad1", BIQUAD_SIZE, 0x00),
COEFF_RAM_CTL("Cascade1L BiQuad2", BIQUAD_SIZE, 0x05),
diff --git a/sound/soc/codecs/tscs42xx.h b/sound/soc/codecs/tscs42xx.h
index d4a30bcbf64b..9b15bf89c4d0 100644
--- a/sound/soc/codecs/tscs42xx.h
+++ b/sound/soc/codecs/tscs42xx.h
@@ -34,6 +34,7 @@ enum {
 #define R_DACSR 0x19
 #define R_PWRM1 0x1A
 #define R_PWRM2 0x1B
+#define R_CTL  0x1C
 #define R_CONFIG0   0x1F
 #define R_CONFIG1   0x20
 #define R_DMICCTL   0x24
@@ -1110,6 +,13 @@ enum {
 #define RV_PWRM2_VREF_DISABLE \
 RV(FV_PWRM2_VREF_DISABLE, FB_PWRM2_VREF)
 
+/**
+ *  R_CTL (0x1C)  *
+ **/
+
+/* Fiel Offsets */
+#define FB_CTL_HPSWEN7
+#define FB_CTL_HPSWPOL   6
 
 /**
  *  R_CONFIG0 (0x1F)  *
-- 
2.17.0



[alsa-devel][PATCH 3/3] ASoC: TSCS42xx: Add headphone auto switching

2018-06-04 Thread Steven Eckhoff
Add headphone auto switching controls

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 6 ++
 sound/soc/codecs/tscs42xx.h | 8 
 2 files changed, 14 insertions(+)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index c79c075228a6..4f56d2937a35 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -641,6 +641,12 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
/* Mic Bias */
SOC_SINGLE("Mic Bias Boost Switch", 0x71, 0x07, 1, 0),
 
+   /* Headphone Auto Switching */
+   SOC_SINGLE("Headphone Auto Switching Switch",
+   R_CTL, FB_CTL_HPSWEN, 1, 0),
+   SOC_SINGLE("Headphone Detect Polarity Toggle Switch",
+   R_CTL, FB_CTL_HPSWPOL, 1, 0),
+
/* Coefficient Ram */
COEFF_RAM_CTL("Cascade1L BiQuad1", BIQUAD_SIZE, 0x00),
COEFF_RAM_CTL("Cascade1L BiQuad2", BIQUAD_SIZE, 0x05),
diff --git a/sound/soc/codecs/tscs42xx.h b/sound/soc/codecs/tscs42xx.h
index d4a30bcbf64b..9b15bf89c4d0 100644
--- a/sound/soc/codecs/tscs42xx.h
+++ b/sound/soc/codecs/tscs42xx.h
@@ -34,6 +34,7 @@ enum {
 #define R_DACSR 0x19
 #define R_PWRM1 0x1A
 #define R_PWRM2 0x1B
+#define R_CTL  0x1C
 #define R_CONFIG0   0x1F
 #define R_CONFIG1   0x20
 #define R_DMICCTL   0x24
@@ -1110,6 +,13 @@ enum {
 #define RV_PWRM2_VREF_DISABLE \
 RV(FV_PWRM2_VREF_DISABLE, FB_PWRM2_VREF)
 
+/**
+ *  R_CTL (0x1C)  *
+ **/
+
+/* Fiel Offsets */
+#define FB_CTL_HPSWEN7
+#define FB_CTL_HPSWPOL   6
 
 /**
  *  R_CONFIG0 (0x1F)  *
-- 
2.17.0



[alsa-devel][PATCH 2/3] ASoC: TSCS42xx: Remove Playback/Capture in names

2018-06-04 Thread Steven Eckhoff
These aren't needed and some userspace apps don't work consistently with
them.

Remove Playback/Capture from control names

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index 15505c3c9ed4..c79c075228a6 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -619,19 +619,19 @@ static int bytes_info_ext(struct snd_kcontrol *kcontrol,
 
 static const struct snd_kcontrol_new tscs42xx_snd_controls[] = {
/* Volumes */
-   SOC_DOUBLE_R_TLV("Headphone Playback Volume", R_HPVOLL, R_HPVOLR,
+   SOC_DOUBLE_R_TLV("Headphone Volume", R_HPVOLL, R_HPVOLR,
FB_HPVOLL, 0x7F, 0, hpvol_scale),
-   SOC_DOUBLE_R_TLV("Speaker Playback Volume", R_SPKVOLL, R_SPKVOLR,
+   SOC_DOUBLE_R_TLV("Speaker Volume", R_SPKVOLL, R_SPKVOLR,
FB_SPKVOLL, 0x7F, 0, spkvol_scale),
-   SOC_DOUBLE_R_TLV("Master Playback Volume", R_DACVOLL, R_DACVOLR,
+   SOC_DOUBLE_R_TLV("Master Volume", R_DACVOLL, R_DACVOLR,
FB_DACVOLL, 0xFF, 0, dacvol_scale),
-   SOC_DOUBLE_R_TLV("PCM Capture Volume", R_ADCVOLL, R_ADCVOLR,
+   SOC_DOUBLE_R_TLV("PCM Volume", R_ADCVOLL, R_ADCVOLR,
FB_ADCVOLL, 0xFF, 0, adcvol_scale),
-   SOC_DOUBLE_R_TLV("Master Capture Volume", R_INVOLL, R_INVOLR,
+   SOC_DOUBLE_R_TLV("Input Volume", R_INVOLL, R_INVOLR,
FB_INVOLL, 0x3F, 0, invol_scale),
 
/* INSEL */
-   SOC_DOUBLE_R_TLV("Mic Boost Capture Volume", R_INSELL, R_INSELR,
+   SOC_DOUBLE_R_TLV("Mic Boost Volume", R_INSELL, R_INSELR,
FB_INSELL_MICBSTL, FV_INSELL_MICBSTL_30DB,
0, mic_boost_scale),
 
@@ -730,9 +730,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
R_CLECTL, FB_CLECTL_LIMIT_EN, 1, 0),
SOC_SINGLE("Comp Switch",
R_CLECTL, FB_CLECTL_COMP_EN, 1, 0),
-   SOC_SINGLE_TLV("CLE Make-Up Gain Playback Volume",
+   SOC_SINGLE_TLV("CLE Make-Up Gain Volume",
R_MUGAIN, FB_MUGAIN_CLEMUG, 0x1f, 0, mugain_scale),
-   SOC_SINGLE_TLV("Comp Thresh Playback Volume",
+   SOC_SINGLE_TLV("Comp Thresh Volume",
R_COMPTH, FB_COMPTH, 0xff, 0, compth_scale),
SOC_ENUM("Comp Ratio", compressor_ratio_enum),
SND_SOC_BYTES("Comp Atk Time", R_CATKTCL, 2),
@@ -763,9 +763,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
 
SOC_SINGLE("MBC1 Phase Invert Switch",
R_DACMBCMUG1, FB_DACMBCMUG1_PHASE, 1, 0),
-   SOC_SINGLE_TLV("DAC MBC1 Make-Up Gain Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC1 Make-Up Gain Volume",
R_DACMBCMUG1, FB_DACMBCMUG1_MUGAIN, 0x1f, 0, mugain_scale),
-   SOC_SINGLE_TLV("DAC MBC1 Comp Thresh Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC1 Comp Thresh Volume",
R_DACMBCTHR1, FB_DACMBCTHR1_THRESH, 0xff, 0, compth_scale),
SOC_ENUM("DAC MBC1 Comp Ratio",
dac_mbc1_compressor_ratio_enum),
@@ -775,9 +775,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
 
SOC_SINGLE("MBC2 Phase Invert Switch",
R_DACMBCMUG2, FB_DACMBCMUG2_PHASE, 1, 0),
-   SOC_SINGLE_TLV("DAC MBC2 Make-Up Gain Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC2 Make-Up Gain Volume",
R_DACMBCMUG2, FB_DACMBCMUG2_MUGAIN, 0x1f, 0, mugain_scale),
-   SOC_SINGLE_TLV("DAC MBC2 Comp Thresh Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC2 Comp Thresh Volume",
R_DACMBCTHR2, FB_DACMBCTHR2_THRESH, 0xff, 0, compth_scale),
SOC_ENUM("DAC MBC2 Comp Ratio",
dac_mbc2_compressor_ratio_enum),
@@ -787,9 +787,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
 
SOC_SINGLE("MBC3 Phase Invert Switch",
R_DACMBCMUG3, FB_DACMBCMUG3_PHASE, 1, 0),
-   SOC_SINGLE_TLV("DAC MBC3 Make-Up Gain Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC3 Make-Up Gain Volume",
R_DACMBCMUG3, FB_DACMBCMUG3_MUGAIN, 0x1f, 0, mugain_scale),
-   SOC_SINGLE_TLV("DAC MBC3 Comp Thresh Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC3 Comp Thresh Volume",
R_DACMBCTHR3, FB_DACMBCTHR3_THRESH, 0xff, 0, compth_scale),
SOC_ENUM("DAC MBC3 Comp Ratio",
dac_mbc3_compressor_ratio_enum),
-- 
2.17.0



[alsa-devel][PATCH 2/3] ASoC: TSCS42xx: Remove Playback/Capture in names

2018-06-04 Thread Steven Eckhoff
These aren't needed and some userspace apps don't work consistently with
them.

Remove Playback/Capture from control names

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index 15505c3c9ed4..c79c075228a6 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -619,19 +619,19 @@ static int bytes_info_ext(struct snd_kcontrol *kcontrol,
 
 static const struct snd_kcontrol_new tscs42xx_snd_controls[] = {
/* Volumes */
-   SOC_DOUBLE_R_TLV("Headphone Playback Volume", R_HPVOLL, R_HPVOLR,
+   SOC_DOUBLE_R_TLV("Headphone Volume", R_HPVOLL, R_HPVOLR,
FB_HPVOLL, 0x7F, 0, hpvol_scale),
-   SOC_DOUBLE_R_TLV("Speaker Playback Volume", R_SPKVOLL, R_SPKVOLR,
+   SOC_DOUBLE_R_TLV("Speaker Volume", R_SPKVOLL, R_SPKVOLR,
FB_SPKVOLL, 0x7F, 0, spkvol_scale),
-   SOC_DOUBLE_R_TLV("Master Playback Volume", R_DACVOLL, R_DACVOLR,
+   SOC_DOUBLE_R_TLV("Master Volume", R_DACVOLL, R_DACVOLR,
FB_DACVOLL, 0xFF, 0, dacvol_scale),
-   SOC_DOUBLE_R_TLV("PCM Capture Volume", R_ADCVOLL, R_ADCVOLR,
+   SOC_DOUBLE_R_TLV("PCM Volume", R_ADCVOLL, R_ADCVOLR,
FB_ADCVOLL, 0xFF, 0, adcvol_scale),
-   SOC_DOUBLE_R_TLV("Master Capture Volume", R_INVOLL, R_INVOLR,
+   SOC_DOUBLE_R_TLV("Input Volume", R_INVOLL, R_INVOLR,
FB_INVOLL, 0x3F, 0, invol_scale),
 
/* INSEL */
-   SOC_DOUBLE_R_TLV("Mic Boost Capture Volume", R_INSELL, R_INSELR,
+   SOC_DOUBLE_R_TLV("Mic Boost Volume", R_INSELL, R_INSELR,
FB_INSELL_MICBSTL, FV_INSELL_MICBSTL_30DB,
0, mic_boost_scale),
 
@@ -730,9 +730,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
R_CLECTL, FB_CLECTL_LIMIT_EN, 1, 0),
SOC_SINGLE("Comp Switch",
R_CLECTL, FB_CLECTL_COMP_EN, 1, 0),
-   SOC_SINGLE_TLV("CLE Make-Up Gain Playback Volume",
+   SOC_SINGLE_TLV("CLE Make-Up Gain Volume",
R_MUGAIN, FB_MUGAIN_CLEMUG, 0x1f, 0, mugain_scale),
-   SOC_SINGLE_TLV("Comp Thresh Playback Volume",
+   SOC_SINGLE_TLV("Comp Thresh Volume",
R_COMPTH, FB_COMPTH, 0xff, 0, compth_scale),
SOC_ENUM("Comp Ratio", compressor_ratio_enum),
SND_SOC_BYTES("Comp Atk Time", R_CATKTCL, 2),
@@ -763,9 +763,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
 
SOC_SINGLE("MBC1 Phase Invert Switch",
R_DACMBCMUG1, FB_DACMBCMUG1_PHASE, 1, 0),
-   SOC_SINGLE_TLV("DAC MBC1 Make-Up Gain Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC1 Make-Up Gain Volume",
R_DACMBCMUG1, FB_DACMBCMUG1_MUGAIN, 0x1f, 0, mugain_scale),
-   SOC_SINGLE_TLV("DAC MBC1 Comp Thresh Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC1 Comp Thresh Volume",
R_DACMBCTHR1, FB_DACMBCTHR1_THRESH, 0xff, 0, compth_scale),
SOC_ENUM("DAC MBC1 Comp Ratio",
dac_mbc1_compressor_ratio_enum),
@@ -775,9 +775,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
 
SOC_SINGLE("MBC2 Phase Invert Switch",
R_DACMBCMUG2, FB_DACMBCMUG2_PHASE, 1, 0),
-   SOC_SINGLE_TLV("DAC MBC2 Make-Up Gain Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC2 Make-Up Gain Volume",
R_DACMBCMUG2, FB_DACMBCMUG2_MUGAIN, 0x1f, 0, mugain_scale),
-   SOC_SINGLE_TLV("DAC MBC2 Comp Thresh Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC2 Comp Thresh Volume",
R_DACMBCTHR2, FB_DACMBCTHR2_THRESH, 0xff, 0, compth_scale),
SOC_ENUM("DAC MBC2 Comp Ratio",
dac_mbc2_compressor_ratio_enum),
@@ -787,9 +787,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
 
SOC_SINGLE("MBC3 Phase Invert Switch",
R_DACMBCMUG3, FB_DACMBCMUG3_PHASE, 1, 0),
-   SOC_SINGLE_TLV("DAC MBC3 Make-Up Gain Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC3 Make-Up Gain Volume",
R_DACMBCMUG3, FB_DACMBCMUG3_MUGAIN, 0x1f, 0, mugain_scale),
-   SOC_SINGLE_TLV("DAC MBC3 Comp Thresh Playback Volume",
+   SOC_SINGLE_TLV("DAC MBC3 Comp Thresh Volume",
R_DACMBCTHR3, FB_DACMBCTHR3_THRESH, 0xff, 0, compth_scale),
SOC_ENUM("DAC MBC3 Comp Ratio",
dac_mbc3_compressor_ratio_enum),
-- 
2.17.0



[alsa-devel][PATCH 1/3] ASoC: TSCS42xx: Add mic bias boost control

2018-06-04 Thread Steven Eckhoff
Add mic bias boost control

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index bbfc73a79b18..15505c3c9ed4 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -638,6 +638,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
/* Input Channel Map */
SOC_ENUM("Input Channel Map", ch_map_select_enum),
 
+   /* Mic Bias */
+   SOC_SINGLE("Mic Bias Boost Switch", 0x71, 0x07, 1, 0),
+
/* Coefficient Ram */
COEFF_RAM_CTL("Cascade1L BiQuad1", BIQUAD_SIZE, 0x00),
COEFF_RAM_CTL("Cascade1L BiQuad2", BIQUAD_SIZE, 0x05),
-- 
2.17.0



[alsa-devel][PATCH 1/3] ASoC: TSCS42xx: Add mic bias boost control

2018-06-04 Thread Steven Eckhoff
Add mic bias boost control

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index bbfc73a79b18..15505c3c9ed4 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -638,6 +638,9 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
/* Input Channel Map */
SOC_ENUM("Input Channel Map", ch_map_select_enum),
 
+   /* Mic Bias */
+   SOC_SINGLE("Mic Bias Boost Switch", 0x71, 0x07, 1, 0),
+
/* Coefficient Ram */
COEFF_RAM_CTL("Cascade1L BiQuad1", BIQUAD_SIZE, 0x00),
COEFF_RAM_CTL("Cascade1L BiQuad2", BIQUAD_SIZE, 0x05),
-- 
2.17.0



[alsa-devel][PATCH 0/3] ASoC: TSCS42xx: Control Improvements

2018-06-04 Thread Steven Eckhoff
Steven Eckhoff (3):
  Add mic bias boost control
  Remove Playback/Capture from control names
  Add headphone auto switching controls

 sound/soc/codecs/tscs42xx.c | 37 +++--
 sound/soc/codecs/tscs42xx.h |  8 
 2 files changed, 31 insertions(+), 14 deletions(-)

-- 
2.17.0



[alsa-devel][PATCH 0/3] ASoC: TSCS42xx: Control Improvements

2018-06-04 Thread Steven Eckhoff
Steven Eckhoff (3):
  Add mic bias boost control
  Remove Playback/Capture from control names
  Add headphone auto switching controls

 sound/soc/codecs/tscs42xx.c | 37 +++--
 sound/soc/codecs/tscs42xx.h |  8 
 2 files changed, 31 insertions(+), 14 deletions(-)

-- 
2.17.0



[alsa-devel][RESEND PATCH 1/3 v3] ASoC: TSCS42xx: Shorten lines and other cleanup

2018-04-04 Thread Steven Eckhoff
Shorten lines greater than 80 chars
Add const to struct snd_soc_component_driver

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 sound/soc/codecs/tscs42xx.c | 87 -
 1 file changed, 55 insertions(+), 32 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index bbfc73a79b18..5ad68e5538ae 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -204,7 +204,8 @@ static int power_up_audio_plls(struct snd_soc_component 
*component)
break;
default:
ret = -EINVAL;
-   dev_err(component->dev, "Unrecognized PLL output freq (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Unrecognized PLL output freq (%d)\n", ret);
return ret;
}
 
@@ -261,7 +262,8 @@ static int power_down_audio_plls(struct snd_soc_component 
*component)
 static int coeff_ram_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -280,7 +282,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
 static int coeff_ram_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -363,7 +366,8 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w,
 static int pll_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
int ret;
 
if (SND_SOC_DAPM_EVENT_ON(event))
@@ -377,7 +381,8 @@ static int pll_event(struct snd_soc_dapm_widget *w,
 static int dac_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret;
 
@@ -819,16 +824,19 @@ static int setup_sample_format(struct snd_soc_component 
*component,
dev_err(component->dev, "Unsupported format width (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_WL, 
width);
+   ret = snd_soc_component_update_bits(component,
+   R_AIC1, RM_AIC1_WL, width);
if (ret < 0) {
-   dev_err(component->dev, "Failed to set sample width (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to set sample width (%d)\n", ret);
return ret;
}
 
return 0;
 }
 
-static int setup_sample_rate(struct snd_soc_component *component, unsigned int 
rate)
+static int setup_sample_rate(struct snd_soc_component *component,
+   unsigned int rate)
 {
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
unsigned int br, bm;
@@ -881,24 +889,32 @@ static int setup_sample_rate(struct snd_soc_component 
*component, unsigned int r
}
 
/* DAC and ADC share bit and frame clock */
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBR, 
br);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBR, br);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBM, 
bm);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBM, bm);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   &q

[alsa-devel][RESEND PATCH 1/3 v3] ASoC: TSCS42xx: Shorten lines and other cleanup

2018-04-04 Thread Steven Eckhoff
Shorten lines greater than 80 chars
Add const to struct snd_soc_component_driver

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 87 -
 1 file changed, 55 insertions(+), 32 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index bbfc73a79b18..5ad68e5538ae 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -204,7 +204,8 @@ static int power_up_audio_plls(struct snd_soc_component 
*component)
break;
default:
ret = -EINVAL;
-   dev_err(component->dev, "Unrecognized PLL output freq (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Unrecognized PLL output freq (%d)\n", ret);
return ret;
}
 
@@ -261,7 +262,8 @@ static int power_down_audio_plls(struct snd_soc_component 
*component)
 static int coeff_ram_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -280,7 +282,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
 static int coeff_ram_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -363,7 +366,8 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w,
 static int pll_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
int ret;
 
if (SND_SOC_DAPM_EVENT_ON(event))
@@ -377,7 +381,8 @@ static int pll_event(struct snd_soc_dapm_widget *w,
 static int dac_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret;
 
@@ -819,16 +824,19 @@ static int setup_sample_format(struct snd_soc_component 
*component,
dev_err(component->dev, "Unsupported format width (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_WL, 
width);
+   ret = snd_soc_component_update_bits(component,
+   R_AIC1, RM_AIC1_WL, width);
if (ret < 0) {
-   dev_err(component->dev, "Failed to set sample width (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to set sample width (%d)\n", ret);
return ret;
}
 
return 0;
 }
 
-static int setup_sample_rate(struct snd_soc_component *component, unsigned int 
rate)
+static int setup_sample_rate(struct snd_soc_component *component,
+   unsigned int rate)
 {
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
unsigned int br, bm;
@@ -881,24 +889,32 @@ static int setup_sample_rate(struct snd_soc_component 
*component, unsigned int r
}
 
/* DAC and ADC share bit and frame clock */
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBR, 
br);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBR, br);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBM, 
bm);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBM, bm);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n&qu

[alsa-devel][RESEND PATCH 3/3 v3] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-04-04 Thread Steven Eckhoff
The TSCS42xx relies on set_sysclk to get a unique clock id and rate,
which prevents it from being used with the simple-card.

Remove set_sysclk callback
Add CCF support to get clock id and rate
Add clocks and clock-names to device tree binding

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 .../devicetree/bindings/sound/tscs42xx.txt |   6 ++
 sound/soc/codecs/tscs42xx.c| 104 ++---
 sound/soc/codecs/tscs42xx.h|   2 +-
 3 files changed, 75 insertions(+), 37 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
index 2ac2f0996697..7eea32e9d078 100644
--- a/Documentation/devicetree/bindings/sound/tscs42xx.txt
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -8,9 +8,15 @@ Required Properties:
- reg : <0x71> for analog mic
<0x69> for digital mic
 
+   - clock-names:  Must one of  the following "mclk1", "xtal", "mclk2"
+
+   - clocks:   phandle of the clock that provides the codec sysclk
+
 Example:
 
 wookie: codec@69 {
compatible = "tempo,tscs42A2";
reg = <0x69>;
+   clock-names = "xtal";
+   clocks = <_xtal>;
 };
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index bf207b0345f1..d18ff17719cc 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,9 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
+
+   struct clk *sysclk;
+   int sysclk_src_id;
 };
 
 struct coeff_ram_ctl {
@@ -1251,13 +1255,46 @@ static int tscs42xx_set_dai_bclk_ratio(struct 
snd_soc_dai *codec_dai,
return 0;
 }
 
-static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
-   int clk_id, unsigned int freq, int dir)
+static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
+   .hw_params  = tscs42xx_hw_params,
+   .mute_stream= tscs42xx_mute_stream,
+   .set_fmt= tscs42xx_set_dai_fmt,
+   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
+};
+
+static int part_is_valid(struct tscs42xx *tscs42xx)
 {
-   struct snd_soc_component *component = codec_dai->component;
+   int val;
int ret;
+   unsigned int reg;
+
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
+   if (ret < 0)
+   return ret;
 
-   switch (clk_id) {
+   val = reg << 8;
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
+   if (ret < 0)
+   return ret;
+
+   val |= reg;
+
+   switch (val) {
+   case 0x4A74:
+   case 0x4A73:
+   return true;
+   default:
+   return false;
+   };
+}
+
+static int set_sysclk(struct snd_soc_component *component)
+{
+   struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
+   unsigned long freq;
+   int ret;
+
+   switch (tscs42xx->sysclk_src_id) {
case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_component_write(component, R_PLLREFSEL,
@@ -1285,6 +1322,7 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
+   freq = clk_get_rate(tscs42xx->sysclk);
ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) {
dev_err(component->dev,
@@ -1295,41 +1333,13 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return 0;
 }
 
-static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
-   .hw_params  = tscs42xx_hw_params,
-   .mute_stream= tscs42xx_mute_stream,
-   .set_fmt= tscs42xx_set_dai_fmt,
-   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
-   .set_sysclk = tscs42xx_set_dai_sysclk,
-};
-
-static int part_is_valid(struct tscs42xx *tscs42xx)
+static int tscs42xx_probe(struct snd_soc_component *component)
 {
-   int val;
-   int ret;
-   unsigned int reg;
-
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
-   if (ret < 0)
-   return ret;
-
-   val = reg << 8;
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
-   if (ret < 0)
-   return ret;
-
-   val |= reg;
-
-   switch (val) {
-   case 0x4A74:
-   case 0x4A73:
-   return true;
-   default:
-   return false;
-   };
+   return set_sysclk(component);
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
+   .probe  = tscs42xx_probe,
.dapm_widgets   = tscs42xx_dapm_widgets,
.num_dapm_widgets   = ARRAY_SIZE(tscs42xx_dapm_wid

[alsa-devel][RESEND PATCH 3/3 v3] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-04-04 Thread Steven Eckhoff
The TSCS42xx relies on set_sysclk to get a unique clock id and rate,
which prevents it from being used with the simple-card.

Remove set_sysclk callback
Add CCF support to get clock id and rate
Add clocks and clock-names to device tree binding

Signed-off-by: Steven Eckhoff 
---
 .../devicetree/bindings/sound/tscs42xx.txt |   6 ++
 sound/soc/codecs/tscs42xx.c| 104 ++---
 sound/soc/codecs/tscs42xx.h|   2 +-
 3 files changed, 75 insertions(+), 37 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
index 2ac2f0996697..7eea32e9d078 100644
--- a/Documentation/devicetree/bindings/sound/tscs42xx.txt
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -8,9 +8,15 @@ Required Properties:
- reg : <0x71> for analog mic
<0x69> for digital mic
 
+   - clock-names:  Must one of  the following "mclk1", "xtal", "mclk2"
+
+   - clocks:   phandle of the clock that provides the codec sysclk
+
 Example:
 
 wookie: codec@69 {
compatible = "tempo,tscs42A2";
reg = <0x69>;
+   clock-names = "xtal";
+   clocks = <_xtal>;
 };
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index bf207b0345f1..d18ff17719cc 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,9 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
+
+   struct clk *sysclk;
+   int sysclk_src_id;
 };
 
 struct coeff_ram_ctl {
@@ -1251,13 +1255,46 @@ static int tscs42xx_set_dai_bclk_ratio(struct 
snd_soc_dai *codec_dai,
return 0;
 }
 
-static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
-   int clk_id, unsigned int freq, int dir)
+static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
+   .hw_params  = tscs42xx_hw_params,
+   .mute_stream= tscs42xx_mute_stream,
+   .set_fmt= tscs42xx_set_dai_fmt,
+   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
+};
+
+static int part_is_valid(struct tscs42xx *tscs42xx)
 {
-   struct snd_soc_component *component = codec_dai->component;
+   int val;
int ret;
+   unsigned int reg;
+
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
+   if (ret < 0)
+   return ret;
 
-   switch (clk_id) {
+   val = reg << 8;
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
+   if (ret < 0)
+   return ret;
+
+   val |= reg;
+
+   switch (val) {
+   case 0x4A74:
+   case 0x4A73:
+   return true;
+   default:
+   return false;
+   };
+}
+
+static int set_sysclk(struct snd_soc_component *component)
+{
+   struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
+   unsigned long freq;
+   int ret;
+
+   switch (tscs42xx->sysclk_src_id) {
case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_component_write(component, R_PLLREFSEL,
@@ -1285,6 +1322,7 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
+   freq = clk_get_rate(tscs42xx->sysclk);
ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) {
dev_err(component->dev,
@@ -1295,41 +1333,13 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return 0;
 }
 
-static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
-   .hw_params  = tscs42xx_hw_params,
-   .mute_stream= tscs42xx_mute_stream,
-   .set_fmt= tscs42xx_set_dai_fmt,
-   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
-   .set_sysclk = tscs42xx_set_dai_sysclk,
-};
-
-static int part_is_valid(struct tscs42xx *tscs42xx)
+static int tscs42xx_probe(struct snd_soc_component *component)
 {
-   int val;
-   int ret;
-   unsigned int reg;
-
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
-   if (ret < 0)
-   return ret;
-
-   val = reg << 8;
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
-   if (ret < 0)
-   return ret;
-
-   val |= reg;
-
-   switch (val) {
-   case 0x4A74:
-   case 0x4A73:
-   return true;
-   default:
-   return false;
-   };
+   return set_sysclk(component);
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
+   .probe  = tscs42xx_probe,
.dapm_widgets   = tscs42xx_dapm_widgets,
.num_dapm_widgets   = ARRAY_SIZE(tscs42xx_dapm_widgets),
.dapm_routes  

[alsa-devel][RESEND PATCH 2/3 v3] ASoC: TSCS42xx: Cleanup private data members

2018-04-04 Thread Steven Eckhoff
Remove blrcm from private data
Remove dev from private data

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 sound/soc/codecs/tscs42xx.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index 5ad68e5538ae..bf207b0345f1 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -31,7 +31,6 @@ struct tscs42xx {
 
int bclk_ratio;
int samplerate;
-   unsigned int blrcm;
struct mutex audio_params_lock;
 
u8 coeff_ram[COEFF_RAM_SIZE];
@@ -41,8 +40,6 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
-
-   struct device *dev;
 };
 
 struct coeff_ram_ctl {
@@ -1404,12 +1401,11 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
return ret;
}
i2c_set_clientdata(i2c, tscs42xx);
-   tscs42xx->dev = >dev;
 
tscs42xx->regmap = devm_regmap_init_i2c(i2c, _regmap);
if (IS_ERR(tscs42xx->regmap)) {
ret = PTR_ERR(tscs42xx->regmap);
-   dev_err(tscs42xx->dev, "Failed to allocate regmap (%d)\n", ret);
+   dev_err(>dev, "Failed to allocate regmap (%d)\n", ret);
return ret;
}
 
@@ -1417,21 +1413,21 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
 
ret = part_is_valid(tscs42xx);
if (ret <= 0) {
-   dev_err(tscs42xx->dev, "No valid part (%d)\n", ret);
+   dev_err(>dev, "No valid part (%d)\n", ret);
ret = -ENODEV;
return ret;
}
 
ret = regmap_write(tscs42xx->regmap, R_RESET, RV_RESET_ENABLE);
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to reset device (%d)\n", ret);
+   dev_err(>dev, "Failed to reset device (%d)\n", ret);
return ret;
}
 
ret = regmap_register_patch(tscs42xx->regmap, tscs42xx_patch,
ARRAY_SIZE(tscs42xx_patch));
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to apply patch (%d)\n", ret);
+   dev_err(>dev, "Failed to apply patch (%d)\n", ret);
return ret;
}
 
@@ -1439,10 +1435,10 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
mutex_init(>coeff_ram_lock);
mutex_init(>pll_lock);
 
-   ret = devm_snd_soc_register_component(tscs42xx->dev,
+   ret = devm_snd_soc_register_component(>dev,
_codec_dev_tscs42xx, _dai, 1);
if (ret) {
-   dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret);
+   dev_err(>dev, "Failed to register codec (%d)\n", ret);
return ret;
}
 
-- 
2.15.1



[alsa-devel][RESEND PATCH 2/3 v3] ASoC: TSCS42xx: Cleanup private data members

2018-04-04 Thread Steven Eckhoff
Remove blrcm from private data
Remove dev from private data

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index 5ad68e5538ae..bf207b0345f1 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -31,7 +31,6 @@ struct tscs42xx {
 
int bclk_ratio;
int samplerate;
-   unsigned int blrcm;
struct mutex audio_params_lock;
 
u8 coeff_ram[COEFF_RAM_SIZE];
@@ -41,8 +40,6 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
-
-   struct device *dev;
 };
 
 struct coeff_ram_ctl {
@@ -1404,12 +1401,11 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
return ret;
}
i2c_set_clientdata(i2c, tscs42xx);
-   tscs42xx->dev = >dev;
 
tscs42xx->regmap = devm_regmap_init_i2c(i2c, _regmap);
if (IS_ERR(tscs42xx->regmap)) {
ret = PTR_ERR(tscs42xx->regmap);
-   dev_err(tscs42xx->dev, "Failed to allocate regmap (%d)\n", ret);
+   dev_err(>dev, "Failed to allocate regmap (%d)\n", ret);
return ret;
}
 
@@ -1417,21 +1413,21 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
 
ret = part_is_valid(tscs42xx);
if (ret <= 0) {
-   dev_err(tscs42xx->dev, "No valid part (%d)\n", ret);
+   dev_err(>dev, "No valid part (%d)\n", ret);
ret = -ENODEV;
return ret;
}
 
ret = regmap_write(tscs42xx->regmap, R_RESET, RV_RESET_ENABLE);
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to reset device (%d)\n", ret);
+   dev_err(>dev, "Failed to reset device (%d)\n", ret);
return ret;
}
 
ret = regmap_register_patch(tscs42xx->regmap, tscs42xx_patch,
ARRAY_SIZE(tscs42xx_patch));
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to apply patch (%d)\n", ret);
+   dev_err(>dev, "Failed to apply patch (%d)\n", ret);
return ret;
}
 
@@ -1439,10 +1435,10 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
mutex_init(>coeff_ram_lock);
mutex_init(>pll_lock);
 
-   ret = devm_snd_soc_register_component(tscs42xx->dev,
+   ret = devm_snd_soc_register_component(>dev,
_codec_dev_tscs42xx, _dai, 1);
if (ret) {
-   dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret);
+   dev_err(>dev, "Failed to register codec (%d)\n", ret);
return ret;
}
 
-- 
2.15.1



Re: [alsa-devel][PATCH 1/3 v3] ASoC: TSCS42xx: Shorten lines and other cleanup

2018-04-03 Thread Steven Eckhoff
On Mon, Apr 02, 2018 at 04:23:35PM +0100, Mark Brown wrote:
> I only seem to have patches 1 and 2 here (and they aren't threaded with
> each other which is a bit odd too).  I seem to recall this has been
> happening quite a bit with your patches - in general if you're sending
> things you should always send the entire series at once, ideally
> threaded together.  Sending things separately makes it very error prone
> to try to follow which patches go together.
I apologize for the delay. I am just seeing this. I will resend with
them threaded.


Re: [alsa-devel][PATCH 1/3 v3] ASoC: TSCS42xx: Shorten lines and other cleanup

2018-04-03 Thread Steven Eckhoff
On Mon, Apr 02, 2018 at 04:23:35PM +0100, Mark Brown wrote:
> I only seem to have patches 1 and 2 here (and they aren't threaded with
> each other which is a bit odd too).  I seem to recall this has been
> happening quite a bit with your patches - in general if you're sending
> things you should always send the entire series at once, ideally
> threaded together.  Sending things separately makes it very error prone
> to try to follow which patches go together.
I apologize for the delay. I am just seeing this. I will resend with
them threaded.


Re: [alsa-devel][PATCH 3/3 v3] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-03-28 Thread Steven Eckhoff
On Wed, Mar 28, 2018 at 10:44:27AM +0800, Mark Brown wrote:
> I'm missing patches 1 and 2 of this resend.

I apologize I just sent them.


Re: [alsa-devel][PATCH 3/3 v3] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-03-28 Thread Steven Eckhoff
On Wed, Mar 28, 2018 at 10:44:27AM +0800, Mark Brown wrote:
> I'm missing patches 1 and 2 of this resend.

I apologize I just sent them.


[alsa-devel][PATCH 2/3 v3] ASoC: TSCS42xx: Cleanup private data members

2018-03-28 Thread Steven Eckhoff
Remove blrcm from private data
Remove dev from private data

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 sound/soc/codecs/tscs42xx.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index 37636d6efe60..d41852a37ac6 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -31,7 +31,6 @@ struct tscs42xx {
 
int bclk_ratio;
int samplerate;
-   unsigned int blrcm;
struct mutex audio_params_lock;
 
u8 coeff_ram[COEFF_RAM_SIZE];
@@ -41,8 +40,6 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
-
-   struct device *dev;
 };
 
 struct coeff_ram_ctl {
@@ -1404,12 +1401,11 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
return ret;
}
i2c_set_clientdata(i2c, tscs42xx);
-   tscs42xx->dev = >dev;
 
tscs42xx->regmap = devm_regmap_init_i2c(i2c, _regmap);
if (IS_ERR(tscs42xx->regmap)) {
ret = PTR_ERR(tscs42xx->regmap);
-   dev_err(tscs42xx->dev, "Failed to allocate regmap (%d)\n", ret);
+   dev_err(>dev, "Failed to allocate regmap (%d)\n", ret);
return ret;
}
 
@@ -1417,21 +1413,21 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
 
ret = part_is_valid(tscs42xx);
if (ret <= 0) {
-   dev_err(tscs42xx->dev, "No valid part (%d)\n", ret);
+   dev_err(>dev, "No valid part (%d)\n", ret);
ret = -ENODEV;
return ret;
}
 
ret = regmap_write(tscs42xx->regmap, R_RESET, RV_RESET_ENABLE);
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to reset device (%d)\n", ret);
+   dev_err(>dev, "Failed to reset device (%d)\n", ret);
return ret;
}
 
ret = regmap_register_patch(tscs42xx->regmap, tscs42xx_patch,
ARRAY_SIZE(tscs42xx_patch));
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to apply patch (%d)\n", ret);
+   dev_err(>dev, "Failed to apply patch (%d)\n", ret);
return ret;
}
 
@@ -1439,10 +1435,10 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
mutex_init(>coeff_ram_lock);
mutex_init(>pll_lock);
 
-   ret = devm_snd_soc_register_component(tscs42xx->dev,
+   ret = devm_snd_soc_register_component(>dev,
_codec_dev_tscs42xx, _dai, 1);
if (ret) {
-   dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret);
+   dev_err(>dev, "Failed to register codec (%d)\n", ret);
return ret;
}
 
-- 
2.15.1



[alsa-devel][PATCH 2/3 v3] ASoC: TSCS42xx: Cleanup private data members

2018-03-28 Thread Steven Eckhoff
Remove blrcm from private data
Remove dev from private data

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index 37636d6efe60..d41852a37ac6 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -31,7 +31,6 @@ struct tscs42xx {
 
int bclk_ratio;
int samplerate;
-   unsigned int blrcm;
struct mutex audio_params_lock;
 
u8 coeff_ram[COEFF_RAM_SIZE];
@@ -41,8 +40,6 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
-
-   struct device *dev;
 };
 
 struct coeff_ram_ctl {
@@ -1404,12 +1401,11 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
return ret;
}
i2c_set_clientdata(i2c, tscs42xx);
-   tscs42xx->dev = >dev;
 
tscs42xx->regmap = devm_regmap_init_i2c(i2c, _regmap);
if (IS_ERR(tscs42xx->regmap)) {
ret = PTR_ERR(tscs42xx->regmap);
-   dev_err(tscs42xx->dev, "Failed to allocate regmap (%d)\n", ret);
+   dev_err(>dev, "Failed to allocate regmap (%d)\n", ret);
return ret;
}
 
@@ -1417,21 +1413,21 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
 
ret = part_is_valid(tscs42xx);
if (ret <= 0) {
-   dev_err(tscs42xx->dev, "No valid part (%d)\n", ret);
+   dev_err(>dev, "No valid part (%d)\n", ret);
ret = -ENODEV;
return ret;
}
 
ret = regmap_write(tscs42xx->regmap, R_RESET, RV_RESET_ENABLE);
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to reset device (%d)\n", ret);
+   dev_err(>dev, "Failed to reset device (%d)\n", ret);
return ret;
}
 
ret = regmap_register_patch(tscs42xx->regmap, tscs42xx_patch,
ARRAY_SIZE(tscs42xx_patch));
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to apply patch (%d)\n", ret);
+   dev_err(>dev, "Failed to apply patch (%d)\n", ret);
return ret;
}
 
@@ -1439,10 +1435,10 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
mutex_init(>coeff_ram_lock);
mutex_init(>pll_lock);
 
-   ret = devm_snd_soc_register_component(tscs42xx->dev,
+   ret = devm_snd_soc_register_component(>dev,
_codec_dev_tscs42xx, _dai, 1);
if (ret) {
-   dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret);
+   dev_err(>dev, "Failed to register codec (%d)\n", ret);
return ret;
}
 
-- 
2.15.1



[alsa-devel][PATCH 1/3 v3] ASoC: TSCS42xx: Shorten lines and other cleanup

2018-03-28 Thread Steven Eckhoff
Shorten lines greater than 80 chars
Add const to struct snd_soc_component_driver

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 sound/soc/codecs/tscs42xx.c | 87 -
 1 file changed, 55 insertions(+), 32 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index cfc71b5411ee..37636d6efe60 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -204,7 +204,8 @@ static int power_up_audio_plls(struct snd_soc_component 
*component)
break;
default:
ret = -EINVAL;
-   dev_err(component->dev, "Unrecognized PLL output freq (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Unrecognized PLL output freq (%d)\n", ret);
return ret;
}
 
@@ -261,7 +262,8 @@ static int power_down_audio_plls(struct snd_soc_component 
*component)
 static int coeff_ram_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -280,7 +282,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
 static int coeff_ram_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -363,7 +366,8 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w,
 static int pll_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
int ret;
 
if (SND_SOC_DAPM_EVENT_ON(event))
@@ -377,7 +381,8 @@ static int pll_event(struct snd_soc_dapm_widget *w,
 static int dac_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret;
 
@@ -819,16 +824,19 @@ static int setup_sample_format(struct snd_soc_component 
*component,
dev_err(component->dev, "Unsupported format width (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_WL, 
width);
+   ret = snd_soc_component_update_bits(component,
+   R_AIC1, RM_AIC1_WL, width);
if (ret < 0) {
-   dev_err(component->dev, "Failed to set sample width (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to set sample width (%d)\n", ret);
return ret;
}
 
return 0;
 }
 
-static int setup_sample_rate(struct snd_soc_component *component, unsigned int 
rate)
+static int setup_sample_rate(struct snd_soc_component *component,
+   unsigned int rate)
 {
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
unsigned int br, bm;
@@ -881,24 +889,32 @@ static int setup_sample_rate(struct snd_soc_component 
*component, unsigned int r
}
 
/* DAC and ADC share bit and frame clock */
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBR, 
br);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBR, br);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBM, 
bm);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBM, bm);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   &q

[alsa-devel][PATCH 1/3 v3] ASoC: TSCS42xx: Shorten lines and other cleanup

2018-03-28 Thread Steven Eckhoff
Shorten lines greater than 80 chars
Add const to struct snd_soc_component_driver

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 87 -
 1 file changed, 55 insertions(+), 32 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index cfc71b5411ee..37636d6efe60 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -204,7 +204,8 @@ static int power_up_audio_plls(struct snd_soc_component 
*component)
break;
default:
ret = -EINVAL;
-   dev_err(component->dev, "Unrecognized PLL output freq (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Unrecognized PLL output freq (%d)\n", ret);
return ret;
}
 
@@ -261,7 +262,8 @@ static int power_down_audio_plls(struct snd_soc_component 
*component)
 static int coeff_ram_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -280,7 +282,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
 static int coeff_ram_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -363,7 +366,8 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w,
 static int pll_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
int ret;
 
if (SND_SOC_DAPM_EVENT_ON(event))
@@ -377,7 +381,8 @@ static int pll_event(struct snd_soc_dapm_widget *w,
 static int dac_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret;
 
@@ -819,16 +824,19 @@ static int setup_sample_format(struct snd_soc_component 
*component,
dev_err(component->dev, "Unsupported format width (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_WL, 
width);
+   ret = snd_soc_component_update_bits(component,
+   R_AIC1, RM_AIC1_WL, width);
if (ret < 0) {
-   dev_err(component->dev, "Failed to set sample width (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to set sample width (%d)\n", ret);
return ret;
}
 
return 0;
 }
 
-static int setup_sample_rate(struct snd_soc_component *component, unsigned int 
rate)
+static int setup_sample_rate(struct snd_soc_component *component,
+   unsigned int rate)
 {
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
unsigned int br, bm;
@@ -881,24 +889,32 @@ static int setup_sample_rate(struct snd_soc_component 
*component, unsigned int r
}
 
/* DAC and ADC share bit and frame clock */
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBR, 
br);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBR, br);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBM, 
bm);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBM, bm);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n&qu

[alsa-devel][PATCH 3/3 v3] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-03-27 Thread Steven Eckhoff
The TSCS42xx relies on set_sysclk to get a unique clock id and rate,
which
prevents it from being used with the simple-card.

Remove set_sysclk callback
Add CCF support to get clock id and rate
Add clocks and clock-names to device tree binding

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 .../devicetree/bindings/sound/tscs42xx.txt |   6 ++
 sound/soc/codecs/tscs42xx.c| 104 ++---
 sound/soc/codecs/tscs42xx.h|   2 +-
 3 files changed, 75 insertions(+), 37 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
index 2ac2f0996697..7eea32e9d078 100644
--- a/Documentation/devicetree/bindings/sound/tscs42xx.txt
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -8,9 +8,15 @@ Required Properties:
- reg : <0x71> for analog mic
<0x69> for digital mic
 
+   - clock-names:  Must one of  the following "mclk1", "xtal", "mclk2"
+
+   - clocks:   phandle of the clock that provides the codec sysclk
+
 Example:
 
 wookie: codec@69 {
compatible = "tempo,tscs42A2";
reg = <0x69>;
+   clock-names = "xtal";
+   clocks = <_xtal>;
 };
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index d41852a37ac6..0aaa6a826096 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,9 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
+
+   struct clk *sysclk;
+   int sysclk_src_id;
 };
 
 struct coeff_ram_ctl {
@@ -1251,13 +1255,46 @@ static int tscs42xx_set_dai_bclk_ratio(struct 
snd_soc_dai *codec_dai,
return 0;
 }
 
-static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
-   int clk_id, unsigned int freq, int dir)
+static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
+   .hw_params  = tscs42xx_hw_params,
+   .mute_stream= tscs42xx_mute_stream,
+   .set_fmt= tscs42xx_set_dai_fmt,
+   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
+};
+
+static int part_is_valid(struct tscs42xx *tscs42xx)
 {
-   struct snd_soc_component *component = codec_dai->component;
+   int val;
int ret;
+   unsigned int reg;
+
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
+   if (ret < 0)
+   return ret;
 
-   switch (clk_id) {
+   val = reg << 8;
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
+   if (ret < 0)
+   return ret;
+
+   val |= reg;
+
+   switch (val) {
+   case 0x4A74:
+   case 0x4A73:
+   return true;
+   default:
+   return false;
+   };
+}
+
+static int set_sysclk(struct snd_soc_component *component)
+{
+   struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
+   unsigned long freq;
+   int ret;
+
+   switch (tscs42xx->sysclk_src_id) {
case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_component_write(component, R_PLLREFSEL,
@@ -1285,6 +1322,7 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
+   freq = clk_get_rate(tscs42xx->sysclk);
ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) {
dev_err(component->dev,
@@ -1295,41 +1333,13 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return 0;
 }
 
-static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
-   .hw_params  = tscs42xx_hw_params,
-   .mute_stream= tscs42xx_mute_stream,
-   .set_fmt= tscs42xx_set_dai_fmt,
-   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
-   .set_sysclk = tscs42xx_set_dai_sysclk,
-};
-
-static int part_is_valid(struct tscs42xx *tscs42xx)
+static int tscs42xx_probe(struct snd_soc_component *component)
 {
-   int val;
-   int ret;
-   unsigned int reg;
-
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
-   if (ret < 0)
-   return ret;
-
-   val = reg << 8;
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
-   if (ret < 0)
-   return ret;
-
-   val |= reg;
-
-   switch (val) {
-   case 0x4A74:
-   case 0x4A73:
-   return true;
-   default:
-   return false;
-   };
+   return set_sysclk(component);
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
+   .probe  = tscs42xx_probe,
.dapm_widgets   = tscs42xx_dapm_widgets,
.num_dapm_widgets   = ARRAY_SIZE(tscs42xx_dapm_wid

[alsa-devel][PATCH 3/3 v3] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-03-27 Thread Steven Eckhoff
The TSCS42xx relies on set_sysclk to get a unique clock id and rate,
which
prevents it from being used with the simple-card.

Remove set_sysclk callback
Add CCF support to get clock id and rate
Add clocks and clock-names to device tree binding

Signed-off-by: Steven Eckhoff 
---
 .../devicetree/bindings/sound/tscs42xx.txt |   6 ++
 sound/soc/codecs/tscs42xx.c| 104 ++---
 sound/soc/codecs/tscs42xx.h|   2 +-
 3 files changed, 75 insertions(+), 37 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
index 2ac2f0996697..7eea32e9d078 100644
--- a/Documentation/devicetree/bindings/sound/tscs42xx.txt
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -8,9 +8,15 @@ Required Properties:
- reg : <0x71> for analog mic
<0x69> for digital mic
 
+   - clock-names:  Must one of  the following "mclk1", "xtal", "mclk2"
+
+   - clocks:   phandle of the clock that provides the codec sysclk
+
 Example:
 
 wookie: codec@69 {
compatible = "tempo,tscs42A2";
reg = <0x69>;
+   clock-names = "xtal";
+   clocks = <_xtal>;
 };
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index d41852a37ac6..0aaa6a826096 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,9 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
+
+   struct clk *sysclk;
+   int sysclk_src_id;
 };
 
 struct coeff_ram_ctl {
@@ -1251,13 +1255,46 @@ static int tscs42xx_set_dai_bclk_ratio(struct 
snd_soc_dai *codec_dai,
return 0;
 }
 
-static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
-   int clk_id, unsigned int freq, int dir)
+static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
+   .hw_params  = tscs42xx_hw_params,
+   .mute_stream= tscs42xx_mute_stream,
+   .set_fmt= tscs42xx_set_dai_fmt,
+   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
+};
+
+static int part_is_valid(struct tscs42xx *tscs42xx)
 {
-   struct snd_soc_component *component = codec_dai->component;
+   int val;
int ret;
+   unsigned int reg;
+
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
+   if (ret < 0)
+   return ret;
 
-   switch (clk_id) {
+   val = reg << 8;
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
+   if (ret < 0)
+   return ret;
+
+   val |= reg;
+
+   switch (val) {
+   case 0x4A74:
+   case 0x4A73:
+   return true;
+   default:
+   return false;
+   };
+}
+
+static int set_sysclk(struct snd_soc_component *component)
+{
+   struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
+   unsigned long freq;
+   int ret;
+
+   switch (tscs42xx->sysclk_src_id) {
case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_component_write(component, R_PLLREFSEL,
@@ -1285,6 +1322,7 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
+   freq = clk_get_rate(tscs42xx->sysclk);
ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) {
dev_err(component->dev,
@@ -1295,41 +1333,13 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return 0;
 }
 
-static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
-   .hw_params  = tscs42xx_hw_params,
-   .mute_stream= tscs42xx_mute_stream,
-   .set_fmt= tscs42xx_set_dai_fmt,
-   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
-   .set_sysclk = tscs42xx_set_dai_sysclk,
-};
-
-static int part_is_valid(struct tscs42xx *tscs42xx)
+static int tscs42xx_probe(struct snd_soc_component *component)
 {
-   int val;
-   int ret;
-   unsigned int reg;
-
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
-   if (ret < 0)
-   return ret;
-
-   val = reg << 8;
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
-   if (ret < 0)
-   return ret;
-
-   val |= reg;
-
-   switch (val) {
-   case 0x4A74:
-   case 0x4A73:
-   return true;
-   default:
-   return false;
-   };
+   return set_sysclk(component);
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
+   .probe  = tscs42xx_probe,
.dapm_widgets   = tscs42xx_dapm_widgets,
.num_dapm_widgets   = ARRAY_SIZE(tscs42xx_dapm_widgets),
.dapm_routes  

[alsa-devel][PATCH 3/3 v2] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-03-27 Thread Steven Eckhoff
The TSCS42xx relies on set_sysclk to get a unique clock id and rate,
which
prevents it from being used with the simple-card.

Remove set_sysclk callback
Add CCF support to get clock id and rate
Add clocks and clock-names to device tree binding

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 .../devicetree/bindings/sound/tscs42xx.txt |   6 ++
 sound/soc/codecs/tscs42xx.c| 104 ++---
 sound/soc/codecs/tscs42xx.h|   2 +-
 3 files changed, 75 insertions(+), 37 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
index 2ac2f0996697..7eea32e9d078 100644
--- a/Documentation/devicetree/bindings/sound/tscs42xx.txt
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -8,9 +8,15 @@ Required Properties:
- reg : <0x71> for analog mic
<0x69> for digital mic
 
+   - clock-names:  Must one of  the following "mclk1", "xtal", "mclk2"
+
+   - clocks:   phandle of the clock that provides the codec sysclk
+
 Example:
 
 wookie: codec@69 {
compatible = "tempo,tscs42A2";
reg = <0x69>;
+   clock-names = "xtal";
+   clocks = <_xtal>;
 };
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index d41852a37ac6..69cd4c1ed1d6 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,9 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
+
+   struct clk *sysclk;
+   int sysclk_src_id;
 };
 
 struct coeff_ram_ctl {
@@ -1251,13 +1255,46 @@ static int tscs42xx_set_dai_bclk_ratio(struct 
snd_soc_dai *codec_dai,
return 0;
 }
 
-static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
-   int clk_id, unsigned int freq, int dir)
+static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
+   .hw_params  = tscs42xx_hw_params,
+   .mute_stream= tscs42xx_mute_stream,
+   .set_fmt= tscs42xx_set_dai_fmt,
+   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
+};
+
+static int part_is_valid(struct tscs42xx *tscs42xx)
 {
-   struct snd_soc_component *component = codec_dai->component;
+   int val;
int ret;
+   unsigned int reg;
+
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
+   if (ret < 0)
+   return ret;
 
-   switch (clk_id) {
+   val = reg << 8;
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
+   if (ret < 0)
+   return ret;
+
+   val |= reg;
+
+   switch (val) {
+   case 0x4A74:
+   case 0x4A73:
+   return true;
+   default:
+   return false;
+   };
+}
+
+static int set_sysclk(struct snd_soc_component *component)
+{
+   struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
+   unsigned long freq;
+   int ret;
+
+   switch (tscs42xx->sysclk_src_id) {
case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_component_write(component, R_PLLREFSEL,
@@ -1285,6 +1322,7 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
+   freq = clk_get_rate(tscs42xx->sysclk);
ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) {
dev_err(component->dev,
@@ -1295,41 +1333,13 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return 0;
 }
 
-static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
-   .hw_params  = tscs42xx_hw_params,
-   .mute_stream= tscs42xx_mute_stream,
-   .set_fmt= tscs42xx_set_dai_fmt,
-   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
-   .set_sysclk = tscs42xx_set_dai_sysclk,
-};
-
-static int part_is_valid(struct tscs42xx *tscs42xx)
+static int tscs42xx_probe(struct snd_soc_component *component)
 {
-   int val;
-   int ret;
-   unsigned int reg;
-
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
-   if (ret < 0)
-   return ret;
-
-   val = reg << 8;
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
-   if (ret < 0)
-   return ret;
-
-   val |= reg;
-
-   switch (val) {
-   case 0x4A74:
-   case 0x4A73:
-   return true;
-   default:
-   return false;
-   };
+   return set_sysclk(component);
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
+   .probe  = tscs42xx_probe,
.dapm_widgets   = tscs42xx_dapm_widgets,
.num_dapm_widgets   = ARRAY_SIZE(tscs42xx_dapm_wid

[alsa-devel][PATCH 3/3 v2] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-03-27 Thread Steven Eckhoff
The TSCS42xx relies on set_sysclk to get a unique clock id and rate,
which
prevents it from being used with the simple-card.

Remove set_sysclk callback
Add CCF support to get clock id and rate
Add clocks and clock-names to device tree binding

Signed-off-by: Steven Eckhoff 
---
 .../devicetree/bindings/sound/tscs42xx.txt |   6 ++
 sound/soc/codecs/tscs42xx.c| 104 ++---
 sound/soc/codecs/tscs42xx.h|   2 +-
 3 files changed, 75 insertions(+), 37 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
index 2ac2f0996697..7eea32e9d078 100644
--- a/Documentation/devicetree/bindings/sound/tscs42xx.txt
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -8,9 +8,15 @@ Required Properties:
- reg : <0x71> for analog mic
<0x69> for digital mic
 
+   - clock-names:  Must one of  the following "mclk1", "xtal", "mclk2"
+
+   - clocks:   phandle of the clock that provides the codec sysclk
+
 Example:
 
 wookie: codec@69 {
compatible = "tempo,tscs42A2";
reg = <0x69>;
+   clock-names = "xtal";
+   clocks = <_xtal>;
 };
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index d41852a37ac6..69cd4c1ed1d6 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,9 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
+
+   struct clk *sysclk;
+   int sysclk_src_id;
 };
 
 struct coeff_ram_ctl {
@@ -1251,13 +1255,46 @@ static int tscs42xx_set_dai_bclk_ratio(struct 
snd_soc_dai *codec_dai,
return 0;
 }
 
-static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
-   int clk_id, unsigned int freq, int dir)
+static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
+   .hw_params  = tscs42xx_hw_params,
+   .mute_stream= tscs42xx_mute_stream,
+   .set_fmt= tscs42xx_set_dai_fmt,
+   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
+};
+
+static int part_is_valid(struct tscs42xx *tscs42xx)
 {
-   struct snd_soc_component *component = codec_dai->component;
+   int val;
int ret;
+   unsigned int reg;
+
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
+   if (ret < 0)
+   return ret;
 
-   switch (clk_id) {
+   val = reg << 8;
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
+   if (ret < 0)
+   return ret;
+
+   val |= reg;
+
+   switch (val) {
+   case 0x4A74:
+   case 0x4A73:
+   return true;
+   default:
+   return false;
+   };
+}
+
+static int set_sysclk(struct snd_soc_component *component)
+{
+   struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
+   unsigned long freq;
+   int ret;
+
+   switch (tscs42xx->sysclk_src_id) {
case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_component_write(component, R_PLLREFSEL,
@@ -1285,6 +1322,7 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
+   freq = clk_get_rate(tscs42xx->sysclk);
ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) {
dev_err(component->dev,
@@ -1295,41 +1333,13 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return 0;
 }
 
-static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
-   .hw_params  = tscs42xx_hw_params,
-   .mute_stream= tscs42xx_mute_stream,
-   .set_fmt= tscs42xx_set_dai_fmt,
-   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
-   .set_sysclk = tscs42xx_set_dai_sysclk,
-};
-
-static int part_is_valid(struct tscs42xx *tscs42xx)
+static int tscs42xx_probe(struct snd_soc_component *component)
 {
-   int val;
-   int ret;
-   unsigned int reg;
-
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
-   if (ret < 0)
-   return ret;
-
-   val = reg << 8;
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
-   if (ret < 0)
-   return ret;
-
-   val |= reg;
-
-   switch (val) {
-   case 0x4A74:
-   case 0x4A73:
-   return true;
-   default:
-   return false;
-   };
+   return set_sysclk(component);
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
+   .probe  = tscs42xx_probe,
.dapm_widgets   = tscs42xx_dapm_widgets,
.num_dapm_widgets   = ARRAY_SIZE(tscs42xx_dapm_widgets),
.dapm_routes  

[alsa-devel][PATCH 3/3] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-03-23 Thread Steven Eckhoff
The TSCS42xx relies on set_sysclk to get a unique clock id and rate, which
prevents it from being used with the simple-card.

Remove set_sysclk callback
Add CCF support to get clock id and rate
Add clocks and clock-names to device tree binding

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 .../devicetree/bindings/sound/tscs42xx.txt |  6 ++
 sound/soc/codecs/tscs42xx.c| 98 ++
 sound/soc/codecs/tscs42xx.h|  2 +-
 3 files changed, 69 insertions(+), 37 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
index 2ac2f0996697..7eea32e9d078 100644
--- a/Documentation/devicetree/bindings/sound/tscs42xx.txt
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -8,9 +8,15 @@ Required Properties:
- reg : <0x71> for analog mic
<0x69> for digital mic
 
+   - clock-names:  Must one of  the following "mclk1", "xtal", "mclk2"
+
+   - clocks:   phandle of the clock that provides the codec sysclk
+
 Example:
 
 wookie: codec@69 {
compatible = "tempo,tscs42A2";
reg = <0x69>;
+   clock-names = "xtal";
+   clocks = <_xtal>;
 };
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index d41852a37ac6..081af0e05d33 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,9 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
+
+   struct clk *sysclk;
+   int sysclk_src_id;
 };
 
 struct coeff_ram_ctl {
@@ -1251,13 +1255,46 @@ static int tscs42xx_set_dai_bclk_ratio(struct 
snd_soc_dai *codec_dai,
return 0;
 }
 
-static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
-   int clk_id, unsigned int freq, int dir)
+static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
+   .hw_params  = tscs42xx_hw_params,
+   .mute_stream= tscs42xx_mute_stream,
+   .set_fmt= tscs42xx_set_dai_fmt,
+   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
+};
+
+static int part_is_valid(struct tscs42xx *tscs42xx)
 {
-   struct snd_soc_component *component = codec_dai->component;
+   int val;
int ret;
+   unsigned int reg;
 
-   switch (clk_id) {
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
+   if (ret < 0)
+   return ret;
+
+   val = reg << 8;
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
+   if (ret < 0)
+   return ret;
+
+   val |= reg;
+
+   switch (val) {
+   case 0x4A74:
+   case 0x4A73:
+   return true;
+   default:
+   return false;
+   };
+}
+
+static int set_sysclk(struct snd_soc_component *component)
+{
+   struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
+   unsigned long freq;
+   int ret;
+
+   switch (tscs42xx->sysclk_src_id) {
case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_component_write(component, R_PLLREFSEL,
@@ -1285,6 +1322,7 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
+   freq = clk_get_rate(tscs42xx->sysclk);
ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) {
dev_err(component->dev,
@@ -1295,41 +1333,13 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return 0;
 }
 
-static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
-   .hw_params  = tscs42xx_hw_params,
-   .mute_stream= tscs42xx_mute_stream,
-   .set_fmt= tscs42xx_set_dai_fmt,
-   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
-   .set_sysclk = tscs42xx_set_dai_sysclk,
-};
-
-static int part_is_valid(struct tscs42xx *tscs42xx)
+static int tscs42xx_probe(struct snd_soc_component *component)
 {
-   int val;
-   int ret;
-   unsigned int reg;
-
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
-   if (ret < 0)
-   return ret;
-
-   val = reg << 8;
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
-   if (ret < 0)
-   return ret;
-
-   val |= reg;
-
-   switch (val) {
-   case 0x4A74:
-   case 0x4A73:
-   return true;
-   default:
-   return false;
-   };
+   return set_sysclk(component);
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
+   .probe  = tscs42xx_probe,
.dapm_widgets   = tscs42xx_dapm_widgets,
.num_dapm_widgets   = ARRAY_SIZE(tscs42xx_dapm_wid

[alsa-devel][PATCH 3/3] ASoC: TSCS42xx: Add CCF support to get sysclk

2018-03-23 Thread Steven Eckhoff
The TSCS42xx relies on set_sysclk to get a unique clock id and rate, which
prevents it from being used with the simple-card.

Remove set_sysclk callback
Add CCF support to get clock id and rate
Add clocks and clock-names to device tree binding

Signed-off-by: Steven Eckhoff 
---
 .../devicetree/bindings/sound/tscs42xx.txt |  6 ++
 sound/soc/codecs/tscs42xx.c| 98 ++
 sound/soc/codecs/tscs42xx.h|  2 +-
 3 files changed, 69 insertions(+), 37 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
index 2ac2f0996697..7eea32e9d078 100644
--- a/Documentation/devicetree/bindings/sound/tscs42xx.txt
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -8,9 +8,15 @@ Required Properties:
- reg : <0x71> for analog mic
<0x69> for digital mic
 
+   - clock-names:  Must one of  the following "mclk1", "xtal", "mclk2"
+
+   - clocks:   phandle of the clock that provides the codec sysclk
+
 Example:
 
 wookie: codec@69 {
compatible = "tempo,tscs42A2";
reg = <0x69>;
+   clock-names = "xtal";
+   clocks = <_xtal>;
 };
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index d41852a37ac6..081af0e05d33 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,9 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
+
+   struct clk *sysclk;
+   int sysclk_src_id;
 };
 
 struct coeff_ram_ctl {
@@ -1251,13 +1255,46 @@ static int tscs42xx_set_dai_bclk_ratio(struct 
snd_soc_dai *codec_dai,
return 0;
 }
 
-static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
-   int clk_id, unsigned int freq, int dir)
+static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
+   .hw_params  = tscs42xx_hw_params,
+   .mute_stream= tscs42xx_mute_stream,
+   .set_fmt= tscs42xx_set_dai_fmt,
+   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
+};
+
+static int part_is_valid(struct tscs42xx *tscs42xx)
 {
-   struct snd_soc_component *component = codec_dai->component;
+   int val;
int ret;
+   unsigned int reg;
 
-   switch (clk_id) {
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
+   if (ret < 0)
+   return ret;
+
+   val = reg << 8;
+   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
+   if (ret < 0)
+   return ret;
+
+   val |= reg;
+
+   switch (val) {
+   case 0x4A74:
+   case 0x4A73:
+   return true;
+   default:
+   return false;
+   };
+}
+
+static int set_sysclk(struct snd_soc_component *component)
+{
+   struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
+   unsigned long freq;
+   int ret;
+
+   switch (tscs42xx->sysclk_src_id) {
case TSCS42XX_PLL_SRC_XTAL:
case TSCS42XX_PLL_SRC_MCLK1:
ret = snd_soc_component_write(component, R_PLLREFSEL,
@@ -1285,6 +1322,7 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return -EINVAL;
}
 
+   freq = clk_get_rate(tscs42xx->sysclk);
ret = set_pll_ctl_from_input_freq(component, freq);
if (ret < 0) {
dev_err(component->dev,
@@ -1295,41 +1333,13 @@ static int tscs42xx_set_dai_sysclk(struct snd_soc_dai 
*codec_dai,
return 0;
 }
 
-static const struct snd_soc_dai_ops tscs42xx_dai_ops = {
-   .hw_params  = tscs42xx_hw_params,
-   .mute_stream= tscs42xx_mute_stream,
-   .set_fmt= tscs42xx_set_dai_fmt,
-   .set_bclk_ratio = tscs42xx_set_dai_bclk_ratio,
-   .set_sysclk = tscs42xx_set_dai_sysclk,
-};
-
-static int part_is_valid(struct tscs42xx *tscs42xx)
+static int tscs42xx_probe(struct snd_soc_component *component)
 {
-   int val;
-   int ret;
-   unsigned int reg;
-
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDH, );
-   if (ret < 0)
-   return ret;
-
-   val = reg << 8;
-   ret = regmap_read(tscs42xx->regmap, R_DEVIDL, );
-   if (ret < 0)
-   return ret;
-
-   val |= reg;
-
-   switch (val) {
-   case 0x4A74:
-   case 0x4A73:
-   return true;
-   default:
-   return false;
-   };
+   return set_sysclk(component);
 }
 
 static const struct snd_soc_component_driver soc_codec_dev_tscs42xx = {
+   .probe  = tscs42xx_probe,
.dapm_widgets   = tscs42xx_dapm_widgets,
.num_dapm_widgets   = ARRAY_SIZE(tscs42xx_dapm_widgets),
.dapm_routes  

[alsa-devel][PATCH 2/3] ASoC: TSCS42xx: Cleanup private data members

2018-03-23 Thread Steven Eckhoff
In the TSCS42xx driver there are some unnecesarry private data members

Remove blrcm from private data
Remove dev from private data

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 sound/soc/codecs/tscs42xx.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index 37636d6efe60..d41852a37ac6 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -31,7 +31,6 @@ struct tscs42xx {
 
int bclk_ratio;
int samplerate;
-   unsigned int blrcm;
struct mutex audio_params_lock;
 
u8 coeff_ram[COEFF_RAM_SIZE];
@@ -41,8 +40,6 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
-
-   struct device *dev;
 };
 
 struct coeff_ram_ctl {
@@ -1404,12 +1401,11 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
return ret;
}
i2c_set_clientdata(i2c, tscs42xx);
-   tscs42xx->dev = >dev;
 
tscs42xx->regmap = devm_regmap_init_i2c(i2c, _regmap);
if (IS_ERR(tscs42xx->regmap)) {
ret = PTR_ERR(tscs42xx->regmap);
-   dev_err(tscs42xx->dev, "Failed to allocate regmap (%d)\n", ret);
+   dev_err(>dev, "Failed to allocate regmap (%d)\n", ret);
return ret;
}
 
@@ -1417,21 +1413,21 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
 
ret = part_is_valid(tscs42xx);
if (ret <= 0) {
-   dev_err(tscs42xx->dev, "No valid part (%d)\n", ret);
+   dev_err(>dev, "No valid part (%d)\n", ret);
ret = -ENODEV;
return ret;
}
 
ret = regmap_write(tscs42xx->regmap, R_RESET, RV_RESET_ENABLE);
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to reset device (%d)\n", ret);
+   dev_err(>dev, "Failed to reset device (%d)\n", ret);
return ret;
}
 
ret = regmap_register_patch(tscs42xx->regmap, tscs42xx_patch,
ARRAY_SIZE(tscs42xx_patch));
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to apply patch (%d)\n", ret);
+   dev_err(>dev, "Failed to apply patch (%d)\n", ret);
return ret;
}
 
@@ -1439,10 +1435,10 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
mutex_init(>coeff_ram_lock);
mutex_init(>pll_lock);
 
-   ret = devm_snd_soc_register_component(tscs42xx->dev,
+   ret = devm_snd_soc_register_component(>dev,
_codec_dev_tscs42xx, _dai, 1);
if (ret) {
-   dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret);
+   dev_err(>dev, "Failed to register codec (%d)\n", ret);
return ret;
}
 
-- 
2.15.1



[alsa-devel][PATCH 2/3] ASoC: TSCS42xx: Cleanup private data members

2018-03-23 Thread Steven Eckhoff
In the TSCS42xx driver there are some unnecesarry private data members

Remove blrcm from private data
Remove dev from private data

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index 37636d6efe60..d41852a37ac6 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -31,7 +31,6 @@ struct tscs42xx {
 
int bclk_ratio;
int samplerate;
-   unsigned int blrcm;
struct mutex audio_params_lock;
 
u8 coeff_ram[COEFF_RAM_SIZE];
@@ -41,8 +40,6 @@ struct tscs42xx {
struct mutex pll_lock;
 
struct regmap *regmap;
-
-   struct device *dev;
 };
 
 struct coeff_ram_ctl {
@@ -1404,12 +1401,11 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
return ret;
}
i2c_set_clientdata(i2c, tscs42xx);
-   tscs42xx->dev = >dev;
 
tscs42xx->regmap = devm_regmap_init_i2c(i2c, _regmap);
if (IS_ERR(tscs42xx->regmap)) {
ret = PTR_ERR(tscs42xx->regmap);
-   dev_err(tscs42xx->dev, "Failed to allocate regmap (%d)\n", ret);
+   dev_err(>dev, "Failed to allocate regmap (%d)\n", ret);
return ret;
}
 
@@ -1417,21 +1413,21 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
 
ret = part_is_valid(tscs42xx);
if (ret <= 0) {
-   dev_err(tscs42xx->dev, "No valid part (%d)\n", ret);
+   dev_err(>dev, "No valid part (%d)\n", ret);
ret = -ENODEV;
return ret;
}
 
ret = regmap_write(tscs42xx->regmap, R_RESET, RV_RESET_ENABLE);
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to reset device (%d)\n", ret);
+   dev_err(>dev, "Failed to reset device (%d)\n", ret);
return ret;
}
 
ret = regmap_register_patch(tscs42xx->regmap, tscs42xx_patch,
ARRAY_SIZE(tscs42xx_patch));
if (ret < 0) {
-   dev_err(tscs42xx->dev, "Failed to apply patch (%d)\n", ret);
+   dev_err(>dev, "Failed to apply patch (%d)\n", ret);
return ret;
}
 
@@ -1439,10 +1435,10 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c,
mutex_init(>coeff_ram_lock);
mutex_init(>pll_lock);
 
-   ret = devm_snd_soc_register_component(tscs42xx->dev,
+   ret = devm_snd_soc_register_component(>dev,
_codec_dev_tscs42xx, _dai, 1);
if (ret) {
-   dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret);
+   dev_err(>dev, "Failed to register codec (%d)\n", ret);
return ret;
}
 
-- 
2.15.1



[alsa-devel][PATCH 1/3] ASoC: TSCS42xx: Shorten lines and other cleanup

2018-03-23 Thread Steven Eckhoff
Shorten lines greater than 80 chars
Add const to struct snd_soc_component_driver

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 sound/soc/codecs/tscs42xx.c | 87 -
 1 file changed, 55 insertions(+), 32 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index cfc71b5411ee..37636d6efe60 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -204,7 +204,8 @@ static int power_up_audio_plls(struct snd_soc_component 
*component)
break;
default:
ret = -EINVAL;
-   dev_err(component->dev, "Unrecognized PLL output freq (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Unrecognized PLL output freq (%d)\n", ret);
return ret;
}
 
@@ -261,7 +262,8 @@ static int power_down_audio_plls(struct snd_soc_component 
*component)
 static int coeff_ram_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -280,7 +282,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
 static int coeff_ram_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -363,7 +366,8 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w,
 static int pll_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
int ret;
 
if (SND_SOC_DAPM_EVENT_ON(event))
@@ -377,7 +381,8 @@ static int pll_event(struct snd_soc_dapm_widget *w,
 static int dac_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret;
 
@@ -819,16 +824,19 @@ static int setup_sample_format(struct snd_soc_component 
*component,
dev_err(component->dev, "Unsupported format width (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_WL, 
width);
+   ret = snd_soc_component_update_bits(component,
+   R_AIC1, RM_AIC1_WL, width);
if (ret < 0) {
-   dev_err(component->dev, "Failed to set sample width (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to set sample width (%d)\n", ret);
return ret;
}
 
return 0;
 }
 
-static int setup_sample_rate(struct snd_soc_component *component, unsigned int 
rate)
+static int setup_sample_rate(struct snd_soc_component *component,
+   unsigned int rate)
 {
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
unsigned int br, bm;
@@ -881,24 +889,32 @@ static int setup_sample_rate(struct snd_soc_component 
*component, unsigned int r
}
 
/* DAC and ADC share bit and frame clock */
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBR, 
br);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBR, br);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBM, 
bm);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBM, bm);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   &q

[alsa-devel][PATCH 1/3] ASoC: TSCS42xx: Shorten lines and other cleanup

2018-03-23 Thread Steven Eckhoff
Shorten lines greater than 80 chars
Add const to struct snd_soc_component_driver

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 87 -
 1 file changed, 55 insertions(+), 32 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index cfc71b5411ee..37636d6efe60 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -204,7 +204,8 @@ static int power_up_audio_plls(struct snd_soc_component 
*component)
break;
default:
ret = -EINVAL;
-   dev_err(component->dev, "Unrecognized PLL output freq (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Unrecognized PLL output freq (%d)\n", ret);
return ret;
}
 
@@ -261,7 +262,8 @@ static int power_down_audio_plls(struct snd_soc_component 
*component)
 static int coeff_ram_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -280,7 +282,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol,
 static int coeff_ram_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
 {
-   struct snd_soc_component *component = 
snd_soc_kcontrol_component(kcontrol);
+   struct snd_soc_component *component =
+   snd_soc_kcontrol_component(kcontrol);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
struct coeff_ram_ctl *ctl =
(struct coeff_ram_ctl *)kcontrol->private_value;
@@ -363,7 +366,8 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w,
 static int pll_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
int ret;
 
if (SND_SOC_DAPM_EVENT_ON(event))
@@ -377,7 +381,8 @@ static int pll_event(struct snd_soc_dapm_widget *w,
 static int dac_event(struct snd_soc_dapm_widget *w,
 struct snd_kcontrol *kcontrol, int event)
 {
-   struct snd_soc_component *component = 
snd_soc_dapm_to_component(w->dapm);
+   struct snd_soc_component *component =
+   snd_soc_dapm_to_component(w->dapm);
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
int ret;
 
@@ -819,16 +824,19 @@ static int setup_sample_format(struct snd_soc_component 
*component,
dev_err(component->dev, "Unsupported format width (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_WL, 
width);
+   ret = snd_soc_component_update_bits(component,
+   R_AIC1, RM_AIC1_WL, width);
if (ret < 0) {
-   dev_err(component->dev, "Failed to set sample width (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to set sample width (%d)\n", ret);
return ret;
}
 
return 0;
 }
 
-static int setup_sample_rate(struct snd_soc_component *component, unsigned int 
rate)
+static int setup_sample_rate(struct snd_soc_component *component,
+   unsigned int rate)
 {
struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component);
unsigned int br, bm;
@@ -881,24 +889,32 @@ static int setup_sample_rate(struct snd_soc_component 
*component, unsigned int r
}
 
/* DAC and ADC share bit and frame clock */
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBR, 
br);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBR, br);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n", ret);
return ret;
}
-   ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBM, 
bm);
+   ret = snd_soc_component_update_bits(component,
+   R_DACSR, RM_DACSR_DBM, bm);
if (ret < 0) {
-   dev_err(component->dev, "Failed to update register (%d)\n", 
ret);
+   dev_err(component->dev,
+   "Failed to update register (%d)\n&qu

[alsa-devel][PATCH v1] ASoC: TSCS42xx: Add missing headers

2018-03-08 Thread Steven Eckhoff
Add missing headers

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 sound/soc/codecs/tscs42xx.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index e915261fa1cb..cfc71b5411ee 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -3,14 +3,19 @@
 // Copyright 2017 Tempo Semiconductor, Inc.
 // Author: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
+#include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
 
 #include "tscs42xx.h"
 
-- 
2.15.1



[alsa-devel][PATCH v1] ASoC: TSCS42xx: Add missing headers

2018-03-08 Thread Steven Eckhoff
Add missing headers

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index e915261fa1cb..cfc71b5411ee 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -3,14 +3,19 @@
 // Copyright 2017 Tempo Semiconductor, Inc.
 // Author: Steven Eckhoff 
 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
+#include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-#include 
 
 #include "tscs42xx.h"
 
-- 
2.15.1



Re: [PATCH] ASoC: TSCS42xx: make const array norm_addrs static, reduces object code size

2018-03-08 Thread Steven Eckhoff
On Wed, Feb 14, 2018 at 05:21:53PM +, Colin King wrote:

> Don't populate the const array norm_addrs on the stack, instead make it
> static.  Makes the object code smaller by over 230 bytes.  Also re-format
> array data as the insertion of the static keywork made the first line
> overly long.

I have tested this on our HAT and it works well. You can add:

Reviewed-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
Tested-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>

Regards,

Steven


Re: [PATCH] ASoC: TSCS42xx: make const array norm_addrs static, reduces object code size

2018-03-08 Thread Steven Eckhoff
On Wed, Feb 14, 2018 at 05:21:53PM +, Colin King wrote:

> Don't populate the const array norm_addrs on the stack, instead make it
> static.  Makes the object code smaller by over 230 bytes.  Also re-format
> array data as the insertion of the static keywork made the first line
> overly long.

I have tested this on our HAT and it works well. You can add:

Reviewed-by: Steven Eckhoff 
Tested-by: Steven Eckhoff 

Regards,

Steven


Re: [PATCH][next] ASoC: TSCS42xx: make functions pll_event and dac_event static

2018-01-09 Thread Steven Eckhoff
On Mon, Jan 08, 2018 at 11:14:44PM +, Colin King wrote:

> The functions pll_event and dac_event are local to the source and do
> not need to be in global scope, so make them static.

This looks good to me. Thanks for catching this. You can add:

Reviewed-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>



Re: [PATCH][next] ASoC: TSCS42xx: make functions pll_event and dac_event static

2018-01-09 Thread Steven Eckhoff
On Mon, Jan 08, 2018 at 11:14:44PM +, Colin King wrote:

> The functions pll_event and dac_event are local to the source and do
> not need to be in global scope, so make them static.

This looks good to me. Thanks for catching this. You can add:

Reviewed-by: Steven Eckhoff 



[alsa-devel][PATCH v1] ASoC: TSCS42xx: Fix control names

2018-01-08 Thread Steven Eckhoff
The tscs42xx CODEC driver can confuse userspace with non-standard
control names.

Remove "Switch" from enum control type names.
Add "Switch" to on/off control type names.

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 sound/soc/codecs/tscs42xx.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index eedd600875e5..4a5b32a717f2 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -631,7 +631,7 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
0, mic_boost_scale),
 
/* Input Channel Map */
-   SOC_ENUM("Input Channel Map Switch", ch_map_select_enum),
+   SOC_ENUM("Input Channel Map", ch_map_select_enum),
 
/* Coefficient Ram */
COEFF_RAM_CTL("Cascade1L BiQuad1", BIQUAD_SIZE, 0x00),
@@ -708,13 +708,13 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
/* EQ */
SOC_SINGLE("EQ1 Switch", R_CONFIG1, FB_CONFIG1_EQ1_EN, 1, 0),
SOC_SINGLE("EQ2 Switch", R_CONFIG1, FB_CONFIG1_EQ2_EN, 1, 0),
-   SOC_ENUM("EQ1 Band Enable Switch", eq1_band_enable_enum),
-   SOC_ENUM("EQ2 Band Enable Switch", eq2_band_enable_enum),
+   SOC_ENUM("EQ1 Band Enable", eq1_band_enable_enum),
+   SOC_ENUM("EQ2 Band Enable", eq2_band_enable_enum),
 
/* CLE */
-   SOC_ENUM("CLE Level Detect Switch",
+   SOC_ENUM("CLE Level Detect",
cle_level_detection_enum),
-   SOC_ENUM("CLE Level Detect Win Switch",
+   SOC_ENUM("CLE Level Detect Win",
cle_level_detection_window_enum),
SOC_SINGLE("Expander Switch",
R_CLECTL, FB_CLECTL_EXP_EN, 1, 0),
@@ -726,7 +726,7 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
R_MUGAIN, FB_MUGAIN_CLEMUG, 0x1f, 0, mugain_scale),
SOC_SINGLE_TLV("Comp Thresh Playback Volume",
R_COMPTH, FB_COMPTH, 0xff, 0, compth_scale),
-   SOC_ENUM("Comp Ratio Switch", compressor_ratio_enum),
+   SOC_ENUM("Comp Ratio", compressor_ratio_enum),
SND_SOC_BYTES("Comp Atk Time", R_CATKTCL, 2),
 
/* Effects */
@@ -740,50 +740,50 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
SOC_SINGLE("MBC Band1 Switch", R_DACMBCEN, FB_DACMBCEN_MBCEN1, 1, 0),
SOC_SINGLE("MBC Band2 Switch", R_DACMBCEN, FB_DACMBCEN_MBCEN2, 1, 0),
SOC_SINGLE("MBC Band3 Switch", R_DACMBCEN, FB_DACMBCEN_MBCEN3, 1, 0),
-   SOC_ENUM("MBC Band1 Level Detect Switch",
+   SOC_ENUM("MBC Band1 Level Detect",
mbc_level_detection_enums[0]),
-   SOC_ENUM("MBC Band2 Level Detect Switch",
+   SOC_ENUM("MBC Band2 Level Detect",
mbc_level_detection_enums[1]),
-   SOC_ENUM("MBC Band3 Level Detect Switch",
+   SOC_ENUM("MBC Band3 Level Detect",
mbc_level_detection_enums[2]),
-   SOC_ENUM("MBC Band1 Level Detect Win Switch",
+   SOC_ENUM("MBC Band1 Level Detect Win",
mbc_level_detection_window_enums[0]),
-   SOC_ENUM("MBC Band2 Level Detect Win Switch",
+   SOC_ENUM("MBC Band2 Level Detect Win",
mbc_level_detection_window_enums[1]),
-   SOC_ENUM("MBC Band3 Level Detect Win Switch",
+   SOC_ENUM("MBC Band3 Level Detect Win",
mbc_level_detection_window_enums[2]),
 
-   SOC_SINGLE("MBC1 Phase Invert", R_DACMBCMUG1, FB_DACMBCMUG1_PHASE,
-   1, 0),
+   SOC_SINGLE("MBC1 Phase Invert Switch",
+   R_DACMBCMUG1, FB_DACMBCMUG1_PHASE, 1, 0),
SOC_SINGLE_TLV("DAC MBC1 Make-Up Gain Playback Volume",
R_DACMBCMUG1, FB_DACMBCMUG1_MUGAIN, 0x1f, 0, mugain_scale),
SOC_SINGLE_TLV("DAC MBC1 Comp Thresh Playback Volume",
R_DACMBCTHR1, FB_DACMBCTHR1_THRESH, 0xff, 0, compth_scale),
-   SOC_ENUM("DAC MBC1 Comp Ratio Switch",
+   SOC_ENUM("DAC MBC1 Comp Ratio",
dac_mbc1_compressor_ratio_enum),
SND_SOC_BYTES("DAC MBC1 Comp Atk Time", R_DACMBCATK1L, 2),
SND_SOC_BYTES("DAC MBC1 Comp Rel Time Const",
R_DACMBCREL1L, 2),
 
-   SOC_SINGLE("MBC2 Phase Invert", R_DACMBCMUG2, FB_DACMBCMUG2_PHASE,
-   1, 0),
+   SOC_SINGLE("MBC2 Phase Invert Switch",
+   R_DACMBCMUG2, FB_DACMBCMUG2_PHASE, 1, 0),
SOC_SINGLE_TLV("DAC MBC2 Make-Up Gain Playback Volume",
   

[alsa-devel][PATCH v1] ASoC: TSCS42xx: Fix control names

2018-01-08 Thread Steven Eckhoff
The tscs42xx CODEC driver can confuse userspace with non-standard
control names.

Remove "Switch" from enum control type names.
Add "Switch" to on/off control type names.

Signed-off-by: Steven Eckhoff 
---
 sound/soc/codecs/tscs42xx.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
index eedd600875e5..4a5b32a717f2 100644
--- a/sound/soc/codecs/tscs42xx.c
+++ b/sound/soc/codecs/tscs42xx.c
@@ -631,7 +631,7 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
0, mic_boost_scale),
 
/* Input Channel Map */
-   SOC_ENUM("Input Channel Map Switch", ch_map_select_enum),
+   SOC_ENUM("Input Channel Map", ch_map_select_enum),
 
/* Coefficient Ram */
COEFF_RAM_CTL("Cascade1L BiQuad1", BIQUAD_SIZE, 0x00),
@@ -708,13 +708,13 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
/* EQ */
SOC_SINGLE("EQ1 Switch", R_CONFIG1, FB_CONFIG1_EQ1_EN, 1, 0),
SOC_SINGLE("EQ2 Switch", R_CONFIG1, FB_CONFIG1_EQ2_EN, 1, 0),
-   SOC_ENUM("EQ1 Band Enable Switch", eq1_band_enable_enum),
-   SOC_ENUM("EQ2 Band Enable Switch", eq2_band_enable_enum),
+   SOC_ENUM("EQ1 Band Enable", eq1_band_enable_enum),
+   SOC_ENUM("EQ2 Band Enable", eq2_band_enable_enum),
 
/* CLE */
-   SOC_ENUM("CLE Level Detect Switch",
+   SOC_ENUM("CLE Level Detect",
cle_level_detection_enum),
-   SOC_ENUM("CLE Level Detect Win Switch",
+   SOC_ENUM("CLE Level Detect Win",
cle_level_detection_window_enum),
SOC_SINGLE("Expander Switch",
R_CLECTL, FB_CLECTL_EXP_EN, 1, 0),
@@ -726,7 +726,7 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
R_MUGAIN, FB_MUGAIN_CLEMUG, 0x1f, 0, mugain_scale),
SOC_SINGLE_TLV("Comp Thresh Playback Volume",
R_COMPTH, FB_COMPTH, 0xff, 0, compth_scale),
-   SOC_ENUM("Comp Ratio Switch", compressor_ratio_enum),
+   SOC_ENUM("Comp Ratio", compressor_ratio_enum),
SND_SOC_BYTES("Comp Atk Time", R_CATKTCL, 2),
 
/* Effects */
@@ -740,50 +740,50 @@ static const struct snd_kcontrol_new 
tscs42xx_snd_controls[] = {
SOC_SINGLE("MBC Band1 Switch", R_DACMBCEN, FB_DACMBCEN_MBCEN1, 1, 0),
SOC_SINGLE("MBC Band2 Switch", R_DACMBCEN, FB_DACMBCEN_MBCEN2, 1, 0),
SOC_SINGLE("MBC Band3 Switch", R_DACMBCEN, FB_DACMBCEN_MBCEN3, 1, 0),
-   SOC_ENUM("MBC Band1 Level Detect Switch",
+   SOC_ENUM("MBC Band1 Level Detect",
mbc_level_detection_enums[0]),
-   SOC_ENUM("MBC Band2 Level Detect Switch",
+   SOC_ENUM("MBC Band2 Level Detect",
mbc_level_detection_enums[1]),
-   SOC_ENUM("MBC Band3 Level Detect Switch",
+   SOC_ENUM("MBC Band3 Level Detect",
mbc_level_detection_enums[2]),
-   SOC_ENUM("MBC Band1 Level Detect Win Switch",
+   SOC_ENUM("MBC Band1 Level Detect Win",
mbc_level_detection_window_enums[0]),
-   SOC_ENUM("MBC Band2 Level Detect Win Switch",
+   SOC_ENUM("MBC Band2 Level Detect Win",
mbc_level_detection_window_enums[1]),
-   SOC_ENUM("MBC Band3 Level Detect Win Switch",
+   SOC_ENUM("MBC Band3 Level Detect Win",
mbc_level_detection_window_enums[2]),
 
-   SOC_SINGLE("MBC1 Phase Invert", R_DACMBCMUG1, FB_DACMBCMUG1_PHASE,
-   1, 0),
+   SOC_SINGLE("MBC1 Phase Invert Switch",
+   R_DACMBCMUG1, FB_DACMBCMUG1_PHASE, 1, 0),
SOC_SINGLE_TLV("DAC MBC1 Make-Up Gain Playback Volume",
R_DACMBCMUG1, FB_DACMBCMUG1_MUGAIN, 0x1f, 0, mugain_scale),
SOC_SINGLE_TLV("DAC MBC1 Comp Thresh Playback Volume",
R_DACMBCTHR1, FB_DACMBCTHR1_THRESH, 0xff, 0, compth_scale),
-   SOC_ENUM("DAC MBC1 Comp Ratio Switch",
+   SOC_ENUM("DAC MBC1 Comp Ratio",
dac_mbc1_compressor_ratio_enum),
SND_SOC_BYTES("DAC MBC1 Comp Atk Time", R_DACMBCATK1L, 2),
SND_SOC_BYTES("DAC MBC1 Comp Rel Time Const",
R_DACMBCREL1L, 2),
 
-   SOC_SINGLE("MBC2 Phase Invert", R_DACMBCMUG2, FB_DACMBCMUG2_PHASE,
-   1, 0),
+   SOC_SINGLE("MBC2 Phase Invert Switch",
+   R_DACMBCMUG2, FB_DACMBCMUG2_PHASE, 1, 0),
SOC_SINGLE_TLV("DAC MBC2 Make-Up Gain Playback Volume",
R_DACMBCMUG2, FB_DACMBCMUG2_

Re: [alsa-devel][PATCH v8] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-08 Thread Steven Eckhoff
On Mon, Jan 08, 2018 at 03:31:07PM +, Mark Brown wrote:
> Please don't do that either, if you're submitting a new patch just
> submit a new patch.  If patches get sorted into the middle of an old
> thread it makes it harder to follow what's new and current.

Okay that makes sense. I will submit a new incremental patch.



Re: [alsa-devel][PATCH v8] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-08 Thread Steven Eckhoff
On Mon, Jan 08, 2018 at 03:31:07PM +, Mark Brown wrote:
> Please don't do that either, if you're submitting a new patch just
> submit a new patch.  If patches get sorted into the middle of an old
> thread it makes it harder to follow what's new and current.

Okay that makes sense. I will submit a new incremental patch.



Re: [alsa-devel][PATCH v8] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-08 Thread Steven Eckhoff
On Mon, Jan 08, 2018 at 11:20:46AM +, Mark Brown wrote:
> Please don't resubmit patches that have already been applied, you should
> submit patches against current code in the tree you're expecting things
> to be applied to.  If any updates are needed to a patch that's already
> been applied you should submit incremental patches which make those
> updates.  This avoids having to change published git commits which could
> cause problems for people working against git.

I apologize I will reply to the v7 thread with an incremental patch.



Re: [alsa-devel][PATCH v8] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-08 Thread Steven Eckhoff
On Mon, Jan 08, 2018 at 11:20:46AM +, Mark Brown wrote:
> Please don't resubmit patches that have already been applied, you should
> submit patches against current code in the tree you're expecting things
> to be applied to.  If any updates are needed to a patch that's already
> been applied you should submit incremental patches which make those
> updates.  This avoids having to change published git commits which could
> cause problems for people working against git.

I apologize I will reply to the v7 thread with an incremental patch.



[alsa-devel][PATCH v8] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-07 Thread Steven Eckhoff
Currently there is no support for TSCS42xx audio CODECs.

Add support for TSCS42xx audio CODECs.

Reviewed-by: Charles Keepax <ckee...@opensource.cirrus.com>
Acked-by: Philippe Ombredanne <pombreda...@nexb.com>
Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
Thank you to everyone involved in improving this driver.

In the following history I have attempted to address every comment made
during the review process.

History:
 
 v8:
  - Remove switch from SOC_ENUM controls
  - Add switch to SOC_SINGLE controls

 v7:
  - Remove unused D2S mux controls
  - Add coeff_ram_get and coeff_ram_put to COEFF_RAM_CTL
  - Remove get/put arguments from COEFF_RAM_CTL
  - Add Reviewed-by: Charles Keepax <ckee...@opensource.cirrus.com>
 
 v6:
  - Remove leftover TLV stuff
  - Make bytes_ext_info static
  - Make compatible strings for specific devices
  - Change vendor prefix from tscs to tempo
  - Add upper bound to daccrstat reads
  - Reove PLL power up/down from mute callbacks
  - Add PLL DAPM widget
  - Wire up PLL DAPM widget
  - Add comment about why slave is not supported
  - Replace non-standard reg patch with regmap patch
  - Remove empty tscs42xx_remove call back
  - Make I2C ids explicit part numbers
  - Add Acked-by: Philippe Ombredanne <pombreda...@nexb.com>
 
 v5:
  - No change
 
 v4:
  - Add SPDX ids
 
 v3:
  - Remove sysfs interface used to program coefficients
  - Add standard ALSA binary interface for programming coefficients
  - Put Kconfig entry in sorted order
  - Remove dev_info
  - Replace mdelay with msleep
  - Increase granularity of locking
  - Make locking self documenting
  - Remove redundant case in tscs42xx_set_dai_fmt
  - Fix Kernel coding style issue
  - Replace non-standard I2C read/write calls with regmap calls
  - Remove clocking logic
  - Add MCLK1 case
  - Add module_i2c_driver()
 
 v2:
  - Fix email address
 
 v1:
  - Initial patch
 
diffstat:
 .../devicetree/bindings/sound/tscs42xx.txt |   16 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|7 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1456 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4183 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..2ac2f0996697
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,16 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+   - compatible :  "tempo,tscs42A1" for analog mic
+   "tempo,tscs42A2" for digital mic
+
+   - reg : <0x71> for analog mic
+   <0x69> for digital mic
+
+Example:
+
+wookie: codec@69 {
+   compatible = "tempo,tscs42A2";
+   reg = <0x69>;
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 0994bdd82cd3..f776fb804a8c 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -347,6 +347,7 @@ tcg Trusted Computing Group
 tclToby Churchill Ltd.
 technexion TechNexion
 technologicTechnologic Systems
+tempo  Tempo Semiconductor
 terasicTerasic Inc.
 thine  THine Electronics, Inc.
 ti Texas Instruments
diff --git a/MAINTAINERS b/MAINTAINERS
index aa71ab52fd76..426e9ffc3faa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13396,6 +13396,13 @@ M: Mark Gross <mark.gr...@intel.com>
 S: Supported
 F: drivers/char/tlclk.c
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+S: Maintained
+F: sound/soc/codecs/tscs*.c
+F: sound/soc/codecs/tscs*.h
+F: Documentation/devicetree/bindings/sound/tscs*.txt
+
 TENSILICA XTENSA PORT (xtensa)
 M: Chris Zankel <ch...@zankel.net>
 M: Max Filippov <jcmvb...@gmail.com>
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index a42ddbc93f3d..5ccdc6b14177 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -159,6 +159,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
select SND_SOC_TS3A227E if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
select SND_SOC_UDA134X
@@ -933,6 +934,13 @@ config SND_SOC_TS3A227E
tristate "TI Head

[alsa-devel][PATCH v8] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-07 Thread Steven Eckhoff
Currently there is no support for TSCS42xx audio CODECs.

Add support for TSCS42xx audio CODECs.

Reviewed-by: Charles Keepax 
Acked-by: Philippe Ombredanne 
Signed-off-by: Steven Eckhoff 
---
Thank you to everyone involved in improving this driver.

In the following history I have attempted to address every comment made
during the review process.

History:
 
 v8:
  - Remove switch from SOC_ENUM controls
  - Add switch to SOC_SINGLE controls

 v7:
  - Remove unused D2S mux controls
  - Add coeff_ram_get and coeff_ram_put to COEFF_RAM_CTL
  - Remove get/put arguments from COEFF_RAM_CTL
  - Add Reviewed-by: Charles Keepax 
 
 v6:
  - Remove leftover TLV stuff
  - Make bytes_ext_info static
  - Make compatible strings for specific devices
  - Change vendor prefix from tscs to tempo
  - Add upper bound to daccrstat reads
  - Reove PLL power up/down from mute callbacks
  - Add PLL DAPM widget
  - Wire up PLL DAPM widget
  - Add comment about why slave is not supported
  - Replace non-standard reg patch with regmap patch
  - Remove empty tscs42xx_remove call back
  - Make I2C ids explicit part numbers
  - Add Acked-by: Philippe Ombredanne 
 
 v5:
  - No change
 
 v4:
  - Add SPDX ids
 
 v3:
  - Remove sysfs interface used to program coefficients
  - Add standard ALSA binary interface for programming coefficients
  - Put Kconfig entry in sorted order
  - Remove dev_info
  - Replace mdelay with msleep
  - Increase granularity of locking
  - Make locking self documenting
  - Remove redundant case in tscs42xx_set_dai_fmt
  - Fix Kernel coding style issue
  - Replace non-standard I2C read/write calls with regmap calls
  - Remove clocking logic
  - Add MCLK1 case
  - Add module_i2c_driver()
 
 v2:
  - Fix email address
 
 v1:
  - Initial patch
 
diffstat:
 .../devicetree/bindings/sound/tscs42xx.txt |   16 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|7 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1456 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4183 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..2ac2f0996697
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,16 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+   - compatible :  "tempo,tscs42A1" for analog mic
+   "tempo,tscs42A2" for digital mic
+
+   - reg : <0x71> for analog mic
+   <0x69> for digital mic
+
+Example:
+
+wookie: codec@69 {
+   compatible = "tempo,tscs42A2";
+   reg = <0x69>;
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 0994bdd82cd3..f776fb804a8c 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -347,6 +347,7 @@ tcg Trusted Computing Group
 tclToby Churchill Ltd.
 technexion TechNexion
 technologicTechnologic Systems
+tempo  Tempo Semiconductor
 terasicTerasic Inc.
 thine  THine Electronics, Inc.
 ti Texas Instruments
diff --git a/MAINTAINERS b/MAINTAINERS
index aa71ab52fd76..426e9ffc3faa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13396,6 +13396,13 @@ M: Mark Gross 
 S: Supported
 F: drivers/char/tlclk.c
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff 
+S: Maintained
+F: sound/soc/codecs/tscs*.c
+F: sound/soc/codecs/tscs*.h
+F: Documentation/devicetree/bindings/sound/tscs*.txt
+
 TENSILICA XTENSA PORT (xtensa)
 M: Chris Zankel 
 M: Max Filippov 
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index a42ddbc93f3d..5ccdc6b14177 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -159,6 +159,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
select SND_SOC_TS3A227E if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
select SND_SOC_UDA134X
@@ -933,6 +934,13 @@ config SND_SOC_TS3A227E
tristate "TI Headset/Mic detect and keypress chip"
depends on I2C
 
+config SND_SOC_TSCS42XX
+   tristate "Tempo Semiconductor TSCS42xx CODEC"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ Add support for Tempo Semiconductor's TSCS42xx audio CODEC.
+
 config SN

Re: [alsa-devel][PATCH v7] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-07 Thread Steven Eckhoff
On Fri, Jan 05, 2018 at 12:38:03PM +, Mark Brown wrote:
> This doesn't apply cleanly against current code, what did you submit
> against?  :(  These aren't trivial things that have just been added to
> my tree in this development cycle either, it looks like you're
> submitting against some older kernel.  I've applied anyway but please be
> careful.
I apologize for this. I created the patch against the master branch and
did not notice that is was las updated 5 years ago. On IRC I was told to
use for-next. I will use that tree to create the next patch against.


Re: [alsa-devel][PATCH v7] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-07 Thread Steven Eckhoff
On Fri, Jan 05, 2018 at 12:38:03PM +, Mark Brown wrote:
> This doesn't apply cleanly against current code, what did you submit
> against?  :(  These aren't trivial things that have just been added to
> my tree in this development cycle either, it looks like you're
> submitting against some older kernel.  I've applied anyway but please be
> careful.
I apologize for this. I created the patch against the master branch and
did not notice that is was las updated 5 years ago. On IRC I was told to
use for-next. I will use that tree to create the next patch against.


Re: [alsa-devel][PATCH v7] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-06 Thread Steven Eckhoff
On Fri, Jan 05, 2018 at 12:22:42PM +, Mark Brown wrote:

> > +   SOC_ENUM("MBC Band1 Level Detect Switch",
> > +   mbc_level_detection_enums[0]),
> > +   SOC_ENUM("MBC Band2 Level Detect Switch",
> > +   mbc_level_detection_enums[1]),
> > +   SOC_ENUM("MBC Band3 Level Detect Switch",
> > +   mbc_level_detection_enums[2]),
> > +   SOC_ENUM("MBC Band1 Level Detect Win Switch",
> > +   mbc_level_detection_window_enums[0]),
> > +   SOC_ENUM("MBC Band2 Level Detect Win Switch",
> > +   mbc_level_detection_window_enums[1]),
> > +   SOC_ENUM("MBC Band3 Level Detect Win Switch",
> > +   mbc_level_detection_window_enums[2]),
> 
> These are enums so they should probably not have Switch at the end of
> their name, I suspect that might confuse userspace somehow.

v8 will remove Switch from the name.

> > +   SOC_SINGLE("MBC1 Phase Invert", R_DACMBCMUG1, FB_DACMBCMUG1_PHASE,
> > +   1, 0),
> 
> While this is an on/off switch (for inversion) so it ought to end in
> Switch.  Otherwise this driver looks good I think, just those couple of
> small things so I'll apply - please send followup patches fixing.

v8 will add Switch to this.

Thank you again for your time on this.


Re: [alsa-devel][PATCH v7] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2018-01-06 Thread Steven Eckhoff
On Fri, Jan 05, 2018 at 12:22:42PM +, Mark Brown wrote:

> > +   SOC_ENUM("MBC Band1 Level Detect Switch",
> > +   mbc_level_detection_enums[0]),
> > +   SOC_ENUM("MBC Band2 Level Detect Switch",
> > +   mbc_level_detection_enums[1]),
> > +   SOC_ENUM("MBC Band3 Level Detect Switch",
> > +   mbc_level_detection_enums[2]),
> > +   SOC_ENUM("MBC Band1 Level Detect Win Switch",
> > +   mbc_level_detection_window_enums[0]),
> > +   SOC_ENUM("MBC Band2 Level Detect Win Switch",
> > +   mbc_level_detection_window_enums[1]),
> > +   SOC_ENUM("MBC Band3 Level Detect Win Switch",
> > +   mbc_level_detection_window_enums[2]),
> 
> These are enums so they should probably not have Switch at the end of
> their name, I suspect that might confuse userspace somehow.

v8 will remove Switch from the name.

> > +   SOC_SINGLE("MBC1 Phase Invert", R_DACMBCMUG1, FB_DACMBCMUG1_PHASE,
> > +   1, 0),
> 
> While this is an on/off switch (for inversion) so it ought to end in
> Switch.  Otherwise this driver looks good I think, just those couple of
> small things so I'll apply - please send followup patches fixing.

v8 will add Switch to this.

Thank you again for your time on this.


[alsa-devel][PATCH v7] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-19 Thread Steven Eckhoff
Currently there is no support for TSCS42xx audio CODECs.

Add support for TSCS42xx audio CODECs.

Reviewed-by: Charles Keepax <ckee...@opensource.cirrus.com>
Acked-by: Philippe Ombredanne <pombreda...@nexb.com>
Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
Thank you to everyone involved in improving this driver.

In the following history I have attempted to address every comment made
during the review process.

History:

 v7:
  - Remove unused D2S mux controls
  - Add coeff_ram_get and coeff_ram_put to COEFF_RAM_CTL
  - Remove get/put arguments from COEFF_RAM_CTL
  - Add Reviewed-by: Charles Keepax <ckee...@opensource.cirrus.com>
 
 v6:
  - Remove leftover TLV stuff
  - Make bytes_ext_info static
  - Make compatible strings for specific devices
  - Change vendor prefix from tscs to tempo
  - Add upper bound to daccrstat reads
  - Reove PLL power up/down from mute callbacks
  - Add PLL DAPM widget
  - Wire up PLL DAPM widget
  - Add comment about why slave is not supported
  - Replace non-standard reg patch with regmap patch
  - Remove empty tscs42xx_remove call back
  - Make I2C ids explicit part numbers
  - Add Acked-by: Philippe Ombredanne <pombreda...@nexb.com>
 
 v5:
  - No change
 
 v4:
  - Add SPDX ids
 
 v3:
  - Remove sysfs interface used to program coefficients
  - Add standard ALSA binary interface for programming coefficients
  - Put Kconfig entry in sorted order
  - Remove dev_info
  - Replace mdelay with msleep
  - Increase granularity of locking
  - Make locking self documenting
  - Remove redundant case in tscs42xx_set_dai_fmt
  - Fix Kernel coding style issue
  - Replace non-standard I2C read/write calls with regmap calls
  - Remove clocking logic
  - Add MCLK1 case
  - Add module_i2c_driver()
 
 v2:
  - Fix email address
 
 v1:
  - Initial patch
 
diffstat:

 .../devicetree/bindings/sound/tscs42xx.txt |   16 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|7 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1456 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4183 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..2ac2f0996697
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,16 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+   - compatible :  "tempo,tscs42A1" for analog mic
+   "tempo,tscs42A2" for digital mic
+
+   - reg : <0x71> for analog mic
+   <0x69> for digital mic
+
+Example:
+
+wookie: codec@69 {
+   compatible = "tempo,tscs42A2";
+   reg = <0x69>;
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 19e1ef73ab0d..4543e688c5d4 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -54,6 +54,7 @@ snps  Synopsys, Inc.
 st STMicroelectronics
 steST-Ericsson
 stericsson ST-Ericsson
+tempo  Tempo Semiconductor
 ti Texas Instruments
 toshibaToshiba Corporation
 viaVIA Technologies, Inc.
diff --git a/MAINTAINERS b/MAINTAINERS
index 8bdd7a7ef2f4..6c9adfcbc7a4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8094,6 +8094,13 @@ T:   git 
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
 S: Maintained
 K:     ^Subject:.*(?i)trivial
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+S: Maintained
+F: sound/soc/codecs/tscs*.c
+F: sound/soc/codecs/tscs*.h
+F: Documentation/devicetree/bindings/sound/tscs*.txt
+
 TTY LAYER
 M: Greg Kroah-Hartman <gre...@linuxfoundation.org>
 M: Jiri Slaby <jsl...@suse.cz>
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 45b72561c615..dcedfaa2c94d 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -69,6 +69,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TLV320AIC3X if I2C
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
select SND_SOC_UDA134X
@@ -336,6 +337,13 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
tristate
 
+config SND_SOC_TSCS42XX
+   tristate "Tempo Semiconducto

[alsa-devel][PATCH v7] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-19 Thread Steven Eckhoff
Currently there is no support for TSCS42xx audio CODECs.

Add support for TSCS42xx audio CODECs.

Reviewed-by: Charles Keepax 
Acked-by: Philippe Ombredanne 
Signed-off-by: Steven Eckhoff 
---
Thank you to everyone involved in improving this driver.

In the following history I have attempted to address every comment made
during the review process.

History:

 v7:
  - Remove unused D2S mux controls
  - Add coeff_ram_get and coeff_ram_put to COEFF_RAM_CTL
  - Remove get/put arguments from COEFF_RAM_CTL
  - Add Reviewed-by: Charles Keepax 
 
 v6:
  - Remove leftover TLV stuff
  - Make bytes_ext_info static
  - Make compatible strings for specific devices
  - Change vendor prefix from tscs to tempo
  - Add upper bound to daccrstat reads
  - Reove PLL power up/down from mute callbacks
  - Add PLL DAPM widget
  - Wire up PLL DAPM widget
  - Add comment about why slave is not supported
  - Replace non-standard reg patch with regmap patch
  - Remove empty tscs42xx_remove call back
  - Make I2C ids explicit part numbers
  - Add Acked-by: Philippe Ombredanne 
 
 v5:
  - No change
 
 v4:
  - Add SPDX ids
 
 v3:
  - Remove sysfs interface used to program coefficients
  - Add standard ALSA binary interface for programming coefficients
  - Put Kconfig entry in sorted order
  - Remove dev_info
  - Replace mdelay with msleep
  - Increase granularity of locking
  - Make locking self documenting
  - Remove redundant case in tscs42xx_set_dai_fmt
  - Fix Kernel coding style issue
  - Replace non-standard I2C read/write calls with regmap calls
  - Remove clocking logic
  - Add MCLK1 case
  - Add module_i2c_driver()
 
 v2:
  - Fix email address
 
 v1:
  - Initial patch
 
diffstat:

 .../devicetree/bindings/sound/tscs42xx.txt |   16 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|7 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1456 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4183 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..2ac2f0996697
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,16 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+   - compatible :  "tempo,tscs42A1" for analog mic
+   "tempo,tscs42A2" for digital mic
+
+   - reg : <0x71> for analog mic
+   <0x69> for digital mic
+
+Example:
+
+wookie: codec@69 {
+   compatible = "tempo,tscs42A2";
+   reg = <0x69>;
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 19e1ef73ab0d..4543e688c5d4 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -54,6 +54,7 @@ snps  Synopsys, Inc.
 st STMicroelectronics
 steST-Ericsson
 stericsson ST-Ericsson
+tempo  Tempo Semiconductor
 ti Texas Instruments
 toshibaToshiba Corporation
 viaVIA Technologies, Inc.
diff --git a/MAINTAINERS b/MAINTAINERS
index 8bdd7a7ef2f4..6c9adfcbc7a4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8094,6 +8094,13 @@ T:   git 
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
 S: Maintained
 K: ^Subject:.*(?i)trivial
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff 
+S: Maintained
+F: sound/soc/codecs/tscs*.c
+F: sound/soc/codecs/tscs*.h
+F: Documentation/devicetree/bindings/sound/tscs*.txt
+
 TTY LAYER
 M: Greg Kroah-Hartman 
 M: Jiri Slaby 
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 45b72561c615..dcedfaa2c94d 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -69,6 +69,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TLV320AIC3X if I2C
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
select SND_SOC_UDA134X
@@ -336,6 +337,13 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
tristate
 
+config SND_SOC_TSCS42XX
+   tristate "Tempo Semiconductor TSCS42xx CODEC"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ Add support for Tempo Semiconductor's TSCS42xx audio CODEC.
+
 config SND_SOC_TWL4030
select MFD_TWL4030_AUDIO
tristate
diff --git a/sound/soc/codecs/Makefile b/

Re: [alsa-devel][PATCH v6] ASoC: TSCS42xx: Support Tempo Semiconductor's TSCS42xx audio CODECs

2017-12-18 Thread Steven Eckhoff
On Mon, Dec 18, 2017 at 09:50:48AM +, Charles Keepax wrote:

> Is this unused?

I apologize I missed this. These were going to be mux controls for two
differential inputs. There are two inputs, but only one can be used at
a time. We have never seen anybody use the second input, so I will
remove the mux controls since it is likely just going to be noise to
anybody configuring the chip through these controls.

> Given all users of this macro use coeff_ram_get and coeff_ram_put
> might it just be worth sticking them in here?

Good point. In the next version the callbacks will be implied through
the use of the macro.

> Other than those two very minor comments, looks ok to me so I
> think you can add:
> 
> Reviewed-by: Charles Keepax 
> 
> Thanks,
> Charles

Thank you so much for your time on this review. It has really helped
improve the driver.



Re: [alsa-devel][PATCH v6] ASoC: TSCS42xx: Support Tempo Semiconductor's TSCS42xx audio CODECs

2017-12-18 Thread Steven Eckhoff
On Mon, Dec 18, 2017 at 09:50:48AM +, Charles Keepax wrote:

> Is this unused?

I apologize I missed this. These were going to be mux controls for two
differential inputs. There are two inputs, but only one can be used at
a time. We have never seen anybody use the second input, so I will
remove the mux controls since it is likely just going to be noise to
anybody configuring the chip through these controls.

> Given all users of this macro use coeff_ram_get and coeff_ram_put
> might it just be worth sticking them in here?

Good point. In the next version the callbacks will be implied through
the use of the macro.

> Other than those two very minor comments, looks ok to me so I
> think you can add:
> 
> Reviewed-by: Charles Keepax 
> 
> Thanks,
> Charles

Thank you so much for your time on this review. It has really helped
improve the driver.



Re: [alsa-devel] [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-17 Thread Steven Eckhoff
On Thu, Dec 14, 2017 at 09:32:44AM +, Charles Keepax wrote:

> Not sure what you mean here but setting up CODEC registers
> directly from the machine driver is probably not ideal. You
> should probably be looking into regmap_register_patch this lets
> you apply a bunch of register settings to the chip every time you
> do a regmap_cache_sync. This is useful for situations like the
> chip has terrible register defaults you want to correct.

I ended up using your suggestion with regmap_register_patch in v6. I
experimented a bit with handling all the interface configurations and it
ultimately became too complex since we would need to handle cases where
there could be one synchronous interface or two asynchronous interfaces that
only have capture or playback. Typically we have only seen uses where
there is one synchronous interface where adc and dac run at the same
rate and on other parts we have sample rate converters that allow capture
and playback to run at different rates. The default value here was
infact not very sane since it is the least used, so the patch method was
very useful in this case. Thanks for the input.



Re: [alsa-devel] [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-17 Thread Steven Eckhoff
On Thu, Dec 14, 2017 at 09:32:44AM +, Charles Keepax wrote:

> Not sure what you mean here but setting up CODEC registers
> directly from the machine driver is probably not ideal. You
> should probably be looking into regmap_register_patch this lets
> you apply a bunch of register settings to the chip every time you
> do a regmap_cache_sync. This is useful for situations like the
> chip has terrible register defaults you want to correct.

I ended up using your suggestion with regmap_register_patch in v6. I
experimented a bit with handling all the interface configurations and it
ultimately became too complex since we would need to handle cases where
there could be one synchronous interface or two asynchronous interfaces that
only have capture or playback. Typically we have only seen uses where
there is one synchronous interface where adc and dac run at the same
rate and on other parts we have sample rate converters that allow capture
and playback to run at different rates. The default value here was
infact not very sane since it is the least used, so the patch method was
very useful in this case. Thanks for the input.



[alsa-devel][PATCH v6] ASoC: TSCS42xx: Support Tempo Semiconductor's TSCS42xx audio CODECs

2017-12-16 Thread Steven Eckhoff
Currently there is no support for TSCS42xx audio CODECs.

Add support for TSCS42xx audio CODECs.

Acked-by: Philippe Ombredanne <pombreda...@nexb.com>
Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 .../devicetree/bindings/sound/tscs42xx.txt |   16 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|7 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1520 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4247 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..2ac2f0996697
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,16 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+   - compatible :  "tempo,tscs42A1" for analog mic
+   "tempo,tscs42A2" for digital mic
+
+   - reg : <0x71> for analog mic
+   <0x69> for digital mic
+
+Example:
+
+wookie: codec@69 {
+   compatible = "tempo,tscs42A2";
+   reg = <0x69>;
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 19e1ef73ab0d..4543e688c5d4 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -54,6 +54,7 @@ snps  Synopsys, Inc.
 st STMicroelectronics
 steST-Ericsson
 stericsson ST-Ericsson
+tempo  Tempo Semiconductor
 ti Texas Instruments
 toshibaToshiba Corporation
 viaVIA Technologies, Inc.
diff --git a/MAINTAINERS b/MAINTAINERS
index 8bdd7a7ef2f4..6c9adfcbc7a4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8094,6 +8094,13 @@ T:   git 
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
 S: Maintained
 K: ^Subject:.*(?i)trivial
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+S: Maintained
+F: sound/soc/codecs/tscs*.c
+F: sound/soc/codecs/tscs*.h
+F: Documentation/devicetree/bindings/sound/tscs*.txt
+
 TTY LAYER
 M: Greg Kroah-Hartman <gre...@linuxfoundation.org>
 M: Jiri Slaby <jsl...@suse.cz>
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 45b72561c615..dcedfaa2c94d 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -69,6 +69,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TLV320AIC3X if I2C
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
select SND_SOC_UDA134X
@@ -336,6 +337,13 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
tristate
 
+config SND_SOC_TSCS42XX
+   tristate "Tempo Semiconductor TSCS42xx CODEC"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ Add support for Tempo Semiconductor's TSCS42xx audio CODEC.
+
 config SND_SOC_TWL4030
select MFD_TWL4030_AUDIO
tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 6a3b3c3b8b41..2d42710a6bc2 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -60,6 +60,7 @@ snd-soc-tlv320aic26-objs := tlv320aic26.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 snd-soc-tlv320aic32x4-objs := tlv320aic32x4.o
 snd-soc-tlv320dac33-objs := tlv320dac33.o
+snd-soc-tscs42xx-objs := tscs42xx.o
 snd-soc-twl4030-objs := twl4030.o
 snd-soc-twl6040-objs := twl6040.o
 snd-soc-uda134x-objs := uda134x.o
@@ -182,6 +183,7 @@ obj-$(CONFIG_SND_SOC_TLV320AIC26)   += snd-soc-tlv320aic26.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)  += snd-soc-tlv320aic3x.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4) += snd-soc-tlv320aic32x4.o
 obj-$(CONFIG_SND_SOC_TLV320DAC33)  += snd-soc-tlv320dac33.o
+obj-$(CONFIG_SND_SOC_TSCS42XX) += snd-soc-tscs42xx.o
 obj-$(CONFIG_SND_SOC_TWL4030)  += snd-soc-twl4030.o
 obj-$(CONFIG_SND_SOC_TWL6040)  += snd-soc-twl6040.o
 obj-$(CONFIG_SND_SOC_UDA134X)  += snd-soc-uda134x.o
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
new file mode 100644
index ..840f6e3ba160
--- /dev/null
+++ b/sound/soc/codecs/tscs42xx.c
@@ -0,0 +1,1520 @@
+// SPDX-License-Identifier: GPL-2.0
+// tscs42xx.c -- TSCS42xx ALSA SoC Audio driver
+// Copyright 2017 Tempo Semiconductor, Inc.
+// Author: Steven Eckhoff <steven.eckhoff.opensou...@gmail.co

[alsa-devel][PATCH v6] ASoC: TSCS42xx: Support Tempo Semiconductor's TSCS42xx audio CODECs

2017-12-16 Thread Steven Eckhoff
Currently there is no support for TSCS42xx audio CODECs.

Add support for TSCS42xx audio CODECs.

Acked-by: Philippe Ombredanne 
Signed-off-by: Steven Eckhoff 
---
 .../devicetree/bindings/sound/tscs42xx.txt |   16 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|7 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1520 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4247 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..2ac2f0996697
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,16 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+   - compatible :  "tempo,tscs42A1" for analog mic
+   "tempo,tscs42A2" for digital mic
+
+   - reg : <0x71> for analog mic
+   <0x69> for digital mic
+
+Example:
+
+wookie: codec@69 {
+   compatible = "tempo,tscs42A2";
+   reg = <0x69>;
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 19e1ef73ab0d..4543e688c5d4 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -54,6 +54,7 @@ snps  Synopsys, Inc.
 st STMicroelectronics
 steST-Ericsson
 stericsson ST-Ericsson
+tempo  Tempo Semiconductor
 ti Texas Instruments
 toshibaToshiba Corporation
 viaVIA Technologies, Inc.
diff --git a/MAINTAINERS b/MAINTAINERS
index 8bdd7a7ef2f4..6c9adfcbc7a4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8094,6 +8094,13 @@ T:   git 
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
 S: Maintained
 K: ^Subject:.*(?i)trivial
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff 
+S: Maintained
+F: sound/soc/codecs/tscs*.c
+F: sound/soc/codecs/tscs*.h
+F: Documentation/devicetree/bindings/sound/tscs*.txt
+
 TTY LAYER
 M: Greg Kroah-Hartman 
 M: Jiri Slaby 
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 45b72561c615..dcedfaa2c94d 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -69,6 +69,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TLV320AIC3X if I2C
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
select SND_SOC_UDA134X
@@ -336,6 +337,13 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
tristate
 
+config SND_SOC_TSCS42XX
+   tristate "Tempo Semiconductor TSCS42xx CODEC"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ Add support for Tempo Semiconductor's TSCS42xx audio CODEC.
+
 config SND_SOC_TWL4030
select MFD_TWL4030_AUDIO
tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 6a3b3c3b8b41..2d42710a6bc2 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -60,6 +60,7 @@ snd-soc-tlv320aic26-objs := tlv320aic26.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 snd-soc-tlv320aic32x4-objs := tlv320aic32x4.o
 snd-soc-tlv320dac33-objs := tlv320dac33.o
+snd-soc-tscs42xx-objs := tscs42xx.o
 snd-soc-twl4030-objs := twl4030.o
 snd-soc-twl6040-objs := twl6040.o
 snd-soc-uda134x-objs := uda134x.o
@@ -182,6 +183,7 @@ obj-$(CONFIG_SND_SOC_TLV320AIC26)   += snd-soc-tlv320aic26.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)  += snd-soc-tlv320aic3x.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4) += snd-soc-tlv320aic32x4.o
 obj-$(CONFIG_SND_SOC_TLV320DAC33)  += snd-soc-tlv320dac33.o
+obj-$(CONFIG_SND_SOC_TSCS42XX) += snd-soc-tscs42xx.o
 obj-$(CONFIG_SND_SOC_TWL4030)  += snd-soc-twl4030.o
 obj-$(CONFIG_SND_SOC_TWL6040)  += snd-soc-twl6040.o
 obj-$(CONFIG_SND_SOC_UDA134X)  += snd-soc-uda134x.o
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
new file mode 100644
index ..840f6e3ba160
--- /dev/null
+++ b/sound/soc/codecs/tscs42xx.c
@@ -0,0 +1,1520 @@
+// SPDX-License-Identifier: GPL-2.0
+// tscs42xx.c -- TSCS42xx ALSA SoC Audio driver
+// Copyright 2017 Tempo Semiconductor, Inc.
+// Author: Steven Eckhoff 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "tscs42xx.h"
+
+#define COEFF_SIZE 3
+#define BIQUAD_COEFF_COUNT 5
+#define BIQUAD_SIZE (COEFF_SI

Re: [alsa-devel] [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-15 Thread Steven Eckhoff
On Fri, Dec 15, 2017 at 11:36:54AM +, Charles Keepax wrote:

> Hmm... might need to think about the case of whether to share a
> clock depends a little on what the hardware actually looks like.
> 
> But basically my point is that writing random CODEC registers
> from the machine driver is not very nice. You want to be making
> use of ASoC calls etc. to have the CODEC driver apply the setting
> you want.
> 
> For example you might call snd_soc_dai_set_fmt to configure
> who is master/slave, but you wouldn't want to write the bit
> that selects master mode on the CODEC directly from the machine
> driver.

I completely agree. ASoC calls would be better or maybe something in the
DT. The register setting needs to reflect what the physical connections
are. There is no ASRC on the chip so to have the ADC run at a different
rate you would need to use an extra bclk and lrclk and configure
it for that. The current version configures the chip so that the DAC and
ADCs run synchronously which only needs the bclk, lrclk, din, and dout
to function. Doing this in the machine driver is indeed broken as it is
making assumptions.

The next version will either set a sane default using your suggestion
or it will implement something through the device tree. I will think on
it a bit more.


Re: [alsa-devel] [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-15 Thread Steven Eckhoff
On Fri, Dec 15, 2017 at 11:36:54AM +, Charles Keepax wrote:

> Hmm... might need to think about the case of whether to share a
> clock depends a little on what the hardware actually looks like.
> 
> But basically my point is that writing random CODEC registers
> from the machine driver is not very nice. You want to be making
> use of ASoC calls etc. to have the CODEC driver apply the setting
> you want.
> 
> For example you might call snd_soc_dai_set_fmt to configure
> who is master/slave, but you wouldn't want to write the bit
> that selects master mode on the CODEC directly from the machine
> driver.

I completely agree. ASoC calls would be better or maybe something in the
DT. The register setting needs to reflect what the physical connections
are. There is no ASRC on the chip so to have the ADC run at a different
rate you would need to use an extra bclk and lrclk and configure
it for that. The current version configures the chip so that the DAC and
ADCs run synchronously which only needs the bclk, lrclk, din, and dout
to function. Doing this in the machine driver is indeed broken as it is
making assumptions.

The next version will either set a sane default using your suggestion
or it will implement something through the device tree. I will think on
it a bit more.


Re: [alsa-devel] [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-14 Thread Steven Eckhoff
On Thu, Dec 14, 2017 at 04:36:17PM -0600, Steven Eckhoff wrote:
> On Thu, Dec 14, 2017 at 09:32:44AM +, Charles Keepax wrote:
> 
> > Not sure what you mean here but setting up CODEC registers
> > directly from the machine driver is probably not ideal. You
> > should probably be looking into regmap_register_patch this lets
> > you apply a bunch of register settings to the chip every time you
> > do a regmap_cache_sync. This is useful for situations like the
> > chip has terrible register defaults you want to correct.
> 
> Thanks I will keep that in mind. For now our defaults are okay, but
> this may come in handy in other drivers. I have removed this bit from
> the next version since this can be set by the machine driver and it
> makes more sense there since the settings were configuring how the I2S
> interfaces were connected.

I apologize I had to reread that.

The settings were setting whether the bclk and lrclk would be shared
between the DAC and ADC interfaces. I thought this would make sense in
the machine driver since it knows how the devices are connected. Is
there a better way to do this?


Re: [alsa-devel] [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-14 Thread Steven Eckhoff
On Thu, Dec 14, 2017 at 04:36:17PM -0600, Steven Eckhoff wrote:
> On Thu, Dec 14, 2017 at 09:32:44AM +, Charles Keepax wrote:
> 
> > Not sure what you mean here but setting up CODEC registers
> > directly from the machine driver is probably not ideal. You
> > should probably be looking into regmap_register_patch this lets
> > you apply a bunch of register settings to the chip every time you
> > do a regmap_cache_sync. This is useful for situations like the
> > chip has terrible register defaults you want to correct.
> 
> Thanks I will keep that in mind. For now our defaults are okay, but
> this may come in handy in other drivers. I have removed this bit from
> the next version since this can be set by the machine driver and it
> makes more sense there since the settings were configuring how the I2S
> interfaces were connected.

I apologize I had to reread that.

The settings were setting whether the bclk and lrclk would be shared
between the DAC and ADC interfaces. I thought this would make sense in
the machine driver since it knows how the devices are connected. Is
there a better way to do this?


Re: [alsa-devel] [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-14 Thread Steven Eckhoff
On Thu, Dec 14, 2017 at 09:32:44AM +, Charles Keepax wrote:

> Not sure what you mean here but setting up CODEC registers
> directly from the machine driver is probably not ideal. You
> should probably be looking into regmap_register_patch this lets
> you apply a bunch of register settings to the chip every time you
> do a regmap_cache_sync. This is useful for situations like the
> chip has terrible register defaults you want to correct.

Thanks I will keep that in mind. For now our defaults are okay, but
this may come in handy in other drivers. I have removed this bit from
the next version since this can be set by the machine driver and it
makes more sense there since the settings were configuring how the I2S
interfaces were connected.


Re: [alsa-devel] [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-14 Thread Steven Eckhoff
On Thu, Dec 14, 2017 at 09:32:44AM +, Charles Keepax wrote:

> Not sure what you mean here but setting up CODEC registers
> directly from the machine driver is probably not ideal. You
> should probably be looking into regmap_register_patch this lets
> you apply a bunch of register settings to the chip every time you
> do a regmap_cache_sync. This is useful for situations like the
> chip has terrible register defaults you want to correct.

Thanks I will keep that in mind. For now our defaults are okay, but
this may come in handy in other drivers. I have removed this bit from
the next version since this can be set by the machine driver and it
makes more sense there since the settings were configuring how the I2S
interfaces were connected.


Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-13 Thread Steven Eckhoff
On Wed, Dec 13, 2017 at 10:47:32AM +, Mark Brown wrote:
> The things the driver is doing automatically to mute the DACs and ADCs
> should be moved to user control if they're not suitable for doing
> automatically.
> 
The mutes can work normally without the PLL stuff. I have removed the PLL
stuff from the next version and have added a DAPM widget to handle the
PLL power up/down.

> Please delete unneeded context from mails when replying.  Doing this
> makes it much easier to find your reply in the message, helping ensure
> it won't be missed by people scrolling through the irrelevant quoted
> material.
I apologize again. I realized that I had done that after it was too
late. 

Thanks for the reviews and all the help. I believe this driver has improved
through this process.


Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-13 Thread Steven Eckhoff
On Wed, Dec 13, 2017 at 10:47:32AM +, Mark Brown wrote:
> The things the driver is doing automatically to mute the DACs and ADCs
> should be moved to user control if they're not suitable for doing
> automatically.
> 
The mutes can work normally without the PLL stuff. I have removed the PLL
stuff from the next version and have added a DAPM widget to handle the
PLL power up/down.

> Please delete unneeded context from mails when replying.  Doing this
> makes it much easier to find your reply in the message, helping ensure
> it won't be missed by people scrolling through the irrelevant quoted
> material.
I apologize again. I realized that I had done that after it was too
late. 

Thanks for the reviews and all the help. I believe this driver has improved
through this process.


Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 04:51:35PM -0600, Steven Eckhoff wrote:

> > > > +static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int 
> > > > stream)
> > > > +{
> > > > +   struct snd_soc_codec *codec = dai->codec;
> > > > +   int ret;
> > > > +
> > > > +   if (mute)
> > > > +   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > > +   ret = dac_mute(codec);
> > > > +   else
> > > > +   ret = adc_mute(codec);
> > > > +   else
> > > > +   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > > +   ret = dac_unmute(codec);
> > > > +   else
> > > > +   ret = adc_unmute(codec);
> > > > +
> > > > +   return ret;
> > > > +}
> > > 
> > > All these mute functions also shut down the PLLs which since...
> > > 
> > This is a bit funky since it looks like if you unmuted the dac and then
> > muted the adc that the PLLs would be powered off on the playback stream,
> > but the logic in the chip is a bit funky in that it wont allow this unless
> > the playback interface is also powered off.
> > 
> > This should definitely be fixed since it is confusing. The PLL
> > powered up/down stuff will be removed from the mute functions in the
> > next version.
> > 
> > What are your thoughts on turning the PLL into a DAPM widget and using
> > the event callback to power up/down the PLLs? I have tested this and it
> > seems to work fine.
> > 
> > > > +   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
> > > > +   case SND_SOC_DAIFMT_CBM_CFM:
> > > > +   ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_MS,
> > > > +   RV_AIC1_MS_MASTER);
> > > > +   if (ret < 0)
> > > > +   dev_err(codec->dev,
> > > > +   "Failed to set codec DAI master 
> > > > (%d)\n", ret);
> > > > +   else
> > > > +   ret = 0;
> > > > +   break;
> > > > +   default:
> > > 
> > > ...we only support the CODEC being the clock master seems like it might
> > > mean we stop clocking the DAI?  If that's the case it's better to just
> > > not have the mute control and allow the user to just control these as
> > > normal mutes.
> > > 
> > I am going to put slave mode support in, but I may need some time to
> > test how it works.
> > 
> Okay I had to refresh my memory on why slave was not being supported.
> Our slave mode needs the audio clocks to stay active to avoid pops. This
> has something to do with how the charge pump is setup. In master mode
> this is not an issue. I will keep the slave mode support out of the next
> version.
> 
> Also I am not sure what you mean with the mute controls. Could you
> elaborate more on this?
> 
Okay I belive I know what this was all about. 

Were you asking why the mute functions are powering up/down the PLLs?

The answer is that is was a vestige of the very first version of the
driver where I was told I needed to power PLLs before unmuting and
muting before powering them down, which is correct I just didn't have
them in the correct callback. In the next version I have moved the
powering of the PLLs into the event call back of a DAPM supply widget.
If there is a better way I can implement that.

The previous comment on slave mode is still valid, so the next version
will only suppor the codec in master mode.

Sorry for any confusion that I may have caused.



Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 04:51:35PM -0600, Steven Eckhoff wrote:

> > > > +static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int 
> > > > stream)
> > > > +{
> > > > +   struct snd_soc_codec *codec = dai->codec;
> > > > +   int ret;
> > > > +
> > > > +   if (mute)
> > > > +   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > > +   ret = dac_mute(codec);
> > > > +   else
> > > > +   ret = adc_mute(codec);
> > > > +   else
> > > > +   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > > +   ret = dac_unmute(codec);
> > > > +   else
> > > > +   ret = adc_unmute(codec);
> > > > +
> > > > +   return ret;
> > > > +}
> > > 
> > > All these mute functions also shut down the PLLs which since...
> > > 
> > This is a bit funky since it looks like if you unmuted the dac and then
> > muted the adc that the PLLs would be powered off on the playback stream,
> > but the logic in the chip is a bit funky in that it wont allow this unless
> > the playback interface is also powered off.
> > 
> > This should definitely be fixed since it is confusing. The PLL
> > powered up/down stuff will be removed from the mute functions in the
> > next version.
> > 
> > What are your thoughts on turning the PLL into a DAPM widget and using
> > the event callback to power up/down the PLLs? I have tested this and it
> > seems to work fine.
> > 
> > > > +   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
> > > > +   case SND_SOC_DAIFMT_CBM_CFM:
> > > > +   ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_MS,
> > > > +   RV_AIC1_MS_MASTER);
> > > > +   if (ret < 0)
> > > > +   dev_err(codec->dev,
> > > > +   "Failed to set codec DAI master 
> > > > (%d)\n", ret);
> > > > +   else
> > > > +   ret = 0;
> > > > +   break;
> > > > +   default:
> > > 
> > > ...we only support the CODEC being the clock master seems like it might
> > > mean we stop clocking the DAI?  If that's the case it's better to just
> > > not have the mute control and allow the user to just control these as
> > > normal mutes.
> > > 
> > I am going to put slave mode support in, but I may need some time to
> > test how it works.
> > 
> Okay I had to refresh my memory on why slave was not being supported.
> Our slave mode needs the audio clocks to stay active to avoid pops. This
> has something to do with how the charge pump is setup. In master mode
> this is not an issue. I will keep the slave mode support out of the next
> version.
> 
> Also I am not sure what you mean with the mute controls. Could you
> elaborate more on this?
> 
Okay I belive I know what this was all about. 

Were you asking why the mute functions are powering up/down the PLLs?

The answer is that is was a vestige of the very first version of the
driver where I was told I needed to power PLLs before unmuting and
muting before powering them down, which is correct I just didn't have
them in the correct callback. In the next version I have moved the
powering of the PLLs into the event call back of a DAPM supply widget.
If there is a better way I can implement that.

The previous comment on slave mode is still valid, so the next version
will only suppor the codec in master mode.

Sorry for any confusion that I may have caused.



Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 03:31:16PM -0600, Steven Eckhoff wrote:
> On Tue, Dec 12, 2017 at 04:32:54PM +, Mark Brown wrote:
> > On Mon, Dec 11, 2017 at 01:54:25PM -0600, Steven Eckhoff wrote:
> > > Currently there is no support for the TSCS42xx audio CODEC.
> > > 
> > > Add support for it.
> > > 
> > > v5 attempts to address all issues raised in the previous reviews.
> > > 
> > > Thank you to everyone who has invested their time reviewing these
> > > patches.
> > 
> > Please add inter-version changelogs and commentary like this after --- 
> > as covered in SubmittingPatches - this lets tools know they don't need
> > to end up in git.
> > 
> Again I apologize. I will fix this. I will also go over the document to
> make sure nothing else gets messed up. Also thank you for the time you
> have spent reviewing the numerous versions of this patch.
> 
> > > +  - compatible : "tscs:tscs42xx"
> > 
> > Compatible strings should be for specific devices, they may all be
> > treated identically by software now but may not be in future.
> > 
> Okay, this will be fixed in the next version.
> 
> > > + do {
> > > + ret = snd_soc_read(codec, R_DACCRSTAT);
> > > + if (ret < 0) {
> > > + dev_err(codec->dev,
> > > + "Failed to read stat (%d)\n", ret);
> > > + return ret;
> > > + }
> > > + } while (ret);
> > 
> > There should be some sort of upper bound on how many times we'll try to
> > wait for this in case the hardware fails somehow.
> > 
> I totally agree. Most of the time the DACCRSTAT should be cleared before
> the next iteration starts, so I will sleep it 20ms if it isn't
> cleared by then and error if it hasn't cleared after 20ms.
> 
> > > +static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int 
> > > stream)
> > > +{
> > > + struct snd_soc_codec *codec = dai->codec;
> > > + int ret;
> > > +
> > > + if (mute)
> > > + if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > + ret = dac_mute(codec);
> > > + else
> > > + ret = adc_mute(codec);
> > > + else
> > > + if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > + ret = dac_unmute(codec);
> > > + else
> > > + ret = adc_unmute(codec);
> > > +
> > > + return ret;
> > > +}
> > 
> > All these mute functions also shut down the PLLs which since...
> > 
> This is a bit funky since it looks like if you unmuted the dac and then
> muted the adc that the PLLs would be powered off on the playback stream,
> but the logic in the chip is a bit funky in that it wont allow this unless
> the playback interface is also powered off.
> 
> This should definitely be fixed since it is confusing. The PLL
> powered up/down stuff will be removed from the mute functions in the
> next version.
> 
> What are your thoughts on turning the PLL into a DAPM widget and using
> the event callback to power up/down the PLLs? I have tested this and it
> seems to work fine.
> 
> > > + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
> > > + case SND_SOC_DAIFMT_CBM_CFM:
> > > + ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_MS,
> > > + RV_AIC1_MS_MASTER);
> > > + if (ret < 0)
> > > + dev_err(codec->dev,
> > > + "Failed to set codec DAI master (%d)\n", ret);
> > > + else
> > > + ret = 0;
> > > + break;
> > > + default:
> > 
> > ...we only support the CODEC being the clock master seems like it might
> > mean we stop clocking the DAI?  If that's the case it's better to just
> > not have the mute control and allow the user to just control these as
> > normal mutes.
> > 
> I am going to put slave mode support in, but I may need some time to
> test how it works.
> 
Okay I had to refresh my memory on why slave was not being supported.
Our slave mode needs the audio clocks to stay active to avoid pops. This
has something to do with how the charge pump is setup. In master mode
this is not an issue. I will keep the slave mode support out of the next
version.

Also I am not sure what you mean with the mute controls. Could you
elaborate more on this?

> > > +static int tscs42xx_probe

Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 03:31:16PM -0600, Steven Eckhoff wrote:
> On Tue, Dec 12, 2017 at 04:32:54PM +, Mark Brown wrote:
> > On Mon, Dec 11, 2017 at 01:54:25PM -0600, Steven Eckhoff wrote:
> > > Currently there is no support for the TSCS42xx audio CODEC.
> > > 
> > > Add support for it.
> > > 
> > > v5 attempts to address all issues raised in the previous reviews.
> > > 
> > > Thank you to everyone who has invested their time reviewing these
> > > patches.
> > 
> > Please add inter-version changelogs and commentary like this after --- 
> > as covered in SubmittingPatches - this lets tools know they don't need
> > to end up in git.
> > 
> Again I apologize. I will fix this. I will also go over the document to
> make sure nothing else gets messed up. Also thank you for the time you
> have spent reviewing the numerous versions of this patch.
> 
> > > +  - compatible : "tscs:tscs42xx"
> > 
> > Compatible strings should be for specific devices, they may all be
> > treated identically by software now but may not be in future.
> > 
> Okay, this will be fixed in the next version.
> 
> > > + do {
> > > + ret = snd_soc_read(codec, R_DACCRSTAT);
> > > + if (ret < 0) {
> > > + dev_err(codec->dev,
> > > + "Failed to read stat (%d)\n", ret);
> > > + return ret;
> > > + }
> > > + } while (ret);
> > 
> > There should be some sort of upper bound on how many times we'll try to
> > wait for this in case the hardware fails somehow.
> > 
> I totally agree. Most of the time the DACCRSTAT should be cleared before
> the next iteration starts, so I will sleep it 20ms if it isn't
> cleared by then and error if it hasn't cleared after 20ms.
> 
> > > +static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int 
> > > stream)
> > > +{
> > > + struct snd_soc_codec *codec = dai->codec;
> > > + int ret;
> > > +
> > > + if (mute)
> > > + if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > + ret = dac_mute(codec);
> > > + else
> > > + ret = adc_mute(codec);
> > > + else
> > > + if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > > + ret = dac_unmute(codec);
> > > + else
> > > + ret = adc_unmute(codec);
> > > +
> > > + return ret;
> > > +}
> > 
> > All these mute functions also shut down the PLLs which since...
> > 
> This is a bit funky since it looks like if you unmuted the dac and then
> muted the adc that the PLLs would be powered off on the playback stream,
> but the logic in the chip is a bit funky in that it wont allow this unless
> the playback interface is also powered off.
> 
> This should definitely be fixed since it is confusing. The PLL
> powered up/down stuff will be removed from the mute functions in the
> next version.
> 
> What are your thoughts on turning the PLL into a DAPM widget and using
> the event callback to power up/down the PLLs? I have tested this and it
> seems to work fine.
> 
> > > + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
> > > + case SND_SOC_DAIFMT_CBM_CFM:
> > > + ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_MS,
> > > + RV_AIC1_MS_MASTER);
> > > + if (ret < 0)
> > > + dev_err(codec->dev,
> > > + "Failed to set codec DAI master (%d)\n", ret);
> > > + else
> > > + ret = 0;
> > > + break;
> > > + default:
> > 
> > ...we only support the CODEC being the clock master seems like it might
> > mean we stop clocking the DAI?  If that's the case it's better to just
> > not have the mute control and allow the user to just control these as
> > normal mutes.
> > 
> I am going to put slave mode support in, but I may need some time to
> test how it works.
> 
Okay I had to refresh my memory on why slave was not being supported.
Our slave mode needs the audio clocks to stay active to avoid pops. This
has something to do with how the charge pump is setup. In master mode
this is not an issue. I will keep the slave mode support out of the next
version.

Also I am not sure what you mean with the mute controls. Could you
elaborate more on this?

> > > +static int tscs42xx_probe

Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 04:32:54PM +, Mark Brown wrote:
> On Mon, Dec 11, 2017 at 01:54:25PM -0600, Steven Eckhoff wrote:
> > Currently there is no support for the TSCS42xx audio CODEC.
> > 
> > Add support for it.
> > 
> > v5 attempts to address all issues raised in the previous reviews.
> > 
> > Thank you to everyone who has invested their time reviewing these
> > patches.
> 
> Please add inter-version changelogs and commentary like this after --- 
> as covered in SubmittingPatches - this lets tools know they don't need
> to end up in git.
> 
Again I apologize. I will fix this. I will also go over the document to
make sure nothing else gets messed up. Also thank you for the time you
have spent reviewing the numerous versions of this patch.

> > +  - compatible : "tscs:tscs42xx"
> 
> Compatible strings should be for specific devices, they may all be
> treated identically by software now but may not be in future.
> 
Okay, this will be fixed in the next version.

> > +   do {
> > +   ret = snd_soc_read(codec, R_DACCRSTAT);
> > +   if (ret < 0) {
> > +   dev_err(codec->dev,
> > +   "Failed to read stat (%d)\n", ret);
> > +   return ret;
> > +   }
> > +   } while (ret);
> 
> There should be some sort of upper bound on how many times we'll try to
> wait for this in case the hardware fails somehow.
> 
I totally agree. Most of the time the DACCRSTAT should be cleared before
the next iteration starts, so I will sleep it 20ms if it isn't
cleared by then and error if it hasn't cleared after 20ms.

> > +static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int 
> > stream)
> > +{
> > +   struct snd_soc_codec *codec = dai->codec;
> > +   int ret;
> > +
> > +   if (mute)
> > +   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > +   ret = dac_mute(codec);
> > +   else
> > +   ret = adc_mute(codec);
> > +   else
> > +   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > +   ret = dac_unmute(codec);
> > +   else
> > +   ret = adc_unmute(codec);
> > +
> > +   return ret;
> > +}
> 
> All these mute functions also shut down the PLLs which since...
> 
This is a bit funky since it looks like if you unmuted the dac and then
muted the adc that the PLLs would be powered off on the playback stream,
but the logic in the chip is a bit funky in that it wont allow this unless
the playback interface is also powered off.

This should definitely be fixed since it is confusing. The PLL
powered up/down stuff will be removed from the mute functions in the
next version.

What are your thoughts on turning the PLL into a DAPM widget and using
the event callback to power up/down the PLLs? I have tested this and it
seems to work fine.

> > +   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
> > +   case SND_SOC_DAIFMT_CBM_CFM:
> > +   ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_MS,
> > +   RV_AIC1_MS_MASTER);
> > +   if (ret < 0)
> > +   dev_err(codec->dev,
> > +   "Failed to set codec DAI master (%d)\n", ret);
> > +   else
> > +   ret = 0;
> > +   break;
> > +   default:
> 
> ...we only support the CODEC being the clock master seems like it might
> mean we stop clocking the DAI?  If that's the case it's better to just
> not have the mute control and allow the user to just control these as
> normal mutes.
> 
I am going to put slave mode support in, but I may need some time to
test how it works.

> > +static int tscs42xx_probe(struct snd_soc_codec *codec)
> > +{
> > +   int i;
> > +   int ret;
> > +
> > +   for (i = 0; i < ARRAY_SIZE(r_inits); ++i) {
> > +   ret = snd_soc_write(codec, r_inits[i].reg, r_inits[i].def);
> > +   if (ret < 0) {
> > +   dev_err(codec->dev,
> > +   "Failed to write codec defaults (%d)\n", ret);
> > +   return ret;
> > +   }
> > +   }
> 
> I'd expect the driver to just reset the CODEC (it appears to have that
> feature) and the regmap.
> 
These init values were meant to be driver defaults that differed from
the device defaults. In hindsight this was a bad idea. I am removing
them in the next revision and will have the machine driver setup the
codec appropriately.

> > +static int tscs42xx_remove(struct snd_soc_codec *codec)
> > +{
> > +   return 0;
> > +}
> 
> Just remove empty functions.
> 
Next revision will have this removed.

> > +static const struct i2c_device_id tscs42xx_i2c_id[] = {
> > +   { "tscs42xx", 0 },
> > +   { }
> > +};
> > +MODULE_DEVICE_TABLE(i2c, tscs42xx_i2c_id);
> 
> I2C IDs are better as explicit part numbers too like compatible
> strings.
I will update this in the next version.



Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 04:32:54PM +, Mark Brown wrote:
> On Mon, Dec 11, 2017 at 01:54:25PM -0600, Steven Eckhoff wrote:
> > Currently there is no support for the TSCS42xx audio CODEC.
> > 
> > Add support for it.
> > 
> > v5 attempts to address all issues raised in the previous reviews.
> > 
> > Thank you to everyone who has invested their time reviewing these
> > patches.
> 
> Please add inter-version changelogs and commentary like this after --- 
> as covered in SubmittingPatches - this lets tools know they don't need
> to end up in git.
> 
Again I apologize. I will fix this. I will also go over the document to
make sure nothing else gets messed up. Also thank you for the time you
have spent reviewing the numerous versions of this patch.

> > +  - compatible : "tscs:tscs42xx"
> 
> Compatible strings should be for specific devices, they may all be
> treated identically by software now but may not be in future.
> 
Okay, this will be fixed in the next version.

> > +   do {
> > +   ret = snd_soc_read(codec, R_DACCRSTAT);
> > +   if (ret < 0) {
> > +   dev_err(codec->dev,
> > +   "Failed to read stat (%d)\n", ret);
> > +   return ret;
> > +   }
> > +   } while (ret);
> 
> There should be some sort of upper bound on how many times we'll try to
> wait for this in case the hardware fails somehow.
> 
I totally agree. Most of the time the DACCRSTAT should be cleared before
the next iteration starts, so I will sleep it 20ms if it isn't
cleared by then and error if it hasn't cleared after 20ms.

> > +static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int 
> > stream)
> > +{
> > +   struct snd_soc_codec *codec = dai->codec;
> > +   int ret;
> > +
> > +   if (mute)
> > +   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > +   ret = dac_mute(codec);
> > +   else
> > +   ret = adc_mute(codec);
> > +   else
> > +   if (stream == SNDRV_PCM_STREAM_PLAYBACK)
> > +   ret = dac_unmute(codec);
> > +   else
> > +   ret = adc_unmute(codec);
> > +
> > +   return ret;
> > +}
> 
> All these mute functions also shut down the PLLs which since...
> 
This is a bit funky since it looks like if you unmuted the dac and then
muted the adc that the PLLs would be powered off on the playback stream,
but the logic in the chip is a bit funky in that it wont allow this unless
the playback interface is also powered off.

This should definitely be fixed since it is confusing. The PLL
powered up/down stuff will be removed from the mute functions in the
next version.

What are your thoughts on turning the PLL into a DAPM widget and using
the event callback to power up/down the PLLs? I have tested this and it
seems to work fine.

> > +   switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
> > +   case SND_SOC_DAIFMT_CBM_CFM:
> > +   ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_MS,
> > +   RV_AIC1_MS_MASTER);
> > +   if (ret < 0)
> > +   dev_err(codec->dev,
> > +   "Failed to set codec DAI master (%d)\n", ret);
> > +   else
> > +   ret = 0;
> > +   break;
> > +   default:
> 
> ...we only support the CODEC being the clock master seems like it might
> mean we stop clocking the DAI?  If that's the case it's better to just
> not have the mute control and allow the user to just control these as
> normal mutes.
> 
I am going to put slave mode support in, but I may need some time to
test how it works.

> > +static int tscs42xx_probe(struct snd_soc_codec *codec)
> > +{
> > +   int i;
> > +   int ret;
> > +
> > +   for (i = 0; i < ARRAY_SIZE(r_inits); ++i) {
> > +   ret = snd_soc_write(codec, r_inits[i].reg, r_inits[i].def);
> > +   if (ret < 0) {
> > +   dev_err(codec->dev,
> > +   "Failed to write codec defaults (%d)\n", ret);
> > +   return ret;
> > +   }
> > +   }
> 
> I'd expect the driver to just reset the CODEC (it appears to have that
> feature) and the regmap.
> 
These init values were meant to be driver defaults that differed from
the device defaults. In hindsight this was a bad idea. I am removing
them in the next revision and will have the machine driver setup the
codec appropriately.

> > +static int tscs42xx_remove(struct snd_soc_codec *codec)
> > +{
> > +   return 0;
> > +}
> 
> Just remove empty functions.
> 
Next revision will have this removed.

> > +static const struct i2c_device_id tscs42xx_i2c_id[] = {
> > +   { "tscs42xx", 0 },
> > +   { }
> > +};
> > +MODULE_DEVICE_TABLE(i2c, tscs42xx_i2c_id);
> 
> I2C IDs are better as explicit part numbers too like compatible
> strings.
I will update this in the next version.



Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 02:10:09PM +0100, Takashi Iwai wrote:
> On Tue, 12 Dec 2017 14:04:01 +0100,
> Charles Keepax wrote:
> > 
> > On Mon, Dec 11, 2017 at 01:54:25PM -0600, Steven Eckhoff wrote:
> > > Currently there is no support for the TSCS42xx audio CODEC.
> > > 
> > > Add support for it.
> > > 
> > > v5 attempts to address all issues raised in the previous reviews.
> > > 
> > > Thank you to everyone who has invested their time reviewing these
> > > patches.
> > > 
> > > Acked-by: Philippe Ombredanne <pombreda...@nexb.com>
> > > Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
> > > ---
> > > +int bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
> > > + unsigned int size, unsigned int __user *tlv)
> > > +{
> > > + struct tscs_dsp_ctl *ctl =
> > > + (struct tscs_dsp_ctl *)kcontrol->private_value;
> > > + struct soc_bytes_ext *params = >bytes_ext;
> > > + unsigned int count = size < params->max ? size : params->max;
> > > + int ret = -ENXIO;
> > > +
> > > + switch (op_flag) {
> > > + case SNDRV_CTL_TLV_OP_READ:
> > > + if (params->get)
> > > + ret = params->get(kcontrol, tlv, count);
> > > + break;
> > > + case SNDRV_CTL_TLV_OP_WRITE:
> > > + if (params->put)
> > > + ret = params->put(kcontrol, tlv, count);
> > > + break;
> > > + }
> > > + return ret;
> > > +}
> > 
> > Should this function be removed, I am assuming it is a hang over
> > from the earlier TLV implementation?
> 
> Yes, and bytes_ext_info() is also missing static.
> 
> 
> Takashi

Thanks for the review! it is marked static in the next version.


Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 02:10:09PM +0100, Takashi Iwai wrote:
> On Tue, 12 Dec 2017 14:04:01 +0100,
> Charles Keepax wrote:
> > 
> > On Mon, Dec 11, 2017 at 01:54:25PM -0600, Steven Eckhoff wrote:
> > > Currently there is no support for the TSCS42xx audio CODEC.
> > > 
> > > Add support for it.
> > > 
> > > v5 attempts to address all issues raised in the previous reviews.
> > > 
> > > Thank you to everyone who has invested their time reviewing these
> > > patches.
> > > 
> > > Acked-by: Philippe Ombredanne 
> > > Signed-off-by: Steven Eckhoff 
> > > ---
> > > +int bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
> > > + unsigned int size, unsigned int __user *tlv)
> > > +{
> > > + struct tscs_dsp_ctl *ctl =
> > > + (struct tscs_dsp_ctl *)kcontrol->private_value;
> > > + struct soc_bytes_ext *params = >bytes_ext;
> > > + unsigned int count = size < params->max ? size : params->max;
> > > + int ret = -ENXIO;
> > > +
> > > + switch (op_flag) {
> > > + case SNDRV_CTL_TLV_OP_READ:
> > > + if (params->get)
> > > + ret = params->get(kcontrol, tlv, count);
> > > + break;
> > > + case SNDRV_CTL_TLV_OP_WRITE:
> > > + if (params->put)
> > > + ret = params->put(kcontrol, tlv, count);
> > > + break;
> > > + }
> > > + return ret;
> > > +}
> > 
> > Should this function be removed, I am assuming it is a hang over
> > from the earlier TLV implementation?
> 
> Yes, and bytes_ext_info() is also missing static.
> 
> 
> Takashi

Thanks for the review! it is marked static in the next version.


Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 01:04:01PM +, Charles Keepax wrote:
> On Mon, Dec 11, 2017 at 01:54:25PM -0600, Steven Eckhoff wrote:
> > Currently there is no support for the TSCS42xx audio CODEC.
> > 
> > Add support for it.
> > 
> > v5 attempts to address all issues raised in the previous reviews.
> > 
> > Thank you to everyone who has invested their time reviewing these
> > patches.
> > 
> > Acked-by: Philippe Ombredanne <pombreda...@nexb.com>
> > Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
> > ---
> > +int bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
> > +   unsigned int size, unsigned int __user *tlv)
> > +{
> > +   struct tscs_dsp_ctl *ctl =
> > +   (struct tscs_dsp_ctl *)kcontrol->private_value;
> > +   struct soc_bytes_ext *params = >bytes_ext;
> > +   unsigned int count = size < params->max ? size : params->max;
> > +   int ret = -ENXIO;
> > +
> > +   switch (op_flag) {
> > +   case SNDRV_CTL_TLV_OP_READ:
> > +   if (params->get)
> > +   ret = params->get(kcontrol, tlv, count);
> > +   break;
> > +   case SNDRV_CTL_TLV_OP_WRITE:
> > +   if (params->put)
> > +   ret = params->put(kcontrol, tlv, count);
> > +   break;
> > +   }
> > +   return ret;
> > +}
> 
> Should this function be removed, I am assuming it is a hang over
> from the earlier TLV implementation?
> 
> Thanks,
> Charles

Thanks for the review! bytes_tlv_callback will be removed in the next
version.


Re: [PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-12 Thread Steven Eckhoff
On Tue, Dec 12, 2017 at 01:04:01PM +, Charles Keepax wrote:
> On Mon, Dec 11, 2017 at 01:54:25PM -0600, Steven Eckhoff wrote:
> > Currently there is no support for the TSCS42xx audio CODEC.
> > 
> > Add support for it.
> > 
> > v5 attempts to address all issues raised in the previous reviews.
> > 
> > Thank you to everyone who has invested their time reviewing these
> > patches.
> > 
> > Acked-by: Philippe Ombredanne 
> > Signed-off-by: Steven Eckhoff 
> > ---
> > +int bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
> > +   unsigned int size, unsigned int __user *tlv)
> > +{
> > +   struct tscs_dsp_ctl *ctl =
> > +   (struct tscs_dsp_ctl *)kcontrol->private_value;
> > +   struct soc_bytes_ext *params = >bytes_ext;
> > +   unsigned int count = size < params->max ? size : params->max;
> > +   int ret = -ENXIO;
> > +
> > +   switch (op_flag) {
> > +   case SNDRV_CTL_TLV_OP_READ:
> > +   if (params->get)
> > +   ret = params->get(kcontrol, tlv, count);
> > +   break;
> > +   case SNDRV_CTL_TLV_OP_WRITE:
> > +   if (params->put)
> > +   ret = params->put(kcontrol, tlv, count);
> > +   break;
> > +   }
> > +   return ret;
> > +}
> 
> Should this function be removed, I am assuming it is a hang over
> from the earlier TLV implementation?
> 
> Thanks,
> Charles

Thanks for the review! bytes_tlv_callback will be removed in the next
version.


[PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-11 Thread Steven Eckhoff
Currently there is no support for the TSCS42xx audio CODEC.

Add support for it.

v5 attempts to address all issues raised in the previous reviews.

Thank you to everyone who has invested their time reviewing these
patches.

Acked-by: Philippe Ombredanne <pombreda...@nexb.com>
Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
---
 .../devicetree/bindings/sound/tscs42xx.txt |   15 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|5 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1550 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4274 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..da8ea96f4cf0
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,15 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+  - compatible : "tscs:tscs42xx"
+
+  - reg : The I2C address of the device
+
+Example:
+
+codec: tscs42xx@69 {
+   compatible = "tscs,tscs42xx";
+   reg = <0x69>;
+   status = "okay";
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 0994bdd82cd3..6ee98ba258ca 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -363,6 +363,7 @@ tpo TPO
 tronfy Tronfy
 tronsmart  Tronsmart
 truly  Truly Semiconductors Limited
+tscs   Tempo Semiconductor
 tsdTheobroma Systems Design und Consulting GmbH
 tyan   Tyan Computer Corporation
 ucrobotics uCRobotics
diff --git a/MAINTAINERS b/MAINTAINERS
index 82ad0eabce4f..03b31e465fa3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13850,6 +13850,11 @@ T: git 
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
 S: Maintained
 K: ^Subject:.*(?i)trivial
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+S: Maintained
+F: sound/soc/codecs/tscs42xx.*
+
 TTY LAYER
 M: Greg Kroah-Hartman <gre...@linuxfoundation.org>
 M: Jiri Slaby <jsl...@suse.com>
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index a42ddbc93f3d..d2f65c37464a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -158,6 +158,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TLV320AIC3X if I2C
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TS3A227E if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
@@ -929,6 +930,13 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
tristate
 
+config SND_SOC_TSCS42XX
+   tristate "Tempo Semiconductor TSCS42xx CODEC"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ Add support for Tempo Semiconductor's TSCS42xx audio CODEC.
+
 config SND_SOC_TS3A227E
tristate "TI Headset/Mic detect and keypress chip"
depends on I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 0001069ce2a7..ded86bceca37 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -167,6 +167,7 @@ snd-soc-tlv320aic32x4-i2c-objs := tlv320aic32x4-i2c.o
 snd-soc-tlv320aic32x4-spi-objs := tlv320aic32x4-spi.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 snd-soc-tlv320dac33-objs := tlv320dac33.o
+snd-soc-tscs42xx-objs := tscs42xx.o
 snd-soc-ts3a227e-objs := ts3a227e.o
 snd-soc-twl4030-objs := twl4030.o
 snd-soc-twl6040-objs := twl6040.o
@@ -406,6 +407,7 @@ obj-$(CONFIG_SND_SOC_TLV320AIC32X4_I2C) += 
snd-soc-tlv320aic32x4-i2c.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4_SPI)+= snd-soc-tlv320aic32x4-spi.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)  += snd-soc-tlv320aic3x.o
 obj-$(CONFIG_SND_SOC_TLV320DAC33)  += snd-soc-tlv320dac33.o
+obj-$(CONFIG_SND_SOC_TSCS42XX) += snd-soc-tscs42xx.o
 obj-$(CONFIG_SND_SOC_TS3A227E) += snd-soc-ts3a227e.o
 obj-$(CONFIG_SND_SOC_TWL4030)  += snd-soc-twl4030.o
 obj-$(CONFIG_SND_SOC_TWL6040)  += snd-soc-twl6040.o
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
new file mode 100644
index ..2eaf142785ad
--- /dev/null
+++ b/sound/soc/codecs/tscs42xx.c
@@ -0,0 +1,1550 @@
+// SPDX-License-Identifier: GPL-2.0
+// tscs42xx.c -- TSCS42xx ALSA SoC Audio driver
+// Copyright 2017 Tempo Semiconductor, Inc.
+// Author: Steven Eckhoff <ste

[PATCH v5] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-11 Thread Steven Eckhoff
Currently there is no support for the TSCS42xx audio CODEC.

Add support for it.

v5 attempts to address all issues raised in the previous reviews.

Thank you to everyone who has invested their time reviewing these
patches.

Acked-by: Philippe Ombredanne 
Signed-off-by: Steven Eckhoff 
---
 .../devicetree/bindings/sound/tscs42xx.txt |   15 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|5 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1550 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4274 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..da8ea96f4cf0
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,15 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+  - compatible : "tscs:tscs42xx"
+
+  - reg : The I2C address of the device
+
+Example:
+
+codec: tscs42xx@69 {
+   compatible = "tscs,tscs42xx";
+   reg = <0x69>;
+   status = "okay";
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 0994bdd82cd3..6ee98ba258ca 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -363,6 +363,7 @@ tpo TPO
 tronfy Tronfy
 tronsmart  Tronsmart
 truly  Truly Semiconductors Limited
+tscs   Tempo Semiconductor
 tsdTheobroma Systems Design und Consulting GmbH
 tyan   Tyan Computer Corporation
 ucrobotics uCRobotics
diff --git a/MAINTAINERS b/MAINTAINERS
index 82ad0eabce4f..03b31e465fa3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13850,6 +13850,11 @@ T: git 
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
 S: Maintained
 K: ^Subject:.*(?i)trivial
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff 
+S: Maintained
+F: sound/soc/codecs/tscs42xx.*
+
 TTY LAYER
 M: Greg Kroah-Hartman 
 M: Jiri Slaby 
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index a42ddbc93f3d..d2f65c37464a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -158,6 +158,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TLV320AIC3X if I2C
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TS3A227E if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
@@ -929,6 +930,13 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
tristate
 
+config SND_SOC_TSCS42XX
+   tristate "Tempo Semiconductor TSCS42xx CODEC"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ Add support for Tempo Semiconductor's TSCS42xx audio CODEC.
+
 config SND_SOC_TS3A227E
tristate "TI Headset/Mic detect and keypress chip"
depends on I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 0001069ce2a7..ded86bceca37 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -167,6 +167,7 @@ snd-soc-tlv320aic32x4-i2c-objs := tlv320aic32x4-i2c.o
 snd-soc-tlv320aic32x4-spi-objs := tlv320aic32x4-spi.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 snd-soc-tlv320dac33-objs := tlv320dac33.o
+snd-soc-tscs42xx-objs := tscs42xx.o
 snd-soc-ts3a227e-objs := ts3a227e.o
 snd-soc-twl4030-objs := twl4030.o
 snd-soc-twl6040-objs := twl6040.o
@@ -406,6 +407,7 @@ obj-$(CONFIG_SND_SOC_TLV320AIC32X4_I2C) += 
snd-soc-tlv320aic32x4-i2c.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4_SPI)+= snd-soc-tlv320aic32x4-spi.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)  += snd-soc-tlv320aic3x.o
 obj-$(CONFIG_SND_SOC_TLV320DAC33)  += snd-soc-tlv320dac33.o
+obj-$(CONFIG_SND_SOC_TSCS42XX) += snd-soc-tscs42xx.o
 obj-$(CONFIG_SND_SOC_TS3A227E) += snd-soc-ts3a227e.o
 obj-$(CONFIG_SND_SOC_TWL4030)  += snd-soc-twl4030.o
 obj-$(CONFIG_SND_SOC_TWL6040)  += snd-soc-twl6040.o
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
new file mode 100644
index ..2eaf142785ad
--- /dev/null
+++ b/sound/soc/codecs/tscs42xx.c
@@ -0,0 +1,1550 @@
+// SPDX-License-Identifier: GPL-2.0
+// tscs42xx.c -- TSCS42xx ALSA SoC Audio driver
+// Copyright 2017 Tempo Semiconductor, Inc.
+// Author: Steven Eckhoff 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "tscs42xx.h"
+
+#define COEFF_SIZE 3
+#define BIQUAD_COEFF_COUNT 5

Re: [alsa-devel][PATCH v3] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-10 Thread Steven Eckhoff
On Sun, Dec 10, 2017 at 10:00:02AM +0100, Philippe Ombredanne wrote:
 
> Have you considered using the new SPDX ids?

I was unaware of this. Thank you for bringing it to my attention.
I have added it to v4. You can see it here: 

https://patchwork.kernel.org/patch/10104003/

Thanks for the review!


Re: [alsa-devel][PATCH v3] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-10 Thread Steven Eckhoff
On Sun, Dec 10, 2017 at 10:00:02AM +0100, Philippe Ombredanne wrote:
 
> Have you considered using the new SPDX ids?

I was unaware of this. Thank you for bringing it to my attention.
I have added it to v4. You can see it here: 

https://patchwork.kernel.org/patch/10104003/

Thanks for the review!


[alsa-devel][PATCH v4] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-10 Thread Steven Eckhoff
Thank you to everyone who has reviewed this. The v4 patch addresses all
 issues raised.

I apologize for this email chain getting hacked up.

Philippe Ombredanne <pombreda...@nexb.com> wrote:

> Have you considered using the new SPDX ids?

No I haven't, but thank you for bringing this to my attention.
 I have added them.

> Mark Brown <broo...@kernel.org> wrote:
> 
> > > Currently there is no support for the TSCS42xx audio CODEC.
> >
> > This driver is doing a lot of weird, non-standard stuff without any
> > explanation - quite a bit of this needs to be refactored to use standard
> > interfaces.  The code is mostly clean but if it doesn't fit in well with
> > the rest of the system that's an issue.
> 
> I apologize for this I was not aware of some of these interfaces and
>  reinvented the wheel in a few places. I have resolved these issues
>  with the latest patch.
> 
> > Please submit patches using subject lines reflecting the style for the
> > subsystem.  This makes it easier for people to identify relevant
> > patches.  Look at what existing commits in the area you're changing are
> > doing and make sure your subject lines visually resemble what they're
> > doing.
> 
> I also apologize for this. I hope that the subject line is correct now.
> 
> > > +What:/sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_[ab][n]
> > > +Date:November 2017
> > > +KernelVersion:   4.14
> > > +Contact: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
> > > +Description: Sets the equalizer biquad coefficient
> > 
> > Don't add sysfs files for configuring DSP coefficients, use binary
> > controls like other drivers do so that all the audio configuration can
> > be done via one interface.
> 
> Binary controls added and sysfs files removed.
> 
> > > +What:/sys/bus/i2c/devices/.../controls/limit_en
> > > +Date:November 2017
> > > +KernelVersion:   4.14
> > > +Contact: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
> > > +Description: Enables the limiter
> > 
> > This isn't even a DSP coefficeint, this is just a standard on/off enable
> > control.  Why are you adding all this stuff that makes no attempt to use
> > standard interfaces?
> 
> Yes I also had standard enable switches in the old sysfs interface. My
>  thought was to hide these controls from the ALSA interface so only our
>  custom apps could access them. In hindsight it wasn't a great idea. Now
>  all controls use the standard ALSA interfaces.
> 
> > > index c367d11079bc..34e911c1e082 100644
> > > --- a/sound/soc/codecs/Kconfig
> > > +++ b/sound/soc/codecs/Kconfig
> > > @@ -217,6 +217,7 @@ config SND_SOC_ALL_CODECS
> > >   select SND_SOC_WM9705 if SND_SOC_AC97_BUS
> > >   select SND_SOC_WM9712 if SND_SOC_AC97_BUS
> > >   select SND_SOC_WM9713 if SND_SOC_AC97_BUS
> > > + select SND_SOC_TSCS42XX if I2C
> > >  help
> > 
> > Keep these lists sorted please.
> 
> Fixed. I apologize for this.
> 
> > > + /* Write LSB first due to auto increment on MSB */
> > > + ret = snd_soc_write(codec, R_DACCRWRL + j,
> > > + fw->data[i + NUM_DACCR_BYTES - 1 - j]);
> > > + if (ret < 0) {
> >
> > Can't the device handle writing all three bytes at once (the regmap said
> > it could)?  If so that'd speed things up a lot.
> 
> Fixed.
> 
> > > + dev_info(codec->dev, "Loaded tscs42xx_daccram.dfw\n");
> > 
> > dev_dbg() at most.
> 
> Removed from v4.
> 
> > > +#define NUM_CONTROL_BYTES 2
> > > +static int load_control_regs(struct snd_soc_codec *codec)
> > > +{
> > > + const struct firmware *fw = NULL;
> > > + int ret;
> > > + int i;
> > > +
> > > + ret = request_firmware_direct(, "tscs42xx_controls.dfw", codec->dev);
> > > + if (ret) {
> > > + dev_info(codec->dev,
> > > + "No tscs42xx_controls.dfw file found (%d)\n", ret);
> > > + return 0;
> > > + }
> > 
> > What exactly are these controls?
> 
> These were controls that I was attempting to hide so only our app could use
>  them. They have been removed and only standard ALSA controls are used.
> 
> > > + for (count = 0; count < PLL_LOCK_TIME_MAX; count++) {
> > > + reg = snd_soc_read(codec, R_PLLCTL0);
> > > + if (reg < 0) {
> > > + 

[alsa-devel][PATCH v4] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-10 Thread Steven Eckhoff
Thank you to everyone who has reviewed this. The v4 patch addresses all
 issues raised.

I apologize for this email chain getting hacked up.

Philippe Ombredanne  wrote:

> Have you considered using the new SPDX ids?

No I haven't, but thank you for bringing this to my attention.
 I have added them.

> Mark Brown  wrote:
> 
> > > Currently there is no support for the TSCS42xx audio CODEC.
> >
> > This driver is doing a lot of weird, non-standard stuff without any
> > explanation - quite a bit of this needs to be refactored to use standard
> > interfaces.  The code is mostly clean but if it doesn't fit in well with
> > the rest of the system that's an issue.
> 
> I apologize for this I was not aware of some of these interfaces and
>  reinvented the wheel in a few places. I have resolved these issues
>  with the latest patch.
> 
> > Please submit patches using subject lines reflecting the style for the
> > subsystem.  This makes it easier for people to identify relevant
> > patches.  Look at what existing commits in the area you're changing are
> > doing and make sure your subject lines visually resemble what they're
> > doing.
> 
> I also apologize for this. I hope that the subject line is correct now.
> 
> > > +What:/sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_[ab][n]
> > > +Date:November 2017
> > > +KernelVersion:   4.14
> > > +Contact: Steven Eckhoff 
> > > +Description: Sets the equalizer biquad coefficient
> > 
> > Don't add sysfs files for configuring DSP coefficients, use binary
> > controls like other drivers do so that all the audio configuration can
> > be done via one interface.
> 
> Binary controls added and sysfs files removed.
> 
> > > +What:/sys/bus/i2c/devices/.../controls/limit_en
> > > +Date:November 2017
> > > +KernelVersion:   4.14
> > > +Contact: Steven Eckhoff 
> > > +Description: Enables the limiter
> > 
> > This isn't even a DSP coefficeint, this is just a standard on/off enable
> > control.  Why are you adding all this stuff that makes no attempt to use
> > standard interfaces?
> 
> Yes I also had standard enable switches in the old sysfs interface. My
>  thought was to hide these controls from the ALSA interface so only our
>  custom apps could access them. In hindsight it wasn't a great idea. Now
>  all controls use the standard ALSA interfaces.
> 
> > > index c367d11079bc..34e911c1e082 100644
> > > --- a/sound/soc/codecs/Kconfig
> > > +++ b/sound/soc/codecs/Kconfig
> > > @@ -217,6 +217,7 @@ config SND_SOC_ALL_CODECS
> > >   select SND_SOC_WM9705 if SND_SOC_AC97_BUS
> > >   select SND_SOC_WM9712 if SND_SOC_AC97_BUS
> > >   select SND_SOC_WM9713 if SND_SOC_AC97_BUS
> > > + select SND_SOC_TSCS42XX if I2C
> > >  help
> > 
> > Keep these lists sorted please.
> 
> Fixed. I apologize for this.
> 
> > > + /* Write LSB first due to auto increment on MSB */
> > > + ret = snd_soc_write(codec, R_DACCRWRL + j,
> > > + fw->data[i + NUM_DACCR_BYTES - 1 - j]);
> > > + if (ret < 0) {
> >
> > Can't the device handle writing all three bytes at once (the regmap said
> > it could)?  If so that'd speed things up a lot.
> 
> Fixed.
> 
> > > + dev_info(codec->dev, "Loaded tscs42xx_daccram.dfw\n");
> > 
> > dev_dbg() at most.
> 
> Removed from v4.
> 
> > > +#define NUM_CONTROL_BYTES 2
> > > +static int load_control_regs(struct snd_soc_codec *codec)
> > > +{
> > > + const struct firmware *fw = NULL;
> > > + int ret;
> > > + int i;
> > > +
> > > + ret = request_firmware_direct(, "tscs42xx_controls.dfw", codec->dev);
> > > + if (ret) {
> > > + dev_info(codec->dev,
> > > + "No tscs42xx_controls.dfw file found (%d)\n", ret);
> > > + return 0;
> > > + }
> > 
> > What exactly are these controls?
> 
> These were controls that I was attempting to hide so only our app could use
>  them. They have been removed and only standard ALSA controls are used.
> 
> > > + for (count = 0; count < PLL_LOCK_TIME_MAX; count++) {
> > > + reg = snd_soc_read(codec, R_PLLCTL0);
> > > + if (reg < 0) {
> > > + dev_err(codec->dev,
> > > + "Failed to read PLL lock status (%d)\n", ret);
> > > +   

[alsa-devel][PATCH v3] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-09 Thread Steven Eckhoff
Currently there is no support for the TSCS42xx audio CODEC.

Add support for it.

Below is the link to the v2 patch in case the threading is broken. This
 patch addressed each issue raised in the last review.

https://patchwork.kernel.org/patch/10058117/

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
Cc: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
Cc: Liam Girdwood <lgirdw...@gmail.com>
Cc: Mark Brown <broo...@kernel.org>
Cc: Jaroslav Kysela <pe...@perex.cz>
Cc: Takashi Iwai <ti...@suse.com>
Cc: alsa-de...@alsa-project.org
Cc: linux-kernel@vger.kernel.org
---
 .../devicetree/bindings/sound/tscs42xx.txt |   15 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|5 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1571 
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4295 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..da8ea96f4cf0
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,15 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+  - compatible : "tscs:tscs42xx"
+
+  - reg : The I2C address of the device
+
+Example:
+
+codec: tscs42xx@69 {
+   compatible = "tscs,tscs42xx";
+   reg = <0x69>;
+   status = "okay";
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 0994bdd82cd3..6ee98ba258ca 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -363,6 +363,7 @@ tpo TPO
 tronfy Tronfy
 tronsmart  Tronsmart
 truly  Truly Semiconductors Limited
+tscs   Tempo Semiconductor
 tsdTheobroma Systems Design und Consulting GmbH
 tyan   Tyan Computer Corporation
 ucrobotics uCRobotics
diff --git a/MAINTAINERS b/MAINTAINERS
index 9e0045e3ee0c..dbcf1cedda91 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13850,6 +13850,11 @@ T: git 
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
 S: Maintained
 K:     ^Subject:.*(?i)trivial
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+S: Maintained
+F: sound/soc/codecs/tscs42xx.*
+
 TTY LAYER
 M: Greg Kroah-Hartman <gre...@linuxfoundation.org>
 M: Jiri Slaby <jsl...@suse.com>
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index a42ddbc93f3d..d2f65c37464a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -158,6 +158,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TLV320AIC3X if I2C
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TS3A227E if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
@@ -929,6 +930,13 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
tristate
 
+config SND_SOC_TSCS42XX
+   tristate "Tempo Semiconductor TSCS42xx CODEC"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ Add support for Tempo Semiconductor's TSCS42xx audio CODEC.
+
 config SND_SOC_TS3A227E
tristate "TI Headset/Mic detect and keypress chip"
depends on I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 0001069ce2a7..ded86bceca37 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -167,6 +167,7 @@ snd-soc-tlv320aic32x4-i2c-objs := tlv320aic32x4-i2c.o
 snd-soc-tlv320aic32x4-spi-objs := tlv320aic32x4-spi.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 snd-soc-tlv320dac33-objs := tlv320dac33.o
+snd-soc-tscs42xx-objs := tscs42xx.o
 snd-soc-ts3a227e-objs := ts3a227e.o
 snd-soc-twl4030-objs := twl4030.o
 snd-soc-twl6040-objs := twl6040.o
@@ -406,6 +407,7 @@ obj-$(CONFIG_SND_SOC_TLV320AIC32X4_I2C) += 
snd-soc-tlv320aic32x4-i2c.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4_SPI)+= snd-soc-tlv320aic32x4-spi.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)  += snd-soc-tlv320aic3x.o
 obj-$(CONFIG_SND_SOC_TLV320DAC33)  += snd-soc-tlv320dac33.o
+obj-$(CONFIG_SND_SOC_TSCS42XX) += snd-soc-tscs42xx.o
 obj-$(CONFIG_SND_SOC_TS3A227E) += snd-soc-ts3a227e.o
 obj-$(CONFIG_SND_SOC_TWL4030)  += snd-soc-twl4030.o
 obj-$(CONFIG_SND_SOC_TWL6040)  += snd-soc-twl6040.o
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
new fil

[alsa-devel][PATCH v3] ASoC: TSCS42xx: Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-12-09 Thread Steven Eckhoff
Currently there is no support for the TSCS42xx audio CODEC.

Add support for it.

Below is the link to the v2 patch in case the threading is broken. This
 patch addressed each issue raised in the last review.

https://patchwork.kernel.org/patch/10058117/

Signed-off-by: Steven Eckhoff 
Cc: Steven Eckhoff 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: alsa-de...@alsa-project.org
Cc: linux-kernel@vger.kernel.org
---
 .../devicetree/bindings/sound/tscs42xx.txt |   15 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|5 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 1571 
 sound/soc/codecs/tscs42xx.h| 2693 
 7 files changed, 4295 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/devicetree/bindings/sound/tscs42xx.txt 
b/Documentation/devicetree/bindings/sound/tscs42xx.txt
new file mode 100644
index ..da8ea96f4cf0
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/tscs42xx.txt
@@ -0,0 +1,15 @@
+TSCS42XX Audio CODEC
+
+Required Properties:
+
+  - compatible : "tscs:tscs42xx"
+
+  - reg : The I2C address of the device
+
+Example:
+
+codec: tscs42xx@69 {
+   compatible = "tscs,tscs42xx";
+   reg = <0x69>;
+   status = "okay";
+};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 0994bdd82cd3..6ee98ba258ca 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -363,6 +363,7 @@ tpo TPO
 tronfy Tronfy
 tronsmart  Tronsmart
 truly  Truly Semiconductors Limited
+tscs   Tempo Semiconductor
 tsdTheobroma Systems Design und Consulting GmbH
 tyan   Tyan Computer Corporation
 ucrobotics uCRobotics
diff --git a/MAINTAINERS b/MAINTAINERS
index 9e0045e3ee0c..dbcf1cedda91 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13850,6 +13850,11 @@ T: git 
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
 S: Maintained
 K: ^Subject:.*(?i)trivial
 
+TEMPO SEMICONDUCTOR DRIVERS
+M: Steven Eckhoff 
+S: Maintained
+F: sound/soc/codecs/tscs42xx.*
+
 TTY LAYER
 M: Greg Kroah-Hartman 
 M: Jiri Slaby 
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index a42ddbc93f3d..d2f65c37464a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -158,6 +158,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TLV320AIC3X if I2C
select SND_SOC_TPA6130A2 if I2C
select SND_SOC_TLV320DAC33 if I2C
+   select SND_SOC_TSCS42XX if I2C
select SND_SOC_TS3A227E if I2C
select SND_SOC_TWL4030 if TWL4030_CORE
select SND_SOC_TWL6040 if TWL6040_CORE
@@ -929,6 +930,13 @@ config SND_SOC_TLV320AIC3X
 config SND_SOC_TLV320DAC33
tristate
 
+config SND_SOC_TSCS42XX
+   tristate "Tempo Semiconductor TSCS42xx CODEC"
+   depends on I2C
+   select REGMAP_I2C
+   help
+ Add support for Tempo Semiconductor's TSCS42xx audio CODEC.
+
 config SND_SOC_TS3A227E
tristate "TI Headset/Mic detect and keypress chip"
depends on I2C
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 0001069ce2a7..ded86bceca37 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -167,6 +167,7 @@ snd-soc-tlv320aic32x4-i2c-objs := tlv320aic32x4-i2c.o
 snd-soc-tlv320aic32x4-spi-objs := tlv320aic32x4-spi.o
 snd-soc-tlv320aic3x-objs := tlv320aic3x.o
 snd-soc-tlv320dac33-objs := tlv320dac33.o
+snd-soc-tscs42xx-objs := tscs42xx.o
 snd-soc-ts3a227e-objs := ts3a227e.o
 snd-soc-twl4030-objs := twl4030.o
 snd-soc-twl6040-objs := twl6040.o
@@ -406,6 +407,7 @@ obj-$(CONFIG_SND_SOC_TLV320AIC32X4_I2C) += 
snd-soc-tlv320aic32x4-i2c.o
 obj-$(CONFIG_SND_SOC_TLV320AIC32X4_SPI)+= snd-soc-tlv320aic32x4-spi.o
 obj-$(CONFIG_SND_SOC_TLV320AIC3X)  += snd-soc-tlv320aic3x.o
 obj-$(CONFIG_SND_SOC_TLV320DAC33)  += snd-soc-tlv320dac33.o
+obj-$(CONFIG_SND_SOC_TSCS42XX) += snd-soc-tscs42xx.o
 obj-$(CONFIG_SND_SOC_TS3A227E) += snd-soc-ts3a227e.o
 obj-$(CONFIG_SND_SOC_TWL4030)  += snd-soc-twl4030.o
 obj-$(CONFIG_SND_SOC_TWL6040)  += snd-soc-twl6040.o
diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c
new file mode 100644
index ..cc849aa15bef
--- /dev/null
+++ b/sound/soc/codecs/tscs42xx.c
@@ -0,0 +1,1571 @@
+/*
+ * tscs42xx.c -- TSCS42xx ALSA SoC Audio driver
+ *
+ * Copyright 2017 Tempo Semiconductor, Inc.
+ *
+ * Author: Steven Eckhoff 
+ *
+ * This program is free software; you 

[PATCH v2] Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-11-14 Thread Steven Eckhoff
Currently there is no support for the TSCS42xx audio CODEC.

Add support for it.

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
Cc: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
Cc: Liam Girdwood <lgirdw...@gmail.com>
Cc: Mark Brown <broo...@kernel.org>
Cc: Jaroslav Kysela <pe...@perex.cz>
Cc: Takashi Iwai <ti...@suse.com>
Cc: alsa-de...@alsa-project.org
Cc: linux-kernel@vger.kernel.org
---
 .../ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt |  185 ++
 .../devicetree/bindings/sound/tscs42xx.txt |   24 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|5 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 2006 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 8 files changed, 4924 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt 
b/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
new file mode 100644
index ..ed409a97e812
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
@@ -0,0 +1,185 @@
+What:  /sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets the equalizer biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_prescale
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets the prescaler attenuation of the equalizer
+   biquad cascade
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_ext[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets the bass extraction biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_lmt_[ab][n]
+Date:      November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets the bass non linear function coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_cto_[ab][n]
+Date:      November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets the bass cut-off biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_ext[n]_[ab][n]
+Date:      November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets the treb extraction biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_lmt_[ab][n]
+Date:      November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets the treb non linear function coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_cto_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets the treb cut-off biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/3d_coef
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets the 3d coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/3d_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets 3d mix coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets bass mix coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Sets treb mix coefficient
+
+What:  /sys/bus/i2c/devices/.../controls/eq1_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Enables equalizer one
+
+What:  /sys/bus/i2c/devices/.../controls/eq1_bands_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
+Description:   Enables equalizer one bands:
+   0h = Pr

[PATCH v2] Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-11-14 Thread Steven Eckhoff
Currently there is no support for the TSCS42xx audio CODEC.

Add support for it.

Signed-off-by: Steven Eckhoff 
Cc: Steven Eckhoff 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: alsa-de...@alsa-project.org
Cc: linux-kernel@vger.kernel.org
---
 .../ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt |  185 ++
 .../devicetree/bindings/sound/tscs42xx.txt |   24 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|5 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 2006 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 8 files changed, 4924 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt 
b/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
new file mode 100644
index ..ed409a97e812
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
@@ -0,0 +1,185 @@
+What:  /sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the equalizer biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_prescale
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the prescaler attenuation of the equalizer
+   biquad cascade
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_ext[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the bass extraction biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_lmt_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the bass non linear function coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_cto_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the bass cut-off biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_ext[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the treb extraction biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_lmt_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the treb non linear function coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_cto_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the treb cut-off biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/3d_coef
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the 3d coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/3d_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets 3d mix coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets bass mix coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets treb mix coefficient
+
+What:  /sys/bus/i2c/devices/.../controls/eq1_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Enables equalizer one
+
+What:  /sys/bus/i2c/devices/.../controls/eq1_bands_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Enables equalizer one bands:
+   0h = Pre-scale only
+   1h = Pre-scale + EQ band 0
+   2h = Pre-scale + EQ bands 0 to 1
+   ...
+   6h = Pre-scale + EQ bands 0 to 5
+
+What:  /sys/bus/i2c/devices/.../controls/eq2_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Enables equalizer one
+
+What:  /sys/bus/i2c/devices/.../controls/eq2_bands_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Enables equalizer one bands:
+   0h = Pre-scale only
+   1h = Pre-scale + EQ band 0
+   2h = Pre-scale + EQ bands 0 to 1
+   ...
+   6h = Pre-scale + EQ

[PATCH] Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-11-14 Thread Steven Eckhoff
Currently there is no support for the TSCS42xx audio CODEC.

Add support for it.

Signed-off-by: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
Cc: Steven Eckhoff <steven.eckhoff.opensou...@gmail.com>
Cc: Liam Girdwood <lgirdw...@gmail.com>
Cc: Mark Brown <broo...@kernel.org>
Cc: Jaroslav Kysela <pe...@perex.cz>
Cc: Takashi Iwai <ti...@suse.com>
Cc: alsa-de...@alsa-project.org
Cc: linux-kernel@vger.kernel.org
---
 .../ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt |  185 ++
 .../devicetree/bindings/sound/tscs42xx.txt |   24 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|5 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 2006 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 8 files changed, 4924 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt 
b/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
new file mode 100644
index ..39cd8912c020
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
@@ -0,0 +1,185 @@
+What:  /sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets the equalizer biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_prescale
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets the prescaler attenuation of the equalizer
+   biquad cascade
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_ext[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets the bass extraction biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_lmt_[ab][n]
+Date:      November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets the bass non linear function coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_cto_[ab][n]
+Date:      November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets the bass cut-off biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_ext[n]_[ab][n]
+Date:      November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets the treb extraction biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_lmt_[ab][n]
+Date:      November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets the treb non linear function coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_cto_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets the treb cut-off biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/3d_coef
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets the 3d coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/3d_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets 3d mix coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets bass mix coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Sets treb mix coefficient
+
+What:  /sys/bus/i2c/devices/.../controls/eq1_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Enables equalizer one
+
+What:  /sys/bus/i2c/devices/.../controls/eq1_bands_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff <steve.eckhoff.opensou...@gmail.com>
+Description:   Enables equalizer one bands:
+   0h = Pr

[PATCH] Add support for Tempo Semiconductor's TSCS42xx audio CODEC

2017-11-14 Thread Steven Eckhoff
Currently there is no support for the TSCS42xx audio CODEC.

Add support for it.

Signed-off-by: Steven Eckhoff 
Cc: Steven Eckhoff 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: alsa-de...@alsa-project.org
Cc: linux-kernel@vger.kernel.org
---
 .../ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt |  185 ++
 .../devicetree/bindings/sound/tscs42xx.txt |   24 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 MAINTAINERS|5 +
 sound/soc/codecs/Kconfig   |8 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/tscs42xx.c| 2006 +++
 sound/soc/codecs/tscs42xx.h| 2693 
 8 files changed, 4924 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
 create mode 100644 Documentation/devicetree/bindings/sound/tscs42xx.txt
 create mode 100644 sound/soc/codecs/tscs42xx.c
 create mode 100644 sound/soc/codecs/tscs42xx.h

diff --git a/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt 
b/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
new file mode 100644
index ..39cd8912c020
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-i2c-devices-tscs42xx.txt
@@ -0,0 +1,185 @@
+What:  /sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the equalizer biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/eq[n]_ch[n]_prescale
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the prescaler attenuation of the equalizer
+   biquad cascade
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_ext[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the bass extraction biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_lmt_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the bass non linear function coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_cto_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the bass cut-off biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_ext[n]_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the treb extraction biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_lmt_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the treb non linear function coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_cto_[ab][n]
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the treb cut-off biquad coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/3d_coef
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets the 3d coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/3d_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets 3d mix coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/bass_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets bass mix coefficient
+
+What:  /sys/bus/i2c/devices/.../dsp/treb_mix
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Sets treb mix coefficient
+
+What:  /sys/bus/i2c/devices/.../controls/eq1_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Enables equalizer one
+
+What:  /sys/bus/i2c/devices/.../controls/eq1_bands_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Enables equalizer one bands:
+   0h = Pre-scale only
+   1h = Pre-scale + EQ band 0
+   2h = Pre-scale + EQ bands 0 to 1
+   ...
+   6h = Pre-scale + EQ bands 0 to 5
+
+What:  /sys/bus/i2c/devices/.../controls/eq2_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Enables equalizer one
+
+What:  /sys/bus/i2c/devices/.../controls/eq2_bands_en
+Date:  November 2017
+KernelVersion: 4.14
+Contact:   Steven Eckhoff 
+Description:   Enables equalizer one bands:
+   0h = Pre-scale only
+   1h = Pre-scale + EQ band 0
+   2h = Pre-scale + EQ bands 0 to 1
+   ...
+   6h = Pre-scale + EQ