Skip to content

Commit 0ba13c7

Browse files
mjg59dlezcano
authored andcommitted
thermal/int340x_thermal: Export GDDV
Implementing DPTF properly requires making use of firmware-provided information associated with the INT3400 device. Calling GDDV provides a buffer of information which userland can then interpret to determine appropriate DPTF policy. Conflicts: drivers/thermal/intel/int340x_thermal/int3400_thermal.c Signed-off-by: Matthew Garrett <mjg59@google.com> Tested-by: Pandruvada, Srinivas <srinivas.pandruvada@linux.intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com> Link: https://lore.kernel.org/r/20200414020953.255364-1-matthewgarrett@google.com
1 parent 47fa116 commit 0ba13c7

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ struct int3400_thermal_priv {
5252
u8 uuid_bitmap;
5353
int rel_misc_dev_res;
5454
int current_uuid_index;
55+
char *data_vault;
56+
};
57+
58+
static ssize_t data_vault_read(struct file *file, struct kobject *kobj,
59+
struct bin_attribute *attr, char *buf, loff_t off, size_t count)
60+
{
61+
memcpy(buf, attr->private + off, count);
62+
return count;
63+
}
64+
65+
static BIN_ATTR_RO(data_vault, 0);
66+
67+
static struct bin_attribute *data_attributes[] = {
68+
&bin_attr_data_vault,
69+
NULL,
70+
};
71+
72+
static const struct attribute_group data_attribute_group = {
73+
.bin_attrs = data_attributes,
5574
};
5675

5776
static ssize_t available_uuids_show(struct device *dev,
@@ -280,6 +299,32 @@ static struct thermal_zone_params int3400_thermal_params = {
280299
.no_hwmon = true,
281300
};
282301

302+
static void int3400_setup_gddv(struct int3400_thermal_priv *priv)
303+
{
304+
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
305+
union acpi_object *obj;
306+
acpi_status status;
307+
308+
status = acpi_evaluate_object(priv->adev->handle, "GDDV", NULL,
309+
&buffer);
310+
if (ACPI_FAILURE(status) || !buffer.length)
311+
return;
312+
313+
obj = buffer.pointer;
314+
if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 1
315+
|| obj->package.elements[0].type != ACPI_TYPE_BUFFER) {
316+
kfree(buffer.pointer);
317+
return;
318+
}
319+
320+
priv->data_vault = kmemdup(obj->package.elements[0].buffer.pointer,
321+
obj->package.elements[0].buffer.length,
322+
GFP_KERNEL);
323+
bin_attr_data_vault.private = priv->data_vault;
324+
bin_attr_data_vault.size = obj->package.elements[0].buffer.length;
325+
kfree(buffer.pointer);
326+
}
327+
283328
static int int3400_thermal_probe(struct platform_device *pdev)
284329
{
285330
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
@@ -311,6 +356,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)
311356

312357
platform_set_drvdata(pdev, priv);
313358

359+
int3400_setup_gddv(priv);
360+
314361
priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0,
315362
priv, &int3400_thermal_ops,
316363
&int3400_thermal_params, 0, 0);
@@ -326,6 +373,13 @@ static int int3400_thermal_probe(struct platform_device *pdev)
326373
if (result)
327374
goto free_rel_misc;
328375

376+
if (priv->data_vault) {
377+
result = sysfs_create_group(&pdev->dev.kobj,
378+
&data_attribute_group);
379+
if (result)
380+
goto free_uuid;
381+
}
382+
329383
result = acpi_install_notify_handler(
330384
priv->adev->handle, ACPI_DEVICE_NOTIFY, int3400_notify,
331385
(void *)priv);
@@ -335,6 +389,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)
335389
return 0;
336390

337391
free_sysfs:
392+
if (priv->data_vault)
393+
sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
394+
free_uuid:
338395
sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group);
339396
free_rel_misc:
340397
if (!priv->rel_misc_dev_res)
@@ -359,8 +416,11 @@ static int int3400_thermal_remove(struct platform_device *pdev)
359416
if (!priv->rel_misc_dev_res)
360417
acpi_thermal_rel_misc_device_remove(priv->adev->handle);
361418

419+
if (priv->data_vault)
420+
sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
362421
sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group);
363422
thermal_zone_device_unregister(priv->thermal);
423+
kfree(priv->data_vault);
364424
kfree(priv->trts);
365425
kfree(priv->arts);
366426
kfree(priv);

0 commit comments

Comments
 (0)