Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: uniphier-ep: Add NX1 support

Add basic support for UniPhier NX1 SoC as non-legacy SoC. This includes
a compatible string, SoC-dependent data containing init() and wait()
functions for the controller.

Link: https://lore.kernel.org/r/1644480596-20037-4-git-send-email-hayashi.kunihiko@socionext.com
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Rob Herring <robh@kernel.org>

authored by

Kunihiko Hayashi and committed by
Lorenzo Pieralisi
892fdf15 d41584ae

+81
+81
drivers/pci/controller/dwc/pcie-uniphier-ep.c
··· 10 10 #include <linux/clk.h> 11 11 #include <linux/delay.h> 12 12 #include <linux/init.h> 13 + #include <linux/iopoll.h> 13 14 #include <linux/of_device.h> 14 15 #include <linux/pci.h> 15 16 #include <linux/phy/phy.h> ··· 32 31 #define PCL_RSTCTRL2 0x0024 33 32 #define PCL_RSTCTRL_PHY_RESET BIT(0) 34 33 34 + #define PCL_PINCTRL0 0x002c 35 + #define PCL_PERST_PLDN_REGEN BIT(12) 36 + #define PCL_PERST_NOE_REGEN BIT(11) 37 + #define PCL_PERST_OUT_REGEN BIT(8) 38 + #define PCL_PERST_PLDN_REGVAL BIT(4) 39 + #define PCL_PERST_NOE_REGVAL BIT(3) 40 + #define PCL_PERST_OUT_REGVAL BIT(0) 41 + 42 + #define PCL_PIPEMON 0x0044 43 + #define PCL_PCLK_ALIVE BIT(15) 44 + 35 45 #define PCL_MODE 0x8000 36 46 #define PCL_MODE_REGEN BIT(8) 37 47 #define PCL_MODE_REGVAL BIT(0) ··· 62 50 63 51 #define PCL_APP_INTX 0x8074 64 52 #define PCL_APP_INTX_SYS_INT BIT(0) 53 + 54 + #define PCL_APP_PM0 0x8078 55 + #define PCL_SYS_AUX_PWR_DET BIT(8) 65 56 66 57 /* assertion time of INTx in usec */ 67 58 #define PCL_INTX_WIDTH_USEC 30 ··· 136 121 uniphier_pcie_ltssm_enable(priv, false); 137 122 138 123 msleep(100); 124 + } 125 + 126 + static void uniphier_pcie_nx1_init_ep(struct uniphier_pcie_ep_priv *priv) 127 + { 128 + u32 val; 129 + 130 + /* set EP mode */ 131 + val = readl(priv->base + PCL_MODE); 132 + val |= PCL_MODE_REGEN | PCL_MODE_REGVAL; 133 + writel(val, priv->base + PCL_MODE); 134 + 135 + /* use auxiliary power detection */ 136 + val = readl(priv->base + PCL_APP_PM0); 137 + val |= PCL_SYS_AUX_PWR_DET; 138 + writel(val, priv->base + PCL_APP_PM0); 139 + 140 + /* assert PERST# */ 141 + val = readl(priv->base + PCL_PINCTRL0); 142 + val &= ~(PCL_PERST_NOE_REGVAL | PCL_PERST_OUT_REGVAL 143 + | PCL_PERST_PLDN_REGVAL); 144 + val |= PCL_PERST_NOE_REGEN | PCL_PERST_OUT_REGEN 145 + | PCL_PERST_PLDN_REGEN; 146 + writel(val, priv->base + PCL_PINCTRL0); 147 + 148 + uniphier_pcie_ltssm_enable(priv, false); 149 + 150 + usleep_range(100000, 200000); 151 + 152 + /* deassert PERST# */ 153 + val = readl(priv->base + PCL_PINCTRL0); 154 + val |= PCL_PERST_OUT_REGVAL | PCL_PERST_OUT_REGEN; 155 + writel(val, priv->base + PCL_PINCTRL0); 156 + } 157 + 158 + static int uniphier_pcie_nx1_wait_ep(struct uniphier_pcie_ep_priv *priv) 159 + { 160 + u32 status; 161 + int ret; 162 + 163 + /* wait PIPE clock */ 164 + ret = readl_poll_timeout(priv->base + PCL_PIPEMON, status, 165 + status & PCL_PCLK_ALIVE, 100000, 1000000); 166 + if (ret) { 167 + dev_err(priv->pci.dev, 168 + "Failed to initialize controller in EP mode\n"); 169 + return ret; 170 + } 171 + 172 + return 0; 139 173 } 140 174 141 175 static int uniphier_pcie_start_link(struct dw_pcie *pci) ··· 417 353 }, 418 354 }; 419 355 356 + static const struct uniphier_pcie_ep_soc_data uniphier_nx1_data = { 357 + .has_gio = false, 358 + .init = uniphier_pcie_nx1_init_ep, 359 + .wait = uniphier_pcie_nx1_wait_ep, 360 + .features = { 361 + .linkup_notifier = false, 362 + .msi_capable = true, 363 + .msix_capable = false, 364 + .align = 1 << 12, 365 + .bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4), 366 + }, 367 + }; 368 + 420 369 static const struct of_device_id uniphier_pcie_ep_match[] = { 421 370 { 422 371 .compatible = "socionext,uniphier-pro5-pcie-ep", 423 372 .data = &uniphier_pro5_data, 373 + }, 374 + { 375 + .compatible = "socionext,uniphier-nx1-pcie-ep", 376 + .data = &uniphier_nx1_data, 424 377 }, 425 378 { /* sentinel */ }, 426 379 };