[U-Boot] [RFC 4/5] sf: fsl_qspi: Add support of fsl_qspi_set_mode

Prabhakar Kushwaha prabhakar.kushwaha at nxp.com
Mon Dec 11 05:57:35 UTC 2017


SPI bus provide support dual and quad wire data transfers for tx and
rx. This information is parsed from device tree and passed to slave
device via set_mode of dm_spi_ops.

Implement set_mode i.e. fsl_qspi_set_mode to store mode information
in fsl_qspi_priv structure.

Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha at nxp.com>
---
 drivers/spi/fsl_qspi.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/fsl_qspi.c b/drivers/spi/fsl_qspi.c
index 0f3f7d9..7ec222a 100644
--- a/drivers/spi/fsl_qspi.c
+++ b/drivers/spi/fsl_qspi.c
@@ -120,6 +120,7 @@ struct fsl_qspi_platdata {
  * @cur_amba_base: Base address of QSPI memory mapping of current CS
  * @flash_num: Number of active slave devices
  * @num_chipselect: Number of QSPI chipselect signals
+ * @mode: I/O lines
  * @regs: Point to QSPI register structure for I/O access
  */
 struct fsl_qspi_priv {
@@ -133,6 +134,7 @@ struct fsl_qspi_priv {
 	u32 cur_amba_base;
 	u32 flash_num;
 	u32 num_chipselect;
+	u32 mode;
 	struct fsl_qspi_regs *regs;
 };
 
@@ -1212,7 +1214,33 @@ static int fsl_qspi_set_speed(struct udevice *bus, uint speed)
 
 static int fsl_qspi_set_mode(struct udevice *bus, uint mode)
 {
-	/* Nothing to do */
+	struct fsl_qspi_priv *priv = dev_get_priv(bus);
+
+	if (mode & SPI_RX_QUAD)
+		priv->mode |= SPI_RX_QUAD;
+	else if (mode & SPI_RX_DUAL)
+		priv->mode |= SPI_RX_DUAL;
+	else
+		priv->mode &= ~(SPI_RX_QUAD | SPI_RX_DUAL);
+
+	priv->mode &= ~(SPI_TX_QUAD | SPI_TX_DUAL);
+
+	debug("%s:  mode=%d rx: ", __func__, mode);
+
+	if (mode & SPI_RX_QUAD)
+		debug("quad, tx: ");
+	else if (mode & SPI_RX_DUAL)
+		debug("dual, tx: ");
+	else
+		debug("single, tx: ");
+
+	if (mode & SPI_TX_QUAD)
+		debug("quad\n");
+	else if (mode & SPI_TX_DUAL)
+		debug("dual\n");
+	else
+		debug("single\n");
+
 	return 0;
 }
 
-- 
2.7.4



More information about the U-Boot mailing list