Lines Matching refs:f34

24 static int rmi_f34v7_read_flash_status(struct f34_data *f34)  in rmi_f34v7_read_flash_status()  argument
30 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_flash_status()
31 f34->fn->fd.data_base_addr + f34->v7.off.flash_status, in rmi_f34v7_read_flash_status()
35 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_read_flash_status()
40 f34->v7.in_bl_mode = status >> 7; in rmi_f34v7_read_flash_status()
41 f34->v7.flash_status = status & 0x1f; in rmi_f34v7_read_flash_status()
43 if (f34->v7.flash_status != 0x00) { in rmi_f34v7_read_flash_status()
44 dev_err(&f34->fn->dev, "%s: status=%d, command=0x%02x\n", in rmi_f34v7_read_flash_status()
45 __func__, f34->v7.flash_status, f34->v7.command); in rmi_f34v7_read_flash_status()
48 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_flash_status()
49 f34->fn->fd.data_base_addr + f34->v7.off.flash_cmd, in rmi_f34v7_read_flash_status()
53 dev_err(&f34->fn->dev, "%s: Failed to read flash command\n", in rmi_f34v7_read_flash_status()
58 f34->v7.command = command; in rmi_f34v7_read_flash_status()
63 static int rmi_f34v7_wait_for_idle(struct f34_data *f34, int timeout_ms) in rmi_f34v7_wait_for_idle() argument
69 if (!wait_for_completion_timeout(&f34->v7.cmd_done, timeout)) { in rmi_f34v7_wait_for_idle()
70 dev_warn(&f34->fn->dev, "%s: Timed out waiting for idle status\n", in rmi_f34v7_wait_for_idle()
78 static int rmi_f34v7_write_command_single_transaction(struct f34_data *f34, in rmi_f34v7_write_command_single_transaction() argument
85 base = f34->fn->fd.data_base_addr; in rmi_f34v7_write_command_single_transaction()
124 data_1_5.payload[0] = f34->bootloader_id[0]; in rmi_f34v7_write_command_single_transaction()
125 data_1_5.payload[1] = f34->bootloader_id[1]; in rmi_f34v7_write_command_single_transaction()
127 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_command_single_transaction()
128 base + f34->v7.off.partition_id, in rmi_f34v7_write_command_single_transaction()
131 dev_err(&f34->fn->dev, in rmi_f34v7_write_command_single_transaction()
140 static int rmi_f34v7_write_command(struct f34_data *f34, u8 cmd) in rmi_f34v7_write_command() argument
146 base = f34->fn->fd.data_base_addr; in rmi_f34v7_write_command()
172 dev_err(&f34->fn->dev, "%s: Invalid command 0x%02x\n", in rmi_f34v7_write_command()
177 f34->v7.command = command; in rmi_f34v7_write_command()
188 ret = rmi_f34v7_write_command_single_transaction(f34, cmd); in rmi_f34v7_write_command()
197 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: writing cmd %02X\n", in rmi_f34v7_write_command()
200 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_command()
201 base + f34->v7.off.flash_cmd, in rmi_f34v7_write_command()
204 dev_err(&f34->fn->dev, "%s: Failed to write flash command\n", in rmi_f34v7_write_command()
212 static int rmi_f34v7_write_partition_id(struct f34_data *f34, u8 cmd) in rmi_f34v7_write_partition_id() argument
218 base = f34->fn->fd.data_base_addr; in rmi_f34v7_write_partition_id()
226 if (f34->v7.config_area == v7_UI_CONFIG_AREA) in rmi_f34v7_write_partition_id()
228 else if (f34->v7.config_area == v7_DP_CONFIG_AREA) in rmi_f34v7_write_partition_id()
230 else if (f34->v7.config_area == v7_PM_CONFIG_AREA) in rmi_f34v7_write_partition_id()
232 else if (f34->v7.config_area == v7_BL_CONFIG_AREA) in rmi_f34v7_write_partition_id()
234 else if (f34->v7.config_area == v7_FLASH_CONFIG_AREA) in rmi_f34v7_write_partition_id()
262 dev_err(&f34->fn->dev, "%s: Invalid command 0x%02x\n", in rmi_f34v7_write_partition_id()
267 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_partition_id()
268 base + f34->v7.off.partition_id, in rmi_f34v7_write_partition_id()
271 dev_err(&f34->fn->dev, "%s: Failed to write partition ID\n", in rmi_f34v7_write_partition_id()
279 static int rmi_f34v7_read_partition_table(struct f34_data *f34) in rmi_f34v7_read_partition_table() argument
287 base = f34->fn->fd.data_base_addr; in rmi_f34v7_read_partition_table()
289 f34->v7.config_area = v7_FLASH_CONFIG_AREA; in rmi_f34v7_read_partition_table()
291 ret = rmi_f34v7_write_partition_id(f34, v7_CMD_READ_CONFIG); in rmi_f34v7_read_partition_table()
295 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_read_partition_table()
296 base + f34->v7.off.block_number, in rmi_f34v7_read_partition_table()
299 dev_err(&f34->fn->dev, "%s: Failed to write block number\n", in rmi_f34v7_read_partition_table()
304 put_unaligned_le16(f34->v7.flash_config_length, &length); in rmi_f34v7_read_partition_table()
306 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_read_partition_table()
307 base + f34->v7.off.transfer_length, in rmi_f34v7_read_partition_table()
310 dev_err(&f34->fn->dev, "%s: Failed to write transfer length\n", in rmi_f34v7_read_partition_table()
315 init_completion(&f34->v7.cmd_done); in rmi_f34v7_read_partition_table()
317 ret = rmi_f34v7_write_command(f34, v7_CMD_READ_CONFIG); in rmi_f34v7_read_partition_table()
319 dev_err(&f34->fn->dev, "%s: Failed to write command\n", in rmi_f34v7_read_partition_table()
327 rmi_f34v7_read_flash_status(f34); in rmi_f34v7_read_partition_table()
329 if (f34->v7.command == v7_CMD_IDLE && in rmi_f34v7_read_partition_table()
330 f34->v7.flash_status == 0x00) { in rmi_f34v7_read_partition_table()
335 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_partition_table()
336 base + f34->v7.off.payload, in rmi_f34v7_read_partition_table()
337 f34->v7.read_config_buf, in rmi_f34v7_read_partition_table()
338 f34->v7.partition_table_bytes); in rmi_f34v7_read_partition_table()
340 dev_err(&f34->fn->dev, "%s: Failed to read block data\n", in rmi_f34v7_read_partition_table()
348 static void rmi_f34v7_parse_partition_table(struct f34_data *f34, in rmi_f34v7_parse_partition_table() argument
359 for (i = 0; i < f34->v7.partitions; i++) { in rmi_f34v7_parse_partition_table()
364 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
371 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
378 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
385 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
391 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
398 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()
416 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_partition_table()
424 static int rmi_f34v7_read_queries_bl_version(struct f34_data *f34) in rmi_f34v7_read_queries_bl_version() argument
432 base = f34->fn->fd.query_base_addr; in rmi_f34v7_read_queries_bl_version()
434 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries_bl_version()
439 dev_err(&f34->fn->dev, in rmi_f34v7_read_queries_bl_version()
446 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries_bl_version()
451 dev_err(&f34->fn->dev, "%s: Failed to read queries 1 to 7\n", in rmi_f34v7_read_queries_bl_version()
456 f34->bootloader_id[0] = query_1_7.bl_minor_revision; in rmi_f34v7_read_queries_bl_version()
457 f34->bootloader_id[1] = query_1_7.bl_major_revision; in rmi_f34v7_read_queries_bl_version()
459 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "Bootloader V%d.%d\n", in rmi_f34v7_read_queries_bl_version()
460 f34->bootloader_id[1], f34->bootloader_id[0]); in rmi_f34v7_read_queries_bl_version()
465 static int rmi_f34v7_read_queries(struct f34_data *f34) in rmi_f34v7_read_queries() argument
475 base = f34->fn->fd.query_base_addr; in rmi_f34v7_read_queries()
477 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries()
482 dev_err(&f34->fn->dev, in rmi_f34v7_read_queries()
489 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries()
494 dev_err(&f34->fn->dev, "%s: Failed to read queries 1 to 7\n", in rmi_f34v7_read_queries()
499 f34->bootloader_id[0] = query_1_7.bl_minor_revision; in rmi_f34v7_read_queries()
500 f34->bootloader_id[1] = query_1_7.bl_major_revision; in rmi_f34v7_read_queries()
502 f34->v7.block_size = le16_to_cpu(query_1_7.block_size); in rmi_f34v7_read_queries()
503 f34->v7.flash_config_length = in rmi_f34v7_read_queries()
505 f34->v7.payload_length = le16_to_cpu(query_1_7.payload_length); in rmi_f34v7_read_queries()
507 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: f34->v7.block_size = %d\n", in rmi_f34v7_read_queries()
508 __func__, f34->v7.block_size); in rmi_f34v7_read_queries()
510 f34->v7.off.flash_status = V7_FLASH_STATUS_OFFSET; in rmi_f34v7_read_queries()
511 f34->v7.off.partition_id = V7_PARTITION_ID_OFFSET; in rmi_f34v7_read_queries()
512 f34->v7.off.block_number = V7_BLOCK_NUMBER_OFFSET; in rmi_f34v7_read_queries()
513 f34->v7.off.transfer_length = V7_TRANSFER_LENGTH_OFFSET; in rmi_f34v7_read_queries()
514 f34->v7.off.flash_cmd = V7_COMMAND_OFFSET; in rmi_f34v7_read_queries()
515 f34->v7.off.payload = V7_PAYLOAD_OFFSET; in rmi_f34v7_read_queries()
517 f34->v7.has_display_cfg = query_1_7.partition_support[1] & HAS_DISP_CFG; in rmi_f34v7_read_queries()
518 f34->v7.has_guest_code = in rmi_f34v7_read_queries()
524 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_queries()
525 f34->fn->fd.control_base_addr, in rmi_f34v7_read_queries()
535 snprintf(f34->configuration_id, sizeof(f34->configuration_id), in rmi_f34v7_read_queries()
538 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "Configuration ID: %s\n", in rmi_f34v7_read_queries()
539 f34->configuration_id); in rmi_f34v7_read_queries()
542 f34->v7.partitions = 0; in rmi_f34v7_read_queries()
544 f34->v7.partitions += hweight8(query_1_7.partition_support[i]); in rmi_f34v7_read_queries()
546 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: Supported partitions: %*ph\n", in rmi_f34v7_read_queries()
551 f34->v7.partition_table_bytes = f34->v7.partitions * 8 + 2; in rmi_f34v7_read_queries()
553 f34->v7.read_config_buf = devm_kzalloc(&f34->fn->dev, in rmi_f34v7_read_queries()
554 f34->v7.partition_table_bytes, in rmi_f34v7_read_queries()
556 if (!f34->v7.read_config_buf) { in rmi_f34v7_read_queries()
557 f34->v7.read_config_buf_size = 0; in rmi_f34v7_read_queries()
561 f34->v7.read_config_buf_size = f34->v7.partition_table_bytes; in rmi_f34v7_read_queries()
562 ptable = f34->v7.read_config_buf; in rmi_f34v7_read_queries()
564 ret = rmi_f34v7_read_partition_table(f34); in rmi_f34v7_read_queries()
566 dev_err(&f34->fn->dev, "%s: Failed to read partition table\n", in rmi_f34v7_read_queries()
571 rmi_f34v7_parse_partition_table(f34, ptable, in rmi_f34v7_read_queries()
572 &f34->v7.blkcount, &f34->v7.phyaddr); in rmi_f34v7_read_queries()
577 static int rmi_f34v7_check_ui_firmware_size(struct f34_data *f34) in rmi_f34v7_check_ui_firmware_size() argument
581 block_count = f34->v7.img.ui_firmware.size / f34->v7.block_size; in rmi_f34v7_check_ui_firmware_size()
582 f34->update_size += block_count; in rmi_f34v7_check_ui_firmware_size()
584 if (block_count != f34->v7.blkcount.ui_firmware) { in rmi_f34v7_check_ui_firmware_size()
585 dev_err(&f34->fn->dev, in rmi_f34v7_check_ui_firmware_size()
587 block_count, f34->v7.blkcount.ui_firmware); in rmi_f34v7_check_ui_firmware_size()
594 static int rmi_f34v7_check_ui_config_size(struct f34_data *f34) in rmi_f34v7_check_ui_config_size() argument
598 block_count = f34->v7.img.ui_config.size / f34->v7.block_size; in rmi_f34v7_check_ui_config_size()
599 f34->update_size += block_count; in rmi_f34v7_check_ui_config_size()
601 if (block_count != f34->v7.blkcount.ui_config) { in rmi_f34v7_check_ui_config_size()
602 dev_err(&f34->fn->dev, "UI config size mismatch\n"); in rmi_f34v7_check_ui_config_size()
609 static int rmi_f34v7_check_dp_config_size(struct f34_data *f34) in rmi_f34v7_check_dp_config_size() argument
613 block_count = f34->v7.img.dp_config.size / f34->v7.block_size; in rmi_f34v7_check_dp_config_size()
614 f34->update_size += block_count; in rmi_f34v7_check_dp_config_size()
616 if (block_count != f34->v7.blkcount.dp_config) { in rmi_f34v7_check_dp_config_size()
617 dev_err(&f34->fn->dev, "Display config size mismatch\n"); in rmi_f34v7_check_dp_config_size()
624 static int rmi_f34v7_check_guest_code_size(struct f34_data *f34) in rmi_f34v7_check_guest_code_size() argument
628 block_count = f34->v7.img.guest_code.size / f34->v7.block_size; in rmi_f34v7_check_guest_code_size()
629 f34->update_size += block_count; in rmi_f34v7_check_guest_code_size()
631 if (block_count != f34->v7.blkcount.guest_code) { in rmi_f34v7_check_guest_code_size()
632 dev_err(&f34->fn->dev, "Guest code size mismatch\n"); in rmi_f34v7_check_guest_code_size()
639 static int rmi_f34v7_check_bl_config_size(struct f34_data *f34) in rmi_f34v7_check_bl_config_size() argument
643 block_count = f34->v7.img.bl_config.size / f34->v7.block_size; in rmi_f34v7_check_bl_config_size()
644 f34->update_size += block_count; in rmi_f34v7_check_bl_config_size()
646 if (block_count != f34->v7.blkcount.bl_config) { in rmi_f34v7_check_bl_config_size()
647 dev_err(&f34->fn->dev, "Bootloader config size mismatch\n"); in rmi_f34v7_check_bl_config_size()
654 static int rmi_f34v7_erase_config(struct f34_data *f34) in rmi_f34v7_erase_config() argument
658 dev_info(&f34->fn->dev, "Erasing config...\n"); in rmi_f34v7_erase_config()
660 init_completion(&f34->v7.cmd_done); in rmi_f34v7_erase_config()
662 switch (f34->v7.config_area) { in rmi_f34v7_erase_config()
664 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_CONFIG); in rmi_f34v7_erase_config()
669 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_DISP_CONFIG); in rmi_f34v7_erase_config()
674 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_BL_CONFIG); in rmi_f34v7_erase_config()
680 ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS); in rmi_f34v7_erase_config()
687 static int rmi_f34v7_erase_guest_code(struct f34_data *f34) in rmi_f34v7_erase_guest_code() argument
691 dev_info(&f34->fn->dev, "Erasing guest code...\n"); in rmi_f34v7_erase_guest_code()
693 init_completion(&f34->v7.cmd_done); in rmi_f34v7_erase_guest_code()
695 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_GUEST_CODE); in rmi_f34v7_erase_guest_code()
699 ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS); in rmi_f34v7_erase_guest_code()
706 static int rmi_f34v7_erase_all(struct f34_data *f34) in rmi_f34v7_erase_all() argument
710 dev_info(&f34->fn->dev, "Erasing firmware...\n"); in rmi_f34v7_erase_all()
712 init_completion(&f34->v7.cmd_done); in rmi_f34v7_erase_all()
714 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_FIRMWARE); in rmi_f34v7_erase_all()
718 ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS); in rmi_f34v7_erase_all()
722 f34->v7.config_area = v7_UI_CONFIG_AREA; in rmi_f34v7_erase_all()
723 ret = rmi_f34v7_erase_config(f34); in rmi_f34v7_erase_all()
727 if (f34->v7.has_display_cfg) { in rmi_f34v7_erase_all()
728 f34->v7.config_area = v7_DP_CONFIG_AREA; in rmi_f34v7_erase_all()
729 ret = rmi_f34v7_erase_config(f34); in rmi_f34v7_erase_all()
734 if (f34->v7.new_partition_table && f34->v7.has_guest_code) { in rmi_f34v7_erase_all()
735 ret = rmi_f34v7_erase_guest_code(f34); in rmi_f34v7_erase_all()
743 static int rmi_f34v7_read_blocks(struct f34_data *f34, in rmi_f34v7_read_blocks() argument
755 base = f34->fn->fd.data_base_addr; in rmi_f34v7_read_blocks()
757 ret = rmi_f34v7_write_partition_id(f34, command); in rmi_f34v7_read_blocks()
761 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_read_blocks()
762 base + f34->v7.off.block_number, in rmi_f34v7_read_blocks()
765 dev_err(&f34->fn->dev, "%s: Failed to write block number\n", in rmi_f34v7_read_blocks()
770 max_transfer = min(f34->v7.payload_length, in rmi_f34v7_read_blocks()
771 (u16)(PAGE_SIZE / f34->v7.block_size)); in rmi_f34v7_read_blocks()
777 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_read_blocks()
778 base + f34->v7.off.transfer_length, in rmi_f34v7_read_blocks()
781 dev_err(&f34->fn->dev, in rmi_f34v7_read_blocks()
787 init_completion(&f34->v7.cmd_done); in rmi_f34v7_read_blocks()
789 ret = rmi_f34v7_write_command(f34, command); in rmi_f34v7_read_blocks()
793 ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS); in rmi_f34v7_read_blocks()
797 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_read_blocks()
798 base + f34->v7.off.payload, in rmi_f34v7_read_blocks()
799 &f34->v7.read_config_buf[index], in rmi_f34v7_read_blocks()
800 transfer * f34->v7.block_size); in rmi_f34v7_read_blocks()
802 dev_err(&f34->fn->dev, in rmi_f34v7_read_blocks()
808 index += (transfer * f34->v7.block_size); in rmi_f34v7_read_blocks()
815 static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34, in rmi_f34v7_write_f34v7_blocks() argument
827 base = f34->fn->fd.data_base_addr; in rmi_f34v7_write_f34v7_blocks()
829 ret = rmi_f34v7_write_partition_id(f34, command); in rmi_f34v7_write_f34v7_blocks()
833 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_f34v7_blocks()
834 base + f34->v7.off.block_number, in rmi_f34v7_write_f34v7_blocks()
837 dev_err(&f34->fn->dev, "%s: Failed to write block number\n", in rmi_f34v7_write_f34v7_blocks()
842 if (f34->v7.payload_length > (PAGE_SIZE / f34->v7.block_size)) in rmi_f34v7_write_f34v7_blocks()
843 max_transfer = PAGE_SIZE / f34->v7.block_size; in rmi_f34v7_write_f34v7_blocks()
845 max_transfer = f34->v7.payload_length; in rmi_f34v7_write_f34v7_blocks()
851 init_completion(&f34->v7.cmd_done); in rmi_f34v7_write_f34v7_blocks()
853 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_f34v7_blocks()
854 base + f34->v7.off.transfer_length, in rmi_f34v7_write_f34v7_blocks()
857 dev_err(&f34->fn->dev, in rmi_f34v7_write_f34v7_blocks()
863 ret = rmi_f34v7_write_command(f34, command); in rmi_f34v7_write_f34v7_blocks()
867 ret = rmi_write_block(f34->fn->rmi_dev, in rmi_f34v7_write_f34v7_blocks()
868 base + f34->v7.off.payload, in rmi_f34v7_write_f34v7_blocks()
869 block_ptr, transfer * f34->v7.block_size); in rmi_f34v7_write_f34v7_blocks()
871 dev_err(&f34->fn->dev, in rmi_f34v7_write_f34v7_blocks()
877 ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS); in rmi_f34v7_write_f34v7_blocks()
881 block_ptr += (transfer * f34->v7.block_size); in rmi_f34v7_write_f34v7_blocks()
883 f34->update_progress += transfer; in rmi_f34v7_write_f34v7_blocks()
884 f34->update_status = (f34->update_progress * 100) / in rmi_f34v7_write_f34v7_blocks()
885 f34->update_size; in rmi_f34v7_write_f34v7_blocks()
891 static int rmi_f34v7_write_config(struct f34_data *f34) in rmi_f34v7_write_config() argument
893 return rmi_f34v7_write_f34v7_blocks(f34, f34->v7.config_data, in rmi_f34v7_write_config()
894 f34->v7.config_block_count, in rmi_f34v7_write_config()
898 static int rmi_f34v7_write_ui_config(struct f34_data *f34) in rmi_f34v7_write_ui_config() argument
900 f34->v7.config_area = v7_UI_CONFIG_AREA; in rmi_f34v7_write_ui_config()
901 f34->v7.config_data = f34->v7.img.ui_config.data; in rmi_f34v7_write_ui_config()
902 f34->v7.config_size = f34->v7.img.ui_config.size; in rmi_f34v7_write_ui_config()
903 f34->v7.config_block_count = f34->v7.config_size / f34->v7.block_size; in rmi_f34v7_write_ui_config()
905 return rmi_f34v7_write_config(f34); in rmi_f34v7_write_ui_config()
908 static int rmi_f34v7_write_dp_config(struct f34_data *f34) in rmi_f34v7_write_dp_config() argument
910 f34->v7.config_area = v7_DP_CONFIG_AREA; in rmi_f34v7_write_dp_config()
911 f34->v7.config_data = f34->v7.img.dp_config.data; in rmi_f34v7_write_dp_config()
912 f34->v7.config_size = f34->v7.img.dp_config.size; in rmi_f34v7_write_dp_config()
913 f34->v7.config_block_count = f34->v7.config_size / f34->v7.block_size; in rmi_f34v7_write_dp_config()
915 return rmi_f34v7_write_config(f34); in rmi_f34v7_write_dp_config()
918 static int rmi_f34v7_write_guest_code(struct f34_data *f34) in rmi_f34v7_write_guest_code() argument
920 return rmi_f34v7_write_f34v7_blocks(f34, f34->v7.img.guest_code.data, in rmi_f34v7_write_guest_code()
921 f34->v7.img.guest_code.size / in rmi_f34v7_write_guest_code()
922 f34->v7.block_size, in rmi_f34v7_write_guest_code()
926 static int rmi_f34v7_write_flash_config(struct f34_data *f34) in rmi_f34v7_write_flash_config() argument
930 f34->v7.config_area = v7_FLASH_CONFIG_AREA; in rmi_f34v7_write_flash_config()
931 f34->v7.config_data = f34->v7.img.fl_config.data; in rmi_f34v7_write_flash_config()
932 f34->v7.config_size = f34->v7.img.fl_config.size; in rmi_f34v7_write_flash_config()
933 f34->v7.config_block_count = f34->v7.config_size / f34->v7.block_size; in rmi_f34v7_write_flash_config()
935 if (f34->v7.config_block_count != f34->v7.blkcount.fl_config) { in rmi_f34v7_write_flash_config()
936 dev_err(&f34->fn->dev, "%s: Flash config size mismatch\n", in rmi_f34v7_write_flash_config()
941 init_completion(&f34->v7.cmd_done); in rmi_f34v7_write_flash_config()
943 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_FLASH_CONFIG); in rmi_f34v7_write_flash_config()
947 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_write_flash_config()
950 ret = rmi_f34v7_wait_for_idle(f34, F34_WRITE_WAIT_MS); in rmi_f34v7_write_flash_config()
954 ret = rmi_f34v7_write_config(f34); in rmi_f34v7_write_flash_config()
961 static int rmi_f34v7_write_partition_table(struct f34_data *f34) in rmi_f34v7_write_partition_table() argument
966 block_count = f34->v7.blkcount.bl_config; in rmi_f34v7_write_partition_table()
967 f34->v7.config_area = v7_BL_CONFIG_AREA; in rmi_f34v7_write_partition_table()
968 f34->v7.config_size = f34->v7.block_size * block_count; in rmi_f34v7_write_partition_table()
969 devm_kfree(&f34->fn->dev, f34->v7.read_config_buf); in rmi_f34v7_write_partition_table()
970 f34->v7.read_config_buf = devm_kzalloc(&f34->fn->dev, in rmi_f34v7_write_partition_table()
971 f34->v7.config_size, GFP_KERNEL); in rmi_f34v7_write_partition_table()
972 if (!f34->v7.read_config_buf) { in rmi_f34v7_write_partition_table()
973 f34->v7.read_config_buf_size = 0; in rmi_f34v7_write_partition_table()
977 f34->v7.read_config_buf_size = f34->v7.config_size; in rmi_f34v7_write_partition_table()
979 ret = rmi_f34v7_read_blocks(f34, block_count, v7_CMD_READ_CONFIG); in rmi_f34v7_write_partition_table()
983 ret = rmi_f34v7_erase_config(f34); in rmi_f34v7_write_partition_table()
987 ret = rmi_f34v7_write_flash_config(f34); in rmi_f34v7_write_partition_table()
991 f34->v7.config_area = v7_BL_CONFIG_AREA; in rmi_f34v7_write_partition_table()
992 f34->v7.config_data = f34->v7.read_config_buf; in rmi_f34v7_write_partition_table()
993 f34->v7.config_size = f34->v7.img.bl_config.size; in rmi_f34v7_write_partition_table()
994 f34->v7.config_block_count = f34->v7.config_size / f34->v7.block_size; in rmi_f34v7_write_partition_table()
996 ret = rmi_f34v7_write_config(f34); in rmi_f34v7_write_partition_table()
1003 static int rmi_f34v7_write_firmware(struct f34_data *f34) in rmi_f34v7_write_firmware() argument
1007 blk_count = f34->v7.img.ui_firmware.size / f34->v7.block_size; in rmi_f34v7_write_firmware()
1009 return rmi_f34v7_write_f34v7_blocks(f34, f34->v7.img.ui_firmware.data, in rmi_f34v7_write_firmware()
1013 static void rmi_f34v7_compare_partition_tables(struct f34_data *f34) in rmi_f34v7_compare_partition_tables() argument
1015 if (f34->v7.phyaddr.ui_firmware != f34->v7.img.phyaddr.ui_firmware) { in rmi_f34v7_compare_partition_tables()
1016 f34->v7.new_partition_table = true; in rmi_f34v7_compare_partition_tables()
1020 if (f34->v7.phyaddr.ui_config != f34->v7.img.phyaddr.ui_config) { in rmi_f34v7_compare_partition_tables()
1021 f34->v7.new_partition_table = true; in rmi_f34v7_compare_partition_tables()
1025 if (f34->v7.has_display_cfg && in rmi_f34v7_compare_partition_tables()
1026 f34->v7.phyaddr.dp_config != f34->v7.img.phyaddr.dp_config) { in rmi_f34v7_compare_partition_tables()
1027 f34->v7.new_partition_table = true; in rmi_f34v7_compare_partition_tables()
1031 if (f34->v7.has_guest_code && in rmi_f34v7_compare_partition_tables()
1032 f34->v7.phyaddr.guest_code != f34->v7.img.phyaddr.guest_code) { in rmi_f34v7_compare_partition_tables()
1033 f34->v7.new_partition_table = true; in rmi_f34v7_compare_partition_tables()
1037 f34->v7.new_partition_table = false; in rmi_f34v7_compare_partition_tables()
1040 static void rmi_f34v7_parse_img_header_10_bl_container(struct f34_data *f34, in rmi_f34v7_parse_img_header_10_bl_container() argument
1051 num_of_containers = f34->v7.img.bootloader.size / 4 - 1; in rmi_f34v7_parse_img_header_10_bl_container()
1054 addr = get_unaligned_le32(f34->v7.img.bootloader.data + i * 4); in rmi_f34v7_parse_img_header_10_bl_container()
1062 f34->v7.img.bl_config.data = content; in rmi_f34v7_parse_img_header_10_bl_container()
1063 f34->v7.img.bl_config.size = length; in rmi_f34v7_parse_img_header_10_bl_container()
1067 f34->v7.img.lockdown.data = content; in rmi_f34v7_parse_img_header_10_bl_container()
1068 f34->v7.img.lockdown.size = length; in rmi_f34v7_parse_img_header_10_bl_container()
1076 static void rmi_f34v7_parse_image_header_10(struct f34_data *f34) in rmi_f34v7_parse_image_header_10() argument
1084 const void *image = f34->v7.image; in rmi_f34v7_parse_image_header_10()
1089 f34->v7.img.checksum = le32_to_cpu(header->checksum); in rmi_f34v7_parse_image_header_10()
1091 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: f34->v7.img.checksum=%X\n", in rmi_f34v7_parse_image_header_10()
1092 __func__, f34->v7.img.checksum); in rmi_f34v7_parse_image_header_10()
1110 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_image_header_10()
1117 f34->v7.img.ui_firmware.data = content; in rmi_f34v7_parse_image_header_10()
1118 f34->v7.img.ui_firmware.size = length; in rmi_f34v7_parse_image_header_10()
1122 f34->v7.img.ui_config.data = content; in rmi_f34v7_parse_image_header_10()
1123 f34->v7.img.ui_config.size = length; in rmi_f34v7_parse_image_header_10()
1126 f34->v7.img.bl_version = *content; in rmi_f34v7_parse_image_header_10()
1127 f34->v7.img.bootloader.data = content; in rmi_f34v7_parse_image_header_10()
1128 f34->v7.img.bootloader.size = length; in rmi_f34v7_parse_image_header_10()
1129 rmi_f34v7_parse_img_header_10_bl_container(f34, image); in rmi_f34v7_parse_image_header_10()
1132 f34->v7.img.contains_guest_code = true; in rmi_f34v7_parse_image_header_10()
1133 f34->v7.img.guest_code.data = content; in rmi_f34v7_parse_image_header_10()
1134 f34->v7.img.guest_code.size = length; in rmi_f34v7_parse_image_header_10()
1137 f34->v7.img.contains_display_cfg = true; in rmi_f34v7_parse_image_header_10()
1138 f34->v7.img.dp_config.data = content; in rmi_f34v7_parse_image_header_10()
1139 f34->v7.img.dp_config.size = length; in rmi_f34v7_parse_image_header_10()
1142 f34->v7.img.contains_flash_config = true; in rmi_f34v7_parse_image_header_10()
1143 f34->v7.img.fl_config.data = content; in rmi_f34v7_parse_image_header_10()
1144 f34->v7.img.fl_config.size = length; in rmi_f34v7_parse_image_header_10()
1147 f34->v7.img.contains_firmware_id = true; in rmi_f34v7_parse_image_header_10()
1148 f34->v7.img.firmware_id = in rmi_f34v7_parse_image_header_10()
1157 static int rmi_f34v7_parse_image_info(struct f34_data *f34) in rmi_f34v7_parse_image_info() argument
1159 const struct image_header_10 *header = f34->v7.image; in rmi_f34v7_parse_image_info()
1161 memset(&f34->v7.img, 0x00, sizeof(f34->v7.img)); in rmi_f34v7_parse_image_info()
1163 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34v7_parse_image_info()
1169 rmi_f34v7_parse_image_header_10(f34); in rmi_f34v7_parse_image_info()
1172 dev_err(&f34->fn->dev, "Unsupported image file format %02X\n", in rmi_f34v7_parse_image_info()
1177 if (!f34->v7.img.contains_flash_config) { in rmi_f34v7_parse_image_info()
1178 dev_err(&f34->fn->dev, "%s: No flash config in fw image\n", in rmi_f34v7_parse_image_info()
1183 rmi_f34v7_parse_partition_table(f34, f34->v7.img.fl_config.data, in rmi_f34v7_parse_image_info()
1184 &f34->v7.img.blkcount, &f34->v7.img.phyaddr); in rmi_f34v7_parse_image_info()
1186 rmi_f34v7_compare_partition_tables(f34); in rmi_f34v7_parse_image_info()
1191 int rmi_f34v7_do_reflash(struct f34_data *f34, const struct firmware *fw) in rmi_f34v7_do_reflash() argument
1195 rmi_f34v7_read_queries_bl_version(f34); in rmi_f34v7_do_reflash()
1197 f34->v7.image = fw->data; in rmi_f34v7_do_reflash()
1198 f34->update_progress = 0; in rmi_f34v7_do_reflash()
1199 f34->update_size = 0; in rmi_f34v7_do_reflash()
1201 ret = rmi_f34v7_parse_image_info(f34); in rmi_f34v7_do_reflash()
1205 if (!f34->v7.new_partition_table) { in rmi_f34v7_do_reflash()
1206 ret = rmi_f34v7_check_ui_firmware_size(f34); in rmi_f34v7_do_reflash()
1210 ret = rmi_f34v7_check_ui_config_size(f34); in rmi_f34v7_do_reflash()
1214 if (f34->v7.has_display_cfg && in rmi_f34v7_do_reflash()
1215 f34->v7.img.contains_display_cfg) { in rmi_f34v7_do_reflash()
1216 ret = rmi_f34v7_check_dp_config_size(f34); in rmi_f34v7_do_reflash()
1221 if (f34->v7.has_guest_code && f34->v7.img.contains_guest_code) { in rmi_f34v7_do_reflash()
1222 ret = rmi_f34v7_check_guest_code_size(f34); in rmi_f34v7_do_reflash()
1227 ret = rmi_f34v7_check_bl_config_size(f34); in rmi_f34v7_do_reflash()
1232 ret = rmi_f34v7_erase_all(f34); in rmi_f34v7_do_reflash()
1236 if (f34->v7.new_partition_table) { in rmi_f34v7_do_reflash()
1237 ret = rmi_f34v7_write_partition_table(f34); in rmi_f34v7_do_reflash()
1240 dev_info(&f34->fn->dev, "%s: Partition table programmed\n", in rmi_f34v7_do_reflash()
1244 dev_info(&f34->fn->dev, "Writing firmware (%d bytes)...\n", in rmi_f34v7_do_reflash()
1245 f34->v7.img.ui_firmware.size); in rmi_f34v7_do_reflash()
1247 ret = rmi_f34v7_write_firmware(f34); in rmi_f34v7_do_reflash()
1251 dev_info(&f34->fn->dev, "Writing config (%d bytes)...\n", in rmi_f34v7_do_reflash()
1252 f34->v7.img.ui_config.size); in rmi_f34v7_do_reflash()
1254 f34->v7.config_area = v7_UI_CONFIG_AREA; in rmi_f34v7_do_reflash()
1255 ret = rmi_f34v7_write_ui_config(f34); in rmi_f34v7_do_reflash()
1259 if (f34->v7.has_display_cfg && f34->v7.img.contains_display_cfg) { in rmi_f34v7_do_reflash()
1260 dev_info(&f34->fn->dev, "Writing display config...\n"); in rmi_f34v7_do_reflash()
1262 ret = rmi_f34v7_write_dp_config(f34); in rmi_f34v7_do_reflash()
1267 if (f34->v7.new_partition_table) { in rmi_f34v7_do_reflash()
1268 if (f34->v7.has_guest_code && f34->v7.img.contains_guest_code) { in rmi_f34v7_do_reflash()
1269 dev_info(&f34->fn->dev, "Writing guest code...\n"); in rmi_f34v7_do_reflash()
1271 ret = rmi_f34v7_write_guest_code(f34); in rmi_f34v7_do_reflash()
1281 static int rmi_f34v7_enter_flash_prog(struct f34_data *f34) in rmi_f34v7_enter_flash_prog() argument
1285 f34->fn->rmi_dev->driver->set_irq_bits(f34->fn->rmi_dev, f34->fn->irq_mask); in rmi_f34v7_enter_flash_prog()
1287 ret = rmi_f34v7_read_flash_status(f34); in rmi_f34v7_enter_flash_prog()
1291 if (f34->v7.in_bl_mode) in rmi_f34v7_enter_flash_prog()
1294 init_completion(&f34->v7.cmd_done); in rmi_f34v7_enter_flash_prog()
1296 ret = rmi_f34v7_write_command(f34, v7_CMD_ENABLE_FLASH_PROG); in rmi_f34v7_enter_flash_prog()
1300 ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS); in rmi_f34v7_enter_flash_prog()
1307 int rmi_f34v7_start_reflash(struct f34_data *f34, const struct firmware *fw) in rmi_f34v7_start_reflash() argument
1311 f34->fn->rmi_dev->driver->set_irq_bits(f34->fn->rmi_dev, f34->fn->irq_mask); in rmi_f34v7_start_reflash()
1313 f34->v7.config_area = v7_UI_CONFIG_AREA; in rmi_f34v7_start_reflash()
1314 f34->v7.image = fw->data; in rmi_f34v7_start_reflash()
1316 ret = rmi_f34v7_parse_image_info(f34); in rmi_f34v7_start_reflash()
1320 if (!f34->v7.force_update && f34->v7.new_partition_table) { in rmi_f34v7_start_reflash()
1321 dev_err(&f34->fn->dev, "%s: Partition table mismatch\n", in rmi_f34v7_start_reflash()
1327 dev_info(&f34->fn->dev, "Firmware image OK\n"); in rmi_f34v7_start_reflash()
1329 ret = rmi_f34v7_read_flash_status(f34); in rmi_f34v7_start_reflash()
1333 if (f34->v7.in_bl_mode) { in rmi_f34v7_start_reflash()
1334 dev_info(&f34->fn->dev, "%s: Device in bootloader mode\n", in rmi_f34v7_start_reflash()
1338 rmi_f34v7_enter_flash_prog(f34); in rmi_f34v7_start_reflash()
1346 int rmi_f34v7_probe(struct f34_data *f34) in rmi_f34v7_probe() argument
1351 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34v7_probe()
1352 f34->fn->fd.query_base_addr + V7_BOOTLOADER_ID_OFFSET, in rmi_f34v7_probe()
1353 f34->bootloader_id, in rmi_f34v7_probe()
1354 sizeof(f34->bootloader_id)); in rmi_f34v7_probe()
1356 dev_err(&f34->fn->dev, "%s: Failed to read bootloader ID\n", in rmi_f34v7_probe()
1361 if (f34->bootloader_id[1] == '5') { in rmi_f34v7_probe()
1362 f34->bl_version = 5; in rmi_f34v7_probe()
1363 } else if (f34->bootloader_id[1] == '6') { in rmi_f34v7_probe()
1364 f34->bl_version = 6; in rmi_f34v7_probe()
1365 } else if (f34->bootloader_id[1] == 7) { in rmi_f34v7_probe()
1366 f34->bl_version = 7; in rmi_f34v7_probe()
1368 dev_err(&f34->fn->dev, "%s: Unrecognized bootloader version\n", in rmi_f34v7_probe()
1373 memset(&f34->v7.blkcount, 0x00, sizeof(f34->v7.blkcount)); in rmi_f34v7_probe()
1374 memset(&f34->v7.phyaddr, 0x00, sizeof(f34->v7.phyaddr)); in rmi_f34v7_probe()
1376 init_completion(&f34->v7.cmd_done); in rmi_f34v7_probe()
1378 ret = rmi_f34v7_read_queries(f34); in rmi_f34v7_probe()
1382 f34->v7.force_update = true; in rmi_f34v7_probe()