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 __NVSNOR_CONTROLLER_H |
| 34 #define __NVSNOR_CONTROLLER_H |
| 35 |
| 36 #include "mach/nvrm_linux.h" |
| 37 #include "nvos.h" |
| 38 #include "nvassert.h" |
| 39 #include "nvodm_query.h" |
| 40 |
| 41 #include "nvodm_services.h" |
| 42 #include "nvodm_query_discovery.h" |
| 43 |
| 44 #include "ap20/arsnor.h" |
| 45 #include "nvrm_hardware_access.h" |
| 46 #include "nvrm_power.h" |
| 47 #include "nvrm_drf.h" |
| 48 #include "nvrm_module.h" |
| 49 #include "nvrm_memmgr.h" |
| 50 #include "nvrm_interrupt.h" |
| 51 |
| 52 #define SNOR_CONTROLLER_CHIPSELECT_MAX 8 |
| 53 |
| 54 #define SNOR_DMA_BUFFER_SIZE_BYTE 0x1000 //4KB |
| 55 //#define SNOR_DMA_BUFFER_SIZE_BYTE 0x4000 //16KB |
| 56 |
| 57 |
| 58 #define SNOR_READ32(pSnorHwRegsVirtBaseAdd, reg) \ |
| 59 NV_READ32((pSnorHwRegsVirtBaseAdd) + ((SNOR_##reg##_0)/4)) |
| 60 |
| 61 #define SNOR_WRITE32(pSnorHwRegsVirtBaseAdd, reg, val) \ |
| 62 do \ |
| 63 { \ |
| 64 NV_WRITE32((((pSnorHwRegsVirtBaseAdd) + ((SNOR_##reg##_0)/4))), (val));
\ |
| 65 } while (0) |
| 66 |
| 67 typedef struct |
| 68 { |
| 69 NvRmPhysAddr DeviceBaseAddress; |
| 70 NvU32 DeviceAddressSize; |
| 71 NvU16 *pDeviceBaseVirtAddress; |
| 72 NvU32 DevicePureAddress; |
| 73 } ConnectedDeviceIntRegister; |
| 74 |
| 75 typedef struct |
| 76 { |
| 77 NvU32 Config; |
| 78 |
| 79 NvU32 Status; |
| 80 NvU32 NorAddressPtr; |
| 81 NvU32 AhbAddrPtr; |
| 82 NvU32 Timing0; |
| 83 NvU32 Timing1; |
| 84 NvU32 MioCfg; |
| 85 NvU32 MioTiming; |
| 86 NvU32 DmaConfig; |
| 87 NvU32 ChipSelectMuxConfig; |
| 88 } SnorControllerRegs; |
| 89 |
| 90 typedef struct |
| 91 { |
| 92 NvU32 Muxed_Width; |
| 93 NvU32 Hold_Width; |
| 94 NvU32 ADV_dWidth; |
| 95 NvU32 WE_Width; |
| 96 NvU32 OE_Width; |
| 97 NvU32 Wait_Width; |
| 98 |
| 99 } SnorControllerTimingRegVals; |
| 100 |
| 101 |
| 102 typedef struct NvSnorRec |
| 103 { |
| 104 NvRmDeviceHandle hRmDevice; |
| 105 |
| 106 NvU32 OpenCount; |
| 107 |
| 108 // Physical Address of the SNOR controller instance |
| 109 NvU32 SnorControllerBaseAdd; |
| 110 |
| 111 // Virtual address for the SNOR controller instance |
| 112 NvU32 *pSnorControllerVirtBaseAdd; |
| 113 |
| 114 // Size of the SNOR register map |
| 115 NvU32 SnorRegMapSize; |
| 116 |
| 117 // Semaphore for registering the client with the power manager. |
| 118 NvOsSemaphoreHandle hRmPowerEventSema; |
| 119 |
| 120 // Power client Id. |
| 121 NvU32 RmPowerClientId; |
| 122 |
| 123 // Command complete semaphore |
| 124 NvOsSemaphoreHandle hCommandCompleteSema; |
| 125 |
| 126 // Interrupt handle |
| 127 NvOsInterruptHandle hIntr; |
| 128 //For SNOR controller's DMA allocation |
| 129 NvRmMemHandle hRmMemory; |
| 130 NvRmPhysAddr DmaBuffPhysAdd; |
| 131 NvU32 *pAhbDmaBuffer; |
| 132 NvU32 Snor_DmaBufSize; |
| 133 |
| 134 //Number of devices present |
| 135 NvU32 NumOfDevicesConnected; |
| 136 |
| 137 // Tells whether the device is avialble or not. |
| 138 //NvU32 IsDevAvailable[SNOR_CONTROLLER_CHIPSELECT_MAX]; |
| 139 |
| 140 // Device interface register to access the devices which is controlled by SN
OR controller. |
| 141 ConnectedDeviceIntRegister ConnectedDevReg; |
| 142 |
| 143 SnorControllerRegs SnorRegs; |
| 144 } NvSnor; |
| 145 |
| 146 typedef struct NvSnorRec *NvSnorHandle; |
| 147 |
| 148 typedef struct |
| 149 { |
| 150 NvRmDeviceHandle hRmDevice; |
| 151 NvSnorHandle hSnor; |
| 152 } NvSnorInformation; |
| 153 |
| 154 |
| 155 NvError InitSnorInformation(void); |
| 156 void DeinitSnorInformation(void); |
| 157 void InitSnorController(NvSnorHandle hSnor, NvU32 DevTypeSNOREn, SnorControllerT
imingRegVals TimingRegVals); |
| 158 void SetChipSelect(NvSnorHandle hSnor, NvU32 ChipSelId); |
| 159 NvError CreateSnorHandle(NvRmDeviceHandle hRmDevice, NvSnorHandle *phSnor); |
| 160 void DestroySnorHandle(NvSnorHandle hSnor); |
| 161 |
| 162 void NvReadViaSNORControllerDMA (NvSnorHandle hSnor, void* SnorAddr, NvU32 word3
2bit_count); |
| 163 void NvWriteViaSNORControllerDMA (NvSnorHandle hSnor, void* SnorAddr, NvU32 word
32bit_count); |
| 164 |
| 165 #endif |
OLD | NEW |