Re: I2C slave mode for i2c-at91 driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Juergen,,

> Currently I'm working on a driver adding I2C slave support to some Atmel /
> Microchip MPUs. I already patched the i2c-at91.c and made the
> i2c-slave-eeprom backend working on an ATSAMA5D27. But this is still in the
> prototype status. My next steps are cleaning up the code and sharing the
> patch with you for review and merge into Linux.

Nice!

> 
> 1) According to [1] the return value of the I2C_SLAVE_WRITE_RECEIVED event
> determines whether the received byte shall be ACKed or NACKed. The problem
> with the Atmel hardware is that it is not possible to manipulate the ACK bit
> of the current byte in flight; it will be ACKed automatically. It is only
> possible to (N)ACK the following byte(s) since some FIFO magic is going on
> inside the hardware.

So, it is not possible to NACK the last byte?

> Do you think it is a valid approach to ignore the return value and always
> ACK received bytes? Or would you rather set the behaviour for the following
> bytes? That would delay the desired ACK bit by at least one byte.

Tricky, since both options are really sub-optimal. I tend to think that
reporting the error a bit later is the slightly better option. Most
client drivers will act on the fact that the whole transfer failed
somehow. Where it fails is not so essential. We don't have proper means
to report the exact position of the failure currently anyhow.

> 2) The Atmel hardware does not support master and slave concurrently. The
> data sheet [2] examples disable master mode before entering the slave mode.
> (cf. p. 1362) Furthermore send and receive registers and their FIFOs are
> shared.
> How would you implement blocking master transactions while slave mode is
> enabled? I would return EBUSY if master_xfer is called.

The i2c-designware driver has the same problem. We decided to have
seperate struct i2c_algorithms for master and slave. The core helper
i2c_detect_slave_mode() can help you to determine which mode should be
used. The designware drive might give you some inspiration.

Hope that helps?

Kind regards,

   Wolfram

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux