Date: Tue, 28 Jul 2020 09:29:56 +0000 (UTC) From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363636 - in head/sys: conf dev/smc Message-ID: <202007280929.06S9Tu2X080424@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andrew Date: Tue Jul 28 09:29:56 2020 New Revision: 363636 URL: https://svnweb.freebsd.org/changeset/base/363636 Log: Add an ACPI attachment for if_smc This is needed by some of the Arm simulators as they implement a smc based network interface, but use ACPI rather than FDT. Sponsored by: Innovate UK Added: head/sys/dev/smc/if_smc_acpi.c - copied, changed from r363635, head/sys/dev/smc/if_smc_fdt.c Modified: head/sys/conf/files head/sys/dev/smc/if_smc.c head/sys/dev/smc/if_smc_fdt.c head/sys/dev/smc/if_smcvar.h Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Tue Jul 28 07:07:38 2020 (r363635) +++ head/sys/conf/files Tue Jul 28 09:29:56 2020 (r363636) @@ -3029,6 +3029,7 @@ dev/smbus/smbconf.c optional smbus dev/smbus/smbus.c optional smbus dev/smbus/smbus_if.m optional smbus dev/smc/if_smc.c optional smc +dev/smc/if_smc_acpi.c optional smc acpi dev/smc/if_smc_fdt.c optional smc fdt dev/snp/snp.c optional snp dev/sound/clone.c optional sound Modified: head/sys/dev/smc/if_smc.c ============================================================================== --- head/sys/dev/smc/if_smc.c Tue Jul 28 07:07:38 2020 (r363635) +++ head/sys/dev/smc/if_smc.c Tue Jul 28 09:29:56 2020 (r363636) @@ -80,6 +80,8 @@ __FBSDID("$FreeBSD$"); #include <dev/mii/mii_bitbang.h> #include <dev/mii/miivar.h> +#include "miibus_if.h" + #define SMC_LOCK(sc) mtx_lock(&(sc)->smc_mtx) #define SMC_UNLOCK(sc) mtx_unlock(&(sc)->smc_mtx) #define SMC_ASSERT_LOCKED(sc) mtx_assert(&(sc)->smc_mtx, MA_OWNED) @@ -479,6 +481,27 @@ smc_detach(device_t dev) return (0); } + +static device_method_t smc_methods[] = { + /* Device interface */ + DEVMETHOD(device_attach, smc_attach), + DEVMETHOD(device_detach, smc_detach), + + /* MII interface */ + DEVMETHOD(miibus_readreg, smc_miibus_readreg), + DEVMETHOD(miibus_writereg, smc_miibus_writereg), + DEVMETHOD(miibus_statchg, smc_miibus_statchg), + + { 0, 0 } +}; + +driver_t smc_driver = { + "smc", + smc_methods, + sizeof(struct smc_softc), +}; + +DRIVER_MODULE(miibus, smc, miibus_driver, miibus_devclass, 0, 0); static void smc_start(struct ifnet *ifp) Copied and modified: head/sys/dev/smc/if_smc_acpi.c (from r363635, head/sys/dev/smc/if_smc_fdt.c) ============================================================================== --- head/sys/dev/smc/if_smc_fdt.c Tue Jul 28 07:07:38 2020 (r363635, copy source) +++ head/sys/dev/smc/if_smc_acpi.c Tue Jul 28 09:29:56 2020 (r363636) @@ -1,6 +1,7 @@ /*- * Copyright (c) 2008 Benno Rice * All rights reserved. + * Copyright (c) 2020 Andrew Turner * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,92 +36,45 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/taskqueue.h> -#include <machine/bus.h> -#include <machine/resource.h> - -#include <net/ethernet.h> #include <net/if.h> -#include <net/if_arp.h> -#include <net/if_media.h> #include <dev/smc/if_smcvar.h> -#include <dev/mii/mii.h> -#include <dev/mii/miivar.h> +#include <contrib/dev/acpica/include/acpi.h> +#include <dev/acpica/acpivar.h> -#include <dev/fdt/fdt_common.h> -#include <dev/ofw/openfirm.h> -#include <dev/ofw/ofw_bus.h> -#include <dev/ofw/ofw_bus_subr.h> +static int smc_acpi_probe(device_t); -#include "miibus_if.h" - -static int smc_fdt_probe(device_t); -static int smc_fdt_attach(device_t); -static int smc_fdt_detach(device_t); - static int -smc_fdt_probe(device_t dev) +smc_acpi_probe(device_t dev) { struct smc_softc *sc; + ACPI_HANDLE h; - if (!ofw_bus_status_okay(dev)) + if ((h = acpi_get_handle(dev)) == NULL) return (ENXIO); - if (ofw_bus_is_compatible(dev, "smsc,lan91c111")) { - sc = device_get_softc(dev); - sc->smc_usemem = 1; + if (!acpi_MatchHid(h, "LNRO0003")) + return (ENXIO); - if (smc_probe(dev) != 0) { - return (ENXIO); - } + sc = device_get_softc(dev); + sc->smc_usemem = 1; - return (0); - } - - return (ENXIO); + return (smc_probe(dev)); } -static int -smc_fdt_attach(device_t dev) -{ - - return smc_attach(dev); -} - -static int -smc_fdt_detach(device_t dev) -{ - - smc_detach(dev); - - return (0); -} - -static device_method_t smc_fdt_methods[] = { +static device_method_t smc_acpi_methods[] = { /* Device interface */ - DEVMETHOD(device_probe, smc_fdt_probe), - DEVMETHOD(device_attach, smc_fdt_attach), - DEVMETHOD(device_detach, smc_fdt_detach), - - /* MII interface */ - DEVMETHOD(miibus_readreg, smc_miibus_readreg), - DEVMETHOD(miibus_writereg, smc_miibus_writereg), - DEVMETHOD(miibus_statchg, smc_miibus_statchg), - + DEVMETHOD(device_probe, smc_acpi_probe), { 0, 0 } }; -static driver_t smc_fdt_driver = { - "smc", - smc_fdt_methods, - sizeof(struct smc_softc), -}; +DEFINE_CLASS_1(smc, smc_acpi_driver, smc_acpi_methods, + sizeof(struct smc_softc), smc_driver); extern devclass_t smc_devclass; -DRIVER_MODULE(smc, simplebus, smc_fdt_driver, smc_devclass, 0, 0); -DRIVER_MODULE(miibus, smc, miibus_driver, miibus_devclass, 0, 0); -MODULE_DEPEND(smc, fdt, 1, 1, 1); +DRIVER_MODULE(smc, acpi, smc_acpi_driver, smc_devclass, 0, 0); +MODULE_DEPEND(smc, acpi, 1, 1, 1); MODULE_DEPEND(smc, ether, 1, 1, 1); MODULE_DEPEND(smc, miibus, 1, 1, 1); Modified: head/sys/dev/smc/if_smc_fdt.c ============================================================================== --- head/sys/dev/smc/if_smc_fdt.c Tue Jul 28 07:07:38 2020 (r363635) +++ head/sys/dev/smc/if_smc_fdt.c Tue Jul 28 09:29:56 2020 (r363636) @@ -35,29 +35,16 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/taskqueue.h> -#include <machine/bus.h> -#include <machine/resource.h> - -#include <net/ethernet.h> #include <net/if.h> -#include <net/if_arp.h> -#include <net/if_media.h> #include <dev/smc/if_smcvar.h> -#include <dev/mii/mii.h> -#include <dev/mii/miivar.h> - #include <dev/fdt/fdt_common.h> #include <dev/ofw/openfirm.h> #include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_bus_subr.h> -#include "miibus_if.h" - static int smc_fdt_probe(device_t); -static int smc_fdt_attach(device_t); -static int smc_fdt_detach(device_t); static int smc_fdt_probe(device_t dev) @@ -81,46 +68,18 @@ smc_fdt_probe(device_t dev) return (ENXIO); } -static int -smc_fdt_attach(device_t dev) -{ - - return smc_attach(dev); -} - -static int -smc_fdt_detach(device_t dev) -{ - - smc_detach(dev); - - return (0); -} - static device_method_t smc_fdt_methods[] = { /* Device interface */ DEVMETHOD(device_probe, smc_fdt_probe), - DEVMETHOD(device_attach, smc_fdt_attach), - DEVMETHOD(device_detach, smc_fdt_detach), - - /* MII interface */ - DEVMETHOD(miibus_readreg, smc_miibus_readreg), - DEVMETHOD(miibus_writereg, smc_miibus_writereg), - DEVMETHOD(miibus_statchg, smc_miibus_statchg), - { 0, 0 } }; -static driver_t smc_fdt_driver = { - "smc", - smc_fdt_methods, - sizeof(struct smc_softc), -}; +DEFINE_CLASS_1(smc, smc_fdt_driver, smc_fdt_methods, + sizeof(struct smc_softc), smc_driver); extern devclass_t smc_devclass; DRIVER_MODULE(smc, simplebus, smc_fdt_driver, smc_devclass, 0, 0); -DRIVER_MODULE(miibus, smc, miibus_driver, miibus_devclass, 0, 0); MODULE_DEPEND(smc, fdt, 1, 1, 1); MODULE_DEPEND(smc, ether, 1, 1, 1); MODULE_DEPEND(smc, miibus, 1, 1, 1); Modified: head/sys/dev/smc/if_smcvar.h ============================================================================== --- head/sys/dev/smc/if_smcvar.h Tue Jul 28 07:07:38 2020 (r363635) +++ head/sys/dev/smc/if_smcvar.h Tue Jul 28 09:29:56 2020 (r363636) @@ -68,6 +68,8 @@ struct smc_softc { void *smc_read_arg; }; +DECLARE_CLASS(smc_driver); + int smc_probe(device_t); int smc_attach(device_t); int smc_detach(device_t);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007280929.06S9Tu2X080424>