xref: /freebsd/sys/x86/include/pci_cfgreg.h (revision f54a3890b1f419d4a9edc99000efef52b9071b8f)
11368987aSJohn Baldwin /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3ebf5747bSPedro F. Giffuni  *
41368987aSJohn Baldwin  * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
51368987aSJohn Baldwin  * All rights reserved.
61368987aSJohn Baldwin  *
71368987aSJohn Baldwin  * Redistribution and use in source and binary forms, with or without
81368987aSJohn Baldwin  * modification, are permitted provided that the following conditions
91368987aSJohn Baldwin  * are met:
101368987aSJohn Baldwin  * 1. Redistributions of source code must retain the above copyright
111368987aSJohn Baldwin  *    notice unmodified, this list of conditions, and the following
121368987aSJohn Baldwin  *    disclaimer.
131368987aSJohn Baldwin  * 2. Redistributions in binary form must reproduce the above copyright
141368987aSJohn Baldwin  *    notice, this list of conditions and the following disclaimer in the
151368987aSJohn Baldwin  *    documentation and/or other materials provided with the distribution.
161368987aSJohn Baldwin  *
171368987aSJohn Baldwin  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
181368987aSJohn Baldwin  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
191368987aSJohn Baldwin  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
201368987aSJohn Baldwin  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
211368987aSJohn Baldwin  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
221368987aSJohn Baldwin  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231368987aSJohn Baldwin  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241368987aSJohn Baldwin  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251368987aSJohn Baldwin  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
261368987aSJohn Baldwin  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271368987aSJohn Baldwin  *
281368987aSJohn Baldwin  */
291368987aSJohn Baldwin 
301368987aSJohn Baldwin #ifndef __X86_PCI_CFGREG_H__
311368987aSJohn Baldwin #define	__X86_PCI_CFGREG_H__
321368987aSJohn Baldwin 
331368987aSJohn Baldwin #define CONF1_ADDR_PORT    0x0cf8
341368987aSJohn Baldwin #define CONF1_DATA_PORT    0x0cfc
351368987aSJohn Baldwin 
361368987aSJohn Baldwin #define CONF1_ENABLE       0x80000000ul
371368987aSJohn Baldwin #define CONF1_ENABLE_CHK   0x80000000ul
381368987aSJohn Baldwin #define CONF1_ENABLE_MSK   0x7f000000ul
391368987aSJohn Baldwin #define CONF1_ENABLE_CHK1  0xff000001ul
401368987aSJohn Baldwin #define CONF1_ENABLE_MSK1  0x80000001ul
411368987aSJohn Baldwin #define CONF1_ENABLE_RES1  0x80000000ul
421368987aSJohn Baldwin 
431368987aSJohn Baldwin #define CONF2_ENABLE_PORT  0x0cf8
441368987aSJohn Baldwin #define CONF2_FORWARD_PORT 0x0cfa
451368987aSJohn Baldwin 
461368987aSJohn Baldwin #define CONF2_ENABLE_CHK   0x0e
471368987aSJohn Baldwin #define CONF2_ENABLE_RES   0x0e
481368987aSJohn Baldwin 
492a508645SKonstantin Belousov enum {
502a508645SKonstantin Belousov 	CFGMECH_NONE = 0,
512a508645SKonstantin Belousov 	CFGMECH_1,
522a508645SKonstantin Belousov 	CFGMECH_2,
532a508645SKonstantin Belousov 	CFGMECH_PCIE,
542a508645SKonstantin Belousov };
552a508645SKonstantin Belousov 
562a508645SKonstantin Belousov extern int cfgmech;
572a508645SKonstantin Belousov 
582dd1bdf1SJustin Hibbits rman_res_t	hostb_alloc_start(int type, rman_res_t start, rman_res_t end, rman_res_t count);
59*f54a3890SJohn Baldwin int		pcie_cfgregopen(uint64_t base, uint16_t domain, uint8_t minbus, uint8_t maxbus);
601368987aSJohn Baldwin int		pci_cfgregopen(void);
611587a9dbSJohn Baldwin u_int32_t	pci_cfgregread(int domain, int bus, int slot, int func, int reg, int bytes);
621587a9dbSJohn Baldwin void		pci_cfgregwrite(int domain, int bus, int slot, int func, int reg, u_int32_t data, int bytes);
631368987aSJohn Baldwin #ifdef __HAVE_PIR
641368987aSJohn Baldwin void		pci_pir_open(void);
651368987aSJohn Baldwin int		pci_pir_probe(int bus, int require_parse);
661368987aSJohn Baldwin int		pci_pir_route_interrupt(int bus, int device, int func, int pin);
671368987aSJohn Baldwin #endif
681368987aSJohn Baldwin 
691368987aSJohn Baldwin #endif /* !__X86_PCI_CFGREG_H__ */
70