Lines Matching full:hwmon
6 #include <linux/hwmon.h>
7 #include <linux/hwmon-sysfs.h>
19 * SF_* - scale factors for particular quantities according to hwmon spec.
47 struct i915_hwmon *hwmon; member
71 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_locked_with_pm_intel_uncore_rmw() local
75 mutex_lock(&hwmon->hwmon_lock); in hwm_locked_with_pm_intel_uncore_rmw()
80 mutex_unlock(&hwmon->hwmon_lock); in hwm_locked_with_pm_intel_uncore_rmw()
119 * the hwmon API. Using x86_64 128 bit arithmetic (see mul_u64_u32_shr()),
121 * hwmon->scl_shift_energy of 14 bits we have 57 (63 - 20 + 14) bits before
128 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_energy() local
135 rgaddr = hwmon->rg.energy_status_tile; in hwm_energy()
137 rgaddr = hwmon->rg.energy_status_all; in hwm_energy()
139 mutex_lock(&hwmon->hwmon_lock); in hwm_energy()
151 hwmon->scl_shift_energy); in hwm_energy()
152 mutex_unlock(&hwmon->hwmon_lock); in hwm_energy()
160 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power1_max_interval_show() local
166 r = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_rapl_limit); in hwm_power1_max_interval_show()
179 /* val in hwmon interface units (millisec) */ in hwm_power1_max_interval_show()
180 out = mul_u64_u32_shr(tau4, SF_TIME, hwmon->scl_shift_time + x_w); in hwm_power1_max_interval_show()
191 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power1_max_interval_store() local
203 * The hwmon->scl_shift_time default of 0xa results in a max tau of 256 seconds in hwm_power1_max_interval_store()
208 * val must be < max in hwmon interface units. The steps below are in hwm_power1_max_interval_store()
215 max_win = mul_u64_u32_shr(tau4, SF_TIME, hwmon->scl_shift_time + x_w); in hwm_power1_max_interval_store()
221 val = DIV_ROUND_CLOSEST_ULL((u64)val << hwmon->scl_shift_time, SF_TIME); in hwm_power1_max_interval_store()
235 hwm_locked_with_pm_intel_uncore_rmw(ddat, hwmon->rg.pkg_rapl_limit, in hwm_power1_max_interval_store()
254 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_attributes_visible() local
257 return i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit) ? attr->mode : 0; in hwm_attributes_visible()
318 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_in_read() local
325 reg_value = intel_uncore_read(ddat->uncore, hwmon->rg.gt_perf_status); in hwm_in_read()
338 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power_is_visible() local
343 return i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit) ? 0664 : 0; in hwm_power_is_visible()
345 return i915_mmio_reg_valid(hwmon->rg.pkg_power_sku) ? 0444 : 0; in hwm_power_is_visible()
365 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power_max_read() local
371 r = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_rapl_limit); in hwm_power_max_read()
378 hwmon->rg.pkg_rapl_limit, in hwm_power_max_read()
380 hwmon->scl_shift_power, in hwm_power_max_read()
384 r = intel_uncore_read64(ddat->uncore, hwmon->rg.pkg_power_sku); in hwm_power_max_read()
386 min = mul_u64_u32_shr(min, SF_POWER, hwmon->scl_shift_power); in hwm_power_max_read()
388 max = mul_u64_u32_shr(max, SF_POWER, hwmon->scl_shift_power); in hwm_power_max_read()
399 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power_max_write() local
407 mutex_lock(&hwmon->hwmon_lock); in hwm_power_max_write()
411 if (!hwmon->ddat.reset_in_progress) in hwm_power_max_write()
419 mutex_unlock(&hwmon->hwmon_lock); in hwm_power_max_write()
431 intel_uncore_rmw(ddat->uncore, hwmon->rg.pkg_rapl_limit, in hwm_power_max_write()
433 nval = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_rapl_limit); in hwm_power_max_write()
441 nval = DIV_ROUND_CLOSEST_ULL((u64)val << hwmon->scl_shift_power, SF_POWER); in hwm_power_max_write()
444 intel_uncore_rmw(ddat->uncore, hwmon->rg.pkg_rapl_limit, in hwm_power_max_write()
449 mutex_unlock(&hwmon->hwmon_lock); in hwm_power_max_write()
456 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_power_read() local
465 hwmon->rg.pkg_power_sku, in hwm_power_read()
467 hwmon->scl_shift_power, in hwm_power_read()
502 struct i915_hwmon *hwmon = i915->hwmon; in i915_hwmon_power_max_disable() local
505 if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit)) in i915_hwmon_power_max_disable()
508 mutex_lock(&hwmon->hwmon_lock); in i915_hwmon_power_max_disable()
510 hwmon->ddat.reset_in_progress = true; in i915_hwmon_power_max_disable()
511 r = intel_uncore_rmw(hwmon->ddat.uncore, hwmon->rg.pkg_rapl_limit, in i915_hwmon_power_max_disable()
515 mutex_unlock(&hwmon->hwmon_lock); in i915_hwmon_power_max_disable()
520 struct i915_hwmon *hwmon = i915->hwmon; in i915_hwmon_power_max_restore() local
522 if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit)) in i915_hwmon_power_max_restore()
525 mutex_lock(&hwmon->hwmon_lock); in i915_hwmon_power_max_restore()
527 intel_uncore_rmw(hwmon->ddat.uncore, hwmon->rg.pkg_rapl_limit, in i915_hwmon_power_max_restore()
529 hwmon->ddat.reset_in_progress = false; in i915_hwmon_power_max_restore()
530 wake_up_all(&hwmon->ddat.waitq); in i915_hwmon_power_max_restore()
532 mutex_unlock(&hwmon->hwmon_lock); in i915_hwmon_power_max_restore()
538 struct i915_hwmon *hwmon = ddat->hwmon; in hwm_energy_is_visible() local
544 rgaddr = hwmon->rg.energy_status_tile; in hwm_energy_is_visible()
546 rgaddr = hwmon->rg.energy_status_all; in hwm_energy_is_visible()
723 struct i915_hwmon *hwmon = i915->hwmon; in hwm_get_preregistration_info() local
725 struct hwm_drvdata *ddat = &hwmon->ddat; in hwm_get_preregistration_info()
733 hwmon->rg.gt_perf_status = GEN12_RPSTAT1; in hwm_get_preregistration_info()
736 hwmon->rg.pkg_power_sku_unit = PCU_PACKAGE_POWER_SKU_UNIT; in hwm_get_preregistration_info()
737 hwmon->rg.pkg_power_sku = PCU_PACKAGE_POWER_SKU; in hwm_get_preregistration_info()
738 hwmon->rg.pkg_rapl_limit = PCU_PACKAGE_RAPL_LIMIT; in hwm_get_preregistration_info()
739 hwmon->rg.energy_status_all = PCU_PACKAGE_ENERGY_STATUS; in hwm_get_preregistration_info()
740 hwmon->rg.energy_status_tile = INVALID_MMIO_REG; in hwm_get_preregistration_info()
742 hwmon->rg.pkg_power_sku_unit = GT0_PACKAGE_POWER_SKU_UNIT; in hwm_get_preregistration_info()
743 hwmon->rg.pkg_power_sku = INVALID_MMIO_REG; in hwm_get_preregistration_info()
744 hwmon->rg.pkg_rapl_limit = GT0_PACKAGE_RAPL_LIMIT; in hwm_get_preregistration_info()
745 hwmon->rg.energy_status_all = GT0_PLATFORM_ENERGY_STATUS; in hwm_get_preregistration_info()
746 hwmon->rg.energy_status_tile = GT0_PACKAGE_ENERGY_STATUS; in hwm_get_preregistration_info()
748 hwmon->rg.pkg_power_sku_unit = INVALID_MMIO_REG; in hwm_get_preregistration_info()
749 hwmon->rg.pkg_power_sku = INVALID_MMIO_REG; in hwm_get_preregistration_info()
750 hwmon->rg.pkg_rapl_limit = INVALID_MMIO_REG; in hwm_get_preregistration_info()
751 hwmon->rg.energy_status_all = INVALID_MMIO_REG; in hwm_get_preregistration_info()
752 hwmon->rg.energy_status_tile = INVALID_MMIO_REG; in hwm_get_preregistration_info()
757 * The contents of register hwmon->rg.pkg_power_sku_unit do not change, in hwm_get_preregistration_info()
760 if (i915_mmio_reg_valid(hwmon->rg.pkg_power_sku_unit)) in hwm_get_preregistration_info()
762 hwmon->rg.pkg_power_sku_unit); in hwm_get_preregistration_info()
765 hwmon->scl_shift_power = REG_FIELD_GET(PKG_PWR_UNIT, val_sku_unit); in hwm_get_preregistration_info()
766 hwmon->scl_shift_energy = REG_FIELD_GET(PKG_ENERGY_UNIT, val_sku_unit); in hwm_get_preregistration_info()
767 hwmon->scl_shift_time = REG_FIELD_GET(PKG_TIME_UNIT, val_sku_unit); in hwm_get_preregistration_info()
773 if (i915_mmio_reg_valid(hwmon->rg.energy_status_all)) in hwm_get_preregistration_info()
775 if (i915_mmio_reg_valid(hwmon->rg.energy_status_tile)) { in hwm_get_preregistration_info()
777 hwm_energy(&hwmon->ddat_gt[i], &energy); in hwm_get_preregistration_info()
784 struct i915_hwmon *hwmon; in i915_hwmon_register() local
791 /* hwmon is available only for dGfx */ in i915_hwmon_register()
795 hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL); in i915_hwmon_register()
796 if (!hwmon) in i915_hwmon_register()
799 i915->hwmon = hwmon; in i915_hwmon_register()
800 mutex_init(&hwmon->hwmon_lock); in i915_hwmon_register()
801 ddat = &hwmon->ddat; in i915_hwmon_register()
803 ddat->hwmon = hwmon; in i915_hwmon_register()
810 ddat_gt = hwmon->ddat_gt + i; in i915_hwmon_register()
812 ddat_gt->hwmon = hwmon; in i915_hwmon_register()
820 /* hwmon_dev points to device hwmon<i> */ in i915_hwmon_register()
826 i915->hwmon = NULL; in i915_hwmon_register()
833 ddat_gt = hwmon->ddat_gt + i; in i915_hwmon_register()
852 fetch_and_zero(&i915->hwmon); in i915_hwmon_unregister()