From: nicolas.ferre@atmel.com (Nicolas Ferre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] [media] at91: add code to initialize and manage the ISI_MCK for Atmel ISI driver.
Date: Fri, 09 Sep 2011 12:04:47 +0200 [thread overview]
Message-ID: <4E69E4BF.3030402@atmel.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1109060803590.14818@axis700.grange>
Le 06/09/2011 08:54, Guennadi Liakhovetski :
> On Tue, 6 Sep 2011, Josh Wu wrote:
>
>> This patch enable the configuration for ISI_MCK, which is provided by programmable clock.
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> ---
>> drivers/media/video/atmel-isi.c | 60 ++++++++++++++++++++++++++++++++++++++-
>> include/media/atmel-isi.h | 4 ++
>> 2 files changed, 63 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c
[..]
>> /* -----------------------------------------------------------------------*/
>> +/* Initialize ISI_MCK clock, called by atmel_isi_probe() function */
>> +static int initialize_mck(struct platform_device *pdev,
>> + struct atmel_isi *isi)
>> +{
>> + struct device *dev = &pdev->dev;
>> + struct isi_platform_data *pdata = dev->platform_data;
>> + struct clk *pck_parent;
>> + int ret;
>> +
>> + if (!strlen(pdata->pck_name) || !strlen(pdata->pck_parent_name))
>> + return -EINVAL;
>> +
>> + /* ISI_MCK is provided by PCK clock */
>> + isi->mck = clk_get(dev, pdata->pck_name);
>
> I think, it's still not what Russell meant. Look at
> drivers/mmc/host/atmel-mci.c:
>
> host->mck = clk_get(&pdev->dev, "mci_clk");
>
> and in arch/arm/mach-at91/at91sam9g45.c they've got
>
> CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.0", &mmc0_clk),
> CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.1", &mmc1_clk),
>
> where
>
> #define CLKDEV_CON_DEV_ID(_con_id, _dev_id, _clk) \
> { \
> .con_id = _con_id, \
> .dev_id = _dev_id, \
> .clk = _clk, \
> }
>
> I.e., in the device driver (mmc in this case) you only use the (platform)
> device instance, whose dev_name(dev) is then matched against one of clock
> lookups above, and a connection ID, which is used in case your device is
> using more than one clock. In the ISI case, your pck1 clock, that you seem
> to need here, doesn't have a clock lookup object, so, you might have to
> add one, and then use its connection ID.
>
>> + if (IS_ERR(isi->mck)) {
>> + dev_err(dev, "Failed to get PCK: %s\n", pdata->pck_name);
>> + return PTR_ERR(isi->mck);
>> + }
>> +
>> + pck_parent = clk_get(dev, pdata->pck_parent_name);
>> + if (IS_ERR(pck_parent)) {
>> + ret = PTR_ERR(pck_parent);
>> + dev_err(dev, "Failed to get PCK parent: %s\n",
>> + pdata->pck_parent_name);
>> + goto err_init_mck;
>> + }
>> +
>> + ret = clk_set_parent(isi->mck, pck_parent);
>
> I'm not entirely sure on this one, but as we had a similar situation with
> clocks, we decided to extablish the clock hierarchy in the board code, and
> only deal with the actual device clocks in the driver itself. I.e., we
> moved all clk_set_parent() and setting up the parent clock into the board.
> And I do think, this makes more sense, than doing this in the driver, not
> all users of this driver will need to manage the parent clock, right?
Exactly.
Josh, for the two comments by Guennadi above, you can take
sound/soc/atmel/sam9g20_wm8731.c
as an example of using PCK and parent clocks. You will also find how to
use named clocks and how to set the programmable clocks rate...
>> + clk_put(pck_parent);
>> + if (ret)
>> + goto err_init_mck;
>> +
>> + ret = clk_set_rate(isi->mck, pdata->isi_mck_hz);
>> + if (ret < 0)
>> + goto err_init_mck;
>> +
>> + return 0;
>> +
>> +err_init_mck:
>> + clk_put(isi->mck);
>> + return ret;
>> +}
>> +
>> static int __devexit atmel_isi_remove(struct platform_device *pdev)
>> {
>> struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
>> @@ -897,6 +948,7 @@ static int __devexit atmel_isi_remove(struct platform_device *pdev)
>> isi->fb_descriptors_phys);
>>
>> iounmap(isi->regs);
>> + clk_put(isi->mck);
>> clk_put(isi->pclk);
>> kfree(isi);
[..]
Best regards,
--
Nicolas Ferre
WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: Josh Wu <josh.wu@atmel.com>,
linux-arm-kernel@lists.infradead.org,
linux-media@vger.kernel.org
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
plagnioj@jcrosoft.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] [media] at91: add code to initialize and manage the ISI_MCK for Atmel ISI driver.
Date: Fri, 09 Sep 2011 12:04:47 +0200 [thread overview]
Message-ID: <4E69E4BF.3030402@atmel.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1109060803590.14818@axis700.grange>
Le 06/09/2011 08:54, Guennadi Liakhovetski :
> On Tue, 6 Sep 2011, Josh Wu wrote:
>
>> This patch enable the configuration for ISI_MCK, which is provided by programmable clock.
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> ---
>> drivers/media/video/atmel-isi.c | 60 ++++++++++++++++++++++++++++++++++++++-
>> include/media/atmel-isi.h | 4 ++
>> 2 files changed, 63 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/media/video/atmel-isi.c b/drivers/media/video/atmel-isi.c
[..]
>> /* -----------------------------------------------------------------------*/
>> +/* Initialize ISI_MCK clock, called by atmel_isi_probe() function */
>> +static int initialize_mck(struct platform_device *pdev,
>> + struct atmel_isi *isi)
>> +{
>> + struct device *dev = &pdev->dev;
>> + struct isi_platform_data *pdata = dev->platform_data;
>> + struct clk *pck_parent;
>> + int ret;
>> +
>> + if (!strlen(pdata->pck_name) || !strlen(pdata->pck_parent_name))
>> + return -EINVAL;
>> +
>> + /* ISI_MCK is provided by PCK clock */
>> + isi->mck = clk_get(dev, pdata->pck_name);
>
> I think, it's still not what Russell meant. Look at
> drivers/mmc/host/atmel-mci.c:
>
> host->mck = clk_get(&pdev->dev, "mci_clk");
>
> and in arch/arm/mach-at91/at91sam9g45.c they've got
>
> CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.0", &mmc0_clk),
> CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.1", &mmc1_clk),
>
> where
>
> #define CLKDEV_CON_DEV_ID(_con_id, _dev_id, _clk) \
> { \
> .con_id = _con_id, \
> .dev_id = _dev_id, \
> .clk = _clk, \
> }
>
> I.e., in the device driver (mmc in this case) you only use the (platform)
> device instance, whose dev_name(dev) is then matched against one of clock
> lookups above, and a connection ID, which is used in case your device is
> using more than one clock. In the ISI case, your pck1 clock, that you seem
> to need here, doesn't have a clock lookup object, so, you might have to
> add one, and then use its connection ID.
>
>> + if (IS_ERR(isi->mck)) {
>> + dev_err(dev, "Failed to get PCK: %s\n", pdata->pck_name);
>> + return PTR_ERR(isi->mck);
>> + }
>> +
>> + pck_parent = clk_get(dev, pdata->pck_parent_name);
>> + if (IS_ERR(pck_parent)) {
>> + ret = PTR_ERR(pck_parent);
>> + dev_err(dev, "Failed to get PCK parent: %s\n",
>> + pdata->pck_parent_name);
>> + goto err_init_mck;
>> + }
>> +
>> + ret = clk_set_parent(isi->mck, pck_parent);
>
> I'm not entirely sure on this one, but as we had a similar situation with
> clocks, we decided to extablish the clock hierarchy in the board code, and
> only deal with the actual device clocks in the driver itself. I.e., we
> moved all clk_set_parent() and setting up the parent clock into the board.
> And I do think, this makes more sense, than doing this in the driver, not
> all users of this driver will need to manage the parent clock, right?
Exactly.
Josh, for the two comments by Guennadi above, you can take
sound/soc/atmel/sam9g20_wm8731.c
as an example of using PCK and parent clocks. You will also find how to
use named clocks and how to set the programmable clocks rate...
>> + clk_put(pck_parent);
>> + if (ret)
>> + goto err_init_mck;
>> +
>> + ret = clk_set_rate(isi->mck, pdata->isi_mck_hz);
>> + if (ret < 0)
>> + goto err_init_mck;
>> +
>> + return 0;
>> +
>> +err_init_mck:
>> + clk_put(isi->mck);
>> + return ret;
>> +}
>> +
>> static int __devexit atmel_isi_remove(struct platform_device *pdev)
>> {
>> struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev);
>> @@ -897,6 +948,7 @@ static int __devexit atmel_isi_remove(struct platform_device *pdev)
>> isi->fb_descriptors_phys);
>>
>> iounmap(isi->regs);
>> + clk_put(isi->mck);
>> clk_put(isi->pclk);
>> kfree(isi);
[..]
Best regards,
--
Nicolas Ferre
next prev parent reply other threads:[~2011-09-09 10:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-06 5:56 [PATCH v2] [media] at91: add code to initialize and manage the ISI_MCK for Atmel ISI driver Josh Wu
2011-09-06 5:56 ` Josh Wu
2011-09-06 6:54 ` Guennadi Liakhovetski
2011-09-06 6:54 ` Guennadi Liakhovetski
2011-09-06 20:05 ` Jean-Christophe PLAGNIOL-VILLARD
2011-09-06 20:05 ` Jean-Christophe PLAGNIOL-VILLARD
2011-09-06 21:08 ` Sylwester Nawrocki
2011-09-06 21:08 ` Sylwester Nawrocki
2011-09-15 13:23 ` Jean-Christophe PLAGNIOL-VILLARD
2011-09-15 13:23 ` Jean-Christophe PLAGNIOL-VILLARD
2011-09-15 15:30 ` Sylwester Nawrocki
2011-09-15 15:30 ` Sylwester Nawrocki
2011-09-09 10:04 ` Nicolas Ferre [this message]
2011-09-09 10:04 ` Nicolas Ferre
2011-09-22 3:23 ` Wu, Josh
2011-09-22 3:23 ` Wu, Josh
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=4E69E4BF.3030402@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=linux-arm-kernel@lists.infradead.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: 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.