Lines Matching +full:bootloader +full:- +full:config
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2007-2016, Synaptics Incorporated
18 struct rmi_function *fn = f34->fn; in rmi_f34_write_bootloader_id()
19 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_f34_write_bootloader_id()
23 ret = rmi_read_block(rmi_dev, fn->fd.query_base_addr, in rmi_f34_write_bootloader_id()
26 dev_err(&fn->dev, "%s: Reading bootloader ID failed: %d\n", in rmi_f34_write_bootloader_id()
31 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: writing bootloader id '%c%c'\n", in rmi_f34_write_bootloader_id()
35 fn->fd.data_base_addr + F34_BLOCK_DATA_OFFSET, in rmi_f34_write_bootloader_id()
38 dev_err(&fn->dev, "Failed to write bootloader ID: %d\n", ret); in rmi_f34_write_bootloader_id()
48 struct rmi_function *fn = f34->fn; in rmi_f34_command()
49 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_f34_command()
58 init_completion(&f34->v5.cmd_done); in rmi_f34_command()
60 ret = rmi_read(rmi_dev, f34->v5.ctrl_address, &f34->v5.status); in rmi_f34_command()
62 dev_err(&f34->fn->dev, in rmi_f34_command()
68 f34->v5.status |= command & 0x0f; in rmi_f34_command()
70 ret = rmi_write(rmi_dev, f34->v5.ctrl_address, f34->v5.status); in rmi_f34_command()
72 dev_err(&f34->fn->dev, in rmi_f34_command()
78 if (!wait_for_completion_timeout(&f34->v5.cmd_done, in rmi_f34_command()
81 ret = rmi_read(rmi_dev, f34->v5.ctrl_address, &f34->v5.status); in rmi_f34_command()
83 dev_err(&f34->fn->dev, in rmi_f34_command()
89 if (f34->v5.status & 0x7f) { in rmi_f34_command()
90 dev_err(&f34->fn->dev, in rmi_f34_command()
92 __func__, command, f34->v5.status); in rmi_f34_command()
93 return -ETIMEDOUT; in rmi_f34_command()
103 struct f34_data *f34 = dev_get_drvdata(&fn->dev); in rmi_f34_attention()
107 if (f34->bl_version == 5) { in rmi_f34_attention()
108 ret = rmi_read(f34->fn->rmi_dev, f34->v5.ctrl_address, in rmi_f34_attention()
110 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: status: %#02x, ret: %d\n", in rmi_f34_attention()
114 complete(&f34->v5.cmd_done); in rmi_f34_attention()
116 ret = rmi_read_block(f34->fn->rmi_dev, in rmi_f34_attention()
117 f34->fn->fd.data_base_addr + in rmi_f34_attention()
120 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, "%s: cmd: %#02x, ret: %d\n", in rmi_f34_attention()
124 complete(&f34->v7.cmd_done); in rmi_f34_attention()
133 struct rmi_function *fn = f34->fn; in rmi_f34_write_blocks()
134 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_f34_write_blocks()
135 u16 address = fn->fd.data_base_addr + F34_BLOCK_DATA_OFFSET; in rmi_f34_write_blocks()
140 ret = rmi_write_block(rmi_dev, fn->fd.data_base_addr, in rmi_f34_write_blocks()
143 dev_err(&fn->dev, "Failed to write initial zeros: %d\n", ret); in rmi_f34_write_blocks()
149 data, f34->v5.block_size); in rmi_f34_write_blocks()
151 dev_err(&fn->dev, in rmi_f34_write_blocks()
158 dev_err(&fn->dev, in rmi_f34_write_blocks()
164 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "wrote block %d of %d\n", in rmi_f34_write_blocks()
167 data += f34->v5.block_size; in rmi_f34_write_blocks()
168 f34->update_progress += f34->v5.block_size; in rmi_f34_write_blocks()
169 f34->update_status = (f34->update_progress * 100) / in rmi_f34_write_blocks()
170 f34->update_size; in rmi_f34_write_blocks()
178 return rmi_f34_write_blocks(f34, data, f34->v5.fw_blocks, in rmi_f34_write_firmware()
184 return rmi_f34_write_blocks(f34, data, f34->v5.config_blocks, in rmi_f34_write_config()
197 struct rmi_function *fn = f34->fn; in rmi_f34_flash_firmware()
198 u32 image_size = le32_to_cpu(syn_fw->image_size); in rmi_f34_flash_firmware()
199 u32 config_size = le32_to_cpu(syn_fw->config_size); in rmi_f34_flash_firmware()
202 f34->update_progress = 0; in rmi_f34_flash_firmware()
203 f34->update_size = image_size + config_size; in rmi_f34_flash_firmware()
206 dev_info(&fn->dev, "Erasing firmware...\n"); in rmi_f34_flash_firmware()
212 dev_info(&fn->dev, "Writing firmware (%d bytes)...\n", in rmi_f34_flash_firmware()
214 ret = rmi_f34_write_firmware(f34, syn_fw->data); in rmi_f34_flash_firmware()
221 * We only need to erase config if we haven't updated in rmi_f34_flash_firmware()
225 dev_info(&fn->dev, "Erasing config...\n"); in rmi_f34_flash_firmware()
232 dev_info(&fn->dev, "Writing config (%d bytes)...\n", in rmi_f34_flash_firmware()
234 ret = rmi_f34_write_config(f34, &syn_fw->data[image_size]); in rmi_f34_flash_firmware()
246 (const struct rmi_f34_firmware *)fw->data; in rmi_f34_update_firmware()
247 u32 image_size = le32_to_cpu(syn_fw->image_size); in rmi_f34_update_firmware()
248 u32 config_size = le32_to_cpu(syn_fw->config_size); in rmi_f34_update_firmware()
253 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34_update_firmware()
255 fw->size, in rmi_f34_update_firmware()
256 le32_to_cpu(syn_fw->checksum), in rmi_f34_update_firmware()
259 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, in rmi_f34_update_firmware()
261 syn_fw->bootloader_version, in rmi_f34_update_firmware()
262 (int)sizeof(syn_fw->product_id), syn_fw->product_id, in rmi_f34_update_firmware()
263 syn_fw->product_info[0], syn_fw->product_info[1]); in rmi_f34_update_firmware()
265 if (image_size && image_size != f34->v5.fw_blocks * f34->v5.block_size) { in rmi_f34_update_firmware()
266 dev_err(&f34->fn->dev, in rmi_f34_update_firmware()
268 image_size, f34->v5.fw_blocks * f34->v5.block_size); in rmi_f34_update_firmware()
269 return -EILSEQ; in rmi_f34_update_firmware()
273 config_size != f34->v5.config_blocks * f34->v5.block_size) { in rmi_f34_update_firmware()
274 dev_err(&f34->fn->dev, in rmi_f34_update_firmware()
275 "Bad firmware image: config size %d, expected %d\n", in rmi_f34_update_firmware()
277 f34->v5.config_blocks * f34->v5.block_size); in rmi_f34_update_firmware()
278 return -EILSEQ; in rmi_f34_update_firmware()
282 dev_err(&f34->fn->dev, "Bad firmware image: no config data\n"); in rmi_f34_update_firmware()
283 return -EILSEQ; in rmi_f34_update_firmware()
286 dev_info(&f34->fn->dev, "Firmware image OK\n"); in rmi_f34_update_firmware()
288 guard(mutex)(&f34->v5.flash_mutex); in rmi_f34_update_firmware()
294 struct f34_data *f34 = dev_get_drvdata(&fn->dev); in rmi_f34_status()
300 return f34->update_status; in rmi_f34_status()
308 struct rmi_function *fn = data->f34_container; in rmi_driver_bootloader_id_show()
312 f34 = dev_get_drvdata(&fn->dev); in rmi_driver_bootloader_id_show()
314 if (f34->bl_version == 5) in rmi_driver_bootloader_id_show()
316 f34->bootloader_id[0], in rmi_driver_bootloader_id_show()
317 f34->bootloader_id[1]); in rmi_driver_bootloader_id_show()
320 f34->bootloader_id[1], in rmi_driver_bootloader_id_show()
321 f34->bootloader_id[0]); in rmi_driver_bootloader_id_show()
334 struct rmi_function *fn = data->f34_container; in rmi_driver_configuration_id_show()
338 f34 = dev_get_drvdata(&fn->dev); in rmi_driver_configuration_id_show()
340 return sysfs_emit(buf, "%s\n", f34->configuration_id); in rmi_driver_configuration_id_show()
352 struct rmi_device *rmi_dev = data->rmi_dev; in rmi_firmware_update()
353 struct device *dev = &rmi_dev->dev; in rmi_firmware_update()
357 if (!data->f34_container) { in rmi_firmware_update()
359 return -EINVAL; in rmi_firmware_update()
362 f34 = dev_get_drvdata(&data->f34_container->dev); in rmi_firmware_update()
364 if (f34->bl_version >= 7) { in rmi_firmware_update()
365 if (data->pdt_props & HAS_BSR) { in rmi_firmware_update()
367 return -ENODEV; in rmi_firmware_update()
369 } else if (f34->bl_version != 5) { in rmi_firmware_update()
371 data->f34_container->fd.function_version); in rmi_firmware_update()
372 return -ENODEV; in rmi_firmware_update()
376 if (f34->bl_version >= 7) in rmi_firmware_update()
385 /* Tear down functions and re-probe */ in rmi_firmware_update()
396 if (!data->bootloader_mode || !data->f34_container) { in rmi_firmware_update()
397 dev_warn(dev, "%s: No F34 present or not in bootloader!\n", in rmi_firmware_update()
399 return -EINVAL; in rmi_firmware_update()
404 f34 = dev_get_drvdata(&data->f34_container->dev); in rmi_firmware_update()
407 if (f34->bl_version >= 7) in rmi_firmware_update()
413 f34->update_status = ret; in rmi_firmware_update()
414 dev_err(&f34->fn->dev, in rmi_firmware_update()
417 dev_info(&f34->fn->dev, "Firmware update complete\n"); in rmi_firmware_update()
422 /* Re-probe */ in rmi_firmware_update()
423 rmi_dbg(RMI_DEBUG_FN, dev, "Re-probing device\n"); in rmi_firmware_update()
440 if (data->f01_container->dev.driver) in rmi_firmware_update()
459 return -EINVAL; in rmi_driver_update_fw_store()
461 if (buf[count - 1] == '\0' || buf[count - 1] == '\n') in rmi_driver_update_fw_store()
462 copy_count -= 1; in rmi_driver_update_fw_store()
490 if (data->f34_container) in rmi_driver_update_fw_status_show()
491 update_status = rmi_f34_status(data->f34_container); in rmi_driver_update_fw_status_show()
516 u8 version = fn->fd.function_version; in rmi_f34_probe()
519 f34 = devm_kzalloc(&fn->dev, sizeof(struct f34_data), GFP_KERNEL); in rmi_f34_probe()
521 return -ENOMEM; in rmi_f34_probe()
523 f34->fn = fn; in rmi_f34_probe()
524 dev_set_drvdata(&fn->dev, f34); in rmi_f34_probe()
530 f34->bl_version = 5; in rmi_f34_probe()
532 ret = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr, in rmi_f34_probe()
535 dev_err(&fn->dev, "%s: Failed to query properties\n", in rmi_f34_probe()
540 snprintf(f34->bootloader_id, sizeof(f34->bootloader_id), in rmi_f34_probe()
543 mutex_init(&f34->v5.flash_mutex); in rmi_f34_probe()
544 init_completion(&f34->v5.cmd_done); in rmi_f34_probe()
546 f34->v5.block_size = get_unaligned_le16(&f34_queries[3]); in rmi_f34_probe()
547 f34->v5.fw_blocks = get_unaligned_le16(&f34_queries[5]); in rmi_f34_probe()
548 f34->v5.config_blocks = get_unaligned_le16(&f34_queries[7]); in rmi_f34_probe()
549 f34->v5.ctrl_address = fn->fd.data_base_addr + F34_BLOCK_DATA_OFFSET + in rmi_f34_probe()
550 f34->v5.block_size; in rmi_f34_probe()
553 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "Bootloader ID: %s\n", in rmi_f34_probe()
554 f34->bootloader_id); in rmi_f34_probe()
555 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "Block size: %d\n", in rmi_f34_probe()
556 f34->v5.block_size); in rmi_f34_probe()
557 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "FW blocks: %d\n", in rmi_f34_probe()
558 f34->v5.fw_blocks); in rmi_f34_probe()
559 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "CFG blocks: %d\n", in rmi_f34_probe()
560 f34->v5.config_blocks); in rmi_f34_probe()
563 ret = rmi_read_block(fn->rmi_dev, fn->fd.control_base_addr, in rmi_f34_probe()
566 dev_err(&fn->dev, "Failed to read F34 config ID\n"); in rmi_f34_probe()
570 snprintf(f34->configuration_id, sizeof(f34->configuration_id), in rmi_f34_probe()
575 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "Configuration ID: %s\n", in rmi_f34_probe()
576 f34->configuration_id); in rmi_f34_probe()
584 return sysfs_create_group(&rmi_dev->dev.kobj, &rmi_firmware_attr_group); in rmi_f34_create_sysfs()
589 sysfs_remove_group(&rmi_dev->dev.kobj, &rmi_firmware_attr_group); in rmi_f34_remove_sysfs()