Home | History | Annotate | Line # | Download | only in marvell
gtpcivar.h revision 1.2
      1 /*	$NetBSD: gtpcivar.h,v 1.2 2003/03/16 07:05:34 matt Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc.
      5  * 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  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed for the NetBSD Project by
     18  *      Allegro Networks, Inc., and Wasabi Systems, Inc.
     19  * 4. The name of Allegro Networks, Inc. may not be used to endorse
     20  *    or promote products derived from this software without specific prior
     21  *    written permission.
     22  * 5. The name of Wasabi Systems, Inc. may not be used to endorse
     23  *    or promote products derived from this software without specific prior
     24  *    written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY ALLEGRO NETWORKS, INC. AND
     27  * WASABI SYSTEMS, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
     28  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
     29  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     30  * IN NO EVENT SHALL EITHER ALLEGRO NETWORKS, INC. OR WASABI SYSTEMS, INC.
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 #ifndef _DEV_MARVELL_GTPCIVAR_H
     41 #define _DEV_MARVELL_GTPCIVAR_H
     42 
     43 /*
     44  */
     45 struct gtpci_chipset {
     46 	struct pci_chipset gtpc_pc;
     47 	int gtpc_busno;
     48 	bus_space_tag_t gtpc_io_bs;
     49 	bus_space_tag_t gtpc_mem_bs;
     50 	bus_space_tag_t gtpc_gt_memt;
     51 	bus_space_handle_t gtpc_gt_memh;
     52 	bus_size_t gtpc_cfgaddr;
     53 	bus_size_t gtpc_cfgdata;
     54 	bus_size_t gtpc_syncreg;
     55 };
     56 
     57 
     58 #ifdef _KERNEL
     59 static uint32_t __inline
     60 gtpci_read(struct gtpci_chipset *gtpc, bus_size_t reg)
     61 {
     62 	uint32_t rv;
     63 	(void) bus_space_read_4(gtpc->gtpc_gt_memt, gtpc->gtpc_gt_memh,
     64 	    gtpc->gtpc_syncreg);
     65 	rv = bus_space_read_4(gtpc->gtpc_gt_memt, gtpc->gtpc_gt_memh, reg);
     66 	(void) bus_space_read_4(gtpc->gtpc_gt_memt, gtpc->gtpc_gt_memh,
     67 	    gtpc->gtpc_syncreg);
     68 	return rv;
     69 }
     70 
     71 static void __inline
     72 gtpci_write(struct gtpci_chipset *gtpc, bus_size_t reg, uint32_t val)
     73 {
     74 	(void) bus_space_read_4(gtpc->gtpc_gt_memt, gtpc->gtpc_gt_memh,
     75 	    gtpc->gtpc_syncreg);
     76 	bus_space_write_4(gtpc->gtpc_gt_memt, gtpc->gtpc_gt_memh, reg, val);
     77 	(void) bus_space_read_4(gtpc->gtpc_gt_memt, gtpc->gtpc_gt_memh,
     78 	    gtpc->gtpc_syncreg);
     79 }
     80 
     81 pcitag_t gtpci_make_tag(pci_chipset_tag_t, int, int, int);
     82 void	gtpci_decompose_tag(pci_chipset_tag_t, pcitag_t, int *, int *, int *);
     83 pcireg_t gtpci_conf_read(pci_chipset_tag_t, pcitag_t, int);
     84 void	gtpci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
     85 
     86 void	gtpci_md_bus_devorder(pci_chipset_tag_t, int, char []);
     87 int	gtpci_md_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
     88 int	gtpci_md_conf_hook(pci_chipset_tag_t, int, int, int, pcireg_t);
     89 void	gtpci_md_conf_interrupt(pci_chipset_tag_t, int, int, int, int, int *);
     90 #endif /* _KERNEL */
     91 
     92 #endif /* _DEV_MARVELL_GTPCIVAR_H */
     93