15
15
#include <linux/irqchip/chained_irq.h>
16
16
#include <linux/irqdomain.h>
17
17
#include <linux/kernel.h>
18
+ #include <linux/mfd/syscon.h>
18
19
#include <linux/module.h>
19
20
#include <linux/msi.h>
20
21
#include <linux/of_device.h>
24
25
#include <linux/platform_device.h>
25
26
#include <linux/pm_domain.h>
26
27
#include <linux/pm_runtime.h>
28
+ #include <linux/regmap.h>
27
29
#include <linux/reset.h>
28
30
29
31
#include "../pci.h"
@@ -930,9 +932,13 @@ static int mtk_pcie_parse_port(struct mtk_gen3_pcie *pcie)
930
932
931
933
static int mtk_pcie_en7581_power_up (struct mtk_gen3_pcie * pcie )
932
934
{
935
+ struct pci_host_bridge * host = pci_host_bridge_from_priv (pcie );
933
936
struct device * dev = pcie -> dev ;
937
+ struct resource_entry * entry ;
938
+ struct regmap * pbus_regmap ;
939
+ u32 val , args [2 ], size ;
940
+ resource_size_t addr ;
934
941
int err ;
935
- u32 val ;
936
942
937
943
/*
938
944
* The controller may have been left out of reset by the bootloader
@@ -944,6 +950,26 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
944
950
/* Wait for the time needed to complete the reset lines assert. */
945
951
msleep (PCIE_EN7581_RESET_TIME_MS );
946
952
953
+ /*
954
+ * Configure PBus base address and base address mask to allow the
955
+ * hw to detect if a given address is accessible on PCIe controller.
956
+ */
957
+ pbus_regmap = syscon_regmap_lookup_by_phandle_args (dev -> of_node ,
958
+ "mediatek,pbus-csr" ,
959
+ ARRAY_SIZE (args ),
960
+ args );
961
+ if (IS_ERR (pbus_regmap ))
962
+ return PTR_ERR (pbus_regmap );
963
+
964
+ entry = resource_list_first_type (& host -> windows , IORESOURCE_MEM );
965
+ if (!entry )
966
+ return - ENODEV ;
967
+
968
+ addr = entry -> res -> start - entry -> offset ;
969
+ regmap_write (pbus_regmap , args [0 ], lower_32_bits (addr ));
970
+ size = lower_32_bits (resource_size (entry -> res ));
971
+ regmap_write (pbus_regmap , args [1 ], GENMASK (31 , __fls (size )));
972
+
947
973
/*
948
974
* Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
949
975
* requires PHY initialization and power-on before PHY reset deassert.
0 commit comments