Skip to contentSkip to conversation

ARM: bcm2835: add device tree for Raspberry Pi model B+

PATCH Superseded Matthias Klein 5 participants 16 messages Nov 5, 2014 – Nov 19, 2014 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ARM: bcm2835: add device tree for Raspberry Pi model B+

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

---
Changes in v2:
- move the common parts between the B and B+ model into the new bcm2835-rpi.dtsi file

- add the I2S signals to the B+ file which fix the problem that USB is not working with the current bcm2835-rpi-b.dts file on the B+.

---
 arch/arm/boot/dts/Makefile               |  1 +
 arch/arm/boot/dts/bcm2835-rpi-b-plus.dts | 30 +++++++++++++++++++
 arch/arm/boot/dts/bcm2835-rpi-b.dts      | 46 ++--------------------------
 arch/arm/boot/dts/bcm2835-rpi.dtsi       | 51 ++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+), 43 deletions(-)
 create mode 100644 arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
 create mode 100644 arch/arm/boot/dts/bcm2835-rpi.dtsi
arch/arm/boot/dts/Makefile +1 -0
index aaae0d6..29e18ee 100644
@@ -54,6 +54,7 @@ dtb-$(CONFIG_ARCH_AT91)	+= at91-sama5d4ek.dtb
 dtb-$(CONFIG_ARCH_ATLAS6) += atlas6-evb.dtb
 dtb-$(CONFIG_ARCH_AXXIA) += axm5516-amarillo.dtb
 dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb
+dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b-plus.dtb
 dtb-$(CONFIG_ARCH_BCM_5301X) += bcm4708-netgear-r6250.dtb
 dtb-$(CONFIG_ARCH_BCM_63XX) += bcm963138dvt.dtb
 dtb-$(CONFIG_ARCH_BCM_MOBILE) += bcm28155-ap.dtb \
arch/arm/boot/dts/bcm2835-rpi-b-plus.dts new file +30 -0
new file mode 100644
index 0000000..e479515
@@ -0,0 +1,30 @@
+/dts-v1/;
+/include/ "bcm2835-rpi.dtsi"
+
+/ {
+	compatible = "raspberrypi,model-b-plus", "brcm,bcm2835";
+	model = "Raspberry Pi Model B+";
+
+	leds {
+		act {
+			gpios = <&gpio 47 0>;
+		};
+
+		pwr {
+			label = "PWR";
+			gpios = <&gpio 35 0>;
+			default-state = "keep";
+			linux,default-trigger = "default-on";
+		};
+	};
+};
+
+&gpio {
+	pinctrl-0 = <&gpioout &alt0 &i2s_alt0 &alt3>;
+
+	/* I2S interface */
+	i2s_alt0: i2s_alt0 {
+		brcm,pins = <18 19 20 21>;
+		brcm,function = <4>; /* alt0 */
+	};
+};
arch/arm/boot/dts/bcm2835-rpi-b.dts +3 -43

66 lines not on this page · raw message

arch/arm/boot/dts/bcm2835-rpi.dtsi new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
2.1.3
Tested-by on v2 1/1
#1 lore raw
Quoted 2 lines · Matthias Klein

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

(On a model B rev 2, UART, SD card, and enumeration of built-in USB devices works fine)

Lee, how do you want to handle patches - will you apply them to the git repo?

Matthias, BTW, you should CC [email protected] too; possibly you can use that to replace the main [email protected] mailing list.

#3 lore raw
In reply to Matthias Klein
Quoted 2 lines · Matthias Klein

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

BTW, according to:

http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/

... there are actually 2 different HW configurations we care about for the pre-plus Pis:

B rev 1
A, or B rev 2

I guess we should have separate device trees for those, since there are some differences in the GPIO and I2C channel usage. That'd leave us with:

bcm2835-rpi-b.dts (Pin3=GPIO0, Pin5=GPIO1, Pin13=GPIO21, I2C-0) bcm2835-rpi-b-rev2.dts (Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, 12C-1) bcm2835-rpi-b-plus.dts (TBD pending schematic or equivalent info) ... and probably another for the compute board.

We can ignore RAM size differences, since these are automatically filled into the /memory node in DT. I'm not sure if A-vs-B-rev-1 is interesting. Perhaps we should have separate DTs just in case, since we may need to represent the LAN_RUN GPIO in DT at some point, and that only applies to the B.

Presumably, the boot loader would automatically query the VC firmware for the board revision data, and dynamically load the appropriate DT filename.

Any thoughts or objections?

#4 lore raw

Am 06.11.2014 um 06:29 schrieb Stephen Warren:

Quoted 5 lines

I guess we should have separate device trees for those, since there are some differences in the GPIO and I2C channel usage. That'd leave us with:

bcm2835-rpi-b.dts (Pin3=GPIO0, Pin5=GPIO1, Pin13=GPIO21, I2C-0) bcm2835-rpi-b-rev2.dts (Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, 12C-1)

I think for these differences separate device trees are not needed.
These pins are all at the moment configured as ALT0. Both I2C buses are configured for I2C, therefore I doesn't matter which one is wired to the gpio header.

But for clarity it would be better to have a separate device tree for each model.

When a gpio signal (which is configured in device tree as ALT0) is used as e.g. plain gpio output, does the kernel the reconfiguration from ALT0 to gpio output? Or must the gpio signal be configured as output in the device tree?

Is is possible to set at the brcm,function/brcm,pins gpio definition also the voltage level of an gpio output for e.g. the LAN_RUN signal?

How do we want to continue?
Is my patch OK, or should I try to write a device tree for every model where every gpio signal is defined?

Best regards,
Matthias

#5 lore raw
Quoted 5 lines · Matthias Klein

Am 06.11.2014 um 06:29 schrieb Stephen Warren:

Quoted 3 lines

I guess we should have separate device trees for those, since there are some differences in the GPIO and I2C channel usage. That'd leave us with:

Quoted 7 lines
Quoted 2 lines

bcm2835-rpi-b.dts (Pin3=GPIO0, Pin5=GPIO1, Pin13=GPIO21, I2C-0) bcm2835-rpi-b-rev2.dts (Pin3=GPIO1, Pin5=GPIO2, Pin13=GPIO27, 12C-1)

I think for these differences separate device trees are not needed. These pins are all at the moment configured as ALT0.Both I2C buses are configured for I2C,
therefore I doesn't matter which one is wired to the gpio header.

At the moment perhaps there's not a lot of difference between the board. However, e.g. the board ID pins on the early boards are connected to pull-up/down resistors, and hence could be represented in DT as specific named GPIOs or not, depending on whether the board has board ID pins. Similarly, we should only enable the I2C controllers on a particular board if there's any possibility of a user connecting something, which is only true if that particular I2C controller is routed to an IO connector (or on-board device).

Quoted 2 lines

But for clarity it would be better to have a separate device tree for each model.

So yes, I think we should move to separate DTs for each incompatible model, so that if/when we actually want to make the DT content different between them, we already have separate DTs in place to do that. That will allow use to update any bootloaders to choose the right DT now, rather than right when we really need it done already:-)

Quoted 3 lines

When a gpio signal (which is configured in device tree as ALT0) is used as e.g. plain gpio output, does the kernel the reconfiguration from ALT0 to gpio output?

IIRC, the kernel GPIO driver sets the pinmux to GPIOin/GPIOout based on gpio_request() calls.

Quoted 1 line

Or must the gpio signal be configured as output in the device tree?

It doens't have to be. That said, if we *know* that a particular GPIO is used as a GPIO rather than a special function, there's probably no harm just putting that setting right into the DT.

Quoted 2 lines

Is is possible to set at the brcm,function/brcm,pins gpio definition also the voltage level of an gpio output for e.g. the LAN_RUN signal?

No. The value on a GPIO pin can only be selected by code. For pins such as LAN_RUN that don't have code controlling them, you can get away with setting the pin as input/tri-state with a pull-up/pull-down to get the desired state.

Quoted 3 lines

How do we want to continue?
Is my patch OK, or should I try to write a device tree for every model where every gpio signal is defined?

I think the patch is fine for now; my thoughts were more about the need to send additional patches to add more DTs later.

#6 lore raw
In reply to Matthias Klein

Den 06.11.2014 00:45, skrev Matthias Klein:

Quoted 11 lines

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

---
Changes in v2:
- move the common parts between the B and B+ model into the new bcm2835-rpi.dtsi file

- add the I2S signals to the B+ file which fix the problem that USB is not working with the current bcm2835-rpi-b.dts file on the B+.
---

<snip>

Quoted 8 lines

+&gpio {

arch/arm/boot/dts/bcm2835-rpi.dtsi new file +7 -0
+	pinctrl-names = "default";
+
+	gpioout: gpioout {
+		brcm,pins = <6>;
+		brcm,function = <1>; /* GPIO out */
+	};
+

arch/arm/boot/dts/bcm2835-rpi.dtsi line 36

Quoted 10 lines
arch/arm/boot/dts/bcm2835-rpi.dtsi new file +10 -0
+	alt0: alt0 {
+		brcm,pins = <0 1 2 3 4 5 7 8 9 10 11 14 15 40 45>;
+		brcm,function = <4>; /* alt0 */
+	};
+
+	alt3: alt3 {
+		brcm,pins = <48 49 50 51 52 53>;
+		brcm,function = <7>; /* alt3 */
+	};
+};

AFAIK these pins will always be configured regardless of whether they are used by a driver or not.

Could we do something like this for SPI and I2C, configuring only when needed?

&gpio {
    spi_pins: spi_pins {
        brcm,pins = <7 8 9 10 11>;
        brcm,function = <4>; /* alt0 */
    };

    i2c0_pins: i2c0_pins {
        brcm,pins = <0 1>;
        brcm,function = <4>;
    };

    i2c1_pins: i2c1_pins {
        brcm,pins = <2 3>;
        brcm,function = <4>;
    };
};
&spi {
    pinctrl-names = "default";
    pinctrl-0 = <&spi_pins>;
};
&i2c0 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c0_pins>;
    clock-frequency = <100000>;
};
&i2c1 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c1_pins>;
    clock-frequency = <100000>;
};

arch/arm/boot/dts/bcm2835-rpi.dtsi line 47

Quoted 11 lines
arch/arm/boot/dts/bcm2835-rpi.dtsi new file +11 -0
+
+&i2c0 {
+	status = "okay";
+	clock-frequency = <100000>;
+};
+
+&i2c1 {
+	status = "okay";
+	clock-frequency = <100000>;
+};
+

Should the I2C busses be enabled by default? On Raspian, i2c is disabled by blacklisting the module (/etc/modprobe.d/raspi-blacklist.conf). At least i2c0 should be left disabled due to the HAT EEPROM and camera.
The bus number has also changed with revisions: http://www.raspberrypi.org/forums/viewtopic.php?p=603950#p603950

#7 lore raw
Quoted 28 lines · Noralf Tronnes

Den 06.11.2014 00:45, skrev Matthias Klein:

Quoted 13 lines

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

---
Changes in v2:
- move the common parts between the B and B+ model into the new bcm2835-rpi.dtsi file

- add the I2S signals to the B+ file which fix the problem that USB is not working
with the current bcm2835-rpi-b.dts file on the B+.
---

<snip>

Quoted 13 lines

+&gpio {

arch/arm/boot/dts/bcm2835-rpi.dtsi new file +12 -0
+    pinctrl-names = "default";
+
+    gpioout: gpioout {
+        brcm,pins = <6>;
+        brcm,function = <1>; /* GPIO out */
+    };
+
+    alt0: alt0 {
+        brcm,pins = <0 1 2 3 4 5 7 8 9 10 11 14 15 40 45>;
+        brcm,function = <4>; /* alt0 */
+    };
+
Quoted 8 lines

arch/arm/boot/dts/bcm2835-rpi.dtsi line 36

Quoted 5 lines
arch/arm/boot/dts/bcm2835-rpi.dtsi new file +5 -0
+    alt3: alt3 {
+        brcm,pins = <48 49 50 51 52 53>;
+        brcm,function = <7>; /* alt3 */
+    };
+};

AFAIK these pins will always be configured regardless of whether they are used by a driver or not.

Yes.

Quoted 2 lines

Could we do something like this for SPI and I2C, configuring only when needed?

...

Quoted 4 lines
&spi {
    pinctrl-names = "default";
    pinctrl-0 = <&spi_pins>;
};

It's certainly possible, but I don't really see any advantage. I'd much rather see the pinmux set up correctly all in one go as early as possible.

Quoted 4 lines
Quoted 4 lines

+&i2c0 {

arch/arm/boot/dts/bcm2835-rpi.dtsi new file +3 -0
+    status = "okay";
+    clock-frequency = <100000>;
+};
Quoted 8 lines

arch/arm/boot/dts/bcm2835-rpi.dtsi line 47

Quoted 6 lines
arch/arm/boot/dts/bcm2835-rpi.dtsi new file +6 -0
+
+&i2c1 {
+    status = "okay";
+    clock-frequency = <100000>;
+};
+

Should the I2C busses be enabled by default?

Yes, I think so. Whichever I2C controllers are actually connected to something (even bare pins on an IO connector) should be enabled by the DT, so that they're available for use.

Quoted 5 lines

On Raspian, i2c is disabled
by blacklisting the module (/etc/modprobe.d/raspi-blacklist.conf). At least i2c0 should be left disabled due to the HAT EEPROM and camera. The bus number has also changed with revisions:
http://www.raspberrypi.org/forums/viewtopic.php?p=603950#p603950

It sounds like for I2C-0 on the B+ should use the i2c-mux-pinctrl.c to switch the bus between the two destinations as required, although we'd have to confirm with Broadcom or the RPi Foundation that that would work with this SoC.

There's certainly no reason to believe that the kernel wouldn't want to read the HAT EEPROM. After all, it has to identify what's connected there.

#8 lore raw

Den 07.11.2014 05:22, skrev Stephen Warren:

Quoted 59 lines · Noralf Tronnes
Quoted 27 lines

Den 06.11.2014 00:45, skrev Matthias Klein:

Quoted 13 lines

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

---
Changes in v2:
- move the common parts between the B and B+ model into the new bcm2835-rpi.dtsi file

- add the I2S signals to the B+ file which fix the problem that USB is not working
with the current bcm2835-rpi-b.dts file on the B+.
---

<snip>

Quoted 12 lines

+&gpio {

arch/arm/boot/dts/bcm2835-rpi.dtsi new file +11 -0
+    pinctrl-names = "default";
+
+    gpioout: gpioout {
+        brcm,pins = <6>;
+        brcm,function = <1>; /* GPIO out */
+    };
+
+    alt0: alt0 {
+        brcm,pins = <0 1 2 3 4 5 7 8 9 10 11 14 15 40 45>;
+        brcm,function = <4>; /* alt0 */
+    };
Quoted 8 lines

arch/arm/boot/dts/bcm2835-rpi.dtsi line 36

Quoted 6 lines
arch/arm/boot/dts/bcm2835-rpi.dtsi new file +6 -0
+
+    alt3: alt3 {
+        brcm,pins = <48 49 50 51 52 53>;
+        brcm,function = <7>; /* alt3 */
+    };
+};

AFAIK these pins will always be configured regardless of whether they are used by a driver or not.

Yes.

Quoted 2 lines

Could we do something like this for SPI and I2C, configuring only when needed?

...

Quoted 4 lines
&spi {
     pinctrl-names = "default";
     pinctrl-0 = <&spi_pins>;
};

It's certainly possible, but I don't really see any advantage. I'd much rather see the pinmux set up correctly all in one go as early as possible.

Quoted 11 lines

arch/arm/boot/dts/bcm2835-rpi.dtsi line 47

Quoted 10 lines

+&i2c0 {

arch/arm/boot/dts/bcm2835-rpi.dtsi new file +9 -0
+    status = "okay";
+    clock-frequency = <100000>;
+};
+
+&i2c1 {
+    status = "okay";
+    clock-frequency = <100000>;
+};
+

Should the I2C busses be enabled by default?

Quoted 3 lines

Yes, I think so. Whichever I2C controllers are actually connected to something (even bare pins on an IO connector) should be enabled by the DT, so that they're available for use.

What makes i2c so special that it should be enabled by default? SPI is not enabled and not 1wire, i2s, lirc either, they must be explicitly enabled. The problem I see, is that this is a newbie platform, and having pins driven increases the chance of shorting something.
And it's quite easy to enable these devices with fdtput.

Quoted 5 lines
Quoted 5 lines

On Raspian, i2c is disabled
by blacklisting the module (/etc/modprobe.d/raspi-blacklist.conf). At least i2c0 should be left disabled due to the HAT EEPROM and camera. The bus number has also changed with revisions:
http://www.raspberrypi.org/forums/viewtopic.php?p=603950#p603950

Quoted 7 lines

It sounds like for I2C-0 on the B+ should use the i2c-mux-pinctrl.c to switch the bus between the two destinations as required, although we'd have to confirm with Broadcom or the RPi Foundation that that would work with this SoC.

There's certainly no reason to believe that the kernel wouldn't want to read the HAT EEPROM. After all, it has to identify what's connected there.

This will happen solely in the firmware. The firmware reads the eeprom, and if it contains a DT fragment, it is merged with the dtb before handing it over to the kernel. As far as I know, this hasn't been implemented yet.

I asked if we couldn't use u-boot as the boot loader, but I was turned down. Personally I'm not happy about putting a lot stuff in a closed firmware, especially on a platform dedicated to getting kids into programming.

From the HAT specification:
GPIO pins ID_SC and ID_SD (GPIO0 and GPIO1) are reserved for use solely for board detection / identification. The only allowed connections to the ID_ pins are an ID EEPROM plus 3.9K pull up resistors. Do not connect anything else to these pins!

Ref: https://github.com/raspberrypi/hats/blob/master/designguide.md#gpio-requirements

I asked in the forum if I could use an app for writing to the eeprom to change things like display rotation in the DT fragment, but was told that this was a no-no. i2c0 is also used together with the camera port, which is then controlled by the firmware.

When talking about firmware, there's also a /boot/dt-blob.bin used for configuring pins and clocks.
https://github.com/raspberrypi/documentation/blob/master/configuration/pin-configuration.md
This is the source of that file: https://github.com/raspberrypi/documentation/blob/master/configuration/images/dt-blob.dts
I haven't studied this, so I don't know how/if it affects our work here.

#10 lore raw
In reply to a message not in the archive

Resend: HTML less...

Quoted 174 lines · Gordon Hollingworth
Quoted 119 lines · Noralf Tronnes

Den 07.11.2014 05:22, skrev Stephen Warren:

Quoted 73 lines · Noralf Tronnes
Quoted 33 lines

Den 06.11.2014 00:45, skrev Matthias Klein:

Quoted 15 lines

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the
I2S interface.

---
Changes in v2:
- move the common parts between the B and B+ model into the new bcm2835-rpi.dtsi file

- add the I2S signals to the B+ file which fix the problem that USB is not working
with the current bcm2835-rpi-b.dts file on the B+.
---

<snip>

Quoted 14 lines

+&gpio {

arch/arm/boot/dts/bcm2835-rpi.dtsi new file +12 -0
+    pinctrl-names = "default";
+
+    gpioout: gpioout {
+        brcm,pins = <6>;
+        brcm,function = <1>; /* GPIO out */
+    };
+
+    alt0: alt0 {
+        brcm,pins = <0 1 2 3 4 5 7 8 9 10 11 14 15 40 45>;
+        brcm,function = <4>; /* alt0 */
+    };
+
Quoted 8 lines

arch/arm/boot/dts/bcm2835-rpi.dtsi line 36

Quoted 5 lines
arch/arm/boot/dts/bcm2835-rpi.dtsi new file +5 -0
+    alt3: alt3 {
+        brcm,pins = <48 49 50 51 52 53>;
+        brcm,function = <7>; /* alt3 */
+    };
+};

AFAIK these pins will always be configured regardless of whether they are used by a driver or not.

Yes.

Quoted 2 lines

Could we do something like this for SPI and I2C, configuring only when needed?

...

Quoted 5 lines
&spi {
     pinctrl-names = "default";
     pinctrl-0 = <&spi_pins>;
};

It's certainly possible, but I don't really see any advantage. I'd much rather see the pinmux set up correctly all in one go as early as possible.

Quoted 4 lines
Quoted 4 lines

+&i2c0 {

arch/arm/boot/dts/bcm2835-rpi.dtsi new file +3 -0
+    status = "okay";
+    clock-frequency = <100000>;
+};
Quoted 8 lines

arch/arm/boot/dts/bcm2835-rpi.dtsi line 47

Quoted 6 lines
arch/arm/boot/dts/bcm2835-rpi.dtsi new file +6 -0
+
+&i2c1 {
+    status = "okay";
+    clock-frequency = <100000>;
+};
+

Should the I2C busses be enabled by default?

Quoted 3 lines

Yes, I think so. Whichever I2C controllers are actually connected to something (even bare pins on an IO connector) should be enabled by the DT, so that they're available for use.

What makes i2c so special that it should be enabled by default? SPI is not enabled and not 1wire, i2s, lirc either, they must be explicitly
enabled. The problem I see, is that this is a newbie platform, and having pins driven increases the chance of shorting something.
And it's quite easy to enable these devices with fdtput.

Quoted 6 lines
Quoted 5 lines

On Raspian, i2c is disabled
by blacklisting the module (/etc/modprobe.d/raspi-blacklist.conf). At least i2c0 should be left disabled due to the HAT EEPROM and camera. The bus number has also changed with revisions:
http://www.raspberrypi.org/forums/viewtopic.php?p=603950#p603950

Quoted 8 lines

It sounds like for I2C-0 on the B+ should use the i2c-mux-pinctrl.c to switch the bus between the two destinations as required, although we'd have to confirm with Broadcom or the RPi Foundation that that would work with this SoC.

There's certainly no reason to believe that the kernel wouldn't want to read the HAT EEPROM. After all, it has to identify what's connected there.

This will happen solely in the firmware. The firmware reads the eeprom, and if it contains a DT fragment, it is merged with the dtb before handing it over to the kernel. As far as I know, this hasn't been implemented yet.

I asked if we couldn't use u-boot as the boot loader, but I was turned down.
Personally I'm not happy about putting a lot stuff in a closed firmware, especially on a platform dedicated to getting kids into programming.

From the HAT specification:
GPIO pins ID_SC and ID_SD (GPIO0 and GPIO1) are reserved for use solely for board detection / identification. The only allowed connections to the ID_ pins are an ID EEPROM plus 3.9K pull up resistors. Do not connect anything else to these pins!

Ref:
https://github.com/raspberrypi/hats/blob/master/designguide.md#gpio-requirements

Quoted 6 lines

I asked in the forum if I could use an app for writing to the eeprom to change things like display rotation in the DT fragment, but was told that this
was a no-no. i2c0 is also used together with the camera port, which is then
controlled by the firmware.

The idea with the HAT specification is to provide a mechanism for hardware developers to add their drivers and configuration in such a way as to avoid 'special' kernel builds for particular bits of hardware (this was a problem with a number of DAC add on boards for the Pi)

There is software in the Raspberry Pi github to edit the EEPROM if you really want to (which would allow you to do that) but this isn't really the point for normal users and shouldn't be encouraged (just in case they break the information in the EEPROM).

Quoted 10 lines

When talking about firmware, there's also a /boot/dt-blob.bin used for configuring pins and clocks.

https://github.com/raspberrypi/documentation/blob/master/configuration/pin-configuration.md
This is the source of that file:
https://github.com/raspberrypi/documentation/blob/master/configuration/images/dt-blob.dts
I haven't studied this, so I don't know how/if it affects our work here.

The dt-blob.bin is a device tree blob that is specifically used to configure the binary blob initial gpio settings, if you look at the documentation you'll see the standard default dt-blob.bin In there are a number of different nodes specifically for the videocore blob, firstly they set up the gpio alternate settings and pin defaults and also assign pin numbers to pin functions for the binary blob, such as the HDMI_ATTACHED (hdmi hotplug gpio), obviously this pin is fixed on the B, B+, A but are programmable for the compute module... This allows hardware designers a little freedom when assigning pins which is very important when developing new hardware.

It does in some way effect you because in the long run, the two files are going to contain similar data (i.e. the initial state of the GPIOs and the alternate settings) and of course it's just bad design having to reproduce the same data in two places!

Quoted 6 lines

_______________________________________________
linux-rpi-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

#13 lore raw
In reply to Noralf Tronnes
Quoted 6 lines · Noralf Tronnes

Den 07.11.2014 05:22, skrev Stephen Warren:

Quoted 5 lines · Noralf Tronnes
Quoted 4 lines

Den 06.11.2014 00:45, skrev Matthias Klein:

Quoted 3 lines

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the
I2S interface.

...

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

arch/arm/boot/dts/bcm2835-rpi.dtsi line 47

Quoted 10 lines

+&i2c0 {

arch/arm/boot/dts/bcm2835-rpi.dtsi new file +9 -0
+    status = "okay";
+    clock-frequency = <100000>;
+};
+
+&i2c1 {
+    status = "okay";
+    clock-frequency = <100000>;
+};
+

Should the I2C busses be enabled by default?

Quoted 5 lines
Quoted 3 lines

Yes, I think so. Whichever I2C controllers are actually connected to something (even bare pins on an IO connector) should be enabled by the DT, so that they're available for use.

What makes i2c so special that it should be enabled by default?

I2C itself as a bus requires no configuration. If all you represent in DT is an enabled controller, it's quite possible for SW to then go and use the I2C bus in SW. Thus bus can be scanned to detect devices. The user can instruct SW what address to communicate with and how. Etc.

Quoted 1 line

SPI is not enabled

SPI devices require extra configuration; the chip-select must be configured for each device. It doesn't make sense to enable the SPI bus without actually defining which devices are attached to it.

Quoted 2 lines

and not 1wire, i2s, lirc either, they must be explicitly enabled.

I don't think there is a 1-wire controller on the RPi? There's certainly no pin on the expansion header (at least in A/B/B-rev2) that's labeled in a way that indicates 1-wire is the "default" purpose.

I2S typically requires other things to be set up to be useful, e.g. communication with a (typically I2C-based) CODEC to configure it before it'll accept I2S data.

lirc is more of a SW concept.

Quoted 2 lines

The problem I see, is that this is a newbie platform, and having pins driven increases the chance of shorting something.

In the case of I2C at least, the pins are always pulled high by the I2C pull-ups. Admittedly that's a weak drive. Either way though, you simply need to take care when hooking things up. There's simply no way for SW to make it completely fool-proof.

Quoted 1 line

And it's quite easy to enable these devices with fdtput.

DT include files might be better, or DT overlays.

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines

On Raspian, i2c is disabled
by blacklisting the module (/etc/modprobe.d/raspi-blacklist.conf). At least i2c0 should be left disabled due to the HAT EEPROM and camera. The bus number has also changed with revisions:
http://www.raspberrypi.org/forums/viewtopic.php?p=603950#p603950

It sounds like for I2C-0 on the B+ should use the i2c-mux-pinctrl.c to switch the bus between the two destinations as required, although we'd have to confirm with Broadcom or the RPi Foundation that that would work with this SoC.

Quoted 5 lines
Quoted 3 lines

There's certainly no reason to believe that the kernel wouldn't want to read the HAT EEPROM. After all, it has to identify what's connected there.

This will happen solely in the firmware.

Oh, given your comments below, does the firmware completely own I2C-0 both when it's used for EEPROM ID *and* when driving the camera module? I had assumed all control of the camera module would be performed via drivers in the Linux kernel, and hence I2C-0 would be driven by the Linux kernel I2C driver. If this isn't the case, we should indeed make sure that the kernel DTs don't touch the pinmux for the camera I2C port at all. It'd also be quite disappointing, since it would make it essentially impossible for anyone outside the RPi Foundation to connect a different camera module that required different programming over I2C.

Quoted 3 lines

The firmware reads the eeprom,
and if it contains a DT fragment, it is merged with the dtb before handing it over to the kernel. As far as I know, this hasn't been implemented yet.

Hmm. It sounds like it'd be much better if the EEPROM contained a board ID, and the board ID was passed into the kernel, which then used the (recently merged upstream) DT overlays feature to load the overlay DT once that kernel boots. IIUC this would also allow unloading and reloading the overlay DT during development of the DT overlay.

Quoted 2 lines

I asked if we couldn't use u-boot as the boot loader, but I was turned down.

I assume you mean in the official SD card images? Nothing is stopping anyone from using it; I use it without issue for example.

Quoted 2 lines

Personally I'm not happy about putting a lot stuff in a closed firmware, especially on a platform dedicated to getting kids into programming.

Indeed.

Quoted 6 lines

From the HAT specification:
GPIO pins ID_SC and ID_SD (GPIO0 and GPIO1) are reserved for use solely for board detection / identification. The only allowed connections to the ID_ pins are an ID EEPROM plus 3.9K pull up resistors. Do not connect anything else to these pins!

Quoted 8 lines

Ref:
https://github.com/raspberrypi/hats/blob/master/designguide.md#gpio-requirements

I asked in the forum if I could use an app for writing to the eeprom to change things like display rotation in the DT fragment, but was told that this
was a no-no. i2c0 is also used together with the camera port, which is then controlled by the firmware.

Oh, I see. See what I said about I2C-0 above.

Quoted 8 lines

When talking about firmware, there's also a /boot/dt-blob.bin used for configuring pins and clocks.
https://github.com/raspberrypi/documentation/blob/master/configuration/pin-configuration.md

This is the source of that file:
https://github.com/raspberrypi/documentation/blob/master/configuration/images/dt-blob.dts

I haven't studied this, so I don't know how/if it affects our work here.

Hmm. DT blobs for firmware:-(

#11 lore raw
In reply to Gordon Hollingworth
Quoted 3 lines · Gordon Hollingworth

Resend: HTML less...

Quoted 1 line · Gordon Hollingworth

On 7 November 2014 16:20, Noralf Tronnes <[email protected]> wrote:

...

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

From the HAT specification:
GPIO pins ID_SC and ID_SD (GPIO0 and GPIO1) are reserved for use solely for board detection / identification. The only allowed connections to the ID_ pins are an ID EEPROM plus 3.9K pull up resistors. Do not connect anything else to these pins!

Ref:
https://github.com/raspberrypi/hats/blob/master/designguide.md#gpio-requirements

I asked in the forum if I could use an app for writing to the eeprom to change things like display rotation in the DT fragment, but was told that this was a no-no. i2c0 is also used together with the camera port, which is then controlled by the firmware.

Quoted 4 lines
Quoted 4 lines

The idea with the HAT specification is to provide a mechanism for hardware developers to add their drivers and configuration in such a way as to avoid 'special' kernel builds for particular bits of hardware (this was a problem with a number of DAC add on boards for the Pi)

Have you considered using the (recently merged upstream) DT overlay mechanism instead? In this case, the board EEPROM would simply provide a unique ID for the board. Linux would obtain this ID somehow (perhaps directly reading the EEPROM on boot, or perhaps having some special DT node indicating which device was present if only the VC firmware can access the EEPROM). The ID then gets used to look up a DT overlay file that the kernel loads and merges into its DT at run-time. The benefit here is that the DT overlay is a file in the filesystem, and can be easily modified or replaced to fix issues, especially when first developing that DT for a new HAT. This is all based on the way the BeagleBone Black handles its capes. Having RPi work in a standard way that's also used on other boards leverages people's knowledge/experience across different HW stacks. Standards are good!

If I want to use U-Boot as a bootloader on the Pi, is there a VC firmware mailbox message that the firmware can use to read the content of the EEPROM (or the VC firmware's cached copy of it?) Or, must U-Boot be modified to accept a DT, extract information from it, and then modify the DT it subsequently passes to the kernel based on the DT it was passed?

#12 lore raw
Quoted 24 lines · Stephen Warren
Quoted 3 lines · Gordon Hollingworth

Resend: HTML less...

Quoted 1 line · Gordon Hollingworth

On 7 November 2014 16:20, Noralf Tronnes <[email protected]> wrote:

...

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

From the HAT specification:
GPIO pins ID_SC and ID_SD (GPIO0 and GPIO1) are reserved for use solely for board detection / identification. The only allowed connections to the ID_ pins are an ID EEPROM plus 3.9K pull up resistors. Do not connect anything else to these pins!

Ref:
https://github.com/raspberrypi/hats/blob/master/designguide.md#gpio-requirements

I asked in the forum if I could use an app for writing to the eeprom to change things like display rotation in the DT fragment, but was told that this was a no-no. i2c0 is also used together with the camera port, which is then controlled by the firmware.

Quoted 4 lines
Quoted 4 lines

The idea with the HAT specification is to provide a mechanism for hardware developers to add their drivers and configuration in such a way as to avoid 'special' kernel builds for particular bits of hardware (this was a problem with a number of DAC add on boards for the Pi)

Quoted 13 lines

Have you considered using the (recently merged upstream) DT overlay mechanism instead? In this case, the board EEPROM would simply provide a unique ID for the board. Linux would obtain this ID somehow (perhaps directly reading the EEPROM on boot, or perhaps having some special DT node indicating which device was present if only the VC firmware can access the EEPROM). The ID then gets used to look up a DT overlay file that the kernel loads and merges into its DT at run-time. The benefit here is that the DT overlay is a file in the filesystem, and can be easily modified or replaced to fix issues, especially when first developing that DT for a new HAT. This is all based on the way the BeagleBone Black handles its capes. Having RPi work in a standard way that's also used on other boards leverages people's knowledge/experience across different HW stacks. Standards are good!

Sounds good, I like the idea of implementing both capabilities, since it is possible
for the HAT EEPROM to contain different atoms containing different information it seems the HAT could contain a value overlay file to integrate and an ID. Then
the bootloader could check to see which one it will use based on whether a valid overlay file exists. The overlay file can then override the EEPROM, the reason this is useful is because often the time delay between releasing some new hardware
and getting it's software into the kernel and then getting the kernel into a Raspbian
release is quite long (mostly due to all the steps + testing + lead times on SD card images etc).

Quoted 6 lines

If I want to use U-Boot as a bootloader on the Pi, is there a VC firmware mailbox message that the firmware can use to read the content of the EEPROM (or the VC firmware's cached copy of it?) Or, must U-Boot be modified to accept a DT, extract information from it, and then modify the DT it subsequently passes to the kernel based on the DT it was passed?

Currently there is no interface to achieve this, but I'm having to implement something
similar for accessing the touchscreen on the new Raspberry Pi DSI screen so it seems
like it'd be a good addition.

#2 lore raw

PATCH v2 1/1 ARM: bcm2835: add device tree for Raspberry Pi model B+

In reply to Stephen Warren

Am 06.11.2014 um 06:11 schrieb Stephen Warren:

Quoted 10 lines · Matthias Klein
Quoted 2 lines

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

(On a model B rev 2, UART, SD card, and enumeration of built-in USB devices works fine)

Lee, how do you want to handle patches - will you apply them to the git repo?

Can you accept the patch, or do I have to rework something?

#14 lore raw
In reply to Matthias Klein
Quoted 10 lines

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

---
Changes in v2:
- move the common parts between the B and B+ model into the new bcm2835-rpi.dtsi file

- add the I2S signals to the B+ file which fix the problem that USB is not working with the current bcm2835-rpi-b.dts file on the B+.

Quoted 8 lines
---
 arch/arm/boot/dts/Makefile               |  1 +
 arch/arm/boot/dts/bcm2835-rpi-b-plus.dts | 30 +++++++++++++++++++
 arch/arm/boot/dts/bcm2835-rpi-b.dts      | 46 ++--------------------------
 arch/arm/boot/dts/bcm2835-rpi.dtsi       | 51 ++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+), 43 deletions(-)
 create mode 100644 arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
 create mode 100644 arch/arm/boot/dts/bcm2835-rpi.dtsi

Sorry for the delay. I thought RPi world was exceptionally quiet, but in fact I had issues with my newly setup mailbox and filters. All rectified now in any case.

It might be worth noting that this will not likely land in v3.19, as we are one step removed from Linus (i.e. via ARM SoC) and they usually like to have pull-requests in by -rc5. Unless anyone stamps their feet, I'll be sending this no sooner than v3.20.

Patch applied, thanks.

[...]

#15 lore raw
Quoted 19 lines · Lee Jones
Quoted 10 lines

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

---
Changes in v2:
- move the common parts between the B and B+ model into the new bcm2835-rpi.dtsi file

- add the I2S signals to the B+ file which fix the problem that USB is not working with the current bcm2835-rpi-b.dts file on the B+.

Quoted 8 lines
---
  arch/arm/boot/dts/Makefile               |  1 +
  arch/arm/boot/dts/bcm2835-rpi-b-plus.dts | 30 +++++++++++++++++++
  arch/arm/boot/dts/bcm2835-rpi-b.dts      | 46 ++--------------------------
  arch/arm/boot/dts/bcm2835-rpi.dtsi       | 51 ++++++++++++++++++++++++++++++++
  4 files changed, 85 insertions(+), 43 deletions(-)

create mode 100644 arch/arm/boot/dts/bcm2835-rpi-b-plus.dts create mode 100644 arch/arm/boot/dts/bcm2835-rpi.dtsi

Quoted 8 lines

Sorry for the delay. I thought RPi world was exceptionally quiet, but in fact I had issues with my newly setup mailbox and filters. All rectified now in any case.

It might be worth noting that this will not likely land in v3.19, as we are one step removed from Linus (i.e. via ARM SoC) and they usually like to have pull-requests in by -rc5. Unless anyone stamps their feet, I'll be sending this no sooner than v3.20.

-rc6 is the usual cut-off, and the arm-soc maintainers have said that's not always a very strict cut-off; it depends on how invasive the patch is (which this isn't) and whether the patch has been in linux-next already before getting into arm-soc (and linux-rpi.git's for-next branch is in linux-next).

#16 lore raw
Quoted 29 lines · Stephen Warren
Quoted 19 lines · Lee Jones
Quoted 10 lines

The model B and B+ differ in the GPIO lines for ACT and PWR leds, and the I2S interface.

---
Changes in v2:
- move the common parts between the B and B+ model into the new bcm2835-rpi.dtsi file

- add the I2S signals to the B+ file which fix the problem that USB is not working with the current bcm2835-rpi-b.dts file on the B+.

Quoted 8 lines
---
 arch/arm/boot/dts/Makefile               |  1 +
 arch/arm/boot/dts/bcm2835-rpi-b-plus.dts | 30 +++++++++++++++++++
 arch/arm/boot/dts/bcm2835-rpi-b.dts      | 46 ++--------------------------
 arch/arm/boot/dts/bcm2835-rpi.dtsi       | 51 ++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+), 43 deletions(-)
 create mode 100644 arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
 create mode 100644 arch/arm/boot/dts/bcm2835-rpi.dtsi
Quoted 8 lines

Sorry for the delay. I thought RPi world was exceptionally quiet, but in fact I had issues with my newly setup mailbox and filters. All rectified now in any case.

It might be worth noting that this will not likely land in v3.19, as we are one step removed from Linus (i.e. via ARM SoC) and they usually like to have pull-requests in by -rc5. Unless anyone stamps their feet, I'll be sending this no sooner than v3.20.

Quoted 5 lines

-rc6 is the usual cut-off, and the arm-soc maintainers have said that's not always a very strict cut-off; it depends on how invasive the patch is (which this isn't) and whether the patch has been in linux-next already before getting into arm-soc (and linux-rpi.git's for-next branch is in linux-next).

Okay, looks like I'm off-by-one -- I ways thought the cut-off was -rc5. Nevertheless, I'll have the patch in -next by tonight (tomorrow at the latest, as it's getting late and I need to wait for a previous test-build to finish before I can run this patch), let it stew there for a couple of weeks and fire them a pull-request around -rc6 and see what happens.