From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: linux-media@vger.kernel.org
Cc: devicetree@vger.kernel.org,
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH v3 2/3] media: i2c: ds90ub960: Add DS90UB954 support
Date: Tue, 15 Oct 2024 11:07:36 +0300 [thread overview]
Message-ID: <20241015080737.16272-2-eagle.alexander923@gmail.com> (raw)
In-Reply-To: <20241015080737.16272-1-eagle.alexander923@gmail.com>
Add support for TI DS90UB954 FPD-Link III Deserializer.
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
v2: Avoid potentially infinite loop when checking chip frequency.
Move chip specific checks to appropriate functions.
v3: Fix Media-CI test warnings
---
drivers/media/i2c/Kconfig | 4 +--
drivers/media/i2c/ds90ub960.c | 58 ++++++++++++++++++++++++++++++++---
2 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 8ba096b8ebca..91fd2c3eb8bb 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -1604,8 +1604,8 @@ config VIDEO_DS90UB960
select V4L2_FWNODE
select VIDEO_V4L2_SUBDEV_API
help
- Device driver for the Texas Instruments DS90UB960
- FPD-Link III Deserializer and DS90UB9702 FPD-Link IV Deserializer.
+ Device driver for the Texas Instruments DS90UB954/DS90UB960
+ FPD-Link III Deserializers and DS90UB9702 FPD-Link IV Deserializer.
config VIDEO_MAX96714
tristate "Maxim MAX96714 GMSL2 deserializer"
diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
index 8000801d5810..7efe8635b221 100644
--- a/drivers/media/i2c/ds90ub960.c
+++ b/drivers/media/i2c/ds90ub960.c
@@ -403,6 +403,7 @@
#define UB960_NUM_EQ_LEVELS (UB960_MAX_EQ_LEVEL - UB960_MIN_EQ_LEVEL + 1)
enum chip_type {
+ UB954,
UB960,
UB9702,
};
@@ -815,6 +816,10 @@ static int ub960_txport_select(struct ub960_data *priv, u8 nport)
lockdep_assert_held(&priv->reg_lock);
+ /* TX port registers is shared for UB954 */
+ if (priv->hw_data->chip_type == UB954)
+ return 0;
+
if (priv->reg_current.txport == nport)
return 0;
@@ -1157,10 +1162,18 @@ static int ub960_parse_dt_txport(struct ub960_data *priv,
priv->tx_link_freq[0] = vep.link_frequencies[0];
priv->tx_data_rate = priv->tx_link_freq[0] * 2;
- if (priv->tx_data_rate != MHZ(1600) &&
- priv->tx_data_rate != MHZ(1200) &&
- priv->tx_data_rate != MHZ(800) &&
- priv->tx_data_rate != MHZ(400)) {
+ switch (priv->tx_data_rate) {
+ case MHZ(1600):
+ case MHZ(800):
+ case MHZ(400):
+ break;
+ case MHZ(1200):
+ /* UB954 does not support 1.2 Gbps */
+ if (priv->hw_data->chip_type == UB960 ||
+ priv->hw_data->chip_type == UB9702)
+ break;
+ fallthrough;
+ default:
dev_err(dev, "tx%u: invalid 'link-frequencies' value\n", nport);
ret = -EINVAL;
goto err_free_vep;
@@ -1311,6 +1324,10 @@ static void ub960_rxport_set_strobe_pos(struct ub960_data *priv,
{
u8 clk_delay, data_delay;
+ /* FIXME: After writing to this area the UB954 chip no longer responds */
+ if (priv->hw_data->chip_type == UB954)
+ return;
+
clk_delay = UB960_IR_RX_ANA_STROBE_SET_CLK_NO_EXTRA_DELAY;
data_delay = UB960_IR_RX_ANA_STROBE_SET_DATA_NO_EXTRA_DELAY;
@@ -3853,6 +3870,9 @@ static int ub960_enable_core_hw(struct ub960_data *priv)
}
switch (priv->hw_data->chip_type) {
+ case UB954:
+ model = "UB954";
+ break;
case UB960:
model = "UB960";
break;
@@ -3874,6 +3894,27 @@ static int ub960_enable_core_hw(struct ub960_data *priv)
if (ret)
goto err_pd_gpio;
+ if (priv->hw_data->chip_type == UB954) {
+ /* From DS90UB954-Q1 datasheet:
+ * "REFCLK_FREQ measurement is not synchronized. Value in this
+ * register should read twice and only considered valid if
+ * REFCLK_FREQ is unchanged between reads."
+ */
+ unsigned long timeout = jiffies + msecs_to_jiffies(100);
+
+ do {
+ u8 refclk_new;
+
+ ret = ub960_read(priv, UB960_XR_REFCLK_FREQ, &refclk_new);
+ if (ret)
+ goto err_pd_gpio;
+
+ if (refclk_new == refclk_freq)
+ break;
+ refclk_freq = refclk_new;
+ } while (time_before(jiffies, timeout));
+ }
+
dev_dbg(dev, "refclk valid %u freq %u MHz (clk fw freq %lu MHz)\n",
!!(dev_sts & BIT(4)), refclk_freq,
clk_get_rate(priv->refclk) / 1000000);
@@ -4045,6 +4086,13 @@ static void ub960_remove(struct i2c_client *client)
mutex_destroy(&priv->reg_lock);
}
+static const struct ub960_hw_data ds90ub954_hw = {
+ .chip_type = UB954,
+ .chip_family = FAMILY_FPD3,
+ .num_rxports = 2,
+ .num_txports = 1,
+};
+
static const struct ub960_hw_data ds90ub960_hw = {
.chip_type = UB960,
.chip_family = FAMILY_FPD3,
@@ -4060,6 +4108,7 @@ static const struct ub960_hw_data ds90ub9702_hw = {
};
static const struct i2c_device_id ub960_id[] = {
+ { "ds90ub954-q1", (kernel_ulong_t)&ds90ub954_hw },
{ "ds90ub960-q1", (kernel_ulong_t)&ds90ub960_hw },
{ "ds90ub9702-q1", (kernel_ulong_t)&ds90ub9702_hw },
{}
@@ -4067,6 +4116,7 @@ static const struct i2c_device_id ub960_id[] = {
MODULE_DEVICE_TABLE(i2c, ub960_id);
static const struct of_device_id ub960_dt_ids[] = {
+ { .compatible = "ti,ds90ub954-q1", .data = &ds90ub954_hw },
{ .compatible = "ti,ds90ub960-q1", .data = &ds90ub960_hw },
{ .compatible = "ti,ds90ub9702-q1", .data = &ds90ub9702_hw },
{}
--
2.39.1
next prev parent reply other threads:[~2024-10-15 8:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 8:07 [PATCH v3 1/3] media: i2c: ds90ub960: Convert IC specific variables to enums Alexander Shiyan
2024-10-15 8:07 ` Alexander Shiyan [this message]
2024-10-15 8:07 ` [PATCH v3 3/3] media: dt-bindings: i2c: ds90ub960: Add DS90UB954 support Alexander Shiyan
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=20241015080737.16272-2-eagle.alexander923@gmail.com \
--to=eagle.alexander923@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=krzk+dt@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.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;
as well as URLs for NNTP newsgroup(s).