Esempio n. 1
0
static s32 muic_proc_set_ap_uart(void)
{
	s32 ret;

#if defined (CONFIG_MACH_BSSQ)
#if defined(CONFIG_LU6500)
  if(get_lge_pcb_revision() > REV_D)
    muic_i2c_write_byte(SW_CONTROL, COMP2_TO_AUD2|COMN1_TO_AUD1);
  else
#endif
#else
	/* Connect CP UART signals to AP */
	usif_switch_ctrl(USIF_AP);

	/* Connect AP UART to MUIC UART */
	dp3t_switch_ctrl(DP3T_AP_UART);
#endif
	/* Connect DP, DM to UART_TX, UART_RX */
	ret = muic_i2c_write_byte(SW_CONTROL, DP_UART | DM_UART);

	muic_mode = MUIC_AP_UART;	
	charging_mode = CHARGING_UNKNOWN;

	DBG("[MUIC] muic_proc_set_ap_uart(): AP_UART\n");

	return ret;
}
Esempio n. 2
0
void set_ts5usba33402_ap_uart_mode(void)
{ 
	/* Connects CP UART signals to AP */
	usif_switch_ctrl(USIF_AP);

	/* Connects AP UART to MUIC UART */
	dp3t_switch_ctrl(DP3T_AP_UART);

  	/* Enables 200K, Charger Pump, and ADC (0x01=0x13) */
   	muic_i2c_write_byte(CONTROL_1, ID_200 | SEMREN | CP_EN);
#if defined(CONFIG_LU6500)
	  if(get_lge_pcb_revision() > REV_D)
		muic_i2c_write_byte(SW_CONTROL, COMP2_TO_AUD2|COMN1_TO_AUD1);
	  else
#endif
  	/* Enable USB Path (0x03=0x00) */
	muic_i2c_write_byte(SW_CONTROL, COMP2_TO_U2 | COMN1_TO_U1);

}
Esempio n. 3
0
/*
 * muic_probe() is called in the middle of booting sequence due to '__init'.
 * '__init' causes muic_probe() to be released after the booting.
 */
static s32 __devinit muic_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	s32 ret = 0;
	muic_client = client;

	DBG("[MUIC] LG muic_probe() Begin\n");
#if defined (CONFIG_USIF)
	/* 
	 * Initializes gpio_165 (USIF1_SW).
	 * Checks if other driver already occupied it.
	 */
	ret = gpio_request(USIF_IN_1_GPIO, "USIF switch control GPIO");
	if (ret < 0) {
		DBG("[MUIC] GPIO 165 USIF1_SW is already occupied by other driver!\n");
		/*
		 * We know board_cosmo.c:ifx_n721_configure_gpio() performs a gpio_request on this pin first.
		 * Because the prior gpio_request is also for the analog switch control, this is not a confliction.
		 */
		return -ENOSYS;
	}
#if 0
	ret = gpio_direction_output(USIF_IN_1_GPIO, 0); // USIF_IN_1 ==> GPIO_PU3 not use in P999
#else
     ret = gpio_direction_output(USIF_IN_1_GPIO, 1);
#endif
	if (ret < 0) {
		DBG("[MUIC] gpio_16 USIF_IN_1_GPIO direction initialization failed!\n");
		return -ENOSYS;
	}
	tegra_gpio_enable(USIF_IN_1_GPIO);
#endif	//

#if defined (CONFIG_LGE_MUIC_DP3T)
	/*
	 * Initializes gpio_11 (OMAP_UART_SW) and gpio_12 (IFX_UART_SW).
	 * Checks if other driver already occupied them.
	 */
	ret = gpio_request(DP3T_IN_1_GPIO, "DP3T switch control 1 GPIO");
	if (ret < 0) {
		DBG("[MUIC] GPIO 11 DP3T_IN_1_GPIO is already occupied by other driver!\n");
		return -ENOSYS;
	}

	ret = gpio_direction_output(DP3T_IN_1_GPIO, 0);
	if (ret < 0) {
		DBG("[MUIC] gpio_11 DP3T_IN_1_GPIO direction initialization failed!\n");
		return -ENOSYS;
	}
	tegra_gpio_enable(DP3T_IN_1_GPIO);


	DBG("[MUIC] Old REV_D has AP_UART --- initalizing DP3T_IN_2_GPIO\n");
	ret = gpio_request(DP3T_IN_2_GPIO, "DP3T switch control 2 GPIO");
	if (ret < 0) {
		DBG("[MUIC] gpio_12 DP3T_IN_2_GPIO is already occupied by other driver!\n");
		return -ENOSYS;
	}

	ret = gpio_direction_output(DP3T_IN_2_GPIO, 0);
	if (ret < 0) {
		DBG("[MUIC] gpio_12 DP3T_IN_2_GPIO direction initialization failed!\n");
		return -ENOSYS;
	}
	tegra_gpio_enable(DP3T_IN_2_GPIO);


	ret = gpio_request(IFX_USB_VBUS_EN_GPIO, "DP3T switch control 2 GPIO");
	if (ret < 0) {
		DBG("[MUIC] gpio_55 IFX_USB_VBUS_EN_GPIO is already occupied by other driver!\n");
		return -ENOSYS;
	}

	ret = gpio_direction_output(IFX_USB_VBUS_EN_GPIO, 0);
	if (ret < 0) {
		DBG("[MUIC] gpio_55 IFX_USB_VBUS_EN_GPIO direction initialization failed!\n");
		return -ENOSYS;
	}
	tegra_gpio_enable(IFX_USB_VBUS_EN_GPIO);
#endif//

#if defined (CONFIG_MACH_BSSQ)

#if defined(CONFIG_LU6500)
  if(get_lge_pcb_revision() > REV_D)
    muic_intr_gpio = GPIO_MUIC_INT_N_REV_E;
#endif
	printk("[kdh] config_mach_bssq\n");
	gpio_request(muic_intr_gpio, "muic_int_n");
	tegra_gpio_enable(muic_intr_gpio);
	gpio_direction_input(muic_intr_gpio);

	gpio_request(GPIO_CP_UART_SW, "uart_sw");
	tegra_gpio_enable(GPIO_CP_UART_SW);
	gpio_direction_output(GPIO_CP_UART_SW, 0);

	gpio_request(GPIO_CP_USB_VBUS_EN, "mdm_usb_vbus_en");
	tegra_gpio_enable(GPIO_CP_USB_VBUS_EN);
	gpio_direction_output(GPIO_CP_USB_VBUS_EN, 0);
#else
	ret = gpio_request(MUIC_GPIO, "pu0");

	if (ret < 0)
	{
		DBG("[MUIC] MUIC_GPIO is already occupied by other driver!\n");
		return -ENOSYS;
	}

	ret=gpio_direction_input(MUIC_GPIO);
	if (ret < 0)
	{
		DBG("[MUIC] MUIC_GPIO direction initialization failed!\n");
		gpio_free(MUIC_GPIO);
		return -ENOSYS;
	}
	else
		tegra_gpio_enable(MUIC_GPIO);
#endif

#if defined (MUIC_SLEEP)
	wake_lock_init(&muic_wake_lock, WAKE_LOCK_SUSPEND, "muic_lock");
#endif

	/* Registers MUIC work queue function */
#if 0//def CONFIG_MACH_STAR_SU660
	INIT_WORK(&muic_work, muic_work_func);
#else
	INIT_WORK(&muic_wq, muic_wq_func);
#endif
	/* 
	 * Set up an IRQ line and enable the involved interrupt handler.
	 * From this point, a MUIC_INT_N can invoke muic_interrupt_handler().
	 * muic_interrupt_handler merely calls schedule_work() with muic_wq_func().
	 * muic_wq_func() actually performs the accessory detection.
	 */
#if defined (CONFIG_MACH_BSSQ)
	muic_gpio_irq = gpio_to_irq(muic_intr_gpio);
	ret = request_irq(muic_gpio_irq, (irq_handler_t)muic_interrupt_handler,IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, client->name, &client->dev);
#else
	muic_gpio_irq = gpio_to_irq(MUIC_GPIO);
	ret = request_irq(muic_gpio_irq, (irq_handler_t)muic_interrupt_handler, IRQF_TRIGGER_FALLING  , client->name, &client->dev);
#endif
	if (ret < 0) {
		DBG("[MUIC] MUIC_GPIO IRQ line set up failed!\n");
		free_irq(muic_gpio_irq, &client->dev);
		return -ENOSYS;
	}
	//disable_irq_wake(MUIC_GPIO);
//#if defined(CONFIG_LU6500)
//  if(get_lge_pcb_revision() > REV_D)  
//  enable_irq_wake(gpio_to_irq(muic_intr_gpio)); 
//#endif

	/* Prepares a human accessible method to control MUIC */
	create_lg_muic_proc_file();

	/* Selects one of the possible muic chips */
	muic_detect_device();

#if defined (CONFIG_MACH_BSSQ)
	if(muic_boot_keeping == TRUE)
	{
		if(muic_boot_path == PORT_SETTING_CP_USB)
			retain_mode = RETAIN_CP_USB;
		else if(muic_boot_path == PORT_SETTING_AP_USB)
			retain_mode = RETAIN_AP_USB;
	}
	printk("[KDH] muic keeping %d boot_path %d\n", muic_boot_keeping,muic_boot_path);
#endif

	/* Initializes MUIC - Finally MUIC INT becomes enabled */
	if (retain_mode == RETAIN_AP_USB) {
		muic_proc_set_ap_usb();	//[[email protected]] was not in cosmo code.
		muic_mode = MUIC_AP_USB;
		muic_init_device(DEFAULT);
		check_charging_mode();
		DBG("[MUIC] muic_init_device... retain mode = AP_USB\n");
	} else if (retain_mode == RETAIN_CP_USB) {
		muic_proc_set_cp_usb();
		muic_mode = MUIC_CP_USB;
		muic_init_device(DEFAULT);
		check_charging_mode();
		DBG("[MUIC] muic_detect_accessory... retain mode = CP_USB\n");
	} else {

		if (muic_init_device)
			muic_init_device(DEFAULT);	//[[email protected]] default is OK(already initialized at bootloader)
		else
			DBG("[MUIC] You should add codes for new MUIC chip");
		if (muic_detect_accessory)
			muic_detect_accessory(NOT_UPON_IRQ);
		else
			DBG("[MUIC] You should add codes for new MUIC chip");
	}

	//[[email protected]]
	set_muic_charger_detected();

	/* Makes the interrupt on MUIC_GPIO INT wake up AP which is in suspend mode */
#if 0
	ret = enable_irq_wake(gpio_to_irq(MUIC_GPIO));
	if (ret < 0) {
		DBG("[MUIC] MUIC_GPIO wake up source setting failed!\n");
		disable_irq_wake(gpio_to_irq(MUIC_GPIO));
		return -ENOSYS;
	}
#endif//
        register_reboot_notifier(&muic_reboot_nb);
	DBG();

	return ret;
}
Esempio n. 4
0
/*****************************************************************************************
 *  
 *  function    : gp2a_work_func_prox 
 *  description : This function is for proximity sensor (using B-1 Mode ). 
 *                when INT signal is occured , it gets value from VO register.   
 */
void gp2a_work_func_prox(struct work_struct *work) {
	struct gp2a_data *gp2a = container_of(work, struct gp2a_data, work_prox);
	
	unsigned char value;
	unsigned char vout = 0;

	if (proximity_enable == OFF) {
		gprintk("proximity is not enable\n");
		return;
	}

	//20111001 [email protected] : change disable step for Mode B1
	disable_irq_nosync(gp2a->irq);
	
	//20111001 [email protected] : Set Operation mode B1 for X2 New HW Revision [S]
	/* Procedure 5 - Read VO & INT Clear */
	value = opt_i2c_read(gp2a, REGS_PROX);
	
	//Report Data toward HAL [S]
	vout = (value & 0x01)?0:1;
	//20110706 [email protected] : for diag test mode. 250.49 [S]
	if(vout)
		proximity_status = 0;
	else proximity_status = 1;
	//20110706 [email protected] : for diag test mode. 250.49 [E]
	gprintk("value = %x, vout = %d\n",value, vout);

	wake_lock_timeout(&gp2a_wake_lock, 3 * HZ);
	input_report_abs(gp2a->input_dev,ABS_DISTANCE,(int)vout);
	input_sync(gp2a->input_dev);
	mdelay(1);
	//Reposrt Data toward HAL [E]
	
	/* Procedure 6 - Write HYS Register */
//20111110 - [email protected] - Revision 처리 추가! - HW Tuning for Touch Window[S]	
#if defined(CONFIG_KS1103)
	if(get_lge_pcb_revision() > REV_C) {
		if(vout) 
			value = 0x00;
		else 
			value = 0xC3;
	} else {
		if(vout)
			value = 0x40;
		else
			value = 0x23;
	}
#else
	if(vout)
		value = 0x40;
	else
		value = 0x23;
#endif
//20111110 - [email protected] - Revision 처리 추가! - HW Tuning for Touch Window[E]
	opt_i2c_write(gp2a, (u8)(REGS_HYS), value);

	/* Procedure 7 - Forcing vout terminal to go high */
	opt_i2c_write(gp2a, (u8)(REGS_CON), 0x18);

	/* Procedure 8 - enable INT */
	enable_irq(gp2a->irq);
	mdelay(2);

	/* Procedure 9 - enabling VOUT terminal in nomal operation */
	opt_i2c_write(gp2a, (u8)(REGS_CON), 0x00);
	//20111001 [email protected] : Set Operation mode B1 for X2 New HW Revision [E]
}
Esempio n. 5
0
static void mpu3050_power_init(void)
{

	struct regulator *regulator1 = NULL;
	struct regulator *regulator2 = NULL;
	unsigned int gyro_int_gpio;

#ifdef CONFIG_MACH_STAR
	printk(KERN_INFO "[BCH][mpu-dev.c] enter [%s()] CONFIG_MACH_STAR \n", __func__);
	gyro_int_gpio = TEGRA_GPIO_PQ5
#else
#if defined (CONFIG_KS1001) 
	if(get_lge_pcb_revision() >= REV_C)
		gyro_int_gpio = TEGRA_GPIO_PF6;
	else
		gyro_int_gpio = TEGRA_GPIO_PB3;
#elif defined (CONFIG_KS1103)
	printk(KERN_INFO "[BCH][mpu-dev.c] enter [%s()] CONFIG_KS1103 \n", __func__);
	gyro_int_gpio = TEGRA_GPIO_PF6;
#else
	gyro_int_gpio = TEGRA_GPIO_PB3;
#endif	
#endif

	printk(KERN_INFO "mpu3050_power_init.. \n");

#ifdef CONFIG_MACH_BSSQ
	// 20110618 [email protected] Gyro sensor power sequence (OFF in BL -> ON in init)
	// Set GYRO_INT as input and LOW for 1.5s
	gpio_request(TEGRA_GPIO_PE1, "i2c_sw");
	tegra_gpio_enable(TEGRA_GPIO_PE1);
	gpio_direction_output(TEGRA_GPIO_PE1, 0);
#endif

	gpio_request(gyro_int_gpio, "gyro_int");
	tegra_gpio_enable(gyro_int_gpio);
	gpio_direction_output(gyro_int_gpio, 0);

	mdelay(1500);

	regulator1 = regulator_get(NULL, "vcc_sensor_3v0");
	if (!regulator1) {
		printk(KERN_INFO "mpu3050: vcc_sensor_3v0 failed\n");
	}
	regulator_set_voltage(regulator1, 3000000, 3000000);
	regulator2 = regulator_get(NULL, "vcc_sensor_1v8");
	if (!regulator2) {
		printk(KERN_INFO "mpu3050: vcc_sensor_1v8 failed\n");
	}
	regulator_set_voltage(regulator2, 1800000, 1800000);

	regulator_enable(regulator1);
	mdelay(10);
	regulator_enable(regulator2);
	mdelay(10); // [email protected] // HW req.
#ifdef CONFIG_MACH_BSSQ
	gpio_direction_output(TEGRA_GPIO_PE1, 1);
#endif
	gpio_direction_input(gyro_int_gpio);

	mdelay(1);
}