Commit 100a5737 authored by Mario Limonciello's avatar Mario Limonciello Committed by Rafael J. Wysocki

ACPI: x86: s2idle: Move _HID handling for AMD systems into structures

Right now the information about which cases to use for what are in a
comment, but this is error prone.  Instead move all information into
a dedicated structure.

Tested-by: catalin@antebit.com
Reviewed-by: default avatarPhilipp Zabel <philipp.zabel@gmail.com>
Tested-by: Philipp Zabel <philipp.zabel@gmail.com> # GA402RJ
Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 0efe92b4
...@@ -363,6 +363,39 @@ static int validate_dsm(acpi_handle handle, const char *uuid, int rev, guid_t *d ...@@ -363,6 +363,39 @@ static int validate_dsm(acpi_handle handle, const char *uuid, int rev, guid_t *d
return ret; return ret;
} }
struct amd_lps0_hid_device_data {
const unsigned int rev_id;
const bool check_off_by_one;
const bool prefer_amd_guid;
};
static const struct amd_lps0_hid_device_data amd_picasso = {
.rev_id = 0,
.check_off_by_one = true,
.prefer_amd_guid = false,
};
static const struct amd_lps0_hid_device_data amd_cezanne = {
.rev_id = 0,
.check_off_by_one = false,
.prefer_amd_guid = false,
};
static const struct amd_lps0_hid_device_data amd_rembrandt = {
.rev_id = 2,
.check_off_by_one = false,
.prefer_amd_guid = true,
};
static const struct acpi_device_id amd_hid_ids[] = {
{"AMD0004", (kernel_ulong_t)&amd_picasso, },
{"AMD0005", (kernel_ulong_t)&amd_picasso, },
{"AMDI0005", (kernel_ulong_t)&amd_picasso, },
{"AMDI0006", (kernel_ulong_t)&amd_cezanne, },
{"AMDI0007", (kernel_ulong_t)&amd_rembrandt, },
{}
};
static int lps0_device_attach(struct acpi_device *adev, static int lps0_device_attach(struct acpi_device *adev,
const struct acpi_device_id *not_used) const struct acpi_device_id *not_used)
{ {
...@@ -370,31 +403,27 @@ static int lps0_device_attach(struct acpi_device *adev, ...@@ -370,31 +403,27 @@ static int lps0_device_attach(struct acpi_device *adev,
return 0; return 0;
if (acpi_s2idle_vendor_amd()) { if (acpi_s2idle_vendor_amd()) {
/* AMD0004, AMD0005, AMDI0005: static const struct acpi_device_id *dev_id;
* - Should use rev_id 0x0 const struct amd_lps0_hid_device_data *data;
* - function mask > 0x3: Should use AMD method, but has off by one bug
* - function mask = 0x3: Should use Microsoft method for (dev_id = &amd_hid_ids[0]; dev_id->id[0]; dev_id++)
* AMDI0006: if (acpi_dev_hid_uid_match(adev, dev_id->id, NULL))
* - should use rev_id 0x0 break;
* - function mask = 0x3: Should use Microsoft method if (dev_id)
* AMDI0007: data = (const struct amd_lps0_hid_device_data *) dev_id->driver_data;
* - Should use rev_id 0x2 else
* - Should only use AMD method return 0;
*/ rev_id = data->rev_id;
const char *hid = acpi_device_hid(adev);
rev_id = strcmp(hid, "AMDI0007") ? 0 : 2;
lps0_dsm_func_mask = validate_dsm(adev->handle, lps0_dsm_func_mask = validate_dsm(adev->handle,
ACPI_LPS0_DSM_UUID_AMD, rev_id, &lps0_dsm_guid); ACPI_LPS0_DSM_UUID_AMD, rev_id, &lps0_dsm_guid);
lps0_dsm_func_mask_microsoft = validate_dsm(adev->handle, lps0_dsm_func_mask_microsoft = validate_dsm(adev->handle,
ACPI_LPS0_DSM_UUID_MICROSOFT, 0, ACPI_LPS0_DSM_UUID_MICROSOFT, 0,
&lps0_dsm_guid_microsoft); &lps0_dsm_guid_microsoft);
if (lps0_dsm_func_mask > 0x3 && (!strcmp(hid, "AMD0004") || if (lps0_dsm_func_mask > 0x3 && data->check_off_by_one) {
!strcmp(hid, "AMD0005") ||
!strcmp(hid, "AMDI0005"))) {
lps0_dsm_func_mask = (lps0_dsm_func_mask << 1) | 0x1; lps0_dsm_func_mask = (lps0_dsm_func_mask << 1) | 0x1;
acpi_handle_debug(adev->handle, "_DSM UUID %s: Adjusted function mask: 0x%x\n", acpi_handle_debug(adev->handle, "_DSM UUID %s: Adjusted function mask: 0x%x\n",
ACPI_LPS0_DSM_UUID_AMD, lps0_dsm_func_mask); ACPI_LPS0_DSM_UUID_AMD, lps0_dsm_func_mask);
} else if (lps0_dsm_func_mask_microsoft > 0 && } else if (lps0_dsm_func_mask_microsoft > 0 && data->prefer_amd_guid &&
(!strcmp(hid, "AMDI0007") || (!strcmp(hid, "AMDI0007") ||
!strcmp(hid, "AMDI0008"))) { !strcmp(hid, "AMDI0008"))) {
lps0_dsm_func_mask_microsoft = -EINVAL; lps0_dsm_func_mask_microsoft = -EINVAL;
......
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