From patchwork Mon Apr 19 06:35:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 12210877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B87A8C433B4 for ; Mon, 19 Apr 2021 06:37:33 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E03A60FDB for ; Mon, 19 Apr 2021 06:37:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E03A60FDB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=toshiba.co.jp Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=jfe7J29g5ItoCDN5U9ii+TqBJ05Ma6dB80jo67a9j3k=; b=W5DOcjLfSrz/Wr8qo6LmjFTFC 9S4+FHcuGckX46831dtGjO/aL2Jsy3NFXO2HXiiRF+uGeU1tY9VBav/tfTvLHdUAS7lOcU1hd3PF9 X2lESqVkZMFQR7A0nhIYGHpkIDtHsbfdbWDng9MLLUFuZtbw858yU9e/clIYo8d8045/WFZS6X/KC KcjYYUsvDOXl7s3js8G9B2x4UMtyJk6mtQTSBuQ6eeUgEH4KRuvDgSrL/zwfFcCeOuiN2HtEV9hfa wB+eWgH0zIIehHgFMPQy+hNWGsNqz3Kyhf501giwNWBhCGpFc939OKMeQI7m7zardV+X71gBPgz3V h8gcmquDQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYNVd-009E0j-NQ; Mon, 19 Apr 2021 06:35:49 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYNVU-009Dzj-Mo for linux-arm-kernel@desiato.infradead.org; Mon, 19 Apr 2021 06:35:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=rcpx+0qUZ8XcxJNqdfY3RJuoYBA/PXvuEpWaJgX0+Ws=; b=y8JsnJ8eWM22bucVLEY7ImSyjL kTvoh/rYru63LxRpLmFJ9kYHYnB4fs/9fmBx23EyKZsEH0Z8L/m9xOLkDoacOa7LYO7cQE51b4qM5 zoB0yhQ3/klenyverOWZkK28/DAZlpnQ0FGfQvj3g77L6iiEjMStG9IUhDS3uG6JLYDztoJDkC5Yk aCkunel46n1L4gZBeuQ7+dltfiIwqROFJFJ/j5lJ9XsnqaMsGxUQNrxPK6y/EoNn2yhF5IEbDUMSQ +HVvVX0qmQ1mZOtCZgbL65wi2sEN5NubjVt69sbXWAqUB3fHU3G5OPzc7lBRagqBJOXBI+0DHBiwA dWn9wIDA==; Received: from mo-csw1115.securemx.jp ([210.130.202.157] helo=mo-csw.securemx.jp) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYNVN-00B4Lz-Sd for linux-arm-kernel@lists.infradead.org; Mon, 19 Apr 2021 06:35:39 +0000 Received: by mo-csw.securemx.jp (mx-mo-csw1115) id 13J6ZHgj006290; Mon, 19 Apr 2021 15:35:17 +0900 X-Iguazu-Qid: 2wHH6QSERX9idHMS2P X-Iguazu-QSIG: v=2; s=0; t=1618814116; q=2wHH6QSERX9idHMS2P; m=Y+hWR6geCWf+yqbAwGkjRsVnStrIgBNBD/hv0Ib1Wfk= Received: from imx12-a.toshiba.co.jp (imx12-a.toshiba.co.jp [61.202.160.135]) by relay.securemx.jp (mx-mr1112) id 13J6ZFeh004322 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 19 Apr 2021 15:35:16 +0900 Received: from enc02.toshiba.co.jp (enc02.toshiba.co.jp [61.202.160.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by imx12-a.toshiba.co.jp (Postfix) with ESMTPS id BA83C100078; Mon, 19 Apr 2021 15:35:15 +0900 (JST) Received: from hop101.toshiba.co.jp ([133.199.85.107]) by enc02.toshiba.co.jp with ESMTP id 13J6ZFRl025297; Mon, 19 Apr 2021 15:35:15 +0900 From: Nobuhiro Iwamatsu To: Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, punit1.agrawal@toshiba.co.jp, yuji2.ishikawa@toshiba.co.jp, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nobuhiro Iwamatsu Subject: [PATCH v2 1/3] dt-bindings: pci: Add DT binding for Toshiba Visconti PCIe controller Date: Mon, 19 Apr 2021 15:35:11 +0900 X-TSB-HOP: ON Message-Id: <20210419063513.1947003-2-nobuhiro1.iwamatsu@toshiba.co.jp> X-Mailer: git-send-email 2.30.0.rc2 In-Reply-To: <20210419063513.1947003-1-nobuhiro1.iwamatsu@toshiba.co.jp> References: <20210419063513.1947003-1-nobuhiro1.iwamatsu@toshiba.co.jp> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210418_233534_226056_1DE7D4DC X-CRM114-Status: GOOD ( 15.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This commit adds the Device Tree binding documentation that allows to describe the PCIe controller found in Toshiba Visconti SoCs. Signed-off-by: Nobuhiro Iwamatsu --- .../bindings/pci/toshiba,visconti-pcie.yaml | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/toshiba,visconti-pcie.yaml diff --git a/Documentation/devicetree/bindings/pci/toshiba,visconti-pcie.yaml b/Documentation/devicetree/bindings/pci/toshiba,visconti-pcie.yaml new file mode 100644 index 000000000000..d47a4a3c49e3 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/toshiba,visconti-pcie.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/toshiba,visconti-pcie.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Toshiba Visconti5 SoC PCIe Host Controller Device Tree Bindings + +maintainers: + - Nobuhiro Iwamatsu + +description: |+ + Toshiba Visconti5 SoC PCIe host controller is based on the Synopsys DesignWare PCIe IP. + +allOf: + - $ref: /schemas/pci/pci-bus.yaml# + +properties: + compatible: + const: toshiba,visconti-pcie + + reg: + items: + - description: Data Bus Interface (DBI) registers. + - description: PCIe configuration space region. + - description: Visconti specific additional registers. + - description: Visconti specific SMU registers + - description: Visconti specific memory protection unit registers (MPU) + + reg-names: + items: + - const: dbi + - const: config + - const: ulreg + - const: smu + - const: mpu + + interrupts: + maxItems: 1 + + clocks: + items: + - description: PCIe reference clock + - description: PCIe system clock + - description: Auxiliary clock + + clock-names: + items: + - const: pcie_refclk + - const: sysclk + - const: auxclk + + num-lanes: + const: 2 + +required: + - reg + - reg-names + - interrupts + - "#interrupt-cells" + - interrupt-map + - interrupt-map-mask + - num-lanes + - clocks + - clock-names + - max-link-speed + +unevaluatedProperties: false + +examples: + - | + #include + #include + + soc { + #address-cells = <2>; + #size-cells = <2>; + + pcie: pcie@28400000 { + compatible = "toshiba,visconti-pcie"; + reg = <0x0 0x28400000 0x0 0x00400000>, + <0x0 0x70000000 0x0 0x10000000>, + <0x0 0x28050000 0x0 0x00010000>, + <0x0 0x24200000 0x0 0x00002000>, + <0x0 0x24162000 0x0 0x00001000>; + reg-names = "dbi", "config", "ulreg", "smu", "mpu"; + device_type = "pci"; + bus-range = <0x00 0xff>; + num-lanes = <2>; + num-viewport = <8>; + + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges = <0x81000000 0 0x40000000 0 0x40000000 0 0x00010000>, + <0x82000000 0 0x50000000 0 0x50000000 0 0x20000000>; + interrupts = ; + interrupt-names = "intr"; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = + <0 0 0 1 &gic GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH + 0 0 0 2 &gic GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH + 0 0 0 3 &gic GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH + 0 0 0 4 &gic GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&extclk100mhz>, <&clk600mhz>, <&clk25mhz>; + clock-names = "pcie_refclk", "sysclk", "auxclk"; + max-link-speed = <2>; + }; + }; +... From patchwork Mon Apr 19 06:35:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 12210881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63006C433ED for ; Mon, 19 Apr 2021 06:37:43 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF18961104 for ; Mon, 19 Apr 2021 06:37:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF18961104 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=toshiba.co.jp Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kwE+ADjkb6f9L0NI4ahieGm/duFRrk9zWf3f+M9TEjE=; b=OkpCbZAuc4ary/KcxVWz7VNiM MIgRy9QDQH/7CPxHhG8c5Hnbo0yP212b9a5NZFM/a1Rv8k1Qj2vSDmrOqi9ir5MW+EoonYfgWMPLj oE5I3HdH2bslmjTp3RXOq1Axo05DPBPr2ES0SNAkvr2h8SqFfYobay93WxEmQbWOi2PfgixcSVHNC 5gLldTaOGcPrwJGI8R4v5snOevOq0MpVxVMJN+NyCtc5BJGtE6/3uaK7GJqD61xK8HJW0y/nmX1Ok p0jNvYB+Zz7F4ttWy6buMsAmSbqVy+IcMs1yWgCY/0nj+Emqj2KtFyRuj4mFVyA1QXvX01aJjVanE K+VfbhjnA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYNVv-009E3M-10; Mon, 19 Apr 2021 06:36:07 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYNVV-009Dzm-5f for linux-arm-kernel@desiato.infradead.org; Mon, 19 Apr 2021 06:35:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=x9ETfo1blHtWf4os90xYaaaqZC+x3Er8ohi4XJ0fz4U=; b=gwkOd2Idkc46TdQvpc7aon5IRO i41dRzQ1bcFe0IP5/STfHQ89pf1JuviyUFKKQ392osseZOAOG1TBSSqKlvAQ7Pi6oNZ8gjibUSxpV Cf4YUbOhCTJo6iwpWl3H3f3D0kf6M1yLQGV/xJ6/jQ3XaXwbkhzNIbQ0sS2yxJsEAxyXvjVH0tQO2 QLIzy10pkbLmm0hI70Rm7bOkZzCJlpjRfWuSDCg4uzYZknr/okya6PshaxAkjWCYlNXT2A+fCusl1 pIcGBSwwk3gJGnnXYRt1TN4NlwEsMNSyXBIOxypAd1pcvcX5i6+gq7Fqelf6xOtvgjJe7Ikv/1hUG Wj59Pp2A==; Received: from mo-csw1115.securemx.jp ([210.130.202.157] helo=mo-csw.securemx.jp) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYNVN-00B4M1-Sf for linux-arm-kernel@lists.infradead.org; Mon, 19 Apr 2021 06:35:39 +0000 Received: by mo-csw.securemx.jp (mx-mo-csw1115) id 13J6ZHKB006379; Mon, 19 Apr 2021 15:35:18 +0900 X-Iguazu-Qid: 2wHHJLHH09KWPw3krC X-Iguazu-QSIG: v=2; s=0; t=1618814117; q=2wHHJLHH09KWPw3krC; m=BmJZm+c0uwoQuI7CKPxyC8LNl6srxk7xqoM/zwWpo+0= Received: from imx2-a.toshiba.co.jp (imx2-a.toshiba.co.jp [106.186.93.35]) by relay.securemx.jp (mx-mr1112) id 13J6ZGRv004357 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 19 Apr 2021 15:35:17 +0900 Received: from enc01.toshiba.co.jp (enc01.toshiba.co.jp [106.186.93.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by imx2-a.toshiba.co.jp (Postfix) with ESMTPS id 642A31000B6; Mon, 19 Apr 2021 15:35:16 +0900 (JST) Received: from hop001.toshiba.co.jp ([133.199.164.63]) by enc01.toshiba.co.jp with ESMTP id 13J6ZFfJ018156; Mon, 19 Apr 2021 15:35:16 +0900 From: Nobuhiro Iwamatsu To: Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, punit1.agrawal@toshiba.co.jp, yuji2.ishikawa@toshiba.co.jp, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nobuhiro Iwamatsu Subject: [PATCH v2 2/3] PCI: dwc: Visconti: PCIe RC controller driver Date: Mon, 19 Apr 2021 15:35:12 +0900 X-TSB-HOP: ON Message-Id: <20210419063513.1947003-3-nobuhiro1.iwamatsu@toshiba.co.jp> X-Mailer: git-send-email 2.30.0.rc2 In-Reply-To: <20210419063513.1947003-1-nobuhiro1.iwamatsu@toshiba.co.jp> References: <20210419063513.1947003-1-nobuhiro1.iwamatsu@toshiba.co.jp> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210418_233534_246085_86B0D925 X-CRM114-Status: GOOD ( 25.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support to PCIe RC controller on Toshiba Visconti ARM SoCs. PCIe controller is based of Synopsys DesignWare PCIe core. This patch does not yet use the clock framework to control the clock. This will be replaced in the future. Signed-off-by: Yuji Ishikawa Signed-off-by: Nobuhiro Iwamatsu --- drivers/pci/controller/dwc/Kconfig | 9 + drivers/pci/controller/dwc/Makefile | 1 + drivers/pci/controller/dwc/pcie-visconti.c | 333 +++++++++++++++++++++ 3 files changed, 343 insertions(+) create mode 100644 drivers/pci/controller/dwc/pcie-visconti.c diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig index b9aaa84452c4..043c2c70d566 100644 --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig @@ -286,6 +286,15 @@ config PCIE_TEGRA194_EP in order to enable device-specific features PCIE_TEGRA194_EP must be selected. This uses the DesignWare core. +config PCIE_VISCONTI + bool "Toshiba VISCONTI PCIe controllers" + depends on ARCH_VISCONTI || COMPILE_TEST + depends on PCI_MSI_IRQ_DOMAIN + select PCIE_DW_HOST + help + Say Y here if you want PCIe controller support on Toshiba Visconti SoC. + This driver supports TMPV77xx. + config PCIE_UNIPHIER bool "Socionext UniPhier PCIe host controllers" depends on ARCH_UNIPHIER || COMPILE_TEST diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/dwc/Makefile index ba7c42f6df6f..46ac5d49dc75 100644 --- a/drivers/pci/controller/dwc/Makefile +++ b/drivers/pci/controller/dwc/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_PCI_MESON) += pci-meson.o obj-$(CONFIG_PCIE_TEGRA194) += pcie-tegra194.o obj-$(CONFIG_PCIE_UNIPHIER) += pcie-uniphier.o obj-$(CONFIG_PCIE_UNIPHIER_EP) += pcie-uniphier-ep.o +obj-$(CONFIG_PCIE_VISCONTI) += pcie-visconti.o # The following drivers are for devices that use the generic ACPI # pci_root.c driver but don't support standard ECAM config access. diff --git a/drivers/pci/controller/dwc/pcie-visconti.c b/drivers/pci/controller/dwc/pcie-visconti.c new file mode 100644 index 000000000000..a4739e7187f0 --- /dev/null +++ b/drivers/pci/controller/dwc/pcie-visconti.c @@ -0,0 +1,333 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * DWC PCIe RC driver for Toshiba Visconti ARM SoC + * + * Copyright (C) 2019, 2020 Toshiba Electronic Device & Storage Corporation + * Copyright (C) 2020, TOSHIBA CORPORATION + * + * Nobuhiro Iwamatsu + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pcie-designware.h" +#include "../../pci.h" + +struct visconti_pcie { + struct dw_pcie pci; + void __iomem *ulreg_base; + void __iomem *smu_base; + void __iomem *mpu_base; + struct clk *refclk; + struct clk *sysclk; + struct clk *auxclk; +}; + +#define PCIE_UL_REG_S_PCIE_MODE 0x00F4 +#define PCIE_UL_REG_S_PCIE_MODE_EP 0x00 +#define PCIE_UL_REG_S_PCIE_MODE_RC 0x04 + +#define PCIE_UL_REG_S_PERSTN_CTRL 0x00F8 +#define PCIE_UL_IOM_PCIE_PERSTN_I_EN BIT(3) +#define PCIE_UL_DIRECT_PERSTN_EN BIT(2) +#define PCIE_UL_PERSTN_OUT BIT(1) +#define PCIE_UL_DIRECT_PERSTN BIT(0) + +#define PCIE_UL_REG_S_PHY_INIT_02 0x0104 +#define PCIE_UL_PHY0_SRAM_EXT_LD_DONE BIT(0) + +#define PCIE_UL_REG_S_PHY_INIT_03 0x0108 +#define PCIE_UL_PHY0_SRAM_INIT_DONE BIT(0) + +#define PCIE_UL_REG_S_INT_EVENT_MASK1 0x0138 +#define PCIE_UL_CFG_PME_INT BIT(0) +#define PCIE_UL_CFG_LINK_EQ_REQ_INT BIT(1) +#define PCIE_UL_EDMA_INT0 BIT(2) +#define PCIE_UL_EDMA_INT1 BIT(3) +#define PCIE_UL_EDMA_INT2 BIT(4) +#define PCIE_UL_EDMA_INT3 BIT(5) +#define PCIE_UL_S_INT_EVENT_MASK1_ALL (PCIE_UL_CFG_PME_INT | PCIE_UL_CFG_LINK_EQ_REQ_INT | \ + PCIE_UL_EDMA_INT0 | PCIE_UL_EDMA_INT1 | \ + PCIE_UL_EDMA_INT2 | PCIE_UL_EDMA_INT3) + +#define PCIE_UL_REG_S_SB_MON 0x0198 +#define PCIE_UL_REG_S_SIG_MON 0x019C +#define PCIE_UL_CORE_RST_N_MON BIT(0) + +#define PCIE_UL_REG_V_SII_DBG_00 0x0844 +#define PCIE_UL_REG_V_SII_GEN_CTRL_01 0x0860 +#define PCIE_UL_APP_LTSSM_ENABLE BIT(0) + +#define PCIE_UL_REG_V_PHY_ST_00 0x0864 +#define PCIE_UL_SMLH_LINK_UP BIT(0) + +#define PCIE_UL_REG_V_PHY_ST_02 0x0868 +#define PCIE_UL_S_DETECT_ACT 0x01 +#define PCIE_UL_S_L0 0x11 + +#define PISMU_CKON_PCIE 0x0038 +#define PISMU_CKON_PCIE_AUX_CLK BIT(1) +#define PISMU_CKON_PCIE_MSTR_ACLK BIT(0) + +#define PISMU_RSOFF_PCIE 0x0538 +#define PISMU_RSOFF_PCIE_ULREG_RST_N BIT(1) +#define PISMU_RSOFF_PCIE_PWR_UP_RST_N BIT(0) + +#define PCIE_MPU_REG_MP_EN 0x0 +#define MPU_MP_EN_DISABLE BIT(0) + +#define PCIE_BUS_OFFSET 0x40000000 + +/* Access registers in PCIe ulreg */ +static inline void visconti_ulreg_writel(struct visconti_pcie *pcie, u32 val, u32 reg) +{ + writel_relaxed(val, pcie->ulreg_base + reg); +} + +/* Access registers in PCIe smu */ +static inline void visconti_smu_writel(struct visconti_pcie *pcie, u32 val, u32 reg) +{ + writel_relaxed(val, pcie->smu_base + reg); +} + +/* Access registers in PCIe mpu */ +static inline void visconti_mpu_writel(struct visconti_pcie *pcie, u32 val, u32 reg) +{ + writel_relaxed(val, pcie->mpu_base + reg); +} + +static inline u32 visconti_mpu_readl(struct visconti_pcie *pcie, u32 reg) +{ + return readl_relaxed(pcie->mpu_base + reg); +} + +static int visconti_pcie_check_link_status(struct visconti_pcie *pcie) +{ + int err; + u32 val; + + /* wait for linkup of phy link layer */ + err = readl_relaxed_poll_timeout(pcie->ulreg_base + PCIE_UL_REG_V_PHY_ST_00, val, + (val & PCIE_UL_SMLH_LINK_UP), 1000, 10000); + if (err) + return err; + + /* wait for linkup of data link layer */ + err = readl_relaxed_poll_timeout(pcie->ulreg_base + PCIE_UL_REG_V_PHY_ST_02, val, + (val & PCIE_UL_S_DETECT_ACT), 1000, 10000); + if (err) + return err; + + /* wait for LTSSM Status */ + return readl_relaxed_poll_timeout(pcie->ulreg_base + PCIE_UL_REG_V_PHY_ST_02, val, + (val & PCIE_UL_S_L0), 1000, 10000); +} + +static int visconti_pcie_establish_link(struct pcie_port *pp) +{ + int ret; + u32 val; + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct visconti_pcie *pcie = dev_get_drvdata(pci->dev); + + visconti_ulreg_writel(pcie, PCIE_UL_APP_LTSSM_ENABLE, PCIE_UL_REG_V_SII_GEN_CTRL_01); + + ret = visconti_pcie_check_link_status(pcie); + if (ret < 0) { + dev_info(pci->dev, "Link failure\n"); + return ret; + } + + val = visconti_mpu_readl(pcie, PCIE_MPU_REG_MP_EN); + visconti_mpu_writel(pcie, val & ~MPU_MP_EN_DISABLE, PCIE_MPU_REG_MP_EN); + + visconti_ulreg_writel(pcie, PCIE_UL_S_INT_EVENT_MASK1_ALL, PCIE_UL_REG_S_INT_EVENT_MASK1); + + return 0; +} + +static int visconti_pcie_host_init(struct pcie_port *pp) +{ + dw_pcie_setup_rc(pp); + return visconti_pcie_establish_link(pp); +} + +static const struct dw_pcie_host_ops visconti_pcie_host_ops = { + .host_init = visconti_pcie_host_init, +}; + +static u64 visconti_pcie_cpu_addr_fixup(struct dw_pcie *pci, u64 pci_addr) +{ + return pci_addr - PCIE_BUS_OFFSET; +} + +static const struct dw_pcie_ops dw_pcie_ops = { + .cpu_addr_fixup = visconti_pcie_cpu_addr_fixup, +}; + +static int visconti_get_resources(struct platform_device *pdev, + struct visconti_pcie *pcie) +{ + struct device *dev = &pdev->dev; + + pcie->ulreg_base = devm_platform_ioremap_resource_byname(pdev, "ulreg"); + if (IS_ERR(pcie->ulreg_base)) + return PTR_ERR(pcie->ulreg_base); + + pcie->smu_base = devm_platform_ioremap_resource_byname(pdev, "smu"); + if (IS_ERR(pcie->smu_base)) + return PTR_ERR(pcie->smu_base); + + pcie->mpu_base = devm_platform_ioremap_resource_byname(pdev, "mpu"); + if (IS_ERR(pcie->mpu_base)) + return PTR_ERR(pcie->mpu_base); + + pcie->refclk = devm_clk_get(dev, "pcie_refclk"); + if (IS_ERR(pcie->refclk)) { + dev_err(dev, "Failed to get refclk clock: %ld\n", PTR_ERR(pcie->refclk)); + return PTR_ERR(pcie->refclk); + } + + pcie->sysclk = devm_clk_get(dev, "sysclk"); + if (IS_ERR(pcie->sysclk)) { + dev_err(dev, "Failed to get sysclk clock: %ld\n", PTR_ERR(pcie->sysclk)); + return PTR_ERR(pcie->sysclk); + } + + pcie->auxclk = devm_clk_get(dev, "auxclk"); + if (IS_ERR(pcie->auxclk)) { + dev_err(dev, "Failed to get auxclk clock: %ld\n", PTR_ERR(pcie->auxclk)); + return PTR_ERR(pcie->auxclk); + } + + return 0; +} + +static int visconti_device_turnon(struct visconti_pcie *pcie) +{ + int err; + u32 val; + + visconti_smu_writel(pcie, PISMU_CKON_PCIE_AUX_CLK | PISMU_CKON_PCIE_MSTR_ACLK, + PISMU_CKON_PCIE); + ndelay(250); + + visconti_smu_writel(pcie, PISMU_RSOFF_PCIE_ULREG_RST_N, PISMU_RSOFF_PCIE); + + visconti_ulreg_writel(pcie, PCIE_UL_REG_S_PCIE_MODE_RC, PCIE_UL_REG_S_PCIE_MODE); + + val = PCIE_UL_IOM_PCIE_PERSTN_I_EN | PCIE_UL_DIRECT_PERSTN_EN | PCIE_UL_DIRECT_PERSTN; + visconti_ulreg_writel(pcie, val, PCIE_UL_REG_S_PERSTN_CTRL); + udelay(100); + + val |= PCIE_UL_PERSTN_OUT; + visconti_ulreg_writel(pcie, val, PCIE_UL_REG_S_PERSTN_CTRL); + udelay(100); + + visconti_smu_writel(pcie, PISMU_RSOFF_PCIE_PWR_UP_RST_N, PISMU_RSOFF_PCIE); + + err = readl_relaxed_poll_timeout(pcie->ulreg_base + PCIE_UL_REG_S_PHY_INIT_03, val, + (val & PCIE_UL_PHY0_SRAM_INIT_DONE), 100, 1000); + if (err) + return err; + + visconti_ulreg_writel(pcie, PCIE_UL_PHY0_SRAM_EXT_LD_DONE, PCIE_UL_REG_S_PHY_INIT_02); + + return readl_relaxed_poll_timeout(pcie->ulreg_base + PCIE_UL_REG_S_SIG_MON, val, + (val & PCIE_UL_CORE_RST_N_MON), 100, 1000); +} + +static int visconti_add_pcie_port(struct visconti_pcie *pcie, struct platform_device *pdev) +{ + struct dw_pcie *pci = &pcie->pci; + struct pcie_port *pp = &pci->pp; + struct device *dev = &pdev->dev; + int ret; + + pp->irq = platform_get_irq_byname(pdev, "intr"); + if (pp->irq < 0) { + dev_err(dev, "interrupt intr is missing"); + return pp->irq; + } + + pp->ops = &visconti_pcie_host_ops; + + pci->link_gen = of_pci_get_max_link_speed(pdev->dev.of_node); + if (pci->link_gen < 0 || pci->link_gen > 3) { + pci->link_gen = 3; + dev_dbg(dev, "Applied default link speed\n"); + } + + dev_dbg(dev, "link speed Gen %d", pci->link_gen); + + ret = visconti_device_turnon(pcie); + if (ret) + goto error; + + ret = dw_pcie_host_init(pp); + if (ret) + dev_err(dev, "Failed to initialize host\n"); + +error: + return ret; +} + +static int visconti_pcie_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct visconti_pcie *pcie; + struct pcie_port *pp; + struct dw_pcie *pci; + int ret; + + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(36)); + if (ret) + return ret; + + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); + if (!pcie) + return -ENOMEM; + + pci = &pcie->pci; + pp = &pci->pp; + pp->num_vectors = MAX_MSI_IRQS; + + pci->dev = dev; + pci->ops = &dw_pcie_ops; + + ret = visconti_get_resources(pdev, pcie); + if (ret) + return ret; + + platform_set_drvdata(pdev, pcie); + + return visconti_add_pcie_port(pcie, pdev); +} + +static const struct of_device_id visconti_pcie_match[] = { + { .compatible = "toshiba,visconti-pcie" }, + {}, +}; + +static struct platform_driver visconti_pcie_driver = { + .probe = visconti_pcie_probe, + .driver = { + .name = "visconti-pcie", + .of_match_table = visconti_pcie_match, + .suppress_bind_attrs = true, + }, +}; + +builtin_platform_driver(visconti_pcie_driver); From patchwork Mon Apr 19 06:35:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro Iwamatsu X-Patchwork-Id: 12210879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71B6CC433ED for ; Mon, 19 Apr 2021 06:37:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2508C61104 for ; Mon, 19 Apr 2021 06:37:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2508C61104 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=toshiba.co.jp Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8V0O2/ir457XtCs9n+7OwZbZoMBTaG+GqK5wBqT0Cgg=; b=MIF9AC6/zztElz/04cVyIu/Z6 pgcPzG6ayoXIueEnRoEeDc/uE3gebK+6yX6idXRfDb6JgrMt6igyHF1lL8Yit+P+wbpY3MTxOROhK E1b2efSNLe4TMGFn2v4RKe6mmslJxqQ/zGt5PYGzShVLydy8ZPSEMbOHq6vO9CCt0Nygm0g2tJ5mg enZv1PCNLpiRDhiVK8sW8lBVn1llcTFEGGA4x7rNoESpZPZQt7IuUSQlB5BaegesHfsrpgIz2gt5K vOR8kiWAzGNWlD50AmnpMA8+faA3g5dM3B0YrGrM82U0UT0LP6Su+Gem+lOvqdthMxLz7NpOpTpRB 7cUf5Humw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYNVm-009E1t-Ak; Mon, 19 Apr 2021 06:35:58 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYNVV-009Dzl-5A for linux-arm-kernel@desiato.infradead.org; Mon, 19 Apr 2021 06:35:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=jdZdrldg7emUwDpyRlwMYlwE9Sw6ondyIeX0jaO9IJQ=; b=wdUXupNOHu/V8z6ASLgQtpGcwR hjj3Y46s60/e1ALprZHeZ63qZx3UEtwfLCMXK4rNXxtDGRZxjuHQ4IrLv3jKMd3WSiU4B/w2n7+DA 1CBwnBb9Z4OJKQImXPQZ3PWCFOj3J7bFhH7ArRzmiTJvl6Sl8LLrizfF01iiVB0yGmWjN6X0l9FRT CfBkrPWABCFNdtEf9g222A+j7G4XOeIqO10y/Qni6EfMertWH0NLJ5nzE8YRz3MRI3VZLvBqHTEsu Ii/LloLncIZlfC039ih+mWifLZ4f0THjahS/yrugne0twY8iiUg3TPJfi/P/5m3bJdMPfoYFTLJ8h IwpyJ3/w==; Received: from mo-csw1515.securemx.jp ([210.130.202.154] helo=mo-csw.securemx.jp) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYNVO-00B4Lw-1E for linux-arm-kernel@lists.infradead.org; Mon, 19 Apr 2021 06:35:39 +0000 Received: by mo-csw.securemx.jp (mx-mo-csw1515) id 13J6ZIHa030286; Mon, 19 Apr 2021 15:35:18 +0900 X-Iguazu-Qid: 34tr9jB2dgCsPBSbHj X-Iguazu-QSIG: v=2; s=0; t=1618814117; q=34tr9jB2dgCsPBSbHj; m=KAQgw1k5Yh2trgm8JKJC2ZRyPU6Q5anXfHj5orjLd+g= Received: from imx2-a.toshiba.co.jp (imx2-a.toshiba.co.jp [106.186.93.35]) by relay.securemx.jp (mx-mr1510) id 13J6ZGJZ005389 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 19 Apr 2021 15:35:17 +0900 Received: from enc01.toshiba.co.jp (enc01.toshiba.co.jp [106.186.93.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by imx2-a.toshiba.co.jp (Postfix) with ESMTPS id C50F51000B9; Mon, 19 Apr 2021 15:35:16 +0900 (JST) Received: from hop001.toshiba.co.jp ([133.199.164.63]) by enc01.toshiba.co.jp with ESMTP id 13J6ZGjr018183; Mon, 19 Apr 2021 15:35:16 +0900 From: Nobuhiro Iwamatsu To: Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, punit1.agrawal@toshiba.co.jp, yuji2.ishikawa@toshiba.co.jp, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nobuhiro Iwamatsu Subject: [PATCH v2 3/3] MAINTAINERS: Add entries for Toshiba Visconti PCIe controller Date: Mon, 19 Apr 2021 15:35:13 +0900 X-TSB-HOP: ON Message-Id: <20210419063513.1947003-4-nobuhiro1.iwamatsu@toshiba.co.jp> X-Mailer: git-send-email 2.30.0.rc2 In-Reply-To: <20210419063513.1947003-1-nobuhiro1.iwamatsu@toshiba.co.jp> References: <20210419063513.1947003-1-nobuhiro1.iwamatsu@toshiba.co.jp> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210418_233534_307655_1D5FC6D4 X-CRM114-Status: GOOD ( 10.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add entries for Toshiba Visconti PCIe controller binding and driver. Signed-off-by: Nobuhiro Iwamatsu --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 8a154939ae27..3e5187c5b8d2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2621,11 +2621,13 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/iwamatsu/linux-visconti.git F: Documentation/devicetree/bindings/arm/toshiba.yaml F: Documentation/devicetree/bindings/net/toshiba,visconti-dwmac.yaml F: Documentation/devicetree/bindings/gpio/toshiba,gpio-visconti.yaml +F: Documentation/devicetree/bindings/pci/toshiba,visconti-pcie.yaml F: Documentation/devicetree/bindings/pinctrl/toshiba,tmpv7700-pinctrl.yaml F: Documentation/devicetree/bindings/watchdog/toshiba,visconti-wdt.yaml F: arch/arm64/boot/dts/toshiba/ F: drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c F: drivers/gpio/gpio-visconti.c +F: drivers/pci/controller/dwc/pcie-visconti.c F: drivers/pinctrl/visconti/ F: drivers/watchdog/visconti_wdt.c N: visconti