Add ES8328 audio codec
Subsystems (5)
v8 cover Add ES8328 audio codec
This patchset adds support for the Everest Semi ES8328 audio codec, used in the Novena open source laptop. 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 speaker amps and as well as supporting headphone jacks, in addition to the i.MX audmux routing.
Changes since v7:
- We now fetch the regulators in the device-level probe rather than in the ASoC-level probe.
Changes since v6:
- Minor clarification of AUDMUX in imx-audio-es8328.txt
- Use u32 instead of int in imx-es8328.c for int-mux and ext-mux
- Bounds checking on mux-int-port and mux-ext-port in imx-es8328.c
- Remove NULL checks before calling of_node_put()
Changes since v5:
- Removed empty imx_set_frequency function from imx-es8328.c
- Move the clock from imx-audio-es8328 to the es8328 codec itself
- Add support for 2x (22.5792 MHz) and 1x (11.2896 MHz) source clocks
- Restore registers on resume
- Document pins for ES8328, including input pins
Changes since v4:
- Simplify clock handling and use assigned-clock-parents
- Move the codec regulator from the machine driver to the codec
- Specify all four regulators, and require their presence
- Fix audio recording, such that it enables the PGA
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 | 38 ++ .../devicetree/bindings/sound/imx-audio-es8328.txt | 61 ++ .../devicetree/bindings/vendor-prefixes.txt | 1 + sound/soc/codecs/Kconfig | 13 + sound/soc/codecs/Makefile | 6 + sound/soc/codecs/es8328-i2c.c | 60 ++ sound/soc/codecs/es8328-spi.c | 49 ++ sound/soc/codecs/es8328.c | 719 +++++++++++++++++++++ sound/soc/codecs/es8328.h | 314 +++++++++ sound/soc/fsl/Kconfig | 14 + sound/soc/fsl/Makefile | 2 + sound/soc/fsl/imx-es8328.c | 233 +++++++ 12 files changed, 1510 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
PATCH v8 1/3 devicetree: bindings: Add Everest Semicodunctor
In reply to a message not in the archiveEverest Semiconductor makes audio codecs.
--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -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
PATCH v8 2/3 ASoC: add es8328 codec driver
In reply to a message not in the archiveAdd a codec driver for the Everest ES8328. It supports two separate audio outputs and two separate audio inputs.
--- Documentation/devicetree/bindings/sound/es8328.txt | 38 ++ sound/soc/codecs/Kconfig | 13 + sound/soc/codecs/Makefile | 6 + sound/soc/codecs/es8328-i2c.c | 60 ++ sound/soc/codecs/es8328-spi.c | 49 ++ sound/soc/codecs/es8328.c | 719 +++++++++++++++++++++ sound/soc/codecs/es8328.h | 314 +++++++++ 7 files changed, 1199 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 +38 -0
@@ -0,0 +1,38 @@ +Everest ES8328 audio CODEC + +This device supports both I2C and SPI. + +Required properties: + + - compatible : "everest,es8328" + - DVDD-supply : Regulator providing digital core supply voltage 1.8 - 3.6V + - AVDD-supply : Regulator providing analog supply voltage 3.3V + - PVDD-supply : Regulator providing digital IO supply voltage 1.8 - 3.6V + - IPVDD-supply : Regulator providing analog output voltage 3.3V + - clocks : A 22.5792 or 11.2896 MHz clock + - reg : the I2C address of the device for I2C, the chip select number for SPI + +Pins on the device (for linking into audio routes): + + * LOUT1 + * LOUT2 + * ROUT1 + * ROUT2 + * LINPUT1 + * RINPUT1 + * LINPUT2 + * RINPUT2 + * Mic Bias + + +Example: + +codec: es8328@11 { + compatible = "everest,es8328"; + DVDD-supply = <®_3p3v>; + AVDD-supply = <®_3p3v>; + PVDD-supply = <®_3p3v>; + HPVDD-supply = <®_3p3v>; + clocks = <&clks 169>; + reg = <0x11>; +};
sound/soc/codecs/Kconfig +13 -0
@@ -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
@@ -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
@@ -215,6 +218,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 +60 -0
60 lines not on this page · raw message
sound/soc/codecs/es8328-spi.c new file +49 -0
49 lines not on this page · raw message
sound/soc/codecs/es8328.c new file +719 -0
719 lines not on this page · raw message
sound/soc/codecs/es8328.h new file +314 -0
314 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
PATCH v8 3/3 ASoC: fsl: add imx-es8328 machine driver
In reply to a message not in the archiveThis adds an initial machine driver for the ES8328 audio codec on Freescale boards. The driver supports headphones and an audio regulator for an onboard speaker amp.
--- .../devicetree/bindings/sound/imx-audio-es8328.txt | 61 ++++++ sound/soc/fsl/Kconfig | 14 ++ sound/soc/fsl/Makefile | 2 + sound/soc/fsl/imx-es8328.c | 233 +++++++++++++++++++++ 4 files changed, 310 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 +61 -0
@@ -0,0 +1,61 @@ +Freescale i.MX audio complex with ES8328 codec + +Required properties: +- compatible : "fsl,imx-audio-es8328" +- model : The user-visible name of this sound complex +- ssi-controller : The phandle of the i.MX SSI controller +- jack-gpio : Optional GPIO for headphone jack +- 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 + + ES8328 pins: + * LOUT1 + * LOUT2 + * ROUT1 + * ROUT2 + * LINPUT1 + * LINPUT2 + * RINPUT1 + * RINPUT2 + * Mic PGA + + Board connectors: + * Headphone + * Speaker + * Mic Jack + +- 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 (AUDMIX) + +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"; + ssi-controller = <&ssi1>; + audio-codec = <&codec>; + jack-gpio = <&gpio5 15 0>; + audio-amp-supply = <®_audio_amp>; + audio-routing = + "Speaker", "LOUT2", + "Speaker", "ROUT2", + "Speaker", "audio-amp", + "Headphone", "ROUT1", + "Headphone", "LOUT1", + "LINPUT1", "Mic Jack", + "RINPUT1", "Mic Jack", + "Mic Jack", "Mic Bias"; + mux-int-port = <1>; + mux-ext-port = <3>; +}; +
sound/soc/fsl/Kconfig +14 -0
@@ -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
@@ -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 +233 -0
233 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
Re: [PATCH v8 2/3] ASoC: add es8328 codec driver
In reply to a message not in the archiveQuoted 2 lines · Sean Cross
Add a codec driver for the Everest ES8328. It supports two separate audio outputs and two separate audio inputs.
This looks mostly fine so I've applied it, there are some issues below - please send followups fixing them.
sound/soc/codecs/es8328.c line 417
Quoted 5 lines
sound/soc/codecs/es8328.c new file +5
-0+if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) + reg =ES8328_DACCONTROL2 ; + +else + reg =ES8328_ADCCONTROL5 ;
Coding style, extra blank line in the middle of the if ().
Quoted 8 lines
sound/soc/codecs/es8328.c new file +8
-0+switch (params_rate (params)) { +case 8000 : + val = es8328_sample_ratios[ES8328_RATE_8019 ]; +break ; +case 11025 : + val = es8328_sample_ratios[ES8328_RATE_11025 ]; +break ; +case 22050 :
sound/soc/codecs/es8328.c line 447
Quoted 10 lines
sound/soc/codecs/es8328.c new file +10
-0+ val = es8328_sample_ratios[ES8328_RATE_22050 ]; +break ; +case 44100 : + val = es8328_sample_ratios[ES8328_RATE_44100 ]; +break ; +default : +dev_err (codec->dev,"%s: unknown rate %d\n" , + __func__,params_rate (params)); +return -EINVAL ; + }
The array serves no function given that you're never iterating over it or anything - either have the array be a lookup table or just put the constants in the switch statement directly. You're also calling the array "_sample_ratios" but it actually appears to be sample rates.
sound/soc/codecs/es8328.c line 501
Quoted 10 lines
sound/soc/codecs/es8328.c new file +10
-0+snd_soc_write (codec,ES8328_MASTERMODE ,ES8328_MASTERMODE_MSC ); + + clk_rate =clk_get_rate (es8328->clk); +if (clk_rate ==ES8328_SYSCLK_RATE_1X ) +snd_soc_write (codec,ES8328_MASTERMODE , +ES8328_MASTERMODE_MSC ); +else +snd_soc_write (codec,ES8328_MASTERMODE , +ES8328_MASTERMODE_MCLKDIV2 | +ES8328_MASTERMODE_MSC );
update_bits().
sound/soc/codecs/es8328.c line 566
Quoted 10 lines
sound/soc/codecs/es8328.c new file +10
-0+snd_soc_write (codec,ES8328_CHIPPOWER , +ES8328_CHIPPOWER_ADCDIG_OFF | +ES8328_CHIPPOWER_DACDIG_OFF | +ES8328_CHIPPOWER_ADCSTM_RESET | +ES8328_CHIPPOWER_DACSTM_RESET | +ES8328_CHIPPOWER_ADCPLL_OFF | +ES8328_CHIPPOWER_DACPLL_OFF | +ES8328_CHIPPOWER_ADCVREF_OFF | +ES8328_CHIPPOWER_DACVREF_OFF ); +break ;
This looks like most if not all of it should be in DAPM, especially the DAC and ADC power - the device is wasting power on the ADC during playback for example. Looking at the code I suspect that some of these should be done as supply widgets.
Quoted 6 lines
sound/soc/codecs/es8328.c new file +6
-0+static int es8328_suspend (struct snd_soc_codec *codec) +{ +es8328_set_bias_level (codec,SND_SOC_BIAS_OFF ); +return 0 ; +} +
sound/soc/codecs/es8328.c line 612
Quoted 10 lines
sound/soc/codecs/es8328.c new file +10
-0+static int es8328_resume (struct snd_soc_codec *codec) +{ +struct regmap *regmap =dev_get_regmap (codec->dev,NULL ); + +regcache_mark_dirty (regmap); +regcache_sync (regmap); + +es8328_set_bias_level (codec,SND_SOC_BIAS_STANDBY ); +return 0 ; +}
But leave the regulators and clocks enabled?
Mark Brown
AppliedRe: [PATCH v8 3/3] ASoC: fsl: add imx-es8328 machine driver
In reply to a message not in the archiveQuoted 3 lines · Sean Cross
This adds an initial machine driver for the ES8328 audio codec on Freescale boards. The driver supports headphones and an audio regulator for an onboard speaker amp.
Applied, thanks.
Mark Brown
maintainerRe: [PATCH v8 2/3] ASoC: add es8328 codec driver
In reply to Mark BrownQuoted 7 lines · Mark Brown
Quoted 2 lines · Sean Cross
Add a codec driver for the Everest ES8328. It supports two separate audio outputs and two separate audio inputs.
This looks mostly fine so I've applied it, there are some issues below - please send followups fixing them.
...except it doesn't actually build since you use the variable ret in the probe function without declaring it. Reverted, please fix this along with the other more minor issues and resubmit.