aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-10-20 16:40:48 -0400
committerArnd Bergmann <arnd@arndb.de>2017-10-20 16:43:05 -0400
commit1c6788e8746d5250ad9bd16e1e48140a396f4733 (patch)
tree643f0483e984cf5d596ffc8c957f41b70bb6a690
parent8193d9ae379484cb9d36fb5f01053f5ca79fc9dd (diff)
parente868adf21c0a25634d5dfa5b1e6dbf839306d8fa (diff)
Merge tag 'soc-fsl-for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/leo/linux into next/drivers
Pull "FSL/NXP ARM SoC drivers updates for 4.14" from Li Yang: This adds the DPAA QBMan support for ARM SoCs and a few minor fixes/updates. This pull request includes updates to the QMAN/BMAN drivers to make them work on the arm/arm64 architectures in addition to the power architecture and a few minor update/bug-fix to the soc/fsl drivers. We got the Reviewed-by from Catalin on the ARM architecture side. DPAA (Data Path Acceleration Architecture) is a set of hardware components used on some FSL/NXP QorIQ Networking SoCs, it provides the infrastructure to support simplified sharing of networking interfaces and accelerators by multiple CPU cores, and the accelerators themselves. The QMan(Queue Manager) and BMan(Buffer Manager) are infrastructural components within the DPAA framework. They are used to manage queues and buffers for various I/O interfaces, hardware accelerators. * tag 'soc-fsl-for-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/leo/linux: soc/fsl/qbman: Enable FSL_LAYERSCAPE config on ARM soc/fsl/qbman: Add missing headers on ARM soc/fsl/qbman: different register offsets on ARM soc/fsl/qbman: add QMAN_REV32 soc/fsl/qbman: Rework portal mapping calls for ARM/PPC soc/fsl/qbman: Fix ARM32 typo soc/fsl/qbman: Drop L1_CACHE_BYTES compile time check soc/fsl/qbman: Drop set/clear_bits usage dt-bindings: soc/fsl: Update reserved memory binding for QBMan soc/fsl/qbman: Use shared-dma-pool for QMan private memory allocations soc/fsl/qbman: Use shared-dma-pool for BMan private memory allocations soc/fsl/qbman: Add common routine for QBMan private allocations soc/fsl/guts: Add compatible string for LS1088 soc/fsl/qman: Sleep instead of stuck hacking jiffies
-rw-r--r--Documentation/devicetree/bindings/soc/fsl/bman.txt12
-rw-r--r--Documentation/devicetree/bindings/soc/fsl/qman.txt26
-rw-r--r--drivers/soc/fsl/guts.c1
-rw-r--r--drivers/soc/fsl/qbman/Kconfig2
-rw-r--r--drivers/soc/fsl/qbman/Makefile2
-rw-r--r--drivers/soc/fsl/qbman/bman.c42
-rw-r--r--drivers/soc/fsl/qbman/bman_ccsr.c15
-rw-r--r--drivers/soc/fsl/qbman/bman_portal.c23
-rw-r--r--drivers/soc/fsl/qbman/bman_priv.h8
-rw-r--r--drivers/soc/fsl/qbman/dpaa_sys.c78
-rw-r--r--drivers/soc/fsl/qbman/dpaa_sys.h25
-rw-r--r--drivers/soc/fsl/qbman/qman.c83
-rw-r--r--drivers/soc/fsl/qbman/qman_ccsr.c95
-rw-r--r--drivers/soc/fsl/qbman/qman_portal.c23
-rw-r--r--drivers/soc/fsl/qbman/qman_priv.h11
-rw-r--r--drivers/soc/fsl/qbman/qman_test.h2
16 files changed, 320 insertions, 128 deletions
diff --git a/Documentation/devicetree/bindings/soc/fsl/bman.txt b/Documentation/devicetree/bindings/soc/fsl/bman.txt
index 47ac834414d8..48eed140765b 100644
--- a/Documentation/devicetree/bindings/soc/fsl/bman.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/bman.txt
@@ -65,8 +65,8 @@ to the respective BMan instance
65BMan Private Memory Node 65BMan Private Memory Node
66 66
67BMan requires a contiguous range of physical memory used for the backing store 67BMan requires a contiguous range of physical memory used for the backing store
68for BMan Free Buffer Proxy Records (FBPR). This memory is reserved/allocated as a 68for BMan Free Buffer Proxy Records (FBPR). This memory is reserved/allocated as
69node under the /reserved-memory node 69a node under the /reserved-memory node.
70 70
71The BMan FBPR memory node must be named "bman-fbpr" 71The BMan FBPR memory node must be named "bman-fbpr"
72 72
@@ -75,7 +75,9 @@ PROPERTIES
75- compatible 75- compatible
76 Usage: required 76 Usage: required
77 Value type: <stringlist> 77 Value type: <stringlist>
78 Definition: Must inclide "fsl,bman-fbpr" 78 Definition: PPC platforms: Must include "fsl,bman-fbpr"
79 ARM platforms: Must include "shared-dma-pool"
80 as well as the "no-map" property
79 81
80The following constraints are relevant to the FBPR private memory: 82The following constraints are relevant to the FBPR private memory:
81 - The size must be 2^(size + 1), with size = 11..33. That is 4 KiB to 83 - The size must be 2^(size + 1), with size = 11..33. That is 4 KiB to
@@ -100,10 +102,10 @@ The example below shows a BMan FBPR dynamic allocation memory node
100 ranges; 102 ranges;
101 103
102 bman_fbpr: bman-fbpr { 104 bman_fbpr: bman-fbpr {
103 compatible = "fsl,bman-fbpr"; 105 compatible = "shared-mem-pool";
104 alloc-ranges = <0 0 0x10 0>;
105 size = <0 0x1000000>; 106 size = <0 0x1000000>;
106 alignment = <0 0x1000000>; 107 alignment = <0 0x1000000>;
108 no-map;
107 }; 109 };
108 }; 110 };
109 111
diff --git a/Documentation/devicetree/bindings/soc/fsl/qman.txt b/Documentation/devicetree/bindings/soc/fsl/qman.txt
index 556ebb8be75d..ee96afd2af72 100644
--- a/Documentation/devicetree/bindings/soc/fsl/qman.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/qman.txt
@@ -60,6 +60,12 @@ are located at offsets 0xbf8 and 0xbfc
60 Value type: <prop-encoded-array> 60 Value type: <prop-encoded-array>
61 Definition: Reference input clock. Its frequency is half of the 61 Definition: Reference input clock. Its frequency is half of the
62 platform clock 62 platform clock
63- memory-regions
64 Usage: Required for ARM
65 Value type: <phandle array>
66 Definition: List of phandles referencing the QMan private memory
67 nodes (described below). The qman-fqd node must be
68 first followed by qman-pfdr node. Only used on ARM
63 69
64Devices connected to a QMan instance via Direct Connect Portals (DCP) must link 70Devices connected to a QMan instance via Direct Connect Portals (DCP) must link
65to the respective QMan instance 71to the respective QMan instance
@@ -74,7 +80,9 @@ QMan Private Memory Nodes
74 80
75QMan requires two contiguous range of physical memory used for the backing store 81QMan requires two contiguous range of physical memory used for the backing store
76for QMan Frame Queue Descriptor (FQD) and Packed Frame Descriptor Record (PFDR). 82for QMan Frame Queue Descriptor (FQD) and Packed Frame Descriptor Record (PFDR).
77This memory is reserved/allocated as a nodes under the /reserved-memory node 83This memory is reserved/allocated as a node under the /reserved-memory node.
84
85For additional details about reserved memory regions see reserved-memory.txt
78 86
79The QMan FQD memory node must be named "qman-fqd" 87The QMan FQD memory node must be named "qman-fqd"
80 88
@@ -83,7 +91,9 @@ PROPERTIES
83- compatible 91- compatible
84 Usage: required 92 Usage: required
85 Value type: <stringlist> 93 Value type: <stringlist>
86 Definition: Must inclide "fsl,qman-fqd" 94 Definition: PPC platforms: Must include "fsl,qman-fqd"
95 ARM platforms: Must include "shared-dma-pool"
96 as well as the "no-map" property
87 97
88The QMan PFDR memory node must be named "qman-pfdr" 98The QMan PFDR memory node must be named "qman-pfdr"
89 99
@@ -92,7 +102,9 @@ PROPERTIES
92- compatible 102- compatible
93 Usage: required 103 Usage: required
94 Value type: <stringlist> 104 Value type: <stringlist>
95 Definition: Must inclide "fsl,qman-pfdr" 105 Definition: PPC platforms: Must include "fsl,qman-pfdr"
106 ARM platforms: Must include "shared-dma-pool"
107 as well as the "no-map" property
96 108
97The following constraints are relevant to the FQD and PFDR private memory: 109The following constraints are relevant to the FQD and PFDR private memory:
98 - The size must be 2^(size + 1), with size = 11..29. That is 4 KiB to 110 - The size must be 2^(size + 1), with size = 11..29. That is 4 KiB to
@@ -117,16 +129,16 @@ The example below shows a QMan FQD and a PFDR dynamic allocation memory nodes
117 ranges; 129 ranges;
118 130
119 qman_fqd: qman-fqd { 131 qman_fqd: qman-fqd {
120 compatible = "fsl,qman-fqd"; 132 compatible = "shared-dma-pool";
121 alloc-ranges = <0 0 0x10 0>;
122 size = <0 0x400000>; 133 size = <0 0x400000>;
123 alignment = <0 0x400000>; 134 alignment = <0 0x400000>;
135 no-map;
124 }; 136 };
125 qman_pfdr: qman-pfdr { 137 qman_pfdr: qman-pfdr {
126 compatible = "fsl,qman-pfdr"; 138 compatible = "shared-dma-pool";
127 alloc-ranges = <0 0 0x10 0>;
128 size = <0 0x2000000>; 139 size = <0 0x2000000>;
129 alignment = <0 0x2000000>; 140 alignment = <0 0x2000000>;
141 no-map;
130 }; 142 };
131 }; 143 };
132 144
diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
index 6af7a11f09a5..d89a6a80c8ef 100644
--- a/drivers/soc/fsl/guts.c
+++ b/drivers/soc/fsl/guts.c
@@ -213,6 +213,7 @@ static const struct of_device_id fsl_guts_of_match[] = {
213 { .compatible = "fsl,ls1021a-dcfg", }, 213 { .compatible = "fsl,ls1021a-dcfg", },
214 { .compatible = "fsl,ls1043a-dcfg", }, 214 { .compatible = "fsl,ls1043a-dcfg", },
215 { .compatible = "fsl,ls2080a-dcfg", }, 215 { .compatible = "fsl,ls2080a-dcfg", },
216 { .compatible = "fsl,ls1088a-dcfg", },
216 {} 217 {}
217}; 218};
218MODULE_DEVICE_TABLE(of, fsl_guts_of_match); 219MODULE_DEVICE_TABLE(of, fsl_guts_of_match);
diff --git a/drivers/soc/fsl/qbman/Kconfig b/drivers/soc/fsl/qbman/Kconfig
index 757033c0586c..fb4e6bf0a0c4 100644
--- a/drivers/soc/fsl/qbman/Kconfig
+++ b/drivers/soc/fsl/qbman/Kconfig
@@ -1,6 +1,6 @@
1menuconfig FSL_DPAA 1menuconfig FSL_DPAA
2 bool "Freescale DPAA 1.x support" 2 bool "Freescale DPAA 1.x support"
3 depends on FSL_SOC_BOOKE 3 depends on (FSL_SOC_BOOKE || ARCH_LAYERSCAPE)
4 select GENERIC_ALLOCATOR 4 select GENERIC_ALLOCATOR
5 help 5 help
6 The Freescale Data Path Acceleration Architecture (DPAA) is a set of 6 The Freescale Data Path Acceleration Architecture (DPAA) is a set of
diff --git a/drivers/soc/fsl/qbman/Makefile b/drivers/soc/fsl/qbman/Makefile
index 7ae199f1664e..3cbd08aeab59 100644
--- a/drivers/soc/fsl/qbman/Makefile
+++ b/drivers/soc/fsl/qbman/Makefile
@@ -1,6 +1,6 @@
1obj-$(CONFIG_FSL_DPAA) += bman_ccsr.o qman_ccsr.o \ 1obj-$(CONFIG_FSL_DPAA) += bman_ccsr.o qman_ccsr.o \
2 bman_portal.o qman_portal.o \ 2 bman_portal.o qman_portal.o \
3 bman.o qman.o 3 bman.o qman.o dpaa_sys.o
4 4
5obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o 5obj-$(CONFIG_FSL_BMAN_TEST) += bman-test.o
6bman-test-y = bman_test.o 6bman-test-y = bman_test.o
diff --git a/drivers/soc/fsl/qbman/bman.c b/drivers/soc/fsl/qbman/bman.c
index a3d6d7cfa929..f9485cedc648 100644
--- a/drivers/soc/fsl/qbman/bman.c
+++ b/drivers/soc/fsl/qbman/bman.c
@@ -35,6 +35,27 @@
35 35
36/* Portal register assists */ 36/* Portal register assists */
37 37
38#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
39/* Cache-inhibited register offsets */
40#define BM_REG_RCR_PI_CINH 0x3000
41#define BM_REG_RCR_CI_CINH 0x3100
42#define BM_REG_RCR_ITR 0x3200
43#define BM_REG_CFG 0x3300
44#define BM_REG_SCN(n) (0x3400 + ((n) << 6))
45#define BM_REG_ISR 0x3e00
46#define BM_REG_IER 0x3e40
47#define BM_REG_ISDR 0x3e80
48#define BM_REG_IIR 0x3ec0
49
50/* Cache-enabled register offsets */
51#define BM_CL_CR 0x0000
52#define BM_CL_RR0 0x0100
53#define BM_CL_RR1 0x0140
54#define BM_CL_RCR 0x1000
55#define BM_CL_RCR_PI_CENA 0x3000
56#define BM_CL_RCR_CI_CENA 0x3100
57
58#else
38/* Cache-inhibited register offsets */ 59/* Cache-inhibited register offsets */
39#define BM_REG_RCR_PI_CINH 0x0000 60#define BM_REG_RCR_PI_CINH 0x0000
40#define BM_REG_RCR_CI_CINH 0x0004 61#define BM_REG_RCR_CI_CINH 0x0004
@@ -53,6 +74,7 @@
53#define BM_CL_RCR 0x1000 74#define BM_CL_RCR 0x1000
54#define BM_CL_RCR_PI_CENA 0x3000 75#define BM_CL_RCR_PI_CENA 0x3000
55#define BM_CL_RCR_CI_CENA 0x3100 76#define BM_CL_RCR_CI_CENA 0x3100
77#endif
56 78
57/* 79/*
58 * Portal modes. 80 * Portal modes.
@@ -154,7 +176,8 @@ struct bm_mc {
154}; 176};
155 177
156struct bm_addr { 178struct bm_addr {
157 void __iomem *ce; /* cache-enabled */ 179 void *ce; /* cache-enabled */
180 __be32 *ce_be; /* Same as above but for direct access */
158 void __iomem *ci; /* cache-inhibited */ 181 void __iomem *ci; /* cache-inhibited */
159}; 182};
160 183
@@ -167,12 +190,12 @@ struct bm_portal {
167/* Cache-inhibited register access. */ 190/* Cache-inhibited register access. */
168static inline u32 bm_in(struct bm_portal *p, u32 offset) 191static inline u32 bm_in(struct bm_portal *p, u32 offset)
169{ 192{
170 return be32_to_cpu(__raw_readl(p->addr.ci + offset)); 193 return ioread32be(p->addr.ci + offset);
171} 194}
172 195
173static inline void bm_out(struct bm_portal *p, u32 offset, u32 val) 196static inline void bm_out(struct bm_portal *p, u32 offset, u32 val)
174{ 197{
175 __raw_writel(cpu_to_be32(val), p->addr.ci + offset); 198 iowrite32be(val, p->addr.ci + offset);
176} 199}
177 200
178/* Cache Enabled Portal Access */ 201/* Cache Enabled Portal Access */
@@ -188,7 +211,7 @@ static inline void bm_cl_touch_ro(struct bm_portal *p, u32 offset)
188 211
189static inline u32 bm_ce_in(struct bm_portal *p, u32 offset) 212static inline u32 bm_ce_in(struct bm_portal *p, u32 offset)
190{ 213{
191 return be32_to_cpu(__raw_readl(p->addr.ce + offset)); 214 return be32_to_cpu(*(p->addr.ce_be + (offset/4)));
192} 215}
193 216
194struct bman_portal { 217struct bman_portal {
@@ -408,7 +431,7 @@ static int bm_mc_init(struct bm_portal *portal)
408 431
409 mc->cr = portal->addr.ce + BM_CL_CR; 432 mc->cr = portal->addr.ce + BM_CL_CR;
410 mc->rr = portal->addr.ce + BM_CL_RR0; 433 mc->rr = portal->addr.ce + BM_CL_RR0;
411 mc->rridx = (__raw_readb(&mc->cr->_ncw_verb) & BM_MCC_VERB_VBIT) ? 434 mc->rridx = (mc->cr->_ncw_verb & BM_MCC_VERB_VBIT) ?
412 0 : 1; 435 0 : 1;
413 mc->vbit = mc->rridx ? BM_MCC_VERB_VBIT : 0; 436 mc->vbit = mc->rridx ? BM_MCC_VERB_VBIT : 0;
414#ifdef CONFIG_FSL_DPAA_CHECKING 437#ifdef CONFIG_FSL_DPAA_CHECKING
@@ -466,7 +489,7 @@ static inline union bm_mc_result *bm_mc_result(struct bm_portal *portal)
466 * its command is submitted and completed. This includes the valid-bit, 489 * its command is submitted and completed. This includes the valid-bit,
467 * in case you were wondering... 490 * in case you were wondering...
468 */ 491 */
469 if (!__raw_readb(&rr->verb)) { 492 if (!rr->verb) {
470 dpaa_invalidate_touch_ro(rr); 493 dpaa_invalidate_touch_ro(rr);
471 return NULL; 494 return NULL;
472 } 495 }
@@ -512,8 +535,9 @@ static int bman_create_portal(struct bman_portal *portal,
512 * config, everything that follows depends on it and "config" is more 535 * config, everything that follows depends on it and "config" is more
513 * for (de)reference... 536 * for (de)reference...
514 */ 537 */
515 p->addr.ce = c->addr_virt[DPAA_PORTAL_CE]; 538 p->addr.ce = c->addr_virt_ce;
516 p->addr.ci = c->addr_virt[DPAA_PORTAL_CI]; 539 p->addr.ce_be = c->addr_virt_ce;
540 p->addr.ci = c->addr_virt_ci;
517 if (bm_rcr_init(p, bm_rcr_pvb, bm_rcr_cce)) { 541 if (bm_rcr_init(p, bm_rcr_pvb, bm_rcr_cce)) {
518 dev_err(c->dev, "RCR initialisation failed\n"); 542 dev_err(c->dev, "RCR initialisation failed\n");
519 goto fail_rcr; 543 goto fail_rcr;
@@ -607,7 +631,7 @@ int bman_p_irqsource_add(struct bman_portal *p, u32 bits)
607 unsigned long irqflags; 631 unsigned long irqflags;
608 632
609 local_irq_save(irqflags); 633 local_irq_save(irqflags);
610 set_bits(bits & BM_PIRQ_VISIBLE, &p->irq_sources); 634 p->irq_sources |= bits & BM_PIRQ_VISIBLE;
611 bm_out(&p->p, BM_REG_IER, p->irq_sources); 635 bm_out(&p->p, BM_REG_IER, p->irq_sources);
612 local_irq_restore(irqflags); 636 local_irq_restore(irqflags);
613 return 0; 637 return 0;
diff --git a/drivers/soc/fsl/qbman/bman_ccsr.c b/drivers/soc/fsl/qbman/bman_ccsr.c
index eaa9585c7347..05c42235dd41 100644
--- a/drivers/soc/fsl/qbman/bman_ccsr.c
+++ b/drivers/soc/fsl/qbman/bman_ccsr.c
@@ -201,6 +201,21 @@ static int fsl_bman_probe(struct platform_device *pdev)
201 return -ENODEV; 201 return -ENODEV;
202 } 202 }
203 203
204 /*
205 * If FBPR memory wasn't defined using the qbman compatible string
206 * try using the of_reserved_mem_device method
207 */
208 if (!fbpr_a) {
209 ret = qbman_init_private_mem(dev, 0, &fbpr_a, &fbpr_sz);
210 if (ret) {
211 dev_err(dev, "qbman_init_private_mem() failed 0x%x\n",
212 ret);
213 return -ENODEV;
214 }
215 }
216
217 dev_dbg(dev, "Allocated FBPR 0x%llx 0x%zx\n", fbpr_a, fbpr_sz);
218
204 bm_set_memory(fbpr_a, fbpr_sz); 219 bm_set_memory(fbpr_a, fbpr_sz);
205 220
206 err_irq = platform_get_irq(pdev, 0); 221 err_irq = platform_get_irq(pdev, 0);
diff --git a/drivers/soc/fsl/qbman/bman_portal.c b/drivers/soc/fsl/qbman/bman_portal.c
index 39b39c8f1399..2f71f7df3465 100644
--- a/drivers/soc/fsl/qbman/bman_portal.c
+++ b/drivers/soc/fsl/qbman/bman_portal.c
@@ -91,7 +91,6 @@ static int bman_portal_probe(struct platform_device *pdev)
91 struct device_node *node = dev->of_node; 91 struct device_node *node = dev->of_node;
92 struct bm_portal_config *pcfg; 92 struct bm_portal_config *pcfg;
93 struct resource *addr_phys[2]; 93 struct resource *addr_phys[2];
94 void __iomem *va;
95 int irq, cpu; 94 int irq, cpu;
96 95
97 pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL); 96 pcfg = devm_kmalloc(dev, sizeof(*pcfg), GFP_KERNEL);
@@ -123,23 +122,21 @@ static int bman_portal_probe(struct platform_device *pdev)
123 } 122 }
124 pcfg->irq = irq; 123 pcfg->irq = irq;
125 124
126 va = ioremap_prot(addr_phys[0]->start, resource_size(addr_phys[0]), 0); 125 pcfg->addr_virt_ce = memremap(addr_phys[0]->start,
127 if (!va) { 126 resource_size(addr_phys[0]),
128 dev_err(dev, "ioremap::CE failed\n"); 127 QBMAN_MEMREMAP_ATTR);
128 if (!pcfg->addr_virt_ce) {
129 dev_err(dev, "memremap::CE failed\n");
129 goto err_ioremap1; 130 goto err_ioremap1;
130 } 131 }
131 132
132 pcfg->addr_virt[DPAA_PORTAL_CE] = va; 133 pcfg->addr_virt_ci = ioremap(addr_phys[1]->start,
133 134 resource_size(addr_phys[1]));
134 va = ioremap_prot(addr_phys[1]->start, resource_size(addr_phys[1]), 135 if (!pcfg->addr_virt_ci) {
135 _PAGE_GUARDED | _PAGE_NO_CACHE);
136 if (!va) {
137 dev_err(dev, "ioremap::CI failed\n"); 136 dev_err(dev, "ioremap::CI failed\n");
138 goto err_ioremap2; 137 goto err_ioremap2;
139 } 138 }
140 139
141 pcfg->addr_virt[DPAA_PORTAL_CI] = va;
142
143 spin_lock(&bman_lock); 140 spin_lock(&bman_lock);
144 cpu = cpumask_next_zero(-1, &portal_cpus); 141 cpu = cpumask_next_zero(-1, &portal_cpus);
145 if (cpu >= nr_cpu_ids) { 142 if (cpu >= nr_cpu_ids) {
@@ -164,9 +161,9 @@ static int bman_portal_probe(struct platform_device *pdev)
164 return 0; 161 return 0;
165 162
166err_portal_init: 163err_portal_init:
167 iounmap(pcfg->addr_virt[DPAA_PORTAL_CI]); 164 iounmap(pcfg->addr_virt_ci);
168err_ioremap2: 165err_ioremap2:
169 iounmap(pcfg->addr_virt[DPAA_PORTAL_CE]); 166 memunmap(pcfg->addr_virt_ce);
170err_ioremap1: 167err_ioremap1:
171 return -ENXIO; 168 return -ENXIO;
172} 169}
diff --git a/drivers/soc/fsl/qbman/bman_priv.h b/drivers/soc/fsl/qbman/bman_priv.h
index f6896a2f6d90..751ce90383b7 100644
--- a/drivers/soc/fsl/qbman/bman_priv.h
+++ b/drivers/soc/fsl/qbman/bman_priv.h
@@ -46,11 +46,9 @@ extern u16 bman_ip_rev; /* 0 if uninitialised, otherwise BMAN_REVx */
46extern struct gen_pool *bm_bpalloc; 46extern struct gen_pool *bm_bpalloc;
47 47
48struct bm_portal_config { 48struct bm_portal_config {
49 /* 49 /* Portal addresses */
50 * Corenet portal addresses; 50 void *addr_virt_ce;
51 * [0]==cache-enabled, [1]==cache-inhibited. 51 void __iomem *addr_virt_ci;
52 */
53 void __iomem *addr_virt[2];
54 /* Allow these to be joined in lists */ 52 /* Allow these to be joined in lists */
55 struct list_head list; 53 struct list_head list;
56 struct device *dev; 54 struct device *dev;
diff --git a/drivers/soc/fsl/qbman/dpaa_sys.c b/drivers/soc/fsl/qbman/dpaa_sys.c
new file mode 100644
index 000000000000..9436aa83ff1b
--- /dev/null
+++ b/drivers/soc/fsl/qbman/dpaa_sys.c
@@ -0,0 +1,78 @@
1/* Copyright 2017 NXP Semiconductor, Inc.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 * * Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * * Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 * * Neither the name of NXP Semiconductor nor the
11 * names of its contributors may be used to endorse or promote products
12 * derived from this software without specific prior written permission.
13 *
14 * ALTERNATIVELY, this software may be distributed under the terms of the
15 * GNU General Public License ("GPL") as published by the Free Software
16 * Foundation, either version 2 of that License or (at your option) any
17 * later version.
18 *
19 * THIS SOFTWARE IS PROVIDED BY NXP Semiconductor ``AS IS'' AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL NXP Semiconductor BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <linux/dma-mapping.h>
32#include "dpaa_sys.h"
33
34/*
35 * Initialize a devices private memory region
36 */
37int qbman_init_private_mem(struct device *dev, int idx, dma_addr_t *addr,
38 size_t *size)
39{
40 int ret;
41 struct device_node *mem_node;
42 u64 size64;
43
44 ret = of_reserved_mem_device_init_by_idx(dev, dev->of_node, idx);
45 if (ret) {
46 dev_err(dev,
47 "of_reserved_mem_device_init_by_idx(%d) failed 0x%x\n",
48 idx, ret);
49 return -ENODEV;
50 }
51 mem_node = of_parse_phandle(dev->of_node, "memory-region", 0);
52 if (mem_node) {
53 ret = of_property_read_u64(mem_node, "size", &size64);
54 if (ret) {
55 dev_err(dev, "of_address_to_resource fails 0x%x\n",
56 ret);
57 return -ENODEV;
58 }
59 *size = size64;
60 } else {
61 dev_err(dev, "No memory-region found for index %d\n", idx);
62 return -ENODEV;
63 }
64
65 if (!dma_zalloc_coherent(dev, *size, addr, 0)) {
66 dev_err(dev, "DMA Alloc memory failed\n");
67 return -ENODEV;
68 }
69
70 /*
71 * Disassociate the reserved memory area from the device
72 * because a device can only have one DMA memory area. This
73 * should be fine since the memory is allocated and initialized
74 * and only ever accessed by the QBMan device from now on
75 */
76 of_reserved_mem_device_release(dev);
77 return 0;
78}
diff --git a/drivers/soc/fsl/qbman/dpaa_sys.h b/drivers/soc/fsl/qbman/dpaa_sys.h
index 2ce394aa4c95..9f379000da85 100644
--- a/drivers/soc/fsl/qbman/dpaa_sys.h
+++ b/drivers/soc/fsl/qbman/dpaa_sys.h
@@ -44,23 +44,21 @@
44#include <linux/prefetch.h> 44#include <linux/prefetch.h>
45#include <linux/genalloc.h> 45#include <linux/genalloc.h>
46#include <asm/cacheflush.h> 46#include <asm/cacheflush.h>
47#include <linux/io.h>
48#include <linux/delay.h>
47 49
48/* For 2-element tables related to cache-inhibited and cache-enabled mappings */ 50/* For 2-element tables related to cache-inhibited and cache-enabled mappings */
49#define DPAA_PORTAL_CE 0 51#define DPAA_PORTAL_CE 0
50#define DPAA_PORTAL_CI 1 52#define DPAA_PORTAL_CI 1
51 53
52#if (L1_CACHE_BYTES != 32) && (L1_CACHE_BYTES != 64)
53#error "Unsupported Cacheline Size"
54#endif
55
56static inline void dpaa_flush(void *p) 54static inline void dpaa_flush(void *p)
57{ 55{
56 /*
57 * Only PPC needs to flush the cache currently - on ARM the mapping
58 * is non cacheable
59 */
58#ifdef CONFIG_PPC 60#ifdef CONFIG_PPC
59 flush_dcache_range((unsigned long)p, (unsigned long)p+64); 61 flush_dcache_range((unsigned long)p, (unsigned long)p+64);
60#elif defined(CONFIG_ARM32)
61 __cpuc_flush_dcache_area(p, 64);
62#elif defined(CONFIG_ARM64)
63 __flush_dcache_area(p, 64);
64#endif 62#endif
65} 63}
66 64
@@ -102,4 +100,15 @@ static inline u8 dpaa_cyc_diff(u8 ringsize, u8 first, u8 last)
102/* Offset applied to genalloc pools due to zero being an error return */ 100/* Offset applied to genalloc pools due to zero being an error return */
103#define DPAA_GENALLOC_OFF 0x80000000 101#define DPAA_GENALLOC_OFF 0x80000000
104 102
103/* Initialize the devices private memory region */
104int qbman_init_private_mem(struct device *dev, int idx, dma_addr_t *addr,
105 size_t *size);
106
107/* memremap() attributes for different platforms */
108#ifdef CONFIG_PPC
109#define QBMAN_MEMREMAP_ATTR MEMREMAP_WB
110#else
111#define QBMAN_MEMREMAP_ATTR MEMREMAP_WC
112#endif
113
105#endif /* __DPAA_SYS_H */ 114#endif /* __DPAA_SYS_H */
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 18eefc3f1abe..e4f5bb056fd2 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -41,6 +41,43 @@
41 41
42/* Portal register assists */ 42/* Portal register assists */
43 43
44#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
45/* Cache-inhibited register offsets */
46#define QM_REG_EQCR_PI_CINH 0x3000
47#define QM_REG_EQCR_CI_CINH 0x3040
48#define QM_REG_EQCR_ITR 0x3080
49#define QM_REG_DQRR_PI_CINH 0x3100
50#define QM_REG_DQRR_CI_CINH 0x3140
51#define QM_REG_DQRR_ITR 0x3180
52#define QM_REG_DQRR_DCAP 0x31C0
53#define QM_REG_DQRR_SDQCR 0x3200
54#define QM_REG_DQRR_VDQCR 0x3240
55#define QM_REG_DQRR_PDQCR 0x3280
56#define QM_REG_MR_PI_CINH 0x3300
57#define QM_REG_MR_CI_CINH 0x3340
58#define QM_REG_MR_ITR 0x3380
59#define QM_REG_CFG 0x3500
60#define QM_REG_ISR 0x3600
61#define QM_REG_IER 0x3640
62#define QM_REG_ISDR 0x3680
63#define QM_REG_IIR 0x36C0
64#define QM_REG_ITPR 0x3740
65
66/* Cache-enabled register offsets */
67#define QM_CL_EQCR 0x0000
68#define QM_CL_DQRR 0x1000
69#define QM_CL_MR 0x2000
70#define QM_CL_EQCR_PI_CENA 0x3000
71#define QM_CL_EQCR_CI_CENA 0x3040
72#define QM_CL_DQRR_PI_CENA 0x3100
73#define QM_CL_DQRR_CI_CENA 0x3140
74#define QM_CL_MR_PI_CENA 0x3300
75#define QM_CL_MR_CI_CENA 0x3340
76#define QM_CL_CR 0x3800
77#define QM_CL_RR0 0x3900
78#define QM_CL_RR1 0x3940
79
80#else
44/* Cache-inhibited register offsets */ 81/* Cache-inhibited register offsets */
45#define QM_REG_EQCR_PI_CINH 0x0000 82#define QM_REG_EQCR_PI_CINH 0x0000
46#define QM_REG_EQCR_CI_CINH 0x0004 83#define QM_REG_EQCR_CI_CINH 0x0004
@@ -75,6 +112,7 @@
75#define QM_CL_CR 0x3800 112#define QM_CL_CR 0x3800
76#define QM_CL_RR0 0x3900 113#define QM_CL_RR0 0x3900
77#define QM_CL_RR1 0x3940 114#define QM_CL_RR1 0x3940
115#endif
78 116
79/* 117/*
80 * BTW, the drivers (and h/w programming model) already obtain the required 118 * BTW, the drivers (and h/w programming model) already obtain the required
@@ -300,7 +338,8 @@ struct qm_mc {
300}; 338};
301 339
302struct qm_addr { 340struct qm_addr {
303 void __iomem *ce; /* cache-enabled */ 341 void *ce; /* cache-enabled */
342 __be32 *ce_be; /* same value as above but for direct access */
304 void __iomem *ci; /* cache-inhibited */ 343 void __iomem *ci; /* cache-inhibited */
305}; 344};
306 345
@@ -321,12 +360,12 @@ struct qm_portal {
321/* Cache-inhibited register access. */ 360/* Cache-inhibited register access. */
322static inline u32 qm_in(struct qm_portal *p, u32 offset) 361static inline u32 qm_in(struct qm_portal *p, u32 offset)
323{ 362{
324 return be32_to_cpu(__raw_readl(p->addr.ci + offset)); 363 return ioread32be(p->addr.ci + offset);
325} 364}
326 365
327static inline void qm_out(struct qm_portal *p, u32 offset, u32 val) 366static inline void qm_out(struct qm_portal *p, u32 offset, u32 val)
328{ 367{
329 __raw_writel(cpu_to_be32(val), p->addr.ci + offset); 368 iowrite32be(val, p->addr.ci + offset);
330} 369}
331 370
332/* Cache Enabled Portal Access */ 371/* Cache Enabled Portal Access */
@@ -342,7 +381,7 @@ static inline void qm_cl_touch_ro(struct qm_portal *p, u32 offset)
342 381
343static inline u32 qm_ce_in(struct qm_portal *p, u32 offset) 382static inline u32 qm_ce_in(struct qm_portal *p, u32 offset)
344{ 383{
345 return be32_to_cpu(__raw_readl(p->addr.ce + offset)); 384 return be32_to_cpu(*(p->addr.ce_be + (offset/4)));
346} 385}
347 386
348/* --- EQCR API --- */ 387/* --- EQCR API --- */
@@ -646,11 +685,7 @@ static inline void qm_dqrr_pvb_update(struct qm_portal *portal)
646 */ 685 */
647 dpaa_invalidate_touch_ro(res); 686 dpaa_invalidate_touch_ro(res);
648#endif 687#endif
649 /* 688 if ((res->verb & QM_DQRR_VERB_VBIT) == dqrr->vbit) {
650 * when accessing 'verb', use __raw_readb() to ensure that compiler
651 * inlining doesn't try to optimise out "excess reads".
652 */
653 if ((__raw_readb(&res->verb) & QM_DQRR_VERB_VBIT) == dqrr->vbit) {
654 dqrr->pi = (dqrr->pi + 1) & (QM_DQRR_SIZE - 1); 689 dqrr->pi = (dqrr->pi + 1) & (QM_DQRR_SIZE - 1);
655 if (!dqrr->pi) 690 if (!dqrr->pi)
656 dqrr->vbit ^= QM_DQRR_VERB_VBIT; 691 dqrr->vbit ^= QM_DQRR_VERB_VBIT;
@@ -777,11 +812,8 @@ static inline void qm_mr_pvb_update(struct qm_portal *portal)
777 union qm_mr_entry *res = qm_cl(mr->ring, mr->pi); 812 union qm_mr_entry *res = qm_cl(mr->ring, mr->pi);
778 813
779 DPAA_ASSERT(mr->pmode == qm_mr_pvb); 814 DPAA_ASSERT(mr->pmode == qm_mr_pvb);
780 /* 815
781 * when accessing 'verb', use __raw_readb() to ensure that compiler 816 if ((res->verb & QM_MR_VERB_VBIT) == mr->vbit) {
782 * inlining doesn't try to optimise out "excess reads".
783 */
784 if ((__raw_readb(&res->verb) & QM_MR_VERB_VBIT) == mr->vbit) {
785 mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1); 817 mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
786 if (!mr->pi) 818 if (!mr->pi)
787 mr->vbit ^= QM_MR_VERB_VBIT; 819 mr->vbit ^= QM_MR_VERB_VBIT;
@@ -822,7 +854,7 @@ static inline int qm_mc_init(struct qm_portal *portal)
822 854
823 mc->cr = portal->addr.ce + QM_CL_CR; 855 mc->cr = portal->addr.ce + QM_CL_CR;
824 mc->rr = portal->addr.ce + QM_CL_RR0; 856 mc->rr = portal->addr.ce + QM_CL_RR0;
825 mc->rridx = (__raw_readb(&mc->cr->_ncw_verb) & QM_MCC_VERB_VBIT) 857 mc->rridx = (mc->cr->_ncw_verb & QM_MCC_VERB_VBIT)
826 ? 0 : 1; 858 ? 0 : 1;
827 mc->vbit = mc->rridx ? QM_MCC_VERB_VBIT : 0; 859 mc->vbit = mc->rridx ? QM_MCC_VERB_VBIT : 0;
828#ifdef CONFIG_FSL_DPAA_CHECKING 860#ifdef CONFIG_FSL_DPAA_CHECKING
@@ -880,7 +912,7 @@ static inline union qm_mc_result *qm_mc_result(struct qm_portal *portal)
880 * its command is submitted and completed. This includes the valid-bit, 912 * its command is submitted and completed. This includes the valid-bit,
881 * in case you were wondering... 913 * in case you were wondering...
882 */ 914 */
883 if (!__raw_readb(&rr->verb)) { 915 if (!rr->verb) {
884 dpaa_invalidate_touch_ro(rr); 916 dpaa_invalidate_touch_ro(rr);
885 return NULL; 917 return NULL;
886 } 918 }
@@ -909,12 +941,12 @@ static inline int qm_mc_result_timeout(struct qm_portal *portal,
909 941
910static inline void fq_set(struct qman_fq *fq, u32 mask) 942static inline void fq_set(struct qman_fq *fq, u32 mask)
911{ 943{
912 set_bits(mask, &fq->flags); 944 fq->flags |= mask;
913} 945}
914 946
915static inline void fq_clear(struct qman_fq *fq, u32 mask) 947static inline void fq_clear(struct qman_fq *fq, u32 mask)
916{ 948{
917 clear_bits(mask, &fq->flags); 949 fq->flags &= ~mask;
918} 950}
919 951
920static inline int fq_isset(struct qman_fq *fq, u32 mask) 952static inline int fq_isset(struct qman_fq *fq, u32 mask)
@@ -1084,11 +1116,7 @@ loop:
1084 * entries well before the ring has been fully consumed, so 1116 * entries well before the ring has been fully consumed, so
1085 * we're being *really* paranoid here. 1117 * we're being *really* paranoid here.
1086 */ 1118 */
1087 u64 now, then = jiffies; 1119 msleep(1);
1088
1089 do {
1090 now = jiffies;
1091 } while ((then + 10000) > now);
1092 msg = qm_mr_current(p); 1120 msg = qm_mr_current(p);
1093 if (!msg) 1121 if (!msg)
1094 return 0; 1122 return 0;
@@ -1124,8 +1152,9 @@ static int qman_create_portal(struct qman_portal *portal,
1124 * config, everything that follows depends on it and "config" is more 1152 * config, everything that follows depends on it and "config" is more
1125 * for (de)reference 1153 * for (de)reference
1126 */ 1154 */
1127 p->addr.ce = c->addr_virt[DPAA_PORTAL_CE]; 1155 p->addr.ce = c->addr_virt_ce;
1128 p->addr.ci = c->addr_virt[DPAA_PORTAL_CI]; 1156 p->addr.ce_be = c->addr_virt_ce;
1157 p->addr.ci = c->addr_virt_ci;
1129 /* 1158 /*
1130 * If CI-stashing is used, the current defaults use a threshold of 3, 1159 * If CI-stashing is used, the current defaults use a threshold of 3,
1131 * and stash with high-than-DQRR priority. 1160 * and stash with high-than-DQRR priority.
@@ -1566,7 +1595,7 @@ void qman_p_irqsource_add(struct qman_portal *p, u32 bits)
1566 unsigned long irqflags; 1595 unsigned long irqflags;
1567 1596
1568 local_irq_save(irqflags); 1597 local_irq_save(irqflags);
1569 set_bits(bits & QM_PIRQ_VISIBLE, &p->irq_sources); 1598 p->irq_sources |= bits & QM_PIRQ_VISIBLE;
1570 qm_out(&p->p, QM_REG_IER, p->irq_sources); 1599 qm_out(&p->p, QM_REG_IER, p->irq_sources);
1571 local_irq_restore(irqflags); 1600 local_irq_restore(irqflags);
1572} 1601}
@@ -1589,7 +1618,7 @@ void qman_p_irqsource_remove(struct qman_portal *p, u32 bits)
1589 */ 1618 */
1590 local_irq_save(irqflags); 1619 local_irq_save(irqflags);
1591 bits &= QM_PIRQ_VISIBLE; 1620 bits &= QM_PIRQ_VISIBLE;
1592 clear_bits(bits, &p->irq_sources); 1621 p->irq_sources &= ~bits;
1593 qm_out(&p->p, QM_REG_IER, p->irq_sources); 1622 qm_out(&p->p, QM_REG_IER, p->irq_sources);
1594 ier = qm_in(&p->p, QM_REG_IER); 1623 ier = qm_in(&p->p, QM_REG_IER);
1595 /* 1624 /*
diff --git a/drivers/soc/fsl/qbman/qman_ccsr.c b/drivers/soc/fsl/qbman/qman_ccsr.c
index 835ce947ffca..79cba58387a5 100644
--- a/drivers/soc/fsl/qbman/qman_ccsr.c
+++ b/drivers/soc/fsl/qbman/qman_ccsr.c
@@ -401,21 +401,42 @@ static int qm_init_pfdr(struct device *dev, u32 pfdr_start, u32 num)
401} 401}
402 402
403/* 403/*
404 * Ideally we would use the DMA API to turn rmem->base into a DMA address 404 * QMan needs two global memory areas initialized at boot time:
405 * (especially if iommu translations ever get involved). Unfortunately, the 405 * 1) FQD: Frame Queue Descriptors used to manage frame queues
406 * DMA API currently does not allow mapping anything that is not backed with 406 * 2) PFDR: Packed Frame Queue Descriptor Records used to store frames
407 * a struct page. 407 * Both areas are reserved using the device tree reserved memory framework
408 * and the addresses and sizes are initialized when the QMan device is probed
408 */ 409 */
409static dma_addr_t fqd_a, pfdr_a; 410static dma_addr_t fqd_a, pfdr_a;
410static size_t fqd_sz, pfdr_sz; 411static size_t fqd_sz, pfdr_sz;
411 412
413#ifdef CONFIG_PPC
414/*
415 * Support for PPC Device Tree backward compatibility when compatible
416 * string is set to fsl-qman-fqd and fsl-qman-pfdr
417 */
418static int zero_priv_mem(phys_addr_t addr, size_t sz)
419{
420 /* map as cacheable, non-guarded */
421 void __iomem *tmpp = ioremap_prot(addr, sz, 0);
422
423 if (!tmpp)
424 return -ENOMEM;
425
426 memset_io(tmpp, 0, sz);
427 flush_dcache_range((unsigned long)tmpp,
428 (unsigned long)tmpp + sz);
429 iounmap(tmpp);
430
431 return 0;
432}
433
412static int qman_fqd(struct reserved_mem *rmem) 434static int qman_fqd(struct reserved_mem *rmem)
413{ 435{
414 fqd_a = rmem->base; 436 fqd_a = rmem->base;
415 fqd_sz = rmem->size; 437 fqd_sz = rmem->size;
416 438
417 WARN_ON(!(fqd_a && fqd_sz)); 439 WARN_ON(!(fqd_a && fqd_sz));
418
419 return 0; 440 return 0;
420} 441}
421RESERVEDMEM_OF_DECLARE(qman_fqd, "fsl,qman-fqd", qman_fqd); 442RESERVEDMEM_OF_DECLARE(qman_fqd, "fsl,qman-fqd", qman_fqd);
@@ -431,32 +452,13 @@ static int qman_pfdr(struct reserved_mem *rmem)
431} 452}
432RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman_pfdr); 453RESERVEDMEM_OF_DECLARE(qman_pfdr, "fsl,qman-pfdr", qman_pfdr);
433 454
455#endif
456
434static unsigned int qm_get_fqid_maxcnt(void) 457static unsigned int qm_get_fqid_maxcnt(void)
435{ 458{
436 return fqd_sz / 64; 459 return fqd_sz / 64;
437} 460}
438 461
439/*
440 * Flush this memory range from data cache so that QMAN originated
441 * transactions for this memory region could be marked non-coherent.
442 */
443static int zero_priv_mem(struct device *dev, struct device_node *node,
444 phys_addr_t addr, size_t sz)
445{
446 /* map as cacheable, non-guarded */
447 void __iomem *tmpp = ioremap_prot(addr, sz, 0);
448
449 if (!tmpp)
450 return -ENOMEM;
451
452 memset_io(tmpp, 0, sz);
453 flush_dcache_range((unsigned long)tmpp,
454 (unsigned long)tmpp + sz);
455 iounmap(tmpp);
456
457 return 0;
458}
459
460static void log_edata_bits(struct device *dev, u32 bit_count) 462static void log_edata_bits(struct device *dev, u32 bit_count)
461{ 463{
462 u32 i, j, mask = 0xffffffff; 464 u32 i, j, mask = 0xffffffff;
@@ -717,6 +719,8 @@ static int fsl_qman_probe(struct platform_device *pdev)
717 qman_ip_rev = QMAN_REV30; 719 qman_ip_rev = QMAN_REV30;
718 else if (major == 3 && minor == 1) 720 else if (major == 3 && minor == 1)
719 qman_ip_rev = QMAN_REV31; 721 qman_ip_rev = QMAN_REV31;
722 else if (major == 3 && minor == 2)
723 qman_ip_rev = QMAN_REV32;
720 else { 724 else {
721 dev_err(dev, "Unknown QMan version\n"); 725 dev_err(dev, "Unknown QMan version\n");
722 return -ENODEV; 726 return -ENODEV;
@@ -727,10 +731,41 @@ static int fsl_qman_probe(struct platform_device *pdev)
727 qm_channel_caam = QMAN_CHANNEL_CAAM_REV3; 731 qm_channel_caam = QMAN_CHANNEL_CAAM_REV3;
728 } 732 }
729 733
730 ret = zero_priv_mem(dev, node, fqd_a, fqd_sz); 734 if (fqd_a) {
731 WARN_ON(ret); 735#ifdef CONFIG_PPC
732 if (ret) 736 /*
733 return -ENODEV; 737 * For PPC backward DT compatibility
738 * FQD memory MUST be zero'd by software
739 */
740 zero_priv_mem(fqd_a, fqd_sz);
741#else
742 WARN(1, "Unexpected architecture using non shared-dma-mem reservations");
743#endif
744 } else {
745 /*
746 * Order of memory regions is assumed as FQD followed by PFDR
747 * in order to ensure allocations from the correct regions the
748 * driver initializes then allocates each piece in order
749 */
750 ret = qbman_init_private_mem(dev, 0, &fqd_a, &fqd_sz);
751 if (ret) {
752 dev_err(dev, "qbman_init_private_mem() for FQD failed 0x%x\n",
753 ret);
754 return -ENODEV;
755 }
756 }
757 dev_dbg(dev, "Allocated FQD 0x%llx 0x%zx\n", fqd_a, fqd_sz);
758
759 if (!pfdr_a) {
760 /* Setup PFDR memory */
761 ret = qbman_init_private_mem(dev, 1, &pfdr_a, &pfdr_sz);
762 if (ret) {
763 dev_err(dev, "qbman_init_private_mem() for PFDR failed 0x%x\n",
764 ret);
765 return -ENODEV;
766 }
767 }
768 dev_dbg(dev, "Allocated PFDR 0x%llx 0x%zx\n", pfdr_a, pfdr_sz);
734 769
735 ret = qman_init_ccsr(dev); 770 ret = qman_init_ccsr(dev);
736 if (ret) { 771 if (ret) {
diff --git a/drivers/soc/fsl/qbman/qman_portal.c b/drivers/soc/fsl/qbman/qman_portal.c
index cbacdf4f98ed..a120002b630e 100644
--- a/drivers/soc/fsl/qbman/qman_portal.c
+++ b/drivers/soc/fsl/qbman/qman_portal.c
@@ -224,7 +224,6 @@ static int qman_portal_probe(struct platform_device *pdev)
224 struct device_node *node = dev->of_node; 224 struct device_node *node = dev->of_node;
225 struct qm_portal_config *pcfg; 225 struct qm_portal_config *pcfg;
226 struct resource *addr_phys[2]; 226 struct resource *addr_phys[2];
227 void __iomem *va;
228 int irq, cpu, err; 227 int irq, cpu, err;
229 u32 val; 228 u32 val;
230 229
@@ -262,23 +261,21 @@ static int qman_portal_probe(struct platform_device *pdev)
262 } 261 }
263 pcfg->irq = irq; 262 pcfg->irq = irq;
264 263
265 va = ioremap_prot(addr_phys[0]->start, resource_size(addr_phys[0]), 0); 264 pcfg->addr_virt_ce = memremap(addr_phys[0]->start,
266 if (!va) { 265 resource_size(addr_phys[0]),
267 dev_err(dev, "ioremap::CE failed\n"); 266 QBMAN_MEMREMAP_ATTR);
267 if (!pcfg->addr_virt_ce) {
268 dev_err(dev, "memremap::CE failed\n");
268 goto err_ioremap1; 269 goto err_ioremap1;
269 } 270 }
270 271
271 pcfg->addr_virt[DPAA_PORTAL_CE] = va; 272 pcfg->addr_virt_ci = ioremap(addr_phys[1]->start,
272 273 resource_size(addr_phys[1]));
273 va = ioremap_prot(addr_phys[1]->start, resource_size(addr_phys[1]), 274 if (!pcfg->addr_virt_ci) {
274 _PAGE_GUARDED | _PAGE_NO_CACHE);
275 if (!va) {
276 dev_err(dev, "ioremap::CI failed\n"); 275 dev_err(dev, "ioremap::CI failed\n");
277 goto err_ioremap2; 276 goto err_ioremap2;
278 } 277 }
279 278
280 pcfg->addr_virt[DPAA_PORTAL_CI] = va;
281
282 pcfg->pools = qm_get_pools_sdqcr(); 279 pcfg->pools = qm_get_pools_sdqcr();
283 280
284 spin_lock(&qman_lock); 281 spin_lock(&qman_lock);
@@ -310,9 +307,9 @@ static int qman_portal_probe(struct platform_device *pdev)
310 return 0; 307 return 0;
311 308
312err_portal_init: 309err_portal_init:
313 iounmap(pcfg->addr_virt[DPAA_PORTAL_CI]); 310 iounmap(pcfg->addr_virt_ci);
314err_ioremap2: 311err_ioremap2:
315 iounmap(pcfg->addr_virt[DPAA_PORTAL_CE]); 312 memunmap(pcfg->addr_virt_ce);
316err_ioremap1: 313err_ioremap1:
317 return -ENXIO; 314 return -ENXIO;
318} 315}
diff --git a/drivers/soc/fsl/qbman/qman_priv.h b/drivers/soc/fsl/qbman/qman_priv.h
index 5fe9faf6232e..75a8f905f8f7 100644
--- a/drivers/soc/fsl/qbman/qman_priv.h
+++ b/drivers/soc/fsl/qbman/qman_priv.h
@@ -28,8 +28,6 @@
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
32
33#include "dpaa_sys.h" 31#include "dpaa_sys.h"
34 32
35#include <soc/fsl/qman.h> 33#include <soc/fsl/qman.h>
@@ -155,11 +153,9 @@ static inline void qman_cgrs_xor(struct qman_cgrs *dest,
155void qman_init_cgr_all(void); 153void qman_init_cgr_all(void);
156 154
157struct qm_portal_config { 155struct qm_portal_config {
158 /* 156 /* Portal addresses */
159 * Corenet portal addresses; 157 void *addr_virt_ce;
160 * [0]==cache-enabled, [1]==cache-inhibited. 158 void __iomem *addr_virt_ci;
161 */
162 void __iomem *addr_virt[2];
163 struct device *dev; 159 struct device *dev;
164 struct iommu_domain *iommu_domain; 160 struct iommu_domain *iommu_domain;
165 /* Allow these to be joined in lists */ 161 /* Allow these to be joined in lists */
@@ -187,6 +183,7 @@ struct qm_portal_config {
187#define QMAN_REV20 0x0200 183#define QMAN_REV20 0x0200
188#define QMAN_REV30 0x0300 184#define QMAN_REV30 0x0300
189#define QMAN_REV31 0x0301 185#define QMAN_REV31 0x0301
186#define QMAN_REV32 0x0302
190extern u16 qman_ip_rev; /* 0 if uninitialised, otherwise QMAN_REVx */ 187extern u16 qman_ip_rev; /* 0 if uninitialised, otherwise QMAN_REVx */
191 188
192#define QM_FQID_RANGE_START 1 /* FQID 0 reserved for internal use */ 189#define QM_FQID_RANGE_START 1 /* FQID 0 reserved for internal use */
diff --git a/drivers/soc/fsl/qbman/qman_test.h b/drivers/soc/fsl/qbman/qman_test.h
index d5f8cb2260dc..41bdbc48cade 100644
--- a/drivers/soc/fsl/qbman/qman_test.h
+++ b/drivers/soc/fsl/qbman/qman_test.h
@@ -30,7 +30,5 @@
30 30
31#include "qman_priv.h" 31#include "qman_priv.h"
32 32
33#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
34
35int qman_test_stash(void); 33int qman_test_stash(void);
36int qman_test_api(void); 34int qman_test_api(void);