• Home
  • Raw
  • Download

Lines Matching refs:mem

104 static int spi_check_buswidth_req(struct spi_mem *mem, u8 buswidth, bool tx)  in spi_check_buswidth_req()  argument
106 u32 mode = mem->spi->mode; in spi_check_buswidth_req()
142 static bool spi_mem_check_buswidth(struct spi_mem *mem, in spi_mem_check_buswidth() argument
145 if (spi_check_buswidth_req(mem, op->cmd.buswidth, true)) in spi_mem_check_buswidth()
149 spi_check_buswidth_req(mem, op->addr.buswidth, true)) in spi_mem_check_buswidth()
153 spi_check_buswidth_req(mem, op->dummy.buswidth, true)) in spi_mem_check_buswidth()
157 spi_check_buswidth_req(mem, op->data.buswidth, in spi_mem_check_buswidth()
164 bool spi_mem_default_supports_op(struct spi_mem *mem, in spi_mem_default_supports_op() argument
167 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_default_supports_op()
187 return spi_mem_check_buswidth(mem, op); in spi_mem_default_supports_op()
227 static bool spi_mem_internal_supports_op(struct spi_mem *mem, in spi_mem_internal_supports_op() argument
230 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_internal_supports_op()
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
258 return spi_mem_internal_supports_op(mem, op); in spi_mem_supports_op()
262 static int spi_mem_access_start(struct spi_mem *mem) in spi_mem_access_start() argument
264 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_access_start()
289 static void spi_mem_access_end(struct spi_mem *mem) in spi_mem_access_end() argument
291 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_access_end()
312 int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) in spi_mem_exec_op() argument
315 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_exec_op()
325 if (!spi_mem_internal_supports_op(mem, op)) in spi_mem_exec_op()
328 if (ctlr->mem_ops && !mem->spi->cs_gpiod) { in spi_mem_exec_op()
329 ret = spi_mem_access_start(mem); in spi_mem_exec_op()
333 ret = ctlr->mem_ops->exec_op(mem, op); in spi_mem_exec_op()
335 spi_mem_access_end(mem); in spi_mem_exec_op()
408 ret = spi_sync(mem->spi, &msg); in spi_mem_exec_op()
434 const char *spi_mem_get_name(struct spi_mem *mem) in spi_mem_get_name() argument
436 return mem->name; in spi_mem_get_name()
455 int spi_mem_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) in spi_mem_adjust_op_size() argument
457 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_adjust_op_size()
461 return ctlr->mem_ops->adjust_op_size(mem, op); in spi_mem_adjust_op_size()
466 if (len > spi_max_transfer_size(mem->spi)) in spi_mem_adjust_op_size()
470 spi_max_transfer_size(mem->spi), in spi_mem_adjust_op_size()
471 spi_max_message_size(mem->spi) - in spi_mem_adjust_op_size()
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()
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()
535 spi_mem_dirmap_create(struct spi_mem *mem, in spi_mem_dirmap_create() argument
538 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_dirmap_create()
554 desc->mem = mem; in spi_mem_dirmap_create()
561 if (!spi_mem_supports_op(desc->mem, &desc->info.op_tmpl)) in spi_mem_dirmap_create()
585 struct spi_controller *ctlr = desc->mem->spi->controller; in spi_mem_dirmap_destroy()
614 devm_spi_mem_dirmap_create(struct device *dev, struct spi_mem *mem, in devm_spi_mem_dirmap_create() argument
624 desc = spi_mem_dirmap_create(mem, info); in devm_spi_mem_dirmap_create()
682 struct spi_controller *ctlr = desc->mem->spi->controller; in spi_mem_dirmap_read()
694 ret = spi_mem_access_start(desc->mem); in spi_mem_dirmap_read()
700 spi_mem_access_end(desc->mem); in spi_mem_dirmap_read()
728 struct spi_controller *ctlr = desc->mem->spi->controller; in spi_mem_dirmap_write()
740 ret = spi_mem_access_start(desc->mem); in spi_mem_dirmap_write()
746 spi_mem_access_end(desc->mem); in spi_mem_dirmap_write()
760 static int spi_mem_read_status(struct spi_mem *mem, in spi_mem_read_status() argument
767 ret = spi_mem_exec_op(mem, op); in spi_mem_read_status()
795 int spi_mem_poll_status(struct spi_mem *mem, in spi_mem_poll_status() argument
802 struct spi_controller *ctlr = mem->spi->controller; in spi_mem_poll_status()
811 if (ctlr->mem_ops && ctlr->mem_ops->poll_status && !mem->spi->cs_gpiod) { in spi_mem_poll_status()
812 ret = spi_mem_access_start(mem); in spi_mem_poll_status()
816 ret = ctlr->mem_ops->poll_status(mem, op, mask, match, in spi_mem_poll_status()
820 spi_mem_access_end(mem); in spi_mem_poll_status()
824 if (!spi_mem_supports_op(mem, op)) in spi_mem_poll_status()
835 polling_delay_us, timeout_ms * 1000, false, mem, in spi_mem_poll_status()
849 struct spi_mem *mem; in spi_mem_probe() local
851 mem = devm_kzalloc(&spi->dev, sizeof(*mem), GFP_KERNEL); in spi_mem_probe()
852 if (!mem) in spi_mem_probe()
855 mem->spi = spi; in spi_mem_probe()
858 mem->name = ctlr->mem_ops->get_name(mem); in spi_mem_probe()
860 mem->name = dev_name(&spi->dev); in spi_mem_probe()
862 if (IS_ERR_OR_NULL(mem->name)) in spi_mem_probe()
863 return PTR_ERR_OR_ZERO(mem->name); in spi_mem_probe()
865 spi_set_drvdata(spi, mem); in spi_mem_probe()
867 return memdrv->probe(mem); in spi_mem_probe()
873 struct spi_mem *mem = spi_get_drvdata(spi); in spi_mem_remove() local
876 memdrv->remove(mem); in spi_mem_remove()
882 struct spi_mem *mem = spi_get_drvdata(spi); in spi_mem_shutdown() local
885 memdrv->shutdown(mem); in spi_mem_shutdown()