From patchwork Mon May 1 08:43:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 88989 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2562302vqo; Mon, 1 May 2023 01:57:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6YLn4huzn9vMHEwoiTgI5PW4f2/HyGfdpLRKwDf7Piur0IHNZrh9CjeRMY5GnRPNICOQN+ X-Received: by 2002:a05:6a21:164d:b0:d3:89a1:76d1 with SMTP id no13-20020a056a21164d00b000d389a176d1mr14486272pzb.11.1682931473236; Mon, 01 May 2023 01:57:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682931473; cv=none; d=google.com; s=arc-20160816; b=dnYScu8/unDRh5gy4JrNbzreo7P9kc1h1zEi8nwy4sKHBLE+g8yzpesOxPqYx/+N+n IIgZ3HaIrkf1BahQZrl08PNgv+Kfm4uS/u+2MwRe+kZNG5lFMkT9A8Vmp8BmhwV6BOsU xJHbdOufSqDGwzQfQF0kjw5NZkqMHKiUBjKsPL0FfDbI5/sZDLJJcR6OrAQsTm91WuMx GnzOqv05TnnVJFj7jnfuUJ6wvYoPk4PLZdDX2nc51scmDljkI1X7rIjIUAYqfHb3VgD4 XDRoEcblk+LU9t/0xMKRHsFIV6QOfN5qBma6QMJX4JrRyZqvZEYuwFkcMtY3FeRq+7x8 GuLg== 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=FMezA3s6OlHncbCOV4Cl8sjpGitFfZE4YMsw42pqalY=; b=uD3opeFVEa0uffuVcV+W6wUbgWDCfY9BF5GR7WpldzyzkbZiD1da5VPVhnOq9dsV3e O3sfx1mY9pdQNzmaJFyNV7f4aya7+qcflGxRXhdMfokgDy0yRcKnMNPpzgExXgllZQAn Y38ZZzfKGG702ZSZhoJCmJhc9Vv5xUHof1Wu21/5kyXNWUOVBOr45htp/P5ekhFGSLDy FOnlN/emy8/FEEOtlCZ+8tPQruPLRrNty3ycEdn68yCrHBwsqaOZ2H/y5J6noMiHanZQ PYYxQmH94LizF1QE4Hav7w8yqxyPEcVXhAqhvtAHO8tJgi7tCBiv2vh/aJQDY6BAEvRK ugtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bW20S5pr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a21-20020a63e855000000b0051b70782bc7si27504649pgk.234.2023.05.01.01.57.38; Mon, 01 May 2023 01:57:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=bW20S5pr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232243AbjEAIoP (ORCPT + 99 others); Mon, 1 May 2023 04:44:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbjEAIoL (ORCPT ); Mon, 1 May 2023 04:44:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1099E77; Mon, 1 May 2023 01:44:09 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id BA6B1660316A; Mon, 1 May 2023 09:44:07 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682930647; bh=kd7zQbdIfdiTDSN/o2vEbLYpgYwM2fkzUD6The1XAxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bW20S5pr2VrH21jPW2bW1Qq5Q0y22PBXadsQF8Sck9ckohiicu7jgY3TzwR12RNqa hBm8yqUOBz6mqfbRmmVRKkJA1nsZQlpLPGmPsOxe4oFm1yu7IiU9uf5DgyiCnSkMRP Hptrs25IORrQB0mO5LKbVkZnRDUJ6QcCjw+ozvKQhXssT6W0EW5DI17AVbcAf8YEho u5uZ/qYegKtdT6fl1FdVDeeLBJPTmjUsWkK/jdbLfape3Ud4JWR8U8V05WB/CAbhtc uQ1s+3+t82PUZ0rSTULlcuuG5hfGY9D97hj3fRzYMX9GtKJ+ro9CRJZULcBgMe717t dYU9AwhdnDbqA== From: Cristian Ciocaltea To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Philipp Zabel , Sebastian Reichel , Shreeya Patel , Kever Yang , Finley Xiao Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 1/8] dt-bindings: nvmem: Convert rockchip-otp.txt to dt-schema Date: Mon, 1 May 2023 11:43:53 +0300 Message-Id: <20230501084401.765169-2-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> References: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764681552181897798?= X-GMAIL-MSGID: =?utf-8?q?1764681552181897798?= Convert the Rockchip OTP memory bindings to dt-schema. Signed-off-by: Cristian Ciocaltea Reviewed-by: Heiko Stuebner --- .../bindings/nvmem/rockchip-otp.txt | 25 ------ .../bindings/nvmem/rockchip-otp.yaml | 83 +++++++++++++++++++ 2 files changed, 83 insertions(+), 25 deletions(-) delete mode 100644 Documentation/devicetree/bindings/nvmem/rockchip-otp.txt create mode 100644 Documentation/devicetree/bindings/nvmem/rockchip-otp.yaml diff --git a/Documentation/devicetree/bindings/nvmem/rockchip-otp.txt b/Documentation/devicetree/bindings/nvmem/rockchip-otp.txt deleted file mode 100644 index 40f649f7c2e5..000000000000 --- a/Documentation/devicetree/bindings/nvmem/rockchip-otp.txt +++ /dev/null @@ -1,25 +0,0 @@ -Rockchip internal OTP (One Time Programmable) memory device tree bindings - -Required properties: -- compatible: Should be one of the following. - - "rockchip,px30-otp" - for PX30 SoCs. - - "rockchip,rk3308-otp" - for RK3308 SoCs. -- reg: Should contain the registers location and size -- clocks: Must contain an entry for each entry in clock-names. -- clock-names: Should be "otp", "apb_pclk" and "phy". -- resets: Must contain an entry for each entry in reset-names. - See ../../reset/reset.txt for details. -- reset-names: Should be "phy". - -See nvmem.txt for more information. - -Example: - otp: otp@ff290000 { - compatible = "rockchip,px30-otp"; - reg = <0x0 0xff290000 0x0 0x4000>; - #address-cells = <1>; - #size-cells = <1>; - clocks = <&cru SCLK_OTP_USR>, <&cru PCLK_OTP_NS>, - <&cru PCLK_OTP_PHY>; - clock-names = "otp", "apb_pclk", "phy"; - }; diff --git a/Documentation/devicetree/bindings/nvmem/rockchip-otp.yaml b/Documentation/devicetree/bindings/nvmem/rockchip-otp.yaml new file mode 100644 index 000000000000..658ceed14ee2 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/rockchip-otp.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/rockchip-otp.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Rockchip internal OTP (One Time Programmable) memory + +maintainers: + - Heiko Stuebner + +allOf: + - $ref: nvmem.yaml# + +properties: + compatible: + enum: + - rockchip,px30-otp + - rockchip,rk3308-otp + + reg: + maxItems: 1 + + clocks: + minItems: 3 + maxItems: 3 + + clock-names: + items: + - const: otp + - const: apb_pclk + - const: phy + + resets: + maxItems: 1 + + reset-names: + items: + - const: phy + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + +unevaluatedProperties: false + +examples: + - | + #include + + soc { + #address-cells = <2>; + #size-cells = <2>; + + otp: efuse@ff290000 { + compatible = "rockchip,px30-otp"; + reg = <0x0 0xff290000 0x0 0x4000>; + clocks = <&cru SCLK_OTP_USR>, <&cru PCLK_OTP_NS>, + <&cru PCLK_OTP_PHY>; + clock-names = "otp", "apb_pclk", "phy"; + resets = <&cru SRST_OTP_PHY>; + reset-names = "phy"; + #address-cells = <1>; + #size-cells = <1>; + + cpu_id: id@7 { + reg = <0x07 0x10>; + }; + + cpu_leakage: cpu-leakage@17 { + reg = <0x17 0x1>; + }; + + performance: performance@1e { + reg = <0x1e 0x1>; + bits = <4 3>; + }; + }; + }; From patchwork Mon May 1 08:43:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 88986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2558411vqo; Mon, 1 May 2023 01:45:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79X8K0oAZrB86ft21zEzqi8rA5975MW3c8+nAFH+l7yudz5dyWk/cAnvVwFNXutphOy92M X-Received: by 2002:a05:6a20:c892:b0:f5:b78b:654 with SMTP id hb18-20020a056a20c89200b000f5b78b0654mr13134865pzb.15.1682930745097; Mon, 01 May 2023 01:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682930745; cv=none; d=google.com; s=arc-20160816; b=a45iStf7O6Hn+bjaDUZhnF0oUGMibUpybH3dMbrOLrjYN4+zK8NlO2zGMUKC2V6nkV 5ch03/scnYbc188fjaMTsnVW8JCAKu6IeHdIHnJCrOc0w6EPqnaKWmnNh2+WgD0Z8KNA auknSH88emxUnNe55zb5gQP+MtFHO0yRaYkTr/gFKuFZwHq+pzDUT6Wh5MOY6tVqu/qK 4H4pIYjORQ4OYGzRtq0UPwmWvk/NaoJZsm81j29/09rOZW7r4Vac4am7dcGudr63joK7 Cp7ISSUu34q5ifSDMMha9aPiTxctpaSW3eZuYiRbTHbu3iAnTCVJL7hRjSujSGNmKuqK 480g== 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=TT8MEsi5vaClOkJ7v3R27CiK4FK0J72UChiuNHVh51U=; b=DhRwceM5Tsr2j3xz3Dpx42aJNXoXbc6TUIsmDh2Zp/T5hh25x6KUyvISaYzEB9hQdx 8aqKZI8F66DeifoVKmOGoZIRsSR/Z49EyD3pbtfv2ehytaESlPktTFoW42kp6VOhezHX Na0PnYoksRrru1/rfEf1GiI64TLJkS+0498wypB+l+QSfYqS8wUzxhjxKUaGzl7vZYwj oKzEI+Qs+oSzrJQbCHtA8ZegvQ8wchij/XqtAV8o4hbdaw8cHuDKYWUnXZMeNvI5zKcS miCBDPxEEZ3lalirn3N5WzksHNiydVzkRm/ts1SxP2Pj87FY4nUowA/Sp4pvPKWuWxln t09A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dDtM4xXk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q4-20020a634304000000b00524b2358ffcsi27302047pga.574.2023.05.01.01.45.31; Mon, 01 May 2023 01:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dDtM4xXk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232296AbjEAIoT (ORCPT + 99 others); Mon, 1 May 2023 04:44:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjEAIoN (ORCPT ); Mon, 1 May 2023 04:44:13 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49D0B10E7; Mon, 1 May 2023 01:44:12 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id EC90866031F8; Mon, 1 May 2023 09:44:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682930651; bh=yOu4hxNG9H8E3BYZJ09jRWvIMd5u45GgHcAb3KhsBXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dDtM4xXkSvrO9zdyBpA378ZJAH4M4xhc/dBOhKHaCOt+9q5hwE0pELA34MPZ+5FYv 7jqO+uj9fguFhOi6cHFI4hkdJX3pJppxA3yD92B7JYgdPfiXahOU0yyskQch7zhtho y0Fi5zukqvta1IISIzKQWtPUIc8IaskyI6nDtLiaHC+WFb8A6K7hRNdFRVtYD8pydi twf95xDWKxcWNTw6i8HBMpHlXcAZOEZZCaZUXcbWC82fB1frbWIYFfWuUdbjpE+EG+ pBJCVYA9hYqPLOZyX7Lk6mBvjolYDh6aNl3eZ0LlapUSoJ/+X6C9TI51ZCRXl+AUu0 YWtqnDKAxOK9A== From: Cristian Ciocaltea To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Philipp Zabel , Sebastian Reichel , Shreeya Patel , Kever Yang , Finley Xiao Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 2/8] dt-bindings: nvmem: rockchip-otp: Add compatible for RK3588 Date: Mon, 1 May 2023 11:43:54 +0300 Message-Id: <20230501084401.765169-3-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> References: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764680789165456103?= X-GMAIL-MSGID: =?utf-8?q?1764680789165456103?= Document the OTP memory found on Rockchip RK3588 SoC. Signed-off-by: Cristian Ciocaltea Reviewed-by: Heiko Stuebner --- .../bindings/nvmem/rockchip-otp.yaml | 71 ++++++++++++++++--- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/nvmem/rockchip-otp.yaml b/Documentation/devicetree/bindings/nvmem/rockchip-otp.yaml index 658ceed14ee2..84a11382c6e7 100644 --- a/Documentation/devicetree/bindings/nvmem/rockchip-otp.yaml +++ b/Documentation/devicetree/bindings/nvmem/rockchip-otp.yaml @@ -9,34 +9,31 @@ title: Rockchip internal OTP (One Time Programmable) memory maintainers: - Heiko Stuebner -allOf: - - $ref: nvmem.yaml# - properties: compatible: enum: - rockchip,px30-otp - rockchip,rk3308-otp + - rockchip,rk3588-otp reg: maxItems: 1 clocks: minItems: 3 - maxItems: 3 + maxItems: 4 clock-names: - items: - - const: otp - - const: apb_pclk - - const: phy + minItems: 3 + maxItems: 4 resets: - maxItems: 1 + minItems: 1 + maxItems: 3 reset-names: - items: - - const: phy + minItems: 1 + maxItems: 3 required: - compatible @@ -46,6 +43,58 @@ required: - resets - reset-names +allOf: + - $ref: nvmem.yaml# + + - if: + properties: + compatible: + contains: + enum: + - rockchip,px30-otp + - rockchip,rk3308-otp + then: + properties: + clocks: + minItems: 3 + maxItems: 3 + clock-names: + items: + - const: otp + - const: apb_pclk + - const: phy + resets: + maxItems: 1 + reset-names: + items: + - const: phy + + - if: + properties: + compatible: + contains: + enum: + - rockchip,rk3588-otp + then: + properties: + clocks: + minItems: 4 + maxItems: 4 + clock-names: + items: + - const: otpc + - const: apb + - const: arb + - const: phy + resets: + minItems: 1 + maxItems: 3 + reset-names: + items: + - const: otpc + - const: apb + - const: arb + unevaluatedProperties: false examples: From patchwork Mon May 1 08:43:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 88990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2562323vqo; Mon, 1 May 2023 01:57:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4FE8PcTXCntvXnFUeZRprSzwVVSU8/j36MYQFMz0PZ5TAdjL/m8TWVPqPMvwvtJmzHnGUJ X-Received: by 2002:a17:90a:318b:b0:24d:fba9:80e9 with SMTP id j11-20020a17090a318b00b0024dfba980e9mr3013694pjb.23.1682931476584; Mon, 01 May 2023 01:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682931476; cv=none; d=google.com; s=arc-20160816; b=jJJUKEgiIbDVDzNUxh6iC9IFkwTiVhe+U7FafqgpQmd60LbgibcTODJYqBwJRtIWv4 efMbxNolQNjBa2xxQdK4Avw+eQwjTJUZYYVF6AnMCZKBPtOUNKkZKNn/lrPfDW9IQwQa QqMIMtgDzi7F5Nt5W637OnVxx0Ge/VnmPYubB7nqNIlNwflYNpWMcAIZdfkL/Ay/K8e1 2aH0V+PqyiVowvqXJdDlDq/mLJuR8JFg0IWR9R72HYbcSdE9sxjUyFjVZWnh5xUwRrgT ikgCCCvhjLaQriwOgUGllhNUxLGheTrm9KvrqPfuCMKFxERWgdk356txLL67NQZIYXSC NEpQ== 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=GsSdveGX/aKpOkda2V8mxgRsbnuuiWZuYADvS4pWQWs=; b=XibcwM9J+wMg6pRmT2ZWqIiZ0k5Lz63XVo5p2+mYeiDhvPddYMyuz+zac9KTpQbWIV AEyBSqUrPru9waIFj9f4fu3ndB3s3ZN4wNAxv4n02mMpVNiiUkE4QgskPdgBqHl2YKz6 XC/bxRxbH5JXRIlVCrbN8VmBwPmsd0qlnf4znYR3p1uijuMZ1oRFBCzmodoodjJeddjY lnX4zdzBqI27dr1fbufXvrqD+fV3DbK9+fCLQtFCM+uC2Q35CvUpfbd0YkhupA5XnpPw QganygPn5zDfmVwk1aIltMpDIIZo+K79lJxjx4T/qz+F1JVlZqGpnMtOnrMA63yN7qRH EDfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=B1Sotb+d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a17090a86c700b0023fc6dc1092si30014128pjv.145.2023.05.01.01.57.44; Mon, 01 May 2023 01:57:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=B1Sotb+d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232290AbjEAIoW (ORCPT + 99 others); Mon, 1 May 2023 04:44:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232277AbjEAIoQ (ORCPT ); Mon, 1 May 2023 04:44:16 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B5B510E2; Mon, 1 May 2023 01:44:15 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id D878D66031C9; Mon, 1 May 2023 09:44:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682930654; bh=vUSYcmRTpasIIy+WikTj0BrypHJmCXBFXT3CHvUXLpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1Sotb+dv7fMJXGyd8Y1FNhinwUu9t4HZHt2jXWROtdydHlblcwftM8S+QYCGLmaK RtTPupiZa3x/C/YAI5rmi+e/jndYcQO3e50Q0M9KDB0elVQoAwltQEV8HPpvVNNI8i IfIAXzBh+IYb5QPXw0+FUX7Gha0I6Pojp8PRKjFxrYDsbIi6lxdvTBLkEQFcpMASBZ MgkETPIftUASRUMWWUv6Q6qpRhU0J6xhJYgAIBvG7us9dKkzugrhJWCqGasGaOXN0s ewnFEagXJtYGspAYhMw7gQ3EiaMVu2959dxsGmDNn9Xup54OyRmS8svSwFsEcgR4ZZ tpgf2Xy7zksDA== From: Cristian Ciocaltea To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Philipp Zabel , Sebastian Reichel , Shreeya Patel , Kever Yang , Finley Xiao Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 3/8] nvmem: rockchip-otp: Add clocks and reg_read to rockchip_data Date: Mon, 1 May 2023 11:43:55 +0300 Message-Id: <20230501084401.765169-4-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> References: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764681556253578535?= X-GMAIL-MSGID: =?utf-8?q?1764681556253578535?= In preparation to support new Rockchip OTP memory devices with different clock configurations and register layout, extend rockchip_data struct with the related members: clocks, num_clks, reg_read. Additionally, to avoid managing redundant driver data, drop num_clks member from rockchip_otp struct and update all references to point to the equivalent member in rockchip_data. Signed-off-by: Cristian Ciocaltea Reviewed-by: Heiko Stuebner --- drivers/nvmem/rockchip-otp.c | 79 ++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c index 9f53bcce2f87..a5b234e60735 100644 --- a/drivers/nvmem/rockchip-otp.c +++ b/drivers/nvmem/rockchip-otp.c @@ -54,21 +54,19 @@ #define OTPC_TIMEOUT 10000 +struct rockchip_data { + int size; + const char * const *clocks; + int num_clks; + nvmem_reg_read_t reg_read; +}; + struct rockchip_otp { struct device *dev; void __iomem *base; - struct clk_bulk_data *clks; - int num_clks; + struct clk_bulk_data *clks; struct reset_control *rst; -}; - -/* list of required clocks */ -static const char * const rockchip_otp_clocks[] = { - "otp", "apb_pclk", "phy", -}; - -struct rockchip_data { - int size; + const struct rockchip_data *data; }; static int rockchip_otp_reset(struct rockchip_otp *otp) @@ -132,29 +130,23 @@ static int rockchip_otp_ecc_enable(struct rockchip_otp *otp, bool enable) return ret; } -static int rockchip_otp_read(void *context, unsigned int offset, - void *val, size_t bytes) +static int px30_otp_read(void *context, unsigned int offset, + void *val, size_t bytes) { struct rockchip_otp *otp = context; u8 *buf = val; - int ret = 0; - - ret = clk_bulk_prepare_enable(otp->num_clks, otp->clks); - if (ret < 0) { - dev_err(otp->dev, "failed to prepare/enable clks\n"); - return ret; - } + int ret; ret = rockchip_otp_reset(otp); if (ret) { dev_err(otp->dev, "failed to reset otp phy\n"); - goto disable_clks; + return ret; } ret = rockchip_otp_ecc_enable(otp, false); if (ret < 0) { dev_err(otp->dev, "rockchip_otp_ecc_enable err\n"); - goto disable_clks; + return ret; } writel(OTPC_USE_USER | OTPC_USE_USER_MASK, otp->base + OTPC_USER_CTRL); @@ -174,8 +166,28 @@ static int rockchip_otp_read(void *context, unsigned int offset, read_end: writel(0x0 | OTPC_USE_USER_MASK, otp->base + OTPC_USER_CTRL); -disable_clks: - clk_bulk_disable_unprepare(otp->num_clks, otp->clks); + + return ret; +} + +static int rockchip_otp_read(void *context, unsigned int offset, + void *val, size_t bytes) +{ + struct rockchip_otp *otp = context; + int ret; + + if (!otp->data || !otp->data->reg_read) + return -EINVAL; + + ret = clk_bulk_prepare_enable(otp->data->num_clks, otp->clks); + if (ret < 0) { + dev_err(otp->dev, "failed to prepare/enable clks\n"); + return ret; + } + + ret = otp->data->reg_read(context, offset, val, bytes); + + clk_bulk_disable_unprepare(otp->data->num_clks, otp->clks); return ret; } @@ -189,8 +201,15 @@ static struct nvmem_config otp_config = { .reg_read = rockchip_otp_read, }; +static const char * const px30_otp_clocks[] = { + "otp", "apb_pclk", "phy", +}; + static const struct rockchip_data px30_data = { .size = 0x40, + .clocks = px30_otp_clocks, + .num_clks = ARRAY_SIZE(px30_otp_clocks), + .reg_read = px30_otp_read, }; static const struct of_device_id rockchip_otp_match[] = { @@ -225,21 +244,21 @@ static int rockchip_otp_probe(struct platform_device *pdev) if (!otp) return -ENOMEM; + otp->data = data; otp->dev = dev; otp->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(otp->base)) return PTR_ERR(otp->base); - otp->num_clks = ARRAY_SIZE(rockchip_otp_clocks); - otp->clks = devm_kcalloc(dev, otp->num_clks, - sizeof(*otp->clks), GFP_KERNEL); + otp->clks = devm_kcalloc(dev, data->num_clks, sizeof(*otp->clks), + GFP_KERNEL); if (!otp->clks) return -ENOMEM; - for (i = 0; i < otp->num_clks; ++i) - otp->clks[i].id = rockchip_otp_clocks[i]; + for (i = 0; i < data->num_clks; ++i) + otp->clks[i].id = data->clocks[i]; - ret = devm_clk_bulk_get(dev, otp->num_clks, otp->clks); + ret = devm_clk_bulk_get(dev, data->num_clks, otp->clks); if (ret) return ret; From patchwork Mon May 1 08:43:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 88993 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2562373vqo; Mon, 1 May 2023 01:58:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7DkMk8f3eiPyWuQS6cFpgGatWiq0fLIf4gmNbhfspdmC2H/pJfJEd3yMfjjpmtp/nrQz5U X-Received: by 2002:a17:90b:80f:b0:24e:4c8:3ae5 with SMTP id bk15-20020a17090b080f00b0024e04c83ae5mr2361973pjb.28.1682931483673; Mon, 01 May 2023 01:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682931483; cv=none; d=google.com; s=arc-20160816; b=tuxRVOu1Y6iZaI13CpwRh2wo/1KnO+ivO8ISixHuzD5Qulbk/vmK6LfO00hNM8O/ua vPY3IZEYU6qD4aeAI2AxeLd2fkDiJ5rWRTd/fIRpwE5p7F4Wfy1YtwZ7N4hHyZ8cLLE9 K9EZiXnNVmi5VgR1zUvzxbE7dAQNoWcWY8KU2J8dEHhmoG5AvHTn0N+NTDDBwTY4XStm WsHnovzTxz/UPXVelkltrTZSZimZSqgZZFAOLJAq+SGUVX3+u8QkaQVEbd5JeNvAzuc5 7Jw/tOjZl/VL63Ysd1e762UedOdJ7HVWnVVxczeyCPGgPr+rvZB5qEuF7U85RGgaA2pV dslA== 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=2N7BS+zQhkI1Ug1q8REjBE1RbcrtbgKiyYpxMG+5mLA=; b=NtFAT2AtFzdU2f23LzjRD05FIWlOq+ln6QeJLl2oEg4p50x4IuBkteWAQUwiISY7Gn ocHbm8LfSepBHWNnOsBuk95ehGWvEocfwIbNBFPdPSoK4XFMxKVYf/CXy5X8wW0lPoap h1JkuJjMQQ9l2+VgYz0g/QIG0T0Z0SjbuQdj6NDDOPF23PKfVUKsoeCU5462Hp7jjouB aYZJ6qDWKTwyi3e22aAsAMek46KIH+9Ke14zX7rWtOueSSIxu8Ewrd0nK/kGp7jWbwMy GKlfwN6+gk7FaWlY7ZxEKEq0JgGtTOZ56il+7nJ9SNJMJUyb9U6xDrGsJWL7Lw1F6goC VSGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=d1YFnRqU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oo7-20020a17090b1c8700b0024b011026aesi32098662pjb.76.2023.05.01.01.57.51; Mon, 01 May 2023 01:58:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=d1YFnRqU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232277AbjEAIob (ORCPT + 99 others); Mon, 1 May 2023 04:44:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232301AbjEAIoT (ORCPT ); Mon, 1 May 2023 04:44:19 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 836C8E7A; Mon, 1 May 2023 01:44:17 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 415B16602F6A; Mon, 1 May 2023 09:44:16 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682930656; bh=ZmCzaqB0Ylzg7HWMRjjmRxOmRNTg2+5slMJcMqm5f6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1YFnRqU2NXyvNPxFtU+B4cH0+o7q5oe9isAwzP7ExBDZR0Itb2A7oFB0Eyy5tFNL YU1BihI9sYxK2yHEPU24oB3gfHcoXqynHmCirbreZzU9wRczVxs0z4YvokBGvAHnDd GPgHGdmbIitnMCvs1s+zBJ+/CAYAFjvD0sOM4G2TPa+m0cWwHxQydOrmQ0YrA9qFjj eLwmtoXdjlbRZTnnc1zYZqW4ojTxyDdMG/RlYyAsy5+3Io3RFggqtKYBwoBfAeM3bQ +KaZo9etZNsf4UsqpPiuzrwXaFLNYN5u+g00qCMpeJCjHMpQhVohoEHGmkv+UldU3q vUN1ZoJRr9Nsw== From: Cristian Ciocaltea To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Philipp Zabel , Sebastian Reichel , Shreeya Patel , Kever Yang , Finley Xiao Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 4/8] nvmem: rockchip-otp: Generalize rockchip_otp_wait_status() Date: Mon, 1 May 2023 11:43:56 +0300 Message-Id: <20230501084401.765169-5-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> References: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764681563485709565?= X-GMAIL-MSGID: =?utf-8?q?1764681563485709565?= In preparation to support additional Rockchip OTP memory devices with different register layout, generalize rockchip_otp_wait_status() to accept a new parameter for specifying the offset of the status register. Signed-off-by: Cristian Ciocaltea Reviewed-by: Heiko Stuebner --- drivers/nvmem/rockchip-otp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c index a5b234e60735..e308dd3b4eb1 100644 --- a/drivers/nvmem/rockchip-otp.c +++ b/drivers/nvmem/rockchip-otp.c @@ -90,18 +90,19 @@ static int rockchip_otp_reset(struct rockchip_otp *otp) return 0; } -static int rockchip_otp_wait_status(struct rockchip_otp *otp, u32 flag) +static int rockchip_otp_wait_status(struct rockchip_otp *otp, + unsigned int reg, u32 flag) { u32 status = 0; int ret; - ret = readl_poll_timeout_atomic(otp->base + OTPC_INT_STATUS, status, + ret = readl_poll_timeout_atomic(otp->base + reg, status, (status & flag), 1, OTPC_TIMEOUT); if (ret) return ret; /* clean int status */ - writel(flag, otp->base + OTPC_INT_STATUS); + writel(flag, otp->base + reg); return 0; } @@ -123,7 +124,7 @@ static int rockchip_otp_ecc_enable(struct rockchip_otp *otp, bool enable) writel(SBPI_ENABLE_MASK | SBPI_ENABLE, otp->base + OTPC_SBPI_CTRL); - ret = rockchip_otp_wait_status(otp, OTPC_SBPI_DONE); + ret = rockchip_otp_wait_status(otp, OTPC_INT_STATUS, OTPC_SBPI_DONE); if (ret < 0) dev_err(otp->dev, "timeout during ecc_enable\n"); @@ -156,7 +157,7 @@ static int px30_otp_read(void *context, unsigned int offset, otp->base + OTPC_USER_ADDR); writel(OTPC_USER_FSM_ENABLE | OTPC_USER_FSM_ENABLE_MASK, otp->base + OTPC_USER_ENABLE); - ret = rockchip_otp_wait_status(otp, OTPC_USER_DONE); + ret = rockchip_otp_wait_status(otp, OTPC_INT_STATUS, OTPC_USER_DONE); if (ret < 0) { dev_err(otp->dev, "timeout during read setup\n"); goto read_end; From patchwork Mon May 1 08:43:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 88987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2558584vqo; Mon, 1 May 2023 01:46:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66P8Y5dWW2LAlPVmydJT2LXBGzBeYRCc9OZRLgTPiOG3310i2EBkPZx6EDCWT/P4PJzIRf X-Received: by 2002:a17:902:db09:b0:1a6:8405:f709 with SMTP id m9-20020a170902db0900b001a68405f709mr17148421plx.20.1682930772503; Mon, 01 May 2023 01:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682930772; cv=none; d=google.com; s=arc-20160816; b=P1A7l4gFCy3T7mPoIvX8hwDsXw8kYvsbnhyqJA0X92QfsV7CO1ULuJbOtcft9go3re ZmP/J1n8P/8Bcsn0XIdVlyG2fGttIfxTdXofbOrj+64bJjFAWr21IwtNt5RviqQSwOLY 2G5vWoQSRt554Rq56ujmjiIrvTzKOiot+DfQjVLQRxJbVvGjZEXuy5GR+S/aM+ltXCh7 Iss9OlFh2pi45pyxvpdd58IOqSpw00+OsxfDU4hKjrDb1srmB0NZ/DTUz91n7w624SIM Tjw507plrS//aRlWE6uJWfE8INvSuYB0UsmsFwT8WubDN5Ck5UAkumjzrzP7QAzPn7K/ bfdg== 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=7z/WzrPxMvN0Pfajrn8O27DHI26f7hs17jAw6CSqcNw=; b=cIlO6fZtat1mEznkPUaAo54dwfQvoZbEgyunGEVgrwulidiZFcTQTmt1GifdND+vrO OcPTfVggRmVHQChVnRgKV3s3HyPJ5qg547WgGesf5VJolGQsIIENPhG0ZFJRCLrggbQr IEhL5buzpATJ3tnTC9RCigmqD1VfD8F4D7H4BABiNcZV7SZRA9k3oX8C/NnLjLY4LXsb WFuOzcloj3gqtXPk5Ky+E69yfBWKoz5VAcwKpQbAlCJa/zcFPA86AUUOx/B6dOy04zHk hse2az7d7DAQeF2OQxwCEcqfN3xrDaw/uZXgMg6FbMVk4RjQ6mIMJEte1MlSe+iGxnA4 oQZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VrbFGRRy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a170902d48b00b001a97c1afb8asi19279382plg.622.2023.05.01.01.45.58; Mon, 01 May 2023 01:46:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=VrbFGRRy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232327AbjEAIog (ORCPT + 99 others); Mon, 1 May 2023 04:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232322AbjEAIoa (ORCPT ); Mon, 1 May 2023 04:44:30 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36734171B; Mon, 1 May 2023 01:44:21 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id C979E660316A; Mon, 1 May 2023 09:44:19 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682930660; bh=x9XZQ3uvxTsAewM1Yl0ycP8UKF79G7B1mNgN7RoKnIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VrbFGRRyDt+77pqbitqtY1sN76z1tYvVESWYrVbjH/7Jr48ltiHzsIPYxDXBHw4Za Dj60ePX2+kI39jGyjvshxIG18+Rml62ysPMU+2iWLUvjLne7oLCHP8kKmd7DCTzFS+ MGcHkgjcqPHrtvI+oN39DO/dbHbUbnUNoYs4FrETcewBVab0pC5MM9sB3vb2/ZsRnZ yCdqMPJTUhdMXoz3grpOe/zIGGrAHM8M/WsAkWkWzLiyJafZZuEQAhCyLA398MHZda PQQrsEbTkxxvC3jbWm+Ov1VrrgFtF8XZ4rF7cRUlR4TqQBXdGvz5ofMgWHZT7Gpdr/ LxFb7sI1MAS7w== From: Cristian Ciocaltea To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Philipp Zabel , Sebastian Reichel , Shreeya Patel , Kever Yang , Finley Xiao Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 5/8] nvmem: rockchip-otp: Use devm_reset_control_array_get_exclusive() Date: Mon, 1 May 2023 11:43:57 +0300 Message-Id: <20230501084401.765169-6-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> References: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764680817724403321?= X-GMAIL-MSGID: =?utf-8?q?1764680817724403321?= In preparation to support new Rockchip OTP memory devices having specific reset configurations, switch devm_reset_control_get() to devm_reset_control_array_get_exclusive(). Signed-off-by: Cristian Ciocaltea Reviewed-by: Heiko Stuebner --- drivers/nvmem/rockchip-otp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c index e308dd3b4eb1..b74d98f82ae5 100644 --- a/drivers/nvmem/rockchip-otp.c +++ b/drivers/nvmem/rockchip-otp.c @@ -263,7 +263,7 @@ static int rockchip_otp_probe(struct platform_device *pdev) if (ret) return ret; - otp->rst = devm_reset_control_get(dev, "phy"); + otp->rst = devm_reset_control_array_get_exclusive(dev); if (IS_ERR(otp->rst)) return PTR_ERR(otp->rst); From patchwork Mon May 1 08:43:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 88991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2562324vqo; Mon, 1 May 2023 01:57:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6LolASpupFoAPIik975tkbjmnHlEe7DjZ/Ha0hugCa3GxbLekrl5GOD64toIGiPkT3fnC6 X-Received: by 2002:a05:6a20:144d:b0:f6:2287:e05d with SMTP id a13-20020a056a20144d00b000f62287e05dmr17476450pzi.10.1682931476937; Mon, 01 May 2023 01:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682931476; cv=none; d=google.com; s=arc-20160816; b=N7Xlhv7KgFjSG9saVLJ16+2BitdqqTJQw+/8TTk19LwPOGziE/JttqxSQSytlpuM+R QLOiTqJcdRFVDMOHp4TII8QeFjOf78XrE3o5kJsQTDezgz5G/3SQmrINx84/EPovyfwh CZSg8Kr8uERFmcYiETqeY51wdh9mARvzh/uZqufEjZXKfvR7KoLhu1HNiIcjZkAzaBqF FWx1T7rySC1eIkkWqPecT6NWRu5Zg4+pZB7AZzKX4IuOiuM9ofk3h/pFUVDFLlSEoJzR 5HSlPF+WHYDMpaoFL7/7QPsakqK+CKcro7DkpG5AKlVKb4+JEtY2W0OC3kl8OZ/pN4Ht pnPw== 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=uBc+fkxZEhDIzD6d923ZMHW/2GS8o30bnPWJxKFfpTc=; b=urp4Ywklxy4KA0VZlW1kzugYIGIwIx6BsWwsXmcFB+FIeM5iTZnD2cZWQG+dbST6hF ZXppxJVhudq5m6UceFcLFYKxdRJLEbqMVQ9OdxmGADwtb3qr6O4FnAhsZsZ2S7JKaCDe nzBP4xK6Bt+gM1vaSC+1494FZ3LLTQbVrEzogWMvxVJPyXUPLVwIc6ICy5hG0Jmhjs0g ogOiHvRZOqBvccdLLW3F1M+WKG6ymoHoE9BuGC/jE6yOufubrekfFID2UslYXMZ66s8Q nSuTo1sONiAQbK6WUnzlAqUH6unwRxYbnecX78UpvN+KeR+lP+2edzZQG2u/vcovUZ7P AZiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fFTI9Pf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 85-20020a630058000000b00528b933cffesi8249589pga.868.2023.05.01.01.57.44; Mon, 01 May 2023 01:57:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fFTI9Pf9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232242AbjEAIou (ORCPT + 99 others); Mon, 1 May 2023 04:44:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232298AbjEAIoc (ORCPT ); Mon, 1 May 2023 04:44:32 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D581010FD; Mon, 1 May 2023 01:44:24 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 0A4876602F6A; Mon, 1 May 2023 09:44:22 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682930663; bh=eFpFeWyImJpFwgodlftFerx7HEWYmMUA01PlcCUlrro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFTI9Pf9U4RPcD9XXPwfu/CVDrBtiM4yD72KEGx3dNlWSaV/qWZxI3W157KB967UO ukEVanU1quhqoOsERuxQEs66gOnBHm7bmebpxtFoI5tJZK1jHVb2jXx9c+Zhm4GUpa nNi5xD5sY1cO3cBOzyfjlndWGOeVXc4mYK/iT2I21tyff3yLllzBeS8m53RZELmKuY u4Gq8DCXieEX3lZJ2C+OlXfVCcrpdrnhs9EZy8DSQnRnuKGHB40O2P27uZqUVp5Ycu OOOgfrtb3MJTdWr0JTD6/Ex6xNseScCt9kNJAJcaOWTCc68DRhQ+vpOb4etdlQ0aJl J6k3z0sUjXPHw== From: Cristian Ciocaltea To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Philipp Zabel , Sebastian Reichel , Shreeya Patel , Kever Yang , Finley Xiao Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 6/8] nvmem: rockchip-otp: Improve probe error handling Date: Mon, 1 May 2023 11:43:58 +0300 Message-Id: <20230501084401.765169-7-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> References: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764681556304081245?= X-GMAIL-MSGID: =?utf-8?q?1764681556304081245?= Enhance error handling in the probe function by making use of dev_err_probe(), which ensures the error code is always printed, in addition to the specified error message. Signed-off-by: Cristian Ciocaltea Reviewed-by: Heiko Stuebner --- drivers/nvmem/rockchip-otp.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c index b74d98f82ae5..4370d6c5e4e9 100644 --- a/drivers/nvmem/rockchip-otp.c +++ b/drivers/nvmem/rockchip-otp.c @@ -235,10 +235,8 @@ static int rockchip_otp_probe(struct platform_device *pdev) int ret, i; data = of_device_get_match_data(dev); - if (!data) { - dev_err(dev, "failed to get match data\n"); - return -EINVAL; - } + if (!data) + return dev_err_probe(dev, -EINVAL, "failed to get match data\n"); otp = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_otp), GFP_KERNEL); @@ -249,7 +247,8 @@ static int rockchip_otp_probe(struct platform_device *pdev) otp->dev = dev; otp->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(otp->base)) - return PTR_ERR(otp->base); + return dev_err_probe(dev, PTR_ERR(otp->base), + "failed to ioremap resource\n"); otp->clks = devm_kcalloc(dev, data->num_clks, sizeof(*otp->clks), GFP_KERNEL); @@ -261,18 +260,22 @@ static int rockchip_otp_probe(struct platform_device *pdev) ret = devm_clk_bulk_get(dev, data->num_clks, otp->clks); if (ret) - return ret; + return dev_err_probe(dev, ret, "failed to get clocks\n"); otp->rst = devm_reset_control_array_get_exclusive(dev); if (IS_ERR(otp->rst)) - return PTR_ERR(otp->rst); + return dev_err_probe(dev, PTR_ERR(otp->rst), + "failed to get resets\n"); otp_config.size = data->size; otp_config.priv = otp; otp_config.dev = dev; - nvmem = devm_nvmem_register(dev, &otp_config); - return PTR_ERR_OR_ZERO(nvmem); + nvmem = devm_nvmem_register(dev, &otp_config); + if (IS_ERR(nvmem)) + return dev_err_probe(dev, PTR_ERR(nvmem), + "failed to register nvmem device\n"); + return 0; } static struct platform_driver rockchip_otp_driver = { From patchwork Mon May 1 08:43:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 88992 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2562325vqo; Mon, 1 May 2023 01:57:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6TgXrqC5B1ElZn4XaC5saaQ2mzURTGJvIQyJO2Jh4gL9jXJ9D5jILS/r3d/e2bBsTxkvQO X-Received: by 2002:a05:6a21:6d87:b0:ed:1d7a:3339 with SMTP id wl7-20020a056a216d8700b000ed1d7a3339mr5822468pzb.57.1682931476928; Mon, 01 May 2023 01:57:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682931476; cv=none; d=google.com; s=arc-20160816; b=IR0GohEFY1afQQ7R5ZqgKNS1sExNQi+LjKdSxrdZThfaY08XvBu54zPN+rHiQsplLn 5oMlFl+TbY1gcwxF6NEpAAnfpwe1cyo2Ny4FNbWGxgU6a4XHwlCEIpyn2xRKaO4YTqGy Gvw+KzbSytRNSLCd+a49uYT4xz0fdbV8Tr+3+3258s+wVFhKH8e2CB8+CEjODvqxKDah R7htKk9bUeocKmOlbPVfHbVg2g2UJS/c95RpgDC58WaSrO/MqRv/Gp9NBJHoIFTX8gI/ zwN63k3qkrR6wv4IzJ/Gtf5eWmUpmSj3zQnsy+P18kA5kaxopkSKJ39w20vUyAuTQw+r W7EQ== 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=u6LJUHB6/l93Bpm8f23YD/lI3k+WXvkK5kmhcQoxcJE=; b=ReSQzPv59jGrIZnFgIcpX+hbG7ZGLBOn2kkmyZyujB/OS/vVtP1VGOhYtkro21w5my BmnQ3DclLudAhCxz9Bv1ue3a3Uz+qveLrnH8kKo7jy/h8pXqq82fJl5pedOM3wOP3yHB y9MG7h4x8EamLHhKNLLP1Ss7vljUnqy1E7BwFO1oOTW16hIu4/6H/Flmq97AUTPw6Anm RPepMMi0bf8oc0WkmwRhKmeWh6P7FU3Myz8E6fRTSx/QylxDsBSVC/Vv2CjGAP6c8l3l qyRXMH5TO5sjshSMPCC1jLpd6GfIJt0op7zgubAVeur68nAGTnh0xp/eTgJt+Ks1vcui +Hgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BZVj6tyY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a63cf0d000000b0051f74e18927si27204116pgg.184.2023.05.01.01.57.44; Mon, 01 May 2023 01:57:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=BZVj6tyY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229947AbjEAIo5 (ORCPT + 99 others); Mon, 1 May 2023 04:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbjEAIom (ORCPT ); Mon, 1 May 2023 04:44:42 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50A381BCB; Mon, 1 May 2023 01:44:28 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 0841C660316A; Mon, 1 May 2023 09:44:25 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682930666; bh=9fCkdJIhomNHjg/BSj98OPViI3ZhU3YXyHQVh8Ob45w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BZVj6tyYWbTCLZL7F8tEBQ6EnB5bFziJVZlhJK8CISd/7uX0pSGgEzzj/XMy2KBD2 /QvfGWkiTQIN9GcJeTzTNbkbEwwW5KMr6QCUYE1XaOER2cXEE1xi4rQDPHgwRxNHFx IfoPqi4/vh6r1B3+0rBo/xeR/UBb+SrH4XYPHQR/9ZTtW+lNa7zTYhz30TD8eTxvMM cYq0U05aDr2s4tOLtIZ6oZ0T58e/1WJXVG2zboG4rcHgV04iXmzny8TnknR3OR1ffZ KxTTfVGvoT8NovSNUSYieUIHtpyA0W5sDc7Ky7nrHZVvhBxZcI9HVw3f+mZUwykkX/ cUT3J0K8LRwKQ== From: Cristian Ciocaltea To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Philipp Zabel , Sebastian Reichel , Shreeya Patel , Kever Yang , Finley Xiao Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 7/8] nvmem: rockchip-otp: Add support for RK3588 Date: Mon, 1 May 2023 11:43:59 +0300 Message-Id: <20230501084401.765169-8-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> References: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764681556308196834?= X-GMAIL-MSGID: =?utf-8?q?1764681556308196834?= Add support for the OTP memory device found on the Rockchip RK3588 SoC. While here, remove the unnecessary 'void *' casts in the OF device ID table. Co-developed-by: Finley Xiao Signed-off-by: Finley Xiao Signed-off-by: Cristian Ciocaltea Reviewed-by: Heiko Stuebner --- drivers/nvmem/rockchip-otp.c | 78 +++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c index 4370d6c5e4e9..022691cadf94 100644 --- a/drivers/nvmem/rockchip-otp.c +++ b/drivers/nvmem/rockchip-otp.c @@ -54,6 +54,19 @@ #define OTPC_TIMEOUT 10000 +/* RK3588 Register */ +#define RK3588_OTPC_AUTO_CTRL 0x04 +#define RK3588_OTPC_AUTO_EN 0x08 +#define RK3588_OTPC_INT_ST 0x84 +#define RK3588_OTPC_DOUT0 0x20 +#define RK3588_NO_SECURE_OFFSET 0x300 +#define RK3588_NBYTES 4 +#define RK3588_BURST_NUM 1 +#define RK3588_BURST_SHIFT 8 +#define RK3588_ADDR_SHIFT 16 +#define RK3588_AUTO_EN BIT(0) +#define RK3588_RD_DONE BIT(1) + struct rockchip_data { int size; const char * const *clocks; @@ -171,6 +184,52 @@ static int px30_otp_read(void *context, unsigned int offset, return ret; } +static int rk3588_otp_read(void *context, unsigned int offset, + void *val, size_t bytes) +{ + struct rockchip_otp *otp = context; + unsigned int addr_start, addr_end, addr_len; + int ret, i = 0; + u32 data; + u8 *buf; + + addr_start = round_down(offset, RK3588_NBYTES) / RK3588_NBYTES; + addr_end = round_up(offset + bytes, RK3588_NBYTES) / RK3588_NBYTES; + addr_len = addr_end - addr_start; + addr_start += RK3588_NO_SECURE_OFFSET; + + buf = kzalloc(array_size(addr_len, RK3588_NBYTES), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + while (addr_len--) { + writel((addr_start << RK3588_ADDR_SHIFT) | + (RK3588_BURST_NUM << RK3588_BURST_SHIFT), + otp->base + RK3588_OTPC_AUTO_CTRL); + writel(RK3588_AUTO_EN, otp->base + RK3588_OTPC_AUTO_EN); + + ret = rockchip_otp_wait_status(otp, RK3588_OTPC_INT_ST, + RK3588_RD_DONE); + if (ret < 0) { + dev_err(otp->dev, "timeout during read setup\n"); + goto read_end; + } + + data = readl(otp->base + RK3588_OTPC_DOUT0); + memcpy(&buf[i], &data, RK3588_NBYTES); + + i += RK3588_NBYTES; + addr_start++; + } + + memcpy(val, buf + offset % RK3588_NBYTES, bytes); + +read_end: + kfree(buf); + + return ret; +} + static int rockchip_otp_read(void *context, unsigned int offset, void *val, size_t bytes) { @@ -213,14 +272,29 @@ static const struct rockchip_data px30_data = { .reg_read = px30_otp_read, }; +static const char * const rk3588_otp_clocks[] = { + "otpc", "apb", "arb", "phy", +}; + +static const struct rockchip_data rk3588_data = { + .size = 0x400, + .clocks = rk3588_otp_clocks, + .num_clks = ARRAY_SIZE(rk3588_otp_clocks), + .reg_read = rk3588_otp_read, +}; + static const struct of_device_id rockchip_otp_match[] = { { .compatible = "rockchip,px30-otp", - .data = (void *)&px30_data, + .data = &px30_data, }, { .compatible = "rockchip,rk3308-otp", - .data = (void *)&px30_data, + .data = &px30_data, + }, + { + .compatible = "rockchip,rk3588-otp", + .data = &rk3588_data, }, { /* sentinel */ }, }; From patchwork Mon May 1 08:44:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 88988 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2558998vqo; Mon, 1 May 2023 01:47:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZVwismsW6/7PEqTFpFvKQrO2zLQeprHp8vdW24/u4guV+4451A95MRHkCtSTozIElW35W X-Received: by 2002:a17:902:f68e:b0:1a9:8ddd:8213 with SMTP id l14-20020a170902f68e00b001a98ddd8213mr17180495plg.57.1682930849205; Mon, 01 May 2023 01:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682930849; cv=none; d=google.com; s=arc-20160816; b=kJ/noGpzpIN5s9U8xRQPIeKoO7NKO4BmXYwzqyUv24LMJR8gYQYnUwEqBHUc0SQz7R qcxz4vIVJapdyxXvUMx04V5NEBDCbzbCV/aOo9Vr0W+Yas1quDQX70KNncMM05tyma7h DvcgDrMJrLlG3q9fSct4xHTYjVFPTx25Hbn2mWiKGYZs5o3zf1OlwhREiK0rdyTgGL/M +8HiKW3+tIB+Hkyp6NP8wX8BsUkWBevl8jv+t25iX983i3oWQcAaCDvh+xN3CzeqOL7o iXtOijjrVXng7fa+n38qx8tKEQToGVY6dLhsi3NNSdilZQ4TvYUQYodMwaQP2lZ9Ti/T QWaQ== 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=kI+u1uUNPs0MBQbuBHe5Fj5GBdDKQq0bEql33UYqfYY=; b=K5XpxHWxj0nfUfh0DQG2IJ3LgLdn5zy7bvJAKiPZVz3ld+QEhey8eTXo9/bovEPNhC jt0RvbK3hClbkReIkFftkKqiHP/ckfydePhCRdxS9MxPQ0/ZIt29Y0JdjgpQmsKJET0A itEXH0JvL3hnQOsOg6FyQEnn2Qk4qO6z2P2rRneGKedp+LOibyuXsoS3d6g+AJ/qBDI5 ByeAmYDDXmKede+DvHG5MslbRk42Mp/ls6EPXbIYn4ieHHkr5wID9ZlpEkA/acqH68BN iXMvtRuUzMdvpBpfcTu4NZol1ft5HQsy04bvJCABGExuye7WtUvqfHy0szMTKnqsR1Ar w+Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=GOIXfJMW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a170903241100b001a66ed4f67fsi27996821plo.292.2023.05.01.01.47.14; Mon, 01 May 2023 01:47:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=GOIXfJMW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232292AbjEAIo7 (ORCPT + 99 others); Mon, 1 May 2023 04:44:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232370AbjEAIoq (ORCPT ); Mon, 1 May 2023 04:44:46 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C55510CA; Mon, 1 May 2023 01:44:29 -0700 (PDT) Received: from localhost (unknown [188.27.34.213]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madras.collabora.co.uk (Postfix) with ESMTPSA id 7776C66031C9; Mon, 1 May 2023 09:44:28 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682930668; bh=rxSmyDetIZGvppZUNfAhus6ErLEiFJ3xF8DbQXYz7ag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GOIXfJMWPnN+iB38HSKAo06ZeYvHke9DTjRs95PihjrzCHA8Z9/9v9acS5hdPHKBW Pf2vJ47cHYzPOP5Tz/2YHeu2EsMMALzj4bZ8980EoquE+7GcfQUfkov3FXTt8XyvdS ggr8sQIXcnWYvaCVjgmpxnxwLj2bYlxta/IUVVpV8uV4m8x965N/zpwf9uQ0mEHjMT ICnbSZQy1ItIsmMaYWrzK8gkTaVgWuF80l18vDx4F5vXKVX6HLxkpN4bRjiVTM+RB7 AycotF6qNKY703ZhMgJIvL80ObyB2x7YAtRZiZUDLXR7V1xQ8UgNgrWVIxej/29tTf 7BmAtbsvY/gVQ== From: Cristian Ciocaltea To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Heiko Stuebner , Philipp Zabel , Sebastian Reichel , Shreeya Patel , Kever Yang , Finley Xiao Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: [PATCH 8/8] arm64: dts: rockchip: Add rk3588 OTP node Date: Mon, 1 May 2023 11:44:00 +0300 Message-Id: <20230501084401.765169-9-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> References: <20230501084401.765169-1-cristian.ciocaltea@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764680897940243160?= X-GMAIL-MSGID: =?utf-8?q?1764680897940243160?= Add DT node for Rockchip RK3588/RK3588S OTP memory. Co-developed-by: Finley Xiao Signed-off-by: Finley Xiao Signed-off-by: Cristian Ciocaltea --- arch/arm64/boot/dts/rockchip/rk3588s.dtsi | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi index 767084a1ec43..0abcd51d7d66 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588s.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588s.dtsi @@ -1822,6 +1822,60 @@ spi4: spi@fecb0000 { status = "disabled"; }; + otp: efuse@fecc0000 { + compatible = "rockchip,rk3588-otp"; + reg = <0x0 0xfecc0000 0x0 0x400>; + clocks = <&cru CLK_OTPC_NS>, <&cru PCLK_OTPC_NS>, + <&cru CLK_OTPC_ARB>, <&cru CLK_OTP_PHY_G>; + clock-names = "otpc", "apb", "arb", "phy"; + resets = <&cru SRST_OTPC_NS>, <&cru SRST_P_OTPC_NS>, + <&cru SRST_OTPC_ARB>; + reset-names = "otpc", "apb", "arb"; + #address-cells = <1>; + #size-cells = <1>; + + cpu_code: cpu-code@2 { + reg = <0x02 0x2>; + }; + + otp_id: id@7 { + reg = <0x07 0x10>; + }; + + otp_cpu_version: cpu-version@1c { + reg = <0x1c 0x1>; + bits = <3 3>; + }; + + cpub0_leakage: cpu-leakage@17 { + reg = <0x17 0x1>; + }; + + cpub1_leakage: cpu-leakage@18 { + reg = <0x18 0x1>; + }; + + cpul_leakage: cpu-leakage@19 { + reg = <0x19 0x1>; + }; + + log_leakage: log-leakage@1a { + reg = <0x1a 0x1>; + }; + + gpu_leakage: gpu-leakage@1b { + reg = <0x1b 0x1>; + }; + + npu_leakage: npu-leakage@28 { + reg = <0x28 0x1>; + }; + + codec_leakage: codec-leakage@29 { + reg = <0x29 0x1>; + }; + }; + dmac2: dma-controller@fed10000 { compatible = "arm,pl330", "arm,primecell"; reg = <0x0 0xfed10000 0x0 0x4000>;