From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758763AbcIMRMB (ORCPT ); Tue, 13 Sep 2016 13:12:01 -0400 Received: from mail.savoirfairelinux.com ([208.88.110.44]:33277 "EHLO mail.savoirfairelinux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751222AbcIMRMA (ORCPT ); Tue, 13 Sep 2016 13:12:00 -0400 From: Vivien Didelot To: Andrew Lunn , John Crispin Cc: "David S. Miller" , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, qsdk-review@qca.qualcomm.com Subject: Re: [PATCH 3/3] net-next: dsa: add new driver for qca8xxx family In-Reply-To: <20160913131408.GE15332@lunn.ch> References: <1473669337-21221-1-git-send-email-john@phrozen.org> <1473669337-21221-4-git-send-email-john@phrozen.org> <20160913012304.GC3585@lunn.ch> <5c028659-db7e-9a98-7ec1-1e2d19d135f9@phrozen.org> <20160913131408.GE15332@lunn.ch> User-Agent: Notmuch/0.22.2 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-unknown-linux-gnu) Date: Tue, 13 Sep 2016 13:11:56 -0400 Message-ID: <87twdjafmr.fsf@ketchup.mtl.sfl> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrew, Andrew Lunn writes: >> ok, i will simply substract 1 from the phy_addr inside the mdio >> callbacks. this would make the code more readable and make the DT >> binding compliant with the ePAPR spec. > > It does however need well commenting. It is setting a trap for anybody > who puts an external PHY on port 6. If they access that PHY via these > functions, the address is off by one. > > This is the first silicon vendor who made their MDIO addresses for > PHYs illogical. So i'm thinking we maybe should add a new function to > dsa_switch_ops. > > /* Return the MDIO address for the PHY for this port. */ > int (*phy_port_map(struct dsa_switch *ds, int port); > > This should return the MDIO address for integrated PHYs only, or > -ENODEV if the port does not have an integrated PHY. For an external > PHY, a phy-handle should be used. This phy_port_map() is used in > dsa_slave_phy_setup(). But dsa_slave_phy_setup() is already too > complex, so it needs doing with care. Note that some switch drivers *have to* register their slave MDIO bus themselves (e.g. bcm_sf2). This becomes confusing with the DSA phy_{read,write} ops. Since the former alternative is prefered, we may want to remove the latter soon from DSA. If this phy_port_map is needed for that case, it'd be preferable not to add it. Thanks, Vivien