Commit 618aba51 authored by Tomi Valkeinen's avatar Tomi Valkeinen Committed by Mauro Carvalho Chehab

media: i2c: ds90ub953: Support non-sync mode

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: default avatarTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent d7d7a9ab
...@@ -145,6 +145,7 @@ struct ub953_data { ...@@ -145,6 +145,7 @@ struct ub953_data {
struct i2c_client *client; struct i2c_client *client;
struct regmap *regmap; struct regmap *regmap;
struct clk *clkin;
u32 num_data_lanes; u32 num_data_lanes;
bool non_continous_clk; bool non_continous_clk;
...@@ -844,15 +845,21 @@ static int ub953_i2c_master_init(struct ub953_data *priv) ...@@ -844,15 +845,21 @@ static int ub953_i2c_master_init(struct ub953_data *priv)
static u64 ub953_get_fc_rate(struct ub953_data *priv) static u64 ub953_get_fc_rate(struct ub953_data *priv)
{ {
if (priv->mode != UB953_MODE_SYNC) { switch (priv->mode) {
/* Not supported */ case UB953_MODE_SYNC:
return 0;
}
if (priv->hw_data->is_ub971) if (priv->hw_data->is_ub971)
return priv->plat_data->bc_rate * 160ull; return priv->plat_data->bc_rate * 160ull;
else else
return priv->plat_data->bc_rate / 2 * 160ull; 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;
}
} }
static unsigned long ub953_calc_clkout_ub953(struct ub953_data *priv, static unsigned long ub953_calc_clkout_ub953(struct ub953_data *priv,
...@@ -1195,9 +1202,15 @@ static int ub953_hw_init(struct ub953_data *priv) ...@@ -1195,9 +1202,15 @@ static int ub953_hw_init(struct ub953_data *priv)
dev_dbg(dev, "mode from %s: %#x\n", mode_override ? "reg" : "strap", dev_dbg(dev, "mode from %s: %#x\n", mode_override ? "reg" : "strap",
priv->mode); 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, return dev_err_probe(dev, -ENODEV,
"Only synchronous mode supported\n"); "Unsupported mode selected: %u\n",
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); ret = ub953_read(priv, UB953_REG_REV_MASK_ID, &v);
if (ret) if (ret)
...@@ -1314,6 +1327,13 @@ static int ub953_probe(struct i2c_client *client) ...@@ -1314,6 +1327,13 @@ static int ub953_probe(struct i2c_client *client)
goto err_mutex_destroy; goto err_mutex_destroy;
} }
priv->clkin = devm_clk_get_optional(dev, "clkin");
if (IS_ERR(priv->clkin)) {
ret = PTR_ERR(priv->clkin);
dev_err_probe(dev, ret, "failed to parse 'clkin'\n");
goto err_mutex_destroy;
}
ret = ub953_parse_dt(priv); ret = ub953_parse_dt(priv);
if (ret) if (ret)
goto err_mutex_destroy; goto err_mutex_destroy;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment