Lines Matching refs:sec
20 int (*rsu_status)(struct m10bmc_sec *sec);
41 static int m10bmc_sec_write(struct m10bmc_sec *sec, const u8 *buf, u32 offset, u32 size) in m10bmc_sec_write() argument
43 struct intel_m10bmc *m10bmc = sec->m10bmc; in m10bmc_sec_write()
51 if (sec->m10bmc->flash_bulk_ops) in m10bmc_sec_write()
52 return sec->m10bmc->flash_bulk_ops->write(m10bmc, buf, offset, size); in m10bmc_sec_write()
74 static int m10bmc_sec_read(struct m10bmc_sec *sec, u8 *buf, u32 addr, u32 size) in m10bmc_sec_read() argument
76 struct intel_m10bmc *m10bmc = sec->m10bmc; in m10bmc_sec_read()
84 if (sec->m10bmc->flash_bulk_ops) in m10bmc_sec_read()
85 return sec->m10bmc->flash_bulk_ops->read(m10bmc, buf, addr, size); in m10bmc_sec_read()
110 struct m10bmc_sec *sec = dev_get_drvdata(dev); in show_root_entry_hash() local
115 ret = m10bmc_sec_read(sec, (u8 *)&magic, prog_addr, sizeof(magic)); in show_root_entry_hash()
125 dev_err(sec->dev, "%s bad sha num bytes %d\n", __func__, in show_root_entry_hash()
130 ret = m10bmc_sec_read(sec, hash, reh_addr, sha_num_bytes); in show_root_entry_hash()
148 struct m10bmc_sec *sec = dev_get_drvdata(dev); \
149 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; \
169 struct m10bmc_sec *sec = dev_get_drvdata(dev); in show_canceled_csk() local
175 ret = m10bmc_sec_read(sec, (u8 *)&csk_le32, addr, size); in show_canceled_csk()
177 dev_err(sec->dev, "failed to read CSK vector\n"); in show_canceled_csk()
194 struct m10bmc_sec *sec = dev_get_drvdata(dev); \
195 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; \
214 struct m10bmc_sec *sec = dev_get_drvdata(dev); in flash_count_show() local
215 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in flash_count_show()
226 ret = m10bmc_sec_read(sec, flash_buf, csr_map->rsu_update_counter, in flash_count_show()
229 dev_err(sec->dev, "failed to read flash count\n"); in flash_count_show()
262 static void log_error_regs(struct m10bmc_sec *sec, u32 doorbell) in log_error_regs() argument
264 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in log_error_regs()
267 dev_err(sec->dev, "Doorbell: 0x%08x\n", doorbell); in log_error_regs()
269 if (!m10bmc_sys_read(sec->m10bmc, csr_map->auth_result, &auth_result)) in log_error_regs()
270 dev_err(sec->dev, "RSU auth result: 0x%08x\n", auth_result); in log_error_regs()
273 static int m10bmc_sec_n3000_rsu_status(struct m10bmc_sec *sec) in m10bmc_sec_n3000_rsu_status() argument
275 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in m10bmc_sec_n3000_rsu_status()
279 ret = m10bmc_sys_read(sec->m10bmc, csr_map->doorbell, &doorbell); in m10bmc_sec_n3000_rsu_status()
286 static int m10bmc_sec_n6000_rsu_status(struct m10bmc_sec *sec) in m10bmc_sec_n6000_rsu_status() argument
288 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in m10bmc_sec_n6000_rsu_status()
292 ret = m10bmc_sys_read(sec->m10bmc, csr_map->auth_result, &auth_result); in m10bmc_sec_n6000_rsu_status()
321 static int m10bmc_sec_progress_status(struct m10bmc_sec *sec, u32 *doorbell_reg, in m10bmc_sec_progress_status() argument
324 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in m10bmc_sec_progress_status()
327 ret = m10bmc_sys_read(sec->m10bmc, csr_map->doorbell, doorbell_reg); in m10bmc_sec_progress_status()
331 ret = sec->ops->rsu_status(sec); in m10bmc_sec_progress_status()
341 static enum fw_upload_err rsu_check_idle(struct m10bmc_sec *sec) in rsu_check_idle() argument
343 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in rsu_check_idle()
347 ret = m10bmc_sys_read(sec->m10bmc, csr_map->doorbell, &doorbell); in rsu_check_idle()
352 log_error_regs(sec, doorbell); in rsu_check_idle()
373 static enum fw_upload_err rsu_update_init(struct m10bmc_sec *sec) in rsu_update_init() argument
375 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in rsu_update_init()
379 ret = m10bmc_sys_update_bits(sec->m10bmc, csr_map->doorbell, in rsu_update_init()
392 sec, &doorbell_reg, &progress, &status); in rsu_update_init()
395 log_error_regs(sec, doorbell_reg); in rsu_update_init()
402 dev_warn(sec->dev, "Excessive flash update count detected\n"); in rsu_update_init()
405 log_error_regs(sec, doorbell_reg); in rsu_update_init()
412 static enum fw_upload_err rsu_prog_ready(struct m10bmc_sec *sec) in rsu_prog_ready() argument
414 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in rsu_prog_ready()
419 ret = m10bmc_sys_read(sec->m10bmc, csr_map->doorbell, &doorbell); in rsu_prog_ready()
429 ret = m10bmc_sys_read(sec->m10bmc, csr_map->doorbell, &doorbell); in rsu_prog_ready()
436 log_error_regs(sec, doorbell); in rsu_prog_ready()
439 log_error_regs(sec, doorbell); in rsu_prog_ready()
446 static enum fw_upload_err rsu_send_data(struct m10bmc_sec *sec) in rsu_send_data() argument
448 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in rsu_send_data()
452 ret = m10bmc_sys_update_bits(sec->m10bmc, csr_map->doorbell, in rsu_send_data()
459 ret = regmap_read_poll_timeout(sec->m10bmc->regmap, in rsu_send_data()
467 log_error_regs(sec, doorbell_reg); in rsu_send_data()
473 ret = sec->ops->rsu_status(sec); in rsu_send_data()
479 log_error_regs(sec, doorbell_reg); in rsu_send_data()
486 static int rsu_check_complete(struct m10bmc_sec *sec, u32 *doorbell_reg) in rsu_check_complete() argument
490 if (m10bmc_sec_progress_status(sec, doorbell_reg, &progress, &status)) in rsu_check_complete()
505 static enum fw_upload_err rsu_cancel(struct m10bmc_sec *sec) in rsu_cancel() argument
507 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in rsu_cancel()
511 ret = m10bmc_sys_read(sec->m10bmc, csr_map->doorbell, &doorbell); in rsu_cancel()
518 ret = m10bmc_sys_update_bits(sec->m10bmc, csr_map->doorbell, in rsu_cancel()
531 struct m10bmc_sec *sec = fwl->dd_handle; in m10bmc_sec_prepare() local
534 sec->cancel_request = false; in m10bmc_sec_prepare()
539 if (sec->m10bmc->flash_bulk_ops) in m10bmc_sec_prepare()
540 if (sec->m10bmc->flash_bulk_ops->lock_write(sec->m10bmc)) in m10bmc_sec_prepare()
543 ret = rsu_check_idle(sec); in m10bmc_sec_prepare()
547 m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_SEC_UPDATE_PREPARE); in m10bmc_sec_prepare()
549 ret = rsu_update_init(sec); in m10bmc_sec_prepare()
553 ret = rsu_prog_ready(sec); in m10bmc_sec_prepare()
557 if (sec->cancel_request) { in m10bmc_sec_prepare()
558 ret = rsu_cancel(sec); in m10bmc_sec_prepare()
562 m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_SEC_UPDATE_WRITE); in m10bmc_sec_prepare()
567 m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_NORMAL); in m10bmc_sec_prepare()
570 if (sec->m10bmc->flash_bulk_ops) in m10bmc_sec_prepare()
571 sec->m10bmc->flash_bulk_ops->unlock_write(sec->m10bmc); in m10bmc_sec_prepare()
580 struct m10bmc_sec *sec = fwl->dd_handle; in m10bmc_sec_fw_write() local
581 const struct m10bmc_csr_map *csr_map = sec->m10bmc->info->csr_map; in m10bmc_sec_fw_write()
582 struct intel_m10bmc *m10bmc = sec->m10bmc; in m10bmc_sec_fw_write()
586 if (sec->cancel_request) in m10bmc_sec_fw_write()
587 return rsu_cancel(sec); in m10bmc_sec_fw_write()
593 log_error_regs(sec, doorbell); in m10bmc_sec_fw_write()
599 ret = m10bmc_sec_write(sec, data, offset, blk_size); in m10bmc_sec_fw_write()
609 struct m10bmc_sec *sec = fwl->dd_handle; in m10bmc_sec_poll_complete() local
614 if (sec->cancel_request) in m10bmc_sec_poll_complete()
615 return rsu_cancel(sec); in m10bmc_sec_poll_complete()
617 m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_SEC_UPDATE_PROGRAM); in m10bmc_sec_poll_complete()
619 result = rsu_send_data(sec); in m10bmc_sec_poll_complete()
626 ret = rsu_check_complete(sec, &doorbell); in m10bmc_sec_poll_complete()
630 log_error_regs(sec, doorbell); in m10bmc_sec_poll_complete()
635 log_error_regs(sec, doorbell); in m10bmc_sec_poll_complete()
651 struct m10bmc_sec *sec = fwl->dd_handle; in m10bmc_sec_cancel() local
653 sec->cancel_request = true; in m10bmc_sec_cancel()
658 struct m10bmc_sec *sec = fwl->dd_handle; in m10bmc_sec_cleanup() local
660 (void)rsu_cancel(sec); in m10bmc_sec_cleanup()
662 m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_NORMAL); in m10bmc_sec_cleanup()
664 if (sec->m10bmc->flash_bulk_ops) in m10bmc_sec_cleanup()
665 sec->m10bmc->flash_bulk_ops->unlock_write(sec->m10bmc); in m10bmc_sec_cleanup()
688 struct m10bmc_sec *sec; in m10bmc_sec_probe() local
693 sec = devm_kzalloc(&pdev->dev, sizeof(*sec), GFP_KERNEL); in m10bmc_sec_probe()
694 if (!sec) in m10bmc_sec_probe()
697 sec->dev = &pdev->dev; in m10bmc_sec_probe()
698 sec->m10bmc = dev_get_drvdata(pdev->dev.parent); in m10bmc_sec_probe()
699 sec->ops = (struct m10bmc_sec_ops *)platform_get_device_id(pdev)->driver_data; in m10bmc_sec_probe()
700 dev_set_drvdata(&pdev->dev, sec); in m10bmc_sec_probe()
702 ret = xa_alloc(&fw_upload_xa, &sec->fw_name_id, sec, in m10bmc_sec_probe()
708 sec->fw_name_id); in m10bmc_sec_probe()
709 sec->fw_name = kmemdup_nul(buf, len, GFP_KERNEL); in m10bmc_sec_probe()
710 if (!sec->fw_name) { in m10bmc_sec_probe()
715 fwl = firmware_upload_register(THIS_MODULE, sec->dev, sec->fw_name, in m10bmc_sec_probe()
716 &m10bmc_ops, sec); in m10bmc_sec_probe()
718 dev_err(sec->dev, "Firmware Upload driver failed to start\n"); in m10bmc_sec_probe()
723 sec->fwl = fwl; in m10bmc_sec_probe()
727 kfree(sec->fw_name); in m10bmc_sec_probe()
729 xa_erase(&fw_upload_xa, sec->fw_name_id); in m10bmc_sec_probe()
735 struct m10bmc_sec *sec = dev_get_drvdata(&pdev->dev); in m10bmc_sec_remove() local
737 firmware_upload_unregister(sec->fwl); in m10bmc_sec_remove()
738 kfree(sec->fw_name); in m10bmc_sec_remove()
739 xa_erase(&fw_upload_xa, sec->fw_name_id); in m10bmc_sec_remove()