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