From patchwork Fri Jan 15 15:38:59 2021 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: 364829 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 4DC50C4332B for ; Fri, 15 Jan 2021 15:40:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16CAF2388B for ; Fri, 15 Jan 2021 15:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732751AbhAOPj7 (ORCPT ); Fri, 15 Jan 2021 10:39:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731623AbhAOPj7 (ORCPT ); Fri, 15 Jan 2021 10:39:59 -0500 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64ECCC0613D3; Fri, 15 Jan 2021 07:39:18 -0800 (PST) Received: by mail-lj1-x22c.google.com with SMTP id n8so2041664ljg.3; Fri, 15 Jan 2021 07:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=srgjk5QVmLK3FqpIHac5AnRKp8slJiIMm3vehhv+DqU=; b=rvx+H0Qmrb/n8UlxFo7AwfzpD8AvmON747N0xAQWZMOMoqQ0OL0/5baVgkHSaWmC/p Mj1BV9d7TQG2L8lnoJfpvQTgZQJsx83QWH+CTBtp26ZXGJep7yS6qnq2uQcnxVIISGLh bWK097qEVIUgDIO9Dxgkn5KRuMq+Dj0lsN6WDazstZSuanVzmWYxSHqxilmzB3GWefkk TDa0CVDHzn/fuKj7oBfBR4i2EJuKFLh4igDaQ5TbxZ3gEDRNpxGrtuJCaE/AnmRa/utq UcGEOA+//9WHn4LKCU/ASjfQ1OllFemiUb0sXAiMnbP5x086r7T+GzIXMwJUlTp8lbiO QgLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=srgjk5QVmLK3FqpIHac5AnRKp8slJiIMm3vehhv+DqU=; b=opMux2KF1snd44aVyIulUlzT6EvewZ/T48hAOkXWmVR5znf0qJk+P2ap7geeT27KKE slNPyTXujcIx0CAZgjPi9+5EqIwiwSz5iW4IvjzBLlBw/YjQVjdNAvtkyHK22AGb4EEJ VvknW6qJFzrOVKlxXxA68c1A02KE+dUWe16MvYyGY3OR281bAPqHyf7iFbBh9PXcFULJ Xpj3ViGufgmy6c/WM1wIKPDsu3W/UG2o0hJtYK5bgSgXdBWPiqXY7aajau19hfVLo81M CHpU8Qdj9AVZ9yhhv5v7BsmeHlrgqibomsPcOqlap0rhyFGR8qbn8Amm8sJJrSMROWLI VPQA== X-Gm-Message-State: AOAM531rs66SLFMVcQRXtCwhmDRZXXc7WTngyXpIyvdhI4iRXT3VYY95 fDV6cPHDa00VEEVx6fmddC8= X-Google-Smtp-Source: ABdhPJwZjsLS3nFSwGHZRWYqxl3I/ZmEVsseUeiRs/KOrZkYVTEFxEN9eg31UyjKv5J8wc64/oYLLA== X-Received: by 2002:a2e:8416:: with SMTP id z22mr5535221ljg.347.1610725155447; Fri, 15 Jan 2021 07:39:15 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id j2sm931567lfe.134.2021.01.15.07.39.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:39:14 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring Cc: Boris Brezillon , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 1/3] dt-bindings: mtd: move partition binding to its own file Date: Fri, 15 Jan 2021 16:38:59 +0100 Message-Id: <20210115153901.31052-1-zajec5@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Rafał Miłecki Single partition binding is quite common and may be: 1. Used by multiple parsers 2. Extended for more specific cases Move it to separated file to avoid code duplication. Signed-off-by: Rafał Miłecki Reviewed-by: Rob Herring --- .../mtd/partitions/fixed-partitions.yaml | 33 +------------ .../bindings/mtd/partitions/partition.yaml | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 32 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/partition.yaml diff --git a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml index 6d4a3450e064..ea4cace6a955 100644 --- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml +++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml @@ -27,38 +27,7 @@ properties: patternProperties: "@[0-9a-f]+$": - description: node describing a single flash partition - type: object - - properties: - reg: - description: partition's offset and size within the flash - maxItems: 1 - - label: - description: The label / name for this partition. If omitted, the label - is taken from the node name (excluding the unit address). - - read-only: - description: This parameter, if present, is a hint that this partition - should only be mounted read-only. This is usually used for flash - partitions containing early-boot firmware images or data which should - not be clobbered. - type: boolean - - lock: - description: Do not unlock the partition at initialization time (not - supported on all devices) - type: boolean - - slc-mode: - description: This parameter, if present, allows one to emulate SLC mode - on a partition attached to an MLC NAND thus making this partition - immune to paired-pages corruptions - type: boolean - - required: - - reg + $ref: "partition.yaml#" required: - "#address-cells" diff --git a/Documentation/devicetree/bindings/mtd/partitions/partition.yaml b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml new file mode 100644 index 000000000000..e1ac08064425 --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/partitions/partition.yaml @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mtd/partitions/partition.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Partition + +description: | + This binding describes a single flash partition. Each partition must have its + relative offset and size specified. Depending on partition function extra + properties can be used. + +maintainers: + - Rafał Miłecki + +properties: + reg: + description: partition's offset and size within the flash + maxItems: 1 + + label: + description: The label / name for this partition. If omitted, the label + is taken from the node name (excluding the unit address). + + read-only: + description: This parameter, if present, is a hint that this partition + should only be mounted read-only. This is usually used for flash + partitions containing early-boot firmware images or data which should + not be clobbered. + type: boolean + + lock: + description: Do not unlock the partition at initialization time (not + supported on all devices) + type: boolean + + slc-mode: + description: This parameter, if present, allows one to emulate SLC mode + on a partition attached to an MLC NAND thus making this partition + immune to paired-pages corruptions + type: boolean + +required: + - reg + +additionalProperties: true From patchwork Fri Jan 15 15:39:00 2021 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: 363990 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 90832C43331 for ; Fri, 15 Jan 2021 15:40:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52132207D0 for ; Fri, 15 Jan 2021 15:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732380AbhAOPkD (ORCPT ); Fri, 15 Jan 2021 10:40:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733116AbhAOPkD (ORCPT ); Fri, 15 Jan 2021 10:40:03 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15FA9C061794; Fri, 15 Jan 2021 07:39:22 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id o17so13757756lfg.4; Fri, 15 Jan 2021 07:39:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7im1QXvoU9pnwhNU516Up7aImtiZpLV/k+KA0KsbcAE=; b=qbSvhrRlFFWplAJZXDw8nkCVTFgkNpvW+CyQHlqom83lOcBI6lP1ZUAnLA1RwqKiY4 qots7YAfLkvtJkf9rHTne2G2A+dNqeyMUowh3mIVK7zIGxIOoSz59mfTRn37SiX0z1li acO8itK70B+ig9uU27eL9844ScY9NF/rj6Ps6C3YzjwYWjCYPy2CfoEZiQN6/HXomN5j 7fWKASDPDdbLGFc7lEpd2Dc4rK/zUId06Zlqw3MtFOgn9ebyse4YDzOTmT0er5p3br2B quiDC3Zk20fvOrP62KKt9hYM63iuyyOgWDn8Rzk1AQkyxhYUPeF7p6yixV0DSENtNqIs k4sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7im1QXvoU9pnwhNU516Up7aImtiZpLV/k+KA0KsbcAE=; b=d75wQoAaF9UR+gOjW3F+/nD7lBZ/TUPr4a6VKmwg+7vSnjkf2TQ4Ke2/cq0Njkf/kb Z7XLUHNJK+LrmYm3YAEtEfJ7iScdqaG8Z1XYk4c3ijAetGcZXyLlUnxgYy4AGMcWLsfK PdNLsQydUcv+BKmhkNtzHGAfw1dFguqXR+KsO/hdGUzML6C0p+8ScXm8z9WgYOETuWdM oDkFySp6WKJRbzWW82NrqnG75glKLKsvxkVjOkV52s5EB/O5Q25MXxmyWRBpZdBRPQ10 plNu8ptRYfEJGnyB8l76R8+9SvpXObRhpsuJGaxQkQnlUjqtV1il8IRw6vtxGWK4AvZO TPaA== X-Gm-Message-State: AOAM532OhbRyXrR0El3b/AQHAlDZFytop2SJWCZzDM5YuNO+lqe8SC89 4EHyDOrxEz4LuW1vO9MEO9A= X-Google-Smtp-Source: ABdhPJzGH6aFky/BcP4EsxiG2NISHHzisLOpSgA1WLSUZmC8Spq6xttOYv7Ularabh36qAmG5jLxXw== X-Received: by 2002:a19:9d3:: with SMTP id 202mr5640760lfj.388.1610725160638; Fri, 15 Jan 2021 07:39:20 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id j2sm931567lfe.134.2021.01.15.07.39.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:39:20 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring Cc: Boris Brezillon , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 2/3] dt-bindings: mtd: add binding from BCM4908 partitions Date: Fri, 15 Jan 2021 16:39:00 +0100 Message-Id: <20210115153901.31052-2-zajec5@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153901.31052-1-zajec5@gmail.com> References: <20210115153901.31052-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Rafał Miłecki BCM4908 uses fixed partitions layout but function of some partitions may vary. Some devices use multiple firmware partitions and those should be marked to let system discover their purpose. Signed-off-by: Rafał Miłecki --- .../partitions/brcm,bcm4908-partitions.yaml | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml diff --git a/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml new file mode 100644 index 000000000000..4090b61a3da7 --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/partitions/brcm,bcm4908-partitions.yaml @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mtd/partitions/brcm,bcm4908-partitions.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom BCM4908 partitioning + +description: | + Broadcom BCM4908 CFE bootloader supports two firmware partitions. One is used + for regular booting, the other is treated as fallback. + + This binding allows defining all fixed partitions and marking those containing + firmware. System can use that information e.g. for booting or flashing + purposes. + +maintainers: + - Rafał Miłecki + +properties: + compatible: + const: brcm,bcm4908-partitions + + "#address-cells": true + + "#size-cells": true + +patternProperties: + "@[0-9a-f]+$": + allOf: + - $ref: "partition.yaml#" + - properties: + compatible: + const: brcm,bcm4908-firmware + +required: + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + partitions { + compatible = "brcm,bcm4908-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "cferom"; + reg = <0x0 0x100000>; + }; + + partition@100000 { + compatible = "brcm,bcm4908-firmware"; + reg = <0x100000 0xf00000>; + }; + + partition@1000000 { + compatible = "brcm,bcm4908-firmware"; + reg = <0x1000000 0xf00000>; + }; + + partition@1f00000 { + label = "calibration"; + reg = <0x1f00000 0x100000>; + }; + }; From patchwork Fri Jan 15 15:39:01 2021 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: 363989 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 83593C433DB for ; Fri, 15 Jan 2021 15:40:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 571E22339D for ; Fri, 15 Jan 2021 15:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731581AbhAOPkJ (ORCPT ); Fri, 15 Jan 2021 10:40:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733185AbhAOPkH (ORCPT ); Fri, 15 Jan 2021 10:40:07 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38763C061795; Fri, 15 Jan 2021 07:39:26 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id o19so13760688lfo.1; Fri, 15 Jan 2021 07:39:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lmKofo5XL6pcYRLvYw3BVNxNonI1i89zwQf4fYPG/TE=; b=KWm++DFKRV44YTJ9Y1Uy3zEf6NCQrSnrlbcSe6DJgOdiEj0uwtbwOKOzpJ1XedPkPc TIktwXbYZYUz57IyoUXCByNKUQziVWr8Yn/VMaPyCTu3jAczUuGeTPx71LTVhfflUiya PMPU+uB5t4kpOwucMByfakRwfmOf3Gdov4CHvpTiiGBAG1F99P5M8DX8oEDqNtkcSIkb nwbvz9aLfgBDQa7yWlAC2aBDrmpRWeZJET4JcTzZKnGFMpWDebJ9V6xeXbDHAY+g+BPC 1hgerIIVbdhBm3ApQDDNfwmw9TrnLmDRIhPC3KzzbQt6TSvigHCqfi78LHN8GQshvwQi BZ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lmKofo5XL6pcYRLvYw3BVNxNonI1i89zwQf4fYPG/TE=; b=Ujxri1gv/NyFawV6WcqKbSYIPH09vE0uqLPBBnx/GgsoX2a/ismQDAMLNnb0B9lOnv fIY/1nBNGW6f93YUQGxAo4UwRz6oEKCAZfyiUrJilt5hw07j2vtnogzj3/P3ZH3QunQM RK9ZRTR1+mS6utFIA/DRm8ijvdO/V9adTfJJboBjG+ybfjnzT8hIgCjtJx7cPv5cZNdn DAOuSXQz9mWSzpJjiFDEJ2mWaEFnho0DWumuXa7szR88hb7g69cPsW6SPZSETCAUHRRA ZPivXaNrEnxhxKNJixIyiXQQqOAL7/K6Q4/jRRiriI9/Mb143e9He/Otc7AfQ1JEE6D9 DVZw== X-Gm-Message-State: AOAM533gOVHFmxOXr23BoSM2H4O5cutgwyddQPPUsoOT8HfQ7SMtU87F qv+fucz1idzIHmKuL90+UCceA2XnxB87Zw== X-Google-Smtp-Source: ABdhPJxiWY5O8tu0C42AedBrV5j5v4srilwuB6eUvl5BAcKz5/2Z1bbXjqYuwPHfqRXxGTUyHp7bcA== X-Received: by 2002:ac2:483b:: with SMTP id 27mr5823959lft.429.1610725164762; Fri, 15 Jan 2021 07:39:24 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id j2sm931567lfe.134.2021.01.15.07.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 07:39:24 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring Cc: Boris Brezillon , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 3/3] mtd: parsers: ofpart: support BCM4908 fixed partitions Date: Fri, 15 Jan 2021 16:39:01 +0100 Message-Id: <20210115153901.31052-3-zajec5@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210115153901.31052-1-zajec5@gmail.com> References: <20210115153901.31052-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Rafał Miłecki BCM4908 partitioning is based on fixed layout but allows specifying multiple firmware partitions. It requires detecting which firmware partition was used for booting current kernel. To support such cases without duplicating a lot of code (without copying most of the ofpart.c code) support for post-parsing callback was added. BCM4908 callback simply reads offset of currently used firmware partition from the DT. Bootloader specifies it using the "brcm_blparms" property. Signed-off-by: Rafał Miłecki --- drivers/mtd/parsers/Makefile | 1 + drivers/mtd/parsers/bcm4908-partitions.c | 62 ++++++++++++++++++++++++ drivers/mtd/parsers/bcm4908-partitions.h | 7 +++ drivers/mtd/parsers/ofpart.c | 28 ++++++++++- 4 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 drivers/mtd/parsers/bcm4908-partitions.c create mode 100644 drivers/mtd/parsers/bcm4908-partitions.h diff --git a/drivers/mtd/parsers/Makefile b/drivers/mtd/parsers/Makefile index b0c5f62f9e85..3e26001f743c 100644 --- a/drivers/mtd/parsers/Makefile +++ b/drivers/mtd/parsers/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o +obj-$(CONFIG_MTD_OF_PARTS) += bcm4908-partitions.o obj-$(CONFIG_MTD_PARSER_IMAGETAG) += parser_imagetag.o obj-$(CONFIG_MTD_AFS_PARTS) += afs.o obj-$(CONFIG_MTD_PARSER_TRX) += parser_trx.o diff --git a/drivers/mtd/parsers/bcm4908-partitions.c b/drivers/mtd/parsers/bcm4908-partitions.c new file mode 100644 index 000000000000..032a4b1b8a5f --- /dev/null +++ b/drivers/mtd/parsers/bcm4908-partitions.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2021 Rafał Miłecki + */ + +#include +#include +#include +#include +#include +#include + +#define BLPARAMS_FW_OFFSET "NAND_RFS_OFS" + +static long long bcm4908_partitions_fw_offset(void) +{ + struct device_node *root; + struct property *prop; + const char *s; + + root = of_find_node_by_path("/"); + if (!root) + return -ENOENT; + + of_property_for_each_string(root, "brcm_blparms", prop, s) { + size_t len = strlen(BLPARAMS_FW_OFFSET); + unsigned long offset; + int err; + + if (strncmp(s, BLPARAMS_FW_OFFSET, len) || s[len] != '=') + continue; + + err = kstrtoul(s + len + 1, 0, &offset); + if (err) { + pr_err("failed to parse %s\n", s + len + 1); + return err; + } + + return offset << 10; + } + + return -ENOENT; +} + +int bcm4908_partitions_post_parse(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts) +{ + long long fw_offset; + int i; + + fw_offset = bcm4908_partitions_fw_offset(); + + for (i = 0; i < nr_parts; i++) { + if (of_device_is_compatible(parts[i].of_node, "brcm,bcm4908-firmware")) { + if (fw_offset < 0 || parts[i].offset == fw_offset) + parts[i].name = "firmware"; + else + parts[i].name = "backup"; + } + } + + return 0; +} diff --git a/drivers/mtd/parsers/bcm4908-partitions.h b/drivers/mtd/parsers/bcm4908-partitions.h new file mode 100644 index 000000000000..df25f0487d0a --- /dev/null +++ b/drivers/mtd/parsers/bcm4908-partitions.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __BCM4908_PARTITIONS_H +#define __BCM4908_PARTITIONS_H + +int bcm4908_partitions_post_parse(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts); + +#endif diff --git a/drivers/mtd/parsers/ofpart.c b/drivers/mtd/parsers/ofpart.c index daf507c123e6..6b221df8401c 100644 --- a/drivers/mtd/parsers/ofpart.c +++ b/drivers/mtd/parsers/ofpart.c @@ -16,6 +16,18 @@ #include #include +#include "bcm4908-partitions.h" + +struct fixed_partitions_quirks { + int (*post_parse)(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts); +}; + +struct fixed_partitions_quirks bcm4908_partitions_quirks = { + .post_parse = bcm4908_partitions_post_parse, +}; + +static const struct of_device_id parse_ofpart_match_table[]; + static bool node_has_compatible(struct device_node *pp) { return of_get_property(pp, "compatible", NULL); @@ -25,6 +37,8 @@ static int parse_fixed_partitions(struct mtd_info *master, const struct mtd_partition **pparts, struct mtd_part_parser_data *data) { + const struct fixed_partitions_quirks *quirks; + const struct of_device_id *of_id; struct mtd_partition *parts; struct device_node *mtd_node; struct device_node *ofpart_node; @@ -33,7 +47,6 @@ static int parse_fixed_partitions(struct mtd_info *master, int nr_parts, i, ret = 0; bool dedicated = true; - /* Pull of_node from the master device node */ mtd_node = mtd_get_of_node(master); if (!mtd_node) @@ -50,11 +63,16 @@ static int parse_fixed_partitions(struct mtd_info *master, master->name, mtd_node); ofpart_node = mtd_node; dedicated = false; - } else if (!of_device_is_compatible(ofpart_node, "fixed-partitions")) { + } + + of_id = of_match_node(parse_ofpart_match_table, ofpart_node); + if (dedicated && !of_id) { /* The 'partitions' subnode might be used by another parser */ return 0; } + quirks = of_id ? of_id->data : NULL; + /* First count the subnodes */ nr_parts = 0; for_each_child_of_node(ofpart_node, pp) { @@ -126,6 +144,9 @@ static int parse_fixed_partitions(struct mtd_info *master, if (!nr_parts) goto ofpart_none; + if (quirks && quirks->post_parse) + quirks->post_parse(master, parts, nr_parts); + *pparts = parts; return nr_parts; @@ -140,7 +161,10 @@ static int parse_fixed_partitions(struct mtd_info *master, } static const struct of_device_id parse_ofpart_match_table[] = { + /* Generic */ { .compatible = "fixed-partitions" }, + /* Customized */ + { .compatible = "brcm,bcm4908-partitions", .data = &bcm4908_partitions_quirks, }, {}, }; MODULE_DEVICE_TABLE(of, parse_ofpart_match_table);