コード例 #1
0
void test_spi(void)
{
    uint8_t i, tmp;
    int n;

    i = 0;

    yushan_spi_write(0x0808, 0x0);
    mdelay(10);
    SPI_Read(0x0808, 1, (uint8_t *)(&tmp));

    if(i != tmp) {
        printk("SPI test fail 1: i %x read tmp is %x\n",i, tmp);
        return;
    }

#if 1
    for(n=0; n<5; n++) {
        pr_info("spi test loop count=%d\n",n);
        i = 0x66;

        yushan_spi_write(0x0808, i);
        mdelay(10);
        SPI_Read(0x808, 1, (uint8_t *)(&tmp));

        if(i != tmp) {
            printk("SPI test fail 2: i %x read tmp is %x\n",i, tmp);

        } else {
            pr_info("SPI test write %x :OK\n",i);
        }

        i = 0x55;

        yushan_spi_write(0x0808, i);
        mdelay(10);
        SPI_Read(0x0808, 1, (uint8_t *)(&tmp));

        if(i != tmp) {
            printk("SPI test fail 3: i %x read tmp is %x\n",i, tmp);

        } else {
            pr_info("SPI test write %x :OK\n",i);
        }

        i = 0xaa;
        yushan_spi_write(0x0808, i);
        mdelay(10);
        SPI_Read(0x0808, 1, (uint8_t *)(&tmp));

        if(i != tmp) {
            printk("SPI test fail 4: i %x read tmp is %x\n",i, tmp);

        } else {
            pr_info("SPI test write %x :OK\n",i);
        }
    }

#endif
}
コード例 #2
0
static int endeavor_s5k6a1gx03_power_on(void)
{
    int ret;

    gpio_direction_output(FRONT_CAM_RST, 0);
    gpio_direction_output(CAM_SEL, 0);

    tegra_gpio_disable(CAM_I2C_SCL);
    tegra_gpio_disable(CAM_I2C_SDA);
    tegra_gpio_disable(CAM_MCLK);

    /* analog */
        ret = regulator_enable(cam_a2v85_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_a2v85_en\n");
		regulator_put(cam_a2v85_en);
		cam_a2v85_en = NULL;
		return ret;
	}
    ENR_usleep(200);
    /* vcm */
	ret = regulator_enable(cam_vcm_2v85_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_vcm_2v85_en\n");
		regulator_put(cam_vcm_2v85_en);
		cam_vcm_2v85_en = NULL;
		return ret;
	}
    ENR_usleep(200);
    /* IO */
	ret = regulator_enable(cam_vddio_1v8_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_vddio_1v8_en\n");
		regulator_put(cam_vddio_1v8_en);
		cam_vddio_1v8_en = NULL;
		return ret;
	}
    ENR_usleep(200);
    /* RSTN */
    gpio_direction_output(FRONT_CAM_RST, 1);
    /* digital */
	ret = regulator_enable(cam2_d1v2_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_d1v2_en\n");
		regulator_put(cam_d1v2_en);
		cam_d1v2_en = NULL;
		return ret;
	}
    /* CAM SEL */
    gpio_direction_output(CAM_SEL, 1);
    ENR_msleep(1);

	/* SPI send command to configure RAWCHIP here! */
	rawchip_spi_clock_control(1);
	yushan_spi_write(0x0008, 0x7f);

    return 0;
}
コード例 #3
0
int rawchip_power_up(const struct msm_camera_rawchip_info *pdata)
{
	int rc = 0;
	CDBG("[CAM] %s\n", __func__);

	if (pdata->camera_rawchip_power_on == NULL) {
		pr_err("rawchip power on platform_data didn't register\n");
		return -EIO;
	}
	rc = pdata->camera_rawchip_power_on();
	if (rc < 0) {
		pr_err("rawchip power on failed\n");
		goto enable_power_on_failed;
	}

#ifdef CONFIG_RAWCHIP_MCLK
	rc = msm_camio_clk_enable(CAMIO_CAM_RAWCHIP_MCLK_CLK);
#else
	rc = msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK);
#endif

	if (rc < 0) {
		pr_err("enable MCLK failed\n");
		goto enable_mclk_failed;
	}
	mdelay(1); 

	rc = gpio_request(pdata->rawchip_reset, "rawchip");
	if (rc < 0) {
		pr_err("GPIO(%d) request failed\n", pdata->rawchip_reset);
		goto enable_reset_failed;
	}
	gpio_direction_output(pdata->rawchip_reset, 1);
	gpio_free(pdata->rawchip_reset);
	mdelay(1); 

	yushan_spi_write(0x0008, 0x7f);
	mdelay(1);

	return rc;

enable_reset_failed:
#ifdef CONFIG_RAWCHIP_MCLK
	rc = msm_camio_clk_disable(CAMIO_CAM_RAWCHIP_MCLK_CLK);
#else
	rc = msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
#endif

enable_mclk_failed:
	if (pdata->camera_rawchip_power_off == NULL)
		pr_err("rawchip power off platform_data didn't register\n");
	else
		pdata->camera_rawchip_power_off();
enable_power_on_failed:
	return rc;
}
コード例 #4
0
static int endeavor_s5k3h2y_power_on(void)
{
    int ret;

    pr_info("[CAM] s5k3h2y power on ++\n");

	if (endeavor_s5k3h2y_power_state)
		return 0;

	tegra_gpio_disable(RAW_SPI_CLK);
	tegra_gpio_disable(RAW_SPI_CS);
	tegra_gpio_disable(RAW_SPI_DI);
	tegra_gpio_disable(RAW_SPI_DO);
	//tegra_gpio_disable(RAW_INTR0);
	//tegra_gpio_disable(RAW_INTR1);
	tegra_gpio_disable(CAM_I2C_SCL_GPIO);
	tegra_gpio_disable(CAM_I2C_SDA_GPIO);
	tegra_gpio_disable(CAM_MCLK_GPIO);

    gpio_direction_output(CAM_PWDN, 0);
    gpio_direction_output(CAM1_VCM_PD_GPIO, 0);
    #if RAWCHIP
    gpio_direction_output(RAW_RSTN, 0);
    #endif
    //ENR_msleep(1); //TODO

#ifdef CAMERA_REGULATOR
    //pr_info("[CAM] use regurator to get power\n");

	#if RAWCHIP
	/*RAW_1V8_EN */
	gpio_direction_output(RAW_1V8_EN, 1);
	ENR_usleep(200);
	#endif

	/* VCM */
	ret = regulator_enable(cam_vcm_2v85_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator v_cam1_vcm_2v85\n");
		regulator_put(cam_vcm_2v85_en);
		cam_vcm_2v85_en = NULL;
		return ret;
	}

    /* main/front cam analog*/
	ret = regulator_enable(cam_a2v85_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_a2v85_en\n");
		regulator_put(cam_a2v85_en);
		cam_a2v85_en = NULL;
		return ret;
	}
    ENR_usleep(200);
 
    /*main cam core 1v2 & rawchip external 1v2 */
	ret = regulator_enable(cam_d1v2_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_d1v2_en\n");
		regulator_put(cam_d1v2_en);
		cam_d1v2_en = NULL;
		return ret;
	}
	ENR_usleep(200);
 
	#if RAWCHIP
	/*RAW_1V2_EN */
    if (htc_get_pcbid_info() < PROJECT_PHASE_XE) {
        gpio_direction_output(RAW_1V2_EN, 1);
	    ENR_usleep(200);
    }
	#endif

    /* IO */
	ret = regulator_enable(cam_vddio_1v8_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_vddio_1v8_en\n");
		regulator_put(cam_vddio_1v8_en);
		cam_vddio_1v8_en = NULL;
		return ret;
	}
    ENR_usleep(100);

    /*CAM SEL */
    gpio_direction_output(CAM_SEL_GPIO, 0);
    ENR_usleep(100);

    #if RAWCHIP
    /*RAW_RSTN */
    gpio_direction_output(RAW_RSTN, 1);
    ENR_msleep(3);
    /*SPI send command to configure RAWCHIP here!*/
	yushan_spi_write(0x0008, 0x7f);
	ENR_msleep(1);
    #endif

    /* XSHUTDOWM */
    gpio_direction_output(CAM_PWDN, 1);
    ENR_usleep(100);

     /* VCM PD*/
    gpio_direction_output(CAM1_VCM_PD_GPIO, 1);
    ENR_usleep(100);

#else/* use gpio pull up to get power*/
      #if RAWCHIP
	/*RAW_1V8_EN */
	gpio_direction_output(RAW_1V8_EN, 1);
	ENR_usleep(200);
      #endif

	/* VCM */
	gpio_direction_output(CAM_VCM2V85, 1);
	ENR_usleep(200);

	/* analog */
	gpio_direction_output(CAM_A2V85_EN, 1);
	ENR_usleep(200);

	/*core*/
	gpio_direction_output(CAM_D1V2_EN, 1);
	ENR_usleep(200);

	#if RAWCHIP
	/*RAW_1V2_EN */
    if (htc_get_pcbid_info() < PROJECT_PHASE_XE) {
	    ret = gpio_direction_output(RAW_1V2_EN, 1);
	    ENR_usleep(200);
    }
    #endif

	/* IO */
	gpio_direction_output(CAMIO_1V8_EN, 1);
	ENR_usleep(100);

	/*CAM SEL */
	gpio_direction_output(CAM_SEL_GPIO, 0);
	ENR_usleep(100);

      #if RAWCHIP
	/*RAW_RSTN */
	ret = gpio_direction_output(RAW_RSTN, 1);
	ENR_msleep(3);

      /*SPI send command to configure RAWCHIP here!*/
	  yushan_spi_write(0x0008, 0x7f);
		ENR_msleep(1);
      #endif

	/* XSHUTDOWM */
	gpio_direction_output(CAM_PWDN, 1);
	ENR_usleep(100);
	/* VCM PD*/
	gpio_direction_output(CAM1_VCM_PD_GPIO, 1);
	ENR_usleep(100);
#endif
	endeavor_s5k3h2y_power_state = 1;
    //pr_info("[CAM] s5k3h2y power on --\n");
    return 0;
}
コード例 #5
0
int rawchip_power_up(const struct msm_camera_rawchip_info *pdata)
{
    int rc = 0;
    CDBG("[CAM]%s\n", __func__);

    if (pdata->camera_rawchip_power_on == NULL) {
        pr_err("[CAM]rawchip power on platform_data didn't register\n");
        return -EIO;
    }
    rc = pdata->camera_rawchip_power_on();
    if (rc < 0) {
        pr_err("[CAM] rawchip power on failed\n");
        goto enable_power_on_failed;
    }

    rc = msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK);
    if (rc < 0) {
        pr_err("[CAM] enable MCLK failed\n");
        goto enable_mclk_failed;
    }
    mdelay(1);

#if ((defined CONFIG_I2C_CPLD) && ((defined CONFIG_MACH_DUMMY) || (defined CONFIG_MACH_DUMMY) || (defined CONFIG_MACH_DUMMY)))
    pr_info("[CAM]%s rawchip reset High", __func__);
    rc = cpld_gpio_write(pdata->rawchip_reset, 1);
    if(rc < 0) {
        pr_err("[CAM]%s: rawchip_reset fail\n", __func__);
        goto enable_reset_failed;
    }
    mdelay(1);
#else
    rc = gpio_request(pdata->rawchip_reset, "rawchip");
    if (rc < 0) {
        pr_err("GPIO(%d) request failed\n", pdata->rawchip_reset);
        goto enable_reset_failed;
    }

    pr_info("[CAM]%s rawchip reset High", __func__);
    gpio_direction_output(pdata->rawchip_reset, 1);
    gpio_free(pdata->rawchip_reset);
    mdelay(1);
#endif

    yushan_spi_write(0x0008, 0x7f);
    mdelay(1);

    {
        uint16_t uwSpiData = 0x1E00;
        SPI_Write(0x1018, 2, (unsigned char*)&uwSpiData);
    }

    return rc;

enable_reset_failed:
    msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
enable_mclk_failed:
    if (pdata->camera_rawchip_power_off == NULL)
        pr_err("rawchip power off platform_data didn't register\n");
    else
        pdata->camera_rawchip_power_off();
enable_power_on_failed:
    return rc;
}
コード例 #6
0
static int endeavor_s5k3h2y_power_on(void)
{
    int ret;

    if (endeavor_s5k3h2y_power_state) {
	pr_info("[CAM] %s already power on, return 0", __func__);
	return 0;
    }

	tegra_gpio_disable(MCAM_SPI_CLK);
	tegra_gpio_disable(MCAM_SPI_CS0);
	tegra_gpio_disable(MCAM_SPI_DI);
	tegra_gpio_disable(MCAM_SPI_DO);
	tegra_gpio_disable(CAM_I2C_SCL);
	tegra_gpio_disable(CAM_I2C_SDA);
	tegra_gpio_disable(CAM_MCLK);

    gpio_direction_output(CAM1_PWDN, 0);
    gpio_direction_output(CAM1_VCM_PD, 0);
    gpio_direction_output(RAW_RSTN, 0);

	/* RAW_1V8_EN */
	gpio_direction_output(RAW_1V8_EN, 1);
	ENR_usleep(200);

	/* VCM */
	ret = regulator_enable(cam_vcm_2v85_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator v_cam1_vcm_2v85\n");
		regulator_put(cam_vcm_2v85_en);
		cam_vcm_2v85_en = NULL;
		return ret;
	}

    	/* main/front cam analog */
	ret = regulator_enable(cam_a2v85_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_a2v85_en\n");
		regulator_put(cam_a2v85_en);
		cam_a2v85_en = NULL;
		return ret;
	}
    	ENR_usleep(200);
 
    	/* main cam core 1v2 & rawchip external 1v2 */
	ret = regulator_enable(cam_d1v2_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_d1v2_en\n");
		regulator_put(cam_d1v2_en);
		cam_d1v2_en = NULL;
		return ret;
	}
	ENR_usleep(200);
 
	/* RAW_1V2_EN */
    	if (htc_get_pcbid_info() < PROJECT_PHASE_XE) {
        	gpio_direction_output(RAW_1V2_EN, 1);
		ENR_usleep(200);
    	}

    	/* IO */
	ret = regulator_enable(cam_vddio_1v8_en);
	if (ret < 0) {
		pr_err("[CAM] couldn't enable regulator cam_vddio_1v8_en\n");
		regulator_put(cam_vddio_1v8_en);
		cam_vddio_1v8_en = NULL;
		return ret;
	}
    	ENR_usleep(100);

	/* CAM SEL */
	gpio_direction_output(CAM_SEL, 0);
	ENR_usleep(100);

	/* RAW_RSTN */
	gpio_direction_output(RAW_RSTN, 1);
	ENR_msleep(3);

	/* SPI send command to configure RAWCHIP here! */
	rawchip_spi_clock_control(1);
	yushan_spi_write(0x0008, 0x7f);
	ENR_msleep(1);

	/* XSHUTDOWM */
	gpio_direction_output(CAM1_PWDN, 1);
	ENR_usleep(100);

	/* VCM PD */
	gpio_direction_output(CAM1_VCM_PD, 1);
	ENR_usleep(100);

	endeavor_s5k3h2y_power_state = 1;

    return 0;
}
コード例 #7
0
static int enrc2b_s5k6a1gx03_power_on(void)
{
	int ret;
	int pcbid = htc_get_pcbid_info();
	pr_info("[CAM] %s ++", __func__);

	enrc2b_set_regulator();

	gpio_direction_output(CAM_MCLK, 0);

#if defined(CONFIG_RAWCHIP_ENABLE)
	if ((pcbid >= PROJECT_PHASE_XB) || (pcbid == PROJECT_PHASE_EVM) || is_global_sku)
	{
		tegra_gpio_disable(MCAM_SPI_CLK);
		tegra_gpio_disable(MCAM_SPI_DO);
		tegra_gpio_disable(MCAM_SPI_DI);
		tegra_gpio_disable(MCAM_SPI_CS0);
		tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_ROW0, TEGRA_PUPD_NORMAL);
		tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_CLK3_REQ, TEGRA_PUPD_NORMAL);
	}
#endif

	tegra_gpio_disable(CAM_I2C_SCL);
	tegra_gpio_disable(CAM_I2C_SDA);

	gpio_direction_output(CAM1_PWDN, 0);

	gpio_direction_output(FRONT_CAM_RST, 0);

	gpio_direction_output(CAM1_VCM_PD, 0);

#if defined(CONFIG_RAWCHIP_ENABLE)
	if ((pcbid >= PROJECT_PHASE_XB) || (pcbid == PROJECT_PHASE_EVM) || is_global_sku)
	{
		gpio_direction_output(RAW_RSTN, 0);
	}
#endif

	gpio_direction_output(CAM_SEL, 0);

#if defined(CONFIG_RAWCHIP_ENABLE)
	if ((pcbid >= PROJECT_PHASE_XB) || (pcbid == PROJECT_PHASE_EVM) || is_global_sku)
	{
		/* RAW_1V8_EN */
		gpio_direction_output(RAW_1V8_EN, 1);
		ENR_usleep(200);
	}
#endif

	/* vcm */
	ret = regulator_enable(cam_vcm2v85_en);
	if (ret < 0)
	{
		pr_err("[CAM] couldn't enable regulator cam_vcm2v85_en\n");
		regulator_put(cam_vcm2v85_en);
		cam_vcm2v85_en = NULL;
		return ret;
	}
	ENR_usleep(200);

	/* analog */
	ret = regulator_enable(cam_a2v85_en);
	if (ret < 0)
	{
		pr_err("[CAM] couldn't enable regulator cam_a2v85_en\n");
		regulator_put(cam_a2v85_en);
		cam_a2v85_en = NULL;
		return ret;
	}
	ENR_usleep(200);

#if defined(CONFIG_RAWCHIP_ENABLE)
	if ((pcbid >= PROJECT_PHASE_XB) || (pcbid == PROJECT_PHASE_EVM) || is_global_sku)
	{
		/* main camera core */
		gpio_direction_output(CAM_D1V2_EN, 1);
		ENR_usleep(200);
	}
#endif

	/* IO */
	gpio_direction_output(CAMIO_1V8_EN, 1);
	ENR_usleep(200);

	/* RSTN */
	gpio_direction_output(FRONT_CAM_RST, 1);

	/* digital */
	gpio_direction_output(CAM2_D1V2_EN, 1);
	ENR_usleep(200);

	/* CAM SEL */
	gpio_direction_output(CAM_SEL, 1);
	ENR_msleep(1);

	tegra_gpio_disable(CAM_MCLK);
	ENR_msleep(1);

#if defined(CONFIG_RAWCHIP_ENABLE)
	if ((pcbid >= PROJECT_PHASE_XB) || (pcbid == PROJECT_PHASE_EVM) || is_global_sku)
	{
		/* RAW_RSTN */
		ret = gpio_direction_output(RAW_RSTN, 1);
		ENR_msleep(1);

		/* SPI send command to configure RAWCHIP here! */
		rawchip_spi_clock_control(1);
		yushan_spi_write(0x0008, 0x7f);
		ENR_msleep(1);
	}
#endif

	pr_info("[CAM] %s --", __func__);
	return 0;
}
コード例 #8
0
static int enrc2b_main_power_on(void)
{
	int ret;

	pr_info("[CAM] %s ++: %s", __func__, camera_module_name[cam_src]);

	if (enrc2b_power_state) {
		pr_info("[CAM] %s already power on, return 0", __func__);
		return 0;
	}

	enrc2b_set_regulator();

	gpio_direction_output(CAM_MCLK, 0);

	tegra_gpio_disable(CAM_I2C_SCL);
	tegra_gpio_disable(CAM_I2C_SDA);

	tegra_gpio_disable(MCAM_SPI_CLK);
	tegra_gpio_disable(MCAM_SPI_DO);
	tegra_gpio_disable(MCAM_SPI_DI);
	tegra_gpio_disable(MCAM_SPI_CS0);
	tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_KB_ROW0, TEGRA_PUPD_NORMAL);
	tegra_pinmux_set_pullupdown(TEGRA_PINGROUP_CLK3_REQ, TEGRA_PUPD_NORMAL);

	gpio_direction_output(CAM1_PWDN, 0);

	gpio_direction_output(FRONT_CAM_RST, 0);

	gpio_direction_output(CAM1_VCM_PD, 0);

#if defined(CONFIG_RAWCHIP_ENABLE)
	/* RAW_RSTN */
	ret = gpio_direction_output(RAW_RSTN, 0);
#endif

	/* CAM SEL */
	gpio_direction_output(CAM_SEL, 0);

#if defined(CONFIG_RAWCHIP_ENABLE)
	/* RAW_1V8_EN */
	gpio_direction_output(RAW_1V8_EN, 1);
	ENR_usleep(200);
#endif

	/* VCM */
	ret = regulator_enable(cam_vcm2v85_en);
	if (ret < 0)
	{
		pr_err("[CAM] couldn't enable regulator v_cam1_vcm_2v85\n");
		regulator_put(cam_vcm2v85_en);
		cam_vcm2v85_en = NULL;
		return ret;
	}

	/* main/front cam analog*/
	ret = regulator_enable(cam_a2v85_en);
	if (ret < 0)
	{
		pr_err("[CAM] couldn't enable regulator cam_a2v85_en\n");
		regulator_put(cam_a2v85_en);
		cam_a2v85_en = NULL;
		return ret;
	}
	ENR_usleep(200);

	/* core */
	gpio_direction_output(CAM_D1V2_EN, 1);
	ENR_usleep(200);

	/* IO */
	gpio_direction_output(CAMIO_1V8_EN, 1);
	ENR_usleep(200);

	tegra_gpio_disable(CAM_MCLK);
	ENR_msleep(3);

#if defined(CONFIG_RAWCHIP_ENABLE)
	/* RAW_RSTN */
	ret = gpio_direction_output(RAW_RSTN, 1);
	ENR_msleep(1);

	pr_info("[CAM] %s, rawchip power on, send SPI command", __func__);
	rawchip_spi_clock_control(1);
	/* SPI send command to configure RAWCHIP here! */
	yushan_spi_write(0x0008, 0x7f);
	pr_info("[CAM] %s, rawchip power on done", __func__);
	ENR_msleep(1);
#endif

	/* XSHUTDOWM */
	gpio_direction_output(CAM1_PWDN, 1);
	ENR_msleep(1);

	gpio_direction_output(CAM1_VCM_PD, 1);

	enrc2b_power_state = 1;
	pr_info("[CAM] %s --", __func__);
	return 0;
}