1 /* $NetBSD: if_sm_pxaip.c,v 1.2.38.1 2007/10/03 19:23:13 garbled Exp $ */
4 * Copyright (c) 2005 Antti Kantee. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the company nor the name of the author may be used to
15 * endorse or promote products derived from this software without specific
16 * prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: if_sm_pxaip.c,v 1.2.38.1 2007/10/03 19:23:13 garbled Exp $");
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
39 #include <net/if_ether.h>
40 #include <net/if_media.h>
42 #include <machine/intr.h>
43 #include <machine/bus.h>
45 #include <dev/mii/mii.h>
46 #include <dev/mii/miivar.h>
48 #include <dev/ic/smc91cxxreg.h>
49 #include <dev/ic/smc91cxxvar.h>
51 #include <arch/arm/xscale/pxa2x0var.h>
52 #include <arch/arm/xscale/pxa2x0_gpio.h>
54 #include <arch/evbarm/viper/viper_reg.h>
56 static int sm_pxaip_match(struct device
*, struct cfdata
*, void *);
57 static void sm_pxaip_attach(struct device
*, struct device
*, void *);
59 struct sm_pxaip_softc
{
60 struct smc91cxx_softc sc_sm
;
64 CFATTACH_DECL(sm_pxaip
, sizeof(struct sm_pxaip_softc
), sm_pxaip_match
,
65 sm_pxaip_attach
, NULL
, NULL
);
68 sm_pxaip_match(struct device
*parent
, struct cfdata
*match
, void *aux
)
70 struct pxaip_attach_args
*paa
= aux
;
72 if (paa
->pxa_addr
== VIPER_SMSC_PBASE
)
78 sm_pxaip_attach(struct device
*parent
, struct device
*self
, void *aux
)
80 struct sm_pxaip_softc
*pxasc
= (struct sm_pxaip_softc
*)self
;
81 struct smc91cxx_softc
*sc
= &pxasc
->sc_sm
;
82 struct pxaip_attach_args
*paa
= aux
;
83 bus_space_tag_t bst
= &pxa2x0_bs_tag
;
84 bus_space_handle_t bsh
;
87 if (bus_space_map(bst
, paa
->pxa_addr
, SMC_IOSIZE
, 0, &bsh
) != 0) {
88 aprint_error(": sm_pxaip_attach: can't map i/o space");
92 /* register the interrupt handler */
93 pxasc
->ih
= pxa2x0_gpio_intr_establish(paa
->pxa_intr
, IST_EDGE_RISING
,
94 IPL_NET
, smc91cxx_intr
, sc
);
95 if (pxasc
->ih
== NULL
) {
96 aprint_error(": couldn't establish interrupt\n");
97 bus_space_unmap(bst
, bsh
, SMC_IOSIZE
);
103 /* fill in master sc */
107 sc
->sc_flags
= SMC_FLAGS_ENABLED
;
108 smc91cxx_attach(sc
, NULL
);