patch-2.1.79 linux/arch/ppc/kernel/pci.c
Next file: linux/arch/ppc/kernel/pmac_pci.c
Previous file: linux/arch/ppc/kernel/openpic.c
Back to the patch index
Back to the overall index
- Lines: 251
- Date:
Mon Jan 12 15:18:13 1998
- Orig file:
v2.1.78/linux/arch/ppc/kernel/pci.c
- Orig date:
Thu Sep 4 17:07:29 1997
diff -u --recursive --new-file v2.1.78/linux/arch/ppc/kernel/pci.c linux/arch/ppc/kernel/pci.c
@@ -1,22 +1,27 @@
/*
- * $Id: pci.c,v 1.12 1997/08/27 05:05:28 cort Exp $
+ * $Id: pci.c,v 1.18 1997/10/29 03:35:07 cort Exp $
* Common pmac/prep/chrp pci routines. -- Cort
*/
#include <linux/kernel.h>
#include <linux/pci.h>
-/*#include <linux/bios32.h>*/
+#include <linux/bios32.h>
#include <linux/delay.h>
#include <linux/string.h>
#include <linux/init.h>
+#include <linux/config.h>
+#include <linux/pci.h>
#include <asm/processor.h>
#include <asm/io.h>
#include <asm/prom.h>
#include <asm/pci-bridge.h>
-unsigned long io_base;
+#if !defined(CONFIG_MACH_SPECIFIC)
+unsigned long isa_io_base;
+unsigned long isa_mem_base;
unsigned long pci_dram_offset;
+#endif /* CONFIG_MACH_SPECIFIC */
/*
* It would be nice if we could create a include/asm/pci.h and have just
@@ -29,77 +34,56 @@
* -- Cort
*/
int (*ptr_pcibios_read_config_byte)(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned char *val);
+ unsigned char offset, unsigned char *val);
int (*ptr_pcibios_read_config_word)(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned short *val);
+ unsigned char offset, unsigned short *val);
int (*ptr_pcibios_read_config_dword)(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned int *val);
+ unsigned char offset, unsigned int *val);
int (*ptr_pcibios_write_config_byte)(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned char val);
+ unsigned char offset, unsigned char val);
int (*ptr_pcibios_write_config_word)(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned short val);
+ unsigned char offset, unsigned short val);
int (*ptr_pcibios_write_config_dword)(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned int val);
-int (*ptr_pcibios_find_device)(unsigned short vendor, unsigned short dev_id,
- unsigned short index, unsigned char *bus_ptr,
- unsigned char *dev_fn_ptr);
-int (*ptr_pcibios_find_class)(unsigned int class_code, unsigned short index,
- unsigned char *bus_ptr, unsigned char *dev_fn_ptr);
+ unsigned char offset, unsigned int val);
extern int pmac_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned char *val);
+ unsigned char offset, unsigned char *val);
extern int pmac_pcibios_read_config_word(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned short *val);
+ unsigned char offset, unsigned short *val);
extern int pmac_pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned int *val);
+ unsigned char offset, unsigned int *val);
extern int pmac_pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned char val);
+ unsigned char offset, unsigned char val);
extern int pmac_pcibios_write_config_word(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned short val);
+ unsigned char offset, unsigned short val);
extern int pmac_pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned int val);
-extern int pmac_pcibios_find_device(unsigned short vendor, unsigned short dev_id,
- unsigned short index, unsigned char *bus_ptr,
- unsigned char *dev_fn_ptr);
-extern int pmac_pcibios_find_class(unsigned int class_code, unsigned short index,
- unsigned char *bus_ptr, unsigned char *dev_fn_ptr);
+ unsigned char offset, unsigned int val);
extern int chrp_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned char *val);
+ unsigned char offset, unsigned char *val);
extern int chrp_pcibios_read_config_word(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned short *val);
+ unsigned char offset, unsigned short *val);
extern int chrp_pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned int *val);
+ unsigned char offset, unsigned int *val);
extern int chrp_pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned char val);
+ unsigned char offset, unsigned char val);
extern int chrp_pcibios_write_config_word(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned short val);
+ unsigned char offset, unsigned short val);
extern int chrp_pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned int val);
-extern int chrp_pcibios_find_device(unsigned short vendor, unsigned short dev_id,
- unsigned short index, unsigned char *bus_ptr,
- unsigned char *dev_fn_ptr);
-extern int chrp_pcibios_find_class(unsigned int class_code, unsigned short index,
- unsigned char *bus_ptr, unsigned char *dev_fn_ptr);
+ unsigned char offset, unsigned int val);
extern int prep_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned char *val);
+ unsigned char offset, unsigned char *val);
extern int prep_pcibios_read_config_word(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned short *val);
+ unsigned char offset, unsigned short *val);
extern int prep_pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned int *val);
+ unsigned char offset, unsigned int *val);
extern int prep_pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned char val);
+ unsigned char offset, unsigned char val);
extern int prep_pcibios_write_config_word(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned short val);
+ unsigned char offset, unsigned short val);
extern int prep_pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn,
- unsigned char offset, unsigned int val);
-extern int prep_pcibios_find_device(unsigned short vendor, unsigned short dev_id,
- unsigned short index, unsigned char *bus_ptr,
- unsigned char *dev_fn_ptr);
-extern int prep_pcibios_find_class(unsigned int class_code, unsigned short index,
- unsigned char *bus_ptr, unsigned char *dev_fn_ptr);
-
+ unsigned char offset, unsigned int val);
int pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn,
unsigned char offset, unsigned char *val)
@@ -131,64 +115,94 @@
{
return ptr_pcibios_write_config_dword(bus,dev_fn,offset,val);
}
-int pcibios_find_device(unsigned short vendor, unsigned short dev_id,
- unsigned short index, unsigned char *bus_ptr,
- unsigned char *dev_fn_ptr)
+
+int pcibios_present(void)
{
- return ptr_pcibios_find_device(vendor,dev_id,index,bus_ptr,dev_fn_ptr);
+ return 1;
}
-int pcibios_find_class(unsigned int class_code, unsigned short index,
- unsigned char *bus_ptr, unsigned char *dev_fn_ptr)
-{
- return ptr_pcibios_find_class(class_code,index,bus_ptr,dev_fn_ptr);
+
+int pcibios_find_device (unsigned short vendor, unsigned short device_id,
+ unsigned short index, unsigned char *bus,
+ unsigned char *devfn)
+{
+ unsigned int curr = 0;
+ struct pci_dev *dev;
+ for (dev = pci_devices; dev; dev = dev->next) {
+ if (dev->vendor == vendor && dev->device == device_id) {
+ if (curr == index) {
+ *devfn = dev->devfn;
+ *bus = dev->bus->number;
+ return PCIBIOS_SUCCESSFUL;
+ }
+ ++curr;
+ }
+ }
+ return PCIBIOS_DEVICE_NOT_FOUND;
}
-int pcibios_present(void)
+/*
+ * Given the class, find the n'th instance of that device
+ * in the system.
+ */
+int pcibios_find_class (unsigned int class_code, unsigned short index,
+ unsigned char *bus, unsigned char *devfn)
{
- return 1;
+ unsigned int curr = 0;
+ struct pci_dev *dev;
+
+ for (dev = pci_devices; dev; dev = dev->next) {
+ if (dev->class == class_code) {
+ if (curr == index) {
+ *devfn = dev->devfn;
+ *bus = dev->bus->number;
+ return PCIBIOS_SUCCESSFUL;
+ }
+ ++curr;
+ }
+ }
+ return PCIBIOS_DEVICE_NOT_FOUND;
}
+
__initfunc(unsigned long
-pcibios_init(unsigned long mem_start,unsigned long mem_end))
+ pcibios_init(unsigned long mem_start,unsigned long mem_end))
+{
+ return mem_start;
+}
+
+__initfunc(void
+ setup_pci_ptrs(void))
{
switch (_machine) {
- case _MACH_Motorola:
- case _MACH_IBM:
+ case _MACH_prep:
ptr_pcibios_read_config_byte = prep_pcibios_read_config_byte;
ptr_pcibios_read_config_word = prep_pcibios_read_config_word;
ptr_pcibios_read_config_dword = prep_pcibios_read_config_dword;
ptr_pcibios_write_config_byte = prep_pcibios_write_config_byte;
ptr_pcibios_write_config_word = prep_pcibios_write_config_word;
ptr_pcibios_write_config_dword = prep_pcibios_write_config_dword;
- ptr_pcibios_find_device = prep_pcibios_find_device;
- ptr_pcibios_find_class = prep_pcibios_find_class;
break;
- case _MACH_Pmac:
+ case _MACH_Pmac:
ptr_pcibios_read_config_byte = pmac_pcibios_read_config_byte;
ptr_pcibios_read_config_word = pmac_pcibios_read_config_word;
ptr_pcibios_read_config_dword = pmac_pcibios_read_config_dword;
ptr_pcibios_write_config_byte = pmac_pcibios_write_config_byte;
ptr_pcibios_write_config_word = pmac_pcibios_write_config_word;
ptr_pcibios_write_config_dword = pmac_pcibios_write_config_dword;
- ptr_pcibios_find_device = pmac_pcibios_find_device;
- ptr_pcibios_find_class = pmac_pcibios_find_class;
break;
- case _MACH_chrp:
+ case _MACH_chrp:
ptr_pcibios_read_config_byte = chrp_pcibios_read_config_byte;
ptr_pcibios_read_config_word = chrp_pcibios_read_config_word;
ptr_pcibios_read_config_dword = chrp_pcibios_read_config_dword;
ptr_pcibios_write_config_byte = chrp_pcibios_write_config_byte;
ptr_pcibios_write_config_word = chrp_pcibios_write_config_word;
ptr_pcibios_write_config_dword = chrp_pcibios_write_config_dword;
- ptr_pcibios_find_device = chrp_pcibios_find_device;
- ptr_pcibios_find_class = chrp_pcibios_find_class;
break;
}
- return mem_start;
}
__initfunc(unsigned long
-pcibios_fixup(unsigned long mem_start, unsigned long mem_end))
+ pcibios_fixup(unsigned long mem_start, unsigned long mem_end))
{
return mem_start;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov