From c4f2279e2fdb7fa44771f92ecc89f12ef8d2bcb0 Mon Sep 17 00:00:00 2001
From: Imre Deak <imre.deak@solidboot.com>
Date: Mon, 19 Jun 2006 20:31:54 +0300
Subject: [PATCH] ARM: OMAP2: McSPI: add debugging for setup and transfer
 functions

Sprinkle dev_dbg's wrapped with VERBOSE to several functions to aid
debugging.

Signed-off-by: Imre Deak <imre.deak@solidboot.com>
Signed-off-by: Juha Yrjola <juha.yrjola@solidboot.com>
---
 drivers/spi/omap2_mcspi.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index 336f5c58a5..2c7cd54fa8 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -210,6 +210,10 @@ static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer)
 		while (c--) {
 			if (tx != NULL) {
 				while (!(__raw_readl(chstat_reg) & OMAP2_MCSPI_CHSTAT_TXS));
+#ifdef VERBOSE
+				dev_dbg(&spi->dev, "write-%d %02x\n",
+						word_len, *tx);
+#endif
 				__raw_writel(*tx, tx_reg);
 			}
 			if (rx != NULL) {
@@ -217,6 +221,10 @@ static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer)
 				if (c == 0 && tx == NULL)
 					omap2_mcspi_set_enable(spi, 0);
 				*rx++ = __raw_readl(rx_reg);
+#ifdef VERBOSE
+				dev_dbg(&spi->dev, "read-%d %02x\n",
+						word_len, *(rx - 1));
+#endif
 			}
 		}
 	} else if (word_len <= 16) {
@@ -229,6 +237,10 @@ static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer)
 		while (c--) {
 			if (tx != NULL) {
 				while (!(__raw_readl(chstat_reg) & OMAP2_MCSPI_CHSTAT_TXS));
+#ifdef VERBOSE
+				dev_dbg(&spi->dev, "write-%d %04x\n",
+						word_len, *tx);
+#endif
 				__raw_writel(*tx++, tx_reg);
 			}
 			if (rx != NULL) {
@@ -236,6 +248,10 @@ static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer)
 				if (c == 0 && tx == NULL)
 					omap2_mcspi_set_enable(spi, 0);
 				*rx++ = __raw_readl(rx_reg);
+#ifdef VERBOSE
+				dev_dbg(&spi->dev, "read-%d %04x\n",
+						word_len, *(rx - 1));
+#endif
 			}
 		}
 	} else if (word_len <= 32) {
@@ -248,6 +264,10 @@ static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer)
 		while (c--) {
 			if (tx != NULL) {
 				while (!(__raw_readl(chstat_reg) & OMAP2_MCSPI_CHSTAT_TXS));
+#ifdef VERBOSE
+				dev_dbg(&spi->dev, "write-%d %04x\n",
+						word_len, *tx);
+#endif
 				__raw_writel(*tx++, tx_reg);
 			}
 			if (rx != NULL) {
@@ -255,6 +275,10 @@ static void omap2_mcspi_txrx(struct spi_device *spi, struct spi_transfer *xfer)
 				if (c == 0 && tx == NULL)
 					omap2_mcspi_set_enable(spi, 0);
 				*rx++ = __raw_readl(rx_reg);
+#ifdef VERBOSE
+				dev_dbg(&spi->dev, "read-%d %04x\n",
+						word_len, *(rx - 1));
+#endif
 			}
 		}
 	}
@@ -325,6 +349,11 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,
 		l |= OMAP2_MCSPI_CHCONF_PHA;
 	mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, l);
 
+	dev_dbg(&spi->dev, "setup: speed %d, sample %s edge, clk %s inverted\n",
+			OMAP2_MCSPI_MAX_FREQ / (1 << div),
+			(spi->mode & SPI_CPHA) ? "odd" : "even",
+			(spi->mode & SPI_CPOL) ? "" : "not");
+
 	return 0;
 }
 
-- 
2.25.4