Commit de8d28b1 authored by David S. Miller's avatar David S. Miller

[SPARC64]: Convert sparc64 PCI layer to in-kernel device tree.

One thing this change pointed out was that we really should
pull the "get 'local-mac-address' property" logic into a helper
function all the network drivers can call.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 765b5f32
......@@ -553,7 +553,7 @@ void __init ebus_init(void)
}
cookie = pdev->sysdata;
ebusnd = cookie->prom_node;
ebusnd = cookie->prom_node->node;
ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus));
ebus->next = NULL;
......@@ -578,7 +578,7 @@ void __init ebus_init(void)
}
ebus->is_rio = is_rio;
cookie = pdev->sysdata;
ebusnd = cookie->prom_node;
ebusnd = cookie->prom_node->node;
continue;
}
printk("ebus%d:", num_ebus);
......@@ -622,7 +622,7 @@ void __init ebus_init(void)
break;
cookie = pdev->sysdata;
ebusnd = cookie->prom_node;
ebusnd = cookie->prom_node->node;
ebus->next = ebus_alloc(sizeof(struct linux_ebus));
ebus = ebus->next;
......
......@@ -291,8 +291,8 @@ void __init isa_init(void)
isa_br->parent = pbm;
isa_br->self = pdev;
isa_br->index = index++;
isa_br->prom_node = pdev_cookie->prom_node;
strncpy(isa_br->prom_name, pdev_cookie->prom_name,
isa_br->prom_node = pdev_cookie->prom_node->node;
strncpy(isa_br->prom_name, pdev_cookie->prom_node->name,
sizeof(isa_br->prom_name));
prop_len = prom_getproperty(isa_br->prom_node,
......
This diff is collapsed.
......@@ -10,6 +10,7 @@
#include <linux/types.h>
#include <linux/spinlock.h>
#include <asm/io.h>
#include <asm/prom.h>
extern struct pci_controller_info *pci_controller_root;
......@@ -19,7 +20,7 @@ extern int pci_num_controllers;
extern void pci_fixup_host_bridge_self(struct pci_bus *pbus);
extern void pci_fill_in_pbm_cookies(struct pci_bus *pbus,
struct pci_pbm_info *pbm,
int prom_node);
struct device_node *prom_node);
extern void pci_record_assignments(struct pci_pbm_info *pbm,
struct pci_bus *pbus);
extern void pci_assign_unassigned(struct pci_pbm_info *pbm,
......
......@@ -1104,7 +1104,7 @@ static void pbm_scan_bus(struct pci_controller_info *p,
pci_fixup_host_bridge_self(pbm->pci_bus);
pbm->pci_bus->self->sysdata = cookie;
pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node->node);
pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
pci_record_assignments(pbm, pbm->pci_bus);
pci_assign_unassigned(pbm, pbm->pci_bus);
pci_fixup_irq(pbm, pbm->pci_bus);
......
......@@ -1161,7 +1161,7 @@ static void sabre_scan_bus(struct pci_controller_info *p)
pbus->sysdata = pbm;
pbm->pci_bus = pbus;
pci_fill_in_pbm_cookies(pbus, pbm, pbm->prom_node->node);
pci_fill_in_pbm_cookies(pbus, pbm, pbm->prom_node);
pci_record_assignments(pbm, pbus);
pci_assign_unassigned(pbm, pbus);
pci_fixup_irq(pbm, pbus);
......@@ -1174,7 +1174,7 @@ static void sabre_scan_bus(struct pci_controller_info *p)
pbm = &p->pbm_A;
sabre_bus->sysdata = pbm;
pbm->pci_bus = sabre_bus;
pci_fill_in_pbm_cookies(sabre_bus, pbm, pbm->prom_node->node);
pci_fill_in_pbm_cookies(sabre_bus, pbm, pbm->prom_node);
pci_record_assignments(pbm, sabre_bus);
pci_assign_unassigned(pbm, sabre_bus);
pci_fixup_irq(pbm, sabre_bus);
......
......@@ -1438,7 +1438,7 @@ static void pbm_scan_bus(struct pci_controller_info *p,
pci_fixup_host_bridge_self(pbm->pci_bus);
pbm->pci_bus->self->sysdata = cookie;
pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node->node);
pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
pci_record_assignments(pbm, pbm->pci_bus);
pci_assign_unassigned(pbm, pbm->pci_bus);
pci_fixup_irq(pbm, pbm->pci_bus);
......
......@@ -814,8 +814,7 @@ static void pbm_scan_bus(struct pci_controller_info *p,
pci_fixup_host_bridge_self(pbm->pci_bus);
pbm->pci_bus->self->sysdata = cookie;
#endif
pci_fill_in_pbm_cookies(pbm->pci_bus, pbm,
pbm->prom_node->node);
pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node);
pci_record_assignments(pbm, pbm->pci_bus);
pci_assign_unassigned(pbm, pbm->pci_bus);
pci_fixup_irq(pbm, pbm->pci_bus);
......
......@@ -20,6 +20,7 @@
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/bootmem.h>
#include <linux/module.h>
#include <asm/prom.h>
#include <asm/oplib.h>
......@@ -63,6 +64,17 @@ struct device_node *of_find_node_by_path(const char *path)
return np;
}
struct device_node *of_find_node_by_phandle(phandle handle)
{
struct device_node *np;
for (np = allnodes; np != 0; np = np->allnext)
if (np->node == handle)
break;
return np;
}
struct device_node *of_find_node_by_name(struct device_node *from,
const char *name)
{
......@@ -103,6 +115,18 @@ struct property *of_find_property(struct device_node *np, const char *name,
}
return pp;
}
EXPORT_SYMBOL(of_find_property);
/*
* Find a property with a given name for a given node
* and return the value.
*/
void *of_get_property(struct device_node *np, const char *name, int *lenp)
{
struct property *pp = of_find_property(np,name,lenp);
return pp ? pp->value : NULL;
}
EXPORT_SYMBOL(of_get_property);
int of_getintprop_default(struct device_node *np, const char *name, int def)
{
......@@ -115,6 +139,7 @@ int of_getintprop_default(struct device_node *np, const char *name, int def)
return *(int *) prop->value;
}
EXPORT_SYMBOL(of_getintprop_default);
static unsigned int prom_early_allocated;
......
......@@ -2880,17 +2880,20 @@ static int __devinit gem_get_device_address(struct gem *gp)
#if defined(__sparc__)
struct pci_dev *pdev = gp->pdev;
struct pcidev_cookie *pcp = pdev->sysdata;
int node = -1;
int use_idprom = 1;
if (pcp != NULL) {
node = pcp->prom_node;
if (prom_getproplen(node, "local-mac-address") == 6)
prom_getproperty(node, "local-mac-address",
dev->dev_addr, 6);
else
node = -1;
unsigned char *addr;
int len;
addr = of_get_property(pcp->prom_node, "local-mac-address",
&len);
if (addr && len == 6) {
use_idprom = 0;
memcpy(dev->dev_addr, addr, 6);
}
}
if (node == -1)
if (use_idprom)
memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
#elif defined(CONFIG_PPC_PMAC)
unsigned char *addr;
......
......@@ -3013,7 +3013,6 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
struct quattro *qp = NULL;
#ifdef __sparc__
struct pcidev_cookie *pcp;
int node;
#endif
struct happy_meal *hp;
struct net_device *dev;
......@@ -3026,13 +3025,12 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
/* Now make sure pci_dev cookie is there. */
#ifdef __sparc__
pcp = pdev->sysdata;
if (pcp == NULL || pcp->prom_node == -1) {
if (pcp == NULL) {
printk(KERN_ERR "happymeal(PCI): Some PCI device info missing\n");
return -ENODEV;
}
node = pcp->prom_node;
prom_getstring(node, "name", prom_name, sizeof(prom_name));
strcpy(prom_name, pcp->prom_node->name);
#else
if (is_quattro_p(pdev))
strcpy(prom_name, "SUNW,qfe");
......@@ -3104,10 +3102,14 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
macaddr[5]++;
} else {
#ifdef __sparc__
unsigned char *addr;
int len;
if (qfe_slot != -1 &&
prom_getproplen(node, "local-mac-address") == 6) {
prom_getproperty(node, "local-mac-address",
dev->dev_addr, 6);
(addr = of_get_property(pcp->prom_node,
"local-mac-address", &len)) != NULL
&& len == 6) {
memcpy(dev->dev_addr, addr, 6);
} else {
memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
}
......@@ -3124,7 +3126,7 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
hp->tcvregs = (hpreg_base + 0x7000UL);
#ifdef __sparc__
hp->hm_revision = prom_getintdefault(node, "hm-rev", 0xff);
hp->hm_revision = of_getintprop_default(pcp->prom_node, "hm-rev", 0xff);
if (hp->hm_revision == 0xff) {
unsigned char prev;
......
......@@ -10549,11 +10549,13 @@ static int __devinit tg3_get_macaddr_sparc(struct tg3 *tp)
struct pcidev_cookie *pcp = pdev->sysdata;
if (pcp != NULL) {
int node = pcp->prom_node;
unsigned char *addr;
int len;
if (prom_getproplen(node, "local-mac-address") == 6) {
prom_getproperty(node, "local-mac-address",
dev->dev_addr, 6);
addr = of_get_property(pcp->prom_node, "local-mac-address",
&len);
if (addr && len == 6) {
memcpy(dev->dev_addr, addr, 6);
memcpy(dev->perm_addr, dev->dev_addr, 6);
return 0;
}
......
......@@ -1550,10 +1550,14 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
dev->dev_addr[i] = last_phys_addr[i];
dev->dev_addr[i] = last_phys_addr[i] + 1;
#if defined(__sparc__)
if ((pcp != NULL) && prom_getproplen(pcp->prom_node,
"local-mac-address") == 6) {
prom_getproperty(pcp->prom_node, "local-mac-address",
dev->dev_addr, 6);
if (pcp) {
unsigned char *addr;
int len;
addr = of_get_property(pcp->prom_node,
"local-mac-address", &len);
if (addr && len == 6)
memcpy(dev->dev_addr, addr, 6);
}
#endif
#if defined(__i386__) || defined(__x86_64__) /* Patch up x86 BIOS bug. */
......
......@@ -243,8 +243,8 @@ static int openprom_sunos_ioctl(struct inode * inode, struct file * file,
((int *) opp->oprom_array)[1]);
pcp = pdev->sysdata;
if (pcp != NULL && pcp->prom_node != -1 && pcp->prom_node) {
node = pcp->prom_node;
if (pcp != NULL) {
node = pcp->prom_node->node;
data->current_node = node;
*((int *)opp->oprom_array) = node;
opp->oprom_size = sizeof(int);
......
......@@ -2966,7 +2966,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
}
pcp = pdev->sysdata;
if (node == pcp->prom_node) {
if (node == pcp->prom_node->node) {
struct fb_var_screeninfo *var = &default_var;
unsigned int N, P, Q, M, T, R;
u32 v_total, h_total;
......
......@@ -227,8 +227,7 @@ struct pci_controller_info {
*/
struct pcidev_cookie {
struct pci_pbm_info *pbm;
char prom_name[64];
int prom_node;
struct device_node *prom_node;
struct linux_prom_pci_registers prom_regs[PROMREG_MAX];
int num_prom_regs;
struct linux_prom_pci_registers prom_assignments[PROMREG_MAX];
......
......@@ -76,12 +76,15 @@ extern struct device_node *of_find_node_by_type(struct device_node *from,
for (dn = of_find_node_by_type(NULL, type); dn; \
dn = of_find_node_by_type(dn, type))
extern struct device_node *of_find_node_by_path(const char *path);
extern struct device_node *of_find_node_by_phandle(phandle handle);
extern struct device_node *of_get_parent(const struct device_node *node);
extern struct device_node *of_get_next_child(const struct device_node *node,
struct device_node *prev);
extern struct property *of_find_property(struct device_node *np,
const char *name,
int *lenp);
extern void *of_get_property(struct device_node *node, const char *name,
int *lenp);
extern int of_getintprop_default(struct device_node *np,
const char *name,
int def);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment