From patchwork Mon Oct 18 09:15:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 12565435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C195C433EF for ; Mon, 18 Oct 2021 09:16:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 EA6196126A for ; Mon, 18 Oct 2021 09:16:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EA6196126A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=m4k0B63LFKWHgoggYPQQPJTLm9unsA5PztCwnNzl0EM=; b=Y7SrKIm0TR4BGz wB0L3CJYOVcGqXqUZSrk7oj5k8v5tE0vRP2cEfUihrrh2nxbi6WDlhS8RqTRcwtjMVIFzwesXgxWY 0X/85RR7t2jhCdjP/2mgAXqWBJcxXdaXWHcNVc1q7lyeq3E5J/IeQaiCFDLxb0meGBon0MoUUV2xq 6lSfGLfiKBOI/UBN0MwL1JJsz3eSjC9Cw1nssMFO/d9DBi9TVKAvOYv02ZBdBh0YvcenmAnzk/fM9 fNme7cKKrNNkSbLulXUNeARDkOAZ0yYnYQkQmKt43Ifqh1LnGl7ovkwEIdtF5DEMdISGTCYvhP6Jp Kax612rI6tTjJ2TC8Xxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcOjR-00ElFP-ET; Mon, 18 Oct 2021 09:14:57 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcOjB-00ElAs-Ip for linux-arm-kernel@lists.infradead.org; Mon, 18 Oct 2021 09:14:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1634548481; x=1666084481; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KF9bcBS1aN5J5YJFqNrlEjHZxvMOq6zrEhAbR5BXkug=; b=b9YsGiGl7cTg9On/zm/yl2567t9H1lJ6T3m4cK4dCMXM5kRuIyoBV3bh GYlhSB4EBVse2kZvwXyZ6z44MQufRSPPNvrraW2A3h9015ILLN4AupLbB 6a4Uyl0MWMX5vOAa5piMZJY/3SVHPkfLdfP3UywO8RfH0jpkcoAsFa8hO zitnrG408zzonsaE/xdBms4Y7taMrkO1ML7GiVkajU3cRcYKvE5MAQYgi 656fEcls1xgBEoledXG/xX3gEAeQpJoSYnk4f8EKzlXawhKSWH7P0biHj bhXkSxxkrn4C/yPWvRnsndCFmcIf57POONB2OPvBOGxCMoxZBqWRlGTAi g==; IronPort-SDR: TiHGsLzahI453AFoCVVf4zjmXSd7ZW6xlTU0Qa7nSgnXqvg9Pa3SSfOlSoeDd8U4S36TFthY4L r+G/y6cqkoY03KTXig+JbMrnYsK393twN/7sLt+Kj7NWN1MPNNadKweDfVr/rRQyPpZeMB9cA+ TeqhvDctnMGhr3jp4OVbg/ytZTKHV54FWdCQfpVvEBhdFhVrK4VQ1GE6KMK87tHr20NZ1V3+hA pV/2PPvtKBFY/JtDwDsLWxEWpzFx8a8DebMp6K0NuO0swbCxjF72BiGGoKfudRdLCS92LGkA7r XMXw/359Q+F3O1SxLiPOj0+M X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="133411108" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 18 Oct 2021 02:14:40 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 18 Oct 2021 02:14:40 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 18 Oct 2021 02:14:38 -0700 From: Horatiu Vultur To: , , , , , , , CC: Horatiu Vultur Subject: [PATCH v4 1/2] dt-bindings: reset: Add lan966x support Date: Mon, 18 Oct 2021 11:15:21 +0200 Message-ID: <20211018091522.1113510-2-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211018091522.1113510-1-horatiu.vultur@microchip.com> References: <20211018091522.1113510-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211018_021441_710938_89BE75B5 X-CRM114-Status: UNSURE ( 9.95 ) X-CRM114-Notice: Please train this message. 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 patch extends the existing file microchip,rst.yaml to support also the lan966x. For this is added only a new compatible string. Signed-off-by: Horatiu Vultur --- Documentation/devicetree/bindings/reset/microchip,rst.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/reset/microchip,rst.yaml b/Documentation/devicetree/bindings/reset/microchip,rst.yaml index 370579aeeca1..578bfa529b16 100644 --- a/Documentation/devicetree/bindings/reset/microchip,rst.yaml +++ b/Documentation/devicetree/bindings/reset/microchip,rst.yaml @@ -20,7 +20,9 @@ properties: pattern: "^reset-controller@[0-9a-f]+$" compatible: - const: microchip,sparx5-switch-reset + enum: + - microchip,sparx5-switch-reset + - microchip,lan966x-switch-reset reg: items: From patchwork Mon Oct 18 09:15:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 12565437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37FB1C433EF for ; Mon, 18 Oct 2021 09:16:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 07253610A6 for ; Mon, 18 Oct 2021 09:16:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 07253610A6 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=dAfemrXHmp6N0aMRKgf/E5CEGwbR54WQSdZlpdr6GdQ=; b=0RNHQS7u/kF+gA 1MQPYGzK4fklzjKjTBvTRgSqbOKCc2QUe77s18BqBXBVw6lUSJqYDbw5UpuXVIkyypbHLAa9/IZJg 6UvCKChfTaXcP0UbiIixOegnjlFvHoEYSDKM+q7zBzVhB2b5cr/O/QnkOeSwnajpd0Hn1F0h0927I BdHSf5vfmqT4c2vRUVR5RN8mqj1olBxQFeMq+xTNHD+F+dHD09jAdLgA7ybapujxesHT4mjMGZtnM CGBaZjli3CEAssZA6V/YCVwRFshxW6JbkEm1SFHZ4DBGzrAFnepyuD+zj291Z+Dh1B4GgOYjg1W6h Q2kSgx8P+O+wwN6QtmJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcOje-00ElKp-AQ; Mon, 18 Oct 2021 09:15:10 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcOjE-00ElBv-2m for linux-arm-kernel@lists.infradead.org; Mon, 18 Oct 2021 09:14:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1634548483; x=1666084483; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+GOBKGZE8qV030U5WlyM99ORTXZIFIqw7hbODktZ6b4=; b=Ro57GLv7L4mUQKs1cTKdiwBRY7vEEA53PEtSYXor0bKkxTJ08M5qg9R7 qZHCixjmRO10rHTen+ccR3bIYSbD2k++3ycg6Bw7dFhk+OPgm4B11hFdi oofF4jr/RZpoY3kPsN3nWHwCcONMTG/WXQiVghmDEcnKOeAC/W7v8hLZn CsGJgfWnz6BQlv29x/KLQyYniZoqqb/vCYOD+8WGOGConDceqvJe1Ljwe 7V5DEwjJyDCV0g2360XnN/EELCC/B7o9lAjHO29l8ey9fsI/z1cQ43hCg X4fqsoEK3hWZ28JNAGP0jfaPk8fUMDo4nMwN868MFmnI85NZBxlVE3sNZ g==; IronPort-SDR: JqDL+hl7PNWSAe1qF7MA55FkX+1IvFQ5Tz2mDf89jfsEIERx6uVpRIwBVeP4rWCECyUF+D3OKk NGEYwzXyWdqu3dZ86RxWkDMX99kDYwV1U4MgEoYFCIkERoKH6wa5cghOmIAQaaOTvOHgoOEn9S 7D1sUEKcuyKL67w91MCj1Po4JvXPDrxBgQ+7VAApu0XAjem0lG+l4tob1lpk8SfwDDfHE2RVbf yfPGkE9yFKLw1FB5XoiIKXg05Jjuy1Fnj+xWo/acd7hI4plalhqQUVectVaqy2Nkji1qAcfViC yVwQkL12XXUrilyf3cxqDfqq X-IronPort-AV: E=Sophos;i="5.85,381,1624345200"; d="scan'208";a="133411118" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 18 Oct 2021 02:14:43 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 18 Oct 2021 02:14:42 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 18 Oct 2021 02:14:40 -0700 From: Horatiu Vultur To: , , , , , , , CC: Horatiu Vultur , Andrew Lunn Subject: [PATCH v4 2/2] reset: mchp: sparx5: Extend support for lan966x Date: Mon, 18 Oct 2021 11:15:22 +0200 Message-ID: <20211018091522.1113510-3-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211018091522.1113510-1-horatiu.vultur@microchip.com> References: <20211018091522.1113510-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211018_021444_239931_7D88356E X-CRM114-Status: GOOD ( 16.72 ) 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 patch extends sparx5 driver to support also the lan966x. The process to reset the switch is the same only it has different offsets. Therefore make the driver more generic and add support for lan966x. Signed-off-by: Horatiu Vultur Reviewed-by: Andrew Lunn Reviewed-by: Philipp Zabel Reviewed-by: Steen Hegelund --- drivers/reset/Kconfig | 2 +- drivers/reset/reset-microchip-sparx5.c | 40 ++++++++++++++++++++------ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index be799a5abf8a..36ce6c8bcf1e 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -116,7 +116,7 @@ config RESET_LPC18XX config RESET_MCHP_SPARX5 bool "Microchip Sparx5 reset driver" - depends on ARCH_SPARX5 || COMPILE_TEST + depends on ARCH_SPARX5 || SOC_LAN966 || COMPILE_TEST default y if SPARX5_SWITCH select MFD_SYSCON help diff --git a/drivers/reset/reset-microchip-sparx5.c b/drivers/reset/reset-microchip-sparx5.c index f01e7db8e83b..00b612a0effa 100644 --- a/drivers/reset/reset-microchip-sparx5.c +++ b/drivers/reset/reset-microchip-sparx5.c @@ -13,15 +13,18 @@ #include #include -#define PROTECT_REG 0x84 -#define PROTECT_BIT BIT(10) -#define SOFT_RESET_REG 0x00 -#define SOFT_RESET_BIT BIT(1) +struct reset_props { + u32 protect_reg; + u32 protect_bit; + u32 reset_reg; + u32 reset_bit; +}; struct mchp_reset_context { struct regmap *cpu_ctrl; struct regmap *gcb_ctrl; struct reset_controller_dev rcdev; + const struct reset_props *props; }; static struct regmap_config sparx5_reset_regmap_config = { @@ -38,14 +41,16 @@ static int sparx5_switch_reset(struct reset_controller_dev *rcdev, u32 val; /* Make sure the core is PROTECTED from reset */ - regmap_update_bits(ctx->cpu_ctrl, PROTECT_REG, PROTECT_BIT, PROTECT_BIT); + regmap_update_bits(ctx->cpu_ctrl, ctx->props->protect_reg, + ctx->props->protect_bit, ctx->props->protect_bit); /* Start soft reset */ - regmap_write(ctx->gcb_ctrl, SOFT_RESET_REG, SOFT_RESET_BIT); + regmap_write(ctx->gcb_ctrl, ctx->props->reset_reg, + ctx->props->reset_bit); /* Wait for soft reset done */ - return regmap_read_poll_timeout(ctx->gcb_ctrl, SOFT_RESET_REG, val, - (val & SOFT_RESET_BIT) == 0, + return regmap_read_poll_timeout(ctx->gcb_ctrl, ctx->props->reset_reg, val, + (val & ctx->props->reset_bit) == 0, 1, 100); } @@ -115,13 +120,32 @@ static int mchp_sparx5_reset_probe(struct platform_device *pdev) ctx->rcdev.nr_resets = 1; ctx->rcdev.ops = &sparx5_reset_ops; ctx->rcdev.of_node = dn; + ctx->props = device_get_match_data(&pdev->dev); return devm_reset_controller_register(&pdev->dev, &ctx->rcdev); } +static const struct reset_props reset_props_sparx5 = { + .protect_reg = 0x84, + .protect_bit = BIT(10), + .reset_reg = 0x0, + .reset_bit = BIT(1), +}; + +static const struct reset_props reset_props_lan966x = { + .protect_reg = 0x88, + .protect_bit = BIT(5), + .reset_reg = 0x0, + .reset_bit = BIT(1), +}; + static const struct of_device_id mchp_sparx5_reset_of_match[] = { { .compatible = "microchip,sparx5-switch-reset", + .data = &reset_props_sparx5, + }, { + .compatible = "microchip,lan966x-switch-reset", + .data = &reset_props_lan966x, }, { } };