summaryrefslogtreecommitdiffstats
path: root/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas
diff options
context:
space:
mode:
authorVladimir Barinov <vladimir.barinov@cogentembedded.com>2017-07-14 22:54:16 +0300
committerVladimir Barinov <vladimir.barinov@cogentembedded.com>2017-07-14 22:54:16 +0300
commitc11ff1e06ad65e555344424ce6545bbfec41fef2 (patch)
treea5509e7f1f176a75090aefbcb0a3e159b4d3aaa3 /meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas
parent5f7f9577f2f3351884af70de000812ddbd88b066 (diff)
ov490 switch to vendor's firmware, OV495 OTP ID
1) This adds default RDCAM21/RDCAM24 firmware: /usr/share/factory/rcarm21.rdcam24.1280x1080@30.bin If firmware flashed with Cogent samples then it is possible to rollback using script: /usr/share/factory/rdcam21.rdcam24.1280x1080@30.bin ov495: change YUYV -> UYVY ti964/ti954: use FSIN reference clock from camera port0 2) Add ov495 OTP ID
Diffstat (limited to 'meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas')
-rw-r--r--meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0030-Gen3-LVDS-cameras.patch163
1 files changed, 76 insertions, 87 deletions
diff --git a/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0030-Gen3-LVDS-cameras.patch b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0030-Gen3-LVDS-cameras.patch
index 82d93d4..c560ec4 100644
--- a/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0030-Gen3-LVDS-cameras.patch
+++ b/meta-rcar-gen3-adas/recipes-kernel/linux/linux-renesas/0030-Gen3-LVDS-cameras.patch
@@ -17,12 +17,12 @@ Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
drivers/media/i2c/soc_camera/ov10635.h | 1139 ++++++++++++++++++++++
drivers/media/i2c/soc_camera/ov10635_debug.h | 54 +
drivers/media/i2c/soc_camera/ov106xx.c | 95 ++
- drivers/media/i2c/soc_camera/ov490_ov10640.c | 963 ++++++++++++++++++
+ drivers/media/i2c/soc_camera/ov490_ov10640.c | 961 ++++++++++++++++++
drivers/media/i2c/soc_camera/ov490_ov10640.h | 82 ++
- drivers/media/i2c/soc_camera/ov495_ov2775.c | 670 +++++++++++++
- drivers/media/i2c/soc_camera/ov495_ov2775.h | 18 +
- drivers/media/i2c/soc_camera/ti954_ti9x3.c | 414 ++++++++
- drivers/media/i2c/soc_camera/ti964_ti9x3.c | 382 ++++++++
+ drivers/media/i2c/soc_camera/ov495_ov2775.c | 650 ++++++++++++
+ drivers/media/i2c/soc_camera/ov495_ov2775.h | 23 +
+ drivers/media/i2c/soc_camera/ti954_ti9x3.c | 417 ++++++++
+ drivers/media/i2c/soc_camera/ti964_ti9x3.c | 385 ++++++++
drivers/media/i2c/soc_camera/ti9x4_ti9x3.h | 108 ++
drivers/media/platform/soc_camera/rcar_csi2.c | 297 ++++--
drivers/media/platform/soc_camera/rcar_vin.c | 159 ++-
@@ -30,7 +30,7 @@ Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
drivers/media/platform/soc_camera/soc_mediabus.c | 16 +
include/media/drv-intf/soc_mediabus.h | 3 +
include/media/soc_camera.h | 1 +
- 21 files changed, 5872 insertions(+), 109 deletions(-)
+ 21 files changed, 5861 insertions(+), 109 deletions(-)
create mode 100644 drivers/media/i2c/soc_camera/max9286_max9271.c
create mode 100644 drivers/media/i2c/soc_camera/max9286_max9271.h
create mode 100644 drivers/media/i2c/soc_camera/ov10635.c
@@ -2958,10 +2958,10 @@ index 0000000..0079bb2
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/i2c/soc_camera/ov490_ov10640.c b/drivers/media/i2c/soc_camera/ov490_ov10640.c
new file mode 100644
-index 0000000..dfd410a
+index 0000000..308fe1b
--- /dev/null
+++ b/drivers/media/i2c/soc_camera/ov490_ov10640.c
-@@ -0,0 +1,963 @@
+@@ -0,0 +1,961 @@
+/*
+ * OmniVision ov490-ov10640 sensor camera driver
+ *
@@ -2993,7 +2993,6 @@ index 0000000..dfd410a
+#define OV490_VER 0x300b
+#define OV490_VERSION_REG 0x0490
+#define OV490_VERSION(pid, ver) (((pid) << 8) | ((ver) & 0xff))
-+#define OV490_REV 0x0007
+
+#define OV490_ISP_HSIZE_LOW 0x60
+#define OV490_ISP_HSIZE_HIGH 0x61
@@ -3630,7 +3629,7 @@ index 0000000..dfd410a
+{
+ struct ov490_priv *priv = to_ov490(client);
+ u8 val = 0;
-+ u8 pid = 0, ver = 0, rev = 0;
++ u8 pid = 0, ver = 0;
+ int ret = 0;
+
+ if (priv->is_fixed_sensor) {
@@ -3646,7 +3645,6 @@ index 0000000..dfd410a
+ usleep_range(100, 150); /* wait 100 us */
+ reg16_read(client, OV490_PID, &pid);
+ reg16_read(client, OV490_VER, &ver);
-+ reg16_read(client, OV490_REV, &rev);
+
+ if (OV490_VERSION(pid, ver) != OV490_VERSION_REG) {
+ dev_dbg(&client->dev, "Product ID error %x:%x\n", pid, ver);
@@ -3680,8 +3678,8 @@ index 0000000..dfd410a
+ ov490_otp_id_read(client);
+
+out:
-+ dev_info(&client->dev, "ov490/ov10640 Product ID %x Manufacturer ID %x, rev 1%x, res %dx%d, OTP_ID %02x:%02x:%02x:%02x:%02x:%02x\n",
-+ pid, ver, 0xa + rev, priv->max_width, priv->max_height, priv->id[0], priv->id[1], priv->id[2], priv->id[3], priv->id[4], priv->id[5]);
++ dev_info(&client->dev, "ov490/ov10640 PID %x%x, res %dx%d, OTP_ID %02x:%02x:%02x:%02x:%02x:%02x\n",
++ pid, ver, priv->max_width, priv->max_height, priv->id[0], priv->id[1], priv->id[2], priv->id[3], priv->id[4], priv->id[5]);
+err:
+ ov490_s_port(client, 0);
+
@@ -3927,7 +3925,7 @@ index 0000000..dfd410a
+#endif
diff --git a/drivers/media/i2c/soc_camera/ov490_ov10640.h b/drivers/media/i2c/soc_camera/ov490_ov10640.h
new file mode 100644
-index 0000000..0e6197d
+index 0000000..dde81ef
--- /dev/null
+++ b/drivers/media/i2c/soc_camera/ov490_ov10640.h
@@ -0,0 +1,82 @@
@@ -3963,21 +3961,12 @@ index 0000000..0e6197d
+{0xfffe, 0x80},
+{0x0091, 0x00},
+{0x00bb, 0x1d}, // bit[3]=0 - PCLK polarity workaround
-+/* ov10635 FSIN */
-+{0xfffd, 0x80},
-+{0xfffe, 0x19},
-+{0x5000, 0x00},
-+{0x5001, 0x30},
-+{0x5002, 0x8c},
-+{0x5003, 0xb2},
-+{0xfffe, 0x80},
-+{0x00c0, 0xc1},
+/* ov10635 EMB line disable */
+{0xfffe, 0x19},
+{0x5000, 0x00},
+{0x5001, 0x30},
+{0x5002, 0x91},
-+{0x5003, 0x00},
++{0x5003, 0x08},
+{0xfffe, 0x80},
+{0x00c0, 0xc1},
+/* Ov490 FSIN: app_fsin_from_fsync */
@@ -4012,13 +4001,22 @@ index 0000000..0e6197d
+{0x0007, 0x00},
+{0xfffe, 0x80},
+{0x0081, 0x00}, // 03;SENSOR FSIN
++/* ov10635 FSIN */
++{0xfffd, 0x80},
++{0xfffe, 0x19},
++{0x5000, 0x00},
++{0x5001, 0x30},
++{0x5002, 0x8c},
++{0x5003, 0xb2},
++{0xfffe, 0x80},
++{0x00c0, 0xc1},
+};
diff --git a/drivers/media/i2c/soc_camera/ov495_ov2775.c b/drivers/media/i2c/soc_camera/ov495_ov2775.c
new file mode 100644
-index 0000000..3f55778
+index 0000000..56891ff
--- /dev/null
+++ b/drivers/media/i2c/soc_camera/ov495_ov2775.c
-@@ -0,0 +1,670 @@
+@@ -0,0 +1,650 @@
+/*
+ * OmniVision ov495-ov2775 sensor camera driver
+ *
@@ -4049,7 +4047,6 @@ index 0000000..3f55778
+#define OV495_VER 0x300b
+#define OV495_VERSION_REG 0x0495
+#define OV495_VERSION(pid, ver) (((pid) << 8) | ((ver) & 0xff))
-+#define OV495_REV 0x0007
+
+#define OV495_ISP_HSIZE_LOW 0x60
+#define OV495_ISP_HSIZE_HIGH 0x61
@@ -4068,7 +4065,6 @@ index 0000000..3f55778
+ int exposure;
+ int gain;
+ int autogain;
-+ int dvp_order;
+ /* serializers */
+ int max9286_addr;
+ int max9271_addr;
@@ -4366,53 +4362,43 @@ index 0000000..3f55778
+
+static void ov495_otp_id_read(struct i2c_client *client)
+{
-+#if 0
+ struct ov495_priv *priv = to_ov495(client);
+ int i;
+
++#if 0
+ /* read camera id from ov495 OTP memory */
+ reg16_write(client, 0xFFFD, 0x80);
-+ reg16_write(client, 0xFFFE, 0x28);
++ reg16_write(client, 0xFFFE, 0x20);
+ usleep_range(100, 150); /* wait 100 us */
-+ reg16_write(client, 0xE084, 0x40); /* manual mode, bank#0 */
-+ reg16_write(client, 0xE081, 1); /* start OTP read */
++ reg16_write(client, 0x7384, 0x40); /* manual mode, bank#0 */
++ reg16_write(client, 0x7381, 1); /* start OTP read */
+
+ usleep_range(25000, 26000); /* wait 25 ms */
+
+ for (i = 0; i < 6; i++)
-+ reg16_read(client, 0xe000 + i + 4, &priv->id[i]);
++ reg16_read(client, 0x7300 + i + 4, &priv->id[i]);
+#else
-+#if 0
+ /* read camera id from ov2775 OTP memory */
-+ reg16_write(client, 0xFFFD, 0x80);
-+ usleep_range(100, 150); /* wait 100 us */
-+ reg16_write(client, 0xFFFE, 0x19);
-+ usleep_range(100, 150); /* wait 100 us */
-+ reg16_write(client, 0x5000, 0x00); /* write 0x349C -> 1 */
-+ reg16_write(client, 0x5001, 0x34);
-+ reg16_write(client, 0x5002, 0x9C);
-+ reg16_write(client, 0x5003, 1);
-+ reg16_write(client, 0xFFFE, 0x80);
-+ usleep_range(100, 150); /* wait 100 us */
-+ reg16_write(client, 0x00C0, 0xc1);
++ reg16_write(client, 0x3516, 0x00); /* unlock write */
++ reg16_write(client, 0x0FFC, 0);
++ reg16_write(client, 0x0500, 0x00); /* write 0x34a1 -> 1 */
++ reg16_write(client, 0x0501, 0x34);
++ reg16_write(client, 0x0502, 0xa1);
++ reg16_write(client, 0x0503, 1);
++ reg16_write(client, 0x30C0, 0xc1);
+
+ usleep_range(25000, 25500); /* wait 25 ms */
+
+ for (i = 0; i < 6; i++) {
-+ reg16_write(client, 0xFFFE, 0x19);
-+ usleep_range(100, 150); /* wait 100 us */
-+ reg16_write(client, 0x5000, 0x01); /* read (0x349E + i) */
-+ reg16_write(client, 0x5001, 0x34);
-+ reg16_write(client, 0x5002, 0x9e + i + 6); /* first 6 bytes are equal on all ov2775 */
-+ reg16_write(client, 0xFFFE, 0x80);
-+ usleep_range(100, 150); /* wait 100 us */
-+ reg16_write(client, 0x00C0, 0xc1);
-+ reg16_write(client, 0xFFFE, 0x19);
++ reg16_write(client, 0x3516, 0x00); /* unlock write */
++ reg16_write(client, 0x0500, 0x01); /* read (0x7a00 + i) */
++ reg16_write(client, 0x0501, 0x7a);
++ reg16_write(client, 0x0502, 0x00 + i + (i < 3 ? 11 : 3)); /* take bytes 11,12,13,6,7,8 */
++ reg16_write(client, 0x30C0, 0xc1);
+ usleep_range(1000, 1500); /* wait 1 ms */
-+ reg16_read(client, 0x5000, &priv->id[i]);
++ reg16_read(client, 0x0500, &priv->id[i]);
+ }
+#endif
-+#endif
+}
+
+static ssize_t ov495_otp_id_show(struct device *dev,
@@ -4431,7 +4417,7 @@ index 0000000..3f55778
+static int ov495_initialize(struct i2c_client *client)
+{
+ struct ov495_priv *priv = to_ov495(client);
-+ u8 pid = 0, ver = 0, rev = 0;
++ u8 pid = 0, ver = 0;
+ int ret = 0;
+
+ /* check and show product ID and manufacturer ID */
@@ -4440,7 +4426,6 @@ index 0000000..3f55778
+ usleep_range(100, 150); /* wait 100 us */
+ reg16_read(client, OV495_PID, &pid);
+ reg16_read(client, OV495_VER, &ver);
-+ reg16_read(client, OV495_REV, &rev);
+
+ if (OV495_VERSION(pid, ver) != OV495_VERSION_REG) {
+ dev_err(&client->dev, "Product ID error %x:%x\n", pid, ver);
@@ -4470,20 +4455,15 @@ index 0000000..3f55778
+#endif
+
+ /* set virtual channel */
-+ reg16_write(client, 0x3516, 0x0); /* unlock write */
-+ reg16_write(client, 0xFFFD, 0x80);
-+ reg16_write(client, 0xFFFE, 0x20);
-+ reg16_write(client, 0x8017, 0x1e | (priv->port << 6));
-+ reg16_write(client, 0x3516, 0x1); /* lock write */
-+
++ ov495_regs_wizard[3].val = 0x1e | (priv->port << 6);
+ /* Program wizard registers */
+ ov495_set_regs(client, ov495_regs_wizard, ARRAY_SIZE(ov495_regs_wizard));
+ /* Read OTP IDs */
+ ov495_otp_id_read(client);
+
+out:
-+ dev_info(&client->dev, "ov495/ov2775 Product ID %x Manufacturer ID %x, rev 1%x, res %dx%d, OTP_ID %02x:%02x:%02x:%02x:%02x:%02x\n",
-+ pid, ver, 0xa + rev, priv->max_width, priv->max_height, priv->id[0], priv->id[1], priv->id[2], priv->id[3], priv->id[4], priv->id[5]);
++ dev_info(&client->dev, "ov495/ov2775 PID %x%x, res %dx%d, OTP_ID %02x:%02x:%02x:%02x:%02x:%02x\n",
++ pid, ver, priv->max_width, priv->max_height, priv->id[0], priv->id[1], priv->id[2], priv->id[3], priv->id[4], priv->id[5]);
+err:
+ return ret;
+}
@@ -4502,8 +4482,6 @@ index 0000000..3f55778
+
+ of_node_put(endpoint);
+
-+ of_property_read_u32(endpoint, "dvp-order", &priv->dvp_order);
-+
+ rendpoint = of_parse_phandle(endpoint, "remote-endpoint", 0);
+ if (!rendpoint)
+ continue;
@@ -4691,10 +4669,10 @@ index 0000000..3f55778
+#endif
diff --git a/drivers/media/i2c/soc_camera/ov495_ov2775.h b/drivers/media/i2c/soc_camera/ov495_ov2775.h
new file mode 100644
-index 0000000..dc6ad86
+index 0000000..3f53689
--- /dev/null
+++ b/drivers/media/i2c/soc_camera/ov495_ov2775.h
-@@ -0,0 +1,18 @@
+@@ -0,0 +1,23 @@
+/*
+ * OmniVision ov495-ov2775 sensor camera wizard 1280x1080@30/UYVY/BT601/8bit
+ *
@@ -4711,14 +4689,19 @@ index 0000000..dc6ad86
+ u8 val;
+};
+
-+static const struct ov495_reg ov495_regs_wizard[] = {
++static struct ov495_reg ov495_regs_wizard[] = {
++{0x3516, 0x00}, /* unlock write */
++{0xFFFD, 0x80},
++{0xFFFE, 0x20},
++{0x8017, 0x1e | (0 << 6)},
++{0x7c10, 0x01}, /* UYVY */
+};
diff --git a/drivers/media/i2c/soc_camera/ti954_ti9x3.c b/drivers/media/i2c/soc_camera/ti954_ti9x3.c
new file mode 100644
-index 0000000..c325876
+index 0000000..f94208d
--- /dev/null
+++ b/drivers/media/i2c/soc_camera/ti954_ti9x3.c
-@@ -0,0 +1,414 @@
+@@ -0,0 +1,417 @@
+/*
+ * TI ti954-(ti913/ti953) FPDLinkIII driver
+ *
@@ -4833,20 +4816,23 @@ index 0000000..c325876
+ reg8_write(client, 0x32, 0x01); /* Select TX (CSI) port 0 */
+ reg8_write(client, 0x33, ((priv->lanes - 1) ^ 0x3) << 4); /* disable CSI output, set CSI lane count, non-continuous CSI mode */
+ reg8_write(client, 0x20, 0xf0); /* disable port forwarding */
-+#if 1
++#if 0
+ /* FrameSync setup for REFCLK=25MHz, FPS=30: period_counts=1/2/FPS*25MHz =1/2/30*25Mhz =416666 -> FS_TIME=416666 */
+ /* FrameSync setup for REFCLK=22.5MHz, FPS=30: period_counts=1/2/FPS*22.5Mhz=1/2/30*22.5Mhz=375000 -> FS_TIME=375000 */
-+ #define FS_TIME (priv->csi_rate == 1450 ? 376000 : 417666)
++// #define FS_TIME (priv->csi_rate == 1450 ? 376000 : 417666)
++ #define FS_TIME (priv->csi_rate == 1450 ? 385000 : 428000) // FPS=29.2 (new vendor's firmware AWB restriction?)
+ reg8_write(client, 0x1a, FS_TIME >> 16); /* FrameSync time 24bit */
+ reg8_write(client, 0x1b, (FS_TIME >> 8) & 0xff);
+ reg8_write(client, 0x1c, FS_TIME & 0xff);
+ reg8_write(client, 0x18, 0x43); /* Enable FrameSync, 50/50 mode, Frame clock from 25MHz */
+#else
-+ /* FrameSync setup for 30FPS: period_counts=1/FPS/12mks=1/30/12e-6=2777 -> HI=2, LO=2775 FPS=30.008 */
++ /* FrameSync setup for REFCLK=25MHz, FPS=30: period_counts=1/FPS/12mks=1/30/12e-6=2777 -> HI=2, LO=2775 */
++ /* FrameSync setup for REFCLK=22.5MHz, FPS=30: period_counts=1/FPS/13.333mks=1/30/13.333e-6=2500 -> HI=2, LO=2498 */
++ #define FS_TIME (priv->csi_rate == 1450 ? (2498+15) : (2775+15))
+ reg8_write(client, 0x19, 2 >> 8); /* FrameSync high time MSB */
-+ reg8_write(client, 0x1a, 2 >> 16); /* FrameSync high time LSB */
-+ reg8_write(client, 0x1b, 2775 & 0xff); /* FrameSync low time MSB */
-+ reg8_write(client, 0x1c, 2775 & 0xff); /* FrameSync low time LSB */
++ reg8_write(client, 0x1a, 2 & 0xff); /* FrameSync high time LSB */
++ reg8_write(client, 0x1b, FS_TIME >> 8); /* FrameSync low time MSB */
++ reg8_write(client, 0x1c, FS_TIME & 0xff); /* FrameSync low time LSB */
+ reg8_write(client, 0x18, 0x01); /* Enable FrameSync, HI/LO mode, Frame clock from port0 */
+#endif
+}
@@ -5135,10 +5121,10 @@ index 0000000..c325876
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/i2c/soc_camera/ti964_ti9x3.c b/drivers/media/i2c/soc_camera/ti964_ti9x3.c
new file mode 100644
-index 0000000..b293466
+index 0000000..567def1
--- /dev/null
+++ b/drivers/media/i2c/soc_camera/ti964_ti9x3.c
-@@ -0,0 +1,382 @@
+@@ -0,0 +1,385 @@
+/*
+ * TI (ti964/ti960)-(ti913/ti953) FPDLinkIII driver
+ *
@@ -5226,20 +5212,23 @@ index 0000000..b293466
+ reg8_write(client, 0x32, 0x01); /* Select TX (CSI) port 0 */
+ reg8_write(client, 0x33, ((priv->lanes - 1) ^ 0x3) << 4); /* disable CSI output, set CSI lane count, non-continuous CSI mode */
+ reg8_write(client, 0x20, 0xf0); /* disable port forwarding */
-+#if 1
++#if 0
+ /* FrameSync setup for REFCLK=25MHz, FPS=30: period_counts=1/2/FPS*25MHz =1/2/30*25Mhz =416666 -> FS_TIME=416666 */
+ /* FrameSync setup for REFCLK=22.5MHz, FPS=30: period_counts=1/2/FPS*22.5Mhz=1/2/30*22.5Mhz=375000 -> FS_TIME=375000 */
-+ #define FS_TIME (priv->csi_rate == 1450 ? 376000 : 417666)
++// #define FS_TIME (priv->csi_rate == 1450 ? 376000 : 417666)
++ #define FS_TIME (priv->csi_rate == 1450 ? 385000 : 428000) // FPS=29.2 (new vendor's firmware AWB restriction?)
+ reg8_write(client, 0x1a, FS_TIME >> 16); /* FrameSync time 24bit */
+ reg8_write(client, 0x1b, (FS_TIME >> 8) & 0xff);
+ reg8_write(client, 0x1c, FS_TIME & 0xff);
+ reg8_write(client, 0x18, 0x43); /* Enable FrameSync, 50/50 mode, Frame clock from 25MHz */
+#else
-+ /* FrameSync setup for 30FPS: period_counts=1/FPS/12mks=1/30/12e-6=2777 -> HI=2, LO=2775 FPS=30.008 */
++ /* FrameSync setup for REFCLK=25MHz, FPS=30: period_counts=1/FPS/12mks=1/30/12e-6=2777 -> HI=2, LO=2775 */
++ /* FrameSync setup for REFCLK=22.5MHz, FPS=30: period_counts=1/FPS/13.333mks=1/30/13.333e-6=2500 -> HI=2, LO=2498 */
++ #define FS_TIME (priv->csi_rate == 1450 ? (2498+15) : (2775+15))
+ reg8_write(client, 0x19, 2 >> 8); /* FrameSync high time MSB */
-+ reg8_write(client, 0x1a, 2 >> 16); /* FrameSync high time LSB */
-+ reg8_write(client, 0x1b, 2775 & 0xff); /* FrameSync low time MSB */
-+ reg8_write(client, 0x1c, 2775 & 0xff); /* FrameSync low time LSB */
++ reg8_write(client, 0x1a, 2 & 0xff); /* FrameSync high time LSB */
++ reg8_write(client, 0x1b, FS_TIME >> 8); /* FrameSync low time MSB */
++ reg8_write(client, 0x1c, FS_TIME & 0xff); /* FrameSync low time LSB */
+ reg8_write(client, 0x18, 0x01); /* Enable FrameSync, HI/LO mode, Frame clock from port0 */
+#endif
+}