Skip to content

Commit 5c36cf2

Browse files
spandruvadarafaeljw
authored andcommitted
thermal: intel: int340x: Add production mode attribute
It is possible that the system manufacturer locks down thermal tuning beyond what is usually done on the given platform. In that case user space calibration tools should not try to adjust the thermal configuration of the system. To allow user space to check if that is the case, add a new sysfs attribute "production_mode" that will be present when the ACPI DCFG method is present under the INT3400 device object in the ACPI Namespace. Signed-off-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent fee19c6 commit 5c36cf2

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

Documentation/driver-api/thermal/intel_dptf.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ DPTF ACPI Drivers interface
8484
https:/github.com/intel/thermal_daemon for decoding
8585
thermal table.
8686

87+
``production_mode`` (RO)
88+
When different from zero, manufacturer locked thermal configuration
89+
from further changes.
8790

8891
ACPI Thermal Relationship table interface
8992
------------------------------------------

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct int3400_thermal_priv {
6060
int odvp_count;
6161
int *odvp;
6262
u32 os_uuid_mask;
63+
int production_mode;
6364
struct odvp_attr *odvp_attrs;
6465
};
6566

@@ -309,6 +310,44 @@ static int int3400_thermal_get_uuids(struct int3400_thermal_priv *priv)
309310
return result;
310311
}
311312

313+
static ssize_t production_mode_show(struct device *dev, struct device_attribute *attr,
314+
char *buf)
315+
{
316+
struct int3400_thermal_priv *priv = dev_get_drvdata(dev);
317+
318+
return sysfs_emit(buf, "%d\n", priv->production_mode);
319+
}
320+
321+
static DEVICE_ATTR_RO(production_mode);
322+
323+
static int production_mode_init(struct int3400_thermal_priv *priv)
324+
{
325+
unsigned long long mode;
326+
acpi_status status;
327+
int ret;
328+
329+
priv->production_mode = -1;
330+
331+
status = acpi_evaluate_integer(priv->adev->handle, "DCFG", NULL, &mode);
332+
/* If the method is not present, this is not an error */
333+
if (ACPI_FAILURE(status))
334+
return 0;
335+
336+
ret = sysfs_create_file(&priv->pdev->dev.kobj, &dev_attr_production_mode.attr);
337+
if (ret)
338+
return ret;
339+
340+
priv->production_mode = mode;
341+
342+
return 0;
343+
}
344+
345+
static void production_mode_exit(struct int3400_thermal_priv *priv)
346+
{
347+
if (priv->production_mode >= 0)
348+
sysfs_remove_file(&priv->pdev->dev.kobj, &dev_attr_production_mode.attr);
349+
}
350+
312351
static ssize_t odvp_show(struct device *dev, struct device_attribute *attr,
313352
char *buf)
314353
{
@@ -604,8 +643,15 @@ static int int3400_thermal_probe(struct platform_device *pdev)
604643
if (result)
605644
goto free_sysfs;
606645

646+
result = production_mode_init(priv);
647+
if (result)
648+
goto free_notify;
649+
607650
return 0;
608651

652+
free_notify:
653+
acpi_remove_notify_handler(priv->adev->handle, ACPI_DEVICE_NOTIFY,
654+
int3400_notify);
609655
free_sysfs:
610656
cleanup_odvp(priv);
611657
if (!ZERO_OR_NULL_PTR(priv->data_vault)) {
@@ -632,6 +678,8 @@ static int int3400_thermal_remove(struct platform_device *pdev)
632678
{
633679
struct int3400_thermal_priv *priv = platform_get_drvdata(pdev);
634680

681+
production_mode_exit(priv);
682+
635683
acpi_remove_notify_handler(
636684
priv->adev->handle, ACPI_DEVICE_NOTIFY,
637685
int3400_notify);

0 commit comments

Comments
 (0)