Lines Matching refs:op

37 				       const struct spi_mem_op *op,  in spi_controller_dma_map_mem_op_data()  argument
42 if (!op->data.nbytes) in spi_controller_dma_map_mem_op_data()
45 if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx) in spi_controller_dma_map_mem_op_data()
47 else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx) in spi_controller_dma_map_mem_op_data()
55 return spi_map_buf(ctlr, dmadev, sgt, op->data.buf.in, op->data.nbytes, in spi_controller_dma_map_mem_op_data()
56 op->data.dir == SPI_MEM_DATA_IN ? in spi_controller_dma_map_mem_op_data()
83 const struct spi_mem_op *op, in spi_controller_dma_unmap_mem_op_data() argument
88 if (!op->data.nbytes) in spi_controller_dma_unmap_mem_op_data()
91 if (op->data.dir == SPI_MEM_DATA_OUT && ctlr->dma_tx) in spi_controller_dma_unmap_mem_op_data()
93 else if (op->data.dir == SPI_MEM_DATA_IN && ctlr->dma_rx) in spi_controller_dma_unmap_mem_op_data()
99 op->data.dir == SPI_MEM_DATA_IN ? in spi_controller_dma_unmap_mem_op_data()
143 const struct spi_mem_op *op) in spi_mem_check_buswidth() argument
145 if (spi_check_buswidth_req(mem, op->cmd.buswidth, true)) in spi_mem_check_buswidth()
148 if (op->addr.nbytes && in spi_mem_check_buswidth()
149 spi_check_buswidth_req(mem, op->addr.buswidth, true)) in spi_mem_check_buswidth()
152 if (op->dummy.nbytes && in spi_mem_check_buswidth()
153 spi_check_buswidth_req(mem, op->dummy.buswidth, true)) in spi_mem_check_buswidth()
156 if (op->data.dir != SPI_MEM_NO_DATA && in spi_mem_check_buswidth()
157 spi_check_buswidth_req(mem, op->data.buswidth, in spi_mem_check_buswidth()
158 op->data.dir == SPI_MEM_DATA_OUT)) in spi_mem_check_buswidth()
165 const struct spi_mem_op *op) in spi_mem_default_supports_op() argument
169 op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr; in spi_mem_default_supports_op()
175 if (op->cmd.nbytes != 2) in spi_mem_default_supports_op()
178 if (op->cmd.nbytes != 1) in spi_mem_default_supports_op()
182 if (op->data.ecc) { in spi_mem_default_supports_op()
187 return spi_mem_check_buswidth(mem, op); in spi_mem_default_supports_op()
199 static int spi_mem_check_op(const struct spi_mem_op *op) in spi_mem_check_op() argument
201 if (!op->cmd.buswidth || !op->cmd.nbytes) in spi_mem_check_op()
204 if ((op->addr.nbytes && !op->addr.buswidth) || in spi_mem_check_op()
205 (op->dummy.nbytes && !op->dummy.buswidth) || in spi_mem_check_op()
206 (op->data.nbytes && !op->data.buswidth)) in spi_mem_check_op()
209 if (!spi_mem_buswidth_is_valid(op->cmd.buswidth) || in spi_mem_check_op()
210 !spi_mem_buswidth_is_valid(op->addr.buswidth) || in spi_mem_check_op()
211 !spi_mem_buswidth_is_valid(op->dummy.buswidth) || in spi_mem_check_op()
212 !spi_mem_buswidth_is_valid(op->data.buswidth)) in spi_mem_check_op()
216 if (WARN_ON_ONCE(op->data.dir == SPI_MEM_DATA_IN && in spi_mem_check_op()
217 object_is_on_stack(op->data.buf.in))) in spi_mem_check_op()
220 if (WARN_ON_ONCE(op->data.dir == SPI_MEM_DATA_OUT && in spi_mem_check_op()
221 object_is_on_stack(op->data.buf.out))) in spi_mem_check_op()
228 const struct spi_mem_op *op) in spi_mem_internal_supports_op() argument
233 return ctlr->mem_ops->supports_op(mem, op); in spi_mem_internal_supports_op()
235 return spi_mem_default_supports_op(mem, op); in spi_mem_internal_supports_op()
253 bool spi_mem_supports_op(struct spi_mem *mem, const struct spi_mem_op *op) in spi_mem_supports_op() argument
255 if (spi_mem_check_op(op)) in spi_mem_supports_op()
258 return spi_mem_internal_supports_op(mem, op); in spi_mem_supports_op()
312 int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) in spi_mem_exec_op() argument
321 ret = spi_mem_check_op(op); in spi_mem_exec_op()
325 if (!spi_mem_internal_supports_op(mem, op)) in spi_mem_exec_op()
333 ret = ctlr->mem_ops->exec_op(mem, op); in spi_mem_exec_op()
346 tmpbufsize = op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes; in spi_mem_exec_op()
359 tmpbuf[0] = op->cmd.opcode; in spi_mem_exec_op()
361 xfers[xferpos].len = op->cmd.nbytes; in spi_mem_exec_op()
362 xfers[xferpos].tx_nbits = op->cmd.buswidth; in spi_mem_exec_op()
367 if (op->addr.nbytes) { in spi_mem_exec_op()
370 for (i = 0; i < op->addr.nbytes; i++) in spi_mem_exec_op()
371 tmpbuf[i + 1] = op->addr.val >> in spi_mem_exec_op()
372 (8 * (op->addr.nbytes - i - 1)); in spi_mem_exec_op()
375 xfers[xferpos].len = op->addr.nbytes; in spi_mem_exec_op()
376 xfers[xferpos].tx_nbits = op->addr.buswidth; in spi_mem_exec_op()
379 totalxferlen += op->addr.nbytes; in spi_mem_exec_op()
382 if (op->dummy.nbytes) { in spi_mem_exec_op()
383 memset(tmpbuf + op->addr.nbytes + 1, 0xff, op->dummy.nbytes); in spi_mem_exec_op()
384 xfers[xferpos].tx_buf = tmpbuf + op->addr.nbytes + 1; in spi_mem_exec_op()
385 xfers[xferpos].len = op->dummy.nbytes; in spi_mem_exec_op()
386 xfers[xferpos].tx_nbits = op->dummy.buswidth; in spi_mem_exec_op()
390 totalxferlen += op->dummy.nbytes; in spi_mem_exec_op()
393 if (op->data.nbytes) { in spi_mem_exec_op()
394 if (op->data.dir == SPI_MEM_DATA_IN) { in spi_mem_exec_op()
395 xfers[xferpos].rx_buf = op->data.buf.in; in spi_mem_exec_op()
396 xfers[xferpos].rx_nbits = op->data.buswidth; in spi_mem_exec_op()
398 xfers[xferpos].tx_buf = op->data.buf.out; in spi_mem_exec_op()
399 xfers[xferpos].tx_nbits = op->data.buswidth; in spi_mem_exec_op()
402 xfers[xferpos].len = op->data.nbytes; in spi_mem_exec_op()
405 totalxferlen += op->data.nbytes; in spi_mem_exec_op()
455 int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) in spi_mem_adjust_op_size() argument
461 return ctlr->mem_ops->adjust_op_size(mem, op); in spi_mem_adjust_op_size()
464 len = op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes; in spi_mem_adjust_op_size()
469 op->data.nbytes = min3((size_t)op->data.nbytes, in spi_mem_adjust_op_size()
473 if (!op->data.nbytes) in spi_mem_adjust_op_size()
484 struct spi_mem_op op = desc->info.op_tmpl; in spi_mem_no_dirmap_read() local
487 op.addr.val = desc->info.offset + offs; in spi_mem_no_dirmap_read()
488 op.data.buf.in = buf; in spi_mem_no_dirmap_read()
489 op.data.nbytes = len; in spi_mem_no_dirmap_read()
490 ret = spi_mem_adjust_op_size(desc->mem, &op); in spi_mem_no_dirmap_read()
494 ret = spi_mem_exec_op(desc->mem, &op); in spi_mem_no_dirmap_read()
498 return op.data.nbytes; in spi_mem_no_dirmap_read()
504 struct spi_mem_op op = desc->info.op_tmpl; in spi_mem_no_dirmap_write() local
507 op.addr.val = desc->info.offset + offs; in spi_mem_no_dirmap_write()
508 op.data.buf.out = buf; in spi_mem_no_dirmap_write()
509 op.data.nbytes = len; in spi_mem_no_dirmap_write()
510 ret = spi_mem_adjust_op_size(desc->mem, &op); in spi_mem_no_dirmap_write()
514 ret = spi_mem_exec_op(desc->mem, &op); in spi_mem_no_dirmap_write()
518 return op.data.nbytes; in spi_mem_no_dirmap_write()
761 const struct spi_mem_op *op, in spi_mem_read_status() argument
764 const u8 *bytes = (u8 *)op->data.buf.in; in spi_mem_read_status()
767 ret = spi_mem_exec_op(mem, op); in spi_mem_read_status()
771 if (op->data.nbytes > 1) in spi_mem_read_status()
796 const struct spi_mem_op *op, in spi_mem_poll_status() argument
807 if (op->data.nbytes < 1 || op->data.nbytes > 2 || in spi_mem_poll_status()
808 op->data.dir != SPI_MEM_DATA_IN) in spi_mem_poll_status()
816 ret = ctlr->mem_ops->poll_status(mem, op, mask, match, in spi_mem_poll_status()
824 if (!spi_mem_supports_op(mem, op)) in spi_mem_poll_status()
836 op, &status); in spi_mem_poll_status()