Skip to contentSkip to conversation

ASoC: codecs: add rk817 support

PATCH Superseded Chris Morgan 3 participants 11 messages May 5, 2021 – May 14, 2021

Subsystems (5)

v9 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v9 cover ASoC: codecs: add rk817 support

From: Chris Morgan <[email protected]>

This series is to add support for the Rockchip rk817 audio codec which is present in all Rockchip rk817 MFD chips.

Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in separate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

Chris Morgan (4):
mfd: Add Rockchip rk817 audio CODEC support
ASoC: Add Rockchip rk817 audio CODEC support
dt-bindings: Add Rockchip rk817 audio CODEC support
arm64: dts: rockchip: add rk817 codec to Odroid Go

 .../devicetree/bindings/mfd/rk808.txt         | 186 ++++++
 .../boot/dts/rockchip/rk3326-odroid-go2.dts   |  36 +-
 drivers/mfd/rk808.c                           |  85 +++
 include/linux/mfd/rk808.h                     |  81 +++
 sound/soc/codecs/Kconfig                      |   6 +
 sound/soc/codecs/Makefile                     |   2 +
 sound/soc/codecs/rk817_codec.c                | 558 ++++++++++++++++++
 7 files changed, 952 insertions(+), 2 deletions(-)
 create mode 100644 sound/soc/codecs/rk817_codec.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v9 1/4 mfd: Add Rockchip rk817 audio CODEC support

From: Chris Morgan <[email protected]>

Add rk817 codec support cell to rk808 mfd driver.

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 drivers/mfd/rk808.c       | 85 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rk808.h | 81 +++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
drivers/mfd/rk808.c +85 -0
index ad923dd4e007..9231209184e0 100644
@@ -65,6 +65,7 @@ static bool rk817_is_volatile_reg(struct device *dev, unsigned int reg)
 	switch (reg) {
 	case RK817_SECONDS_REG ... RK817_WEEKS_REG:
 	case RK817_RTC_STATUS_REG:
+	case RK817_CODEC_DTOP_LPT_SRST:
 	case RK817_INT_STS_REG0:
 	case RK817_INT_STS_REG1:
 	case RK817_INT_STS_REG2:
@@ -163,6 +164,11 @@ static const struct mfd_cell rk817s[] = {
 		.num_resources = ARRAY_SIZE(rk817_rtc_resources),
 		.resources = &rk817_rtc_resources[0],
 	},
+#ifdef CONFIG_SND_SOC_RK817
+	{
+		.name = "rk817-codec",
+	},
+#endif
 };
 
 static const struct mfd_cell rk818s[] = {
@@ -201,6 +207,85 @@ static const struct rk808_reg_data rk808_pre_init_reg[] = {
 
 static const struct rk808_reg_data rk817_pre_init_reg[] = {
 	{RK817_RTC_CTRL_REG, RTC_STOP, RTC_STOP},
+	/* Codec specific registers */
+	{ RK817_CODEC_DTOP_VUCTL, MASK_ALL, 0x03 },
+	{ RK817_CODEC_DTOP_VUCTIME, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DTOP_LPT_SRST, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DTOP_DIGEN_CLKE, MASK_ALL, 0x00 },
+	/* from vendor driver, CODEC_AREF_RTCFG0 not defined in data sheet */
+	{ RK817_CODEC_AREF_RTCFG0, MASK_ALL, 0x00 },
+	{ RK817_CODEC_AREF_RTCFG1, MASK_ALL, 0x06 },
+	{ RK817_CODEC_AADC_CFG0, MASK_ALL, 0xc8 },
+	/* from vendor driver, CODEC_AADC_CFG1 not defined in data sheet */
+	{ RK817_CODEC_AADC_CFG1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DADC_VOLL, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DADC_VOLR, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DADC_SR_ACL0, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DADC_ALC1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DADC_ALC2, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DADC_NG, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DADC_HPF, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DADC_RVOLL, MASK_ALL, 0xff },
+	{ RK817_CODEC_DADC_RVOLR, MASK_ALL, 0xff },
+	{ RK817_CODEC_AMIC_CFG0, MASK_ALL, 0x70 },
+	{ RK817_CODEC_AMIC_CFG1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DMIC_PGA_GAIN, MASK_ALL, 0x66 },
+	{ RK817_CODEC_DMIC_LMT1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DMIC_LMT2, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DMIC_NG1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DMIC_NG2, MASK_ALL, 0x00 },
+	/* from vendor driver, CODEC_ADAC_CFG0 not defined in data sheet */
+	{ RK817_CODEC_ADAC_CFG0, MASK_ALL, 0x00 },
+	{ RK817_CODEC_ADAC_CFG1, MASK_ALL, 0x07 },
+	{ RK817_CODEC_DDAC_POPD_DACST, MASK_ALL, 0x82 },
+	{ RK817_CODEC_DDAC_VOLL, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_VOLR, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_SR_LMT0, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_LMT1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_LMT2, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_MUTE_MIXCTL, MASK_ALL, 0xa0 },
+	{ RK817_CODEC_DDAC_RVOLL, MASK_ALL, 0xff },
+	{ RK817_CODEC_DADC_RVOLR, MASK_ALL, 0xff },
+	{ RK817_CODEC_AMIC_CFG0, MASK_ALL, 0x70 },
+	{ RK817_CODEC_AMIC_CFG1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DMIC_PGA_GAIN, MASK_ALL, 0x66 },
+	{ RK817_CODEC_DMIC_LMT1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DMIC_LMT2, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DMIC_NG1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DMIC_NG2, MASK_ALL, 0x00 },
+	/* from vendor driver, CODEC_ADAC_CFG0 not defined in data sheet */
+	{ RK817_CODEC_ADAC_CFG0, MASK_ALL, 0x00 },
+	{ RK817_CODEC_ADAC_CFG1, MASK_ALL, 0x07 },
+	{ RK817_CODEC_DDAC_POPD_DACST, MASK_ALL, 0x82 },
+	{ RK817_CODEC_DDAC_VOLL, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_VOLR, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_SR_LMT0, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_LMT1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_LMT2, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DDAC_MUTE_MIXCTL, MASK_ALL, 0xa0 },
+	{ RK817_CODEC_DDAC_RVOLL, MASK_ALL, 0xff },
+	{ RK817_CODEC_DDAC_RVOLR, MASK_ALL, 0xff },
+	{ RK817_CODEC_AHP_ANTI0, MASK_ALL, 0x00 },
+	{ RK817_CODEC_AHP_ANTI1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_AHP_CFG0, MASK_ALL, 0xe0 },
+	{ RK817_CODEC_AHP_CFG1, MASK_ALL, 0x1f },
+	{ RK817_CODEC_AHP_CP, MASK_ALL, 0x09 },
+	{ RK817_CODEC_ACLASSD_CFG1, MASK_ALL, 0x69 },
+	{ RK817_CODEC_ACLASSD_CFG2, MASK_ALL, 0x44 },
+	{ RK817_CODEC_APLL_CFG0, MASK_ALL, 0x04 },
+	{ RK817_CODEC_APLL_CFG1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_APLL_CFG2, MASK_ALL, 0x30 },
+	{ RK817_CODEC_APLL_CFG3, MASK_ALL, 0x19 },
+	{ RK817_CODEC_APLL_CFG4, MASK_ALL, 0x65 },
+	{ RK817_CODEC_APLL_CFG5, MASK_ALL, 0x01 },
+	{ RK817_CODEC_DI2S_CKM, MASK_ALL, 0x01 },
+	{ RK817_CODEC_DI2S_RSD, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DI2S_RXCR1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DI2S_RXCR2, MASK_ALL, 0x17 },
+	{ RK817_CODEC_DI2S_RXCMD_TSD, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DI2S_TXCR1, MASK_ALL, 0x00 },
+	{ RK817_CODEC_DI2S_TXCR2, MASK_ALL, 0x17 },
+	{ RK817_CODEC_DI2S_TXCR3_TXCMD, MASK_ALL, 0x00 },
 	{RK817_GPIO_INT_CFG, RK817_INT_POL_MSK, RK817_INT_POL_L},
 	{RK817_SYS_CFG(1), RK817_HOTDIE_TEMP_MSK | RK817_TSD_TEMP_MSK,
 					   RK817_HOTDIE_105 | RK817_TSD_140},
include/linux/mfd/rk808.h +81 -0

87 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v9 1/4] mfd: Add Rockchip rk817 audio CODEC support

Quoted 6 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add rk817 codec support cell to rk808 mfd driver.

Nit: These should be chronological.

Quoted 61 lines

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 drivers/mfd/rk808.c       | 85 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rk808.h | 81 +++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
drivers/mfd/rk808.c +1 -0
index ad923dd4e007..9231209184e0 100644
@@ -65,6 +65,7 @@ static bool rk817_is_volatile_reg(struct device *dev, unsigned int reg)
 	switch (reg) {
 	case RK817_SECONDS_REG ... RK817_WEEKS_REG:
 	case RK817_RTC_STATUS_REG:
+	case RK817_CODEC_DTOP_LPT_SRST:
 	case RK817_INT_STS_REG0:
 	case RK817_INT_STS_REG1:
 	case RK817_INT_STS_REG2:

drivers/mfd/rk808.c static const struct mfd_cell rk817s[] = { · line 171

Quoted 8 lines
drivers/mfd/rk808.c +5 -0
@@ -163,6 +164,11 @@ static const struct mfd_cell rk817s[] = {
 		.num_resources = ARRAY_SIZE(rk817_rtc_resources),
 		.resources = &rk817_rtc_resources[0],
 	},
+#ifdef CONFIG_SND_SOC_RK817
+	{
+		.name = "rk817-codec",
+	},
+#endif

No #ifery please.

Just replace it with a comment.

If no associated driver exists, it just won't match/bind.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw

Re: [PATCH v9 1/4] mfd: Add Rockchip rk817 audio CODEC support

Quoted 10 lines · Lee Jones
Quoted 6 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add rk817 codec support cell to rk808 mfd driver.

Nit: These should be chronological.

Acknowledged. I will make sure to do this if a v10 is necessary.

Quoted 73 lines
Quoted 62 lines

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 drivers/mfd/rk808.c       | 85 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rk808.h | 81 +++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
drivers/mfd/rk808.c +1 -0
index ad923dd4e007..9231209184e0 100644
@@ -65,6 +65,7 @@ static bool rk817_is_volatile_reg(struct device *dev, unsigned int reg)
 	switch (reg) {
 	case RK817_SECONDS_REG ... RK817_WEEKS_REG:
 	case RK817_RTC_STATUS_REG:
+	case RK817_CODEC_DTOP_LPT_SRST:
 	case RK817_INT_STS_REG0:
 	case RK817_INT_STS_REG1:
 	case RK817_INT_STS_REG2:

drivers/mfd/rk808.c static const struct mfd_cell rk817s[] = { · line 171

Quoted 8 lines
drivers/mfd/rk808.c +5 -0
@@ -163,6 +164,11 @@ static const struct mfd_cell rk817s[] = {
 		.num_resources = ARRAY_SIZE(rk817_rtc_resources),
 		.resources = &rk817_rtc_resources[0],
 	},
+#ifdef CONFIG_SND_SOC_RK817
+	{
+		.name = "rk817-codec",
+	},
+#endif

No #ifery please.

Quoted 3 lines

Just replace it with a comment.

If no associated driver exists, it just won't match/bind.

I did the "if" here because I noticed that if I have a rk817 and do not utilize the codec I receive a dmesg warning. I put the if here to silence it in the event that someone was using this PMIC but didn't want to use the audio codec. I will make the change if you say so though, but I just want to confirm that it's acceptable to have a warning for all rk817s that do not use the codec about a missing codec. The hardware is always present, I just can't say for certain it will always be used.

Thank you.

Quoted 6 lines
Signature · 5 lines
-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw

Re: [PATCH v9 1/4] mfd: Add Rockchip rk817 audio CODEC support

Quoted 91 lines · Chris Morgan
Quoted 10 lines · Lee Jones
Quoted 6 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add rk817 codec support cell to rk808 mfd driver.

Nit: These should be chronological.

Acknowledged. I will make sure to do this if a v10 is necessary.

Quoted 73 lines
Quoted 62 lines

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 drivers/mfd/rk808.c       | 85 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rk808.h | 81 +++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
drivers/mfd/rk808.c +1 -0
index ad923dd4e007..9231209184e0 100644
@@ -65,6 +65,7 @@ static bool rk817_is_volatile_reg(struct device *dev, unsigned int reg)
 	switch (reg) {
 	case RK817_SECONDS_REG ... RK817_WEEKS_REG:
 	case RK817_RTC_STATUS_REG:
+	case RK817_CODEC_DTOP_LPT_SRST:
 	case RK817_INT_STS_REG0:
 	case RK817_INT_STS_REG1:
 	case RK817_INT_STS_REG2:

drivers/mfd/rk808.c static const struct mfd_cell rk817s[] = { · line 171

Quoted 8 lines
drivers/mfd/rk808.c +5 -0
@@ -163,6 +164,11 @@ static const struct mfd_cell rk817s[] = {
 		.num_resources = ARRAY_SIZE(rk817_rtc_resources),
 		.resources = &rk817_rtc_resources[0],
 	},
+#ifdef CONFIG_SND_SOC_RK817
+	{
+		.name = "rk817-codec",
+	},
+#endif

No #ifery please.

Quoted 3 lines

Just replace it with a comment.

If no associated driver exists, it just won't match/bind.

Quoted 7 lines

I did the "if" here because I noticed that if I have a rk817 and do not utilize the codec I receive a dmesg warning. I put the if here to silence it in the event that someone was using this PMIC but didn't want to use the audio codec. I will make the change if you say so though, but I just want to confirm that it's acceptable to have a warning for all rk817s that do not use the codec about a missing codec. The hardware is always present, I just can't say for certain it will always be used.

What is the dmesg warning you receive?

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#5 lore raw

Re: [PATCH v9 1/4] mfd: Add Rockchip rk817 audio CODEC support

Quoted 101 lines · Lee Jones
Quoted 91 lines · Chris Morgan
Quoted 10 lines · Lee Jones
Quoted 6 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add rk817 codec support cell to rk808 mfd driver.

Nit: These should be chronological.

Acknowledged. I will make sure to do this if a v10 is necessary.

Quoted 73 lines
Quoted 62 lines

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 drivers/mfd/rk808.c       | 85 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rk808.h | 81 +++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
drivers/mfd/rk808.c +1 -0
index ad923dd4e007..9231209184e0 100644
@@ -65,6 +65,7 @@ static bool rk817_is_volatile_reg(struct device *dev, unsigned int reg)
 	switch (reg) {
 	case RK817_SECONDS_REG ... RK817_WEEKS_REG:
 	case RK817_RTC_STATUS_REG:
+	case RK817_CODEC_DTOP_LPT_SRST:
 	case RK817_INT_STS_REG0:
 	case RK817_INT_STS_REG1:
 	case RK817_INT_STS_REG2:

drivers/mfd/rk808.c static const struct mfd_cell rk817s[] = { · line 171

Quoted 8 lines
drivers/mfd/rk808.c +5 -0
@@ -163,6 +164,11 @@ static const struct mfd_cell rk817s[] = {
 		.num_resources = ARRAY_SIZE(rk817_rtc_resources),
 		.resources = &rk817_rtc_resources[0],
 	},
+#ifdef CONFIG_SND_SOC_RK817
+	{
+		.name = "rk817-codec",
+	},
+#endif

No #ifery please.

Quoted 3 lines

Just replace it with a comment.

If no associated driver exists, it just won't match/bind.

Quoted 7 lines

I did the "if" here because I noticed that if I have a rk817 and do not utilize the codec I receive a dmesg warning. I put the if here to silence it in the event that someone was using this PMIC but didn't want to use the audio codec. I will make the change if you say so though, but I just want to confirm that it's acceptable to have a warning for all rk817s that do not use the codec about a missing codec. The hardware is always present, I just can't say for certain it will always be used.

Quoted 1 line

What is the dmesg warning you receive?

It appears I was confused, I will update the code. No warning is received when I take away the ifdef guard. However, if I build the codec and don't include a devicetree node for it I get the following lines in dmesg:

rk817-codec rk817-codec: rk817_codec_parse_dt_property() Can not get child: codec rk817-codec rk817-codec: rk817_platform_probe() parse device tree property error -19

So it looks like this ifdef was meant to "fix" a problem that it doesn't even fix. I'll get rid of it and resubmit. To that end, do you think these messages above are okay, or should we try to fix them in the edge case of a user with an rk817 who doesn't use the codec but still has the codec driver compiled?

Thank you.

Quoted 6 lines
Signature · 5 lines
-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
maintainer
#6 lore raw

Re: [PATCH v9 1/4] mfd: Add Rockchip rk817 audio CODEC support

Hi Chris,

Am Freitag, 14. Mai 2021, 17:50:08 CEST schrieb Chris Morgan:

Quoted 109 lines · Lee Jones
Quoted 101 lines · Chris Morgan
Quoted 92 lines · Lee Jones
Quoted 10 lines · Chris Morgan
Quoted 7 lines

From: Chris Morgan <[email protected]>

Add rk817 codec support cell to rk808 mfd driver.

Nit: These should be chronological.

Acknowledged. I will make sure to do this if a v10 is necessary.

Quoted 73 lines
Quoted 62 lines

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 drivers/mfd/rk808.c       | 85 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rk808.h | 81 +++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
drivers/mfd/rk808.c +1 -0
index ad923dd4e007..9231209184e0 100644
@@ -65,6 +65,7 @@ static bool rk817_is_volatile_reg(struct device *dev, unsigned int reg)
 	switch (reg) {
 	case RK817_SECONDS_REG ... RK817_WEEKS_REG:
 	case RK817_RTC_STATUS_REG:
+	case RK817_CODEC_DTOP_LPT_SRST:
 	case RK817_INT_STS_REG0:
 	case RK817_INT_STS_REG1:
 	case RK817_INT_STS_REG2:

drivers/mfd/rk808.c static const struct mfd_cell rk817s[] = { · line 171

Quoted 8 lines
drivers/mfd/rk808.c +5 -0
@@ -163,6 +164,11 @@ static const struct mfd_cell rk817s[] = {
 		.num_resources = ARRAY_SIZE(rk817_rtc_resources),
 		.resources = &rk817_rtc_resources[0],
 	},
+#ifdef CONFIG_SND_SOC_RK817
+	{
+		.name = "rk817-codec",
+	},
+#endif

No #ifery please.

Quoted 3 lines

Just replace it with a comment.

If no associated driver exists, it just won't match/bind.

Quoted 7 lines

I did the "if" here because I noticed that if I have a rk817 and do not utilize the codec I receive a dmesg warning. I put the if here to silence it in the event that someone was using this PMIC but didn't want to use the audio codec. I will make the change if you say so though, but I just want to confirm that it's acceptable to have a warning for all rk817s that do not use the codec about a missing codec. The hardware is always present, I just can't say for certain it will always be used.

Quoted 1 line

What is the dmesg warning you receive?

It appears I was confused, I will update the code. No warning is received when I take away the ifdef guard. However, if I build the codec and don't include a devicetree node for it I get the following lines in dmesg:

Quoted 8 lines

rk817-codec rk817-codec: rk817_codec_parse_dt_property() Can not get child: codec rk817-codec rk817-codec: rk817_platform_probe() parse device tree property error -19

So it looks like this ifdef was meant to "fix" a problem that it doesn't even fix. I'll get rid of it and resubmit. To that end, do you think these messages above are okay, or should we try to fix them in the edge case of a user with an rk817 who doesn't use the codec but still has the codec driver compiled?

The general case is always having most stuff enabled (as modules) think distro-kernels. So having the codec available but a board not using it should not result in error messages confusing the user ;-) .

I don't think the rk817-codec will be the first mfd to stumble upon this, so I guess just looking through others might provide the solution on how to resolve this "silently" ;-)

Heiko

#7 lore raw

Re: [PATCH v9 1/4] mfd: Add Rockchip rk817 audio CODEC support

Quoted 125 lines · Heiko Stuebner

Hi Chris,

Am Freitag, 14. Mai 2021, 17:50:08 CEST schrieb Chris Morgan:

Quoted 109 lines · Lee Jones
Quoted 101 lines · Chris Morgan
Quoted 92 lines · Lee Jones
Quoted 10 lines · Chris Morgan
Quoted 7 lines

From: Chris Morgan <[email protected]>

Add rk817 codec support cell to rk808 mfd driver.

Nit: These should be chronological.

Acknowledged. I will make sure to do this if a v10 is necessary.

Quoted 73 lines
Quoted 62 lines

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 drivers/mfd/rk808.c       | 85 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/rk808.h | 81 +++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
drivers/mfd/rk808.c +1 -0
index ad923dd4e007..9231209184e0 100644
@@ -65,6 +65,7 @@ static bool rk817_is_volatile_reg(struct device *dev, unsigned int reg)
 	switch (reg) {
 	case RK817_SECONDS_REG ... RK817_WEEKS_REG:
 	case RK817_RTC_STATUS_REG:
+	case RK817_CODEC_DTOP_LPT_SRST:
 	case RK817_INT_STS_REG0:
 	case RK817_INT_STS_REG1:
 	case RK817_INT_STS_REG2:

drivers/mfd/rk808.c static const struct mfd_cell rk817s[] = { · line 171

Quoted 8 lines
drivers/mfd/rk808.c +5 -0
@@ -163,6 +164,11 @@ static const struct mfd_cell rk817s[] = {
 		.num_resources = ARRAY_SIZE(rk817_rtc_resources),
 		.resources = &rk817_rtc_resources[0],
 	},
+#ifdef CONFIG_SND_SOC_RK817
+	{
+		.name = "rk817-codec",
+	},
+#endif

No #ifery please.

Quoted 3 lines

Just replace it with a comment.

If no associated driver exists, it just won't match/bind.

Quoted 7 lines

I did the "if" here because I noticed that if I have a rk817 and do not utilize the codec I receive a dmesg warning. I put the if here to silence it in the event that someone was using this PMIC but didn't want to use the audio codec. I will make the change if you say so though, but I just want to confirm that it's acceptable to have a warning for all rk817s that do not use the codec about a missing codec. The hardware is always present, I just can't say for certain it will always be used.

Quoted 1 line

What is the dmesg warning you receive?

It appears I was confused, I will update the code. No warning is received when I take away the ifdef guard. However, if I build the codec and don't include a devicetree node for it I get the following lines in dmesg:

Quoted 8 lines

rk817-codec rk817-codec: rk817_codec_parse_dt_property() Can not get child: codec rk817-codec rk817-codec: rk817_platform_probe() parse device tree property error -19

So it looks like this ifdef was meant to "fix" a problem that it doesn't even fix. I'll get rid of it and resubmit. To that end, do you think these messages above are okay, or should we try to fix them in the edge case of a user with an rk817 who doesn't use the codec but still has the codec driver compiled?

The general case is always having most stuff enabled (as modules) think distro-kernels. So having the codec available but a board not using it should not result in error messages confusing the user ;-) .

Quoted 11 lines

I don't think the rk817-codec will be the first mfd to stumble upon this, so I guess just looking through others might provide the solution on how to resolve this "silently" ;-)

Heiko

I'm just going to change the message to a dev_dbg, since it's coming from the codec driver anyway. That way if you purposefully aren't using the codec the messages shouldn't appear in the dmesg log, however if you're troubleshooting a problem that exists because of a missing or invalid entry and enable debug messages you'll see this error. Again, I expect this to be an edge case where a user has an rk817 but purposefully doesn't want to use the codec hardware that's on 100% of all rk817s.

Thank you.

#8 lore raw

PATCH v9 2/4 ASoC: Add Rockchip rk817 audio CODEC support

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add support for the Rockchip rk817 audio codec integrated into the rk817 PMIC. This is based on the sources provided by Rockchip from their BSP kernel.

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 sound/soc/codecs/Kconfig       |   6 +
 sound/soc/codecs/Makefile      |   2 +
 sound/soc/codecs/rk817_codec.c | 558 +++++++++++++++++++++++++++++++++
 3 files changed, 566 insertions(+)
 create mode 100644 sound/soc/codecs/rk817_codec.c
sound/soc/codecs/Kconfig +6 -0
index 2a7b3e363069..4fbd404566c5 100644
@@ -155,6 +155,7 @@ config SND_SOC_ALL_CODECS
 	imply SND_SOC_PCM512x_I2C
 	imply SND_SOC_PCM512x_SPI
 	imply SND_SOC_RK3328
+	imply SND_SOC_RK817
 	imply SND_SOC_RT274
 	imply SND_SOC_RT286
 	imply SND_SOC_RT298
@@ -1063,6 +1064,11 @@ config SND_SOC_RK3328
 	tristate "Rockchip RK3328 audio CODEC"
 	select REGMAP_MMIO
 
+config SND_SOC_RK817
+	tristate "Rockchip RK817 audio CODEC"
+	depends on MFD_RK808
+	select REGMAP_I2C
+
 config SND_SOC_RL6231
 	tristate
 	default y if SND_SOC_RT5514=y
sound/soc/codecs/Makefile +2 -0
index 0efdba609048..d4a75ba43c18 100644
@@ -166,6 +166,7 @@ snd-soc-pcm512x-objs := pcm512x.o
 snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o
 snd-soc-pcm512x-spi-objs := pcm512x-spi.o
 snd-soc-rk3328-objs := rk3328_codec.o
+snd-soc-rk817-objs := rk817_codec.o
 snd-soc-rl6231-objs := rl6231.o
 snd-soc-rl6347a-objs := rl6347a.o
 snd-soc-rt1011-objs := rt1011.o
@@ -487,6 +488,7 @@ obj-$(CONFIG_SND_SOC_PCM512x)	+= snd-soc-pcm512x.o
 obj-$(CONFIG_SND_SOC_PCM512x_I2C)	+= snd-soc-pcm512x-i2c.o
 obj-$(CONFIG_SND_SOC_PCM512x_SPI)	+= snd-soc-pcm512x-spi.o
 obj-$(CONFIG_SND_SOC_RK3328)	+= snd-soc-rk3328.o
+obj-$(CONFIG_SND_SOC_RK817)	+= snd-soc-rk817.o
 obj-$(CONFIG_SND_SOC_RL6231)	+= snd-soc-rl6231.o
 obj-$(CONFIG_SND_SOC_RL6347A)	+= snd-soc-rl6347a.o
 obj-$(CONFIG_SND_SOC_RT1011)	+= snd-soc-rt1011.o
sound/soc/codecs/rk817_codec.c new file +558 -0

558 lines not on this page · raw message

Signature · 1 line
2.25.1
#9 lore raw

PATCH v9 3/4 dt-bindings: Add Rockchip rk817 audio CODEC support

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Create dt-binding documentation to document rk817 codec. New property name of rockchip,mic-in-differential added to control if the microphone is in differential mode or not.

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 .../devicetree/bindings/mfd/rk808.txt         | 186 ++++++++++++++++++
 1 file changed, 186 insertions(+)
Documentation/devicetree/bindings/mfd/rk808.txt +186 -0
index 04df07f6f793..56121039154f 100644
@@ -23,6 +23,7 @@ Optional properties:
   default output clock name
 - rockchip,system-power-controller: Telling whether or not this pmic is controlling
   the system power.
+- wakeup-source: Device can be used as a wakeup source.
 
 Optional RK805 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
@@ -63,8 +64,16 @@ Optional RK809 properties:
 - vcc9-supply:  The input supply for DCDC_REG5, SWITCH_REG2
 
 Optional RK817 properties:
+- clocks:	The input clock for the audio codec
+- clock-names:	The clock name for the codec clock. Should be "mclk".
+- #sound-dai-cells: Needed for the interpretation of sound dais. Should be 0.
+
 - vcc8-supply:  The input supply for BOOST
 - vcc9-supply:  The input supply for OTG_SWITCH
+- codec:	The child node for the codec to hold additional properties.
+
+- rockchip,mic-in-differential: Telling if the microphone uses differential
+				mode. Should be under the codec child node.
 
 Optional RK818 properties:
 - vcc1-supply:  The input supply for DCDC_REG1
@@ -275,3 +284,180 @@ Example:
 			};
 		};
 	};
+
+	rk817: pmic@20 {
+		compatible = "rockchip,rk817";
+		reg = <0x20>;
+		interrupt-parent = <&gpio0>;
+		interrupts = <RK_PB2 IRQ_TYPE_LEVEL_LOW>;
+		clock-output-names = "rk808-clkout1", "xin32k";
+		clock-names = "mclk";
+		clocks = <&cru SCLK_I2S1_OUT>;
+		pinctrl-names = "default";
+		pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>;
+		wakeup-source;
+		#clock-cells = <1>;
+		#sound-dai-cells = <0>;
+
+		vcc1-supply = <&vccsys>;
+		vcc2-supply = <&vccsys>;
+		vcc3-supply = <&vccsys>;
+		vcc4-supply = <&vccsys>;
+		vcc5-supply = <&vccsys>;
+		vcc6-supply = <&vccsys>;
+		vcc7-supply = <&vccsys>;
+
+		regulators {
+			vdd_logic: DCDC_REG1 {
+				regulator-name = "vdd_logic";
+				regulator-min-microvolt = <950000>;
+				regulator-max-microvolt = <1150000>;
+				regulator-ramp-delay = <6001>;
+				regulator-always-on;
+				regulator-boot-on;
+
+				regulator-state-mem {
+					regulator-on-in-suspend;
+					regulator-suspend-microvolt = <950000>;
+				};
+			};
+
+			vdd_arm: DCDC_REG2 {
+				regulator-name = "vdd_arm";
+				regulator-min-microvolt = <950000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-ramp-delay = <6001>;
+				regulator-always-on;
+				regulator-boot-on;
+
+				regulator-state-mem {
+					regulator-off-in-suspend;
+					regulator-suspend-microvolt = <950000>;
+				};
+			};
+
+			vcc_ddr: DCDC_REG3 {
+				regulator-name = "vcc_ddr";
+				regulator-always-on;
+				regulator-boot-on;
+
+				regulator-state-mem {
+					regulator-on-in-suspend;
+				};
+			};
+
+			vcc_3v3: DCDC_REG4 {
+				regulator-name = "vcc_3v3";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-always-on;
+				regulator-boot-on;
+
+				regulator-state-mem {
+					regulator-off-in-suspend;
+					regulator-suspend-microvolt = <3300000>;
+				};
+			};
+
+			vcc_1v8: LDO_REG2 {
+				regulator-name = "vcc_1v8";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				regulator-always-on;
+				regulator-boot-on;
+
+				regulator-state-mem {
+					regulator-on-in-suspend;
+					regulator-suspend-microvolt = <1800000>;
+				};
+			};
+
+			vdd_1v0: LDO_REG3 {
+				regulator-name = "vdd_1v0";
+				regulator-min-microvolt = <1000000>;
+				regulator-max-microvolt = <1000000>;
+				regulator-always-on;
+				regulator-boot-on;
+
+				regulator-state-mem {
+					regulator-on-in-suspend;
+					regulator-suspend-microvolt = <1000000>;
+				};
+			};
+
+			vcc3v3_pmu: LDO_REG4 {
+				regulator-name = "vcc3v3_pmu";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-always-on;
+				regulator-boot-on;
+
+				regulator-state-mem {
+					regulator-on-in-suspend;
+					regulator-suspend-microvolt = <3300000>;
+				};
+			};
+
+			vccio_sd: LDO_REG5 {
+				regulator-name = "vccio_sd";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-always-on;
+				regulator-boot-on;
+
+				regulator-state-mem {
+					regulator-on-in-suspend;
+					regulator-suspend-microvolt = <3300000>;
+				};
+			};
+
+			vcc_sd: LDO_REG6 {
+				regulator-name = "vcc_sd";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-boot-on;
+
+				regulator-state-mem {
+					regulator-on-in-suspend;
+					regulator-suspend-microvolt = <3300000>;
+				};
+			};
+
+			vcc_bl: LDO_REG7 {
+				regulator-name = "vcc_bl";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+
+				regulator-state-mem {
+					regulator-off-in-suspend;
+					regulator-suspend-microvolt = <3300000>;
+				};
+			};
+
+			vcc_lcd: LDO_REG8 {
+				regulator-name = "vcc_lcd";
+				regulator-min-microvolt = <2800000>;
+				regulator-max-microvolt = <2800000>;
+
+				regulator-state-mem {
+					regulator-off-in-suspend;
+					regulator-suspend-microvolt = <2800000>;
+				};
+			};
+
+			vcc_cam: LDO_REG9 {
+				regulator-name = "vcc_cam";
+				regulator-min-microvolt = <3000000>;
+				regulator-max-microvolt = <3000000>;
+
+				regulator-state-mem {
+					regulator-off-in-suspend;
+					regulator-suspend-microvolt = <3000000>;
+				};
+			};
+		};
+
+		rk817_codec: codec {
+			rockchip,mic-in-differential;
+		};
+	};
Signature · 1 line
2.25.1
#10 lore raw

PATCH v9 4/4 arm64: dts: rockchip: add rk817 codec to Odroid Go

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add the new rk817 codec driver to the Odroid Go Advance.

---
Changes in v9:
- Add cover letter.
- Remove documentation for interrupt parent per Rob Herring's request.
- Remove unused MODULE_DEVICE_TABLE to fix a bug identified by kernel test robot.
Changes in v8:
- Added additional documentation for missing properties of #sound-dai-cells, interrupt-parent, and wakeup-source for mfd documentation.
- Corrected order of elements descriptions in device tree documentation.
- Changed name of "mic-in-differential" to "rockchip,mic-in-differential".
- Changed name of sound card from "rockchip,rk817-codec" to "Analog".
- Removed unused resets and reset-names from the i2s1_2ch node.
Changes in v7:
- Removed ifdef around register definitions for MFD.
- Replaced codec documentation with updates to MFD documentation.
- Reordered elements in example to comply with upstream rules.
- Added binding update back for Odroid Go Advance as requested.
- Submitting patches from gmail now.
Changes in v6:
- Included additional project maintainers for correct subsystems.
- Removed unneeded compatible from DT documentation.
- Removed binding update for Odroid Go Advance (will do in seperate series).
Changes in v5:
- Move register definitions from rk817_codec.h to main rk808.h register definitions.
- Add volatile register for codec bits.
- Add default values for codec bits.
- Removed of_compatible from mtd driver (not necessary).
- Switched to using parent regmap instead of private regmap for codec.
Changes in v4:
- Created set_pll() call.
- Created user visible gain control in mic.
- Check for return value of clk_prepare_enable().
- Removed duplicate clk_prepare_enable().
- Split DT documentation to separate commit.
Changes in v3:
- Use DAPM macros to set audio path.
- Updated devicetree binding (as every rk817 has this codec chip).
- Changed documentation to yaml format.
- Split MFD changes to separate commit.
Changes in v2:
- Fixed audio path registers to solve some bugs.

 .../boot/dts/rockchip/rk3326-odroid-go2.dts   | 36 +++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts +34 -2
index 49c97f76df77..e8c2b5a817a7 100644
@@ -165,6 +165,31 @@ blue_led: led-0 {
 		};
 	};
 
+	rk817-sound {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "Analog";
+		simple-audio-card,format = "i2s";
+		simple-audio-card,mclk-fs = <256>;
+		simple-audio-card,widgets =
+			"Microphone", "Mic Jack",
+			"Headphone", "Headphones",
+			"Speaker", "Speaker";
+		simple-audio-card,routing =
+			"MICL", "Mic Jack",
+			"Headphones", "HPOL",
+			"Headphones", "HPOR",
+			"Speaker", "SPKO";
+		simple-audio-card,hp-det-gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>;
+
+		simple-audio-card,cpu {
+			sound-dai = <&i2s1_2ch>;
+		};
+
+		simple-audio-card,codec {
+			sound-dai = <&rk817>;
+		};
+	};
+
 	vccsys: vccsys {
 		compatible = "regulator-fixed";
 		regulator-name = "vcc3v8_sys";
@@ -269,11 +294,14 @@ rk817: pmic@20 {
 		reg = <0x20>;
 		interrupt-parent = <&gpio0>;
 		interrupts = <RK_PB2 IRQ_TYPE_LEVEL_LOW>;
+		clock-output-names = "rk808-clkout1", "xin32k";
+		clock-names = "mclk";
+		clocks = <&cru SCLK_I2S1_OUT>;
 		pinctrl-names = "default";
-		pinctrl-0 = <&pmic_int>;
+		pinctrl-0 = <&pmic_int>, <&i2s1_2ch_mclk>;
 		wakeup-source;
 		#clock-cells = <1>;
-		clock-output-names = "rk808-clkout1", "xin32k";
+		#sound-dai-cells = <0>;
 
 		vcc1-supply = <&vccsys>;
 		vcc2-supply = <&vccsys>;
@@ -432,6 +460,10 @@ regulator-state-mem {
 				};
 			};
 		};
+
+		rk817_codec: codec {
+			rockchip,mic-in-differential;
+		};
 	};
 };
 
Signature · 1 line
2.25.1