Skip to content

Commit 892fdf1

Browse files
khayash1Lorenzo Pieralisi
authored andcommitted
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>
1 parent d41584a commit 892fdf1

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

drivers/pci/controller/dwc/pcie-uniphier-ep.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/clk.h>
1111
#include <linux/delay.h>
1212
#include <linux/init.h>
13+
#include <linux/iopoll.h>
1314
#include <linux/of_device.h>
1415
#include <linux/pci.h>
1516
#include <linux/phy/phy.h>
@@ -31,6 +32,17 @@
3132
#define PCL_RSTCTRL2 0x0024
3233
#define PCL_RSTCTRL_PHY_RESET BIT(0)
3334

35+
#define PCL_PINCTRL0 0x002c
36+
#define PCL_PERST_PLDN_REGEN BIT(12)
37+
#define PCL_PERST_NOE_REGEN BIT(11)
38+
#define PCL_PERST_OUT_REGEN BIT(8)
39+
#define PCL_PERST_PLDN_REGVAL BIT(4)
40+
#define PCL_PERST_NOE_REGVAL BIT(3)
41+
#define PCL_PERST_OUT_REGVAL BIT(0)
42+
43+
#define PCL_PIPEMON 0x0044
44+
#define PCL_PCLK_ALIVE BIT(15)
45+
3446
#define PCL_MODE 0x8000
3547
#define PCL_MODE_REGEN BIT(8)
3648
#define PCL_MODE_REGVAL BIT(0)
@@ -51,6 +63,9 @@
5163
#define PCL_APP_INTX 0x8074
5264
#define PCL_APP_INTX_SYS_INT BIT(0)
5365

66+
#define PCL_APP_PM0 0x8078
67+
#define PCL_SYS_AUX_PWR_DET BIT(8)
68+
5469
/* assertion time of INTx in usec */
5570
#define PCL_INTX_WIDTH_USEC 30
5671

@@ -123,6 +138,55 @@ static void uniphier_pcie_pro5_init_ep(struct uniphier_pcie_ep_priv *priv)
123138
msleep(100);
124139
}
125140

141+
static void uniphier_pcie_nx1_init_ep(struct uniphier_pcie_ep_priv *priv)
142+
{
143+
u32 val;
144+
145+
/* set EP mode */
146+
val = readl(priv->base + PCL_MODE);
147+
val |= PCL_MODE_REGEN | PCL_MODE_REGVAL;
148+
writel(val, priv->base + PCL_MODE);
149+
150+
/* use auxiliary power detection */
151+
val = readl(priv->base + PCL_APP_PM0);
152+
val |= PCL_SYS_AUX_PWR_DET;
153+
writel(val, priv->base + PCL_APP_PM0);
154+
155+
/* assert PERST# */
156+
val = readl(priv->base + PCL_PINCTRL0);
157+
val &= ~(PCL_PERST_NOE_REGVAL | PCL_PERST_OUT_REGVAL
158+
| PCL_PERST_PLDN_REGVAL);
159+
val |= PCL_PERST_NOE_REGEN | PCL_PERST_OUT_REGEN
160+
| PCL_PERST_PLDN_REGEN;
161+
writel(val, priv->base + PCL_PINCTRL0);
162+
163+
uniphier_pcie_ltssm_enable(priv, false);
164+
165+
usleep_range(100000, 200000);
166+
167+
/* deassert PERST# */
168+
val = readl(priv->base + PCL_PINCTRL0);
169+
val |= PCL_PERST_OUT_REGVAL | PCL_PERST_OUT_REGEN;
170+
writel(val, priv->base + PCL_PINCTRL0);
171+
}
172+
173+
static int uniphier_pcie_nx1_wait_ep(struct uniphier_pcie_ep_priv *priv)
174+
{
175+
u32 status;
176+
int ret;
177+
178+
/* wait PIPE clock */
179+
ret = readl_poll_timeout(priv->base + PCL_PIPEMON, status,
180+
status & PCL_PCLK_ALIVE, 100000, 1000000);
181+
if (ret) {
182+
dev_err(priv->pci.dev,
183+
"Failed to initialize controller in EP mode\n");
184+
return ret;
185+
}
186+
187+
return 0;
188+
}
189+
126190
static int uniphier_pcie_start_link(struct dw_pcie *pci)
127191
{
128192
struct uniphier_pcie_ep_priv *priv = to_uniphier_pcie(pci);
@@ -353,11 +417,28 @@ static const struct uniphier_pcie_ep_soc_data uniphier_pro5_data = {
353417
},
354418
};
355419

420+
static const struct uniphier_pcie_ep_soc_data uniphier_nx1_data = {
421+
.has_gio = false,
422+
.init = uniphier_pcie_nx1_init_ep,
423+
.wait = uniphier_pcie_nx1_wait_ep,
424+
.features = {
425+
.linkup_notifier = false,
426+
.msi_capable = true,
427+
.msix_capable = false,
428+
.align = 1 << 12,
429+
.bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4),
430+
},
431+
};
432+
356433
static const struct of_device_id uniphier_pcie_ep_match[] = {
357434
{
358435
.compatible = "socionext,uniphier-pro5-pcie-ep",
359436
.data = &uniphier_pro5_data,
360437
},
438+
{
439+
.compatible = "socionext,uniphier-nx1-pcie-ep",
440+
.data = &uniphier_nx1_data,
441+
},
361442
{ /* sentinel */ },
362443
};
363444

0 commit comments

Comments
 (0)