| 1 | /******************************************************************************* |
| 2 | Copyright (C) Marvell International Ltd. and its affiliates |
| 3 | |
| 4 | This software file (the "File") is owned and distributed by Marvell |
| 5 | International Ltd. and/or its affiliates ("Marvell") under the following |
| 6 | alternative licensing terms. Once you have made an election to distribute the |
| 7 | File under one of the following license alternatives, please (i) delete this |
| 8 | introductory statement regarding license alternatives, (ii) delete the two |
| 9 | license alternatives that you have not elected to use and (iii) preserve the |
| 10 | Marvell copyright notice above. |
| 11 | |
| 12 | ******************************************************************************** |
| 13 | Marvell Commercial License Option |
| 14 | |
| 15 | If you received this File from Marvell and you have entered into a commercial |
| 16 | license agreement (a "Commercial License") with Marvell, the File is licensed |
| 17 | to you under the terms of the applicable Commercial License. |
| 18 | |
| 19 | ******************************************************************************** |
| 20 | Marvell GPL License Option |
| 21 | |
| 22 | If you received this File from Marvell, you may opt to use, redistribute and/or |
| 23 | modify this File in accordance with the terms and conditions of the General |
| 24 | Public License Version 2, June 1991 (the "GPL License"), a copy of which is |
| 25 | available along with the File in the license.txt file or by writing to the Free |
| 26 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 or |
| 27 | on the worldwide web at http://www.gnu.org/licenses/gpl.txt. |
| 28 | |
| 29 | THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED |
| 30 | WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY |
| 31 | DISCLAIMED. The GPL License provides additional details about this warranty |
| 32 | disclaimer. |
| 33 | ******************************************************************************** |
| 34 | Marvell BSD License Option |
| 35 | |
| 36 | If you received this File from Marvell, you may opt to use, redistribute and/or |
| 37 | modify this File under the following licensing terms. |
| 38 | Redistribution and use in source and binary forms, with or without modification, |
| 39 | are permitted provided that the following conditions are met: |
| 40 | |
| 41 | * Redistributions of source code must retain the above copyright notice, |
| 42 | this list of conditions and the following disclaimer. |
| 43 | |
| 44 | * Redistributions in binary form must reproduce the above copyright |
| 45 | notice, this list of conditions and the following disclaimer in the |
| 46 | documentation and/or other materials provided with the distribution. |
| 47 | |
| 48 | * Neither the name of Marvell nor the names of its contributors may be |
| 49 | used to endorse or promote products derived from this software without |
| 50 | specific prior written permission. |
| 51 | |
| 52 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 53 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 54 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 55 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 56 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 57 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 58 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 59 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 60 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 61 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 62 | |
| 63 | *******************************************************************************/ |
| 64 | |
| 65 | |
| 66 | #ifndef __INCmvCtrlEnvLibh |
| 67 | #define __INCmvCtrlEnvLibh |
| 68 | |
| 69 | /* includes */ |
| 70 | #include "mvSysHwConfig.h" |
| 71 | #include "mvCommon.h" |
| 72 | #include "mvTypes.h" |
| 73 | #include "mvOs.h" |
| 74 | #include "boardEnv/mvBoardEnvLib.h" |
| 75 | #include "ctrlEnv/mvCtrlEnvSpec.h" |
| 76 | #include "ctrlEnv/mvCtrlEnvRegs.h" |
| 77 | #include "ctrlEnv/mvCtrlEnvAddrDec.h" |
| 78 | |
| 79 | |
| 80 | /* typedefs */ |
| 81 | |
| 82 | /* This enumerator describes the possible HW cache coherency policies the */ |
| 83 | /* controllers supports. */ |
| 84 | typedef enum _mvCachePolicy |
| 85 | { |
| 86 | NO_COHERENCY, /* No HW cache coherency support */ |
| 87 | WT_COHERENCY, /* HW cache coherency supported in Write Through policy */ |
| 88 | WB_COHERENCY /* HW cache coherency supported in Write Back policy */ |
| 89 | }MV_CACHE_POLICY; |
| 90 | |
| 91 | |
| 92 | /* The swapping is referred to a 64-bit words (as this is the controller */ |
| 93 | /* internal data path width). This enumerator describes the possible */ |
| 94 | /* data swap types. Below is an example of the data 0x0011223344556677 */ |
| 95 | typedef enum _mvSwapType |
| 96 | { |
| 97 | MV_BYTE_SWAP, /* Byte Swap 77 66 55 44 33 22 11 00 */ |
| 98 | MV_NO_SWAP, /* No swapping 00 11 22 33 44 55 66 77 */ |
| 99 | MV_BYTE_WORD_SWAP, /* Both byte and word swap 33 22 11 00 77 66 55 44 */ |
| 100 | MV_WORD_SWAP, /* Word swap 44 55 66 77 00 11 22 33 */ |
| 101 | SWAP_TYPE_MAX /* Delimiter for this enumerator */ |
| 102 | }MV_SWAP_TYPE; |
| 103 | |
| 104 | /* This structure describes access rights for Access protection windows */ |
| 105 | /* that can be found in IDMA, XOR, Ethernet and MPSC units. */ |
| 106 | /* Note that the permission enumerator coresponds to its register format. */ |
| 107 | /* For example, Read only premission is presented as "1" in register field. */ |
| 108 | typedef enum _mvAccessRights |
| 109 | { |
| 110 | NO_ACCESS_ALLOWED = 0, /* No access allowed */ |
| 111 | READ_ONLY = 1, /* Read only permission */ |
| 112 | ACC_RESERVED = 2, /* Reserved access right */ |
| 113 | FULL_ACCESS = 3, /* Read and Write permission */ |
| 114 | MAX_ACC_RIGHTS |
| 115 | }MV_ACCESS_RIGHTS; |
| 116 | |
| 117 | |
| 118 | /* mcspLib.h API list */ |
| 119 | |
| 120 | MV_STATUS mvCtrlEnvInit(MV_VOID); |
| 121 | MV_U32 mvCtrlMppRegGet(MV_U32 mppGroup); |
| 122 | |
| 123 | #if defined(MV_INCLUDE_PEX) |
| 124 | MV_U32 mvCtrlPexMaxIfGet(MV_VOID); |
| 125 | #else |
| 126 | #define mvCtrlPexMaxIfGet() (0) |
| 127 | #endif |
| 128 | |
| 129 | #define mvCtrlPciIfMaxIfGet() (0) |
| 130 | |
| 131 | #if defined(MV_INCLUDE_GIG_ETH) |
| 132 | MV_U32 mvCtrlEthMaxPortGet(MV_VOID); |
| 133 | #endif |
| 134 | #if defined(MV_INCLUDE_XOR) |
| 135 | MV_U32 mvCtrlXorMaxChanGet(MV_VOID); |
| 136 | #endif |
| 137 | #if defined(MV_INCLUDE_USB) |
| 138 | MV_U32 mvCtrlUsbMaxGet(MV_VOID); |
| 139 | #endif |
| 140 | #if defined(MV_INCLUDE_NAND) |
| 141 | MV_U32 mvCtrlNandSupport(MV_VOID); |
| 142 | #endif |
| 143 | #if defined(MV_INCLUDE_SDIO) |
| 144 | MV_U32 mvCtrlSdioSupport(MV_VOID); |
| 145 | #endif |
| 146 | #if defined(MV_INCLUDE_TS) |
| 147 | MV_U32 mvCtrlTsSupport(MV_VOID); |
| 148 | #endif |
| 149 | #if defined(MV_INCLUDE_AUDIO) |
| 150 | MV_U32 mvCtrlAudioSupport(MV_VOID); |
| 151 | #endif |
| 152 | #if defined(MV_INCLUDE_TDM) |
| 153 | MV_U32 mvCtrlTdmSupport(MV_VOID); |
| 154 | #endif |
| 155 | |
| 156 | MV_U16 mvCtrlModelGet(MV_VOID); |
| 157 | MV_U8 mvCtrlRevGet(MV_VOID); |
| 158 | MV_STATUS mvCtrlNameGet(char *pNameBuff); |
| 159 | MV_U32 mvCtrlModelRevGet(MV_VOID); |
| 160 | MV_STATUS mvCtrlModelRevNameGet(char *pNameBuff); |
| 161 | MV_VOID mvCtrlAddrDecShow(MV_VOID); |
| 162 | const MV_8* mvCtrlTargetNameGet(MV_TARGET target); |
| 163 | MV_U32 ctrlSizeToReg(MV_U32 size, MV_U32 alignment); |
| 164 | MV_U32 ctrlRegToSize(MV_U32 regSize, MV_U32 alignment); |
| 165 | MV_U32 ctrlSizeRegRoundUp(MV_U32 size, MV_U32 alignment); |
| 166 | MV_U32 mvCtrlSysRstLengthCounterGet(MV_VOID); |
| 167 | MV_STATUS ctrlWinOverlapTest(MV_ADDR_WIN *pAddrWin1, MV_ADDR_WIN *pAddrWin2); |
| 168 | MV_STATUS ctrlWinWithinWinTest(MV_ADDR_WIN *pAddrWin1, MV_ADDR_WIN *pAddrWin2); |
| 169 | |
| 170 | MV_VOID mvCtrlPwrClckSet(MV_UNIT_ID unitId, MV_U32 index, MV_BOOL enable); |
| 171 | MV_BOOL mvCtrlPwrClckGet(MV_UNIT_ID unitId, MV_U32 index); |
| 172 | MV_VOID mvCtrlPwrMemSet(MV_UNIT_ID unitId, MV_U32 index, MV_BOOL enable); |
| 173 | MV_BOOL mvCtrlIsBootFromSPI(MV_VOID); |
| 174 | MV_BOOL mvCtrlIsBootFromSPIUseNAND(MV_VOID); |
| 175 | MV_BOOL mvCtrlIsBootFromNAND(MV_VOID); |
| 176 | #if defined(MV_INCLUDE_CLK_PWR_CNTRL) |
| 177 | MV_VOID mvCtrlPwrSaveOn(MV_VOID); |
| 178 | MV_VOID mvCtrlPwrSaveOff(MV_VOID); |
| 179 | #endif |
| 180 | MV_BOOL mvCtrlPwrMemGet(MV_UNIT_ID unitId, MV_U32 index); |
| 181 | MV_VOID mvMPPConfigToSPI(MV_VOID); |
| 182 | MV_VOID mvMPPConfigToDefault(MV_VOID); |
| 183 | |
| 184 | |
| 185 | #endif /* __INCmvCtrlEnvLibh */ |
| 186 | |