Hardware Reference
In-Depth Information
Now that you know your RTC is alive on your I2C bus the next challenge is to load a supporting module. Recall
how I said the DS1338 was hardware-compatible with the DS1307? If you were to take a look at a module listing for the
Raspberry Pi you will notice there is nothing listed for the DS1338.
# modprobe -l
So how do you know it's compatible? There are two ways to check this. The first method is by using the
tool modinfo :
# modinfo rtc-ds1307
This will give you an alias table and you will find the DS1338 listed there. Another way to find out if the module
has support for the DS1338 chip is to use a command called strings . This command will search though compiled
code and pull out the text strings:
# strings /lib/modules/�uname -r�/kernel/drivers/rtc/rtc-ds1307.ko | grep ds1338
You would see the same alias definition. Take a look at Figure 8-16 to see the output on my Raspberry Pi.
Figure 8-16. Module info and the strings tool
If you were to run either one of these tools on any of the other RTC modules listed by the modinfo -l command
you would soon notice that none of them have DS1338 listed. So this has to be what you need to load. You need to
load this module in a very special way, otherwise nothing will happen because the module has no idea what address
your RTC can be found at. You're going to need to tell it where to find the RTC. To do that, you're going to use the
special file called new_device .
This special file can only be written to and its sole job is to instantiate an I2C slave device at a certain address.
This file takes two parameters.
The first parameter is the name of the kernel module that is needed to support the device
expressed just as the device name. It will take care of loading any kernel modules needed. In
your case this first parameter will be ds1307 .
The second parameter will be the address of the I2C device in hex. In your case this will be
0x68 as you found out via the i2cdetect tool.
 
Search WWH ::




Custom Search