Lines Matching +full:sensor +full:- +full:channel
1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2016-2019 HabanaLabs, Ltd.
49 dev_err_ratelimited(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_ratelimited(hdev->dev, "unsupported h/w sensor type %d\n", type); in adjust_hwmon_flags()
165 dev_err_ratelimited(hdev->dev, in hl_build_hwmon_channel_info()
166 "Got wrong sensor type %d from device\n", type); in hl_build_hwmon_channel_info()
167 return -EINVAL; in hl_build_hwmon_channel_info()
179 dev_dbg(hdev->dev, "num_sensors_for_type %d = %d\n", i, num_sensors_for_type); in hl_build_hwmon_channel_info()
183 rc = -ENOMEM; in hl_build_hwmon_channel_info()
201 rc = -ENOMEM; in hl_build_hwmon_channel_info()
208 rc = -ENOMEM; in hl_build_hwmon_channel_info()
217 channels_info[j]->type = i; in hl_build_hwmon_channel_info()
218 channels_info[j]->config = sensors_by_type[i]; in hl_build_hwmon_channel_info()
222 hdev->hl_chip_info->info = (const struct hwmon_channel_info **)channels_info; in hl_build_hwmon_channel_info()
229 kfree(channels_info[i]->config); in hl_build_hwmon_channel_info()
244 u32 attr, int channel, long *val) in hl_read() argument
252 return -ENODEV; in hl_read()
254 use_cpucp_enum = (hdev->asic_prop.fw_app_cpu_boot_dev_sts0 & in hl_read()
282 return -EINVAL; in hl_read()
286 rc = hl_get_temperature(hdev, channel, cpucp_attr, val); in hl_read()
288 rc = hl_get_temperature(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
305 return -EINVAL; in hl_read()
309 rc = hl_get_voltage(hdev, channel, cpucp_attr, val); in hl_read()
311 rc = hl_get_voltage(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
328 return -EINVAL; in hl_read()
332 rc = hl_get_current(hdev, channel, cpucp_attr, val); in hl_read()
334 rc = hl_get_current(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
348 return -EINVAL; in hl_read()
352 rc = hl_get_fan_speed(hdev, channel, cpucp_attr, val); in hl_read()
354 rc = hl_get_fan_speed(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
365 return -EINVAL; in hl_read()
369 rc = hl_get_pwm_info(hdev, channel, cpucp_attr, val); in hl_read()
372 rc = hl_get_pwm_info(hdev, channel, attr, val); in hl_read()
383 return -EINVAL; in hl_read()
387 rc = hl_get_power(hdev, channel, cpucp_attr, val); in hl_read()
389 rc = hl_get_power(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_read()
392 return -EINVAL; in hl_read()
398 u32 attr, int channel, long val) in hl_write() argument
402 bool use_cpucp_enum = (hdev->asic_prop.fw_app_cpu_boot_dev_sts0 & in hl_write()
406 return -ENODEV; in hl_write()
418 return -EINVAL; in hl_write()
422 hl_set_temperature(hdev, channel, cpucp_attr, val); in hl_write()
424 hl_set_temperature(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_write()
435 return -EINVAL; in hl_write()
439 hl_set_pwm_info(hdev, channel, cpucp_attr, val); in hl_write()
442 hl_set_pwm_info(hdev, channel, attr, val); in hl_write()
450 return -EINVAL; in hl_write()
454 hl_set_voltage(hdev, channel, cpucp_attr, val); in hl_write()
456 hl_set_voltage(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_write()
464 return -EINVAL; in hl_write()
468 hl_set_current(hdev, channel, cpucp_attr, val); in hl_write()
470 hl_set_current(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_write()
478 return -EINVAL; in hl_write()
482 hl_set_power(hdev, channel, cpucp_attr, val); in hl_write()
484 hl_set_power(hdev, channel, fixup_attr_legacy_fw(attr), val); in hl_write()
487 return -EINVAL; in hl_write()
493 u32 attr, int channel) in hl_is_visible() argument
582 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_temperature()
588 if (rc != -EAGAIN) in hl_get_temperature()
589 dev_err_ratelimited(hdev->dev, in hl_get_temperature()
590 "Failed to get temperature from sensor %d, error %d\n", in hl_get_temperature()
612 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_temperature()
614 if (rc && rc != -EAGAIN) in hl_set_temperature()
615 dev_err_ratelimited(hdev->dev, in hl_set_temperature()
616 "Failed to set temperature of sensor %d, error %d\n", in hl_set_temperature()
636 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_voltage()
642 if (rc != -EAGAIN) in hl_get_voltage()
643 dev_err_ratelimited(hdev->dev, in hl_get_voltage()
644 "Failed to get voltage from sensor %d, error %d\n", in hl_get_voltage()
666 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_current()
672 if (rc != -EAGAIN) in hl_get_current()
673 dev_err_ratelimited(hdev->dev, in hl_get_current()
674 "Failed to get current from sensor %d, error %d\n", in hl_get_current()
696 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_fan_speed()
702 if (rc != -EAGAIN) in hl_get_fan_speed()
703 dev_err_ratelimited(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 if (rc != -EAGAIN) in hl_get_pwm_info()
733 dev_err_ratelimited(hdev->dev, in hl_get_pwm_info()
734 "Failed to get pwm info from sensor %d, error %d\n", in hl_get_pwm_info()
756 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_pwm_info()
758 if (rc && rc != -EAGAIN) in hl_set_pwm_info()
759 dev_err_ratelimited(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()
780 if (rc && rc != -EAGAIN) in hl_set_voltage()
781 dev_err_ratelimited(hdev->dev, in hl_set_voltage()
782 "Failed to set voltage of sensor %d, error %d\n", in hl_set_voltage()
802 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), 0, NULL); in hl_set_current()
803 if (rc && rc != -EAGAIN) in hl_set_current()
804 dev_err_ratelimited(hdev->dev, in hl_set_current()
805 "Failed to set current of sensor %d, error %d\n", in hl_set_current()
815 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_set_power()
820 if (prop->use_get_power_for_reset_history) in hl_set_power()
831 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_power()
833 if (rc && rc != -EAGAIN) in hl_set_power()
834 dev_err_ratelimited(hdev->dev, in hl_set_power()
835 "Failed to set power of sensor %d, error %d\n", in hl_set_power()
855 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_power()
861 if (rc != -EAGAIN) in hl_get_power()
862 dev_err_ratelimited(hdev->dev, in hl_get_power()
863 "Failed to get power of sensor %d, error %d\n", in hl_get_power()
873 struct device *dev = hdev->pdev ? &hdev->pdev->dev : hdev->dev; in hl_hwmon_init()
874 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_hwmon_init()
877 if ((hdev->hwmon_initialized) || !(hdev->cpu_queues_enable)) in hl_hwmon_init()
880 if (hdev->hl_chip_info->info) { in hl_hwmon_init()
881 hdev->hl_chip_info->ops = &hl_hwmon_ops; in hl_hwmon_init()
883 hdev->hwmon_dev = hwmon_device_register_with_info(dev, in hl_hwmon_init()
884 prop->cpucp_info.card_name, hdev, in hl_hwmon_init()
885 hdev->hl_chip_info, NULL); in hl_hwmon_init()
886 if (IS_ERR(hdev->hwmon_dev)) { in hl_hwmon_init()
887 rc = PTR_ERR(hdev->hwmon_dev); in hl_hwmon_init()
888 dev_err(hdev->dev, in hl_hwmon_init()
893 dev_info(hdev->dev, "%s: add sensors information\n", in hl_hwmon_init()
894 dev_name(hdev->hwmon_dev)); in hl_hwmon_init()
896 hdev->hwmon_initialized = true; in hl_hwmon_init()
898 dev_info(hdev->dev, "no available sensors\n"); in hl_hwmon_init()
906 if (!hdev->hwmon_initialized) in hl_hwmon_fini()
909 hwmon_device_unregister(hdev->hwmon_dev); in hl_hwmon_fini()
917 if (!hdev->hl_chip_info->info) in hl_hwmon_release_resources()
920 channel_info_arr = hdev->hl_chip_info->info; in hl_hwmon_release_resources()
923 kfree(channel_info_arr[i]->config); in hl_hwmon_release_resources()
930 hdev->hl_chip_info->info = NULL; in hl_hwmon_release_resources()