Home | History | Annotate | Line # | Download | only in pci
btvmeivar.h revision 1.6
      1 /* $NetBSD: btvmeivar.h,v 1.6 2023/12/05 14:58:01 thorpej Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1999
      5  *	Matthias Drochner.  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. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  *
     16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  *
     27  */
     28 
     29 #include <sys/vmem.h>
     30 
     31 struct b3_617_vmeintrhand {
     32 	TAILQ_ENTRY(b3_617_vmeintrhand) ih_next;
     33 	int (*ih_fun)(void*);
     34 	void *ih_arg;
     35 	int ih_level;
     36 	int ih_vector;
     37 	int ih_prior;
     38 	u_long ih_count;
     39 };
     40 
     41 struct b3_617_softc {
     42 	device_t sc_dev;
     43 
     44 	/* tags passed in from PCI */
     45 	pci_chipset_tag_t sc_pc;
     46 	bus_space_tag_t csrt, mapt;
     47 	bus_space_handle_t csrh, maph;
     48 	bus_addr_t vmepbase; /* physical PCI address */
     49 	bus_dma_tag_t sc_dmat;
     50 	void *sc_ih;
     51 
     52 	bus_space_tag_t sc_vmet;
     53 
     54 	struct vme_range csrwindow, dmawindow24, dmawindow32;
     55 
     56 	/* tags passed to VME devices */
     57 	struct vme_chipset_tag sc_vct;
     58 
     59 	/* list of VME interrupt handlers */
     60 	TAILQ_HEAD(, b3_617_vmeintrhand) intrhdls;
     61 	int strayintrs;
     62 
     63 	/*
     64 	 * management of adapter mapping tables
     65 	 */
     66 	vmem_t *vme_arena;
     67 };
     68 
     69 #define read_csr_byte(sc, reg) \
     70   bus_space_read_1(sc->csrt, sc->csrh, reg)
     71 #define write_csr_byte(sc, reg, val) \
     72   bus_space_write_1(sc->csrt, sc->csrh, reg, val)
     73 #define read_csr_word(sc, reg) \
     74   bus_space_read_2(sc->csrt, sc->csrh, reg)
     75 #define write_csr_word(sc, reg, val) \
     76   bus_space_write_2(sc->csrt, sc->csrh, reg, val)
     77 
     78 #define write_mapmem(sc, ofs, val) \
     79   bus_space_write_4(sc->mapt, sc->maph, ofs, val)
     80 #define read_mapmem(sc, ofs) \
     81   bus_space_read_4(sc->mapt, sc->maph, ofs)
     82 
     83 #define VME_PAGESIZE 0x1000
     84 #define PCI_PAGESIZE 0x1000
     85 #define DMA_PAGESIZE 0x1000
     86 
     87 /* shared between driver parts */
     88 int b3_617_reset(struct b3_617_softc*);
     89 int b3_617_init(struct b3_617_softc*);
     90 #ifdef notyet /* for detach */
     91 void b3_617_halt(struct b3_617_softc*);
     92 #endif
     93 int b3_617_intr(void*);
     94 #if 0
     95 void b3_617_cntlrdma_done(struct b3_617_softc*);
     96 #endif
     97 
     98 /* exported via tag structs */
     99 int b3_617_map_vme(void *, vme_addr_t, vme_size_t,
    100 			vme_am_t, vme_datasize_t, vme_swap_t,
    101 			bus_space_tag_t *, bus_space_handle_t *,
    102 			vme_mapresc_t*);
    103 void b3_617_unmap_vme(void *, vme_mapresc_t);
    104 
    105 int b3_617_vme_probe(void *, vme_addr_t, vme_size_t, vme_am_t,
    106 			  vme_datasize_t,
    107 			  int (*)(void *, bus_space_tag_t, bus_space_handle_t),
    108 			  void *);
    109 
    110 int b3_617_map_vmeint(void *, int, int, vme_intr_handle_t *);
    111 void *b3_617_establish_vmeint(void *, vme_intr_handle_t, int,
    112 				   int (*)(void *), void *);
    113 void b3_617_disestablish_vmeint(void *, void *);
    114 
    115 int b3_617_dmamap_create(void *, vme_size_t,
    116 			      vme_am_t, vme_datasize_t, vme_swap_t,
    117 			      int, vme_size_t, vme_addr_t,
    118 			      int, bus_dmamap_t *);
    119 void b3_617_dmamap_destroy(void *, bus_dmamap_t);
    120 
    121 int b3_617_dmamem_alloc(void *, vme_size_t,
    122 			     vme_am_t, vme_datasize_t, vme_swap_t,
    123 			     bus_dma_segment_t *, int, int *, int);
    124 void b3_617_dmamem_free(void *, bus_dma_segment_t *, int);
    125