Skip to content

Commit

Permalink
Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
Browse files Browse the repository at this point in the history
* '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
  • Loading branch information
torvalds committed Oct 25, 2010
2 parents a7f505c + 97ff46c commit 51f00a4
Show file tree
Hide file tree
Showing 60 changed files with 800 additions and 417 deletions.
5 changes: 0 additions & 5 deletions arch/microblaze/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
#include <asm/sections.h>
#include <asm/pci-bridge.h>

void __init early_init_dt_scan_chosen_arch(unsigned long node)
{
/* No Microblaze specific code here */
}

void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
memblock_add(base, size);
Expand Down
7 changes: 7 additions & 0 deletions arch/mips/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,13 @@ config SECCOMP

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

config USE_OF
bool "Flattened Device Tree support"
select OF
select OF_FLATTREE
help
Include support for flattened device tree machine descriptions.

endmenu

config LOCKDEP_SUPPORT
Expand Down
5 changes: 5 additions & 0 deletions arch/mips/include/asm/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@

#include <irq.h>

static inline void irq_dispose_mapping(unsigned int virq)
{
return;
}

#ifdef CONFIG_I8259
static inline int irq_canonicalize(int irq)
{
Expand Down
31 changes: 31 additions & 0 deletions arch/mips/include/asm/prom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* arch/mips/include/asm/prom.h
*
* Copyright (C) 2010 Cisco Systems Inc. <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#ifndef __ASM_MIPS_PROM_H
#define __ASM_MIPS_PROM_H

#ifdef CONFIG_OF
#include <asm/bootinfo.h>

/* which is compatible with the flattened device tree (FDT) */
#define cmd_line arcs_cmdline

extern int early_init_dt_scan_memory_arch(unsigned long node,
const char *uname, int depth, void *data);

extern int reserve_mem_mach(unsigned long addr, unsigned long size);
extern void free_mem_mach(unsigned long addr, unsigned long size);

extern void device_tree_init(void);
#else /* CONFIG_OF */
static inline void device_tree_init(void) { }
#endif /* CONFIG_OF */

#endif /* _ASM_MIPS_PROM_H */
2 changes: 2 additions & 0 deletions arch/mips/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o

obj-$(CONFIG_OF) += prom.o

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)

obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
Expand Down
112 changes: 112 additions & 0 deletions arch/mips/kernel/prom.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* MIPS support for CONFIG_OF device tree support
*
* Copyright (C) 2010 Cisco Systems Inc. <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#include <linux/init.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/bootmem.h>
#include <linux/initrd.h>
#include <linux/debugfs.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>

#include <asm/page.h>
#include <asm/prom.h>

int __init early_init_dt_scan_memory_arch(unsigned long node,
const char *uname, int depth,
void *data)
{
return early_init_dt_scan_memory(node, uname, depth, data);
}

void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
return add_memory_region(base, size, BOOT_MEM_RAM);
}

int __init reserve_mem_mach(unsigned long addr, unsigned long size)
{
return reserve_bootmem(addr, size, BOOTMEM_DEFAULT);
}

void __init free_mem_mach(unsigned long addr, unsigned long size)
{
return free_bootmem(addr, size);
}

u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
{
return virt_to_phys(
__alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS))
);
}

#ifdef CONFIG_BLK_DEV_INITRD
void __init early_init_dt_setup_initrd_arch(unsigned long start,
unsigned long end)
{
initrd_start = (unsigned long)__va(start);
initrd_end = (unsigned long)__va(end);
initrd_below_start_ok = 1;
}
#endif

/*
* irq_create_of_mapping - Hook to resolve OF irq specifier into a Linux irq#
*
* Currently the mapping mechanism is trivial; simple flat hwirq numbers are
* mapped 1:1 onto Linux irq numbers. Cascaded irq controllers are not
* supported.
*/
unsigned int irq_create_of_mapping(struct device_node *controller,
const u32 *intspec, unsigned int intsize)
{
return intspec[0];
}
EXPORT_SYMBOL_GPL(irq_create_of_mapping);

void __init early_init_devtree(void *params)
{
/* Setup flat device-tree pointer */
initial_boot_params = params;

/* Retrieve various informations from the /chosen node of the
* device-tree, including the platform type, initrd location and
* size, and more ...
*/
of_scan_flat_dt(early_init_dt_scan_chosen, NULL);

/* Scan memory nodes */
of_scan_flat_dt(early_init_dt_scan_root, NULL);
of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL);
}

void __init device_tree_init(void)
{
unsigned long base, size;

if (!initial_boot_params)
return;

base = virt_to_phys((void *)initial_boot_params);
size = initial_boot_params->totalsize;

/* Before we do anything, lets reserve the dt blob */
reserve_mem_mach(base, size);

unflatten_device_tree();

/* free the space reserved for the dt blob */
free_mem_mach(base, size);
}
2 changes: 2 additions & 0 deletions arch/mips/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <asm/setup.h>
#include <asm/smp-ops.h>
#include <asm/system.h>
#include <asm/prom.h>

struct cpuinfo_mips cpu_data[NR_CPUS] __read_mostly;

Expand Down Expand Up @@ -487,6 +488,7 @@ static void __init arch_mem_init(char **cmdline_p)
}

bootmem_init();
device_tree_init();
sparse_init();
paging_init();
}
Expand Down
11 changes: 4 additions & 7 deletions arch/powerpc/kernel/ibmebus.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,10 @@ static int ibmebus_create_device(struct device_node *dn)
dev->dev.bus = &ibmebus_bus_type;
dev->dev.archdata.dma_ops = &ibmebus_dma_ops;

ret = of_device_register(dev);
if (ret) {
of_device_free(dev);
return ret;
}

return 0;
ret = of_device_add(dev);
if (ret)
platform_device_put(dev);
return ret;
}

static int ibmebus_create_devices(const struct of_device_id *matches)
Expand Down
22 changes: 11 additions & 11 deletions arch/powerpc/kernel/legacy_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
phys_addr_t taddr, unsigned long irq,
upf_t flags, int irq_check_parent)
{
const u32 *clk, *spd;
const __be32 *clk, *spd;
u32 clock = BASE_BAUD * 16;
int index;

/* get clock freq. if present */
clk = of_get_property(np, "clock-frequency", NULL);
if (clk && *clk)
clock = *clk;
clock = be32_to_cpup(clk);

/* get default speed if present */
spd = of_get_property(np, "current-speed", NULL);
Expand Down Expand Up @@ -109,7 +109,7 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
legacy_serial_infos[index].taddr = taddr;
legacy_serial_infos[index].np = of_node_get(np);
legacy_serial_infos[index].clock = clock;
legacy_serial_infos[index].speed = spd ? *spd : 0;
legacy_serial_infos[index].speed = spd ? be32_to_cpup(spd) : 0;
legacy_serial_infos[index].irq_check_parent = irq_check_parent;

printk(KERN_DEBUG "Found legacy serial port %d for %s\n",
Expand Down Expand Up @@ -168,7 +168,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
static int __init add_legacy_isa_port(struct device_node *np,
struct device_node *isa_brg)
{
const u32 *reg;
const __be32 *reg;
const char *typep;
int index = -1;
u64 taddr;
Expand All @@ -181,7 +181,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
return -1;

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

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

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

}
Expand Down Expand Up @@ -251,9 +251,9 @@ static int __init add_legacy_pci_port(struct device_node *np,
* we get to their "reg" property
*/
if (np != pci_dev) {
const u32 *reg = of_get_property(np, "reg", NULL);
if (reg && (*reg < 4))
index = lindex = *reg;
const __be32 *reg = of_get_property(np, "reg", NULL);
if (reg && (be32_to_cpup(reg) < 4))
index = lindex = be32_to_cpup(reg);
}

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

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

Expand Down Expand Up @@ -547,7 +547,7 @@ static int __init check_legacy_serial_console(void)
}
spd = of_get_property(prom_stdout, "current-speed", NULL);
if (spd)
speed = *spd;
speed = be32_to_cpup(spd);

if (strcmp(name, "serial") != 0)
goto not_found;
Expand Down
12 changes: 10 additions & 2 deletions arch/powerpc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,15 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
return 0;
}

void __init early_init_dt_scan_chosen_arch(unsigned long node)
int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname,
int depth, void *data)
{
unsigned long *lprop;

/* Use common scan routine to determine if this is the chosen node */
if (early_init_dt_scan_chosen(node, uname, depth, data) == 0)
return 0;

#ifdef CONFIG_PPC64
/* check if iommu is forced on or off */
if (of_get_flat_dt_prop(node, "linux,iommu-off", NULL) != NULL)
Expand Down Expand Up @@ -399,6 +404,9 @@ void __init early_init_dt_scan_chosen_arch(unsigned long node)
if (lprop)
crashk_res.end = crashk_res.start + *lprop - 1;
#endif

/* break now */
return 1;
}

#ifdef CONFIG_PPC_PSERIES
Expand Down Expand Up @@ -683,7 +691,7 @@ void __init early_init_devtree(void *params)
* device-tree, including the platform type, initrd location and
* size, TCE reserve, and more ...
*/
of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
of_scan_flat_dt(early_init_dt_scan_chosen_ppc, NULL);

/* Scan memory nodes and rebuild MEMBLOCKs */
memblock_init();
Expand Down
1 change: 1 addition & 0 deletions arch/sparc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ config SPARC
bool
default y
select OF
select OF_PROMTREE
select HAVE_IDE
select HAVE_OPROFILE
select HAVE_ARCH_KGDB if !SMP || SPARC64
Expand Down
1 change: 0 additions & 1 deletion arch/sparc/include/asm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ header-y += display7seg.h
header-y += envctrl.h
header-y += fbio.h
header-y += jsflash.h
header-y += openprom.h
header-y += openpromio.h
header-y += perfctr.h
header-y += psrcompat.h
Expand Down
3 changes: 2 additions & 1 deletion arch/sparc/include/asm/floppy_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ static struct linux_prom_registers fd_regs[2];
static int sun_floppy_init(void)
{
char state[128];
int tnode, fd_node, num_regs;
phandle tnode, fd_node;
int num_regs;
struct resource r;

use_virtual_dma = 1;
Expand Down
Loading

0 comments on commit 51f00a4

Please sign in to comment.