xref: /netbsd-src/sys/arch/cobalt/include/pci_machdep.h (revision ca8ce3aeb13a6d3fb3deb6cd56d1d0e3d824199c)
1*ca8ce3aeSthorpej /*	$NetBSD: pci_machdep.h,v 1.15 2020/07/07 03:38:46 thorpej Exp $	*/
24c547143Ssoren 
34c547143Ssoren /*
44c547143Ssoren  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
54c547143Ssoren  * Copyright (c) 1994 Charles M. Hannum.  All rights reserved.
64c547143Ssoren  *
74c547143Ssoren  * Redistribution and use in source and binary forms, with or without
84c547143Ssoren  * modification, are permitted provided that the following conditions
94c547143Ssoren  * are met:
104c547143Ssoren  * 1. Redistributions of source code must retain the above copyright
114c547143Ssoren  *    notice, this list of conditions and the following disclaimer.
124c547143Ssoren  * 2. Redistributions in binary form must reproduce the above copyright
134c547143Ssoren  *    notice, this list of conditions and the following disclaimer in the
144c547143Ssoren  *    documentation and/or other materials provided with the distribution.
154c547143Ssoren  * 3. All advertising materials mentioning features or use of this software
164c547143Ssoren  *    must display the following acknowledgement:
174c547143Ssoren  *	This product includes software developed by Charles M. Hannum.
184c547143Ssoren  * 4. The name of the author may not be used to endorse or promote products
194c547143Ssoren  *    derived from this software without specific prior written permission.
204c547143Ssoren  *
214c547143Ssoren  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
224c547143Ssoren  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
234c547143Ssoren  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
244c547143Ssoren  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
254c547143Ssoren  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
264c547143Ssoren  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
274c547143Ssoren  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
284c547143Ssoren  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
294c547143Ssoren  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
304c547143Ssoren  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
314c547143Ssoren  */
324c547143Ssoren 
334c547143Ssoren /*
344c547143Ssoren  * Machine-specific definitions for PCI autoconfiguration.
354c547143Ssoren  */
36e5bd00e4Ssimonb #define	__HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
37120ecb16Stsutsui #define	__HAVE_PCI_CONF_HOOK
384c547143Ssoren 
394c547143Ssoren /*
40851de295Ssommerfeld  * Forward declarations.
41851de295Ssommerfeld  */
42851de295Ssommerfeld struct pci_attach_args;
43851de295Ssommerfeld 
44851de295Ssommerfeld /*
454c547143Ssoren  * Cobalt-specific PCI structure and type definitions.
464c547143Ssoren  * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
474c547143Ssoren  */
484c547143Ssoren 
49d28c36d4Sskrll extern struct mips_bus_dma_tag pci_bus_dma_tag;
504c547143Ssoren 
514c547143Ssoren /*
524c547143Ssoren  * Types provided to machine-independent PCI code
534c547143Ssoren  */
54106c596dStsutsui typedef struct cobalt_pci_chipset *pci_chipset_tag_t;
556abe9ac9Stsutsui typedef uint32_t	pcitag_t;
564c547143Ssoren typedef int 		pci_intr_handle_t;
574c547143Ssoren 
58106c596dStsutsui struct cobalt_pci_chipset {
59106c596dStsutsui 	bus_space_tag_t pc_bst;		/* bus space tag for PCICFG regs */
60106c596dStsutsui 	bus_space_handle_t pc_bsh;	/* bus space handle for PCICFG regs */
61106c596dStsutsui };
62106c596dStsutsui 
634c547143Ssoren /*
644c547143Ssoren  * Functions provided to machine-independent PCI code.
654c547143Ssoren  */
66cbab9cadSchs void		pci_attach_hook(device_t, device_t,
674c547143Ssoren 			struct pcibus_attach_args *);
684c547143Ssoren int		pci_bus_maxdevs(pci_chipset_tag_t, int);
694c547143Ssoren pcitag_t	pci_make_tag(pci_chipset_tag_t, int, int, int);
704c547143Ssoren void		pci_decompose_tag(pci_chipset_tag_t, pcitag_t,
714c547143Ssoren 			int *, int *, int *);
724c547143Ssoren pcireg_t	pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
734c547143Ssoren void		pci_conf_write(pci_chipset_tag_t, pcitag_t, int,
744c547143Ssoren 			pcireg_t);
75a184f1f4Sdyoung int		pci_intr_map(const struct pci_attach_args *,
76a184f1f4Sdyoung 			pci_intr_handle_t *);
77e58a356cSchristos const char	*pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t, char *, size_t);
78cffb5808Scgd const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t);
794c547143Ssoren void		*pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t,
804c547143Ssoren 			int, int (*)(void *), void *);
814c547143Ssoren void		pci_intr_disestablish(pci_chipset_tag_t, void *);
82120ecb16Stsutsui void		pci_conf_interrupt(pci_chipset_tag_t, int, int, int, int,
83120ecb16Stsutsui 			int *);
84120ecb16Stsutsui int		pci_conf_hook(pci_chipset_tag_t, int, int, int, pcireg_t);
85