Re: [PATCH v1 4/4] hwmon: add driver for the Microchip LAN966x SoC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux