80
80
#define PCIE_ATU_FUNC (x ) (((x) & 0x7) << 16)
81
81
#define PCIE_ATU_UPPER_TARGET 0x91C
82
82
83
+ /*
84
+ * iATU Unroll-specific register definitions
85
+ * From 4.80 core version the address translation will be made by unroll
86
+ */
87
+ #define PCIE_ATU_UNR_REGION_CTRL1 0x00
88
+ #define PCIE_ATU_UNR_REGION_CTRL2 0x04
89
+ #define PCIE_ATU_UNR_LOWER_BASE 0x08
90
+ #define PCIE_ATU_UNR_UPPER_BASE 0x0C
91
+ #define PCIE_ATU_UNR_LIMIT 0x10
92
+ #define PCIE_ATU_UNR_LOWER_TARGET 0x14
93
+ #define PCIE_ATU_UNR_UPPER_TARGET 0x18
94
+
95
+ /* Register address builder */
96
+ #define PCIE_GET_ATU_OUTB_UNR_REG_OFFSET (region ) ((0x3 << 20) | (region << 9))
97
+
83
98
/* PCIe Port Logic registers */
84
99
#define PLR_OFFSET 0x700
85
100
#define PCIE_PHY_DEBUG_R1 (PLR_OFFSET + 0x2c)
@@ -141,6 +156,27 @@ static inline void dw_pcie_writel_rc(struct pcie_port *pp, u32 val, u32 reg)
141
156
writel (val , pp -> dbi_base + reg );
142
157
}
143
158
159
+ static inline u32 dw_pcie_readl_unroll (struct pcie_port * pp , u32 index , u32 reg )
160
+ {
161
+ u32 offset = PCIE_GET_ATU_OUTB_UNR_REG_OFFSET (index );
162
+
163
+ if (pp -> ops -> readl_rc )
164
+ return pp -> ops -> readl_rc (pp , pp -> dbi_base + offset + reg );
165
+
166
+ return readl (pp -> dbi_base + offset + reg );
167
+ }
168
+
169
+ static inline void dw_pcie_writel_unroll (struct pcie_port * pp , u32 index ,
170
+ u32 val , u32 reg )
171
+ {
172
+ u32 offset = PCIE_GET_ATU_OUTB_UNR_REG_OFFSET (index );
173
+
174
+ if (pp -> ops -> writel_rc )
175
+ pp -> ops -> writel_rc (pp , val , pp -> dbi_base + offset + reg );
176
+ else
177
+ writel (val , pp -> dbi_base + offset + reg );
178
+ }
179
+
144
180
static int dw_pcie_rd_own_conf (struct pcie_port * pp , int where , int size ,
145
181
u32 * val )
146
182
{
@@ -164,23 +200,49 @@ static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index,
164
200
{
165
201
u32 retries , val ;
166
202
167
- dw_pcie_writel_rc (pp , PCIE_ATU_REGION_OUTBOUND | index ,
168
- PCIE_ATU_VIEWPORT );
169
- dw_pcie_writel_rc (pp , lower_32_bits (cpu_addr ), PCIE_ATU_LOWER_BASE );
170
- dw_pcie_writel_rc (pp , upper_32_bits (cpu_addr ), PCIE_ATU_UPPER_BASE );
171
- dw_pcie_writel_rc (pp , lower_32_bits (cpu_addr + size - 1 ),
172
- PCIE_ATU_LIMIT );
173
- dw_pcie_writel_rc (pp , lower_32_bits (pci_addr ), PCIE_ATU_LOWER_TARGET );
174
- dw_pcie_writel_rc (pp , upper_32_bits (pci_addr ), PCIE_ATU_UPPER_TARGET );
175
- dw_pcie_writel_rc (pp , type , PCIE_ATU_CR1 );
176
- dw_pcie_writel_rc (pp , PCIE_ATU_ENABLE , PCIE_ATU_CR2 );
203
+ if (pp -> iatu_unroll_enabled ) {
204
+ dw_pcie_writel_unroll (pp , index ,
205
+ lower_32_bits (cpu_addr ), PCIE_ATU_UNR_LOWER_BASE );
206
+ dw_pcie_writel_unroll (pp , index ,
207
+ upper_32_bits (cpu_addr ), PCIE_ATU_UNR_UPPER_BASE );
208
+ dw_pcie_writel_unroll (pp , index ,
209
+ lower_32_bits (cpu_addr + size - 1 ), PCIE_ATU_UNR_LIMIT );
210
+ dw_pcie_writel_unroll (pp , index ,
211
+ lower_32_bits (pci_addr ), PCIE_ATU_UNR_LOWER_TARGET );
212
+ dw_pcie_writel_unroll (pp , index ,
213
+ upper_32_bits (pci_addr ), PCIE_ATU_UNR_UPPER_TARGET );
214
+ dw_pcie_writel_unroll (pp , index ,
215
+ type , PCIE_ATU_UNR_REGION_CTRL1 );
216
+ dw_pcie_writel_unroll (pp , index ,
217
+ PCIE_ATU_ENABLE , PCIE_ATU_UNR_REGION_CTRL2 );
218
+ } else {
219
+ dw_pcie_writel_rc (pp , PCIE_ATU_REGION_OUTBOUND | index ,
220
+ PCIE_ATU_VIEWPORT );
221
+ dw_pcie_writel_rc (pp , lower_32_bits (cpu_addr ),
222
+ PCIE_ATU_LOWER_BASE );
223
+ dw_pcie_writel_rc (pp , upper_32_bits (cpu_addr ),
224
+ PCIE_ATU_UPPER_BASE );
225
+ dw_pcie_writel_rc (pp , lower_32_bits (cpu_addr + size - 1 ),
226
+ PCIE_ATU_LIMIT );
227
+ dw_pcie_writel_rc (pp , lower_32_bits (pci_addr ),
228
+ PCIE_ATU_LOWER_TARGET );
229
+ dw_pcie_writel_rc (pp , upper_32_bits (pci_addr ),
230
+ PCIE_ATU_UPPER_TARGET );
231
+ dw_pcie_writel_rc (pp , type , PCIE_ATU_CR1 );
232
+ dw_pcie_writel_rc (pp , PCIE_ATU_ENABLE , PCIE_ATU_CR2 );
233
+ }
177
234
178
235
/*
179
236
* Make sure ATU enable takes effect before any subsequent config
180
237
* and I/O accesses.
181
238
*/
182
239
for (retries = 0 ; retries < LINK_WAIT_MAX_IATU_RETRIES ; retries ++ ) {
183
- val = dw_pcie_readl_rc (pp , PCIE_ATU_CR2 );
240
+ if (pp -> iatu_unroll_enabled )
241
+ val = dw_pcie_readl_unroll (pp , index ,
242
+ PCIE_ATU_UNR_REGION_CTRL2 );
243
+ else
244
+ val = dw_pcie_readl_rc (pp , PCIE_ATU_CR2 );
245
+
184
246
if (val == PCIE_ATU_ENABLE )
185
247
return ;
186
248
@@ -445,6 +507,17 @@ static const struct irq_domain_ops msi_domain_ops = {
445
507
.map = dw_pcie_msi_map ,
446
508
};
447
509
510
+ static u8 dw_pcie_iatu_unroll_enabled (struct pcie_port * pp )
511
+ {
512
+ u32 val ;
513
+
514
+ val = dw_pcie_readl_rc (pp , PCIE_ATU_VIEWPORT );
515
+ if (val == 0xffffffff )
516
+ return 1 ;
517
+
518
+ return 0 ;
519
+ }
520
+
448
521
int dw_pcie_host_init (struct pcie_port * pp )
449
522
{
450
523
struct device_node * np = pp -> dev -> of_node ;
@@ -561,6 +634,8 @@ int dw_pcie_host_init(struct pcie_port *pp)
561
634
}
562
635
}
563
636
637
+ pp -> iatu_unroll_enabled = dw_pcie_iatu_unroll_enabled (pp );
638
+
564
639
if (pp -> ops -> host_init )
565
640
pp -> ops -> host_init (pp );
566
641
0 commit comments