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