2010-05-05 11:58:32 BF537 spi_sync returns error
Adam Rosenberg (UNITED STATES)
Message: 89155
I am trying to write a sound driver that can communicate with a Cirrus Logic CS42448 using the BF537 SPI driver.
The value of result at the end of the following code is -5. I do not know how to debug kernel modules using a debugger so I have been trying to trace this manually. From what I can tell, -5 is actually -EIO which is set as the message status in bfin_spi_pump_transfers in spi_bfin5xx.c
What are the possible causes of this error?
-- code --
unsigned char msg[3];
int result = 0;
struct spi_transfer tw = {
.tx_buf = &msg,
.len = 3,
};
struct spi_message m;
msg[0] = (CS42448_CHIP_ADDR | CS42448_CHIP_WRITE);
msg[1] = (CS42448_REG_POWER_CONTROL & CS42448_MAP_MASK);
msg[2] = 0x01;
spi_message_init(&m);
spi_message_add_tail(&tw, &m);
result = spi_sync(me->spi, &m);
-- end code --
Thank you,
Adam
QuoteReplyEditDelete
2010-05-05 15:06:54 Re: BF537 spi_sync returns error
Mike Frysinger (UNITED STATES)
Message: 89160
all negative values are errno values, so look it up in the errno headers. -5 is -EIO.
as for where the error is coming from, enable debugging in the relevant drivers (#define DEBUG) and look at where it's coming from.
QuoteReplyEditDelete
2010-05-06 09:26:53 Re: BF537 spi_sync returns error
Adam Rosenberg (UNITED STATES)
Message: 89180
Mike,
Thank you for your quick response. Here is the output from the debug messages:
bfin-spi bfin-spi.0: restoring spi ctl state
bfin-spi bfin-spi.0: got a message to pump, state is set to: baud 20, flag 0x20, ctl 0x1000
bfin-spi bfin-spi.0: the first transfer len is 3
bfin-spi bfin-spi.0: tx_buf is 03bd8308, tx_end is 03bd830b
bfin-spi bfin-spi.0: transfer: drv_data->write is 00090870, chip->write is 00090870, null_wr is 000905f8
bfin-spi bfin-spi.0: now pumping a transfer: width is 1, len is 3
bfin-spi bfin-spi.0: doing IO transfer
bfin-spi bfin-spi.0: IO write: cr is 0x5100
bfin-spi bfin-spi.0: IO write error!
bfin-spi bfin-spi.0: transfer: we've hit an error
What are the possible causes of this error?
Thank you,
Adam
QuoteReplyEditDelete
2010-05-06 09:42:53 Re: BF537 spi_sync returns error
Michael Hennerich (GERMANY)
Message: 89181 In your platform board file - could it be that you set bfin5xx_spi_chip.bits_per_word = 16 ?
This might explain the error for the odd transfer count.
-Michael
QuoteReplyEditDelete
2010-05-06 10:19:14 Re: BF537 spi_sync returns error
Adam Rosenberg (UNITED STATES)
Message: 89184
Mike,
I looked through the area of the code that caused the "bfin-spi bfin-spi.0: IO write error!" and took a guess that it doesn't like writing only 3 bytes. I padded my write with a zero at the end and sure enough, it worked. I do not yet know if that extra byte is going to cause problems when I try to communicate with the CS42448 but at least I am one step closer. I will keep you posted if anything changes.
Thanks,
Adam
QuoteReplyEditDelete
2010-05-06 10:21:21 Re: BF537 spi_sync returns error
Adam Rosenberg (UNITED STATES)
Message: 89185
You are correct, I didn't change bits per word to 8! Thanks I will try that now.
-Adam