From patchwork Fri Apr 9 08:37:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 419017 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 665A1C43460 for ; Fri, 9 Apr 2021 08:38:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AE0061185 for ; Fri, 9 Apr 2021 08:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232087AbhDIIic (ORCPT ); Fri, 9 Apr 2021 04:38:32 -0400 Received: from mail-eopbgr30077.outbound.protection.outlook.com ([40.107.3.77]:50793 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232021AbhDIIia (ORCPT ); Fri, 9 Apr 2021 04:38:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oAIt6yb0SaEDro9WVE3cm1MXip0/7SZ2GoP74TnUiL9+WnbaRVUD+/fsPtg5xqJV3LRbaaGqaYTo5EiP7gG5rNGuigL+2rdIIEenDdCDOjzVROLbDeFe6M927VxGKVgT69sKHnq4CLwoxI/BtTdesIGnz2+Xg50YhdmebJHYR1PJ6yd7hUlCFHgFskuKZhcEIpND6uRipgjLIF5IM9S1J+gxbLH+i/3nXgpj10jsqMcsLnecgqR+ZsFAnZ0siYAd3yRHIALNXsx319YVDvkkA/XcMbdBLfa2jWj1jkhk9G5KAmCo4yd1w1gr09o+hek9gkuRSABGEs5wey31mcbTuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ci/5m4BuQuvSU5S9ipW21U1f1kWeQmz1Ae3R+0Nlexs=; b=HDQIZioovzkzse9YBleGFKnTPU4P9QneOgpsFklwD8cUzvpsTSzxKKGK8D6q7Nnf8Xank6uEbPW3pWXaAleD0vpl+FW8dtLqhEQTgiGoRFaWk6SSB00DYcSs6unV4237kFyvP+NG1NrSke6BgsrJHBmyiRfkKuCTetxaeXH3e92Xn0M619Eot6K5jcGNVfM1kko8a0cIwuKCso+7/TB7n4LNlss8YEZgH2ZOp4+gakfgRSKAYIs1f7KG9ruzLZmzV2+EYm/2fKWOfnZjSuHrJQiAV8+pJN4XruPqDQO8Nqp2g3qV4cJ1wyqYmZXhOUu7OKcs3awhxL7XDTUM4IyaQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ci/5m4BuQuvSU5S9ipW21U1f1kWeQmz1Ae3R+0Nlexs=; b=KYp2hp7l8kbD/OR66tow9HxQrn4BV0hg84s541PkZZEFha1YPjVu21X8Ug3TtKTwxjEd11oaztjrqd0YQpbtWVchIcKQI1iyG2YoQyDpFIg6AcqmBYBchylEsrRUXxc6PThipYG/sj7LGSm8mcaxatfagEj/WzeoRb8+tNgKBYE= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DB7PR04MB4521.eurprd04.prod.outlook.com (2603:10a6:5:39::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Fri, 9 Apr 2021 08:38:16 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::9598:ace0:4417:d1d5]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::9598:ace0:4417:d1d5%6]) with mapi id 15.20.4020.017; Fri, 9 Apr 2021 08:38:16 +0000 From: Joakim Zhang To: davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, frowand.list@gmail.com Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/3] dt-bindings: net: add new properties for of_get_mac_address from nvmem Date: Fri, 9 Apr 2021 16:37:49 +0800 Message-Id: <20210409083751.27750-2-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210409083751.27750-1-qiangqing.zhang@nxp.com> References: <20210409083751.27750-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR0401CA0014.apcprd04.prod.outlook.com (2603:1096:202:2::24) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR0401CA0014.apcprd04.prod.outlook.com (2603:1096:202:2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Fri, 9 Apr 2021 08:38:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 10914813-7557-40f0-c4f9-08d8fb32d17f X-MS-TrafficTypeDiagnostic: DB7PR04MB4521: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /IQi/usn4tVSEtvVjJm9eVW9NRY/4P8K7CePIcUEA/2ROn5Puh2DP2upI0bsim4xgx/6HTBoh3GEZ93TcSFOw0mhFBEJOUdxK3d96pAYuYKIXI4ya0t08qFt9mgm3txcp6LBck6W+l+in7fPMEkKCGfr3T47JtUjZmc34qUUYvFsxuLDw2WGjFgEQB4q+gnUEHEgL0BBPlLgeqlpeifRouYwDFkcKvvJ3cFhnCevvAqfHSI5Qc2zm9jvazJqxp5/vEUe9B63R7nY5iyxyg2lAz7s8gFJQYbCijxG9Ksc73Mth6Go2ls0zUkqdeLxpWBwarkuuKvU1D/hF48HZp3QvGb6aZM26gg/SWncfyTr2KPd5A3DjZ0FGKIfQVm+5w3zWkKCb5TGG2ceFEoK8pO82jMKhPA1WM+H19OOJVB9x3MgxIH5FlstMQjOvUSycalNIOx0K5bZRc6y99OaixEhZhBUVv4D0wExVghh6e0yODvpQs82FMNqqpkoEewr/+EfS/SkADzJQUDaJsbM2ra6JRvBz0kpe1/Xg0WlOemjCfBqnzMxLu8/jD9IinrDhr8oEHgAs/rsL3QC6PffV7HRBFEPaebc7iBCkLTajdo+Jcp21L1BJHEThQZbYaeCohSkFnFzzOdWBBfKDQ3EaaDib9lKZoCuVx0FnXaLBFQKakW9XylieuFthYUHhFsWpV62HM91272fXzKExqkBhuixfkGhUuIcY6PYQFrBV2QfZGQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6795.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(136003)(346002)(396003)(376002)(8676002)(6486002)(52116002)(316002)(6506007)(6512007)(478600001)(69590400012)(83380400001)(8936002)(2616005)(36756003)(7416002)(2906002)(26005)(186003)(956004)(38350700001)(16526019)(66946007)(6666004)(1076003)(66476007)(66556008)(4326008)(5660300002)(38100700001)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: oh3aaXVpF+jSsSnaxfz50gpWUfcpBs7LIBa/YHAtzncjpafrsCX0jjYmczYNTbhc9n9m3uHUEokwTVhQCyjgVCMSGR/wOqtudjcYCdVtr6VnDDzmhLH+XqBfqFQQaFnAbOcc3Idy2WQa8ctZgqUdFc3VbMLDY/PrSK+5uoCxPaB/PauEqifS9mOoyEab9ILG1Y5q67CN6kHDYb42QU07DbZe52e0O159dWHynDRsqUYxkJ4RQRA7VUhV2JL3WIrjp8OBH8QmVk7lK1hbuadIxEgZJyW9qXBLwsIkHqwWZT4TOD+c/DWJVKg6WBKBRr6V1EyhyJgKUmPlleDwd0bxn2xcmQTkiW1iAi3US4mRAQgkgqX8GDhXoOSCdFO1koiE+kZ5R30m9o5PpLwEkO4FClWNBrMQig8b3QoK8Bs8Yk6USLCikHdCm585XxPpSjakdXy3Y+MohlcdLKXrigwCHuBI4Go2nrGW81tOdoZNJJJgVXty4RVXj2r/Chn3j4Kl1rAe0Q/V+oQeiLXmWjKBKW61xL8HUCdbEUt6t5xTNjA4EJMZfHpUOBOYdUoitzGm+ToStpZ7a/K4oN7MJ4Phqeru4Nd8/cjNq/3KWuaxnBOUPzFtxxoE3kkRYzeWajX2YXJoX9rl1Hx3m0h3KXlQXPQFih2Sr2MHSWER5dr9AjHYIC1nkbesjoKdSZk3yf2gQq6/8uYsU58S4bzS27bpjD3Rpo7vKi/SmWnhqFO0mLJBQnpdEzZnjz7AKrVIAFb31H1Vwh9/ylH7paHSaQt9E1WCvWtUgOh6ceSnk4nWMhbNj4J0HdauaVTJWHxrUWYL0TwWra/6Phamc/gxAt6lrkuOfhwAC+I52E/8nc1EqFXfRu2hJPYtjQlFAXQsIu+F0illIzzAJq3osnt3ejaP1IC+YSoUtFzeEwBWJfS3BkvgKlvn1l/ZdUdtQBZWmRwLDvSkkYpdMVBuI5AsusyWcGE6eUcvU30Wqu8BWKeOYAXS+Y1HS7ijeWHgtLCZ2IGv3PtO+Whb1OwNbCde58+NPCRkbLFdMpxSSuf1eu2sN4J0HkZYsB65hQUmA0UpoWRs7uz5FrAjTCPIs9Y8G9yu78ZWgB2xkB3Ror6mgPfTkA9+rRJCuPDP5NTQLnKjgRrYTNtaoih5L9NwwAjgAzLccfnmQ6Ei9QVRhTTM2zo6HD1zTxzC77lrgaPA3ITkn31IbtHDMfr1airL1JIKDy4B5PwNXNvPU2JLlGJt6Wedo50ToBuh8m4LwtrQFmMfX0ZDaJJvjxpfVzp9/yM1dikBvfTEF1VU/g5YZcBbkrw0IoiWv8xfn5sPj5sQ2vSityFo X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10914813-7557-40f0-c4f9-08d8fb32d17f X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2021 08:38:15.9681 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ylJPxWitLIr5lKd3vulXOXoE0qrqS20qq5iZn/Syajkb4GnD2n0HjlEJJNKW6aA5R/EgvLeBMH80dffoydk1XQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4521 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Fugang Duan Currently, of_get_mac_address supports NVMEM, some platforms MAC address that read from NVMEM efuse requires to swap bytes order, so add new property "nvmem_macaddr_swap" to specify the behavior. If the MAC address is valid from NVMEM, add new property "nvmem-mac-address" in ethernet node. Update these two properties in the binding documentation. Signed-off-by: Fugang Duan Signed-off-by: Joakim Zhang --- .../bindings/net/ethernet-controller.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml index e8f04687a3e0..c868c295aabf 100644 --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml @@ -32,6 +32,15 @@ properties: - minItems: 6 maxItems: 6 + nvmem-mac-address: + allOf: + - $ref: /schemas/types.yaml#definitions/uint8-array + - minItems: 6 + maxItems: 6 + description: + Specifies the MAC address that was read from nvmem-cells and dynamically + add the property in device node; + max-frame-size: $ref: /schemas/types.yaml#/definitions/uint32 description: @@ -52,6 +61,11 @@ properties: nvmem-cell-names: const: mac-address + nvmem_macaddr_swap: + $ref: /schemas/types.yaml#/definitions/flag + description: + swap bytes order for the 6 bytes of MAC address + phy-connection-type: description: Specifies interface type between the Ethernet device and a physical From patchwork Fri Apr 9 08:37:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 418380 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 5D9ECC433B4 for ; Fri, 9 Apr 2021 08:38:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3199D611AD for ; Fri, 9 Apr 2021 08:38:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbhDIIif (ORCPT ); Fri, 9 Apr 2021 04:38:35 -0400 Received: from mail-db8eur05on2083.outbound.protection.outlook.com ([40.107.20.83]:61615 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232161AbhDIIid (ORCPT ); Fri, 9 Apr 2021 04:38:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gx9mkAV6rvNR46tIQpss9qc0oLZrff97TsSnaciYqOJGuFf7J8fn8D7zdComSDO5/ixF2llWWU0qIxxW+mxFSb08jMb/+L/jmrQnq9OAQ7CIYTb/+VM2G/hph1CSHKydcQE6HLj4XFu+7VoEM7i8aLgWLVNIo2pf9vHkXnA1oA95fnTACrgVCK8rHlS95z+yrT4izE7F4EcSUl78zKXJnKX0OWl+JkkWiib/XDzasjHuudvlC1VMJWV43qUniXJDRiOR+N4UdSIV3JLly6RRwpPjAuYS6/whVGuPFxrxczmiM+CLxzr7JQFNyz7tafK7i8k+e7dgNv0LckaSye9d3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3iB9kddQliaUKAkoLWowI2Km+Ju0958c8++EXuYyz0Y=; b=SGwUHhcfhAcA6Qje1EnQCergD8jI+nO6o/blyLsPx/I5CVFuxQIR8nHvG2EyW5FJZoQ1tW2Cb1H7vlImGcHA4eJRo66j05NlKF7B6ku+rgdNgWIlnRqdCE4mu7CwgkJ2VfWDrNJFw1RZU97Xwsr/WafMe6SRe/VtiD1pN/oDGL82oSFKA8iSHVSvHXZIIpXTNgt2E6QTGzdDeliLNxKt1XxkyBZ2mgUKzimNVhFJmbE+KxZ1O9vODA4X3uOfb8ngf5VRi7o7ldhZFVYIytvZLlgIw2ZmaduHWrmhS6IdfqcYUBpgDnucOOIq7i1UHdOZdvft8PMaLGhk0+n9KaZZNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3iB9kddQliaUKAkoLWowI2Km+Ju0958c8++EXuYyz0Y=; b=ZHquo/VAdubbsghaHuFTCouXS2sGRnJ7r18+olPMnm4AaRaw30tBSIjZnDuEPmnaVlzcdfgDRINWuLb9mb9sB5q1+QlAwhkcbZmJCkMS2b06sfIz8p2lY+pdRIEvw+nA0OXNE2aCFjPEQWhoZ5SbFNrSwSN4YTeqB2eMgEWPUew= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DB7PR04MB4521.eurprd04.prod.outlook.com (2603:10a6:5:39::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Fri, 9 Apr 2021 08:38:19 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::9598:ace0:4417:d1d5]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::9598:ace0:4417:d1d5%6]) with mapi id 15.20.4020.017; Fri, 9 Apr 2021 08:38:19 +0000 From: Joakim Zhang To: davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, frowand.list@gmail.com Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/3] net: ethernet: add property "nvmem_macaddr_swap" to swap macaddr bytes order Date: Fri, 9 Apr 2021 16:37:50 +0800 Message-Id: <20210409083751.27750-3-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210409083751.27750-1-qiangqing.zhang@nxp.com> References: <20210409083751.27750-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR0401CA0014.apcprd04.prod.outlook.com (2603:1096:202:2::24) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR0401CA0014.apcprd04.prod.outlook.com (2603:1096:202:2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Fri, 9 Apr 2021 08:38:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 004d3919-dba9-49ed-f8dc-08d8fb32d3bc X-MS-TrafficTypeDiagnostic: DB7PR04MB4521: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 45GDGOHwwfM6Tm583Z6BN4Nb63uN+yAIWQu7q5uOInWsGV9cvf/ndxtlrYMpq2fR/Hr8C6SAWrByR+ZYRX269vChFWsSZTIVzSZhFYFNgTh0ENO2fnuOXaHcdmXn+VlsWEUH3vd6vljl8ozw56tCB5w1c1vmUcDh59zLZN+2pdk4vyQ1iEqXMiD2OAbXmtRIIm0Cqhtkei9jL1NAyn4DmERZp2hfIAqgAWw2zKdJ8XZ0ccCZL7JoUdQKv271b16xX4M6Ggl5qnWpcRa3IKu2HNorV8jy3iC6Pm35cl71vq+OOOxfaZqe5kRhVvOL93jRJDin4kA3r7v077A/J0QO7arQRxBaL4j9TiTb7t/UstLVvNrylm3r2AstiWK/uYGpKYiF24hL4YCksAO6T+gaL2NTRKOP2hU/zWwcABtsfuKug3a5GOXh60j2wke34xvGp8YtVfiGk9/qNp/n5GuJYrlSFGLFLNj/3D5iMYf0d2vSp51s6ManXWIkp14bJiRM+pU8aud3FVu4Nz7iIQGNLtIQ8RiHfv8n9Fc3in+KbgSDAd6F9Nb6E3jk/xvpNROtQPPWY7Slpp94LWIAw0XO9moOYMdhkTjLwM1qhGMuSZqZnuYzf5UUHxRuhmcVwRW/FlmXDaAAsMNm6nxGmc2MGfLqsyq7XlObwQaY9ouHPDPpAdjR/1qeImtMwalWOw2xRQwQq45FdpqOJjREsMOzhdFYsrvOKIOzxKNM47R7LQA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6795.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(136003)(346002)(396003)(376002)(8676002)(6486002)(52116002)(316002)(6506007)(6512007)(478600001)(69590400012)(83380400001)(8936002)(2616005)(36756003)(7416002)(2906002)(26005)(186003)(956004)(38350700001)(16526019)(66946007)(6666004)(1076003)(66476007)(66556008)(4326008)(5660300002)(38100700001)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tEyeKy9IxcjhcB3Yshd4KrUlk0YuZqcbCMF0exWvcAxFg9xNy67GzaRv7sJUyvT2t019O1/juRXGm6OImH5FJ2/1qBH/RsHCxo+p3Bjv72SOZNS72Je6zN4r5Ct5Ulc8oPl7HC84256aMNabWh8HRWXKpoPCLTl85kfbMvVKUMx8FVs93kTohmmybvUhn6Pu61DPkdQ57BLxkFSx3mHF0XI91aSkX/Fz0aV00fH02DOLhdUWQA5W3N+2V2Bp8bMHEEl7fVb/5DYjl2xaltlsNtalpwH4sjVs2Jr8N4eLxXe/Y2GMWmFYJiX+MtecUT/l2elI9yQH3jEhw3rps/vsWZvlDJvbBbejguKut5EOCaorXDqfAmCa6LducURb2nxkTwYTARNixgnl9xCjaSF+sWZyYZCxoJdas+pGV1n1MteCTyapVN6vSqQzcKL6U3xaSYUsPzUH1cs68q7ndknVuQ+Je1tqQ7N1+3mnZ/s+IZUC3PSDo7OqnkcoenSiN5VcyFLsmAFI/27oqtGnE1Ict1Dn3pu8AwIm1kRY7WKZ4uC1wZCB6O7iPq3pvapxM2EFC5cw4whdDLHaqp04MDM4ADRmYA9wOT5A9PF5J3BEgXcaS7CLXvVyC1qbHhMq4XTK2wXThSTG+qI/k8YVXOAe21Tqg7hEXFe4BFMWKeRFF87Fevm8CHDlGiyPfuidY+V59ZWmmpzgbRVOAVPiAsrL1MkwHqu9qlaT2FQAI87sgDu4hFFyRw+xSgHkKCRMGycIiaKTqNhHh1LogiRRd05MNn45fuYDilGj5CgkRXnLZhLxMwOxPUJmFdD7NOa6Xkqo0RZN1ofjc11mosSXS0dNW2SoQA2809z5iFCyU4UGr9q0oYG0czZfDqTo1Ee6kjLYbkTA8pTCzCLtpFxq+jmAh0RIaV++9WzRemKiMMaN703vHvIcGijxAov79sJDnazP82QsWIhLnPeOrH0WkwmcGz88pbmd7T+ZhE+bLMwzKKdJ+tllDvjYgHvJDzb4J6qGMLYcOOGKKeLNSb4WfzZ/KsGQOVCciahdMS0zqtV40ueGC8sUi2cvaEciColojp2zkpl/z9Kbfsz3JF+gKqO4nKt4XSp8PkchWgbt2Q8MFv4D0+1TLSU5if+/FkRFKAw+8bdtFZg5Dfy/i+7XBamcfkSfmlvfKVbeP6mcHX2DCeoZ2ILFVHVt5F9iU9GboUn4QThI3LFXhSVqn8SOmkHKHWn8nsarrMJeLuw9rx7S0Grb/4ypQaFHMpuyuiDnIZ5wUxv/C7HJ4Y79q7GqNZxaGJONGJ/uumGGtxoLxvEHObFhGvUKbO9i1eNmRwqLxGlR X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 004d3919-dba9-49ed-f8dc-08d8fb32d3bc X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2021 08:38:19.3483 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: stWM380tICWbwHEwRGLX3WZZcHC9taJxB81XGqJHEl5yu7afnBG5I5ulOOrkOC6DdNMDctaoumTKFqV6sZq1QA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4521 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Fugang Duan ethernet controller driver call .of_get_mac_address() to get the mac address from devictree tree, if these properties are not present, then try to read from nvmem. For example, read MAC address from nvmem: of_get_mac_address() of_get_mac_addr_nvmem() nvmem_get_mac_address() i.MX6x/7D/8MQ/8MM platforms ethernet MAC address read from nvmem ocotp eFuses, but it requires to swap the six bytes order. The patch add optional property "nvmem_macaddr_swap" to swap macaddr bytes order. Signed-off-by: Fugang Duan Signed-off-by: Joakim Zhang --- net/ethernet/eth.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 4106373180c6..11057671a9d6 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -534,8 +534,10 @@ EXPORT_SYMBOL(eth_platform_get_mac_address); int nvmem_get_mac_address(struct device *dev, void *addrbuf) { struct nvmem_cell *cell; - const void *mac; + const unsigned char *mac; + unsigned char macaddr[ETH_ALEN]; size_t len; + int i = 0; cell = nvmem_cell_get(dev, "mac-address"); if (IS_ERR(cell)) @@ -547,14 +549,27 @@ int nvmem_get_mac_address(struct device *dev, void *addrbuf) if (IS_ERR(mac)) return PTR_ERR(mac); - if (len != ETH_ALEN || !is_valid_ether_addr(mac)) { - kfree(mac); - return -EINVAL; + if (len != ETH_ALEN) + goto invalid_addr; + + if (dev->of_node && + of_property_read_bool(dev->of_node, "nvmem_macaddr_swap")) { + for (i = 0; i < ETH_ALEN; i++) + macaddr[i] = mac[ETH_ALEN - i - 1]; + } else { + ether_addr_copy(macaddr, mac); } - ether_addr_copy(addrbuf, mac); + if (!is_valid_ether_addr(macaddr)) + goto invalid_addr; + + ether_addr_copy(addrbuf, macaddr); kfree(mac); return 0; + +invalid_addr: + kfree(mac); + return -EINVAL; } EXPORT_SYMBOL(nvmem_get_mac_address); From patchwork Fri Apr 9 08:37:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 419016 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 1113CC433B4 for ; Fri, 9 Apr 2021 08:38:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB0C061185 for ; Fri, 9 Apr 2021 08:38:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232021AbhDIIin (ORCPT ); Fri, 9 Apr 2021 04:38:43 -0400 Received: from mail-eopbgr80057.outbound.protection.outlook.com ([40.107.8.57]:60167 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232358AbhDIIii (ORCPT ); Fri, 9 Apr 2021 04:38:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EeGgbzNx2cIyVIhPMetVsvHc2wnto8aOspOO1WBLveckg6CYOqmEXmdw1X2NUM8ARDJTeFl8Em91m2qSZsZBrJane4xpjo2A0IVnSu3vl4ga8TIJIR9rZBxahc9b89b8O/wI6GB97bzIrkCgw6OHgfDqbn0EHN09dpS8T2WU0mfEryoUasrmIbH4fyKk6S0kquKucxp8D8O1jje+w7T9JOrkvfEuhqrM/qyU9/97SaRljT+vQSog70hd+oGx1br+Ebz/PJj0vhlpbr3po0J+bSD6WWLNA5Ll6lvjlCPWllvbzOppT4teldZwhHM3AnexzAyLdLWvYq7w5PW+6eN6QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OMlg2fxi4P7R0H3wJXlXTRCG+pYcSmWvSfNx9ui2a+Y=; b=Ii878GK+RWlD1U2bt7CmTa5HqT/ICieSfHwxTpk+8VrCef0gJ0qDw6iyesUX7a7AvJwydYtrwyG8EIscUrbxXNwJWVyraOuvFsHVMZf/GemYH9aZEdh3xpCU+RDbVfpAB8q7Nt2PpVjOTOPL5+U1EmuQu7SLx2I625fdBzNBeihDer3d4cw8Sb8hRHHa3xVQgTcfl5T8Q8+copaGwGyvUsipiGRWVqdx9+QYyytbXShKfTGyWUOq5Gz842uDI9erqavDOUbKgJGwUGDr7tai3cFeR+YKSCURReTktOzmO32C7gur5oQVuhUuzaKc2aLOEBQtMX22fkSPeLer3Ae0cQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OMlg2fxi4P7R0H3wJXlXTRCG+pYcSmWvSfNx9ui2a+Y=; b=nqLp2zi2Q6aR5aJJthgii3op+LqdYtGwVSuHElOIZAnHaEoW84JDq5WaaDqgbOZBMJzgvN8y88089OOJ9b1rwBX1n/cO1wtehtAzmfERFatXBKACopjOPsBxM5q8awqIZ9P+jiH8kudZU0YOi6LBXQ3Mc4rpEz7U7VdLa+aBPcA= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none; davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DBAPR04MB7400.eurprd04.prod.outlook.com (2603:10a6:10:1b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17; Fri, 9 Apr 2021 08:38:23 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::9598:ace0:4417:d1d5]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::9598:ace0:4417:d1d5%6]) with mapi id 15.20.4020.017; Fri, 9 Apr 2021 08:38:23 +0000 From: Joakim Zhang To: davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, frowand.list@gmail.com Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/3] of_net: add property "nvmem-mac-address" for of_get_mac_addr() Date: Fri, 9 Apr 2021 16:37:51 +0800 Message-Id: <20210409083751.27750-4-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210409083751.27750-1-qiangqing.zhang@nxp.com> References: <20210409083751.27750-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR0401CA0014.apcprd04.prod.outlook.com (2603:1096:202:2::24) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by HK2PR0401CA0014.apcprd04.prod.outlook.com (2603:1096:202:2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Fri, 9 Apr 2021 08:38:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7369d7f5-bfca-4e5d-ecc8-08d8fb32d5be X-MS-TrafficTypeDiagnostic: DBAPR04MB7400: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hOd+7uLQY+y1r0UllORq1FZHWca/zhjsdUHMXE7EZnJIh3/foEc4KQEaXxuEQ1fXG5lHvEAWTnPHTA9Ft+MF/0QdupAGy30ZXMPdEBWB/mqS7swlw3koR2bhR5ny+Wpz+v0nLmPUMd6Sp/PEoN8ObtF/i+78ettuMZVAoN64KVsJCPL/0vyPblrT20MVKcz7ujAwnojCWttitg2wd83aUngo2OWd574q57TSEEZhkr3E0c40UnKz3wMBrjuWn7VrFMXEp21Bf1xZSyc88o4ajc8ALuD5Er/EwAvom2vv8NglCA0QxxnXIqnGJzcnMhs6tgUv3AKRiCnZgwql4fu0wORq4vn2RyRy2xbJV7VxfNS3DxbAMcst3pVMPM+g/otCHu0cYKkOeCeXEP/U4uNccTiIVH0rwsThwMnSyPRWxTl4MTB9Y+rowdtxbXQAxfyWIu45AU8bgrGRorXYaIPY5WGTzYZHQH2feAJgNabm65isFB7M/bxnkAn7E4+F8Pv7zC2hAkrX9jbWcCXu032NYjgwQAoJKWSJi+VsX9BZjbBw/gHe3Usb6hvyfVu9qQszPPFS2wHQN7NiRaTv+caFb7OUlHLqRX6fIUqCQy+dQa/uD5HSQxJpRkDJSLZctQp2Gj78mKHLDEu7QNNgiw7pey+S5dWAo/wZXSsv8HqsrwT5Ue3IbwOoLlEcusyQVXa03g8xfx1Y8TZ5odG6f9lU8EFjlGqzAN1/2bONdsxJbGU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6795.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(366004)(39860400002)(376002)(396003)(346002)(38100700001)(7416002)(38350700001)(6486002)(6506007)(956004)(186003)(6512007)(2616005)(478600001)(36756003)(4326008)(5660300002)(6666004)(4744005)(2906002)(16526019)(316002)(8676002)(8936002)(66476007)(52116002)(66556008)(69590400012)(86362001)(1076003)(66946007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: mWlQT1Hvc0GxtXfb81wMkUO4R8iK9qGaUZTYrYTPLn+d2NvdTdGsMdyP+HXtrubWh0rJXJWl7XouZptYyw0r+Vjk80yk/QS5b1xd0qtlDD+tks0VoOF9Bb9zjLDd/iBSHZ7NRAtdx6J/jI2mqmQkpRZRA9oVzBMxvzgpOK8gImZIRCa4kbefT5bKYxDIRBGp0yEVysP6tgcx8P1rQiuIkoZVsQ5PpnuVW7bstcfx09AmsSo72ybCyEUHCvRibBW5jfPlhZ9c5duFiMqeFqjF1EwlplZsTJc4ItIvfOTVOH8HNsgd0dJvPq7wCgoTfxYZCliG+lY4Q7q5FHKWnHN22uMMpOGALRVzfnO2h+1WnOkpdGBpIQHdNuOFTjHrjKTrVkISDIkx+XkY9TvIakhptfzkFU30ear6KXqS0/xIJziO9DB9b9F5rRX/EmXfHXJ1QiQv94v3PqSZjLnkbFlGwSycQs3tMsb4lAcoinAL2McpwFu/4g2iRjSX/wdQcrMGk7IXKEbZBfBrkMA05HQH0UQA0vt2HMSgbWTpwB4P3hfpaTOtni80RHEZx4sld/5AnOJB5cnszvbLQ3ihltUxkFJRguVg/mU1SEMdOz+kPEcTlcjCRL7wlxcjotccsOU0PNJuffD6VdHQ8FqrEcEYunL3ryZW7rCPJd0LmbkrJa+GsTFgSBfMb38JuuQkDoz5/kbCpUdVC+j/NlqnHiYgQNAFYz1qt6URoVpiifx6sXf+dDbcccZDYH75HKESxQbum9hEQ4h5To/76+YQRVybpqT9yMgoHx56TdJ4VGvmJyTL4UM26nXLMM04NEcnK1Ak1znPHeR9Y/koELERRVamtezuZUQbvhvUX8fjwwNsTa4W59In65XkZQVGwB61jRngXfeX1IypIkXsuuv7+LBclUBRZmjQCRIhHGB+qGSCEykBCLZK8YnPxL0Tq7rfFfA/EPDO1krvjEBGoryIiGtvaTeP30KQB8qy+iY45E6LI7DByolEvkfY0cGe5Xc+ioCSHrKfZxRtdx6AsqdhyRhKAcE1Iu6Idzt0oc9gCSycnfrAr4YP4f5IcxGO0RgtKyD/6eLndvKW8n/LDiH2flL/BBJjK5217DfRtGUrqbf2Wki3aSCrbOhS6rU70xcEDEeHG0AqtJZ1J/PXhyq22gcUpjqxiSl48pe7YzYKPvoEy8tIDXwrJ8hYROCW0fB1R2hPnP7mX8rA99UCmSNctClxMmDDkBm3WB+Ty6Pbg8lgnZXV4sp1uzBJ5YXNULd+k/+9z88EXF+RwPstEu+DJ9P63bHpPwACH6cI/8PqwNm0vRKwEsKZwgwGbkm1pN9O8ypA X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7369d7f5-bfca-4e5d-ecc8-08d8fb32d5be X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2021 08:38:22.9415 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UbnGTN/+Ob8ikH1G27e9lDLAfnCQFYGkXtu4L+SnZtoDdE16MNBlWA1QhXc1Az5ZmssmEPlGZJq1q+977JZnuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7400 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Fugang Duan If MAC address read from nvmem cell and it is valid mac address, .of_get_mac_addr_nvmem() add new property "nvmem-mac-address" in ethernet node. Once user call .of_get_mac_address() to get MAC address again, it can read valid MAC address from device tree in directly. Signed-off-by: Fugang Duan Signed-off-by: Joakim Zhang --- drivers/of/of_net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c index 6e411821583e..20c3ae17f95f 100644 --- a/drivers/of/of_net.c +++ b/drivers/of/of_net.c @@ -116,6 +116,10 @@ const void *of_get_mac_address(struct device_node *np) if (addr) return addr; + addr = of_get_mac_addr(np, "nvmem-mac-address"); + if (addr) + return addr; + return of_get_mac_addr_nvmem(np); } EXPORT_SYMBOL(of_get_mac_address);