gtmpsc.c revision 1.6 1 /* $NetBSD: gtmpsc.c,v 1.6 2003/04/08 22:33:33 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
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 for the NetBSD Project by
18 * Allegro Networks, Inc., and Wasabi Systems, Inc.
19 * 4. The name of Allegro Networks, Inc. may not be used to endorse
20 * or promote products derived from this software without specific prior
21 * written permission.
22 * 5. The name of Wasabi Systems, Inc. may not be used to endorse
23 * or promote products derived from this software without specific prior
24 * written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY ALLEGRO NETWORKS, INC. AND
27 * WASABI SYSTEMS, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
28 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
29 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 * IN NO EVENT SHALL EITHER ALLEGRO NETWORKS, INC. OR WASABI SYSTEMS, INC.
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 /*
41 * mpsc.c - MPSC serial driver, supports UART mode only
42 *
43 *
44 * creation Mon Apr 9 19:40:15 PDT 2001 cliff
45 */
46
47 #include "opt_kgdb.h"
48
49 #include <sys/param.h>
50 #include <sys/conf.h>
51 #include <sys/device.h>
52 #include <sys/proc.h>
53 #include <sys/systm.h>
54 #include <sys/tty.h>
55 #include <sys/callout.h>
56 #include <sys/fcntl.h>
57 #ifdef KGDB
58 #include <sys/kernel.h>
59 #include <sys/kgdb.h>
60 #endif
61
62 #include <uvm/uvm_extern.h>
63
64 #include <powerpc/atomic.h>
65 #include <dev/cons.h>
66 #include <machine/bus.h>
67 #include <machine/cpu.h> /* for DELAY */
68 #include <machine/stdarg.h>
69 #include "gtmpsc.h"
70
71
72 #include <dev/marvell/gtreg.h>
73 #include <dev/marvell/gtvar.h>
74 #include <dev/marvell/gtintrreg.h>
75 #include <dev/marvell/gtmpscreg.h>
76 #include <dev/marvell/gtsdmareg.h>
77 #include <dev/marvell/gtmpscvar.h>
78 #include <dev/marvell/gtbrgreg.h>
79
80 /*
81 * XXX these delays were derived empiracaly
82 */
83 #define GTMPSC_POLL_DELAY 1 /* 1 usec */
84 /*
85 * Wait 2 characters time for RESET_DELAY
86 */
87 #define GTMPSC_RESET_DELAY (2*8*1000000 / GT_MPSC_DEFAULT_BAUD_RATE)
88
89 #define BURSTLEN 128
90
91 /*
92 * stat values for gtmpsc_common_pollc
93 */
94 #define GTMPSC_STAT_NONE 0
95 #define GTMPSC_STAT_BREAK 1
96
97
98 #define PRINTF(x) gtmpsc_mem_printf x
99
100 #if defined(DEBUG)
101 unsigned int gtmpsc_debug = 0;
102 # define STATIC
103 # define DPRINTF(x) do { if (gtmpsc_debug) gtmpsc_mem_printf x ; } while (0)
104 #else
105 # define STATIC static
106 # define DPRINTF(x)
107 #endif
108
109 #define GTMPSCUNIT_MASK 0x7ffff
110 #define GTMPSCDIALOUT_MASK 0x80000
111
112 #define GTMPSCUNIT(x) (minor(x) & GTMPSCUNIT_MASK)
113 #define GTMPSCDIALOUT(x) (minor(x) & GTMPSCDIALOUT_MASK)
114
115 STATIC void gtmpscinit(struct gtmpsc_softc *);
116 STATIC int gtmpscmatch(struct device *, struct cfdata *, void *);
117 STATIC void gtmpscattach(struct device *, struct device *, void *);
118 STATIC int compute_cdv(unsigned int);
119 STATIC void gtmpsc_loadchannelregs(struct gtmpsc_softc *);
120 STATIC void gtmpscshutdown(struct gtmpsc_softc *);
121 STATIC void gtmpscstart(struct tty *);
122 STATIC int gtmpscparam(struct tty *, struct termios *);
123 STATIC int gtmpsc_probe(void);
124 STATIC int gtmpsc_intr(void *);
125 STATIC void gtmpsc_softintr(void *);
126
127 STATIC void gtmpsc_common_putn(struct gtmpsc_softc *);
128 STATIC void gtmpsc_common_putc(unsigned int, unsigned char);
129 STATIC int gtmpsc_common_getc(unsigned int);
130 STATIC int gtmpsc_common_pollc(unsigned int, char *, int *);
131 STATIC void gtmpsc_poll(void *);
132 #ifdef KGDB
133 STATIC void gtmpsc_kgdb_poll(void *);
134 #endif
135 STATIC void gtmpsc_mem_printf(const char *, ...);
136
137 STATIC void gtmpsc_txdesc_init(gtmpsc_poll_sdma_t *, gtmpsc_poll_sdma_t *);
138 STATIC void gtmpsc_rxdesc_init(gtmpsc_poll_sdma_t *, gtmpsc_poll_sdma_t *);
139 STATIC unsigned int gtmpsc_get_causes(void);
140 STATIC void gtmpsc_hackinit(struct gtmpsc_softc *, bus_space_tag_t,
141 bus_space_handle_t, int);
142 STATIC void gtmpscinit_stop(struct gtmpsc_softc *, int);
143 STATIC void gtmpscinit_start(struct gtmpsc_softc *, int);
144 #if 0
145 void gtmpsc_printf(const char *fmt, ...);
146 #endif
147 void gtmpsc_puts(char *);
148
149 void gtmpsccnprobe(struct consdev *);
150 void gtmpsccninit(struct consdev *);
151 int gtmpsccngetc(dev_t);
152 void gtmpsccnputc(dev_t, int);
153 void gtmpsccnpollc(dev_t, int);
154 void gtmpsccnhalt(dev_t);
155
156 STATIC void gtmpsc_txflush(gtmpsc_softc_t *);
157 STATIC void gtmpsc_iflush(gtmpsc_softc_t *);
158 STATIC void gtmpsc_shutdownhook(void *);
159
160 dev_type_open(gtmpscopen);
161 dev_type_close(gtmpscclose);
162 dev_type_read(gtmpscread);
163 dev_type_write(gtmpscwrite);
164 dev_type_ioctl(gtmpscioctl);
165 dev_type_stop(gtmpscstop);
166 dev_type_tty(gtmpsctty);
167 dev_type_poll(gtmpscpoll);
168
169 const struct cdevsw gtmpsc_cdevsw = {
170 gtmpscopen, gtmpscclose, gtmpscread, gtmpscwrite, gtmpscioctl,
171 gtmpscstop, gtmpsctty, gtmpscpoll, nommap, ttykqfilter, D_TTY
172 };
173
174 CFATTACH_DECL(gtmpsc, sizeof(struct gtmpsc_softc),
175 gtmpscmatch, gtmpscattach, NULL, NULL);
176
177 extern struct cfdriver gtmpsc_cd;
178
179 static struct consdev gtmpsc_consdev = {
180 0,
181 gtmpsccninit,
182 gtmpsccngetc,
183 gtmpsccnputc,
184 gtmpsccnpollc,
185 NULL, /* cn_bell */
186 gtmpsccnhalt,
187 NULL, /* cn_flush */
188 NODEV,
189 CN_NORMAL
190 };
191
192 STATIC void *gtmpsc_sdma_ih = NULL;
193
194 gtmpsc_softc_t *gtmpsc_scp[GTMPSC_NCHAN] = { 0 };
195
196 STATIC int gt_reva_gtmpsc_bug;
197 unsigned int sdma_imask; /* soft copy of SDMA IMASK reg */
198
199 #ifdef KGDB
200 #include <sys/kgdb.h>
201
202 static int gtmpsc_kgdb_addr;
203 static int gtmpsc_kgdb_attached;
204
205 int kgdb_break_immediate /* = 0 */ ;
206
207 STATIC int gtmpsc_kgdb_getc(void *);
208 STATIC void gtmpsc_kgdb_putc(void *, int);
209 #endif /* KGDB */
210
211 /*
212 * hacks for console initialization
213 * which happens prior to autoconfig "attach"
214 *
215 * XXX Assumes PAGE_SIZE is a constant!
216 */
217 STATIC unsigned int gtmpsccninit_done = 0;
218 STATIC gtmpsc_softc_t gtmpsc_fake_softc;
219 STATIC unsigned char gtmpsc_earlybuf[PAGE_SIZE]
220 __attribute__ ((aligned(PAGE_SIZE)));
221 STATIC unsigned char gtmpsc_fake_dmapage[PAGE_SIZE]
222 __attribute__ ((aligned(PAGE_SIZE)));
223
224
225 #define GTMPSC_PRINT_BUF_SIZE 4096
226 STATIC unsigned char gtmpsc_print_buf[GTMPSC_PRINT_BUF_SIZE] = { 0 };
227
228 unsigned int gtmpsc_poll_putc_cnt = 0;
229 unsigned int gtmpsc_poll_putn_cnt = 0;
230 unsigned int gtmpsc_poll_getc_cnt = 0;
231 unsigned int gtmpsc_poll_pollc_cnt = 0;
232 unsigned int gtmpsc_poll_putc_miss = 0;
233 unsigned int gtmpsc_poll_putn_miss = 0;
234 unsigned int gtmpsc_poll_getc_miss = 0;
235 unsigned int gtmpsc_poll_pollc_miss = 0;
236
237 #ifndef SDMA_COHERENT
238 /*
239 * inlines to flush, invalidate cache
240 * required if DMA cache coherency is broken
241 * note that pointer `p' args are assumed to be cache aligned
242 * and the size is assumed to be one CACHELINESIZE block
243 */
244
245 #define GTMPSC_CACHE_FLUSH(p) gtmpsc_cache_flush(p)
246 #define GTMPSC_CACHE_INVALIDATE(p) gtmpsc_cache_invalidate(p)
247
248 static volatile inline void
249 gtmpsc_cache_flush(void *p)
250 {
251 __asm __volatile ("eieio; dcbf 0,%0; lwz %0,0(%0); sync;"
252 : "+r"(p):);
253 }
254
255 static volatile inline void
256 gtmpsc_cache_invalidate(void *p)
257 {
258 __asm __volatile ("eieio; dcbi 0,%0; sync;" :: "r"(p));
259 }
260 #else
261
262 #define GTMPSC_CACHE_FLUSH(p)
263 #define GTMPSC_CACHE_INVALIDATE(p)
264
265 #endif /* SDMA_COHERENT */
266
267 #define GT_READ(sc,o) \
268 bus_space_read_4((sc)->gtmpsc_memt, (sc)->gtmpsc_memh, (o))
269 #define GT_WRITE(sc,o,v) \
270 bus_space_write_4((sc)->gtmpsc_memt, (sc)->gtmpsc_memh, (o), (v))
271
272
273 #define SDMA_IMASK_ENABLE(sc, bit) do { \
274 unsigned int r; \
275 GT_WRITE(sc, SDMA_ICAUSE, ~(bit)); \
276 if (gt_reva_gtmpsc_bug) \
277 r = sdma_imask; \
278 else \
279 r = GT_READ(sc, SDMA_IMASK); \
280 r |= (bit); \
281 sdma_imask = r; \
282 GT_WRITE(sc, SDMA_IMASK, r); \
283 } while (/*CONSTCOND*/ 0)
284
285 #define SDMA_IMASK_DISABLE(sc, bit) do { \
286 unsigned int r; \
287 if (gt_reva_gtmpsc_bug) \
288 r = sdma_imask; \
289 else \
290 r = GT_READ(sc, SDMA_IMASK); \
291 r &= ~(bit); \
292 sdma_imask = r; \
293 GT_WRITE(sc, SDMA_IMASK, r); \
294 } while (/*CONSTCOND*/ 0)
295
296 static volatile inline unsigned int
297 desc_read(unsigned int *ip)
298 {
299 unsigned int rv;
300
301 __asm __volatile ("lwzx %0,0,%1; eieio;"
302 : "=r"(rv) : "r"(ip));
303 return rv;
304 }
305
306 static volatile inline void
307 desc_write(unsigned int *ip, unsigned int val)
308 {
309 __asm __volatile ("stwx %0,0,%1; eieio;"
310 :: "r"(val), "r"(ip));
311 }
312
313
314 /*
315 * gtmpsc_txdesc_init - set up TX descriptor ring
316 */
317 STATIC void
318 gtmpsc_txdesc_init(gtmpsc_poll_sdma_t *vmps, gtmpsc_poll_sdma_t *pmps)
319 {
320 int n;
321 sdma_desc_t *dp;
322 gtmpsc_polltx_t *vtxp;
323 gtmpsc_polltx_t *ptxp;
324 gtmpsc_polltx_t *next_ptxp;
325 gtmpsc_polltx_t *first_ptxp;
326
327 first_ptxp = ptxp = &pmps->tx[0];
328 vtxp = &vmps->tx[0];
329 next_ptxp = ptxp + 1;
330 for (n = (GTMPSC_NTXDESC - 1); n--; ) {
331 dp = &vtxp->txdesc;
332 desc_write(&dp->sdma_csr, 0);
333 desc_write(&dp->sdma_cnt, 0);
334 desc_write(&dp->sdma_bufp, (u_int32_t)&ptxp->txbuf);
335 desc_write(&dp->sdma_next, (u_int32_t)&next_ptxp->txdesc);
336 GTMPSC_CACHE_FLUSH(dp);
337 vtxp++;
338 ptxp++;
339 next_ptxp++;
340 }
341 dp = &vtxp->txdesc;
342 desc_write(&dp->sdma_csr, 0);
343 desc_write(&dp->sdma_cnt, 0);
344 desc_write(&dp->sdma_bufp, (u_int32_t)&ptxp->txbuf);
345 desc_write(&dp->sdma_next, (u_int32_t)&first_ptxp->txdesc);
346 GTMPSC_CACHE_FLUSH(dp);
347 }
348
349 /*
350 * gtmpsc_rxdesc_init - set up RX descriptor ring
351 */
352 STATIC void
353 gtmpsc_rxdesc_init(gtmpsc_poll_sdma_t *vmps, gtmpsc_poll_sdma_t *pmps)
354 {
355 int n;
356 sdma_desc_t *dp;
357 gtmpsc_pollrx_t *vrxp;
358 gtmpsc_pollrx_t *prxp;
359 gtmpsc_pollrx_t *next_prxp;
360 gtmpsc_pollrx_t *first_prxp;
361 unsigned int csr;
362
363 csr = SDMA_CSR_RX_L|SDMA_CSR_RX_F|SDMA_CSR_RX_OWN|SDMA_CSR_RX_EI;
364 first_prxp = prxp = &pmps->rx[0];
365 vrxp = &vmps->rx[0];
366 next_prxp = prxp + 1;
367 for (n = (GTMPSC_NRXDESC - 1); n--; ) {
368 dp = &vrxp->rxdesc;
369 desc_write(&dp->sdma_csr, csr);
370 desc_write(&dp->sdma_cnt,
371 GTMPSC_RXBUFSZ << SDMA_RX_CNT_BUFSZ_SHIFT);
372 desc_write(&dp->sdma_bufp, (u_int32_t)&prxp->rxbuf);
373 desc_write(&dp->sdma_next, (u_int32_t)&next_prxp->rxdesc);
374 GTMPSC_CACHE_FLUSH(dp);
375 vrxp++;
376 prxp++;
377 next_prxp++;
378 }
379 dp = &vrxp->rxdesc;
380 desc_write(&dp->sdma_csr, SDMA_CSR_RX_OWN);
381 desc_write(&dp->sdma_cnt,
382 GTMPSC_RXBUFSZ << SDMA_RX_CNT_BUFSZ_SHIFT);
383 desc_write(&dp->sdma_bufp, (u_int32_t)&prxp->rxbuf);
384 desc_write(&dp->sdma_next, (u_int32_t)&first_prxp->rxdesc);
385 GTMPSC_CACHE_FLUSH(dp);
386 }
387
388 /*
389 * Compute the BRG countdown value (CDV in BRG_BCR)
390 */
391
392 STATIC int
393 compute_cdv(unsigned int baud)
394 {
395 unsigned int cdv;
396
397 if (baud == 0)
398 return 0;
399 cdv = (GT_MPSC_FREQUENCY / (baud * GTMPSC_CLOCK_DIVIDER) + 1) / 2 - 1;
400 if (cdv > BRG_BCR_CDV_MAX)
401 return -1;
402 return cdv;
403 }
404
405 STATIC void
406 gtmpsc_loadchannelregs(struct gtmpsc_softc *sc)
407 {
408 u_int brg_bcr;
409 u_int unit;
410
411 unit = sc->gtmpsc_unit;
412 brg_bcr = unit ? BRG_BCR1 : BRG_BCR0;
413
414 GT_WRITE(sc, brg_bcr, sc->gtmpsc_brg_bcr);
415 GT_WRITE(sc, GTMPSC_U_CHRN(unit, 3), sc->gtmpsc_chr3);
416 }
417
418 STATIC int
419 gtmpscmatch(struct device *parent, struct cfdata *self, void *aux)
420 {
421 struct gt_softc *gt = (struct gt_softc *) parent;
422 struct gt_attach_args *ga = aux;
423
424 return GT_MPSCOK(gt, ga, >mpsc_cd);
425 }
426
427 STATIC void
428 gtmpscattach(struct device *parent, struct device *self, void *aux)
429 {
430 struct gt_attach_args *ga = aux;
431 struct gt_softc *gt = (struct gt_softc *) parent;
432 struct gtmpsc_softc *sc = (struct gtmpsc_softc *) self;
433 gtmpsc_poll_sdma_t *vmps;
434 gtmpsc_poll_sdma_t *pmps;
435 struct tty *tp;
436 caddr_t kva;
437 int rsegs;
438 int err;
439 int s;
440 int is_console = 0;
441
442 DPRINTF(("mpscattach\n"));
443
444 GT_MPSCFOUND(gt, ga);
445
446 s = splhigh();
447
448 sc->gtmpsc_memt = ga->ga_memt;
449 sc->gtmpsc_memh = ga->ga_memh;
450 sc->gtmpsc_dmat = ga->ga_dmat;
451 sc->gtmpsc_unit = ga->ga_unit;
452
453 aprint_normal(": SDMA");
454 err = bus_dmamem_alloc(sc->gtmpsc_dmat, PAGE_SIZE, PAGE_SIZE, PAGE_SIZE,
455 sc->gtmpsc_dma_segs, 1, &rsegs, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW);
456 if (err) {
457 PRINTF(("mpscattach: bus_dmamem_alloc error 0x%x\n", err));
458 splx(s);
459 return;
460 }
461 #ifndef SDMA_COHERENT
462 err = bus_dmamem_map(sc->gtmpsc_dmat, sc->gtmpsc_dma_segs, 1, PAGE_SIZE,
463 &kva, BUS_DMA_NOWAIT);
464 #else
465 err = bus_dmamem_map(sc->gtmpsc_dmat, sc->gtmpsc_dma_segs, 1, PAGE_SIZE,
466 &kva, BUS_DMA_NOWAIT|BUS_DMA_NOCACHE);
467 #endif
468 if (err) {
469 PRINTF(("mpscattach: bus_dmamem_map error 0x%x\n", err));
470 splx(s);
471 return;
472 }
473
474 err = bus_dmamap_create(sc->gtmpsc_dmat, PAGE_SIZE, 1, PAGE_SIZE,
475 PAGE_SIZE, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, &sc->gtmpsc_dma_map);
476 if (err) {
477 PRINTF(("mpscattach: bus_dmamap_create error 0x%x\n", err));
478 splx(s);
479 return;
480 }
481
482 err = bus_dmamap_load(sc->gtmpsc_dmat, sc->gtmpsc_dma_map, kva,
483 PAGE_SIZE, NULL, 0);
484 if (err) {
485 PRINTF(("mpscattach: bus_dmamap_load error 0x%x\n", err));
486 splx(s);
487 return;
488 }
489 memset(kva, 0, PAGE_SIZE); /* paranoid/superfluous */
490
491 vmps = (gtmpsc_poll_sdma_t *)kva; /* KVA */
492 pmps = (gtmpsc_poll_sdma_t *)sc->gtmpsc_dma_map->dm_segs[0].ds_addr; /* PA */
493 #if defined(DEBUG)
494 printf(" at %p/%p", vmps, pmps);
495 #endif
496 gtmpsc_txdesc_init(vmps, pmps);
497 gtmpsc_rxdesc_init(vmps, pmps);
498 sc->gtmpsc_poll_sdmapage = vmps;
499
500 if (gtmpsc_scp[sc->gtmpsc_unit] != NULL)
501 gtmpsc_txflush(gtmpsc_scp[sc->gtmpsc_unit]);
502
503 sc->gtmpsc_tty = tp = ttymalloc();
504 tp->t_oproc = gtmpscstart;
505 tp->t_param = gtmpscparam;
506 tty_attach(tp);
507
508 if (gtmpsc_sdma_ih == NULL) {
509 gtmpsc_sdma_ih = intr_establish(IRQ_SDMA, IST_LEVEL, IPL_SERIAL,
510 gtmpsc_intr, &sc);
511 if (gtmpsc_sdma_ih == NULL)
512 panic("mpscattach: cannot intr_establish IRQ_SDMA");
513 }
514
515 sc->sc_si = softintr_establish(IPL_SOFTSERIAL, gtmpsc_softintr, sc);
516 if (sc->sc_si == NULL)
517 panic("mpscattach: cannot softintr_establish IPL_SOFTSERIAL");
518
519 shutdownhook_establish(gtmpsc_shutdownhook, sc);
520
521 gtmpsc_scp[sc->gtmpsc_unit] = sc;
522 gtmpscinit(sc);
523
524 if (cn_tab == >mpsc_consdev &&
525 cn_tab->cn_dev == makedev(0, sc->gtmpsc_unit)) {
526 cn_tab->cn_dev = makedev(cdevsw_lookup_major(>mpsc_cdevsw),
527 sc->gtmpsc_dev.dv_unit);
528 is_console = 1;
529 }
530
531 aprint_normal(" irq %s%s\n",
532 intr_string(IRQ_SDMA),
533 (gt_reva_gtmpsc_bug) ? " [Rev A. bug]" : "");
534
535 if (is_console)
536 aprint_normal("%s: console\n", sc->gtmpsc_dev.dv_xname);
537
538 #ifdef DDB
539 if (is_console == 0)
540 SDMA_IMASK_ENABLE(sc, SDMA_INTR_RXBUF(sc->gtmpsc_unit));
541 #endif /* DDB */
542
543 splx(s);
544 #ifdef KGDB
545 /*
546 * Allow kgdb to "take over" this port. If this is
547 * the kgdb device, it has exclusive use.
548 */
549 if (sc->gtmpsc_unit == comkgdbport) {
550 if (comkgdbport == 0) { /* FIXME */
551 printf("%s(kgdb): cannot share with console\n",
552 sc->gtmpsc_dev.dv_xname);
553 return;
554 }
555
556 sc->gtmpsc_flags |= GTMPSCF_KGDB;
557 printf("%s: kgdb\n", sc->gtmpsc_dev.dv_xname);
558 gtmpsc_txflush(gtmpsc_scp[0]);
559 kgdb_attach(gtmpsc_kgdb_getc, gtmpsc_kgdb_putc, NULL);
560 kgdb_dev = 123; /* unneeded, only to satisfy some tests */
561 gtmpsc_kgdb_attached = 1;
562 SDMA_IMASK_ENABLE(sc, SDMA_INTR_RXBUF(sc->gtmpsc_unit));
563 kgdb_connect(1);
564 }
565 #endif /* KGDB */
566 }
567
568 STATIC void
569 gtmpscshutdown(struct gtmpsc_softc *sc)
570 {
571 struct tty *tp;
572 int s;
573
574 #ifdef KGDB
575 if (sc->gtmpsc_flags & GTMPSCF_KGDB != 0)
576 return;
577 #endif
578 tp = sc->gtmpsc_tty;
579 s = splserial();
580 /* Fake carrier off */
581 (void) (*tp->t_linesw->l_modem)(tp, 0);
582 SDMA_IMASK_DISABLE(sc, SDMA_INTR_RXBUF(sc->gtmpsc_unit));
583 splx(s);
584 }
585
586 int
587 gtmpscopen(dev_t dev, int flag, int mode, struct proc *p)
588 {
589 struct gtmpsc_softc *sc;
590 int unit = GTMPSCUNIT(dev);
591 struct tty *tp;
592 int s;
593 int s2;
594 int error;
595
596 if (unit >= gtmpsc_cd.cd_ndevs)
597 return ENXIO;
598 sc = gtmpsc_cd.cd_devs[unit];
599 if (!sc)
600 return ENXIO;
601 #ifdef KGDB
602 /*
603 * If this is the kgdb port, no other use is permitted.
604 */
605 if (sc->gtmpsc_flags & GTMPSCF_KGDB != 0)
606 return (EBUSY);
607 #endif
608 tp = sc->gtmpsc_tty;
609 if (ISSET(tp->t_state, TS_ISOPEN) &&
610 ISSET(tp->t_state, TS_XCLUDE) &&
611 p->p_ucred->cr_uid != 0)
612 return (EBUSY);
613
614 s = spltty();
615
616 if (!(tp->t_state & TS_ISOPEN)) {
617 struct termios t;
618
619 tp->t_dev = dev;
620 s2 = splserial();
621 SDMA_IMASK_ENABLE(sc, SDMA_INTR_RXBUF(unit));
622 splx(s2);
623 t.c_ispeed = 0;
624 #if 0
625 t.c_ospeed = TTYDEF_SPEED;
626 #else
627 t.c_ospeed = GT_MPSC_DEFAULT_BAUD_RATE;
628 #endif
629 t.c_cflag = TTYDEF_CFLAG;
630 /* Make sure gtmpscparam() will do something. */
631 tp->t_ospeed = 0;
632 (void) gtmpscparam(tp, &t);
633 tp->t_iflag = TTYDEF_IFLAG;
634 tp->t_oflag = TTYDEF_OFLAG;
635 tp->t_lflag = TTYDEF_LFLAG;
636 ttychars(tp);
637 ttsetwater(tp);
638 s2 = splserial();
639 /* Clear the input ring */
640 sc->gtmpsc_rxfifo_putix = 0;
641 sc->gtmpsc_rxfifo_getix = 0;
642 sc->gtmpsc_rxfifo_navail = GTMPSC_RXFIFOSZ;
643 gtmpsc_iflush(sc);
644 splx(s2);
645 }
646 splx(s);
647 error = ttyopen(tp, GTMPSCDIALOUT(dev), ISSET(flag, O_NONBLOCK));
648 if (error)
649 goto bad;
650
651 error = (*tp->t_linesw->l_open)(dev, tp);
652 if (error)
653 goto bad;
654
655 return (0);
656
657 bad:
658 if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
659 /*
660 * We failed to open the device, and nobody else had it opened.
661 * Clean up the state as appropriate.
662 */
663 gtmpscshutdown(sc);
664 }
665
666 return (error);
667 }
668
669 int
670 gtmpscclose(dev_t dev, int flag, int mode, struct proc *p)
671 {
672 int unit = GTMPSCUNIT(dev);
673 struct gtmpsc_softc *sc = gtmpsc_cd.cd_devs[unit];
674 struct tty *tp = sc->gtmpsc_tty;
675 int s;
676
677 s = splserial();
678 if (!ISSET(tp->t_state, TS_ISOPEN)) {
679 splx(s);
680 return (0);
681 }
682
683 (*tp->t_linesw->l_close)(tp, flag);
684 ttyclose(tp);
685 if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
686 /*
687 * Although we got a last close, the device may still be in
688 * use; e.g. if this was the dialout node, and there are still
689 * processes waiting for carrier on the non-dialout node.
690 */
691 gtmpscshutdown(sc);
692 }
693
694 splx(s);
695 return (0);
696 }
697
698 int
699 gtmpscread(dev_t dev, struct uio *uio, int flag)
700 {
701 struct gtmpsc_softc *sc = gtmpsc_cd.cd_devs[GTMPSCUNIT(dev)];
702 struct tty *tp = sc->gtmpsc_tty;
703
704 return (*tp->t_linesw->l_read)(tp, uio, flag);
705 }
706
707 int
708 gtmpscwrite(dev_t dev, struct uio *uio, int flag)
709 {
710 struct gtmpsc_softc *sc = gtmpsc_cd.cd_devs[GTMPSCUNIT(dev)];
711 struct tty *tp = sc->gtmpsc_tty;
712
713 return (*tp->t_linesw->l_write)(tp, uio, flag);
714 }
715
716 int
717 gtmpscpoll(dev_t dev, int events, struct proc *p)
718 {
719 struct gtmpsc_softc *sc = gtmpsc_cd.cd_devs[GTMPSCUNIT(dev)];
720 struct tty *tp = sc->gtmpsc_tty;
721
722 return ((*tp->t_linesw->l_poll)(tp, events, p));
723 }
724
725 int
726 gtmpscioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
727 {
728 struct gtmpsc_softc *sc = gtmpsc_cd.cd_devs[GTMPSCUNIT(dev)];
729 struct tty *tp = sc->gtmpsc_tty;
730 int error;
731
732 if ((error = (*tp->t_linesw->l_ioctl)(tp, cmd, data, flag, p)) >= 0)
733 return error;
734 if ((error = ttioctl(tp, cmd, data, flag, p)) >= 0)
735 return error;
736 return ENOTTY;
737 }
738
739 struct tty *
740 gtmpsctty(dev_t dev)
741 {
742 struct gtmpsc_softc *sc = gtmpsc_cd.cd_devs[GTMPSCUNIT(dev)];
743
744 return sc->gtmpsc_tty;
745 }
746
747 void
748 gtmpscstop(struct tty *tp, int flag)
749 {
750 }
751
752 STATIC void
753 gtmpscstart(struct tty *tp)
754 {
755 struct gtmpsc_softc *sc;
756 unsigned char *tba;
757 unsigned int unit;
758 int s, s2, tbc;
759
760 unit = GTMPSCUNIT(tp->t_dev);
761 sc = gtmpsc_cd.cd_devs[unit];
762 if (sc == NULL)
763 return;
764
765 s = spltty();
766 if (tp->t_state & (TS_TIMEOUT | TS_BUSY | TS_TTSTOP))
767 goto out;
768 if (sc->sc_tx_stopped)
769 goto out;
770 if (tp->t_outq.c_cc <= tp->t_lowat) {
771 if ((tp->t_state & TS_ASLEEP) != 0) {
772 tp->t_state &= ~TS_ASLEEP;
773 wakeup(&tp->t_outq);
774 }
775 selwakeup(&tp->t_wsel);
776 if (tp->t_outq.c_cc == 0)
777 goto out;
778 }
779
780 /* Grab the first contiguous region of buffer space. */
781 tba = tp->t_outq.c_cf;
782 tbc = ndqb(&tp->t_outq, 0);
783
784 s2 = splserial();
785
786 sc->sc_tba = tba;
787 sc->sc_tbc = tbc;
788 sc->cnt_tx_from_ldisc += tbc;
789 SDMA_IMASK_ENABLE(sc, SDMA_INTR_TXBUF(unit));
790 tp->t_state |= TS_BUSY;
791 sc->sc_tx_busy = 1;
792 gtmpsc_common_putn(sc);
793
794 splx(s2);
795 out:
796 splx(s);
797 }
798
799 STATIC int
800 gtmpscparam(struct tty *tp, struct termios *t)
801 {
802 struct gtmpsc_softc *sc = gtmpsc_cd.cd_devs[GTMPSCUNIT(tp->t_dev)];
803 int ospeed = compute_cdv(t->c_ospeed);
804 int s;
805
806 /* Check requested parameters. */
807 if (ospeed < 0)
808 return (EINVAL);
809 if (t->c_ispeed && t->c_ispeed != t->c_ospeed)
810 return (EINVAL);
811
812 /*
813 * If there were no changes, don't do anything. This avoids dropping
814 * input and improves performance when all we did was frob things like
815 * VMIN and VTIME.
816 */
817 if (tp->t_ospeed == t->c_ospeed &&
818 tp->t_cflag == t->c_cflag)
819 return (0);
820
821 s = splserial();
822
823 sc->gtmpsc_brg_bcr = BRG_BCR_EN | GT_MPSC_CLOCK_SOURCE | ospeed;
824 sc->gtmpsc_chr3 = GTMPSC_MAXIDLE(t->c_ospeed);
825
826 /* And copy to tty. */
827 tp->t_ispeed = 0;
828 tp->t_ospeed = t->c_ospeed;
829 tp->t_cflag = t->c_cflag;
830
831 if (!sc->sc_heldchange) {
832 if (sc->sc_tx_busy) {
833 sc->sc_heldtbc = sc->sc_tbc;
834 sc->sc_tbc = 0;
835 sc->sc_heldchange = 1;
836 } else
837 gtmpsc_loadchannelregs(sc);
838 }
839
840 splx(s);
841
842 /* Fake carrier on */
843 (void) (*tp->t_linesw->l_modem)(tp, 1);
844
845 return 0;
846 }
847
848 STATIC int
849 gtmpsc_probe(void)
850 {
851 return 1; /* XXX */
852 }
853
854 STATIC unsigned int
855 gtmpsc_get_causes(void)
856 {
857 int i;
858 struct gtmpsc_softc *sc;
859 unsigned int cause = 0;
860 static unsigned int bits[4] = {
861 SDMA_INTR_RXBUF(0),
862 SDMA_INTR_TXBUF(0),
863 SDMA_INTR_RXBUF(1),
864 SDMA_INTR_TXBUF(1),
865 };
866 sdma_desc_t *desc_addr[4];
867 static unsigned int fake_once = SDMA_INTR_RXBUF(0)
868 | SDMA_INTR_RXBUF(1);
869
870 desc_addr[0] = 0;
871 desc_addr[1] = 0;
872 desc_addr[2] = 0;
873 desc_addr[3] = 0;
874 sc = gtmpsc_cd.cd_devs[0];
875 if (sc != 0) {
876 if (sdma_imask & SDMA_INTR_RXBUF(0)) {
877 desc_addr[0] =
878 &sc->gtmpsc_poll_sdmapage->rx[sc->gtmpsc_poll_rxix].rxdesc;
879 GTMPSC_CACHE_INVALIDATE(desc_addr[0]);
880 __asm __volatile ("dcbt 0,%0" :: "r"(desc_addr[0]));
881 }
882 if (sdma_imask & SDMA_INTR_TXBUF(0)) {
883 desc_addr[1] =
884 &sc->gtmpsc_poll_sdmapage->tx[sc->gtmpsc_poll_txix].txdesc;
885 GTMPSC_CACHE_INVALIDATE(desc_addr[1]);
886 __asm __volatile ("dcbt 0,%0" :: "r"(desc_addr[1]));
887 }
888 }
889 sc = gtmpsc_cd.cd_devs[1];
890 if (sc != 0) {
891 if (sdma_imask & SDMA_INTR_RXBUF(1)) {
892 desc_addr[2] =
893 &sc->gtmpsc_poll_sdmapage->rx[sc->gtmpsc_poll_rxix].rxdesc;
894 GTMPSC_CACHE_INVALIDATE(desc_addr[2]);
895 __asm __volatile ("dcbt 0,%0" :: "r"(desc_addr[2]));
896 }
897 if (sdma_imask & SDMA_INTR_TXBUF(1)) {
898 desc_addr[3] =
899 &sc->gtmpsc_poll_sdmapage->tx[sc->gtmpsc_poll_txix].txdesc;
900 GTMPSC_CACHE_INVALIDATE(desc_addr[3]);
901 __asm __volatile ("dcbt 0,%0" :: "r"(desc_addr[3]));
902 }
903 }
904
905 for (i = 0; i < 4; ++i)
906 if ((sdma_imask & bits[i]) && desc_addr[i] != 0 &&
907 (desc_addr[i]->sdma_csr & SDMA_CSR_TX_OWN) == 0)
908 cause |= bits[i];
909 if (fake_once & sdma_imask) {
910 cause |= fake_once & sdma_imask;
911 /* fake_once &= ~(cause & fake_once); */
912 }
913 return cause;
914 }
915
916 STATIC int
917 gtmpsc_intr(void *arg)
918 {
919 struct gtmpsc_softc *sc;
920 unsigned int unit;
921 int spurious = 1;
922 unsigned int r;
923 unsigned int cause=0;
924
925 if (gt_reva_gtmpsc_bug)
926 cause = gtmpsc_get_causes();
927
928 #ifdef KGDB
929 if (kgdb_break_immediate) {
930 unit = comkgdbport;
931 sc = gtmpsc_cd.cd_devs[unit];
932 if (sc == 0 || (sc->gtmpsc_flags & GTMPSCF_KGDB) == 0)
933 goto skip_kgdb;
934 if (gt_reva_gtmpsc_bug)
935 r = cause & sdma_imask;
936 else {
937 r = GT_READ(sc, SDMA_ICAUSE);
938 r &= GT_READ(sc, SDMA_IMASK);
939 }
940 r &= SDMA_INTR_RXBUF(unit);
941 if (r == 0)
942 goto skip_kgdb;
943 GT_WRITE(sc, SDMA_ICAUSE, ~r);
944 spurious = 0;
945 gtmpsc_kgdb_poll(sc);
946 }
947 skip_kgdb:
948 #endif
949 for (unit = 0; unit < GTMPSC_NCHAN; ++unit) {
950 sc = gtmpsc_cd.cd_devs[unit];
951 if (sc == 0)
952 continue;
953 if (gt_reva_gtmpsc_bug)
954 r = cause & sdma_imask;
955 else {
956 r = GT_READ(sc, SDMA_ICAUSE);
957 r &= GT_READ(sc, SDMA_IMASK);
958 }
959 r &= SDMA_U_INTR_MASK(unit);
960 if (r == 0)
961 continue;
962 GT_WRITE(sc, SDMA_ICAUSE, ~r);
963 spurious = 0;
964 if (r & SDMA_INTR_RXBUF(unit)) {
965 #ifdef KGDB
966 if (sc->gtmpsc_flags & GTMPSCF_KGDB)
967 gtmpsc_kgdb_poll(sc);
968 else
969 #endif
970 gtmpsc_poll(sc);
971 }
972 if (r & SDMA_INTR_TXBUF(unit)) {
973 /*
974 * If we've delayed a parameter change, do it now,
975 * and restart output.
976 */
977 if (sc->sc_heldchange) {
978 gtmpsc_loadchannelregs(sc);
979 sc->sc_heldchange = 0;
980 sc->sc_tbc = sc->sc_heldtbc;
981 sc->sc_heldtbc = 0;
982 }
983
984 /* Output the next chunk of the contiguous buffer,
985 if any. */
986 if (sc->sc_tbc > 0)
987 gtmpsc_common_putn(sc);
988 if (sc->sc_tbc == 0 && sc->sc_tx_busy) {
989 sc->sc_tx_busy = 0;
990 sc->sc_tx_done = 1;
991 softintr_schedule(sc->sc_si);
992 SDMA_IMASK_DISABLE(sc, SDMA_INTR_TXBUF(unit));
993 }
994 }
995 }
996 return 1;
997 /* return !spurious; */
998 }
999
1000 STATIC void
1001 gtmpsc_softintr(void *arg)
1002 {
1003 struct gtmpsc_softc *sc = arg;
1004 struct tty *tp;
1005 int (*rint)(int, struct tty *);
1006 int jobs;
1007 int s;
1008
1009 tp = sc->gtmpsc_tty;
1010 rint = tp->t_linesw->l_rint;
1011 do {
1012 jobs = 0;
1013 if (sc->gtmpsc_rxfifo_navail < GTMPSC_RXFIFOSZ) {
1014 s = spltty();
1015 rint(sc->gtmpsc_rxfifo[sc->gtmpsc_rxfifo_getix++],
1016 tp);
1017 if (sc->gtmpsc_rxfifo_getix >= GTMPSC_RXFIFOSZ)
1018 sc->gtmpsc_rxfifo_getix = 0;
1019 ++sc->cnt_rx_from_fifo;
1020 /* atomic_add() returns the previous value */
1021 jobs += atomic_add(&sc->gtmpsc_rxfifo_navail, 1) + 1
1022 < GTMPSC_RXFIFOSZ;
1023 splx(s);
1024 }
1025 if (sc->sc_tx_done) {
1026 ++jobs;
1027 sc->sc_tx_done = 0;
1028 s = spltty();
1029 tp->t_state &= ~TS_BUSY;
1030 if ((tp->t_state & TS_FLUSH) != 0)
1031 tp->t_state &= ~TS_FLUSH;
1032 else
1033 ndflush(&tp->t_outq, (int)(sc->sc_tba - tp->t_outq.c_cf));
1034 (*tp->t_linesw->l_start)(tp);
1035 splx(s);
1036 }
1037 } while (jobs);
1038 }
1039
1040 /*
1041 * Console support functions
1042 */
1043 void
1044 gtmpsccnprobe(struct consdev *cd)
1045 {
1046 int maj;
1047 /* {extern void return_to_dink(int); return_to_dink(gtbase);} */
1048
1049 if (!gtmpsc_probe())
1050 return;
1051
1052 maj = cdevsw_lookup_major(>mpsc_cdevsw);
1053 cd->cn_dev = makedev(maj, 0);
1054 cd->cn_pri = CN_INTERNAL;
1055 }
1056
1057 /*
1058 * gtmpsc_hackinit - hacks required to supprt GTMPSC console
1059 */
1060 STATIC void
1061 gtmpsc_hackinit(struct gtmpsc_softc *sc, bus_space_tag_t memt,
1062 bus_space_handle_t memh, int unit)
1063 {
1064 gtmpsc_poll_sdma_t *vmps;
1065 gtmpsc_poll_sdma_t *pmps;
1066
1067 DPRINTF(("hackinit\n"));
1068
1069 bzero(sc, sizeof(struct gtmpsc_softc));
1070 sc->gtmpsc_memt = memt;
1071 sc->gtmpsc_memh = memh;
1072 sc->gtmpsc_unit = unit;
1073 gtmpsc_scp[sc->gtmpsc_unit] = sc;
1074
1075 vmps = (gtmpsc_poll_sdma_t *)gtmpsc_fake_dmapage; /* KVA */
1076 pmps = (gtmpsc_poll_sdma_t *)gtmpsc_fake_dmapage; /* PA */
1077
1078 gtmpsc_txdesc_init(vmps, pmps);
1079 gtmpsc_rxdesc_init(vmps, pmps);
1080
1081 sc->gtmpsc_poll_sdmapage = vmps;
1082 }
1083
1084 /*
1085 * gtmpsc_txflush - wait for output to drain
1086 */
1087 STATIC void
1088 gtmpsc_txflush(gtmpsc_softc_t *sc)
1089 {
1090 unsigned int csr;
1091 unsigned int *csrp;
1092 gtmpsc_polltx_t *vtxp;
1093 int limit = 4000000; /* 4 seconds */
1094 int ix;
1095
1096 ix = sc->gtmpsc_poll_txix - 1;
1097 if (ix < 0)
1098 ix = GTMPSC_NTXDESC - 1;
1099
1100 vtxp = &sc->gtmpsc_poll_sdmapage->tx[ix];
1101 csrp = &vtxp->txdesc.sdma_csr;
1102 while (limit > 0) {
1103 GTMPSC_CACHE_INVALIDATE(csrp);
1104 csr = desc_read(csrp);
1105 if ((csr & SDMA_CSR_TX_OWN) == 0)
1106 break;
1107 DELAY(GTMPSC_POLL_DELAY);
1108 limit -= GTMPSC_POLL_DELAY;
1109 }
1110 }
1111
1112 STATIC void
1113 gtmpsc_iflush(gtmpsc_softc_t *sc)
1114 {
1115 int timo;
1116 char c;
1117 int stat;
1118
1119 for (timo = 50000; timo; timo--)
1120 if (gtmpsc_common_pollc(sc->gtmpsc_unit, &c, &stat) == 0)
1121 return;
1122 #ifdef DIAGNOSTIC
1123 printf("%s: gtmpsc_iflush timeout %02x\n", sc->gtmpsc_dev.dv_xname, c);
1124 #endif
1125 }
1126
1127 STATIC void
1128 gtmpscinit_stop(struct gtmpsc_softc *sc, int once)
1129 {
1130 unsigned int r;
1131 unsigned int unit = sc->gtmpsc_unit;
1132
1133 /*
1134 * XXX HACK FIXME
1135 * PMON output has not been flushed. give him a chance
1136 */
1137 #if 1
1138 if (! once)
1139 DELAY(100000); /* XXX */
1140 #endif
1141
1142 DPRINTF(("gtmpscinit_stop: unit 0x%x\n", unit));
1143 if (unit >= GTMPSC_NCHAN) {
1144 PRINTF(("mpscinit: undefined unit %d\n", sc->gtmpsc_unit));
1145 return;
1146 }
1147
1148 sc->gtmpsc_chr2 = 0; /* Default value of CHR2 */
1149
1150 /*
1151 * stop GTMPSC unit
1152 */
1153 r = sc->gtmpsc_chr2 | GTMPSC_CHR2_RXABORT|GTMPSC_CHR2_TXABORT;
1154 GT_WRITE(sc, GTMPSC_U_CHRN(unit, 2), r);
1155
1156 DELAY(GTMPSC_RESET_DELAY);
1157
1158 /*
1159 * abort SDMA TX, RX for GTMPSC unit
1160 */
1161 GT_WRITE(sc, SDMA_U_SDCM(unit), SDMA_SDCM_AR|SDMA_SDCM_AT);
1162
1163 if (once == 0) {
1164 /*
1165 * Determine if this is the buggy GT-64260A case.
1166 * If this is, then most of GTMPSC and SDMA registers
1167 * are unreadable.
1168 * (They always yield -1).
1169 */
1170 GT_WRITE(sc, SDMA_IMASK, 0);
1171 r = GT_READ(sc, SDMA_IMASK);
1172 gt_reva_gtmpsc_bug = r == ~0;
1173 sdma_imask = 0;
1174 }
1175 /*
1176 * poll for GTMPSC RX abort completion
1177 */
1178 if (gt_reva_gtmpsc_bug) {
1179 /* Sync up with the device first */
1180 r = GT_READ(sc, GTMPSC_U_CHRN(unit, 2));
1181 DELAY(GTMPSC_RESET_DELAY);
1182 } else
1183 for (;;) {
1184 r = GT_READ(sc, GTMPSC_U_CHRN(unit, 2));
1185 if (! (r & GTMPSC_CHR2_RXABORT))
1186 break;
1187 }
1188
1189 /*
1190 * poll for SDMA RX abort completion
1191 */
1192 for (;;) {
1193 r = GT_READ(sc, SDMA_U_SDCM(unit));
1194 if (! (r & (SDMA_SDCM_AR|SDMA_SDCM_AT)))
1195 break;
1196 DELAY(50);
1197 }
1198
1199 }
1200
1201 STATIC void
1202 gtmpscinit_start(struct gtmpsc_softc *sc, int once)
1203 {
1204 unsigned int r;
1205 unsigned int unit = sc->gtmpsc_unit;
1206
1207 /*
1208 * initialize softc's "current" transfer indicies & counts
1209 */
1210 sc->gtmpsc_cx = 0;
1211 sc->gtmpsc_nc = 0;
1212 sc->gtmpsc_poll_txix = 0;
1213 sc->gtmpsc_poll_rxix = 0;
1214
1215 /*
1216 * initialize softc's RX softintr FIFO
1217 */
1218 sc->gtmpsc_rxfifo_putix = 0;
1219 sc->gtmpsc_rxfifo_getix = 0;
1220 sc->gtmpsc_rxfifo_navail = GTMPSC_RXFIFOSZ;
1221 memset(&sc->gtmpsc_rxfifo[0], 0, GTMPSC_RXFIFOSZ);
1222
1223 /*
1224 * set SDMA unit port TX descriptor pointers
1225 * "next" pointer of last descriptor is start of ring
1226 */
1227 r = desc_read(
1228 &sc->gtmpsc_poll_sdmapage->tx[GTMPSC_NTXDESC-1].txdesc.sdma_next);
1229 GT_WRITE(sc, SDMA_U_SCTDP(unit), r); /* current */
1230 (void)GT_READ(sc, SDMA_U_SCTDP(unit));
1231 GT_WRITE(sc, SDMA_U_SFTDP(unit), r); /* first */
1232 (void)GT_READ(sc, SDMA_U_SFTDP(unit));
1233 /*
1234 * set SDMA unit port RX descriptor pointer
1235 * "next" pointer of last descriptor is start of ring
1236 */
1237 r = desc_read(
1238 &sc->gtmpsc_poll_sdmapage->rx[GTMPSC_NRXDESC-1].rxdesc.sdma_next);
1239 GT_WRITE(sc, SDMA_U_SCRDP(unit), r); /* current */
1240
1241 /*
1242 * initialize SDMA unit Configuration Register
1243 */
1244 r = SDMA_SDC_BSZ_8x64|SDMA_SDC_SFM|SDMA_SDC_RFT;
1245 GT_WRITE(sc, SDMA_U_SDC(unit), r);
1246
1247 /*
1248 * enable SDMA receive
1249 */
1250 GT_WRITE(sc, SDMA_U_SDCM(unit), SDMA_SDCM_ERD);
1251
1252 if (once == 0) {
1253 /*
1254 * GTMPSC Routing:
1255 * MR0 --> Serial Port 0
1256 * MR1 --> Serial Port 1
1257 */
1258 GT_WRITE(sc, GTMPSC_MRR, GTMPSC_MRR_RES);
1259
1260 /*
1261 * RX and TX Clock Routing:
1262 * CRR0 --> BRG0
1263 * CRR1 --> BRG1
1264 */
1265 r = GTMPSC_CRR_BRG0 | (GTMPSC_CRR_BRG1 << GTMPSC_CRR1_SHIFT);
1266 GT_WRITE(sc, GTMPSC_RCRR, r);
1267 GT_WRITE(sc, GTMPSC_TCRR, r);
1268 }
1269 sc->gtmpsc_brg_bcr = BRG_BCR_EN | GT_MPSC_CLOCK_SOURCE |
1270 compute_cdv(GT_MPSC_DEFAULT_BAUD_RATE);
1271 sc->gtmpsc_chr3 = GTMPSC_MAXIDLE(GT_MPSC_DEFAULT_BAUD_RATE);
1272 gtmpsc_loadchannelregs(sc);
1273
1274 /*
1275 * set MPSC Protocol configuration register for GTMPSC unit
1276 */
1277 GT_WRITE(sc, GTMPSC_U_MPCR(unit), GTMPSC_MPCR_CL_8);
1278
1279 /*
1280 * set MPSC LO and HI port config registers for GTMPSC unit
1281 */
1282 r = GTMPSC_MMCR_LO_MODE_UART
1283 |GTMPSC_MMCR_LO_ET
1284 |GTMPSC_MMCR_LO_ER
1285 |GTMPSC_MMCR_LO_NLM;
1286 GT_WRITE(sc, GTMPSC_U_MMCR_LO(unit), r);
1287
1288 r =
1289 GTMPSC_MMCR_HI_TCDV_DEFAULT
1290 |GTMPSC_MMCR_HI_RDW
1291 |GTMPSC_MMCR_HI_RCDV_DEFAULT;
1292 GT_WRITE(sc, GTMPSC_U_MMCR_HI(unit), r);
1293
1294 /*
1295 * tell MPSC receive the Enter Hunt
1296 */
1297 r = sc->gtmpsc_chr2 | GTMPSC_CHR2_EH;
1298 GT_WRITE(sc, GTMPSC_U_CHRN(unit, 2), r);
1299
1300 /*
1301 * clear any pending SDMA interrupts for this unit
1302 */
1303 r = GT_READ(sc, SDMA_ICAUSE);
1304 r &= ~SDMA_U_INTR_MASK(unit);
1305 GT_WRITE(sc, SDMA_ICAUSE, r); /* ??? */
1306
1307 DPRINTF(("gtmpscinit: OK\n"));
1308 }
1309
1310 /*
1311 * gtmpscinit - prepare MPSC for operation
1312 *
1313 * assumes we are called at ipl >= IPL_SERIAL
1314 */
1315 STATIC void
1316 gtmpscinit(struct gtmpsc_softc *sc)
1317 {
1318 static int once = 0;
1319
1320 gtmpscinit_stop(sc, once);
1321 gtmpscinit_start(sc, once);
1322 once = 1;
1323 }
1324
1325 /*
1326 * gtmpsccninit - initialize the driver and the mpsc device
1327 */
1328 void
1329 gtmpsccninit(struct consdev *cd)
1330 {
1331 }
1332
1333 int
1334 gtmpsccngetc(dev_t dev)
1335 {
1336 unsigned int unit = 0;
1337 int c;
1338
1339 unit = GTMPSCUNIT(dev);
1340 if (major(dev) != 0) {
1341 struct gtmpsc_softc *sc = device_lookup(>mpsc_cd, unit);
1342 if (sc == NULL)
1343 return 0;
1344 unit = sc->gtmpsc_unit;
1345 }
1346 if (unit >= GTMPSC_NCHAN)
1347 return 0;
1348 c = gtmpsc_common_getc(unit);
1349
1350 return c;
1351 }
1352
1353 void
1354 gtmpsccnputc(dev_t dev, int c)
1355 {
1356 unsigned int unit = 0;
1357 char ch = c;
1358 static int ix = 0;
1359
1360 if (gtmpsccninit_done == 0) {
1361 if ((minor(dev) == 0) && (ix < sizeof(gtmpsc_earlybuf)))
1362 gtmpsc_earlybuf[ix++] = (unsigned char)c;
1363 return;
1364 }
1365
1366 unit = GTMPSCUNIT(dev);
1367 if (major(dev) != 0) {
1368 struct gtmpsc_softc *sc = device_lookup(>mpsc_cd, unit);
1369 if (sc == NULL)
1370 return;
1371 unit = sc->gtmpsc_unit;
1372 }
1373
1374 if (unit >= GTMPSC_NCHAN)
1375 return;
1376
1377 gtmpsc_common_putc(unit, ch);
1378 }
1379
1380 void
1381 gtmpsccnpollc(dev_t dev, int on)
1382 {
1383 }
1384
1385 int
1386 gtmpsccnattach(bus_space_tag_t memt, bus_space_handle_t memh, int unit,
1387 int speed, tcflag_t tcflag)
1388 {
1389 struct gtmpsc_softc *sc = >mpsc_fake_softc;
1390 unsigned char *cp;
1391 unsigned char c;
1392 unsigned int i;
1393
1394 if (gtmpsccninit_done)
1395 return 0;
1396
1397 DPRINTF(("gtmpsccnattach\n"));
1398 gtmpsc_hackinit(sc, memt, memh, unit);
1399 DPRINTF(("gtmpscinit\n"));
1400 gtmpscinit(sc);
1401 gtmpsccninit_done = 1;
1402 cp = gtmpsc_earlybuf;
1403 strcpy(gtmpsc_earlybuf, "\r\nMPSC Lives!\r\n");
1404 for (i=0; i < sizeof(gtmpsc_earlybuf); i++) {
1405 c = *cp++;
1406 if (c == 0)
1407 break;
1408 gtmpsc_common_putc(unit, c);
1409 }
1410 DPRINTF(("switching cn_tab\n"));
1411 gtmpsc_consdev.cn_dev = makedev(0, unit);
1412 cn_tab = >mpsc_consdev;
1413 DPRINTF(("switched cn_tab!\n"));
1414 return 0;
1415 }
1416
1417 /*
1418 * gtmpsc_common_pollc - non-blocking console read
1419 *
1420 * if there is an RX char, return it in *cp
1421 * set *statp if Break detected
1422 *
1423 * assumes we are called at ipl >= IPL_SERIAL
1424 *
1425 * return 1 if there is RX data
1426 * otherwise return 0
1427 */
1428 STATIC int
1429 gtmpsc_common_pollc(unsigned int unit, char *cp, int *statp)
1430 {
1431 struct gtmpsc_softc *sc = gtmpsc_scp[unit];
1432 gtmpsc_pollrx_t *vrxp;
1433 unsigned int ix;
1434 unsigned int cx;
1435 unsigned int nc;
1436
1437 *statp = GTMPSC_STAT_NONE;
1438 ix = sc->gtmpsc_poll_rxix;
1439 nc = sc->gtmpsc_nc;
1440 cx = sc->gtmpsc_cx;
1441 if (nc == 0) {
1442 unsigned int *csrp;
1443 unsigned int csr;
1444
1445 vrxp = &sc->gtmpsc_poll_sdmapage->rx[ix];
1446 csrp = &vrxp->rxdesc.sdma_csr;
1447 cx = 0;
1448
1449 GTMPSC_CACHE_INVALIDATE(csrp);
1450 csr = desc_read(csrp);
1451 if (csr & SDMA_CSR_RX_OWN)
1452 return 0;
1453 if (csr & SDMA_CSR_RX_BR)
1454 *statp = GTMPSC_STAT_BREAK;
1455 if (csr & SDMA_CSR_RX_ES)
1456 PRINTF(("mpsc 0 RX error, rxdesc csr 0x%x\n", csr));
1457
1458 nc = desc_read(&vrxp->rxdesc.sdma_cnt);
1459 nc &= SDMA_RX_CNT_BCNT_MASK;
1460 csr = SDMA_CSR_RX_L|SDMA_CSR_RX_F|SDMA_CSR_RX_OWN
1461 |SDMA_CSR_RX_EI;
1462 if (nc == 0) {
1463 if ((++ix) >= GTMPSC_NRXDESC)
1464 ix = 0;
1465 sc->gtmpsc_poll_rxix = ix;
1466 desc_write(csrp, csr);
1467 GTMPSC_CACHE_FLUSH(csrp);
1468 return 0;
1469 }
1470 bcopy(vrxp->rxbuf, sc->gtmpsc_rxbuf, nc);
1471 desc_write(csrp, csr);
1472 GTMPSC_CACHE_FLUSH(csrp);
1473 }
1474 gtmpsc_poll_pollc_cnt++;
1475 nc--;
1476 *cp = sc->gtmpsc_rxbuf[cx++];
1477 if (nc == 0) {
1478 if ((++ix) >= GTMPSC_NRXDESC)
1479 ix = 0;
1480 sc->gtmpsc_poll_rxix = ix;
1481 }
1482 sc->gtmpsc_cx = cx;
1483 sc->gtmpsc_nc = nc;
1484 return 1;
1485 }
1486
1487 /*
1488 * gtmpsc_common_getc - polled console read
1489 *
1490 * We copy data from the DMA buffers into a buffer in the softc
1491 * to reduce descriptor ownership turnaround time
1492 * MPSC can crater if it wraps descriptor rings,
1493 * which is asynchronous and throttled only by line speed.
1494 *
1495 * This code assumes the buffer PA==KVA
1496 * and assumes we are called at ipl >= IPL_SERIAL
1497 */
1498 STATIC int
1499 gtmpsc_common_getc(unsigned int unit)
1500 {
1501 struct gtmpsc_softc *sc = gtmpsc_scp[unit];
1502 gtmpsc_pollrx_t *vrxp;
1503 unsigned int ix;
1504 unsigned int cx;
1505 unsigned int nc;
1506 int c;
1507
1508 ix = sc->gtmpsc_poll_rxix;
1509 nc = sc->gtmpsc_nc;
1510 cx = sc->gtmpsc_cx;
1511 while (nc == 0) {
1512 unsigned int *csrp;
1513 unsigned int csr;
1514 unsigned int r;
1515
1516 vrxp = &sc->gtmpsc_poll_sdmapage->rx[ix];
1517 csrp = &vrxp->rxdesc.sdma_csr;
1518 cx = 0;
1519
1520 GTMPSC_CACHE_INVALIDATE(csrp);
1521 csr = desc_read(csrp);
1522 if (csr & SDMA_CSR_RX_OWN) {
1523 r = sc->gtmpsc_chr2 | GTMPSC_CHR2_CRD;
1524 GT_WRITE(sc, GTMPSC_U_CHRN(unit, 2), r);
1525 do {
1526
1527 gtmpsc_poll_getc_miss++;
1528 GTMPSC_CACHE_INVALIDATE(csrp);
1529 DELAY(50);
1530 csr = desc_read(csrp);
1531 } while (csr & SDMA_CSR_RX_OWN);
1532 }
1533 if (csr & SDMA_CSR_RX_ES)
1534 PRINTF(("mpsc 0 RX error, rxdesc csr 0x%x\n", csr));
1535
1536 nc = desc_read(&vrxp->rxdesc.sdma_cnt);
1537 nc &= SDMA_RX_CNT_BCNT_MASK;
1538 if (nc) {
1539 bcopy(vrxp->rxbuf, sc->gtmpsc_rxbuf, nc);
1540 } else {
1541 if ((++ix) >= GTMPSC_NRXDESC)
1542 ix = 0;
1543 sc->gtmpsc_poll_rxix = ix;
1544 }
1545 csr = SDMA_CSR_RX_L|SDMA_CSR_RX_F|SDMA_CSR_RX_OWN
1546 |SDMA_CSR_RX_EI;
1547 desc_write(csrp, csr);
1548 GTMPSC_CACHE_FLUSH(csrp);
1549 #ifdef KGDB
1550 if (unit == comkgdbport && gt_reva_gtmpsc_bug)
1551 GT_WRITE(sc, SDMA_ICAUSE, ~SDMA_INTR_RXBUF(unit));
1552 #endif
1553 }
1554 gtmpsc_poll_getc_cnt++;
1555 nc--;
1556 c = (int)sc->gtmpsc_rxbuf[cx++];
1557 if (nc == 0) {
1558 if ((++ix) >= GTMPSC_NRXDESC)
1559 ix = 0;
1560 sc->gtmpsc_poll_rxix = ix;
1561 }
1562 sc->gtmpsc_cx = cx;
1563 sc->gtmpsc_nc = nc;
1564 return c;
1565 }
1566
1567 /*
1568 * gtmpsc_common_putn - write a buffer into the hardware
1569 *
1570 * assumes we are called at ipl >= IPL_SERIAL
1571 */
1572 STATIC void
1573 gtmpsc_common_putn(struct gtmpsc_softc *sc)
1574
1575 {
1576 int unit = sc->gtmpsc_unit;
1577 int n;
1578 int kick;
1579 gtmpsc_polltx_t *vtxp;
1580 unsigned int *csrp;
1581 unsigned int csr;
1582 unsigned int ix;
1583 unsigned int sdcm;
1584
1585 kick = 0;
1586 for (ix = sc->gtmpsc_poll_txix; sc->sc_tbc;) {
1587 vtxp = &sc->gtmpsc_poll_sdmapage->tx[ix];
1588 csrp = &vtxp->txdesc.sdma_csr;
1589 GTMPSC_CACHE_INVALIDATE(csrp);
1590 csr = desc_read(csrp);
1591 if ((csr & SDMA_CSR_TX_OWN) != 0)
1592 break;
1593 n = sc->sc_tbc;
1594 if (n > GTMPSC_TXBUFSZ)
1595 n = GTMPSC_TXBUFSZ;
1596 bcopy(sc->sc_tba, vtxp->txbuf, n);
1597 csr = SDMA_CSR_TX_L | SDMA_CSR_TX_F
1598 | SDMA_CSR_TX_EI | SDMA_CSR_TX_OWN;
1599 desc_write(&vtxp->txdesc.sdma_cnt,
1600 (n << SDMA_TX_CNT_BCNT_SHIFT) | n);
1601 desc_write(csrp, csr);
1602 GTMPSC_CACHE_FLUSH(csrp);
1603 sc->sc_tbc -= n;
1604 sc->sc_tba += n;
1605 gtmpsc_poll_putn_cnt += n;
1606 sc->cnt_tx_to_sdma += n;
1607 kick = 1;
1608
1609 if (++ix >= GTMPSC_NTXDESC)
1610 ix = 0;
1611 }
1612 if (kick) {
1613 sc->gtmpsc_poll_txix = ix;
1614
1615 /*
1616 * now kick some SDMA
1617 */
1618 sdcm = GT_READ(sc, SDMA_U_SDCM(unit));
1619
1620 if ((sdcm & SDMA_SDCM_TXD) == 0) {
1621 GT_WRITE(sc, SDMA_U_SDCM(unit), SDMA_SDCM_TXD);
1622 }
1623 }
1624 }
1625
1626 /*
1627 * gtmpsc_common_putc - polled console putc
1628 *
1629 * assumes we are called at ipl >= IPL_SERIAL
1630 */
1631 STATIC void
1632 gtmpsc_common_putc(unsigned int unit, unsigned char c)
1633 {
1634 struct gtmpsc_softc *sc = gtmpsc_scp[unit];
1635 gtmpsc_polltx_t *vtxp;
1636 unsigned int *csrp;
1637 unsigned int csr;
1638 unsigned int ix;
1639 unsigned int nix;
1640
1641 DPRINTF(("gtmpsc_common_putc(%d, '%c'): cur=%#x, first=%#x", unit, c,
1642 GT_READ(sc, SDMA_U_SCTDP(unit)), /* current */
1643 GT_READ(sc, SDMA_U_SFTDP(unit)))); /* first */
1644 ix = sc->gtmpsc_poll_txix;
1645 nix = ix + 1;
1646 if (nix >= GTMPSC_NTXDESC)
1647 nix = 0;
1648 sc->gtmpsc_poll_txix = nix;
1649 vtxp = &sc->gtmpsc_poll_sdmapage->tx[ix];
1650 csrp = &vtxp->txdesc.sdma_csr;
1651
1652
1653 for (;;) {
1654 GTMPSC_CACHE_INVALIDATE(csrp);
1655 csr = desc_read(csrp);
1656 if ((csr & SDMA_CSR_TX_OWN) == 0)
1657 break;
1658 gtmpsc_poll_putc_miss++;
1659 DELAY(40);
1660 DPRINTF(("."));
1661 }
1662 if (csr & SDMA_CSR_TX_ES)
1663 PRINTF(("mpsc %d TX error, txdesc csr 0x%x\n", unit, csr));
1664
1665 gtmpsc_poll_putc_cnt++;
1666 vtxp->txbuf[0] = c;
1667 csr = SDMA_CSR_TX_L | SDMA_CSR_TX_F | SDMA_CSR_TX_EI | SDMA_CSR_TX_OWN;
1668 desc_write(&vtxp->txdesc.sdma_cnt, (1 << SDMA_TX_CNT_BCNT_SHIFT) | 1);
1669 desc_write(csrp, csr);
1670 GTMPSC_CACHE_FLUSH(csrp);
1671
1672 /*
1673 * now kick some SDMA
1674 */
1675 GT_WRITE(sc, SDMA_U_SDCM(unit), SDMA_SDCM_TXD);
1676 }
1677
1678
1679 STATIC void
1680 gtmpsc_poll(void *arg)
1681 {
1682 struct gtmpsc_softc *sc = (struct gtmpsc_softc *)arg;
1683 int kick;
1684 char ch;
1685 int stat;
1686 static struct timeval msg_time = {0,0};
1687 static struct timeval cur_time;
1688 static int fifo_full = 0;
1689
1690 kick = 0;
1691 while (gtmpsc_common_pollc(sc->gtmpsc_unit, &ch, &stat)) {
1692 #ifdef DDB
1693 if (stat)
1694 break;
1695 #endif
1696 ++sc->cnt_rx_from_sdma;
1697 if (sc->gtmpsc_rxfifo_navail != 0) {
1698 sc->gtmpsc_rxfifo[sc->gtmpsc_rxfifo_putix++] = ch;
1699 if (sc->gtmpsc_rxfifo_putix == GTMPSC_RXFIFOSZ)
1700 sc->gtmpsc_rxfifo_putix = 0;
1701 atomic_add(&sc->gtmpsc_rxfifo_navail, -1);
1702 ++sc->cnt_rx_to_fifo;
1703 fifo_full = 0;
1704 kick = 1;
1705 } else {
1706 if (fifo_full == 0) {
1707 fifo_full = 1;
1708 microtime(&cur_time);
1709 if (cur_time.tv_sec - msg_time.tv_sec >= 5) {
1710 /* Only do this once in 5 sec */
1711 msg_time = cur_time;
1712 printf("mpsc%d: input FIFO full, "
1713 "dropping incoming characters\n",
1714 sc->gtmpsc_unit);
1715 }
1716 }
1717 }
1718 }
1719 #ifdef DDB
1720 if (stat) {
1721 if (cn_tab == >mpsc_consdev) {
1722 Debugger();
1723 }
1724 }
1725 #endif
1726 if (kick)
1727 softintr_schedule(sc->sc_si);
1728 }
1729
1730 #ifdef KGDB
1731 /* ARGSUSED */
1732 STATIC int
1733 gtmpsc_kgdb_getc(arg)
1734 void *arg;
1735 {
1736
1737 return (gtmpsc_common_getc(comkgdbport));
1738 }
1739
1740 /* ARGSUSED */
1741 STATIC void
1742 gtmpsc_kgdb_putc(arg, c)
1743 void *arg;
1744 int c;
1745 {
1746
1747 return (gtmpsc_common_putc(comkgdbport, c));
1748 }
1749
1750 STATIC void
1751 gtmpsc_kgdb_poll(void *arg)
1752 {
1753 struct gtmpsc_softc *sc = (struct gtmpsc_softc *)arg;
1754 int s;
1755 char c;
1756 int brk;
1757
1758 s = splserial();
1759 if (kgdb_recover == 0) { /* gdb is not currently talking to its agent */
1760 while (gtmpsc_common_pollc(sc->gtmpsc_unit, &c, &brk)) {
1761 if (c == CTRL('c'))
1762 brk = GTMPSC_STAT_BREAK;
1763 if (brk == GTMPSC_STAT_BREAK)
1764 break;
1765 }
1766 if (brk == GTMPSC_STAT_BREAK) {
1767 if (kgdb_break_immediate)
1768 breakpoint();
1769 else {
1770 printf("connecting to kgdb\n");
1771 kgdb_connect(1);
1772 }
1773 }
1774 }
1775 splx(s);
1776 }
1777
1778 #endif /* KGDB */
1779
1780 #if 0
1781 void
1782 gtmpsc_printf(const char *fmt, ...)
1783 {
1784 struct consdev *ocd;
1785 int s;
1786 va_list ap;
1787
1788 s = splserial();
1789 ocd = cn_tab;
1790 cn_tab = &constab[0];
1791 va_start(ap, fmt);
1792 printf(fmt, ap);
1793 va_end(ap);
1794 cn_tab = ocd;
1795 splx(s);
1796 }
1797 #endif
1798
1799 void
1800 gtmpsc_mem_printf(const char *fmt, ...)
1801 {
1802 va_list ap;
1803 static unsigned char *p = gtmpsc_print_buf;
1804
1805 if (p >= >mpsc_print_buf[GTMPSC_PRINT_BUF_SIZE - 128]) {
1806 bzero(gtmpsc_print_buf, GTMPSC_PRINT_BUF_SIZE);
1807 p = gtmpsc_print_buf;
1808 }
1809 va_start(ap, fmt);
1810 p += vsprintf(p, fmt, ap);
1811 va_end(ap);
1812 }
1813
1814 void
1815 gtmpsc_shutdownhook(void *arg)
1816 {
1817 gtmpsc_softc_t *sc = (gtmpsc_softc_t *)arg;
1818
1819 gtmpsc_txflush(sc);
1820 }
1821
1822 void
1823 gtmpsccnhalt(dev_t dev)
1824 {
1825 unsigned int unit;
1826 u_int32_t r;
1827
1828 for (unit = 0; unit < GTMPSC_NCHAN; unit++) {
1829 gtmpsc_softc_t *sc = gtmpsc_scp[unit];
1830 if (sc == NULL)
1831 continue;
1832
1833 /*
1834 * flush TX buffers
1835 */
1836 gtmpsc_txflush(sc);
1837
1838 /*
1839 * stop MPSC unit RX
1840 */
1841 r = GT_READ(sc, GTMPSC_U_CHRN(unit, 2));
1842 r &= ~GTMPSC_CHR2_EH;
1843 r |= GTMPSC_CHR2_RXABORT;
1844 GT_WRITE(sc, GTMPSC_U_CHRN(unit, 2), r);
1845
1846 DELAY(GTMPSC_RESET_DELAY);
1847
1848 /*
1849 * abort SDMA RX for MPSC unit
1850 */
1851 GT_WRITE(sc, SDMA_U_SDCM(unit), SDMA_SDCM_AR);
1852 }
1853 }
1854
1855 void
1856 gtmpsc_puts(char *str)
1857 {
1858 char c;
1859
1860 if (str == NULL)
1861 return;
1862 while ((c = *str++) != 0)
1863 gtmpsccnputc(0, c);
1864 }
1865