Lines Matching defs:hdev
17 static u32 fixup_flags_legacy_fw(struct hl_device *hdev, enum hwmon_sensor_types type,
49 dev_err(hdev->dev, "unsupported h/w sensor type %d\n", type);
64 static u32 fixup_flags_legacy_fw(struct hl_device *hdev, enum hwmon_sensor_types type,
77 static u32 adjust_hwmon_flags(struct hl_device *hdev, enum hwmon_sensor_types type, u32 cpucp_flags)
82 use_cpucp_enum = (hdev->asic_prop.fw_app_cpu_boot_dev_sts0 &
137 dev_err(hdev->dev, "unsupported h/w sensor type %d\n", type);
142 flags = fixup_flags_legacy_fw(hdev, type, cpucp_flags);
148 int hl_build_hwmon_channel_info(struct hl_device *hdev, struct cpucp_sensor *sensors_arr)
165 dev_err(hdev->dev, "Got wrong sensor type %d from device\n", type);
178 dev_dbg(hdev->dev, "num_sensors_for_type %d = %d\n", i, num_sensors_for_type);
193 flags = adjust_hwmon_flags(hdev, type, le32_to_cpu(sensors_arr[i].flags));
221 hdev->hl_chip_info->info = (const struct hwmon_channel_info **)channels_info;
245 struct hl_device *hdev = dev_get_drvdata(dev);
250 if (!hl_device_operational(hdev, NULL))
253 use_cpucp_enum = (hdev->asic_prop.fw_app_cpu_boot_dev_sts0 &
285 rc = hl_get_temperature(hdev, channel, cpucp_attr, val);
287 rc = hl_get_temperature(hdev, channel, fixup_attr_legacy_fw(attr), val);
308 rc = hl_get_voltage(hdev, channel, cpucp_attr, val);
310 rc = hl_get_voltage(hdev, channel, fixup_attr_legacy_fw(attr), val);
331 rc = hl_get_current(hdev, channel, cpucp_attr, val);
333 rc = hl_get_current(hdev, channel, fixup_attr_legacy_fw(attr), val);
351 rc = hl_get_fan_speed(hdev, channel, cpucp_attr, val);
353 rc = hl_get_fan_speed(hdev, channel, fixup_attr_legacy_fw(attr), val);
368 rc = hl_get_pwm_info(hdev, channel, cpucp_attr, val);
371 rc = hl_get_pwm_info(hdev, channel, attr, val);
386 rc = hl_get_power(hdev, channel, cpucp_attr, val);
388 rc = hl_get_power(hdev, channel, fixup_attr_legacy_fw(attr), val);
399 struct hl_device *hdev = dev_get_drvdata(dev);
401 bool use_cpucp_enum = (hdev->asic_prop.fw_app_cpu_boot_dev_sts0 &
404 if (!hl_device_operational(hdev, NULL))
421 hl_set_temperature(hdev, channel, cpucp_attr, val);
423 hl_set_temperature(hdev, channel, fixup_attr_legacy_fw(attr), val);
438 hl_set_pwm_info(hdev, channel, cpucp_attr, val);
441 hl_set_pwm_info(hdev, channel, attr, val);
453 hl_set_voltage(hdev, channel, cpucp_attr, val);
455 hl_set_voltage(hdev, channel, fixup_attr_legacy_fw(attr), val);
467 hl_set_current(hdev, channel, cpucp_attr, val);
469 hl_set_current(hdev, channel, fixup_attr_legacy_fw(attr), val);
481 hl_set_power(hdev, channel, cpucp_attr, val);
483 hl_set_power(hdev, channel, fixup_attr_legacy_fw(attr), val);
568 int hl_get_temperature(struct hl_device *hdev,
582 dev_dbg(hdev->dev, "get temp, ctl 0x%x, sensor %d, type %d\n",
585 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
591 dev_err(hdev->dev,
600 int hl_set_temperature(struct hl_device *hdev,
614 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
618 dev_err(hdev->dev,
625 int hl_get_voltage(struct hl_device *hdev,
639 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
645 dev_err(hdev->dev,
654 int hl_get_current(struct hl_device *hdev,
668 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
674 dev_err(hdev->dev,
683 int hl_get_fan_speed(struct hl_device *hdev,
697 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
703 dev_err(hdev->dev,
712 int hl_get_pwm_info(struct hl_device *hdev,
726 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
732 dev_err(hdev->dev,
741 void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
755 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
759 dev_err(hdev->dev,
764 int hl_set_voltage(struct hl_device *hdev,
778 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
782 dev_err(hdev->dev,
789 int hl_set_current(struct hl_device *hdev,
803 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
807 dev_err(hdev->dev,
814 int hl_set_power(struct hl_device *hdev,
818 struct asic_fixed_properties *prop = &hdev->asic_prop;
834 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
838 dev_err(hdev->dev,
845 int hl_get_power(struct hl_device *hdev,
859 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
865 dev_err(hdev->dev,
874 int hl_hwmon_init(struct hl_device *hdev)
876 struct device *dev = hdev->pdev ? &hdev->pdev->dev : hdev->dev;
877 struct asic_fixed_properties *prop = &hdev->asic_prop;
880 if ((hdev->hwmon_initialized) || !(hdev->cpu_queues_enable))
883 if (hdev->hl_chip_info->info) {
884 hdev->hl_chip_info->ops = &hl_hwmon_ops;
886 hdev->hwmon_dev = hwmon_device_register_with_info(dev,
887 prop->cpucp_info.card_name, hdev,
888 hdev->hl_chip_info, NULL);
889 if (IS_ERR(hdev->hwmon_dev)) {
890 rc = PTR_ERR(hdev->hwmon_dev);
891 dev_err(hdev->dev,
896 dev_info(hdev->dev, "%s: add sensors information\n",
897 dev_name(hdev->hwmon_dev));
899 hdev->hwmon_initialized = true;
901 dev_info(hdev->dev, "no available sensors\n");
907 void hl_hwmon_fini(struct hl_device *hdev)
909 if (!hdev->hwmon_initialized)
912 hwmon_device_unregister(hdev->hwmon_dev);
915 void hl_hwmon_release_resources(struct hl_device *hdev)
920 if (!hdev->hl_chip_info->info)
923 channel_info_arr = hdev->hl_chip_info->info;
933 hdev->hl_chip_info->info = NULL;