Skip to contentSkip to conversation

OMAP3ISP CCP2 support

PATCH In review Sakari Ailus 3 participants 9 messages Jul 13, 2017 – Jul 14, 2017 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

cover OMAP3ISP CCP2 support

Hi Pavel,

I took the liberty of changing your patch a bit. I added another to extract the number of lanes from the endpoint instead as it's not really a property of the PHY. (Not tested yet, will check with N9.)

Pavel Machek (1):
omap3isp: add CSI1 support

Sakari Ailus (1):
omap3isp: Explicitly set the number of CSI-2 lanes used in lane cfg

 drivers/media/platform/omap3isp/isp.c       |  5 ++++-
 drivers/media/platform/omap3isp/ispccp2.c   |  1 +
 drivers/media/platform/omap3isp/ispcsiphy.c | 35 +++++++++++++++++++----------
 drivers/media/platform/omap3isp/omap3isp.h  |  3 +++
 4 files changed, 31 insertions(+), 13 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/2 omap3isp: Explicitly set the number of CSI-2 lanes used in lane cfg

The omap3isp driver extracts the CSI-2 lane configuration from the V4L2 fwnode endpoint but misses the number of lanes itself. Get this information and use it in PHY configuration.

---
 drivers/media/platform/omap3isp/isp.c       |  5 ++++-
 drivers/media/platform/omap3isp/ispcsiphy.c | 16 +++++++++++-----
 drivers/media/platform/omap3isp/omap3isp.h  |  3 +++
 3 files changed, 18 insertions(+), 6 deletions(-)
drivers/media/platform/omap3isp/isp.c +4 -1
index 088dc8b1b78a..db2cccb57ceb 100644
@@ -2061,7 +2061,10 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwnode,
 			buscfg->bus.csi2.lanecfg.clk.pol,
 			buscfg->bus.csi2.lanecfg.clk.pos);
 
-		for (i = 0; i < ISP_CSIPHY2_NUM_DATA_LANES; i++) {
+		buscfg->bus.csi2.num_data_lanes =
+			vep.bus.mipi_csi2.num_data_lanes;
+
+		for (i = 0; i < buscfg->bus.csi2.num_data_lanes; i++) {
 			buscfg->bus.csi2.lanecfg.data[i].pos =
 				vep.bus.mipi_csi2.data_lanes[i];
 			buscfg->bus.csi2.lanecfg.data[i].pol =
drivers/media/platform/omap3isp/ispcsiphy.c +11 -5
index 83940e9d8291..3efa71396aae 100644
@@ -169,7 +169,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
 	struct isp_bus_cfg *buscfg = pipe->external->host_priv;
 	struct isp_csiphy_lanes_cfg *lanes;
 	int csi2_ddrclk_khz;
-	unsigned int used_lanes = 0;
+	unsigned int num_data_lanes, used_lanes = 0;
 	unsigned int i;
 	u32 reg;
 
@@ -181,13 +181,19 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
 	}
 
 	if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1
-	    || buscfg->interface == ISP_INTERFACE_CCP2B_PHY2)
+	    || buscfg->interface == ISP_INTERFACE_CCP2B_PHY2) {
 		lanes = &buscfg->bus.ccp2.lanecfg;
-	else
+		num_data_lanes = 1;
+	} else {
 		lanes = &buscfg->bus.csi2.lanecfg;
+		num_data_lanes = buscfg->bus.csi2.num_data_lanes;
+	}
+
+	if (num_data_lanes > phy->num_data_lanes)
+		return -EINVAL;
 
 	/* Clock and data lanes verification */
-	for (i = 0; i < phy->num_data_lanes; i++) {
+	for (i = 0; i < num_data_lanes; i++) {
 		if (lanes->data[i].pol > 1 || lanes->data[i].pos > 3)
 			return -EINVAL;
 
@@ -243,7 +249,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
 	/* DPHY lane configuration */
 	reg = isp_reg_readl(csi2->isp, phy->cfg_regs, ISPCSI2_PHY_CFG);
 
-	for (i = 0; i < phy->num_data_lanes; i++) {
+	for (i = 0; i < num_data_lanes; i++) {
 		reg &= ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) |
 			 ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1));
 		reg |= (lanes->data[i].pol <<
drivers/media/platform/omap3isp/omap3isp.h +3 -0
index 443e8f7673e2..3c26f9a3f508 100644
@@ -114,10 +114,13 @@ struct isp_ccp2_cfg {
 /**
  * struct isp_csi2_cfg - CSI2 interface configuration
  * @crc: Enable the cyclic redundancy check
+ * @lanecfg: CSI-2 lane configuration
+ * @num_data_lanes: The number of data lanes in use
  */
 struct isp_csi2_cfg {
 	unsigned crc:1;
 	struct isp_csiphy_lanes_cfg lanecfg;
+	u8 num_data_lanes;
 };
 
 struct isp_bus_cfg {
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/2 omap3isp: add CSI1 support

In reply to Sakari Ailus

From: Pavel Machek <[email protected]>

CSI-2 PHY power management is only needed for major version 15 of the ISP. Additionally, set the CCP2 PHY for previous ISP versions as well.

These changes are necessary for CCP2 support.

---
 drivers/media/platform/omap3isp/ispccp2.c   |  1 +
 drivers/media/platform/omap3isp/ispcsiphy.c | 19 ++++++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)
drivers/media/platform/omap3isp/ispccp2.c +1 -0
index ca095238510d..588f67a89f79 100644
@@ -1141,6 +1141,7 @@ int omap3isp_ccp2_init(struct isp_device *isp)
 				"Could not get regulator vdds_csib\n");
 			ccp2->vdds_csib = NULL;
 		}
+		ccp2->phy = &isp->isp_csiphy2;
 	} else if (isp->revision == ISP_REVISION_15_0) {
 		ccp2->phy = &isp->isp_csiphy1;
 	}
drivers/media/platform/omap3isp/ispcsiphy.c +12 -7
index 3efa71396aae..addc6efbb033 100644
@@ -292,13 +292,16 @@ int omap3isp_csiphy_acquire(struct isp_csiphy *phy)
 	if (rval < 0)
 		goto done;
 
-	rval = csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_ON);
-	if (rval) {
-		regulator_disable(phy->vdd);
-		goto done;
+	if (phy->isp->revision == ISP_REVISION_15_0) {
+		rval = csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_ON);
+		if (rval) {
+			regulator_disable(phy->vdd);
+			goto done;
+		}
+
+		csiphy_power_autoswitch_enable(phy, true);
 	}
 
-	csiphy_power_autoswitch_enable(phy, true);
 	phy->phy_in_use = 1;
 
 done:
@@ -317,8 +320,10 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)
 
 		csiphy_routing_cfg(phy, buscfg->interface, false,
 				   buscfg->bus.ccp2.phy_layer);
-		csiphy_power_autoswitch_enable(phy, false);
-		csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_OFF);
+		if (phy->isp->revision == ISP_REVISION_15_0) {
+			csiphy_power_autoswitch_enable(phy, false);
+			csiphy_set_power(phy, ISPCSI2_PHY_CFG_PWR_CMD_OFF);
+		}
 		regulator_disable(phy->vdd);
 		phy->phy_in_use = 0;
 	}
Signature · 1 line
2.11.0
#3 lore raw
In reply to Sakari Ailus

Hi!

Quoted 3 lines

I took the liberty of changing your patch a bit. I added another to extract the number of lanes from the endpoint instead as it's not really a property of the PHY. (Not tested yet, will check with N9.)

No problem.

Notice that the 1/2 does not apply on top of ccp2 branch; my merge resolution was this:

I broke something in my userspace; I'll continue testing tommorow.

Thanks,
Pavel

commit 895f4f28972942d1ee77d98dd38dc3d59afaa5c4

Author: Sakari Ailus <[email protected]>
Date:   Thu Jul 13 19:19:02 2017 +0300

omap3isp: Explicitly set the number of CSI-2 lanes used in lane cfg

The omap3isp driver extracts the CSI-2 lane configuration from the V4L2 fwnode endpoint but misses the number of lanes itself. Get this information and use it in PHY configuration.

drivers/media/platform/omap3isp/isp.c +4 -1
index b80debf..776f708 100644
@@ -2118,7 +2118,10 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwnode,
 				buscfg->bus.csi2.lanecfg.clk.pol,
 				buscfg->bus.csi2.lanecfg.clk.pos);
 
-			for (i = 0; i < ISP_CSIPHY2_NUM_DATA_LANES; i++) {
+			buscfg->bus.csi2.num_data_lanes =
+				vep.bus.mipi_csi2.num_data_lanes;
+
+			for (i = 0; i < buscfg->bus.csi2.num_data_lanes; i++) {
 				buscfg->bus.csi2.lanecfg.data[i].pos =
 					vep.bus.mipi_csi2.data_lanes[i];
 				buscfg->bus.csi2.lanecfg.data[i].pol =
drivers/media/platform/omap3isp/ispcsiphy.c +11 -5
index 50c0f64..958ac7b 100644
@@ -181,7 +181,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
 	struct isp_bus_cfg *buscfg;
 	struct isp_csiphy_lanes_cfg *lanes;
 	int csi2_ddrclk_khz;
-	unsigned int used_lanes = 0;
+	unsigned int num_data_lanes, used_lanes = 0;
 	unsigned int i;
 	u32 reg;
 
@@ -197,13 +197,19 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
 	}
 
 	if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1
-	    || buscfg->interface == ISP_INTERFACE_CCP2B_PHY2)
+	    || buscfg->interface == ISP_INTERFACE_CCP2B_PHY2) {
 		lanes = &buscfg->bus.ccp2.lanecfg;
-	else
+		num_data_lanes = 1;
+	} else {
 		lanes = &buscfg->bus.csi2.lanecfg;
+		num_data_lanes = buscfg->bus.csi2.num_data_lanes;
+	}
+
+	if (num_data_lanes > phy->num_data_lanes)
+		return -EINVAL;
 
 	/* Clock and data lanes verification */
-	for (i = 0; i < phy->num_data_lanes; i++) {
+	for (i = 0; i < num_data_lanes; i++) {
 		if (lanes->data[i].pol > 1 || lanes->data[i].pos > 3)
 			return -EINVAL;
 
@@ -259,7 +265,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy)
 	/* DPHY lane configuration */
 	reg = isp_reg_readl(phy->isp, phy->cfg_regs, ISPCSI2_PHY_CFG);
 
-	for (i = 0; i < phy->num_data_lanes; i++) {
+	for (i = 0; i < num_data_lanes; i++) {
 		reg &= ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) |
 			 ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1));
 		reg |= (lanes->data[i].pol <<
drivers/media/platform/omap3isp/omap3isp.h +3 -0
index f6d1d0d..672a9cf 100644
@@ -115,10 +115,13 @@ struct isp_ccp2_cfg {
 /**
  * struct isp_csi2_cfg - CSI2 interface configuration
  * @crc: Enable the cyclic redundancy check
+ * @lanecfg: CSI-2 lane configuration
+ * @num_data_lanes: The number of data lanes in use
  */
 struct isp_csi2_cfg {
 	unsigned crc:1;
 	struct isp_csiphy_lanes_cfg lanecfg;
+	u8 num_data_lanes;
 };
 
 struct isp_bus_cfg {
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#4 lore raw
Quoted 10 lines · Pavel Machek

Hi!

Quoted 3 lines

I took the liberty of changing your patch a bit. I added another to extract the number of lanes from the endpoint instead as it's not really a property of the PHY. (Not tested yet, will check with N9.)

No problem.

Notice that the 1/2 does not apply on top of ccp2 branch; my merge resolution was this:

The two patches are for the ccp2-prepare branches, not for ccp2; it's somewhat out of date right now and needs a rebase.

The patches work fine on N9.

Signature · 2 lines
Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
Acked-by Tested-by
#5 lore raw
Quoted 7 lines · Sakari Ailus
Quoted 6 lines · Pavel Machek

Hi!

Quoted 3 lines

I took the liberty of changing your patch a bit. I added another to extract the number of lanes from the endpoint instead as it's not really a property of the PHY. (Not tested yet, will check with N9.)

Quoted 7 lines
Quoted 4 lines

No problem.

Notice that the 1/2 does not apply on top of ccp2 branch; my merge resolution was this:

The two patches are for the ccp2-prepare branches, not for ccp2; it's somewhat out of date right now and needs a rebase.

Yes, and 1/2 will need merge resolution when you do that. Fortunately it is easy.

Quoted 1 line

The patches work fine on N9.

I was able to fix the userspace, and they work for me, too. For both:

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#6 lore raw
Quoted 10 lines · Pavel Machek
Quoted 9 lines · Sakari Ailus
Quoted 8 lines · Pavel Machek

Hi!

Quoted 3 lines

I took the liberty of changing your patch a bit. I added another to extract the number of lanes from the endpoint instead as it's not really a property of the PHY. (Not tested yet, will check with N9.)

No problem.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Notice that the 1/2 does not apply on top of ccp2 branch; my merge resolution was this:

The two patches are for the ccp2-prepare branches, not for ccp2; it's somewhat out of date right now and needs a rebase.

Yes, and 1/2 will need merge resolution when you do that. Fortunately it is easy.

Well... the other patches go on top of this. The end result is still the same.

Quoted 7 lines
Quoted 2 lines

The patches work fine on N9.

I was able to fix the userspace, and they work for me, too. For both:

Thanks! I've applied these on ccp2-prepare. ccp2 branch is rebased, too.

Signature · 4 lines
Regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]
#7 lore raw

Hi!

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

The patches work fine on N9.

I was able to fix the userspace, and they work for me, too. For both:

Thanks! I've applied these on ccp2-prepare. ccp2 branch is rebased, too.

Thanks!

I rebased my patches on top of it, and pushed result to camera-fw6-2 branch.

Can you drop this patch from ccp2 branch?

https://git.linuxtv.org/sailus/media_tree.git/commit/?h=ccp2&id=27be6eb1f66389632a5d9dbaf0426a83f1b99b54

It is preparation for subdevices support on isp; but those will not be needed there as we decided to move subdevices to et8ek8.

Thanks and best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#8 lore raw
Quoted 16 lines · Pavel Machek

Hi!

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

The patches work fine on N9.

I was able to fix the userspace, and they work for me, too. For both:

Thanks! I've applied these on ccp2-prepare. ccp2 branch is rebased, too.

Thanks!

I rebased my patches on top of it, and pushed result to camera-fw6-2 branch.

Quoted 6 lines

Can you drop this patch from ccp2 branch?

https://git.linuxtv.org/sailus/media_tree.git/commit/?h=ccp2&id=27be6eb1f66389632a5d9dbaf0426a83f1b99b54

It is preparation for subdevices support on isp; but those will not be needed there as we decided to move subdevices to et8ek8.

Indeed; I've dropped the patch.

Signature · 2 lines
Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]