Lines Matching +full:sensor +full:- +full:channel
1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2016-2019 HabanaLabs, Ltd.
49 dev_err(hdev->dev, "unsupported h/w sensor type %d\n", type); in fixup_flags_legacy_fw()
59 return (attr - 1); in fixup_attr_legacy_fw()
82 use_cpucp_enum = (hdev->asic_prop.fw_app_cpu_boot_dev_sts0 & in adjust_hwmon_flags()
137 dev_err(hdev->dev, "unsupported h/w sensor type %d\n", type); in adjust_hwmon_flags()
165 dev_err(hdev->dev, "Got wrong sensor type %d from device\n", type); in hl_build_hwmon_channel_info()
166 return -EINVAL; in hl_build_hwmon_channel_info()
178 dev_dbg(hdev->dev, "num_sensors_for_type %d = %d\n", i, num_sensors_for_type); in hl_build_hwmon_channel_info()
182 rc = -ENOMEM; in hl_build_hwmon_channel_info()
200 rc = -ENOMEM; in hl_build_hwmon_channel_info()
207 rc = -ENOMEM; in hl_build_hwmon_channel_info()
216 channels_info[j]->type = i; in hl_build_hwmon_channel_info()
217 channels_info[j]->config = sensors_by_type[i]; in hl_build_hwmon_channel_info()
221 hdev->hl_chip_info->info = (const struct hwmon_channel_info **)channels_info; in hl_build_hwmon_channel_info()
228 kfree(channels_info[i]->config); in hl_build_hwmon_channel_info()
243 u32 attr, int channel, long *val) in hl_read() argument
251 return -ENODEV; in hl_read()
253 use_cpucp_enum = (hdev->asic_prop.fw_app_cpu_boot_dev_sts0 & in hl_read()
281 return -EINVAL; in hl_read()
285 rc = hl_get_temperature(hdev, channel, cpucp_attr, val); in hl_read()
287 rc = hl_get_temperature(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
304 return -EINVAL; in hl_read()
308 rc = hl_get_voltage(hdev, channel, cpucp_attr, val); in hl_read()
310 rc = hl_get_voltage(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
327 return -EINVAL; in hl_read()
331 rc = hl_get_current(hdev, channel, cpucp_attr, val); in hl_read()
333 rc = hl_get_current(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
347 return -EINVAL; in hl_read()
351 rc = hl_get_fan_speed(hdev, channel, cpucp_attr, val); in hl_read()
353 rc = hl_get_fan_speed(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
364 return -EINVAL; in hl_read()
368 rc = hl_get_pwm_info(hdev, channel, cpucp_attr, val); in hl_read()
371 rc = hl_get_pwm_info(hdev, channel, attr, val); in hl_read()
382 return -EINVAL; in hl_read()
386 rc = hl_get_power(hdev, channel, cpucp_attr, val); in hl_read()
388 rc = hl_get_power(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
391 return -EINVAL; in hl_read()
397 u32 attr, int channel, long val) in hl_write() argument
401 bool use_cpucp_enum = (hdev->asic_prop.fw_app_cpu_boot_dev_sts0 & in hl_write()
405 return -ENODEV; in hl_write()
417 return -EINVAL; in hl_write()
421 hl_set_temperature(hdev, channel, cpucp_attr, val); in hl_write()
423 hl_set_temperature(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_write()
434 return -EINVAL; in hl_write()
438 hl_set_pwm_info(hdev, channel, cpucp_attr, val); in hl_write()
441 hl_set_pwm_info(hdev, channel, attr, val); in hl_write()
449 return -EINVAL; in hl_write()
453 hl_set_voltage(hdev, channel, cpucp_attr, val); in hl_write()
455 hl_set_voltage(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_write()
463 return -EINVAL; in hl_write()
467 hl_set_current(hdev, channel, cpucp_attr, val); in hl_write()
469 hl_set_current(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_write()
477 return -EINVAL; in hl_write()
481 hl_set_power(hdev, channel, cpucp_attr, val); in hl_write()
483 hl_set_power(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_write()
486 return -EINVAL; in hl_write()
492 u32 attr, int channel) in hl_is_visible() argument
582 dev_dbg(hdev->dev, "get temp, ctl 0x%x, sensor %d, type %d\n", in hl_get_temperature()
585 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_temperature()
591 dev_err(hdev->dev, in hl_get_temperature()
592 "Failed to get temperature from sensor %d, error %d\n", in hl_get_temperature()
614 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_temperature()
618 dev_err(hdev->dev, in hl_set_temperature()
619 "Failed to set temperature of sensor %d, error %d\n", in hl_set_temperature()
639 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_voltage()
645 dev_err(hdev->dev, in hl_get_voltage()
646 "Failed to get voltage from sensor %d, error %d\n", in hl_get_voltage()
668 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_current()
674 dev_err(hdev->dev, in hl_get_current()
675 "Failed to get current from sensor %d, error %d\n", in hl_get_current()
697 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_fan_speed()
703 dev_err(hdev->dev, in hl_get_fan_speed()
704 "Failed to get fan speed from sensor %d, error %d\n", in hl_get_fan_speed()
726 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_pwm_info()
732 dev_err(hdev->dev, in hl_get_pwm_info()
733 "Failed to get pwm info from sensor %d, error %d\n", in hl_get_pwm_info()
755 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_pwm_info()
759 dev_err(hdev->dev, in hl_set_pwm_info()
760 "Failed to set pwm info to sensor %d, error %d\n", in hl_set_pwm_info()
778 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_voltage()
782 dev_err(hdev->dev, in hl_set_voltage()
783 "Failed to set voltage of sensor %d, error %d\n", in hl_set_voltage()
803 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_current()
807 dev_err(hdev->dev, in hl_set_current()
808 "Failed to set current of sensor %d, error %d\n", in hl_set_current()
818 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_set_power()
823 if (prop->use_get_power_for_reset_history) in hl_set_power()
834 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_power()
838 dev_err(hdev->dev, in hl_set_power()
839 "Failed to set power of sensor %d, error %d\n", in hl_set_power()
859 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_power()
865 dev_err(hdev->dev, in hl_get_power()
866 "Failed to get power of sensor %d, error %d\n", in hl_get_power()
876 struct device *dev = hdev->pdev ? &hdev->pdev->dev : hdev->dev; in hl_hwmon_init()
877 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_hwmon_init()
880 if ((hdev->hwmon_initialized) || !(hdev->cpu_queues_enable)) in hl_hwmon_init()
883 if (hdev->hl_chip_info->info) { in hl_hwmon_init()
884 hdev->hl_chip_info->ops = &hl_hwmon_ops; in hl_hwmon_init()
886 hdev->hwmon_dev = hwmon_device_register_with_info(dev, in hl_hwmon_init()
887 prop->cpucp_info.card_name, hdev, in hl_hwmon_init()
888 hdev->hl_chip_info, NULL); in hl_hwmon_init()
889 if (IS_ERR(hdev->hwmon_dev)) { in hl_hwmon_init()
890 rc = PTR_ERR(hdev->hwmon_dev); in hl_hwmon_init()
891 dev_err(hdev->dev, in hl_hwmon_init()
896 dev_info(hdev->dev, "%s: add sensors information\n", in hl_hwmon_init()
897 dev_name(hdev->hwmon_dev)); in hl_hwmon_init()
899 hdev->hwmon_initialized = true; in hl_hwmon_init()
901 dev_info(hdev->dev, "no available sensors\n"); in hl_hwmon_init()
909 if (!hdev->hwmon_initialized) in hl_hwmon_fini()
912 hwmon_device_unregister(hdev->hwmon_dev); in hl_hwmon_fini()
920 if (!hdev->hl_chip_info->info) in hl_hwmon_release_resources()
923 channel_info_arr = hdev->hl_chip_info->info; in hl_hwmon_release_resources()
926 kfree(channel_info_arr[i]->config); in hl_hwmon_release_resources()
933 hdev->hl_chip_info->info = NULL; in hl_hwmon_release_resources()