No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / cesfic / dev / if_le.c
blob7283afaec86af12f0aa2b63da927bb43be0d720b
1 /* $NetBSD: if_le.c,v 1.6 2005/12/11 12:17:05 christos Exp $ */
3 /*
4 * Copyright (c) 1997, 1999
5 * Matthias Drochner. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.6 2005/12/11 12:17:05 christos Exp $");
32 #include "opt_inet.h"
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/socket.h>
37 #include <sys/device.h>
39 #include <net/if.h>
40 #include <net/if_ether.h>
41 #include <net/if_media.h>
43 #ifdef INET
44 #include <netinet/in.h>
45 #include <netinet/if_inarp.h>
46 #endif
48 #include <machine/cpu.h>
49 #include <machine/pte.h>
51 #include <machine/autoconf.h>
53 #include <dev/ic/lancereg.h>
54 #include <dev/ic/lancevar.h>
55 #include <dev/ic/am79900reg.h>
56 #include <dev/ic/am79900var.h>
58 #include <cesfic/cesfic/isr.h>
60 int lematch(device_t, cfdata_t, void *);
61 void leattach(device_t, device_t, void *);
63 CFATTACH_DECL_NEW(le, sizeof(struct am79900_softc),
64 lematch, leattach, NULL, NULL);
66 int leintr(void *);
68 void lewrcsr(struct lance_softc *, uint16_t, uint16_t);
69 uint16_t lerdcsr(struct lance_softc *, uint16_t);
71 static char *lebase, *lemembase;
73 void
74 lewrcsr(struct lance_softc *sc, uint16_t port, uint16_t val)
77 *(volatile int *)(lebase + 4) = port;
78 *(volatile int *)(lebase + 0) = val;
81 uint16_t
82 lerdcsr(struct lance_softc *sc, uint16_t port)
84 uint16_t val;
86 *(volatile int *)(lebase + 4) = port;
87 val = *(volatile int *)(lebase + 0);
88 return (val);
91 int
92 lematch(device_t parent, cfdata_t cf, void *aux)
95 return (1);
99 * Interface exists: make available by filling in network interface
100 * record. System will initialize the interface when it is ready
101 * to accept packets.
103 extern void sic_enable_int(int, int, int, int, int);
104 static char hwa[6] = {0x00,0x80,0xa2,0x00,0x30,0x23};
105 void
106 leattach(device_t parent, device_t self, void *aux)
108 struct lance_softc *sc = device_private(self);
109 int i;
111 mainbus_map(0x4c000000, 0x10000, 0, (void *)&lemembase);
112 mainbus_map(0x48000000, 0x1000, 0, (void *)&lebase);
114 sc->sc_dev = self;
115 sc->sc_mem = lemembase;
116 sc->sc_conf3 = LE_C3_BSWP;
117 sc->sc_addr = 0x4c000000;
118 sc->sc_memsize = 64 * 1024;
120 if (cesfic_getetheraddr(sc->sc_enaddr)) {
121 /* fallback */
122 for (i = 0; i < sizeof(sc->sc_enaddr); i++) {
123 sc->sc_enaddr[i] = hwa[i];
127 sc->sc_copytodesc = lance_copytobuf_contig;
128 sc->sc_copyfromdesc = lance_copyfrombuf_contig;
129 sc->sc_copytobuf = lance_copytobuf_contig;
130 sc->sc_copyfrombuf = lance_copyfrombuf_contig;
131 sc->sc_zerobuf = lance_zerobuf_contig;
133 sc->sc_rdcsr = lerdcsr;
134 sc->sc_wrcsr = lewrcsr;
135 sc->sc_hwinit = NULL;
137 lewrcsr(sc, 4, 0x44);
138 am79900_config((struct am79900_softc *)sc);
140 /* Establish the interrupt handler. */
141 (void) isrlink(leintr, sc, 3, ISRPRI_NET);
142 sic_enable_int(17, 0, 1, 3, 0);
146 leintr(void *arg)
148 struct lance_softc *sc = arg;
149 uint16_t isr4;
151 isr4 = lerdcsr(sc, 4);
152 if (isr4 & 0x08) {
153 lewrcsr(sc, 4, isr4);
154 return (1);
157 return (am79900_intr(sc));