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

Merge nuts.ninka.net:/home/davem/src/BK/sparcwork-2.5

into nuts.ninka.net:/home/davem/src/BK/sparc-2.5
parents 71380949 773f63e6
...@@ -221,7 +221,7 @@ static struct { ...@@ -221,7 +221,7 @@ static struct {
#define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \ #define PCI_NUM_CONTROLLER_TYPES (sizeof(pci_controller_table) / \
sizeof(pci_controller_table[0])) sizeof(pci_controller_table[0]))
static void pci_controller_init(char *model_name, int namelen, int node) static int pci_controller_init(char *model_name, int namelen, int node)
{ {
int i; int i;
...@@ -230,12 +230,14 @@ static void pci_controller_init(char *model_name, int namelen, int node) ...@@ -230,12 +230,14 @@ static void pci_controller_init(char *model_name, int namelen, int node)
pci_controller_table[i].model_name, pci_controller_table[i].model_name,
namelen)) { namelen)) {
pci_controller_table[i].init(node, model_name); pci_controller_table[i].init(node, model_name);
return; return 1;
} }
} }
printk("PCI: Warning unknown controller, model name [%s]\n", printk("PCI: Warning unknown controller, model name [%s]\n",
model_name); model_name);
printk("PCI: Ignoring controller...\n"); printk("PCI: Ignoring controller...\n");
return 0;
} }
static int pci_is_controller(char *model_name, int namelen, int node) static int pci_is_controller(char *model_name, int namelen, int node)
...@@ -252,37 +254,47 @@ static int pci_is_controller(char *model_name, int namelen, int node) ...@@ -252,37 +254,47 @@ static int pci_is_controller(char *model_name, int namelen, int node)
return 0; return 0;
} }
/* Is there some PCI controller in the system? */
int pcic_present(void) static int pci_controller_scan(int (*handler)(char *, int, int))
{ {
char namebuf[16]; char namebuf[64];
int node; int node;
int count = 0;
node = prom_getchild(prom_root_node); node = prom_getchild(prom_root_node);
while ((node = prom_searchsiblings(node, "pci")) != 0) { while ((node = prom_searchsiblings(node, "pci")) != 0) {
int len, ret; int len;
len = prom_getproperty(node, "model", if ((len = prom_getproperty(node, "model", namebuf, sizeof(namebuf))) > 0 ||
namebuf, sizeof(namebuf)); (len = prom_getproperty(node, "compatible", namebuf, sizeof(namebuf))) > 0) {
int item_len = 0;
ret = 0; /* Our value may be a multi-valued string in the
if (len > 0) { * case of some compatible properties. For sanity,
ret = pci_is_controller(namebuf, len, node); * only try the first one. */
} else {
len = prom_getproperty(node, "compatible", while (namebuf[item_len] && len) {
namebuf, sizeof(namebuf)); len--;
if (len > 0) item_len++;
ret = pci_is_controller(namebuf, len, node); }
if (handler(namebuf, item_len, node))
count++;
} }
if (ret)
return ret;
node = prom_getsibling(node); node = prom_getsibling(node);
if (!node) if (!node)
break; break;
} }
return 0; return count;
}
/* Is there some PCI controller in the system? */
int pcic_present(void)
{
return pci_controller_scan(pci_is_controller);
} }
/* Find each controller in the system, attach and initialize /* Find each controller in the system, attach and initialize
...@@ -292,28 +304,9 @@ int pcic_present(void) ...@@ -292,28 +304,9 @@ int pcic_present(void)
*/ */
static void pci_controller_probe(void) static void pci_controller_probe(void)
{ {
char namebuf[16];
int node;
printk("PCI: Probing for controllers.\n"); printk("PCI: Probing for controllers.\n");
node = prom_getchild(prom_root_node);
while ((node = prom_searchsiblings(node, "pci")) != 0) {
int len;
len = prom_getproperty(node, "model", pci_controller_scan(pci_controller_init);
namebuf, sizeof(namebuf));
if (len > 0)
pci_controller_init(namebuf, len, node);
else {
len = prom_getproperty(node, "compatible",
namebuf, sizeof(namebuf));
if (len > 0)
pci_controller_init(namebuf, len, node);
}
node = prom_getsibling(node);
if (!node)
break;
}
} }
static void pci_scan_each_controller_bus(void) static void pci_scan_each_controller_bus(void)
......
...@@ -334,7 +334,7 @@ static int __init sbus_init(void) ...@@ -334,7 +334,7 @@ static int __init sbus_init(void)
nd = prom_searchsiblings(topnd, "sbus"); nd = prom_searchsiblings(topnd, "sbus");
if(nd == 0) { if(nd == 0) {
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
if (pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL) == NULL) { if (!pcic_present()) {
prom_printf("Neither SBUS nor PCI found.\n"); prom_printf("Neither SBUS nor PCI found.\n");
prom_halt(); prom_halt();
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment