示例#1
0
void set_charging_current(void)
{
	static int old_status = -1;
	int current_status = -1;

	if( !get_madc_probe_done() )
		return ;

	current_status = get_external_power_status();
	if( old_status != current_status ) {

		if( -1 == lge_usb_acc_detect())
			return ;

#ifdef CONFIG_LGE_BATT_THERM_LAB3_SCENARIO
		need_to_batt_therm_sett = 1;
#endif

		set_charging_current_sub();

		old_status = current_status;
	}

	charger_state_update_by_other();
	return ;
}
示例#2
0
void set_charging_current(void)
{
	static int old_status = -1;
	int current_status = -1;

	if( !get_madc_probe_done() )
		return ;

	current_status = get_external_power_status();
	if( old_status != current_status ) {

		/* mbk_temp */
		lge_usb_acc_detect();

		switch( get_ext_pwr_type() ) {
			case NO_CABLE:
				break;
			case LT_CABLE:
				// if LT_Cable, u-boot already set charing current. in kernel no need to set 
				//charging_ic_set_factory_mode();

				/* mbk_temp HW Request */
				setting_for_factory_mode_hw_req();
				break;
			case TA_CABLE:
			case FORGED_TA_CABLE:
				charging_ic_set_ta_mode();
				break;
		}
		printk("[charging_msg] %s, External Power Type %d \n", __FUNCTION__, get_ext_pwr_type());

		old_status = current_status;
	}

	charger_state_update_by_other();
	return ;
}
示例#3
0
int lge_usb_dp_dm_check(struct twl4030_usb *twl)
{
#if 0
	cable_dp_dm_short = 1;
	return 0;
#else
	int ret;
	int is_short;
	u8 reg_val;
	u8 reg_backup[2];

//20110804 [email protected] [LS855] skipping check d+/d- when detect LT Cable. [START]
#if 1
	check_cable_type = get_ext_pwr_type();

	if( get_external_power_status()||((check_cable_type==LT_CABLE_56K || check_cable_type==LT_CABLE_130K || check_cable_type==LT_CABLE_910K)))
		return 0;
#else
	if( get_external_power_status())
		return 0;
#endif
//20110804 [email protected] [LS855] skipping check d+/d- when detect LT Cable. [END]


#if 1 /* already exist in twl4030_phy_power() */
//	printk("twl : 0x%x\n", twl);

//	regulator_enable(twl->usb3v1);
	regulator_enable(twl->usb1v8);
	regulator_enable(twl->usb1v5);

	/* PHY power up */
	twl_i2c_read_u8(TWL4030_MODULE_USB, &reg_val, PHY_PWR_CTRL);
	reg_val &= ~PHY_PWR_PHYPWD;
	ret = twl_i2c_write_u8(TWL4030_MODULE_USB, reg_val, PHY_PWR_CTRL);
	if (ret)
		goto err_short_chk1;

	/* ULPI register clock gating is enable */
	ret = twl_i2c_read_u8(TWL4030_MODULE_USB, &reg_backup[0], PHY_CLK_CTRL);
	if (ret)
		goto err_short_chk2;

	ret = twl_i2c_write_u8(TWL4030_MODULE_USB,
			reg_backup[0] | PHY_CLK_CTRL_CLOCKGATING_EN, PHY_CLK_CTRL);
	if (ret)
		goto err_short_chk2;
#endif

	ret = twl_i2c_write_u8(TWL4030_MODULE_USB,
			FUNC_CTRL_XCVRSELECT_MASK | FUNC_CTRL_OPMODE_MASK, FUNC_CTRL_CLR);
	if (ret)
		goto err_short_chk3;

	/* Disable D+, D- pulldown */
	ret = twl_i2c_write_u8(TWL4030_MODULE_USB,
			OTG_CTRL_DMPULLDOWN | OTG_CTRL_DPPULLDOWN, OTG_CTRL_CLR);
	if (ret)
		goto err_short_chk4;

	/* Set D+ to high, D- to low */
#if 0
	ret = twl_i2c_read_u8(TWL4030_MODULE_USB, &reg_val, OTHER_FUNC_CTRL);
	if (ret)
		goto err_short_chk5;

	reg_backup[1] = reg_val & ~(DM_PULLUP | DP_PULLUP);
	ret = twl_i2c_write_u8(TWL4030_MODULE_USB,
			reg_backup[1] | DP_PULLUP, OTHER_FUNC_CTRL);
#else
	ret = twl_i2c_read_u8(TWL4030_MODULE_USB, &reg_backup[1], OTHER_FUNC_CTRL);
	if (ret)
		goto err_short_chk5;

	reg_val = reg_backup[1] & ~(DM_PULLUP | DP_PULLUP);
	ret = twl_i2c_write_u8(TWL4030_MODULE_USB,
			reg_val | DP_PULLUP, OTHER_FUNC_CTRL);
#endif

	if (ret)
		goto err_short_chk5;

	/* Check D- line */
	ret = twl_i2c_read_u8(TWL4030_MODULE_USB, &reg_val, OTHER_INT_STS);
	if (ret)
		goto err_short_chk6;

	if ((reg_val & 0x60) == 0x60)
		is_short = 1;
	else
		is_short = 0;

	/* Set to default */
	twl_i2c_write_u8(TWL4030_MODULE_USB, reg_backup[1], OTHER_FUNC_CTRL);
	twl_i2c_write_u8(TWL4030_MODULE_USB,
			OTG_CTRL_DMPULLDOWN | OTG_CTRL_DPPULLDOWN, OTG_CTRL_SET);
	twl_i2c_write_u8(TWL4030_MODULE_USB,
			FUNC_CTRL_XCVRSELECT_MASK | FUNC_CTRL_OPMODE_MASK, FUNC_CTRL_SET);
#if 0
	twl_i2c_write_u8(TWL4030_MODULE_USB, reg_backup[0], PHY_CLK_CTRL);	/* ULPI register clock gating is disble */
	/* LGE_CHANGE_S [VX20000:FW:[email protected]] 2009-06-08, XXX_mbk_ADC_VBATT_THRM 
	 * If below code is not present in TA Cable asserted, 
	 * we can not set SEL_MADC_MCPC to 1 in ther CARKIT_ANA_CTRL
	 * I don't know why......*/ 
#if 1
	/*#define REG_CARKIT_ANA_CTRL		0xBB */

	ret = twl_i2c_read_u8(TWL4030_MODULE_USB,
			&data_temp,
			REG_CARKIT_ANA_CTRL);
	if (ret) {
		printk(KERN_ERR "%s: BUSY flag.\n", __func__);
	}
#endif
	/* LGE_CHANGE_E [VX20000:FW:[email protected]] / 2009-06-08 */
#endif

	twl_i2c_read_u8(TWL4030_MODULE_USB, &reg_val, PHY_PWR_CTRL);
	reg_val |= PHY_PWR_PHYPWD;
	twl_i2c_write_u8(TWL4030_MODULE_USB, reg_val, PHY_PWR_CTRL);	/* PHY power down */
	//twl4030_i2c_access(0);
	regulator_disable(twl->usb1v5);
	regulator_disable(twl->usb1v8);
//	regulator_disable(twl->usb3v1);

	cable_dp_dm_short = is_short; 

	printk(KERN_DEBUG "%s: D+ and D- lines are %s\n", __func__, is_short? "short":"open");
	return 0;

err_short_chk6:
	twl_i2c_write_u8(TWL4030_MODULE_USB, reg_backup[1], OTHER_FUNC_CTRL);
err_short_chk5:
	twl_i2c_write_u8(TWL4030_MODULE_USB,
			OTG_CTRL_DMPULLDOWN | OTG_CTRL_DPPULLDOWN, OTG_CTRL_SET);
err_short_chk4:
	twl_i2c_write_u8(TWL4030_MODULE_USB,
			FUNC_CTRL_XCVRSELECT_MASK | FUNC_CTRL_OPMODE_MASK, FUNC_CTRL_SET);
err_short_chk3:
	twl_i2c_write_u8(TWL4030_MODULE_USB, reg_backup[0], PHY_CLK_CTRL);
err_short_chk2:
	twl_i2c_write_u8(TWL4030_MODULE_USB, PHY_PWR_PHYPWD, PHY_PWR_CTRL);
err_short_chk1:
	//twl4030_i2c_access(0);

	regulator_disable(twl->usb1v5);
	regulator_disable(twl->usb1v8);
//	regulator_disable(twl->usb3v1);

	printk(KERN_ERR "%s: Error \n", __func__);
	return ret;
#endif
}