From 89a74789f4b476cda2c791ba26a1ade116218b15 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 29 Aug 2018 15:51:06 +0100 Subject: power: supply: cros_usbpd: remove unused pointer 'dev' Pointer 'dev' is being assigned but is never used hence it is redundant and can be removed. Cleans up clang warning: variable 'dev' set but not used [-Wunused-but-set-variable] Signed-off-by: Colin Ian King Reviewed-by: Krzysztof Kozlowski Signed-off-by: Sebastian Reichel --- drivers/power/supply/cros_usbpd-charger.c | 2 -- 1 file changed, 2 deletions(-) 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)) { -- cgit v1.2.3 From b00b04aa668cc16ab67fe7ef553a7d14d4d16861 Mon Sep 17 00:00:00 2001 From: Ding Xiang Date: Mon, 27 Aug 2018 06:49:15 -0400 Subject: power: supply: ab8500_fg: fix obsolete function simple_strtoul is obsolete, and use kstrtoint instead Signed-off-by: Ding Xiang Signed-off-by: Sebastian Reichel --- drivers/power/supply/ab8500_fg.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 02356f9b5f22..2bdadb58bcc6 100644 --- a/drivers/power/supply/ab8500_fg.c +++ b/drivers/power/supply/ab8500_fg.c @@ -2582,11 +2582,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 +2637,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 +2687,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 +2782,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 +2856,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; -- cgit v1.2.3 From 7b38ebdf74308918f2e2e92f8ee8f60f5bbc512c Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Tue, 7 Aug 2018 18:21:06 +0200 Subject: power: supply: maxim: Add SPDX license identifiers Replace GPL v2.0 and v2.0+ license statements with SPDX license identifiers. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sebastian Reichel --- drivers/power/supply/max14577_charger.c | 22 ++++++---------------- drivers/power/supply/max17040_battery.c | 18 +++++++----------- drivers/power/supply/max17042_battery.c | 32 +++++++++----------------------- drivers/power/supply/max77693_charger.c | 22 ++++++---------------- drivers/power/supply/max8997_charger.c | 26 ++++++-------------------- drivers/power/supply/max8998_charger.c | 26 ++++++-------------------- 6 files changed, 40 insertions(+), 106 deletions(-) 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 - * - * 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 #include #include 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 - * - * 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 #include #include 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 - * - * 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 +// +// This driver is based on max17040_battery.c #include #include 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 - * - * 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 #include #include 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 - * - * 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 #include #include 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 - * - * 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 #include #include -- cgit v1.2.3 From 9d9ae3414d1bb655d8db7079e56b0f51e7cd07f0 Mon Sep 17 00:00:00 2001 From: "Angus Ainslie (Purism)" Date: Tue, 31 Jul 2018 11:49:06 -0600 Subject: power: supply: bq25890_charger: Add debugging output of failed initialization To ease adding a new part variant some debugging is handy. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Angus Ainslie (Purism) Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq25890_charger.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 8e2c41ded171..7f0b3a46c50c 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -608,30 +608,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; @@ -767,6 +777,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; } -- cgit v1.2.3 From 0838d84fff7c57dc76590536c5ea5a3404370538 Mon Sep 17 00:00:00 2001 From: "Angus Ainslie (Purism)" Date: Tue, 31 Jul 2018 11:49:07 -0600 Subject: power: supply: bq25890_charger: Remove unused table entries There are a few table entries that aren't used. Drop them. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Angus Ainslie (Purism) Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq25890_charger.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 7f0b3a46c50c..ca61278e932e 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -244,10 +244,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 +284,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 */ -- cgit v1.2.3 From 2e1a2ddee9cef07f5b1fab5625dcc56078139a4e Mon Sep 17 00:00:00 2001 From: "Angus Ainslie (Purism)" Date: Tue, 31 Jul 2018 11:49:08 -0600 Subject: power: supply: bq25890_charger: Add the BQ25896 part The BQ25896 is almost identical to the BQ25890. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Angus Ainslie (Purism) Signed-off-by: Sebastian Reichel --- .../devicetree/bindings/power/supply/bq25890.txt | 3 +++ drivers/power/supply/bq25890_charger.c | 24 +++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/power/supply/bq25890.txt b/Documentation/devicetree/bindings/power/supply/bq25890.txt index c9dd17d142ad..dc0568933359 100644 --- a/Documentation/devicetree/bindings/power/supply/bq25890.txt +++ b/Documentation/devicetree/bindings/power/supply/bq25890.txt @@ -1,5 +1,8 @@ Binding for TI bq25890 Li-Ion Charger +This driver will support the bq25896 and the bq25890. There are other ICs +in the same family but those have not been tested. + Required properties: - compatible: Should contain one of the following: * "ti,bq25890" diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index ca61278e932e..23b39da07e56 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), @@ -396,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; @@ -647,6 +660,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, @@ -848,7 +862,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; } -- cgit v1.2.3 From ae6fe7a387e97e2ea8cc275fff5ef55568c4daf3 Mon Sep 17 00:00:00 2001 From: "Angus Ainslie (Purism)" Date: Tue, 31 Jul 2018 11:49:09 -0600 Subject: power: supply: bq25890_charger: Read back the current battery voltage The BQ2589x family has the capability of reading the current battery voltage. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Angus Ainslie (Purism) Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq25890_charger.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 23b39da07e56..1aa7872ddeb0 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -461,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; } @@ -669,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[] = { -- cgit v1.2.3 From 87a2b65fc855e6be50f791c2ebbb492541896827 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Wed, 12 Sep 2018 19:48:30 -0500 Subject: power: supply: sysfs: ratelimit property read error message This adds rate limiting to the message that is printed when reading a power supply property via sysfs returns an error. This will prevent userspace applications from unintentionally dDOSing the system by continuously reading a property that returns an error. Signed-off-by: David Lechner Signed-off-by: Sebastian Reichel --- drivers/power/supply/power_supply_sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; } -- cgit v1.2.3 From 54baff8d4e5dce2cef61953b1dc22079cda1ddb1 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 10 Sep 2018 11:39:04 +0300 Subject: power: supply: ab8500_fg: silence uninitialized variable warnings If kstrtoul() fails then we print "charge_full" when it's uninitialized. The debug printk doesn't add anything so I deleted it and cleaned these two functions up a bit. Signed-off-by: Dan Carpenter Signed-off-by: Sebastian Reichel --- drivers/power/supply/ab8500_fg.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c index 2bdadb58bcc6..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 = -- cgit v1.2.3 From b3e1b276a429e80824f9a1384eb656af3c1daf59 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Fri, 7 Sep 2018 02:15:08 +0000 Subject: power: reset: convert to SPDX identifiers This patch updates license to use SPDX-License-Identifier instead of verbose license text. Signed-off-by: Kuninori Morimoto Reviewed-by: Simon Horman Signed-off-by: Sebastian Reichel --- drivers/power/reset/rmobile-reset.c | 5 +---- 1 file changed, 1 insertion(+), 4 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 -- cgit v1.2.3 From 9f7195da31fb0b0f83dbd6bbe7aa98c889fb865a Mon Sep 17 00:00:00 2001 From: Claudiu Beznea Date: Thu, 30 Aug 2018 14:50:06 +0300 Subject: power: reset: at91-poweroff: switch to slow clock before shutdown The SAMA5D2 NRST input signal is resynchronized with the SLCK clock and it can take up to 2 SLCK cycles (about 90us) for the internal reset to be effective. During this delay, the VDDCORE current consumption may still be high (application-dependent) with the VDDCORE regulator already OFF. Under such conditions, VDDCORE may operate below its operating range leading to potential register corruption. To prevent such situation, it is recommended to decrease significantly the power consumption of the device once the voltage regulator is turned-off. This can be achieved by operating the device at a much lower low frequency. To solve this switch the master clock to slock clock just before writing shutdown command to shutdown controller. Signed-off-by: Claudiu Beznea Suggested-by: Patrice Vilchez Acked-by: Nicolas Ferre Signed-off-by: Sebastian Reichel --- arch/arm/mach-at91/pm_suspend.S | 8 ++++ drivers/power/reset/at91-sama5d2_shdwc.c | 66 ++++++++++++++++++++++++++++---- 2 files changed, 66 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S index a7c6ae13c945..bfe1c4d06901 100644 --- a/arch/arm/mach-at91/pm_suspend.S +++ b/arch/arm/mach-at91/pm_suspend.S @@ -149,6 +149,14 @@ exit_suspend: ENDPROC(at91_pm_suspend_in_sram) ENTRY(at91_backup_mode) + /* Switch the master clock source to slow clock. */ + ldr pmc, .pmc_base + ldr tmp1, [pmc, #AT91_PMC_MCKR] + bic tmp1, tmp1, #AT91_PMC_CSS + str tmp1, [pmc, #AT91_PMC_MCKR] + + wait_mckrdy + /*BUMEN*/ ldr r0, .sfr mov tmp1, #0x1 diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c index 0206cce328b3..dd6297bd7b6a 100644 --- a/drivers/power/reset/at91-sama5d2_shdwc.c +++ b/drivers/power/reset/at91-sama5d2_shdwc.c @@ -19,6 +19,7 @@ */ #include +#include #include #include #include @@ -70,6 +71,7 @@ struct shdwc_config { struct shdwc { const struct shdwc_config *cfg; void __iomem *at91_shdwc_base; + void __iomem *pmc_base; }; /* @@ -108,6 +110,12 @@ static void __init at91_wakeup_status(struct platform_device *pdev) static void at91_poweroff(void) { + /* Switch the master clock source to slow clock. */ + writel(readl(at91_shdwc->pmc_base + AT91_PMC_MCKR) & ~AT91_PMC_CSS, + at91_shdwc->pmc_base + AT91_PMC_MCKR); + while (!(readl(at91_shdwc->pmc_base + AT91_PMC_SR) & AT91_PMC_MCKRDY)) + ; + writel(AT91_SHDW_KEY | AT91_SHDW_SHDW, at91_shdwc->at91_shdwc_base + AT91_SHDW_CR); } @@ -123,6 +131,16 @@ static void at91_lpddr_poweroff(void) /* Power down SDRAM0 */ " str %1, [%0, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t" + + /* Switch the master clock source to slow clock. */ + " ldr r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t" + " bic r6, r6, #" __stringify(AT91_PMC_CSS) "\n\t" + " str r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t" + /* Wait for clock switch. */ + "1: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t" + " tst r6, #" __stringify(AT91_PMC_MCKRDY) "\n\t" + " beq 1b\n\t" + /* Shutdown CPU */ " str %3, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t" @@ -131,7 +149,8 @@ static void at91_lpddr_poweroff(void) : "r" (mpddrc_base), "r" cpu_to_le32(AT91_DDRSDRC_LPDDR2_PWOFF), "r" (at91_shdwc->at91_shdwc_base), - "r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW) + "r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW), + "r" (at91_shdwc->pmc_base) : "r6"); } @@ -276,26 +295,53 @@ static int __init at91_shdwc_probe(struct platform_device *pdev) at91_shdwc_dt_configure(pdev); - pm_power_off = at91_poweroff; + np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-pmc"); + if (!np) { + ret = -ENODEV; + goto clk_disable; + } + + at91_shdwc->pmc_base = of_iomap(np, 0); + of_node_put(np); + + if (!at91_shdwc->pmc_base) { + ret = -ENOMEM; + goto clk_disable; + } np = of_find_compatible_node(NULL, NULL, "atmel,sama5d3-ddramc"); - if (!np) - return 0; + if (!np) { + ret = -ENODEV; + goto unmap; + } mpddrc_base = of_iomap(np, 0); of_node_put(np); - if (!mpddrc_base) - return 0; + if (!mpddrc_base) { + ret = -ENOMEM; + goto unmap; + } + + pm_power_off = at91_poweroff; ddr_type = readl(mpddrc_base + AT91_DDRSDRC_MDR) & AT91_DDRSDRC_MD; if ((ddr_type == AT91_DDRSDRC_MD_LPDDR2) || - (ddr_type == AT91_DDRSDRC_MD_LPDDR3)) + (ddr_type == AT91_DDRSDRC_MD_LPDDR3)) { pm_power_off = at91_lpddr_poweroff; - else + } else { iounmap(mpddrc_base); + mpddrc_base = NULL; + } return 0; + +unmap: + iounmap(at91_shdwc->pmc_base); +clk_disable: + clk_disable_unprepare(sclk); + + return ret; } static int __exit at91_shdwc_remove(struct platform_device *pdev) @@ -310,6 +356,10 @@ static int __exit at91_shdwc_remove(struct platform_device *pdev) writel(0, shdw->at91_shdwc_base + AT91_SHDW_MR); writel(0, shdw->at91_shdwc_base + AT91_SHDW_WUIR); + if (mpddrc_base) + iounmap(mpddrc_base); + iounmap(shdw->pmc_base); + clk_disable_unprepare(sclk); return 0; -- cgit v1.2.3 From 4e018c1e9b05f722cdd2fecb36201376e3c58dda Mon Sep 17 00:00:00 2001 From: Claudiu Beznea Date: Thu, 30 Aug 2018 14:50:07 +0300 Subject: power: reset: at91-poweroff: use only one poweroff function Use only one poweroff function for sama5d2 and adapt it to work for both scenarios (having LPDDR or not). Signed-off-by: Claudiu Beznea Acked-by: Nicolas Ferre Signed-off-by: Sebastian Reichel --- drivers/power/reset/at91-sama5d2_shdwc.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c index dd6297bd7b6a..94ad79d0d82e 100644 --- a/drivers/power/reset/at91-sama5d2_shdwc.c +++ b/drivers/power/reset/at91-sama5d2_shdwc.c @@ -109,18 +109,6 @@ static void __init at91_wakeup_status(struct platform_device *pdev) } static void at91_poweroff(void) -{ - /* Switch the master clock source to slow clock. */ - writel(readl(at91_shdwc->pmc_base + AT91_PMC_MCKR) & ~AT91_PMC_CSS, - at91_shdwc->pmc_base + AT91_PMC_MCKR); - while (!(readl(at91_shdwc->pmc_base + AT91_PMC_SR) & AT91_PMC_MCKRDY)) - ; - - writel(AT91_SHDW_KEY | AT91_SHDW_SHDW, - at91_shdwc->at91_shdwc_base + AT91_SHDW_CR); -} - -static void at91_lpddr_poweroff(void) { asm volatile( /* Align to cache lines */ @@ -130,16 +118,18 @@ static void at91_lpddr_poweroff(void) " ldr r6, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t" /* Power down SDRAM0 */ + " tst %0, #0\n\t" + " beq 1f\n\t" " str %1, [%0, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t" /* Switch the master clock source to slow clock. */ - " ldr r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t" + "1: ldr r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t" " bic r6, r6, #" __stringify(AT91_PMC_CSS) "\n\t" " str r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t" /* Wait for clock switch. */ - "1: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t" + "2: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t" " tst r6, #" __stringify(AT91_PMC_MCKRDY) "\n\t" - " beq 1b\n\t" + " beq 2b\n\t" /* Shutdown CPU */ " str %3, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t" @@ -326,10 +316,8 @@ static int __init at91_shdwc_probe(struct platform_device *pdev) pm_power_off = at91_poweroff; ddr_type = readl(mpddrc_base + AT91_DDRSDRC_MDR) & AT91_DDRSDRC_MD; - if ((ddr_type == AT91_DDRSDRC_MD_LPDDR2) || - (ddr_type == AT91_DDRSDRC_MD_LPDDR3)) { - pm_power_off = at91_lpddr_poweroff; - } else { + if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 && + ddr_type != AT91_DDRSDRC_MD_LPDDR3) { iounmap(mpddrc_base); mpddrc_base = NULL; } @@ -348,8 +336,7 @@ static int __exit at91_shdwc_remove(struct platform_device *pdev) { struct shdwc *shdw = platform_get_drvdata(pdev); - if (pm_power_off == at91_poweroff || - pm_power_off == at91_lpddr_poweroff) + if (pm_power_off == at91_poweroff) pm_power_off = NULL; /* Reset values to disable wake-up features */ -- cgit v1.2.3 From 9be74f0d39c1c923185e184f3263ba29439ebad6 Mon Sep 17 00:00:00 2001 From: Claudiu Beznea Date: Thu, 30 Aug 2018 14:50:08 +0300 Subject: power: reset: at91-poweroff: make mpddrc_base part of struct shdwc Make mpddrc_base part of struct shdwc since there is also only one instance of struct shdwc *at91_shdwc in system and to have all data specific to SHDWC grouped together. Signed-off-by: Claudiu Beznea Acked-by: Nicolas Ferre Signed-off-by: Sebastian Reichel --- drivers/power/reset/at91-sama5d2_shdwc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c index 94ad79d0d82e..c9994103248e 100644 --- a/drivers/power/reset/at91-sama5d2_shdwc.c +++ b/drivers/power/reset/at91-sama5d2_shdwc.c @@ -71,6 +71,7 @@ struct shdwc_config { struct shdwc { const struct shdwc_config *cfg; void __iomem *at91_shdwc_base; + void __iomem *mpddrc_base; void __iomem *pmc_base; }; @@ -80,7 +81,6 @@ struct shdwc { */ static struct shdwc *at91_shdwc; static struct clk *sclk; -static void __iomem *mpddrc_base; static const unsigned long long sdwc_dbc_period[] = { 0, 3, 32, 512, 4096, 32768, @@ -136,7 +136,7 @@ static void at91_poweroff(void) " b .\n\t" : - : "r" (mpddrc_base), + : "r" (at91_shdwc->mpddrc_base), "r" cpu_to_le32(AT91_DDRSDRC_LPDDR2_PWOFF), "r" (at91_shdwc->at91_shdwc_base), "r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW), @@ -305,21 +305,22 @@ static int __init at91_shdwc_probe(struct platform_device *pdev) goto unmap; } - mpddrc_base = of_iomap(np, 0); + at91_shdwc->mpddrc_base = of_iomap(np, 0); of_node_put(np); - if (!mpddrc_base) { + if (!at91_shdwc->mpddrc_base) { ret = -ENOMEM; goto unmap; } pm_power_off = at91_poweroff; - ddr_type = readl(mpddrc_base + AT91_DDRSDRC_MDR) & AT91_DDRSDRC_MD; + ddr_type = readl(at91_shdwc->mpddrc_base + AT91_DDRSDRC_MDR) & + AT91_DDRSDRC_MD; if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 && ddr_type != AT91_DDRSDRC_MD_LPDDR3) { - iounmap(mpddrc_base); - mpddrc_base = NULL; + iounmap(at91_shdwc->mpddrc_base); + at91_shdwc->mpddrc_base = NULL; } return 0; @@ -343,8 +344,8 @@ static int __exit at91_shdwc_remove(struct platform_device *pdev) writel(0, shdw->at91_shdwc_base + AT91_SHDW_MR); writel(0, shdw->at91_shdwc_base + AT91_SHDW_WUIR); - if (mpddrc_base) - iounmap(mpddrc_base); + if (shdw->mpddrc_base) + iounmap(shdw->mpddrc_base); iounmap(shdw->pmc_base); clk_disable_unprepare(sclk); -- cgit v1.2.3 From 6764aca14fc85c5ae2bb0a63bece445a05dd4fff Mon Sep 17 00:00:00 2001 From: Claudiu Beznea Date: Thu, 30 Aug 2018 14:50:09 +0300 Subject: power: reset: at91-poweroff: make sclk part of struct shdwc Make sclk part of struct shdwc to have all the data specific to SHDWC grouped together in one structure. Signed-off-by: Claudiu Beznea Acked-by: Nicolas Ferre Signed-off-by: Sebastian Reichel --- drivers/power/reset/at91-sama5d2_shdwc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c index c9994103248e..945b41b4086a 100644 --- a/drivers/power/reset/at91-sama5d2_shdwc.c +++ b/drivers/power/reset/at91-sama5d2_shdwc.c @@ -70,6 +70,7 @@ struct shdwc_config { struct shdwc { const struct shdwc_config *cfg; + struct clk *sclk; void __iomem *at91_shdwc_base; void __iomem *mpddrc_base; void __iomem *pmc_base; @@ -80,7 +81,6 @@ struct shdwc { * since pm_power_off itself is global. */ static struct shdwc *at91_shdwc; -static struct clk *sclk; static const unsigned long long sdwc_dbc_period[] = { 0, 3, 32, 512, 4096, 32768, @@ -271,11 +271,11 @@ static int __init at91_shdwc_probe(struct platform_device *pdev) match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node); at91_shdwc->cfg = match->data; - sclk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(sclk)) - return PTR_ERR(sclk); + at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(at91_shdwc->sclk)) + return PTR_ERR(at91_shdwc->sclk); - ret = clk_prepare_enable(sclk); + ret = clk_prepare_enable(at91_shdwc->sclk); if (ret) { dev_err(&pdev->dev, "Could not enable slow clock\n"); return ret; @@ -328,7 +328,7 @@ static int __init at91_shdwc_probe(struct platform_device *pdev) unmap: iounmap(at91_shdwc->pmc_base); clk_disable: - clk_disable_unprepare(sclk); + clk_disable_unprepare(at91_shdwc->sclk); return ret; } @@ -348,7 +348,7 @@ static int __exit at91_shdwc_remove(struct platform_device *pdev) iounmap(shdw->mpddrc_base); iounmap(shdw->pmc_base); - clk_disable_unprepare(sclk); + clk_disable_unprepare(shdw->sclk); return 0; } -- cgit v1.2.3 From d12f84906bcb9384d0bf58726688fb60aac8a100 Mon Sep 17 00:00:00 2001 From: Claudiu Beznea Date: Thu, 30 Aug 2018 14:50:10 +0300 Subject: power: reset: at91-poweroff: rename at91_shdwc_base member of struct shdwc Rename at91_shdwc_base member of struct shdwc to shdwc_base. There is already an "at91" string in at91_shdwc object. Signed-off-by: Claudiu Beznea Acked-by: Nicolas Ferre Signed-off-by: Sebastian Reichel --- drivers/power/reset/at91-sama5d2_shdwc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c index 945b41b4086a..ad6e2796690a 100644 --- a/drivers/power/reset/at91-sama5d2_shdwc.c +++ b/drivers/power/reset/at91-sama5d2_shdwc.c @@ -71,7 +71,7 @@ struct shdwc_config { struct shdwc { const struct shdwc_config *cfg; struct clk *sclk; - void __iomem *at91_shdwc_base; + void __iomem *shdwc_base; void __iomem *mpddrc_base; void __iomem *pmc_base; }; @@ -92,7 +92,7 @@ static void __init at91_wakeup_status(struct platform_device *pdev) u32 reg; char *reason = "unknown"; - reg = readl(shdw->at91_shdwc_base + AT91_SHDW_SR); + reg = readl(shdw->shdwc_base + AT91_SHDW_SR); dev_dbg(&pdev->dev, "%s: status = %#x\n", __func__, reg); @@ -138,7 +138,7 @@ static void at91_poweroff(void) : : "r" (at91_shdwc->mpddrc_base), "r" cpu_to_le32(AT91_DDRSDRC_LPDDR2_PWOFF), - "r" (at91_shdwc->at91_shdwc_base), + "r" (at91_shdwc->shdwc_base), "r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW), "r" (at91_shdwc->pmc_base) : "r6"); @@ -222,10 +222,10 @@ static void at91_shdwc_dt_configure(struct platform_device *pdev) mode |= SHDW_RTCWKEN(shdw->cfg); dev_dbg(&pdev->dev, "%s: mode = %#x\n", __func__, mode); - writel(mode, shdw->at91_shdwc_base + AT91_SHDW_MR); + writel(mode, shdw->shdwc_base + AT91_SHDW_MR); input = at91_shdwc_get_wakeup_input(pdev, np); - writel(input, shdw->at91_shdwc_base + AT91_SHDW_WUIR); + writel(input, shdw->shdwc_base + AT91_SHDW_WUIR); } static const struct shdwc_config sama5d2_shdwc_config = { @@ -262,10 +262,10 @@ static int __init at91_shdwc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, at91_shdwc); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - at91_shdwc->at91_shdwc_base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(at91_shdwc->at91_shdwc_base)) { + at91_shdwc->shdwc_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(at91_shdwc->shdwc_base)) { dev_err(&pdev->dev, "Could not map reset controller address\n"); - return PTR_ERR(at91_shdwc->at91_shdwc_base); + return PTR_ERR(at91_shdwc->shdwc_base); } match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node); @@ -341,8 +341,8 @@ static int __exit at91_shdwc_remove(struct platform_device *pdev) pm_power_off = NULL; /* Reset values to disable wake-up features */ - writel(0, shdw->at91_shdwc_base + AT91_SHDW_MR); - writel(0, shdw->at91_shdwc_base + AT91_SHDW_WUIR); + writel(0, shdw->shdwc_base + AT91_SHDW_MR); + writel(0, shdw->shdwc_base + AT91_SHDW_WUIR); if (shdw->mpddrc_base) iounmap(shdw->mpddrc_base); -- cgit v1.2.3 From 9f1e44774be578fb92776add95f1fcaf8284d692 Mon Sep 17 00:00:00 2001 From: Claudiu Beznea Date: Thu, 30 Aug 2018 14:50:11 +0300 Subject: power: reset: at91-poweroff: do not procede if at91_shdwc is allocated There should be only one instance of struct shdwc in the system. This is referenced through at91_shdwc. Return in probe if at91_shdwc is already allocated. Signed-off-by: Claudiu Beznea Acked-by: Nicolas Ferre Signed-off-by: Sebastian Reichel --- drivers/power/reset/at91-sama5d2_shdwc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c index ad6e2796690a..2b686c55b717 100644 --- a/drivers/power/reset/at91-sama5d2_shdwc.c +++ b/drivers/power/reset/at91-sama5d2_shdwc.c @@ -255,6 +255,9 @@ static int __init at91_shdwc_probe(struct platform_device *pdev) if (!pdev->dev.of_node) return -ENODEV; + if (at91_shdwc) + return -EBUSY; + at91_shdwc = devm_kzalloc(&pdev->dev, sizeof(*at91_shdwc), GFP_KERNEL); if (!at91_shdwc) return -ENOMEM; -- cgit v1.2.3 From 36f47383c7f9fa0fdc20a92635435ff77ff71a6f Mon Sep 17 00:00:00 2001 From: Fabien Parent Date: Fri, 10 Aug 2018 15:13:47 +0200 Subject: mfd: cros: add charger port count command definition A new more command has been added to the ChromeOS embedded controller that allows to get the number of charger port count. Unlike EC_CMD_USB_PD_PORTS, this new command also includes the dedicated port if present. This command will be used to expose the dedicated charger port in the ChromeOS charger driver. Signed-off-by: Fabien Parent Acked-for-MFD-by: Lee Jones Reviewed-by: Enric Balletbo i Serra Signed-off-by: Sebastian Reichel --- include/linux/mfd/cros_ec_commands.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index 6e1ab9bead28..20ee71f10865 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h @@ -3102,6 +3102,16 @@ struct ec_params_usb_pd_info_request { uint8_t port; } __packed; +/* + * This command will return the number of USB PD charge port + the number + * of dedicated port present. + * EC_CMD_USB_PD_PORTS does NOT include the dedicated ports + */ +#define EC_CMD_CHARGE_PORT_COUNT 0x0105 +struct ec_response_charge_port_count { + uint8_t port_count; +} __packed; + /* Read USB-PD Device discovery info */ #define EC_CMD_USB_PD_DISCOVERY 0x0113 struct ec_params_usb_pd_discovery_entry { -- cgit v1.2.3 From 3af15cfacd1eef7f223802d49a88cae23c509183 Mon Sep 17 00:00:00 2001 From: Fabien Parent Date: Fri, 10 Aug 2018 15:13:48 +0200 Subject: power: supply: cros: add support for dedicated port ChromeOS devices can have one optional dedicated port. The Dedicated port is unique and similar to the USB PD ports except that it doesn't support as many properties. The presence of a dedicated port is determined from whether the EC's charger port count is equal to 'number of USB PD port' + 1. The dedicated port ID is always the last valid port ID. This commit keeps compatibility with Embedded Controllers that do not support the new EC_CMD_CHARGE_PORT_COUNT command by setting the number of charger port to be equal to the number of USB PD port when this command fails. Signed-off-by: Fabien Parent Signed-off-by: Sebastian Reichel --- drivers/power/supply/cros_usbpd-charger.c | 115 ++++++++++++++++++++++++++---- 1 file changed, 101 insertions(+), 14 deletions(-) diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c index 688a16bacfbb..fe1502715e46 100644 --- a/drivers/power/supply/cros_usbpd-charger.c +++ b/drivers/power/supply/cros_usbpd-charger.c @@ -12,8 +12,12 @@ #include #include -#define CHARGER_DIR_NAME "CROS_USBPD_CHARGER%d" -#define CHARGER_DIR_NAME_LENGTH sizeof(CHARGER_DIR_NAME) +#define CHARGER_USBPD_DIR_NAME "CROS_USBPD_CHARGER%d" +#define CHARGER_DEDICATED_DIR_NAME "CROS_DEDICATED_CHARGER" +#define CHARGER_DIR_NAME_LENGTH (sizeof(CHARGER_USBPD_DIR_NAME) >= \ + sizeof(CHARGER_DEDICATED_DIR_NAME) ? \ + sizeof(CHARGER_USBPD_DIR_NAME) : \ + sizeof(CHARGER_DEDICATED_DIR_NAME)) #define CHARGER_CACHE_UPDATE_DELAY msecs_to_jiffies(500) #define CHARGER_MANUFACTURER_MODEL_LENGTH 32 @@ -42,6 +46,7 @@ struct charger_data { struct cros_ec_dev *ec_dev; struct cros_ec_device *ec_device; int num_charger_ports; + int num_usbpd_ports; int num_registered_psy; struct port_data *ports[EC_USB_PD_MAX_PORTS]; struct notifier_block notifier; @@ -58,6 +63,12 @@ static enum power_supply_property cros_usbpd_charger_props[] = { POWER_SUPPLY_PROP_USB_TYPE }; +static enum power_supply_property cros_usbpd_dedicated_charger_props[] = { + POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_VOLTAGE_NOW, +}; + static enum power_supply_usb_type cros_usbpd_charger_usb_types[] = { POWER_SUPPLY_USB_TYPE_UNKNOWN, POWER_SUPPLY_USB_TYPE_SDP, @@ -69,6 +80,11 @@ static enum power_supply_usb_type cros_usbpd_charger_usb_types[] = { POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID }; +static bool cros_usbpd_charger_port_is_dedicated(struct port_data *port) +{ + return port->port_number >= port->charger->num_usbpd_ports; +} + static int cros_usbpd_charger_ec_command(struct charger_data *charger, unsigned int version, unsigned int command, @@ -102,6 +118,23 @@ static int cros_usbpd_charger_ec_command(struct charger_data *charger, } static int cros_usbpd_charger_get_num_ports(struct charger_data *charger) +{ + struct ec_response_charge_port_count resp; + int ret; + + ret = cros_usbpd_charger_ec_command(charger, 0, + EC_CMD_CHARGE_PORT_COUNT, + NULL, 0, &resp, sizeof(resp)); + if (ret < 0) { + dev_err(charger->dev, + "Unable to get the number of ports (err:0x%x)\n", ret); + return ret; + } + + return resp.port_count; +} + +static int cros_usbpd_charger_get_usbpd_num_ports(struct charger_data *charger) { struct ec_response_usb_pd_ports resp; int ret; @@ -246,7 +279,10 @@ static int cros_usbpd_charger_get_power_info(struct port_data *port) port->psy_usb_type = POWER_SUPPLY_USB_TYPE_SDP; } - port->psy_desc.type = POWER_SUPPLY_TYPE_USB; + if (cros_usbpd_charger_port_is_dedicated(port)) + port->psy_desc.type = POWER_SUPPLY_TYPE_MAINS; + else + port->psy_desc.type = POWER_SUPPLY_TYPE_USB; dev_dbg(dev, "Port %d: type=%d vmax=%d vnow=%d cmax=%d clim=%d pmax=%d\n", @@ -281,7 +317,8 @@ static int cros_usbpd_charger_get_port_status(struct port_data *port, if (ret < 0) return ret; - ret = cros_usbpd_charger_get_discovery_info(port); + if (!cros_usbpd_charger_port_is_dedicated(port)) + ret = cros_usbpd_charger_get_discovery_info(port); port->last_update = jiffies; return ret; @@ -426,17 +463,56 @@ static int cros_usbpd_charger_probe(struct platform_device *pd) platform_set_drvdata(pd, charger); + /* + * We need to know the number of USB PD ports in order to know whether + * there is a dedicated port. The dedicated port will always be + * after the USB PD ports, and there should be only one. + */ + charger->num_usbpd_ports = + cros_usbpd_charger_get_usbpd_num_ports(charger); + if (charger->num_usbpd_ports <= 0) { + /* + * This can happen on a system that doesn't support USB PD. + * Log a message, but no need to warn. + */ + dev_info(dev, "No USB PD charging ports found\n"); + } + charger->num_charger_ports = cros_usbpd_charger_get_num_ports(charger); - if (charger->num_charger_ports <= 0) { + if (charger->num_charger_ports < 0) { /* * This can happen on a system that doesn't support USB PD. * Log a message, but no need to warn. + * Older ECs do not support the above command, in that case + * let's set up the number of charger ports equal to the number + * of USB PD ports + */ + dev_info(dev, "Could not get charger port count\n"); + charger->num_charger_ports = charger->num_usbpd_ports; + } + + if (charger->num_charger_ports <= 0) { + /* + * This can happen on a system that doesn't support USB PD and + * doesn't have a dedicated port. + * Log a message, but no need to warn. */ dev_info(dev, "No charging ports found\n"); ret = -ENODEV; goto fail_nowarn; } + /* + * Sanity checks on the number of ports: + * there should be at most 1 dedicated port + */ + if (charger->num_charger_ports < charger->num_usbpd_ports || + charger->num_charger_ports > (charger->num_usbpd_ports + 1)) { + dev_err(dev, "Unexpected number of charge port count\n"); + ret = -EPROTO; + goto fail_nowarn; + } + for (i = 0; i < charger->num_charger_ports; i++) { struct power_supply_config psy_cfg = {}; @@ -448,22 +524,33 @@ static int cros_usbpd_charger_probe(struct platform_device *pd) port->charger = charger; port->port_number = i; - sprintf(port->name, CHARGER_DIR_NAME, i); psy_desc = &port->psy_desc; - psy_desc->name = port->name; - psy_desc->type = POWER_SUPPLY_TYPE_USB; psy_desc->get_property = cros_usbpd_charger_get_prop; psy_desc->external_power_changed = cros_usbpd_charger_power_changed; - psy_desc->properties = cros_usbpd_charger_props; - psy_desc->num_properties = - ARRAY_SIZE(cros_usbpd_charger_props); - psy_desc->usb_types = cros_usbpd_charger_usb_types; - psy_desc->num_usb_types = - ARRAY_SIZE(cros_usbpd_charger_usb_types); psy_cfg.drv_data = port; + if (cros_usbpd_charger_port_is_dedicated(port)) { + sprintf(port->name, CHARGER_DEDICATED_DIR_NAME); + psy_desc->type = POWER_SUPPLY_TYPE_MAINS; + psy_desc->properties = + cros_usbpd_dedicated_charger_props; + psy_desc->num_properties = + ARRAY_SIZE(cros_usbpd_dedicated_charger_props); + } else { + sprintf(port->name, CHARGER_USBPD_DIR_NAME, i); + psy_desc->type = POWER_SUPPLY_TYPE_USB; + psy_desc->properties = cros_usbpd_charger_props; + psy_desc->num_properties = + ARRAY_SIZE(cros_usbpd_charger_props); + psy_desc->usb_types = cros_usbpd_charger_usb_types; + psy_desc->num_usb_types = + ARRAY_SIZE(cros_usbpd_charger_usb_types); + } + + psy_desc->name = port->name; + psy = devm_power_supply_register_no_ws(dev, psy_desc, &psy_cfg); if (IS_ERR(psy)) { -- cgit v1.2.3 From cb90a2c6f77fe9b43d1e3f759bb2f13fe7fa1811 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Tue, 17 Jul 2018 18:05:07 +0200 Subject: power: supply: max8998-charger: Fix platform data retrieval MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the max8998 MFD driver supports instantiation by DT, platform data retrieval is handled in MFD probe and cell drivers should get use the pdata field of max8998_dev struct to obtain them. Fixes: ee999fb3f17f ("mfd: max8998: Add support for Device Tree") Signed-off-by: Tomasz Figa Signed-off-by: PaweÅ‚ Chmiel Signed-off-by: Sebastian Reichel --- drivers/power/supply/max8998_charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/power/supply/max8998_charger.c b/drivers/power/supply/max8998_charger.c index 95292381c3de..9a926c7c0f22 100644 --- a/drivers/power/supply/max8998_charger.c +++ b/drivers/power/supply/max8998_charger.c @@ -72,7 +72,7 @@ static const struct power_supply_desc max8998_battery_desc = { static int max8998_battery_probe(struct platform_device *pdev) { struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct max8998_platform_data *pdata = dev_get_platdata(iodev->dev); + struct max8998_platform_data *pdata = iodev->pdata; struct power_supply_config psy_cfg = {}; struct max8998_battery_data *max8998; struct i2c_client *i2c; -- cgit v1.2.3 From ad1570d99f280f73c72510d7f79db9adf599474b Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Mon, 17 Sep 2018 10:23:20 +0800 Subject: power: supply: bq25890_charger: fix semicolon.cocci warnings drivers/power/supply/bq25890_charger.c:614:2-3: Unneeded semicolon drivers/power/supply/bq25890_charger.c:621:2-3: Unneeded semicolon drivers/power/supply/bq25890_charger.c:630:3-4: Unneeded semicolon drivers/power/supply/bq25890_charger.c:638:2-3: Unneeded semicolon drivers/power/supply/bq25890_charger.c:644:2-3: Unneeded semicolon Remove unneeded semicolon. Generated by: scripts/coccinelle/misc/semicolon.cocci Fixes: 9d9ae3414d1b ("power: supply: bq25890_charger: Add debugging output of failed initialization") CC: Angus Ainslie (Purism) Signed-off-by: kbuild test robot Signed-off-by: Sebastian Reichel --- drivers/power/supply/bq25890_charger.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c index 1aa7872ddeb0..70b90db5ae38 100644 --- a/drivers/power/supply/bq25890_charger.c +++ b/drivers/power/supply/bq25890_charger.c @@ -628,14 +628,14 @@ static int bq25890_hw_init(struct bq25890_device *bq) 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) { 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++) { @@ -644,7 +644,7 @@ static int bq25890_hw_init(struct bq25890_device *bq) 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. */ @@ -652,13 +652,13 @@ static int bq25890_hw_init(struct bq25890_device *bq) 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) { dev_dbg(bq->dev, "Get state failed %d\n", ret); return ret; - }; + } mutex_lock(&bq->lock); bq->state = state; -- cgit v1.2.3 From 8314c212f995bc0d06b54ad02ef0ab4089781540 Mon Sep 17 00:00:00 2001 From: Andreas Kemnade Date: Mon, 17 Sep 2018 07:20:35 +0200 Subject: power: supply: twl4030_charger: fix charging current out-of-bounds the charging current uses unsigned int variables, if we step back if the current is still low, we would run into negative which means setting the target to a huge value. Better add checks here. Signed-off-by: Andreas Kemnade Signed-off-by: Sebastian Reichel --- drivers/power/supply/twl4030_charger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index bbcaee56db9d..c629c1642531 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -420,7 +420,8 @@ static void twl4030_current_worker(struct work_struct *data) if (v < USB_MIN_VOLT) { /* Back up and stop adjusting. */ - bci->usb_cur -= USB_CUR_STEP; + if (bci->usb_cur >= USB_CUR_STEP) + bci->usb_cur -= USB_CUR_STEP; bci->usb_cur_target = bci->usb_cur; } else if (bci->usb_cur >= bci->usb_cur_target || bci->usb_cur + USB_CUR_STEP > USB_MAX_CURRENT) { -- cgit v1.2.3 From 079cdff3d0a09c5da10ae1be35def7a116776328 Mon Sep 17 00:00:00 2001 From: Andreas Kemnade Date: Mon, 17 Sep 2018 07:00:07 +0200 Subject: power: supply: twl4030_charger: disable eoc interrupt on linear charge This avoids getting woken up from suspend after power interruptions when the bci wrongly thinks the battery is full just because of input current going low because of low input power Signed-off-by: Andreas Kemnade Signed-off-by: Sebastian Reichel --- drivers/power/supply/twl4030_charger.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c index c629c1642531..80582c8f98fa 100644 --- a/drivers/power/supply/twl4030_charger.c +++ b/drivers/power/supply/twl4030_charger.c @@ -440,6 +440,7 @@ static void twl4030_current_worker(struct work_struct *data) static int twl4030_charger_enable_usb(struct twl4030_bci *bci, bool enable) { int ret; + u32 reg; if (bci->usb_mode == CHARGE_OFF) enable = false; @@ -453,14 +454,38 @@ static int twl4030_charger_enable_usb(struct twl4030_bci *bci, bool enable) bci->usb_enabled = 1; } - if (bci->usb_mode == CHARGE_AUTO) + if (bci->usb_mode == CHARGE_AUTO) { + /* Enable interrupts now. */ + reg = ~(u32)(TWL4030_ICHGLOW | TWL4030_ICHGEOC | + TWL4030_TBATOR2 | TWL4030_TBATOR1 | + TWL4030_BATSTS); + ret = twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, reg, + TWL4030_INTERRUPTS_BCIIMR1A); + if (ret < 0) { + dev_err(bci->dev, + "failed to unmask interrupts: %d\n", + ret); + return ret; + } /* forcing the field BCIAUTOUSB (BOOT_BCI[1]) to 1 */ ret = twl4030_clear_set_boot_bci(0, TWL4030_BCIAUTOUSB); + } /* forcing USBFASTMCHG(BCIMFSTS4[2]) to 1 */ ret = twl4030_clear_set(TWL_MODULE_MAIN_CHARGE, 0, TWL4030_USBFASTMCHG, TWL4030_BCIMFSTS4); if (bci->usb_mode == CHARGE_LINEAR) { + /* Enable interrupts now. */ + reg = ~(u32)(TWL4030_ICHGLOW | TWL4030_TBATOR2 | + TWL4030_TBATOR1 | TWL4030_BATSTS); + ret = twl_i2c_write_u8(TWL4030_MODULE_INTERRUPTS, reg, + TWL4030_INTERRUPTS_BCIIMR1A); + if (ret < 0) { + dev_err(bci->dev, + "failed to unmask interrupts: %d\n", + ret); + return ret; + } twl4030_clear_set_boot_bci(TWL4030_BCIAUTOAC|TWL4030_CVENAC, 0); /* Watch dog key: WOVF acknowledge */ ret = twl_i2c_write_u8(TWL_MODULE_MAIN_CHARGE, 0x33, -- cgit v1.2.3 From 8d1f326ab8edbb15cb90ffe43fc9a0d7add97291 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Mon, 17 Sep 2018 13:03:30 -0700 Subject: dt-bindings: power: Add Spreadtrum SC2731 charger documentation This patch adds the binding documentation for Spreadtrum SC2731 charger device. Signed-off-by: Baolin Wang Reviewed-by: Krzysztof Kozlowski Signed-off-by: Sebastian Reichel --- .../bindings/power/supply/sc2731_charger.txt | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/sc2731_charger.txt diff --git a/Documentation/devicetree/bindings/power/supply/sc2731_charger.txt b/Documentation/devicetree/bindings/power/supply/sc2731_charger.txt new file mode 100644 index 000000000000..5266fab16575 --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/sc2731_charger.txt @@ -0,0 +1,40 @@ +Spreadtrum SC2731 PMIC battery charger binding + +Required properties: + - compatible: Should be "sprd,sc2731-charger". + - reg: Address offset of charger register. + - phys: Contains a phandle to the USB phy. + +Optional Properties: +- monitored-battery: phandle of battery characteristics devicetree node. + The charger uses the following battery properties: +- charge-term-current-microamp: current for charge termination phase. +- constant-charge-voltage-max-microvolt: maximum constant input voltage. + See Documentation/devicetree/bindings/power/supply/battery.txt + +Example: + + bat: battery { + compatible = "simple-battery"; + charge-term-current-microamp = <120000>; + constant-charge-voltage-max-microvolt = <4350000>; + ...... + }; + + sc2731_pmic: pmic@0 { + compatible = "sprd,sc2731"; + reg = <0>; + spi-max-frequency = <26000000>; + interrupts = ; + interrupt-controller; + #interrupt-cells = <2>; + #address-cells = <1>; + #size-cells = <0>; + + charger@0 { + compatible = "sprd,sc2731-charger"; + reg = <0x0>; + phys = <&ssphy>; + monitored-battery = <&bat>; + }; + }; -- cgit v1.2.3 From 1c3d7b0364f0730a8a64801dd07a589bbac06671 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Mon, 17 Sep 2018 13:03:31 -0700 Subject: power: supply: Add Spreadtrum SC2731 charger support This patch adds the SC2731 PMIC switch charger support. Signed-off-by: Baolin Wang Reviewed-by: Krzysztof Kozlowski Signed-off-by: Sebastian Reichel --- drivers/power/supply/Kconfig | 7 + drivers/power/supply/Makefile | 1 + drivers/power/supply/sc2731_charger.c | 504 ++++++++++++++++++++++++++++++++++ 3 files changed, 512 insertions(+) create mode 100644 drivers/power/supply/sc2731_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index ff6dab0bf0dd..f27cf0709500 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -645,4 +645,11 @@ config CHARGER_CROS_USBPD what is connected to USB PD ports from the EC and converts that into power_supply properties. +config CHARGER_SC2731 + tristate "Spreadtrum SC2731 charger driver" + depends on MFD_SC27XX_PMIC || COMPILE_TEST + help + Say Y here to enable support for battery charging with SC2731 + PMIC chips. + endif # POWER_SUPPLY diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index a26b402c45d9..767105b88d00 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -85,3 +85,4 @@ obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o obj-$(CONFIG_CHARGER_CROS_USBPD) += cros_usbpd-charger.o +obj-$(CONFIG_CHARGER_SC2731) += sc2731_charger.o diff --git a/drivers/power/supply/sc2731_charger.c b/drivers/power/supply/sc2731_charger.c new file mode 100644 index 000000000000..525a820537bf --- /dev/null +++ b/drivers/power/supply/sc2731_charger.c @@ -0,0 +1,504 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (C) 2018 Spreadtrum Communications Inc. + +#include +#include +#include +#include +#include +#include +#include + +/* PMIC global registers definition */ +#define SC2731_CHARGE_STATUS 0xedc +#define SC2731_CHARGE_FULL BIT(4) +#define SC2731_MODULE_EN1 0xc0c +#define SC2731_CHARGE_EN BIT(5) + +/* SC2731 switch charger registers definition */ +#define SC2731_CHG_CFG0 0x0 +#define SC2731_CHG_CFG1 0x4 +#define SC2731_CHG_CFG2 0x8 +#define SC2731_CHG_CFG3 0xc +#define SC2731_CHG_CFG4 0x10 +#define SC2731_CHG_CFG5 0x28 + +/* SC2731_CHG_CFG0 register definition */ +#define SC2731_PRECHG_RNG_SHIFT 11 +#define SC2731_PRECHG_RNG_MASK GENMASK(12, 11) + +#define SC2731_TERMINATION_VOL_MASK GENMASK(2, 1) +#define SC2731_TERMINATION_VOL_SHIFT 1 +#define SC2731_TERMINATION_VOL_CAL_MASK GENMASK(8, 3) +#define SC2731_TERMINATION_VOL_CAL_SHIFT 3 +#define SC2731_TERMINATION_CUR_MASK GENMASK(2, 0) + +#define SC2731_CC_EN BIT(13) +#define SC2731_CHARGER_PD BIT(0) + +/* SC2731_CHG_CFG1 register definition */ +#define SC2731_CUR_MASK GENMASK(5, 0) + +/* SC2731_CHG_CFG5 register definition */ +#define SC2731_CUR_LIMIT_SHIFT 8 +#define SC2731_CUR_LIMIT_MASK GENMASK(9, 8) + +/* Default current definition (unit is mA) */ +#define SC2731_CURRENT_LIMIT_100 100 +#define SC2731_CURRENT_LIMIT_500 500 +#define SC2731_CURRENT_LIMIT_900 900 +#define SC2731_CURRENT_LIMIT_2000 2000 +#define SC2731_CURRENT_PRECHG 450 +#define SC2731_CURRENT_STEP 50 + +struct sc2731_charger_info { + struct device *dev; + struct regmap *regmap; + struct usb_phy *usb_phy; + struct notifier_block usb_notify; + struct power_supply *psy_usb; + struct mutex lock; + bool charging; + u32 base; +}; + +static void sc2731_charger_stop_charge(struct sc2731_charger_info *info) +{ + regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, + SC2731_CC_EN, 0); + + regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, + SC2731_CHARGER_PD, SC2731_CHARGER_PD); +} + +static int sc2731_charger_start_charge(struct sc2731_charger_info *info) +{ + int ret; + + /* Enable charger constant current mode */ + ret = regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, + SC2731_CC_EN, SC2731_CC_EN); + if (ret) + return ret; + + /* Start charging */ + return regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, + SC2731_CHARGER_PD, 0); +} + +static int sc2731_charger_set_current_limit(struct sc2731_charger_info *info, + u32 limit) +{ + u32 val; + + if (limit <= SC2731_CURRENT_LIMIT_100) + val = 0; + else if (limit <= SC2731_CURRENT_LIMIT_500) + val = 3; + else if (limit <= SC2731_CURRENT_LIMIT_900) + val = 2; + else + val = 1; + + return regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG5, + SC2731_CUR_LIMIT_MASK, + val << SC2731_CUR_LIMIT_SHIFT); +} + +static int sc2731_charger_set_current(struct sc2731_charger_info *info, u32 cur) +{ + u32 val; + int ret; + + if (cur > SC2731_CURRENT_LIMIT_2000) + cur = SC2731_CURRENT_LIMIT_2000; + else if (cur < SC2731_CURRENT_PRECHG) + cur = SC2731_CURRENT_PRECHG; + + /* Calculate the step value, each step is 50 mA */ + val = (cur - SC2731_CURRENT_PRECHG) / SC2731_CURRENT_STEP; + + /* Set pre-charge current as 450 mA */ + ret = regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, + SC2731_PRECHG_RNG_MASK, + 0x3 << SC2731_PRECHG_RNG_SHIFT); + if (ret) + return ret; + + return regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG1, + SC2731_CUR_MASK, val); +} + +static int sc2731_charger_get_status(struct sc2731_charger_info *info) +{ + u32 val; + int ret; + + ret = regmap_read(info->regmap, SC2731_CHARGE_STATUS, &val); + if (ret) + return ret; + + if (val & SC2731_CHARGE_FULL) + return POWER_SUPPLY_STATUS_FULL; + + return POWER_SUPPLY_STATUS_CHARGING; +} + +static int sc2731_charger_get_current(struct sc2731_charger_info *info, + u32 *cur) +{ + int ret; + u32 val; + + ret = regmap_read(info->regmap, info->base + SC2731_CHG_CFG1, &val); + if (ret) + return ret; + + val &= SC2731_CUR_MASK; + *cur = val * SC2731_CURRENT_STEP + SC2731_CURRENT_PRECHG; + + return 0; +} + +static int sc2731_charger_get_current_limit(struct sc2731_charger_info *info, + u32 *cur) +{ + int ret; + u32 val; + + ret = regmap_read(info->regmap, info->base + SC2731_CHG_CFG5, &val); + if (ret) + return ret; + + val = (val & SC2731_CUR_LIMIT_MASK) >> SC2731_CUR_LIMIT_SHIFT; + + switch (val) { + case 0: + *cur = SC2731_CURRENT_LIMIT_100; + break; + + case 1: + *cur = SC2731_CURRENT_LIMIT_2000; + break; + + case 2: + *cur = SC2731_CURRENT_LIMIT_900; + break; + + case 3: + *cur = SC2731_CURRENT_LIMIT_500; + break; + + default: + return -EINVAL; + } + + return 0; +} + +static int +sc2731_charger_usb_set_property(struct power_supply *psy, + enum power_supply_property psp, + const union power_supply_propval *val) +{ + struct sc2731_charger_info *info = power_supply_get_drvdata(psy); + int ret; + + mutex_lock(&info->lock); + + if (!info->charging) { + mutex_unlock(&info->lock); + return -ENODEV; + } + + switch (psp) { + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + ret = sc2731_charger_set_current(info, val->intval / 1000); + if (ret < 0) + dev_err(info->dev, "set charge current failed\n"); + break; + + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + ret = sc2731_charger_set_current_limit(info, + val->intval / 1000); + if (ret < 0) + dev_err(info->dev, "set input current limit failed\n"); + break; + + default: + ret = -EINVAL; + } + + mutex_unlock(&info->lock); + return ret; +} + +static int sc2731_charger_usb_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct sc2731_charger_info *info = power_supply_get_drvdata(psy); + int ret = 0; + u32 cur; + + mutex_lock(&info->lock); + + switch (psp) { + case POWER_SUPPLY_PROP_STATUS: + if (info->charging) + val->intval = sc2731_charger_get_status(info); + else + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; + break; + + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + if (!info->charging) { + val->intval = 0; + } else { + ret = sc2731_charger_get_current(info, &cur); + if (ret) + goto out; + + val->intval = cur * 1000; + } + break; + + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + if (!info->charging) { + val->intval = 0; + } else { + ret = sc2731_charger_get_current_limit(info, &cur); + if (ret) + goto out; + + val->intval = cur * 1000; + } + break; + + default: + ret = -EINVAL; + } + +out: + mutex_unlock(&info->lock); + return ret; +} + +static int sc2731_charger_property_is_writeable(struct power_supply *psy, + enum power_supply_property psp) +{ + int ret; + + switch (psp) { + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT: + case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT: + ret = 1; + break; + + default: + ret = 0; + } + + return ret; +} + +static enum power_supply_property sc2731_usb_props[] = { + POWER_SUPPLY_PROP_STATUS, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT, + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, +}; + +static const struct power_supply_desc sc2731_charger_desc = { + .name = "sc2731_charger", + .type = POWER_SUPPLY_TYPE_USB, + .properties = sc2731_usb_props, + .num_properties = ARRAY_SIZE(sc2731_usb_props), + .get_property = sc2731_charger_usb_get_property, + .set_property = sc2731_charger_usb_set_property, + .property_is_writeable = sc2731_charger_property_is_writeable, +}; + +static int sc2731_charger_usb_change(struct notifier_block *nb, + unsigned long limit, void *data) +{ + struct sc2731_charger_info *info = + container_of(nb, struct sc2731_charger_info, usb_notify); + int ret = 0; + + mutex_lock(&info->lock); + + if (limit > 0) { + /* set current limitation and start to charge */ + ret = sc2731_charger_set_current_limit(info, limit); + if (ret) + goto out; + + ret = sc2731_charger_set_current(info, limit); + if (ret) + goto out; + + ret = sc2731_charger_start_charge(info); + if (ret) + goto out; + + info->charging = true; + } else { + /* Stop charging */ + info->charging = false; + sc2731_charger_stop_charge(info); + } + +out: + mutex_unlock(&info->lock); + return ret; +} + +static int sc2731_charger_hw_init(struct sc2731_charger_info *info) +{ + struct power_supply_battery_info bat_info = { }; + u32 term_currrent, term_voltage, cur_val, vol_val; + int ret; + + /* Enable charger module */ + ret = regmap_update_bits(info->regmap, SC2731_MODULE_EN1, + SC2731_CHARGE_EN, SC2731_CHARGE_EN); + if (ret) + return ret; + + ret = power_supply_get_battery_info(info->psy_usb, &bat_info); + if (ret) { + dev_warn(info->dev, "no battery information is supplied\n"); + + /* + * If no battery information is supplied, we should set + * default charge termination current to 120 mA, and default + * charge termination voltage to 4.35V. + */ + cur_val = 0x2; + vol_val = 0x1; + } else { + term_currrent = bat_info.charge_term_current_ua / 1000; + + if (term_currrent <= 90) + cur_val = 0; + else if (term_currrent >= 265) + cur_val = 0x7; + else + cur_val = ((term_currrent - 90) / 25) + 1; + + term_voltage = bat_info.constant_charge_voltage_max_uv / 1000; + + if (term_voltage > 4500) + term_voltage = 4500; + + if (term_voltage > 4200) + vol_val = (term_voltage - 4200) / 100; + else + vol_val = 0; + } + + /* Set charge termination current */ + ret = regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG2, + SC2731_TERMINATION_CUR_MASK, cur_val); + if (ret) + goto error; + + /* Set charge termination voltage */ + ret = regmap_update_bits(info->regmap, info->base + SC2731_CHG_CFG0, + SC2731_TERMINATION_VOL_MASK | + SC2731_TERMINATION_VOL_CAL_MASK, + (vol_val << SC2731_TERMINATION_VOL_SHIFT) | + (0x6 << SC2731_TERMINATION_VOL_CAL_SHIFT)); + if (ret) + goto error; + + return 0; + +error: + regmap_update_bits(info->regmap, SC2731_MODULE_EN1, SC2731_CHARGE_EN, 0); + return ret; +} + +static int sc2731_charger_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct sc2731_charger_info *info; + struct power_supply_config charger_cfg = { }; + int ret; + + info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + mutex_init(&info->lock); + info->dev = &pdev->dev; + + info->regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!info->regmap) { + dev_err(&pdev->dev, "failed to get charger regmap\n"); + return -ENODEV; + } + + ret = of_property_read_u32(np, "reg", &info->base); + if (ret) { + dev_err(&pdev->dev, "failed to get register address\n"); + return -ENODEV; + } + + charger_cfg.drv_data = info; + charger_cfg.of_node = np; + info->psy_usb = devm_power_supply_register(&pdev->dev, + &sc2731_charger_desc, + &charger_cfg); + if (IS_ERR(info->psy_usb)) { + dev_err(&pdev->dev, "failed to register power supply\n"); + return PTR_ERR(info->psy_usb); + } + + ret = sc2731_charger_hw_init(info); + if (ret) + return ret; + + info->usb_phy = devm_usb_get_phy_by_phandle(&pdev->dev, "phys", 0); + if (IS_ERR(info->usb_phy)) { + dev_err(&pdev->dev, "failed to find USB phy\n"); + return PTR_ERR(info->usb_phy); + } + + info->usb_notify.notifier_call = sc2731_charger_usb_change; + ret = usb_register_notifier(info->usb_phy, &info->usb_notify); + if (ret) { + dev_err(&pdev->dev, "failed to register notifier: %d\n", ret); + return ret; + } + + return 0; +} + +static int sc2731_charger_remove(struct platform_device *pdev) +{ + struct sc2731_charger_info *info = platform_get_drvdata(pdev); + + usb_unregister_notifier(info->usb_phy, &info->usb_notify); + + return 0; +} + +static const struct of_device_id sc2731_charger_of_match[] = { + { .compatible = "sprd,sc2731-charger", }, + { } +}; + +static struct platform_driver sc2731_charger_driver = { + .driver = { + .name = "sc2731-charger", + .of_match_table = sc2731_charger_of_match, + }, + .probe = sc2731_charger_probe, + .remove = sc2731_charger_remove, +}; + +module_platform_driver(sc2731_charger_driver); + +MODULE_DESCRIPTION("Spreadtrum SC2731 Charger Driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 457b42f0aa1c397745ada6083bf81b9479ab19fe Mon Sep 17 00:00:00 2001 From: Liu Xiang Date: Sun, 22 Jul 2018 21:33:56 +0800 Subject: power: supply: bq27xxx: Add support for BQ27411 According to the datasheet, bq27411 is similar to bq27421. Signed-off-by: Liu Xiang Reviewed-by: Andrew F. Davis Signed-off-by: Sebastian Reichel --- Documentation/devicetree/bindings/power/supply/bq27xxx.txt | 1 + drivers/power/supply/bq27xxx_battery.c | 9 +++++++++ drivers/power/supply/bq27xxx_battery_i2c.c | 2 ++ include/linux/power/bq27xxx_battery.h | 1 + 4 files changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/bq27xxx.txt b/Documentation/devicetree/bindings/power/supply/bq27xxx.txt index 37994fdb18ca..4fa8e08df2b6 100644 --- a/Documentation/devicetree/bindings/power/supply/bq27xxx.txt +++ b/Documentation/devicetree/bindings/power/supply/bq27xxx.txt @@ -23,6 +23,7 @@ Required properties: * "ti,bq27546" - BQ27546 * "ti,bq27742" - BQ27742 * "ti,bq27545" - BQ27545 + * "ti,bq27411" - BQ27411 * "ti,bq27421" - BQ27421 * "ti,bq27425" - BQ27425 * "ti,bq27426" - BQ27426 diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c index f022e1b550df..6dbbe95844a3 100644 --- a/drivers/power/supply/bq27xxx_battery.c +++ b/drivers/power/supply/bq27xxx_battery.c @@ -432,6 +432,7 @@ static u8 [BQ27XXX_REG_AP] = 0x18, BQ27XXX_DM_REG_ROWS, }; +#define bq27411_regs bq27421_regs #define bq27425_regs bq27421_regs #define bq27426_regs bq27421_regs #define bq27441_regs bq27421_regs @@ -665,6 +666,7 @@ static enum power_supply_property bq27421_props[] = { POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, POWER_SUPPLY_PROP_MANUFACTURER, }; +#define bq27411_props bq27421_props #define bq27425_props bq27421_props #define bq27426_props bq27421_props #define bq27441_props bq27421_props @@ -725,6 +727,12 @@ static struct bq27xxx_dm_reg bq27545_dm_regs[] = { #define bq27545_dm_regs 0 #endif +static struct bq27xxx_dm_reg bq27411_dm_regs[] = { + [BQ27XXX_DM_DESIGN_CAPACITY] = { 82, 10, 2, 0, 32767 }, + [BQ27XXX_DM_DESIGN_ENERGY] = { 82, 12, 2, 0, 32767 }, + [BQ27XXX_DM_TERMINATE_VOLTAGE] = { 82, 16, 2, 2800, 3700 }, +}; + static struct bq27xxx_dm_reg bq27421_dm_regs[] = { [BQ27XXX_DM_DESIGN_CAPACITY] = { 82, 10, 2, 0, 8000 }, [BQ27XXX_DM_DESIGN_ENERGY] = { 82, 12, 2, 0, 32767 }, @@ -802,6 +810,7 @@ static struct { [BQ27546] = BQ27XXX_DATA(bq27546, 0 , BQ27XXX_O_OTDC), [BQ27742] = BQ27XXX_DATA(bq27742, 0 , BQ27XXX_O_OTDC), [BQ27545] = BQ27XXX_DATA(bq27545, 0x04143672, BQ27XXX_O_OTDC), + [BQ27411] = BQ27XXX_DATA(bq27411, 0x80008000, BQ27XXX_O_UTOT | BQ27XXX_O_CFGUP | BQ27XXX_O_RAM), [BQ27421] = BQ27XXX_DATA(bq27421, 0x80008000, BQ27XXX_O_UTOT | BQ27XXX_O_CFGUP | BQ27XXX_O_RAM), [BQ27425] = BQ27XXX_DATA(bq27425, 0x04143672, BQ27XXX_O_UTOT | BQ27XXX_O_CFGUP), [BQ27426] = BQ27XXX_DATA(bq27426, 0x80008000, BQ27XXX_O_UTOT | BQ27XXX_O_CFGUP | BQ27XXX_O_RAM), diff --git a/drivers/power/supply/bq27xxx_battery_i2c.c b/drivers/power/supply/bq27xxx_battery_i2c.c index 40069128ad44..2677c38a8a42 100644 --- a/drivers/power/supply/bq27xxx_battery_i2c.c +++ b/drivers/power/supply/bq27xxx_battery_i2c.c @@ -247,6 +247,7 @@ static const struct i2c_device_id bq27xxx_i2c_id_table[] = { { "bq27546", BQ27546 }, { "bq27742", BQ27742 }, { "bq27545", BQ27545 }, + { "bq27411", BQ27411 }, { "bq27421", BQ27421 }, { "bq27425", BQ27425 }, { "bq27426", BQ27426 }, @@ -279,6 +280,7 @@ static const struct of_device_id bq27xxx_battery_i2c_of_match_table[] = { { .compatible = "ti,bq27546" }, { .compatible = "ti,bq27742" }, { .compatible = "ti,bq27545" }, + { .compatible = "ti,bq27411" }, { .compatible = "ti,bq27421" }, { .compatible = "ti,bq27425" }, { .compatible = "ti,bq27426" }, diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h index d6355f49fbae..507c5e214c42 100644 --- a/include/linux/power/bq27xxx_battery.h +++ b/include/linux/power/bq27xxx_battery.h @@ -24,6 +24,7 @@ enum bq27xxx_chip { BQ27546, BQ27742, BQ27545, /* bq27545 */ + BQ27411, BQ27421, /* bq27421, bq27441, bq27621 */ BQ27425, BQ27426, -- cgit v1.2.3 From a4ac1f5ced58b0782252d5a8b2dfe28a1d7a5e19 Mon Sep 17 00:00:00 2001 From: Vinod Koul Date: Wed, 19 Sep 2018 18:50:44 -0700 Subject: power: reset: qcom-pon: Add pms405 pon support Update the binding and driver for pms405 pon. Signed-off-by: Vinod Koul Signed-off-by: Bjorn Andersson Signed-off-by: Sebastian Reichel --- Documentation/devicetree/bindings/power/reset/qcom,pon.txt | 5 ++++- drivers/power/reset/qcom-pon.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/power/reset/qcom,pon.txt b/Documentation/devicetree/bindings/power/reset/qcom,pon.txt index 651491bb63b7..5705f575862d 100644 --- a/Documentation/devicetree/bindings/power/reset/qcom,pon.txt +++ b/Documentation/devicetree/bindings/power/reset/qcom,pon.txt @@ -6,7 +6,10 @@ and resin along with the Android reboot-mode. This DT node has pwrkey and resin as sub nodes. Required Properties: --compatible: "qcom,pm8916-pon" +-compatible: Must be one of: + "qcom,pm8916-pon" + "qcom,pms405-pon" + -reg: Specifies the physical address of the pon register Optional subnode: diff --git a/drivers/power/reset/qcom-pon.c b/drivers/power/reset/qcom-pon.c index 0c4caaa7e88f..3fa1642d4c54 100644 --- a/drivers/power/reset/qcom-pon.c +++ b/drivers/power/reset/qcom-pon.c @@ -74,6 +74,7 @@ static int pm8916_pon_probe(struct platform_device *pdev) static const struct of_device_id pm8916_pon_id_table[] = { { .compatible = "qcom,pm8916-pon" }, + { .compatible = "qcom,pms405-pon" }, { } }; MODULE_DEVICE_TABLE(of, pm8916_pon_id_table); -- cgit v1.2.3 From 415d602b226b3ed7b24edd8f0c2bfc111684d2b1 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 13 Oct 2018 16:27:27 +0100 Subject: power: supply: fix spelling mistake "Gauage" -> "Gauge" Trivial fix to spelling mistake in MODULE_DESCRIPTION text Signed-off-by: Colin Ian King Signed-off-by: Sebastian Reichel --- drivers/power/supply/ds2780_battery.c | 2 +- drivers/power/supply/ds2781_battery.c | 2 +- drivers/power/supply/ds2782_battery.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/ds2780_battery.c b/drivers/power/supply/ds2780_battery.c index 370e9109342b..cad14ba1b648 100644 --- a/drivers/power/supply/ds2780_battery.c +++ b/drivers/power/supply/ds2780_battery.c @@ -829,5 +829,5 @@ module_platform_driver(ds2780_battery_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Clifton Barnes "); -MODULE_DESCRIPTION("Maxim/Dallas DS2780 Stand-Alone Fuel Gauage IC driver"); +MODULE_DESCRIPTION("Maxim/Dallas DS2780 Stand-Alone Fuel Gauge IC driver"); MODULE_ALIAS("platform:ds2780-battery"); diff --git a/drivers/power/supply/ds2781_battery.c b/drivers/power/supply/ds2781_battery.c index d1b5a19aae7c..5e794607f732 100644 --- a/drivers/power/supply/ds2781_battery.c +++ b/drivers/power/supply/ds2781_battery.c @@ -829,6 +829,6 @@ module_platform_driver(ds2781_battery_driver); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Renata Sayakhova "); -MODULE_DESCRIPTION("Maxim/Dallas DS2781 Stand-Alone Fuel Gauage IC driver"); +MODULE_DESCRIPTION("Maxim/Dallas DS2781 Stand-Alone Fuel Gauge IC driver"); MODULE_ALIAS("platform:ds2781-battery"); diff --git a/drivers/power/supply/ds2782_battery.c b/drivers/power/supply/ds2782_battery.c index a1b7e0592245..019c58493e3d 100644 --- a/drivers/power/supply/ds2782_battery.c +++ b/drivers/power/supply/ds2782_battery.c @@ -471,5 +471,5 @@ static struct i2c_driver ds278x_battery_driver = { module_i2c_driver(ds278x_battery_driver); MODULE_AUTHOR("Ryan Mallon"); -MODULE_DESCRIPTION("Maxim/Dallas DS2782 Stand-Alone Fuel Gauage IC driver"); +MODULE_DESCRIPTION("Maxim/Dallas DS2782 Stand-Alone Fuel Gauge IC driver"); MODULE_LICENSE("GPL"); -- cgit v1.2.3 From cfb347979e71d3ce6be59a988b3357f541c9eacf Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Thu, 4 Oct 2018 15:56:36 +0200 Subject: power: max8925: mark expected switch fall-through In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Addresses-Coverity-ID: 201510 ("Missing break in switch") Signed-off-by: Gustavo A. R. Silva Signed-off-by: Sebastian Reichel --- drivers/power/supply/max8925_power.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/power/supply/max8925_power.c b/drivers/power/supply/max8925_power.c index 3b94620ce5c1..39b4d5b6ac39 100644 --- a/drivers/power/supply/max8925_power.c +++ b/drivers/power/supply/max8925_power.c @@ -124,6 +124,7 @@ static irqreturn_t max8925_charger_handler(int irq, void *data) case MAX8925_IRQ_VCHG_THM_OK_F: /* Battery is not ready yet */ dev_dbg(chip->dev, "Battery temperature is out of range\n"); + /* Fall through */ case MAX8925_IRQ_VCHG_DC_OVP: dev_dbg(chip->dev, "Error detection\n"); __set_charger(info, 0); -- cgit v1.2.3