From: <honghui.zhang@mediatek.com>
To: <bhelgaas@google.com>, <robh@kerenl.org>, <robh+dt@kernel.org>,
<matthias.bgg@gmail.com>, <linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
<yingjoe.chen@mediatek.com>, <eddie.huang@mediatek.com>,
<ryder.lee@mediatek.com>
Cc: <honghui.zhang@mediatek.com>, <hongkun.cao@mediatek.com>,
<youlin.pei@mediatek.com>, <yong.wu@mediatek.com>,
<yt.shen@mediatek.com>, <sean.wang@mediatek.com>,
<xinping.qian@mediatek.com>
Subject: [PATCH v4 4/7] PCI: mediatek: switch to use platform_get_resource_byname()
Date: Thu, 10 Aug 2017 14:34:57 +0800 [thread overview]
Message-ID: <f7810da34df710a2b98f903e7a95247ee9387032.1502336769.git.honghui.zhang@mediatek.com> (raw)
In-Reply-To: <cover.1502336769.git.honghui.zhang@mediatek.com>
From: Ryder Lee <ryder.lee@mediatek.com>
This is a transitional patch. We currently use platfarm_get_resource() for
retrieving the IOMEM resources, but there might be some chips don't have
subsys/shared registers part, which depends on platform design, and these
will be introduced in further patches.
Switch this function to use the platform_get_resource_byname() so that the
binding can be agnostic of the resource order.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
---
drivers/pci/host/pcie-mediatek.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/host/pcie-mediatek.c b/drivers/pci/host/pcie-mediatek.c
index 01caa98..c649ab4 100644
--- a/drivers/pci/host/pcie-mediatek.c
+++ b/drivers/pci/host/pcie-mediatek.c
@@ -295,7 +295,8 @@ static int mtk_pcie_parse_port(struct mtk_pcie *pcie,
return err;
}
- regs = platform_get_resource(pdev, IORESOURCE_MEM, slot + 1);
+ snprintf(name, sizeof(name), "port%d", slot);
+ regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
port->base = devm_ioremap_resource(dev, regs);
if (IS_ERR(port->base)) {
dev_err(dev, "failed to map port%d base\n", slot);
@@ -336,12 +337,14 @@ static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie)
struct resource *regs;
int err;
- /* get shared registers */
- regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- pcie->base = devm_ioremap_resource(dev, regs);
- if (IS_ERR(pcie->base)) {
- dev_err(dev, "failed to map shared register\n");
- return PTR_ERR(pcie->base);
+ /* get shared registers, which are optional */
+ regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "subsys");
+ if (regs) {
+ pcie->base = devm_ioremap_resource(dev, regs);
+ if (IS_ERR(pcie->base)) {
+ dev_err(dev, "failed to map shared register\n");
+ return PTR_ERR(pcie->base);
+ }
}
pcie->free_ck = devm_clk_get(dev, "free_ck");
--
2.6.4
next prev parent reply other threads:[~2017-08-10 6:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-10 6:34 [PATCH v4 0/7] PCI: MediaTek: Add host controller support for mt2712 and mt7622 honghui.zhang
2017-08-10 6:34 ` [PATCH v4 1/7] PCI: mediatek: Using readl_poll_timeout to wait Gen2 training honghui.zhang
2017-08-10 6:34 ` [PATCH v4 2/7] PCI: mediatek: make the parameter and function names more accurate honghui.zhang
2017-08-10 6:34 ` [PATCH v4 3/7] PCI: mediatek: Add a structure to abstract the controller generations honghui.zhang
2017-08-10 6:34 ` honghui.zhang [this message]
2017-08-10 6:34 ` [PATCH v4 5/7] dt-bindings: PCI: rename and cleanup MediaTek binding text honghui.zhang
2017-08-10 6:34 ` [PATCH v4 6/7] PCI: mediatek: Add controller support for mt2712 and mt7622 honghui.zhang
2017-08-10 6:35 ` [PATCH v4 7/7] dt-bindings: PCI: add " honghui.zhang
2017-08-10 22:26 ` [PATCH v4 0/7] PCI: MediaTek: Add host controller " 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=f7810da34df710a2b98f903e7a95247ee9387032.1502336769.git.honghui.zhang@mediatek.com \
--to=honghui.zhang@mediatek.com \
--cc=bhelgaas@google.com \
--cc=devicetree@vger.kernel.org \
--cc=eddie.huang@mediatek.com \
--cc=hongkun.cao@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pci@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=robh+dt@kernel.org \
--cc=robh@kerenl.org \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
--cc=xinping.qian@mediatek.com \
--cc=yingjoe.chen@mediatek.com \
--cc=yong.wu@mediatek.com \
--cc=youlin.pei@mediatek.com \
--cc=yt.shen@mediatek.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
all inboxes | Powered by JetHome®