Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
via82c505.c
Go to the documentation of this file.
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 #include <linux/io.h>
8 
9 
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 
16 static int
17 via82c505_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 
35 static int
36 via82c505_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 
55  .read = via82c505_read_config,
56  .write = via82c505_write_config,
57 };
58 
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 
81 {
82  return (nr == 0);
83 }