/*
 * Copyright (c) 2020, MediaTek Inc. All rights reserved.
 *
 * This software/firmware and related documentation ("MediaTek Software") are
 * protected under relevant copyright laws.
 * The information contained herein is confidential and proprietary to
 * MediaTek Inc. and/or its licensors.
 * Except as otherwise provided in the applicable licensing terms with
 * MediaTek Inc. and/or its licensors, any reproduction, modification, use or
 * disclosure of MediaTek Software, and information contained herein, in whole
 * or in part, shall be strictly prohibited.
*/

#ifndef _ECINFO_H_
#define _ECINFO_H_

#include <ecmap.h>

#define MAX_PAIR_NUMBER 256
#define MAX_KEY_LENGTH 128
#define MAX_VALUE_LENGTH 128
#define MAX_EC_PATH_BOOTARGS 30
#define MAX_PCODE 8
#define FILE_PATH_SIZE 128

/* MAX_PAIR_NUMBER * (MAX_KEY_LENGTH + MAX_KEY_LENGTH) */
#define MAX_EC_CONTENT 32768

#define EC_OFFSET 8
#define EC_PATH_OFFSET 28
#define MAX_VERSION_LENGTH 4
extern char EC_VERSION[5];
extern char PCODE[9];
extern char EC_PATH[128];

//For T6y Json Map struct expanding list
extern map_str_t EC_MAP, SOPQ_FlashPQ, SOPQ_LDM, EC_VCOM, SOPQ_DVCFG, SOPQ_HOST_043, SOPQ_HOST_050, SOPQ_HOST_055, SOPQ_HOST_065, SOPQ_HOST_075, SOPQ_HOST_085, SOPQ_HOST_100, SOPQ_PQU_043, SOPQ_PQU_050, SOPQ_PQU_055, SOPQ_PQU_065, SOPQ_PQU_075, SOPQ_PQU_085, SOPQ_PQU_100, SOPQ_HAL_043, SOPQ_HAL_050, SOPQ_HAL_055, SOPQ_HAL_065, SOPQ_HAL_075, SOPQ_HAL_085, SOPQ_HAL_100, SOPQ_SOPQD;

/*
 * EC Uboot main functions list:
 * 1. Get EC version in /vendor/tvconfig/ec/version.txt.
 * 2. Read Product Code and store in PCODE[].
 * 3. Implement Map function in Uboot.
 * 4. Parse base and optional json file into Memory and delete duplicated item,
 *     transfer them into Map struct.
 * 6. Implement get_ec_value and get_ec_version.
 */
extern int EC_READY, EX_EC_READY, EC_DEBUG_PREPARE, EC_DTBO_OVERLAY_FINISH, EC_SETBOOT_FINISH;
extern int EC_MAP_INIT, SOPQ_FlashPQ_INIT, SOPQ_LDM_INIT, SOPQ_SOPQD_INIT, EC_VCOM_INIT, SOPQ_DVCFG_INIT;

int do_ec_uboot_init(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int parse_ec_version(void);
int check_ec_filepath_if_ready(void);
int base_read_to_Map(void);
int ExBaseReadToMap(map_str_t *MAP, char* JsonFileAbPath);
int optional_ec_read_to_Map(char optional_ec_name[]);
int loop_all_optional_ec(void);
extern int subec_map_result(char *SubEcFunction, char Result[][128], int * NumECMap);
extern int ec_dtbo_overlay(char *ft_addr, char mode);
extern int ec_dtbo_overlay_pre(void);
extern int get_ec_value(const char* key, char* value, int length);
extern int get_ec_version(char* version, int length);

//For T6y common Json Parse
extern int ExGetJsonValue(char* ExJsonFunction, const char* key, char* value, int length);
#endif
