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: 3251 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1315210wrs; Mon, 17 Oct 2022 00:31:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6w2ROTK1I6owkW4efn/Jqf4yeGqd10TL0gtbSJoM/p3PEDtovKLJnbm+SCPv5m6UHiS5+z X-Received: by 2002:a17:90a:2a42:b0:20a:6232:a2ab with SMTP id d2-20020a17090a2a4200b0020a6232a2abmr32001175pjg.66.1665991904219; Mon, 17 Oct 2022 00:31:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665991904; cv=none; d=google.com; s=arc-20160816; b=QDUVKvUTTrjsj49/8hLdUSxreHHQWd58Rs9CA+7nN8YDDtb3dmVdK3VM8EdxYbUyfL oQW8yFpAGctIZa1v/RLkKBPm4gC/BkdD19JoekPphv44oJY5SzSLL9q8W1D+M/6+e4+U ESXoEKV+Pxo9SgOFcNdQS/91qUztTLn1AKtUR6l7BnQSHKPOFf6OzF7Gfl9TXA+N8jqh SchzWlFsA3BGcPFmvA0FTIoCNOyPWxI047dsJDFL0jOMvA9okgsG+oYEqBqkgWFWGWVh rJeLAgVtaXHKBj922/QQWkMC01lvruevzXyCQrPCCJqKw0NObSZ5Pf9fV/1919oioLvM e26g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=aTbbFD+gjgbQXX2LBmI+E75ORM8YiSCeM7mZ239f43Y=; b=mPVMLbvgGnn985yocgUigjm1cH/cIB/2S4Y4NI62cNFAxH/xhoaC2/2T0O+TZ1q+Eb T4/Bb8ywgKX0PA1no+1YW1lqCfVM4dWIQN0ohwnWauwYaifjGtBl+EpVhUftFA9P+TcA upSM/9EqRKB1xG2FwIEXgmkKtNsg8RzrLslEfQ6e2yDgGV84nrFIAgLruXZDFfEIzAWW +e088TBRWpXx6blQbpVUCIOJKJ74jpuUg+vPcILUhg3zXOcp/+vZ0D0lhzm9cScbxGbV R54DlGGGb7FvBJl9P55Pi+hVHX11fPDUbbOpv7JKRzrmgbHx0tM6Xgjapvmzo4+V4gGT +3HQ== 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 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 f12-20020a056a001acc00b00562e67620fesi12347714pfv.192.2022.10.17.00.31.29; Mon, 17 Oct 2022 00:31:44 -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=lQBlwYnk; 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 S230099AbiJQHRk (ORCPT + 99 others); Mon, 17 Oct 2022 03:17:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbiJQHRi (ORCPT ); Mon, 17 Oct 2022 03:17:38 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B901E28E34 for ; Mon, 17 Oct 2022 00:17:37 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id sc25so22746642ejc.12 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=nCzn51Aj3YGpkwn8AwiCNW4V+HVnbx0xG1QOr0Es9oNRagcznHFPRyPKf4NJcJy8BV CHr2Za+OcKwheH4wvEQuf0tPn8OmWVYerOFD+cUSsvIPpUmCoEjYO8n52UgZAA+Wtvzw YWUKxKQBbc0/iuUhld5TS681FJs71pj3fs78ZPiPD22Ix12OHB4GSVK68/nhTAxUosGj 9Dayb+9jHbAAk4XKMRizoQCOod57+G8JmN5G8j/tKNbY15pda6k/B56DRaQCGsAdXBZU ePQLdDUKHhT74UOddLHGgLo4OIyexPG1ACMDAwUs0DVxOiJ/sjCjFfMHd3yhUjZIq1Fp Q5jQ== X-Gm-Message-State: ACrzQf126d4QnvCC0aJErE8i79mgybwuYRFr0Quc+G1tmAvthwBzpr9W GuKeZtxlx52vTHWmYBSVURI= 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-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?1746919126754968791?= X-GMAIL-MSGID: =?utf-8?q?1746919126754968791?= 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, }, {}, };