#include "habanalabs.h"
#include <linux/pci.h>
#include <linux/hwmon.h>
#define HWMON_NR_SENSOR_TYPES …
#ifdef _HAS_HWMON_HWMON_T_ENABLE
static u32 fixup_flags_legacy_fw(struct hl_device *hdev, enum hwmon_sensor_types type,
u32 cpucp_flags)
{
u32 flags;
switch (type) {
case hwmon_temp:
flags = (cpucp_flags << 1) | HWMON_T_ENABLE;
break;
case hwmon_in:
flags = (cpucp_flags << 1) | HWMON_I_ENABLE;
break;
case hwmon_curr:
flags = (cpucp_flags << 1) | HWMON_C_ENABLE;
break;
case hwmon_fan:
flags = (cpucp_flags << 1) | HWMON_F_ENABLE;
break;
case hwmon_power:
flags = (cpucp_flags << 1) | HWMON_P_ENABLE;
break;
case hwmon_pwm:
flags = cpucp_flags;
break;
default:
dev_err_ratelimited(hdev->dev, "unsupported h/w sensor type %d\n", type);
flags = cpucp_flags;
break;
}
return flags;
}
static u32 fixup_attr_legacy_fw(u32 attr)
{
return (attr - 1);
}
#else
static u32 fixup_flags_legacy_fw(struct hl_device *hdev, enum hwmon_sensor_types type,
u32 cpucp_flags)
{ … }
static u32 fixup_attr_legacy_fw(u32 attr)
{ … }
#endif
static u32 adjust_hwmon_flags(struct hl_device *hdev, enum hwmon_sensor_types type, u32 cpucp_flags)
{ … }
int hl_build_hwmon_channel_info(struct hl_device *hdev, struct cpucp_sensor *sensors_arr)
{ … }
static int hl_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{ … }
static int hl_write(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long val)
{ … }
static umode_t hl_is_visible(const void *data, enum hwmon_sensor_types type,
u32 attr, int channel)
{ … }
static const struct hwmon_ops hl_hwmon_ops = …;
int hl_get_temperature(struct hl_device *hdev,
int sensor_index, u32 attr, long *value)
{ … }
int hl_set_temperature(struct hl_device *hdev,
int sensor_index, u32 attr, long value)
{ … }
int hl_get_voltage(struct hl_device *hdev,
int sensor_index, u32 attr, long *value)
{ … }
int hl_get_current(struct hl_device *hdev,
int sensor_index, u32 attr, long *value)
{ … }
int hl_get_fan_speed(struct hl_device *hdev,
int sensor_index, u32 attr, long *value)
{ … }
int hl_get_pwm_info(struct hl_device *hdev,
int sensor_index, u32 attr, long *value)
{ … }
void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
long value)
{ … }
int hl_set_voltage(struct hl_device *hdev,
int sensor_index, u32 attr, long value)
{ … }
int hl_set_current(struct hl_device *hdev,
int sensor_index, u32 attr, long value)
{ … }
int hl_set_power(struct hl_device *hdev,
int sensor_index, u32 attr, long value)
{ … }
int hl_get_power(struct hl_device *hdev,
int sensor_index, u32 attr, long *value)
{ … }
int hl_hwmon_init(struct hl_device *hdev)
{ … }
void hl_hwmon_fini(struct hl_device *hdev)
{ … }
void hl_hwmon_release_resources(struct hl_device *hdev)
{ … }