mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-30 08:30:50 +09:00
spi: spi-mem: Claim SPI bus before spi mem access
It is necessary to call spi_claim_bus() before starting any SPI transactions and this restriction would also apply when calling spi-mem operations. Therefore claim and release bus before requesting transfer via exec_op. Signed-off-by: Vignesh R <vigneshr@ti.com> Tested-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Tested-by: Stefan Roese <sr@denx.de> Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com> Reviewed-by: Jagan Teki <jagan@openedev.com> Tested-by: Jagan Teki <jagan@amarulasolutions.com> #zynq-microzed
This commit is contained in:
parent
12563f768e
commit
76094485e4
@ -210,6 +210,10 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
|
|||||||
if (!spi_mem_supports_op(slave, op))
|
if (!spi_mem_supports_op(slave, op))
|
||||||
return -ENOTSUPP;
|
return -ENOTSUPP;
|
||||||
|
|
||||||
|
ret = spi_claim_bus(slave);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
if (ops->mem_ops) {
|
if (ops->mem_ops) {
|
||||||
#ifndef __UBOOT__
|
#ifndef __UBOOT__
|
||||||
/*
|
/*
|
||||||
@ -232,6 +236,7 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
|
|||||||
mutex_lock(&ctlr->io_mutex);
|
mutex_lock(&ctlr->io_mutex);
|
||||||
#endif
|
#endif
|
||||||
ret = ops->mem_ops->exec_op(slave, op);
|
ret = ops->mem_ops->exec_op(slave, op);
|
||||||
|
|
||||||
#ifndef __UBOOT__
|
#ifndef __UBOOT__
|
||||||
mutex_unlock(&ctlr->io_mutex);
|
mutex_unlock(&ctlr->io_mutex);
|
||||||
mutex_unlock(&ctlr->bus_lock_mutex);
|
mutex_unlock(&ctlr->bus_lock_mutex);
|
||||||
@ -245,9 +250,11 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
|
|||||||
* read path) and expect the core to use the regular SPI
|
* read path) and expect the core to use the regular SPI
|
||||||
* interface in other cases.
|
* interface in other cases.
|
||||||
*/
|
*/
|
||||||
if (!ret || ret != -ENOTSUPP)
|
if (!ret || ret != -ENOTSUPP) {
|
||||||
|
spi_release_bus(slave);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef __UBOOT__
|
#ifndef __UBOOT__
|
||||||
tmpbufsize = sizeof(op->cmd.opcode) + op->addr.nbytes +
|
tmpbufsize = sizeof(op->cmd.opcode) + op->addr.nbytes +
|
||||||
@ -333,10 +340,6 @@ int spi_mem_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
|
|||||||
op_len = sizeof(op->cmd.opcode) + op->addr.nbytes + op->dummy.nbytes;
|
op_len = sizeof(op->cmd.opcode) + op->addr.nbytes + op->dummy.nbytes;
|
||||||
op_buf = calloc(1, op_len);
|
op_buf = calloc(1, op_len);
|
||||||
|
|
||||||
ret = spi_claim_bus(slave);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
op_buf[pos++] = op->cmd.opcode;
|
op_buf[pos++] = op->cmd.opcode;
|
||||||
|
|
||||||
if (op->addr.nbytes) {
|
if (op->addr.nbytes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user