Home | History | Annotate | Line # | Download | only in include
pci_machdep.h revision 1.10.10.1
      1  1.10.10.1  pgoyette /*	$NetBSD: pci_machdep.h,v 1.10.10.1 2017/04/26 02:53:00 pgoyette Exp $	*/
      2        1.1   reinoud 
      3        1.1   reinoud /*
      4        1.1   reinoud  * Modified for arm32 by Mark Brinicombe
      5        1.1   reinoud  *
      6        1.1   reinoud  * from: sys/arch/alpha/pci/pci_machdep.h
      7        1.1   reinoud  *
      8        1.1   reinoud  * Copyright (c) 1996 Carnegie-Mellon University.
      9        1.1   reinoud  * All rights reserved.
     10        1.1   reinoud  *
     11        1.1   reinoud  * Author: Chris G. Demetriou
     12        1.1   reinoud  *
     13        1.1   reinoud  * Permission to use, copy, modify and distribute this software and
     14        1.1   reinoud  * its documentation is hereby granted, provided that both the copyright
     15        1.1   reinoud  * notice and this permission notice appear in all copies of the
     16        1.1   reinoud  * software, derivative works or modified versions, and any portions
     17        1.1   reinoud  * thereof, and that both notices appear in supporting documentation.
     18        1.1   reinoud  *
     19        1.1   reinoud  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     20        1.1   reinoud  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     21        1.1   reinoud  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     22        1.1   reinoud  *
     23        1.1   reinoud  * Carnegie Mellon requests users of this software to return to
     24        1.1   reinoud  *
     25        1.1   reinoud  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     26        1.1   reinoud  *  School of Computer Science
     27        1.1   reinoud  *  Carnegie Mellon University
     28        1.1   reinoud  *  Pittsburgh PA 15213-3890
     29        1.1   reinoud  *
     30        1.1   reinoud  * any improvements or extensions that they make and grant Carnegie the
     31        1.1   reinoud  * rights to redistribute these changes.
     32        1.1   reinoud  */
     33        1.1   reinoud 
     34        1.5  kiyohara #ifndef _ARM_PCI_MACHDEP_H_
     35        1.5  kiyohara #define _ARM_PCI_MACHDEP_H_
     36        1.1   reinoud /*
     37        1.1   reinoud  * Machine-specific definitions for PCI autoconfiguration.
     38        1.1   reinoud  */
     39        1.1   reinoud 
     40  1.10.10.1  pgoyette #include <sys/errno.h>
     41  1.10.10.1  pgoyette 
     42        1.1   reinoud /*
     43        1.1   reinoud  * Types provided to machine-independent PCI code
     44        1.1   reinoud  */
     45        1.1   reinoud typedef struct	arm32_pci_chipset	*pci_chipset_tag_t;
     46        1.1   reinoud typedef u_long	pcitag_t;
     47        1.1   reinoud typedef u_long	pci_intr_handle_t;
     48        1.1   reinoud 
     49        1.1   reinoud /*
     50        1.1   reinoud  * Forward declarations.
     51        1.1   reinoud  */
     52        1.1   reinoud struct pci_attach_args;
     53        1.1   reinoud 
     54        1.1   reinoud /*
     55        1.1   reinoud  * arm32-specific PCI structure and type definitions.
     56        1.1   reinoud  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
     57        1.1   reinoud  */
     58        1.1   reinoud struct arm32_pci_chipset {
     59        1.1   reinoud 	void		*pc_conf_v;
     60        1.8      matt 	void		(*pc_attach_hook)(device_t, device_t,
     61        1.8      matt 			    struct pcibus_attach_args *);
     62        1.1   reinoud 	int		(*pc_bus_maxdevs)(void *, int);
     63        1.1   reinoud 	pcitag_t	(*pc_make_tag)(void *, int, int, int);
     64        1.1   reinoud 	void		(*pc_decompose_tag)(void *, pcitag_t, int *,
     65        1.1   reinoud 			    int *, int *);
     66        1.1   reinoud 	pcireg_t	(*pc_conf_read)(void *, pcitag_t, int);
     67        1.1   reinoud 	void		(*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
     68        1.1   reinoud 
     69        1.1   reinoud 	void		*pc_intr_v;
     70        1.7    dyoung 	int		(*pc_intr_map)(const struct pci_attach_args *,
     71        1.1   reinoud 			    pci_intr_handle_t *);
     72       1.10  christos 	const char	*(*pc_intr_string)(void *, pci_intr_handle_t,
     73       1.10  christos 			    char *, size_t);
     74        1.1   reinoud 	const struct evcnt *(*pc_intr_evcnt)(void *, pci_intr_handle_t);
     75  1.10.10.1  pgoyette 	int		(*pc_intr_setattr)(void *, pci_intr_handle_t *,
     76  1.10.10.1  pgoyette 			    int, uint64_t);
     77        1.1   reinoud 	void		*(*pc_intr_establish)(void *, pci_intr_handle_t,
     78        1.1   reinoud 			    int, int (*)(void *), void *);
     79        1.1   reinoud 	void		(*pc_intr_disestablish)(void *, void *);
     80        1.6      matt 
     81        1.6      matt #ifdef __HAVE_PCI_CONF_HOOK
     82        1.9      matt 	int		(*pc_conf_hook)(void *, int, int, int, pcireg_t);
     83        1.6      matt #endif
     84        1.9      matt 	void		(*pc_conf_interrupt)(void *, int, int, int, int, int *);
     85        1.6      matt 
     86        1.6      matt 	uint32_t	pc_cfg_cmd;
     87        1.1   reinoud };
     88        1.1   reinoud 
     89        1.1   reinoud /*
     90        1.1   reinoud  * Functions provided to machine-independent PCI code.
     91        1.1   reinoud  */
     92        1.1   reinoud #define	pci_attach_hook(p, s, pba)					\
     93        1.1   reinoud     (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
     94        1.1   reinoud #define	pci_bus_maxdevs(c, b)						\
     95        1.1   reinoud     (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
     96        1.1   reinoud #define	pci_make_tag(c, b, d, f)					\
     97        1.1   reinoud     (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
     98        1.1   reinoud #define	pci_decompose_tag(c, t, bp, dp, fp)				\
     99        1.1   reinoud     (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
    100        1.1   reinoud #define	pci_conf_read(c, t, r)						\
    101        1.1   reinoud     (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
    102        1.1   reinoud #define	pci_conf_write(c, t, r, v)					\
    103        1.1   reinoud     (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
    104        1.1   reinoud #define	pci_intr_map(pa, ihp)						\
    105        1.1   reinoud     (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
    106       1.10  christos #define	pci_intr_string(c, ih, buf, len)				\
    107       1.10  christos     (*(c)->pc_intr_string)((c)->pc_intr_v, (ih), (buf), (len))
    108        1.1   reinoud #define	pci_intr_evcnt(c, ih)						\
    109        1.1   reinoud     (*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
    110        1.1   reinoud #define	pci_intr_establish(c, ih, l, h, a)				\
    111        1.1   reinoud     (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
    112        1.1   reinoud #define	pci_intr_disestablish(c, iv)					\
    113        1.1   reinoud     (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
    114        1.6      matt #ifdef __HAVE_PCI_CONF_HOOK
    115        1.6      matt #define	pci_conf_hook(c, b, d, f, id)					\
    116        1.9      matt     (*(c)->pc_conf_hook)((c)->pc_conf_v, (b), (d), (f), (id))
    117        1.6      matt #endif
    118        1.9      matt #define	pci_conf_interrupt(c, b, d, i, s, p)				\
    119        1.9      matt     (*(c)->pc_conf_interrupt)((c)->pc_conf_v, (b), (d), (i), (s), (p))
    120        1.5  kiyohara 
    121  1.10.10.1  pgoyette static inline int
    122  1.10.10.1  pgoyette pci_intr_setattr(pci_chipset_tag_t pc, pci_intr_handle_t *ihp,
    123  1.10.10.1  pgoyette     int attr, uint64_t data)
    124  1.10.10.1  pgoyette {
    125  1.10.10.1  pgoyette 	if (!pc->pc_intr_setattr)
    126  1.10.10.1  pgoyette 		return ENODEV;
    127  1.10.10.1  pgoyette 	return pc->pc_intr_setattr(pc, ihp, attr, data);
    128  1.10.10.1  pgoyette }
    129  1.10.10.1  pgoyette 
    130        1.5  kiyohara #endif	/* _ARM_PCI_MACHDEP_H_ */
    131