OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2009 NVIDIA Corporation. |
| 3 * All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: |
| 7 * |
| 8 * Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. |
| 10 * |
| 11 * Redistributions in binary form must reproduce the above copyright notice, |
| 12 * this list of conditions and the following disclaimer in the documentation |
| 13 * and/or other materials provided with the distribution. |
| 14 * |
| 15 * Neither the name of the NVIDIA Corporation nor the names of its contributors |
| 16 * may be used to endorse or promote products derived from this software |
| 17 * without specific prior written permission. |
| 18 * |
| 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 * POSSIBILITY OF SUCH DAMAGE. |
| 30 * |
| 31 */ |
| 32 |
| 33 #ifndef INCLUDED_nvrm_pcie_H |
| 34 #define INCLUDED_nvrm_pcie_H |
| 35 |
| 36 |
| 37 #if defined(__cplusplus) |
| 38 extern "C" |
| 39 { |
| 40 #endif |
| 41 |
| 42 #include "nvrm_module.h" |
| 43 #include "nvrm_init.h" |
| 44 |
| 45 typedef enum |
| 46 { |
| 47 |
| 48 // NvRm PCIE access type read |
| 49 NvRmPcieAccessType_Read, |
| 50 |
| 51 // NvRm PCIE access type write |
| 52 NvRmPcieAccessType_Write, |
| 53 NvRmPcieAccessType_Num, |
| 54 NvRmPcieAccessType_Force32 = 0x7FFFFFFF |
| 55 } NvRmPcieAccessType; |
| 56 |
| 57 |
| 58 /** Reads or writes the config space of the PCI device. |
| 59 * |
| 60 * @param hRmDeviceHandle The Rm device handle |
| 61 * @param bus_number Bus number on on which the device is present. |
| 62 * @param type Specifies the access type |
| 63 * @param offset Start offset to read the configuration data |
| 64 * @param Data Data in bytes used to read/write from/to device config space, |
| 65 * depending on the access type. |
| 66 * @param DataLen Sepcifies the length of Data Array. |
| 67 * |
| 68 * Returns NvSuccess or the appropriate error code. |
| 69 */ |
| 70 |
| 71 NvError NvRmReadWriteConfigSpace( |
| 72 NvRmDeviceHandle hDeviceHandle, |
| 73 NvU32 bus_number, |
| 74 NvRmPcieAccessType type, |
| 75 NvU32 offset, |
| 76 NvU8 * Data, |
| 77 NvU32 DataLen ); |
| 78 |
| 79 |
| 80 /** Registers a MSI handler for the device at an index. |
| 81 * |
| 82 * @param hRmDeviceHandle The Rm device handle |
| 83 * @param function_device_bus function/device/bus tuple. |
| 84 * @param index Msi index. Some devices support more than 1 MSI. For those |
| 85 * devices, index value is from (0 to max-1) |
| 86 * @param sem Semaphore which will be signalled when the MSI interrupt is |
| 87 * triggered. |
| 88 * @param InterruptEnable To enable or disable interrupt. |
| 89 * |
| 90 * Returns NvSuccess or the appropriate error code. |
| 91 */ |
| 92 |
| 93 |
| 94 NvError NvRmRegisterPcieMSIHandler( |
| 95 NvRmDeviceHandle hDeviceHandle, |
| 96 NvU32 function_device_bus, |
| 97 NvU32 index, |
| 98 NvOsSemaphoreHandle sem, |
| 99 NvBool InterruptEnable ); |
| 100 |
| 101 NvError NvRmRegisterPcieLegacyHandler( |
| 102 NvRmDeviceHandle hDeviceHandle, |
| 103 NvU32 function_device_bus, |
| 104 NvOsSemaphoreHandle sem, |
| 105 NvBool InterruptEnable ); |
| 106 |
| 107 // PCIE address map supports 64-bit addressing. But, RM driver only supports |
| 108 // 32-addressing. In the future, if the device supports 64-bit addressing, one |
| 109 // can change this typedef. |
| 110 |
| 111 typedef NvU32 NvRmPciPhysAddr; |
| 112 |
| 113 /** |
| 114 * Attemtps to map the Pcie memory to the 32-bit AXI address region. |
| 115 * Ap20 reserves only 1GB PCIe aperture. Out of that 1GB, some region is reserve
d for |
| 116 * the register/config/msi access. Only 768MB is left out for the PCIe memory ap
erture. |
| 117 * |
| 118 * @param hRmDeviceHandle Rm device handle |
| 119 * @param mem "Base address registers" of a PCI device. |
| 120 * |
| 121 * Returns the mapped AXI address. If the mapping fails, it returns 0. |
| 122 */ |
| 123 |
| 124 NvRmPhysAddr NvRmMapPciMemory( |
| 125 NvRmDeviceHandle hDeviceHandle, |
| 126 NvRmPciPhysAddr mem, |
| 127 NvU32 size ); |
| 128 |
| 129 /** Unmaps the PCI to AXI address mapping |
| 130 * |
| 131 * @param hRmDeviceHandle Rm device handle |
| 132 * @param mem AXI addresses mapped by calling NvRmMapPcieMemory |
| 133 * API. |
| 134 */ |
| 135 |
| 136 void NvRmUnmapPciMemory( |
| 137 NvRmDeviceHandle hDeviceHandle, |
| 138 NvRmPhysAddr mem, |
| 139 NvU32 size ); |
| 140 |
| 141 /** @} */ |
| 142 |
| 143 #if defined(__cplusplus) |
| 144 } |
| 145 #endif |
| 146 |
| 147 #endif |
OLD | NEW |