Skip to contentSkip to conversation

Add ES8328 audio codec

PATCH Superseded Sean Cross 4 participants 12 messages Jun 18, 2014 – Jun 19, 2014 7 messages not in the archive

Subsystems (5)

v4 of 11 Superseded Latest is v11 →

lore
Share & tools
lore

Sean Cross

author
#0 lore raw

v4 cover Add ES8328 audio codec

This patchset adds support for the Everest Semi ES8328 audio codec. It also adds support for using the es8328 on IMX boards.

We write a machine driver rather than using simple-card because the machine driver needs to support regulators for the codec itself and speaker amps, have headphone support, and must supply an unusual frequency to the codec chip.

Changes since v3:
- Add OF bindings for everest,es8328
- Add back in patch to add everest as a vendor prefix
- Give clocks more generic names
- Document required clocks in DT bindings document

Changes since v2:
- Change deemph to a bool, and update based on sample rate
- Replace value enums with regular enums
- Break SPI and I2C drivers into their own modules
- Rename everest,es8328 to es8328 as the module wasn't getting detected. Because of this, the patch to vendor-prefixes.txt has been dropped.

Changes since v1:
- Rename HP/Speaker to OUT1/OUT2
- Use DAPM widgets for startup/shutdown
- Add regulator support to machine driver

Sean Cross (3):
devicetree: bindings: Add Everest Semicodunctor
ASoC: add es8328 codec driver
ASoC: fsl: add imx-es8328 machine driver

 Documentation/devicetree/bindings/sound/es8328.txt |  18 +
 .../devicetree/bindings/sound/imx-audio-es8328.txt |  68 +++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 sound/soc/codecs/Kconfig                           |  13 +
 sound/soc/codecs/Makefile                          |   6 +
 sound/soc/codecs/es8328-i2c.c                      |  62 ++
 sound/soc/codecs/es8328-spi.c                      |  51 ++
 sound/soc/codecs/es8328.c                          | 625 +++++++++++++++++++++
 sound/soc/codecs/es8328.h                          | 313 +++++++++++
 sound/soc/fsl/Kconfig                              |  14 +
 sound/soc/fsl/Makefile                             |   2 +
 sound/soc/fsl/imx-es8328.c                         | 359 ++++++++++++
 12 files changed, 1532 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/es8328.txt
 create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-es8328.txt
 create mode 100644 sound/soc/codecs/es8328-i2c.c
 create mode 100644 sound/soc/codecs/es8328-spi.c
 create mode 100644 sound/soc/codecs/es8328.c
 create mode 100644 sound/soc/codecs/es8328.h
 create mode 100644 sound/soc/fsl/imx-es8328.c
Signature · 6 lines
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#2 lore raw

PATCH v4 1/3 devicetree: bindings: Add Everest Semicodunctor

In reply to a message not in the archive

Everest Semiconductor makes audio codecs.

---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index 4d7f375..2d88c10 100644
@@ -46,6 +46,7 @@ epfl	Ecole Polytechnique Fédérale de Lausanne
 epson	Seiko Epson Corp.
 est	ESTeem Wireless Modems
 eukrea  Eukréa Electromatique
+everest	Everest Semiconductor Co. Ltd.
 excito	Excito
 fsl	Freescale Semiconductor
 GEFanuc	GE Fanuc Intelligent Platforms Embedded Systems, Inc.
Signature · 6 lines
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#3 lore raw

PATCH v4 2/3 ASoC: add es8328 codec driver

In reply to a message not in the archive

Add a codec driver for the Everest ES8328. It supports two separate audio outputs and two separate audio inputs.

---
 Documentation/devicetree/bindings/sound/es8328.txt |  18 +
 sound/soc/codecs/Kconfig                           |  13 +
 sound/soc/codecs/Makefile                          |   6 +
 sound/soc/codecs/es8328-i2c.c                      |  62 ++
 sound/soc/codecs/es8328-spi.c                      |  51 ++
 sound/soc/codecs/es8328.c                          | 625 +++++++++++++++++++++
 sound/soc/codecs/es8328.h                          | 313 +++++++++++
 7 files changed, 1088 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/es8328.txt
 create mode 100644 sound/soc/codecs/es8328-i2c.c
 create mode 100644 sound/soc/codecs/es8328-spi.c
 create mode 100644 sound/soc/codecs/es8328.c
 create mode 100644 sound/soc/codecs/es8328.h
Documentation/devicetree/bindings/sound/es8328.txt new file +18 -0
new file mode 100644
index 0000000..488bc32
@@ -0,0 +1,18 @@
+Everest ES8328 audio CODEC
+
+This device supports both I2C and SPI (configured with pin strapping
+on the board).
+
+Required properties:
+
+  - compatible : "es8328"
+
+  - reg : the I2C address of the device for I2C, the chip select
+          number for SPI.
+
+Example:
+
+codec: es8328@11 {
+	compatible = "es8328";
+	reg = <0x11>;
+};
sound/soc/codecs/Kconfig +13 -0
index cbfa1e1..6a509e3 100644
@@ -56,6 +56,8 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_DA732X if I2C
 	select SND_SOC_DA9055 if I2C
 	select SND_SOC_BT_SCO
+	select SND_SOC_ES8328_SPI if SPI_MASTER
+	select SND_SOC_ES8328_I2C if I2C
 	select SND_SOC_ISABELLE if I2C
 	select SND_SOC_JZ4740_CODEC
 	select SND_SOC_LM4857 if I2C
@@ -396,6 +398,17 @@ config SND_SOC_DMIC
 config SND_SOC_HDMI_CODEC
        tristate "HDMI stub CODEC"
 
+config SND_SOC_ES8328
+	tristate "Everest Semi ES8328 CODEC"
+
+config SND_SOC_ES8328_I2C
+	tristate
+	select SND_SOC_ES8328
+
+config SND_SOC_ES8328_SPI
+	tristate
+	select SND_SOC_ES8328
+
 config SND_SOC_ISABELLE
         tristate
 
sound/soc/codecs/Makefile +6 -0
index be3377b..66e7859 100644
@@ -48,6 +48,9 @@ snd-soc-da732x-objs := da732x.o
 snd-soc-da9055-objs := da9055.o
 snd-soc-bt-sco-objs := bt-sco.o
 snd-soc-dmic-objs := dmic.o
+snd-soc-es8328-objs := es8328.o
+snd-soc-es8328-i2c-objs := es8328-i2c.o
+snd-soc-es8328-spi-objs := es8328-spi.o
 snd-soc-isabelle-objs := isabelle.o
 snd-soc-jz4740-codec-objs := jz4740.o
 snd-soc-l3-objs := l3.o
@@ -213,6 +216,9 @@ obj-$(CONFIG_SND_SOC_DA732X)	+= snd-soc-da732x.o
 obj-$(CONFIG_SND_SOC_DA9055)	+= snd-soc-da9055.o
 obj-$(CONFIG_SND_SOC_BT_SCO)	+= snd-soc-bt-sco.o
 obj-$(CONFIG_SND_SOC_DMIC)	+= snd-soc-dmic.o
+obj-$(CONFIG_SND_SOC_ES8328)	+= snd-soc-es8328.o
+obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
+obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
 obj-$(CONFIG_SND_SOC_ISABELLE)	+= snd-soc-isabelle.o
 obj-$(CONFIG_SND_SOC_JZ4740_CODEC)	+= snd-soc-jz4740-codec.o
 obj-$(CONFIG_SND_SOC_L3)	+= snd-soc-l3.o
sound/soc/codecs/es8328-i2c.c new file +62 -0

62 lines not on this page · raw message

sound/soc/codecs/es8328-spi.c new file +51 -0

51 lines not on this page · raw message

sound/soc/codecs/es8328.c new file +625 -0

625 lines not on this page · raw message

sound/soc/codecs/es8328.h new file +313 -0

313 lines not on this page · raw message

Signature · 6 lines
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#6 lore raw

PATCH v4 3/3 ASoC: fsl: add imx-es8328 machine driver

In reply to a message not in the archive

This adds an initial machine driver for the ES8328 audio codec. The driver supports headphones, an audio regulator for both the codec itself and a speaker amp, and supports reparenting and adjusting clocks to supply the audio codec with the unusual frequency it requires.

---
 .../devicetree/bindings/sound/imx-audio-es8328.txt |  68 ++++
 sound/soc/fsl/Kconfig                              |  14 +
 sound/soc/fsl/Makefile                             |   2 +
 sound/soc/fsl/imx-es8328.c                         | 359 +++++++++++++++++++++
 4 files changed, 443 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/imx-audio-es8328.txt
 create mode 100644 sound/soc/fsl/imx-es8328.c
Documentation/devicetree/bindings/sound/imx-audio-es8328.txt new file +68 -0
new file mode 100644
index 0000000..9498e42
@@ -0,0 +1,68 @@
+Freescale i.MX audio complex with ES8328 codec
+
+Required properties:
+- compatible : "fsl,imx-audio-es8328"
+- model : The user-visible name of this sound complex
+- clocks : A list of clocks required to run the codec at 22.5792 MHz:
+- clock-names : Descriptive names of the various clocks:
+
+    clk_sel : Main audio PLL source selector
+    clk_src : Main audio PLL
+    clk_post_div : Clock source, after a 1-32 divider
+    clk : The final clock stage before reaching output
+    output_clk : The resulting output clock frequency
+
+- ssi-controller : The phandle of the i.MX SSI controller
+- jack-gpio : Optional GPIO for headphone jack
+- codec-supply : Power regulator for audio codec chip
+- audio-amp-supply : Power regulator for speaker amps
+- audio-codec : The phandle of the ES8328 audio codec
+- audio-routing : A list of the connections between audio components.
+  Each entry is a pair of strings, the first being the connection's sink,
+  the second being the connection's source. Valid names could be power
+  supplies, ES8328 pins, and the jacks on the board:
+
+  Power supplies:
+   * audio-amp
+   * codec
+
+  ES8328 pins:
+   * LOUT1
+   * LOUT2
+   * ROUT1
+   * ROUT2
+
+  Board connectors:
+   * Headphone
+   * Speaker
+
+- mux-int-port : The internal port of the i.MX audio muxer (AUDMUX)
+- mux-ext-port : The external port of the i.MX audio muxer
+
+Note: The AUDMUX port numbering should start at 1, which is consistent with
+hardware manual.
+
+Example:
+
+sound {
+	compatible = "fsl,imx-audio-es8328";
+	model = "imx-audio-es8328";
+	clocks = <&clks 169>, <&clks 57>, <&clks 173>,
+		 <&clks 203>, <&clks 201>;
+	clock-names = "cko1", "cko1_sel", "pll4_audio",
+		      "pll4_post_div", "cko_sel";
+	ssi-controller = <&ssi1>;
+	audio-codec = <&codec>;
+	jack-gpio = <&gpio5 15 0>;
+	codec-supply = <&reg_audio_codec>;
+	audio-amp-supply = <&reg_audio_amp>;
+	audio-routing =
+		"Speaker", "LOUT2",
+		"Speaker", "ROUT2",
+		"Speaker", "audio-amp",
+		"Headphone", "ROUT1",
+		"Headphone", "LOUT1";
+	mux-int-port = <1>;
+	mux-ext-port = <3>;
+};
+
sound/soc/fsl/Kconfig +14 -0
index 3793362..c0ace69 100644
@@ -229,6 +229,20 @@ config SND_SOC_IMX_WM8962
 	  Say Y if you want to add support for SoC audio on an i.MX board with
 	  a wm8962 codec.
 
+config SND_SOC_IMX_ES8328
+	tristate "SoC Audio support for i.MX boards with the ES8328 codec"
+	depends on OF && (I2C || SPI)
+	select SND_SOC_ES8328_I2C if I2C
+	select SND_SOC_ES8328_SPI if SPI_MASTER
+	select SND_SOC_IMX_PCM_DMA
+	select SND_SOC_IMX_AUDMUX
+	select SND_SOC_FSL_SSI
+	select SND_SOC_FSL_UTILS
+	select SND_SOC_IMX_PCM_FIQ
+	help
+	  Say Y if you want to add support for the ES8328 audio codec connected
+	  via SSI/I2S over either SPI or I2C.
+
 config SND_SOC_IMX_SGTL5000
 	tristate "SoC Audio support for i.MX boards with sgtl5000"
 	depends on OF && I2C
sound/soc/fsl/Makefile +2 -0
index db254e3..e561766 100644
@@ -48,6 +48,7 @@ snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o
 snd-soc-phycore-ac97-objs := phycore-ac97.o
 snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o
 snd-soc-wm1133-ev1-objs := wm1133-ev1.o
+snd-soc-imx-es8328-objs := imx-es8328.o
 snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o
 snd-soc-imx-wm8962-objs := imx-wm8962.o
 snd-soc-imx-spdif-objs := imx-spdif.o
@@ -57,6 +58,7 @@ obj-$(CONFIG_SND_SOC_EUKREA_TLV320) += snd-soc-eukrea-tlv320.o
 obj-$(CONFIG_SND_SOC_PHYCORE_AC97) += snd-soc-phycore-ac97.o
 obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o
 obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o
+obj-$(CONFIG_SND_SOC_IMX_ES8328) += snd-soc-imx-es8328.o
 obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o
 obj-$(CONFIG_SND_SOC_IMX_WM8962) += snd-soc-imx-wm8962.o
 obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o
sound/soc/fsl/imx-es8328.c new file +359 -0

359 lines not on this page · raw message

Signature · 6 lines
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

Re: [PATCH v4 2/3] ASoC: add es8328 codec driver

In reply to a message not in the archive

Documentation/devicetree/bindings/sound/es8328.txt line 8

Quoted 3 lines · Sean Cross
Documentation/devicetree/bindings/sound/es8328.txt new file +3 -0
+Required properties:
+
+  - compatible : "es8328"

This needs the prefix, as does the example.

sound/soc/codecs/es8328-i2c.c line 40

Quoted 8 lines
sound/soc/codecs/es8328-i2c.c new file +8 -0
+static int es8328_i2c_probe(struct i2c_client *i2c,
+			    const struct i2c_device_id *id)
+{
+	struct regmap_config config;
+
+	config = es8328_regmap_config;
+	return es8328_probe(&i2c->dev, devm_regmap_init_i2c(i2c, &config));
+}

config appears to serve no purpose here.

sound/soc/codecs/es8328.c line 34

Quoted 7 lines
sound/soc/codecs/es8328.c new file +7 -0
+/* Run the codec at 22.5792 MHz to support these rates */
+enum es8328_rate {
+	ES8328_RATE_8019,
+	ES8328_RATE_11025,
+	ES8328_RATE_22050,
+	ES8328_RATE_44100,
+};

The driver should be enforcing constraints based on the clock it's got then. Not everything does though so it's a bit optional.

Quoted 4 lines
sound/soc/codecs/es8328.c new file +4 -0
+static int es8328_put_deemph(struct snd_kcontrol *kcontrol,
+			     struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);

sound/soc/codecs/es8328.c line 123

Quoted 10 lines
sound/soc/codecs/es8328.c new file +10 -0
+	struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec);
+	int deemph = ucontrol->value.enumerated.item[0];
+
+	if (deemph > 1)
+		return -EINVAL;
+
+	es8328->deemph = deemph;
+
+	return es8328_set_deemph(codec);
+}

This will unconditionally store the new deemphasis setting even if we failed to set it. That should never happen but still...

sound/soc/codecs/es8328.c line 159

Quoted 1 line
sound/soc/codecs/es8328.c new file +1 -0
+	SOC_DOUBLE_TLV("Mic PGA Gain", ES8328_ADCCONTROL1, 4, 0, 8, 0, mic_tlv),

Mic PGA Volume.

sound/soc/codecs/es8328.c line 259

Quoted 2 lines
sound/soc/codecs/es8328.c new file +2 -0
+	SND_SOC_DAPM_MICBIAS("Mic Bias", ES8328_ADCPOWER,
+			ES8328_ADCPOWER_MIC_BIAS_OFF, 1),

Represent this as a suply, MICBIAS widgets are legacy.

sound/soc/codecs/es8328.c line 491

Quoted 7 lines
sound/soc/codecs/es8328.c new file +7 -0
+	case SND_SOC_BIAS_PREPARE:
+		/* VREF, VMID=2x50k, digital enabled */
+		snd_soc_write(codec, ES8328_CHIPPOWER, pwr_reg);
+		snd_soc_write(codec, ES8328_CONTROL1,
+				cc1_reg |
+				ES8328_CONTROL1_VMIDSEL_50k |
+				ES8328_CONTROL1_ENREF);

snd_soc_update_bits().

sound/soc/codecs/es8328.c line 588

Quoted 7 lines
sound/soc/codecs/es8328.c new file +7 -0
+const struct regmap_config es8328_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = ES8328_REG_MAX,
+	.cache_type = REGCACHE_NONE,
+};
+EXPORT_SYMBOL_GPL(es8328_regmap_config);

No need to specify no cache, it's the default - though a cache is better, it's faster and allows for suspend/resume.

#8 lore raw

Re: [PATCH v4 3/3] ASoC: fsl: add imx-es8328 machine driver

In reply to a message not in the archive

sound/soc/fsl/Kconfig config SND_SOC_IMX_WM8962 · line 236

Quoted 5 lines · Sean Cross
sound/soc/fsl/Kconfig +5 -0
+config SND_SOC_IMX_ES8328
+	tristate "SoC Audio support for i.MX boards with the ES8328 codec"
+	depends on OF && (I2C || SPI)
+	select SND_SOC_ES8328_I2C if I2C
+	select SND_SOC_ES8328_SPI if SPI_MASTER

I expect this is going to break configurations where I2C is modular and SPI is enabled since it'll try to build in the I2C bus interface.

Quoted 5 lines
sound/soc/fsl/imx-es8328.c new file +5 -0
+static int imx_set_frequency(struct imx_es8328_data *data, int freq)
+{
+	int ret;
+
+	ret = clk_set_parent(data->output_clk, data->codec_clk);

sound/soc/fsl/imx-es8328.c line 113

Quoted 10 lines
sound/soc/fsl/imx-es8328.c new file +10 -0
+	if (ret) {
+		dev_err(data->dev, "unable to set clk output");
+		return ret;
+	}
+
+	ret = clk_set_parent(data->codec_clk_sel, data->codec_clk_post_div);
+	if (ret) {
+		dev_err(data->dev, "unable to set clk parent");
+		return ret;
+	}

This should be handled by the clock bindings not open coded in the driver - leaving this here most likely won't play nicely when the clock API can configure the defaults for the tree. There is supposed to be support for setting default clock trees going in (or perhaps already in) the clock bindings.

sound/soc/fsl/imx-es8328.c line 274

Quoted 10 lines
sound/soc/fsl/imx-es8328.c new file +10 -0
+	data->codec_regulator = devm_regulator_get(dev, "codec");
+	if (IS_ERR(data->codec_regulator)) {
+		dev_err(dev, "No codec regulator\n");
+		data->codec_regulator = NULL;
+	} else {
+		ret = regulator_enable(data->codec_regulator);
+		if (ret)
+			dev_err(dev,
+				"Unable to enable codec regulator: %d\n", ret);
+	}

No, this is broken. The CODEC should request its own supplies which need to correspond to the supplies the physical device has and failing to get the supplies should be a fatal error unless the device works without power (in which case why bother enablin them at all?).

sound/soc/fsl/imx-es8328.c line 301

Quoted 3 lines
sound/soc/fsl/imx-es8328.c new file +3 -0
+	ret = snd_soc_register_card(&data->card);
+	if (ret)
+		goto fail;

devm_snd_soc_register_card().

author
#10 lore raw

Re: [PATCH v4 3/3] ASoC: fsl: add imx-es8328 machine driver

In reply to a message not in the archive
Quoted 9 lines · Mark Brown

sound/soc/fsl/Kconfig config SND_SOC_IMX_WM8962 · line 236

Quoted 5 lines · Sean Cross
sound/soc/fsl/Kconfig +5 -0
+config SND_SOC_IMX_ES8328
+	tristate "SoC Audio support for i.MX boards with the ES8328 codec"
+	depends on OF && (I2C || SPI)
+	select SND_SOC_ES8328_I2C if I2C
+	select SND_SOC_ES8328_SPI if SPI_MASTER

I expect this is going to break configurations where I2C is modular and SPI is enabled since it'll try to build in the I2C bus interface.

I see this pattern used frequently in the blackfin tree. Is there a way to achieve this without breaking configuration?

Quoted 12 lines
Quoted 12 lines
sound/soc/fsl/imx-es8328.c new file +12 -0
+static int imx_set_frequency(struct imx_es8328_data *data, int freq)
+{
+	int ret;
+
+	ret = clk_set_parent(data->output_clk, data->codec_clk);
+	if (ret) {
+		dev_err(data->dev, "unable to set clk output");
+		return ret;
+	}
+
+	ret = clk_set_parent(data->codec_clk_sel, data->codec_clk_post_div);
+	if (ret) {
Quoted 8 lines

sound/soc/fsl/imx-es8328.c line 113

Quoted 3 lines
sound/soc/fsl/imx-es8328.c new file +3 -0
+		dev_err(data->dev, "unable to set clk parent");
+		return ret;
+	}

This should be handled by the clock bindings not open coded in the driver - leaving this here most likely won't play nicely when the clock API can configure the defaults for the tree. There is supposed to be support for setting default clock trees going in (or perhaps already in) the clock bindings.

Can you give me more information on it? Currently, it looks like most boards use a 24 MHz clock, judging from this comment in mach-imx/clk-imx6q.c:

/*
* Let's initially set up CLKO with OSC24M, since this configuration
* is widely used by imx6q board designs to clock audio codec. */

This codec requires the more unusual 22.5792 MHz clock. What is the appropriate method of obtaining this particular frequency?

Quoted 6 lines
Quoted 6 lines
sound/soc/fsl/imx-es8328.c new file +6 -0
+	data->codec_regulator = devm_regulator_get(dev, "codec");
+	if (IS_ERR(data->codec_regulator)) {
+		dev_err(dev, "No codec regulator\n");
+		data->codec_regulator = NULL;
+	} else {
+		ret = regulator_enable(data->codec_regulator);
Quoted 8 lines

sound/soc/fsl/imx-es8328.c line 274

Quoted 4 lines
sound/soc/fsl/imx-es8328.c new file +4 -0
+		if (ret)
+			dev_err(dev,
+				"Unable to enable codec regulator: %d\n", ret);
+	}

No, this is broken. The CODEC should request its own supplies which need to correspond to the supplies the physical device has and failing to get the supplies should be a fatal error unless the device works without power (in which case why bother enablin them at all?).

Not all codecs have power supplies. Most don't, in fact, it's just this board where a switch was added to reset the codec in case it gets wedged. Boards might use this codec but omit the power switch to save cost, because they are confident the codec won't get stuck, in which case they would be forced to use a dummy regulator.

Additionally, since the regulator is external to the codec (as it physically cuts 3.3V from the power supply), it doesn't make sense to put it in the codec driver.

Sean
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#11 lore raw

Re: [PATCH v4 3/3] ASoC: fsl: add imx-es8328 machine driver

Quoted 11 lines · Sean Cross
Quoted 5 lines · Mark Brown

This should be handled by the clock bindings not open coded in the driver - leaving this here most likely won't play nicely when the clock API can configure the defaults for the tree. There is supposed to be support for setting default clock trees going in (or perhaps already in) the clock bindings.

Can you give me more information on it? Currently, it looks like most boards use a 24 MHz clock, judging from this comment in mach-imx/clk-imx6q.c:

Look at the clock API, this stuff was introduced in the last merge window if it's there yet at all.

Quoted 2 lines

This codec requires the more unusual 22.5792 MHz clock. What is the appropriate method of obtaining this particular frequency?

clk_set_rate() on the directly connected clock, the problem is fiddling about with the parenting rather than setting the rate.

Quoted 6 lines
Quoted 4 lines

No, this is broken. The CODEC should request its own supplies which need to correspond to the supplies the physical device has and failing to get the supplies should be a fatal error unless the device works without power (in which case why bother enablin them at all?).

Not all codecs have power supplies. Most don't, in fact, it's just this

The manufactuers of those that don't are being awfully quiet about what sounds like a rather impressive feature...

Quoted 3 lines

Additionally, since the regulator is external to the codec (as it physically cuts 3.3V from the power supply), it doesn't make sense to put it in the codec driver.

I'm not sure you've quite understood what the regulator API is there for.

author
#13 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ASoC: fsl: add imx-es8328 machine driver

In reply to a message not in the archive
Quoted 7 lines · Mark Brown
Quoted 6 lines · Sean Cross
Quoted 5 lines · Mark Brown

This should be handled by the clock bindings not open coded in the driver - leaving this here most likely won't play nicely when the clock API can configure the defaults for the tree. There is supposed to be support for setting default clock trees going in (or perhaps already in) the clock bindings.

Quoted 5 lines
Quoted 3 lines

Can you give me more information on it? Currently, it looks like most boards use a 24 MHz clock, judging from this comment in mach-imx/clk-imx6q.c:

Look at the clock API, this stuff was introduced in the last merge window if it's there yet at all.

I don't see anything mentioning it. If I remove the parenting calls then the es8328 will refuse to run as its clock is at 66 MHz rather than the requested 22.5792 MHz. But since you say the default clock tree support is going to be merged, I'd like to try using that code. Is this the "assigned-clock-parents" patch you're referring to, or is there a patchset that will automatically reparent as necessary?

Quoted 10 lines
Quoted 2 lines

This codec requires the more unusual 22.5792 MHz clock. What is the appropriate method of obtaining this particular frequency?

clk_set_rate() on the directly connected clock, the problem is fiddling about with the parenting rather than setting the rate.

Quoted 5 lines
Quoted 4 lines

No, this is broken. The CODEC should request its own supplies which need to correspond to the supplies the physical device has and failing to get the supplies should be a fatal error unless the device works without power (in which case why bother enablin them at all?).

Not all codecs have power supplies. Most don't, in fact, it's just this

Quoted 8 lines

The manufactuers of those that don't are being awfully quiet about what sounds like a rather impressive feature...

Quoted 3 lines

Additionally, since the regulator is external to the codec (as it physically cuts 3.3V from the power supply), it doesn't make sense to put it in the codec driver.

I'm not sure you've quite understood what the regulator API is there for.

I'm having trouble understanding where the separating line is between machine drivers and codec drivers. A random sampling of codec drivers doesn't yield any drivers grabbing their own power switches. Is that an oversight? Should every codec driver include at least one regulator to describe its power source?

If you like, I can move the regulator from the machine driver to the codec driver, and make it non-optional. But we've done designs in the past where it just hangs off the 3.3V rail where it's non-switchable, and the concept of describing a regulator seemed overkill.

Sean

#15 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ASoC: fsl: add imx-es8328 machine driver

In reply to a message not in the archive
Quoted 8 lines · Sean Cross
Quoted 2 lines · Mark Brown

Look at the clock API, this stuff was introduced in the last merge window if it's there yet at all.

support is going to be merged, I'd like to try using that code. Is this the "assigned-clock-parents" patch you're referring to, or is there a patchset that will automatically reparent as necessary?

assigned-clock-parents sounds like it's what I was thinking of.

Quoted 2 lines

machine drivers and codec drivers. A random sampling of codec drivers doesn't yield any drivers grabbing their own power switches. Is that an

$ grep regulator_get sound/soc/codecs/*.c | wc -l 
19
$ grep regulator_bulk_get sound/soc/codecs/*.c | wc -l
32

Please put a bit more effort into trying to understand what you're doing, the common patterns, the terminology and so on - people will be much more willing to help if it appears that there is active engagement on your part.

#16 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ASoC: fsl: add imx-es8328 machine driver

In reply to a message not in the archive
Quoted 22 lines · Sean Cross
Quoted 7 lines · Mark Brown
Quoted 6 lines · Sean Cross
Quoted 4 lines · Mark Brown

No, this is broken. The CODEC should request its own supplies which need to correspond to the supplies the physical device has and failing to get the supplies should be a fatal error unless the device works without power (in which case why bother enablin them at all?).

Not all codecs have power supplies. Most don't, in fact, it's just this

Quoted 8 lines

The manufactuers of those that don't are being awfully quiet about what sounds like a rather impressive feature...

Quoted 3 lines

Additionally, since the regulator is external to the codec (as it physically cuts 3.3V from the power supply), it doesn't make sense to put it in the codec driver.

I'm not sure you've quite understood what the regulator API is there for.

I'm having trouble understanding where the separating line is between machine drivers and codec drivers. A random sampling of codec drivers doesn't yield any drivers grabbing their own power switches. Is that an oversight? Should every codec driver include at least one regulator to describe its power source?

Quoted 8 lines

If you like, I can move the regulator from the machine driver to the codec driver, and make it non-optional. But we've done designs in the past where it just hangs off the 3.3V rail where it's non-switchable, and the concept of describing a regulator seemed overkill.

Sean

I think for your power switch you should be able to use the existing gpio regulator binding, so you shouldn't need to actually write any code.

Take for example wm2200.c, this registers two supplies for the CODEC through DAPM:

SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
SND_SOC_DAPM_REGULATOR_SUPPLY("AVDD", 20, 0),

These are then hooked up to whatever parts of the CODEC require power from them. CPVDD powers the charge pumps so is only hooked up to those, AVDD is the main analogue power for the chip so is needed whenever the CODEC is up, for such supplies one approach is to just to hook them up to all the CODEC inputs and outputs, which is what we do here.

You mention that your power gate might only exist on some hardware. This hardware differences are what device tree is there to describe. So lets say your CODEC has a main power supply called AVDD as in my example above:

codec_pwr: regulator@0 {
	compatble = "regulator-fixed";

	... fixed regulator stuff ...
};
codec_pwr_switch: regulator@0 {
	compatible = "regulator-gpio";

	... regulator gpio stuff ...
};

/* Board with switch */

codec: es8328@11 {
       compatible = "es8328";
       reg = <0x11>;
	AVDD-supply = <&codec_pwr_switch>;
};

/* Board without switch */

codec: es8328@11 {
       compatible = "es8328";
       reg = <0x11>;
	AVDD-supply = <&codec_pwr>;
};

Thanks,
Charles

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

#18 lore raw

Re: [alsa-devel] [PATCH v4 3/3] ASoC: fsl: add imx-es8328 machine driver

In reply to a message not in the archive
Quoted 4 lines · Charles Keepax

You mention that your power gate might only exist on some hardware. This hardware differences are what device tree is there to describe. So lets say your CODEC has a main power supply called AVDD as in my example above:

FWIW the datasheet I just googled appears to say there are power supplies AVDD, DVDD, PVDD and HPVDD - all four of them should appear in the driver.