From: Robert Foss <robert.foss@linaro.org>
To: ben.kao@intel.com, mchehab@kernel.org, robh+dt@kernel.org,
mark.rutland@arm.com, matthias.bgg@gmail.com,
davem@davemloft.net, gregkh@linuxfoundation.org,
Jonathan.Cameron@huawei.com, andriy.shevchenko@linux.intel.com,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Dongchun Zhu <dongchun.zhu@mediatek.com>
Cc: Tomasz Figa <tfiga@chromium.org>, Robert Foss <robert.foss@linaro.org>
Subject: [v1 3/3] media: ov8856: Implement sensor module revision identification
Date: Tue, 10 Mar 2020 14:46:03 +0100 [thread overview]
Message-ID: <20200310134603.30260-4-robert.foss@linaro.org> (raw)
In-Reply-To: <20200310134603.30260-1-robert.foss@linaro.org>
Query the sensor for its module revision, and compare it
to known revisions.
Currently only the '1B' revision has been added.
Signed-off-by: Robert Foss <robert.foss@linaro.org>
---
drivers/media/i2c/ov8856.c | 48 ++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c
index 1769acdfaa44..48e8f4b997d6 100644
--- a/drivers/media/i2c/ov8856.c
+++ b/drivers/media/i2c/ov8856.c
@@ -34,6 +34,18 @@
#define OV8856_MODE_STANDBY 0x00
#define OV8856_MODE_STREAMING 0x01
+/* define 1B module revision */
+#define OV8856_1B_MODULE 0x02
+
+/* the OTP read-out buffer is at 0x7000 and 0xf is the offset
+ * of the byte in the OTP that means the module revision
+ */
+#define OV8856_MODULE_REVISION 0x700f
+#define OV8856_OTP_MODE_CTRL 0x3d84
+#define OV8856_OTP_LOAD_CTRL 0x3d81
+#define OV8856_OTP_MODE_AUTO 0x00
+#define OV8856_OTP_LOAD_CTRL_ENABLE BIT(0)
+
/* vertical-timings from sensor */
#define OV8856_REG_VTS 0x380e
#define OV8856_VTS_MAX 0x7fff
@@ -713,6 +725,25 @@ static int ov8856_test_pattern(struct ov8856 *ov8856, u32 pattern)
OV8856_REG_VALUE_08BIT, pattern);
}
+static int ov8856_check_revision(struct ov8856 *ov8856)
+{
+ int ret;
+
+ ret = ov8856_write_reg(ov8856, OV8856_REG_MODE_SELECT,
+ OV8856_REG_VALUE_08BIT, OV8856_MODE_STREAMING);
+ if (ret)
+ return ret;
+
+ ret = ov8856_write_reg(ov8856, OV8856_OTP_MODE_CTRL,
+ OV8856_REG_VALUE_08BIT, OV8856_OTP_MODE_AUTO);
+ if (ret)
+ return ret;
+
+ return ov8856_write_reg(ov8856, OV8856_OTP_LOAD_CTRL,
+ OV8856_REG_VALUE_08BIT,
+ OV8856_OTP_LOAD_CTRL_ENABLE);
+}
+
static int ov8856_set_ctrl(struct v4l2_ctrl *ctrl)
{
struct ov8856 *ov8856 = container_of(ctrl->handler,
@@ -1145,6 +1176,23 @@ static int ov8856_identify_module(struct ov8856 *ov8856)
return -ENXIO;
}
+ /* check sensor hardware revision */
+ ret = ov8856_check_revision(ov8856);
+ if (ret) {
+ dev_err(&client->dev, "failed to check sensor revision");
+ return ret;
+ }
+
+ ret = ov8856_read_reg(ov8856, OV8856_MODULE_REVISION,
+ OV8856_REG_VALUE_08BIT, &val);
+ if (ret)
+ return ret;
+
+ dev_info(&client->dev, "OV8856 revision %x (%s) at address 0x%02x\n",
+ val,
+ val == OV8856_1B_MODULE ? "1B" : "unknown revision",
+ client->addr);
+
return 0;
}
--
2.20.1
next prev parent reply other threads:[~2020-03-10 13:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-10 13:46 [v1 0/3] media: ov8856: Add sensor modes & devicetree support Robert Foss
2020-03-10 13:46 ` [v1 1/3] media: dt-bindings: ov8856: Document YAML bindings Robert Foss
2020-03-10 13:57 ` Fabio Estevam
2020-03-10 15:51 ` Robert Foss
2020-03-12 10:13 ` Robert Foss
2020-03-10 18:38 ` Rob Herring
2020-03-10 13:46 ` [v1 2/3] media: ov8856: Add devicetree support Robert Foss
2020-03-10 14:03 ` Fabio Estevam
2020-03-10 15:46 ` Robert Foss
2020-03-10 14:26 ` Andy Shevchenko
2020-03-10 15:55 ` Robert Foss
2020-03-11 9:05 ` Andy Shevchenko
2020-03-11 11:48 ` Sakari Ailus
2020-03-11 13:32 ` Robert Foss
2020-03-11 13:32 ` Robert Foss
2020-03-11 16:16 ` Sakari Ailus
2020-03-10 13:46 ` Robert Foss [this message]
2020-03-10 14:30 ` [v1 3/3] media: ov8856: Implement sensor module revision identification Andy Shevchenko
2020-03-12 16:37 ` Robert Foss
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=20200310134603.30260-4-robert.foss@linaro.org \
--to=robert.foss@linaro.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ben.kao@intel.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dongchun.zhu@mediatek.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=robh+dt@kernel.org \
--cc=tfiga@chromium.org \
/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).