power_supply: update to the new registration scheme
The power_supply class in 4.4 kernel changes power_supply registration to pass in a descriptor and a configuration structure. Update msm power_supply registering drivers with the new scheme. Change-Id: Iaf63a96ab01f9d4676681ee4e6cf61ac2e8d3f4d Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
This commit is contained in:
parent
2a65148ba7
commit
8b5cc3d711
5 changed files with 249 additions and 224 deletions
|
@ -127,7 +127,8 @@ struct bcl_device {
|
|||
};
|
||||
|
||||
static struct bcl_device *bcl_perph;
|
||||
static struct power_supply bcl_psy;
|
||||
static struct power_supply_desc bcl_psy_d;
|
||||
static struct power_supply *bcl_psy;
|
||||
static const char bcl_psy_name[] = "fg_adc";
|
||||
static bool calibration_done;
|
||||
static DEFINE_MUTEX(bcl_access_mutex);
|
||||
|
@ -1000,6 +1001,7 @@ update_data_exit:
|
|||
static int bcl_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret = 0;
|
||||
struct power_supply_config bcl_psy_cfg;
|
||||
|
||||
bcl_perph = devm_kzalloc(&pdev->dev, sizeof(struct bcl_device),
|
||||
GFP_KERNEL);
|
||||
|
@ -1025,15 +1027,21 @@ static int bcl_probe(struct platform_device *pdev)
|
|||
pr_debug("Could not read calibration values. err:%d", ret);
|
||||
goto bcl_probe_exit;
|
||||
}
|
||||
bcl_psy.name = bcl_psy_name;
|
||||
bcl_psy.type = POWER_SUPPLY_TYPE_BMS;
|
||||
bcl_psy.get_property = bcl_psy_get_property;
|
||||
bcl_psy.set_property = bcl_psy_set_property;
|
||||
bcl_psy.num_properties = 0;
|
||||
bcl_psy.external_power_changed = power_supply_callback;
|
||||
ret = power_supply_register(&pdev->dev, &bcl_psy);
|
||||
if (ret < 0) {
|
||||
pr_err("Unable to register bcl_psy rc = %d\n", ret);
|
||||
bcl_psy_d.name = bcl_psy_name;
|
||||
bcl_psy_d.type = POWER_SUPPLY_TYPE_BMS;
|
||||
bcl_psy_d.get_property = bcl_psy_get_property;
|
||||
bcl_psy_d.set_property = bcl_psy_set_property;
|
||||
bcl_psy_d.num_properties = 0;
|
||||
bcl_psy_d.external_power_changed = power_supply_callback;
|
||||
|
||||
bcl_psy_cfg.num_supplicants = 0;
|
||||
bcl_psy_cfg.drv_data = bcl_perph;
|
||||
|
||||
bcl_psy = devm_power_supply_register(&pdev->dev, &bcl_psy_d,
|
||||
&bcl_psy_cfg);
|
||||
if (IS_ERR(bcl_psy)) {
|
||||
pr_err("Unable to register bcl_psy rc = %ld\n",
|
||||
PTR_ERR(bcl_psy));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -418,7 +418,8 @@ struct fg_chip {
|
|||
struct completion sram_access_revoked;
|
||||
struct completion batt_id_avail;
|
||||
struct completion first_soc_done;
|
||||
struct power_supply bms_psy;
|
||||
struct power_supply *bms_psy;
|
||||
struct power_supply_desc bms_psy_d;
|
||||
struct mutex rw_lock;
|
||||
struct mutex sysfs_restart_lock;
|
||||
struct delayed_work batt_profile_init;
|
||||
|
@ -2619,7 +2620,7 @@ static int fg_power_get_property(struct power_supply *psy,
|
|||
enum power_supply_property psp,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
struct fg_chip *chip = container_of(psy, struct fg_chip, bms_psy);
|
||||
struct fg_chip *chip = power_supply_get_drvdata(psy);
|
||||
bool vbatt_low_sts;
|
||||
|
||||
switch (psp) {
|
||||
|
@ -3513,7 +3514,7 @@ static int fg_power_set_property(struct power_supply *psy,
|
|||
enum power_supply_property psp,
|
||||
const union power_supply_propval *val)
|
||||
{
|
||||
struct fg_chip *chip = container_of(psy, struct fg_chip, bms_psy);
|
||||
struct fg_chip *chip = power_supply_get_drvdata(psy);
|
||||
int rc = 0, unused;
|
||||
|
||||
switch (psp) {
|
||||
|
@ -3840,7 +3841,7 @@ static irqreturn_t fg_vbatt_low_handler(int irq, void *_chip)
|
|||
}
|
||||
}
|
||||
if (chip->power_supply_registered)
|
||||
power_supply_changed(&chip->bms_psy);
|
||||
power_supply_changed(chip->bms_psy);
|
||||
out:
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
@ -3878,7 +3879,7 @@ static irqreturn_t fg_batt_missing_irq_handler(int irq, void *_chip)
|
|||
batt_missing ? "missing" : "present");
|
||||
|
||||
if (chip->power_supply_registered)
|
||||
power_supply_changed(&chip->bms_psy);
|
||||
power_supply_changed(chip->bms_psy);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -3932,7 +3933,7 @@ static irqreturn_t fg_soc_irq_handler(int irq, void *_chip)
|
|||
schedule_work(&chip->battery_age_work);
|
||||
|
||||
if (chip->power_supply_registered)
|
||||
power_supply_changed(&chip->bms_psy);
|
||||
power_supply_changed(chip->bms_psy);
|
||||
|
||||
if (chip->rslow_comp.chg_rs_to_rslow > 0 &&
|
||||
chip->rslow_comp.chg_rslow_comp_c1 > 0 &&
|
||||
|
@ -3997,7 +3998,7 @@ static irqreturn_t fg_first_soc_irq_handler(int irq, void *_chip)
|
|||
schedule_work(&chip->dump_sram);
|
||||
|
||||
if (chip->power_supply_registered)
|
||||
power_supply_changed(&chip->bms_psy);
|
||||
power_supply_changed(chip->bms_psy);
|
||||
|
||||
complete_all(&chip->first_soc_done);
|
||||
|
||||
|
@ -4006,7 +4007,7 @@ static irqreturn_t fg_first_soc_irq_handler(int irq, void *_chip)
|
|||
|
||||
static void fg_external_power_changed(struct power_supply *psy)
|
||||
{
|
||||
struct fg_chip *chip = container_of(psy, struct fg_chip, bms_psy);
|
||||
struct fg_chip *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
if (is_input_present(chip) && chip->rslow_comp.active &&
|
||||
chip->rslow_comp.chg_rs_to_rslow > 0 &&
|
||||
|
@ -4728,7 +4729,7 @@ wait:
|
|||
goto reschedule;
|
||||
}
|
||||
if (chip->power_supply_registered)
|
||||
power_supply_changed(&chip->bms_psy);
|
||||
power_supply_changed(chip->bms_psy);
|
||||
|
||||
memcpy(chip->batt_profile, data, len);
|
||||
|
||||
|
@ -4784,14 +4785,14 @@ done:
|
|||
estimate_battery_age(chip, &chip->actual_cap_uah);
|
||||
schedule_work(&chip->status_change_work);
|
||||
if (chip->power_supply_registered)
|
||||
power_supply_changed(&chip->bms_psy);
|
||||
power_supply_changed(chip->bms_psy);
|
||||
fg_relax(&chip->profile_wakeup_source);
|
||||
pr_info("Battery SOC: %d, V: %duV\n", get_prop_capacity(chip),
|
||||
fg_data[FG_DATA_VOLTAGE].value);
|
||||
return rc;
|
||||
no_profile:
|
||||
if (chip->power_supply_registered)
|
||||
power_supply_changed(&chip->bms_psy);
|
||||
power_supply_changed(chip->bms_psy);
|
||||
fg_relax(&chip->profile_wakeup_source);
|
||||
return rc;
|
||||
reschedule:
|
||||
|
@ -4813,7 +4814,7 @@ static void check_empty_work(struct work_struct *work)
|
|||
pr_info("EMPTY SOC high\n");
|
||||
chip->soc_empty = true;
|
||||
if (chip->power_supply_registered)
|
||||
power_supply_changed(&chip->bms_psy);
|
||||
power_supply_changed(chip->bms_psy);
|
||||
}
|
||||
fg_relax(&chip->empty_check_wakeup_source);
|
||||
}
|
||||
|
@ -5400,7 +5401,6 @@ static void fg_cleanup(struct fg_chip *chip)
|
|||
cancel_work_sync(&chip->gain_comp_work);
|
||||
cancel_work_sync(&chip->init_work);
|
||||
cancel_work_sync(&chip->charge_full_work);
|
||||
power_supply_unregister(&chip->bms_psy);
|
||||
mutex_destroy(&chip->rslow_comp.lock);
|
||||
mutex_destroy(&chip->rw_lock);
|
||||
mutex_destroy(&chip->cyc_ctr.lock);
|
||||
|
@ -6306,6 +6306,7 @@ static int fg_probe(struct platform_device *pdev)
|
|||
unsigned int base;
|
||||
u8 subtype, reg;
|
||||
int rc = 0;
|
||||
struct power_supply_config bms_psy_cfg;
|
||||
|
||||
if (!pdev) {
|
||||
pr_err("no valid spmi pointer\n");
|
||||
|
@ -6473,20 +6474,25 @@ static int fg_probe(struct platform_device *pdev)
|
|||
|
||||
chip->batt_type = default_batt_type;
|
||||
|
||||
chip->bms_psy.name = "bms";
|
||||
chip->bms_psy.type = POWER_SUPPLY_TYPE_BMS;
|
||||
chip->bms_psy.properties = fg_power_props;
|
||||
chip->bms_psy.num_properties = ARRAY_SIZE(fg_power_props);
|
||||
chip->bms_psy.get_property = fg_power_get_property;
|
||||
chip->bms_psy.set_property = fg_power_set_property;
|
||||
chip->bms_psy.external_power_changed = fg_external_power_changed;
|
||||
chip->bms_psy.supplied_to = fg_supplicants;
|
||||
chip->bms_psy.num_supplicants = ARRAY_SIZE(fg_supplicants);
|
||||
chip->bms_psy.property_is_writeable = fg_property_is_writeable;
|
||||
chip->bms_psy_d.name = "bms";
|
||||
chip->bms_psy_d.type = POWER_SUPPLY_TYPE_BMS;
|
||||
chip->bms_psy_d.properties = fg_power_props;
|
||||
chip->bms_psy_d.num_properties = ARRAY_SIZE(fg_power_props);
|
||||
chip->bms_psy_d.get_property = fg_power_get_property;
|
||||
chip->bms_psy_d.set_property = fg_power_set_property;
|
||||
chip->bms_psy_d.external_power_changed = fg_external_power_changed;
|
||||
chip->bms_psy_d.property_is_writeable = fg_property_is_writeable;
|
||||
|
||||
rc = power_supply_register(chip->dev, &chip->bms_psy);
|
||||
if (rc < 0) {
|
||||
pr_err("batt failed to register rc = %d\n", rc);
|
||||
bms_psy_cfg.drv_data = chip;
|
||||
bms_psy_cfg.supplied_to = fg_supplicants;
|
||||
bms_psy_cfg.num_supplicants = ARRAY_SIZE(fg_supplicants);
|
||||
bms_psy_cfg.of_node = NULL;
|
||||
chip->bms_psy = devm_power_supply_register(chip->dev,
|
||||
&chip->bms_psy_d,
|
||||
&bms_psy_cfg);
|
||||
if (IS_ERR(chip->bms_psy)) {
|
||||
pr_err("batt failed to register rc = %ld\n",
|
||||
PTR_ERR(chip->bms_psy));
|
||||
goto of_init_fail;
|
||||
}
|
||||
chip->power_supply_registered = true;
|
||||
|
@ -6500,7 +6506,7 @@ static int fg_probe(struct platform_device *pdev)
|
|||
rc = fg_dfs_create(chip);
|
||||
if (rc < 0) {
|
||||
pr_err("failed to create debugfs rc = %d\n", rc);
|
||||
goto power_supply_unregister;
|
||||
goto cancel_work;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6513,8 +6519,6 @@ static int fg_probe(struct platform_device *pdev)
|
|||
|
||||
return rc;
|
||||
|
||||
power_supply_unregister:
|
||||
power_supply_unregister(&chip->bms_psy);
|
||||
cancel_work:
|
||||
cancel_delayed_work_sync(&chip->update_jeita_setting);
|
||||
cancel_delayed_work_sync(&chip->update_sram_data);
|
||||
|
@ -6637,7 +6641,7 @@ static int fg_sense_type_set(const char *val, const struct kernel_param *kp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
chip = container_of(bms_psy, struct fg_chip, bms_psy);
|
||||
chip = power_supply_get_drvdata(bms_psy);
|
||||
rc = set_prop_sense_type(chip, fg_sense_type);
|
||||
return rc;
|
||||
}
|
||||
|
@ -6659,7 +6663,7 @@ static int fg_restart_set(const char *val, const struct kernel_param *kp)
|
|||
pr_err("bms psy not found\n");
|
||||
return 0;
|
||||
}
|
||||
chip = container_of(bms_psy, struct fg_chip, bms_psy);
|
||||
chip = power_supply_get_drvdata(bms_psy);
|
||||
|
||||
mutex_lock(&chip->sysfs_restart_lock);
|
||||
if (fg_restart != 0) {
|
||||
|
|
|
@ -236,8 +236,10 @@ struct smbchg_chip {
|
|||
|
||||
/* psy */
|
||||
struct power_supply *usb_psy;
|
||||
struct power_supply batt_psy;
|
||||
struct power_supply dc_psy;
|
||||
struct power_supply_desc batt_psy_d;
|
||||
struct power_supply *batt_psy;
|
||||
struct power_supply_desc dc_psy_d;
|
||||
struct power_supply *dc_psy;
|
||||
struct power_supply *bms_psy;
|
||||
struct power_supply *typec_psy;
|
||||
int dc_psy_type;
|
||||
|
@ -2346,7 +2348,7 @@ static int dc_suspend_vote_cb(struct device *dev, int suspend,
|
|||
return rc;
|
||||
|
||||
if (chip->dc_psy_type != -EINVAL && chip->psy_registered)
|
||||
power_supply_changed(&chip->dc_psy);
|
||||
power_supply_changed(chip->dc_psy);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -3542,8 +3544,7 @@ static void check_battery_type(struct smbchg_chip *chip)
|
|||
|
||||
static void smbchg_external_power_changed(struct power_supply *psy)
|
||||
{
|
||||
struct smbchg_chip *chip = container_of(psy,
|
||||
struct smbchg_chip, batt_psy);
|
||||
struct smbchg_chip *chip = power_supply_get_drvdata(psy);
|
||||
union power_supply_propval prop = {0,};
|
||||
int rc, current_limit = 0, soc;
|
||||
enum power_supply_type usb_supply_type;
|
||||
|
@ -3596,7 +3597,7 @@ static void smbchg_external_power_changed(struct power_supply *psy)
|
|||
skip_current_for_non_sdp:
|
||||
smbchg_vfloat_adjust_check(chip);
|
||||
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
}
|
||||
|
||||
static int smbchg_otg_regulator_enable(struct regulator_dev *rdev)
|
||||
|
@ -4428,7 +4429,7 @@ static void smbchg_hvdcp_det_work(struct work_struct *work)
|
|||
smbchg_change_usb_supply_type(chip,
|
||||
POWER_SUPPLY_TYPE_USB_HVDCP);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_aicl_deglitch_wa_check(chip);
|
||||
}
|
||||
}
|
||||
|
@ -5623,8 +5624,7 @@ static int smbchg_battery_set_property(struct power_supply *psy,
|
|||
const union power_supply_propval *val)
|
||||
{
|
||||
int rc = 0;
|
||||
struct smbchg_chip *chip = container_of(psy,
|
||||
struct smbchg_chip, batt_psy);
|
||||
struct smbchg_chip *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_BATTERY_CHARGING_ENABLED:
|
||||
|
@ -5641,7 +5641,7 @@ static int smbchg_battery_set_property(struct power_supply *psy,
|
|||
break;
|
||||
case POWER_SUPPLY_PROP_CAPACITY:
|
||||
chip->fake_battery_soc = val->intval;
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
|
||||
smbchg_system_temp_level_set(chip, val->intval);
|
||||
|
@ -5729,8 +5729,7 @@ static int smbchg_battery_get_property(struct power_supply *psy,
|
|||
enum power_supply_property prop,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
struct smbchg_chip *chip = container_of(psy,
|
||||
struct smbchg_chip, batt_psy);
|
||||
struct smbchg_chip *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_STATUS:
|
||||
|
@ -5835,8 +5834,7 @@ static int smbchg_dc_set_property(struct power_supply *psy,
|
|||
const union power_supply_propval *val)
|
||||
{
|
||||
int rc = 0;
|
||||
struct smbchg_chip *chip = container_of(psy,
|
||||
struct smbchg_chip, dc_psy);
|
||||
struct smbchg_chip *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
|
||||
|
@ -5858,8 +5856,7 @@ static int smbchg_dc_get_property(struct power_supply *psy,
|
|||
enum power_supply_property prop,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
struct smbchg_chip *chip = container_of(psy,
|
||||
struct smbchg_chip, dc_psy);
|
||||
struct smbchg_chip *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_PRESENT:
|
||||
|
@ -5919,7 +5916,7 @@ static irqreturn_t batt_hot_handler(int irq, void *_chip)
|
|||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
set_property_on_fg(chip, POWER_SUPPLY_PROP_HEALTH,
|
||||
|
@ -5937,7 +5934,7 @@ static irqreturn_t batt_cold_handler(int irq, void *_chip)
|
|||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
set_property_on_fg(chip, POWER_SUPPLY_PROP_HEALTH,
|
||||
|
@ -5955,7 +5952,7 @@ static irqreturn_t batt_warm_handler(int irq, void *_chip)
|
|||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
set_property_on_fg(chip, POWER_SUPPLY_PROP_HEALTH,
|
||||
get_prop_batt_health(chip));
|
||||
return IRQ_HANDLED;
|
||||
|
@ -5971,7 +5968,7 @@ static irqreturn_t batt_cool_handler(int irq, void *_chip)
|
|||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
set_property_on_fg(chip, POWER_SUPPLY_PROP_HEALTH,
|
||||
get_prop_batt_health(chip));
|
||||
return IRQ_HANDLED;
|
||||
|
@ -5986,7 +5983,7 @@ static irqreturn_t batt_pres_handler(int irq, void *_chip)
|
|||
chip->batt_present = !(reg & BAT_MISSING_BIT);
|
||||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
set_property_on_fg(chip, POWER_SUPPLY_PROP_HEALTH,
|
||||
get_prop_batt_health(chip));
|
||||
|
@ -6021,7 +6018,7 @@ static irqreturn_t chg_error_handler(int irq, void *_chip)
|
|||
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
return IRQ_HANDLED;
|
||||
|
@ -6034,7 +6031,7 @@ static irqreturn_t fastchg_handler(int irq, void *_chip)
|
|||
pr_smb(PR_INTERRUPT, "p2f triggered\n");
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
return IRQ_HANDLED;
|
||||
|
@ -6063,7 +6060,7 @@ static irqreturn_t chg_term_handler(int irq, void *_chip)
|
|||
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
|
@ -6079,7 +6076,7 @@ static irqreturn_t taper_handler(int irq, void *_chip)
|
|||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_taper(chip);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_wipower_check(chip);
|
||||
return IRQ_HANDLED;
|
||||
|
@ -6094,7 +6091,7 @@ static irqreturn_t recharge_handler(int irq, void *_chip)
|
|||
pr_smb(PR_INTERRUPT, "triggered: 0x%02x\n", reg);
|
||||
smbchg_parallel_usb_check_ok(chip);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
@ -6107,7 +6104,7 @@ static irqreturn_t wdog_timeout_handler(int irq, void *_chip)
|
|||
smbchg_read(chip, ®, chip->misc_base + RT_STS, 1);
|
||||
pr_warn_ratelimited("wdog timeout rt_stat = 0x%02x\n", reg);
|
||||
if (chip->psy_registered)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
@ -6145,7 +6142,7 @@ static irqreturn_t dcin_uv_handler(int irq, void *_chip)
|
|||
/* dc changed */
|
||||
chip->dc_present = dc_present;
|
||||
if (chip->dc_psy_type != -EINVAL && chip->psy_registered)
|
||||
power_supply_changed(&chip->dc_psy);
|
||||
power_supply_changed(chip->dc_psy);
|
||||
smbchg_charging_status_change(chip);
|
||||
smbchg_aicl_deglitch_wa_check(chip);
|
||||
chip->vbat_above_headroom = false;
|
||||
|
@ -6422,7 +6419,7 @@ static irqreturn_t aicl_done_handler(int irq, void *_chip)
|
|||
smbchg_parallel_usb_check_ok(chip);
|
||||
|
||||
if (chip->aicl_complete)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
@ -7866,6 +7863,8 @@ static int smbchg_probe(struct platform_device *pdev)
|
|||
struct qpnp_vadc_chip *vadc_dev, *vchg_vadc_dev;
|
||||
const char *typec_psy_name;
|
||||
union power_supply_propval pval = {0, };
|
||||
struct power_supply_config batt_psy_cfg;
|
||||
struct power_supply_config dc_psy_cfg;
|
||||
|
||||
usb_psy = power_supply_get_by_name("usb");
|
||||
if (!usb_psy) {
|
||||
|
@ -8058,37 +8057,49 @@ static int smbchg_probe(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
chip->previous_soc = -EINVAL;
|
||||
chip->batt_psy.name = chip->battery_psy_name;
|
||||
chip->batt_psy.type = POWER_SUPPLY_TYPE_BATTERY;
|
||||
chip->batt_psy.get_property = smbchg_battery_get_property;
|
||||
chip->batt_psy.set_property = smbchg_battery_set_property;
|
||||
chip->batt_psy.properties = smbchg_battery_properties;
|
||||
chip->batt_psy.num_properties = ARRAY_SIZE(smbchg_battery_properties);
|
||||
chip->batt_psy.external_power_changed = smbchg_external_power_changed;
|
||||
chip->batt_psy.property_is_writeable = smbchg_battery_is_writeable;
|
||||
chip->batt_psy_d.name = chip->battery_psy_name;
|
||||
chip->batt_psy_d.type = POWER_SUPPLY_TYPE_BATTERY;
|
||||
chip->batt_psy_d.get_property = smbchg_battery_get_property;
|
||||
chip->batt_psy_d.set_property = smbchg_battery_set_property;
|
||||
chip->batt_psy_d.properties = smbchg_battery_properties;
|
||||
chip->batt_psy_d.num_properties = ARRAY_SIZE(smbchg_battery_properties);
|
||||
chip->batt_psy_d.external_power_changed = smbchg_external_power_changed;
|
||||
chip->batt_psy_d.property_is_writeable = smbchg_battery_is_writeable;
|
||||
|
||||
rc = power_supply_register(chip->dev, &chip->batt_psy);
|
||||
if (rc < 0) {
|
||||
batt_psy_cfg.drv_data = chip;
|
||||
batt_psy_cfg.num_supplicants = 0;
|
||||
chip->batt_psy = devm_power_supply_register(chip->dev,
|
||||
&chip->batt_psy_d,
|
||||
&batt_psy_cfg);
|
||||
if (IS_ERR(chip->batt_psy)) {
|
||||
dev_err(&pdev->dev,
|
||||
"Unable to register batt_psy rc = %d\n", rc);
|
||||
"Unable to register batt_psy rc = %ld\n",
|
||||
PTR_ERR(chip->batt_psy));
|
||||
goto out;
|
||||
}
|
||||
if (chip->dc_psy_type != -EINVAL) {
|
||||
chip->dc_psy.name = "dc";
|
||||
chip->dc_psy.type = chip->dc_psy_type;
|
||||
chip->dc_psy.get_property = smbchg_dc_get_property;
|
||||
chip->dc_psy.set_property = smbchg_dc_set_property;
|
||||
chip->dc_psy.property_is_writeable = smbchg_dc_is_writeable;
|
||||
chip->dc_psy.properties = smbchg_dc_properties;
|
||||
chip->dc_psy.num_properties = ARRAY_SIZE(smbchg_dc_properties);
|
||||
chip->dc_psy.supplied_to = smbchg_dc_supplicants;
|
||||
chip->dc_psy.num_supplicants
|
||||
chip->dc_psy_d.name = "dc";
|
||||
chip->dc_psy_d.type = chip->dc_psy_type;
|
||||
chip->dc_psy_d.get_property = smbchg_dc_get_property;
|
||||
chip->dc_psy_d.set_property = smbchg_dc_set_property;
|
||||
chip->dc_psy_d.property_is_writeable = smbchg_dc_is_writeable;
|
||||
chip->dc_psy_d.properties = smbchg_dc_properties;
|
||||
chip->dc_psy_d.num_properties
|
||||
= ARRAY_SIZE(smbchg_dc_properties);
|
||||
|
||||
dc_psy_cfg.drv_data = chip;
|
||||
dc_psy_cfg.num_supplicants
|
||||
= ARRAY_SIZE(smbchg_dc_supplicants);
|
||||
rc = power_supply_register(chip->dev, &chip->dc_psy);
|
||||
if (rc < 0) {
|
||||
dc_psy_cfg.supplied_to = smbchg_dc_supplicants;
|
||||
|
||||
chip->dc_psy = devm_power_supply_register(chip->dev,
|
||||
&chip->dc_psy_d,
|
||||
&dc_psy_cfg);
|
||||
if (IS_ERR(chip->dc_psy)) {
|
||||
dev_err(&pdev->dev,
|
||||
"Unable to register dc_psy rc = %d\n", rc);
|
||||
goto unregister_batt_psy;
|
||||
"Unable to register dc_psy rc = %ld\n",
|
||||
PTR_ERR(chip->dc_psy));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
chip->psy_registered = true;
|
||||
|
@ -8100,7 +8111,7 @@ static int smbchg_probe(struct platform_device *pdev)
|
|||
dev_err(chip->dev,
|
||||
"Unable to register charger led: %d\n",
|
||||
rc);
|
||||
goto unregister_dc_psy;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rc = smbchg_chg_led_controls(chip);
|
||||
|
@ -8142,10 +8153,6 @@ static int smbchg_probe(struct platform_device *pdev)
|
|||
unregister_led_class:
|
||||
if (chip->cfg_chg_led_support && chip->schg_version == QPNP_SCHG_LITE)
|
||||
led_classdev_unregister(&chip->led_cdev);
|
||||
unregister_dc_psy:
|
||||
power_supply_unregister(&chip->dc_psy);
|
||||
unregister_batt_psy:
|
||||
power_supply_unregister(&chip->batt_psy);
|
||||
out:
|
||||
handle_usb_removal(chip);
|
||||
return rc;
|
||||
|
@ -8157,11 +8164,6 @@ static int smbchg_remove(struct platform_device *pdev)
|
|||
|
||||
debugfs_remove_recursive(chip->debug_root);
|
||||
|
||||
if (chip->dc_psy_type != -EINVAL)
|
||||
power_supply_unregister(&chip->dc_psy);
|
||||
|
||||
power_supply_unregister(&chip->batt_psy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -473,8 +473,10 @@ struct smb1351_charger {
|
|||
struct power_supply *usb_psy;
|
||||
int usb_psy_ma;
|
||||
struct power_supply *bms_psy;
|
||||
struct power_supply batt_psy;
|
||||
struct power_supply parallel_psy;
|
||||
struct power_supply_desc batt_psy_d;
|
||||
struct power_supply *batt_psy;
|
||||
struct power_supply *parallel_psy;
|
||||
struct power_supply_desc parallel_psy_d;
|
||||
|
||||
struct smb1351_regulator otg_vreg;
|
||||
struct mutex irq_complete;
|
||||
|
@ -1317,8 +1319,7 @@ static int smb1351_battery_set_property(struct power_supply *psy,
|
|||
const union power_supply_propval *val)
|
||||
{
|
||||
int rc;
|
||||
struct smb1351_charger *chip = container_of(psy,
|
||||
struct smb1351_charger, batt_psy);
|
||||
struct smb1351_charger *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_STATUS:
|
||||
|
@ -1338,7 +1339,7 @@ static int smb1351_battery_set_property(struct power_supply *psy,
|
|||
break;
|
||||
case POWER_SUPPLY_STATUS_DISCHARGING:
|
||||
chip->batt_full = false;
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
pr_debug("status = DISCHARGING, batt_full = %d\n",
|
||||
chip->batt_full);
|
||||
break;
|
||||
|
@ -1365,7 +1366,7 @@ static int smb1351_battery_set_property(struct power_supply *psy,
|
|||
break;
|
||||
case POWER_SUPPLY_PROP_CAPACITY:
|
||||
chip->fake_battery_soc = val->intval;
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
@ -1378,8 +1379,7 @@ static int smb1351_battery_get_property(struct power_supply *psy,
|
|||
enum power_supply_property prop,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
struct smb1351_charger *chip = container_of(psy,
|
||||
struct smb1351_charger, batt_psy);
|
||||
struct smb1351_charger *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_STATUS:
|
||||
|
@ -1580,8 +1580,7 @@ static int smb1351_parallel_set_property(struct power_supply *psy,
|
|||
const union power_supply_propval *val)
|
||||
{
|
||||
int rc = 0, index;
|
||||
struct smb1351_charger *chip = container_of(psy,
|
||||
struct smb1351_charger, parallel_psy);
|
||||
struct smb1351_charger *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
|
||||
|
@ -1643,8 +1642,7 @@ static int smb1351_parallel_get_property(struct power_supply *psy,
|
|||
enum power_supply_property prop,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
struct smb1351_charger *chip = container_of(psy,
|
||||
struct smb1351_charger, parallel_psy);
|
||||
struct smb1351_charger *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
|
||||
|
@ -1778,7 +1776,7 @@ static void smb1351_chg_ctrl_in_jeita(struct smb1351_charger *chip)
|
|||
chip->batt_full);
|
||||
}
|
||||
pr_debug("batt psy changed\n");
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2478,7 +2476,7 @@ static irqreturn_t smb1351_chg_stat_handler(int irq, void *dev_id)
|
|||
pr_debug("handler count = %d\n", handler_count);
|
||||
if (handler_count) {
|
||||
pr_debug("batt psy changed\n");
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
}
|
||||
|
||||
mutex_unlock(&chip->irq_complete);
|
||||
|
@ -2488,8 +2486,7 @@ static irqreturn_t smb1351_chg_stat_handler(int irq, void *dev_id)
|
|||
|
||||
static void smb1351_external_power_changed(struct power_supply *psy)
|
||||
{
|
||||
struct smb1351_charger *chip = container_of(psy,
|
||||
struct smb1351_charger, batt_psy);
|
||||
struct smb1351_charger *chip = power_supply_get_drvdata(psy);
|
||||
union power_supply_propval prop = {0,};
|
||||
int rc, current_limit = 0, online = 0;
|
||||
|
||||
|
@ -2970,6 +2967,7 @@ static int smb1351_main_charger_probe(struct i2c_client *client,
|
|||
int rc;
|
||||
struct smb1351_charger *chip;
|
||||
struct power_supply *usb_psy;
|
||||
struct power_supply_config batt_psy_cfg;
|
||||
u8 reg = 0;
|
||||
|
||||
usb_psy = power_supply_get_by_name("usb");
|
||||
|
@ -3026,26 +3024,30 @@ static int smb1351_main_charger_probe(struct i2c_client *client,
|
|||
|
||||
i2c_set_clientdata(client, chip);
|
||||
|
||||
chip->batt_psy.name = "battery";
|
||||
chip->batt_psy.type = POWER_SUPPLY_TYPE_BATTERY;
|
||||
chip->batt_psy.get_property = smb1351_battery_get_property;
|
||||
chip->batt_psy.set_property = smb1351_battery_set_property;
|
||||
chip->batt_psy.property_is_writeable =
|
||||
chip->batt_psy_d.name = "battery";
|
||||
chip->batt_psy_d.type = POWER_SUPPLY_TYPE_BATTERY;
|
||||
chip->batt_psy_d.get_property = smb1351_battery_get_property;
|
||||
chip->batt_psy_d.set_property = smb1351_battery_set_property;
|
||||
chip->batt_psy_d.property_is_writeable =
|
||||
smb1351_batt_property_is_writeable;
|
||||
chip->batt_psy.properties = smb1351_battery_properties;
|
||||
chip->batt_psy.num_properties =
|
||||
chip->batt_psy_d.properties = smb1351_battery_properties;
|
||||
chip->batt_psy_d.num_properties =
|
||||
ARRAY_SIZE(smb1351_battery_properties);
|
||||
chip->batt_psy.external_power_changed =
|
||||
chip->batt_psy_d.external_power_changed =
|
||||
smb1351_external_power_changed;
|
||||
chip->batt_psy.supplied_to = pm_batt_supplied_to;
|
||||
chip->batt_psy.num_supplicants = ARRAY_SIZE(pm_batt_supplied_to);
|
||||
|
||||
chip->resume_completed = true;
|
||||
mutex_init(&chip->irq_complete);
|
||||
|
||||
rc = power_supply_register(chip->dev, &chip->batt_psy);
|
||||
if (rc) {
|
||||
pr_err("Couldn't register batt psy rc=%d\n", rc);
|
||||
batt_psy_cfg.drv_data = chip;
|
||||
batt_psy_cfg.supplied_to = pm_batt_supplied_to;
|
||||
batt_psy_cfg.num_supplicants = ARRAY_SIZE(pm_batt_supplied_to);
|
||||
chip->batt_psy = devm_power_supply_register(chip->dev,
|
||||
&chip->batt_psy_d,
|
||||
&batt_psy_cfg);
|
||||
if (IS_ERR(chip->batt_psy)) {
|
||||
pr_err("Couldn't register batt psy rc=%ld\n",
|
||||
PTR_ERR(chip->batt_psy));
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -3120,7 +3122,6 @@ static int smb1351_main_charger_probe(struct i2c_client *client,
|
|||
fail_smb1351_hw_init:
|
||||
regulator_unregister(chip->otg_vreg.rdev);
|
||||
fail_smb1351_regulator_init:
|
||||
power_supply_unregister(&chip->batt_psy);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -3130,6 +3131,7 @@ static int smb1351_parallel_charger_probe(struct i2c_client *client,
|
|||
int rc;
|
||||
struct smb1351_charger *chip;
|
||||
struct device_node *node = client->dev.of_node;
|
||||
struct power_supply_config parallel_psy_cfg;
|
||||
|
||||
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
|
||||
if (!chip) {
|
||||
|
@ -3163,19 +3165,24 @@ static int smb1351_parallel_charger_probe(struct i2c_client *client,
|
|||
|
||||
i2c_set_clientdata(client, chip);
|
||||
|
||||
chip->parallel_psy.name = "usb-parallel";
|
||||
chip->parallel_psy.type = POWER_SUPPLY_TYPE_USB_PARALLEL;
|
||||
chip->parallel_psy.get_property = smb1351_parallel_get_property;
|
||||
chip->parallel_psy.set_property = smb1351_parallel_set_property;
|
||||
chip->parallel_psy.properties = smb1351_parallel_properties;
|
||||
chip->parallel_psy.property_is_writeable
|
||||
chip->parallel_psy_d.name = "usb-parallel";
|
||||
chip->parallel_psy_d.type = POWER_SUPPLY_TYPE_USB_PARALLEL;
|
||||
chip->parallel_psy_d.get_property = smb1351_parallel_get_property;
|
||||
chip->parallel_psy_d.set_property = smb1351_parallel_set_property;
|
||||
chip->parallel_psy_d.properties = smb1351_parallel_properties;
|
||||
chip->parallel_psy_d.property_is_writeable
|
||||
= smb1351_parallel_is_writeable;
|
||||
chip->parallel_psy.num_properties
|
||||
chip->parallel_psy_d.num_properties
|
||||
= ARRAY_SIZE(smb1351_parallel_properties);
|
||||
|
||||
rc = power_supply_register(chip->dev, &chip->parallel_psy);
|
||||
if (rc) {
|
||||
pr_err("Couldn't register parallel psy rc=%d\n", rc);
|
||||
parallel_psy_cfg.drv_data = chip;
|
||||
parallel_psy_cfg.num_supplicants = 0;
|
||||
chip->parallel_psy = devm_power_supply_register(chip->dev,
|
||||
&chip->parallel_psy_d,
|
||||
¶llel_psy_cfg);
|
||||
if (IS_ERR(chip->parallel_psy)) {
|
||||
pr_err("Couldn't register parallel psy rc=%ld\n",
|
||||
PTR_ERR(chip->parallel_psy));
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -3203,7 +3210,6 @@ static int smb1351_charger_remove(struct i2c_client *client)
|
|||
struct smb1351_charger *chip = i2c_get_clientdata(client);
|
||||
|
||||
cancel_delayed_work_sync(&chip->chg_remove_work);
|
||||
power_supply_unregister(&chip->batt_psy);
|
||||
|
||||
mutex_destroy(&chip->irq_complete);
|
||||
debugfs_remove_recursive(chip->debug_root);
|
||||
|
|
|
@ -372,9 +372,12 @@ struct smb135x_chg {
|
|||
struct power_supply *usb_psy;
|
||||
int usb_psy_ma;
|
||||
int real_usb_psy_ma;
|
||||
struct power_supply batt_psy;
|
||||
struct power_supply dc_psy;
|
||||
struct power_supply parallel_psy;
|
||||
struct power_supply_desc batt_psy_d;
|
||||
struct power_supply *batt_psy;
|
||||
struct power_supply_desc dc_psy_d;
|
||||
struct power_supply *dc_psy;
|
||||
struct power_supply_desc parallel_psy_d;
|
||||
struct power_supply *parallel_psy;
|
||||
struct power_supply *bms_psy;
|
||||
int dc_psy_type;
|
||||
int dc_psy_ma;
|
||||
|
@ -1402,7 +1405,7 @@ static int smb135x_charging(struct smb135x_chg *chip, int enable)
|
|||
}
|
||||
if (chip->dc_psy_type != -EINVAL) {
|
||||
pr_debug("dc psy changed\n");
|
||||
power_supply_changed(&chip->dc_psy);
|
||||
power_supply_changed(chip->dc_psy);
|
||||
}
|
||||
pr_debug("charging %s\n",
|
||||
enable ? "enabled" : "disabled running from batt");
|
||||
|
@ -1489,8 +1492,7 @@ static int smb135x_battery_set_property(struct power_supply *psy,
|
|||
const union power_supply_propval *val)
|
||||
{
|
||||
int rc = 0, update_psy = 0;
|
||||
struct smb135x_chg *chip = container_of(psy,
|
||||
struct smb135x_chg, batt_psy);
|
||||
struct smb135x_chg *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_STATUS:
|
||||
|
@ -1548,7 +1550,7 @@ static int smb135x_battery_set_property(struct power_supply *psy,
|
|||
}
|
||||
|
||||
if (!rc && update_psy)
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1574,8 +1576,7 @@ static int smb135x_battery_get_property(struct power_supply *psy,
|
|||
enum power_supply_property prop,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
struct smb135x_chg *chip = container_of(psy,
|
||||
struct smb135x_chg, batt_psy);
|
||||
struct smb135x_chg *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_STATUS:
|
||||
|
@ -1618,8 +1619,7 @@ static int smb135x_dc_get_property(struct power_supply *psy,
|
|||
enum power_supply_property prop,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
struct smb135x_chg *chip = container_of(psy,
|
||||
struct smb135x_chg, dc_psy);
|
||||
struct smb135x_chg *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_PRESENT:
|
||||
|
@ -1874,8 +1874,7 @@ static int smb135x_parallel_set_property(struct power_supply *psy,
|
|||
const union power_supply_propval *val)
|
||||
{
|
||||
int rc = 0;
|
||||
struct smb135x_chg *chip = container_of(psy,
|
||||
struct smb135x_chg, parallel_psy);
|
||||
struct smb135x_chg *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
|
||||
|
@ -1935,8 +1934,7 @@ static int smb135x_parallel_get_property(struct power_supply *psy,
|
|||
enum power_supply_property prop,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
struct smb135x_chg *chip = container_of(psy,
|
||||
struct smb135x_chg, parallel_psy);
|
||||
struct smb135x_chg *chip = power_supply_get_drvdata(psy);
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_CHARGING_ENABLED:
|
||||
|
@ -1974,8 +1972,7 @@ static int smb135x_parallel_get_property(struct power_supply *psy,
|
|||
|
||||
static void smb135x_external_power_changed(struct power_supply *psy)
|
||||
{
|
||||
struct smb135x_chg *chip = container_of(psy,
|
||||
struct smb135x_chg, batt_psy);
|
||||
struct smb135x_chg *chip = power_supply_get_drvdata(psy);
|
||||
union power_supply_propval prop = {0,};
|
||||
int rc, current_limit = 0;
|
||||
|
||||
|
@ -2576,7 +2573,7 @@ static int handle_dc_removal(struct smb135x_chg *chip)
|
|||
}
|
||||
if (chip->dc_psy_type != -EINVAL) {
|
||||
prop.intval = chip->dc_present;
|
||||
power_supply_set_property(&chip->dc_psy,
|
||||
power_supply_set_property(chip->dc_psy,
|
||||
POWER_SUPPLY_PROP_ONLINE, &prop);
|
||||
}
|
||||
return 0;
|
||||
|
@ -2592,7 +2589,7 @@ static int handle_dc_insertion(struct smb135x_chg *chip)
|
|||
msecs_to_jiffies(DCIN_UNSUSPEND_DELAY_MS));
|
||||
if (chip->dc_psy_type != -EINVAL) {
|
||||
prop.intval = chip->dc_present;
|
||||
power_supply_set_property(&chip->dc_psy,
|
||||
power_supply_set_property(chip->dc_psy,
|
||||
POWER_SUPPLY_PROP_ONLINE, &prop);
|
||||
}
|
||||
return 0;
|
||||
|
@ -3145,14 +3142,14 @@ static irqreturn_t smb135x_chg_stat_handler(int irq, void *dev_id)
|
|||
pr_debug("handler count = %d\n", handler_count);
|
||||
if (handler_count) {
|
||||
pr_debug("batt psy changed\n");
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
power_supply_changed(chip->batt_psy);
|
||||
if (chip->usb_psy) {
|
||||
pr_debug("usb psy changed\n");
|
||||
power_supply_changed(chip->usb_psy);
|
||||
}
|
||||
if (chip->dc_psy_type != -EINVAL) {
|
||||
pr_debug("dc psy changed\n");
|
||||
power_supply_changed(&chip->dc_psy);
|
||||
power_supply_changed(chip->dc_psy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4154,6 +4151,8 @@ static int smb135x_main_charger_probe(struct i2c_client *client,
|
|||
int rc;
|
||||
struct smb135x_chg *chip;
|
||||
struct power_supply *usb_psy;
|
||||
struct power_supply_config batt_psy_cfg;
|
||||
struct power_supply_config dc_psy_cfg;
|
||||
u8 reg = 0;
|
||||
|
||||
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
|
||||
|
@ -4230,39 +4229,51 @@ static int smb135x_main_charger_probe(struct i2c_client *client,
|
|||
goto free_regulator;
|
||||
}
|
||||
|
||||
chip->batt_psy.name = "battery";
|
||||
chip->batt_psy.type = POWER_SUPPLY_TYPE_BATTERY;
|
||||
chip->batt_psy.get_property = smb135x_battery_get_property;
|
||||
chip->batt_psy.set_property = smb135x_battery_set_property;
|
||||
chip->batt_psy.properties = smb135x_battery_properties;
|
||||
chip->batt_psy.num_properties = ARRAY_SIZE(smb135x_battery_properties);
|
||||
chip->batt_psy.external_power_changed = smb135x_external_power_changed;
|
||||
chip->batt_psy.property_is_writeable = smb135x_battery_is_writeable;
|
||||
chip->batt_psy_d.name = "battery";
|
||||
chip->batt_psy_d.type = POWER_SUPPLY_TYPE_BATTERY;
|
||||
chip->batt_psy_d.get_property = smb135x_battery_get_property;
|
||||
chip->batt_psy_d.set_property = smb135x_battery_set_property;
|
||||
chip->batt_psy_d.properties = smb135x_battery_properties;
|
||||
chip->batt_psy_d.num_properties
|
||||
= ARRAY_SIZE(smb135x_battery_properties);
|
||||
chip->batt_psy_d.external_power_changed
|
||||
= smb135x_external_power_changed;
|
||||
chip->batt_psy_d.property_is_writeable = smb135x_battery_is_writeable;
|
||||
|
||||
batt_psy_cfg.drv_data = chip;
|
||||
batt_psy_cfg.num_supplicants = 0;
|
||||
if (chip->bms_controlled_charging) {
|
||||
chip->batt_psy.supplied_to = pm_batt_supplied_to;
|
||||
chip->batt_psy.num_supplicants =
|
||||
ARRAY_SIZE(pm_batt_supplied_to);
|
||||
batt_psy_cfg.supplied_to = pm_batt_supplied_to;
|
||||
batt_psy_cfg.num_supplicants
|
||||
= ARRAY_SIZE(pm_batt_supplied_to);
|
||||
}
|
||||
|
||||
rc = power_supply_register(chip->dev, &chip->batt_psy);
|
||||
if (rc < 0) {
|
||||
dev_err(&client->dev,
|
||||
"Unable to register batt_psy rc = %d\n", rc);
|
||||
chip->batt_psy = devm_power_supply_register(chip->dev,
|
||||
&chip->batt_psy_d, &batt_psy_cfg);
|
||||
if (IS_ERR(chip->batt_psy)) {
|
||||
dev_err(&client->dev, "Unable to register batt_psy rc = %ld\n",
|
||||
PTR_ERR(chip->batt_psy));
|
||||
goto free_regulator;
|
||||
}
|
||||
|
||||
if (chip->dc_psy_type != -EINVAL) {
|
||||
chip->dc_psy.name = "dc";
|
||||
chip->dc_psy.type = chip->dc_psy_type;
|
||||
chip->dc_psy.get_property = smb135x_dc_get_property;
|
||||
chip->dc_psy.properties = smb135x_dc_properties;
|
||||
chip->dc_psy.num_properties = ARRAY_SIZE(smb135x_dc_properties);
|
||||
rc = power_supply_register(chip->dev, &chip->dc_psy);
|
||||
if (rc < 0) {
|
||||
chip->dc_psy_d.name = "dc";
|
||||
chip->dc_psy_d.type = chip->dc_psy_type;
|
||||
chip->dc_psy_d.get_property = smb135x_dc_get_property;
|
||||
chip->dc_psy_d.properties = smb135x_dc_properties;
|
||||
chip->dc_psy_d.num_properties
|
||||
= ARRAY_SIZE(smb135x_dc_properties);
|
||||
|
||||
dc_psy_cfg.drv_data = chip;
|
||||
dc_psy_cfg.num_supplicants = 0;
|
||||
chip->dc_psy = devm_power_supply_register(chip->dev,
|
||||
&chip->dc_psy_d,
|
||||
&dc_psy_cfg);
|
||||
|
||||
if (IS_ERR(chip->dc_psy)) {
|
||||
dev_err(&client->dev,
|
||||
"Unable to register dc_psy rc = %d\n", rc);
|
||||
goto unregister_batt_psy;
|
||||
"Unable to register dc_psy rc = %ld\n",
|
||||
PTR_ERR(chip->dc_psy));
|
||||
goto free_regulator;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4279,7 +4290,7 @@ static int smb135x_main_charger_probe(struct i2c_client *client,
|
|||
dev_err(&client->dev,
|
||||
"request_irq for irq=%d failed rc = %d\n",
|
||||
client->irq, rc);
|
||||
goto unregister_dc_psy;
|
||||
goto free_regulator;
|
||||
}
|
||||
enable_irq_wake(client->irq);
|
||||
}
|
||||
|
@ -4292,11 +4303,6 @@ static int smb135x_main_charger_probe(struct i2c_client *client,
|
|||
chip->dc_present, chip->usb_present);
|
||||
return 0;
|
||||
|
||||
unregister_dc_psy:
|
||||
if (chip->dc_psy_type != -EINVAL)
|
||||
power_supply_unregister(&chip->dc_psy);
|
||||
unregister_batt_psy:
|
||||
power_supply_unregister(&chip->batt_psy);
|
||||
free_regulator:
|
||||
smb135x_regulator_deinit(chip);
|
||||
return rc;
|
||||
|
@ -4309,6 +4315,7 @@ static int smb135x_parallel_charger_probe(struct i2c_client *client,
|
|||
struct smb135x_chg *chip;
|
||||
const struct of_device_id *match;
|
||||
struct device_node *node = client->dev.of_node;
|
||||
struct power_supply_config parallel_psy_cfg;
|
||||
|
||||
chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
|
||||
if (!chip) {
|
||||
|
@ -4349,20 +4356,25 @@ static int smb135x_parallel_charger_probe(struct i2c_client *client,
|
|||
|
||||
i2c_set_clientdata(client, chip);
|
||||
|
||||
chip->parallel_psy.name = "usb-parallel";
|
||||
chip->parallel_psy.type = POWER_SUPPLY_TYPE_USB_PARALLEL;
|
||||
chip->parallel_psy.get_property = smb135x_parallel_get_property;
|
||||
chip->parallel_psy.set_property = smb135x_parallel_set_property;
|
||||
chip->parallel_psy.properties = smb135x_parallel_properties;
|
||||
chip->parallel_psy.property_is_writeable
|
||||
chip->parallel_psy_d.name = "usb-parallel";
|
||||
chip->parallel_psy_d.type = POWER_SUPPLY_TYPE_USB_PARALLEL;
|
||||
chip->parallel_psy_d.get_property = smb135x_parallel_get_property;
|
||||
chip->parallel_psy_d.set_property = smb135x_parallel_set_property;
|
||||
chip->parallel_psy_d.properties = smb135x_parallel_properties;
|
||||
chip->parallel_psy_d.property_is_writeable
|
||||
= smb135x_parallel_is_writeable;
|
||||
chip->parallel_psy.num_properties
|
||||
chip->parallel_psy_d.num_properties
|
||||
= ARRAY_SIZE(smb135x_parallel_properties);
|
||||
|
||||
rc = power_supply_register(chip->dev, &chip->parallel_psy);
|
||||
if (rc < 0) {
|
||||
parallel_psy_cfg.drv_data = chip;
|
||||
parallel_psy_cfg.num_supplicants = 0;
|
||||
chip->parallel_psy = devm_power_supply_register(chip->dev,
|
||||
&chip->parallel_psy_d,
|
||||
¶llel_psy_cfg);
|
||||
if (IS_ERR(chip->parallel_psy)) {
|
||||
dev_err(&client->dev,
|
||||
"Unable to register parallel_psy rc = %d\n", rc);
|
||||
"Unable to register parallel_psy rc = %d\n",
|
||||
PTR_ERR(chip->parallel_psy));
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -4376,7 +4388,7 @@ static int smb135x_parallel_charger_probe(struct i2c_client *client,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int smb135x_charger_probe(struct i2c_client *client,
|
||||
static int smb135x_chg_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
if (is_parallel_charger(client))
|
||||
|
@ -4385,17 +4397,15 @@ static int smb135x_charger_probe(struct i2c_client *client,
|
|||
return smb135x_main_charger_probe(client, id);
|
||||
}
|
||||
|
||||
static int smb135x_charger_remove(struct i2c_client *client)
|
||||
static int smb135x_chg_remove(struct i2c_client *client)
|
||||
{
|
||||
int rc;
|
||||
struct smb135x_chg *chip = i2c_get_clientdata(client);
|
||||
|
||||
debugfs_remove_recursive(chip->debug_root);
|
||||
|
||||
if (chip->parallel_charger) {
|
||||
power_supply_unregister(&chip->parallel_psy);
|
||||
if (chip->parallel_charger)
|
||||
goto mutex_destroy;
|
||||
}
|
||||
|
||||
if (chip->therm_bias_vreg) {
|
||||
rc = regulator_disable(chip->therm_bias_vreg);
|
||||
|
@ -4409,11 +4419,6 @@ static int smb135x_charger_remove(struct i2c_client *client)
|
|||
pr_err("Couldn't disable data-pullup rc = %d\n", rc);
|
||||
}
|
||||
|
||||
if (chip->dc_psy_type != -EINVAL)
|
||||
power_supply_unregister(&chip->dc_psy);
|
||||
|
||||
power_supply_unregister(&chip->batt_psy);
|
||||
|
||||
smb135x_regulator_deinit(chip);
|
||||
|
||||
mutex_destroy:
|
||||
|
@ -4514,11 +4519,11 @@ static const struct dev_pm_ops smb135x_pm_ops = {
|
|||
.suspend = smb135x_suspend,
|
||||
};
|
||||
|
||||
static const struct i2c_device_id smb135x_charger_id[] = {
|
||||
static const struct i2c_device_id smb135x_chg_id[] = {
|
||||
{"smb135x-charger", 0},
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, smb135x_charger_id);
|
||||
MODULE_DEVICE_TABLE(i2c, smb135x_chg_id);
|
||||
|
||||
static void smb135x_shutdown(struct i2c_client *client)
|
||||
{
|
||||
|
@ -4537,20 +4542,20 @@ static void smb135x_shutdown(struct i2c_client *client)
|
|||
}
|
||||
}
|
||||
|
||||
static struct i2c_driver smb135x_charger_driver = {
|
||||
static struct i2c_driver smb135x_chg_driver = {
|
||||
.driver = {
|
||||
.name = "smb135x-charger",
|
||||
.owner = THIS_MODULE,
|
||||
.of_match_table = smb135x_match_table,
|
||||
.pm = &smb135x_pm_ops,
|
||||
},
|
||||
.probe = smb135x_charger_probe,
|
||||
.remove = smb135x_charger_remove,
|
||||
.id_table = smb135x_charger_id,
|
||||
.probe = smb135x_chg_probe,
|
||||
.remove = smb135x_chg_remove,
|
||||
.id_table = smb135x_chg_id,
|
||||
.shutdown = smb135x_shutdown,
|
||||
};
|
||||
|
||||
module_i2c_driver(smb135x_charger_driver);
|
||||
module_i2c_driver(smb135x_chg_driver);
|
||||
|
||||
MODULE_DESCRIPTION("SMB135x Charger");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
|
Loading…
Add table
Reference in a new issue