From: Guenter Roeck <linux@roeck-us.net>
To: Patryk Biel <pbiel7@gmail.com>, Jean Delvare <jdelvare@suse.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Frank Li <Frank.Li@nxp.com>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH 1/2] hwmon: pmbus: Add support for ltc2971
Date: Sat, 26 Oct 2024 09:18:17 -0700 [thread overview]
Message-ID: <495cff30-b472-4903-b1b1-e28349061ef9@roeck-us.net> (raw)
In-Reply-To: <20241026-add-ltc2971-v1-1-109ec21687bc@gmail.com>
On 10/26/24 02:08, Patryk Biel wrote:
> LTC2971 is a power manager similar to already supported LTC2972,
> it uses the same register set but supports a different voltage range.
>
> Signed-off-by: Patryk Biel <pbiel7@gmail.com>
> ---
> drivers/hwmon/pmbus/ltc2978.c | 34 +++++++++++++++++++++++++++++++---
Please also update Documentation/hwmon/ltc2978.rst and drivers/hwmon/pmbus/Kconfig.
> 1 file changed, 31 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hwmon/pmbus/ltc2978.c b/drivers/hwmon/pmbus/ltc2978.c
> index 73a86f4d647288be97615f19a5c6314e4036e6a3..681e7b811dbcc263fe8f5e4f9da30fcbc7e019ad 100644
> --- a/drivers/hwmon/pmbus/ltc2978.c
> +++ b/drivers/hwmon/pmbus/ltc2978.c
> @@ -21,7 +21,8 @@
>
> enum chips {
> /* Managers */
> - ltc2972, ltc2974, ltc2975, ltc2977, ltc2978, ltc2979, ltc2980,
> + ltc2971, ltc2972, ltc2974, ltc2975, ltc2977, ltc2978,
> + ltc2979, ltc2980,
> /* Controllers */
> ltc3880, ltc3882, ltc3883, ltc3884, ltc3886, ltc3887, ltc3889, ltc7132, ltc7880,
> /* Modules */
> @@ -61,6 +62,7 @@ enum chips {
>
> #define LTC2978_ID_MASK 0xfff0
>
> +#define LTC2971_ID 0x0320
> #define LTC2972_ID 0x0310
> #define LTC2974_ID 0x0210
> #define LTC2975_ID 0x0220
> @@ -533,6 +535,7 @@ static int ltc2978_write_word_data(struct i2c_client *client, int page,
> }
>
> static const struct i2c_device_id ltc2978_id[] = {
> + {"ltc2971", ltc2971},
> {"ltc2972", ltc2972},
> {"ltc2974", ltc2974},
> {"ltc2975", ltc2975},
> @@ -564,11 +567,19 @@ MODULE_DEVICE_TABLE(i2c, ltc2978_id);
>
> #if IS_ENABLED(CONFIG_SENSORS_LTC2978_REGULATOR)
> #define LTC2978_ADC_RES 0xFFFF
> +#define LTC2978_UV_STEP 1000
> +
> +/* Common for most chips */
> #define LTC2978_N_ADC 122
> #define LTC2978_MAX_UV (LTC2978_ADC_RES * LTC2978_N_ADC)
> -#define LTC2978_UV_STEP 1000
> #define LTC2978_N_VOLTAGES ((LTC2978_MAX_UV / LTC2978_UV_STEP) + 1)
>
Please just add the chip specific defines as you do below, and don't move
the defines above around. It happens a lot that there are common definitions
followed by chip specific ones. Spelling that out explicitly doesn't really
add much if any value and just results in rearranged code whenever a new
chip with other parameters is added.
> +/* LTC2971 */
> +#define LTC2971_N_ADC 4500
> +#define LTC2971_MAX_UV (LTC2978_ADC_RES * LTC2971_N_ADC)
I think something is wrong here.
4500 * 65535 uV ~= 295V.
However, the datasheet says that the output voltage is calculated by
(register value / 1024), where the register value is a 16-bit value.
65535 / 1024 ~= 64V. Where does the 4,500 come from ?
> +#define LTC2971_N_VOLTAGES ((LTC2971_MAX_UV / LTC2978_UV_STEP) + 1)
Does the chip really support 294,908 voltages ? That seems impossible since
the VOUT_COMMAND register is only 16 bit wide.
Unless I misunderstand the datasheet, the voltage resolution should be 1/1024V
or 976 uV, and there should be 65,536 voltages. This is from the chip datasheet,
PMBus Command Description, Note 1: Data Formats, for L16 data.
If my understanding is wrong, please explain and document your numbers.
Thanks,
Guenter
next prev parent reply other threads:[~2024-10-26 16:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-26 9:08 [PATCH 0/2] Add support for LTC2971 power manager Patryk Biel
2024-10-26 9:08 ` [PATCH 1/2] hwmon: pmbus: Add support for ltc2971 Patryk Biel
2024-10-26 16:18 ` Guenter Roeck [this message]
2024-10-27 10:52 ` Patryk
2024-10-26 9:08 ` [PATCH 2/2] dt-bindings: hwmon: Add ltc2971 bindings Patryk Biel
2024-10-26 18:18 ` Krzysztof Kozlowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=495cff30-b472-4903-b1b1-e28349061ef9@roeck-us.net \
--to=linux@roeck-us.net \
--cc=Frank.Li@nxp.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbiel7@gmail.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox