xref: /linux/sound/soc/codecs/aw88395/aw88395_lib.h (revision 4345865b003be60fed335efbed5aee61aac86da0)
1*4345865bSWeidong Wang // SPDX-License-Identifier: GPL-2.0-only
2*4345865bSWeidong Wang //
3*4345865bSWeidong Wang // aw88395_lib.h  -- ACF bin parsing and check library file for aw88395
4*4345865bSWeidong Wang //
5*4345865bSWeidong Wang // Copyright (c) 2022-2023 AWINIC Technology CO., LTD
6*4345865bSWeidong Wang //
7*4345865bSWeidong Wang // Author: Bruce zhao <zhaolei@awinic.com>
8*4345865bSWeidong Wang //
9*4345865bSWeidong Wang 
10*4345865bSWeidong Wang #ifndef __AW88395_LIB_H__
11*4345865bSWeidong Wang #define __AW88395_LIB_H__
12*4345865bSWeidong Wang 
13*4345865bSWeidong Wang #define CHECK_REGISTER_NUM_OFFSET	(4)
14*4345865bSWeidong Wang #define VALID_DATA_LEN			(4)
15*4345865bSWeidong Wang #define VALID_DATA_ADDR		(4)
16*4345865bSWeidong Wang #define PARSE_DSP_REG_NUM		(4)
17*4345865bSWeidong Wang #define REG_DATA_BYTP_LEN		(8)
18*4345865bSWeidong Wang #define CHECK_DSP_REG_NUM		(12)
19*4345865bSWeidong Wang #define DSP_VALID_DATA_LEN		(12)
20*4345865bSWeidong Wang #define DSP_VALID_DATA_ADDR		(12)
21*4345865bSWeidong Wang #define PARSE_SOC_APP_NUM		(8)
22*4345865bSWeidong Wang #define CHECK_SOC_APP_NUM		(12)
23*4345865bSWeidong Wang #define APP_DOWNLOAD_ADDR		(4)
24*4345865bSWeidong Wang #define APP_VALID_DATA_LEN		(12)
25*4345865bSWeidong Wang #define APP_VALID_DATA_ADDR		(12)
26*4345865bSWeidong Wang #define BIN_NUM_MAX			(100)
27*4345865bSWeidong Wang #define HEADER_LEN			(60)
28*4345865bSWeidong Wang #define BIN_DATA_TYPE_OFFSET		(8)
29*4345865bSWeidong Wang #define DATA_LEN			(44)
30*4345865bSWeidong Wang #define VALID_DATA_ADDR_OFFSET		(60)
31*4345865bSWeidong Wang #define START_ADDR_OFFSET		(64)
32*4345865bSWeidong Wang 
33*4345865bSWeidong Wang #define AW88395_FW_CHECK_PART		(10)
34*4345865bSWeidong Wang #define HDADER_LEN			(60)
35*4345865bSWeidong Wang 
36*4345865bSWeidong Wang #define HEADER_VERSION_OFFSET		(4)
37*4345865bSWeidong Wang 
38*4345865bSWeidong Wang enum bin_header_version_enum {
39*4345865bSWeidong Wang 	HEADER_VERSION_V1 = 0x01000000,
40*4345865bSWeidong Wang };
41*4345865bSWeidong Wang 
42*4345865bSWeidong Wang enum data_type_enum {
43*4345865bSWeidong Wang 	DATA_TYPE_REGISTER   = 0x00000000,
44*4345865bSWeidong Wang 	DATA_TYPE_DSP_REG    = 0x00000010,
45*4345865bSWeidong Wang 	DATA_TYPE_DSP_CFG    = 0x00000011,
46*4345865bSWeidong Wang 	DATA_TYPE_SOC_REG    = 0x00000020,
47*4345865bSWeidong Wang 	DATA_TYPE_SOC_APP    = 0x00000021,
48*4345865bSWeidong Wang 	DATA_TYPE_DSP_FW     = 0x00000022,
49*4345865bSWeidong Wang 	DATA_TYPE_MULTI_BINS = 0x00002000,
50*4345865bSWeidong Wang };
51*4345865bSWeidong Wang 
52*4345865bSWeidong Wang enum data_version_enum {
53*4345865bSWeidong Wang 	DATA_VERSION_V1 = 0x00000001,
54*4345865bSWeidong Wang 	DATA_VERSION_MAX,
55*4345865bSWeidong Wang };
56*4345865bSWeidong Wang 
57*4345865bSWeidong Wang struct bin_header_info {
58*4345865bSWeidong Wang 	unsigned int check_sum;
59*4345865bSWeidong Wang 	unsigned int header_ver;
60*4345865bSWeidong Wang 	unsigned int bin_data_type;
61*4345865bSWeidong Wang 	unsigned int bin_data_ver;
62*4345865bSWeidong Wang 	unsigned int bin_data_len;
63*4345865bSWeidong Wang 	unsigned int ui_ver;
64*4345865bSWeidong Wang 	unsigned char chip_type[8];
65*4345865bSWeidong Wang 	unsigned int reg_byte_len;
66*4345865bSWeidong Wang 	unsigned int data_byte_len;
67*4345865bSWeidong Wang 	unsigned int device_addr;
68*4345865bSWeidong Wang 	unsigned int valid_data_len;
69*4345865bSWeidong Wang 	unsigned int valid_data_addr;
70*4345865bSWeidong Wang 
71*4345865bSWeidong Wang 	unsigned int reg_num;
72*4345865bSWeidong Wang 	unsigned int reg_data_byte_len;
73*4345865bSWeidong Wang 	unsigned int download_addr;
74*4345865bSWeidong Wang 	unsigned int app_version;
75*4345865bSWeidong Wang 	unsigned int header_len;
76*4345865bSWeidong Wang };
77*4345865bSWeidong Wang 
78*4345865bSWeidong Wang struct bin_container {
79*4345865bSWeidong Wang 	unsigned int len;
80*4345865bSWeidong Wang 	unsigned char data[];
81*4345865bSWeidong Wang };
82*4345865bSWeidong Wang 
83*4345865bSWeidong Wang struct aw_bin {
84*4345865bSWeidong Wang 	unsigned char *p_addr;
85*4345865bSWeidong Wang 	unsigned int all_bin_parse_num;
86*4345865bSWeidong Wang 	unsigned int multi_bin_parse_num;
87*4345865bSWeidong Wang 	unsigned int single_bin_parse_num;
88*4345865bSWeidong Wang 	struct bin_header_info header_info[BIN_NUM_MAX];
89*4345865bSWeidong Wang 	struct bin_container info;
90*4345865bSWeidong Wang };
91*4345865bSWeidong Wang 
92*4345865bSWeidong Wang #endif
93