111111#define PCIE_MSI_MASK_REG (CONTROL_BASE_ADDR + 0x5C)
112112#define PCIE_MSI_PAYLOAD_REG (CONTROL_BASE_ADDR + 0x9C)
113113
114- /* PCIe window configuration */
115- #define OB_WIN_BASE_ADDR 0x4c00
116- #define OB_WIN_BLOCK_SIZE 0x20
117- #define OB_WIN_REG_ADDR (win , offset ) (OB_WIN_BASE_ADDR + \
118- OB_WIN_BLOCK_SIZE * (win) + \
119- (offset))
120- #define OB_WIN_MATCH_LS (win ) OB_WIN_REG_ADDR(win, 0x00)
121- #define OB_WIN_MATCH_MS (win ) OB_WIN_REG_ADDR(win, 0x04)
122- #define OB_WIN_REMAP_LS (win ) OB_WIN_REG_ADDR(win, 0x08)
123- #define OB_WIN_REMAP_MS (win ) OB_WIN_REG_ADDR(win, 0x0c)
124- #define OB_WIN_MASK_LS (win ) OB_WIN_REG_ADDR(win, 0x10)
125- #define OB_WIN_MASK_MS (win ) OB_WIN_REG_ADDR(win, 0x14)
126- #define OB_WIN_ACTIONS (win ) OB_WIN_REG_ADDR(win, 0x18)
127-
128- /* PCIe window types */
129- #define OB_PCIE_MEM 0x0
130- #define OB_PCIE_IO 0x4
131-
132114/* LMI registers base address and register offsets */
133115#define LMI_BASE_ADDR 0x6000
134116#define CFG_REG (LMI_BASE_ADDR + 0x0)
@@ -247,34 +229,9 @@ static int advk_pcie_wait_for_link(struct advk_pcie *pcie)
247229 return - ETIMEDOUT ;
248230}
249231
250- /*
251- * Set PCIe address window register which could be used for memory
252- * mapping.
253- */
254- static void advk_pcie_set_ob_win (struct advk_pcie * pcie ,
255- u32 win_num , u32 match_ms ,
256- u32 match_ls , u32 mask_ms ,
257- u32 mask_ls , u32 remap_ms ,
258- u32 remap_ls , u32 action )
259- {
260- advk_writel (pcie , match_ls , OB_WIN_MATCH_LS (win_num ));
261- advk_writel (pcie , match_ms , OB_WIN_MATCH_MS (win_num ));
262- advk_writel (pcie , mask_ms , OB_WIN_MASK_MS (win_num ));
263- advk_writel (pcie , mask_ls , OB_WIN_MASK_LS (win_num ));
264- advk_writel (pcie , remap_ms , OB_WIN_REMAP_MS (win_num ));
265- advk_writel (pcie , remap_ls , OB_WIN_REMAP_LS (win_num ));
266- advk_writel (pcie , action , OB_WIN_ACTIONS (win_num ));
267- advk_writel (pcie , match_ls | BIT (0 ), OB_WIN_MATCH_LS (win_num ));
268- }
269-
270232static void advk_pcie_setup_hw (struct advk_pcie * pcie )
271233{
272234 u32 reg ;
273- int i ;
274-
275- /* Point PCIe unit MBUS decode windows to DRAM space */
276- for (i = 0 ; i < 8 ; i ++ )
277- advk_pcie_set_ob_win (pcie , i , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
278235
279236 /* Set to Direct mode */
280237 reg = advk_readl (pcie , CTRL_CONFIG_REG );
@@ -433,14 +390,23 @@ static int advk_pcie_wait_pio(struct advk_pcie *pcie)
433390 return - ETIMEDOUT ;
434391}
435392
393+ static bool advk_pcie_valid_device (struct advk_pcie * pcie , struct pci_bus * bus ,
394+ int devfn )
395+ {
396+ if ((bus -> number == pcie -> root_bus_nr ) && PCI_SLOT (devfn ) != 0 )
397+ return false;
398+
399+ return true;
400+ }
401+
436402static int advk_pcie_rd_conf (struct pci_bus * bus , u32 devfn ,
437403 int where , int size , u32 * val )
438404{
439405 struct advk_pcie * pcie = bus -> sysdata ;
440406 u32 reg ;
441407 int ret ;
442408
443- if (( bus -> number == pcie -> root_bus_nr ) && PCI_SLOT ( devfn ) != 0 ) {
409+ if (! advk_pcie_valid_device ( pcie , bus , devfn )) {
444410 * val = 0xffffffff ;
445411 return PCIBIOS_DEVICE_NOT_FOUND ;
446412 }
@@ -494,7 +460,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
494460 int offset ;
495461 int ret ;
496462
497- if (( bus -> number == pcie -> root_bus_nr ) && PCI_SLOT ( devfn ) != 0 )
463+ if (! advk_pcie_valid_device ( pcie , bus , devfn ))
498464 return PCIBIOS_DEVICE_NOT_FOUND ;
499465
500466 if (where % size )
@@ -843,12 +809,6 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
843809
844810 switch (resource_type (res )) {
845811 case IORESOURCE_IO :
846- advk_pcie_set_ob_win (pcie , 1 ,
847- upper_32_bits (res -> start ),
848- lower_32_bits (res -> start ),
849- 0 , 0xF8000000 , 0 ,
850- lower_32_bits (res -> start ),
851- OB_PCIE_IO );
852812 err = devm_pci_remap_iospace (dev , res , iobase );
853813 if (err ) {
854814 dev_warn (dev , "error %d: failed to map resource %pR\n" ,
@@ -857,12 +817,6 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
857817 }
858818 break ;
859819 case IORESOURCE_MEM :
860- advk_pcie_set_ob_win (pcie , 0 ,
861- upper_32_bits (res -> start ),
862- lower_32_bits (res -> start ),
863- 0x0 , 0xF8000000 , 0 ,
864- lower_32_bits (res -> start ),
865- (2 << 20 ) | OB_PCIE_MEM );
866820 res_valid |= !(res -> flags & IORESOURCE_PREFETCH );
867821 break ;
868822 case IORESOURCE_BUS :
@@ -889,7 +843,6 @@ static int advk_pcie_probe(struct platform_device *pdev)
889843 struct device * dev = & pdev -> dev ;
890844 struct advk_pcie * pcie ;
891845 struct resource * res ;
892- struct pci_bus * bus , * child ;
893846 struct pci_host_bridge * bridge ;
894847 int ret , irq ;
895848
@@ -943,21 +896,13 @@ static int advk_pcie_probe(struct platform_device *pdev)
943896 bridge -> map_irq = of_irq_parse_and_map_pci ;
944897 bridge -> swizzle_irq = pci_common_swizzle ;
945898
946- ret = pci_scan_root_bus_bridge (bridge );
899+ ret = pci_host_probe (bridge );
947900 if (ret < 0 ) {
948901 advk_pcie_remove_msi_irq_domain (pcie );
949902 advk_pcie_remove_irq_domain (pcie );
950903 return ret ;
951904 }
952905
953- bus = bridge -> bus ;
954-
955- pci_bus_assign_resources (bus );
956-
957- list_for_each_entry (child , & bus -> children , node )
958- pcie_bus_configure_settings (child );
959-
960- pci_bus_add_devices (bus );
961906 return 0 ;
962907}
963908
0 commit comments