Received: by 10.223.164.221 with SMTP id h29csp3165185wrb; Fri, 3 Nov 2017 02:51:04 -0700 (PDT) X-Google-Smtp-Source: ABhQp+R/YNIrMzDENUha5fIJevSH/1eyastqrnOgailnzZ2IfIOJWJqLn0bbvhtDxVkO7NLzSOn7 X-Received: by 10.84.142.129 with SMTP id 1mr6276385plx.341.1509702664470; Fri, 03 Nov 2017 02:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509702664; cv=none; d=google.com; s=arc-20160816; b=peOtMsjUKazM7Lk2W841toEs+qHQoZ3GEMNOmhNQCF/npVbVtCAZRa5RYxl93qLCtO ylz6/se8FoFL3YjwArZABiOzOjT1HWN6KScbUPMctuExZnB/wsARjYy2U/2s+9nnJwYJ cBxvDUbeTIRBPizmJiLc9eNldIzNWuWKyA2UMn45MrjFFN8aqiuEyGJ/nkk8xb9hWgUx nS+oKH45DXOAjX0uASEkgQG6raUC96zbt8v67P7k3CMBBo0hA/hEw7FlncCKmquAbTRv IpfbUT56zhwLvEJMbjHAItz4yXdgB6493yt4nawOrS+rwX2huyw+2CQxqe85Y+xcYoB9 jLdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results; bh=TVSjGKvR+FqU5PBFjDAWSgCe+pbvDlCqEBbTBmbJtG8=; b=aMZzRE/2N1oru/JSNi/UhL5FSi879wdnvluQRQ1NHkubwI34TdqUB3AkwKFjfTfJsD toE+6Ru9MauzljM3T+tjYupsQVJ48iGHejuIWIZAnUyp0z5OZTTmrQt4FvHVBNFhE/D0 MlbjbnvA7EYPsUAJNDl7nJR8YTAp8n6mk+OL5WSiI/smTA5zCaySo6PbzP8eUvqvZewx CJ3OExPhNk/43UTu7XKYZgbpG0XkPMjm+NdGrl+FgSO0Hx1oXIZ/dLlLloHpwJS/8pJk t5p6V6MNkV1nthue+tdRjQjXMkwQOtDYvtjcCRzFLmOwFLJ3myVnNK4R3KLZXOFQRBmP fUEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si4738875plt.232.2017.11.03.02.50.51; Fri, 03 Nov 2017 02:51:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932716AbdKCJuB (ORCPT + 97 others); Fri, 3 Nov 2017 05:50:01 -0400 Received: from mail-cys01nam02on0043.outbound.protection.outlook.com ([104.47.37.43]:52224 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755853AbdKCJty (ORCPT ); Fri, 3 Nov 2017 05:49:54 -0400 Received: from BN6PR03CA0060.namprd03.prod.outlook.com (10.173.137.22) by CO2PR03MB2358.namprd03.prod.outlook.com (10.166.93.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.197.13; Fri, 3 Nov 2017 09:49:52 +0000 Received: from BN1AFFO11FD045.protection.gbl (2a01:111:f400:7c10::127) by BN6PR03CA0060.outlook.office365.com (2603:10b6:404:4c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.178.6 via Frontend Transport; Fri, 3 Nov 2017 09:49:52 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.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 BN1AFFO11FD045.mail.protection.outlook.com (10.58.53.60) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.178.5 via Frontend Transport; Fri, 3 Nov 2017 09:49:51 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id vA39nNmR022617; Fri, 3 Nov 2017 02:49:44 -0700 From: Bao Xiaowei To: , , , , , , , , , , , , , , , , , , , , , , , CC: Bao Xiaowei Subject: [PATCH 2/3] ARMv8: layerscape: add the pcie ep function support Date: Fri, 3 Nov 2017 17:31:14 +0800 Message-ID: <20171103093115.14915-3-xiaowei.bao@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171103093115.14915-1-xiaowei.bao@nxp.com> References: <20171103093115.14915-1-xiaowei.bao@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131541761921105449;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7966004)(336005)(346002)(376002)(39380400002)(39860400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(104016004)(305945005)(316002)(2950100002)(33646002)(85426001)(6666003)(105606002)(6636002)(36756003)(106466001)(356003)(50986999)(76176999)(5003940100001)(189998001)(8656006)(97736004)(1076002)(8676002)(53936002)(86362001)(7416002)(39060400002)(68736007)(2201001)(81156014)(4326008)(81166006)(50466002)(110136005)(48376002)(2906002)(5660300001)(50226002)(47776003)(575784001)(16586007)(498600001)(8936002)(77096006)(921003)(1121003)(2101003)(83996005);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR03MB2358;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD045;1:0oLapve76Fp9TdqWC8++uZYd9BQiIZ2zGjOcs6IB5s9nKwx1S5NgZPcLT9b7p9vY2D6QIvljO5DWub2CfF+bwdH/WkLWgEfMMkkzMWFWJYEtHIO5eRAYsQTRlWHeEbhq MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0fcf0e27-4c3b-4c4e-5cca-08d522a03ae4 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4628075)(201703131517081)(2017052603199);SRVR:CO2PR03MB2358; X-Microsoft-Exchange-Diagnostics: 1;CO2PR03MB2358;3:Osd8gqQ9e/+YAQw0vSVFc5WyUeqSQKsvrIyZnQCynLWzvM60jGiWl3LA3OIBxbB4BxOVSBPPwt3k7FwyxBzX31x6Z7GpQypR//pBtR/Qva/sqg0xFKqJgZRYBwE1PSz1PdcwneHKT545qdP/5ynAWiwc2rwy1+s7FdJeB9FrWIj8Dr0JTrHRbBWgiQEO5Z4Misnkd4GK0olzwMyynx7KbGqF2s5dANCisPH6T0lUC9dVPM7L+vW5WkF27pv/JBtG/FL99XC7UGl7or9iLBawSEIKHECOFy9VI+pjHmZZH6zmT2rH7S/dQho0LPWtupJ8oMZF7zooAOefn8+SMoIURqN8J/nOJFw1GDA8/EQr7CQ=;25:IIx38QYraGZiy7bIfXqwjPdcScWpE22mubRFQjXtwB667c3Af2N5aBn5ZkIe+cOERpt8nCEvCcUbXZ6jF3bphaQnP/+hU4TG/0DFYxzZo0V8fCktGTKFkzNfou9UYZVFSsCYiehuwwKnFMnO1/+rM6MdNGepfksBkiPuhOAWVWNrKmDtUiI1UepvPxHE39XZoIqqMFJBqqKLYX53ju0w1ftIN/6DK86Z4NZ36dGpN39aUSxP9PfYcuV7BFuXRGPLGlqswXdbbJ2JqEh+M44UL6E9MQ2DH79gwGgAMqz1yPz3OPT9iGpEIKvT7dBBzLPM7qVlLEsSND4UApuZ7sxrXA== X-MS-TrafficTypeDiagnostic: CO2PR03MB2358: X-Microsoft-Exchange-Diagnostics: 1;CO2PR03MB2358;31:82tXR2nNjsOzLomuYbtQnwracZx+ds+0RhHo1fhmMM6IzrVRfBtNuHxBFqZC3+B81CQxtAFmFhLnEerxpdR8mO34gpROHg+Tpkklw6jCHzaBaqcUf9hXBIRCDXWBLEibPm8Wohxnut83aeYbKjWVM5reJEHJSLRvrNFRH/srVjZ4kjbFM0YreOGIfoLC5fCVTdbeRKxjX84qDx6mZoL8c5SgxIOB0Ge043WG9zbz/1s=;4:V2t6VPe6sRRTLSCBCkDVApi8ac39jpLHdZV7s3Z9WDoxwthTXIAhvdLAaqn3uOLVQa8tZx7W5IgracoZFtLtY5+RP+IzoH4B6Q06go/b76bWrkcFuPa2gQ/h1BuodnKUCpyM/kK+/tKpbIGgfw2DyooAYp7/2+dG5LwG08TQbpTWShzqn5VC2DDQhhw/H8mvIUajooQdRDjX/tOw+IbXRiJKwSRgr3buL7zOUb04ybbeD0hU3IWJ7l/XF69zn+Qfbf/RpFqUzIb0u6wXziCyRBrAb3A9HjmPlNWn1U6BPpS2tRUQd+mR6cO040QLDELW X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231021)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6096035)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123561025)(20161123565025)(20161123559100)(20161123556025)(20161123563025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CO2PR03MB2358;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CO2PR03MB2358; X-Forefront-PRVS: 0480A51D4A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO2PR03MB2358;23:OGAx4rLzitkcKJsbWT8pMovU5UOOYdVQQxGykqbhe?= =?us-ascii?Q?IIaBhUjXxmV9Xu/LmGOK4V/84w99doLtUrgtDFyAb05OSDq7EV2WYiF9YSbN?= =?us-ascii?Q?fOVs1A3CcnPJeI3t0gMnDwr0rV4T1FaNry0N++456frvMzFE38oap7ybxC6s?= =?us-ascii?Q?6pz0QCDRXHJropPAYNsES/oAnQdPGBrSG7Uy0MDl2zfuuo3iJoucMiHZ9lOU?= =?us-ascii?Q?T1VYS6O7mg2u/wUoKLF1OXjoj37OmY4NdvqpwOYZmu5+XYNUi2I5K68DUItQ?= =?us-ascii?Q?akgJiYhK3C5k1J5qI3blMC8lh3sAXkV/I+eNprTb/jJOrrp70tfPlm3Fgq6+?= =?us-ascii?Q?GLSf7ZY9k6nFpPHuvdVNa0t4FxrYONZzFtt8WBQP6tQ7W80VHb3Nn7sR66u6?= =?us-ascii?Q?ylOnxqc0Ggnrt+wZBo85G4xTZoNz4mn5URHYyYibMCE2N5i59i5IATFxCM0u?= =?us-ascii?Q?8LYtKlj/ApNiCoerureZOxKyzGs+DiOd/NvxAofDaVyFK3L2uBCjL47VFk8i?= =?us-ascii?Q?gDpOhqXIbtxrkehmM33mobV7jdpRVVYuqWX+NYa9IZ8tZ0tSFRe0UjftNDd8?= =?us-ascii?Q?vlFnr/+mZ0jQGsB24wj0AyT/xdxgVKVyP6Ry8tYLpKmdaJ1pnBFx3kGlRcbw?= =?us-ascii?Q?+AYdGmQqMiGZ/bT5P+ZAMmFHzNo7z7p7SbLsxJE6umhvWIS8pY4jRMpZX/P6?= =?us-ascii?Q?EBtnkoTOFzGAdYvfk6HVPVkh1t10wsHKKQH8W9pZMi4ZuQHQsfX39vbp4MUy?= =?us-ascii?Q?f+xArjKVVqCOjbOyWEd8XwEVKHRB5v498225ay6hoIhhO+pueSEQLRA5aSqz?= =?us-ascii?Q?qwiXarDxL81jW3dQtC7saW+pAKlhE8Hddb4erUhMb+0w+/vk18WK7yv6Sa1o?= =?us-ascii?Q?fDr1jNQxHCWPRa/laTH5ugMRy4a12Cm+yybTmitkiHfJwRQlrB+ImCreT8AT?= =?us-ascii?Q?BqPwdaF+FkJYxuFI3mglkLm1RpUov4ImFRHuQljrvBul3cpEbomFFpU/keDZ?= =?us-ascii?Q?SS0M5RT2h3HmoLD7D9IKsiyi9cxsRI4q5BjGLIk9i41yY38LKf9nZEOQpre5?= =?us-ascii?Q?NTbl2b8zyapanl7t++GTtriT7k05MfXvSdBH2vEk2XXWlWeJQGhC/Ri4sgJR?= =?us-ascii?Q?pFKzqSgGLbKRveBe5IRK3BxdGmc16zYMGX+tQw97ejsmZlzFEYfvwKK0H2ik?= =?us-ascii?Q?vX5m9S9TeVhK/qd8/X60d/P+WrE1GgP/U+03hI91VC90uKapLYDGfCd3iTqP?= =?us-ascii?Q?WT1BP3CFWGpNK5TMVz4SBI46ABCfQ3tVj4NSbC+pqDqVFD37npE7vCW8lMKY?= =?us-ascii?Q?nVyDWHnjU8RGHIe27EYUhEjhZ90QwMU2RtGeHO2v89w?= X-Microsoft-Exchange-Diagnostics: 1;CO2PR03MB2358;6:yNrzH5eljNZ5uFbd+VzooTvzDOAjAAdFGpF5N19Qhh6Qayg2TfFlz2LpKGTPwIsMauD67e9rObWpgNnylP9lSCb7+0ZHqjdSzJMyUSsDjJuhs2BA188PkkHEBjQm7J5EIJrMRVtHVSY5DAn/11gj6KR3Wnjz6NV4lu4zGotdIAUj/wO/isUjgicfgnPRDz4dXlIHjzj8KSl/oi12J9bvBXYd5I7FvwXHMKgJcaj0fGR01fIH+iZToQVxWeeg1O/sxlqegGYEjcDCZJwqfcVPK4e6PJ9tzEL4yrwOu44pYi9cjnW1SiOb5W06U+CKmmtz4gMwjglcRXiQ+wQxRYEn7T//s9XNaWa7HPnCt0lMe2k=;5:0AUn0Ho9ZBOhSJiQMcF2E16+ICIuzVMIY87PkZS22+SyUWP/0jlET6VWypx9uQsbizr8RvefC/heWG1J0wC3FNET/Zgkc4ACZmtM29N2uGEWHzALmHtHDQnkqqnLKTilXiQUVhXOXo/HszdpurKcccr/jkyBjqzrURQoZsQTWW8=;24:TYAYOr9m740y3EFcQrsVgF25mCQQbvENqcLUIhHK448FjT9YM63XWGwn1RYJ/RNJe/Bwad0i5LjbPcdPOK8juq/MwIdwyzbGBlk5ejfk98s=;7:kiBknxjKiHtGwpfWADzMDHlJ691ghLpuTO+sffVzGWedgCj4Fq9Ty3WAQUozB3KhfAbv8uoyALrhhafulzODq8PK8aynPdx/tvJmVaEjBLuy4RAuTzc18Am7xedX1DNzFI9LvVpqMmz+TwNsKc5nDqEcKAE9MDdWT8aqF1XtcSI+j/KSVuAJ7V1L0H6AEiLlSnQyzehE+7ZWi9SaJKx8afIYDSH0IBSHNXJw/M525N4yuF03SSLQ2YJtJd1DrhTx SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2017 09:49:51.8453 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0fcf0e27-4c3b-4c4e-5cca-08d522a03ae4 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR03MB2358 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the pcie controller ep function support of layerscape base on pcie ep framework. Signed-off-by: Bao Xiaowei --- v2: - fix the ioremap function used but no ioumap issue - optimize the code structure - add code comments drivers/pci/dwc/pci-layerscape.c | 122 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 116 insertions(+), 6 deletions(-) diff --git a/drivers/pci/dwc/pci-layerscape.c b/drivers/pci/dwc/pci-layerscape.c index 87fa486bee2c..ab1ac1fcd0c4 100644 --- a/drivers/pci/dwc/pci-layerscape.c +++ b/drivers/pci/dwc/pci-layerscape.c @@ -34,7 +34,12 @@ /* PEX Internal Configuration Registers */ #define PCIE_STRFMR1 0x71c /* Symbol Timer & Filter Mask Register1 */ +#define PCIE_DBI2_BASE 0x1000 /* DBI2 base address*/ +#define PCIE_MSI_MSG_DATA_OFF 0x5c /* MSI Data register address*/ +#define PCIE_MSI_OB_SIZE 4096 +#define PCIE_MSI_ADDR_OFFSET (1024 * 1024) #define PCIE_IATU_NUM 6 +#define PCIE_EP_ADDR_SPACE_SIZE 0x100000000 struct ls_pcie_drvdata { u32 lut_offset; @@ -44,12 +49,20 @@ struct ls_pcie_drvdata { const struct dw_pcie_ops *dw_pcie_ops; }; +struct ls_pcie_ep { + dma_addr_t msi_phys_addr; + void __iomem *msi_virt_addr; + u64 msi_msg_addr; + u16 msi_msg_data; +}; + struct ls_pcie { struct dw_pcie *pci; void __iomem *lut; struct regmap *scfg; const struct ls_pcie_drvdata *drvdata; int index; + struct ls_pcie_ep *pcie_ep; }; #define to_ls_pcie(x) dev_get_drvdata((x)->dev) @@ -263,6 +276,98 @@ static const struct of_device_id ls_pcie_of_match[] = { { }, }; +static void ls_pcie_raise_msi_irq(struct ls_pcie_ep *pcie_ep) +{ + iowrite32(pcie_ep->msi_msg_data, pcie_ep->msi_virt_addr); +} + +static int ls_pcie_raise_irq(struct dw_pcie_ep *ep, + enum pci_epc_irq_type type, u8 interrupt_num) +{ + struct dw_pcie *pci = to_dw_pcie_from_ep(ep); + struct ls_pcie *pcie = to_ls_pcie(pci); + struct ls_pcie_ep *pcie_ep = pcie->pcie_ep; + u32 free_win; + + /* get the msi message address and msi message data */ + pcie_ep->msi_msg_addr = ioread32(pci->dbi_base + MSI_MESSAGE_ADDR_L32) | + (((u64)ioread32(pci->dbi_base + MSI_MESSAGE_ADDR_U32)) << 32); + pcie_ep->msi_msg_data = ioread16(pci->dbi_base + PCIE_MSI_MSG_DATA_OFF); + + /* request and config the outband window for msi */ + free_win = find_first_zero_bit(&ep->ob_window_map, + sizeof(ep->ob_window_map)); + if (free_win >= ep->num_ob_windows) + dev_err(pci->dev, "no free outbound window\n"); + + dw_pcie_prog_outbound_atu(pci, free_win, PCIE_ATU_TYPE_MEM, + pcie_ep->msi_phys_addr, + pcie_ep->msi_msg_addr, + PCIE_MSI_OB_SIZE); + + set_bit(free_win, &ep->ob_window_map); + + /* generate the msi interrupt */ + ls_pcie_raise_msi_irq(pcie_ep); + + /* release the outband window of msi */ + dw_pcie_disable_atu(pci, free_win, DW_PCIE_REGION_OUTBOUND); + clear_bit(free_win, &ep->ob_window_map); + + return 0; +} + +static struct dw_pcie_ep_ops pcie_ep_ops = { + .raise_irq = ls_pcie_raise_irq, +}; + +static int __init ls_add_pcie_ep(struct ls_pcie *pcie, + struct platform_device *pdev) +{ + struct dw_pcie *pci = pcie->pci; + struct device *dev = pci->dev; + struct dw_pcie_ep *ep; + struct ls_pcie_ep *pcie_ep; + struct resource *cfg_res; + int ret; + + ep = &pci->ep; + ep->ops = &pcie_ep_ops; + + pcie_ep = devm_kzalloc(dev, sizeof(*pcie_ep), GFP_KERNEL); + if (!pcie_ep) + return -ENOMEM; + + pcie->pcie_ep = pcie_ep; + + cfg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "config"); + if (cfg_res) { + ep->phys_base = cfg_res->start; + ep->addr_size = PCIE_EP_ADDR_SPACE_SIZE; + } else { + dev_err(dev, "missing *config* space\n"); + return -ENODEV; + } + + pcie_ep->msi_phys_addr = ep->phys_base + PCIE_MSI_ADDR_OFFSET; + + pcie_ep->msi_virt_addr = ioremap(pcie_ep->msi_phys_addr, + PCIE_MSI_OB_SIZE); + if (!pcie_ep->msi_virt_addr) { + dev_err(dev, "failed to map MSI outbound region\n"); + return -ENOMEM; + } + + ret = dw_pcie_ep_init(ep); + if (ret) { + dev_err(dev, "failed to initialize endpoint\n"); + return ret; + } + + return 0; + +} + static int __init ls_add_pcie_port(struct ls_pcie *pcie) { struct dw_pcie *pci = pcie->pci; @@ -309,16 +414,21 @@ static int __init ls_pcie_probe(struct platform_device *pdev) if (IS_ERR(pci->dbi_base)) return PTR_ERR(pci->dbi_base); - pcie->lut = pci->dbi_base + pcie->drvdata->lut_offset; + pci->dbi_base2 = pci->dbi_base + PCIE_DBI2_BASE; - if (!ls_pcie_is_bridge(pcie)) - return -ENODEV; + pcie->lut = pci->dbi_base + pcie->drvdata->lut_offset; platform_set_drvdata(pdev, pcie); - ret = ls_add_pcie_port(pcie); - if (ret < 0) - return ret; + if (!ls_pcie_is_bridge(pcie)) { + ret = ls_add_pcie_ep(pcie, pdev); + if (ret < 0) + return ret; + } else { + ret = ls_add_pcie_port(pcie); + if (ret < 0) + return ret; + } return 0; } -- 2.14.1 From 1583337449529443926@xxx Mon Nov 06 17:10:59 +0000 2017 X-GM-THRID: 1583328068057628562 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread