linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver
@ 2021-05-07 19:40 Erik Rosen
  2021-05-07 19:40 ` [PATCH v2 1/3] hwmon: (pmbus) Add new flag PMBUS_READ_STATUS_AFTER_FAILED_CHECK Erik Rosen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Erik Rosen @ 2021-05-07 19:40 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Jonathan Corbet, linux-hwmon,
	linux-doc, linux-kernel
  Cc: Erik Rosen

Some Flex pmbus converters (BMR310, BMR458, BMR80, BMR490 and BMR491)
end up in an undefined state when trying to read a register that does
not exist in the chip. This causes the following chip access to also
fail even if it is a valid register read or write. This will mess up the
pmbus driver auto-detection process.

One way to reset the pmbus state machine to a known state is to read
a register that is known to exist. This read will fail but will also
reset the chip into a known state.

For such chips we suggest adding a new pmbus flag:
PMBUS_READ_STATUS_AFTER_FAILED_CHECK
By setting this flag the driver will try to read the STATUS register
after each failed register check. This read may fail, but it will put
the chip into a known state so that the auto-detection process can
proceed correctly.

Add support for Flex BMR310, BMR456, BMR457, BMR458, BMR480, BMR490,
BMR491 and BMR492 to the pmbus driver

This patch has been tested with Flex BMR310, BMR456, BMR457, BMR458,
BMR480, BMR490, BMR491 and BMR492 converter modules

v2
-Copy all flags to pmbus_platform_data struct instead of one by one
-Fix code formatting in pmbus_core documentation
-Add documentation for flag NO_CAPABILITY
-Fix sorting of chip names and prefix in pmbus documentation

Erik Rosen (3):
  Add new flag PMBUS_READ_STATUS_AFTER_FAILED_CHECK
  Add documentation for new flags
  Add support for Flex BMR310, BMR456, BMR457, BMR458, BMR480, BMR490,
    BMR491 and BMR492 to the pmbus driver

 Documentation/hwmon/pmbus-core.rst | 42 +++++++++++++++++++++++++++---
 Documentation/hwmon/pmbus.rst      | 11 +++++---
 drivers/hwmon/pmbus/Kconfig        |  7 ++---
 drivers/hwmon/pmbus/pmbus.c        | 19 ++++++++++++--
 drivers/hwmon/pmbus/pmbus_core.c   |  2 ++
 include/linux/pmbus.h              | 13 +++++++++
 6 files changed, 81 insertions(+), 13 deletions(-)


base-commit: 1e28eed17697bcf343c6743f0028cc3b5dd88bf0
-- 
2.20.1


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

* [PATCH v2 1/3] hwmon: (pmbus) Add new flag PMBUS_READ_STATUS_AFTER_FAILED_CHECK
  2021-05-07 19:40 [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver Erik Rosen
@ 2021-05-07 19:40 ` Erik Rosen
  2021-05-07 19:40 ` [PATCH v2 2/3] hwmon: (pmbus) Add documentation for new flags Erik Rosen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Erik Rosen @ 2021-05-07 19:40 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Jonathan Corbet, linux-hwmon,
	linux-doc, linux-kernel
  Cc: Erik Rosen

Some PMBus chips end up in an undefined state when trying to read an
unsupported register. For such chips, it is necessary to reset the
chip pmbus controller to a known state after a failed register check.
This can be done by reading a known register. By setting this flag the
driver will try to read the STATUS register after each failed
register check. This read may fail, but it will put the chip into a
known state.

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
---
 drivers/hwmon/pmbus/pmbus_core.c |  2 ++
 include/linux/pmbus.h            | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index aadea85fe630..cb0b3c7c3434 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -512,6 +512,8 @@ static bool pmbus_check_register(struct i2c_client *client,
 	rv = func(client, page, reg);
 	if (rv >= 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK))
 		rv = pmbus_check_status_cml(client);
+	if (rv < 0 && (data->flags & PMBUS_READ_STATUS_AFTER_FAILED_CHECK))
+		data->read_status(client, -1);
 	pmbus_clear_fault_page(client, -1);
 	return rv >= 0;
 }
diff --git a/include/linux/pmbus.h b/include/linux/pmbus.h
index 12cbbf305969..edd7c84fef65 100644
--- a/include/linux/pmbus.h
+++ b/include/linux/pmbus.h
@@ -43,6 +43,19 @@
  */
 #define PMBUS_NO_CAPABILITY			BIT(2)
 
+/*
+ * PMBUS_READ_STATUS_AFTER_FAILED_CHECK
+ *
+ * Some PMBus chips end up in an undefined state when trying to read an
+ * unsupported register. For such chips, it is necessary to reset the
+ * chip pmbus controller to a known state after a failed register check.
+ * This can be done by reading a known register. By setting this flag the
+ * driver will try to read the STATUS register after each failed
+ * register check. This read may fail, but it will put the chip in a
+ * known state.
+ */
+#define PMBUS_READ_STATUS_AFTER_FAILED_CHECK	BIT(3)
+
 struct pmbus_platform_data {
 	u32 flags;		/* Device specific flags */
 
-- 
2.20.1


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

* [PATCH v2 2/3] hwmon: (pmbus) Add documentation for new flags
  2021-05-07 19:40 [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver Erik Rosen
  2021-05-07 19:40 ` [PATCH v2 1/3] hwmon: (pmbus) Add new flag PMBUS_READ_STATUS_AFTER_FAILED_CHECK Erik Rosen
@ 2021-05-07 19:40 ` Erik Rosen
  2021-05-07 19:40 ` [PATCH v2 3/3] hwmon: (pmbus) Add support for additional Flex BMR converters to pmbus Erik Rosen
  2021-05-10 16:38 ` [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver Guenter Roeck
  3 siblings, 0 replies; 5+ messages in thread
From: Erik Rosen @ 2021-05-07 19:40 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Jonathan Corbet, linux-hwmon,
	linux-doc, linux-kernel
  Cc: Erik Rosen

Add documentation for the new pmbus flags PMBUS_WRITE_PROTECTED,
PMBUS_NO_CAPABILITY and PMBUS_READ_STATUS_AFTER_FAILED_CHECK

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
---
 Documentation/hwmon/pmbus-core.rst | 42 +++++++++++++++++++++++++++---
 1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/Documentation/hwmon/pmbus-core.rst b/Documentation/hwmon/pmbus-core.rst
index 73e23ab42cc3..102c50e2be3d 100644
--- a/Documentation/hwmon/pmbus-core.rst
+++ b/Documentation/hwmon/pmbus-core.rst
@@ -289,12 +289,22 @@ PMBus driver platform data
 ==========================
 
 PMBus platform data is defined in include/linux/pmbus.h. Platform data
-currently only provides a flag field with a single bit used::
+currently provides a flags field with four bits used::
 
-	#define PMBUS_SKIP_STATUS_CHECK (1 << 0)
+	#define PMBUS_SKIP_STATUS_CHECK			BIT(0)
+
+	#define PMBUS_WRITE_PROTECTED			BIT(1)
+
+	#define PMBUS_NO_CAPABILITY			BIT(2)
+
+	#define PMBUS_READ_STATUS_AFTER_FAILED_CHECK	BIT(3)
 
 	struct pmbus_platform_data {
 		u32 flags;              /* Device specific flags */
+
+		/* regulator support */
+		int num_regulators;
+		struct regulator_init_data *reg_init_data;
 	};
 
 
@@ -302,8 +312,9 @@ Flags
 -----
 
 PMBUS_SKIP_STATUS_CHECK
-	During register detection, skip checking the status register for
-	communication or command errors.
+
+During register detection, skip checking the status register for
+communication or command errors.
 
 Some PMBus chips respond with valid data when trying to read an unsupported
 register. For such chips, checking the status register is mandatory when
@@ -315,3 +326,26 @@ status register must be disabled.
 Some i2c controllers do not support single-byte commands (write commands with
 no data, i2c_smbus_write_byte()). With such controllers, clearing the status
 register is impossible, and the PMBUS_SKIP_STATUS_CHECK flag must be set.
+
+PMBUS_WRITE_PROTECTED
+
+Set if the chip is write protected and write protection is not determined
+by the standard WRITE_PROTECT command.
+
+PMBUS_NO_CAPABILITY
+
+Some PMBus chips don't respond with valid data when reading the CAPABILITY
+register. For such chips, this flag should be set so that the PMBus core
+driver doesn't use CAPABILITY to determine it's behavior.
+
+PMBUS_READ_STATUS_AFTER_FAILED_CHECK
+
+Read the STATUS register after each failed register check.
+
+Some PMBus chips end up in an undefined state when trying to read an
+unsupported register. For such chips, it is necessary to reset the
+chip pmbus controller to a known state after a failed register check.
+This can be done by reading a known register. By setting this flag the
+driver will try to read the STATUS register after each failed
+register check. This read may fail, but it will put the chip into a
+known state.
\ No newline at end of file
-- 
2.20.1


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

* [PATCH v2 3/3] hwmon: (pmbus) Add support for additional Flex BMR converters to pmbus
  2021-05-07 19:40 [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver Erik Rosen
  2021-05-07 19:40 ` [PATCH v2 1/3] hwmon: (pmbus) Add new flag PMBUS_READ_STATUS_AFTER_FAILED_CHECK Erik Rosen
  2021-05-07 19:40 ` [PATCH v2 2/3] hwmon: (pmbus) Add documentation for new flags Erik Rosen
@ 2021-05-07 19:40 ` Erik Rosen
  2021-05-10 16:38 ` [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver Guenter Roeck
  3 siblings, 0 replies; 5+ messages in thread
From: Erik Rosen @ 2021-05-07 19:40 UTC (permalink / raw)
  To: Jean Delvare, Guenter Roeck, Jonathan Corbet, linux-hwmon,
	linux-doc, linux-kernel
  Cc: Erik Rosen

Add support for Flex BMR310, BMR456, BMR457, BMR458, BMR480, BMR490,
BMR491 and BMR492 to the pmbus driver

Signed-off-by: Erik Rosen <erik.rosen@metormote.com>
---
 Documentation/hwmon/pmbus.rst | 11 +++++++----
 drivers/hwmon/pmbus/Kconfig   |  7 ++++---
 drivers/hwmon/pmbus/pmbus.c   | 19 +++++++++++++++++--
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/Documentation/hwmon/pmbus.rst b/Documentation/hwmon/pmbus.rst
index c44f14115413..b51de98ab825 100644
--- a/Documentation/hwmon/pmbus.rst
+++ b/Documentation/hwmon/pmbus.rst
@@ -3,15 +3,18 @@ Kernel driver pmbus
 
 Supported chips:
 
-  * Ericsson BMR453, BMR454
+  * Flex BMR310, BMR453, BMR454, BMR456, BMR457, BMR458, BMR480,
+    BMR490, BMR491, BMR492
 
-    Prefixes: 'bmr453', 'bmr454'
+    Prefixes: 'bmr310', 'bmr453', 'bmr454', 'bmr456', 'bmr457', 'bmr458', 'bmr480',
+    'bmr490', 'bmr491', 'bmr492'
 
     Addresses scanned: -
 
-    Datasheet:
+    Datasheets:
+
+ 	https://flexpowermodules.com/products
 
- http://archive.ericsson.net/service/internet/picov/get?DocNo=28701-EN/LZT146395
 
   * ON Semiconductor ADP4000, NCP4200, NCP4208
 
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 32d2fc850621..59080d142bf7 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -19,9 +19,10 @@ config SENSORS_PMBUS
 	default y
 	help
 	  If you say yes here you get hardware monitoring support for generic
-	  PMBus devices, including but not limited to ADP4000, BMR453, BMR454,
-	  MAX20796, MDT040, NCP4200, NCP4208, PDT003, PDT006, PDT012, TPS40400,
-	  TPS544B20, TPS544B25, TPS544C20, TPS544C25, and UDT020.
+	  PMBus devices, including but not limited to ADP4000, BMR310, BMR453,
+	  BMR454, BMR456, BMR457, BMR458, BMR480, BMR490, BMR491, BMR492,
+	  MAX20796, MDT040, NCP4200, NCP4208, PDT003, PDT006, PDT012,
+	  TPS40400, TPS544B20, TPS544B25, TPS544C20, TPS544C25, and UDT020.
 
 	  This driver can also be built as a module. If so, the module will
 	  be called pmbus.
diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
index a1b4260e75b2..dc4f0c586f8c 100644
--- a/drivers/hwmon/pmbus/pmbus.c
+++ b/drivers/hwmon/pmbus/pmbus.c
@@ -173,13 +173,13 @@ static int pmbus_probe(struct i2c_client *client)
 		return -ENOMEM;
 
 	device_info = (struct pmbus_device_info *)i2c_match_id(pmbus_id, client)->driver_data;
-	if (device_info->flags & PMBUS_SKIP_STATUS_CHECK) {
+	if (device_info->flags) {
 		pdata = devm_kzalloc(dev, sizeof(struct pmbus_platform_data),
 				     GFP_KERNEL);
 		if (!pdata)
 			return -ENOMEM;
 
-		pdata->flags = PMBUS_SKIP_STATUS_CHECK;
+		pdata->flags = device_info->flags;
 	}
 
 	info->pages = device_info->pages;
@@ -193,22 +193,37 @@ static const struct pmbus_device_info pmbus_info_one = {
 	.pages = 1,
 	.flags = 0
 };
+
 static const struct pmbus_device_info pmbus_info_zero = {
 	.pages = 0,
 	.flags = 0
 };
+
 static const struct pmbus_device_info pmbus_info_one_skip = {
 	.pages = 1,
 	.flags = PMBUS_SKIP_STATUS_CHECK
 };
 
+static const struct pmbus_device_info pmbus_info_one_status = {
+	.pages = 1,
+	.flags = PMBUS_READ_STATUS_AFTER_FAILED_CHECK
+};
+
 /*
  * Use driver_data to set the number of pages supported by the chip.
  */
 static const struct i2c_device_id pmbus_id[] = {
 	{"adp4000", (kernel_ulong_t)&pmbus_info_one},
+	{"bmr310", (kernel_ulong_t)&pmbus_info_one_status},
 	{"bmr453", (kernel_ulong_t)&pmbus_info_one},
 	{"bmr454", (kernel_ulong_t)&pmbus_info_one},
+	{"bmr456", (kernel_ulong_t)&pmbus_info_one},
+	{"bmr457", (kernel_ulong_t)&pmbus_info_one},
+	{"bmr458", (kernel_ulong_t)&pmbus_info_one_status},
+	{"bmr480", (kernel_ulong_t)&pmbus_info_one_status},
+	{"bmr490", (kernel_ulong_t)&pmbus_info_one_status},
+	{"bmr491", (kernel_ulong_t)&pmbus_info_one_status},
+	{"bmr492", (kernel_ulong_t)&pmbus_info_one},
 	{"dps460", (kernel_ulong_t)&pmbus_info_one_skip},
 	{"dps650ab", (kernel_ulong_t)&pmbus_info_one_skip},
 	{"dps800", (kernel_ulong_t)&pmbus_info_one_skip},
-- 
2.20.1


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

* Re: [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver
  2021-05-07 19:40 [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver Erik Rosen
                   ` (2 preceding siblings ...)
  2021-05-07 19:40 ` [PATCH v2 3/3] hwmon: (pmbus) Add support for additional Flex BMR converters to pmbus Erik Rosen
@ 2021-05-10 16:38 ` Guenter Roeck
  3 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-05-10 16:38 UTC (permalink / raw)
  To: Erik Rosen
  Cc: Jean Delvare, Jonathan Corbet, linux-hwmon, linux-doc, linux-kernel

On Fri, May 07, 2021 at 09:40:20PM +0200, Erik Rosen wrote:
> Some Flex pmbus converters (BMR310, BMR458, BMR80, BMR490 and BMR491)
> end up in an undefined state when trying to read a register that does
> not exist in the chip. This causes the following chip access to also
> fail even if it is a valid register read or write. This will mess up the
> pmbus driver auto-detection process.
> 
> One way to reset the pmbus state machine to a known state is to read
> a register that is known to exist. This read will fail but will also
> reset the chip into a known state.
> 
> For such chips we suggest adding a new pmbus flag:
> PMBUS_READ_STATUS_AFTER_FAILED_CHECK
> By setting this flag the driver will try to read the STATUS register
> after each failed register check. This read may fail, but it will put
> the chip into a known state so that the auto-detection process can
> proceed correctly.
> 
> Add support for Flex BMR310, BMR456, BMR457, BMR458, BMR480, BMR490,
> BMR491 and BMR492 to the pmbus driver
> 
> This patch has been tested with Flex BMR310, BMR456, BMR457, BMR458,
> BMR480, BMR490, BMR491 and BMR492 converter modules
> 
> v2
> -Copy all flags to pmbus_platform_data struct instead of one by one
> -Fix code formatting in pmbus_core documentation
> -Add documentation for flag NO_CAPABILITY
> -Fix sorting of chip names and prefix in pmbus documentation
> 
Series applied, with minor whitespace fixes in documentation.

Guenter

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

end of thread, other threads:[~2021-05-10 16:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 19:40 [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver Erik Rosen
2021-05-07 19:40 ` [PATCH v2 1/3] hwmon: (pmbus) Add new flag PMBUS_READ_STATUS_AFTER_FAILED_CHECK Erik Rosen
2021-05-07 19:40 ` [PATCH v2 2/3] hwmon: (pmbus) Add documentation for new flags Erik Rosen
2021-05-07 19:40 ` [PATCH v2 3/3] hwmon: (pmbus) Add support for additional Flex BMR converters to pmbus Erik Rosen
2021-05-10 16:38 ` [PATCH v2 0/3] hwmon: (pmbus) Add support for additional Flex BMR converters to the pmbus driver Guenter Roeck

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).