[PATCH] spi: omap: support swapping D0/D1
Sascha Hauer
s.hauer at pengutronix.de
Wed May 14 23:11:10 PDT 2014
From: Jan Luebbe <jlu at pengutronix.de>
The OMAP SPI core allows swapping MISO/MOSI and some boards are
wired up that way, so add a property to swap the lines.
Signed-off-by: Jan Luebbe <jlu at pengutronix.de>
---
drivers/spi/omap3_spi.c | 24 ++++++++++++++++++++++--
drivers/spi/omap3_spi.h | 1 +
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index 073a98f..c62288b 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -106,8 +106,15 @@ int spi_claim_bus(struct spi_device *spi)
/* standard 4-wire master mode: SCK, MOSI/out, MISO/in, nCS
* REVISIT: this controller could support SPI_3WIRE mode.
*/
- conf &= ~(OMAP3_MCSPI_CHCONF_IS|OMAP3_MCSPI_CHCONF_DPE1);
- conf |= OMAP3_MCSPI_CHCONF_DPE0;
+ if (omap3_master->swap_miso_mosi) {
+ /* swapped */
+ conf |= (OMAP3_MCSPI_CHCONF_IS | OMAP3_MCSPI_CHCONF_DPE1);
+ conf &= ~OMAP3_MCSPI_CHCONF_DPE0;
+ } else {
+ /* bootloader default */
+ conf &= ~(OMAP3_MCSPI_CHCONF_IS | OMAP3_MCSPI_CHCONF_DPE1);
+ conf |= OMAP3_MCSPI_CHCONF_DPE0;
+ }
/* wordlength */
conf &= ~OMAP3_MCSPI_CHCONF_WL_MASK;
@@ -343,6 +350,17 @@ static int omap3_spi_setup(struct spi_device *spi)
return 0;
}
+static int omap3_spi_probe_dt(struct device_d *dev, struct omap3_spi_master *omap3_master)
+{
+ if (!IS_ENABLED(CONFIG_OFDEVICE) || !dev->device_node)
+ return -ENODEV;
+
+ if (of_property_read_bool(dev->device_node, "ti,pindir-d0-out-d1-in"))
+ omap3_master->swap_miso_mosi = 1;
+
+ return 0;
+}
+
static int omap3_spi_probe(struct device_d *dev)
{
struct spi_master *master;
@@ -356,6 +374,8 @@ static int omap3_spi_probe(struct device_d *dev)
omap3_master = xzalloc(sizeof(*omap3_master));
+ omap3_spi_probe_dt(dev, omap3_master);
+
master = &omap3_master->master;
master->dev = dev;
diff --git a/drivers/spi/omap3_spi.h b/drivers/spi/omap3_spi.h
index ce4a29b..6fd6bda 100644
--- a/drivers/spi/omap3_spi.h
+++ b/drivers/spi/omap3_spi.h
@@ -93,6 +93,7 @@ struct omap3_spi_master {
* offset of 0x100 between start of register space
* and registers
*/
+ int swap_miso_mosi;
};
#endif /* _OMAP3_SPI_H_ */
--
2.0.0.rc0
More information about the barebox
mailing list