ARM: integrator: call common init function from machine
Subsystems (3)
PATCH v2 1/6 ARM: integrator: call common init function from machine
There is currently a common integrator_init() function set up to be called from an arch_initcall(). The problem is that it is using machine_is_integrator() which is not working with device tree, let's call this from respective machine initilization function and add a parameter to tell whether it's the Integrator/AP or Integrator/CP instead.
There are still machine_is*() calls in the Integrator machines directory, but this one needs to be fixed lest we don't even get a UART console on the Integrator/AP after a Device Tree boot.
--- arch/arm/mach-integrator/common.h | 1 + arch/arm/mach-integrator/core.c | 6 ++---- arch/arm/mach-integrator/integrator_ap.c | 2 ++ arch/arm/mach-integrator/integrator_cp.c | 1 + 4 files changed, 6 insertions(+), 4 deletions(-)
arch/arm/mach-integrator/common.h +1 -0
@@ -1,3 +1,4 @@void integrator_init_early (void ); +int integrator_init (bool is_cp);void integrator_reserve (void );void integrator_restart (char ,const char *);
arch/arm/mach-integrator/core.c +2 -4
@@ -61,7 +61,7 @@ static struct amba_device *amba_devs[] __initdata = { &kmi1_device, }; -static int __init integrator_init (void ) +int __init integrator_init (bool is_cp) {int i;
@@ -70,7 +70,7 @@ static int __init integrator_init(void)* hard-code them. The Integator/CP and forward have proper cell IDs. * Else we leave them undefined to the bus driver can autoprobe them. */ -if (machine_is_integrator ()) { +if (!is_cp) { rtc_device.periphid =0x00041030 ; uart0_device.periphid =0x00041010 ; uart1_device.periphid =0x00041010 ;
@@ -86,8 +86,6 @@ static int __init integrator_init(void)return 0 ; } -arch_initcall (integrator_init); -/* * On the Integrator platform, the port RTS and DTR are provided by * bits in the following SC_CTRLS register bits:
arch/arm/mach-integrator/integrator_ap.c +2 -0
@@ -312,6 +312,8 @@ static void __init ap_init(void)lm_device_register (lmdev); } + +integrator_init (false); }/*
arch/arm/mach-integrator/integrator_cp.c +1 -0
@@ -366,6 +366,7 @@ static void __init intcp_init(void)struct amba_device *d = amba_devs[i];amba_device_register (d, &iomem_resource); } +integrator_init (true); }#define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE)
Signature · 1 line
1.7.11.4
PATCH v2 2/6 ARM: integrator: check PL010 device name rather than base address
In the PL010 UART callback a comparison against the base address is done to figure out which UART is doing the callback. This does not play well with device tree, so let's check the dev_name() of the device instead.
--- arch/arm/mach-integrator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-integrator/core.c +1 -1
@@ -100,7 +100,7 @@ static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *bas {unsigned int ctrls =0 , ctrlc =0 , rts_mask, dtr_mask; -if (dev == &uart0_device) { +if (!strcmp (dev_name (&dev->dev),"uart0" )) { rts_mask =1 <<4 ; dtr_mask =1 <<5 ; }else {
Signature · 1 line
1.7.11.4
PATCH v2 3/6 ARM: plat-versatile: add DT support to FPGA IRQ controller
This adds Device Tree probing support to the Versatile FPGA IRQ controller.
---
ChangeLog v1->v2:
- Stop passing the Linux IRQ number in the DT node, bad idea. Register descriptors dynamically, and use whatever IRQ number base we get. Assume we will switch everything using this over to DT and live with it.
--- .../devicetree/bindings/arm/versatile-fpga-irq.txt | 31 ++++++++++++++ arch/arm/plat-versatile/fpga-irq.c | 47 ++++++++++++++++++++++ arch/arm/plat-versatile/include/plat/fpga-irq.h | 2 + 3 files changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/versatile-fpga-irq.txt
Documentation/devicetree/bindings/arm/versatile-fpga-irq.txt new file +31 -0
@@ -0,0 +1,31 @@ +* ARM Versatile FPGA interrupt controller + +One or more FPGA IRQ controllers can be synthesized in an ARM reference board +such as the Integrator or Versatile family. The output of these different +controllers are OR:ed together and fed to the CPU tile's IRQ input. Each +instance can handle up to 32 interrupts. + +Required properties: +- compatible: "arm,versatile-fpga-irq" +- interrupt-controller: Identifies the node as an interrupt controller +- #interrupt-cells: The number of cells to define the interrupts. Must be 1 + as the FPGA IRQ controller has no configuration options for interrupt + sources. The cell is a u32 and defines the interrupt number. +- reg: The register bank for the FPGA interrupt controller. +- clear-mask: a u32 number representing the mask written to clear all IRQs + on the controller at boot for example. +- valid-mask: a u32 number representing a bit mask determining which of + the interrupts are valid. Unconnected/unused lines are set to 0, and + the system till not make it possible for devices to request these + interrupts. + +Example: + +pic: pic at 14000000 { + compatible = "arm,versatile-fpga-irq"; + #interrupt-cells = <1>; + interrupt-controller; + reg = <0x14000000 0x100>; + clear-mask = <0xffffffff>; + valid-mask = <0x003fffff>; +};
arch/arm/plat-versatile/fpga-irq.c +47 -0
62 lines not on this page · raw message
arch/arm/plat-versatile/include/plat/fpga-irq.h +2 -0
@@ -7,5 +7,7 @@ struct pt_regs;void fpga_handle_irq (struct pt_regs *regs);void fpga_irq_init (void __iomem *,const char *,int ,int ,u32 ,struct device_node *node); +int fpga_irq_of_init (struct device_node *node, +struct device_node *parent);#endif
Signature · 1 line
1.7.11.4
PATCH v2 4/6 ARM: integrator: initial device tree support
This is initial device tree support for the ARM Integrator family, we create a very basic device tree, #ifdef out the non-DT machines when compiling for device tree.
---
ChangeLog v1->v2:
- Also switch over clocksource and clockevent to device tree. Else the IRQ mapping goes bananas.
--- Documentation/devicetree/bindings/arm/arm-boards | 12 ++ arch/arm/boot/dts/integratorap.dts | 51 ++++++++ arch/arm/boot/dts/integratorcp.dts | 69 ++++++++++ arch/arm/mach-integrator/integrator_ap.c | 137 ++++++++++++++++---- arch/arm/mach-integrator/integrator_cp.c | 152 ++++++++++++++++------- 5 files changed, 353 insertions(+), 68 deletions(-) create mode 100644 arch/arm/boot/dts/integratorap.dts create mode 100644 arch/arm/boot/dts/integratorcp.dts
Documentation/devicetree/bindings/arm/arm-boards +12 -0
@@ -1,3 +1,15 @@ +ARM Integrator/AP (Application Platform) and Integrator/CP (Compact Platform) +----------------------------------------------------------------------------- +ARM's oldest Linux-supported platform with connectors for different core +tiles of ARMv4, ARMv5 and ARMv6 type. + +Required properties (in root node): + compatible = "arm,integrator-ap"; /* Application Platform */ + compatible = "arm,integrator-cp"; /* Compact Platform */ + +FPGA type interrupt controllers, see the versatile-fpga-irq binding doc. + + ARM Versatile Application and Platform Baseboards ------------------------------------------------- ARM's development hardware platform with connectors for customizable
arch/arm/boot/dts/integratorap.dts new file +51 -0
51 lines not on this page · raw message
arch/arm/boot/dts/integratorcp.dts new file +69 -0
69 lines not on this page · raw message
arch/arm/mach-integrator/integrator_ap.c +112 -25
201 lines not on this page · raw message
arch/arm/mach-integrator/integrator_cp.c +109 -43
182 lines not on this page · raw message
Signature · 1 line
1.7.11.4
PATCH v2 5/6 ARM: integrator: convert AMBA devices to device tree
This converts the AMBA (PrimeCell) devices on the Integrator/AP and Integrator/CP over to probing from the Device Tree if the kernel is compiled for Device Tree support.
We continue to #ifdef out all non-DT code and vice versa on respective boot type to get a clean cut.
We need to add a bunch of auxdata (compare to the Versatile) to handle bus names and callbacks alike.
---
ChangeLog v1->v2:
- Move interrupt-parent up one step to the fpga bus for the PrimeCell devices. (Suggestion from Arnd Bergmann)
--- arch/arm/boot/dts/integratorap.dts | 43 ++++++++++++ arch/arm/boot/dts/integratorcp.dts | 57 ++++++++++++++++ arch/arm/mach-integrator/common.h | 2 + arch/arm/mach-integrator/core.c | 8 ++- arch/arm/mach-integrator/integrator_ap.c | 109 ++++++++++++++++++++++--------- arch/arm/mach-integrator/integrator_cp.c | 84 ++++++++++++++++++------ 6 files changed, 250 insertions(+), 53 deletions(-)
arch/arm/boot/dts/integratorap.dts +43 -0
@@ -48,4 +48,47 @@ clear-mask = <0xffffffff>; valid-mask = <0x003fffff>; }; + + fpga { + compatible = "arm,amba-bus", "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + interrupt-parent = <&pic>; + + rtc: rtc at 15000000 { + compatible = "arm,pl031", "arm,primecell"; + reg = <0x15000000 0x1000>; + interrupts = <8>; + arm,primecell-periphid = <0x00041030>; + }; + + uart0: uart at 16000000 { + compatible = "arm,pl011", "arm,primecell"; + reg = <0x16000000 0x1000>; + interrupts = <1>; + arm,primecell-periphid = <0x00041010>; + }; + + uart1: uart at 17000000 { + compatible = "arm,pl011", "arm,primecell"; + reg = <0x17000000 0x1000>; + interrupts = <2>; + arm,primecell-periphid = <0x00041010>; + }; + + kmi0: kmi at 18000000 { + compatible = "arm,pl050", "arm,primecell"; + reg = <0x18000000 0x1000>; + interrupts = <3>; + arm,primecell-periphid = <0x00041050>; + }; + + kmi1: kmi at 19000000 { + compatible = "arm,pl050", "arm,primecell"; + reg = <0x19000000 0x1000>; + interrupts = <4>; + arm,primecell-periphid = <0x00041050>; + }; + }; };
arch/arm/boot/dts/integratorcp.dts +57 -0
61 lines not on this page · raw message
arch/arm/mach-integrator/common.h +2 -0
@@ -1,3 +1,5 @@ +#include <linux/amba/serial.h> +extern struct amba_pl010_data integrator_uart_data;void integrator_init_early (void );int integrator_init (bool is_cp);void integrator_reserve (void );
arch/arm/mach-integrator/core.c +6 -2
@@ -33,7 +33,9 @@#include <asm/mach/time.h> #include <asm/pgtable.h> -static struct amba_pl010_data integrator_uart_data; +#include "common.h" + +#ifndef CONFIG_OF #define INTEGRATOR_RTC_IRQ { IRQ_RTCINT }#define INTEGRATOR_UART0_IRQ { IRQ_UARTINT0 }
@@ -86,6 +88,8 @@ int __init integrator_init(bool is_cp) return 0; } +#endif +/* * On the Integrator platform, the port RTS and DTR are provided by * bits in the following SC_CTRLS register bits:
@@ -122,7 +126,7 @@ static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *bas__raw_writel (ctrlc,SC_CTRLC ); } -static struct amba_pl010_data integrator_uart_data = { +struct amba_pl010_data integrator_uart_data = { .set_mctrl = integrator_uart_set_mctrl, };
arch/arm/mach-integrator/integrator_ap.c +78 -31
139 lines not on this page · raw message
arch/arm/mach-integrator/integrator_cp.c +64 -20
120 lines not on this page · raw message
Signature · 1 line
1.7.11.4
PATCH v2 6/6 ARM: integrator: convert platform devices to Device Tree
This moves the physmap flash and SMSC91x ethernet devices over to the device tree, moving the static board code down into the #ifndef CONFIG_OF section.
--- arch/arm/boot/dts/integratorap.dts | 5 ++ arch/arm/boot/dts/integratorcp.dts | 12 +++++ arch/arm/mach-integrator/integrator_ap.c | 36 ++++++------- arch/arm/mach-integrator/integrator_cp.c | 92 ++++++++++++++++---------------- 4 files changed, 82 insertions(+), 63 deletions(-)
arch/arm/boot/dts/integratorap.dts +5 -0
@@ -49,6 +49,11 @@ valid-mask = <0x003fffff>; }; + flash: flash at 24000000 { + compatible = "cfi-flash"; + reg = <0x24000000 0x02000000>; + }; + fpga { compatible = "arm,amba-bus", "simple-bus"; #address-cells = <1>;
arch/arm/boot/dts/integratorcp.dts +12 -0
@@ -67,6 +67,18 @@ valid-mask = <0x00000fff>; }; + flash: flash at 24000000 { + compatible = "cfi-flash"; + reg = <0x24000000 0x02000000>; + }; + + ethernet: ethernet at c8000000 { + compatible = "smsc,lan91c111"; + reg = <0xc8000000 0x10>; + interrupt-parent = <&pic>; + interrupts = <27>; + }; + fpga { compatible = "arm,amba-bus", "simple-bus"; #address-cells = <1>;
arch/arm/mach-integrator/integrator_ap.c +18 -18
@@ -256,22 +256,6 @@ static struct physmap_flash_data ap_flash_data = { .set_vpp = ap_flash_set_vpp, }; -static struct resource cfi_flash_resource = { - .start =INTEGRATOR_FLASH_BASE , - .end =INTEGRATOR_FLASH_BASE +INTEGRATOR_FLASH_SIZE -1 , - .flags =IORESOURCE_MEM , -}; - -static struct platform_device cfi_flash_device = { - .name ="physmap-flash" , - .id =0 , - .dev = { - .platform_data = &ap_flash_data, - }, - .num_resources =1 , - .resource = &cfi_flash_resource, -}; -/* * Where is the timer (VA)? */
@@ -476,6 +460,8 @@ static struct of_dev_auxdata ap_auxdata_lookup[] __initdata = { "kmi0", NULL), OF_DEV_AUXDATA("arm,primecell", KMI1_BASE, "kmi1", NULL), + OF_DEV_AUXDATA("cfi-flash", INTEGRATOR_FLASH_BASE, + "physmap-flash", &ap_flash_data), { /* sentinel */ }, };
@@ -487,8 +473,6 @@ static void __init ap_init_of(void)of_platform_populate (NULL , of_default_bus_match_table, ap_auxdata_lookup,NULL ); -platform_device_register (&cfi_flash_device); - sc_dec =readl (VA_SC_BASE +INTEGRATOR_SC_DEC_OFFSET );for (i =0 ; i <4 ; i++) {struct lm_device *lmdev;
@@ -535,6 +519,22 @@ MACHINE_END* for eventual deletion. */ +static struct resource cfi_flash_resource = { + .start =INTEGRATOR_FLASH_BASE , + .end =INTEGRATOR_FLASH_BASE +INTEGRATOR_FLASH_SIZE -1 , + .flags =IORESOURCE_MEM , +}; + +static struct platform_device cfi_flash_device = { + .name ="physmap-flash" , + .id =0 , + .dev = { + .platform_data = &ap_flash_data, + }, + .num_resources =1 , + .resource = &cfi_flash_resource, +}; +static void __init ap_init_timer (void ) {struct clk *clk;
arch/arm/mach-integrator/integrator_cp.c +47 -45
125 lines not on this page · raw message
Signature · 1 line
1.7.11.4
PATCH v2 4/6 ARM: integrator: initial device tree support
In reply to Linus WalleijQuoted 12 lines · Linus Walleij
arch/arm/boot/dts/integratorcp.dts new file +6
-0@@ -0,0 +1,69 @@ +/* + * Device Tree for the ARM Integrator/CP platform + */ + +/dts-v1/; +/include/ "skeleton.dtsi"
arch/arm/boot/dts/integratorcp.dts line 16
Quoted 10 lines
arch/arm/boot/dts/integratorcp.dts new file +10
-0+ +/ { + model = "ARM Integrator/CP"; + compatible = "arm,integrator-cp"; + ranges; + + aliases { + arm,integrator-clocksource = &timer2; + arm,integrator-clockevent = &timer1; + };
It looks like this file is almost a direct superset of the integratorap.dts file. How about including the other file from here and just adding the extra nodes and overriding the few bits that are actually different?
Quoted 3 lines
arch/arm/boot/dts/integratorcp.dts new file +2
-0+#ifdef CONFIG_OF +
...
Quoted 15 lines
arch/arm/boot/dts/integratorcp.dts new file +15
-0+DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)") + .reserve = integrator_reserve, + .map_io = ap_map_io, + .nr_irqs = NR_IRQS_INTEGRATOR_AP, + .init_early = ap_init_early, + .init_irq = ap_init_irq_of, + .handle_irq = fpga_handle_irq, + .timer = &ap_of_timer, + .init_machine = ap_init, + .restart = integrator_restart, + .dt_compat = ap_dt_board_compat, +MACHINE_END + +#else +
...
arch/arm/boot/dts/integratorcp.dts MACHINE_START(INTEGRATOR, "ARM-Integrator") · line 575
Quoted 9 lines
MACHINE_START(INTEGRATOR, "ARM-Integrator")arch/arm/boot/dts/integratorcp.dts new file +2
-0/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ .atag_offset = 0x100,@@ -486,3 +571,5 @@ MACHINE_START(INTEGRATOR, "ARM-Integrator") .init_machine = ap_init, .restart = integrator_restart, MACHINE_END + +#endif
I think we discussed this before. It would be nice to replace the #if/#else with
#ifdef CONFIG_OF
...
#endif
#ifdef CONFIG_ATAG
...
#endif
so you can actually support both in the same binary. The other alternative would be to remove the ATAG boot capability right away, as some other platforms have done when they moved to DT.
Arnd
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 15 lines · Arnd Bergmann
arch/arm/boot/dts/integratorcp.dts line 16
Quoted 10 lines · Linus Walleij
arch/arm/boot/dts/integratorcp.dts +9
-0+/ { + model = "ARM Integrator/CP"; + compatible = "arm,integrator-cp"; + ranges; + + aliases { + arm,integrator-clocksource = &timer2; + arm,integrator-clockevent = &timer1; + };It looks like this file is almost a direct superset of the
integratorap.dtsfile. How about including the other file from here and just adding the extra nodes and overriding the few bits that are actually different?
Isn't it more apropriate to create an integrator.dtsi for the common stuff and include that into integratorap.dts and integratorcp.dts?
Quoted 32 lines
Quoted 2 lines
arch/arm/boot/dts/integratorcp.dts +2
-0+#ifdef CONFIG_OF +...
Quoted 15 lines
arch/arm/boot/dts/integratorcp.dts +15
-0+DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)") + .reserve = integrator_reserve, + .map_io = ap_map_io, + .nr_irqs = NR_IRQS_INTEGRATOR_AP, + .init_early = ap_init_early, + .init_irq = ap_init_irq_of, + .handle_irq = fpga_handle_irq, + .timer = &ap_of_timer, + .init_machine = ap_init, + .restart = integrator_restart, + .dt_compat = ap_dt_board_compat, +MACHINE_END + +#else +...
arch/arm/boot/dts/integratorcp.dts MACHINE_START(INTEGRATOR, "ARM-Integrator") · line 575
Quoted 9 lines
MACHINE_START(INTEGRATOR, "ARM-Integrator")/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ .atag_offset = 0x100,arch/arm/boot/dts/integratorcp.dts +2
-0@@ -486,3 +571,5 @@ MACHINE_START(INTEGRATOR, "ARM-Integrator") .init_machine = ap_init, .restart = integrator_restart, MACHINE_END + +#endifI think we discussed this before. It would be nice to replace the #if/#else with
Quoted 6 lines
#ifdef
CONFIG_OF
...
#endif
#ifdefCONFIG_ATAG
...
#endif
Sure, have you applied Nico's patch adding CONFIG_ATAG to and ARM SoC branch so I can base my patches on it?
I was under the impression that his patch would go through Russell's tree and I would thus not be able to rely on it until it has landed there and you have pulled Russell's stuff into your tree.
Currently I would make it impossible to use ATAGs if I do this since the symbol does not exist, so I really need to base such an approach in a tree which has CONFIG_ATAG in the first place.
Yours,
Linus Walleij
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 11 lines · Linus Walleij
Quoted 9 lines · Arnd Bergmann
I think we discussed this before. It would be nice to replace the #if/#else with
#ifdef
CONFIG_OF
...
#endif
#ifdefCONFIG_ATAG
...
#endif
Quoted 6 lines
Sure, have you applied Nico's patch adding
CONFIG_ATAGto and ARM SoC branch so I can base my patches on it?I was under the impression that his patch would go through Russell's tree and I would thus not be able to rely on it until it has landed there and you have pulled Russell's stuff into your tree.
One of them is already in my tree - I put it in on Saturday though on an unstable branch.
Quoted 3 lines
Currently I would make it impossible to use ATAGs if I do this since the symbol does not exist, so I really need to base such an approach in a tree which has
CONFIG_ATAGin the first place.
I've just merged that patch though.
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 6 lines · Russell King - ARM Linux
[Me]
Quoted 3 lines
Currently I would make it impossible to use ATAGs if I do this since the symbol does not exist, so I really need to base such an approach in a tree which has
CONFIG_ATAGin the first place.I've just merged that patch though.
OK great, Arnd do you have a Russell baseline in ARM SoC or is it easier if I try to submit this series directly to Russell?
Yours,
Linus Walleij
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 11 lines · Linus Walleij
Quoted 6 lines · Russell King - ARM Linux
[Me]
Quoted 3 lines
Currently I would make it impossible to use ATAGs if I do this since the symbol does not exist, so I really need to base such an approach in a tree which has
CONFIG_ATAGin the first place.I've just merged that patch though.
OK great, Arnd do you have a Russell baseline in ARM SoC or is it easier if I try to submit this series directly to Russell?
Since Russell said he hasn't applied it to a stable branch we can't pull anything in yet. But once he does, especially if he does it on a separate topic branch, we can easily pull that in as a prerequisite in arm-soc. Russell?
There probably isn't much conflicting development in this release cycle on integrator though, so having all changes go through Russell could be OK as well. Only time that becomes awkward is if there's changes in both trees that end up needing manual merge resolution. I don't think that's high risk in this case.
So, Linus, it's up to you (and Russell) what you prefer, but I'd be happy to take it through arm-soc if we get a stable base.
-Olof
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 2 lines · Olof Johansson
So, Linus, it's up to you (and Russell) what you prefer, but I'd be happy to take it through arm-soc if we get a stable base.
I'll fix up the usage of CONFIG_ATAGS in this patch and put it into Russell's tracker to minimize the hazzle.
Yours,
Linus Walleij
PATCH v2 4/6 ARM: integrator: initial device tree support
In reply to Linus WalleijQuoted 10 lines · Linus Walleij
This is initial device tree support for the ARM Integrator family, we create a very basic device tree, #ifdef out the non-DT machines when compiling for device tree.
Signed-off-by Linus Walleij <[email protected]>---
ChangeLogv1->v2:
- Also switch over clocksource and clockevent to device tree. Else the IRQ mapping goes bananas.
---
snip
Quoted 7 lines
+++
b/arch/arm/boot/dts/integratorcp.dtsarch/arm/boot/dts/integratorcp.dts new file +5
-0@@ -0,0 +1,69 @@ +/* + * Device Tree for the ARM Integrator/CP platform + */ + +/dts-v1/;
arch/arm/boot/dts/integratorcp.dts line 15
Quoted 10 lines
arch/arm/boot/dts/integratorcp.dts new file +10
-0+/include/ "skeleton.dtsi" + +/ { + model = "ARM Integrator/CP"; + compatible = "arm,integrator-cp"; + ranges; + + aliases { + arm,integrator-clocksource = &timer2; + arm,integrator-clockevent = &timer1;
This is linux specific and a common issue we need a solution for. Grant had done something for versatile and we discussed it some, but nothing ever got close to finalized. IIRC, Grant's solution was just add a "linux,clockevent" or "linux,clocksource" to the nodes that are to be used. But he wasn't really happy with it. Perhaps using these names as aliases would be better.
Rob
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 17 lines · Rob Herring
arch/arm/boot/dts/integratorcp.dts line 15
Quoted 8 lines · Linus Walleij
arch/arm/boot/dts/integratorcp.dts new file +8
-0+/ { + model = "ARM Integrator/CP"; + compatible = "arm,integrator-cp"; + ranges; + + aliases { + arm,integrator-clocksource = &timer2; + arm,integrator-clockevent = &timer1;This is linux specific and a common issue we need a solution for. Grant had done something for versatile and we discussed it some, but nothing ever got close to finalized. IIRC, Grant's solution was just add a "linux,clockevent" or "linux,clocksource" to the nodes that are to be used. But he wasn't really happy with it. Perhaps using these names as aliases would be better.
Atleast I'm honest about what this is, IMHO this is better than any of the solutions we already have in boot/dts.
Look at the versatile expressarch/arm/boot/dts/vexpress-v2m.dtsi:
aliases {
arm,v2m_timer = &v2m_timer01;
};It's quite hard to tell that this "vtm_timer" is actually the block serving as clock source and clockevent for the Vexpress, but if you inspect the code you can see that this is what it is.
I can of course skip the aliases and go for the timer nodes I want directly, but that isn't any helpful for people reading the device tree, is it?
Maybe primary-timer, secondary-timer is sufficiently good and neutral aliases?
Yours,
Linus Walleij
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 25 lines · Linus Walleij
Quoted 17 lines · Rob Herring
arch/arm/boot/dts/integratorcp.dts line 15
Quoted 8 lines · Linus Walleij
arch/arm/boot/dts/integratorcp.dts new file +8
-0+/ { + model = "ARM Integrator/CP"; + compatible = "arm,integrator-cp"; + ranges; + + aliases { + arm,integrator-clocksource = &timer2; + arm,integrator-clockevent = &timer1;This is linux specific and a common issue we need a solution for. Grant had done something for versatile and we discussed it some, but nothing ever got close to finalized. IIRC, Grant's solution was just add a "linux,clockevent" or "linux,clocksource" to the nodes that are to be used. But he wasn't really happy with it. Perhaps using these names as aliases would be better.
Atleast I'm honest about what this is, IMHO this is better than any of the solutions we already have in boot/dts.
Look at the versatile express
arch/arm/boot/dts/vexpress-v2m.dtsi:
Quoted 7 lines
aliases { arm,v2m_timer = &v2m_timer01; };It's quite hard to tell that this "
vtm_timer" is actually the block serving as clock source and clockevent for the Vexpress, but if you inspect the code you can see that this is what it is.
Yeah, we really need to unify all this.
Quoted 3 lines
I can of course skip the aliases and go for the timer nodes I want directly, but that isn't any helpful for people reading the device tree, is it?
Well, the dts doesn't really need to describe how Linux is using things. I'd like to get to common DT code for sp804 so all platforms just have a call to sp804_dt_init() which does all the initialization.
Quoted 3 lines
Maybe primary-timer, secondary-timer is sufficiently good and neutral aliases?
That doesn't distinguish clk-event vs. clk-source. Perhaps we can use presence of interrupt to distinguish that. It shouldn't really matter which timer Linux picks as long as the h/w has the necessary features. We just need to make sure dts describes those features. Some of the things we have to deal with:
Highbank has interrupt for timer0, but not on timer1, so timer0 must be clk-event. It also users timer1 for sched clock, but ARM Ltd platforms use a different timer.
Realview and Versatile use timer0 for clk-event and timer3 for clk-src. Is there something broken with timer1 and timer2? It is certainly possible the h/w has the clock tied off for 1 of the 2 timers.
VExpress CA9 has broken timers on the core tile (at least they were ifdef'ed out before the last clean-up). We could just remove/disable them in the dts so they are not used.
Rob
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 6 lines · Rob Herring
[Me]
Quoted 3 lines
I can of course skip the aliases and go for the timer nodes I want directly, but that isn't any helpful for people reading the device tree, is it?
Well, the dts doesn't really need to describe how Linux is using things.
The arm,integrator-clocksource and arm,integrator-clockevent are renamed arm,timer-primary and arm,timer-secondary in the last patch set.
Are you OK with this for now, going forward? I'd be happy to take a round refactoring it for the next cycle as outlined below.
Quoted 2 lines
I'd like to get to common DT code for sp804 so all platforms just have a call to
sp804_dt_init()which does all the initialization.
The Integrator/AP does not have the SP804 timer, it has a precursor with similar, yet different register setup. The driver is in the integrator_ab. core file.
(I could look into merging this SP804 ancestor into the SP804 driver with some flag or so, but that would be a different TODO item.)
The Integrator/CP has the SP804 however.
Quoted 5 lines
Quoted 2 lines
Maybe primary-timer, secondary-timer is sufficiently good and neutral aliases?
That doesn't distinguish clk-event vs. clk-source. Perhaps we can use presence of interrupt to distinguish that.
They all have interrupts in the Integrator case so all timers are equal. But I vaguely recall someone whisper bad things about timer0.
Quoted 2 lines
It shouldn't really matter
which timer Linux picks as long as the h/w has the necessary features.
That is true, what I've been doing so far is just a 1-to-1 mapping to current usage without much massaging of the abstract resource concept.
Quoted 6 lines
We just need to make sure dts describes those features. Some of the things we have to deal with:
Highbank has interrupt for timer0, but not on timer1, so timer0 must be clk-event. It also users timer1 for sched clock, but ARM Ltd platforms use a different timer.
So I guess this SP804? They just didn't route the IRQ line I guess... :-(
Quoted 3 lines
Realview and Versatile use timer0 for clk-event and timer3 for clk-src. Is there something broken with timer1 and timer2? It is certainly possible the h/w has the clock tied off for 1 of the 2 timers.
Integrator use timer2 for clockevent and timer1 for clocksource, and legends tell that timer0 should be avoided. But I guess I could try to find out by experience, I fear that it could work but be instable so that it appears to work but in reality does not...
Quoted 3 lines
VExpress CA9 has broken timers on the core tile (at least they were ifdef'ed out before the last clean-up). We could just remove/disable them in the dts so they are not used.
There is something about the DT ambition here (or for that matter the boardfile ambition). On the RealView PB1176 there is a broken DMA engine, we just deleted it from the resource list. Other people might want to have all available resources listed but marked "broken" in the DT for completeness.
The latter has the upside of providing hints to the next engineer who would otherwise come around and ask why the hardware in the refman is not listed in the DT and start to try to add it and find out it is broken. Knowing it's there and it's broken is encoding real knowledge at the expense of a few DT bytes.
(I'm fine with either.)
Yours,
Linus Walleij
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 8 lines · Linus Walleij
Quoted 6 lines · Rob Herring
[Me]
Quoted 3 lines
I can of course skip the aliases and go for the timer nodes I want directly, but that isn't any helpful for people reading the device tree, is it?
Well, the dts doesn't really need to describe how Linux is using things.
Quoted 7 lines
The arm,integrator-clocksource and arm,integrator-clockevent are renamed arm,timer-primary and arm,timer-secondary in the last patch set.
Are you OK with this for now, going forward? I'd be happy to take a round refactoring it for the next cycle as outlined below.
If the timers are really free for use by anything and you want to encode how Linux uses them, I would suggest naming the aliases "linux.clocksource" and "linux,clockevent" to make it clear that you are not describing the hardware here but rather picking a configuration.
Arnd
PATCH v2 4/6 ARM: integrator: initial device tree support
Quoted 17 lines · Arnd Bergmann
Quoted 8 lines · Linus Walleij
Quoted 6 lines · Rob Herring
[Me]
Quoted 3 lines
I can of course skip the aliases and go for the timer nodes I want directly, but that isn't any helpful for people reading the device tree, is it?
Well, the dts doesn't really need to describe how Linux is using things.
Quoted 7 lines
The arm,integrator-clocksource and arm,integrator-clockevent are renamed arm,timer-primary and arm,timer-secondary in the last patch set.
Are you OK with this for now, going forward? I'd be happy to take a round refactoring it for the next cycle as outlined below.
Quoted 5 lines
If the timers are really free for use by anything and you want to encode how Linux uses them, I would suggest naming the aliases "linux.clocksource" and "linux,clockevent" to make it clear that you are not describing the hardware here but rather picking a configuration.
So the renaming of the aliases to arm,timer-primary and arm-timer-secondary is to be taken as a hint to the OS to use these two as primary and secondary respectively.
linux.foo seems bad in comparison, but if you insist...
Yours,
Linus Walleij
PATCH v2 4/6 ARM: integrator: initial device tree support
In reply to Linus WalleijQuoted 16 lines · Linus Walleij
Quoted 6 lines · Rob Herring
[Me]
Quoted 3 lines
I can of course skip the aliases and go for the timer nodes I want directly, but that isn't any helpful for people reading the device tree, is it?
Well, the dts doesn't really need to describe how Linux is using things.
The arm,integrator-clocksource and arm,integrator-clockevent are renamed arm,timer-primary and arm,timer-secondary in the last patch set.
Are you OK with this for now, going forward? I'd be happy to take a round refactoring it for the next cycle as outlined below.
Quoted 6 lines
Quoted 2 lines
I'd like to get to common DT code for sp804 so all platforms just have a call to
sp804_dt_init()which does all the initialization.The Integrator/AP does not have the SP804 timer, it has a precursor with similar, yet different register setup. The driver is in the
integrator_ab. core file.
Right, that was really just an example. We have the general problem that platforms have N timers and how do we assign them to clk source and clk event. I'm fine with aliases if we decide that other options have issues or are not worth the complexity. A "linux,X" property really needs to be a last resort.
Quoted 9 lines
(I could look into merging this SP804 ancestor into the SP804 driver with some flag or so, but that would be a different TODO item.)
The Integrator/CP has the SP804 however.
Quoted 3 lines
Quoted 2 lines
Maybe primary-timer, secondary-timer is sufficiently good and neutral aliases?
Quoted 6 lines
Quoted 2 lines
That doesn't distinguish clk-event vs. clk-source. Perhaps we can use presence of interrupt to distinguish that.
They all have interrupts in the Integrator case so all timers are equal. But I vaguely recall someone whisper bad things about timer0.
Then that is a "feature" of the h/w. So perhaps a "arm,timer-horked" should be added as a property. Certainly wouldn't be the first timer with that feature. :)
Quoted 36 lines
Quoted 2 lines
It shouldn't really matter
which timer Linux picks as long as the h/w has the necessary features.That is true, what I've been doing so far is just a 1-to-1 mapping to current usage without much massaging of the abstract resource concept.
Quoted 6 lines
We just need to make sure dts describes those features. Some of the things we have to deal with:
Highbank has interrupt for timer0, but not on timer1, so timer0 must be clk-event. It also users timer1 for sched clock, but ARM Ltd platforms use a different timer.
So I guess this SP804? They just didn't route the IRQ line I guess... :-(
Quoted 3 lines
Realview and Versatile use timer0 for clk-event and timer3 for clk-src. Is there something broken with timer1 and timer2? It is certainly possible the h/w has the clock tied off for 1 of the 2 timers.
Integrator use timer2 for clockevent and timer1 for clocksource, and legends tell that timer0 should be avoided. But I guess I could try to find out by experience, I fear that it could work but be instable so that it appears to work but in reality does not...
Quoted 3 lines
VExpress CA9 has broken timers on the core tile (at least they were ifdef'ed out before the last clean-up). We could just remove/disable them in the dts so they are not used.
There is something about the DT ambition here (or for that matter the boardfile ambition). On the RealView PB1176 there is a broken DMA engine, we just deleted it from the resource list. Other people might want to have all available resources listed but marked "broken" in the DT for completeness.
Quoted 7 lines
The latter has the upside of providing hints to the next engineer who would otherwise come around and ask why the hardware in the refman is not listed in the DT and start to try to add it and find out it is broken. Knowing it's there and it's broken is encoding real knowledge at the expense of a few DT bytes.
Yes, saving that information somewhere is useful.
Rob
PATCH v2 4/6 ARM: integrator: initial device tree support
In reply to Rob HerringQuoted 3 lines · Rob Herring
Well, the dts doesn't really need to describe how Linux is using things. I'd like to get to common DT code for sp804 so all platforms just have a call to
sp804_dt_init()which does all the initialization.
They don't all have SP804 timers. The Integrator/AP does not have SP804, and it would be wrong to try and merge them into the clean SP804 driver.
Integrator/AP timers are strictly 16-bit only affairs, which need special clocking handling to ensure that their rollover rate is sufficiently long. SP804 timers are 32-bit or 16-bit timers, we drive the only in 32-bit mode, and so they don't suffer from the above issue. Polluting this code with the legacy 16-bit stuff just for one platform is not a good idea. They weren't even called SP804 in the Integrator/AP days - they were just a random timer design embedded into a FPGA.
Quoted 3 lines
Realview and Versatile use timer0 for clk-event and timer3 for clk-src. Is there something broken with timer1 and timer2? It is certainly possible the h/w has the clock tied off for 1 of the 2 timers.
I don't believe so, that's the way the timers were used when I received the initial code drop from ARM Ltd, before it got cleaned up. The selection of what timers are used appears to me to be completely random.
Quoted 3 lines
VExpress CA9 has broken timers on the core tile (at least they were ifdef'ed out before the last clean-up). We could just remove/disable them in the dts so they are not used.
The motherboard timers can be switched between 32kHz and 1MHz mode. The core tile timers can probably be switched between 32kHz and 1MHz mode but god knows how - they default to 32kHz. So given that choice, I opted for the higher resolution motherboard timers and left the hooks for the core tile timers in place, in the hope that someone would tell me or implement the switching to 1MHz mode.
Obviously, no one did, and the code got removed. I doubt it makes any difference what so ever.
And that's a very good point - in the current way things are handled on these platforms, the tweaking of the SP804 input clocks has been divorced from the SP804 initialization. This is bad, because it means that dependency has been hidden by the DT conversion...
So, selection of the right SP804s to use is also a function of "do we know how to control its clock rate". If we don't, we can't be certain of the rate at which the timer ticks.
PATCH v2 2/6 ARM: integrator: check PL010 device name rather than base address
In reply to Linus WalleijQuoted 6 lines · Linus Walleij
In the PL010 UART callback a comparison against the base address is done to figure out which UART is doing the callback. This does not play well with device tree, so let's check the
dev_name()of the device instead.Signed-off-by Linus Walleij <[email protected]>
Hmm, I think the dev_name would also not be that nice, because it changes after the conversion to DT is complete.
Quoted 8 lines
arch/arm/mach-integrator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/mach-integrator/core.c +0
-0
arch/arm/mach-integrator/core.c static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *bas · line 106
Quoted 8 lines
arch/arm/mach-integrator/core.c +1
-1@@ -100,7 +100,7 @@ static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *bas {unsigned int ctrls =0 , ctrlc =0 , rts_mask, dtr_mask; -if (dev == &uart0_device) { +if (!strcmp (dev_name (&dev->dev),"uart0" )) { rts_mask =1 <<4 ; dtr_mask =1 <<5 ; }else {
Maybe it's possible to compare the base pointer against INTEGRATOR_UART0_BASE instead?
Arnd
PATCH v2 2/6 ARM: integrator: check PL010 device name rather than base address
Quoted 10 lines · Arnd Bergmann
Quoted 6 lines · Linus Walleij
In the PL010 UART callback a comparison against the base address is done to figure out which UART is doing the callback. This does not play well with device tree, so let's check the
dev_name()of the device instead.Signed-off-by Linus Walleij <[email protected]>Hmm, I think the
dev_namewould also not be that nice, because it changes after the conversion to DT is complete.
Hmmmm yeah. I do tie down the name to "uart0" using auxdata.
(...)
Quoted 5 lines
Quoted 5 lines
+++
b/arch/arm/mach-integrator/core.carch/arm/mach-integrator/core.c +0
-0@@ -100,7 +100,7 @@ static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *bas {unsigned int ctrls =0 , ctrlc =0 , rts_mask, dtr_mask;
Quoted 7 lines
arch/arm/mach-integrator/core.c static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *bas · line 106
Quoted 5 lines
arch/arm/mach-integrator/core.c +1
-1-if (dev == &uart0_device) { +if (!strcmp (dev_name (&dev->dev),"uart0" )) { rts_mask =1 <<4 ; dtr_mask =1 <<5 ; }else {Maybe it's possible to compare the base pointer against
INTEGRATOR_UART0_BASEinstead?
Nope, that is an ioremapped() base, I have no clue what it may be.
Yours,
Linus Walleij
PATCH v2 2/6 ARM: integrator: check PL010 device name rather than base address
Quoted 9 lines · Linus Walleij
Quoted 7 lines · Arnd Bergmann
Quoted 5 lines · Linus Walleij
arch/arm/mach-integrator/core.c +1
-1-if (dev == &uart0_device) { +if (!strcmp (dev_name (&dev->dev),"uart0" )) { rts_mask =1 <<4 ; dtr_mask =1 <<5 ; }else {
Quoted 3 lines
Quoted 1 line
Maybe it's possible to compare the base pointer against
INTEGRATOR_UART0_BASEinstead?Nope, that is an
ioremapped()base, I have no clue what it may be.
But hey I have the struct amba_device there, so the mem resource is there indeed :-) I'll fix!
Yours,
Linus Walleij