Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/pci.h> |
| 3 | #include <linux/ptrace.h> |
| 4 | #include <linux/interrupt.h> |
| 5 | #include <linux/mm.h> |
| 6 | #include <linux/init.h> |
| 7 | #include <linux/ioport.h> |
| 8 | |
| 9 | #include <asm/io.h> |
| 10 | #include <asm/system.h> |
| 11 | |
| 12 | #include <asm/mach/pci.h> |
| 13 | |
| 14 | #define MAX_SLOTS 7 |
| 15 | |
| 16 | #define CONFIG_CMD(bus, devfn, where) (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3)) |
| 17 | |
| 18 | static int |
| 19 | via82c505_read_config(struct pci_bus *bus, unsigned int devfn, int where, |
| 20 | int size, u32 *value) |
| 21 | { |
| 22 | outl(CONFIG_CMD(bus,devfn,where),0xCF8); |
| 23 | switch (size) { |
| 24 | case 1: |
| 25 | *value=inb(0xCFC + (where&3)); |
| 26 | break; |
| 27 | case 2: |
| 28 | *value=inw(0xCFC + (where&2)); |
| 29 | break; |
| 30 | case 4: |
| 31 | *value=inl(0xCFC); |
| 32 | break; |
| 33 | } |
| 34 | return PCIBIOS_SUCCESSFUL; |
| 35 | } |
| 36 | |
| 37 | static int |
| 38 | via82c505_write_config(struct pci_bus *bus, unsigned int devfn, int where, |
| 39 | int size, u32 value) |
| 40 | { |
| 41 | outl(CONFIG_CMD(bus,devfn,where),0xCF8); |
| 42 | switch (size) { |
| 43 | case 1: |
| 44 | outb(value, 0xCFC + (where&3)); |
| 45 | break; |
| 46 | case 2: |
| 47 | outw(value, 0xCFC + (where&2)); |
| 48 | break; |
| 49 | case 4: |
| 50 | outl(value, 0xCFC); |
| 51 | break; |
| 52 | } |
| 53 | return PCIBIOS_SUCCESSFUL; |
| 54 | } |
| 55 | |
| 56 | static struct pci_ops via82c505_ops = { |
| 57 | .read = via82c505_read_config, |
| 58 | .write = via82c505_write_config, |
| 59 | }; |
| 60 | |
| 61 | void __init via82c505_preinit(void) |
| 62 | { |
| 63 | printk(KERN_DEBUG "PCI: VIA 82c505\n"); |
| 64 | if (!request_region(0xA8,2,"via config")) { |
| 65 | printk(KERN_WARNING"VIA 82c505: Unable to request region 0xA8\n"); |
| 66 | return; |
| 67 | } |
| 68 | if (!request_region(0xCF8,8,"pci config")) { |
| 69 | printk(KERN_WARNING"VIA 82c505: Unable to request region 0xCF8\n"); |
| 70 | release_region(0xA8, 2); |
| 71 | return; |
| 72 | } |
| 73 | |
| 74 | /* Enable compatible Mode */ |
| 75 | outb(0x96,0xA8); |
| 76 | outb(0x18,0xA9); |
| 77 | outb(0x93,0xA8); |
| 78 | outb(0xd0,0xA9); |
| 79 | |
| 80 | } |
| 81 | |
| 82 | int __init via82c505_setup(int nr, struct pci_sys_data *sys) |
| 83 | { |
| 84 | return (nr == 0); |
| 85 | } |
| 86 | |
| 87 | struct pci_bus * __init via82c505_scan_bus(int nr, struct pci_sys_data *sysdata) |
| 88 | { |
| 89 | if (nr == 0) |
| 90 | return pci_scan_bus(0, &via82c505_ops, sysdata); |
| 91 | |
| 92 | return NULL; |
| 93 | } |