Received: by 10.223.164.202 with SMTP id h10csp1001577wrb; Thu, 9 Nov 2017 19:09:06 -0800 (PST) X-Google-Smtp-Source: ABhQp+S76mzHWntIokn9bHjui8tyEcAPFHx4g9DNY/OGrErQzMAmMQ6k29RpvxsMauAI+rdtOVeW X-Received: by 10.99.95.133 with SMTP id t127mr1671679pgb.368.1510283346669; Thu, 09 Nov 2017 19:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510283346; cv=none; d=google.com; s=arc-20160816; b=saXk/ipujAHoi7HJKAdBpXHrhb+Lk4++fb0YMRaZYOEVsBCogLQfKMeLARVhyTyXJA lNuzP5DgukXjcP58i/MrWw2ojrtOOZkB8ibKqjilVE9fyqpkCm2bajxL/P8y05G6pFTQ pqI81kN5a0IbzS6HmJESGGlCLdQ1Pfks3L/GqhHyjNGnlfbnd9wkdFb3r0Wo7xtfaD1q npZvl4FG2sqtTE4YAZKqP3VotzcyHGMJVSfQWuTuAFRvWpTgyQBfR7iiy2RZyC4mYbnE ncpmX2jNN9XeoMkEwhKIDvw8QfJUXHSFmjeiLLHAeKhd9o90pH/3D93jS1kWOnDWqA37 mG8Q== 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=HB4zlvPCdcUR1PElR4frH/gB9DWFHokrEOk7hz7HMVI=; b=zexDcj/HwFbfqByOUgX9M7X7cM6k4Brvm5oWI90tHuu+xsM/rQlTwV8vG2jACLoaSO e0iMAEhhFKgYg7FZqqg6otsVX5aeej5eFjmGip+K/KFTFxpVpPnnJR5VqdGQMgwb785/ WYVAg2oAH4fcTsVHF45iEXgMzeNSgVA6idrImxttpKlypOzVi0VAs3lb7QC3UZd7kfrG m2zvRPEFGs1PgrWNtQodI+FKSs8Nyjy38wn0PxzHeJpUPzTx0UZrsCYpx+Vem+pbHEnZ VBf1UWdYmKSaEvflavv8LWZEKzjOuJpXWJNmVKgQN/3QS4hf/RrrDatewDWKzvdWsCz4 MFdA== 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 g127si7491083pgc.553.2017.11.09.19.08.55; Thu, 09 Nov 2017 19:09:06 -0800 (PST) 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 S1755871AbdKJDIP (ORCPT + 83 others); Thu, 9 Nov 2017 22:08:15 -0500 Received: from mail-bl2nam02on0075.outbound.protection.outlook.com ([104.47.38.75]:46341 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755694AbdKJDIJ (ORCPT ); Thu, 9 Nov 2017 22:08:09 -0500 Received: from BN6PR03CA0023.namprd03.prod.outlook.com (2603:10b6:404:23::33) by SN2PR03MB2365.namprd03.prod.outlook.com (2603:10b6:804:e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.218.12; Fri, 10 Nov 2017 03:08:07 +0000 Received: from BL2FFO11OLC010.protection.gbl (2a01:111:f400:7c09::112) by BN6PR03CA0023.outlook.office365.com (2603:10b6:404:23::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.218.12 via Frontend Transport; Fri, 10 Nov 2017 03:08:07 +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 BL2FFO11OLC010.mail.protection.outlook.com (10.173.160.154) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.178.5 via Frontend Transport; Fri, 10 Nov 2017 03:08:07 +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 vAA37fFf032559; Thu, 9 Nov 2017 20:07:59 -0700 From: Bao Xiaowei To: , , , , , , , , , , , , , , , , , , , , , , , CC: Bao Xiaowei Subject: [PATCHv3 2/3] ARMv8: layerscape: add the pcie ep function support Date: Fri, 10 Nov 2017 10:49:25 +0800 Message-ID: <20171110024926.39700-3-xiaowei.bao@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171110024926.39700-1-xiaowei.bao@nxp.com> References: <20171110024926.39700-1-xiaowei.bao@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131547568875451526;(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)(336005)(7966004)(376002)(39380400002)(39860400002)(346002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(5003940100001)(8936002)(105606002)(53936002)(1076002)(39060400002)(7416002)(81166006)(189998001)(106466001)(4326008)(305945005)(33646002)(68736007)(76176999)(6636002)(81156014)(6666003)(50986999)(86362001)(77096006)(356003)(48376002)(8676002)(97736004)(104016004)(36756003)(47776003)(8656006)(110136005)(498600001)(50466002)(2906002)(2950100002)(16586007)(85426001)(316002)(2201001)(50226002)(5660300001)(921003)(83996005)(1121003)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR03MB2365;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11OLC010;1:+9KJV40GtMwP4AkWqIaALQoZRHEmwCyACnqLKHr8lu4/9/GrJ/v2M7hN2oeqzdEwl702N7VzNQstyV+BkUI2kTKPVzUduXELrvsR4lJqQ/1f06DotiP8EadKCjZBle6r MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6d8ec82e-e4cf-42c7-3486-08d527e8445a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4628075)(201703131517081)(2017052603256);SRVR:SN2PR03MB2365; X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2365;3:/2W+4uYZjBS9iWIrkbRvBXm0Hb0O3+05Osz8vsboecjQUaf0qQokVCbcmYjaU7whXjoSxmMW9iDX7JQNYxiQ5Cdvc788KfFQYlud6gv8kgqSZzRn7b+tAFs5mFrSUikZ8q0ddIISQKYAQD7DLE4PiGCGT4bmvnObsBZZxl+YticlkNbAQcJ2B9shdbgkCgbvCHFdmEddtw+IWxULMYSdgvSqGzb8lt7/o67Po/0RWAYTLDbIzRQPM4gh+K1wpN2mVDcfvspavKWkZ8Wa8KgHAkLMQx+4RXAAm2iCqFkzJmSoG3/BY+te/5CfH5LfR3Zn5laOMCbeSNAZn+sjzkiPS7H96bTiDTGpMivzrbLTEN8=;25:y3AY5T6R6GkLORw+E00u8qhsMMkrJGrSGnY3j1c7ZxPiRm5Ir60RvlcsGEoBolDK1ycb1XLvRz/dehH7m2wUwasPXyNLeUqP2pnHOXUJ52QOJf7YgHUdZztP5nCr+8A2wM/GWFPwICbScKkGByFizh0sLXt2J2sDJwYCDMXjBe2je0kfcw6Krh3DEx6ibGg661jAGmZyiIk3zNpG8BwSQMnmTsgO7Wfra4NrN+z36uRgPcDbBZ/AN//tFSwHdvsG5EnjP5Y4Eaq5q69V+UUD9lSG2J8gVZBFtgP1u4z2/xIy+SyaxntGHckAh1lsodkxY7OMQXFDPVupnJpEOuu0/w== X-MS-TrafficTypeDiagnostic: SN2PR03MB2365: X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2365;31:Krg06YN6jDQXoN6IVTGGw6jm3A/KvaILrIck7RsyqeWGjI7inxRTj4dMfuxaKiYdiu3bmmVoXXkn503lFbSwNzQDSfxGvVKwSVYKwMytdnnpAiOdJTfrkaeHb4pMmr7oUbonPOz9h4RJfQt60CxhV0117a52Hsg+ZUfdCfufSIs+FIrQzVSPau5f4Uqn6juMHTnUeQzXS+7EzjteBoK3WEB9ZRM6rwwTh93VA1CYyJE=;4:4x0BK3VXR8uXNAPmA191bG+6aefkxVk3m31dJexP40z74+AC8ug7pp8GrpvC5JHwNu3Ojym5tuuonu7FxnlfjLIEEnnU7zhZEkZOJ4wWQjA8C9V2NOO4d4mQcDQDL27xLZAh6fbqDEg2bnGu7DJ42yDJG58oKtML9sbTHXVS93FKnKX6DNnCep9BL68oNRlG+IPk7LkDqkyWy9GDh/2a5PK5Z8xyms4LEDWNaw3zGPmhW+h7lXRKxtsb0bPFezK6xPPOvzdyu8J/9+MFFlGxH+DtNqAsBz3z3Bi3wT6SCR330uuLO9KxlgU2//FUHxcZ 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)(3231021)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123556025)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123561025)(20161123559100)(20161123563025)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:SN2PR03MB2365;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:SN2PR03MB2365; X-Forefront-PRVS: 0487C0DB7E X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN2PR03MB2365;23:4+ACl2hdq1e+nhTLUl2v4Aszyxd+6qkFYoISuuBww?= =?us-ascii?Q?UPXKwML15Dhp6iO4snMhQ9TeLTL69OLX6bn0jOM16cRx953EEU0LY3CcHO5s?= =?us-ascii?Q?Jt/yVzeIMyPLPJF2PkJ/AGR3RfitFLoA/8k6XEPch4lff5hJRwrtQPl1uQLP?= =?us-ascii?Q?erbR2ExTFV2hTOdar25cVgovnR2WR37X1Uva0EJm4ZbuKwKTuCFlFFhucDQu?= =?us-ascii?Q?1wH8S46CCUfUsvk0CsmdFD8zLxo6Yp07YHOF++NGNdeS3XzDyo1baa6Idlox?= =?us-ascii?Q?SYOr/ABYuQeSsodSp5LvyWZ3gK6+yH+m6DC2uXTDr6arPegjbRNBI/6AzMFJ?= =?us-ascii?Q?p/6UtdKCJhqGi9Uu9d1+ieK1TV1RBatWlsWuJ6oZl77bNpPqI/ShBYyCYz60?= =?us-ascii?Q?zuXojRGzCZx7xwr3nAN7raYAc8ZKsATa//D6bE3RGV5CyMjwZ+i7S9ACs14p?= =?us-ascii?Q?ZAs8G51HBMj1Eg8DpKy/MpR5nBdMJddooSVbBnApv2zXmXmj4pA79Mh5v3HL?= =?us-ascii?Q?FjeDzKincm4m15k73g9i6VRDhiOfIOsDrTpmWucXbbwYZJspU5omTigIndLt?= =?us-ascii?Q?ohY3uHu8ISSWPVFOUdH+Pbs24kkw+ck0ZZCYz2xUWvK1/1DJeruelb+O0hdF?= =?us-ascii?Q?kC12EBfjy4i89Q0vrAwG3A4RNvuPDb1Uyca+j7glhN2xuLVfRw0RkcgQYROL?= =?us-ascii?Q?6u4/jk9oKZcCsve0jaXYcHHLLPvSWEOuDgBrxC07qBZfzJ/se/oVO218Y6vl?= =?us-ascii?Q?Jy/NWb1JdDr/ET6aIchZy3eZxW5P6QgYN07JAzPCrHbB2kZS0D3a1rDZBzd9?= =?us-ascii?Q?cjupgw5dxCjAd0FgOO8UXube4Lh+QjT0Fn/vEYLDD9pLkl+clChYtMwXVsdH?= =?us-ascii?Q?HVtTE36fcR2PFQh7m4nDa6dhdWUqfjHmzqhaVsjq3TpaEYuIkoY4FogvfhHT?= =?us-ascii?Q?HXRzBC5wNj2UiQIqjDsF+UtI3XJAJDy+50nhrNG/u+IRHFO3DM3xopUXlu7F?= =?us-ascii?Q?KodumrGGEcjkgvPm9/C+2q/U4F6sRBHhBURwINm0kpTAZd6LWT0KVEj1yXuy?= =?us-ascii?Q?b5+Ghamin7HYzFYilSdp/0R8WLGihbQYbMl908kiNP2cy5ROzX2y4t7E/4/9?= =?us-ascii?Q?9BqcQ2thhUnSp2GLagSPdERtoCRGCjfLksafbep+mdajD56frSrzTpFdP2Cb?= =?us-ascii?Q?rAL6zWx569ILjP8wg82fnkUvBuBvVR/hh6eCVhJJByXnvNJ6VgRdN8ZXZycS?= =?us-ascii?Q?y/HZm42K6P9MFSZpca1QwcGy5hacpd0ECZmYIvz+ck3FC6eOaM8PjaPpTODm?= =?us-ascii?Q?kjXnj6XwAvDnOFkLO4qGGc=3D?= X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2365;6:3DN2HWDKLh4UGl5BCHNsOMG4VoUotooVzL+H0E55I56l/BfnFdQXwbPYI5HXAOa9RxnmuYjaxjT4sQ9nuF1FbHfcNq2pUx+wDMCl+aOVOvPpD/5bU0m7yInQ6mqNsL4IWZzhsQqzLQPloXv0A26HjSzXSsehjv6FkGCI/a2HqoC5JHgI6VVx0U81Qb4gnDChDgHeKcW/9CB+6PlBIiO3vPjKRuyN+bhTtWG/KLSBcvBMhWH3aeUYRfBHiWtAdQw1zEBOFc7woOG0p5MoI1fQiD/SVr0ufYdFxmsHBB0Wm/q+KMriL81nOzcu3I1YM0NWaFAAyW3XlF27Xj3cV5VNJ77rz/GX2k5/4dqxCczSrDE=;5:G2OdrmTc/AwWSFgP4caY9QZT1/C0NINDhw6/U+s+fhsc5YDOsBzK3AZOu+BTXz1c22XuYAcqVOKkWJckBkM8HFkK1Fzr9HX1QyK9vb1PTUdmK0zSBXAuVp4UubPiU/gElJo4wZPzrnKibiyJyVv9JcdCJhgjDza4FcUy9+UtlAU=;24:XgreW9XXWuA9KNDC4VeyecbjJvdbwt5D+4zdwKV3mXiNwj5NzteyEA8IfIM0+X0zPCy7u0xkWARxwbennXWgyReuBYgk2frpBXj92Am6x7E=;7:OEqqf79uC386yaS8Ve0r5YShu+cJnySwL3pV1Tt25ZhDhSa0qlh4u6b6u1rsWqUnpoh6QWYjqXqoGkxQkMfzvWal6v9eurUmIMCU3E1WDhqw/PQRxlpl0QeZrHc2dZs1Yke1SLbDTHnVpvnalh0eKq28k/uU2bL6OzAZFbMhEhTwjI/skhqI3ER0yYLXmZPkQozWRGGMlf5o/Y0C8QYVIdDUE0LgBG1UHehRXZ/47IWkU0koRDmln5ri47Y/ppbg SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2017 03:08:07.2955 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d8ec82e-e4cf-42c7-3486-08d527e8445a 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: SN2PR03MB2365 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 v3: - fix the msi outband window request failed issue drivers/pci/dwc/pci-layerscape.c | 124 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 118 insertions(+), 6 deletions(-) diff --git a/drivers/pci/dwc/pci-layerscape.c b/drivers/pci/dwc/pci-layerscape.c index 87fa486bee2c..d787375528eb 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,100 @@ 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"); + return -ENOMEM; + } + + 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 +416,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 1583483902263439672@xxx Wed Nov 08 07:58:48 +0000 2017 X-GM-THRID: 1583483902263439672 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread