/* 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.
 *
 *****************************************************************************/


#ifndef MTK_FUNCNO_PIN_SETUP_H
#define MTK_FUNCNO_PIN_SETUP_H

UINT32 _gu4SysPinmuxInit[][2] =
{
    // Audio
    {PIN_ALIN, PINMUX_FUNCTION1},
    {PIN_ASPDIF0, PINMUX_FUNCTION1},
    {PIN_ASPDIF1, PINMUX_FUNCTION1},
    {PIN_AOMCLK, PINMUX_FUNCTION1},
    {PIN_AOBCK, PINMUX_FUNCTION1},
    {PIN_AOLRCK, PINMUX_FUNCTION1},
    {PIN_AOSDATA0, PINMUX_FUNCTION1},
    {PIN_AOSDATA1, PINMUX_FUNCTION1},
    {PIN_AOSDATA2, PINMUX_FUNCTION1},
    {PIN_AOSDATA3, PINMUX_FUNCTION1},
    {PIN_AOSDATA4, PINMUX_FUNCTION1},

    {PIN_OSDA0, PINMUX_FUNCTION1},
    //    {PIN_OSDA1, 1},
    //    {PIN_OSDA2, 0},

    // UART 0
    {PIN_U0TX, PINMUX_FUNCTION0},
    {PIN_U0RX, PINMUX_FUNCTION0},

    // Demod ATD
    {PIN_IF_AGC, PINMUX_FUNCTION1},
    {PIN_RF_AGC, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSCLK, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSVAL, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSSYNC, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSDATA0, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSDATA1, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSDATA2, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSDATA3, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSDATA4, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSDATA5, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSDATA6, PINMUX_FUNCTION1},
    {PIN_DEMOD_TSDATA7, PINMUX_FUNCTION1},

    // SD card
    {PIN_GPIO63,  PINMUX_FUNCTION0 },//GPIO 63 SDIO PWR SWITCH
    {PIN_ADIN7,  PINMUX_FUNCTION1 },//GPIO 236  SDCARD DETECT

#ifdef LVDS_GPIO_SUPPORT
    //set the following lvds pins as gpio function
    {PIN_BE4P,  PINMUX_FUNCTION1 },//GPIO 160  FE_PWR_ON/DSQ_SW_CTRL
    {PIN_BE4N,  PINMUX_FUNCTION1 },//GPIO 161  FE_PWR2_ON/FE_SAT_XRST
    {PIN_BE3P,  PINMUX_FUNCTION1 },//GPIO 162
    {PIN_BE3N,  PINMUX_FUNCTION1 },//GPIO 163  HP_DET
    {PIN_BECKP,  PINMUX_FUNCTION1 },//GPIO 164  COMP_DET
    {PIN_BECKN,  PINMUX_FUNCTION1 },//GPIO 165  SDCARD WP
    {PIN_BE2P,  PINMUX_FUNCTION1 },//GPIO 166  SDCARD VOL CNT
    {PIN_BE2N,  PINMUX_FUNCTION1 },//GPIO 167  USB_OCP1
    {PIN_BE1P,  PINMUX_FUNCTION1 },//GPIO 168  FE_XRST
    {PIN_BE1N,  PINMUX_FUNCTION1 },//GPIO 169  BL_ECO
    {PIN_BE0P,  PINMUX_FUNCTION1 },//GPIO 170  USB_VBUS3
    {PIN_BE0N,  PINMUX_FUNCTION1 },//GPIO 171  USB_OCP3
    {PIN_BO4P,  PINMUX_FUNCTION1 },//GPIO 172  HDMI_RST
    {PIN_BO4N,  PINMUX_FUNCTION1 },//GPIO 173  PANEL_TEST_ON
    {PIN_BO3P,  PINMUX_FUNCTION1 },//GPIO 174
    {PIN_BO3N,  PINMUX_FUNCTION1 },//GPIO 175  PANEL_VCOM_WP
    {PIN_BOCKP,  PINMUX_FUNCTION1 },//GPIO 176  AMP_XRST
    {PIN_BOCKN,  PINMUX_FUNCTION1 },//GPIO 177  NT_DONE
    {PIN_BO2P,  PINMUX_FUNCTION1 },//GPIO 178  MAIN_FAN_ON
    {PIN_BO2N,  PINMUX_FUNCTION1 },//GPIO 179  FAN_MAX
    {PIN_BO1P,  PINMUX_FUNCTION1 },//GPIO 180  FAN_SOO
#endif
    // Internal CI
    {PIN_GPIO0, PINMUX_FUNCTION1 },//GPIO 0
    {PIN_GPIO1, PINMUX_FUNCTION1 },//GPIO 1
    {PIN_GPIO2, PINMUX_FUNCTION1 },//GPIO 2
    {PIN_GPIO3, PINMUX_FUNCTION1 },//GPIO 3
    {PIN_GPIO4, PINMUX_FUNCTION1 },//GPIO 4
    {PIN_GPIO5, PINMUX_FUNCTION1 },//GPIO 5
    {PIN_GPIO6, PINMUX_FUNCTION1 },//GPIO 6
    {PIN_GPIO7, PINMUX_FUNCTION1 },//GPIO 7
    {PIN_GPIO8, PINMUX_FUNCTION1 },//GPIO 8
    {PIN_GPIO9, PINMUX_FUNCTION1 },//GPIO 9
    {PIN_GPIO10,    PINMUX_FUNCTION1 },//GPIO 10
    {PIN_GPIO11,    PINMUX_FUNCTION1 },//GPIO 11
    {PIN_GPIO12,    PINMUX_FUNCTION1 },//GPIO 12
    {PIN_GPIO13,    PINMUX_FUNCTION1 },//GPIO 13
    {PIN_GPIO14,    PINMUX_FUNCTION1 },//GPIO 14
    {PIN_GPIO15,    PINMUX_FUNCTION1 },//GPIO 15
    {PIN_GPIO16,    PINMUX_FUNCTION1 },//GPIO 16
    {PIN_GPIO17,    PINMUX_FUNCTION1 },//GPIO 17
    {PIN_GPIO18,    PINMUX_FUNCTION1 },//GPIO 18
    {PIN_GPIO19,    PINMUX_FUNCTION1 },//GPIO 19
    {PIN_GPIO20,    PINMUX_FUNCTION1 },//GPIO 20
    {PIN_GPIO21,    PINMUX_FUNCTION1 },//GPIO 21
    {PIN_GPIO22,    PINMUX_FUNCTION1 },//GPIO 22
    {PIN_GPIO23,    PINMUX_FUNCTION1 },//GPIO 23
    {PIN_GPIO24,    PINMUX_FUNCTION1 },//GPIO 24
    {PIN_GPIO25,    PINMUX_FUNCTION1 },//GPIO 25
    {PIN_GPIO26,    PINMUX_FUNCTION1 },//GPIO 26
    {PIN_GPIO27,    PINMUX_FUNCTION1 },//GPIO 27
    {PIN_GPIO28,    PINMUX_FUNCTION1 },//GPIO 28
    {PIN_GPIO29,    PINMUX_FUNCTION1 },//GPIO 29
    {PIN_GPIO30,    PINMUX_FUNCTION1 },//GPIO 30
    {PIN_GPIO31,    PINMUX_FUNCTION1 },//GPIO 31
    {PIN_GPIO32,    PINMUX_FUNCTION1 },//GPIO 32
    {PIN_GPIO33,    PINMUX_FUNCTION1 },//GPIO 33
    {PIN_GPIO34,    PINMUX_FUNCTION1 },//GPIO 34
    {PIN_GPIO35,    PINMUX_FUNCTION1 },//GPIO 35
    {PIN_GPIO36,    PINMUX_FUNCTION1 },//GPIO 36
    {PIN_GPIO37,    PINMUX_FUNCTION1 },//GPIO 37
    {PIN_GPIO38,    PINMUX_FUNCTION1 },//GPIO 38
    {PIN_GPIO39,    PINMUX_FUNCTION1 },//GPIO 39
    {PIN_GPIO40,    PINMUX_FUNCTION1 },//GPIO 40
    {PIN_GPIO41,    PINMUX_FUNCTION1 },//GPIO 41
    {PIN_PVR_TSCLK, PINMUX_FUNCTION3 },//GPIO 56
    {PIN_PVR_TSVAL, PINMUX_FUNCTION0 },//GPIO 57
    {PIN_PVR_TSSYNC,    PINMUX_FUNCTION3 },//GPIO 58
    {PIN_PVR_TSDATA0,   PINMUX_FUNCTION3 },//GPIO 59
    {PIN_PVR_TSDATA1,   PINMUX_FUNCTION3 },//GPIO 60
    {PIN_SPI_CLK,   PINMUX_FUNCTION3 },//GPIO 61
    {PIN_SPI_CLK1,  PINMUX_FUNCTION3 },//GPIO 62
    {PIN_SPI_DATA,  PINMUX_FUNCTION3 },//GPIO 63
    {PIN_SPI_CLE,   PINMUX_FUNCTION3 },//GPIO 64
    {PIN_CI_INT,    PINMUX_FUNCTION3 },//GPIO 66
    {PIN_CI_TSCLK,  PINMUX_FUNCTION3 },//GPIO 121
    {PIN_CI_TSVAL,  PINMUX_FUNCTION3 },//GPIO 122
    {PIN_CI_TSSYNC, PINMUX_FUNCTION3 },//GPIO 123
    {PIN_CI_TSDATA0,    PINMUX_FUNCTION3 },//GPIO 124
#ifdef CC_LG_CI_RESET_DEF
    {PIN_DEMOD_RST, PINMUX_FUNCTION3 },//GPIO 65    //LG  -> CI reset
    {PIN_GPIO47, PINMUX_FUNCTION0 },//GPIO 47     //turnkey ->USB power
#else
    {PIN_DEMOD_RST, PINMUX_FUNCTION0 },//GPIO 65     //turnkey ->demod reset
    {PIN_GPIO47, PINMUX_FUNCTION3 },//GPIO 47     //turnkey ->CI reset
#endif

    // PWM
    {PIN_OPWM0, PINMUX_FUNCTION2},
    {PIN_OPWM1, PINMUX_FUNCTION2},
    {PIN_OPWM2, PINMUX_FUNCTION2},

    // VGA
    {PIN_VGA_SCL, PINMUX_FUNCTION2},
    {PIN_VGA_SDA, PINMUX_FUNCTION2},

    // HDMI
    {PIN_HDMI_CEC, PINMUX_FUNCTION1},

#ifdef CC_ENABLE_HDMI_JTAG
    {PIN_GPIO57, PINMUX_FUNCTION1 },        // default JTCK
    {PIN_HDMI_1_SCL, PINMUX_FUNCTION2 },    // ice_jtms
    {PIN_HDMI_1_SDA, PINMUX_FUNCTION2 },    // ice_jtck
    {PIN_HDMI_2_SCL, PINMUX_FUNCTION2 },    // ice_jtdo
    {PIN_HDMI_2_SDA, PINMUX_FUNCTION2 },    // ice_jtdi
    {PIN_HDMI_2_HPD, PINMUX_FUNCTION2 },    // ice_jtrst
#else // deticated JTAG
    {PIN_GPIO57, PINMUX_FUNCTION0 },        // default JTCK
#endif
    {PIN_LAST_PINMUX, PINMUX_FUNCTION0}//always put last!

};


#endif /* MTK_FUNCNO_PIN_SETUP_H */

