xref: /linux/drivers/media/pci/intel/ipu6/ipu6-cpd.h (revision 6fd600d742744dc7ef7fc65ca26daa2b1163158a)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (C) 2015--2024 Intel Corporation */
3 
4 #ifndef IPU6_CPD_H
5 #define IPU6_CPD_H
6 
7 struct ipu6_device;
8 struct ipu6_bus_device;
9 
10 #define IPU6_CPD_SIZE_OF_FW_ARCH_VERSION	7
11 #define IPU6_CPD_SIZE_OF_SYSTEM_VERSION		11
12 #define IPU6_CPD_SIZE_OF_COMPONENT_NAME		12
13 
14 #define IPU6_CPD_METADATA_EXTN_TYPE_IUNIT	0x10
15 
16 #define IPU6_CPD_METADATA_IMAGE_TYPE_RESERVED		0
17 #define IPU6_CPD_METADATA_IMAGE_TYPE_BOOTLOADER		1
18 #define IPU6_CPD_METADATA_IMAGE_TYPE_MAIN_FIRMWARE	2
19 
20 #define IPU6_CPD_PKG_DIR_PSYS_SERVER_IDX	0
21 #define IPU6_CPD_PKG_DIR_ISYS_SERVER_IDX	1
22 
23 #define IPU6_CPD_PKG_DIR_CLIENT_PG_TYPE		3
24 
25 #define IPU6_CPD_METADATA_HASH_KEY_SIZE		48
26 #define IPU6SE_CPD_METADATA_HASH_KEY_SIZE	32
27 
28 struct ipu6_cpd_module_data_hdr {
29 	u32 hdr_len;
30 	u32 endian;
31 	u32 fw_pkg_date;
32 	u32 hive_sdk_date;
33 	u32 compiler_date;
34 	u32 target_platform_type;
35 	u8 sys_ver[IPU6_CPD_SIZE_OF_SYSTEM_VERSION];
36 	u8 fw_arch_ver[IPU6_CPD_SIZE_OF_FW_ARCH_VERSION];
37 	u8 rsvd[2];
38 } __packed;
39 
40 /*
41  * ipu6_cpd_hdr structure updated as the chksum and
42  * sub_partition_name is unused on host side
43  * CSE layout version 1.6 for IPU6SE (hdr_len = 0x10)
44  * CSE layout version 1.7 for IPU6 (hdr_len = 0x14)
45  */
46 struct ipu6_cpd_hdr {
47 	u32 hdr_mark;
48 	u32 ent_cnt;
49 	u8 hdr_ver;
50 	u8 ent_ver;
51 	u8 hdr_len;
52 } __packed;
53 
54 struct ipu6_cpd_ent {
55 	u8 name[IPU6_CPD_SIZE_OF_COMPONENT_NAME];
56 	u32 offset;
57 	u32 len;
58 	u8 rsvd[4];
59 } __packed;
60 
61 struct ipu6_cpd_metadata_cmpnt_hdr {
62 	u32 id;
63 	u32 size;
64 	u32 ver;
65 } __packed;
66 
67 struct ipu6_cpd_metadata_cmpnt {
68 	struct ipu6_cpd_metadata_cmpnt_hdr hdr;
69 	u8 sha2_hash[IPU6_CPD_METADATA_HASH_KEY_SIZE];
70 	u32 entry_point;
71 	u32 icache_base_offs;
72 	u8 attrs[16];
73 } __packed;
74 
75 struct ipu6se_cpd_metadata_cmpnt {
76 	struct ipu6_cpd_metadata_cmpnt_hdr hdr;
77 	u8 sha2_hash[IPU6SE_CPD_METADATA_HASH_KEY_SIZE];
78 	u32 entry_point;
79 	u32 icache_base_offs;
80 	u8 attrs[16];
81 } __packed;
82 
83 struct ipu6_cpd_metadata_extn {
84 	u32 extn_type;
85 	u32 len;
86 	u32 img_type;
87 	u8 rsvd[16];
88 } __packed;
89 
90 struct ipu6_cpd_client_pkg_hdr {
91 	u32 prog_list_offs;
92 	u32 prog_list_size;
93 	u32 prog_desc_offs;
94 	u32 prog_desc_size;
95 	u32 pg_manifest_offs;
96 	u32 pg_manifest_size;
97 	u32 prog_bin_offs;
98 	u32 prog_bin_size;
99 } __packed;
100 
101 int ipu6_cpd_create_pkg_dir(struct ipu6_bus_device *adev, const void *src);
102 void ipu6_cpd_free_pkg_dir(struct ipu6_bus_device *adev);
103 int ipu6_cpd_validate_cpd_file(struct ipu6_device *isp, const void *cpd_file,
104 			       unsigned long cpd_file_size);
105 #endif /* IPU6_CPD_H */
106