From patchwork Mon Jul 11 15:30:40 2022 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: 589392 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp3350131mab; Mon, 11 Jul 2022 08:30:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sptmXwe+tmD30sN/oKQ56kXX31ccdiZBh/mhlBkOuqYfyHsPaeqjzmZQaaLS/3g4IcAptJ X-Received: by 2002:a05:6512:3f8b:b0:489:de73:b7b3 with SMTP id x11-20020a0565123f8b00b00489de73b7b3mr3437453lfa.590.1657553456811; Mon, 11 Jul 2022 08:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657553456; cv=none; d=google.com; s=arc-20160816; b=nmA4t3lj1+LBaASG03mHK7A85ugIKBILJNc9sFnTcZj+mR9mPZ05C7orCdmBCxZsO+ h0EZsks9ZNHXWUq8NZiC9jMclQDs5ojcGM/lq/p9eluf/Tss2+z//011YS1R24YfrR6m fFtOHrxt752hUxBQosCjjG/N5UL6IjoNrjr7qLg1xC9EHtch6uYHxf3HDf6OwgAbdbdY VsiDDOErxCsfJNukNnvzKCu2MXip2kig6jmnEORJM4uHogU94wgb0cTjVTJgst6VVY/c ZBLzzigSpRxJGA1dVCpyw2CvvIWba/aMMsDmkZs7GGsNDa3dgCgftBaLVqFY/+2X/i7H +dkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=O6aF44242Cbhj9tJR/zWLAwI/ThWjZFM50mDO0hgdDw=; b=YLZScA2ddtRqHF2HQKaCHlKY8eDfA/aLpEakXJAVqSr0ebZYPwQsKSjd6nyjDqhD3d 7bWfEaWsST2ODWhpbpkz7qqbcHhOraVxG59YL4LwOCZ5PQh/5reOGtuyRb/fSR0KljHd djiUKKAMWujWf+tdjBBrhDy1RmJjWWwyuxSmbcu18P1z84lOsQzvFUwl4y4ReRmcQJet xO3wg+i3ChDSRMsrdFWuQWc07hi8ofZW2vsTARerjeZgbMr8uBcMOc22XwSUz6lQ+ObG M80FA8T2wLz5mh/FkWAdFtVMlqg9dVuBigeddnZnU5fuQUUWUnVrApLtIeHu6aJw7aCy Go5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TibOBdGS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id o1-20020ac24bc1000000b00488c70dd342si5886756lfq.293.2022.07.11.08.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:30:56 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TibOBdGS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A83584014; Mon, 11 Jul 2022 17:30:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TibOBdGS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 112CA84039; Mon, 11 Jul 2022 17:30:51 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2109584005 for ; Mon, 11 Jul 2022 17:30:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=zajec5@gmail.com Received: by mail-ej1-x62d.google.com with SMTP id u12so9441187eja.8 for ; Mon, 11 Jul 2022 08:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=O6aF44242Cbhj9tJR/zWLAwI/ThWjZFM50mDO0hgdDw=; b=TibOBdGSO+jHYEmqxPBPE1v1o5zW0g08biNvyyHtM881mmqbCne/CjOxui4UEFwRWR A2Q0c+jZHCx+iZ85vHjuwX5V7LaLcCqPHBzSxIYTnssGOM+yUfdvUpKOdr7sJNyDnPgm GwDDF8EX99oAPiVMlI8IIKuhgLJgi85qmKWdbtZXLnFZem5YwG4ig3H3rXxC3QYLZ0/z UjMWEYkBAmbcKoz62i/wIqxOEfvmXasyFer2ubzqmixLwSf+6W6qVpAumtf37KP+HWBw yG8JNTz/NwkjmUT/pU9ogR9ggTQsyTNbhPSqdKcKXCs8yutTTi/qQEZKtHGS+4L6dbXk fJpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=O6aF44242Cbhj9tJR/zWLAwI/ThWjZFM50mDO0hgdDw=; b=4wgjbUMr3W0v1LWvvBNiilCbGbnqVMTpNGE/4fPyt8xJbxJEv6qL8eNBiRX6nyd+xO pWcQpusiYg0KO8NRdNPWQFBQMffO+q2dXPYsSkskqqWOotBKSfVYrlRasDlmHG2D16OT APkTcTrr/urnj0S9ZvIIG+LraYh/kqUr9vYujcw3pjIsW+uctNOW+zqf/9l9O9CQXxut St0b2p9hAZGguhHLqpcSj04wVkOC+v2jcKyupm85kesnWg8Rx2msqvmz0fa4OIIaEj5Q xjBnfiEkU7JNSDljL2WrUDJ/0IbSgJk3txDKNYj1QC0jt1UET3zgl4p4D7hQwiTvyTkN JCLg== X-Gm-Message-State: AJIora/GFvwO9+wzjO5uPK+RdewjU0H770Pce8k4mg7tqfbzsPxLPctc bQ1ajqLWs8T/BRWzdarTLAw= X-Received: by 2002:a17:907:1dc4:b0:72b:4d85:c7c4 with SMTP id og4-20020a1709071dc400b0072b4d85c7c4mr7409903ejc.258.1657553447551; Mon, 11 Jul 2022 08:30:47 -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 n23-20020a170906725700b00722e603c39asm2773917ejk.31.2022.07.11.08.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:30:47 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Rob Herring , Krzysztof Kozlowski , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, u-boot@lists.denx.de, bcm-kernel-feedback-list@broadcom.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 1/2] dt-bindings: mtd: partitions: add binding for U-Boot bootloader Date: Mon, 11 Jul 2022 17:30:40 +0200 Message-Id: <20220711153041.6036-1-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Rafał Miłecki Right now there is no (known) real reason for a custom binding for standard U-Boot partitions. Broadcom's U-Boot however requires extra handling - looking for environment variables subblocks. This commit adds Broadcom specific binding. Signed-off-by: Rafał Miłecki Reviewed-by: Rob Herring --- .../bindings/mtd/partitions/u-boot.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml diff --git a/Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml b/Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml new file mode 100644 index 000000000000..8a88e7d16524 --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mtd/partitions/u-boot.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: U-Boot bootloader partition + +description: | + U-Boot is a bootlodaer commonly used in embedded devices. It's almost always + located on some kind of flash device. + + Device configuration is stored as a set of environment variables that are + located in a (usually standalone) block of data. + +maintainers: + - Rafał Miłecki + +allOf: + - $ref: partition.yaml# + +properties: + compatible: + oneOf: + - const: brcm,u-boot + description: | + Broadcom stores environment variables inside a U-Boot partition. They + can be identified by a custom header with magic value. + +unevaluatedProperties: false + +examples: + - | + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + compatible = "brcm,u-boot"; + reg = <0x0 0x100000>; + label = "u-boot"; + }; + + partition@100000 { + reg = <0x100000 0x1ff00000>; + label = "firmware"; + }; + }; From patchwork Mon Jul 11 15:30:41 2022 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: 589393 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp3350341mab; Mon, 11 Jul 2022 08:31:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tRWnoO6DN7ic9AnJUsMuTFgYk18toA2hMJoB7JGQvaYdc5fUesQUygw66icwmZaNZC6we4 X-Received: by 2002:a05:6512:1319:b0:482:b8ce:a278 with SMTP id x25-20020a056512131900b00482b8cea278mr12184184lfu.8.1657553471791; Mon, 11 Jul 2022 08:31:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657553471; cv=none; d=google.com; s=arc-20160816; b=cH9uDziHUVw9VbNRHXqNn5XNv4Qqzl5rJMmB6FQExkuHPDJhCrNW9ZCnsKrgMqdB+D B5G7O+i8imcv/JgSS4izwog5z2nZ/NaB+0lUhoSVgIsJJ7MAnMEkHprPRWWkJah+xvWH AuVTrh4THesClNdiRn0NuuSfWLt1ax6mOLjEWWbKfZVR55kNop3LuxouW+t5ys5Mb3Gm G63a1I71nOSjilkLGqrii44iaunnDoOh5al9HQ9GmhFeMq+4iHtax2Ic2TzBOBq0JN55 uBB7lDOKl+YVITTmDCAeYuwDHybEf26j9J230E7yXrhFZOcJFJDIiClZ9AGoZvJhWdxM eecQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9NbtZW5iYffYk9vJVjFHUiX8xjAYGNvMtQ0Q/nx4lmE=; b=Bs4Pmab0DD3VSxxpsdE1ZN64eKK/jWBwxUIcDzERnE09alBmDA80kuqui/dmAre7kn es14o6928h4AlE2JZ0f1Cf2KlNWSYtX0RKk2G1ZlB4nAhzxqfJwrHY02ZH3scre3Vr+e 2S0PIgSAd9iXnOFQh13uZ0DGVYXuydRvL3wfqDdkuRYGxNDJ3Yruk7eVU/mmpSdZqNaW 3b3zlIbnL/1JSeXVUeuuoEepO9vUGqPMvRZL/srV1q4k2xxOhflpN6CSM2Y3fLrlV5gp 5FP73u28IDcaKzqb7yO172SF6jkSaxFi6zzZAXswO+nzFPePuF8BUrPxI0Ux7o6Fnp2t XLFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RXgXOcZj; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id i2-20020a056512340200b00479674a70e5si9399217lfr.232.2022.07.11.08.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RXgXOcZj; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9D7CD84039; Mon, 11 Jul 2022 17:30:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RXgXOcZj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CBE084005; Mon, 11 Jul 2022 17:30:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8CC208401B for ; Mon, 11 Jul 2022 17:30:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=zajec5@gmail.com Received: by mail-ej1-x631.google.com with SMTP id ss3so3415698ejc.11 for ; Mon, 11 Jul 2022 08:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9NbtZW5iYffYk9vJVjFHUiX8xjAYGNvMtQ0Q/nx4lmE=; b=RXgXOcZj6YH+t3Aq/vb7Vvy1y3qynU35QEgQvsk2xM8MzwSpdHV1CeVrk9yu89X1mQ DCN7Umzu+MkC8OTHHi6gwQIPu1mgzzz4M8RQ5RnPMEGLP35ZSYvIQJdOnSrIX5cOyJqL J5n9qN15WTysFcf65IkJ3fDCIfublrwG/IE/LxE+WWq0h4V0APn5fAk8XfaOlyVcQ6aW Hw4B248mr7TH4zDKONitE6y9eoXGuKbkjYHSMrqScvKmVOLwQ5Z3YY1Dye4zMw7lxqy5 1hqr1zFnDfBr61akis4PnNsELCJPfeObv9f8tDhcTrU4g9pkHBj0moknGcFSt1a27Eys EtwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9NbtZW5iYffYk9vJVjFHUiX8xjAYGNvMtQ0Q/nx4lmE=; b=cNIAV10CTxju1dkMpAYp8YM0U+4laAdtEzcbIhHC9juqYIasLwZtWDtBSjjMaxmLcM fEnc/q3FxlORXRWjTtLEGWaL8G3hDCEHYAjHC19I2DAt5amHBRjYt/Lvbt5P4OvuQEr1 y/OAFtTobI+Jss/hyHWeGK1X+YloCSduK/pCXr4KT35GkfWWeWChbpI5rUO2grOmEmwO LGa9zLAhSAMI9K+bhEIVPAGP3G/MjspQv6xJAStkD/52FNHQBHhFmMqjm8grHphLnNKT 74Fqowuoyd3yUuseQK6PDcfA7gGtgU31UT8qCkCPgslDlhZWkfTaAybrVxJfQYBBBv4J aM+Q== X-Gm-Message-State: AJIora9suisEab8i5VXXgXi+RGHVS6ORS0e8OBzZnDJxm/TgCKwDfYNF 4/555geDy8fFIKSxH1kxUuU= X-Received: by 2002:a17:907:7e85:b0:726:9fc5:cc2d with SMTP id qb5-20020a1709077e8500b007269fc5cc2dmr18462100ejc.376.1657553449101; Mon, 11 Jul 2022 08:30:49 -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 n23-20020a170906725700b00722e603c39asm2773917ejk.31.2022.07.11.08.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 08:30:48 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Rob Herring , Krzysztof Kozlowski , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, u-boot@lists.denx.de, bcm-kernel-feedback-list@broadcom.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 2/2] mtd: parsers: add Broadcom's U-Boot parser Date: Mon, 11 Jul 2022 17:30:41 +0200 Message-Id: <20220711153041.6036-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220711153041.6036-1-zajec5@gmail.com> References: <20220711153041.6036-1-zajec5@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Rafał Miłecki Broadcom stores environment variables blocks inside U-Boot partition itself. This driver finds & registers them. Signed-off-by: Rafał Miłecki --- drivers/mtd/parsers/Kconfig | 10 ++++ drivers/mtd/parsers/Makefile | 1 + drivers/mtd/parsers/brcm_u-boot.c | 84 +++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 drivers/mtd/parsers/brcm_u-boot.c diff --git a/drivers/mtd/parsers/Kconfig b/drivers/mtd/parsers/Kconfig index b43df73927a0..81f2d0a795a6 100644 --- a/drivers/mtd/parsers/Kconfig +++ b/drivers/mtd/parsers/Kconfig @@ -20,6 +20,16 @@ config MTD_BCM63XX_PARTS This provides partition parsing for BCM63xx devices with CFE bootloaders. +config MTD_BRCM_U_BOOT + tristate "Broadcom's U-Boot partition parser" + depends on ARCH_BCM4908 || COMPILE_TEST + help + Broadcom uses a custom way of storing U-Boot environment variables. + They are placed inside U-Boot partition itself at unspecified offset. + It's possible to locate them by looking for a custom header with a + magic value. This driver does that and creates subpartitions for + each found environment variables block. + config MTD_CMDLINE_PARTS tristate "Command line partition table parsing" depends on MTD diff --git a/drivers/mtd/parsers/Makefile b/drivers/mtd/parsers/Makefile index 2fcf0ab9e7da..23fa4de4016f 100644 --- a/drivers/mtd/parsers/Makefile +++ b/drivers/mtd/parsers/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o obj-$(CONFIG_MTD_BCM47XX_PARTS) += bcm47xxpart.o obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o +obj-$(CONFIG_MTD_BRCM_U_BOOT) += brcm_u-boot.o obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o ofpart-y += ofpart_core.o diff --git a/drivers/mtd/parsers/brcm_u-boot.c b/drivers/mtd/parsers/brcm_u-boot.c new file mode 100644 index 000000000000..7c338dc7b8f3 --- /dev/null +++ b/drivers/mtd/parsers/brcm_u-boot.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright © 2022 Rafał Miłecki + */ + +#include +#include +#include +#include +#include + +#define BRCM_U_BOOT_MAX_OFFSET 0x200000 +#define BRCM_U_BOOT_STEP 0x1000 + +#define BRCM_U_BOOT_MAX_PARTS 2 + +#define BRCM_U_BOOT_MAGIC 0x75456e76 /* uEnv */ + +struct brcm_u_boot_header { + __le32 magic; + __le32 length; +} __packed; + +static const char *names[BRCM_U_BOOT_MAX_PARTS] = { + "u-boot-env", + "u-boot-env-backup", +}; + +static int brcm_u_boot_parse(struct mtd_info *mtd, + const struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +{ + struct brcm_u_boot_header header; + struct mtd_partition *parts; + size_t bytes_read; + size_t offset; + int err; + int i = 0; + + parts = kcalloc(BRCM_U_BOOT_MAX_PARTS, sizeof(*parts), GFP_KERNEL); + if (!parts) + return -ENOMEM; + + for (offset = 0; + offset < min_t(size_t, mtd->size, BRCM_U_BOOT_MAX_OFFSET); + offset += BRCM_U_BOOT_STEP) { + err = mtd_read(mtd, offset, sizeof(header), &bytes_read, (uint8_t *)&header); + if (err && !mtd_is_bitflip(err)) { + pr_err("Failed to read from %s at 0x%zx: %d\n", mtd->name, offset, err); + continue; + } + + if (le32_to_cpu(header.magic) != BRCM_U_BOOT_MAGIC) + continue; + + parts[i].name = names[i]; + parts[i].offset = offset; + parts[i].size = sizeof(header) + le32_to_cpu(header.length); + i++; + pr_info("offset:0x%zx magic:0x%08x BINGO\n", offset, header.magic); + + if (i == BRCM_U_BOOT_MAX_PARTS) + break; + } + + *pparts = parts; + + return i; +}; + +static const struct of_device_id brcm_u_boot_of_match_table[] = { + { .compatible = "brcm,u-boot" }, + {}, +}; +MODULE_DEVICE_TABLE(of, brcm_u_boot_of_match_table); + +static struct mtd_part_parser brcm_u_boot_mtd_parser = { + .parse_fn = brcm_u_boot_parse, + .name = "brcm_u-boot", + .of_match_table = brcm_u_boot_of_match_table, +}; +module_mtd_part_parser(brcm_u_boot_mtd_parser); + +MODULE_LICENSE("GPL");