From owner-svn-src-head@freebsd.org Tue Jul 28 09:29:58 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20E1E3A3896; Tue, 28 Jul 2020 09:29:58 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BGBGY75BGz47YJ; Tue, 28 Jul 2020 09:29:57 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D7019C7EA; Tue, 28 Jul 2020 09:29:57 +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 06S9TvP2080429; Tue, 28 Jul 2020 09:29:57 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06S9Tu2X080424; Tue, 28 Jul 2020 09:29:56 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <202007280929.06S9Tu2X080424@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Tue, 28 Jul 2020 09:29:56 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: in head/sys: conf dev/smc X-SVN-Commit-Revision: 363636 X-SVN-Commit-Repository: base 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.33 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, 28 Jul 2020 09:29:58 -0000 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 #include +#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 #include -#include -#include - -#include #include -#include -#include #include -#include -#include +#include +#include -#include -#include -#include -#include +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 #include -#include -#include - -#include #include -#include -#include #include -#include -#include - #include #include #include #include -#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);