media: omap3isp: Explicitly set the number of CSI-2 lanes used in lane cfg
authorSakari Ailus <sakari.ailus@linux.intel.com>
Thu, 13 Jul 2017 16:11:32 +0000 (12:11 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 19 Jul 2017 19:46:06 +0000 (15:46 -0400)
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.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Tested-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/platform/omap3isp/isp.c
drivers/media/platform/omap3isp/ispcsiphy.c
drivers/media/platform/omap3isp/omap3isp.h

index 088dc8b1b78ac406b0fe05fe6475c1e5260c47cb..db2cccb57ceb37185fa7fcd3b655eac3b0514636 100644 (file)
@@ -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 =
index 83940e9d82916f7d69d739073a708f1400fd82dd..3efa71396aae21747c5c57306d9730511fc0804b 100644 (file)
@@ -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 <<
index 443e8f7673e2fe02164ba907ca5744a12bf44785..3c26f9a3f508f65ca22325bbae1cc4a85c4832f6 100644 (file)
@@ -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 {