static int curcial_oj_poweron(int on)
{
	uint8_t data[2];

#ifdef CONFIG_MACH_BRAVO
	struct vreg *oj_power = vreg_get(0, "gp2");
	if (IS_ERR(oj_power)) {
		pr_err("%s: Error power domain\n", __func__);
		return 0;
	}

	if (on) {
		vreg_set_level(oj_power, 2750);
		vreg_enable(oj_power);
	} else {
		/* for microp firmware(v04) setting*/
		microp_i2c_read(MICROP_I2C_RCMD_VERSION, data, 2);
		if (data[0] < 4) {
			printk("Microp firmware version: %d\n", data[0]);
			return 1;
		}
		vreg_disable(oj_power);
	}
	pr_err("%s: OJ power enable(%d)\n", __func__, on);
#else
	/* for microp firmware(v04) setting*/
	if (on == 0) {
		microp_i2c_read(MICROP_I2C_RCMD_VERSION, data, 2);
		if (data[0] < 4) {
			printk("Microp firmware version:%d\n",data[0]);
			return 1;
		}
	}

	gpio_set_value(CURCIAL_OJ_POWER, on);

	if (gpio_get_value(CURCIAL_OJ_POWER) != on) {
		printk(KERN_ERR "%s:OJ:power status fail \n", __func__);
		return 0;
	}
	printk(KERN_ERR "%s:OJ:power status ok \n", __func__);
#endif
	return 1;
}
Exemplo n.º 2
0
/*static*/ int ts_set_vreg(unsigned char onoff) //for touch download
{

	int rc = 0;
	struct vreg *vreg_l1 = NULL;

	vreg_l1 = vreg_get(NULL, "rfrx1");
	if (IS_ERR(vreg_l1)) {
		pr_err("%s: vreg_get failed (%ld)\n", __func__, PTR_ERR(vreg_l1));
		return PTR_ERR(vreg_l1);
	}

	printk(KERN_INFO "ts_set_veg : %d\n", onoff);
	if(onoff){

		/* LGE_CHANGE_S: E0 [email protected] [2011-12-19] 
		: Changed the touchscreen operating power 3V into 3.05V*/
		rc = vreg_set_level(vreg_l1, 3050);
		/* LGE_CHANGE_E: E0 [email protected] [2011-12-19] 
		: Changed the touchscreen operating power 3V into 3.05V*/

		if (rc < 0) {
			pr_err("%s: vreg_set_level failed (%d)\n", __func__, rc);
			goto vreg_touch_fail;
		}
		rc = vreg_enable(vreg_l1);
		if (rc < 0) {
			pr_err("%s: vreg_enable failed (%d)\n", __func__, rc);
			goto vreg_touch_fail;
		}
	} else {
		rc = vreg_disable(vreg_l1);
			if (rc < 0) {
			pr_err("%s: vreg_disable failed (%d)\n", __func__, rc);
			goto vreg_touch_fail;
		}
	}

	return rc;

vreg_touch_fail:
	vreg_put(vreg_l1);
	return rc;
}
static uint32_t htcleo_sdslot_switchvdd(struct device *dev, unsigned int vdd)
{
	// We have to find the right vreg Interface on Leo
	int i;
	int ret = 0;

	if (vdd == sdslot_vdd)
		return 0;

	sdslot_vdd = vdd;

	printk("@@@ SD power %d @@@\n", vdd);

	if (vdd == 0) 
	{
		config_gpio_table(sdcard_off_gpio_table,ARRAY_SIZE(sdcard_off_gpio_table));             
		vreg_disable(sdslot_vreg);
		sdslot_vreg_enabled = 0;
		return 0;
	}

	if (!sdslot_vreg_enabled) 
	{
		ret = vreg_enable(sdslot_vreg);
		if (ret)
			pr_err("%s: Error enabling vreg (%d)\n", __func__, ret);
		config_gpio_table(sdcard_on_gpio_table, ARRAY_SIZE(sdcard_on_gpio_table));
		sdslot_vreg_enabled = 1;
	}

	for (i = 0; i < ARRAY_SIZE(mmc_vdd_table); i++) {
		if (mmc_vdd_table[i].mask != (1 << vdd))
			continue;
		ret = vreg_set_level(sdslot_vreg, mmc_vdd_table[i].level);
		if (ret)
			pr_err("%s: Error setting level (%d)\n", __func__, ret);
		return 0;
	}

	pr_err("%s: Invalid VDD (%d) specified\n", __func__, vdd);
	return 0;
}
Exemplo n.º 4
0
static uint32_t vision_sdslot_switchvdd(struct device *dev, unsigned int vdd)
{
	int i;

	BUG_ON(!vreg_sdslot);

	if (vdd == sdslot_vdd)
		return 0;

	sdslot_vdd = vdd;

	if (vdd == 0) {
		printk(KERN_INFO "%s: Disabling SD slot power\n", __func__);
		config_gpio_table(sdcard_off_gpio_table,
				  ARRAY_SIZE(sdcard_off_gpio_table));
		vreg_disable(vreg_sdslot);
		sdslot_vreg_enabled = 0;
		return 0;
	}

	if (!sdslot_vreg_enabled) {
		mdelay(5);
		vreg_enable(vreg_sdslot);
		udelay(500);
		config_gpio_table(sdcard_on_gpio_table,
				  ARRAY_SIZE(sdcard_on_gpio_table));
		sdslot_vreg_enabled = 1;
	}

	for (i = 0; i < ARRAY_SIZE(mmc_vdd_table); i++) {
		if (mmc_vdd_table[i].mask == (1 << vdd)) {
			printk(KERN_INFO "%s: Setting level to %u\n",
				__func__, mmc_vdd_table[i].level);
			vreg_set_level(vreg_sdslot, mmc_vdd_table[i].level);
			return 0;
		}
	}

	printk(KERN_ERR "%s: Invalid VDD %d specified\n", __func__, vdd);
	return 0;
}
Exemplo n.º 5
0
static int __init ts_init(void)
{	
	u8 buf[8];
	int ret,rc;
	struct vreg *vreg_gp4 = NULL;
	u32 x_st,y_st;

		printk("[Bing]set gp4=2.6v\r\n");
		vreg_gp4 = vreg_get(0, "gp4");
		rc = vreg_set_level(vreg_gp4, 2600);
		if (rc) 
		{
			printk("[Bing]%s: vreg set gp4 level failed (%d)\n",	__func__, rc);
		}

		rc = vreg_enable(vreg_gp4);
		if (rc) 
		{
			printk("[Bing]%s: vreg enable gp4 failed (%d)\n", __func__, rc);
		}
		ret = i2c_add_driver(&st1232_ts_driver);
		ts_early.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
		ts_early.suspend = st1232_early_suspend;
		ts_early.resume = st1232_later_resume;
		register_early_suspend(&ts_early);	
		printk("[Bing][%s]K4H/CAP6 project, ret = %d\r\n", __func__, ret);

		//ret = gpio_request(TOUCH_GPIO,"touch_int");	
		//if(ret < 0)
		//	printk("fail to request gpio for touch_int! error = %d\n",ret);
		// printk("[Bing] %s: TOUCH_GPIO = %d\n",__func__,gpio_get_value(TOUCH_GPIO) );
		 //gpio_direction_output(TOUCH_GPIO, 1);
	 	printk("[Bing] %s: TOUCH_GPIO = %d\n",__func__,gpio_get_value(TOUCH_GPIO) );		
		ret = i2c_master_recv(st1232_ts->client, buf, 8);
			y_st = ((buf[2]&0x70)<<4)|buf[3];
			x_st = 289 - (((buf[2]&0x07)<<8)|buf[4]);
			printk("[Bing]init x_st=%d, y_st=%d\r\n", x_st, y_st);


	return ret;
}
Exemplo n.º 6
0
/** accelerometer **/
int accel_power(unsigned char onoff)
{
	int ret = 0;
	struct vreg *usim2_vreg = vreg_get(0, "usim2");

	if (onoff) {
		printk(KERN_INFO "accel_power_on\n");

		ret = vreg_set_level(usim2_vreg, 3000);
		if (ret != 0) {
			printk(KERN_INFO "[Accel] vreg_set_level failed\n");
			return ret;
		}
		vreg_enable(usim2_vreg);
	} else {
		printk(KERN_INFO "accel_power_off\n");
		vreg_disable(usim2_vreg);
	}

	return ret;
}
Exemplo n.º 7
0
static uint32_t mahimahi_sdslot_switchvdd(struct device *dev, unsigned int vdd)
{
	int i;
	int ret;

	if (vdd == sdslot_vdd)
		return 0;

	sdslot_vdd = vdd;

	if (vdd == 0) {
		config_gpio_table(sdcard_off_gpio_table,
				  ARRAY_SIZE(sdcard_off_gpio_table));
		vreg_disable(sdslot_vreg);
		sdslot_vreg_enabled = 0;
		return 0;
	}

	if (!sdslot_vreg_enabled) {
		ret = vreg_enable(sdslot_vreg);
		if (ret)
			pr_err("%s: Error enabling vreg (%d)\n", __func__, ret);
		config_gpio_table(sdcard_on_gpio_table,
				  ARRAY_SIZE(sdcard_on_gpio_table));
		sdslot_vreg_enabled = 1;
	}

	for (i = 0; i < ARRAY_SIZE(mmc_vdd_table); i++) {
		if (mmc_vdd_table[i].mask != (1 << vdd))
			continue;
		ret = vreg_set_level(sdslot_vreg, mmc_vdd_table[i].level);
		if (ret)
			pr_err("%s: Error setting level (%d)\n", __func__, ret);
		return 0;
	}

	pr_err("%s: Invalid VDD (%d) specified\n", __func__, vdd);
	return 0;
}
static unsigned int ft5306_power_up(void)
{
	int rc = 0;
	struct vreg *vreg = NULL;
	vreg = vreg_get(NULL, "gp2");
	if (IS_ERR(vreg)) {
		pr_err("%s: vreg get failed (%ld)\n",
			__func__, PTR_ERR(vreg));
		return PTR_ERR(vreg);
	}
	rc = vreg_set_level(vreg, 2850);
	if (rc < 0) {
		pr_err("%s: vreg set level failed (%d)\n",
				__func__, rc);
	}
	rc = vreg_enable(vreg);
	if (rc < 0) {
		pr_err("%s: vreg enable failed (%d)\n",
		       __func__, rc);
	}
	return rc;
}
int key_led_power_control(uint8_t LED_ON_OFF)
{
	struct vreg *vreg_keyled;
	int ret=0;

	printk(KERN_ERR "%s: key_led_power_control ON/OFF [%d]\n",__func__, LED_ON_OFF);
	vreg_keyled = vreg_get(NULL, "maxldo04");
	if (LED_ON_OFF == TRUE) {
		ret = vreg_set_level(vreg_keyled, OUT3000mV);
		ret = vreg_enable(vreg_keyled);
		mod_timer(&g_led_timer, jiffies + (HZ*KEY_LED_ON_TIME));
		if (ret) {
			return -EIO;
		}
	} else {
		ret = vreg_disable(vreg_keyled);
		if (ret) {
			return -EIO;
		}
	}
	return ret;
}
Exemplo n.º 10
0
static void htckovsky_oj_power(bool enable) {
	char buffer[2];
	
	if (enable) {
		vreg_set_level(htckovsky_oj.vreg_pwr, 2800);
		vreg_enable(htckovsky_oj.vreg_pwr);
		vreg_enable(htckovsky_oj.vreg_28v);
		
		buffer[0] = MICROP_OJ_POWER_KOVS;
		buffer[1] = MICROP_CMD_OJ_PWR_ON;
		microp_ng_write(htckovsky_oj.client, buffer, ARRAY_SIZE(buffer));
		htckovsky_oj_reset();	
	}
	else {
		buffer[0] = MICROP_OJ_POWER_KOVS;
		buffer[1] = MICROP_CMD_OJ_PWR_OFF;
		microp_ng_write(htckovsky_oj.client, buffer, ARRAY_SIZE(buffer));
		
		vreg_disable(htckovsky_oj.vreg_28v);
		vreg_disable(htckovsky_oj.vreg_pwr);
	}
}
static int ts_set_vreg(unsigned char onoff)
#endif
{
	struct vreg *vreg_touch;
	int rc;
	// LGE_CHANGE [[email protected]] 2010-07-26, onoff stat
	static int old_onoff = 0;

	printk("[Touch] %s() onoff:%d\n",__FUNCTION__, onoff);

	// LGE_CHANGE [[email protected]] 2010-07-26, onoff stat
	if (old_onoff == onoff)
		return 0;

	vreg_touch = vreg_get(0, "synt");

	if(IS_ERR(vreg_touch)) {
		printk("[Touch] vreg_get fail : touch\n");
		return -1;
	}

	if (onoff) {
		rc = vreg_set_level(vreg_touch, 3050);
		if (rc != 0) {
			printk("[Touch] vreg_set_level failed\n");
			return -1;
		}
		vreg_enable(vreg_touch);
		// LGE_CHANGE [[email protected]] 2010-07-26, onoff stat
		old_onoff = onoff;
	} else {
		vreg_disable(vreg_touch);
		// LGE_CHANGE [[email protected]] 2010-07-26, onoff stat
		old_onoff = onoff;
	}

	return 0;
}
Exemplo n.º 12
0
/* proximity */
static int prox_power_set(unsigned char onoff)
{
	static bool init_done = 0;
	
	int ret = 0;
	struct vreg *gp6_vreg = vreg_get(0, "gp6");

	printk("[Proximity] %s() : Power %s\n",__FUNCTION__, onoff ? "On" : "Off");
	
	if (init_done == 0 && onoff)
	{
		if (onoff) {
			vreg_set_level(gp6_vreg, 2800);
			vreg_enable(gp6_vreg);

			init_done = 1;
		} else {
			vreg_disable(gp6_vreg);
		}
	}

	return ret;
}
Exemplo n.º 13
0
static int pp2106_vreg_set(unsigned char onoff)
{
	int rc = 0;
	struct vreg *vreg_l12 = NULL;

	vreg_l12 = vreg_get(NULL, "gp2");
	if (IS_ERR(vreg_l12)) {
		pr_err("%s: vreg_get failed (%ld)\n", __func__, PTR_ERR(vreg_l12));
		return PTR_ERR(vreg_l12);
	}

	if (onoff) {
		rc = vreg_set_level(vreg_l12, 2850);
		if (rc < 0) {
			pr_err("%s: vreg_set_level failed (%d)\n", __func__, rc);
			goto vreg_fail;
		}
		rc = vreg_enable(vreg_l12);
		if (rc < 0) {
			pr_err("%s: vreg_enable failed (%d)\n", __func__, rc);
			goto vreg_fail;
		}
	} else {
		rc = vreg_disable(vreg_l12);
		if (rc < 0) {
			pr_err("%s: vreg_disable failed (%d)\n", __func__, rc);
			goto vreg_fail;
		}
	}

	return rc;

vreg_fail:
	vreg_put(vreg_l12);
	return rc;
}
Exemplo n.º 14
0
static int32_t sensor_vreg_enable
(
    struct msm_camera_sensor_vreg *sensor_vreg,
    uint8_t vreg_num
)

{
    struct vreg *vreg_handle;
    uint8_t temp_vreg_sum;
    int32_t rc;
    
    if(sensor_vreg == NULL)
    {
        return 0;
    }
    
    for(temp_vreg_sum = 0; temp_vreg_sum < vreg_num;temp_vreg_sum++)
    {
        vreg_handle = vreg_get(0, sensor_vreg[temp_vreg_sum].vreg_name);
    	if (!vreg_handle) {
    		printk(KERN_ERR "vreg_handle get failed\n");
    		return -EIO;
    	}
    	rc = vreg_set_level(vreg_handle, sensor_vreg[temp_vreg_sum].mv);
    	if (rc) {
    		printk(KERN_ERR "vreg_handle set level failed\n");
    		return -EIO;
    	}
    	rc = vreg_enable(vreg_handle);
    	if (rc) {
    		printk(KERN_ERR "vreg_handle enable failed\n");
    		return -EIO;
    	}
    }
    return 0;
}
static int ts_set_vreg(unsigned char onoff)
{
	struct vreg *vreg_touch;
	int rc;
	unsigned on_off, id;

	printk("[Touch] %s() onoff:%d\n",__FUNCTION__, onoff);

	vreg_touch = vreg_get(0, "synt");

	if(IS_ERR(vreg_touch)) {
		printk("[Touch] vreg_get fail : touch\n");
		return -1;
	}

	if (onoff) {		
		on_off = 0;
		id = PM_VREG_PDOWN_SYNT_ID;
		msm_proc_comm(PCOM_VREG_PULLDOWN, &on_off, &id);		
		vreg_disable(vreg_touch);

		rc = vreg_set_level(vreg_touch, 3050);
		if (rc != 0) {
			printk("[Touch] vreg_set_level failed\n");
			return -1;
		}
		vreg_enable(vreg_touch);
	} else {		
		vreg_disable(vreg_touch);
		on_off = 1;
		id = PM_VREG_PDOWN_SYNT_ID;
		msm_proc_comm(PCOM_VREG_PULLDOWN, &on_off, &id);		
	}

	return 0;
}
Exemplo n.º 16
0
/* Proximity Sensor (Capella_CM3602)*/
static int __capella_cm3602_power(int on)
{
	int ret;
	struct vreg *vreg = vreg_get(0, "gp1");
	if (!vreg) {
		printk(KERN_ERR "%s: vreg error\n", __func__);
		return -EIO;
	}
	ret = vreg_set_level(vreg, 2800);

	printk(KERN_DEBUG "%s: Turn the capella_cm3602 power %s\n",
		__func__, (on) ? "on" : "off");
	if (on) {
		gpio_direction_output(SUPERSONIC_GPIO_PROXIMITY_EN_N, 1);
		ret = vreg_enable(vreg);
		if (ret < 0)
			printk(KERN_ERR "%s: vreg enable failed\n", __func__);
	} else {
		vreg_disable(vreg);
		gpio_direction_output(SUPERSONIC_GPIO_PROXIMITY_EN_N, 0);
	}

	return ret;
}
/* proximity */
static int apds_power_set(unsigned char enable)
{
	int err = 0;
	int hw_rev_num = lge_get_hw_rev();
	struct vreg *vreg_power_1;

	printk("### apds_power_set enable : %d\n", enable);

	
	if(hw_rev_num < LGE_REV_11)
		vreg_power_1 = vreg_get(0, VREG_PROXI_VDD_26V);
	else if(hw_rev_num >= LGE_REV_11)
		vreg_power_1 = vreg_get(0, VREG_PERI_26V);

	if (enable) {
		vreg_enable(vreg_power_1);

		// LGE_UPDATE_S... [email protected] 13-Apr-2011
		// Change Vreg_power value for Proximtiy Sensor Tunning.(2.6V --> 2.8V)
		// [email protected] 30-JUN-2011 Change Vreg_power value for Proximtiy Sensor Tunning.(2.8V --> 3.0V)
		err = vreg_set_level(vreg_power_1, 3000/*2800*/);
		// LGE_UPDATE_E... 

		if (err != 0) {
			printk("### vreg_power_1 failed.\n");
			return -1;
		}

		printk("### adps sensor power OK\n");
	}
	else {
		vreg_disable(vreg_power_1);
	}

	return err; 
}
Exemplo n.º 18
0
int vreg_set_level(struct vreg *vreg, unsigned mv)
{
	unsigned id = vreg->id;

#if defined(CONFIG_MSM_AMSS_VERSION_WINCE)
	struct msm_dex_command dex = { 
		.cmd = PCOM_PMIC_REG_VOLTAGE,
		.has_data = 1, 
		.data = (1U << id) };
	// This reg appears to only be used by vreg_set_level()
	writel(mv, MSM_SHARED_RAM_BASE + 0xfc130);
	vreg->status = msm_proc_comm_wince(&dex, 0);
#else
	vreg->status = msm_proc_comm(PCOM_VREG_SET_LEVEL, &id, &mv);
#endif

	if (debug_mask & VREG_DEBUG_LEVEL)
		printk(KERN_DEBUG "%s: n=%s id=%u s=%d ref=%u -> %umv\n", __func__,
			vreg->name, vreg->id, vreg->status, vreg->refcnt, mv);

	return vreg->status;
}

#if defined(CONFIG_DEBUG_FS)

static int vreg_debug_set(void *data, u64 val)
{
	struct vreg *vreg = data;
	switch (val) {
	case 0:
		vreg_disable(vreg);
		break;
	case 1:
		vreg_enable(vreg);
		break;
	default:
		vreg_set_level(vreg, val);
		break;
	}
	return 0;
}

static int vreg_debug_get(void *data, u64 *val)
{
	struct vreg *vreg = data;

	if (!vreg->status)
		*val = 0;
	else
		*val = 1;

	return 0;
}

static int vreg_debug_count_set(void *data, u64 val)
{
	struct vreg *vreg = data;
	if (val > UINT_MAX)
		val = UINT_MAX;
	vreg->refcnt = val;
	return 0;
}

static int vreg_debug_count_get(void *data, u64 *val)
{
	struct vreg *vreg = data;

	*val = vreg->refcnt;

	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(vreg_fops, vreg_debug_get, vreg_debug_set, "%llu\n");
DEFINE_SIMPLE_ATTRIBUTE(vreg_count_fops, vreg_debug_count_get,
			vreg_debug_count_set, "%llu\n");

static int __init vreg_debug_init(void)
{
	struct dentry *dent;
	int n;
	char name[32];
	const char *refcnt_name = "_refcnt";

	dent = debugfs_create_dir("vreg", 0);
	if (IS_ERR(dent))
		return 0;

	for (n = 0; n < ARRAY_SIZE(vregs); n++) {
		(void) debugfs_create_file(vregs[n].name, 0644,
					   dent, vregs + n, &vreg_fops);

		strlcpy(name, vregs[n].name, sizeof(name));
		strlcat(name, refcnt_name, sizeof(name));
		(void) debugfs_create_file(name, 0644,
					   dent, vregs + n, &vreg_count_fops);
	}

	return 0;
}

device_initcall(vreg_debug_init);
Exemplo n.º 19
0
static uint32_t chacha_sdslot_switchvdd(struct device *dev, unsigned int vdd)
{
    int i;

    BUG_ON(!vreg_sdslot);

    if (vdd == sdslot_vdd)
        return 0;

    sdslot_vdd = vdd;

    if (vdd == 0) {
        printk(KERN_INFO "%s: Disabling SD slot power\n", __func__);
        writel(MCI_PWR_OFF, MSM_SDC2_BASE + MMCIPOWER);
        mdelay(1);
        config_gpio_table(sdcard_off_gpio_table,
                          ARRAY_SIZE(sdcard_off_gpio_table));
        vreg_disable(vreg_sdslot);
        sdslot_vreg_enabled = 0;
        return 0;
    }

    if (!sdslot_vreg_enabled) {
        mdelay(5);
        vreg_enable(vreg_sdslot);
    }

    for (i = 0; i < ARRAY_SIZE(mmc_vdd_table); i++) {
        if (mmc_vdd_table[i].mask == (1 << vdd)) {
            printk(KERN_INFO "%s: Setting level to %u\n",
                   __func__, mmc_vdd_table[i].level);
            vreg_set_level(vreg_sdslot, mmc_vdd_table[i].level);
            if (!sdslot_vreg_enabled)
                break;
            else
                return 0;
        }
    }

    /* All vdd match failed */
    if (i == ARRAY_SIZE(mmc_vdd_table))
        goto out;

    if (!sdslot_vreg_enabled) {
        u32 pwr = 0;

        /* Power on MCI controller */
        mdelay(5);
        pwr = readl(MSM_SDC2_BASE + MMCIPOWER);
        writel(pwr | MCI_PWR_UP, MSM_SDC2_BASE + MMCIPOWER);
        mdelay(5);
        pwr = readl(MSM_SDC2_BASE + MMCIPOWER);
        writel(pwr | MCI_PWR_ON, MSM_SDC2_BASE + MMCIPOWER);
        mdelay(5);

        /* ..then, config GPIO */
        config_gpio_table(sdcard_on_gpio_table,
                          ARRAY_SIZE(sdcard_on_gpio_table));
        sdslot_vreg_enabled = 1;
        return 0;
    }

out:
    printk(KERN_ERR "%s: Invalid VDD %d specified\n", __func__, vdd);
    return 0;
}
Exemplo n.º 20
0
static int sr130pc10_set_power(int onoff)
{
  int rc = 0;
    struct vreg *vreg_ldo20, *vreg_ldo11;

/* test1*/
    vreg_ldo20 = vreg_get(NULL, "gp13");
    if(!vreg_ldo20){
        printk("[S5K4ECGX]%s: VREG L20 get failed\n", __func__);
    }
    if(vreg_set_level(vreg_ldo20, 1800)){
        printk("[S5K4ECGX]%s: vreg_set_level failed\n", __func__);
    }

    vreg_ldo11 = vreg_get(NULL, "gp2");
    if (!vreg_ldo11) {
        printk("[S5K4ECGX]%s: VREG L11 get failed\n", __func__);
    }
    if (vreg_set_level(vreg_ldo11, 2800)) {
        printk("[S5K4ECGX]%s: vreg_set_level failed\n", __func__);	
    }
/* end of test1 */





  if(onoff)
  {
    printk("<=PCAM=> ++++++++++++++++++++++++++sr130pc10 test driver++++++++++++++++++++++++++++++++++++ \n");
    gpio_tlmm_config(GPIO_CFG(CAM_RESET, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_RESET
    gpio_tlmm_config(GPIO_CFG(CAM_STANDBY, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_STANDBY
    gpio_tlmm_config(GPIO_CFG(CAM_EN, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_EN
    gpio_tlmm_config(GPIO_CFG(CAM_VT_RST, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_VT_RST
    gpio_tlmm_config(GPIO_CFG(CAM_VT_nSTBY, 0,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE); //CAM_VT_nSTBY
#if 0
    vreg_ldo20 = vreg_get(NULL, "gp13");
    vreg_ldo11 = vreg_get(NULL, "gp2");
    vreg_set_level(vreg_ldo20, 1800);
    vreg_set_level(vreg_ldo11, 2800);
    vreg_disable(vreg_ldo20);
    vreg_disable(vreg_ldo11);
#endif
    gpio_set_value(CAM_RESET, 0);	
    gpio_set_value(CAM_STANDBY, 0);	
    gpio_set_value(CAM_EN, 0);	
    gpio_set_value(CAM_VT_RST, 0);	
    gpio_set_value(CAM_VT_nSTBY, 0);	
    
    mdelay(1);
    gpio_set_value(CAM_EN, 1); //CAM_EN->UP	

#if 1
        if (vreg_enable(vreg_ldo20)) {
            printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![S5K4ECGX]%s: reg_enable failed\n", __func__);
        }
        if (vreg_enable(vreg_ldo11)) {
            printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![S5K4ECGX]%s: reg_enable failed\n", __func__);
        }
#else
    vreg_enable(vreg_ldo20);
    mdelay(1);
    vreg_enable(vreg_ldo11);
#endif
    gpio_set_value(CAM_VT_nSTBY, 1); //VGA_STBY UP
    udelay(5);
    
    gpio_tlmm_config(GPIO_CFG(CAM_MCLK, 1,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), GPIO_CFG_ENABLE);
    mdelay(10);
    //CAM_MCLK
    // msm_camio_clk_rate_set(24000000);	//MCLK
    // msm_camio_camif_pad_reg_reset();
    
    gpio_set_value(CAM_VT_RST, 1); //VGA_RESET UP
    mdelay(2);
    printk("I2C Enable \n");  
    gpio_tlmm_config(GPIO_CFG(0, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA) , GPIO_CFG_ENABLE);            
    gpio_tlmm_config(GPIO_CFG(1, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA) , GPIO_CFG_ENABLE); 
  }
  else
  {
    gpio_set_value(CAM_RESET, 0); //REST -> DOWN
    gpio_set_value(CAM_STANDBY,0);

    mdelay(1);
    gpio_set_value(CAM_EN, 0); //CAM_EN->UP	

    printk("I2C Disable \n"); 
    gpio_tlmm_config(GPIO_CFG(0, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA) , GPIO_CFG_DISABLE);
    gpio_tlmm_config(GPIO_CFG(1, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA) , GPIO_CFG_DISABLE);
    mdelay(7/*2*/);
    gpio_set_value(CAM_VT_RST, 0); //REST -> DOWN
    mdelay(2);
    gpio_tlmm_config(GPIO_CFG(CAM_MCLK, 1,GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_DISABLE);
    udelay(5);
    gpio_set_value(CAM_VT_nSTBY, 0); //STBY -> DOWN
    udelay(5);

#if 1
		//Entering shutdown mode
		if (vreg_disable(vreg_ldo11)) {  //Power down VDDIO 1.8V and 1.3Mcore 1.8V
            printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![S5K4ECGX]%s: reg_disable failed\n", __func__);
        }
        mdelay(1);
        if (vreg_disable(vreg_ldo20)) {  //Power down AVDD 2.8V 
            printk("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!![S5K4ECGX]%s: reg_disable failed\n", __func__);
        }
#else
    vreg_disable(vreg_get(NULL, "gp2"));
    mdelay(1);
    
    vreg_disable(vreg_get(NULL, "gp13"));
    mdelay(1);
#endif
//	gpio_set_value(CAM_EN, 0); //EN -> DOWN
//	mdelay(1);
  }
}
Exemplo n.º 21
0
/*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

	Driver Description

 *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/
static int bwpm_driver_probe( struct platform_device *pdev )
{
	int pin;
	int ret;
	struct vreg *vreg_bt;
	struct vreg *vreg_wl;
	bwpm_data_t *p_priv;

    int ini;

	/* Port Configuration */
	for (pin = 0; pin < ARRAY_SIZE(bwpm_gpio_config); pin++) {
		ret = gpio_tlmm_config( bwpm_gpio_config[pin], GPIO_CFG_ENABLE );
		if (ret) {
			disp_err( "gpio_tlmm_config(%d)<-%#x : %d\n", pin,bwpm_gpio_config[pin], ret);
			return -EIO;
		}
	}

	/* Regurator Configuration for BT */
	vreg_bt = vreg_get(NULL, "wlan");
	if (IS_ERR(vreg_bt)) {
		disp_err( "vreg get failed (%ld)\n", PTR_ERR(vreg_bt) );
		return PTR_ERR(vreg_bt);
	}
	ret = vreg_set_level( vreg_bt, BWPM_VREG_L13_LEVEL );
	if ( ret ) {
		disp_err( "vreg set level failed (%d)\n", ret) ;
		return -EIO;
	}

	/* Regurator Configration for wlan */
	vreg_wl = vreg_get(NULL, "wlan2");
	if (IS_ERR(vreg_wl)) {
		disp_err( "vreg get for wlan failed (%ld)\n", PTR_ERR(vreg_wl) );
		return PTR_ERR(vreg_wl);
	}
	ret = vreg_set_level( vreg_wl, BWPM_VREG_L19_LEVEL );
	if ( ret ) {
		disp_err( "vreg set level for wlan failed (%d)\n", ret) ;
		return -EIO;
	}

	/* Initialize private data */
	p_priv = kmalloc( sizeof(*p_priv) , GFP_KERNEL );
	if ( p_priv == NULL ){
		disp_err( "memory allocation for private data failed\n" );
		return -ENOMEM;
	}
	p_priv->vreg_bt = vreg_bt;
	p_priv->vreg_wl = vreg_wl;
	platform_set_drvdata( pdev , p_priv );

	/* power on reset */
    bwpm_reset( &(pdev->dev) );

	/* power on */
	ini = BWPM_INI_FM;
	if ( ini ){
		bwpm_fm_on( &(pdev->dev) , 1 );
	}
	ini = BWPM_INI_BT;
	if ( ini ){
		bwpm_bluetooth_on( &(pdev->dev) , 1 );
	}
	ini = BWPM_INI_WL;
	if ( ini ){
		bwpm_wifi_on( &(pdev->dev) , 1 );
	}

	/* create sysfs interface */
	ret = sysfs_create_group( &(pdev->dev.kobj), &bwpm_device_attributes_gourp);
	if ( ret ){
		disp_err( "Sysfs attribute export failed with error %d.\n" , ret );
	}

	return ret;
}
Exemplo n.º 22
0
static int aps_12d_probe(
	
	struct i2c_client *client, const struct i2c_device_id *id)
{	
	/* define and initialization the value */
	int value_lsb = 0;
	int value_msb = 0;   
	int ret;
	struct aps_data *aps;
	/*the aps_12d sensors ispower on*/
	int i;
#ifdef CONFIG_ARCH_MSM7X30
	struct vreg *vreg_gp4=NULL;
	int rc;
	/*delete this line,27A don't have to match the power supply*/
	
    vreg_gp4 = vreg_get(NULL, VREG_GP4_NAME);
    if (IS_ERR(vreg_gp4)) 
    {
	    pr_err("%s:gp4 power init get failed\n", __func__);
    }

    /* set gp4 voltage as 2700mV for all */
    rc = vreg_set_level(vreg_gp4,VREG_GP4_VOLTAGE_VALUE_2700);
    
    if (rc) {
        pr_err("%s: vreg_gp4 vreg_set_level failed (%d)\n", __func__, rc);
        return rc;
    }
    rc = vreg_enable(vreg_gp4);
    if (rc) {
        pr_err("%s: vreg_gp4 vreg_enable failed (%d)\n", __func__, rc);
        return rc;
    }
#endif
    mdelay(5);
    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        printk(KERN_ERR "aps_12d_probe: need I2C_FUNC_I2C\n");
        ret = -ENODEV;
        goto err_check_functionality_failed;
    }

	/* if querry the board is T1 or T2 turn off the proximity */
    /* This modification for version A&B of U8800,only */
	if((machine_is_msm7x30_u8800())&&((get_hw_sub_board_id() == HW_VER_SUB_VA) || ((get_hw_sub_board_id() == HW_VER_SUB_VB))))
	{
		printk(KERN_ERR "aps_12d_probe: aps is not supported in U8800 and U8800 T1 board!\n");
		ret = -ENODEV;
		goto err_check_functionality_failed; 
	}    

	aps = kzalloc(sizeof(*aps), GFP_KERNEL);
	if (aps == NULL) {
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}

	mutex_init(&aps->mlock);
	
	INIT_WORK(&aps->work, aps_12d_work_func);
	aps->client = client;
	i2c_set_clientdata(client, aps);

	PROXIMITY_DEBUG(KERN_INFO "ghj aps_12d_probe send command 2\n ");
	
	/* Command 2 register: 25mA,DC,12bit,Range1 */
	/*power_down to avoid the iic read error */
	aps_i2c_reg_write(aps, APS_12D_REG_CMD1, APS_12D_POWER_DOWN);
	
	/*init the flag,because everlight's 0x06,0x07's register's value low 4 bit is 0*/
	value_lsb = aps_i2c_reg_read(aps, APS_INT_HT_LSB);
	value_msb = aps_i2c_reg_read(aps, APS_INT_HT_MSB);
	old_lsb = value_lsb;
	old_msb = value_msb;
	
	/* debug--- stare at the value of lsb & msb */
	APS_DBG("value_lsb=%d,value_msb=%d\n",value_lsb,value_msb);
	/* judge the device type */
	/* when 06 07 registers don't equal 0x00, we think it's a intersil hardware */
	if((0x00 == value_lsb) && (0x00 == value_msb))
	{
		intersil_flag = EVERLIGHT;
	}
	else
	{
		intersil_flag = INTERSIL;
	}
	
	/* write reg value for the two device */
	if(EVERLIGHT == intersil_flag)
	{
		ret = aps_i2c_reg_write(aps, APS_12D_REG_CMD2, \
							(uint8_t)(APS_12D_IRDR_SEL_50MA << 6 | \
										APS_12D_FREQ_SEL_DC << 4 | \
										APS_12D_RES_SEL_12 << 2 | \
										APS_12D_RANGE_SEL_ALS_1000));
	}
	else 
	{
		/*because Power-up and Power Supply Considerations is not good enough for intersil's datasheet,so avoid it via software*/
		ret = aps_i2c_reg_write(aps, APS_TEST, APS_12D_POWER_DOWN);
		if (ret < 0) 
		{
			PROXIMITY_DEBUG("APS_TEST error!\n");
		}
		msleep(10);
		ret = aps_i2c_reg_write(aps, APS_12D_REG_CMD1, APS_12D_POWER_DOWN);
		if (ret < 0) 
		{
			PROXIMITY_DEBUG("APS_12D_POWER_DOWN error!\n");
		}
		msleep(10);
		ret = aps_i2c_reg_write(aps, APS_12D_REG_CMD2, \
								(uint8_t)(APS_12D_IRDR_SEL_INTERSIL_50MA << 4 | \
										APS_FREQ_INTERSIL_DC << 6 | \
										APS_ADC_12 << 2 | \
										APS_INTERSIL_SCHEME_OFF| \
										APS_12D_RANGE_SEL_ALS_1000));
	}
	err_threshold_value[1] = 50;
	if (ret < 0) {
		goto err_detect_failed;
	}
	range_index = 0;
    #ifdef CONFIG_HUAWEI_HW_DEV_DCT
    /* detect current device successful, set the flag as present */
    set_hw_dev_flag(DEV_I2C_APS);
    #endif

	for(i = 0; i < TOTAL_RANGE_NUM; i++)
	{
		/* NOTE: do NOT use the last one */
		/* get the down_range_value */
		if(EVERLIGHT == intersil_flag)
		{
			up_range_value[i] = MAX_ADC_OUTPUT - high_threshold_value_U8661[i] - RANGE_FIX + 500; 
		}
		else
		{
			up_range_value[i] = MAX_ADC_OUTPUT - high_threshold_value_U8661_I[i] - RANGE_FIX + 500; 
		}
	}

	down_range_value[0] = 0;
	for(i = 1; i < TOTAL_RANGE_NUM; i++)
	{
		/* NOTE: do not use the first one */
		/* get the down_range_value */
		if(EVERLIGHT == intersil_flag)
		{
			down_range_value[i] = (MAX_ADC_OUTPUT - high_threshold_value_U8661[i-1] - (MAX_ADC_OUTPUT / ADJUST_GATE)) / 4 - 650;
		}
		else
		{
			down_range_value[i] = (MAX_ADC_OUTPUT - high_threshold_value_U8661_I[i-1] - (MAX_ADC_OUTPUT / ADJUST_GATE)) / 4 - 650;
		}
	}
	
	/*we don't use the input device sensors again */
	aps->input_dev = input_allocate_device();
	if (aps->input_dev == NULL) {
		ret = -ENOMEM;
		PROXIMITY_DEBUG(KERN_ERR "aps_12d_probe: Failed to allocate input device\n");
		goto err_input_dev_alloc_failed;
	}
	aps->input_dev->name = "sensors_aps";
	
	aps->input_dev->id.bustype = BUS_I2C;
	
	input_set_drvdata(aps->input_dev, aps);
	
	ret = input_register_device(aps->input_dev);
	if (ret) {
		printk(KERN_ERR "aps_probe: Unable to register %s input device\n", aps->input_dev->name);
		goto err_input_register_device_failed;
	}
	
	set_bit(EV_ABS, aps->input_dev->evbit);
	input_set_abs_params(aps->input_dev, ABS_LIGHT, 0, 10240, 0, 0);
	input_set_abs_params(aps->input_dev, ABS_DISTANCE, 0, 1, 0, 0);

	ret = misc_register(&light_device);
	if (ret) {
		printk(KERN_ERR "aps_12d_probe: light_device register failed\n");
		goto err_light_misc_device_register_failed;
	}

	ret = misc_register(&proximity_device);
	if (ret) {
		printk(KERN_ERR "aps_12d_probe: proximity_device register failed\n");
		goto err_proximity_misc_device_register_failed;
	}


	if( light_device.minor != MISC_DYNAMIC_MINOR ){
		light_device_minor = light_device.minor;
	}

	

	if( proximity_device.minor != MISC_DYNAMIC_MINOR ){
		proximity_device_minor = proximity_device.minor ;
	}

	wake_lock_init(&proximity_wake_lock, WAKE_LOCK_SUSPEND, "proximity");


	hrtimer_init(&aps->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	aps->timer.function = aps_timer_func;
	
	aps_wq = create_singlethread_workqueue("aps_wq");

	if (!aps_wq) 
	{
		ret = -ENOMEM;
		goto err_create_workqueue_failed;
	}
	
	this_aps_data =aps;
	ret = set_sensor_input(PS, aps->input_dev->dev.kobj.name);
	if (ret) {
		dev_err(&client->dev, "%s set_sensor_input failed\n", __func__);
		goto err_create_workqueue_failed;
	}
	ret = set_sensor_input(ALS, aps->input_dev->dev.kobj.name);
	if (ret) {
		dev_err(&client->dev, "%s set_sensor_input failed\n", __func__);
		goto err_create_workqueue_failed;
	}
	/* delete the redundant code */

	printk(KERN_INFO "aps_12d_probe: Start Proximity Sensor APS-12D\n");

	set_sensors_list(L_SENSOR + P_SENSOR);
	return 0;
	
err_create_workqueue_failed:
	misc_deregister(&proximity_device);
err_proximity_misc_device_register_failed:
	misc_deregister(&light_device);
err_light_misc_device_register_failed:
err_input_register_device_failed:
	input_free_device(aps->input_dev);
err_input_dev_alloc_failed:
err_detect_failed:
	kfree(aps);
err_alloc_data_failed:
err_check_functionality_failed:
#ifdef CONFIG_ARCH_MSM7X30
	if(NULL != vreg_gp4)
	{
        /* can't use the flag ret here, it will change the return value of probe function */
        vreg_disable(vreg_gp4);
        /* delete a line */
	}
#endif
	return ret;
  
}
Exemplo n.º 23
0
static int gp2a_opt_probe(struct i2c_client *client,
			 const struct i2c_device_id *id)
{
	int err = 0;
	int i;
#if USE_INTERRUPT
	int irq;
#endif
	int config;

	struct gp2a_data *gp2a;
#ifdef STM_DEBUG
	printk(KERN_INFO "%s\n",__FUNCTION__);
#endif

#if defined(CONFIG_MACH_TOTORO_CTC) && (CONFIG_BOARD_REVISION >= 0x02) //twkim add proximity sensor driver to totoro_ctc
    {
		vreg_proximity = vreg_get(0, "ldo9"); //twkim fixed pmic set
		if (IS_ERR(vreg_proximity))
		{	
			printk("===== [PROXIMITY] proximity IS_ERR TEST =====\n");
			return PTR_ERR(vreg_proximity);
		}
	
#if defined(CONFIG_MACH_TOTORO_CTC) && (CONFIG_BOARD_REVISION >= 0x02) //twkim add proximity sensor driver to totoro_ctc
             vreg_set_level(vreg_proximity, OUT2800mV); // set to 3.0V voltage twkim 12 -> 10 to set 2.85V -> 2.6v
             gp2a_gpio_set(ENABLE);
#else
	vreg_set_level(vreg_proximity, OUT2850mV); // set to 3.0V voltage twkim 12 -> 10 to set 2.85V
#endif
		vreg_enable(vreg_proximity); // voltage 
	}
#else
	if( board_hw_revision < 3 )
	{
		vreg_proximity = vreg_get(0, "ldo19");
		if (IS_ERR(vreg_proximity))
		{	
			printk("===== [PROXIMITY] proximity IS_ERR TEST =====\n");
			return PTR_ERR(vreg_proximity);
		}
	
	vreg_set_level(vreg_proximity, 12); // set to 3.0V voltage 
		vreg_enable(vreg_proximity); // voltage 
	}
	else
	{
		gpio_set_value(VIR_LED_EN, 1);
	}
#endif    
	
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
	{
		printk(KERN_INFO "[GP2A] i2c_check_functionality error\n");
		err = -ENODEV;
		goto exit;
	}
	if ( !i2c_check_functionality(client->adapter,I2C_FUNC_SMBUS_BYTE_DATA) ) {
		printk(KERN_INFO "[GP2A] byte op is not permited.\n");
		goto exit;
	}

	/* OK. For now, we presume we have a valid client. We now create the
	client structure, even though we cannot fill it completely yet. */
	if (!(gp2a = kzalloc(sizeof(struct gp2a_data), GFP_KERNEL)))
	{
		err = -ENOMEM;
		goto exit;
	}
	memset(gp2a, 0, sizeof(struct gp2a_data));
	gp2a->client = client;
	i2c_set_clientdata(client, gp2a);

	opt_i2c_client = client;

	if (i2c_smbus_read_byte(client) < 0)
	{
		printk(KERN_ERR "[GP2A] i2c_smbus_read_byte error!!\n");
		goto exit_kfree;
	}
	else
	{
		printk("GP2A Device detected!\n");
	}

	printk("[%s] slave addr = %x\n", __func__, client->addr);
	
	/* Input device Settings */
	if(USE_INPUT_DEVICE)
	{
		gp2a->input_dev = input_allocate_device();
		if (gp2a->input_dev == NULL) 
		{
			pr_err("Failed to allocate input device\n");
			return -ENOMEM;
		}
		gp2a->input_dev->name = "proximity_sensor";
	
		set_bit(EV_SYN,gp2a->input_dev->evbit);
		set_bit(EV_ABS,gp2a->input_dev->evbit);
		
 	       input_set_abs_params(gp2a->input_dev, ABS_DISTANCE, 0, 1, 0, 0);
		
	
		err = input_register_device(gp2a->input_dev);
		if (err) 
		{
			pr_err("Unable to register %s input device\n", gp2a->input_dev->name);
			input_free_device(gp2a->input_dev);
			kfree(gp2a);
			return -1;
		}

	}

#if USE_INTERRUPT
	/* WORK QUEUE Settings */
	gp2a_wq = create_singlethread_workqueue("gp2a_wq");
	if (!gp2a_wq)
		return -ENOMEM;
	INIT_WORK(&gp2a->work_prox, gp2a_work_func_prox);
	gprintk("Workqueue Settings complete\n");
#endif

	/* misc device Settings */
	err = misc_register(&proximity_device);
	if(err) {
		pr_err(KERN_ERR "misc_register failed - prox \n");
	}

	/* wake lock init */
	wake_lock_init(&prx_wake_lock, WAKE_LOCK_SUSPEND, "prx_wake_lock");

	/* set sysfs for light sensor */
	proxsensor_class = class_create(THIS_MODULE, "proxsensor");
	if (IS_ERR(proxsensor_class))
		pr_err("Failed to create class(proxsensor)!\n");

	switch_cmd_dev = device_create(proxsensor_class, NULL, 0, NULL, "switch_cmd");	
	if (device_create_file(switch_cmd_dev, &dev_attr_proxsensor_file_state) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_proxsensor_file_state.attr.name);
	
	dev_set_drvdata(switch_cmd_dev,gp2a);
	
	/* ktime init */

	timeA = ktime_set(0,0);
	timeB = ktime_set(0,0);
	
	/* gpio config */
	config = GPIO_CFG(GPIO_SENSE_OUT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
	err = gpio_tlmm_config(config, GPIO_CFG_ENABLE);
	if (err) 
		printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n", __func__, GPIO_SENSE_OUT, err);

	/* GP2A Regs INIT SETTINGS */
	for(i=1;i<5;i++)
	{
		opt_i2c_write((u8)(i),&gp2a_original_image[i]);
	}

	mdelay(2);
#if USE_INTERRUPT
	/* INT Settings */	
	irq = gpio_to_irq(GPIO_SENSE_OUT);
	gp2a->irq = -1;
	set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);

	err = request_irq(irq, gp2a_irq_handler, IRQF_DISABLED, "gp2a_int", gp2a);
	if (err)
	{
		printk("[GP2A] request_irq failed for gp2a\n");
		goto exit_kfree;
	}

	printk("[GP2A] register irq = %d\n",irq);
	err = set_irq_wake(irq, 1);
	printk("[GP2A] register wakeup source = %d\n",err);
	if (err) 
		printk("[GP2A] register wakeup source failed\n");
	
	gp2a->irq = irq;
	gprintk("INT Settings complete\n");
#endif
	
	// maintain power-down mode before using sensor
	gp2a_off(gp2a,ALL);
	
//++	// test for sensor 

/*
	printk("[GP2A] curr prox value = %d\n", gpio_get_value(GPIO_SENSE_OUT));
	gp2a_on(gp2a,PROXIMITY);
	printk("[GP2A] curr prox value = %d\n", gpio_get_value(GPIO_SENSE_OUT));
	
//--

	// maintain power-down mode before using sensor
	//ESD test sleep
	gp2a_off(gp2a,ALL);
*/

	printk("gp2a_opt_probe is OK!!\n");
	return 0;
	
exit_kfree:
	kfree(gp2a);
exit:
	return err;
}
Exemplo n.º 24
0
int ts_set_vreg(unsigned char onoff)
{
	if (lge_bd_rev == LGE_REV_A) {
		struct vreg *vreg_touch;
		int rc;

		printk(KERN_INFO "[Touch] %s() onoff:%d\n", __func__, onoff);

		vreg_touch = vreg_get(0, "bt");

		if (IS_ERR(vreg_touch)) {
			printk(KERN_INFO"[Touch] vreg_get fail : touch\n");
			return -EBUSY;
		}

		if (onoff) {
			rc = vreg_set_level(vreg_touch, 2850);
			if (rc != 0) {
				printk(KERN_INFO "[Touch] vreg_set_level failed\n");
				return -EBUSY;
			}
			vreg_enable(vreg_touch);
		} else {
			vreg_disable(vreg_touch);
		}
	} else if (lge_bd_rev >= LGE_REV_B) {
		static struct regulator *ldo1 = NULL;
		int rc;
		static int init = 0;
		ldo1 = regulator_get(NULL, "RT8053_LDO1");
		if (ldo1 == NULL)
			pr_err("%s: regulator_get(ldo1) failed\n", __func__);

		if (onoff) {
			rc = regulator_set_voltage(ldo1, 3000000, 3000000);
			if (rc < 0)
				pr_err(
					"%s: regulator_set_voltage(ldo1) failed\n",
					__func__);

			rc = regulator_enable(ldo1);
			if (rc < 0)
				pr_err(
					"%s: regulator_enable(ldo1) failed\n",
					__func__);

			init = 1;
		} else {
			if (init > 0) {
				rc = regulator_disable(ldo1);
				if (rc < 0)
					pr_err(
						"%s: regulator_disble(ldo1) failed\n",
						__func__);

				regulator_put(ldo1);
			}
		}
	}
	return 0;
}
Exemplo n.º 25
0
static ssize_t misc_helper_write(struct file *fp, const char __user *buf, size_t count, loff_t *pos)
{
	unsigned char cmd[64];
	int len;
	int i, r;
	unsigned int id, val;
	unsigned char *uchar;
	char *soc_baseband_id, *args[10]={0};

	static char bp_version[32]={0};
	static int  bp_taken=0;
	static smem_mot_vendor1_type *vendor1;

	if (count < 1)
		return 0;

	len = count > 63 ? 63 : count;

	if (copy_from_user(cmd, buf, len))
		return -EFAULT;

	cmd[len] = 0;

	/* lazy */
	if (cmd[len-1] == '\n') {
		cmd[len-1] = 0;
		len--;
	}

	if ((r = misc_helper_args (args, cmd, len)) > 0) {
		for (i=0; i < r; i++)
			D(KERN_ERR "ARG[%d] %s\n", i, args[i]);
	}

    if (r == 0)
        return count;

	switch (misc_helper_get_cmd (args[0], r))
	 {
	 case CMD_BP_VER :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		if (! bp_taken) {
			soc_baseband_id = socinfo_get_baseband_id();
			if (soc_baseband_id) {
				strncpy (bp_version, soc_baseband_id, sizeof (bp_version)-1);
				bp_version[31] = 0;
			}else
				strcpy (bp_version, "undefined");
			bp_taken = 1;
		}
		D("%s(): %s\n", misc_helper_cmd_name[CMD_BP_VER], bp_version);
		sprintf (misc_helper_info.data.buffer, "%s", bp_version);
			break;

	 case CMD_AP_FLASH :
		if(!0) {
			misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
			id = PROCCOMM_MODEM_SET_AP_FLASH_REASON;
			val = 0;
			r = meta_proc(id, &val);
			D("%s()=%08x,%08x rc=%d\n", misc_helper_cmd_name[CMD_AP_FLASH], id, val, r);
			sprintf (misc_helper_info.data.buffer, "%u %u", id, val);
		} else
			sprintf (misc_helper_info.data.buffer, "Permissions denied");
			break;

	 case CMD_UUID_HIGH :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		id = 0;
		val = 0;
		r = msm_proc_comm (PCOM_GET_UUID_HIGH, &id, &val);
		D("%s()=%08x,%08x rc=%d\n", misc_helper_cmd_name[CMD_UUID_HIGH], id, val, r);
		uchar = (unsigned char *)&id;
		sprintf (misc_helper_info.data.buffer, "%02x %02x %02x %02x ", *uchar, *uchar+1, *uchar+2, *uchar+3);
		uchar = (unsigned char *)&val;
		sprintf (misc_helper_info.data.buffer+strlen(misc_helper_info.data.buffer),
			 "%02x %02x %02x %02x", *uchar, *uchar+1, *uchar+2, *uchar+3);
			break;

	 case CMD_UUID_LOW :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		id = 0;
		val = 0;
		r = msm_proc_comm (PCOM_GET_UUID_LOW, &id, &val);
		D("%s()=%08x,%08x rc=%d\n", misc_helper_cmd_name[CMD_UUID_LOW], id, val, r);
		uchar = (unsigned char *)&id;
		sprintf (misc_helper_info.data.buffer, "%02x %02x %02x %02x ", *uchar, *uchar+1, *uchar+2, *uchar+3);
		uchar = (unsigned char *)&val;
		sprintf (misc_helper_info.data.buffer+strlen(misc_helper_info.data.buffer),
			 "%02x %02x %02x %02x", *uchar, *uchar+1, *uchar+2, *uchar+3);
			break;

	 case CMD_HELP :
		if (!is_secure_hw()) {
			misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
			misc_helper_usage (args, r);
		} else
			sprintf (misc_helper_info.data.buffer, "Permissions denied");
			break;

	 case CMD_GPIO_GET :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		id = (unsigned)simple_strtoul (args[1], NULL, 10);
		val = gpio_get_value (id);
		D("%s(%u)=%u\n", misc_helper_cmd_name[CMD_GPIO_GET], id, val);
		sprintf (misc_helper_info.data.buffer, "%u", val);
			break;

	 case CMD_BATTERY :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		id = 0;
		val = 0;
		r = msm_proc_comm (PCOM_GET_BATT_LEVEL, &id, &val);
		D("%s()=%u,%u rc=%d\n", misc_helper_cmd_name[CMD_BATTERY], id, val, r);
		sprintf (misc_helper_info.data.buffer, "%u %u", id, val);
			break;

	 case CMD_CHARGING :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		id = 0;
		val = 0;
		r = msm_proc_comm (PCOM_CHG_IS_CHARGING, &id, &val);
		D("%s()=%u,%u rc=%d\n", misc_helper_cmd_name[CMD_CHARGING], id, val, r);
		sprintf (misc_helper_info.data.buffer, "%u %u", id, val);
			break;

	 case CMD_RESET :
		if(!0) { //if (!is_secure_hw()) {
			misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
			id = 0;
			val = 0;
			r = msm_proc_comm (PCOM_RESET_MODEM, &id, &val);
			D("%s()=%u,%u rc=%d\n", misc_helper_cmd_name[CMD_RESET], id, val, r);
			sprintf (misc_helper_info.data.buffer, "%u %u", id, val);
		} else
			sprintf (misc_helper_info.data.buffer, "Permissions denied");
			break;

	 case CMD_CHIP_PWRDN :
		if(!0) { //if (!is_secure_hw()) {
			misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
			id = 0;
			val = 0;
			r = msm_proc_comm (PCOM_POWER_DOWN, &id, &val);
			D("%s()=%u,%u rc=%d\n", misc_helper_cmd_name[CMD_CHIP_PWRDN], id, val, r);
			sprintf (misc_helper_info.data.buffer, "%u %u", id, val);
		} else
			sprintf (misc_helper_info.data.buffer, "Permissions denied");
			break;

	 case CMD_NVREAD :
		if (!0) { //if (!is_secure_hw()) {
			misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
			id = (unsigned)simple_strtoul (args[1], NULL, 10);
			id = (id << 8) | PROCCOMM_NV_READ;
			val = 0;
			r = msm_proc_comm (PCOM_CUSTOMER_CMD3, &id, &val);
			D("%s(0x%08x)=%u rc=%d\n", misc_helper_cmd_name[CMD_NVREAD], id, val, r);
			sprintf (misc_helper_info.data.buffer, "%u %u", id, val);
		} else
			sprintf (misc_helper_info.data.buffer, "Permissions denied");
			break;

	 case CMD_NVWRITE :
		if (!0) { //if (!is_secure_hw()) {
			misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
			id = (unsigned)simple_strtoul (args[1], NULL, 10);
			id = (id << 8) | PROCCOMM_NV_WRITE;
			val = (unsigned)simple_strtoul (args[2], NULL, 10);
			r = msm_proc_comm (PCOM_CUSTOMER_CMD3, &id, &val);
			D("%s(0x%08x, %u) rc=%d\n", misc_helper_cmd_name[CMD_NVWRITE], id, val, r);
			sprintf (misc_helper_info.data.buffer, "%d", r);
		} else
			sprintf (misc_helper_info.data.buffer, "Permissions denied");
			break;

#if 0
	 case CMD_NVR :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		id = (unsigned)simple_strtoul (args[1], NULL, 10);
		val = 0; 
		r = msm_proc_comm (PCOM_NV_READ, &id, &val);
		D("%s(%u)=%u rc=%d\n", misc_helper_cmd_name[CMD_NVR], id, val, r);
		sprintf (misc_helper_info.data.buffer, "%u %u", id, val);
			break;

	 case CMD_NVW :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		id = (unsigned)simple_strtoul (args[1], NULL, 10);
		val = (unsigned)simple_strtoul (args[2], NULL, 10);
		r = msm_proc_comm (PCOM_NV_WRITE, &id, &val);
		D("%s(%u, %u) rc=%d\n", misc_helper_cmd_name[CMD_NVW], id, val, r);
		sprintf (misc_helper_info.data.buffer, "%d", r);
			break;
#endif

	 case CMD_GPIO_SET :
		if (!is_secure_hw()) {
			misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
			id = (unsigned)simple_strtoul (args[1], NULL, 10);
			val = (unsigned)simple_strtoul (args[2], NULL, 10);
			r = gpio_set_value (id, val);
			val = gpio_get_value (id);
			D("%s(%u, %u) rc=%d\n", misc_helper_cmd_name[CMD_GPIO_SET], id, val, r);
			sprintf (misc_helper_info.data.buffer, "%u", val);
		} else
			sprintf (misc_helper_info.data.buffer, "Permissions denied");
			break;

     case CMD_VREG :
	if (!is_secure_hw()) {
           misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
           {
            unsigned int mv = (unsigned)simple_strtoul (args[2], NULL, 10);
            int rc;
            struct vreg *vreg;
            vreg = vreg_get(0,args[1]);
            if (IS_ERR(vreg)) {
                sprintf(misc_helper_info.data.buffer, "* bad name (%s)", args[1]);
                break;
            }
            if (mv > 0) {
                if ((rc = vreg_set_level(vreg, mv))) {
                    sprintf(misc_helper_info.data.buffer, "* failed to set level (%d mV) [%d]", mv, rc);
                    break;
                }
                if ((rc = vreg_enable(vreg))) {
                    sprintf(misc_helper_info.data.buffer, "* failed to enable [%d]", rc);
                    break;
                }
            }
            else {
                if ((rc = vreg_disable(vreg))) {
                    sprintf(misc_helper_info.data.buffer, "* failed to disable [%d]", rc);
                    break;
                }
            }
            D("%s(%s,%d) rc=%d\n", misc_helper_cmd_name[CMD_VREG],args[1],mv,rc);
           }
           sprintf(misc_helper_info.data.buffer, "OK");
	} else
		sprintf (misc_helper_info.data.buffer, "Permissions denied");
        		break;

     case CMD_CLK :
	if (!is_secure_hw()) {
	   misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
	   {
            unsigned int rate = (unsigned)simple_strtoul (args[2], NULL, 10);
            int rc = 0;
            struct clk *clk;
            clk = clk_get(NULL, args[1]);
            if (IS_ERR(clk)) {
                sprintf(misc_helper_info.data.buffer, "* bad name (%s)", args[1]);
                break;
            }
            if (rate > 0) {
                if ((rc = clk_enable(clk))) {
                    sprintf(misc_helper_info.data.buffer, "* failed to enable clk [%d]", rc);
                    break;
                }
                if ((rc = clk_set_rate(clk,rate))) {
                    sprintf(misc_helper_info.data.buffer, "* failed to set rate [%d]", rc);
                    break;
                }
            }
            else {
                clk_disable(clk);
            }
            D("%s(%s,%d) rc=%d\n", misc_helper_cmd_name[CMD_CLK],args[1],rate,rc);
           }
           sprintf(misc_helper_info.data.buffer, "OK");
	} else
		sprintf (misc_helper_info.data.buffer, "Permissions denied");
        		break;

	 case CMD_FB_SET :
		if (!is_secure_hw()) {
			misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
			id = (1 << 8) | PROCCOMM_FACTORY_BYTE;
			val = (unsigned)simple_strtoul (args[1], NULL, 10);
			r = msm_proc_comm (PCOM_CUSTOMER_CMD3, &id, &val);
			D("%s(%u)=%u\n", misc_helper_cmd_name[CMD_FB_SET], id, val);
			sprintf (misc_helper_info.data.buffer, "%u", val);
		} else
			sprintf (misc_helper_info.data.buffer, "Permissions denied");
			break;

	 case CMD_TRUSTED_BOOT :
		if (! vendor1) {
			vendor1 = smem_alloc(SMEM_ID_VENDOR1, sizeof(smem_mot_vendor1_type));
		}
		if (vendor1) {
			r = 0;
			val = (unsigned int)vendor1->trusted_boot;

		} else {
			r = -1;
			val = -1;
		}
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		D("%s(is_boot_trusted)=%u, rc=%d\n", misc_helper_cmd_name[CMD_TRUSTED_BOOT], val, r);
		sprintf (misc_helper_info.data.buffer, "%u", val);
			break;


	 case CMD_SECURE :
		r = 0;
		val = (unsigned int)is_secure_hw();
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		D("%s(is_security_on)=%u, rc=%d\n", misc_helper_cmd_name[CMD_SECURE], val, r);
		sprintf (misc_helper_info.data.buffer, "%u", val);
			break;


	 case CMD_FB_GET :
		if (! vendor1) {
			vendor1 = smem_alloc(SMEM_ID_VENDOR1, sizeof(smem_mot_vendor1_type));
		}
		if (vendor1) {
			r = 0;
			val = (unsigned int)vendor1->fact_byte;

		} else {
			r = -1;
			val = -1;
		}
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		D("%s(10024)=%u, rc=%d\n", misc_helper_cmd_name[CMD_FB_GET], val, r);
		sprintf (misc_helper_info.data.buffer, "%u", val);
			break;

	 case CMD_MAX :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF;
		sprintf (misc_helper_info.data.buffer, "missing parameters for command: %s", args[0]);
			break;
	 default :
		misc_helper_info.response |= MH_RESP_REQUIRED | MH_RESP_READY | MH_RESP_FMT_BUFF; 
		sprintf (misc_helper_info.data.buffer, "command: %s is not supported", cmd);
	}
	return count;
}
static int cypress_cpt_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    int ret = 0;
    int j = 0;
    
#ifdef CONFIG_CYPRESS_1044_UPDATE_TS_FIRMWARE 
    static char version[10];
    int firmware_id;
#endif

    int gpio_config;

    if(machine_is_msm7x27_c8800())
    { 
        lcd_x = LCD_X_WVGA;
        lcd_y = LCD_Y_WVGA;
        v_key_h = VIRTUAL_KEYS_H_WVGA;
    }
    else
    {
        lcd_x = LCD_X_HVGA;
        lcd_y = LCD_Y_HVGA;   
        v_key_h = VIRTUAL_KEYS_H_HVGA;
    }

	gpio_config = GPIO_CFG(29, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA);
	ret = gpio_tlmm_config(gpio_config, GPIO_CFG_ENABLE);
    if(ret)
    {
       printk(KERN_ERR "GPIO_CFG failed\n");
    }

	/* power on touchscreen */   
    struct vreg *v_gp5 = NULL;
    v_gp5 = vreg_get(NULL,"gp5");

    ret = IS_ERR(v_gp5);
    if(ret)
    {
       goto err_power_failed;
    }
    
    ret = vreg_set_level(v_gp5,2700);
    ret = vreg_enable(v_gp5);
    msleep(200);

    struct cypress_cpt_ts_data *ts = NULL;

#if defined (CONFIG_CYPRESS_TOUCHSCREEN_GESTURE) || defined (CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY)
    int i;
#endif

    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 
    {
    	printk(KERN_ERR "cypress_cpt_ts_probe: need I2C_FUNC_I2C\n");
    	ret = -ENODEV;
    	goto err_check_functionality_failed;
    }

    cypress_ts_power_on_reset(client);	

    /* detect make sure the client really exists  */
    for( j = 5;  j > 0;  j-- )
    {
    	ret = i2c_smbus_read_byte_data(client, 0x00);
    	if ( ret >= 0 ) 
        {
            break;
        }
    	msleep(10);
    }
    if( j <= 0 )
    {
        goto err_i2c_read_failed;
    }
    
#ifdef CONFIG_CYPRESS_1044_UPDATE_TS_FIRMWARE     
    g_client = client;      
    for (i = 0 ; i < 3; i++) 
    {
    	ret= ts_firmware_file();   
    	if (!ret)
    	    break;
    }
#endif

    cypress_cpt_wq = create_singlethread_workqueue("cypress_cpt_wq");
    if (!cypress_cpt_wq)
    {
        printk(KERN_ERR "%s: create_singlethread_workqueue failed\n",  __FUNCTION__);
    	goto err_work_init_failed;
    }
    ts = kzalloc(sizeof(*ts), GFP_KERNEL);
    if (ts == NULL) 
    {
    	ret = -ENOMEM;
    	goto err_alloc_data_failed;
    }
    INIT_WORK(&ts->work, cypress_cpt_ts_work_func);
    ts->client = client;
    i2c_set_clientdata(client, ts);
    ts->input_dev = input_allocate_device();
    if (ts->input_dev == NULL) 
    {
    	ret = -ENOMEM;
    	printk(KERN_ERR "cypress_cpt_ts_probe: Failed to allocate input device\n");
    	goto err_input_dev_alloc_failed;
    }
    if(client->flags)
    {
        muti_touch = TRUE;
        i2c_read_len = I2C_MUTI_READ_LEN;
    }
    else
    {
        muti_touch = FALSE;
        i2c_read_len = I2C_SNGL_READ_LEN;
    }
    
#ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY	
    ts->input_extra_dev = input_allocate_device();
    if(ts->input_extra_dev == NULL) 
    {
	    ret = -ENOMEM;
	    printk(KERN_ERR"%s: Failed to allocate input extra device \n", __FUNCTION__ );
	    goto err_input_dev_alloc_failed;
	}
#endif
	  
	ts->input_dev->name = "cypress_cpt";
	set_bit(EV_SYN, ts->input_dev->evbit);
	set_bit(EV_ABS, ts->input_dev->evbit);
    set_bit(EV_KEY, ts->input_dev->evbit);
    set_bit(BTN_TOUCH, ts->input_dev->keybit);
	set_bit(ABS_X, ts->input_dev->absbit);
	set_bit(ABS_Y, ts->input_dev->absbit);
    set_bit(KEY_NUMLOCK, ts->input_dev->keybit);

    /* single or mutil touch both set as this */
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X,0,lcd_x, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, lcd_y-v_key_h, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);  

#ifdef CONFIG_CYPRESS_TOUCHSCREEN_GESTURE		
	set_bit(EV_GESTURE, ts->input_dev->evbit);
	for (i = GESTURE_NO_GESTURE; i < GESTURE_MAX; i++)
	    set_bit(i, ts->input_dev->gesturebit);	
#endif	/*CONFIG_CYPRESS_TOUCHSCREEN_GESTURE*/

	/* query version number */
#ifdef CONFIG_CYPRESS_1044_UPDATE_TS_FIRMWARE 
	ts->input_dev->uniq = version;
	firmware_id = i2c_smbus_read_byte_data(g_client, 0x0c);
	version[0] = (firmware_id / 16) + '0';
	version[1] = '.';
	version[2] = (firmware_id % 16) + '0';
	version[3] = '\0'; 
#endif 

	ret = input_register_device(ts->input_dev);
	if (ret) 
    {
	    printk(KERN_ERR "cypress_cpt_ts_probe: Unable to register %s input device\n", ts->input_dev->name);
	    goto err_input_register_device_failed;
	}

#ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY
	ts->input_extra_dev->name ="cypress extra key";
	set_bit(EV_KEY, ts->input_extra_dev->evbit);

	for(i =0; i < MAX_EXTRA_TOUCH_KEY; i++)
	{
	    set_bit(touch_extra_key_region.touch_extra_key[i].keycode&KEY_MAX,  ts->input_extra_dev->keybit);
	}

	ret = input_register_device(ts->input_extra_dev);
	if(ret)
	{
	    printk(KERN_ERR"%s: Unable to register input device %s", __FUNCTION__, ts->input_extra_dev->name);
	    goto err_input_register_extra_device_failed;
	}
#endif 
			 
	ret = gpio_request(29, "gpio 29 for touch");
	if(ret)
	    printk("%s: request gpio %d failed!\n", __FUNCTION__, client->irq);
	
	ret = gpio_direction_input(29);
	if (ret)
	    printk("touchscreen gpio 45 direction input error!\n");

	if (client->irq)
	{
	    printk(KERN_ERR "%s@%d: cypress_cpt_ts_probe\n", __FILE__,__LINE__);
	    ret = request_irq(client->irq, cypress_cpt_ts_irq_handler, IRQF_TRIGGER_FALLING, client->name, ts);
	    if (ret == 0)
		ts->use_irq = 1;
	    else
		printk("cypress_cpt_ts_probe: request_irq %d failed\n", client->irq);
	}
	if (!ts->use_irq) 
    {
	    printk("cypress use timer-based polling\n ");
	    hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	    ts->timer.function = cypress_cpt_ts_timer_func;
	    hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ts->early_suspend.suspend = cypress_cpt_ts_early_suspend;
	ts->early_suspend.resume = cypress_cpt_ts_late_resume;
	register_early_suspend(&ts->early_suspend);
#endif

	CYPRESS_DEBUG(KERN_INFO "cpt_ts_probe: Start touchscreen %s in %s mode\n", ts->input_dev->name, ts->use_irq ? "interrupt" : "polling");
	
	return 0;
#ifdef CONFIG_CYPRESS_TOUCHSCREEN_1044_EXTRA_KEY
    err_input_register_extra_device_failed:
	input_free_device(ts->input_extra_dev);
#endif
    err_input_register_device_failed:
	input_free_device(ts->input_dev);
    err_input_dev_alloc_failed:
	kfree(ts);	
    err_alloc_data_failed:
    err_work_init_failed:
    err_i2c_read_failed:
    if(NULL != v_gp5)
	{
        ret = vreg_disable(v_gp5);
	}
    err_power_failed:
    err_check_functionality_failed:
	return ret;
}
static void msm_camera_vreg_enable(struct platform_device *pdev)
{
	vreg_gp2 = vreg_get(NULL, "gp2");
	if (IS_ERR(vreg_gp2)) {
		pr_err("%s: VREG GP2 get failed %ld\n", __func__,
			PTR_ERR(vreg_gp2));
		vreg_gp2 = NULL;
		return;
	}

	if (vreg_set_level(vreg_gp2, 2600)) {
		pr_err("%s: VREG GP2 set failed\n", __func__);
		goto gp2_put;
	}

	if (vreg_enable(vreg_gp2)) {
		pr_err("%s: VREG GP2 enable failed\n", __func__);
		goto gp2_put;
	}

	vreg_lvsw1 = vreg_get(NULL, "lvsw1");
	if (IS_ERR(vreg_lvsw1)) {
		pr_err("%s: VREG LVSW1 get failed %ld\n", __func__,
			PTR_ERR(vreg_lvsw1));
		vreg_lvsw1 = NULL;
		goto gp2_disable;
		}
	if (vreg_set_level(vreg_lvsw1, 1800)) {
		pr_err("%s: VREG LVSW1 set failed\n", __func__);
		goto lvsw1_put;
	}
	if (vreg_enable(vreg_lvsw1)) {
		pr_err("%s: VREG LVSW1 enable failed\n", __func__);
		goto lvsw1_put;
	}

	if (!strcmp(pdev->name, "msm_camera_sn12m0pz")) {
		vreg_gp6 = vreg_get(NULL, "gp6");
		if (IS_ERR(vreg_gp6)) {
			pr_err("%s: VREG GP6 get failed %ld\n", __func__,
				PTR_ERR(vreg_gp6));
			vreg_gp6 = NULL;
			goto lvsw1_disable;
		}

		if (vreg_set_level(vreg_gp6, 3050)) {
			pr_err("%s: VREG GP6 set failed\n", __func__);
			goto gp6_put;
		}

		if (vreg_enable(vreg_gp6)) {
			pr_err("%s: VREG GP6 enable failed\n", __func__);
			goto gp6_put;
		}
		vreg_gp16 = vreg_get(NULL, "gp16");
		if (IS_ERR(vreg_gp16)) {
			pr_err("%s: VREG GP16 get failed %ld\n", __func__,
				PTR_ERR(vreg_gp16));
			vreg_gp16 = NULL;
			goto gp6_disable;
		}

		if (vreg_set_level(vreg_gp16, 1200)) {
			pr_err("%s: VREG GP16 set failed\n", __func__);
			goto gp16_put;
		}

		if (vreg_enable(vreg_gp16)) {
			pr_err("%s: VREG GP16 enable failed\n", __func__);
			goto gp16_put;
		}
	}
	return;

gp16_put:
	vreg_put(vreg_gp16);
	vreg_gp16 = NULL;
gp6_disable:
	 vreg_disable(vreg_gp6);
gp6_put:
	vreg_put(vreg_gp6);
	vreg_gp6 = NULL;
lvsw1_disable:
	vreg_disable(vreg_lvsw1);
lvsw1_put:
	vreg_put(vreg_lvsw1);
	vreg_lvsw1 = NULL;
gp2_disable:
	vreg_disable(vreg_gp2);
gp2_put:
	vreg_put(vreg_gp2);
	vreg_gp2 = NULL;
}
static int synaptics_ts_probe(
		struct i2c_client *client, const struct i2c_device_id *id)
{
	struct synaptics_ts_data *ts;
	int ret = 0;
	struct vreg *vreg_touch;
	uint8_t i2c_addr = 0x1B;
	uint8_t buf_tmp[3]={0,};

	HW_ver = 0;
	SW_ver = 0;

	printk("[TSP] %s, %d\n", __func__, __LINE__ );

	vreg_touch = vreg_get(NULL, "ldo6");
	ret = vreg_set_level(vreg_touch, OUT3000mV);
	if (ret) {
		printk(KERN_ERR "%s: vreg set level failed (%d)\n",
				__func__, ret);
		return -EIO;
	}

	ret = vreg_enable(vreg_touch);
	if (ret) {
		printk(KERN_ERR "%s: vreg enable failed (%d)\n",
				__func__, ret);
		return -EIO;
	}

	msleep(700);

	ts = kzalloc(sizeof(*ts), GFP_KERNEL);
	if (ts == NULL) {
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}
	INIT_WORK(&ts->work, synaptics_ts_work_func);
	INIT_DELAYED_WORK(&ts->work_check_ic, check_ic_work_func );
	schedule_delayed_work(&ts->work_check_ic, CHECK_TIME );

	ts->client = client;
	i2c_set_clientdata(client, ts);

	ts_global = ts;

	ts->input_dev = input_allocate_device();
	if (ts->input_dev == NULL) {
		ret = -ENOMEM;
			touch_present = 0;
		printk(KERN_ERR "synaptics_ts_probe: Failed to allocate input device\n");
		goto err_input_dev_alloc_failed;
	}
	ts->input_dev->name = "sec_touchscreen";
	set_bit(EV_SYN, ts->input_dev->evbit);
	set_bit(EV_KEY, ts->input_dev->evbit);
	set_bit(BTN_TOUCH, ts->input_dev->keybit);
	set_bit(EV_ABS, ts->input_dev->evbit);

	printk(KERN_INFO "synaptics_ts_probe: max_x: 240, max_y: 320\n");
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, MAX_X, 0, 0);	//0, MAX_X, 0, 0
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, MAX_Y, 0, 0);	//0, MAX_Y, 0, 0
	input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);

	/* ts->input_dev->name = ts->keypad_info->name; */
	ret = input_register_device(ts->input_dev);
	if (ret) {
			touch_present = 0;
		printk(KERN_ERR "synaptics_ts_probe: Unable to register %s input device\n", ts->input_dev->name);
		goto err_input_register_device_failed;
	}
	printk("[TSP] %s, irq=%d\n", __func__, client->irq );

	if (client->irq) {
		ret = request_irq(client->irq, synaptics_ts_irq_handler,/* IRQF_TRIGGER_RISING |*/ IRQF_TRIGGER_FALLING , client->name, ts);
		if (ret == 0) 
			ts->use_irq = 1;
		else
			dev_err(&client->dev, "request_irq failed\n");
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ts->early_suspend.suspend = synaptics_ts_early_suspend;
	ts->early_suspend.resume = synaptics_ts_late_resume;
	register_early_suspend(&ts->early_suspend);
#endif

	printk(KERN_INFO "synaptics_ts_probe: Start touchscreen %s in %s mode\n", ts->input_dev->name, ts->use_irq ? "interrupt" : "polling");

	/* sys fs */
	touch_class = class_create(THIS_MODULE, "touch");
	if (IS_ERR(touch_class))
		pr_err("Failed to create class(touch)!\n");

	firmware_dev = device_create(touch_class, NULL, 0, NULL, "firmware");
	if (IS_ERR(firmware_dev))
		pr_err("Failed to create device(firmware)!\n");

	if (device_create_file(firmware_dev, &dev_attr_firmware) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_firmware.attr.name);
	if (device_create_file(firmware_dev, &dev_attr_firmware_ret) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_firmware_ret.attr.name);
	/* sys fs */

	/* Check point - i2c check - start */
	ret = tsp_i2c_read( i2c_addr, buf_tmp, sizeof(buf_tmp));
	HW_ver = buf_tmp[1];
	SW_ver = buf_tmp[2];

	if (ret <= 0) {
		printk(KERN_ERR "i2c_transfer failed\n");
		ret = tsp_i2c_read( i2c_addr, buf_tmp, sizeof(buf_tmp));

		if (ret <= 0) 
		{
			disable_irq(ts_global->client->irq);
			cancel_delayed_work_sync(&ts_global->work_check_ic);
			touch_present = 0;
			printk("[TSP] %s, ln:%d, Failed to register TSP!!!\n\tcheck the i2c line!!!, ret=%d\n", __func__,__LINE__, ret);
			goto err_check_functionality_failed;
		}
	}
	/* Check point - i2c check - end */
	printk("[TSP] %s, ver CY=%x\n", __func__ , buf_tmp[0] );
	printk("[TSP] %s, ver HW=%x\n", __func__ , buf_tmp[1] );
	printk("[TSP] %s, ver SW=%x\n", __func__ , buf_tmp[2] );

	touch_present = 1;
	/* Check point - Firmware */
	printk("[TSP] %s:%d, ver SW=%x, HW=%x\n", __func__, __LINE__,  SW_ver, HW_ver);

	printk("[TSP] Here - Deleted Firmware Check Routine \n");
#if 0
	switch( (HW_ver+1)/10 ){
		case 0:		//Degitech
			if(HW_ver < Digi_HEX_HW_VER){	//Firmware Update
				firm_update();
			}else if((SW_ver<Digi_HEX_SW_VER)||((SW_ver&0xF0)==0xF0)||(SW_ver==0)){
				printk("[TSP] firm_update START!!, ln=%d\n",__LINE__);
				firm_update();
			}else{
				printk("[TSP] Firmware Version(Digitech) is Up-to-date.\n");
			}break;	
		case 1:		//SMAC
			if(HW_ver < SMAC_HEX_HW_VER){	//Firmware Update
				firm_update();
			}else if((SW_ver<SMAC_HEX_SW_VER)||((SW_ver&0xF0)==0xF0)||(SW_ver==0)){
				printk("[TSP] firm_update START!!, ln=%d\n",__LINE__);
				firm_update();
			}else{
				printk("[TSP] Firmware Version(SMAC) is Up-to-date.\n");
			}break;	
		case 2:	;	//
	}
#endif

	printk(KERN_INFO "synaptics_ts_probe: Manufacturer ID: %x, HW ver=%x, SW ver=%x\n", buf_tmp[0], buf_tmp[1], buf_tmp[2]);

	/* Check point - Firmware */

	return 0;

err_input_register_device_failed:
	input_free_device(ts->input_dev);

err_input_dev_alloc_failed:
	kfree(ts);
err_alloc_data_failed:
err_check_functionality_failed:
	return ret;
}
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;
};
Exemplo n.º 30
0
static int proximity_sensor_probe(struct platform_device *pdev)
{
#if 1
		vreg_proximity = vreg_get(0, "ruim");
		vreg_set_level(vreg_proximity, 2800);
		vreg_enable(vreg_proximity);
#endif

	struct proximity_platform_data *proximity = pdev->dev.platform_data;
	printk(KERN_ERR"%s: enter, irq=%d\n", __func__, gpio_to_irq(proximity->intr));
	int err = 0;
	if (err < 0)
		printk(KERN_ERR"%s: gpio_direction_input failed\n", __func__);

	err = gpio_request(proximity->enable, "proximity_sensor");
	if (err < 0)
		printk(KERN_ERR"%s: gpio_request failed\n", __func__);

	err = gpio_direction_output(proximity->enable, 1);
	if (err < 0)
		printk(KERN_ERR"%s: gpio_direction_input failed\n", __func__);

	err = gpio_request(proximity->intr, "proximity_sensor");
	if (err < 0)
		printk(KERN_ERR"%s: gpio_request failed\n", __func__);

	err = gpio_direction_input(proximity->intr);
	if (err < 0)
		printk(KERN_ERR"%s: gpio_direction_input failed\n", __func__);

	proximity->input_dev = input_allocate_device();

	if (!proximity->input_dev) {
		err = -ENOMEM;
		printk(KERN_ERR"%s: Failed to allocate input device\n", __func__);
	}
	set_bit(EV_ABS, proximity->input_dev->evbit);
	input_set_abs_params(proximity->input_dev, ABS_DISTANCE, 0, 1, 0, 0);

	proximity->input_dev->name = "proximity";

	err = input_register_device(proximity->input_dev);

	err = request_irq(gpio_to_irq(proximity->intr), proximity_interrupt, IRQF_TRIGGER_LOW|IRQF_TRIGGER_HIGH,
				  "proximity", proximity);
	if (err < 0)
		printk(KERN_ERR"%s: request irq failed, proximity: %p\n", __func__, proximity);

	err = misc_register(&proximity_device);
	if (err)
		printk(KERN_ERR "%s: misc register failed\n", __func__);

#if 0
	vreg_proximity = vreg_get(0, "ruim");
	vreg_set_level(vreg_proximity, 2800);
	vreg_enable(vreg_proximity);
#endif
	proximity->early_suspend_proximity.suspend = proximity_early_suspend;
	proximity->early_suspend_proximity.resume = proximity_early_resume;
	register_early_suspend(&proximity->early_suspend_proximity);

	err = device_create_file(&pdev->dev, &dev_attr_proximity);
	if (err)
		printk(KERN_ERR"%s: device_create_file failed\n", __func__);
	this_proximity = proximity;

	return 0;
}