diff mbox

[RFC,04/13] omap3isp: add support for CSI1 bus

Message ID 20170218225312.GA14012@amd (mailing list archive)
State New, archived
Headers show

Commit Message

Pavel Machek Feb. 18, 2017, 10:53 p.m. UTC
Hi!

I guess I'll need some help here.

> @@ -160,6 +163,33 @@ static int ccp2_if_enable(struct isp_ccp2_device *ccp2, u8 enable)
>  			return ret;
>  	}
>  
> +	if (isp->revision == ISP_REVISION_2_0) {
> +		struct media_pad *pad;
> +		struct v4l2_subdev *sensor;
> +		const struct isp_ccp2_cfg *buscfg;
> +		u32 csirxfe;
> +
> +		pad = media_entity_remote_pad(&ccp2->pads[CCP2_PAD_SINK]);
> +		sensor = media_entity_to_v4l2_subdev(pad->entity);
> +		/* Struct isp_bus_cfg has union inside */
> +		buscfg = &((struct isp_bus_cfg *)sensor->host_priv)->bus.ccp2;
> +
> +
> +		if (enable) {
> +			csirxfe = OMAP343X_CONTROL_CSIRXFE_PWRDNZ |
> +				  OMAP343X_CONTROL_CSIRXFE_RESET;
> +
> +			if (buscfg->phy_layer)
> +				csirxfe |= OMAP343X_CONTROL_CSIRXFE_SELFORM;
> +
> +			if (buscfg->strobe_clk_pol)
> +				csirxfe |= OMAP343X_CONTROL_CSIRXFE_CSIB_INV;
> +		} else
> +			csirxfe = 0;
> +
> +		regmap_write(isp->syscon, isp->syscon_offset, csirxfe);
> +	}
> +

This is ugly. This does not belong here, it is basically duplicate of

. But that function is not called, because ccp2->phy is not
initialized for ISP_REVISION_2_0 in ..._ccp2_init():

int omap3isp_ccp2_init(struct isp_device *isp)
{
        if (isp->revision == ISP_REVISION_2_0) {
                ccp2->vdds_csib = devm_regulator_get(isp->dev, "vdds_csib");
                if (IS_ERR(ccp2->vdds_csib)) {
                        if (PTR_ERR(ccp2->vdds_csib) == -EPROBE_DEFER)
                                return -EPROBE_DEFER;
                        dev_dbg(isp->dev,
                                "Could not get regulator vdds_csib\n");
                        ccp2->vdds_csib = NULL;
                }
        } else if (isp->revision == ISP_REVISION_15_0) {
                ccp2->phy = &isp->isp_csiphy1;
        }


...phy is only initialized for REVISION_15 case. (and isp_csiphy1
seems to contain uninitialized data at this point. Below is a fix for
that).

If someone has an idea what to do there, please help. I tried
ccp2->phy = &isp->isp_csiphy2; but that does not have pipe
initialized, so it eventually leads to crash.

Thanks,
								Pavel
diff mbox

Patch

diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c b/drivers/media/platform/omap3isp/ispcsiphy.c
index 8f73f6d..a2474b6 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.c
+++ b/drivers/media/platform/omap3isp/ispcsiphy.c
@@ -362,14 +374,16 @@  int omap3isp_csiphy_init(struct isp_device *isp)
 	phy2->phy_regs = OMAP3_ISP_IOMEM_CSIPHY2;
 	mutex_init(&phy2->mutex);
 
-	if (isp->revision == ISP_REVISION_15_0) {
-		phy1->isp = isp;
-		phy1->csi2 = &isp->isp_csi2c;
-		phy1->num_data_lanes = ISP_CSIPHY1_NUM_DATA_LANES;
-		phy1->cfg_regs = OMAP3_ISP_IOMEM_CSI2C_REGS1;
-		phy1->phy_regs = OMAP3_ISP_IOMEM_CSIPHY1;
-		mutex_init(&phy1->mutex);
+	if (isp->revision != ISP_REVISION_15_0) {
+		memset(phy1, sizeof(*phy1), 0);
+		return 0;
 	}
 
+	phy1->isp = isp;
+	phy1->csi2 = &isp->isp_csi2c;
+	phy1->num_data_lanes = ISP_CSIPHY1_NUM_DATA_LANES;
+	phy1->cfg_regs = OMAP3_ISP_IOMEM_CSI2C_REGS1;
+	phy1->phy_regs = OMAP3_ISP_IOMEM_CSIPHY1;
+	mutex_init(&phy1->mutex);
 	return 0;
 }