From patchwork Fri Apr 16 08:40:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 12207185 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 C1758C43460 for ; Fri, 16 Apr 2021 09:08:03 +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 3E8876113B for ; Fri, 16 Apr 2021 09:08:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E8876113B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com 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=IaQCxJR06dLJ3jXmfzx5rWNtTqDyIXnkZlRB2r6Bb+8=; b=W2cDlqdF7bgn2GJXbBCoZ6R2G kL7Pr3KTABSrfQs3lOwKJ3Nk3yR085aVlht94XHU4WFYhfyO/4wlpjh7yMT9lwkU2U9ESH8lR6c/R 2nXbgKj79t8Yoe7tSh+RlNBB04OZE+Bz/8snh7g3wYoEFd22ZOubXR3JVCHUlTkpEK9uDLXcEikWQ OouYESmm6QyqO1cFrU7Yiu0V9FAEp+PZ7f7D7g4diGZyqqgf+BgJLBc4cDIPh8x4rWZbNMCTuWaHt +BE5J367lCPnEgLWjX6WlSspgBvQG7t1ocN+bZK7HdsH3Nw6Yegeyabo1iMRJctmhOwgOQHn0nmfc LEzIKXikA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lXKPD-001TVb-S7; Fri, 16 Apr 2021 09:04:52 +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 1lXK2F-001Ors-Pq for linux-arm-kernel@desiato.infradead.org; Fri, 16 Apr 2021 08:41:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description; bh=U4ByfyZNnCMaaz248hsFxEKlDW0bN4CezVYV49f+IAE=; b=vFgsE31JQjyMOyPA5QKVfhSOVW rTiKWLM6oXXJFKRWCJmjM4C15XFZ40LwZlCxTEjnxD/W/bYZ7AdJ1nBmggLPtDw3EntsZAeFP0rmy ICkk2D6KF/FFHOpmNyssgi3Cr4Fn93PEljBb7ZI44aOeMvRZUk88pKiIzL/JuUwYIE2G8xuEXQHsn 0edUtYLYimKV41lCi5n1yeR2Sytws1TxsuMy1AEGvU5YsOUxnjRh2EhYMqGWEXhVOVxBpekgvOwTE v+kug8di9NCMzQvhhaCZFFIiYQEIqqc2KLA/p5MV/SZFykx/cf+iI81oUyx4LKvMUOxh3H1tYto0m ZbWfvwIg==; Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXK2C-009Cep-Vw for linux-arm-kernel@lists.infradead.org; Fri, 16 Apr 2021 08:41:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618562465; x=1650098465; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8lTZOjpt/PsZ0L6mL9vuEq3HADt4pfMakp+8pxOPEJk=; b=TOy9FXivYb7/9jlatQOqNK8podR9qdWJRkPKWxOJKWG5Nj0Wbk3l0jUc W+ZtyZL3FPJ5b5WVSpWzmN+6ejlsfPYbKduAuw0lYGjldIONUhgR39hme CUiigYGZz2+gmUW2QEliTWiGuXrZ2834wwMFaNmjgkkuYd3AZq1kV1wCH FOXD3vF8uKnm9/dNjwwFmifiSGeklEzmEGf5IuV8Ew8qzjPeBCn4eOp/9 D1oX4mJgv619brn1zPNvXisx7siyPRs8pieleUo8Dk1eahsPFjNjzCEp6 8vyBFZ1myqjkYBLs1NphunRdAvLHdc9Db8KURuLEudiNUNmGtJnKp87px g==; IronPort-SDR: Ha6NQ0j0CyD2wsaq7XsdO2Euv7+sh+eBpsXlZ5y52Mx46fmY+ed1kesyLwx2NelqvkM/NxS1E5 RgAWy0HfIdM9ErtRcbk6MB3H++4cREZE7mkVSlisjsA6x49BYSHDjo2jQt8GAWHWDe2WYITkwp Oy/GOPAqlDHBFObS8LGAssse1rV8N9vexGmGf9RC2yM37FIicaoNfMtiyQSAc0GqCO7ocWG044 7/MTFtgT0y48H4pQCEkiIP1SYuwK40lIutn1H8MRJYeiCEFH5xkhv9ZfVF/y2LPeF1914XgLZ9 b5w= X-IronPort-AV: E=Sophos;i="5.82,226,1613458800"; d="scan'208";a="116692462" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 16 Apr 2021 01:41:02 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Apr 2021 01:41:01 -0700 Received: from mchp-dev-shegelun.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Fri, 16 Apr 2021 01:40:59 -0700 From: Steen Hegelund To: Philipp Zabel , Rob Herring CC: Steen Hegelund , Andrew Lunn , Microchip Linux Driver Support , Alexandre Belloni , Gregory Clement , , , , "Rob Herring" Subject: [PATCH v9 1/3] dt-bindings: reset: microchip sparx5 reset driver bindings Date: Fri, 16 Apr 2021 10:40:52 +0200 Message-ID: <20210416084054.2922327-2-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210416084054.2922327-1-steen.hegelund@microchip.com> References: <20210416084054.2922327-1-steen.hegelund@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210416_014105_062672_E761BC7A X-CRM114-Status: GOOD ( 12.46 ) 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 Document the Sparx5 reset device driver bindings The driver uses a syscon and an IO range on sparx5 for access to the reset control and the reset status. Sparx5 will no longer use the existing Ocelot chip reset driver, but use this new switch reset driver as it has the reset controller interface that allows the first client to perform the reset on behalf of all the Sparx5 component drivers. Signed-off-by: Steen Hegelund Reviewed-by: Rob Herring --- .../bindings/reset/microchip,rst.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/microchip,rst.yaml diff --git a/Documentation/devicetree/bindings/reset/microchip,rst.yaml b/Documentation/devicetree/bindings/reset/microchip,rst.yaml new file mode 100644 index 000000000000..370579aeeca1 --- /dev/null +++ b/Documentation/devicetree/bindings/reset/microchip,rst.yaml @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/reset/microchip,rst.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Microchip Sparx5 Switch Reset Controller + +maintainers: + - Steen Hegelund + - Lars Povlsen + +description: | + The Microchip Sparx5 Switch provides reset control and implements the following + functions + - One Time Switch Core Reset (Soft Reset) + +properties: + $nodename: + pattern: "^reset-controller@[0-9a-f]+$" + + compatible: + const: microchip,sparx5-switch-reset + + reg: + items: + - description: global control block registers + + reg-names: + items: + - const: gcb + + "#reset-cells": + const: 1 + + cpu-syscon: + $ref: "/schemas/types.yaml#/definitions/phandle" + description: syscon used to access CPU reset + +required: + - compatible + - reg + - reg-names + - "#reset-cells" + - cpu-syscon + +additionalProperties: false + +examples: + - | + reset: reset-controller@11010008 { + compatible = "microchip,sparx5-switch-reset"; + reg = <0x11010008 0x4>; + reg-names = "gcb"; + #reset-cells = <1>; + cpu-syscon = <&cpu_ctrl>; + }; + From patchwork Fri Apr 16 08:40:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 12207187 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=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 74374C433B4 for ; Fri, 16 Apr 2021 09:08:29 +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 E942E6100C for ; Fri, 16 Apr 2021 09:08:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E942E6100C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com 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=dbaGbJcBg3tHkc2ujqbJGoqOpX/yuHXXXnS1fApIXCo=; b=jTHipvZ6PkaH1tE/fWVStoaa0 d5kMfDLqnPQE8vdyJCDXDFl1IyG18ShlzL6xVYBPUGIM8HSjI8QxTdveZNBW26kpCFc5iti71HpsG mHoydkQCJ+HLInXckxV0acWCqepmjj7V//bd6iDnVsrnd5Ddi+VjQsQCNvsIZAkWa9DM4eKzhaFOl fxpXosexeJA8Qpg59opjhDIfT9x/oxjsCBe5yXfu3/iolQ4qpr6IepN2rs7Cak1K1HNU9jlEexMDf SZMJJC4oVs8m3Em5nnZZQNCizScRA3zb/jqA4WbgdxzR9h0MQW8T1ZQcSwra+0sG6Bg3GSSQDo3za MiSFXi6Ow==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lXKQ3-001TbM-Eo; Fri, 16 Apr 2021 09:05:47 +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 1lXK2G-001OsD-GH for linux-arm-kernel@desiato.infradead.org; Fri, 16 Apr 2021 08:41:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description; bh=Op6/r5cIyJgEdTe2OXN/MCpADQuiHuK8GI56u2qRtXw=; b=IYsRP3ZVVZgu+/E4DOJ9u440D3 wykb/ONlzhYGZ+KwJJme4ghQsmTBznBjIBiYX+41ZT2Nx8WMjE7bLDpzNnkHtFbjvUDX32FNnNspX 344zDge2LbG48rZHaBVfRmeHelm5fHOa0sn8Zcy1ZkGCyg4UmBqe3b3PXp9V4aTNl7bixo3oGcvWT 3B9eNNLMTr1+aD4sV5ITxjfRGd9hW/HzFCAXkxGP8DcPJGI00Wsu8ChAXvuUi8WObuabcUI1eaEjX QAJk20p+yRSRYwS29INNyw1oa8fj3vZ2hdZmVw1nUXKGLlufYU5C9koZnoSnHveIjdGd2aZXbILfX BDC2HOWw==; Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXK2D-009Cf5-Dk for linux-arm-kernel@lists.infradead.org; Fri, 16 Apr 2021 08:41:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618562465; x=1650098465; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xCD7g6/g6HiLLPWo4tnh9d5cUiUqj29Srge0p1C8H8U=; b=Uu6NpLO94Tb/r0cr7gQV/+hFncFq2RgN6ILNxI21Nko6YimMgYfzszx/ 6Y7ZT6K//PxMmBJpOl28khLtKxqnfpbbzsbHX6rgcTEr230EhWXPB0F9w MsLjM+dDik3sL9+FvSH9DQjkKLWmBI5Qvm19Sq01v9mpa/Z51zEkVl4Cd DDzQPvs3IVpFxXHbVcDuF/+4AbYo4ffyUxh0mBfMgvDe6eoNd9epoCGho R9NF9Z23B3x0A4E2Vo6Sa/u6F6u6L8QIutu/fIRTduhH6iiMxhWQGGvDh ks5qq3qyCmtl+zvw2oZyKhG3IK2c6f59YDlFZ5t22Fj1cLv3rBft6vPVR g==; IronPort-SDR: St2SkBg7OPvjH+/oJVWtDdOnqyL1tXg9iZF7IQ41GR0y/2muMEY6EZ8cSjIywem9dRWE/LrPOZ ovvZAQqLFCYlWzpUJQelCKwwXzGrVbv1WIZhfgif42Ayed618n8iUb5c3chcNmknCUrzBd3rSD gcUOIPcN7+jbFJfSEnvP4QchM5TGQTdiiG2C5FUFWYNFSu6+HrdzqpN/DKICENwDmVrrbNMD69 2CgTsmNwMFMMaGLptR4fVoy9riuuTKBlreCU6y9pLh+yepxELTN84cCEXFEO2CP2szvD+32+Kz u2w= X-IronPort-AV: E=Sophos;i="5.82,226,1613458800"; d="scan'208";a="111062402" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 16 Apr 2021 01:41:03 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Apr 2021 01:41:03 -0700 Received: from mchp-dev-shegelun.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Fri, 16 Apr 2021 01:41:01 -0700 From: Steen Hegelund To: Philipp Zabel CC: Steen Hegelund , Andrew Lunn , Microchip Linux Driver Support , Alexandre Belloni , Gregory Clement , , Subject: [PATCH v9 2/3] reset: mchp: sparx5: add switch reset driver Date: Fri, 16 Apr 2021 10:40:53 +0200 Message-ID: <20210416084054.2922327-3-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210416084054.2922327-1-steen.hegelund@microchip.com> References: <20210416084054.2922327-1-steen.hegelund@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210416_014105_593085_189EF58E X-CRM114-Status: GOOD ( 22.91 ) 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 The Sparx5 Switch SoC has a number of components that can be reset indiviually, but at least the Switch Core needs to be in a well defined state at power on, when any of the Sparx5 drivers starts to access the Switch Core, this reset driver is available. The reset driver is loaded early via the postcore_initcall interface, and will then be available for the other Sparx5 drivers (SGPIO, SwitchDev etc) that are loaded next, and the first of them to be loaded can perform the one-time Switch Core reset that is needed. The driver has protection so that the system busses, DDR controller, PCI-E and ARM A53 CPU and a few other subsystems are not touched by the reset. Signed-off-by: Steen Hegelund Reviewed-by: Alexandre Belloni --- drivers/reset/Kconfig | 8 ++ drivers/reset/Makefile | 1 + drivers/reset/reset-microchip-sparx5.c | 146 +++++++++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 drivers/reset/reset-microchip-sparx5.c diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 4171c6f76385..c26798092ccf 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -111,6 +111,14 @@ config RESET_LPC18XX help This enables the reset controller driver for NXP LPC18xx/43xx SoCs. +config RESET_MCHP_SPARX5 + bool "Microchip Sparx5 reset driver" + depends on HAS_IOMEM || COMPILE_TEST + default y if SPARX5_SWITCH + select MFD_SYSCON + help + This driver supports switch core reset for the Microchip Sparx5 SoC. + config RESET_MESON tristate "Meson Reset Driver" depends on ARCH_MESON || COMPILE_TEST diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index 65a118a91b27..c1d6aa9b1b52 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_RESET_INTEL_GW) += reset-intel-gw.o obj-$(CONFIG_RESET_K210) += reset-k210.o obj-$(CONFIG_RESET_LANTIQ) += reset-lantiq.o obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o +obj-$(CONFIG_RESET_MCHP_SPARX5) += reset-microchip-sparx5.o obj-$(CONFIG_RESET_MESON) += reset-meson.o obj-$(CONFIG_RESET_MESON_AUDIO_ARB) += reset-meson-audio-arb.o obj-$(CONFIG_RESET_NPCM) += reset-npcm.o diff --git a/drivers/reset/reset-microchip-sparx5.c b/drivers/reset/reset-microchip-sparx5.c new file mode 100644 index 000000000000..cff39a643a14 --- /dev/null +++ b/drivers/reset/reset-microchip-sparx5.c @@ -0,0 +1,146 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* Microchip Sparx5 Switch Reset driver + * + * Copyright (c) 2020 Microchip Technology Inc. and its subsidiaries. + * + * The Sparx5 Chip Register Model can be browsed at this location: + * https://github.com/microchip-ung/sparx-5_reginfo + */ +#include +#include +#include +#include +#include +#include + +#define PROTECT_REG 0x84 +#define PROTECT_BIT BIT(10) +#define SOFT_RESET_REG 0x00 +#define SOFT_RESET_BIT BIT(1) + +struct mchp_reset_context { + struct regmap *cpu_ctrl; + struct regmap *gcb_ctrl; + struct reset_controller_dev rcdev; +}; + +static struct regmap_config sparx5_reset_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + +static int sparx5_switch_reset(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct mchp_reset_context *ctx = + container_of(rcdev, struct mchp_reset_context, rcdev); + u32 val; + + /* Make sure the core is PROTECTED from reset */ + regmap_update_bits(ctx->cpu_ctrl, PROTECT_REG, PROTECT_BIT, PROTECT_BIT); + + /* Start soft reset */ + regmap_write(ctx->gcb_ctrl, SOFT_RESET_REG, SOFT_RESET_BIT); + + /* Wait for soft reset done */ + return regmap_read_poll_timeout(ctx->gcb_ctrl, SOFT_RESET_REG, val, + (val & SOFT_RESET_BIT) == 0, + 1, 100); +} + +static const struct reset_control_ops sparx5_reset_ops = { + .reset = sparx5_switch_reset, +}; + +static int mchp_sparx5_map_syscon(struct platform_device *pdev, char *name, + struct regmap **target) +{ + struct device_node *syscon_np; + struct regmap *regmap; + int err; + + syscon_np = of_parse_phandle(pdev->dev.of_node, name, 0); + if (!syscon_np) + return -ENODEV; + regmap = syscon_node_to_regmap(syscon_np); + of_node_put(syscon_np); + if (IS_ERR(regmap)) { + err = PTR_ERR(regmap); + dev_err(&pdev->dev, "No '%s' map: %d\n", name, err); + return err; + } + *target = regmap; + return 0; +} + +static int mchp_sparx5_map_io(struct platform_device *pdev, int index, + struct regmap **target) +{ + struct resource *res; + struct regmap *map; + void __iomem *mem; + + mem = devm_platform_get_and_ioremap_resource(pdev, index, &res); + if (!mem) { + dev_err(&pdev->dev, "Could not map resource %d\n", index); + return -ENXIO; + } + sparx5_reset_regmap_config.name = res->name; + map = devm_regmap_init_mmio(&pdev->dev, mem, &sparx5_reset_regmap_config); + if (IS_ERR(map)) + return PTR_ERR(map); + *target = map; + return 0; +} + +static int mchp_sparx5_reset_probe(struct platform_device *pdev) +{ + struct device_node *dn = pdev->dev.of_node; + struct mchp_reset_context *ctx; + int err; + + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + err = mchp_sparx5_map_syscon(pdev, "cpu-syscon", &ctx->cpu_ctrl); + if (err) + return err; + err = mchp_sparx5_map_io(pdev, 0, &ctx->gcb_ctrl); + if (err) + return err; + + ctx->rcdev.owner = THIS_MODULE; + ctx->rcdev.nr_resets = 1; + ctx->rcdev.ops = &sparx5_reset_ops; + ctx->rcdev.of_node = dn; + + return devm_reset_controller_register(&pdev->dev, &ctx->rcdev); +} + +static const struct of_device_id mchp_sparx5_reset_of_match[] = { + { + .compatible = "microchip,sparx5-switch-reset", + }, + { } +}; + +static struct platform_driver mchp_sparx5_reset_driver = { + .probe = mchp_sparx5_reset_probe, + .driver = { + .name = "sparx5-switch-reset", + .of_match_table = mchp_sparx5_reset_of_match, + }, +}; + +static int __init mchp_sparx5_reset_init(void) +{ + return platform_driver_register(&mchp_sparx5_reset_driver); +} + +postcore_initcall(mchp_sparx5_reset_init); + +MODULE_DESCRIPTION("Microchip Sparx5 switch reset driver"); +MODULE_AUTHOR("Steen Hegelund "); +MODULE_LICENSE("Dual MIT/GPL"); From patchwork Fri Apr 16 08:40:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steen Hegelund X-Patchwork-Id: 12207189 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=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 C600DC433B4 for ; Fri, 16 Apr 2021 09:08: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 4A3E96100C for ; Fri, 16 Apr 2021 09:08:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A3E96100C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com 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=alEBkzW/4+d6kKxky7pFpzrtrAf7K4E0rvm6jK/8+Ho=; b=Rst8gYUVUNDuj3d3GFrQookdF feKZGZYbSy0n0lFLzEh9ThrLwDBezoJ/P4mrgO542plH0WUPXIUEhGc7vzeI93tQFIhk4B2TuwCII TR6r69BMMEwEJd3Sz0axqiq5B1657hs+5By23XBz8CqMjDGu0NJAAEgPEBzdLkALeFPwKtOLZp2W6 OzJNnmWEtQ93JXmQUJ3pHXEXeonTlQiYIGI5iLwFPh2Tao0jQvPDZl3gu8W1QXIw3OYO/o6jowPFn qppeQMQs+ynbuUvjKovdOHLi2/25S7MHe7sXvgk7wFYS21P+tNshHaR07LbenUWiYGrD8CcVzkRLR 63yslUdtw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lXKRN-001TkE-6T; Fri, 16 Apr 2021 09:07:05 +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 1lXK2H-001Osf-Ov for linux-arm-kernel@desiato.infradead.org; Fri, 16 Apr 2021 08:41:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Sender:Reply-To:Content-ID:Content-Description; bh=RGGdDAKrZNs9C2MBV49GRNqlgs23/WGrNJevyaHHHOs=; b=BmW+0Url7wrm2I8QpiNy32r7nl ERPAPibJRePl6oSq5hyDTH24T+LDsEYXF7fQ9IDDH/tUWOX0EONx8pyeoHO+9chHjSOI32hzISQ6X BpiRqPd4Hfc/0LmkLwhkd+D53HMFR0E6OlrABzlFjEVWLa3wdhyIRHSrQNhk1f81k6UjeZ1eHBhvI chfgbHTcABclak4lMnbSrUnyXgqu9f7hJ1SSIKB+Zd2mBTvMDeg+ceVQsq7RdELOjliMjTxQG9RN/ ihXbIrluiBK2KkFhRvblNilXPlwH0WmqGj9sW44MTSuhcc5WQTUgel+F/4vzc+bzaAYR/CeZy9/p8 Zd//HU6Q==; Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lXK2F-009CfY-1k for linux-arm-kernel@lists.infradead.org; Fri, 16 Apr 2021 08:41:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1618562466; x=1650098466; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xboU3TO7GJRPpG7WTJfaV2IWSqO0VeAzKYAu121oemk=; b=YydCYjO5OLgNMX8h2lAx20sJjGWoVg+EorRIbLKTrbhpBAybXhp6shrX pDl6wOT8E/XAOm88/EPPhy4vJh1CQu6fYK+XLXWWbh/m7D0hu49/ITzGC GepcWEGxenG2UDxzAovEjUzKWOAvMr38Xna2XdZgMZHdoPhDRKj/HSysv vEqVAgqSi+5BcAj0DEnLfZijW3uEt+1Fft5X67J4tJwPBy+eKr4WKP2Kq gg6YT1cfUZejEOO9zFzA3RbS3WOxAoHi6mIIJT/HkEiLFdfvxRnKCE7NG QgKtSbgv3yS2HBDWtWB1jPaa0uYieQsjWCovGpRnGhSg0uZqx7rcVFiEy Q==; IronPort-SDR: JSWFwF3awOSEQ3akSCeSKD45X3NpLH0YyknPPOgcJR94ZsEiggTU/oFclO8tV5jmD4QJOL/dBF ALUbxnZ3FHK4CUzoEz7e1PSD6gaWFmcItkdb+SJ/nXHa37i7oFynx9gHwVn1YNFd/yk+i1Obfy H2BJIa7m3agPeQ29C+L6QWnA4Qo3jdDDgSlUrDxE/ueqKsr94szIX2lF0c6d9JsM+Tdvskahn4 XyMyAXJIDdruThOtWv53o1yncMH9M8tNFUV7AjMYX35QkO8UAzC5xMPVIOu2k/6wb+lsI1ffCr fwU= X-IronPort-AV: E=Sophos;i="5.82,226,1613458800"; d="scan'208";a="111062406" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 16 Apr 2021 01:41:05 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Apr 2021 01:41:06 -0700 Received: from mchp-dev-shegelun.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Fri, 16 Apr 2021 01:41:03 -0700 From: Steen Hegelund To: Philipp Zabel , Rob Herring CC: Steen Hegelund , Andrew Lunn , Microchip Linux Driver Support , Alexandre Belloni , Gregory Clement , , , Subject: [PATCH v9 3/3] arm64: dts: reset: add microchip sparx5 switch reset driver Date: Fri, 16 Apr 2021 10:40:54 +0200 Message-ID: <20210416084054.2922327-4-steen.hegelund@microchip.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210416084054.2922327-1-steen.hegelund@microchip.com> References: <20210416084054.2922327-1-steen.hegelund@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210416_014107_174458_ABD2D5C2 X-CRM114-Status: GOOD ( 10.71 ) 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 provides reset driver support for the Microchip Sparx5 PCB134 and PCB135 reference boards. The Sparx5 Switch will no longer use the Ocelot Chip Reset Driver (with the compatible string "microchip,sparx5-chip-reset"), but use a separate driver that exposes a reset controller interface and has the compatiple string "microchip,sparx5-switch-reset". Eventually the Sparx5 reset support will be removed from the Ocelot chip reset driver. Signed-off-by: Steen Hegelund Reviewed-by: Alexandre Belloni --- arch/arm64/boot/dts/microchip/sparx5.dtsi | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/microchip/sparx5.dtsi b/arch/arm64/boot/dts/microchip/sparx5.dtsi index 380281f312d8..dc3ada5cf9fc 100644 --- a/arch/arm64/boot/dts/microchip/sparx5.dtsi +++ b/arch/arm64/boot/dts/microchip/sparx5.dtsi @@ -132,9 +132,12 @@ mux: mux-controller { }; }; - reset@611010008 { - compatible = "microchip,sparx5-chip-reset"; + reset: reset-controller@611010008 { + compatible = "microchip,sparx5-switch-reset"; reg = <0x6 0x11010008 0x4>; + reg-names = "gcb"; + #reset-cells = <1>; + cpu-syscon = <&cpu_ctrl>; }; uart0: serial@600100000 {