Lines Matching full:mem
11 #include <linux/spi/spi-mem.h>
102 static int spi_check_buswidth_req(struct spi_mem *mem, u8 buswidth, bool tx) in spi_check_buswidth_req() argument
104 u32 mode = mem->spi->mode; in spi_check_buswidth_req()
140 bool spi_mem_default_supports_op(struct spi_mem *mem, in spi_mem_default_supports_op() argument
143 if (spi_check_buswidth_req(mem, op->cmd.buswidth, true)) in spi_mem_default_supports_op()
147 spi_check_buswidth_req(mem, op->addr.buswidth, true)) in spi_mem_default_supports_op()
151 spi_check_buswidth_req(mem, op->dummy.buswidth, true)) in spi_mem_default_supports_op()
155 spi_check_buswidth_req(mem, op->data.buswidth, in spi_mem_default_supports_op()
196 static bool spi_mem_internal_supports_op(struct spi_mem *mem, in spi_mem_internal_supports_op() argument
199 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_internal_supports_op()
202 return ctlr->mem_ops->supports_op(mem, op); in spi_mem_internal_supports_op()
204 return spi_mem_default_supports_op(mem, op); in spi_mem_internal_supports_op()
210 * @mem: the SPI memory
222 bool spi_mem_supports_op(struct spi_mem *mem, const struct spi_mem_op *op) in spi_mem_supports_op() argument
227 return spi_mem_internal_supports_op(mem, op); in spi_mem_supports_op()
231 static int spi_mem_access_start(struct spi_mem *mem) in spi_mem_access_start() argument
233 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_access_start()
258 static void spi_mem_access_end(struct spi_mem *mem) in spi_mem_access_end() argument
260 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_access_end()
271 * @mem: the SPI memory
281 int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) in spi_mem_exec_op() argument
284 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_exec_op()
294 if (!spi_mem_internal_supports_op(mem, op)) in spi_mem_exec_op()
297 if (ctlr->mem_ops && !mem->spi->cs_gpiod) { in spi_mem_exec_op()
298 ret = spi_mem_access_start(mem); in spi_mem_exec_op()
302 ret = ctlr->mem_ops->exec_op(mem, op); in spi_mem_exec_op()
304 spi_mem_access_end(mem); in spi_mem_exec_op()
376 ret = spi_sync(mem->spi, &msg); in spi_mem_exec_op()
391 * spi_mem_get_name() - Return the SPI mem device name to be used by the
393 * @mem: the SPI memory
395 * This function allows SPI mem users to retrieve the SPI mem device name.
400 * by the SPI mem user
402 const char *spi_mem_get_name(struct spi_mem *mem) in spi_mem_get_name() argument
404 return mem->name; in spi_mem_get_name()
409 * spi_mem_adjust_op_size() - Adjust the data size of a SPI mem operation to
411 * @mem: the SPI memory
416 * optimized accesses. This function allows SPI mem drivers to split a single
423 int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) in spi_mem_adjust_op_size() argument
425 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_adjust_op_size()
429 return ctlr->mem_ops->adjust_op_size(mem, op); in spi_mem_adjust_op_size()
434 if (len > spi_max_transfer_size(mem->spi)) in spi_mem_adjust_op_size()
438 spi_max_transfer_size(mem->spi), in spi_mem_adjust_op_size()
439 spi_max_message_size(mem->spi) - in spi_mem_adjust_op_size()
458 ret = spi_mem_adjust_op_size(desc->mem, &op); in spi_mem_no_dirmap_read()
462 ret = spi_mem_exec_op(desc->mem, &op); in spi_mem_no_dirmap_read()
478 ret = spi_mem_adjust_op_size(desc->mem, &op); in spi_mem_no_dirmap_write()
482 ret = spi_mem_exec_op(desc->mem, &op); in spi_mem_no_dirmap_write()
491 * @mem: SPI mem device this direct mapping should be created for
503 spi_mem_dirmap_create(struct spi_mem *mem, in spi_mem_dirmap_create() argument
506 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_dirmap_create()
522 desc->mem = mem; in spi_mem_dirmap_create()
529 if (!spi_mem_supports_op(desc->mem, &desc->info.op_tmpl)) in spi_mem_dirmap_create()
553 struct spi_controller *ctlr = desc->mem->spi->controller; in spi_mem_dirmap_destroy()
573 * @mem: SPI mem device this direct mapping should be created for
582 devm_spi_mem_dirmap_create(struct device *dev, struct spi_mem *mem, in devm_spi_mem_dirmap_create() argument
592 desc = spi_mem_dirmap_create(mem, info); in devm_spi_mem_dirmap_create()
650 struct spi_controller *ctlr = desc->mem->spi->controller; in spi_mem_dirmap_read()
662 ret = spi_mem_access_start(desc->mem); in spi_mem_dirmap_read()
668 spi_mem_access_end(desc->mem); in spi_mem_dirmap_read()
696 struct spi_controller *ctlr = desc->mem->spi->controller; in spi_mem_dirmap_write()
708 ret = spi_mem_access_start(desc->mem); in spi_mem_dirmap_write()
714 spi_mem_access_end(desc->mem); in spi_mem_dirmap_write()
732 struct spi_mem *mem; in spi_mem_probe() local
734 mem = devm_kzalloc(&spi->dev, sizeof(*mem), GFP_KERNEL); in spi_mem_probe()
735 if (!mem) in spi_mem_probe()
738 mem->spi = spi; in spi_mem_probe()
741 mem->name = ctlr->mem_ops->get_name(mem); in spi_mem_probe()
743 mem->name = dev_name(&spi->dev); in spi_mem_probe()
745 if (IS_ERR_OR_NULL(mem->name)) in spi_mem_probe()
746 return PTR_ERR(mem->name); in spi_mem_probe()
748 spi_set_drvdata(spi, mem); in spi_mem_probe()
750 return memdrv->probe(mem); in spi_mem_probe()
756 struct spi_mem *mem = spi_get_drvdata(spi); in spi_mem_remove() local
759 return memdrv->remove(mem); in spi_mem_remove()
767 struct spi_mem *mem = spi_get_drvdata(spi); in spi_mem_shutdown() local
770 memdrv->shutdown(mem); in spi_mem_shutdown()