diff mbox

[2/2] ASoC: AMD: Enable da7219 master clock using common clock framework

Message ID 1520845883-24062-2-git-send-email-akshu.agrawal@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

Akshu Agrawal March 12, 2018, 9:11 a.m. UTC
DA7219 is clock master for other codecs. DA7219 has exposed clock
control by using common clock framework and same is used to enable
and disable clock for all codecs in the system.

TEST=Build, apply grunt_mixer_settings:
iotools mmio_write32 0xfed80e40 0x040c40c0
iotools mmio_write32 0xfed80e28 0x10000
aplay -D hw:0,0 -vv <file>
arecord -D hw:0,0 -f dat -d 5 -vv <file>
aplay -D hw:0,1 -vv <file>

Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
---
 sound/soc/amd/acp-da7219-max98357a.c | 41 ++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

Comments

kernel test robot March 13, 2018, 12:32 a.m. UTC | #1
Hi Akshu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20180309]
[cannot apply to v4.16-rc4 v4.16-rc3 v4.16-rc2 v4.16-rc5]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Akshu-Agrawal/ASoC-AMD-Use-single-dai-for-da7219-playback-and-capture/20180313-035239
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   sound/soc/amd/acp-da7219-max98357a.c: In function 'cz_da7219_init':
>> sound/soc/amd/acp-da7219-max98357a.c:70:19: error: implicit declaration of function 'clk_get'; did you mean 'key_get'? [-Werror=implicit-function-declaration]
     da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks");
                      ^~~~~~~
                      key_get
>> sound/soc/amd/acp-da7219-max98357a.c:70:27: error: 'codec' undeclared (first use in this function); did you mean 'cdev'?
     da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks");
                              ^~~~~
                              cdev
   sound/soc/amd/acp-da7219-max98357a.c:70:27: note: each undeclared identifier is reported only once for each function it appears in
   sound/soc/amd/acp-da7219-max98357a.c: In function 'cz_da7219_hw_params':
>> sound/soc/amd/acp-da7219-max98357a.c:93:8: error: implicit declaration of function 'clk_prepare_enable'; did you mean 'preempt_enable'? [-Werror=implicit-function-declaration]
     ret = clk_prepare_enable(da7219_dai_clk);
           ^~~~~~~~~~~~~~~~~~
           preempt_enable
   sound/soc/amd/acp-da7219-max98357a.c: In function 'cz_da7219_hw_free':
>> sound/soc/amd/acp-da7219-max98357a.c:106:2: error: implicit declaration of function 'clk_disable_unprepare'; did you mean 'acpi_disable_gpe'? [-Werror=implicit-function-declaration]
     clk_disable_unprepare(da7219_dai_clk);
     ^~~~~~~~~~~~~~~~~~~~~
     acpi_disable_gpe
   cc1: some warnings being treated as errors

vim +70 sound/soc/amd/acp-da7219-max98357a.c

    46	
    47	static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
    48	{
    49		int ret;
    50		struct snd_soc_card *card = rtd->card;
    51		struct snd_soc_dai *codec_dai = rtd->codec_dai;
    52		struct snd_soc_component *component = codec_dai->component;
    53	
    54		dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name);
    55	
    56		ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK,
    57					     CZ_PLAT_CLK, SND_SOC_CLOCK_IN);
    58		if (ret < 0) {
    59			dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret);
    60			return ret;
    61		}
    62	
    63		ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL,
    64					  CZ_PLAT_CLK, MCLK_RATE);
    65		if (ret < 0) {
    66			dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
    67			return ret;
    68		}
    69	
  > 70		da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks");
    71	
    72		ret = snd_soc_card_jack_new(card, "Headset Jack",
    73					SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
    74					SND_JACK_BTN_0 | SND_JACK_BTN_1 |
    75					SND_JACK_BTN_2 | SND_JACK_BTN_3,
    76					&cz_jack, NULL, 0);
    77		if (ret) {
    78			dev_err(card->dev, "HP jack creation failed %d\n", ret);
    79			return ret;
    80		}
    81	
    82		da7219_aad_jack_det(component, &cz_jack);
    83	
    84		return 0;
    85	}
    86	
    87	static int cz_da7219_hw_params(struct snd_pcm_substream *substream,
    88				     struct snd_pcm_hw_params *params)
    89	{
    90		int ret = 0;
    91		struct snd_soc_pcm_runtime *rtd = substream->private_data;
    92	
  > 93		ret = clk_prepare_enable(da7219_dai_clk);
    94		if (ret < 0) {
    95			dev_err(rtd->dev, "can't enable master clock %d\n", ret);
    96			return ret;
    97		}
    98	
    99		return ret;
   100	}
   101	
   102	static int cz_da7219_hw_free(struct snd_pcm_substream *substream)
   103	{
   104		int ret = 0;
   105	
 > 106		clk_disable_unprepare(da7219_dai_clk);
   107	
   108		return ret;
   109	}
   110	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot March 13, 2018, 4:37 a.m. UTC | #2
Hi Akshu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20180309]
[cannot apply to v4.16-rc4 v4.16-rc3 v4.16-rc2 v4.16-rc5]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Akshu-Agrawal/ASoC-AMD-Use-single-dai-for-da7219-playback-and-capture/20180313-035239
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   sound/soc/amd/acp-da7219-max98357a.c: In function 'cz_da7219_init':
   sound/soc/amd/acp-da7219-max98357a.c:70:19: error: implicit declaration of function 'clk_get'; did you mean 'key_get'? [-Werror=implicit-function-declaration]
     da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks");
                      ^~~~~~~
                      key_get
   sound/soc/amd/acp-da7219-max98357a.c:70:27: error: 'codec' undeclared (first use in this function); did you mean 'cdev'?
     da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks");
                              ^~~~~
                              cdev
   sound/soc/amd/acp-da7219-max98357a.c:70:27: note: each undeclared identifier is reported only once for each function it appears in
   sound/soc/amd/acp-da7219-max98357a.c: In function 'cz_da7219_hw_params':
>> sound/soc/amd/acp-da7219-max98357a.c:93:8: error: implicit declaration of function 'clk_prepare_enable'; did you mean 'acpi_pci_irq_enable'? [-Werror=implicit-function-declaration]
     ret = clk_prepare_enable(da7219_dai_clk);
           ^~~~~~~~~~~~~~~~~~
           acpi_pci_irq_enable
   sound/soc/amd/acp-da7219-max98357a.c: In function 'cz_da7219_hw_free':
   sound/soc/amd/acp-da7219-max98357a.c:106:2: error: implicit declaration of function 'clk_disable_unprepare'; did you mean 'acpi_disable_gpe'? [-Werror=implicit-function-declaration]
     clk_disable_unprepare(da7219_dai_clk);
     ^~~~~~~~~~~~~~~~~~~~~
     acpi_disable_gpe
   cc1: some warnings being treated as errors

coccinelle warnings: (new ones prefixed by >>)

>> sound/soc/amd/acp-da7219-max98357a.c:104:5-8: Unneeded variable: "ret". Return "0" on line 108

Please review and possibly fold the followup patch.

vim +93 sound/soc/amd/acp-da7219-max98357a.c

    46	
    47	static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
    48	{
    49		int ret;
    50		struct snd_soc_card *card = rtd->card;
    51		struct snd_soc_dai *codec_dai = rtd->codec_dai;
    52		struct snd_soc_component *component = codec_dai->component;
    53	
    54		dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name);
    55	
    56		ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK,
    57					     CZ_PLAT_CLK, SND_SOC_CLOCK_IN);
    58		if (ret < 0) {
    59			dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret);
    60			return ret;
    61		}
    62	
    63		ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL,
    64					  CZ_PLAT_CLK, MCLK_RATE);
    65		if (ret < 0) {
    66			dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
    67			return ret;
    68		}
    69	
  > 70		da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks");
    71	
    72		ret = snd_soc_card_jack_new(card, "Headset Jack",
    73					SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
    74					SND_JACK_BTN_0 | SND_JACK_BTN_1 |
    75					SND_JACK_BTN_2 | SND_JACK_BTN_3,
    76					&cz_jack, NULL, 0);
    77		if (ret) {
    78			dev_err(card->dev, "HP jack creation failed %d\n", ret);
    79			return ret;
    80		}
    81	
    82		da7219_aad_jack_det(component, &cz_jack);
    83	
    84		return 0;
    85	}
    86	
    87	static int cz_da7219_hw_params(struct snd_pcm_substream *substream,
    88				     struct snd_pcm_hw_params *params)
    89	{
    90		int ret = 0;
    91		struct snd_soc_pcm_runtime *rtd = substream->private_data;
    92	
  > 93		ret = clk_prepare_enable(da7219_dai_clk);
    94		if (ret < 0) {
    95			dev_err(rtd->dev, "can't enable master clock %d\n", ret);
    96			return ret;
    97		}
    98	
    99		return ret;
   100	}
   101	
   102	static int cz_da7219_hw_free(struct snd_pcm_substream *substream)
   103	{
 > 104		int ret = 0;
   105	
   106		clk_disable_unprepare(da7219_dai_clk);
   107	
 > 108		return ret;
   109	}
   110	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c
index d07c2a1..1441be3 100644
--- a/sound/soc/amd/acp-da7219-max98357a.c
+++ b/sound/soc/amd/acp-da7219-max98357a.c
@@ -42,6 +42,7 @@ 
 #define DUAL_CHANNEL		2
 
 static struct snd_soc_jack cz_jack;
+struct clk *da7219_dai_clk;
 
 static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
 {
@@ -66,6 +67,8 @@  static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
 		return ret;
 	}
 
+	da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks");
+
 	ret = snd_soc_card_jack_new(card, "Headset Jack",
 				SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |
 				SND_JACK_BTN_0 | SND_JACK_BTN_1 |
@@ -81,6 +84,30 @@  static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
 	return 0;
 }
 
+static int cz_da7219_hw_params(struct snd_pcm_substream *substream,
+			     struct snd_pcm_hw_params *params)
+{
+	int ret = 0;
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+
+	ret = clk_prepare_enable(da7219_dai_clk);
+	if (ret < 0) {
+		dev_err(rtd->dev, "can't enable master clock %d\n", ret);
+		return ret;
+	}
+
+	return ret;
+}
+
+static int cz_da7219_hw_free(struct snd_pcm_substream *substream)
+{
+	int ret = 0;
+
+	clk_disable_unprepare(da7219_dai_clk);
+
+	return ret;
+}
+
 static const unsigned int channels[] = {
 	DUAL_CHANNEL,
 };
@@ -119,9 +146,21 @@  static int cz_fe_startup(struct snd_pcm_substream *substream)
 }
 
 static struct snd_soc_ops cz_da7219_cap_ops = {
+	.hw_params = cz_da7219_hw_params,
+	.hw_free = cz_da7219_hw_free,
 	.startup = cz_fe_startup,
 };
 
+static struct snd_soc_ops cz_max_play_ops = {
+	.hw_params = cz_da7219_hw_params,
+	.hw_free = cz_da7219_hw_free,
+};
+
+static struct snd_soc_ops cz_dmic_cap_ops = {
+	.hw_params = cz_da7219_hw_params,
+	.hw_free = cz_da7219_hw_free,
+};
+
 static struct snd_soc_dai_link cz_dai_7219_98357[] = {
 	{
 		.name = "amd-da7219-play-cap",
@@ -147,6 +186,7 @@  static int cz_fe_startup(struct snd_pcm_substream *substream)
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 		.dpcm_playback = 1,
+		.ops = &cz_max_play_ops,
 	},
 	{
 		.name = "dmic",
@@ -158,6 +198,7 @@  static int cz_fe_startup(struct snd_pcm_substream *substream)
 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
 				| SND_SOC_DAIFMT_CBM_CFM,
 		.dpcm_capture = 1,
+		.ops = &cz_dmic_cap_ops,
 	},
 };