Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @brief PCI Auto Configuration Library
0007  */
0008 
0009 /*
0010  * COPYRIGHT (c) 2010 Cobham Gaisler AB.
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  */
0033 
0034 #ifndef __PCI_CFG_AUTO_H__
0035 #define __PCI_CFG_AUTO_H__
0036 
0037 #define CFGOPT_NOSETUP_IRQ 0x1 /* Skip IRQ setup */
0038 
0039 /* PCI Memory Layout setup, used by the auto-config library in order to
0040  * determine the addresses of PCI BARs and Buses.
0041  *
0042  * All addresses are in PCI address space, the actual address the CPU access
0043  * may be different, and taken care of elsewhere.
0044  */
0045 struct pci_auto_setup {
0046     int options;
0047 
0048     /* PCI prefetchable Memory space (OPTIONAL) */
0049     uint32_t mem_start;
0050     uint32_t mem_size; /* 0 = Use MEMIO space for prefetchable mem BARs */
0051 
0052     /* PCI non-prefetchable Memory */
0053     uint32_t memio_start;
0054     uint32_t memio_size;
0055 
0056     /* PCI I/O space (OPTIONAL) */
0057     uint32_t io_start;
0058     uint32_t io_size; /* 0 = No I/O space */
0059 
0060     /* Get System IRQ connected to a PCI line of a PCI device on bus0.
0061      * The return IRQ value zero equals no IRQ (IRQ disabled).
0062      */
0063     uint8_t (*irq_map)(pci_dev_t dev, int irq_pin);
0064 
0065     /* IRQ Bridge routing. Returns the interrupt pin (0..3 = A..D) that
0066      * a device is connected to on parent bus.
0067      */
0068     int (*irq_route)(pci_dev_t dev, int irq_pin);
0069 };
0070 
0071 /* Do PCI initialization: Enumrate buses, scan buses for devices, assign
0072  * I/O MEM and MEMIO resources, assign IRQ and so on.
0073  */
0074 extern int pci_config_auto(void);
0075 
0076 /* Register a configuration for the auto library (struct pci_auto_setup *) */
0077 extern void pci_config_auto_register(void *config);
0078 
0079 /* PCI memory map */
0080 extern struct pci_auto_setup pci_auto_cfg;
0081 
0082 #endif