From: Minghuan Lian <Minghuan.Lian@freescale.com>
To: <linux-pci@vger.kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
Zang Roy-R61911 <r61911@freescale.com>,
Hu Mingkai-B21284 <B21284@freescale.com>,
"Yoder Stuart-B08248" <stuart.yoder@freescale.com>,
Li Yang <leoli@freescale.com>, Arnd Bergmann <arnd@arndb.de>,
Bjorn Helgaas <bhelgaas@google.com>,
"Jingoo Han" <jg1.han@samsung.com>,
Zhou Wang <wangzhou1@hisilicon.com>,
"Minghuan Lian" <Minghuan.Lian@freescale.com>
Subject: [PATCH v4 3/6] PCI: layerscape: factor out SCFG related function
Date: Fri, 16 Oct 2015 15:19:17 +0800 [thread overview]
Message-ID: <1444979960-24100-3-git-send-email-Minghuan.Lian@freescale.com> (raw)
In-Reply-To: <1444979960-24100-1-git-send-email-Minghuan.Lian@freescale.com>
For LS1021a PCIe controller, some status registers are located
in SCFG. This is different to other kind of Layerscape. The
patch moves SCFG related code to ls1021_pcie_host_init() and
rename ls_pcie_link_up to ls1021_pcie_link_up because LTSSM
status is also in SCFG.
Signed-off-by: Minghuan Lian <Minghuan.Lian@freescale.com>
---
Change log
v4: split from [PATCH v3] PCI: layerscape: Add PCIe support for LS1043a and LS2080a
drivers/pci/host/pci-layerscape.c | 72 +++++++++++++++++++++++++--------------
1 file changed, 46 insertions(+), 26 deletions(-)
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c
index 5eabe92..89b7eb8 100644
--- a/drivers/pci/host/pci-layerscape.c
+++ b/drivers/pci/host/pci-layerscape.c
@@ -34,6 +34,10 @@
/* Symbol Timer Register and Filter Mask Register 1 */
#define PCIE_STRFMR1 0x71c
+struct ls_pcie_drvdata {
+ struct pcie_host_ops *ops;
+};
+
struct ls_pcie {
struct list_head node;
struct device *dev;
@@ -41,6 +45,7 @@ struct ls_pcie {
void __iomem *dbi;
struct regmap *scfg;
struct pcie_port pp;
+ const struct ls_pcie_drvdata *drvdata;
int index;
int msi_irq;
};
@@ -57,11 +62,14 @@ static bool ls_pcie_is_bridge(struct ls_pcie *pcie)
return header_type == PCI_HEADER_TYPE_BRIDGE;
}
-static int ls_pcie_link_up(struct pcie_port *pp)
+static int ls1021_pcie_link_up(struct pcie_port *pp)
{
u32 state;
struct ls_pcie *pcie = to_ls_pcie(pp);
+ if (!pcie->scfg)
+ return 0;
+
regmap_read(pcie->scfg, SCFG_PEXMSCPORTSR(pcie->index), &state);
state = (state >> LTSSM_STATE_SHIFT) & LTSSM_STATE_MASK;
@@ -71,10 +79,25 @@ static int ls_pcie_link_up(struct pcie_port *pp)
return 1;
}
-static void ls_pcie_host_init(struct pcie_port *pp)
+static void ls1021_pcie_host_init(struct pcie_port *pp)
{
struct ls_pcie *pcie = to_ls_pcie(pp);
- u32 val;
+ u32 val, index[2];
+
+ pcie->scfg = syscon_regmap_lookup_by_phandle(pp->dev->of_node,
+ "fsl,pcie-scfg");
+ if (IS_ERR(pcie->scfg)) {
+ dev_err(pp->dev, "No syscfg phandle specified\n");
+ pcie->scfg = NULL;
+ return;
+ }
+
+ if (of_property_read_u32_array(pp->dev->of_node,
+ "fsl,pcie-scfg", index, 2)) {
+ pcie->scfg = NULL;
+ return;
+ }
+ pcie->index = index[1];
dw_pcie_setup_rc(pp);
@@ -87,11 +110,21 @@ static void ls_pcie_host_init(struct pcie_port *pp)
iowrite32(val, pcie->dbi + PCIE_STRFMR1);
}
-static struct pcie_host_ops ls_pcie_host_ops = {
- .link_up = ls_pcie_link_up,
- .host_init = ls_pcie_host_init,
+static struct pcie_host_ops ls1021_pcie_host_ops = {
+ .link_up = ls1021_pcie_link_up,
+ .host_init = ls1021_pcie_host_init,
+};
+
+static struct ls_pcie_drvdata ls1021_drvdata = {
+ .ops = &ls1021_pcie_host_ops,
};
+static const struct of_device_id ls_pcie_of_match[] = {
+ { .compatible = "fsl,ls1021a-pcie", .data = &ls1021_drvdata },
+ { },
+};
+MODULE_DEVICE_TABLE(of, ls_pcie_of_match);
+
static int ls_add_pcie_port(struct ls_pcie *pcie)
{
struct pcie_port *pp;
@@ -101,7 +134,7 @@ static int ls_add_pcie_port(struct ls_pcie *pcie)
pp->dev = pcie->dev;
pp->dbi_base = pcie->dbi;
pp->root_bus_nr = -1;
- pp->ops = &ls_pcie_host_ops;
+ pp->ops = pcie->drvdata->ops;
ret = dw_pcie_host_init(pp);
if (ret) {
@@ -114,11 +147,15 @@ static int ls_add_pcie_port(struct ls_pcie *pcie)
static int __init ls_pcie_probe(struct platform_device *pdev)
{
+ const struct of_device_id *match;
struct ls_pcie *pcie;
struct resource *dbi_base;
- u32 index[2];
int ret;
+ match = of_match_device(ls_pcie_of_match, &pdev->dev);
+ if (!match)
+ return -ENODEV;
+
pcie = devm_kzalloc(&pdev->dev, sizeof(*pcie), GFP_KERNEL);
if (!pcie)
return -ENOMEM;
@@ -132,18 +169,7 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
return PTR_ERR(pcie->dbi);
}
- pcie->scfg = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
- "fsl,pcie-scfg");
- if (IS_ERR(pcie->scfg)) {
- dev_err(&pdev->dev, "No syscfg phandle specified\n");
- return PTR_ERR(pcie->scfg);
- }
-
- ret = of_property_read_u32_array(pdev->dev.of_node,
- "fsl,pcie-scfg", index, 2);
- if (ret)
- return ret;
- pcie->index = index[1];
+ pcie->drvdata = match->data;
if (!ls_pcie_is_bridge(pcie))
return -ENODEV;
@@ -157,12 +183,6 @@ static int __init ls_pcie_probe(struct platform_device *pdev)
return 0;
}
-static const struct of_device_id ls_pcie_of_match[] = {
- { .compatible = "fsl,ls1021a-pcie" },
- { },
-};
-MODULE_DEVICE_TABLE(of, ls_pcie_of_match);
-
static struct platform_driver ls_pcie_driver = {
.driver = {
.name = "layerscape-pcie",
--
1.9.1
next prev parent reply other threads:[~2015-10-16 7:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-16 7:19 [PATCH v4 1/6] PCI: layerscape: remove ls_pcie_establish_link() Minghuan Lian
2015-10-16 7:19 ` [PATCH v4 2/6] PCI: layerscape: check PCIe controller work mode Minghuan Lian
2015-10-16 7:19 ` Minghuan Lian [this message]
2015-10-16 7:19 ` [PATCH v4 4/6] PCI: layerscape: update ls_add_pcie_port() Minghuan Lian
2015-10-16 7:19 ` [PATCH v4 5/6] PCI: layerscape: add PCIe support for LS1043a and LS2080a Minghuan Lian
2015-10-21 21:36 ` Bjorn Helgaas
2015-10-22 17:38 ` Li Yang
2015-10-22 18:08 ` Bjorn Helgaas
2015-10-22 19:17 ` Li Yang
2015-11-02 21:08 ` Li Yang
2015-11-02 21:36 ` Bjorn Helgaas
2015-10-22 15:47 ` Bjorn Helgaas
2015-10-16 7:19 ` [PATCH v4 6/6] PCI: layerscape: add ls_pcie_msi_host_init Minghuan Lian
2015-10-21 21:34 ` Bjorn Helgaas
2015-10-22 16:21 ` Bjorn Helgaas
2015-11-02 21:06 ` Bjorn Helgaas
2015-10-21 21:40 ` [PATCH v4 1/6] PCI: layerscape: remove ls_pcie_establish_link() Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1444979960-24100-3-git-send-email-Minghuan.Lian@freescale.com \
--to=minghuan.lian@freescale.com \
--cc=B21284@freescale.com \
--cc=arnd@arndb.de \
--cc=bhelgaas@google.com \
--cc=jg1.han@samsung.com \
--cc=leoli@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=r61911@freescale.com \
--cc=stuart.yoder@freescale.com \
--cc=wangzhou1@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).