1c43a8674SZbigniew Bodek /*- 2c43a8674SZbigniew Bodek * Copyright (c) 2011 Nathan Whitehorn 3c43a8674SZbigniew Bodek * All rights reserved. 4c43a8674SZbigniew Bodek * 5c43a8674SZbigniew Bodek * Redistribution and use in source and binary forms, with or without 6c43a8674SZbigniew Bodek * modification, are permitted provided that the following conditions 7c43a8674SZbigniew Bodek * are met: 8c43a8674SZbigniew Bodek * 1. Redistributions of source code must retain the above copyright 9c43a8674SZbigniew Bodek * notice, this list of conditions and the following disclaimer. 10c43a8674SZbigniew Bodek * 2. Redistributions in binary form must reproduce the above copyright 11c43a8674SZbigniew Bodek * notice, this list of conditions and the following disclaimer in the 12c43a8674SZbigniew Bodek * documentation and/or other materials provided with the distribution. 13c43a8674SZbigniew Bodek * 14c43a8674SZbigniew Bodek * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15c43a8674SZbigniew Bodek * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16c43a8674SZbigniew Bodek * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17c43a8674SZbigniew Bodek * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18c43a8674SZbigniew Bodek * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19c43a8674SZbigniew Bodek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20c43a8674SZbigniew Bodek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21c43a8674SZbigniew Bodek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22c43a8674SZbigniew Bodek * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23c43a8674SZbigniew Bodek * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24c43a8674SZbigniew Bodek * SUCH DAMAGE. 25c43a8674SZbigniew Bodek */ 26c43a8674SZbigniew Bodek 27c43a8674SZbigniew Bodek #ifndef _DEV_OFW_OFWPCI_H_ 28c43a8674SZbigniew Bodek #define _DEV_OFW_OFWPCI_H_ 29c43a8674SZbigniew Bodek 30c43a8674SZbigniew Bodek /* 31c43a8674SZbigniew Bodek * Export class definition for inheritance purposes 32c43a8674SZbigniew Bodek */ 3324042910SMarcin Wojtas DECLARE_CLASS(ofw_pcib_driver); 34c43a8674SZbigniew Bodek 35c43a8674SZbigniew Bodek struct ofw_pci_cell_info { 36c43a8674SZbigniew Bodek pcell_t host_address_cells; 37c43a8674SZbigniew Bodek pcell_t pci_address_cell; 38c43a8674SZbigniew Bodek pcell_t size_cells; 39c43a8674SZbigniew Bodek }; 40c43a8674SZbigniew Bodek 41c43a8674SZbigniew Bodek struct ofw_pci_range { 42c43a8674SZbigniew Bodek uint32_t pci_hi; 43c43a8674SZbigniew Bodek uint64_t pci; 44c43a8674SZbigniew Bodek uint64_t host; 45c43a8674SZbigniew Bodek uint64_t size; 46c43a8674SZbigniew Bodek }; 47c43a8674SZbigniew Bodek 48c43a8674SZbigniew Bodek /* 49c43a8674SZbigniew Bodek * Quirks for some adapters 50c43a8674SZbigniew Bodek */ 51c43a8674SZbigniew Bodek enum { 52c43a8674SZbigniew Bodek OFW_PCI_QUIRK_RANGES_ON_CHILDREN = 1, 53c43a8674SZbigniew Bodek }; 54c43a8674SZbigniew Bodek 55c43a8674SZbigniew Bodek struct ofw_pci_softc { 56c43a8674SZbigniew Bodek device_t sc_dev; 57c43a8674SZbigniew Bodek phandle_t sc_node; 58c43a8674SZbigniew Bodek int sc_bus; 59c43a8674SZbigniew Bodek int sc_initialized; 60c43a8674SZbigniew Bodek int sc_quirks; 615572376dSMichal Meloun int sc_have_pmem; 62c43a8674SZbigniew Bodek 63c43a8674SZbigniew Bodek struct ofw_pci_range *sc_range; 64c43a8674SZbigniew Bodek int sc_nrange; 655572376dSMichal Meloun uint64_t sc_range_mask; 66c43a8674SZbigniew Bodek struct ofw_pci_cell_info *sc_cell_info; 67c43a8674SZbigniew Bodek 68c43a8674SZbigniew Bodek struct rman sc_io_rman; 69c43a8674SZbigniew Bodek struct rman sc_mem_rman; 705572376dSMichal Meloun struct rman sc_pmem_rman; 71c43a8674SZbigniew Bodek bus_space_tag_t sc_memt; 72c43a8674SZbigniew Bodek bus_dma_tag_t sc_dmat; 73efafbd0aSMichal Meloun int sc_pci_domain; 74c43a8674SZbigniew Bodek 75c43a8674SZbigniew Bodek struct ofw_bus_iinfo sc_pci_iinfo; 76c43a8674SZbigniew Bodek }; 77c43a8674SZbigniew Bodek 7824042910SMarcin Wojtas int ofw_pcib_init(device_t); 79*b1e93132SAndrew Turner void ofw_pcib_fini(device_t); 8024042910SMarcin Wojtas int ofw_pcib_attach(device_t); 8124042910SMarcin Wojtas int ofw_pcib_read_ivar(device_t, device_t, int, uintptr_t *); 8224042910SMarcin Wojtas int ofw_pcib_write_ivar(device_t, device_t, int, uintptr_t); 8324042910SMarcin Wojtas int ofw_pcib_route_interrupt(device_t, device_t, int); 8424042910SMarcin Wojtas int ofw_pcib_nranges(phandle_t, struct ofw_pci_cell_info *); 85c43a8674SZbigniew Bodek 86c43a8674SZbigniew Bodek #endif /* _DEV_OFW_OFWPCI_H_ */ 87