@@ -51,6 +51,7 @@ static struct resource sh7786_pci0_resources[] = {
5151 .name = "PCIe0 MEM 2" ,
5252 .start = 0xfe100000 ,
5353 .end = 0xfe100000 + SZ_1M - 1 ,
54+ .flags = IORESOURCE_MEM ,
5455 },
5556};
5657
@@ -74,6 +75,7 @@ static struct resource sh7786_pci1_resources[] = {
7475 .name = "PCIe1 MEM 2" ,
7576 .start = 0xfe300000 ,
7677 .end = 0xfe300000 + SZ_1M - 1 ,
78+ .flags = IORESOURCE_MEM ,
7779 },
7880};
7981
@@ -82,6 +84,7 @@ static struct resource sh7786_pci2_resources[] = {
8284 .name = "PCIe2 IO" ,
8385 .start = 0xfc800000 ,
8486 .end = 0xfc800000 + SZ_4M - 1 ,
87+ .flags = IORESOURCE_IO ,
8588 }, {
8689 .name = "PCIe2 MEM 0" ,
8790 .start = 0x80000000 ,
@@ -96,6 +99,7 @@ static struct resource sh7786_pci2_resources[] = {
9699 .name = "PCIe2 MEM 2" ,
97100 .start = 0xfcd00000 ,
98101 .end = 0xfcd00000 + SZ_1M - 1 ,
102+ .flags = IORESOURCE_MEM ,
99103 },
100104};
101105
@@ -204,16 +208,26 @@ static int phy_init(struct pci_channel *chan)
204208 return - ETIMEDOUT ;
205209}
206210
211+ static void pcie_reset (struct sh7786_pcie_port * port )
212+ {
213+ struct pci_channel * chan = port -> hose ;
214+
215+ pci_write_reg (chan , 1 , SH4A_PCIESRSTR );
216+ pci_write_reg (chan , 0 , SH4A_PCIETCTLR );
217+ pci_write_reg (chan , 0 , SH4A_PCIESRSTR );
218+ pci_write_reg (chan , 0 , SH4A_PCIETXVC0SR );
219+ }
220+
207221static int pcie_init (struct sh7786_pcie_port * port )
208222{
209223 struct pci_channel * chan = port -> hose ;
210224 unsigned int data ;
211225 phys_addr_t memphys ;
212226 size_t memsize ;
213- int ret , i ;
227+ int ret , i , win ;
214228
215229 /* Begin initialization */
216- pci_write_reg ( chan , 0 , SH4A_PCIETCTLR );
230+ pcie_reset ( port );
217231
218232 /* Initialize as type1. */
219233 data = pci_read_reg (chan , SH4A_PCIEPCICONF3 );
@@ -327,13 +341,19 @@ static int pcie_init(struct sh7786_pcie_port *port)
327341 printk (KERN_NOTICE "PCI: PCIe#%d link width %d\n" ,
328342 port -> index , (data >> 20 ) & 0x3f );
329343
330-
331- for (i = 0 ; i < chan -> nr_resources ; i ++ ) {
344+ for (i = win = 0 ; i < chan -> nr_resources ; i ++ ) {
332345 struct resource * res = chan -> resources + i ;
333346 resource_size_t size ;
334347 u32 enable_mask ;
335348
336- pci_write_reg (chan , 0x00000000 , SH4A_PCIEPTCTLR (i ));
349+ /*
350+ * We can't use the 32-bit mode windows in legacy 29-bit
351+ * mode, so just skip them entirely.
352+ */
353+ if ((res -> flags & IORESOURCE_MEM_32BIT ) && __in_29bit_mode ())
354+ continue ;
355+
356+ pci_write_reg (chan , 0x00000000 , SH4A_PCIEPTCTLR (win ));
337357
338358 size = resource_size (res );
339359
@@ -342,16 +362,18 @@ static int pcie_init(struct sh7786_pcie_port *port)
342362 * keeps things pretty simple.
343363 */
344364 __raw_writel (((roundup_pow_of_two (size ) / SZ_256K ) - 1 ) << 18 ,
345- chan -> reg_base + SH4A_PCIEPAMR (i ));
365+ chan -> reg_base + SH4A_PCIEPAMR (win ));
346366
347- pci_write_reg (chan , 0x00000000 , SH4A_PCIEPARH ( i ));
348- pci_write_reg (chan , 0x00000000 , SH4A_PCIEPARL ( i ));
367+ pci_write_reg (chan , res -> start , SH4A_PCIEPARL ( win ));
368+ pci_write_reg (chan , 0x00000000 , SH4A_PCIEPARH ( win ));
349369
350370 enable_mask = MASK_PARE ;
351371 if (res -> flags & IORESOURCE_IO )
352372 enable_mask |= MASK_SPC ;
353373
354- pci_write_reg (chan , enable_mask , SH4A_PCIEPTCTLR (i ));
374+ pci_write_reg (chan , enable_mask , SH4A_PCIEPTCTLR (win ));
375+
376+ win ++ ;
355377 }
356378
357379 return 0 ;
0 commit comments