diff mbox series

[v3,03/46] media: sun6i-csi: Grab bus clock instead of passing it to regmap

Message ID 20220311143532.265091-4-paul.kocialkowski@bootlin.com (mailing list archive)
State New, archived
Headers show
Series Allwinner A31/A83T MIPI CSI-2 and A31 ISP / CSI Rework | expand

Commit Message

Paul Kocialkowski March 11, 2022, 2:34 p.m. UTC
Since the bus clock alone is not enough to get access to the registers,
don't pass it to regmap and manage it instead just like the other
clocks.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 10 ++++++++--
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

Comments

Jernej Škrabec March 15, 2022, 7:22 p.m. UTC | #1
Hi Paul!

Dne petek, 11. marec 2022 ob 15:34:49 CET je Paul Kocialkowski napisal(a):
> Since the bus clock alone is not enough to get access to the registers,
> don't pass it to regmap and manage it instead just like the other
> clocks.
> 

Let me ask it in another way, is bus clock needed only for register access? If 
yes, it makes sense to keep it enabled only during register access.

Best regards,
Jernej

> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 10 ++++++++--
>  drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h |  1 +
>  2 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/
media/platform/sunxi/sun6i-csi/sun6i_csi.c
> index 5fbaa1e99412..dc79f3c14336 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
> @@ -827,13 +827,19 @@ static int sun6i_csi_resource_request(struct 
sun6i_csi_device *csi_dev,
>  	if (IS_ERR(io_base))
>  		return PTR_ERR(io_base);
>  
> -	csi_dev->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "bus", 
io_base,
> -						    
&sun6i_csi_regmap_config);
> +	csi_dev->regmap = devm_regmap_init_mmio(&pdev->dev, io_base,
> +						
&sun6i_csi_regmap_config);
>  	if (IS_ERR(csi_dev->regmap)) {
>  		dev_err(&pdev->dev, "Failed to init register map\n");
>  		return PTR_ERR(csi_dev->regmap);
>  	}
>  
> +	csi_dev->clk_bus = devm_clk_get(&pdev->dev, "bus");
> +	if (IS_ERR(csi_dev->clk_bus)) {
> +		dev_err(&pdev->dev, "Unable to acquire bus clock\n");
> +		return PTR_ERR(csi_dev->clk_bus);
> +	}
> +
>  	csi_dev->clk_mod = devm_clk_get(&pdev->dev, "mod");
>  	if (IS_ERR(csi_dev->clk_mod)) {
>  		dev_err(&pdev->dev, "Unable to acquire csi clock\n");
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/
media/platform/sunxi/sun6i-csi/sun6i_csi.h
> index e4e7ac6c869f..356661b413f8 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
> @@ -51,6 +51,7 @@ struct sun6i_csi_device {
>  	struct sun6i_video		video;
>  
>  	struct regmap			*regmap;
> +	struct clk			*clk_bus;
>  	struct clk			*clk_mod;
>  	struct clk			*clk_ram;
>  	struct reset_control		*reset;
> -- 
> 2.35.1
> 
>
Paul Kocialkowski March 18, 2022, 8:49 a.m. UTC | #2
Hi Jernej,

On Tue 15 Mar 22, 20:22, Jernej Škrabec wrote:
> Hi Paul!
> 
> Dne petek, 11. marec 2022 ob 15:34:49 CET je Paul Kocialkowski napisal(a):
> > Since the bus clock alone is not enough to get access to the registers,
> > don't pass it to regmap and manage it instead just like the other
> > clocks.
> > 
> 
> Let me ask it in another way, is bus clock needed only for register access? If 
> yes, it makes sense to keep it enabled only during register access.

Ah right, I lost sight that what regmap will do is to enable/disable the
clock around register access. I understand there might be an advantage
in terms of power consumption here.

I haven't checked specifically, but since it was used like that before
it's probably fine.

Out of curiosity: is there any noticeable latency added by the process?

Cheers,

Paul

> Best regards,
> Jernej
> 
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > ---
> >  drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 10 ++++++++--
> >  drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h |  1 +
> >  2 files changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/
> media/platform/sunxi/sun6i-csi/sun6i_csi.c
> > index 5fbaa1e99412..dc79f3c14336 100644
> > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
> > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
> > @@ -827,13 +827,19 @@ static int sun6i_csi_resource_request(struct 
> sun6i_csi_device *csi_dev,
> >  	if (IS_ERR(io_base))
> >  		return PTR_ERR(io_base);
> >  
> > -	csi_dev->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "bus", 
> io_base,
> > -						    
> &sun6i_csi_regmap_config);
> > +	csi_dev->regmap = devm_regmap_init_mmio(&pdev->dev, io_base,
> > +						
> &sun6i_csi_regmap_config);
> >  	if (IS_ERR(csi_dev->regmap)) {
> >  		dev_err(&pdev->dev, "Failed to init register map\n");
> >  		return PTR_ERR(csi_dev->regmap);
> >  	}
> >  
> > +	csi_dev->clk_bus = devm_clk_get(&pdev->dev, "bus");
> > +	if (IS_ERR(csi_dev->clk_bus)) {
> > +		dev_err(&pdev->dev, "Unable to acquire bus clock\n");
> > +		return PTR_ERR(csi_dev->clk_bus);
> > +	}
> > +
> >  	csi_dev->clk_mod = devm_clk_get(&pdev->dev, "mod");
> >  	if (IS_ERR(csi_dev->clk_mod)) {
> >  		dev_err(&pdev->dev, "Unable to acquire csi clock\n");
> > diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/
> media/platform/sunxi/sun6i-csi/sun6i_csi.h
> > index e4e7ac6c869f..356661b413f8 100644
> > --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
> > +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
> > @@ -51,6 +51,7 @@ struct sun6i_csi_device {
> >  	struct sun6i_video		video;
> >  
> >  	struct regmap			*regmap;
> > +	struct clk			*clk_bus;
> >  	struct clk			*clk_mod;
> >  	struct clk			*clk_ram;
> >  	struct reset_control		*reset;
> > -- 
> > 2.35.1
> > 
> > 
> 
>
diff mbox series

Patch

diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
index 5fbaa1e99412..dc79f3c14336 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
@@ -827,13 +827,19 @@  static int sun6i_csi_resource_request(struct sun6i_csi_device *csi_dev,
 	if (IS_ERR(io_base))
 		return PTR_ERR(io_base);
 
-	csi_dev->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "bus", io_base,
-						    &sun6i_csi_regmap_config);
+	csi_dev->regmap = devm_regmap_init_mmio(&pdev->dev, io_base,
+						&sun6i_csi_regmap_config);
 	if (IS_ERR(csi_dev->regmap)) {
 		dev_err(&pdev->dev, "Failed to init register map\n");
 		return PTR_ERR(csi_dev->regmap);
 	}
 
+	csi_dev->clk_bus = devm_clk_get(&pdev->dev, "bus");
+	if (IS_ERR(csi_dev->clk_bus)) {
+		dev_err(&pdev->dev, "Unable to acquire bus clock\n");
+		return PTR_ERR(csi_dev->clk_bus);
+	}
+
 	csi_dev->clk_mod = devm_clk_get(&pdev->dev, "mod");
 	if (IS_ERR(csi_dev->clk_mod)) {
 		dev_err(&pdev->dev, "Unable to acquire csi clock\n");
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
index e4e7ac6c869f..356661b413f8 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.h
@@ -51,6 +51,7 @@  struct sun6i_csi_device {
 	struct sun6i_video		video;
 
 	struct regmap			*regmap;
+	struct clk			*clk_bus;
 	struct clk			*clk_mod;
 	struct clk			*clk_ram;
 	struct reset_control		*reset;