metag: move setup_machine_fdt declaration from prom.h
[deliverable/linux.git] / arch / microblaze / kernel / prom.c
CommitLineData
12e84142
MS
1/*
2 * Procedures for creating, accessing and interpreting the device tree.
3 *
4 * Paul Mackerras August 1996.
5 * Copyright (C) 1996-2005 Paul Mackerras.
6 *
7 * Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
8 * {engebret|bergner}@us.ibm.com
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#include <stdarg.h>
d64af918 17#include <linux/export.h>
12e84142
MS
18#include <linux/kernel.h>
19#include <linux/string.h>
20#include <linux/init.h>
21#include <linux/threads.h>
22#include <linux/spinlock.h>
23#include <linux/types.h>
24#include <linux/pci.h>
25#include <linux/stringify.h>
26#include <linux/delay.h>
27#include <linux/initrd.h>
28#include <linux/bitops.h>
12e84142
MS
29#include <linux/kexec.h>
30#include <linux/debugfs.h>
31#include <linux/irq.h>
95f72d1e 32#include <linux/memblock.h>
12e84142
MS
33
34#include <asm/prom.h>
35#include <asm/page.h>
36#include <asm/processor.h>
37#include <asm/irq.h>
38#include <linux/io.h>
12e84142
MS
39#include <asm/mmu.h>
40#include <asm/pgtable.h>
12e84142
MS
41#include <asm/sections.h>
42#include <asm/pci-bridge.h>
43
12e84142 44#ifdef CONFIG_EARLY_PRINTK
c0d997fb 45static char *stdout;
12e84142 46
c0d997fb 47static int __init early_init_dt_scan_chosen_serial(unsigned long node,
67f4aaa2
MS
48 const char *uname, int depth, void *data)
49{
50 unsigned long l;
51 char *p;
67f4aaa2 52
2aa8e375
MS
53 pr_debug("%s: depth: %d, uname: %s\n", __func__, depth, uname);
54
55 if (depth == 1 && (strcmp(uname, "chosen") == 0 ||
56 strcmp(uname, "chosen@0") == 0)) {
57 p = of_get_flat_dt_prop(node, "linux,stdout-path", &l);
58 if (p != NULL && l > 0)
59 stdout = p; /* store pointer to stdout-path */
60 }
61
62 if (stdout && strstr(stdout, uname)) {
63 p = of_get_flat_dt_prop(node, "compatible", &l);
64 pr_debug("Compatible string: %s\n", p);
65
66 if ((strncmp(p, "xlnx,xps-uart16550", 18) == 0) ||
67 (strncmp(p, "xlnx,axi-uart16550", 18) == 0)) {
68 unsigned int addr;
69
70 *(u32 *)data = UART16550;
71
72 addr = *(u32 *)of_get_flat_dt_prop(node, "reg", &l);
73 addr += *(u32 *)of_get_flat_dt_prop(node,
74 "reg-offset", &l);
75 /* clear register offset */
76 return be32_to_cpu(addr) & ~3;
77 }
78 if ((strncmp(p, "xlnx,xps-uartlite", 17) == 0) ||
79 (strncmp(p, "xlnx,opb-uartlite", 17) == 0) ||
ca12adc8
MS
80 (strncmp(p, "xlnx,axi-uartlite", 17) == 0) ||
81 (strncmp(p, "xlnx,mdm", 8) == 0)) {
2aa8e375
MS
82 unsigned int *addrp;
83
84 *(u32 *)data = UARTLITE;
85
86 addrp = of_get_flat_dt_prop(node, "reg", &l);
87 return be32_to_cpup(addrp); /* return address */
88 }
89 }
90 return 0;
67f4aaa2
MS
91}
92
2aa8e375
MS
93/* this function is looking for early console - Microblaze specific */
94int __init of_early_console(void *version)
67f4aaa2 95{
2aa8e375 96 return of_scan_flat_dt(early_init_dt_scan_chosen_serial, version);
67f4aaa2 97}
12e84142
MS
98#endif
99
100void __init early_init_devtree(void *params)
101{
102 pr_debug(" -> early_init_devtree(%p)\n", params);
103
dc0b4335
RH
104 early_init_dt_scan(params);
105 if (!strlen(boot_command_line))
106 strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
12e84142 107
12e84142
MS
108 parse_early_param();
109
1aadc056 110 memblock_allow_resize();
12e84142 111
95f72d1e 112 pr_debug("Phys. mem: %lx\n", (unsigned long) memblock_phys_mem_size());
12e84142 113
12e84142
MS
114 pr_debug(" <- early_init_devtree()\n");
115}
116
12e84142
MS
117/*******
118 *
119 * New implementation of the OF "find" APIs, return a refcounted
120 * object, call of_node_put() when done. The device tree and list
121 * are protected by a rw_lock.
122 *
123 * Note that property management will need some locking as well,
124 * this isn't dealt with yet.
125 *
126 *******/
127
12e84142
MS
128#if defined(CONFIG_DEBUG_FS) && defined(DEBUG)
129static struct debugfs_blob_wrapper flat_dt_blob;
130
131static int __init export_flat_device_tree(void)
132{
133 struct dentry *d;
134
135 flat_dt_blob.data = initial_boot_params;
136 flat_dt_blob.size = initial_boot_params->totalsize;
137
138 d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR,
139 of_debugfs_root, &flat_dt_blob);
140 if (!d)
141 return 1;
142
143 return 0;
144}
145device_initcall(export_flat_device_tree);
146#endif
This page took 0.38133 seconds and 5 git commands to generate.