diff options
author | Matthew Wilcox <matthew@wil.cx> | 2008-02-10 09:45:28 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-10 15:52:46 -0500 |
commit | b6ce068a1285a24185b01be8a49021827516b3e1 (patch) | |
tree | ea1420fefff86f2e2ee4ed83f08ec2dd99a86dc5 /arch/x86 | |
parent | a0ca9909609470ad779b9b9cc68ce96e975afff7 (diff) |
Change pci_raw_ops to pci_raw_read/write
We want to allow different implementations of pci_raw_ops for standard
and extended config space on x86. Rather than clutter generic code with
knowledge of this, we make pci_raw_ops private to x86 and use it to
implement the new raw interface -- raw_pci_read() and raw_pci_write().
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/quirks.c | 2 | ||||
-rw-r--r-- | arch/x86/pci/common.c | 25 | ||||
-rw-r--r-- | arch/x86/pci/direct.c | 4 | ||||
-rw-r--r-- | arch/x86/pci/fixup.c | 6 | ||||
-rw-r--r-- | arch/x86/pci/legacy.c | 2 | ||||
-rw-r--r-- | arch/x86/pci/mmconfig-shared.c | 6 | ||||
-rw-r--r-- | arch/x86/pci/mmconfig_32.c | 10 | ||||
-rw-r--r-- | arch/x86/pci/mmconfig_64.c | 8 | ||||
-rw-r--r-- | arch/x86/pci/pci.h | 15 | ||||
-rw-r--r-- | arch/x86/pci/visws.c | 3 |
10 files changed, 48 insertions, 33 deletions
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c index 6ba33ca8715a..1941482d4ca3 100644 --- a/arch/x86/kernel/quirks.c +++ b/arch/x86/kernel/quirks.c | |||
@@ -27,7 +27,7 @@ static void __devinit quirk_intel_irqbalance(struct pci_dev *dev) | |||
27 | pci_write_config_byte(dev, 0xf4, config|0x2); | 27 | pci_write_config_byte(dev, 0xf4, config|0x2); |
28 | 28 | ||
29 | /* read xTPR register */ | 29 | /* read xTPR register */ |
30 | raw_pci_ops->read(0, 0, 0x40, 0x4c, 2, &word); | 30 | raw_pci_read(0, 0, 0x40, 0x4c, 2, &word); |
31 | 31 | ||
32 | if (!(word & (1 << 13))) { | 32 | if (!(word & (1 << 13))) { |
33 | dev_info(&dev->dev, "Intel E7520/7320/7525 detected; " | 33 | dev_info(&dev->dev, "Intel E7520/7320/7525 detected; " |
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 52deabc72a6f..b7c67a187b6b 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c | |||
@@ -26,16 +26,37 @@ int pcibios_last_bus = -1; | |||
26 | unsigned long pirq_table_addr; | 26 | unsigned long pirq_table_addr; |
27 | struct pci_bus *pci_root_bus; | 27 | struct pci_bus *pci_root_bus; |
28 | struct pci_raw_ops *raw_pci_ops; | 28 | struct pci_raw_ops *raw_pci_ops; |
29 | struct pci_raw_ops *raw_pci_ext_ops; | ||
30 | |||
31 | int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, | ||
32 | int reg, int len, u32 *val) | ||
33 | { | ||
34 | if (reg < 256 && raw_pci_ops) | ||
35 | return raw_pci_ops->read(domain, bus, devfn, reg, len, val); | ||
36 | if (raw_pci_ext_ops) | ||
37 | return raw_pci_ext_ops->read(domain, bus, devfn, reg, len, val); | ||
38 | return -EINVAL; | ||
39 | } | ||
40 | |||
41 | int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, | ||
42 | int reg, int len, u32 val) | ||
43 | { | ||
44 | if (reg < 256 && raw_pci_ops) | ||
45 | return raw_pci_ops->write(domain, bus, devfn, reg, len, val); | ||
46 | if (raw_pci_ext_ops) | ||
47 | return raw_pci_ext_ops->write(domain, bus, devfn, reg, len, val); | ||
48 | return -EINVAL; | ||
49 | } | ||
29 | 50 | ||
30 | static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) | 51 | static int pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) |
31 | { | 52 | { |
32 | return raw_pci_ops->read(pci_domain_nr(bus), bus->number, | 53 | return raw_pci_read(pci_domain_nr(bus), bus->number, |
33 | devfn, where, size, value); | 54 | devfn, where, size, value); |
34 | } | 55 | } |
35 | 56 | ||
36 | static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) | 57 | static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value) |
37 | { | 58 | { |
38 | return raw_pci_ops->write(pci_domain_nr(bus), bus->number, | 59 | return raw_pci_write(pci_domain_nr(bus), bus->number, |
39 | devfn, where, size, value); | 60 | devfn, where, size, value); |
40 | } | 61 | } |
41 | 62 | ||
diff --git a/arch/x86/pci/direct.c b/arch/x86/pci/direct.c index 431c9a51b157..42f3e4cad179 100644 --- a/arch/x86/pci/direct.c +++ b/arch/x86/pci/direct.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #define PCI_CONF1_ADDRESS(bus, devfn, reg) \ | 14 | #define PCI_CONF1_ADDRESS(bus, devfn, reg) \ |
15 | (0x80000000 | (bus << 16) | (devfn << 8) | (reg & ~3)) | 15 | (0x80000000 | (bus << 16) | (devfn << 8) | (reg & ~3)) |
16 | 16 | ||
17 | int pci_conf1_read(unsigned int seg, unsigned int bus, | 17 | static int pci_conf1_read(unsigned int seg, unsigned int bus, |
18 | unsigned int devfn, int reg, int len, u32 *value) | 18 | unsigned int devfn, int reg, int len, u32 *value) |
19 | { | 19 | { |
20 | unsigned long flags; | 20 | unsigned long flags; |
@@ -45,7 +45,7 @@ int pci_conf1_read(unsigned int seg, unsigned int bus, | |||
45 | return 0; | 45 | return 0; |
46 | } | 46 | } |
47 | 47 | ||
48 | int pci_conf1_write(unsigned int seg, unsigned int bus, | 48 | static int pci_conf1_write(unsigned int seg, unsigned int bus, |
49 | unsigned int devfn, int reg, int len, u32 value) | 49 | unsigned int devfn, int reg, int len, u32 value) |
50 | { | 50 | { |
51 | unsigned long flags; | 51 | unsigned long flags; |
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c index 74d30ff33c49..a5ef5f551373 100644 --- a/arch/x86/pci/fixup.c +++ b/arch/x86/pci/fixup.c | |||
@@ -215,7 +215,8 @@ static int quirk_aspm_offset[MAX_PCIEROOT << 3]; | |||
215 | 215 | ||
216 | static int quirk_pcie_aspm_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) | 216 | static int quirk_pcie_aspm_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) |
217 | { | 217 | { |
218 | return raw_pci_ops->read(0, bus->number, devfn, where, size, value); | 218 | return raw_pci_read(pci_domain_nr(bus), bus->number, |
219 | devfn, where, size, value); | ||
219 | } | 220 | } |
220 | 221 | ||
221 | /* | 222 | /* |
@@ -231,7 +232,8 @@ static int quirk_pcie_aspm_write(struct pci_bus *bus, unsigned int devfn, int wh | |||
231 | if ((offset) && (where == offset)) | 232 | if ((offset) && (where == offset)) |
232 | value = value & 0xfffffffc; | 233 | value = value & 0xfffffffc; |
233 | 234 | ||
234 | return raw_pci_ops->write(0, bus->number, devfn, where, size, value); | 235 | return raw_pci_write(pci_domain_nr(bus), bus->number, |
236 | devfn, where, size, value); | ||
235 | } | 237 | } |
236 | 238 | ||
237 | static struct pci_ops quirk_pcie_aspm_ops = { | 239 | static struct pci_ops quirk_pcie_aspm_ops = { |
diff --git a/arch/x86/pci/legacy.c b/arch/x86/pci/legacy.c index 5565d7016b75..e041ced0ce13 100644 --- a/arch/x86/pci/legacy.c +++ b/arch/x86/pci/legacy.c | |||
@@ -22,7 +22,7 @@ static void __devinit pcibios_fixup_peer_bridges(void) | |||
22 | if (pci_find_bus(0, n)) | 22 | if (pci_find_bus(0, n)) |
23 | continue; | 23 | continue; |
24 | for (devfn = 0; devfn < 256; devfn += 8) { | 24 | for (devfn = 0; devfn < 256; devfn += 8) { |
25 | if (!raw_pci_ops->read(0, n, devfn, PCI_VENDOR_ID, 2, &l) && | 25 | if (!raw_pci_read(0, n, devfn, PCI_VENDOR_ID, 2, &l) && |
26 | l != 0x0000 && l != 0xffff) { | 26 | l != 0x0000 && l != 0xffff) { |
27 | DBG("Found device at %02x:%02x [%04x]\n", n, devfn, l); | 27 | DBG("Found device at %02x:%02x [%04x]\n", n, devfn, l); |
28 | printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n); | 28 | printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n); |
diff --git a/arch/x86/pci/mmconfig-shared.c b/arch/x86/pci/mmconfig-shared.c index 6b521d389327..8d54df4dfaad 100644 --- a/arch/x86/pci/mmconfig-shared.c +++ b/arch/x86/pci/mmconfig-shared.c | |||
@@ -28,7 +28,7 @@ static int __initdata pci_mmcfg_resources_inserted; | |||
28 | static const char __init *pci_mmcfg_e7520(void) | 28 | static const char __init *pci_mmcfg_e7520(void) |
29 | { | 29 | { |
30 | u32 win; | 30 | u32 win; |
31 | pci_conf1_read(0, 0, PCI_DEVFN(0,0), 0xce, 2, &win); | 31 | pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0xce, 2, &win); |
32 | 32 | ||
33 | win = win & 0xf000; | 33 | win = win & 0xf000; |
34 | if(win == 0x0000 || win == 0xf000) | 34 | if(win == 0x0000 || win == 0xf000) |
@@ -53,7 +53,7 @@ static const char __init *pci_mmcfg_intel_945(void) | |||
53 | 53 | ||
54 | pci_mmcfg_config_num = 1; | 54 | pci_mmcfg_config_num = 1; |
55 | 55 | ||
56 | pci_conf1_read(0, 0, PCI_DEVFN(0,0), 0x48, 4, &pciexbar); | 56 | pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0x48, 4, &pciexbar); |
57 | 57 | ||
58 | /* Enable bit */ | 58 | /* Enable bit */ |
59 | if (!(pciexbar & 1)) | 59 | if (!(pciexbar & 1)) |
@@ -118,7 +118,7 @@ static int __init pci_mmcfg_check_hostbridge(void) | |||
118 | int i; | 118 | int i; |
119 | const char *name; | 119 | const char *name; |
120 | 120 | ||
121 | pci_conf1_read(0, 0, PCI_DEVFN(0,0), 0, 4, &l); | 121 | pci_direct_conf1.read(0, 0, PCI_DEVFN(0,0), 0, 4, &l); |
122 | vendor = l & 0xffff; | 122 | vendor = l & 0xffff; |
123 | device = (l >> 16) & 0xffff; | 123 | device = (l >> 16) & 0xffff; |
124 | 124 | ||
diff --git a/arch/x86/pci/mmconfig_32.c b/arch/x86/pci/mmconfig_32.c index 7b75e6513436..081816ada057 100644 --- a/arch/x86/pci/mmconfig_32.c +++ b/arch/x86/pci/mmconfig_32.c | |||
@@ -68,9 +68,6 @@ err: *value = -1; | |||
68 | return -EINVAL; | 68 | return -EINVAL; |
69 | } | 69 | } |
70 | 70 | ||
71 | if (reg < 256) | ||
72 | return pci_conf1_read(seg,bus,devfn,reg,len,value); | ||
73 | |||
74 | base = get_base_addr(seg, bus, devfn); | 71 | base = get_base_addr(seg, bus, devfn); |
75 | if (!base) | 72 | if (!base) |
76 | goto err; | 73 | goto err; |
@@ -104,9 +101,6 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus, | |||
104 | if ((bus > 255) || (devfn > 255) || (reg > 4095)) | 101 | if ((bus > 255) || (devfn > 255) || (reg > 4095)) |
105 | return -EINVAL; | 102 | return -EINVAL; |
106 | 103 | ||
107 | if (reg < 256) | ||
108 | return pci_conf1_write(seg,bus,devfn,reg,len,value); | ||
109 | |||
110 | base = get_base_addr(seg, bus, devfn); | 104 | base = get_base_addr(seg, bus, devfn); |
111 | if (!base) | 105 | if (!base) |
112 | return -EINVAL; | 106 | return -EINVAL; |
@@ -138,7 +132,7 @@ static struct pci_raw_ops pci_mmcfg = { | |||
138 | 132 | ||
139 | int __init pci_mmcfg_arch_init(void) | 133 | int __init pci_mmcfg_arch_init(void) |
140 | { | 134 | { |
141 | printk(KERN_INFO "PCI: Using MMCONFIG\n"); | 135 | printk(KERN_INFO "PCI: Using MMCONFIG for extended config space\n"); |
142 | raw_pci_ops = &pci_mmcfg; | 136 | raw_pci_ext_ops = &pci_mmcfg; |
143 | return 1; | 137 | return 1; |
144 | } | 138 | } |
diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c index c4cf318e44a9..9207fd49233c 100644 --- a/arch/x86/pci/mmconfig_64.c +++ b/arch/x86/pci/mmconfig_64.c | |||
@@ -58,9 +58,6 @@ err: *value = -1; | |||
58 | return -EINVAL; | 58 | return -EINVAL; |
59 | } | 59 | } |
60 | 60 | ||
61 | if (reg < 256) | ||
62 | return pci_conf1_read(seg,bus,devfn,reg,len,value); | ||
63 | |||
64 | addr = pci_dev_base(seg, bus, devfn); | 61 | addr = pci_dev_base(seg, bus, devfn); |
65 | if (!addr) | 62 | if (!addr) |
66 | goto err; | 63 | goto err; |
@@ -89,9 +86,6 @@ static int pci_mmcfg_write(unsigned int seg, unsigned int bus, | |||
89 | if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) | 86 | if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) |
90 | return -EINVAL; | 87 | return -EINVAL; |
91 | 88 | ||
92 | if (reg < 256) | ||
93 | return pci_conf1_write(seg,bus,devfn,reg,len,value); | ||
94 | |||
95 | addr = pci_dev_base(seg, bus, devfn); | 89 | addr = pci_dev_base(seg, bus, devfn); |
96 | if (!addr) | 90 | if (!addr) |
97 | return -EINVAL; | 91 | return -EINVAL; |
@@ -150,6 +144,6 @@ int __init pci_mmcfg_arch_init(void) | |||
150 | return 0; | 144 | return 0; |
151 | } | 145 | } |
152 | } | 146 | } |
153 | raw_pci_ops = &pci_mmcfg; | 147 | raw_pci_ext_ops = &pci_mmcfg; |
154 | return 1; | 148 | return 1; |
155 | } | 149 | } |
diff --git a/arch/x86/pci/pci.h b/arch/x86/pci/pci.h index 36cb44c397c3..3431518d921a 100644 --- a/arch/x86/pci/pci.h +++ b/arch/x86/pci/pci.h | |||
@@ -85,10 +85,17 @@ extern spinlock_t pci_config_lock; | |||
85 | extern int (*pcibios_enable_irq)(struct pci_dev *dev); | 85 | extern int (*pcibios_enable_irq)(struct pci_dev *dev); |
86 | extern void (*pcibios_disable_irq)(struct pci_dev *dev); | 86 | extern void (*pcibios_disable_irq)(struct pci_dev *dev); |
87 | 87 | ||
88 | extern int pci_conf1_write(unsigned int seg, unsigned int bus, | 88 | struct pci_raw_ops { |
89 | unsigned int devfn, int reg, int len, u32 value); | 89 | int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn, |
90 | extern int pci_conf1_read(unsigned int seg, unsigned int bus, | 90 | int reg, int len, u32 *val); |
91 | unsigned int devfn, int reg, int len, u32 *value); | 91 | int (*write)(unsigned int domain, unsigned int bus, unsigned int devfn, |
92 | int reg, int len, u32 val); | ||
93 | }; | ||
94 | |||
95 | extern struct pci_raw_ops *raw_pci_ops; | ||
96 | extern struct pci_raw_ops *raw_pci_ext_ops; | ||
97 | |||
98 | extern struct pci_raw_ops pci_direct_conf1; | ||
92 | 99 | ||
93 | extern int pci_direct_probe(void); | 100 | extern int pci_direct_probe(void); |
94 | extern void pci_direct_init(int type); | 101 | extern void pci_direct_init(int type); |
diff --git a/arch/x86/pci/visws.c b/arch/x86/pci/visws.c index 8ecb1c722594..c2df4e97eed6 100644 --- a/arch/x86/pci/visws.c +++ b/arch/x86/pci/visws.c | |||
@@ -13,9 +13,6 @@ | |||
13 | 13 | ||
14 | #include "pci.h" | 14 | #include "pci.h" |
15 | 15 | ||
16 | |||
17 | extern struct pci_raw_ops pci_direct_conf1; | ||
18 | |||
19 | static int pci_visws_enable_irq(struct pci_dev *dev) { return 0; } | 16 | static int pci_visws_enable_irq(struct pci_dev *dev) { return 0; } |
20 | static void pci_visws_disable_irq(struct pci_dev *dev) { } | 17 | static void pci_visws_disable_irq(struct pci_dev *dev) { } |
21 | 18 | ||