From patchwork Mon Mar 11 09:32:40 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: 10847161 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 D59B214DE for ; Mon, 11 Mar 2019 09:48:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB89F28FE3 for ; Mon, 11 Mar 2019 09:48:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF09228FE5; Mon, 11 Mar 2019 09:48:57 +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 4882C28FE3 for ; Mon, 11 Mar 2019 09:48:57 +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=SXfx78U98okpEdq42IwnLnocUEIeM4LsbBFFRM1orek=; b=cSxTLk6PCuaC6o N9RQjaZIZyig6NkDrLv9S2aVxq4Mv4mXHhRXJcVjhsR72QhTxiTJMYJaWPmTNGk4yK+eTKB6aYQJk aipKdCaMcYSibwumY/N/2XvRjhxFN5a2tbEKChba3svt4FH6fCYb6F17DBZNvdvTyyOM14Ynoa/2d zxoQUYLk9CpNzlpP5ngIezNYR30at9dOi7K3iOU4uWOxavJE0ini4+rK//DqtJL/qVoGugAEAG5/x jbjm1q34rF0r5gXndpjTKUNR3i+XSY2i6e4/dTnMEwNF/k2fX6TmnqW/6RxS3QQVrarBsiN/be594 dSdWB6sXNjWJ2tgpmMSw==; 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 1h3HYF-0005A3-Rx; Mon, 11 Mar 2019 09:48:55 +0000 Received: from mail-eopbgr70049.outbound.protection.outlook.com ([40.107.7.49] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3HJB-0000Rr-2Y for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2019 09:33:51 +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=djRJedX0YnGMR+kxBuz6xh14Gf7Z72o/ke4jkc9v3Cw=; b=DyzpigMqijpiqAvoKkgqsQF/oxGGmfUYiGs5Jf7Yn/YuYYHGvutYjB9twFJgPcevURnzvLAE0x1rcGkh1Iw5CGp90547uJfjWDG0tjVSd/SErmrN8EL+NJgUxPkTAGUr3daxnSwZc/5J/Y/2q0KFIJx6Jg/v+4eeVz6egjT/9To= Received: from AM6PR04MB5781.eurprd04.prod.outlook.com (20.179.3.19) by AM6PR04MB6566.eurprd04.prod.outlook.com (20.179.246.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.16; Mon, 11 Mar 2019 09:32:41 +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:40 +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 20/28] PCI: mobiveil: disabled IB and OB windows set by bootloader Thread-Topic: [PATCHv4 20/28] PCI: mobiveil: disabled IB and OB windows set by bootloader Thread-Index: AQHU1+1fWHXqD4bHmUakTFM3fhqbXg== Date: Mon, 11 Mar 2019 09:32:40 +0000 Message-ID: <20190311093130.7209-21-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: a5fbdb15-257a-48b1-6f2e-08d6a60480eb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM6PR04MB6566; x-ms-traffictypediagnostic: AM6PR04MB6566: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; AM6PR04MB6566; 23:kZOQMGleawVldBPA40VGBqc7m6H1+Z7xrUbr5m9?= =?iso-8859-1?q?QbdoQVVAQXwdzKR?= =?iso-8859-1?q?3ECibK170FG37QEV3Gey4Qgvb0XIuZhr3T3b5ZFl+noD/UvTs9yItBV1LxPs?= =?iso-8859-1?q?9zlgE8eUGo8YIZzkVlA0yJIwfNQnMkKmaP24ci3R72pLlg0LXQlWv4//1q/a?= =?iso-8859-1?q?CELfbU9aeLf11dKdQIdEofhtevVYBqsG175a5n90Sks+QAiQrBM2CD89sL3/?= =?iso-8859-1?q?514RcxRVNia5Z0VCe8DLYylBbi/2BMCPht79ulcY33AkC4TeYMIEme6xFUME?= =?iso-8859-1?q?4V2lkL7MNCz43ttYEpY09emtPYB2HPkNr8MU94+FxDCaXA1uWYyDlnh3oRay?= =?iso-8859-1?q?pKXKa3UhTlyCSBo/nGpbynVzGeHdixpYf+KHba8chp/1LJVdt1uiWeLPYdA2?= =?iso-8859-1?q?XPvSFkm7VX93UzYQlTNJTI81p6//xXVJF9iIn1Tc1yqLN36eVzQSp9bf5t4r?= =?iso-8859-1?q?Cz7seH+ufCNya9zXyhk015u2wGkdsJMaHQO7fCLYWpLebv3vlpamcxYLyhea?= =?iso-8859-1?q?odQHZdoOV8jxWZ3SfDmnVlTadbzT+DsZo5Q4cdoAIFul/mbcb7dm72AxCsgx?= =?iso-8859-1?q?h3O9AlptgG6Fd+EK3dTinUs0AIA4ATwqANYd821vYDF3IOZyClZfLqp1fEQ1?= =?iso-8859-1?q?1hYS80r2qwHPeBw+Wgt+sJmluN0iuarjHVUjj6E9ardYN9/BDx8yhrnRyTB6?= =?iso-8859-1?q?fcHPQapznyKc3SIDew5GXn3MFmLMOzzr4HVJThm0OSuDTb57B7yF3CAIYsR9?= =?iso-8859-1?q?Qacr3gmEwD2ThQ5ZMnwuqL3GztDi8x31qzuQO1Ux45s1pKQnC+VUnvDndUqy?= =?iso-8859-1?q?WrJdDuJdm0zoBccGFBuNfinQ7ipv8crSPSYP9X5/HBElpHgqb1h7vy1iLO3L?= =?iso-8859-1?q?hW4ERXTPemqY4zH9OdHR2sHjSjSJG5S1TMHfobwZ59OqY+j9m9IriWq8aovA?= =?iso-8859-1?q?KFf8Yhj1y142WO4hBWnenOdwnPC9xYQl6t0k1TGkwoY32N232riHKL05qCnr?= =?iso-8859-1?q?PxHvyPoxMoUXt5fs0Y47kCbGG/oHembJWgmV4ZyEPvjJ15w+cwV4FUAk+Tgd?= =?iso-8859-1?q?L642Y6LpZBLtTffULkn4IXaWAswzjDTYeONj8ofW57/iEucXoy0JQc3o6mH8?= =?iso-8859-1?q?bNuv2Lgk2ZsE3I6N79g/zpmWjtUzRadWAD1nERz6sSdmG3QNWHpZW/3iq1ie?= =?iso-8859-1?q?Epv0BHkxKrWXVOFAj1KuBoGmUY0ble6mpptgxn1jXJNUDk0qIfPEapK9o4oN?= =?iso-8859-1?q?pHod9mGMMvVjCLvPk9roAxu1I7wPdWrhcNarJ8goOMCPR2LHDyYwpG4HpMi8?= =?iso-8859-1?q?VinlR1oN4=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09730BD177 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(346002)(39860400002)(366004)(396003)(189003)(199004)(6512007)(8936002)(26005)(68736007)(53936002)(1076003)(316002)(14444005)(256004)(14454004)(186003)(305945005)(105586002)(4326008)(106356001)(7736002)(52116002)(386003)(66066001)(54906003)(50226002)(6506007)(36756003)(110136005)(102836004)(6116002)(76176011)(3846002)(486006)(81166006)(81156014)(478600001)(6436002)(25786009)(476003)(2616005)(11346002)(99286004)(97736004)(446003)(6486002)(2501003)(86362001)(7416002)(2906002)(71190400001)(71200400001)(2201001)(5660300002)(8676002)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM6PR04MB6566; 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: VQR7s65k6XKP9vgc8+qRuJy08gPUUKos9KcnjajPfC5WUChq9nIrRE7J8v/g+mVgPXseQ47+gPJaq/GhluPIUuuqksQUwwxf8NuILDm6xgPJBRXzGhAjKR6/ezcGUUc21aH3t9XvnOJUq0zZc46kTiI6ceWveq1GHMsHt5dYX7HzXRlmEKC2ua6F81tV5/bEm0rIrfpiDAkosQOshJSrljvO9iIjznuVD7H5wLEOTWEOgD2E5OGMbx9x9LEfN+JbkdsHW3k8QHbt+llyw8r55kSTBUfZpv9MmlCjSzS6AKZ4T4yXtXLkDn4AhUB0MuCpDWVT1LUXRDMQc/boEvA/EzV4yJ545UlvSZWJgm+xJx+xmHgTuAQD4YX9WNg1ARNIdANXRpkDBqI0d3D0XnHVvQ0m2tyndrau4xoWbGk1oNQ= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5fbdb15-257a-48b1-6f2e-08d6a60480eb X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2019 09:32:40.5316 (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: AM6PR04MB6566 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190311_023321_458107_2E9024E1 X-CRM114-Status: UNSURE ( 9.81 ) X-CRM114-Notice: Please train this message. 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 Disabled all inbound and outbound windows before set up the windows in kernel, in case transactions match the window set by bootloader. Signed-off-by: Hou Zhiqiang Reviewed-by: Minghuan Lian Reviewed-by: Subrahmanya Lingappa --- V4: - no change .../controller/mobiveil/pcie-mobiveil-host.c | 7 +++++++ .../pci/controller/mobiveil/pcie-mobiveil.c | 18 ++++++++++++++++++ .../pci/controller/mobiveil/pcie-mobiveil.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c b/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c index d1765d572f44..d028cdf31d0e 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil-host.c @@ -221,6 +221,13 @@ static int mobiveil_host_init(struct mobiveil_pcie *pcie) { u32 value, pab_ctrl, type; struct resource_entry *win; + int i; + + /* Disable all inbound/outbound windows */ + for (i = 0; i < pcie->apio_wins; i++) + mobiveil_pcie_disable_ob_win(pcie, i); + 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); diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil.c b/drivers/pci/controller/mobiveil/pcie-mobiveil.c index 370658d6546d..49d471b75925 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil.c +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil.c @@ -226,3 +226,21 @@ int mobiveil_bringup_link(struct mobiveil_pcie *pcie) return -ETIMEDOUT; } + +void mobiveil_pcie_disable_ib_win(struct mobiveil_pcie *pci, int win_num) +{ + u32 val; + + val = csr_readl(pci, PAB_PEX_AMAP_CTRL(win_num)); + val &= ~(1 << AMAP_CTRL_EN_SHIFT); + csr_writel(pci, val, PAB_PEX_AMAP_CTRL(win_num)); +} + +void mobiveil_pcie_disable_ob_win(struct mobiveil_pcie *pci, int win_num) +{ + u32 val; + + val = csr_readl(pci, PAB_AXI_AMAP_CTRL(win_num)); + val &= ~(1 << WIN_ENABLE_SHIFT); + csr_writel(pci, val, PAB_AXI_AMAP_CTRL(win_num)); +} diff --git a/drivers/pci/controller/mobiveil/pcie-mobiveil.h b/drivers/pci/controller/mobiveil/pcie-mobiveil.h index eb4cb61291a8..81685840b378 100644 --- a/drivers/pci/controller/mobiveil/pcie-mobiveil.h +++ b/drivers/pci/controller/mobiveil/pcie-mobiveil.h @@ -171,6 +171,8 @@ void program_ob_windows(struct mobiveil_pcie *pcie, int win_num, u64 cpu_addr, u64 pci_addr, u32 type, u64 size); void program_ib_windows(struct mobiveil_pcie *pcie, int win_num, u64 cpu_addr, u64 pci_addr, u32 type, u64 size); +void mobiveil_pcie_disable_ob_win(struct mobiveil_pcie *pci, int win_num); +void mobiveil_pcie_disable_ib_win(struct mobiveil_pcie *pci, int win_num); u32 csr_read(struct mobiveil_pcie *pcie, u32 off, size_t size); void csr_write(struct mobiveil_pcie *pcie, u32 val, u32 off, size_t size);