From patchwork Sat Oct 10 06:23:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minghuan Lian X-Patchwork-Id: 7365731 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BBBEF9F1B9 for ; Sat, 10 Oct 2015 06:25:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82754208B6 for ; Sat, 10 Oct 2015 06:25:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FE812089F for ; Sat, 10 Oct 2015 06:25:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZknYu-0001Xx-Vc; Sat, 10 Oct 2015 06:23:21 +0000 Received: from mail-by2on0109.outbound.protection.outlook.com ([207.46.100.109] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZknYs-0001VU-50 for linux-arm-kernel@lists.infradead.org; Sat, 10 Oct 2015 06:23:19 +0000 Received: from BN3PR0301CA0018.namprd03.prod.outlook.com (10.160.180.156) by DM2PR0301MB1263.namprd03.prod.outlook.com (10.160.219.28) with Microsoft SMTP Server (TLS) id 15.1.286.20; Sat, 10 Oct 2015 06:22:55 +0000 Received: from BY2FFO11OLC009.protection.gbl (2a01:111:f400:7c0c::102) by BN3PR0301CA0018.outlook.office365.com (2a01:111:e400:4000::28) with Microsoft SMTP Server (TLS) id 15.1.293.16 via Frontend Transport; Sat, 10 Oct 2015 06:22:55 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11OLC009.mail.protection.outlook.com (10.1.15.0) with Microsoft SMTP Server (TLS) id 15.1.293.9 via Frontend Transport; Sat, 10 Oct 2015 06:22:54 +0000 Received: from lmh.ap.freescale.net (lmh.ap.freescale.net [10.193.20.20]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t9A6MlFP002625; Fri, 9 Oct 2015 23:22:48 -0700 From: Minghuan Lian To: Subject: [PATCH v3] PCI: layerscape: Add PCIe support for LS1043a and LS2080a Date: Sat, 10 Oct 2015 14:23:37 +0800 Message-ID: <1444458217-31004-1-git-send-email-Minghuan.Lian@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC009; 1:XhPVYfF962EjJMv2TNnhFJQ8d7EJicZcT+V/J9c3khHbQTwrJQHjXZu4QdA18IhuZi0vNMf7wIuNdgLEB0u5kuHwuLS2y0uw0UamhEQT8Sw5JGC7jOl7maroTVJZ+KqiRYjxVq/2H+H+oCNXjv93mjpWJZKsgjkUGNvh/JL03acAJwDhzr9nX1NmfonEbz0h6M6iXi3YZ6gCEZ8mEpla36UH+e/Qf/YFG8z9UNNSyIJJ4xZi4hCsg5BxUn7eG6sHMoCgSf2CZAtCXBtu7eT38ILM4+VRtq4qYWhognYVmqwmqA6i4+m6Gjb0g3+7ZS9UB5sK7DtJZRJ5kmdiw2aOhjF/2GdRziz+/Pn5pSWsN6Iwmw6U1+HAtlHqd2s8H84wbqIsmcIClGDdEg12zJcc2A== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(54534003)(11100500001)(107886002)(81156007)(36756003)(5007970100001)(104016004)(50226001)(47776003)(64706001)(97736004)(50986999)(19580405001)(19580395003)(5003940100001)(69596002)(86362001)(87936001)(110136002)(2351001)(85426001)(46102003)(48376002)(229853001)(77096005)(50466002)(6806005)(106466001)(5001960100002)(189998001)(5008740100001)(105606002)(92566002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR0301MB1263; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1263; 2:QSZlweDuOpzvb6zKvqoJz7+rN7t1N/35S+Roubrry7opFMnbjQV91zxfDWWwHBlnQpiNRsN8DlaDVaMdDTJGI4ISzCFwJeYBbfriz0SwIznYLVxqYloJWrudIZMpOaVeo9qpQozVexaAtVsdvPg3G9ZWIvs0C7TaKI/T6CDfp94=; 3:ce8jW60BKK138DuiEuC5w3xjusec8ruRxVnrvuCIswZt4LBzV1DYhqlaw66YVfvoNdIr7rF8ggKkANx5a3rJWHSj8eUpPRi/WgKQ2XJnY+fi49wDC+ZuIYboMoAm9ReEJicy5OYXLcxybkP25Fyg0IRG9K/sfMlSUADI5iVNGHIQTSLb41p3IDXKhMt2L9gFOG0vwG1C0KeLg6uM5QHwIXqfuO9Gb59s9X5NjOHS59I=; 25:nzV2AEBZqIF5jDccbgG2Ej9r9pQbeET/Cf9ifDXohknVzdPcYRZxhSJYMriC/81filFr+0G1LzkfWUCTBdQUHeZ4kL+n4PkR6wbITbzB1B3qV+VrvwpLzdMrNhtPy6iSMHB/2JgCVUxboIPaRPzAp0G7Y04+v85bPOGCkr++MlLUSDQzWfbYf2F0Z0KmepOYGdiq+2Cv2MIYnA8E4SJ8WDx6mB+m4OM4WWlvv8Mr9WieEofy12XXsIdP4XELxVDvSsS2dpcved6ONTr51H5cAw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1263; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1263; 20:SiPuyxyguQ/WNr2HN/1FIBGvcDu8KawbRa2QcyJ7cuM0Do4+1GS2utNRRCGTANiWy1kxx/U7WXo/Op5aQsYXe4I2mgWjdaZ997pJdnC1s7tTL9OTU7GJNJz6CCILOj3s4EfrXfQvsjPy4SfMR6AeujkkwO/U13AtQhyQEt8cx8moXFO5sEqYKkBdVuxrK8GFsnro+1HXf3CXAnWqi+2OqArofcIraNP0swWg5Bh6Vbj3C55WPh+2jIiyj1Vo7iKLPW1BHEKnDm4Veso0cDND28QwAOWx66ySfbD0RWJlWOWg+fTM2QCVSBK9n047GwliRPYVcaKeDNXv3Beoh+3zMb44SEpqN0bFU8ZVZJvxVFs=; 4:nbDKzDSZhHQRq912f8OoTfsqDtpz3drclPeUvtw8fo6lXKp7MqpiG+UlTBP0PQFQGETJs1ZP9z54i9vehYIaFO6pYtadE2w0pug90xua4Qlsede18B8iaqyOZ2SbqwKTBsh/JxLyE736sBjrvIJ6eelHHbUDhkOsRWpbnc/aEy/wmds9Q8R4hw0Hd2xRYzgBp9+z05qr0w6EsU0QjFCpCGNZKNH+mcLAr52uOWEAj77CFBA8QkqWnKuNy0ch5gVQLCOP7T4iQh0hXLc/xU1TJOJqmtVFSMij9Cp+MqwWCmz5Tjlw0musyrLpJL4DHx4pJiCAeBYthoabbJ6yXvEgri2C2mTEv2urCfeL9XV6Vv0= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001); SRVR:DM2PR0301MB1263; BCL:0; PCL:0; RULEID:; SRVR:DM2PR0301MB1263; X-Forefront-PRVS: 0725D9E8D0 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB1263; 23:PV1yAUc6KRKqOVwUHPUUUNn2dmeGPZUDRwJPBV9?= =?us-ascii?Q?B8KOIX4dFrWQPZ63TEJAQzzGeFwQSSQmaKXrlRbowbOYZwhOh+A+THibHyQf?= =?us-ascii?Q?ZGHnLgT21OFOQ/ZH65OLIHgJisVKTntydxXpTDA+RG5UGBYA0+lFDSZmwwOv?= =?us-ascii?Q?8VdxilWum146pGhHFvaeea+/rpOoPSK9uZH29iNdAvWxg7bSrua/zz2z+mBb?= =?us-ascii?Q?Vf15uWAg4AjmPueAmGEpchXcXD4xfc8f7FvW8CskGM5ItXSOz3HS6qVdWjCG?= =?us-ascii?Q?ASTWlmr/doF49bWeEUErxxnnFUTin9o9Q1oDLWMOrAeKuGnCepGxabBxN0zT?= =?us-ascii?Q?rahIK+sQqZT2zBYAOphlDDUEj0d0J0+G5+lky5XBBdxsC6O8OiHk9MsyYLmk?= =?us-ascii?Q?v/40aUdcXzXjRDohTRyuC5EW4iNxzGx0gET1L7slocGrDd+89mY+58qZx5P/?= =?us-ascii?Q?Vbd1SgTAYM/jeItAUsMR5qsWoEHQm+HUr/7fvbuM9l71k0lPMvrMpnfvYPgS?= =?us-ascii?Q?ntlLozacVaA2vD7gn2OFse9332Z1d4Xw/AwXSjI9d0SlgMs+aAcfoLwFhhUB?= =?us-ascii?Q?vEaL/CP8QqibPMJcsn7WBMayolmjp0DwqGQl6f10Kv+cvWyqDTq92K1e0aGJ?= =?us-ascii?Q?ECax9JdN2gKm6twQaK5BdsI/E/qUoxzycSJMZ+NChjUbY0HEaY4/mPMfoXhR?= =?us-ascii?Q?FnOnwwf1dkU5f33g2mQCFLco0U0kgnkWL269GtNXBaLMdIyZxpptvSp+S2VH?= =?us-ascii?Q?i64UwhZTPDxM16XfH+NNPI26SQNUH/5Wz1AQ672mbv0yyRQBkzVzRm7eixJi?= =?us-ascii?Q?wqwAXyEMO+Hav7STJFgpvhRNAQTh/E1MIzYM1x9MyJH6qqpMhpnH+YUYXveD?= =?us-ascii?Q?IN4HJGaKehguhN1BmqWQifZiPOVlX2ceZwyl2kwh2cV3Xvu8I2FSDR7kdMHt?= =?us-ascii?Q?ibooRnTtgvS7JSckANXUTV2KzQrsVpyZNarmiZApaGfzvy+mo+VFC3z2JXOD?= =?us-ascii?Q?O9OB6S42y2V8JTNlNP6u5SImTSfh1mOcixVoaJ881WPU45fGoZNs+XsO51ET?= =?us-ascii?Q?jl/Efdi3AsCVhnoxUKuLGle6mzNTeK46zSo6pvwy8Fd5F7jrO6g=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1263; 5:e9/vwTAxFS0yZm2emTRR7a6hnowJgopdQ61B+0QT1bsZmUXmo6NV9Qo306K1Liw0fXzi526UALZfW+3i21X5f3FRHpB/J6Ozw0M9MTuU2NbmX2Om2L35GJf7s13fnMidaRUQq7pDfeyiztPdVS21YA==; 24:LhMHhK2cyC7kn+ZQ+AJY6h/aC3K1CHVXbBUdCfKaN0IT1d5URLwnWQ82/FK/N4s/yqk6lmXLVzZJI4RxAc9dpb4QKGrYwK6JXM+qjma+WDQ=; 20:HBR5wq/8QOrWZr+SjULuFSv+XvdR4oPE4i4B0ellzfUeul/egFhBG+wnematRmkyf8hzSoXusGvb66K1AUqVlQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2015 06:22:54.7601 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB1263 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151009_232318_266597_8DB48440 X-CRM114-Status: GOOD ( 22.70 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Jingoo Han , Hu Mingkai-B21284 , Zang Roy-R61911 , Yoder Stuart-B08248 , Minghuan Lian , Zhou Wang , Bjorn Helgaas , Li Yang , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch adds PCIe support for LS1043a and LS2080a. Signed-off-by: Minghuan Lian --- This patch is based on v4.3-rc4 and [PATCH v10 3/6] PCI: designware: Add ARM64 support. change log v3: 1. Use 8 or 16 bit access function to simplify code 2. Add ls_add_pcie_port in accordance with other DesignWare-based drivers v2: 1. Rename ls2085a to ls2080a 2. Add ls_pcie_msi_host_init() drivers/pci/host/Kconfig | 2 +- drivers/pci/host/pci-layerscape.c | 215 +++++++++++++++++++++++++++----------- 2 files changed, 153 insertions(+), 64 deletions(-) diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index d5e58ba..b5f1a3b 100644 --- a/drivers/pci/host/Kconfig +++ b/drivers/pci/host/Kconfig @@ -105,7 +105,7 @@ config PCI_XGENE_MSI config PCI_LAYERSCAPE bool "Freescale Layerscape PCIe controller" - depends on OF && ARM + depends on OF && (ARM || ARM64) select PCIE_DW select MFD_SYSCON help diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c index b2328ea1..024727f 100644 --- a/drivers/pci/host/pci-layerscape.c +++ b/drivers/pci/host/pci-layerscape.c @@ -11,7 +11,6 @@ */ #include -#include #include #include #include @@ -32,27 +31,60 @@ #define LTSSM_STATE_MASK 0x3f #define LTSSM_PCIE_L0 0x11 /* L0 state */ -/* Symbol Timer Register and Filter Mask Register 1 */ -#define PCIE_STRFMR1 0x71c +/* PEX Internal Configuration Registers */ +#define PCIE_STRFMR1 0x71c /* Symbol Timer & Filter Mask Register1 */ +#define PCIE_DBI_RO_WR_EN 0x8bc /* DBI Read-Only Write Enable Register */ + +/* PEX LUT registers */ +#define PCIE_LUT_DBG 0x7FC /* PEX LUT Debug Register */ + +struct ls_pcie_drvdata { + u32 lut_offset; + u32 ltssm_shift; + struct pcie_host_ops *ops; +}; struct ls_pcie { - struct list_head node; - struct device *dev; - struct pci_bus *bus; - void __iomem *dbi; - struct regmap *scfg; struct pcie_port pp; + const struct ls_pcie_drvdata *drvdata; + void __iomem *regs; + void __iomem *lut; + struct regmap *scfg; int index; - int msi_irq; }; #define to_ls_pcie(x) container_of(x, struct ls_pcie, pp) -static int ls_pcie_link_up(struct pcie_port *pp) +static bool ls_pcie_is_bridge(struct ls_pcie *pcie) +{ + u32 header_type; + + header_type = ioread8(pcie->regs + PCI_HEADER_TYPE); + header_type &= 0x7f; + + return header_type == PCI_HEADER_TYPE_BRIDGE; +} + +/* Clear multi-function bit */ +static void ls_pcie_clear_multifunction(struct ls_pcie *pcie) +{ + iowrite8(PCI_HEADER_TYPE_BRIDGE, pcie->regs + PCI_HEADER_TYPE); +} + +/* Fix class value */ +static void ls_pcie_fix_class(struct ls_pcie *pcie) +{ + iowrite16(PCI_CLASS_BRIDGE_PCI, pcie->regs + PCI_CLASS_DEVICE); +} + +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; @@ -62,56 +94,124 @@ static int ls_pcie_link_up(struct pcie_port *pp) return 1; } -static int ls_pcie_establish_link(struct pcie_port *pp) +static void ls1021_pcie_host_init(struct pcie_port *pp) { - unsigned int retries; + struct ls_pcie *pcie = to_ls_pcie(pp); + u32 val, index[2]; - for (retries = 0; retries < 200; retries++) { - if (dw_pcie_link_up(pp)) - return 0; - usleep_range(100, 1000); + 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; } - dev_err(pp->dev, "phy link never came up\n"); - return -EINVAL; + if (of_property_read_u32_array(pp->dev->of_node, + "fsl,pcie-scfg", index, 2)) { + pcie->scfg = NULL; + return; + } + pcie->index = index[1]; + + /* + * LS1021A Workaround for internal TKT228622 + * to fix the INTx hang issue + */ + val = ioread32(pcie->regs + PCIE_STRFMR1); + val &= 0xffff; + iowrite32(val, pcie->regs + PCIE_STRFMR1); +} + +static int ls_pcie_link_up(struct pcie_port *pp) +{ + struct ls_pcie *pcie = to_ls_pcie(pp); + u32 state; + + state = (ioread32(pcie->lut + PCIE_LUT_DBG) >> + pcie->drvdata->ltssm_shift) & + LTSSM_STATE_MASK; + + if (state < LTSSM_PCIE_L0) + return 0; + + return 1; } static void ls_pcie_host_init(struct pcie_port *pp) { struct ls_pcie *pcie = to_ls_pcie(pp); - u32 val; - dw_pcie_setup_rc(pp); - ls_pcie_establish_link(pp); + iowrite32(1, pcie->regs + PCIE_DBI_RO_WR_EN); + ls_pcie_fix_class(pcie); + ls_pcie_clear_multifunction(pcie); + iowrite32(0, pcie->regs + PCIE_DBI_RO_WR_EN); +} - /* - * LS1021A Workaround for internal TKT228622 - * to fix the INTx hang issue - */ - val = ioread32(pcie->dbi + PCIE_STRFMR1); - val &= 0xffff; - iowrite32(val, pcie->dbi + PCIE_STRFMR1); +static int ls_pcie_msi_host_init(struct pcie_port *pp, + struct msi_controller *chip) +{ + struct device_node *msi_node; + struct device_node *np = pp->dev->of_node; + + msi_node = of_parse_phandle(np, "msi-parent", 0); + if (!msi_node) { + dev_err(pp->dev, "failed to find msi-parent\n"); + return -EINVAL; + } + + return 0; } +static struct pcie_host_ops ls1021_pcie_host_ops = { + .link_up = ls1021_pcie_link_up, + .host_init = ls1021_pcie_host_init, + .msi_host_init = ls_pcie_msi_host_init, +}; + static struct pcie_host_ops ls_pcie_host_ops = { .link_up = ls_pcie_link_up, .host_init = ls_pcie_host_init, + .msi_host_init = ls_pcie_msi_host_init, +}; + +static struct ls_pcie_drvdata ls1021_drvdata = { + .ops = &ls1021_pcie_host_ops, +}; + +static struct ls_pcie_drvdata ls1043_drvdata = { + .lut_offset = 0x10000, + .ltssm_shift = 24, + .ops = &ls_pcie_host_ops, +}; + +static struct ls_pcie_drvdata ls2080_drvdata = { + .lut_offset = 0x80000, + .ltssm_shift = 0, + .ops = &ls_pcie_host_ops, }; -static int ls_add_pcie_port(struct ls_pcie *pcie) +static const struct of_device_id ls_pcie_of_match[] = { + { .compatible = "fsl,ls1021a-pcie", .data = &ls1021_drvdata }, + { .compatible = "fsl,ls1043a-pcie", .data = &ls1043_drvdata }, + { .compatible = "fsl,ls2080a-pcie", .data = &ls2080_drvdata }, + { }, +}; +MODULE_DEVICE_TABLE(of, ls_pcie_of_match); + +static int __init ls_add_pcie_port(struct pcie_port *pp, + struct platform_device *pdev) { - struct pcie_port *pp; int ret; + struct ls_pcie *pcie = to_ls_pcie(pp); - pp = &pcie->pp; - pp->dev = pcie->dev; - pp->dbi_base = pcie->dbi; - pp->root_bus_nr = -1; - pp->ops = &ls_pcie_host_ops; + pp->dev = &pdev->dev; + pp->dbi_base = pcie->regs; + pp->ops = pcie->drvdata->ops; ret = dw_pcie_host_init(pp); if (ret) { - dev_err(pp->dev, "failed to initialize host\n"); + dev_err(&pdev->dev, "failed to initialize host\n"); return ret; } @@ -120,39 +220,34 @@ 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]; + struct resource *res; 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; - pcie->dev = &pdev->dev; - - dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); - pcie->dbi = devm_ioremap_resource(&pdev->dev, dbi_base); - if (IS_ERR(pcie->dbi)) { + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); + pcie->regs = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(pcie->regs)) { dev_err(&pdev->dev, "missing *regs* space\n"); - return PTR_ERR(pcie->dbi); + return PTR_ERR(pcie->regs); } - 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); - } + pcie->drvdata = match->data; + pcie->lut = pcie->regs + pcie->drvdata->lut_offset; - ret = of_property_read_u32_array(pdev->dev.of_node, - "fsl,pcie-scfg", index, 2); - if (ret) - return ret; - pcie->index = index[1]; + if (!ls_pcie_is_bridge(pcie)) + return -ENODEV; - ret = ls_add_pcie_port(pcie); - if (ret < 0) + ret = ls_add_pcie_port(&pcie->pp, pdev); + if (ret) return ret; platform_set_drvdata(pdev, pcie); @@ -160,12 +255,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",