From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030525AbdEWSMO (ORCPT ); Tue, 23 May 2017 14:12:14 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34914 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030319AbdEWSMK (ORCPT ); Tue, 23 May 2017 14:12:10 -0400 Subject: Re: [PATCH 1/2] net: phy: Update get_phy_c45_ids for Cortina PHYs To: Andrew Lunn , Bogdan Purcareata Cc: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <1495554799-23060-1-git-send-email-bogdan.purcareata@nxp.com> <1495554799-23060-2-git-send-email-bogdan.purcareata@nxp.com> <20170523160353.GB21169@lunn.ch> <20170523165554.GB24029@lunn.ch> From: Florian Fainelli Message-ID: <8768d0f5-6226-b3e0-b741-f742ff5ffee3@gmail.com> Date: Tue, 23 May 2017 11:12:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20170523165554.GB24029@lunn.ch> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/23/2017 09:55 AM, Andrew Lunn wrote: >> The patches mentioned in the commit message add _some_ support for >> the Cortina PHYs - mainly checking for devices at additional >> locations. Once they are found, the phy IDs must be read from custom >> locations. > > As a general principle, we don't add hacks in generic code to handle > broken devices. We add generic mechanisms to work around the > brokenness. > > In this case, by using ethernet-phy-id in the device tree, we are > saying, this PHYs probing is totally borked, but we know it is there, > at this address. Just load the driver. > > Please try to make ethernet-phy-id work. What Andrew is suggesting is to leverage the code in drivers/of/of_mdio.c which does the following: is_c45 = of_device_is_compatible(child, "ethernet-phy-ieee802.3-c45"); if (!is_c45 && !of_get_phy_id(child, &phy_id)) phy = phy_device_create(mdio, addr, phy_id, 0, NULL); else phy = get_phy_device(mdio, addr, is_c45); if (IS_ERR(phy)) return; If you know the PHY ID, and you did put it in the PHY node's compatible string (in the format that of_get_phy_id() expects it to, and you also did not add "ethernet-phy-ieee802.3-c45") then the PHY library will directly create the PHY device, with the designated ID, at the specific address. While this works for clause 22 PHYs, I don't know if it also does for clause 45 PHYs, but as Andrew is suggesting, I would be more inclined into making this scheme work for all types (22 or 45) PHYs, rather than hacking the core code that tries to identify devices in packages. Can you give it a spin? -- Florian