From patchwork Fri May 22 21:30:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296473 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKSn1wsTz9sSF for ; Sat, 23 May 2020 07:32:09 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731141AbgEVVbL (ORCPT ); Fri, 22 May 2020 17:31:11 -0400 Received: from foss.arm.com ([217.140.110.172]:42312 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730976AbgEVVbK (ORCPT ); Fri, 22 May 2020 17:31:10 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5DBA41063; Fri, 22 May 2020 14:31:09 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4D5063F68F; Fri, 22 May 2020 14:31:09 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 01/11] net: phy: Don't report success if devices weren't found Date: Fri, 22 May 2020 16:30:49 -0500 Message-Id: <20200522213059.1535892-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org C45 devices are to return 0 for registers they haven't implemented. This means in theory we can terminate the device search loop without finding any MMDs. In that case we want to immediately return indicating that nothing was found rather than continuing to probe and falling into the success state at the bottom. Signed-off-by: Jeremy Linton --- drivers/net/phy/phy_device.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index ac2784192472..245899b58a7d 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -742,6 +742,12 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, } } + /* no reported devices */ + if (*devs == 0) { + *phy_id = 0xffffffff; + return 0; + } + /* Now probe Device Identifiers for each device present. */ for (i = 1; i < num_ids; i++) { if (!(c45_ids->devices_in_package & (1 << i))) From patchwork Fri May 22 21:30:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296464 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKRh6F36z9sRK for ; Sat, 23 May 2020 07:31:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731152AbgEVVbM (ORCPT ); Fri, 22 May 2020 17:31:12 -0400 Received: from foss.arm.com ([217.140.110.172]:42324 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731128AbgEVVbK (ORCPT ); Fri, 22 May 2020 17:31:10 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E850E106F; Fri, 22 May 2020 14:31:09 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E0C5D3F68F; Fri, 22 May 2020 14:31:09 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 02/11] net: phy: Simplify MMD device list termination Date: Fri, 22 May 2020 16:30:50 -0500 Message-Id: <20200522213059.1535892-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since we are already checking for *devs == 0 after the loop terminates, we can add a mostly F's check as well. With that change we can simplify the return/break sequence inside the loop. Add a valid_phy_id() macro for this, since we will be using it in a couple other places. Signed-off-by: Jeremy Linton --- drivers/net/phy/phy_device.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 245899b58a7d..7746c07b97fe 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -695,6 +695,11 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr, return 0; } +static bool valid_phy_id(int val) +{ + return (val > 0 && ((val & 0x1fffffff) != 0x1fffffff)); +} + /** * get_phy_c45_ids - reads the specified addr for its 802.3-c45 IDs. * @bus: the target MII bus @@ -732,18 +737,12 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs); if (phy_reg < 0) return -EIO; - /* no device there, let's get out of here */ - if ((*devs & 0x1fffffff) == 0x1fffffff) { - *phy_id = 0xffffffff; - return 0; - } else { - break; - } + break; } } /* no reported devices */ - if (*devs == 0) { + if (!valid_phy_id(*devs)) { *phy_id = 0xffffffff; return 0; } From patchwork Fri May 22 21:30:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296474 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKSt2z7Wz9sRK for ; Sat, 23 May 2020 07:32:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731293AbgEVVcJ (ORCPT ); Fri, 22 May 2020 17:32:09 -0400 Received: from foss.arm.com ([217.140.110.172]:42338 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731130AbgEVVbL (ORCPT ); Fri, 22 May 2020 17:31:11 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C43D011FB; Fri, 22 May 2020 14:31:10 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B398E3F68F; Fri, 22 May 2020 14:31:10 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 03/11] net: phy: refactor c45 phy identification sequence Date: Fri, 22 May 2020 16:30:51 -0500 Message-Id: <20200522213059.1535892-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Lets factor out the phy id logic, and make it generic so that it can be used for c22 and c45. Signed-off-by: Jeremy Linton --- drivers/net/phy/phy_device.c | 65 +++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 7746c07b97fe..f0761fa5e40b 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -695,6 +695,29 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr, return 0; } +static int _get_phy_id(struct mii_bus *bus, int addr, int dev_addr, + u32 *phy_id, bool c45) +{ + int phy_reg, reg_addr; + + int reg_base = c45 ? (MII_ADDR_C45 | dev_addr << 16) : 0; + + reg_addr = reg_base | MII_PHYSID1; + phy_reg = mdiobus_read(bus, addr, reg_addr); + if (phy_reg < 0) + return -EIO; + + *phy_id = phy_reg << 16; + + reg_addr = reg_base | MII_PHYSID2; + phy_reg = mdiobus_read(bus, addr, reg_addr); + if (phy_reg < 0) + return -EIO; + *phy_id |= phy_reg; + + return 0; +} + static bool valid_phy_id(int val) { return (val > 0 && ((val & 0x1fffffff) != 0x1fffffff)); @@ -715,17 +738,17 @@ static bool valid_phy_id(int val) */ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, struct phy_c45_device_ids *c45_ids) { - int phy_reg; - int i, reg_addr; + int ret; + int i; const int num_ids = ARRAY_SIZE(c45_ids->device_ids); u32 *devs = &c45_ids->devices_in_package; /* Find first non-zero Devices In package. Device zero is reserved * for 802.3 c45 complied PHYs, so don't probe it at first. */ - for (i = 1; i < num_ids && *devs == 0; i++) { - phy_reg = get_phy_c45_devs_in_pkg(bus, addr, i, devs); - if (phy_reg < 0) + for (i = 0; i < num_ids && *devs == 0; i++) { + ret = get_phy_c45_devs_in_pkg(bus, addr, i, devs); + if (ret < 0) return -EIO; if ((*devs & 0x1fffffff) == 0x1fffffff) { @@ -752,17 +775,9 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, if (!(c45_ids->devices_in_package & (1 << i))) continue; - reg_addr = MII_ADDR_C45 | i << 16 | MII_PHYSID1; - phy_reg = mdiobus_read(bus, addr, reg_addr); - if (phy_reg < 0) - return -EIO; - c45_ids->device_ids[i] = phy_reg << 16; - - reg_addr = MII_ADDR_C45 | i << 16 | MII_PHYSID2; - phy_reg = mdiobus_read(bus, addr, reg_addr); - if (phy_reg < 0) - return -EIO; - c45_ids->device_ids[i] |= phy_reg; + ret = _get_phy_id(bus, addr, i, &c45_ids->device_ids[i], true); + if (ret < 0) + return ret; } *phy_id = 0; return 0; @@ -787,27 +802,17 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id, bool is_c45, struct phy_c45_device_ids *c45_ids) { - int phy_reg; + int ret; if (is_c45) return get_phy_c45_ids(bus, addr, phy_id, c45_ids); - /* Grab the bits from PHYIR1, and put them in the upper half */ - phy_reg = mdiobus_read(bus, addr, MII_PHYSID1); - if (phy_reg < 0) { + ret = _get_phy_id(bus, addr, 0, phy_id, false); + if (ret < 0) { /* returning -ENODEV doesn't stop bus scanning */ - return (phy_reg == -EIO || phy_reg == -ENODEV) ? -ENODEV : -EIO; + return (ret == -EIO || ret == -ENODEV) ? -ENODEV : -EIO; } - *phy_id = phy_reg << 16; - - /* Grab the bits from PHYIR2, and put them in the lower half */ - phy_reg = mdiobus_read(bus, addr, MII_PHYSID2); - if (phy_reg < 0) - return -EIO; - - *phy_id |= phy_reg; - return 0; } From patchwork Fri May 22 21:30:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296472 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKSg6lLfz9sSF for ; Sat, 23 May 2020 07:32:03 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731271AbgEVVby (ORCPT ); Fri, 22 May 2020 17:31:54 -0400 Received: from foss.arm.com ([217.140.110.172]:42348 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731145AbgEVVbM (ORCPT ); Fri, 22 May 2020 17:31:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9267C13A1; Fri, 22 May 2020 14:31:11 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8B6DE3F68F; Fri, 22 May 2020 14:31:11 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 04/11] net: phy: Handle c22 regs presence better Date: Fri, 22 May 2020 16:30:52 -0500 Message-Id: <20200522213059.1535892-5-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Until this point, we have been sanitizing the c22 regs presence bit out of all the MMD device lists. This is incorrect as it causes the 0xFFFFFFFF checks to incorrectly fail. Further, it turns out that we want to utilize this flag to make a determination that there is actually a phy at this location and we should be accessing it using c22. Signed-off-by: Jeremy Linton --- drivers/net/phy/phy_device.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index f0761fa5e40b..2d677490ecab 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -689,9 +689,6 @@ static int get_phy_c45_devs_in_pkg(struct mii_bus *bus, int addr, int dev_addr, return -EIO; *devices_in_package |= phy_reg; - /* Bit 0 doesn't represent a device, it indicates c22 regs presence */ - *devices_in_package &= ~BIT(0); - return 0; } @@ -742,6 +739,8 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, int i; const int num_ids = ARRAY_SIZE(c45_ids->device_ids); u32 *devs = &c45_ids->devices_in_package; + bool c22_present = false; + bool valid_id = false; /* Find first non-zero Devices In package. Device zero is reserved * for 802.3 c45 complied PHYs, so don't probe it at first. @@ -770,6 +769,10 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, return 0; } + /* Bit 0 doesn't represent a device, it indicates c22 regs presence */ + c22_present = *devs & BIT(0); + *devs &= ~BIT(0); + /* Now probe Device Identifiers for each device present. */ for (i = 1; i < num_ids; i++) { if (!(c45_ids->devices_in_package & (1 << i))) @@ -778,6 +781,13 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, ret = _get_phy_id(bus, addr, i, &c45_ids->device_ids[i], true); if (ret < 0) return ret; + if (valid_phy_id(c45_ids->device_ids[i])) + valid_id = true; + } + + if (!valid_id && c22_present) { + *phy_id = 0xffffffff; + return 0; } *phy_id = 0; return 0; From patchwork Fri May 22 21:30:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296466 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKRn1wJCz9sSJ for ; Sat, 23 May 2020 07:31:17 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731186AbgEVVbQ (ORCPT ); Fri, 22 May 2020 17:31:16 -0400 Received: from foss.arm.com ([217.140.110.172]:42338 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731153AbgEVVbM (ORCPT ); Fri, 22 May 2020 17:31:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F54E142F; Fri, 22 May 2020 14:31:12 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2849E3F68F; Fri, 22 May 2020 14:31:12 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 05/11] net: phy: Scan the entire MMD device space Date: Fri, 22 May 2020 16:30:53 -0500 Message-Id: <20200522213059.1535892-6-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The spec identifies devices in the top of the 32-bit device space. Some phys are actually responding that high. Lets try and capture their information as well. Starting at the reserved address 0, lets scan every single possible MMD address. The spec seems to indicate that every MMD should respond with the same devices list. But it seems this is being interpreted that only implemented MMDs need respond. Since it doesn't appear to hurt to scan reserved addresses, and the spec says that access to unimplemented registers should return 0 (despite this some devices appear to be returning 0xFFFFFFFF) we are just going to ignore anything that doesn't look like a valid return. Signed-off-by: Jeremy Linton --- drivers/net/phy/phy_device.c | 8 +++----- include/linux/phy.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 2d677490ecab..360c3a72c498 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -743,7 +743,8 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, bool valid_id = false; /* Find first non-zero Devices In package. Device zero is reserved - * for 802.3 c45 complied PHYs, so don't probe it at first. + * for 802.3 c45 complied PHYs, We will ask it for a devices list, + * but later we won't ask for identification from it. */ for (i = 0; i < num_ids && *devs == 0; i++) { ret = get_phy_c45_devs_in_pkg(bus, addr, i, devs); @@ -756,10 +757,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, * 10G PHYs have zero Devices In package, * e.g. Cortina CS4315/CS4340 PHY. */ - phy_reg = get_phy_c45_devs_in_pkg(bus, addr, 0, devs); - if (phy_reg < 0) - return -EIO; - break; + *devs = 0; } } diff --git a/include/linux/phy.h b/include/linux/phy.h index 2432ca463ddc..480a6b153227 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -346,7 +346,7 @@ enum phy_state { */ struct phy_c45_device_ids { u32 devices_in_package; - u32 device_ids[8]; + u32 device_ids[32]; }; struct macsec_context; From patchwork Fri May 22 21:30:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296465 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKRm2vyGz9sRK for ; Sat, 23 May 2020 07:31:16 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731170AbgEVVbO (ORCPT ); Fri, 22 May 2020 17:31:14 -0400 Received: from foss.arm.com ([217.140.110.172]:42348 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731157AbgEVVbN (ORCPT ); Fri, 22 May 2020 17:31:13 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B70541FB; Fri, 22 May 2020 14:31:12 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AFFF53F68F; Fri, 22 May 2020 14:31:12 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 06/11] net: phy: Hoist no phy detected state Date: Fri, 22 May 2020 16:30:54 -0500 Message-Id: <20200522213059.1535892-7-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Default initializing the phy_id to "invalid" allows us to avoid setting it on the error returns. Signed-off-by: Jeremy Linton --- drivers/net/phy/phy_device.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 360c3a72c498..b2cd22d6315c 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -742,6 +742,7 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, bool c22_present = false; bool valid_id = false; + *phy_id = 0xffffffff; /* Find first non-zero Devices In package. Device zero is reserved * for 802.3 c45 complied PHYs, We will ask it for a devices list, * but later we won't ask for identification from it. @@ -762,10 +763,8 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, } /* no reported devices */ - if (!valid_phy_id(*devs)) { - *phy_id = 0xffffffff; + if (!valid_phy_id(*devs)) return 0; - } /* Bit 0 doesn't represent a device, it indicates c22 regs presence */ c22_present = *devs & BIT(0); @@ -783,10 +782,9 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, valid_id = true; } - if (!valid_id && c22_present) { - *phy_id = 0xffffffff; + if (!valid_id && c22_present) return 0; - } + *phy_id = 0; return 0; } From patchwork Fri May 22 21:30:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296471 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKSN0f2Hz9sSF for ; Sat, 23 May 2020 07:31:48 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731256AbgEVVbr (ORCPT ); Fri, 22 May 2020 17:31:47 -0400 Received: from foss.arm.com ([217.140.110.172]:42348 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731162AbgEVVbN (ORCPT ); Fri, 22 May 2020 17:31:13 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 524831063; Fri, 22 May 2020 14:31:13 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4B3183F68F; Fri, 22 May 2020 14:31:13 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 07/11] net: phy: reset invalid phy reads of 0 back to 0xffffffff Date: Fri, 22 May 2020 16:30:55 -0500 Message-Id: <20200522213059.1535892-8-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org MMD's in the device list sometimes return 0 for their id. When that happens lets reset the id back to 0xfffffff so that we don't get a stub device created for it. This is a questionable commit, but i'm tossing it out there along with the comment that reading the spec seems to indicate that maybe there are further registers that could be probed in an attempt to resolve some futher "bad" phys. It sort of comes down to do we want unused phy devices floating around (potentially unmatched in dt) or do we want to cut them off early and let DT create them directly. For the ACPI case, we don't really have a good way to match them, and since it hasn't been working I think its perfectly reasonable at this point to expect phy's to implement enough of the standard that we can detect them and attach a phy specific driver. Signed-off-by: Jeremy Linton --- drivers/net/phy/phy_device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index b2cd22d6315c..acdada865864 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -780,6 +780,10 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, return ret; if (valid_phy_id(c45_ids->device_ids[i])) valid_id = true; + else + c45_ids->device_ids[i] = 0xffffffff; + + /* consider probing PKGID per 45.2.12.2.1? */ } if (!valid_id && c22_present) From patchwork Fri May 22 21:30:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296469 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKS63dHlz9sRK for ; Sat, 23 May 2020 07:31:34 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731234AbgEVVbd (ORCPT ); Fri, 22 May 2020 17:31:33 -0400 Received: from foss.arm.com ([217.140.110.172]:42338 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731167AbgEVVbO (ORCPT ); Fri, 22 May 2020 17:31:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CACD51435; Fri, 22 May 2020 14:31:13 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C39033F68F; Fri, 22 May 2020 14:31:13 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 08/11] net: phy: Allow mdio buses to auto-probe c45 devices Date: Fri, 22 May 2020 16:30:56 -0500 Message-Id: <20200522213059.1535892-9-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The mdiobus_scan logic is currently hardcoded to only work with c22 devices. This works fairly well in most cases, but its possible a c45 device doesn't respond despite being a standard phy. If the parent hardware is capable, it makes sense to scan for c45 devices before falling back to c22. As we want this to reflect the capabilities of the STA, lets add a field to the mii_bus structure to represent the capability. That way devices can opt into the extended scanning. Existing users should continue to default to c22 only scanning as long as they are zero'ing the structure before use. At the moment its a yes/no option, but in the future it may be useful to extend this to c45 only policy, or add additional classes and policies. Signed-off-by: Jeremy Linton --- drivers/net/phy/mdio_bus.c | 9 +++++++-- include/linux/phy.h | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 7a4eb3f2cb74..3ab618e15f2c 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -732,10 +732,15 @@ EXPORT_SYMBOL(mdiobus_free); */ struct phy_device *mdiobus_scan(struct mii_bus *bus, int addr) { - struct phy_device *phydev; + struct phy_device *phydev = ERR_PTR(-ENODEV); int err; - phydev = get_phy_device(bus, addr, false); + if (bus->probe_capabilities == MDIOBUS_C45_FIRST) + phydev = get_phy_device(bus, addr, true); + + if (IS_ERR(phydev)) + phydev = get_phy_device(bus, addr, false); + if (IS_ERR(phydev)) return phydev; diff --git a/include/linux/phy.h b/include/linux/phy.h index 480a6b153227..d68e1ebab484 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -275,6 +275,11 @@ struct mii_bus { int reset_delay_us; /* RESET GPIO descriptor pointer */ struct gpio_desc *reset_gpiod; + /* bus capabilities, used for probing */ + enum { + MDIOBUS_C22_ONLY = 0, + MDIOBUS_C45_FIRST, + } probe_capabilities; }; #define to_mii_bus(d) container_of(d, struct mii_bus, dev) From patchwork Fri May 22 21:30:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296470 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKSC4ngGz9sSJ for ; Sat, 23 May 2020 07:31:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731244AbgEVVbf (ORCPT ); Fri, 22 May 2020 17:31:35 -0400 Received: from foss.arm.com ([217.140.110.172]:42348 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731174AbgEVVbO (ORCPT ); Fri, 22 May 2020 17:31:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4FBE5143B; Fri, 22 May 2020 14:31:14 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 48A573F68F; Fri, 22 May 2020 14:31:14 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 09/11] net: phy: Refuse to consider phy_id=0 a valid phy Date: Fri, 22 May 2020 16:30:57 -0500 Message-Id: <20200522213059.1535892-10-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is another one of those questionable commits. In this case a bus tagged C45_FIRST refuses to create phys where the phy id is invalid. In general this is probably a good idea, but might cause problems. Another idea might be to create an additional flag (MDIOBUS_STRICT_ID?) for this case. Or we just ignore it and accept that the probe logic as it stands potentially creates bogus phy devices, to avoid the case where an actual phy exists but isn't responding correctly. Signed-off-by: Jeremy Linton --- drivers/net/phy/phy_device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index acdada865864..e74f2ef6f12b 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -789,7 +789,9 @@ static int get_phy_c45_ids(struct mii_bus *bus, int addr, u32 *phy_id, if (!valid_id && c22_present) return 0; - *phy_id = 0; + if (valid_id || bus->probe_capabilities != MDIOBUS_C45_FIRST) + *phy_id = 0; + return 0; } @@ -853,6 +855,10 @@ struct phy_device *get_phy_device(struct mii_bus *bus, int addr, bool is_c45) if ((phy_id & 0x1fffffff) == 0x1fffffff) return ERR_PTR(-ENODEV); + /* Strict scanning should also ignore phy_id = 0 */ + if (phy_id == 0 && bus->probe_capabilities == MDIOBUS_C45_FIRST) + return ERR_PTR(-ENODEV); + return phy_device_create(bus, addr, phy_id, is_c45, &c45_ids); } EXPORT_SYMBOL(get_phy_device); From patchwork Fri May 22 21:30:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296467 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKRz5rKZz9sRK for ; Sat, 23 May 2020 07:31:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731217AbgEVVbX (ORCPT ); Fri, 22 May 2020 17:31:23 -0400 Received: from foss.arm.com ([217.140.110.172]:42400 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731176AbgEVVbP (ORCPT ); Fri, 22 May 2020 17:31:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CE1011477; Fri, 22 May 2020 14:31:14 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BD9943F68F; Fri, 22 May 2020 14:31:14 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 10/11] net: example acpize xgmac_mdio Date: Fri, 22 May 2020 16:30:58 -0500 Message-Id: <20200522213059.1535892-11-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Jeremy Linton --- drivers/net/ethernet/freescale/xgmac_mdio.c | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index c82c85ef5fb3..96ee3bd89983 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -245,14 +245,14 @@ static int xgmac_mdio_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct mii_bus *bus; - struct resource res; + struct resource *res; struct mdio_fsl_priv *priv; int ret; - ret = of_address_to_resource(np, 0, &res); - if (ret) { + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { dev_err(&pdev->dev, "could not obtain address\n"); - return ret; + return -EINVAL; } bus = mdiobus_alloc_size(sizeof(struct mdio_fsl_priv)); @@ -263,21 +263,21 @@ static int xgmac_mdio_probe(struct platform_device *pdev) bus->read = xgmac_mdio_read; bus->write = xgmac_mdio_write; bus->parent = &pdev->dev; - snprintf(bus->id, MII_BUS_ID_SIZE, "%llx", (unsigned long long)res.start); + snprintf(bus->id, MII_BUS_ID_SIZE, "%llx", (unsigned long long)res->start); /* Set the PHY base address */ priv = bus->priv; - priv->mdio_base = of_iomap(np, 0); + priv->mdio_base = devm_platform_ioremap_resource(pdev, 0); if (!priv->mdio_base) { ret = -ENOMEM; goto err_ioremap; } - priv->is_little_endian = of_property_read_bool(pdev->dev.of_node, - "little-endian"); + priv->is_little_endian = device_property_read_bool(&pdev->dev, + "little-endian"); - priv->has_a011043 = of_property_read_bool(pdev->dev.of_node, - "fsl,erratum-a011043"); + priv->has_a011043 = device_property_read_bool(&pdev->dev, + "fsl,erratum-a011043"); ret = of_mdiobus_register(bus, np); if (ret) { @@ -320,10 +320,17 @@ static const struct of_device_id xgmac_mdio_match[] = { }; MODULE_DEVICE_TABLE(of, xgmac_mdio_match); +static const struct acpi_device_id xgmac_acpi_match[] = { + { "NXP0006", (kernel_ulong_t)NULL }, + { }, +}; +MODULE_DEVICE_TABLE(acpi, xgmac_acpi_match); + static struct platform_driver xgmac_mdio_driver = { .driver = { .name = "fsl-fman_xmdio", .of_match_table = xgmac_mdio_match, + .acpi_match_table = xgmac_acpi_match, }, .probe = xgmac_mdio_probe, .remove = xgmac_mdio_remove, From patchwork Fri May 22 21:30:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 1296468 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49TKS224wPz9sRK for ; Sat, 23 May 2020 07:31:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731206AbgEVVbW (ORCPT ); Fri, 22 May 2020 17:31:22 -0400 Received: from foss.arm.com ([217.140.110.172]:42408 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731179AbgEVVbP (ORCPT ); Fri, 22 May 2020 17:31:15 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4EFB91480; Fri, 22 May 2020 14:31:15 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.28.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3E9903F68F; Fri, 22 May 2020 14:31:15 -0700 (PDT) From: Jeremy Linton To: netdev@vger.kernel.org Cc: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com, hkallweit1@gmail.com, linux@armlinux.org.uk, madalin.bucur@oss.nxp.com, calvin.johnson@oss.nxp.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [RFC 11/11] net: example xgmac enable extended scanning Date: Fri, 22 May 2020 16:30:59 -0500 Message-Id: <20200522213059.1535892-12-jeremy.linton@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200522213059.1535892-1-jeremy.linton@arm.com> References: <20200522213059.1535892-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since we know the xgmac hardware always has a c45 complaint bus, lets try scanning for c45 capable phys first. If we fail to find any, then it with fall back to c22 automatically. Signed-off-by: Jeremy Linton --- drivers/net/ethernet/freescale/xgmac_mdio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c index 96ee3bd89983..1d7313031be6 100644 --- a/drivers/net/ethernet/freescale/xgmac_mdio.c +++ b/drivers/net/ethernet/freescale/xgmac_mdio.c @@ -263,6 +263,7 @@ static int xgmac_mdio_probe(struct platform_device *pdev) bus->read = xgmac_mdio_read; bus->write = xgmac_mdio_write; bus->parent = &pdev->dev; + bus->probe_capabilities = MDIOBUS_C45_FIRST; snprintf(bus->id, MII_BUS_ID_SIZE, "%llx", (unsigned long long)res->start); /* Set the PHY base address */