Home | History | Annotate | Line # | Download | only in dev
dio.c revision 1.23.2.6
      1  1.23.2.6     skrll /*	$NetBSD: dio.c,v 1.23.2.6 2005/11/10 13:56:08 skrll Exp $	*/
      2       1.1   thorpej 
      3       1.1   thorpej /*-
      4      1.11   thorpej  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
      5       1.1   thorpej  * All rights reserved.
      6       1.1   thorpej  *
      7       1.1   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1   thorpej  * by Jason R. Thorpe.
      9       1.1   thorpej  *
     10       1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     11       1.1   thorpej  * modification, are permitted provided that the following conditions
     12       1.1   thorpej  * are met:
     13       1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     14       1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     15       1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     17       1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     18       1.1   thorpej  * 3. All advertising materials mentioning features or use of this software
     19       1.1   thorpej  *    must display the following acknowledgement:
     20       1.1   thorpej  *        This product includes software developed by the NetBSD
     21       1.1   thorpej  *        Foundation, Inc. and its contributors.
     22       1.1   thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.1   thorpej  *    contributors may be used to endorse or promote products derived
     24       1.1   thorpej  *    from this software without specific prior written permission.
     25       1.1   thorpej  *
     26       1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.1   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.1   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.10       jtc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.10       jtc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.1   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.1   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.1   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.1   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.1   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.1   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1   thorpej  */
     38       1.1   thorpej 
     39       1.1   thorpej /*
     40       1.1   thorpej  * Autoconfiguration and mapping support for the DIO bus.
     41       1.1   thorpej  */
     42      1.16  gmcgarry 
     43      1.16  gmcgarry #include <sys/cdefs.h>
     44  1.23.2.6     skrll __KERNEL_RCSID(0, "$NetBSD: dio.c,v 1.23.2.6 2005/11/10 13:56:08 skrll Exp $");
     45       1.1   thorpej 
     46       1.7   thorpej #define	_HP300_INTR_H_PRIVATE
     47       1.7   thorpej 
     48       1.1   thorpej #include <sys/param.h>
     49       1.1   thorpej #include <sys/systm.h>
     50       1.1   thorpej #include <sys/kernel.h>
     51       1.1   thorpej #include <sys/device.h>
     52       1.1   thorpej 
     53      1.23  gmcgarry #include <machine/bus.h>
     54      1.23  gmcgarry 
     55      1.22   thorpej #include <uvm/uvm_extern.h>
     56      1.22   thorpej 
     57       1.1   thorpej #include <machine/autoconf.h>
     58       1.1   thorpej #include <machine/cpu.h>
     59       1.6   thorpej #include <machine/hp300spu.h>
     60       1.1   thorpej 
     61       1.7   thorpej #include <hp300/dev/dmavar.h>
     62       1.7   thorpej 
     63       1.1   thorpej #include <hp300/dev/dioreg.h>
     64       1.1   thorpej #include <hp300/dev/diovar.h>
     65       1.1   thorpej 
     66       1.1   thorpej #include <hp300/dev/diodevs.h>
     67       1.1   thorpej #include <hp300/dev/diodevs_data.h>
     68       1.1   thorpej 
     69      1.23  gmcgarry #include "locators.h"
     70      1.23  gmcgarry #define        diocf_scode             cf_loc[DIOCF_SCODE]
     71      1.23  gmcgarry 
     72  1.23.2.1     skrll struct dio_softc {
     73  1.23.2.1     skrll 	struct device sc_dev;
     74  1.23.2.1     skrll 	struct bus_space_tag sc_tag;
     75  1.23.2.1     skrll };
     76       1.1   thorpej 
     77  1.23.2.2     skrll static int	dio_scodesize(struct dio_attach_args *);
     78  1.23.2.2     skrll static const char *dio_devinfo(struct dio_attach_args *, char *, size_t);
     79       1.1   thorpej 
     80  1.23.2.2     skrll static int	diomatch(struct device *, struct cfdata *, void *);
     81  1.23.2.2     skrll static void	dioattach(struct device *, struct device *, void *);
     82  1.23.2.2     skrll static int	dioprint(void *, const char *);
     83  1.23.2.6     skrll static int	diosubmatch(struct device *, struct cfdata *, const int *, void *);
     84       1.1   thorpej 
     85  1.23.2.1     skrll CFATTACH_DECL(dio, sizeof(struct dio_softc),
     86      1.19   thorpej     diomatch, dioattach, NULL, NULL);
     87       1.1   thorpej 
     88  1.23.2.2     skrll static int
     89  1.23.2.2     skrll diomatch(struct device *parent, struct cfdata *match, void *aux)
     90       1.1   thorpej {
     91       1.1   thorpej 	static int dio_matched = 0;
     92       1.1   thorpej 
     93       1.1   thorpej 	/* Allow only one instance. */
     94       1.1   thorpej 	if (dio_matched)
     95       1.1   thorpej 		return (0);
     96       1.1   thorpej 
     97       1.1   thorpej 	dio_matched = 1;
     98       1.1   thorpej 	return (1);
     99       1.1   thorpej }
    100       1.1   thorpej 
    101  1.23.2.2     skrll static void
    102  1.23.2.2     skrll dioattach(struct device *parent, struct device *self, void *aux)
    103       1.1   thorpej {
    104  1.23.2.1     skrll 	struct dio_softc *sc = (struct dio_softc *)self;
    105       1.1   thorpej 	struct dio_attach_args da;
    106       1.1   thorpej 	caddr_t pa, va;
    107  1.23.2.1     skrll 	bus_space_tag_t bst = &sc->sc_tag;
    108      1.23  gmcgarry 	int scode, scmax, scodesize;
    109       1.1   thorpej 
    110      1.20  gmcgarry 	printf("\n");
    111      1.20  gmcgarry 
    112  1.23.2.1     skrll 	memset(bst, 0, sizeof(struct bus_space_tag));
    113  1.23.2.1     skrll 	bst->bustype = HP300_BUS_SPACE_DIO;
    114  1.23.2.1     skrll 
    115       1.1   thorpej 	scmax = DIO_SCMAX(machineid);
    116       1.1   thorpej 
    117       1.1   thorpej 	for (scode = 0; scode < scmax; ) {
    118       1.1   thorpej 		if (DIO_INHOLE(scode)) {
    119       1.1   thorpej 			scode++;
    120       1.1   thorpej 			continue;
    121       1.1   thorpej 		}
    122       1.1   thorpej 
    123       1.1   thorpej 		/*
    124       1.1   thorpej 		 * Temporarily map the space corresponding to
    125       1.1   thorpej 		 * the current select code unless:
    126       1.1   thorpej 		 */
    127       1.1   thorpej 		pa = dio_scodetopa(scode);
    128  1.23.2.1     skrll 		va = iomap(pa, PAGE_SIZE);
    129  1.23.2.1     skrll 		if (va == NULL) {
    130  1.23.2.1     skrll 			printf("%s: can't map scode %d\n",
    131  1.23.2.1     skrll 			    self->dv_xname, scode);
    132  1.23.2.1     skrll 			scode++;
    133  1.23.2.1     skrll 			continue;
    134       1.1   thorpej 		}
    135       1.1   thorpej 
    136       1.1   thorpej 		/* Check for hardware. */
    137       1.1   thorpej 		if (badaddr(va)) {
    138      1.23  gmcgarry 			iounmap(va, PAGE_SIZE);
    139       1.1   thorpej 			scode++;
    140       1.1   thorpej 			continue;
    141       1.1   thorpej 		}
    142       1.1   thorpej 
    143       1.1   thorpej 		/* Fill out attach args. */
    144      1.14  gmcgarry 		memset(&da, 0, sizeof(da));
    145  1.23.2.1     skrll 		da.da_bst = bst;
    146       1.1   thorpej 		da.da_scode = scode;
    147       1.1   thorpej 
    148      1.23  gmcgarry 		da.da_id = DIO_ID(va);
    149       1.1   thorpej 		if (DIO_ISFRAMEBUFFER(da.da_id))
    150       1.1   thorpej 			da.da_secid = DIO_SECID(va);
    151      1.23  gmcgarry 		da.da_addr = (bus_addr_t)dio_scodetopa(scode);
    152       1.1   thorpej 		da.da_size = DIO_SIZE(scode, va);
    153       1.1   thorpej 		scodesize = dio_scodesize(&da);
    154       1.1   thorpej 		if (DIO_ISDIO(scode))
    155       1.1   thorpej 			da.da_size *= scodesize;
    156      1.23  gmcgarry 		da.da_ipl = DIO_IPL(va);
    157       1.1   thorpej 
    158       1.1   thorpej 		/* No longer need the device to be mapped. */
    159      1.23  gmcgarry 		iounmap(va, PAGE_SIZE);
    160       1.1   thorpej 
    161       1.1   thorpej 		/* Attach matching device. */
    162  1.23.2.6     skrll 		config_found_sm_loc(self, "dio", NULL, &da, dioprint,
    163  1.23.2.6     skrll 				    diosubmatch);
    164       1.1   thorpej 		scode += scodesize;
    165       1.1   thorpej 	}
    166       1.1   thorpej }
    167       1.1   thorpej 
    168  1.23.2.2     skrll static int
    169  1.23.2.6     skrll diosubmatch(struct device *parent, struct cfdata *cf,
    170  1.23.2.6     skrll 	    const int *ldesc, void *aux)
    171       1.1   thorpej {
    172       1.1   thorpej 	struct dio_attach_args *da = aux;
    173       1.1   thorpej 
    174       1.8       jtk 	if (cf->diocf_scode != DIOCF_SCODE_DEFAULT &&
    175       1.1   thorpej 	    cf->diocf_scode != da->da_scode)
    176       1.1   thorpej 		return (0);
    177       1.1   thorpej 
    178      1.17   thorpej 	return (config_match(parent, cf, aux));
    179       1.1   thorpej }
    180       1.1   thorpej 
    181  1.23.2.2     skrll static int
    182  1.23.2.2     skrll dioprint(void *aux, const char *pnp)
    183       1.1   thorpej {
    184       1.1   thorpej 	struct dio_attach_args *da = aux;
    185       1.1   thorpej 	char buf[128];
    186       1.1   thorpej 
    187       1.1   thorpej 	if (pnp)
    188      1.21   thorpej 		aprint_normal("%s at %s",
    189      1.21   thorpej 		    dio_devinfo(da, buf, sizeof(buf)), pnp);
    190      1.23  gmcgarry 	aprint_normal(" scode %d ipl %d", da->da_scode, da->da_ipl);
    191       1.1   thorpej 	return (UNCONF);
    192       1.1   thorpej }
    193       1.1   thorpej 
    194       1.1   thorpej /*
    195       1.1   thorpej  * Convert a select code to a system physical address.
    196       1.1   thorpej  */
    197       1.1   thorpej void *
    198  1.23.2.2     skrll dio_scodetopa(int scode)
    199       1.1   thorpej {
    200       1.1   thorpej 	u_long rval;
    201       1.1   thorpej 
    202      1.23  gmcgarry 	if (DIO_ISDIO(scode))
    203       1.1   thorpej 		rval = DIO_BASE + (scode * DIO_DEVSIZE);
    204       1.1   thorpej 	else if (DIO_ISDIOII(scode))
    205       1.2   thorpej 		rval = DIOII_BASE + ((scode - DIOII_SCBASE) * DIOII_DEVSIZE);
    206       1.1   thorpej 	else
    207       1.1   thorpej 		rval = 0;
    208       1.1   thorpej 
    209       1.1   thorpej 	return ((void *)rval);
    210       1.1   thorpej }
    211       1.1   thorpej 
    212       1.1   thorpej /*
    213       1.1   thorpej  * Return the select code size for this device, defaulting to 1
    214       1.1   thorpej  * if we don't know what kind of device we have.
    215       1.1   thorpej  */
    216      1.23  gmcgarry static int
    217  1.23.2.2     skrll dio_scodesize(struct dio_attach_args *da)
    218       1.1   thorpej {
    219       1.1   thorpej 	int i;
    220       1.1   thorpej 
    221       1.1   thorpej 	/*
    222       1.1   thorpej 	 * Find the dio_devdata matchind the primary id.
    223       1.1   thorpej 	 * If we're a framebuffer, we also check the secondary id.
    224       1.1   thorpej 	 */
    225       1.1   thorpej 	for (i = 0; i < DIO_NDEVICES; i++) {
    226       1.1   thorpej 		if (da->da_id == dio_devdatas[i].dd_id) {
    227       1.1   thorpej 			if (DIO_ISFRAMEBUFFER(da->da_id)) {
    228       1.1   thorpej 				if (da->da_secid == dio_devdatas[i].dd_secid) {
    229       1.1   thorpej 					goto foundit;
    230       1.1   thorpej 				}
    231       1.1   thorpej 			} else {
    232       1.1   thorpej 			foundit:
    233       1.1   thorpej 				return (dio_devdatas[i].dd_nscode);
    234       1.1   thorpej 			}
    235       1.1   thorpej 		}
    236       1.1   thorpej 	}
    237       1.1   thorpej 
    238       1.1   thorpej 	/*
    239       1.1   thorpej 	 * Device is unknown.  Print a warning and assume a default.
    240       1.1   thorpej 	 */
    241       1.1   thorpej 	printf("WARNING: select code size unknown for id = 0x%x secid = 0x%x\n",
    242       1.1   thorpej 	    da->da_id, da->da_secid);
    243       1.1   thorpej 	return (1);
    244       1.1   thorpej }
    245       1.1   thorpej 
    246       1.1   thorpej /*
    247       1.1   thorpej  * Return a reasonable description of a DIO device.
    248       1.1   thorpej  */
    249  1.23.2.2     skrll static const char *
    250  1.23.2.2     skrll dio_devinfo(struct dio_attach_args *da, char *buf, size_t buflen)
    251       1.1   thorpej {
    252       1.5   thorpej #ifdef DIOVERBOSE
    253       1.1   thorpej 	int i;
    254       1.5   thorpej #endif
    255       1.1   thorpej 
    256      1.14  gmcgarry 	memset(buf, 0, buflen);
    257       1.1   thorpej 
    258       1.1   thorpej #ifdef DIOVERBOSE
    259       1.1   thorpej 	/*
    260       1.1   thorpej 	 * Find the description matching our primary id.
    261       1.1   thorpej 	 * If we're a framebuffer, we also check the secondary id.
    262       1.1   thorpej 	 */
    263       1.1   thorpej 	for (i = 0; i < DIO_NDEVICES; i++) {
    264       1.1   thorpej 		if (da->da_id == dio_devdescs[i].dd_id) {
    265       1.1   thorpej 			if (DIO_ISFRAMEBUFFER(da->da_id)) {
    266       1.1   thorpej 				if (da->da_secid == dio_devdescs[i].dd_secid) {
    267       1.1   thorpej 					goto foundit;
    268       1.1   thorpej 				}
    269       1.1   thorpej 			} else {
    270       1.1   thorpej 			foundit:
    271       1.1   thorpej 				sprintf(buf, "%s", dio_devdescs[i].dd_desc);
    272       1.1   thorpej 				return (buf);
    273       1.1   thorpej 			}
    274       1.1   thorpej 		}
    275       1.1   thorpej 	}
    276       1.1   thorpej #endif /* DIOVERBOSE */
    277       1.1   thorpej 
    278       1.1   thorpej 	/*
    279       1.1   thorpej 	 * Device is unknown.  Construct something reasonable.
    280       1.1   thorpej 	 */
    281       1.1   thorpej 	sprintf(buf, "device id = 0x%x secid = 0x%x",
    282       1.1   thorpej 	    da->da_id, da->da_secid);
    283       1.1   thorpej 	return (buf);
    284       1.7   thorpej }
    285       1.7   thorpej 
    286       1.7   thorpej /*
    287       1.7   thorpej  * Establish an interrupt handler for a DIO device.
    288       1.7   thorpej  */
    289       1.7   thorpej void *
    290  1.23.2.2     skrll dio_intr_establish(int (*func)(void *), void *arg, int ipl, int priority)
    291       1.7   thorpej {
    292       1.7   thorpej 	void *ih;
    293       1.7   thorpej 
    294       1.7   thorpej 	ih = intr_establish(func, arg, ipl, priority);
    295       1.7   thorpej 
    296       1.7   thorpej 	if (priority == IPL_BIO)
    297       1.7   thorpej 		dmacomputeipl();
    298       1.7   thorpej 
    299       1.7   thorpej 	return (ih);
    300       1.7   thorpej }
    301       1.7   thorpej 
    302       1.7   thorpej /*
    303       1.7   thorpej  * Remove an interrupt handler for a DIO device.
    304       1.7   thorpej  */
    305       1.7   thorpej void
    306  1.23.2.2     skrll dio_intr_disestablish(void *arg)
    307       1.7   thorpej {
    308      1.14  gmcgarry 	struct hp300_intrhand *ih = arg;
    309      1.14  gmcgarry 	int priority = ih->ih_priority;
    310       1.7   thorpej 
    311       1.7   thorpej 	intr_disestablish(arg);
    312       1.7   thorpej 
    313       1.7   thorpej 	if (priority == IPL_BIO)
    314       1.7   thorpej 		dmacomputeipl();
    315       1.1   thorpej }
    316  1.23.2.1     skrll 
    317  1.23.2.1     skrll /*
    318  1.23.2.1     skrll  * DIO specific bus_space(9) support functions.
    319  1.23.2.1     skrll  */
    320  1.23.2.5     skrll static uint8_t dio_bus_space_read_oddbyte_1(bus_space_tag_t,
    321  1.23.2.2     skrll     bus_space_handle_t, bus_size_t);
    322  1.23.2.2     skrll static void dio_bus_space_write_oddbyte_1(bus_space_tag_t,
    323  1.23.2.5     skrll     bus_space_handle_t, bus_size_t, uint8_t);
    324  1.23.2.2     skrll 
    325  1.23.2.2     skrll static void dio_bus_space_read_multi_oddbyte_1(bus_space_tag_t,
    326  1.23.2.5     skrll     bus_space_handle_t, bus_size_t, uint8_t *, bus_size_t);
    327  1.23.2.2     skrll static void dio_bus_space_write_multi_oddbyte_1(bus_space_tag_t,
    328  1.23.2.5     skrll     bus_space_handle_t, bus_size_t, const uint8_t *, bus_size_t);
    329  1.23.2.2     skrll 
    330  1.23.2.2     skrll static void dio_bus_space_read_region_oddbyte_1(bus_space_tag_t,
    331  1.23.2.5     skrll     bus_space_handle_t, bus_size_t, uint8_t *, bus_size_t);
    332  1.23.2.2     skrll static void dio_bus_space_write_region_oddbyte_1(bus_space_tag_t,
    333  1.23.2.5     skrll     bus_space_handle_t, bus_size_t, const uint8_t *, bus_size_t);
    334  1.23.2.1     skrll 
    335  1.23.2.2     skrll static void dio_bus_space_set_multi_oddbyte_1(bus_space_tag_t,
    336  1.23.2.5     skrll     bus_space_handle_t, bus_size_t, uint8_t, bus_size_t);
    337  1.23.2.1     skrll 
    338  1.23.2.2     skrll static void dio_bus_space_set_region_oddbyte_1(bus_space_tag_t,
    339  1.23.2.5     skrll     bus_space_handle_t, bus_size_t, uint8_t, bus_size_t);
    340  1.23.2.1     skrll 
    341  1.23.2.1     skrll /*
    342  1.23.2.1     skrll  * dio_set_bus_space_oddbyte():
    343  1.23.2.1     skrll  *	Override bus_space functions in bus_space_tag_t
    344  1.23.2.1     skrll  *	for devices which have odd byte address space.
    345  1.23.2.1     skrll  */
    346  1.23.2.1     skrll void
    347  1.23.2.2     skrll dio_set_bus_space_oddbyte(bus_space_tag_t bst)
    348  1.23.2.1     skrll {
    349  1.23.2.1     skrll 
    350  1.23.2.1     skrll 	/* XXX only 1-byte functions for now */
    351  1.23.2.1     skrll 	bst->bsr1 = dio_bus_space_read_oddbyte_1;
    352  1.23.2.1     skrll 	bst->bsw1 = dio_bus_space_write_oddbyte_1;
    353  1.23.2.1     skrll 
    354  1.23.2.1     skrll 	bst->bsrm1 = dio_bus_space_read_multi_oddbyte_1;
    355  1.23.2.1     skrll 	bst->bswm1 = dio_bus_space_write_multi_oddbyte_1;
    356  1.23.2.1     skrll 
    357  1.23.2.1     skrll 	bst->bsrr1 = dio_bus_space_read_region_oddbyte_1;
    358  1.23.2.1     skrll 	bst->bswr1 = dio_bus_space_write_region_oddbyte_1;
    359  1.23.2.1     skrll 
    360  1.23.2.1     skrll 	bst->bssm1 = dio_bus_space_set_multi_oddbyte_1;
    361  1.23.2.1     skrll 
    362  1.23.2.1     skrll 	bst->bssr1 = dio_bus_space_set_region_oddbyte_1;
    363  1.23.2.1     skrll }
    364  1.23.2.1     skrll 
    365  1.23.2.5     skrll static uint8_t
    366  1.23.2.2     skrll dio_bus_space_read_oddbyte_1(bus_space_tag_t bst, bus_space_handle_t bsh,
    367  1.23.2.2     skrll     bus_size_t offset)
    368  1.23.2.1     skrll {
    369  1.23.2.1     skrll 
    370  1.23.2.5     skrll 	return *(volatile uint8_t *)(bsh + (offset << 1) + 1);
    371  1.23.2.1     skrll }
    372  1.23.2.1     skrll 
    373  1.23.2.2     skrll static void
    374  1.23.2.2     skrll dio_bus_space_write_oddbyte_1(bus_space_tag_t bst, bus_space_handle_t bsh,
    375  1.23.2.5     skrll     bus_size_t offset, uint8_t val)
    376  1.23.2.1     skrll {
    377  1.23.2.1     skrll 
    378  1.23.2.5     skrll 	*(volatile uint8_t *)(bsh + (offset << 1) + 1) = val;
    379  1.23.2.1     skrll }
    380  1.23.2.1     skrll 
    381  1.23.2.1     skrll static void
    382  1.23.2.2     skrll dio_bus_space_read_multi_oddbyte_1(bus_space_tag_t bst, bus_space_handle_t bsh,
    383  1.23.2.5     skrll     bus_size_t offset, uint8_t *addr, bus_size_t len)
    384  1.23.2.1     skrll {
    385  1.23.2.1     skrll 
    386  1.23.2.1     skrll 	__asm __volatile (
    387  1.23.2.1     skrll 	"	movl	%0,%%a0		;\n"
    388  1.23.2.1     skrll 	"	movl	%1,%%a1		;\n"
    389  1.23.2.1     skrll 	"	movl	%2,%%d0		;\n"
    390  1.23.2.1     skrll 	"1:	movb	%%a0@,%%a1@+	;\n"
    391  1.23.2.1     skrll 	"	subql	#1,%%d0		;\n"
    392  1.23.2.1     skrll 	"	jne	1b"
    393  1.23.2.1     skrll 	    :
    394  1.23.2.1     skrll 	    : "r" (bsh + (offset << 1) + 1), "g" (addr), "g" (len)
    395  1.23.2.1     skrll 	    : "%a0","%a1","%d0");
    396  1.23.2.1     skrll }
    397  1.23.2.1     skrll 
    398  1.23.2.1     skrll static void
    399  1.23.2.2     skrll dio_bus_space_write_multi_oddbyte_1(bus_space_tag_t bst, bus_space_handle_t bsh,
    400  1.23.2.5     skrll     bus_size_t offset, const uint8_t *addr, bus_size_t len)
    401  1.23.2.1     skrll {
    402  1.23.2.1     skrll 
    403  1.23.2.1     skrll 	__asm __volatile (
    404  1.23.2.1     skrll 	"	movl	%0,%%a0		;\n"
    405  1.23.2.1     skrll 	"	movl	%1,%%a1		;\n"
    406  1.23.2.1     skrll 	"	movl	%2,%%d0		;\n"
    407  1.23.2.1     skrll 	"1:	movb	%%a1@+,%%a0@	;\n"
    408  1.23.2.1     skrll 	"	subql	#1,%%d0		;\n"
    409  1.23.2.1     skrll 	"	jne	1b"
    410  1.23.2.1     skrll 	    :
    411  1.23.2.1     skrll 	    : "r" (bsh + (offset << 1) + 1), "g" (addr), "g" (len)
    412  1.23.2.1     skrll 	    : "%a0","%a1","%d0");
    413  1.23.2.1     skrll }
    414  1.23.2.1     skrll 
    415  1.23.2.1     skrll static void
    416  1.23.2.2     skrll dio_bus_space_read_region_oddbyte_1(bus_space_tag_t bst, bus_space_handle_t bsh,
    417  1.23.2.5     skrll     bus_size_t offset, uint8_t *addr, bus_size_t len)
    418  1.23.2.1     skrll {
    419  1.23.2.1     skrll 	__asm __volatile (
    420  1.23.2.1     skrll 	"	movl	%0,%%a0		;\n"
    421  1.23.2.1     skrll 	"	movl	%1,%%a1		;\n"
    422  1.23.2.1     skrll 	"	movl	%2,%%d0		;\n"
    423  1.23.2.1     skrll 	"1:	movb	%%a0@,%%a1@+	;\n"
    424  1.23.2.1     skrll 	"	addql	#2,%%a0		;\n"
    425  1.23.2.1     skrll 	"	subql	#1,%%d0		;\n"
    426  1.23.2.1     skrll 	"	jne	1b"
    427  1.23.2.1     skrll 	    :
    428  1.23.2.1     skrll 	    : "r" (bsh + (offset << 1) + 1), "g" (addr), "g" (len)
    429  1.23.2.1     skrll 	    : "%a0","%a1","%d0");
    430  1.23.2.1     skrll }
    431  1.23.2.1     skrll 
    432  1.23.2.1     skrll static void
    433  1.23.2.2     skrll dio_bus_space_write_region_oddbyte_1(bus_space_tag_t bst,
    434  1.23.2.5     skrll     bus_space_handle_t bsh, bus_size_t offset, const uint8_t *addr,
    435  1.23.2.2     skrll     bus_size_t len)
    436  1.23.2.1     skrll {
    437  1.23.2.1     skrll 
    438  1.23.2.1     skrll 	__asm __volatile (
    439  1.23.2.1     skrll 	"	movl	%0,%%a0		;\n"
    440  1.23.2.1     skrll 	"	movl	%1,%%a1		;\n"
    441  1.23.2.1     skrll 	"	movl	%2,%%d0		;\n"
    442  1.23.2.1     skrll 	"1:	movb	%%a1@+,%%a0@	;\n"
    443  1.23.2.1     skrll 	"	addql	#2,%%a0		;\n"
    444  1.23.2.1     skrll 	"	subql	#1,%%d0		;\n"
    445  1.23.2.1     skrll 	"	jne	1b"
    446  1.23.2.1     skrll 	    :
    447  1.23.2.1     skrll 	    : "r" (bsh + (offset << 1) + 1), "g" (addr), "g" (len)
    448  1.23.2.1     skrll 	    : "%a0","%a1","%d0");
    449  1.23.2.1     skrll }
    450  1.23.2.1     skrll 
    451  1.23.2.1     skrll static void
    452  1.23.2.2     skrll dio_bus_space_set_multi_oddbyte_1(bus_space_tag_t bst, bus_space_handle_t bsh,
    453  1.23.2.5     skrll     bus_size_t offset, uint8_t val, bus_size_t count)
    454  1.23.2.1     skrll {
    455  1.23.2.1     skrll 	__asm __volatile (
    456  1.23.2.1     skrll 	"	movl	%0,%%a0		;\n"
    457  1.23.2.1     skrll 	"	movl	%1,%%d1		;\n"
    458  1.23.2.1     skrll 	"	movl	%2,%%d0		;\n"
    459  1.23.2.1     skrll 	"1:	movb	%%d1,%%a0@	;\n"
    460  1.23.2.1     skrll 	"	subql	#1,%%d0		;\n"
    461  1.23.2.1     skrll 	"	jne	1b"
    462  1.23.2.1     skrll 	    :
    463  1.23.2.1     skrll 	    : "r" (bsh + (offset << 1) + 1), "g" (val), "g" (count)
    464  1.23.2.1     skrll 	    : "%a0","%d0","%d1");
    465  1.23.2.1     skrll }
    466  1.23.2.1     skrll 
    467  1.23.2.1     skrll static void
    468  1.23.2.2     skrll dio_bus_space_set_region_oddbyte_1(bus_space_tag_t bst, bus_space_handle_t bsh,
    469  1.23.2.5     skrll     bus_size_t offset, uint8_t val, bus_size_t count)
    470  1.23.2.1     skrll {
    471  1.23.2.1     skrll 
    472  1.23.2.1     skrll 	__asm __volatile (
    473  1.23.2.1     skrll 	"	movl	%0,%%a0		;\n"
    474  1.23.2.1     skrll 	"	movl	%1,%%d1		;\n"
    475  1.23.2.1     skrll 	"	movl	%2,%%d0		;\n"
    476  1.23.2.1     skrll 	"1:	movb	%%d1,%%a0@	;\n"
    477  1.23.2.1     skrll 	"	addql	#2,%%a0		;\n"
    478  1.23.2.1     skrll 	"	subql	#1,%%d0		;\n"
    479  1.23.2.1     skrll 	"	jne	1b"
    480  1.23.2.1     skrll 	    :
    481  1.23.2.1     skrll 	    : "r" (bsh + (offset << 1) + 1), "g" (val), "g" (count)
    482  1.23.2.1     skrll 	    : "%a0","%d0","%d1");
    483  1.23.2.1     skrll }
    484