示例#1
0
struct msm_handset {
	struct input_dev *ipdev;
	struct switch_dev sdev;
	struct msm_handset_platform_data *hs_pdata;
};

static struct msm_rpc_client *rpc_client;
static struct msm_handset *hs;
#if defined(CONFIG_MACH_R750) 
#define MSM_GPIO_GSM_EARPHONE_DETECT	    78
typedef enum
{
  GPIO_LOW_LEVEL  = 0,
  GPIO_HIGH_LEVEL = 1
} GPIO_ValueType;
static unsigned modemctl_config_earphonedetect = GPIO_CFG(
MSM_GPIO_GSM_EARPHONE_DETECT, 0, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_2MA);

static int earphone_gpio_init(void)
{
    int rc = 0;

    /* GSM AT_SW pin */
    rc = gpio_tlmm_config(modemctl_config_earphonedetect ,GPIO_ENABLE);
	if (rc) 
	{
		printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",__func__, 
			MSM_GPIO_GSM_EARPHONE_DETECT, rc);
		return -EIO;
	}
	rc = gpio_request(MSM_GPIO_GSM_EARPHONE_DETECT, "modemctl");
	if(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 init_gpios(void){
    int ret;
    struct gpio_switch_data *p = head;
    while(p){
	    ret = gpio_tlmm_config(GPIO_CFG(p->gpio, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),GPIO_CFG_ENABLE);
	    if (ret){
	    	pr_err("Could not configure gpio %d\n", p->gpio);
            return -EINVAL;
        }
        gpio_request(p->gpio , p->name);

        if(p->event_mode == PAN_INPUTEVENT){
            p->input_dev = input_allocate_device();
            if(p->input_dev == NULL){
                pr_err("switch_gpio failed to allocate input device\n");
                return -ENOMEM;
            }
            p->input_dev->name = p->name;
	        set_bit(EV_SW, p->input_dev->evbit);
	        set_bit(SW_LID, p->input_dev->swbit);
            ret = input_register_device(p->input_dev);
            if(ret){
                pr_err("switch_gpio unable to register %s input device\n", p->input_dev->name);
                return -EINVAL;
            }
        }
        else if(p->event_mode == PAN_UEVENT){
            p->sdev.print_state = gpio_switch_print_state;
            p->sdev.name = p->name;
            ret = switch_dev_register(&p->sdev);
            if(ret < 0){
                pr_err("%s Switch dev register is failed\n" , p->sdev.name);
                return -EINVAL;
            }
        }
        else{
            pr_err("event_mode : %d does not exist\n" , p->event_mode); 
            return -EINVAL;
        }
        p->current_state = gpio_get_value(p->gpio) ^ p->flag;

        if(p->event_mode == PAN_INPUTEVENT){
            dbg("INPUTEVENT %s sent event : %d\n" , p->name , p->current_state);
            input_report_switch(p->input_dev , SW_LID , p->current_state);
            input_sync(p->input_dev);
        }
        else if(p->event_mode == PAN_UEVENT){
            dbg("UEVENT %s sent event : %d\n" , p->name , p->current_state);
            switch_set_state(&p->sdev , p->current_state);
        }
        p->last_state = p->current_state;

        ret = request_threaded_irq(p->irq , NULL , gpio_switch_irq_handler , IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING , p->name , p);
        if(ret){
            pr_err("%s request_irq is failed reason : %d\n" , p->name , ret);
            return -EINVAL;
        }
        
        hrtimer_init(&p->timer , CLOCK_MONOTONIC , HRTIMER_MODE_REL);
        p->timer.function = gpio_switch_timer_func;
        p->debounce = DEBOUNCE_UNKNOWN | DEBOUNCE_WAIT_IRQ;
        p->debounce_count = 0;

        p->notify = NULL;
        p->emergency_notify = NULL;

        INIT_WORK(&p->work , gpio_switch_work);

        wake_lock_init(&p->wakelock, WAKE_LOCK_SUSPEND, p->name);
        enable_irq_wake(p->irq);

        p->disabled = false;
        
        p = p->next;
    }
    return 0;
}
示例#4
0
static int max77803_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max77803_dev *max77803;
	struct max77803_platform_data *pdata;
	u8 reg_data;
	int ret = 0;
	dev_info(&i2c->dev, "%s\n", __func__);

	max77803 = kzalloc(sizeof(struct max77803_dev), GFP_KERNEL);
	if (max77803 == NULL)
		return -ENOMEM;

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

		ret = of_max77803_dt(&i2c->dev, pdata);
		if (ret < 0){
			dev_err(&i2c->dev, "Failed to get device of_node \n");
			return ret;
		}
		/*Filling the platform data*/
		pdata->num_regulators = MAX77803_REG_MAX;
		pdata->muic_data = &max77803_muic;
		pdata->charger_data = &sec_battery_pdata;
		pdata->regulators = max77803_regulators,
#ifdef CONFIG_VIBETONZ
		pdata->haptic_data = &max77803_haptic_pdata;
#endif
		pdata->led_data = &max77803_led_pdata;
		/* set irq_base at sec_battery_pdata */
		sec_battery_pdata.bat_irq = pdata->irq_base + MAX77803_CHG_IRQ_BATP_I;
		/*pdata update to other modules*/
		i2c->dev.platform_data = pdata;
	} else
		pdata = i2c->dev.platform_data;

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

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

	mutex_init(&max77803->iolock);

	if (max77803_read_reg(i2c, MAX77803_PMIC_REG_PMIC_ID2, &reg_data) < 0) {
		dev_err(max77803->dev,
			"device not found on this channel (this is not an error)\n");
		ret = -ENODEV;
		goto err;
	} else {
		/* print rev */
		max77803->pmic_rev = (reg_data & 0x7);
		max77803->pmic_ver = ((reg_data & 0xF8) >> 0x3);
		pr_info("%s: device found: rev.0x%x, ver.0x%x\n", __func__,
				max77803->pmic_rev, max77803->pmic_ver);
	}
#if 0
#if defined(CONFIG_MACH_JF_VZW) || defined(CONFIG_MACH_JF_LGT)
	if (kernel_sec_get_debug_level() == KERNEL_SEC_DEBUG_LEVEL_LOW) {
		pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET);
		max77803_write_reg(i2c, MAX77803_PMIC_REG_MAINCTRL1, 0x04);
	} else {
		pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET);
		max77803_write_reg(i2c, MAX77803_PMIC_REG_MAINCTRL1, 0x0c);
	}
#else
	if (kernel_sec_get_debug_level() == KERNEL_SEC_DEBUG_LEVEL_LOW) {
		max77803_write_reg(i2c, MAX77803_PMIC_REG_MAINCTRL1, 0x04);
	} else {
		pm8xxx_hard_reset_config(PM8XXX_DISABLE_HARD_RESET);
		max77803_write_reg(i2c, MAX77803_PMIC_REG_MAINCTRL1, 0x0c);
	}
#endif
#endif
	max77803_update_reg(i2c, MAX77803_CHG_REG_SAFEOUT_CTRL, 0x00, 0x30);

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

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

	ret = max77803_irq_init(max77803);
	if (ret < 0)
		goto err_irq_init;

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

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

	return ret;

err_mfd:
	mfd_remove_devices(max77803->dev);
	max77803_irq_exit(max77803);
err_irq_init:
	i2c_unregister_device(max77803->muic);
	i2c_unregister_device(max77803->haptic);
err:
	kfree(max77803);
	return ret;
}
};

static char lcdc_splash_is_enabled()
{
	return mdp_pdata.cont_splash_enabled;
}

#define GPIO_LCDC_BRDG_PD	128
#define GPIO_LCDC_BRDG_RESET_N	129
#define GPIO_LCD_DSI_SEL	125
#define LCDC_RESET_PHYS		0x90008014

static  void __iomem *lcdc_reset_ptr;

static unsigned mipi_dsi_gpio[] = {
		GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
		GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */
};

static unsigned lcd_dsi_sel_gpio[] = {
	GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
			GPIO_CFG_2MA),
};

enum {
	DSI_SINGLE_LANE = 1,
	DSI_TWO_LANES,
};

static int msm_fb_get_lane_config(void)
示例#6
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;
	}

#ifndef CONFIG_SHLCDC_BOARD
	vsync_clk_status = 0;
#endif /* CONFIG_SHLCDC_BOARD */
	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);


#ifdef CONFIG_FB_MSM_MDP40
				if (mdp_hw_revision < MDP4_REVISION_V2_1)
					mdp_set_sync_cfg_1(mfd, vsync_cnt_cfg);
#endif

				/*
				 * 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);
#ifdef CONFIG_FB_MSM_MDP40
				if (mdp_hw_revision < MDP4_REVISION_V2_1) {
					MDP_OUTP(MDP_BASE +
					MDP_SEC_VSYNC_INIT_VAL, vsync_load_cnt);
				}
#endif

				/*
				 * external vsync source pulse width and
				 * polarity flip
				 */
				MDP_OUTP(MDP_BASE + MDP_PRIM_VSYNC_OUT_CTRL,
							BIT(0));
#ifdef CONFIG_FB_MSM_MDP40
				if (mdp_hw_revision < MDP4_REVISION_V2_1) {
					MDP_OUTP(MDP_BASE +
					MDP_SEC_VSYNC_OUT_CTRL, BIT(0));
					MDP_OUTP(MDP_BASE +
						MDP_VSYNC_SEL, 0x20);
				}
#endif

				/* 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;
#ifdef CONFIG_SHLCDC_BOARD
		init_waitqueue_head(&mdp_wq_for_vsync);
		atomic_set(&mdp_atomic_for_vsync, 0);
		hrtimer_init(&vsync_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
#else
		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 /*CONFIG_SHLCDC_BOARD*/
#endif

#ifdef CONFIG_FB_MSM_MDDI
		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,
#ifdef CONFIG_SHLCDC_BOARD
                    GPIO_CFG_NO_PULL,
#else
					GPIO_CFG_PULL_DOWN,
#endif
					GPIO_CFG_2MA),
					GPIO_CFG_ENABLE);
			if (ret)
				goto err_handle;

			/*
			 * if use_mdp_vsync, then no interrupt need since
			 * mdp_vsync is feed directly to mdp to reset the
			 * write pointer counter. therefore no irq_handler
			 * need to reset write pointer counter.
			 */
			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;
				}
			}
		}
#endif
		#ifndef CONFIG_SHLCDC_BOARD
		mdp_hw_vsync_clk_enable(mfd);
		mdp_set_vsync((unsigned long)mfd);
		#endif /*CONFIG_SHLCDC_BOARD*/
	}

	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__);
}
示例#7
0
int dsi_panel_device_register(struct device_node *pan_node,
				struct mdss_dsi_ctrl_pdata *ctrl_pdata)
{
	struct mipi_panel_info *mipi;
	int rc, i, len;
	struct device_node *dsi_ctrl_np = NULL;
	struct platform_device *ctrl_pdev = NULL;
	bool dynamic_fps;
	const char *data;
	struct mdss_panel_info *pinfo = &(ctrl_pdata->panel_data.panel_info);

	mipi  = &(pinfo->mipi);

	pinfo->type =
		((mipi->mode == DSI_VIDEO_MODE)
			? MIPI_VIDEO_PANEL : MIPI_CMD_PANEL);

	rc = mdss_dsi_clk_div_config(pinfo, mipi->frame_rate);
	if (rc) {
		pr_err("%s: unable to initialize the clk dividers\n", __func__);
		return rc;
	}

	dsi_ctrl_np = of_parse_phandle(pan_node,
				"qcom,mdss-dsi-panel-controller", 0);
	if (!dsi_ctrl_np) {
		pr_err("%s: Dsi controller node not initialized\n", __func__);
		return -EPROBE_DEFER;
	}

	ctrl_pdev = of_find_device_by_node(dsi_ctrl_np);

	rc = mdss_dsi_regulator_init(ctrl_pdev);
	if (rc) {
		pr_err("%s: failed to init regulator, rc=%d\n",
						__func__, rc);
		return rc;
	}

	data = of_get_property(ctrl_pdev->dev.of_node,
		"qcom,platform-strength-ctrl", &len);
	if ((!data) || (len != 2)) {
		pr_err("%s:%d, Unable to read Phy Strength ctrl settings",
			__func__, __LINE__);
		return -EINVAL;
	}
	pinfo->mipi.dsi_phy_db.strength[0] = data[0];
	pinfo->mipi.dsi_phy_db.strength[1] = data[1];

	data = of_get_property(ctrl_pdev->dev.of_node,
		"qcom,platform-regulator-settings", &len);
	if ((!data) || (len != 7)) {
		pr_err("%s:%d, Unable to read Phy regulator settings",
			__func__, __LINE__);
		return -EINVAL;
	}
	for (i = 0; i < len; i++) {
		pinfo->mipi.dsi_phy_db.regulator[i]
			= data[i];
	}

	data = of_get_property(ctrl_pdev->dev.of_node,
		"qcom,platform-bist-ctrl", &len);
	if ((!data) || (len != 6)) {
		pr_err("%s:%d, Unable to read Phy Bist Ctrl settings",
			__func__, __LINE__);
		return -EINVAL;
	}
	for (i = 0; i < len; i++) {
		pinfo->mipi.dsi_phy_db.bistctrl[i]
			= data[i];
	}

	data = of_get_property(ctrl_pdev->dev.of_node,
		"qcom,platform-lane-config", &len);
	if ((!data) || (len != 45)) {
		pr_err("%s:%d, Unable to read Phy lane configure settings",
			__func__, __LINE__);
		return -EINVAL;
	}
	for (i = 0; i < len; i++) {
		pinfo->mipi.dsi_phy_db.lanecfg[i] =
			data[i];
	}

	ctrl_pdata->shared_pdata.broadcast_enable = of_property_read_bool(
		pan_node, "qcom,mdss-dsi-panel-broadcast-mode");

	dynamic_fps = of_property_read_bool(pan_node,
					  "qcom,mdss-dsi-pan-enable-dynamic-fps");
	if (dynamic_fps) {
		pinfo->dynamic_fps = true;
		data = of_get_property(pan_node,
					  "qcom,mdss-dsi-pan-fps-update", NULL);
		if (data) {
			if (!strcmp(data, "dfps_suspend_resume_mode")) {
				pinfo->dfps_update =
						DFPS_SUSPEND_RESUME_MODE;
				pr_debug("%s: dfps mode: suspend/resume\n",
								__func__);
			} else if (!strcmp(data,
					    "dfps_immediate_clk_mode")) {
				pinfo->dfps_update =
						DFPS_IMMEDIATE_CLK_UPDATE_MODE;
				pr_debug("%s: dfps mode: Immediate clk\n",
								__func__);
			} else if (!strcmp(data,
					    "dfps_immediate_porch_mode")) {
				pinfo->dfps_update =
					DFPS_IMMEDIATE_PORCH_UPDATE_MODE;
				pr_debug("%s: dfps mode: Immediate porch\n",
								__func__);
			} else {
				pr_debug("%s: dfps to default mode\n",
								__func__);
				pinfo->dfps_update =
						DFPS_SUSPEND_RESUME_MODE;
				pr_debug("%s: dfps mode: suspend/resume\n",
								__func__);
			}
		} else {
			pr_debug("%s: dfps update mode not configured\n",
								__func__);
				pinfo->dynamic_fps =
								false;
				pr_debug("%s: dynamic FPS disabled\n",
								__func__);
		}
		pinfo->new_fps = pinfo->mipi.frame_rate;
	}

	pinfo->panel_max_fps = mdss_panel_get_framerate(pinfo);
	pinfo->panel_max_vtotal = mdss_panel_get_vtotal(pinfo);
	ctrl_pdata->disp_en_gpio = of_get_named_gpio(ctrl_pdev->dev.of_node,
		"qcom,platform-enable-gpio", 0);

	if (!gpio_is_valid(ctrl_pdata->disp_en_gpio))
		pr_err("%s:%d, Disp_en gpio not specified\n",
						__func__, __LINE__);

	if (pinfo->type == MIPI_CMD_PANEL) {
		ctrl_pdata->disp_te_gpio = of_get_named_gpio(ctrl_pdev->dev.of_node,
						"qcom,platform-te-gpio", 0);
		if (!gpio_is_valid(ctrl_pdata->disp_te_gpio)) {
			pr_err("%s:%d, Disp_te gpio not specified\n",
						__func__, __LINE__);
		}
	}

	if (gpio_is_valid(ctrl_pdata->disp_te_gpio) &&
					pinfo->type == MIPI_CMD_PANEL) {
		rc = gpio_request(ctrl_pdata->disp_te_gpio, "disp_te");
		if (rc) {
			pr_err("request TE gpio failed, rc=%d\n",
			       rc);
			return -ENODEV;
		}
		rc = gpio_tlmm_config(GPIO_CFG(
				ctrl_pdata->disp_te_gpio, 1,
				GPIO_CFG_INPUT,
				GPIO_CFG_PULL_DOWN,
				GPIO_CFG_2MA),
				GPIO_CFG_ENABLE);

		if (rc) {
			pr_err("%s: unable to config tlmm = %d\n",
				__func__, ctrl_pdata->disp_te_gpio);
			gpio_free(ctrl_pdata->disp_te_gpio);
			return -ENODEV;
		}

		rc = gpio_direction_input(ctrl_pdata->disp_te_gpio);
		if (rc) {
			pr_err("set_direction for disp_en gpio failed, rc=%d\n",
			       rc);
			gpio_free(ctrl_pdata->disp_te_gpio);
			return -ENODEV;
		}
		pr_debug("%s: te_gpio=%d\n", __func__,
					ctrl_pdata->disp_te_gpio);
	}

	ctrl_pdata->rst_gpio = of_get_named_gpio(ctrl_pdev->dev.of_node,
			 "qcom,platform-reset-gpio", 0);
	if (!gpio_is_valid(ctrl_pdata->rst_gpio))
		pr_err("%s:%d, reset gpio not specified\n",
						__func__, __LINE__);

	if (pinfo->mode_gpio_state != MODE_GPIO_NOT_VALID) {

		ctrl_pdata->mode_gpio = of_get_named_gpio(
					ctrl_pdev->dev.of_node,
					"qcom,platform-mode-gpio", 0);
		if (!gpio_is_valid(ctrl_pdata->mode_gpio))
			pr_info("%s:%d, mode gpio not specified\n",
							__func__, __LINE__);
	} else {
		ctrl_pdata->mode_gpio = -EINVAL;
	}

	if (mdss_dsi_clk_init(ctrl_pdev, ctrl_pdata)) {
		pr_err("%s: unable to initialize Dsi ctrl clks\n", __func__);
		return -EPERM;
	}

	if (mdss_dsi_retrieve_ctrl_resources(ctrl_pdev,
					     pinfo->pdest,
					     ctrl_pdata)) {
		pr_err("%s: unable to get Dsi controller res\n", __func__);
		return -EPERM;
	}

	ctrl_pdata->panel_data.event_handler = mdss_dsi_event_handler;
	ctrl_pdata->check_status = mdss_dsi_bta_status_check;

	if (ctrl_pdata->bklt_ctrl == BL_PWM)
		mdss_dsi_panel_pwm_cfg(ctrl_pdata);

	mdss_dsi_ctrl_init(ctrl_pdata);
	/*
	 * register in mdp driver
	 */

	ctrl_pdata->pclk_rate = mipi->dsi_pclk_rate;
	ctrl_pdata->byte_clk_rate = pinfo->clk_rate / 8;
	pr_debug("%s: pclk=%d, bclk=%d\n", __func__,
			ctrl_pdata->pclk_rate, ctrl_pdata->byte_clk_rate);

	ctrl_pdata->ctrl_state = CTRL_STATE_UNKNOWN;

	if (pinfo->cont_splash_enabled) {
		pinfo->panel_power_on = 1;
		rc = mdss_dsi_panel_power_on(&(ctrl_pdata->panel_data), 1);
		if (rc) {
			pr_err("%s: Panel power on failed\n", __func__);
			return rc;
		}

		mdss_dsi_clk_ctrl(ctrl_pdata, DSI_ALL_CLKS, 1);
		ctrl_pdata->ctrl_state |=
			(CTRL_STATE_PANEL_INIT | CTRL_STATE_MDP_ACTIVE);
	} else {
		pinfo->panel_power_on = 0;
	}

	rc = mdss_register_panel(ctrl_pdev, &(ctrl_pdata->panel_data));
	if (rc) {
		pr_err("%s: unable to register MIPI DSI panel\n", __func__);
		return rc;
	}

	if (pinfo->pdest == DISPLAY_1) {
		mdss_debug_register_base("dsi0",
			ctrl_pdata->ctrl_base, ctrl_pdata->reg_size);
		ctrl_pdata->ndx = 0;
	} else {
		mdss_debug_register_base("dsi1",
			ctrl_pdata->ctrl_base, ctrl_pdata->reg_size);
		ctrl_pdata->ndx = 1;
	}

	pr_debug("%s: Panel data initialized\n", __func__);
	return 0;
}
示例#8
0
static int __devinit hs_probe(struct platform_device *pdev)
{
	int rc = 0;
	struct input_dev *ipdev;
	printk(" hs_probe start. \n"); //ps2 p13106
	hs = kzalloc(sizeof(struct msm_handset), GFP_KERNEL);
	if (!hs)
		return -ENOMEM;

	hs->sdev.name	= "h2w";
	hs->sdev.print_name = msm_headset_print_name;

	rc = switch_dev_register(&hs->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, hs);

	hs->ipdev = ipdev;

	if (pdev->dev.platform_data)
		hs->hs_pdata = pdev->dev.platform_data;

	if (hs->hs_pdata->hs_name)
		ipdev->name = hs->hs_pdata->hs_name;
	else
		ipdev->name	= DRIVER_NAME;
////////////////////////////////////////////////////////////////////////////////////

#if defined(T_LASER2)
	printk(" CONFIG_MACH_MSM8X55_LASER2 hs_probe start. \n"); //ps2 p13106
	
	hs->type=EARJACK_STATE_OFF;
	hs->hs_on=hs->mic_on=0;
	hs->remotekey_pressed = 0;
	hs->remotekey_first = 0;
  hs->remotekey_count=0;
  #if (BOARD_VER > WS20 )
  // Initialize Voltage Mic bias
  vreg_Earjack_GP6 = vreg_get(NULL, "gp6");
	rc = vreg_set_level(vreg_Earjack_GP6, 2700);
	if (rc) {
		printk(KERN_ERR "%s: vreg_Earjack_GP6 set level failed (%d)\n", __func__, rc);
		return -1;
	}

	rc = vreg_disable(vreg_Earjack_GP6);
	if (rc) {
		printk(KERN_ERR "%s: #include <mach/vreg.h> enable failed (%d)\n", __func__, rc);
		return -1;
	}	
  #endif //(BOARD_VER > WS20 )

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

	// 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");

	// Get 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_PULL_DOWN, 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", hs);

	gpio_tlmm_config(GPIO_CFG(REMOTEKEY_DET, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	rc = request_irq(gpio_to_irq(REMOTEKEY_DET), Remotekey_Det_handler, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remotekey-irq", hs);

	// Init Mutex
	set_irq_wake(gpio_to_irq(EARJACK_DET), 1);
	set_irq_wake(gpio_to_irq(REMOTEKEY_DET), 1);

  // check earjack is inserted
	wake_lock(&earjack_wake_lock);
	schedule_delayed_work(&earjack_work, 10);    // after 100ms start function of earjack_detect_func
	
	
#endif // defined(T_LASER2)


	ipdev->id.vendor	= 0x0001;
	ipdev->id.product	= 1;
	ipdev->id.version	= 1;

	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_SW, SW_HEADPHONE_INSERT);
	input_set_capability(ipdev, EV_SW, SW_MICROPHONE_INSERT);
	input_set_capability(ipdev, EV_KEY, KEY_POWER);
	input_set_capability(ipdev, EV_KEY, KEY_END);

	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, hs);

	rc = hs_rpc_init();
	if (rc) {
		dev_err(&ipdev->dev, "rpc init failure\n");
		goto err_hs_rpc_init;
	}

	return 0;

err_hs_rpc_init:
	input_unregister_device(ipdev);
	ipdev = NULL;
err_reg_input_dev:
	input_free_device(ipdev);
err_alloc_input_dev:
	switch_dev_unregister(&hs->sdev);
err_switch_dev_register:
	kfree(hs);
	return rc;
}
示例#9
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;
		}
	}

#ifdef 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;
}
//#include <linux/module.h>
int msm_proc_comm(unsigned cmd, unsigned *data1, unsigned *data2);

extern int msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat);

/* ---- SDCARD ---- */
/* ---- WIFI ---- */

static uint32_t wifi_on_gpio_table[] = {
	//GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* DAT3 */
	//GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* DAT2 */
	//GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* DAT1 */
	//GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* DAT0 */
	//GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), /* CMD */
	//GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), /* CLK */
	GPIO_CFG(RIDER_GPIO_WIFI_IRQ, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* WLAN IRQ */
};

static uint32_t wifi_off_gpio_table[] = {
	//GPIO_CFG(116, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* DAT3 */
	//GPIO_CFG(117, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* DAT2 */
	//GPIO_CFG(118, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* DAT1 */
	//GPIO_CFG(119, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* DAT0 */
	//GPIO_CFG(111, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_4MA), /* CMD */
	//GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), /* CLK */
	GPIO_CFG(RIDER_GPIO_WIFI_IRQ, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* WLAN IRQ */
};

static void config_gpio_table(uint32_t *table, int len)
{
		int n, rc;
示例#11
0
#elif (defined  CONFIG_PROJECT_P825A31) || (defined  CONFIG_PROJECT_P825T20)
#define GPIO_RED_LIGHT_CTRL        49
#define GPIO_GREEN_LIGHT_CTRL    34
#else
#define GPIO_RED_LIGHT_CTRL        10
#define GPIO_GREEN_LIGHT_CTRL    11
#endif

#elif defined(CONFIG_USE_PM_GPIO_CTRL_LED)
#define GPIO_RED_LIGHT_CTRL        PMIC_GPIO_5
#define GPIO_GREEN_LIGHT_CTRL    PMIC_GPIO_6
#endif

#ifdef CONFIG_GPIO_10_11_CTRL_LED
static unsigned data_leds_gpio[] = {
	GPIO_CFG(GPIO_RED_LIGHT_CTRL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),	/* red */
	GPIO_CFG(GPIO_GREEN_LIGHT_CTRL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),	/* green */
};
#endif

struct BLINK_LED_data{
         int blink_flag;
	int blink_led_flag;  // 0: off, 1:0n
	int blink_on_time;  //ms
	int blink_off_time;  //ms
	struct timer_list timer;
         struct work_struct work_led_on;
         struct work_struct work_led_off;
	struct led_classdev led;
};
static int lge_hsd_probe(struct platform_device *pdev)
{
    int ret;
    struct gpio_switch_platform_data *pdata = pdev->dev.platform_data;

    HSD_DBG("%s\n", pdata->name);

    if (!pdata) {
        HSD_ERR("The platform data is null\n");
        return -EBUSY;
    }

    hi = kzalloc(sizeof(struct hsd_info), GFP_KERNEL);
    if (!hi) {
        HSD_ERR("Failed to allloate headset per device info\n");
        return -ENOMEM;
    }

    hi->gpio = pdata->gpio;
    mutex_init(&hi->mutex_lock);
    hi->sdev.name = pdata->name;
    hi->sdev.print_state = lge_hsd_print_state;
    hi->sdev.print_name = lge_hsd_print_name;

    ret = switch_dev_register(&hi->sdev);
    if (ret < 0) {
        HSD_ERR("Failed to register switch device\n");
        goto err_switch_dev_register;
    }

    hs_detect_work_queue = create_workqueue("hs_detect");
    if (hs_detect_work_queue == NULL) {
        HSD_ERR("Failed to create workqueue\n");
        goto err_create_work_queue;
    }

    ret = gpio_request(hi->gpio, pdev->name);
    if (ret < 0) {
        HSD_ERR("Failed to request gpio%d\n", hi->gpio);
        goto err_request_detect_gpio;
    }

    ret = gpio_direction_input(hi->gpio);
    if (ret < 0) {
        HSD_ERR("Failed to set gpio%d as input\n", hi->gpio);
        goto err_set_detect_gpio;
    }

    if (hi->gpio == LGE_HEADSET_DETECT_GPIO) {
        ret = gpio_tlmm_config(GPIO_CFG(hi->gpio, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
                                        GPIO_CFG_2MA), GPIO_CFG_ENABLE);
        if (ret < 0) {
            HSD_ERR("Failed to configure gpio%d tlmm\n", hi->gpio);
            goto err_set_detect_gpio;
        }
    }

    hi->irq = gpio_to_irq(pdata->gpio);
    if (hi->irq < 0) {
        HSD_ERR("Failed to get interrupt number\n");
        ret = hi->irq;
        goto err_get_irq_num_failed;
    }

    ret = request_irq(hi->irq, gpio_irq_handler,
                      IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING, pdev->name, NULL);

    if (ret < 0) {
        HSD_ERR("Failed to request interrupt handler\n");
        goto err_request_detect_irq;
    }

    ret = irq_set_irq_wake(hi->irq, 1);
    if (ret < 0) {
        HSD_ERR("Failed to set interrupt wake\n");
        goto err_request_input_dev;
    }

    hi->input = input_allocate_device();
    if (!hi->input) {
        HSD_ERR("Failed to allocate input device\n");
        ret = -ENOMEM;
        goto err_request_input_dev;
    }

    if (pdev->dev.platform_data)
        hi->input->name = "7k_headset";
    else
        hi->input->name = "hsd_headset";

    hi->input->id.vendor	= 0x0001;
    hi->input->id.product	= 1;
    hi->input->id.version	= 1;

    input_set_capability(hi->input, EV_SW, SW_HEADPHONE_INSERT);

    ret = input_register_device(hi->input);
    if (ret) {
        HSD_ERR("Failed to register input device\n");
        goto err_register_input_dev;
    }

    /* Perform initial detection */
    return 0;

err_register_input_dev:
    input_free_device(hi->input);
err_request_input_dev:
    free_irq(hi->irq, 0);
err_request_detect_irq:
err_get_irq_num_failed:
err_set_detect_gpio:
    gpio_free(hi->gpio);
err_request_detect_gpio:
    destroy_workqueue(hs_detect_work_queue);
err_create_work_queue:
    switch_dev_unregister(&hi->sdev);
err_switch_dev_register:
    HSD_ERR("Failed to register driver\n");

    return ret;
}
static void hallic_init_gpio(void) {
	gpio_request(s5712ACDL1_pdata.irq_pin,"hallic_irq");
	gpio_tlmm_config(GPIO_CFG(s5712ACDL1_pdata.irq_pin,
		0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
}
void mdp_config_vsync(struct platform_device *pdev,
	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;
	}

	vsync_clk_status = 0;
	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.tv64 = 0;

#ifdef MDP_HW_VSYNC
		if (mdp_vsync_clk == NULL)
			mdp_vsync_clk = clk_get(&pdev->dev, "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_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_vsync_cfg_regs(mfd, TRUE);
			}
		}
#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

#ifdef CONFIG_FB_MSM_MDDI
		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 use_mdp_vsync, then no interrupt need since
			 * mdp_vsync is feed directly to mdp to reset the
			 * write pointer counter. therefore no irq_handler
			 * need to reset write pointer counter.
			 */
			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;
				}
			}
		}
#endif
		mdp_hw_vsync_clk_enable(mfd);
		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__);
}
示例#15
0
static int icp_hd_power(int on)
{
	int rc = 0;
	//int status=0;
		//CAM_INFO("%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) {
			//CAM_INFO("%s %s:%d\n", __FILE__, __func__, __LINE__);
			gpio_set_value(SENSOR_STANDBY_8M,0);					
		}
		
		rc = regulator_enable(s2b_1p2v_8m);
		if (rc) {
			//CAM_ERR("%s: Enable regulator s2b_1p2v failed\n", __func__);
			goto fail;
		}
		msleep(1);
		
		rc = regulator_enable(mvs0b_1p8v_8m);
		if (rc) {
			//CAM_ERR("%s: Enable regulator mvs0b_1p8v failed\n", __func__);
			goto fail;
		}
		msleep(1);
		
		rc = regulator_enable(lvs3b_1p8v);
		if (rc) {
			//CAM_ERR("%s: Enable regulator lvs3b_1p8v failed\n", __func__);
			goto fail;
		}		
		msleep(1);
		
		rc = regulator_enable(l2b_2p8v_8m);
		if (rc) {
			//CAM_ERR("%s: Enable regulator l2b_2p8v failed\n", __func__);
			goto fail;
		}
		msleep(1);
		
		rc = regulator_enable(l3b_2p8v_8m);
		if (rc) {
			//CAM_ERR("%s: Enable regulator l3b_2p8v failed\n", __func__);
			goto fail;
		}

		//CAM_INFO("%s %s ON Success:%d\n", __FILE__, __func__, __LINE__);
	}
	else {
		//CAM_INFO("%s %s:%d power \n", __FILE__, __func__, __LINE__);
		//CAM_INFO("%s %s:%d power \n", __FILE__, __func__, __LINE__);
		if(1)//mvs0b_1p8v) 
		{
			rc = regulator_disable(mvs0b_1p8v_8m);
			if (rc){
				//CAM_ERR("%s: Disable regulator mvs0b_1p8v failed\n", __func__);
				goto fail;
			}
		}
		//CAM_INFO("%s %s:%d power \n", __FILE__, __func__, __LINE__);
		if(1)//l2b_2p8v) 
		{
			rc = regulator_disable(l2b_2p8v_8m);
			if (rc){
				//CAM_ERR("%s: Disable regulator l2b_2p8v failed\n", __func__);
				goto fail;
			}
			regulator_put(l2b_2p8v_8m);
		}
		//CAM_INFO("%s %s:%d power \n", __FILE__, __func__, __LINE__);
		if(1)//l3b_2p8v) 
		{
		rc = regulator_disable(l3b_2p8v_8m);
			if (rc){
				//CAM_ERR("%s: Disable regulator l3b_2p8v failed\n", __func__);
				goto fail;
			}
			regulator_put(l3b_2p8v_8m);		
		}
		//CAM_INFO("%s %s OFF Success:%d\n", __FILE__, __func__, __LINE__);
	}
	
	return rc;
fail:
	CAM_ERR("%s %s Failed!:%d\n", __FILE__, __func__, __LINE__);
	if(l2b_2p8v_8m){
		regulator_put(l2b_2p8v_8m);
	}
	if(s2b_1p2v_8m){
		regulator_put(s2b_1p2v_8m);
	}
	if(l3b_2p8v_8m){
		regulator_put(l3b_2p8v_8m);
	}
	return rc;			
}
示例#16
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;
}
示例#17
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_OUTP(MDP_BASE + 0x300,
					 ((mfd->total_lcd_lines -
					   1) << MDP_SYNCFG_HGT_LOC) | (mfd->
									panel_info.
									lcd.
									hw_vsync_mode
									?
									MDP_SYNCFG_VSYNC_EXT_EN
									: 0) |
					 MDP_SYNCFG_VSYNC_INT_EN |
					 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 + 0x328, vsync_load_cnt);

				// external vsync source pulse width and polarity flip
				MDP_OUTP(MDP_BASE + 0x318, 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_INPUT,
					GPIO_PULL_DOWN,
					GPIO_2MA),
					GPIO_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__);
}
static unsigned int msm_AR600X_setup_power(bool on)
{
	int rc = 0;
	static bool init_done;

	if (wlan_powered_up) {
		pr_info("WLAN already powered up\n");
		return 0;
	}

	if (unlikely(!init_done)) {
		gpio_wlan_config();
		rc = qrf6285_init_regs();
		if (rc) {
			pr_err("%s: qrf6285 init failed = %d\n", __func__, rc);
			return rc;
		} else {
			init_done = true;
		}
	}

	rc = wlan_switch_regulators(on);
	if (rc) {
		pr_err("%s: wlan_switch_regulators error = %d\n", __func__, rc);
		goto out;
	}

	/* GPIO_WLAN_3V3_EN is only required for the QRD7627a */
	if (machine_is_msm7627a_qrd1()) {
		rc = gpio_tlmm_config(GPIO_CFG(GPIO_WLAN_3V3_EN, 0,
					GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
					GPIO_CFG_2MA), GPIO_CFG_ENABLE);
		if (rc) {
			pr_err("%s gpio_tlmm_config 119 failed,error = %d\n",
				__func__, rc);
			goto reg_disable;
		}
		gpio_set_value(GPIO_WLAN_3V3_EN, 1);
	}

	/*
	 * gpio_wlan_sys_rest_en is not from the GPIO expander for QRD7627a,
	 * EVB1.0 and QRD8625,so the below step is required for those devices.
	 */
	if (machine_is_msm7627a_qrd1() || machine_is_msm7627a_evb()
					|| machine_is_msm8625_evb()
					|| machine_is_msm8625_evt()
					|| machine_is_msm7627a_qrd3()
					|| machine_is_msm8625_qrd7()) {
		rc = gpio_tlmm_config(GPIO_CFG(gpio_wlan_sys_rest_en, 0,
					GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
					GPIO_CFG_2MA), GPIO_CFG_ENABLE);
		if (rc) {
			pr_err("%s gpio_tlmm_config 119 failed,error = %d\n",
				__func__, rc);
			goto qrd_gpio_fail;
		}
		gpio_set_value(gpio_wlan_sys_rest_en, 1);
	} else {
		rc = gpio_request(gpio_wlan_sys_rest_en, "WLAN_DEEP_SLEEP_N");
		if (rc) {
			pr_err("%s: WLAN sys_rest_en GPIO %d request failed %d\n",
				__func__,
				gpio_wlan_sys_rest_en, rc);
			goto qrd_gpio_fail;
		}
		rc = setup_wlan_gpio(on);
		if (rc) {
			pr_err("%s: wlan_set_gpio = %d\n", __func__, rc);
			goto gpio_fail;
		}
	}

	/* Enable the A0 clock */
	rc = setup_wlan_clock(on);
	if (rc) {
		pr_err("%s: setup_wlan_clock = %d\n", __func__, rc);
		goto set_gpio_fail;
	}

	/* Configure A0 clock to be slave to WLAN_CLK_PWR_REQ */
	rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0,
				 PMAPP_CLOCK_VOTE_PIN_CTRL);
	if (rc) {
		pr_err("%s: Configuring A0 to Pin controllable failed %d\n",
				__func__, rc);
		goto set_clock_fail;
	}

	pr_info("WLAN power-up success\n");
	wlan_powered_up = true;
	return 0;
set_clock_fail:
	setup_wlan_clock(0);
set_gpio_fail:
	setup_wlan_gpio(0);
gpio_fail:
	if (!(machine_is_msm7627a_qrd1() || machine_is_msm7627a_evb() ||
	    machine_is_msm8625_evb() || machine_is_msm8625_evt() ||
	    machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()))
	gpio_free(gpio_wlan_sys_rest_en);
qrd_gpio_fail:
	/* GPIO_WLAN_3V3_EN is only required for the QRD7627a */
	if (machine_is_msm7627a_qrd1())
		gpio_free(GPIO_WLAN_3V3_EN);
reg_disable:
	wlan_switch_regulators(0);
out:
	pr_info("WLAN power-up failed\n");
	wlan_powered_up = false;
	return rc;
}
	{
		.gpio = PWR_KEY_MSMz,
		.code = KEY_POWER,
	},
	{
		.gpio = VOL_DOWNz_XA_XB,
		.code = KEY_VOLUMEDOWN,
	},
	{
		.gpio = VOL_UPz_XA_XB,
		.code = KEY_VOLUMEUP,
	},
};

static uint32_t matirx_inputs_gpio_table_xc[] = {
	GPIO_CFG(PWR_KEY_MSMz, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
		 GPIO_CFG_2MA),
	GPIO_CFG(VOL_DOWNz_XC, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
		 GPIO_CFG_2MA),
	GPIO_CFG(VOL_UPz_XC, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
		 GPIO_CFG_2MA),
};

static uint32_t matirx_inputs_gpio_table[] = {
	GPIO_CFG(PWR_KEY_MSMz, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
		 GPIO_CFG_2MA),
	GPIO_CFG(VOL_DOWNz_XA_XB, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
		 GPIO_CFG_2MA),
	GPIO_CFG(VOL_UPz_XA_XB, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
		 GPIO_CFG_2MA),
};
static unsigned int msm_AR600X_shutdown_power(bool on)
{
	int rc = 0;

	if (!wlan_powered_up) {
		pr_info("WLAN is not powered up, returning success\n");
		return 0;
	}

	/* Disable the A0 clock */
	rc = setup_wlan_clock(on);
	if (rc) {
		pr_err("%s: setup_wlan_clock = %d\n", __func__, rc);
		goto set_clock_fail;
	}

	/*
	 * gpio_wlan_sys_rest_en is not from the GPIO expander for QRD7627a,
	 * EVB1.0 and QRD8625,so the below step is required for those devices.
	 */
	if (machine_is_msm7627a_qrd1() || machine_is_msm7627a_evb()
					|| machine_is_msm8625_evb()
					|| machine_is_msm8625_evt()
					|| machine_is_msm7627a_qrd3()
					|| machine_is_msm8625_qrd7()) {
		rc = gpio_tlmm_config(GPIO_CFG(gpio_wlan_sys_rest_en, 0,
					GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
					GPIO_CFG_2MA), GPIO_CFG_ENABLE);
		if (rc) {
			pr_err("%s gpio_tlmm_config 119 failed,error = %d\n",
				__func__, rc);
			goto gpio_fail;
		}
		gpio_set_value(gpio_wlan_sys_rest_en, 0);
	} else {
		rc = setup_wlan_gpio(on);
		if (rc) {
			pr_err("%s: setup_wlan_gpio = %d\n", __func__, rc);
			goto set_gpio_fail;
		}
		gpio_free(gpio_wlan_sys_rest_en);
	}

	/* GPIO_WLAN_3V3_EN is only required for the QRD7627a */
	if (machine_is_msm7627a_qrd1()) {
		rc = gpio_tlmm_config(GPIO_CFG(GPIO_WLAN_3V3_EN, 0,
					GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
					GPIO_CFG_2MA), GPIO_CFG_ENABLE);
		if (rc) {
			pr_err("%s gpio_tlmm_config 119 failed,error = %d\n",
				__func__, rc);
			goto qrd_gpio_fail;
		}
		gpio_set_value(GPIO_WLAN_3V3_EN, 0);
	}

	rc = wlan_switch_regulators(on);
	if (rc) {
		pr_err("%s: wlan_switch_regulators error = %d\n",
			__func__, rc);
		goto reg_disable;
	}
	wlan_powered_up = false;
	pr_info("WLAN power-down success\n");
	return 0;
set_clock_fail:
	setup_wlan_clock(0);
set_gpio_fail:
	setup_wlan_gpio(0);
gpio_fail:
	if (!(machine_is_msm7627a_qrd1() || machine_is_msm7627a_evb() ||
	    machine_is_msm8625_evb() || machine_is_msm8625_evt() ||
	    machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()))
	gpio_free(gpio_wlan_sys_rest_en);
qrd_gpio_fail:
	/* GPIO_WLAN_3V3_EN is only required for the QRD7627a */
	if (machine_is_msm7627a_qrd1())
		gpio_free(GPIO_WLAN_3V3_EN);
reg_disable:
	wlan_switch_regulators(0);
	pr_info("WLAN power-down failed\n");
	return rc;
}
static int mipi_dsi_panel_power(int on)
{
	static struct regulator *reg_lvs5, *reg_l2;
	static int gpio36, gpio37;
	int rc;

	pr_debug("%s: on=%d\n", __func__, on);

	if (!dsi_power_on) {
		reg_lvs5 = regulator_get(&msm_mipi_dsi1_device.dev,
				"dsi1_vddio");
		if (IS_ERR_OR_NULL(reg_lvs5)) {
			pr_err("could not get 8921_lvs5, rc = %ld\n",
				PTR_ERR(reg_lvs5));
			return -ENODEV;
		}

		reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
				"dsi1_pll_vdda");
		if (IS_ERR_OR_NULL(reg_l2)) {
			pr_err("could not get 8921_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;
		}

		gpio36 = PM8921_GPIO_PM_TO_SYS(V_LCM_N5V_EN); 
		rc = gpio_request(gpio36, "lcd_5v-");
		if (rc) {
			pr_err("request lcd_5v- failed, rc=%d\n", rc);
			return -ENODEV;
		}
		gpio37 = PM8921_GPIO_PM_TO_SYS(V_LCM_P5V_EN); 
		rc = gpio_request(gpio37, "lcd_5v+");
		if (rc) {
			pr_err("request lcd_5v+ failed, rc=%d\n", rc);
			return -ENODEV;
		}
		gpio_tlmm_config(GPIO_CFG(LCD_RST, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

		dsi_power_on = true;
	}

	if (on) {
		if (!first_init) {
			rc = regulator_enable(reg_lvs5);
			if (rc) {
				pr_err("enable lvs5 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			msleep(200);

			gpio_set_value_cansleep(gpio37, 1);
			msleep(10);
			gpio_set_value_cansleep(gpio36, 1);

			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;
			}
			
			msm_xo_mode_vote(wa_xo, MSM_XO_MODE_ON);

			gpio_set_value(LCD_RST, 0);
			msleep(10);
			gpio_set_value(LCD_RST, 1);
			
			msm_xo_mode_vote(wa_xo, MSM_XO_MODE_OFF);
		} else {
			
			rc = regulator_enable(reg_lvs5);
			if (rc) {
				pr_err("enable lvs5 failed, rc=%d\n", rc);
				return -ENODEV;
			}
			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;
			}
			
			msm_xo_mode_vote(wa_xo, MSM_XO_MODE_ON);
			msleep(10);
			msm_xo_mode_vote(wa_xo, MSM_XO_MODE_OFF);
		}
	} else {
		if (system_rev == XB) {
			gpio_tlmm_config(GPIO_CFG(MBAT_IN_XA_XB, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
			gpio_set_value(MBAT_IN_XA_XB, 0);
		} else if (system_rev >= XC) {
			gpio_tlmm_config(GPIO_CFG(BL_HW_EN_XC_XD, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
			gpio_set_value(BL_HW_EN_XC_XD, 0);
		}

		gpio_set_value(LCD_RST, 0);
		msleep(10);
		rc = regulator_disable(reg_l2);
		if (rc) {
			pr_err("disable reg_l2 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		gpio_set_value_cansleep(gpio36, 0);
		msleep(10);
		gpio_set_value_cansleep(gpio37, 0);
		msleep(100);
		rc = regulator_disable(reg_lvs5);
		if (rc) {
			pr_err("disable reg_lvs5 failed, rc=%d\n", rc);
			return -ENODEV;
		}
	}

	return 0;
}
static int mipi_dsi_panel_power(int on)
{
	int rc = 0;

/* LGE_CHANGE_S [email protected] 2013-01-15 booting animation sometimes no display*/
	if(on == 0){
    		if(firstbootend == 0){
             		firstbootend = 1;

			return 0;
         	}
       }
/* LGE_CHANGE_E [email protected] 2013-01-15 booting animation sometimes no display*/

	if (unlikely(!dsi_gpio_initialized)) 
	{
		/* Resetting LCD Panel*/
		rc = gpio_request(GPIO_LCD_RESET, "lcd_reset");
		if (rc) {
			pr_err("%s: gpio_request GPIO_LCD_RESET failed\n", __func__);
		}
		rc = gpio_tlmm_config(GPIO_CFG(GPIO_LCD_RESET, 0, GPIO_CFG_OUTPUT,
							  GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
		if (rc) {
			printk(KERN_ERR "%s: Failed to configure GPIO %d\n",
					__func__, rc);
		}
		dsi_gpio_initialized = 1;
	}

	if (on) {
		rc = regulator_enable(regulator_mipi_dsi[0]);
		if (rc) {
			pr_err("%s: vreg_enable failed for mipi_dsi_v18\n", __func__);
			goto vreg_put_dsi_v18;
		}
			
		msleep(3); //LGE_CHANGE_S [changbum.lee] 20120130 : add delay
		rc = regulator_enable(regulator_mipi_dsi[1]);
		if (rc) {
			pr_err("%s: vreg_enable failed for mipi_dsi_v28\n", __func__);
			goto vreg_put_dsi_v28;
		}
		rc = gpio_direction_output(GPIO_LCD_RESET, 1);
		if (rc) {
			pr_err("%s: gpio_direction_output failed for lcd_reset\n", __func__);
			goto vreg_put_dsi_v28;
		}
			
		if (firstbootend) 
		{
			gpio_set_value(GPIO_LCD_RESET, 0); //sohyun.nam, 12-11-23, arrange nReset pin
			msleep(8); //sohyun.nam, 12-11-23, arrange nReset pin
				
			rc = regulator_disable(regulator_mipi_dsi[1]);//2.8v
			msleep(15); //sohyun.nam, 12-11-23, arrange nReset pin
			if (rc) {
				pr_err("%s: vreg_disable failed for mipi_dsi_v28\n", __func__);
				goto vreg_put_dsi_v28;
			}			
		
			rc = regulator_enable(regulator_mipi_dsi[1]);//2.8v 
			msleep(15); //sohyun.nam, 12-11-23, arrange nReset pin

			gpio_set_value(GPIO_LCD_RESET, 1); //sohyun.nam
  			msleep(8);
		
			if (rc) {
				pr_err("%s: vreg_enable failed for mipi_dsi_v28\n", __func__);
				goto vreg_put_dsi_v28;
			}		
		} 
		else {
			firstbootend=1; 
		}
	}
	else//off 
	{
		rc = regulator_disable(regulator_mipi_dsi[0]);
		if (rc) {
			pr_err("%s: vreg_disable failed for mipi_dsi_v18\n", __func__);
			goto vreg_put_dsi_v18;
		}

		rc = regulator_disable(regulator_mipi_dsi[1]);
		if (rc) {
			pr_err("%s: vreg_disable failed for mipi_dsi_v28\n", __func__);
			goto vreg_put_dsi_v28;
		}
	}
	
	return 0;
	
vreg_put_dsi_v28:
	regulator_put(regulator_mipi_dsi[1]);

vreg_put_dsi_v18:
	regulator_put(regulator_mipi_dsi[0]);

	return rc;
}
#endif
#elif defined(CONFIG_MACH_CHAGALL_KDI)
#define GPIO_WL_HOST_WAKE 18
#else
#define GPIO_WL_HOST_WAKE 54
#endif

#if defined(CONFIG_SEC_KS01_PROJECT) || defined(CONFIG_SEC_JACTIVE_PROJECT)
extern int ice_gpiox_get(int num);
extern int ice_gpiox_set(int num, int val);
#endif

#if !defined(CONFIG_SEC_K_PROJECT) && !defined(CONFIG_SEC_KS01_PROJECT) && !defined(CONFIG_SEC_KACTIVE_PROJECT) &&\
    !defined(CONFIG_SEC_JACTIVE_PROJECT) && !defined(CONFIG_SEC_PATEK_PROJECT)
static unsigned config_gpio_wl_reg_on[] = {
	GPIO_CFG(GPIO_WL_REG_ON, 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA) };
#endif /* not defined (CONFIG_SEC_K_PROJECT && CONFIG_SEC_KS01_PROJECT) && CONFIG_SEC_KACTIVE_PROJECT*/

static int brcm_wifi_cd; /* WIFI virtual 'card detect' status */
static void (*wifi_status_cb)(int card_present, void *dev_id);
static void *wifi_status_cb_devid;
static void *wifi_mmc_host;
extern void sdio_ctrl_power(struct mmc_host *card, bool onoff);

static unsigned get_gpio_wl_host_wake(void)
{
	unsigned gpio_wl_host_wake;

	gpio_wl_host_wake = GPIO_WL_HOST_WAKE;

	return gpio_wl_host_wake;
static int __devinit hs_probe(struct platform_device *pdev)
{
    int rc = 0,err;
    struct input_dev *ipdev;
	struct pm8xxx_mpp_config_data sky_handset_digital_adc = {
		.type	= PM8XXX_MPP_TYPE_D_INPUT,
		.level	= PM8058_MPP_DIG_LEVEL_S3,
		.control = PM8XXX_MPP_DIN_TO_INT,
	};

    hs_dbg("hs_probe start!!!\n");
	headset_init=0;
    //sky_hs_3p5pi_jack_ctrl.state=SKY_HS_JACK_STATE_INIT;
    hs = kzalloc(sizeof(struct msm_headset), GFP_KERNEL);
    if (!hs)
        return -ENOMEM;

    hspd = kzalloc(sizeof(struct msm_headset_platform_data), GFP_KERNEL);
    if (!hspd)
        return -ENOMEM;

#if 0	
    hs->sdev.name   = "h2w";
#else
    hs->sdev.name   = "hw2";
#endif
    hs->sdev.print_name = msm_headset_print_name;

    rc = switch_dev_register(&hs->sdev);
    if (rc)
        goto err_switch_dev_register;

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

    hs->ipdev = ipdev;

    if (pdev->dev.platform_data) {
        hs->hs_pdata = pdev->dev.platform_data;
	  hspd = pdev->dev.platform_data;
    }

    if (hs->hs_pdata->hs_name)
        ipdev->name = hs->hs_pdata->hs_name;
    else
        ipdev->name = DRIVER_NAME;

	mutex_init(&headset_adc_lock);

    INIT_DELAYED_WORK(&earjack_work,earjack_det_func);
    INIT_DELAYED_WORK(&remotekey_work,remotekey_det_func);

    wake_lock_init(&headset_wakelock, WAKE_LOCK_SUSPEND, "Headset_wakelock");
    
    ipdev->id.vendor    = 0x0001;
    ipdev->id.product   = 1;
    ipdev->id.version   = 1;

    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_END);
    input_set_capability(ipdev, EV_SW, SW_HEADPHONE_INSERT);
    //input_set_capability(ipdev, EV_KEY, KEY_POWER);    
    //input_set_capability(ipdev, EV_KEY, KEY_SEND);
 
    rc = input_register_device(ipdev);
    if (rc) {
        dev_err(&ipdev->dev,
                "hs_probe: input_register_device rc=%d\n", rc);
        goto err_reg_wakelock;
    }

	/* Enable runtime PM ops, start in ACTIVE mode */
	//rc = pm_runtime_set_active(&pdev->dev);
	//if (rc < 0)
	//	dev_dbg(&pdev->dev, "unable to set runtime pm state\n");
	//pm_runtime_enable(&pdev->dev);


    platform_set_drvdata(pdev, hs);

    device_init_wakeup(&pdev->dev,1);

    hs_jack_l8 = regulator_get(NULL, "8058_l8");
    if(IS_ERR(hs_jack_l8)) {
      printk("regulator l8 get error\n");
      goto err_reg_input_dev;
    }

	// Added sysfs. (/sys/devices/platform/msm-handset/headset)
    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_reg_input_dev;
    }


    err = gpio_request(hspd->ear_det, "headset_det");
    if(err) {
		printk("unable to request gpio headset_det err=%d\n",err); 
		goto err_reg_input_dev;
    }

    err=gpio_direction_input(hspd->ear_det);
    if(err) {
		printk("Unable to set direction headset_det err=%d\n",err); 
		goto err_reg_input_dev;
    }
#if AT1_BDVER_GE(AT1_WS22) 
    gpio_tlmm_config(GPIO_CFG(hspd->ear_det, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
#else
	gpio_tlmm_config(GPIO_CFG(hspd->ear_det, 0, GPIO_CFG_INPUT,GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
#endif
    //gpio_set_debounce(hspd->ear_det,5);

    //set_irq_wake(gpio_to_irq(hspd->ear_det),1);

    err=request_irq(gpio_to_irq(hspd->ear_det), Earjack_Det_handler, 
		IRQF_DISABLED|IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "earjack_det-irq", hs);
	if (err  < 0) {
		printk("Couldn't acquire ear_det as request_irq()");
		goto err_reg_input_dev;
	}

	irq_set_irq_wake(gpio_to_irq(hspd->ear_det),1);

    err = gpio_request(hspd->remote_det, "remote_det");
    if(err) {
		printk("unable to request gpio remote_det err=%d\n",err); 
		goto err_reg_input_dev;
    }

#if AT1_BDVER_GE(AT1_WS22) 

	err = pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(XOADC_MPP_3), &sky_handset_digital_adc);
	if (err < 0)
		printk("%s: pm8058_mpp_config_DIG ret=%d\n",__func__, err);

/*
	err = pm8058_mpp_config_digital_in(PM8058_MPP_SYS_TO_PM(hspd->remote_det),
					PM8058_MPP_DIG_LEVEL_S3,
					PM_MPP_DIN_TO_INT);
	err |=  pm8058_mpp_config_bi_dir(PM8058_MPP_SYS_TO_PM(hspd->remote_det),
					PM8058_MPP_DIG_LEVEL_S3,
					PM_MPP_BI_PULLUP_OPEN);	
*/
	printk("mpp config %d mpp %d err=%d\n",hspd->remote_det,
		PM8058_MPP_SYS_TO_PM(hspd->remote_det),err);
	printk(" remote %d %d\n",gpio_to_irq(hspd->remote_det),PM8058_MPP_IRQ(PM8058_IRQ_BASE,PM8058_MPP_SYS_TO_PM(hspd->remote_det)));

    err=request_threaded_irq(gpio_to_irq(hspd->remote_det),NULL,
		Remotekey_Det_handler,IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", hs);
#else
    err=gpio_direction_input(hspd->remote_det);
    if(err) {
		printk("Unable to set direction remote_det err=%d\n",err); 
		goto err_reg_input_dev;
    }

    //gpio_tlmm_config(GPIO_CFG(hspd->remote_det, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_tlmm_config(GPIO_CFG(hspd->remote_det, 0, GPIO_CFG_INPUT,GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
    //gpio_set_debounce(hspd->remote_det,5);


    err=request_irq(gpio_to_irq(hspd->remote_det), Remotekey_Det_handler, 
              IRQF_DISABLED|IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", hs);
#endif
	if (err  < 0) {
		printk("Couldn't acquire remote_det as request_irq()");
		goto err_reg_input_dev;
	}

	disable_irq(gpio_to_irq(hspd->remote_det));

	headset_init=1; // headset init

	
    rc=gpio_get_value_cansleep(hspd->ear_det);
    if(rc==hspd->ear_det_active) {
	  schedule_delayed_work(&earjack_work,msecs_to_jiffies(200));
	  //schedule_delayed_work(&earjack_work,200);
    }

        printk("hs_probe success!!!\n");

    return 0;

err_reg_input_dev:
    input_unregister_device(ipdev);
err_reg_wakelock:
    wake_lock_destroy(&headset_wakelock);
    input_free_device(ipdev);
err_switch_dev:
    switch_dev_unregister(&hs->sdev);
err_switch_dev_register:
    kfree(hspd);
    kfree(hs);
    return rc;
}
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 __devinit pmic8xxx_kp_probe(struct platform_device *pdev)
{
	const struct pm8xxx_keypad_platform_data *pdata =
					dev_get_platdata(&pdev->dev);
	const struct matrix_keymap_data *keymap_data;
	struct pmic8xxx_kp *kp;
	int rc;
	u8 ctrl_val;
	struct device *sec_key;

	struct pm_gpio kypd_drv = {
		.direction	= PM_GPIO_DIR_OUT,
		.output_buffer	= PM_GPIO_OUT_BUF_OPEN_DRAIN,
		.output_value	= 0,
		.pull		= PM_GPIO_PULL_NO,
		.vin_sel	= PM_GPIO_VIN_S4,
		.out_strength	= PM_GPIO_STRENGTH_LOW,
		.function	= PM_GPIO_FUNC_1,
		.inv_int_pol	= 1,
	};

	struct pm_gpio kypd_sns = {
		.direction	= PM_GPIO_DIR_IN,
		.pull		= PM_GPIO_PULL_UP_31P5,
		.vin_sel	= PM_GPIO_VIN_S4,
		.out_strength	= PM_GPIO_STRENGTH_NO,
		.function	= PM_GPIO_FUNC_NORMAL,
		.inv_int_pol	= 1,
	};


	if (!pdata || !pdata->num_cols || !pdata->num_rows ||
		pdata->num_cols > PM8XXX_MAX_COLS ||
		pdata->num_rows > PM8XXX_MAX_ROWS ||
		pdata->num_cols < PM8XXX_MIN_COLS) {
		dev_err(&pdev->dev, "invalid platform data\n");
		return -EINVAL;
	}

	if (!pdata->scan_delay_ms ||
		pdata->scan_delay_ms > MAX_SCAN_DELAY ||
		pdata->scan_delay_ms < MIN_SCAN_DELAY ||
		!is_power_of_2(pdata->scan_delay_ms)) {
		dev_err(&pdev->dev, "invalid keypad scan time supplied\n");
		return -EINVAL;
	}

	if (!pdata->row_hold_ns ||
		pdata->row_hold_ns > MAX_ROW_HOLD_DELAY ||
		pdata->row_hold_ns < MIN_ROW_HOLD_DELAY ||
		((pdata->row_hold_ns % MIN_ROW_HOLD_DELAY) != 0)) {
		dev_err(&pdev->dev, "invalid keypad row hold time supplied\n");
		return -EINVAL;
	}

	if (!pdata->debounce_ms ||
		((pdata->debounce_ms % 5) != 0) ||
		pdata->debounce_ms > MAX_DEBOUNCE_TIME ||
		pdata->debounce_ms < MIN_DEBOUNCE_TIME) {
		dev_err(&pdev->dev, "invalid debounce time supplied\n");
		return -EINVAL;
	}

	keymap_data = pdata->keymap_data;
	if (!keymap_data) {
		dev_err(&pdev->dev, "no keymap data supplied\n");
		return -EINVAL;
	}

	kp = kzalloc(sizeof(*kp), GFP_KERNEL);
	if (!kp)
		return -ENOMEM;

	platform_set_drvdata(pdev, kp);

	kp->pdata	= pdata;
	kp->dev		= &pdev->dev;

	kp->input = input_allocate_device();
	if (!kp->input) {
		dev_err(&pdev->dev, "unable to allocate input device\n");
		rc = -ENOMEM;
		goto err_alloc_device;
	}

	kp->key_sense_irq = platform_get_irq(pdev, 0);
	if (kp->key_sense_irq < 0) {
		dev_err(&pdev->dev, "unable to get keypad sense irq\n");
		rc = -ENXIO;
		goto err_get_irq;
	}

	kp->key_stuck_irq = platform_get_irq(pdev, 1);
	if (kp->key_stuck_irq < 0) {
		dev_err(&pdev->dev, "unable to get keypad stuck irq\n");
		rc = -ENXIO;
		goto err_get_irq;
	}

	kp->input->name = pdata->input_name ? : "PMIC8XXX keypad";
	kp->input->phys = pdata->input_phys_device ? : "pmic8xxx_keypad/input0";

	kp->input->dev.parent	= &pdev->dev;

	kp->input->id.bustype	= BUS_I2C;
	kp->input->id.version	= 0x0001;
	kp->input->id.product	= 0x0001;
	kp->input->id.vendor	= 0x0001;

	kp->input->evbit[0]	= BIT_MASK(EV_KEY);

	if (pdata->rep)
		__set_bit(EV_REP, kp->input->evbit);

	kp->input->keycode	= kp->keycodes;
	kp->input->keycodemax	= PM8XXX_MATRIX_MAX_SIZE;
	kp->input->keycodesize	= sizeof(kp->keycodes);
	kp->input->open		= pmic8xxx_kp_open;
	kp->input->close	= pmic8xxx_kp_close;

	matrix_keypad_build_keymap(keymap_data, PM8XXX_ROW_SHIFT,
					kp->input->keycode, kp->input->keybit);

	get_volumekey_matrix(keymap_data,
					&volup_matrix, &voldown_matrix);

	input_set_capability(kp->input, EV_MSC, MSC_SCAN);
	input_set_drvdata(kp->input, kp);

	/* initialize keypad state */
	memset(kp->keystate, 0xff, sizeof(kp->keystate));
	memset(kp->stuckstate, 0xff, sizeof(kp->stuckstate));

	rc = pmic8xxx_kpd_init(kp);
	if (rc < 0) {
		dev_err(&pdev->dev, "unable to initialize keypad controller\n");
		goto err_get_irq;
	}

	rc = pmic8xxx_kp_config_gpio(pdata->cols_gpio_start,
					pdata->num_cols, kp, &kypd_sns);
	if (rc < 0) {
		dev_err(&pdev->dev, "unable to configure keypad sense lines\n");
		goto err_gpio_config;
	}

	rc = pmic8xxx_kp_config_gpio(pdata->rows_gpio_start,
					pdata->num_rows, kp, &kypd_drv);
	if (rc < 0) {
		dev_err(&pdev->dev, "unable to configure keypad drive lines\n");
		goto err_gpio_config;
	}

	rc = request_any_context_irq(kp->key_sense_irq, pmic8xxx_kp_irq,
				 IRQF_TRIGGER_RISING, "pmic-keypad", kp);
	if (rc < 0) {
		dev_err(&pdev->dev, "failed to request keypad sense irq\n");
		goto err_get_irq;
	}

	rc = request_any_context_irq(kp->key_stuck_irq, pmic8xxx_kp_stuck_irq,
				 IRQF_TRIGGER_RISING, "pmic-keypad-stuck", kp);
	if (rc < 0) {
		dev_err(&pdev->dev, "failed to request keypad stuck irq\n");
		goto err_req_stuck_irq;
	}

	rc = pmic8xxx_kp_read_u8(kp, &ctrl_val, KEYP_CTRL);
	if (rc < 0) {
		dev_err(&pdev->dev, "failed to read KEYP_CTRL register\n");
		goto err_pmic_reg_read;
	}

	rc = request_threaded_irq(MSM_GPIO_KEY_VOLUP_IRQ ,
		NULL, pmic8058_volume_up_irq, IRQF_TRIGGER_RISING |
		IRQF_TRIGGER_FALLING, "vol_up", kp);

	if (rc < 0) {
				dev_err(&pdev->dev, "failed to request vol_up irq\n");
		goto err_req_sense_irq;
	}

	rc = request_threaded_irq(MSM_GPIO_KEY_VOLDOWN_IRQ ,
		NULL, pmic8058_volume_down_irq, IRQF_TRIGGER_RISING |
		IRQF_TRIGGER_FALLING, "vol_down", kp);

	if (rc < 0) {
		dev_err(&pdev->dev, "failed to request vol_down irq\n");
		goto err_req_sense_irq;
	}
	kp->ctrl_reg = ctrl_val;

#if defined CONFIG_MACH_VITAL2REFRESH


	gpio_tlmm_config(GPIO_CFG(MSM_HALL_IC, 1, GPIO_CFG_INPUT,
		GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

	input_set_capability(kp->input, EV_SW, SW_LID);

	if (gpio_get_value(MSM_HALL_IC)) {
		input_report_switch(kp->input, SW_LID, 1);
	}
	else {
		input_report_switch(kp->input, SW_LID, 0);
	}

	input_sync(kp->input);

	printk(KERN_INFO "[input_report_switch] slide_int - !gpio_hall_ic %s\n",
			gpio_get_value(MSM_HALL_IC) == 0 ? "OPEN" : "CLOSE");

	rc = request_threaded_irq(MSM_GPIO_TO_INT(MSM_HALL_IC), NULL,
		hall_ic_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
							"hall_ic", kp);

	if (rc < 0) {
		dev_err(&pdev->dev, "failed to request hall_ic irq\n");
		goto err_hall_ic_irq;
	}

#endif
	rc = input_register_device(kp->input);
	if (rc < 0) {
		dev_err(&pdev->dev, "unable to register keypad input device\n");
		goto err_pmic_reg_read;
	}

	sec_key = device_create(sec_class, NULL, 0, NULL, "sec_key");
	if (IS_ERR(sec_key))
		pr_err("Failed to create device(sec_key)!\n");

	rc = device_create_file(sec_key, &dev_attr_sec_key_pressed);
	if (rc) {
		pr_err("Failed to create device file - pressed(%s), err(%d)!\n",
				dev_attr_sec_key_pressed.attr.name, rc);
	}

	dev_set_drvdata(sec_key, kp);

	device_init_wakeup(&pdev->dev, pdata->wakeup);

	return 0;

err_pmic_reg_read:
	free_irq(kp->key_stuck_irq, kp);
err_req_stuck_irq:
	free_irq(kp->key_sense_irq, kp);
#if defined CONFIG_MACH_VITAL2REFRESH
err_hall_ic_irq:
#endif
err_req_sense_irq:
err_gpio_config:
err_get_irq:
	input_free_device(kp->input);
err_alloc_device:
	platform_set_drvdata(pdev, NULL);
	kfree(kp);
	return rc;
}

static int __devexit pmic8xxx_kp_remove(struct platform_device *pdev)
{
	struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);

	device_init_wakeup(&pdev->dev, 0);
	free_irq(kp->key_stuck_irq, kp);
	free_irq(kp->key_sense_irq, kp);
	input_unregister_device(kp->input);
	kfree(kp);

	platform_set_drvdata(pdev, NULL);
	return 0;
}

#ifdef CONFIG_PM_SLEEP
static int pmic8xxx_kp_suspend(struct device *dev)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
	struct input_dev *input_dev = kp->input;

	if (device_may_wakeup(dev)) {
		enable_irq_wake(kp->key_sense_irq);
	} else {
		mutex_lock(&input_dev->mutex);

#if defined CONFIG_MACH_VITAL2REFRESH
	enable_irq_wake(MSM_GPIO_TO_INT(MSM_HALL_IC));
	/* to wakeup in case of sleep */
#endif
		if (input_dev->users)
			pmic8xxx_kp_disable(kp);

		mutex_unlock(&input_dev->mutex);
	}

	return 0;
}

static int pmic8xxx_kp_resume(struct device *dev)
{
	struct platform_device *pdev = to_platform_device(dev);
	struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
	struct input_dev *input_dev = kp->input;

	if (device_may_wakeup(dev)) {
		disable_irq_wake(kp->key_sense_irq);
	} else {
		mutex_lock(&input_dev->mutex);

#if defined CONFIG_MACH_VITAL2REFRESH
	disable_irq_wake(MSM_GPIO_TO_INT(MSM_HALL_IC)); /* to match irq pair */
#endif
	if (input_dev->users)
		pmic8xxx_kp_enable(kp);
		mutex_unlock(&input_dev->mutex);
	}

	return 0;
}
#endif

static SIMPLE_DEV_PM_OPS(pm8xxx_kp_pm_ops,
			 pmic8xxx_kp_suspend, pmic8xxx_kp_resume);

static struct platform_driver pmic8xxx_kp_driver = {
	.probe		= pmic8xxx_kp_probe,
	.remove		= __devexit_p(pmic8xxx_kp_remove),
	.driver		= {
		.name = PM8XXX_KEYPAD_DEV_NAME,
		.owner = THIS_MODULE,
		.pm = &pm8xxx_kp_pm_ops,
	},
};

static int __init pmic8xxx_kp_init(void)
{
	return platform_driver_register(&pmic8xxx_kp_driver);
}
module_init(pmic8xxx_kp_init);

static void __exit pmic8xxx_kp_exit(void)
{
	platform_driver_unregister(&pmic8xxx_kp_driver);
}
module_exit(pmic8xxx_kp_exit);

MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("PMIC8XXX keypad driver");
MODULE_VERSION("1.0");
MODULE_ALIAS("platform:pmic8xxx_keypad");
MODULE_AUTHOR("Trilok Soni <*****@*****.**>");
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);
	}
#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;
	}
#if !defined(CONFIG_MACH_JACTIVE_ATT) && !defined(CONFIG_MACH_JACTIVE_EUR)
#if defined(CONFIG_MACH_JACTIVE_ATT)
	if(system_rev < 10)
		gpio_direction_output(gpio33, 0);
	else
		gpio_direction_output(LCD_22V_EN, 0);	
#else
	gpio_direction_output(LCD_22V_EN, 0);
#endif
	if (system_rev == 0)
		gpio_direction_output(gpio43, 0);
	else
		pm8xxx_mpp_config(
			PM8921_MPP_PM_TO_SYS(MLCD_RST_MPP2),
			&MLCD_RESET_LOW_CONFIG);

	msleep(1000);
#endif
	gpio_direction_output(gpio27, 0);

	return rc;
}
示例#28
0
	int     dout;
	int     din;
	int     syncout;
	int     clkin_a;
};

static struct aux_pcm_state the_aux_pcm_state;

static void __iomem *get_base_addr(struct aux_pcm_state *aux_pcm)
{
	return aux_pcm->aux_pcm_base;
}
#ifdef CONFIG_SH_AUDIO_DRIVER
static unsigned aux_pcm_gpio_on[] = {
#if (CONFIG_SH_AUDIO_DRIVER_MODEL_NUMBER == 302)||(CONFIG_SH_AUDIO_DRIVER_MODEL_NUMBER == 303)||(CONFIG_SH_AUDIO_DRIVER_MODEL_NUMBER == 304)
	GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA),
	GPIO_CFG(139, 1, GPIO_CFG_INPUT,  GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
	GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA),
	GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA),
#else
	GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_6MA),
	GPIO_CFG(139, 1, GPIO_CFG_INPUT,  GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
	GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_6MA),
	GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_6MA),
#endif /* CONFIG_SH_AUDIO_DRIVER_MODEL_NUMBER */
};

static int aux_pcm_gpios_enable(void)
{
	int pin, rc;
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);
						}
					}
				}
示例#30
0
static int sec_switch_probe(struct platform_device *pdev)
{
	struct sec_switch_struct *secsw;
	struct sec_switch_platform_data *pdata = pdev->dev.platform_data;
	struct sec_switch_wq *wq;

	pr_err("sec_switch_probe enter %s\n", __func__);

	if (!pdata) {
		pr_err("%s : pdata is NULL.\n", __func__);
		return -ENODEV;
	}

	secsw = kzalloc(sizeof(struct sec_switch_struct), GFP_KERNEL);
	if (!secsw) {
		pr_err("%s : failed to allocate memory\n", __func__);
		return -ENOMEM;
	}

	secsw->pdata = pdata;
	secsw->switch_sel = 1;	/* UART_SEL default to MDM9K */
	secsw->is_manualset= 0;

	dev_set_drvdata(switch_dev, secsw);

	/* Initializing GPIO for control */
	gpio_request(UART_SEL_SW, "uart_sel");
	gpio_tlmm_config(GPIO_CFG(UART_SEL_SW, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);

	/* create sysfs files */
	if (device_create_file(switch_dev, &dev_attr_uart_sel) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_uart_sel.attr.name);

	if (device_create_file(switch_dev, &dev_attr_usb_state) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_usb_state.attr.name);

	if (device_create_file(switch_dev, &dev_attr_usb_sel) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_usb_sel.attr.name);

#if 0 	/* NOT USED */
	if (device_create_file(switch_dev, &dev_attr_disable_vbus) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_usb_state.attr.name);

	if (device_create_file(switch_dev, &dev_attr_device_type) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_device_type.attr.name);
#endif

#ifdef _SEC_DM_
	usb_lock = device_create(sec_class, switch_dev, MKDEV(0, 0), NULL, ".usb_lock");

	if (IS_ERR(usb_lock)) {
		pr_err("Failed to create device (usb_lock)!\n");
		return PTR_ERR(usb_lock);
	}

	dev_set_drvdata(usb_lock, secsw);

	if (device_create_file(usb_lock, &dev_attr_enable) < 0)	{
		pr_err("Failed to create device file(%s)!\n", dev_attr_enable.attr.name);
		device_destroy((struct class *)usb_lock, MKDEV(0, 0));
	}