From patchwork Tue Aug 8 16:02:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 13292 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2273388vqr; Tue, 8 Aug 2023 10:19:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIST2Z9ekrNWJbkBs4IFIEMz+v81/1M5+7QNPtPXmZ4oTVfkgwmJhWxmBNkted4cmgRdz8 X-Received: by 2002:a17:90b:180d:b0:263:eb0e:5681 with SMTP id lw13-20020a17090b180d00b00263eb0e5681mr524175pjb.3.1691515197699; Tue, 08 Aug 2023 10:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691515197; cv=none; d=google.com; s=arc-20160816; b=sfXnOv6DUeVsahG56a9aE8jhj9SXj/ofLZ8MxpesHfkloPVUZ6VBQcmrQ6RMf1SJ0Y spcjK+YT33xVtqRPcoM+JOR8yugOLRGKRuN7cas7m0K+wuioxgABzqSBhvfHOW3KNk7Q 223J9g7sLD/h4VgudNM/nkCJB3NoTHKOnFEXlZfoAJS65fn9Kr2+wrzvAB+5GgNH41y6 O0K/NETB8SN6JA9tJIcPdI4wo/wE9E9Z/CaOudpzLW5vbLCs2bLp/Xc47O5VwCm9i5GN wmuyrTo/TLaVt/HCbxFK0Utj2XxwbjlQaeBzVaGBQcfC/NjZZmgMuqXHaV7oV4798g07 sHcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=zLgeO4l4hAmozmbcmApO7NRfYgQINPAcKrxV/SR/AyA=; fh=fqW8oMY9ydixFpWZdFhmrmd4m3lvFBw58fIoJyq/l8o=; b=MA+F1sQBxi8973hc1YDMndwgJd3pl1b1M8n1rAE/w8gHVBTjIFNHLhBzqK4ixesHFR eK/Vt0RsUb45hPiX4/oyQvS/N07IBYIbUGVQWadg7ycNyeqfPBT2ZL2HGDZCkL9ZYslO QDCpZJVySGCTucxd261lPj1A4qkGHfNT40ijBtvDqjAyMxPk+Lwg+VjgjPIGejzvCZIX puMtjX61l2cK3TtTyNK9FHdaF6cWycklOrS9hz8+PYp3N70ymd3XzYJX9trTBsJu3CfY 2/CZMAY2GZ/TbzSTgh+b04Xvd+mO7jUEqawoXF+hPMZr6H3DIeJ7XBYKHKxMzCVnlFY4 vwpw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lx16-20020a17090b4b1000b002636d222400si11343465pjb.14.2023.08.08.10.19.43; Tue, 08 Aug 2023 10:19:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234267AbjHHRPo (ORCPT + 99 others); Tue, 8 Aug 2023 13:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234101AbjHHRPI (ORCPT ); Tue, 8 Aug 2023 13:15:08 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 856336BD3B; Tue, 8 Aug 2023 09:06:15 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1qTPAq-0007Wz-1J; Tue, 08 Aug 2023 16:03:08 +0000 Date: Tue, 8 Aug 2023 17:02:55 +0100 From: Daniel Golle To: Randy Dunlap , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Daniel Golle , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/8] mtd: ubi: allow UBI volumes to provide NVMEM Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773682239846366793 X-GMAIL-MSGID: 1773682239846366793 The series is a follow-up and contains all patches of the previous series "mtd: ubi: behave like a good MTD citizen"[1] which was meant in preparation for implementing the NVMEM provider. The goal is to support embedded Linux devices which got NVMEM bits stored inside a UBI volume. Representing the UBI volume in the Device Tree, adding a phandle to be referenced by NVMEM consumers allows such devices to come up with their correct MAC addresses and device-specific Wi-Fi calibration data loaded. In order to be available for other drivers, attaching UBI devices has to be moved from late_initcall (which is too late for other drivers) to happen earlier. As an alternative to the existing kernel cmdline parameter the Device Tree property 'compatible = "linux,ubi";' inside an MTD partition can be used to have that MTD device attached as UBI device. MTD partitions which serve as UBI devices may have a "volumes" firmware subnode with volumes which may be compatible with "nvmem-cells". In this way, other drivers (think: Ethernet, Wi-Fi) can resolve and acquire NVMEM bits using the usual device tree phandle, just this time the NVMEM content is read from a UBI volume. [1]: https://patchwork.ozlabs.org/project/linux-mtd/list/?series=353177&state=%2A&archive=both Changes since v2: * include dt-bindings additions Changes since v1: * include patch to fix exiting Kconfig formatting issues * fix typo and indentation in Kconfig Daniel Golle (8): dt-bindings: mtd: add basic bindings for UBI dt-bindings: mtd: nvmem-cells: allow UBI volumes to provide NVMEM mtd: ubi: block: don't return on error when removing mtd: ubi: block: use notifier to create ubiblock from parameter mtd: ubi: attach MTD partition from device-tree mtd: ubi: introduce pre-removal notification for UBI volumes mtd: ubi: populate ubi volume fwnode mtd: ubi: provide NVMEM layer over UBI volumes .../bindings/mtd/partitions/linux,ubi.yaml | 66 ++++++ .../bindings/mtd/partitions/nvmem-cells.yaml | 5 +- .../bindings/mtd/partitions/ubi-volume.yaml | 35 ++++ drivers/mtd/ubi/Kconfig | 12 ++ drivers/mtd/ubi/Makefile | 1 + drivers/mtd/ubi/block.c | 186 ++++++++++------- drivers/mtd/ubi/build.c | 160 +++++++++++---- drivers/mtd/ubi/cdev.c | 4 +- drivers/mtd/ubi/nvmem.c | 189 ++++++++++++++++++ drivers/mtd/ubi/ubi.h | 6 +- drivers/mtd/ubi/vmt.c | 32 +++ include/linux/mtd/ubi.h | 2 + 12 files changed, 578 insertions(+), 120 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/linux,ubi.yaml create mode 100644 Documentation/devicetree/bindings/mtd/partitions/ubi-volume.yaml create mode 100644 drivers/mtd/ubi/nvmem.c