diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/reset/rmobile-reset.c | 5 | ||||
-rw-r--r-- | drivers/power/supply/ab8500_fg.c | 52 | ||||
-rw-r--r-- | drivers/power/supply/bq25890_charger.c | 62 | ||||
-rw-r--r-- | drivers/power/supply/cros_usbpd-charger.c | 2 | ||||
-rw-r--r-- | drivers/power/supply/max14577_charger.c | 22 | ||||
-rw-r--r-- | drivers/power/supply/max17040_battery.c | 18 | ||||
-rw-r--r-- | drivers/power/supply/max17042_battery.c | 32 | ||||
-rw-r--r-- | drivers/power/supply/max77693_charger.c | 22 | ||||
-rw-r--r-- | drivers/power/supply/max8997_charger.c | 26 | ||||
-rw-r--r-- | drivers/power/supply/max8998_charger.c | 26 | ||||
-rw-r--r-- | drivers/power/supply/power_supply_sysfs.c | 3 |
11 files changed, 117 insertions, 153 deletions
diff --git a/drivers/power/reset/rmobile-reset.c b/drivers/power/reset/rmobile-reset.c index e6569df76941..bd3b396558e0 100644 --- a/drivers/power/reset/rmobile-reset.c +++ b/drivers/power/reset/rmobile-reset.c @@ -1,11 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Renesas R-Mobile Reset Driver * * Copyright (C) 2014 Glider bvba - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. */ #include <linux/io.h> diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 02356f9b5f22..776102c31305 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -2433,17 +2433,14 @@ static ssize_t charge_full_store(struct ab8500_fg *di, const char *buf, size_t count) { unsigned long charge_full; - ssize_t ret; + int ret; ret = kstrtoul(buf, 10, &charge_full); + if (ret) + return ret; - dev_dbg(di->dev, "Ret %zd charge_full %lu", ret, charge_full); - - if (!ret) { - di->bat_cap.max_mah = (int) charge_full; - ret = count; - } - return ret; + di->bat_cap.max_mah = (int) charge_full; + return count; } static ssize_t charge_now_show(struct ab8500_fg *di, char *buf) @@ -2455,20 +2452,16 @@ static ssize_t charge_now_store(struct ab8500_fg *di, const char *buf, size_t count) { unsigned long charge_now; - ssize_t ret; + int ret; ret = kstrtoul(buf, 10, &charge_now); + if (ret) + return ret; - dev_dbg(di->dev, "Ret %zd charge_now %lu was %d", - ret, charge_now, di->bat_cap.prev_mah); - - if (!ret) { - di->bat_cap.user_mah = (int) charge_now; - di->flags.user_cap = true; - ret = count; - queue_delayed_work(di->fg_wq, &di->fg_periodic_work, 0); - } - return ret; + di->bat_cap.user_mah = (int) charge_now; + di->flags.user_cap = true; + queue_delayed_work(di->fg_wq, &di->fg_periodic_work, 0); + return count; } static struct ab8500_fg_sysfs_entry charge_full_attr = @@ -2582,11 +2575,12 @@ static ssize_t ab8505_powercut_flagtime_write(struct device *dev, const char *buf, size_t count) { int ret; - long unsigned reg_value; + int reg_value; struct power_supply *psy = dev_get_drvdata(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); - reg_value = simple_strtoul(buf, NULL, 10); + if (kstrtoint(buf, 10, ®_value)) + goto fail; if (reg_value > 0x7F) { dev_err(dev, "Incorrect parameter, echo 0 (1.98s) - 127 (15.625ms) for flagtime\n"); @@ -2636,7 +2630,9 @@ static ssize_t ab8505_powercut_maxtime_write(struct device *dev, struct power_supply *psy = dev_get_drvdata(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); - reg_value = simple_strtoul(buf, NULL, 10); + if (kstrtoint(buf, 10, ®_value)) + goto fail; + if (reg_value > 0x7F) { dev_err(dev, "Incorrect parameter, echo 0 (0.0s) - 127 (1.98s) for maxtime\n"); goto fail; @@ -2684,7 +2680,9 @@ static ssize_t ab8505_powercut_restart_write(struct device *dev, struct power_supply *psy = dev_get_drvdata(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); - reg_value = simple_strtoul(buf, NULL, 10); + if (kstrtoint(buf, 10, ®_value)) + goto fail; + if (reg_value > 0xF) { dev_err(dev, "Incorrect parameter, echo 0 - 15 for number of restart\n"); goto fail; @@ -2777,7 +2775,9 @@ static ssize_t ab8505_powercut_write(struct device *dev, struct power_supply *psy = dev_get_drvdata(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); - reg_value = simple_strtoul(buf, NULL, 10); + if (kstrtoint(buf, 10, ®_value)) + goto fail; + if (reg_value > 0x1) { dev_err(dev, "Incorrect parameter, echo 0/1 to disable/enable Pcut feature\n"); goto fail; @@ -2849,7 +2849,9 @@ static ssize_t ab8505_powercut_debounce_write(struct device *dev, struct power_supply *psy = dev_get_drvdata(dev); struct ab8500_fg *di = power_supply_get_drvdata(psy); - reg_value = simple_strtoul(buf, NULL, 10); + if (kstrtoint(buf, 10, ®_value)) + goto fail; + if (reg_value > 0x7) { dev_err(dev, "Incorrect parameter, echo 0 to 7 for debounce setting\n"); goto fail; diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 8e2c41ded171..1aa7872ddeb0 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -32,6 +32,7 @@ #define BQ25890_IRQ_PIN "bq25890_irq" #define BQ25890_ID 3 +#define BQ25896_ID 0 enum bq25890_fields { F_EN_HIZ, F_EN_ILIM, F_IILIM, /* Reg00 */ @@ -153,8 +154,8 @@ static const struct reg_field bq25890_reg_fields[] = { [F_CONV_RATE] = REG_FIELD(0x02, 6, 6), [F_BOOSTF] = REG_FIELD(0x02, 5, 5), [F_ICO_EN] = REG_FIELD(0x02, 4, 4), - [F_HVDCP_EN] = REG_FIELD(0x02, 3, 3), - [F_MAXC_EN] = REG_FIELD(0x02, 2, 2), + [F_HVDCP_EN] = REG_FIELD(0x02, 3, 3), // reserved on BQ25896 + [F_MAXC_EN] = REG_FIELD(0x02, 2, 2), // reserved on BQ25896 [F_FORCE_DPM] = REG_FIELD(0x02, 1, 1), [F_AUTO_DPDM_EN] = REG_FIELD(0x02, 0, 0), /* REG03 */ @@ -163,6 +164,7 @@ static const struct reg_field bq25890_reg_fields[] = { [F_OTG_CFG] = REG_FIELD(0x03, 5, 5), [F_CHG_CFG] = REG_FIELD(0x03, 4, 4), [F_SYSVMIN] = REG_FIELD(0x03, 1, 3), + /* MIN_VBAT_SEL on BQ25896 */ /* REG04 */ [F_PUMPX_EN] = REG_FIELD(0x04, 7, 7), [F_ICHG] = REG_FIELD(0x04, 0, 6), @@ -181,7 +183,7 @@ static const struct reg_field bq25890_reg_fields[] = { [F_CHG_TMR] = REG_FIELD(0x07, 1, 2), [F_JEITA_ISET] = REG_FIELD(0x07, 0, 0), /* REG08 */ - [F_BATCMP] = REG_FIELD(0x08, 6, 7), + [F_BATCMP] = REG_FIELD(0x08, 6, 7), // 5-7 on BQ25896 [F_VCLAMP] = REG_FIELD(0x08, 2, 4), [F_TREG] = REG_FIELD(0x08, 0, 1), /* REG09 */ @@ -195,12 +197,13 @@ static const struct reg_field bq25890_reg_fields[] = { [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), /* REG0B */ [F_VBUS_STAT] = REG_FIELD(0x0B, 5, 7), [F_CHG_STAT] = REG_FIELD(0x0B, 3, 4), [F_PG_STAT] = REG_FIELD(0x0B, 2, 2), - [F_SDP_STAT] = REG_FIELD(0x0B, 1, 1), + [F_SDP_STAT] = REG_FIELD(0x0B, 1, 1), // reserved on BQ25896 [F_VSYS_STAT] = REG_FIELD(0x0B, 0, 0), /* REG0C */ [F_WD_FAULT] = REG_FIELD(0x0C, 7, 7), @@ -244,10 +247,7 @@ enum bq25890_table_ids { /* range tables */ TBL_ICHG, TBL_ITERM, - TBL_IPRECHG, TBL_VREG, - TBL_BATCMP, - TBL_VCLAMP, TBL_BOOSTV, TBL_SYSVMIN, @@ -287,8 +287,6 @@ static const union { [TBL_ICHG] = { .rt = {0, 5056000, 64000} }, /* uA */ [TBL_ITERM] = { .rt = {64000, 1024000, 64000} }, /* uA */ [TBL_VREG] = { .rt = {3840000, 4608000, 16000} }, /* uV */ - [TBL_BATCMP] = { .rt = {0, 140, 20} }, /* mOhm */ - [TBL_VCLAMP] = { .rt = {0, 224000, 32000} }, /* uV */ [TBL_BOOSTV] = { .rt = {4550000, 5510000, 64000} }, /* uV */ [TBL_SYSVMIN] = { .rt = {3000000, 3700000, 100000} }, /* uV */ @@ -401,6 +399,16 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, val->strval = BQ25890_MANUFACTURER; break; + case POWER_SUPPLY_PROP_MODEL_NAME: + if (bq->chip_id == BQ25890_ID) + val->strval = "BQ25890"; + else if (bq->chip_id == BQ25896_ID) + val->strval = "BQ25896"; + else + val->strval = "UNKNOWN"; + + break; + case POWER_SUPPLY_PROP_ONLINE: val->intval = state.online; break; @@ -453,6 +461,15 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, val->intval = bq25890_find_val(bq->init_data.iterm, TBL_ITERM); break; + case POWER_SUPPLY_PROP_VOLTAGE_NOW: + ret = bq25890_field_read(bq, F_SYSV); /* read measured value */ + if (ret < 0) + return ret; + + /* converted_val = 2.304V + ADC_val * 20mV (table 10.3.15) */ + val->intval = 2304000 + ret * 20000; + break; + default: return -EINVAL; } @@ -608,30 +625,40 @@ static int bq25890_hw_init(struct bq25890_device *bq) }; ret = bq25890_chip_reset(bq); - if (ret < 0) + if (ret < 0) { + dev_dbg(bq->dev, "Reset failed %d\n", ret); return ret; + }; /* disable watchdog */ ret = bq25890_field_write(bq, F_WD, 0); - if (ret < 0) + if (ret < 0) { + dev_dbg(bq->dev, "Disabling watchdog failed %d\n", ret); return ret; + }; /* initialize currents/voltages and other parameters */ for (i = 0; i < ARRAY_SIZE(init_data); i++) { ret = bq25890_field_write(bq, init_data[i].id, init_data[i].value); - if (ret < 0) + if (ret < 0) { + dev_dbg(bq->dev, "Writing init data failed %d\n", ret); return ret; + }; } /* Configure ADC for continuous conversions. This does not enable it. */ ret = bq25890_field_write(bq, F_CONV_RATE, 1); - if (ret < 0) + if (ret < 0) { + dev_dbg(bq->dev, "Config ADC failed %d\n", ret); return ret; + }; ret = bq25890_get_chip_state(bq, &state); - if (ret < 0) + if (ret < 0) { + dev_dbg(bq->dev, "Get state failed %d\n", ret); return ret; + }; mutex_lock(&bq->lock); bq->state = state; @@ -642,6 +669,7 @@ static int bq25890_hw_init(struct bq25890_device *bq) static enum power_supply_property bq25890_power_supply_props[] = { POWER_SUPPLY_PROP_MANUFACTURER, + POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_HEALTH, @@ -650,6 +678,7 @@ static enum power_supply_property bq25890_power_supply_props[] = { POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, + POWER_SUPPLY_PROP_VOLTAGE_NOW, }; static char *bq25890_charger_supplied_to[] = { @@ -767,6 +796,9 @@ static int bq25890_fw_read_u32_props(struct bq25890_device *bq) if (props[i].optional) continue; + dev_err(bq->dev, "Unable to read property %d %s\n", ret, + props[i].name); + return ret; } @@ -840,7 +872,7 @@ static int bq25890_probe(struct i2c_client *client, return bq->chip_id; } - if (bq->chip_id != BQ25890_ID) { + if ((bq->chip_id != BQ25890_ID) && (bq->chip_id != BQ25896_ID)) { dev_err(dev, "Chip with ID=%d, not supported!\n", bq->chip_id); return -ENODEV; } diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c index 688a16bacfbb..f2b8de502b82 100644 --- a/drivers/power/supply/cros_usbpd-charger.c +++ b/drivers/power/supply/cros_usbpd-charger.c @@ -378,12 +378,10 @@ static int cros_usbpd_charger_ec_event(struct notifier_block *nb, { struct cros_ec_device *ec_device; struct charger_data *charger; - struct device *dev; u32 host_event; charger = container_of(nb, struct charger_data, notifier); ec_device = charger->ec_device; - dev = charger->dev; host_event = cros_ec_get_host_event(ec_device); if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) { diff --git a/drivers/power/supply/max14577_charger.c b/drivers/power/supply/max14577_charger.c index 449fc56f09eb..8a59feac6468 100644 --- a/drivers/power/supply/max14577_charger.c +++ b/drivers/power/supply/max14577_charger.c @@ -1,19 +1,9 @@ -/* - * max14577_charger.c - Battery charger driver for the Maxim 14577/77836 - * - * Copyright (C) 2013,2014 Samsung Electronics - * Krzysztof Kozlowski <krzk@kernel.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +// SPDX-License-Identifier: GPL-2.0+ +// +// max14577_charger.c - Battery charger driver for the Maxim 14577/77836 +// +// Copyright (C) 2013,2014 Samsung Electronics +// Krzysztof Kozlowski <krzk@kernel.org> #include <linux/module.h> #include <linux/platform_device.h> diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index 33c40f79d23d..91cafc7bed30 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -1,14 +1,10 @@ -/* - * max17040_battery.c - * fuel-gauge systems for lithium-ion (Li+) batteries - * - * Copyright (C) 2009 Samsung Electronics - * Minkyu Kang <mk7.kang@samsung.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ +// SPDX-License-Identifier: GPL-2.0 +// +// max17040_battery.c +// fuel-gauge systems for lithium-ion (Li+) batteries +// +// Copyright (C) 2009 Samsung Electronics +// Minkyu Kang <mk7.kang@samsung.com> #include <linux/module.h> #include <linux/init.h> diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c index 1a568df383db..2a8d75e5e930 100644 --- a/drivers/power/supply/max17042_battery.c +++ b/drivers/power/supply/max17042_battery.c @@ -1,26 +1,12 @@ -/* - * Fuel gauge driver for Maxim 17042 / 8966 / 8997 - * Note that Maxim 8966 and 8997 are mfd and this is its subdevice. - * - * Copyright (C) 2011 Samsung Electronics - * MyungJoo Ham <myungjoo.ham@samsung.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * This driver is based on max17040_battery.c - */ +// SPDX-License-Identifier: GPL-2.0+ +// +// Fuel gauge driver for Maxim 17042 / 8966 / 8997 +// Note that Maxim 8966 and 8997 are mfd and this is its subdevice. +// +// Copyright (C) 2011 Samsung Electronics +// MyungJoo Ham <myungjoo.ham@samsung.com> +// +// This driver is based on max17040_battery.c #include <linux/acpi.h> #include <linux/init.h> diff --git a/drivers/power/supply/max77693_charger.c b/drivers/power/supply/max77693_charger.c index 749c7926e3c9..a2c5c9858639 100644 --- a/drivers/power/supply/max77693_charger.c +++ b/drivers/power/supply/max77693_charger.c @@ -1,19 +1,9 @@ -/* - * max77693_charger.c - Battery charger driver for the Maxim 77693 - * - * Copyright (C) 2014 Samsung Electronics - * Krzysztof Kozlowski <krzk@kernel.org> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +// SPDX-License-Identifier: GPL-2.0+ +// +// max77693_charger.c - Battery charger driver for the Maxim 77693 +// +// Copyright (C) 2014 Samsung Electronics +// Krzysztof Kozlowski <krzk@kernel.org> #include <linux/module.h> #include <linux/platform_device.h> diff --git a/drivers/power/supply/max8997_charger.c b/drivers/power/supply/max8997_charger.c index c73fb4221695..f5e84cd47924 100644 --- a/drivers/power/supply/max8997_charger.c +++ b/drivers/power/supply/max8997_charger.c @@ -1,23 +1,9 @@ -/* - * max8997_charger.c - Power supply consumer driver for the Maxim 8997/8966 - * - * Copyright (C) 2011 Samsung Electronics - * MyungJoo Ham <myungjoo.ham@samsung.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +// SPDX-License-Identifier: GPL-2.0+ +// +// max8997_charger.c - Power supply consumer driver for the Maxim 8997/8966 +// +// Copyright (C) 2011 Samsung Electronics +// MyungJoo Ham <myungjoo.ham@samsung.com> #include <linux/err.h> #include <linux/module.h> diff --git a/drivers/power/supply/max8998_charger.c b/drivers/power/supply/max8998_charger.c index cad7d1a8feec..95292381c3de 100644 --- a/drivers/power/supply/max8998_charger.c +++ b/drivers/power/supply/max8998_charger.c @@ -1,23 +1,9 @@ -/* - * max8998_charger.c - Power supply consumer driver for the Maxim 8998/LP3974 - * - * Copyright (C) 2009-2010 Samsung Electronics - * MyungJoo Ham <myungjoo.ham@samsung.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +// SPDX-License-Identifier: GPL-2.0+ +// +// max8998_charger.c - Power supply consumer driver for the Maxim 8998/LP3974 +// +// Copyright (C) 2009-2010 Samsung Electronics +// MyungJoo Ham <myungjoo.ham@samsung.com> #include <linux/err.h> #include <linux/module.h> diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 6170ed8b6854..dce24f596160 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -131,7 +131,8 @@ static ssize_t power_supply_show_property(struct device *dev, dev_dbg(dev, "driver has no data for `%s' property\n", attr->attr.name); else if (ret != -ENODEV && ret != -EAGAIN) - dev_err(dev, "driver failed to report `%s' property: %zd\n", + dev_err_ratelimited(dev, + "driver failed to report `%s' property: %zd\n", attr->attr.name, ret); return ret; } |