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: 13008253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E22EDC433FE for ; Mon, 17 Oct 2022 07:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=NHfrZ94knwrbBoYBjQB63J2sOHgCXIehtQ4zKQeOCBw=; b=FCaBL3CJYS3jpI RymFKmQ7UjgZARWJL5/45KbXuLzWqzqDg9uVAdmqxIU2L1oBtL+ytCRtVs0UrEunFDudLD5HgF1dK AEmAtxAB2SLlsCO29+LdBXrVtdwM0uN8rBlO5L1QG7YrrbYv/UvxsJUQlu6m4gxNSsKwt+IH/Dqnp OFJ70VUv7ZuTtWTEgq0EiSh5z77atK5mES2e2IkvjMTtQy235w77PXppsdalocp8do5RyjCNZznwn xUChPI1iWT3vf6Cw1lE3Oj7xfbkCfJNJjKRx3VJkDZ5FZ5MjCerVya/RTc99hBkBYl3bzTvOVsnym /sCa4Hs2Yy2/v03boyrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1okKNZ-008PDA-Mv; Mon, 17 Oct 2022 07:17:41 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1okKNX-008PC5-06 for linux-arm-kernel@lists.infradead.org; Mon, 17 Oct 2022 07:17:40 +0000 Received: by mail-ej1-x633.google.com with SMTP id ot12so22859931ejb.1 for ; Mon, 17 Oct 2022 00:17:37 -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=xtxDhf3xQk1z9XNZEreMWx2bgDmiD8b5jiYCONY3YAmC8Ru/oDmGbBXPBPpEw4uQZa Fu26HDd7b9tWK+xE2mKwKVYhJXLuSuhLYwMkirVYBhfBqos4acdSeJEzv1yyc71q21VQ 4Neylpf04f2i/SkablBuDfEP061atj+P1bSBjyYzqLkx0NZeGcqgzrBDidgJWv3iyd6k vMKaF+iu0ZA2Je15a2ipTc94PfV3vBp+ZUXyXytzBnUjbUHHQv1SqyJPzzhxD6fB7bjS JqEIKQ0pLKuJo9WXJwrhGqo0JZ3h9+GyqRy5Bm0OITtfdefMmeFR6Iz7lYT5jeW9NiXo Zg/Q== X-Gm-Message-State: ACrzQf0LPG0oqQ3/Kp1dxytrilK7YQudIQU+OyVN+PQYYe/x72Mb4kOu Azdlfc3THvCVhBmbCFmHHXKRCwMxi1E= X-Google-Smtp-Source: AMsMyM7xEckB6MUGEv7KdcQvLp4KeKB6N/zcQyks1ZYNFmuz0+oN/wOyuz5R+2UjePwVD9cmhA3Vyw== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221017_001739_085956_A05FB8D7 X-CRM114-Status: GOOD ( 12.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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, }, {}, };