aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2017-01-10 10:56:33 +0000
committerAndrew Turner <andrew@FreeBSD.org>2017-01-10 10:56:33 +0000
commit2647410d059e4b1a042625eda57dfcf0c00fb0f0 (patch)
treec9c584f0ab22dd5dc7f0e22e8d12ecedc592071a /sys/dev
parent7c07ea9aa23363a9aa160505cc7fa33f3b2739d7 (diff)
downloadsrc-2647410d059e4b1a042625eda57dfcf0c00fb0f0.tar.gz
src-2647410d059e4b1a042625eda57dfcf0c00fb0f0.zip
Add an ACPI attachment to the existing ahci_generic driver. This is used
in some arm64 hardware, for example the AMD Opteron A1100. Reviewed by: mav Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8852
Notes
Notes: svn path=/head/; revision=311874
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ahci/ahci_generic.c88
1 files changed, 74 insertions, 14 deletions
diff --git a/sys/dev/ahci/ahci_generic.c b/sys/dev/ahci/ahci_generic.c
index 80f7fedee049..a427e7aeaeea 100644
--- a/sys/dev/ahci/ahci_generic.c
+++ b/sys/dev/ahci/ahci_generic.c
@@ -27,6 +27,9 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_acpi.h"
+#include "opt_platform.h"
+
#include <sys/param.h>
#include <sys/module.h>
#include <sys/systm.h>
@@ -44,6 +47,15 @@ __FBSDID("$FreeBSD$");
#include <dev/ahci/ahci.h>
+#ifdef DEV_ACPI
+#include <contrib/dev/acpica/include/acpi.h>
+#include <dev/acpica/acpivar.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#endif
+
+#ifdef FDT
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -54,14 +66,7 @@ static struct ofw_compat_data compat_data[] = {
};
static int
-ahci_gen_ctlr_reset(device_t dev)
-{
-
- return ahci_ctlr_reset(dev);
-}
-
-static int
-ahci_probe(device_t dev)
+ahci_fdt_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
@@ -73,6 +78,34 @@ ahci_probe(device_t dev)
device_set_desc_copy(dev, "AHCI SATA controller");
return (BUS_PROBE_DEFAULT);
}
+#endif
+
+#ifdef DEV_ACPI
+static int
+ahci_acpi_probe(device_t dev)
+{
+ ACPI_HANDLE h;
+
+ if ((h = acpi_get_handle(dev)) == NULL)
+ return (ENXIO);
+
+ if (pci_get_class(dev) == PCIC_STORAGE &&
+ pci_get_subclass(dev) == PCIS_STORAGE_SATA &&
+ pci_get_progif(dev) == PCIP_STORAGE_SATA_AHCI_1_0) {
+ device_set_desc_copy(dev, "AHCI SATA controller");
+ return (BUS_PROBE_DEFAULT);
+ }
+
+ return (ENXIO);
+}
+#endif
+
+static int
+ahci_gen_ctlr_reset(device_t dev)
+{
+
+ return ahci_ctlr_reset(dev);
+}
static int
ahci_gen_attach(device_t dev)
@@ -109,9 +142,34 @@ ahci_gen_detach(device_t dev)
return (0);
}
-static devclass_t ahci_gen_devclass;
-static device_method_t ahci_methods[] = {
- DEVMETHOD(device_probe, ahci_probe),
+#ifdef FDT
+static devclass_t ahci_gen_fdt_devclass;
+static device_method_t ahci_fdt_methods[] = {
+ DEVMETHOD(device_probe, ahci_fdt_probe),
+ DEVMETHOD(device_attach, ahci_gen_attach),
+ DEVMETHOD(device_detach, ahci_gen_detach),
+ DEVMETHOD(bus_print_child, ahci_print_child),
+ DEVMETHOD(bus_alloc_resource, ahci_alloc_resource),
+ DEVMETHOD(bus_release_resource, ahci_release_resource),
+ DEVMETHOD(bus_setup_intr, ahci_setup_intr),
+ DEVMETHOD(bus_teardown_intr,ahci_teardown_intr),
+ DEVMETHOD(bus_child_location_str, ahci_child_location_str),
+ DEVMETHOD(bus_get_dma_tag, ahci_get_dma_tag),
+ DEVMETHOD_END
+};
+static driver_t ahci_fdt_driver = {
+ "ahci",
+ ahci_fdt_methods,
+ sizeof(struct ahci_controller)
+};
+DRIVER_MODULE(ahci_fdt, simplebus, ahci_fdt_driver, ahci_gen_fdt_devclass,
+ NULL, NULL);
+#endif
+
+#ifdef DEV_ACPI
+static devclass_t ahci_gen_acpi_devclass;
+static device_method_t ahci_acpi_methods[] = {
+ DEVMETHOD(device_probe, ahci_acpi_probe),
DEVMETHOD(device_attach, ahci_gen_attach),
DEVMETHOD(device_detach, ahci_gen_detach),
DEVMETHOD(bus_print_child, ahci_print_child),
@@ -123,9 +181,11 @@ static device_method_t ahci_methods[] = {
DEVMETHOD(bus_get_dma_tag, ahci_get_dma_tag),
DEVMETHOD_END
};
-static driver_t ahci_driver = {
+static driver_t ahci_acpi_driver = {
"ahci",
- ahci_methods,
+ ahci_acpi_methods,
sizeof(struct ahci_controller)
};
-DRIVER_MODULE(ahci, simplebus, ahci_driver, ahci_gen_devclass, NULL, NULL);
+DRIVER_MODULE(ahci_acpi, acpi, ahci_acpi_driver, ahci_gen_acpi_devclass,
+ NULL, NULL);
+#endif