mbox series

[v9,0/4] ASoC: codecs: add rk817 support

Message ID 20210505140854.15929-1-macroalpha82@gmail.com
Headers show
Series ASoC: codecs: add rk817 support | expand

Message

Chris Morgan May 5, 2021, 2:08 p.m. UTC
From: Chris Morgan <macromorgan@hotmail.com>

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

Comments

Lee Jones May 10, 2021, 4:23 p.m. UTC | #1
On Wed, 05 May 2021, Chris Morgan wrote:

> From: Chris Morgan <macromorgan@hotmail.com>

> 

> Add rk817 codec support cell to rk808 mfd driver.

> 

> Tested-by: Maciej Matuszczyk <maccraft123mc@gmail.com>

> Signed-off-by: Chris Morgan <macromorgan@hotmail.com>


Nit: These should be chronological.

> ---

> 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(+)

> 

> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c

> index ad923dd4e007..9231209184e0 100644

> --- a/drivers/mfd/rk808.c

> +++ b/drivers/mfd/rk808.c

> @@ -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


No #ifery please.

Just replace it with a comment.

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

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
Chris Morgan May 13, 2021, 3:01 p.m. UTC | #2
On Mon, May 10, 2021 at 05:23:29PM +0100, Lee Jones wrote:
> On Wed, 05 May 2021, Chris Morgan wrote:

> 

> > From: Chris Morgan <macromorgan@hotmail.com>

> > 

> > Add rk817 codec support cell to rk808 mfd driver.

> > 

> > Tested-by: Maciej Matuszczyk <maccraft123mc@gmail.com>

> > Signed-off-by: Chris Morgan <macromorgan@hotmail.com>

> 

> Nit: These should be chronological.


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

> 

> > ---

> > 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(+)

> > 

> > diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c

> > index ad923dd4e007..9231209184e0 100644

> > --- a/drivers/mfd/rk808.c

> > +++ b/drivers/mfd/rk808.c

> > @@ -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

> 

> No #ifery please.

> 

> 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.

> 

> -- 

> Lee Jones [李琼斯]

> Senior Technical Lead - Developer Services

> Linaro.org │ Open source software for Arm SoCs

> Follow Linaro: Facebook | Twitter | Blog
Lee Jones May 13, 2021, 8:11 p.m. UTC | #3
On Thu, 13 May 2021, Chris Morgan wrote:

> On Mon, May 10, 2021 at 05:23:29PM +0100, Lee Jones wrote:

> > On Wed, 05 May 2021, Chris Morgan wrote:

> > 

> > > From: Chris Morgan <macromorgan@hotmail.com>

> > > 

> > > Add rk817 codec support cell to rk808 mfd driver.

> > > 

> > > Tested-by: Maciej Matuszczyk <maccraft123mc@gmail.com>

> > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com>

> > 

> > Nit: These should be chronological.

> 

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

> 

> > 

> > > ---

> > > 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(+)

> > > 

> > > diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c

> > > index ad923dd4e007..9231209184e0 100644

> > > --- a/drivers/mfd/rk808.c

> > > +++ b/drivers/mfd/rk808.c

> > > @@ -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

> > 

> > No #ifery please.

> > 

> > 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.


What is the dmesg warning you receive?

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
Chris Morgan May 14, 2021, 3:50 p.m. UTC | #4
On Thu, May 13, 2021 at 09:11:14PM +0100, Lee Jones wrote:
> On Thu, 13 May 2021, Chris Morgan wrote:

> 

> > On Mon, May 10, 2021 at 05:23:29PM +0100, Lee Jones wrote:

> > > On Wed, 05 May 2021, Chris Morgan wrote:

> > > 

> > > > From: Chris Morgan <macromorgan@hotmail.com>

> > > > 

> > > > Add rk817 codec support cell to rk808 mfd driver.

> > > > 

> > > > Tested-by: Maciej Matuszczyk <maccraft123mc@gmail.com>

> > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com>

> > > 

> > > Nit: These should be chronological.

> > 

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

> > 

> > > 

> > > > ---

> > > > 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(+)

> > > > 

> > > > diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c

> > > > index ad923dd4e007..9231209184e0 100644

> > > > --- a/drivers/mfd/rk808.c

> > > > +++ b/drivers/mfd/rk808.c

> > > > @@ -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

> > > 

> > > No #ifery please.

> > > 

> > > 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.

> 

> 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.

> 

> -- 

> Lee Jones [李琼斯]

> Senior Technical Lead - Developer Services

> Linaro.org │ Open source software for Arm SoCs

> Follow Linaro: Facebook | Twitter | Blog
Heiko Stübner May 14, 2021, 4:36 p.m. UTC | #5
Hi Chris,

Am Freitag, 14. Mai 2021, 17:50:08 CEST schrieb Chris Morgan:
> On Thu, May 13, 2021 at 09:11:14PM +0100, Lee Jones wrote:

> > On Thu, 13 May 2021, Chris Morgan wrote:

> > 

> > > On Mon, May 10, 2021 at 05:23:29PM +0100, Lee Jones wrote:

> > > > On Wed, 05 May 2021, Chris Morgan wrote:

> > > > 

> > > > > From: Chris Morgan <macromorgan@hotmail.com>

> > > > > 

> > > > > Add rk817 codec support cell to rk808 mfd driver.

> > > > > 

> > > > > Tested-by: Maciej Matuszczyk <maccraft123mc@gmail.com>

> > > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com>

> > > > 

> > > > Nit: These should be chronological.

> > > 

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

> > > 

> > > > 

> > > > > ---

> > > > > 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(+)

> > > > > 

> > > > > diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c

> > > > > index ad923dd4e007..9231209184e0 100644

> > > > > --- a/drivers/mfd/rk808.c

> > > > > +++ b/drivers/mfd/rk808.c

> > > > > @@ -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

> > > > 

> > > > No #ifery please.

> > > > 

> > > > 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.

> > 

> > 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?


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
Chris Morgan May 14, 2021, 4:59 p.m. UTC | #6
On Fri, May 14, 2021 at 06:36:47PM +0200, Heiko Stuebner wrote:
> Hi Chris,

> 

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

> > On Thu, May 13, 2021 at 09:11:14PM +0100, Lee Jones wrote:

> > > On Thu, 13 May 2021, Chris Morgan wrote:

> > > 

> > > > On Mon, May 10, 2021 at 05:23:29PM +0100, Lee Jones wrote:

> > > > > On Wed, 05 May 2021, Chris Morgan wrote:

> > > > > 

> > > > > > From: Chris Morgan <macromorgan@hotmail.com>

> > > > > > 

> > > > > > Add rk817 codec support cell to rk808 mfd driver.

> > > > > > 

> > > > > > Tested-by: Maciej Matuszczyk <maccraft123mc@gmail.com>

> > > > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com>

> > > > > 

> > > > > Nit: These should be chronological.

> > > > 

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

> > > > 

> > > > > 

> > > > > > ---

> > > > > > 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(+)

> > > > > > 

> > > > > > diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c

> > > > > > index ad923dd4e007..9231209184e0 100644

> > > > > > --- a/drivers/mfd/rk808.c

> > > > > > +++ b/drivers/mfd/rk808.c

> > > > > > @@ -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

> > > > > 

> > > > > No #ifery please.

> > > > > 

> > > > > 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.

> > > 

> > > 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?

> 

> 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

> 

> 

> 

> 

> 

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.