having to add many more _HID entries to the match table.
ok deraadt@, mlarkin@
-/* $OpenBSD: acpi.c,v 1.355 2018/07/10 17:11:42 kettenis Exp $ */
+/* $OpenBSD: acpi.c,v 1.356 2018/08/03 22:18:13 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
void acpi_indicator(struct acpi_softc *, int);
-int acpi_matchhids(struct acpi_attach_args *aa, const char *hids[],
- const char *driver);
-
void acpi_init_pm(struct acpi_softc *);
int acpi_founddock(struct aml_node *, void *);
return 0;
}
+int
+acpi_matchcls(struct acpi_attach_args *aaa, int class, int subclass,
+ int interface)
+{
+ struct acpi_softc *sc = acpi_softc;
+ struct aml_value res;
+
+ if (aaa->aaa_dev == NULL || aaa->aaa_node == NULL)
+ return (0);
+
+ if (aml_evalname(sc, aaa->aaa_node, "_CLS", 0, NULL, &res))
+ return (0);
+
+ if (res.type != AML_OBJTYPE_PACKAGE || res.length != 3 ||
+ res.v_package[0]->type != AML_OBJTYPE_INTEGER ||
+ res.v_package[1]->type != AML_OBJTYPE_INTEGER ||
+ res.v_package[2]->type != AML_OBJTYPE_INTEGER)
+ return (0);
+
+ if (res.v_package[0]->v_integer == class &&
+ res.v_package[1]->v_integer == subclass &&
+ res.v_package[2]->v_integer == interface)
+ return (1);
+
+ return (0);
+}
+
int
_acpi_matchhids(const char *hid, const char *hids[])
{
-/* $OpenBSD: acpivar.h,v 1.96 2018/07/10 17:11:42 kettenis Exp $ */
+/* $OpenBSD: acpivar.h,v 1.97 2018/08/03 22:18:13 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
void acpi_poll(void *);
void acpi_sleep(int, char *);
+int acpi_matchcls(struct acpi_attach_args *, int, int, int);
int acpi_matchhids(struct acpi_attach_args *, const char *[], const char *);
int acpi_parsehid(struct aml_node *, void *, char *, char *, size_t);
-/* $OpenBSD: ahci_acpi.c,v 1.1 2018/07/01 15:54:59 kettenis Exp $ */
+/* $OpenBSD: ahci_acpi.c,v 1.2 2018/08/03 22:18:13 kettenis Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis
*
sizeof(struct ahci_acpi_softc), ahci_acpi_match, ahci_acpi_attach
};
-const char *ahci_hids[] = {
- "AMDI0600",
- "LNRO001E",
- NULL
-};
-
int ahci_acpi_parse_resources(int, union acpi_resource *, void *);
int
ahci_acpi_match(struct device *parent, void *match, void *aux)
{
struct acpi_attach_args *aaa = aux;
- struct cfdata *cf = match;
- return acpi_matchhids(aaa, ahci_hids, cf->cf_driver->cd_name);
+ return acpi_matchcls(aaa, PCI_CLASS_MASS_STORAGE,
+ PCI_SUBCLASS_MASS_STORAGE_SATA, PCI_INTERFACE_SATA_AHCI10);
}
void
-/* $OpenBSD: ahci_pci.c,v 1.14 2018/01/03 20:10:40 kettenis Exp $ */
+/* $OpenBSD: ahci_pci.c,v 1.15 2018/08/03 22:18:13 kettenis Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
#define AHCI_PCI_BAR 0x24
#define AHCI_PCI_ATI_SB600_MAGIC 0x40
#define AHCI_PCI_ATI_SB600_LOCKED 0x01
-#define AHCI_PCI_INTERFACE 0x01
struct ahci_pci_softc {
struct ahci_softc psc_ahci;
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG,
PCI_CLASS_MASS_STORAGE << PCI_CLASS_SHIFT |
PCI_SUBCLASS_MASS_STORAGE_SATA << PCI_SUBCLASS_SHIFT |
- AHCI_PCI_INTERFACE << PCI_INTERFACE_SHIFT |
+ PCI_INTERFACE_SATA_AHCI10 << PCI_INTERFACE_SHIFT |
PCI_REVISION(pa->pa_class) << PCI_REVISION_SHIFT);
pci_conf_write(pa->pa_pc, pa->pa_tag,
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_MASS_STORAGE &&
PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_MASS_STORAGE_SATA &&
- PCI_INTERFACE(pa->pa_class) == AHCI_PCI_INTERFACE)
+ PCI_INTERFACE(pa->pa_class) == PCI_INTERFACE_SATA_AHCI10)
return (2);
return (0);
-/* $OpenBSD: pcireg.h,v 1.55 2017/08/09 21:42:44 mlarkin Exp $ */
+/* $OpenBSD: pcireg.h,v 1.56 2018/08/03 22:18:13 kettenis Exp $ */
/* $NetBSD: pcireg.h,v 1.26 2000/05/10 16:58:42 thorpej Exp $ */
/*
#define PCI_SUBCLASS_MASS_STORAGE_RAID 0x04
#define PCI_SUBCLASS_MASS_STORAGE_ATA 0x05
#define PCI_SUBCLASS_MASS_STORAGE_SATA 0x06
+#define PCI_INTERFACE_SATA_AHCI10 0x01
#define PCI_SUBCLASS_MASS_STORAGE_SAS 0x07
#define PCI_SUBCLASS_MASS_STORAGE_NVM 0x08
#define PCI_SUBCLASS_MASS_STORAGE_UFS 0x09