lorenzobianconi

Untitled

Feb 22nd, 2025
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.93 KB | None | 0 0
  1. From f062d9dff6de03ebb2e4fc377f2ef81a29a21fec Mon Sep 17 00:00:00 2001
  2. Message-ID: <f062d9dff6de03ebb2e4fc377f2ef81a29[email protected]>
  3. From: Lorenzo Bianconi <[email protected]>
  4. Date: Tue, 3 Sep 2024 23:14:02 +0200
  5. Subject: [PATCH] PCI: mediatek-gen3: Configure PBUS_CSR registers for EN7581
  6.  SoC
  7.  
  8. Configure PBus base address and address mask to allow the hw
  9. to detect if a given address is on PCIE0, PCIE1 or PCIE2.
  10.  
  11. Fixes: f6ab898356dd ("PCI: mediatek-gen3: Add Airoha EN7581 support")
  12. Signed-off-by: Lorenzo Bianconi <[email protected]>
  13. ---
  14. drivers/pci/controller/pcie-mediatek-gen3.c | 34 ++++++++++++++++++++-
  15.  1 file changed, 33 insertions(+), 1 deletion(-)
  16.  
  17. diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c
  18. index 0f64e76e2111..917f36d524a9 100644
  19. --- a/drivers/pci/controller/pcie-mediatek-gen3.c
  20. +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
  21. @@ -15,6 +15,7 @@
  22.  #include <linux/irqchip/chained_irq.h>
  23.  #include <linux/irqdomain.h>
  24.  #include <linux/kernel.h>
  25. +#include <linux/mfd/syscon.h>
  26.  #include <linux/module.h>
  27.  #include <linux/msi.h>
  28.  #include <linux/of_device.h>
  29. @@ -24,6 +25,7 @@
  30.  #include <linux/platform_device.h>
  31.  #include <linux/pm_domain.h>
  32.  #include <linux/pm_runtime.h>
  33. +#include <linux/regmap.h>
  34.  #include <linux/reset.h>
  35.  
  36.  #include "../pci.h"
  37. @@ -930,9 +932,14 @@ static int mtk_pcie_parse_port(struct mtk_gen3_pcie *pcie)
  38.  
  39.  static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
  40.  {
  41. +   struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
  42.     struct device *dev = pcie->dev;
  43. +   struct resource_entry *entry;
  44. +   struct regmap *pbus_regmap;
  45. +   resource_size_t addr;
  46. +   resource_size_t size;
  47. +   u32 val, args[2];
  48.     int err;
  49. -   u32 val;
  50.  
  51.     /*
  52.      * The controller may have been left out of reset by the bootloader
  53. @@ -944,6 +951,31 @@ static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
  54.     /* Wait for the time needed to complete the reset lines assert. */
  55.     msleep(PCIE_EN7581_RESET_TIME_MS);
  56.  
  57. +   /*
  58. +    * Configure PBus base address and base address mask to allow the
  59. +    * hw to detect if a given address is accessible on PCIe controller.
  60. +    */
  61. +   pbus_regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node,
  62. +                              "mediatek,pbus-csr",
  63. +                              ARRAY_SIZE(args),
  64. +                              args);
  65. +   if (IS_ERR(pbus_regmap))
  66. +       return PTR_ERR(pbus_regmap);
  67. +
  68. +   entry = resource_list_first_type(&host->windows, IORESOURCE_MEM);
  69. +   if (!entry)
  70. +       return -EINVAL;
  71. +
  72. +   addr = entry->res->start - entry->offset;
  73. +   err = regmap_write(pbus_regmap, args[0], lower_32_bits(addr));
  74. +   if (err)
  75. +       return err;
  76. +
  77. +   size = resource_size(entry->res);
  78. +   err = regmap_write(pbus_regmap, args[1], GENMASK(31, __fls(size)));
  79. +   if (err)
  80. +       return err;
  81. +
  82.     /*
  83.      * Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
  84.      * requires PHY initialization and power-on before PHY reset deassert.
  85. --
  86. 2.48.1
  87.  
  88.  
Advertisement
Add Comment
Please, Sign In to add comment