xref: /freebsd-src/sys/dev/smc/if_smc_fdt.c (revision fdafd315ad0d0f28a11b9fb4476a9ab059c62b92)
19ff96c23SAndrew Turner /*-
29ff96c23SAndrew Turner  * Copyright (c) 2008 Benno Rice
39ff96c23SAndrew Turner  * All rights reserved.
49ff96c23SAndrew Turner  *
59ff96c23SAndrew Turner  * Redistribution and use in source and binary forms, with or without
69ff96c23SAndrew Turner  * modification, are permitted provided that the following conditions
79ff96c23SAndrew Turner  * are met:
89ff96c23SAndrew Turner  * 1. Redistributions of source code must retain the above copyright
99ff96c23SAndrew Turner  *    notice, this list of conditions and the following disclaimer.
109ff96c23SAndrew Turner  * 2. Redistributions in binary form must reproduce the above copyright
119ff96c23SAndrew Turner  *    notice, this list of conditions and the following disclaimer in the
129ff96c23SAndrew Turner  *    documentation and/or other materials provided with the distribution.
139ff96c23SAndrew Turner  *
149ff96c23SAndrew Turner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
159ff96c23SAndrew Turner  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
169ff96c23SAndrew Turner  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
179ff96c23SAndrew Turner  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
189ff96c23SAndrew Turner  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
199ff96c23SAndrew Turner  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
209ff96c23SAndrew Turner  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
219ff96c23SAndrew Turner  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
229ff96c23SAndrew Turner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
239ff96c23SAndrew Turner  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
249ff96c23SAndrew Turner  *
259ff96c23SAndrew Turner  */
269ff96c23SAndrew Turner 
279ff96c23SAndrew Turner #include <sys/param.h>
289ff96c23SAndrew Turner #include <sys/bus.h>
299ff96c23SAndrew Turner #include <sys/kernel.h>
309ff96c23SAndrew Turner #include <sys/module.h>
319ff96c23SAndrew Turner #include <sys/socket.h>
329ff96c23SAndrew Turner #include <sys/systm.h>
339ff96c23SAndrew Turner #include <sys/taskqueue.h>
349ff96c23SAndrew Turner 
359ff96c23SAndrew Turner #include <net/if.h>
369ff96c23SAndrew Turner 
379ff96c23SAndrew Turner #include <dev/smc/if_smcvar.h>
389ff96c23SAndrew Turner 
399ff96c23SAndrew Turner #include <dev/fdt/fdt_common.h>
409ff96c23SAndrew Turner #include <dev/ofw/openfirm.h>
419ff96c23SAndrew Turner #include <dev/ofw/ofw_bus.h>
429ff96c23SAndrew Turner #include <dev/ofw/ofw_bus_subr.h>
439ff96c23SAndrew Turner 
449ff96c23SAndrew Turner static int		smc_fdt_probe(device_t);
459ff96c23SAndrew Turner 
469ff96c23SAndrew Turner static int
smc_fdt_probe(device_t dev)479ff96c23SAndrew Turner smc_fdt_probe(device_t dev)
489ff96c23SAndrew Turner {
499ff96c23SAndrew Turner 	struct	smc_softc *sc;
509ff96c23SAndrew Turner 
519ff96c23SAndrew Turner 	if (!ofw_bus_status_okay(dev))
529ff96c23SAndrew Turner 		return (ENXIO);
539ff96c23SAndrew Turner 
549ff96c23SAndrew Turner 	if (ofw_bus_is_compatible(dev, "smsc,lan91c111")) {
559ff96c23SAndrew Turner 		sc = device_get_softc(dev);
569ff96c23SAndrew Turner 		sc->smc_usemem = 1;
579ff96c23SAndrew Turner 
589ff96c23SAndrew Turner 		if (smc_probe(dev) != 0) {
599ff96c23SAndrew Turner 			return (ENXIO);
609ff96c23SAndrew Turner 		}
619ff96c23SAndrew Turner 
629ff96c23SAndrew Turner 		return (0);
639ff96c23SAndrew Turner 	}
649ff96c23SAndrew Turner 
659ff96c23SAndrew Turner 	return (ENXIO);
669ff96c23SAndrew Turner }
679ff96c23SAndrew Turner 
689ff96c23SAndrew Turner static device_method_t smc_fdt_methods[] = {
699ff96c23SAndrew Turner 	/* Device interface */
709ff96c23SAndrew Turner 	DEVMETHOD(device_probe,		smc_fdt_probe),
719ff96c23SAndrew Turner 	{ 0, 0 }
729ff96c23SAndrew Turner };
739ff96c23SAndrew Turner 
7422b33ca4SAndrew Turner DEFINE_CLASS_1(smc, smc_fdt_driver, smc_fdt_methods,
7522b33ca4SAndrew Turner     sizeof(struct smc_softc), smc_driver);
769ff96c23SAndrew Turner 
77*e88935abSJohn Baldwin DRIVER_MODULE(smc, simplebus, smc_fdt_driver, 0, 0);
789ff96c23SAndrew Turner MODULE_DEPEND(smc, fdt, 1, 1, 1);
799ff96c23SAndrew Turner MODULE_DEPEND(smc, ether, 1, 1, 1);
809ff96c23SAndrew Turner MODULE_DEPEND(smc, miibus, 1, 1, 1);
81