1 /* $NetBSD: if_sm_emifs.c,v 1.1.20.1 2007/10/03 19:23:12 garbled Exp $ */
4 * OSK5912 SMC91Cxx wrapper, based on sys/arch/evbarm/viper/if_sm_pxaip.c
6 * Copyright (c) 2005 Antti Kantee. All Rights Reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the company nor the name of the author may be used to
17 * endorse or promote products derived from this software without specific
18 * prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: if_sm_emifs.c,v 1.1.20.1 2007/10/03 19:23:12 garbled Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/device.h>
41 #include <net/if_ether.h>
42 #include <net/if_media.h>
44 #include <machine/intr.h>
45 #include <machine/bus.h>
47 #include <dev/mii/mii.h>
48 #include <dev/mii/miivar.h>
50 #include <dev/ic/smc91cxxreg.h>
51 #include <dev/ic/smc91cxxvar.h>
53 #include <arch/arm/omap/omap_emifs.h>
54 #include <arch/arm/omap/omap_gpio.h>
56 static int sm_emifs_match(struct device
*, struct cfdata
*, void *);
57 static void sm_emifs_attach(struct device
*, struct device
*, void *);
59 struct sm_emifs_softc
{
60 struct smc91cxx_softc sc_sm
;
64 CFATTACH_DECL(sm_emifs
, sizeof(struct sm_emifs_softc
), sm_emifs_match
,
65 sm_emifs_attach
, NULL
, NULL
);
68 sm_emifs_match(struct device
*parent
, struct cfdata
*match
, void *aux
)
70 struct emifs_attach_args
*emifs
= aux
;
72 if (emifs
->emifs_addr
== -1)
73 panic("sm must have addr specified in config.");
75 /* Trust the config file. */
80 sm_emifs_attach(struct device
*parent
, struct device
*self
, void *aux
)
82 struct sm_emifs_softc
*emifssc
= (struct sm_emifs_softc
*)self
;
83 struct smc91cxx_softc
*sc
= &emifssc
->sc_sm
;
84 struct emifs_attach_args
*emifs
= aux
;
86 bus_space_handle_t bsh
;
88 bst
= emifs
->emifs_iot
;
91 if (bus_space_map(bst
, emifs
->emifs_addr
, SMC_IOSIZE
, 0, &bsh
) != 0) {
92 aprint_error(": sm_emifs_attach: can't map i/o space");
98 /* fill in master sc */
102 /* register the interrupt handler */
104 omap_gpio_intr_establish(emifs
->emifs_intr
, IST_EDGE_RISING
,
105 IPL_NET
, sc
->sc_dev
.dv_xname
,
108 if (emifssc
->ih
== NULL
) {
109 aprint_error(": couldn't establish interrupt\n");
110 bus_space_unmap(bst
, bsh
, SMC_IOSIZE
);
114 /* Perform generic attach. */
115 sc
->sc_flags
|= SMC_FLAGS_ENABLED
;
116 smc91cxx_attach(sc
, NULL
);