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
581 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_temperature()
587 dev_err(hdev->dev, in hl_get_temperature()
588 "Failed to get temperature from sensor %d, error %d\n", in hl_get_temperature()
610 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_temperature()
614 dev_err(hdev->dev, in hl_set_temperature()
615 "Failed to set temperature of sensor %d, error %d\n", in hl_set_temperature()
635 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_voltage()
641 dev_err(hdev->dev, in hl_get_voltage()
642 "Failed to get voltage from sensor %d, error %d\n", in hl_get_voltage()
664 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_current()
670 dev_err(hdev->dev, in hl_get_current()
671 "Failed to get current from sensor %d, error %d\n", in hl_get_current()
693 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_fan_speed()
699 dev_err(hdev->dev, in hl_get_fan_speed()
700 "Failed to get fan speed from sensor %d, error %d\n", in hl_get_fan_speed()
722 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_get_pwm_info()
728 dev_err(hdev->dev, in hl_get_pwm_info()
729 "Failed to get pwm info from sensor %d, error %d\n", in hl_get_pwm_info()
751 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_pwm_info()
755 dev_err(hdev->dev, in hl_set_pwm_info()
756 "Failed to set pwm info to sensor %d, error %d\n", in hl_set_pwm_info()
774 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_voltage()
778 dev_err(hdev->dev, in hl_set_voltage()
779 "Failed to set voltage of sensor %d, error %d\n", in hl_set_voltage()
799 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_current()
803 dev_err(hdev->dev, in hl_set_current()
804 "Failed to set current of sensor %d, error %d\n", in hl_set_current()
814 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_set_power()
819 if (prop->use_get_power_for_reset_history) in hl_set_power()
830 rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt), in hl_set_power()
834 dev_err(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 dev_err(hdev->dev, in hl_get_power()
862 "Failed to get power of sensor %d, error %d\n", in hl_get_power()
872 struct device *dev = hdev->pdev ? &hdev->pdev->dev : hdev->dev; in hl_hwmon_init()
873 struct asic_fixed_properties *prop = &hdev->asic_prop; in hl_hwmon_init()
876 if ((hdev->hwmon_initialized) || !(hdev->cpu_queues_enable)) in hl_hwmon_init()
879 if (hdev->hl_chip_info->info) { in hl_hwmon_init()
880 hdev->hl_chip_info->ops = &hl_hwmon_ops; in hl_hwmon_init()
882 hdev->hwmon_dev = hwmon_device_register_with_info(dev, in hl_hwmon_init()
883 prop->cpucp_info.card_name, hdev, in hl_hwmon_init()
884 hdev->hl_chip_info, NULL); in hl_hwmon_init()
885 if (IS_ERR(hdev->hwmon_dev)) { in hl_hwmon_init()
886 rc = PTR_ERR(hdev->hwmon_dev); in hl_hwmon_init()
887 dev_err(hdev->dev, in hl_hwmon_init()
892 dev_info(hdev->dev, "%s: add sensors information\n", in hl_hwmon_init()
893 dev_name(hdev->hwmon_dev)); in hl_hwmon_init()
895 hdev->hwmon_initialized = true; in hl_hwmon_init()
897 dev_info(hdev->dev, "no available sensors\n"); in hl_hwmon_init()
905 if (!hdev->hwmon_initialized) in hl_hwmon_fini()
908 hwmon_device_unregister(hdev->hwmon_dev); in hl_hwmon_fini()
916 if (!hdev->hl_chip_info->info) in hl_hwmon_release_resources()
919 channel_info_arr = hdev->hl_chip_info->info; in hl_hwmon_release_resources()
922 kfree(channel_info_arr[i]->config); in hl_hwmon_release_resources()
929 hdev->hl_chip_info->info = NULL; in hl_hwmon_release_resources()