Home | History | Annotate | Line # | Download | only in jensenio
jensenio.c revision 1.3.2.2
      1  1.3.2.2  nathanw /* $NetBSD: jensenio.c,v 1.3.2.2 2002/10/18 02:34:15 nathanw Exp $ */
      2  1.3.2.2  nathanw 
      3  1.3.2.2  nathanw /*-
      4  1.3.2.2  nathanw  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
      5  1.3.2.2  nathanw  * All rights reserved.
      6  1.3.2.2  nathanw  *
      7  1.3.2.2  nathanw  * This code is derived from software contributed to The NetBSD Foundation
      8  1.3.2.2  nathanw  * by Jason R. Thorpe.
      9  1.3.2.2  nathanw  *
     10  1.3.2.2  nathanw  * Redistribution and use in source and binary forms, with or without
     11  1.3.2.2  nathanw  * modification, are permitted provided that the following conditions
     12  1.3.2.2  nathanw  * are met:
     13  1.3.2.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     14  1.3.2.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     15  1.3.2.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.3.2.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     17  1.3.2.2  nathanw  *    documentation and/or other materials provided with the distribution.
     18  1.3.2.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     19  1.3.2.2  nathanw  *    must display the following acknowledgement:
     20  1.3.2.2  nathanw  *	This product includes software developed by the NetBSD
     21  1.3.2.2  nathanw  *	Foundation, Inc. and its contributors.
     22  1.3.2.2  nathanw  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.3.2.2  nathanw  *    contributors may be used to endorse or promote products derived
     24  1.3.2.2  nathanw  *    from this software without specific prior written permission.
     25  1.3.2.2  nathanw  *
     26  1.3.2.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.3.2.2  nathanw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.3.2.2  nathanw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.3.2.2  nathanw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.3.2.2  nathanw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.3.2.2  nathanw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.3.2.2  nathanw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.3.2.2  nathanw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.3.2.2  nathanw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.3.2.2  nathanw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.3.2.2  nathanw  * POSSIBILITY OF SUCH DAMAGE.
     37  1.3.2.2  nathanw  */
     38  1.3.2.2  nathanw 
     39  1.3.2.2  nathanw /*
     40  1.3.2.2  nathanw  * Driver for the Jensen I/O bus.
     41  1.3.2.2  nathanw  *
     42  1.3.2.2  nathanw  * The Jensen I/O `bus' is comprised of two things:
     43  1.3.2.2  nathanw  *
     44  1.3.2.2  nathanw  *	- VLSI VL82C106 junk I/O chip
     45  1.3.2.2  nathanw  *	- Intel EISA bus interface
     46  1.3.2.2  nathanw  *
     47  1.3.2.2  nathanw  * Access to the 82C106 is different than to the rest of EISA space, even
     48  1.3.2.2  nathanw  * though it is a single address space.
     49  1.3.2.2  nathanw  */
     50  1.3.2.2  nathanw 
     51  1.3.2.2  nathanw #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     52  1.3.2.2  nathanw 
     53  1.3.2.2  nathanw __KERNEL_RCSID(0, "$NetBSD: jensenio.c,v 1.3.2.2 2002/10/18 02:34:15 nathanw Exp $");
     54  1.3.2.2  nathanw 
     55  1.3.2.2  nathanw #include <sys/param.h>
     56  1.3.2.2  nathanw #include <sys/systm.h>
     57  1.3.2.2  nathanw #include <sys/device.h>
     58  1.3.2.2  nathanw 
     59  1.3.2.2  nathanw #include <machine/autoconf.h>
     60  1.3.2.2  nathanw 
     61  1.3.2.2  nathanw #include <dev/eisa/eisavar.h>
     62  1.3.2.2  nathanw 
     63  1.3.2.2  nathanw #include <dev/isa/isareg.h>
     64  1.3.2.2  nathanw #include <dev/isa/isavar.h>
     65  1.3.2.2  nathanw 
     66  1.3.2.2  nathanw #include <alpha/jensenio/jensenioreg.h>
     67  1.3.2.2  nathanw #include <alpha/jensenio/jenseniovar.h>
     68  1.3.2.2  nathanw 
     69  1.3.2.2  nathanw #include "eisa.h"
     70  1.3.2.2  nathanw 
     71  1.3.2.2  nathanw /*
     72  1.3.2.2  nathanw  * The devices built-in to the VLSI VL82C106 junk I/O chip.
     73  1.3.2.2  nathanw  */
     74  1.3.2.2  nathanw const struct jensenio_dev {
     75  1.3.2.2  nathanw 	const char *jd_name;		/* device name */
     76  1.3.2.2  nathanw 	bus_addr_t jd_ioaddr;		/* I/O space address */
     77  1.3.2.2  nathanw 	int jd_irq[2];			/* Jensen IRQs */
     78  1.3.2.2  nathanw } jensenio_devs[] = {
     79  1.3.2.2  nathanw 	{ "pckbc",	IO_KBD,		{ 0x980, 0x990 } },
     80  1.3.2.2  nathanw 	{ "com",	IO_COM1,	{ 0x900, -1 } },
     81  1.3.2.2  nathanw 	{ "com",	IO_COM2,	{ 0x920, -1 } },
     82  1.3.2.2  nathanw 	{ "lpt",	IO_LPT3,	{ 1, -1 } },
     83  1.3.2.2  nathanw 	{ "mcclock",	0x170,		{ -1, -1 } },
     84  1.3.2.2  nathanw 	{ NULL,		0,		{ -1, -1 } },
     85  1.3.2.2  nathanw };
     86  1.3.2.2  nathanw 
     87  1.3.2.2  nathanw int	jensenio_match(struct device *, struct cfdata *, void *);
     88  1.3.2.2  nathanw void	jensenio_attach(struct device *, struct device *, void *);
     89  1.3.2.2  nathanw 
     90  1.3.2.2  nathanw CFATTACH_DECL(jensenio, sizeof(struct device),
     91  1.3.2.2  nathanw     jensenio_match, jensenio_attach, NULL, NULL);
     92  1.3.2.2  nathanw 
     93  1.3.2.2  nathanw int	jensenio_print(void *, const char *);
     94  1.3.2.2  nathanw int	jensenio_submatch(struct device *, struct cfdata *, void *);
     95  1.3.2.2  nathanw 
     96  1.3.2.2  nathanw int	jensenio_attached;
     97  1.3.2.2  nathanw 
     98  1.3.2.2  nathanw struct jensenio_config jensenio_configuration;
     99  1.3.2.2  nathanw 
    100  1.3.2.2  nathanw void	jensenio_eisa_attach_hook(struct device *, struct device *,
    101  1.3.2.2  nathanw 	    struct eisabus_attach_args *);
    102  1.3.2.2  nathanw int	jensenio_eisa_maxslots(void *);
    103  1.3.2.2  nathanw 
    104  1.3.2.2  nathanw void	jensenio_isa_attach_hook(struct device *, struct device *,
    105  1.3.2.2  nathanw 	    struct isabus_attach_args *);
    106  1.3.2.2  nathanw 
    107  1.3.2.2  nathanw /*
    108  1.3.2.2  nathanw  * Set up the Jensen's function pointers.
    109  1.3.2.2  nathanw  */
    110  1.3.2.2  nathanw void
    111  1.3.2.2  nathanw jensenio_init(struct jensenio_config *jcp, int mallocsafe)
    112  1.3.2.2  nathanw {
    113  1.3.2.2  nathanw 
    114  1.3.2.2  nathanw 	/*
    115  1.3.2.2  nathanw 	 * Initialize the Host Address Extension register to 0
    116  1.3.2.2  nathanw 	 * (the firmware should have already done this).  We will
    117  1.3.2.2  nathanw 	 * disallow mapping of any device who's address would
    118  1.3.2.2  nathanw 	 * require a non-0 HAE.  This should be safe as the final
    119  1.3.2.2  nathanw 	 * draft of the Jensen system specification states that
    120  1.3.2.2  nathanw 	 * applications should follow this little rule.
    121  1.3.2.2  nathanw 	 *
    122  1.3.2.2  nathanw 	 * There's a good reason for this; actually using HAE would
    123  1.3.2.2  nathanw 	 * require a mutex around *every* EISA cycle!  Gross!
    124  1.3.2.2  nathanw 	 */
    125  1.3.2.2  nathanw 	REGVAL(JENSEN_HAE) = 0;
    126  1.3.2.2  nathanw 	alpha_mb();
    127  1.3.2.2  nathanw 
    128  1.3.2.2  nathanw 	if (jcp->jc_initted == 0) {
    129  1.3.2.2  nathanw 		/* don't do these twice since they set up extents */
    130  1.3.2.2  nathanw 		jensenio_bus_io_init(&jcp->jc_eisa_iot, jcp);
    131  1.3.2.2  nathanw 		jensenio_bus_intio_init(&jcp->jc_internal_iot, jcp);
    132  1.3.2.2  nathanw 		jensenio_bus_mem_init(&jcp->jc_eisa_memt, jcp);
    133  1.3.2.2  nathanw 	}
    134  1.3.2.2  nathanw 	jcp->jc_mallocsafe = mallocsafe;
    135  1.3.2.2  nathanw }
    136  1.3.2.2  nathanw 
    137  1.3.2.2  nathanw int
    138  1.3.2.2  nathanw jensenio_match(struct device *parent, struct cfdata *cf, void *aux)
    139  1.3.2.2  nathanw {
    140  1.3.2.2  nathanw 	struct mainbus_attach_args *ma = aux;
    141  1.3.2.2  nathanw 
    142  1.3.2.2  nathanw 	if (strcmp(ma->ma_name, cf->cf_name) != 0)
    143  1.3.2.2  nathanw 		return (0);
    144  1.3.2.2  nathanw 
    145  1.3.2.2  nathanw 	/* There can be only one. */
    146  1.3.2.2  nathanw 	if (jensenio_attached)
    147  1.3.2.2  nathanw 		return (0);
    148  1.3.2.2  nathanw 
    149  1.3.2.2  nathanw 	return (1);
    150  1.3.2.2  nathanw }
    151  1.3.2.2  nathanw 
    152  1.3.2.2  nathanw void
    153  1.3.2.2  nathanw jensenio_attach(struct device *parent, struct device *self, void *aux)
    154  1.3.2.2  nathanw {
    155  1.3.2.2  nathanw 	struct jensenio_attach_args ja;
    156  1.3.2.2  nathanw 	struct jensenio_config *jcp = &jensenio_configuration;
    157  1.3.2.2  nathanw 	int i;
    158  1.3.2.2  nathanw 
    159  1.3.2.2  nathanw 	printf("\n");
    160  1.3.2.2  nathanw 
    161  1.3.2.2  nathanw 	jensenio_attached = 1;
    162  1.3.2.2  nathanw 
    163  1.3.2.2  nathanw 	/*
    164  1.3.2.2  nathanw 	 * Done once at console init time, but we might need to do
    165  1.3.2.2  nathanw 	 * additional work this time.
    166  1.3.2.2  nathanw 	 */
    167  1.3.2.2  nathanw 	jensenio_init(jcp, 1);
    168  1.3.2.2  nathanw 
    169  1.3.2.2  nathanw 	/*
    170  1.3.2.2  nathanw 	 * Initialize DMA.
    171  1.3.2.2  nathanw 	 */
    172  1.3.2.2  nathanw 	jensenio_dma_init(jcp);
    173  1.3.2.2  nathanw 
    174  1.3.2.2  nathanw 	/*
    175  1.3.2.2  nathanw 	 * Initialize interrupts.
    176  1.3.2.2  nathanw 	 */
    177  1.3.2.2  nathanw 	jensenio_intr_init(jcp);
    178  1.3.2.2  nathanw 
    179  1.3.2.2  nathanw 	/*
    180  1.3.2.2  nathanw 	 * First attach all of the built-in devices.
    181  1.3.2.2  nathanw 	 */
    182  1.3.2.2  nathanw 	for (i = 0; jensenio_devs[i].jd_name != NULL; i++) {
    183  1.3.2.2  nathanw 		ja.ja_name = jensenio_devs[i].jd_name;
    184  1.3.2.2  nathanw 		ja.ja_ioaddr = jensenio_devs[i].jd_ioaddr;
    185  1.3.2.2  nathanw 		ja.ja_irq[0] = jensenio_devs[i].jd_irq[0];
    186  1.3.2.2  nathanw 		ja.ja_irq[1] = jensenio_devs[i].jd_irq[1];
    187  1.3.2.2  nathanw 
    188  1.3.2.2  nathanw 		ja.ja_iot = &jcp->jc_internal_iot;
    189  1.3.2.2  nathanw 		ja.ja_ec = &jcp->jc_ec;
    190  1.3.2.2  nathanw 
    191  1.3.2.2  nathanw 		(void) config_found_sm(self, &ja, jensenio_print,
    192  1.3.2.2  nathanw 		    jensenio_submatch);
    193  1.3.2.2  nathanw 	}
    194  1.3.2.2  nathanw 
    195  1.3.2.2  nathanw 	/*
    196  1.3.2.2  nathanw 	 * Attach the EISA bus.
    197  1.3.2.2  nathanw 	 */
    198  1.3.2.2  nathanw 	jcp->jc_ec.ec_attach_hook = jensenio_eisa_attach_hook;
    199  1.3.2.2  nathanw 	jcp->jc_ec.ec_maxslots = jensenio_eisa_maxslots;
    200  1.3.2.2  nathanw 
    201  1.3.2.2  nathanw 	ja.ja_eisa.eba_busname = "eisa";
    202  1.3.2.2  nathanw 	ja.ja_eisa.eba_iot = &jcp->jc_eisa_iot;
    203  1.3.2.2  nathanw 	ja.ja_eisa.eba_memt = &jcp->jc_eisa_memt;
    204  1.3.2.2  nathanw 	ja.ja_eisa.eba_dmat = &jcp->jc_dmat_eisa;
    205  1.3.2.2  nathanw 	ja.ja_eisa.eba_ec = &jcp->jc_ec;
    206  1.3.2.2  nathanw 	(void) config_found(self, &ja.ja_eisa, jensenio_print);
    207  1.3.2.2  nathanw 
    208  1.3.2.2  nathanw 	/*
    209  1.3.2.2  nathanw 	 * Attach the ISA bus.
    210  1.3.2.2  nathanw 	 */
    211  1.3.2.2  nathanw 	jcp->jc_ic.ic_attach_hook = jensenio_isa_attach_hook;
    212  1.3.2.2  nathanw 
    213  1.3.2.2  nathanw 	ja.ja_isa.iba_busname = "isa";
    214  1.3.2.2  nathanw 	ja.ja_isa.iba_iot = &jcp->jc_eisa_iot;
    215  1.3.2.2  nathanw 	ja.ja_isa.iba_memt = &jcp->jc_eisa_memt;
    216  1.3.2.2  nathanw 	ja.ja_isa.iba_dmat = &jcp->jc_dmat_isa;
    217  1.3.2.2  nathanw 	ja.ja_isa.iba_ic = &jcp->jc_ic;
    218  1.3.2.2  nathanw 	(void) config_found(self, &ja.ja_isa, jensenio_print);
    219  1.3.2.2  nathanw }
    220  1.3.2.2  nathanw 
    221  1.3.2.2  nathanw int
    222  1.3.2.2  nathanw jensenio_submatch(struct device *parent, struct cfdata *cf, void *aux)
    223  1.3.2.2  nathanw {
    224  1.3.2.2  nathanw 	struct jensenio_attach_args *ja = aux;
    225  1.3.2.2  nathanw 
    226  1.3.2.2  nathanw 	/*
    227  1.3.2.2  nathanw 	 * Skip the locator song-and-dance if we're attaching the
    228  1.3.2.2  nathanw 	 * EISA or ISA layer.
    229  1.3.2.2  nathanw 	 */
    230  1.3.2.2  nathanw 	if (strcmp(ja->ja_name, "eisa") == 0 ||
    231  1.3.2.2  nathanw 	    strcmp(ja->ja_name, "isa") == 0)
    232  1.3.2.2  nathanw 		return (config_match(parent, cf, aux));
    233  1.3.2.2  nathanw 
    234  1.3.2.2  nathanw 	if (cf->cf_loc[JENSENIOCF_PORT] != JENSENIOCF_PORT_DEFAULT &&
    235  1.3.2.2  nathanw 	    cf->cf_loc[JENSENIOCF_PORT] != ja->ja_ioaddr)
    236  1.3.2.2  nathanw 		return (0);
    237  1.3.2.2  nathanw 
    238  1.3.2.2  nathanw 	return (config_match(parent, cf, aux));
    239  1.3.2.2  nathanw }
    240  1.3.2.2  nathanw 
    241  1.3.2.2  nathanw int
    242  1.3.2.2  nathanw jensenio_print(void *aux, const char *pnp)
    243  1.3.2.2  nathanw {
    244  1.3.2.2  nathanw 	struct jensenio_attach_args *ja = aux;
    245  1.3.2.2  nathanw 
    246  1.3.2.2  nathanw 	if (pnp != NULL)
    247  1.3.2.2  nathanw 		printf("%s at %s", ja->ja_name, pnp);
    248  1.3.2.2  nathanw 
    249  1.3.2.2  nathanw 	/*
    250  1.3.2.2  nathanw 	 * Skip the locator song-and-dance if we're attaching the
    251  1.3.2.2  nathanw 	 * EISA or ISA layer.
    252  1.3.2.2  nathanw 	 */
    253  1.3.2.2  nathanw 	if (strcmp(ja->ja_name, "eisa") != 0 &&
    254  1.3.2.2  nathanw 	    strcmp(ja->ja_name, "isa") != 0)
    255  1.3.2.2  nathanw 		printf(" port 0x%lx", ja->ja_ioaddr);
    256  1.3.2.2  nathanw 
    257  1.3.2.2  nathanw 	return (UNCONF);
    258  1.3.2.2  nathanw }
    259  1.3.2.2  nathanw 
    260  1.3.2.2  nathanw void
    261  1.3.2.2  nathanw jensenio_eisa_attach_hook(struct device *parent, struct device *self,
    262  1.3.2.2  nathanw     struct eisabus_attach_args *eba)
    263  1.3.2.2  nathanw {
    264  1.3.2.2  nathanw 
    265  1.3.2.2  nathanw #if NEISA > 0
    266  1.3.2.2  nathanw 	/*
    267  1.3.2.2  nathanw 	 * Jensen's EISA config info is sparse, and is mapped at a
    268  1.3.2.2  nathanw 	 * different location that on other EISA systems.
    269  1.3.2.2  nathanw 	 */
    270  1.3.2.2  nathanw 	eisa_config_stride = 0x200;
    271  1.3.2.2  nathanw 	eisa_config_addr = JENSEN_FEPROM1;
    272  1.3.2.2  nathanw 	eisa_init();
    273  1.3.2.2  nathanw #endif
    274  1.3.2.2  nathanw }
    275  1.3.2.2  nathanw 
    276  1.3.2.2  nathanw int
    277  1.3.2.2  nathanw jensenio_eisa_maxslots(void *v)
    278  1.3.2.2  nathanw {
    279  1.3.2.2  nathanw 
    280  1.3.2.2  nathanw 	return (16);	/* as good a number as any.  only 8, maybe? */
    281  1.3.2.2  nathanw }
    282  1.3.2.2  nathanw 
    283  1.3.2.2  nathanw void
    284  1.3.2.2  nathanw jensenio_isa_attach_hook(struct device *parent, struct device *self,
    285  1.3.2.2  nathanw     struct isabus_attach_args *iba)
    286  1.3.2.2  nathanw {
    287  1.3.2.2  nathanw 
    288  1.3.2.2  nathanw 	/* Nothing to do. */
    289  1.3.2.2  nathanw }
    290