blob: 1171a5010aeaa1fdf1a8c678b29d7a69936b08a9 [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
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
16static int
17via82c505_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
35static int
36via82c505_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
54static struct pci_ops via82c505_ops = {
55 .read = via82c505_read_config,
56 .write = via82c505_write_config,
57};
58
59void __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
80int __init via82c505_setup(int nr, struct pci_sys_data *sys)
81{
82 return (nr == 0);
83}
84
85struct pci_bus * __init via82c505_scan_bus(int nr, struct pci_sys_data *sysdata)
86{
87 if (nr == 0)
Bjorn Helgaas37d15902011-10-28 16:26:16 -060088 return pci_scan_root_bus(NULL, 0, &via82c505_ops, sysdata,
89 &sysdata->resources);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91 return NULL;
92}