Exemplo n.º 1
0
void msm7x27a_wifi_power(bool on)
{

	int rc = 0, index = 0;
	static int resultFlag = 0, flag = 1;

	for (index = 0; index < ARRAY_SIZE(vreg_info); index++) {
		vreg_info[index].vreg = vreg_get(NULL,
						vreg_info[index].vreg_id);
		if (IS_ERR(vreg_info[index].vreg)) {
			pr_err("%s:%s vreg get failed %ld\n",
				__func__, vreg_info[index].vreg_id,
				PTR_ERR(vreg_info[index].vreg));
			rc = PTR_ERR(vreg_info[index].vreg);
			if (on)
				goto vreg_fail;
			else
				continue;
		}
	
		if (on) {
			rc = vreg_set_level(vreg_info[index].vreg,
					 vreg_info[index].vreg_level);
			if (rc) {
				pr_err("%s:%s vreg set level failed %d\n",
					__func__, vreg_info[index].vreg_id, rc);
				goto vreg_fail;
			}

			rc = vreg_enable(vreg_info[index].vreg);
			if (rc) {
				pr_err("%s:%s vreg enable failed %d\n",
					__func__,
					vreg_info[index].vreg_id, rc);
				goto vreg_fail;
			}

			if (vreg_info[index].is_vreg_pin_controlled) {
				rc = pmapp_vreg_lpm_pincntrl_vote(id,
					 vreg_info[index].pmapp_id,
					 PMAPP_CLOCK_ID_A0, 1);
				if (rc) {
					pr_err("%s:%s pmapp_vreg_lpm_pincntrl_vote"
						" for enable failed %d\n",
						__func__,
						vreg_info[index].vreg_id, rc);
					goto vreg_fail;
				}
			} 
		

                        if (index == WLAN_VREG_L17)
                                usleep(5);
                        else if (index == WLAN_VREG_L19)
                                usleep(10);
                        
			printk("\n vote for %s vreg. \n",vreg_info[index].vreg_id);

		} else {
			if (vreg_info[index].is_vreg_pin_controlled) {
				rc = pmapp_vreg_lpm_pincntrl_vote(id,
						 vreg_info[index].pmapp_id,
						 PMAPP_CLOCK_ID_A0, 0);
				if (rc) {
					pr_err("%s:%s pmapp_vreg_lpm_pincntrl_vote"
						" for disable failed %d\n",
						__func__,
						vreg_info[index].vreg_id, rc);
				}
			} 
			rc = vreg_disable(vreg_info[index].vreg);
			if (rc) {
				pr_err("%s:%s vreg disable failed %d\n",
					__func__,
					vreg_info[index].vreg_id, rc);
			}
	
                        printk("\n vote against %s vreg. \n",vreg_info[index].vreg_id);
		}
	}

	if (on) {
                rc = gpio_request(WLAN_GPIO_EXT_POR_N, "WLAN_DEEP_SLEEP_N");
                if (rc) {
                        pr_err("WLAN reset GPIO %d request failed %d\n",
                        WLAN_GPIO_EXT_POR_N, rc);
                        goto fail;
                }
		if(flag)
		{
			flag=0;
	                rc = gpio_direction_output(WLAN_GPIO_EXT_POR_N, 1);
        	        if (rc < 0) {
	        	        pr_err("WLAN reset GPIO %d set direction failed %d\n",
	                	WLAN_GPIO_EXT_POR_N, rc);
		                goto fail_gpio_dir_out;
        	        }
		}

#ifdef	A0_CLOCK 
                rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_ON);
		printk("\nVote for A0 clock done\n");

		rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_PIN_CTRL);
                if (rc) {
                         pr_err("%s: Configuring A0 clock to Pin controllable failed %d\n",
                                    __func__, rc);
                }
#else

                rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0, PMAPP_CLOCK_VOTE_OFF);
		 printk("\nVote against A0 clock done\n");
#endif
                if (rc) {
                        pr_err("%s: Configuring A0 to turn off"
                        " failed %d\n", __func__, rc);
                } 
                printk("\n vote for WLAN GPIO 134 done. \n");

	} else {

		if(!resultFlag){
                	gpio_set_value_cansleep(WLAN_GPIO_EXT_POR_N, 0); 
			rc = gpio_direction_input(WLAN_GPIO_EXT_POR_N);
			if (rc) {
                	        pr_err("WLAN reset GPIO %d set direction failed %d\n",
                        	WLAN_GPIO_EXT_POR_N, rc);
                	}
	                gpio_free(WLAN_GPIO_EXT_POR_N);
        	        printk("\n vote against WLAN GPIO 134 done. \n");
		}
		rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A0,
 					PMAPP_CLOCK_VOTE_OFF);
 		if (rc) {
 			pr_err("%s: Configuring A0 to turn OFF"
 			" failed %d\n", __func__, rc);
 		}
	}

	printk("Interface %s success \n",on?"initialization":"deinitialization");
	resultFlag = 0;
	return;

fail_gpio_dir_out:
	gpio_free(WLAN_GPIO_EXT_POR_N);
vreg_fail:
	index--;
	while (index > 0) {
		rc = vreg_disable(vreg_info[index].vreg);
		if (rc) {
			pr_err("%s:%s vreg disable failed %d\n",
				__func__, vreg_info[index].vreg_id, rc);
		}
		index--;
	}
	if (!on)
		goto fail;
fail:
	resultFlag = 1;
        printk("Interface %s failed \n",on?"initialization":"deinitialization");
	return;
}
Exemplo n.º 2
0
int vision_init_panel(void)
{
  int ret = 0;

  printk(KERN_ERR "%s: Sony=%d Samsung=%d Other=%d\n", __func__, is_sony_panel(), panel_type == SAMSUNG_PANEL, panel_type != SAMSUNG_PANEL && !is_sony_panel());

  vreg_ldo12 = vreg_get(NULL, "gp9");
  if (IS_ERR(vreg_ldo12)) {
    pr_err("%s: gp9 vreg get failed (%ld)\n",
           __func__, PTR_ERR(vreg_ldo12));
    return -1;
  }
  ret = vreg_set_level(vreg_ldo12, 2850);
  if (ret) {
    pr_err("%s: vreg LDO12(gp9) set level failed (%d)\n",
           __func__, ret);
    return -1;
  }

  vreg_ldo19 = vreg_get(NULL, "wlan2");
  if (IS_ERR(vreg_ldo19)) {
    pr_err("%s: wlan2 vreg get failed (%ld)\n",
           __func__, PTR_ERR(vreg_ldo19));
    return -1;
  }
  vreg_ldo20 = vreg_get(NULL, "gp13");

  if (IS_ERR(vreg_ldo20)) {
    pr_err("%s: gp13 vreg get failed (%ld)\n",
           __func__, PTR_ERR(vreg_ldo20));
    return -1;
  }

  ret = vreg_set_level(vreg_ldo19, 1800);
  if (ret) {
    pr_err("%s: vreg LDO19 set level failed (%d)\n",
           __func__, ret);
    return -1;
  }

  resources_msm_fb[0].start = msm_fb_base;
  resources_msm_fb[0].end = msm_fb_base + MSM_FB_SIZE - 1;

  if(is_samsung_panel())
    ret = vreg_set_level(vreg_ldo20, 2850);
  else
    ret = vreg_set_level(vreg_ldo20, 2600);
  if (ret) {
    pr_err("%s: vreg LDO20 set level failed (%d)\n",
           __func__, ret);
    return -1;
  }

  if (is_sony_panel()) {
    ret = platform_device_register(&sonywvga_panel);
    printk(KERN_ERR "%s: registered sony panel: %d\n", __func__, ret);
  } else if (panel_type == SAMSUNG_PANEL) {
    ret = platform_device_register(&amoled_panel[0]);
    printk(KERN_ERR "%s: registered amoled panel[0]: %d\n", __func__, ret);
  } else {
    ret = platform_device_register(&amoled_panel[1]);
    printk(KERN_ERR "%s: registered amoled panel[1]: %d\n", __func__, ret);
  }
  return ret;
}
void msm_camio_disable(struct platform_device *pdev)
{
	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
	struct msm_camera_device_platform_data *camdev = sinfo->pdata;

#if defined(CONFIG_MACH_EUROPA)//PGH
        struct vreg *vreg_cam_out8;
        struct vreg *vreg_cam_out9;
        struct vreg *vreg_cam_out4;
#endif//PGH

	iounmap(mdcbase);
	release_mem_region(camio_ext.mdcphy, camio_ext.mdcsz);
	iounmap(appbase);
	release_mem_region(camio_ext.appphy, camio_ext.appsz);

	camdev->camera_gpio_off();

#if defined(CONFIG_MACH_COOPER)
	/* CAM STANDBY(GPIO 37) set to LOW */
	//gpio_set_value(37, 0);
	//msleep(15);
	/* CAM RESET(GPIO 0) set to LOW */
	gpio_set_value(0, 0);  
	msleep(1);
#endif
#if defined(CONFIG_MACH_CALLISTO) || defined(CONFIG_MACH_BENI) || defined(CONFIG_MACH_TASS)
	/* CAM STANDBY(GPIO 37) set to LOW */
	//gpio_set_value(37, 0);
	//msleep(15);
	/* CAM RESET(GPIO 0) set to LOW */
	gpio_set_value(0, 0);  
	msleep(1);
#endif
#if defined(CONFIG_MACH_EUROPA)
	gpio_set_value(0, 0);//RESET	
	mdelay(10);
#endif

	msm_camio_clk_disable(CAMIO_VFE_CLK);
	msm_camio_clk_disable(CAMIO_MDC_CLK);
	msm_camio_clk_disable(CAMIO_VFE_MDC_CLK);

#if defined(CONFIG_MACH_COOPER)
	msleep(1);

	cam_pw(0);//PCAM
#elif defined(CONFIG_MACH_CALLISTO) || defined(CONFIG_MACH_BENI) || defined(CONFIG_MACH_TASS)
	msleep(1);

	gpio_set_value(1, 0);//STBY
	mdelay(1);

	cam_pw(0);//PCAM
#elif defined(CONFIG_MACH_EUROPA)
	mdelay(1);

	gpio_set_value(1, 0);//STBY
	mdelay(1);



        vreg_cam_out8 = vreg_get(NULL, "ldo8");
        vreg_cam_out9 = vreg_get(NULL, "ldo9");
        vreg_cam_out4 = vreg_get(NULL, "ldo4");



	vreg_disable(vreg_cam_out9);
	vreg_disable(vreg_cam_out8);
	vreg_disable(vreg_cam_out4);	
#endif
}
Exemplo n.º 4
0
/* EVT1.5 */
static int evt1_5_board_init(struct ara_board_info *board_info) {
    int rc;

    /*
     * VSYS and VCHG are active high with a pull-up.
     * Initialize these lines as output low to prevent any spurious
     * activation at boot time.
     */
    gpio_direction_out(VSYS_EN1_N, 0);
    gpio_direction_out(VSYS_EN2_N, 0);
    gpio_direction_out(VSYS_EN3A_N, 0);
    gpio_direction_out(VSYS_EN3B_N, 0);
    gpio_direction_out(VSYS_EN4A_N, 0);
    gpio_direction_out(VSYS_EN4B_N, 0);
    gpio_direction_out(VSYS_EN5_N, 0);
    gpio_direction_out(VCHG_EN1_N, 0);
    gpio_direction_out(VCHG_EN2_N, 0);
    gpio_direction_out(VCHG_EN3A_N, 0);
    gpio_direction_out(VCHG_EN3B_N, 0);
    gpio_direction_out(VCHG_EN4A_N, 0);
    gpio_direction_out(VCHG_EN4B_N, 0);
    gpio_direction_out(VCHG_EN5_N, 0);

    /* For now, just always enable REFCLK_MAIN and the buffers. */
    rc = vreg_config(&refclk_main_vreg) || vreg_get(&refclk_main_vreg);
    if (rc) {
        dbg_error("%s: can't start REFCLK_MAIN: %d\n", __func__, rc);
        return ERROR;
    }

    /* Configure Switch Standby Boot line */
    stm32_configgpio(SW_STANDBY_N);

    /* Configure the switch power supply lines. */
    rc = vreg_config(&sw_vreg);
    if (rc) {
        dbg_error("%s: can't configure switch regulators: %d\n", __func__, rc);
        return ERROR;
    }
    stm32_configgpio(evt1_5_board_info.sw_data.gpio_reset);
    up_udelay(POWER_SWITCH_OFF_STAB_TIME_US);

    /* Configure the wake/detect lines. */
    stm32_configgpio(WD_1_DET_IN_GPIO);
    stm32_configgpio(WD_2_DET_IN_GPIO);
    stm32_configgpio(WD_3A_DET_IN_GPIO);
    stm32_configgpio(WD_3B_DET_IN_GPIO);
    stm32_configgpio(WD_4A_DET_IN_GPIO);
    stm32_configgpio(WD_4B_DET_IN_GPIO);
    stm32_configgpio(WD_5_DET_IN_GPIO);
    stm32_configgpio(WD_8A_DET_IN_GPIO);
    stm32_configgpio(WD_8B_DET_IN_GPIO);

    /* Configure the module release pins */
    stm32_configgpio(MOD_RELEASE_1_CONFIG);
    stm32_configgpio(MOD_RELEASE_2_CONFIG);
    stm32_configgpio(MOD_RELEASE_3A_CONFIG);
    stm32_configgpio(MOD_RELEASE_3B_CONFIG);
    stm32_configgpio(MOD_RELEASE_4A_CONFIG);
    stm32_configgpio(MOD_RELEASE_4B_CONFIG);
    stm32_configgpio(MOD_RELEASE_5_CONFIG);

    /* Configure ARA key input pin */
    stm32_configgpio(ARA_KEY_CONFIG);

    /*
     * (Module hotplug pins unconfigured. TODO, part of SW-1942.)
     */

    /* Configure AP Wake from OFF pin */
    gpio_set_value(PM_CBL_PWR_N_GPIO, 1);
    gpio_direction_out(PM_CBL_PWR_N_GPIO, 1);

    return 0;
}
/*
 * In boot loader, mddi is powered on already.
 *
 * So, we just detect panel here, setting different
 * power function for each panel.
 *
 * Then we did not have to detect panel in each time
 * mddi_client_power or panel_power is called.
 *
 * jay: Nov 20, 08'
 */
int __init chacha_init_panel(void)
{
	int rc;
	int panel_type = 0;
	int panel_id = -1;
	int gpio_lcd_id0, gpio_lcd_id1;
	uint32_t config;
	struct panel_data *panel_data = &renesas_AUO_client_data.panel_conf;
	struct msm_mddi_client_data *client = renesas.client_data;

	B(KERN_INFO "%s: enter.\n", __func__);

	vreg_lcm_2v6 = vreg_get(0, "gp4");
	if (IS_ERR(vreg_lcm_2v6))
		return PTR_ERR(vreg_lcm_2v6);

	vreg_lcm_2v85 = vreg_get(0, "rfrx2");
	if (IS_ERR(vreg_lcm_2v85))
		return PTR_ERR(vreg_lcm_2v85);

	gpio_lcd_id0 =  PCOM_GPIO_CFG(CHACHA_GPIO_LCD_ID0, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA);
	gpio_lcd_id1 =  PCOM_GPIO_CFG(CHACHA_GPIO_LCD_ID1, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA);
	msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &gpio_lcd_id0, 0);
	msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &gpio_lcd_id1, 0);

	panel_id = gpio_get_value(CHACHA_GPIO_LCD_ID0) |
	           (gpio_get_value(CHACHA_GPIO_LCD_ID1) << 1);

	B(KERN_INFO "%s: panel_id:%d.\n", __func__,panel_id);

	switch(panel_id) {
		case 0:
			panel_type = 10;
			panel_data = &renesas_liberty_client_data.panel_conf;
		break;

		case 1:
			panel_type = 13;
			panel_data = &renesas_AUO_client_data.panel_conf;
		break;
		default:
			chacha_mddi_renesas_power(client, 0);
			gpio_lcd_id0 =  PCOM_GPIO_CFG(CHACHA_GPIO_LCD_ID0, 0,
						GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA);
			gpio_lcd_id1 =  PCOM_GPIO_CFG(CHACHA_GPIO_LCD_ID1, 0,
						GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA);
			msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &gpio_lcd_id0, 0);
			msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &gpio_lcd_id1, 0);
		break;
	}

	panel_data->panel_id = panel_type;
	panel_data->caps = MSMFB_CAP_CABC;
	panel_data->pwm = pwm_renesas;
	panel_data->shrink = 1;
	panel_data->shrink_br = chacha_panel_shrink;
	panel_data->default_br = 83;

	config = PCOM_GPIO_CFG(CHACHA_GPIO_MDDI_TE, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA);
	msm_proc_comm(PCOM_RPC_GPIO_TLMM_CONFIG_EX, &config, 0);

	msm_device_mdp.dev.platform_data = &chacha_mdp_pdata;
	rc = platform_device_register(&msm_device_mdp);
	if (rc)
		return rc;

	msm_device_mddi0.dev.platform_data = &chacha_pdata;
	rc = platform_device_register(&msm_device_mddi0);
	if (rc)
		return rc;

	led_trigger_register_simple("lcd-backlight-gate", &chacha_lcd_backlight);
	if (IS_ERR(chacha_lcd_backlight))
		printk(KERN_ERR "[BKL] %s: backlight registration failed!\n",
			__func__);
	return 0;
}
int firm_update( void )
{
	int ret = 0;
	int cnt = 0;
	struct vreg *vreg_touch;

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

	printk("[TSP] disable_irq : %d\n", __LINE__ );

	firmware_ret_val = -1;

	vreg_touch = vreg_get(NULL, "maxldo06");

	if (ts_global->use_irq)
	{
		printk("[TSP] disable_irq : %d\n", __LINE__ );
		disable_irq(ts_global->client->irq);
	}

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

	printk("[F/W D/L] Entry gpio_tlmm_config\n");

	gpio_tlmm_config(GPIO_CFG( TSP_SCL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_tlmm_config(GPIO_CFG( TSP_SDA, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_tlmm_config(GPIO_CFG( TSP_INT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_ENABLE);

	gpio_set_value( TSP_SCL , 0 ); 
	gpio_set_value( TSP_SDA , 0 ); 
	gpio_set_value( TSP_INT , 0 ); 

	gpio_set_value( VTOUCH_EN , 0 );	//I2C Pullup

	for (cnt=0; cnt <5 ; cnt++){
		mdelay(200);	
		printk("[F/W D/L] Entry mcsdl_download_binary_data, try=%d\n", cnt );

		ret = mcsdl_download_binary_data( HW_ver );
		mdelay(200);	

		if(ret > 0)
		{
			ret = read_ver();
			if ( ret> 0) {
				firmware_ret_val = 1;
				printk("[TSP] Firmware update success! HW rev 0x%02x., SW rev 0x%02x.]\n", HW_ver, SW_ver);
				break;	
			}
		} else {
			printk("[TSP] Firmware update failed.. RESET!, try=%d\n", cnt);
			mcsdl_vdd_off();
			mdelay(500);
			mcsdl_vdd_on();
			mdelay(200);

			if ( cnt >= 4 ) {
				printk("[TSP] Firmware update failed.. RESET!, try=%d\n", cnt);
				printk("[TSP] check i2c lines.\n");
				firmware_ret_val = 0;
				break;	
			}
		}
	}

	gpio_set_value( TSP_SCL , 1 ); 
	gpio_set_value( TSP_SDA , 1 ); 
	gpio_set_value( TSP_INT , 1 ); 
	gpio_set_value( VTOUCH_EN , 1 );	//I2C Pullup
	
	ret = vreg_enable(vreg_touch);
	if (ret) {
		printk(KERN_ERR "%s: vreg enable failed (%d)\n",
				__func__, ret);
	}

	msleep(10);

	if (ts_global->use_irq)
	{
		enable_irq(ts_global->client->irq);
	}

	return 0;
}
Exemplo n.º 7
0
static int cam_hw_init()
{
	int rc = 0;
	struct vreg *vreg_L8;

#ifdef CONFIG_MACH_ICON
	msm_camio_camif_pad_reg_reset();
	mdelay(10);

	gpio_set_value(CAM_VT_RST, 1);
	mdelay(1);
#else
	printk(KERN_DEBUG
	    "<=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_EN_2, 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
		GPIO_CFG_ENABLE);	/*CAM_EN_2 */
	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 */

	vreg_L8 = vreg_get(NULL, "gp7");
	vreg_set_level(vreg_L8, 1800);
	vreg_disable(vreg_L8);

	gpio_set_value(CAM_RESET, 0);
	gpio_set_value(CAM_STANDBY, 0);
	gpio_set_value(CAM_EN, 0);
	gpio_set_value(CAM_EN_2, 0);
	gpio_set_value(CAM_VT_RST, 0);
	gpio_set_value(CAM_VT_nSTBY, 0);

	/*mdelay(1);		changed for coding rule*/
	mdelay(1);

	gpio_set_value(CAM_EN_2, 1);	/*CAM_EN->UP */
	gpio_set_value(CAM_EN, 1); /*CAM_EN->UP*/
	vreg_enable(vreg_L8);
	udelay(10);

	gpio_set_value(CAM_VT_nSTBY, 1); /*VGA_STBY UP*/
	udelay(10);

	gpio_tlmm_config(GPIO_CFG(CAM_MCLK, 1, GPIO_CFG_OUTPUT,
		GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
		GPIO_CFG_ENABLE);	/*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(1);
#endif
	return rc;
}
Exemplo n.º 8
0
////////////////////////////////
// Power ON
////////////////////////////////
static int cam12mp_sensor_poweron(void)
{
    struct vreg *vreg_gp1, *vreg_gp6;

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

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

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

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

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

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

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

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

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

    gpio_set_value(H_STBY, 1);

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

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

    return 0;

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

_sensor_poweron_fail_1:
    sub_pmic_reg_ctrl(SUB_PMIC_REG2, SUB_PMIC_LDO_OFF);
    LOGI("-%s (fail.)\n", __func__);
    return -1;
}
Exemplo n.º 9
0
static int fm_radio_setup(struct marimba_fm_platform_data *pdata)
{
	int rc = 0;
	const char *id = "FMPW";
	uint32_t irqcfg;
	struct marimba config = { .mod_id =  SLAVE_ID_BAHAMA};
	u8 value;

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

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

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

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

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

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

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

	return 0;

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

fm_vreg_fail:
	vreg_put(fm_regulator);

	return rc;
};
Exemplo n.º 10
0
 static int __init zte_wifi_init(void)
{

    int ret = 0;
    struct vreg *wlan_3p3; 
	struct vreg *wlan_1p8;

	do {
		pr_info("%s() enter\n", __func__);
		ret = gpio_tlmm_config(GPIO_CFG(WLAN_CHIP_WOW_PIN, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

       	if(ret) {
            		printk(KERN_ERR"WLAN_CHIP_WOW_PIN config failed\n");
	    		break;
        	} 
		gpio_request(WLAN_CHIP_WOW_PIN, "WLAN_WOW");
		gpio_free(WLAN_CHIP_WOW_PIN);        

	wlan_3p3 = vreg_get(NULL, "bt");
	if(!wlan_3p3)
	{
	      pr_err("%s: VREG_L17 get failed\n",__func__);
	}

       ret = vreg_set_level(wlan_3p3, 3300);
	if(ret<0)
	{
	      pr_err("%s: VREG_L17 set failed\n",__func__);
	}
		ret=vreg_enable(wlan_3p3);
	if (ret) {
		pr_err("%s: vreg_enable failed \n", __func__);
	}
	mdelay(50);

	wlan_1p8 = vreg_get(NULL,"wlan1v8");
	       if(!wlan_1p8)
	{
	      pr_err("%s: VREG_L19 get failed\n",__func__);
	}
	  ret = vreg_set_level(wlan_1p8, 1800);
	if(ret<0)
	{
	      pr_err("%s: VREG_L19 set failed\n",__func__);
	}
		ret=vreg_enable(wlan_1p8);
	if (ret) {
		pr_err("%s: vreg_enable failed \n", __func__);
	}

        pr_info("%s() VREG 1.8v On\n", __func__);
        mdelay(100);
        pr_info("%s() Pull low CHIP PWD\n", __func__);
        /*
         * Pull low Chip power down pin
         */		
		ret = gpio_tlmm_config(GPIO_CFG(WLAN_CHIP_PWD_PIN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), GPIO_CFG_ENABLE);
        	if(ret) {
            		printk(KERN_ERR"WLAN_CHIP_PWD_PIN config failed\n");
	    		break;
        	} 
		gpio_request(WLAN_CHIP_PWD_PIN, "WLAN_CHIP_PWD");
		gpio_direction_output(WLAN_CHIP_PWD_PIN, 0);
		gpio_free(WLAN_CHIP_PWD_PIN);

		platform_device_register(&zte_wifi_device);	
		//pc_wifi_mac_nvread();
              return 0;
		}while(0);
        return ret;
}
Exemplo n.º 11
0
static int __init msm_serial_probe(struct platform_device *pdev)
{
	struct msm_port *msm_port;
	struct resource *resource;
	struct uart_port *port;
#if defined(CONFIG_KERNEL_MOTOROLA)
	struct vreg *vreg;
#endif /* defined(CONFIG_KERNEL_MOTOROLA) */

	if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
		return -ENXIO;

	printk(KERN_INFO "msm_serial: detected port #%d\n", pdev->id);
#ifdef CONFIG_MACH_CALGARY
	/* Calgary uses VREG_USIM (RUIM1) for the UART3 block */
        if (pdev->id == 2)
	{
		vreg = vreg_get(0, "ruim");
		if (IS_ERR(vreg))
			printk(KERN_ERR "%s: vreg get failed for VREG_RUIM\n", __func__);
		else if (vreg_set_level(vreg, 2200))
			printk(KERN_ERR "%s: vreg set level failed for VREG_RUIM\n", __func__);
		else if (vreg_enable(vreg))
			printk(KERN_ERR "%s: vreg enable failed for VREG_RUIM\n", __func__);
		else
			printk(KERN_INFO "%s: VREG_RUIM enabled for RS232\n", __func__);
	}
#endif

#if defined(CONFIG_KERNEL_MOTOROLA)
	/* Calgary uses VREG_USIM (RUIM1) for the UART3 block */
        if (pdev->id == 2)
	{
		vreg = vreg_get(0, "ruim");
		if (IS_ERR(vreg))
			printk(KERN_ERR "%s: vreg get failed for VREG_RUIM\n", __func__);
		else if (vreg_set_level(vreg, 2200))
			printk(KERN_ERR "%s: vreg set level failed for VREG_RUIM\n", __func__);
		else if (vreg_enable(vreg))
			printk(KERN_ERR "%s: vreg enable failed for VREG_RUIM\n", __func__);
		else
			printk(KERN_INFO "%s: VREG_RUIM enabled for RS232\n", __func__);
	}
#endif /* defined(CONFIG_KERNEL_MOTOROLA) */

	port = get_port_from_line(pdev->id);
	port->dev = &pdev->dev;
	msm_port = UART_TO_MSM(port);

	msm_port->clk = clk_get(&pdev->dev, "uart_clk");
	if (unlikely(IS_ERR(msm_port->clk)))
		return PTR_ERR(msm_port->clk);
	port->uartclk = clk_get_rate(msm_port->clk);

	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (unlikely(!resource))
		return -ENXIO;
	port->mapbase = resource->start;

	port->irq = platform_get_irq(pdev, 0);
	if (unlikely(port->irq < 0))
		return -ENXIO;

	platform_set_drvdata(pdev, port);

	if (unlikely(set_irq_wake(port->irq, 1)))
		return -ENXIO;

#ifdef CONFIG_SERIAL_MSM_RX_WAKEUP
	if (port->line == 0)  /* BT is serial device 0 */
		if (unlikely(set_irq_wake(MSM_GPIO_TO_INT(45), 1)))
			return -ENXIO;
#endif

#ifdef CONFIG_SERIAL_MSM_CLOCK_CONTROL
	msm_port->clk_state = MSM_CLK_PORT_OFF;
	hrtimer_init(&msm_port->clk_off_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	msm_port->clk_off_timer.function = msm_serial_clock_off;
	msm_port->clk_off_delay = ktime_set(0, 1000000);  /* 1 ms */
#endif

	return uart_add_one_port(&msm_uart_driver, port);
}
Exemplo n.º 12
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;
    int ret;
	int a;

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


#if defined(CONFIG_MACH_VASTO)
	vreg_proximity = vreg_get(NULL, "vcama");
	ret = vreg_set_level(vreg_proximity, 3000); // 2800 -> 3000 H/W requeset
	if (ret) {
		printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, ret);
		return -EIO;
	}

	ret = vreg_enable(vreg_proximity);
	if (ret) {
		printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret);
		return -EIO;
	}
#else  
	if( board_hw_revision < 3 )
	{
		vreg_proximity = vreg_get(0, "vcama");
		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";
	
		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 */ // set in board file
	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);

//for(a = 0; a < 10 ; a++)
//{
	/* GP2A Regs INIT SETTINGS */
	for(i=1;i<5;i++)
	{
		opt_i2c_write((u8)(i),&gp2a_original_image[i]);
		mdelay(5);
		mdelay(5);
	//	printk("%d",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.º 13
0
int camera_power_on (void)
{
	int rc;
	struct device *dev = su370_backlight_dev();

	camera_power_mutex_lock();
	if(lcd_bl_power_state == BL_POWER_SUSPEND)
	{
		u370_pwrsink_resume();
		mdelay(50);
	}

	
	
	gpio_set_value(GPIO_CAM_RESET, 0);
	gpio_set_value(GPIO_CAM_PWDN, 0);

	


	


	{	
		struct vreg *vreg_mmc = vreg_get(0, "mmc");
		vreg_set_level(vreg_mmc, 2800);
		vreg_enable(vreg_mmc);
	}

  
	rc = aat28xx_ldo_set_level(dev, LDO_CAM_DVDD_NO, 1200);
	if (rc < 0) {
		printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_DVDD_NO);
		goto power_on_fail;
	}
	rc = aat28xx_ldo_enable(dev, LDO_CAM_DVDD_NO, 1);
	if (rc < 0) {
		printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_DVDD_NO);
		goto power_on_fail;
	}

  
	rc = aat28xx_ldo_set_level(dev, LDO_CAM_IOVDD_NO, 2600);
	if (rc < 0) {
		printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_IOVDD_NO);
		goto power_on_fail;
	}
	rc = aat28xx_ldo_enable(dev, LDO_CAM_IOVDD_NO, 1);
	if (rc < 0) {
		printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_IOVDD_NO);
		goto power_on_fail;
	}

	
	
	rc = aat28xx_ldo_set_level(dev, LDO_CAM_AVDD_NO, 2800);
	if (rc < 0) {
		printk(KERN_ERR "%s: ldo %d set level error\n", __func__, LDO_CAM_AVDD_NO);
		goto power_on_fail;
	}
	rc = aat28xx_ldo_enable(dev, LDO_CAM_AVDD_NO, 1);
	if (rc < 0) {
		printk(KERN_ERR "%s: ldo %d control error\n", __func__, LDO_CAM_AVDD_NO);
		goto power_on_fail;
	}	

	mdelay(5);
	
	msm_camio_clk_rate_set(mclk_rate);
	mdelay(5);
	msm_camio_camif_pad_reg_reset();
	mdelay(5);

	
	gpio_set_value(GPIO_CAM_RESET, 1);

	mdelay(5); 
	
	gpio_set_value(GPIO_CAM_PWDN, 1);
	
	mdelay(8);  

	camera_power_state = CAM_POWER_ON;

power_on_fail:
	camera_power_mutex_unlock();
	return rc;

}
static int mxt_power_on(bool on)
{
    int     retval;

    /* for New model (use PM8058) */
    if ( on ){
        /* get structure */
        cap_vreg_l8 = vreg_get( NULL, "gp7" );
        if ( IS_ERR(cap_vreg_l8) ){
            printk( KERN_ERR "%s: get vreg structure error retval = %d\n", __func__, (int)cap_vreg_l8 );
            return -1;
        }

        /* set voltage */
        retval = vreg_set_level( cap_vreg_l8, 1800 );
        if ( retval ) {
            printk( KERN_ERR "%s: set voltage error retval = %d\n", __func__, retval );
            return -1;
        }

        /* output enable */
        retval = vreg_enable( cap_vreg_l8 );
        if ( retval ) {
            printk( KERN_ERR "%s: output enable error retval = %d\n", __func__, retval );
            return -1;
        }

        cap_vreg_l10 = vreg_get( NULL, "gp4" );
        if ( IS_ERR(cap_vreg_l10) ){
            printk( KERN_ERR "%s: get vreg structure error retval = %d\n", __func__, (int)cap_vreg_l10 );
            return -1;
        }

        /* set voltage */
        retval = vreg_set_level( cap_vreg_l10, 2900 );
        if ( retval ) {
            printk( KERN_ERR "%s: set voltage error retval = %d\n", __func__, retval );
            return -1;
        }

        /* output enable */
        retval = vreg_enable( cap_vreg_l10 );
        if ( retval ) {
            printk( KERN_ERR "%s: output enable error retval = %d\n", __func__, retval );
            return -1;
        }

        msleep( 40 );
    }else{
        /* check structure */
        if ( IS_ERR(cap_vreg_l8) ){
            printk( KERN_ERR "%s: invalid vreg structure \n", __func__ );
            return 0;
        }

        /* output disable */
        retval = vreg_disable( cap_vreg_l8 );
        if ( retval ) {
            printk( KERN_ERR "%s: output disable error retval = %d\n", __func__, retval );
            return retval;
        }

        vreg_put( cap_vreg_l8 );
        cap_vreg_l8 = NULL;

        /* check structure */
        if ( IS_ERR(cap_vreg_l10) ){
            printk( KERN_ERR "%s: invalid vreg structure \n", __func__ );
            return 0;
        }

        /* output disable */
        retval = vreg_disable( cap_vreg_l10 );
        if ( retval ) {
            printk( KERN_ERR "%s: output disable error retval = %d\n", __func__, retval );
            return retval;
        }

        vreg_put( cap_vreg_l10 );
        cap_vreg_l10 = NULL;
        return 0;

	}
	return 0;
}
int tsp_reset( void )
{
	int ret=0;
	struct vreg *vreg_touch;
	printk("[TSP] %s+\n", __func__ );

	vreg_touch = vreg_get(NULL, "maxldo06");

	if (ts_global->use_irq)
	{
		disable_irq(ts_global->client->irq);
	}

	ret = vreg_disable(vreg_touch);

	msleep(10);
	if (ret) {
		printk(KERN_ERR "%s: vreg enable failed (%d)\n",
				__func__, ret);
		ret=-EIO;
		goto tsp_reset_out;
	}

	gpio_tlmm_config(GPIO_CFG( TSP_SCL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_tlmm_config(GPIO_CFG( TSP_SDA, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_tlmm_config(GPIO_CFG( TSP_INT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_set_value( VTOUCH_EN , 0 );	//I2C Pullup

	msleep(10);

	gpio_set_value( TSP_SCL , 0 ); 
	gpio_set_value( TSP_SDA , 0 ); 
	gpio_set_value( TSP_INT , 0 ); 

	msleep(200);

	gpio_set_value( TSP_SCL , 1 ); 
	gpio_set_value( TSP_SDA , 1 ); 
	gpio_set_value( TSP_INT , 1 ); 
	gpio_set_value( VTOUCH_EN , 1 );	//I2C Pullup

	ret = vreg_enable(vreg_touch);

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

	msleep(200);

tsp_reset_out:
	if (ts_global->use_irq)
	{
		enable_irq(ts_global->client->irq);
	}
	printk("[TSP] %s-\n", __func__ );

	return ret;
}
Exemplo n.º 16
0
struct ara_board_info *board_init(void) {
    int i;
    int rc;

    /* Disable the I/O expanders for now. */
    stm32_configgpio(SVC_RST_IOEXP1_GPIO);
    stm32_configgpio(SVC_RST_IOEXP2_GPIO);
    stm32_gpiowrite(SVC_RST_IOEXP1_GPIO, false);
    stm32_gpiowrite(SVC_RST_IOEXP2_GPIO, false);

    /*
     * Register STM32 GPIOs to GPIO chip framework. This has to happen
     * before the following configuration, which depends on STM32 GPIO
     * pin numbers.
     */
    stm32_gpio_init();

    /* Register the TCA64xx I/O Expanders to the gpio chip core. */
    for (i = 0; i < evt1_board_info.nr_io_expanders; i++) {
        struct io_expander_info *io_exp = &evt1_board_info.io_expanders[i];

        io_exp->i2c_dev = up_i2cinitialize(io_exp->i2c_bus);
        if (!io_exp->i2c_dev) {
            dbg_error("%s(): Failed to get I/O Expander I2C bus %u\n",
                      __func__, io_exp->i2c_bus);
            board_exit();
            return NULL;
        }
        if (tca64xx_init(&io_exp->io_exp_driver_data,
                         io_exp->part,
                         io_exp->i2c_dev,
                         io_exp->i2c_addr,
                         io_exp->reset,
                         io_exp->irq,
                         io_exp->gpio_base) < 0) {
            dbg_error("%s(): Failed to register I/O Expander(0x%02x)\n",
                      __func__, io_exp->i2c_addr);
            board_exit();
            return NULL;
        }
    }

    /* For now, just always enable REFCLK_MAIN and the buffers. */
    rc = vreg_config(&refclk_main_vreg) || vreg_get(&refclk_main_vreg);
    if (rc) {
        dbg_error("%s: can't start REFCLK_MAIN: %d\n", __func__, rc);
        board_exit();
        return NULL;
    }

    /* Configure the switch power supply lines. */
    rc = vreg_config(&sw_vreg);
    if (rc) {
        dbg_error("%s: can't configure switch regulators: %d\n", __func__, rc);
        board_exit();
        return NULL;
    }
    stm32_configgpio(evt1_board_info.sw_data.gpio_reset);
    up_udelay(POWER_SWITCH_OFF_STAB_TIME_US);

    /* Configure the wake/detect lines. */
    stm32_configgpio(WD_1_DET_IN_GPIO);
    stm32_configgpio(WD_2_DET_IN_GPIO);
    stm32_configgpio(WD_3A_DET_IN_GPIO);
    stm32_configgpio(WD_3B_DET_IN_GPIO);
    stm32_configgpio(WD_4A_DET_IN_GPIO);
    stm32_configgpio(WD_4B_DET_IN_GPIO);
    stm32_configgpio(WD_5_DET_IN_GPIO);
    stm32_configgpio(WD_8A_DET_IN_GPIO);
    stm32_configgpio(WD_8B_DET_IN_GPIO);

    /* Configure the ARA key. */
    stm32_configgpio(ARA_KEY_GPIO);

    /*
     * (Module hotplug pins unconfigured. TODO, part of SW-1942.)
     */

    return &evt1_board_info;
}
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;

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

	tsp_ready=0;

	vreg_touch = vreg_get(NULL, "maxldo06");
	ret = vreg_set_level(vreg_touch, OUT2800mV);
	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(100);

	gpio_tlmm_config(GPIO_CFG( VTOUCH_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,GPIO_CFG_2MA), GPIO_CFG_ENABLE);	//I2C Pullup 2.6V 
	gpio_set_value( VTOUCH_EN, 1 );

	msleep(100);

	ts = kzalloc(sizeof(*ts), GFP_KERNEL);
	if (ts == NULL) {
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}
	INIT_WORK(&ts->work, synaptics_ts_work_func);
	ts->client = client;
	i2c_set_clientdata(client, ts);

	ts_global = ts;

	ts->input_dev = input_allocate_device();
	if (ts->input_dev == NULL) {
		ret = -ENOMEM;
		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: %d, max_y: %d\n", MAX_X, MAX_Y);

	input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, MAX_X, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, MAX_Y, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);

	/* ts->input_dev->name = ts->keypad_info->name; */
	ret = input_register_device(ts->input_dev);
	if (ret) {
		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_DISABLE_FB;
//CHJ origin	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 = read_ver();

	if (ret <= 0) {
		printk("[TSP] %s, ln=%d, Error\n", __func__, __LINE__ );
		ret = read_ver();

		if (ret <= 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 */

#if 0//CHJ
	/* Check point - firmware ver check - start */
	if(board_hw_revision == 0x02){
		if( (HW_ver==0x08)&&(SW_ver<0x11) ){
			printk(KERN_INFO "[TSP] board_rev=%d, TSP HW_ver=%2x, SW_ver=%2x\n", board_hw_revision, HW_ver, SW_ver);
			firm_update();
		}
	}

	if(board_hw_revision == 0x03){
		if( (HW_ver==HEX_HW_VER)&&(SW_ver<HEX_SW_VER) ){
			printk(KERN_INFO "[TSP] board_rev=%d, TSP HW_ver=%2x, SW_ver=%2x\n", board_hw_revision, HW_ver, SW_ver);
			firm_update();
		}
	}
	/* Check point - firmware ver check - end */
#endif

	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;
}
Exemplo n.º 18
0
/*
* mlm1183_sensor_init
*  - It is called from OPEN.
*/
static int mlm1183_sensor_init(
    const struct msm_camera_sensor_info* sensor_info
)
{
    long rc = 0;
    struct sensor_cfg_data cfg_data;
    static struct vreg *vreg_cfg;

    MLM1183_ENTER;

    senser_info_mlm1183 = (struct msm_camera_sensor_info_mlm1183 *)sensor_info;
    mlm1183_wait_flag = 0;

    gpio_request(senser_info_mlm1183->sensor_info.sensor_pwd, "PWD");
    gpio_request(senser_info_mlm1183->sensor_info.sensor_reset, "RST");

    /* VCAML provide start */
    cfg_data.cfg.gpio_cfg.port = senser_info_mlm1183->sensor_info.sensor_pwd;
    cfg_data.cfg.gpio_cfg.ctl = GPIO_HIGH;
    rc = mlm1183_sensor_set_gpio( &cfg_data );
    if(rc != 0){
        MLM1183_RETURN_N(rc);
    }
    
    /* Wait:1ms */
    mdelay(1);
    
    /* VCAMD provide start */
    cfg_data.cfg.pmic_cfg.id = senser_info_mlm1183->vcmd_pwd;
    cfg_data.cfg.pmic_cfg.ctl =  PMIC_ON;
    rc = mlm1183_sensor_set_pmic( &cfg_data );
    if(rc != 0){
        MLM1183_RETURN_N(rc);
    }
    
    /* VCAMA provide start */
    cfg_data.cfg.pmic_cfg.id = senser_info_mlm1183->vcma_pwd;
    cfg_data.cfg.pmic_cfg.ctl =  PMIC_ON;
    vreg_cfg = vreg_get(NULL, cfg_data.cfg.pmic_cfg.id);
    vreg_set_level(vreg_cfg, 2800);
    rc = mlm1183_sensor_set_pmic( &cfg_data );
    if(rc != 0){
        MLM1183_RETURN_N(rc);
    }
    
    /* VCAMAF provide start */
    cfg_data.cfg.pmic_cfg.id = senser_info_mlm1183->vcmaf_pwd;
    cfg_data.cfg.pmic_cfg.ctl =  PMIC_ON;
    vreg_cfg = vreg_get(NULL, cfg_data.cfg.pmic_cfg.id);
    vreg_set_level(vreg_cfg, 2800);
    rc = mlm1183_sensor_set_pmic( &cfg_data );
    if(rc != 0){
        MLM1183_RETURN_N(rc);
    }
    
    /* Wait:1ms */
    msleep(1);
    
    /* CAM_CLK provide start */
    cfg_data.cfg.mclk_ctl = MCLK_ON;
    rc = mlm1183_sensor_set_mclk( &cfg_data );
    if(rc != 0){
        MLM1183_RETURN_N(rc);
    }

    /* Wait:5ms */
    msleep(5);

    /* Reset CAMIF PAD REG */
    msm_camio_camif_pad_reg_reset();
    
    /* Wait:5ms */
    msleep(5);
    
    /* reset cancel */
    cfg_data.cfg.gpio_cfg.port = senser_info_mlm1183->sensor_info.sensor_reset;
    cfg_data.cfg.gpio_cfg.ctl = GPIO_HIGH;
    rc = mlm1183_sensor_set_gpio( &cfg_data );
    if(rc != 0){
        MLM1183_RETURN_N(rc);
    }
    
    rc = request_irq( gpio_to_irq(MLM1183_INTERRUPT_PORT),
                      mlm1183_interrupt,
                      IRQF_TRIGGER_RISING,
                      "cam_trig_h",
                      0 );
    if(rc != 0){
        MLM1183_RETURN_N(rc);
    }
    
    MLM1183_RETURN_N(rc);
}
Exemplo n.º 19
0
static int gs_probe(
	struct i2c_client *client, const struct i2c_device_id *id)
{	
   int ret;
   struct gs_data *gs;

	struct vreg *vreg_gp4=NULL;
	int rc;

	vreg_gp4 = vreg_get(NULL, "gp4");
    /* set gp4 voltage as 2700mV for all */
    rc = vreg_set_level(vreg_gp4,VREG_GP4_VOLTAGE_VALUE_2700);
	if (rc) {
		printk("%s: vreg_gp4  vreg_set_level failed \n", __func__);
		return rc;
	}
	
	rc = vreg_enable(vreg_gp4);
	if (rc) {
		printk("%s: vreg_gp4    vreg_enable failed \n", __func__);
		return rc;
	}
	mdelay(5);
   	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		printk(KERN_ERR "gs_probe: need I2C_FUNC_I2C\n");
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}
#ifndef GS_POLLING
	ret = gs_config_int1_pin();
	if(ret <0)
	{
		goto err_check_functionality_failed;
	}
	
	ret = gs_config_int2_pin();
	if(ret <0)
	{
		goto err_check_functionality_failed;
	}	
#endif
	gs = kzalloc(sizeof(*gs), GFP_KERNEL);
	if (gs == NULL) {		
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}
	
/*BK4D00238, add  mlock, dingxifeng KF14049, 2009-4-3 begin */	
		mutex_init(&gs->mlock);
/*BK4D00238, add  mlock, dingxifeng KF14049, 2009-4-3 end */
	
	INIT_WORK(&gs->work, gs_work_func);
	gs->client = client;
	i2c_set_clientdata(client, gs);
/*BK4D00238, add accelerometer code, dingxifeng KF14049, 2009-5-9 begin */
	
	
	 ret =reg_read(gs,GS_ADI_REG_DEVID);		
	if ( ret <0 )
		goto err_detect_failed;
	switch (ret) {
	case ID_ADXL345:
		break;
	default:
		printk(KERN_ERR, "Failed to probe \n" );
		goto err_detect_failed;
	}
	 
/*BK4D01637, gs_probe interface set standby mode , dingxifeng KF14049, 2009-6-22  begin*/
	 ret = reg_write(gs,GS_ADI_REG_POWER_CTL,0x14);   /* auto low power ,deep sleep */
/*BK4D01637, gs_probe interface set standby mode , dingxifeng KF14049, 2009-6-22  end*/
	if ( ret <0 )
		goto err_detect_failed;
	ret =  reg_write(gs,GS_ADI_REG_BW,0x0a);    /* Rate: 100Hz, IDD: 130uA */
      if ( ret <0 )
		goto err_detect_failed;
	 ret = reg_write(gs,GS_ADI_REG_DATA_FORMAT,0x01);  /* Data Format: 8g right justified  	128=1g  8g*/
	 if ( ret <0 )
			 goto err_detect_failed;

	 ret = reg_write(gs,GS_ADI_REG_INT_ENABLE,0x80); /* enable  int Int En: Data Rdy*/

	 if ( ret <0 )
			 goto err_detect_failed;

	 ret = reg_write(gs,GS_ADI_REG_TAP_AXES,0x01);	/* Z Axis Tap */
	 if ( ret <0 )
		goto err_detect_failed;
       ret = reg_write(gs,GS_ADI_REG_THRESH_TAP,0x20);	/* Tap Threshold: 2G */
	   if ( ret <0 )
			   goto err_detect_failed;


	 ret = reg_write(gs,GS_ADI_REG_DUR,0x50);	/* Dur:50ms */
	 if ( ret <0 )
			 goto err_detect_failed;


	 ret = reg_write(gs,GS_ADI_REG_LATENT,0x20);	 /* Latent: 40ms */
	 if ( ret <0 )
			 goto err_detect_failed;


	 ret = reg_write(gs,GS_ADI_REG_WINDOW,0xF0);	 /* Window: 300ms */
	 if ( ret <0 )
			 goto err_detect_failed;
	 
	if (sensor_dev == NULL)
	{
		gs->input_dev = input_allocate_device();
		if (gs->input_dev == NULL) {
			ret = -ENOMEM;
			printk(KERN_ERR "gs_probe: Failed to allocate input device\n");
			goto err_input_dev_alloc_failed;
		}
		gs->input_dev->name = "sensors";
		sensor_dev = gs->input_dev;
	}else{
	
		gs->input_dev = sensor_dev;
	}
	gs->input_dev->id.vendor = GS_ADIX345;//for akm8973 compass detect.

	set_bit(EV_ABS,gs->input_dev->evbit);
	
	/* modify for ES-version*/
	input_set_abs_params(gs->input_dev, ABS_X, -11520, 11520, 0, 0);
	input_set_abs_params(gs->input_dev, ABS_Y, -11520, 11520, 0, 0);
	input_set_abs_params(gs->input_dev, ABS_Z, -11520, 11520, 0, 0);
	
	set_bit(EV_SYN,gs->input_dev->evbit);


	gs->input_dev->id.bustype = BUS_I2C;
	//gs->input_dev->open = gs_adi_input_open;
	//gs->input_dev->close = gs_adi_input_close;
	
	input_set_drvdata(gs->input_dev, gs);
	ret = input_register_device(gs->input_dev);
	if (ret) {
		printk(KERN_ERR "gs_probe: Unable to register %s input device\n", gs->input_dev->name);
		goto err_input_register_device_failed;
	}
	
	ret = misc_register(&gsensor_device);
	if (ret) {
/*BK4D02639, modify printk mesg, dingxifeng KF14049, 2009-7-13 begin */

		printk(KERN_ERR "gs_probe: gsensor_device register failed\n");
/*BK4D02639, modify printk mesg, dingxifeng KF14049, 2009-7-13 end */

		goto err_misc_device_register_failed;
	}
/*BK4D00263, add for input devices, dingxifeng KF14049, 2009-5-20 end*/

	
#ifndef   GS_POLLING 
	if (client->irq) {
		ret = request_irq(client->irq, gs_irq_handler, 0, client->name, gs);
		
		if (ret == 0)
			gs->use_irq = 1;
		else
			dev_err(&client->dev, "request_irq failed\n");
	}
#endif 


/*BK4D00238, add accelerometer code, dingxifeng KF14049, 2009-5-9 end */

	if (!gs->use_irq) {
		hrtimer_init(&gs->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		gs->timer.function = gs_timer_func;
		
	}
#ifdef CONFIG_HAS_EARLYSUSPEND
	gs->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	gs->early_suspend.suspend = gs_early_suspend;
	gs->early_suspend.resume = gs_late_resume;
	register_early_suspend(&gs->early_suspend);
#endif
	
	gs_wq = create_singlethread_workqueue("gs_wq");
	if (!gs_wq)
		return -ENOMEM;
	
/*BK4D00263, add for misc devices, dingxifeng KF14049, 2009-5-20begin */
#if 0
	else
		GS_SENSOR_ADI_FLAG =1;
#endif
      this_gs_data =gs;
/*BK4D00263, add for misc devices, dingxifeng KF14049, 2009-5-20 end */

	printk(KERN_INFO "gs_probe: Start gs_adixl345  in %s mode\n", gs->use_irq ? "interrupt" : "polling");

	return 0;
	
/*BK4D00263, add for misc devices, dingxifeng KF14049, 2009-5-20 begin */
err_misc_device_register_failed:
	
	misc_deregister(&gsensor_device);

err_input_register_device_failed:
	input_free_device(gs->input_dev);

err_input_dev_alloc_failed:

/*BK4D00263, add for misc devices, dingxifeng KF14049, 2009-5-20 end */

err_detect_failed:

	kfree(gs);
	
#ifndef   GS_POLLING 
	gs_free_int1();
	gs_free_int2();
#endif	
	
err_alloc_data_failed:
err_check_functionality_failed:
	if (vreg_gp4!=NULL)
	{
		rc = vreg_disable(vreg_gp4);
		if (rc) {
			printk("%s: vreg_gp4    vreg_enable failed \n", __func__);
			return rc;
		}
	}
	return ret;
}
Exemplo n.º 20
0
/*<BU5D08118 zhangtao 20100419 begin*/
static int aps_12d_probe(
	
	struct i2c_client *client, const struct i2c_device_id *id)
{	
	int ret;
	struct aps_data *aps;
	/*the aps_12d sensors ispower on*/
	/* <BU5D07679 zhangtao 20100413 begin */
	struct vreg *vreg_gp4=NULL;
	int rc;
/* <DTS2010100800714 liugaofei 20101008 begin */
	int i;
/* DTS2010100800714 liugaofei 20101008 end */
	
    vreg_gp4 = vreg_get(NULL, VREG_GP4_NAME);
    /* < DTS2010061200552 zhangtao 20100612 begin */
    if (IS_ERR(vreg_gp4)) 
    {
	    pr_err("%s:gp4 power init get failed\n", __func__);
    }
    /* DTS2010061200552 zhangtao 20100612 end> */

    /* <DTS2011012600839 liliang 20110215 begin */
    /* set gp4 voltage as 2700mV for all */
    rc = vreg_set_level(vreg_gp4,VREG_GP4_VOLTAGE_VALUE_2700);
    /* <DTS2011012600839 liliang 20110215 end >*/
    
	if (rc) {
		PROXIMITY_DEBUG("%s: vreg_gp4  vreg_set_level failed \n", __func__);
		return rc;
	}
	rc = vreg_enable(vreg_gp4);
	if (rc) {
		pr_err("%s: vreg_gp4    vreg_enable failed \n", __func__);
		return rc;
	}
	mdelay(5);
       /* BU5D07679 zhangtao 20100413 end> */
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		PROXIMITY_DEBUG(KERN_ERR "aps_12d_probe: need I2C_FUNC_I2C\n");
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}

	/* < DTS2010091001474 zhangtao 20100910 begin */
	/* if querry the board is T1 or T2 turn off the proximity */
    /*< DTS2010092400487  lijianzhao 20100924 begin */
    /* 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; 
	}    
    /* DTS2010092400487  lijianzhao 20100924 end >*/ 
	/* DTS2010091001474 zhangtao 20100910 end > */

	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 */

	/* < DTS2010081803338 zhangtao 20100818 begin */
	/* make the rang smaller can make the ir changge bigger */
	ret = aps_i2c_reg_write(aps, APS_12D_REG_CMD2, \
/* < DTS2010102103994 zhangtao 20101112 begin */
	                         (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));
/* DTS2010102103994 zhangtao 20101112 end > */
	/* DTS2010081803338 zhangtao 20100818 end > */
	if(ret < 0)
	{
		goto err_detect_failed;
	}
/* <DTS2010100800714 liugaofei 20101008 begin */
	range_index = 0;

	for(i = 0; i < TOTAL_RANGE_NUM; i++)
	{
		/* NOTE: do NOT use the last one */
		up_range_value[i] = MAX_ADC_OUTPUT - high_threshold_value[i] - RANGE_FIX; 
	}

	down_range_value[0] = 0;
	for(i = 1; i < TOTAL_RANGE_NUM; i++)
	{
		/* NOTE: do not use the first one */
		down_range_value[i] = (MAX_ADC_OUTPUT - high_threshold_value[i-1] - (MAX_ADC_OUTPUT / ADJUST_GATE)) / 4; 
	}
/* DTS2010100800714 liugaofei 20101008 end */

	/* < DTS2011042705601 zhangtao 20110427 begin */
	/*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;
	}
	/* DTS2011042705601 zhangtao 20110427 end > */
	
	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;
	}

	/* < DTS2010090300997 zhangtao 20100903 begin */

	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");
	/* DTS2010090300997 zhangtao 20100903 end > */


	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;

    /* <DTS2011032104626 shenjinming 20110321 begin */
    #ifdef CONFIG_HUAWEI_HW_DEV_DCT
    /* detect current device successful, set the flag as present */
    set_hw_dev_flag(DEV_I2C_APS);
    #endif
    /* <DTS2011032104626 shenjinming 20110321 end> */
/* < DTS2011052606009 jiaxianghong 20110527 end */	  

	printk(KERN_INFO "aps_12d_probe: Start Proximity Sensor APS-12D\n");
/* DTS2010072801000 zhangtao 20100728 end > */

	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:
/* < DTS2010061200552 zhangtao 20100612 begin */
	if(NULL != vreg_gp4)
	{
	    /* < DTS2011052101089 shenjinming 20110521 begin */
        /* can't use the flag ret here, it will change the return value of probe function */
        vreg_disable(vreg_gp4);
        /* delete a line */
        /* DTS2011052101089 shenjinming 20110521 end > */
	}
/* DTS2010061200552 zhangtao 20100612 end > */
	return ret;
  
}