From patchwork Tue May 11 21:20:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 434512 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 C2B6CC433ED for ; Tue, 11 May 2021 21:21:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87532611BD for ; Tue, 11 May 2021 21:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbhEKVWG (ORCPT ); Tue, 11 May 2021 17:22:06 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:48237 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbhEKVWF (ORCPT ); Tue, 11 May 2021 17:22:05 -0400 Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 7DB6084488; Wed, 12 May 2021 09:20:55 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1620768055; bh=BgAjOuGtonx7aZqvvw9jeRLkSYu+EAFqQXChSZxwKRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xj2pZaksDcmF5nI3+ChJF7VrjVxJNE8KSyWLOMbvetvNW3h7l1EjBiPKSaPNNwIck 3pVUVrpMaE5Bez/OgB7Px00CKfmyywghmiXIjKj32b3gSfd3WRNOzwpZ26s3zOqIFm idgLL4siJTbluVNDaNyvVhnsYkUrz+byon+g1lm/QcHLvQWjQbyUdGcE1/kTPV5TgD R+PrMNOinMZLbpXry3Bx592VG6p4lcUyCt5M5uG78iNeIG1Y06bnZb+/Z4zBhgAJDM IGRs/P+w00lnsCkN0ZODPbYSu9EA0tiyq8wWvQK72JkIXQqbPAiFl2dLjcdorCeSL0 lq5x8joDexfkQ== 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 ; Wed, 12 May 2021 09:20:55 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by pat.atlnz.lc (Postfix) with ESMTP id 5CF9C13ECA6; Wed, 12 May 2021 09:20:55 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 59F78283A61; Wed, 12 May 2021 09:20:55 +1200 (NZST) From: Chris Packham To: wsa@kernel.org, andriy.shevchenko@linux.intel.com, andy.shevchenko@gmail.com, robh+dt@kernel.org, mpe@ellerman.id.au Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH v3 1/4] dt-bindings: i2c: mpc: Add fsl, i2c-erratum-a004447 flag Date: Wed, 12 May 2021 09:20:49 +1200 Message-Id: <20210511212052.27242-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511212052.27242-1-chris.packham@alliedtelesis.co.nz> References: <20210511212052.27242-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=K6Jc4BeI c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=5FLXtPjwQuUA:10 a=VwQbUJbxAAAA:8 a=Qb3TSHUbMK0G8g0bADAA:9 a=AjGcO6oz07-iQ99wixmX:22 X-SEG-SpamProfiler-Score: 0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Document the fsl,i2c-erratum-a004447 flag which indicates the presence of an i2c erratum on some QorIQ SoCs. Signed-off-by: Chris Packham Acked-by: Rob Herring --- Notes: Changes in v3: - Add Ack from Rob Documentation/devicetree/bindings/i2c/i2c-mpc.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mpc.yaml b/Documentation/devicetree/bindings/i2c/i2c-mpc.yaml index 7b553d559c83..98c6fcf7bf26 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mpc.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-mpc.yaml @@ -46,6 +46,13 @@ properties: description: | I2C bus timeout in microseconds + fsl,i2c-erratum-a004447: + $ref: /schemas/types.yaml#/definitions/flag + description: | + Indicates the presence of QorIQ erratum A-004447, which + says that the standard i2c recovery scheme mechanism does + not work and an alternate implementation is needed. + required: - compatible - reg From patchwork Tue May 11 21:20:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 435932 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 964B4C43462 for ; Tue, 11 May 2021 21:21:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 606436191C for ; Tue, 11 May 2021 21:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbhEKVWH (ORCPT ); Tue, 11 May 2021 17:22:07 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:48243 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbhEKVWF (ORCPT ); Tue, 11 May 2021 17:22:05 -0400 Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id A15F4891AD; Wed, 12 May 2021 09:20:55 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1620768055; bh=NuxtmiB9vBtPJ7+lr2Jkbk+llLCBqpimoEWh66Aw+ZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fTiG4o8jYm31vmd7bCG8oEeTmrJtwWArdupFwEcUK21zMu/yU/AUT4WYTNaYHUesz WadDVszJW83O1laIrGmQqbwxw/QNHgRPLH7wMK9V1JFh6Q6+EWjAOkU9CO8WAaRaEn LRqfsksu5c8mVcMAVE9h6o2bwqF2XzLkpVVdCHlciS25SlBDBP3VfQOZt6xSP6QbT1 g8lqwBj3xvpcPejoB9RVIqzjATUuy3m+UMf0n4Bag1/tSBZigA3U922X5QufnCPAv/ LUhAzt3Ke+iJt1HBeLagEKnAhu8uk+oZ4dXnxK8ARZ0VFt8ZivdOh5iDSVFRCzIHbb fP0+1Q8mOmt6A== 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 ; Wed, 12 May 2021 09:20:55 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by pat.atlnz.lc (Postfix) with ESMTP id 8079013ECA6; Wed, 12 May 2021 09:20:55 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 7D10D283A61; Wed, 12 May 2021 09:20:55 +1200 (NZST) From: Chris Packham To: wsa@kernel.org, andriy.shevchenko@linux.intel.com, andy.shevchenko@gmail.com, robh+dt@kernel.org, mpe@ellerman.id.au Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Chris Packham , Benjamin Herrenschmidt , Paul Mackerras Subject: [PATCH v3 2/4] powerpc/fsl: set fsl, i2c-erratum-a004447 flag for P2041 i2c controllers Date: Wed, 12 May 2021 09:20:50 +1200 Message-Id: <20210511212052.27242-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511212052.27242-1-chris.packham@alliedtelesis.co.nz> References: <20210511212052.27242-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=K6Jc4BeI c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=5FLXtPjwQuUA:10 a=CCyhWkR5sz16QRgSDIcA:9 X-SEG-SpamProfiler-Score: 0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The i2c controllers on the P2040/P2041 have an erratum where the documented scheme for i2c bus recovery will not work (A-004447). A different mechanism is needed which is documented in the P2040 Chip Errata Rev Q (latest available at the time of writing). Signed-off-by: Chris Packham Acked-by: Michael Ellerman --- arch/powerpc/boot/dts/fsl/p2041si-post.dtsi | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi b/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi index 872e4485dc3f..ddc018d42252 100644 --- a/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi +++ b/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi @@ -371,7 +371,23 @@ sdhc@114000 { }; /include/ "qoriq-i2c-0.dtsi" + i2c@118000 { + fsl,i2c-erratum-a004447; + }; + + i2c@118100 { + fsl,i2c-erratum-a004447; + }; + /include/ "qoriq-i2c-1.dtsi" + i2c@119000 { + fsl,i2c-erratum-a004447; + }; + + i2c@119100 { + fsl,i2c-erratum-a004447; + }; + /include/ "qoriq-duart-0.dtsi" /include/ "qoriq-duart-1.dtsi" /include/ "qoriq-gpio-0.dtsi" From patchwork Tue May 11 21:20:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 435933 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 66313C43461 for ; Tue, 11 May 2021 21:21:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 311E96191A for ; Tue, 11 May 2021 21:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229996AbhEKVWG (ORCPT ); Tue, 11 May 2021 17:22:06 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:48252 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbhEKVWF (ORCPT ); Tue, 11 May 2021 17:22:05 -0400 Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id C4BA7891B0; Wed, 12 May 2021 09:20:55 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1620768055; bh=kJIwm8UvSDRhwl42HtUfLnsYFX5gkJOtab2NNv/0grU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ilrfs2fIDEof0cYUZs5FsVaRBplnXwiE9vyFldfT95ZDbs/AqZohXJxy0Men/294S lXdmR2icabZCuwro0f5X6RFLtXHI/2oT5TZT9fmgcW4X9iO+rWTtU84gu7vDzcmqrl Y0Tl9vkDgf3L9aKfPGMFMuxfbvs/GmKyi6wOUtyFC28qmhzMhkC9ZnQznt4mKOUAtz XVRe89hw9W9JCe1sqzcKPoNqBm8G2h6vWAu6BusFbE9LMf9YRWut7TCq1W3N+riyvD Q2RlqQ6OloX5WqR5szZQFue1OzFDaGrEMq0v975zkzCjqUc0C3OrjboWrfscaxI4JS FTtglr9+zokqA== 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 ; Wed, 12 May 2021 09:20:55 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by pat.atlnz.lc (Postfix) with ESMTP id A300813ECA6; Wed, 12 May 2021 09:20:55 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 9FEBE283A61; Wed, 12 May 2021 09:20:55 +1200 (NZST) From: Chris Packham To: wsa@kernel.org, andriy.shevchenko@linux.intel.com, andy.shevchenko@gmail.com, robh+dt@kernel.org, mpe@ellerman.id.au Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Chris Packham , Benjamin Herrenschmidt , Paul Mackerras Subject: [PATCH v3 3/4] powerpc/fsl: set fsl, i2c-erratum-a004447 flag for P1010 i2c controllers Date: Wed, 12 May 2021 09:20:51 +1200 Message-Id: <20210511212052.27242-4-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511212052.27242-1-chris.packham@alliedtelesis.co.nz> References: <20210511212052.27242-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=K6Jc4BeI c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=5FLXtPjwQuUA:10 a=1ZVZaj5zE4ULg8TjvlMA:9 X-SEG-SpamProfiler-Score: 0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The i2c controllers on the P1010 have an erratum where the documented scheme for i2c bus recovery will not work (A-004447). A different mechanism is needed which is documented in the P1010 Chip Errata Rev L. Signed-off-by: Chris Packham --- Notes: Changes in v3: - New arch/powerpc/boot/dts/fsl/p1010si-post.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi index c2717f31925a..ccda0a91abf0 100644 --- a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi +++ b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi @@ -122,7 +122,15 @@ memory-controller@2000 { }; /include/ "pq3-i2c-0.dtsi" + i2c@3000 { + fsl,i2c-erratum-a004447; + }; + /include/ "pq3-i2c-1.dtsi" + i2c@3100 { + fsl,i2c-erratum-a004447; + }; + /include/ "pq3-duart-0.dtsi" /include/ "pq3-espi-0.dtsi" spi0: spi@7000 { From patchwork Tue May 11 21:20:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 434510 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, 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 899CCC43470 for ; Tue, 11 May 2021 21:21:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66AA96190A for ; Tue, 11 May 2021 21:21:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbhEKVWH (ORCPT ); Tue, 11 May 2021 17:22:07 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:48270 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbhEKVWG (ORCPT ); Tue, 11 May 2021 17:22:06 -0400 Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 2114C891B1; Wed, 12 May 2021 09:20:56 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1620768056; bh=Gbh5Hq8cFLe7sHg6877yUHfJTLnJ0lbE1WXVQxvk2xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xr5qNTRTGRHkFh3fc957QOCSy/4nCoQSB+iVpRvPwT6yFv/FE2F9jz6Vmh8ltlnUG EoM3XCySGX6wacChM5VrRN8H6uCg9TpHHYUzztAqzAklppPPNz3zuwOeF+i3bsanpo q+9hnB5h0twX2yAToLaKRZELCw+M8spxOSBNjTXChLr+H1STaQs9gEpFCHQDB9gjiv qwHkTVh9NfK3KDOqffEvQl+clB91uQebwXepT8WOpGXvAzWMIaFSHCdkjM/kbwrAQr lnRvs1oEPPgpd5FW3PuOzkSJU6i3Tq04KWlnCL1c4u0s37mCmQvZxF217ar7M4FUH/ v/sYT3A7z/ZYg== 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 ; Wed, 12 May 2021 09:20:55 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by pat.atlnz.lc (Postfix) with ESMTP id C8D5D13ECA6; Wed, 12 May 2021 09:20:55 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id C5E5E283A61; Wed, 12 May 2021 09:20:55 +1200 (NZST) From: Chris Packham To: wsa@kernel.org, andriy.shevchenko@linux.intel.com, andy.shevchenko@gmail.com, robh+dt@kernel.org, mpe@ellerman.id.au Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH v3 4/4] i2c: mpc: implement erratum A-004447 workaround Date: Wed, 12 May 2021 09:20:52 +1200 Message-Id: <20210511212052.27242-5-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511212052.27242-1-chris.packham@alliedtelesis.co.nz> References: <20210511212052.27242-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=K6Jc4BeI c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=5FLXtPjwQuUA:10 a=w4j1xu5M8ypyE8uBZIYA:9 X-SEG-SpamProfiler-Score: 0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The P2040/P2041 has an erratum where the normal i2c recovery mechanism does not work. Implement the alternative recovery mechanism documented in the P2040 Chip Errata Rev Q. Signed-off-by: Chris Packham --- Notes: Changes in v3: - Further code reduction in i2c_mpc_wait_sr() Changes in v2: - Use readb_poll_timeout instead of open-coded loop drivers/i2c/busses/i2c-mpc.c | 81 +++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 30d9e89a3db2..dcca9c2396db 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -45,6 +46,7 @@ #define CCR_MTX 0x10 #define CCR_TXAK 0x08 #define CCR_RSTA 0x04 +#define CCR_RSVD 0x02 #define CSR_MCF 0x80 #define CSR_MAAS 0x40 @@ -97,7 +99,7 @@ struct mpc_i2c { u32 block; int rc; int expect_rxack; - + bool has_errata_A004447; }; struct mpc_i2c_divider { @@ -136,6 +138,75 @@ static void mpc_i2c_fixup(struct mpc_i2c *i2c) } } +static int i2c_mpc_wait_sr(struct mpc_i2c *i2c, int mask) +{ + void __iomem *addr = i2c->base + MPC_I2C_SR; + u8 val; + + return readb_poll_timeout(addr, val, val & mask, 0, 100); +} + +/* + * Workaround for Erratum A004447. From the P2040CE Rev Q + * + * 1. Set up the frequency divider and sampling rate. + * 2. I2CCR - a0h + * 3. Poll for I2CSR[MBB] to get set. + * 4. If I2CSR[MAL] is set (an indication that SDA is stuck low), then go to + * step 5. If MAL is not set, then go to step 13. + * 5. I2CCR - 00h + * 6. I2CCR - 22h + * 7. I2CCR - a2h + * 8. Poll for I2CSR[MBB] to get set. + * 9. Issue read to I2CDR. + * 10. Poll for I2CSR[MIF] to be set. + * 11. I2CCR - 82h + * 12. Workaround complete. Skip the next steps. + * 13. Issue read to I2CDR. + * 14. Poll for I2CSR[MIF] to be set. + * 15. I2CCR - 80h + */ +static void mpc_i2c_fixup_A004447(struct mpc_i2c *i2c) +{ + int ret; + u32 val; + + writeccr(i2c, CCR_MEN | CCR_MSTA); + ret = i2c_mpc_wait_sr(i2c, CSR_MBB); + if (ret) { + dev_err(i2c->dev, "timeout waiting for CSR_MBB\n"); + return; + } + + val = readb(i2c->base + MPC_I2C_SR); + + if (val & CSR_MAL) { + writeccr(i2c, 0x00); + writeccr(i2c, CCR_MSTA | CCR_RSVD); + writeccr(i2c, CCR_MEN | CCR_MSTA | CCR_RSVD); + ret = i2c_mpc_wait_sr(i2c, CSR_MBB); + if (ret) { + dev_err(i2c->dev, "timeout waiting for CSR_MBB\n"); + return; + } + val = readb(i2c->base + MPC_I2C_DR); + ret = i2c_mpc_wait_sr(i2c, CSR_MIF); + if (ret) { + dev_err(i2c->dev, "timeout waiting for CSR_MIF\n"); + return; + } + writeccr(i2c, CCR_MEN | CCR_RSVD); + } else { + val = readb(i2c->base + MPC_I2C_DR); + ret = i2c_mpc_wait_sr(i2c, CSR_MIF); + if (ret) { + dev_err(i2c->dev, "timeout waiting for CSR_MIF\n"); + return; + } + writeccr(i2c, CCR_MEN); + } +} + #if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x) static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = { {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23}, @@ -670,7 +741,10 @@ static int fsl_i2c_bus_recovery(struct i2c_adapter *adap) { struct mpc_i2c *i2c = i2c_get_adapdata(adap); - mpc_i2c_fixup(i2c); + if (i2c->has_errata_A004447) + mpc_i2c_fixup_A004447(i2c); + else + mpc_i2c_fixup(i2c); return 0; } @@ -767,6 +841,9 @@ static int fsl_i2c_probe(struct platform_device *op) } dev_info(i2c->dev, "timeout %u us\n", mpc_ops.timeout * 1000000 / HZ); + if (of_property_read_bool(op->dev.of_node, "fsl,i2c-erratum-a004447")) + i2c->has_errata_A004447 = true; + i2c->adap = mpc_ops; scnprintf(i2c->adap.name, sizeof(i2c->adap.name), "MPC adapter (%s)", of_node_full_name(op->dev.of_node));