Lines Matching full:hwmon
6 #include <linux/hwmon.h>
7 #include <linux/hwmon-sysfs.h>
20 * SF_* - scale factors for particular quantities according to hwmon spec.
54 struct i915_hwmon *hwmon; member
79 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_locked_with_pm_intel_uncore_rmw() local
84 mutex_lock(&hwmon->hwmon_lock); in hwm_locked_with_pm_intel_uncore_rmw()
88 mutex_unlock(&hwmon->hwmon_lock); in hwm_locked_with_pm_intel_uncore_rmw()
128 * the hwmon API. Using x86_64 128 bit arithmetic (see mul_u64_u32_shr()),
130 * hwmon->scl_shift_energy of 14 bits we have 57 (63 - 20 + 14) bits before
137 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_energy() local
144 rgaddr = hwmon->rg.energy_status_tile; in hwm_energy()
146 rgaddr = hwmon->rg.energy_status_all; in hwm_energy()
149 mutex_lock(&hwmon->hwmon_lock); in hwm_energy()
160 hwmon->scl_shift_energy); in hwm_energy()
161 mutex_unlock(&hwmon->hwmon_lock); in hwm_energy()
170 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power1_max_interval_show() local
176 r = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_rapl_limit); in hwm_power1_max_interval_show()
189 /* val in hwmon interface units (millisec) */ in hwm_power1_max_interval_show()
190 out = mul_u64_u32_shr(tau4, SF_TIME, hwmon->scl_shift_time + x_w); in hwm_power1_max_interval_show()
201 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power1_max_interval_store() local
213 * The hwmon->scl_shift_time default of 0xa results in a max tau of 256 seconds in hwm_power1_max_interval_store()
218 * val must be < max in hwmon interface units. The steps below are in hwm_power1_max_interval_store()
225 max_win = mul_u64_u32_shr(tau4, SF_TIME, hwmon->scl_shift_time + x_w); in hwm_power1_max_interval_store()
231 val = DIV_ROUND_CLOSEST_ULL((u64)val << hwmon->scl_shift_time, SF_TIME); in hwm_power1_max_interval_store()
245 hwm_locked_with_pm_intel_uncore_rmw(ddat, hwmon->rg.pkg_rapl_limit, in hwm_power1_max_interval_store()
264 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_attributes_visible() local
267 return i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit) ? attr->mode : 0; in hwm_attributes_visible()
329 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_in_read() local
336 reg_value = intel_uncore_read(ddat->uncore, hwmon->rg.gt_perf_status); in hwm_in_read()
349 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power_is_visible() local
354 return i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit) ? 0664 : 0; in hwm_power_is_visible()
356 return i915_mmio_reg_valid(hwmon->rg.pkg_power_sku) ? 0444 : 0; in hwm_power_is_visible()
376 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power_max_read() local
382 r = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_rapl_limit); in hwm_power_max_read()
389 hwmon->rg.pkg_rapl_limit, in hwm_power_max_read()
391 hwmon->scl_shift_power, in hwm_power_max_read()
395 r = intel_uncore_read64(ddat->uncore, hwmon->rg.pkg_power_sku); in hwm_power_max_read()
397 min = mul_u64_u32_shr(min, SF_POWER, hwmon->scl_shift_power); in hwm_power_max_read()
399 max = mul_u64_u32_shr(max, SF_POWER, hwmon->scl_shift_power); in hwm_power_max_read()
410 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power_max_write() local
419 mutex_lock(&hwmon->hwmon_lock); in hwm_power_max_write()
423 if (!hwmon->ddat.reset_in_progress) in hwm_power_max_write()
431 mutex_unlock(&hwmon->hwmon_lock); in hwm_power_max_write()
442 intel_uncore_rmw(ddat->uncore, hwmon->rg.pkg_rapl_limit, in hwm_power_max_write()
444 nval = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_rapl_limit); in hwm_power_max_write()
452 nval = DIV_ROUND_CLOSEST_ULL((u64)val << hwmon->scl_shift_power, SF_POWER); in hwm_power_max_write()
455 intel_uncore_rmw(ddat->uncore, hwmon->rg.pkg_rapl_limit, in hwm_power_max_write()
458 mutex_unlock(&hwmon->hwmon_lock); in hwm_power_max_write()
466 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power_read() local
475 hwmon->rg.pkg_power_sku, in hwm_power_read()
477 hwmon->scl_shift_power, in hwm_power_read()
512 struct i915_hwmon *hwmon = i915->hwmon; in i915_hwmon_power_max_disable() local
515 if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit)) in i915_hwmon_power_max_disable()
518 mutex_lock(&hwmon->hwmon_lock); in i915_hwmon_power_max_disable()
520 hwmon->ddat.reset_in_progress = true; in i915_hwmon_power_max_disable()
521 r = intel_uncore_rmw(hwmon->ddat.uncore, hwmon->rg.pkg_rapl_limit, in i915_hwmon_power_max_disable()
525 mutex_unlock(&hwmon->hwmon_lock); in i915_hwmon_power_max_disable()
530 struct i915_hwmon *hwmon = i915->hwmon; in i915_hwmon_power_max_restore() local
532 if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit)) in i915_hwmon_power_max_restore()
535 mutex_lock(&hwmon->hwmon_lock); in i915_hwmon_power_max_restore()
537 intel_uncore_rmw(hwmon->ddat.uncore, hwmon->rg.pkg_rapl_limit, in i915_hwmon_power_max_restore()
539 hwmon->ddat.reset_in_progress = false; in i915_hwmon_power_max_restore()
540 wake_up_all(&hwmon->ddat.waitq); in i915_hwmon_power_max_restore()
542 mutex_unlock(&hwmon->hwmon_lock); in i915_hwmon_power_max_restore()
548 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_energy_is_visible() local
554 rgaddr = hwmon->rg.energy_status_tile; in hwm_energy_is_visible()
556 rgaddr = hwmon->rg.energy_status_all; in hwm_energy_is_visible()
628 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_fan_is_visible() local
630 if (attr == hwmon_fan_input && i915_mmio_reg_valid(hwmon->rg.fan_speed)) in hwm_fan_is_visible()
639 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_fan_input_read() local
647 mutex_lock(&hwmon->hwmon_lock); in hwm_fan_input_read()
649 reg_val = intel_uncore_read(ddat->uncore, hwmon->rg.fan_speed); in hwm_fan_input_read()
674 mutex_unlock(&hwmon->hwmon_lock); in hwm_fan_input_read()
800 struct i915_hwmon *hwmon = i915->hwmon; in hwm_get_preregistration_info() local
802 struct hwm_drvdata *ddat = &hwmon->ddat; in hwm_get_preregistration_info()
810 hwmon->rg.gt_perf_status = GEN12_RPSTAT1; in hwm_get_preregistration_info()
813 hwmon->rg.pkg_power_sku_unit = PCU_PACKAGE_POWER_SKU_UNIT; in hwm_get_preregistration_info()
814 hwmon->rg.pkg_power_sku = PCU_PACKAGE_POWER_SKU; in hwm_get_preregistration_info()
815 hwmon->rg.pkg_rapl_limit = PCU_PACKAGE_RAPL_LIMIT; in hwm_get_preregistration_info()
816 hwmon->rg.energy_status_all = PCU_PACKAGE_ENERGY_STATUS; in hwm_get_preregistration_info()
817 hwmon->rg.energy_status_tile = INVALID_MMIO_REG; in hwm_get_preregistration_info()
818 hwmon->rg.fan_speed = PCU_PWM_FAN_SPEED; in hwm_get_preregistration_info()
820 hwmon->rg.pkg_power_sku_unit = INVALID_MMIO_REG; in hwm_get_preregistration_info()
821 hwmon->rg.pkg_power_sku = INVALID_MMIO_REG; in hwm_get_preregistration_info()
822 hwmon->rg.pkg_rapl_limit = INVALID_MMIO_REG; in hwm_get_preregistration_info()
823 hwmon->rg.energy_status_all = INVALID_MMIO_REG; in hwm_get_preregistration_info()
824 hwmon->rg.energy_status_tile = INVALID_MMIO_REG; in hwm_get_preregistration_info()
825 hwmon->rg.fan_speed = INVALID_MMIO_REG; in hwm_get_preregistration_info()
830 * The contents of register hwmon->rg.pkg_power_sku_unit do not change, in hwm_get_preregistration_info()
833 if (i915_mmio_reg_valid(hwmon->rg.pkg_power_sku_unit)) in hwm_get_preregistration_info()
835 hwmon->rg.pkg_power_sku_unit); in hwm_get_preregistration_info()
841 if (i915_mmio_reg_valid(hwmon->rg.fan_speed)) { in hwm_get_preregistration_info()
843 hwmon->rg.fan_speed); in hwm_get_preregistration_info()
848 hwmon->scl_shift_power = REG_FIELD_GET(PKG_PWR_UNIT, val_sku_unit); in hwm_get_preregistration_info()
849 hwmon->scl_shift_energy = REG_FIELD_GET(PKG_ENERGY_UNIT, val_sku_unit); in hwm_get_preregistration_info()
850 hwmon->scl_shift_time = REG_FIELD_GET(PKG_TIME_UNIT, val_sku_unit); in hwm_get_preregistration_info()
856 if (i915_mmio_reg_valid(hwmon->rg.energy_status_all)) in hwm_get_preregistration_info()
858 if (i915_mmio_reg_valid(hwmon->rg.energy_status_tile)) { in hwm_get_preregistration_info()
860 hwm_energy(&hwmon->ddat_gt[i], &energy); in hwm_get_preregistration_info()
867 struct i915_hwmon *hwmon; in i915_hwmon_register() local
874 /* hwmon is available only for dGfx */ in i915_hwmon_register()
878 hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL); in i915_hwmon_register()
879 if (!hwmon) in i915_hwmon_register()
882 i915->hwmon = hwmon; in i915_hwmon_register()
883 mutex_init(&hwmon->hwmon_lock); in i915_hwmon_register()
884 ddat = &hwmon->ddat; in i915_hwmon_register()
886 ddat->hwmon = hwmon; in i915_hwmon_register()
893 ddat_gt = hwmon->ddat_gt + i; in i915_hwmon_register()
895 ddat_gt->hwmon = hwmon; in i915_hwmon_register()
903 /* hwmon_dev points to device hwmon<i> */ in i915_hwmon_register()
914 ddat_gt = hwmon->ddat_gt + i; in i915_hwmon_register()
936 struct i915_hwmon *hwmon = i915->hwmon; in i915_hwmon_unregister() local
940 if (!hwmon) in i915_hwmon_unregister()
944 if (hwmon->ddat_gt[i].hwmon_dev) in i915_hwmon_unregister()
945 hwmon_device_unregister(hwmon->ddat_gt[i].hwmon_dev); in i915_hwmon_unregister()
947 if (hwmon->ddat.hwmon_dev) in i915_hwmon_unregister()
948 hwmon_device_unregister(hwmon->ddat.hwmon_dev); in i915_hwmon_unregister()
950 mutex_destroy(&hwmon->hwmon_lock); in i915_hwmon_unregister()
952 kfree(i915->hwmon); in i915_hwmon_unregister()
953 i915->hwmon = NULL; in i915_hwmon_unregister()