Commit 0ba13c76 authored by Matthew Garrett's avatar Matthew Garrett Committed by Daniel Lezcano

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: default avatarMatthew Garrett <mjg59@google.com>
Tested-by: default avatarPandruvada, Srinivas <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
Link: https://lore.kernel.org/r/20200414020953.255364-1-matthewgarrett@google.com
parent 47fa116e
...@@ -52,6 +52,25 @@ struct int3400_thermal_priv { ...@@ -52,6 +52,25 @@ struct int3400_thermal_priv {
u8 uuid_bitmap; u8 uuid_bitmap;
int rel_misc_dev_res; int rel_misc_dev_res;
int current_uuid_index; int current_uuid_index;
char *data_vault;
};
static ssize_t data_vault_read(struct file *file, struct kobject *kobj,
struct bin_attribute *attr, char *buf, loff_t off, size_t count)
{
memcpy(buf, attr->private + off, count);
return count;
}
static BIN_ATTR_RO(data_vault, 0);
static struct bin_attribute *data_attributes[] = {
&bin_attr_data_vault,
NULL,
};
static const struct attribute_group data_attribute_group = {
.bin_attrs = data_attributes,
}; };
static ssize_t available_uuids_show(struct device *dev, static ssize_t available_uuids_show(struct device *dev,
...@@ -280,6 +299,32 @@ static struct thermal_zone_params int3400_thermal_params = { ...@@ -280,6 +299,32 @@ static struct thermal_zone_params int3400_thermal_params = {
.no_hwmon = true, .no_hwmon = true,
}; };
static void int3400_setup_gddv(struct int3400_thermal_priv *priv)
{
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *obj;
acpi_status status;
status = acpi_evaluate_object(priv->adev->handle, "GDDV", NULL,
&buffer);
if (ACPI_FAILURE(status) || !buffer.length)
return;
obj = buffer.pointer;
if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 1
|| obj->package.elements[0].type != ACPI_TYPE_BUFFER) {
kfree(buffer.pointer);
return;
}
priv->data_vault = kmemdup(obj->package.elements[0].buffer.pointer,
obj->package.elements[0].buffer.length,
GFP_KERNEL);
bin_attr_data_vault.private = priv->data_vault;
bin_attr_data_vault.size = obj->package.elements[0].buffer.length;
kfree(buffer.pointer);
}
static int int3400_thermal_probe(struct platform_device *pdev) static int int3400_thermal_probe(struct platform_device *pdev)
{ {
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
...@@ -311,6 +356,8 @@ static int int3400_thermal_probe(struct platform_device *pdev) ...@@ -311,6 +356,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
int3400_setup_gddv(priv);
priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0, priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0,
priv, &int3400_thermal_ops, priv, &int3400_thermal_ops,
&int3400_thermal_params, 0, 0); &int3400_thermal_params, 0, 0);
...@@ -326,6 +373,13 @@ static int int3400_thermal_probe(struct platform_device *pdev) ...@@ -326,6 +373,13 @@ static int int3400_thermal_probe(struct platform_device *pdev)
if (result) if (result)
goto free_rel_misc; goto free_rel_misc;
if (priv->data_vault) {
result = sysfs_create_group(&pdev->dev.kobj,
&data_attribute_group);
if (result)
goto free_uuid;
}
result = acpi_install_notify_handler( result = acpi_install_notify_handler(
priv->adev->handle, ACPI_DEVICE_NOTIFY, int3400_notify, priv->adev->handle, ACPI_DEVICE_NOTIFY, int3400_notify,
(void *)priv); (void *)priv);
...@@ -335,6 +389,9 @@ static int int3400_thermal_probe(struct platform_device *pdev) ...@@ -335,6 +389,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)
return 0; return 0;
free_sysfs: free_sysfs:
if (priv->data_vault)
sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
free_uuid:
sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group); sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group);
free_rel_misc: free_rel_misc:
if (!priv->rel_misc_dev_res) if (!priv->rel_misc_dev_res)
...@@ -359,8 +416,11 @@ static int int3400_thermal_remove(struct platform_device *pdev) ...@@ -359,8 +416,11 @@ static int int3400_thermal_remove(struct platform_device *pdev)
if (!priv->rel_misc_dev_res) if (!priv->rel_misc_dev_res)
acpi_thermal_rel_misc_device_remove(priv->adev->handle); acpi_thermal_rel_misc_device_remove(priv->adev->handle);
if (priv->data_vault)
sysfs_remove_group(&pdev->dev.kobj, &data_attribute_group);
sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group); sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group);
thermal_zone_device_unregister(priv->thermal); thermal_zone_device_unregister(priv->thermal);
kfree(priv->data_vault);
kfree(priv->trts); kfree(priv->trts);
kfree(priv->arts); kfree(priv->arts);
kfree(priv); kfree(priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment