* [PATCH] spi: omap: support swapping D0/D1
@ 2014-05-15 6:11 Sascha Hauer
0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2014-05-15 6:11 UTC (permalink / raw)
To: barebox
From: Jan Luebbe <jlu@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@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
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-05-15 6:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15 6:11 [PATCH] spi: omap: support swapping D0/D1 Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox