linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv1 00/19] Improve SBS battery support
@ 2020-05-13 18:55 Sebastian Reichel
  2020-05-13 18:55 ` [PATCHv1 01/19] kobject: increase allowed number of uevent variables Sebastian Reichel
                   ` (21 more replies)
  0 siblings, 22 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:55 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

This patchset improves support for SBS compliant batteries. Due to
the changes, the battery now exposes 32 power supply properties and
(un)plugging it generates a backtrace containing the following message
without the first patch in this series:

---------------------------
WARNING: CPU: 0 PID: 20 at lib/kobject_uevent.c:659 add_uevent_var+0xd4/0x104
add_uevent_var: too many keys
---------------------------

For references this is what an SBS battery status looks like after
the patch series has been applied:

cat /sys/class/power_supply/sbs-0-000b/uevent 
POWER_SUPPLY_NAME=sbs-0-000b
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_HEALTH=Good
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=12
POWER_SUPPLY_VOLTAGE_NOW=11441000
POWER_SUPPLY_CURRENT_NOW=-26000
POWER_SUPPLY_CURRENT_AVG=-24000
POWER_SUPPLY_CAPACITY=76
POWER_SUPPLY_CAPACITY_ERROR_MARGIN=1
POWER_SUPPLY_TEMP=198
POWER_SUPPLY_TIME_TO_EMPTY_AVG=438600
POWER_SUPPLY_TIME_TO_FULL_AVG=3932100
POWER_SUPPLY_SERIAL_NUMBER=0000
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
POWER_SUPPLY_VOLTAGE_MAX_DESIGN=10800000
POWER_SUPPLY_ENERGY_NOW=31090000
POWER_SUPPLY_ENERGY_FULL=42450000
POWER_SUPPLY_ENERGY_FULL_DESIGN=41040000
POWER_SUPPLY_CHARGE_NOW=2924000
POWER_SUPPLY_CHARGE_FULL=3898000
POWER_SUPPLY_CHARGE_FULL_DESIGN=3800000
POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=3000000
POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE_MAX=12300000
POWER_SUPPLY_MANUFACTURE_YEAR=2017
POWER_SUPPLY_MANUFACTURE_MONTH=7
POWER_SUPPLY_MANUFACTURE_DAY=3
POWER_SUPPLY_MANUFACTURER=UR18650A
POWER_SUPPLY_MODEL_NAME=GEHC

-- Sebastian

Jean-Francois Dagenais (1):
  power: supply: sbs-battery: add ability to disable charger broadcasts

Sebastian Reichel (18):
  kobject: increase allowed number of uevent variables
  power: supply: core: add capacity error margin property
  power: supply: core: add manufacture date properties
  power: supply: core: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED
  power: supply: sbs-battery: Add TI BQ20Z65 support
  power: supply: sbs-battery: add
    POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN support
  power: supply: sbs-battery: simplify read_read_string_data
  power: supply: sbs-battery: add PEC support
  power: supply: sbs-battery: add POWER_SUPPLY_PROP_CURRENT_AVG support
  power: supply: sbs-battery: Improve POWER_SUPPLY_PROP_TECHNOLOGY
    support
  power: supply: sbs-battery: add
    POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT/VOLTAGE_MAX support
  power: supply: sbs-battery: add MANUFACTURE_DATE support
  power: supply: sbs-battery: add
    POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED support
  power: supply: sbs-battery: fix idle battery status
  power: supply: sbs-battery: switch from of_property_* to
    device_property_*
  power: supply: sbs-battery: switch to i2c's probe_new
  power: supply: sbs-battery: constify power-supply property array
  dt-bindings: power: sbs-battery: Convert to yaml

 Documentation/ABI/testing/sysfs-class-power   |  45 ++-
 .../power/supply/sbs,sbs-battery.yaml         |  83 +++++
 .../bindings/power/supply/sbs_sbs-battery.txt |  27 --
 drivers/power/supply/power_supply_sysfs.c     |   5 +
 drivers/power/supply/sbs-battery.c            | 348 +++++++++++++-----
 include/linux/kobject.h                       |   2 +-
 include/linux/power_supply.h                  |   5 +
 7 files changed, 404 insertions(+), 111 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/supply/sbs,sbs-battery.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt

-- 
2.26.2


^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCHv1 01/19] kobject: increase allowed number of uevent variables
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
@ 2020-05-13 18:55 ` Sebastian Reichel
  2020-05-14  6:11   ` Greg Kroah-Hartman
  2020-05-15 14:45   ` Emil Velikov
  2020-05-13 18:55 ` [PATCHv1 02/19] power: supply: core: add capacity error margin property Sebastian Reichel
                   ` (20 subsequent siblings)
  21 siblings, 2 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:55 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

SBS battery driver exposes 32 power supply properties now,
which will result in uevent failure on (un)plugging the
battery. Other drivers (e.g. bq27xxx) are also coming close
to this limit, so increase it.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 include/linux/kobject.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index e2ca0a292e21..75e822569e39 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -29,7 +29,7 @@
 #include <linux/uidgid.h>
 
 #define UEVENT_HELPER_PATH_LEN		256
-#define UEVENT_NUM_ENVP			32	/* number of env pointers */
+#define UEVENT_NUM_ENVP			64	/* number of env pointers */
 #define UEVENT_BUFFER_SIZE		2048	/* buffer for the variables */
 
 #ifdef CONFIG_UEVENT_HELPER
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 02/19] power: supply: core: add capacity error margin property
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
  2020-05-13 18:55 ` [PATCHv1 01/19] kobject: increase allowed number of uevent variables Sebastian Reichel
@ 2020-05-13 18:55 ` Sebastian Reichel
  2020-05-13 18:55 ` [PATCHv1 03/19] power: supply: core: add manufacture date properties Sebastian Reichel
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:55 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Add a property for reporting the error margin expected
by fuel gauge chips.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 Documentation/ABI/testing/sysfs-class-power | 15 +++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                |  1 +
 3 files changed, 17 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
index bf3b48f022dc..2f896555ae23 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -74,6 +74,21 @@ Description:
 		Access: Read, Write
 		Valid values: 0 - 100 (percent)
 
+What:		/sys/class/power_supply/<supply_name>/capacity_error_margin
+Date:		April 2019
+Contact:	linux-pm@vger.kernel.org
+Description:
+		Battery capacity measurement becomes unreliable without
+		recalibration. This values provides the maximum error
+		margin expected to exist by the fuel gauge in percent.
+		Values close to 0% will be returned after (re-)calibration
+		has happened. Over time the error margin will increase.
+		100% means, that the capacity related values are basically
+		completely useless.
+
+		Access: Read
+		Valid values: 0 - 100 (percent)
+
 What:		/sys/class/power_supply/<supply_name>/capacity_level
 Date:		June 2009
 Contact:	linux-pm@vger.kernel.org
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index d21b4e0edf38..e664774a2d1e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -178,6 +178,7 @@ static struct power_supply_attr power_supply_attrs[] = {
 	POWER_SUPPLY_ATTR(CAPACITY),
 	POWER_SUPPLY_ATTR(CAPACITY_ALERT_MIN),
 	POWER_SUPPLY_ATTR(CAPACITY_ALERT_MAX),
+	POWER_SUPPLY_ATTR(CAPACITY_ERROR_MARGIN),
 	POWER_SUPPLY_ENUM_ATTR(CAPACITY_LEVEL),
 	POWER_SUPPLY_ATTR(TEMP),
 	POWER_SUPPLY_ATTR(TEMP_MAX),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 1f60731ec7fe..453a85f25635 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -139,6 +139,7 @@ enum power_supply_property {
 	POWER_SUPPLY_PROP_CAPACITY, /* in percents! */
 	POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, /* in percents! */
 	POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX, /* in percents! */
+	POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, /* in percents! */
 	POWER_SUPPLY_PROP_CAPACITY_LEVEL,
 	POWER_SUPPLY_PROP_TEMP,
 	POWER_SUPPLY_PROP_TEMP_MAX,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 03/19] power: supply: core: add manufacture date properties
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
  2020-05-13 18:55 ` [PATCHv1 01/19] kobject: increase allowed number of uevent variables Sebastian Reichel
  2020-05-13 18:55 ` [PATCHv1 02/19] power: supply: core: add capacity error margin property Sebastian Reichel
@ 2020-05-13 18:55 ` Sebastian Reichel
  2020-05-15 14:47   ` Emil Velikov
  2020-05-13 18:56 ` [PATCHv1 04/19] power: supply: core: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED Sebastian Reichel
                   ` (18 subsequent siblings)
  21 siblings, 1 reply; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:55 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Some smart batteries store their manufacture date, which is
useful to identify the battery and/or to know about the cell
quality.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 Documentation/ABI/testing/sysfs-class-power | 28 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  3 +++
 include/linux/power_supply.h                |  3 +++
 3 files changed, 34 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
index 2f896555ae23..e6d7348766b2 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -680,3 +680,31 @@ Description:
 		Valid values:
 		- 1: enabled
 		- 0: disabled
+
+What:		/sys/class/power_supply/<supply_name>/manufacture_year
+Date:		January 2020
+Contact:	linux-pm@vger.kernel.org
+Description:
+		Reports the year (following Gregorian calendar) when the device has been
+		manufactured.
+
+		Access: Read
+		Valid values: Reported as integer
+
+What:		/sys/class/power_supply/<supply_name>/manufacture_month
+Date:		January 2020
+Contact:	linux-pm@vger.kernel.org
+Description:
+		Reports the month when the device has been manufactured.
+
+		Access: Read
+		Valid values: 1-12
+
+What:		/sys/class/power_supply/<supply_name>/manufacture_day
+Date:		January 2020
+Contact:	linux-pm@vger.kernel.org
+Description:
+		Reports the day of month when the device has been manufactured.
+
+		Access: Read
+		Valid values: 1-31
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index e664774a2d1e..78d5382e69f1 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -198,6 +198,9 @@ static struct power_supply_attr power_supply_attrs[] = {
 	POWER_SUPPLY_ATTR(PRECHARGE_CURRENT),
 	POWER_SUPPLY_ATTR(CHARGE_TERM_CURRENT),
 	POWER_SUPPLY_ATTR(CALIBRATE),
+	POWER_SUPPLY_ATTR(MANUFACTURE_YEAR),
+	POWER_SUPPLY_ATTR(MANUFACTURE_MONTH),
+	POWER_SUPPLY_ATTR(MANUFACTURE_DAY),
 	/* Properties of type `const char *' */
 	POWER_SUPPLY_ATTR(MODEL_NAME),
 	POWER_SUPPLY_ATTR(MANUFACTURER),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 453a85f25635..63ffe2a0a87b 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -159,6 +159,9 @@ enum power_supply_property {
 	POWER_SUPPLY_PROP_PRECHARGE_CURRENT,
 	POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
 	POWER_SUPPLY_PROP_CALIBRATE,
+	POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
+	POWER_SUPPLY_PROP_MANUFACTURE_MONTH,
+	POWER_SUPPLY_PROP_MANUFACTURE_DAY,
 	/* Properties of type `const char *' */
 	POWER_SUPPLY_PROP_MODEL_NAME,
 	POWER_SUPPLY_PROP_MANUFACTURER,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 04/19] power: supply: core: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (2 preceding siblings ...)
  2020-05-13 18:55 ` [PATCHv1 03/19] power: supply: core: add manufacture date properties Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 05/19] power: supply: sbs-battery: Add TI BQ20Z65 support Sebastian Reichel
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Some battery fuel gauges know when the battery needs to
be recalibrated before providing usable values. This
should be reported via the health property.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 Documentation/ABI/testing/sysfs-class-power | 2 +-
 drivers/power/supply/power_supply_sysfs.c   | 1 +
 include/linux/power_supply.h                | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
index e6d7348766b2..216d61a22f1e 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -205,7 +205,7 @@ Description:
 		Valid values: "Unknown", "Good", "Overheat", "Dead",
 			      "Over voltage", "Unspecified failure", "Cold",
 			      "Watchdog timer expire", "Safety timer expire",
-			      "Over current"
+			      "Over current", "Calibration required"
 
 What:		/sys/class/power_supply/<supply_name>/precharge_current
 Date:		June 2017
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index 78d5382e69f1..bc79560229b5 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -100,6 +100,7 @@ static const char * const POWER_SUPPLY_HEALTH_TEXT[] = {
 	[POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE] = "Watchdog timer expire",
 	[POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE]   = "Safety timer expire",
 	[POWER_SUPPLY_HEALTH_OVERCURRENT]	    = "Over current",
+	[POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED]  = "Calibration required",
 };
 
 static const char * const POWER_SUPPLY_TECHNOLOGY_TEXT[] = {
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 63ffe2a0a87b..ac1345a48ad0 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -61,6 +61,7 @@ enum {
 	POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE,
 	POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE,
 	POWER_SUPPLY_HEALTH_OVERCURRENT,
+	POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED,
 };
 
 enum {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 05/19] power: supply: sbs-battery: Add TI BQ20Z65 support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (3 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 04/19] power: supply: core: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-28  2:37   ` Rob Herring
  2020-05-13 18:56 ` [PATCHv1 06/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN support Sebastian Reichel
                   ` (16 subsequent siblings)
  21 siblings, 1 reply; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Add support for BQ20Z65 manufacturer data to the sbs-battery
driver. Implementation has been verified using the public TRM
available from [0] and tested using a GE Flex 3S2P battery.

[0] http://www.ti.com/lit/pdf/sluu386

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 .../bindings/power/supply/sbs_sbs-battery.txt     |  1 +
 drivers/power/supply/sbs-battery.c                | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt b/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
index 4e78e51018eb..fa5a8b516dbf 100644
--- a/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
+++ b/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
@@ -6,6 +6,7 @@ Required properties :
      part number compatible string might be used in order to take care of
      vendor specific registers.
      Known <vendor>,<part-number>:
+       ti,bq20z65
        ti,bq20z75
 
 Optional properties :
diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 6acd242eed48..a15783802ef8 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -149,8 +149,8 @@ static enum power_supply_property sbs_properties[] = {
 	POWER_SUPPLY_PROP_MODEL_NAME
 };
 
-/* Supports special manufacturer commands from TI BQ20Z75 IC. */
-#define SBS_FLAGS_TI_BQ20Z75		BIT(0)
+/* Supports special manufacturer commands from TI BQ20Z65 and BQ20Z75 IC. */
+#define SBS_FLAGS_TI_BQ20ZX5		BIT(0)
 
 struct sbs_info {
 	struct i2c_client		*client;
@@ -626,7 +626,7 @@ static int sbs_get_property(struct power_supply *psy,
 	switch (psp) {
 	case POWER_SUPPLY_PROP_PRESENT:
 	case POWER_SUPPLY_PROP_HEALTH:
-		if (chip->flags & SBS_FLAGS_TI_BQ20Z75)
+		if (chip->flags & SBS_FLAGS_TI_BQ20ZX5)
 			ret = sbs_get_ti_battery_presence_and_health(client,
 								     psp, val);
 		else
@@ -950,7 +950,7 @@ static int sbs_suspend(struct device *dev)
 	if (chip->poll_time > 0)
 		cancel_delayed_work_sync(&chip->work);
 
-	if (chip->flags & SBS_FLAGS_TI_BQ20Z75) {
+	if (chip->flags & SBS_FLAGS_TI_BQ20ZX5) {
 		/* Write to manufacturer access with sleep command. */
 		ret = sbs_write_word_data(client,
 					  sbs_data[REG_MANUFACTURER_DATA].addr,
@@ -970,6 +970,7 @@ static SIMPLE_DEV_PM_OPS(sbs_pm_ops, sbs_suspend, NULL);
 #endif
 
 static const struct i2c_device_id sbs_id[] = {
+	{ "bq20z65", 0 },
 	{ "bq20z75", 0 },
 	{ "sbs-battery", 1 },
 	{}
@@ -978,9 +979,13 @@ MODULE_DEVICE_TABLE(i2c, sbs_id);
 
 static const struct of_device_id sbs_dt_ids[] = {
 	{ .compatible = "sbs,sbs-battery" },
+	{
+		.compatible = "ti,bq20z65",
+		.data = (void *)SBS_FLAGS_TI_BQ20ZX5,
+	},
 	{
 		.compatible = "ti,bq20z75",
-		.data = (void *)SBS_FLAGS_TI_BQ20Z75,
+		.data = (void *)SBS_FLAGS_TI_BQ20ZX5,
 	},
 	{ }
 };
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 06/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (4 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 05/19] power: supply: sbs-battery: Add TI BQ20Z65 support Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 07/19] power: supply: sbs-battery: simplify read_read_string_data Sebastian Reichel
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Add support for reporting the MaxError register from
battery fuel gauges following the smart battery standard.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index a15783802ef8..4356fdf25d4a 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -26,6 +26,7 @@ enum {
 	REG_TEMPERATURE,
 	REG_VOLTAGE,
 	REG_CURRENT,
+	REG_MAX_ERR,
 	REG_CAPACITY,
 	REG_TIME_TO_EMPTY,
 	REG_TIME_TO_FULL,
@@ -85,6 +86,8 @@ static const struct chip_data {
 		SBS_DATA(POWER_SUPPLY_PROP_VOLTAGE_NOW, 0x09, 0, 20000),
 	[REG_CURRENT] =
 		SBS_DATA(POWER_SUPPLY_PROP_CURRENT_NOW, 0x0A, -32768, 32767),
+	[REG_MAX_ERR] =
+		SBS_DATA(POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, 0x0c, 0, 100),
 	[REG_CAPACITY] =
 		SBS_DATA(POWER_SUPPLY_PROP_CAPACITY, 0x0D, 0, 100),
 	[REG_REMAINING_CAPACITY] =
@@ -132,6 +135,7 @@ static enum power_supply_property sbs_properties[] = {
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
 	POWER_SUPPLY_PROP_CURRENT_NOW,
 	POWER_SUPPLY_PROP_CAPACITY,
+	POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN,
 	POWER_SUPPLY_PROP_TEMP,
 	POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
 	POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
@@ -676,6 +680,7 @@ static int sbs_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
 	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
 	case POWER_SUPPLY_PROP_CAPACITY:
+	case POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN:
 		ret = sbs_get_property_index(client, psp);
 		if (ret < 0)
 			break;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 07/19] power: supply: sbs-battery: simplify read_read_string_data
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (5 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 06/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN support Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 08/19] power: supply: sbs-battery: add PEC support Sebastian Reichel
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

The SBS battery implements SMBus block reads. Currently the
driver "emulates" this by doing an I2C byte read for the
length followed by an I2C block read. The I2C subsystem
actually provides a proper API for doing SMBus block reads,
which can and should be used instead. The current implementation
does not properly handle packet error checking (PEC).

This change requires, that I2C bus drivers support I2C_M_RECV_LEN
or directly provide the SMBus API to access device manufacturer
and model name.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 65 ++++++------------------------
 1 file changed, 12 insertions(+), 53 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 4356fdf25d4a..a9a1d28dabbe 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -202,66 +202,32 @@ static int sbs_read_string_data(struct i2c_client *client, u8 address,
 				char *values)
 {
 	struct sbs_info *chip = i2c_get_clientdata(client);
-	s32 ret = 0, block_length = 0;
-	int retries_length, retries_block;
-	u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1];
-
-	retries_length = chip->i2c_retry_count;
-	retries_block = chip->i2c_retry_count;
+	int retries = chip->i2c_retry_count;
+	s32 ret = 0;
 
-	/* Adapter needs to support these two functions */
 	if (!i2c_check_functionality(client->adapter,
-				     I2C_FUNC_SMBUS_BYTE_DATA |
-				     I2C_FUNC_SMBUS_I2C_BLOCK)){
+				     I2C_FUNC_SMBUS_READ_BLOCK_DATA)) {
 		return -ENODEV;
 	}
 
-	/* Get the length of block data */
-	while (retries_length > 0) {
-		ret = i2c_smbus_read_byte_data(client, address);
-		if (ret >= 0)
-			break;
-		retries_length--;
-	}
-
-	if (ret < 0) {
-		dev_dbg(&client->dev,
-			"%s: i2c read at address 0x%x failed\n",
-			__func__, address);
-		return ret;
-	}
-
-	/* block_length does not include NULL terminator */
-	block_length = ret;
-	if (block_length > I2C_SMBUS_BLOCK_MAX) {
-		dev_err(&client->dev,
-			"%s: Returned block_length is longer than 0x%x\n",
-			__func__, I2C_SMBUS_BLOCK_MAX);
-		return -EINVAL;
-	}
-
 	/* Get the block data */
-	while (retries_block > 0) {
-		ret = i2c_smbus_read_i2c_block_data(
-				client, address,
-				block_length + 1, block_buffer);
+	while (retries > 0) {
+		ret = i2c_smbus_read_block_data(client, address, values);
 		if (ret >= 0)
 			break;
-		retries_block--;
+		retries--;
 	}
 
 	if (ret < 0) {
-		dev_dbg(&client->dev,
-			"%s: i2c read at address 0x%x failed\n",
-			__func__, address);
+		dev_dbg(&client->dev, "%s: failed to read block 0x%x: %d\n",
+			__func__, address, ret);
 		return ret;
 	}
 
-	/* block_buffer[0] == block_length */
-	memcpy(values, block_buffer + 1, block_length);
-	values[block_length] = '\0';
+	/* add string termination */
+	values[ret] = '\0';
 
-	return ret;
+	return 0;
 }
 
 static int sbs_write_word_data(struct i2c_client *client, u8 address,
@@ -465,14 +431,7 @@ static int sbs_get_battery_property(struct i2c_client *client,
 static int sbs_get_battery_string_property(struct i2c_client *client,
 	int reg_offset, enum power_supply_property psp, char *val)
 {
-	s32 ret;
-
-	ret = sbs_read_string_data(client, sbs_data[reg_offset].addr, val);
-
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	return sbs_read_string_data(client, sbs_data[reg_offset].addr, val);
 }
 
 static void  sbs_unit_adjustment(struct i2c_client *client,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 08/19] power: supply: sbs-battery: add PEC support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (6 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 07/19] power: supply: sbs-battery: simplify read_read_string_data Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 09/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CURRENT_AVG support Sebastian Reichel
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

SBS batteries optionally have support for PEC. This enables
PEC handling based on the implemented SBS version as suggested
by the standard. The support for PEC is re-evaluated when the
battery is hotplugged into the system, since there might be
systems supporting batteries from different SBS generations.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 72 ++++++++++++++++++++++++++++--
 1 file changed, 69 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index a9a1d28dabbe..ab774d491269 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -46,6 +46,14 @@ enum {
 	REG_MODEL_NAME,
 };
 
+#define REG_ADDR_SPEC_INFO		0x1A
+#define SPEC_INFO_VERSION_MASK		GENMASK(7, 4)
+#define SPEC_INFO_VERSION_SHIFT		4
+
+#define SBS_VERSION_1_0			1
+#define SBS_VERSION_1_1			2
+#define SBS_VERSION_1_1_WITH_PEC	3
+
 /* Battery Mode defines */
 #define BATTERY_MODE_OFFSET		0x03
 #define BATTERY_MODE_CAPACITY_MASK	BIT(15)
@@ -175,6 +183,64 @@ static char model_name[I2C_SMBUS_BLOCK_MAX + 1];
 static char manufacturer[I2C_SMBUS_BLOCK_MAX + 1];
 static bool force_load;
 
+static int sbs_update_presence(struct sbs_info *chip, bool is_present)
+{
+	struct i2c_client *client = chip->client;
+	int retries = chip->i2c_retry_count;
+	s32 ret = 0;
+	u8 version;
+
+	if (chip->is_present == is_present)
+		return 0;
+
+	if (!is_present) {
+		chip->is_present = false;
+		/* Disable PEC when no device is present */
+		client->flags &= ~I2C_CLIENT_PEC;
+		return 0;
+	}
+
+	/* Check if device supports packet error checking and use it */
+	while (retries > 0) {
+		ret = i2c_smbus_read_word_data(client, REG_ADDR_SPEC_INFO);
+		if (ret >= 0)
+			break;
+
+		/*
+		 * Some batteries trigger the detection pin before the
+		 * I2C bus is properly connected. This works around the
+		 * issue.
+		 */
+		msleep(100);
+
+		retries--;
+	}
+
+	if (ret < 0) {
+		dev_dbg(&client->dev, "failed to read spec info: %d\n", ret);
+
+		/* fallback to old behaviour */
+		client->flags &= ~I2C_CLIENT_PEC;
+		chip->is_present = true;
+
+		return ret;
+	}
+
+	version = (ret & SPEC_INFO_VERSION_MASK) >> SPEC_INFO_VERSION_SHIFT;
+
+	if (version == SBS_VERSION_1_1_WITH_PEC)
+		client->flags |= I2C_CLIENT_PEC;
+	else
+		client->flags &= ~I2C_CLIENT_PEC;
+
+	dev_dbg(&client->dev, "PEC: %s\n", (client->flags & I2C_CLIENT_PEC) ?
+		"enabled" : "disabled");
+
+	chip->is_present = true;
+
+	return 0;
+}
+
 static int sbs_read_word_data(struct i2c_client *client, u8 address)
 {
 	struct sbs_info *chip = i2c_get_clientdata(client);
@@ -579,7 +645,7 @@ static int sbs_get_property(struct power_supply *psy,
 			return ret;
 		if (psp == POWER_SUPPLY_PROP_PRESENT) {
 			val->intval = ret;
-			chip->is_present = val->intval;
+			sbs_update_presence(chip, ret);
 			return 0;
 		}
 		if (ret == 0)
@@ -678,7 +744,7 @@ static int sbs_get_property(struct power_supply *psy,
 
 	if (!chip->gpio_detect &&
 		chip->is_present != (ret >= 0)) {
-		chip->is_present = (ret >= 0);
+		sbs_update_presence(chip, (ret >= 0));
 		power_supply_changed(chip->power_supply);
 	}
 
@@ -709,7 +775,7 @@ static void sbs_supply_changed(struct sbs_info *chip)
 	ret = gpiod_get_value_cansleep(chip->gpio_detect);
 	if (ret < 0)
 		return;
-	chip->is_present = ret;
+	sbs_update_presence(chip, ret);
 	power_supply_changed(battery);
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 09/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CURRENT_AVG support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (7 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 08/19] power: supply: sbs-battery: add PEC support Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 10/19] power: supply: sbs-battery: Improve POWER_SUPPLY_PROP_TECHNOLOGY support Sebastian Reichel
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Expose averaged current information, which is part of the SBS
standard and should be supported by all batteries.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index ab774d491269..611a11385496 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -25,7 +25,8 @@ enum {
 	REG_MANUFACTURER_DATA,
 	REG_TEMPERATURE,
 	REG_VOLTAGE,
-	REG_CURRENT,
+	REG_CURRENT_NOW,
+	REG_CURRENT_AVG,
 	REG_MAX_ERR,
 	REG_CAPACITY,
 	REG_TIME_TO_EMPTY,
@@ -92,8 +93,10 @@ static const struct chip_data {
 		SBS_DATA(POWER_SUPPLY_PROP_TEMP, 0x08, 0, 65535),
 	[REG_VOLTAGE] =
 		SBS_DATA(POWER_SUPPLY_PROP_VOLTAGE_NOW, 0x09, 0, 20000),
-	[REG_CURRENT] =
+	[REG_CURRENT_NOW] =
 		SBS_DATA(POWER_SUPPLY_PROP_CURRENT_NOW, 0x0A, -32768, 32767),
+	[REG_CURRENT_AVG] =
+		SBS_DATA(POWER_SUPPLY_PROP_CURRENT_AVG, 0x0B, -32768, 32767),
 	[REG_MAX_ERR] =
 		SBS_DATA(POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN, 0x0c, 0, 100),
 	[REG_CAPACITY] =
@@ -142,6 +145,7 @@ static enum power_supply_property sbs_properties[] = {
 	POWER_SUPPLY_PROP_CYCLE_COUNT,
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
 	POWER_SUPPLY_PROP_CURRENT_NOW,
+	POWER_SUPPLY_PROP_CURRENT_AVG,
 	POWER_SUPPLY_PROP_CAPACITY,
 	POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN,
 	POWER_SUPPLY_PROP_TEMP,
@@ -324,7 +328,7 @@ static int sbs_status_correct(struct i2c_client *client, int *intval)
 {
 	int ret;
 
-	ret = sbs_read_word_data(client, sbs_data[REG_CURRENT].addr);
+	ret = sbs_read_word_data(client, sbs_data[REG_CURRENT_NOW].addr);
 	if (ret < 0)
 		return ret;
 
@@ -521,6 +525,7 @@ static void  sbs_unit_adjustment(struct i2c_client *client,
 	case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
 	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
+	case POWER_SUPPLY_PROP_CURRENT_AVG:
 	case POWER_SUPPLY_PROP_CHARGE_NOW:
 	case POWER_SUPPLY_PROP_CHARGE_FULL:
 	case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
@@ -699,6 +704,7 @@ static int sbs_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_CYCLE_COUNT:
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
+	case POWER_SUPPLY_PROP_CURRENT_AVG:
 	case POWER_SUPPLY_PROP_TEMP:
 	case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
 	case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 10/19] power: supply: sbs-battery: Improve POWER_SUPPLY_PROP_TECHNOLOGY support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (8 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 09/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CURRENT_AVG support Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 11/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT/VOLTAGE_MAX support Sebastian Reichel
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

This reads the battery chemistry from the battery chip instead
of incorrectly hardcoding the type to be Li-Ion.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 43 ++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 611a11385496..b697a42d9ccf 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -43,6 +43,7 @@ enum {
 	REG_DESIGN_CAPACITY_CHARGE,
 	REG_DESIGN_VOLTAGE_MIN,
 	REG_DESIGN_VOLTAGE_MAX,
+	REG_CHEMISTRY,
 	REG_MANUFACTURER,
 	REG_MODEL_NAME,
 };
@@ -133,7 +134,9 @@ static const struct chip_data {
 	[REG_MANUFACTURER] =
 		SBS_DATA(POWER_SUPPLY_PROP_MANUFACTURER, 0x20, 0, 65535),
 	[REG_MODEL_NAME] =
-		SBS_DATA(POWER_SUPPLY_PROP_MODEL_NAME, 0x21, 0, 65535)
+		SBS_DATA(POWER_SUPPLY_PROP_MODEL_NAME, 0x21, 0, 65535),
+	[REG_CHEMISTRY] =
+		SBS_DATA(POWER_SUPPLY_PROP_TECHNOLOGY, 0x22, 0, 65535)
 };
 
 static enum power_supply_property sbs_properties[] = {
@@ -185,6 +188,7 @@ struct sbs_info {
 
 static char model_name[I2C_SMBUS_BLOCK_MAX + 1];
 static char manufacturer[I2C_SMBUS_BLOCK_MAX + 1];
+static char chemistry[I2C_SMBUS_BLOCK_MAX + 1];
 static bool force_load;
 
 static int sbs_update_presence(struct sbs_info *chip, bool is_present)
@@ -636,6 +640,38 @@ static int sbs_get_property_index(struct i2c_client *client,
 	return -EINVAL;
 }
 
+static int sbs_get_chemistry(struct i2c_client *client,
+		union power_supply_propval *val)
+{
+	enum power_supply_property psp = POWER_SUPPLY_PROP_TECHNOLOGY;
+	int ret;
+
+	ret = sbs_get_property_index(client, psp);
+	if (ret < 0)
+		return ret;
+
+	ret = sbs_get_battery_string_property(client, ret, psp,
+					      chemistry);
+	if (ret < 0)
+		return ret;
+
+	if (!strncasecmp(chemistry, "LION", 4))
+		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
+	else if (!strncasecmp(chemistry, "LiP", 3))
+		val->intval = POWER_SUPPLY_TECHNOLOGY_LIPO;
+	else if (!strncasecmp(chemistry, "NiCd", 4))
+		val->intval = POWER_SUPPLY_TECHNOLOGY_NiCd;
+	else if (!strncasecmp(chemistry, "NiMH", 4))
+		val->intval = POWER_SUPPLY_TECHNOLOGY_NiMH;
+	else
+		val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
+
+	if (val->intval == POWER_SUPPLY_TECHNOLOGY_UNKNOWN)
+		dev_warn(&client->dev, "Unknown chemistry: %s\n", chemistry);
+
+	return 0;
+}
+
 static int sbs_get_property(struct power_supply *psy,
 	enum power_supply_property psp,
 	union power_supply_propval *val)
@@ -673,7 +709,10 @@ static int sbs_get_property(struct power_supply *psy,
 		break;
 
 	case POWER_SUPPLY_PROP_TECHNOLOGY:
-		val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
+		ret = sbs_get_chemistry(client, val);
+		if (ret < 0)
+			break;
+
 		goto done; /* don't trigger power_supply_changed()! */
 
 	case POWER_SUPPLY_PROP_ENERGY_NOW:
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 11/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT/VOLTAGE_MAX support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (9 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 10/19] power: supply: sbs-battery: Improve POWER_SUPPLY_PROP_TECHNOLOGY support Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 12/19] power: supply: sbs-battery: add MANUFACTURE_DATE support Sebastian Reichel
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Expose maximum charge current/voltage information requested
by the battery.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index b697a42d9ccf..e6f61baa9bed 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -46,6 +46,8 @@ enum {
 	REG_CHEMISTRY,
 	REG_MANUFACTURER,
 	REG_MODEL_NAME,
+	REG_CHARGE_CURRENT,
+	REG_CHARGE_VOLTAGE,
 };
 
 #define REG_ADDR_SPEC_INFO		0x1A
@@ -114,6 +116,10 @@ static const struct chip_data {
 		SBS_DATA(POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, 0x12, 0, 65535),
 	[REG_TIME_TO_FULL] =
 		SBS_DATA(POWER_SUPPLY_PROP_TIME_TO_FULL_AVG, 0x13, 0, 65535),
+	[REG_CHARGE_CURRENT] =
+		SBS_DATA(POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, 0x14, 0, 65535),
+	[REG_CHARGE_VOLTAGE] =
+		SBS_DATA(POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX, 0x15, 0, 65535),
 	[REG_STATUS] =
 		SBS_DATA(POWER_SUPPLY_PROP_STATUS, 0x16, 0, 65535),
 	[REG_CAPACITY_LEVEL] =
@@ -163,6 +169,8 @@ static enum power_supply_property sbs_properties[] = {
 	POWER_SUPPLY_PROP_CHARGE_NOW,
 	POWER_SUPPLY_PROP_CHARGE_FULL,
 	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
+	POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
 	/* Properties of type `const char *' */
 	POWER_SUPPLY_PROP_MANUFACTURER,
 	POWER_SUPPLY_PROP_MODEL_NAME
@@ -531,6 +539,8 @@ static void  sbs_unit_adjustment(struct i2c_client *client,
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
 	case POWER_SUPPLY_PROP_CURRENT_AVG:
 	case POWER_SUPPLY_PROP_CHARGE_NOW:
+	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
+	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
 	case POWER_SUPPLY_PROP_CHARGE_FULL:
 	case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
 		val->intval *= BASE_UNIT_CONVERSION;
@@ -749,6 +759,8 @@ static int sbs_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
 	case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
 	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
+	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
+	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
 	case POWER_SUPPLY_PROP_CAPACITY:
 	case POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN:
 		ret = sbs_get_property_index(client, psp);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 12/19] power: supply: sbs-battery: add MANUFACTURE_DATE support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (10 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 11/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT/VOLTAGE_MAX support Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 13/19] power: supply: sbs-battery: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED support Sebastian Reichel
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Expose the battery's manufacture date to userspace.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 43 ++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index e6f61baa9bed..4fa553d61db2 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -58,6 +58,8 @@ enum {
 #define SBS_VERSION_1_1			2
 #define SBS_VERSION_1_1_WITH_PEC	3
 
+#define REG_ADDR_MANUFACTURE_DATE	0x1B
+
 /* Battery Mode defines */
 #define BATTERY_MODE_OFFSET		0x03
 #define BATTERY_MODE_CAPACITY_MASK	BIT(15)
@@ -171,6 +173,9 @@ static enum power_supply_property sbs_properties[] = {
 	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
 	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
 	POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
+	POWER_SUPPLY_PROP_MANUFACTURE_YEAR,
+	POWER_SUPPLY_PROP_MANUFACTURE_MONTH,
+	POWER_SUPPLY_PROP_MANUFACTURE_DAY,
 	/* Properties of type `const char *' */
 	POWER_SUPPLY_PROP_MANUFACTURER,
 	POWER_SUPPLY_PROP_MODEL_NAME
@@ -682,6 +687,38 @@ static int sbs_get_chemistry(struct i2c_client *client,
 	return 0;
 }
 
+static int sbs_get_battery_manufacture_date(struct i2c_client *client,
+	enum power_supply_property psp,
+	union power_supply_propval *val)
+{
+	int ret;
+	u16 day, month, year;
+
+	ret = sbs_read_word_data(client, REG_ADDR_MANUFACTURE_DATE);
+	if (ret < 0)
+		return ret;
+
+	day   = ret   & GENMASK(4,  0);
+	month = (ret  & GENMASK(8,  5)) >> 5;
+	year  = ((ret & GENMASK(15, 9)) >> 9) + 1980;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_MANUFACTURE_YEAR:
+		val->intval = year;
+		break;
+	case POWER_SUPPLY_PROP_MANUFACTURE_MONTH:
+		val->intval = month;
+		break;
+	case POWER_SUPPLY_PROP_MANUFACTURE_DAY:
+		val->intval = day;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int sbs_get_property(struct power_supply *psy,
 	enum power_supply_property psp,
 	union power_supply_propval *val)
@@ -790,6 +827,12 @@ static int sbs_get_property(struct power_supply *psy,
 		val->strval = manufacturer;
 		break;
 
+	case POWER_SUPPLY_PROP_MANUFACTURE_YEAR:
+	case POWER_SUPPLY_PROP_MANUFACTURE_MONTH:
+	case POWER_SUPPLY_PROP_MANUFACTURE_DAY:
+		ret = sbs_get_battery_manufacture_date(client, psp, val);
+		break;
+
 	default:
 		dev_err(&client->dev,
 			"%s: INVALID property\n", __func__);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 13/19] power: supply: sbs-battery: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (11 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 12/19] power: supply: sbs-battery: add MANUFACTURE_DATE support Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-15 15:35   ` Emil Velikov
  2020-05-13 18:56 ` [PATCHv1 14/19] power: supply: sbs-battery: fix idle battery status Sebastian Reichel
                   ` (8 subsequent siblings)
  21 siblings, 1 reply; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Add support for reporting the SBS battery's condition flag
to userspace using the new "Calibration required" health status.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 4fa553d61db2..2a2b926ad75c 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -23,6 +23,7 @@
 
 enum {
 	REG_MANUFACTURER_DATA,
+	REG_BATTERY_MODE,
 	REG_TEMPERATURE,
 	REG_VOLTAGE,
 	REG_CURRENT_NOW,
@@ -94,6 +95,8 @@ static const struct chip_data {
 } sbs_data[] = {
 	[REG_MANUFACTURER_DATA] =
 		SBS_DATA(POWER_SUPPLY_PROP_PRESENT, 0x00, 0, 65535),
+	[REG_BATTERY_MODE] =
+		SBS_DATA(-1, 0x03, 0, 65535),
 	[REG_TEMPERATURE] =
 		SBS_DATA(POWER_SUPPLY_PROP_TEMP, 0x08, 0, 65535),
 	[REG_VOLTAGE] =
@@ -366,6 +369,17 @@ static int sbs_status_correct(struct i2c_client *client, int *intval)
 	return 0;
 }
 
+static bool sbs_bat_needs_calibration(struct i2c_client *client)
+{
+	int ret;
+
+	ret = sbs_read_word_data(client, sbs_data[REG_BATTERY_MODE].addr);
+	if (ret < 0)
+		return false;
+
+	return !!(ret & BIT(7));
+}
+
 static int sbs_get_battery_presence_and_health(
 	struct i2c_client *client, enum power_supply_property psp,
 	union power_supply_propval *val)
@@ -385,9 +399,14 @@ static int sbs_get_battery_presence_and_health(
 
 	if (psp == POWER_SUPPLY_PROP_PRESENT)
 		val->intval = 1; /* battery present */
-	else /* POWER_SUPPLY_PROP_HEALTH */
-		/* SBS spec doesn't have a general health command. */
-		val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
+	else { /* POWER_SUPPLY_PROP_HEALTH */
+		if (sbs_bat_needs_calibration(client)) {
+			val->intval = POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED;
+		} else {
+			/* SBS spec doesn't have a general health command. */
+			val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
+		}
+	}
 
 	return 0;
 }
@@ -441,6 +460,8 @@ static int sbs_get_ti_battery_presence_and_health(
 			val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
 		else if (ret == 0x0C)
 			val->intval = POWER_SUPPLY_HEALTH_DEAD;
+		else if (sbs_bat_needs_calibration(client))
+			val->intval = POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED;
 		else
 			val->intval = POWER_SUPPLY_HEALTH_GOOD;
 	}
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 14/19] power: supply: sbs-battery: fix idle battery status
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (12 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 13/19] power: supply: sbs-battery: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED support Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 15/19] power: supply: sbs-battery: add ability to disable charger broadcasts Sebastian Reichel
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

A battery, that is neither charged, nor discharged is not
always Full. If the charger is disabled for other reasons
it might simply be idle and should be marked accordingly.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 2a2b926ad75c..e3c685b2c247 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -354,9 +354,9 @@ static int sbs_status_correct(struct i2c_client *client, int *intval)
 
 	ret = (s16)ret;
 
-	/* Not drawing current means full (cannot be not charging) */
-	if (ret == 0)
-		*intval = POWER_SUPPLY_STATUS_FULL;
+	/* Not drawing current -> not charging (i.e. idle) */
+	if (*intval != POWER_SUPPLY_STATUS_FULL && ret == 0)
+		*intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
 
 	if (*intval == POWER_SUPPLY_STATUS_FULL) {
 		/* Drawing or providing current when full */
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 15/19] power: supply: sbs-battery: add ability to disable charger broadcasts
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (13 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 14/19] power: supply: sbs-battery: fix idle battery status Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-15 14:57   ` Emil Velikov
  2020-05-13 18:56 ` [PATCHv1 16/19] power: supply: sbs-battery: switch from of_property_* to device_property_* Sebastian Reichel
                   ` (6 subsequent siblings)
  21 siblings, 1 reply; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel,
	Jean-Francois Dagenais, Sebastian Reichel

From: Jean-Francois Dagenais <jeff.dagenais@gmail.com>

In certain designs, it is possible to add a battery on a populated i2c
bus without an sbs compliant charger. In that case, the battery will
un-necessarily and sometimes un-desirably master the bus trying to write
info in the charger.

It is observed in many occasion that these battery "broadcasts" are even
corrupting other ongoing master to slave communication. I.e. the
multi-master support in the battery is inadequate.

Thankfully, the CHARGER_MODE bit allows designers to disable that SBS
battery behaviour.

This needs to be done once when the battery is first seen on the bus.

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
[rebased code]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 .../bindings/power/supply/sbs_sbs-battery.txt |  2 ++
 drivers/power/supply/sbs-battery.c            | 29 +++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt b/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
index fa5a8b516dbf..a5093ccef5c5 100644
--- a/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
+++ b/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
@@ -16,6 +16,7 @@ Optional properties :
    after an external change notification.
  - sbs,battery-detect-gpios : The gpio which signals battery detection and
    a flag specifying its polarity.
+ - sbs,disable-charger-broadcasts: for systems without sbs compliant chargers
 
 Example:
 
@@ -25,4 +26,5 @@ Example:
 		sbs,i2c-retry-count = <2>;
 		sbs,poll-retry-count = <10>;
 		sbs,battery-detect-gpios = <&gpio-controller 122 1>;
+		sbs,disable-charger-broadcasts;
 	}
diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index e3c685b2c247..7c6905a486da 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -68,6 +68,7 @@ enum sbs_capacity_mode {
 	CAPACITY_MODE_AMPS = 0,
 	CAPACITY_MODE_WATTS = BATTERY_MODE_CAPACITY_MASK
 };
+#define BATTERY_MODE_CHARGER_MASK	(1<<14)
 
 /* manufacturer access defines */
 #define MANUFACTURER_ACCESS_STATUS	0x0006
@@ -193,6 +194,7 @@ struct sbs_info {
 	bool				is_present;
 	struct gpio_desc		*gpio_detect;
 	bool				enable_detection;
+	bool				charger_broadcasts;
 	int				last_state;
 	int				poll_time;
 	u32				i2c_retry_count;
@@ -207,6 +209,27 @@ static char manufacturer[I2C_SMBUS_BLOCK_MAX + 1];
 static char chemistry[I2C_SMBUS_BLOCK_MAX + 1];
 static bool force_load;
 
+static int sbs_read_word_data(struct i2c_client *client, u8 address);
+static int sbs_write_word_data(struct i2c_client *client, u8 address, u16 value);
+
+static void sbs_disable_charger_broadcasts(struct sbs_info *chip)
+{
+	int val = sbs_read_word_data(chip->client, BATTERY_MODE_OFFSET);
+	if (val < 0)
+		goto exit;
+
+	val |= BATTERY_MODE_CHARGER_MASK;
+
+	val = sbs_write_word_data(chip->client, BATTERY_MODE_OFFSET, val);
+
+exit:
+	if (val < 0)
+		dev_err(&chip->client->dev,
+			"Failed to disable charger broadcasting: %d\n", val);
+	else
+		dev_dbg(&chip->client->dev, "%s\n", __func__);
+}
+
 static int sbs_update_presence(struct sbs_info *chip, bool is_present)
 {
 	struct i2c_client *client = chip->client;
@@ -260,6 +283,9 @@ static int sbs_update_presence(struct sbs_info *chip, bool is_present)
 	dev_dbg(&client->dev, "PEC: %s\n", (client->flags & I2C_CLIENT_PEC) ?
 		"enabled" : "disabled");
 
+	if (!chip->is_present && is_present && !chip->charger_broadcasts)
+		sbs_disable_charger_broadcasts(chip);
+
 	chip->is_present = true;
 
 	return 0;
@@ -1017,6 +1043,9 @@ static int sbs_probe(struct i2c_client *client,
 	}
 	chip->i2c_retry_count = chip->i2c_retry_count + 1;
 
+	chip->charger_broadcasts = !of_property_read_bool(client->dev.of_node,
+					"sbs,disable-charger-broadcasts");
+
 	chip->gpio_detect = devm_gpiod_get_optional(&client->dev,
 			"sbs,battery-detect", GPIOD_IN);
 	if (IS_ERR(chip->gpio_detect)) {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 16/19] power: supply: sbs-battery: switch from of_property_* to device_property_*
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (14 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 15/19] power: supply: sbs-battery: add ability to disable charger broadcasts Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 17/19] power: supply: sbs-battery: switch to i2c's probe_new Sebastian Reichel
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Switch from DT specific of_property_* API to generic and more
modern device_property_* API.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 7c6905a486da..73dfe526c867 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -14,7 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/property.h>
 #include <linux/of_device.h>
 #include <linux/power/sbs-battery.h>
 #include <linux/power_supply.h>
@@ -1016,7 +1016,7 @@ static int sbs_probe(struct i2c_client *client,
 	if (!chip)
 		return -ENOMEM;
 
-	chip->flags = (u32)(uintptr_t)of_device_get_match_data(&client->dev);
+	chip->flags = (u32)(uintptr_t)device_get_match_data(&client->dev);
 	chip->client = client;
 	chip->enable_detection = false;
 	psy_cfg.of_node = client->dev.of_node;
@@ -1027,13 +1027,13 @@ static int sbs_probe(struct i2c_client *client,
 	/* use pdata if available, fall back to DT properties,
 	 * or hardcoded defaults if not
 	 */
-	rc = of_property_read_u32(client->dev.of_node, "sbs,i2c-retry-count",
-				  &chip->i2c_retry_count);
+	rc = device_property_read_u32(&client->dev, "sbs,i2c-retry-count",
+				      &chip->i2c_retry_count);
 	if (rc)
 		chip->i2c_retry_count = 0;
 
-	rc = of_property_read_u32(client->dev.of_node, "sbs,poll-retry-count",
-				  &chip->poll_retry_count);
+	rc = device_property_read_u32(&client->dev, "sbs,poll-retry-count",
+				      &chip->poll_retry_count);
 	if (rc)
 		chip->poll_retry_count = 0;
 
@@ -1043,7 +1043,7 @@ static int sbs_probe(struct i2c_client *client,
 	}
 	chip->i2c_retry_count = chip->i2c_retry_count + 1;
 
-	chip->charger_broadcasts = !of_property_read_bool(client->dev.of_node,
+	chip->charger_broadcasts = !device_property_read_bool(&client->dev,
 					"sbs,disable-charger-broadcasts");
 
 	chip->gpio_detect = devm_gpiod_get_optional(&client->dev,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 17/19] power: supply: sbs-battery: switch to i2c's probe_new
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (15 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 16/19] power: supply: sbs-battery: switch from of_property_* to device_property_* Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 18/19] power: supply: sbs-battery: constify power-supply property array Sebastian Reichel
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

sbs-battery does not use the ID parameter, so switch to i2c's
probe_new API.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index 73dfe526c867..f0392be350eb 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -992,8 +992,7 @@ static const struct power_supply_desc sbs_default_desc = {
 	.external_power_changed = sbs_external_power_changed,
 };
 
-static int sbs_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
+static int sbs_probe(struct i2c_client *client)
 {
 	struct sbs_info *chip;
 	struct power_supply_desc *sbs_desc;
@@ -1172,7 +1171,7 @@ static const struct of_device_id sbs_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, sbs_dt_ids);
 
 static struct i2c_driver sbs_battery_driver = {
-	.probe		= sbs_probe,
+	.probe_new	= sbs_probe,
 	.remove		= sbs_remove,
 	.alert		= sbs_alert,
 	.id_table	= sbs_id,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 18/19] power: supply: sbs-battery: constify power-supply property array
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (16 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 17/19] power: supply: sbs-battery: switch to i2c's probe_new Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-13 18:56 ` [PATCHv1 19/19] dt-bindings: power: sbs-battery: Convert to yaml Sebastian Reichel
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/power/supply/sbs-battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index f0392be350eb..f4f73e669460 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -151,7 +151,7 @@ static const struct chip_data {
 		SBS_DATA(POWER_SUPPLY_PROP_TECHNOLOGY, 0x22, 0, 65535)
 };
 
-static enum power_supply_property sbs_properties[] = {
+static const enum power_supply_property sbs_properties[] = {
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_CAPACITY_LEVEL,
 	POWER_SUPPLY_PROP_HEALTH,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCHv1 19/19] dt-bindings: power: sbs-battery: Convert to yaml
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (17 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 18/19] power: supply: sbs-battery: constify power-supply property array Sebastian Reichel
@ 2020-05-13 18:56 ` Sebastian Reichel
  2020-05-28  2:40   ` Rob Herring
  2020-05-28 22:44 ` [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (2 subsequent siblings)
  21 siblings, 1 reply; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-13 18:56 UTC (permalink / raw)
  To: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, Sebastian Reichel

Convert sbs-battery bindings to YAML.

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 .../power/supply/sbs,sbs-battery.yaml         | 83 +++++++++++++++++++
 .../bindings/power/supply/sbs_sbs-battery.txt | 30 -------
 2 files changed, 83 insertions(+), 30 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/power/supply/sbs,sbs-battery.yaml
 delete mode 100644 Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt

diff --git a/Documentation/devicetree/bindings/power/supply/sbs,sbs-battery.yaml b/Documentation/devicetree/bindings/power/supply/sbs,sbs-battery.yaml
new file mode 100644
index 000000000000..205bc826bd20
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/sbs,sbs-battery.yaml
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/sbs,sbs-battery.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SBS compliant battery
+
+maintainers:
+  - Sebastian Reichel <sre@kernel.org>
+
+description: |
+  Battery compatible with the smart battery system specifications
+
+properties:
+
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - ti,bq20z65
+              - ti,bq20z75
+          - enum:
+              - sbs,sbs-battery
+      - items:
+          - const: sbs,sbs-battery
+
+  reg:
+    maxItems: 1
+
+  sbs,i2c-retry-count:
+    description:
+      The number of times to retry I2C transactions on I2C IO failure.
+    default: 0
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+
+  sbs,poll-retry-count:
+    description:
+      The number of times to try looking for new status after an external
+      change notification.
+    default: 0
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+
+  sbs,battery-detect-gpios:
+    description:
+      GPIO which signals battery detection. If this is not supplied, the bus
+      needs to be polled to detect the battery.
+    maxItems: 1
+
+  sbs,disable-charger-broadcasts:
+    description:
+      SBS batteries by default send broadcast messages to SBS compliant chargers to
+      configure max. charge current/voltage. If your hardware does not have an SBS
+      compliant charger it should be disabled via this property to avoid blocking
+      the bus. Also some SBS battery fuel gauges are known to have a buggy multi-
+      master implementation.
+    type: boolean
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        battery@b {
+            compatible = "ti,bq20z75", "sbs,sbs-battery";
+            reg = <0xb>;
+            sbs,i2c-retry-count = <2>;
+            sbs,poll-retry-count = <10>;
+            sbs,battery-detect-gpios = <&gpio 122 GPIO_ACTIVE_HIGH>;
+            sbs,disable-charger-broadcasts;
+       };
+    };
diff --git a/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt b/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
deleted file mode 100644
index a5093ccef5c5..000000000000
--- a/Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-SBS sbs-battery
-~~~~~~~~~~
-
-Required properties :
- - compatible: "<vendor>,<part-number>", "sbs,sbs-battery" as fallback. The
-     part number compatible string might be used in order to take care of
-     vendor specific registers.
-     Known <vendor>,<part-number>:
-       ti,bq20z65
-       ti,bq20z75
-
-Optional properties :
- - sbs,i2c-retry-count : The number of times to retry i2c transactions on i2c
-   IO failure.
- - sbs,poll-retry-count : The number of times to try looking for new status
-   after an external change notification.
- - sbs,battery-detect-gpios : The gpio which signals battery detection and
-   a flag specifying its polarity.
- - sbs,disable-charger-broadcasts: for systems without sbs compliant chargers
-
-Example:
-
-	battery@b {
-		compatible = "ti,bq20z75", "sbs,sbs-battery";
-		reg = <0xb>;
-		sbs,i2c-retry-count = <2>;
-		sbs,poll-retry-count = <10>;
-		sbs,battery-detect-gpios = <&gpio-controller 122 1>;
-		sbs,disable-charger-broadcasts;
-	}
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 01/19] kobject: increase allowed number of uevent variables
  2020-05-13 18:55 ` [PATCHv1 01/19] kobject: increase allowed number of uevent variables Sebastian Reichel
@ 2020-05-14  6:11   ` Greg Kroah-Hartman
  2020-05-15 14:45   ` Emil Velikov
  1 sibling, 0 replies; 37+ messages in thread
From: Greg Kroah-Hartman @ 2020-05-14  6:11 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Rob Herring, Rafael J . Wysocki, linux-pm,
	devicetree, linux-kernel, kernel

On Wed, May 13, 2020 at 08:55:57PM +0200, Sebastian Reichel wrote:
> SBS battery driver exposes 32 power supply properties now,
> which will result in uevent failure on (un)plugging the
> battery. Other drivers (e.g. bq27xxx) are also coming close
> to this limit, so increase it.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  include/linux/kobject.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/kobject.h b/include/linux/kobject.h
> index e2ca0a292e21..75e822569e39 100644
> --- a/include/linux/kobject.h
> +++ b/include/linux/kobject.h
> @@ -29,7 +29,7 @@
>  #include <linux/uidgid.h>
>  
>  #define UEVENT_HELPER_PATH_LEN		256
> -#define UEVENT_NUM_ENVP			32	/* number of env pointers */
> +#define UEVENT_NUM_ENVP			64	/* number of env pointers */
>  #define UEVENT_BUFFER_SIZE		2048	/* buffer for the variables */
>  
>  #ifdef CONFIG_UEVENT_HELPER

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 01/19] kobject: increase allowed number of uevent variables
  2020-05-13 18:55 ` [PATCHv1 01/19] kobject: increase allowed number of uevent variables Sebastian Reichel
  2020-05-14  6:11   ` Greg Kroah-Hartman
@ 2020-05-15 14:45   ` Emil Velikov
  1 sibling, 0 replies; 37+ messages in thread
From: Emil Velikov @ 2020-05-15 14:45 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman,
	Rafael J . Wysocki, linux-pm, devicetree, linux-kernel, kernel

On 2020/05/13, Sebastian Reichel wrote:
> SBS battery driver exposes 32 power supply properties now,
> which will result in uevent failure on (un)plugging the
> battery. Other drivers (e.g. bq27xxx) are also coming close
> to this limit, so increase it.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  include/linux/kobject.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/kobject.h b/include/linux/kobject.h
> index e2ca0a292e21..75e822569e39 100644
> --- a/include/linux/kobject.h
> +++ b/include/linux/kobject.h
> @@ -29,7 +29,7 @@
>  #include <linux/uidgid.h>
>  
>  #define UEVENT_HELPER_PATH_LEN		256
> -#define UEVENT_NUM_ENVP			32	/* number of env pointers */
> +#define UEVENT_NUM_ENVP			64	/* number of env pointers */

To be on the safe side I've checked systemd/udev. It's using ordered hashmap,
so it's perfectly capable of handling the extra entries.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>

-Emil

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 03/19] power: supply: core: add manufacture date properties
  2020-05-13 18:55 ` [PATCHv1 03/19] power: supply: core: add manufacture date properties Sebastian Reichel
@ 2020-05-15 14:47   ` Emil Velikov
  2020-05-15 15:14     ` Sebastian Reichel
  0 siblings, 1 reply; 37+ messages in thread
From: Emil Velikov @ 2020-05-15 14:47 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman,
	Rafael J . Wysocki, linux-pm, devicetree, linux-kernel, kernel

Hi Sebastian,

On 2020/05/13, Sebastian Reichel wrote:
> Some smart batteries store their manufacture date, which is
> useful to identify the battery and/or to know about the cell
> quality.
> 
Have you considered exposing this as a single file? Say following the ISO8601
format - YYYY-MM-DD.

-Emil

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 15/19] power: supply: sbs-battery: add ability to disable charger broadcasts
  2020-05-13 18:56 ` [PATCHv1 15/19] power: supply: sbs-battery: add ability to disable charger broadcasts Sebastian Reichel
@ 2020-05-15 14:57   ` Emil Velikov
  0 siblings, 0 replies; 37+ messages in thread
From: Emil Velikov @ 2020-05-15 14:57 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman,
	Rafael J . Wysocki, linux-pm, devicetree, linux-kernel, kernel,
	Jean-Francois Dagenais

On 2020/05/13, Sebastian Reichel wrote:
> From: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
> 
> In certain designs, it is possible to add a battery on a populated i2c
> bus without an sbs compliant charger. In that case, the battery will
> un-necessarily and sometimes un-desirably master the bus trying to write
> info in the charger.

Nit: s/un-/un/

> 
> It is observed in many occasion that these battery "broadcasts" are even
> corrupting other ongoing master to slave communication. I.e. the
> multi-master support in the battery is inadequate.
> 
> Thankfully, the CHARGER_MODE bit allows designers to disable that SBS
> battery behaviour.
> 
> This needs to be done once when the battery is first seen on the bus.
> 
> Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
> [rebased code]
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---

> @@ -1017,6 +1043,9 @@ static int sbs_probe(struct i2c_client *client,
>  	}
>  	chip->i2c_retry_count = chip->i2c_retry_count + 1;
>  
> +	chip->charger_broadcasts = !of_property_read_bool(client->dev.of_node,
> +					"sbs,disable-charger-broadcasts");
> +
This patch adds the of_property_read, only for it to be replaced in the next
patch. Consider flipping the patch order?

-Emil

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 03/19] power: supply: core: add manufacture date properties
  2020-05-15 14:47   ` Emil Velikov
@ 2020-05-15 15:14     ` Sebastian Reichel
  2020-05-15 16:01       ` Emil Velikov
  0 siblings, 1 reply; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-15 15:14 UTC (permalink / raw)
  To: Emil Velikov; +Cc: linux-pm, devicetree, linux-kernel, kernel

[-- Attachment #1: Type: text/plain, Size: 725 bytes --]

Hi,

On Fri, May 15, 2020 at 03:47:32PM +0100, Emil Velikov wrote:
> On 2020/05/13, Sebastian Reichel wrote:
> > Some smart batteries store their manufacture date, which is
> > useful to identify the battery and/or to know about the cell
> > quality.
> > 
> Have you considered exposing this as a single file? Say following
> the ISO8601 format - YYYY-MM-DD.

Yes. My initial implementation was exactly that. The thing is, that
I suspect some fuel gauge implementations may only expose the year
or just year + month. I chose 3 files, since receiving 'YYYY-MM'
instead of full ISO code might be more unexpected than not having
the DAY file available. But I don't have a strong opinion on this.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 13/19] power: supply: sbs-battery: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED support
  2020-05-13 18:56 ` [PATCHv1 13/19] power: supply: sbs-battery: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED support Sebastian Reichel
@ 2020-05-15 15:35   ` Emil Velikov
  0 siblings, 0 replies; 37+ messages in thread
From: Emil Velikov @ 2020-05-15 15:35 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman,
	Rafael J . Wysocki, linux-pm, devicetree, linux-kernel, kernel

On 2020/05/13, Sebastian Reichel wrote:
> Add support for reporting the SBS battery's condition flag
> to userspace using the new "Calibration required" health status.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  drivers/power/supply/sbs-battery.c | 27 ++++++++++++++++++++++++---
>  1 file changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
> index 4fa553d61db2..2a2b926ad75c 100644
> --- a/drivers/power/supply/sbs-battery.c
> +++ b/drivers/power/supply/sbs-battery.c
> @@ -23,6 +23,7 @@
>  
>  enum {
>  	REG_MANUFACTURER_DATA,
> +	REG_BATTERY_MODE,
>  	REG_TEMPERATURE,
>  	REG_VOLTAGE,
>  	REG_CURRENT_NOW,
> @@ -94,6 +95,8 @@ static const struct chip_data {
>  } sbs_data[] = {
>  	[REG_MANUFACTURER_DATA] =
>  		SBS_DATA(POWER_SUPPLY_PROP_PRESENT, 0x00, 0, 65535),
> +	[REG_BATTERY_MODE] =
> +		SBS_DATA(-1, 0x03, 0, 65535),

Fwiw I really like how neatly the driver is split into components. One thing
which makes me wonder, have you considered reshuffling the sbs_data struct.

In particular:
 - index POWER_SUPPLY_PROP, kill off the REG_ enum
   - sbs_get_property_index() can go, alongside a couple of unreachable paths
   - replace batter_mode (needs calibration) with with PROP_HEALTH + comment
   - perhaps even add REG_ADDR_SPEC_INFO 0x1a under POWER_SUPPLY_PROP_PRESENT
 - using the min/max seems wasteful, considering only one register is in s16
   range while everything else is within u16


Regardless of the questions and trivial suggestions, the series looks spot on.

For the lot:
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>


-Emil
P.S. The reg table is nearly complete only 0x01-0x07, 0x0E, 0x11, 0x1d-0x1f
remain o/

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 03/19] power: supply: core: add manufacture date properties
  2020-05-15 15:14     ` Sebastian Reichel
@ 2020-05-15 16:01       ` Emil Velikov
  0 siblings, 0 replies; 37+ messages in thread
From: Emil Velikov @ 2020-05-15 16:01 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: linux-pm, devicetree, linux-kernel, kernel

On 2020/05/15, Sebastian Reichel wrote:
> Hi,
> 
> On Fri, May 15, 2020 at 03:47:32PM +0100, Emil Velikov wrote:
> > On 2020/05/13, Sebastian Reichel wrote:
> > > Some smart batteries store their manufacture date, which is
> > > useful to identify the battery and/or to know about the cell
> > > quality.
> > > 
> > Have you considered exposing this as a single file? Say following
> > the ISO8601 format - YYYY-MM-DD.
> 
> Yes. My initial implementation was exactly that. The thing is, that
> I suspect some fuel gauge implementations may only expose the year
> or just year + month. I chose 3 files, since receiving 'YYYY-MM'
> instead of full ISO code might be more unexpected than not having
> the DAY file available. But I don't have a strong opinion on this.
> 
Fwiw the ISO 8601 allows for YYYY-MM, although you're spot on. Having
the three fields separate makes perfect sense.

Thanks
Emil


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 05/19] power: supply: sbs-battery: Add TI BQ20Z65 support
  2020-05-13 18:56 ` [PATCHv1 05/19] power: supply: sbs-battery: Add TI BQ20Z65 support Sebastian Reichel
@ 2020-05-28  2:37   ` Rob Herring
  0 siblings, 0 replies; 37+ messages in thread
From: Rob Herring @ 2020-05-28  2:37 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Rafael J . Wysocki, kernel, devicetree, Greg Kroah-Hartman,
	linux-pm, linux-kernel, Rob Herring, Sebastian Reichel

On Wed, 13 May 2020 20:56:01 +0200, Sebastian Reichel wrote:
> Add support for BQ20Z65 manufacturer data to the sbs-battery
> driver. Implementation has been verified using the public TRM
> available from [0] and tested using a GE Flex 3S2P battery.
> 
> [0] http://www.ti.com/lit/pdf/sluu386
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  .../bindings/power/supply/sbs_sbs-battery.txt     |  1 +
>  drivers/power/supply/sbs-battery.c                | 15 ++++++++++-----
>  2 files changed, 11 insertions(+), 5 deletions(-)
> 

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 19/19] dt-bindings: power: sbs-battery: Convert to yaml
  2020-05-13 18:56 ` [PATCHv1 19/19] dt-bindings: power: sbs-battery: Convert to yaml Sebastian Reichel
@ 2020-05-28  2:40   ` Rob Herring
  0 siblings, 0 replies; 37+ messages in thread
From: Rob Herring @ 2020-05-28  2:40 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Rob Herring, kernel, Rafael J . Wysocki, devicetree,
	Greg Kroah-Hartman, Sebastian Reichel, linux-pm, linux-kernel

On Wed, 13 May 2020 20:56:15 +0200, Sebastian Reichel wrote:
> Convert sbs-battery bindings to YAML.
> 
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  .../power/supply/sbs,sbs-battery.yaml         | 83 +++++++++++++++++++
>  .../bindings/power/supply/sbs_sbs-battery.txt | 30 -------
>  2 files changed, 83 insertions(+), 30 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/power/supply/sbs,sbs-battery.yaml
>  delete mode 100644 Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 00/19] Improve SBS battery support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (18 preceding siblings ...)
  2020-05-13 18:56 ` [PATCHv1 19/19] dt-bindings: power: sbs-battery: Convert to yaml Sebastian Reichel
@ 2020-05-28 22:44 ` Sebastian Reichel
  2020-05-29 16:27 ` Pavel Machek
       [not found] ` <CGME20200601104027eucas1p2b076ee860520d709e8178c41550653f7@eucas1p2.samsung.com>
  21 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-05-28 22:44 UTC (permalink / raw)
  To: Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel

[-- Attachment #1: Type: text/plain, Size: 4042 bytes --]

Hi,

I queued this series to power-supply's for-next branch.

-- Sebastian

On Wed, May 13, 2020 at 08:55:56PM +0200, Sebastian Reichel wrote:
> This patchset improves support for SBS compliant batteries. Due to
> the changes, the battery now exposes 32 power supply properties and
> (un)plugging it generates a backtrace containing the following message
> without the first patch in this series:
> 
> ---------------------------
> WARNING: CPU: 0 PID: 20 at lib/kobject_uevent.c:659 add_uevent_var+0xd4/0x104
> add_uevent_var: too many keys
> ---------------------------
> 
> For references this is what an SBS battery status looks like after
> the patch series has been applied:
> 
> cat /sys/class/power_supply/sbs-0-000b/uevent 
> POWER_SUPPLY_NAME=sbs-0-000b
> POWER_SUPPLY_TYPE=Battery
> POWER_SUPPLY_STATUS=Discharging
> POWER_SUPPLY_CAPACITY_LEVEL=Normal
> POWER_SUPPLY_HEALTH=Good
> POWER_SUPPLY_PRESENT=1
> POWER_SUPPLY_TECHNOLOGY=Li-ion
> POWER_SUPPLY_CYCLE_COUNT=12
> POWER_SUPPLY_VOLTAGE_NOW=11441000
> POWER_SUPPLY_CURRENT_NOW=-26000
> POWER_SUPPLY_CURRENT_AVG=-24000
> POWER_SUPPLY_CAPACITY=76
> POWER_SUPPLY_CAPACITY_ERROR_MARGIN=1
> POWER_SUPPLY_TEMP=198
> POWER_SUPPLY_TIME_TO_EMPTY_AVG=438600
> POWER_SUPPLY_TIME_TO_FULL_AVG=3932100
> POWER_SUPPLY_SERIAL_NUMBER=0000
> POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
> POWER_SUPPLY_VOLTAGE_MAX_DESIGN=10800000
> POWER_SUPPLY_ENERGY_NOW=31090000
> POWER_SUPPLY_ENERGY_FULL=42450000
> POWER_SUPPLY_ENERGY_FULL_DESIGN=41040000
> POWER_SUPPLY_CHARGE_NOW=2924000
> POWER_SUPPLY_CHARGE_FULL=3898000
> POWER_SUPPLY_CHARGE_FULL_DESIGN=3800000
> POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=3000000
> POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE_MAX=12300000
> POWER_SUPPLY_MANUFACTURE_YEAR=2017
> POWER_SUPPLY_MANUFACTURE_MONTH=7
> POWER_SUPPLY_MANUFACTURE_DAY=3
> POWER_SUPPLY_MANUFACTURER=UR18650A
> POWER_SUPPLY_MODEL_NAME=GEHC
> 
> -- Sebastian
> 
> Jean-Francois Dagenais (1):
>   power: supply: sbs-battery: add ability to disable charger broadcasts
> 
> Sebastian Reichel (18):
>   kobject: increase allowed number of uevent variables
>   power: supply: core: add capacity error margin property
>   power: supply: core: add manufacture date properties
>   power: supply: core: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED
>   power: supply: sbs-battery: Add TI BQ20Z65 support
>   power: supply: sbs-battery: add
>     POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN support
>   power: supply: sbs-battery: simplify read_read_string_data
>   power: supply: sbs-battery: add PEC support
>   power: supply: sbs-battery: add POWER_SUPPLY_PROP_CURRENT_AVG support
>   power: supply: sbs-battery: Improve POWER_SUPPLY_PROP_TECHNOLOGY
>     support
>   power: supply: sbs-battery: add
>     POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT/VOLTAGE_MAX support
>   power: supply: sbs-battery: add MANUFACTURE_DATE support
>   power: supply: sbs-battery: add
>     POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED support
>   power: supply: sbs-battery: fix idle battery status
>   power: supply: sbs-battery: switch from of_property_* to
>     device_property_*
>   power: supply: sbs-battery: switch to i2c's probe_new
>   power: supply: sbs-battery: constify power-supply property array
>   dt-bindings: power: sbs-battery: Convert to yaml
> 
>  Documentation/ABI/testing/sysfs-class-power   |  45 ++-
>  .../power/supply/sbs,sbs-battery.yaml         |  83 +++++
>  .../bindings/power/supply/sbs_sbs-battery.txt |  27 --
>  drivers/power/supply/power_supply_sysfs.c     |   5 +
>  drivers/power/supply/sbs-battery.c            | 348 +++++++++++++-----
>  include/linux/kobject.h                       |   2 +-
>  include/linux/power_supply.h                  |   5 +
>  7 files changed, 404 insertions(+), 111 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/power/supply/sbs,sbs-battery.yaml
>  delete mode 100644 Documentation/devicetree/bindings/power/supply/sbs_sbs-battery.txt
> 
> -- 
> 2.26.2
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 00/19] Improve SBS battery support
  2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
                   ` (19 preceding siblings ...)
  2020-05-28 22:44 ` [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
@ 2020-05-29 16:27 ` Pavel Machek
  2020-06-01 21:57   ` Sebastian Reichel
       [not found] ` <CGME20200601104027eucas1p2b076ee860520d709e8178c41550653f7@eucas1p2.samsung.com>
  21 siblings, 1 reply; 37+ messages in thread
From: Pavel Machek @ 2020-05-29 16:27 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Rob Herring, Greg Kroah-Hartman,
	Rafael J . Wysocki, linux-pm, devicetree, linux-kernel, kernel

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

Hi!

> This patchset improves support for SBS compliant batteries. Due to
> the changes, the battery now exposes 32 power supply properties and
> (un)plugging it generates a backtrace containing the following message
> without the first patch in this series:
> 
> ---------------------------
> WARNING: CPU: 0 PID: 20 at lib/kobject_uevent.c:659 add_uevent_var+0xd4/0x104
> add_uevent_var: too many keys
> ---------------------------
> 
> For references this is what an SBS battery status looks like after
> the patch series has been applied:
> 
> POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
> POWER_SUPPLY_VOLTAGE_MAX_DESIGN=10800000

Is that correct, BTW? sounds like these should not be equal...

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 00/19] Improve SBS battery support
       [not found] ` <CGME20200601104027eucas1p2b076ee860520d709e8178c41550653f7@eucas1p2.samsung.com>
@ 2020-06-01 10:40   ` Marek Szyprowski
  2020-06-01 17:05     ` Sebastian Reichel
  0 siblings, 1 reply; 37+ messages in thread
From: Marek Szyprowski @ 2020-06-01 10:40 UTC (permalink / raw)
  To: Sebastian Reichel, Sebastian Reichel, Rob Herring,
	Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: linux-pm, devicetree, linux-kernel, kernel, 'Linux Samsung SOC'

Hi Sebastian,

On 13.05.2020 20:55, Sebastian Reichel wrote:
> This patchset improves support for SBS compliant batteries. Due to
> the changes, the battery now exposes 32 power supply properties and
> (un)plugging it generates a backtrace containing the following message
> without the first patch in this series:
>
> ---------------------------
> WARNING: CPU: 0 PID: 20 at lib/kobject_uevent.c:659 add_uevent_var+0xd4/0x104
> add_uevent_var: too many keys
> ---------------------------
>
> For references this is what an SBS battery status looks like after
> the patch series has been applied:
>
> cat /sys/class/power_supply/sbs-0-000b/uevent
> POWER_SUPPLY_NAME=sbs-0-000b
> POWER_SUPPLY_TYPE=Battery
> POWER_SUPPLY_STATUS=Discharging
> POWER_SUPPLY_CAPACITY_LEVEL=Normal
> POWER_SUPPLY_HEALTH=Good
> POWER_SUPPLY_PRESENT=1
> POWER_SUPPLY_TECHNOLOGY=Li-ion
> POWER_SUPPLY_CYCLE_COUNT=12
> POWER_SUPPLY_VOLTAGE_NOW=11441000
> POWER_SUPPLY_CURRENT_NOW=-26000
> POWER_SUPPLY_CURRENT_AVG=-24000
> POWER_SUPPLY_CAPACITY=76
> POWER_SUPPLY_CAPACITY_ERROR_MARGIN=1
> POWER_SUPPLY_TEMP=198
> POWER_SUPPLY_TIME_TO_EMPTY_AVG=438600
> POWER_SUPPLY_TIME_TO_FULL_AVG=3932100
> POWER_SUPPLY_SERIAL_NUMBER=0000
> POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
> POWER_SUPPLY_VOLTAGE_MAX_DESIGN=10800000
> POWER_SUPPLY_ENERGY_NOW=31090000
> POWER_SUPPLY_ENERGY_FULL=42450000
> POWER_SUPPLY_ENERGY_FULL_DESIGN=41040000
> POWER_SUPPLY_CHARGE_NOW=2924000
> POWER_SUPPLY_CHARGE_FULL=3898000
> POWER_SUPPLY_CHARGE_FULL_DESIGN=3800000
> POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=3000000
> POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE_MAX=12300000
> POWER_SUPPLY_MANUFACTURE_YEAR=2017
> POWER_SUPPLY_MANUFACTURE_MONTH=7
> POWER_SUPPLY_MANUFACTURE_DAY=3
> POWER_SUPPLY_MANUFACTURER=UR18650A
> POWER_SUPPLY_MODEL_NAME=GEHC

This patch landed in linux-next dated 20200529. Sadly it causes a 
regression on Samsung Exynos-based Chromebooks (Exynos5250 Snow, 
Exynos5420 Peach-Pi and Exynos5800 Peach-Pit). System boots to 
userspace, but then, when udev populates /dev, booting hangs:

[    4.435167] VFS: Mounted root (ext4 filesystem) readonly on device 
179:51.
[    4.457477] devtmpfs: mounted
[    4.460235] Freeing unused kernel memory: 1024K
[    4.464022] Run /sbin/init as init process
INIT: version 2.88 booting
[info] Using makefile-style concurrent boot in runlevel S.
[    5.102096] random: crng init done
[....] Starting the hotplug events dispatcher: systemd-udevdstarting 
version 236
[ ok .
[....] Synthesizing the initial hotplug events...[ ok done.
[....] Waiting for /dev to be fully populated...[   34.409914] 
TPS65090_RAILSDCDC1: disabling
[   34.412977] TPS65090_RAILSDCDC2: disabling
[   34.417021] TPS65090_RAILSDCDC3: disabling
[   34.423848] TPS65090_RAILSLDO1: disabling
[   34.429068] TPS65090_RAILSLDO2: disabling

Bisect between v5.7-rc1 and next-20200529 pointed me to the first bad 
commit: [c4b12a2f3f3de670f6be5e96092a2cab0b877f1a] power: supply: 
sbs-battery: simplify read_read_string_data. However reverting it in 
linux-next doesn't fix the issue, so the next commits are also relevant 
to this issue.

Let me know how can I help debugging it.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 00/19] Improve SBS battery support
  2020-06-01 10:40   ` Marek Szyprowski
@ 2020-06-01 17:05     ` Sebastian Reichel
  2020-06-02  7:17       ` Marek Szyprowski
  0 siblings, 1 reply; 37+ messages in thread
From: Sebastian Reichel @ 2020-06-01 17:05 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki, linux-pm,
	devicetree, linux-kernel, kernel, 'Linux Samsung SOC'

[-- Attachment #1: Type: text/plain, Size: 4774 bytes --]

Hi Marek,

On Mon, Jun 01, 2020 at 12:40:27PM +0200, Marek Szyprowski wrote:
> On 13.05.2020 20:55, Sebastian Reichel wrote:
> > This patchset improves support for SBS compliant batteries. Due to
> > the changes, the battery now exposes 32 power supply properties and
> > (un)plugging it generates a backtrace containing the following message
> > without the first patch in this series:
> >
> > ---------------------------
> > WARNING: CPU: 0 PID: 20 at lib/kobject_uevent.c:659 add_uevent_var+0xd4/0x104
> > add_uevent_var: too many keys
> > ---------------------------
> >
> > For references this is what an SBS battery status looks like after
> > the patch series has been applied:
> >
> > cat /sys/class/power_supply/sbs-0-000b/uevent
> > POWER_SUPPLY_NAME=sbs-0-000b
> > POWER_SUPPLY_TYPE=Battery
> > POWER_SUPPLY_STATUS=Discharging
> > POWER_SUPPLY_CAPACITY_LEVEL=Normal
> > POWER_SUPPLY_HEALTH=Good
> > POWER_SUPPLY_PRESENT=1
> > POWER_SUPPLY_TECHNOLOGY=Li-ion
> > POWER_SUPPLY_CYCLE_COUNT=12
> > POWER_SUPPLY_VOLTAGE_NOW=11441000
> > POWER_SUPPLY_CURRENT_NOW=-26000
> > POWER_SUPPLY_CURRENT_AVG=-24000
> > POWER_SUPPLY_CAPACITY=76
> > POWER_SUPPLY_CAPACITY_ERROR_MARGIN=1
> > POWER_SUPPLY_TEMP=198
> > POWER_SUPPLY_TIME_TO_EMPTY_AVG=438600
> > POWER_SUPPLY_TIME_TO_FULL_AVG=3932100
> > POWER_SUPPLY_SERIAL_NUMBER=0000
> > POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
> > POWER_SUPPLY_VOLTAGE_MAX_DESIGN=10800000
> > POWER_SUPPLY_ENERGY_NOW=31090000
> > POWER_SUPPLY_ENERGY_FULL=42450000
> > POWER_SUPPLY_ENERGY_FULL_DESIGN=41040000
> > POWER_SUPPLY_CHARGE_NOW=2924000
> > POWER_SUPPLY_CHARGE_FULL=3898000
> > POWER_SUPPLY_CHARGE_FULL_DESIGN=3800000
> > POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=3000000
> > POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE_MAX=12300000
> > POWER_SUPPLY_MANUFACTURE_YEAR=2017
> > POWER_SUPPLY_MANUFACTURE_MONTH=7
> > POWER_SUPPLY_MANUFACTURE_DAY=3
> > POWER_SUPPLY_MANUFACTURER=UR18650A
> > POWER_SUPPLY_MODEL_NAME=GEHC
> 
> This patch landed in linux-next dated 20200529. Sadly it causes a 
> regression on Samsung Exynos-based Chromebooks (Exynos5250 Snow, 
> Exynos5420 Peach-Pi and Exynos5800 Peach-Pit). System boots to 
> userspace, but then, when udev populates /dev, booting hangs:
> 
> [    4.435167] VFS: Mounted root (ext4 filesystem) readonly on device 
> 179:51.
> [    4.457477] devtmpfs: mounted
> [    4.460235] Freeing unused kernel memory: 1024K
> [    4.464022] Run /sbin/init as init process
> INIT: version 2.88 booting
> [info] Using makefile-style concurrent boot in runlevel S.
> [    5.102096] random: crng init done
> [....] Starting the hotplug events dispatcher: systemd-udevdstarting 
> version 236
> [ ok .
> [....] Synthesizing the initial hotplug events...[ ok done.
> [....] Waiting for /dev to be fully populated...[   34.409914] 
> TPS65090_RAILSDCDC1: disabling
> [   34.412977] TPS65090_RAILSDCDC2: disabling
> [   34.417021] TPS65090_RAILSDCDC3: disabling
> [   34.423848] TPS65090_RAILSLDO1: disabling
> [   34.429068] TPS65090_RAILSLDO2: disabling

:(

log does not look useful either.

> Bisect between v5.7-rc1 and next-20200529 pointed me to the first bad 
> commit: [c4b12a2f3f3de670f6be5e96092a2cab0b877f1a] power: supply: 
> sbs-battery: simplify read_read_string_data.

ok. I tested this on an to-be-upstreamed i.MX6 based system
and arch/arm/boot/dts/imx53-ppd.dts. I think the difference
is, that i2c-exynos5 does not expose I2C_FUNC_SMBUS_READ_BLOCK_DATA.
I hoped all systems using SBS battery support this, but now
I see I2C_FUNC_SMBUS_EMUL only supports writing block data.
Looks like I need to add another patch implementing that
using the old code with added PEC support.

In any case that should only return -ENODEV for the property
(and uevent), but not break boot. So something fishy is going
on.

> However reverting it in linux-next doesn't fix the issue, so the
> next commits are also relevant to this issue.

The next patch, which adds PEC support depends on the simplification
of sbs_read_string_data. The old, open coded variant will result in
PEC failure for string properties (which should not stop boot either
of course). Can you try reverting both?

If that helps I will revert those two instead of dropping the whole
series for this merge window.

> Let me know how can I help debugging it.

I suspect, that this is userspace endlessly retrying reading the
battery uevent when an error is returned. Could you check this?
Should be easy to see by adding some printfs.

That would mean a faulty battery could stall complete boot without
a useful error message, which is bad and needs to be fixed.

Sorry for the inconvience and thanks for your report,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 00/19] Improve SBS battery support
  2020-05-29 16:27 ` Pavel Machek
@ 2020-06-01 21:57   ` Sebastian Reichel
  0 siblings, 0 replies; 37+ messages in thread
From: Sebastian Reichel @ 2020-06-01 21:57 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki, linux-pm,
	devicetree, linux-kernel, kernel

[-- Attachment #1: Type: text/plain, Size: 1327 bytes --]

Hi,

On Fri, May 29, 2020 at 06:27:04PM +0200, Pavel Machek wrote:
> > This patchset improves support for SBS compliant batteries. Due to
> > the changes, the battery now exposes 32 power supply properties and
> > (un)plugging it generates a backtrace containing the following message
> > without the first patch in this series:
> > 
> > ---------------------------
> > WARNING: CPU: 0 PID: 20 at lib/kobject_uevent.c:659 add_uevent_var+0xd4/0x104
> > add_uevent_var: too many keys
> > ---------------------------
> > 
> > For references this is what an SBS battery status looks like after
> > the patch series has been applied:
> > 
> > POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
> > POWER_SUPPLY_VOLTAGE_MAX_DESIGN=10800000
> 
> Is that correct, BTW? sounds like these should not be equal...

(Some) GE batteries have weird values stored in the SBS chip.
For example manufacturer and model name are swapped:

POWER_SUPPLY_MANUFACTURER=UR18650A
POWER_SUPPLY_MODEL_NAME=GEHC

I carefully checked manufacturer/model name when writing these
patches some time ago and came to the conclusion that the batteries
do report it the wrong way around.

I will have a look for the design voltages (which are not modified
by this patchset), but I expect this to be another GE specific thing.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 00/19] Improve SBS battery support
  2020-06-01 17:05     ` Sebastian Reichel
@ 2020-06-02  7:17       ` Marek Szyprowski
  2020-06-02 18:01         ` Sebastian Reichel
  0 siblings, 1 reply; 37+ messages in thread
From: Marek Szyprowski @ 2020-06-02  7:17 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki, linux-pm,
	devicetree, linux-kernel, kernel, 'Linux Samsung SOC'

Hi Sebastian,

On 01.06.2020 19:05, Sebastian Reichel wrote:
> On Mon, Jun 01, 2020 at 12:40:27PM +0200, Marek Szyprowski wrote:
>> On 13.05.2020 20:55, Sebastian Reichel wrote:
>>> This patchset improves support for SBS compliant batteries. Due to
>>> the changes, the battery now exposes 32 power supply properties and
>>> (un)plugging it generates a backtrace containing the following message
>>> without the first patch in this series:
>>>
>>> ---------------------------
>>> WARNING: CPU: 0 PID: 20 at lib/kobject_uevent.c:659 add_uevent_var+0xd4/0x104
>>> add_uevent_var: too many keys
>>> ---------------------------
>>>
>>> For references this is what an SBS battery status looks like after
>>> the patch series has been applied:
>>>
>>> cat /sys/class/power_supply/sbs-0-000b/uevent
>>> POWER_SUPPLY_NAME=sbs-0-000b
>>> POWER_SUPPLY_TYPE=Battery
>>> POWER_SUPPLY_STATUS=Discharging
>>> POWER_SUPPLY_CAPACITY_LEVEL=Normal
>>> POWER_SUPPLY_HEALTH=Good
>>> POWER_SUPPLY_PRESENT=1
>>> POWER_SUPPLY_TECHNOLOGY=Li-ion
>>> POWER_SUPPLY_CYCLE_COUNT=12
>>> POWER_SUPPLY_VOLTAGE_NOW=11441000
>>> POWER_SUPPLY_CURRENT_NOW=-26000
>>> POWER_SUPPLY_CURRENT_AVG=-24000
>>> POWER_SUPPLY_CAPACITY=76
>>> POWER_SUPPLY_CAPACITY_ERROR_MARGIN=1
>>> POWER_SUPPLY_TEMP=198
>>> POWER_SUPPLY_TIME_TO_EMPTY_AVG=438600
>>> POWER_SUPPLY_TIME_TO_FULL_AVG=3932100
>>> POWER_SUPPLY_SERIAL_NUMBER=0000
>>> POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
>>> POWER_SUPPLY_VOLTAGE_MAX_DESIGN=10800000
>>> POWER_SUPPLY_ENERGY_NOW=31090000
>>> POWER_SUPPLY_ENERGY_FULL=42450000
>>> POWER_SUPPLY_ENERGY_FULL_DESIGN=41040000
>>> POWER_SUPPLY_CHARGE_NOW=2924000
>>> POWER_SUPPLY_CHARGE_FULL=3898000
>>> POWER_SUPPLY_CHARGE_FULL_DESIGN=3800000
>>> POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=3000000
>>> POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE_MAX=12300000
>>> POWER_SUPPLY_MANUFACTURE_YEAR=2017
>>> POWER_SUPPLY_MANUFACTURE_MONTH=7
>>> POWER_SUPPLY_MANUFACTURE_DAY=3
>>> POWER_SUPPLY_MANUFACTURER=UR18650A
>>> POWER_SUPPLY_MODEL_NAME=GEHC
>> This patch landed in linux-next dated 20200529. Sadly it causes a
>> regression on Samsung Exynos-based Chromebooks (Exynos5250 Snow,
>> Exynos5420 Peach-Pi and Exynos5800 Peach-Pit). System boots to
>> userspace, but then, when udev populates /dev, booting hangs:
>>
>> [    4.435167] VFS: Mounted root (ext4 filesystem) readonly on device
>> 179:51.
>> [    4.457477] devtmpfs: mounted
>> [    4.460235] Freeing unused kernel memory: 1024K
>> [    4.464022] Run /sbin/init as init process
>> INIT: version 2.88 booting
>> [info] Using makefile-style concurrent boot in runlevel S.
>> [    5.102096] random: crng init done
>> [....] Starting the hotplug events dispatcher: systemd-udevdstarting
>> version 236
>> [ ok .
>> [....] Synthesizing the initial hotplug events...[ ok done.
>> [....] Waiting for /dev to be fully populated...[   34.409914]
>> TPS65090_RAILSDCDC1: disabling
>> [   34.412977] TPS65090_RAILSDCDC2: disabling
>> [   34.417021] TPS65090_RAILSDCDC3: disabling
>> [   34.423848] TPS65090_RAILSLDO1: disabling
>> [   34.429068] TPS65090_RAILSLDO2: disabling
> :(
>
> log does not look useful either.
>
>> Bisect between v5.7-rc1 and next-20200529 pointed me to the first bad
>> commit: [c4b12a2f3f3de670f6be5e96092a2cab0b877f1a] power: supply:
>> sbs-battery: simplify read_read_string_data.
> ok. I tested this on an to-be-upstreamed i.MX6 based system
> and arch/arm/boot/dts/imx53-ppd.dts. I think the difference
> is, that i2c-exynos5 does not expose I2C_FUNC_SMBUS_READ_BLOCK_DATA.
> I hoped all systems using SBS battery support this, but now
> I see I2C_FUNC_SMBUS_EMUL only supports writing block data.
> Looks like I need to add another patch implementing that
> using the old code with added PEC support.
>
> In any case that should only return -ENODEV for the property
> (and uevent), but not break boot. So something fishy is going
> on.
>
>> However reverting it in linux-next doesn't fix the issue, so the
>> next commits are also relevant to this issue.
> The next patch, which adds PEC support depends on the simplification
> of sbs_read_string_data. The old, open coded variant will result in
> PEC failure for string properties (which should not stop boot either
> of course). Can you try reverting both?
Indeed, reverting both (and fixing the conflict) restores proper boot.
> If that helps I will revert those two instead of dropping the whole
> series for this merge window.
>
>> Let me know how can I help debugging it.
> I suspect, that this is userspace endlessly retrying reading the
> battery uevent when an error is returned. Could you check this?
> Should be easy to see by adding some printfs.
I've added some debug messages in sbs_get_property() and it read the 
same properties many times. However I've noticed that if I wait long 
enough booting finally continues.
> That would mean a faulty battery could stall complete boot without
> a useful error message, which is bad and needs to be fixed.
>
> Sorry for the inconvience and thanks for your report,

No problem, finding regressions is one of the linux-next goal.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 00/19] Improve SBS battery support
  2020-06-02  7:17       ` Marek Szyprowski
@ 2020-06-02 18:01         ` Sebastian Reichel
  2020-06-03 18:49           ` Marek Szyprowski
  0 siblings, 1 reply; 37+ messages in thread
From: Sebastian Reichel @ 2020-06-02 18:01 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki, linux-pm,
	devicetree, linux-kernel, kernel, 'Linux Samsung SOC'

[-- Attachment #1: Type: text/plain, Size: 5570 bytes --]

Hi,

On Tue, Jun 02, 2020 at 09:17:09AM +0200, Marek Szyprowski wrote:
> Hi Sebastian,
> 
> On 01.06.2020 19:05, Sebastian Reichel wrote:
> > On Mon, Jun 01, 2020 at 12:40:27PM +0200, Marek Szyprowski wrote:
> >> On 13.05.2020 20:55, Sebastian Reichel wrote:
> >>> This patchset improves support for SBS compliant batteries. Due to
> >>> the changes, the battery now exposes 32 power supply properties and
> >>> (un)plugging it generates a backtrace containing the following message
> >>> without the first patch in this series:
> >>>
> >>> ---------------------------
> >>> WARNING: CPU: 0 PID: 20 at lib/kobject_uevent.c:659 add_uevent_var+0xd4/0x104
> >>> add_uevent_var: too many keys
> >>> ---------------------------
> >>>
> >>> For references this is what an SBS battery status looks like after
> >>> the patch series has been applied:
> >>>
> >>> cat /sys/class/power_supply/sbs-0-000b/uevent
> >>> POWER_SUPPLY_NAME=sbs-0-000b
> >>> POWER_SUPPLY_TYPE=Battery
> >>> POWER_SUPPLY_STATUS=Discharging
> >>> POWER_SUPPLY_CAPACITY_LEVEL=Normal
> >>> POWER_SUPPLY_HEALTH=Good
> >>> POWER_SUPPLY_PRESENT=1
> >>> POWER_SUPPLY_TECHNOLOGY=Li-ion
> >>> POWER_SUPPLY_CYCLE_COUNT=12
> >>> POWER_SUPPLY_VOLTAGE_NOW=11441000
> >>> POWER_SUPPLY_CURRENT_NOW=-26000
> >>> POWER_SUPPLY_CURRENT_AVG=-24000
> >>> POWER_SUPPLY_CAPACITY=76
> >>> POWER_SUPPLY_CAPACITY_ERROR_MARGIN=1
> >>> POWER_SUPPLY_TEMP=198
> >>> POWER_SUPPLY_TIME_TO_EMPTY_AVG=438600
> >>> POWER_SUPPLY_TIME_TO_FULL_AVG=3932100
> >>> POWER_SUPPLY_SERIAL_NUMBER=0000
> >>> POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
> >>> POWER_SUPPLY_VOLTAGE_MAX_DESIGN=10800000
> >>> POWER_SUPPLY_ENERGY_NOW=31090000
> >>> POWER_SUPPLY_ENERGY_FULL=42450000
> >>> POWER_SUPPLY_ENERGY_FULL_DESIGN=41040000
> >>> POWER_SUPPLY_CHARGE_NOW=2924000
> >>> POWER_SUPPLY_CHARGE_FULL=3898000
> >>> POWER_SUPPLY_CHARGE_FULL_DESIGN=3800000
> >>> POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=3000000
> >>> POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE_MAX=12300000
> >>> POWER_SUPPLY_MANUFACTURE_YEAR=2017
> >>> POWER_SUPPLY_MANUFACTURE_MONTH=7
> >>> POWER_SUPPLY_MANUFACTURE_DAY=3
> >>> POWER_SUPPLY_MANUFACTURER=UR18650A
> >>> POWER_SUPPLY_MODEL_NAME=GEHC
> >> This patch landed in linux-next dated 20200529. Sadly it causes a
> >> regression on Samsung Exynos-based Chromebooks (Exynos5250 Snow,
> >> Exynos5420 Peach-Pi and Exynos5800 Peach-Pit). System boots to
> >> userspace, but then, when udev populates /dev, booting hangs:
> >>
> >> [    4.435167] VFS: Mounted root (ext4 filesystem) readonly on device
> >> 179:51.
> >> [    4.457477] devtmpfs: mounted
> >> [    4.460235] Freeing unused kernel memory: 1024K
> >> [    4.464022] Run /sbin/init as init process
> >> INIT: version 2.88 booting
> >> [info] Using makefile-style concurrent boot in runlevel S.
> >> [    5.102096] random: crng init done
> >> [....] Starting the hotplug events dispatcher: systemd-udevdstarting
> >> version 236
> >> [ ok .
> >> [....] Synthesizing the initial hotplug events...[ ok done.
> >> [....] Waiting for /dev to be fully populated...[   34.409914]
> >> TPS65090_RAILSDCDC1: disabling
> >> [   34.412977] TPS65090_RAILSDCDC2: disabling
> >> [   34.417021] TPS65090_RAILSDCDC3: disabling
> >> [   34.423848] TPS65090_RAILSLDO1: disabling
> >> [   34.429068] TPS65090_RAILSLDO2: disabling
> > :(
> >
> > log does not look useful either.
> >
> >> Bisect between v5.7-rc1 and next-20200529 pointed me to the first bad
> >> commit: [c4b12a2f3f3de670f6be5e96092a2cab0b877f1a] power: supply:
> >> sbs-battery: simplify read_read_string_data.
> > ok. I tested this on an to-be-upstreamed i.MX6 based system
> > and arch/arm/boot/dts/imx53-ppd.dts. I think the difference
> > is, that i2c-exynos5 does not expose I2C_FUNC_SMBUS_READ_BLOCK_DATA.
> > I hoped all systems using SBS battery support this, but now
> > I see I2C_FUNC_SMBUS_EMUL only supports writing block data.
> > Looks like I need to add another patch implementing that
> > using the old code with added PEC support.
> >
> > In any case that should only return -ENODEV for the property
> > (and uevent), but not break boot. So something fishy is going
> > on.
> >
> >> However reverting it in linux-next doesn't fix the issue, so the
> >> next commits are also relevant to this issue.
> > The next patch, which adds PEC support depends on the simplification
> > of sbs_read_string_data. The old, open coded variant will result in
> > PEC failure for string properties (which should not stop boot either
> > of course). Can you try reverting both?
> Indeed, reverting both (and fixing the conflict) restores proper boot.

Ok, I pushed out a revert of those two patches. They should land in
tomorrows linux-next release. Please test it.

> > If that helps I will revert those two instead of dropping the whole
> > series for this merge window.
> >
> >> Let me know how can I help debugging it.
> > I suspect, that this is userspace endlessly retrying reading the
> > battery uevent when an error is returned. Could you check this?
> > Should be easy to see by adding some printfs.
> I've added some debug messages in sbs_get_property() and it read the 
> same properties many times. However I've noticed that if I wait long 
> enough booting finally continues.

So basically userspace slows down itself massively by trying to
re-read uevent over and over when an error occurs. Does not seem
like a sensible thing to do. I will have a look at this when I find
some time.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCHv1 00/19] Improve SBS battery support
  2020-06-02 18:01         ` Sebastian Reichel
@ 2020-06-03 18:49           ` Marek Szyprowski
  0 siblings, 0 replies; 37+ messages in thread
From: Marek Szyprowski @ 2020-06-03 18:49 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Rob Herring, Greg Kroah-Hartman, Rafael J . Wysocki, linux-pm,
	devicetree, linux-kernel, kernel, 'Linux Samsung SOC'

Hi Sebastian,

On 02.06.2020 20:01, Sebastian Reichel wrote:
> On Tue, Jun 02, 2020 at 09:17:09AM +0200, Marek Szyprowski wrote:
>> On 01.06.2020 19:05, Sebastian Reichel wrote:
>>> On Mon, Jun 01, 2020 at 12:40:27PM +0200, Marek Szyprowski wrote:
>>>> On 13.05.2020 20:55, Sebastian Reichel wrote:
>>>>> This patchset improves support for SBS compliant batteries. Due to
>>>>> the changes, the battery now exposes 32 power supply properties and
>>>>> (un)plugging it generates a backtrace containing the following message
>>>>> without the first patch in this series:
>>>>>
>>>>> ---------------------------
>>>>> WARNING: CPU: 0 PID: 20 at lib/kobject_uevent.c:659 add_uevent_var+0xd4/0x104
>>>>> add_uevent_var: too many keys
>>>>> ---------------------------
>>>>>
>>>>> For references this is what an SBS battery status looks like after
>>>>> the patch series has been applied:
>>>>>
>>>>> cat /sys/class/power_supply/sbs-0-000b/uevent
>>>>> POWER_SUPPLY_NAME=sbs-0-000b
>>>>> POWER_SUPPLY_TYPE=Battery
>>>>> POWER_SUPPLY_STATUS=Discharging
>>>>> POWER_SUPPLY_CAPACITY_LEVEL=Normal
>>>>> POWER_SUPPLY_HEALTH=Good
>>>>> POWER_SUPPLY_PRESENT=1
>>>>> POWER_SUPPLY_TECHNOLOGY=Li-ion
>>>>> POWER_SUPPLY_CYCLE_COUNT=12
>>>>> POWER_SUPPLY_VOLTAGE_NOW=11441000
>>>>> POWER_SUPPLY_CURRENT_NOW=-26000
>>>>> POWER_SUPPLY_CURRENT_AVG=-24000
>>>>> POWER_SUPPLY_CAPACITY=76
>>>>> POWER_SUPPLY_CAPACITY_ERROR_MARGIN=1
>>>>> POWER_SUPPLY_TEMP=198
>>>>> POWER_SUPPLY_TIME_TO_EMPTY_AVG=438600
>>>>> POWER_SUPPLY_TIME_TO_FULL_AVG=3932100
>>>>> POWER_SUPPLY_SERIAL_NUMBER=0000
>>>>> POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
>>>>> POWER_SUPPLY_VOLTAGE_MAX_DESIGN=10800000
>>>>> POWER_SUPPLY_ENERGY_NOW=31090000
>>>>> POWER_SUPPLY_ENERGY_FULL=42450000
>>>>> POWER_SUPPLY_ENERGY_FULL_DESIGN=41040000
>>>>> POWER_SUPPLY_CHARGE_NOW=2924000
>>>>> POWER_SUPPLY_CHARGE_FULL=3898000
>>>>> POWER_SUPPLY_CHARGE_FULL_DESIGN=3800000
>>>>> POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=3000000
>>>>> POWER_SUPPLY_CONSTANT_CHARGE_VOLTAGE_MAX=12300000
>>>>> POWER_SUPPLY_MANUFACTURE_YEAR=2017
>>>>> POWER_SUPPLY_MANUFACTURE_MONTH=7
>>>>> POWER_SUPPLY_MANUFACTURE_DAY=3
>>>>> POWER_SUPPLY_MANUFACTURER=UR18650A
>>>>> POWER_SUPPLY_MODEL_NAME=GEHC
>>>> This patch landed in linux-next dated 20200529. Sadly it causes a
>>>> regression on Samsung Exynos-based Chromebooks (Exynos5250 Snow,
>>>> Exynos5420 Peach-Pi and Exynos5800 Peach-Pit). System boots to
>>>> userspace, but then, when udev populates /dev, booting hangs:
>>>>
>>>> [    4.435167] VFS: Mounted root (ext4 filesystem) readonly on device
>>>> 179:51.
>>>> [    4.457477] devtmpfs: mounted
>>>> [    4.460235] Freeing unused kernel memory: 1024K
>>>> [    4.464022] Run /sbin/init as init process
>>>> INIT: version 2.88 booting
>>>> [info] Using makefile-style concurrent boot in runlevel S.
>>>> [    5.102096] random: crng init done
>>>> [....] Starting the hotplug events dispatcher: systemd-udevdstarting
>>>> version 236
>>>> [ ok .
>>>> [....] Synthesizing the initial hotplug events...[ ok done.
>>>> [....] Waiting for /dev to be fully populated...[   34.409914]
>>>> TPS65090_RAILSDCDC1: disabling
>>>> [   34.412977] TPS65090_RAILSDCDC2: disabling
>>>> [   34.417021] TPS65090_RAILSDCDC3: disabling
>>>> [   34.423848] TPS65090_RAILSLDO1: disabling
>>>> [   34.429068] TPS65090_RAILSLDO2: disabling
>>> :(
>>>
>>> log does not look useful either.
>>>
>>>> Bisect between v5.7-rc1 and next-20200529 pointed me to the first bad
>>>> commit: [c4b12a2f3f3de670f6be5e96092a2cab0b877f1a] power: supply:
>>>> sbs-battery: simplify read_read_string_data.
>>> ok. I tested this on an to-be-upstreamed i.MX6 based system
>>> and arch/arm/boot/dts/imx53-ppd.dts. I think the difference
>>> is, that i2c-exynos5 does not expose I2C_FUNC_SMBUS_READ_BLOCK_DATA.
>>> I hoped all systems using SBS battery support this, but now
>>> I see I2C_FUNC_SMBUS_EMUL only supports writing block data.
>>> Looks like I need to add another patch implementing that
>>> using the old code with added PEC support.
>>>
>>> In any case that should only return -ENODEV for the property
>>> (and uevent), but not break boot. So something fishy is going
>>> on.
>>>
>>>> However reverting it in linux-next doesn't fix the issue, so the
>>>> next commits are also relevant to this issue.
>>> The next patch, which adds PEC support depends on the simplification
>>> of sbs_read_string_data. The old, open coded variant will result in
>>> PEC failure for string properties (which should not stop boot either
>>> of course). Can you try reverting both?
>> Indeed, reverting both (and fixing the conflict) restores proper boot.
> Ok, I pushed out a revert of those two patches. They should land in
> tomorrows linux-next release. Please test it.


Today's linux-next (20200603) boots fine on the Samsung Exynos-based 
Chromebooks. Let me know how if you need any help debugging the issues 
to resurrect those patches.


>>> If that helps I will revert those two instead of dropping the whole
>>> series for this merge window.
>>>
>>>> Let me know how can I help debugging it.
>>> I suspect, that this is userspace endlessly retrying reading the
>>> battery uevent when an error is returned. Could you check this?
>>> Should be easy to see by adding some printfs.
>> I've added some debug messages in sbs_get_property() and it read the
>> same properties many times. However I've noticed that if I wait long
>> enough booting finally continues.
> So basically userspace slows down itself massively by trying to
> re-read uevent over and over when an error occurs. Does not seem
> like a sensible thing to do. I will have a look at this when I find
> some time.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2020-06-03 18:49 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13 18:55 [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
2020-05-13 18:55 ` [PATCHv1 01/19] kobject: increase allowed number of uevent variables Sebastian Reichel
2020-05-14  6:11   ` Greg Kroah-Hartman
2020-05-15 14:45   ` Emil Velikov
2020-05-13 18:55 ` [PATCHv1 02/19] power: supply: core: add capacity error margin property Sebastian Reichel
2020-05-13 18:55 ` [PATCHv1 03/19] power: supply: core: add manufacture date properties Sebastian Reichel
2020-05-15 14:47   ` Emil Velikov
2020-05-15 15:14     ` Sebastian Reichel
2020-05-15 16:01       ` Emil Velikov
2020-05-13 18:56 ` [PATCHv1 04/19] power: supply: core: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 05/19] power: supply: sbs-battery: Add TI BQ20Z65 support Sebastian Reichel
2020-05-28  2:37   ` Rob Herring
2020-05-13 18:56 ` [PATCHv1 06/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CAPACITY_ERROR_MARGIN support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 07/19] power: supply: sbs-battery: simplify read_read_string_data Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 08/19] power: supply: sbs-battery: add PEC support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 09/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CURRENT_AVG support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 10/19] power: supply: sbs-battery: Improve POWER_SUPPLY_PROP_TECHNOLOGY support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 11/19] power: supply: sbs-battery: add POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT/VOLTAGE_MAX support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 12/19] power: supply: sbs-battery: add MANUFACTURE_DATE support Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 13/19] power: supply: sbs-battery: add POWER_SUPPLY_HEALTH_CALIBRATION_REQUIRED support Sebastian Reichel
2020-05-15 15:35   ` Emil Velikov
2020-05-13 18:56 ` [PATCHv1 14/19] power: supply: sbs-battery: fix idle battery status Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 15/19] power: supply: sbs-battery: add ability to disable charger broadcasts Sebastian Reichel
2020-05-15 14:57   ` Emil Velikov
2020-05-13 18:56 ` [PATCHv1 16/19] power: supply: sbs-battery: switch from of_property_* to device_property_* Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 17/19] power: supply: sbs-battery: switch to i2c's probe_new Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 18/19] power: supply: sbs-battery: constify power-supply property array Sebastian Reichel
2020-05-13 18:56 ` [PATCHv1 19/19] dt-bindings: power: sbs-battery: Convert to yaml Sebastian Reichel
2020-05-28  2:40   ` Rob Herring
2020-05-28 22:44 ` [PATCHv1 00/19] Improve SBS battery support Sebastian Reichel
2020-05-29 16:27 ` Pavel Machek
2020-06-01 21:57   ` Sebastian Reichel
     [not found] ` <CGME20200601104027eucas1p2b076ee860520d709e8178c41550653f7@eucas1p2.samsung.com>
2020-06-01 10:40   ` Marek Szyprowski
2020-06-01 17:05     ` Sebastian Reichel
2020-06-02  7:17       ` Marek Szyprowski
2020-06-02 18:01         ` Sebastian Reichel
2020-06-03 18:49           ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).