From patchwork Wed Sep 7 05:44:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ren X-Patchwork-Id: 12968454 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CD84C38145 for ; Wed, 7 Sep 2022 05:46:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cAhmBot4HhyDh4/1KmZHnZsNRGN0+uYA3cThfnrDmso=; b=bxfXSrYPnMOzi2 f2QM31ARFXUJ6Qbhsx+O5EtWxqVU65OoYXVHDcNuJg84AgJQ/SEc+haHlAo9xnyS1SY+eZqJWDrnz AaDdZtMnZ3x7+lPrXkhz2POSBr5B/vaiUg4aIm6/iLvIpW42RRUdeNsCseP6kjAsED4qP5Sb2RkXL MC8lQW1SCoCFk8mgrqskMouBnLe8DCxkVF/QE5/qwV//h1R0k+z3RKSVoBKQyYadjrV042nMk4id5 TrChX7yg2V2xoGrfnQ2oDIc10ECcycpsMxS+oxp7OeFQm7uhHT68u+/UYAnwCy0UBPpq7Dd/gq0Xw ezG88Lnhqh/bASEMCMww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVnsG-002uYm-65; Wed, 07 Sep 2022 05:45:20 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVns0-002uRy-6d for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2022 05:45:05 +0000 Received: by mail-pg1-x52b.google.com with SMTP id t70so6772590pgc.5 for ; Tue, 06 Sep 2022 22:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=vc+9lhZdvHGipmJiQR19DK5It5RgAjYlDgcsNDiBYQ0=; b=EM8MHwat55nL4Wjn4+ya6MxNTraM9ElIKbCMnpkCgyrNM7kPFcj2J4e2SlrDK5a/U2 1AmHYLeIRJP/eopqpa6mzwjvFjOfyVd9l4zP5lPBh69ZCn6YF5zUTclM8HqcAOedibJ7 TkLDCP1+ZzTxIH4gGugzDDozIcU5CJnqmFhfMWdIR1Wgjg/KvCtBsMjnm+Edhap8ee5a R5jaNIKv2Jy7yRfFFBgadZVSKI01j3aM5I7iiSRwanDfC19uG/z8P1wGRO3ST1XkTNi/ 0tLEvLiH1ZyLYOfyjtSzjkkdzPNvFozpLWVowbrxgJTHkOWiAhAFDvNsqaFDdkFLAi2r dnVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=vc+9lhZdvHGipmJiQR19DK5It5RgAjYlDgcsNDiBYQ0=; b=RRuF0mfAIFGhOV56kKIG/yuxYfXrGM3YazSothJC5uIe60+PVC2ztxN80XxPJ6NQ4X dEx4bUANLFBrQQYfcXHXlN1NcMAlQYU84sWyKVwXdX6oeKsn1a8TsGWZcpi/dULrSzOo sZ2JKTW0tx28PBi8iWmvF967mzi0Pj1hZoBmoaeQJ/6VfauKVzzp35RNYPsIPAYcy75D UGq80jdSY1nOdq5q8pbr8TMpzMu4rI4SiWdISxaSMPJc8Hq8haJlFoddIogB6U8Kl03+ YAXROK7bEo3puATQfuXULn+5LvjVXFu15ya+R6dyMXp/Ls845iiraAN8dMvJMNVjok0o Tuzw== X-Gm-Message-State: ACgBeo3MqgUQ2ZUl49YvF9aBa36C37Or4LxBJPPrfgvunQYZ4nnXLNDt c1WQwuzfRJ19j5SRDwi8Wsg= X-Google-Smtp-Source: AA6agR64WB1uKVsnb83+o3qiFDrgAfqg4TmB3M18AMQi1RgPJhea91VyXpDVcMspPl4mWCNRguOWow== X-Received: by 2002:a63:c003:0:b0:434:dd62:18e1 with SMTP id h3-20020a63c003000000b00434dd6218e1mr2020043pgg.53.1662529502321; Tue, 06 Sep 2022 22:45:02 -0700 (PDT) Received: from localhost.localdomain ([76.132.249.1]) by smtp.gmail.com with ESMTPSA id b2-20020a170902d50200b0016c0c82e85csm11222798plg.75.2022.09.06.22.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 22:45:01 -0700 (PDT) From: rentao.bupt@gmail.com To: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heyi Guo , Dylan Hung , Guangbin Huang , Liang He , Hao Chen , Rob Herring , Krzysztof Kozlowski , Joel Stanley , Andrew Jeffery , Tao Ren , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: Tao Ren Subject: [PATCH net-next v3 1/2] net: ftgmac100: support fixed link Date: Tue, 6 Sep 2022 22:44:52 -0700 Message-Id: <20220907054453.20016-2-rentao.bupt@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220907054453.20016-1-rentao.bupt@gmail.com> References: <20220907054453.20016-1-rentao.bupt@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_224504_266349_61FF62D6 X-CRM114-Status: GOOD ( 15.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tao Ren Support fixed link in ftgmac100 driver. Fixed link is used on several Meta OpenBMC platforms, such as Elbert (AST2620) and Wedge400 (AST2520). Signed-off-by: Tao Ren Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- Changes in v3: None Changes in v2: None drivers/net/ethernet/faraday/ftgmac100.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index 9277d5fb5052..da04beee5865 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -1701,10 +1701,14 @@ static int ftgmac100_setup_mdio(struct net_device *netdev) static void ftgmac100_phy_disconnect(struct net_device *netdev) { + struct ftgmac100 *priv = netdev_priv(netdev); + if (!netdev->phydev) return; phy_disconnect(netdev->phydev); + if (of_phy_is_fixed_link(priv->dev->of_node)) + of_phy_deregister_fixed_link(priv->dev->of_node); } static void ftgmac100_destroy_mdio(struct net_device *netdev) @@ -1867,6 +1871,26 @@ static int ftgmac100_probe(struct platform_device *pdev) err = -EINVAL; goto err_phy_connect; } + } else if (np && of_phy_is_fixed_link(np)) { + struct phy_device *phy; + + err = of_phy_register_fixed_link(np); + if (err) { + dev_err(&pdev->dev, "Failed to register fixed PHY\n"); + goto err_phy_connect; + } + + phy = of_phy_get_and_connect(priv->netdev, np, + &ftgmac100_adjust_link); + if (!phy) { + dev_err(&pdev->dev, "Failed to connect to fixed PHY\n"); + of_phy_deregister_fixed_link(np); + err = -EINVAL; + goto err_phy_connect; + } + + /* Display what we found */ + phy_attached_info(phy); } else if (np && of_get_property(np, "phy-handle", NULL)) { struct phy_device *phy;