[i2c] I2C Bus Driver needed?
James Chapman
jchapman at katalix.com
Wed May 2 09:50:49 CEST 2007
Markus Franke wrote:
> Hi,
>
> James Chapman wrote:
>> My comment about you might not needing one is the very rare case where
>> a SoC might have hardware support for interfacing to specific i2c
>> device types. It might provide a memory-mapped register interface and
>> handle i2c transactions with the hardware transparently. One example
>> is a SoC that supports an external i2c nvram. It provides a register
>> for the user to set a RAM offset and a register for reading/writing
>> the data at that offset. Under the hood, the SoC handles all of the
>> i2c transactions. In such cases, you don't need a bus driver or a chip
>> driver or the kernel i2c core; you just need a custom driver for
>> accessing the SoC's memory mapped registers.
>
> I think my SoC offers the possibility to control everything in hardware.
> I can access some memory mapped registers of the I2C controller.
Any SoC with an i2c controller offers registers through which i2c
accesses are done. A bus driver allows kernel i2c code to use that i2c
hardware for i2c device access. I think you are confusing bit-banging
i2c controllers with dedicated i2c controllers. The kernel i2c core
supports both. (Bit-banging controllers aren't really controllers at
all. The kernel has code that allows generic IO pins to be turned into a
software-driven i2c controller.)
If your SoC has i2c control registers then I think you need a bus driver
so that the kernel's i2c core can provide all of the i2c infrastructure
for you. The bus driver is the hardware-specific mapping to the kernel's
i2c generic code.
Just to be clear, the only reason that you wouldn't need an i2c bus
driver is if your device access is through registers that are not
related to i2c. In other words, in cases where you are not exposing i2c
to software at all. In the nvram device example above, those registers
are device address offset and data, i.e. nothing to do with an i2c
controller. In your case, you mention an i2c controller so write a bus
driver for it.
> So this means I can just omit dealing with i2c-core.c and just focus on
> working with memory mapped registers without taking care about the I2C
> core of linux?
See above.
> That means also that linux would not be aware of the I2C
> device and the device won't show up in sysfs, right?
If you need these features then use the i2c core and write a bus driver
because you are exposing i2c to the kernel and application.
If you are still unclear about this, please list the registers of your
SoC that you are using to access your i2c device(s) and give a summary
of how those registers are used. I'm almost certain that they will be
generic i2c controller registers, in which case a bus driver is needed.
>> The Au1xxx is a MIPS SoC. It has an i2c bus driver.
>
> Thanks. I will also have a look at it.
>
> Regards,
> Markus
>
--
James Chapman
Katalix Systems Ltd
http://www.katalix.com
Catalysts for your Embedded Linux software development
More information about the i2c
mailing list