Pull thermal into release branch
[linux-drm-fsl-dcu.git] / arch / arm / common / via82c505.c
1 #include <linux/kernel.h>
2 #include <linux/pci.h>
3 #include <linux/interrupt.h>
4 #include <linux/mm.h>
5 #include <linux/init.h>
6 #include <linux/ioport.h>
7
8 #include <asm/io.h>
9 #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
17 static int
18 via82c505_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
36 static int
37 via82c505_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
55 static struct pci_ops via82c505_ops = {
56         .read   = via82c505_read_config,
57         .write  = via82c505_write_config,
58 };
59
60 void __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
81 int __init via82c505_setup(int nr, struct pci_sys_data *sys)
82 {
83         return (nr == 0);
84 }
85
86 struct pci_bus * __init via82c505_scan_bus(int nr, struct pci_sys_data *sysdata)
87 {
88         if (nr == 0)
89                 return pci_scan_bus(0, &via82c505_ops, sysdata);
90
91         return NULL;
92 }