Skip to contentSkip to conversation

Integrator devicetree support

PATCH New Linus Walleij 3 participants 6 messages Aug 16, 2012 – Aug 30, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover Integrator devicetree support

This is a patch set for devicetree on the Integrator/AP and Integrator/CP I've been cooking. I did some stepwise development in recent kernels moving to sparse IRQs, per-system clock source then common clk. Now we can do single zImage and also devicetree on this platform, so this is a first patch set.

In case you're wondering why, take down your Torvalds autobiography and read the title. It was also a bit of learning exercise, plus it's fun to run devicetree on this ARMv4 system.

This patch set moves all the non-DT platform code into #ifndef CONFIG_OF sections for clarity. The plan is to delete them after deprecation.

Remaining roadblocks to deleting non-DT code altogether.

- Uncertain about how to do the fpga-irq DT binding so please review closely.

- The Integrator/AP ARM core tiles have add-on logic modules called Integrator/IM-PD1 with a load of PrimeCells and stuff. These spawn off a special bus called "lm" in arch/arm/mach-integrator/lm.c, and the core module support is in impd1.c. It'd probably be pretty easy to create device tree bindings for these, but I have no such module and no clue on where to get one. Is anyone actually using it? Russell?

- The special PCI adapter in the Integrator has to be DT:ed, but AFAICT there is still a problem with how to represent these things in DT. Any hints/examples, Arnd, Rob? arch/arm/mach-integrator/pci_v3.c

Yours,
Linus Walleij

Linus Walleij (6):
ARM: integrator: call common init function from machine
ARM: integrator: check PL010 device name rather than base address
ARM: plat-versatile: add DT support to FPGA IRQ controller
ARM: integrator: initial device tree support
ARM: integrator: convert AMBA devices to device tree
ARM: integrator: convert platform devices to Device Tree

 Documentation/devicetree/bindings/arm/arm-boards   |  12 +
 .../devicetree/bindings/arm/versatile-fpga-irq.txt |  35 +++
 arch/arm/boot/dts/integratorap.dts                 |  78 ++++++
 arch/arm/boot/dts/integratorcp.dts                 | 122 +++++++++
 arch/arm/mach-integrator/common.h                  |   3 +
 arch/arm/mach-integrator/core.c                    |  14 +-
 arch/arm/mach-integrator/integrator_ap.c           | 214 ++++++++++-----
 arch/arm/mach-integrator/integrator_cp.c           | 296 +++++++++++++--------
 arch/arm/plat-versatile/fpga-irq.c                 |  41 +++
 arch/arm/plat-versatile/include/plat/fpga-irq.h    |   2 +
 10 files changed, 640 insertions(+), 177 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/versatile-fpga-irq.txt
 create mode 100644 arch/arm/boot/dts/integratorap.dts
 create mode 100644 arch/arm/boot/dts/integratorcp.dts
Signature · 1 line
1.7.11.2
#1 lore raw

cover Integrator devicetree support

Quoted 3 lines · Linus Walleij

This patch set moves all the non-DT platform code into #ifndef CONFIG_OF sections for clarity. The plan is to delete them after deprecation.

I'm fine with your playing around with this in any way you like, but I think in general we should have a new CONFIG_ATAG symbol, so you can build a kernel that supports booting both with and without DT for the same platform, depending on what the boot loader supports.

Then you can enclose all the non-DT sections in #ifdef CONFIG_ATAG and we can remove them at some later stage.

Quoted 4 lines

- The special PCI adapter in the Integrator has to be DT:ed, but AFAICT there is still a problem with how to represent these things in DT. Any hints/examples, Arnd, Rob? arch/arm/mach-integrator/pci_v3.c

PCI bindings are a bit tricky but they are well-defined, see www.openfirmware.org/ofwg/bindings/pci/pci2_1.pdf

The main thing to understand is the use of 3-cell address spaces and the interrupt map. Each PCI host must have

         #interrupt-cells = <1>;
         #size-cells = <2>;
         #address-cells = <3>;

The "ranges" property is used to transform the PCI address space into the host address space.

The first cell identifies the device and address space using a bit-masked notation. The important part to know here is

0x00000000 config space
0x01000000 I/O space
0x02000000 memory space
0x03000000 64 bit memory space
0x42000000 memory space, prefetchable
0x43000000 64 bit memory space, prefetchable

Each entry in the ranges property consists of 3 cells for the PCI address start, one cell for a 32 bit parent but start address where this is mapped, and two cells for the size.
For your bus, the ranges then would be defined as

ranges = <0x00000000 0x00000000 0x00000000 /* configuration space: */

	  0x61000000 0x00000000 0x00100000 /* 16 MB at 61000000    */
	  0x01000000 0x00000000 0x00000000 /* I/O space:	   */
	  0x60000000 0x00000000 0x00010000 /* 64KB@0x60000000   */
	  0x02000000 0x00000000 0x40000000 /* non-prefetchable mem */
	  0x40000000 0x00000000 0x10000000 /* identity-mapped      */
	  0x42000000 0x00000000 0x50000000 /* prefetchable mem     */
	  0x50000000 0x00000000 0x10000000> /* identity-mapped     */

I'm not quite sure if I understood the comments about LB_BASE0 etc correctly, so it might actually be different.

You also need an interrupt-map, which maps the slots to the connected irq lines in a board-specific way:

interrupt-map = <

	/* IDSEL 9 */
	0x4800 0 0 1 &pic 14 /* INT A on slot 9 is irq 14 */
	0x4800 0 0 2 &pic 15 /* INT B on slot 9 is irq 15 */
	0x4800 0 0 3 &pic 16 /* INT C on slot 9 is irq 16 */
	0x4800 0 0 4 &pic 17 /* INT D on slot 9 is irq 17 */

	/* IDSEL 10 */
	0x5000 0 0 1 &pic 15 /* INT A on slot 10 is irq 15 */
	0x5000 0 0 2 &pic 16 /* INT B on slot 10 is irq 16 */
	0x5000 0 0 3 &pic 17 /* INT C on slot 10 is irq 17 */
	0x5000 0 0 4 &pic 14 /* INT D on slot 10 is irq 18 */

	/* IDSEL 11 */
	0x5800 0 0 1 &pic 16 /* INT A on slot 11 is irq 16 */
	0x5800 0 0 2 &pic 17 /* INT B on slot 11 is irq 17 */
	0x5800 0 0 3 &pic 14 /* INT C on slot 11 is irq 18 */
	0x5800 0 0 4 &pic 15 /* INT D on slot 11 is irq 14 */

	/* IDSEL 12 */
	0x6000 0 0 1 &pic 17 /* INT A on slot 12 is irq 17 */
	0x6000 0 0 2 &pic 14 /* INT B on slot 12 is irq 14 */
	0x6000 0 0 3 &pic 15 /* INT C on slot 12 is irq 15 */
	0x6000 0 0 4 &pic 16 /* INT D on slot 12 is irq 16 */
	>;

	Arnd
#2 lore raw

cover Integrator devicetree support

Quoted 5 lines · Arnd Bergmann
Quoted 3 lines · Linus Walleij

This patch set moves all the non-DT platform code into #ifndef CONFIG_OF sections for clarity. The plan is to delete them after deprecation.

Quoted 8 lines

I'm fine with your playing around with this in any way you like, but I think in general we should have a new CONFIG_ATAG symbol, so you can build a kernel that supports booting both with and without DT for the same platform, depending on what the boot loader supports.

Then you can enclose all the non-DT sections in #ifdef CONFIG_ATAG and we can remove them at some later stage.

Since we already have CONFIG_USE_OF I think CONFIG_USE_ATAGS is more apropriate, but I get the idea. So it begins like this:

arch/arm/Kconfig +7 -0
index e91c7cd..0764ef7 100644
@@ -1907,6 +1907,12 @@ endmenu
 
 menu "Boot options"
 
+config USE_ATAGS
+       bool "ATAGS support"
+       default y
+       help
+         Include support for ATAGS-based machine descriptions.
+
 config USE_OF
        bool "Flattened Device Tree support"
        select OF
@@ -2110,6 +2116,7 @@ config KEXEC
 
 config ATAGS_PROC
        bool "Export atags in procfs"
+       depends on USE_ATAGS
        depends on KEXEC
        default y
        help

But then we hit #ifdeffing and compiling out a lot of dangerous stuff in arch/arm/kernel and then I get the creeps. I can try, but I think this is typical Nico territory for example...

Yours,
Linus Walleij

#3 lore raw

cover Integrator devicetree support

Quoted 3 lines · Linus Walleij

Since we already have CONFIG_USE_OF I think CONFIG_USE_ATAGS is more apropriate, but I get the idea.

There is both CONFIG_USE_OF and CONFIG_OF. The former is what a platform selects and it turns on a few other options as well, while the latter is the one that you typically check in #ifdef.

We might need both of them for ATAG as well, but I think if we have just one, CONFIG_ATAGS or CONFIG_ATAG would be nicer because it's slightly shorter.

Quoted 28 lines

So it begins like this:

arch/arm/Kconfig +7 -0
index e91c7cd..0764ef7 100644
@@ -1907,6 +1907,12 @@ endmenu
 
 menu "Boot options"
 
+config USE_ATAGS
+       bool "ATAGS support"
+       default y
+       help
+         Include support for ATAGS-based machine descriptions.
+
 config USE_OF
        bool "Flattened Device Tree support"
        select OF
@@ -2110,6 +2116,7 @@ config KEXEC
 
 config ATAGS_PROC
        bool "Export atags in procfs"
+       depends on USE_ATAGS
        depends on KEXEC
        default y
        help
Quoted 3 lines

But then we hit #ifdeffing and compiling out a lot of dangerous stuff in arch/arm/kernel and then I get the creeps. I can try, but I think this is typical Nico territory for example...

We don't have to enclose every single usage of ATAGS with this, but I think it's helpful in platforms that you want to migrate away from ATAG to DT-only. I think we should also use this method in mach-ux500, for instance.

Putting MACHINE_START and DT_MACHINE_START inside of CONFIG_ATAG and CONFIG_OF respectively would help ensure that we don't accidentally build support for a board that cannot work.

Arnd

#4 lore raw

cover Integrator devicetree support

In reply to Linus Walleij
Quoted 3 lines · Linus Walleij

But then we hit #ifdeffing and compiling out a lot of dangerous stuff in arch/arm/kernel and then I get the creeps. I can try, but I think this is typical Nico territory for example...

I did post a patch moving all the ATAG stuff to a separate source file a while ago, exactly for that purpose. I should try to dig it out and refresh it.

Nicolas

#5 lore raw

cover Integrator devicetree support

Quoted 9 lines · Nicolas Pitre
Quoted 3 lines · Linus Walleij

But then we hit #ifdeffing and compiling out a lot of dangerous stuff in arch/arm/kernel and then I get the creeps. I can try, but I think this is typical Nico territory for example...

I did post a patch moving all the ATAG stuff to a separate source file a while ago, exactly for that purpose. I should try to dig it out and refresh it.

OK... In this case "a while ago" = 2 years!

Please see the 2 patches to follow.

Nicolas