Skip to contentSkip to conversation

DTS question

DISCUSSION Gary Thomas 3 participants 5 messages Sep 2, 2008 – Sep 3, 2008

lore
Share & tools
lore
#0 lore raw

Following on with my RTC problem, I cut&pasted this from the TQM5200 dts file:

                i2c@3d40 {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        compatible = "fsl,mpc5200-i2c","fsl-i2c";
                        reg = <0x3d40 0x40>;
                        interrupts = <2 16 0>;
                        interrupt-parent = <&mpc5200_pic>;
                        fsl5200-clocking;

                         rtc@68 {
                                device_type = "rtc";
                                compatible = "dallas,ds1307";
                                reg = <0x68>;
                        };
                };

However, the dts file I started with had this (*mine*):

		i2c@3d40 {
			#address-cells = <1>;
			#size-cells = <0>;
			compatible = "fsl,mpc5200-i2c","fsl-i2c";
			cell-index = <1>;
			reg = <3d40 40>;
			interrupts = <2 10 0>;
			interrupt-parent = <&mpc5200_pic>;
			fsl5200-clocking;
		};

Notice the different mix of hex (0xNNN) and implied hex values. This is really confusing to me. Even more so when I added the RTC snippet cut directly from the TQM5200 file:

                         rtc@68 {
                                device_type = "rtc";
                                compatible = "dallas,ds1307";
                                reg = <0x68>;
                        };

This yielded a syntax error when merged with my platform dts. When I changed the 'reg=<0x68>' to 'reg=<68>', the syntax error went away & it worked perfectly.

What gives? Why is explicit hex sometimes an error and sometimes not? Is the format of this file documented anywhere (I've not found it)?

Signature · 4 lines
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
#1 lore raw
Quoted 40 lines · Gary Thomas

Following on with my RTC problem, I cut&pasted this from the TQM5200 dts file:

                i2c@3d40 {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        compatible = "fsl,mpc5200-i2c","fsl-i2c";
                        reg = <0x3d40 0x40>;
                        interrupts = <2 16 0>;
                        interrupt-parent = <&mpc5200_pic>;
                        fsl5200-clocking;

                         rtc@68 {
                                device_type = "rtc";
                                compatible = "dallas,ds1307";
                                reg = <0x68>;
                        };
                };

However, the dts file I started with had this (*mine*):

		i2c@3d40 {
			#address-cells = <1>;
			#size-cells = <0>;
			compatible = "fsl,mpc5200-i2c","fsl-i2c";
			cell-index = <1>;
			reg = <3d40 40>;
			interrupts = <2 10 0>;
			interrupt-parent = <&mpc5200_pic>;
			fsl5200-clocking;
		};

Notice the different mix of hex (0xNNN) and implied hex values. This is really confusing to me. Even more so when I added the RTC snippet cut directly from the TQM5200 file:

                         rtc@68 {
                                device_type = "rtc";
                                compatible = "dallas,ds1307";
                                reg = <0x68>;
                        };
Quoted 5 lines

This yielded a syntax error when merged with my platform dts. When I changed the 'reg=<0x68>' to 'reg=<68>', the syntax error went away & it worked perfectly.

What gives? Why is explicit hex sometimes an error and sometimes not?

Because we changed the format at one point. Originally (the "dts-v0" format) it was implicitly hex everywhere, which turned out to be a mistake. So we introduced the new dts-v1 format which uses C-style literals. New-style files are marked with a /dts-v1/; token at the top of the file.

Quoted 1 line

Is the format of this file documented anywhere (I've not found it)?

It's in Documentation/dts-format.txt in the dtc tree. I don't think that's been included in the version of dtc in the kernel tree, though, so you'll need to download the standalone dtc.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#4 lore raw
In reply to Gary Thomas
Quoted 2 lines · Gary Thomas

What gives? Why is explicit hex sometimes an error and sometimes not? Is the format of this file documented anywhere (I've not found it)?

If the file has /dts-v1/; at the top, it uses version 1 of the device tree syntax, which has C-like numerical constants. Without it, you get version zero syntax, with implicit hex.

-Scott

#2 lore raw
In reply to David Gibson
Quoted 1 line · David Gibson

On Tue, Sep 02, 2008 at 03:56:30PM -0600, Gary Thomas wrote:

<snip>

Quoted 7 lines
Quoted 1 line

What gives? Why is explicit hex sometimes an error and sometimes not?

Because we changed the format at one point. Originally (the "dts-v0" format) it was implicitly hex everywhere, which turned out to be a mistake. So we introduced the new dts-v1 format which uses C-style literals. New-style files are marked with a /dts-v1/; token at the top of the file.

Gotcha, thanks. Not sure where I picked up the dts-v0 file I based my platform on, but at least now I understand the magic.

Quoted 6 lines
Quoted 1 line

Is the format of this file documented anywhere (I've not found it)?

It's in Documentation/dts-format.txt in the dtc tree. I don't think that's been included in the version of dtc in the kernel tree, though, so you'll need to download the standalone dtc.

Where do I find this "dtc" tree?

Signature · 4 lines
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------
#3 lore raw
Quoted 5 lines · Gary Thomas
Quoted 1 line · David Gibson

On Tue, Sep 02, 2008 at 03:56:30PM -0600, Gary Thomas wrote:

<snip>

Quoted 2 lines
Quoted 1 line

What gives? Why is explicit hex sometimes an error and sometimes not?

Quoted 8 lines
Quoted 5 lines

Because we changed the format at one point. Originally (the "dts-v0" format) it was implicitly hex everywhere, which turned out to be a mistake. So we introduced the new dts-v1 format which uses C-style literals. New-style files are marked with a /dts-v1/; token at the top of the file.

Gotcha, thanks. Not sure where I picked up the dts-v0 file I based my platform on, but at least now I understand the magic.

Well, it's only fairly recently that we converted all the in-kernel files to v1, so you may have grabbed something before the conversion.

We're hoping to get everyone converted over to v1 as quickly as possible, to avoid this sort of confusion.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Is the format of this file documented anywhere (I've not found it)?

It's in Documentation/dts-format.txt in the dtc tree. I don't think that's been included in the version of dtc in the kernel tree, though, so you'll need to download the standalone dtc.

Where do I find this "dtc" tree?

git://git.jdl.com/software/dtc.git

Or get tarballs from

http://jdl.com/software/

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson