From owner-svn-src-head@freebsd.org Tue Jan 10 10:56:34 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8BDB5CA8139; Tue, 10 Jan 2017 10:56:34 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DCE41FBB; Tue, 10 Jan 2017 10:56:34 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v0AAuXSD028224; Tue, 10 Jan 2017 10:56:33 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v0AAuXb7028222; Tue, 10 Jan 2017 10:56:33 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201701101056.v0AAuXb7028222@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 10 Jan 2017 10:56:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r311874 - in head/sys: conf dev/ahci X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jan 2017 10:56:34 -0000 Author: andrew Date: Tue Jan 10 10:56:33 2017 New Revision: 311874 URL: https://svnweb.freebsd.org/changeset/base/311874 Log: 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 Modified: head/sys/conf/files.arm64 head/sys/dev/ahci/ahci_generic.c Modified: head/sys/conf/files.arm64 ============================================================================== --- head/sys/conf/files.arm64 Tue Jan 10 10:33:36 2017 (r311873) +++ head/sys/conf/files.arm64 Tue Jan 10 10:56:33 2017 (r311874) @@ -145,7 +145,7 @@ armv8_crypto_wrap.o optional armv8crypt crypto/blowfish/bf_enc.c optional crypto | ipsec crypto/des/des_enc.c optional crypto | ipsec | netsmb dev/acpica/acpi_if.m optional acpi -dev/ahci/ahci_generic.c optional ahci fdt +dev/ahci/ahci_generic.c optional ahci dev/cpufreq/cpufreq_dt.c optional cpufreq fdt dev/hwpmc/hwpmc_arm64.c optional hwpmc dev/hwpmc/hwpmc_arm64_md.c optional hwpmc Modified: head/sys/dev/ahci/ahci_generic.c ============================================================================== --- head/sys/dev/ahci/ahci_generic.c Tue Jan 10 10:33:36 2017 (r311873) +++ head/sys/dev/ahci/ahci_generic.c Tue Jan 10 10:56:33 2017 (r311874) @@ -27,6 +27,9 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_acpi.h" +#include "opt_platform.h" + #include #include #include @@ -44,6 +47,15 @@ __FBSDID("$FreeBSD$"); #include +#ifdef DEV_ACPI +#include +#include + +#include +#include +#endif + +#ifdef FDT #include #include @@ -54,14 +66,7 @@ static struct ofw_compat_data compat_dat }; 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