Skip to content

Commit d41584a

Browse files
khayash1Lorenzo Pieralisi
authored andcommitted
PCI: uniphier-ep: Add SoC data structure
Define SoC data structure that includes pci_epc_features, SoC-dependent callback functions and flags to distinguish the behavior of each SoC. The callback functions define init() to initialize the controller and wait() to wait until initialization is completed. Rename uniphier_pcie_init_ep() to uniphier_pcie_pro5_init_ep() for initializing PCIe controller implemented in Pro5 SoC. And Pro5 SoC doesn't have wait() function. Link: https://lore.kernel.org/r/1644480596-20037-3-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 f28b240 commit d41584a

1 file changed

Lines changed: 42 additions & 19 deletions

File tree

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

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ struct uniphier_pcie_ep_priv {
6060
struct clk *clk, *clk_gio;
6161
struct reset_control *rst, *rst_gio;
6262
struct phy *phy;
63-
const struct pci_epc_features *features;
63+
const struct uniphier_pcie_ep_soc_data *data;
64+
};
65+
66+
struct uniphier_pcie_ep_soc_data {
67+
bool has_gio;
68+
void (*init)(struct uniphier_pcie_ep_priv *priv);
69+
int (*wait)(struct uniphier_pcie_ep_priv *priv);
70+
const struct pci_epc_features features;
6471
};
6572

6673
#define to_uniphier_pcie(x) dev_get_drvdata((x)->dev)
@@ -91,7 +98,7 @@ static void uniphier_pcie_phy_reset(struct uniphier_pcie_ep_priv *priv,
9198
writel(val, priv->base + PCL_RSTCTRL2);
9299
}
93100

94-
static void uniphier_pcie_init_ep(struct uniphier_pcie_ep_priv *priv)
101+
static void uniphier_pcie_pro5_init_ep(struct uniphier_pcie_ep_priv *priv)
95102
{
96103
u32 val;
97104

@@ -209,7 +216,7 @@ uniphier_pcie_get_features(struct dw_pcie_ep *ep)
209216
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
210217
struct uniphier_pcie_ep_priv *priv = to_uniphier_pcie(pci);
211218

212-
return priv->features;
219+
return &priv->data->features;
213220
}
214221

215222
static const struct dw_pcie_ep_ops uniphier_pcie_ep_ops = {
@@ -238,7 +245,8 @@ static int uniphier_pcie_ep_enable(struct uniphier_pcie_ep_priv *priv)
238245
if (ret)
239246
goto out_rst_assert;
240247

241-
uniphier_pcie_init_ep(priv);
248+
if (priv->data->init)
249+
priv->data->init(priv);
242250

243251
uniphier_pcie_phy_reset(priv, true);
244252

@@ -248,8 +256,16 @@ static int uniphier_pcie_ep_enable(struct uniphier_pcie_ep_priv *priv)
248256

249257
uniphier_pcie_phy_reset(priv, false);
250258

259+
if (priv->data->wait) {
260+
ret = priv->data->wait(priv);
261+
if (ret)
262+
goto out_phy_exit;
263+
}
264+
251265
return 0;
252266

267+
out_phy_exit:
268+
phy_exit(priv->phy);
253269
out_rst_gio_assert:
254270
reset_control_assert(priv->rst_gio);
255271
out_rst_assert:
@@ -277,8 +293,8 @@ static int uniphier_pcie_ep_probe(struct platform_device *pdev)
277293
if (!priv)
278294
return -ENOMEM;
279295

280-
priv->features = of_device_get_match_data(dev);
281-
if (WARN_ON(!priv->features))
296+
priv->data = of_device_get_match_data(dev);
297+
if (WARN_ON(!priv->data))
282298
return -EINVAL;
283299

284300
priv->pci.dev = dev;
@@ -288,13 +304,15 @@ static int uniphier_pcie_ep_probe(struct platform_device *pdev)
288304
if (IS_ERR(priv->base))
289305
return PTR_ERR(priv->base);
290306

291-
priv->clk_gio = devm_clk_get(dev, "gio");
292-
if (IS_ERR(priv->clk_gio))
293-
return PTR_ERR(priv->clk_gio);
307+
if (priv->data->has_gio) {
308+
priv->clk_gio = devm_clk_get(dev, "gio");
309+
if (IS_ERR(priv->clk_gio))
310+
return PTR_ERR(priv->clk_gio);
294311

295-
priv->rst_gio = devm_reset_control_get_shared(dev, "gio");
296-
if (IS_ERR(priv->rst_gio))
297-
return PTR_ERR(priv->rst_gio);
312+
priv->rst_gio = devm_reset_control_get_shared(dev, "gio");
313+
if (IS_ERR(priv->rst_gio))
314+
return PTR_ERR(priv->rst_gio);
315+
}
298316

299317
priv->clk = devm_clk_get(dev, "link");
300318
if (IS_ERR(priv->clk))
@@ -321,13 +339,18 @@ static int uniphier_pcie_ep_probe(struct platform_device *pdev)
321339
return dw_pcie_ep_init(&priv->pci.ep);
322340
}
323341

324-
static const struct pci_epc_features uniphier_pro5_data = {
325-
.linkup_notifier = false,
326-
.msi_capable = true,
327-
.msix_capable = false,
328-
.align = 1 << 16,
329-
.bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4),
330-
.reserved_bar = BIT(BAR_4),
342+
static const struct uniphier_pcie_ep_soc_data uniphier_pro5_data = {
343+
.has_gio = true,
344+
.init = uniphier_pcie_pro5_init_ep,
345+
.wait = NULL,
346+
.features = {
347+
.linkup_notifier = false,
348+
.msi_capable = true,
349+
.msix_capable = false,
350+
.align = 1 << 16,
351+
.bar_fixed_64bit = BIT(BAR_0) | BIT(BAR_2) | BIT(BAR_4),
352+
.reserved_bar = BIT(BAR_4),
353+
},
331354
};
332355

333356
static const struct of_device_id uniphier_pcie_ep_match[] = {

0 commit comments

Comments
 (0)