From patchwork Sun Sep 20 09:57:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 260539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BBEAC43469 for ; Sun, 20 Sep 2020 09:57:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01D702158C for ; Sun, 20 Sep 2020 09:57:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ExV2J0dk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgITJ5n (ORCPT ); Sun, 20 Sep 2020 05:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgITJ5n (ORCPT ); Sun, 20 Sep 2020 05:57:43 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22650C061755; Sun, 20 Sep 2020 02:57:43 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id di5so5742127qvb.13; Sun, 20 Sep 2020 02:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1Cp6wGeZB6SS98LJtexBivyXrwvaD2ffDaajHaSACWY=; b=ExV2J0dku2JMmlAU9XWVQ6EA1ZpDFcBWqnSgZ52HkNzqXKPznuXV2TscrMYYZshBMA KScQZHTuODTN5KaT0FSwOi7O2X3RUWwcXQI+WDJ6bS9rvIyl/ZchqRy5d71W/JPiHwcb 1Fl1FTnD2W2BHC3sDNv16IeD96xIkM7YPS9RcOhTcWGi1pKFbd27vQX+ec9nyt11mEx+ drL7pH1LR/HnPBLImJ3r7TQOlyMoDYnfMqyx2Z/YQWlE7iPMRuUIam/1SXMBJm5Me8is 2tu2UXCrDOBaXBazoAa1+ZuUUmvSFSYNqMjJCI9ctYdCYdvKn5M1l6rIVBJBA9IEHHLM Mb3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1Cp6wGeZB6SS98LJtexBivyXrwvaD2ffDaajHaSACWY=; b=jTskMon6aLTD6+B49F064q5zDh0pFG5k3d2pDg964yCkWcEoY3MEJxnOPqGT0aguJg 9OyXojztsu2dorNHYvzkafFNYJtGMDzdOM5un8qeqwkPAgSuEp/mw4vcU4zAGafBw8Bk MrmLTyZ23NWhDQqe4/23M5yC+XDCGP4iyZiK90f5tz2Ky+ZdWJsdU1K7gCxX+U5Qb6XU 94avYqgJUZL9j2WGVFUAltVU4sGZX2EBLDSEnH/X2ilrMgEkof2SM93Qi6t0uHPf/ciY dVLKx66KbVZ2oM9KMTK8wVjrBuBkWDt/ibfUR/uuq3abPXjaUf41rAtJikMWB1rPfMWV WJBw== X-Gm-Message-State: AOAM530fJgIBUEBf/QHHh43+rH9cG+LNY9DvEOdX3loZb/Rmk4Palo9D sfHivPWlB+WxLPGD86MdOA4= X-Google-Smtp-Source: ABdhPJwEhDyAwUV5UVHjMYtJZMqZWnXncn13LWvoJ+ZoTbYCWu2zx0tKeSvcu7jECySfUWPeBSJS+g== X-Received: by 2002:a05:6214:1021:: with SMTP id k1mr24205091qvr.62.1600595862353; Sun, 20 Sep 2020 02:57:42 -0700 (PDT) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id w6sm6968323qti.63.2020.09.20.02.57.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2020 02:57:40 -0700 (PDT) From: Ansuel Smith To: Miquel Raynal Cc: Ansuel Smith , Richard Weinberger , Vignesh Raghavendra , Rob Herring , "David S. Miller" , Jakub Kicinski , Andrew Lunn , Heiner Kallweit , Russell King , Frank Rowand , Boris Brezillon , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 1/4] mtd: Add nvmem support for mtd nvmem-providers Date: Sun, 20 Sep 2020 11:57:19 +0200 Message-Id: <20200920095724.8251-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200920095724.8251-1-ansuelsmth@gmail.com> References: <20200920095724.8251-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce 2 new bindings for the mtd structure. Mtd partitions can be set as 'nvmem-provider' and any subpartition defined with the tag 'nvmem-cell' are skipped by the 'fixed-partitions' parser and registred as a nvmem cell by the nvmem api. Signed-off-by: Ansuel Smith --- drivers/mtd/mtdcore.c | 3 ++- drivers/mtd/parsers/ofpart.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 7d930569a7df..ba5236db8318 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -551,6 +551,7 @@ static int mtd_nvmem_reg_read(void *priv, unsigned int offset, static int mtd_nvmem_add(struct mtd_info *mtd) { + struct device_node *mtd_node = mtd_get_of_node(mtd); struct nvmem_config config = {}; config.id = -1; @@ -563,7 +564,7 @@ static int mtd_nvmem_add(struct mtd_info *mtd) config.stride = 1; config.read_only = true; config.root_only = true; - config.no_of_node = true; + config.no_of_node = !of_property_read_bool(mtd_node, "nvmem-provider"); config.priv = mtd; mtd->nvmem = nvmem_register(&config); diff --git a/drivers/mtd/parsers/ofpart.c b/drivers/mtd/parsers/ofpart.c index daf507c123e6..442e039214bc 100644 --- a/drivers/mtd/parsers/ofpart.c +++ b/drivers/mtd/parsers/ofpart.c @@ -61,6 +61,10 @@ static int parse_fixed_partitions(struct mtd_info *master, if (!dedicated && node_has_compatible(pp)) continue; + /* skip adding if a nvmem-cell is detected */ + if (of_property_read_bool(pp, "nvmem-cell")) + continue; + nr_parts++; } @@ -80,6 +84,10 @@ static int parse_fixed_partitions(struct mtd_info *master, if (!dedicated && node_has_compatible(pp)) continue; + /* skip adding if a nvmem-cell is detected */ + if (of_property_read_bool(pp, "nvmem-cell")) + continue; + reg = of_get_property(pp, "reg", &len); if (!reg) { if (dedicated) { From patchwork Sun Sep 20 09:57:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 260538 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C28E1C43468 for ; Sun, 20 Sep 2020 09:58:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86AC3214F1 for ; Sun, 20 Sep 2020 09:58:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PvksojqI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726442AbgITJ6C (ORCPT ); Sun, 20 Sep 2020 05:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbgITJ6B (ORCPT ); Sun, 20 Sep 2020 05:58:01 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6453C061755; Sun, 20 Sep 2020 02:58:00 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id d20so11894867qka.5; Sun, 20 Sep 2020 02:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7qdhkRouPUBlhhUeuoTWCcVW3x0+uiY3ffJ1oCMZQUk=; b=PvksojqItdBGtMhfwgKVJlnT43Rh3sUoLBTo2Iu8ZudwahRjKwVfIa2w3ob8pTa587 MwqTSxoHQGn17cO0HvQau/Az/czSlT8qzP/HdiabGHVsR89on1ljbFc3xxliPEtfJNlm iCIJG4gGaUnNLLBSXAJ7jeklc6N4f8m6Nf4LVoj0ikbId4Ul32cFhOBAsmdc/lTwP/JM g+tMG4TklMRz/m8LSzok7C3UksAmaq8Vca/WrOzJe703DgdPFeI4+6sO+732rk8SWvLD qHOVsyi1aPzt08ZPEZPCh2g4hK9mDxUmvXG3NF/jNoDFB3Th6PUwfHog9Ija68/O1iQO 1S7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7qdhkRouPUBlhhUeuoTWCcVW3x0+uiY3ffJ1oCMZQUk=; b=qspGvqppsgOG4TxEvgJ1ZlpABEd7/eb+D2VvQ9eLlFcBox970ghmC4r1uEK99hfk1m l15+iN2pAQAeGmlnfveiQG2ISPuE78DHpLUv+xfVaY9aXt42nbtaeL4WuQZ23s/DQ5lZ BBI99x/W3Vvol/bumvLq36FCzNzJRXi9P+TNp2RzQIm8/IxJffk3DXSIUWPqJWcPH1uD F5qox5rSqsiP3lcMSCLjtvATgg0fKNT/1BQIW1IhulHxDGPB07ZrxFWSwE+9+Dkuh6hp 7WrYsWVJhUUQ0jE2o3YpjPV9II+pKmz8+0cXPpJr0hLIaJGjwUm8YLJJfpHFwYGp6i8t MEsg== X-Gm-Message-State: AOAM530JUaymlYptk9hF6+gROz6JilX4+KtVHyCrRNL1jgZs5Bjp5p7S ktfqom9K6ePs/hZPMIMBzgg= X-Google-Smtp-Source: ABdhPJw4fjyrkxIC+QZRszgyocPb227aTwysjA6Y6+BSsjmYj3MtfEQbRiHUZN+EhaJlycSon3FALA== X-Received: by 2002:ae9:ebcf:: with SMTP id b198mr40726993qkg.488.1600595879999; Sun, 20 Sep 2020 02:57:59 -0700 (PDT) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id w6sm6968323qti.63.2020.09.20.02.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2020 02:57:59 -0700 (PDT) From: Ansuel Smith To: Miquel Raynal Cc: Ansuel Smith , Richard Weinberger , Vignesh Raghavendra , Rob Herring , "David S. Miller" , Jakub Kicinski , Andrew Lunn , Heiner Kallweit , Russell King , Frank Rowand , Boris Brezillon , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v3 4/4] dt-bindings: net: Document use of mac-address-increment Date: Sun, 20 Sep 2020 11:57:22 +0200 Message-Id: <20200920095724.8251-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200920095724.8251-1-ansuelsmth@gmail.com> References: <20200920095724.8251-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Two new bindings are now supported by the of_net driver to increase (or decrease) a mac-address. This can be very useful in case where the system extract the mac-address for the device from a dedicated partition and have a generic mac-address that needs to be incremented based on the device number. - mac-address-increment-byte is used to tell what byte must be incremented (if not set the last byte is increased) - mac-address-increment is used to tell how much to increment of the extracted mac-address decided byte. Signed-off-by: Ansuel Smith --- .../bindings/net/ethernet-controller.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml index fa2baca8c726..8174f64e79bd 100644 --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml @@ -32,6 +32,27 @@ properties: - minItems: 6 maxItems: 6 + mac-address-increment: + description: + The MAC address can optionally be increased (or decreased using + negative values) from the original value read (from a nvmem cell + for example). This can be used if the mac is read from a dedicated + partition and must be increased based on the number of device + present in the system. The increment will not overflow/underflow to + the other bytes if it's over 255 or 0. + (example 00:01:02:03:04:ff + 1 == 00:01:02:03:04:00) + minimum: -255 + maximum: 255 + + mac-address-increment-byte: + description: + If 'mac-address-increment' is defined, this will tell what byte of + the mac-address will be increased. If 'mac-address-increment' is + not defined, this option will do nothing. + default: 5 + minimum: 3 + maximum: 5 + max-frame-size: $ref: /schemas/types.yaml#definitions/uint32 description: