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