RE: implementing a slave driver

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

 



Marc Dietrich wrote:
> the HW I'm using (tegra) can be configured to act as a slave. This
function is 
> needed to communicate with an embedded controller (which is the
master). I 
> like to know if this slave function can/should be implemented in the 
> i2c/busses/i2c-tegra.c driver or better outside, e.g. in the driver
for the 
> embedded controller.

Do you need to implement a slave for write-only or also read messages?

> I haven't found any other hw so far which has this function and it
seems that 
> the i2c layer does not provide any interface for the communication
with a 
> master.

In fact, the Freescale's MPC8xxx I2C controllers are also capable of
slave 
operation. I've implemented it, and it's working fine.

Please find attached a patch against 2.6.35.

 drivers/i2c/busses/i2c-mpc.c |   79
+++++++++++++++++++++++++++++++++++++++++--
 drivers/i2c/i2c-dev.c        |    8 +++-
 include/linux/i2c.h          |    1
 3 files changed, 84 insertions(+), 4 deletions(-)

The proposal sent last year[1] relies on a generic API extension.
<<
The i2c-dev subsystem is extended with a new flag I2C_M_SLAVE.
Basically, a struct i2c_msg holding flag I2C_M_SLAVE will wait
in slave mode for a write request on specified target address,
and will report the received content to the user-land application.

An example of driver implementation has been done for i2c-mpc. 
There's no support for read request yet, and I'm wondering whether
it would make sense. The patch has been tested on powerpc MPC8313E. 
Note: the present i2c-mpc implementation is RFC and may be improved,
esp. regarding current timing issues.

[...]
Talking about i2c-dev, does the I2C_M_SLAVE flag is the appropriate 
way of modelling the API extension? Is there any interest for
this extension to be accepted in the linux kernel?
>>

[1] http://thread.gmane.org/gmane.linux.drivers.i2c/6417

Until now, I have no good proposal for the read request.
It should be doable to pass a static array and let the kernel read from
it,
but I see no easy way to have a user task respond with
compute-as-you-go.

Still, the write message is satisfactory for my use case.

Comments welcome.
-- 
Stephane

PS: sorry about my broken MUA, it's about to be changed in the coming
weeks,
as well as my e-mail address.

Attachment: mpc-i2c-slave.patch
Description: mpc-i2c-slave.patch


[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