Home | History | Annotate | Line # | Download | only in tx
tx39uart.c revision 1.1
      1 /*	$NetBSD: tx39uart.c,v 1.1 1999/11/20 19:56:38 uch Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1999, by UCHIYAMA Yasushi
      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. The name of the developer may NOT be used to endorse or promote products
     13  *    derived from this software without specific prior written permission.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  * SUCH DAMAGE.
     26  *
     27  */
     28 #include "opt_tx39_debug.h"
     29 #include "opt_tx39uartdebug.h"
     30 
     31 #include <sys/param.h>
     32 #include <sys/systm.h>
     33 #include <sys/device.h>
     34 
     35 #include <machine/bus.h>
     36 #include <machine/intr.h>
     37 
     38 #include <hpcmips/tx/tx39var.h>
     39 #include <hpcmips/tx/tx39uartvar.h>
     40 
     41 #include "locators.h"
     42 
     43 int	tx39uart_match __P((struct device*, struct cfdata*, void*));
     44 void	tx39uart_attach __P((struct device*, struct device*, void*));
     45 int	tx39uart_print __P((void*, const char*));
     46 int	tx39uart_search __P((struct device*, struct cfdata*, void*));
     47 
     48 struct tx39uart_softc {
     49 	struct	device sc_dev;
     50 	tx_chipset_tag_t sc_tc;
     51 	int sc_enabled;
     52 };
     53 
     54 struct cfattach tx39uart_ca = {
     55 	sizeof(struct tx39uart_softc), tx39uart_match, tx39uart_attach
     56 };
     57 
     58 int
     59 tx39uart_match(parent, cf, aux)
     60 	struct device *parent;
     61 	struct cfdata *cf;
     62 	void *aux;
     63 {
     64 	return 1;
     65 }
     66 
     67 void
     68 tx39uart_attach(parent, self, aux)
     69 	struct device *parent;
     70 	struct device *self;
     71 	void *aux;
     72 {
     73 	struct txsim_attach_args *ta = aux;
     74 	struct tx39uart_softc *sc = (void*)self;
     75 	tx_chipset_tag_t tc;
     76 
     77 	printf("\n");
     78 	sc->sc_tc = tc = ta->ta_tc;
     79 
     80 	config_search(tx39uart_search, self, tx39uart_print);
     81 }
     82 
     83 int
     84 tx39uart_search(parent, cf, aux)
     85 	struct device *parent;
     86 	struct cfdata *cf;
     87 	void *aux;
     88 {
     89 	struct tx39uart_softc *sc = (void*)parent;
     90 	struct tx39uart_attach_args ua;
     91 
     92 	ua.ua_tc	= sc->sc_tc;
     93 	ua.ua_slot	= cf->cf_loc[TXCOMIFCF_SLOT];
     94 
     95 	if (ua.ua_slot == TXCOMIFCF_SLOT_DEFAULT) {
     96 		printf("tx39uart_search: wildcarded slot, skipping\n");
     97 		return 0;
     98 	}
     99 
    100 	if (!(sc->sc_enabled & (1 << ua.ua_slot)) && /* not attached slot */
    101 	    (*cf->cf_attach->ca_match)(parent, cf, &ua)) {
    102 		config_attach(parent, cf, &ua, tx39uart_print);
    103 		sc->sc_enabled |= (1 << ua.ua_slot);
    104 	}
    105 
    106 	return 0;
    107 }
    108 
    109 int
    110 tx39uart_print(aux, pnp)
    111 	void *aux;
    112 	const char *pnp;
    113 {
    114 	return pnp ? QUIET : UNCONF;
    115 }
    116