Skip to content

Commit 249b782

Browse files
LorenzoBianconikwilczynski
authored andcommitted
PCI: mediatek-gen3: Configure PBUS_CSR registers for EN7581 SoC
Configure PBus base address and address mask to allow the hw to detect if a given address is accessible on PCIe controller. Fixes: f6ab898 ("PCI: mediatek-gen3: Add Airoha EN7581 support") Reviewed-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Wilczyński <[email protected]>
1 parent a1360a6 commit 249b782

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

drivers/pci/controller/pcie-mediatek-gen3.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/irqchip/chained_irq.h>
1616
#include <linux/irqdomain.h>
1717
#include <linux/kernel.h>
18+
#include <linux/mfd/syscon.h>
1819
#include <linux/module.h>
1920
#include <linux/msi.h>
2021
#include <linux/of_device.h>
@@ -24,6 +25,7 @@
2425
#include <linux/platform_device.h>
2526
#include <linux/pm_domain.h>
2627
#include <linux/pm_runtime.h>
28+
#include <linux/regmap.h>
2729
#include <linux/reset.h>
2830

2931
#include "../pci.h"
@@ -930,9 +932,13 @@ static int mtk_pcie_parse_port(struct mtk_gen3_pcie *pcie)
930932

931933
static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
932934
{
935+
struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
933936
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;
934941
int err;
935-
u32 val;
936942

937943
/*
938944
* 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)
944950
/* Wait for the time needed to complete the reset lines assert. */
945951
msleep(PCIE_EN7581_RESET_TIME_MS);
946952

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+
947973
/*
948974
* Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
949975
* requires PHY initialization and power-on before PHY reset deassert.

0 commit comments

Comments
 (0)