public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Luca Ceresoli <luca.ceresoli@bootlin.com>,
	Andy Shevchenko <andriy.shevchenko@intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Satish Nagireddy <satish.nagireddy@getcruise.com>,
	Matti Vaittinen <mazziesaccount@gmail.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 7/8] media: i2c: ds90ub953: Support non-sync mode
Date: Tue, 25 Jul 2023 19:44:12 +0300	[thread overview]
Message-ID: <20230725164412.GM31069@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230720-fpdlink-additions-v2-7-b91b1eca2ad3@ideasonboard.com>

Hi Tomi,

Thank you for the patch.

On Thu, Jul 20, 2023 at 01:30:38PM +0300, Tomi Valkeinen wrote:
> Add support for FPD-Link non-sync mode with external clock. The only
> thing that needs to be added is the calculation for the clkout.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  drivers/media/i2c/ds90ub953.c | 34 ++++++++++++++++++++++++++--------
>  1 file changed, 26 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
> index 3a19c6dedd2f..846542e6e20d 100644
> --- a/drivers/media/i2c/ds90ub953.c
> +++ b/drivers/media/i2c/ds90ub953.c
> @@ -143,6 +143,7 @@ struct ub953_data {
>  
>  	struct i2c_client	*client;
>  	struct regmap		*regmap;
> +	struct clk		*clkin;
>  
>  	u32			num_data_lanes;
>  	bool			non_cont_clk;
> @@ -842,15 +843,21 @@ static int ub953_i2c_master_init(struct ub953_data *priv)
>  
>  static u64 ub953_get_fc_rate(struct ub953_data *priv)
>  {
> -	if (priv->mode != UB953_MODE_SYNC) {
> +	switch (priv->mode) {
> +	case UB953_MODE_SYNC:
> +		if (priv->hw_data->is_ub971)
> +			return priv->plat_data->bc_rate * 160ull;
> +		else
> +			return priv->plat_data->bc_rate / 2 * 160ull;
> +
> +	case UB953_MODE_NONSYNC_EXT:
> +		/* CLKIN_DIV = 1 always */
> +		return clk_get_rate(priv->clkin) * 80ull;
> +
> +	default:
>  		/* Not supported */
>  		return 0;
>  	}
> -
> -	if (priv->hw_data->is_ub971)
> -		return priv->plat_data->bc_rate * 160ull;
> -	else
> -		return priv->plat_data->bc_rate / 2 * 160ull;
>  }
>  
>  static unsigned long ub953_calc_clkout_ub953(struct ub953_data *priv,
> @@ -1188,9 +1195,15 @@ static int ub953_hw_init(struct ub953_data *priv)
>  	dev_dbg(dev, "mode from %s: %#x\n", mode_override ? "reg" : "strap",
>  		priv->mode);
>  
> -	if (priv->mode != UB953_MODE_SYNC)
> +	if (priv->mode != UB953_MODE_SYNC &&
> +	    priv->mode != UB953_MODE_NONSYNC_EXT)
>  		return dev_err_probe(dev, -ENODEV,
> -				     "Only synchronous mode supported\n");
> +				     "Unsupported mode selected: %d\n",

%u

> +				     priv->mode);
> +
> +	if (priv->mode == UB953_MODE_NONSYNC_EXT && !priv->clkin)
> +		return dev_err_probe(dev, -EINVAL,
> +				     "clkin required for non-sync ext mode\n");
>  
>  	ret = ub953_read(priv, UB953_REG_REV_MASK_ID, &v);
>  	if (ret)
> @@ -1318,6 +1331,11 @@ static int ub953_probe(struct i2c_client *client)
>  		goto err_mutex_destroy;
>  	}
>  
> +	priv->clkin = devm_clk_get_optional(dev, "clkin");
> +	if (IS_ERR(priv->clkin))
> +		return dev_err_probe(dev, PTR_ERR(priv->clkin),
> +				     "failed to parse 'clkin'\n");

You need to goto err_mutex_destroy.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +
>  	ret = ub953_parse_dt(priv);
>  	if (ret)
>  		goto err_mutex_destroy;
> 

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2023-07-25 16:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 10:30 [PATCH v2 0/8] media: i2c: ds90ub9xx: Misc improvements Tomi Valkeinen
2023-07-20 10:30 ` [PATCH v2 1/8] media: i2c: ds90ub960: Configure CSI-2 continuous clock Tomi Valkeinen
2023-07-25 16:29   ` Laurent Pinchart
2023-07-20 10:30 ` [PATCH v2 2/8] media: i2c: ds90ub953: Use v4l2_fwnode_endpoint_parse() Tomi Valkeinen
2023-07-25 16:30   ` Laurent Pinchart
2023-07-20 10:30 ` [PATCH v2 3/8] media: i2c: ds90ub913: " Tomi Valkeinen
2023-07-25 16:34   ` Laurent Pinchart
2023-07-20 10:30 ` [PATCH v2 4/8] media: i2c: ds90ub953: Handle V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK Tomi Valkeinen
2023-07-25 16:36   ` Laurent Pinchart
2023-07-20 10:30 ` [PATCH v2 5/8] media: i2c: ds90ub960: Allow FPD-Link async mode Tomi Valkeinen
2023-07-25 16:38   ` Laurent Pinchart
2023-07-20 10:30 ` [PATCH v2 6/8] media: i2c: ds90ub953: Restructure clkout management Tomi Valkeinen
2023-07-21 10:29   ` Andy Shevchenko
2023-07-21 13:23     ` Tomi Valkeinen
2023-07-21 13:44       ` Andy Shevchenko
2023-07-25 16:50   ` Laurent Pinchart
2023-07-20 10:30 ` [PATCH v2 7/8] media: i2c: ds90ub953: Support non-sync mode Tomi Valkeinen
2023-07-25 16:44   ` Laurent Pinchart [this message]
2023-07-20 10:30 ` [PATCH v2 8/8] media: i2c: ds90ub960: Rename RXPORT_MODE_CSI2_ASYNC to RXPORT_MODE_CSI2_NONSYNC Tomi Valkeinen
2023-07-25 16:45   ` Laurent Pinchart
2023-07-21 10:32 ` [PATCH v2 0/8] media: i2c: ds90ub9xx: Misc improvements Andy Shevchenko

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=20230725164412.GM31069@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=mazziesaccount@gmail.com \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=satish.nagireddy@getcruise.com \
    --cc=tomi.valkeinen@ideasonboard.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