From: Jyri Sarha <jsarha@ti.com> To: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, bcousson@baylibre.com Cc: broonie@kernel.org, Jyri Sarha <jsarha@ti.com> Subject: [PATCH RFC v2 REPOST 2/8] ASoC: davinci-evm: Add named clock reference to DT bindings Date: Fri, 20 Dec 2013 12:38:27 +0200 [thread overview] Message-ID: <c1ae738c9b6cd9f2e595eed1f4981378ded46925.1387535302.git.jsarha@ti.com> (raw) In-Reply-To: <cover.1387535299.git.jsarha@ti.com> The referenced clock is used to get codec clock rate and the clock is disabled and enabled in startup and shutdown snd_soc_ops call backs. The change is also documented in DT bindigs document. Signed-off-by: Jyri Sarha <jsarha@ti.com> cc: bcousson@baylibre.com --- .../bindings/sound/davinci-evm-audio.txt | 9 ++- sound/soc/davinci/davinci-evm.c | 60 +++++++++++++++++++- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt index 865178d..4aa00f6 100644 --- a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt +++ b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt @@ -5,12 +5,19 @@ Required properties: - ti,model : The user-visible name of this sound complex. - ti,audio-codec : The phandle of the TLV320AIC3x audio codec - ti,mcasp-controller : The phandle of the McASP controller -- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec - ti,audio-routing : A list of the connections between audio components. Each entry is a pair of strings, the first being the connection's sink, the second being the connection's source. Valid names for sources and sinks are the codec's pins, and the jacks on the board: +Optional properties: +- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec. +- clocks : Reference to the clock used as codec clock +- clock-names : The codec clock should be named "ti,codec-clock" +- Either codec-clock-rate or the codec-clock reference has to be defined. If + the both are defined the driver attempts to set referenced clock to the + defined rate and takes the rate from the clock reference. + Board connectors: * Headphone Jack diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 70ff377..b28c9fd 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -17,6 +17,7 @@ #include <linux/platform_data/edma.h> #include <linux/i2c.h> #include <linux/of_platform.h> +#include <linux/clk.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/soc.h> @@ -30,9 +31,30 @@ #include "davinci-i2s.h" struct snd_soc_card_drvdata_davinci { + struct clk *mclk; unsigned sysclk; }; +static int evm_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *soc_card = rtd->codec->card; + struct clk *mclk = ((struct snd_soc_card_drvdata_davinci *) + snd_soc_card_get_drvdata(soc_card))->mclk; + + return clk_prepare_enable(mclk); +} + +static void evm_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *soc_card = rtd->codec->card; + struct clk *mclk = ((struct snd_soc_card_drvdata_davinci *) + snd_soc_card_get_drvdata(soc_card))->mclk; + + clk_disable_unprepare(mclk); +} + static int evm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -59,6 +81,8 @@ static int evm_hw_params(struct snd_pcm_substream *substream, } static struct snd_soc_ops evm_ops = { + .startup = evm_startup, + .shutdown = evm_shutdown, .hw_params = evm_hw_params, }; @@ -348,6 +372,7 @@ static int davinci_evm_probe(struct platform_device *pdev) of_match_device(of_match_ptr(davinci_evm_dt_ids), &pdev->dev); struct snd_soc_dai_link *dai = (struct snd_soc_dai_link *) match->data; struct snd_soc_card_drvdata_davinci *drvdata = NULL; + struct clk *mclk; int ret = 0; evm_soc_card.dai_link = dai; @@ -367,13 +392,38 @@ static int davinci_evm_probe(struct platform_device *pdev) if (ret) return ret; + mclk = of_clk_get_by_name(np, "ti,codec-clock"); + if (PTR_ERR(mclk) == -EPROBE_DEFER) { + return -EPROBE_DEFER; + } else if (IS_ERR(mclk)) { + dev_dbg(&pdev->dev, "Codec clock not found.\n"); + mclk = NULL; + } + drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; + drvdata->mclk = mclk; + ret = of_property_read_u32(np, "ti,codec-clock-rate", &drvdata->sysclk); - if (ret < 0) - return -EINVAL; + + if (ret < 0) { + if (!drvdata->mclk) { + dev_err(&pdev->dev, + "No clock or clock rate defined.\n"); + return -EINVAL; + } + drvdata->sysclk = clk_get_rate(drvdata->mclk); + } else if (drvdata->mclk) { + unsigned int requestd_rate = drvdata->sysclk; + clk_set_rate(drvdata->mclk, drvdata->sysclk); + drvdata->sysclk = clk_get_rate(drvdata->mclk); + if (drvdata->sysclk != requestd_rate) + dev_warn(&pdev->dev, + "Could not get requested rate %u using %u.\n", + requestd_rate, drvdata->sysclk); + } snd_soc_card_set_drvdata(&evm_soc_card, drvdata); ret = devm_snd_soc_register_card(&pdev->dev, &evm_soc_card); @@ -387,6 +437,12 @@ static int davinci_evm_probe(struct platform_device *pdev) static int davinci_evm_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); + struct snd_soc_card_drvdata_davinci *drvdata = + (struct snd_soc_card_drvdata_davinci *) + snd_soc_card_get_drvdata(card); + + if (drvdata->mclk) + clk_put(drvdata->mclk); snd_soc_unregister_card(card); -- 1.7.9.5
WARNING: multiple messages have this Message-ID (diff)
From: jsarha@ti.com (Jyri Sarha) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC v2 REPOST 2/8] ASoC: davinci-evm: Add named clock reference to DT bindings Date: Fri, 20 Dec 2013 12:38:27 +0200 [thread overview] Message-ID: <c1ae738c9b6cd9f2e595eed1f4981378ded46925.1387535302.git.jsarha@ti.com> (raw) In-Reply-To: <cover.1387535299.git.jsarha@ti.com> The referenced clock is used to get codec clock rate and the clock is disabled and enabled in startup and shutdown snd_soc_ops call backs. The change is also documented in DT bindigs document. Signed-off-by: Jyri Sarha <jsarha@ti.com> cc: bcousson at baylibre.com --- .../bindings/sound/davinci-evm-audio.txt | 9 ++- sound/soc/davinci/davinci-evm.c | 60 +++++++++++++++++++- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt index 865178d..4aa00f6 100644 --- a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt +++ b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt @@ -5,12 +5,19 @@ Required properties: - ti,model : The user-visible name of this sound complex. - ti,audio-codec : The phandle of the TLV320AIC3x audio codec - ti,mcasp-controller : The phandle of the McASP controller -- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec - ti,audio-routing : A list of the connections between audio components. Each entry is a pair of strings, the first being the connection's sink, the second being the connection's source. Valid names for sources and sinks are the codec's pins, and the jacks on the board: +Optional properties: +- ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec. +- clocks : Reference to the clock used as codec clock +- clock-names : The codec clock should be named "ti,codec-clock" +- Either codec-clock-rate or the codec-clock reference has to be defined. If + the both are defined the driver attempts to set referenced clock to the + defined rate and takes the rate from the clock reference. + Board connectors: * Headphone Jack diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index 70ff377..b28c9fd 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c @@ -17,6 +17,7 @@ #include <linux/platform_data/edma.h> #include <linux/i2c.h> #include <linux/of_platform.h> +#include <linux/clk.h> #include <sound/core.h> #include <sound/pcm.h> #include <sound/soc.h> @@ -30,9 +31,30 @@ #include "davinci-i2s.h" struct snd_soc_card_drvdata_davinci { + struct clk *mclk; unsigned sysclk; }; +static int evm_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *soc_card = rtd->codec->card; + struct clk *mclk = ((struct snd_soc_card_drvdata_davinci *) + snd_soc_card_get_drvdata(soc_card))->mclk; + + return clk_prepare_enable(mclk); +} + +static void evm_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *soc_card = rtd->codec->card; + struct clk *mclk = ((struct snd_soc_card_drvdata_davinci *) + snd_soc_card_get_drvdata(soc_card))->mclk; + + clk_disable_unprepare(mclk); +} + static int evm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { @@ -59,6 +81,8 @@ static int evm_hw_params(struct snd_pcm_substream *substream, } static struct snd_soc_ops evm_ops = { + .startup = evm_startup, + .shutdown = evm_shutdown, .hw_params = evm_hw_params, }; @@ -348,6 +372,7 @@ static int davinci_evm_probe(struct platform_device *pdev) of_match_device(of_match_ptr(davinci_evm_dt_ids), &pdev->dev); struct snd_soc_dai_link *dai = (struct snd_soc_dai_link *) match->data; struct snd_soc_card_drvdata_davinci *drvdata = NULL; + struct clk *mclk; int ret = 0; evm_soc_card.dai_link = dai; @@ -367,13 +392,38 @@ static int davinci_evm_probe(struct platform_device *pdev) if (ret) return ret; + mclk = of_clk_get_by_name(np, "ti,codec-clock"); + if (PTR_ERR(mclk) == -EPROBE_DEFER) { + return -EPROBE_DEFER; + } else if (IS_ERR(mclk)) { + dev_dbg(&pdev->dev, "Codec clock not found.\n"); + mclk = NULL; + } + drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; + drvdata->mclk = mclk; + ret = of_property_read_u32(np, "ti,codec-clock-rate", &drvdata->sysclk); - if (ret < 0) - return -EINVAL; + + if (ret < 0) { + if (!drvdata->mclk) { + dev_err(&pdev->dev, + "No clock or clock rate defined.\n"); + return -EINVAL; + } + drvdata->sysclk = clk_get_rate(drvdata->mclk); + } else if (drvdata->mclk) { + unsigned int requestd_rate = drvdata->sysclk; + clk_set_rate(drvdata->mclk, drvdata->sysclk); + drvdata->sysclk = clk_get_rate(drvdata->mclk); + if (drvdata->sysclk != requestd_rate) + dev_warn(&pdev->dev, + "Could not get requested rate %u using %u.\n", + requestd_rate, drvdata->sysclk); + } snd_soc_card_set_drvdata(&evm_soc_card, drvdata); ret = devm_snd_soc_register_card(&pdev->dev, &evm_soc_card); @@ -387,6 +437,12 @@ static int davinci_evm_probe(struct platform_device *pdev) static int davinci_evm_remove(struct platform_device *pdev) { struct snd_soc_card *card = platform_get_drvdata(pdev); + struct snd_soc_card_drvdata_davinci *drvdata = + (struct snd_soc_card_drvdata_davinci *) + snd_soc_card_get_drvdata(card); + + if (drvdata->mclk) + clk_put(drvdata->mclk); snd_soc_unregister_card(card); -- 1.7.9.5
next prev parent reply other threads:[~2013-12-20 10:38 UTC|newest] Thread overview: 110+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-11-19 12:12 [PATCH RFC 0/9] Beaglebone-Black HDMI audio Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 12:12 ` [PATCH RFC 1/9] clk: add gpio controlled clock Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 12:12 ` [PATCH RFC 2/9] ASoC: davinci-evm: Add named clock reference to DT bindings Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 18:18 ` Mark Brown 2013-11-19 18:18 ` Mark Brown 2013-11-19 12:12 ` [PATCH RFC 3/9] ASoC: davinci-evm: HDMI audio support for TDA998x trough McASP I2S bus Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 15:07 ` Thomas Petazzoni 2013-11-19 15:07 ` Thomas Petazzoni 2013-11-19 12:12 ` [PATCH RFC 4/9] ASoC: hdmi-codec: Add devicetree binding with documentation Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 17:50 ` Mark Brown 2013-11-19 17:50 ` Mark Brown 2013-11-20 9:23 ` Jean-Francois Moine 2013-11-20 9:23 ` Jean-Francois Moine 2013-11-20 10:09 ` Mark Brown 2013-11-20 10:09 ` Mark Brown 2013-11-20 12:34 ` Jean-Francois Moine 2013-11-20 12:34 ` Jean-Francois Moine 2013-11-20 13:33 ` Mark Brown 2013-11-20 13:33 ` Mark Brown 2013-11-19 12:12 ` [PATCH RFC 5/9] ASoC: hdmi-codec: Add SNDRV_PCM_FMTBIT_32_LE playback format Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 18:21 ` Mark Brown 2013-11-19 18:21 ` Mark Brown 2013-11-19 12:12 ` [PATCH RFC 6/9] ASoC: davinci: HDMI audio build for AM33XX and TDA998x Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 12:12 ` [PATCH RFC 7/9] drm/tilcdc: Add I2C HDMI audio config for tda998x Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 12:12 ` [PATCH RFC 8/9] ARM: OMAP2+: omap2plus_defconfig: Enable tilcdc and TDA998X HDMI support Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 12:12 ` [PATCH RFC 9/9] ARM: OMAP2+: omap2plus_defconfig: Enable BeagleBone Black HDMI audio support Jyri Sarha 2013-11-19 12:12 ` Jyri Sarha 2013-11-19 12:21 ` [PATCH RFC] DTS Changes for Beaglebone-Black HDMI audio Jyri Sarha 2013-11-19 12:21 ` Jyri Sarha 2013-11-19 12:21 ` [PATCH RFC] ARM/dts: am335x-boneblack: Add HDMI audio support Jyri Sarha 2013-11-19 12:21 ` Jyri Sarha 2013-11-19 13:02 ` Benoit Cousson 2013-11-19 13:02 ` Benoit Cousson 2013-11-19 13:29 ` Jyri Sarha 2013-11-19 13:29 ` Jyri Sarha 2013-12-08 12:16 ` [RFC v2 0/8] Beaglebone-Black HDMI audio Jyri Sarha 2013-12-08 12:16 ` [RFC v2 1/8] clk: add gpio controlled clock Jyri Sarha 2013-12-08 12:16 ` [RFC v2 2/8] ASoC: davinci-evm: Add named clock reference to DT bindings Jyri Sarha 2013-12-08 12:16 ` [RFC v2 3/8] ASoC: davinci-evm: HDMI audio support for TDA998x trough McASP I2S bus Jyri Sarha 2013-12-08 12:16 ` [RFC v2 4/8] ASoC: hdmi-codec: Add devicetree binding with documentation Jyri Sarha 2013-12-08 12:16 ` [RFC v2 5/8] ASoC: davinci: HDMI audio build for AM33XX and TDA998x Jyri Sarha 2013-12-08 12:16 ` [RFC v2 6/8] drm/tilcdc: Add I2C HDMI audio config for tda998x Jyri Sarha 2013-12-08 12:16 ` [RFC v2 7/8] ARM: OMAP2+: omap2plus_defconfig: Enable tilcdc and TDA998X HDMI support Jyri Sarha 2013-12-08 12:16 ` [RFC v2 8/8] ARM: OMAP2+: omap2plus_defconfig: Enable BeagleBone Black HDMI audio support Jyri Sarha 2013-12-08 12:20 ` [RFC v2] Beaglebone-Black HDMI audio Jyri Sarha 2013-12-08 12:20 ` [RFC v2] ARM/dts: am335x-boneblack: Add HDMI audio support Jyri Sarha 2013-12-10 18:52 ` Jyri Sarha [not found] ` <cover.1386504183.git.jsarha-l0cyMroinI0@public.gmane.org> 2013-12-10 18:52 ` Jyri Sarha [not found] ` <cover.1384862950.git.jsarha-l0cyMroinI0@public.gmane.org> 2013-12-10 18:52 ` [RFC v2] Beaglebone-Black HDMI audio Jyri Sarha 2013-12-20 10:36 ` [PATCH RFC v2 REPOST 0/8] " Jyri Sarha 2013-12-20 10:36 ` Jyri Sarha 2013-12-20 10:37 ` [PATCH RFC v2 REPOST 1/8] clk: add gpio controlled clock Jyri Sarha 2013-12-20 10:37 ` Jyri Sarha 2013-12-20 10:38 ` Jyri Sarha [this message] 2013-12-20 10:38 ` [PATCH RFC v2 REPOST 2/8] ASoC: davinci-evm: Add named clock reference to DT bindings Jyri Sarha 2013-12-31 13:16 ` Mark Brown 2013-12-31 13:16 ` Mark Brown 2014-01-15 11:12 ` Jyri Sarha 2014-01-15 11:12 ` Jyri Sarha 2013-12-20 10:39 ` [PATCH RFC v2 REPOST 3/8] ASoC: davinci-evm: HDMI audio support for TDA998x trough McASP I2S bus Jyri Sarha 2013-12-20 10:39 ` Jyri Sarha 2013-12-31 13:25 ` Mark Brown 2013-12-31 13:25 ` Mark Brown 2014-01-15 11:27 ` Jyri Sarha 2014-01-15 11:27 ` Jyri Sarha 2014-01-15 13:48 ` Anssi Hannula 2014-01-15 13:48 ` [alsa-devel] " Anssi Hannula 2014-01-15 16:28 ` Jyri Sarha 2014-01-15 16:28 ` [alsa-devel] " Jyri Sarha 2014-01-15 15:51 ` Jean-Francois Moine 2014-01-15 15:51 ` Jean-Francois Moine 2014-01-22 9:20 ` Jyri Sarha 2014-01-22 9:20 ` [alsa-devel] " Jyri Sarha 2014-01-22 10:19 ` Jean-Francois Moine 2014-01-22 10:19 ` Jean-Francois Moine 2014-01-22 10:46 ` Jean-Francois Moine 2014-01-22 10:46 ` Jean-Francois Moine 2014-01-24 12:57 ` Jyri Sarha 2014-01-24 12:57 ` [alsa-devel] " Jyri Sarha 2014-01-24 16:54 ` Jean-Francois Moine 2014-01-24 16:54 ` Jean-Francois Moine 2014-01-21 19:15 ` Mark Brown 2014-01-21 19:15 ` Mark Brown 2014-01-24 13:01 ` Jyri Sarha 2014-01-24 13:01 ` Jyri Sarha 2013-12-20 10:40 ` [PATCH RFC v2 REPOST 4/8] ASoC: hdmi-codec: Add devicetree binding with documentation Jyri Sarha 2013-12-20 10:40 ` Jyri Sarha 2013-12-31 13:26 ` Mark Brown 2013-12-31 13:26 ` Mark Brown 2013-12-20 10:40 ` [PATCH RFC v2 REPOST 5/8] ASoC: davinci: HDMI audio build for AM33XX and TDA998x Jyri Sarha 2013-12-20 10:40 ` Jyri Sarha 2013-12-20 10:41 ` [PATCH RFC v2 REPOST 6/8] drm/tilcdc: Add I2C HDMI audio config for tda998x Jyri Sarha 2013-12-20 10:41 ` Jyri Sarha 2013-12-20 10:42 ` [PATCH RFC v2 REPOST 7/8] ARM: OMAP2+: omap2plus_defconfig: Enable tilcdc and TDA998X HDMI support Jyri Sarha 2013-12-20 10:42 ` Jyri Sarha 2013-12-20 10:43 ` [PATCH RFC v2 REPOST 8/8] ARM: OMAP2+: omap2plus_defconfig: Enable BeagleBone Black HDMI audio support Jyri Sarha 2013-12-20 10:43 ` Jyri Sarha 2013-12-20 11:30 ` [alsa-devel] [PATCH RFC v2 REPOST 0/8] Beaglebone-Black HDMI audio Mark Brown 2013-12-20 11:30 ` Mark Brown 2013-12-20 11:51 ` Jyri Sarha 2013-12-20 11:51 ` [alsa-devel] " Jyri Sarha
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=c1ae738c9b6cd9f2e595eed1f4981378ded46925.1387535302.git.jsarha@ti.com \ --to=jsarha@ti.com \ --cc=alsa-devel@alsa-project.org \ --cc=bcousson@baylibre.com \ --cc=broonie@kernel.org \ --cc=devicetree@vger.kernel.org \ --cc=dri-devel@lists.freedesktop.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-omap@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.