1 1.1 skrll /* $NetBSD: pcihost_fdtvar.h,v 1.1 2026/09/20 11:00:34 skrll Exp $ */ 2 1.1 skrll 3 1.1 skrll /*- 4 1.1 skrll * Copyright (c) 2018 Jared D. McNeill <jmcneill (at) invisible.ca> 5 1.1 skrll * All rights reserved. 6 1.1 skrll * 7 1.1 skrll * Redistribution and use in source and binary forms, with or without 8 1.1 skrll * modification, are permitted provided that the following conditions 9 1.1 skrll * are met: 10 1.1 skrll * 1. Redistributions of source code must retain the above copyright 11 1.1 skrll * notice, this list of conditions and the following disclaimer. 12 1.1 skrll * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 skrll * notice, this list of conditions and the following disclaimer in the 14 1.1 skrll * documentation and/or other materials provided with the distribution. 15 1.1 skrll * 16 1.1 skrll * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 1.1 skrll * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 1.1 skrll * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 1.1 skrll * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 1.1 skrll * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 1.1 skrll * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 1.1 skrll * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 1.1 skrll * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 1.1 skrll * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 1.1 skrll * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 1.1 skrll * SUCH DAMAGE. 27 1.1 skrll */ 28 1.1 skrll 29 1.1 skrll #include <machine/pci_machdep.h> 30 1.1 skrll 31 1.1 skrll /* Physical address format bit definitions */ 32 1.1 skrll #define PHYS_HI_RELO __BIT(31) 33 1.1 skrll #define PHYS_HI_PREFETCH __BIT(30) 34 1.1 skrll #define PHYS_HI_ALIASED __BIT(29) 35 1.1 skrll #define PHYS_HI_SPACE __BITS(25,24) 36 1.1 skrll #define PHYS_HI_SPACE_CFG 0 37 1.1 skrll #define PHYS_HI_SPACE_IO 1 38 1.1 skrll #define PHYS_HI_SPACE_MEM32 2 39 1.1 skrll #define PHYS_HI_SPACE_MEM64 3 40 1.1 skrll #define PHYS_HI_BUS __BITS(23,16) 41 1.1 skrll #define PHYS_HI_DEVICE __BITS(15,11) 42 1.1 skrll #define PHYS_HI_FUNCTION __BITS(10,8) 43 1.1 skrll #define PHYS_HI_REGISTER __BITS(7,0) 44 1.1 skrll 45 1.1 skrll extern int pcihost_segment; 46 1.1 skrll 47 1.1 skrll enum pcihost_type { 48 1.1 skrll PCIHOST_CAM = 1, 49 1.1 skrll PCIHOST_ECAM, 50 1.1 skrll }; 51 1.1 skrll 52 1.1 skrll struct pcihost_msi_handlers; 53 1.1 skrll 54 1.1 skrll struct pcih_bus_space { 55 1.1 skrll struct bus_space bst; 56 1.1 skrll 57 1.1 skrll int (*map)(void *, bus_addr_t, bus_size_t, 58 1.1 skrll int, bus_space_handle_t *); 59 1.1 skrll int flags; 60 1.1 skrll 61 1.1 skrll struct space_range { 62 1.1 skrll bus_addr_t bpci; 63 1.1 skrll bus_addr_t bbus; 64 1.1 skrll bus_size_t size; 65 1.1 skrll } ranges[4]; 66 1.1 skrll size_t nranges; 67 1.1 skrll }; 68 1.1 skrll 69 1.1 skrll struct pcihost_softc { 70 1.1 skrll device_t sc_dev; 71 1.1 skrll bus_dma_tag_t sc_dmat; 72 1.1 skrll bus_space_tag_t sc_bst; 73 1.1 skrll bus_space_handle_t sc_bsh; 74 1.1 skrll bus_space_tag_t sc_pci_bst; 75 1.1 skrll int sc_phandle; 76 1.1 skrll 77 1.1 skrll enum pcihost_type sc_type; 78 1.1 skrll 79 1.1 skrll u_int sc_seg; 80 1.1 skrll u_int sc_bus_min; 81 1.1 skrll u_int sc_bus_max; 82 1.1 skrll 83 1.1 skrll struct md_pci_chipset sc_pc; 84 1.1 skrll 85 1.1 skrll struct pcih_bus_space sc_io; 86 1.1 skrll struct pcih_bus_space sc_mem; 87 1.1 skrll 88 1.1 skrll int sc_pci_flags; 89 1.1 skrll 90 1.1 skrll const u_int *sc_pci_ranges; 91 1.1 skrll u_int sc_pci_ranges_cells; 92 1.1 skrll 93 1.1 skrll #ifdef __HAVE_PCI_MSI_MSIX 94 1.1 skrll kmutex_t sc_msi_handlers_mutex; 95 1.1 skrll LIST_HEAD(, pcihost_msi_handler) 96 1.1 skrll sc_msi_handlers; 97 1.1 skrll #endif 98 1.1 skrll }; 99 1.1 skrll 100 1.1 skrll void pcihost_init2(struct pcihost_softc *); 101 1.1 skrll void pcihost_init(pci_chipset_tag_t, void *); 102