From patchwork Tue Mar 21 10:24:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 72792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1695799wrt; Tue, 21 Mar 2023 03:30:04 -0700 (PDT) X-Google-Smtp-Source: AK7set/dfFXwD+RObf/Jo8NKN5luM99QjMc6jf59k8c34sXYohofJUOEHtpGFdX32NFkNvQjfNZT X-Received: by 2002:aa7:9dc1:0:b0:5a8:4861:af7d with SMTP id g1-20020aa79dc1000000b005a84861af7dmr2151398pfq.20.1679394604098; Tue, 21 Mar 2023 03:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679394604; cv=none; d=google.com; s=arc-20160816; b=uO8pqwpJJm1z85HGLZvLSHHuHFmkY9hIMqeD/2i6A3urptiOxBAjbrXyX7ZsgcMQYB KUB5NRZw5Bl4TXtAy2GkJlcvIzG9hEDZHMJttfI0g0MEEkILC/FohYi0zdxxiuVMmm+8 YfVdU1HlJTQAq8gCL534FT7bAz49jBE2Pr++N/mkWtcS1wEJBVTXX+I8TenlxCqrxhBX mWVPC9JpqUb2C+cpPx88qspFmlR0y25BbXTgSAU/OXCx55KRISTq4Iy9guKOH7olCN3K 17v87P47ZPup2OhA4hqhtXqcQZ3mFn1WZ7YWQNsS5FSX3xHm2uiUCRFXh18YkhTmNlgD 8eDA== 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=NcNwNDUcozJ4ihl03xpaC0MK0yzIXoC3GmNplcK5VuY=; b=Lm2PVkqyNna+nujXajEYtRzCvKtEvE1eH0WC6HHQ4+OOkErmVNWzSLhJwKBWBZRhLg gO8UzdaU70/wdYNdSqGvb/iJYmA/f2DshWOytS58GpG1mQxFe2ULzJGKrTlKkgHpDtDk +n11R4XucoHt2NOPgOMSxVcEZRopQWS1VmTgCb0fZ/ZqQV/3yA8bfcKvscZvMq5KNCG0 JxmrJ+X/JcEQEi/JvsCyzAjTGtGGmB5ts05yXJsh/im5mZkrM/mVQgWy/qPoIOKhGalz 1e6oHiGLsCCoKe9Ltarydva9IomFDZdsVwHfqJzEOU+1F6s4etT5c4nWr0dayLVXz4MV DC9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SyoDu8ZM; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x71-20020a62864a000000b006233c7e8887si12967563pfd.90.2023.03.21.03.29.51; Tue, 21 Mar 2023 03:30:04 -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=@gmail.com header.s=20210112 header.b=SyoDu8ZM; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230135AbjCUKY6 (ORCPT + 99 others); Tue, 21 Mar 2023 06:24:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbjCUKYm (ORCPT ); Tue, 21 Mar 2023 06:24:42 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 398CC166DA; Tue, 21 Mar 2023 03:24:27 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id a11so4443365lji.6; Tue, 21 Mar 2023 03:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679394265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NcNwNDUcozJ4ihl03xpaC0MK0yzIXoC3GmNplcK5VuY=; b=SyoDu8ZMUOI+lX1BtyTlX1QnIVrvgtQR2ZmTBTIUIYIG1/bWFsPm1ACl3tv2f7elO6 InRVkS9KlJmbSmlfcbMDiNulycEnUpkUV3V1mQShUq8bVOo8wNEEht8V+xCYxTOLXKT+ jNyqnjxEdHfF8r8qceJ3RgCk8TL8uSFCtEfrfMlBhhHYDz9V5XibZron81KNl5wObMDB nUCZhy27UEGrEsMKYBRNXh1A0YD5+JZZclYEr6scZ2+3LOjnm6vF4psh7nn7fy8ow/hV DJSnNKb2bC5nqj4GaR8soTPKS73+l30w869VxUwDGW27aaspFUFAW2iW2Ewv4gf/Wn21 hcJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679394265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NcNwNDUcozJ4ihl03xpaC0MK0yzIXoC3GmNplcK5VuY=; b=s3pWv+arR8co/SMgvFMSif4/VnOvVnpUoIqqWGmEH6BZmFHbwYtTdnk2MlRpJNHAre 6lLWq4HIWqzbdQSvybhZLdxLo/Jd0ZSoLFoR88cAbJPkgF3KQYng6mMTF+P27DfhnL6I JJBmmDtVj1hJM4w6pZEa+dRTaKnyAvzn8+2owrT1KeqxBHQO2OrQrgB1whVuzo6r9zdf 5PgTPuzvjl+bNjOpPVw4w74sab0rkC607c4DJQtNYuDkWY5ETVMIF938g9G+r7U17XMC P3l3u8TIi96Dd83WKUNI9dc6Et7gKW4HisK8jsRN5AOWgucLPV5zEl9rGeJpXrg1NCel lVwA== X-Gm-Message-State: AO0yUKUyv5NE9BXSDjDtQAhII3lIX/qJYgCZUy95xkq/QJwBmefrPRIq r4AA3S3ud5itvBH+aIIA30M= X-Received: by 2002:a05:651c:223:b0:29c:9223:2f6b with SMTP id z3-20020a05651c022300b0029c92232f6bmr669574ljn.30.1679394265330; Tue, 21 Mar 2023 03:24:25 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id n12-20020a2e904c000000b00299f0194108sm2163069ljg.31.2023.03.21.03.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 03:24:24 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla Cc: Greg Kroah-Hartman , Miquel Raynal , Michael Walle , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFm?= =?utf-8?b?YcWCIE1pxYJlY2tp?= Subject: [PATCH V5 1/3] dt-bindings: nvmem: layouts: add fixed-layout Date: Tue, 21 Mar 2023 11:24:16 +0100 Message-Id: <20230321102418.4190-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230321102418.4190-1-zajec5@gmail.com> References: <20230321102418.4190-1-zajec5@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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?1760972876479416428?= X-GMAIL-MSGID: =?utf-8?q?1760972876479416428?= From: Rafał Miłecki With the introduction of NVMEM layouts, new NVMEM content structures should be defined as such. We should also try to convert / migrate existing NVMEM content bindings to layouts. This commit handles fixed NVMEM cells. So far they had to be defined directly - as device subnodes. With this change it's allowed to put them in the DT node named "nvmem-layout". Having NVMEM cells in separated node is preferred as it draws a nice line between NVMEM device and its content. It results in cleaner bindings. FWIW a very similar situation has happened to MTD devices and their partitions: see commit 5d96ea42eb63 ("dt-bindings: mtd: Clarify all partition subnodes"). Signed-off-by: Rafał Miłecki --- .../bindings/nvmem/layouts/fixed-cell.yaml | 31 ++++++++++++ .../bindings/nvmem/layouts/fixed-layout.yaml | 49 +++++++++++++++++++ .../bindings/nvmem/layouts/nvmem-layout.yaml | 5 +- .../devicetree/bindings/nvmem/nvmem.yaml | 19 +------ 4 files changed, 83 insertions(+), 21 deletions(-) create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml new file mode 100644 index 000000000000..e698098450e1 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/layouts/fixed-cell.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Fixed offset & size NVMEM cell + +maintainers: + - Rafał Miłecki + - Srinivas Kandagatla + +properties: + reg: + maxItems: 1 + + bits: + $ref: /schemas/types.yaml#/definitions/uint32-array + items: + - minimum: 0 + maximum: 7 + description: + Offset in bit within the address range specified by reg. + - minimum: 1 + description: + Size in bit within the address range specified by reg. + +required: + - reg + +additionalProperties: true diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml new file mode 100644 index 000000000000..f7496ba28f33 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/layouts/fixed-layout.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVMEM layout for fixed NVMEM cells + +description: + Many NVMEM devices have hardcoded cells layout (offset and size of defined + NVMEM content doesn't change). + + This binding allows defining such NVMEM layout with its cells. It can be used + on top of any NVMEM device. + +maintainers: + - Rafał Miłecki + +properties: + compatible: + const: fixed-layout + + "#address-cells": + const: 1 + + "#size-cells": + const: 1 + +patternProperties: + "@[a-f0-9]+$": + type: object + $ref: fixed-cell.yaml + +required: + - compatible + +additionalProperties: false + +examples: + - | + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + calibration@4000 { + reg = <0x4000 0x100>; + }; + }; diff --git a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml index 8512ee538c4c..3b40f7880774 100644 --- a/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml +++ b/Documentation/devicetree/bindings/nvmem/layouts/nvmem-layout.yaml @@ -18,16 +18,13 @@ description: | perform their parsing. The nvmem-layout container is here to describe these. oneOf: + - $ref: fixed-layout.yaml - $ref: kontron,sl28-vpd.yaml - $ref: onie,tlv-layout.yaml properties: compatible: true - '#address-cells': false - - '#size-cells': false - required: - compatible diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml index 75bb93dda9df..b79f1bb795fb 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -49,23 +49,8 @@ properties: patternProperties: "@[0-9a-f]+(,[0-7])?$": type: object - - properties: - reg: - maxItems: 1 - description: - Offset and size in bytes within the storage device. - - bits: - $ref: /schemas/types.yaml#/definitions/uint32-array - items: - - minimum: 0 - maximum: 7 - description: - Offset in bit within the address range specified by reg. - - minimum: 1 - description: - Size in bit within the address range specified by reg. + $ref: layouts/fixed-cell.yaml + deprecated: true additionalProperties: true From patchwork Tue Mar 21 10:24:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 72802 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1703160wrt; Tue, 21 Mar 2023 03:51:51 -0700 (PDT) X-Google-Smtp-Source: AK7set+CfQ7UbzKJH1wVL+ZqELOrmK1SOg40NIFTVSt8/DYUYHISUN+iN41sGo02Efjd0B+aXupj X-Received: by 2002:a17:90b:350c:b0:23f:2c65:fab7 with SMTP id ls12-20020a17090b350c00b0023f2c65fab7mr2167537pjb.42.1679395911351; Tue, 21 Mar 2023 03:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679395911; cv=none; d=google.com; s=arc-20160816; b=bxnk2LGn+AayemlmX7vhYjQ8D02dDy6J1A4DNA1HrT4U7xoNMPo2XB5pLtWpUohJNy IO5RjsSx7UxxPYfLV13QIRp3jyNCJAc6U1SOI76f+rwGS9hzmNtZEbu3lVCu78gJeQgD d/Q9LtuwPZV/QhdPXHnanQexNSL7w0Lx0oVuu4BpnsK0/Zm/agmRhNCnslATy8r5zjzK IqE4GDv5GuEYVDxZDjVNPS9NRM1ayCq57Q7uFb3VZj6Q3qwHYGClxhZo6+H9Ma+uS0bN z67WTXGlVI1KV+dkd/RuzqJR308Z4YeSY3SJXS9iFovRrKLfKf5soRWgtwny17YRhgsB Bh0Q== 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=TlFYzvPaNc4+r1fF+4ETWq25exQj+hE48K2I2gE4XAQ=; b=SctF3GJueDS6f5kqW4lrJf5PgaDu9/uUhKryCYTXguegRYt2gDr+4FuagVIbSBBjw3 kYGN0V5pHbHv0pVivvh87lSA8tLP2tparuCRA0lZk3zz1oBEzjOF7nsD+ceh1VtFXOz3 Ep0crFeUZ9lqOrQocfX63i+wIv5jJ1d4OpZzRgTnbaDNPsnOoJeQp9WlL1RUUsk0vnw+ j9V5F8qXH4Mv1SWcR+nzzGE3cyU2FH0NXV5ZGGvXlo050YFrw/e9HepIU46Q3i8h6mnM +svOdcGExa9nhWttR96d/8baUwTtx3EMvKE75UGJ9hRA3Hyi+9x784lYJdLZ/gHm4avO YEow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=in1ot4HN; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu8-20020a17090b1b0800b002347fd03c90si20697585pjb.29.2023.03.21.03.51.36; Tue, 21 Mar 2023 03:51:51 -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=@gmail.com header.s=20210112 header.b=in1ot4HN; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229854AbjCUKZC (ORCPT + 99 others); Tue, 21 Mar 2023 06:25:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbjCUKYn (ORCPT ); Tue, 21 Mar 2023 06:24:43 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D975918B08; Tue, 21 Mar 2023 03:24:28 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id q14so587954ljm.11; Tue, 21 Mar 2023 03:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679394267; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TlFYzvPaNc4+r1fF+4ETWq25exQj+hE48K2I2gE4XAQ=; b=in1ot4HNg4D0Zl6IetwLv2Twu6rMFjNgcqqzIJVhQeHgi3KQh4qiutrKGa3/8fu5Xw 2yA9KTbmoyQCiCQskH7su5+akiRxGhHFAW1XZouCNVFYADNlSj+yO3/s0eAXCDOFdibO 0Q5h9iaYUzVeV2kuoYKeBd61UnK0E2B289+4B/FBj6r2Cvgf4Ug/RqnteZYQw7hYE7cT 2i1D3o8wEXPHJxnrV+Svn5RkhfdFtfXARqjkMR2r2ErAZf11MhfPtVhDW5mJ7Zs4OfV9 sXqoKnxQWGgElib3o8ODymdeWX/byG/4maxcsNs/84tTdmrIptW68ZgUOhno50vNGf6z 4/MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679394267; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TlFYzvPaNc4+r1fF+4ETWq25exQj+hE48K2I2gE4XAQ=; b=RTECmv7gZpYQY8cd3saDew3gA1g+k6nCzg/XwqJ2oc4cWsFL0M6UH7gSdMWdAEHOkC LoU07O5ZWISsdGQG2TWVdvWqLDU3U2X6qpMFOkIARYtLhWFhWJ9qixPhv0rbo3ww8wlw lioCSw9xR2C6a/Oc/Ck/zfkQO9U8S0EAY4LgDPTZu1tXm2AgUJIG0pZmpSl/Zcmos05k r9l07s8XZyk94NmITY1OWPLrIcb3L1QEKHoSTIlRzz1der7D+H+Tawx9DVIuUBoe1JO5 4UjUEgYxb+Wyyumb/YdBSLC70bES+mhhiwZCAJPh7Nt+XadAXKjF21WpOaxOaXUTQI3Q MVyA== X-Gm-Message-State: AO0yUKUIQH3so2bviKHT1XqHxuuD4mWKWBa5FSyQL/d/4oBdSZY875k6 9S663/J19uMDKEvaYk8IoXU= X-Received: by 2002:a2e:9d0c:0:b0:299:57eb:ef3a with SMTP id t12-20020a2e9d0c000000b0029957ebef3amr693229lji.2.1679394267021; Tue, 21 Mar 2023 03:24:27 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id n12-20020a2e904c000000b00299f0194108sm2163069ljg.31.2023.03.21.03.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 03:24:26 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla Cc: Greg Kroah-Hartman , Miquel Raynal , Michael Walle , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFm?= =?utf-8?b?YcWCIE1pxYJlY2tp?= Subject: [PATCH V5 2/3] dt-bindings: nvmem: convert base example to use NVMEM fixed cells layout Date: Tue, 21 Mar 2023 11:24:17 +0100 Message-Id: <20230321102418.4190-3-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230321102418.4190-1-zajec5@gmail.com> References: <20230321102418.4190-1-zajec5@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1760974247290723474?= X-GMAIL-MSGID: =?utf-8?q?1760974247290723474?= From: Rafał Miłecki With support for the "fixed-layout" binding it's possible and preferred now to define fixed NVMEM cells in the layout node. Do that for the example binding. Signed-off-by: Rafał Miłecki Reviewed-by: Rob Herring --- .../devicetree/bindings/nvmem/nvmem.yaml | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml index b79f1bb795fb..980244100690 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -68,24 +68,30 @@ examples: /* ... */ - /* Data cells */ - tsens_calibration: calib@404 { - reg = <0x404 0x10>; - }; - - tsens_calibration_bckp: calib_bckp@504 { - reg = <0x504 0x11>; - bits = <6 128>; - }; - - pvs_version: pvs-version@6 { - reg = <0x6 0x2>; - bits = <7 2>; - }; - - speed_bin: speed-bin@c{ - reg = <0xc 0x1>; - bits = <2 3>; + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + /* Data cells */ + tsens_calibration: calib@404 { + reg = <0x404 0x10>; + }; + + tsens_calibration_bckp: calib_bckp@504 { + reg = <0x504 0x11>; + bits = <6 128>; + }; + + pvs_version: pvs-version@6 { + reg = <0x6 0x2>; + bits = <7 2>; + }; + + speed_bin: speed-bin@c{ + reg = <0xc 0x1>; + bits = <2 3>; + }; }; }; From patchwork Tue Mar 21 10:24:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 72793 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1695859wrt; Tue, 21 Mar 2023 03:30:11 -0700 (PDT) X-Google-Smtp-Source: AK7set/W1Isbtkf3S+katVpnIdO+Y1nCu9CwY+BODgDkwmx7WmkCrueWZYIOEJpNWl74Zs8CbTOh X-Received: by 2002:a17:90a:1903:b0:23b:2f4f:1a9b with SMTP id 3-20020a17090a190300b0023b2f4f1a9bmr2122319pjg.37.1679394610930; Tue, 21 Mar 2023 03:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679394610; cv=none; d=google.com; s=arc-20160816; b=exuT9sJQ7sJ3QDWd8zZcX0TU5m+P0BwpoO2iG7x8JtzbttF5NGK9pvtcB35kMtOfe1 iUk/wvedcHDfPakWUmlGZwtcQMO457aPYHoTygizy9lMRgGVnFEfSVhuI0exeq2j8U9U BSne9bG3OUWv6hE658iAW1E9pYLfO/Joh2YYFUGhpmgmiq8NohqAkNOnzxT0c2Ubjz3q 5NN2LVMoxqYiWa70RN2si67F11gbJkPSKOJ3cvVua7WsRd8a2952vw43wbTpaJ/EIS/8 eeTcXe7EbBb/w8dfzVYrPHg0JeCFAsgKYrMdPBmF/BidtraVoiKBo9irQm5Hz+INPeIv FA7Q== 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=aWn/7mbklD+A+VP8Q0o9PMepwQzDExkOlaUCk9c90go=; b=UEpY5HfmxlflDzPJnlrYW90gz6BJ2zUG9pxen6GGQav4QPu+35iOcKQRcnrnHOg/l4 DkqWSs2ZbYd7UFkoFSmMNn+U+8qcXxJiJL1YC6w5GUKrGbXWlGqEWiZyFT2cRjQAzlwG irMm7mwIsrCuqEm3TdZ6lov28mvQbWixGIGbv+ZHYAl5gp5KBzBZKa9XEVhulB2sjMpY oP5RmLRXUnxXMb14kxbQSaDUDtteeJ8E4+Y1aX4hJWwyDht4d/U9VJcKhO447SVSdXrw 12tb7BU6btVePQWN3jBBWURtnkevWjsqrGm5YkbOu7QiJV3Bblck7WyT8aU/lvcicvDU qqJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iquuKDMl; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a6552cb000000b0050bef74a9b1si12893299pgp.632.2023.03.21.03.29.58; Tue, 21 Mar 2023 03:30:10 -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=@gmail.com header.s=20210112 header.b=iquuKDMl; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230156AbjCUKZG (ORCPT + 99 others); Tue, 21 Mar 2023 06:25:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbjCUKYo (ORCPT ); Tue, 21 Mar 2023 06:24:44 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42F541A663; Tue, 21 Mar 2023 03:24:30 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id t11so18465585lfr.1; Tue, 21 Mar 2023 03:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679394268; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aWn/7mbklD+A+VP8Q0o9PMepwQzDExkOlaUCk9c90go=; b=iquuKDMl6Sqaw/4fFi35QnrEmF2ISe0CqEPGKCaT2wkhZo/3Yz10fW2lj6LbTbJymI bdxwZ4WL3jPu8LAnQQa08mrHlhJ7VTpicEm/DuObAWhtOFTiU07Upmk5Sdw6Wk1r9+7m 5YLoSxx4zCZ3IqIu4es5M2p05CPoScm4iH2Pz7QEFiyrzCVctSVdsT/viItWjJrhv7fi zYV0KK1ACS9w+6/SoEVz8zouJZPqndunovcm82iQVZ6Kgu3xbuSjUarTTbuPekjzCR7Z jKpTmL5DWjmERKHOSYfcZzSDX0f7X69xk2x3PUPpwODw9qC2cB3ab/Y1UDpnA3rw99Ft e77Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679394268; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aWn/7mbklD+A+VP8Q0o9PMepwQzDExkOlaUCk9c90go=; b=4pB18e+OUD232VBcLkxhZiu2dDASgvDC4lOyfx9k3ck/kWGNM7ZGjFqsJv7hkiQVDW YsV/a7yS04NKr0m5J9ChaY/iDw7lS6EbD4fNgwITGi6wozuISEzY2Xc6RfGNmW9WDQlB je2Fv0FzHLLxLrRyKG2Uw7yIQvEKnqZvSwf/NGJ9pVyC5Nv589pkX/81zLm5NgpT7QOQ OdVgddg5cEhsdu1mMt/p9SuKOQJElWFhgcA+16BvHYc1AZWFST0iVWU1E48BCZkeGP+6 bK5WsNy/IKwn8eB+umZAaQrE1ZXirujs4lQQaB+4WPs+vuFP3Z65ylCUCIDjpxzHXTyy Jf5Q== X-Gm-Message-State: AO0yUKWfyJ14lC//UsA9LgG5hGOlw6BS92za7kjT4fC3hOSXdEh66OdK nsTJD4uAHOAFjt8oZE+cvmo= X-Received: by 2002:ac2:4ac8:0:b0:4e0:2455:3ade with SMTP id m8-20020ac24ac8000000b004e024553ademr603297lfp.60.1679394268654; Tue, 21 Mar 2023 03:24:28 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id n12-20020a2e904c000000b00299f0194108sm2163069ljg.31.2023.03.21.03.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 03:24:28 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla Cc: Greg Kroah-Hartman , Miquel Raynal , Michael Walle , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFm?= =?utf-8?b?YcWCIE1pxYJlY2tp?= Subject: [PATCH V5 3/3] nvmem: core: add support for fixed cells *layout* Date: Tue, 21 Mar 2023 11:24:18 +0100 Message-Id: <20230321102418.4190-4-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230321102418.4190-1-zajec5@gmail.com> References: <20230321102418.4190-1-zajec5@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1760972883364295779?= X-GMAIL-MSGID: =?utf-8?q?1760972883364295779?= From: Rafał Miłecki This adds support for the "fixed-layout" NVMEM layout binding. It allows defining NVMEM cells in a layout DT node named "nvmem-layout". While NVMEM subsystem supports layout drivers it has been discussed that "fixed-layout" may actually be supperted internally. It's because: 1. It's a very basic layout 2. It allows sharing code with legacy syntax parsing 3. It's safer for soc_device_match() due to -EPROBE_DEFER 4. This will make the syntax transition easier Signed-off-by: Rafał Miłecki Reviewed-by: Michael Walle --- drivers/nvmem/core.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 212c5ba5789f..591b640f53dd 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -694,7 +694,7 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem) return 0; } -static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) +static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np) { struct nvmem_layout *layout = nvmem->layout; struct device *dev = &nvmem->dev; @@ -702,7 +702,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) const __be32 *addr; int len, ret; - for_each_child_of_node(dev->of_node, child) { + for_each_child_of_node(np, child) { struct nvmem_cell_info info = {0}; addr = of_get_property(child, "reg", &len); @@ -740,6 +740,28 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) return 0; } +static int nvmem_add_cells_from_legacy_of(struct nvmem_device *nvmem) +{ + return nvmem_add_cells_from_dt(nvmem, nvmem->dev.of_node); +} + +static int nvmem_add_cells_fixed(struct nvmem_device *nvmem) +{ + struct device_node *layout_np; + int err = 0; + + layout_np = of_nvmem_layout_get_container(nvmem); + if (!layout_np) + return 0; + + if (of_device_is_compatible(layout_np, "fixed-layout")) + err = nvmem_add_cells_from_dt(nvmem, layout_np); + + of_node_put(layout_np); + + return err; +} + int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner) { layout->owner = owner; @@ -970,7 +992,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (rval) goto err_remove_cells; - rval = nvmem_add_cells_from_of(nvmem); + rval = nvmem_add_cells_from_legacy_of(nvmem); if (rval) goto err_remove_cells; @@ -980,6 +1002,10 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (rval) goto err_remove_cells; + rval = nvmem_add_cells_fixed(nvmem); + if (rval) + goto err_remove_cells; + rval = nvmem_add_cells_from_layout(nvmem); if (rval) goto err_remove_cells;