* [PATCH 1/3] hwmon: (tps23861) define regmap max register
@ 2021-06-09 22:07 Robert Marko
2021-06-09 22:07 ` [PATCH 2/3] hwmon: (tps23861) set current shunt value Robert Marko
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Robert Marko @ 2021-06-09 22:07 UTC (permalink / raw)
To: jdelvare, linux, linux-hwmon, linux-kernel; +Cc: luka.perkov, Robert Marko
Define the max register address the device supports.
This allows reading the whole register space via
regmap debugfs, without it only register 0x0 is visible.
This was forgotten in the original driver commit.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
drivers/hwmon/tps23861.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c
index c2484f15298b..fd0be8883829 100644
--- a/drivers/hwmon/tps23861.c
+++ b/drivers/hwmon/tps23861.c
@@ -117,6 +117,7 @@ struct tps23861_data {
static struct regmap_config tps23861_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
+ .max_register = 0x6f,
};
static int tps23861_read_temp(struct tps23861_data *data, long *val)
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] hwmon: (tps23861) set current shunt value
2021-06-09 22:07 [PATCH 1/3] hwmon: (tps23861) define regmap max register Robert Marko
@ 2021-06-09 22:07 ` Robert Marko
2021-06-10 15:39 ` Guenter Roeck
2021-06-09 22:07 ` [PATCH 3/3] hwmon: (tps23861) correct shunt LSB values Robert Marko
2021-06-10 15:36 ` [PATCH 1/3] hwmon: (tps23861) define regmap max register Guenter Roeck
2 siblings, 1 reply; 6+ messages in thread
From: Robert Marko @ 2021-06-09 22:07 UTC (permalink / raw)
To: jdelvare, linux, linux-hwmon, linux-kernel; +Cc: luka.perkov, Robert Marko
TPS23861 has a configuration bit for setting of the
current shunt value used on the board.
Its bit 0 of the General Mask 1 register.
According to the datasheet bit values are:
0 for 255 mOhm (Default)
1 for 250 mOhm
So, configure the bit before registering the hwmon
device according to the value passed in the DTS or
default one if none is passed.
This caused potentially reading slightly skewed values
due to max current value being 1.02A when 250mOhm shunt
is used instead of 1.0A when 255mOhm is used.
Fixes: fff7b8ab2255 ("hwmon: add Texas Instruments TPS23861 driver")
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
drivers/hwmon/tps23861.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c
index fd0be8883829..c3685b7e9e82 100644
--- a/drivers/hwmon/tps23861.c
+++ b/drivers/hwmon/tps23861.c
@@ -99,6 +99,9 @@
#define POWER_ENABLE 0x19
#define TPS23861_NUM_PORTS 4
+#define TPS23861_GENERAL_MASK_1 0x17
+#define TPS23861_CURRENT_SHUNT_MASK BIT(0)
+
#define TEMPERATURE_LSB 652 /* 0.652 degrees Celsius */
#define VOLTAGE_LSB 3662 /* 3.662 mV */
#define SHUNT_RESISTOR_DEFAULT 255000 /* 255 mOhm */
@@ -561,6 +564,15 @@ static int tps23861_probe(struct i2c_client *client)
else
data->shunt_resistor = SHUNT_RESISTOR_DEFAULT;
+ if (data->shunt_resistor == SHUNT_RESISTOR_DEFAULT)
+ regmap_clear_bits(data->regmap,
+ TPS23861_GENERAL_MASK_1,
+ TPS23861_CURRENT_SHUNT_MASK);
+ else
+ regmap_set_bits(data->regmap,
+ TPS23861_GENERAL_MASK_1,
+ TPS23861_CURRENT_SHUNT_MASK);
+
hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name,
data, &tps23861_chip_info,
NULL);
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] hwmon: (tps23861) correct shunt LSB values
2021-06-09 22:07 [PATCH 1/3] hwmon: (tps23861) define regmap max register Robert Marko
2021-06-09 22:07 ` [PATCH 2/3] hwmon: (tps23861) set current shunt value Robert Marko
@ 2021-06-09 22:07 ` Robert Marko
2021-06-10 15:40 ` Guenter Roeck
2021-06-10 15:36 ` [PATCH 1/3] hwmon: (tps23861) define regmap max register Guenter Roeck
2 siblings, 1 reply; 6+ messages in thread
From: Robert Marko @ 2021-06-09 22:07 UTC (permalink / raw)
To: jdelvare, linux, linux-hwmon, linux-kernel; +Cc: luka.perkov, Robert Marko
Current shunt LSB values got reversed during in the
original driver commit.
So, correct the current shunt LSB values according to
the datasheet.
This caused reading slightly skewed current values.
Fixes: fff7b8ab2255 ("hwmon: add Texas Instruments TPS23861 driver")
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
drivers/hwmon/tps23861.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c
index c3685b7e9e82..8bd6435c13e8 100644
--- a/drivers/hwmon/tps23861.c
+++ b/drivers/hwmon/tps23861.c
@@ -105,8 +105,8 @@
#define TEMPERATURE_LSB 652 /* 0.652 degrees Celsius */
#define VOLTAGE_LSB 3662 /* 3.662 mV */
#define SHUNT_RESISTOR_DEFAULT 255000 /* 255 mOhm */
-#define CURRENT_LSB_255 62260 /* 62.260 uA */
-#define CURRENT_LSB_250 61039 /* 61.039 uA */
+#define CURRENT_LSB_250 62260 /* 62.260 uA */
+#define CURRENT_LSB_255 61039 /* 61.039 uA */
#define RESISTANCE_LSB 110966 /* 11.0966 Ohm*/
#define RESISTANCE_LSB_LOW 157216 /* 15.7216 Ohm*/
--
2.31.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] hwmon: (tps23861) define regmap max register
2021-06-09 22:07 [PATCH 1/3] hwmon: (tps23861) define regmap max register Robert Marko
2021-06-09 22:07 ` [PATCH 2/3] hwmon: (tps23861) set current shunt value Robert Marko
2021-06-09 22:07 ` [PATCH 3/3] hwmon: (tps23861) correct shunt LSB values Robert Marko
@ 2021-06-10 15:36 ` Guenter Roeck
2 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2021-06-10 15:36 UTC (permalink / raw)
To: Robert Marko; +Cc: jdelvare, linux-hwmon, linux-kernel, luka.perkov
On Thu, Jun 10, 2021 at 12:07:26AM +0200, Robert Marko wrote:
> Define the max register address the device supports.
> This allows reading the whole register space via
> regmap debugfs, without it only register 0x0 is visible.
>
> This was forgotten in the original driver commit.
>
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/tps23861.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c
> index c2484f15298b..fd0be8883829 100644
> --- a/drivers/hwmon/tps23861.c
> +++ b/drivers/hwmon/tps23861.c
> @@ -117,6 +117,7 @@ struct tps23861_data {
> static struct regmap_config tps23861_regmap_config = {
> .reg_bits = 8,
> .val_bits = 8,
> + .max_register = 0x6f,
> };
>
> static int tps23861_read_temp(struct tps23861_data *data, long *val)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] hwmon: (tps23861) set current shunt value
2021-06-09 22:07 ` [PATCH 2/3] hwmon: (tps23861) set current shunt value Robert Marko
@ 2021-06-10 15:39 ` Guenter Roeck
0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2021-06-10 15:39 UTC (permalink / raw)
To: Robert Marko; +Cc: jdelvare, linux-hwmon, linux-kernel, luka.perkov
On Thu, Jun 10, 2021 at 12:07:27AM +0200, Robert Marko wrote:
> TPS23861 has a configuration bit for setting of the
> current shunt value used on the board.
> Its bit 0 of the General Mask 1 register.
>
> According to the datasheet bit values are:
> 0 for 255 mOhm (Default)
> 1 for 250 mOhm
>
> So, configure the bit before registering the hwmon
> device according to the value passed in the DTS or
> default one if none is passed.
>
> This caused potentially reading slightly skewed values
> due to max current value being 1.02A when 250mOhm shunt
> is used instead of 1.0A when 255mOhm is used.
>
> Fixes: fff7b8ab2255 ("hwmon: add Texas Instruments TPS23861 driver")
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/tps23861.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/hwmon/tps23861.c b/drivers/hwmon/tps23861.c
> index fd0be8883829..c3685b7e9e82 100644
> --- a/drivers/hwmon/tps23861.c
> +++ b/drivers/hwmon/tps23861.c
> @@ -99,6 +99,9 @@
> #define POWER_ENABLE 0x19
> #define TPS23861_NUM_PORTS 4
>
> +#define TPS23861_GENERAL_MASK_1 0x17
> +#define TPS23861_CURRENT_SHUNT_MASK BIT(0)
> +
> #define TEMPERATURE_LSB 652 /* 0.652 degrees Celsius */
> #define VOLTAGE_LSB 3662 /* 3.662 mV */
> #define SHUNT_RESISTOR_DEFAULT 255000 /* 255 mOhm */
> @@ -561,6 +564,15 @@ static int tps23861_probe(struct i2c_client *client)
> else
> data->shunt_resistor = SHUNT_RESISTOR_DEFAULT;
>
> + if (data->shunt_resistor == SHUNT_RESISTOR_DEFAULT)
> + regmap_clear_bits(data->regmap,
> + TPS23861_GENERAL_MASK_1,
> + TPS23861_CURRENT_SHUNT_MASK);
> + else
> + regmap_set_bits(data->regmap,
> + TPS23861_GENERAL_MASK_1,
> + TPS23861_CURRENT_SHUNT_MASK);
> +
> hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name,
> data, &tps23861_chip_info,
> NULL);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] hwmon: (tps23861) correct shunt LSB values
2021-06-09 22:07 ` [PATCH 3/3] hwmon: (tps23861) correct shunt LSB values Robert Marko
@ 2021-06-10 15:40 ` Guenter Roeck
0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2021-06-10 15:40 UTC (permalink / raw)
To: Robert Marko; +Cc: jdelvare, linux-hwmon, linux-kernel, luka.perkov
On Thu, Jun 10, 2021 at 12:07:28AM +0200, Robert Marko wrote:
> Current shunt LSB values got reversed during in the
> original driver commit.
>
> So, correct the current shunt LSB values according to
> the datasheet.
>
> This caused reading slightly skewed current values.
>
> Fixes: fff7b8ab2255 ("hwmon: add Texas Instruments TPS23861 driver")
> Signed-off-by: Robert Marko <robert.marko@sartura.hr>
Applied.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-06-10 15:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 22:07 [PATCH 1/3] hwmon: (tps23861) define regmap max register Robert Marko
2021-06-09 22:07 ` [PATCH 2/3] hwmon: (tps23861) set current shunt value Robert Marko
2021-06-10 15:39 ` Guenter Roeck
2021-06-09 22:07 ` [PATCH 3/3] hwmon: (tps23861) correct shunt LSB values Robert Marko
2021-06-10 15:40 ` Guenter Roeck
2021-06-10 15:36 ` [PATCH 1/3] hwmon: (tps23861) define regmap max register 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).