From patchwork Fri Nov 10 02:49:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaowei Bao X-Patchwork-Id: 10052323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 215CA60631 for ; Fri, 10 Nov 2017 03:09:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DB842876A for ; Fri, 10 Nov 2017 03:09:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F36032B0D7; Fri, 10 Nov 2017 03:09:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5A52F2876A for ; Fri, 10 Nov 2017 03:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gisXrBtZYWpYHCNjTnor38t9WhQVDxuLY8SRXTYNolM=; b=o2pGV+7cG0MnEf Kdx1Jugaf30bAhh/M/E0mNK3DivAJH3hd1xdmNMbM6Y8vXHA1+v9pfG7+Za2HOR9FEpMRraKyjIls BxUW/8kJfSWuXBQrRKUk5nGb65/yIzMhcNDsKQ8fVc7TYwgrL8sJpQ/Gp0tX8rY4YZsf0MFM/3cS1 AwRHFnjLMfjb+LIcw+0tFVUomtswHh9c3bgj36RBXhvKNnS4sl5OXrPwxYY/kht4yCHnHNv87SHIq I+DFpD+aiCHYgTKj3K8iIX+tGbPqjklUT3JUmDqnL6h+1D6zua+rS4/br22tzZQFVkbE4i5Zca+jx Az2MNHIfkF+eIvJjmM1Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eCzh9-0004JF-2x; Fri, 10 Nov 2017 03:09:27 +0000 Received: from mail-bl2nam02on0081.outbound.protection.outlook.com ([104.47.38.81] helo=NAM02-BL2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eCzgE-0003Ne-7O for linux-arm-kernel@lists.infradead.org; Fri, 10 Nov 2017 03:08:36 +0000 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: , , , , , , , , , , , , , , , , , , , , , , , 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171109_190830_888785_B7F89C58 X-CRM114-Status: GOOD ( 20.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bao Xiaowei Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }