Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751478AbdGQT1k (ORCPT ); Mon, 17 Jul 2017 15:27:40 -0400 Received: from vps0.lunn.ch ([178.209.37.122]:58226 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbdGQT1i (ORCPT ); Mon, 17 Jul 2017 15:27:38 -0400 Date: Mon, 17 Jul 2017 21:27:34 +0200 From: Andrew Lunn To: Vivien Didelot Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, "David S. Miller" , Florian Fainelli Subject: Re: [PATCH net-next 11/12] net: dsa: mv88e6xxx: add Energy Detect ops Message-ID: <20170717192734.GD9363@lunn.ch> References: <20170717170346.19555-1-vivien.didelot@savoirfairelinux.com> <20170717170346.19555-12-vivien.didelot@savoirfairelinux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170717170346.19555-12-vivien.didelot@savoirfairelinux.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1261 Lines: 44 > diff --git a/drivers/net/dsa/mv88e6xxx/phy.c b/drivers/net/dsa/mv88e6xxx/phy.c > index 436668bd50dc..317ae89cfa68 100644 > --- a/drivers/net/dsa/mv88e6xxx/phy.c > +++ b/drivers/net/dsa/mv88e6xxx/phy.c > @@ -246,3 +246,99 @@ int mv88e6xxx_phy_setup(struct mv88e6xxx_chip *chip) > { > return mv88e6xxx_phy_ppu_enable(chip); > } > + > +/* Page 0, Register 16: Copper Specific Control Register 1 */ > + > +int mv88e6352_phy_energy_detect_read(struct mv88e6xxx_chip *chip, int phy, > + struct ethtool_eee *eee) > +{ > + u16 val; > + int err; > + > + err = mv88e6xxx_phy_read(chip, phy, MV88E6XXX_PHY_CSCTL1, &val); > + if (err) > + return err; > + > + val &= MV88E6352_PHY_CSCTL1_ENERGY_DETECT_MASK; > + > + eee->eee_enabled = false; > + eee->tx_lpi_enabled = false; > + > + switch (val) { > + case MV88E6352_PHY_CSCTL1_ENERGY_DETECT_SENSE_NLP: > + eee->tx_lpi_enabled = true; > + /* fall through... */ > + case MV88E6352_PHY_CSCTL1_ENERGY_DETECT_SENSE_RCV: > + eee->eee_enabled = true; > + } > + > + return 0; > +} Hi Vivien I never liked this. I think it is architecturally wrong for the switch to be poking around in the PHY. It should ask the PHY driver. This is especially true for external PHYs which might not be a Marvell PHY. Andrew