Home | History | Annotate | Line # | Download | only in dev
com_hpcio.c revision 1.2.2.4
      1  1.2.2.4  jdolecek /*	$NetBSD: com_hpcio.c,v 1.2.2.4 2002/10/10 18:32:54 jdolecek Exp $	*/
      2  1.2.2.2   thorpej 
      3  1.2.2.2   thorpej /*-
      4  1.2.2.2   thorpej  * Copyright (c) 2002 TAKEMRUA Shin. All rights reserved.
      5  1.2.2.2   thorpej  *
      6  1.2.2.2   thorpej  * Redistribution and use in source and binary forms, with or without
      7  1.2.2.2   thorpej  * modification, are permitted provided that the following conditions
      8  1.2.2.2   thorpej  * are met:
      9  1.2.2.2   thorpej  * 1. Redistributions of source code must retain the above copyright
     10  1.2.2.2   thorpej  *    notice, this list of conditions and the following disclaimer.
     11  1.2.2.2   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.2.2.2   thorpej  *    notice, this list of conditions and the following disclaimer in the
     13  1.2.2.2   thorpej  *    documentation and/or other materials provided with the distribution.
     14  1.2.2.2   thorpej  * 3. Neither the name of the project nor the names of its contributors
     15  1.2.2.2   thorpej  *    may be used to endorse or promote products derived from this software
     16  1.2.2.2   thorpej  *    without specific prior written permission.
     17  1.2.2.2   thorpej  *
     18  1.2.2.2   thorpej  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     19  1.2.2.2   thorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  1.2.2.2   thorpej  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  1.2.2.2   thorpej  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     22  1.2.2.2   thorpej  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  1.2.2.2   thorpej  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24  1.2.2.2   thorpej  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  1.2.2.2   thorpej  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  1.2.2.2   thorpej  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  1.2.2.2   thorpej  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  1.2.2.2   thorpej  * SUCH DAMAGE.
     29  1.2.2.2   thorpej  *
     30  1.2.2.2   thorpej  */
     31  1.2.2.2   thorpej 
     32  1.2.2.2   thorpej #include "opt_kgdb.h"
     33  1.2.2.2   thorpej 
     34  1.2.2.2   thorpej #include <sys/param.h>
     35  1.2.2.2   thorpej #include <sys/systm.h>
     36  1.2.2.2   thorpej #include <sys/device.h>
     37  1.2.2.2   thorpej #include <sys/reboot.h>
     38  1.2.2.2   thorpej #include <sys/termios.h>
     39  1.2.2.2   thorpej 
     40  1.2.2.2   thorpej #include <machine/intr.h>
     41  1.2.2.2   thorpej #include <machine/bus.h>
     42  1.2.2.2   thorpej #include <machine/platid.h>
     43  1.2.2.2   thorpej #include <machine/platid_mask.h>
     44  1.2.2.2   thorpej 
     45  1.2.2.2   thorpej #include <hpcmips/dev/com_hpciovar.h>
     46  1.2.2.2   thorpej 
     47  1.2.2.2   thorpej #include <dev/hpc/hpciovar.h>
     48  1.2.2.2   thorpej #include <dev/ic/comvar.h>
     49  1.2.2.2   thorpej #include <dev/ic/comreg.h>
     50  1.2.2.2   thorpej 
     51  1.2.2.2   thorpej #include "locators.h"
     52  1.2.2.2   thorpej 
     53  1.2.2.2   thorpej #define COM_HPCIODEBUG
     54  1.2.2.2   thorpej #ifdef COM_HPCIODEBUG
     55  1.2.2.2   thorpej int	com_hpcio_debug = 0;
     56  1.2.2.2   thorpej #define	DPRINTF(arg...) do { if (com_hpcio_debug) printf(arg); } while (0)
     57  1.2.2.2   thorpej #else
     58  1.2.2.2   thorpej #define	DPRINTF(arg...) do {} while (0)
     59  1.2.2.2   thorpej #endif
     60  1.2.2.2   thorpej 
     61  1.2.2.2   thorpej #define COM_HPCIO_BYTE_ALIGNMENT	0
     62  1.2.2.2   thorpej #define COM_HPCIO_HALFWORD_ALIGNMENT	1
     63  1.2.2.2   thorpej 
     64  1.2.2.2   thorpej struct com_hpcio_softc {
     65  1.2.2.2   thorpej 	struct com_softc	hsc_com;
     66  1.2.2.2   thorpej 	struct bus_space_tag	hsc_iot;
     67  1.2.2.2   thorpej 	struct hpcio_chip	*hsc_hc;
     68  1.2.2.2   thorpej };
     69  1.2.2.2   thorpej static struct bus_space_tag com_hpcio_cniotx;
     70  1.2.2.2   thorpej static bus_space_tag_t com_hpcio_cniot = &com_hpcio_cniotx;
     71  1.2.2.2   thorpej static int com_hpcio_cniobase;
     72  1.2.2.2   thorpej 
     73  1.2.2.2   thorpej static int com_hpcio_probe(struct device *, struct cfdata *, void *);
     74  1.2.2.2   thorpej static void com_hpcio_attach(struct device *, struct device *, void *);
     75  1.2.2.2   thorpej static int com_hpcio_common_probe(bus_space_tag_t, int, int *);
     76  1.2.2.2   thorpej void com_hpcio_iot_init(bus_space_tag_t iot, bus_space_tag_t base);
     77  1.2.2.2   thorpej bus_space_protos(bs_notimpl);
     78  1.2.2.2   thorpej bus_space_protos(bs_through);
     79  1.2.2.2   thorpej bus_space_protos(com_hpcio);
     80  1.2.2.2   thorpej 
     81  1.2.2.4  jdolecek CFATTACH_DECL(com_hpcio, sizeof(struct com_hpcio_softc),
     82  1.2.2.4  jdolecek     com_hpcio_probe, com_hpcio_attach, NULL, NULL);
     83  1.2.2.2   thorpej 
     84  1.2.2.2   thorpej struct bus_space_ops com_hpcio_bs_ops = {
     85  1.2.2.2   thorpej 	/* mapping/unmapping */
     86  1.2.2.2   thorpej 	bs_through_bs_map,
     87  1.2.2.2   thorpej 	bs_through_bs_unmap,
     88  1.2.2.2   thorpej 	bs_through_bs_subregion,
     89  1.2.2.2   thorpej 
     90  1.2.2.2   thorpej 	/* allocation/deallocation */
     91  1.2.2.2   thorpej 	bs_through_bs_alloc,
     92  1.2.2.2   thorpej 	bs_through_bs_free,
     93  1.2.2.2   thorpej 
     94  1.2.2.2   thorpej 	/* get kernel virtual address */
     95  1.2.2.2   thorpej 	bs_through_bs_vaddr, /* there is no linear mapping */
     96  1.2.2.2   thorpej 
     97  1.2.2.2   thorpej 	/* Mmap bus space for user */
     98  1.2.2.2   thorpej 	bs_through_bs_mmap,
     99  1.2.2.2   thorpej 
    100  1.2.2.2   thorpej 	/* barrier */
    101  1.2.2.2   thorpej 	bs_through_bs_barrier,
    102  1.2.2.2   thorpej 
    103  1.2.2.3  jdolecek 	/* probe */
    104  1.2.2.3  jdolecek 	bs_through_bs_peek,
    105  1.2.2.3  jdolecek 	bs_through_bs_poke,
    106  1.2.2.3  jdolecek 
    107  1.2.2.2   thorpej 	/* read (single) */
    108  1.2.2.2   thorpej 	com_hpcio_bs_r_1,
    109  1.2.2.2   thorpej 	bs_notimpl_bs_r_2,
    110  1.2.2.2   thorpej 	bs_notimpl_bs_r_4,
    111  1.2.2.2   thorpej 	bs_notimpl_bs_r_8,
    112  1.2.2.2   thorpej 
    113  1.2.2.2   thorpej 	/* read multiple */
    114  1.2.2.2   thorpej 	bs_notimpl_bs_rm_1,
    115  1.2.2.2   thorpej 	bs_notimpl_bs_rm_2,
    116  1.2.2.2   thorpej 	bs_notimpl_bs_rm_4,
    117  1.2.2.2   thorpej 	bs_notimpl_bs_rm_8,
    118  1.2.2.2   thorpej 
    119  1.2.2.2   thorpej 	/* read region */
    120  1.2.2.2   thorpej 	bs_notimpl_bs_rr_1,
    121  1.2.2.2   thorpej 	bs_notimpl_bs_rr_2,
    122  1.2.2.2   thorpej 	bs_notimpl_bs_rr_4,
    123  1.2.2.2   thorpej 	bs_notimpl_bs_rr_8,
    124  1.2.2.2   thorpej 
    125  1.2.2.2   thorpej 	/* write (single) */
    126  1.2.2.2   thorpej 	com_hpcio_bs_w_1,
    127  1.2.2.2   thorpej 	bs_notimpl_bs_w_2,
    128  1.2.2.2   thorpej 	bs_notimpl_bs_w_4,
    129  1.2.2.2   thorpej 	bs_notimpl_bs_w_8,
    130  1.2.2.2   thorpej 
    131  1.2.2.2   thorpej 	/* write multiple */
    132  1.2.2.2   thorpej 	com_hpcio_bs_wm_1,
    133  1.2.2.2   thorpej 	bs_notimpl_bs_wm_2,
    134  1.2.2.2   thorpej 	bs_notimpl_bs_wm_4,
    135  1.2.2.2   thorpej 	bs_notimpl_bs_wm_8,
    136  1.2.2.2   thorpej 
    137  1.2.2.2   thorpej 	/* write region */
    138  1.2.2.2   thorpej 	bs_notimpl_bs_wr_1,
    139  1.2.2.2   thorpej 	bs_notimpl_bs_wr_2,
    140  1.2.2.2   thorpej 	bs_notimpl_bs_wr_4,
    141  1.2.2.2   thorpej 	bs_notimpl_bs_wr_8,
    142  1.2.2.2   thorpej 
    143  1.2.2.2   thorpej #ifdef BUS_SPACE_HAS_REAL_STREAM_METHODS
    144  1.2.2.2   thorpej 	/* read stream (single) */
    145  1.2.2.2   thorpej 	bs_notimpl_bs_rs_1,
    146  1.2.2.2   thorpej 	bs_notimpl_bs_rs_2,
    147  1.2.2.2   thorpej 	bs_notimpl_bs_rs_4,
    148  1.2.2.2   thorpej 	bs_notimpl_bs_rs_8,
    149  1.2.2.2   thorpej 
    150  1.2.2.2   thorpej 	/* read multiple stream */
    151  1.2.2.2   thorpej 	bs_notimpl_bs_rms_1,
    152  1.2.2.2   thorpej 	bs_notimpl_bs_rms_2,
    153  1.2.2.2   thorpej 	bs_notimpl_bs_rms_4,
    154  1.2.2.2   thorpej 	bs_notimpl_bs_rms_8,
    155  1.2.2.2   thorpej 
    156  1.2.2.2   thorpej 	/* read region stream */
    157  1.2.2.2   thorpej 	bs_notimpl_bs_rrs_1,
    158  1.2.2.2   thorpej 	bs_notimpl_bs_rrs_2,
    159  1.2.2.2   thorpej 	bs_notimpl_bs_rrs_4,
    160  1.2.2.2   thorpej 	bs_notimpl_bs_rrs_8,
    161  1.2.2.2   thorpej 
    162  1.2.2.2   thorpej 	/* write stream (single) */
    163  1.2.2.2   thorpej 	bs_notimpl_bs_ws_1,
    164  1.2.2.2   thorpej 	bs_notimpl_bs_ws_2,
    165  1.2.2.2   thorpej 	bs_notimpl_bs_ws_4,
    166  1.2.2.2   thorpej 	bs_notimpl_bs_ws_8,
    167  1.2.2.2   thorpej 
    168  1.2.2.2   thorpej 	/* write multiple stream */
    169  1.2.2.2   thorpej 	bs_notimpl_bs_wms_1,
    170  1.2.2.2   thorpej 	bs_notimpl_bs_wms_2,
    171  1.2.2.2   thorpej 	bs_notimpl_bs_wms_4,
    172  1.2.2.2   thorpej 	bs_notimpl_bs_wms_8,
    173  1.2.2.2   thorpej 
    174  1.2.2.2   thorpej 	/* write region stream */
    175  1.2.2.2   thorpej 	bs_notimpl_bs_wrs_1,
    176  1.2.2.2   thorpej 	bs_notimpl_bs_wrs_2,
    177  1.2.2.2   thorpej 	bs_notimpl_bs_wrs_4,
    178  1.2.2.2   thorpej 	bs_notimpl_bs_wrs_8,
    179  1.2.2.2   thorpej #endif /* BUS_SPACE_HAS_REAL_STREAM_METHODS */
    180  1.2.2.2   thorpej 
    181  1.2.2.2   thorpej 	/* set multi */
    182  1.2.2.2   thorpej 	bs_notimpl_bs_sm_1,
    183  1.2.2.2   thorpej 	bs_notimpl_bs_sm_2,
    184  1.2.2.2   thorpej 	bs_notimpl_bs_sm_4,
    185  1.2.2.2   thorpej 	bs_notimpl_bs_sm_8,
    186  1.2.2.2   thorpej 
    187  1.2.2.2   thorpej 	/* set region */
    188  1.2.2.2   thorpej 	bs_notimpl_bs_sr_1,
    189  1.2.2.2   thorpej 	bs_notimpl_bs_sr_2,
    190  1.2.2.2   thorpej 	bs_notimpl_bs_sr_4,
    191  1.2.2.2   thorpej 	bs_notimpl_bs_sr_8,
    192  1.2.2.2   thorpej 
    193  1.2.2.2   thorpej 	/* copy */
    194  1.2.2.2   thorpej 	bs_notimpl_bs_c_1,
    195  1.2.2.2   thorpej 	bs_notimpl_bs_c_2,
    196  1.2.2.2   thorpej 	bs_notimpl_bs_c_4,
    197  1.2.2.2   thorpej 	bs_notimpl_bs_c_8,
    198  1.2.2.2   thorpej };
    199  1.2.2.2   thorpej 
    200  1.2.2.2   thorpej int
    201  1.2.2.2   thorpej com_hpcio_cndb_attach(bus_space_tag_t iot, int iobase, int rate,
    202  1.2.2.2   thorpej     int frequency, tcflag_t cflag, int kgdb)
    203  1.2.2.2   thorpej {
    204  1.2.2.2   thorpej 	int alignment;
    205  1.2.2.2   thorpej 
    206  1.2.2.2   thorpej 	DPRINTF("com_hpcio_cndb_attach()\n");
    207  1.2.2.2   thorpej 	if (!com_hpcio_common_probe(iot, iobase, &alignment)) {
    208  1.2.2.2   thorpej 		DPRINTF("com_hpcio_cndb_attach(): probe failed\n");
    209  1.2.2.2   thorpej 		return (ENOTTY);
    210  1.2.2.2   thorpej 	}
    211  1.2.2.2   thorpej 	if (alignment == COM_HPCIO_HALFWORD_ALIGNMENT) {
    212  1.2.2.2   thorpej 		DPRINTF("com_hpcio_cndb_attach(): half word aligned\n");
    213  1.2.2.2   thorpej 		com_hpcio_iot_init(&com_hpcio_cniotx, iot);
    214  1.2.2.2   thorpej 		com_hpcio_cniot = &com_hpcio_cniotx;
    215  1.2.2.2   thorpej 	} else {
    216  1.2.2.2   thorpej 		com_hpcio_cniot = iot;
    217  1.2.2.2   thorpej 	}
    218  1.2.2.2   thorpej 	com_hpcio_cniobase = iobase;
    219  1.2.2.2   thorpej 	DPRINTF("com_hpcio_cndb_attach(): probe succeeded\n");
    220  1.2.2.2   thorpej #ifdef KGDB
    221  1.2.2.2   thorpej 	if (kgdb)
    222  1.2.2.2   thorpej 		return (com_kgdb_attach(com_hpcio_cniot, iobase, rate,
    223  1.2.2.2   thorpej 		    frequency, cflag));
    224  1.2.2.2   thorpej 	else
    225  1.2.2.2   thorpej #endif
    226  1.2.2.2   thorpej 		return (comcnattach(com_hpcio_cniot, iobase, rate,
    227  1.2.2.2   thorpej 		    frequency, cflag));
    228  1.2.2.2   thorpej }
    229  1.2.2.2   thorpej 
    230  1.2.2.2   thorpej static int
    231  1.2.2.2   thorpej com_hpcio_common_probe(bus_space_tag_t iot, int iobase, int *alignment)
    232  1.2.2.2   thorpej {
    233  1.2.2.2   thorpej 	bus_space_handle_t ioh;
    234  1.2.2.2   thorpej 	static struct bus_space_tag tmpiot;
    235  1.2.2.2   thorpej 	int rv;
    236  1.2.2.2   thorpej 
    237  1.2.2.2   thorpej 	/*
    238  1.2.2.2   thorpej 	 * try byte aligned register
    239  1.2.2.2   thorpej 	 */
    240  1.2.2.2   thorpej 	*alignment = COM_HPCIO_BYTE_ALIGNMENT;
    241  1.2.2.2   thorpej 	if (bus_space_map(iot, iobase, 1, 0, &ioh))
    242  1.2.2.2   thorpej 		return 0;
    243  1.2.2.2   thorpej 	rv = comprobe1(iot, ioh);
    244  1.2.2.2   thorpej 	bus_space_unmap(iot, ioh, 1);
    245  1.2.2.2   thorpej 
    246  1.2.2.2   thorpej 	if (rv != 0)
    247  1.2.2.2   thorpej 		return (rv);
    248  1.2.2.2   thorpej 
    249  1.2.2.2   thorpej 	/*
    250  1.2.2.2   thorpej 	 * try half word aligned register
    251  1.2.2.2   thorpej 	 */
    252  1.2.2.2   thorpej 	*alignment = COM_HPCIO_HALFWORD_ALIGNMENT;
    253  1.2.2.2   thorpej 	com_hpcio_iot_init(&tmpiot, iot);
    254  1.2.2.2   thorpej 	if (bus_space_map(&tmpiot, iobase, 1, 0, &ioh))
    255  1.2.2.2   thorpej 		return 0;
    256  1.2.2.2   thorpej 	rv = comprobe1(&tmpiot, ioh);
    257  1.2.2.2   thorpej 	bus_space_unmap(&tmpiot, ioh, 1);
    258  1.2.2.2   thorpej 
    259  1.2.2.2   thorpej 	return (rv);
    260  1.2.2.2   thorpej }
    261  1.2.2.2   thorpej 
    262  1.2.2.2   thorpej static int
    263  1.2.2.2   thorpej com_hpcio_probe(struct device *parent, struct cfdata *cf, void *aux)
    264  1.2.2.2   thorpej {
    265  1.2.2.2   thorpej 	struct hpcio_attach_args *haa = aux;
    266  1.2.2.2   thorpej 	bus_space_tag_t iot = haa->haa_iot;
    267  1.2.2.2   thorpej 	int addr, alignment;
    268  1.2.2.2   thorpej 
    269  1.2.2.2   thorpej 	if (cf->cf_loc[HPCIOIFCF_PLATFORM] != HPCIOIFCF_PLATFORM_DEFAULT) {
    270  1.2.2.2   thorpej 		platid_mask_t mask;
    271  1.2.2.2   thorpej 
    272  1.2.2.2   thorpej 		mask = PLATID_DEREF(cf->cf_loc[HPCIOIFCF_PLATFORM]);
    273  1.2.2.2   thorpej 		if (!platid_match(&platid, &mask))
    274  1.2.2.2   thorpej 			return (0); /* platform id didn't match */
    275  1.2.2.2   thorpej 	}
    276  1.2.2.2   thorpej 
    277  1.2.2.2   thorpej 	if ((addr = cf->cf_loc[HPCIOIFCF_ADDR]) == HPCIOIFCF_ADDR_DEFAULT)
    278  1.2.2.2   thorpej 		return (0); /* address wasn't specified */
    279  1.2.2.2   thorpej 
    280  1.2.2.2   thorpej 	return com_hpcio_common_probe(iot, addr, &alignment);
    281  1.2.2.2   thorpej }
    282  1.2.2.2   thorpej 
    283  1.2.2.2   thorpej 
    284  1.2.2.2   thorpej static void
    285  1.2.2.2   thorpej com_hpcio_attach(struct device *parent, struct device *self, void *aux)
    286  1.2.2.2   thorpej {
    287  1.2.2.2   thorpej 	struct com_hpcio_softc *hsc = (void *)self;
    288  1.2.2.2   thorpej 	struct com_softc *sc = &hsc->hsc_com;
    289  1.2.2.2   thorpej 	struct hpcio_attach_args *haa = aux;
    290  1.2.2.2   thorpej 	bus_space_tag_t iot;
    291  1.2.2.2   thorpej 	bus_space_handle_t ioh;
    292  1.2.2.2   thorpej 	int addr, port, mode, alignment, *loc;
    293  1.2.2.2   thorpej 
    294  1.2.2.2   thorpej 	loc = sc->sc_dev.dv_cfdata->cf_loc;
    295  1.2.2.2   thorpej 	addr = loc[HPCIOIFCF_ADDR];
    296  1.2.2.2   thorpej 	printf(" addr %x", addr);
    297  1.2.2.2   thorpej 	if ((com_hpcio_cniot == haa->haa_iot ||
    298  1.2.2.2   thorpej 	    com_hpcio_cniot->bs_base == haa->haa_iot) &&
    299  1.2.2.2   thorpej 	    com_hpcio_cniobase == addr &&
    300  1.2.2.2   thorpej 	    com_is_console(com_hpcio_cniot, addr, 0)) {
    301  1.2.2.2   thorpej 		iot = com_hpcio_cniot;
    302  1.2.2.2   thorpej 		if (com_hpcio_cniot->bs_base == haa->haa_iot)
    303  1.2.2.2   thorpej 			printf(", half word aligned");
    304  1.2.2.2   thorpej 	} else {
    305  1.2.2.2   thorpej 		com_hpcio_common_probe(haa->haa_iot, addr, &alignment);
    306  1.2.2.2   thorpej 		if (alignment == COM_HPCIO_HALFWORD_ALIGNMENT) {
    307  1.2.2.2   thorpej 			printf(", half word aligned");
    308  1.2.2.2   thorpej 			iot = &hsc->hsc_iot;
    309  1.2.2.2   thorpej 			com_hpcio_iot_init(iot, haa->haa_iot);
    310  1.2.2.2   thorpej 		} else {
    311  1.2.2.2   thorpej 			iot = haa->haa_iot;
    312  1.2.2.2   thorpej 		}
    313  1.2.2.2   thorpej 	}
    314  1.2.2.2   thorpej 	if (bus_space_map(iot, addr, 1, 0, &ioh)) {
    315  1.2.2.2   thorpej 		printf(": can't map bus space\n");
    316  1.2.2.2   thorpej 		return;
    317  1.2.2.2   thorpej 	}
    318  1.2.2.2   thorpej 	sc->sc_iobase = addr;
    319  1.2.2.2   thorpej 	sc->sc_iot = iot;
    320  1.2.2.2   thorpej 	sc->sc_ioh = ioh;
    321  1.2.2.2   thorpej 
    322  1.2.2.2   thorpej 	sc->enable = NULL;
    323  1.2.2.2   thorpej 	sc->disable = NULL;
    324  1.2.2.2   thorpej 
    325  1.2.2.2   thorpej 	sc->sc_frequency = COM_FREQ;
    326  1.2.2.2   thorpej 	com_attach_subr(sc);
    327  1.2.2.2   thorpej 
    328  1.2.2.2   thorpej 	hsc->hsc_hc = (*haa->haa_getchip)(haa->haa_sc, loc[HPCIOIFCF_IOCHIP]);
    329  1.2.2.2   thorpej 	port = loc[HPCIOIFCF_PORT];
    330  1.2.2.2   thorpej 	mode = HPCIO_INTR_LEVEL | HPCIO_INTR_HIGH;
    331  1.2.2.2   thorpej 	hpcio_intr_establish(hsc->hsc_hc, port, mode, comintr, sc);
    332  1.2.2.2   thorpej }
    333  1.2.2.2   thorpej 
    334  1.2.2.2   thorpej /*
    335  1.2.2.2   thorpej  * bus stuff (registershalf word aligned)
    336  1.2.2.2   thorpej  */
    337  1.2.2.2   thorpej void
    338  1.2.2.2   thorpej com_hpcio_iot_init(bus_space_tag_t iot, bus_space_tag_t base)
    339  1.2.2.2   thorpej {
    340  1.2.2.2   thorpej 
    341  1.2.2.2   thorpej 	iot->bs_base = base;
    342  1.2.2.2   thorpej 	iot->bs_ops = com_hpcio_bs_ops; /* structure assignment */
    343  1.2.2.2   thorpej 	iot->bs_ops.bs_r_1 = com_hpcio_bs_r_1;
    344  1.2.2.2   thorpej 	iot->bs_ops.bs_w_1 = com_hpcio_bs_w_1;
    345  1.2.2.2   thorpej 	iot->bs_ops.bs_wm_1 = com_hpcio_bs_wm_1;
    346  1.2.2.2   thorpej }
    347  1.2.2.2   thorpej 
    348  1.2.2.2   thorpej u_int8_t
    349  1.2.2.2   thorpej com_hpcio_bs_r_1(bus_space_tag_t t, bus_space_handle_t bsh,
    350  1.2.2.2   thorpej     bus_size_t offset)
    351  1.2.2.2   thorpej {
    352  1.2.2.2   thorpej 	return bus_space_read_1(t->bs_base, bsh, offset * 2);
    353  1.2.2.2   thorpej }
    354  1.2.2.2   thorpej 
    355  1.2.2.2   thorpej void
    356  1.2.2.2   thorpej com_hpcio_bs_w_1(bus_space_tag_t t, bus_space_handle_t bsh,
    357  1.2.2.2   thorpej     bus_size_t offset, u_int8_t value)
    358  1.2.2.2   thorpej {
    359  1.2.2.2   thorpej 	bus_space_write_1(t->bs_base, bsh, offset * 2, value);
    360  1.2.2.2   thorpej }
    361  1.2.2.2   thorpej 
    362  1.2.2.2   thorpej void
    363  1.2.2.2   thorpej com_hpcio_bs_wm_1(bus_space_tag_t t, bus_space_handle_t bsh,
    364  1.2.2.2   thorpej     bus_size_t offset, const u_int8_t *addr, bus_size_t count)
    365  1.2.2.2   thorpej {
    366  1.2.2.2   thorpej 	bus_space_write_multi_1(t->bs_base, bsh, offset * 2, addr, count);
    367  1.2.2.2   thorpej }
    368