Hi
I writing an additional GPIO driver based on the mcp23s17 SPI chip.
I have problems with the spi_write_then_read() function. The returned value is dummy (0xFF or 0x00).
I tried different values ".del_cs_to_clk" and ".del_after_trans" in the chip structure, without results. I checked signals on the SPI bus using oscilloscope and they are correct.
The spi_write() function work very good.
I think it is software problem.
Here is my function form the driver module:
static u8 expander_read(u8 addr, u8 data)
{
u16 spi_word;
u8 result;
s8 retval;
if (gpio_device==NULL || gpio_device->spi==NULL)
return -ENODEV;
spi_word = ((addr&0xFF)<<8)|(data&0xFF);
#ifdef MCP23S17_DEBUG
printk("m5329gpio data write before read -> 0x%x\n", spi_word);
#endif
retval = spi_write_then_read(gpio_device->spi, (u8*)&spi_word, 2, &result, 1); // 3 bytes -> 24 bits [opcode][reg_addr] [read reg_data]
#ifdef MCP23S17_DEBUG
printk("spi_write_then_read status -> %d\n", retval);
#endif
if (retval < 0) {
#ifdef MCP23S17_DEBUG
printk("m5329gpio spi_write_then_read error -> %d\n", retval);
#endif
}
#ifdef MCP23S17_DEBUG
printk("m5329gpio data read -> 0x%x\n", result);
#endif
return result;
}
Any suggestions ??
Regards