No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / arc / jazz / if_sn_jazzio.c
blobc7b7254ec5311b355902eaa04ceb2a95e641e1a3
1 /* $NetBSD: if_sn_jazzio.c,v 1.10 2008/04/23 13:29:45 tsutsui Exp $ */
3 /*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
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 * Microsoft JAZZ front-end for for the National Semiconductor DP83932
34 * Systems-Oriented Network Interface Controller (SONIC).
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: if_sn_jazzio.c,v 1.10 2008/04/23 13:29:45 tsutsui Exp $");
40 #include "bpfilter.h"
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/mbuf.h>
45 #include <sys/malloc.h>
46 #include <sys/kernel.h>
47 #include <sys/socket.h>
48 #include <sys/ioctl.h>
49 #include <sys/errno.h>
50 #include <sys/device.h>
51 #include <sys/kcore.h>
53 #include <net/if.h>
54 #include <net/if_dl.h>
55 #include <net/if_ether.h>
57 #include <machine/autoconf.h>
58 #include <machine/bus.h>
59 #include <machine/intr.h>
61 #include <dev/ic/dp83932reg.h>
62 #include <dev/ic/dp83932var.h>
64 #include <arc/arc/arcbios.h>
65 #include <arc/jazz/jazziovar.h>
67 int sonic_jazzio_match(device_t, cfdata_t, void *);
68 void sonic_jazzio_attach(device_t, device_t, void *);
70 CFATTACH_DECL_NEW(sn_jazzio, sizeof(struct sonic_softc),
71 sonic_jazzio_match, sonic_jazzio_attach, NULL, NULL);
73 int
74 sonic_jazzio_match(device_t parent, cfdata_t cf, void *aux)
76 struct jazzio_attach_args *ja = aux;
78 if (strcmp(ja->ja_name, "SONIC") != 0)
79 return 0;
81 return 1;
84 void
85 sonic_jazzio_attach(device_t parent, device_t self, void *aux)
87 struct sonic_softc *sc = device_private(self);
88 struct jazzio_attach_args *ja = aux;
89 int i;
90 uint8_t enaddr[ETHER_ADDR_LEN];
92 sc->sc_dev = self;
93 sc->sc_st = ja->ja_bust;
94 sc->sc_dmat = ja->ja_dmat;
96 aprint_normal(": SONIC Ethernet\n");
98 /* Map the device. */
99 if (bus_space_map(sc->sc_st, ja->ja_addr, SONIC_NREGS * 4,
100 0, &sc->sc_sh) != 0) {
101 aprint_error_dev(sc->sc_dev, "unable to map SONIC registers\n");
102 return;
105 /* We run in 32-bit mode. */
106 sc->sc_32bit = 1;
108 /* BMODE is set for little-endian. */
109 sc->sc_bigendian = 0;
111 /* Regs are 16-bit, plus 16-bit pad. */
112 for (i = 0; i < SONIC_NREGS; i++)
113 sc->sc_regmap[i] = i * 4;
116 * Configure DCR:
118 * - Latched bug retry
119 * - Synchronous bus (memory cycle 2 clocks)
120 * - 0 wait states added (WC0,WC1 == 0,0)
121 * - 4 byte Rx DMA threshold (RFT0,RFT1 == 0,0)
122 * - 28 byte Tx DMA threshold (TFT0,TFT1 == 1,1)
123 * XXX There was a comment
124 * "XXX RFT & TFT according to MIPS manual"
125 * in old MD sys/arch/arc/dev/if_sn.c in Attic.
127 sc->sc_dcr = DCR_LBR | DCR_SBUS | DCR_TFT0 | DCR_TFT1;
128 sc->sc_dcr2 = 0;
130 /* Hook up our interrupt handler. */
131 jazzio_intr_establish(ja->ja_intr, sonic_intr, sc);
133 /* The Ethernet address is from the product ID. */
134 memcpy(enaddr, arc_product_id, sizeof(enaddr));
136 /* Finish off the attach. */
137 sonic_attach(sc, enaddr);