Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp413602rwl; Wed, 5 Apr 2023 02:31:06 -0700 (PDT) X-Google-Smtp-Source: AKy350Ypd+yzhWiZDg1XOexo0UVGw6upB+WaOLxeimLlSxWsla5/h4nuvG9+W1AIC6PPM31grDQd X-Received: by 2002:a17:903:1111:b0:19e:5cc3:828f with SMTP id n17-20020a170903111100b0019e5cc3828fmr7190224plh.27.1680687066722; Wed, 05 Apr 2023 02:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680687066; cv=none; d=google.com; s=arc-20160816; b=YOJ219XH3mss00KMML7fhkM3I5EOKdSsgnjYlyexmb7Hdvn4T8RFYQ84GGwyzEt8HO DpfPyivIIS9s9IWdOr9fHsT3FXq2CLykT2dqKItLczMiok0UgQ89PxHCgOMqxTToeoWh cMefVrk8qwaBFDkRVdg3lYmU1YHcX/yJQXrUCDOSfjViybc2RsiSY6IoExMgDEQ0l4Ka OiiM9WVKnp8i2jQ0V9sk0nE2x6bGKMptcrFC5Zw4DfsvtDICPdYMB39Umr3pvI2eXvXL eaNGQQ0t+HH9Ru4eLAMFOJEGUx7wk9mqo4ZaxzdL/g3glyU2KF7Wo58yP4VNzBjJLT1V Il7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=M4Jq90D8OmWIRM0nPVXoOoFucqKfWfStcXF7nzgrSWU=; b=dEojH0By2hszjQKDYO6GbBuWbW1K2IY4wswQvlouIRZ1FylHGfddMYeSgjRFe8aX5k rQ0Uw5NzjMbDCtaQnepNqyUEHPLVMywIAKsDVpqpLA4syVodYgH9e20lzI/4aMVAoE0Y IFqM7MDCoYXtWwQ/uUmyyzpoh0wRd+k6oPEaK2BY+d4UpF94+jQLyidP41qE4bFYrA1o Kq/pJBCy0lJ5CdxCRInDZxs/piyhpkZdENqzIBuz7i5VjpGFz1o9vNqVeDJjiSSlGCvE wp7Qzor3F+yLc3gCTQyCVVNnlxURcJVKJs/g7tnu648LzagdYQY52kuIiF4hEt79aKcm NYUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a170903229100b001a0561c726dsi12559619plh.264.2023.04.05.02.30.55; Wed, 05 Apr 2023 02:31:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237413AbjDEJae (ORCPT + 99 others); Wed, 5 Apr 2023 05:30:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237681AbjDEJaF (ORCPT ); Wed, 5 Apr 2023 05:30:05 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 358CD5FC0 for ; Wed, 5 Apr 2023 02:29:34 -0700 (PDT) Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1pjzQ3-0004pA-Fk; Wed, 05 Apr 2023 11:27:07 +0200 From: Marco Felsch Date: Wed, 05 Apr 2023 11:26:56 +0200 Subject: [PATCH 05/12] net: phy: add phy_id_broken support MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230405-net-next-topic-net-phy-reset-v1-5-7e5329f08002@pengutronix.de> References: <20230405-net-next-topic-net-phy-reset-v1-0-7e5329f08002@pengutronix.de> In-Reply-To: <20230405-net-next-topic-net-phy-reset-v1-0-7e5329f08002@pengutronix.de> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Broadcom internal kernel review list , Richard Cochran , Radu Pirea , Shyam Sundar S K , Yisen Zhuang , Salil Mehta , Jassi Brar , Ilias Apalodimas , Iyappan Subramanian , Keyur Chudgar , Quan Nguyen , "Rafael J. Wysocki" , Len Brown , Rob Herring , Frank Rowand Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de X-Mailer: b4 0.12.1 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::28 X-SA-Exim-Mail-From: m.felsch@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some phy's don't report the correct phy-id, e.g. the TJA1102 dual-port report 0 for the 2nd port. To fix this a driver needs to supply the phyid instead and tell the phy framework to not try to readout the phyid. The latter case is done via the new 'phy_id_broken' flag which tells the phy framework to skip phyid readout for the corresponding phy. Signed-off-by: Marco Felsch --- drivers/net/phy/nxp-tja11xx.c | 1 + drivers/net/phy/phy_device.c | 3 +++ include/linux/phy.h | 3 +++ 3 files changed, 7 insertions(+) diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c index b5e03d66b7f5..2a4c0f6d74eb 100644 --- a/drivers/net/phy/nxp-tja11xx.c +++ b/drivers/net/phy/nxp-tja11xx.c @@ -560,6 +560,7 @@ static void tja1102_p1_register(struct work_struct *work) .mii_bus = bus, /* Real PHY ID of Port 1 is 0 */ .phy_id = PHY_ID_TJA1102, + .phy_id_broken = true, }; struct phy_device *phy; diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index bb465a324eef..7e4b3b3caba9 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -969,6 +969,9 @@ static int phy_device_detect(struct phy_device_config *config) int addr = config->phy_addr; int r; + if (config->phy_id_broken) + return 0; + if (is_c45) r = get_phy_c45_ids(bus, addr, c45_ids); else diff --git a/include/linux/phy.h b/include/linux/phy.h index 498f4dc7669d..0f0cb72a08ab 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -764,6 +764,8 @@ static inline struct phy_device *to_phy_device(const struct device *dev) * @phy_id: UID for this device found during discovery * @c45_ids: 802.3-c45 Device Identifiers if is_c45. * @is_c45: If true the PHY uses the 802.3 clause 45 protocol + * @phy_id_broken: Skip the phy_id detection instead use the supplied phy_id or + * c45_ids. * * The struct contain possible configuration parameters for a PHY device which * are used to setup the struct phy_device. @@ -775,6 +777,7 @@ struct phy_device_config { u32 phy_id; struct phy_c45_device_ids c45_ids; bool is_c45; + bool phy_id_broken; }; /** -- 2.39.2