devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jack Zhu <jack.zhu@starfivetech.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Maxime Ripard <mripard@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	"Todor Tomov" <todor.too@gmail.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	"Ezequiel Garcia" <ezequiel@vanguardiasur.com.ar>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Eugen Hristev <eugen.hristev@collabora.com>,
	<linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<changhuang.liang@starfivetech.com>
Subject: Re: [PATCH v3 6/9] media: cadence: Add operation on reset
Date: Fri, 7 Apr 2023 14:30:17 +0800	[thread overview]
Message-ID: <6b7486a4-ed01-89ed-5756-d7aca08a836d@starfivetech.com> (raw)
In-Reply-To: <20230404050615.GN16648@pendragon.ideasonboard.com>



On 2023/4/4 13:06, Laurent Pinchart wrote:
> Hi Jack,
> 
> Thank you for the patch.
> 
> On Fri, Mar 31, 2023 at 08:18:23PM +0800, Jack Zhu wrote:
>> Add operation on reset for Cadence MIPI-CSI2 RX Controller.
>> 
>> Signed-off-by: Jack Zhu <jack.zhu@starfivetech.com>
>> ---
>>  drivers/media/platform/cadence/cdns-csi2rx.c | 30 ++++++++++++++++++++
>>  1 file changed, 30 insertions(+)
>> 
>> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
>> index cc3ebb0d96f6..a1555cedb349 100644
>> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
>> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
>> @@ -13,6 +13,7 @@
>>  #include <linux/of_graph.h>
>>  #include <linux/phy/phy.h>
>>  #include <linux/platform_device.h>
>> +#include <linux/reset.h>
>>  #include <linux/slab.h>
>>  
>>  #include <media/v4l2-ctrls.h>
>> @@ -68,6 +69,9 @@ struct csi2rx_priv {
>>  	struct clk			*sys_clk;
>>  	struct clk			*p_clk;
>>  	struct clk			*pixel_clk[CSI2RX_STREAMS_MAX];
>> +	struct reset_control		*sys_rst;
>> +	struct reset_control		*p_rst;
>> +	struct reset_control		*pixel_rst[CSI2RX_STREAMS_MAX];
>>  	struct phy			*dphy;
>>  
>>  	u8				lanes[CSI2RX_LANES_MAX];
>> @@ -112,6 +116,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
>>  	if (ret)
>>  		return ret;
>>  
>> +	reset_control_deassert(csi2rx->p_rst);
>>  	csi2rx_reset(csi2rx);
>>  
>>  	reg = csi2rx->num_lanes << 8;
>> @@ -154,6 +159,8 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
>>  		if (ret)
>>  			goto err_disable_pixclk;
> 
> The loop after the err_disable_pixclk label should assert the
> pixel_rst[i] reset.
> 

OK, I will fix it.

>>  
>> +		reset_control_deassert(csi2rx->pixel_rst[i]);
>> +
>>  		writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF,
>>  		       csi2rx->base + CSI2RX_STREAM_CFG_REG(i));
>>  
>> @@ -169,6 +176,7 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
>>  	if (ret)
>>  		goto err_disable_pixclk;
>>  
>> +	reset_control_deassert(csi2rx->sys_rst);
>>  	clk_disable_unprepare(csi2rx->p_clk);
>>  
>>  	return 0;
>> @@ -188,14 +196,17 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
>>  	unsigned int i;
>>  
>>  	clk_prepare_enable(csi2rx->p_clk);
>> +	reset_control_assert(csi2rx->sys_rst);
>>  	clk_disable_unprepare(csi2rx->sys_clk);
>>  
>>  	for (i = 0; i < csi2rx->max_streams; i++) {
>>  		writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
>>  
>> +		reset_control_assert(csi2rx->pixel_rst[i]);
>>  		clk_disable_unprepare(csi2rx->pixel_clk[i]);
>>  	}
>>  
>> +	reset_control_assert(csi2rx->p_rst);
>>  	clk_disable_unprepare(csi2rx->p_clk);
>>  
>>  	if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
>> @@ -299,6 +310,17 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
>>  		return PTR_ERR(csi2rx->p_clk);
>>  	}
>>  
>> +	csi2rx->sys_rst =
>> +		devm_reset_control_get_optional_exclusive(&pdev->dev,
>> +							  "sys_rst");
> 
> You can write this on two lines:
> 
> 	csi2rx->sys_rst = devm_reset_control_get_optional_exclusive(&pdev->dev,
> 								    "sys_rst");

OK, I will modify it.

>> +	if (IS_ERR(csi2rx->sys_rst))
>> +		return PTR_ERR(csi2rx->sys_rst);
>> +
>> +	csi2rx->p_rst =
>> +		devm_reset_control_get_optional_exclusive(&pdev->dev, "p_rst");
> 
> And here,
> 
> 	csi2rx->p_rst = devm_reset_control_get_optional_exclusive(&pdev->dev,
> 								  "p_rst");
> 
> would be the same number of lines but more readable in my opinion.
> 

OK, I will modify it.

>> +	if (IS_ERR(csi2rx->p_rst))
>> +		return PTR_ERR(csi2rx->p_rst);
>> +
>>  	csi2rx->dphy = devm_phy_optional_get(&pdev->dev, "dphy");
>>  	if (IS_ERR(csi2rx->dphy)) {
>>  		dev_err(&pdev->dev, "Couldn't get external D-PHY\n");
>> @@ -350,6 +372,7 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
>>  
>>  	for (i = 0; i < csi2rx->max_streams; i++) {
>>  		char clk_name[16];
>> +		char rst_name[16];
> 
> You don't need two variables, you can rename clk_name to name, and use
> it for both clk and rst.
> 

OK, I will fix it.

> With these small issues addressed you can add my
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> in the next version.
>
OK. Thank you for your review.

>>  
>>  		snprintf(clk_name, sizeof(clk_name), "pixel_if%u_clk", i);
>>  		csi2rx->pixel_clk[i] = devm_clk_get(&pdev->dev, clk_name);
>> @@ -357,6 +380,13 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
>>  			dev_err(&pdev->dev, "Couldn't get clock %s\n", clk_name);
>>  			return PTR_ERR(csi2rx->pixel_clk[i]);
>>  		}
>> +
>> +		snprintf(rst_name, sizeof(rst_name), "pixel_if%u_rst", i);
>> +		csi2rx->pixel_rst[i] =
>> +			devm_reset_control_get_optional_exclusive(&pdev->dev,
>> +								  rst_name);
>> +		if (IS_ERR(csi2rx->pixel_rst[i]))
>> +			return PTR_ERR(csi2rx->pixel_rst[i]);
>>  	}
>>  
>>  	return 0;
> 

  reply	other threads:[~2023-04-07  6:30 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31 12:18 [PATCH v3 0/9] Add Starfive Camera Subsystem driver Jack Zhu
2023-03-31 12:18 ` [PATCH v3 1/9] media: dt-bindings: Add bindings for JH7110 Camera Subsystem Jack Zhu
2023-03-31 20:09   ` Krzysztof Kozlowski
2023-04-03  9:14     ` Jack Zhu
2023-04-03 21:48       ` Rob Herring
2023-04-04  2:44         ` Jack Zhu
2023-04-04  4:39   ` Laurent Pinchart
2023-04-07  6:20     ` Jack Zhu
2023-03-31 12:18 ` [PATCH v3 2/9] media: admin-guide: Add starfive_camss.rst for Starfive " Jack Zhu
2023-04-01  2:12   ` kernel test robot
2023-03-31 12:18 ` [PATCH v3 3/9] media: dt-bindings: cadence-csi2rx: Convert to DT schema Jack Zhu
2023-03-31 20:12   ` Krzysztof Kozlowski
2023-04-03  9:48     ` Jack Zhu
2023-04-03  9:53       ` Krzysztof Kozlowski
2023-04-04  2:26         ` Jack Zhu
2023-03-31 12:18 ` [PATCH v3 4/9] media: dt-bindings: cadence-csi2rx: Add resets property Jack Zhu
2023-03-31 20:12   ` Krzysztof Kozlowski
2023-04-04  4:56   ` Laurent Pinchart
2023-03-31 12:18 ` [PATCH v3 5/9] media: dt-bindings: cadence-csi2rx: Add starfive compatible Jack Zhu
2023-03-31 20:14   ` Krzysztof Kozlowski
2023-04-04  4:46   ` Laurent Pinchart
2023-03-31 12:18 ` [PATCH v3 6/9] media: cadence: Add operation on reset Jack Zhu
2023-04-04  5:06   ` Laurent Pinchart
2023-04-07  6:30     ` Jack Zhu [this message]
2023-03-31 12:18 ` [PATCH v3 7/9] media: cadence: Add support for external dphy Jack Zhu
2023-04-04  4:55   ` Laurent Pinchart
2023-03-31 12:18 ` [PATCH v3 8/9] media: cadence: Add support for JH7110 SoC Jack Zhu
2023-04-04  5:07   ` Laurent Pinchart
2023-04-07  6:33     ` Jack Zhu
2023-03-31 12:18 ` [PATCH v3 9/9] media: starfive: Add Starfive Camera Subsystem driver Jack Zhu
2023-03-31 14:38   ` kernel test robot
2023-04-01  5:16   ` kernel test robot

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=6b7486a4-ed01-89ed-5756-d7aca08a836d@starfivetech.com \
    --to=jack.zhu@starfivetech.com \
    --cc=changhuang.liang@starfivetech.com \
    --cc=devicetree@vger.kernel.org \
    --cc=eugen.hristev@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mripard@kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=rfoss@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=todor.too@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 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).