Example #1
0
static int icp_hd_power(int on)
{
	int rc = 0;
		SKYCDBG("%s %s:%d power = %d\n", __FILE__, __func__, __LINE__,on);
	if(on) {
		//standby control
		rc = gpio_tlmm_config(GPIO_CFG(SENSOR_STANDBY_8M, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),GPIO_CFG_ENABLE);
		if (!rc) {
			SKYCDBG("%s %s:%d\n", __FILE__, __func__, __LINE__);
			gpio_set_value(SENSOR_STANDBY_8M,0);					
		}
		
		rc = regulator_enable(s2b_1p2v_8m);
		if (rc) {
			SKYCERR("%s: Enable regulator s2b_1p2v failed\n", __func__);
			goto fail;
		}
		msleep(1);
		
		rc = regulator_enable(lvs3b_1p8v_8m);
		if (rc) {
			SKYCERR("%s: Enable regulator mvs0b_1p8v failed\n", __func__);
			goto fail;
		}
		msleep(1);
		
		rc = regulator_enable(mvs0b_1p8v);
		if (rc) {
			SKYCERR("%s: Enable regulator mvs0b_1p8v failed\n", __func__);
			goto fail;
		}		
		msleep(1);
		
		rc = regulator_enable(l20a_2p8v_8m);
		if (rc) {
			SKYCERR("%s: Enable regulator l20a_2p8v failed\n", __func__);
			goto fail;
		}
		msleep(1);
		
		rc = regulator_enable(l14a_2p8v_8m);
		if (rc) {
			SKYCERR("%s: Enable regulator l14a_2p8v failed\n", __func__);
			goto fail;
		}

		SKYCDBG("%s %s ON Success:%d\n", __FILE__, __func__, __LINE__);
	}
	else {
		SKYCDBG("%s %s:%d power \n", __FILE__, __func__, __LINE__);
#if 0		
		if(1)//s2b_1p2v) 
		{
			rc = regulator_disable(s2b_1p2v_8m);
			if (rc){
				SKYCERR("%s: Disable regulator s2b_1p2v failed\n", __func__);
				goto fail;
			}
			regulator_put(s2b_1p2v_8m);
		}
		
		if(mvs0b_1p8v) {
			rc = regulator_disable(mvs0b_1p8v);
			if (rc){
				SKYCERR("%s: Disable regulator mvs0b_1p8v failed\n", __func__);		
				goto fail;
			}
		}
#endif		
		SKYCDBG("%s %s:%d power \n", __FILE__, __func__, __LINE__);
		if(1)//mvs0b_1p8v) 
		{
			rc = regulator_disable(lvs3b_1p8v_8m);
			if (rc){
				SKYCERR("%s: Disable regulator lvs3b_1p8v failed\n", __func__);
				goto fail;
			}
		}
		SKYCDBG("%s %s:%d power \n", __FILE__, __func__, __LINE__);
		if(1)//l20a_2p8v) 
		{
			rc = regulator_disable(l20a_2p8v_8m);
			if (rc){
				SKYCERR("%s: Disable regulator l20a_2p8v failed\n", __func__);
				goto fail;
			}
			regulator_put(l20a_2p8v_8m);
		}
		SKYCDBG("%s %s:%d power \n", __FILE__, __func__, __LINE__);
		if(1)//l14a_2p8v) 
		{
		rc = regulator_disable(l14a_2p8v_8m);
			if (rc){
				SKYCERR("%s: Disable regulator l14a_2p8v failed\n", __func__);
				goto fail;
			}
			regulator_put(l14a_2p8v_8m);		
		}
		SKYCDBG("%s %s OFF Success:%d\n", __FILE__, __func__, __LINE__);
	}
	
	return rc;
fail:
	SKYCERR("%s %s Failed!:%d\n", __FILE__, __func__, __LINE__);
	if(l20a_2p8v_8m){
		regulator_put(l20a_2p8v_8m);
	}
	if(s2b_1p2v_8m){
		regulator_put(s2b_1p2v_8m);
	}
	if(l14a_2p8v_8m){
		regulator_put(l14a_2p8v_8m);
	}
	return rc;			
}
void sku3_lcdc_lcd_camera_power_init(void)
{
	int rc = 0;
	u32 socinfo = socinfo_get_platform_type();

	  /* LDO_EXT2V8 */
	if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
		pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
		return;
	}

	rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 0,
		GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
		GPIO_CFG_ENABLE);

	if (rc < 0) {
		pr_err("%s:unable to enable lcd_camera_ldo_2v8!\n", __func__);
		goto fail_gpio2;
	}

	/* LDO_EVT1V8 */
	if (socinfo == 0x0B) {
		if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_1V8,
				"lcd_camera_ldo_1v8")) {
			pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
			goto fail_gpio1;
		}

		rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_1V8, 0,
			GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
			GPIO_CFG_ENABLE);

		if (rc < 0) {
			pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
				__func__);
			goto fail_gpio1;
		}
	} else if (socinfo == 0x0F || machine_is_msm8625_qrd7()) {
		if (gpio_request(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
				"lcd_camera_ldo_1v8")) {
			pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
			goto fail_gpio1;
		}

		rc = gpio_tlmm_config(GPIO_CFG(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
			0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
			GPIO_CFG_ENABLE);

		if (rc < 0) {
			pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
				__func__);
			goto fail_gpio1;
		}
	}

	rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_truly_lcdc),
			regs_truly_lcdc);
	if (rc)
		pr_err("%s: could not get regulators: %d\n", __func__, rc);

	rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_truly_lcdc),
			regs_truly_lcdc);
	if (rc)
		pr_err("%s: could not set voltages: %d\n", __func__, rc);

	return;

fail_gpio1:
	if (socinfo == 0x0B)
		gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_1V8);
	else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
		gpio_free(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8);
fail_gpio2:
	gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_2V8);
	return;
}
static int mipi_dsi_panel_msm_power(int on)
{
	/*++ Huize - 20120927 Modify for identifying what the code is used by customization ++*/
	#ifdef DISPLAY_CUSTOMIZATION
	int rc = 0;
	if (unlikely(!dsi_gpio_initialized)) {
		pr_emerg("%s\n", __func__);
		#ifndef CONFIG_LEDS_CHIP_LM3533
		rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bl_en");
		if (rc < 0) {
			pr_err("failed to request gpio_bl_en\n");
			return rc;
		}
		rc = gpio_tlmm_config(
			GPIO_CFG(GPIO_BACKLIGHT_EN,0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
			GPIO_CFG_ENABLE);
		#endif	
		if (rc) {
			pr_err("Failed to enable gpio_bl_en\n");
			goto fail_gpio1;
		}
		rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi);
		if (rc) {
			pr_err("%s: could not get regulators: %d\n",
					__func__, rc);
			goto fail_gpio2;
		}

		rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi), regs_dsi);
		if (rc) {
			pr_err("%s: could not set voltages: %d\n",
					__func__, rc);
			goto fail_vreg;
		}

		dsi_gpio_initialized = 1;
	}
	#else
	int rc = 0;
	uint32_t lcdc_reset_cfg;

	/* I2C-controlled GPIO Expander -init of the GPIOs very late */
	if (unlikely(!dsi_gpio_initialized)) {
		pmapp_disp_backlight_init();

		rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr");
		if (rc < 0) {
			pr_err("failed to request gpio_disp_pwr\n");
			return rc;
		}

		if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()
				|| machine_is_msm8625_surf()) {
			rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1);
			if (rc < 0) {
				pr_err("failed to enable display pwr\n");
				goto fail_gpio1;
			}

			rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
			if (rc < 0) {
				pr_err("failed to request gpio_bkl_en\n");
				goto fail_gpio1;
			}

			rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
			if (rc < 0) {
				pr_err("failed to enable backlight\n");
				goto fail_gpio2;
			}
		}

		rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi);
		if (rc) {
			pr_err("%s: could not get regulators: %d\n",
					__func__, rc);
			goto fail_gpio2;
		}

		rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi),
						regs_dsi);
		if (rc) {
			pr_err("%s: could not set voltages: %d\n",
					__func__, rc);
			goto fail_vreg;
		}
		if (pmapp_disp_backlight_set_brightness(100))
			pr_err("backlight set brightness failed\n");

		dsi_gpio_initialized = 1;
	}
	if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
			machine_is_msm8625_surf()) {
		gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
		gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
	} else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()
					|| machine_is_msm8625_ffa()) {
		if (on) {
			/* This line drives an active low pin on FFA */
			rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on);
			if (rc < 0)
				pr_err("failed to set direction for "
					"display pwr\n");
		} else {
			gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on);
			rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN);
			if (rc < 0)
				pr_err("failed to set direction for "
					"display pwr\n");
		}
	}

	if (on) {
		gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);

		if (machine_is_msm7x27a_surf() ||
				 machine_is_msm7625a_surf() ||
				 machine_is_msm8625_surf()) {
			lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr);
			rmb();
			lcdc_reset_cfg &= ~1;

			writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
			msleep(20);
			wmb();
			lcdc_reset_cfg |= 1;
			writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
		} else {
			gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
			msleep(20);
			gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
		}
	} else {
		gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1);
	}
	#endif
	/*-- Huize - 20120927 Modify for identifying what the code is used by customization --*/

	rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) :
		  regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi);

	if (rc)
		pr_err("%s: could not %sable regulators: %d\n",
				__func__, on ? "en" : "dis", rc);

	return rc;
fail_vreg:
	regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi);
fail_gpio2:
	gpio_free(GPIO_BACKLIGHT_EN);
fail_gpio1:
//Jordan-20111230 , remove 	
//	gpio_free(GPIO_DISPLAY_PWR_EN);
	dsi_gpio_initialized = 0;
	return rc;
}
Example #4
0
static int mipi_dsi_on(struct platform_device *pdev)
{
	int ret = 0;
	u32 clk_rate;
	struct msm_fb_data_type *mfd;
	struct fb_info *fbi;
	struct fb_var_screeninfo *var;
	struct msm_panel_info *pinfo;
	struct mipi_panel_info *mipi;
	u32 hbp, hfp, vbp, vfp, hspw, vspw, width, height;
	u32 ystride, bpp, data;
	u32 dummy_xres, dummy_yres;
	int target_type = 0;
	u32 tmp;

	pr_debug("%s+:\n", __func__);

#if defined(CONFIG_ESD_ERR_FG_RECOVERY)
	pdev_for_esd = pdev;
#endif
	mfd = platform_get_drvdata(pdev);
	fbi = mfd->fbi;
	var = &fbi->var;
	pinfo = &mfd->panel_info;
	esc_byte_ratio = pinfo->mipi.esc_byte_ratio;

	if (mipi_dsi_pdata && mipi_dsi_pdata->power_common)
		mipi_dsi_pdata->power_common();

#if defined(CONFIG_SUPPORT_SECOND_POWER)
	if (mipi_dsi_pdata && mipi_dsi_pdata->panel_power_save)
		mipi_dsi_pdata->panel_power_save(1);
#endif

	if (system_rev == 6)
		mdelay(500);

	if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_power_save)
		mipi_dsi_pdata->dsi_power_save(1);

	cont_splash_clk_ctrl(0);
	mipi_dsi_prepare_clocks();

	mipi_dsi_ahb_ctrl(1);

	clk_rate = mfd->fbi->var.pixclock;
	clk_rate = min(clk_rate, mfd->panel_info.clk_max);

	mipi_dsi_phy_ctrl(1);

	if (mdp_rev == MDP_REV_42 && mipi_dsi_pdata)
		target_type = mipi_dsi_pdata->target_type;

	mipi_dsi_phy_init(0, &(mfd->panel_info), target_type);

	mipi_dsi_clk_enable();

	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 1);
	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 0);

	hbp = var->left_margin;
	hfp = var->right_margin;
	vbp = var->upper_margin;
	vfp = var->lower_margin;
	hspw = var->hsync_len;
	vspw = var->vsync_len;
	width = mfd->panel_info.xres;
	height = mfd->panel_info.yres;

	mipi  = &mfd->panel_info.mipi;
	if (mfd->panel_info.type == MIPI_VIDEO_PANEL) {
		dummy_xres = mfd->panel_info.lcdc.xres_pad;
		dummy_yres = mfd->panel_info.lcdc.yres_pad;

		if (mdp_rev >= MDP_REV_41) {
			MIPI_OUTP(MIPI_DSI_BASE + 0x20,
				((hspw + hbp + width + dummy_xres) << 16 |
				(hspw + hbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x24,
				((vspw + vbp + height + dummy_yres) << 16 |
				(vspw + vbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x28,
				(vspw + vbp + height + dummy_yres +
					vfp - 1) << 16 | (hspw + hbp +
					width + dummy_xres + hfp - 1));
		} else {
			/* DSI_LAN_SWAP_CTRL */
			MIPI_OUTP(MIPI_DSI_BASE + 0x00ac, mipi->dlane_swap);

			MIPI_OUTP(MIPI_DSI_BASE + 0x20,
				((hbp + width + dummy_xres) << 16 | (hbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x24,
				((vbp + height + dummy_yres) << 16 | (vbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x28,
				(vbp + height + dummy_yres + vfp) << 16 |
					(hbp + width + dummy_xres + hfp));
		}

		MIPI_OUTP(MIPI_DSI_BASE + 0x2c, (hspw << 16));
		MIPI_OUTP(MIPI_DSI_BASE + 0x30, 0);
		MIPI_OUTP(MIPI_DSI_BASE + 0x34, (vspw << 16));

	} else {		/* command mode */
		if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB888)
			bpp = 3;
		else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB666)
			bpp = 3;
		else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB565)
			bpp = 2;
		else
			bpp = 3;	/* Default format set to RGB888 */

		ystride = width * bpp + 1;

		/* DSI_COMMAND_MODE_MDP_STREAM_CTRL */
		data = (ystride << 16) | (mipi->vc << 8) | DTYPE_DCS_LWRITE;
		MIPI_OUTP(MIPI_DSI_BASE + 0x5c, data);
		MIPI_OUTP(MIPI_DSI_BASE + 0x54, data);

		/* DSI_COMMAND_MODE_MDP_STREAM_TOTAL */
		data = height << 16 | width;
		MIPI_OUTP(MIPI_DSI_BASE + 0x60, data);
		MIPI_OUTP(MIPI_DSI_BASE + 0x58, data);
	}

	mipi_dsi_host_init(mipi);

	msleep(10);

	/* LP11 */
	tmp = MIPI_INP(MIPI_DSI_BASE + 0xA8);
	tmp &= ~(1<<28);
	MIPI_OUTP(MIPI_DSI_BASE + 0xA8, tmp);
	wmb();
	/* LP11 */

	usleep(5000);
	if (mipi_dsi_pdata && mipi_dsi_pdata->active_reset)
			mipi_dsi_pdata->active_reset(1); /* high */
	usleep(10000);

	/* always high */
	if (mipi->force_clk_lane_hs) {
		tmp = MIPI_INP(MIPI_DSI_BASE + 0xA8);
		tmp |= (1<<28);
		MIPI_OUTP(MIPI_DSI_BASE + 0xA8, tmp);
		wmb();
	}

	if (mdp_rev >= MDP_REV_41)
		mutex_lock(&mfd->dma->ov_mutex);
	else
		down(&mfd->dma->mutex);

	ret = panel_next_on(pdev);

	mipi_dsi_op_mode_config(mipi->mode);

	if (mfd->panel_info.type == MIPI_CMD_PANEL) {
		if (pinfo->lcd.vsync_enable) {
			if (pinfo->lcd.hw_vsync_mode && vsync_gpio >= 0) {
				if (mdp_rev >= MDP_REV_41) {
					if (gpio_request(vsync_gpio,
						"MDP_VSYNC") == 0)
						gpio_direction_input(
							vsync_gpio);
					else
						pr_err("%s: unable to \
							request gpio=%d\n",
							__func__, vsync_gpio);
				} else if (mdp_rev == MDP_REV_303) {
					if (!tlmm_settings && gpio_request(
						vsync_gpio, "MDP_VSYNC") == 0) {
						ret = gpio_tlmm_config(
							GPIO_CFG(
							vsync_gpio, 1,
							GPIO_CFG_INPUT,
							GPIO_CFG_PULL_DOWN,
							GPIO_CFG_2MA),
							GPIO_CFG_ENABLE);

						if (ret) {
							pr_err(
							"%s: unable to config \
							tlmm = %d\n",
							__func__, vsync_gpio);
						}
						tlmm_settings = TRUE;

						gpio_direction_input(
							vsync_gpio);
					} else {
						if (!tlmm_settings) {
							pr_err(
							"%s: unable to request \
							gpio=%d\n",
							__func__, vsync_gpio);
						}
					}
				}
Example #5
0
static int mipi_dsi_on(struct platform_device *pdev)
{
	int ret = 0;
	u32 clk_rate;
	struct msm_fb_data_type *mfd;
	struct fb_info *fbi;
	struct fb_var_screeninfo *var;
	struct msm_panel_info *pinfo;
	struct mipi_panel_info *mipi;
	u32 hbp, hfp, vbp, vfp, hspw, vspw, width, height;
	u32 ystride, bpp, data;
	u32 dummy_xres, dummy_yres;
	int target_type = 0;

	pr_debug("%s+:\n", __func__);

	mfd = platform_get_drvdata(pdev);
	fbi = mfd->fbi;
	var = &fbi->var;
	pinfo = &mfd->panel_info;
	esc_byte_ratio = pinfo->mipi.esc_byte_ratio;
	printk(KERN_INFO"%s is started.. \n", __func__);

	if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_power_save)
		mipi_dsi_pdata->dsi_power_save(1);

	cont_splash_clk_ctrl(0);
	mipi_dsi_prepare_clocks();

	mipi_dsi_ahb_ctrl(1);

	clk_rate = mfd->fbi->var.pixclock;
	clk_rate = min(clk_rate, mfd->panel_info.clk_max);

	mipi_dsi_phy_ctrl(1);

	if (mdp_rev == MDP_REV_42 && mipi_dsi_pdata)
		target_type = mipi_dsi_pdata->target_type;

	mipi_dsi_phy_init(0, &(mfd->panel_info), target_type);

	mipi_dsi_clk_enable();

	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 1);
	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 0);

	hbp = var->left_margin;
	hfp = var->right_margin;
	vbp = var->upper_margin;
	vfp = var->lower_margin;
	hspw = var->hsync_len;
	vspw = var->vsync_len;
	width = mfd->panel_info.xres;
	height = mfd->panel_info.yres;

	mipi  = &mfd->panel_info.mipi;
	if (mfd->panel_info.type == MIPI_VIDEO_PANEL) {
		dummy_xres = mfd->panel_info.lcdc.xres_pad;
		dummy_yres = mfd->panel_info.lcdc.yres_pad;

		if (mdp_rev >= MDP_REV_41) {
			MIPI_OUTP(MIPI_DSI_BASE + 0x20,
				((hspw + hbp + width + dummy_xres) << 16 |
				(hspw + hbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x24,
				((vspw + vbp + height + dummy_yres) << 16 |
				(vspw + vbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x28,
				(vspw + vbp + height + dummy_yres +
					vfp - 1) << 16 | (hspw + hbp +
					width + dummy_xres + hfp - 1));
		} else {
			/* DSI_LAN_SWAP_CTRL */
			MIPI_OUTP(MIPI_DSI_BASE + 0x00ac, mipi->dlane_swap);

			MIPI_OUTP(MIPI_DSI_BASE + 0x20,
				((hbp + width + dummy_xres) << 16 | (hbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x24,
				((vbp + height + dummy_yres) << 16 | (vbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x28,
				(vbp + height + dummy_yres + vfp) << 16 |
					(hbp + width + dummy_xres + hfp));
		}

		MIPI_OUTP(MIPI_DSI_BASE + 0x2c, (hspw << 16));
		MIPI_OUTP(MIPI_DSI_BASE + 0x30, 0);
		MIPI_OUTP(MIPI_DSI_BASE + 0x34, (vspw << 16));

	} else {		/* command mode */
		if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB888)
			bpp = 3;
		else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB666)
			bpp = 3;
		else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB565)
			bpp = 2;
		else
			bpp = 3;	/* Default format set to RGB888 */

		ystride = width * bpp + 1;

		/* DSI_COMMAND_MODE_MDP_STREAM_CTRL */
		data = (ystride << 16) | (mipi->vc << 8) | DTYPE_DCS_LWRITE;
		MIPI_OUTP(MIPI_DSI_BASE + 0x5c, data);
		MIPI_OUTP(MIPI_DSI_BASE + 0x54, data);

		/* DSI_COMMAND_MODE_MDP_STREAM_TOTAL */
		data = height << 16 | width;
		MIPI_OUTP(MIPI_DSI_BASE + 0x60, data);
		MIPI_OUTP(MIPI_DSI_BASE + 0x58, data);
	}

	mipi_dsi_host_init(mipi);

	if (mipi->force_clk_lane_hs) {
		u32 tmp;

		tmp = MIPI_INP(MIPI_DSI_BASE + 0xA8);
		tmp |= (1<<28);
		MIPI_OUTP(MIPI_DSI_BASE + 0xA8, tmp);
		wmb();
	}

	if (mdp_rev >= MDP_REV_41)
		mutex_lock(&mfd->dma->ov_mutex);
	else
		down(&mfd->dma->mutex);
#if defined(CONFIG_MACH_LGE)
/* LGE_CHANGE
 * in case of WXGA panel,
 * video mode MUST NOT be set prior to power_on_cmd seq.
 * 2012-09-01 chaeuk.lee@lge.com
 */
	ret = panel_next_on(pdev);
	if (ret < 0)
	{
		if (mdp_rev >= MDP_REV_41)
			mutex_unlock(&mfd->dma->ov_mutex);
		else
			up(&mfd->dma->mutex);

		return ret;
	} else {
		ret = 0;
	}
	#if defined(CONFIG_FB_MSM_MIPI_HITACHI_VIDEO_HD_PT) || defined(CONFIG_FB_MSM_MIPI_DSI_LGIT_FHD)
	mipi_dsi_op_mode_config(mipi->mode);
	#endif
#else
	ret = panel_next_on(pdev);

	mipi_dsi_op_mode_config(mipi->mode);
#endif

	if (mfd->panel_info.type == MIPI_CMD_PANEL) {
		if (pinfo->lcd.vsync_enable) {
			if (pinfo->lcd.hw_vsync_mode && vsync_gpio >= 0) {
				if (mdp_rev >= MDP_REV_41) {
					if (gpio_request(vsync_gpio,
						"MDP_VSYNC") == 0)
						gpio_direction_input(
							vsync_gpio);
					else
						pr_err("%s: unable to \
							request gpio=%d\n",
							__func__, vsync_gpio);
				} else if (mdp_rev == MDP_REV_303) {
					if (!tlmm_settings && gpio_request(
						vsync_gpio, "MDP_VSYNC") == 0) {
						ret = gpio_tlmm_config(
							GPIO_CFG(
							vsync_gpio, 1,
							GPIO_CFG_INPUT,
							GPIO_CFG_PULL_DOWN,
							GPIO_CFG_2MA),
							GPIO_CFG_ENABLE);

						if (ret) {
							pr_err(
							"%s: unable to config \
							tlmm = %d\n",
							__func__, vsync_gpio);
						}
						tlmm_settings = TRUE;

						gpio_direction_input(
							vsync_gpio);
					} else {
						if (!tlmm_settings) {
							pr_err(
							"%s: unable to request \
							gpio=%d\n",
							__func__, vsync_gpio);
						}
					}
				}
Example #6
0
static int mipi_dsi_panel_power(int on)
{
	static struct regulator *reg_l2;
	int rc;

	PR_DISP_INFO("%s: power %s.\n", __func__, on ? "on" : "off");

	if (!dsi_power_on) {
		
		gpio_tlmm_config(GPIO_CFG(MSM_LCD_ID0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, 0), GPIO_CFG_ENABLE);
		gpio_tlmm_config(GPIO_CFG(MSM_LCD_ID1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, 0), GPIO_CFG_ENABLE);

		
		reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
				"dsi_vdda");
		if (IS_ERR(reg_l2)) {
			pr_err("could not get 8038_l2, rc = %ld\n",
				PTR_ERR(reg_l2));
			return -ENODEV;
		}
		rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
		if (rc) {
			pr_err("set_voltage l2 failed, rc=%d\n", rc);
			return -EINVAL;
		}

		dsi_power_on = true;

		if (first_inited) {
			first_inited = false;

			rc = regulator_set_optimum_mode(reg_l2, 100000);
			if (rc < 0) {
				pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
				return -EINVAL;
			}
			rc = regulator_enable(reg_l2);
			if (rc) {
				pr_err("enable l2 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			return 0;
		}
	}

	if (on) {
		if (panel_type == PANEL_ID_K2_WL_AUO || panel_type == PANEL_ID_K2_WL_AUO_C2) {
			rc = regulator_set_optimum_mode(reg_l2, 100000);
			if (rc < 0) {
				pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
				return -EINVAL;
			}

			gpio_set_value(MSM_V_LCMIO_1V8_EN, 1);
			hr_msleep(1);
			gpio_set_value(MSM_V_LCM_3V3_EN, 1);

			rc = regulator_enable(reg_l2);
			if (rc) {
				pr_err("enable l2 failed, rc=%d\n", rc);
				return -ENODEV;
			}

			hr_msleep(55);
			gpio_set_value(MSM_LCD_RSTz, 1);
			usleep(20);
			gpio_set_value(MSM_LCD_RSTz, 0);
			usleep(30);
			gpio_set_value(MSM_LCD_RSTz, 1);
			hr_msleep(120);
		} else if (panel_type == PANEL_ID_K2_WL_JDI_NT) {
			rc = regulator_set_optimum_mode(reg_l2, 100000);
			if (rc < 0) {
				pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
				return -EINVAL;
			}

			gpio_set_value(MSM_V_LCMIO_1V8_EN, 1);
			hr_msleep(1);
			gpio_set_value(MSM_V_LCM_3V3_EN, 1);

			rc = regulator_enable(reg_l2);
			if (rc) {
				pr_err("enable l2 failed, rc=%d\n", rc);
				return -ENODEV;
			}

			hr_msleep(50);
			gpio_set_value(MSM_LCD_RSTz, 1);
			hr_msleep(10);
			gpio_set_value(MSM_LCD_RSTz, 0);
			hr_msleep(10);
			gpio_set_value(MSM_LCD_RSTz, 1);
			hr_msleep(120);
        }
	} else {
		if (panel_type == PANEL_ID_K2_WL_AUO || panel_type == PANEL_ID_K2_WL_AUO_C2) {
			rc = regulator_disable(reg_l2);
			if (rc) {
				pr_err("disable reg_l2 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			rc = regulator_set_optimum_mode(reg_l2, 100);
				if (rc < 0) {
					pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
				return -EINVAL;
			}

			gpio_set_value(MSM_LCD_RSTz, 0);
			hr_msleep(1);
			gpio_set_value(MSM_V_LCM_3V3_EN, 0);
			hr_msleep(5);
			gpio_set_value(MSM_V_LCMIO_1V8_EN, 0);
		} else if (panel_type == PANEL_ID_K2_WL_JDI_NT) {
			rc = regulator_disable(reg_l2);
			if (rc) {
				pr_err("disable reg_l2 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			rc = regulator_set_optimum_mode(reg_l2, 100);
				if (rc < 0) {
					pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
				return -EINVAL;
			}
			hr_msleep(10);
			gpio_set_value(MSM_LCD_RSTz, 0);
			hr_msleep(10);
			gpio_set_value(MSM_V_LCM_3V3_EN, 0);
			hr_msleep(10);
			gpio_set_value(MSM_V_LCMIO_1V8_EN, 0);
        }
	}
	return 0;
}
/* Configure gpio for uart - based on gsbi id */
void gpio_config_uart_dm(uint8_t id)
{
	if(board_platform_id() == MPQ8064)
	{
		switch (id) {

		case GSBI_ID_5:
			/* configure rx gpio */
			gpio_tlmm_config(52, 2, GPIO_INPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			/* configure tx gpio */
			gpio_tlmm_config(51, 2, GPIO_OUTPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			break;

		default:
			ASSERT(0);
		}
	}
	else if((board_platform_id() == APQ8064) ||
			(board_platform_id() == APQ8064AA) ||
			(board_platform_id() == APQ8064AB))
	{
		switch (id) {

		case GSBI_ID_1:
			/* configure rx gpio */
			gpio_tlmm_config(19, 1, GPIO_INPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			/* configure tx gpio */
			gpio_tlmm_config(18, 1, GPIO_OUTPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			break;

		case GSBI_ID_2:
			/* configure rx gpio */
			gpio_tlmm_config(22, 1, GPIO_INPUT, GPIO_NO_PULL,
						        GPIO_8MA, GPIO_DISABLE);
			/* configure tx gpio */
			gpio_tlmm_config(23, 1, GPIO_OUTPUT, GPIO_NO_PULL,
						        GPIO_8MA, GPIO_DISABLE);
			break;


		case GSBI_ID_7:
			/* configure rx gpio */
			gpio_tlmm_config(83, 1, GPIO_INPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			/* configure tx gpio */
			gpio_tlmm_config(82, 2, GPIO_OUTPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			break;

		default:
			ASSERT(0);
		}
	}
	else
	{
		switch (id) {

		case GSBI_ID_3:
			/* configure rx gpio */
			gpio_tlmm_config(15, 1, GPIO_INPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			/* configure tx gpio */
			gpio_tlmm_config(14, 1, GPIO_OUTPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			break;

		case GSBI_ID_5:
			/* configure rx gpio */
			gpio_tlmm_config(23, 1, GPIO_INPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			/* configure tx gpio */
			gpio_tlmm_config(22, 1, GPIO_OUTPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			break;

		case GSBI_ID_8:
			/* configure rx gpio */
			gpio_tlmm_config(35, 1, GPIO_INPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			/* configure tx gpio */
			gpio_tlmm_config(34, 1, GPIO_OUTPUT, GPIO_NO_PULL,
							 GPIO_8MA, GPIO_DISABLE);
			break;

		default:
			ASSERT(0);
		}
	}
}
static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
{
	int rc = 0;
	const char *id = "FMPW";
	uint32_t irqcfg;
	struct marimba config = { .mod_id =  SLAVE_ID_BAHAMA};
	u8 value;

	/* Voting for 1.8V Regulator */
	fm_regulator = vreg_get(NULL , "msme1");
	if (IS_ERR(fm_regulator)) {
		pr_err("%s: vreg get failed with : (%ld)\n",
			__func__, PTR_ERR(fm_regulator));
		return -EINVAL;
	}

	/* Set the voltage level to 1.8V */
	rc = vreg_set_level(fm_regulator, 1800);
	if (rc < 0) {
		pr_err("%s: set regulator level failed with :(%d)\n",
			__func__, rc);
		goto fm_vreg_fail;
	}

	/* Enabling the 1.8V regulator */
	rc = vreg_enable(fm_regulator);
	if (rc) {
		pr_err("%s: enable regulator failed with :(%d)\n",
			__func__, rc);
		goto fm_vreg_fail;
	}

	/* Voting for 19.2MHz clock */
	rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
			PMAPP_CLOCK_VOTE_ON);
	if (rc < 0) {
		pr_err("%s: clock vote failed with :(%d)\n",
			 __func__, rc);
		goto fm_clock_vote_fail;
	}

	rc = bt_set_gpio(1);
	if (rc) {
		pr_err("%s: bt_set_gpio = %d", __func__, rc);
		goto fm_gpio_config_fail;
	}
	/*re-write FM Slave Id, after reset*/
	value = BAHAMA_SLAVE_ID_FM_ADDR;
	rc = marimba_write_bit_mask(&config,
			BAHAMA_SLAVE_ID_FM_REG, &value, 1, 0xFF);
	if (rc < 0) {
		pr_err("%s: FM Slave ID rewrite Failed = %d", __func__, rc);
		goto fm_gpio_config_fail;
	}

	/* Configuring the FM GPIO */
	irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
			GPIO_CFG_2MA);

	rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
	if (rc) {
		pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
			 __func__, irqcfg, rc);
		goto fm_gpio_config_fail;
	}

	return 0;

fm_gpio_config_fail:
	pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1,
		PMAPP_CLOCK_VOTE_OFF);
	bt_set_gpio(0);
fm_clock_vote_fail:
	vreg_disable(fm_regulator);

fm_vreg_fail:
	vreg_put(fm_regulator);

	return rc;
};
static int mipi_dsi_power_tft_request(void)
{
	int rc = 0;
#if defined(CONFIG_MACH_JACTIVE_ATT) 
	if (system_rev < 10){
		gpio33 = PM8921_GPIO_PM_TO_SYS(LCD_22V_EN);
		rc = gpio_request(gpio33, "led_dirver");
		if (rc) {
			pr_err("request gpio lcd_22v_en failed, rc=%d\n", rc);
			return -ENODEV;
		}
		rc = pm8xxx_gpio_config(gpio33, &gpio43_param);
		if (rc) {
			pr_err("gpio_config lcd_22v_en failed (3), rc=%d\n", rc);
			return -EINVAL;
		}
	}
	else{
		pr_info("[lcd] request gpio lcd_22v_en\n");
		rc = gpio_request(LCD_22V_EN, "lcd_22v_en");

		if (rc) {
			gpio_free(LCD_22V_EN);
			rc = gpio_request(LCD_22V_EN, "lcd_22v_en");
			if(rc){
				pr_err("request gpio lcd_22v_en failed, rc=%d\n", rc);
				return -ENODEV;
			}
		}

		pr_info("[lcd] configure LCD_22V_EN\n");
		gpio_tlmm_config(GPIO_CFG(LCD_22V_EN,  0, GPIO_CFG_OUTPUT,
		GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

#if defined(CONFIG_FB_MSM_ENABLE_LCD_EN2)
		if( system_rev >= 13 ) // rev0.5 + 8
		{
			pr_info("[lcd] request gpio lcd_22v_en_2\n");
			rc = gpio_request(LCD_22V_EN_2, "lcd_22v_en_2");
			if (rc) {
				gpio_free(LCD_22V_EN_2);
				rc = gpio_request(LCD_22V_EN_2, "lcd_22v_en_2");
				if(rc){
					pr_err("request gpio lcd_22v_en_2 failed, rc=%d\n", rc);
					return -ENODEV;
				}
			}
			pr_info("[lcd] configure LCD_22V_EN_2\n");
			gpio_tlmm_config(GPIO_CFG(LCD_22V_EN_2,  0, GPIO_CFG_OUTPUT,
			GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
		}
#endif
	}
#else
	pr_info("[lcd] request gpio lcd_22v_en\n");
	rc = gpio_request(LCD_22V_EN, "lcd_22v_en");

	if (rc) {
		pr_err("request gpio lcd_22v_en failed, rc=%d\n", rc);
		return -ENODEV;
	}

	pr_info("[lcd] configure LCD_22V_EN\n");
	gpio_tlmm_config(GPIO_CFG(LCD_22V_EN,  0, GPIO_CFG_OUTPUT,
		GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

#if defined(CONFIG_FB_MSM_ENABLE_LCD_EN2)
	if( system_rev >= 16 ) // rev0.6 + 10
	{
		pr_info("[lcd] request gpio lcd_22v_en_2\n");
		rc = gpio_request(LCD_22V_EN_2, "lcd_22v_en_2");
		if (rc) {
			pr_err("request gpio lcd_22v_en_2 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		pr_info("[lcd] configure LCD_22V_EN_2\n");
		gpio_tlmm_config(GPIO_CFG(LCD_22V_EN_2,  0, GPIO_CFG_OUTPUT,
			GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	}
#endif
#endif

	if (system_rev == 0) {
		gpio43 = PM8921_GPIO_PM_TO_SYS(
						PMIC_GPIO_LCD_RST);

		rc = gpio_request(gpio43, "mlcd_rst");
		if (rc) {
			pr_err("request gpio mlcd_rst failed, rc=%d\n", rc);
			return -ENODEV;
		}

		rc = pm8xxx_gpio_config(gpio43, &gpio43_param);
		if (rc) {
			pr_err("gpio_config mlcd_rst failed (3), rc=%d\n", rc);
			return -EINVAL;
		}
	}
#if defined(CONFIG_MACH_JACTIVE_ATT)
	if (system_rev < 10)
		gpio27 = PM8921_GPIO_PM_TO_SYS(PMIC_GPIO_LED_DRIVER_REV00);
	else
		gpio27 = PM8921_GPIO_PM_TO_SYS(PMIC_GPIO_LED_DRIVER_REV10);
#else
	gpio27 = PM8921_GPIO_PM_TO_SYS(PMIC_GPIO_LED_DRIVER);
#endif
		

	rc = gpio_request(gpio27, "led_dirver");
	if (rc) {
		pr_err("request gpio led_dirver failed, rc=%d\n", rc);
		return -ENODEV;
	}

	rc = pm8xxx_gpio_config(gpio27, &gpio43_param);
	if (rc) {
		pr_err("gpio_config led_dirver failed (3), rc=%d\n", rc);
		return -EINVAL;
	}

	gpio_direction_output(gpio27, 0);

	return rc;
}
Example #10
0
// Pantech Earjack Probe Function
static int __devinit pantech_earjack_probe(struct platform_device *pdev)
{
	int rc = 0;
	int err = 0;
	struct input_dev *ipdev;

	dbg_func_in();

	irq_state = 0;

	// Alloc Devices
	earjack = kzalloc(sizeof(struct pantech_earjack), GFP_KERNEL);
	if (!earjack)
		return -ENOMEM;

	earjack->sdev.name	= "h2w";   
  
	earjack->sdev.print_name = msm_headset_print_name;
	rc = switch_dev_register(&earjack->sdev);
	if (rc)
		goto err_switch_dev_register;

	ipdev = input_allocate_device();
	if (!ipdev) {
		rc = -ENOMEM;
		goto err_alloc_input_dev;
	}
	input_set_drvdata(ipdev, earjack);


	// Init Status Flags
	earjack->ipdev = ipdev;
	earjack->car_kit = 0;
	earjack->type=EARJACK_STATE_OFF;
	earjack->remotekey_pressed = 0;
	earjack->remotekey_index = 0;

	// Initialize Work Queue
	INIT_DELAYED_WORK(&earjack_work,earjack_detect_func);          // INIT WORK
	INIT_DELAYED_WORK(&remotekey_work,remotekey_detect_func);

	// Get Power Source
#if defined(CONFIG_MIC_BIAS_1_8V)
	err = 0;
#else
	hs_jack_l8 = regulator_get(NULL, "8058_l8");
	regulator_set_voltage(hs_jack_l8,2700000,2700000);

	dbg("regulator_enable hs_jack_l8 value => %d\n",err);
#endif

	// Initialize Wakelocks
	wake_lock_init(&earjack_wake_lock, WAKE_LOCK_SUSPEND, "earjack_wake_lock_init");
	wake_lock_init(&remotekey_wake_lock, WAKE_LOCK_SUSPEND, "remotekey_wake_lock_init");

	// Setup GPIO's
	gpio_request(EARJACK_DET, "earjack_det");
	gpio_request(REMOTEKEY_DET, "remotekey_det");
	gpio_tlmm_config(GPIO_CFG(EARJACK_DET, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	rc = request_irq(gpio_to_irq(EARJACK_DET), Earjack_Det_handler, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "earjack_det-irq", earjack);

	// Warning: REMOTEKEY_DET using default gpio config.
	//gpio_tlmm_config(GPIO_CFG(REMOTEKEY_DET, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	
	irq_set_irq_wake(gpio_to_irq(EARJACK_DET), 1);
	irq_set_irq_wake(gpio_to_irq(REMOTEKEY_DET), 1);

	// Init Input Device
//pz1946 merge for wired long key
#ifdef CONFIG_MACH_MSM8X60_PRESTO
	ipdev->name	= DRIVER_NAME;
	ipdev->id.vendor    = 0;
	ipdev->id.product   = 0;
	ipdev->id.version   = 0;
#else	
	ipdev->id.vendor    = 0x0001;
	ipdev->id.product   = 1;
	ipdev->id.version   = 1;
#endif

	input_set_capability(ipdev, EV_KEY, KEY_MEDIA);
	input_set_capability(ipdev, EV_KEY, KEY_VOLUMEUP);
	input_set_capability(ipdev, EV_KEY, KEY_VOLUMEDOWN);
	input_set_capability(ipdev, EV_KEY, KEY_POWER);    
	input_set_capability(ipdev, EV_KEY, KEY_END);
	input_set_capability(ipdev, EV_SW,  SW_HEADPHONE_INSERT);
	input_set_capability(ipdev, EV_SW,  SW_MICROPHONE_INSERT);

	rc = input_register_device(ipdev);
	if (rc) {
		dev_err(&ipdev->dev,
				"hs_probe: input_register_device rc=%d\n", rc);
		goto err_reg_input_dev;
	}
	platform_set_drvdata(pdev, earjack);

	rc = sysfs_create_group(&pdev->dev.kobj, &dev_attr_grp);
	if (rc) {
		dev_err(&ipdev->dev,
				"hs_probe: sysfs_create_group rc=%d\n", rc);
		goto err_earjack_init;
	}

	// Scehdule earjack_detect_func for initial detect
	disable_irq_detect(); //disable_irq_nosync(gpio_to_irq(EARJACK_DET));
	
	wake_lock(&earjack_wake_lock);
	disable_irq_nosync(gpio_to_irq(REMOTEKEY_DET));

	schedule_delayed_work(&earjack_work,10);    // after 100ms
	
	dbg_func_out();
	return 0;

err_earjack_init:

err_reg_input_dev:
	input_unregister_device(ipdev);
	ipdev = NULL;
err_alloc_input_dev:
	input_free_device(ipdev);
err_switch_dev_register:
	kfree(earjack);
	return 0;
}
Example #11
0
////////////////////////////////
// Power ON
////////////////////////////////
static int cam12mp_sensor_poweron(void)
{
    struct vreg *vreg_gp1, *vreg_gp6;

    LOGI("+%s()\n", __func__);

    vreg_gp6 = vreg_get(NULL, "gp6");
    if (IS_ERR(vreg_gp6)) {
        LOGE(" - vreg_get(gp6) failed (%ld) !\n", PTR_ERR(vreg_gp6));
        return -1;
    }
    if (vreg_set_level(vreg_gp6, 1800)) {
        LOGE(" - vreg gp6 set level failed !\n");
        return -1;
    }
    vreg_gp1 = vreg_get(NULL, "gp1");
    if (IS_ERR(vreg_gp1)) {
        LOGE(" - vreg_get(gp1) failed (%ld)\n", PTR_ERR(vreg_gp1));
        return -1;
    }
    if (vreg_set_level(vreg_gp1, 2700)) {
        LOGE(" - vreg gp1 set level failed !\n");
        return -1;
    }

    sub_pmic_reg_ctrl(SUB_PMIC_REG2, SUB_PMIC_LDO_ON);
    mdelay(1);

    if (vreg_enable(vreg_gp6)) {
        LOGE(" - vreg gp6 enable failed !\n");
        goto _sensor_poweron_fail_1;
    }
    mdelay(1);

    sub_pmic_ldo_ctrl(SUB_PMIC_CAM12V, SUB_PMIC_LDO_ON);
    mdelay(1);

    gpio_set_value(CAM_18V, 1);
    mdelay(1);

    sub_pmic_ldo_ctrl(SUB_PMIC_CAM28V, SUB_PMIC_LDO_ON);
    mdelay(1);

    if (vreg_enable(vreg_gp1)) {
        LOGE(" - vreg gp1 enable failed !\n");
        goto _sensor_poweron_fail_2;
    }
    mdelay(1);

    gpio_tlmm_config(GPIO_CFG(MCLK, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_4MA), GPIO_ENABLE);
    msm_camio_clk_rate_set(9600000);
    msm_camio_camif_pad_reg_reset();

    gpio_set_value(H_STBY, 1);

    gpio_set_value(R_STBY, 1);
    mdelay(1);

    gpio_set_value(RESET, 1);
    mdelay(4);

    return 0;

_sensor_poweron_fail_2:
    sub_pmic_ldo_ctrl(SUB_PMIC_CAM28V, SUB_PMIC_LDO_OFF);
    gpio_set_value(CAM_18V, 0);
    sub_pmic_ldo_ctrl(SUB_PMIC_CAM12V, SUB_PMIC_LDO_OFF);
    vreg_disable(vreg_gp6);

_sensor_poweron_fail_1:
    sub_pmic_reg_ctrl(SUB_PMIC_REG2, SUB_PMIC_LDO_OFF);
    LOGI("-%s (fail.)\n", __func__);
    return -1;
}
void wacom_init_gpio(struct wacom_g5_platform_data *pdata)
{
	int ret;
	pr_err("epen: %s, %d \n",__func__, __LINE__ );
	pr_err("epen: %d, %d, %d, %d, %d \n",pdata->gpio_reset_n,pdata->gpio_fwe1, pdata->gpio_pendct,pdata->gpio_irq,pdata->gpio_ldo_en );

	// reset
	ret = gpio_request(pdata->gpio_reset_n, "gpio_reset_n");
	if(ret) {
		printk(KERN_INFO "epen: %s: unable to gpio [%d], r:%d\n", __func__, pdata->gpio_reset_n, ret);
		return;
	}
	gpio_direction_output(pdata->gpio_reset_n, 0);

	// slp, fwe1
	ret = gpio_request(pdata->gpio_fwe1, "gpio_fwe1");
	if(ret) {
		printk(KERN_INFO "epen: %s: unable to gpio [%d], r:%d\n", __func__, pdata->gpio_fwe1, ret);
		return;
	}
	gpio_direction_output(pdata->gpio_fwe1, 0);

	// pdct
	ret = gpio_request(pdata->gpio_pendct, "gpio_pendct");
	if(ret) {
		printk(KERN_INFO "epen: %s: unable to gpio [%d], r:%d\n", __func__, pdata->gpio_pendct, ret);
		return;
	}
	gpio_tlmm_config(GPIO_CFG(pdata->gpio_pendct, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);

	// irq
	ret = gpio_request(pdata->gpio_irq, "gpio_irq");
	if(ret) {
		printk(KERN_INFO "epen: %s: unable to gpio [%d], r:%d\n", __func__, pdata->gpio_irq, ret);
		return;
	}
	gpio_tlmm_config(GPIO_CFG(pdata->gpio_irq, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);

	// ldo en
	ret = gpio_request(pdata->gpio_ldo_en, "gpio_ldo_en");
	if(ret) {
		printk(KERN_INFO "epen: %s: unable to gpio [%d], r:%d\n", __func__, pdata->gpio_ldo_en, ret);
		return;
	}
	gpio_direction_output(pdata->gpio_ldo_en, 1);


	gpio_tlmm_config(GPIO_CFG(GPIO_PEN_SDA_18V, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);
	gpio_tlmm_config(GPIO_CFG(GPIO_PEN_SCL_N_18V, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);


	// pen_insert
	ret = gpio_request(pdata->gpio_pen_insert, "gpio_pen_insert");
	if(ret) {
		printk(KERN_INFO "epen: %s: unable to gpio [%d], r:%d\n", __func__, pdata->gpio_pen_insert, ret);
		return;
	}
	if(g_gpio_insert_pen_pull){
	gpio_tlmm_config(GPIO_CFG(pdata->gpio_pen_insert, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), 1);
	}else{
		gpio_tlmm_config(GPIO_CFG(pdata->gpio_pen_insert, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);
	}

}
void __init qrd7627a_add_io_devices(void)
{
        int rc;	
       	int i; //hanjue
	/* touchscreen */
	if (machine_is_msm7627a_qrd1()) {
		i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
					synaptic_i2c_clearpad3k,
					ARRAY_SIZE(synaptic_i2c_clearpad3k));
	} else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb() ||
			machine_is_msm8625_qrd5() || machine_is_msm7x27a_qrd5a()) {
	#if 1   //linxc 2012-12-21 +++
		if (machine_is_msm8625_qrd5()) {
			i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID, 
			himax_ts_i2c_info, 
			ARRAY_SIZE(himax_ts_i2c_info));
		}
	#else
		/* Use configuration data for sku5 */
		if (machine_is_msm8625_qrd5()) {
			mxt_config_array[0].config = mxt_config_data_qrd5;
			mxt_config_array[0].config_length =
					ARRAY_SIZE(mxt_config_data_qrd5);
			mxt_platform_data.panel_maxy = 875;
			mxt_platform_data.need_calibration = true;
			mxt_vkey_setup();
		}

		if (machine_is_msm7x27a_qrd5a()) {
			mxt_config_array[0].config = mxt_config_data_qrd5a;
			mxt_config_array[0].config_length =
					ARRAY_SIZE(mxt_config_data_qrd5a);
			mxt_platform_data.panel_maxy = 875;
			mxt_vkey_setup();
		}

		rc = gpio_tlmm_config(GPIO_CFG(MXT_TS_IRQ_GPIO, 0,
				GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
				GPIO_CFG_8MA), GPIO_CFG_ENABLE);
		if (rc) {
			pr_err("%s: gpio_tlmm_config for %d failed\n",
				__func__, MXT_TS_IRQ_GPIO);
		}

		rc = gpio_tlmm_config(GPIO_CFG(MXT_TS_RESET_GPIO, 0,
				GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
				GPIO_CFG_8MA), GPIO_CFG_ENABLE);
		if (rc) {
			pr_err("%s: gpio_tlmm_config for %d failed\n",
				__func__, MXT_TS_RESET_GPIO);
		}

		i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
					mxt_device_info,
					ARRAY_SIZE(mxt_device_info));
	#endif  //linxc 2012-12-21 ---	
	} else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7() || machine_is_msm8625q_skud() || machine_is_msm8625q_skue()) {
		ft5x06_touchpad_setup();
	}

	/* headset */
	platform_device_register(&hs_pdev);

	/* vibrator */
#ifdef CONFIG_MSM_RPC_VIBRATOR
	msm_init_pmic_vibrator();
#endif
//add by hanjue
    /* change the keymap for qrd sku5 */
	if(machine_is_msm8625_qrd5() || machine_is_msm7x27a_qrd5a()) {
		kp_matrix_info_8625.keymap = keymap_8625_qrd5;
		kp_matrix_info_8625.output_gpios = kp_row_gpios_8625_qrd5;
		kp_matrix_info_8625.noutputs = ARRAY_SIZE(kp_row_gpios_8625_qrd5);

		
		for (i = 0; i < kp_matrix_info_8625.noutputs; i++) {
			rc = gpio_tlmm_config(GPIO_CFG(kp_matrix_info_8625.output_gpios[i], 0,
				GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN,
				GPIO_CFG_2MA), GPIO_CFG_ENABLE);
			if (rc) {
				pr_err("%s: gpio_tlmm_config for %d failed\n",
					__func__, kp_matrix_info_8625.output_gpios[i]);
			}
		}
		for (i = 0; i < kp_matrix_info_8625.ninputs; i++) {
			rc = gpio_tlmm_config(GPIO_CFG(kp_matrix_info_8625.input_gpios[i], 0,
				GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
				GPIO_CFG_2MA), GPIO_CFG_ENABLE);
			if (rc) {
				pr_err("%s: gpio_tlmm_config for %d failed\n",
					__func__, kp_matrix_info_8625.input_gpios[i]);
			}
		}
		

	}
	/* keypad */
	if (machine_is_msm7627a_evb() ||
		 machine_is_msm8625_evb()||
		 machine_is_msm8625_qrd5() || machine_is_msm7x27a_qrd5a() ||
		 machine_is_msm8625_qrd7())
		platform_device_register(&kp_pdev_8625);
	else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
		platform_device_register(&kp_pdev_qrd3);
	else if (machine_is_msm8625q_skud())
		platform_device_register(&kp_pdev_skud);
    #if 0
	/* keypad */
	if (machine_is_msm8625_qrd5() || machine_is_msm7x27a_qrd5a())
		kp_matrix_info_8625.keymap = keymap_8625_qrd5;

	if (machine_is_msm7627a_evb() || machine_is_msm8625_evb() ||
			machine_is_msm8625_qrd5() || machine_is_msm7x27a_qrd5a())
		platform_device_register(&kp_pdev_8625);
	else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
		platform_device_register(&kp_pdev_qrd3);
	else if (machine_is_msm8625q_skud())
		platform_device_register(&kp_pdev_skud);
     #endif
/*start by lf 2012.12.26 */	 
#if 0
	/* leds */
	if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
            || machine_is_msm8625_qrd5() || machine_is_msm7x27a_qrd5a()) {

		platform_device_register(&pmic_mpp_leds_pdev);
		platform_device_register(&tricolor_leds_pdev);
	} else if (machine_is_msm8625q_skud()) {
		platform_device_register(&pmic_mpp_leds_pdev_skud);
		/* enable the skud flash and torch by gpio leds driver */
		platform_device_register(&gpio_flash_skud);
	}
#endif
/*end by lf 2012.12.26 */
#ifdef CONFIG_LEDS_TRICOLOR_FLAHSLIGHT
	    /*tricolor leds init*/
	if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()
            || machine_is_msm8625_qrd5() || machine_is_msm7x27a_qrd5a()) {
		platform_device_register(&msm_device_tricolor_leds);
		tricolor_leds_gpio_setup();
	}
#endif
}
// struct sn3193_i2c_platform_data rgb_pdata  = {
//		.sdb_gpio = APQ_SLED_SDB_GPIO,  
//};
static void SN3193_power(void)
{		
/*	if (on) {
		if (get_pcb_version() <= PCB_VERSION_EVT) { 
			//evt---lvs5
			lvs5 = regulator_get(NULL, "8921_lvs5");
			if (IS_ERR(lvs5)){
				pr_err("%s: VREG LVS5 get failed\n", __func__);
				lvs5 = NULL;
				goto lvs5_get_failed;
			}
			if (regulator_enable(lvs5)) {
				pr_err("%s: VREG LVS5 enable failed\n", __func__);
				goto lvs5_get_failed;
			}
		}
		else {
		//dvt---l21
			ldo121 = regulator_get(NULL, "8921_l21");
			if (IS_ERR(ldo121)){
				pr_err("%s: VREG ldo121 get failed\n", __func__);
				ldo121 = NULL;
				goto ldo121_get_failed;
			}
			if (regulator_set_voltage(ldo121, 1800000, 1800000)) {
				pr_err("%s: VREG ldo121 set voltage failed\n",	__func__);
				goto ldo121_get_failed;
			}
			if (regulator_enable(ldo121)) {
				pr_err("%s: VREG ldo121 enable failed\n", __func__);
				goto ldo121_get_failed;
			}
		}
	}else if (!on) {
		if (get_pcb_version() <= PCB_VERSION_EVT) {	//evt
			if (lvs5){
				regulator_disable(lvs5);
				regulator_put(lvs5);
			}
		}else { //dvt
			if (ldo121) {
				regulator_disable(ldo121);
				regulator_put(ldo121);
			}
		}
	}
	return 0 ;
	
ldo121_get_failed:
	regulator_disable(ldo121);
lvs5_get_failed:
	regulator_put(lvs5);
	
	return -1 ;
	*/

    int ret = 0  ;
 
    //irq
    //Delete by Jianfeng.Qiu, 2014-09-12, not use
#if 0
    ret = gpio_tlmm_config(SN3193_SDB, GPIO_CFG_ENABLE);
    if (ret) {
        printk(KERN_ERR "%s:yuyi,gpio_tlmm_config(%#x)=%d\n",
            __func__, SN3193_SDB, ret);
    }
#endif
    gpio_set_value(SN3193_sled_dev_sate->ena_gpio, 1);
    ret = gpio_get_value(SN3193_sled_dev_sate->ena_gpio);
    printk("the gpio_get_value is  %d\n", ret);

    printk("yuyi,sn3193  power end\n");
    printk(KERN_ERR "%s:yuyi for SN3193_SDB gpio---\n", __func__);
}
int seport_platform_register_button_gpio_callback(int (*func)(int, void *arg),
						  void *data)
{
	int retval, mean_rid, mean_ain, irq;

	/* TODO: Make sure that we handle errors in a later state! */
	gpio_set_value(seport_conf->rid_ping_enable_pin, 0);
	msleep(10);
	retval = gpio_tlmm_config(GPIO_CFG(seport_conf->button_detect_pin,
					   0, GPIO_INPUT, GPIO_NO_PULL,
					   GPIO_2MA),
				  GPIO_ENABLE);
	if (retval) {
		printk(KERN_CRIT "Failed to configure GPIO pin. Aborting\n");
		gpio_set_value(seport_conf->rid_ping_enable_pin, 0);
		return retval;
	}
	/* Delay a bit to make sure GPIOs are in the correct mode. */
	msleep(10);

	mean_rid = seport_platform_read_mean_rid_val(3);

	/* Enabling DCout to see if we have different AIN value than RID.
	 * This is used to filter out inserted accessories with pressed
	 * buttons. */
	(void)seport_set_dcout(1);
	msleep(10);

	mean_ain = seport_platform_read_mean_rid_val(3);

	/*
	 * Here we try to detect if we have a valid AIN accessory. This will
	 * not handle if RID == AIN which can be the case in very special
	 * circumstances even though the accessory is a valid AIN event. This
	 * can happen if a button is pressed when the accessory is inserted and
	 * we have no way to filter that specific case.
	 * The +-4 steps should be a good range to handle different RID values.
	 */
	if (abs(mean_ain - mean_rid) > 4) {
		irq = gpio_to_irq(seport_conf->button_detect_pin);
		if (0 <= irq) {
			retval = request_irq(irq,
					     func, IRQF_TRIGGER_FALLING,
					     "seport_buttondetect",
					     data);

			if (retval) {
				printk(KERN_CRIT "Failed to register" \
				       " interrupt handler for button" \
				       " detection\n");
				return retval;
			}
		} else {
			printk(KERN_CRIT "%s - Irq for requested GPIO (%d) " \
			       "does not exist. Button detection will not " \
			       "work\n", __func__,
			       seport_conf->button_detect_pin);
			return -ENXIO;
		}

		/*
		 * Setting interrupt enabled here, will in worst case generate
		 * a "unmatched irq_wake" print in the kernel log when
		 * shutting down the system, but at least some detection will
		 * work.
		 */
		seport_button_detect_interrupt_enabled = 1;

		retval = enable_irq_wake(irq);
		if (retval)
			printk(KERN_CRIT "Failed to enable wakup on IRQ " \
			       "request\n");

		return retval;
	} else {
		printk(KERN_INFO "Accessory was not detected as an AIN " \
		       "accessory or a special button was pressed while " \
		       "inserting accessory\n");

		/* Ignoring return values here. Can't do much about
		   them if they fail. */
		gpio_set_value(seport_conf->rid_ping_enable_pin, 1);

		(void)gpio_tlmm_config(GPIO_CFG(seport_conf->button_detect_pin,
						0, GPIO_OUTPUT, GPIO_PULL_DOWN,
						GPIO_2MA),
				       GPIO_ENABLE);
	}
	return -3; /* ERROR_NO_AIN_ACCESSORY; */
}
void __init verdi_lte_audio_init(void)
{
	mutex_init(&bt_sco_lock);
	mutex_init(&mic_lock);

#ifdef CONFIG_MSM8X60_AUDIO_LTE
	pr_aud_info("%s\n", __func__);
	htc_8x60_register_analog_ops(&ops);
	htc_8x60_register_icodec_ops(&iops);
	htc_8x60_register_ecodec_ops(&eops);
	acoustic_register_ops(&acoustic);
	htc_8x60_register_aic3254_ops(&aops);
#endif

	aic3254_register_ctl_ops(&cops);

	/* PMIC GPIO Init (See board-verdi-lte.c) */

	mutex_init(&audio_2v85_usage_lock);
	audio_2v85_usage_counter = 0;
	verdi_lte_audio_2v85_set_voltage(1);

	/* Reset AIC3254 */
	gpio_tlmm_config(msm_aic3254_reset_gpio[0], GPIO_CFG_ENABLE);

	/* this PIN is only defined in XA board */
	if (system_rev == 0) {
		gpio_set_value(VERDI_LTE_AUD_LDO_SEL, 0);

		mdelay(1);
		config_gpio_table(msm_snddev_gpio_on, \
			ARRAY_SIZE(msm_snddev_gpio_on));
		gpio_set_value(VERDI_LTE_AUD_RX_MCLK1, 0);
		gpio_set_value(VERDI_LTE_AUD_QTR_TX_MCLK1, 0);
		gpio_set_value(VERDI_LTE_AUD_QTR_TX_I2S_SD2, 0);
	} else {
		config_gpio_table(msm_snddev_gpio_off, \
			ARRAY_SIZE(msm_snddev_gpio_off));
		gpio_set_value(VERDI_LTE_AUD_RX_MCLK1, 0);
		gpio_set_value(VERDI_LTE_AUD_QTR_TX_MCLK1, 0);
		gpio_set_value(VERDI_LTE_AUD_QTR_TX_I2S_SD2, 0);
	}

	config_gpio_table(verdi_lte_a1028_gpio, \
		ARRAY_SIZE(verdi_lte_a1028_gpio));
	gpio_set_value(VERDI_LTE_AUD_A1028_RESET, 0);
	gpio_set_value(VERDI_LTE_AUD_A1028_WAKEUP, 0);
	gpio_set_value(VERDI_LTE_AUD_A1028_INT, 0);

	config_gpio_table(verdi_lte_i2s_rx2_gpio, \
		ARRAY_SIZE(verdi_lte_i2s_rx2_gpio));
	gpio_set_value(VERDI_LTE_AUD_RX_CLK2, 0);
	gpio_set_value(VERDI_LTE_AUD_RX_WS2, 0);
	gpio_set_value(VERDI_LTE_AUD_RX_SD2, 0);
	gpio_set_value(VERDI_LTE_AUD_RX_MCLK2, 0);

	gpio_tlmm_config(msm_qtr_reset_gpio[0], GPIO_CFG_ENABLE);
	gpio_set_value(VERDI_LTE_AUD_QTR_RESET, 1);

	/* BT AUX PCM PIN init */
	config_gpio_table(aux_pcm_gpio_off, ARRAY_SIZE(aux_pcm_gpio_off));
	gpio_set_value(VERDI_LTE_GPIO_BT_PCM_OUT, 0);
	gpio_set_value(VERDI_LTE_GPIO_BT_PCM_SYNC, 0);
	gpio_set_value(VERDI_LTE_GPIO_BT_PCM_CLK, 0);

	audio_first_boot_counter = 0;
}
int es705_gpio_init(struct es705_priv *es705)
{
	int rc = 0;
#ifdef CONFIG_SND_SOC_ES704_TEMP
	static int gpio_initialized = 0;
	if (gpio_initialized)
		return rc;
#endif
	if (es705->pdata->reset_gpio != -1) {
		rc = gpio_request(es705->pdata->reset_gpio, "es705_reset");
		if (rc < 0) {
			dev_err(es705->dev, "%s(): es705_reset request failed",
				__func__);
			goto reset_gpio_request_error;
		}
		rc = gpio_direction_output(es705->pdata->reset_gpio, 0);
		if (rc < 0) {
			dev_err(es705->dev, "%s(): es705_reset direction failed",
				__func__);
			goto reset_gpio_direction_error;
		}
	} else {
		dev_warn(es705->dev, "%s(): es705_reset undefined\n",
				__func__);
	}

	if (es705->pdata->wakeup_gpio != -1) {
		rc = gpio_request(es705->pdata->wakeup_gpio, "es705_wakeup");
		if (rc < 0) {
			dev_err(es705->dev, "%s(): es705_wakeup request failed",
				__func__);
			goto wakeup_gpio_request_error;
		}
		rc = gpio_direction_output(es705->pdata->wakeup_gpio, 0);
		if (rc < 0) {
			dev_err(es705->dev, "%s(): es705_wakeup direction failed",
				__func__);
			goto wakeup_gpio_direction_error;
		}
	} else {
		dev_warn(es705->dev, "%s(): wakeup_gpio undefined\n",
				__func__);
	}
	/* under H/W rev 0.5 */
	if (es705->pdata->uart_gpio != -1) {
		rc = gpio_request(es705->pdata->uart_gpio, "es705_uart");
		if (rc < 0) {
			dev_err(es705->dev, "%s(): es705_uart request failed",
				__func__);
			goto uart_gpio_request_error;
		}
		rc = gpio_direction_output(es705->pdata->uart_gpio, 0);
		if (rc < 0) {
			dev_err(es705->dev, "%s(): es705_uart direction failed",
				__func__);
			goto uart_gpio_direction_error;
		}
	} else {
		dev_warn(es705->dev, "%s(): es705_uart undefined\n",
				__func__);
	}

	if (es705->pdata->gpiob_gpio) {
		rc = request_threaded_irq(es705->pdata->irq_base,
					  NULL,
					  es705_irq_event, IRQF_TRIGGER_RISING,
					  "es705-irq-event", es705);
		if (rc) {
			dev_err(es705->dev, "%s(): event request_irq() failed\n",
				__func__);
			goto event_irq_request_error;
		}
		rc = irq_set_irq_wake(es705->pdata->irq_base, 1);
		if (rc < 0) {
			dev_err(es705->dev, "%s(): set event irq wake failed\n",
				__func__);
			disable_irq(es705->pdata->irq_base);
			free_irq(es705->pdata->irq_base, es705);
			goto event_irq_wake_error;
		}
	}

#if defined(CONFIG_MACH_K3GDUOS_CTC)
	gpio_tlmm_config(GPIO_CFG(es705->pdata->uart_tx_gpio, 2, GPIO_CFG_OUTPUT,GPIO_CFG_NO_PULL, GPIO_CFG_8MA), 1);
	gpio_tlmm_config(GPIO_CFG(es705->pdata->uart_rx_gpio, 2, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_8MA), 1);
#endif /* CONFIG_MACH_K3GDUOS_CTC */

#ifdef CONFIG_SND_SOC_ES704_TEMP
	gpio_initialized = 1;
#endif
	return rc;
uart_gpio_direction_error:
	gpio_free(es705->pdata->uart_gpio);
uart_gpio_request_error:
wakeup_gpio_direction_error:
	gpio_free(es705->pdata->wakeup_gpio);
wakeup_gpio_request_error:
reset_gpio_direction_error:
	gpio_free(es705->pdata->reset_gpio);
reset_gpio_request_error:
event_irq_wake_error:
event_irq_request_error:
	return rc;
}
Example #18
0
static int mipi_dsi_on(struct platform_device *pdev)
{
	int ret = 0;
	u32 clk_rate;
	struct msm_fb_data_type *mfd;
	struct fb_info *fbi;
	struct fb_var_screeninfo *var;
	struct msm_panel_info *pinfo;
	struct mipi_panel_info *mipi;
	u32 hbp, hfp, vbp, vfp, hspw, vspw, width, height;
	u32 ystride, bpp, data;
	u32 dummy_xres, dummy_yres;
	int target_type = 0;

	mfd = platform_get_drvdata(pdev);
	fbi = mfd->fbi;
	var = &fbi->var;
	pinfo = &mfd->panel_info;
	if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_power_save)
		mipi_dsi_pdata->dsi_power_save(1);
#if defined(CONFIG_FB_MSM_MIPI_PANEL_POWERON_LP11)
	/*
	 * Fix for floating state of VDD line in toshiba chip
	 * */
	if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_client_power_save)
		mipi_dsi_pdata->dsi_client_power_save(1);
#endif /* CONFIG_FB_MSM_MIPI_PANEL_POWERON_LP11 */

	cont_splash_clk_ctrl();
	local_bh_disable();
	mipi_dsi_ahb_ctrl(1);
	local_bh_enable();

	clk_rate = mfd->fbi->var.pixclock;
	clk_rate = min(clk_rate, mfd->panel_info.clk_max);

	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 1);
	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 0);

	hbp = var->left_margin;
	hfp = var->right_margin;
	vbp = var->upper_margin;
	vfp = var->lower_margin;
	hspw = var->hsync_len;
	vspw = var->vsync_len;
	width = mfd->panel_info.xres;
	height = mfd->panel_info.yres;

	mipi_dsi_phy_ctrl(1);

	if (mdp_rev == MDP_REV_42 && mipi_dsi_pdata)
		target_type = mipi_dsi_pdata->target_type;

	mipi_dsi_phy_init(0, &(mfd->panel_info), target_type);

	local_bh_disable();
	mipi_dsi_clk_enable();
	local_bh_enable();

	mipi  = &mfd->panel_info.mipi;
	if (mfd->panel_info.type == MIPI_VIDEO_PANEL) {
		dummy_xres = mfd->panel_info.mipi.xres_pad;
		dummy_yres = mfd->panel_info.mipi.yres_pad;

		if (mdp_rev >= MDP_REV_41) {
			MIPI_OUTP(MIPI_DSI_BASE + 0x20,
				((hspw + hbp + width + dummy_xres) << 16 |
				(hspw + hbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x24,
				((vspw + vbp + height + dummy_yres) << 16 |
				(vspw + vbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x28,
				(vspw + vbp + height + dummy_yres +
					vfp - 1) << 16 | (hspw + hbp +
					width + dummy_xres + hfp - 1));
		} else {
			/* DSI_LAN_SWAP_CTRL */
			MIPI_OUTP(MIPI_DSI_BASE + 0x00ac, mipi->dlane_swap);

			MIPI_OUTP(MIPI_DSI_BASE + 0x20,
				((hbp + width + dummy_xres) << 16 | (hbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x24,
				((vbp + height + dummy_yres) << 16 | (vbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x28,
				(vbp + height + dummy_yres + vfp) << 16 |
					(hbp + width + dummy_xres + hfp));
		}

		MIPI_OUTP(MIPI_DSI_BASE + 0x2c, (hspw << 16));
		MIPI_OUTP(MIPI_DSI_BASE + 0x30, 0);
		MIPI_OUTP(MIPI_DSI_BASE + 0x34, (vspw << 16));

	} else {		/* command mode */
		if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB888)
			bpp = 3;
		else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB666)
			bpp = 3;
		else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB565)
			bpp = 2;
		else
			bpp = 3;	/* Default format set to RGB888 */

		ystride = width * bpp + 1;

		/* DSI_COMMAND_MODE_MDP_STREAM_CTRL */
		data = (ystride << 16) | (mipi->vc << 8) | DTYPE_DCS_LWRITE;
		MIPI_OUTP(MIPI_DSI_BASE + 0x5c, data);
		MIPI_OUTP(MIPI_DSI_BASE + 0x54, data);

		/* DSI_COMMAND_MODE_MDP_STREAM_TOTAL */
		data = height << 16 | width;
		MIPI_OUTP(MIPI_DSI_BASE + 0x60, data);
		MIPI_OUTP(MIPI_DSI_BASE + 0x58, data);
	}

	mipi_dsi_host_init(mipi);
#if defined(CONFIG_FB_MSM_MIPI_PANEL_POWERON_LP11)
	/*
	 * For TC358764 D2L IC, one of the requirement for power on
	 * is to maintain an LP11 state in data and clock lanes during
	 * power enabling and reset assertion. This change is to
	 * achieve that.
	 * */
	if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_client_power_save) {
		u32 tmp_reg0c, tmp_rega8;
		mipi_dsi_pdata->dsi_client_reset();
		udelay(200);
		/* backup register values */
		tmp_reg0c = MIPI_INP(MIPI_DSI_BASE + 0x000c);
		tmp_rega8 = MIPI_INP(MIPI_DSI_BASE + 0xA8);
		/* Clear HS  mode assertion and related flags */
		MIPI_OUTP(MIPI_DSI_BASE + 0x0c, 0x8000);
		MIPI_OUTP(MIPI_DSI_BASE + 0xA8, 0x0);
		wmb();
		mdelay(5);
		/* restore previous values */
		MIPI_OUTP(MIPI_DSI_BASE + 0x0c, tmp_reg0c);
		MIPI_OUTP(MIPI_DSI_BASE + 0xa8, tmp_rega8);
		wmb();
	}
#endif /* CONFIG_FB_MSM_MIPI_PANEL_POWERON_LP11 */


	if (mipi->force_clk_lane_hs) {
		u32 tmp;

		tmp = MIPI_INP(MIPI_DSI_BASE + 0xA8);
		tmp |= (1<<28);
		MIPI_OUTP(MIPI_DSI_BASE + 0xA8, tmp);
		wmb();
	}

	if (mdp_rev >= MDP_REV_41)
		mutex_lock(&mfd->dma->ov_mutex);
	else
		down(&mfd->dma->mutex);

	ret = panel_next_on(pdev);

	mipi_dsi_op_mode_config(mipi->mode);

	if (mfd->panel_info.type == MIPI_CMD_PANEL) {
		if (pinfo->lcd.vsync_enable) {
			if (pinfo->lcd.hw_vsync_mode && vsync_gpio >= 0) {
				if (mdp_rev >= MDP_REV_41) {
					if (gpio_request(vsync_gpio,
						"MDP_VSYNC") == 0)
						gpio_direction_input(
							vsync_gpio);
					else
						pr_err("%s: unable to request gpio=%d\n",
							__func__, vsync_gpio);
				} else if (mdp_rev == MDP_REV_303) {
					if (!tlmm_settings && gpio_request(
						vsync_gpio, "MDP_VSYNC") == 0) {
						ret = gpio_tlmm_config(
							GPIO_CFG(
							vsync_gpio, 1,
							GPIO_CFG_INPUT,
							GPIO_CFG_PULL_DOWN,
							GPIO_CFG_2MA),
							GPIO_CFG_ENABLE);

						if (ret) {
							pr_err("%s: unable to config tlmm = %d\n",
							__func__, vsync_gpio);
						}
						tlmm_settings = TRUE;

						gpio_direction_input(
							vsync_gpio);
					} else {
						if (!tlmm_settings) {
							pr_err("%s: unable to request gpio=%d\n",
							__func__, vsync_gpio);
						}
					}
				}
			}
			mipi_dsi_set_tear_on(mfd);
		}
	}

#ifdef CONFIG_MSM_BUS_SCALING
	mdp_bus_scale_update_request(2);
#endif

	mdp4_overlay_dsi_state_set(ST_DSI_RESUME);

	if (mdp_rev >= MDP_REV_41)
		mutex_unlock(&mfd->dma->ov_mutex);
	else
		up(&mfd->dma->mutex);

	pr_debug("%s-:\n", __func__);

	return ret;
}
Example #19
0
void mdp_config_vsync(struct msm_fb_data_type *mfd)
{

	/* vsync on primary lcd only for now */
	if ((mfd->dest != DISPLAY_LCD) || (mfd->panel_info.pdest != DISPLAY_1)
	    || (!vsync_mode)) {
		goto err_handle;
	}

	if (mfd->panel_info.lcd.vsync_enable) {
		mfd->total_porch_lines = mfd->panel_info.lcd.v_back_porch +
		    mfd->panel_info.lcd.v_front_porch +
		    mfd->panel_info.lcd.v_pulse_width;
		mfd->total_lcd_lines =
		    mfd->panel_info.yres + mfd->total_porch_lines;
		mfd->lcd_ref_usec_time =
		    100000000 / mfd->panel_info.lcd.refx100;
		mfd->vsync_handler_pending = FALSE;
		mfd->last_vsync_timetick.tv.sec = 0;
		mfd->last_vsync_timetick.tv.nsec = 0;

#ifdef MDP_HW_VSYNC
		if (mdp_vsync_clk == NULL)
			mdp_vsync_clk = clk_get(NULL, "mdp_vsync_clk");

		if (IS_ERR(mdp_vsync_clk)) {
			printk(KERN_ERR "error: can't get mdp_vsync_clk!\n");
			mfd->use_mdp_vsync = 0;
		} else
			mfd->use_mdp_vsync = 1;

		if (mfd->use_mdp_vsync) {
			uint32 vsync_cnt_cfg, vsync_cnt_cfg_dem;
			uint32 mdp_vsync_clk_speed_hz;

			mdp_vsync_clk_speed_hz = clk_get_rate(mdp_vsync_clk);

			if (mdp_vsync_clk_speed_hz == 0) {
				mfd->use_mdp_vsync = 0;
			} else {
				/*
				 * Do this calculation in 2 steps for
				 * rounding uint32 properly.
				 */
				vsync_cnt_cfg_dem =
				    (mfd->panel_info.lcd.refx100 *
				     mfd->total_lcd_lines) / 100;
				vsync_cnt_cfg =
				    (mdp_vsync_clk_speed_hz) /
				    vsync_cnt_cfg_dem;

				/* MDP cmd block enable */
				mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON,
					      FALSE);
				mdp_hw_vsync_clk_enable(mfd);

				mdp_set_sync_cfg_0(mfd, vsync_cnt_cfg);

				/*
				 * load the last line + 1 to be in the
				 * safety zone
				 */
				vsync_load_cnt = mfd->panel_info.yres;

				/* line counter init value at the next pulse */
				MDP_OUTP(MDP_BASE + MDP_PRIM_VSYNC_INIT_VAL,
							vsync_load_cnt);

				/*
				 * external vsync source pulse width and
				 * polarity flip
				 */
				MDP_OUTP(MDP_BASE + MDP_PRIM_VSYNC_OUT_CTRL,
							BIT(30) | BIT(0));


				/* threshold */
				MDP_OUTP(MDP_BASE + 0x200,
					 (vsync_above_th << 16) |
					 (vsync_start_th));

				mdp_hw_vsync_clk_disable(mfd);
				/* MDP cmd block disable */
				mdp_pipe_ctrl(MDP_CMD_BLOCK,
					      MDP_BLOCK_POWER_OFF, FALSE);
			}
		}
#else
		mfd->use_mdp_vsync = 0;
		hrtimer_init(&mfd->dma_hrtimer, CLOCK_MONOTONIC,
			     HRTIMER_MODE_REL);
		mfd->dma_hrtimer.function = mdp_dma2_vsync_hrtimer_handler;
		mfd->vsync_width_boundary = vmalloc(mfd->panel_info.xres * 4);
#endif

		mfd->channel_irq = 0;
		if (mfd->panel_info.lcd.hw_vsync_mode) {
			u32 vsync_gpio = mfd->vsync_gpio;
			u32 ret;

			if (vsync_gpio == -1) {
				MSM_FB_INFO("vsync_gpio not defined!\n");
				goto err_handle;
			}

			ret = gpio_tlmm_config(GPIO_CFG
					(vsync_gpio,
					(mfd->use_mdp_vsync) ? 1 : 0,
					GPIO_CFG_INPUT,
					GPIO_CFG_PULL_DOWN,
					GPIO_CFG_2MA),
					GPIO_CFG_ENABLE);
			if (ret)
				goto err_handle;

			if (!mfd->use_mdp_vsync) {
				mfd->channel_irq = MSM_GPIO_TO_INT(vsync_gpio);
				if (request_irq
				    (mfd->channel_irq,
				     &mdp_hw_vsync_handler_proxy,
				     IRQF_TRIGGER_FALLING, "VSYNC_GPIO",
				     (void *)mfd)) {
					MSM_FB_INFO
					("irq=%d failed! vsync_gpio=%d\n",
						mfd->channel_irq,
						vsync_gpio);
					goto err_handle;
				}
			}
		}

		mdp_set_vsync((unsigned long)mfd);
	}

	return;

err_handle:
	if (mfd->vsync_width_boundary)
		vfree(mfd->vsync_width_boundary);
	mfd->panel_info.lcd.vsync_enable = FALSE;
	printk(KERN_ERR "%s: failed!\n", __func__);
}
Example #20
0
void gpio_set_diag_gpio_table(unsigned long *dwMFG_gpio_table)
{
	int i = 0;
	unsigned cfg;
	PSUSPEND_PIN_CONFIG pSuspendPinConfig = 0;

	pSuspendPinConfig = (PSUSPEND_PIN_CONFIG)(dwMFG_gpio_table);
#if defined(CONFIG_ARCH_MSM7X00A)
	for (i = 0; i <= 121; i++)
#elif defined(CONFIG_ARCH_MSM7225)
	for (i = 0; i < 132; i++)
#elif defined(CONFIG_ARCH_MSM7227)
	for (i = 0; i < 132; i++)
#elif defined(CONFIG_ARCH_QSD8X50)
	for (i = 0; i <= 164; i++)
#elif defined(CONFIG_ARCH_MSM7X30)
	for (i = 0; i <= 181; i++)
#elif defined(CONFIG_ARCH_MSM8X60)
	for (i = 0; i < 173; i++)
#elif defined(CONFIG_ARCH_MSM8960)
	for (i = 0; i < 151; i++)
#endif
	{
		unsigned char tempGpio = pSuspendPinConfig->arGpio[i];

		if (tempGpio & 0x1) {
			/* configure by the settings from DIAG */
			unsigned long dwGpioKind, dwGpioConfig, dwOutputLevel;
			if (tempGpio & 0x2) { /* GPIO INPUT PIN */
				dwGpioKind = GPIO_INPUT;
				dwOutputLevel = 0;
			} else { /* GPIO_OUTPUT_PIN */
				dwGpioKind = GPIO_OUTPUT;
				if (tempGpio & 0x4)
					dwOutputLevel = 1;
				else
					dwOutputLevel = 0;
			}

			/* config GpioPullStatus */
			if ((tempGpio & 0x10) && (tempGpio & 0x08))
				dwGpioConfig = GPIO_PULL_UP;
			else if (tempGpio & 0x08)
				dwGpioConfig = GPIO_PULL_DOWN;
			else if (tempGpio & 0x10)
				dwGpioConfig = GPIO_KEEPER;
			else
				dwGpioConfig = GPIO_NO_PULL;

#if defined(CONFIG_ARCH_MSM8X60) || defined(CONFIG_ARCH_MSM8960)
			cfg = GPIO_CFG(i, 0, dwGpioKind, dwGpioConfig, GPIO_2MA);
			gpio_tlmm_config(cfg, GPIO_CFG_ENABLE);
#else
			cfg = PCOM_GPIO_CFG(i, 0, dwGpioKind, dwGpioConfig, GPIO_2MA);

			msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &cfg, 0);
#endif
			if (dwGpioKind == GPIO_OUTPUT)
				gpio_direction_output(i, dwOutputLevel);
		} else {
			/* DIAG does not want to config this GPIO */
			continue;
		}
	}
}
static void kingdom_setup_input_gpio(void)
{
	gpio_tlmm_config(inputs_gpio_table[0], GPIO_CFG_ENABLE);
}
Example #22
0
static int max77804k_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max77804k_dev *max77804k;
	struct max77804k_platform_data *pdata;
	u8 reg_data;
	int ret = 0;
	dev_info(&i2c->dev, "%s\n", __func__);

	max77804k = kzalloc(sizeof(struct max77804k_dev), GFP_KERNEL);
	if (max77804k == NULL)
		return -ENOMEM;

	if (i2c->dev.of_node) {
		pdata = devm_kzalloc(&i2c->dev,
				sizeof(struct max77804k_platform_data),
				GFP_KERNEL);
		if (!pdata) {
			dev_err(&i2c->dev, "Failed to allocate memory \n");
			ret = -ENOMEM;
			goto err;
		}

		ret = of_max77804k_dt(&i2c->dev, pdata);
		if (ret < 0){
			dev_err(&i2c->dev, "Failed to get device of_node \n");
			ret = -ENOMEM;
			goto err;
		}
		/*Filling the platform data*/
		pdata->muic_data = &max77804k_muic;
#ifdef CONFIG_REGULATOR_MAX77804K
		pdata->num_regulators = MAX77804K_REG_MAX;
		pdata->regulators = max77804k_regulators;
#endif
#ifdef CONFIG_LEDS_MAX77804K
		pdata->led_data = &max77804k_led_pdata;
#endif
		/*pdata update to other modules*/
		i2c->dev.platform_data = pdata;
	} else
		pdata = i2c->dev.platform_data;

	i2c_set_clientdata(i2c, max77804k);
	max77804k->dev = &i2c->dev;

	max77804k->i2c = i2c;
	max77804k->irq = i2c->irq;
	if (pdata) {
		max77804k->irq_base = pdata->irq_base;
		max77804k->irq_gpio = pdata->irq_gpio;
		max77804k->wakeup = pdata->wakeup;
		gpio_tlmm_config(GPIO_CFG(max77804k->irq_gpio,  0, GPIO_CFG_INPUT,
                GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_DISABLE);
	} else {
		ret = -EINVAL;
		goto err;
	}

	mutex_init(&max77804k->iolock);

	if (max77804k_read_reg(i2c, MAX77804K_PMIC_REG_PMIC_ID2, &reg_data) < 0) {
		dev_err(max77804k->dev,
			"device not found on this channel (this is not an error)\n");
		ret = -ENODEV;
		goto err;
	} else {
		/* print rev */
		max77804k->pmic_rev = (reg_data & 0x7);
		max77804k->pmic_ver = ((reg_data & 0xF8) >> 0x3);
		pr_info("%s: device found: rev.0x%x, ver.0x%x\n", __func__,
				max77804k->pmic_rev, max77804k->pmic_ver);
	}
	max77804k_update_reg(i2c, MAX77804K_CHG_REG_SAFEOUT_CTRL, 0x00, 0x30);

	max77804k->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
	i2c_set_clientdata(max77804k->muic, max77804k);

	max77804k->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
	i2c_set_clientdata(max77804k->haptic, max77804k);

	ret = max77804k_irq_init(max77804k);
	if (ret < 0)
		goto err_irq_init;

	ret = mfd_add_devices(max77804k->dev, -1, max77804k_devs,
			ARRAY_SIZE(max77804k_devs), NULL, 0);
	if (ret < 0)
		goto err_mfd;

	device_init_wakeup(max77804k->dev, pdata->wakeup);

	/* Set continuous mode */
	max77804k_update_reg(max77804k->muic, MAX77804K_MUIC_REG_CTRL4,
			ADC_ALWAYS, CTRL4_ADCMODE_MASK);

	return ret;

err_mfd:
	mfd_remove_devices(max77804k->dev);
	max77804k_irq_exit(max77804k);
err_irq_init:
	i2c_unregister_device(max77804k->muic);
	i2c_unregister_device(max77804k->haptic);
err:
	kfree(max77804k);
	return ret;
}
/* get module value */
int get_tp_id(void)
{
    int id0 = 0;
    int id1 = 0;
	int high_read = 0;
    int low_read = 0;
    int ret = 0;
    
    ret = gpio_request(TP_ID0, "TP_ID0");
	if(ret < 0)
	{
		printk(KERN_ERR"TP_ID0 gpio[%d] request failed\n", TP_ID0);
		return -1;
	}
	ret = gpio_request(TP_ID1, "TP_ID1");
	if(ret < 0)
	{
		printk(KERN_ERR"TP_ID1 gpio[%d] request failed\n", TP_ID1);
		return -1;
	}
	
    gpio_tlmm_config(GPIO_CFG(TP_ID0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);	
	gpio_set_value(TP_ID0,0);	
	gpio_tlmm_config(GPIO_CFG(TP_ID0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);	
    low_read = gpio_get_value(TP_ID0);
    
	gpio_tlmm_config(GPIO_CFG(TP_ID0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_set_value(TP_ID0,1);
	gpio_tlmm_config(GPIO_CFG(TP_ID0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	high_read = gpio_get_value(TP_ID0);

    if (low_read != high_read)
    {
    	gpio_tlmm_config(GPIO_CFG(TP_ID0, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
    	id0 = BIT(1);
    }
	else
	{
		id0  = low_read;
		if (id0)
			gpio_tlmm_config(GPIO_CFG(TP_ID0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
		else
			gpio_tlmm_config(GPIO_CFG(TP_ID0, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	}

    gpio_tlmm_config(GPIO_CFG(TP_ID1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);  
	gpio_set_value(TP_ID1,0);
	gpio_tlmm_config(GPIO_CFG(TP_ID1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);	
    low_read = gpio_get_value(TP_ID1);

    gpio_tlmm_config(GPIO_CFG(TP_ID1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
    gpio_set_value(TP_ID1,1);
	gpio_tlmm_config(GPIO_CFG(TP_ID1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	high_read = gpio_get_value(TP_ID1);

    if (low_read != high_read)
    {
    	gpio_tlmm_config(GPIO_CFG(TP_ID1, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
    	id1 = BIT(1);
    }
	else
	{
		id1  = low_read;
		if (id1)
			gpio_tlmm_config(GPIO_CFG(TP_ID1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
		else
			gpio_tlmm_config(GPIO_CFG(TP_ID1, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	}

	gpio_free(TP_ID0);
	gpio_free(TP_ID1);
    return  id1 << 2 | id0;
}
static int __devinit jogball_probe(struct platform_device *pdev)
{
    struct jogball_platform_data *pdata = pdev->dev.platform_data;
    struct jogball_drvdata *ddata;
    struct jogball_button *button;
    int i;
    int error = -1;

#ifdef CONFIG_HUAWEI_FEATURE_U8220_PP1
    int iHwversion = -1;
#endif

    gpio_tlmm_config(GPIO_CFG(pdata->gpio_ctl, 0, GPIO_OUTPUT,  GPIO_PULL_UP, GPIO_2MA), GPIO_ENABLE);
    for (i = 0; i < pdata->nbuttons; i++) {
        button = &pdata->buttons[i];
        gpio_tlmm_config(GPIO_CFG(button->gpio, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA), GPIO_ENABLE);
    }

    ddata = kzalloc(sizeof(struct jogball_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL);
    if (!ddata) {
        error = -ENOMEM;
        printk("\n kzalloc error \n");        
        goto err_alloc;
    }

    ddata->input  = input_allocate_device();
    if (!(ddata->input)) {
        error = -ENOMEM;
        printk("\n input_allocate_device error \n");        
        goto err_inputalloc;
    }
    
    set_bit(EV_KEY, ddata->input->evbit);
    platform_set_drvdata(pdev, ddata);

    ddata->input->name = pdev->name;
    error = gpio_request(pdata->gpio_ctl, "jogball_ctl");
    if (error<0) {
        printk("jogball_ctl: failed to request GPIO for jogball_ctl %d,"
        " error %d\n", pdata->gpio_ctl, error);
        goto err_gpio_req;
        
    }
    error = gpio_direction_output(pdata->gpio_ctl,GPIO_LOW_VALUE);
    if (error<0) {
        pr_err("jogball_clt: gpio_configure failed for "
        "output %d\n", pdata->gpio_ctl);
        goto err_gpio_dir;
    }      

    for (i = 0; i < pdata->nbuttons; i++) {
        button = &pdata->buttons[i];
        //unsigned int type = button->type ?: EV_KEY;                
        error = gpio_request(button->gpio, "jogball");
        if (error < 0) {
            printk("jogball: failed to request GPIO %d,"
            " error %d\n", button->gpio, error);
            while (--i >= 0) {
                gpio_free(pdata->buttons[i].gpio);
            }            
            goto err_gpio_dir;
        }
        error = gpio_direction_input(button->gpio);
        if (error < 0) {
            printk("jogball: failed to configure input"
            " direction for GPIO %d, error %d\n",
            button->gpio, error);
            while (--i >= 0) {
                gpio_free(pdata->buttons[i].gpio);
            }
            /*we release one more*/
            gpio_free(button->gpio);
            goto err_gpio_dir;
        }

    //input_set_capability(ddata->input, type, button->code);
    }

#ifdef CONFIG_HUAWEI_FEATURE_U8220_PP1
/*decide HW version for deal jogball */
    iHwversion = bio_get_hw_sub_ver();

    if(HW_VER_T1 == iHwversion)
    {/*T1,T2*/
        g_iJogballReport = 0;
    }
    else if (HW_VER_PP1 == iHwversion)
    {/*PP1*/
        g_iJogballReport = JOGBALL_REPNUM;
    }
    else
    {
        g_iJogballReport = JOGBALL_REPNUM;
    }
#endif

    g_iJogballReport = JOGBALL_REPNUM;
    input_set_capability(ddata->input, EV_KEY, BTN_MOUSE);
    input_set_capability(ddata->input, EV_REL, REL_X);
    input_set_capability(ddata->input, EV_REL, REL_Y);
    
    INIT_WORK(&ddata->jogball_work, jogball_do_work);

    error = jogball_up_isr_start(pdev);
    if(error < 0)
    {
        goto err_gpiodir_req;
    }
    error = jogball_down_isr_start(pdev);
    if(error < 0)
    {
        goto err_gpiodir_req;
    }
    error = jogball_left_isr_start(pdev);
    if(error < 0)
    {
        goto err_gpiodir_req;
    }
    error = jogball_right_isr_start(pdev);
    if(error < 0)
    {
        goto err_gpiodir_req;
    }

    error = input_register_device(ddata->input);
    if (error) {
        printk("jogball: Unable to register input device, " "error: %d\n", error);
        goto err_gpiodir_req;
    }
    return 0;
//error:
err_gpiodir_req:
    for(i = 0; i < pdata->nbuttons; i++) {
        gpio_free(pdata->buttons[i].gpio);
    }
err_gpio_dir:
    //gpio_free(JOGBALL_CTL);
    gpio_free(pdata->gpio_ctl);
err_gpio_req:
    platform_set_drvdata(pdev, NULL);
    input_free_device(ddata->input);
err_inputalloc:
    kfree(ddata);
err_alloc:
    return error;
}
static void sdcc_gpio_init(void)
{
#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
	int rc = 0;
	if (gpio_request(sd_detect_gpio, "sdc1_status_pin_irq"))
		pr_err("failed to request gpio sdc1_status_irq\n");
	rc = gpio_tlmm_config(GPIO_CFG(sd_detect_gpio, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
									GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	if (rc)
		printk(KERN_ERR "%s: Failed to configure GPIO %d\n",
					__func__, rc);
	/* if (gpio_request(GPIO_MMC_COVER_DETECT, "sdc1_status_socket_irq")) */
	/* 	pr_err("failed to request gpio sdc1_status_irq\n"); */
	/* rc = gpio_tlmm_config(GPIO_CFG(GPIO_MMC_COVER_DETECT, 0, GPIO_INPUT, GPIO_PULL_UP, */
	/* 							   GPIO_2MA), GPIO_ENABLE); */
	/* if (rc) */
	/* 	printk(KERN_ERR "%s: Failed to configure GPIO %d\n", */
	/* 				__func__, rc); */
#endif
	/* SDC1 GPIOs */
#ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
#ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION
	if (gpio_request(GPIO_SD_DATA_3, "sdc1_data_3"))
		pr_err("failed to request gpio sdc1_data_3\n");
	if (gpio_request(GPIO_SD_DATA_2, "sdc1_data_2"))
		pr_err("failed to request gpio sdc1_data_2\n");
	if (gpio_request(GPIO_SD_DATA_1, "sdc1_data_1"))
		pr_err("failed to request gpio sdc1_data_1\n");
	if (gpio_request(GPIO_SD_DATA_0, "sdc1_data_0"))
		pr_err("failed to request gpio sdc1_data_0\n");
	if (gpio_request(GPIO_SD_CMD, "sdc1_cmd"))
		pr_err("failed to request gpio sdc1_cmd\n");
	if (gpio_request(GPIO_SD_CLK, "sdc1_clk"))
		pr_err("failed to request gpio sdc1_clk\n");
#else
	if (gpio_request(51, "sdc1_data_3"))
		pr_err("failed to request gpio sdc1_data_3\n");
	if (gpio_request(52, "sdc1_data_2"))
		pr_err("failed to request gpio sdc1_data_2\n");
	if (gpio_request(53, "sdc1_data_1"))
		pr_err("failed to request gpio sdc1_data_1\n");
	if (gpio_request(54, "sdc1_data_0"))
		pr_err("failed to request gpio sdc1_data_0\n");
	if (gpio_request(55, "sdc1_cmd"))
		pr_err("failed to request gpio sdc1_cmd\n");
	if (gpio_request(56, "sdc1_clk"))
		pr_err("failed to request gpio sdc1_clk\n");
#endif
#endif

	/* SDC2 GPIOs */
#ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
	if (gpio_request(62, "sdc2_clk"))
		pr_err("failed to request gpio sdc2_clk\n");
	if (gpio_request(63, "sdc2_cmd"))
		pr_err("failed to request gpio sdc2_cmd\n");
	if (gpio_request(64, "sdc2_data_3"))
		pr_err("failed to request gpio sdc2_data_3\n");
	if (gpio_request(65, "sdc2_data_2"))
		pr_err("failed to request gpio sdc2_data_2\n");
	if (gpio_request(66, "sdc2_data_1"))
		pr_err("failed to request gpio sdc2_data_1\n");
	if (gpio_request(67, "sdc2_data_0"))
		pr_err("failed to request gpio sdc2_data_0\n");
#endif

	/* SDC3 GPIOs */
#ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
	if (gpio_request(88, "sdc3_clk"))
		pr_err("failed to request gpio sdc3_clk\n");
	if (gpio_request(89, "sdc3_cmd"))
		pr_err("failed to request gpio sdc3_cmd\n");
	if (gpio_request(90, "sdc3_data_3"))
		pr_err("failed to request gpio sdc3_data_3\n");
	if (gpio_request(91, "sdc3_data_2"))
		pr_err("failed to request gpio sdc3_data_2\n");
	if (gpio_request(92, "sdc3_data_1"))
		pr_err("failed to request gpio sdc3_data_1\n");
	if (gpio_request(93, "sdc3_data_0"))
		pr_err("failed to request gpio sdc3_data_0\n");
#endif

	/* SDC4 GPIOs */
#ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
	if (gpio_request(19, "sdc4_data_3"))
		pr_err("failed to request gpio sdc4_data_3\n");
	if (gpio_request(20, "sdc4_data_2"))
		pr_err("failed to request gpio sdc4_data_2\n");
	if (gpio_request(21, "sdc4_data_1"))
		pr_err("failed to request gpio sdc4_data_1\n");
	if (gpio_request(107, "sdc4_cmd"))
		pr_err("failed to request gpio sdc4_cmd\n");
	if (gpio_request(108, "sdc4_data_0"))
		pr_err("failed to request gpio sdc4_data_0\n");
	if (gpio_request(109, "sdc4_clk"))
		pr_err("failed to request gpio sdc4_clk\n");
#endif
}
Example #26
0
static int
qcom_ehci_attach(device_t self)
{
	ehci_softc_t *sc;
        struct qcom_ehci_softc *esc;
	bus_space_handle_t bsh;
	int err;
	uint32_t val;

        esc = device_get_softc(self);
        sc = &esc->base;
	sc->sc_bus.parent = self;
	sc->sc_bus.devices = sc->sc_devices;
	sc->sc_bus.devices_max = EHCI_MAX_DEVICES;

	/* get all DMA memory */
	if (usb_bus_mem_alloc_all(&sc->sc_bus,
	    USB_GET_DMA_TAG(self), &ehci_iterate_hw_softc)) {
		return (ENOMEM);
	}

	sc->sc_bus.usbrev = USB_REV_2_0;

        if (bus_alloc_resources(self, qcom_ehci_spec, esc->res)) {
                device_printf(self, "could not allocate resources\n");
                return (ENXIO);
        }
        /* EHCI registers */
        sc->sc_io_tag = rman_get_bustag(esc->res[0]);
        bsh = rman_get_bushandle(esc->res[0]);
        sc->sc_io_size = rman_get_size(esc->res[0]);

        /* GPIO */
        esc->gpio_bst = rman_get_bustag(esc->res[1]);
        esc->gpio_bsh = rman_get_bushandle(esc->res[1]);

	if (bus_space_subregion(sc->sc_io_tag, bsh, 0x100,
	    sc->sc_io_size, &sc->sc_io_hdl) != 0)
		panic("%s: unable to subregion USB host registers",
		    device_get_name(self));

	sc->sc_bus.bdev = device_add_child(self, "usbus", -1);
	if (!sc->sc_bus.bdev) {
		device_printf(self, "Could not add USB device\n");
		goto error;
	}
	device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
	device_set_desc(sc->sc_bus.bdev, EHCI_HC_DEVSTR);

	sprintf(sc->sc_vendor, "Qualcomm");

	err = bus_setup_intr(self, esc->res[2], INTR_TYPE_BIO | INTR_MPSAFE,
	    NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
	if (err) {
		device_printf(self, "Could not setup irq, %d\n", err);
		sc->sc_intr_hdl = NULL;
		goto error;
	}

	sc->sc_flags |= EHCI_SCFLG_DONTRESET;

        /* Configure GPIO for output */ 
        gpio_tlmm_config(esc, 77, 0, QGPIO_OUTPUT, QGPIO_NO_PULL, QGPIO_8MA, QGPIO_ENABLE);

        /* Output High */
        gpio_set(esc, 77, 2);

	/* ehci phy reset */
	val = READ_4(sc, USB_PORTSC) & ~PORTSC_PTS_MASK;
	WRITE_4(sc, USB_PORTSC, val | PORTSC_PTS_ULPI);
	WRITE_4(sc, USB_USBCMD, USBCMD_RESET);

	/* reset */
	WRITE_4(sc, USB_USBCMD, 0x00080000);
	/* select ULPI phy */
	WRITE_4(sc, USB_PORTSC, 0x80000000);

	/* burst of unspecified len */
	WRITE_4(sc, USB_AHB_BURST, 0);
	/* HPROT mode */
	WRITE_4(sc, USB_AHB_MODE, 0x08);

	/* disable BAM */
	WRITE_4(sc, USB_GENCONFIG, (1 << 13));

//	READ_4(sc, USB_DCCPARAMS);
	/* Disable streaming mode and select host mode */
	WRITE_4(sc, USB_USBMODE, 0x13);

	/* go to RUN mode (D+ pullup enable) */
	WRITE_4(sc, USB_USBCMD, 0x00080000);

//	breakpoint();
	err = ehci_init(sc);
	if (!err)
		err = device_probe_and_attach(sc->sc_bus.bdev);

	if (err) {
		device_printf(self, "USB init failed err=%d\n", err);
		goto error;
	}
	return (0);

error:
	qcom_ehci_detach(self);
	return (ENXIO);
}
/* FIH-SW-MM-VH-DISPLAY-JB00*[ */
static int msm_fb_dsi_client_msm_reset(int hold)
{
	int rc = 0;
	static int dsi_reset_initialized = 0;

	printk(KERN_INFO "[DISPLAY]%s: E, hold <%d>\n", __func__, hold);

	if (dsi_reset_initialized == 0) {
		rc = gpio_request(GPIO_LCM_RESET, "gpio_disp_pwr");
		if (rc < 0) {
			pr_err("[DISPLAY] %s: Failed to request lcm_reset, rc <%d>\n", __func__, rc);
			//return rc;
		}
		rc = gpio_tlmm_config(GPIO_CFG(GPIO_LCM_RESET, 0, GPIO_CFG_OUTPUT,
									GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

		if (unlikely(fih_get_product_phase() < Phase_SP2)) {
			printk(KERN_ALERT "[DISPLAY]%s: <%d> < SP2\n", __func__, fih_get_product_phase());
			rc = gpio_request(GPIO_LCM_BKL_EN, "lcm_bkl_en");
			if (rc < 0) {
				pr_err("[DISPLAY] %s: Failed to request lcm_bkl_en\n", __func__);
				//goto gpio_error;
			}

			rc = gpio_tlmm_config(GPIO_CFG(GPIO_LCM_BKL_EN, 0, GPIO_CFG_OUTPUT,
										GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
									GPIO_CFG_ENABLE); 
			if (rc < 0) {
				pr_err("[DISPLAY] %s: Failed lcm_bkl_en enable\n", __func__);
				//goto gpio_error2;
			}
		}
		dsi_reset_initialized = 1;
	}

	if (hold) {
		gpio_direction_output(GPIO_LCM_RESET, 0);
	} else {
		rc |= gpio_direction_output(GPIO_LCM_RESET, 1);
		msleep(5);
		rc |= gpio_direction_output(GPIO_LCM_RESET, 0);
		msleep(5);
		rc |= gpio_direction_output(GPIO_LCM_RESET, 1);
	}
	msleep(150);
#if 0
	if (!rc) {
		if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()
				|| machine_is_msm8625_surf()) {
			lcdc_reset_ptr = ioremap_nocache(LCDC_RESET_PHYS,
				sizeof(uint32_t));
			printk(KERN_ERR "[DISPLAY]%s: surf\n", __func__);

			if (!lcdc_reset_ptr)
				return 0;
		}

		printk(KERN_ERR "[DISPLAY]%s: X, rc <%d>\n", __func__, rc);
		return rc;
	} else {
		//goto gpio_error;
	}
#endif
#if 0
gpio_error2:
	pr_err("Failed GPIO bridge pd\n");
	gpio_free(GPIO_LCDC_BRDG_PD);

gpio_error:
	pr_err("Failed GPIO bridge reset\n");
	gpio_free(GPIO_LCDC_BRDG_RESET_N);
#endif
	printk(KERN_INFO "[DISPLAY]%s: X, rc <%d>\n", __func__, rc);

	return rc;
}
int pic16f_fw_update(bool pull96)
{
	unsigned char zero_buf[1] = {0};
	unsigned char addr_buf[2] = {0x02,0x00};
	unsigned char temp_buf[1];
	int i,rc=0;
	unsigned int addr = 0x200;
	int download_again = 0;
	
	pr_err("%s pic16F_update_fw,erase data ing.......\n",__func__);

	//pull up GPIO96 to power on MCU1503
	if(pull96){
		gpio_set_value(96,1);
		rc = gpio_tlmm_config(GPIO_CFG(96, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),GPIO_CFG_ENABLE);
		if(rc < 0){
			pr_err("%s pull up GPIO96 fail\n",__func__);
			return rc;
		}
		msleep(300);
	}

update_fw:
	//erase address 0x200-0x7FF 
	for(i = 0;i < ERASE_COUNT;i++){
		//first:set address
		rc = i2c_smbus_write_i2c_block_data(pic16F_client,0x01,2,&addr_buf[0]);
		if(rc < 0){
			pr_err("%s pic16F_update_fw,i2c_write 0x01 error\n",__func__);
			goto update_fw_err;
			}
		//erase data:0x10 words once
		i2c_smbus_write_i2c_block_data(pic16F_client,0x04,1,&zero_buf[0]);
		msleep(1);
		i2c_smbus_read_i2c_block_data(pic16F_client,0x04,1,&temp_buf[0]);
		//printk("lfc read 0x04,temp_buf[0]:0x%x\n",temp_buf[0]);
		addr = addr + 0x10;
		addr_buf[0] = addr >> 8;
		addr_buf[1] = addr & 0xFF;
		//printk("lfc addr_buf[0]:0x%x,addr_buf[1]:0x%x\n",addr_buf[0],addr_buf[1]);
	}
	msleep(10);
		
	pic16f_fw_write(Pic16F_firmware_data,0,sizeof(Pic16F_firmware_data) - 34);

	//fw check begin:read data from pic1503/1508,and compare it with Pic16F_firmware_data[]
	rc = pic16f_fw_check();
	if(rc == FW_CHECK_FAIL){
		download_again++;
		if(download_again > 3){
			goto update_fw_err;
		}
		pr_err("%s fw check fail,download fw again\n",__func__);
		goto update_fw;
	}
	//fw check end

	//write 0x7F0~0x7FF(0x7FF = 0x3455)
	rc = pic16f_fw_write(Pic16F_firmware_data,sizeof(Pic16F_firmware_data) - 34,34);
	if(rc < 0){
		goto update_fw_err;
	}
	//write 0x7F0~0x7FF end
	
	msleep(2);
	//jump to app code begin
	i2c_smbus_write_i2c_block_data(pic16F_client,0x06,1,&zero_buf[0]);
	i2c_smbus_read_i2c_block_data(pic16F_client,0x06,1,&temp_buf[0]);
	//jump to app code end
	
	pic_have_updated = 1;
	
	//pull down GPIO96 to power off MCU1503/1508
	if(pull96) {
		gpio_set_value(96,0);
		rc = gpio_tlmm_config(GPIO_CFG(96, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),GPIO_CFG_ENABLE);
		if(rc < 0){
			pr_err("%s pull down GPIO96 fail\n",__func__);
		}
	}	
	pr_err("%s pic16F update_fw success\n",__func__);
	return 0;

update_fw_err:
	if(pull96){
		gpio_set_value(96,0);
		rc = gpio_tlmm_config(GPIO_CFG(96, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),GPIO_CFG_ENABLE);
		if(rc < 0){
			pr_err("%s pull down GPIO96 fail\n",__func__);
		}
	}
	pr_err("%s pic16F update_fw fail\n",__func__);
	return 1;
}
static int mipi_dsi_panel_qrd3_power(int on)
{
	int rc = 0;

	if (!qrd3_dsi_gpio_initialized) {
		pmapp_disp_backlight_init();
		rc = gpio_request(GPIO_QRD3_LCD_BACKLIGHT_EN,
			"qrd3_gpio_bkl_en");
		if (rc < 0)
			return rc;

		qrd3_dsi_gpio_initialized = 1;

		if (mdp_pdata.cont_splash_enabled) {
			rc = gpio_tlmm_config(GPIO_CFG(
			     GPIO_QRD3_LCD_BACKLIGHT_EN, 0, GPIO_CFG_OUTPUT,
			     GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
			if (rc < 0) {
				pr_err("failed QRD3 GPIO_BACKLIGHT_EN tlmm config\n");
				return rc;
			}
			rc = gpio_direction_output(GPIO_QRD3_LCD_BACKLIGHT_EN,
			     1);
			if (rc < 0) {
				pr_err("failed to enable backlight\n");
				gpio_free(GPIO_QRD3_LCD_BACKLIGHT_EN);
				return rc;
			}

			/*Configure LCD Bridge reset*/
			rc = gpio_tlmm_config(qrd3_mipi_dsi_gpio[0],
			     GPIO_CFG_ENABLE);
			if (rc < 0) {
				pr_err("Failed to enable LCD Bridge reset enable\n");
				return rc;
			}

			rc = gpio_direction_output(GPIO_QRD3_LCD_BRDG_RESET_N,
			     1);

			if (rc < 0) {
				pr_err("Failed GPIO bridge Reset\n");
				gpio_free(GPIO_QRD3_LCD_BRDG_RESET_N);
				return rc;
			}
			return 0;
		}
	}

	if (on) {
		rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0,
			GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),
			GPIO_CFG_ENABLE);
		if (rc < 0) {
			pr_err("failed QRD3 GPIO_BACKLIGHT_EN tlmm config\n");
			return rc;
		}
		rc = gpio_direction_output(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
		if (rc < 0) {
			pr_err("failed to enable backlight\n");
			gpio_free(GPIO_QRD3_LCD_BACKLIGHT_EN);
			return rc;
		}
		/*Toggle Backlight GPIO*/
		gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
		udelay(100);
		gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 0);
		udelay(430);
		gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
		/* 1 wire mode starts from this low to high transition */
		udelay(50);

		/*Enable EXT_2.85 and 1.8 regulators*/
		rc = regulator_enable(gpio_reg_2p85v);
		if (rc < 0)
			pr_err("%s: reg enable failed\n", __func__);
		rc = regulator_enable(gpio_reg_1p8v);
		if (rc < 0)
			pr_err("%s: reg enable failed\n", __func__);

		/*Configure LCD Bridge reset*/
		rc = gpio_tlmm_config(qrd3_mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
		if (rc < 0) {
			pr_err("Failed to enable LCD Bridge reset enable\n");
			return rc;
		}

		rc = gpio_direction_output(GPIO_QRD3_LCD_BRDG_RESET_N, 1);

		if (rc < 0) {
			pr_err("Failed GPIO bridge Reset\n");
			gpio_free(GPIO_QRD3_LCD_BRDG_RESET_N);
			return rc;
		}

		/*Toggle Bridge Reset GPIO*/
		msleep(20);
		gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 0);
		msleep(20);
		gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 1);
		msleep(20);

	} else {
		gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0,
			GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
			GPIO_CFG_DISABLE);

		gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0,
			GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
			GPIO_CFG_DISABLE);

		rc = regulator_disable(gpio_reg_2p85v);
		if (rc < 0)
			pr_err("%s: reg disable failed\n", __func__);
		rc = regulator_disable(gpio_reg_1p8v);
		if (rc < 0)
			pr_err("%s: reg disable failed\n", __func__);

	}

	return rc;
}
static int rt9396_probe(struct i2c_client *i2c_dev, const struct i2c_device_id *i2c_dev_id)
{
	struct lge_backlight_platform_data *pdata;
	struct rt9396_driver_data *drvdata;
	struct backlight_device *bd;
	int err;

	rt9396_powerstate = NORMAL_STATE;
	dprintk("start, client addr=0x%x\n", i2c_dev->addr);

	pdata = i2c_dev->dev.platform_data;
	if(!pdata)
		return -EINVAL;

	drvdata = kzalloc(sizeof(struct rt9396_driver_data), GFP_KERNEL);
	if (!drvdata) {
		dev_err(&i2c_dev->dev, "failed to allocate memory\n");
		return -ENOMEM;
	}

	if (pdata && pdata->platform_init)
		pdata->platform_init();

	drvdata->client = i2c_dev;
	drvdata->gpio = pdata->gpio;
	drvdata->max_intensity = LCD_LED_MAX;
	if (pdata->max_current > 0)
		drvdata->max_intensity = pdata->max_current;
	drvdata->intensity = LCD_LED_MIN;
	drvdata->mode = NORMAL_MODE;
	drvdata->state = UNINIT_STATE;
	drvdata->version = pdata->version;

	if(rt9396_setup_version(drvdata) != 0) {
		eprintk("Error while requesting gpio %d\n", drvdata->gpio);
		kfree(drvdata);
		return -ENODEV;
	}

//[V3][junghoon79.kim][2012.9.10] #if 0 -> #if 1
#if 1 //not use enable pin in rt9396	
	if (drvdata->gpio && gpio_request(drvdata->gpio, "rt9396_en") != 0) {
		eprintk("Error while requesting gpio %d\n", drvdata->gpio);
		kfree(drvdata);
		return -ENODEV;
	}
   gpio_tlmm_config(GPIO_CFG(drvdata->gpio, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
#endif
 //[V3][junghoon79.kim][2012.9.10]- end
 
	bd = backlight_device_register("rt9396-bl", &i2c_dev->dev, NULL, &rt9396_ops, NULL);
	if (bd == NULL) {
		eprintk("entering rt9396 probe function error \n");
		//if (gpio_is_valid(drvdata->gpio))
		//	gpio_free(drvdata->gpio);
		kfree(drvdata);
		return -1;
	}
	bd->props.power = FB_BLANK_UNBLANK;
	bd->props.brightness = drvdata->intensity;
	bd->props.max_brightness = drvdata->max_intensity;
	drvdata->bd = bd;

#ifdef CONFIG_BACKLIGHT_LEDS_CLASS
	if (led_classdev_register(&i2c_dev->dev, &rt9396_led_dev) == 0) {
		eprintk("Registering led class dev successfully.\n");
		drvdata->led = &rt9396_led_dev;
		err = device_create_file(drvdata->led->dev, &dev_attr_alc);
		err = device_create_file(drvdata->led->dev, &dev_attr_reg);
		err = device_create_file(drvdata->led->dev, &dev_attr_drvstat);
		err = device_create_file(drvdata->led->dev, &dev_attr_chargerlogo);
	}
/*2012-09-26 junghoon-kim(junghoon79.kim@lge.com) porting from bu61800 driver [START]*/
#ifdef USE_BUTTON_BACKLIGHT
	/* dajin.kim@lge.com */
	if (led_classdev_register(&i2c_dev->dev, &rt9396_keyled_dev) == 0) {
		eprintk("Registering led class dev successfully.\n");
		drvdata->led = &rt9396_keyled_dev;
	}
	/* dajin.kim@lge.com */
#endif
/*2012-09-26 junghoon-kim(junghoon79.kim@lge.com) porting from bu61800 driver [END]*/
#endif

	i2c_set_clientdata(i2c_dev, drvdata);
	i2c_set_adapdata(i2c_dev->adapter, i2c_dev);

	rt9396_device_init(drvdata);
	rt9396_send_intensity(drvdata, RT9396BL_DEFAULT_BRIGHTNESS);

#ifdef CONFIG_HAS_EARLYSUSPEND
	drvdata->early_suspend.suspend = rt9396_early_suspend;
	drvdata->early_suspend.resume = rt9396_late_resume;
	drvdata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN - 40;
	register_early_suspend(&drvdata->early_suspend);
#endif

	rt9396_ref = drvdata;

	eprintk("done\n");
	return 0;
}