Home | History | Annotate | Line # | Download | only in dev
zs_pcc.c revision 1.3.6.3
      1  1.3.6.3     skrll /*	$NetBSD: zs_pcc.c,v 1.3.6.3 2004/09/21 13:14:33 skrll Exp $	*/
      2      1.1  drochner 
      3      1.1  drochner /*
      4      1.1  drochner  * Copyright (c) 1997, 1999
      5      1.1  drochner  *	Matthias Drochner.  All rights reserved.
      6      1.1  drochner  *
      7      1.1  drochner  * Redistribution and use in source and binary forms, with or without
      8      1.1  drochner  * modification, are permitted provided that the following conditions
      9      1.1  drochner  * are met:
     10      1.1  drochner  * 1. Redistributions of source code must retain the above copyright
     11      1.1  drochner  *    notice, this list of conditions and the following disclaimer.
     12      1.1  drochner  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1  drochner  *    notice, this list of conditions and the following disclaimer in the
     14      1.1  drochner  *    documentation and/or other materials provided with the distribution.
     15      1.1  drochner  *
     16      1.1  drochner  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17      1.1  drochner  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18      1.1  drochner  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19      1.1  drochner  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20      1.1  drochner  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21      1.1  drochner  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22      1.1  drochner  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23      1.1  drochner  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24      1.1  drochner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25      1.1  drochner  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26      1.1  drochner  *
     27      1.1  drochner  */
     28      1.1  drochner 
     29  1.3.6.1     skrll #include <sys/cdefs.h>
     30  1.3.6.3     skrll __KERNEL_RCSID(0, "$NetBSD: zs_pcc.c,v 1.3.6.3 2004/09/21 13:14:33 skrll Exp $");
     31  1.3.6.1     skrll 
     32      1.1  drochner #include <sys/param.h>
     33      1.1  drochner #include <sys/systm.h>
     34      1.1  drochner #include <sys/proc.h>
     35      1.1  drochner #include <sys/device.h>
     36      1.1  drochner #include <sys/conf.h>
     37      1.1  drochner #include <sys/file.h>
     38      1.1  drochner #include <sys/ioctl.h>
     39      1.1  drochner #include <sys/tty.h>
     40      1.1  drochner #include <sys/time.h>
     41      1.1  drochner #include <sys/kernel.h>
     42      1.1  drochner #include <sys/syslog.h>
     43      1.1  drochner 
     44      1.1  drochner #include <dev/cons.h>
     45      1.1  drochner #include <dev/ic/z8530reg.h>
     46      1.1  drochner #include <machine/z8530var.h>
     47      1.1  drochner 
     48      1.1  drochner #include <machine/cpu.h>
     49      1.1  drochner #include <machine/autoconf.h>
     50      1.1  drochner 
     51      1.1  drochner #include <cesfic/cesfic/isr.h>
     52      1.1  drochner 
     53      1.1  drochner #include <cesfic/dev/zsvar.h>
     54      1.1  drochner 
     55      1.1  drochner extern void sic_enable_int __P((int, int, int, int, int));
     56      1.1  drochner 
     57      1.1  drochner static int	zsc_pcc_match  __P((struct device *, struct cfdata *, void *));
     58      1.1  drochner static void	zsc_pcc_attach __P((struct device *, struct device *, void *));
     59      1.1  drochner 
     60      1.1  drochner static char *zsbase;
     61      1.1  drochner 
     62      1.3   thorpej CFATTACH_DECL(zsc_pcc, sizeof(struct zsc_softc),
     63      1.3   thorpej     zsc_pcc_match, zsc_pcc_attach, NULL, NULL);
     64      1.1  drochner 
     65      1.1  drochner static int
     66      1.1  drochner zsc_pcc_match(parent, cf, aux)
     67      1.1  drochner 	struct device *parent;
     68      1.1  drochner 	struct cfdata *cf;
     69      1.1  drochner 	void *aux;
     70      1.1  drochner {
     71      1.1  drochner 	return (1);
     72      1.1  drochner }
     73      1.1  drochner 
     74      1.1  drochner static void
     75      1.1  drochner zsc_pcc_attach(parent, self, aux)
     76      1.1  drochner 	struct device *parent;
     77      1.1  drochner 	struct device *self;
     78      1.1  drochner 	void *aux;
     79      1.1  drochner {
     80      1.1  drochner 	struct zsc_softc *zsc = (void *) self;
     81      1.1  drochner 	static int didintr;
     82      1.1  drochner 
     83      1.1  drochner 	if (!zsbase)
     84  1.3.6.1     skrll 		mainbus_map(0x58000000, 0x10000, 0, (void *)&zsbase);
     85      1.1  drochner 
     86      1.1  drochner 	/* Do common parts of SCC configuration. */
     87      1.1  drochner 	zs_config(zsc, zsbase);
     88      1.1  drochner 
     89      1.1  drochner 	/*
     90      1.1  drochner 	 * Now safe to install interrupt handlers.  Note the arguments
     91      1.1  drochner 	 * to the interrupt handlers aren't used.  Note, we only do this
     92      1.1  drochner 	 * once since both SCCs interrupt at the same level and vector.
     93      1.1  drochner 	 */
     94      1.1  drochner 	if (didintr == 0) {
     95      1.1  drochner 		didintr = 1;
     96      1.1  drochner 		(void) isrlink(zshard, zsc, 4, ISRPRI_TTY);
     97      1.1  drochner 		sic_enable_int(19, 0, 4, 4, 0);
     98      1.1  drochner 	}
     99      1.1  drochner 
    100      1.1  drochner 	zs_write_reg(zsc->zsc_cs[0], 2, 0x18 + ZSHARD_PRI);
    101      1.1  drochner 	zs_write_reg(zsc->zsc_cs[0], 9, ZSWR9_MASTER_IE);
    102      1.1  drochner }
    103      1.1  drochner 
    104      1.1  drochner void
    105      1.1  drochner zs_cnattach(base)
    106      1.1  drochner 	void *base;
    107      1.1  drochner {
    108      1.1  drochner 	zsbase = base;
    109      1.1  drochner 
    110      1.1  drochner 	zs_cninit(zsbase);
    111      1.1  drochner }
    112