Commit Graph

12 Commits

Author SHA1 Message Date
Nuno Sa
ec823656c1 hwmon: (axi-fan-control) Make use of dev_err_probe()
Use dev_err_probe() to slightly simplify printing errors during probe.
No functional changes intended.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240214-axi-fan-control-no-of-v1-3-43ca656fe2e3@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-02-25 12:37:46 -08:00
Nuno Sa
0b5f91d47d hwmon: (axi-fan-control) Make use of sysfs_emit()
Use sysfs_emit() instead of directly call sprintf().

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240214-axi-fan-control-no-of-v1-2-43ca656fe2e3@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-02-25 12:37:46 -08:00
Nuno Sa
1b5239f70f hwmon: (axi-fan-control) Use device firmware agnostic API
Don't directly use OF and use device property APIs. In addition, this
makes the probe() code neater and also allow us to move the
of_device_id table to it's natural place.

While at it, make sure to explicitly include mod_devicetable.h for the
of_device_id table.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240214-axi-fan-control-no-of-v1-1-43ca656fe2e3@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-02-25 12:37:46 -08:00
Dragos Bogdan
2a5b3370a1 hwmon: (axi-fan-control) Fix possible NULL pointer dereference
axi_fan_control_irq_handler(), dependent on the private
axi_fan_control_data structure, might be called before the hwmon
device is registered. That will cause an "Unable to handle kernel
NULL pointer dereference" error.

Fixes: 8412b410fa ("hwmon: Support ADI Fan Control IP")
Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20231025132100.649499-1-nuno.sa@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-10-25 11:56:22 -07:00
Krzysztof Kozlowski
a1e308bfae hwmon: axi-fan: constify pointers to hwmon_channel_info
Statically allocated array of pointed to hwmon_channel_info can be made
const for safety.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-04-19 07:08:34 -07:00
Uwe Kleine-König
0dee25ebc7 hwmon: Make use of devm_clk_get_enabled()
Several drivers manually register a devm handler to disable their clk.
Convert them to devm_clk_get_enabled().

Acked-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-09-25 14:22:11 -07:00
Nuno Sá
5d4a2ea96b hwmon: (axi-fan-control) Use hwmon_notify_event
Instead of directly accessing kobj directly from the driver, use the
hwmon notify API.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220308135408.440744-1-nuno.sa@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-03-08 09:20:00 -08:00
Nuno Sá
2aee7e67be hwmon: (axi-fan-control) Support temperature vs pwm points
The HW has some predefined points where it will associate a PWM value.
However some users might want to better set these points to their
usecases. This patch exposes these points as pwm auto_points:

 * pwm1_auto_point1_temp_hyst: temperature threshold below which PWM should
   be 0%;
 * pwm1_auto_point1_temp: temperature threshold above which PWM should be
   25%;
 * pwm1_auto_point2_temp_hyst: temperature threshold below which PWM should
   be 25%;
 * pwm1_auto_point2_temp: temperature threshold above which PWM should be
   50%;
 * pwm1_auto_point3_temp_hyst: temperature threshold below which PWM should
   be 50%;
 * pwm1_auto_point3_temp: temperature threshold above which PWM should be
   75%;
 * pwm1_auto_point4_temp_hyst: temperature threshold below which PWM should
   be 75%;
 * pwm1_auto_point4_temp: temperature threshold above which PWM should be
   100%;

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210811114853.159298-4-nuno.sa@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Nuno Sá
e66705de82 hwmon: (axi-fan-control) Handle irqs in natural order
The core will now start out of reset at boot as soon as clocking is
available. Hence, by the time we unmask the interrupts we already might
have some of them set. Thus, it's important to handle them in the
natural order the core generates them. Otherwise, we could process
'ADI_IRQ_SRC_PWM_CHANGED' before 'ADI_IRQ_SRC_TEMP_INCREASE' and
erroneously set 'update_tacho_params' to true.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210811114853.159298-3-nuno.sa@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Nuno Sá
a3933625de hwmon: (axi-fan-control) Make sure the clock is enabled
The core will only work if it's clock is enabled. This patch is a
minor enhancement to make sure that's the case.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210811114853.159298-2-nuno.sa@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Alexandru Ardelean
dfddc57c99 hwmon: (axi-fan-control) remove duplicate macros
These macros are also present in the "include/linux/fpga/adi-axi-common.h"
file which is included in this driver.

This patch removes them from the AXI Fan Control driver. No sense in having
them in 2 places.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200803054311.98174-1-alexandru.ardelean@analog.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-08-04 14:27:20 -07:00
Nuno Sá
8412b410fa hwmon: Support ADI Fan Control IP
The purpose of this IP Core is to control the fan used for the cooling of a
Xilinx Zynq Ultrascale+ MPSoC without the need of any external temperature
sensors. To achieve this, the IP core uses the PL SYSMONE4 primitive to
obtain the PL temperature and, based on those readings, it then outputs
a PWM signal to control the fan rotation accordingly.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20191009102806.262241-1-nuno.sa@analog.com
[groeck: adi,pulses-per-revolution -> pulses-per-revolution;
 dropped unused 'res' from probe function]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-03-08 20:35:46 -07:00