From patchwork Wed Jul 11 17:45:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 141764 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp576454ljj; Wed, 11 Jul 2018 10:47:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcQPIG3aByZvzqSjQPpBwMXpsXFfqjfKH+/TNwgHNyPNepqcj23+WnOerlcE2B2oIJkC36Z X-Received: by 2002:a17:902:b08a:: with SMTP id p10-v6mr30371104plr.0.1531331238759; Wed, 11 Jul 2018 10:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531331238; cv=none; d=google.com; s=arc-20160816; b=x9DF9bY70XEUCteF2jAYTSCIUvSG83fVgG7zPcQZ02RT+a7ObW3yOKEySi3fjhIdMR gRvCfNRuAEvmeZiy/2pEXTpEXHjLH4xBF95mWbTSlnhfr6G36SVUl+TiuhA8vLQIuMGD ilCEpkTVP8ys1WxUlT/aIXyBNCNHonErehn1F0eZZXX48mDQFpA7au4ld6EBkI4HQBgm LX8KuqO4xaftgXGkK6gMJ2I6urjEywxaK3v3epGTXvoyLkh4ali97yPvLb1AG/ieWUYK 4/p0qZh/afDw7ZGbvAxoQiCh3e2xFLCs4GU4rt5FPCc7WSUYq8nSJNTkYb37AfrZW8+6 jZkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=UJqGDOxyl3aCRRxWWgcAZ2GQkOMn4j34l7efMa/vlo4=; b=V/f5lZU1Oha+vLtoRuVEJ1aJvW4w7+2mPazjrisliafqwLO16pOeszBsQCMvDnKzUO OJA10G5s/ppv+5mUe77elZSleU4noACywLEKDF4RuPhVSCsSGl2qBzj4uCmxCexGEv+r ghEJnXtm8fFCxNM42qus6gd3n+VXF54OX/z8+d4cpSLdxDAuc+j3qjb0JHBh03DndUmn YJKEZUyy3zeSyEL5Qh3a9vKGKTpxQKj+GLp+HAxZdORaedSmFbIliXXMUox24LWw4QOa hndq+PvoJeKxZ3/hCoxDP8anxnWtwOx31fRFCLqbe5AIip6tuhO9Rq5XuSklQA1vbRUm G5Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ESOZRBvn; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16-v6si19264431pga.168.2018.07.11.10.47.18; Wed, 11 Jul 2018 10:47:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ESOZRBvn; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388918AbeGKRwl (ORCPT + 10 others); Wed, 11 Jul 2018 13:52:41 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34716 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732987AbeGKRwk (ORCPT ); Wed, 11 Jul 2018 13:52:40 -0400 Received: by mail-lj1-f196.google.com with SMTP id f8-v6so2330523ljk.1 for ; Wed, 11 Jul 2018 10:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=UJqGDOxyl3aCRRxWWgcAZ2GQkOMn4j34l7efMa/vlo4=; b=ESOZRBvnXwGCHKeIgM0n2cKdADUJCudaFaAYTjEJ3mfQDF/22AvSy/zd6oBBT9fWhp 8+7hiw5Wbj+n1bE3Iezei9wCNneqM/hd5NEV1YiiWcjLr05bGvuCz6RG5m32Tk0IM6Ym 8cOZjOYwbGFJoatLMSd/lQtemPt5QdUqnkITo= 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; bh=UJqGDOxyl3aCRRxWWgcAZ2GQkOMn4j34l7efMa/vlo4=; b=J10XNBQ3zjIUVLBR7LrmatkHN0UvyREqRfyi1JvQCReiI7mFk0qpDIffSDrc/q5Orb JUG0JsF8sn0XUGjUsNxmv4QJ4H3X6VCC7IKm1oJxa7WwGuw9YlWjK3j6+JXnuD17LO6Q v9ZnbLpKcjC3XJJ17bu2Rqbx/dZrcIrdDsr37qH/pxLa4+a1IdQ/DAiti/BC1ppb4Q2U fcLgnNfQ7/ikZsmZtvDum3dsUCiDkwyJKUavoy4xFU9B8PdhEwVjwZL2wbpLaWwqHD/M irJ1KSrI9bFKCat+I4ekhbTxXZgwVX7pVbChnulUbbB6h2QpXHjW/NlQYlo2bohu7W/Q Sp0g== X-Gm-Message-State: APt69E1UDdkC02lAz1OgJA++OlWe0SX70/BuZAMXOy8UM2GdKyaSe5BG W43e2WAMUXFEUVN6i7fFn2+xKg== X-Received: by 2002:a2e:9dc7:: with SMTP id x7-v6mr6778427ljj.142.1531331235154; Wed, 11 Jul 2018 10:47:15 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id z4-v6sm5484268lfa.57.2018.07.11.10.47.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jul 2018 10:47:13 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Florian Fainelli , "David S . Miller" Cc: netdev@vger.kernel.org, Laurent Pinchart , Linus Walleij Subject: [PATCH] of: mdio: Support fixed links in of_phy_get_and_connect() Date: Wed, 11 Jul 2018 19:45:11 +0200 Message-Id: <20180711174511.15308-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org By a simple extension of of_phy_get_and_connect() drivers that have a fixed link on e.g. RGMII can support also fixed links, so in addition to: ethernet-port { phy-mode = "rgmii"; phy-handle = <&foo>; }; This setup with a fixed-link node and no phy-handle will now also work just fine: ethernet-port { phy-mode = "rgmii"; fixed-link { speed = <1000>; full-duplex; pause; }; }; This is very helpful for connecting random ethernet ports to e.g. DSA switches that typically reside on fixed links. The phy-mode is still there as the fixes link in this case is still an RGMII link. Tested on the Cortina Gemini driver with the Vitesse DSA router chip on a fixed 1Gbit link. Suggested-by: Andrew Lunn Signed-off-by: Linus Walleij --- drivers/of/of_mdio.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) -- 2.17.1 Reviewed-by: Andrew Lunn diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index d963baf8e53a..e92391d6d1bd 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -367,14 +367,23 @@ struct phy_device *of_phy_get_and_connect(struct net_device *dev, phy_interface_t iface; struct device_node *phy_np; struct phy_device *phy; + int ret; iface = of_get_phy_mode(np); if (iface < 0) return NULL; - - phy_np = of_parse_phandle(np, "phy-handle", 0); - if (!phy_np) - return NULL; + if (of_phy_is_fixed_link(np)) { + ret = of_phy_register_fixed_link(np); + if (ret < 0) { + netdev_err(dev, "broken fixed-link specification\n"); + return NULL; + } + phy_np = of_node_get(np); + } else { + phy_np = of_parse_phandle(np, "phy-handle", 0); + if (!phy_np) + return NULL; + } phy = of_phy_connect(dev, phy_np, hndlr, 0, iface);