aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-04-29 21:10:09 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-04-29 21:10:09 -0400
commitbc23100a0d646aedb6e17fbcecdc35a24cd3bf2a (patch)
treeafbf44b177d17a8450d606b6d976e76e8e964273 /arch/powerpc/sysdev
parent28bf41a1fedad76e9b4de70c9573bb3f8afc3709 (diff)
parent9e2ecdbba3b0745f9ed454ab86961e3ccf9dc224 (diff)
Merge remote-tracking branch 'kumar/next' into next
From Kumar Gala: << Add support for T4 and B4 SoC families from Freescale, e6500 altivec support, some various board fixes and other minor cleanups. >>
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r--arch/powerpc/sysdev/fsl_msi.c4
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c112
-rw-r--r--arch/powerpc/sysdev/fsl_pci.h13
-rw-r--r--arch/powerpc/sysdev/indirect_pci.c10
-rw-r--r--arch/powerpc/sysdev/qe_lib/Kconfig2
5 files changed, 101 insertions, 40 deletions
diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index 178c99427b1c..ab02db3d02d8 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -333,6 +333,8 @@ static int fsl_of_msi_remove(struct platform_device *ofdev)
333 return 0; 333 return 0;
334} 334}
335 335
336static struct lock_class_key fsl_msi_irq_class;
337
336static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev, 338static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev,
337 int offset, int irq_index) 339 int offset, int irq_index)
338{ 340{
@@ -351,7 +353,7 @@ static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev,
351 dev_err(&dev->dev, "No memory for MSI cascade data\n"); 353 dev_err(&dev->dev, "No memory for MSI cascade data\n");
352 return -ENOMEM; 354 return -ENOMEM;
353 } 355 }
354 356 irq_set_lockdep_class(virt_msir, &fsl_msi_irq_class);
355 msi->msi_virqs[irq_index] = virt_msir; 357 msi->msi_virqs[irq_index] = virt_msir;
356 cascade_data->index = offset; 358 cascade_data->index = offset;
357 cascade_data->msi_data = msi; 359 cascade_data->msi_data = msi;
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 682084dba19b..cf81d6516514 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -54,16 +54,63 @@ static void quirk_fsl_pcie_header(struct pci_dev *dev)
54 return; 54 return;
55} 55}
56 56
57static int __init fsl_pcie_check_link(struct pci_controller *hose) 57static int fsl_indirect_read_config(struct pci_bus *, unsigned int,
58 int, int, u32 *);
59
60static int fsl_pcie_check_link(struct pci_controller *hose)
58{ 61{
59 u32 val; 62 u32 val = 0;
63
64 if (hose->indirect_type & PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK) {
65 if (hose->ops->read == fsl_indirect_read_config) {
66 struct pci_bus bus;
67 bus.number = 0;
68 bus.sysdata = hose;
69 bus.ops = hose->ops;
70 indirect_read_config(&bus, 0, PCIE_LTSSM, 4, &val);
71 } else
72 early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
73 if (val < PCIE_LTSSM_L0)
74 return 1;
75 } else {
76 struct ccsr_pci __iomem *pci = hose->private_data;
77 /* for PCIe IP rev 3.0 or greater use CSR0 for link state */
78 val = (in_be32(&pci->pex_csr0) & PEX_CSR0_LTSSM_MASK)
79 >> PEX_CSR0_LTSSM_SHIFT;
80 if (val != PEX_CSR0_LTSSM_L0)
81 return 1;
82 }
60 83
61 early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
62 if (val < PCIE_LTSSM_L0)
63 return 1;
64 return 0; 84 return 0;
65} 85}
66 86
87static int fsl_indirect_read_config(struct pci_bus *bus, unsigned int devfn,
88 int offset, int len, u32 *val)
89{
90 struct pci_controller *hose = pci_bus_to_host(bus);
91
92 if (fsl_pcie_check_link(hose))
93 hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
94 else
95 hose->indirect_type &= ~PPC_INDIRECT_TYPE_NO_PCIE_LINK;
96
97 return indirect_read_config(bus, devfn, offset, len, val);
98}
99
100static struct pci_ops fsl_indirect_pci_ops =
101{
102 .read = fsl_indirect_read_config,
103 .write = indirect_write_config,
104};
105
106static void __init fsl_setup_indirect_pci(struct pci_controller* hose,
107 resource_size_t cfg_addr,
108 resource_size_t cfg_data, u32 flags)
109{
110 setup_indirect_pci(hose, cfg_addr, cfg_data, flags);
111 hose->ops = &fsl_indirect_pci_ops;
112}
113
67#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx) 114#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
68 115
69#define MAX_PHYS_ADDR_BITS 40 116#define MAX_PHYS_ADDR_BITS 40
@@ -106,7 +153,7 @@ static int setup_one_atmu(struct ccsr_pci __iomem *pci,
106 flags |= 0x10000000; /* enable relaxed ordering */ 153 flags |= 0x10000000; /* enable relaxed ordering */
107 154
108 for (i = 0; size > 0; i++) { 155 for (i = 0; size > 0; i++) {
109 unsigned int bits = min(__ilog2(size), 156 unsigned int bits = min(ilog2(size),
110 __ffs(pci_addr | phys_addr)); 157 __ffs(pci_addr | phys_addr));
111 158
112 if (index + i >= 5) 159 if (index + i >= 5)
@@ -126,10 +173,9 @@ static int setup_one_atmu(struct ccsr_pci __iomem *pci,
126} 173}
127 174
128/* atmu setup for fsl pci/pcie controller */ 175/* atmu setup for fsl pci/pcie controller */
129static void setup_pci_atmu(struct pci_controller *hose, 176static void setup_pci_atmu(struct pci_controller *hose)
130 struct resource *rsrc)
131{ 177{
132 struct ccsr_pci __iomem *pci; 178 struct ccsr_pci __iomem *pci = hose->private_data;
133 int i, j, n, mem_log, win_idx = 3, start_idx = 1, end_idx = 4; 179 int i, j, n, mem_log, win_idx = 3, start_idx = 1, end_idx = 4;
134 u64 mem, sz, paddr_hi = 0; 180 u64 mem, sz, paddr_hi = 0;
135 u64 paddr_lo = ULLONG_MAX; 181 u64 paddr_lo = ULLONG_MAX;
@@ -140,15 +186,6 @@ static void setup_pci_atmu(struct pci_controller *hose,
140 const u64 *reg; 186 const u64 *reg;
141 int len; 187 int len;
142 188
143 pr_debug("PCI memory map start 0x%016llx, size 0x%016llx\n",
144 (u64)rsrc->start, (u64)resource_size(rsrc));
145
146 pci = ioremap(rsrc->start, resource_size(rsrc));
147 if (!pci) {
148 dev_err(hose->parent, "Unable to map ATMU registers\n");
149 return;
150 }
151
152 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) { 189 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
153 if (in_be32(&pci->block_rev1) >= PCIE_IP_REV_2_2) { 190 if (in_be32(&pci->block_rev1) >= PCIE_IP_REV_2_2) {
154 win_idx = 2; 191 win_idx = 2;
@@ -196,7 +233,7 @@ static void setup_pci_atmu(struct pci_controller *hose,
196 out_be32(&pci->pow[j].powbar, (hose->io_base_phys >> 12)); 233 out_be32(&pci->pow[j].powbar, (hose->io_base_phys >> 12));
197 /* Enable, IO R/W */ 234 /* Enable, IO R/W */
198 out_be32(&pci->pow[j].powar, 0x80088000 235 out_be32(&pci->pow[j].powar, 0x80088000
199 | (__ilog2(hose->io_resource.end 236 | (ilog2(hose->io_resource.end
200 - hose->io_resource.start + 1) - 1)); 237 - hose->io_resource.start + 1) - 1));
201 } 238 }
202 } 239 }
@@ -207,12 +244,12 @@ static void setup_pci_atmu(struct pci_controller *hose,
207 244
208 if (paddr_hi == paddr_lo) { 245 if (paddr_hi == paddr_lo) {
209 pr_err("%s: No outbound window space\n", name); 246 pr_err("%s: No outbound window space\n", name);
210 goto out; 247 return;
211 } 248 }
212 249
213 if (paddr_lo == 0) { 250 if (paddr_lo == 0) {
214 pr_err("%s: No space for inbound window\n", name); 251 pr_err("%s: No space for inbound window\n", name);
215 goto out; 252 return;
216 } 253 }
217 254
218 /* setup PCSRBAR/PEXCSRBAR */ 255 /* setup PCSRBAR/PEXCSRBAR */
@@ -261,7 +298,7 @@ static void setup_pci_atmu(struct pci_controller *hose,
261 } 298 }
262 299
263 sz = min(mem, paddr_lo); 300 sz = min(mem, paddr_lo);
264 mem_log = __ilog2_u64(sz); 301 mem_log = ilog2(sz);
265 302
266 /* PCIe can overmap inbound & outbound since RX & TX are separated */ 303 /* PCIe can overmap inbound & outbound since RX & TX are separated */
267 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) { 304 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
@@ -290,7 +327,7 @@ static void setup_pci_atmu(struct pci_controller *hose,
290 * SWIOTLB and access the full range of memory 327 * SWIOTLB and access the full range of memory
291 */ 328 */
292 if (sz != mem) { 329 if (sz != mem) {
293 mem_log = __ilog2_u64(mem); 330 mem_log = ilog2(mem);
294 331
295 /* Size window up if we dont fit in exact power-of-2 */ 332 /* Size window up if we dont fit in exact power-of-2 */
296 if ((1ull << mem_log) != mem) 333 if ((1ull << mem_log) != mem)
@@ -327,7 +364,7 @@ static void setup_pci_atmu(struct pci_controller *hose,
327 sz -= 1ull << mem_log; 364 sz -= 1ull << mem_log;
328 365
329 if (sz) { 366 if (sz) {
330 mem_log = __ilog2_u64(sz); 367 mem_log = ilog2(sz);
331 piwar |= (mem_log - 1); 368 piwar |= (mem_log - 1);
332 369
333 out_be32(&pci->piw[win_idx].pitar, paddr >> 12); 370 out_be32(&pci->piw[win_idx].pitar, paddr >> 12);
@@ -358,9 +395,6 @@ static void setup_pci_atmu(struct pci_controller *hose,
358 pr_info("%s: DMA window size is 0x%llx\n", name, 395 pr_info("%s: DMA window size is 0x%llx\n", name,
359 (u64)hose->dma_window_size); 396 (u64)hose->dma_window_size);
360 } 397 }
361
362out:
363 iounmap(pci);
364} 398}
365 399
366static void __init setup_pci_cmd(struct pci_controller *hose) 400static void __init setup_pci_cmd(struct pci_controller *hose)
@@ -429,6 +463,7 @@ int __init fsl_add_bridge(struct platform_device *pdev, int is_primary)
429 const int *bus_range; 463 const int *bus_range;
430 u8 hdr_type, progif; 464 u8 hdr_type, progif;
431 struct device_node *dev; 465 struct device_node *dev;
466 struct ccsr_pci __iomem *pci;
432 467
433 dev = pdev->dev.of_node; 468 dev = pdev->dev.of_node;
434 469
@@ -461,8 +496,18 @@ int __init fsl_add_bridge(struct platform_device *pdev, int is_primary)
461 hose->first_busno = bus_range ? bus_range[0] : 0x0; 496 hose->first_busno = bus_range ? bus_range[0] : 0x0;
462 hose->last_busno = bus_range ? bus_range[1] : 0xff; 497 hose->last_busno = bus_range ? bus_range[1] : 0xff;
463 498
464 setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4, 499 pr_debug("PCI memory map start 0x%016llx, size 0x%016llx\n",
465 PPC_INDIRECT_TYPE_BIG_ENDIAN); 500 (u64)rsrc.start, (u64)resource_size(&rsrc));
501
502 pci = hose->private_data = ioremap(rsrc.start, resource_size(&rsrc));
503 if (!hose->private_data)
504 goto no_bridge;
505
506 fsl_setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
507 PPC_INDIRECT_TYPE_BIG_ENDIAN);
508
509 if (in_be32(&pci->block_rev1) < PCIE_IP_REV_3_0)
510 hose->indirect_type |= PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK;
466 511
467 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) { 512 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
468 /* For PCIE read HEADER_TYPE to identify controler mode */ 513 /* For PCIE read HEADER_TYPE to identify controler mode */
@@ -500,11 +545,12 @@ int __init fsl_add_bridge(struct platform_device *pdev, int is_primary)
500 pci_process_bridge_OF_ranges(hose, dev, is_primary); 545 pci_process_bridge_OF_ranges(hose, dev, is_primary);
501 546
502 /* Setup PEX window registers */ 547 /* Setup PEX window registers */
503 setup_pci_atmu(hose, &rsrc); 548 setup_pci_atmu(hose);
504 549
505 return 0; 550 return 0;
506 551
507no_bridge: 552no_bridge:
553 iounmap(hose->private_data);
508 /* unmap cfg_data & cfg_addr separately if not on same page */ 554 /* unmap cfg_data & cfg_addr separately if not on same page */
509 if (((unsigned long)hose->cfg_data & PAGE_MASK) != 555 if (((unsigned long)hose->cfg_data & PAGE_MASK) !=
510 ((unsigned long)hose->cfg_addr & PAGE_MASK)) 556 ((unsigned long)hose->cfg_addr & PAGE_MASK))
@@ -681,6 +727,7 @@ static int __init mpc83xx_pcie_setup(struct pci_controller *hose,
681 WARN_ON(hose->dn->data); 727 WARN_ON(hose->dn->data);
682 hose->dn->data = pcie; 728 hose->dn->data = pcie;
683 hose->ops = &mpc83xx_pcie_ops; 729 hose->ops = &mpc83xx_pcie_ops;
730 hose->indirect_type |= PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK;
684 731
685 out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAH, 0); 732 out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAH, 0);
686 out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAL, 0); 733 out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAL, 0);
@@ -766,8 +813,8 @@ int __init mpc83xx_add_bridge(struct device_node *dev)
766 if (ret) 813 if (ret)
767 goto err0; 814 goto err0;
768 } else { 815 } else {
769 setup_indirect_pci(hose, rsrc_cfg.start, 816 fsl_setup_indirect_pci(hose, rsrc_cfg.start,
770 rsrc_cfg.start + 4, 0); 817 rsrc_cfg.start + 4, 0);
771 } 818 }
772 819
773 printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx. " 820 printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx. "
@@ -836,6 +883,7 @@ static const struct of_device_id pci_ids[] = {
836 { .compatible = "fsl,qoriq-pcie-v2.2", }, 883 { .compatible = "fsl,qoriq-pcie-v2.2", },
837 { .compatible = "fsl,qoriq-pcie-v2.3", }, 884 { .compatible = "fsl,qoriq-pcie-v2.3", },
838 { .compatible = "fsl,qoriq-pcie-v2.4", }, 885 { .compatible = "fsl,qoriq-pcie-v2.4", },
886 { .compatible = "fsl,qoriq-pcie-v3.0", },
839 887
840 /* 888 /*
841 * The following entries are for compatibility with older device 889 * The following entries are for compatibility with older device
diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
index c495c00c8740..72b5625330e2 100644
--- a/arch/powerpc/sysdev/fsl_pci.h
+++ b/arch/powerpc/sysdev/fsl_pci.h
@@ -14,9 +14,12 @@
14#ifndef __POWERPC_FSL_PCI_H 14#ifndef __POWERPC_FSL_PCI_H
15#define __POWERPC_FSL_PCI_H 15#define __POWERPC_FSL_PCI_H
16 16
17struct platform_device;
18
17#define PCIE_LTSSM 0x0404 /* PCIE Link Training and Status */ 19#define PCIE_LTSSM 0x0404 /* PCIE Link Training and Status */
18#define PCIE_LTSSM_L0 0x16 /* L0 state */ 20#define PCIE_LTSSM_L0 0x16 /* L0 state */
19#define PCIE_IP_REV_2_2 0x02080202 /* PCIE IP block version Rev2.2 */ 21#define PCIE_IP_REV_2_2 0x02080202 /* PCIE IP block version Rev2.2 */
22#define PCIE_IP_REV_3_0 0x02080300 /* PCIE IP block version Rev3.0 */
20#define PIWAR_EN 0x80000000 /* Enable */ 23#define PIWAR_EN 0x80000000 /* Enable */
21#define PIWAR_PF 0x20000000 /* prefetch */ 24#define PIWAR_PF 0x20000000 /* prefetch */
22#define PIWAR_TGI_LOCAL 0x00f00000 /* target - local memory */ 25#define PIWAR_TGI_LOCAL 0x00f00000 /* target - local memory */
@@ -89,6 +92,16 @@ struct ccsr_pci {
89 __be32 pex_err_cap_r1; /* 0x.e2c - PCIE error capture register 0 */ 92 __be32 pex_err_cap_r1; /* 0x.e2c - PCIE error capture register 0 */
90 __be32 pex_err_cap_r2; /* 0x.e30 - PCIE error capture register 0 */ 93 __be32 pex_err_cap_r2; /* 0x.e30 - PCIE error capture register 0 */
91 __be32 pex_err_cap_r3; /* 0x.e34 - PCIE error capture register 0 */ 94 __be32 pex_err_cap_r3; /* 0x.e34 - PCIE error capture register 0 */
95 u8 res_e38[200];
96 __be32 pdb_stat; /* 0x.f00 - PCIE Debug Status */
97 u8 res_f04[16];
98 __be32 pex_csr0; /* 0x.f14 - PEX Control/Status register 0*/
99#define PEX_CSR0_LTSSM_MASK 0xFC
100#define PEX_CSR0_LTSSM_SHIFT 2
101#define PEX_CSR0_LTSSM_L0 0x11
102 __be32 pex_csr1; /* 0x.f18 - PEX Control/Status register 1*/
103 u8 res_f1c[228];
104
92}; 105};
93 106
94extern int fsl_add_bridge(struct platform_device *pdev, int is_primary); 107extern int fsl_add_bridge(struct platform_device *pdev, int is_primary);
diff --git a/arch/powerpc/sysdev/indirect_pci.c b/arch/powerpc/sysdev/indirect_pci.c
index 82fdad885d20..c6c8b526a4f6 100644
--- a/arch/powerpc/sysdev/indirect_pci.c
+++ b/arch/powerpc/sysdev/indirect_pci.c
@@ -20,9 +20,8 @@
20#include <asm/pci-bridge.h> 20#include <asm/pci-bridge.h>
21#include <asm/machdep.h> 21#include <asm/machdep.h>
22 22
23static int 23int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
24indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset, 24 int offset, int len, u32 *val)
25 int len, u32 *val)
26{ 25{
27 struct pci_controller *hose = pci_bus_to_host(bus); 26 struct pci_controller *hose = pci_bus_to_host(bus);
28 volatile void __iomem *cfg_data; 27 volatile void __iomem *cfg_data;
@@ -78,9 +77,8 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
78 return PCIBIOS_SUCCESSFUL; 77 return PCIBIOS_SUCCESSFUL;
79} 78}
80 79
81static int 80int indirect_write_config(struct pci_bus *bus, unsigned int devfn,
82indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset, 81 int offset, int len, u32 val)
83 int len, u32 val)
84{ 82{
85 struct pci_controller *hose = pci_bus_to_host(bus); 83 struct pci_controller *hose = pci_bus_to_host(bus);
86 volatile void __iomem *cfg_data; 84 volatile void __iomem *cfg_data;
diff --git a/arch/powerpc/sysdev/qe_lib/Kconfig b/arch/powerpc/sysdev/qe_lib/Kconfig
index 41ac3dfac98e..3c251993bacd 100644
--- a/arch/powerpc/sysdev/qe_lib/Kconfig
+++ b/arch/powerpc/sysdev/qe_lib/Kconfig
@@ -22,6 +22,6 @@ config UCC
22 22
23config QE_USB 23config QE_USB
24 bool 24 bool
25 default y if USB_GADGET_FSL_QE 25 default y if USB_FSL_QE
26 help 26 help
27 QE USB Controller support 27 QE USB Controller support