I2C client driver on dragonboard 410c

I want to develop I2C Client driver for RTC device on dragonboard 410c.
please guide me with the steps to be followed to write I2C driver.

Hi @Vijay

Which RTC chip are you intending to use? Most RTC chips already have kernel drivers and it is just a matter of enabling the driver, you usually don’t need to develop an I2C client driver. Once I know which chip you are trying to use I will show you how to enable it in the kernel. I did this a year and a half ago for the DS1307 chip, but most other chips are the same process.

Take a look at I2C DS1307 Problem and at DragonBoard 410c with Real-time clock (RTC) - #3 by ljking

Full Disclosure: I am an employee of Qualcomm Canada, any opinions I may have expressed in this post or any other post may not reflect the opinions of my employer.


Hi ljking,

Thanks for your reply. I want to write I2C driver for learning device driver development.
I will also try the method you suggested. Could you suggest any references for i2c client driver development.

Hi @vijay

The “secret” of kernel driver development is that, unless you are working on really exotic, never-before-seen hardware, there are lots of example drivers to choose from. Almost all accomplished kernel developers will read the code for the existing drivers before choosing one to copy and use as a template.

Thus the very best source for references for i2c client driver development is the kernel source itself. The critical skill a kernel driver writer must develop is how to select a driver to use as a template. Personally I look for a mix of freshness (i.e. a recently added driver where I can go and read the LKML review comments from the maintainer) and similarity of hardware (i.e. a driver for hardware that has similar data flow to the hardware I want to enable).

There is API documentation to help you understand what the drivers do: I2C and SMBus Subsystem — The Linux Kernel documentation . However, since that documentation is derived from comments in the kernel sources, I prefer to use a source navigator to find out what a specific bit of kernel API does.

PS Linux Device Drivers is getting a bit old now, but nevertheless it remains a good primer for the overall structure of a kernel driver and as an introduction to some key kernel APIs. If you struggle to read the I2C drivers in the kernel you should take a look at this. Just be aware that not all the example code will run without modification on the latest kernels.