From patchwork Fri Oct 16 07:19:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minghuan Lian X-Patchwork-Id: 7411841 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A51BABEEA4 for ; Fri, 16 Oct 2015 07:24:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 92B882069B for ; Fri, 16 Oct 2015 07:24:31 +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 5A4332085D for ; Fri, 16 Oct 2015 07:24:29 +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 1ZmzLf-0007Yl-RN; Fri, 16 Oct 2015 07:22:43 +0000 Received: from mail-bn1bn0107.outbound.protection.outlook.com ([157.56.110.107] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmzIG-0001Dc-KJ for linux-arm-kernel@lists.infradead.org; Fri, 16 Oct 2015 07:19:14 +0000 Received: from BY2PR03CA038.namprd03.prod.outlook.com (10.141.249.11) by BY2PR03MB572.namprd03.prod.outlook.com (10.141.143.152) with Microsoft SMTP Server (TLS) id 15.1.293.16; Fri, 16 Oct 2015 07:18:50 +0000 Received: from BN1BFFO11FD041.protection.gbl (2a01:111:f400:7c10::1:142) by BY2PR03CA038.outlook.office365.com (2a01:111:e400:2c5d::11) with Microsoft SMTP Server (TLS) id 15.1.300.14 via Frontend Transport; Fri, 16 Oct 2015 07:18:50 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) 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.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD041.mail.protection.outlook.com (10.58.144.104) with Microsoft SMTP Server (TLS) id 15.1.293.9 via Frontend Transport; Fri, 16 Oct 2015 07:18:49 +0000 Received: from lmh.ap.freescale.net (lmh.ap.freescale.net [10.193.20.20]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t9G7ISIL004957; Fri, 16 Oct 2015 00:18:45 -0700 From: Minghuan Lian To: Subject: [PATCH v4 5/6] PCI: layerscape: add PCIe support for LS1043a and LS2080a Date: Fri, 16 Oct 2015 15:19:19 +0800 Message-ID: <1444979960-24100-5-git-send-email-Minghuan.Lian@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444979960-24100-1-git-send-email-Minghuan.Lian@freescale.com> References: <1444979960-24100-1-git-send-email-Minghuan.Lian@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD041; 1:OxPWYpGFSCtqS5R3ol8NEj8G89+inRSHMgScHow0MnARBVrWUjp/k1VahE+BLuuk46EW8qgfgsM2pxRS1EWRqhRF/MO1ZbcZl8DFxL6tH9VDb9qKW6DdOcTE9ZbQwSobjPY9cJnQe6A4rhn5xelSiwhYO+iMBVN4KKbArGWTCdjHEWMrXkJho/nqj6UB500xEXRU4yDSVwuN0T/eXVyM1ATvcbEfkgzvbj/AxviX2+q0J+glzUgMJ2AQK5tkbHKGnkeXBBOyPW7oLAUatjwQICis6pW2SAhqemBInxbBWO0Ldm+s+dGdOrAX4iJfgMX8MP+NqbPyci0Vh94deBr/9iUJobT6+rB00hE5oZCBOStkhr8cBIv4LKeNrWIvYk8lz9AuK0VgKX3o3HIyhjP+Dg== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(54534003)(199003)(5001960100002)(11100500001)(77096005)(85426001)(47776003)(50226001)(87936001)(6806005)(107886002)(229853001)(110136002)(105606002)(106466001)(19580395003)(92566002)(104016004)(86362001)(2950100001)(46102003)(64706001)(5007970100001)(5008740100001)(81156007)(189998001)(19580405001)(48376002)(2351001)(76176999)(50986999)(36756003)(50466002)(97736004)(5003940100001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB572; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB572; 2:6+rcYR1bLMTMkl0HJunxZ3vLEvxm4QcAxsRNPQJRJDcWg71WRHjUrwskfhKYpToq2xcKKm/aiCBunnFcQviUbqbCGU3iJNiwWxuP9gal5+m9lNnzYQk6OIfkg2s4Ic89gmJat6TcaZJPtHvbZ32HCtiDSgiNyY+h+aPagdBQe74=; 3:IiaswqkFPxUEFzKK9987ukJB3GIL0pQh0ErC1CGGh4/iSfE5oeQBVOVtUmSoD0vUkcwwONHBb/aFKqbwyOsXXY37UNXLTI+w7DOo+ruW1LBGfxI6zKL7TH4hcH/SWud2tS2DGqwd7mx14EeKxscaklVz7bAphA0cdtntv3W/qqfijOHqgKTz+LpvcivRT7CpywQR/Yo5zt+Sq0b10si8y82B/mKRT2YT4Y5Ih6nLy6k=; 25:WrfrmeXbW5qmJrFQ8I8OhuDbWxFAYWSZNksyrlflK/N4u4/54YtlcxsU/Cod+YyFvRj00vI0ZKisbWFyUU0m5ZqcRKBwxlrfta8Nuj6PJaYf01q46gpz/BPlyLysNjBfDcTUd88Xbo3c01PKLUdnVvyq/Wm26UXAZTRugQ2mHQJyvMj4O8Q/dBV5gkWyd8CFSHH0ckhha5JperefNC4Jh6K09c78zSAWeKiInSrlha2mavyHklz3YQ8Q5KJIazPYldN5RwQDzJcFlZjTHGwvtw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB572; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB572; 20:ZzDQfSO2YYgvussuRpy3dRG4DKGdcfo4OsQdQATd1iTUj+kiicjVpKrIexjV5mV9y6tBreWNrJn8vQfqhbEMOUT6QZX49PU/ADLs1NawTGc3KuuPL8f3J2iljM45FLgkoUXA54ycBYoa05erst7c1AphEck4nbI/JcFlZh/fh+tVE4Oaln4/u0gSyIXQJth0GBlRjpka2ITbqyEw5ThsUXmGtJrJyDgUKE+KIbNmFliBfvpp1ndnHV9eh4qpDhuOdKcDCnbriVb0vff7KK+Q/DSQzG7nLyvwZAbDjt4lbkBVkhov+vGFSfU96bapKdRF3Q2tV1oy2h/I1rMJmXoTDTe514XBNRTBVk9cIusErAw=; 4:IepSRDz5a3WX+31kVgdsh+Gl9nWrWas9vK182n5Wz/shpNjzlzDY2fGdg/zEZImIxOaPyb1NbOioSMDu8/ve5s4MvRKLgHCIYQh9puWaJv7RB1A/X8JIGu6b8AHRxtr+/w9GciwFvBgd7FuiV6RPWvrYcuYVTB0Cl1NrcjINI3zFVA5wTLQxUmeVESCBeQLvnnvJlVxWopc5yvmJHE+T6ODFSCV79u+emWVoNfF9KMSSlAsS8T9zo2+oczfvkygoiwI/PwtSZUzmR78q/69noFJYLyhx0SRoNGPseZ3hBIIQVIQ8V9R77rDZ2IulAYJM74DpSZob/S7H4OHcr1qiO5U7Pa83oZJMwz0LpYtNV0I= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001); SRVR:BY2PR03MB572; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB572; X-Forefront-PRVS: 0731AA2DE6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB572; 23:Yf2JBLRVIGwhvIjONuBU8McshJeXUnBJMxeJ247oRH?= =?us-ascii?Q?/nITXg1G73n3MKf3m4ma9qPvUg+n5iqLIHJwxPDHCSGdmgqD9M/MBZ4xktGG?= =?us-ascii?Q?SsBFOLhYDuZzRNQiXTNBqphjMD11coz6t1MzZxhEjKVh8Osbsy+0Rz43+QGu?= =?us-ascii?Q?mpCXmuvZpJJVT/I30+bMfkGkvpLNHTDil5y0SCTI7fsXkWdC7A6MLhLK37nh?= =?us-ascii?Q?ZTCWB70SI9JyxppHn6s79oiF0rKqBbNcsCn+RcUBY7PrwqbsVCF9VxsmxJ4z?= =?us-ascii?Q?1MHtfwTtXD5BamGCV+HOq2f4KUXcFDx2Bb6YrXXkaTjwwCXV+1ajyz/ayYA/?= =?us-ascii?Q?kZu9zW/HH2TqM8gvFSKImFr7CZKLXKjIBJp5Nw4/BfACCcIz5eSPsI53KWD6?= =?us-ascii?Q?G3Pnqkoo1x1y5awYNAnbhkyAQVHbpMNF9stFOYoqeFSvD9VPsJXExxsPdJMW?= =?us-ascii?Q?BaOQu9WGacSoIjCMun4QkIqfhbIMz2/tDTY8HLWeGKNO2JJ4QS7KmP9cag4h?= =?us-ascii?Q?3CaUwk5kqc/Tolsn1v3B112ucSI/1nCn8Ht5v0ArJk5LW5VykTI7zz6jLFSo?= =?us-ascii?Q?Py/6mt5OhFWJ1TXwm1DWn3dMwnj1IRUOeJFOPlEzZn0o6tBEc4g/Dg/QVW4t?= =?us-ascii?Q?Sg4Exo0P/QTdqsiLqnSGAAziE7JpNAAPv6dgKws+PdUh4J7HX7sevG/O7R9F?= =?us-ascii?Q?TUl2Oaa8bEyIs1CpIgStyJI3V/EuKg7Ah62LwtxTC9j0kk+BcE6nny8VprNt?= =?us-ascii?Q?VZpyqwYreTMyWwXfqx2APzw4B7/Wt3SzuQqP4W1xapx5PykpuMjbfN3+9DIA?= =?us-ascii?Q?xTtbTy3QW+glkKvLxss5+I2i+VM6Bj+7nxTjMntcawbuOSeCLiXCgWZmrTNX?= =?us-ascii?Q?20VrjALeWvhaYwntffiE1O8I2uohWeHmNI0VnfiryFDEL+W2fkGvHlKtq5LG?= =?us-ascii?Q?iTwl5cS3T0bJjAawH8LjlPCdIIBm53BsVHjIQuxPeplB7SES8JxlQu4qckC6?= =?us-ascii?Q?b6pVAME/srF2ibkHKEyY3H1Higu7OQZw5Zym5cnzyH1rjn6TknOxgWhUeNsh?= =?us-ascii?Q?xwofra+7pkwzwa0+T/Q9q/hGWjIDkDhEbNhz48dLbPlGDhbXWTbYfsL1hpjZ?= =?us-ascii?Q?k1GOrb+K7hSqY/m2qHtm2S5sJyhf1D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB572; 5:G+hThFfWkcvgnow7e53O/9UObAw+Ag28Ti/KDk45CxI6JjytTSXULfy7t1cBsU2GEOwUf7n6+JS+pgcKACVY9GRu3tmHxrtBsPu3siP/rHNBsdihq3NMYVyvaHcHvvUH2V9BT8fUMiVI+RiAIlPF1w==; 24:RimBpch+4EHbzmoU1mHGVkFpiIwumCmiRSHqXob5W4SfTYw2CpZwS9MqsmHMj/KGXIhHCg+zc1Uk6CBrGPXc1C+/FCAitbS4PtW7TL/Cqe8=; 20:BUer/YHv4CHTh3W0XaKU/VcNU3kk84QE6tfzoIYpDdYdgQRHoxK4PoptmTsTjmVjkTvOEvN9RD6HzJSUJa7hew== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2015 07:18:49.5051 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB572 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151016_001913_036890_DD7E81DD X-CRM114-Status: GOOD ( 22.86 ) 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 Both LS1043a and LS2080a are based on ARMv8 64-bit architecture and have similar PCIe implementation. LUT is added to controller. The patch removes the necessary fields from struct ls_pcie. 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 v4: 1. split to 6 patches. 2. use ARCH_LAYERSCAPE instead of ARM64 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 | 72 +++++++++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index ae873be..8eb09ea 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 || ARCH_LAYERSCAPE) select PCIE_DW select MFD_SYSCON help diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c index 891e504..c53692a 100644 --- a/drivers/pci/host/pci-layerscape.c +++ b/drivers/pci/host/pci-layerscape.c @@ -31,23 +31,26 @@ #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; + void __iomem *lut; struct regmap *scfg; struct pcie_port pp; const struct ls_pcie_drvdata *drvdata; int index; - int msi_irq; }; #define to_ls_pcie(x) container_of(x, struct ls_pcie, pp) @@ -62,6 +65,18 @@ static bool ls_pcie_is_bridge(struct ls_pcie *pcie) 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->dbi + PCI_HEADER_TYPE); +} + +/* Fix class value */ +static void ls_pcie_fix_class(struct ls_pcie *pcie) +{ + iowrite16(PCI_CLASS_BRIDGE_PCI, pcie->dbi + PCI_CLASS_DEVICE); +} + static int ls1021_pcie_link_up(struct pcie_port *pp) { u32 state; @@ -110,17 +125,61 @@ static void ls1021_pcie_host_init(struct pcie_port *pp) iowrite32(val, pcie->dbi + 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); + + iowrite32(1, pcie->dbi + PCIE_DBI_RO_WR_EN); + ls_pcie_fix_class(pcie); + ls_pcie_clear_multifunction(pcie); + iowrite32(0, pcie->dbi + PCIE_DBI_RO_WR_EN); +} + static struct pcie_host_ops ls1021_pcie_host_ops = { .link_up = ls1021_pcie_link_up, .host_init = ls1021_pcie_host_init, }; +static struct pcie_host_ops ls_pcie_host_ops = { + .link_up = ls_pcie_link_up, + .host_init = ls_pcie_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 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); @@ -167,6 +226,7 @@ static int __init ls_pcie_probe(struct platform_device *pdev) } pcie->drvdata = match->data; + pcie->lut = pcie->dbi + pcie->drvdata->lut_offset; if (!ls_pcie_is_bridge(pcie)) return -ENODEV;