From: Quentin Schulz <quentin.schulz@cherry.de>
To: Guenter Roeck <linux@roeck-us.net>, linux-hwmon@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Farouk Bouabid <farouk.bouabid@cherry.de>
Subject: Re: [PATCH v3 09/11] hwmon: (amc6821) Convert to use regmap
Date: Mon, 8 Jul 2024 12:37:59 +0200 [thread overview]
Message-ID: <b4218ace-4aae-4fe3-ad27-dd983087d1f7@cherry.de> (raw)
In-Reply-To: <949d9c32-7722-4afe-a8ae-b2ef57d1cf01@roeck-us.net>
Hi Guenter,
On 7/5/24 4:28 PM, Guenter Roeck wrote:
> On 7/5/24 03:59, Quentin Schulz wrote:
>> Hi Guenter,
>>
>> On 7/4/24 7:52 PM, Guenter Roeck wrote:
[...]
>>> + err = regmap_read(regmap,
>>> + channel ? AMC6821_REG_RTEMP_FAN_CTRL :
>>> AMC6821_REG_LTEMP_FAN_CTRL,
>>> + ®val);
>>> + if (err)
>>> + return err;
>>> + temps[1] = (regval & 0xF8) >> 1;
>>
>> I think we want to use AMC6821_TEMP_LIMIT_MASK here instead of 0xF8?
>>
>> I guess we could also use FIELD_GET?
>>
>
> Yes. The value in the register is in °C * 4, so that is going to be
> temps[1] = FIELD_GET(regval, AMC6821_TEMP_LIMIT_MASK) * 4;
> which improves readability and should also clarify the units a bit
> better.
>
> Note hat
> (regval & 0xF8) >> 1;
> resulted in the temperature in °C (shift right 1 instead of 3).
>
Yes, it actually took me a while to figure out why this 1b shift was
necessary as it didn't match what I got from the datasheet, but the
formula was actually (>>3) * 4. Former because the register starts at
bit 3, so we need to right-shift by three bits to have the actual value.
Then multiply by 4 because a bit in the register means 4°C.
So yes, much more readable with this instead :)
[...]
>>> + /*
>>> + * Passive cooling temperature. Range limit against low limit
>>> + * of both channels.
>>> + */
>>> + val = DIV_ROUND_CLOSEST(clamp_val(val, 0, 63000), 1000);
>>
>> This was already in the original code, but I think 64°C should be
>> doable as well? The datasheet says:
>>
>> """
>> The PSV ranges from 0°C to +64°C.
>> """
>>
>
> Yes, but I am sure the datasheet is wrong here. The register has 6
> active bits,
> which means the highest possible value is 0x3f or 63.
>
>> And there's a PSV8 bit we can write, meaning we can do (1 << 8) with a
>> step of 4°C which gives us 64°C? In a separate commit though, to not
>> mix too many fixes into one, making it easier for people to identify
>> and possibly revert them if necessary.
>>
> Not sure I understand. Can you clarify ?
>
> Temperature bit assignments in the datasheet are confusing. PSV3
> means full degrees C, PSV8 means 32 degrees C. That is all in one register.
> On the other side, L-TEMP0 reflects _4_ degrees C.
>
> Am I missing something ?
>
No, my brain came up with its own math. Register value TEMPERATURE
MONITORING section all seems to be 1°C increments (except
Temp-DATA-LByte since it represents 0.125°C increments for a few select
registers.
Thanks for taking the time to explain!
Quentin
next prev parent reply other threads:[~2024-07-08 10:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 17:51 [PATCH v3 00/11] hwmon: (amc6821) Various improvements Guenter Roeck
2024-07-04 17:51 ` [PATCH v3 01/11] hwmon: (amc6821) Stop accepting invalid pwm values Guenter Roeck
2024-07-04 17:51 ` [PATCH v3 02/11] hwmon: (amc6821) Make reading and writing fan speed limits consistent Guenter Roeck
2024-07-04 17:51 ` [PATCH v3 03/11] hwmon: (amc6821) Rename fan1_div to fan1_pulses Guenter Roeck
2024-07-04 17:52 ` [PATCH v3 04/11] hwmon: (amc6821) Add support for fan1_target and pwm1_enable mode 4 Guenter Roeck
2024-07-04 17:52 ` [PATCH v3 05/11] hwmon: (amc2821) Reorder include files, drop unnecessary ones Guenter Roeck
2024-07-04 17:52 ` [PATCH v3 06/11] hwmon: (amc6821) Use tabs for column alignment in defines Guenter Roeck
2024-07-04 17:52 ` [PATCH v3 07/11] hwmon: (amc2821) Use BIT() and GENMASK() Guenter Roeck
2024-07-04 17:52 ` [PATCH v3 08/11] hwmon: (amc6821) Drop unnecessary enum chips Guenter Roeck
2024-07-04 17:52 ` [PATCH v3 09/11] hwmon: (amc6821) Convert to use regmap Guenter Roeck
2024-07-05 10:59 ` Quentin Schulz
2024-07-05 14:28 ` Guenter Roeck
2024-07-08 10:37 ` Quentin Schulz [this message]
2024-07-04 17:52 ` [PATCH v3 10/11] hwmon: (amc6821) Convert to with_info API Guenter Roeck
2024-07-04 17:52 ` [PATCH v3 11/11] hwmon: (amc6821) Add support for pwm1_mode attribute Guenter Roeck
2024-07-05 11:00 ` Quentin Schulz
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=b4218ace-4aae-4fe3-ad27-dd983087d1f7@cherry.de \
--to=quentin.schulz@cherry.de \
--cc=farouk.bouabid@cherry.de \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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