* [PATCH 0/3] media: atmel-isi: rework on the clock part and add runtime pm support
@ 2015-03-05 5:00 Josh Wu
2015-03-05 5:00 ` [PATCH 1/3] media: atmel-isi: move the peripheral clock to start/stop_stream() function Josh Wu
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Josh Wu @ 2015-03-05 5:00 UTC (permalink / raw)
To: linux-arm-kernel
This patch series fix the peripheral clock code and enable runtime pm
support.
Aslo clean up the code which is for the compatiblity of mck.
Josh Wu (3):
media: atmel-isi: move the peripheral clock to start/stop_stream()
function
media: atmel-isi: add runtime pm support
media: atmel-isi: remove mck back compatiable code as we don't need it
drivers/media/platform/soc_camera/atmel-isi.c | 72 +++++++++++++--------------
1 file changed, 34 insertions(+), 38 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/3] media: atmel-isi: move the peripheral clock to start/stop_stream() function
2015-03-05 5:00 [PATCH 0/3] media: atmel-isi: rework on the clock part and add runtime pm support Josh Wu
@ 2015-03-05 5:00 ` Josh Wu
2015-03-05 10:39 ` Laurent Pinchart
2015-03-05 5:01 ` [PATCH 2/3] media: atmel-isi: add runtime pm support Josh Wu
2015-03-05 5:01 ` [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it Josh Wu
2 siblings, 1 reply; 13+ messages in thread
From: Josh Wu @ 2015-03-05 5:00 UTC (permalink / raw)
To: linux-arm-kernel
As the clock_start/stop() use to control the mclk for the sensor not the
ISI peripheral clock.
So we move them to start/stop_stream() function.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
drivers/media/platform/soc_camera/atmel-isi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
index 1208818..eb179e7 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -386,6 +386,10 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
struct atmel_isi *isi = ici->priv;
int ret;
+ ret = clk_prepare_enable(isi->pclk);
+ if (ret)
+ return ret;
+
/* Reset ISI */
ret = atmel_isi_wait_status(isi, WAIT_ISI_RESET);
if (ret < 0) {
@@ -445,6 +449,8 @@ static void stop_streaming(struct vb2_queue *vq)
ret = atmel_isi_wait_status(isi, WAIT_ISI_DISABLE);
if (ret < 0)
dev_err(icd->parent, "Disable ISI timed out\n");
+
+ clk_disable_unprepare(isi->pclk);
}
static struct vb2_ops isi_video_qops = {
@@ -723,14 +729,9 @@ static int isi_camera_clock_start(struct soc_camera_host *ici)
struct atmel_isi *isi = ici->priv;
int ret;
- ret = clk_prepare_enable(isi->pclk);
- if (ret)
- return ret;
-
if (!IS_ERR(isi->mck)) {
ret = clk_prepare_enable(isi->mck);
if (ret) {
- clk_disable_unprepare(isi->pclk);
return ret;
}
}
@@ -745,7 +746,6 @@ static void isi_camera_clock_stop(struct soc_camera_host *ici)
if (!IS_ERR(isi->mck))
clk_disable_unprepare(isi->mck);
- clk_disable_unprepare(isi->pclk);
}
static unsigned int isi_camera_poll(struct file *file, poll_table *pt)
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/3] media: atmel-isi: add runtime pm support
2015-03-05 5:00 [PATCH 0/3] media: atmel-isi: rework on the clock part and add runtime pm support Josh Wu
2015-03-05 5:00 ` [PATCH 1/3] media: atmel-isi: move the peripheral clock to start/stop_stream() function Josh Wu
@ 2015-03-05 5:01 ` Josh Wu
2015-03-05 10:36 ` Laurent Pinchart
2015-03-05 5:01 ` [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it Josh Wu
2 siblings, 1 reply; 13+ messages in thread
From: Josh Wu @ 2015-03-05 5:01 UTC (permalink / raw)
To: linux-arm-kernel
The runtime pm resume/suspend will enable/disable pclk (ISI peripheral
clock).
And we need to call rumtime_pm_get/put_sync function to make pm
resume/suspend.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
drivers/media/platform/soc_camera/atmel-isi.c | 36 ++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
index eb179e7..4a384f1 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -20,6 +20,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <media/atmel-isi.h>
@@ -386,9 +387,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
struct atmel_isi *isi = ici->priv;
int ret;
- ret = clk_prepare_enable(isi->pclk);
- if (ret)
- return ret;
+ pm_runtime_get_sync(ici->v4l2_dev.dev);
/* Reset ISI */
ret = atmel_isi_wait_status(isi, WAIT_ISI_RESET);
@@ -450,7 +449,7 @@ static void stop_streaming(struct vb2_queue *vq)
if (ret < 0)
dev_err(icd->parent, "Disable ISI timed out\n");
- clk_disable_unprepare(isi->pclk);
+ pm_runtime_put_sync(ici->v4l2_dev.dev);
}
static struct vb2_ops isi_video_qops = {
@@ -1042,6 +1041,9 @@ static int atmel_isi_probe(struct platform_device *pdev)
soc_host->v4l2_dev.dev = &pdev->dev;
soc_host->nr = pdev->id;
+ pm_suspend_ignore_children(&pdev->dev, true);
+ pm_runtime_enable(&pdev->dev);
+
if (isi->pdata.asd_sizes) {
soc_host->asd = isi->pdata.asd;
soc_host->asd_sizes = isi->pdata.asd_sizes;
@@ -1055,6 +1057,7 @@ static int atmel_isi_probe(struct platform_device *pdev)
return 0;
err_register_soc_camera_host:
+ pm_runtime_disable(&pdev->dev);
err_req_irq:
err_ioremap:
vb2_dma_contig_cleanup_ctx(isi->alloc_ctx);
@@ -1067,6 +1070,30 @@ err_alloc_ctx:
return ret;
}
+static int atmel_isi_runtime_suspend(struct device *dev)
+{
+ struct soc_camera_host *soc_host = to_soc_camera_host(dev);
+ struct atmel_isi *isi = container_of(soc_host,
+ struct atmel_isi, soc_host);
+
+ clk_disable_unprepare(isi->pclk);
+
+ return 0;
+}
+static int atmel_isi_runtime_resume(struct device *dev)
+{
+ struct soc_camera_host *soc_host = to_soc_camera_host(dev);
+ struct atmel_isi *isi = container_of(soc_host,
+ struct atmel_isi, soc_host);
+
+ return clk_prepare_enable(isi->pclk);
+}
+
+static const struct dev_pm_ops atmel_isi_dev_pm_ops = {
+ SET_RUNTIME_PM_OPS(atmel_isi_runtime_suspend,
+ atmel_isi_runtime_resume, NULL)
+};
+
static const struct of_device_id atmel_isi_of_match[] = {
{ .compatible = "atmel,at91sam9g45-isi" },
{ }
@@ -1079,6 +1106,7 @@ static struct platform_driver atmel_isi_driver = {
.name = "atmel_isi",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(atmel_isi_of_match),
+ .pm = &atmel_isi_dev_pm_ops,
},
};
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it
2015-03-05 5:00 [PATCH 0/3] media: atmel-isi: rework on the clock part and add runtime pm support Josh Wu
2015-03-05 5:00 ` [PATCH 1/3] media: atmel-isi: move the peripheral clock to start/stop_stream() function Josh Wu
2015-03-05 5:01 ` [PATCH 2/3] media: atmel-isi: add runtime pm support Josh Wu
@ 2015-03-05 5:01 ` Josh Wu
2015-03-05 10:41 ` Laurent Pinchart
2 siblings, 1 reply; 13+ messages in thread
From: Josh Wu @ 2015-03-05 5:01 UTC (permalink / raw)
To: linux-arm-kernel
The master clock should handled by sensor itself.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
drivers/media/platform/soc_camera/atmel-isi.c | 32 ---------------------------
1 file changed, 32 deletions(-)
diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
index 4a384f1..50375ce 100644
--- a/drivers/media/platform/soc_camera/atmel-isi.c
+++ b/drivers/media/platform/soc_camera/atmel-isi.c
@@ -83,8 +83,6 @@ struct atmel_isi {
struct completion complete;
/* ISI peripherial clock */
struct clk *pclk;
- /* ISI_MCK, feed to camera sensor to generate pixel clock */
- struct clk *mck;
unsigned int irq;
struct isi_platform_data pdata;
@@ -725,26 +723,12 @@ static void isi_camera_remove_device(struct soc_camera_device *icd)
/* Called with .host_lock held */
static int isi_camera_clock_start(struct soc_camera_host *ici)
{
- struct atmel_isi *isi = ici->priv;
- int ret;
-
- if (!IS_ERR(isi->mck)) {
- ret = clk_prepare_enable(isi->mck);
- if (ret) {
- return ret;
- }
- }
-
return 0;
}
/* Called with .host_lock held */
static void isi_camera_clock_stop(struct soc_camera_host *ici)
{
- struct atmel_isi *isi = ici->priv;
-
- if (!IS_ERR(isi->mck))
- clk_disable_unprepare(isi->mck);
}
static unsigned int isi_camera_poll(struct file *file, poll_table *pt)
@@ -894,7 +878,6 @@ static int atmel_isi_probe_dt(struct atmel_isi *isi,
/* Default settings for ISI */
isi->pdata.full_mode = 1;
- isi->pdata.mck_hz = ISI_DEFAULT_MCLK_FREQ;
isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL;
np = of_graph_get_next_endpoint(np, NULL);
@@ -970,21 +953,6 @@ static int atmel_isi_probe(struct platform_device *pdev)
INIT_LIST_HEAD(&isi->video_buffer_list);
INIT_LIST_HEAD(&isi->dma_desc_head);
- /* ISI_MCK is the sensor master clock. It should be handled by the
- * sensor driver directly, as the ISI has no use for that clock. Make
- * the clock optional here while platforms transition to the correct
- * model.
- */
- isi->mck = devm_clk_get(dev, "isi_mck");
- if (!IS_ERR(isi->mck)) {
- /* Set ISI_MCK's frequency, it should be faster than pixel
- * clock.
- */
- ret = clk_set_rate(isi->mck, isi->pdata.mck_hz);
- if (ret < 0)
- return ret;
- }
-
isi->p_fb_descriptors = dma_alloc_coherent(&pdev->dev,
sizeof(struct fbd) * MAX_BUFFER_NUM,
&isi->fb_descriptors_phys,
--
1.9.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/3] media: atmel-isi: add runtime pm support
2015-03-05 5:01 ` [PATCH 2/3] media: atmel-isi: add runtime pm support Josh Wu
@ 2015-03-05 10:36 ` Laurent Pinchart
2015-03-06 10:10 ` Josh Wu
0 siblings, 1 reply; 13+ messages in thread
From: Laurent Pinchart @ 2015-03-05 10:36 UTC (permalink / raw)
To: linux-arm-kernel
Hi Josh,
Thank you for the patch.
On Thursday 05 March 2015 13:01:00 Josh Wu wrote:
> The runtime pm resume/suspend will enable/disable pclk (ISI peripheral
> clock).
> And we need to call rumtime_pm_get/put_sync function to make pm
> resume/suspend.
>
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> ---
>
> drivers/media/platform/soc_camera/atmel-isi.c | 36 +++++++++++++++++++++---
> 1 file changed, 32 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c
> b/drivers/media/platform/soc_camera/atmel-isi.c index eb179e7..4a384f1
> 100644
> --- a/drivers/media/platform/soc_camera/atmel-isi.c
> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
> @@ -20,6 +20,7 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
> #include <linux/slab.h>
>
> #include <media/atmel-isi.h>
> @@ -386,9 +387,7 @@ static int start_streaming(struct vb2_queue *vq,
> unsigned int count) struct atmel_isi *isi = ici->priv;
> int ret;
>
> - ret = clk_prepare_enable(isi->pclk);
> - if (ret)
> - return ret;
> + pm_runtime_get_sync(ici->v4l2_dev.dev);
>
> /* Reset ISI */
> ret = atmel_isi_wait_status(isi, WAIT_ISI_RESET);
> @@ -450,7 +449,7 @@ static void stop_streaming(struct vb2_queue *vq)
> if (ret < 0)
> dev_err(icd->parent, "Disable ISI timed out\n");
>
> - clk_disable_unprepare(isi->pclk);
> + pm_runtime_put_sync(ici->v4l2_dev.dev);
Is there a reason to use pm_runtime_put_sync() and not just pm_runtime_put() ?
> }
>
> static struct vb2_ops isi_video_qops = {
> @@ -1042,6 +1041,9 @@ static int atmel_isi_probe(struct platform_device
> *pdev) soc_host->v4l2_dev.dev = &pdev->dev;
> soc_host->nr = pdev->id;
>
> + pm_suspend_ignore_children(&pdev->dev, true);
> + pm_runtime_enable(&pdev->dev);
> +
> if (isi->pdata.asd_sizes) {
> soc_host->asd = isi->pdata.asd;
> soc_host->asd_sizes = isi->pdata.asd_sizes;
> @@ -1055,6 +1057,7 @@ static int atmel_isi_probe(struct platform_device
> *pdev) return 0;
>
> err_register_soc_camera_host:
> + pm_runtime_disable(&pdev->dev);
> err_req_irq:
> err_ioremap:
> vb2_dma_contig_cleanup_ctx(isi->alloc_ctx);
> @@ -1067,6 +1070,30 @@ err_alloc_ctx:
> return ret;
> }
>
> +static int atmel_isi_runtime_suspend(struct device *dev)
> +{
> + struct soc_camera_host *soc_host = to_soc_camera_host(dev);
> + struct atmel_isi *isi = container_of(soc_host,
> + struct atmel_isi, soc_host);
> +
> + clk_disable_unprepare(isi->pclk);
> +
> + return 0;
> +}
> +static int atmel_isi_runtime_resume(struct device *dev)
> +{
> + struct soc_camera_host *soc_host = to_soc_camera_host(dev);
> + struct atmel_isi *isi = container_of(soc_host,
> + struct atmel_isi, soc_host);
> +
> + return clk_prepare_enable(isi->pclk);
> +}
> +
> +static const struct dev_pm_ops atmel_isi_dev_pm_ops = {
> + SET_RUNTIME_PM_OPS(atmel_isi_runtime_suspend,
> + atmel_isi_runtime_resume, NULL)
> +};
> +
> static const struct of_device_id atmel_isi_of_match[] = {
> { .compatible = "atmel,at91sam9g45-isi" },
> { }
> @@ -1079,6 +1106,7 @@ static struct platform_driver atmel_isi_driver = {
> .name = "atmel_isi",
> .owner = THIS_MODULE,
> .of_match_table = of_match_ptr(atmel_isi_of_match),
> + .pm = &atmel_isi_dev_pm_ops,
> },
> };
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/3] media: atmel-isi: move the peripheral clock to start/stop_stream() function
2015-03-05 5:00 ` [PATCH 1/3] media: atmel-isi: move the peripheral clock to start/stop_stream() function Josh Wu
@ 2015-03-05 10:39 ` Laurent Pinchart
2015-03-06 10:16 ` Josh Wu
0 siblings, 1 reply; 13+ messages in thread
From: Laurent Pinchart @ 2015-03-05 10:39 UTC (permalink / raw)
To: linux-arm-kernel
Hi Josh,
Thank you for the patch.
On Thursday 05 March 2015 13:00:59 Josh Wu wrote:
> As the clock_start/stop() use to control the mclk for the sensor not the
> ISI peripheral clock.
> So we move them to start/stop_stream() function.
Then the driver will access registers with the peripheral clock disabled, for
instance in isi_camera_set_fmt() (calling configure_geometry),
isi_camera_set_bus_param() or atmel_isi_probe(). Isn't that a problem ? Or are
all registers guaranteed to be accessible (and retained) when the clock is
disabled ?
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> ---
>
> drivers/media/platform/soc_camera/atmel-isi.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c
> b/drivers/media/platform/soc_camera/atmel-isi.c index 1208818..eb179e7
> 100644
> --- a/drivers/media/platform/soc_camera/atmel-isi.c
> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
> @@ -386,6 +386,10 @@ static int start_streaming(struct vb2_queue *vq,
> unsigned int count) struct atmel_isi *isi = ici->priv;
> int ret;
>
> + ret = clk_prepare_enable(isi->pclk);
> + if (ret)
> + return ret;
> +
> /* Reset ISI */
> ret = atmel_isi_wait_status(isi, WAIT_ISI_RESET);
> if (ret < 0) {
> @@ -445,6 +449,8 @@ static void stop_streaming(struct vb2_queue *vq)
> ret = atmel_isi_wait_status(isi, WAIT_ISI_DISABLE);
> if (ret < 0)
> dev_err(icd->parent, "Disable ISI timed out\n");
> +
> + clk_disable_unprepare(isi->pclk);
> }
>
> static struct vb2_ops isi_video_qops = {
> @@ -723,14 +729,9 @@ static int isi_camera_clock_start(struct
> soc_camera_host *ici) struct atmel_isi *isi = ici->priv;
> int ret;
>
> - ret = clk_prepare_enable(isi->pclk);
> - if (ret)
> - return ret;
> -
> if (!IS_ERR(isi->mck)) {
> ret = clk_prepare_enable(isi->mck);
> if (ret) {
> - clk_disable_unprepare(isi->pclk);
> return ret;
> }
> }
> @@ -745,7 +746,6 @@ static void isi_camera_clock_stop(struct soc_camera_host
> *ici)
>
> if (!IS_ERR(isi->mck))
> clk_disable_unprepare(isi->mck);
> - clk_disable_unprepare(isi->pclk);
> }
>
> static unsigned int isi_camera_poll(struct file *file, poll_table *pt)
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it
2015-03-05 5:01 ` [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it Josh Wu
@ 2015-03-05 10:41 ` Laurent Pinchart
2015-03-06 10:13 ` Josh Wu
0 siblings, 1 reply; 13+ messages in thread
From: Laurent Pinchart @ 2015-03-05 10:41 UTC (permalink / raw)
To: linux-arm-kernel
Hi Josh,
Thank you for the patch.
On Thursday 05 March 2015 13:01:01 Josh Wu wrote:
> The master clock should handled by sensor itself.
I like that :-)
> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> ---
>
> drivers/media/platform/soc_camera/atmel-isi.c | 32 ------------------------
> 1 file changed, 32 deletions(-)
>
> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c
> b/drivers/media/platform/soc_camera/atmel-isi.c index 4a384f1..50375ce
> 100644
> --- a/drivers/media/platform/soc_camera/atmel-isi.c
> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
> @@ -83,8 +83,6 @@ struct atmel_isi {
> struct completion complete;
> /* ISI peripherial clock */
> struct clk *pclk;
> - /* ISI_MCK, feed to camera sensor to generate pixel clock */
> - struct clk *mck;
> unsigned int irq;
>
> struct isi_platform_data pdata;
> @@ -725,26 +723,12 @@ static void isi_camera_remove_device(struct
> soc_camera_device *icd) /* Called with .host_lock held */
> static int isi_camera_clock_start(struct soc_camera_host *ici)
> {
> - struct atmel_isi *isi = ici->priv;
> - int ret;
> -
> - if (!IS_ERR(isi->mck)) {
> - ret = clk_prepare_enable(isi->mck);
> - if (ret) {
> - return ret;
> - }
> - }
> -
> return 0;
Would it make sense to make the clock_start and clock_stop operations optional
in the soc-camera core ?
> }
>
> /* Called with .host_lock held */
> static void isi_camera_clock_stop(struct soc_camera_host *ici)
> {
> - struct atmel_isi *isi = ici->priv;
> -
> - if (!IS_ERR(isi->mck))
> - clk_disable_unprepare(isi->mck);
> }
>
> static unsigned int isi_camera_poll(struct file *file, poll_table *pt)
> @@ -894,7 +878,6 @@ static int atmel_isi_probe_dt(struct atmel_isi *isi,
>
> /* Default settings for ISI */
> isi->pdata.full_mode = 1;
> - isi->pdata.mck_hz = ISI_DEFAULT_MCLK_FREQ;
> isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL;
>
> np = of_graph_get_next_endpoint(np, NULL);
> @@ -970,21 +953,6 @@ static int atmel_isi_probe(struct platform_device
> *pdev) INIT_LIST_HEAD(&isi->video_buffer_list);
> INIT_LIST_HEAD(&isi->dma_desc_head);
>
> - /* ISI_MCK is the sensor master clock. It should be handled by the
> - * sensor driver directly, as the ISI has no use for that clock. Make
> - * the clock optional here while platforms transition to the correct
> - * model.
> - */
> - isi->mck = devm_clk_get(dev, "isi_mck");
> - if (!IS_ERR(isi->mck)) {
> - /* Set ISI_MCK's frequency, it should be faster than pixel
> - * clock.
> - */
> - ret = clk_set_rate(isi->mck, isi->pdata.mck_hz);
> - if (ret < 0)
> - return ret;
> - }
> -
> isi->p_fb_descriptors = dma_alloc_coherent(&pdev->dev,
> sizeof(struct fbd) * MAX_BUFFER_NUM,
> &isi->fb_descriptors_phys,
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 2/3] media: atmel-isi: add runtime pm support
2015-03-05 10:36 ` Laurent Pinchart
@ 2015-03-06 10:10 ` Josh Wu
0 siblings, 0 replies; 13+ messages in thread
From: Josh Wu @ 2015-03-06 10:10 UTC (permalink / raw)
To: linux-arm-kernel
On 3/5/2015 6:36 PM, Laurent Pinchart wrote:
> Hi Josh,
>
> Thank you for the patch.
>
> On Thursday 05 March 2015 13:01:00 Josh Wu wrote:
>> The runtime pm resume/suspend will enable/disable pclk (ISI peripheral
>> clock).
>> And we need to call rumtime_pm_get/put_sync function to make pm
>> resume/suspend.
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> ---
>>
>> drivers/media/platform/soc_camera/atmel-isi.c | 36 +++++++++++++++++++++---
>> 1 file changed, 32 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c
>> b/drivers/media/platform/soc_camera/atmel-isi.c index eb179e7..4a384f1
>> 100644
>> --- a/drivers/media/platform/soc_camera/atmel-isi.c
>> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
>> @@ -20,6 +20,7 @@
>> #include <linux/kernel.h>
>> #include <linux/module.h>
>> #include <linux/platform_device.h>
>> +#include <linux/pm_runtime.h>
>> #include <linux/slab.h>
>>
>> #include <media/atmel-isi.h>
>> @@ -386,9 +387,7 @@ static int start_streaming(struct vb2_queue *vq,
>> unsigned int count) struct atmel_isi *isi = ici->priv;
>> int ret;
>>
>> - ret = clk_prepare_enable(isi->pclk);
>> - if (ret)
>> - return ret;
>> + pm_runtime_get_sync(ici->v4l2_dev.dev);
>>
>> /* Reset ISI */
>> ret = atmel_isi_wait_status(isi, WAIT_ISI_RESET);
>> @@ -450,7 +449,7 @@ static void stop_streaming(struct vb2_queue *vq)
>> if (ret < 0)
>> dev_err(icd->parent, "Disable ISI timed out\n");
>>
>> - clk_disable_unprepare(isi->pclk);
>> + pm_runtime_put_sync(ici->v4l2_dev.dev);
> Is there a reason to use pm_runtime_put_sync() and not just pm_runtime_put() ?
right, for sure we can use pm_runtime_put() here.
Best Regards,
Josh Wu
>
>> }
>>
>> static struct vb2_ops isi_video_qops = {
>> @@ -1042,6 +1041,9 @@ static int atmel_isi_probe(struct platform_device
>> *pdev) soc_host->v4l2_dev.dev = &pdev->dev;
>> soc_host->nr = pdev->id;
>>
>> + pm_suspend_ignore_children(&pdev->dev, true);
>> + pm_runtime_enable(&pdev->dev);
>> +
>> if (isi->pdata.asd_sizes) {
>> soc_host->asd = isi->pdata.asd;
>> soc_host->asd_sizes = isi->pdata.asd_sizes;
>> @@ -1055,6 +1057,7 @@ static int atmel_isi_probe(struct platform_device
>> *pdev) return 0;
>>
>> err_register_soc_camera_host:
>> + pm_runtime_disable(&pdev->dev);
>> err_req_irq:
>> err_ioremap:
>> vb2_dma_contig_cleanup_ctx(isi->alloc_ctx);
>> @@ -1067,6 +1070,30 @@ err_alloc_ctx:
>> return ret;
>> }
>>
>> +static int atmel_isi_runtime_suspend(struct device *dev)
>> +{
>> + struct soc_camera_host *soc_host = to_soc_camera_host(dev);
>> + struct atmel_isi *isi = container_of(soc_host,
>> + struct atmel_isi, soc_host);
>> +
>> + clk_disable_unprepare(isi->pclk);
>> +
>> + return 0;
>> +}
>> +static int atmel_isi_runtime_resume(struct device *dev)
>> +{
>> + struct soc_camera_host *soc_host = to_soc_camera_host(dev);
>> + struct atmel_isi *isi = container_of(soc_host,
>> + struct atmel_isi, soc_host);
>> +
>> + return clk_prepare_enable(isi->pclk);
>> +}
>> +
>> +static const struct dev_pm_ops atmel_isi_dev_pm_ops = {
>> + SET_RUNTIME_PM_OPS(atmel_isi_runtime_suspend,
>> + atmel_isi_runtime_resume, NULL)
>> +};
>> +
>> static const struct of_device_id atmel_isi_of_match[] = {
>> { .compatible = "atmel,at91sam9g45-isi" },
>> { }
>> @@ -1079,6 +1106,7 @@ static struct platform_driver atmel_isi_driver = {
>> .name = "atmel_isi",
>> .owner = THIS_MODULE,
>> .of_match_table = of_match_ptr(atmel_isi_of_match),
>> + .pm = &atmel_isi_dev_pm_ops,
>> },
>> };
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it
2015-03-05 10:41 ` Laurent Pinchart
@ 2015-03-06 10:13 ` Josh Wu
2015-03-06 20:25 ` Guennadi Liakhovetski
0 siblings, 1 reply; 13+ messages in thread
From: Josh Wu @ 2015-03-06 10:13 UTC (permalink / raw)
To: linux-arm-kernel
On 3/5/2015 6:41 PM, Laurent Pinchart wrote:
> Hi Josh,
>
> Thank you for the patch.
>
> On Thursday 05 March 2015 13:01:01 Josh Wu wrote:
>> The master clock should handled by sensor itself.
> I like that :-)
>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> ---
>>
>> drivers/media/platform/soc_camera/atmel-isi.c | 32 ------------------------
>> 1 file changed, 32 deletions(-)
>>
>> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c
>> b/drivers/media/platform/soc_camera/atmel-isi.c index 4a384f1..50375ce
>> 100644
>> --- a/drivers/media/platform/soc_camera/atmel-isi.c
>> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
>> @@ -83,8 +83,6 @@ struct atmel_isi {
>> struct completion complete;
>> /* ISI peripherial clock */
>> struct clk *pclk;
>> - /* ISI_MCK, feed to camera sensor to generate pixel clock */
>> - struct clk *mck;
>> unsigned int irq;
>>
>> struct isi_platform_data pdata;
>> @@ -725,26 +723,12 @@ static void isi_camera_remove_device(struct
>> soc_camera_device *icd) /* Called with .host_lock held */
>> static int isi_camera_clock_start(struct soc_camera_host *ici)
>> {
>> - struct atmel_isi *isi = ici->priv;
>> - int ret;
>> -
>> - if (!IS_ERR(isi->mck)) {
>> - ret = clk_prepare_enable(isi->mck);
>> - if (ret) {
>> - return ret;
>> - }
>> - }
>> -
>> return 0;
> Would it make sense to make the clock_start and clock_stop operations optional
> in the soc-camera core ?
I agree. For those camera host which don't provide master clock for
sensor, clock_start and clock_stop should be optional.
Hi, Guennadi
Do you agree with this?
Best Regards,
Josh Wu
>
>> }
>>
>> /* Called with .host_lock held */
>> static void isi_camera_clock_stop(struct soc_camera_host *ici)
>> {
>> - struct atmel_isi *isi = ici->priv;
>> -
>> - if (!IS_ERR(isi->mck))
>> - clk_disable_unprepare(isi->mck);
>> }
>>
>> static unsigned int isi_camera_poll(struct file *file, poll_table *pt)
>> @@ -894,7 +878,6 @@ static int atmel_isi_probe_dt(struct atmel_isi *isi,
>>
>> /* Default settings for ISI */
>> isi->pdata.full_mode = 1;
>> - isi->pdata.mck_hz = ISI_DEFAULT_MCLK_FREQ;
>> isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL;
>>
>> np = of_graph_get_next_endpoint(np, NULL);
>> @@ -970,21 +953,6 @@ static int atmel_isi_probe(struct platform_device
>> *pdev) INIT_LIST_HEAD(&isi->video_buffer_list);
>> INIT_LIST_HEAD(&isi->dma_desc_head);
>>
>> - /* ISI_MCK is the sensor master clock. It should be handled by the
>> - * sensor driver directly, as the ISI has no use for that clock. Make
>> - * the clock optional here while platforms transition to the correct
>> - * model.
>> - */
>> - isi->mck = devm_clk_get(dev, "isi_mck");
>> - if (!IS_ERR(isi->mck)) {
>> - /* Set ISI_MCK's frequency, it should be faster than pixel
>> - * clock.
>> - */
>> - ret = clk_set_rate(isi->mck, isi->pdata.mck_hz);
>> - if (ret < 0)
>> - return ret;
>> - }
>> -
>> isi->p_fb_descriptors = dma_alloc_coherent(&pdev->dev,
>> sizeof(struct fbd) * MAX_BUFFER_NUM,
>> &isi->fb_descriptors_phys,
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/3] media: atmel-isi: move the peripheral clock to start/stop_stream() function
2015-03-05 10:39 ` Laurent Pinchart
@ 2015-03-06 10:16 ` Josh Wu
0 siblings, 0 replies; 13+ messages in thread
From: Josh Wu @ 2015-03-06 10:16 UTC (permalink / raw)
To: linux-arm-kernel
On 3/5/2015 6:39 PM, Laurent Pinchart wrote:
> Hi Josh,
>
> Thank you for the patch.
>
> On Thursday 05 March 2015 13:00:59 Josh Wu wrote:
>> As the clock_start/stop() use to control the mclk for the sensor not the
>> ISI peripheral clock.
>> So we move them to start/stop_stream() function.
> Then the driver will access registers with the peripheral clock disabled, for
> instance in isi_camera_set_fmt() (calling configure_geometry),
> isi_camera_set_bus_param() or atmel_isi_probe(). Isn't that a problem ? Or are
> all registers guaranteed to be accessible (and retained) when the clock is
> disabled ?
So far, I don't see any problem yet. But I'd like to be sure of that.
I'll give you the feedback after more test.
Thanks for make me head up.
Best Regards,
Josh Wu
>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> ---
>>
>> drivers/media/platform/soc_camera/atmel-isi.c | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c
>> b/drivers/media/platform/soc_camera/atmel-isi.c index 1208818..eb179e7
>> 100644
>> --- a/drivers/media/platform/soc_camera/atmel-isi.c
>> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
>> @@ -386,6 +386,10 @@ static int start_streaming(struct vb2_queue *vq,
>> unsigned int count) struct atmel_isi *isi = ici->priv;
>> int ret;
>>
>> + ret = clk_prepare_enable(isi->pclk);
>> + if (ret)
>> + return ret;
>> +
>> /* Reset ISI */
>> ret = atmel_isi_wait_status(isi, WAIT_ISI_RESET);
>> if (ret < 0) {
>> @@ -445,6 +449,8 @@ static void stop_streaming(struct vb2_queue *vq)
>> ret = atmel_isi_wait_status(isi, WAIT_ISI_DISABLE);
>> if (ret < 0)
>> dev_err(icd->parent, "Disable ISI timed out\n");
>> +
>> + clk_disable_unprepare(isi->pclk);
>> }
>>
>> static struct vb2_ops isi_video_qops = {
>> @@ -723,14 +729,9 @@ static int isi_camera_clock_start(struct
>> soc_camera_host *ici) struct atmel_isi *isi = ici->priv;
>> int ret;
>>
>> - ret = clk_prepare_enable(isi->pclk);
>> - if (ret)
>> - return ret;
>> -
>> if (!IS_ERR(isi->mck)) {
>> ret = clk_prepare_enable(isi->mck);
>> if (ret) {
>> - clk_disable_unprepare(isi->pclk);
>> return ret;
>> }
>> }
>> @@ -745,7 +746,6 @@ static void isi_camera_clock_stop(struct soc_camera_host
>> *ici)
>>
>> if (!IS_ERR(isi->mck))
>> clk_disable_unprepare(isi->mck);
>> - clk_disable_unprepare(isi->pclk);
>> }
>>
>> static unsigned int isi_camera_poll(struct file *file, poll_table *pt)
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it
2015-03-06 10:13 ` Josh Wu
@ 2015-03-06 20:25 ` Guennadi Liakhovetski
2015-03-08 0:28 ` Laurent Pinchart
0 siblings, 1 reply; 13+ messages in thread
From: Guennadi Liakhovetski @ 2015-03-06 20:25 UTC (permalink / raw)
To: linux-arm-kernel
Hi Josh, Laurent,
On Fri, 6 Mar 2015, Josh Wu wrote:
> On 3/5/2015 6:41 PM, Laurent Pinchart wrote:
> > Hi Josh,
> >
> > Thank you for the patch.
> >
> > On Thursday 05 March 2015 13:01:01 Josh Wu wrote:
> > > The master clock should handled by sensor itself.
> > I like that :-)
> >
> > > Signed-off-by: Josh Wu <josh.wu@atmel.com>
> > > ---
> > >
> > > drivers/media/platform/soc_camera/atmel-isi.c | 32
> > > ------------------------
> > > 1 file changed, 32 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/soc_camera/atmel-isi.c
> > > b/drivers/media/platform/soc_camera/atmel-isi.c index 4a384f1..50375ce
> > > 100644
> > > --- a/drivers/media/platform/soc_camera/atmel-isi.c
> > > +++ b/drivers/media/platform/soc_camera/atmel-isi.c
> > > @@ -83,8 +83,6 @@ struct atmel_isi {
> > > struct completion complete;
> > > /* ISI peripherial clock */
> > > struct clk *pclk;
> > > - /* ISI_MCK, feed to camera sensor to generate pixel clock */
> > > - struct clk *mck;
> > > unsigned int irq;
> > >
> > > struct isi_platform_data pdata;
> > > @@ -725,26 +723,12 @@ static void isi_camera_remove_device(struct
> > > soc_camera_device *icd) /* Called with .host_lock held */
> > > static int isi_camera_clock_start(struct soc_camera_host *ici)
> > > {
> > > - struct atmel_isi *isi = ici->priv;
> > > - int ret;
> > > -
> > > - if (!IS_ERR(isi->mck)) {
> > > - ret = clk_prepare_enable(isi->mck);
> > > - if (ret) {
> > > - return ret;
> > > - }
> > > - }
> > > -
> > > return 0;
> > Would it make sense to make the clock_start and clock_stop operations
> > optional
> > in the soc-camera core ?
> I agree. For those camera host which don't provide master clock for sensor,
> clock_start and clock_stop should be optional.
>
> Hi, Guennadi
>
> Do you agree with this?
Yes, sure, we can do this. Would anyone like to prepare a patch?
Thanks
Guennadi
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it
2015-03-06 20:25 ` Guennadi Liakhovetski
@ 2015-03-08 0:28 ` Laurent Pinchart
2015-03-09 1:33 ` Josh Wu
0 siblings, 1 reply; 13+ messages in thread
From: Laurent Pinchart @ 2015-03-08 0:28 UTC (permalink / raw)
To: linux-arm-kernel
On Friday 06 March 2015 21:25:36 Guennadi Liakhovetski wrote:
> On Fri, 6 Mar 2015, Josh Wu wrote:
> > On 3/5/2015 6:41 PM, Laurent Pinchart wrote:
> >> On Thursday 05 March 2015 13:01:01 Josh Wu wrote:
> >>> The master clock should handled by sensor itself.
> >>
> >> I like that :-)
> >>
> >>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
> >>> ---
> >>>
> >>> drivers/media/platform/soc_camera/atmel-isi.c | 32 -------------------
> >>> 1 file changed, 32 deletions(-)
> >>>
> >>> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c
> >>> b/drivers/media/platform/soc_camera/atmel-isi.c index 4a384f1..50375ce
> >>> 100644
> >>> --- a/drivers/media/platform/soc_camera/atmel-isi.c
> >>> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
> >>> @@ -83,8 +83,6 @@ struct atmel_isi {
> >>>
> >>> struct completion complete;
> >>> /* ISI peripherial clock */
> >>> struct clk *pclk;
> >>>
> >>> - /* ISI_MCK, feed to camera sensor to generate pixel clock */
> >>> - struct clk *mck;
> >>>
> >>> unsigned int irq;
> >>>
> >>> struct isi_platform_data pdata;
> >>>
> >>> @@ -725,26 +723,12 @@ static void isi_camera_remove_device(struct
> >>> soc_camera_device *icd) /* Called with .host_lock held */
> >>>
> >>> static int isi_camera_clock_start(struct soc_camera_host *ici)
> >>> {
> >>>
> >>> - struct atmel_isi *isi = ici->priv;
> >>> - int ret;
> >>> -
> >>> - if (!IS_ERR(isi->mck)) {
> >>> - ret = clk_prepare_enable(isi->mck);
> >>> - if (ret) {
> >>> - return ret;
> >>> - }
> >>> - }
> >>> -
> >>>
> >>> return 0;
> >>
> >> Would it make sense to make the clock_start and clock_stop operations
> >> optional in the soc-camera core ?
> >
> > I agree. For those camera host which don't provide master clock for
> > sensor, clock_start and clock_stop should be optional.
> >
> > Hi, Guennadi
> >
> > Do you agree with this?
>
> Yes, sure, we can do this. Would anyone like to prepare a patch?
Josh, would you like to do that, or should I give it a go ?
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it
2015-03-08 0:28 ` Laurent Pinchart
@ 2015-03-09 1:33 ` Josh Wu
0 siblings, 0 replies; 13+ messages in thread
From: Josh Wu @ 2015-03-09 1:33 UTC (permalink / raw)
To: linux-arm-kernel
Hi, Laurent
On 3/8/2015 8:28 AM, Laurent Pinchart wrote:
> On Friday 06 March 2015 21:25:36 Guennadi Liakhovetski wrote:
>> On Fri, 6 Mar 2015, Josh Wu wrote:
>>> On 3/5/2015 6:41 PM, Laurent Pinchart wrote:
>>>> On Thursday 05 March 2015 13:01:01 Josh Wu wrote:
>>>>> The master clock should handled by sensor itself.
>>>> I like that :-)
>>>>
>>>>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>>>>> ---
>>>>>
>>>>> drivers/media/platform/soc_camera/atmel-isi.c | 32 -------------------
>>>>> 1 file changed, 32 deletions(-)
>>>>>
>>>>> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c
>>>>> b/drivers/media/platform/soc_camera/atmel-isi.c index 4a384f1..50375ce
>>>>> 100644
>>>>> --- a/drivers/media/platform/soc_camera/atmel-isi.c
>>>>> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
>>>>> @@ -83,8 +83,6 @@ struct atmel_isi {
>>>>>
>>>>> struct completion complete;
>>>>> /* ISI peripherial clock */
>>>>> struct clk *pclk;
>>>>>
>>>>> - /* ISI_MCK, feed to camera sensor to generate pixel clock */
>>>>> - struct clk *mck;
>>>>>
>>>>> unsigned int irq;
>>>>>
>>>>> struct isi_platform_data pdata;
>>>>>
>>>>> @@ -725,26 +723,12 @@ static void isi_camera_remove_device(struct
>>>>> soc_camera_device *icd) /* Called with .host_lock held */
>>>>>
>>>>> static int isi_camera_clock_start(struct soc_camera_host *ici)
>>>>> {
>>>>>
>>>>> - struct atmel_isi *isi = ici->priv;
>>>>> - int ret;
>>>>> -
>>>>> - if (!IS_ERR(isi->mck)) {
>>>>> - ret = clk_prepare_enable(isi->mck);
>>>>> - if (ret) {
>>>>> - return ret;
>>>>> - }
>>>>> - }
>>>>> -
>>>>>
>>>>> return 0;
>>>> Would it make sense to make the clock_start and clock_stop operations
>>>> optional in the soc-camera core ?
>>> I agree. For those camera host which don't provide master clock for
>>> sensor, clock_start and clock_stop should be optional.
>>>
>>> Hi, Guennadi
>>>
>>> Do you agree with this?
>> Yes, sure, we can do this. Would anyone like to prepare a patch?
> Josh, would you like to do that, or should I give it a go ?
>
Yes, you can do that if you have time. ;-)
Best Regards,
Josh Wu
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-03-09 1:33 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 5:00 [PATCH 0/3] media: atmel-isi: rework on the clock part and add runtime pm support Josh Wu
2015-03-05 5:00 ` [PATCH 1/3] media: atmel-isi: move the peripheral clock to start/stop_stream() function Josh Wu
2015-03-05 10:39 ` Laurent Pinchart
2015-03-06 10:16 ` Josh Wu
2015-03-05 5:01 ` [PATCH 2/3] media: atmel-isi: add runtime pm support Josh Wu
2015-03-05 10:36 ` Laurent Pinchart
2015-03-06 10:10 ` Josh Wu
2015-03-05 5:01 ` [PATCH 3/3] media: atmel-isi: remove mck back compatiable code as we don't need it Josh Wu
2015-03-05 10:41 ` Laurent Pinchart
2015-03-06 10:13 ` Josh Wu
2015-03-06 20:25 ` Guennadi Liakhovetski
2015-03-08 0:28 ` Laurent Pinchart
2015-03-09 1:33 ` Josh Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).