diff options
author | Michael Ellerman <michael@ozlabs.org> | 2011-04-11 17:25:01 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-04-27 00:18:29 -0400 |
commit | 3cc30d0726d258ac336283bcde66a8ab58283b61 (patch) | |
tree | d0b6664707f2d6ee5b5a008af1c2810d5ba1390c /arch/powerpc/platforms/cell | |
parent | 21176fed25c3b0cb17c6c42d71b4e3d68b8f9dd4 (diff) |
powerpc/pci: Move IO workarounds to the common kernel dir
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/platforms/cell')
-rw-r--r-- | arch/powerpc/platforms/cell/Kconfig | 1 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/Makefile | 8 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/celleb_pci.c | 1 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/celleb_pci.h | 3 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/io-workarounds.c | 185 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/io-workarounds.h | 49 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/qpace_setup.c | 1 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/setup.c | 2 | ||||
-rw-r--r-- | arch/powerpc/platforms/cell/spider-pci.c | 3 |
9 files changed, 9 insertions, 244 deletions
diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig index 3c7f1de06cdf..67d5009b4e86 100644 --- a/arch/powerpc/platforms/cell/Kconfig +++ b/arch/powerpc/platforms/cell/Kconfig | |||
@@ -16,6 +16,7 @@ config PPC_CELL_NATIVE | |||
16 | bool | 16 | bool |
17 | select PPC_CELL_COMMON | 17 | select PPC_CELL_COMMON |
18 | select MPIC | 18 | select MPIC |
19 | select PPC_IO_WORKAROUNDS | ||
19 | select IBM_NEW_EMAC_EMAC4 | 20 | select IBM_NEW_EMAC_EMAC4 |
20 | select IBM_NEW_EMAC_RGMII | 21 | select IBM_NEW_EMAC_RGMII |
21 | select IBM_NEW_EMAC_ZMII #test only | 22 | select IBM_NEW_EMAC_ZMII #test only |
diff --git a/arch/powerpc/platforms/cell/Makefile b/arch/powerpc/platforms/cell/Makefile index 83fafe922641..8839ef6c7188 100644 --- a/arch/powerpc/platforms/cell/Makefile +++ b/arch/powerpc/platforms/cell/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | obj-$(CONFIG_PPC_CELL_COMMON) += cbe_regs.o interrupt.o pervasive.o | 1 | obj-$(CONFIG_PPC_CELL_COMMON) += cbe_regs.o interrupt.o pervasive.o |
2 | 2 | ||
3 | obj-$(CONFIG_PPC_CELL_NATIVE) += iommu.o setup.o spider-pic.o \ | 3 | obj-$(CONFIG_PPC_CELL_NATIVE) += iommu.o setup.o spider-pic.o \ |
4 | pmu.o io-workarounds.o spider-pci.o | 4 | pmu.o spider-pci.o |
5 | obj-$(CONFIG_CBE_RAS) += ras.o | 5 | obj-$(CONFIG_CBE_RAS) += ras.o |
6 | 6 | ||
7 | obj-$(CONFIG_CBE_THERM) += cbe_thermal.o | 7 | obj-$(CONFIG_CBE_THERM) += cbe_thermal.o |
@@ -39,9 +39,9 @@ obj-y += celleb_setup.o \ | |||
39 | celleb_pci.o celleb_scc_epci.o \ | 39 | celleb_pci.o celleb_scc_epci.o \ |
40 | celleb_scc_pciex.o \ | 40 | celleb_scc_pciex.o \ |
41 | celleb_scc_uhc.o \ | 41 | celleb_scc_uhc.o \ |
42 | io-workarounds.o spider-pci.o \ | 42 | spider-pci.o beat.o beat_htab.o \ |
43 | beat.o beat_htab.o beat_hvCall.o \ | 43 | beat_hvCall.o beat_interrupt.o \ |
44 | beat_interrupt.o beat_iommu.o | 44 | beat_iommu.o |
45 | 45 | ||
46 | obj-$(CONFIG_SMP) += beat_smp.o | 46 | obj-$(CONFIG_SMP) += beat_smp.o |
47 | obj-$(CONFIG_PPC_UDBG_BEAT) += beat_udbg.o | 47 | obj-$(CONFIG_PPC_UDBG_BEAT) += beat_udbg.o |
diff --git a/arch/powerpc/platforms/cell/celleb_pci.c b/arch/powerpc/platforms/cell/celleb_pci.c index 404d1fc04d59..c19b783a7c99 100644 --- a/arch/powerpc/platforms/cell/celleb_pci.c +++ b/arch/powerpc/platforms/cell/celleb_pci.c | |||
@@ -41,7 +41,6 @@ | |||
41 | #include <asm/pci-bridge.h> | 41 | #include <asm/pci-bridge.h> |
42 | #include <asm/ppc-pci.h> | 42 | #include <asm/ppc-pci.h> |
43 | 43 | ||
44 | #include "io-workarounds.h" | ||
45 | #include "celleb_pci.h" | 44 | #include "celleb_pci.h" |
46 | 45 | ||
47 | #define MAX_PCI_DEVICES 32 | 46 | #define MAX_PCI_DEVICES 32 |
diff --git a/arch/powerpc/platforms/cell/celleb_pci.h b/arch/powerpc/platforms/cell/celleb_pci.h index 4cba1523ec50..a801fcc5f389 100644 --- a/arch/powerpc/platforms/cell/celleb_pci.h +++ b/arch/powerpc/platforms/cell/celleb_pci.h | |||
@@ -26,8 +26,9 @@ | |||
26 | #include <asm/pci-bridge.h> | 26 | #include <asm/pci-bridge.h> |
27 | #include <asm/prom.h> | 27 | #include <asm/prom.h> |
28 | #include <asm/ppc-pci.h> | 28 | #include <asm/ppc-pci.h> |
29 | #include <asm/io-workarounds.h> | ||
29 | 30 | ||
30 | #include "io-workarounds.h" | 31 | struct iowa_bus; |
31 | 32 | ||
32 | struct celleb_phb_spec { | 33 | struct celleb_phb_spec { |
33 | int (*setup)(struct device_node *, struct pci_controller *); | 34 | int (*setup)(struct device_node *, struct pci_controller *); |
diff --git a/arch/powerpc/platforms/cell/io-workarounds.c b/arch/powerpc/platforms/cell/io-workarounds.c deleted file mode 100644 index 5c1118e31940..000000000000 --- a/arch/powerpc/platforms/cell/io-workarounds.c +++ /dev/null | |||
@@ -1,185 +0,0 @@ | |||
1 | /* | ||
2 | * Support PCI IO workaround | ||
3 | * | ||
4 | * Copyright (C) 2006 Benjamin Herrenschmidt <benh@kernel.crashing.org> | ||
5 | * IBM, Corp. | ||
6 | * (C) Copyright 2007-2008 TOSHIBA CORPORATION | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | #undef DEBUG | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | |||
16 | #include <asm/io.h> | ||
17 | #include <asm/machdep.h> | ||
18 | #include <asm/pgtable.h> | ||
19 | #include <asm/ppc-pci.h> | ||
20 | |||
21 | #include "io-workarounds.h" | ||
22 | |||
23 | #define IOWA_MAX_BUS 8 | ||
24 | |||
25 | static struct iowa_bus iowa_busses[IOWA_MAX_BUS]; | ||
26 | static unsigned int iowa_bus_count; | ||
27 | |||
28 | static struct iowa_bus *iowa_pci_find(unsigned long vaddr, unsigned long paddr) | ||
29 | { | ||
30 | int i, j; | ||
31 | struct resource *res; | ||
32 | unsigned long vstart, vend; | ||
33 | |||
34 | for (i = 0; i < iowa_bus_count; i++) { | ||
35 | struct iowa_bus *bus = &iowa_busses[i]; | ||
36 | struct pci_controller *phb = bus->phb; | ||
37 | |||
38 | if (vaddr) { | ||
39 | vstart = (unsigned long)phb->io_base_virt; | ||
40 | vend = vstart + phb->pci_io_size - 1; | ||
41 | if ((vaddr >= vstart) && (vaddr <= vend)) | ||
42 | return bus; | ||
43 | } | ||
44 | |||
45 | if (paddr) | ||
46 | for (j = 0; j < 3; j++) { | ||
47 | res = &phb->mem_resources[j]; | ||
48 | if (paddr >= res->start && paddr <= res->end) | ||
49 | return bus; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | return NULL; | ||
54 | } | ||
55 | |||
56 | struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr) | ||
57 | { | ||
58 | struct iowa_bus *bus; | ||
59 | int token; | ||
60 | |||
61 | token = PCI_GET_ADDR_TOKEN(addr); | ||
62 | |||
63 | if (token && token <= iowa_bus_count) | ||
64 | bus = &iowa_busses[token - 1]; | ||
65 | else { | ||
66 | unsigned long vaddr, paddr; | ||
67 | pte_t *ptep; | ||
68 | |||
69 | vaddr = (unsigned long)PCI_FIX_ADDR(addr); | ||
70 | if (vaddr < PHB_IO_BASE || vaddr >= PHB_IO_END) | ||
71 | return NULL; | ||
72 | |||
73 | ptep = find_linux_pte(init_mm.pgd, vaddr); | ||
74 | if (ptep == NULL) | ||
75 | paddr = 0; | ||
76 | else | ||
77 | paddr = pte_pfn(*ptep) << PAGE_SHIFT; | ||
78 | bus = iowa_pci_find(vaddr, paddr); | ||
79 | |||
80 | if (bus == NULL) | ||
81 | return NULL; | ||
82 | } | ||
83 | |||
84 | return bus; | ||
85 | } | ||
86 | |||
87 | struct iowa_bus *iowa_pio_find_bus(unsigned long port) | ||
88 | { | ||
89 | unsigned long vaddr = (unsigned long)pci_io_base + port; | ||
90 | return iowa_pci_find(vaddr, 0); | ||
91 | } | ||
92 | |||
93 | |||
94 | #define DEF_PCI_AC_RET(name, ret, at, al, space, aa) \ | ||
95 | static ret iowa_##name at \ | ||
96 | { \ | ||
97 | struct iowa_bus *bus; \ | ||
98 | bus = iowa_##space##_find_bus(aa); \ | ||
99 | if (bus && bus->ops && bus->ops->name) \ | ||
100 | return bus->ops->name al; \ | ||
101 | return __do_##name al; \ | ||
102 | } | ||
103 | |||
104 | #define DEF_PCI_AC_NORET(name, at, al, space, aa) \ | ||
105 | static void iowa_##name at \ | ||
106 | { \ | ||
107 | struct iowa_bus *bus; \ | ||
108 | bus = iowa_##space##_find_bus(aa); \ | ||
109 | if (bus && bus->ops && bus->ops->name) { \ | ||
110 | bus->ops->name al; \ | ||
111 | return; \ | ||
112 | } \ | ||
113 | __do_##name al; \ | ||
114 | } | ||
115 | |||
116 | #include <asm/io-defs.h> | ||
117 | |||
118 | #undef DEF_PCI_AC_RET | ||
119 | #undef DEF_PCI_AC_NORET | ||
120 | |||
121 | static const struct ppc_pci_io __devinitconst iowa_pci_io = { | ||
122 | |||
123 | #define DEF_PCI_AC_RET(name, ret, at, al, space, aa) .name = iowa_##name, | ||
124 | #define DEF_PCI_AC_NORET(name, at, al, space, aa) .name = iowa_##name, | ||
125 | |||
126 | #include <asm/io-defs.h> | ||
127 | |||
128 | #undef DEF_PCI_AC_RET | ||
129 | #undef DEF_PCI_AC_NORET | ||
130 | |||
131 | }; | ||
132 | |||
133 | static void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size, | ||
134 | unsigned long flags, void *caller) | ||
135 | { | ||
136 | struct iowa_bus *bus; | ||
137 | void __iomem *res = __ioremap_caller(addr, size, flags, caller); | ||
138 | int busno; | ||
139 | |||
140 | bus = iowa_pci_find(0, (unsigned long)addr); | ||
141 | if (bus != NULL) { | ||
142 | busno = bus - iowa_busses; | ||
143 | PCI_SET_ADDR_TOKEN(res, busno + 1); | ||
144 | } | ||
145 | return res; | ||
146 | } | ||
147 | |||
148 | /* Regist new bus to support workaround */ | ||
149 | void __devinit iowa_register_bus(struct pci_controller *phb, | ||
150 | struct ppc_pci_io *ops, | ||
151 | int (*initfunc)(struct iowa_bus *, void *), void *data) | ||
152 | { | ||
153 | struct iowa_bus *bus; | ||
154 | struct device_node *np = phb->dn; | ||
155 | |||
156 | if (iowa_bus_count >= IOWA_MAX_BUS) { | ||
157 | pr_err("IOWA:Too many pci bridges, " | ||
158 | "workarounds disabled for %s\n", np->full_name); | ||
159 | return; | ||
160 | } | ||
161 | |||
162 | bus = &iowa_busses[iowa_bus_count]; | ||
163 | bus->phb = phb; | ||
164 | bus->ops = ops; | ||
165 | |||
166 | if (initfunc) | ||
167 | if ((*initfunc)(bus, data)) | ||
168 | return; | ||
169 | |||
170 | iowa_bus_count++; | ||
171 | |||
172 | pr_debug("IOWA:[%d]Add bus, %s.\n", iowa_bus_count-1, np->full_name); | ||
173 | } | ||
174 | |||
175 | /* enable IO workaround */ | ||
176 | void __devinit io_workaround_init(void) | ||
177 | { | ||
178 | static int io_workaround_inited; | ||
179 | |||
180 | if (io_workaround_inited) | ||
181 | return; | ||
182 | ppc_pci_io = iowa_pci_io; | ||
183 | ppc_md.ioremap = iowa_ioremap; | ||
184 | io_workaround_inited = 1; | ||
185 | } | ||
diff --git a/arch/powerpc/platforms/cell/io-workarounds.h b/arch/powerpc/platforms/cell/io-workarounds.h deleted file mode 100644 index 6efc7782ebf2..000000000000 --- a/arch/powerpc/platforms/cell/io-workarounds.h +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /* | ||
2 | * Support PCI IO workaround | ||
3 | * | ||
4 | * (C) Copyright 2007-2008 TOSHIBA CORPORATION | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef _IO_WORKAROUNDS_H | ||
22 | #define _IO_WORKAROUNDS_H | ||
23 | |||
24 | #include <linux/io.h> | ||
25 | #include <asm/pci-bridge.h> | ||
26 | |||
27 | /* Bus info */ | ||
28 | struct iowa_bus { | ||
29 | struct pci_controller *phb; | ||
30 | struct ppc_pci_io *ops; | ||
31 | void *private; | ||
32 | }; | ||
33 | |||
34 | void __devinit io_workaround_init(void); | ||
35 | void __devinit iowa_register_bus(struct pci_controller *, struct ppc_pci_io *, | ||
36 | int (*)(struct iowa_bus *, void *), void *); | ||
37 | struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR); | ||
38 | struct iowa_bus *iowa_pio_find_bus(unsigned long); | ||
39 | |||
40 | extern struct ppc_pci_io spiderpci_ops; | ||
41 | extern int spiderpci_iowa_init(struct iowa_bus *, void *); | ||
42 | |||
43 | #define SPIDER_PCI_REG_BASE 0xd000 | ||
44 | #define SPIDER_PCI_REG_SIZE 0x1000 | ||
45 | #define SPIDER_PCI_VCI_CNTL_STAT 0x0110 | ||
46 | #define SPIDER_PCI_DUMMY_READ 0x0810 | ||
47 | #define SPIDER_PCI_DUMMY_READ_BASE 0x0814 | ||
48 | |||
49 | #endif /* _IO_WORKAROUNDS_H */ | ||
diff --git a/arch/powerpc/platforms/cell/qpace_setup.c b/arch/powerpc/platforms/cell/qpace_setup.c index d31c594cfdf3..51e290126bc1 100644 --- a/arch/powerpc/platforms/cell/qpace_setup.c +++ b/arch/powerpc/platforms/cell/qpace_setup.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include "interrupt.h" | 42 | #include "interrupt.h" |
43 | #include "pervasive.h" | 43 | #include "pervasive.h" |
44 | #include "ras.h" | 44 | #include "ras.h" |
45 | #include "io-workarounds.h" | ||
46 | 45 | ||
47 | static void qpace_show_cpuinfo(struct seq_file *m) | 46 | static void qpace_show_cpuinfo(struct seq_file *m) |
48 | { | 47 | { |
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c index fd57bfe00edf..af7b13cd7110 100644 --- a/arch/powerpc/platforms/cell/setup.c +++ b/arch/powerpc/platforms/cell/setup.c | |||
@@ -51,11 +51,11 @@ | |||
51 | #include <asm/udbg.h> | 51 | #include <asm/udbg.h> |
52 | #include <asm/mpic.h> | 52 | #include <asm/mpic.h> |
53 | #include <asm/cell-regs.h> | 53 | #include <asm/cell-regs.h> |
54 | #include <asm/io-workarounds.h> | ||
54 | 55 | ||
55 | #include "interrupt.h" | 56 | #include "interrupt.h" |
56 | #include "pervasive.h" | 57 | #include "pervasive.h" |
57 | #include "ras.h" | 58 | #include "ras.h" |
58 | #include "io-workarounds.h" | ||
59 | 59 | ||
60 | #ifdef DEBUG | 60 | #ifdef DEBUG |
61 | #define DBG(fmt...) udbg_printf(fmt) | 61 | #define DBG(fmt...) udbg_printf(fmt) |
diff --git a/arch/powerpc/platforms/cell/spider-pci.c b/arch/powerpc/platforms/cell/spider-pci.c index ca7731c0b595..f1f7878893f3 100644 --- a/arch/powerpc/platforms/cell/spider-pci.c +++ b/arch/powerpc/platforms/cell/spider-pci.c | |||
@@ -27,8 +27,7 @@ | |||
27 | 27 | ||
28 | #include <asm/ppc-pci.h> | 28 | #include <asm/ppc-pci.h> |
29 | #include <asm/pci-bridge.h> | 29 | #include <asm/pci-bridge.h> |
30 | 30 | #include <asm/io-workarounds.h> | |
31 | #include "io-workarounds.h" | ||
32 | 31 | ||
33 | #define SPIDER_PCI_DISABLE_PREFETCH | 32 | #define SPIDER_PCI_DISABLE_PREFETCH |
34 | 33 | ||