Take into account the size of the interrupt cell. It's determined

by the parent for interrupt resources. This corrects parsing of
the interrupts property.

With parsing of the property fixed, add all interrupts to the
resource list. Bump the max. number of interrupts from 5 to 6
as scc(4) attached to macio(4) has 6 interrupts (3 per channel).

Submitted by: Nathan Whitehorn <nathanw@uchicago.edu>
This commit is contained in:
Marcel Moolenaar 2008-04-26 18:35:44 +00:00
parent 324eb73387
commit 4924db935d
2 changed files with 27 additions and 14 deletions

View File

@ -179,27 +179,40 @@ macio_get_quirks(const char *name)
static void
macio_add_intr(phandle_t devnode, struct macio_devinfo *dinfo)
{
int intr;
int *intr;
int i, nintr;
phandle_t iparent;
int icells;
if (dinfo->mdi_ninterrupts >= 5) {
printf("macio: device has more than 5 interrupts\n");
if (dinfo->mdi_ninterrupts >= 6) {
printf("macio: device has more than 6 interrupts\n");
return;
}
if (OF_getprop(devnode, "interrupts", &intr, sizeof(intr)) == -1) {
if (OF_getprop(devnode, "AAPL,interrupts", &intr,
sizeof(intr)) == -1)
icells = 1;
if (OF_getprop(devnode, "interrupt-parent", &iparent, sizeof(iparent)) == sizeof(iparent))
OF_getprop(iparent, "#interrupt-cells", &icells, sizeof(icells));
nintr = OF_getprop_alloc(devnode, "interrupts", sizeof(*intr),
(void **)&intr);
if (nintr == -1) {
nintr = OF_getprop_alloc(devnode, "AAPL,interrupts",
sizeof(*intr), (void **)&intr);
if (nintr == -1)
return;
}
if (intr == -1)
if (intr[0] == -1)
return;
resource_list_add(&dinfo->mdi_resources, SYS_RES_IRQ,
dinfo->mdi_ninterrupts, intr, intr, 1);
for (i = 0; i < nintr; i+=icells) {
resource_list_add(&dinfo->mdi_resources, SYS_RES_IRQ,
dinfo->mdi_ninterrupts, intr[i], intr[i], 1);
dinfo->mdi_interrupts[dinfo->mdi_ninterrupts] = intr;
dinfo->mdi_ninterrupts++;
dinfo->mdi_interrupts[dinfo->mdi_ninterrupts] = intr[i];
dinfo->mdi_ninterrupts++;
}
}
@ -413,9 +426,9 @@ macio_alloc_resource(device_t bus, device_t child, int type, int *rid,
rle = resource_list_find(&dinfo->mdi_resources, SYS_RES_IRQ,
*rid);
if (rle == NULL) {
if (dinfo->mdi_ninterrupts >= 5) {
if (dinfo->mdi_ninterrupts >= 6) {
device_printf(bus,
"%s has more than 5 interrupts\n",
"%s has more than 6 interrupts\n",
device_get_nameunit(child));
return (NULL);
}

View File

@ -49,7 +49,7 @@ struct macio_reg {
* Per macio device structure.
*/
struct macio_devinfo {
int mdi_interrupts[5];
int mdi_interrupts[6];
int mdi_ninterrupts;
int mdi_base;
struct ofw_bus_devinfo mdi_obdinfo;