Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6949981rwr; Wed, 10 May 2023 01:28:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5xw9guUkhpOxUSLpgCxftGnUMxCGv6en8HWG191HnnPzQ83THQrWj6beskCocC3nborEvO X-Received: by 2002:a05:6a20:244d:b0:f5:9f72:1aaa with SMTP id t13-20020a056a20244d00b000f59f721aaamr21196456pzc.19.1683707284514; Wed, 10 May 2023 01:28:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683707284; cv=pass; d=google.com; s=arc-20160816; b=guzuqD7LSUCievNI0mmMblPIvU1525z8KMbqxuTchEYi840bIhlbpTeVZul8+tTnVV EQs1NmKLL/LlF2AHSZynMlcICs2nhZXo+E8FEyWOZBnFCuyy9kwi1pz6d2dzdXaBZyeV JYHTIg4gZRA/+7L4jNk/O4m39vGWi+lECnjZFaxxctK/gCGKNiQdBi1JbPKW7ABj9oEM 9OS0JjEESZiCxolp2CyjVmRR9gaUfh2O+eKxOPvRmvipAg7obayz8m1w3RBvKefRkUxv IgMlp0wtWoQ6EJUoZt9BjI1skQIOST7QvXIUPKK8Ky9fiueqZFGbAhiIov/TAbzKz0Ps O9qw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=3hEvRxnVuY8OkAsvsamTaF333oxcWYeCMolkQYpT9/8=; b=hyFvCzp3JM37BhWSua6pgri9929oO0yC5CHAV6noEe5yTjmll+jpdQrofSFeYb40eg BlNutxJ4anHCVTIrevJkTomY43882E0dRpvmjEKYJ6gzHkXMwBnb4CvKHZ4IwNRSNqmz 8n25sl30gJ0Mixiu6HRY5lNssdtH8BLV7ULjBBD3VAIu8pFXaarPQAG4gEIBuMSRoxSE bu86sDvSp1eOnk4KB5mE/r5e1B1UTnNQX7Z53PL3vMAI0qaP1hEaadrDzxSX/WWT512S 28OTUgPeqtTEZohTcw5Gz7DoJGrnZVOFZZkbdj932eegwWyoDVAB+61xFTJXyAFXsucO 2rJw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=gIurOX9e; 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 s1-20020a63dc01000000b0050fa9bc63cbsi3569468pgg.432.2023.05.10.01.27.52; Wed, 10 May 2023 01:28:04 -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=gIurOX9e; 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 S235609AbjEJIPx (ORCPT + 99 others); Wed, 10 May 2023 04:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231124AbjEJIPv (ORCPT ); Wed, 10 May 2023 04:15:51 -0400 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01olkn2088.outbound.protection.outlook.com [40.92.107.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5D61109; Wed, 10 May 2023 01:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ro9u7wxV4dVhZ3UE4rjd/9UAtIyySCWZ7l5oxLzn7jzt/fr4zShYUQ5Z0x1r8plHaY4kM0eLrxpPRvjrl7fgf7fIf6Otv5qDApEV0T7p8fObQKSz6vAct2cyLdzPhgxPIfGU7t5a5jMq8W+WZ80Sa3ekoMZBlfdBKul556MDNMGD0FRd0Y4yG6lcUxsTxUFyenEUhYcxlnEMEGQSPi/kBV3TkxpWEUQYsE1CJ21uzwRDhbkPck8ry/9vMvNJRMiSfwjf3klWkTEK6j36hjGO/YUh03htgGULcopBPnYUtWm1o2HsSTvL6MpZmewCN4hor0HP0hMPI5Km8ga9SeqlLQ== 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=3hEvRxnVuY8OkAsvsamTaF333oxcWYeCMolkQYpT9/8=; b=VTUrSoTY/Llwk8GTRKcEWDlwGs3hlr9xZGXluwTWTYJwHsn1dUYKxkbvQIm+xsGhDezQMMQp6mozHlS595cPDCiKVmMw69bk6ggQ5FeqLk8JssALlKZ0yJ1vGvxnsK1riPU9K6bUWcZVPd3fJjSoKBzAaNd2QGUieuZyEYo1XmMDPZelhbYCffSG4vje+fbVE6hXl0pQ9Tx6grTHOBTtY13s7q78SmRM8x1K4NebVFZ4u4JDanYNSveJPCdqtBoiPUDinnqjg4744+NRQ4mcUQED/inF3529HphfXUWmzj/wZtzf8plzWdtVNeq4VOZzj7gqf9DNVCSQVJhBE5tQng== 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=3hEvRxnVuY8OkAsvsamTaF333oxcWYeCMolkQYpT9/8=; b=gIurOX9ejF91xgWrvwGBxAmwUCU+PdLTiAgRM8ChXsHV8hNNgKrC0AnevDLEcdTNI0D+Nco5IReU3OWM/aRBFxMGbyY8h0OIbynXTaU5acDD+arFnzYK+gNpxDuhWUYib1OFHybK47ZYr57/cLwGGEyLANlLnH9eMnyoM9Ln8MW0HxH5LBoCge2plbaC/X95E1rTfGMP++W7oLuaLKlyUnwhjE/V2rzFNhEcxQVDDyatRUBxu+wTqo8iDi+xdjFA+b3hLu/38FzkAWxGiT81ABMss3uXcHdId0SCx1xD/EtUcCq6J+R4UtUzkjYvYD4PDLoh2FbH3M9oya/dF3oKrw== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by TYZPR01MB5258.apcprd01.prod.exchangelabs.com (2603:1096:400:33f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Wed, 10 May 2023 08:15:44 +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:15:44 +0000 From: Yan Wang To: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux@armlinux.org.uk Cc: Yan Wang Subject: [PATCH v3] net: mdiobus: Add a function to deassert reset Date: Wed, 10 May 2023 16:15:22 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-TMN: [f8AmAEqqUiimxftPk4FqF8Heq66pso1H] X-ClientProxiedBy: SI2PR01CA0015.apcprd01.prod.exchangelabs.com (2603:1096:4:191::15) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: <20230510081522.16677-1-rk.code@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|TYZPR01MB5258:EE_ X-MS-Office365-Filtering-Correlation-Id: 970beb9a-7c95-44a8-80bd-08db512ec098 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnoXjDUq8U81DgqU2Yh/IM/qLFwPWOVjsZzDA1JtHG0MQR0oGrKOkfjCZ/YnrJHRujVH4uo97XNvuxPV6CPGug14IZWzkuxTgJ36nIp5bWMPMUYR6MDB40+Td0WgPo6HrhcTmX1Q1qn3kRjE0qVvcFE24T5g/6Lih07VmPsXc1NZWxEm2U2gah82e/LZn6Yyb0PQhj6ZjyOvk1KtohzjFaeQDOH1n5+2l5oIq7xrjb7Ob/YJs2ecM4Z9LqbMFx5ySqFQ+JtYWtdq68WHYsLwg/WizctY+MbQNqkq49I7uwB+vlPgsnog7byGNMK4itXqbOuNbQLPNMocTXI+QytBKtmS4WzXm7ICyoP+T2b1CQh49k/Tqjz8LnAzy89e+/v7JXp1eGIIIZcVs8c4Uh7ahyEKhXU98og56+ioU6E4LBYDBz9OpIC1GNgCaJ6+c7/jbNHLbtkod5yedfMLclB7HIkqUNahUxW1Q87vO3kzDe+/M0NPUgizUyDAg3C9ZvRvG+7L0xLm24OUi7fmX/XJX7fd8yrjnvY75sf0N5mtG76sTAkjhe/8o8UUzJ6iukHy5UIcIq1zphEKKzfnwPdNRoYUXGvPwaQk7DGX24lVFZ4uK6vsuGxmpUCY4sH/W7Qu7x8jmk0eJy0sH0bQzjEEa9cah38IuqUFhKo1cO/AZcV6KzDXK0iI4hbqoAkEAXMQS3un5gcR8UyKeDgfJlzm3l60au6IGPKqxFnCqOEivQqDSacL6FliUSIhuo8vfJ0HuHE= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qAv4JR3El4+vbwyiitEq2u+NSzivilNfFRc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pvocEx6bAa0MJN5PDRzI8?= =?us-ascii?Q?uj+B2Zk8n0EjcfOas4lueWKZwqd1SAh+27D0zQ=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 970beb9a-7c95-44a8-80bd-08db512ec098 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:15:44.7647 (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: TYZPR01MB5258 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,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 not 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 --- v3: - fixed commit message v2: https://lore.kernel.org/all/KL1PR01MB54482416A8BE0D80EA27223CE6779@KL1PR01MB5448.apcprd01.prod.exchangelabs.com/ - 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