Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8203948rwr; Wed, 10 May 2023 20:21:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4MM8qXJO5Tdz8NZm2cwFbASYSKQI3KQm4RQJrEJEy6Y9BjDUoTdzFDo7VRYIPboEUdTmAa X-Received: by 2002:a05:6a00:2401:b0:63b:5501:6795 with SMTP id z1-20020a056a00240100b0063b55016795mr25453562pfh.24.1683775318663; Wed, 10 May 2023 20:21:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683775318; cv=pass; d=google.com; s=arc-20160816; b=cqlPqjMX+suDja+55KAK0jqusNHyg1TWqpaAktYMTN7UlyQv5DPsINrJhAYj1xrCa3 WJvLForS+xhWKogvfGYqgaF1b5mfypjmNy6IYajwtdqBrDMach7ItdTCsRDhZT5aNw4C xC3526YwhBK5n1il5BfpecuGw+fkuQFr+yQwlGZjUq8NXE83aIeOKPoi+SRBdQiNir0J 5f4Vk/J09tmxk48+PXvpIQ1UA+JcF/UML2VGVyXB3hASmR0U37yUsW1TnMjU1jaRU6rT jhlMz0ZdLqHD5BRKBG4dhrwffgSHdqQJQgKZrX/qJCtdrvBJrbHVXJL9eij4A7qfjD5c nNng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:subject:user-agent:date :message-id:dkim-signature; bh=sCq7AIj7Rkd+59By2ou4H55UQRh/tHJ/x5HWhqIRRok=; b=bepKZI4YQgpwV84lhaG61eZZQgHNhTZmnwU09WtO3T9kyiSEtSCqi7hW9BnuBjwJWf BatDrlXzIKjYd32RzpoCkrV4dX0UTk3jO/lFJ828LRrJf17sF4ldvmTdpZmXCINju/8l WrIAWoFxYvqTFiMiarMw46rAV9IORGw8qKgrhfkCeOeGqNYjD1gK/XAvS8fnmD+wIE8f XgmSExHxO60VsYx8eOv2XEB3FHVAZLpTHp86kB9Qybm5bA5qIffx17IuLGFJKyiod9os HyBKyN9/TvunhythEtpdGq846UBDdHj10q1ySxHW4PkOdCUy4wh+ClfqlpE6STVp1P5q n1Pg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=bl+7nCcT; 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 v10-20020aa799ca000000b0063b7b49928fsi6492777pfi.204.2023.05.10.20.21.45; Wed, 10 May 2023 20:21:58 -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=bl+7nCcT; 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 S236438AbjEKDRU (ORCPT + 99 others); Wed, 10 May 2023 23:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235731AbjEKDRR (ORCPT ); Wed, 10 May 2023 23:17:17 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01olkn2046.outbound.protection.outlook.com [40.92.107.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59A8D4230; Wed, 10 May 2023 20:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NdzI+JILhAZm1FK5eCYlc6YgiDFcbvlZfn/OCKnMdReVq9YnA/Ei5sb9YZDcqnEwY6zohYmoLXK/4fiz/GctJbpOzHvW8B3aAoB2zgz2kh44OjMddUQ7VXW7PqZN99bniKS3OAZ3AD5iOjB4qFOLW+K5E257ii9BbGl/mmfNVfFkVi+uo1PuEaznoPhqX9Efw8rL8F57/lC1bKd07hDrE8asiFw3x69Z9XW976QdjPSl64Uok8FKzXHR41qdfLe49W88pUJb63i/M2FxmVGm+HFwiQxRQFYJtoWwkJhmLqMX/cnOZLEY+Wxw0v0A3vud/2kK/3vrNpK1CqK0LTTulw== 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=sCq7AIj7Rkd+59By2ou4H55UQRh/tHJ/x5HWhqIRRok=; b=KQ9aWsQdkEKlUQ++HbmvQGicYcEXuAwqfRLTh+niIY2SIZa99x5APFzKoCxuatd6Wu4xB3dSqscHNU1BMD9hj51yiKT+xFyQoSlGnm2Bq9LtggYg/1haerm9VLJ1aSfY5uqPVVRYwYtnFRyn+UPDHh5/fIDDvvgxm4DtBeMaJxEZBcXMfy6cIr+cTQSibj6VyfwxDhrSzmoynwF8pRIEZU9OWzFv1Eme317ICL31gQQyhI/jO2a+827CyIKo3xMTcwPnFVAGOLCVtOdzFEFn7lfFt1Q4spZqWhAo6y9YIOUf9V+HBsCTrv0hCEe7c1K2MPY5Bglhzhbo8jqB9WuvGw== 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=sCq7AIj7Rkd+59By2ou4H55UQRh/tHJ/x5HWhqIRRok=; b=bl+7nCcTrQog0DQ2XsuXr+7+OJnnoPNo6vRnMBmAfzPk37WySinEGvkql7U0+uU436MBos3xjD+TJJXpwOMaOxCyfrIOfev4JUZy2aDB8Di8EV4yS60/Ayl4Oj0qVw5mxT8YfOXY2JScYZ9NMSheg5nqaymzUDtDRmhevg18s1ZBAYTrXsiRLkp9mibcMgTZbS9qu43/ziCg5+qRM5CdSnx8iwIIDFSn5cBGeBN6hTuNevKflECdvqZkjoNcvw9Dgcnv3x2HBZto92Tx/LR2XV1eZQjqEgFr4UKNx9npwA6dAuPAYurYvMSGnuBnTqf9KvREQnq4XYPcZEDjKcoapg== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by PUZPR01MB4932.apcprd01.prod.exchangelabs.com (2603:1096:301:f3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.19; Thu, 11 May 2023 03:16:56 +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; Thu, 11 May 2023 03:16:56 +0000 Message-ID: Date: Thu, 11 May 2023 11:16:52 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v2] net: mdiobus: Add a function to deassert reset To: Alexander Stein , andrew@lunn.ch Cc: Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "open list:ETHERNET PHY LIBRARY" , open list References: <96a1b95e-d05e-40f0-ada9-1956f43010e0@lunn.ch> <9107661.CDJkKcVGEf@steina-w> From: Yan Wang In-Reply-To: <9107661.CDJkKcVGEf@steina-w> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TMN: [Q7JojGAbaI9VqIvq83L5ApDzpGMsV/RYYKmLKjlqzwI=] X-ClientProxiedBy: SG2PR03CA0108.apcprd03.prod.outlook.com (2603:1096:4:7c::36) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: <2591cbd3-5bc1-515a-a157-8a51dc321e13@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|PUZPR01MB4932:EE_ X-MS-Office365-Filtering-Correlation-Id: 8fe48ab3-4447-477a-bfd8-08db51ce2cf2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gqsTBqNZ+6YT44/twAgBfZbZHnoqV165z4ctIl8CfiaggZaSLb8prtqU/PshyLlkXNYpfQ+vSxI4ec5cGkc5kAb82hpnAWg9px5fwLJfC6E92h+UlLxGqJSd4YBCEjZpmJhnXmO66OsPMhBcJH35mOnlkTzQKatc+Plo6DGdDuaLxEG/wB6ecL6am/3rt/ByaJJ0ZPJ3fSti1yLCtG/caOXj7h8/zWJ4H16IdTPqXJhuyl3OtZIVz4Uq/MVd5INPOctssVV1SPAMJjW69fkfvSYeq4JFbRIrTsbIdYY0Dn1zEoqxhbRtY91I7eGoCb8WkHwcdjwXyS+2m8D45ipfT6OisWuYY8ERNct+77ftlvNRNvH+8bfaci5vKNQIcaeUJ1Lp+OyXjubvts52iTXSrgthdaPtnrv1yt1KHmsWJmrWeFBRNusUIU0Ry8qF9r7hGvKF15KpdTBJiCVqGkxGhCcpmaWbl+yrpjlQdBkMfvAo3m6cM9st6a9eBXuBMYd0eYpT58U5fzkVRejClM4WO6zvD9OcMb9I5xhW7zj0M8CLqTILIAwYvfqP4WMlpb70UDxlDn7qJ4A7r+WJgdL/2wNJ6i7aRGfDY61mp7usI1c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2 X-MS-Exchange-CrossTenant-AuthSource: KL1PR01MB5448.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 03:16:56.4654 (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: PUZPR01MB4932 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_MUA_MOZILLA, FREEMAIL_FROM,NICE_REPLY_A,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 On 5/10/2023 7:55 PM, Alexander Stein wrote: > Am Mittwoch, 10. Mai 2023, 10:02:52 CEST schrieb Yan Wang: >> It is possible to mount multiple sub-devices on the mido bus. > mdio bus Yes, misspelled. >> 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 > We had similar cases where the (single) PHY was in reset during Linux boot. > Should you be able to make this work by using a "ethernet-phy-id%4x.%4x" > compatible? See also [1] > > [1] https://lkml.org/lkml/2020/10/28/1139 Well, I've seen the [1] before, this method may mask some issues. For example ,if I use another type of phy ,I have to modify the DT, Is it very cumbersome? >> --- >> v2: >> - fixed commit message >> - Using gpiod_ replace gpio_ >> v1: >> https://lore.kernel.org/all/KL1PR01MB5448631F2D6F71021602117FE6769@KL1PR01M >> B5448.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) > How are you dealing with EPROBE_DEFER if the reset line is e.g. attached to an > i2c expander, which is to be probed later on? Thank you ,The logic is wrong,trying to fix it. >> + return; >> + >> + usleep_range(100, 200); > How do you know a PHY's reset pulse width? > >> + gpiod_set_value_cansleep(reset, 0); > What about post-reset stabilization times before MDIO access is allowed? yes,I need to get reset pulse width and post-reset stabilization times from reset-assert-us and  reset-deassert-us. right? >> + /*Release the reset pin,it needs to be registered with the PHY.*/ > /* Release [...] PHY. */ > > Best regards, > Alexander Thank you for your support. >> + 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); >