From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: Mateusz Krawczuk <m.krawczuk@partner.samsung.com>
Cc: kgene.kim@samsung.com, kyungmin.park@samsung.com,
t.figa@samsung.com, tomasz.figa@gmail.com,
rob.herring@calxeda.com, pawel.moll@arm.com,
mark.rutland@arm.com, swarren@wwwdotorg.org,
ian.campbell@citrix.com, rob@landley.net, mturquette@linaro.org,
thomas.abraham@linaro.org, t.stanislaws@samsung.com,
m.chehab@samsung.com, s.nawrocki@samsung.com,
m.szyprowski@samung.com, linux-kernel@vger.kernel.org,
linux-samsung-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk,
devicetree@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH RFC 1/5] media: s5p-tv: Fix sdo driver to work with CCF
Date: Mon, 26 Aug 2013 17:32:05 +0200 [thread overview]
Message-ID: <3259807.j0POtVdD7o@amdc1032> (raw)
In-Reply-To: <1377517114-20222-2-git-send-email-m.krawczuk@partner.samsung.com>
Hi,
On Monday, August 26, 2013 01:38:30 PM Mateusz Krawczuk wrote:
> Replace clk_enable by clock_enable_prepare and clk_disable with clk_disable_unprepare.
> Clock prepare is required by Clock Common Framework, and old clock driver didn`t support it.
> Without it Common Clock Framework prints a warning.
>
> Signed-off-by: Mateusz Krawczuk <m.krawczuk@partner.samsung.com>
> ---
> drivers/media/platform/s5p-tv/sdo_drv.c | 44 +++++++++++++++++++++++++--------
> 1 file changed, 34 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c b/drivers/media/platform/s5p-tv/sdo_drv.c
> index 0afa90f..77eac6d 100644
> --- a/drivers/media/platform/s5p-tv/sdo_drv.c
> +++ b/drivers/media/platform/s5p-tv/sdo_drv.c
> @@ -55,6 +55,8 @@ struct sdo_device {
> struct clk *dacphy;
> /** clock for control of VPLL */
> struct clk *fout_vpll;
> + /** vpll rate before sdo stream was on */
> + int vpll_rate;
> /** regulator for SDO IP power */
> struct regulator *vdac;
> /** regulator for SDO plug detection */
> @@ -193,17 +195,34 @@ static int sdo_s_power(struct v4l2_subdev *sd, int on)
>
> static int sdo_streamon(struct sdo_device *sdev)
> {
> + int ret = 0;
There is no need to initialize ret to 0 here.
> /* set proper clock for Timing Generator */
> - clk_set_rate(sdev->fout_vpll, 54000000);
> + sdev->vpll_rate = clk_get_rate(sdev->fout_vpll);
> + ret = clk_set_rate(sdev->fout_vpll, 54000000);
> + if (ret < 0) {
> + dev_err(sdev->dev,
> + "%s: Failed to set vpll rate!\n", __func__);
> + return ret;
> + }
> dev_info(sdev->dev, "fout_vpll.rate = %lu\n",
> clk_get_rate(sdev->fout_vpll));
> /* enable clock in SDO */
> sdo_write_mask(sdev, SDO_CLKCON, ~0, SDO_TVOUT_CLOCK_ON);
> - clk_enable(sdev->dacphy);
> + ret = clk_prepare_enable(sdev->dacphy);
> + if (ret < 0) {
> + dev_err(sdev->dev,
> + "%s: Failed to prepare and enable clock !\n", __func__);
> + goto fail;
> + }
> /* enable DAC */
> sdo_write_mask(sdev, SDO_DAC, ~0, SDO_POWER_ON_DAC);
> sdo_reg_debug(sdev);
> return 0;
> +fail:
> + sdo_write_mask(sdev, SDO_CLKCON, 0, SDO_TVOUT_CLOCK_ON);
> + clk_set_rate(sdev->fout_vpll, sdev->vpll_rate);
There is not a word about this change in the patch description.
> + return ret;
> }
>
> static int sdo_streamoff(struct sdo_device *sdev)
> @@ -211,7 +230,7 @@ static int sdo_streamoff(struct sdo_device *sdev)
> int tries;
>
> sdo_write_mask(sdev, SDO_DAC, 0, SDO_POWER_ON_DAC);
> - clk_disable(sdev->dacphy);
> + clk_disable_unprepare(sdev->dacphy);
> sdo_write_mask(sdev, SDO_CLKCON, 0, SDO_TVOUT_CLOCK_ON);
> for (tries = 100; tries; --tries) {
> if (sdo_read(sdev, SDO_CLKCON) & SDO_TVOUT_CLOCK_READY)
> @@ -220,6 +239,7 @@ static int sdo_streamoff(struct sdo_device *sdev)
> }
> if (tries == 0)
> dev_err(sdev->dev, "failed to stop streaming\n");
> + clk_set_rate(sdev->fout_vpll, sdev->vpll_rate);
ditto
sdev->fout_vpll rate related changes should be moved to a separate patch
(or at least described properly in the patch description).
> return tries ? 0 : -EIO;
> }
>
> @@ -254,7 +274,7 @@ static int sdo_runtime_suspend(struct device *dev)
> dev_info(dev, "suspend\n");
> regulator_disable(sdev->vdet);
> regulator_disable(sdev->vdac);
> - clk_disable(sdev->sclk_dac);
> + clk_disable_unprepare(sdev->sclk_dac);
> return 0;
> }
>
> @@ -266,7 +286,7 @@ static int sdo_runtime_resume(struct device *dev)
>
> dev_info(dev, "resume\n");
>
> - ret = clk_enable(sdev->sclk_dac);
> + ret = clk_prepare_enable(sdev->sclk_dac);
> if (ret < 0)
> return ret;
>
> @@ -299,7 +319,7 @@ static int sdo_runtime_resume(struct device *dev)
> vdac_r_dis:
> regulator_disable(sdev->vdac);
> dac_clk_dis:
> - clk_disable(sdev->sclk_dac);
> + clk_disable_unprepare(sdev->sclk_dac);
> return ret;
> }
>
> @@ -403,10 +423,14 @@ static int sdo_probe(struct platform_device *pdev)
> ret = PTR_ERR(sdev->vdet);
> goto fail_fout_vpll;
> }
> -
> /* enable gate for dac clock, because mixer uses it */
> - clk_enable(sdev->dac);
> -
> + clk_prepare_enable(sdev->dac);
> + if (IS_ERR(sdev->dac)) {
It doesn't seem correct to check sdev->dac with IS_ERR() here, especially
since we have the following code earlier:
sdev->dac = clk_get(dev, "dac");
if (IS_ERR(sdev->dac)) {
dev_err(dev, "failed to get clock 'dac'\n");
ret = PTR_ERR(sdev->dac);
goto fail_sclk_dac;
}
I think you should just check clk_prepare_enable() return value instead.
> + dev_err(dev,
> + "%s: Failed to prepare and enable clock !\n", __func__);
> + ret = PTR_ERR(sdev->dac);
> + goto fail_fout_vpll;
> + }
> /* configure power management */
> pm_runtime_enable(dev);
>
> @@ -444,7 +468,7 @@ static int sdo_remove(struct platform_device *pdev)
> struct sdo_device *sdev = sd_to_sdev(sd);
>
> pm_runtime_disable(&pdev->dev);
> - clk_disable(sdev->dac);
> + clk_disable_unprepare(sdev->dac);
> clk_put(sdev->fout_vpll);
> clk_put(sdev->dacphy);
> clk_put(sdev->dac);
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
WARNING: multiple messages have this Message-ID (diff)
From: b.zolnierkie@samsung.com (Bartlomiej Zolnierkiewicz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC 1/5] media: s5p-tv: Fix sdo driver to work with CCF
Date: Mon, 26 Aug 2013 17:32:05 +0200 [thread overview]
Message-ID: <3259807.j0POtVdD7o@amdc1032> (raw)
In-Reply-To: <1377517114-20222-2-git-send-email-m.krawczuk@partner.samsung.com>
Hi,
On Monday, August 26, 2013 01:38:30 PM Mateusz Krawczuk wrote:
> Replace clk_enable by clock_enable_prepare and clk_disable with clk_disable_unprepare.
> Clock prepare is required by Clock Common Framework, and old clock driver didn`t support it.
> Without it Common Clock Framework prints a warning.
>
> Signed-off-by: Mateusz Krawczuk <m.krawczuk@partner.samsung.com>
> ---
> drivers/media/platform/s5p-tv/sdo_drv.c | 44 +++++++++++++++++++++++++--------
> 1 file changed, 34 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/platform/s5p-tv/sdo_drv.c b/drivers/media/platform/s5p-tv/sdo_drv.c
> index 0afa90f..77eac6d 100644
> --- a/drivers/media/platform/s5p-tv/sdo_drv.c
> +++ b/drivers/media/platform/s5p-tv/sdo_drv.c
> @@ -55,6 +55,8 @@ struct sdo_device {
> struct clk *dacphy;
> /** clock for control of VPLL */
> struct clk *fout_vpll;
> + /** vpll rate before sdo stream was on */
> + int vpll_rate;
> /** regulator for SDO IP power */
> struct regulator *vdac;
> /** regulator for SDO plug detection */
> @@ -193,17 +195,34 @@ static int sdo_s_power(struct v4l2_subdev *sd, int on)
>
> static int sdo_streamon(struct sdo_device *sdev)
> {
> + int ret = 0;
There is no need to initialize ret to 0 here.
> /* set proper clock for Timing Generator */
> - clk_set_rate(sdev->fout_vpll, 54000000);
> + sdev->vpll_rate = clk_get_rate(sdev->fout_vpll);
> + ret = clk_set_rate(sdev->fout_vpll, 54000000);
> + if (ret < 0) {
> + dev_err(sdev->dev,
> + "%s: Failed to set vpll rate!\n", __func__);
> + return ret;
> + }
> dev_info(sdev->dev, "fout_vpll.rate = %lu\n",
> clk_get_rate(sdev->fout_vpll));
> /* enable clock in SDO */
> sdo_write_mask(sdev, SDO_CLKCON, ~0, SDO_TVOUT_CLOCK_ON);
> - clk_enable(sdev->dacphy);
> + ret = clk_prepare_enable(sdev->dacphy);
> + if (ret < 0) {
> + dev_err(sdev->dev,
> + "%s: Failed to prepare and enable clock !\n", __func__);
> + goto fail;
> + }
> /* enable DAC */
> sdo_write_mask(sdev, SDO_DAC, ~0, SDO_POWER_ON_DAC);
> sdo_reg_debug(sdev);
> return 0;
> +fail:
> + sdo_write_mask(sdev, SDO_CLKCON, 0, SDO_TVOUT_CLOCK_ON);
> + clk_set_rate(sdev->fout_vpll, sdev->vpll_rate);
There is not a word about this change in the patch description.
> + return ret;
> }
>
> static int sdo_streamoff(struct sdo_device *sdev)
> @@ -211,7 +230,7 @@ static int sdo_streamoff(struct sdo_device *sdev)
> int tries;
>
> sdo_write_mask(sdev, SDO_DAC, 0, SDO_POWER_ON_DAC);
> - clk_disable(sdev->dacphy);
> + clk_disable_unprepare(sdev->dacphy);
> sdo_write_mask(sdev, SDO_CLKCON, 0, SDO_TVOUT_CLOCK_ON);
> for (tries = 100; tries; --tries) {
> if (sdo_read(sdev, SDO_CLKCON) & SDO_TVOUT_CLOCK_READY)
> @@ -220,6 +239,7 @@ static int sdo_streamoff(struct sdo_device *sdev)
> }
> if (tries == 0)
> dev_err(sdev->dev, "failed to stop streaming\n");
> + clk_set_rate(sdev->fout_vpll, sdev->vpll_rate);
ditto
sdev->fout_vpll rate related changes should be moved to a separate patch
(or at least described properly in the patch description).
> return tries ? 0 : -EIO;
> }
>
> @@ -254,7 +274,7 @@ static int sdo_runtime_suspend(struct device *dev)
> dev_info(dev, "suspend\n");
> regulator_disable(sdev->vdet);
> regulator_disable(sdev->vdac);
> - clk_disable(sdev->sclk_dac);
> + clk_disable_unprepare(sdev->sclk_dac);
> return 0;
> }
>
> @@ -266,7 +286,7 @@ static int sdo_runtime_resume(struct device *dev)
>
> dev_info(dev, "resume\n");
>
> - ret = clk_enable(sdev->sclk_dac);
> + ret = clk_prepare_enable(sdev->sclk_dac);
> if (ret < 0)
> return ret;
>
> @@ -299,7 +319,7 @@ static int sdo_runtime_resume(struct device *dev)
> vdac_r_dis:
> regulator_disable(sdev->vdac);
> dac_clk_dis:
> - clk_disable(sdev->sclk_dac);
> + clk_disable_unprepare(sdev->sclk_dac);
> return ret;
> }
>
> @@ -403,10 +423,14 @@ static int sdo_probe(struct platform_device *pdev)
> ret = PTR_ERR(sdev->vdet);
> goto fail_fout_vpll;
> }
> -
> /* enable gate for dac clock, because mixer uses it */
> - clk_enable(sdev->dac);
> -
> + clk_prepare_enable(sdev->dac);
> + if (IS_ERR(sdev->dac)) {
It doesn't seem correct to check sdev->dac with IS_ERR() here, especially
since we have the following code earlier:
sdev->dac = clk_get(dev, "dac");
if (IS_ERR(sdev->dac)) {
dev_err(dev, "failed to get clock 'dac'\n");
ret = PTR_ERR(sdev->dac);
goto fail_sclk_dac;
}
I think you should just check clk_prepare_enable() return value instead.
> + dev_err(dev,
> + "%s: Failed to prepare and enable clock !\n", __func__);
> + ret = PTR_ERR(sdev->dac);
> + goto fail_fout_vpll;
> + }
> /* configure power management */
> pm_runtime_enable(dev);
>
> @@ -444,7 +468,7 @@ static int sdo_remove(struct platform_device *pdev)
> struct sdo_device *sdev = sd_to_sdev(sd);
>
> pm_runtime_disable(&pdev->dev);
> - clk_disable(sdev->dac);
> + clk_disable_unprepare(sdev->dac);
> clk_put(sdev->fout_vpll);
> clk_put(sdev->dacphy);
> clk_put(sdev->dac);
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
next prev parent reply other threads:[~2013-08-26 15:32 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-26 11:38 [PATCH RFC 0/5] ARM: s5pv210: move to common clk framework Mateusz Krawczuk
2013-08-26 11:38 ` Mateusz Krawczuk
2013-08-26 11:38 ` [PATCH RFC 1/5] media: s5p-tv: Fix sdo driver to work with CCF Mateusz Krawczuk
2013-08-26 11:38 ` Mateusz Krawczuk
2013-08-26 11:38 ` Mateusz Krawczuk
2013-08-26 15:32 ` Bartlomiej Zolnierkiewicz [this message]
2013-08-26 15:32 ` Bartlomiej Zolnierkiewicz
2013-08-26 11:38 ` [PATCH RFC 2/5] media: s5p-tv: Fix mixer " Mateusz Krawczuk
2013-08-26 11:38 ` Mateusz Krawczuk
2013-08-26 16:03 ` Bartlomiej Zolnierkiewicz
2013-08-26 16:03 ` Bartlomiej Zolnierkiewicz
2013-08-26 11:38 ` [PATCH RFC 3/5] ARM: samsung: add clock setup for FIMC and FIMD Mateusz Krawczuk
2013-08-26 11:38 ` Mateusz Krawczuk
2013-08-26 16:19 ` Bartlomiej Zolnierkiewicz
2013-08-26 16:19 ` Bartlomiej Zolnierkiewicz
2013-08-26 18:37 ` Sylwester Nawrocki
2013-08-26 18:37 ` Sylwester Nawrocki
2013-08-27 3:07 ` Jingoo Han
2013-08-27 3:07 ` Jingoo Han
2013-08-26 11:38 ` [PATCH RFC 4/5] clk: samsung: Add clock driver for s5pc110/s5pv210 Mateusz Krawczuk
2013-08-26 11:38 ` Mateusz Krawczuk
2013-08-26 17:12 ` Bartlomiej Zolnierkiewicz
2013-08-26 17:12 ` Bartlomiej Zolnierkiewicz
2013-08-26 11:38 ` [PATCH RFC 5/5] ARM: s5pv210: Migrate clock handling to Common Clock Framework Mateusz Krawczuk
2013-08-26 11:38 ` Mateusz Krawczuk
2013-08-26 16:38 ` Bartlomiej Zolnierkiewicz
2013-08-26 16:38 ` Bartlomiej Zolnierkiewicz
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=3259807.j0POtVdD7o@amdc1032 \
--to=b.zolnierkie@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=ian.campbell@citrix.com \
--cc=kgene.kim@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=m.chehab@samsung.com \
--cc=m.krawczuk@partner.samsung.com \
--cc=m.szyprowski@samung.com \
--cc=mark.rutland@arm.com \
--cc=mturquette@linaro.org \
--cc=pawel.moll@arm.com \
--cc=rob.herring@calxeda.com \
--cc=rob@landley.net \
--cc=s.nawrocki@samsung.com \
--cc=swarren@wwwdotorg.org \
--cc=t.figa@samsung.com \
--cc=t.stanislaws@samsung.com \
--cc=thomas.abraham@linaro.org \
--cc=tomasz.figa@gmail.com \
/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: link
Be 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.