From patchwork Mon Oct 17 07:17:22 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: 615686 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp1800591pvb; Mon, 17 Oct 2022 00:17:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM68TJWu44hYrdNi0qpP1UQXo6YaEhIx423KQ3Ftz84OK4Is9EsjN0TxOxbTHVfO0kYouYo8 X-Received: by 2002:aa7:c698:0:b0:458:8274:12ac with SMTP id n24-20020aa7c698000000b00458827412acmr9023527edq.351.1665991064607; Mon, 17 Oct 2022 00:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665991064; cv=none; d=google.com; s=arc-20160816; b=mng9CB58OJ43f3bDbXh8Dyye8xxVpP3DUkKoWTRA8uiHYU3yETWPgyWCxe8cWlmKuG peGG57tm9cLskL/tTjmi9Q/rCuS+BFEyMwEicXaY+hl91CpzJ2A+otaM2Eb3PAkj8m7i AeA1JvL3VeCFVQf0CRrp4t4qHpfmqFJvgy/JYFLYz7HnRuYgbShDTzdcq4S/Q32A4XZN M67lHlEI+tqvQIFA1rTmHcYLroLqE79mPFui1iEJ1hDk+b6gDCcsvIOXaBbljxQ127wI sEZ0afH3/SDNOrbK2PmxrptIO/wIZagWl5x3Yhws7WUVX7t6BSnsWDN5LaMJBHEkwVF4 MUwA== 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=aTbbFD+gjgbQXX2LBmI+E75ORM8YiSCeM7mZ239f43Y=; b=dsEL7oPb1aHgdHa6ozPtebZxUHILABQFNJBUM+y/AQlCNzCIK9xgrXmL/7mP4IaFt2 MysZUnpUVp8oEsPUJ2FGMgtHW4G5bLBToGqM8hhS7gMfJmhT4RfNq/6O3aeyKPWijktm RSJWCTs6uXA8hOh0Py4unsHiwt97QsWSEx+uSgFYInsYwFBGF5u8b8hhb+Iu5Fsoh13p Vhn6msT4qKFyZR/lIPv+qACN52vVsNzMYdJp+sTl6kWty9ocgzKpIysPeXnJ4AVpj4zJ V63RkyThyHMiPwzd8sxrOf0WmcYenJCDRBrXA4xvNtWj4I9hU61HODNqldWSAOD96BVY S2JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lQBlwYnk; 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 x11-20020a05640226cb00b0045d46f28533si6662999edd.377.2022.10.17.00.17.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 00:17:44 -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=lQBlwYnk; 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 259F484EED; Mon, 17 Oct 2022 09:17:41 +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="lQBlwYnk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 40DA484F44; Mon, 17 Oct 2022 09:17:39 +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.8 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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (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 AE95B84DEE for ; Mon, 17 Oct 2022 09:17:36 +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-x629.google.com with SMTP id w18so22771170ejq.11 for ; Mon, 17 Oct 2022 00:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=aTbbFD+gjgbQXX2LBmI+E75ORM8YiSCeM7mZ239f43Y=; b=lQBlwYnkb/uHR9h9ekdJK9DprRvCAtDRMxD4XHdgh/+LheFX5ZiQJeowxeHY1jqtu5 Zgo6DCs432kETKpjRbyjSsyxMxfK1+d3EXbz80G2/A2vZihCygUJrgQ4Ag0reQ9Pn6dm iZb04PG0kJ6DRHMwJhjE6g4KN+X3b6Cx5cBT4sHGoNpvAp/2Y1CM/p1pm4e2s1F7W0IX kVtiPbUqOoL+NVsZdbKwav58q/Zjo3MaOB9nhEwlYExZ2omR+m3q2aM4RMNVGC/Z1JK+ Cj32qzEMvKPW0HtmnT3bV4nYdTi+/mqy4QhZ8n0WGAbaNgG1Y/zTvsTgEBfORoumBRTK 4Qzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aTbbFD+gjgbQXX2LBmI+E75ORM8YiSCeM7mZ239f43Y=; b=lEn3M5+Q+fCywPB4+nw3cWEtl6a5Y+7093zbZCdtgBfpf4PmpTmZ+3kqoJV6d6o+Vb 1UQ0If4bhZ7rig5cNRzt2OsasI0xq19x0OlNjdhUTcwuOwP1s25lfYuVtHIepLl+NaBo aMddOmRX18lWxl8RuFGybhkUc0t01Fp31hq3JWfNe+N1siU4ayWZEICI/zHGErFlyGK1 IOSI8vFX7ifuQDdtZVzV7JOW9WOEUdfDTIkuthHXVPg7I4GQeTyUwolsp82dprTrxHyh i3SMFQ5laVehNUAg//NphgVdzS1JhKkoWRu2t5A2cYzkPwR5tXH7biDusyKAF1Fa8CeE VUDg== X-Gm-Message-State: ACrzQf2s0/o9n24y/k+MfQgWHzJQYosvbCRCDxislbE5CAVqnNMdv9/b Uu81XCEa0/kcVrMZgKJNrXI= X-Received: by 2002:a17:907:d22:b0:78e:2788:51ae with SMTP id gn34-20020a1709070d2200b0078e278851aemr7297386ejc.689.1665991056156; Mon, 17 Oct 2022 00:17:36 -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 a16-20020a170906191000b0078ae49ad169sm5766054eje.91.2022.10.17.00.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 00:17:35 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla Cc: Tom Rini , linux-arm-kernel@lists.infradead.org, u-boot@lists.denx.de, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH] nvmem: u-boot-env: add Broadcom format support Date: Mon, 17 Oct 2022 09:17:22 +0200 Message-Id: <20221017071722.32731-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 Broadcom uses U-Boot for a lot of their bcmbca familiy chipsets. They decided to store U-Boot environment data inside U-Boot partition and to use a custom header (with "uEnv" magic and env data length). Add support for Broadcom's specific binding and their custom format. Ref: c34f9f5499278 ("dt-bindings: nvmem: u-boot,env: add Broadcom's variant binding") Signed-off-by: Rafał Miłecki --- drivers/nvmem/u-boot-env.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/nvmem/u-boot-env.c b/drivers/nvmem/u-boot-env.c index 8e72d1bbd649..049330660fd7 100644 --- a/drivers/nvmem/u-boot-env.c +++ b/drivers/nvmem/u-boot-env.c @@ -16,6 +16,7 @@ enum u_boot_env_format { U_BOOT_FORMAT_SINGLE, U_BOOT_FORMAT_REDUNDANT, + U_BOOT_FORMAT_BROADCOM, }; struct u_boot_env { @@ -40,6 +41,13 @@ struct u_boot_env_image_redundant { uint8_t data[]; } __packed; +struct u_boot_env_image_broadcom { + __le32 magic; + __le32 len; + __le32 crc32; + uint8_t data[0]; +} __packed; + static int u_boot_env_read(void *context, unsigned int offset, void *val, size_t bytes) { @@ -138,6 +146,11 @@ static int u_boot_env_parse(struct u_boot_env *priv) crc32_data_offset = offsetof(struct u_boot_env_image_redundant, mark); data_offset = offsetof(struct u_boot_env_image_redundant, data); break; + case U_BOOT_FORMAT_BROADCOM: + crc32_offset = offsetof(struct u_boot_env_image_broadcom, crc32); + crc32_data_offset = offsetof(struct u_boot_env_image_broadcom, data); + data_offset = offsetof(struct u_boot_env_image_broadcom, data); + break; } crc32 = le32_to_cpu(*(__le32 *)(buf + crc32_offset)); crc32_data_len = priv->mtd->size - crc32_data_offset; @@ -202,6 +215,7 @@ static const struct of_device_id u_boot_env_of_match_table[] = { { .compatible = "u-boot,env", .data = (void *)U_BOOT_FORMAT_SINGLE, }, { .compatible = "u-boot,env-redundant-bool", .data = (void *)U_BOOT_FORMAT_REDUNDANT, }, { .compatible = "u-boot,env-redundant-count", .data = (void *)U_BOOT_FORMAT_REDUNDANT, }, + { .compatible = "brcm,env", .data = (void *)U_BOOT_FORMAT_BROADCOM, }, {}, };