1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright 2018-2019 NXP 4 * 5 * Brief CAAM Job Rings Hardware Abstration Layer header. 6 */ 7 #ifndef __CAAM_HAL_JR_H__ 8 #define __CAAM_HAL_JR_H__ 9 10 #include <caam_common.h> 11 12 /* 13 * Configures the Job Ring Owner and lock it. 14 * If the configuration is already locked, checks the configuration 15 * set and returns an error if value is not corresponding to the 16 * expected value. 17 * 18 * @ctrl_base Base address of the controller 19 * @jr_offset Job Ring offset to configure 20 * @owner Onwer ID to configure 21 */ 22 enum caam_status caam_hal_jr_setowner(vaddr_t ctrl_base, paddr_t jr_offset, 23 enum caam_jr_owner owner); 24 25 /* 26 * Resets the Job Ring to ensure that all pending jobs are completed 27 * and no other will be executed 28 * 29 * @baseaddr Job Ring Base address 30 */ 31 enum caam_status caam_hal_jr_reset(vaddr_t baseaddr); 32 33 /* 34 * Configures the Job Ring HW queues. 35 * 36 * @baseaddr Job Ring Base Address 37 * @nbjobs Number of job rings supported 38 * @inrings physical address of the JR input queue 39 * @outrings physical address of the JR output queue 40 */ 41 void caam_hal_jr_config(vaddr_t baseaddr, uint8_t nbjobs, uint64_t inrings, 42 uint64_t outrings); 43 44 /* 45 * Returns the number of slots available in the input job ring 46 * 47 * @baseaddr Job Ring Base address 48 */ 49 uint32_t caam_hal_jr_read_nbslot_available(vaddr_t baseaddr); 50 51 /* 52 * Indicates to HW that a new job is available 53 * 54 * @baseaddr Job Ring Base Address 55 */ 56 void caam_hal_jr_add_newjob(vaddr_t baseaddr); 57 58 /* 59 * Returns the number of job completed and present in the output ring slots 60 * 61 * @baseaddr Job Ring Base Address 62 */ 63 uint32_t caam_hal_jr_get_nbjob_done(vaddr_t baseaddr); 64 65 /* 66 * Removes a job from the job ring output queue 67 * 68 * @baseaddr Job Ring Base Address 69 */ 70 void caam_hal_jr_del_job(vaddr_t baseaddr); 71 72 /* 73 * Disable and acknwoledge the Job Ring interrupt 74 * 75 * @baseaddr Job Ring Base Address 76 */ 77 void caam_hal_jr_disable_itr(vaddr_t baseaddr); 78 79 /* 80 * Enable the Job Ring interrupt 81 * 82 * @baseaddr Job Ring Base Address 83 */ 84 void caam_hal_jr_enable_itr(vaddr_t baseaddr); 85 86 /* 87 * If an interrupt is pending, acknowledges it and returns true. 88 * 89 * @baseaddr Job Ring Base Address 90 */ 91 bool caam_hal_jr_check_ack_itr(vaddr_t baseaddr); 92 93 /* 94 * Halt the Job Ring processing. Stop fetching input queue and wait 95 * all running jobs normal completion. 96 * 97 * @baseaddr Job Ring Base Address 98 */ 99 enum caam_status caam_hal_jr_halt(vaddr_t baseaddr); 100 101 /* 102 * Wait all Input queue Job Ring processing. 103 * 104 * @baseaddr Job Ring Base Address 105 */ 106 enum caam_status caam_hal_jr_flush(vaddr_t baseaddr); 107 108 /* 109 * Resume the Job Ring processing. 110 * 111 * @baseaddr Job Ring Base Address 112 */ 113 void caam_hal_jr_resume(vaddr_t baseaddr); 114 115 /* 116 * Returns the next entry free in the JR input queue. 117 * The HW increments register by 4. Convert it to a software index number 118 * 119 * @baseaddr CAAM JR Base Address 120 */ 121 uint8_t caam_hal_jr_input_index(vaddr_t baseaddr); 122 123 /* 124 * Returns the next entry to read from the JR output queue. 125 * The HW increments register by 8. Convert it to a software index number 126 * 127 * @baseaddr CAAM JR Base Address 128 */ 129 uint8_t caam_hal_jr_output_index(vaddr_t baseaddr); 130 131 /* 132 * Let the JR prepare data that need backup 133 * 134 * @ctrl_base CAAM JR Base Address 135 * @jr_offset Job Ring offset to prepare backup for 136 */ 137 void caam_hal_jr_prepare_backup(vaddr_t ctrl_base, paddr_t jr_offset); 138 139 #endif /* __CAAM_HAL_JR_H__ */ 140