ASoC: add es8316 codec driver
Subsystems (3)
PATCH v2 1/2 ASoC: add es8316 codec driver
Add a codec driver for the Everest ES8316, based on code provided by David Yang from Everest Semi.
I limited the functionality to items where the vendor code was clear, and things that can be tested on the Weibu F3C (Intel Cherry Trail). As a result the initial implementation only supports running in slave mode at single speed (up to 48kHz sample rate) using I2S. HPD is not supported.
[[email protected]: significant cleanups and simplifications,
remove dead/unclear code]
---
Notes:
v2:
- Add sign-off from David Yang
- Only support whole number rates calculated with mclk ratios
sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/es8316.c | 646 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/es8316.h | 122 +++++++++ 4 files changed, 774 insertions(+) create mode 100644 sound/soc/codecs/es8316.c create mode 100644 sound/soc/codecs/es8316.h
sound/soc/codecs/Kconfig +4 -0
@@ -72,6 +72,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_DA9055 if I2C select SND_SOC_DIO2125 select SND_SOC_DMIC + select SND_SOC_ES8316 if I2C select SND_SOC_ES8328_SPI if SPI_MASTER select SND_SOC_ES8328_I2C if I2C select SND_SOC_ES7134
@@ -543,6 +544,9 @@ config SND_SOC_HDMI_CODEC config SND_SOC_ES7134 tristate "Everest Semi ES7134 CODEC" +config SND_SOC_ES8316 + tristate "Everest Semi ES8316 CODEC" + config SND_SOC_ES8328 tristate
sound/soc/codecs/Makefile +2 -0
@@ -65,6 +65,7 @@ snd-soc-da732x-objs := da732x.o snd-soc-da9055-objs := da9055.o snd-soc-dmic-objs := dmic.o snd-soc-es7134-objs := es7134.o +snd-soc-es8316-objs := es8316.o snd-soc-es8328-objs := es8328.o snd-soc-es8328-i2c-objs := es8328-i2c.o snd-soc-es8328-spi-objs := es8328-spi.o
@@ -300,6 +301,7 @@ obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o obj-$(CONFIG_SND_SOC_DA9055) += snd-soc-da9055.o obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o obj-$(CONFIG_SND_SOC_ES7134) += snd-soc-es7134.o +obj-$(CONFIG_SND_SOC_ES8316) += snd-soc-es8316.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
sound/soc/codecs/es8316.c new file +646 -0
646 lines not on this page · raw message
sound/soc/codecs/es8316.h new file +122 -0
122 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v2 2/2 ASoC: Intel: add machine driver for BYT/CHT + ES8316
Add new machine driver, tested with Weibu F3C MiniPC.
Based heavily on code provided by David Yang @ Everest, and other machine drivers in the same directory.
---
Notes:
v2:
- add sign-off from David Yang
- fix bytbyt typo
- mention that BYT-CR/SSP0 is not supported
- mention which mic was tested
- setup clocks at init time, avoids need for platform clock control
sound/soc/intel/Kconfig | 12 ++ sound/soc/intel/atom/sst/sst_acpi.c | 2 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/bytcht_es8316.c | 300 +++++++++++++++++++++++++++++++++ 4 files changed, 316 insertions(+) create mode 100644 sound/soc/intel/boards/bytcht_es8316.c
sound/soc/intel/Kconfig +12 -0
@@ -214,6 +214,18 @@ config SND_SOC_INTEL_BYT_CHT_DA7213_MACH platforms with DA7212/7213 audio codec. If unsure select "N". +config SND_SOC_INTEL_BYT_CHT_ES8316_MACH + tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail with ES8316 codec" + depends on X86_INTEL_LPSS && I2C && ACPI + select SND_SOC_ES8316 + select SND_SST_ATOM_HIFI2_PLATFORM + select SND_SST_IPC_ACPI + select SND_SOC_INTEL_SST_MATCH if ACPI + help + This adds support for ASoC machine driver for Intel(R) Baytrail & + Cherrytrail platforms with ES8316 audio codec. + If unsure select "N". + config SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH tristate "ASoC Audio driver for Intel Baytrail & Cherrytrail platform with no codec (MinnowBoard MAX, Up)" depends on X86_INTEL_LPSS && I2C && ACPI
sound/soc/intel/atom/sst/sst_acpi.c +2 -0
@@ -533,6 +533,8 @@ static struct sst_acpi_mach sst_acpi_chv[] = { &chv_platform_data }, {"DLGS7213" ,"bytcht_da7213" ,"intel/fw_sst_22a8.bin" ,"bytcht_da7213" ,NULL , &chv_platform_data }, + {"ESSX8316", "bytcht_es8316", "intel/fw_sst_22a8.bin", "cht-bsw", NULL, + &chv_platform_data },/* some CHT-T platforms rely on RT5640, use Baytrail machine driver */ {"10EC5640", "bytcr_rt5640", "intel/fw_sst_22a8.bin", "bytcr_rt5640", cht_quirk, &chv_platform_data },
sound/soc/intel/boards/Makefile +2 -0
@@ -11,6 +11,7 @@ snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o +snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o snd-soc-skl_rt286-objs := skl_rt286.o snd-skl_nau88l25_max98357a-objs := skl_nau88l25_max98357a.o
@@ -29,6 +30,7 @@ obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max98090_ti.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o +obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH) += snd-skl_nau88l25_max98357a.o
sound/soc/intel/boards/bytcht_es8316.c new file +300 -0
300 lines not on this page · raw message
Signature · 1 line
2.11.0
Mark Brown
maintainersound/soc/codecs/es8316.c line 67
Quoted 3 lines · Daniel Drake
sound/soc/codecs/es8316.c new file +3
-0+static const char *const alc_func_txt[] = {"Off" ,"On" }; +static const struct soc_enum alc_func = +SOC_ENUM_SINGLE (ES8316_ADC_ALC1 ,6 ,2 , alc_func_txt);
Use normal boolean controls for simple on/off switches, just a _SINGLE control with a name ending Switch. This applies to many controls in this driver.
sound/soc/codecs/es8316.c line 86
Quoted 5 lines
sound/soc/codecs/es8316.c new file +5
-0+static const struct snd_kcontrol_new es8316_snd_controls[] = { +SOC_DOUBLE_TLV ("HP Playback Volume" ,ES8316_CPHP_ICAL_VOL , +4 ,0 ,0 ,1 , hpout_vol_tlv), +SOC_DOUBLE_TLV ("HPMixer Gain" ,ES8316_HPMIX_VOL , +0 ,4 ,7 ,0 , hpmixer_gain_tlv),
All volume controls should end in Volume so that UIs know what to do with them. This is also a repeated problem.
sound/soc/codecs/es8316.c line 443
Quoted 6 lines
sound/soc/codecs/es8316.c new file +6
-0+static int es8316_set_bias_level (struct snd_soc_codec *codec, +enum snd_soc_bias_level level) +{ +switch (level) { +case SND_SOC_BIAS_ON : +snd_soc_write (codec,ES8316_RESET ,0xC0 );
Writing to the reset register doens't reset the chip?
sound/soc/codecs/es8316.c line 453
Quoted 10 lines
sound/soc/codecs/es8316.c new file +10
-0+snd_soc_write (codec,ES8316_CPHP_OUTEN ,0x66 ); +snd_soc_write (codec,ES8316_DAC_PDN ,0x00 ); +snd_soc_write (codec,ES8316_CPHP_LDOCTL ,0x30 ); +snd_soc_write (codec,ES8316_CPHP_PDN2 ,0x10 ); +snd_soc_write (codec,ES8316_CPHP_PDN1 ,0x03 ); +snd_soc_write (codec,ES8316_HPMIX_PDN ,0x00 ); +snd_soc_update_bits (codec,ES8316_ADC_PDN_LINSEL ,0xc0 ,0x00 ); +snd_soc_write (codec,ES8316_SYS_PDN ,0x00 ); +snd_soc_write (codec,ES8316_SYS_LP1 ,0x04 ); +snd_soc_write (codec,ES8316_SYS_LP2 ,0x0c );
This all looks like it should be managed by DAPM.
sound/soc/codecs/es8316.c line 458
Quoted 5 lines
sound/soc/codecs/es8316.c new file +5
-0+break ; +case SND_SOC_BIAS_PREPARE : +break ; +case SND_SOC_BIAS_STANDBY : +break ;
Transitioning to ON should be undone when we go back down to standby.
Quoted 5 lines
sound/soc/codecs/es8316.c new file +4
-0+static int es8316_probe(struct snd_soc_codec *codec) + snd_soc_write(codec, ES8316_CLKMGR_CLKSEL, 0x08); +snd_soc_write (codec,ES8316_CLKMGR_ADCOSR ,0x32 ); +snd_soc_write (codec,ES8316_CLKMGR_ADCDIV1 ,0x11 );
sound/soc/codecs/es8316.c line 528
Quoted 10 lines
sound/soc/codecs/es8316.c new file +10
-0+snd_soc_write (codec,ES8316_CLKMGR_ADCDIV2 ,0x00 ); +snd_soc_write (codec,ES8316_CLKMGR_DACDIV1 ,0x11 ); +snd_soc_write (codec,ES8316_CLKMGR_DACDIV2 ,0x00 ); +snd_soc_write (codec,ES8316_CLKMGR_CPDIV ,0x00 ); +snd_soc_write (codec,ES8316_SERDATA1 ,0x04 ); +snd_soc_write (codec,ES8316_CLKMGR_CLKSW ,0x7f ); +snd_soc_write (codec,ES8316_CAL_TYPE ,0x0F ); +snd_soc_write (codec,ES8316_CAL_HPLIV ,0x90 ); +snd_soc_write (codec,ES8316_CAL_HPRIV ,0x90 ); +snd_soc_write (codec,ES8316_ADC_VOLUME ,0x00 );
No big undocumented magic register write sequences in probe please, especially not ones that look like they change the default values of user visible controls. The chip should use the hardware defaults where possible to avoid having to decide which use cases to support in the driver. Let userspace pick what works for a given system.
sound/soc/codecs/es8316.c line 618
Quoted 5 lines
sound/soc/codecs/es8316.c new file +5
-0+static const struct i2c_device_id es8316_i2c_id[] = { + {"ESSX8316" ,0 }, + {} +}; +MODULE_DEVICE_TABLE (i2c, es8316_i2c_id);
Linux I2C device IDs are generally lower case.