xref: /netbsd-src/sys/dev/tc/asc_tc.c (revision 76dfffe33547c37f8bdd446e3e4ab0f3c16cea4b)
1 /*	$NetBSD: asc_tc.c,v 1.4 1996/10/13 01:38:37 christos 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 *, void *, 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 	void *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 	ascaddr = (void*)MACH_PHYS_TO_UNCACHED(t->ta_addr);
93 	unit = asc->sc_dev.dv_unit;
94 
95 	/*
96 	 * Initialize hw descriptor, cache some pointers
97 	 */
98 	asc->regs = (asc_regmap_t *)(ascaddr + ASC_OFFSET_53C94);
99 
100 	/*
101 	 * Set up machine dependencies.
102 	 * (1) how to do dma
103 	 * (2) timing based on turbochannel frequency
104 	 */
105 
106 	/*
107 	 * Fall through for turbochannel option.
108 	 */
109 	asc->dmar = (volatile int *)(ascaddr + ASC_OFFSET_DMAR);
110 	asc->buff = (u_char *)(ascaddr + ASC_OFFSET_RAM);
111 	bufsiz = PER_TGT_DMA_SIZE;
112 	asc->dma_start = tc_dma_start;
113 	asc->dma_end = tc_dma_end;
114 
115 	/*
116 	 * Now for timing. The 3max has a 25Mhz tb whereas the 3min and
117 	 * maxine are 12.5Mhz.
118 	 */
119 	printf(" (bus speed: %d) ", t->ta_busspeed);
120 
121 	switch (t->ta_busspeed) {
122 	case TC_SPEED_25_MHZ:
123 		speed = ASC_SPEED_25_MHZ;
124 		break;
125 
126 	default:
127 		printf(" (unknown TC speed, assuming 12.5MHz) ");
128 		/* FALLTHROUGH*/
129 	case TC_SPEED_12_5_MHZ:
130 		speed = ASC_SPEED_12_5_MHZ;
131 		break;
132 	};
133 
134 	ascattach(asc, bufsiz, speed);
135 
136 	/* tie pseudo-slot to device */
137 	tc_intr_establish(parent, t->ta_cookie, TC_IPL_BIO,
138 			  asc_intr, asc);
139 }
140 
141 
142 /*
143  * DMA handling routines. For a turbochannel device, just set the dmar.
144  * For the I/O ASIC, handle the actual DMA interface.
145  */
146 static void
147 tc_dma_start(asc, state, cp, flag)
148 	asc_softc_t asc;
149 	State *state;
150 	caddr_t cp;
151 	int flag;
152 {
153 
154 	if (flag == ASCDMA_WRITE)
155 		*asc->dmar = ASC_DMAR_WRITE | ASC_DMA_ADDR(cp);
156 	else
157 		*asc->dmar = ASC_DMA_ADDR(cp);
158 }
159 
160 static void
161 tc_dma_end(asc, state, flag)
162 	asc_softc_t asc;
163 	State *state;
164 	int flag;
165 {
166 
167 }
168