* [PATCH 6/6 v2] ARM: integrator: convert platform devices to Device Tree @ 2012-09-05 19:29 Linus Walleij 0 siblings, 0 replies; 2+ messages in thread From: Linus Walleij @ 2012-09-05 19:29 UTC (permalink / raw) To: linux-arm-kernel 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. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- ChangeLog v1->v2: - Move flash device definition to the common "integrator.dtsi" file. --- arch/arm/boot/dts/integrator.dtsi | 5 ++ arch/arm/boot/dts/integratorcp.dts | 7 +++ arch/arm/mach-integrator/integrator_ap.c | 36 ++++++------- arch/arm/mach-integrator/integrator_cp.c | 92 ++++++++++++++++---------------- 4 files changed, 77 insertions(+), 63 deletions(-) diff --git a/arch/arm/boot/dts/integrator.dtsi b/arch/arm/boot/dts/integrator.dtsi index 9bcc09d..813b91d 100644 --- a/arch/arm/boot/dts/integrator.dtsi +++ b/arch/arm/boot/dts/integrator.dtsi @@ -31,6 +31,11 @@ clear-mask = <0xffffffff>; }; + flash at 24000000 { + compatible = "cfi-flash"; + reg = <0x24000000 0x02000000>; + }; + fpga { compatible = "arm,amba-bus", "simple-bus"; #address-cells = <1>; diff --git a/arch/arm/boot/dts/integratorcp.dts b/arch/arm/boot/dts/integratorcp.dts index 7bd4946..2dd5e4e 100644 --- a/arch/arm/boot/dts/integratorcp.dts +++ b/arch/arm/boot/dts/integratorcp.dts @@ -52,6 +52,13 @@ valid-mask = <0x00000fff>; }; + ethernet at c8000000 { + compatible = "smsc,lan91c111"; + reg = <0xc8000000 0x10>; + interrupt-parent = <&pic>; + interrupts = <27>; + }; + fpga { /* * These PrimeCells are at the same location and using diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index 8cd0560..ff1255a 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c @@ -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; @@ -537,6 +521,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; diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index f032238..f51363e 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c @@ -52,12 +52,9 @@ #include "common.h" #define INTCP_PA_FLASH_BASE 0x24000000 -#define INTCP_FLASH_SIZE SZ_32M #define INTCP_PA_CLCD_BASE 0xc0000000 -#define INTCP_ETH_SIZE 0x10 - #define INTCP_VA_CTRL_BASE IO_ADDRESS(INTEGRATOR_CP_CTL_BASE) #define INTCP_FLASHPROG 0x04 #define CINTEGRATOR_FLASHPROG_FLVPPEN (1 << 0) @@ -184,47 +181,6 @@ static struct physmap_flash_data intcp_flash_data = { .set_vpp = intcp_flash_set_vpp, }; -static struct resource intcp_flash_resource = { - .start = INTCP_PA_FLASH_BASE, - .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1, - .flags = IORESOURCE_MEM, -}; - -static struct platform_device intcp_flash_device = { - .name = "physmap-flash", - .id = 0, - .dev = { - .platform_data = &intcp_flash_data, - }, - .num_resources = 1, - .resource = &intcp_flash_resource, -}; - -static struct resource smc91x_resources[] = { - [0] = { - .start = INTEGRATOR_CP_ETH_BASE, - .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_CP_ETHINT, - .end = IRQ_CP_ETHINT, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device smc91x_device = { - .name = "smc91x", - .id = 0, - .num_resources = ARRAY_SIZE(smc91x_resources), - .resource = smc91x_resources, -}; - -static struct platform_device *intcp_devs[] __initdata = { - &intcp_flash_device, - &smc91x_device, -}; - /* * It seems that the card insertion interrupt remains active after * we've acknowledged it. We therefore ignore the interrupt, and @@ -375,6 +331,8 @@ static struct of_dev_auxdata intcp_auxdata_lookup[] __initdata = { "aaci", &mmc_data), OF_DEV_AUXDATA("arm,primecell", INTCP_PA_CLCD_BASE, "clcd", &clcd_data), + OF_DEV_AUXDATA("cfi-flash", INTCP_PA_FLASH_BASE, + "physmap-flash", &intcp_flash_data), { /* sentinel */ }, }; @@ -382,7 +340,6 @@ static void __init intcp_init_of(void) { of_platform_populate(NULL, of_default_bus_match_table, intcp_auxdata_lookup, NULL); - platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); } static const char * intcp_dt_board_compat[] = { @@ -412,6 +369,51 @@ MACHINE_END * for eventual deletion. */ +#define INTCP_FLASH_SIZE SZ_32M + +static struct resource intcp_flash_resource = { + .start = INTCP_PA_FLASH_BASE, + .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1, + .flags = IORESOURCE_MEM, +}; + +static struct platform_device intcp_flash_device = { + .name = "physmap-flash", + .id = 0, + .dev = { + .platform_data = &intcp_flash_data, + }, + .num_resources = 1, + .resource = &intcp_flash_resource, +}; + +#define INTCP_ETH_SIZE 0x10 + +static struct resource smc91x_resources[] = { + [0] = { + .start = INTEGRATOR_CP_ETH_BASE, + .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = IRQ_CP_ETHINT, + .end = IRQ_CP_ETHINT, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device smc91x_device = { + .name = "smc91x", + .id = 0, + .num_resources = ARRAY_SIZE(smc91x_resources), + .resource = smc91x_resources, +}; + +static struct platform_device *intcp_devs[] __initdata = { + &intcp_flash_device, + &smc91x_device, +}; + #define INTCP_VA_CIC_BASE __io_address(INTEGRATOR_HDR_BASE + 0x40) #define INTCP_VA_PIC_BASE __io_address(INTEGRATOR_IC_BASE) #define INTCP_VA_SIC_BASE __io_address(INTEGRATOR_CP_SIC_BASE) -- 1.7.11.4 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 1/6 v2] ARM: integrator: call common init function from machine @ 2012-09-01 3:55 Linus Walleij 2012-09-01 3:55 ` [PATCH 2/6 v2] ARM: integrator: check PL010 device name rather than base address Linus Walleij 0 siblings, 1 reply; 2+ messages in thread From: Linus Walleij @ 2012-09-01 3:55 UTC (permalink / raw) To: linux-arm-kernel 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. Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- 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(-) diff --git a/arch/arm/mach-integrator/common.h b/arch/arm/mach-integrator/common.h index 899561d..c4338e2 100644 --- a/arch/arm/mach-integrator/common.h +++ b/arch/arm/mach-integrator/common.h @@ -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 *); diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c index 3fa6c51..5ba4bc8 100644 --- a/arch/arm/mach-integrator/core.c +++ b/arch/arm/mach-integrator/core.c @@ -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: diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index 3b22675..ff966d8 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c @@ -312,6 +312,8 @@ static void __init ap_init(void) lm_device_register(lmdev); } + + integrator_init(false); } /* diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index 82d5c83..2b40bc1 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c @@ -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) -- 1.7.11.4 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/6 v2] ARM: integrator: check PL010 device name rather than base address 2012-09-01 3:55 [PATCH 1/6 v2] ARM: integrator: call common init function from machine Linus Walleij @ 2012-09-01 3:55 ` Linus Walleij 2012-09-01 3:55 ` [PATCH 3/6 v2] ARM: plat-versatile: add DT support to FPGA IRQ controller Linus Walleij 0 siblings, 1 reply; 2+ messages in thread From: Linus Walleij @ 2012-09-01 3:55 UTC (permalink / raw) To: linux-arm-kernel 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 <linus.walleij@linaro.org> --- arch/arm/mach-integrator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c index 5ba4bc8..67ea181 100644 --- a/arch/arm/mach-integrator/core.c +++ b/arch/arm/mach-integrator/core.c @@ -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 { -- 1.7.11.4 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 3/6 v2] ARM: plat-versatile: add DT support to FPGA IRQ controller 2012-09-01 3:55 ` [PATCH 2/6 v2] ARM: integrator: check PL010 device name rather than base address Linus Walleij @ 2012-09-01 3:55 ` Linus Walleij 2012-09-01 3:55 ` [PATCH 4/6 v2] ARM: integrator: initial device tree support Linus Walleij 0 siblings, 1 reply; 2+ messages in thread From: Linus Walleij @ 2012-09-01 3:55 UTC (permalink / raw) To: linux-arm-kernel This adds Device Tree probing support to the Versatile FPGA IRQ controller. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- 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 diff --git a/Documentation/devicetree/bindings/arm/versatile-fpga-irq.txt b/Documentation/devicetree/bindings/arm/versatile-fpga-irq.txt new file mode 100644 index 0000000..9989eda --- /dev/null +++ b/Documentation/devicetree/bindings/arm/versatile-fpga-irq.txt @@ -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>; +}; diff --git a/arch/arm/plat-versatile/fpga-irq.c b/arch/arm/plat-versatile/fpga-irq.c index 6e70d03..1ca595c 100644 --- a/arch/arm/plat-versatile/fpga-irq.c +++ b/arch/arm/plat-versatile/fpga-irq.c @@ -5,6 +5,8 @@ #include <linux/io.h> #include <linux/irqdomain.h> #include <linux/module.h> +#include <linux/of.h> +#include <linux/of_address.h> #include <asm/exception.h> #include <asm/mach/irq.h> @@ -14,6 +16,13 @@ #define IRQ_RAW_STATUS 0x04 #define IRQ_ENABLE_SET 0x08 #define IRQ_ENABLE_CLEAR 0x0c +#define INT_SOFT_SET 0x10 +#define INT_SOFT_CLEAR 0x14 +#define FIQ_STATUS 0x20 +#define FIQ_RAW_STATUS 0x24 +#define FIQ_ENABLE 0x28 +#define FIQ_ENABLE_SET 0x28 +#define FIQ_ENABLE_CLEAR 0x2C /** * struct fpga_irq_data - irq data container for the FPGA IRQ controller @@ -156,3 +165,41 @@ void __init fpga_irq_init(void __iomem *base, const char *name, int irq_start, fpga_irq_id++; } + +#ifdef CONFIG_OF +int __init fpga_irq_of_init(struct device_node *node, + struct device_node *parent) +{ + void __iomem *base; + u32 irq_start; + u32 clear_mask; + u32 valid_mask; + + if (WARN_ON(!node)) + return -ENODEV; + + base = of_iomap(node, 0); + WARN(!base, "unable to map fpga irq registers\n"); + + if (of_property_read_u32(node, "clear-mask", &clear_mask)) + clear_mask = 0; + + if (of_property_read_u32(node, "valid-mask", &valid_mask)) + valid_mask = 0; + + irq_start = irq_alloc_descs(-1, 0, fls(valid_mask), numa_node_id()); + if (WARN_ON(irq_start < 0)) + goto out_unmap; + + writel(clear_mask, base + IRQ_ENABLE_CLEAR); + writel(clear_mask, base + FIQ_ENABLE_CLEAR); + + fpga_irq_init(base, node->name, irq_start, -1, valid_mask, node); + + return 0; + +out_unmap: + iounmap(base); + return -EIO; +} +#endif diff --git a/arch/arm/plat-versatile/include/plat/fpga-irq.h b/arch/arm/plat-versatile/include/plat/fpga-irq.h index 91bcfb6..1fac965 100644 --- a/arch/arm/plat-versatile/include/plat/fpga-irq.h +++ b/arch/arm/plat-versatile/include/plat/fpga-irq.h @@ -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 -- 1.7.11.4 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 4/6 v2] ARM: integrator: initial device tree support 2012-09-01 3:55 ` [PATCH 3/6 v2] ARM: plat-versatile: add DT support to FPGA IRQ controller Linus Walleij @ 2012-09-01 3:55 ` Linus Walleij 2012-09-01 3:55 ` [PATCH 5/6 v2] ARM: integrator: convert AMBA devices to device tree Linus Walleij 0 siblings, 1 reply; 2+ messages in thread From: Linus Walleij @ 2012-09-01 3:55 UTC (permalink / raw) To: linux-arm-kernel 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 <linus.walleij@linaro.org> --- 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 diff --git a/Documentation/devicetree/bindings/arm/arm-boards b/Documentation/devicetree/bindings/arm/arm-boards index 91f2614..fc81a7d 100644 --- a/Documentation/devicetree/bindings/arm/arm-boards +++ b/Documentation/devicetree/bindings/arm/arm-boards @@ -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 diff --git a/arch/arm/boot/dts/integratorap.dts b/arch/arm/boot/dts/integratorap.dts new file mode 100644 index 0000000..928a7be --- /dev/null +++ b/arch/arm/boot/dts/integratorap.dts @@ -0,0 +1,51 @@ +/* + * Device Tree for the ARM Integrator/AP platform + */ + +/dts-v1/; +/include/ "skeleton.dtsi" + +/ { + model = "ARM Integrator/AP"; + compatible = "arm,integrator-ap"; + ranges; + + aliases { + arm,integrator-clocksource = &timer2; + arm,integrator-clockevent = &timer1; + }; + + chosen { + bootargs = "root=/dev/ram0 console=ttyAM0,38400n8 earlyprintk"; + }; + + timer0: timer at 13000000 { + compatible = "arm,integrator-timer"; + reg = <0x13000000 0x100>; + interrupt-parent = <&pic>; + interrupts = <5>; + }; + + timer1: timer at 13000100 { + compatible = "arm,integrator-timer"; + reg = <0x13000100 0x100>; + interrupt-parent = <&pic>; + interrupts = <6>; + }; + + timer2: timer at 13000200 { + compatible = "arm,integrator-timer"; + reg = <0x13000200 0x100>; + interrupt-parent = <&pic>; + interrupts = <7>; + }; + + pic: pic at 14000000 { + compatible = "arm,versatile-fpga-irq"; + #interrupt-cells = <1>; + interrupt-controller; + reg = <0x14000000 0x100>; + clear-mask = <0xffffffff>; + valid-mask = <0x003fffff>; + }; +}; diff --git a/arch/arm/boot/dts/integratorcp.dts b/arch/arm/boot/dts/integratorcp.dts new file mode 100644 index 0000000..8fad5a1 --- /dev/null +++ b/arch/arm/boot/dts/integratorcp.dts @@ -0,0 +1,69 @@ +/* + * Device Tree for the ARM Integrator/CP platform + */ + +/dts-v1/; +/include/ "skeleton.dtsi" + +/ { + model = "ARM Integrator/CP"; + compatible = "arm,integrator-cp"; + ranges; + + aliases { + arm,integrator-clocksource = &timer2; + arm,integrator-clockevent = &timer1; + }; + + chosen { + bootargs = "root=/dev/ram0 console=ttyAMA0,38400n8 earlyprintk"; + }; + + timer0: timer at 13000000 { + compatible = "arm,sp804", "arm,primecell"; + reg = <0x13000000 0x100>; + interrupt-parent = <&pic>; + interrupts = <5>; + }; + + timer1: timer at 13000100 { + compatible = "arm,sp804", "arm,primecell"; + reg = <0x13000100 0x100>; + interrupt-parent = <&pic>; + interrupts = <6>; + }; + + timer2: timer at 13000200 { + compatible = "arm,sp804", "arm,primecell"; + reg = <0x13000200 0x100>; + interrupt-parent = <&pic>; + interrupts = <7>; + }; + + pic: pic at 14000000 { + compatible = "arm,versatile-fpga-irq"; + #interrupt-cells = <1>; + interrupt-controller; + reg = <0x14000000 0x100>; + clear-mask = <0xffffffff>; + valid-mask = <0x1fc003ff>; + }; + + cic: cic at 10000040 { + compatible = "arm,versatile-fpga-irq"; + #interrupt-cells = <1>; + interrupt-controller; + reg = <0x10000040 0x100>; + clear-mask = <0xffffffff>; + valid-mask = <0x00000007>; + }; + + sic: sic at ca000000 { + compatible = "arm,versatile-fpga-irq"; + #interrupt-cells = <1>; + interrupt-controller; + reg = <0xca000000 0x100>; + clear-mask = <0x00000fff>; + valid-mask = <0x00000fff>; + }; +}; diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index ff966d8..26d4d8c 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c @@ -34,6 +34,8 @@ #include <linux/mtd/physmap.h> #include <linux/clk.h> #include <linux/platform_data/clk-integrator.h> +#include <linux/of_irq.h> +#include <linux/of_address.h> #include <video/vga.h> #include <mach/hardware.h> @@ -161,23 +163,6 @@ static void __init ap_map_io(void) vga_base = PCI_MEMORY_VADDR; } -#define INTEGRATOR_SC_VALID_INT 0x003fffff - -static void __init ap_init_irq(void) -{ - /* Disable all interrupts initially. */ - /* Do the core module ones */ - writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR); - - /* do the header card stuff next */ - writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR); - writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR); - - fpga_irq_init(VA_IC_BASE, "SC", IRQ_PIC_START, - -1, INTEGRATOR_SC_VALID_INT, NULL); - integrator_clk_init(false); -} - #ifdef CONFIG_PM static unsigned long ic_irq_enable; @@ -330,9 +315,9 @@ static u32 notrace integrator_read_sched_clock(void) return -readl((void __iomem *) TIMER2_VA_BASE + TIMER_VALUE); } -static void integrator_clocksource_init(unsigned long inrate) +static void integrator_clocksource_init(unsigned long inrate, + void __iomem *base) { - void __iomem *base = (void __iomem *)TIMER2_VA_BASE; u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC; unsigned long rate = inrate; @@ -349,7 +334,7 @@ static void integrator_clocksource_init(unsigned long inrate) setup_sched_clock(integrator_read_sched_clock, 16, rate); } -static void __iomem * const clkevt_base = (void __iomem *)TIMER1_VA_BASE; +static void __iomem * clkevt_base; /* * IRQ handler for the timer @@ -421,11 +406,13 @@ static struct irqaction integrator_timer_irq = { .dev_id = &integrator_clockevent, }; -static void integrator_clockevent_init(unsigned long inrate) +static void integrator_clockevent_init(unsigned long inrate, + void __iomem *base, int irq) { unsigned long rate = inrate; unsigned int ctrl = 0; + clkevt_base = base; /* Calculate and program a divisor */ if (rate > 0x100000 * HZ) { rate /= 256; @@ -437,7 +424,7 @@ static void integrator_clockevent_init(unsigned long inrate) timer_reload = rate / HZ; writel(ctrl, clkevt_base + TIMER_CTRL); - setup_irq(IRQ_TIMERINT1, &integrator_timer_irq); + setup_irq(irq, &integrator_timer_irq); clockevents_config_and_register(&integrator_clockevent, rate, 1, @@ -448,9 +435,89 @@ void __init ap_init_early(void) { } +#ifdef CONFIG_OF + +static void __init ap_init_timer_of(void) +{ + struct device_node *node; + const char *path; + void __iomem *base; + int err; + int irq; + struct clk *clk; + unsigned long rate; + + clk = clk_get_sys("ap_timer", NULL); + BUG_ON(IS_ERR(clk)); + clk_prepare_enable(clk); + rate = clk_get_rate(clk); + + err = of_property_read_string(of_aliases, + "arm,integrator-clocksource", &path); + if (WARN_ON(err)) + return; + node = of_find_node_by_path(path); + base = of_iomap(node, 0); + if (WARN_ON(!base)) + return; + writel(0, base + TIMER_CTRL); + integrator_clocksource_init(rate, base); + + err = of_property_read_string(of_aliases, + "arm,integrator-clockevent", &path); + if (WARN_ON(err)) + return; + node = of_find_node_by_path(path); + base = of_iomap(node, 0); + if (WARN_ON(!base)) + return; + irq = irq_of_parse_and_map(node, 0); + writel(0, base + TIMER_CTRL); + integrator_clockevent_init(rate, base, irq); +} + +static struct sys_timer ap_of_timer = { + .init = ap_init_timer_of, +}; + +static const struct of_device_id fpga_irq_of_match[] __initconst = { + { .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, }, + { /* Sentinel */ } +}; + +static void __init ap_init_irq_of(void) +{ + /* disable core module IRQs */ + writel(0xffffffffU, VA_CMIC_BASE + IRQ_ENABLE_CLEAR); + of_irq_init(fpga_irq_of_match); + integrator_clk_init(false); +} + +static const char * ap_dt_board_compat[] = { + "arm,integrator-ap", + NULL, +}; + +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 + /* - * Set up timer(s). + * This is where non-devicetree initialization code is collected and stashed + * for eventual deletion. */ + static void __init ap_init_timer(void) { struct clk *clk; @@ -465,14 +532,32 @@ static void __init ap_init_timer(void) writel(0, TIMER1_VA_BASE + TIMER_CTRL); writel(0, TIMER2_VA_BASE + TIMER_CTRL); - integrator_clocksource_init(rate); - integrator_clockevent_init(rate); + integrator_clocksource_init(rate, (void __iomem *)TIMER2_VA_BASE); + integrator_clockevent_init(rate, (void __iomem *)TIMER1_VA_BASE, + IRQ_TIMERINT1); } static struct sys_timer ap_timer = { .init = ap_init_timer, }; +#define INTEGRATOR_SC_VALID_INT 0x003fffff + +static void __init ap_init_irq(void) +{ + /* Disable all interrupts initially. */ + /* Do the core module ones */ + writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR); + + /* do the header card stuff next */ + writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR); + writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR); + + fpga_irq_init(VA_IC_BASE, "SC", IRQ_PIC_START, + -1, INTEGRATOR_SC_VALID_INT, NULL); + integrator_clk_init(false); +} + MACHINE_START(INTEGRATOR, "ARM-Integrator") /* 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 diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index 2b40bc1..e7f2fb6 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c @@ -23,6 +23,8 @@ #include <linux/gfp.h> #include <linux/mtd/physmap.h> #include <linux/platform_data/clk-integrator.h> +#include <linux/of_irq.h> +#include <linux/of_address.h> #include <mach/hardware.h> #include <mach/platform.h> @@ -53,10 +55,6 @@ #define INTCP_PA_CLCD_BASE 0xc0000000 -#define INTCP_VA_CIC_BASE __io_address(INTEGRATOR_HDR_BASE + 0x40) -#define INTCP_VA_PIC_BASE __io_address(INTEGRATOR_IC_BASE) -#define INTCP_VA_SIC_BASE __io_address(INTEGRATOR_CP_SIC_BASE) - #define INTCP_ETH_SIZE 0x10 #define INTCP_VA_CTRL_BASE IO_ADDRESS(INTEGRATOR_CP_CTL_BASE) @@ -143,37 +141,6 @@ static void __init intcp_map_io(void) iotable_init(intcp_io_desc, ARRAY_SIZE(intcp_io_desc)); } -static void __init intcp_init_irq(void) -{ - u32 pic_mask, cic_mask, sic_mask; - - /* These masks are for the HW IRQ registers */ - pic_mask = ~((~0u) << (11 - IRQ_PIC_START)); - pic_mask |= (~((~0u) << (29 - 22))) << 22; - cic_mask = ~((~0u) << (1 + IRQ_CIC_END - IRQ_CIC_START)); - sic_mask = ~((~0u) << (1 + IRQ_SIC_END - IRQ_SIC_START)); - - /* - * Disable all interrupt sources - */ - writel(0xffffffff, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR); - writel(0xffffffff, INTCP_VA_PIC_BASE + FIQ_ENABLE_CLEAR); - writel(0xffffffff, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR); - writel(0xffffffff, INTCP_VA_CIC_BASE + FIQ_ENABLE_CLEAR); - writel(sic_mask, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR); - writel(sic_mask, INTCP_VA_SIC_BASE + FIQ_ENABLE_CLEAR); - - fpga_irq_init(INTCP_VA_PIC_BASE, "PIC", IRQ_PIC_START, - -1, pic_mask, NULL); - - fpga_irq_init(INTCP_VA_CIC_BASE, "CIC", IRQ_CIC_START, - -1, cic_mask, NULL); - - fpga_irq_init(INTCP_VA_SIC_BASE, "SIC", IRQ_SIC_START, - IRQ_CP_CPPLDINT, sic_mask, NULL); - integrator_clk_init(true); -} - /* * Flash handling. */ @@ -356,17 +323,114 @@ static void __init intcp_init_early(void) #endif } -static void __init intcp_init(void) +static void __init intcp_timer_init_of(void) +{ + struct device_node *node; + const char *path; + void __iomem *base; + int err; + int irq; + + err = of_property_read_string(of_aliases, + "arm,integrator-clocksource", &path); + if (WARN_ON(err)) + return; + node = of_find_node_by_path(path); + base = of_iomap(node, 0); + if (WARN_ON(!base)) + return; + writel(0, base + TIMER_CTRL); + sp804_clocksource_init(base, node->name); + + err = of_property_read_string(of_aliases, + "arm,integrator-clockevent", &path); + if (WARN_ON(err)) + return; + node = of_find_node_by_path(path); + base = of_iomap(node, 0); + if (WARN_ON(!base)) + return; + irq = irq_of_parse_and_map(node, 0); + writel(0, base + TIMER_CTRL); + sp804_clockevents_init(base, irq, node->name); +} + +static struct sys_timer cp_of_timer = { + .init = intcp_timer_init_of, +}; + +#ifdef CONFIG_OF + +static const struct of_device_id fpga_irq_of_match[] __initconst = { + { .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, }, + { /* Sentinel */ } +}; + +static void __init intcp_init_irq_of(void) { - int i; + of_irq_init(fpga_irq_of_match); + integrator_clk_init(true); +} - platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); +static const char * intcp_dt_board_compat[] = { + "arm,integrator-cp", + NULL, +}; - for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { - struct amba_device *d = amba_devs[i]; - amba_device_register(d, &iomem_resource); - } - integrator_init(true); +DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)") + .reserve = integrator_reserve, + .map_io = intcp_map_io, + .nr_irqs = NR_IRQS_INTEGRATOR_CP, + .init_early = intcp_init_early, + .init_irq = intcp_init_irq_of, + .handle_irq = fpga_handle_irq, + .timer = &cp_of_timer, + .init_machine = intcp_init, + .restart = integrator_restart, + .dt_compat = intcp_dt_board_compat, +MACHINE_END + +#else + +/* + * This is where non-devicetree initialization code is collected and stashed + * for eventual deletion. + */ + +#define INTCP_VA_CIC_BASE __io_address(INTEGRATOR_HDR_BASE + 0x40) +#define INTCP_VA_PIC_BASE __io_address(INTEGRATOR_IC_BASE) +#define INTCP_VA_SIC_BASE __io_address(INTEGRATOR_CP_SIC_BASE) + +static void __init intcp_init_irq(void) +{ + u32 pic_mask, cic_mask, sic_mask; + + /* These masks are for the HW IRQ registers */ + pic_mask = ~((~0u) << (11 - IRQ_PIC_START)); + pic_mask |= (~((~0u) << (29 - 22))) << 22; + cic_mask = ~((~0u) << (1 + IRQ_CIC_END - IRQ_CIC_START)); + sic_mask = ~((~0u) << (1 + IRQ_SIC_END - IRQ_SIC_START)); + + /* + * Disable all interrupt sources + */ + writel(0xffffffff, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR); + writel(0xffffffff, INTCP_VA_PIC_BASE + FIQ_ENABLE_CLEAR); + writel(0xffffffff, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR); + writel(0xffffffff, INTCP_VA_CIC_BASE + FIQ_ENABLE_CLEAR); + writel(sic_mask, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR); + writel(sic_mask, INTCP_VA_SIC_BASE + FIQ_ENABLE_CLEAR); + + fpga_irq_init(INTCP_VA_PIC_BASE, "PIC", IRQ_PIC_START, + -1, pic_mask, NULL); + + fpga_irq_init(INTCP_VA_CIC_BASE, "CIC", IRQ_CIC_START, + -1, cic_mask, NULL); + + fpga_irq_init(INTCP_VA_SIC_BASE, "SIC", IRQ_SIC_START, + IRQ_CP_CPPLDINT, sic_mask, NULL); + + integrator_clk_init(true); } #define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE) @@ -400,3 +464,5 @@ MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") .init_machine = intcp_init, .restart = integrator_restart, MACHINE_END + +#endif -- 1.7.11.4 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 5/6 v2] ARM: integrator: convert AMBA devices to device tree 2012-09-01 3:55 ` [PATCH 4/6 v2] ARM: integrator: initial device tree support Linus Walleij @ 2012-09-01 3:55 ` Linus Walleij 2012-09-01 3:55 ` [PATCH 6/6 v2] ARM: integrator: convert platform devices to Device Tree Linus Walleij 0 siblings, 1 reply; 2+ messages in thread From: Linus Walleij @ 2012-09-01 3:55 UTC (permalink / raw) To: linux-arm-kernel 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. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- 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(-) diff --git a/arch/arm/boot/dts/integratorap.dts b/arch/arm/boot/dts/integratorap.dts index 928a7be..de51bcf 100644 --- a/arch/arm/boot/dts/integratorap.dts +++ b/arch/arm/boot/dts/integratorap.dts @@ -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>; + }; + }; }; diff --git a/arch/arm/boot/dts/integratorcp.dts b/arch/arm/boot/dts/integratorcp.dts index 8fad5a1..3265b25 100644 --- a/arch/arm/boot/dts/integratorcp.dts +++ b/arch/arm/boot/dts/integratorcp.dts @@ -66,4 +66,61 @@ clear-mask = <0x00000fff>; valid-mask = <0x00000fff>; }; + + 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>; + }; + + uart0: uart at 16000000 { + compatible = "arm,pl011", "arm,primecell"; + reg = <0x16000000 0x1000>; + interrupts = <1>; + }; + + uart1: uart at 17000000 { + compatible = "arm,pl011", "arm,primecell"; + reg = <0x17000000 0x1000>; + interrupts = <2>; + }; + + kmi0: kmi at 18000000 { + compatible = "arm,pl050", "arm,primecell"; + reg = <0x18000000 0x1000>; + interrupts = <3>; + }; + + kmi1: kmi at 19000000 { + compatible = "arm,pl050", "arm,primecell"; + reg = <0x19000000 0x1000>; + interrupts = <4>; + }; + + mmci: mmc at 1C000000 { + compatible = "arm,pl180", "arm,primecell"; + reg = <0x1C000000 0x1000>; + interrupts = <23 24>; + max-frequency = <515633>; + }; + + aaci: aaci at 1D000000 { + compatible = "arm,pl041", "arm,primecell"; + reg = <0x1D000000 0x1000>; + interrupts = <25>; + }; + + clcd: clcd at c0000000 { + compatible = "arm,pl110", "arm,primecell"; + reg = <0xC0000000 0x1000>; + interrupts = <22>; + }; + }; }; diff --git a/arch/arm/mach-integrator/common.h b/arch/arm/mach-integrator/common.h index c4338e2..c3ff21b 100644 --- a/arch/arm/mach-integrator/common.h +++ b/arch/arm/mach-integrator/common.h @@ -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); diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c index 67ea181..42890c8 100644 --- a/arch/arm/mach-integrator/core.c +++ b/arch/arm/mach-integrator/core.c @@ -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, }; diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index 26d4d8c..990ce85 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c @@ -36,6 +36,7 @@ #include <linux/platform_data/clk-integrator.h> #include <linux/of_irq.h> #include <linux/of_address.h> +#include <linux/of_platform.h> #include <video/vga.h> #include <mach/hardware.h> @@ -271,36 +272,6 @@ static struct platform_device cfi_flash_device = { .resource = &cfi_flash_resource, }; -static void __init ap_init(void) -{ - unsigned long sc_dec; - int i; - - 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; - - if ((sc_dec & (16 << i)) == 0) - continue; - - lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL); - if (!lmdev) - continue; - - lmdev->resource.start = 0xc0000000 + 0x10000000 * i; - lmdev->resource.end = lmdev->resource.start + 0x0fffffff; - lmdev->resource.flags = IORESOURCE_MEM; - lmdev->irq = IRQ_AP_EXPINT0 + i; - lmdev->id = i; - - lm_device_register(lmdev); - } - - integrator_init(false); -} - /* * Where is the timer (VA)? */ @@ -493,6 +464,52 @@ static void __init ap_init_irq_of(void) integrator_clk_init(false); } +/* For the Device Tree, add in the UART callbacks as AUXDATA */ +static struct of_dev_auxdata ap_auxdata_lookup[] __initdata = { + OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE, + "rtc", NULL), + OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE, + "uart0", &integrator_uart_data), + OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE, + "uart1", &integrator_uart_data), + OF_DEV_AUXDATA("arm,primecell", KMI0_BASE, + "kmi0", NULL), + OF_DEV_AUXDATA("arm,primecell", KMI1_BASE, + "kmi1", NULL), + { /* sentinel */ }, +}; + +static void __init ap_init_of(void) +{ + unsigned long sc_dec; + int i; + + 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; + + if ((sc_dec & (16 << i)) == 0) + continue; + + lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL); + if (!lmdev) + continue; + + lmdev->resource.start = 0xc0000000 + 0x10000000 * i; + lmdev->resource.end = lmdev->resource.start + 0x0fffffff; + lmdev->resource.flags = IORESOURCE_MEM; + lmdev->irq = IRQ_AP_EXPINT0 + i; + lmdev->id = i; + + lm_device_register(lmdev); + } +} + static const char * ap_dt_board_compat[] = { "arm,integrator-ap", NULL, @@ -506,7 +523,7 @@ DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)") .init_irq = ap_init_irq_of, .handle_irq = fpga_handle_irq, .timer = &ap_of_timer, - .init_machine = ap_init, + .init_machine = ap_init_of, .restart = integrator_restart, .dt_compat = ap_dt_board_compat, MACHINE_END @@ -558,6 +575,36 @@ static void __init ap_init_irq(void) integrator_clk_init(false); } +static void __init ap_init(void) +{ + unsigned long sc_dec; + int i; + + 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; + + if ((sc_dec & (16 << i)) == 0) + continue; + + lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL); + if (!lmdev) + continue; + + lmdev->resource.start = 0xc0000000 + 0x10000000 * i; + lmdev->resource.end = lmdev->resource.start + 0x0fffffff; + lmdev->resource.flags = IORESOURCE_MEM; + lmdev->irq = IRQ_AP_EXPINT0 + i; + lmdev->id = i; + + lm_device_register(lmdev); + } + + integrator_init(false); +} + MACHINE_START(INTEGRATOR, "ARM-Integrator") /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ .atag_offset = 0x100, diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index e7f2fb6..1b07aa6 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c @@ -25,6 +25,7 @@ #include <linux/platform_data/clk-integrator.h> #include <linux/of_irq.h> #include <linux/of_address.h> +#include <linux/of_platform.h> #include <mach/hardware.h> #include <mach/platform.h> @@ -245,16 +246,6 @@ static struct mmci_platform_data mmc_data = { .gpio_cd = -1, }; -#define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 } -#define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT } - -static AMBA_APB_DEVICE(mmc, "mmci", 0, INTEGRATOR_CP_MMC_BASE, - INTEGRATOR_CP_MMC_IRQS, &mmc_data); - -static AMBA_APB_DEVICE(aaci, "aaci", 0, INTEGRATOR_CP_AACI_BASE, - INTEGRATOR_CP_AACI_IRQS, NULL); - - /* * CLCD support */ @@ -305,15 +296,6 @@ static struct clcd_board clcd_data = { .remove = versatile_clcd_remove_dma, }; -static AMBA_AHB_DEVICE(clcd, "clcd", 0, INTCP_PA_CLCD_BASE, - { IRQ_CP_CLCDCINT }, &clcd_data); - -static struct amba_device *amba_devs[] __initdata = { - &mmc_device, - &aaci_device, - &clcd_device, -}; - #define REFCOUNTER (__io_address(INTEGRATOR_HDR_BASE) + 0x28) static void __init intcp_init_early(void) @@ -372,6 +354,37 @@ static void __init intcp_init_irq_of(void) integrator_clk_init(true); } +/* + * For the Device Tree, add in the UART, MMC and CLCD specifics as AUXDATA + * and enforce the bus names since these are used for clock lookups. + */ +static struct of_dev_auxdata intcp_auxdata_lookup[] __initdata = { + OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE, + "rtc", NULL), + OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE, + "uart0", &integrator_uart_data), + OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE, + "uart1", &integrator_uart_data), + OF_DEV_AUXDATA("arm,primecell", KMI0_BASE, + "kmi0", NULL), + OF_DEV_AUXDATA("arm,primecell", KMI1_BASE, + "kmi1", NULL), + OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_MMC_BASE, + "mmci", &mmc_data), + OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_AACI_BASE, + "aaci", &mmc_data), + OF_DEV_AUXDATA("arm,primecell", INTCP_PA_CLCD_BASE, + "clcd", &clcd_data), + { /* sentinel */ }, +}; + +static void __init intcp_init_of(void) +{ + of_platform_populate(NULL, of_default_bus_match_table, + intcp_auxdata_lookup, NULL); + platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); +} + static const char * intcp_dt_board_compat[] = { "arm,integrator-cp", NULL, @@ -385,7 +398,7 @@ DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)") .init_irq = intcp_init_irq_of, .handle_irq = fpga_handle_irq, .timer = &cp_of_timer, - .init_machine = intcp_init, + .init_machine = intcp_init_of, .restart = integrator_restart, .dt_compat = intcp_dt_board_compat, MACHINE_END @@ -451,6 +464,37 @@ static struct sys_timer cp_timer = { .init = intcp_timer_init, }; +#define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 } +#define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT } + +static AMBA_APB_DEVICE(mmc, "mmci", 0, INTEGRATOR_CP_MMC_BASE, + INTEGRATOR_CP_MMC_IRQS, &mmc_data); + +static AMBA_APB_DEVICE(aaci, "aaci", 0, INTEGRATOR_CP_AACI_BASE, + INTEGRATOR_CP_AACI_IRQS, NULL); + +static AMBA_AHB_DEVICE(clcd, "clcd", 0, INTCP_PA_CLCD_BASE, + { IRQ_CP_CLCDCINT }, &clcd_data); + +static struct amba_device *amba_devs[] __initdata = { + &mmc_device, + &aaci_device, + &clcd_device, +}; + +static void __init intcp_init(void) +{ + int i; + + platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); + + for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { + struct amba_device *d = amba_devs[i]; + amba_device_register(d, &iomem_resource); + } + integrator_init(true); +} + MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ .atag_offset = 0x100, -- 1.7.11.4 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 6/6 v2] ARM: integrator: convert platform devices to Device Tree 2012-09-01 3:55 ` [PATCH 5/6 v2] ARM: integrator: convert AMBA devices to device tree Linus Walleij @ 2012-09-01 3:55 ` Linus Walleij 0 siblings, 0 replies; 2+ messages in thread From: Linus Walleij @ 2012-09-01 3:55 UTC (permalink / raw) To: linux-arm-kernel 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. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- 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(-) diff --git a/arch/arm/boot/dts/integratorap.dts b/arch/arm/boot/dts/integratorap.dts index de51bcf..044c72b 100644 --- a/arch/arm/boot/dts/integratorap.dts +++ b/arch/arm/boot/dts/integratorap.dts @@ -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>; diff --git a/arch/arm/boot/dts/integratorcp.dts b/arch/arm/boot/dts/integratorcp.dts index 3265b25..8584241 100644 --- a/arch/arm/boot/dts/integratorcp.dts +++ b/arch/arm/boot/dts/integratorcp.dts @@ -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>; diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index 990ce85..aaa6b01 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c @@ -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; diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index 1b07aa6..1f4a7be 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c @@ -52,12 +52,9 @@ #include "common.h" #define INTCP_PA_FLASH_BASE 0x24000000 -#define INTCP_FLASH_SIZE SZ_32M #define INTCP_PA_CLCD_BASE 0xc0000000 -#define INTCP_ETH_SIZE 0x10 - #define INTCP_VA_CTRL_BASE IO_ADDRESS(INTEGRATOR_CP_CTL_BASE) #define INTCP_FLASHPROG 0x04 #define CINTEGRATOR_FLASHPROG_FLVPPEN (1 << 0) @@ -184,47 +181,6 @@ static struct physmap_flash_data intcp_flash_data = { .set_vpp = intcp_flash_set_vpp, }; -static struct resource intcp_flash_resource = { - .start = INTCP_PA_FLASH_BASE, - .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1, - .flags = IORESOURCE_MEM, -}; - -static struct platform_device intcp_flash_device = { - .name = "physmap-flash", - .id = 0, - .dev = { - .platform_data = &intcp_flash_data, - }, - .num_resources = 1, - .resource = &intcp_flash_resource, -}; - -static struct resource smc91x_resources[] = { - [0] = { - .start = INTEGRATOR_CP_ETH_BASE, - .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_CP_ETHINT, - .end = IRQ_CP_ETHINT, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct platform_device smc91x_device = { - .name = "smc91x", - .id = 0, - .num_resources = ARRAY_SIZE(smc91x_resources), - .resource = smc91x_resources, -}; - -static struct platform_device *intcp_devs[] __initdata = { - &intcp_flash_device, - &smc91x_device, -}; - /* * It seems that the card insertion interrupt remains active after * we've acknowledged it. We therefore ignore the interrupt, and @@ -375,6 +331,8 @@ static struct of_dev_auxdata intcp_auxdata_lookup[] __initdata = { "aaci", &mmc_data), OF_DEV_AUXDATA("arm,primecell", INTCP_PA_CLCD_BASE, "clcd", &clcd_data), + OF_DEV_AUXDATA("cfi-flash", INTCP_PA_FLASH_BASE, + "physmap-flash", &intcp_flash_data), { /* sentinel */ }, }; @@ -382,7 +340,6 @@ static void __init intcp_init_of(void) { of_platform_populate(NULL, of_default_bus_match_table, intcp_auxdata_lookup, NULL); - platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); } static const char * intcp_dt_board_compat[] = { @@ -410,6 +367,51 @@ MACHINE_END * for eventual deletion. */ +#define INTCP_FLASH_SIZE SZ_32M + +static struct resource intcp_flash_resource = { + .start = INTCP_PA_FLASH_BASE, + .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1, + .flags = IORESOURCE_MEM, +}; + +static struct platform_device intcp_flash_device = { + .name = "physmap-flash", + .id = 0, + .dev = { + .platform_data = &intcp_flash_data, + }, + .num_resources = 1, + .resource = &intcp_flash_resource, +}; + +#define INTCP_ETH_SIZE 0x10 + +static struct resource smc91x_resources[] = { + [0] = { + .start = INTEGRATOR_CP_ETH_BASE, + .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = IRQ_CP_ETHINT, + .end = IRQ_CP_ETHINT, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device smc91x_device = { + .name = "smc91x", + .id = 0, + .num_resources = ARRAY_SIZE(smc91x_resources), + .resource = smc91x_resources, +}; + +static struct platform_device *intcp_devs[] __initdata = { + &intcp_flash_device, + &smc91x_device, +}; + #define INTCP_VA_CIC_BASE __io_address(INTEGRATOR_HDR_BASE + 0x40) #define INTCP_VA_PIC_BASE __io_address(INTEGRATOR_IC_BASE) #define INTCP_VA_SIC_BASE __io_address(INTEGRATOR_CP_SIC_BASE) -- 1.7.11.4 ^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-05 19:29 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-09-05 19:29 [PATCH 6/6 v2] ARM: integrator: convert platform devices to Device Tree Linus Walleij -- strict thread matches above, loose matches on Subject: below -- 2012-09-01 3:55 [PATCH 1/6 v2] ARM: integrator: call common init function from machine Linus Walleij 2012-09-01 3:55 ` [PATCH 2/6 v2] ARM: integrator: check PL010 device name rather than base address Linus Walleij 2012-09-01 3:55 ` [PATCH 3/6 v2] ARM: plat-versatile: add DT support to FPGA IRQ controller Linus Walleij 2012-09-01 3:55 ` [PATCH 4/6 v2] ARM: integrator: initial device tree support Linus Walleij 2012-09-01 3:55 ` [PATCH 5/6 v2] ARM: integrator: convert AMBA devices to device tree Linus Walleij 2012-09-01 3:55 ` [PATCH 6/6 v2] ARM: integrator: convert platform devices to Device Tree Linus Walleij
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).