From patchwork Fri Oct 6 00:33:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 149065 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6106:b0:13f:353d:d1ed with SMTP id rz6csp713036rwb; Thu, 5 Oct 2023 17:34:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEKj8xfMAjiQbcD5/3H/oxJXNxsqOQfU4JGAMzj5tZXIJ0HDRtJTANwoxUijhx2UGC6BPH X-Received: by 2002:a17:90b:4b87:b0:268:f45:c10a with SMTP id lr7-20020a17090b4b8700b002680f45c10amr6748754pjb.26.1696552484216; Thu, 05 Oct 2023 17:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696552484; cv=none; d=google.com; s=arc-20160816; b=F8oL1en7KpvuvWeYEfJbZkQC0dnITXahxbw2PFCNp5IaC5XIOy9nGMTciawOUUvM9V 0EvseE4IgELWupraY9IUu03fSFPtBJV0+5UjzBNmgXOfTnyBs6flvO5SMmF8lFd9MTuv cW84LLOjGJf3J973iIeTX4JZ1ihZzhH0EjLAabdFHlmGtV23Eom7E44MVG8R42zkMihK xLU7c47K1sVg0V20lKItdgGdGbLVp3dgdTb5dU5Sz2FJPmSJLSvAQm1MGwf8vFqpKq4h EKiEiRuEoePNzMKdabEWJYprw4r/g6V5WFsX6ORBI/S1M/2G0MJhzEUuFbTTtTug29/6 s0qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z5Ulpz8hd9vRm5+9CQamJ7SN/jCUcsm99YX0+edYC84=; fh=HVwtvmm9c22OJQLCUZL2inZSf9v419gurWyvDvs4c/s=; b=kCJXyVHQLmnoG2O6im/ddPjNcskmMeGwHAIO0Xrz53EY6B3MstXZ8P4/aEmQb+TVxh GzCQiqbX6eSsEZaH38ei4qytdZW6wtYAFscqc7b4OrHEW/dlYq+6T5IilxCplM38uAjY g7brgPFalE+tU8q+20gFmnyeFfxEKlZTVIfULQHH+zFiUMcVeI7ZEPj2VnoQjS5Gdre9 QrLkaKfMUzQrx6466lT9mdVGpt+XN0Uum+Qcx9GQD/uSU0HkozqQx7HJQ0OE1BCDytMW BK9d1hmBaVTg7d1wknCINLULQVkdTvH4b4g9h5+KnvNr4ZaHGkKJwEumchvh6LHLKANZ h7aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=flpVkiNZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id z8-20020a1709027e8800b001c6138350b4si402955pla.431.2023.10.05.17.34.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 17:34:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=flpVkiNZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BF538808598F; Thu, 5 Oct 2023 17:34:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbjJFAdk (ORCPT + 18 others); Thu, 5 Oct 2023 20:33:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjJFAdf (ORCPT ); Thu, 5 Oct 2023 20:33:35 -0400 Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [IPv6:2001:df5:b000:5::4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE74BED for ; Thu, 5 Oct 2023 17:33:31 -0700 (PDT) Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id A32C72C0596; Fri, 6 Oct 2023 13:33:28 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1696552408; bh=z5Ulpz8hd9vRm5+9CQamJ7SN/jCUcsm99YX0+edYC84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=flpVkiNZ2Mbuwhghchke+/kIOzBtei53ZV196V1GjIMuz+Brr+eK/we8msd10s/sB QEGujQTkOxI/0baKZaukM1XkT047fXn9Aautey56HH8EtlXaVoApT1KzOyosvNq1LG iFljC59C8fme9o54MXLY9warFsGSZ7LoZy/LMyF0jA/KrLMHyDCdTBNBlup0weel5r RfB1DthM8L6Ibwgkm3uVDJGZJ3bCbdljjtP7pDMXQKSu89GD2nVNtjVVm/G/9R27aG qoeieHh4qQV0jZDTULljMR/bLFCT0yOCsrlAOUh9lUDud0u/Gh0FQCpD15LKW17QFG kUMgYHrVUHXnQ== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Fri, 06 Oct 2023 13:33:28 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id 586D213EE4D; Fri, 6 Oct 2023 13:33:28 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 560A92804C0; Fri, 6 Oct 2023 13:33:28 +1300 (NZDT) From: Chris Packham To: gregory.clement@bootlin.com, andi.shyti@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, pierre.gondois@arm.com Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH v2 1/3] dt-bindings: i2c: mv64xxx: update bindings for unstuck register Date: Fri, 6 Oct 2023 13:33:19 +1300 Message-ID: <20231006003321.2100016-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231006003321.2100016-1-chris.packham@alliedtelesis.co.nz> References: <20231006003321.2100016-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=Vf2Jw2h9 c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=bhdUkHdE2iEA:10 a=XYAwZIGsAAAA:8 a=b5Pq3k1ZBCuUTZ-Yr4IA:9 a=E8ToXWR_bxluHZ7gmE-Z:22 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 05 Oct 2023 17:34:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778964217451117571 X-GMAIL-MSGID: 1778964217451117571 Some newer Marvell SoCs support an "unstuck" function for I2C bus recovery. This is an alternative to the generic GPIO based recovery that the older SoCs use. The unstuck register falls outside of the usual address block for the I2C controller so requires an additional cell in the register property. This is optional and does not need to be supplied. Signed-off-by: Chris Packham Acked-by: Conor Dooley --- Notes: Changes in v2: - Collect ack from Conor .../devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml b/Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml index 984fc1ed3ec6..461d1c9ee3f7 100644 --- a/Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml +++ b/Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml @@ -45,7 +45,10 @@ properties: auto-detects this and sets it appropriately. reg: - maxItems: 1 + minItems: 1 + items: + - description: I2C controller registers + - description: I2C unstuck register interrupts: maxItems: 1 From patchwork Fri Oct 6 00:33:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 149064 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6106:b0:13f:353d:d1ed with SMTP id rz6csp712776rwb; Thu, 5 Oct 2023 17:34:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoYqD3PlkX0+jT39tIYVvdis0866rZaNSif5297G3vMyE8FWabDDklX6ypUtl/nkYvp9o9 X-Received: by 2002:a17:90a:530e:b0:274:24e2:ae6d with SMTP id x14-20020a17090a530e00b0027424e2ae6dmr6505276pjh.0.1696552442748; Thu, 05 Oct 2023 17:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696552442; cv=none; d=google.com; s=arc-20160816; b=nLx+/8+Bzkafv557mmIqcVZ72ovE+K4Wbe8grPXBqh5hg8cZtpONI4Jcu69V4Zqx7m o29lyVXWHfzQXFdjELx9pM1WR8c+ue4YkJ60hjftc48qVQqBXVpbSf8MufpxArYUd5Ho 4uHM7EcsnkKKiB8E+06y/6+6m9DIXvUUTkClQqUzPjSDUzcl/GqXXh+2ursXVaeZQ6Vb WU060X0bcLzDM59HzqaGtw4xUufS9wb0T8/u8barOR6x5/W66u0GuaSZ2BjGs9ZSIzdy e9AWgb8FNJvhDw1tAjQ9uPgmoyglMKYEQyMmSfBoWXI8egu2fXE395lI7Sv3qd0fSdDD hIWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ttASz5PFIq45SB63T27urLBr0KsSG9UVkEiGsDKUa0w=; fh=HVwtvmm9c22OJQLCUZL2inZSf9v419gurWyvDvs4c/s=; b=GOPRAlGYoQ1V7ji3DBLU0NqjBPyS/2eHxJYTpLrhIo8lj9IhiLlhNDA4cMmkdbkA3u Cyu2stR3in8lDijaZsbM/LK4AULw2Qo9QK4ki1hVZ8M29yeBBuelUJcd/KfvN5obHXXR SscGARumo8tR4eIxmVt7GxgvsyPVtReJje024cXpv3KYQGkhp13lJEwrzO2iQvrTikeq nesKVcvmP8Izee+0K9vcGvCElgbjDLhBaAPPcO2kvwT3AG6WQg7RMCXWSn0fjKtOdkax /b6Ux6XHMUNNDrLN0jXbMmA5BD2SLbEx8f0FloOTTUeHRchibixrpGh4/S3eMI6U9G6E dk5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=hKPxUN2e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id t9-20020a17090a1c8900b0027927d7c0ebsi2658057pjt.45.2023.10.05.17.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 17:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=hKPxUN2e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 95EE380ECFB7; Thu, 5 Oct 2023 17:33:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229574AbjJFAdg (ORCPT + 18 others); Thu, 5 Oct 2023 20:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjJFAde (ORCPT ); Thu, 5 Oct 2023 20:33:34 -0400 Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [202.36.163.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A01DE for ; Thu, 5 Oct 2023 17:33:30 -0700 (PDT) Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 967B52C043C; Fri, 6 Oct 2023 13:33:28 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1696552408; bh=ttASz5PFIq45SB63T27urLBr0KsSG9UVkEiGsDKUa0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hKPxUN2ex/Y4eOieQZTMuQHLBMXtMUO8ORdjwqwPX5BZbjKwjkKAMWLyOxj8AlJiH RowRJanGmiQ4O/avQFu+UIdCAU8QPvTHARy7dnOwyX1mtTBvAPMNbNNO56swYbgVOy G5+ZITtpK6ZJwxUggBoxzsIwYHpmraLLadyf085eKuCLXv2DFpJt7Ji34r8WOo+f3D tyK8GYF8cfEt4EF5OsUe0eS2vkRvI/CWEpqSVaOSc7XeafYtxwP3tp4BpYOWQBIpZi wjl20mN4ePNgxFUTL89Byqe9dh3Gc/7myij3YBT7cKLRqsEfaJCwHIj7gsjmNIhorm MEN2qSV1lbrnw== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Fri, 06 Oct 2023 13:33:28 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id 5A7BA13EE85; Fri, 6 Oct 2023 13:33:28 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 59C3028084D; Fri, 6 Oct 2023 13:33:28 +1300 (NZDT) From: Chris Packham To: gregory.clement@bootlin.com, andi.shyti@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, pierre.gondois@arm.com Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH v2 2/3] arm64: dts: marvell: AC5: use I2C unstuck function Date: Fri, 6 Oct 2023 13:33:20 +1300 Message-ID: <20231006003321.2100016-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231006003321.2100016-1-chris.packham@alliedtelesis.co.nz> References: <20231006003321.2100016-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=Vf2Jw2h9 c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=bhdUkHdE2iEA:10 a=Jm_8IDygZZvVWM1ZSnEA:9 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 17:33:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778964173838495577 X-GMAIL-MSGID: 1778964173838495577 The AC5 SoC supports using a controller based I2C unstuck function for recovery. Use this instead of the generic GPIO recovery. Signed-off-by: Chris Packham --- arch/arm64/boot/dts/marvell/ac5-98dx25xx.dtsi | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/arm64/boot/dts/marvell/ac5-98dx25xx.dtsi b/arch/arm64/boot/dts/marvell/ac5-98dx25xx.dtsi index c9ce1010c415..e52d3c3496d5 100644 --- a/arch/arm64/boot/dts/marvell/ac5-98dx25xx.dtsi +++ b/arch/arm64/boot/dts/marvell/ac5-98dx25xx.dtsi @@ -137,7 +137,7 @@ mdio: mdio@22004 { i2c0: i2c@11000{ compatible = "marvell,mv78230-i2c"; - reg = <0x11000 0x20>; + reg = <0x11000 0x20>, <0x110a0 0x4>; #address-cells = <1>; #size-cells = <0>; @@ -146,17 +146,14 @@ i2c0: i2c@11000{ interrupts = ; clock-frequency=<100000>; - pinctrl-names = "default", "gpio"; + pinctrl-names = "default"; pinctrl-0 = <&i2c0_pins>; - pinctrl-1 = <&i2c0_gpio>; - scl-gpios = <&gpio0 26 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - sda-gpios = <&gpio0 27 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; status = "disabled"; }; i2c1: i2c@11100{ compatible = "marvell,mv78230-i2c"; - reg = <0x11100 0x20>; + reg = <0x11100 0x20>, <0x110a4 0x4>; #address-cells = <1>; #size-cells = <0>; @@ -165,11 +162,8 @@ i2c1: i2c@11100{ interrupts = ; clock-frequency=<100000>; - pinctrl-names = "default", "gpio"; + pinctrl-names = "default"; pinctrl-0 = <&i2c1_pins>; - pinctrl-1 = <&i2c1_gpio>; - scl-gpios = <&gpio0 20 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; - sda-gpios = <&gpio0 21 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; status = "disabled"; }; From patchwork Fri Oct 6 00:33:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 149066 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:6106:b0:13f:353d:d1ed with SMTP id rz6csp713054rwb; Thu, 5 Oct 2023 17:34:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIQ7OvZwY2gyIUrYLFPtbkqGvXtOvP8IpMrVZB+HLDJ55kDscNbOIPzH4OuxJiLqvDHgVG X-Received: by 2002:a05:6358:281e:b0:145:63e6:8710 with SMTP id k30-20020a056358281e00b0014563e68710mr8122453rwb.23.1696552487700; Thu, 05 Oct 2023 17:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696552487; cv=none; d=google.com; s=arc-20160816; b=tvedBjhpnjn/drs+R0+nHAvXl0kvxURbT+OFiOF6tdbeFJudCF/km4hL24SAku0PPc JUrfGhS3nf5/PwFXyW466gEoVcTDD40F30h2ie7iP6B/0d+YkkTbUM9aFTWuC6ZcNXAr 2PASJqzepAVBMChAgvdUyrZTL4l5yPVnebK5rBPLPpjLlSEd/K8pOFJNUriqKfET2TG6 6uFf7erg7Gq4TQZK1IDEwoEB2k1N8pnurLaO34ND1pzcu90zzLioBi/20wEOf7YI0jio ggijLtLNIfgu0O1QQQjRcnnnMEVkKCx5EXsjx5F6HVPfKYY3smiU9j4FET9whK8clK15 w1Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lHHeZ3xMn0xmJJCVd5cBfeh7/yXUVz2SulVsbcP+n2E=; fh=HVwtvmm9c22OJQLCUZL2inZSf9v419gurWyvDvs4c/s=; b=EvWlO8JSKGcfagam2Vxys/Od+6gK5SBvE2siEKzXo84wlMP/wAdshzdRNsVRArhEeD n2g/rq8QgiS6rsSLCUTy/a++qUvSvZYafrm4ruF1lzF+G3rAFMD1T8Tt+x9XVcOUSBWB PQIaLnyR5TLKr30n+gyP1gHFkjkVg1gOVOTjlJSJZeG2b4pAyLYC9g7ZzrI0QXYWhMoK CoSXluB5GhSsocbqcPYl0k0wMgQBBxGiI/kYHl5ySeJwDei+93EkYgGhWLddXMFDOwh6 vXn16VsQOqNdR7XdFz1WAhO/Oi+k/X3NoiSZSvDUnux9T6QBEMGlnRder+Hg/Wth36K7 iRBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=fLDG8mdv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id bb19-20020a17090b009300b002748b96d88csi4675627pjb.179.2023.10.05.17.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 17:34:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail181024 header.b=fLDG8mdv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=alliedtelesis.co.nz Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4B21F8085993; Thu, 5 Oct 2023 17:34:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229608AbjJFAdm (ORCPT + 18 others); Thu, 5 Oct 2023 20:33:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjJFAdf (ORCPT ); Thu, 5 Oct 2023 20:33:35 -0400 Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [202.36.163.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19F27E7 for ; Thu, 5 Oct 2023 17:33:30 -0700 (PDT) Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id A5FD32C07F0; Fri, 6 Oct 2023 13:33:28 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1696552408; bh=lHHeZ3xMn0xmJJCVd5cBfeh7/yXUVz2SulVsbcP+n2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fLDG8mdvA0AvziNsAnaRIycCAJFWxZ6PvdCWqKy8SLFGliVRCbpN5NagUuogace29 ynNlIaKNk+EEwz7b/ljssCrHxMIys+ALvTUJxkmlv4cLc2Y2eHQp06b1+LK66nhi71 AOtJpSE7Qt9KV4mhf//JnmXNjlUuh30ERWHwu5EKRzr8j8Fbh6pj0dW3z7xkUI+KDe HeH19QGvM586/cSRPpVUwDwuTb2v50pxIl7vfB6v7vo/ZanHI924+JKUgdZUMv5lCj jecaU6bf+EIoY9hOPOTXc4CNWYPOWWdq95Rdb4CvQQSCAvNXR6y2iszDdD47j+iA2c Y8Y8SXEQ9Fzwg== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Fri, 06 Oct 2023 13:33:28 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id 5DDDE13EEA1; Fri, 6 Oct 2023 13:33:28 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 5CD46280790; Fri, 6 Oct 2023 13:33:28 +1300 (NZDT) From: Chris Packham To: gregory.clement@bootlin.com, andi.shyti@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, pierre.gondois@arm.com Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH v2 3/3] i2c: mv64xxx: add support for FSM based recovery Date: Fri, 6 Oct 2023 13:33:21 +1300 Message-ID: <20231006003321.2100016-4-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231006003321.2100016-1-chris.packham@alliedtelesis.co.nz> References: <20231006003321.2100016-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=Vf2Jw2h9 c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=bhdUkHdE2iEA:10 a=B8jpvDMl2VDXHxTB5w4A:9 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 05 Oct 2023 17:34:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778964221334564099 X-GMAIL-MSGID: 1778964221334564099 Some newer Marvell SoCs (AC5 and CN9130, possibly more) support a I2C unstuck function. This provides a recovery function as part of the FSM as an alternative to changing pinctrl modes and using the generic GPIO based recovery. Allow for using this by adding an optional resource to the platform data which contains the address of the I2C unstuck register for the I2C controller. Signed-off-by: Chris Packham --- Notes: Changes in v2: - shorted delay and timeout used with read_poll_timeout_atomic() - make use dev_dbg() for added messages - remove reference to "marvell,armada-8k-i2c" - I've elected to keep the behaviour that failing to ioremap the unstuck register (if supplied) is an error drivers/i2c/busses/i2c-mv64xxx.c | 68 ++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index fd8403b07fa6..efd28bbecf61 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -82,6 +83,13 @@ /* Bridge Status values */ #define MV64XXX_I2C_BRIDGE_STATUS_ERROR BIT(0) +/* Unstuck Register values */ +#define MV64XXX_I2C_UNSTUCK_TRIGGER BIT(0) +#define MV64XXX_I2C_UNSTUCK_ON_GOING BIT(1) +#define MV64XXX_I2C_UNSTUCK_ERROR BIT(2) +#define MV64XXX_I2C_UNSTUCK_COUNT(val) ((val & 0xf0) >> 4) +#define MV64XXX_I2C_UNSTUCK_INPROGRESS (MV64XXX_I2C_UNSTUCK_TRIGGER|MV64XXX_I2C_UNSTUCK_ON_GOING) + /* Driver states */ enum { MV64XXX_I2C_STATE_INVALID, @@ -126,6 +134,7 @@ struct mv64xxx_i2c_data { u32 aborting; u32 cntl_bits; void __iomem *reg_base; + void __iomem *unstuck_reg; struct mv64xxx_i2c_regs reg_offsets; u32 addr1; u32 addr2; @@ -735,6 +744,33 @@ mv64xxx_i2c_can_offload(struct mv64xxx_i2c_data *drv_data) return false; } +static int +mv64xxx_i2c_recover_bus(struct i2c_adapter *adap) +{ + struct mv64xxx_i2c_data *drv_data = i2c_get_adapdata(adap); + int ret; + u32 val; + + dev_dbg(&adap->dev, "Trying i2c bus recovery\n"); + writel(MV64XXX_I2C_UNSTUCK_TRIGGER, drv_data->unstuck_reg); + ret = readl_poll_timeout_atomic(drv_data->unstuck_reg, val, + !(val & MV64XXX_I2C_UNSTUCK_INPROGRESS), + 10, 1000); + if (ret) { + dev_err(&adap->dev, "recovery timeout\n"); + return ret; + } + + if (val & MV64XXX_I2C_UNSTUCK_ERROR) { + dev_err(&adap->dev, "recovery failed\n"); + return -EBUSY; + } + + dev_dbg(&adap->dev, "recovery complete after %d pulses\n", MV64XXX_I2C_UNSTUCK_COUNT(val)); + + return 0; +} + /* ***************************************************************************** * @@ -936,8 +972,21 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data, } #endif /* CONFIG_OF */ -static int mv64xxx_i2c_init_recovery_info(struct mv64xxx_i2c_data *drv_data, - struct device *dev) +static int mv64xxx_i2c_init_fsm_recovery_info(struct mv64xxx_i2c_data *drv_data, + struct device *dev) +{ + struct i2c_bus_recovery_info *rinfo = &drv_data->rinfo; + + dev_dbg(dev, "using FSM for recovery\n"); + rinfo->recover_bus = mv64xxx_i2c_recover_bus; + drv_data->adapter.bus_recovery_info = rinfo; + + return 0; + +} + +static int mv64xxx_i2c_init_gpio_recovery_info(struct mv64xxx_i2c_data *drv_data, + struct device *dev) { struct i2c_bus_recovery_info *rinfo = &drv_data->rinfo; @@ -986,6 +1035,7 @@ mv64xxx_i2c_probe(struct platform_device *pd) { struct mv64xxx_i2c_data *drv_data; struct mv64xxx_i2c_pdata *pdata = dev_get_platdata(&pd->dev); + struct resource *res; int rc; if ((!pdata && !pd->dev.of_node)) @@ -1000,6 +1050,14 @@ mv64xxx_i2c_probe(struct platform_device *pd) if (IS_ERR(drv_data->reg_base)) return PTR_ERR(drv_data->reg_base); + /* optional unstuck support */ + res = platform_get_resource(pd, IORESOURCE_MEM, 1); + if (res) { + drv_data->unstuck_reg = devm_ioremap_resource(&pd->dev, res); + if (IS_ERR(drv_data->unstuck_reg)) + return PTR_ERR(drv_data->unstuck_reg); + } + strscpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", sizeof(drv_data->adapter.name)); @@ -1037,7 +1095,11 @@ mv64xxx_i2c_probe(struct platform_device *pd) return rc; } - rc = mv64xxx_i2c_init_recovery_info(drv_data, &pd->dev); + if (drv_data->unstuck_reg) + rc = mv64xxx_i2c_init_fsm_recovery_info(drv_data, &pd->dev); + else + rc = mv64xxx_i2c_init_gpio_recovery_info(drv_data, &pd->dev); + if (rc == -EPROBE_DEFER) return rc;