if_bah_zbus.c revision 1.2 1 /* $NetBSD: if_bah_zbus.c,v 1.2 1998/09/04 21:19:07 is Exp $ */
2
3 /*
4 * Copyright (c) 1994, 1995, 1998 Ignatios Souvatzis
5 * All rights reserved.
6 *
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.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Ignatios Souvatzis
18 * for the NetBSD Project.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 /*
35 * Driver frontend for the Commodore Busines Machines and the
36 * Ameristar ARCnet card.
37 */
38
39 #include <sys/types.h>
40 #include <sys/param.h>
41
42 #include <sys/conf.h>
43 #include <sys/device.h>
44 #include <sys/mbuf.h>
45 #include <sys/socket.h>
46 #include <sys/systm.h>
47 #include <sys/kernel.h>
48
49 #include <machine/bus.h>
50 #include <machine/cpu.h>
51 #include <machine/intr.h>
52
53 #include <net/if.h>
54 #include <net/route.h>
55
56 #include <net/if_arc.h>
57
58 #include <amiga/amiga/device.h>
59 #include <amiga/dev/zbusvar.h>
60
61 #include <dev/ic/smc90cx6var.h>
62
63 /*
64 * A2060 software status per interface
65 */
66 struct bah_zbus_softc {
67 struct bah_softc sc_bah;
68 struct bus_space_tag sc_bst;
69 struct isr sc_isr;
70 };
71
72 int bah_zbus_match __P((struct device *, struct cfdata *, void *));
73 void bah_zbus_attach __P((struct device *, struct device *, void *));
74 void bah_zbus_reset __P((struct bah_softc *, int));
75
76 struct cfattach bah_zbus_ca = {
77 sizeof(struct bah_zbus_softc), bah_zbus_match, bah_zbus_attach
78 };
79
80 int
81 bah_zbus_match(parent, cfp, aux)
82 struct device *parent;
83 struct cfdata *cfp;
84 void *aux;
85 {
86 struct zbus_args *zap = aux;
87
88 if ((zap->manid == 514 || zap->manid == 1053) && zap->prodid == 9)
89 return (1);
90
91 return (0);
92 }
93
94 void
95 bah_zbus_attach(parent, self, aux)
96 struct device *parent, *self;
97 void *aux;
98 {
99 struct bah_zbus_softc *bsc = (void *)self;
100 struct bah_softc *sc = &bsc->sc_bah;
101 struct zbus_args *zap = aux;
102
103 #if (defined(BAH_DEBUG) && (BAH_DEBUG > 2))
104 printf("\n%s: attach(0x%x, 0x%x, 0x%x)\n",
105 sc->sc_dev.dv_xname, parent, self, aux);
106 #endif
107 bsc->sc_bst.base = (bus_addr_t)zap->va;
108 bsc->sc_bst.stride = 1;
109
110 sc->sc_bst_r = &bsc->sc_bst;
111 sc->sc_regs = bsc->sc_bst.base + 0x4000;
112
113 sc->sc_bst_m = &bsc->sc_bst;
114 sc->sc_mem = bsc->sc_bst.base + 0x8000;
115
116 sc->sc_reset = bah_zbus_reset;
117
118 bah_attach_subr(sc);
119
120 bsc->sc_isr.isr_intr = bahintr;
121 bsc->sc_isr.isr_arg = sc;
122 bsc->sc_isr.isr_ipl = 2;
123 add_isr(&bsc->sc_isr);
124 }
125
126 void
127 bah_zbus_reset(sc, onoff)
128 struct bah_softc *sc;
129 int onoff;
130 {
131 struct bah_zbus_softc *bsc;
132 volatile u_int8_t *p;
133
134 bsc = (struct bah_zbus_softc *)sc;
135
136 p = (volatile u_int8_t *)bsc->sc_bst.base;
137
138 p[0x0000] = 0; /* A2060 reset flipflop */
139 p[0xc000] = 0; /* A560 reset flipflop */
140
141 if (!onoff)
142 return;
143
144 #ifdef M68060
145 /* make sure we flush the store buffer before the delay */
146 (void)p[0x8000];
147 #endif
148 DELAY(200);
149
150 p[0x0000] = 0xff;
151 p[0xc000] = 0xff;
152
153 return;
154 }
155