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 master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6: (40 commits) [SPARC64]: Update defconfig. [SPARC64]: Make auxio a real driver. [PARPORT] sunbpp: Convert to new SBUS device framework. [Documentation]: Update probing info in sbus_drivers.txt [SCSI] qlogicpti: Convert to new SBUS device framework. [SCSI] esp: Fix bug in esp_remove_common. [NET] sunhme: Kill useless loop over sdevs in quattro_sbus_find(). [NET] myri_sbus: Kill unused next_module struct member. [NET] myri_sbus: Convert to new SBUS device layer. [NET] sunqe: Convert to new SBUS driver layer. [NET] sunbmac: Convert over to new SBUS device framework. [NET] sunlance: Convert to new SBUS driver framework. [NET] sunhme: Convert to new SBUS driver framework. [NET] sunhme: Kill __sparc__ and __sparc_v9__ ifdefs. [SCSI] sparc: Port esp to new SBUS driver layer. [SOUND] sparc: Port amd7930 to new SBUS device layer. [SBUS]: Rewrite and plug into of_device framework. [SPARC]: Port of_device layer and make ebus use it. [SPARC]: Port sparc64 in-kernel device tree code to sparc32. [SPARC64]: Add of_device layer and make ebus/isa use it. ...
This commit is contained in:
@@ -25,42 +25,84 @@ the bits necessary to run your device. The most commonly
|
||||
used members of this structure, and their typical usage,
|
||||
will be detailed below.
|
||||
|
||||
Here is how probing is performed by an SBUS driver
|
||||
under Linux:
|
||||
Here is a piece of skeleton code for perofming a device
|
||||
probe in an SBUS driverunder Linux:
|
||||
|
||||
static void init_one_mydevice(struct sbus_dev *sdev)
|
||||
static int __devinit mydevice_probe_one(struct sbus_dev *sdev)
|
||||
{
|
||||
struct mysdevice *mp = kzalloc(sizeof(*mp), GFP_KERNEL);
|
||||
|
||||
if (!mp)
|
||||
return -ENODEV;
|
||||
|
||||
...
|
||||
dev_set_drvdata(&sdev->ofdev.dev, mp);
|
||||
return 0;
|
||||
...
|
||||
}
|
||||
|
||||
static int mydevice_match(struct sbus_dev *sdev)
|
||||
static int __devinit mydevice_probe(struct of_device *dev,
|
||||
const struct of_device_id *match)
|
||||
{
|
||||
if (some_criteria(sdev))
|
||||
return 1;
|
||||
return 0;
|
||||
struct sbus_dev *sdev = to_sbus_device(&dev->dev);
|
||||
|
||||
return mydevice_probe_one(sdev);
|
||||
}
|
||||
|
||||
static void mydevice_probe(void)
|
||||
static int __devexit mydevice_remove(struct of_device *dev)
|
||||
{
|
||||
struct sbus_bus *sbus;
|
||||
struct sbus_dev *sdev;
|
||||
struct sbus_dev *sdev = to_sbus_device(&dev->dev);
|
||||
struct mydevice *mp = dev_get_drvdata(&dev->dev);
|
||||
|
||||
for_each_sbus(sbus) {
|
||||
for_each_sbusdev(sdev, sbus) {
|
||||
if (mydevice_match(sdev))
|
||||
init_one_mydevice(sdev);
|
||||
}
|
||||
}
|
||||
return mydevice_remove_one(sdev, mp);
|
||||
}
|
||||
|
||||
All this does is walk through all SBUS devices in the
|
||||
system, checks each to see if it is of the type which
|
||||
your driver is written for, and if so it calls the init
|
||||
routine to attach the device and prepare to drive it.
|
||||
static struct of_device_id mydevice_match[] = {
|
||||
{
|
||||
.name = "mydevice",
|
||||
},
|
||||
{},
|
||||
};
|
||||
|
||||
"init_one_mydevice" might do things like allocate software
|
||||
state structures, map in I/O registers, place the hardware
|
||||
into an initialized state, etc.
|
||||
MODULE_DEVICE_TABLE(of, mydevice_match);
|
||||
|
||||
static struct of_platform_driver mydevice_driver = {
|
||||
.name = "mydevice",
|
||||
.match_table = mydevice_match,
|
||||
.probe = mydevice_probe,
|
||||
.remove = __devexit_p(mydevice_remove),
|
||||
};
|
||||
|
||||
static int __init mydevice_init(void)
|
||||
{
|
||||
return of_register_driver(&mydevice_driver, &sbus_bus_type);
|
||||
}
|
||||
|
||||
static void __exit mydevice_exit(void)
|
||||
{
|
||||
of_unregister_driver(&mydevice_driver);
|
||||
}
|
||||
|
||||
module_init(mydevice_init);
|
||||
module_exit(mydevice_exit);
|
||||
|
||||
The mydevice_match table is a series of entries which
|
||||
describes what SBUS devices your driver is meant for. In the
|
||||
simplest case you specify a string for the 'name' field. Every
|
||||
SBUS device with a 'name' property matching your string will
|
||||
be passed one-by-one to your .probe method.
|
||||
|
||||
You should store away your device private state structure
|
||||
pointer in the drvdata area so that you can retrieve it later on
|
||||
in your .remove method.
|
||||
|
||||
Any memory allocated, registers mapped, IRQs registered,
|
||||
etc. must be undone by your .remove method so that all resources
|
||||
of your device are relased by the time it returns.
|
||||
|
||||
You should _NOT_ use the for_each_sbus(), for_each_sbusdev(),
|
||||
and for_all_sbusdev() interfaces. They are deprecated, will be
|
||||
removed, and no new driver should reference them ever.
|
||||
|
||||
Mapping and Accessing I/O Registers
|
||||
|
||||
@@ -263,10 +305,3 @@ discussed above and plus it handles both PCI and SBUS boards.
|
||||
Lance driver abuses consistent mappings for data transfer.
|
||||
It is a nifty trick which we do not particularly recommend...
|
||||
Just check it out and know that it's legal.
|
||||
|
||||
Bad examples, do NOT use
|
||||
|
||||
drivers/video/cgsix.c
|
||||
This one uses result of sbus_ioremap as if it is an address.
|
||||
This does NOT work on sparc64 and therefore is broken. We will
|
||||
convert it at a later date.
|
||||
|
||||
@@ -12,7 +12,7 @@ obj-y := entry.o wof.o wuf.o etrap.o rtrap.o traps.o $(IRQ_OBJS) \
|
||||
sys_sparc.o sunos_asm.o systbls.o \
|
||||
time.o windows.o cpu.o devices.o sclow.o \
|
||||
tadpole.o tick14.o ptrace.o sys_solaris.o \
|
||||
unaligned.o muldiv.o semaphore.o
|
||||
unaligned.o muldiv.o semaphore.o prom.o of_device.o
|
||||
|
||||
obj-$(CONFIG_PCI) += pcic.o
|
||||
obj-$(CONFIG_SUN4) += sun4setup.o
|
||||
|
||||
+105
-80
@@ -20,6 +20,7 @@
|
||||
#include <asm/ebus.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/oplib.h>
|
||||
#include <asm/prom.h>
|
||||
#include <asm/bpp.h>
|
||||
|
||||
struct linux_ebus *ebus_chain = NULL;
|
||||
@@ -83,79 +84,81 @@ int __init ebus_blacklist_irq(char *name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __init fill_ebus_child(int node, struct linux_prom_registers *preg,
|
||||
struct linux_ebus_child *dev)
|
||||
void __init fill_ebus_child(struct device_node *dp,
|
||||
struct linux_ebus_child *dev)
|
||||
{
|
||||
int regs[PROMREG_MAX];
|
||||
int irqs[PROMREG_MAX];
|
||||
char lbuf[128];
|
||||
int *regs;
|
||||
int *irqs;
|
||||
int i, len;
|
||||
|
||||
dev->prom_node = node;
|
||||
prom_getstring(node, "name", lbuf, sizeof(lbuf));
|
||||
strcpy(dev->prom_name, lbuf);
|
||||
|
||||
len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs));
|
||||
if (len == -1) len = 0;
|
||||
dev->prom_node = dp;
|
||||
regs = of_get_property(dp, "reg", &len);
|
||||
if (!regs)
|
||||
len = 0;
|
||||
dev->num_addrs = len / sizeof(regs[0]);
|
||||
|
||||
for (i = 0; i < dev->num_addrs; i++) {
|
||||
if (regs[i] >= dev->parent->num_addrs) {
|
||||
prom_printf("UGH: property for %s was %d, need < %d\n",
|
||||
dev->prom_name, len, dev->parent->num_addrs);
|
||||
dev->prom_node->name, len,
|
||||
dev->parent->num_addrs);
|
||||
panic(__FUNCTION__);
|
||||
}
|
||||
dev->resource[i].start = dev->parent->resource[regs[i]].start; /* XXX resource */
|
||||
|
||||
/* XXX resource */
|
||||
dev->resource[i].start =
|
||||
dev->parent->resource[regs[i]].start;
|
||||
}
|
||||
|
||||
for (i = 0; i < PROMINTR_MAX; i++)
|
||||
dev->irqs[i] = PCI_IRQ_NONE;
|
||||
|
||||
if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_name)) != 0) {
|
||||
if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) {
|
||||
dev->num_irqs = 1;
|
||||
} else if ((len = prom_getproperty(node, "interrupts",
|
||||
(char *)&irqs, sizeof(irqs))) == -1 || len == 0) {
|
||||
dev->num_irqs = 0;
|
||||
dev->irqs[0] = 0;
|
||||
if (dev->parent->num_irqs != 0) {
|
||||
dev->num_irqs = 1;
|
||||
dev->irqs[0] = dev->parent->irqs[0];
|
||||
/* P3 */ /* printk("EBUS: dev %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */
|
||||
}
|
||||
} else {
|
||||
dev->num_irqs = len / sizeof(irqs[0]);
|
||||
if (irqs[0] == 0 || irqs[0] >= 8) {
|
||||
/*
|
||||
* XXX Zero is a valid pin number...
|
||||
* This works as long as Ebus is not wired to INTA#.
|
||||
*/
|
||||
printk("EBUS: %s got bad irq %d from PROM\n",
|
||||
dev->prom_name, irqs[0]);
|
||||
irqs = of_get_property(dp, "interrupts", &len);
|
||||
if (!irqs) {
|
||||
dev->num_irqs = 0;
|
||||
dev->irqs[0] = 0;
|
||||
if (dev->parent->num_irqs != 0) {
|
||||
dev->num_irqs = 1;
|
||||
dev->irqs[0] = dev->parent->irqs[0];
|
||||
}
|
||||
} else {
|
||||
dev->irqs[0] = pcic_pin_to_irq(irqs[0], dev->prom_name);
|
||||
dev->num_irqs = len / sizeof(irqs[0]);
|
||||
if (irqs[0] == 0 || irqs[0] >= 8) {
|
||||
/*
|
||||
* XXX Zero is a valid pin number...
|
||||
* This works as long as Ebus is not wired
|
||||
* to INTA#.
|
||||
*/
|
||||
printk("EBUS: %s got bad irq %d from PROM\n",
|
||||
dev->prom_node->name, irqs[0]);
|
||||
dev->num_irqs = 0;
|
||||
dev->irqs[0] = 0;
|
||||
} else {
|
||||
dev->irqs[0] =
|
||||
pcic_pin_to_irq(irqs[0],
|
||||
dev->prom_node->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
|
||||
void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev)
|
||||
{
|
||||
struct linux_prom_registers regs[PROMREG_MAX];
|
||||
struct linux_prom_registers *regs;
|
||||
struct linux_ebus_child *child;
|
||||
int irqs[PROMINTR_MAX];
|
||||
char lbuf[128];
|
||||
int *irqs;
|
||||
int i, n, len;
|
||||
unsigned long baseaddr;
|
||||
|
||||
dev->prom_node = node;
|
||||
prom_getstring(node, "name", lbuf, sizeof(lbuf));
|
||||
strcpy(dev->prom_name, lbuf);
|
||||
dev->prom_node = dp;
|
||||
|
||||
len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs));
|
||||
regs = of_get_property(dp, "reg", &len);
|
||||
if (len % sizeof(struct linux_prom_registers)) {
|
||||
prom_printf("UGH: proplen for %s was %d, need multiple of %d\n",
|
||||
dev->prom_name, len,
|
||||
dev->prom_node->name, len,
|
||||
(int)sizeof(struct linux_prom_registers));
|
||||
panic(__FUNCTION__);
|
||||
}
|
||||
@@ -197,7 +200,7 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
|
||||
if ((baseaddr = (unsigned long) ioremap(baseaddr,
|
||||
regs[i].reg_size)) == 0) {
|
||||
panic("ebus: unable to remap dev %s",
|
||||
dev->prom_name);
|
||||
dev->prom_node->name);
|
||||
}
|
||||
}
|
||||
dev->resource[i].start = baseaddr; /* XXX Unaligned */
|
||||
@@ -206,29 +209,43 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
|
||||
for (i = 0; i < PROMINTR_MAX; i++)
|
||||
dev->irqs[i] = PCI_IRQ_NONE;
|
||||
|
||||
if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_name)) != 0) {
|
||||
if ((dev->irqs[0] = ebus_blacklist_irq(dev->prom_node->name)) != 0) {
|
||||
dev->num_irqs = 1;
|
||||
} else if ((len = prom_getproperty(node, "interrupts",
|
||||
(char *)&irqs, sizeof(irqs))) == -1 || len == 0) {
|
||||
dev->num_irqs = 0;
|
||||
if ((dev->irqs[0] = dev->bus->self->irq) != 0) {
|
||||
dev->num_irqs = 1;
|
||||
/* P3 */ /* printk("EBUS: child %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */
|
||||
}
|
||||
} else {
|
||||
dev->num_irqs = 1; /* dev->num_irqs = len / sizeof(irqs[0]); */
|
||||
if (irqs[0] == 0 || irqs[0] >= 8) {
|
||||
/* See above for the parent. XXX */
|
||||
printk("EBUS: %s got bad irq %d from PROM\n",
|
||||
dev->prom_name, irqs[0]);
|
||||
irqs = of_get_property(dp, "interrupts", &len);
|
||||
if (!irqs) {
|
||||
dev->num_irqs = 0;
|
||||
dev->irqs[0] = 0;
|
||||
if ((dev->irqs[0] = dev->bus->self->irq) != 0) {
|
||||
dev->num_irqs = 1;
|
||||
/* P3 */ /* printk("EBUS: child %s irq %d from parent\n", dev->prom_name, dev->irqs[0]); */
|
||||
}
|
||||
} else {
|
||||
dev->irqs[0] = pcic_pin_to_irq(irqs[0], dev->prom_name);
|
||||
dev->num_irqs = 1; /* dev->num_irqs = len / sizeof(irqs[0]); */
|
||||
if (irqs[0] == 0 || irqs[0] >= 8) {
|
||||
/* See above for the parent. XXX */
|
||||
printk("EBUS: %s got bad irq %d from PROM\n",
|
||||
dev->prom_node->name, irqs[0]);
|
||||
dev->num_irqs = 0;
|
||||
dev->irqs[0] = 0;
|
||||
} else {
|
||||
dev->irqs[0] =
|
||||
pcic_pin_to_irq(irqs[0],
|
||||
dev->prom_node->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((node = prom_getchild(node))) {
|
||||
dev->ofdev.node = dp;
|
||||
dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
|
||||
dev->ofdev.dev.bus = &ebus_bus_type;
|
||||
strcpy(dev->ofdev.dev.bus_id, dp->path_component_name);
|
||||
|
||||
/* Register with core */
|
||||
if (of_device_register(&dev->ofdev) != 0)
|
||||
printk(KERN_DEBUG "ebus: device registration error for %s!\n",
|
||||
dev->ofdev.dev.bus_id);
|
||||
|
||||
if ((dp = dp->child) != NULL) {
|
||||
dev->children = (struct linux_ebus_child *)
|
||||
ebus_alloc(sizeof(struct linux_ebus_child));
|
||||
|
||||
@@ -236,9 +253,9 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
|
||||
child->next = NULL;
|
||||
child->parent = dev;
|
||||
child->bus = dev->bus;
|
||||
fill_ebus_child(node, ®s[0], child);
|
||||
fill_ebus_child(dp, child);
|
||||
|
||||
while ((node = prom_getsibling(node)) != 0) {
|
||||
while ((dp = dp->sibling) != NULL) {
|
||||
child->next = (struct linux_ebus_child *)
|
||||
ebus_alloc(sizeof(struct linux_ebus_child));
|
||||
|
||||
@@ -246,51 +263,49 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
|
||||
child->next = NULL;
|
||||
child->parent = dev;
|
||||
child->bus = dev->bus;
|
||||
fill_ebus_child(node, ®s[0], child);
|
||||
fill_ebus_child(dp, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __init ebus_init(void)
|
||||
{
|
||||
struct linux_prom_pci_registers regs[PROMREG_MAX];
|
||||
struct linux_prom_pci_registers *regs;
|
||||
struct linux_pbm_info *pbm;
|
||||
struct linux_ebus_device *dev;
|
||||
struct linux_ebus *ebus;
|
||||
struct ebus_system_entry *sp;
|
||||
struct pci_dev *pdev;
|
||||
struct pcidev_cookie *cookie;
|
||||
char lbuf[128];
|
||||
struct device_node *dp;
|
||||
unsigned long addr, *base;
|
||||
unsigned short pci_command;
|
||||
int nd, len, ebusnd;
|
||||
int reg, nreg;
|
||||
int len, reg, nreg;
|
||||
int num_ebus = 0;
|
||||
|
||||
prom_getstring(prom_root_node, "name", lbuf, sizeof(lbuf));
|
||||
dp = of_find_node_by_path("/");
|
||||
for (sp = ebus_blacklist; sp->esname != NULL; sp++) {
|
||||
if (strcmp(lbuf, sp->esname) == 0) {
|
||||
if (strcmp(dp->name, sp->esname) == 0) {
|
||||
ebus_blackp = sp->ipt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_EBUS, NULL);
|
||||
if (!pdev) {
|
||||
if (!pdev)
|
||||
return;
|
||||
}
|
||||
|
||||
cookie = pdev->sysdata;
|
||||
ebusnd = cookie->prom_node;
|
||||
dp = cookie->prom_node;
|
||||
|
||||
ebus_chain = ebus = (struct linux_ebus *)
|
||||
ebus_alloc(sizeof(struct linux_ebus));
|
||||
ebus->next = NULL;
|
||||
|
||||
while (ebusnd) {
|
||||
while (dp) {
|
||||
struct device_node *nd;
|
||||
|
||||
prom_getstring(ebusnd, "name", lbuf, sizeof(lbuf));
|
||||
ebus->prom_node = ebusnd;
|
||||
strcpy(ebus->prom_name, lbuf);
|
||||
ebus->prom_node = dp;
|
||||
ebus->self = pdev;
|
||||
ebus->parent = pbm = cookie->pbm;
|
||||
|
||||
@@ -299,9 +314,8 @@ void __init ebus_init(void)
|
||||
pci_command |= PCI_COMMAND_MASTER;
|
||||
pci_write_config_word(pdev, PCI_COMMAND, pci_command);
|
||||
|
||||
len = prom_getproperty(ebusnd, "reg", (void *)regs,
|
||||
sizeof(regs));
|
||||
if (len == 0 || len == -1) {
|
||||
regs = of_get_property(dp, "reg", &len);
|
||||
if (!regs) {
|
||||
prom_printf("%s: can't find reg property\n",
|
||||
__FUNCTION__);
|
||||
prom_halt();
|
||||
@@ -317,7 +331,18 @@ void __init ebus_init(void)
|
||||
*base++ = addr;
|
||||
}
|
||||
|
||||
nd = prom_getchild(ebusnd);
|
||||
ebus->ofdev.node = dp;
|
||||
ebus->ofdev.dev.parent = &pdev->dev;
|
||||
ebus->ofdev.dev.bus = &ebus_bus_type;
|
||||
strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name);
|
||||
|
||||
/* Register with core */
|
||||
if (of_device_register(&ebus->ofdev) != 0)
|
||||
printk(KERN_DEBUG "ebus: device registration error for %s!\n",
|
||||
ebus->ofdev.dev.bus_id);
|
||||
|
||||
|
||||
nd = dp->child;
|
||||
if (!nd)
|
||||
goto next_ebus;
|
||||
|
||||
@@ -330,7 +355,7 @@ void __init ebus_init(void)
|
||||
dev->bus = ebus;
|
||||
fill_ebus_device(nd, dev);
|
||||
|
||||
while ((nd = prom_getsibling(nd)) != 0) {
|
||||
while ((nd = nd->sibling) != NULL) {
|
||||
dev->next = (struct linux_ebus_device *)
|
||||
ebus_alloc(sizeof(struct linux_ebus_device));
|
||||
|
||||
@@ -348,7 +373,7 @@ void __init ebus_init(void)
|
||||
break;
|
||||
|
||||
cookie = pdev->sysdata;
|
||||
ebusnd = cookie->prom_node;
|
||||
dp = cookie->prom_node;
|
||||
|
||||
ebus->next = (struct linux_ebus *)
|
||||
ebus_alloc(sizeof(struct linux_ebus));
|
||||
|
||||
+130
-1
@@ -39,6 +39,8 @@
|
||||
#include <asm/io.h>
|
||||
#include <asm/vaddrs.h>
|
||||
#include <asm/oplib.h>
|
||||
#include <asm/prom.h>
|
||||
#include <asm/sbus.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/pgalloc.h>
|
||||
#include <asm/dma.h>
|
||||
@@ -224,10 +226,54 @@ static void _sparc_free_io(struct resource *res)
|
||||
|
||||
#ifdef CONFIG_SBUS
|
||||
|
||||
void sbus_set_sbus64(struct sbus_dev *sdev, int x) {
|
||||
void sbus_set_sbus64(struct sbus_dev *sdev, int x)
|
||||
{
|
||||
printk("sbus_set_sbus64: unsupported\n");
|
||||
}
|
||||
|
||||
extern unsigned int sun4d_build_irq(struct sbus_dev *sdev, int irq);
|
||||
void __init sbus_fill_device_irq(struct sbus_dev *sdev)
|
||||
{
|
||||
struct linux_prom_irqs irqs[PROMINTR_MAX];
|
||||
int len;
|
||||
|
||||
len = prom_getproperty(sdev->prom_node, "intr",
|
||||
(char *)irqs, sizeof(irqs));
|
||||
if (len != -1) {
|
||||
sdev->num_irqs = len / 8;
|
||||
if (sdev->num_irqs == 0) {
|
||||
sdev->irqs[0] = 0;
|
||||
} else if (sparc_cpu_model == sun4d) {
|
||||
for (len = 0; len < sdev->num_irqs; len++)
|
||||
sdev->irqs[len] =
|
||||
sun4d_build_irq(sdev, irqs[len].pri);
|
||||
} else {
|
||||
for (len = 0; len < sdev->num_irqs; len++)
|
||||
sdev->irqs[len] = irqs[len].pri;
|
||||
}
|
||||
} else {
|
||||
int interrupts[PROMINTR_MAX];
|
||||
|
||||
/* No "intr" node found-- check for "interrupts" node.
|
||||
* This node contains SBus interrupt levels, not IPLs
|
||||
* as in "intr", and no vector values. We convert
|
||||
* SBus interrupt levels to PILs (platform specific).
|
||||
*/
|
||||
len = prom_getproperty(sdev->prom_node, "interrupts",
|
||||
(char *)interrupts, sizeof(interrupts));
|
||||
if (len == -1) {
|
||||
sdev->irqs[0] = 0;
|
||||
sdev->num_irqs = 0;
|
||||
} else {
|
||||
sdev->num_irqs = len / sizeof(int);
|
||||
for (len = 0; len < sdev->num_irqs; len++) {
|
||||
sdev->irqs[len] =
|
||||
sbint_to_irq(sdev, interrupts[len]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a chunk of memory suitable for DMA.
|
||||
* Typically devices use them for control blocks.
|
||||
@@ -414,6 +460,89 @@ void sbus_dma_sync_sg_for_device(struct sbus_dev *sdev, struct scatterlist *sg,
|
||||
{
|
||||
printk("sbus_dma_sync_sg_for_device: not implemented yet\n");
|
||||
}
|
||||
|
||||
/* Support code for sbus_init(). */
|
||||
/*
|
||||
* XXX This functions appears to be a distorted version of
|
||||
* prom_sbus_ranges_init(), with all sun4d stuff cut away.
|
||||
* Ask DaveM what is going on here, how is sun4d supposed to work... XXX
|
||||
*/
|
||||
/* added back sun4d patch from Thomas Bogendoerfer - should be OK (crn) */
|
||||
void __init sbus_arch_bus_ranges_init(struct device_node *pn, struct sbus_bus *sbus)
|
||||
{
|
||||
int parent_node = pn->node;
|
||||
|
||||
if (sparc_cpu_model == sun4d) {
|
||||
struct linux_prom_ranges iounit_ranges[PROMREG_MAX];
|
||||
int num_iounit_ranges, len;
|
||||
|
||||
len = prom_getproperty(parent_node, "ranges",
|
||||
(char *) iounit_ranges,
|
||||
sizeof (iounit_ranges));
|
||||
if (len != -1) {
|
||||
num_iounit_ranges =
|
||||
(len / sizeof(struct linux_prom_ranges));
|
||||
prom_adjust_ranges(sbus->sbus_ranges,
|
||||
sbus->num_sbus_ranges,
|
||||
iounit_ranges, num_iounit_ranges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __init sbus_setup_iommu(struct sbus_bus *sbus, struct device_node *dp)
|
||||
{
|
||||
struct device_node *parent = dp->parent;
|
||||
|
||||
if (sparc_cpu_model != sun4d &&
|
||||
parent != NULL &&
|
||||
!strcmp(parent->name, "iommu")) {
|
||||
extern void iommu_init(int iommu_node, struct sbus_bus *sbus);
|
||||
|
||||
iommu_init(parent->node, sbus);
|
||||
}
|
||||
|
||||
if (sparc_cpu_model == sun4d) {
|
||||
extern void iounit_init(int sbi_node, int iounit_node,
|
||||
struct sbus_bus *sbus);
|
||||
|
||||
iounit_init(dp->node, parent->node, sbus);
|
||||
}
|
||||
}
|
||||
|
||||
void __init sbus_setup_arch_props(struct sbus_bus *sbus, struct device_node *dp)
|
||||
{
|
||||
if (sparc_cpu_model == sun4d) {
|
||||
struct device_node *parent = dp->parent;
|
||||
|
||||
sbus->devid = of_getintprop_default(parent, "device-id", 0);
|
||||
sbus->board = of_getintprop_default(parent, "board#", 0);
|
||||
}
|
||||
}
|
||||
|
||||
int __init sbus_arch_preinit(void)
|
||||
{
|
||||
extern void register_proc_sparc_ioport(void);
|
||||
|
||||
register_proc_sparc_ioport();
|
||||
|
||||
#ifdef CONFIG_SUN4
|
||||
{
|
||||
extern void sun4_dvma_init(void);
|
||||
sun4_dvma_init();
|
||||
}
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void __init sbus_arch_postinit(void)
|
||||
{
|
||||
if (sparc_cpu_model == sun4d) {
|
||||
extern void sun4d_init_sbi_irq(void);
|
||||
sun4d_init_sbi_irq();
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_SBUS */
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
#include <linux/config.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <asm/errno.h>
|
||||
#include <asm/of_device.h>
|
||||
|
||||
/**
|
||||
* of_match_device - Tell if an of_device structure has a matching
|
||||
* of_match structure
|
||||
* @ids: array of of device match structures to search in
|
||||
* @dev: the of device structure to match against
|
||||
*
|
||||
* Used by a driver to check whether an of_device present in the
|
||||
* system is in its list of supported devices.
|
||||
*/
|
||||
const struct of_device_id *of_match_device(const struct of_device_id *matches,
|
||||
const struct of_device *dev)
|
||||
{
|
||||
if (!dev->node)
|
||||
return NULL;
|
||||
while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
|
||||
int match = 1;
|
||||
if (matches->name[0])
|
||||
match &= dev->node->name
|
||||
&& !strcmp(matches->name, dev->node->name);
|
||||
if (matches->type[0])
|
||||
match &= dev->node->type
|
||||
&& !strcmp(matches->type, dev->node->type);
|
||||
if (matches->compatible[0])
|
||||
match &= of_device_is_compatible(dev->node,
|
||||
matches->compatible);
|
||||
if (match)
|
||||
return matches;
|
||||
matches++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
|
||||
{
|
||||
struct of_device * of_dev = to_of_device(dev);
|
||||
struct of_platform_driver * of_drv = to_of_platform_driver(drv);
|
||||
const struct of_device_id * matches = of_drv->match_table;
|
||||
|
||||
if (!matches)
|
||||
return 0;
|
||||
|
||||
return of_match_device(matches, of_dev) != NULL;
|
||||
}
|
||||
|
||||
struct of_device *of_dev_get(struct of_device *dev)
|
||||
{
|
||||
struct device *tmp;
|
||||
|
||||
if (!dev)
|
||||
return NULL;
|
||||
tmp = get_device(&dev->dev);
|
||||
if (tmp)
|
||||
return to_of_device(tmp);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void of_dev_put(struct of_device *dev)
|
||||
{
|
||||
if (dev)
|
||||
put_device(&dev->dev);
|
||||
}
|
||||
|
||||
|
||||
static int of_device_probe(struct device *dev)
|
||||
{
|
||||
int error = -ENODEV;
|
||||
struct of_platform_driver *drv;
|
||||
struct of_device *of_dev;
|
||||
const struct of_device_id *match;
|
||||
|
||||
drv = to_of_platform_driver(dev->driver);
|
||||
of_dev = to_of_device(dev);
|
||||
|
||||
if (!drv->probe)
|
||||
return error;
|
||||
|
||||
of_dev_get(of_dev);
|
||||
|
||||
match = of_match_device(drv->match_table, of_dev);
|
||||
if (match)
|
||||
error = drv->probe(of_dev, match);
|
||||
if (error)
|
||||
of_dev_put(of_dev);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static int of_device_remove(struct device *dev)
|
||||
{
|
||||
struct of_device * of_dev = to_of_device(dev);
|
||||
struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
|
||||
|
||||
if (dev->driver && drv->remove)
|
||||
drv->remove(of_dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int of_device_suspend(struct device *dev, pm_message_t state)
|
||||
{
|
||||
struct of_device * of_dev = to_of_device(dev);
|
||||
struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
|
||||
int error = 0;
|
||||
|
||||
if (dev->driver && drv->suspend)
|
||||
error = drv->suspend(of_dev, state);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int of_device_resume(struct device * dev)
|
||||
{
|
||||
struct of_device * of_dev = to_of_device(dev);
|
||||
struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
|
||||
int error = 0;
|
||||
|
||||
if (dev->driver && drv->resume)
|
||||
error = drv->resume(of_dev);
|
||||
return error;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
struct bus_type ebus_bus_type = {
|
||||
.name = "ebus",
|
||||
.match = of_platform_bus_match,
|
||||
.probe = of_device_probe,
|
||||
.remove = of_device_remove,
|
||||
.suspend = of_device_suspend,
|
||||
.resume = of_device_resume,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SBUS
|
||||
struct bus_type sbus_bus_type = {
|
||||
.name = "sbus",
|
||||
.match = of_platform_bus_match,
|
||||
.probe = of_device_probe,
|
||||
.remove = of_device_remove,
|
||||
.suspend = of_device_suspend,
|
||||
.resume = of_device_resume,
|
||||
};
|
||||
#endif
|
||||
|
||||
static int __init of_bus_driver_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
if (!err)
|
||||
err = bus_register(&ebus_bus_type);
|
||||
#endif
|
||||
#ifdef CONFIG_SBUS
|
||||
if (!err)
|
||||
err = bus_register(&sbus_bus_type);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
postcore_initcall(of_bus_driver_init);
|
||||
|
||||
int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus)
|
||||
{
|
||||
/* initialize common driver fields */
|
||||
drv->driver.name = drv->name;
|
||||
drv->driver.bus = bus;
|
||||
|
||||
/* register with core */
|
||||
return driver_register(&drv->driver);
|
||||
}
|
||||
|
||||
void of_unregister_driver(struct of_platform_driver *drv)
|
||||
{
|
||||
driver_unregister(&drv->driver);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct of_device *ofdev;
|
||||
|
||||
ofdev = to_of_device(dev);
|
||||
return sprintf(buf, "%s", ofdev->node->full_name);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL);
|
||||
|
||||
/**
|
||||
* of_release_dev - free an of device structure when all users of it are finished.
|
||||
* @dev: device that's been disconnected
|
||||
*
|
||||
* Will be called only by the device core when all users of this of device are
|
||||
* done.
|
||||
*/
|
||||
void of_release_dev(struct device *dev)
|
||||
{
|
||||
struct of_device *ofdev;
|
||||
|
||||
ofdev = to_of_device(dev);
|
||||
|
||||
kfree(ofdev);
|
||||
}
|
||||
|
||||
int of_device_register(struct of_device *ofdev)
|
||||
{
|
||||
int rc;
|
||||
|
||||
BUG_ON(ofdev->node == NULL);
|
||||
|
||||
rc = device_register(&ofdev->dev);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
device_create_file(&ofdev->dev, &dev_attr_devspec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void of_device_unregister(struct of_device *ofdev)
|
||||
{
|
||||
device_remove_file(&ofdev->dev, &dev_attr_devspec);
|
||||
device_unregister(&ofdev->dev);
|
||||
}
|
||||
|
||||
struct of_device* of_platform_device_create(struct device_node *np,
|
||||
const char *bus_id,
|
||||
struct device *parent,
|
||||
struct bus_type *bus)
|
||||
{
|
||||
struct of_device *dev;
|
||||
|
||||
dev = kmalloc(sizeof(*dev), GFP_KERNEL);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
memset(dev, 0, sizeof(*dev));
|
||||
|
||||
dev->dev.parent = parent;
|
||||
dev->dev.bus = bus;
|
||||
dev->dev.release = of_release_dev;
|
||||
|
||||
strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
|
||||
|
||||
if (of_device_register(dev) != 0) {
|
||||
kfree(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(of_match_device);
|
||||
EXPORT_SYMBOL(of_register_driver);
|
||||
EXPORT_SYMBOL(of_unregister_driver);
|
||||
EXPORT_SYMBOL(of_device_register);
|
||||
EXPORT_SYMBOL(of_device_unregister);
|
||||
EXPORT_SYMBOL(of_dev_get);
|
||||
EXPORT_SYMBOL(of_dev_put);
|
||||
EXPORT_SYMBOL(of_platform_device_create);
|
||||
EXPORT_SYMBOL(of_release_dev);
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <asm/irq.h>
|
||||
#include <asm/oplib.h>
|
||||
#include <asm/prom.h>
|
||||
#include <asm/pcic.h>
|
||||
#include <asm/timer.h>
|
||||
#include <asm/uaccess.h>
|
||||
@@ -665,7 +666,7 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
|
||||
/* cookies */
|
||||
pcp = pci_devcookie_alloc();
|
||||
pcp->pbm = &pcic->pbm;
|
||||
pcp->prom_node = node;
|
||||
pcp->prom_node = of_find_node_by_phandle(node);
|
||||
dev->sysdata = pcp;
|
||||
|
||||
/* fixing I/O to look like memory */
|
||||
|
||||
@@ -0,0 +1,474 @@
|
||||
/*
|
||||
* Procedures for creating, accessing and interpreting the device tree.
|
||||
*
|
||||
* Paul Mackerras August 1996.
|
||||
* Copyright (C) 1996-2005 Paul Mackerras.
|
||||
*
|
||||
* Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
|
||||
* {engebret|bergner}@us.ibm.com
|
||||
*
|
||||
* Adapted for sparc32 by David S. Miller davem@davemloft.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/bootmem.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <asm/prom.h>
|
||||
#include <asm/oplib.h>
|
||||
|
||||
static struct device_node *allnodes;
|
||||
|
||||
int of_device_is_compatible(struct device_node *device, const char *compat)
|
||||
{
|
||||
const char* cp;
|
||||
int cplen, l;
|
||||
|
||||
cp = (char *) of_get_property(device, "compatible", &cplen);
|
||||
if (cp == NULL)
|
||||
return 0;
|
||||
while (cplen > 0) {
|
||||
if (strncmp(cp, compat, strlen(compat)) == 0)
|
||||
return 1;
|
||||
l = strlen(cp) + 1;
|
||||
cp += l;
|
||||
cplen -= l;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(of_device_is_compatible);
|
||||
|
||||
struct device_node *of_get_parent(const struct device_node *node)
|
||||
{
|
||||
struct device_node *np;
|
||||
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
np = node->parent;
|
||||
|
||||
return np;
|
||||
}
|
||||
EXPORT_SYMBOL(of_get_parent);
|
||||
|
||||
struct device_node *of_get_next_child(const struct device_node *node,
|
||||
struct device_node *prev)
|
||||
{
|
||||
struct device_node *next;
|
||||
|
||||
next = prev ? prev->sibling : node->child;
|
||||
for (; next != 0; next = next->sibling) {
|
||||
break;
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
EXPORT_SYMBOL(of_get_next_child);
|
||||
|
||||
struct device_node *of_find_node_by_path(const char *path)
|
||||
{
|
||||
struct device_node *np = allnodes;
|
||||
|
||||
for (; np != 0; np = np->allnext) {
|
||||
if (np->full_name != 0 && strcmp(np->full_name, path) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return np;
|
||||
}
|
||||
EXPORT_SYMBOL(of_find_node_by_path);
|
||||
|
||||
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;
|
||||
}
|
||||
EXPORT_SYMBOL(of_find_node_by_phandle);
|
||||
|
||||
struct device_node *of_find_node_by_name(struct device_node *from,
|
||||
const char *name)
|
||||
{
|
||||
struct device_node *np;
|
||||
|
||||
np = from ? from->allnext : allnodes;
|
||||
for (; np != NULL; np = np->allnext)
|
||||
if (np->name != NULL && strcmp(np->name, name) == 0)
|
||||
break;
|
||||
|
||||
return np;
|
||||
}
|
||||
EXPORT_SYMBOL(of_find_node_by_name);
|
||||
|
||||
struct device_node *of_find_node_by_type(struct device_node *from,
|
||||
const char *type)
|
||||
{
|
||||
struct device_node *np;
|
||||
|
||||
np = from ? from->allnext : allnodes;
|
||||
for (; np != 0; np = np->allnext)
|
||||
if (np->type != 0 && strcmp(np->type, type) == 0)
|
||||
break;
|
||||
|
||||
return np;
|
||||
}
|
||||
EXPORT_SYMBOL(of_find_node_by_type);
|
||||
|
||||
struct device_node *of_find_compatible_node(struct device_node *from,
|
||||
const char *type, const char *compatible)
|
||||
{
|
||||
struct device_node *np;
|
||||
|
||||
np = from ? from->allnext : allnodes;
|
||||
for (; np != 0; np = np->allnext) {
|
||||
if (type != NULL
|
||||
&& !(np->type != 0 && strcmp(np->type, type) == 0))
|
||||
continue;
|
||||
if (of_device_is_compatible(np, compatible))
|
||||
break;
|
||||
}
|
||||
|
||||
return np;
|
||||
}
|
||||
EXPORT_SYMBOL(of_find_compatible_node);
|
||||
|
||||
struct property *of_find_property(struct device_node *np, const char *name,
|
||||
int *lenp)
|
||||
{
|
||||
struct property *pp;
|
||||
|
||||
for (pp = np->properties; pp != 0; pp = pp->next) {
|
||||
if (strcmp(pp->name, name) == 0) {
|
||||
if (lenp != 0)
|
||||
*lenp = pp->length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
struct property *prop;
|
||||
int len;
|
||||
|
||||
prop = of_find_property(np, name, &len);
|
||||
if (!prop || len != 4)
|
||||
return def;
|
||||
|
||||
return *(int *) prop->value;
|
||||
}
|
||||
EXPORT_SYMBOL(of_getintprop_default);
|
||||
|
||||
static unsigned int prom_early_allocated;
|
||||
|
||||
static void * __init prom_early_alloc(unsigned long size)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
ret = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL);
|
||||
if (ret != NULL)
|
||||
memset(ret, 0, size);
|
||||
|
||||
prom_early_allocated += size;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int is_root_node(const struct device_node *dp)
|
||||
{
|
||||
if (!dp)
|
||||
return 0;
|
||||
|
||||
return (dp->parent == NULL);
|
||||
}
|
||||
|
||||
/* The following routines deal with the black magic of fully naming a
|
||||
* node.
|
||||
*
|
||||
* Certain well known named nodes are just the simple name string.
|
||||
*
|
||||
* Actual devices have an address specifier appended to the base name
|
||||
* string, like this "foo@addr". The "addr" can be in any number of
|
||||
* formats, and the platform plus the type of the node determine the
|
||||
* format and how it is constructed.
|
||||
*
|
||||
* For children of the ROOT node, the naming convention is fixed and
|
||||
* determined by whether this is a sun4u or sun4v system.
|
||||
*
|
||||
* For children of other nodes, it is bus type specific. So
|
||||
* we walk up the tree until we discover a "device_type" property
|
||||
* we recognize and we go from there.
|
||||
*/
|
||||
static void __init sparc32_path_component(struct device_node *dp, char *tmp_buf)
|
||||
{
|
||||
struct linux_prom_registers *regs;
|
||||
struct property *rprop;
|
||||
|
||||
rprop = of_find_property(dp, "reg", NULL);
|
||||
if (!rprop)
|
||||
return;
|
||||
|
||||
regs = rprop->value;
|
||||
sprintf(tmp_buf, "%s@%x,%x",
|
||||
dp->name,
|
||||
regs->which_io, regs->phys_addr);
|
||||
}
|
||||
|
||||
/* "name@slot,offset" */
|
||||
static void __init sbus_path_component(struct device_node *dp, char *tmp_buf)
|
||||
{
|
||||
struct linux_prom_registers *regs;
|
||||
struct property *prop;
|
||||
|
||||
prop = of_find_property(dp, "reg", NULL);
|
||||
if (!prop)
|
||||
return;
|
||||
|
||||
regs = prop->value;
|
||||
sprintf(tmp_buf, "%s@%x,%x",
|
||||
dp->name,
|
||||
regs->which_io,
|
||||
regs->phys_addr);
|
||||
}
|
||||
|
||||
/* "name@devnum[,func]" */
|
||||
static void __init pci_path_component(struct device_node *dp, char *tmp_buf)
|
||||
{
|
||||
struct linux_prom_pci_registers *regs;
|
||||
struct property *prop;
|
||||
unsigned int devfn;
|
||||
|
||||
prop = of_find_property(dp, "reg", NULL);
|
||||
if (!prop)
|
||||
return;
|
||||
|
||||
regs = prop->value;
|
||||
devfn = (regs->phys_hi >> 8) & 0xff;
|
||||
if (devfn & 0x07) {
|
||||
sprintf(tmp_buf, "%s@%x,%x",
|
||||
dp->name,
|
||||
devfn >> 3,
|
||||
devfn & 0x07);
|
||||
} else {
|
||||
sprintf(tmp_buf, "%s@%x",
|
||||
dp->name,
|
||||
devfn >> 3);
|
||||
}
|
||||
}
|
||||
|
||||
/* "name@addrhi,addrlo" */
|
||||
static void __init ebus_path_component(struct device_node *dp, char *tmp_buf)
|
||||
{
|
||||
struct linux_prom_registers *regs;
|
||||
struct property *prop;
|
||||
|
||||
prop = of_find_property(dp, "reg", NULL);
|
||||
if (!prop)
|
||||
return;
|
||||
|
||||
regs = prop->value;
|
||||
|
||||
sprintf(tmp_buf, "%s@%x,%x",
|
||||
dp->name,
|
||||
regs->which_io, regs->phys_addr);
|
||||
}
|
||||
|
||||
static void __init __build_path_component(struct device_node *dp, char *tmp_buf)
|
||||
{
|
||||
struct device_node *parent = dp->parent;
|
||||
|
||||
if (parent != NULL) {
|
||||
if (!strcmp(parent->type, "pci") ||
|
||||
!strcmp(parent->type, "pciex"))
|
||||
return pci_path_component(dp, tmp_buf);
|
||||
if (!strcmp(parent->type, "sbus"))
|
||||
return sbus_path_component(dp, tmp_buf);
|
||||
if (!strcmp(parent->type, "ebus"))
|
||||
return ebus_path_component(dp, tmp_buf);
|
||||
|
||||
/* "isa" is handled with platform naming */
|
||||
}
|
||||
|
||||
/* Use platform naming convention. */
|
||||
return sparc32_path_component(dp, tmp_buf);
|
||||
}
|
||||
|
||||
static char * __init build_path_component(struct device_node *dp)
|
||||
{
|
||||
char tmp_buf[64], *n;
|
||||
|
||||
tmp_buf[0] = '\0';
|
||||
__build_path_component(dp, tmp_buf);
|
||||
if (tmp_buf[0] == '\0')
|
||||
strcpy(tmp_buf, dp->name);
|
||||
|
||||
n = prom_early_alloc(strlen(tmp_buf) + 1);
|
||||
strcpy(n, tmp_buf);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static char * __init build_full_name(struct device_node *dp)
|
||||
{
|
||||
int len, ourlen, plen;
|
||||
char *n;
|
||||
|
||||
plen = strlen(dp->parent->full_name);
|
||||
ourlen = strlen(dp->path_component_name);
|
||||
len = ourlen + plen + 2;
|
||||
|
||||
n = prom_early_alloc(len);
|
||||
strcpy(n, dp->parent->full_name);
|
||||
if (!is_root_node(dp->parent)) {
|
||||
strcpy(n + plen, "/");
|
||||
plen++;
|
||||
}
|
||||
strcpy(n + plen, dp->path_component_name);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static struct property * __init build_one_prop(phandle node, char *prev)
|
||||
{
|
||||
static struct property *tmp = NULL;
|
||||
struct property *p;
|
||||
int len;
|
||||
|
||||
if (tmp) {
|
||||
p = tmp;
|
||||
memset(p, 0, sizeof(*p) + 32);
|
||||
tmp = NULL;
|
||||
} else
|
||||
p = prom_early_alloc(sizeof(struct property) + 32);
|
||||
|
||||
p->name = (char *) (p + 1);
|
||||
if (prev == NULL) {
|
||||
prom_firstprop(node, p->name);
|
||||
} else {
|
||||
prom_nextprop(node, prev, p->name);
|
||||
}
|
||||
if (strlen(p->name) == 0) {
|
||||
tmp = p;
|
||||
return NULL;
|
||||
}
|
||||
p->length = prom_getproplen(node, p->name);
|
||||
if (p->length <= 0) {
|
||||
p->length = 0;
|
||||
} else {
|
||||
p->value = prom_early_alloc(p->length);
|
||||
len = prom_getproperty(node, p->name, p->value, p->length);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static struct property * __init build_prop_list(phandle node)
|
||||
{
|
||||
struct property *head, *tail;
|
||||
|
||||
head = tail = build_one_prop(node, NULL);
|
||||
while(tail) {
|
||||
tail->next = build_one_prop(node, tail->name);
|
||||
tail = tail->next;
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
static char * __init get_one_property(phandle node, char *name)
|
||||
{
|
||||
char *buf = "<NULL>";
|
||||
int len;
|
||||
|
||||
len = prom_getproplen(node, name);
|
||||
if (len > 0) {
|
||||
buf = prom_early_alloc(len);
|
||||
len = prom_getproperty(node, name, buf, len);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static struct device_node * __init create_node(phandle node)
|
||||
{
|
||||
struct device_node *dp;
|
||||
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
dp = prom_early_alloc(sizeof(*dp));
|
||||
|
||||
kref_init(&dp->kref);
|
||||
|
||||
dp->name = get_one_property(node, "name");
|
||||
dp->type = get_one_property(node, "device_type");
|
||||
dp->node = node;
|
||||
|
||||
/* Build interrupts later... */
|
||||
|
||||
dp->properties = build_prop_list(node);
|
||||
|
||||
return dp;
|
||||
}
|
||||
|
||||
static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp)
|
||||
{
|
||||
struct device_node *dp;
|
||||
|
||||
dp = create_node(node);
|
||||
if (dp) {
|
||||
*(*nextp) = dp;
|
||||
*nextp = &dp->allnext;
|
||||
|
||||
dp->parent = parent;
|
||||
dp->path_component_name = build_path_component(dp);
|
||||
dp->full_name = build_full_name(dp);
|
||||
|
||||
dp->child = build_tree(dp, prom_getchild(node), nextp);
|
||||
|
||||
dp->sibling = build_tree(parent, prom_getsibling(node), nextp);
|
||||
}
|
||||
|
||||
return dp;
|
||||
}
|
||||
|
||||
void __init prom_build_devicetree(void)
|
||||
{
|
||||
struct device_node **nextp;
|
||||
|
||||
allnodes = create_node(prom_root_node);
|
||||
allnodes->path_component_name = "";
|
||||
allnodes->full_name = "/";
|
||||
|
||||
nextp = &allnodes->allnext;
|
||||
allnodes->child = build_tree(allnodes,
|
||||
prom_getchild(allnodes->node),
|
||||
&nextp);
|
||||
printk("PROM: Built device tree with %u bytes of memory.\n",
|
||||
prom_early_allocated);
|
||||
}
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <asm/vaddrs.h>
|
||||
#include <asm/pgalloc.h> /* bug in asm-generic/tlb.h: check_pgt_cache */
|
||||
#include <asm/tlb.h>
|
||||
#include <asm/prom.h>
|
||||
|
||||
DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
|
||||
|
||||
@@ -349,6 +350,7 @@ void __init paging_init(void)
|
||||
protection_map[14] = PAGE_SHARED;
|
||||
protection_map[15] = PAGE_SHARED;
|
||||
btfixup();
|
||||
prom_build_devicetree();
|
||||
device_scan();
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Linux kernel version: 2.6.17
|
||||
# Tue Jun 20 01:26:43 2006
|
||||
# Fri Jun 23 23:17:09 2006
|
||||
#
|
||||
CONFIG_SPARC=y
|
||||
CONFIG_SPARC64=y
|
||||
@@ -286,6 +286,7 @@ CONFIG_STANDALONE=y
|
||||
# CONFIG_PREVENT_FIRMWARE_BUILD is not set
|
||||
CONFIG_FW_LOADER=y
|
||||
# CONFIG_DEBUG_DRIVER is not set
|
||||
# CONFIG_SYS_HYPERVISOR is not set
|
||||
|
||||
#
|
||||
# Connector - unified userspace <-> kernelspace linker
|
||||
@@ -434,6 +435,7 @@ CONFIG_ISCSI_TCP=m
|
||||
# CONFIG_MEGARAID_LEGACY is not set
|
||||
# CONFIG_MEGARAID_SAS is not set
|
||||
# CONFIG_SCSI_SATA is not set
|
||||
# CONFIG_SCSI_HPTIOP is not set
|
||||
# CONFIG_SCSI_DMX3191D is not set
|
||||
# CONFIG_SCSI_FUTURE_DOMAIN is not set
|
||||
# CONFIG_SCSI_IPS is not set
|
||||
@@ -733,6 +735,7 @@ CONFIG_I2C_ALGOBIT=y
|
||||
# CONFIG_I2C_I810 is not set
|
||||
# CONFIG_I2C_PIIX4 is not set
|
||||
# CONFIG_I2C_NFORCE2 is not set
|
||||
# CONFIG_I2C_OCORES is not set
|
||||
# CONFIG_I2C_PARPORT_LIGHT is not set
|
||||
# CONFIG_I2C_PROSAVAGE is not set
|
||||
# CONFIG_I2C_SAVAGE4 is not set
|
||||
@@ -776,6 +779,7 @@ CONFIG_I2C_ALGOBIT=y
|
||||
#
|
||||
CONFIG_HWMON=y
|
||||
# CONFIG_HWMON_VID is not set
|
||||
# CONFIG_SENSORS_ABITUGURU is not set
|
||||
# CONFIG_SENSORS_ADM1021 is not set
|
||||
# CONFIG_SENSORS_ADM1025 is not set
|
||||
# CONFIG_SENSORS_ADM1026 is not set
|
||||
@@ -804,10 +808,12 @@ CONFIG_HWMON=y
|
||||
# CONFIG_SENSORS_PC87360 is not set
|
||||
# CONFIG_SENSORS_SIS5595 is not set
|
||||
# CONFIG_SENSORS_SMSC47M1 is not set
|
||||
# CONFIG_SENSORS_SMSC47M192 is not set
|
||||
# CONFIG_SENSORS_SMSC47B397 is not set
|
||||
# CONFIG_SENSORS_VIA686A is not set
|
||||
# CONFIG_SENSORS_VT8231 is not set
|
||||
# CONFIG_SENSORS_W83781D is not set
|
||||
# CONFIG_SENSORS_W83791D is not set
|
||||
# CONFIG_SENSORS_W83792D is not set
|
||||
# CONFIG_SENSORS_W83L785TS is not set
|
||||
# CONFIG_SENSORS_W83627HF is not set
|
||||
@@ -1018,6 +1024,7 @@ CONFIG_USB_DEVICEFS=y
|
||||
CONFIG_USB_EHCI_HCD=m
|
||||
# CONFIG_USB_EHCI_SPLIT_ISO is not set
|
||||
# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
|
||||
# CONFIG_USB_EHCI_TT_NEWSCHED is not set
|
||||
# CONFIG_USB_ISP116X_HCD is not set
|
||||
CONFIG_USB_OHCI_HCD=y
|
||||
# CONFIG_USB_OHCI_BIG_ENDIAN is not set
|
||||
@@ -1097,10 +1104,12 @@ CONFIG_USB_HIDDEV=y
|
||||
# CONFIG_USB_LEGOTOWER is not set
|
||||
# CONFIG_USB_LCD is not set
|
||||
# CONFIG_USB_LED is not set
|
||||
# CONFIG_USB_CY7C63 is not set
|
||||
# CONFIG_USB_CYTHERM is not set
|
||||
# CONFIG_USB_PHIDGETKIT is not set
|
||||
# CONFIG_USB_PHIDGETSERVO is not set
|
||||
# CONFIG_USB_IDMOUSE is not set
|
||||
# CONFIG_USB_APPLEDISPLAY is not set
|
||||
# CONFIG_USB_SISUSBVGA is not set
|
||||
# CONFIG_USB_LD is not set
|
||||
# CONFIG_USB_TEST is not set
|
||||
@@ -1198,6 +1207,7 @@ CONFIG_FS_POSIX_ACL=y
|
||||
# CONFIG_MINIX_FS is not set
|
||||
# CONFIG_ROMFS_FS is not set
|
||||
CONFIG_INOTIFY=y
|
||||
CONFIG_INOTIFY_USER=y
|
||||
# CONFIG_QUOTA is not set
|
||||
CONFIG_DNOTIFY=y
|
||||
# CONFIG_AUTOFS_FS is not set
|
||||
|
||||
@@ -12,7 +12,7 @@ obj-y := process.o setup.o cpu.o idprom.o \
|
||||
irq.o ptrace.o time.o sys_sparc.o signal.o \
|
||||
unaligned.o central.o pci.o starfire.o semaphore.o \
|
||||
power.o sbus.o iommu_common.o sparc64_ksyms.o chmc.o \
|
||||
visemul.o
|
||||
visemul.o prom.o of_device.o
|
||||
|
||||
obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \
|
||||
pci_psycho.o pci_sabre.o pci_schizo.o \
|
||||
|
||||
+77
-38
@@ -110,43 +110,82 @@ void auxio_set_lte(int on)
|
||||
}
|
||||
}
|
||||
|
||||
void __init auxio_probe(void)
|
||||
static void __devinit auxio_report_dev(struct device_node *dp)
|
||||
{
|
||||
struct sbus_bus *sbus;
|
||||
struct sbus_dev *sdev = NULL;
|
||||
|
||||
for_each_sbus(sbus) {
|
||||
for_each_sbusdev(sdev, sbus) {
|
||||
if(!strcmp(sdev->prom_name, "auxio"))
|
||||
goto found_sdev;
|
||||
}
|
||||
}
|
||||
|
||||
found_sdev:
|
||||
if (sdev) {
|
||||
auxio_devtype = AUXIO_TYPE_SBUS;
|
||||
auxio_register = sbus_ioremap(&sdev->resource[0], 0,
|
||||
sdev->reg_addrs[0].reg_size,
|
||||
"auxiliaryIO");
|
||||
}
|
||||
#ifdef CONFIG_PCI
|
||||
else {
|
||||
struct linux_ebus *ebus;
|
||||
struct linux_ebus_device *edev = NULL;
|
||||
|
||||
for_each_ebus(ebus) {
|
||||
for_each_ebusdev(edev, ebus) {
|
||||
if (!strcmp(edev->prom_name, "auxio"))
|
||||
goto ebus_done;
|
||||
}
|
||||
}
|
||||
ebus_done:
|
||||
if (edev) {
|
||||
auxio_devtype = AUXIO_TYPE_EBUS;
|
||||
auxio_register =
|
||||
ioremap(edev->resource[0].start, sizeof(u32));
|
||||
}
|
||||
}
|
||||
auxio_set_led(AUXIO_LED_ON);
|
||||
#endif
|
||||
printk(KERN_INFO "AUXIO: Found device at %s\n",
|
||||
dp->full_name);
|
||||
}
|
||||
|
||||
static struct of_device_id auxio_match[] = {
|
||||
{
|
||||
.name = "auxio",
|
||||
},
|
||||
{},
|
||||
};
|
||||
|
||||
MODULE_DEVICE_TABLE(of, auxio_match);
|
||||
|
||||
#ifdef CONFIG_SBUS
|
||||
static int __devinit auxio_sbus_probe(struct of_device *dev, const struct of_device_id *match)
|
||||
{
|
||||
struct sbus_dev *sdev = to_sbus_device(&dev->dev);
|
||||
|
||||
auxio_devtype = AUXIO_TYPE_SBUS;
|
||||
auxio_register = sbus_ioremap(&sdev->resource[0], 0,
|
||||
sdev->reg_addrs[0].reg_size,
|
||||
"auxiliaryIO");
|
||||
if (!auxio_register)
|
||||
return -ENODEV;
|
||||
|
||||
auxio_report_dev(dev->node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct of_platform_driver auxio_sbus_driver = {
|
||||
.name = "auxio",
|
||||
.match_table = auxio_match,
|
||||
.probe = auxio_sbus_probe,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
static int __devinit auxio_ebus_probe(struct of_device *dev, const struct of_device_id *match)
|
||||
{
|
||||
struct linux_ebus_device *edev = to_ebus_device(&dev->dev);
|
||||
|
||||
auxio_devtype = AUXIO_TYPE_EBUS;
|
||||
auxio_register = ioremap(edev->resource[0].start, sizeof(u32));
|
||||
if (!auxio_register)
|
||||
return -ENODEV;
|
||||
|
||||
auxio_report_dev(dev->node);
|
||||
|
||||
auxio_set_led(AUXIO_LED_ON);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct of_platform_driver auxio_ebus_driver = {
|
||||
.name = "auxio",
|
||||
.match_table = auxio_match,
|
||||
.probe = auxio_ebus_probe,
|
||||
};
|
||||
#endif
|
||||
|
||||
static int __init auxio_probe(void)
|
||||
{
|
||||
#ifdef CONFIG_SBUS
|
||||
of_register_driver(&auxio_sbus_driver, &sbus_bus_type);
|
||||
#endif
|
||||
#ifdef CONFIG_PCI
|
||||
of_register_driver(&auxio_ebus_driver, &ebus_bus_type);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Must be after subsys_initcall() so that busses are probed. Must
|
||||
* be before device_initcall() because things like the floppy driver
|
||||
* need to use the AUXIO register.
|
||||
*/
|
||||
fs_initcall(auxio_probe);
|
||||
|
||||
@@ -29,28 +29,34 @@ static void central_probe_failure(int line)
|
||||
prom_halt();
|
||||
}
|
||||
|
||||
static void central_ranges_init(int cnode, struct linux_central *central)
|
||||
static void central_ranges_init(struct linux_central *central)
|
||||
{
|
||||
int success;
|
||||
struct device_node *dp = central->prom_node;
|
||||
void *pval;
|
||||
int len;
|
||||
|
||||
central->num_central_ranges = 0;
|
||||
success = prom_getproperty(central->prom_node, "ranges",
|
||||
(char *) central->central_ranges,
|
||||
sizeof (central->central_ranges));
|
||||
if (success != -1)
|
||||
central->num_central_ranges = (success/sizeof(struct linux_prom_ranges));
|
||||
pval = of_get_property(dp, "ranges", &len);
|
||||
if (pval) {
|
||||
memcpy(central->central_ranges, pval, len);
|
||||
central->num_central_ranges =
|
||||
(len / sizeof(struct linux_prom_ranges));
|
||||
}
|
||||
}
|
||||
|
||||
static void fhc_ranges_init(int fnode, struct linux_fhc *fhc)
|
||||
static void fhc_ranges_init(struct linux_fhc *fhc)
|
||||
{
|
||||
int success;
|
||||
struct device_node *dp = fhc->prom_node;
|
||||
void *pval;
|
||||
int len;
|
||||
|
||||
fhc->num_fhc_ranges = 0;
|
||||
success = prom_getproperty(fhc->prom_node, "ranges",
|
||||
(char *) fhc->fhc_ranges,
|
||||
sizeof (fhc->fhc_ranges));
|
||||
if (success != -1)
|
||||
fhc->num_fhc_ranges = (success/sizeof(struct linux_prom_ranges));
|
||||
pval = of_get_property(dp, "ranges", &len);
|
||||
if (pval) {
|
||||
memcpy(fhc->fhc_ranges, pval, len);
|
||||
fhc->num_fhc_ranges =
|
||||
(len / sizeof(struct linux_prom_ranges));
|
||||
}
|
||||
}
|
||||
|
||||
/* Range application routines are exported to various drivers,
|
||||
@@ -112,15 +118,10 @@ static unsigned long prom_reg_to_paddr(struct linux_prom_registers *r)
|
||||
|
||||
static void probe_other_fhcs(void)
|
||||
{
|
||||
struct linux_prom64_registers fpregs[6];
|
||||
char namebuf[128];
|
||||
int node;
|
||||
struct device_node *dp;
|
||||
struct linux_prom64_registers *fpregs;
|
||||
|
||||
node = prom_getchild(prom_root_node);
|
||||
node = prom_searchsiblings(node, "fhc");
|
||||
if (node == 0)
|
||||
central_probe_failure(__LINE__);
|
||||
while (node) {
|
||||
for_each_node_by_name(dp, "fhc") {
|
||||
struct linux_fhc *fhc;
|
||||
int board;
|
||||
u32 tmp;
|
||||
@@ -137,14 +138,12 @@ static void probe_other_fhcs(void)
|
||||
/* Toplevel FHCs have no parent. */
|
||||
fhc->parent = NULL;
|
||||
|
||||
fhc->prom_node = node;
|
||||
prom_getstring(node, "name", namebuf, sizeof(namebuf));
|
||||
strcpy(fhc->prom_name, namebuf);
|
||||
fhc_ranges_init(node, fhc);
|
||||
fhc->prom_node = dp;
|
||||
fhc_ranges_init(fhc);
|
||||
|
||||
/* Non-central FHC's have 64-bit OBP format registers. */
|
||||
if (prom_getproperty(node, "reg",
|
||||
(char *)&fpregs[0], sizeof(fpregs)) == -1)
|
||||
fpregs = of_get_property(dp, "reg", NULL);
|
||||
if (!fpregs)
|
||||
central_probe_failure(__LINE__);
|
||||
|
||||
/* Only central FHC needs special ranges applied. */
|
||||
@@ -155,7 +154,7 @@ static void probe_other_fhcs(void)
|
||||
fhc->fhc_regs.uregs = fpregs[4].phys_addr;
|
||||
fhc->fhc_regs.tregs = fpregs[5].phys_addr;
|
||||
|
||||
board = prom_getintdefault(node, "board#", -1);
|
||||
board = of_getintprop_default(dp, "board#", -1);
|
||||
fhc->board = board;
|
||||
|
||||
tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_JCTRL);
|
||||
@@ -179,33 +178,33 @@ static void probe_other_fhcs(void)
|
||||
tmp = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_CTRL);
|
||||
tmp |= FHC_CONTROL_IXIST;
|
||||
upa_writel(tmp, fhc->fhc_regs.pregs + FHC_PREGS_CTRL);
|
||||
|
||||
/* Look for the next FHC. */
|
||||
node = prom_getsibling(node);
|
||||
if (node == 0)
|
||||
break;
|
||||
node = prom_searchsiblings(node, "fhc");
|
||||
if (node == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void probe_clock_board(struct linux_central *central,
|
||||
struct linux_fhc *fhc,
|
||||
int cnode, int fnode)
|
||||
struct device_node *fp)
|
||||
{
|
||||
struct linux_prom_registers cregs[3];
|
||||
int clknode, nslots, tmp, nregs;
|
||||
struct device_node *dp;
|
||||
struct linux_prom_registers cregs[3], *pr;
|
||||
int nslots, tmp, nregs;
|
||||
|
||||
clknode = prom_searchsiblings(prom_getchild(fnode), "clock-board");
|
||||
if (clknode == 0 || clknode == -1)
|
||||
dp = fp->child;
|
||||
while (dp) {
|
||||
if (!strcmp(dp->name, "clock-board"))
|
||||
break;
|
||||
dp = dp->sibling;
|
||||
}
|
||||
if (!dp)
|
||||
central_probe_failure(__LINE__);
|
||||
|
||||
nregs = prom_getproperty(clknode, "reg", (char *)&cregs[0], sizeof(cregs));
|
||||
if (nregs == -1)
|
||||
pr = of_get_property(dp, "reg", &nregs);
|
||||
if (!pr)
|
||||
central_probe_failure(__LINE__);
|
||||
|
||||
memcpy(cregs, pr, nregs);
|
||||
nregs /= sizeof(struct linux_prom_registers);
|
||||
|
||||
apply_fhc_ranges(fhc, &cregs[0], nregs);
|
||||
apply_central_ranges(central, &cregs[0], nregs);
|
||||
central->cfreg = prom_reg_to_paddr(&cregs[0]);
|
||||
@@ -296,13 +295,13 @@ static void init_all_fhc_hw(void)
|
||||
|
||||
void central_probe(void)
|
||||
{
|
||||
struct linux_prom_registers fpregs[6];
|
||||
struct linux_prom_registers fpregs[6], *pr;
|
||||
struct linux_fhc *fhc;
|
||||
char namebuf[128];
|
||||
int cnode, fnode, err;
|
||||
struct device_node *dp, *fp;
|
||||
int err;
|
||||
|
||||
cnode = prom_finddevice("/central");
|
||||
if (cnode == 0 || cnode == -1) {
|
||||
dp = of_find_node_by_name(NULL, "central");
|
||||
if (!dp) {
|
||||
if (this_is_starfire)
|
||||
starfire_cpu_setup();
|
||||
return;
|
||||
@@ -321,31 +320,31 @@ void central_probe(void)
|
||||
|
||||
/* First init central. */
|
||||
central_bus->child = fhc;
|
||||
central_bus->prom_node = cnode;
|
||||
|
||||
prom_getstring(cnode, "name", namebuf, sizeof(namebuf));
|
||||
strcpy(central_bus->prom_name, namebuf);
|
||||
|
||||
central_ranges_init(cnode, central_bus);
|
||||
central_bus->prom_node = dp;
|
||||
central_ranges_init(central_bus);
|
||||
|
||||
/* And then central's FHC. */
|
||||
fhc->next = fhc_list;
|
||||
fhc_list = fhc;
|
||||
|
||||
fhc->parent = central_bus;
|
||||
fnode = prom_searchsiblings(prom_getchild(cnode), "fhc");
|
||||
if (fnode == 0 || fnode == -1)
|
||||
fp = dp->child;
|
||||
while (fp) {
|
||||
if (!strcmp(fp->name, "fhc"))
|
||||
break;
|
||||
fp = fp->sibling;
|
||||
}
|
||||
if (!fp)
|
||||
central_probe_failure(__LINE__);
|
||||
|
||||
fhc->prom_node = fnode;
|
||||
prom_getstring(fnode, "name", namebuf, sizeof(namebuf));
|
||||
strcpy(fhc->prom_name, namebuf);
|
||||
|
||||
fhc_ranges_init(fnode, fhc);
|
||||
fhc->prom_node = fp;
|
||||
fhc_ranges_init(fhc);
|
||||
|
||||
/* Now, map in FHC register set. */
|
||||
if (prom_getproperty(fnode, "reg", (char *)&fpregs[0], sizeof(fpregs)) == -1)
|
||||
pr = of_get_property(fp, "reg", NULL);
|
||||
if (!pr)
|
||||
central_probe_failure(__LINE__);
|
||||
memcpy(fpregs, pr, sizeof(fpregs));
|
||||
|
||||
apply_central_ranges(central_bus, &fpregs[0], 6);
|
||||
|
||||
@@ -366,7 +365,7 @@ void central_probe(void)
|
||||
fhc->jtag_master = 0;
|
||||
|
||||
/* Attach the clock board registers for CENTRAL. */
|
||||
probe_clock_board(central_bus, fhc, cnode, fnode);
|
||||
probe_clock_board(central_bus, fhc, fp);
|
||||
|
||||
err = upa_readl(fhc->fhc_regs.pregs + FHC_PREGS_ID);
|
||||
printk("FHC(board %d): Version[%x] PartID[%x] Manuf[%x] (CENTRAL)\n",
|
||||
|
||||
+26
-45
@@ -17,6 +17,7 @@
|
||||
#include <asm/spitfire.h>
|
||||
#include <asm/chmctrl.h>
|
||||
#include <asm/oplib.h>
|
||||
#include <asm/prom.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#define CHMCTRL_NDGRPS 2
|
||||
@@ -67,7 +68,6 @@ struct bank_info {
|
||||
struct mctrl_info {
|
||||
struct list_head list;
|
||||
int portid;
|
||||
int index;
|
||||
|
||||
struct obp_mem_layout layout_prop;
|
||||
int layout_size;
|
||||
@@ -339,12 +339,13 @@ static void fetch_decode_regs(struct mctrl_info *mp)
|
||||
read_mcreg(mp, CHMCTRL_DECODE4));
|
||||
}
|
||||
|
||||
static int init_one_mctrl(int node, int index)
|
||||
static int init_one_mctrl(struct device_node *dp)
|
||||
{
|
||||
struct mctrl_info *mp = kmalloc(sizeof(*mp), GFP_KERNEL);
|
||||
int portid = prom_getintdefault(node, "portid", -1);
|
||||
struct linux_prom64_registers p_reg_prop;
|
||||
int t;
|
||||
int portid = of_getintprop_default(dp, "portid", -1);
|
||||
struct linux_prom64_registers *regs;
|
||||
void *pval;
|
||||
int len;
|
||||
|
||||
if (!mp)
|
||||
return -1;
|
||||
@@ -353,24 +354,21 @@ static int init_one_mctrl(int node, int index)
|
||||
goto fail;
|
||||
|
||||
mp->portid = portid;
|
||||
mp->layout_size = prom_getproplen(node, "memory-layout");
|
||||
if (mp->layout_size < 0)
|
||||
pval = of_get_property(dp, "memory-layout", &len);
|
||||
mp->layout_size = len;
|
||||
if (!pval)
|
||||
mp->layout_size = 0;
|
||||
if (mp->layout_size > sizeof(mp->layout_prop))
|
||||
else {
|
||||
if (mp->layout_size > sizeof(mp->layout_prop))
|
||||
goto fail;
|
||||
memcpy(&mp->layout_prop, pval, len);
|
||||
}
|
||||
|
||||
regs = of_get_property(dp, "reg", NULL);
|
||||
if (!regs || regs->reg_size != 0x48)
|
||||
goto fail;
|
||||
|
||||
if (mp->layout_size > 0)
|
||||
prom_getproperty(node, "memory-layout",
|
||||
(char *) &mp->layout_prop,
|
||||
mp->layout_size);
|
||||
|
||||
t = prom_getproperty(node, "reg",
|
||||
(char *) &p_reg_prop,
|
||||
sizeof(p_reg_prop));
|
||||
if (t < 0 || p_reg_prop.reg_size != 0x48)
|
||||
goto fail;
|
||||
|
||||
mp->regs = ioremap(p_reg_prop.phys_addr, p_reg_prop.reg_size);
|
||||
mp->regs = ioremap(regs->phys_addr, regs->reg_size);
|
||||
if (mp->regs == NULL)
|
||||
goto fail;
|
||||
|
||||
@@ -384,13 +382,11 @@ static int init_one_mctrl(int node, int index)
|
||||
|
||||
fetch_decode_regs(mp);
|
||||
|
||||
mp->index = index;
|
||||
|
||||
list_add(&mp->list, &mctrl_list);
|
||||
|
||||
/* Report the device. */
|
||||
printk(KERN_INFO "chmc%d: US3 memory controller at %p [%s]\n",
|
||||
mp->index,
|
||||
printk(KERN_INFO "%s: US3 memory controller at %p [%s]\n",
|
||||
dp->full_name,
|
||||
mp->regs, (mp->layout_size ? "ACTIVE" : "INACTIVE"));
|
||||
|
||||
return 0;
|
||||
@@ -404,34 +400,19 @@ fail:
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int __init probe_for_string(char *name, int index)
|
||||
{
|
||||
int node = prom_getchild(prom_root_node);
|
||||
|
||||
while ((node = prom_searchsiblings(node, name)) != 0) {
|
||||
int ret = init_one_mctrl(node, index);
|
||||
|
||||
if (!ret)
|
||||
index++;
|
||||
|
||||
node = prom_getsibling(node);
|
||||
if (!node)
|
||||
break;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
static int __init chmc_init(void)
|
||||
{
|
||||
int index;
|
||||
struct device_node *dp;
|
||||
|
||||
/* This driver is only for cheetah platforms. */
|
||||
if (tlb_type != cheetah && tlb_type != cheetah_plus)
|
||||
return -ENODEV;
|
||||
|
||||
index = probe_for_string("memory-controller", 0);
|
||||
index = probe_for_string("mc-us3", index);
|
||||
for_each_node_by_name(dp, "memory-controller")
|
||||
init_one_mctrl(dp);
|
||||
|
||||
for_each_node_by_name(dp, "mc-us3")
|
||||
init_one_mctrl(dp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+92
-130
@@ -33,7 +33,7 @@ extern void cpu_probe(void);
|
||||
extern void central_probe(void);
|
||||
|
||||
u32 sun4v_vdev_devhandle;
|
||||
int sun4v_vdev_root;
|
||||
struct device_node *sun4v_vdev_root;
|
||||
|
||||
struct vdev_intmap {
|
||||
unsigned int phys;
|
||||
@@ -50,102 +50,68 @@ struct vdev_intmask {
|
||||
|
||||
static struct vdev_intmap *vdev_intmap;
|
||||
static int vdev_num_intmap;
|
||||
static struct vdev_intmask vdev_intmask;
|
||||
static struct vdev_intmask *vdev_intmask;
|
||||
|
||||
static void __init sun4v_virtual_device_probe(void)
|
||||
{
|
||||
struct linux_prom64_registers regs;
|
||||
struct vdev_intmap *ip;
|
||||
int node, sz, err;
|
||||
struct linux_prom64_registers *regs;
|
||||
struct property *prop;
|
||||
struct device_node *dp;
|
||||
int sz;
|
||||
|
||||
if (tlb_type != hypervisor)
|
||||
return;
|
||||
|
||||
node = prom_getchild(prom_root_node);
|
||||
node = prom_searchsiblings(node, "virtual-devices");
|
||||
if (!node) {
|
||||
dp = of_find_node_by_name(NULL, "virtual-devices");
|
||||
if (!dp) {
|
||||
prom_printf("SUN4V: Fatal error, no virtual-devices node.\n");
|
||||
prom_halt();
|
||||
}
|
||||
|
||||
sun4v_vdev_root = node;
|
||||
sun4v_vdev_root = dp;
|
||||
|
||||
prom_getproperty(node, "reg", (char *)®s, sizeof(regs));
|
||||
sun4v_vdev_devhandle = (regs.phys_addr >> 32UL) & 0x0fffffff;
|
||||
prop = of_find_property(dp, "reg", NULL);
|
||||
regs = prop->value;
|
||||
sun4v_vdev_devhandle = (regs[0].phys_addr >> 32UL) & 0x0fffffff;
|
||||
|
||||
sz = prom_getproplen(node, "interrupt-map");
|
||||
if (sz <= 0) {
|
||||
prom_printf("SUN4V: Error, no vdev interrupt-map.\n");
|
||||
prom_halt();
|
||||
}
|
||||
prop = of_find_property(dp, "interrupt-map", &sz);
|
||||
vdev_intmap = prop->value;
|
||||
vdev_num_intmap = sz / sizeof(struct vdev_intmap);
|
||||
|
||||
if ((sz % sizeof(*ip)) != 0) {
|
||||
prom_printf("SUN4V: Bogus interrupt-map property size %d\n",
|
||||
sz);
|
||||
prom_halt();
|
||||
}
|
||||
prop = of_find_property(dp, "interrupt-map-mask", NULL);
|
||||
vdev_intmask = prop->value;
|
||||
|
||||
vdev_intmap = ip = alloc_bootmem_low_pages(sz);
|
||||
if (!vdev_intmap) {
|
||||
prom_printf("SUN4V: Error, cannot allocate vdev_intmap.\n");
|
||||
prom_halt();
|
||||
}
|
||||
|
||||
err = prom_getproperty(node, "interrupt-map", (char *) ip, sz);
|
||||
if (err == -1) {
|
||||
prom_printf("SUN4V: Fatal error, no vdev interrupt-map.\n");
|
||||
prom_halt();
|
||||
}
|
||||
if (err != sz) {
|
||||
prom_printf("SUN4V: Inconsistent interrupt-map size, "
|
||||
"proplen(%d) vs getprop(%d).\n", sz,err);
|
||||
prom_halt();
|
||||
}
|
||||
|
||||
vdev_num_intmap = err / sizeof(*ip);
|
||||
|
||||
err = prom_getproperty(node, "interrupt-map-mask",
|
||||
(char *) &vdev_intmask,
|
||||
sizeof(vdev_intmask));
|
||||
if (err <= 0) {
|
||||
prom_printf("SUN4V: Fatal error, no vdev "
|
||||
"interrupt-map-mask.\n");
|
||||
prom_halt();
|
||||
}
|
||||
if (err % sizeof(vdev_intmask)) {
|
||||
prom_printf("SUN4V: Bogus interrupt-map-mask "
|
||||
"property size %d\n", err);
|
||||
prom_halt();
|
||||
}
|
||||
|
||||
printk("SUN4V: virtual-devices devhandle[%x]\n",
|
||||
sun4v_vdev_devhandle);
|
||||
printk("%s: Virtual Device Bus devhandle[%x]\n",
|
||||
dp->full_name, sun4v_vdev_devhandle);
|
||||
}
|
||||
|
||||
unsigned int sun4v_vdev_device_interrupt(unsigned int dev_node)
|
||||
unsigned int sun4v_vdev_device_interrupt(struct device_node *dev_node)
|
||||
{
|
||||
struct property *prop;
|
||||
unsigned int irq, reg;
|
||||
int err, i;
|
||||
int i;
|
||||
|
||||
err = prom_getproperty(dev_node, "interrupts",
|
||||
(char *) &irq, sizeof(irq));
|
||||
if (err <= 0) {
|
||||
prop = of_find_property(dev_node, "interrupts", NULL);
|
||||
if (!prop) {
|
||||
printk("VDEV: Cannot get \"interrupts\" "
|
||||
"property for OBP node %x\n", dev_node);
|
||||
"property for OBP node %s\n",
|
||||
dev_node->full_name);
|
||||
return 0;
|
||||
}
|
||||
irq = *(unsigned int *) prop->value;
|
||||
|
||||
err = prom_getproperty(dev_node, "reg",
|
||||
(char *) ®, sizeof(reg));
|
||||
if (err <= 0) {
|
||||
prop = of_find_property(dev_node, "reg", NULL);
|
||||
if (!prop) {
|
||||
printk("VDEV: Cannot get \"reg\" "
|
||||
"property for OBP node %x\n", dev_node);
|
||||
"property for OBP node %s\n",
|
||||
dev_node->full_name);
|
||||
return 0;
|
||||
}
|
||||
reg = *(unsigned int *) prop->value;
|
||||
|
||||
for (i = 0; i < vdev_num_intmap; i++) {
|
||||
if (vdev_intmap[i].phys == (reg & vdev_intmask.phys) &&
|
||||
vdev_intmap[i].irq == (irq & vdev_intmask.interrupt)) {
|
||||
if (vdev_intmap[i].phys == (reg & vdev_intmask->phys) &&
|
||||
vdev_intmap[i].irq == (irq & vdev_intmask->interrupt)) {
|
||||
irq = vdev_intmap[i].cinterrupt;
|
||||
break;
|
||||
}
|
||||
@@ -153,7 +119,7 @@ unsigned int sun4v_vdev_device_interrupt(unsigned int dev_node)
|
||||
|
||||
if (i == vdev_num_intmap) {
|
||||
printk("VDEV: No matching interrupt map entry "
|
||||
"for OBP node %x\n", dev_node);
|
||||
"for OBP node %s\n", dev_node->full_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -167,38 +133,44 @@ static const char *cpu_mid_prop(void)
|
||||
return "portid";
|
||||
}
|
||||
|
||||
static int get_cpu_mid(int prom_node)
|
||||
static int get_cpu_mid(struct device_node *dp)
|
||||
{
|
||||
struct property *prop;
|
||||
|
||||
if (tlb_type == hypervisor) {
|
||||
struct linux_prom64_registers reg;
|
||||
struct linux_prom64_registers *reg;
|
||||
int len;
|
||||
|
||||
if (prom_getproplen(prom_node, "cpuid") == 4)
|
||||
return prom_getintdefault(prom_node, "cpuid", 0);
|
||||
prop = of_find_property(dp, "cpuid", &len);
|
||||
if (prop && len == 4)
|
||||
return *(int *) prop->value;
|
||||
|
||||
prom_getproperty(prom_node, "reg", (char *) ®, sizeof(reg));
|
||||
return (reg.phys_addr >> 32) & 0x0fffffffUL;
|
||||
prop = of_find_property(dp, "reg", NULL);
|
||||
reg = prop->value;
|
||||
return (reg[0].phys_addr >> 32) & 0x0fffffffUL;
|
||||
} else {
|
||||
const char *prop_name = cpu_mid_prop();
|
||||
|
||||
return prom_getintdefault(prom_node, prop_name, 0);
|
||||
prop = of_find_property(dp, prop_name, NULL);
|
||||
if (prop)
|
||||
return *(int *) prop->value;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int check_cpu_node(int nd, int *cur_inst,
|
||||
int (*compare)(int, int, void *), void *compare_arg,
|
||||
int *prom_node, int *mid)
|
||||
static int check_cpu_node(struct device_node *dp, int *cur_inst,
|
||||
int (*compare)(struct device_node *, int, void *),
|
||||
void *compare_arg,
|
||||
struct device_node **dev_node, int *mid)
|
||||
{
|
||||
char node_str[128];
|
||||
|
||||
prom_getstring(nd, "device_type", node_str, sizeof(node_str));
|
||||
if (strcmp(node_str, "cpu"))
|
||||
if (strcmp(dp->type, "cpu"))
|
||||
return -ENODEV;
|
||||
|
||||
if (!compare(nd, *cur_inst, compare_arg)) {
|
||||
if (prom_node)
|
||||
*prom_node = nd;
|
||||
if (!compare(dp, *cur_inst, compare_arg)) {
|
||||
if (dev_node)
|
||||
*dev_node = dp;
|
||||
if (mid)
|
||||
*mid = get_cpu_mid(nd);
|
||||
*mid = get_cpu_mid(dp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -207,25 +179,18 @@ static int check_cpu_node(int nd, int *cur_inst,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
|
||||
int *prom_node, int *mid)
|
||||
static int __cpu_find_by(int (*compare)(struct device_node *, int, void *),
|
||||
void *compare_arg,
|
||||
struct device_node **dev_node, int *mid)
|
||||
{
|
||||
int nd, cur_inst, err;
|
||||
struct device_node *dp;
|
||||
int cur_inst;
|
||||
|
||||
nd = prom_root_node;
|
||||
cur_inst = 0;
|
||||
|
||||
err = check_cpu_node(nd, &cur_inst,
|
||||
compare, compare_arg,
|
||||
prom_node, mid);
|
||||
if (err == 0)
|
||||
return 0;
|
||||
|
||||
nd = prom_getchild(nd);
|
||||
while ((nd = prom_getsibling(nd)) != 0) {
|
||||
err = check_cpu_node(nd, &cur_inst,
|
||||
compare, compare_arg,
|
||||
prom_node, mid);
|
||||
for_each_node_by_type(dp, "cpu") {
|
||||
int err = check_cpu_node(dp, &cur_inst,
|
||||
compare, compare_arg,
|
||||
dev_node, mid);
|
||||
if (err == 0)
|
||||
return 0;
|
||||
}
|
||||
@@ -233,7 +198,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static int cpu_instance_compare(int nd, int instance, void *_arg)
|
||||
static int cpu_instance_compare(struct device_node *dp, int instance, void *_arg)
|
||||
{
|
||||
int desired_instance = (int) (long) _arg;
|
||||
|
||||
@@ -242,27 +207,27 @@ static int cpu_instance_compare(int nd, int instance, void *_arg)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int cpu_find_by_instance(int instance, int *prom_node, int *mid)
|
||||
int cpu_find_by_instance(int instance, struct device_node **dev_node, int *mid)
|
||||
{
|
||||
return __cpu_find_by(cpu_instance_compare, (void *)(long)instance,
|
||||
prom_node, mid);
|
||||
dev_node, mid);
|
||||
}
|
||||
|
||||
static int cpu_mid_compare(int nd, int instance, void *_arg)
|
||||
static int cpu_mid_compare(struct device_node *dp, int instance, void *_arg)
|
||||
{
|
||||
int desired_mid = (int) (long) _arg;
|
||||
int this_mid;
|
||||
|
||||
this_mid = get_cpu_mid(nd);
|
||||
this_mid = get_cpu_mid(dp);
|
||||
if (this_mid == desired_mid)
|
||||
return 0;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int cpu_find_by_mid(int mid, int *prom_node)
|
||||
int cpu_find_by_mid(int mid, struct device_node **dev_node)
|
||||
{
|
||||
return __cpu_find_by(cpu_mid_compare, (void *)(long)mid,
|
||||
prom_node, NULL);
|
||||
dev_node, NULL);
|
||||
}
|
||||
|
||||
void __init device_scan(void)
|
||||
@@ -274,50 +239,47 @@ void __init device_scan(void)
|
||||
|
||||
#ifndef CONFIG_SMP
|
||||
{
|
||||
int err, cpu_node, def;
|
||||
struct device_node *dp;
|
||||
int err, def;
|
||||
|
||||
err = cpu_find_by_instance(0, &cpu_node, NULL);
|
||||
err = cpu_find_by_instance(0, &dp, NULL);
|
||||
if (err) {
|
||||
prom_printf("No cpu nodes, cannot continue\n");
|
||||
prom_halt();
|
||||
}
|
||||
cpu_data(0).clock_tick = prom_getintdefault(cpu_node,
|
||||
"clock-frequency",
|
||||
0);
|
||||
cpu_data(0).clock_tick =
|
||||
of_getintprop_default(dp, "clock-frequency", 0);
|
||||
|
||||
def = ((tlb_type == hypervisor) ?
|
||||
(8 * 1024) :
|
||||
(16 * 1024));
|
||||
cpu_data(0).dcache_size = prom_getintdefault(cpu_node,
|
||||
"dcache-size",
|
||||
def);
|
||||
cpu_data(0).dcache_size = of_getintprop_default(dp,
|
||||
"dcache-size",
|
||||
def);
|
||||
|
||||
def = 32;
|
||||
cpu_data(0).dcache_line_size =
|
||||
prom_getintdefault(cpu_node, "dcache-line-size",
|
||||
def);
|
||||
of_getintprop_default(dp, "dcache-line-size", def);
|
||||
|
||||
def = 16 * 1024;
|
||||
cpu_data(0).icache_size = prom_getintdefault(cpu_node,
|
||||
"icache-size",
|
||||
def);
|
||||
cpu_data(0).icache_size = of_getintprop_default(dp,
|
||||
"icache-size",
|
||||
def);
|
||||
|
||||
def = 32;
|
||||
cpu_data(0).icache_line_size =
|
||||
prom_getintdefault(cpu_node, "icache-line-size",
|
||||
def);
|
||||
of_getintprop_default(dp, "icache-line-size", def);
|
||||
|
||||
def = ((tlb_type == hypervisor) ?
|
||||
(3 * 1024 * 1024) :
|
||||
(4 * 1024 * 1024));
|
||||
cpu_data(0).ecache_size = prom_getintdefault(cpu_node,
|
||||
"ecache-size",
|
||||
def);
|
||||
cpu_data(0).ecache_size = of_getintprop_default(dp,
|
||||
"ecache-size",
|
||||
def);
|
||||
|
||||
def = 64;
|
||||
cpu_data(0).ecache_line_size =
|
||||
prom_getintdefault(cpu_node, "ecache-line-size",
|
||||
def);
|
||||
of_getintprop_default(dp, "ecache-line-size", def);
|
||||
printk("CPU[0]: Caches "
|
||||
"D[sz(%d):line_sz(%d)] "
|
||||
"I[sz(%d):line_sz(%d)] "
|
||||
|
||||
+94
-103
@@ -269,10 +269,6 @@ EXPORT_SYMBOL(ebus_dma_enable);
|
||||
|
||||
struct linux_ebus *ebus_chain = NULL;
|
||||
|
||||
#ifdef CONFIG_SUN_AUXIO
|
||||
extern void auxio_probe(void);
|
||||
#endif
|
||||
|
||||
static inline void *ebus_alloc(size_t size)
|
||||
{
|
||||
void *mem;
|
||||
@@ -283,77 +279,55 @@ static inline void *ebus_alloc(size_t size)
|
||||
return mem;
|
||||
}
|
||||
|
||||
static void __init ebus_ranges_init(struct linux_ebus *ebus)
|
||||
{
|
||||
int success;
|
||||
|
||||
ebus->num_ebus_ranges = 0;
|
||||
success = prom_getproperty(ebus->prom_node, "ranges",
|
||||
(char *)ebus->ebus_ranges,
|
||||
sizeof(ebus->ebus_ranges));
|
||||
if (success != -1)
|
||||
ebus->num_ebus_ranges = (success/sizeof(struct linux_prom_ebus_ranges));
|
||||
}
|
||||
|
||||
static void __init ebus_intmap_init(struct linux_ebus *ebus)
|
||||
{
|
||||
int success;
|
||||
|
||||
ebus->num_ebus_intmap = 0;
|
||||
success = prom_getproperty(ebus->prom_node, "interrupt-map",
|
||||
(char *)ebus->ebus_intmap,
|
||||
sizeof(ebus->ebus_intmap));
|
||||
if (success == -1)
|
||||
return;
|
||||
|
||||
ebus->num_ebus_intmap = (success/sizeof(struct linux_prom_ebus_intmap));
|
||||
|
||||
success = prom_getproperty(ebus->prom_node, "interrupt-map-mask",
|
||||
(char *)&ebus->ebus_intmask,
|
||||
sizeof(ebus->ebus_intmask));
|
||||
if (success == -1) {
|
||||
prom_printf("%s: can't get interrupt-map-mask\n", __FUNCTION__);
|
||||
prom_halt();
|
||||
}
|
||||
}
|
||||
|
||||
int __init ebus_intmap_match(struct linux_ebus *ebus,
|
||||
struct linux_prom_registers *reg,
|
||||
int *interrupt)
|
||||
{
|
||||
struct linux_prom_ebus_intmap *imap;
|
||||
struct linux_prom_ebus_intmask *imask;
|
||||
unsigned int hi, lo, irq;
|
||||
int i;
|
||||
int i, len, n_imap;
|
||||
|
||||
if (!ebus->num_ebus_intmap)
|
||||
imap = of_get_property(ebus->prom_node, "interrupt-map", &len);
|
||||
if (!imap)
|
||||
return 0;
|
||||
n_imap = len / sizeof(imap[0]);
|
||||
|
||||
imask = of_get_property(ebus->prom_node, "interrupt-map-mask", NULL);
|
||||
if (!imask)
|
||||
return 0;
|
||||
|
||||
hi = reg->which_io & ebus->ebus_intmask.phys_hi;
|
||||
lo = reg->phys_addr & ebus->ebus_intmask.phys_lo;
|
||||
irq = *interrupt & ebus->ebus_intmask.interrupt;
|
||||
for (i = 0; i < ebus->num_ebus_intmap; i++) {
|
||||
if ((ebus->ebus_intmap[i].phys_hi == hi) &&
|
||||
(ebus->ebus_intmap[i].phys_lo == lo) &&
|
||||
(ebus->ebus_intmap[i].interrupt == irq)) {
|
||||
*interrupt = ebus->ebus_intmap[i].cinterrupt;
|
||||
hi = reg->which_io & imask->phys_hi;
|
||||
lo = reg->phys_addr & imask->phys_lo;
|
||||
irq = *interrupt & imask->interrupt;
|
||||
for (i = 0; i < n_imap; i++) {
|
||||
if ((imap[i].phys_hi == hi) &&
|
||||
(imap[i].phys_lo == lo) &&
|
||||
(imap[i].interrupt == irq)) {
|
||||
*interrupt = imap[i].cinterrupt;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void __init fill_ebus_child(int node, struct linux_prom_registers *preg,
|
||||
struct linux_ebus_child *dev, int non_standard_regs)
|
||||
void __init fill_ebus_child(struct device_node *dp,
|
||||
struct linux_prom_registers *preg,
|
||||
struct linux_ebus_child *dev,
|
||||
int non_standard_regs)
|
||||
{
|
||||
int regs[PROMREG_MAX];
|
||||
int irqs[PROMREG_MAX];
|
||||
int *regs;
|
||||
int *irqs;
|
||||
int i, len;
|
||||
|
||||
dev->prom_node = node;
|
||||
prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name));
|
||||
printk(" (%s)", dev->prom_name);
|
||||
dev->prom_node = dp;
|
||||
printk(" (%s)", dp->name);
|
||||
|
||||
len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs));
|
||||
dev->num_addrs = len / sizeof(regs[0]);
|
||||
regs = of_get_property(dp, "reg", &len);
|
||||
if (!regs)
|
||||
dev->num_addrs = 0;
|
||||
else
|
||||
dev->num_addrs = len / sizeof(regs[0]);
|
||||
|
||||
if (non_standard_regs) {
|
||||
/* This is to handle reg properties which are not
|
||||
@@ -370,21 +344,21 @@ void __init fill_ebus_child(int node, struct linux_prom_registers *preg,
|
||||
int rnum = regs[i];
|
||||
if (rnum >= dev->parent->num_addrs) {
|
||||
prom_printf("UGH: property for %s was %d, need < %d\n",
|
||||
dev->prom_name, len, dev->parent->num_addrs);
|
||||
panic(__FUNCTION__);
|
||||
dp->name, len, dev->parent->num_addrs);
|
||||
prom_halt();
|
||||
}
|
||||
dev->resource[i].start = dev->parent->resource[i].start;
|
||||
dev->resource[i].end = dev->parent->resource[i].end;
|
||||
dev->resource[i].flags = IORESOURCE_MEM;
|
||||
dev->resource[i].name = dev->prom_name;
|
||||
dev->resource[i].name = dp->name;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < PROMINTR_MAX; i++)
|
||||
dev->irqs[i] = PCI_IRQ_NONE;
|
||||
|
||||
len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs));
|
||||
if ((len == -1) || (len == 0)) {
|
||||
irqs = of_get_property(dp, "interrupts", &len);
|
||||
if (!irqs) {
|
||||
dev->num_irqs = 0;
|
||||
/*
|
||||
* Oh, well, some PROMs don't export interrupts
|
||||
@@ -392,8 +366,8 @@ void __init fill_ebus_child(int node, struct linux_prom_registers *preg,
|
||||
*
|
||||
* Be smart about PS/2 keyboard and mouse.
|
||||
*/
|
||||
if (!strcmp(dev->parent->prom_name, "8042")) {
|
||||
if (!strcmp(dev->prom_name, "kb_ps2")) {
|
||||
if (!strcmp(dev->parent->prom_node->name, "8042")) {
|
||||
if (!strcmp(dev->prom_node->name, "kb_ps2")) {
|
||||
dev->num_irqs = 1;
|
||||
dev->irqs[0] = dev->parent->irqs[0];
|
||||
} else {
|
||||
@@ -423,32 +397,32 @@ void __init fill_ebus_child(int node, struct linux_prom_registers *preg,
|
||||
|
||||
static int __init child_regs_nonstandard(struct linux_ebus_device *dev)
|
||||
{
|
||||
if (!strcmp(dev->prom_name, "i2c") ||
|
||||
!strcmp(dev->prom_name, "SUNW,lombus"))
|
||||
if (!strcmp(dev->prom_node->name, "i2c") ||
|
||||
!strcmp(dev->prom_node->name, "SUNW,lombus"))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
|
||||
void __init fill_ebus_device(struct device_node *dp, struct linux_ebus_device *dev)
|
||||
{
|
||||
struct linux_prom_registers regs[PROMREG_MAX];
|
||||
struct linux_prom_registers *regs;
|
||||
struct linux_ebus_child *child;
|
||||
int irqs[PROMINTR_MAX];
|
||||
int *irqs;
|
||||
int i, n, len;
|
||||
|
||||
dev->prom_node = node;
|
||||
prom_getstring(node, "name", dev->prom_name, sizeof(dev->prom_name));
|
||||
printk(" [%s", dev->prom_name);
|
||||
dev->prom_node = dp;
|
||||
|
||||
len = prom_getproperty(node, "reg", (void *)regs, sizeof(regs));
|
||||
if (len == -1) {
|
||||
printk(" [%s", dp->name);
|
||||
|
||||
regs = of_get_property(dp, "reg", &len);
|
||||
if (!regs) {
|
||||
dev->num_addrs = 0;
|
||||
goto probe_interrupts;
|
||||
}
|
||||
|
||||
if (len % sizeof(struct linux_prom_registers)) {
|
||||
prom_printf("UGH: proplen for %s was %d, need multiple of %d\n",
|
||||
dev->prom_name, len,
|
||||
dev->prom_node->name, len,
|
||||
(int)sizeof(struct linux_prom_registers));
|
||||
prom_halt();
|
||||
}
|
||||
@@ -466,7 +440,7 @@ void __init fill_ebus_device(int node, struct linux_ebus_device *dev)
|
||||
dev->resource[i].end =
|
||||
(dev->resource[i].start + (unsigned long)regs[i].reg_size - 1UL);
|
||||
dev->resource[i].flags = IORESOURCE_MEM;
|
||||
dev->resource[i].name = dev->prom_name;
|
||||
dev->resource[i].name = dev->prom_node->name;
|
||||
request_resource(&dev->bus->self->resource[n],
|
||||
&dev->resource[i]);
|
||||
}
|
||||
@@ -475,8 +449,8 @@ probe_interrupts:
|
||||
for (i = 0; i < PROMINTR_MAX; i++)
|
||||
dev->irqs[i] = PCI_IRQ_NONE;
|
||||
|
||||
len = prom_getproperty(node, "interrupts", (char *)&irqs, sizeof(irqs));
|
||||
if ((len == -1) || (len == 0)) {
|
||||
irqs = of_get_property(dp, "interrupts", &len);
|
||||
if (!irqs) {
|
||||
dev->num_irqs = 0;
|
||||
} else {
|
||||
dev->num_irqs = len / sizeof(irqs[0]);
|
||||
@@ -497,7 +471,18 @@ probe_interrupts:
|
||||
}
|
||||
}
|
||||
|
||||
if ((node = prom_getchild(node))) {
|
||||
dev->ofdev.node = dp;
|
||||
dev->ofdev.dev.parent = &dev->bus->ofdev.dev;
|
||||
dev->ofdev.dev.bus = &ebus_bus_type;
|
||||
strcpy(dev->ofdev.dev.bus_id, dp->path_component_name);
|
||||
|
||||
/* Register with core */
|
||||
if (of_device_register(&dev->ofdev) != 0)
|
||||
printk(KERN_DEBUG "ebus: device registration error for %s!\n",
|
||||
dev->ofdev.dev.bus_id);
|
||||
|
||||
dp = dp->child;
|
||||
if (dp) {
|
||||
printk(" ->");
|
||||
dev->children = ebus_alloc(sizeof(struct linux_ebus_child));
|
||||
|
||||
@@ -505,18 +490,18 @@ probe_interrupts:
|
||||
child->next = NULL;
|
||||
child->parent = dev;
|
||||
child->bus = dev->bus;
|
||||
fill_ebus_child(node, ®s[0],
|
||||
child, child_regs_nonstandard(dev));
|
||||
fill_ebus_child(dp, regs, child,
|
||||
child_regs_nonstandard(dev));
|
||||
|
||||
while ((node = prom_getsibling(node)) != 0) {
|
||||
while ((dp = dp->sibling) != NULL) {
|
||||
child->next = ebus_alloc(sizeof(struct linux_ebus_child));
|
||||
|
||||
child = child->next;
|
||||
child->next = NULL;
|
||||
child->parent = dev;
|
||||
child->bus = dev->bus;
|
||||
fill_ebus_child(node, ®s[0],
|
||||
child, child_regs_nonstandard(dev));
|
||||
fill_ebus_child(dp, regs, child,
|
||||
child_regs_nonstandard(dev));
|
||||
}
|
||||
}
|
||||
printk("]");
|
||||
@@ -543,7 +528,8 @@ void __init ebus_init(void)
|
||||
struct linux_ebus *ebus;
|
||||
struct pci_dev *pdev;
|
||||
struct pcidev_cookie *cookie;
|
||||
int nd, ebusnd, is_rio;
|
||||
struct device_node *dp;
|
||||
int is_rio;
|
||||
int num_ebus = 0;
|
||||
|
||||
pdev = find_next_ebus(NULL, &is_rio);
|
||||
@@ -553,20 +539,22 @@ void __init ebus_init(void)
|
||||
}
|
||||
|
||||
cookie = pdev->sysdata;
|
||||
ebusnd = cookie->prom_node;
|
||||
dp = cookie->prom_node;
|
||||
|
||||
ebus_chain = ebus = ebus_alloc(sizeof(struct linux_ebus));
|
||||
ebus->next = NULL;
|
||||
ebus->is_rio = is_rio;
|
||||
|
||||
while (ebusnd) {
|
||||
while (dp) {
|
||||
struct device_node *child;
|
||||
|
||||
/* SUNW,pci-qfe uses four empty ebuses on it.
|
||||
I think we should not consider them here,
|
||||
as they have half of the properties this
|
||||
code expects and once we do PCI hot-plug,
|
||||
we'd have to tweak with the ebus_chain
|
||||
in the runtime after initialization. -jj */
|
||||
if (!prom_getchild (ebusnd)) {
|
||||
if (!dp->child) {
|
||||
pdev = find_next_ebus(pdev, &is_rio);
|
||||
if (!pdev) {
|
||||
if (ebus == ebus_chain) {
|
||||
@@ -578,22 +566,29 @@ void __init ebus_init(void)
|
||||
}
|
||||
ebus->is_rio = is_rio;
|
||||
cookie = pdev->sysdata;
|
||||
ebusnd = cookie->prom_node;
|
||||
dp = cookie->prom_node;
|
||||
continue;
|
||||
}
|
||||
printk("ebus%d:", num_ebus);
|
||||
|
||||
prom_getstring(ebusnd, "name", ebus->prom_name, sizeof(ebus->prom_name));
|
||||
ebus->index = num_ebus;
|
||||
ebus->prom_node = ebusnd;
|
||||
ebus->prom_node = dp;
|
||||
ebus->self = pdev;
|
||||
ebus->parent = pbm = cookie->pbm;
|
||||
|
||||
ebus_ranges_init(ebus);
|
||||
ebus_intmap_init(ebus);
|
||||
ebus->ofdev.node = dp;
|
||||
ebus->ofdev.dev.parent = &pdev->dev;
|
||||
ebus->ofdev.dev.bus = &ebus_bus_type;
|
||||
strcpy(ebus->ofdev.dev.bus_id, dp->path_component_name);
|
||||
|
||||
nd = prom_getchild(ebusnd);
|
||||
if (!nd)
|
||||
/* Register with core */
|
||||
if (of_device_register(&ebus->ofdev) != 0)
|
||||
printk(KERN_DEBUG "ebus: device registration error for %s!\n",
|
||||
ebus->ofdev.dev.bus_id);
|
||||
|
||||
|
||||
child = dp->child;
|
||||
if (!child)
|
||||
goto next_ebus;
|
||||
|
||||
ebus->devices = ebus_alloc(sizeof(struct linux_ebus_device));
|
||||
@@ -602,16 +597,16 @@ void __init ebus_init(void)
|
||||
dev->next = NULL;
|
||||
dev->children = NULL;
|
||||
dev->bus = ebus;
|
||||
fill_ebus_device(nd, dev);
|
||||
fill_ebus_device(child, dev);
|
||||
|
||||
while ((nd = prom_getsibling(nd)) != 0) {
|
||||
while ((child = child->sibling) != NULL) {
|
||||
dev->next = ebus_alloc(sizeof(struct linux_ebus_device));
|
||||
|
||||
dev = dev->next;
|
||||
dev->next = NULL;
|
||||
dev->children = NULL;
|
||||
dev->bus = ebus;
|
||||
fill_ebus_device(nd, dev);
|
||||
fill_ebus_device(child, dev);
|
||||
}
|
||||
|
||||
next_ebus:
|
||||
@@ -622,7 +617,7 @@ void __init ebus_init(void)
|
||||
break;
|
||||
|
||||
cookie = pdev->sysdata;
|
||||
ebusnd = cookie->prom_node;
|
||||
dp = cookie->prom_node;
|
||||
|
||||
ebus->next = ebus_alloc(sizeof(struct linux_ebus));
|
||||
ebus = ebus->next;
|
||||
@@ -631,8 +626,4 @@ void __init ebus_init(void)
|
||||
++num_ebus;
|
||||
}
|
||||
pci_dev_put(pdev); /* XXX for the case, when ebusnd is 0, is it OK? */
|
||||
|
||||
#ifdef CONFIG_SUN_AUXIO
|
||||
auxio_probe();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <asm/iommu.h>
|
||||
#include <asm/upa.h>
|
||||
#include <asm/oplib.h>
|
||||
#include <asm/prom.h>
|
||||
#include <asm/timer.h>
|
||||
#include <asm/smp.h>
|
||||
#include <asm/starfire.h>
|
||||
@@ -635,23 +636,29 @@ static u64 prom_limit0, prom_limit1;
|
||||
|
||||
static void map_prom_timers(void)
|
||||
{
|
||||
unsigned int addr[3];
|
||||
int tnode, err;
|
||||
struct device_node *dp;
|
||||
unsigned int *addr;
|
||||
|
||||
/* PROM timer node hangs out in the top level of device siblings... */
|
||||
tnode = prom_finddevice("/counter-timer");
|
||||
dp = of_find_node_by_path("/");
|
||||
dp = dp->child;
|
||||
while (dp) {
|
||||
if (!strcmp(dp->name, "counter-timer"))
|
||||
break;
|
||||
dp = dp->sibling;
|
||||
}
|
||||
|
||||
/* Assume if node is not present, PROM uses different tick mechanism
|
||||
* which we should not care about.
|
||||
*/
|
||||
if (tnode == 0 || tnode == -1) {
|
||||
if (!dp) {
|
||||
prom_timers = (struct sun5_timer *) 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* If PROM is really using this, it must be mapped by him. */
|
||||
err = prom_getproperty(tnode, "address", (char *)addr, sizeof(addr));
|
||||
if (err == -1) {
|
||||
addr = of_get_property(dp, "address", NULL);
|
||||
if (!addr) {
|
||||
prom_printf("PROM does not have timer mapped, trying to continue.\n");
|
||||
prom_timers = (struct sun5_timer *) 0;
|
||||
return;
|
||||
|
||||
+80
-101
@@ -15,23 +15,19 @@ static void __init fatal_err(const char *reason)
|
||||
static void __init report_dev(struct sparc_isa_device *isa_dev, int child)
|
||||
{
|
||||
if (child)
|
||||
printk(" (%s)", isa_dev->prom_name);
|
||||
printk(" (%s)", isa_dev->prom_node->name);
|
||||
else
|
||||
printk(" [%s", isa_dev->prom_name);
|
||||
printk(" [%s", isa_dev->prom_node->name);
|
||||
}
|
||||
|
||||
static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev,
|
||||
struct linux_prom_registers *pregs,
|
||||
int pregs_size)
|
||||
static struct linux_prom_registers * __init
|
||||
isa_dev_get_resource(struct sparc_isa_device *isa_dev)
|
||||
{
|
||||
struct linux_prom_registers *pregs;
|
||||
unsigned long base, len;
|
||||
int prop_len;
|
||||
|
||||
prop_len = prom_getproperty(isa_dev->prom_node, "reg",
|
||||
(char *) pregs, pregs_size);
|
||||
|
||||
if (prop_len <= 0)
|
||||
return;
|
||||
pregs = of_get_property(isa_dev->prom_node, "reg", &prop_len);
|
||||
|
||||
/* Only the first one is interesting. */
|
||||
len = pregs[0].reg_size;
|
||||
@@ -42,10 +38,12 @@ static void __init isa_dev_get_resource(struct sparc_isa_device *isa_dev,
|
||||
isa_dev->resource.start = base;
|
||||
isa_dev->resource.end = (base + len - 1UL);
|
||||
isa_dev->resource.flags = IORESOURCE_IO;
|
||||
isa_dev->resource.name = isa_dev->prom_name;
|
||||
isa_dev->resource.name = isa_dev->prom_node->name;
|
||||
|
||||
request_resource(&isa_dev->bus->parent->io_space,
|
||||
&isa_dev->resource);
|
||||
|
||||
return pregs;
|
||||
}
|
||||
|
||||
/* I can't believe they didn't put a real INO in the isa device
|
||||
@@ -74,19 +72,30 @@ static struct {
|
||||
static int __init isa_dev_get_irq_using_imap(struct sparc_isa_device *isa_dev,
|
||||
struct sparc_isa_bridge *isa_br,
|
||||
int *interrupt,
|
||||
struct linux_prom_registers *pregs)
|
||||
struct linux_prom_registers *reg)
|
||||
{
|
||||
struct linux_prom_ebus_intmap *imap;
|
||||
struct linux_prom_ebus_intmap *imask;
|
||||
unsigned int hi, lo, irq;
|
||||
int i;
|
||||
int i, len, n_imap;
|
||||
|
||||
hi = pregs->which_io & isa_br->isa_intmask.phys_hi;
|
||||
lo = pregs->phys_addr & isa_br->isa_intmask.phys_lo;
|
||||
irq = *interrupt & isa_br->isa_intmask.interrupt;
|
||||
for (i = 0; i < isa_br->num_isa_intmap; i++) {
|
||||
if ((isa_br->isa_intmap[i].phys_hi == hi) &&
|
||||
(isa_br->isa_intmap[i].phys_lo == lo) &&
|
||||
(isa_br->isa_intmap[i].interrupt == irq)) {
|
||||
*interrupt = isa_br->isa_intmap[i].cinterrupt;
|
||||
imap = of_get_property(isa_br->prom_node, "interrupt-map", &len);
|
||||
if (!imap)
|
||||
return 0;
|
||||
n_imap = len / sizeof(imap[0]);
|
||||
|
||||
imask = of_get_property(isa_br->prom_node, "interrupt-map-mask", NULL);
|
||||
if (!imask)
|
||||
return 0;
|
||||
|
||||
hi = reg->which_io & imask->phys_hi;
|
||||
lo = reg->phys_addr & imask->phys_lo;
|
||||
irq = *interrupt & imask->interrupt;
|
||||
for (i = 0; i < n_imap; i++) {
|
||||
if ((imap[i].phys_hi == hi) &&
|
||||
(imap[i].phys_lo == lo) &&
|
||||
(imap[i].interrupt == irq)) {
|
||||
*interrupt = imap[i].cinterrupt;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -98,8 +107,8 @@ static void __init isa_dev_get_irq(struct sparc_isa_device *isa_dev,
|
||||
{
|
||||
int irq_prop;
|
||||
|
||||
irq_prop = prom_getintdefault(isa_dev->prom_node,
|
||||
"interrupts", -1);
|
||||
irq_prop = of_getintprop_default(isa_dev->prom_node,
|
||||
"interrupts", -1);
|
||||
if (irq_prop <= 0) {
|
||||
goto no_irq;
|
||||
} else {
|
||||
@@ -107,7 +116,8 @@ static void __init isa_dev_get_irq(struct sparc_isa_device *isa_dev,
|
||||
struct pci_pbm_info *pbm;
|
||||
int i;
|
||||
|
||||
if (isa_dev->bus->num_isa_intmap) {
|
||||
if (of_find_property(isa_dev->bus->prom_node,
|
||||
"interrupt-map", NULL)) {
|
||||
if (!isa_dev_get_irq_using_imap(isa_dev,
|
||||
isa_dev->bus,
|
||||
&irq_prop,
|
||||
@@ -141,16 +151,15 @@ no_irq:
|
||||
|
||||
static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev)
|
||||
{
|
||||
int node = prom_getchild(parent_isa_dev->prom_node);
|
||||
struct device_node *dp = parent_isa_dev->prom_node->child;
|
||||
|
||||
if (node == 0)
|
||||
if (!dp)
|
||||
return;
|
||||
|
||||
printk(" ->");
|
||||
while (node != 0) {
|
||||
struct linux_prom_registers regs[PROMREG_MAX];
|
||||
while (dp) {
|
||||
struct linux_prom_registers *regs;
|
||||
struct sparc_isa_device *isa_dev;
|
||||
int prop_len;
|
||||
|
||||
isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL);
|
||||
if (!isa_dev) {
|
||||
@@ -165,49 +174,46 @@ static void __init isa_fill_children(struct sparc_isa_device *parent_isa_dev)
|
||||
parent_isa_dev->child = isa_dev;
|
||||
|
||||
isa_dev->bus = parent_isa_dev->bus;
|
||||
isa_dev->prom_node = node;
|
||||
prop_len = prom_getproperty(node, "name",
|
||||
(char *) isa_dev->prom_name,
|
||||
sizeof(isa_dev->prom_name));
|
||||
if (prop_len <= 0) {
|
||||
fatal_err("cannot get child isa_dev OBP node name");
|
||||
prom_halt();
|
||||
}
|
||||
isa_dev->prom_node = dp;
|
||||
|
||||
prop_len = prom_getproperty(node, "compatible",
|
||||
(char *) isa_dev->compatible,
|
||||
sizeof(isa_dev->compatible));
|
||||
|
||||
/* Not having this is OK. */
|
||||
if (prop_len <= 0)
|
||||
isa_dev->compatible[0] = '\0';
|
||||
|
||||
isa_dev_get_resource(isa_dev, regs, sizeof(regs));
|
||||
regs = isa_dev_get_resource(isa_dev);
|
||||
isa_dev_get_irq(isa_dev, regs);
|
||||
|
||||
report_dev(isa_dev, 1);
|
||||
|
||||
node = prom_getsibling(node);
|
||||
dp = dp->sibling;
|
||||
}
|
||||
}
|
||||
|
||||
static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
|
||||
{
|
||||
int node = prom_getchild(isa_br->prom_node);
|
||||
struct device_node *dp = isa_br->prom_node->child;
|
||||
|
||||
while (node != 0) {
|
||||
struct linux_prom_registers regs[PROMREG_MAX];
|
||||
while (dp) {
|
||||
struct linux_prom_registers *regs;
|
||||
struct sparc_isa_device *isa_dev;
|
||||
int prop_len;
|
||||
|
||||
isa_dev = kmalloc(sizeof(*isa_dev), GFP_KERNEL);
|
||||
if (!isa_dev) {
|
||||
fatal_err("cannot allocate isa_dev");
|
||||
prom_halt();
|
||||
printk(KERN_DEBUG "ISA: cannot allocate isa_dev");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(isa_dev, 0, sizeof(*isa_dev));
|
||||
|
||||
isa_dev->ofdev.node = dp;
|
||||
isa_dev->ofdev.dev.parent = &isa_br->ofdev.dev;
|
||||
isa_dev->ofdev.dev.bus = &isa_bus_type;
|
||||
strcpy(isa_dev->ofdev.dev.bus_id, dp->path_component_name);
|
||||
|
||||
/* Register with core */
|
||||
if (of_device_register(&isa_dev->ofdev) != 0) {
|
||||
printk(KERN_DEBUG "isa: device registration error for %s!\n",
|
||||
isa_dev->ofdev.dev.bus_id);
|
||||
kfree(isa_dev);
|
||||
goto next_sibling;
|
||||
}
|
||||
|
||||
/* Link it in. */
|
||||
isa_dev->next = NULL;
|
||||
if (isa_br->devices == NULL) {
|
||||
@@ -222,24 +228,9 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
|
||||
}
|
||||
|
||||
isa_dev->bus = isa_br;
|
||||
isa_dev->prom_node = node;
|
||||
prop_len = prom_getproperty(node, "name",
|
||||
(char *) isa_dev->prom_name,
|
||||
sizeof(isa_dev->prom_name));
|
||||
if (prop_len <= 0) {
|
||||
fatal_err("cannot get isa_dev OBP node name");
|
||||
prom_halt();
|
||||
}
|
||||
isa_dev->prom_node = dp;
|
||||
|
||||
prop_len = prom_getproperty(node, "compatible",
|
||||
(char *) isa_dev->compatible,
|
||||
sizeof(isa_dev->compatible));
|
||||
|
||||
/* Not having this is OK. */
|
||||
if (prop_len <= 0)
|
||||
isa_dev->compatible[0] = '\0';
|
||||
|
||||
isa_dev_get_resource(isa_dev, regs, sizeof(regs));
|
||||
regs = isa_dev_get_resource(isa_dev);
|
||||
isa_dev_get_irq(isa_dev, regs);
|
||||
|
||||
report_dev(isa_dev, 0);
|
||||
@@ -248,7 +239,8 @@ static void __init isa_fill_devices(struct sparc_isa_bridge *isa_br)
|
||||
|
||||
printk("]");
|
||||
|
||||
node = prom_getsibling(node);
|
||||
next_sibling:
|
||||
dp = dp->sibling;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +258,7 @@ void __init isa_init(void)
|
||||
struct pcidev_cookie *pdev_cookie;
|
||||
struct pci_pbm_info *pbm;
|
||||
struct sparc_isa_bridge *isa_br;
|
||||
int prop_len;
|
||||
struct device_node *dp;
|
||||
|
||||
pdev_cookie = pdev->sysdata;
|
||||
if (!pdev_cookie) {
|
||||
@@ -275,15 +267,29 @@ void __init isa_init(void)
|
||||
continue;
|
||||
}
|
||||
pbm = pdev_cookie->pbm;
|
||||
dp = pdev_cookie->prom_node;
|
||||
|
||||
isa_br = kmalloc(sizeof(*isa_br), GFP_KERNEL);
|
||||
if (!isa_br) {
|
||||
fatal_err("cannot allocate sparc_isa_bridge");
|
||||
prom_halt();
|
||||
printk(KERN_DEBUG "isa: cannot allocate sparc_isa_bridge");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(isa_br, 0, sizeof(*isa_br));
|
||||
|
||||
isa_br->ofdev.node = dp;
|
||||
isa_br->ofdev.dev.parent = &pdev->dev;
|
||||
isa_br->ofdev.dev.bus = &isa_bus_type;
|
||||
strcpy(isa_br->ofdev.dev.bus_id, dp->path_component_name);
|
||||
|
||||
/* Register with core */
|
||||
if (of_device_register(&isa_br->ofdev) != 0) {
|
||||
printk(KERN_DEBUG "isa: device registration error for %s!\n",
|
||||
isa_br->ofdev.dev.bus_id);
|
||||
kfree(isa_br);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Link it in. */
|
||||
isa_br->next = isa_chain;
|
||||
isa_chain = isa_br;
|
||||
@@ -292,33 +298,6 @@ void __init isa_init(void)
|
||||
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,
|
||||
sizeof(isa_br->prom_name));
|
||||
|
||||
prop_len = prom_getproperty(isa_br->prom_node,
|
||||
"ranges",
|
||||
(char *) isa_br->isa_ranges,
|
||||
sizeof(isa_br->isa_ranges));
|
||||
if (prop_len <= 0)
|
||||
isa_br->num_isa_ranges = 0;
|
||||
else
|
||||
isa_br->num_isa_ranges =
|
||||
(prop_len / sizeof(struct linux_prom_isa_ranges));
|
||||
|
||||
prop_len = prom_getproperty(isa_br->prom_node,
|
||||
"interrupt-map",
|
||||
(char *) isa_br->isa_intmap,
|
||||
sizeof(isa_br->isa_intmap));
|
||||
if (prop_len <= 0)
|
||||
isa_br->num_isa_intmap = 0;
|
||||
else
|
||||
isa_br->num_isa_intmap =
|
||||
(prop_len / sizeof(struct linux_prom_isa_intmap));
|
||||
|
||||
prop_len = prom_getproperty(isa_br->prom_node,
|
||||
"interrupt-map-mask",
|
||||
(char *) &(isa_br->isa_intmask),
|
||||
sizeof(isa_br->isa_intmask));
|
||||
|
||||
printk("isa%d:", isa_br->index);
|
||||
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
#include <linux/config.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <asm/errno.h>
|
||||
#include <asm/of_device.h>
|
||||
|
||||
/**
|
||||
* of_match_device - Tell if an of_device structure has a matching
|
||||
* of_match structure
|
||||
* @ids: array of of device match structures to search in
|
||||
* @dev: the of device structure to match against
|
||||
*
|
||||
* Used by a driver to check whether an of_device present in the
|
||||
* system is in its list of supported devices.
|
||||
*/
|
||||
const struct of_device_id *of_match_device(const struct of_device_id *matches,
|
||||
const struct of_device *dev)
|
||||
{
|
||||
if (!dev->node)
|
||||
return NULL;
|
||||
while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
|
||||
int match = 1;
|
||||
if (matches->name[0])
|
||||
match &= dev->node->name
|
||||
&& !strcmp(matches->name, dev->node->name);
|
||||
if (matches->type[0])
|
||||
match &= dev->node->type
|
||||
&& !strcmp(matches->type, dev->node->type);
|
||||
if (matches->compatible[0])
|
||||
match &= of_device_is_compatible(dev->node,
|
||||
matches->compatible);
|
||||
if (match)
|
||||
return matches;
|
||||
matches++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
|
||||
{
|
||||
struct of_device * of_dev = to_of_device(dev);
|
||||
struct of_platform_driver * of_drv = to_of_platform_driver(drv);
|
||||
const struct of_device_id * matches = of_drv->match_table;
|
||||
|
||||
if (!matches)
|
||||
return 0;
|
||||
|
||||
return of_match_device(matches, of_dev) != NULL;
|
||||
}
|
||||
|
||||
struct of_device *of_dev_get(struct of_device *dev)
|
||||
{
|
||||
struct device *tmp;
|
||||
|
||||
if (!dev)
|
||||
return NULL;
|
||||
tmp = get_device(&dev->dev);
|
||||
if (tmp)
|
||||
return to_of_device(tmp);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void of_dev_put(struct of_device *dev)
|
||||
{
|
||||
if (dev)
|
||||
put_device(&dev->dev);
|
||||
}
|
||||
|
||||
|
||||
static int of_device_probe(struct device *dev)
|
||||
{
|
||||
int error = -ENODEV;
|
||||
struct of_platform_driver *drv;
|
||||
struct of_device *of_dev;
|
||||
const struct of_device_id *match;
|
||||
|
||||
drv = to_of_platform_driver(dev->driver);
|
||||
of_dev = to_of_device(dev);
|
||||
|
||||
if (!drv->probe)
|
||||
return error;
|
||||
|
||||
of_dev_get(of_dev);
|
||||
|
||||
match = of_match_device(drv->match_table, of_dev);
|
||||
if (match)
|
||||
error = drv->probe(of_dev, match);
|
||||
if (error)
|
||||
of_dev_put(of_dev);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static int of_device_remove(struct device *dev)
|
||||
{
|
||||
struct of_device * of_dev = to_of_device(dev);
|
||||
struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
|
||||
|
||||
if (dev->driver && drv->remove)
|
||||
drv->remove(of_dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int of_device_suspend(struct device *dev, pm_message_t state)
|
||||
{
|
||||
struct of_device * of_dev = to_of_device(dev);
|
||||
struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
|
||||
int error = 0;
|
||||
|
||||
if (dev->driver && drv->suspend)
|
||||
error = drv->suspend(of_dev, state);
|
||||
return error;
|
||||
}
|
||||
|
||||
static int of_device_resume(struct device * dev)
|
||||
{
|
||||
struct of_device * of_dev = to_of_device(dev);
|
||||
struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
|
||||
int error = 0;
|
||||
|
||||
if (dev->driver && drv->resume)
|
||||
error = drv->resume(of_dev);
|
||||
return error;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
struct bus_type isa_bus_type = {
|
||||
.name = "isa",
|
||||
.match = of_platform_bus_match,
|
||||
.probe = of_device_probe,
|
||||
.remove = of_device_remove,
|
||||
.suspend = of_device_suspend,
|
||||
.resume = of_device_resume,
|
||||
};
|
||||
|
||||
struct bus_type ebus_bus_type = {
|
||||
.name = "ebus",
|
||||
.match = of_platform_bus_match,
|
||||
.probe = of_device_probe,
|
||||
.remove = of_device_remove,
|
||||
.suspend = of_device_suspend,
|
||||
.resume = of_device_resume,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SBUS
|
||||
struct bus_type sbus_bus_type = {
|
||||
.name = "sbus",
|
||||
.match = of_platform_bus_match,
|
||||
.probe = of_device_probe,
|
||||
.remove = of_device_remove,
|
||||
.suspend = of_device_suspend,
|
||||
.resume = of_device_resume,
|
||||
};
|
||||
#endif
|
||||
|
||||
static int __init of_bus_driver_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
if (!err)
|
||||
err = bus_register(&isa_bus_type);
|
||||
if (!err)
|
||||
err = bus_register(&ebus_bus_type);
|
||||
#endif
|
||||
#ifdef CONFIG_SBUS
|
||||
if (!err)
|
||||
err = bus_register(&sbus_bus_type);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
postcore_initcall(of_bus_driver_init);
|
||||
|
||||
int of_register_driver(struct of_platform_driver *drv, struct bus_type *bus)
|
||||
{
|
||||
/* initialize common driver fields */
|
||||
drv->driver.name = drv->name;
|
||||
drv->driver.bus = bus;
|
||||
|
||||
/* register with core */
|
||||
return driver_register(&drv->driver);
|
||||
}
|
||||
|
||||
void of_unregister_driver(struct of_platform_driver *drv)
|
||||
{
|
||||
driver_unregister(&drv->driver);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct of_device *ofdev;
|
||||
|
||||
ofdev = to_of_device(dev);
|
||||
return sprintf(buf, "%s", ofdev->node->full_name);
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(devspec, S_IRUGO, dev_show_devspec, NULL);
|
||||
|
||||
/**
|
||||
* of_release_dev - free an of device structure when all users of it are finished.
|
||||
* @dev: device that's been disconnected
|
||||
*
|
||||
* Will be called only by the device core when all users of this of device are
|
||||
* done.
|
||||
*/
|
||||
void of_release_dev(struct device *dev)
|
||||
{
|
||||
struct of_device *ofdev;
|
||||
|
||||
ofdev = to_of_device(dev);
|
||||
|
||||
kfree(ofdev);
|
||||
}
|
||||
|
||||
int of_device_register(struct of_device *ofdev)
|
||||
{
|
||||
int rc;
|
||||
|
||||
BUG_ON(ofdev->node == NULL);
|
||||
|
||||
rc = device_register(&ofdev->dev);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
device_create_file(&ofdev->dev, &dev_attr_devspec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void of_device_unregister(struct of_device *ofdev)
|
||||
{
|
||||
device_remove_file(&ofdev->dev, &dev_attr_devspec);
|
||||
device_unregister(&ofdev->dev);
|
||||
}
|
||||
|
||||
struct of_device* of_platform_device_create(struct device_node *np,
|
||||
const char *bus_id,
|
||||
struct device *parent,
|
||||
struct bus_type *bus)
|
||||
{
|
||||
struct of_device *dev;
|
||||
|
||||
dev = kmalloc(sizeof(*dev), GFP_KERNEL);
|
||||
if (!dev)
|
||||
return NULL;
|
||||
memset(dev, 0, sizeof(*dev));
|
||||
|
||||
dev->dev.parent = parent;
|
||||
dev->dev.bus = bus;
|
||||
dev->dev.release = of_release_dev;
|
||||
|
||||
strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
|
||||
|
||||
if (of_device_register(dev) != 0) {
|
||||
kfree(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(of_match_device);
|
||||
EXPORT_SYMBOL(of_register_driver);
|
||||
EXPORT_SYMBOL(of_unregister_driver);
|
||||
EXPORT_SYMBOL(of_device_register);
|
||||
EXPORT_SYMBOL(of_device_unregister);
|
||||
EXPORT_SYMBOL(of_dev_get);
|
||||
EXPORT_SYMBOL(of_dev_put);
|
||||
EXPORT_SYMBOL(of_platform_device_create);
|
||||
EXPORT_SYMBOL(of_release_dev);
|
||||
+31
-28
@@ -22,6 +22,7 @@
|
||||
#include <asm/irq.h>
|
||||
#include <asm/ebus.h>
|
||||
#include <asm/isa.h>
|
||||
#include <asm/prom.h>
|
||||
|
||||
unsigned long pci_memspace_mask = 0xffffffffUL;
|
||||
|
||||
@@ -177,16 +178,16 @@ void pci_config_write32(u32 *addr, u32 val)
|
||||
}
|
||||
|
||||
/* Probe for all PCI controllers in the system. */
|
||||
extern void sabre_init(int, char *);
|
||||
extern void psycho_init(int, char *);
|
||||
extern void schizo_init(int, char *);
|
||||
extern void schizo_plus_init(int, char *);
|
||||
extern void tomatillo_init(int, char *);
|
||||
extern void sun4v_pci_init(int, char *);
|
||||
extern void sabre_init(struct device_node *, const char *);
|
||||
extern void psycho_init(struct device_node *, const char *);
|
||||
extern void schizo_init(struct device_node *, const char *);
|
||||
extern void schizo_plus_init(struct device_node *, const char *);
|
||||
extern void tomatillo_init(struct device_node *, const char *);
|
||||
extern void sun4v_pci_init(struct device_node *, const char *);
|
||||
|
||||
static struct {
|
||||
char *model_name;
|
||||
void (*init)(int, char *);
|
||||
void (*init)(struct device_node *, const char *);
|
||||
} pci_controller_table[] __initdata = {
|
||||
{ "SUNW,sabre", sabre_init },
|
||||
{ "pci108e,a000", sabre_init },
|
||||
@@ -204,7 +205,7 @@ static struct {
|
||||
#define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \
|
||||
sizeof(pci_controller_table[0]))
|
||||
|
||||
static int __init pci_controller_init(char *model_name, int namelen, int node)
|
||||
static int __init pci_controller_init(const char *model_name, int namelen, struct device_node *dp)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -212,18 +213,15 @@ static int __init pci_controller_init(char *model_name, int namelen, int node)
|
||||
if (!strncmp(model_name,
|
||||
pci_controller_table[i].model_name,
|
||||
namelen)) {
|
||||
pci_controller_table[i].init(node, model_name);
|
||||
pci_controller_table[i].init(dp, model_name);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
printk("PCI: Warning unknown controller, model name [%s]\n",
|
||||
model_name);
|
||||
printk("PCI: Ignoring controller...\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __init pci_is_controller(char *model_name, int namelen, int node)
|
||||
static int __init pci_is_controller(const char *model_name, int namelen, struct device_node *dp)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -237,36 +235,35 @@ static int __init pci_is_controller(char *model_name, int namelen, int node)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __init pci_controller_scan(int (*handler)(char *, int, int))
|
||||
static int __init pci_controller_scan(int (*handler)(const char *, int, struct device_node *))
|
||||
{
|
||||
char namebuf[64];
|
||||
int node;
|
||||
struct device_node *dp;
|
||||
int count = 0;
|
||||
|
||||
node = prom_getchild(prom_root_node);
|
||||
while ((node = prom_searchsiblings(node, "pci")) != 0) {
|
||||
for_each_node_by_name(dp, "pci") {
|
||||
struct property *prop;
|
||||
int len;
|
||||
|
||||
if ((len = prom_getproperty(node, "model", namebuf, sizeof(namebuf))) > 0 ||
|
||||
(len = prom_getproperty(node, "compatible", namebuf, sizeof(namebuf))) > 0) {
|
||||
prop = of_find_property(dp, "model", &len);
|
||||
if (!prop)
|
||||
prop = of_find_property(dp, "compatible", &len);
|
||||
|
||||
if (prop) {
|
||||
const char *model = prop->value;
|
||||
int item_len = 0;
|
||||
|
||||
/* Our value may be a multi-valued string in the
|
||||
* case of some compatible properties. For sanity,
|
||||
* only try the first one. */
|
||||
|
||||
while (namebuf[item_len] && len) {
|
||||
* only try the first one.
|
||||
*/
|
||||
while (model[item_len] && len) {
|
||||
len--;
|
||||
item_len++;
|
||||
}
|
||||
|
||||
if (handler(namebuf, item_len, node))
|
||||
if (handler(model, item_len, dp))
|
||||
count++;
|
||||
}
|
||||
|
||||
node = prom_getsibling(node);
|
||||
if (!node)
|
||||
break;
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -409,8 +406,14 @@ void pcibios_bus_to_resource(struct pci_dev *pdev, struct resource *res,
|
||||
}
|
||||
EXPORT_SYMBOL(pcibios_bus_to_resource);
|
||||
|
||||
extern int pci_irq_verbose;
|
||||
|
||||
char * __init pcibios_setup(char *str)
|
||||
{
|
||||
if (!strcmp(str, "irq_verbose")) {
|
||||
pci_irq_verbose = 1;
|
||||
return NULL;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
+120
-103
@@ -9,6 +9,12 @@
|
||||
#include <linux/init.h>
|
||||
|
||||
#include <asm/pbm.h>
|
||||
#include <asm/prom.h>
|
||||
|
||||
#include "pci_impl.h"
|
||||
|
||||
/* Pass "pci=irq_verbose" on the kernel command line to enable this. */
|
||||
int pci_irq_verbose;
|
||||
|
||||
/* Fix self device of BUS and hook it into BUS->self.
|
||||
* The pci_scan_bus does not do this for the host bridge.
|
||||
@@ -28,16 +34,14 @@ void __init pci_fixup_host_bridge_self(struct pci_bus *pbus)
|
||||
prom_halt();
|
||||
}
|
||||
|
||||
/* Find the OBP PROM device tree node for a PCI device.
|
||||
* Return zero if not found.
|
||||
*/
|
||||
static int __init find_device_prom_node(struct pci_pbm_info *pbm,
|
||||
struct pci_dev *pdev,
|
||||
int bus_prom_node,
|
||||
struct linux_prom_pci_registers *pregs,
|
||||
int *nregs)
|
||||
/* Find the OBP PROM device tree node for a PCI device. */
|
||||
static struct device_node * __init
|
||||
find_device_prom_node(struct pci_pbm_info *pbm, struct pci_dev *pdev,
|
||||
struct device_node *bus_node,
|
||||
struct linux_prom_pci_registers **pregs,
|
||||
int *nregs)
|
||||
{
|
||||
int node;
|
||||
struct device_node *dp;
|
||||
|
||||
*nregs = 0;
|
||||
|
||||
@@ -54,24 +58,30 @@ static int __init find_device_prom_node(struct pci_pbm_info *pbm,
|
||||
pdev->device == PCI_DEVICE_ID_SUN_TOMATILLO ||
|
||||
pdev->device == PCI_DEVICE_ID_SUN_SABRE ||
|
||||
pdev->device == PCI_DEVICE_ID_SUN_HUMMINGBIRD))
|
||||
return bus_prom_node;
|
||||
return bus_node;
|
||||
|
||||
node = prom_getchild(bus_prom_node);
|
||||
while (node != 0) {
|
||||
int err = prom_getproperty(node, "reg",
|
||||
(char *)pregs,
|
||||
sizeof(*pregs) * PROMREG_MAX);
|
||||
if (err == 0 || err == -1)
|
||||
dp = bus_node->child;
|
||||
while (dp) {
|
||||
struct linux_prom_pci_registers *regs;
|
||||
struct property *prop;
|
||||
int len;
|
||||
|
||||
prop = of_find_property(dp, "reg", &len);
|
||||
if (!prop)
|
||||
goto do_next_sibling;
|
||||
if (((pregs[0].phys_hi >> 8) & 0xff) == pdev->devfn) {
|
||||
*nregs = err / sizeof(*pregs);
|
||||
return node;
|
||||
|
||||
regs = prop->value;
|
||||
if (((regs[0].phys_hi >> 8) & 0xff) == pdev->devfn) {
|
||||
*pregs = regs;
|
||||
*nregs = len / sizeof(struct linux_prom_pci_registers);
|
||||
return dp;
|
||||
}
|
||||
|
||||
do_next_sibling:
|
||||
node = prom_getsibling(node);
|
||||
dp = dp->sibling;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Older versions of OBP on PCI systems encode 64-bit MEM
|
||||
@@ -128,15 +138,17 @@ static void __init fixup_obp_assignments(struct pci_dev *pdev,
|
||||
*/
|
||||
static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm,
|
||||
struct pci_dev *pdev,
|
||||
int bus_prom_node)
|
||||
struct device_node *bus_node)
|
||||
{
|
||||
struct linux_prom_pci_registers pregs[PROMREG_MAX];
|
||||
struct linux_prom_pci_registers *pregs = NULL;
|
||||
struct pcidev_cookie *pcp;
|
||||
int device_prom_node, nregs, err;
|
||||
struct device_node *dp;
|
||||
struct property *prop;
|
||||
int nregs, len;
|
||||
|
||||
device_prom_node = find_device_prom_node(pbm, pdev, bus_prom_node,
|
||||
pregs, &nregs);
|
||||
if (device_prom_node == 0) {
|
||||
dp = find_device_prom_node(pbm, pdev, bus_node,
|
||||
&pregs, &nregs);
|
||||
if (!dp) {
|
||||
/* If it is not in the OBP device tree then
|
||||
* there must be a damn good reason for it.
|
||||
*
|
||||
@@ -150,45 +162,43 @@ static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm,
|
||||
return;
|
||||
}
|
||||
|
||||
pcp = kmalloc(sizeof(*pcp), GFP_ATOMIC);
|
||||
pcp = kzalloc(sizeof(*pcp), GFP_ATOMIC);
|
||||
if (pcp == NULL) {
|
||||
prom_printf("PCI_COOKIE: Fatal malloc error, aborting...\n");
|
||||
prom_halt();
|
||||
}
|
||||
pcp->pbm = pbm;
|
||||
pcp->prom_node = device_prom_node;
|
||||
memcpy(pcp->prom_regs, pregs, sizeof(pcp->prom_regs));
|
||||
pcp->prom_node = dp;
|
||||
memcpy(pcp->prom_regs, pregs,
|
||||
nregs * sizeof(struct linux_prom_pci_registers));
|
||||
pcp->num_prom_regs = nregs;
|
||||
err = prom_getproperty(device_prom_node, "name",
|
||||
pcp->prom_name, sizeof(pcp->prom_name));
|
||||
if (err > 0)
|
||||
pcp->prom_name[err] = 0;
|
||||
else
|
||||
pcp->prom_name[0] = 0;
|
||||
|
||||
err = prom_getproperty(device_prom_node,
|
||||
"assigned-addresses",
|
||||
(char *)pcp->prom_assignments,
|
||||
sizeof(pcp->prom_assignments));
|
||||
if (err == 0 || err == -1)
|
||||
/* We can't have the pcidev_cookie assignments be just
|
||||
* direct pointers into the property value, since they
|
||||
* are potentially modified by the probing process.
|
||||
*/
|
||||
prop = of_find_property(dp, "assigned-addresses", &len);
|
||||
if (!prop) {
|
||||
pcp->num_prom_assignments = 0;
|
||||
else
|
||||
} else {
|
||||
memcpy(pcp->prom_assignments, prop->value, len);
|
||||
pcp->num_prom_assignments =
|
||||
(err / sizeof(pcp->prom_assignments[0]));
|
||||
(len / sizeof(pcp->prom_assignments[0]));
|
||||
}
|
||||
|
||||
if (strcmp(pcp->prom_name, "ebus") == 0) {
|
||||
struct linux_prom_ebus_ranges erng[PROM_PCIRNG_MAX];
|
||||
if (strcmp(dp->name, "ebus") == 0) {
|
||||
struct linux_prom_ebus_ranges *erng;
|
||||
int iter;
|
||||
|
||||
/* EBUS is special... */
|
||||
err = prom_getproperty(device_prom_node, "ranges",
|
||||
(char *)&erng[0], sizeof(erng));
|
||||
if (err == 0 || err == -1) {
|
||||
prop = of_find_property(dp, "ranges", &len);
|
||||
if (!prop) {
|
||||
prom_printf("EBUS: Fatal error, no range property\n");
|
||||
prom_halt();
|
||||
}
|
||||
err = (err / sizeof(erng[0]));
|
||||
for(iter = 0; iter < err; iter++) {
|
||||
erng = prop->value;
|
||||
len = (len / sizeof(erng[0]));
|
||||
for (iter = 0; iter < len; iter++) {
|
||||
struct linux_prom_ebus_ranges *ep = &erng[iter];
|
||||
struct linux_prom_pci_registers *ap;
|
||||
|
||||
@@ -200,7 +210,7 @@ static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm,
|
||||
ap->size_hi = 0;
|
||||
ap->size_lo = ep->size;
|
||||
}
|
||||
pcp->num_prom_assignments = err;
|
||||
pcp->num_prom_assignments = len;
|
||||
}
|
||||
|
||||
fixup_obp_assignments(pdev, pcp);
|
||||
@@ -210,7 +220,7 @@ static void __init pdev_cookie_fillin(struct pci_pbm_info *pbm,
|
||||
|
||||
void __init pci_fill_in_pbm_cookies(struct pci_bus *pbus,
|
||||
struct pci_pbm_info *pbm,
|
||||
int prom_node)
|
||||
struct device_node *dp)
|
||||
{
|
||||
struct pci_dev *pdev, *pdev_next;
|
||||
struct pci_bus *this_pbus, *pbus_next;
|
||||
@@ -218,7 +228,7 @@ void __init pci_fill_in_pbm_cookies(struct pci_bus *pbus,
|
||||
/* This must be _safe because the cookie fillin
|
||||
routine can delete devices from the tree. */
|
||||
list_for_each_entry_safe(pdev, pdev_next, &pbus->devices, bus_list)
|
||||
pdev_cookie_fillin(pbm, pdev, prom_node);
|
||||
pdev_cookie_fillin(pbm, pdev, dp);
|
||||
|
||||
list_for_each_entry_safe(this_pbus, pbus_next, &pbus->children, node) {
|
||||
struct pcidev_cookie *pcp = this_pbus->self->sysdata;
|
||||
@@ -241,7 +251,6 @@ static void __init bad_assignment(struct pci_dev *pdev,
|
||||
if (res)
|
||||
prom_printf("PCI: RES[%016lx-->%016lx:(%lx)]\n",
|
||||
res->start, res->end, res->flags);
|
||||
prom_printf("Please email this information to davem@redhat.com\n");
|
||||
if (do_prom_halt)
|
||||
prom_halt();
|
||||
}
|
||||
@@ -273,8 +282,7 @@ __init get_root_resource(struct linux_prom_pci_registers *ap,
|
||||
return &pbm->mem_space;
|
||||
|
||||
default:
|
||||
printk("PCI: What is resource space %x? "
|
||||
"Tell davem@redhat.com about it!\n", space);
|
||||
printk("PCI: What is resource space %x?\n", space);
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
@@ -556,9 +564,10 @@ static inline unsigned int pci_slot_swivel(struct pci_pbm_info *pbm,
|
||||
|
||||
ret = ((interrupt - 1 + (PCI_SLOT(pdev->devfn) & 3)) & 3) + 1;
|
||||
|
||||
printk("%s: %s IRQ Swivel %s [%x:%x] -> [%x]\n",
|
||||
pbm->name, pci_name(toplevel_pdev), pci_name(pdev),
|
||||
interrupt, PCI_SLOT(pdev->devfn), ret);
|
||||
if (pci_irq_verbose)
|
||||
printk("%s: %s IRQ Swivel %s [%x:%x] -> [%x]\n",
|
||||
pbm->name, pci_name(toplevel_pdev), pci_name(pdev),
|
||||
interrupt, PCI_SLOT(pdev->devfn), ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -568,58 +577,60 @@ static inline unsigned int pci_apply_intmap(struct pci_pbm_info *pbm,
|
||||
struct pci_dev *pbus,
|
||||
struct pci_dev *pdev,
|
||||
unsigned int interrupt,
|
||||
unsigned int *cnode)
|
||||
struct device_node **cnode)
|
||||
{
|
||||
struct linux_prom_pci_intmap imap[PROM_PCIIMAP_MAX];
|
||||
struct linux_prom_pci_intmask imask;
|
||||
struct linux_prom_pci_intmap *imap;
|
||||
struct linux_prom_pci_intmask *imask;
|
||||
struct pcidev_cookie *pbus_pcp = pbus->sysdata;
|
||||
struct pcidev_cookie *pdev_pcp = pdev->sysdata;
|
||||
struct linux_prom_pci_registers *pregs = pdev_pcp->prom_regs;
|
||||
struct property *prop;
|
||||
int plen, num_imap, i;
|
||||
unsigned int hi, mid, lo, irq, orig_interrupt;
|
||||
|
||||
*cnode = pbus_pcp->prom_node;
|
||||
|
||||
plen = prom_getproperty(pbus_pcp->prom_node, "interrupt-map",
|
||||
(char *) &imap[0], sizeof(imap));
|
||||
if (plen <= 0 ||
|
||||
prop = of_find_property(pbus_pcp->prom_node, "interrupt-map", &plen);
|
||||
if (!prop ||
|
||||
(plen % sizeof(struct linux_prom_pci_intmap)) != 0) {
|
||||
printk("%s: Device %s interrupt-map has bad len %d\n",
|
||||
pbm->name, pci_name(pbus), plen);
|
||||
goto no_intmap;
|
||||
}
|
||||
imap = prop->value;
|
||||
num_imap = plen / sizeof(struct linux_prom_pci_intmap);
|
||||
|
||||
plen = prom_getproperty(pbus_pcp->prom_node, "interrupt-map-mask",
|
||||
(char *) &imask, sizeof(imask));
|
||||
if (plen <= 0 ||
|
||||
prop = of_find_property(pbus_pcp->prom_node, "interrupt-map-mask", &plen);
|
||||
if (!prop ||
|
||||
(plen % sizeof(struct linux_prom_pci_intmask)) != 0) {
|
||||
printk("%s: Device %s interrupt-map-mask has bad len %d\n",
|
||||
pbm->name, pci_name(pbus), plen);
|
||||
goto no_intmap;
|
||||
}
|
||||
imask = prop->value;
|
||||
|
||||
orig_interrupt = interrupt;
|
||||
|
||||
hi = pregs->phys_hi & imask.phys_hi;
|
||||
mid = pregs->phys_mid & imask.phys_mid;
|
||||
lo = pregs->phys_lo & imask.phys_lo;
|
||||
irq = interrupt & imask.interrupt;
|
||||
hi = pregs->phys_hi & imask->phys_hi;
|
||||
mid = pregs->phys_mid & imask->phys_mid;
|
||||
lo = pregs->phys_lo & imask->phys_lo;
|
||||
irq = interrupt & imask->interrupt;
|
||||
|
||||
for (i = 0; i < num_imap; i++) {
|
||||
if (imap[i].phys_hi == hi &&
|
||||
imap[i].phys_mid == mid &&
|
||||
imap[i].phys_lo == lo &&
|
||||
imap[i].interrupt == irq) {
|
||||
*cnode = imap[i].cnode;
|
||||
*cnode = of_find_node_by_phandle(imap[i].cnode);
|
||||
interrupt = imap[i].cinterrupt;
|
||||
}
|
||||
}
|
||||
|
||||
printk("%s: %s MAP BUS %s DEV %s [%x] -> [%x]\n",
|
||||
pbm->name, pci_name(toplevel_pdev),
|
||||
pci_name(pbus), pci_name(pdev),
|
||||
orig_interrupt, interrupt);
|
||||
if (pci_irq_verbose)
|
||||
printk("%s: %s MAP BUS %s DEV %s [%x] -> [%x]\n",
|
||||
pbm->name, pci_name(toplevel_pdev),
|
||||
pci_name(pbus), pci_name(pdev),
|
||||
orig_interrupt, interrupt);
|
||||
|
||||
no_intmap:
|
||||
return interrupt;
|
||||
@@ -633,21 +644,22 @@ no_intmap:
|
||||
* all interrupt translations are complete, else we should use that node's
|
||||
* "reg" property to apply the PBM's "interrupt-{map,mask}" to the interrupt.
|
||||
*/
|
||||
static unsigned int __init pci_intmap_match_to_root(struct pci_pbm_info *pbm,
|
||||
struct pci_dev *pdev,
|
||||
unsigned int *interrupt)
|
||||
static struct device_node * __init
|
||||
pci_intmap_match_to_root(struct pci_pbm_info *pbm,
|
||||
struct pci_dev *pdev,
|
||||
unsigned int *interrupt)
|
||||
{
|
||||
struct pci_dev *toplevel_pdev = pdev;
|
||||
struct pcidev_cookie *toplevel_pcp = toplevel_pdev->sysdata;
|
||||
unsigned int cnode = toplevel_pcp->prom_node;
|
||||
struct device_node *cnode = toplevel_pcp->prom_node;
|
||||
|
||||
while (pdev->bus->number != pbm->pci_first_busno) {
|
||||
struct pci_dev *pbus = pdev->bus->self;
|
||||
struct pcidev_cookie *pcp = pbus->sysdata;
|
||||
int plen;
|
||||
struct property *prop;
|
||||
|
||||
plen = prom_getproplen(pcp->prom_node, "interrupt-map");
|
||||
if (plen <= 0) {
|
||||
prop = of_find_property(pcp->prom_node, "interrupt-map", NULL);
|
||||
if (!prop) {
|
||||
*interrupt = pci_slot_swivel(pbm, toplevel_pdev,
|
||||
pdev, *interrupt);
|
||||
cnode = pcp->prom_node;
|
||||
@@ -675,26 +687,29 @@ static int __init pci_intmap_match(struct pci_dev *pdev, unsigned int *interrupt
|
||||
{
|
||||
struct pcidev_cookie *dev_pcp = pdev->sysdata;
|
||||
struct pci_pbm_info *pbm = dev_pcp->pbm;
|
||||
struct linux_prom_pci_registers reg[PROMREG_MAX];
|
||||
struct linux_prom_pci_registers *reg;
|
||||
struct device_node *cnode;
|
||||
struct property *prop;
|
||||
unsigned int hi, mid, lo, irq;
|
||||
int i, cnode, plen;
|
||||
int i, plen;
|
||||
|
||||
cnode = pci_intmap_match_to_root(pbm, pdev, interrupt);
|
||||
if (cnode == pbm->prom_node)
|
||||
goto success;
|
||||
|
||||
plen = prom_getproperty(cnode, "reg", (char *) reg, sizeof(reg));
|
||||
if (plen <= 0 ||
|
||||
prop = of_find_property(cnode, "reg", &plen);
|
||||
if (!prop ||
|
||||
(plen % sizeof(struct linux_prom_pci_registers)) != 0) {
|
||||
printk("%s: OBP node %x reg property has bad len %d\n",
|
||||
pbm->name, cnode, plen);
|
||||
printk("%s: OBP node %s reg property has bad len %d\n",
|
||||
pbm->name, cnode->full_name, plen);
|
||||
goto fail;
|
||||
}
|
||||
reg = prop->value;
|
||||
|
||||
hi = reg[0].phys_hi & pbm->pbm_intmask.phys_hi;
|
||||
mid = reg[0].phys_mid & pbm->pbm_intmask.phys_mid;
|
||||
lo = reg[0].phys_lo & pbm->pbm_intmask.phys_lo;
|
||||
irq = *interrupt & pbm->pbm_intmask.interrupt;
|
||||
hi = reg[0].phys_hi & pbm->pbm_intmask->phys_hi;
|
||||
mid = reg[0].phys_mid & pbm->pbm_intmask->phys_mid;
|
||||
lo = reg[0].phys_lo & pbm->pbm_intmask->phys_lo;
|
||||
irq = *interrupt & pbm->pbm_intmask->interrupt;
|
||||
|
||||
for (i = 0; i < pbm->num_pbm_intmap; i++) {
|
||||
struct linux_prom_pci_intmap *intmap;
|
||||
@@ -714,9 +729,11 @@ fail:
|
||||
return 0;
|
||||
|
||||
success:
|
||||
printk("PCI-IRQ: Routing bus[%2x] slot[%2x] to INO[%02x]\n",
|
||||
pdev->bus->number, PCI_SLOT(pdev->devfn),
|
||||
*interrupt);
|
||||
if (pci_irq_verbose)
|
||||
printk("%s: Routing bus[%2x] slot[%2x] to INO[%02x]\n",
|
||||
pbm->name,
|
||||
pdev->bus->number, PCI_SLOT(pdev->devfn),
|
||||
*interrupt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -727,8 +744,8 @@ static void __init pdev_fixup_irq(struct pci_dev *pdev)
|
||||
struct pci_controller_info *p = pbm->parent;
|
||||
unsigned int portid = pbm->portid;
|
||||
unsigned int prom_irq;
|
||||
int prom_node = pcp->prom_node;
|
||||
int err;
|
||||
struct device_node *dp = pcp->prom_node;
|
||||
struct property *prop;
|
||||
|
||||
/* If this is an empty EBUS device, sometimes OBP fails to
|
||||
* give it a valid fully specified interrupts property.
|
||||
@@ -739,17 +756,17 @@ static void __init pdev_fixup_irq(struct pci_dev *pdev)
|
||||
*/
|
||||
if (pdev->vendor == PCI_VENDOR_ID_SUN &&
|
||||
pdev->device == PCI_DEVICE_ID_SUN_EBUS &&
|
||||
!prom_getchild(prom_node)) {
|
||||
!dp->child) {
|
||||
pdev->irq = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
err = prom_getproperty(prom_node, "interrupts",
|
||||
(char *)&prom_irq, sizeof(prom_irq));
|
||||
if (err == 0 || err == -1) {
|
||||
prop = of_find_property(dp, "interrupts", NULL);
|
||||
if (!prop) {
|
||||
pdev->irq = 0;
|
||||
return;
|
||||
}
|
||||
prom_irq = *(unsigned int *) prop->value;
|
||||
|
||||
if (tlb_type != hypervisor) {
|
||||
/* Fully specified already? */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user