Home | History | Annotate | Line # | Download | only in include
pci_machdep.h revision 1.1
      1 /*	$NetBSD: pci_machdep.h,v 1.1 2011/08/04 17:48:51 rkujawa Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2011 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Radoslaw Kujawa.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _AMIGA_PCI_MACHDEP_H_
     33 #define _AMIGA_PCI_MACHDEP_H_
     34 
     35 #include <sys/bus.h>
     36 
     37 #include <machine/intr.h>
     38 
     39 #include <m68k/bus_dma.h>
     40 
     41 /*
     42  * Forward declarations.
     43  */
     44 struct pci_attach_args;
     45 
     46 /*
     47  * Types provided to machine-independent PCI code
     48  */
     49 typedef struct	amiga_pci_chipset *pci_chipset_tag_t;
     50 typedef u_long	pcitag_t;
     51 typedef u_long	pci_intr_handle_t;
     52 
     53 /*
     54  * amiga-specific PCI structure and type definitions.
     55  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
     56  */
     57 struct amiga_pci_chipset {
     58 	void		*pc_conf_v;
     59 	void		(*pc_attach_hook)(device_t, device_t,
     60 			    struct pcibus_attach_args *);
     61 	int		(*pc_bus_maxdevs)(pci_chipset_tag_t, int);
     62 	pcitag_t	(*pc_make_tag)(pci_chipset_tag_t, int, int, int);
     63 	void		(*pc_decompose_tag)(pci_chipset_tag_t, pcitag_t, int *,
     64 			    int *, int *);
     65 			pcireg_t(*pc_conf_read)(pci_chipset_tag_t, pcitag_t,
     66 			    int);
     67 	void		(*pc_conf_write)(pci_chipset_tag_t, pcitag_t, int,
     68 			    pcireg_t);
     69 	int		(*pc_intr_map)(const struct pci_attach_args *,
     70 			    pci_intr_handle_t *);
     71 	const char	*(*pc_intr_string)(pci_chipset_tag_t,
     72 			    pci_intr_handle_t);
     73 	void		*(*pc_intr_establish)(pci_chipset_tag_t,
     74 			    pci_intr_handle_t, int, int (*) (void *), void *);
     75 	void		(*pc_intr_disestablish)(pci_chipset_tag_t, void *);
     76 	void		(*pc_conf_interrupt)(pci_chipset_tag_t, int, int, int,
     77 			    int, int *);
     78 	int		(*pc_conf_hook)(pci_chipset_tag_t, int, int, int,
     79 			    pcireg_t);
     80 
     81 	bus_space_tag_t pci_conf_iot;
     82 	bus_space_handle_t pci_conf_ioh;
     83 };
     84 
     85 
     86 /*
     87  * Functions provided to machine-independent PCI code.
     88  */
     89 #define	pci_attach_hook(p, s, pba)					\
     90 	(*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
     91 #define	pci_bus_maxdevs(c, b)						\
     92 	(*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
     93 #define	pci_make_tag(c, b, d, f)					\
     94 	(*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
     95 #define	pci_decompose_tag(c, t, bp, dp, fp)				\
     96 	(*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
     97 #define	pci_conf_read(c, t, r)						\
     98 	(*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
     99 #define	pci_conf_write(c, t, r, v)					\
    100 	(*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
    101 #define	pci_intr_map(pa, ihp)						\
    102 	(*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
    103 #define	pci_intr_string(c, ih)						\
    104 	(*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
    105 #define	pci_intr_evcnt(c, ih)						\
    106 	(*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
    107 #define	pci_intr_establish(c, ih, l, h, a)				\
    108 	(*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
    109 #define	pci_intr_disestablish(c, iv)					\
    110 	(*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
    111 
    112 #endif
    113