diff options
author | Suthikulpanit, Suravee <Suravee.Suthikulpanit@amd.com> | 2015-07-06 19:55:20 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-07-06 19:55:20 -0400 |
commit | 26095a01d359827eeccec5459c28ddd976183179 (patch) | |
tree | 509afc56695ce2fe493cb920958801c314dffcfa /scripts | |
parent | d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff) |
ACPI / scan: Add support for ACPI _CLS device matching
Device drivers typically use ACPI _HIDs/_CIDs listed in struct device_driver
acpi_match_table to match devices. However, for generic drivers, we do not
want to list _HID for all supported devices. Also, certain classes of devices
do not have _CID (e.g. SATA, USB). Instead, we can leverage ACPI _CLS,
which specifies PCI-defined class code (i.e. base-class, subclass and
programming interface). This patch adds support for matching ACPI devices using
the _CLS method.
To support loadable module, current design uses _HID or _CID to match device's
modalias. With the new way of matching with _CLS this would requires modification
to the current ACPI modalias key to include _CLS. This patch appends PCI-defined
class-code to the existing ACPI modalias as following.
acpi:<HID>:<CID1>:<CID2>:..:<CIDn>:<bbsspp>:
E.g:
# cat /sys/devices/platform/AMDI0600:00/modalias
acpi:AMDI0600:010601:
where bb is th base-class code, ss is te sub-class code, and pp is the
programming interface code
Since there would not be _HID/_CID in the ACPI matching table of the driver,
this patch adds a field to acpi_device_id to specify the matching _CLS.
static const struct acpi_device_id ahci_acpi_match[] = {
{ ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff) },
{},
};
In this case, the corresponded entry in modules.alias file would be:
alias acpi*:010601:* ahci_platform
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mod/devicetable-offsets.c | 2 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 32 |
2 files changed, 32 insertions, 2 deletions
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index eff7de1fc82e..e70fcd12eeeb 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c | |||
@@ -63,6 +63,8 @@ int main(void) | |||
63 | 63 | ||
64 | DEVID(acpi_device_id); | 64 | DEVID(acpi_device_id); |
65 | DEVID_FIELD(acpi_device_id, id); | 65 | DEVID_FIELD(acpi_device_id, id); |
66 | DEVID_FIELD(acpi_device_id, cls); | ||
67 | DEVID_FIELD(acpi_device_id, cls_msk); | ||
66 | 68 | ||
67 | DEVID(pnp_device_id); | 69 | DEVID(pnp_device_id); |
68 | DEVID_FIELD(pnp_device_id, id); | 70 | DEVID_FIELD(pnp_device_id, id); |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 84c86f3cd6cd..5f2088209132 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -523,12 +523,40 @@ static int do_serio_entry(const char *filename, | |||
523 | } | 523 | } |
524 | ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); | 524 | ADD_TO_DEVTABLE("serio", serio_device_id, do_serio_entry); |
525 | 525 | ||
526 | /* looks like: "acpi:ACPI0003 or acpi:PNP0C0B" or "acpi:LNXVIDEO" */ | 526 | /* looks like: "acpi:ACPI0003" or "acpi:PNP0C0B" or "acpi:LNXVIDEO" or |
527 | * "acpi:bbsspp" (bb=base-class, ss=sub-class, pp=prog-if) | ||
528 | * | ||
529 | * NOTE: Each driver should use one of the following : _HID, _CIDs | ||
530 | * or _CLS. Also, bb, ss, and pp can be substituted with ?? | ||
531 | * as don't care byte. | ||
532 | */ | ||
527 | static int do_acpi_entry(const char *filename, | 533 | static int do_acpi_entry(const char *filename, |
528 | void *symval, char *alias) | 534 | void *symval, char *alias) |
529 | { | 535 | { |
530 | DEF_FIELD_ADDR(symval, acpi_device_id, id); | 536 | DEF_FIELD_ADDR(symval, acpi_device_id, id); |
531 | sprintf(alias, "acpi*:%s:*", *id); | 537 | DEF_FIELD_ADDR(symval, acpi_device_id, cls); |
538 | DEF_FIELD_ADDR(symval, acpi_device_id, cls_msk); | ||
539 | |||
540 | if (id && strlen((const char *)*id)) | ||
541 | sprintf(alias, "acpi*:%s:*", *id); | ||
542 | else if (cls) { | ||
543 | int i, byte_shift, cnt = 0; | ||
544 | unsigned int msk; | ||
545 | |||
546 | sprintf(&alias[cnt], "acpi*:"); | ||
547 | cnt = 6; | ||
548 | for (i = 1; i <= 3; i++) { | ||
549 | byte_shift = 8 * (3-i); | ||
550 | msk = (*cls_msk >> byte_shift) & 0xFF; | ||
551 | if (msk) | ||
552 | sprintf(&alias[cnt], "%02x", | ||
553 | (*cls >> byte_shift) & 0xFF); | ||
554 | else | ||
555 | sprintf(&alias[cnt], "??"); | ||
556 | cnt += 2; | ||
557 | } | ||
558 | sprintf(&alias[cnt], ":*"); | ||
559 | } | ||
532 | return 1; | 560 | return 1; |
533 | } | 561 | } |
534 | ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry); | 562 | ADD_TO_DEVTABLE("acpi", acpi_device_id, do_acpi_entry); |