Skip to content

Commit

Permalink
Merge tag 'for-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git…
Browse files Browse the repository at this point in the history
…/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:
 "Core:
   - Ensure HWMON devices are registered with valid names
   - Fix device wakeup code

  Drivers:
   - bq25890_charger: Add BQ25895 support
   - axp288_fuel_gauge: Add Minix Neo Z83-4 to blacklist
   - sc27xx: improve battery calibration
   - misc small fixes all over drivers"

* tag 'for-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (24 commits)
  power: supply: cpcap-charger: Enable vbus boost voltage
  power: supply: sc27xx: Add POWER_SUPPLY_PROP_CALIBRATE attribute
  power: supply: sc27xx: Optimize the battery capacity calibration
  power: supply: sc27xx: Make sure the alarm capacity is larger than 0
  power: supply: sc27xx: Fix the the accuracy issue of coulomb calculation
  power: supply: sc27xx: Fix conditon to enable the FGU interrupt
  power: supply: sc27xx: Add POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN attribute
  power: supply: max77650: add MODULE_ALIAS()
  power: supply: isp1704: remove redundant assignment to variable ret
  power: supply: bq25890_charger: Add the BQ25895 part
  power: supply: sc27xx: Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
  power: supply: sc27xx: Introduce local variable 'struct device *dev'
  power: reset: reboot-mode: Fix author email format
  power: supply: ab8500: remove set but not used variables 'vbup33_vrtcn' and 'bup_vch_range'
  power: supply: max17042_battery: Fix a typo in function names
  power: reset: gpio-restart: Fix typo when gpio reset is not found
  power: supply: Init device wakeup after device_add()
  power: supply: ab8500_charger: Mark expected switch fall-through
  power: supply: sbs-battery: only return health when battery present
  MAINTAINERS: N900: Remove isp1704_charger.h record
  ...
  • Loading branch information
Linus Torvalds committed Sep 22, 2019
2 parents 57f1c3c + 7f73786 commit 619e17c
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 120 deletions.
1 change: 0 additions & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -11511,7 +11511,6 @@ NOKIA N900 POWER SUPPLY DRIVERS
R: Pali Rohár <pali.rohar@gmail.com>
F: include/linux/power/bq2415x_charger.h
F: include/linux/power/bq27xxx_battery.h
F: include/linux/power/isp1704_charger.h
F: drivers/power/supply/bq2415x_charger.c
F: drivers/power/supply/bq27xxx_battery.c
F: drivers/power/supply/bq27xxx_battery_i2c.c
Expand Down
8 changes: 5 additions & 3 deletions drivers/phy/motorola/phy-cpcap-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,18 @@ static void cpcap_usb_detect(struct work_struct *work)
goto out_err;

error = regmap_update_bits(ddata->reg, CPCAP_REG_USBC3,
CPCAP_BIT_VBUSSTBY_EN,
CPCAP_BIT_VBUSSTBY_EN);
CPCAP_BIT_VBUSSTBY_EN |
CPCAP_BIT_VBUSEN_SPI,
CPCAP_BIT_VBUSEN_SPI);
if (error)
goto out_err;

return;
}

error = regmap_update_bits(ddata->reg, CPCAP_REG_USBC3,
CPCAP_BIT_VBUSSTBY_EN, 0);
CPCAP_BIT_VBUSSTBY_EN |
CPCAP_BIT_VBUSEN_SPI, 0);
if (error)
goto out_err;

Expand Down
2 changes: 1 addition & 1 deletion drivers/power/reset/gpio-restart.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int gpio_restart_probe(struct platform_device *pdev)
gpio_restart->reset_gpio = devm_gpiod_get(&pdev->dev, NULL,
open_source ? GPIOD_IN : GPIOD_OUT_LOW);
if (IS_ERR(gpio_restart->reset_gpio)) {
dev_err(&pdev->dev, "Could net get reset GPIO\n");
dev_err(&pdev->dev, "Could not get reset GPIO\n");
return PTR_ERR(gpio_restart->reset_gpio);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/power/reset/reboot-mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@ void devm_reboot_mode_unregister(struct device *dev,
}
EXPORT_SYMBOL_GPL(devm_reboot_mode_unregister);

MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com");
MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com>");
MODULE_DESCRIPTION("System reboot mode core library");
MODULE_LICENSE("GPL v2");
9 changes: 1 addition & 8 deletions drivers/power/supply/ab8500_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,
USB_CH_IP_CUR_LVL_1P5;
break;
}
/* Else, fall through */
/* else, fall through */
case USB_STAT_HM_IDGND:
dev_err(di->dev, "USB Type - Charging not allowed\n");
di->max_usb_in_curr.usb_type_max = USB_CH_IP_CUR_LVL_0P05;
Expand Down Expand Up @@ -3011,7 +3011,6 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy,
static int ab8500_charger_init_hw_registers(struct ab8500_charger *di)
{
int ret = 0;
u8 bup_vch_range = 0, vbup33_vrtcn = 0;

/* Setup maximum charger current and voltage for ABB cut2.0 */
if (!is_ab8500_1p1_or_earlier(di->parent)) {
Expand Down Expand Up @@ -3112,12 +3111,6 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di)
goto out;
}

/* Backup battery voltage and current */
if (di->bm->bkup_bat_v > BUP_VCH_SEL_3P1V)
bup_vch_range = BUP_VCH_RANGE;
if (di->bm->bkup_bat_v == BUP_VCH_SEL_3P3V)
vbup33_vrtcn = VBUP33_VRTCN;

ret = abx500_set_register_interruptible(di->dev,
AB8500_RTC,
AB8500_RTC_BACKUP_CHG_REG,
Expand Down
14 changes: 11 additions & 3 deletions drivers/power/supply/axp288_fuel_gauge.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ static void fuel_gauge_init_irq(struct axp288_fg_info *info)
/*
* Some devices have no battery (HDMI sticks) and the axp288 battery's
* detection reports one despite it not being there.
* Please keep this listed sorted alphabetically.
*/
static const struct dmi_system_id axp288_fuel_gauge_blacklist[] = {
{
Expand All @@ -696,6 +697,12 @@ static const struct dmi_system_id axp288_fuel_gauge_blacklist[] = {
DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
},
},
{
/* ECS EF20EA */
.matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
},
},
{
/* Intel Cherry Trail Compute Stick, Windows version */
.matches = {
Expand All @@ -720,10 +727,11 @@ static const struct dmi_system_id axp288_fuel_gauge_blacklist[] = {
},
},
{
/* ECS EF20EA */
/* Minix Neo Z83-4 mini PC */
.matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
},
DMI_MATCH(DMI_SYS_VENDOR, "MINIX"),
DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
}
},
{}
};
Expand Down
12 changes: 8 additions & 4 deletions drivers/power/supply/bq25890_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define BQ25890_IRQ_PIN "bq25890_irq"

#define BQ25890_ID 3
#define BQ25895_ID 7
#define BQ25896_ID 0

enum bq25890_fields {
Expand Down Expand Up @@ -171,7 +172,7 @@ static const struct reg_field bq25890_reg_fields[] = {
[F_WD] = REG_FIELD(0x07, 4, 5),
[F_TMR_EN] = REG_FIELD(0x07, 3, 3),
[F_CHG_TMR] = REG_FIELD(0x07, 1, 2),
[F_JEITA_ISET] = REG_FIELD(0x07, 0, 0),
[F_JEITA_ISET] = REG_FIELD(0x07, 0, 0), // reserved on BQ25895
/* REG08 */
[F_BATCMP] = REG_FIELD(0x08, 5, 7),
[F_VCLAMP] = REG_FIELD(0x08, 2, 4),
Expand All @@ -180,15 +181,15 @@ static const struct reg_field bq25890_reg_fields[] = {
[F_FORCE_ICO] = REG_FIELD(0x09, 7, 7),
[F_TMR2X_EN] = REG_FIELD(0x09, 6, 6),
[F_BATFET_DIS] = REG_FIELD(0x09, 5, 5),
[F_JEITA_VSET] = REG_FIELD(0x09, 4, 4),
[F_JEITA_VSET] = REG_FIELD(0x09, 4, 4), // reserved on BQ25895
[F_BATFET_DLY] = REG_FIELD(0x09, 3, 3),
[F_BATFET_RST_EN] = REG_FIELD(0x09, 2, 2),
[F_PUMPX_UP] = REG_FIELD(0x09, 1, 1),
[F_PUMPX_DN] = REG_FIELD(0x09, 0, 0),
/* REG0A */
[F_BOOSTV] = REG_FIELD(0x0A, 4, 7),
/* PFM_OTG_DIS 3 on BQ25896 */
[F_BOOSTI] = REG_FIELD(0x0A, 0, 2),
[F_BOOSTI] = REG_FIELD(0x0A, 0, 2), // reserved on BQ25895
/* REG0B */
[F_VBUS_STAT] = REG_FIELD(0x0B, 5, 7),
[F_CHG_STAT] = REG_FIELD(0x0B, 3, 4),
Expand Down Expand Up @@ -392,6 +393,8 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_MODEL_NAME:
if (bq->chip_id == BQ25890_ID)
val->strval = "BQ25890";
else if (bq->chip_id == BQ25895_ID)
val->strval = "BQ25895";
else if (bq->chip_id == BQ25896_ID)
val->strval = "BQ25896";
else
Expand Down Expand Up @@ -862,7 +865,8 @@ static int bq25890_probe(struct i2c_client *client,
return bq->chip_id;
}

if ((bq->chip_id != BQ25890_ID) && (bq->chip_id != BQ25896_ID)) {
if ((bq->chip_id != BQ25890_ID) && (bq->chip_id != BQ25895_ID)
&& (bq->chip_id != BQ25896_ID)) {
dev_err(dev, "Chip with ID=%d, not supported!\n", bq->chip_id);
return -ENODEV;
}
Expand Down
23 changes: 20 additions & 3 deletions drivers/power/supply/cpcap-charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
#define CPCAP_REG_CRM_ICHRG_1A596 CPCAP_REG_CRM_ICHRG(0xe)
#define CPCAP_REG_CRM_ICHRG_NO_LIMIT CPCAP_REG_CRM_ICHRG(0xf)

/* CPCAP_REG_VUSBC register bits needed for VBUS */
#define CPCAP_BIT_VBUS_SWITCH BIT(0) /* VBUS boost to 5V */

enum {
CPCAP_CHARGER_IIO_BATTDET,
CPCAP_CHARGER_IIO_VOLTAGE,
Expand All @@ -130,7 +133,8 @@ struct cpcap_charger_ddata {
struct power_supply *usb;

struct phy_companion comparator; /* For USB VBUS */
bool vbus_enabled;
unsigned int vbus_enabled:1;
unsigned int feeding_vbus:1;
atomic_t active;

int status;
Expand Down Expand Up @@ -325,7 +329,6 @@ static bool cpcap_charger_vbus_valid(struct cpcap_charger_ddata *ddata)
}

/* VBUS control functions for the USB PHY companion */

static void cpcap_charger_vbus_work(struct work_struct *work)
{
struct cpcap_charger_ddata *ddata;
Expand All @@ -343,26 +346,39 @@ static void cpcap_charger_vbus_work(struct work_struct *work)
return;
}

ddata->feeding_vbus = true;
cpcap_charger_set_cable_path(ddata, false);
cpcap_charger_set_inductive_path(ddata, false);

error = cpcap_charger_set_state(ddata, 0, 0, 0);
if (error)
goto out_err;

error = regmap_update_bits(ddata->reg, CPCAP_REG_VUSBC,
CPCAP_BIT_VBUS_SWITCH,
CPCAP_BIT_VBUS_SWITCH);
if (error)
goto out_err;

error = regmap_update_bits(ddata->reg, CPCAP_REG_CRM,
CPCAP_REG_CRM_RVRSMODE,
CPCAP_REG_CRM_RVRSMODE);
if (error)
goto out_err;
} else {
error = regmap_update_bits(ddata->reg, CPCAP_REG_VUSBC,
CPCAP_BIT_VBUS_SWITCH, 0);
if (error)
goto out_err;

error = regmap_update_bits(ddata->reg, CPCAP_REG_CRM,
CPCAP_REG_CRM_RVRSMODE, 0);
if (error)
goto out_err;

cpcap_charger_set_cable_path(ddata, true);
cpcap_charger_set_inductive_path(ddata, true);
ddata->feeding_vbus = false;
}

return;
Expand Down Expand Up @@ -431,7 +447,8 @@ static void cpcap_usb_detect(struct work_struct *work)
if (error)
return;

if (cpcap_charger_vbus_valid(ddata) && s.chrgcurr1) {
if (!ddata->feeding_vbus && cpcap_charger_vbus_valid(ddata) &&
s.chrgcurr1) {
int max_current;

if (cpcap_charger_battery_found(ddata))
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/supply/isp1704_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp)
int vendor;
int product;
int i;
int ret = -ENODEV;
int ret;

/* Test ULPI interface */
ret = isp1704_write(isp, ULPI_SCRATCH, 0xaa);
Expand Down
8 changes: 4 additions & 4 deletions drivers/power/supply/max17042_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,15 @@ static inline void max17042_override_por(struct regmap *map,
regmap_write(map, reg, value);
}

static inline void max10742_unlock_model(struct max17042_chip *chip)
static inline void max17042_unlock_model(struct max17042_chip *chip)
{
struct regmap *map = chip->regmap;

regmap_write(map, MAX17042_MLOCKReg1, MODEL_UNLOCK1);
regmap_write(map, MAX17042_MLOCKReg2, MODEL_UNLOCK2);
}

static inline void max10742_lock_model(struct max17042_chip *chip)
static inline void max17042_lock_model(struct max17042_chip *chip)
{
struct regmap *map = chip->regmap;

Expand Down Expand Up @@ -577,7 +577,7 @@ static int max17042_init_model(struct max17042_chip *chip)
if (!temp_data)
return -ENOMEM;

max10742_unlock_model(chip);
max17042_unlock_model(chip);
max17042_write_model_data(chip, MAX17042_MODELChrTbl,
table_size);
max17042_read_model_data(chip, MAX17042_MODELChrTbl, temp_data,
Expand All @@ -589,7 +589,7 @@ static int max17042_init_model(struct max17042_chip *chip)
temp_data,
table_size);

max10742_lock_model(chip);
max17042_lock_model(chip);
kfree(temp_data);

return ret;
Expand Down
1 change: 1 addition & 0 deletions drivers/power/supply/max77650-charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,4 @@ module_platform_driver(max77650_charger_driver);
MODULE_DESCRIPTION("MAXIM 77650/77651 charger driver");
MODULE_AUTHOR("Bartosz Golaszewski <bgolaszewski@baylibre.com>");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:max77650-charger");
10 changes: 5 additions & 5 deletions drivers/power/supply/power_supply_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,14 +1051,14 @@ __power_supply_register(struct device *parent,
}

spin_lock_init(&psy->changed_lock);
rc = device_init_wakeup(dev, ws);
if (rc)
goto wakeup_init_failed;

rc = device_add(dev);
if (rc)
goto device_add_failed;

rc = device_init_wakeup(dev, ws);
if (rc)
goto wakeup_init_failed;

rc = psy_register_thermal(psy);
if (rc)
goto register_thermal_failed;
Expand Down Expand Up @@ -1101,8 +1101,8 @@ __power_supply_register(struct device *parent,
psy_unregister_thermal(psy);
register_thermal_failed:
device_del(dev);
device_add_failed:
wakeup_init_failed:
device_add_failed:
check_supplies_failed:
dev_set_name_failed:
put_device(dev);
Expand Down
15 changes: 14 additions & 1 deletion drivers/power/supply/power_supply_hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy)
struct device *dev = &psy->dev;
struct device *hwmon;
int ret, i;
const char *name;

if (!devres_open_group(dev, power_supply_add_hwmon_sysfs,
GFP_KERNEL))
Expand Down Expand Up @@ -334,7 +335,19 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy)
}
}

hwmon = devm_hwmon_device_register_with_info(dev, psy->desc->name,
name = psy->desc->name;
if (strchr(name, '-')) {
char *new_name;

new_name = devm_kstrdup(dev, name, GFP_KERNEL);
if (!new_name) {
ret = -ENOMEM;
goto error;
}
strreplace(new_name, '-', '_');
name = new_name;
}
hwmon = devm_hwmon_device_register_with_info(dev, name,
psyhw,
&power_supply_hwmon_chip_info,
NULL);
Expand Down
Loading

0 comments on commit 619e17c

Please sign in to comment.