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
34 #define F34_BOOTLOADER_ID_LEN 2
37 #define V7_FLASH_STATUS_OFFSET 0
38 #define V7_PARTITION_ID_OFFSET 1
39 #define V7_BLOCK_NUMBER_OFFSET 2
40 #define V7_TRANSFER_LENGTH_OFFSET 3
41 #define V7_COMMAND_OFFSET 4
42 #define V7_PAYLOAD_OFFSET 5
43 #define V7_BOOTLOADER_ID_OFFSET 1
45 #define IMAGE_HEADER_VERSION_10 0x10
47 #define CONFIG_ID_SIZE 32
48 #define PRODUCT_ID_SIZE 10
50 #define ENABLE_WAIT_MS (1 * 1000)
51 #define WRITE_WAIT_MS (3 * 1000)
53 #define MIN_SLEEP_TIME_US 50
54 #define MAX_SLEEP_TIME_US 100
56 #define HAS_BSR BIT(5)
57 #define HAS_CONFIG_ID BIT(3)
58 #define HAS_GUEST_CODE BIT(6)
59 #define HAS_DISP_CFG BIT(5)
63 #define CMD_V7_ENTER_BL 1
65 #define CMD_V7_WRITE 3
66 #define CMD_V7_ERASE 4
67 #define CMD_V7_ERASE_AP 5
68 #define CMD_V7_SENSOR_ID 6
71 #define v7_CMD_WRITE_FW 1
72 #define v7_CMD_WRITE_CONFIG 2
73 #define v7_CMD_WRITE_LOCKDOWN 3
74 #define v7_CMD_WRITE_GUEST_CODE 4
75 #define v7_CMD_READ_CONFIG 5
76 #define v7_CMD_ERASE_ALL 6
77 #define v7_CMD_ERASE_UI_FIRMWARE 7
78 #define v7_CMD_ERASE_UI_CONFIG 8
79 #define v7_CMD_ERASE_BL_CONFIG 9
80 #define v7_CMD_ERASE_DISP_CONFIG 10
81 #define v7_CMD_ERASE_FLASH_CONFIG 11
82 #define v7_CMD_ERASE_GUEST_CODE 12
83 #define v7_CMD_ENABLE_FLASH_PROG 13
85 #define v7_UI_CONFIG_AREA 0
86 #define v7_PM_CONFIG_AREA 1
87 #define v7_BL_CONFIG_AREA 2
88 #define v7_DP_CONFIG_AREA 3
89 #define v7_FLASH_CONFIG_AREA 4
91 /* F34 V7 partition IDs */
92 #define BOOTLOADER_PARTITION 1
93 #define DEVICE_CONFIG_PARTITION 2
94 #define FLASH_CONFIG_PARTITION 3
95 #define MANUFACTURING_BLOCK_PARTITION 4
96 #define GUEST_SERIALIZATION_PARTITION 5
97 #define GLOBAL_PARAMETERS_PARTITION 6
98 #define CORE_CODE_PARTITION 7
99 #define CORE_CONFIG_PARTITION 8
100 #define GUEST_CODE_PARTITION 9
101 #define DISPLAY_CONFIG_PARTITION 10
103 /* F34 V7 container IDs */
104 #define TOP_LEVEL_CONTAINER 0
105 #define UI_CONTAINER 1
106 #define UI_CONFIG_CONTAINER 2
107 #define BL_CONTAINER 3
108 #define BL_IMAGE_CONTAINER 4
109 #define BL_CONFIG_CONTAINER 5
110 #define BL_LOCKDOWN_INFO_CONTAINER 6
111 #define PERMANENT_CONFIG_CONTAINER 7
112 #define GUEST_CODE_CONTAINER 8
113 #define BL_PROTOCOL_DESCRIPTOR_CONTAINER 9
114 #define UI_PROTOCOL_DESCRIPTOR_CONTAINER 10
115 #define RMI_SELF_DISCOVERY_CONTAINER 11
116 #define RMI_PAGE_CONTENT_CONTAINER 12
117 #define GENERAL_INFORMATION_CONTAINER 13
118 #define DEVICE_CONFIG_CONTAINER 14
119 #define FLASH_CONFIG_CONTAINER 15
120 #define GUEST_SERIALIZATION_CONTAINER 16
121 #define GLOBAL_PARAMETERS_CONTAINER 17
122 #define CORE_CODE_CONTAINER 18
123 #define CORE_CONFIG_CONTAINER 19
124 #define DISPLAY_CONFIG_CONTAINER 20
126 struct f34v7_query_1_7 {
127 u8 bl_minor_revision; /* query 1 */
128 u8 bl_major_revision;
129 __le32 bl_fw_id; /* query 2 */
130 u8 minimum_write_size; /* query 3 */
132 __le16 flash_page_size;
133 __le16 adjustable_partition_area_size; /* query 4 */
134 __le16 flash_config_length; /* query 5 */
135 __le16 payload_length; /* query 6 */
136 u8 partition_support[4]; /* query 7 */
139 struct f34v7_data_1_5 {
142 __le16 transfer_length;
152 struct partition_table {
155 __le16 partition_length;
156 __le16 start_physical_address;
157 __le16 partition_properties;
160 struct physical_address {
167 struct container_descriptor {
168 __le32 content_checksum;
176 u8 container_option_flags[4];
177 __le32 content_options_length;
178 __le32 content_options_address;
179 __le32 content_length;
180 __le32 content_address;
194 struct image_header_10 {
198 u8 minor_header_version;
199 u8 major_header_version;
204 __le32 top_level_container_start_addr;
207 struct image_metadata {
208 bool contains_firmware_id;
209 bool contains_bootloader;
210 bool contains_display_cfg;
211 bool contains_guest_code;
212 bool contains_flash_config;
213 unsigned int firmware_id;
214 unsigned int checksum;
215 unsigned int bootloader_size;
216 unsigned int display_cfg_offset;
217 unsigned char bl_version;
218 unsigned char product_id[PRODUCT_ID_SIZE + 1];
219 unsigned char cstmr_product_id[PRODUCT_ID_SIZE + 1];
220 struct block_data bootloader;
221 struct block_data ui_firmware;
222 struct block_data ui_config;
223 struct block_data dp_config;
224 struct block_data fl_config;
225 struct block_data bl_config;
226 struct block_data guest_code;
227 struct block_data lockdown;
228 struct block_count blkcount;
229 struct physical_address phyaddr;
232 struct register_offset {
246 struct rmi_f34_firmware {
249 u8 bootloader_version;
265 struct completion cmd_done;
266 struct mutex flash_mutex;
270 bool has_display_cfg;
275 size_t read_config_buf_size;
279 u16 config_block_count;
282 u16 flash_config_length;
285 u16 partition_table_bytes;
286 bool new_partition_table;
288 struct register_offset off;
289 struct block_count blkcount;
290 struct physical_address phyaddr;
291 struct image_metadata img;
293 const void *config_data;
298 struct rmi_function *fn;
301 unsigned char bootloader_id[5];
302 unsigned char configuration_id[CONFIG_ID_SIZE*2 + 1];
309 struct f34v5_data v5;
310 struct f34v7_data v7;
314 int rmi_f34v7_start_reflash(struct f34_data *f34, const struct firmware *fw);
315 int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw);
316 int rmi_f34v7_probe(struct f34_data *f34);
318 #endif /* _RMI_F34_H */