/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *  * Neither the name of the copyright holder nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *****************************************************************************/


/**
 * @file LVDS driver interface
 *
 * @author dragon_chen@mtk.com.tw
 */

#ifndef _DRV_LVDS_H_
#define _DRV_LVDS_H_

#define LVDSA_EN_REST_DELAYTIME 20

//#define LVDS_ESD_PROTECT
#define PORTA_PWD 3
#define PORTB_PWD 4//set LVDS pin as GPIO.

#define BO0N  0
#define BO0P  1
#define BO1N  2
#define BO1P  3
#define BO2N  4
#define BO2P  5
#define BO3N  6
#define BO3P  7
#define BO4N  8
#define BO4P  9
#define BO5N  10
#define BO5P  11
#define BOCKN 12
#define BOCKP 13

#define BE0N  16
#define BE0P  17
#define BE1N  18
#define BE1P  19
#define BE2N  20
#define BE2P  21
#define BE3N  22
#define BE3P  23
#define BE4N  24
#define BE4P  25
#define BE5N  26
#define BE5P  27
#define BECKN 28
#define BECKP 29

extern void vDrvLVDSInit(void);
extern void vDrvLVDSOff(void) ;
extern void vDrvLVDSOn(void) ;
extern void vDrvLVDSConfig(void) ;
extern void vDrvLVDSACDRst_Enable(void) ;
extern void vDrvLVDSACDRst_Disable(void) ;
extern void LVDS_SwitchDataEnable(BOOL fEnable);
extern void vSetPI_GROUP(UINT8 u1AEven, UINT8 u1AODD, UINT8 u1BEven, UINT8 u1BOdd);
extern UINT8 vGetPI_GROUP(UINT8 u1Link);
extern void vSetPairSeqInverse(UINT8 u1Type);
extern void vSet_DataPair(UINT8 u1Port,UINT8 u1Pair, UINT8 u1Value);
extern UINT8 u1Get_DataPair(UINT8 u1Port,UINT8 u1Pair);
extern void vSetLVDSDAPadPDForceOn(void);

extern UINT32 vDrvLVDSsettingDrivingCurrent(UINT8 bCurrent);
extern void u4ReadAPad(void);
extern void vSetLVDSAPad(UINT8 u1OnOff, UINT16 u4BExtEn, UINT16 u4BDrvPwd,UINT16 u4AExtEn, UINT16 u4ADrvPwd);
extern void u4ReadDPadPD(void);
extern void vSetLVDSDPadPD(UINT8 u1OnOff, UINT32 u4Value);
extern UINT8 vDrvLVDSGetDriving(void);
extern void vDrvLVDSSetDriving(UINT8 bDriving);
extern void vDrvLVDSSetVCM(UINT8 bVCM);
extern UINT8 vDrvLVDSGetVCM(void);
extern void vDrvSetCurLvdsMode(UINT32 u4LvdsMode);
extern UINT32 vDrvGetCurLvdsMode(void);
extern void vDrvLVDSChgMod(UINT32 u4Mode);
extern void vDrvSetLvdsColorDomain(UINT32 u4ColorDomain);
extern UINT32 vDrvGetLvdsColorDomain(void);
extern void vDrvLVDS7To4FifoEnable(void);
//automation cli
extern void LVDS_ATERM_ATVO_Setting(UINT8 mode);
extern void LVDS_ATERM_ATVO_Restore(UINT32 ATERN, UINT8 ATVO);
extern void LVDS_ATVO_Set(UINT8 mode);
extern void LVDS_APSRC_Set(UINT8 mode);
extern void LVDS_ANSRC_Set(UINT8 mode);
extern void LVDS_PADPD_Set(UINT8 mode);
extern void LVDS_RESET_Set(UINT8 mode);
extern void MLVDS_LS_Set(UINT8 mode);
extern void MLVDS_TestMODE_Set(UINT8 mode);
extern void vDrvVCOPhase_SEL(UINT8 phase);
extern void SET_DDDSFreeRun(void);
extern void u1TCONIFSourceSet(UINT8 val);
extern UINT8 u1TCONIFSourceGet(void);
extern void vTXCRCStatus(void);
extern void u1TCONIFLineBufferSet(UINT8 val);
extern UINT8 u1TCONIFLineBufferGet(void);
extern void vDrvSetVOPLLClockSchema(UINT8 u1ClockSrc);
extern void vDrvLVDSToGPIOInit(UINT8 u1OnOff);
extern void vDrvSetLVDSToGPI(UINT8 u1LVDSPin, UINT8 u1OnOff);
extern void vDrvSetLVDSToGPO(UINT8 u1LVDSPin, UINT8 u1OnOff);
#ifdef LVDS_ESD_PROTECT
extern void vLVDSFIFOSkew_Recover(void);
extern UINT32 u1ChkLVDSFIFOSkewStatus(void);
extern BOOL fgIsLVDSFIFOSkew(void);
#endif

#endif
