ASoC: add rt5665 codec driver
Subsystems (4)
PATCH 1/1 ASoC: add rt5665 codec driver
This is the initial codec driver for rt5665.
--- Documentation/devicetree/bindings/sound/rt5665.txt | 68 + include/sound/rt5665.h | 51 + sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/rt5665.c | 4643 ++++++++++++++++++++ sound/soc/codecs/rt5665.h | 2017 +++++++++ 6 files changed, 6787 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/rt5665.txt create mode 100644 include/sound/rt5665.h create mode 100644 sound/soc/codecs/rt5665.c create mode 100644 sound/soc/codecs/rt5665.h
Documentation/devicetree/bindings/sound/rt5665.txt new file +68 -0
@@ -0,0 +1,68 @@ +RT5665/RT5666/RT5668 audio CODEC + +This device supports I2C only. + +Required properties: + +- compatible : One of "realtek,rt5665", "realtek,rt5666" or "realtek,rt5668". + +- reg : The I2C address of the device. + +- interrupts : The CODEC's interrupt output. + +Optional properties: + +- realtek,in1-differential +- realtek,in2-differential +- realtek,in3-differential +- realtek,in4-differential + Boolean. Indicate MIC1/2/3/4 input are differential, rather than single-ended. + +- realtek,dmic1-data-pin + 0: dmic1 is not used + 1: using GPIO4 pin as dmic1 data pin + 2: using IN2N pin as dmic2 data pin + +- realtek,dmic2-data-pin + 0: dmic2 is not used + 1: using GPIO5 pin as dmic2 data pin + 2: using IN2P pin as dmic2 data pin + +- realtek,jd-src + 0: No JD is used + 1: using JD1 as JD source + +- realtek,ldo1-en-gpios : The GPIO that controls the CODEC's LDO1_EN pin. + +Pins on the device (for linking into audio routes) for RT5659/RT5658: + + * DMIC L1 + * DMIC R1 + * DMIC L2 + * DMIC R2 + * IN1P + * IN1N + * IN2P + * IN2N + * IN3P + * IN3N + * IN4P + * IN4N + * HPOL + * HPOR + * LOUTL + * LOUTR + * MONOOUT + * PDML + * PDMR + +Example: + +rt5659 { + compatible = "realtek,rt5665"; + reg = <0x1b>; + interrupt-parent = <&gpio>; + interrupts = <TEGRA_GPIO(W, 3) GPIO_ACTIVE_HIGH>; + realtek,ldo1-en-gpios = + <&gpio TEGRA_GPIO(V, 3) GPIO_ACTIVE_HIGH>; +};
include/sound/rt5665.h new file +51 -0
51 lines not on this page · raw message
sound/soc/codecs/Kconfig +6 -0
@@ -116,6 +116,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_RT5651 if I2C select SND_SOC_RT5659 if I2C select SND_SOC_RT5660 if I2C + select SND_SOC_RT5665 if I2C select SND_SOC_RT5663 if I2C select SND_SOC_RT5670 if I2C select SND_SOC_RT5677 if I2C && SPI_MASTER
@@ -662,6 +663,7 @@ config SND_SOC_RL6231 default y if SND_SOC_RT5651=y default y if SND_SOC_RT5659=y default y if SND_SOC_RT5660=y + default y if SND_SOC_RT5665=y default y if SND_SOC_RT5663=y default y if SND_SOC_RT5670=y default y if SND_SOC_RT5677=y
@@ -672,6 +674,7 @@ config SND_SOC_RL6231 default m if SND_SOC_RT5651=m default m if SND_SOC_RT5659=m default m if SND_SOC_RT5660=m + default m if SND_SOC_RT5665=m default m if SND_SOC_RT5663=m default m if SND_SOC_RT5670=m default m if SND_SOC_RT5677=m
@@ -721,6 +724,9 @@ config SND_SOC_RT5659 config SND_SOC_RT5660 tristate +config SND_SOC_RT5665 + tristate + config SND_SOC_RT5663 tristate
sound/soc/codecs/Makefile +2 -0
@@ -117,6 +117,7 @@ snd-soc-rt5645-objs := rt5645.o snd-soc-rt5651-objs := rt5651.o snd-soc-rt5659-objs := rt5659.o snd-soc-rt5660-objs := rt5660.o +snd-soc-rt5665-objs := rt5665.o snd-soc-rt5663-objs := rt5663.o snd-soc-rt5670-objs := rt5670.o snd-soc-rt5677-objs := rt5677.o
@@ -343,6 +344,7 @@ obj-$(CONFIG_SND_SOC_RT5645) += snd-soc-rt5645.o obj-$(CONFIG_SND_SOC_RT5651) += snd-soc-rt5651.o obj-$(CONFIG_SND_SOC_RT5659) += snd-soc-rt5659.o obj-$(CONFIG_SND_SOC_RT5660) += snd-soc-rt5660.o +obj-$(CONFIG_SND_SOC_RT5665) += snd-soc-rt5665.o obj-$(CONFIG_SND_SOC_RT5663) += snd-soc-rt5663.o obj-$(CONFIG_SND_SOC_RT5670) += snd-soc-rt5670.o obj-$(CONFIG_SND_SOC_RT5677) += snd-soc-rt5677.o
sound/soc/codecs/rt5665.c new file +4643 -0
2,837 lines not on this page · raw message
sound/soc/codecs/rt5665.h new file +2017 -0
2,017 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.1.1.439.g50a6b54
Part of the diff is not shown here. View the raw message.
Mark Brown
maintainersound/soc/codecs/rt5665.c line 3387
Quoted 2 lines · Bard Liao
sound/soc/codecs/rt5665.c new file +2
-0+ {"TDM2 Data Mux", "1324", "IF1_2 ADC TDM"}, + {"TDM2 Data Mux", "1342", "IF1_2 ADC TDM"},
These aren't really done properly - they're squashing all the data paths down into one. Ideally there'd be a separate AIF widget for each channel. It's not super urgent right now since it won't make a practical difference.
sound/soc/codecs/rt5665.c line 4430
Quoted 6 lines
sound/soc/codecs/rt5665.c new file +6
-0+ regulator_1v8 =devm_regulator_get_optional (&i2c->dev, + rt5665->pdata.regulator_1v8); +if (IS_ERR (regulator_1v8)) +dev_err (&i2c->dev,"Fail to get regulator_1v8\n" ); +else if (regulator_enable (regulator_1v8)) +dev_err (&i2c->dev,"Fail to enable regulator_1v8\n" );
This isn't good, while we log if we fail to enable the regulator we don't otherwise handle the error. If the we failed to power on a power supply the chances are that the device isn't going to work so I'd expect us to fail the proble.
sound/soc/codecs/rt5665.c line 4440
Quoted 5 lines
sound/soc/codecs/rt5665.c new file +4
-0+ regulator_3v3 =devm_regulator_get_optional (&i2c->dev, + rt5665->pdata.regulator_3v3); + regulator_5v =devm_regulator_get_optional (&i2c->dev, + rt5665->pdata.regulator_5v);
I also just don't believe that *all* of the regulators the device has are optional.
A message that is not in the archive (sent off-list or not yet received): ABFD875FF5FB574BA706497D987D48D7011D28D9@RTITMBSV03.realtek.com.tw
Mark Brown
maintainerQuoted 7 lines · Bard Liao
Quoted 3 lines
These aren't really done properly - they're squashing all the data paths down into one. Ideally there'd be a separate AIF widget for each channel. It's not super urgent right now since it won't make a practical difference.
I will modify that. Something like below, right?
SND_SOC_DAPM_AIF_OUT("AIFOUTL", "Capture", 0, SND_SOC_NOPM, 0, 0),SND_SOC_DAPM_AIF_OUT("AIFOUTR", "Capture", 1, SND_SOC_NOPM, 0, 0),
Yes, exactly
Quoted 11 lines
Quoted 7 lines
sound/soc/codecs/rt5665.c line 4440
Quoted 5 lines
sound/soc/codecs/rt5665.c new file +4
-0+ regulator_3v3 =devm_regulator_get_optional (&i2c->dev, + rt5665->pdata.regulator_3v3); + regulator_5v =devm_regulator_get_optional (&i2c->dev, + rt5665->pdata.regulator_5v);I also just don't believe that *all* of the regulators the device has are optional.
That is because we don't know how customers design their schematic. All regulators can be connected by hardware pin. It means we don't need to use a regular to supply it.
No, that's something the regulator API will handle for you - individual drivers should be written with sensible error handling, the regulator API will handle stubbing out things that are needed.
A message that is not in the archive (sent off-list or not yet received): ABFD875FF5FB574BA706497D987D48D7011D5502@RTITMBSV03.realtek.com.tw
Mark Brown
maintainerQuoted 9 lines · Bard Liao
Quoted 3 lines
No, that's something the regulator API will handle for you - individual drivers should be written with sensible error handling, the regulator API will handle stubbing out things that are needed.
Sorry, maybe I didn't describe it clear. What I mean is all power pins needed by rt5665 codec can be connected by hardware directly without SW control. There is no specific power sequence for these power pins. So, we don't need to control them by driver. That's why we think they are optional.
That's exactly what I understood you to mean. The regulator API will hide this for you.