Rob's Technical Article: Board files and your device
I have seen a lot of documentation about drivers of all sorts, including books full of information about writing drivers, assembling embedded systems and whatnot, but nowhere have I seen any information about the board file. I am amazed that there has been so much secrecy on this subject... It's almost like there's some... dare I say it? Conspiracy.
All joking aside, systems that have I2C, SPI or other type of driver will require the person assembling the device to register their peripherals in the board file. This file is often found in your architecture area, in the kernel directory /arch/MAJOR_ARCH/SUB_ARCH/, for example, /arch/arm/mach-msm/.
First, we'll want to know where it is connected and what address it'll use. I'll freely steal code from the file /arch/arm/mach-mx5/board-cpuimx51sd.c which is in one of my kernel distros. I honestly don't know what this is, but I spotted this chip in use in the board file, so I'll use it.
NOTE: Carefully read your board file, or another one in the same architecture. Although many of the principles are the same, there will be some rather large differences between this tutorial and your architecture.
First, make sure you include the appropriate files in your board file...
Next, you'll want to establish the GPIO that's to be used for the interrupt, set up the platform data block defined in the above mentioned tsc2007.h include.
Assemble all of this information in the i2c_board_info block. There may already be an array of i2c_board_info blocks already in your board file.
Once we've got this all assembled, we've got to make sure that the i2c bus is initialized in the main init functions in the bottom of the board file.
If you've got it all put together properly and your driver 'turned on' in the kernel configuration, you should have a working device at this point.