1 /* $NetBSD: if_ie_obio.c,v 1.24 2008/04/28 20:23:37 martin Exp $ */
4 * Copyright (c) 1996 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Machine-dependent glue for the Intel Ethernet (ie) driver.
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.24 2008/04/28 20:23:37 martin Exp $");
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/device.h>
44 #include <sys/protosw.h>
45 #include <sys/socket.h>
47 #include <net/if_ether.h>
50 #include <netinet/in.h>
51 #include <netinet/in_systm.h>
52 #include <netinet/in_var.h>
53 #include <netinet/ip.h>
54 #include <netinet/if_inarp.h>
57 #include <machine/autoconf.h>
58 #include <machine/cpu.h>
59 #include <machine/dvma.h>
60 #include <machine/idprom.h>
61 #include <machine/vmparam.h>
67 static void ie_obreset(struct ie_softc
*);
68 static void ie_obattend(struct ie_softc
*);
69 static void ie_obrun(struct ie_softc
*);
72 * New-style autoconfig attachment
75 static int ie_obio_match(device_t
, cfdata_t
, void *);
76 static void ie_obio_attach(device_t
, device_t
, void *);
78 CFATTACH_DECL_NEW(ie_obio
, sizeof(struct ie_softc
),
79 ie_obio_match
, ie_obio_attach
, NULL
, NULL
);
82 ie_obio_match(device_t parent
, cfdata_t cf
, void *args
)
84 struct confargs
*ca
= args
;
86 /* Make sure there is something there... */
87 if (bus_peek(ca
->ca_bustype
, ca
->ca_paddr
, 1) == -1)
90 /* Default interrupt priority. */
91 if (ca
->ca_intpri
== -1)
98 ie_obio_attach(device_t parent
, device_t self
, void *args
)
100 struct ie_softc
*sc
= device_private(self
);
101 struct confargs
*ca
= args
;
104 sc
->hard_type
= IE_OBIO
;
105 sc
->reset_586
= ie_obreset
;
106 sc
->chan_attn
= ie_obattend
;
107 sc
->run_586
= ie_obrun
;
108 sc
->sc_memcpy
= memcpy
;
109 sc
->sc_memset
= memset
;
111 /* Map in the control registers. */
112 sc
->sc_reg
= bus_mapin(ca
->ca_bustype
,
113 ca
->ca_paddr
, sizeof(struct ieob
));
116 * The on-board "ie" is wired-up such that its
117 * memory access goes to the high 16 megabytes
118 * of the on-board memory space (on-board DVMA).
120 sc
->sc_iobase
= (void *)DVMA_OBIO_SLAVE_BASE
;
123 * The on-board "ie" just uses main memory, so
124 * we can choose how much memory to give it.
125 * XXX: Would like to use less than 64K...
127 sc
->sc_msize
= 0x8000; /* MEMSIZE 32K */
129 /* Allocate "shared" memory (in DVMA space). */
130 sc
->sc_maddr
= dvma_malloc(sc
->sc_msize
);
131 if (sc
->sc_maddr
== NULL
)
132 panic(": not enough dvma space");
135 * Set the System Configuration Pointer (SCP).
136 * Its location is system-dependent because the
137 * i82586 reads it from a fixed physical address.
138 * On this hardware, the i82586 address maps to
139 * a 24-bit offset in on-board DVMA space. The
140 * SCP happens to fall in a page used by the
141 * PROM monitor, which the PROM knows about.
143 sc
->scp
= (volatile void *)((char *)sc
->sc_iobase
+ IE_SCP_ADDR
);
146 * The rest of ram is used for buffers.
148 sc
->buf_area
= sc
->sc_maddr
;
149 sc
->buf_area_sz
= sc
->sc_msize
;
151 /* Install interrupt handler. */
152 isr_add_autovect(ie_intr
, sc
, ca
->ca_intpri
);
154 /* Set the ethernet address. */
155 idprom_etheraddr(sc
->sc_addr
);
157 /* Do machine-independent parts of attach. */
166 /* Whack the "channel attetion" line. */
168 ie_obattend(struct ie_softc
*sc
)
170 volatile struct ieob
*ieo
= (struct ieob
*)sc
->sc_reg
;
172 ieo
->obctrl
|= IEOB_ATTEN
; /* flag! */
173 ieo
->obctrl
&= ~IEOB_ATTEN
; /* down. */
177 * This is called during driver attach.
178 * Reset and initialize.
181 ie_obreset(struct ie_softc
*sc
)
183 volatile struct ieob
*ieo
= (struct ieob
*)sc
->sc_reg
;
186 ieo
->obctrl
= (IEOB_NORSET
| IEOB_ONAIR
| IEOB_IENAB
);
190 * This is called at the end of ieinit().
194 ie_obrun(struct ie_softc
*sc
)
197 /* do it all in reset */