/* 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 CONFIG_DEFAULT_H
#define CONFIG_DEFAULT_H

#include "x_pinmux.h"

//----------------------------------------------------------------------------
// Initial dram settings
//----------------------------------------------------------------------------
#define DEFAULT_DRAM_TYPE               DDR_III_x5
#define DEFAULT_DDR_CLOCK               (1800000000)
//for MTK turnkey PCB only (in bootp.c)
#define DEFAULT_DRAM_PCB_CHK                (1)


#define TOTAL_MEM_SIZE                      (1024 * 1024 * 1024)
#define TOTAL_CHB_MEM_SIZE                  (1024 * 1024 * 1024)

//----------------------------------------------------------------------------
// FBM setup
//----------------------------------------------------------------------------
#ifndef FBM_MEM_CFG_SIZE
#define FBM_MEM_CFG_SIZE                FBM_MEM_CFG_MT5891_3DTV
#endif /* FBM_MEM_CFG_SIZE */

#ifndef FBM_MEM_CHB_CFG_SIZE
#define FBM_MEM_CHB_CFG_SIZE            (FBM_MEM_CFG_MT5891_3DTV_CHB)     
#endif

#ifndef FBM_MEM_CHC_CFG_SIZE
#define FBM_MEM_CHC_CFG_SIZE            (FBM_MEM_CFG_MT5891_3DTV_CHC)     
#endif

//----------------------------------------------------------------------------
// Default Panel setting
//----------------------------------------------------------------------------
#ifndef DEFAULT_PANEL_SELECT
#define DEFAULT_PANEL_SELECT            (PANEL_DEFAULT)
#endif
#define BACKLIGHT_GPIO                  (OPCTRL(4))
#define BACKLIGHT_ON_VAL                (0)
#define PANELPOWER_GPIO                 (OPCTRL(9))
#define PANELPOWER_ON_VAL               (1)
// disable spread spectrum for vga output
#define SPREAD_SPECTRUM_PERMILLAGE      (0)
// pwm backlight adjustment setting
#define PANEL_BACKLIGHT_PWM_PORT        (1)
//3D Enable & LR GPIO
//#define EXT_3D_ENABLE_PORT                  (GPIO(52))
//#define EXT_3D_LR_PIN                      (PIN_GPIO53)
//#define EXT_3D_LR_PIN_FUNC                    (1)

// VB1 lockn & htpdn [Wukong BI]
#define PANEL_VB1_LOCKN_PIN          (PIN_GPIO50)
#define PANEL_VB1_LOCKN_PIN_FUNC     (2)
#define PANEL_VB1_HTPDN_PIN          (PIN_GPIO49)
#define PANEL_VB1_HTPDN_PIN_FUNC     (2)
#define PANEL_VB1_OSD_LOCKN_PIN      (PIN_GPIO54)
#define PANEL_VB1_OSD_LOCKN_PIN_FUNC (2)
#define PANEL_VB1_OSD_HTPDN_PIN      (PIN_GPIO53)
#define PANEL_VB1_OSD_HTPDN_PIN_FUNC (5)

//----------------------------------------------------------------------------
// Audio Customization
//----------------------------------------------------------------------------
#define AUDIO_Mute_Gpio_Num             (OPCTRL(11))
#define AUDIO_Amp_Gpio_Num              (OPCTRL(5))
#define AUDIO_HP_PLUG_IN_GPIO           (OPCTRL(6))
#define AUDIO_MUTE_GPIO_POLARITY        AUD_MUTE_GPIO_LOW_ENALBE
#define AUDIO_AMP_GPIO_POLARITY         AUD_AMP_GPIO_HIGH_ENALBE
#define AUDIO_HP_PLUG_IN_POLARITY       (AUD_GPIO_LOW_ENALBE)

//----------------------------------------------------------------------------
// Other GPIO customization
//----------------------------------------------------------------------------
#define FLAG_EXT_STATUS                 (0)
// #define POWER_LED_GPIO               (OPCTRL(0))
// #define POWER_LED_ON_VAL             (0)
// #define BACKUP_LED_GPIO              (OPCTRL(0))
// #define BACKUP_LED_ON_VAL            (0)
// #define POWER_CTRL_GPIO
// #define POWER_CTRL_ON_VAL

//----------------------------------------------------------------------------
// EEPROM customization
//----------------------------------------------------------------------------
#define SYSTEM_EEPROM_SIZE                (4096)
#define SYSTEM_EEPROM_BUS                 (0)
#define SYSTEM_EEPROM_ADDRESS             (0xA0)
#define SYSTEM_EEPROM_CLKDIV              (0x100)
#define SYSTEM_EEPROM_PAGESIZE              (8)
#define SYSTEM_EEPROM_WP_GPIO               (OPCTRL(7))   // GPIO18.
#define SYSTEM_EEPROM_WP_ENABLE_POLARITY    (1)
#define EDID_EEPROM_WP_GPIO			        (14)   // GPIO14.
#define EDID_EEPROM_WP_ENABLE_POLARITY      (1)
//----------------------------------------------------------------------------
// SIF customization
//----------------------------------------------------------------------------
#define SIF_ENABLE_SCL_STRETCH      (0)
#define SIF_DISABLE_OPEN_DRAIN      (0)
#define SIF_ENABLE_PDWNC_MASTER      (0)
#define SIF_ENABLE_PDWNC_MASTER1      (0)

//----------------------------------------------------------------------------
// USB Customization
//----------------------------------------------------------------------------
// "USBx_PORT_USING_LOADER & USBx_PORT_USING" related define is only for USB2.0 port
// 1. Loader, USB port using define (1)=used (0)=not used
#define USB0_PORT_USING_LOADER              (1)
#define USB1_PORT_USING_LOADER              (1)
#define USB2_PORT_USING_LOADER              (0)
#define USB3_PORT_USING_LOADER              (1)

// 2. Nuclues/Linux/Android System USB port using define (1)=used (0)=not used
#define USB0_PORT_USING                     (1)
#define USB1_PORT_USING                     (1) 
#define USB2_PORT_USING                     (0) 
#define USB3_PORT_USING                     (1)

// 3. USB +5V power switch Vbus GPIO control, if vbus not control by GPIO, mark off it.
#define USB0_VBUS_GPIO                      GPIO(42)    // GPIO42.
#define USB0_VBUS_GPIO_POLARITY		        (1)
#define USB1_VBUS_GPIO                      GPIO(43)    // GPIO43
#define USB1_VBUS_GPIO_POLARITY		        (1)
#define USB2_VBUS_GPIO                      GPIO(48)    // GPIO48
#define USB2_VBUS_GPIO_POLARITY		        (1)
#define USB3_VBUS_GPIO                      OPCTRL(10)  // OPCTRL10.
#define USB3_VBUS_GPIO_POLARITY		        (1)

// 4. USB power switch overcurrent GPIO control, if have not ic to control by GPIO, mark off it.
#define USB0_OC_GPIO                        ADIN(4)     // ADIN 4.
#define USB0_OC_GPIO_POLARITY		        (0)
#define USB1_OC_GPIO                        ADIN(4)     // ADIN 4.
#define USB1_OC_GPIO_POLARITY		        (0)
#define USB2_OC_GPIO                        ADIN(5)     // ADIN 5.
#define USB2_OC_GPIO_POLARITY		        (0)
#define USB3_OC_GPIO                        ADIN(5)     // ADIN 5.
#define USB3_OC_GPIO_POLARITY		        (0)

// 5. Detect USB upgrade time, default is 0, but some device maybe can't detect when upgrade.
// If possible, set it to (300)ms when in customer's module.
#define USB_LOADER_WAIT_TIME                (0)

//#define USB_DISABLE_SUSPEND_MODE /* Disable USB suspend, share 240 Mhz with H.264.*/
//----------------------------------------------------------------------------
// Button Customization
//----------------------------------------------------------------------------
#define FLAG_BUTTON_SUPPORT                 (0)


//----------------------------------------------------------------------------
// MTK IR only setting
//----------------------------------------------------------------------------
#define IR_INCLUDE_FILE                     "mtk/mtk_ir.h"

#ifndef NPTV_SOURCE_TABLE
#define NPTV_SOURCE_TABLE                   "mtk/source_table.c"
#endif

#ifndef T8032UP_INCLUDE_FILE
#define T8032UP_INCLUDE_FILE                "mtk/mtk_t8032fw.h"
#define T8032UP_OFFSET                      au1T8032FW
#define T8032UP_SIZE                        T8032FW_SIZE
#endif
//----------------------------------------------------------------------------
// srvad wakeup customization
//----------------------------------------------------------------------------
//for srvad wakeup test
#define KEYPAD_WAKEUP_BIT                   (DKBIT_ENTER | DKBIT_POWER | DKBIT_PRG_UP | DKBIT_PRG_DOWN | DKBIT_VOL_DOWN | DKBIT_VOL_UP | DKBIT_INPUT_SRC | DKBIT_MENU)

//----------------------------------------------------------------------------
// default HDMI GPIO control
//----------------------------------------------------------------------------
#ifndef HDMI_GPIO_CONF
#define HDMI_GPIO_CONF                      "mtk/hdmi_conf.c"
#endif

/*
 * default VGA table
*/
#ifndef VGA_INCLUDE_FILE
#define VGA_INCLUDE_FILE                    "mtk/mtk_vga.h"
#endif

//----------------------------------------------------------------------------
// Tcon Customization
//----------------------------------------------------------------------------
// support LVDS and MLVDS both
#define PANEL_DISPLAY_TYPE_ALLOWED_MASK ((1<<PANEL_DISPLAY_TYPE_LVDS) | (1 << PANEL_DISPLAY_TYPE_MLVDS) | (1 << PANEL_DISPLAY_TYPE_VB1))

#ifndef TCON_CUST_FILE
#define TCON_CUST_FILE                      "mtk/Oryx_tcon_cust.c"
#endif

//----------------------------------------------------------------------------
// SCART out configuration
//----------------------------------------------------------------------------
#ifndef TVE_INCLUDE_FILE
#define TVE_INCLUDE_FILE                "mtk/mtk_tve.c"
#endif

//----------------------------------------------------------------------------
// DMX configuration
//----------------------------------------------------------------------------
#ifndef DMX_INCLUDE_FILE
#define DMX_INCLUDE_FILE               "mtk/mtk_dmx.h"
#endif

/*
 * default quality table
*/
#ifndef QTYTBL_INCLUDE_FILE
//#define QTYTBL_INCLUDE_FILE                 "mtk/QTY_DEFAULT/mtk_QtyTbl.h"
#endif

#ifdef SUPPORT_FLASH_PQ
#endif // #if SUPPORT_FLASH_PQ

/*
 * default color parameter
*/
#ifndef COLOR_PARAM_INCLUDE_FILE
//#define COLOR_PARAM_INCLUDE_FILE            "mtk/PANEL_DEFAULT/color_param.h"
#endif

/*
 * dynamic backlight parameter
*/

#else /* CONFIG_DEFAULT_H */
#error "Cannot include multi-config files"
#endif /* CONFIG_DEFAULT_H */

