Re: [PATCH v3 3/3] omap3isp: Configure CSI-2 phy based on platform data

2012-10-09 Thread Sakari Ailus
Hi Laurent,

Thanks for the comments.

On Tue, Oct 09, 2012 at 02:33:28AM +0200, Laurent Pinchart wrote:
...
  @@ -248,10 +203,56 @@ static int csiphy_config(struct isp_csiphy *phy,
  if (lanes-clk.pos == 0 || used_lanes  (1  lanes-clk.pos))
  return -EINVAL;
  
  -   mutex_lock(phy-mutex);
  -   phy-dphy = *dphy;
  -   phy-lanes = *lanes;
  -   mutex_unlock(phy-mutex);
  +   csiphy_routing_cfg(phy, subdevs-interface, true,
  +  subdevs-bus.ccp2.phy_layer);
 
 As the second argument is always true, it could make sense to remove it (or 
 to 
 add another call to csiphy_routing_cfg with on set to false).

That's a good point. In principle another call should be added for 3430 to
turn the PHY off. That's not being done on the N900.

I'll see where it could be added.

Regards,

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 3/3] omap3isp: Configure CSI-2 phy based on platform data

2012-10-08 Thread Laurent Pinchart
On Sunday 07 October 2012 23:07:52 Sakari Ailus wrote:
 Configure CSI-2 phy based on platform data in the ISP driver. For that, the
 new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously the same
 was configured from the board code.
 
 This patch is dependent on omap3: Provide means for changing CSI2 PHY
 configuration.
 
 Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
 Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
 ---
  drivers/media/platform/omap3isp/isp.h   |3 -
  drivers/media/platform/omap3isp/ispcsiphy.c |  140 
  drivers/media/platform/omap3isp/ispcsiphy.h |   10 --
  3 files changed, 70 insertions(+), 83 deletions(-)
 
 diff --git a/drivers/media/platform/omap3isp/isp.h
 b/drivers/media/platform/omap3isp/isp.h index 6fed222..accb3b0 100644
 --- a/drivers/media/platform/omap3isp/isp.h
 +++ b/drivers/media/platform/omap3isp/isp.h
 @@ -129,9 +129,6 @@ struct isp_reg {
 
  struct isp_platform_callback {
   u32 (*set_xclk)(struct isp_device *isp, u32 xclk, u8 xclksel);
 - int (*csiphy_config)(struct isp_csiphy *phy,
 -  struct isp_csiphy_dphy_cfg *dphy,
 -  struct isp_csiphy_lanes_cfg *lanes);
  };
 
  /*
 diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c
 b/drivers/media/platform/omap3isp/ispcsiphy.c index f13bfbd..4ac1081 100644
 --- a/drivers/media/platform/omap3isp/ispcsiphy.c
 +++ b/drivers/media/platform/omap3isp/ispcsiphy.c
 @@ -119,36 +119,6 @@ static void csiphy_routing_cfg(struct isp_csiphy *phy,
 u32 iface, bool on, }
 
  /*
 - * csiphy_lanes_config - Configuration of CSIPHY lanes.
 - *
 - * Updates HW configuration.
 - * Called with phy-mutex taken.
 - */
 -static void csiphy_lanes_config(struct isp_csiphy *phy)
 -{
 - unsigned int i;
 - u32 reg;
 -
 - reg = isp_reg_readl(phy-isp, phy-cfg_regs, ISPCSI2_PHY_CFG);
 -
 - for (i = 0; i  phy-num_data_lanes; i++) {
 - reg = ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) |
 -  ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1));
 - reg |= (phy-lanes.data[i].pol 
 - ISPCSI2_PHY_CFG_DATA_POL_SHIFT(i + 1));
 - reg |= (phy-lanes.data[i].pos 
 - ISPCSI2_PHY_CFG_DATA_POSITION_SHIFT(i + 1));
 - }
 -
 - reg = ~(ISPCSI2_PHY_CFG_CLOCK_POL_MASK |
 -  ISPCSI2_PHY_CFG_CLOCK_POSITION_MASK);
 - reg |= phy-lanes.clk.pol  ISPCSI2_PHY_CFG_CLOCK_POL_SHIFT;
 - reg |= phy-lanes.clk.pos  ISPCSI2_PHY_CFG_CLOCK_POSITION_SHIFT;
 -
 - isp_reg_writel(phy-isp, reg, phy-cfg_regs, ISPCSI2_PHY_CFG);
 -}
 -
 -/*
   * csiphy_power_autoswitch_enable
   * @enable: Sets or clears the autoswitch function enable flag.
   */
 @@ -193,43 +163,28 @@ static int csiphy_set_power(struct isp_csiphy *phy,
 u32 power) }
 
  /*
 - * csiphy_dphy_config - Configure CSI2 D-PHY parameters.
 - *
 - * Called with phy-mutex taken.
 + * TCLK values are OK at their reset values
   */
 -static void csiphy_dphy_config(struct isp_csiphy *phy)
 -{
 - u32 reg;
 -
 - /* Set up ISPCSIPHY_REG0 */
 - reg = isp_reg_readl(phy-isp, phy-phy_regs, ISPCSIPHY_REG0);
 -
 - reg = ~(ISPCSIPHY_REG0_THS_TERM_MASK |
 -  ISPCSIPHY_REG0_THS_SETTLE_MASK);
 - reg |= phy-dphy.ths_term  ISPCSIPHY_REG0_THS_TERM_SHIFT;
 - reg |= phy-dphy.ths_settle  ISPCSIPHY_REG0_THS_SETTLE_SHIFT;
 -
 - isp_reg_writel(phy-isp, reg, phy-phy_regs, ISPCSIPHY_REG0);
 -
 - /* Set up ISPCSIPHY_REG1 */
 - reg = isp_reg_readl(phy-isp, phy-phy_regs, ISPCSIPHY_REG1);
 -
 - reg = ~(ISPCSIPHY_REG1_TCLK_TERM_MASK |
 -  ISPCSIPHY_REG1_TCLK_MISS_MASK |
 -  ISPCSIPHY_REG1_TCLK_SETTLE_MASK);
 - reg |= phy-dphy.tclk_term  ISPCSIPHY_REG1_TCLK_TERM_SHIFT;
 - reg |= phy-dphy.tclk_miss  ISPCSIPHY_REG1_TCLK_MISS_SHIFT;
 - reg |= phy-dphy.tclk_settle  ISPCSIPHY_REG1_TCLK_SETTLE_SHIFT;
 +#define TCLK_TERM0
 +#define TCLK_MISS1
 +#define TCLK_SETTLE  14
 
 - isp_reg_writel(phy-isp, reg, phy-phy_regs, ISPCSIPHY_REG1);
 -}
 -
 -static int csiphy_config(struct isp_csiphy *phy,
 -  struct isp_csiphy_dphy_cfg *dphy,
 -  struct isp_csiphy_lanes_cfg *lanes)
 +static int omap3isp_csiphy_config(struct isp_csiphy *phy)
  {
 + struct isp_csi2_device *csi2 = phy-csi2;
 + struct isp_pipeline *pipe = to_isp_pipeline(csi2-subdev.entity);
 + struct isp_v4l2_subdevs_group *subdevs = pipe-external-host_priv;
 + struct isp_csiphy_lanes_cfg *lanes;
 + int csi2_ddrclk_khz;
   unsigned int used_lanes = 0;
   unsigned int i;
 + u32 reg;
 +
 + if (subdevs-interface == ISP_INTERFACE_CCP2B_PHY1
 + || subdevs-interface == ISP_INTERFACE_CCP2B_PHY2)
 + lanes = subdevs-bus.ccp2.lanecfg;
 + else
 + lanes = subdevs-bus.csi2.lanecfg;
 
   /* Clock and data lanes verification */
   for (i = 0; i  phy-num_data_lanes; i++) {
 @@ -248,10 +203,56 @@ 

[PATCH v3 3/3] omap3isp: Configure CSI-2 phy based on platform data

2012-10-07 Thread Sakari Ailus
Configure CSI-2 phy based on platform data in the ISP driver. For that, the
new V4L2_CID_IMAGE_SOURCE_PIXEL_RATE control is used. Previously the same
was configured from the board code.

This patch is dependent on omap3: Provide means for changing CSI2 PHY
configuration.

Signed-off-by: Sakari Ailus sakari.ai...@iki.fi
Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com
---
 drivers/media/platform/omap3isp/isp.h   |3 -
 drivers/media/platform/omap3isp/ispcsiphy.c |  140 +-
 drivers/media/platform/omap3isp/ispcsiphy.h |   10 --
 3 files changed, 70 insertions(+), 83 deletions(-)

diff --git a/drivers/media/platform/omap3isp/isp.h 
b/drivers/media/platform/omap3isp/isp.h
index 6fed222..accb3b0 100644
--- a/drivers/media/platform/omap3isp/isp.h
+++ b/drivers/media/platform/omap3isp/isp.h
@@ -129,9 +129,6 @@ struct isp_reg {
 
 struct isp_platform_callback {
u32 (*set_xclk)(struct isp_device *isp, u32 xclk, u8 xclksel);
-   int (*csiphy_config)(struct isp_csiphy *phy,
-struct isp_csiphy_dphy_cfg *dphy,
-struct isp_csiphy_lanes_cfg *lanes);
 };
 
 /*
diff --git a/drivers/media/platform/omap3isp/ispcsiphy.c 
b/drivers/media/platform/omap3isp/ispcsiphy.c
index f13bfbd..4ac1081 100644
--- a/drivers/media/platform/omap3isp/ispcsiphy.c
+++ b/drivers/media/platform/omap3isp/ispcsiphy.c
@@ -119,36 +119,6 @@ static void csiphy_routing_cfg(struct isp_csiphy *phy, u32 
iface, bool on,
 }
 
 /*
- * csiphy_lanes_config - Configuration of CSIPHY lanes.
- *
- * Updates HW configuration.
- * Called with phy-mutex taken.
- */
-static void csiphy_lanes_config(struct isp_csiphy *phy)
-{
-   unsigned int i;
-   u32 reg;
-
-   reg = isp_reg_readl(phy-isp, phy-cfg_regs, ISPCSI2_PHY_CFG);
-
-   for (i = 0; i  phy-num_data_lanes; i++) {
-   reg = ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) |
-ISPCSI2_PHY_CFG_DATA_POSITION_MASK(i + 1));
-   reg |= (phy-lanes.data[i].pol 
-   ISPCSI2_PHY_CFG_DATA_POL_SHIFT(i + 1));
-   reg |= (phy-lanes.data[i].pos 
-   ISPCSI2_PHY_CFG_DATA_POSITION_SHIFT(i + 1));
-   }
-
-   reg = ~(ISPCSI2_PHY_CFG_CLOCK_POL_MASK |
-ISPCSI2_PHY_CFG_CLOCK_POSITION_MASK);
-   reg |= phy-lanes.clk.pol  ISPCSI2_PHY_CFG_CLOCK_POL_SHIFT;
-   reg |= phy-lanes.clk.pos  ISPCSI2_PHY_CFG_CLOCK_POSITION_SHIFT;
-
-   isp_reg_writel(phy-isp, reg, phy-cfg_regs, ISPCSI2_PHY_CFG);
-}
-
-/*
  * csiphy_power_autoswitch_enable
  * @enable: Sets or clears the autoswitch function enable flag.
  */
@@ -193,43 +163,28 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 
power)
 }
 
 /*
- * csiphy_dphy_config - Configure CSI2 D-PHY parameters.
- *
- * Called with phy-mutex taken.
+ * TCLK values are OK at their reset values
  */
-static void csiphy_dphy_config(struct isp_csiphy *phy)
-{
-   u32 reg;
-
-   /* Set up ISPCSIPHY_REG0 */
-   reg = isp_reg_readl(phy-isp, phy-phy_regs, ISPCSIPHY_REG0);
-
-   reg = ~(ISPCSIPHY_REG0_THS_TERM_MASK |
-ISPCSIPHY_REG0_THS_SETTLE_MASK);
-   reg |= phy-dphy.ths_term  ISPCSIPHY_REG0_THS_TERM_SHIFT;
-   reg |= phy-dphy.ths_settle  ISPCSIPHY_REG0_THS_SETTLE_SHIFT;
-
-   isp_reg_writel(phy-isp, reg, phy-phy_regs, ISPCSIPHY_REG0);
-
-   /* Set up ISPCSIPHY_REG1 */
-   reg = isp_reg_readl(phy-isp, phy-phy_regs, ISPCSIPHY_REG1);
-
-   reg = ~(ISPCSIPHY_REG1_TCLK_TERM_MASK |
-ISPCSIPHY_REG1_TCLK_MISS_MASK |
-ISPCSIPHY_REG1_TCLK_SETTLE_MASK);
-   reg |= phy-dphy.tclk_term  ISPCSIPHY_REG1_TCLK_TERM_SHIFT;
-   reg |= phy-dphy.tclk_miss  ISPCSIPHY_REG1_TCLK_MISS_SHIFT;
-   reg |= phy-dphy.tclk_settle  ISPCSIPHY_REG1_TCLK_SETTLE_SHIFT;
+#define TCLK_TERM  0
+#define TCLK_MISS  1
+#define TCLK_SETTLE14
 
-   isp_reg_writel(phy-isp, reg, phy-phy_regs, ISPCSIPHY_REG1);
-}
-
-static int csiphy_config(struct isp_csiphy *phy,
-struct isp_csiphy_dphy_cfg *dphy,
-struct isp_csiphy_lanes_cfg *lanes)
+static int omap3isp_csiphy_config(struct isp_csiphy *phy)
 {
+   struct isp_csi2_device *csi2 = phy-csi2;
+   struct isp_pipeline *pipe = to_isp_pipeline(csi2-subdev.entity);
+   struct isp_v4l2_subdevs_group *subdevs = pipe-external-host_priv;
+   struct isp_csiphy_lanes_cfg *lanes;
+   int csi2_ddrclk_khz;
unsigned int used_lanes = 0;
unsigned int i;
+   u32 reg;
+
+   if (subdevs-interface == ISP_INTERFACE_CCP2B_PHY1
+   || subdevs-interface == ISP_INTERFACE_CCP2B_PHY2)
+   lanes = subdevs-bus.ccp2.lanecfg;
+   else
+   lanes = subdevs-bus.csi2.lanecfg;
 
/* Clock and data lanes verification */
for (i = 0; i  phy-num_data_lanes; i++) {
@@ -248,10 +203,56 @@ static int csiphy_config(struct isp_csiphy *phy,
if