ASoC: da7219: read fmw property to get mclk for non-dts systems
diff mbox

Message ID 1525071715-17796-1-git-send-email-akshu.agrawal@amd.com
State New
Headers show

Commit Message

Agrawal, Akshu April 30, 2018, 7:01 a.m. UTC
Non-dts based systems can use ACPI DSDT to pass on the mclk
to da7219.
This enables da7219 mclk to be linked to system clock.
Enable/Disable of the mclk is already handled in the codec so
platform drivers don't have to explicitly do handling of mclk.

Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
---
 include/sound/da7219.h    | 2 ++
 sound/soc/codecs/da7219.c | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

kbuild test robot April 30, 2018, 9:28 a.m. UTC | #1
Hi Akshu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v4.17-rc3 next-20180426]
[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-da7219-read-fmw-property-to-get-mclk-for-non-dts-systems/20180430-150614
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: i386-randconfig-x015-201817 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   sound/soc/codecs/da7219.c: In function 'da7219_probe':
>> sound/soc/codecs/da7219.c:1913:31: error: 'codec' undeclared (first use in this function); did you mean 'node'?
      da7219->mclk = devm_clk_get(codec->dev, "mclk");
                                  ^~~~~
                                  node
   sound/soc/codecs/da7219.c:1913:31: note: each undeclared identifier is reported only once for each function it appears in

vim +1913 sound/soc/codecs/da7219.c

  1867	
  1868	static int da7219_probe(struct snd_soc_component *component)
  1869	{
  1870		struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
  1871		unsigned int rev;
  1872		int ret;
  1873	
  1874		mutex_init(&da7219->ctrl_lock);
  1875		mutex_init(&da7219->pll_lock);
  1876	
  1877		/* Regulator configuration */
  1878		ret = da7219_handle_supplies(component);
  1879		if (ret)
  1880			return ret;
  1881	
  1882		ret = regmap_read(da7219->regmap, DA7219_CHIP_REVISION, &rev);
  1883		if (ret) {
  1884			dev_err(component->dev, "Failed to read chip revision: %d\n", ret);
  1885			goto err_disable_reg;
  1886		}
  1887	
  1888		switch (rev & DA7219_CHIP_MINOR_MASK) {
  1889		case 0:
  1890			ret = regmap_register_patch(da7219->regmap, da7219_rev_aa_patch,
  1891						    ARRAY_SIZE(da7219_rev_aa_patch));
  1892			if (ret) {
  1893				dev_err(component->dev, "Failed to register AA patch: %d\n",
  1894					ret);
  1895				goto err_disable_reg;
  1896			}
  1897			break;
  1898		default:
  1899			break;
  1900		}
  1901	
  1902		/* Handle DT/ACPI/Platform data */
  1903		da7219->pdata = dev_get_platdata(component->dev);
  1904		if (!da7219->pdata)
  1905			da7219->pdata = da7219_fw_to_pdata(component);
  1906	
  1907		da7219_handle_pdata(component);
  1908	
  1909		/* Check if MCLK provided */
  1910		if (da7219->pdata->mclk_name)
  1911			da7219->mclk = clk_get(NULL, da7219->pdata->mclk_name);
  1912		if (!da7219->mclk)
> 1913			da7219->mclk = devm_clk_get(codec->dev, "mclk");
  1914		if (IS_ERR(da7219->mclk)) {
  1915			if (PTR_ERR(da7219->mclk) != -ENOENT) {
  1916				ret = PTR_ERR(da7219->mclk);
  1917				goto err_disable_reg;
  1918			} else {
  1919				da7219->mclk = NULL;
  1920			}
  1921		}
  1922	
  1923		/* Default PC counter to free-running */
  1924		snd_soc_component_update_bits(component, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK,
  1925				    DA7219_PC_FREERUN_MASK);
  1926	
  1927		/* Default gain ramping */
  1928		snd_soc_component_update_bits(component, DA7219_MIXIN_L_CTRL,
  1929				    DA7219_MIXIN_L_AMP_RAMP_EN_MASK,
  1930				    DA7219_MIXIN_L_AMP_RAMP_EN_MASK);
  1931		snd_soc_component_update_bits(component, DA7219_ADC_L_CTRL, DA7219_ADC_L_RAMP_EN_MASK,
  1932				    DA7219_ADC_L_RAMP_EN_MASK);
  1933		snd_soc_component_update_bits(component, DA7219_DAC_L_CTRL, DA7219_DAC_L_RAMP_EN_MASK,
  1934				    DA7219_DAC_L_RAMP_EN_MASK);
  1935		snd_soc_component_update_bits(component, DA7219_DAC_R_CTRL, DA7219_DAC_R_RAMP_EN_MASK,
  1936				    DA7219_DAC_R_RAMP_EN_MASK);
  1937		snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
  1938				    DA7219_HP_L_AMP_RAMP_EN_MASK,
  1939				    DA7219_HP_L_AMP_RAMP_EN_MASK);
  1940		snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
  1941				    DA7219_HP_R_AMP_RAMP_EN_MASK,
  1942				    DA7219_HP_R_AMP_RAMP_EN_MASK);
  1943	
  1944		/* Default minimum gain on HP to avoid pops during DAPM sequencing */
  1945		snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
  1946				    DA7219_HP_L_AMP_MIN_GAIN_EN_MASK,
  1947				    DA7219_HP_L_AMP_MIN_GAIN_EN_MASK);
  1948		snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
  1949				    DA7219_HP_R_AMP_MIN_GAIN_EN_MASK,
  1950				    DA7219_HP_R_AMP_MIN_GAIN_EN_MASK);
  1951	
  1952		/* Default infinite tone gen, start/stop by Kcontrol */
  1953		snd_soc_component_write(component, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK);
  1954	
  1955		/* Initialise AAD block */
  1956		ret = da7219_aad_init(component);
  1957		if (ret)
  1958			goto err_disable_reg;
  1959	
  1960		return 0;
  1961	
  1962	err_disable_reg:
  1963		regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies);
  1964	
  1965		return ret;
  1966	}
  1967	

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

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v4.17-rc3 next-20180426]
[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-da7219-read-fmw-property-to-get-mclk-for-non-dts-systems/20180430-150614
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 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=xtensa 

All errors (new ones prefixed by >>):

   sound/soc/codecs/da7219.c: In function 'da7219_probe':
>> sound/soc/codecs/da7219.c:1913:31: error: 'codec' undeclared (first use in this function); did you mean 'cdev'?
      da7219->mclk = devm_clk_get(codec->dev, "mclk");
                                  ^~~~~
                                  cdev
   sound/soc/codecs/da7219.c:1913:31: note: each undeclared identifier is reported only once for each function it appears in

vim +1913 sound/soc/codecs/da7219.c

  1867	
  1868	static int da7219_probe(struct snd_soc_component *component)
  1869	{
  1870		struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
  1871		unsigned int rev;
  1872		int ret;
  1873	
  1874		mutex_init(&da7219->ctrl_lock);
  1875		mutex_init(&da7219->pll_lock);
  1876	
  1877		/* Regulator configuration */
  1878		ret = da7219_handle_supplies(component);
  1879		if (ret)
  1880			return ret;
  1881	
  1882		ret = regmap_read(da7219->regmap, DA7219_CHIP_REVISION, &rev);
  1883		if (ret) {
  1884			dev_err(component->dev, "Failed to read chip revision: %d\n", ret);
  1885			goto err_disable_reg;
  1886		}
  1887	
  1888		switch (rev & DA7219_CHIP_MINOR_MASK) {
  1889		case 0:
  1890			ret = regmap_register_patch(da7219->regmap, da7219_rev_aa_patch,
  1891						    ARRAY_SIZE(da7219_rev_aa_patch));
  1892			if (ret) {
  1893				dev_err(component->dev, "Failed to register AA patch: %d\n",
  1894					ret);
  1895				goto err_disable_reg;
  1896			}
  1897			break;
  1898		default:
  1899			break;
  1900		}
  1901	
  1902		/* Handle DT/ACPI/Platform data */
  1903		da7219->pdata = dev_get_platdata(component->dev);
  1904		if (!da7219->pdata)
  1905			da7219->pdata = da7219_fw_to_pdata(component);
  1906	
  1907		da7219_handle_pdata(component);
  1908	
  1909		/* Check if MCLK provided */
  1910		if (da7219->pdata->mclk_name)
  1911			da7219->mclk = clk_get(NULL, da7219->pdata->mclk_name);
  1912		if (!da7219->mclk)
> 1913			da7219->mclk = devm_clk_get(codec->dev, "mclk");
  1914		if (IS_ERR(da7219->mclk)) {
  1915			if (PTR_ERR(da7219->mclk) != -ENOENT) {
  1916				ret = PTR_ERR(da7219->mclk);
  1917				goto err_disable_reg;
  1918			} else {
  1919				da7219->mclk = NULL;
  1920			}
  1921		}
  1922	
  1923		/* Default PC counter to free-running */
  1924		snd_soc_component_update_bits(component, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK,
  1925				    DA7219_PC_FREERUN_MASK);
  1926	
  1927		/* Default gain ramping */
  1928		snd_soc_component_update_bits(component, DA7219_MIXIN_L_CTRL,
  1929				    DA7219_MIXIN_L_AMP_RAMP_EN_MASK,
  1930				    DA7219_MIXIN_L_AMP_RAMP_EN_MASK);
  1931		snd_soc_component_update_bits(component, DA7219_ADC_L_CTRL, DA7219_ADC_L_RAMP_EN_MASK,
  1932				    DA7219_ADC_L_RAMP_EN_MASK);
  1933		snd_soc_component_update_bits(component, DA7219_DAC_L_CTRL, DA7219_DAC_L_RAMP_EN_MASK,
  1934				    DA7219_DAC_L_RAMP_EN_MASK);
  1935		snd_soc_component_update_bits(component, DA7219_DAC_R_CTRL, DA7219_DAC_R_RAMP_EN_MASK,
  1936				    DA7219_DAC_R_RAMP_EN_MASK);
  1937		snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
  1938				    DA7219_HP_L_AMP_RAMP_EN_MASK,
  1939				    DA7219_HP_L_AMP_RAMP_EN_MASK);
  1940		snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
  1941				    DA7219_HP_R_AMP_RAMP_EN_MASK,
  1942				    DA7219_HP_R_AMP_RAMP_EN_MASK);
  1943	
  1944		/* Default minimum gain on HP to avoid pops during DAPM sequencing */
  1945		snd_soc_component_update_bits(component, DA7219_HP_L_CTRL,
  1946				    DA7219_HP_L_AMP_MIN_GAIN_EN_MASK,
  1947				    DA7219_HP_L_AMP_MIN_GAIN_EN_MASK);
  1948		snd_soc_component_update_bits(component, DA7219_HP_R_CTRL,
  1949				    DA7219_HP_R_AMP_MIN_GAIN_EN_MASK,
  1950				    DA7219_HP_R_AMP_MIN_GAIN_EN_MASK);
  1951	
  1952		/* Default infinite tone gen, start/stop by Kcontrol */
  1953		snd_soc_component_write(component, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK);
  1954	
  1955		/* Initialise AAD block */
  1956		ret = da7219_aad_init(component);
  1957		if (ret)
  1958			goto err_disable_reg;
  1959	
  1960		return 0;
  1961	
  1962	err_disable_reg:
  1963		regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies);
  1964	
  1965		return ret;
  1966	}
  1967	

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

Patch
diff mbox

diff --git a/include/sound/da7219.h b/include/sound/da7219.h
index 1bfcb16..df7ddf4 100644
--- a/include/sound/da7219.h
+++ b/include/sound/da7219.h
@@ -38,6 +38,8 @@  struct da7219_pdata {
 
 	const char *dai_clks_name;
 
+	const char *mclk_name;
+
 	/* Mic */
 	enum da7219_micbias_voltage micbias_lvl;
 	enum da7219_mic_amp_in_sel mic_amp_in_sel;
diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
index 980a6a8..47ffb35 100644
--- a/sound/soc/codecs/da7219.c
+++ b/sound/soc/codecs/da7219.c
@@ -1624,6 +1624,8 @@  static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *compone
 		dev_warn(dev, "Using default clk name: %s\n",
 			 pdata->dai_clks_name);
 
+	device_property_read_string(dev, "dlg,mclk-name", &pdata->mclk_name);
+
 	if (device_property_read_u32(dev, "dlg,micbias-lvl", &of_val32) >= 0)
 		pdata->micbias_lvl = da7219_fw_micbias_lvl(dev, of_val32);
 	else
@@ -1905,7 +1907,10 @@  static int da7219_probe(struct snd_soc_component *component)
 	da7219_handle_pdata(component);
 
 	/* Check if MCLK provided */
-	da7219->mclk = devm_clk_get(component->dev, "mclk");
+	if (da7219->pdata->mclk_name)
+		da7219->mclk = clk_get(NULL, da7219->pdata->mclk_name);
+	if (!da7219->mclk)
+		da7219->mclk = devm_clk_get(codec->dev, "mclk");
 	if (IS_ERR(da7219->mclk)) {
 		if (PTR_ERR(da7219->mclk) != -ENOENT) {
 			ret = PTR_ERR(da7219->mclk);