asc_tc.c revision 1.6 1 /* $NetBSD: asc_tc.c,v 1.6 1997/07/21 05:39:05 jonathan Exp $ */
2
3 /*
4 * Copyright 1996 The Board of Trustees of The Leland Stanford
5 * Junior University. All Rights Reserved.
6 *
7 * Permission to use, copy, modify, and distribute this
8 * software and its documentation for any purpose and without
9 * fee is hereby granted, provided that the above copyright
10 * notice appear in all copies. Stanford University
11 * makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without
13 * express or implied warranty.
14 *
15 */
16
17 #include <sys/param.h>
18 #include <sys/systm.h>
19 #include <sys/types.h>
20 #include <sys/device.h>
21 #include <dev/tc/tcvar.h>
22 #include <machine/autoconf.h>
23 #include <dev/tc/ioasicvar.h>
24
25 #include <pmax/dev/device.h> /* XXX */
26 #include <pmax/dev/scsi.h> /* XXX */
27
28 #include <pmax/dev/ascreg.h> /* XXX */
29 #include <dev/tc/ascvar.h>
30
31 /*XXX*/
32
33
34 /*
35 * Autoconfiguration data for config.
36 */
37 int asc_tc_match __P((struct device *, struct cfdata *, void *));
38 void asc_tc_attach __P((struct device *, struct device *, void *));
39
40 struct cfattach asc_tc_ca = {
41 sizeof(struct asc_softc), asc_tc_match, asc_tc_attach
42 };
43
44 /*
45 * DMA callbacks
46 */
47
48 static void
49 tc_dma_start __P((struct asc_softc *asc, struct scsi_state *state,
50 caddr_t cp, int flag));
51
52 static void
53 tc_dma_end __P((struct asc_softc *asc, struct scsi_state *state,
54 int flag));
55
56
57 int
58 asc_tc_match(parent, match, aux)
59 struct device *parent;
60 struct cfdata *match;
61 void *aux;
62 {
63 struct tc_attach_args *t = aux;
64 void *ascaddr;
65
66 if (strncmp(t->ta_modname, "PMAZ-AA ", TC_ROM_LLEN))
67 return (0);
68
69 ascaddr = (void*)t->ta_addr;
70
71 if (tc_badaddr(ascaddr + ASC_OFFSET_53C94))
72 return (0);
73
74 return (1);
75 }
76
77
78
79 void
80 asc_tc_attach(parent, self, aux)
81 struct device *parent;
82 struct device *self;
83 void *aux;
84 {
85 register struct tc_attach_args *t = aux;
86 register asc_softc_t asc = (asc_softc_t) self;
87 int bufsiz, speed;
88
89 void *ascaddr;
90 int unit;
91
92 /* Use uncached address for chip registers. */
93 ascaddr = (void*)MIPS_PHYS_TO_KSEG1(t->ta_addr);
94 unit = asc->sc_dev.dv_unit;
95
96 /*
97 * Initialize hw descriptor, cache some pointers
98 */
99 asc->regs = (asc_regmap_t *)(ascaddr + ASC_OFFSET_53C94);
100
101 /*
102 * Set up machine dependencies.
103 * (1) how to do dma
104 * (2) timing based on turbochannel frequency
105 */
106
107 /*
108 * Fall through for turbochannel option.
109 */
110 asc->dmar = (volatile int *)(ascaddr + ASC_OFFSET_DMAR);
111 asc->buff = (u_char *)(ascaddr + ASC_OFFSET_RAM);
112 bufsiz = PER_TGT_DMA_SIZE;
113 asc->dma_start = tc_dma_start;
114 asc->dma_end = tc_dma_end;
115
116 /*
117 * Now for timing. The 3max has a 25Mhz tb whereas the 3min and
118 * maxine are 12.5Mhz.
119 */
120 printf(" (bus speed: %d) ", t->ta_busspeed);
121
122 switch (t->ta_busspeed) {
123 case TC_SPEED_25_MHZ:
124 speed = ASC_SPEED_25_MHZ;
125 break;
126
127 default:
128 printf(" (unknown TC speed, assuming 12.5MHz) ");
129 /* FALLTHROUGH*/
130 case TC_SPEED_12_5_MHZ:
131 speed = ASC_SPEED_12_5_MHZ;
132 break;
133 };
134
135 ascattach(asc, bufsiz, speed);
136
137 /* tie pseudo-slot to device */
138 tc_intr_establish(parent, t->ta_cookie, TC_IPL_BIO,
139 asc_intr, asc);
140 }
141
142
143 /*
144 * DMA handling routines. For a turbochannel device, just set the dmar.
145 * For the I/O ASIC, handle the actual DMA interface.
146 */
147 static void
148 tc_dma_start(asc, state, cp, flag)
149 asc_softc_t asc;
150 State *state;
151 caddr_t cp;
152 int flag;
153 {
154
155 if (flag == ASCDMA_WRITE)
156 *asc->dmar = ASC_DMAR_WRITE | ASC_DMA_ADDR(cp);
157 else
158 *asc->dmar = ASC_DMA_ADDR(cp);
159 }
160
161 static void
162 tc_dma_end(asc, state, flag)
163 asc_softc_t asc;
164 State *state;
165 int flag;
166 {
167
168 }
169