Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / amiga / dev / if_bah_zbus.c
blob4d6a21f2f303f9fe358d666a2cea1013fbdc53bc
1 /* $NetBSD: if_bah_zbus.c,v 1.10 2002/10/02 04:55:51 thorpej Exp $ */
3 /*-
4 * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis.
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.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: if_bah_zbus.c,v 1.10 2002/10/02 04:55:51 thorpej Exp $");
36 * Driver frontend for the Commodore Busines Machines and the
37 * Ameristar ARCnet card.
40 #include <sys/types.h>
41 #include <sys/param.h>
43 #include <sys/conf.h>
44 #include <sys/device.h>
45 #include <sys/mbuf.h>
46 #include <sys/socket.h>
47 #include <sys/systm.h>
48 #include <sys/kernel.h>
50 #include <machine/bus.h>
51 #include <machine/cpu.h>
52 #include <machine/intr.h>
54 #include <net/if.h>
55 #include <net/route.h>
57 #include <net/if_arc.h>
59 #include <amiga/amiga/device.h>
60 #include <amiga/dev/zbusvar.h>
62 #include <dev/ic/smc90cx6var.h>
65 * A2060 software status per interface
67 struct bah_zbus_softc {
68 struct bah_softc sc_bah;
69 struct bus_space_tag sc_bst;
70 struct isr sc_isr;
73 int bah_zbus_match(struct device *, struct cfdata *, void *);
74 void bah_zbus_attach(struct device *, struct device *, void *);
75 void bah_zbus_reset(struct bah_softc *, int);
77 CFATTACH_DECL(bah_zbus, sizeof(struct bah_zbus_softc),
78 bah_zbus_match, bah_zbus_attach, NULL, NULL);
80 int
81 bah_zbus_match(struct device *parent, struct cfdata *cfp, void *aux)
83 struct zbus_args *zap = aux;
85 if ((zap->manid == 514 || zap->manid == 1053) && zap->prodid == 9)
86 return (1);
88 return (0);
91 void
92 bah_zbus_attach(struct device *parent, struct device *self, void *aux)
94 struct bah_zbus_softc *bsc = (void *)self;
95 struct bah_softc *sc = &bsc->sc_bah;
96 struct zbus_args *zap = aux;
98 #if (defined(BAH_DEBUG) && (BAH_DEBUG > 2))
99 printf("\n%s: attach(0x%x, 0x%x, 0x%x)\n",
100 sc->sc_dev.dv_xname, parent, self, aux);
101 #endif
102 bsc->sc_bst.base = (bus_addr_t)zap->va;
103 bsc->sc_bst.absm = &amiga_bus_stride_2;
105 sc->sc_bst_r = &bsc->sc_bst;
106 sc->sc_regs = bsc->sc_bst.base + 0x4000;
108 sc->sc_bst_m = &bsc->sc_bst;
109 sc->sc_mem = bsc->sc_bst.base + 0x8000;
111 sc->sc_reset = bah_zbus_reset;
113 bah_attach_subr(sc);
115 bsc->sc_isr.isr_intr = bahintr;
116 bsc->sc_isr.isr_arg = sc;
117 bsc->sc_isr.isr_ipl = 2;
118 add_isr(&bsc->sc_isr);
121 void
122 bah_zbus_reset(struct bah_softc *sc, int onoff)
124 struct bah_zbus_softc *bsc;
125 volatile u_int8_t *p;
127 bsc = (struct bah_zbus_softc *)sc;
129 p = (volatile u_int8_t *)bsc->sc_bst.base;
131 p[0x0000] = 0; /* A2060 reset flipflop */
132 p[0xc000] = 0; /* A560 reset flipflop */
134 if (!onoff)
135 return;
137 #ifdef M68060
138 /* make sure we flush the store buffer before the delay */
139 (void)p[0x8000];
140 #endif
141 DELAY(200);
143 p[0x0000] = 0xff;
144 p[0xc000] = 0xff;
146 return;