Home | History | Annotate | Line # | Download | only in dev
gayle_pcmcia.c revision 1.29.4.2
      1  1.29.4.2    martin /*	$NetBSD: gayle_pcmcia.c,v 1.29.4.2 2015/02/16 12:48:32 martin Exp $ */
      2       1.6   aymeric 
      3       1.6   aymeric /* public domain */
      4       1.1   aymeric 
      5      1.12   aymeric #include <sys/cdefs.h>
      6  1.29.4.2    martin __KERNEL_RCSID(0, "$NetBSD: gayle_pcmcia.c,v 1.29.4.2 2015/02/16 12:48:32 martin Exp $");
      7      1.12   aymeric 
      8       1.1   aymeric /* PCMCIA front-end driver for A1200's and A600's. */
      9       1.1   aymeric 
     10       1.1   aymeric #include <sys/param.h>
     11       1.1   aymeric #include <sys/device.h>
     12       1.1   aymeric #include <sys/kernel.h>
     13       1.1   aymeric #include <sys/kthread.h>
     14       1.1   aymeric #include <sys/systm.h>
     15       1.3       mrg 
     16       1.1   aymeric #include <uvm/uvm.h>
     17       1.3       mrg 
     18       1.1   aymeric #include <dev/pcmcia/pcmciareg.h>
     19       1.1   aymeric #include <dev/pcmcia/pcmciavar.h>
     20       1.1   aymeric 
     21       1.1   aymeric #include <machine/cpu.h>
     22       1.1   aymeric #include <amiga/amiga/custom.h>
     23       1.1   aymeric #include <amiga/amiga/device.h>
     24       1.1   aymeric #include <amiga/amiga/gayle.h>
     25       1.1   aymeric #include <amiga/amiga/isr.h>
     26       1.1   aymeric 
     27       1.1   aymeric 
     28      1.11   aymeric /* There is one of these for each slot. And yes, there is only one slot. */
     29       1.1   aymeric struct pccard_slot {
     30       1.1   aymeric 	struct	pccard_softc *sc;	/* refer to `parent' */
     31       1.1   aymeric 	int	(*intr_func)(void *);
     32       1.1   aymeric 	void *	intr_arg;
     33      1.26       chs 	device_t card;
     34       1.1   aymeric 	int	flags;
     35       1.1   aymeric #define SLOT_OCCUPIED		0x01
     36       1.1   aymeric #define SLOT_NEW_CARD_EVENT	0x02
     37       1.1   aymeric };
     38       1.1   aymeric 
     39       1.1   aymeric struct pccard_softc {
     40       1.1   aymeric 	struct bus_space_tag io_space;
     41       1.1   aymeric 	struct bus_space_tag attr_space;
     42       1.1   aymeric 	struct bus_space_tag mem_space;
     43       1.1   aymeric 	struct pccard_slot devs[1];
     44       1.1   aymeric 	struct isr intr6;
     45       1.1   aymeric 	struct isr intr2;
     46       1.1   aymeric };
     47       1.1   aymeric 
     48      1.26       chs static int	pccard_probe(device_t, cfdata_t, void *);
     49      1.26       chs static void	pccard_attach(device_t, device_t, void *);
     50      1.11   aymeric static void	pccard_attach_slot(struct pccard_slot *);
     51      1.11   aymeric static int	pccard_intr6(void *);
     52      1.11   aymeric static int	pccard_intr2(void *);
     53      1.11   aymeric static void	pccard_kthread(void *);
     54      1.11   aymeric 
     55      1.11   aymeric static int pcf_mem_alloc(pcmcia_chipset_handle_t, bus_size_t,
     56      1.11   aymeric 		struct pcmcia_mem_handle *);
     57      1.11   aymeric static void pcf_mem_free(pcmcia_chipset_handle_t, struct pcmcia_mem_handle *);
     58      1.11   aymeric static int pcf_mem_map(pcmcia_chipset_handle_t, int, bus_addr_t, bus_size_t,
     59      1.11   aymeric 		struct pcmcia_mem_handle *, bus_addr_t *, int *);
     60      1.11   aymeric static void pcf_mem_unmap(pcmcia_chipset_handle_t, int);
     61      1.11   aymeric static int pcf_io_alloc(pcmcia_chipset_handle_t, bus_addr_t, bus_size_t,
     62      1.11   aymeric 		bus_size_t, struct pcmcia_io_handle *);
     63      1.11   aymeric static void pcf_io_free(pcmcia_chipset_handle_t, struct pcmcia_io_handle *);
     64      1.11   aymeric static int pcf_io_map(pcmcia_chipset_handle_t, int, bus_addr_t, bus_size_t,
     65      1.11   aymeric 		struct pcmcia_io_handle *, int *);
     66      1.11   aymeric static void pcf_io_unmap(pcmcia_chipset_handle_t, int);
     67      1.11   aymeric static void *pcf_intr_establish(pcmcia_chipset_handle_t,
     68      1.11   aymeric 		struct pcmcia_function *, int, int (*)(void *), void *);
     69      1.11   aymeric static void pcf_intr_disestablish(pcmcia_chipset_handle_t, void *);
     70      1.11   aymeric static void pcf_socket_enable(pcmcia_chipset_handle_t);
     71      1.11   aymeric static void pcf_socket_disable(pcmcia_chipset_handle_t);
     72      1.15   aymeric static void pcf_socket_settype(pcmcia_chipset_handle_t, int);
     73       1.1   aymeric 
     74       1.1   aymeric static bsr(pcmio_bsr1, u_int8_t);
     75       1.1   aymeric static bsw(pcmio_bsw1, u_int8_t);
     76       1.1   aymeric static bsrm(pcmio_bsrm1, u_int8_t);
     77       1.1   aymeric static bswm(pcmio_bswm1, u_int8_t);
     78       1.1   aymeric static bsrm(pcmio_bsrr1, u_int8_t);
     79       1.1   aymeric static bswm(pcmio_bswr1, u_int8_t);
     80       1.1   aymeric static bssr(pcmio_bssr1, u_int8_t);
     81       1.1   aymeric static bscr(pcmio_bscr1, u_int8_t);
     82       1.1   aymeric 
     83      1.26       chs CFATTACH_DECL_NEW(pccard, sizeof(struct pccard_softc),
     84      1.14   thorpej     pccard_probe, pccard_attach, NULL, NULL);
     85       1.1   aymeric 
     86      1.19   aymeric static struct pcmcia_chip_functions chip_functions = {
     87       1.1   aymeric 	pcf_mem_alloc,		pcf_mem_free,
     88       1.1   aymeric 	pcf_mem_map,		pcf_mem_unmap,
     89       1.1   aymeric 	pcf_io_alloc,		pcf_io_free,
     90       1.1   aymeric 	pcf_io_map,		pcf_io_unmap,
     91       1.1   aymeric 	pcf_intr_establish,	pcf_intr_disestablish,
     92      1.15   aymeric 	pcf_socket_enable,	pcf_socket_disable,
     93      1.15   aymeric 	pcf_socket_settype
     94       1.1   aymeric };
     95       1.1   aymeric 
     96      1.19   aymeric static struct amiga_bus_space_methods pcmio_bs_methods;
     97       1.1   aymeric 
     98      1.11   aymeric static u_int8_t *reset_card_reg;
     99      1.11   aymeric 
    100       1.1   aymeric static int
    101      1.26       chs pccard_probe(device_t parent, cfdata_t cf, void *aux)
    102       1.1   aymeric {
    103      1.11   aymeric 
    104      1.24       phx 	return (is_a600() || is_a1200()) && matchname(aux, "pccard");
    105       1.1   aymeric }
    106       1.1   aymeric 
    107       1.1   aymeric static void
    108      1.26       chs pccard_attach(device_t parent, device_t self, void *aux)
    109       1.1   aymeric {
    110      1.26       chs 	struct pccard_softc *sc = device_private(self);
    111       1.1   aymeric 	struct pcmciabus_attach_args paa;
    112      1.19   aymeric 	vaddr_t pcmcia_base;
    113       1.1   aymeric 	vaddr_t i;
    114       1.1   aymeric 
    115       1.1   aymeric 	printf("\n");
    116       1.1   aymeric 
    117       1.1   aymeric 	gayle_init();
    118       1.1   aymeric 
    119      1.20       chs 	pcmcia_base = uvm_km_alloc(kernel_map,
    120      1.20       chs 				   GAYLE_PCMCIA_END - GAYLE_PCMCIA_START,
    121      1.20       chs 				   0, UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
    122      1.20       chs 	if (pcmcia_base == 0) {
    123       1.1   aymeric 		printf("attach failed (no virtual memory)\n");
    124       1.1   aymeric 		return;
    125       1.1   aymeric 	}
    126       1.1   aymeric 
    127       1.1   aymeric 	for (i = GAYLE_PCMCIA_START; i < GAYLE_PCMCIA_END; i += PAGE_SIZE)
    128      1.20       chs 		pmap_enter(vm_map_pmap(kernel_map),
    129       1.1   aymeric 		    i - GAYLE_PCMCIA_START + pcmcia_base, i,
    130      1.21   thorpej 		    VM_PROT_READ | VM_PROT_WRITE, true);
    131      1.20       chs 	pmap_update(vm_map_pmap(kernel_map));
    132       1.1   aymeric 
    133       1.1   aymeric 	/* override the one-byte access methods for I/O space */
    134       1.1   aymeric 	pcmio_bs_methods = amiga_bus_stride_1;
    135       1.1   aymeric 	pcmio_bs_methods.bsr1 = pcmio_bsr1;
    136       1.1   aymeric 	pcmio_bs_methods.bsw1 = pcmio_bsw1;
    137       1.1   aymeric 	pcmio_bs_methods.bsrm1 = pcmio_bsrm1;
    138       1.1   aymeric 	pcmio_bs_methods.bswm1 = pcmio_bswm1;
    139       1.1   aymeric 	pcmio_bs_methods.bsrr1 = pcmio_bsrr1;
    140       1.1   aymeric 	pcmio_bs_methods.bswr1 = pcmio_bswr1;
    141       1.1   aymeric 	pcmio_bs_methods.bssr1 = pcmio_bssr1;
    142       1.1   aymeric 	pcmio_bs_methods.bscr1 = pcmio_bscr1;
    143       1.1   aymeric 
    144      1.19   aymeric 	reset_card_reg = (u_int8_t *) pcmcia_base +
    145      1.19   aymeric 	    (GAYLE_PCMCIA_RESET - GAYLE_PCMCIA_START);
    146       1.1   aymeric 
    147      1.26       chs 	sc->io_space.base = (bus_addr_t) pcmcia_base +
    148      1.19   aymeric 	    (GAYLE_PCMCIA_IO_START - GAYLE_PCMCIA_START);
    149      1.26       chs 	sc->io_space.absm = &pcmio_bs_methods;
    150       1.1   aymeric 
    151      1.26       chs 	sc->attr_space.base = (bus_addr_t) pcmcia_base +
    152      1.19   aymeric 	    (GAYLE_PCMCIA_ATTR_START - GAYLE_PCMCIA_START);
    153      1.26       chs 	sc->attr_space.absm = &amiga_bus_stride_1;
    154       1.1   aymeric 
    155       1.6   aymeric 	/* XXX we should check if the 4M of common memory are actually
    156       1.6   aymeric 	 *	RAM or PCMCIA usable.
    157       1.6   aymeric 	 * For now, we just do as if the 4M were RAM and make common memory
    158       1.6   aymeric 	 * point to attribute memory, which is OK for some I/O cards.
    159       1.6   aymeric 	 */
    160      1.26       chs 	sc->mem_space.base = (bus_addr_t) pcmcia_base;
    161      1.26       chs 	sc->mem_space.absm = &amiga_bus_stride_1;
    162       1.1   aymeric 
    163      1.26       chs 	sc->devs[0].sc = sc;
    164      1.26       chs 	sc->devs[0].intr_func = NULL;
    165      1.26       chs 	sc->devs[0].intr_arg = NULL;
    166      1.26       chs 	sc->devs[0].flags = 0;
    167       1.1   aymeric 
    168      1.28   rkujawa 	gayle_pcmcia_status_write(0);
    169      1.28   rkujawa 	gayle_intr_ack(0);
    170      1.28   rkujawa 	gayle_pcmcia_config_write(0);
    171      1.28   rkujawa 	gayle_intr_enable_set(GAYLE_INT_IDE);
    172       1.1   aymeric 
    173       1.1   aymeric 	paa.paa_busname = "pcmcia";
    174       1.1   aymeric 	paa.pct = &chip_functions;
    175      1.26       chs 	paa.pch = &sc->devs[0];
    176      1.26       chs 	sc->devs[0].card = config_found(self, &paa, simple_devprint);
    177      1.26       chs 	if (sc->devs[0].card == NULL) {
    178      1.19   aymeric 		printf("attach failed, config_found() returned NULL\n");
    179      1.19   aymeric 		pmap_remove(kernel_map->pmap, pcmcia_base,
    180      1.19   aymeric 		    pcmcia_base + (GAYLE_PCMCIA_END - GAYLE_PCMCIA_START));
    181      1.19   aymeric 		pmap_update(kernel_map->pmap);
    182      1.19   aymeric 		uvm_deallocate(kernel_map, pcmcia_base,
    183      1.19   aymeric 			GAYLE_PCMCIA_END - GAYLE_PCMCIA_START);
    184       1.1   aymeric 		return;
    185       1.1   aymeric 	}
    186       1.1   aymeric 
    187      1.26       chs 	sc->intr6.isr_intr = pccard_intr6;
    188      1.27  jandberg 	sc->intr6.isr_arg = sc;
    189      1.26       chs 	sc->intr6.isr_ipl = 6;
    190      1.26       chs 	add_isr(&sc->intr6);
    191      1.26       chs 
    192      1.26       chs 	sc->intr2.isr_intr = pccard_intr2;
    193      1.27  jandberg 	sc->intr2.isr_arg = sc;
    194      1.26       chs 	sc->intr2.isr_ipl = 2;
    195      1.26       chs 	add_isr(&sc->intr2);
    196       1.1   aymeric 
    197      1.26       chs 	if (kthread_create(PRI_NONE, 0, NULL, pccard_kthread, sc,
    198      1.22        ad 	    NULL, "pccard")) {
    199      1.22        ad 		printf("%s: can't create kernel thread\n",
    200      1.26       chs 		       device_xname(self));
    201      1.22        ad 		panic("pccard kthread_create() failed");
    202      1.22        ad 	}
    203       1.1   aymeric 
    204      1.28   rkujawa 	gayle_intr_enable_set(GAYLE_INT_DETECT | GAYLE_INT_IREQ);
    205       1.1   aymeric 
    206       1.1   aymeric 	/* reset the card if it's already there */
    207      1.28   rkujawa 	if (gayle_pcmcia_status_read() & GAYLE_CCMEM_DETECT) {
    208       1.1   aymeric 		volatile u_int8_t x;
    209  1.29.4.1    martin 
    210  1.29.4.1    martin 		gayle_intr_ack(0xff);
    211  1.29.4.1    martin 		delay(500);
    212  1.29.4.1    martin 		gayle_intr_ack(0xfc);
    213  1.29.4.1    martin 
    214  1.29.4.2    martin 		delay(100*1000);
    215  1.29.4.2    martin 
    216       1.1   aymeric 		*reset_card_reg = 0x0;
    217       1.1   aymeric 		delay(1000);
    218       1.1   aymeric 		x = *reset_card_reg;
    219      1.29  christos 		__USE(x);
    220      1.28   rkujawa 		gayle_pcmcia_status_write(GAYLE_CCMEM_WP | GAYLE_CCIO_SPKR);
    221       1.1   aymeric 	}
    222       1.1   aymeric 
    223      1.26       chs 	pccard_attach_slot(&sc->devs[0]);
    224       1.1   aymeric }
    225       1.1   aymeric 
    226       1.1   aymeric static int
    227      1.11   aymeric pccard_intr6(void *arg)
    228       1.1   aymeric {
    229      1.26       chs 	struct pccard_softc *sc = arg;
    230       1.1   aymeric 
    231      1.28   rkujawa 	if (gayle_intr_status() & GAYLE_INT_DETECT) {
    232      1.28   rkujawa 		gayle_intr_ack(GAYLE_INT_IDE | GAYLE_INT_STSCHG |
    233      1.28   rkujawa 		    GAYLE_INT_SPKR | GAYLE_INT_WP | GAYLE_INT_IREQ);
    234      1.26       chs 		sc->devs[0].flags |= SLOT_NEW_CARD_EVENT;
    235       1.1   aymeric 		return 1;
    236       1.1   aymeric 	}
    237       1.1   aymeric 	return 0;
    238       1.1   aymeric }
    239       1.1   aymeric 
    240       1.1   aymeric static int
    241      1.11   aymeric pccard_intr2(void *arg)
    242       1.1   aymeric {
    243      1.26       chs 	struct pccard_softc *sc = arg;
    244      1.26       chs 	struct pccard_slot *slot = &sc->devs[0];
    245       1.1   aymeric 
    246       1.1   aymeric 	if (slot->flags & SLOT_NEW_CARD_EVENT) {
    247       1.1   aymeric 		slot->flags &= ~SLOT_NEW_CARD_EVENT;
    248       1.1   aymeric 
    249       1.1   aymeric 		/* reset the registers */
    250      1.28   rkujawa 		gayle_intr_ack(GAYLE_INT_IDE | GAYLE_INT_DETECT);
    251      1.28   rkujawa 		gayle_pcmcia_status_write(GAYLE_CCMEM_WP | GAYLE_CCIO_SPKR);
    252      1.28   rkujawa 		gayle_pcmcia_config_write(0);
    253      1.26       chs 		pccard_attach_slot(&sc->devs[0]);
    254       1.1   aymeric 	} else {
    255      1.28   rkujawa 		int intreq = gayle_intr_status() &
    256       1.2   aymeric 		    (GAYLE_INT_STSCHG | GAYLE_INT_WP | GAYLE_INT_IREQ);
    257       1.2   aymeric 		if (intreq) {
    258      1.28   rkujawa 			gayle_intr_ack((intreq ^ 0x2c) | 0xc0);
    259       1.1   aymeric 
    260       1.6   aymeric 			return slot->flags & SLOT_OCCUPIED &&
    261       1.6   aymeric 		   		slot->intr_func != NULL &&
    262       1.1   aymeric 				slot->intr_func(slot->intr_arg);
    263       1.1   aymeric 		}
    264       1.1   aymeric 	}
    265       1.1   aymeric 	return 0;
    266       1.1   aymeric }
    267       1.1   aymeric 
    268       1.1   aymeric static void
    269      1.11   aymeric pccard_kthread(void *arg)
    270       1.1   aymeric {
    271      1.26       chs 	struct pccard_softc *sc = arg;
    272      1.26       chs 	struct pccard_slot *slot = &sc->devs[0];
    273       1.1   aymeric 
    274       1.1   aymeric 	for (;;) {
    275       1.1   aymeric 		int s = spl2();
    276       1.1   aymeric 
    277       1.1   aymeric 		if (slot->flags & SLOT_NEW_CARD_EVENT) {
    278       1.1   aymeric 			slot->flags &= ~SLOT_NEW_CARD_EVENT;
    279      1.28   rkujawa 			gayle_intr_ack(0xc0);
    280       1.1   aymeric 
    281       1.1   aymeric 			/* reset the registers */
    282      1.28   rkujawa 			gayle_intr_ack(GAYLE_INT_IDE | GAYLE_INT_DETECT);
    283      1.28   rkujawa 			gayle_pcmcia_status_write(GAYLE_CCMEM_WP | GAYLE_CCIO_SPKR);
    284      1.28   rkujawa 			gayle_pcmcia_config_write(0);
    285      1.26       chs 			pccard_attach_slot(&sc->devs[0]);
    286       1.1   aymeric 		}
    287       1.1   aymeric 		splx(s);
    288       1.1   aymeric 
    289       1.1   aymeric 		tsleep(slot, PWAIT, "pccthread", hz);
    290       1.1   aymeric 	}
    291       1.1   aymeric }
    292       1.1   aymeric 
    293       1.1   aymeric static void
    294      1.11   aymeric pccard_attach_slot(struct pccard_slot *slot)
    295       1.1   aymeric {
    296      1.11   aymeric 
    297       1.1   aymeric 	if (!(slot->flags & SLOT_OCCUPIED) &&
    298      1.28   rkujawa 			gayle_pcmcia_status_read() & GAYLE_CCMEM_DETECT) {
    299       1.1   aymeric 		if (pcmcia_card_attach(slot->card) == 0)
    300       1.1   aymeric 			slot->flags |= SLOT_OCCUPIED;
    301       1.1   aymeric 	}
    302       1.1   aymeric }
    303       1.1   aymeric 
    304       1.1   aymeric static int
    305      1.11   aymeric pcf_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t bsz,
    306      1.11   aymeric 	      struct pcmcia_mem_handle *pcmh)
    307       1.1   aymeric {
    308       1.1   aymeric 	struct pccard_slot *slot = (struct pccard_slot *) pch;
    309      1.11   aymeric 
    310       1.1   aymeric 	pcmh->memt = &slot->sc->attr_space;
    311       1.1   aymeric 	pcmh->memh = pcmh->memt->base;
    312       1.1   aymeric 	return 0;
    313       1.1   aymeric }
    314       1.1   aymeric 
    315       1.1   aymeric static void
    316      1.11   aymeric pcf_mem_free(pcmcia_chipset_handle_t pch, struct pcmcia_mem_handle *memh)
    317       1.1   aymeric {
    318       1.1   aymeric }
    319       1.1   aymeric 
    320       1.1   aymeric static int
    321      1.11   aymeric pcf_mem_map(pcmcia_chipset_handle_t pch, int kind, bus_addr_t addr,
    322      1.11   aymeric 	    bus_size_t size, struct pcmcia_mem_handle *pcmh,
    323      1.11   aymeric 	    bus_addr_t *offsetp, int *windowp)
    324       1.1   aymeric {
    325       1.1   aymeric 	struct pccard_slot *slot = (struct pccard_slot *) pch;
    326       1.1   aymeric 
    327       1.6   aymeric 	/* Ignore width requirements */
    328       1.6   aymeric 	kind &= ~PCMCIA_WIDTH_MEM_MASK;
    329       1.6   aymeric 
    330       1.1   aymeric 	switch (kind) {
    331       1.1   aymeric 	case PCMCIA_MEM_ATTR:
    332       1.1   aymeric 		pcmh->memt = &slot->sc->attr_space;
    333       1.1   aymeric 		break;
    334       1.1   aymeric 	case PCMCIA_MEM_COMMON:
    335       1.1   aymeric 		pcmh->memt = &slot->sc->mem_space;
    336       1.1   aymeric 		break;
    337       1.1   aymeric 	default:
    338       1.1   aymeric 		/* This means that this code needs an update/a bugfix */
    339       1.7        is 		printf(__FILE__ ": unknown kind %d of PCMCIA memory\n", kind);
    340       1.1   aymeric 		return 1;
    341       1.1   aymeric 	}
    342       1.1   aymeric 
    343       1.1   aymeric 	bus_space_map(pcmh->memt, addr, size, 0, &pcmh->memh);
    344       1.1   aymeric 	*offsetp = 0;
    345       1.1   aymeric 	*windowp = 0;			/* unused */
    346       1.1   aymeric 
    347       1.1   aymeric 	return 0;
    348       1.1   aymeric }
    349       1.1   aymeric 
    350       1.1   aymeric static void
    351      1.11   aymeric pcf_mem_unmap(pcmcia_chipset_handle_t pch, int win)
    352       1.1   aymeric {
    353       1.1   aymeric }
    354       1.1   aymeric 
    355       1.1   aymeric static int
    356      1.11   aymeric pcf_io_alloc(pcmcia_chipset_handle_t pch, bus_addr_t start, bus_size_t size,
    357      1.11   aymeric 	     bus_size_t align, struct pcmcia_io_handle *pcihp)
    358       1.1   aymeric {
    359       1.1   aymeric 	struct pccard_slot *slot = (struct pccard_slot *) pch;
    360       1.1   aymeric 
    361       1.1   aymeric 	pcihp->iot = &slot->sc->io_space;
    362       1.1   aymeric 	pcihp->ioh = pcihp->iot->base;
    363       1.1   aymeric 	return 0;
    364       1.1   aymeric }
    365       1.1   aymeric 
    366       1.1   aymeric static void
    367      1.11   aymeric pcf_io_free(pcmcia_chipset_handle_t pch, struct pcmcia_io_handle *pcihp)
    368       1.1   aymeric {
    369       1.1   aymeric }
    370       1.1   aymeric 
    371       1.1   aymeric static int
    372      1.11   aymeric pcf_io_map(pcmcia_chipset_handle_t pch, int width, bus_addr_t offset,
    373      1.11   aymeric 	   bus_size_t size, struct pcmcia_io_handle *pcihp, int *windowp)
    374       1.1   aymeric {
    375       1.1   aymeric 	struct pccard_slot *slot = (struct pccard_slot *) pch;
    376       1.1   aymeric 
    377       1.1   aymeric 	pcihp->iot = &slot->sc->io_space;
    378      1.16  jandberg 	bus_space_map(pcihp->iot, offset, size, 0, &pcihp->ioh);
    379       1.1   aymeric 
    380       1.1   aymeric 	*windowp = 0;		/* unused */
    381       1.1   aymeric 	return 0;
    382       1.1   aymeric }
    383       1.1   aymeric 
    384       1.1   aymeric static void
    385      1.11   aymeric pcf_io_unmap(pcmcia_chipset_handle_t pch, int win)
    386       1.1   aymeric {
    387       1.1   aymeric }
    388       1.1   aymeric 
    389       1.1   aymeric static void *
    390      1.11   aymeric pcf_intr_establish(pcmcia_chipset_handle_t pch, struct pcmcia_function *pf,
    391      1.11   aymeric 		   int ipl, int (*func)(void *), void *arg)
    392       1.1   aymeric {
    393       1.1   aymeric 	struct pccard_slot *slot = (struct pccard_slot *) pch;
    394       1.1   aymeric 	int s;
    395       1.1   aymeric 
    396       1.1   aymeric 	s = splhigh();
    397       1.1   aymeric 	if (slot->intr_func == NULL) {
    398       1.1   aymeric 		slot->intr_func = func;
    399       1.1   aymeric 		slot->intr_arg = arg;
    400       1.1   aymeric 	} else {
    401       1.1   aymeric 		/* if we are here, we need to put intrs into a list */
    402       1.6   aymeric 		printf("ARGH! see " __FILE__ "\n");
    403       1.1   aymeric 		slot = NULL;
    404       1.1   aymeric 	}
    405       1.1   aymeric 	splx(s);
    406       1.1   aymeric 
    407       1.1   aymeric 	return slot;
    408       1.1   aymeric }
    409       1.1   aymeric 
    410       1.1   aymeric static void
    411      1.11   aymeric pcf_intr_disestablish(pcmcia_chipset_handle_t pch, void *intr_handler)
    412       1.1   aymeric {
    413       1.1   aymeric 	struct pccard_slot *slot = (struct pccard_slot *) intr_handler;
    414       1.1   aymeric 
    415       1.1   aymeric 	if (slot != NULL) {
    416       1.1   aymeric 		slot->intr_func = NULL;
    417       1.1   aymeric 		slot->intr_arg = NULL;
    418       1.1   aymeric 	}
    419       1.1   aymeric }
    420       1.1   aymeric 
    421       1.1   aymeric static void
    422      1.11   aymeric pcf_socket_enable(pcmcia_chipset_handle_t pch)
    423       1.1   aymeric {
    424       1.1   aymeric }
    425       1.1   aymeric 
    426       1.1   aymeric static void
    427      1.11   aymeric pcf_socket_disable(pcmcia_chipset_handle_t pch)
    428       1.1   aymeric {
    429       1.1   aymeric }
    430       1.1   aymeric 
    431      1.15   aymeric static void
    432      1.15   aymeric pcf_socket_settype(pcmcia_chipset_handle_t pch, int type) {
    433      1.15   aymeric }
    434       1.1   aymeric 
    435       1.1   aymeric static u_int8_t
    436      1.11   aymeric pcmio_bsr1(bus_space_handle_t h, bus_size_t o)
    437       1.1   aymeric {
    438      1.11   aymeric 
    439       1.1   aymeric 	return *((volatile u_int8_t *) h + o + (o & 1 ? 0xffff : 0));
    440       1.1   aymeric }
    441       1.1   aymeric 
    442       1.1   aymeric static void
    443      1.11   aymeric pcmio_bsw1(bus_space_handle_t h, bus_size_t o, unsigned v)
    444       1.1   aymeric {
    445      1.11   aymeric 
    446       1.1   aymeric 	*((volatile u_int8_t *) h + o + (o & 1 ? 0xffff : 0)) = v;
    447       1.1   aymeric }
    448       1.1   aymeric 
    449       1.1   aymeric static void
    450      1.11   aymeric pcmio_bsrm1(bus_space_handle_t h, bus_size_t o, u_int8_t *p, bus_size_t c)
    451       1.1   aymeric {
    452      1.11   aymeric 	volatile u_int8_t *src = (volatile u_int8_t *)
    453      1.11   aymeric 		(h + o + (o & 1 ? 0xffff : 0));
    454       1.1   aymeric 
    455       1.1   aymeric 
    456       1.1   aymeric 	/* XXX we can (should, must) optimize this if c >= 4 */
    457       1.1   aymeric 	for (; c > 0; c--)
    458       1.1   aymeric 		*p++ = *src;
    459       1.1   aymeric }
    460       1.1   aymeric 
    461       1.1   aymeric 
    462       1.1   aymeric static void
    463      1.11   aymeric pcmio_bswm1(bus_space_handle_t h, bus_size_t o, const u_int8_t *p, bus_size_t c)
    464       1.1   aymeric {
    465      1.11   aymeric 	volatile u_int8_t *dst = (volatile u_int8_t *)
    466      1.11   aymeric 		(h + o + (o & 1 ? 0xffff : 0));
    467       1.1   aymeric 
    468       1.1   aymeric 
    469       1.1   aymeric 	/* XXX we can (should, must) optimize this if c >= 4 */
    470       1.1   aymeric 	for (; c > 0; c--)
    471       1.1   aymeric 		*dst = *p++;
    472       1.1   aymeric }
    473       1.1   aymeric 
    474       1.1   aymeric static void
    475      1.11   aymeric pcmio_bsrr1(bus_space_handle_t h, bus_size_t o, u_int8_t *p, bus_size_t c)
    476       1.1   aymeric {
    477       1.1   aymeric 	volatile u_int8_t *cp1;
    478       1.1   aymeric 	volatile u_int8_t *cp2;
    479       1.1   aymeric 	volatile u_int8_t *temp;
    480       1.1   aymeric 
    481       1.1   aymeric 	if (o & 1) {
    482       1.1   aymeric 		cp1 = (volatile u_int8_t *) h + o + 0x10000;
    483       1.1   aymeric 		cp2 = (volatile u_int8_t *) h + o;
    484       1.1   aymeric 	} else {
    485       1.1   aymeric 		cp1 = (volatile u_int8_t *) h + o;
    486       1.1   aymeric 		cp2 = (volatile u_int8_t *) h + o + 0x10000 + 2;
    487       1.1   aymeric 	}
    488       1.1   aymeric 
    489       1.1   aymeric 	/* XXX we can (should, must) optimize this if c >= 4 */
    490       1.1   aymeric 	for (; c > 0; c--) {
    491       1.1   aymeric 		*p++ = *cp1;
    492       1.1   aymeric 		cp1 += 2;
    493       1.1   aymeric 
    494       1.1   aymeric 		/* swap pointers - hope gcc generates exg for this ;) */
    495       1.1   aymeric 		temp = cp1;
    496       1.1   aymeric 		cp1 = cp2;
    497       1.1   aymeric 		cp2 = temp;
    498       1.1   aymeric 	}
    499       1.1   aymeric }
    500       1.1   aymeric 
    501       1.1   aymeric 
    502       1.1   aymeric static void
    503      1.11   aymeric pcmio_bswr1(bus_space_handle_t h, bus_size_t o, const u_int8_t *p, bus_size_t c)
    504       1.1   aymeric {
    505       1.1   aymeric 	volatile u_int8_t *cp1;
    506       1.1   aymeric 	volatile u_int8_t *cp2;
    507       1.1   aymeric 	volatile u_int8_t *temp;
    508       1.1   aymeric 
    509       1.1   aymeric 	if (o & 1) {
    510       1.1   aymeric 		cp1 = (volatile u_int8_t *) h + o + 0x10000;
    511       1.1   aymeric 		cp2 = (volatile u_int8_t *) h + o;
    512       1.1   aymeric 	} else {
    513       1.1   aymeric 		cp1 = (volatile u_int8_t *) h + o;
    514       1.1   aymeric 		cp2 = (volatile u_int8_t *) h + o + 0x10000 + 2;
    515       1.1   aymeric 	}
    516       1.1   aymeric 
    517       1.1   aymeric 	/* XXX we can (should, must) optimize this if c >= 4 */
    518       1.1   aymeric 	for (; c > 0; c--) {
    519       1.1   aymeric 		*cp1 = *p++;
    520       1.1   aymeric 		cp1 += 2;
    521       1.1   aymeric 
    522       1.1   aymeric 		/* swap pointers - hope gcc generates exg for this ;) */
    523       1.1   aymeric 		temp = cp1;
    524       1.1   aymeric 		cp1 = cp2;
    525       1.1   aymeric 		cp2 = temp;
    526       1.1   aymeric 	}
    527       1.1   aymeric }
    528       1.1   aymeric 
    529       1.1   aymeric void
    530      1.11   aymeric pcmio_bssr1(bus_space_handle_t h, bus_size_t o, unsigned v, bus_size_t c)
    531       1.1   aymeric {
    532      1.11   aymeric 
    533       1.1   aymeric 	panic("pcmio_bssr1 is not defined (" __FILE__ ")");
    534       1.1   aymeric }
    535       1.1   aymeric 
    536       1.1   aymeric void
    537      1.11   aymeric pcmio_bscr1(bus_space_handle_t h, bus_size_t o, bus_space_handle_t g,
    538      1.11   aymeric 	    bus_size_t q, bus_size_t c)
    539       1.1   aymeric {
    540      1.11   aymeric 
    541       1.1   aymeric 	panic("pcmio_bscr1 is not defined (" __FILE__ ")");
    542       1.1   aymeric }
    543