Lines Matching refs:f34
21 static int rmi_f34v7_read_flash_status(struct f34_data *f34) in rmi_f34v7_read_flash_status() argument
27 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_flash_status()
28 f34->fn->fd.data_base_addr + V7_FLASH_STATUS_OFFSET, in rmi_f34v7_read_flash_status()
32 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_read_flash_status()
37 f34->v7.in_bl_mode = status >> 7; in rmi_f34v7_read_flash_status()
38 f34->v7.flash_status = status & 0x1f; in rmi_f34v7_read_flash_status()
40 if (f34->v7.flash_status != 0x00) { in rmi_f34v7_read_flash_status()
41 dev_err(&f34->fn->dev, "%s: status=%d, command=0x%02x\n", in rmi_f34v7_read_flash_status()
42 __func__, f34->v7.flash_status, f34->v7.command); in rmi_f34v7_read_flash_status()
45 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_flash_status()
46 f34->fn->fd.data_base_addr + V7_COMMAND_OFFSET, in rmi_f34v7_read_flash_status()
50 dev_err(&f34->fn->dev, "%s: Failed to read flash command\n", in rmi_f34v7_read_flash_status()
55 f34->v7.command = command; in rmi_f34v7_read_flash_status()
60 static int rmi_f34v7_wait_for_idle(struct f34_data *f34, int timeout_ms) in rmi_f34v7_wait_for_idle() argument
66 if (!wait_for_completion_timeout(&f34->v7.cmd_done, timeout)) { in rmi_f34v7_wait_for_idle()
67 dev_warn(&f34->fn->dev, "%s: Timed out waiting for idle status\n", in rmi_f34v7_wait_for_idle()
75 static int rmi_f34v7_check_command_status(struct f34_data *f34, int timeout_ms) in rmi_f34v7_check_command_status() argument
79 ret = rmi_f34v7_wait_for_idle(f34, timeout_ms); in rmi_f34v7_check_command_status()
83 ret = rmi_f34v7_read_flash_status(f34); in rmi_f34v7_check_command_status()
87 if (f34->v7.flash_status != 0x00) in rmi_f34v7_check_command_status()
93 static int rmi_f34v7_write_command_single_transaction(struct f34_data *f34, in rmi_f34v7_write_command_single_transaction() argument
100 base = f34->fn->fd.data_base_addr; in rmi_f34v7_write_command_single_transaction()
139 data_1_5.payload[0] = f34->bootloader_id[0]; in rmi_f34v7_write_command_single_transaction()
140 data_1_5.payload[1] = f34->bootloader_id[1]; in rmi_f34v7_write_command_single_transaction()
142 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_command_single_transaction()
146 dev_err(&f34->fn->dev, in rmi_f34v7_write_command_single_transaction()
155 static int rmi_f34v7_write_command(struct f34_data *f34, u8 cmd) in rmi_f34v7_write_command() argument
161 base = f34->fn->fd.data_base_addr; in rmi_f34v7_write_command()
187 dev_err(&f34->fn->dev, "%s: Invalid command 0x%02x\n", in rmi_f34v7_write_command()
192 f34->v7.command = command; in rmi_f34v7_write_command()
203 ret = rmi_f34v7_write_command_single_transaction(f34, cmd); in rmi_f34v7_write_command()
212 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: writing cmd %02X\n", in rmi_f34v7_write_command()
215 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_command()
219 dev_err(&f34->fn->dev, "%s: Failed to write flash command\n", in rmi_f34v7_write_command()
227 static int rmi_f34v7_write_partition_id(struct f34_data *f34, u8 cmd) in rmi_f34v7_write_partition_id() argument
233 base = f34->fn->fd.data_base_addr; in rmi_f34v7_write_partition_id()
241 if (f34->v7.config_area == v7_UI_CONFIG_AREA) in rmi_f34v7_write_partition_id()
243 else if (f34->v7.config_area == v7_DP_CONFIG_AREA) in rmi_f34v7_write_partition_id()
245 else if (f34->v7.config_area == v7_PM_CONFIG_AREA) in rmi_f34v7_write_partition_id()
247 else if (f34->v7.config_area == v7_BL_CONFIG_AREA) in rmi_f34v7_write_partition_id()
249 else if (f34->v7.config_area == v7_FLASH_CONFIG_AREA) in rmi_f34v7_write_partition_id()
277 dev_err(&f34->fn->dev, "%s: Invalid command 0x%02x\n", in rmi_f34v7_write_partition_id()
282 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_partition_id()
286 dev_err(&f34->fn->dev, "%s: Failed to write partition ID\n", in rmi_f34v7_write_partition_id()
294 static int rmi_f34v7_read_partition_table(struct f34_data *f34) in rmi_f34v7_read_partition_table() argument
302 base = f34->fn->fd.data_base_addr; in rmi_f34v7_read_partition_table()
304 f34->v7.config_area = v7_FLASH_CONFIG_AREA; in rmi_f34v7_read_partition_table()
306 ret = rmi_f34v7_write_partition_id(f34, v7_CMD_READ_CONFIG); in rmi_f34v7_read_partition_table()
310 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_read_partition_table()
314 dev_err(&f34->fn->dev, "%s: Failed to write block number\n", in rmi_f34v7_read_partition_table()
319 put_unaligned_le16(f34->v7.flash_config_length, &length); in rmi_f34v7_read_partition_table()
321 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_read_partition_table()
325 dev_err(&f34->fn->dev, "%s: Failed to write transfer length\n", in rmi_f34v7_read_partition_table()
330 init_completion(&f34->v7.cmd_done); in rmi_f34v7_read_partition_table()
332 ret = rmi_f34v7_write_command(f34, v7_CMD_READ_CONFIG); in rmi_f34v7_read_partition_table()
334 dev_err(&f34->fn->dev, "%s: Failed to write command\n", in rmi_f34v7_read_partition_table()
346 rmi_f34v7_read_flash_status(f34); in rmi_f34v7_read_partition_table()
348 if (f34->v7.command == v7_CMD_IDLE && in rmi_f34v7_read_partition_table()
349 f34->v7.flash_status == 0x00) { in rmi_f34v7_read_partition_table()
354 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_partition_table()
356 f34->v7.read_config_buf, in rmi_f34v7_read_partition_table()
357 f34->v7.partition_table_bytes); in rmi_f34v7_read_partition_table()
359 dev_err(&f34->fn->dev, "%s: Failed to read block data\n", in rmi_f34v7_read_partition_table()
367 static void rmi_f34v7_parse_partition_table(struct f34_data *f34, in rmi_f34v7_parse_partition_table() argument
378 for (i = 0; i < f34->v7.partitions; i++) { in rmi_f34v7_parse_partition_table()
383 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
390 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
397 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
404 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
410 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
417 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
423 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
429 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
435 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
443 static int rmi_f34v7_read_queries_bl_version(struct f34_data *f34) in rmi_f34v7_read_queries_bl_version() argument
451 base = f34->fn->fd.query_base_addr; in rmi_f34v7_read_queries_bl_version()
453 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries_bl_version()
458 dev_err(&f34->fn->dev, in rmi_f34v7_read_queries_bl_version()
465 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries_bl_version()
470 dev_err(&f34->fn->dev, "%s: Failed to read queries 1 to 7\n", in rmi_f34v7_read_queries_bl_version()
475 f34->bootloader_id[0] = query_1_7.bl_minor_revision; in rmi_f34v7_read_queries_bl_version()
476 f34->bootloader_id[1] = query_1_7.bl_major_revision; in rmi_f34v7_read_queries_bl_version()
478 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "Bootloader V%d.%d\n", in rmi_f34v7_read_queries_bl_version()
479 f34->bootloader_id[1], f34->bootloader_id[0]); in rmi_f34v7_read_queries_bl_version()
484 static int rmi_f34v7_read_queries(struct f34_data *f34) in rmi_f34v7_read_queries() argument
494 base = f34->fn->fd.query_base_addr; in rmi_f34v7_read_queries()
496 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries()
501 dev_err(&f34->fn->dev, in rmi_f34v7_read_queries()
508 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries()
513 dev_err(&f34->fn->dev, "%s: Failed to read queries 1 to 7\n", in rmi_f34v7_read_queries()
518 f34->bootloader_id[0] = query_1_7.bl_minor_revision; in rmi_f34v7_read_queries()
519 f34->bootloader_id[1] = query_1_7.bl_major_revision; in rmi_f34v7_read_queries()
521 f34->v7.block_size = le16_to_cpu(query_1_7.block_size); in rmi_f34v7_read_queries()
522 f34->v7.flash_config_length = in rmi_f34v7_read_queries()
524 f34->v7.payload_length = le16_to_cpu(query_1_7.payload_length); in rmi_f34v7_read_queries()
526 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: f34->v7.block_size = %d\n", in rmi_f34v7_read_queries()
527 __func__, f34->v7.block_size); in rmi_f34v7_read_queries()
529 f34->v7.has_display_cfg = query_1_7.partition_support[1] & HAS_DISP_CFG; in rmi_f34v7_read_queries()
530 f34->v7.has_guest_code = in rmi_f34v7_read_queries()
536 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries()
537 f34->fn->fd.control_base_addr, in rmi_f34v7_read_queries()
547 snprintf(f34->configuration_id, sizeof(f34->configuration_id), in rmi_f34v7_read_queries()
550 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "Configuration ID: %s\n", in rmi_f34v7_read_queries()
551 f34->configuration_id); in rmi_f34v7_read_queries()
554 f34->v7.partitions = 0; in rmi_f34v7_read_queries()
556 f34->v7.partitions += hweight8(query_1_7.partition_support[i]); in rmi_f34v7_read_queries()
558 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: Supported partitions: %*ph\n", in rmi_f34v7_read_queries()
563 f34->v7.partition_table_bytes = f34->v7.partitions * 8 + 2; in rmi_f34v7_read_queries()
565 f34->v7.read_config_buf = devm_kzalloc(&f34->fn->dev, in rmi_f34v7_read_queries()
566 f34->v7.partition_table_bytes, in rmi_f34v7_read_queries()
568 if (!f34->v7.read_config_buf) { in rmi_f34v7_read_queries()
569 f34->v7.read_config_buf_size = 0; in rmi_f34v7_read_queries()
573 f34->v7.read_config_buf_size = f34->v7.partition_table_bytes; in rmi_f34v7_read_queries()
574 ptable = f34->v7.read_config_buf; in rmi_f34v7_read_queries()
576 ret = rmi_f34v7_read_partition_table(f34); in rmi_f34v7_read_queries()
578 dev_err(&f34->fn->dev, "%s: Failed to read partition table\n", in rmi_f34v7_read_queries()
583 rmi_f34v7_parse_partition_table(f34, ptable, in rmi_f34v7_read_queries()
584 &f34->v7.blkcount, &f34->v7.phyaddr); in rmi_f34v7_read_queries()
589 static int rmi_f34v7_check_bl_config_size(struct f34_data *f34) in rmi_f34v7_check_bl_config_size() argument
593 block_count = f34->v7.img.bl_config.size / f34->v7.block_size; in rmi_f34v7_check_bl_config_size()
594 f34->update_size += block_count; in rmi_f34v7_check_bl_config_size()
596 if (block_count != f34->v7.blkcount.bl_config) { in rmi_f34v7_check_bl_config_size()
597 dev_err(&f34->fn->dev, "Bootloader config size mismatch\n"); in rmi_f34v7_check_bl_config_size()
604 static int rmi_f34v7_erase_all(struct f34_data *f34) in rmi_f34v7_erase_all() argument
608 dev_info(&f34->fn->dev, "Erasing firmware...\n"); in rmi_f34v7_erase_all()
610 init_completion(&f34->v7.cmd_done); in rmi_f34v7_erase_all()
612 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_ALL); in rmi_f34v7_erase_all()
616 ret = rmi_f34v7_check_command_status(f34, F34_ERASE_WAIT_MS); in rmi_f34v7_erase_all()
623 static int rmi_f34v7_read_blocks(struct f34_data *f34, in rmi_f34v7_read_blocks() argument
635 base = f34->fn->fd.data_base_addr; in rmi_f34v7_read_blocks()
637 ret = rmi_f34v7_write_partition_id(f34, command); in rmi_f34v7_read_blocks()
641 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_read_blocks()
645 dev_err(&f34->fn->dev, "%s: Failed to write block number\n", in rmi_f34v7_read_blocks()
650 max_transfer = min(f34->v7.payload_length, in rmi_f34v7_read_blocks()
651 (u16)(PAGE_SIZE / f34->v7.block_size)); in rmi_f34v7_read_blocks()
657 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_read_blocks()
661 dev_err(&f34->fn->dev, in rmi_f34v7_read_blocks()
667 init_completion(&f34->v7.cmd_done); in rmi_f34v7_read_blocks()
669 ret = rmi_f34v7_write_command(f34, command); in rmi_f34v7_read_blocks()
673 ret = rmi_f34v7_check_command_status(f34, F34_ENABLE_WAIT_MS); in rmi_f34v7_read_blocks()
677 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_blocks()
679 &f34->v7.read_config_buf[index], in rmi_f34v7_read_blocks()
680 transfer * f34->v7.block_size); in rmi_f34v7_read_blocks()
682 dev_err(&f34->fn->dev, in rmi_f34v7_read_blocks()
688 index += (transfer * f34->v7.block_size); in rmi_f34v7_read_blocks()
695 static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34, in rmi_f34v7_write_f34v7_blocks() argument
707 base = f34->fn->fd.data_base_addr; in rmi_f34v7_write_f34v7_blocks()
709 ret = rmi_f34v7_write_partition_id(f34, command); in rmi_f34v7_write_f34v7_blocks()
713 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_f34v7_blocks()
717 dev_err(&f34->fn->dev, "%s: Failed to write block number\n", in rmi_f34v7_write_f34v7_blocks()
722 if (f34->v7.payload_length > (PAGE_SIZE / f34->v7.block_size)) in rmi_f34v7_write_f34v7_blocks()
723 max_transfer = PAGE_SIZE / f34->v7.block_size; in rmi_f34v7_write_f34v7_blocks()
725 max_transfer = f34->v7.payload_length; in rmi_f34v7_write_f34v7_blocks()
731 init_completion(&f34->v7.cmd_done); in rmi_f34v7_write_f34v7_blocks()
733 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_f34v7_blocks()
737 dev_err(&f34->fn->dev, in rmi_f34v7_write_f34v7_blocks()
743 ret = rmi_f34v7_write_command(f34, command); in rmi_f34v7_write_f34v7_blocks()
747 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_f34v7_blocks()
749 block_ptr, transfer * f34->v7.block_size); in rmi_f34v7_write_f34v7_blocks()
751 dev_err(&f34->fn->dev, in rmi_f34v7_write_f34v7_blocks()
757 ret = rmi_f34v7_check_command_status(f34, F34_ENABLE_WAIT_MS); in rmi_f34v7_write_f34v7_blocks()
761 block_ptr += (transfer * f34->v7.block_size); in rmi_f34v7_write_f34v7_blocks()
763 f34->update_progress += transfer; in rmi_f34v7_write_f34v7_blocks()
764 f34->update_status = (f34->update_progress * 100) / in rmi_f34v7_write_f34v7_blocks()
765 f34->update_size; in rmi_f34v7_write_f34v7_blocks()
771 static int rmi_f34v7_write_config(struct f34_data *f34) in rmi_f34v7_write_config() argument
773 return rmi_f34v7_write_f34v7_blocks(f34, f34->v7.config_data, in rmi_f34v7_write_config()
774 f34->v7.config_block_count, in rmi_f34v7_write_config()
778 static int rmi_f34v7_write_ui_config(struct f34_data *f34) in rmi_f34v7_write_ui_config() argument
780 f34->v7.config_area = v7_UI_CONFIG_AREA; in rmi_f34v7_write_ui_config()
781 f34->v7.config_data = f34->v7.img.ui_config.data; in rmi_f34v7_write_ui_config()
782 f34->v7.config_size = f34->v7.img.ui_config.size; in rmi_f34v7_write_ui_config()
783 f34->v7.config_block_count = f34->v7.config_size / f34->v7.block_size; in rmi_f34v7_write_ui_config()
785 return rmi_f34v7_write_config(f34); in rmi_f34v7_write_ui_config()
788 static int rmi_f34v7_write_dp_config(struct f34_data *f34) in rmi_f34v7_write_dp_config() argument
790 f34->v7.config_area = v7_DP_CONFIG_AREA; in rmi_f34v7_write_dp_config()
791 f34->v7.config_data = f34->v7.img.dp_config.data; in rmi_f34v7_write_dp_config()
792 f34->v7.config_size = f34->v7.img.dp_config.size; in rmi_f34v7_write_dp_config()
793 f34->v7.config_block_count = f34->v7.config_size / f34->v7.block_size; in rmi_f34v7_write_dp_config()
795 return rmi_f34v7_write_config(f34); in rmi_f34v7_write_dp_config()
798 static int rmi_f34v7_write_guest_code(struct f34_data *f34) in rmi_f34v7_write_guest_code() argument
800 return rmi_f34v7_write_f34v7_blocks(f34, f34->v7.img.guest_code.data, in rmi_f34v7_write_guest_code()
801 f34->v7.img.guest_code.size / in rmi_f34v7_write_guest_code()
802 f34->v7.block_size, in rmi_f34v7_write_guest_code()
806 static int rmi_f34v7_write_flash_config(struct f34_data *f34) in rmi_f34v7_write_flash_config() argument
810 f34->v7.config_area = v7_FLASH_CONFIG_AREA; in rmi_f34v7_write_flash_config()
811 f34->v7.config_data = f34->v7.img.fl_config.data; in rmi_f34v7_write_flash_config()
812 f34->v7.config_size = f34->v7.img.fl_config.size; in rmi_f34v7_write_flash_config()
813 f34->v7.config_block_count = f34->v7.config_size / f34->v7.block_size; in rmi_f34v7_write_flash_config()
815 if (f34->v7.config_block_count != f34->v7.blkcount.fl_config) { in rmi_f34v7_write_flash_config()
816 dev_err(&f34->fn->dev, "%s: Flash config size mismatch\n", in rmi_f34v7_write_flash_config()
821 init_completion(&f34->v7.cmd_done); in rmi_f34v7_write_flash_config()
823 ret = rmi_f34v7_write_config(f34); in rmi_f34v7_write_flash_config()
830 static int rmi_f34v7_write_partition_table(struct f34_data *f34) in rmi_f34v7_write_partition_table() argument
835 block_count = f34->v7.blkcount.bl_config; in rmi_f34v7_write_partition_table()
836 f34->v7.config_area = v7_BL_CONFIG_AREA; in rmi_f34v7_write_partition_table()
837 f34->v7.config_size = f34->v7.block_size * block_count; in rmi_f34v7_write_partition_table()
838 devm_kfree(&f34->fn->dev, f34->v7.read_config_buf); in rmi_f34v7_write_partition_table()
839 f34->v7.read_config_buf = devm_kzalloc(&f34->fn->dev, in rmi_f34v7_write_partition_table()
840 f34->v7.config_size, GFP_KERNEL); in rmi_f34v7_write_partition_table()
841 if (!f34->v7.read_config_buf) { in rmi_f34v7_write_partition_table()
842 f34->v7.read_config_buf_size = 0; in rmi_f34v7_write_partition_table()
846 f34->v7.read_config_buf_size = f34->v7.config_size; in rmi_f34v7_write_partition_table()
848 ret = rmi_f34v7_read_blocks(f34, block_count, v7_CMD_READ_CONFIG); in rmi_f34v7_write_partition_table()
852 ret = rmi_f34v7_write_flash_config(f34); in rmi_f34v7_write_partition_table()
856 f34->v7.config_area = v7_BL_CONFIG_AREA; in rmi_f34v7_write_partition_table()
857 f34->v7.config_data = f34->v7.read_config_buf; in rmi_f34v7_write_partition_table()
858 f34->v7.config_size = f34->v7.img.bl_config.size; in rmi_f34v7_write_partition_table()
859 f34->v7.config_block_count = f34->v7.config_size / f34->v7.block_size; in rmi_f34v7_write_partition_table()
861 ret = rmi_f34v7_write_config(f34); in rmi_f34v7_write_partition_table()
868 static int rmi_f34v7_write_firmware(struct f34_data *f34) in rmi_f34v7_write_firmware() argument
872 blk_count = f34->v7.img.ui_firmware.size / f34->v7.block_size; in rmi_f34v7_write_firmware()
874 return rmi_f34v7_write_f34v7_blocks(f34, f34->v7.img.ui_firmware.data, in rmi_f34v7_write_firmware()
878 static void rmi_f34v7_parse_img_header_10_bl_container(struct f34_data *f34, in rmi_f34v7_parse_img_header_10_bl_container() argument
889 num_of_containers = f34->v7.img.bootloader.size / 4 - 1; in rmi_f34v7_parse_img_header_10_bl_container()
892 addr = get_unaligned_le32(f34->v7.img.bootloader.data + i * 4); in rmi_f34v7_parse_img_header_10_bl_container()
900 f34->v7.img.bl_config.data = content; in rmi_f34v7_parse_img_header_10_bl_container()
901 f34->v7.img.bl_config.size = length; in rmi_f34v7_parse_img_header_10_bl_container()
905 f34->v7.img.lockdown.data = content; in rmi_f34v7_parse_img_header_10_bl_container()
906 f34->v7.img.lockdown.size = length; in rmi_f34v7_parse_img_header_10_bl_container()
914 static void rmi_f34v7_parse_image_header_10(struct f34_data *f34) in rmi_f34v7_parse_image_header_10() argument
922 const void *image = f34->v7.image; in rmi_f34v7_parse_image_header_10()
927 f34->v7.img.checksum = le32_to_cpu(header->checksum); in rmi_f34v7_parse_image_header_10()
929 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: f34->v7.img.checksum=%X\n", in rmi_f34v7_parse_image_header_10()
930 __func__, f34->v7.img.checksum); in rmi_f34v7_parse_image_header_10()
948 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_image_header_10()
955 f34->v7.img.ui_firmware.data = content; in rmi_f34v7_parse_image_header_10()
956 f34->v7.img.ui_firmware.size = length; in rmi_f34v7_parse_image_header_10()
960 f34->v7.img.ui_config.data = content; in rmi_f34v7_parse_image_header_10()
961 f34->v7.img.ui_config.size = length; in rmi_f34v7_parse_image_header_10()
964 f34->v7.img.bl_version = *content; in rmi_f34v7_parse_image_header_10()
965 f34->v7.img.bootloader.data = content; in rmi_f34v7_parse_image_header_10()
966 f34->v7.img.bootloader.size = length; in rmi_f34v7_parse_image_header_10()
967 rmi_f34v7_parse_img_header_10_bl_container(f34, image); in rmi_f34v7_parse_image_header_10()
970 f34->v7.img.contains_guest_code = true; in rmi_f34v7_parse_image_header_10()
971 f34->v7.img.guest_code.data = content; in rmi_f34v7_parse_image_header_10()
972 f34->v7.img.guest_code.size = length; in rmi_f34v7_parse_image_header_10()
975 f34->v7.img.contains_display_cfg = true; in rmi_f34v7_parse_image_header_10()
976 f34->v7.img.dp_config.data = content; in rmi_f34v7_parse_image_header_10()
977 f34->v7.img.dp_config.size = length; in rmi_f34v7_parse_image_header_10()
980 f34->v7.img.contains_flash_config = true; in rmi_f34v7_parse_image_header_10()
981 f34->v7.img.fl_config.data = content; in rmi_f34v7_parse_image_header_10()
982 f34->v7.img.fl_config.size = length; in rmi_f34v7_parse_image_header_10()
985 f34->v7.img.contains_firmware_id = true; in rmi_f34v7_parse_image_header_10()
986 f34->v7.img.firmware_id = in rmi_f34v7_parse_image_header_10()
995 static int rmi_f34v7_parse_image_info(struct f34_data *f34) in rmi_f34v7_parse_image_info() argument
997 const struct image_header_10 *header = f34->v7.image; in rmi_f34v7_parse_image_info()
999 memset(&f34->v7.img, 0x00, sizeof(f34->v7.img)); in rmi_f34v7_parse_image_info()
1001 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_image_info()
1007 rmi_f34v7_parse_image_header_10(f34); in rmi_f34v7_parse_image_info()
1010 dev_err(&f34->fn->dev, "Unsupported image file format %02X\n", in rmi_f34v7_parse_image_info()
1015 if (!f34->v7.img.contains_flash_config) { in rmi_f34v7_parse_image_info()
1016 dev_err(&f34->fn->dev, "%s: No flash config in fw image\n", in rmi_f34v7_parse_image_info()
1021 rmi_f34v7_parse_partition_table(f34, f34->v7.img.fl_config.data, in rmi_f34v7_parse_image_info()
1022 &f34->v7.img.blkcount, &f34->v7.img.phyaddr); in rmi_f34v7_parse_image_info()
1027 int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw) in rmi_f34v7_do_reflash() argument
1031 f34->fn->rmi_dev->driver->set_irq_bits(f34->fn->rmi_dev, in rmi_f34v7_do_reflash()
1032 f34->fn->irq_mask); in rmi_f34v7_do_reflash()
1034 rmi_f34v7_read_queries_bl_version(f34); in rmi_f34v7_do_reflash()
1036 f34->v7.image = fw->data; in rmi_f34v7_do_reflash()
1037 f34->update_progress = 0; in rmi_f34v7_do_reflash()
1038 f34->update_size = 0; in rmi_f34v7_do_reflash()
1040 ret = rmi_f34v7_parse_image_info(f34); in rmi_f34v7_do_reflash()
1044 ret = rmi_f34v7_check_bl_config_size(f34); in rmi_f34v7_do_reflash()
1048 ret = rmi_f34v7_erase_all(f34); in rmi_f34v7_do_reflash()
1052 ret = rmi_f34v7_write_partition_table(f34); in rmi_f34v7_do_reflash()
1055 dev_info(&f34->fn->dev, "%s: Partition table programmed\n", __func__); in rmi_f34v7_do_reflash()
1061 ret = rmi_scan_pdt(f34->fn->rmi_dev, NULL, rmi_initial_reset); in rmi_f34v7_do_reflash()
1063 dev_warn(&f34->fn->dev, "RMI reset failed!\n"); in rmi_f34v7_do_reflash()
1065 dev_info(&f34->fn->dev, "Writing firmware (%d bytes)...\n", in rmi_f34v7_do_reflash()
1066 f34->v7.img.ui_firmware.size); in rmi_f34v7_do_reflash()
1068 ret = rmi_f34v7_write_firmware(f34); in rmi_f34v7_do_reflash()
1072 dev_info(&f34->fn->dev, "Writing config (%d bytes)...\n", in rmi_f34v7_do_reflash()
1073 f34->v7.img.ui_config.size); in rmi_f34v7_do_reflash()
1075 f34->v7.config_area = v7_UI_CONFIG_AREA; in rmi_f34v7_do_reflash()
1076 ret = rmi_f34v7_write_ui_config(f34); in rmi_f34v7_do_reflash()
1080 if (f34->v7.has_display_cfg && f34->v7.img.contains_display_cfg) { in rmi_f34v7_do_reflash()
1081 dev_info(&f34->fn->dev, "Writing display config...\n"); in rmi_f34v7_do_reflash()
1083 ret = rmi_f34v7_write_dp_config(f34); in rmi_f34v7_do_reflash()
1088 if (f34->v7.has_guest_code && f34->v7.img.contains_guest_code) { in rmi_f34v7_do_reflash()
1089 dev_info(&f34->fn->dev, "Writing guest code...\n"); in rmi_f34v7_do_reflash()
1091 ret = rmi_f34v7_write_guest_code(f34); in rmi_f34v7_do_reflash()
1099 static int rmi_f34v7_enter_flash_prog(struct f34_data *f34) in rmi_f34v7_enter_flash_prog() argument
1103 f34->fn->rmi_dev->driver->set_irq_bits(f34->fn->rmi_dev, f34->fn->irq_mask); in rmi_f34v7_enter_flash_prog()
1105 ret = rmi_f34v7_read_flash_status(f34); in rmi_f34v7_enter_flash_prog()
1109 if (f34->v7.in_bl_mode) { in rmi_f34v7_enter_flash_prog()
1110 dev_info(&f34->fn->dev, "%s: Device in bootloader mode\n", in rmi_f34v7_enter_flash_prog()
1115 init_completion(&f34->v7.cmd_done); in rmi_f34v7_enter_flash_prog()
1117 ret = rmi_f34v7_write_command(f34, v7_CMD_ENABLE_FLASH_PROG); in rmi_f34v7_enter_flash_prog()
1121 ret = rmi_f34v7_check_command_status(f34, F34_ENABLE_WAIT_MS); in rmi_f34v7_enter_flash_prog()
1128 int rmi_f34v7_start_reflash(struct f34_data *f34, const struct firmware *fw) in rmi_f34v7_start_reflash() argument
1132 f34->v7.config_area = v7_UI_CONFIG_AREA; in rmi_f34v7_start_reflash()
1133 f34->v7.image = fw->data; in rmi_f34v7_start_reflash()
1135 ret = rmi_f34v7_parse_image_info(f34); in rmi_f34v7_start_reflash()
1139 dev_info(&f34->fn->dev, "Firmware image OK\n"); in rmi_f34v7_start_reflash()
1141 return rmi_f34v7_enter_flash_prog(f34); in rmi_f34v7_start_reflash()
1144 int rmi_f34v7_probe(struct f34_data *f34) in rmi_f34v7_probe() argument
1149 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_probe()
1150 f34->fn->fd.query_base_addr + V7_BOOTLOADER_ID_OFFSET, in rmi_f34v7_probe()
1151 f34->bootloader_id, in rmi_f34v7_probe()
1152 sizeof(f34->bootloader_id)); in rmi_f34v7_probe()
1154 dev_err(&f34->fn->dev, "%s: Failed to read bootloader ID\n", in rmi_f34v7_probe()
1159 if (f34->bootloader_id[1] == '5') { in rmi_f34v7_probe()
1160 f34->bl_version = 5; in rmi_f34v7_probe()
1161 } else if (f34->bootloader_id[1] == '6') { in rmi_f34v7_probe()
1162 f34->bl_version = 6; in rmi_f34v7_probe()
1163 } else if (f34->bootloader_id[1] == 7) { in rmi_f34v7_probe()
1164 f34->bl_version = 7; in rmi_f34v7_probe()
1165 } else if (f34->bootloader_id[1] == 8) { in rmi_f34v7_probe()
1166 f34->bl_version = 8; in rmi_f34v7_probe()
1168 dev_err(&f34->fn->dev, in rmi_f34v7_probe()
1171 f34->bootloader_id[0], f34->bootloader_id[0], in rmi_f34v7_probe()
1172 f34->bootloader_id[1], f34->bootloader_id[1]); in rmi_f34v7_probe()
1176 memset(&f34->v7.blkcount, 0x00, sizeof(f34->v7.blkcount)); in rmi_f34v7_probe()
1177 memset(&f34->v7.phyaddr, 0x00, sizeof(f34->v7.phyaddr)); in rmi_f34v7_probe()
1179 init_completion(&f34->v7.cmd_done); in rmi_f34v7_probe()
1181 ret = rmi_f34v7_read_queries(f34); in rmi_f34v7_probe()