From patchwork Mon Mar 11 09:32:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Z.Q. Hou" X-Patchwork-Id: 10847113 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFE8814DE for ; Mon, 11 Mar 2019 09:34:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7C7C28D47 for ; Mon, 11 Mar 2019 09:34:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A982B28D62; Mon, 11 Mar 2019 09:34:23 +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=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 0A10D28D47 for ; Mon, 11 Mar 2019 09:34:23 +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:In-Reply-To:References: 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=60FS9v4hk/YD/pGera3TVMOQ6+3rth5FCbubALB7dLM=; b=ZZqWIQBQEFAX/4 J75m/7HOuU0k49cm4W9r6pfCUb2P9l+SgxYXM7Iu8teQtnrFx11VD83pmB15tKV2HX5RAfAM+Wp0T 6PMCotRzZTW9TwVwHacjN0gjdJdmxidwLxottPxK+AWEW4AVYRN1FJQYlFGlGVzLGMLkny0w+gQbP VURRuBDm7hbUwg42uv7NaUdjxNgz7ZqiqpWJzyCe4MgiAg37Pa44njYMRisSYiZCXwayvdr5+2Xrs NoTMBkBvY9jPUq5WAL6DYIepmaeZmOci3IebDHQGzzu4XJzxJQe+FaTR52sKrAW7ab+4UDaQauPNT 8jwCsvQrtRmpDWgx/aWA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3HK7-00054c-Fy; Mon, 11 Mar 2019 09:34:19 +0000 Received: from mail-eopbgr70048.outbound.protection.outlook.com ([40.107.7.48] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3HJJ-0003GU-Tf for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2019 09:34:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mwq4DogXXuQC1jDXHppEhLMKOvQm4SLl8Dw1Ilx4cnw=; b=SGsUcs3//zRPwTdHZi7d5pvdSXI4KX8Cz4NabZl1/OMLMYJevZoFlUp4E4wxaAP6semOAbYnrj6J1d1auJKkVsDgOsNMaIBP9XOIKvEnCZ4h/hoYXNUEIgiLUr0MAF2KA/LPt96YAMH8JOLFNgCv6gPYk8roOYH3O8MWD7npo9I= Received: from AM6PR04MB5781.eurprd04.prod.outlook.com (20.179.3.19) by AM6PR04MB4168.eurprd04.prod.outlook.com (52.135.168.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.20; Mon, 11 Mar 2019 09:32:57 +0000 Received: from AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::30cc:e034:1f7a:2cc7]) by AM6PR04MB5781.eurprd04.prod.outlook.com ([fe80::30cc:e034:1f7a:2cc7%2]) with mapi id 15.20.1686.021; Mon, 11 Mar 2019 09:32:57 +0000 From: "Z.q. Hou" To: "linux-pci@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "bhelgaas@google.com" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "l.subrahmanya@mobiveil.co.in" , "shawnguo@kernel.org" , Leo Li , "lorenzo.pieralisi@arm.com" , "catalin.marinas@arm.com" , "will.deacon@arm.com" Subject: [PATCHv4 22/28] PCI: mobiveil: make mobiveil_host_init can be used to re-init host Thread-Topic: [PATCHv4 22/28] PCI: mobiveil: make mobiveil_host_init can be used to re-init host Thread-Index: AQHU1+1pcpzAuc+rfEi+Yu/+RO94xQ== Date: Mon, 11 Mar 2019 09:32:57 +0000 Message-ID: <20190311093130.7209-23-Zhiqiang.Hou@nxp.com> References: <20190311093130.7209-1-Zhiqiang.Hou@nxp.com> In-Reply-To: <20190311093130.7209-1-Zhiqiang.Hou@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR03CA0015.apcprd03.prod.outlook.com (2603:1096:203:2e::27) To AM6PR04MB5781.eurprd04.prod.outlook.com (2603:10a6:20b:ad::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhiqiang.hou@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [119.31.174.73] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d36aeac5-ae63-40f1-fb12-08d6a6048b4c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:AM6PR04MB4168; x-ms-traffictypediagnostic: AM6PR04MB4168: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; AM6PR04MB4168; 23:NO3AY5qwEkKSLM67ciI+Cd7CVesTrb345npIvLe?= =?iso-8859-1?q?5/QfnIK0bQtw0t/?= =?iso-8859-1?q?pdlNgfun7deG0xtBiLYT0ifDz56jvALGpalc1Lq5zqdqbakCHabiL9/8S7Ay?= =?iso-8859-1?q?yrjt2rECFvXA3xY7PeJ15vQPghBZvLuEa0o7alhmuX8er2bEOO5Xvba+3+rz?= =?iso-8859-1?q?8gNEPZsYT0M1KZWgzxJlogn0g9IYI/erRF2cdclGnBT09TjMe2YBcvZZzD5M?= =?iso-8859-1?q?e8KOUl+lvY5K3JTyhHhaQIu35m6CitiM5MwxSqMC/PF7t+F4wNw9Jr8Q/Uxy?= =?iso-8859-1?q?/3ui8eZ4wSp4Xrm0HJnRqwgEftcF0NeaIShJPY3Til6dzSA2co1jk2j2MyaH?= =?iso-8859-1?q?OVm4gt31GmJZ6e2X7CgvJH1eRTYGe439147aps9hnqZP0OXzUcZQAiYBnSVJ?= =?iso-8859-1?q?Jt9BLMApZWHd90Gg7pA6MJi0A7K8VKJo/q+pFU9WW/5Xsh5eg+j9vztRDpBX?= =?iso-8859-1?q?mwVxA9jjZsqEXhUb7vrD4H8SkJAMHafUFO6ZlsN3uOGqAURTj8zzXZzKYIG+?= =?iso-8859-1?q?Yp7yE5Q0D4tZ7DI54HwYBytoTI5uELwtGA91dicCuvl3F9QFsKDqIFrqVkz9?= =?iso-8859-1?q?Xy/3xPaDnZftvKmnSxP+/tV1J8ZBRkvPeuR2/57lxA59nOHnieYChq9M0ZPj?= =?iso-8859-1?q?fq5yFmFAy/vZHa0BALmuTwR2KGDM0Wrf5+wiopvZiek/hObtSyrRw/zzltXr?= =?iso-8859-1?q?ibBbLbnOEOXjWi+U9CZeXlH4lU8e5VbYbveH7Wvfjsj8n68BeCpYfr2I/7+9?= =?iso-8859-1?q?B1utbbhQ7EJxXFGQYxXV7ACBm6PismcRM58jJuWvNimGxDhiJxL6rez67AIl?= =?iso-8859-1?q?6x0/592O+hNatMV9vugonLlCYpqXmRdvr+Tx+l4CniU2TAD3wxUxYKuQhymd?= =?iso-8859-1?q?xf+U2soVqZnNJrXUQyIsPIMrxjc0U0EGwYY3/CnVs+ThK4xGXs9CvGImFD/p?= =?iso-8859-1?q?MJoe8KrSfoFeFZr81CQxa4cs5JhvfTGM0aTXV+qqLxLXdyjJj4Ejq3mJ2PsG?= =?iso-8859-1?q?+N9R2iJushOg5z44IGcKii3fzgK3wQ2S1E2k6heYkY1VW3Slj15BxqQnWLxE?= =?iso-8859-1?q?QvZWJqHtbxggImiiXSfVFtbgsnxwyfRbi5M2jidzrt1bB3NhCNgBX7ho7LsJ?= =?iso-8859-1?q?K8zXYBy6kAYUWGy++an0LODMxW0METYCUIafb0CLkcIUSd5u2kKSQTpSE5UT?= =?iso-8859-1?q?hzXWcggaXpcJwcuPmYkWw83BawqzrPu/0Ama48dJa/ez6/25Y4Or4zEySwIS?= =?iso-8859-1?q?mxYs0Z/DaSrlJx6cVclAbyKfpeqf9AHXjR6o+nQdlRVJm73MuiOHUSxuO7dD?= =?iso-8859-1?q?UwDsZTxbQ=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09730BD177 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(136003)(376002)(366004)(346002)(189003)(199004)(106356001)(476003)(446003)(6512007)(105586002)(7736002)(486006)(11346002)(14444005)(305945005)(256004)(6486002)(2906002)(25786009)(54906003)(6116002)(110136005)(3846002)(71200400001)(2616005)(2201001)(86362001)(4326008)(71190400001)(68736007)(102836004)(5660300002)(81156014)(36756003)(2501003)(7416002)(6506007)(386003)(6436002)(97736004)(53936002)(316002)(186003)(26005)(76176011)(14454004)(8676002)(8936002)(52116002)(478600001)(1076003)(99286004)(50226002)(66066001)(81166006)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR04MB4168; H:AM6PR04MB5781.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: lFvATVmRb6mqGgUfKPRWeu55SauS7avvIueEYqWLLEbTuVAHaxhN/HLHv3jEHBHVFYr0n/5F9T3B+MfamlRIiT/R8ToziW/82HwLUjSRdqC62OpC90JVqoJZJx56ql1QKxvrkpYhajGNy8f8D4Fox/8r0+bDC29Qn5F2k0LAwgDkGDE4btr17+W2YiHgsBDe7Gb/3Kmu+PoPLu5BMPqlcujC86ftFF/qqtKbJzDBP9+MFDwGnNQAaW9pGAkvb2e6K36RHTelrS3xOMc+ZgI74jsLMHrUAIq91zz7OBcWs7BCdKWEjAW6dXblzAbitwqJ7CY7MzQ6p1VZvRd1YpaE4ocJ5/E3ADtwLBmVaoI0ntzhCNlA7w1KQiPj9xSawsO2JP9sxSBADTz6Shdu/QDKe258RPwr7wvt3IAFJX+NpCY= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d36aeac5-ae63-40f1-fb12-08d6a6048b4c X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2019 09:32:57.1045 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR04MB4168 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190311_023330_166059_E619347D X-CRM114-Status: GOOD ( 16.32 ) 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: "M.h. Lian" , "Z.q. Hou" , Xiaowei Bao , Mingkai Hu 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 From: Hou Zhiqiang Make the mobiveil_host_init function can be used to re-init host controller's PAB and GPEX CSR register block, as NXP integrated Mobiveil IP has to reset and then re-init the PAB and GPEX CSR registers upon Hot-reset. Signed-off-by: Hou Zhiqiang Reviewed-by: Subrahmanya Lingappa --- V4: - no change .../controller/mobiveil/pcie-mobiveil-host.c | 41 ++++++++++--------- .../pci/controller/mobiveil/pcie-mobiveil.h | 3 +- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c b/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c index d028cdf31d0e..e8d0c4989013 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c @@ -217,7 +217,7 @@ static void mobiveil_pcie_enable_msi(struct mobiveil_pcie *pcie) writel_relaxed(1, pcie->apb_csr_base + MSI_ENABLE_OFFSET); } -static int mobiveil_host_init(struct mobiveil_pcie *pcie) +int mobiveil_host_init(struct mobiveil_pcie *pcie, bool reinit) { u32 value, pab_ctrl, type; struct resource_entry *win; @@ -229,11 +229,16 @@ static int mobiveil_host_init(struct mobiveil_pcie *pcie) for (i = 0; i < pcie->ppio_wins; i++) mobiveil_pcie_disable_ib_win(pcie, i); - /* setup bus numbers */ - value = csr_readl(pcie, PCI_PRIMARY_BUS); - value &= 0xff000000; - value |= 0x00ff0100; - csr_writel(pcie, value, PCI_PRIMARY_BUS); + pcie->ib_wins_configured = 0; + pcie->ob_wins_configured = 0; + + if (!reinit) { + /* setup bus numbers */ + value = csr_readl(pcie, PCI_PRIMARY_BUS); + value &= 0xff000000; + value |= 0x00ff0100; + csr_writel(pcie, value, PCI_PRIMARY_BUS); + } /* * program Bus Master Enable Bit in Command Register in PAB Config @@ -279,7 +284,7 @@ static int mobiveil_host_init(struct mobiveil_pcie *pcie) program_ib_windows(pcie, WIN_NUM_0, 0, 0, MEM_WINDOW_TYPE, IB_WIN_SIZE); /* Get the I/O and memory ranges from DT */ - resource_list_for_each_entry(win, &pcie->resources) { + resource_list_for_each_entry(win, pcie->resources) { if (resource_type(win->res) == IORESOURCE_MEM) { type = MEM_WINDOW_TYPE; } else if (resource_type(win->res) == IORESOURCE_IO) { @@ -550,8 +555,6 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie) resource_size_t iobase; int ret; - INIT_LIST_HEAD(&pcie->resources); - ret = mobiveil_pcie_parse_dt(pcie); if (ret) { dev_err(dev, "Parsing DT failed, ret: %x\n", ret); @@ -565,34 +568,35 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie) /* parse the host bridge base addresses from the device tree file */ ret = devm_of_pci_get_host_bridge_resources(dev, 0, 0xff, - &pcie->resources, &iobase); + &bridge->windows, &iobase); if (ret) { dev_err(dev, "Getting bridge resources failed\n"); return ret; } + pcie->resources = &bridge->windows; + /* * configure all inbound and outbound windows and prepare the RC for * config access */ - ret = mobiveil_host_init(pcie); + ret = mobiveil_host_init(pcie, false); if (ret) { dev_err(dev, "Failed to initialize host\n"); - goto error; + return ret; } ret = mobiveil_pcie_interrupt_init(pcie); if (ret) { dev_err(dev, "Interrupt init failed\n"); - goto error; + return ret; } - ret = devm_request_pci_bus_resources(dev, &pcie->resources); + ret = devm_request_pci_bus_resources(dev, pcie->resources); if (ret) - goto error; + return ret; /* Initialize bridge */ - list_splice_init(&pcie->resources, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr = pcie->rp.root_bus_nr; @@ -608,7 +612,7 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie) /* setup the kernel resources for the newly added PCIe root bus */ ret = pci_scan_root_bus_bridge(bridge); if (ret) - goto error; + return ret; bus = bridge->bus; @@ -618,7 +622,4 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie) pci_bus_add_devices(bus); return 0; -error: - pci_free_resource_list(&pcie->resources); - return ret; } diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil.h b/drivers/pci/controller/mobiveil/pcie-mobiveil.h index 933c2f34bc52..0f5303962e88 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil.h +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil.h @@ -152,7 +152,7 @@ struct mobiveil_pab_ops { struct mobiveil_pcie { struct platform_device *pdev; - struct list_head resources; + struct list_head *resources; void __iomem *csr_axi_slave_base; /* PAB registers base */ phys_addr_t pcie_reg_base; /* Physical PCIe Controller Base */ void __iomem *apb_csr_base; /* MSI register base */ @@ -165,6 +165,7 @@ struct mobiveil_pcie { }; int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie); +int mobiveil_host_init(struct mobiveil_pcie *pcie, bool reinit); bool mobiveil_pcie_link_up(struct mobiveil_pcie *pcie); int mobiveil_bringup_link(struct mobiveil_pcie *pcie); void program_ob_windows(struct mobiveil_pcie *pcie, int win_num, u64 cpu_addr,