[U-Boot] [PATCH] spi: mxc_spi: Fix chipselect with DM_SPI in SPL

Bernhard Messerklinger bernhard.messerklinger at br-automation.com
Mon Sep 3 10:32:01 UTC 2018


Since CONFIG_IS_ENABLED(DM_SPI) is not working in SPL because
CONFIG_SPL_DM_SPI is not defined we should go with #ifdef CONFIG_DM_SPI.

Signed-off-by: Bernhard Messerklinger <bernhard.messerklinger at br-automation.com>
---

 drivers/spi/mxc_spi.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index 0dccc38b82..bd31e79505 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -57,26 +57,30 @@ static inline struct mxc_spi_slave *to_mxc_spi_slave(struct spi_slave *slave)
 	return container_of(slave, struct mxc_spi_slave, slave);
 }
 
+#ifdef CONFIG_DM_SPI
 static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs)
 {
-	if (CONFIG_IS_ENABLED(DM_SPI)) {
-		dm_gpio_set_value(&mxcs->ss, 1);
-	} else {
-		if (mxcs->gpio > 0)
-			gpio_set_value(mxcs->gpio, mxcs->ss_pol);
-	}
+	dm_gpio_set_value(&mxcs->ss, 1);
 }
 
 static void mxc_spi_cs_deactivate(struct mxc_spi_slave *mxcs)
 {
-	if (CONFIG_IS_ENABLED(DM_SPI)) {
-		dm_gpio_set_value(&mxcs->ss, 0);
-	} else {
-		if (mxcs->gpio > 0)
-			gpio_set_value(mxcs->gpio, !(mxcs->ss_pol));
-	}
+	dm_gpio_set_value(&mxcs->ss, 0);
+}
+#else
+static void mxc_spi_cs_activate(struct mxc_spi_slave *mxcs)
+{
+	if (mxcs->gpio > 0)
+		gpio_set_value(mxcs->gpio, mxcs->ss_pol);
 }
 
+static void mxc_spi_cs_deactivate(struct mxc_spi_slave *mxcs)
+{
+	if (mxcs->gpio > 0)
+		gpio_set_value(mxcs->gpio, !(mxcs->ss_pol));
+}
+#endif
+
 u32 get_cspi_div(u32 div)
 {
 	int i;
-- 
2.18.0




More information about the U-Boot mailing list