162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci//
362306a36Sopenharmony_ci// aw88395_lib.h  -- ACF bin parsing and check library file for aw88395
462306a36Sopenharmony_ci//
562306a36Sopenharmony_ci// Copyright (c) 2022-2023 AWINIC Technology CO., LTD
662306a36Sopenharmony_ci//
762306a36Sopenharmony_ci// Author: Bruce zhao <zhaolei@awinic.com>
862306a36Sopenharmony_ci//
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef __AW88395_LIB_H__
1162306a36Sopenharmony_ci#define __AW88395_LIB_H__
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define CHECK_REGISTER_NUM_OFFSET	(4)
1462306a36Sopenharmony_ci#define VALID_DATA_LEN			(4)
1562306a36Sopenharmony_ci#define VALID_DATA_ADDR		(4)
1662306a36Sopenharmony_ci#define PARSE_DSP_REG_NUM		(4)
1762306a36Sopenharmony_ci#define REG_DATA_BYTP_LEN		(8)
1862306a36Sopenharmony_ci#define CHECK_DSP_REG_NUM		(12)
1962306a36Sopenharmony_ci#define DSP_VALID_DATA_LEN		(12)
2062306a36Sopenharmony_ci#define DSP_VALID_DATA_ADDR		(12)
2162306a36Sopenharmony_ci#define PARSE_SOC_APP_NUM		(8)
2262306a36Sopenharmony_ci#define CHECK_SOC_APP_NUM		(12)
2362306a36Sopenharmony_ci#define APP_DOWNLOAD_ADDR		(4)
2462306a36Sopenharmony_ci#define APP_VALID_DATA_LEN		(12)
2562306a36Sopenharmony_ci#define APP_VALID_DATA_ADDR		(12)
2662306a36Sopenharmony_ci#define BIN_NUM_MAX			(100)
2762306a36Sopenharmony_ci#define HEADER_LEN			(60)
2862306a36Sopenharmony_ci#define BIN_DATA_TYPE_OFFSET		(8)
2962306a36Sopenharmony_ci#define DATA_LEN			(44)
3062306a36Sopenharmony_ci#define VALID_DATA_ADDR_OFFSET		(60)
3162306a36Sopenharmony_ci#define START_ADDR_OFFSET		(64)
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#define AW88395_FW_CHECK_PART		(10)
3462306a36Sopenharmony_ci#define HDADER_LEN			(60)
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#define HEADER_VERSION_OFFSET		(4)
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_cienum bin_header_version_enum {
3962306a36Sopenharmony_ci	HEADER_VERSION_V1 = 0x01000000,
4062306a36Sopenharmony_ci};
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_cienum data_type_enum {
4362306a36Sopenharmony_ci	DATA_TYPE_REGISTER   = 0x00000000,
4462306a36Sopenharmony_ci	DATA_TYPE_DSP_REG    = 0x00000010,
4562306a36Sopenharmony_ci	DATA_TYPE_DSP_CFG    = 0x00000011,
4662306a36Sopenharmony_ci	DATA_TYPE_SOC_REG    = 0x00000020,
4762306a36Sopenharmony_ci	DATA_TYPE_SOC_APP    = 0x00000021,
4862306a36Sopenharmony_ci	DATA_TYPE_DSP_FW     = 0x00000022,
4962306a36Sopenharmony_ci	DATA_TYPE_MULTI_BINS = 0x00002000,
5062306a36Sopenharmony_ci};
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_cienum data_version_enum {
5362306a36Sopenharmony_ci	DATA_VERSION_V1 = 0x00000001,
5462306a36Sopenharmony_ci	DATA_VERSION_MAX,
5562306a36Sopenharmony_ci};
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_cistruct bin_header_info {
5862306a36Sopenharmony_ci	unsigned int check_sum;
5962306a36Sopenharmony_ci	unsigned int header_ver;
6062306a36Sopenharmony_ci	unsigned int bin_data_type;
6162306a36Sopenharmony_ci	unsigned int bin_data_ver;
6262306a36Sopenharmony_ci	unsigned int bin_data_len;
6362306a36Sopenharmony_ci	unsigned int ui_ver;
6462306a36Sopenharmony_ci	unsigned char chip_type[8];
6562306a36Sopenharmony_ci	unsigned int reg_byte_len;
6662306a36Sopenharmony_ci	unsigned int data_byte_len;
6762306a36Sopenharmony_ci	unsigned int device_addr;
6862306a36Sopenharmony_ci	unsigned int valid_data_len;
6962306a36Sopenharmony_ci	unsigned int valid_data_addr;
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci	unsigned int reg_num;
7262306a36Sopenharmony_ci	unsigned int reg_data_byte_len;
7362306a36Sopenharmony_ci	unsigned int download_addr;
7462306a36Sopenharmony_ci	unsigned int app_version;
7562306a36Sopenharmony_ci	unsigned int header_len;
7662306a36Sopenharmony_ci};
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_cistruct bin_container {
7962306a36Sopenharmony_ci	unsigned int len;
8062306a36Sopenharmony_ci	unsigned char data[];
8162306a36Sopenharmony_ci};
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_cistruct aw_bin {
8462306a36Sopenharmony_ci	unsigned char *p_addr;
8562306a36Sopenharmony_ci	unsigned int all_bin_parse_num;
8662306a36Sopenharmony_ci	unsigned int multi_bin_parse_num;
8762306a36Sopenharmony_ci	unsigned int single_bin_parse_num;
8862306a36Sopenharmony_ci	struct bin_header_info header_info[BIN_NUM_MAX];
8962306a36Sopenharmony_ci	struct bin_container info;
9062306a36Sopenharmony_ci};
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci#endif
93