Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6950881rwr; Wed, 10 May 2023 01:29:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4B62bEZTuxMbih39AwEXCi2loXTMmbpqJAgED7i8dhYs1t/R0ys0e+cTFW+leYE46HDsUE X-Received: by 2002:a17:902:da8b:b0:1ac:7e95:74bf with SMTP id j11-20020a170902da8b00b001ac7e9574bfmr10588308plx.6.1683707355899; Wed, 10 May 2023 01:29:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683707355; cv=pass; d=google.com; s=arc-20160816; b=wxLyoL1XlkFQyhjQ1H6G+E0IBet/QlkHVlFBpjwT3NWc4C0F+S9kH7IjKA3DLcXqT4 K1t5iEMkbFrnJmZNt4dLcnHgSckYzpaHJBrNYcqdLWO+Sd0ltEgYi0jJEuUnDRC/ioD+ wd0zP4pvDT8Y8e9AyOgYNrwUDZ+JLqW62j64cf6T7DwcZnUvKpxIscamL6YrqG5Tg+PW gqTHIi+091q9/S4yFXzgpvo9mZo+Yz5Rm7SHCp4OaYrx5Sczz1j67q2FTf0dCvkYOWxm VJOSK3cvcFf5nuR+6VsIBrn1Hbq1+cLqpVBhn9HhZFqPPB8AxN8dmc8imL95gko218Cp GY+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BvMsFh4FPO1iP15Ypt6iloZ1FDVKWvXhmfyczyjOwM8=; b=tv89tJ6J1fO/UJky0SFh+/8lYnWLtl+vlOR8DoAMJ9YyDi2D91llkyBZt17gLTvGJv 3Wm8T0Js2eGjDy5BEBsa4+Snm2BZ2HyyaNHKlEEyIIvq4VZAGb9rvWEhxBEvwkaaFfNJ 7RPyZcscUCxDjFnDoIar/K0K+7pZlEwrUt2TFyFaRyLYOa6diZ9pfkCMl7EdjTzz6Tza vuvcfiT1NVV5egf745YKDJ6aERpRqGjg/bx83jRo/ji34+Y4ihqYXEnYFO8NfRIdtnFI P7zKHUsC5UU3gNfi2V0ye1DB9Zz2l3nSnnaenclKIzEAZLvRhr6XLXFPn9ep5ggTdFmP II2A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=R3NtbwNl; arc=pass (i=1); 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020a170902cecf00b001ab109ea531si3706889plg.558.2023.05.10.01.29.03; Wed, 10 May 2023 01:29:15 -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; dkim=pass header.i=@outlook.com header.s=selector1 header.b=R3NtbwNl; arc=pass (i=1); 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236523AbjEJIDq (ORCPT + 99 others); Wed, 10 May 2023 04:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235798AbjEJIDp (ORCPT ); Wed, 10 May 2023 04:03:45 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01olkn2014.outbound.protection.outlook.com [40.92.53.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9557D1BB; Wed, 10 May 2023 01:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jiNLETpt0YlxMHAPXVXdUsA2uV7ZEB7qXQyEtCGMthUXmzExcQwLfg0XQbi/+jO+v+6ojmT6XStbGjRTMMjv2cWXRgoo/jGGfsisSauHJ+xOkOqZzeE+Zbn2J2xSwGUa+2LFDlrkMhGmsoPNFcHPpL+/ETYNAeMwTNI2Lg2ahhT6k2diZG1QIKZvygconfH9jFjsiIiFOdUhsO2qxIa5Ryr6dTFvH6VwOrRg2VcHk/lli/ZNg90wvXBOvS4hE98p4hAyyt+dy03tYnlHKnkTOQHxZWlexmKy2dVSRgnlAI4XbopMlodmSKmzIgBe1M5tDmJzmsx31C0ITZDPe5KkvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BvMsFh4FPO1iP15Ypt6iloZ1FDVKWvXhmfyczyjOwM8=; b=Qev5T4zOnH+ld2wZM4kmQ8lr6nIF64huY8xwlPKkGWq0z/mx4pL1381LQ0mU6fae6Wiyh8Q6pcTBWTfv0ydrvso+HRLey9RPH1H1S7nvnVT5DRLdWZC1qoEA79tXDpgqoRaCuMVlZquhrCkHSeDYP3an+LkNUVy+qfeODgWB2dobNZB5WbLvILkRYT52Cebt16sYf2aAGQR1NG+X3oUCKnurpYh4hRFmZnLLBuq13nDaAJ7qoRqmFMBM7GOyS2r/uyYxAZWG2E5SLbaXhYSSTJXy8cYga+QU6HXOHgQSYHo7G+GtG6MM//md0B/JQrpY+weIGu8wIndZ5GJpZvNGuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BvMsFh4FPO1iP15Ypt6iloZ1FDVKWvXhmfyczyjOwM8=; b=R3NtbwNlpiPiH5g7W4VgHPwnuxgUlffSMzNiRHShefgbmwwtYBxEC74SKOjq9VLW2kgYkCw70c0GDJBGteBpFa4vCOGGrrs/a0uvIDFK+lCMKCTGLUKIla2gXy1LrPnmYz+SDf5b/YB83Ukwf7oeDDjOIbk+RVHT7vB23Mu0r3pRASfFsB7aM/FTI5BuSoe0KNn5xqxWUCLQlrwd7CGPac9x+JBdThzAJg+7TlRK7OlCi7icGkA/sklNhmy+77sUKXvlu5MPgaJLUiUnTKGDENi5BtBnx+kFmlPWsZF+5HaMTZmB+slvzw5KPjSkMStvz0Iry8T73OWYM4Iy9GSH/w== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by TYZPR01MB5157.apcprd01.prod.exchangelabs.com (2603:1096:400:342::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Wed, 10 May 2023 08:03:38 +0000 Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::93cb:1631:4c4c:1821]) by KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::93cb:1631:4c4c:1821%4]) with mapi id 15.20.6387.018; Wed, 10 May 2023 08:03:38 +0000 From: Yan Wang To: andrew@lunn.ch Cc: Yan Wang , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org (open list:ETHERNET PHY LIBRARY), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] net: mdiobus: Add a function to deassert reset Date: Wed, 10 May 2023 16:02:52 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 In-Reply-To: <96a1b95e-d05e-40f0-ada9-1956f43010e0@lunn.ch> References: <96a1b95e-d05e-40f0-ada9-1956f43010e0@lunn.ch> Content-Type: text/plain X-TMN: [EWmoEiRTzNj2A+LopQ533GNSoOZxDleJBgyBYkdfV1s=] X-ClientProxiedBy: SG2PR04CA0216.apcprd04.prod.outlook.com (2603:1096:4:187::18) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: <20230510080252.8584-1-rk.code@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|TYZPR01MB5157:EE_ X-MS-Office365-Filtering-Correlation-Id: b881ed19-be2f-401b-1500-08db512d0ca1 X-MS-Exchange-SLBlob-MailProps: YfhX3sd/0TX2BmCZQdbdnh7GRQzK1Scz7pFxnsAzYmi/NvFeTcavnYsLt8sW6SRPHvQ9N986QLLiN2tE8mrB5ilPKZ98oHLdmTWqVHBQcj4gL8ad9WPnHPd74G4FLxXXPkn+EN7fWqdR/b6ZWob1s1GI2/grzPF8NqtUsG5SXtdJMKY2SKaoC13EF/CYWp6HEJ7sjPPHERhWLaS5ULtc2QUcAZYX731zKGNMruUv0Wxg5jGJGDiyPRY4/Z6VIt/17tUSvYWf48e8mMPLYqQSN3xCjVg+W/VodkOioWq363mPvzTfyej7rs6nqiNXnnux1AyYQqdQW/rEfSXluCNxeEDorcBfh+l5hAojUCS7QZnr7YEe68C6K46CcRvWzLioZ90vxuXcbp8Ymjlm6oy0UKHPfH8i1HcYNeeN+XIlyus777VvRK1bq0aMUR/AAz1imU4j75AKk9puo0Oisy4DEF/sgMKxr0kEfarVs7kkXGAGncILkrENqnbWGQ8XxrBiIzeRzC9iIXxlwrkKyuh/9nzaM6U3Sh/zINrcS7t3bO+f5p4Z40su1G1TpmfbTWCspQn19uWIA87Ub+BMWwFMBtEJV4QAb6efaRIsgt5auKqOpKIKi1XPbdTnPahTThJ8IEI+kceQcOqxvi+yVF1YU/iyeQhUEk0O5Gn8PkrMn3W0OeD4G0h7F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JFyqMDnd2GWaTP0Sr4gOVAR7a7?= =?us-ascii?Q?NqUoBmKEaEacmofLVmyyPC6Qn+evaqNMd3kPLr0RzSaedi2gMa0vmIw2WQ33?= =?us-ascii?Q?DDsS1Dh6QhYfUriXQG+RWXlGp/lnGTqAeBvbcM1SttrQAQXroOnVrcOG/ONS?= =?us-ascii?Q?KyZpUaz1mfc8zdyLMvVB/WgoGUuQmJfEhS0kXA=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b881ed19-be2f-401b-1500-08db512d0ca1 X-MS-Exchange-CrossTenant-AuthSource: KL1PR01MB5448.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2023 08:03:38.7585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR01MB5157 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 It is possible to mount multiple sub-devices on the mido bus. The hardware power-on does not necessarily reset these devices. The device may be in an uncertain state, causing the device's ID to be scanned. So, before adding a reset to the scan, make sure the device is in normal working mode. I found that the subsequent drive registers the reset pin into the structure of the sub-device to prevent conflicts, so release the reset pin. Signed-off-by: Yan Wang --- v2: - fixed commit message - Using gpiod_ replace gpio_ v1: https://lore.kernel.org/all/KL1PR01MB5448631F2D6F71021602117FE6769@KL1PR01MB5448.apcprd01.prod.exchangelabs.com/ - Incorrect description of commit message. - The gpio-api too old --- drivers/net/mdio/fwnode_mdio.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index 1183ef5e203e..6695848b8ef2 100644 --- a/drivers/net/mdio/fwnode_mdio.c +++ b/drivers/net/mdio/fwnode_mdio.c @@ -57,6 +57,20 @@ fwnode_find_mii_timestamper(struct fwnode_handle *fwnode) return register_mii_timestamper(arg.np, arg.args[0]); } +static void fwnode_mdiobus_pre_enable_phy(struct fwnode_handle *fwnode) +{ + struct gpio_desc *reset; + + reset = fwnode_gpiod_get_index(fwnode, "reset", 0, GPIOD_OUT_HIGH, NULL); + if (IS_ERR(reset) && PTR_ERR(reset) != -EPROBE_DEFER) + return; + + usleep_range(100, 200); + gpiod_set_value_cansleep(reset, 0); + /*Release the reset pin,it needs to be registered with the PHY.*/ + gpiod_put(reset); +} + int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, struct fwnode_handle *child, u32 addr) @@ -119,6 +133,8 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, u32 phy_id; int rc; + fwnode_mdiobus_pre_enable_phy(child); + psec = fwnode_find_pse_control(child); if (IS_ERR(psec)) return PTR_ERR(psec); -- 2.17.1