示例#1
0
static int imx072_sensor_power_set(struct v4l2_int_device *s, enum v4l2_power power)
{
	struct omap34xxcam_videodev *vdev = s->u.slave->master->priv;
	struct isp_device *isp = dev_get_drvdata(vdev->cam->isp);
	struct isp_csi2_lanes_cfg lanecfg;
	struct isp_csi2_phy_cfg phyconfig;
	static enum v4l2_power previous_power = V4L2_POWER_OFF;
// 20110426 [email protected] Update omap_pm_set_max_mpu_wakeup_lat()  for 2.6.35 kernel [START]
	static struct pm_qos_request_list *qos_request;
// 20110426 [email protected] Update omap_pm_set_max_mpu_wakeup_lat()  for 2.6.35 kernel [END]
	int err = 0;
	switch (power) {
	case V4L2_POWER_ON:		
		/* Power Up Sequence */
		printk(KERN_DEBUG "imx072_sensor_power_set(ON)\n");

// [email protected] [TBD]Temporarily block the following code because PM APIs have been changed [START]
#if 1
		/*
		 * Through-put requirement:
		 * Set max OCP freq for 3630 is 200 MHz through-put
		 * is in KByte/s so 200000 KHz * 4 = 800000 KByte/s
		 */
		omap_pm_set_min_bus_tput(vdev->cam->isp,
					 OCP_INITIATOR_AGENT, 800000);

		/* Hold a constraint to keep MPU in C1 */
		omap_pm_set_max_mpu_wakeup_lat(&qos_request, 12);
#endif
// [email protected] [TBD]Temporarily block the following code because PM APIs have been changed [END]

		isp_csi2_reset(&isp->isp_csi2);

		lanecfg.clk.pol = IMX072_CSI2_CLOCK_POLARITY;
		lanecfg.clk.pos = IMX072_CSI2_CLOCK_LANE;
		lanecfg.data[0].pol = IMX072_CSI2_DATA0_POLARITY;
		lanecfg.data[0].pos = IMX072_CSI2_DATA0_LANE;
		lanecfg.data[1].pol = IMX072_CSI2_DATA1_POLARITY;
		lanecfg.data[1].pos = IMX072_CSI2_DATA1_LANE;
		lanecfg.data[2].pol = 0;
		lanecfg.data[2].pos = 0;
		lanecfg.data[3].pol = 0;
		lanecfg.data[3].pos = 0;
		isp_csi2_complexio_lanes_config(&isp->isp_csi2, &lanecfg);
		isp_csi2_complexio_lanes_update(&isp->isp_csi2, true);

		isp_csi2_ctrl_config_ecc_enable(&isp->isp_csi2, true);

		phyconfig.ths_term = IMX072_CSI2_PHY_THS_TERM;
		phyconfig.ths_settle = IMX072_CSI2_PHY_THS_SETTLE;
		phyconfig.tclk_term = IMX072_CSI2_PHY_TCLK_TERM;
		phyconfig.tclk_miss = IMX072_CSI2_PHY_TCLK_MISS;
		phyconfig.tclk_settle = IMX072_CSI2_PHY_TCLK_SETTLE;
		isp_csi2_phy_config(&isp->isp_csi2, &phyconfig);
		isp_csi2_phy_update(&isp->isp_csi2, true);

		isp_configure_interface(vdev->cam->isp, &imx072_if_config);

//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2011.09.19] - CAM
        gpio_direction_output(SUBPM_ENABLE, 1);
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2011.09.19] - CAM

		/* Request and configure gpio pins */
		if (gpio_request(IMX072_RESET_GPIO, "imx072_rst") != 0)
			return -EIO;

		subpm_set_output(SWREG,1);
		subpm_output_enable();
		subpm_set_output(LDO4,1);
		subpm_output_enable();
		subpm_set_output(LDO3,1);
		subpm_output_enable();

		twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
					VAUX_1_8_V, TWL4030_VAUX4_DEDICATED);
		twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
					VAUX_DEV_GRP_P1, TWL4030_VAUX4_DEV_GRP);
	
		udelay(100);
		
		/* have to put sensor to reset to guarantee detection */
		gpio_direction_output(IMX072_RESET_GPIO, 1);
//		gpio_set_value(IMX072_RESET_GPIO, 1);
		udelay(100);
			
//		gpio_direction_output(IMX072_RESET_GPIO, 0);
		gpio_set_value(IMX072_RESET_GPIO, 0);

		udelay(1500);

		/* nRESET is active LOW. set HIGH to release reset */
//		gpio_direction_output(IMX072_RESET_GPIO, 1);
		gpio_set_value(IMX072_RESET_GPIO, 1);
		udelay(300);

		break;
	case V4L2_POWER_OFF:
		subpm_set_output(LDO5,0);
		subpm_output_enable();
        gpio_set_value(DW9716_VCM_ENABLE, 0);

        isp_disable_mclk(isp);
        isp_csi2_complexio_power(&isp->isp_csi2, ISP_CSI2_POWER_OFF);
        isp_csi2_reset(&isp->isp_csi2);
        isp_csi2_ctrl_config_ecc_enable(&isp->isp_csi2, true);
        isp_csi2_complexio_power(&isp->isp_csi2, ISP_CSI2_POWER_OFF);
        isp_disable_mclk(isp);
//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2011.09.19] - CAM
		gpio_direction_output(SUBPM_ENABLE, 0);
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2011.09.19] - CAM
		break;	
		
	case V4L2_POWER_STANDBY:
		printk(KERN_DEBUG "imx072_sensor_power_set(%s)\n",
			(power == V4L2_POWER_OFF) ? "OFF" : "STANDBY");
		/* Power Down Sequence */
		isp_csi2_complexio_power(&isp->isp_csi2, ISP_CSI2_POWER_OFF);

		twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
				VAUX_DEV_GRP_NONE, TWL4030_VAUX4_DEV_GRP);
		gpio_set_value(IMX072_RESET_GPIO, 0);
		udelay(5);
		subpm_set_output(LDO3,0);
		subpm_output_enable();
		subpm_set_output(LDO4,0);
		subpm_output_enable();
		subpm_set_output(SWREG,0);
		subpm_output_enable();
		gpio_free(IMX072_RESET_GPIO);

// [email protected] [TBD]Temporarily block the following code because PM APIs have been changed [START]
#if 1
		/* Remove pm constraints */
		omap_pm_set_min_bus_tput(vdev->cam->isp, OCP_INITIATOR_AGENT, 0);
		//omap_pm_set_max_mpu_wakeup_lat(vdev->cam->isp, -1);
		omap_pm_set_max_mpu_wakeup_lat(&qos_request, -1);
#endif
// [email protected] [TBD]Temporarily block the following code because PM APIs have been changed [END]

		/* Make sure not to disable the MCLK twice in a row */
		if (previous_power == V4L2_POWER_ON)
			isp_disable_mclk(isp);

//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2011.09.19] - CAM
		isp_disable_mclk(isp);
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2011.09.19] - CAM

		break;
	}

	/* Save powerstate to know what was before calling POWER_ON. */
	previous_power = power;
	return err;
}
示例#2
0
static int imx072_sensor_power_set(struct v4l2_int_device *s, enum v4l2_power power)
{
	struct omap34xxcam_videodev *vdev = s->u.slave->master->priv;
	struct isp_device *isp = dev_get_drvdata(vdev->cam->isp);
	struct isp_csi2_lanes_cfg lanecfg;
	struct isp_csi2_phy_cfg phyconfig;
	static enum v4l2_power previous_power = V4L2_POWER_OFF;
	int err = 0;

	switch (power) {
	case V4L2_POWER_ON:		
		/* Power Up Sequence */
		printk(KERN_DEBUG "imx072_sensor_power_set(ON)\n");

		/*
		 * Through-put requirement:
		 * Set max OCP freq for 3630 is 200 MHz through-put
		 * is in KByte/s so 200000 KHz * 4 = 800000 KByte/s
		 */
		omap_pm_set_min_bus_tput(vdev->cam->isp,
					 OCP_INITIATOR_AGENT, 800000);

/* S[, 20120922, [email protected], PM from froyo. */
		doing_wakeup = 1;
/* E], 20120922, [email protected], PM from froyo. */

		/* Hold a constraint to keep MPU in C1 */
		//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2012.05.22] - CAM
		pm_qos_update_request(&pm_qos_handler,
							SET_MPU_CONSTRAINT);
		//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2012.05.22] - CAM

		isp_csi2_reset(&isp->isp_csi2);

		lanecfg.clk.pol = IMX072_CSI2_CLOCK_POLARITY;
		lanecfg.clk.pos = IMX072_CSI2_CLOCK_LANE;
		lanecfg.data[0].pol = IMX072_CSI2_DATA0_POLARITY;
		lanecfg.data[0].pos = IMX072_CSI2_DATA0_LANE;
		lanecfg.data[1].pol = IMX072_CSI2_DATA1_POLARITY;
		lanecfg.data[1].pos = IMX072_CSI2_DATA1_LANE;
		lanecfg.data[2].pol = 0;
		lanecfg.data[2].pos = 0;
		lanecfg.data[3].pol = 0;
		lanecfg.data[3].pos = 0;
		isp_csi2_complexio_lanes_config(&isp->isp_csi2, &lanecfg);
		isp_csi2_complexio_lanes_update(&isp->isp_csi2, true);

		isp_csi2_ctrl_config_ecc_enable(&isp->isp_csi2, true);

		phyconfig.ths_term = IMX072_CSI2_PHY_THS_TERM;
		phyconfig.ths_settle = IMX072_CSI2_PHY_THS_SETTLE;
		phyconfig.tclk_term = IMX072_CSI2_PHY_TCLK_TERM;
		phyconfig.tclk_miss = IMX072_CSI2_PHY_TCLK_MISS;
		phyconfig.tclk_settle = IMX072_CSI2_PHY_TCLK_SETTLE;
		isp_csi2_phy_config(&isp->isp_csi2, &phyconfig);
		isp_csi2_phy_update(&isp->isp_csi2, true);

		isp_configure_interface(vdev->cam->isp, &imx072_if_config);

		/* Request and configure gpio pins */
		if (gpio_request(IMX072_RESET_GPIO, "imx072_rst") != 0)
			return -EIO;

//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2011.07.26] - CAM
		//KJK for HDMI Sub PMIC usage 2011.03.10
		//extern void lp8720_reinit();
		//lp8720_reinit();
    
		//gpio_direction_output(lp8720_pdata.en_gpio_num, 1);
		//subpm_lp8720_power_on();
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2011.07.26] - CAM

		subpm_set_output(SWREG,1);
		subpm_output_enable();
		subpm_set_output(LDO4,1);
		subpm_output_enable();
		subpm_set_output(LDO3,1);
		subpm_output_enable();

		twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
					VAUX_1_8_V, TWL4030_VAUX4_DEDICATED);
		twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
					VAUX_DEV_GRP_P1, TWL4030_VAUX4_DEV_GRP);
	
		udelay(100);
		
		/* have to put sensor to reset to guarantee detection */
		gpio_direction_output(IMX072_RESET_GPIO, 1);
//		gpio_set_value(IMX072_RESET_GPIO, 1);
		udelay(100);
			
//		gpio_direction_output(IMX072_RESET_GPIO, 0);
		gpio_set_value(IMX072_RESET_GPIO, 0);

		udelay(1500);

		/* nRESET is active LOW. set HIGH to release reset */
//		gpio_direction_output(IMX072_RESET_GPIO, 1);
		gpio_set_value(IMX072_RESET_GPIO, 1);
		udelay(300);

		break;
	case V4L2_POWER_OFF:
//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2011.07.26] - CAM
		printk(KERN_DEBUG "imx072_sensor_power_set(OFF)\n");
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2011.07.26] - CAM
		subpm_set_output(LDO5,0);
		subpm_output_enable();

//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2011.07.26] - CAM
		//KJK for HDMI Sub PMIC usage 2011.03.10
		//gpio_direction_output(lp8720_pdata.en_gpio_num, 0);
		//subpm_lp8720_power_off();
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2011.07.26] - CAM

        gpio_set_value(DW9716_VCM_ENABLE, 0);

//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2011.07.26] - CAM
		/* This is not required cuz it is disabled in isp_csi_memvs.c*/
		/* isp_disable_mclk(isp); */
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2011.07.26] - CAM

        isp_csi2_complexio_power(&isp->isp_csi2, ISP_CSI2_POWER_OFF);
        isp_csi2_reset(&isp->isp_csi2);
        isp_csi2_ctrl_config_ecc_enable(&isp->isp_csi2, true);
        isp_csi2_complexio_power(&isp->isp_csi2, ISP_CSI2_POWER_OFF);
		break;	
		
	case V4L2_POWER_STANDBY:
//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2011.07.26] - CAM
  #ifdef CONFIG_OMAP2_DSS_HDMI    
  {
    extern int hdmi_power_initialize;
    int hdmi_wait_cnt = 0;
    for(hdmi_wait_cnt = 0; hdmi_wait_cnt<20; hdmi_wait_cnt++)
    {
      if (hdmi_power_initialize== 0)
      {
        printk("==========================================================\n");
        printk("waiting DONE for HDMI : %d looping \n", hdmi_wait_cnt);
        printk("==========================================================\n");
        break;
      }
      printk("==========================================================\n");
      printk("HDMI is not done yet...waiting for HDMI DONE : %d looping \n", hdmi_wait_cnt);
      printk("==========================================================\n");
      msleep(100);
    }
  }
  #endif
//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2011.07.26] - CAM

		printk(KERN_DEBUG "imx072_sensor_power_set(%s)\n",
			(power == V4L2_POWER_OFF) ? "OFF" : "STANDBY");
		/* Power Down Sequence */
		isp_csi2_complexio_power(&isp->isp_csi2, ISP_CSI2_POWER_OFF);

		twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
				VAUX_DEV_GRP_NONE, TWL4030_VAUX4_DEV_GRP);
		gpio_set_value(IMX072_RESET_GPIO, 0);
		udelay(5);
		subpm_set_output(LDO3,0);
		subpm_output_enable();
		subpm_set_output(LDO4,0);
		subpm_output_enable();
		subpm_set_output(SWREG,0);
		subpm_output_enable();
		gpio_free(IMX072_RESET_GPIO);

/* S[, 20120922, [email protected], PM from froyo. */
		doing_wakeup = 0;
/* E], 20120922, [email protected], PM from froyo. */

		/* Remove pm constraints */
		//--[[ LGE_UBIQUIX_MODIFIED_START : [email protected] [2012.05.22] - CAM		
		omap_pm_set_min_bus_tput(vdev->cam->isp, OCP_INITIATOR_AGENT, -1);
		pm_qos_update_request(&pm_qos_handler,
							CLEAR_MPU_CONSTRAINT);
		//--]] LGE_UBIQUIX_MODIFIED_END : [email protected] [2012.05.22] - CAM	

		break;
	}

	/* Save powerstate to know what was before calling POWER_ON. */
	previous_power = power;
	return err;
}