Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp326428rdb; Thu, 5 Oct 2023 07:10:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWdmIUDD6Ow9GFt4iaQqvz5v2AYVKVEwogBSH/XFiz4XkUoiCC8GryzHVuSfdq4rdtxOxz X-Received: by 2002:a05:6e02:12e9:b0:351:4b68:ec3d with SMTP id l9-20020a056e0212e900b003514b68ec3dmr6033766iln.16.1696515008953; Thu, 05 Oct 2023 07:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696515008; cv=none; d=google.com; s=arc-20160816; b=JEnDjzBUl7IqPIxX7jSPbhg6/tvUikAkypaMMyNTmISJTmnvDZLWH7SExQNfWguf67 6in6HNOMvmAvPItUnKOzhew/hWyrn/AMo+5rF76Ep+af68X5gAGJ43sNWWF9NKol/JfI DxuyGuVaCovtItlvYtXXeTwq7XwWeGrir0vBxlkVhIoVetqyFSnxh/z4BfF1zFVHUmtH 5wNB63WL++S/qhGlhelopi2GrV2ZLfHJbUlleMOhX4X2PT++NrU5jcG0EYE/xydK7d/1 sYGI2EyqjwZXtWOW1fHDleqa7V+SYEAFxAYlCmnfVJNAypBOqGTSaGkHhJ3Tqz+IY1MR 8dpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=/eKCeJNe5cUfyu+XUYUXDRKj9pXdqaIZiHZwEA87Tv0=; fh=cc3a3HrHpgNGTgKaG6d55qORnxRpXIexa3BptGsVpuU=; b=wy4+pfee+M5sw25OhZUMzEpK5WiipmyFDNARjwNQwMnh0rLLbvMB3W5kiQ6XNKqUVT uugmYQpncTFMbn7ur/w5NqRZcZHy6U8OrmNRnQarAmjov8B9cmPXfiUHxoK47erNjMYB jMPhqnncKxOp7t6AD9ld4/feBc6mkwUt07T0x52OejEovj9YJX1nC2Yo96+5qEP/bKCi +vRliZFgN49xPJ56tErbFkfHBiBsxm4EHTXt0PGbArkyf+6NEcu1DR6LnB9/tSJogEdn zxyYWXQpVtIfaY6IjRLky0fJr/l7h1DGlpbCnm52dfH7ZGDgcvPVdyGJsrIPs03+X1R7 SN8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=OkF1GMCV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id s135-20020a63778d000000b00577ac67a31dsi1504576pgc.757.2023.10.05.07.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:10:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=OkF1GMCV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 7F78D802A9F6; Thu, 5 Oct 2023 07:09:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbjJEOJK (ORCPT + 99 others); Thu, 5 Oct 2023 10:09:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbjJEOHG (ORCPT ); Thu, 5 Oct 2023 10:07:06 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 980BB22C90; Thu, 5 Oct 2023 03:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding: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=/eKCeJNe5cUfyu+XUYUXDRKj9pXdqaIZiHZwEA87Tv0=; b=OkF1GMCVjNcoTVw6/Yirr3F4LW 2NpGcfL/ebet0DWCN7OKh2dMXutVNZGS67WbWRTE0fuztTBEdwcRC/BppQw897e1hm9VCCrqhFqbz NCMWCYTOxt/LVd59pKQ1S+aClMls1ObQ7ICFs/MCxk61aMydUFD1CnaIClX3OPnA4/Gw9IBWEI2jn FFw0ewBWaLxXpIP+s2ISGlgoSTODT3XbwumigYxib+GYf4m7YBET0lf+KHUYWePi01NaRwsXpnvbm +yCw5+EVLy4K85mTLzESuglVhkBHUdbZ0Jr2PXYNSnJbqqC6xtDjdLl6EoRsslxlwetDTlNlR9YVc m/NSvQpw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:47980) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qoLqz-0003tB-1l; Thu, 05 Oct 2023 11:45:13 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qoLqz-0001we-4M; Thu, 05 Oct 2023 11:45:13 +0100 Date: Thu, 5 Oct 2023 11:45:13 +0100 From: "Russell King (Oracle)" To: Giulio Benetti Cc: linux-kernel@vger.kernel.org, Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, Giulio Benetti , Jim Reinhart , James Autry , Matthew Maron Subject: Re: [PATCH v3] net: phy: broadcom: add support for BCM5221 phy Message-ID: References: <20230928185949.1731477-1-giulio.benetti@benettiengineering.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230928185949.1731477-1-giulio.benetti@benettiengineering.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:09:48 -0700 (PDT) On Thu, Sep 28, 2023 at 08:59:49PM +0200, Giulio Benetti wrote: > + /* Read to clear status bits */ > reg = phy_read(phydev, MII_BRCM_FET_INTREG); > if (reg < 0) > return reg; > > /* Unmask events we are interested in and mask interrupts globally. */ > - reg = MII_BRCM_FET_IR_DUPLEX_EN | > - MII_BRCM_FET_IR_SPEED_EN | > - MII_BRCM_FET_IR_LINK_EN | > - MII_BRCM_FET_IR_ENABLE | > - MII_BRCM_FET_IR_MASK; Note this style of formatting, where MII_BRCM_xxx line up with the first... > + if (phydev->phy_id == PHY_ID_BCM5221) > + reg = MII_BRCM_FET_IR_ENABLE | > + MII_BRCM_FET_IR_MASK; That should be repeated here. > + else > + reg = MII_BRCM_FET_IR_DUPLEX_EN | > + MII_BRCM_FET_IR_SPEED_EN | > + MII_BRCM_FET_IR_LINK_EN | > + MII_BRCM_FET_IR_ENABLE | > + MII_BRCM_FET_IR_MASK; and here. > > err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); > if (err < 0) > @@ -726,42 +731,50 @@ static int brcm_fet_config_init(struct phy_device *phydev) > > reg = brcmtest | MII_BRCM_FET_BT_SRE; > > - err = phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg); > - if (err < 0) > - return err; > + phy_lock_mdio_bus(phydev); > > - /* Set the LED mode */ > - reg = phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4); > - if (reg < 0) { > - err = reg; > - goto done; > + err = __phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg); > + if (err < 0) { > + phy_unlock_mdio_bus(phydev); > + return err; > } > > - reg &= ~MII_BRCM_FET_SHDW_AM4_LED_MASK; > - reg |= MII_BRCM_FET_SHDW_AM4_LED_MODE1; > + if (phydev->phy_id != PHY_ID_BCM5221) { > + /* Set the LED mode */ > + reg = __phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4); > + if (reg < 0) { > + err = reg; > + goto done; > + } > > - err = phy_write(phydev, MII_BRCM_FET_SHDW_AUXMODE4, reg); > - if (err < 0) > - goto done; > + reg &= ~MII_BRCM_FET_SHDW_AM4_LED_MASK; > + reg |= MII_BRCM_FET_SHDW_AM4_LED_MODE1; > > - /* Enable auto MDIX */ > - err = phy_set_bits(phydev, MII_BRCM_FET_SHDW_MISCCTRL, > - MII_BRCM_FET_SHDW_MC_FAME); > - if (err < 0) > - goto done; > + err = __phy_write(phydev, MII_BRCM_FET_SHDW_AUXMODE4, reg); I think this can be simplified to: err = __phy_modify(phydev, MII_BRCM_FET_SHDW_AUXMODE4, MII_BRCM_FET_SHDW_AM4_LED_MASK, MII_BRCM_FET_SHDW_AM4_LED_MODE1); -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!