开发者

I2C linux drivers

I will need to write my own drivers for few controllers in my chipset.I work on SoC with SDK, that doesn't provide "linux i2c compatible" driver. It has simple char driver for i2c. I would like to use some standard i2c RTC drivers.

  • I assume I will need to add the file to /busses folder, and implement the standard interfaces. And that's all. This file should cooperate with i2c-core and i2c-dev ?

  • Which driver would be the best as basis ? I h开发者_如何学Cave ~9 32bit registers to work with. From first look i2c-ibm_iic.c seems for me quite friendly.

I2C is the warm-up before SPI and USB-gadget drivers for this SoC. Do you know maybe raw Men/Hours estimation for such tasks ?

I will appreciate any hints.

BR Bartlomiej Grzeskowiak


The first order of business is to find if perchance your IC driver has already been implemented within the Linux kernel or by a third party. You may well find that the driver you need has already been implemented. Try asking your SoC vendor if they can tell which company made the I2C macrocell because you are looking for alternative drivers. Again, you may find that the driver you need already exists.

You're looking in the right place. The file should go in busses and should implement and register a driver interface. You will also need to register a platform device so that the kernel will connect the driver-device pair, as usual. Other SoCs have lots of examples of this if yours does not. I don't think you'll find that you need to interact with i2c-core and i2c-dev.

I would look for a small file size and recently modified driver, if I had to pick one as a baseline.

SPI will take about the same amount of effort as I2C. USB gadget would be considerably more -- several times the effort needed for the other two tasks, depending how much implementation work is needed. I am reluctant to put a number to either task. If you're lucky not all functionality is needed (do you care about low power standby, for example?) and you may be able to cut corners.


You are talking about I2C bus(adapter) driver. Here is greatly simplified wiev:

You have to define your own I2C platform_driver structure and register it as platform_driver. Driver is bound with I2C device in probe() function.

You have to define your I2C device structure containing i2c_adapter initialize it's members and i2c_algorithm structure where you define your hooks (callbcaks)

static const struct i2c_algorithm xxx_i2c_algo = { .master_xfer = xxxxx()

and then add i2c_adapter to Kernel I2C layer in order for i2c-core and i2c-devto be able to use of your bus driver.

SPI bus device registration follows similar philosophy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜