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

//----------------------------------------------------------------------------
// Flash Partition configuration
//----------------------------------------------------------------------------
#if defined(LINUX_TURNKEY_SOLUTION) || defined(__KERNEL__)
    #ifndef NAND_FLASH_TOTAL_SIZE
        #define NAND_FLASH_TOTAL_SIZE        (2*1024*1024*1024)
    #endif
    
    #ifndef PART_RESERV_SIZE
        #define PART_RESERV_SIZE                (   256*1024)
    #endif

    #define PART_SDM_BAD_SECTOR_SIZE        (5*1024*1024)

    #define PART_LOADER_SIZE                (2*1024*1024)
    #define PART_UBOOT_ENV_SIZE             (   512*1024)
    #define PART_KERNEL_SIZE                (4*1024*1024)
    #define PART_CHANNEL_SIZE               (1*1024*1024)
    #define PART_PQ_SIZE                   (12*1024*1024)
    #define PART_AQ_SIZE                    (2*1024*1024)
    #define PART_3RDB_SIZE                  (PART_3RD_SIZE)
    #define PART_PERM_SIZE                  (8*1024*1024)

    #ifndef PART_GAME_SIZE
        #define PART_GAME_SIZE                  (PART_RESERV_SIZE)
    #endif
    #ifndef PART_ADSP_SIZE
        #define PART_ADSP_SIZE                  (5*1024*1024)
    #endif
    #define PART_ACFG_DESC_SIZE             (1*1024*1024) /* Acfg description size 1M */
    #define PART_SCHED_PVR_SIZE             (256*1024) /* Schedule PVR size 256K */

	

    #ifndef PART_WELCOME_LOGO_SIZE
        #define PART_WELCOME_LOGO_SIZE          (5*1024*1024)
    #endif

    #define BDM_NON_3RD_SIZE  \
                            (PART_LOADER_SIZE + PART_UBOOT_ENV_SIZE + \
                             PART_RESERV_SIZE + PART_RESERV_SIZE + \
                             PART_KERNEL_SIZE + PART_KERNEL_SIZE + \
                             PART_ROOTFS_SIZE + PART_ROOTFS_SIZE + \
                             PART_BASIC_SIZE + \
                             PART_PERM_SIZE + \
                             FAST_INIT_SUSP_SIZE)

    #define NAND_PART_SIZE_0                (PART_LOADER_SIZE)              /* loader image     */
    #define NAND_PART_SIZE_1                (PART_UBOOT_ENV_SIZE)           /* uboot env        */
    #define NAND_PART_SIZE_2                (PART_RESERV_SIZE)              /* reserved         */
    #define NAND_PART_SIZE_3                (PART_RESERV_SIZE)              /* reserved         */
    #define NAND_PART_SIZE_4                (PART_KERNEL_SIZE)              /* kernel A         */
    #define NAND_PART_SIZE_5                (PART_KERNEL_SIZE)              /* kernel B         */
    #define NAND_PART_SIZE_6                (PART_ROOTFS_SIZE)              /* rootfs A         */
    #define NAND_PART_SIZE_7                (PART_ROOTFS_SIZE)              /* rootfs B         */
    #define NAND_PART_SIZE_8                (PART_BASIC_SIZE)               /* basic            */
    #define NAND_PART_SIZE_9                (PART_3RD_SIZE)                 /* 3rdA             */
    #define NAND_PART_SIZE_10               (PART_3RDB_SIZE)                 /* 3rdB             */
    #define NAND_PART_SIZE_11               (PART_PERM_SIZE)                /* perm             */
    #define NAND_PART_SIZE_12               (PART_3RD_RW_SIZE )             /* 3rd_rw           */
    #define NAND_PART_SIZE_13               (PART_3RD_RO_SIZE)              /* ro_data          */
    #define NAND_PART_SIZE_14               (PART_GAME_SIZE)                /* game             */
    #define NAND_PART_SIZE_15               (PART_CHANNEL_SIZE)             /* channel list A   */
    #define NAND_PART_SIZE_16               (PART_CHANNEL_SIZE)             /* channel list B   */
    #define NAND_PART_SIZE_17               (PART_PQ_SIZE)                  /* Flash PQ         */
    #define NAND_PART_SIZE_18               (PART_AQ_SIZE)                  /* Flash AQ         */
    #define NAND_PART_SIZE_19               (PART_ADSP_SIZE)                /* ADSP             */
    #define NAND_PART_SIZE_20               (PART_RESERV_SIZE)              /* HDCPv2.0         */
    #define NAND_PART_SIZE_21               (PART_RESERV_SIZE)              /* EDID             */
    #define NAND_PART_SIZE_22               (PART_RESERV_SIZE)              /* Acfg description */
    #define NAND_PART_SIZE_23               (PART_WELCOME_LOGO_SIZE)        /* welcome logo     */
    #define NAND_PART_SIZE_24               (PART_RESERV_SIZE)              /* ci               */
    #define NAND_PART_SIZE_25               (PART_RESERV_SIZE)              /* Schedule PVR     */
    #define NAND_PART_SIZE_26               (PART_RESERV_SIZE)              /* DVBS default db  */
    #define NAND_PART_SIZE_27               (PART_CHANNEL_SIZE)             /* For TPV default channel list c */
    #define NAND_PART_SIZE_28               (PART_CHANNEL_SIZE)             /* For TPV default channel list d */

    #define NAND_FLASH_STATIC_LAST_PART_ID  (14)

    #define NAND_FLASH_STATIC_PART_SIZE \
            ((NAND_PART_SIZE_0) + \
            (NAND_PART_SIZE_1) + (NAND_PART_SIZE_2) + (NAND_PART_SIZE_3) + \
            (NAND_PART_SIZE_4) + (NAND_PART_SIZE_5) + (NAND_PART_SIZE_6) + \
            (NAND_PART_SIZE_7) + (NAND_PART_SIZE_8) + (NAND_PART_SIZE_9) + \
            (NAND_PART_SIZE_10) + (NAND_PART_SIZE_11) + (NAND_PART_SIZE_12) +\
            (NAND_PART_SIZE_13) + (NAND_PART_SIZE_14))

    #define SDM_TOTAL_SIZE \
            ((NAND_PART_SIZE_15) + (NAND_PART_SIZE_16) + (NAND_PART_SIZE_17) + (NAND_PART_SIZE_18) + (NAND_PART_SIZE_19) + \
             (NAND_PART_SIZE_20) + (NAND_PART_SIZE_21) + (NAND_PART_SIZE_22) + (NAND_PART_SIZE_23) + (NAND_PART_SIZE_24) + \
             (NAND_PART_SIZE_25) + (NAND_PART_SIZE_26) + (NAND_PART_SIZE_27) + (NAND_PART_SIZE_28) + \
             (PART_SDM_BAD_SECTOR_SIZE))


    /* The NAND_PART_NAME_0-7 use default names. */
    #define NAND_PART_NAME_8                    "basic"
    #define NAND_PART_NAME_9                    "3rdA"
    #define NAND_PART_NAME_10                   "3rdB"
    #define NAND_PART_NAME_11                   "perm"
    #define NAND_PART_NAME_12                   "3rd_rw"
    #define NAND_PART_NAME_13                   "ro_data"
    #define NAND_PART_NAME_14                   "game"
    #define NAND_PART_NAME_15                   "channelA"
    #define NAND_PART_NAME_16                   "channelB"
    #define NAND_PART_NAME_17                   "pq"
    #define NAND_PART_NAME_18                   "aq"
    #define NAND_PART_NAME_19                   "adsp"
    #define NAND_PART_NAME_20                   "reserved"
    #define NAND_PART_NAME_21                   "edid"
    #define NAND_PART_NAME_22                   "AcfgDesc"
    #define NAND_PART_NAME_23                   "logo"
    #define NAND_PART_NAME_24                   "ci"
    #define NAND_PART_NAME_25                   "SchPVR"
    #define NAND_PART_NAME_26                   "dvbs_db"
    #define NAND_PART_NAME_27                   "channel_s_A"
    #define NAND_PART_NAME_28                   "channel_s_B"

#endif //defined(LINUX_TURNKEY_SOLUTION) || defined(__KERNEL__)

    #ifdef CC_HDMI_2_0_HDCP_BIN
        #define FLASH_HDCP_BIN_PARTITION    (20)
        #define FLASH_EDID_BIN_PARTITION    (21)
    #endif

    #ifdef ADSP_BIN_SUPPORT
        #define FLASH_ADSP_BIN_PARTITION                (19)
    #endif
#if 0
#ifdef SUPPORT_FLASH_PQ
#ifdef LINUX_TURNKEY_SOLUTION
#define FLASH_PQ_BASE_PARTITION             (17)
#endif
#endif // #if SUPPORT_FLASH_PQ

// FlashAQ related
#define FLASH_AQ_PART_ID                (18)//(14)
#define FLASH_AQ_BASE_OFFSET            (0)//(0x1ACD0)

#ifdef SUPPORT_FLASH_AQ
#ifdef LINUX_TURNKEY_SOLUTION
#define FLASH_AQ_BASE_PARTITION             (24)
#endif
#endif // #if SUPPORT_FLASH_AQ
#endif

#else /* _PHILIPS_2K14_FLASH_LAYOUT_H */
#error "Cannot include multi flash layout config files"
#endif /* _PHILIPS_2K14_FLASH_LAYOUT_H */

