• Home
  • Raw
  • Download

Lines Matching refs:tee

24 static int tee_alloc_ring(struct psp_tee_device *tee, int ring_size)  in tee_alloc_ring()  argument
26 struct ring_buf_manager *rb_mgr = &tee->rb_mgr; in tee_alloc_ring()
48 static void tee_free_ring(struct psp_tee_device *tee) in tee_free_ring() argument
50 struct ring_buf_manager *rb_mgr = &tee->rb_mgr; in tee_free_ring()
64 static int tee_wait_cmd_poll(struct psp_tee_device *tee, unsigned int timeout, in tee_wait_cmd_poll() argument
71 *reg = ioread32(tee->io_regs + tee->vdata->cmdresp_reg); in tee_wait_cmd_poll()
78 dev_err(tee->dev, "tee: command timed out, disabling PSP\n"); in tee_wait_cmd_poll()
85 struct tee_init_ring_cmd *tee_alloc_cmd_buffer(struct psp_tee_device *tee) in tee_alloc_cmd_buffer() argument
93 cmd->hi_addr = upper_32_bits(tee->rb_mgr.ring_pa); in tee_alloc_cmd_buffer()
94 cmd->low_addr = lower_32_bits(tee->rb_mgr.ring_pa); in tee_alloc_cmd_buffer()
95 cmd->size = tee->rb_mgr.ring_size; in tee_alloc_cmd_buffer()
97 dev_dbg(tee->dev, "tee: ring address: high = 0x%x low = 0x%x size = %u\n", in tee_alloc_cmd_buffer()
108 static int tee_init_ring(struct psp_tee_device *tee) in tee_init_ring() argument
118 ret = tee_alloc_ring(tee, ring_size); in tee_init_ring()
120 dev_err(tee->dev, "tee: ring allocation failed %d\n", ret); in tee_init_ring()
124 tee->rb_mgr.wptr = 0; in tee_init_ring()
126 cmd = tee_alloc_cmd_buffer(tee); in tee_init_ring()
128 tee_free_ring(tee); in tee_init_ring()
139 tee->io_regs + tee->vdata->cmdbuff_addr_lo_reg); in tee_init_ring()
141 tee->io_regs + tee->vdata->cmdbuff_addr_hi_reg); in tee_init_ring()
143 tee->io_regs + tee->vdata->cmdresp_reg); in tee_init_ring()
145 ret = tee_wait_cmd_poll(tee, TEE_DEFAULT_TIMEOUT, &reg); in tee_init_ring()
147 dev_err(tee->dev, "tee: ring init command timed out\n"); in tee_init_ring()
148 tee_free_ring(tee); in tee_init_ring()
153 dev_err(tee->dev, "tee: ring init command failed (%#010x)\n", in tee_init_ring()
155 tee_free_ring(tee); in tee_init_ring()
165 static void tee_destroy_ring(struct psp_tee_device *tee) in tee_destroy_ring() argument
170 if (!tee->rb_mgr.ring_start) in tee_destroy_ring()
177 tee->io_regs + tee->vdata->cmdresp_reg); in tee_destroy_ring()
179 ret = tee_wait_cmd_poll(tee, TEE_DEFAULT_TIMEOUT, &reg); in tee_destroy_ring()
181 dev_err(tee->dev, "tee: ring destroy command timed out\n"); in tee_destroy_ring()
183 dev_err(tee->dev, "tee: ring destroy command failed (%#010x)\n", in tee_destroy_ring()
188 tee_free_ring(tee); in tee_destroy_ring()
194 struct psp_tee_device *tee; in tee_dev_init() local
198 tee = devm_kzalloc(dev, sizeof(*tee), GFP_KERNEL); in tee_dev_init()
199 if (!tee) in tee_dev_init()
202 psp->tee_data = tee; in tee_dev_init()
204 tee->dev = dev; in tee_dev_init()
205 tee->psp = psp; in tee_dev_init()
207 tee->io_regs = psp->io_regs; in tee_dev_init()
209 tee->vdata = (struct tee_vdata *)psp->vdata->tee; in tee_dev_init()
210 if (!tee->vdata) { in tee_dev_init()
216 ret = tee_init_ring(tee); in tee_dev_init()
236 struct psp_tee_device *tee = psp->tee_data; in tee_dev_destroy() local
238 if (!tee) in tee_dev_destroy()
241 tee_destroy_ring(tee); in tee_dev_destroy()
244 static int tee_submit_cmd(struct psp_tee_device *tee, enum tee_cmd_id cmd_id, in tee_submit_cmd() argument
253 mutex_lock(&tee->rb_mgr.mutex); in tee_submit_cmd()
259 (tee->rb_mgr.ring_start + tee->rb_mgr.wptr); in tee_submit_cmd()
261 rptr = ioread32(tee->io_regs + tee->vdata->ring_rptr_reg); in tee_submit_cmd()
266 if (!(tee->rb_mgr.wptr + sizeof(struct tee_ring_cmd) == rptr || in tee_submit_cmd()
270 dev_dbg(tee->dev, "tee: ring buffer full. rptr = %u wptr = %u\n", in tee_submit_cmd()
271 rptr, tee->rb_mgr.wptr); in tee_submit_cmd()
274 mutex_unlock(&tee->rb_mgr.mutex); in tee_submit_cmd()
276 mutex_lock(&tee->rb_mgr.mutex); in tee_submit_cmd()
281 (tee->rb_mgr.wptr + sizeof(struct tee_ring_cmd) == rptr || in tee_submit_cmd()
283 dev_err(tee->dev, "tee: ring buffer full. rptr = %u wptr = %u response flag %u\n", in tee_submit_cmd()
284 rptr, tee->rb_mgr.wptr, cmd->flag); in tee_submit_cmd()
307 tee->rb_mgr.wptr += sizeof(struct tee_ring_cmd); in tee_submit_cmd()
308 if (tee->rb_mgr.wptr >= tee->rb_mgr.ring_size) in tee_submit_cmd()
309 tee->rb_mgr.wptr = 0; in tee_submit_cmd()
312 iowrite32(tee->rb_mgr.wptr, tee->io_regs + tee->vdata->ring_wptr_reg); in tee_submit_cmd()
320 mutex_unlock(&tee->rb_mgr.mutex); in tee_submit_cmd()
325 static int tee_wait_cmd_completion(struct psp_tee_device *tee, in tee_wait_cmd_completion() argument
339 dev_err(tee->dev, "tee: command 0x%x timed out, disabling PSP\n", in tee_wait_cmd_completion()
351 struct psp_tee_device *tee; in psp_tee_process_cmd() local
366 tee = psp->tee_data; in psp_tee_process_cmd()
368 ret = tee_submit_cmd(tee, cmd_id, buf, len, &resp); in psp_tee_process_cmd()
372 ret = tee_wait_cmd_completion(tee, resp, TEE_DEFAULT_TIMEOUT); in psp_tee_process_cmd()