Subject: Re: Device tree and external RTC

From: Peter Korsgaard <[email-masked]>
Date: Thu, 04 Oct 2007 13:21:10 +0200

>>>>> "Bruce" == Bruce Leonard <[email-masked]> writes:

Hi,

 Bruce> I'm seriously confused by how things are supposed to work now
 Bruce> with device trees on the PowerPC arch.  I'm bringing up our
 Bruce> custom HW which is bassed on the mpc8347e, with an m41t00 RTC
 Bruce> hanging off the i2c bus, U-boot is 1.2.0, kernel is 2.6.22.
 Bruce> My problem is I can't get the kernel to access the RTC.  It
 Bruce> works fine in U-boot, but nothing in the kernel.
 Bruce> I've searched through all the device tree files that come with
 Bruce> the kernel 

 Bruce> and I can't find any that explicitly show an external device
 Bruce> as a child node to a SoC I2C controller but it sure seems to
 Bruce> me that the purpose of the device tree is to describe to the
 Bruce> kernel all the hardware in the system.  Therefore it seems to
 Bruce> me that there should be something like the following in the
 Bruce> device tree:

 Bruce> <snip>
 Bruce> i2c@3000 {
 Bruce>         device_type = "i2c";
 Bruce>         compatible = "fsl-i2c";
 Bruce>         reg = <3000 100>;
 Bruce>         interrupts = <e 8>;
 Bruce>         interrupt-parent = < &ipic >;
 Bruce>         dfsrr;

You need to add #address/size-cells to the I2C node, E.G.:
+			#address-cells = <1>;
+			#size-cells = <0>;

 Bruce>         rtc@54 {
 Bruce>                 device_type = "rtc";
 Bruce>                 something;
 Bruce>                 something;
 Bruce>                 something;
 Bruce>         }
 Bruce> }
 Bruce> <snip>

You need to set compatible and reg, E.G.
			rtc@54 {
				device_type = "rtc";
				compatible = "stm,m41t00";
				reg = <54>;
			};

And it should get picked up automatically by
fsl_soc.c:of_find_i2c_driver().

Notice that you will need to use galak's git tree
(git://git.kernel.org/pub/scm/linux/kernel/git/galak/powerpc.git) or
apply the following patch:

http://ozlabs.org/pipermail/linuxppc-dev/2007-September/042896.html

As it isn't in mainline yet.

-- 
Bye, Peter Korsgaard