2 * Copyright (c) 2007-2016, Synaptics Incorporated
3 * Copyright (C) 2016 Zodiac Inflight Innovations
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
13 /* F34 image file offsets. */
14 #define F34_FW_IMAGE_OFFSET 0x100
16 /* F34 register offsets. */
17 #define F34_BLOCK_DATA_OFFSET 2
20 #define F34_WRITE_FW_BLOCK 0x2
21 #define F34_ERASE_ALL 0x3
22 #define F34_READ_CONFIG_BLOCK 0x5
23 #define F34_WRITE_CONFIG_BLOCK 0x6
24 #define F34_ERASE_CONFIG 0x7
25 #define F34_ENABLE_FLASH_PROG 0xf
27 #define F34_STATUS_IN_PROGRESS 0xff
28 #define F34_STATUS_IDLE 0x80
30 #define F34_IDLE_WAIT_MS 500
31 #define F34_ENABLE_WAIT_MS 300
32 #define F34_ERASE_WAIT_MS 5000
33 #define F34_WRITE_WAIT_MS 3000
35 #define F34_BOOTLOADER_ID_LEN 2
38 #define V7_FLASH_STATUS_OFFSET 0
39 #define V7_PARTITION_ID_OFFSET 1
40 #define V7_BLOCK_NUMBER_OFFSET 2
41 #define V7_TRANSFER_LENGTH_OFFSET 3
42 #define V7_COMMAND_OFFSET 4
43 #define V7_PAYLOAD_OFFSET 5
44 #define V7_BOOTLOADER_ID_OFFSET 1
46 #define IMAGE_HEADER_VERSION_10 0x10
48 #define CONFIG_ID_SIZE 32
49 #define PRODUCT_ID_SIZE 10
52 #define HAS_BSR BIT(5)
53 #define HAS_CONFIG_ID BIT(3)
54 #define HAS_GUEST_CODE BIT(6)
55 #define HAS_DISP_CFG BIT(5)
59 #define CMD_V7_ENTER_BL 1
61 #define CMD_V7_WRITE 3
62 #define CMD_V7_ERASE 4
63 #define CMD_V7_ERASE_AP 5
64 #define CMD_V7_SENSOR_ID 6
67 #define v7_CMD_WRITE_FW 1
68 #define v7_CMD_WRITE_CONFIG 2
69 #define v7_CMD_WRITE_LOCKDOWN 3
70 #define v7_CMD_WRITE_GUEST_CODE 4
71 #define v7_CMD_READ_CONFIG 5
72 #define v7_CMD_ERASE_ALL 6
73 #define v7_CMD_ERASE_UI_FIRMWARE 7
74 #define v7_CMD_ERASE_UI_CONFIG 8
75 #define v7_CMD_ERASE_BL_CONFIG 9
76 #define v7_CMD_ERASE_DISP_CONFIG 10
77 #define v7_CMD_ERASE_FLASH_CONFIG 11
78 #define v7_CMD_ERASE_GUEST_CODE 12
79 #define v7_CMD_ENABLE_FLASH_PROG 13
81 #define v7_UI_CONFIG_AREA 0
82 #define v7_PM_CONFIG_AREA 1
83 #define v7_BL_CONFIG_AREA 2
84 #define v7_DP_CONFIG_AREA 3
85 #define v7_FLASH_CONFIG_AREA 4
87 /* F34 V7 partition IDs */
88 #define BOOTLOADER_PARTITION 1
89 #define DEVICE_CONFIG_PARTITION 2
90 #define FLASH_CONFIG_PARTITION 3
91 #define MANUFACTURING_BLOCK_PARTITION 4
92 #define GUEST_SERIALIZATION_PARTITION 5
93 #define GLOBAL_PARAMETERS_PARTITION 6
94 #define CORE_CODE_PARTITION 7
95 #define CORE_CONFIG_PARTITION 8
96 #define GUEST_CODE_PARTITION 9
97 #define DISPLAY_CONFIG_PARTITION 10
99 /* F34 V7 container IDs */
100 #define TOP_LEVEL_CONTAINER 0
101 #define UI_CONTAINER 1
102 #define UI_CONFIG_CONTAINER 2
103 #define BL_CONTAINER 3
104 #define BL_IMAGE_CONTAINER 4
105 #define BL_CONFIG_CONTAINER 5
106 #define BL_LOCKDOWN_INFO_CONTAINER 6
107 #define PERMANENT_CONFIG_CONTAINER 7
108 #define GUEST_CODE_CONTAINER 8
109 #define BL_PROTOCOL_DESCRIPTOR_CONTAINER 9
110 #define UI_PROTOCOL_DESCRIPTOR_CONTAINER 10
111 #define RMI_SELF_DISCOVERY_CONTAINER 11
112 #define RMI_PAGE_CONTENT_CONTAINER 12
113 #define GENERAL_INFORMATION_CONTAINER 13
114 #define DEVICE_CONFIG_CONTAINER 14
115 #define FLASH_CONFIG_CONTAINER 15
116 #define GUEST_SERIALIZATION_CONTAINER 16
117 #define GLOBAL_PARAMETERS_CONTAINER 17
118 #define CORE_CODE_CONTAINER 18
119 #define CORE_CONFIG_CONTAINER 19
120 #define DISPLAY_CONFIG_CONTAINER 20
122 struct f34v7_query_1_7
{
123 u8 bl_minor_revision
; /* query 1 */
124 u8 bl_major_revision
;
125 __le32 bl_fw_id
; /* query 2 */
126 u8 minimum_write_size
; /* query 3 */
128 __le16 flash_page_size
;
129 __le16 adjustable_partition_area_size
; /* query 4 */
130 __le16 flash_config_length
; /* query 5 */
131 __le16 payload_length
; /* query 6 */
132 u8 partition_support
[4]; /* query 7 */
135 struct f34v7_data_1_5
{
138 __le16 transfer_length
;
148 struct partition_table
{
151 __le16 partition_length
;
152 __le16 start_physical_address
;
153 __le16 partition_properties
;
156 struct physical_address
{
163 struct container_descriptor
{
164 __le32 content_checksum
;
172 u8 container_option_flags
[4];
173 __le32 content_options_length
;
174 __le32 content_options_address
;
175 __le32 content_length
;
176 __le32 content_address
;
190 struct image_header_10
{
194 u8 minor_header_version
;
195 u8 major_header_version
;
200 __le32 top_level_container_start_addr
;
203 struct image_metadata
{
204 bool contains_firmware_id
;
205 bool contains_bootloader
;
206 bool contains_display_cfg
;
207 bool contains_guest_code
;
208 bool contains_flash_config
;
209 unsigned int firmware_id
;
210 unsigned int checksum
;
211 unsigned int bootloader_size
;
212 unsigned int display_cfg_offset
;
213 unsigned char bl_version
;
214 unsigned char product_id
[PRODUCT_ID_SIZE
+ 1];
215 unsigned char cstmr_product_id
[PRODUCT_ID_SIZE
+ 1];
216 struct block_data bootloader
;
217 struct block_data ui_firmware
;
218 struct block_data ui_config
;
219 struct block_data dp_config
;
220 struct block_data fl_config
;
221 struct block_data bl_config
;
222 struct block_data guest_code
;
223 struct block_data lockdown
;
224 struct block_count blkcount
;
225 struct physical_address phyaddr
;
228 struct register_offset
{
242 struct rmi_f34_firmware
{
245 u8 bootloader_version
;
261 struct completion cmd_done
;
262 struct mutex flash_mutex
;
266 bool has_display_cfg
;
271 size_t read_config_buf_size
;
275 u16 config_block_count
;
278 u16 flash_config_length
;
281 u16 partition_table_bytes
;
282 bool new_partition_table
;
284 struct register_offset off
;
285 struct block_count blkcount
;
286 struct physical_address phyaddr
;
287 struct image_metadata img
;
289 const void *config_data
;
291 struct completion cmd_done
;
295 struct rmi_function
*fn
;
298 unsigned char bootloader_id
[5];
299 unsigned char configuration_id
[CONFIG_ID_SIZE
*2 + 1];
306 struct f34v5_data v5
;
307 struct f34v7_data v7
;
311 int rmi_f34v7_start_reflash(struct f34_data
*f34
, const struct firmware
*fw
);
312 int rmi_f34v7_do_reflash(struct f34_data
*f34
, const struct firmware
*fw
);
313 int rmi_f34v7_probe(struct f34_data
*f34
);
315 #endif /* _RMI_F34_H */