You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: (29 commits)
of/flattree: forward declare struct device_node in of_fdt.h
ipmi: explicitly include of_address.h and of_irq.h
sparc: explicitly cast negative phandle checks to s32
powerpc/405: Fix missing #{address,size}-cells in i2c node
powerpc/5200: dts: refactor dts files
powerpc/5200: dts: Change combatible strings on localbus
powerpc/5200: dts: remove unused properties
powerpc/5200: dts: rename nodes to prepare for refactoring dts files
of/flattree: Update dtc to current mainline.
of/device: Don't register disabled devices
powerpc/dts: fix syntax bugs in bluestone.dts
of: Fixes for OF probing on little endian systems
of: make drivers depend on CONFIG_OF instead of CONFIG_PPC_OF
of/flattree: Add of_flat_dt_match() helper function
of_serial: explicitly include of_irq.h
of/flattree: Refactor unflatten_device_tree and add fdt_unflatten_tree
of/flattree: Reorder unflatten_dt_node
of/flattree: Refactor unflatten_dt_node
of/flattree: Add non-boottime device tree functions
of/flattree: Add Kconfig for EARLY_FLATTREE
...
Fix up trivial conflict in arch/sparc/prom/tree_32.c as per Grant.
This commit is contained in:
@@ -19,6 +19,10 @@ config OF_FLATTREE
|
||||
bool
|
||||
select DTC
|
||||
|
||||
config OF_EARLY_FLATTREE
|
||||
bool
|
||||
select OF_FLATTREE
|
||||
|
||||
config OF_PROMTREE
|
||||
bool
|
||||
|
||||
@@ -49,6 +53,10 @@ config OF_I2C
|
||||
help
|
||||
OpenFirmware I2C accessors
|
||||
|
||||
config OF_NET
|
||||
depends on NETDEVICES
|
||||
def_bool y
|
||||
|
||||
config OF_SPI
|
||||
def_tristate SPI
|
||||
depends on SPI && !SPARC
|
||||
|
||||
@@ -6,5 +6,6 @@ obj-$(CONFIG_OF_IRQ) += irq.o
|
||||
obj-$(CONFIG_OF_DEVICE) += device.o platform.o
|
||||
obj-$(CONFIG_OF_GPIO) += gpio.o
|
||||
obj-$(CONFIG_OF_I2C) += of_i2c.o
|
||||
obj-$(CONFIG_OF_NET) += of_net.o
|
||||
obj-$(CONFIG_OF_SPI) += of_spi.o
|
||||
obj-$(CONFIG_OF_MDIO) += of_mdio.o
|
||||
|
||||
+28
-26
@@ -12,13 +12,13 @@
|
||||
(ns) > 0)
|
||||
|
||||
static struct of_bus *of_match_bus(struct device_node *np);
|
||||
static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
|
||||
u64 size, unsigned int flags,
|
||||
static int __of_address_to_resource(struct device_node *dev,
|
||||
const __be32 *addrp, u64 size, unsigned int flags,
|
||||
struct resource *r);
|
||||
|
||||
/* Debug utility */
|
||||
#ifdef DEBUG
|
||||
static void of_dump_addr(const char *s, const u32 *addr, int na)
|
||||
static void of_dump_addr(const char *s, const __be32 *addr, int na)
|
||||
{
|
||||
printk(KERN_DEBUG "%s", s);
|
||||
while (na--)
|
||||
@@ -26,7 +26,7 @@ static void of_dump_addr(const char *s, const u32 *addr, int na)
|
||||
printk("\n");
|
||||
}
|
||||
#else
|
||||
static void of_dump_addr(const char *s, const u32 *addr, int na) { }
|
||||
static void of_dump_addr(const char *s, const __be32 *addr, int na) { }
|
||||
#endif
|
||||
|
||||
/* Callbacks for bus specific translators */
|
||||
@@ -36,10 +36,10 @@ struct of_bus {
|
||||
int (*match)(struct device_node *parent);
|
||||
void (*count_cells)(struct device_node *child,
|
||||
int *addrc, int *sizec);
|
||||
u64 (*map)(u32 *addr, const u32 *range,
|
||||
u64 (*map)(u32 *addr, const __be32 *range,
|
||||
int na, int ns, int pna);
|
||||
int (*translate)(u32 *addr, u64 offset, int na);
|
||||
unsigned int (*get_flags)(const u32 *addr);
|
||||
unsigned int (*get_flags)(const __be32 *addr);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -55,7 +55,7 @@ static void of_bus_default_count_cells(struct device_node *dev,
|
||||
*sizec = of_n_size_cells(dev);
|
||||
}
|
||||
|
||||
static u64 of_bus_default_map(u32 *addr, const u32 *range,
|
||||
static u64 of_bus_default_map(u32 *addr, const __be32 *range,
|
||||
int na, int ns, int pna)
|
||||
{
|
||||
u64 cp, s, da;
|
||||
@@ -85,7 +85,7 @@ static int of_bus_default_translate(u32 *addr, u64 offset, int na)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int of_bus_default_get_flags(const u32 *addr)
|
||||
static unsigned int of_bus_default_get_flags(const __be32 *addr)
|
||||
{
|
||||
return IORESOURCE_MEM;
|
||||
}
|
||||
@@ -110,10 +110,10 @@ static void of_bus_pci_count_cells(struct device_node *np,
|
||||
*sizec = 2;
|
||||
}
|
||||
|
||||
static unsigned int of_bus_pci_get_flags(const u32 *addr)
|
||||
static unsigned int of_bus_pci_get_flags(const __be32 *addr)
|
||||
{
|
||||
unsigned int flags = 0;
|
||||
u32 w = addr[0];
|
||||
u32 w = be32_to_cpup(addr);
|
||||
|
||||
switch((w >> 24) & 0x03) {
|
||||
case 0x01:
|
||||
@@ -129,7 +129,8 @@ static unsigned int of_bus_pci_get_flags(const u32 *addr)
|
||||
return flags;
|
||||
}
|
||||
|
||||
static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna)
|
||||
static u64 of_bus_pci_map(u32 *addr, const __be32 *range, int na, int ns,
|
||||
int pna)
|
||||
{
|
||||
u64 cp, s, da;
|
||||
unsigned int af, rf;
|
||||
@@ -160,7 +161,7 @@ static int of_bus_pci_translate(u32 *addr, u64 offset, int na)
|
||||
return of_bus_default_translate(addr + 1, offset, na - 1);
|
||||
}
|
||||
|
||||
const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
|
||||
const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
|
||||
unsigned int *flags)
|
||||
{
|
||||
const __be32 *prop;
|
||||
@@ -207,7 +208,7 @@ EXPORT_SYMBOL(of_get_pci_address);
|
||||
int of_pci_address_to_resource(struct device_node *dev, int bar,
|
||||
struct resource *r)
|
||||
{
|
||||
const u32 *addrp;
|
||||
const __be32 *addrp;
|
||||
u64 size;
|
||||
unsigned int flags;
|
||||
|
||||
@@ -237,12 +238,13 @@ static void of_bus_isa_count_cells(struct device_node *child,
|
||||
*sizec = 1;
|
||||
}
|
||||
|
||||
static u64 of_bus_isa_map(u32 *addr, const u32 *range, int na, int ns, int pna)
|
||||
static u64 of_bus_isa_map(u32 *addr, const __be32 *range, int na, int ns,
|
||||
int pna)
|
||||
{
|
||||
u64 cp, s, da;
|
||||
|
||||
/* Check address type match */
|
||||
if ((addr[0] ^ range[0]) & 0x00000001)
|
||||
if ((addr[0] ^ range[0]) & cpu_to_be32(1))
|
||||
return OF_BAD_ADDR;
|
||||
|
||||
/* Read address values, skipping high cell */
|
||||
@@ -264,10 +266,10 @@ static int of_bus_isa_translate(u32 *addr, u64 offset, int na)
|
||||
return of_bus_default_translate(addr + 1, offset, na - 1);
|
||||
}
|
||||
|
||||
static unsigned int of_bus_isa_get_flags(const u32 *addr)
|
||||
static unsigned int of_bus_isa_get_flags(const __be32 *addr)
|
||||
{
|
||||
unsigned int flags = 0;
|
||||
u32 w = addr[0];
|
||||
u32 w = be32_to_cpup(addr);
|
||||
|
||||
if (w & 1)
|
||||
flags |= IORESOURCE_IO;
|
||||
@@ -330,7 +332,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
|
||||
struct of_bus *pbus, u32 *addr,
|
||||
int na, int ns, int pna, const char *rprop)
|
||||
{
|
||||
const u32 *ranges;
|
||||
const __be32 *ranges;
|
||||
unsigned int rlen;
|
||||
int rone;
|
||||
u64 offset = OF_BAD_ADDR;
|
||||
@@ -398,7 +400,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
|
||||
* that can be mapped to a cpu physical address). This is not really specified
|
||||
* that way, but this is traditionally the way IBM at least do things
|
||||
*/
|
||||
u64 __of_translate_address(struct device_node *dev, const u32 *in_addr,
|
||||
u64 __of_translate_address(struct device_node *dev, const __be32 *in_addr,
|
||||
const char *rprop)
|
||||
{
|
||||
struct device_node *parent = NULL;
|
||||
@@ -475,22 +477,22 @@ u64 __of_translate_address(struct device_node *dev, const u32 *in_addr,
|
||||
return result;
|
||||
}
|
||||
|
||||
u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
|
||||
u64 of_translate_address(struct device_node *dev, const __be32 *in_addr)
|
||||
{
|
||||
return __of_translate_address(dev, in_addr, "ranges");
|
||||
}
|
||||
EXPORT_SYMBOL(of_translate_address);
|
||||
|
||||
u64 of_translate_dma_address(struct device_node *dev, const u32 *in_addr)
|
||||
u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr)
|
||||
{
|
||||
return __of_translate_address(dev, in_addr, "dma-ranges");
|
||||
}
|
||||
EXPORT_SYMBOL(of_translate_dma_address);
|
||||
|
||||
const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
|
||||
const __be32 *of_get_address(struct device_node *dev, int index, u64 *size,
|
||||
unsigned int *flags)
|
||||
{
|
||||
const u32 *prop;
|
||||
const __be32 *prop;
|
||||
unsigned int psize;
|
||||
struct device_node *parent;
|
||||
struct of_bus *bus;
|
||||
@@ -525,8 +527,8 @@ const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
|
||||
}
|
||||
EXPORT_SYMBOL(of_get_address);
|
||||
|
||||
static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
|
||||
u64 size, unsigned int flags,
|
||||
static int __of_address_to_resource(struct device_node *dev,
|
||||
const __be32 *addrp, u64 size, unsigned int flags,
|
||||
struct resource *r)
|
||||
{
|
||||
u64 taddr;
|
||||
@@ -564,7 +566,7 @@ static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
|
||||
int of_address_to_resource(struct device_node *dev, int index,
|
||||
struct resource *r)
|
||||
{
|
||||
const u32 *addrp;
|
||||
const __be32 *addrp;
|
||||
u64 size;
|
||||
unsigned int flags;
|
||||
|
||||
|
||||
+272
-158
File diff suppressed because it is too large
Load Diff
+18
-10
@@ -52,27 +52,35 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
|
||||
|
||||
/* Loop over the child nodes and register a phy_device for each one */
|
||||
for_each_child_of_node(np, child) {
|
||||
const __be32 *addr;
|
||||
const __be32 *paddr;
|
||||
u32 addr;
|
||||
int len;
|
||||
|
||||
/* A PHY must have a reg property in the range [0-31] */
|
||||
addr = of_get_property(child, "reg", &len);
|
||||
if (!addr || len < sizeof(*addr) || *addr >= 32 || *addr < 0) {
|
||||
paddr = of_get_property(child, "reg", &len);
|
||||
if (!paddr || len < sizeof(*paddr)) {
|
||||
dev_err(&mdio->dev, "%s has invalid PHY address\n",
|
||||
child->full_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mdio->irq) {
|
||||
mdio->irq[*addr] = irq_of_parse_and_map(child, 0);
|
||||
if (!mdio->irq[*addr])
|
||||
mdio->irq[*addr] = PHY_POLL;
|
||||
addr = be32_to_cpup(paddr);
|
||||
if (addr >= 32) {
|
||||
dev_err(&mdio->dev, "%s PHY address %i is too large\n",
|
||||
child->full_name, addr);
|
||||
continue;
|
||||
}
|
||||
|
||||
phy = get_phy_device(mdio, be32_to_cpup(addr));
|
||||
if (mdio->irq) {
|
||||
mdio->irq[addr] = irq_of_parse_and_map(child, 0);
|
||||
if (!mdio->irq[addr])
|
||||
mdio->irq[addr] = PHY_POLL;
|
||||
}
|
||||
|
||||
phy = get_phy_device(mdio, addr);
|
||||
if (!phy || IS_ERR(phy)) {
|
||||
dev_err(&mdio->dev, "error probing PHY at address %i\n",
|
||||
*addr);
|
||||
addr);
|
||||
continue;
|
||||
}
|
||||
phy_scan_fixups(phy);
|
||||
@@ -91,7 +99,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
|
||||
}
|
||||
|
||||
dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
|
||||
child->name, *addr);
|
||||
child->name, addr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* OF helpers for network devices.
|
||||
*
|
||||
* This file is released under the GPLv2
|
||||
*
|
||||
* Initially copied out of arch/powerpc/kernel/prom_parse.c
|
||||
*/
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/of_net.h>
|
||||
|
||||
/**
|
||||
* Search the device tree for the best MAC address to use. 'mac-address' is
|
||||
* checked first, because that is supposed to contain to "most recent" MAC
|
||||
* address. If that isn't set, then 'local-mac-address' is checked next,
|
||||
* because that is the default address. If that isn't set, then the obsolete
|
||||
* 'address' is checked, just in case we're using an old device tree.
|
||||
*
|
||||
* Note that the 'address' property is supposed to contain a virtual address of
|
||||
* the register set, but some DTS files have redefined that property to be the
|
||||
* MAC address.
|
||||
*
|
||||
* All-zero MAC addresses are rejected, because those could be properties that
|
||||
* exist in the device tree, but were not set by U-Boot. For example, the
|
||||
* DTS could define 'mac-address' and 'local-mac-address', with zero MAC
|
||||
* addresses. Some older U-Boots only initialized 'local-mac-address'. In
|
||||
* this case, the real MAC is in 'local-mac-address', and 'mac-address' exists
|
||||
* but is all zeros.
|
||||
*/
|
||||
const void *of_get_mac_address(struct device_node *np)
|
||||
{
|
||||
struct property *pp;
|
||||
|
||||
pp = of_find_property(np, "mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "local-mac-address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
pp = of_find_property(np, "address", NULL);
|
||||
if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value))
|
||||
return pp->value;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(of_get_mac_address);
|
||||
+14
-8
@@ -633,6 +633,9 @@ EXPORT_SYMBOL(of_device_alloc);
|
||||
* @np: pointer to node to create device for
|
||||
* @bus_id: name to assign device
|
||||
* @parent: Linux device model parent device.
|
||||
*
|
||||
* Returns pointer to created platform device, or NULL if a device was not
|
||||
* registered. Unavailable devices will not get registered.
|
||||
*/
|
||||
struct platform_device *of_platform_device_create(struct device_node *np,
|
||||
const char *bus_id,
|
||||
@@ -640,6 +643,9 @@ struct platform_device *of_platform_device_create(struct device_node *np,
|
||||
{
|
||||
struct platform_device *dev;
|
||||
|
||||
if (!of_device_is_available(np))
|
||||
return NULL;
|
||||
|
||||
dev = of_device_alloc(np, bus_id, parent);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
@@ -683,8 +689,9 @@ static int of_platform_bus_create(const struct device_node *bus,
|
||||
pr_debug(" create child: %s\n", child->full_name);
|
||||
dev = of_platform_device_create(child, NULL, parent);
|
||||
if (dev == NULL)
|
||||
rc = -ENOMEM;
|
||||
else if (!of_match_node(matches, child))
|
||||
continue;
|
||||
|
||||
if (!of_match_node(matches, child))
|
||||
continue;
|
||||
if (rc == 0) {
|
||||
pr_debug(" and sub busses\n");
|
||||
@@ -733,10 +740,9 @@ int of_platform_bus_probe(struct device_node *root,
|
||||
if (of_match_node(matches, root)) {
|
||||
pr_debug(" root match, create all sub devices\n");
|
||||
dev = of_platform_device_create(root, NULL, parent);
|
||||
if (dev == NULL) {
|
||||
rc = -ENOMEM;
|
||||
if (dev == NULL)
|
||||
goto bail;
|
||||
}
|
||||
|
||||
pr_debug(" create all sub busses\n");
|
||||
rc = of_platform_bus_create(root, matches, &dev->dev);
|
||||
goto bail;
|
||||
@@ -748,9 +754,9 @@ int of_platform_bus_probe(struct device_node *root,
|
||||
pr_debug(" match: %s\n", child->full_name);
|
||||
dev = of_platform_device_create(child, NULL, parent);
|
||||
if (dev == NULL)
|
||||
rc = -ENOMEM;
|
||||
else
|
||||
rc = of_platform_bus_create(child, matches, &dev->dev);
|
||||
continue;
|
||||
|
||||
rc = of_platform_bus_create(child, matches, &dev->dev);
|
||||
if (rc) {
|
||||
of_node_put(child);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user