xref: /freebsd/sys/dev/smc/if_smc_fdt.c (revision f5463265955b829775bbb32e1fd0bc11dafc36ce)
1 /*-
2  * Copyright (c) 2008 Benno Rice
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26 
27 #include <sys/param.h>
28 #include <sys/bus.h>
29 #include <sys/kernel.h>
30 #include <sys/module.h>
31 #include <sys/socket.h>
32 #include <sys/systm.h>
33 #include <sys/taskqueue.h>
34 
35 #include <net/if.h>
36 
37 #include <dev/smc/if_smcvar.h>
38 
39 #include <dev/fdt/fdt_common.h>
40 #include <dev/ofw/openfirm.h>
41 #include <dev/ofw/ofw_bus.h>
42 #include <dev/ofw/ofw_bus_subr.h>
43 
44 static int		smc_fdt_probe(device_t);
45 
46 static int
47 smc_fdt_probe(device_t dev)
48 {
49 	struct	smc_softc *sc;
50 
51 	if (!ofw_bus_status_okay(dev))
52 		return (ENXIO);
53 
54 	if (ofw_bus_is_compatible(dev, "smsc,lan91c111")) {
55 		sc = device_get_softc(dev);
56 		sc->smc_usemem = 1;
57 
58 		if (smc_probe(dev) != 0) {
59 			return (ENXIO);
60 		}
61 
62 		return (0);
63 	}
64 
65 	return (ENXIO);
66 }
67 
68 static device_method_t smc_fdt_methods[] = {
69 	/* Device interface */
70 	DEVMETHOD(device_probe,		smc_fdt_probe),
71 	{ 0, 0 }
72 };
73 
74 DEFINE_CLASS_1(smc, smc_fdt_driver, smc_fdt_methods,
75     sizeof(struct smc_softc), smc_driver);
76 
77 DRIVER_MODULE(smc, simplebus, smc_fdt_driver, 0, 0);
78 MODULE_DEPEND(smc, fdt, 1, 1, 1);
79 MODULE_DEPEND(smc, ether, 1, 1, 1);
80 MODULE_DEPEND(smc, miibus, 1, 1, 1);
81