1 /*******************************************************************************
2 Copyright (C) Marvell International Ltd. and its affiliates
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.
12 ********************************************************************************
13 Marvell Commercial License Option
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.
19 ********************************************************************************
20 Marvell GPL License Option
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.
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
33 ********************************************************************************
34 Marvell BSD License Option
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:
41 * Redistributions of source code must retain the above copyright notice,
42 this list of conditions and the following disclaimer.
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.
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.
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.
63 *******************************************************************************/
64 #ifndef __INCmvBoardEnvLibh
65 #define __INCmvBoardEnvLibh
68 /* The below constant macros defines the board I2C EEPROM data offsets */
72 #include "ctrlEnv/mvCtrlEnvLib.h"
73 #include "mvSysHwConfig.h"
74 #include "boardEnv/mvBoardEnvSpec.h"
77 /* DUART stuff for Tclk detection only */
78 #define DUART_BAUD_RATE 115200
79 #define MAX_CLOCK_MARGINE 5000000 /* Maximum detected clock margine */
81 /* Voice devices assembly modes */
82 #define DAISY_CHAIN_MODE 1
83 #define DUAL_CHIP_SELECT_MODE 0
84 #define INTERRUPT_TO_MPP 1
85 #define INTERRUPT_TO_TDM 0
88 #define BOARD_ETH_PORT_NUM MV_ETH_MAX_PORTS
89 #define BOARD_ETH_SWITCH_PORT_NUM 5
91 #define MV_BOARD_MAX_USB_IF 1
92 #define MV_BOARD_MAX_MPP 7
93 #define MV_BOARD_NAME_LEN 0x20
95 typedef struct _boardData
106 typedef enum _devBoardMppGroupClass
108 MV_BOARD_MPP_GROUP_1
,
109 MV_BOARD_MPP_GROUP_2
,
110 MV_BOARD_MAX_MPP_GROUP
111 }MV_BOARD_MPP_GROUP_CLASS
;
113 typedef enum _devBoardMppTypeClass
123 }MV_BOARD_MPP_TYPE_CLASS
;
125 typedef enum _devBoardModuleIdClass
127 MV_BOARD_MODULE_TDM_ID
= 1,
128 MV_BOARD_MODULE_AUDIO_ID
,
129 MV_BOARD_MODULE_RGMII_ID
,
130 MV_BOARD_MODULE_GMII_ID
,
131 MV_BOARD_MODULE_TS_ID
,
132 MV_BOARD_MODULE_MII_ID
,
133 MV_BOARD_MODULE_TDM_5CHAN_ID
,
134 MV_BOARD_MODULE_OTHER_ID
135 }MV_BOARD_MODULE_ID_CLASS
;
137 typedef struct _boardMppTypeInfo
139 MV_BOARD_MPP_TYPE_CLASS boardMppGroup1
;
140 MV_BOARD_MPP_TYPE_CLASS boardMppGroup2
;
142 }MV_BOARD_MPP_TYPE_INFO
;
145 typedef enum _devBoardClass
148 BOARD_DEV_NAND_FLASH
,
156 typedef enum _devTwsiBoardClass
161 BOARD_TWSI_AUDIO_DEC
,
163 }MV_BOARD_TWSI_CLASS
;
165 typedef enum _devGppBoardClass
170 BOARD_GPP_USB_VBUS_EN
,
172 BOARD_GPP_USB_HOST_DEVICE
,
177 BOARD_GPP_TS_BUTTON_C
,
178 BOARD_GPP_TS_BUTTON_U
,
179 BOARD_GPP_TS_BUTTON_D
,
180 BOARD_GPP_TS_BUTTON_L
,
181 BOARD_GPP_TS_BUTTON_R
,
182 BOARD_GPP_POWER_BUTTON
,
183 BOARD_GPP_RESTOR_BUTTON
,
184 BOARD_GPP_WPS_BUTTON
,
185 BOARD_GPP_HDD0_POWER
,
186 BOARD_GPP_HDD1_POWER
,
189 BOARD_GPP_POWER_ON_LED
,
191 BOARD_GPP_SDIO_POWER
,
192 BOARD_GPP_SDIO_DETECT
,
194 BOARD_GPP_SWITCH_PHY_INT
,
195 BOARD_GPP_TSU_DIRCTION
,
200 typedef struct _devCsInfo
204 MV_U32 devClass
; /* MV_BOARD_DEV_CLASS */
210 #define MV_BOARD_PHY_FORCE_10MB 0x0
211 #define MV_BOARD_PHY_FORCE_100MB 0x1
212 #define MV_BOARD_PHY_FORCE_1000MB 0x2
213 #define MV_BOARD_PHY_SPEED_AUTO 0x3
215 typedef struct _boardSwitchInfo
218 MV_32 qdPort
[BOARD_ETH_SWITCH_PORT_NUM
];
220 MV_32 smiScanMode
; /* 1 for SMI_MANUAL_MODE, 0 otherwise */
223 }MV_BOARD_SWITCH_INFO
;
225 typedef struct _boardLedInfo
227 MV_U8 activeLedsNumber
;
228 MV_U8 ledsPolarity
; /* '0' or '1' to turn on led */
229 MV_U8
* gppPinNum
; /* Pointer to GPP values */
233 typedef struct _boardGppInfo
235 MV_BOARD_GPP_CLASS devClass
;
241 typedef struct _boardTwsiInfo
243 MV_BOARD_TWSI_CLASS devClass
;
245 MV_U8 twsiDevAddrType
;
250 typedef enum _boardMacSpeed
253 BOARD_MAC_SPEED_100M
,
254 BOARD_MAC_SPEED_1000M
,
255 BOARD_MAC_SPEED_AUTO
,
259 typedef struct _boardMacInfo
261 MV_BOARD_MAC_SPEED boardMacSpeed
;
262 MV_U8 boardEthSmiAddr
;
266 typedef struct _boardMppInfo
268 MV_U32 mppGroup
[MV_BOARD_MAX_MPP
];
272 typedef struct _boardInfo
274 char boardName
[MV_BOARD_NAME_LEN
];
275 MV_U8 numBoardMppTypeValue
;
276 MV_BOARD_MPP_TYPE_INFO
* pBoardMppTypeValue
;
277 MV_U8 numBoardMppConfigValue
;
278 MV_BOARD_MPP_INFO
* pBoardMppConfigValue
;
279 MV_U32 intsGppMaskLow
;
280 MV_U32 intsGppMaskHigh
;
281 MV_U8 numBoardDeviceIf
;
282 MV_DEV_CS_INFO
* pDevCsInfo
;
283 MV_U8 numBoardTwsiDev
;
284 MV_BOARD_TWSI_INFO
* pBoardTwsiDev
;
285 MV_U8 numBoardMacInfo
;
286 MV_BOARD_MAC_INFO
* pBoardMacInfo
;
287 MV_U8 numBoardGppInfo
;
288 MV_BOARD_GPP_INFO
* pBoardGppInfo
;
289 MV_U8 activeLedsNumber
;
291 MV_U8 ledsPolarity
; /* '0' or '1' to turn on led */
293 MV_U32 gppOutEnValLow
;
294 MV_U32 gppOutEnValHigh
;
296 MV_U32 gppOutValHigh
;
297 MV_U32 gppPolarityValLow
;
298 MV_U32 gppPolarityValHigh
;
300 /* Switch Configuration */
301 MV_BOARD_SWITCH_INFO
* pSwitchInfo
;
306 MV_VOID
mvBoardEnvInit(MV_VOID
);
307 MV_U32
mvBoardIdGet(MV_VOID
);
308 MV_U16
mvBoardModelGet(MV_VOID
);
309 MV_U16
mvBoardRevGet(MV_VOID
);
310 MV_STATUS
mvBoardNameGet(char *pNameBuff
);
311 MV_32
mvBoardPhyAddrGet(MV_U32 ethPortNum
);
312 MV_BOARD_MAC_SPEED
mvBoardMacSpeedGet(MV_U32 ethPortNum
);
313 MV_32
mvBoardLinkStatusIrqGet(MV_U32 ethPortNum
);
314 MV_32
mvBoardSwitchPortGet(MV_U32 ethPortNum
, MV_U8 boardPortNum
);
315 MV_32
mvBoardSwitchCpuPortGet(MV_U32 ethPortNum
);
316 MV_32
mvBoardIsSwitchConnected(MV_U32 ethPortNum
);
317 MV_32
mvBoardSmiScanModeGet(MV_U32 ethPortNum
);
318 MV_BOOL
mvBoardIsPortInSgmii(MV_U32 ethPortNum
);
319 MV_BOOL
mvBoardIsPortInGmii(MV_VOID
);
320 MV_U32
mvBoardTclkGet(MV_VOID
);
321 MV_U32
mvBoardSysClkGet(MV_VOID
);
322 MV_U32
mvBoardDebugLedNumGet(MV_U32 boardId
);
323 MV_VOID
mvBoardDebugLed(MV_U32 hexNum
);
324 MV_32
mvBoardMppGet(MV_U32 mppGroupNum
);
326 MV_U8
mvBoardRtcTwsiAddrTypeGet(MV_VOID
);
327 MV_U8
mvBoardRtcTwsiAddrGet(MV_VOID
);
329 MV_U8
mvBoardA2DTwsiAddrTypeGet(MV_VOID
);
330 MV_U8
mvBoardA2DTwsiAddrGet(MV_VOID
);
332 MV_U8
mvBoardTwsiExpAddrGet(MV_U32 index
);
333 MV_U8
mvBoardTwsiSatRAddrTypeGet(MV_U32 index
);
334 MV_U8
mvBoardTwsiSatRAddrGet(MV_U32 index
);
335 MV_U8
mvBoardTwsiExpAddrTypeGet(MV_U32 index
);
336 MV_BOARD_MODULE_ID_CLASS
mvBoarModuleTypeGet(MV_BOARD_MPP_GROUP_CLASS devClass
);
337 MV_BOARD_MPP_TYPE_CLASS
mvBoardMppGroupTypeGet(MV_BOARD_MPP_GROUP_CLASS mppGroupClass
);
338 MV_VOID
mvBoardMppGroupTypeSet(MV_BOARD_MPP_GROUP_CLASS mppGroupClass
,
339 MV_BOARD_MPP_TYPE_CLASS mppGroupType
);
340 MV_VOID
mvBoardMppGroupIdUpdate(MV_VOID
);
341 MV_VOID
mvBoardMppMuxSet(MV_VOID
);
342 MV_VOID
mvBoardTdmMppSet(MV_32 chType
);
343 MV_VOID
mvBoardVoiceConnModeGet(MV_32
* connMode
, MV_32
* irqMode
);
345 MV_VOID
mvBoardMppModuleTypePrint(MV_VOID
);
346 MV_VOID
mvBoardReset(MV_VOID
);
347 MV_U8
mvBoarTwsiSatRGet(MV_U8 devNum
, MV_U8 regNum
);
348 MV_STATUS
mvBoarTwsiSatRSet(MV_U8 devNum
, MV_U8 regNum
, MV_U8 regVal
);
349 MV_BOOL
mvBoardSpecInitGet(MV_U32
* regOff
, MV_U32
* data
);
350 /* Board devices API managments */
351 MV_32
mvBoardGetDevicesNumber(MV_BOARD_DEV_CLASS devClass
);
352 MV_32
mvBoardGetDeviceBaseAddr(MV_32 devNum
, MV_BOARD_DEV_CLASS devClass
);
353 MV_32
mvBoardGetDeviceBusWidth(MV_32 devNum
, MV_BOARD_DEV_CLASS devClass
);
354 MV_32
mvBoardGetDeviceWidth(MV_32 devNum
, MV_BOARD_DEV_CLASS devClass
);
355 MV_32
mvBoardGetDeviceWinSize(MV_32 devNum
, MV_BOARD_DEV_CLASS devClass
);
356 MV_U32
boardGetDevCSNum(MV_32 devNum
, MV_BOARD_DEV_CLASS devClass
);
358 /* Gpio Pin Connections API */
359 MV_32
mvBoardUSBVbusGpioPinGet(int devId
);
360 MV_32
mvBoardUSBVbusEnGpioPinGet(int devId
);
361 MV_U32
mvBoardPexBridgeIntPinGet(MV_U32 devNum
, MV_U32 intPin
);
363 MV_32
mvBoardResetGpioPinGet(MV_VOID
);
364 MV_32
mvBoardRTCGpioPinGet(MV_VOID
);
365 MV_32
mvBoardGpioIntMaskLowGet(MV_VOID
);
366 MV_32
mvBoardGpioIntMaskHighGet(MV_VOID
);
367 MV_32
mvBoardSlicGpioPinGet(MV_U32 slicNum
);
369 MV_32
mvBoardSDIOGpioPinGet(MV_VOID
);
370 MV_STATUS
mvBoardSDioWPControl(MV_BOOL mode
);
371 MV_32
mvBoarGpioPinNumGet(MV_BOARD_GPP_CLASS
class, MV_U32 index
);
373 MV_32
mvBoardNandWidthGet(void);
374 MV_STATUS
mvBoardFanPowerControl(MV_BOOL mode
);
375 MV_STATUS
mvBoardHDDPowerControl(MV_BOOL mode
);
376 #endif /* __INCmvBoardEnvLibh */