Description
I have a proposal for a way to get Device Tree support and move to ARCH_BCM2835.
Steps
- Enable the Common Clock framework (COMMON_CLK). This also works without DT.
Replaces arch/arm/mach-bcm2708/clock.c which is removed - Add bootloader option to set ATAG_MEM to usable memory only, and fill chosen/bootargs with the non-DT (extended) ATAG_CMDLINE.
I expand on this further down. - Add Device Tree IRQ mapping to arch/arm/mach-bcm2708/armctrl.c
GPIO interrupts is mapped to a virtual bank 3 since we can't use irq-bcm2835 (at least I couldn't get it to work). - Add Device Tree support to arch/arm/mach-bcm2708/bcm2708.c
- Add minimal Device Tree files
bcm2708.dtsi
bcm2708-rpi-b.dts - Enable Device Tree support (OF_USE)
At this point the kernel boots with Device Tree.
Platform devices can now be added through Device Tree.
Next steps
- Add pinctrl driver (modified version of pinctrl-bcm2835)
It provides DT support to the gpio_chip added in bcm2708_gpio - Add DT support to i2c-bcm2708 and spi-bcm2708
Move SPI/I2C devices to DT
It is also possible to enable i2c-bcm2835 and spi-bcm2835 as well. Testing can begin and maybe we can move to them sooner than later.
At this point SPI and I2C devices can also be added, and pins/GPIOs can be configured (in/out, alt0 etc.) in DT.
Move drivers to DT
Now the rest of the drivers can get DT support and the devices be moved from bcm2708.c to DT
(I have done most of these already in patches lying around)
At this point all devices are added through Device Tree.
Normal ATAG_CMDLINE
Now the normal ATAG_CMDLINE can be used for chosen/bootargs.
Normal chosen/bootargs
Now config.txt can be used for chosen/bootargs if preferred.
Start using dmaengine
Currently most of the drivers manipulate the DMA registers directly.
To remedy this, bcm2708-dmaengine/bcm2835-dma has to get support for slave_sg (I believe this is what is needed).
Then bcm2708_fb, sdhci-bcm2708 and others can start using dmaengine.
Mailbox driver
There is work going on upstream for this (Lubomir Rintel and others).
The Mailbox API isn't settled yet (latest patch version).
Drivers would need to start using this.
FIQ
We need to have FIQ support in ARCH_BCM2835.
I don't know if it is already supported in irq-bcm2835.
Is shortcut the same as FIQ?
At this point, switching to ARCH_BCM2835 should (hopefully) be close at hand.
Some of these steps can of course happen in parallel.
rpi-update
Maybe rpi-update could handle config.txt for Device Tree kernels.
If a .dtb is present
add DT options and use the .dtb
else
remove DT options if present.
VideoCore Bootloader in DT mode
Current behaviour and proposed changes (through a new config option or something similar if needed):
config.txt
device_tree=bcm2708-rpi-b.dtb
device_tree_address=0x100
disable_commandline_tags=1
ATAG_MEM
This is set to the amount of installed memory, not the part that's available to the CPU.
This requires a /memreserve/ node in DT to keep Linux from using memory it doesn't have.
The value of this node depends on the GPU/CPU memory split value in config.txt.
Changing this to available memory, removes the need for /memreserve/. This is how ARCH_BCM2835 expects it, and U-boot delivers it.
ATAG_CMDLINE
chosen/bootargs
This is the contents of cmdline.txt.
Changing this to the extended commandline used in non-DT mode, means no drivers have to be changed when moving to DT.
One caveat with the VC bootloader is that chosen/bootargs has to be prefilled with 1024 characters (COMMAND_LINE_SIZE), since the bootloader isn't equipped to allocate more space in the Device Tree.
The bootloader must have this ability to be able to boot vanilla Linux and pass in cmdline.txt.
libfdt is in use in many projects to provide Device Tree manipulation abilities (Linux, U-boot and others).
Example
I have a working example using a modified U-Boot to get the desired bootloader behaviour.
It sort of covers the steps up to SPI/I2C (it was made before this text was written).
Install
sudo REPO_URI=https://github.com/notro/rpi-firmware BRANCH=dt rpi-update
Patches used in this example:
Issue history
- Need help with Device Tree 2013-09-21
- Device tree population 2012-05-17