Files
meta-pengwyn/recipes-kernel/linux/files/0005-printk-omap2-mcspi.patch
T

159 lines
5.0 KiB
Diff

--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1146,6 +1146,7 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
int status = 0;
u32 chconf;
+ printk(KERN_INFO "[MCSPI] transfer one\n");
mcspi = spi_master_get_devdata(master);
mcspi_dma = mcspi->dma_channels + spi->chip_select;
cs = spi->controller_state;
@@ -1158,27 +1159,40 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
* omap2_mcspi_setup_transfer will be called to configure the hardware
* with the correct mode on the first iteration of the loop below.
*/
- if (spi->mode != cs->mode)
+ printk(KERN_INFO "[MCSPI] mode: (0x%x/0x%x)\n", spi->mode, cs->mode);
+ if (spi->mode != cs->mode) {
+ printk(KERN_INFO "[MCSPI] par_override !\n");
par_override = 1;
+ }
omap2_mcspi_set_enable(spi, 0);
- if (gpio_is_valid(spi->cs_gpio))
+ if (gpio_is_valid(spi->cs_gpio)) {
+ printk(KERN_INFO "[MCSPI] gpio is valid ! (0x%x)\n", spi->cs_gpio);
omap2_mcspi_set_cs(spi, spi->mode & SPI_CS_HIGH);
+ }
if (par_override ||
(t->speed_hz != spi->max_speed_hz) ||
(t->bits_per_word != spi->bits_per_word)) {
par_override = 1;
+ printk(KERN_INFO "[MCSPI] setup transfer !\n");
status = omap2_mcspi_setup_transfer(spi, t);
- if (status < 0)
+ if (status < 0) {
+ printk(KERN_INFO "[MCSPI] ==> out\n");
goto out;
+ }
if (t->speed_hz == spi->max_speed_hz &&
- t->bits_per_word == spi->bits_per_word)
+ t->bits_per_word == spi->bits_per_word) {
+ printk(KERN_INFO "[MCSPI] par_override = 0 !\n");
par_override = 0;
+ }
}
+
if (cd && cd->cs_per_word) {
+ printk(KERN_INFO "[MCSPI] cs_per_word - toggle chip select after every word !\n");
chconf = mcspi->ctx.modulctrl;
+ printk(KERN_INFO "[MCSPI] cs_per_word: chconf: 0x%x\n", chconf);
chconf &= ~OMAP2_MCSPI_MODULCTRL_SINGLE;
mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf);
mcspi->ctx.modulctrl =
@@ -1186,29 +1200,40 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
}
chconf = mcspi_cached_chconf0(spi);
+ printk(KERN_INFO "[MCSPI] chconf: 0x%x\n", chconf);
chconf &= ~OMAP2_MCSPI_CHCONF_TRM_MASK;
+ printk(KERN_INFO "[MCSPI] chconf: 0x%x\n", chconf);
chconf &= ~OMAP2_MCSPI_CHCONF_TURBO;
+ printk(KERN_INFO "[MCSPI] chconf: 0x%x\n", chconf);
if (t->tx_buf == NULL)
chconf |= OMAP2_MCSPI_CHCONF_TRM_RX_ONLY;
else if (t->rx_buf == NULL)
chconf |= OMAP2_MCSPI_CHCONF_TRM_TX_ONLY;
+ printk(KERN_INFO "[MCSPI] chconf: 0x%x\n", chconf);
if (cd && cd->turbo_mode && t->tx_buf == NULL) {
+ printk(KERN_INFO "[MCSPI] Turbo mode\n");
/* Turbo mode is for more than one word */
- if (t->len > ((cs->word_len + 7) >> 3))
+ if (t->len > ((cs->word_len + 7) >> 3)) {
chconf |= OMAP2_MCSPI_CHCONF_TURBO;
+ printk(KERN_INFO "[MCSPI] chconf: 0x%x\n", chconf);
+ }
}
+ printk(KERN_INFO "[MCSPI] write conf\n");
mcspi_write_chconf0(spi, chconf);
if (t->len) {
unsigned count;
+ printk(KERN_INFO "[MCSPI] spi transfer len : %d\n", t->len);
if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) &&
master->cur_msg_mapped &&
- master->can_dma(master, spi, t))
+ master->can_dma(master, spi, t)) {
+ printk(KERN_INFO "[MCSPI] set fifo\n");
omap2_mcspi_set_fifo(spi, t, 1);
+ }
omap2_mcspi_set_enable(spi, 1);
@@ -1219,32 +1244,40 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
if ((mcspi_dma->dma_rx && mcspi_dma->dma_tx) &&
master->cur_msg_mapped &&
- master->can_dma(master, spi, t))
+ master->can_dma(master, spi, t)) {
+ printk(KERN_INFO "[MCSPI] use dma\n");
count = omap2_mcspi_txrx_dma(spi, t);
- else
+ } else {
+ printk(KERN_INFO "[MCSPI] use pio\n");
count = omap2_mcspi_txrx_pio(spi, t);
-
+ }
if (count != t->len) {
status = -EIO;
+ printk(KERN_INFO "[MCSPI] ==> go out (count: %d/%d)\n", count, t->len);
goto out;
}
}
omap2_mcspi_set_enable(spi, 0);
- if (mcspi->fifo_depth > 0)
+ if (mcspi->fifo_depth > 0) {
+ printk(KERN_INFO "[MCSPI] reset fifo\n");
omap2_mcspi_set_fifo(spi, t, 0);
+ }
out:
/* Restore defaults if they were overriden */
if (par_override) {
+ printk(KERN_INFO "[MCSPI] restore default\n");
par_override = 0;
status = omap2_mcspi_setup_transfer(spi, NULL);
}
if (cd && cd->cs_per_word) {
chconf = mcspi->ctx.modulctrl;
+ printk(KERN_INFO "[MCSPI] chconf: 0x%x\n", chconf);
chconf |= OMAP2_MCSPI_MODULCTRL_SINGLE;
+ printk(KERN_INFO "[MCSPI] chconf: 0x%x\n", chconf);
mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf);
mcspi->ctx.modulctrl =
mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL);
@@ -1252,8 +1285,12 @@ static int omap2_mcspi_transfer_one(struct spi_master *master,
omap2_mcspi_set_enable(spi, 0);
- if (gpio_is_valid(spi->cs_gpio))
- omap2_mcspi_set_cs(spi, !(spi->mode & SPI_CS_HIGH));
+ if (gpio_is_valid(spi->cs_gpio)) {
+ printk(KERN_INFO "[MCSPI] reset CS !\n");
+ if(!(t->cs_change)) {
+ omap2_mcspi_set_cs(spi, !(spi->mode & SPI_CS_HIGH));
+ }
+ }
if (mcspi->fifo_depth > 0 && t)
omap2_mcspi_set_fifo(spi, t, 0);