1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2007-2016, Synaptics Incorporated
4 * Copyright (C) 2016 Zodiac Inflight Innovations
10 /* F34 image file offsets. */
11 #define F34_FW_IMAGE_OFFSET 0x100
13 /* F34 register offsets. */
14 #define F34_BLOCK_DATA_OFFSET 2
17 #define F34_WRITE_FW_BLOCK 0x2
18 #define F34_ERASE_ALL 0x3
19 #define F34_READ_CONFIG_BLOCK 0x5
20 #define F34_WRITE_CONFIG_BLOCK 0x6
21 #define F34_ERASE_CONFIG 0x7
22 #define F34_ENABLE_FLASH_PROG 0xf
24 #define F34_STATUS_IN_PROGRESS 0xff
25 #define F34_STATUS_IDLE 0x80
27 #define F34_IDLE_WAIT_MS 500
28 #define F34_ENABLE_WAIT_MS 300
29 #define F34_ERASE_WAIT_MS 5000
30 #define F34_WRITE_WAIT_MS 3000
32 #define F34_BOOTLOADER_ID_LEN 2
35 #define V7_FLASH_STATUS_OFFSET 0
36 #define V7_PARTITION_ID_OFFSET 1
37 #define V7_BLOCK_NUMBER_OFFSET 2
38 #define V7_TRANSFER_LENGTH_OFFSET 3
39 #define V7_COMMAND_OFFSET 4
40 #define V7_PAYLOAD_OFFSET 5
41 #define V7_BOOTLOADER_ID_OFFSET 1
43 #define IMAGE_HEADER_VERSION_10 0x10
45 #define CONFIG_ID_SIZE 32
46 #define PRODUCT_ID_SIZE 10
49 #define HAS_BSR BIT(5)
50 #define HAS_CONFIG_ID BIT(3)
51 #define HAS_GUEST_CODE BIT(6)
52 #define HAS_DISP_CFG BIT(5)
56 #define CMD_V7_ENTER_BL 1
58 #define CMD_V7_WRITE 3
59 #define CMD_V7_ERASE 4
60 #define CMD_V7_ERASE_AP 5
61 #define CMD_V7_SENSOR_ID 6
64 #define v7_CMD_WRITE_FW 1
65 #define v7_CMD_WRITE_CONFIG 2
66 #define v7_CMD_WRITE_LOCKDOWN 3
67 #define v7_CMD_WRITE_GUEST_CODE 4
68 #define v7_CMD_READ_CONFIG 5
69 #define v7_CMD_ERASE_ALL 6
70 #define v7_CMD_ERASE_UI_FIRMWARE 7
71 #define v7_CMD_ERASE_UI_CONFIG 8
72 #define v7_CMD_ERASE_BL_CONFIG 9
73 #define v7_CMD_ERASE_DISP_CONFIG 10
74 #define v7_CMD_ERASE_FLASH_CONFIG 11
75 #define v7_CMD_ERASE_GUEST_CODE 12
76 #define v7_CMD_ENABLE_FLASH_PROG 13
78 #define v7_UI_CONFIG_AREA 0
79 #define v7_PM_CONFIG_AREA 1
80 #define v7_BL_CONFIG_AREA 2
81 #define v7_DP_CONFIG_AREA 3
82 #define v7_FLASH_CONFIG_AREA 4
84 /* F34 V7 partition IDs */
85 #define BOOTLOADER_PARTITION 1
86 #define DEVICE_CONFIG_PARTITION 2
87 #define FLASH_CONFIG_PARTITION 3
88 #define MANUFACTURING_BLOCK_PARTITION 4
89 #define GUEST_SERIALIZATION_PARTITION 5
90 #define GLOBAL_PARAMETERS_PARTITION 6
91 #define CORE_CODE_PARTITION 7
92 #define CORE_CONFIG_PARTITION 8
93 #define GUEST_CODE_PARTITION 9
94 #define DISPLAY_CONFIG_PARTITION 10
96 /* F34 V7 container IDs */
97 #define TOP_LEVEL_CONTAINER 0
98 #define UI_CONTAINER 1
99 #define UI_CONFIG_CONTAINER 2
100 #define BL_CONTAINER 3
101 #define BL_IMAGE_CONTAINER 4
102 #define BL_CONFIG_CONTAINER 5
103 #define BL_LOCKDOWN_INFO_CONTAINER 6
104 #define PERMANENT_CONFIG_CONTAINER 7
105 #define GUEST_CODE_CONTAINER 8
106 #define BL_PROTOCOL_DESCRIPTOR_CONTAINER 9
107 #define UI_PROTOCOL_DESCRIPTOR_CONTAINER 10
108 #define RMI_SELF_DISCOVERY_CONTAINER 11
109 #define RMI_PAGE_CONTENT_CONTAINER 12
110 #define GENERAL_INFORMATION_CONTAINER 13
111 #define DEVICE_CONFIG_CONTAINER 14
112 #define FLASH_CONFIG_CONTAINER 15
113 #define GUEST_SERIALIZATION_CONTAINER 16
114 #define GLOBAL_PARAMETERS_CONTAINER 17
115 #define CORE_CODE_CONTAINER 18
116 #define CORE_CONFIG_CONTAINER 19
117 #define DISPLAY_CONFIG_CONTAINER 20
119 struct f34v7_query_1_7
{
120 u8 bl_minor_revision
; /* query 1 */
121 u8 bl_major_revision
;
122 __le32 bl_fw_id
; /* query 2 */
123 u8 minimum_write_size
; /* query 3 */
125 __le16 flash_page_size
;
126 __le16 adjustable_partition_area_size
; /* query 4 */
127 __le16 flash_config_length
; /* query 5 */
128 __le16 payload_length
; /* query 6 */
129 u8 partition_support
[4]; /* query 7 */
132 struct f34v7_data_1_5
{
135 __le16 transfer_length
;
145 struct partition_table
{
148 __le16 partition_length
;
149 __le16 start_physical_address
;
150 __le16 partition_properties
;
153 struct physical_address
{
160 struct container_descriptor
{
161 __le32 content_checksum
;
169 u8 container_option_flags
[4];
170 __le32 content_options_length
;
171 __le32 content_options_address
;
172 __le32 content_length
;
173 __le32 content_address
;
187 struct image_header_10
{
191 u8 minor_header_version
;
192 u8 major_header_version
;
197 __le32 top_level_container_start_addr
;
200 struct image_metadata
{
201 bool contains_firmware_id
;
202 bool contains_bootloader
;
203 bool contains_display_cfg
;
204 bool contains_guest_code
;
205 bool contains_flash_config
;
206 unsigned int firmware_id
;
207 unsigned int checksum
;
208 unsigned int bootloader_size
;
209 unsigned int display_cfg_offset
;
210 unsigned char bl_version
;
211 unsigned char product_id
[PRODUCT_ID_SIZE
+ 1];
212 unsigned char cstmr_product_id
[PRODUCT_ID_SIZE
+ 1];
213 struct block_data bootloader
;
214 struct block_data ui_firmware
;
215 struct block_data ui_config
;
216 struct block_data dp_config
;
217 struct block_data fl_config
;
218 struct block_data bl_config
;
219 struct block_data guest_code
;
220 struct block_data lockdown
;
221 struct block_count blkcount
;
222 struct physical_address phyaddr
;
225 struct rmi_f34_firmware
{
228 u8 bootloader_version
;
244 struct completion cmd_done
;
245 struct mutex flash_mutex
;
249 bool has_display_cfg
;
253 size_t read_config_buf_size
;
257 u16 config_block_count
;
260 u16 flash_config_length
;
263 u16 partition_table_bytes
;
265 struct block_count blkcount
;
266 struct physical_address phyaddr
;
267 struct image_metadata img
;
269 const void *config_data
;
271 struct completion cmd_done
;
275 struct rmi_function
*fn
;
278 unsigned char bootloader_id
[5];
279 unsigned char configuration_id
[CONFIG_ID_SIZE
*2 + 1];
286 struct f34v5_data v5
;
287 struct f34v7_data v7
;
291 int rmi_f34v7_start_reflash(struct f34_data
*f34
, const struct firmware
*fw
);
292 int rmi_f34v7_do_reflash(struct f34_data
*f34
, const struct firmware
*fw
);
293 int rmi_f34v7_probe(struct f34_data
*f34
);
295 #endif /* _RMI_F34_H */