aboutsummaryrefslogtreecommitdiffstats
path: root/arch/openrisc
diff options
context:
space:
mode:
authorJonas Bonn <jonas@southpole.se>2011-06-04 14:56:16 -0400
committerJonas Bonn <jonas@southpole.se>2011-07-22 12:46:28 -0400
commit4f246ba30e1a9a31fcfd91d2ab8f5c75f1362bbf (patch)
treeca9082608d6ba42abd11bb12d068ac816aa2e842 /arch/openrisc
parent9d02a4283e9ce4e9ca11ff00615bdacdb0515a1a (diff)
OpenRISC: Device tree
The OpenRISC architecture uses the device tree infrastructure for the platform description. This is currently limited to having a device tree built into the kernel, but work is underway within the OpenRISC project to define how this device tree blob should be passed into the kernel from an external resource. Patch contains a single example DTS file to go with the defconfig for or1ksim. Signed-off-by: Jonas Bonn <jonas@southpole.se> Cc: devicetree-discuss@lists.ozlabs.org Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/openrisc')
-rw-r--r--arch/openrisc/boot/dts/or1ksim.dts50
-rw-r--r--arch/openrisc/include/asm/prom.h77
-rw-r--r--arch/openrisc/kernel/prom.c108
3 files changed, 235 insertions, 0 deletions
diff --git a/arch/openrisc/boot/dts/or1ksim.dts b/arch/openrisc/boot/dts/or1ksim.dts
new file mode 100644
index 000000000000..5d4f9027afaf
--- /dev/null
+++ b/arch/openrisc/boot/dts/or1ksim.dts
@@ -0,0 +1,50 @@
1/dts-v1/;
2/ {
3 compatible = "opencores,or1ksim";
4 #address-cells = <1>;
5 #size-cells = <1>;
6 interrupt-parent = <&pic>;
7
8 chosen {
9 bootargs = "console=uart,mmio,0x90000000,115200";
10 };
11
12 memory@0 {
13 device_type = "memory";
14 reg = <0x00000000 0x02000000>;
15 };
16
17 cpus {
18 #address-cells = <1>;
19 #size-cells = <0>;
20 cpu@0 {
21 compatible = "opencores,or1200-rtlsvn481";
22 reg = <0>;
23 clock-frequency = <20000000>;
24 };
25 };
26
27 /*
28 * OR1K PIC is built into CPU and accessed via special purpose
29 * registers. It is not addressable and, hence, has no 'reg'
30 * property.
31 */
32 pic: pic {
33 compatible = "opencores,or1k-pic";
34 #interrupt-cells = <1>;
35 interrupt-controller;
36 };
37
38 serial0: serial@90000000 {
39 compatible = "opencores,uart16550-rtlsvn105", "ns16550a";
40 reg = <0x90000000 0x100>;
41 interrupts = <2>;
42 clock-frequency = <20000000>;
43 };
44
45 enet0: ethoc@92000000 {
46 compatible = "opencores,ethmac-rtlsvn338";
47 reg = <0x92000000 0x100>;
48 interrupts = <4>;
49 };
50};
diff --git a/arch/openrisc/include/asm/prom.h b/arch/openrisc/include/asm/prom.h
new file mode 100644
index 000000000000..e1f3fe26606c
--- /dev/null
+++ b/arch/openrisc/include/asm/prom.h
@@ -0,0 +1,77 @@
1/*
2 * OpenRISC Linux
3 *
4 * Linux architectural port borrowing liberally from similar works of
5 * others. All original copyrights apply as per the original source
6 * declaration.
7 *
8 * OpenRISC implementation:
9 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
10 * et al.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 */
17
18#include <linux/of.h> /* linux/of.h gets to determine #include ordering */
19
20#ifndef _ASM_OPENRISC_PROM_H
21#define _ASM_OPENRISC_PROM_H
22#ifdef __KERNEL__
23#ifndef __ASSEMBLY__
24
25#include <linux/types.h>
26#include <asm/irq.h>
27#include <linux/atomic.h>
28#include <linux/of_irq.h>
29#include <linux/of_fdt.h>
30#include <linux/of_address.h>
31#include <linux/proc_fs.h>
32#include <linux/platform_device.h>
33#define HAVE_ARCH_DEVTREE_FIXUPS
34
35/* Other Prototypes */
36extern int early_uartlite_console(void);
37
38/* Parse the ibm,dma-window property of an OF node into the busno, phys and
39 * size parameters.
40 */
41void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
42 unsigned long *busno, unsigned long *phys, unsigned long *size);
43
44extern void kdump_move_device_tree(void);
45
46/* CPU OF node matching */
47struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
48
49/* Get the MAC address */
50extern const void *of_get_mac_address(struct device_node *np);
51
52/**
53 * of_irq_map_pci - Resolve the interrupt for a PCI device
54 * @pdev: the device whose interrupt is to be resolved
55 * @out_irq: structure of_irq filled by this function
56 *
57 * This function resolves the PCI interrupt for a given PCI device. If a
58 * device-node exists for a given pci_dev, it will use normal OF tree
59 * walking. If not, it will implement standard swizzling and walk up the
60 * PCI tree until an device-node is found, at which point it will finish
61 * resolving using the OF tree walking.
62 */
63struct pci_dev;
64extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
65
66/* This routine is here to provide compatibility with how powerpc
67 * handles IRQ mapping for OF device nodes. We precompute and permanently
68 * register them in the platform_device objects, whereas powerpc computes them
69 * on request.
70 */
71static inline void irq_dispose_mapping(unsigned int virq)
72{
73}
74
75#endif /* __ASSEMBLY__ */
76#endif /* __KERNEL__ */
77#endif /* _ASM_OPENRISC_PROM_H */
diff --git a/arch/openrisc/kernel/prom.c b/arch/openrisc/kernel/prom.c
new file mode 100644
index 000000000000..1bb58ba89afa
--- /dev/null
+++ b/arch/openrisc/kernel/prom.c
@@ -0,0 +1,108 @@
1/*
2 * OpenRISC prom.c
3 *
4 * Linux architectural port borrowing liberally from similar works of
5 * others. All original copyrights apply as per the original source
6 * declaration.
7 *
8 * Modifications for the OpenRISC architecture:
9 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 *
16 * Architecture specific procedures for creating, accessing and
17 * interpreting the device tree.
18 *
19 */
20
21#include <stdarg.h>
22#include <linux/kernel.h>
23#include <linux/string.h>
24#include <linux/init.h>
25#include <linux/threads.h>
26#include <linux/spinlock.h>
27#include <linux/types.h>
28#include <linux/pci.h>
29#include <linux/stringify.h>
30#include <linux/delay.h>
31#include <linux/initrd.h>
32#include <linux/bitops.h>
33#include <linux/module.h>
34#include <linux/kexec.h>
35#include <linux/debugfs.h>
36#include <linux/irq.h>
37#include <linux/memblock.h>
38#include <linux/of_fdt.h>
39
40#include <asm/prom.h>
41#include <asm/page.h>
42#include <asm/processor.h>
43#include <asm/irq.h>
44#include <linux/io.h>
45#include <asm/system.h>
46#include <asm/mmu.h>
47#include <asm/pgtable.h>
48#include <asm/sections.h>
49#include <asm/setup.h>
50
51extern char cmd_line[COMMAND_LINE_SIZE];
52
53void __init early_init_dt_add_memory_arch(u64 base, u64 size)
54{
55 size &= PAGE_MASK;
56 memblock_add(base, size);
57}
58
59void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
60{
61 return __va(memblock_alloc(size, align));
62}
63
64void __init early_init_devtree(void *params)
65{
66 void *alloc;
67
68 /* Setup flat device-tree pointer */
69 initial_boot_params = params;
70
71
72 /* Retrieve various informations from the /chosen node of the
73 * device-tree, including the platform type, initrd location and
74 * size, TCE reserve, and more ...
75 */
76 of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line);
77
78 /* Scan memory nodes and rebuild MEMBLOCKs */
79 memblock_init();
80 of_scan_flat_dt(early_init_dt_scan_root, NULL);
81 of_scan_flat_dt(early_init_dt_scan_memory, NULL);
82
83 /* Save command line for /proc/cmdline and then parse parameters */
84 strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
85
86 memblock_analyze();
87
88 /* We must copy the flattend device tree from init memory to regular
89 * memory because the device tree references the strings in it
90 * directly.
91 */
92
93 alloc = __va(memblock_alloc(initial_boot_params->totalsize, PAGE_SIZE));
94
95 memcpy(alloc, initial_boot_params, initial_boot_params->totalsize);
96
97 initial_boot_params = alloc;
98}
99
100#ifdef CONFIG_BLK_DEV_INITRD
101void __init early_init_dt_setup_initrd_arch(unsigned long start,
102 unsigned long end)
103{
104 initrd_start = (unsigned long)__va(start);
105 initrd_end = (unsigned long)__va(end);
106 initrd_below_start_ok = 1;
107}
108#endif