sync hh.org
[hh.org.git] / arch / arm / common / via82c505.c
blobba2e62986a578da898a1ec131270e0e1353f8b8c
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>
9 #include <asm/io.h>
10 #include <asm/system.h>
12 #include <asm/mach/pci.h>
14 #define MAX_SLOTS 7
16 #define CONFIG_CMD(bus, devfn, where) (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3))
18 static int
19 via82c505_read_config(struct pci_bus *bus, unsigned int devfn, int where,
20 int size, u32 *value)
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;
34 return PCIBIOS_SUCCESSFUL;
37 static int
38 via82c505_write_config(struct pci_bus *bus, unsigned int devfn, int where,
39 int size, u32 value)
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;
53 return PCIBIOS_SUCCESSFUL;
56 static struct pci_ops via82c505_ops = {
57 .read = via82c505_read_config,
58 .write = via82c505_write_config,
61 void __init via82c505_preinit(void)
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;
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;
74 /* Enable compatible Mode */
75 outb(0x96,0xA8);
76 outb(0x18,0xA9);
77 outb(0x93,0xA8);
78 outb(0xd0,0xA9);
82 int __init via82c505_setup(int nr, struct pci_sys_data *sys)
84 return (nr == 0);
87 struct pci_bus * __init via82c505_scan_bus(int nr, struct pci_sys_data *sysdata)
89 if (nr == 0)
90 return pci_scan_bus(0, &via82c505_ops, sysdata);
92 return NULL;