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