mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
Revert "power: pm8921-charger: disable AICL"
This reverts commit a6a33432dc20a3e43539dfa22ca25d51c6c9d57f.
This commit is contained in:
parent
3d2444690c
commit
c5d10ae0e5
1 changed files with 53 additions and 93 deletions
|
@ -294,7 +294,6 @@ struct pm8921_chg_chip {
|
|||
int btc_delay_ms;
|
||||
bool btc_panic_if_cant_stop_chg;
|
||||
int stop_chg_upon_expiry;
|
||||
bool disable_aicl;
|
||||
};
|
||||
|
||||
/* user space parameter to limit usb current */
|
||||
|
@ -1389,7 +1388,6 @@ static enum power_supply_property pm_power_props_usb[] = {
|
|||
POWER_SUPPLY_PROP_ONLINE,
|
||||
POWER_SUPPLY_PROP_CURRENT_MAX,
|
||||
POWER_SUPPLY_PROP_SCOPE,
|
||||
POWER_SUPPLY_PROP_HEALTH,
|
||||
};
|
||||
|
||||
static enum power_supply_property pm_power_props_mains[] = {
|
||||
|
@ -1440,24 +1438,6 @@ static int pm_power_get_property_mains(struct power_supply *psy,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int disable_aicl(int disable)
|
||||
{
|
||||
if (disable != POWER_SUPPLY_HEALTH_UNKNOWN
|
||||
&& disable != POWER_SUPPLY_HEALTH_GOOD) {
|
||||
pr_err("called with invalid param :%d\n", disable);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!the_chip) {
|
||||
pr_err("%s called before init\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pr_debug("Disable AICL = %d\n", disable);
|
||||
the_chip->disable_aicl = disable;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int switch_usb_to_charge_mode(struct pm8921_chg_chip *chip)
|
||||
{
|
||||
int rc;
|
||||
|
@ -1515,28 +1495,12 @@ static int pm_power_set_property_usb(struct power_supply *psy,
|
|||
break;
|
||||
case POWER_SUPPLY_PROP_TYPE:
|
||||
return pm8921_set_usb_power_supply_type(val->intval);
|
||||
case POWER_SUPPLY_PROP_HEALTH:
|
||||
/* UNKNOWN(0) means enable aicl, GOOD(1) means disable aicl */
|
||||
return disable_aicl(val->intval);
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usb_property_is_writeable(struct power_supply *psy,
|
||||
enum power_supply_property psp)
|
||||
{
|
||||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_HEALTH:
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pm_power_get_property_usb(struct power_supply *psy,
|
||||
enum power_supply_property psp,
|
||||
union power_supply_propval *val)
|
||||
|
@ -1571,10 +1535,6 @@ static int pm_power_get_property_usb(struct power_supply *psy,
|
|||
else
|
||||
val->intval = POWER_SUPPLY_SCOPE_DEVICE;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_HEALTH:
|
||||
/* UNKNOWN(0) means enable aicl, GOOD(1) means disable aicl */
|
||||
val->intval = the_chip->disable_aicl;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -1870,6 +1830,7 @@ static int pm_batt_power_get_property(struct power_supply *psy,
|
|||
|
||||
static void (*notify_vbus_state_func_ptr)(int);
|
||||
static int usb_chg_current;
|
||||
static DEFINE_SPINLOCK(vbus_lock);
|
||||
|
||||
int pm8921_charger_register_vbus_sn(void (*callback)(int))
|
||||
{
|
||||
|
@ -1898,6 +1859,7 @@ static void notify_usb_of_the_plugin_event(int plugin)
|
|||
}
|
||||
}
|
||||
|
||||
/* assumes vbus_lock is held */
|
||||
static void __pm8921_charger_vbus_draw(unsigned int mA)
|
||||
{
|
||||
int i, rc;
|
||||
|
@ -1951,10 +1913,15 @@ static void __pm8921_charger_vbus_draw(unsigned int mA)
|
|||
/* USB calls these to tell us how much max usb current the system can draw */
|
||||
void pm8921_charger_vbus_draw(unsigned int mA)
|
||||
{
|
||||
int set_usb_now_ma;
|
||||
unsigned long flags;
|
||||
|
||||
pr_debug("Enter charge=%d\n", mA);
|
||||
|
||||
if (!the_chip) {
|
||||
pr_err("chip not yet initalized\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reject VBUS requests if USB connection is the only available
|
||||
* power source. This makes sure that if booting without
|
||||
|
@ -1964,7 +1931,7 @@ void pm8921_charger_vbus_draw(unsigned int mA)
|
|||
* This would also apply when the battery has been
|
||||
* removed from the running system.
|
||||
*/
|
||||
if (the_chip && !get_prop_batt_present(the_chip)
|
||||
if (!get_prop_batt_present(the_chip)
|
||||
&& !is_dc_chg_plugged_in(the_chip)) {
|
||||
if (!the_chip->has_dc_supply) {
|
||||
pr_err("rejected: no other power source connected\n");
|
||||
|
@ -1983,23 +1950,23 @@ void pm8921_charger_vbus_draw(unsigned int mA)
|
|||
if (usb_target_ma)
|
||||
usb_target_ma = mA;
|
||||
|
||||
|
||||
if (mA > USB_WALL_THRESHOLD_MA)
|
||||
set_usb_now_ma = USB_WALL_THRESHOLD_MA;
|
||||
else
|
||||
set_usb_now_ma = mA;
|
||||
|
||||
if (the_chip && the_chip->disable_aicl)
|
||||
set_usb_now_ma = mA;
|
||||
|
||||
if (the_chip)
|
||||
__pm8921_charger_vbus_draw(set_usb_now_ma);
|
||||
else
|
||||
spin_lock_irqsave(&vbus_lock, flags);
|
||||
if (the_chip) {
|
||||
if (mA > USB_WALL_THRESHOLD_MA)
|
||||
__pm8921_charger_vbus_draw(USB_WALL_THRESHOLD_MA);
|
||||
else
|
||||
__pm8921_charger_vbus_draw(mA);
|
||||
} else {
|
||||
/*
|
||||
* called before pmic initialized,
|
||||
* save this value and use it at probe
|
||||
*/
|
||||
usb_chg_current = set_usb_now_ma;
|
||||
if (mA > USB_WALL_THRESHOLD_MA)
|
||||
usb_chg_current = USB_WALL_THRESHOLD_MA;
|
||||
else
|
||||
usb_chg_current = mA;
|
||||
}
|
||||
spin_unlock_irqrestore(&vbus_lock, flags);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pm8921_charger_vbus_draw);
|
||||
|
||||
|
@ -2638,8 +2605,7 @@ static void vin_collapse_check_worker(struct work_struct *work)
|
|||
* The AICL algorithm will step up the current from 500mA to target
|
||||
*/
|
||||
if (is_usb_chg_plugged_in(chip)
|
||||
&& usb_target_ma > USB_WALL_THRESHOLD_MA
|
||||
&& !chip->disable_aicl) {
|
||||
&& usb_target_ma > USB_WALL_THRESHOLD_MA) {
|
||||
/* decrease usb_target_ma */
|
||||
decrease_usb_ma_value(&usb_target_ma);
|
||||
/* reset here, increase in unplug_check_worker */
|
||||
|
@ -2902,8 +2868,7 @@ static void unplug_check_worker(struct work_struct *work)
|
|||
chip->final_kickstart = true;
|
||||
|
||||
/* AICL only for usb wall charger */
|
||||
if ((active_path & USB_ACTIVE_BIT) && usb_target_ma > 0 &&
|
||||
!chip->disable_aicl) {
|
||||
if ((active_path & USB_ACTIVE_BIT) && usb_target_ma > 0) {
|
||||
reg_loop = pm_chg_get_regulation_loop(chip);
|
||||
pr_debug("reg_loop=0x%x usb_ma = %d\n", reg_loop, usb_ma);
|
||||
if ((reg_loop & VIN_ACTIVE_BIT) &&
|
||||
|
@ -2951,8 +2916,7 @@ static void unplug_check_worker(struct work_struct *work)
|
|||
/* AICL only for usb wall charger */
|
||||
if (!(reg_loop & VIN_ACTIVE_BIT) && (active_path & USB_ACTIVE_BIT)
|
||||
&& usb_target_ma > 0
|
||||
&& !charging_disabled
|
||||
&& !chip->disable_aicl) {
|
||||
&& !charging_disabled) {
|
||||
/* only increase iusb_max if vin loop not active */
|
||||
if (usb_ma < usb_target_ma) {
|
||||
increase_usb_ma_value(&usb_ma);
|
||||
|
@ -3872,6 +3836,7 @@ static void free_irqs(struct pm8921_chg_chip *chip)
|
|||
/* determines the initial present states */
|
||||
static void __devinit determine_initial_state(struct pm8921_chg_chip *chip)
|
||||
{
|
||||
unsigned long flags;
|
||||
int fsm_state;
|
||||
int is_fast_chg;
|
||||
|
||||
|
@ -3896,16 +3861,12 @@ static void __devinit determine_initial_state(struct pm8921_chg_chip *chip)
|
|||
pm8921_chg_enable_irq(chip, VBATDET_LOW_IRQ);
|
||||
pm8921_chg_enable_irq(chip, BAT_TEMP_OK_IRQ);
|
||||
|
||||
if (get_prop_batt_present(the_chip) || is_dc_chg_plugged_in(the_chip))
|
||||
if (usb_chg_current)
|
||||
/*
|
||||
* Reissue a vbus draw call only if a battery
|
||||
* or DC is present. We don't want to brown out the
|
||||
* device if usb is its only source
|
||||
*/
|
||||
__pm8921_charger_vbus_draw(usb_chg_current);
|
||||
usb_chg_current = 0;
|
||||
|
||||
spin_lock_irqsave(&vbus_lock, flags);
|
||||
if (usb_chg_current) {
|
||||
/* reissue a vbus draw call */
|
||||
__pm8921_charger_vbus_draw(usb_chg_current);
|
||||
}
|
||||
spin_unlock_irqrestore(&vbus_lock, flags);
|
||||
/*
|
||||
* The bootloader could have started charging, a fastchg interrupt
|
||||
* might not happen. Check the real time status and if it is fast
|
||||
|
@ -4769,30 +4730,29 @@ static int __devinit pm8921_charger_probe(struct platform_device *pdev)
|
|||
|
||||
chip->stop_chg_upon_expiry = pdata->stop_chg_upon_expiry;
|
||||
|
||||
chip->usb_psy.name = "usb";
|
||||
chip->usb_psy.type = POWER_SUPPLY_TYPE_USB;
|
||||
chip->usb_psy.supplied_to = pm_power_supplied_to;
|
||||
chip->usb_psy.num_supplicants = ARRAY_SIZE(pm_power_supplied_to);
|
||||
chip->usb_psy.properties = pm_power_props_usb;
|
||||
chip->usb_psy.num_properties = ARRAY_SIZE(pm_power_props_usb);
|
||||
chip->usb_psy.get_property = pm_power_get_property_usb;
|
||||
chip->usb_psy.set_property = pm_power_set_property_usb;
|
||||
chip->usb_psy.property_is_writeable = usb_property_is_writeable;
|
||||
chip->usb_psy.name = "usb",
|
||||
chip->usb_psy.type = POWER_SUPPLY_TYPE_USB,
|
||||
chip->usb_psy.supplied_to = pm_power_supplied_to,
|
||||
chip->usb_psy.num_supplicants = ARRAY_SIZE(pm_power_supplied_to),
|
||||
chip->usb_psy.properties = pm_power_props_usb,
|
||||
chip->usb_psy.num_properties = ARRAY_SIZE(pm_power_props_usb),
|
||||
chip->usb_psy.get_property = pm_power_get_property_usb,
|
||||
chip->usb_psy.set_property = pm_power_set_property_usb,
|
||||
|
||||
chip->dc_psy.name = "pm8921-dc";
|
||||
chip->dc_psy.type = POWER_SUPPLY_TYPE_MAINS;
|
||||
chip->dc_psy.supplied_to = pm_power_supplied_to;
|
||||
chip->dc_psy.num_supplicants = ARRAY_SIZE(pm_power_supplied_to);
|
||||
chip->dc_psy.properties = pm_power_props_mains;
|
||||
chip->dc_psy.num_properties = ARRAY_SIZE(pm_power_props_mains);
|
||||
chip->dc_psy.get_property = pm_power_get_property_mains;
|
||||
chip->dc_psy.name = "pm8921-dc",
|
||||
chip->dc_psy.type = POWER_SUPPLY_TYPE_MAINS,
|
||||
chip->dc_psy.supplied_to = pm_power_supplied_to,
|
||||
chip->dc_psy.num_supplicants = ARRAY_SIZE(pm_power_supplied_to),
|
||||
chip->dc_psy.properties = pm_power_props_mains,
|
||||
chip->dc_psy.num_properties = ARRAY_SIZE(pm_power_props_mains),
|
||||
chip->dc_psy.get_property = pm_power_get_property_mains,
|
||||
|
||||
chip->batt_psy.name = "battery";
|
||||
chip->batt_psy.type = POWER_SUPPLY_TYPE_BATTERY;
|
||||
chip->batt_psy.properties = msm_batt_power_props;
|
||||
chip->batt_psy.num_properties = ARRAY_SIZE(msm_batt_power_props);
|
||||
chip->batt_psy.get_property = pm_batt_power_get_property;
|
||||
chip->batt_psy.external_power_changed = pm_batt_external_power_changed;
|
||||
chip->batt_psy.name = "battery",
|
||||
chip->batt_psy.type = POWER_SUPPLY_TYPE_BATTERY,
|
||||
chip->batt_psy.properties = msm_batt_power_props,
|
||||
chip->batt_psy.num_properties = ARRAY_SIZE(msm_batt_power_props),
|
||||
chip->batt_psy.get_property = pm_batt_power_get_property,
|
||||
chip->batt_psy.external_power_changed = pm_batt_external_power_changed,
|
||||
rc = power_supply_register(chip->dev, &chip->usb_psy);
|
||||
if (rc < 0) {
|
||||
pr_err("power_supply_register usb failed rc = %d\n", rc);
|
||||
|
|
Loading…
Reference in a new issue