From patchwork Fri Apr 9 09:07:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 419012 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 CD0A6C433ED for ; Fri, 9 Apr 2021 09:07:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFFE3611BE for ; Fri, 9 Apr 2021 09:07:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232964AbhDIJIF (ORCPT ); Fri, 9 Apr 2021 05:08:05 -0400 Received: from mail-eopbgr40081.outbound.protection.outlook.com ([40.107.4.81]:40854 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232579AbhDIJIB (ORCPT ); Fri, 9 Apr 2021 05:08:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j5L0cz5g4FkOvVYgixRuAo7dkUcyN3Z/O7Rg03GCIEKw2fLRmzFK0K/Xx3Xuk+I4FFZhnJCbeKbjLLHQRTEDNYYD0r3Qb0vvCU+rnurtGWQe4GPxzrdwtD0PcXaF8kDJOlKeRDjgSIWWozenNS2drUSHIVRexsjK4Log6X6rIxB58TErOPsAk6KCNjgDlWxrwxDAf7L1pNDAGrKeKMVc0e5tiZZoYxG3R1faAkFDy8DsTzng7RFE0yvpbJ3TwdbDi/oyRdPlycwEESU9KMDomCVy/vcJ16n9HQ5XKxtdxOBfOGUB4bAKfsxK7zdzL0c15oH49cj7ddmGkRWjzcK5bg== 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=lWBvoFVjE6+30qyzzgzr4Dc+4MA86eGbdLCXmLcSOTKW3Yslmkyh4RwzAW8vsl+TfDcU6LTkCPalmAN69QSUrzygVXJ0M2ck9iRzdItqt13nhsxHQzXGvZFeYsa4+Fx0+UEzS1zG8i8zpPHJeav5PS6luvZMqfGZq6XgbDxk4UwHA8TsnSpLAY1bAhF709RdR4APCbK4OFsuwz8wfm6yEZYjR3EUH5qKzWTP8PzwA20Olt3D3Af0AMOwoH5UoGnstkuiCagkhflrKo3GOVS7BTq5t/zI1EM5MdPQCF2KLnCVBylDrZbf+HeEvXqgnf5f1UDLpjcpTyKgr+OAFuRehg== 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=i+pVIago42M31cSc/lcFlHEi5eabBvRALYG2VkPwgxeHjYpEVHUAtEM+s7uNwtt3KCVzDgUZU6eVYj58K35Sg2GHoNqfc0lNsg48t8sYQ20KJhA7uwIHZyB1WkVSnpuNW0WSnaOmlfLeISoJIrQMSpsfuZJjH2I/1lm7xclBe2s= 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 DBAPR04MB7336.eurprd04.prod.outlook.com (2603:10a6:10:1a9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.20; Fri, 9 Apr 2021 09:07:44 +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 09:07:44 +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, linux-imx@nxp.com Subject: [PATCH net-next 1/3] dt-bindings: net: add new properties for of_get_mac_address from nvmem Date: Fri, 9 Apr 2021 17:07:09 +0800 Message-Id: <20210409090711.27358-2-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210409090711.27358-1-qiangqing.zhang@nxp.com> References: <20210409090711.27358-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) 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 HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) 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 09:07:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3f5d895f-7e56-4aea-9f28-08d8fb36f006 X-MS-TrafficTypeDiagnostic: DBAPR04MB7336: X-MS-Exchange-Transport-Forked: True 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: zg+1Y825xvQ1mZP62Z5RC6OTgWq04pdYJzi9ycQLe13ez6gs2g9813ARNhdOdSC2ejr57i6DFpuspv1BmwBQq0wQSTQrYMEWmSoQAPqi2mNGQMZMSiraZawWcsuguDuZEsQzLAdV+8pCK4nXAcN8obfn6NNgjDritmcAuGQ3K4c3GBsp50z6lyxsp9dvsPdTyM5DNsuUVEizC69W1s7BYQH4xI7BZGCBn5mvBnMsfq9kf47qx15m3rjn6cJnE/5TQcUNsm6O4Fg5Mf0zHaUcq44Ms8V33E0p9Tx+3N6jpcQ21rOZe9U1DUJ3A26wNAOOFPkDYBEunsr4eopW105BXAHR259Pek9hiC9oFWPZm6f2qbE56hm0HDo2qccAdcJ90Kwcg73L+PQCu72EQ0Lu6K7WxmsUS4TwuoSTlEmWkPXWgjJleSkvgZOeRwc+Um4NDiY4ZHBsGIPmwcA+kAIlivnOIN9SAulpvpek/084dMGIhf4Rrf35gcXrGyz95bdFA2pTBk1j/r4qRdxXvqod9XdwH/zZTexsDnAMPSICXbkudE+NxbJL39OXGleVUegzx7v0aNs2lH+9302mmoLaSg1Nb8eyL2PUW5qSNeVd0pE6BOz5/0i2lCF8gGmsAI1S10P34fNdG2TvgbIzBu9/5H0jLoAqwN6OLq4D28EXBy53qX+esutCUpBBQtezel2FfEuP8UVuKHsf+o0l1ORFqhkW+4uOkxt41sFXJeISmA4= 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)(376002)(396003)(136003)(366004)(346002)(39860400002)(316002)(36756003)(6506007)(8936002)(8676002)(6486002)(52116002)(6666004)(6512007)(4326008)(956004)(66476007)(38350700001)(66556008)(5660300002)(69590400012)(2616005)(38100700001)(83380400001)(478600001)(7416002)(16526019)(26005)(186003)(2906002)(1076003)(66946007)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4JgpV8bUohBdBZbW7ekyTubE2+ZzcSME2XFGMBKY9yMUBKskvU0FDlaLzC4fJpF8ANvHl3S5V7gk8Hx4UtAUjDgW97egzl1noAK4nq5kHxsbYsJVV3WpjkH9WxeY7L4E4d+BgcFqeSk8SfkpzQnzldJs1W8FK2wne4Yfwb9g8sioUtpvM6AInJPS6uw5wmeatulv3++88DQnPV7sQsEz/39aDauJDKRvFvscPg/8TBMZmllLPh4eOZcU1zEnHk0oENtAPFNRHQOs2ld62aWvRRBvqCECIKrPzQLl63jpWR6Ru9+wQFqe0crfRJjcMpMXBhJeRYKYv3ANUvfXV6ev6FnQu5Hj3nNTlwz+R/Xfn04g+smLpiyHShTSvLtiuGzEI17OUEeEEv131aVAy5vE4/rXqWU6VOuqPuYQf7GXqzhpEWWolyaIigk4fNhTSZgM2GNh1eyjjpQCNQg8YjFNaNfMSehDBK2nw6UzVIIzT6Sroi1aV556TAh8LYOM6thwgqKAX2qHfeDthgnxcPxfOg0V3PtmqV1AseThEXH3TO2Y8tS8/BXxkTsFmDLJHzzpq/dyyPR0sLECZzV3Jrdp5CamDV9J+qcCWuF+2Lm8Kr6bw0U4wTxXfteUto39iOF3ZNZSGppj7cxFS9jk0wuZJ4bqEgcDoir3zfIg6qkOBoVZk4uu8koOc32XNr1cT/DL5eS14lUczv0y1+Cj7w93gGL0zB8xjwRkzDPl3kfeA1aSo5Uwmf09/aiBdkl4S9l+qkuBy5P0ng2kPPemreeuRb44C9vdmD1HCQ6HNSl8/AqFKmi5jnCgr135e18xChCKrl3u1/19z9nKqilKyKoSwMzvj6VqTf0VYG74ZhE/e3MFmj/nV4dgwSPTQ/iarDqEsIf1A7De14Lw+vo6O//7Tyu1tIxDWiseh6JZYBFUA02nx5AHcUpNzCLZG90QvGz3l/leBABki8KROkHZaZRiOY7m8tNv4S3ovcuP7rNqbcQaoPQdrKqNSJh4tlU5iFXYNDd+inAcAn7J/T30sKT6qB295i4GrR6M5lcVve0gi4hpsO8hBQsQlYIw5gCKjZnVlln/4DnEaChwz8gtdquQQN9eaW208gqJSH6ymwOL1FckAolgVIudXIpJCD0birFbWtFIeCJcqRT2SKj7jK+4y//a4cN1KDDGZfTBO58dkc1kXfvVd6azHJGwQD+PsFP4e/2dbZH+7H+BBeLRgUBGfh+Ch59WJDy/v9AVITD4ND8JEKPtBJk2LXZivbNS0YbUsUhCVZ1sZR8wpbMv7WC2Bm4mIzwMSNmXev2fa2QWM7rnIPu2/b1DdAFcda5jYc48 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f5d895f-7e56-4aea-9f28-08d8fb36f006 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2021 09:07:44.8279 (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: jnqUlreMLah/O7k1CL1QaKkW/nDOyKvlFyR+A0eDg+eNJW2QY6j3RZq57T7E82caRR0UlagXpn5ZLRBkaVh+vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7336 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 09:07:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 418377 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 E1043C43461 for ; Fri, 9 Apr 2021 09:07:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6877611AE for ; Fri, 9 Apr 2021 09:07:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232941AbhDIJIE (ORCPT ); Fri, 9 Apr 2021 05:08:04 -0400 Received: from mail-eopbgr40081.outbound.protection.outlook.com ([40.107.4.81]:40854 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230181AbhDIJIC (ORCPT ); Fri, 9 Apr 2021 05:08:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DzLRDogMHy+fgIicAfM5/V34L3s8+jmPRQW0/r1AbYaVgaIkzHe9Q5epqtCKklBKvSAwsLWG8vjxnh1pecfv9sjBxp+E0lR3ieW96UdMsbvZBb3Ew3Ahkj0EwbUg1jT9MbL+zQd/az87bycwrhSjCQm6Vpi9ljiPatE3u/aVMB9F5eF8teYlyKXUsY7a1x+eJSmFTL+WP9iFBkZ9o8bbEJgqnIhBVs+Hmt39jBteTc2d7G9QzO3TLgYBPEai+EUvc19BbVIaWuuyzNmVhMcXhKZhlAK8iWuTc113UgusZHr40jv/6bHpGKUfZ8GkbBSGLOc6Eavrx4gm7hZubpjMRw== 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=ktREzrNvxKmFyIdNdaJRrK3NjnK/Uplimt2VaehZC91RUcJv+2G6qODmyDpT/GdjbiFhknJWsMIT64b68NArZImiOx/sGE/KcQCEsdmHU4pc0rbkDiy1xE+WrqGnXUm7ylbe9o6gWeUKJneZ2xLi9nJtnihK5dI6o/avt+1nWA+VQx/c7ZhVHs3lVJWm9lcK5ZnaIn+tJBMaiFLH2+9fiufwIcML8COoIZ9av70EbulmKq6/GrFKL4q6wNlpClxNsMxDRYp1hKzZZNXRnTgckauYiXCrJelvzVtnOK5234Ypnq2XLwBPIqwS4LQdjin8+qfFMmTHUHbEA8enugYYHA== 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=S7/23Th/TfepDSrPjPurgsXlaO0lltFYVoFSx1VisIQE/qIDqSZ9Gp0Oufx7NEs8+BJXYoa/htyAQYggbI6DdjI5Vkel4jzNYKNSwvRTAylvLdqaSuBhkm986sHMvao3IB+2bFh5MXlzyovmzG+fB5pfvBrswl4C8j/slVhvKSo= 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 DBAPR04MB7336.eurprd04.prod.outlook.com (2603:10a6:10:1a9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.20; Fri, 9 Apr 2021 09:07:48 +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 09:07:48 +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, linux-imx@nxp.com Subject: [PATCH net-next 2/3] net: ethernet: add property "nvmem_macaddr_swap" to swap macaddr bytes order Date: Fri, 9 Apr 2021 17:07:10 +0800 Message-Id: <20210409090711.27358-3-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210409090711.27358-1-qiangqing.zhang@nxp.com> References: <20210409090711.27358-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) 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 HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) 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 09:07:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d53f914-1fdd-4061-51af-08d8fb36f234 X-MS-TrafficTypeDiagnostic: DBAPR04MB7336: X-MS-Exchange-Transport-Forked: True 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: GO5fSCTiHMqkEZ/b7BbANPYSrFlw2q/HU2Kpfq8jBL+SqVFIT3OxR7M0nMKHslJDDMNxv0mVFiZFMwma2C9ITx/V0reS2bKQXBv94dWf0/XmviWykFCwEhJ40fon9ILiuqSLbvXb0dj1++B15AV/Ygz1ENQZkUqnjLgkArhiHMTF6HSEXb50AWPbPgvKgNKuxiiArs1UWMHHQKnhAk7t1Z7frZRhd+MfxDUlUvIqdxgJJ9jqQqxxqf/9BJG4mOw7J6KrUEBvMY0P8T5+H9LKiZWspXefmkWX+wVPFCdX3TWPvNohj9BxF8hk3i+aW/d4BaDWFoPaqXvH/z8orYP7WPwYl3XNrLGRAkBFBs/OzVeUVwhN3V0HEHblj93PKxYWfndsEbuFhomdE84V/ghSF7dd6FSd0zMp9ldNrvgyDUOWlcfxy9HG9q7/cQWy9zZPm8kXJbHZavFDodxuraYO6pASet5Rk4iLaNvxv/c9LAkFT92Atidwmxp1+rM8bymblU1vTt6HRefgwYhg34R1r43t01OBmAcLHv/22dxV4ZG5fOEZPm9Cs6waEN6XU6M0XLpY4hGlimQtD45gpZQH75D1OXApcJUet+0ec0CW4reaNcgvsAUiBQps93nQaesNBn2IUipdqXegF+4qh6oodK3tiAtgAuYXWcVI3kF4RYc7VIvwgN5y+ECo16bT/Lfhprm9zzZjzBQTP7Ln9abvKL4NntJi7AnYpai4jQlh2GY= 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)(376002)(396003)(136003)(366004)(346002)(39860400002)(316002)(36756003)(6506007)(8936002)(8676002)(6486002)(52116002)(6666004)(6512007)(4326008)(956004)(66476007)(38350700001)(66556008)(5660300002)(69590400012)(2616005)(38100700001)(83380400001)(478600001)(7416002)(16526019)(26005)(186003)(2906002)(1076003)(66946007)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: rqAuksSF7/L+Xm9O/AR8gju+uUNECehuea1ki+UYXzxjwJ2WSawVfo6LofLYaMOFGf2l9Hk9FiEPpc1w4a9gfv/vxdHvjeaNL4G7vFfwIThYO7OiskSU9IU+bmDpH1Zw27rCSUSvoNc4jFkBpw/ZFIue9aZ1XaM4l+Ee7mwOiBrT8F8HT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I8Z+7IPf0LmF0ViJlFwkYwPkYKVzs55IP5cQlNbQ3T5fMJgc1UCOxTy6+P/kp7Qx8ORp39bu X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d53f914-1fdd-4061-51af-08d8fb36f234 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2021 09:07:48.4829 (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: CtJyJ6RHQSRsGke3gKBeTcSOBMuEtmVZYHI76jo8Zvt43TWwUyH+hNiTIhXN4Hv40yH3yS9XQB4Cz4iJscxxpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7336 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 09:07:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 418376 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 B3AF4C43460 for ; Fri, 9 Apr 2021 09:08:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8700E611C2 for ; Fri, 9 Apr 2021 09:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232995AbhDIJIS (ORCPT ); Fri, 9 Apr 2021 05:08:18 -0400 Received: from mail-eopbgr40085.outbound.protection.outlook.com ([40.107.4.85]:42634 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232974AbhDIJIG (ORCPT ); Fri, 9 Apr 2021 05:08:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GthQo9SsDo0D/0qDY/DSZJjMWS3A1Nw+TavzpfHp8dhVWeBBiNCw1apm/IP+8VB6abeYusC98pzhzVUspjX+9YwHIOcKAe1WMkFwfz5fFdBT9/4TKNP86dYr842GNgqWPsDO3qKnDSIQCAAUNJxq38hdmCYQ5Olvo3qV/aSwYIELYAJIy9bLyAOHQG5YopCcJG16OwIvEkjhgLn1ar2/kn16YH2l6hN4QjtNvH4dn7ai87PmaGymWnc8hPOJ6JAnAnAeZF/ZzyxRfKCbBJjnsbxx98j1Sni6m59NIHqrIvPy33NZTvAl0AUQw+TSHZTvQLuYewk5zeD47hfmnhSYUQ== 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=I9lmE5b0t+zSr6Hj9bRSn3/Hz33bdIf2CQ9q9mlsH2He3518h3+sWSYUrTvh46YzNI0oXM8DlbhjgQ/O6UfmxSotG8ZX1vtTQ5xvrHUYL+FwWoeQIGbgWE+QLnIhZRRhkycLTF7p/yIcjfq0S3T5wSqxvg2ecLg7FBDOHhmjnq9vXXygtM0rD0CMXrdiUsxMpwHXxJtBpqATPiUPBH7TkmKQa1sP/7EZYZ4c9Gi+VmSDwkOzo+4mGbqQXi9OzGrElGwvRrLtQHwDHgQw4sKzF988uUYJoC4qUEACZLzawl/YH8hunPPkBEyuWzxVr9e7a8AFxMH5XdQJ/cWWCNuvig== 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=qQxbHK/9+mxq5bfYproiYNqMktq3YjfkQl3JYXgeAMk2WLrZGveN+zoleaGcbmz1usTGnzXUmaT+8Catg0trPQaOal3wdohblr3Skk/y06R+qH6PZ6eNm+9XLti8e/FFUxPMNoFz2rLfWZ/qhP1wVyN3svRAIPzPGUMHWo2QFY4= 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 DBAPR04MB7336.eurprd04.prod.outlook.com (2603:10a6:10:1a9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.20; Fri, 9 Apr 2021 09:07:52 +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 09:07:52 +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, linux-imx@nxp.com Subject: [PATCH net-next 3/3] of_net: add property "nvmem-mac-address" for of_get_mac_addr() Date: Fri, 9 Apr 2021 17:07:11 +0800 Message-Id: <20210409090711.27358-4-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210409090711.27358-1-qiangqing.zhang@nxp.com> References: <20210409090711.27358-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) 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 HK2PR02CA0184.apcprd02.prod.outlook.com (2603:1096:201:21::20) 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 09:07:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 00b198d8-fec2-4ef5-38c6-08d8fb36f476 X-MS-TrafficTypeDiagnostic: DBAPR04MB7336: X-MS-Exchange-Transport-Forked: True 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: vTFg5CtxOAD4LkUyEi0TFXFbYKHW7GdRx8S/UFZ84+jp1K4eq9YZq+xpMT/8YNBU7iO56d+qKO6g3HofH2jkqKeVFy+3bQewRb8e0ZkYT0F7fVEfW3yqC717Ve/YigqSAWwvmCoIWRHB5M2quf5S1hwGnx1QN16w8yoS6YpAkMPh60JEDBlzZrUfn+//KGAGFM40S7vgY1u5VVbniSLMjPL6I2XlSdrAXKmWyU6ylaag4eBan8QuaDAwdydPJFDva1L3t+s0izNQWw5Be+gsmcCndSUW8inyc3E9FJYcataoa7mu6A5wOViLljDbAAoo0jgOFB+KwmJFuI/sZm9W8rY8lhOoBU/cyu29i+juVlR9VE0OXgIbqSVFNgGbK2KzwIYVtmDM4R/WqVez12d/IWS5Mv9dnKEzn7w8k/J5CpVAW9LFnOT0tjWsf/5P4OYcoSxO0vPgPW5j9LWL5CF0kAmzVJV1yOK/OYTtzIIunZdYRzYgU7NXDgNh2cxHhaeUwtFHtqWUJE3UmTjmFU48zuv8dTQMrfwoCGsmR4KzbfFuPf8FPmGzuw5FF3jorhcZvuEDShYuRCRDtL6GxFbQ3TDkflzoCKSSaRDG9Mc9d6lkmFaFl+4sB29Km0vssT28TkmzQwi/NCtnq5x6MbDv5ILoek9HG4+hZmlsU82G+WKEDUTYyDSw5jDwavbCHtlCAU6NvNaAvYJe9BP4Wl4Pb0hwfZPLFiWXc3JifJS5Jys= 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)(376002)(396003)(136003)(366004)(346002)(39860400002)(316002)(36756003)(6506007)(8936002)(8676002)(6486002)(52116002)(6666004)(6512007)(4326008)(956004)(66476007)(38350700001)(66556008)(5660300002)(69590400012)(2616005)(38100700001)(478600001)(7416002)(16526019)(26005)(186003)(2906002)(4744005)(1076003)(66946007)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: deUY06NrfDwdM6YkNBdbfONi2vKqGLn3ZDd/497nU9bvn/bdiKF/Kkb5t3AW+95tlfXnHBQu/1ZLL5b1sr1LJupRvDGppEJzJiwEotOfEFy+3ovZwpkTVmg9u8Edi2jNaWWbvV1gSrBBfSY36X6WJpQTL+v+IjobvAiDTiJAKPsbPXadUTgpX93j64/HjIJS9bMZAjMR/JR8WBsnxTDwjgEuGW6H17P9X7lDoYd5MUP/54prlW9ZG6kz+FGho7RaEEQXX9TA/GMRdxx88nLkCySTSxv91s36nxWbEX55dUJ4pg6x+eM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00b198d8-fec2-4ef5-38c6-08d8fb36f476 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2021 09:07:52.4385 (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: k5bSbLVYP70FS2xxNMxjwILJV9C14AGhE0N4Feexo/ggorTuOYFmSWlcTvYmxvaTNB18/K+xto3W1W2Rw2qOkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7336 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);