From patchwork Fri Jun 11 10:53:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 458958 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=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 639EEC48BE0 for ; Fri, 11 Jun 2021 10:57:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A3DB613CD for ; Fri, 11 Jun 2021 10:57:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231858AbhFKK7X (ORCPT ); Fri, 11 Jun 2021 06:59:23 -0400 Received: from mail-ed1-f48.google.com ([209.85.208.48]:43781 "EHLO mail-ed1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231853AbhFKK62 (ORCPT ); Fri, 11 Jun 2021 06:58:28 -0400 Received: by mail-ed1-f48.google.com with SMTP id s6so36576171edu.10; Fri, 11 Jun 2021 03:56:19 -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=YWiLBG3Lvh9inW6ZMOKYeM9OtMNgaNp+PKI7f1CZHVA=; b=DeStVRl3SimU3xbI02C7tHUE3WZXORGnt6MX73Lomy0EVxmPD/d+l6RWX1ApdtVRr4 JULcJdh/dNrh1WCWLVKeq8zkUVJrMXxZmHmlRs5ETp59HQIF7uy0eHgXuNonoD0dyLNF UC5rRDha1Lx9tks1oaOpY02ZGReY19rUeIIGweZEEq3RdWrZ8f2hfKH/8fuJfIDT+Ln2 IopQtZWQqEhwJhlOGrl1qvnzrBFoVFzjKVAC6vSmLWtl4WtVboRD2x3wTOkJ7AdWPGKM 8VPWdbfSB1wCR2/Dv/eWuVGMP6Kp95DemTPKcoNjmJ/7KHHWqz6aLQc5zogmpNFFnhCE KwkQ== 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=YWiLBG3Lvh9inW6ZMOKYeM9OtMNgaNp+PKI7f1CZHVA=; b=RG1BaT0qadmUEkrdj7KkSXcTS4mAShGiLC2tTXvHaAlL19uE4U4re6/SUVlY78VK6h JQ/A+qOeEphPX1paxMd3q12pdq2um5+OiszVJKqT3Iqm5saJSrXOGz+Xrk5NxmNjMEPk /T29ta4j92px1uG9vo1Js16oLhQh3mxW2F+qZGBo+Syy4ulFOSGY27Sol3Kafy5+iSdi npA5zLnMBtN2/sWBs4aGmYZf+ObU8LT9yeaHD25NqUWz4d1sKUU0X+SdgVnJO7o97w/L y77D19LtESX6KJ+/Ya5MkWsxTVC2hjzzAZT6AQIcIjth5k40VKeQqXmmiemZp8t9bL5M a+oA== X-Gm-Message-State: AOAM531rAQtHUHTA1L5dzYznEhoGkmHhZB28lPvZJuFl4dnnZXBINF7d fRdxdAO/a9Pw8YHXOhfSvBk= X-Google-Smtp-Source: ABdhPJzDxkhjs1JV/YiAc5XilhGPAtjlZURWiwAWpuumGLhMGt9FPAMPwILNnpgqLW8YRc0BIcySIA== X-Received: by 2002:a05:6402:1a:: with SMTP id d26mr3068419edu.105.1623408918928; Fri, 11 Jun 2021 03:55:18 -0700 (PDT) Received: from yoga-910.localhost ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id r19sm2492051eds.75.2021.06.11.03.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 03:55:18 -0700 (PDT) From: Ioana Ciornei To: davem@davemloft.net, kuba@kernel.org, hkallweit1@gmail.com, netdev@vger.kernel.org, Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap , calvin.johnson@oss.nxp.com Cc: Cristi Sovaiala , Florin Laurentiu Chiculita , Madalin Bucur , linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux.cj@gmail.com, Laurentiu Tudor , Len Brown , "Rafael J . Wysocki" , Ioana Ciornei Subject: [PATCH net-next v9 12/15] net/fsl: Use [acpi|of]_mdiobus_register Date: Fri, 11 Jun 2021 13:53:58 +0300 Message-Id: <20210611105401.270673-13-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210611105401.270673-1-ciorneiioana@gmail.com> References: <20210611105401.270673-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Calvin Johnson Depending on the device node type, call the specific OF or ACPI mdiobus_register function. Note: For both ACPI and DT cases, endianness of MDIO controllers need to be specified using the "little-endian" property. Signed-off-by: Calvin Johnson Signed-off-by: Ioana Ciornei Acked-by: Grant Likely --- Changes in v9: none Changes in v8: - Directly call the OF or ACPI variants of registering the MDIO bus. This is needed because the fwnode_mdio.c module should only implement features which can be achieved without going back to the OF/ACPI variants. Without this restrictions we directly end up in a dependency cycle: of_mdio -> fwnode_mdio -> of_mdio. - Changed the commit title since the fwnode_mdiobus_register() is no longer available Changes in v7: - Include fwnode_mdio.h - Alphabetically sort header inclusions Changes in v6: None Changes in v5: None Changes in v4: - Cleanup xgmac_mdio_probe() Changes in v3: - Avoid unnecessary line removal - Remove unused inclusion of acpi.h Changes in v2: None drivers/net/ethernet/freescale/xgmac_mdio.c | 30 ++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index bfa2826c5545..0b68852379da 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -2,6 +2,7 @@ * QorIQ 10G MDIO Controller * * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2021 NXP * * Authors: Andy Fleming * Timur Tabi @@ -11,15 +12,17 @@ * kind, whether express or implied. */ -#include -#include +#include +#include #include -#include -#include +#include #include +#include #include -#include #include +#include +#include +#include /* Number of microseconds to wait for a register to respond */ #define TIMEOUT 1000 @@ -243,10 +246,10 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) static int xgmac_mdio_probe(struct platform_device *pdev) { - struct device_node *np = pdev->dev.of_node; - struct mii_bus *bus; - struct resource *res; + struct fwnode_handle *fwnode; struct mdio_fsl_priv *priv; + struct resource *res; + struct mii_bus *bus; int ret; /* In DPAA-1, MDIO is one of the many FMan sub-devices. The FMan @@ -279,13 +282,22 @@ static int xgmac_mdio_probe(struct platform_device *pdev) goto err_ioremap; } + /* For both ACPI and DT cases, endianness of MDIO controller + * needs to be specified using "little-endian" property. + */ priv->is_little_endian = device_property_read_bool(&pdev->dev, "little-endian"); priv->has_a011043 = device_property_read_bool(&pdev->dev, "fsl,erratum-a011043"); - ret = of_mdiobus_register(bus, np); + fwnode = pdev->dev.fwnode; + if (is_of_node(fwnode)) + ret = of_mdiobus_register(bus, to_of_node(fwnode)); + else if (is_acpi_node(fwnode)) + ret = acpi_mdiobus_register(bus, fwnode); + else + ret = -EINVAL; if (ret) { dev_err(&pdev->dev, "cannot register MDIO bus\n"); goto err_registration;