ARM: nomadik: initial devicetree support
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 4 Jan 2013 23:29:31 +0000 (00:29 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 28 Jan 2013 22:23:44 +0000 (23:23 +0100)
Support basic device tree boot on the Nomadik. Implement the
support in the cpu file with the intent of deleting the board
files later. At this stage IRQ controllers, system timer,
l2x0 cache, UARTs and thus console boot is fully functional.
Patch out the code adding devices by initcalls for now so
as not to disturb the boot.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Documentation/devicetree/bindings/arm/ste-nomadik.txt [new file with mode: 0644]
arch/arm/boot/dts/Makefile
arch/arm/boot/dts/ste-nomadik-s8815.dts [new file with mode: 0644]
arch/arm/boot/dts/ste-nomadik-stn8815.dtsi [new file with mode: 0644]
arch/arm/mach-nomadik/board-nhk8815.c
arch/arm/mach-nomadik/cpu-8815.c
arch/arm/mach-nomadik/cpu-8815.h
arch/arm/mach-nomadik/i2c-8815nhk.c

diff --git a/Documentation/devicetree/bindings/arm/ste-nomadik.txt b/Documentation/devicetree/bindings/arm/ste-nomadik.txt
new file mode 100644 (file)
index 0000000..23f32bd
--- /dev/null
@@ -0,0 +1,19 @@
+ST-Ericsson Nomadik Device Tree Bindings
+
+For various board the "board" node may contain specific properties
+that pertain to this particular board, such as board-specific GPIOs.
+
+Boards with the Nomadik SoC include:
+
+S8815 "MiniKit" manufactured by Calao Systems:
+
+Required root node property:
+
+compatible="calaosystems,usb-s8815";
+
+Required node: usb-s8815
+
+Example:
+
+usb-s8815 {
+};
index e44da40d984f7faa18bb8a32f51f5f1fe233f20a..7bc5ba738041b05a0a8c818f1be44072d73f7833 100644 (file)
@@ -100,6 +100,7 @@ dtb-$(CONFIG_ARCH_MXS) += imx23-evk.dtb \
        imx28-m28evk.dtb \
        imx28-sps1.dtb \
        imx28-tx28.dtb
+dtb-$(CONFIG_ARCH_NOMADIK) += ste-nomadik-s8815.dtb
 dtb-$(CONFIG_ARCH_OMAP2PLUS) += omap2420-h4.dtb \
        omap3-beagle.dtb \
        omap3-beagle-xm.dtb \
diff --git a/arch/arm/boot/dts/ste-nomadik-s8815.dts b/arch/arm/boot/dts/ste-nomadik-s8815.dts
new file mode 100644 (file)
index 0000000..97b7d1d
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Device Tree for the ST-Ericsson Nomadik S8815 board
+ * Produced by Calao Systems
+ */
+
+/dts-v1/;
+/include/ "ste-nomadik-stn8815.dtsi"
+
+/ {
+       model = "Calao Systems USB-S8815";
+       compatible = "calaosystems,usb-s8815";
+
+       chosen {
+               bootargs = "root=/dev/ram0 console=ttyAMA1,115200n8 earlyprintk";
+       };
+
+       /* Custom board node with GPIO pins to active etc */
+       usb-s8815 {
+       };
+};
diff --git a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi
new file mode 100644 (file)
index 0000000..0a5b670
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Device Tree for the ST-Ericsson Nomadik 8815 STn8815 SoC
+ */
+/include/ "skeleton.dtsi"
+
+/ {
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       memory {
+               reg = <0x00000000 0x04000000>,
+                   <0x08000000 0x04000000>;
+       };
+
+       L2: l2-cache {
+               compatible = "arm,l210-cache";
+               reg = <0x10210000 0x1000>;
+               interrupt-parent = <&vica>;
+               interrupts = <30>;
+               cache-unified;
+               cache-level = <2>;
+       };
+
+       mtu0 {
+               /* Nomadik system timer */
+               reg = <0x101e2000 0x1000>;
+               interrupt-parent = <&vica>;
+               interrupts = <4>;
+       };
+
+       mtu1 {
+               /* Secondary timer */
+               reg = <0x101e3000 0x1000>;
+               interrupt-parent = <&vica>;
+               interrupts = <5>;
+       };
+
+       amba {
+               compatible = "arm,amba-bus";
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges;
+
+               vica: intc@0x10140000 {
+                       compatible = "arm,versatile-vic";
+                       interrupt-controller;
+                       #interrupt-cells = <1>;
+                       reg = <0x10140000 0x20>;
+               };
+
+               vicb: intc@0x10140020 {
+                       compatible = "arm,versatile-vic";
+                       interrupt-controller;
+                       #interrupt-cells = <1>;
+                       reg = <0x10140020 0x20>;
+               };
+
+               uart0: uart@101fd000 {
+                       compatible = "arm,pl011", "arm,primecell";
+                       reg = <0x101fd000 0x1000>;
+                       interrupt-parent = <&vica>;
+                       interrupts = <12>;
+               };
+
+               uart1: uart@101fb000 {
+                       compatible = "arm,pl011", "arm,primecell";
+                       reg = <0x101fb000 0x1000>;
+                       interrupt-parent = <&vica>;
+                       interrupts = <17>;
+               };
+
+               uart2: uart@101f2000 {
+                       compatible = "arm,pl011", "arm,primecell";
+                       reg = <0x101f2000 0x1000>;
+                       interrupt-parent = <&vica>;
+                       interrupts = <28>;
+                       status = "disabled";
+               };
+       };
+};
index 72ec3fad2ba6cd66c5e7d5dfa3264c515e47cb32..d152d7bdf41150cd96d0b3c9e1704c7ef1df659d 100644 (file)
@@ -204,6 +204,10 @@ static int __init nhk8815_mmcsd_init(void)
 {
        int ret;
 
+       /* For e.g. devicetree boot */
+       if (!machine_is_nomadik())
+               return 0;
+
        ret = gpio_request(112, "card detect bias");
        if (ret)
                return ret;
index 351404673f6cad5476d664d05f98ffd18d15696b..7c8e3487f4eba57f24ad33113ce19200763f5c1d 100644 (file)
 #include <linux/slab.h>
 #include <linux/irq.h>
 #include <linux/dma-mapping.h>
-#include <linux/irqchip/arm-vic.h>
+#include <linux/irqchip.h>
 #include <linux/platform_data/clk-nomadik.h>
 #include <linux/platform_data/pinctrl-nomadik.h>
+#include <linux/platform_data/clocksource-nomadik-mtu.h>
+#include <linux/of_irq.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
 
 #include <mach/hardware.h>
 #include <mach/irqs.h>
+#include <asm/mach/arch.h>
 #include <asm/mach/map.h>
+#include <asm/mach/time.h>
 
 #include <asm/cacheflush.h>
 #include <asm/hardware/cache-l2x0.h>
@@ -160,3 +166,73 @@ void cpu8815_restart(char mode, const char *cmd)
        /* Write anything to Reset status register */
        writel(1, src_rstsr);
 }
+
+#ifdef CONFIG_OF
+
+/* Initial value for SRC control register: all timers use MXTAL/8 source */
+#define SRC_CR_INIT_MASK       0x00007fff
+#define SRC_CR_INIT_VAL                0x2aaa8000
+
+static void __init cpu8815_timer_init_of(void)
+{
+       struct device_node *mtu;
+       void __iomem *base;
+       int irq;
+       u32 src_cr;
+
+       /* We need this to be up now */
+       nomadik_clk_init();
+
+       mtu = of_find_node_by_path("/mtu0");
+       if (!mtu)
+               return;
+       base = of_iomap(mtu, 0);
+       if (WARN_ON(!base))
+               return;
+       irq = irq_of_parse_and_map(mtu, 0);
+
+       pr_info("Remapped MTU @ %p, irq: %d\n", base, irq);
+
+       /* Configure timer sources in "system reset controller" ctrl reg */
+       src_cr = readl(base);
+       src_cr &= SRC_CR_INIT_MASK;
+       src_cr |= SRC_CR_INIT_VAL;
+       writel(src_cr, base);
+
+       nmdk_timer_init(base, irq);
+}
+
+/* These are mostly to get the right device names for the clock lookups */
+static struct of_dev_auxdata cpu8815_auxdata_lookup[] __initdata = {
+       OF_DEV_AUXDATA("arm,primecell", NOMADIK_UART0_BASE,
+               "uart0", NULL),
+       OF_DEV_AUXDATA("arm,primecell", NOMADIK_UART1_BASE,
+               "uart1", NULL),
+       { /* sentinel */ },
+};
+
+static void __init cpu8815_init_of(void)
+{
+#ifdef CONFIG_CACHE_L2X0
+       /* At full speed latency must be >=2, so 0x249 in low bits */
+       l2x0_of_init(0x00730249, 0xfe000fff);
+#endif
+       of_platform_populate(NULL, of_default_bus_match_table,
+                       cpu8815_auxdata_lookup, NULL);
+}
+
+static const char * cpu8815_board_compat[] = {
+       "calaosystems,usb-s8815",
+       NULL,
+};
+
+DT_MACHINE_START(NOMADIK_DT, "Nomadik STn8815")
+       .map_io         = cpu8815_map_io,
+       .init_irq       = irqchip_init,
+       .init_time      = cpu8815_timer_init_of,
+       .init_machine   = cpu8815_init_of,
+       .restart        = cpu8815_restart,
+       .dt_compat      = cpu8815_board_compat,
+MACHINE_END
+
+#endif
index 71c21e8a11dc4897dbf551ad1e2b46fed357fb0c..d6c7830e479962c44685367fcef9f77232aa20e2 100644 (file)
@@ -2,3 +2,4 @@ extern void cpu8815_map_io(void);
 extern void cpu8815_platform_init(void);
 extern void cpu8815_init_irq(void);
 extern void cpu8815_restart(char, const char *);
+extern struct sys_timer cpu8815_timer;
index f0e9e64f731a8b915969b1705526aa6734e69b87..299ff5a687bcbbd1d4bede35c964c86b1226f966 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/i2c-algo-bit.h>
 #include <linux/i2c-gpio.h>
 #include <linux/platform_device.h>
+#include <asm/mach-types.h>
 
 /*
  * There are two busses in the 8815NHK.
@@ -58,6 +59,10 @@ static struct platform_device nhk8815_i2c_dev2 = {
 
 static int __init nhk8815_i2c_init(void)
 {
+       /* For e.g. devicetree boot */
+       if (!machine_is_nomadik())
+               return 0;
+
        platform_device_register(&nhk8815_i2c_dev0);
        platform_device_register(&nhk8815_i2c_dev1);
        platform_device_register(&nhk8815_i2c_dev2);