Skip to content

Commit 51f00a4

Browse files
committed
Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: mtd/m25p80: add support to parse the partitions by OF node of/irq: of_irq.c needs to include linux/irq.h of/mips: Cleanup some include directives/files. of/mips: Add device tree support to MIPS of/flattree: Eliminate need to provide early_init_dt_scan_chosen_arch of/device: Rework to use common platform_device_alloc() for allocating devices of/xsysace: Fix OF probing on little-endian systems of: use __be32 types for big-endian device tree data of/irq: remove references to NO_IRQ in drivers/of/platform.c of/promtree: add package-to-path support to pdt of/promtree: add of_pdt namespace to pdt code of/promtree: no longer call prom_ functions directly; use an ops structure of/promtree: make drivers/of/pdt.c no longer sparc-only sparc: break out some PROM device-tree building code out into drivers/of of/sparc: convert various prom_* functions to use phandle sparc: stop exporting openprom.h header powerpc, of_serial: Endianness issues setting up the serial ports of: MTD: Fix OF probing on little-endian systems of: GPIO: Fix OF probing on little-endian systems
2 parents a7f505c + 97ff46c commit 51f00a4

60 files changed

Lines changed: 800 additions & 417 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎arch/microblaze/kernel/prom.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
#include <asm/sections.h>
4343
#include <asm/pci-bridge.h>
4444

45-
void __init early_init_dt_scan_chosen_arch(unsigned long node)
46-
{
47-
/* No Microblaze specific code here */
48-
}
49-
5045
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
5146
{
5247
memblock_add(base, size);

‎arch/mips/Kconfig‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,6 +2128,13 @@ config SECCOMP
21282128

21292129
If unsure, say Y. Only embedded should say N here.
21302130

2131+
config USE_OF
2132+
bool "Flattened Device Tree support"
2133+
select OF
2134+
select OF_FLATTREE
2135+
help
2136+
Include support for flattened device tree machine descriptions.
2137+
21312138
endmenu
21322139

21332140
config LOCKDEP_SUPPORT

‎arch/mips/include/asm/irq.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
#include <irq.h>
1818

19+
static inline void irq_dispose_mapping(unsigned int virq)
20+
{
21+
return;
22+
}
23+
1924
#ifdef CONFIG_I8259
2025
static inline int irq_canonicalize(int irq)
2126
{

‎arch/mips/include/asm/prom.h‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* arch/mips/include/asm/prom.h
3+
*
4+
* Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License version 2 as
8+
* published by the Free Software Foundation.
9+
*
10+
*/
11+
#ifndef __ASM_MIPS_PROM_H
12+
#define __ASM_MIPS_PROM_H
13+
14+
#ifdef CONFIG_OF
15+
#include <asm/bootinfo.h>
16+
17+
/* which is compatible with the flattened device tree (FDT) */
18+
#define cmd_line arcs_cmdline
19+
20+
extern int early_init_dt_scan_memory_arch(unsigned long node,
21+
const char *uname, int depth, void *data);
22+
23+
extern int reserve_mem_mach(unsigned long addr, unsigned long size);
24+
extern void free_mem_mach(unsigned long addr, unsigned long size);
25+
26+
extern void device_tree_init(void);
27+
#else /* CONFIG_OF */
28+
static inline void device_tree_init(void) { }
29+
#endif /* CONFIG_OF */
30+
31+
#endif /* _ASM_MIPS_PROM_H */

‎arch/mips/kernel/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
9696
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
9797
obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o
9898

99+
obj-$(CONFIG_OF) += prom.o
100+
99101
CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
100102

101103
obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o

‎arch/mips/kernel/prom.c‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* MIPS support for CONFIG_OF device tree support
3+
*
4+
* Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License version 2 as
8+
* published by the Free Software Foundation.
9+
*/
10+
11+
#include <linux/init.h>
12+
#include <linux/module.h>
13+
#include <linux/errno.h>
14+
#include <linux/types.h>
15+
#include <linux/bootmem.h>
16+
#include <linux/initrd.h>
17+
#include <linux/debugfs.h>
18+
#include <linux/of.h>
19+
#include <linux/of_fdt.h>
20+
#include <linux/of_irq.h>
21+
#include <linux/of_platform.h>
22+
23+
#include <asm/page.h>
24+
#include <asm/prom.h>
25+
26+
int __init early_init_dt_scan_memory_arch(unsigned long node,
27+
const char *uname, int depth,
28+
void *data)
29+
{
30+
return early_init_dt_scan_memory(node, uname, depth, data);
31+
}
32+
33+
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
34+
{
35+
return add_memory_region(base, size, BOOT_MEM_RAM);
36+
}
37+
38+
int __init reserve_mem_mach(unsigned long addr, unsigned long size)
39+
{
40+
return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
41+
}
42+
43+
void __init free_mem_mach(unsigned long addr, unsigned long size)
44+
{
45+
return free_bootmem(addr, size);
46+
}
47+
48+
u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
49+
{
50+
return virt_to_phys(
51+
__alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS))
52+
);
53+
}
54+
55+
#ifdef CONFIG_BLK_DEV_INITRD
56+
void __init early_init_dt_setup_initrd_arch(unsigned long start,
57+
unsigned long end)
58+
{
59+
initrd_start = (unsigned long)__va(start);
60+
initrd_end = (unsigned long)__va(end);
61+
initrd_below_start_ok = 1;
62+
}
63+
#endif
64+
65+
/*
66+
* irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
67+
*
68+
* Currently the mapping mechanism is trivial; simple flat hwirq numbers are
69+
* mapped 1:1 onto Linux irq numbers. Cascaded irq controllers are not
70+
* supported.
71+
*/
72+
unsigned int irq_create_of_mapping(struct device_node *controller,
73+
const u32 *intspec, unsigned int intsize)
74+
{
75+
return intspec[0];
76+
}
77+
EXPORT_SYMBOL_GPL(irq_create_of_mapping);
78+
79+
void __init early_init_devtree(void *params)
80+
{
81+
/* Setup flat device-tree pointer */
82+
initial_boot_params = params;
83+
84+
/* Retrieve various informations from the /chosen node of the
85+
* device-tree, including the platform type, initrd location and
86+
* size, and more ...
87+
*/
88+
of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
89+
90+
/* Scan memory nodes */
91+
of_scan_flat_dt(early_init_dt_scan_root, NULL);
92+
of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
93+
}
94+
95+
void __init device_tree_init(void)
96+
{
97+
unsigned long base, size;
98+
99+
if (!initial_boot_params)
100+
return;
101+
102+
base = virt_to_phys((void *)initial_boot_params);
103+
size = initial_boot_params->totalsize;
104+
105+
/* Before we do anything, lets reserve the dt blob */
106+
reserve_mem_mach(base, size);
107+
108+
unflatten_device_tree();
109+
110+
/* free the space reserved for the dt blob */
111+
free_mem_mach(base, size);
112+
}

‎arch/mips/kernel/setup.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <asm/setup.h>
3232
#include <asm/smp-ops.h>
3333
#include <asm/system.h>
34+
#include <asm/prom.h>
3435

3536
struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly;
3637

@@ -487,6 +488,7 @@ static void __init arch_mem_init(char **cmdline_p)
487488
}
488489

489490
bootmem_init();
491+
device_tree_init();
490492
sparse_init();
491493
paging_init();
492494
}

‎arch/powerpc/kernel/ibmebus.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,10 @@ static int ibmebus_create_device(struct device_node *dn)
162162
dev->dev.bus = &ibmebus_bus_type;
163163
dev->dev.archdata.dma_ops = &ibmebus_dma_ops;
164164

165-
ret = of_device_register(dev);
166-
if (ret) {
167-
of_device_free(dev);
168-
return ret;
169-
}
170-
171-
return 0;
165+
ret = of_device_add(dev);
166+
if (ret)
167+
platform_device_put(dev);
168+
return ret;
172169
}
173170

174171
static int ibmebus_create_devices(const struct of_device_id *matches)

‎arch/powerpc/kernel/legacy_serial.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
5252
phys_addr_t taddr, unsigned long irq,
5353
upf_t flags, int irq_check_parent)
5454
{
55-
const u32 *clk, *spd;
55+
const __be32 *clk, *spd;
5656
u32 clock = BASE_BAUD * 16;
5757
int index;
5858

5959
/* get clock freq. if present */
6060
clk = of_get_property(np, "clock-frequency", NULL);
6161
if (clk && *clk)
62-
clock = *clk;
62+
clock = be32_to_cpup(clk);
6363

6464
/* get default speed if present */
6565
spd = of_get_property(np, "current-speed", NULL);
@@ -109,7 +109,7 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
109109
legacy_serial_infos[index].taddr = taddr;
110110
legacy_serial_infos[index].np = of_node_get(np);
111111
legacy_serial_infos[index].clock = clock;
112-
legacy_serial_infos[index].speed = spd ? *spd : 0;
112+
legacy_serial_infos[index].speed = spd ? be32_to_cpup(spd) : 0;
113113
legacy_serial_infos[index].irq_check_parent = irq_check_parent;
114114

115115
printk(KERN_DEBUG "Found legacy serial port %d for %s\n",
@@ -168,7 +168,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
168168
static int __init add_legacy_isa_port(struct device_node *np,
169169
struct device_node *isa_brg)
170170
{
171-
const u32 *reg;
171+
const __be32 *reg;
172172
const char *typep;
173173
int index = -1;
174174
u64 taddr;
@@ -181,7 +181,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
181181
return -1;
182182

183183
/* Verify it's an IO port, we don't support anything else */
184-
if (!(reg[0] & 0x00000001))
184+
if (!(be32_to_cpu(reg[0]) & 0x00000001))
185185
return -1;
186186

187187
/* Now look for an "ibm,aix-loc" property that gives us ordering
@@ -202,7 +202,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
202202
taddr = 0;
203203

204204
/* Add port, irq will be dealt with later */
205-
return add_legacy_port(np, index, UPIO_PORT, reg[1], taddr,
205+
return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]), taddr,
206206
NO_IRQ, UPF_BOOT_AUTOCONF, 0);
207207

208208
}
@@ -251,9 +251,9 @@ static int __init add_legacy_pci_port(struct device_node *np,
251251
* we get to their "reg" property
252252
*/
253253
if (np != pci_dev) {
254-
const u32 *reg = of_get_property(np, "reg", NULL);
255-
if (reg && (*reg < 4))
256-
index = lindex = *reg;
254+
const __be32 *reg = of_get_property(np, "reg", NULL);
255+
if (reg && (be32_to_cpup(reg) < 4))
256+
index = lindex = be32_to_cpup(reg);
257257
}
258258

259259
/* Local index means it's the Nth port in the PCI chip. Unfortunately
@@ -507,7 +507,7 @@ static int __init check_legacy_serial_console(void)
507507
struct device_node *prom_stdout = NULL;
508508
int i, speed = 0, offset = 0;
509509
const char *name;
510-
const u32 *spd;
510+
const __be32 *spd;
511511

512512
DBG(" -> check_legacy_serial_console()\n");
513513

@@ -547,7 +547,7 @@ static int __init check_legacy_serial_console(void)
547547
}
548548
spd = of_get_property(prom_stdout, "current-speed", NULL);
549549
if (spd)
550-
speed = *spd;
550+
speed = be32_to_cpup(spd);
551551

552552
if (strcmp(name, "serial") != 0)
553553
goto not_found;

‎arch/powerpc/kernel/prom.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,15 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
364364
return 0;
365365
}
366366

367-
void __init early_init_dt_scan_chosen_arch(unsigned long node)
367+
int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname,
368+
int depth, void *data)
368369
{
369370
unsigned long *lprop;
370371

372+
/* Use common scan routine to determine if this is the chosen node */
373+
if (early_init_dt_scan_chosen(node, uname, depth, data) == 0)
374+
return 0;
375+
371376
#ifdef CONFIG_PPC64
372377
/* check if iommu is forced on or off */
373378
if (of_get_flat_dt_prop(node, "linux,iommu-off", NULL) != NULL)
@@ -399,6 +404,9 @@ void __init early_init_dt_scan_chosen_arch(unsigned long node)
399404
if (lprop)
400405
crashk_res.end = crashk_res.start + *lprop - 1;
401406
#endif
407+
408+
/* break now */
409+
return 1;
402410
}
403411

404412
#ifdef CONFIG_PPC_PSERIES
@@ -683,7 +691,7 @@ void __init early_init_devtree(void *params)
683691
* device-tree, including the platform type, initrd location and
684692
* size, TCE reserve, and more ...
685693
*/
686-
of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
694+
of_scan_flat_dt(early_init_dt_scan_chosen_ppc, NULL);
687695

688696
/* Scan memory nodes and rebuild MEMBLOCKs */
689697
memblock_init();

0 commit comments

Comments
 (0)