]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spi: zynq_qspi: Add support for zynq_qspi_mem_exec_op
authorAshok Reddy Soma <ashok.reddy.soma@xilinx.com>
Fri, 15 Jul 2022 14:01:18 +0000 (19:31 +0530)
committerMichal Simek <michal.simek@amd.com>
Tue, 26 Jul 2022 07:34:21 +0000 (09:34 +0200)
Add support_ops function zynq_qspi_mem_exec_op to check controller
supported operations by spi-mem framework. Current default support ops
function does not allow dummy buswidth no more than 1, unless we are
using buswidth is 4 for TX.

Signed-off-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
Link: https://lore.kernel.org/r/1657893679-20039-4-git-send-email-ashok.reddy.soma@xilinx.com
Signed-off-by: Michal Simek <michal.simek@amd.com>
drivers/spi/zynq_qspi.c

index b138c3c38a1c8160e840829774ad0ca7fc7dacfd..52db7b3f219330e6eefb5d08995034280eee4ec0 100644 (file)
@@ -736,8 +736,50 @@ static int zynq_qspi_exec_op(struct spi_slave *slave,
        return 0;
 }
 
+static int zynq_qspi_check_buswidth(struct spi_slave *slave, u8 width)
+{
+       u32 mode = slave->mode;
+
+       switch (width) {
+       case 1:
+               return 0;
+       case 2:
+               if (mode & SPI_RX_DUAL)
+                       return 0;
+               break;
+       case 4:
+               if (mode & SPI_RX_QUAD)
+                       return 0;
+               break;
+       }
+
+       return -EOPNOTSUPP;
+}
+
+bool zynq_qspi_mem_exec_op(struct spi_slave *slave,
+                          const struct spi_mem_op *op)
+{
+       if (zynq_qspi_check_buswidth(slave, op->cmd.buswidth))
+               return false;
+
+       if (op->addr.nbytes &&
+           zynq_qspi_check_buswidth(slave, op->addr.buswidth))
+               return false;
+
+       if (op->dummy.nbytes &&
+           zynq_qspi_check_buswidth(slave, op->dummy.buswidth))
+               return false;
+
+       if (op->data.dir != SPI_MEM_NO_DATA &&
+           zynq_qspi_check_buswidth(slave, op->data.buswidth))
+               return false;
+
+       return true;
+}
+
 static const struct spi_controller_mem_ops zynq_qspi_mem_ops = {
        .exec_op = zynq_qspi_exec_op,
+       .supports_op = zynq_qspi_mem_exec_op,
 };
 
 static const struct dm_spi_ops zynq_qspi_ops = {