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