devicetree: bcm2835:

Stephen Warren swarren at
Fri Aug 14 20:04:22 PDT 2015

On 08/10/2015 11:53 PM, Martin Sperl wrote:
> On 11.08.2015 06:21, Stephen Warren wrote:
>> On 08/10/2015 02:41 AM, Martin Sperl wrote:
>>> Hi!
>>> When adding a gpio section to enable the auxiliar spi device pins
>>> with the correct mode to the bcm2835 device treesimilar to this:
>>>          /* SPI1 pins */
>>>          spi1_pins: spi1_pins {
>>>                  brcm,pins = <19 20 21>;
>>>                  brcm,function = <BCM2835_FSEL_ALT4>
>>>          };
>>>          /* SPI1 GPIO-chipselects */
>>>          spi1_cs_pins: spi1_cs_pins {
>>>                  brcm,pins = <18 17 16>;
>>>                  brcm,function = <BCM2835_FSEL_OUT>;
>>>          };
>>>          /* SPI2 pins */
>>>          spi2_pins: spi2_pins {
>>>                  brcm,pins = <40 41 42>;
>>>                  brcm,function = <BCM2835_FSEL_ALT4>;
>>>          };
>>>          /* SPI2 GPIO-chipselects */
>>>          spi2_cs_pins: spi2_cs_pins {
>>>                  brcm,pins = <43 44 45>;
>>>                  brcm,function = <BCM2835_FSEL_OUT>
>>>          };
>> You don't need to add all that to the SPI node. Just set up the existing
>> pinctrl configurations in the pinctrl node as you need them. Per-device
>> DT configuration nodes are useful if you need to do dynamic pinmuxing,
>> but there's no need for that to simply set up the usage of the SPI/I2C
>> pins at boot.
> So does this mean I should NOT provide some default dt-configs for the
> device tree pin-mux when sending the patch?

I would expect a patch that adds the SPI device into bcm2835.dtsi, and
sets it to disabled by default, since it's board- and user-specific
whether the SPI controller is actually used or not.

> So why do we have PWM0 pin-modes configured in
> arch/arm/boot/dts/bcm2835-rpi.dtsi
> and I2S in arch/arm/boot/dts/bcm2835-rpi-b.dts and in
> arch/arm/boot/dts/bcm2835-rpi-b-plus.dts.

I don't see any pins set to any PWM function.

The RPi pinmux content in the DT files is a bit of a mess right now. The
default DTs should not configure any pins that are on the expansion
header, since there is no way to know what a user has attached to those
pins. All expansion pins should be left set to the HW default, i.e. GPIO
in. Unfortunately that's not the case right now.

The end-user is the only person who knows what they've attached to their
system. They should edit the device tree (or perhaps supply DT overlays
or similar) to describe the pin usage they want.

Of course, for pins that connect to on-board peripherals, the default DT
can and should set up those pins to the appropriate configuration. That
makes sense since there's only one way those pins can possibly be used,
so we can hard-coded that one configuration.

> Would we need separate device-trees (dts) to use spi1/2?
> e.g arch/arm/boot/dts/bcm2835-rpi-b-auxspi.dts
> Note that this would also require that PIN 40 configuration gets moved
> out ?

Yes, a cleanup of the DT files is something that should happen.

> Just wanting to make sure that there is nothing missing when I submit
> the patches for spi-bcm2835aux (plus the bcm2835-aux enable driver).

More information about the linux-rpi-kernel mailing list