From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS 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 AE302C3F2C6 for ; Sat, 29 Feb 2020 15:30:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C33024680 for ; Sat, 29 Feb 2020 15:30:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="DRuRlxoe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727145AbgB2Pac (ORCPT ); Sat, 29 Feb 2020 10:30:32 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:39766 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727070AbgB2Pab (ORCPT ); Sat, 29 Feb 2020 10:30:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=sBHWhVSh3klJN5kcIPaPKiA9b5bvnaJ4b7vpHAEeB84=; b=DRuRlxoe4uR69CzfbpF+lthW4G Xp2/YO/kT2EVT0tfpEhaOJ9ms4+a10KOGpDgPYwgYA3e/pmlSGzZbR8tLrM5KvqPsCs15Pui60LCv cw1+3XubTYqESQ1t4KlLtgm+l+6lB4YMLOq2G2fWkMumPjFip4qIMmyEQq7Ykicppdrk=; Received: from andrew by vps0.lunn.ch with local (Exim 4.93) (envelope-from ) id 1j844N-0001kg-Ss; Sat, 29 Feb 2020 16:30:23 +0100 Date: Sat, 29 Feb 2020 16:30:23 +0100 From: Andrew Lunn To: Pengcheng Xu Cc: Nicolas Ferre , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: macb: add support for fixed-link Message-ID: <20200229153023.GC6305@lunn.ch> References: <20200229070902.1294280-1-i@jsteward.moe> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 29, 2020 at 03:19:15PM +0800, Pengcheng Xu wrote: > Sorry for forgetting to CC the mailing lists. Adding them now. > > 2020年2月29日(土) 15:09 Pengcheng Xu : > > > > The Cadence macb driver did not support fixed-link PHYs. This patch > > adds support for fixed-link PHYs to the driver. > > > > The driver only checks if there's a valid PHY over MDIO, which is either > > present as a device tree node, or (if absent) searched on the MDIO bus. > > This patch detects if there is a `fixed-link` PHY instead of a regular > > MDIO-attached PHY. The device tree node of the MAC is checked for a > > fixed-link PHY via `of_phy_is_fixed_link`, and, if so, the normal MDIO > > register routine is skipped, and `of_phy_register_fixed_link` is > > performed instead. > > > > The changes were borrowed from > > drivers/net/ethernet/altera/altera_tse_main.c and tested to work on a > > Xilinx Zynq UltraScale+ device. > > > > Signed-off-by: Pengcheng Xu > > --- > > drivers/net/ethernet/cadence/macb_main.c | 15 ++++++++++++--- > > 1 file changed, 12 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c > > index 2c28da1737fe..fb359ce90ae4 100644 > > --- a/drivers/net/ethernet/cadence/macb_main.c > > +++ b/drivers/net/ethernet/cadence/macb_main.c > > @@ -744,6 +744,7 @@ static int macb_mdiobus_register(struct macb *bp) > > > > static int macb_mii_init(struct macb *bp) > > { > > + struct device_node *np = bp->pdev->dev.of_node; > > int err = -ENXIO; > > > > /* Enable management port */ > > @@ -765,9 +766,17 @@ static int macb_mii_init(struct macb *bp) > > > > dev_set_drvdata(&bp->dev->dev, bp->mii_bus); > > > > - err = macb_mdiobus_register(bp); > > - if (err) > > - goto err_out_free_mdiobus; > > + if (of_phy_is_fixed_link(np)) { > > + err = of_phy_register_fixed_link(np); > > + if (err) { > > + netdev_err(bp->dev, "cannot register fixed-link PHY\n"); > > + goto err_out_free_mdiobus; > > + } > > + } else { > > + err = macb_mdiobus_register(bp); > > + if (err) > > + goto err_out_free_mdiobus; > > + } > > > > err = macb_mii_probe(bp->dev); > > if (err) Hi Pengcheng Fixed link and an mdio bus are not mutually exclusive. When the MAC is connected to an Ethernet switch, you often see a fixed link, and the ethernet switch on the MDIO bus. As an example, arch/arm/boot/dts/vf610-zii-cfu1.dts &fec1 { phy-mode = "rmii"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_fec1>; status = "okay"; fixed-link { speed = <100>; full-duplex; }; mdio1: mdio { #address-cells = <1>; #size-cells = <0>; status = "okay"; switch0: switch0@0 { compatible = "marvell,mv88e6085"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_switch>; reg = <0>; eeprom-length = <512>; interrupt-parent = <&gpio3>; interrupts = <2 IRQ_TYPE_LEVEL_LOW>; interrupt-controller; #interrupt-cells = <2>; reset-gpios = <&gpio3 11 GPIO_ACTIVE_LOW>; ... So if you find a fixed-phy, you should register it. And if you find an mdio bus, you should also register it. Andrew