Home | History | Annotate | Line # | Download | only in ixm1200
ixpcom_ixm.c revision 1.2.2.3
      1  1.2.2.3  jdolecek /*	$NetBSD: ixpcom_ixm.c,v 1.2.2.3 2002/10/10 18:32:27 jdolecek Exp $ */
      2  1.2.2.2  jdolecek /*
      3  1.2.2.2  jdolecek  * Copyright (c) 2002
      4  1.2.2.2  jdolecek  *	Ichiro FUKUHARA <ichiro (at) ichiro.org>.
      5  1.2.2.2  jdolecek  * All rights reserved.
      6  1.2.2.2  jdolecek  *
      7  1.2.2.2  jdolecek  * Redistribution and use in source and binary forms, with or without
      8  1.2.2.2  jdolecek  * modification, are permitted provided that the following conditions
      9  1.2.2.2  jdolecek  * are met:
     10  1.2.2.2  jdolecek  * 1. Redistributions of source code must retain the above copyright
     11  1.2.2.2  jdolecek  *    notice, this list of conditions and the following disclaimer.
     12  1.2.2.2  jdolecek  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2.2.2  jdolecek  *    notice, this list of conditions and the following disclaimer in the
     14  1.2.2.2  jdolecek  *    documentation and/or other materials provided with the distribution.
     15  1.2.2.2  jdolecek  * 3. All advertising materials mentioning features or use of this software
     16  1.2.2.2  jdolecek  *    must display the following acknowledgement:
     17  1.2.2.2  jdolecek  *	This product includes software developed by Ichiro FUKUHARA.
     18  1.2.2.2  jdolecek  * 4. The name of the company nor the name of the author may be used to
     19  1.2.2.2  jdolecek  *    endorse or promote products derived from this software without specific
     20  1.2.2.2  jdolecek  *    prior written permission.
     21  1.2.2.2  jdolecek  *
     22  1.2.2.2  jdolecek  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
     23  1.2.2.2  jdolecek  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  1.2.2.2  jdolecek  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  1.2.2.2  jdolecek  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
     26  1.2.2.2  jdolecek  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  1.2.2.2  jdolecek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  1.2.2.2  jdolecek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  1.2.2.2  jdolecek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  1.2.2.2  jdolecek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  1.2.2.2  jdolecek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  1.2.2.2  jdolecek  * SUCH DAMAGE.
     33  1.2.2.2  jdolecek  */
     34  1.2.2.2  jdolecek 
     35  1.2.2.2  jdolecek /* Front-end of ixpcom */
     36  1.2.2.2  jdolecek 
     37  1.2.2.2  jdolecek #include <sys/types.h>
     38  1.2.2.2  jdolecek #include <sys/device.h>
     39  1.2.2.2  jdolecek #include <sys/systm.h>
     40  1.2.2.2  jdolecek #include <sys/param.h>
     41  1.2.2.2  jdolecek #include <sys/malloc.h>
     42  1.2.2.2  jdolecek 
     43  1.2.2.2  jdolecek #include <sys/termios.h>
     44  1.2.2.2  jdolecek 
     45  1.2.2.2  jdolecek #include <machine/intr.h>
     46  1.2.2.2  jdolecek #include <machine/bus.h>
     47  1.2.2.2  jdolecek 
     48  1.2.2.2  jdolecek #include <arm/ixp12x0/ixp12x0_comreg.h>
     49  1.2.2.2  jdolecek #include <arm/ixp12x0/ixp12x0_comvar.h>
     50  1.2.2.2  jdolecek #include <arm/ixp12x0/ixp12x0reg.h>
     51  1.2.2.2  jdolecek #include <arm/ixp12x0/ixp12x0var.h>
     52  1.2.2.2  jdolecek #include <arm/ixp12x0/ixpsipvar.h>
     53  1.2.2.2  jdolecek 
     54  1.2.2.2  jdolecek #include <evbarm/ixm1200/ixpcom_ixmvar.h>
     55  1.2.2.2  jdolecek 
     56  1.2.2.2  jdolecek static int	ixpcom_ixm_match(struct device *, struct cfdata *, void *);
     57  1.2.2.2  jdolecek static void	ixpcom_ixm_attach(struct device *, struct device *, void *);
     58  1.2.2.2  jdolecek 
     59  1.2.2.3  jdolecek CFATTACH_DECL(ixpcom_ixm, sizeof(struct ixpcom_softc),
     60  1.2.2.3  jdolecek     ixpcom_ixm_match, ixpcom_ixm_attach, NULL, NULL);
     61  1.2.2.2  jdolecek 
     62  1.2.2.2  jdolecek static int
     63  1.2.2.2  jdolecek ixpcom_ixm_match(parent, match, aux)
     64  1.2.2.2  jdolecek 	struct device *parent;
     65  1.2.2.2  jdolecek 	struct cfdata *match;
     66  1.2.2.2  jdolecek 	void *aux;
     67  1.2.2.2  jdolecek {
     68  1.2.2.3  jdolecek 	if (strcmp(match->cf_name, "ixpcom") == 0)
     69  1.2.2.2  jdolecek 		return 1;
     70  1.2.2.2  jdolecek 	return 0;
     71  1.2.2.2  jdolecek }
     72  1.2.2.2  jdolecek 
     73  1.2.2.2  jdolecek static void
     74  1.2.2.2  jdolecek ixpcom_ixm_attach(parent, self, aux)
     75  1.2.2.2  jdolecek 	struct device *parent;
     76  1.2.2.2  jdolecek 	struct device *self;
     77  1.2.2.2  jdolecek 	void *aux;
     78  1.2.2.2  jdolecek {
     79  1.2.2.2  jdolecek 	struct ixpcom_ixm_softc *isc = (struct ixpcom_ixm_softc *)self;
     80  1.2.2.2  jdolecek 	struct ixpcom_softc *sc = &isc->sc_ixpcom;
     81  1.2.2.2  jdolecek 	struct ixpsip_attach_args *sa = aux;
     82  1.2.2.2  jdolecek 
     83  1.2.2.2  jdolecek 	isc->sc_iot = sa->sa_iot;
     84  1.2.2.2  jdolecek 	sc->sc_iot = sa->sa_iot;
     85  1.2.2.2  jdolecek 	sc->sc_baseaddr = sa->sa_addr;
     86  1.2.2.2  jdolecek 
     87  1.2.2.2  jdolecek 	printf("\n");
     88  1.2.2.2  jdolecek 
     89  1.2.2.2  jdolecek 	if (bus_space_map(sa->sa_iot, sa->sa_addr, sa->sa_size, 0,
     90  1.2.2.2  jdolecek 			 &sc->sc_ioh)) {
     91  1.2.2.2  jdolecek 		printf("%s: unable to map device\n", sc->sc_dev.dv_xname);
     92  1.2.2.2  jdolecek 		return;
     93  1.2.2.2  jdolecek 	}
     94  1.2.2.2  jdolecek 
     95  1.2.2.2  jdolecek 	printf("%s: IXP12x0 UART\n", sc->sc_dev.dv_xname);
     96  1.2.2.2  jdolecek 
     97  1.2.2.2  jdolecek 	ixpcom_attach_subr(sc);
     98  1.2.2.2  jdolecek 
     99  1.2.2.2  jdolecek #ifdef POLLING_COM
    100  1.2.2.2  jdolecek 	{ void* d; d = d = ixpcomintr; }
    101  1.2.2.2  jdolecek #else
    102  1.2.2.2  jdolecek 	ixp12x0_intr_establish(IXP12X0_INTR_UART, IPL_SERIAL, ixpcomintr, sc);
    103  1.2.2.2  jdolecek #endif
    104  1.2.2.2  jdolecek }
    105