devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Jean Delvare <jdelvare@suse.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 4/4] hwmon: add driver for the Microchip LAN966x SoC
Date: Sun, 27 Mar 2022 16:18:28 +0200	[thread overview]
Message-ID: <9aab54bc48284c9e20cd76085cb9d83a@walle.cc> (raw)
In-Reply-To: <2442b460-4c6d-0ac9-af08-ae4c25aed812@roeck-us.net>

Am 2022-03-27 03:34, schrieb Guenter Roeck:

>> +	/*
>> +	 * Data is given in pulses per second. According to the hwmon ABI we
>> +	 * have to assume two pulses per revolution.
> 
> The hwmon ABI doesn't make any such assumptions. It wants to see RPM,
> that is all. Pulses per revolution is a fan property.

There is fanY_pulses according to 
Documentation/ABI/testing/sysfs-class-hwmon:

   Should only be created if the chip has a register to configure
   the number of pulses. In the absence of such a register (and
   thus attribute) the value assumed by all devices is 2 pulses
   per fan revolution.

The hardware returns just the pulses per second. Doesn't that
mean I have to divide that value by two?

>> +	 */
>> +	*val = FIELD_GET(FAN_CNT_DATA, data) * 60 / 2;

.. otherwise this should then be
*val = FIELD_GET(FAN_CNT_DATA, data) * 60;


>> +
>> +	return 0;
>> +}
>> +
>> +static int lan966x_hwmon_read_pwm(struct device *dev, long *val)
>> +{
>> +	struct lan966x_hwmon *hwmon = dev_get_drvdata(dev);
>> +	unsigned int data;
>> +	int ret;
>> +
>> +	ret = regmap_read(hwmon->regmap_fan, FAN_CFG, &data);
>> +	if (ret < 0)
>> +		return ret;
>> +
>> +	*val = FIELD_GET(FAN_CFG_DUTY_CYCLE, data);
>> +
>> +	return 0;
>> +}
>> +
>> +static int lan966x_hwmon_read_pwm_freq(struct device *dev, long *val)
>> +{
>> +	struct lan966x_hwmon *hwmon = dev_get_drvdata(dev);
>> +	unsigned long rate = clk_get_rate(hwmon->clk);
> 
> Is that a dynamic frequency ? If not, it would be better to read it 
> once
> and store it in struct lan966x_hwmon.

yes it is configurable, actually. See lan966x_hwmon_write_pwm_freq().

-michael

  reply	other threads:[~2022-03-27 14:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-26 19:23 [PATCH v1 0/4] hwmon: add lan9668 driver Michael Walle
2022-03-26 19:23 ` [PATCH v1 1/4] lib: add generic polynomial calculation Michael Walle
2022-03-27  1:21   ` Guenter Roeck
2022-03-26 19:23 ` [PATCH v1 2/4] hwmon: (bt1-pvt) use generic polynomial functions Michael Walle
2022-03-27  0:49   ` kernel test robot
2022-03-27  1:10   ` kernel test robot
2022-03-27  1:22   ` Guenter Roeck
2022-03-26 19:23 ` [PATCH v1 3/4] dt-bindings: hwmon: add Microchip LAN966x bindings Michael Walle
2022-03-27 11:17   ` Krzysztof Kozlowski
2022-03-26 19:23 ` [PATCH v1 4/4] hwmon: add driver for the Microchip LAN966x SoC Michael Walle
2022-03-27  1:34   ` Guenter Roeck
2022-03-27 14:18     ` Michael Walle [this message]
2022-03-27 18:22       ` Guenter Roeck
2022-03-28 11:28         ` Michael Walle
2022-03-28 16:37           ` Guenter Roeck
2022-03-27  3:13   ` kernel test robot

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=9aab54bc48284c9e20cd76085cb9d83a@walle.cc \
    --to=michael@walle.cc \
    --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=linux@roeck-us.net \
    --cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).