Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5600634rwr; Tue, 9 May 2023 03:59:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45nBD5dZ8cf/XK6n5Od3CNpwn4g63lNtEbIjng8S9kTHZgurnJMhSVKmbAEpqq29eRbV+j X-Received: by 2002:a17:902:7e84:b0:1a6:f755:a4a0 with SMTP id z4-20020a1709027e8400b001a6f755a4a0mr12153630pla.58.1683629963301; Tue, 09 May 2023 03:59:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683629963; cv=pass; d=google.com; s=arc-20160816; b=eatmm/7IE3eHf851p3N9b3kl6MOpTgM6olW6hoLFuO0YlH0hIH+xF/F/osPf8MV4eN lcD1qcAX+XvIyGL7QZ0rQWwzK4WLCK2Qk/vYhO/4E3wZx5u0O1ePI343/3hu8jTv0FVg lcn5RfWDO7LjN7mLBuIjz5d5A7nUZz/gurud5ajlqO+Z/dooWk8gdYpKneeL85lMnS16 48n0OqH13d3b5XBfJ570bz7TzFcIQXr+H3QKNKSqn6q6VkUYuZR5MRBiP2NZTOVnC0Bp toqoiFzTvg77OXOiIK/EtqhkBPg2gXnNx7JHDESUytnGtKVianqw2LQRkBd3gcuUVQK5 MuhQ== 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=ZzvVmXnT1+11Bbk64z1aTfRv8WOX0X/ABgp4v2cbPqs=; b=cyN1zSKbmTaxhyrSSe/OenrZUR3IGuhdJW9Nu/cjzbpMCgNo6OTIkMPKHcFpeYY/M3 Cg6SQXzvWbAfRDc5M+bFPhmbsMkVTEHJp8DDpxjvha62qJJiPb6v/K3URX/0CBKNK4P3 R6xjzVAprbTfyo/IdwGV+imj1rck2XgC1wovK+K4i71/4PiZ+lEgdqg2/5Rt6QR6V+cA qyQRDkg+zU1JrumIJYN4eJE4ZKCyrlUnkcw8/PK6YA8q02LdDAUfokII9GUfRNWfx5J7 1SrJZ+0xhqRKZvJ1jT+tb0Suc7MMUzvKPNYh7JKWDrky3fBd5/G7a+A9KQHbcy7PQbo0 bfFg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=qn+KnsBJ; 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 w13-20020a170902a70d00b0019aa0d010eesi1180748plq.308.2023.05.09.03.59.08; Tue, 09 May 2023 03:59:23 -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=qn+KnsBJ; 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 S235296AbjEIKoi (ORCPT + 99 others); Tue, 9 May 2023 06:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234945AbjEIKog (ORCPT ); Tue, 9 May 2023 06:44:36 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01olkn2023.outbound.protection.outlook.com [40.92.53.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746E05B82; Tue, 9 May 2023 03:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwI/+lCObVRa2t4u+xtzmcvQyOcgiCKEfNtmAPXecfZEaszTgyyduErQe+fCGVNYBL/JkqBA0FLC3ZbiWZtFyLrIj2d47+ImxF9qi1H+U68OFUTZt2nJvP7BjCab8oWAwmZexxmGCPjeNOhtYLy7kOx2+iwkUsN+DJVJP+kv6Fp9cIPudVSkCZ1P4WkqM5BlOKzFyYyDGbbJ0lzSNx9aDr4Yetba/1P8OXd6FIn66MndjQ85Z3fHbregGOPjgioM6cxO8PUjuiqOMDj9uRg6sXwreDWYE8Pd/EkejJdm10CV1Q2wttxQ/YThly+24c2YJ/GAatDGo3lPDnEll4bXmQ== 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=ZzvVmXnT1+11Bbk64z1aTfRv8WOX0X/ABgp4v2cbPqs=; b=KPte4lLsAPlDN48VI86iAXA0HrDPcO95MZWppzZVJmrdiCs9kRaYd4YyHlvJo6iIaVTZzleNz/yMLL6TrhXnFqG6SPwG2tGeD+WyHk/iESZKTNvdHzsuaJ9IWWqzUUARXHjzXN4od3e26HXhda2tI01SVYMpjiJhOmc5VMjk8GMuoovxKLGxnHzFvh1suL80Cmtq+GW1tD3xLh2kXSiEKiI0rDyQ8jZev++4bgkO9PqmNwPqYZyDMgLMjqZoOx6bhClo/iQtPUtm2rM9w4q2bY++fpITP/t24PKZoHAeLTIACNDhrNi5UE0YXXjqZ22ML6koJfd/RcuiuuIV9UXMSA== 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=ZzvVmXnT1+11Bbk64z1aTfRv8WOX0X/ABgp4v2cbPqs=; b=qn+KnsBJ2AK6HmieLPTwst+Co2Gc1xQuAELpbZ6j3dhuE4X8Fe3KezU3tq0hzlXMcGUGl8b6Daa797P1DFp4Yxj5V5+Z5vejsjaks9XnMWnHIFsOBRgb6LgYNuVcARKnek6AmEKGSoeb9fyl68C1L3cg9C0PDe7FWqHeITOBflh0fR6QDcZjcFM3IJwnKCWOkXDAK37lgeb4cyhGw1gPUYFDafiyWxF8tEKNhAtc1vRx4NMq9NSyJ1FBz3fZNgqL30Khpk+OhWWyvWZwSw2EfaOC6ORZ9P9em6XpuD8a95+Vgbto4Gt19JocPl2+HeBSnLO71y+tUirDLF+24EBtiw== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by TYZPR01MB3791.apcprd01.prod.exchangelabs.com (2603:1096:400:3a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 10:44:29 +0000 Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::1ff1:2f4e:bc0:1ba9]) by KL1PR01MB5448.apcprd01.prod.exchangelabs.com ([fe80::1ff1:2f4e:bc0:1ba9%3]) with mapi id 15.20.6363.033; Tue, 9 May 2023 10:44:29 +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 v1] net: mdiobus: Add a function to deassert reset Date: Tue, 9 May 2023 18:44:02 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-TMN: [QkEH8rhL8Hhmun9bxRi7I3tLjPMxwdqwWbVUHW5mXk0=] X-ClientProxiedBy: SG2PR04CA0184.apcprd04.prod.outlook.com (2603:1096:4:14::22) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: <20230509104402.13498-1-rk.code@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|TYZPR01MB3791:EE_ X-MS-Office365-Filtering-Correlation-Id: 53966928-b058-4510-228e-08db507a5da5 X-MS-Exchange-SLBlob-MailProps: wk1EIbWONa0Oqax1UZBelAFl4e8UuTAlrWAh4HybAGN3wBk78lyzTya/GXmt+H4k606e7ka+G+mt+iURW9uDPc34ojFllBkdU0v3KvvUo2Phslh0IEKm2ZlcoX5KbJtB3uars/MkmLXnYb/J0aj+r3JAszSM8RX4RX7iwTuzFRplgZ5ia82rYDx/ofGSWHay9K378ggvVgBgIhvTQC7xjHFq1rPsNgR0LV4QLkoAEtKc1K/XSxXXpUT+3Mea2DL40iK5UIhCOFuEn6y/bYhM5ljHss1ouTfwRRAXWVh6bjJH894tTFabqjgGwU2ro4kxThzE/SCtvriPjE0/LWx5w+QFyN/i4mgoFSmj3ireiBc12EEeSa+GQ2F04cysZFZrKvXM1dB1djzhvQshC2WNwyMgjqufZSzvORpn3D4N6k6cDCFI+nWfYAMWljQweCzB9F5Y2V9vJ/CfpuLHWl4dqRG+UPxzgnFczONLgpoOsHMPdeHPljgcinLZgXhya1dcUK2uSj4w/NHMWz1naP7NvzC5DrsHtMvMkrnJckWZBDTGPs5BKr2vqdokkVfvuVjpYmUcwMEs9y4Xc5FB8VgqpI2oqeCtmxZ1piqDhlJ6OMah+8FvNIAxIRLclbtJCKnajOStgzTiHYcOkFK4ruDu1JICyt0oXXsKvOxOq+XBwZAeNZK8MqIiFeygm83m+InK6x2LRv8zQis1geYo7mfCPPU1NfckpDZPWjqV7mrygS4sk++PXc/Fug== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZBQ6ecB3I636zxSXErnQSBcQObocjI2gp1fIIizky/Fnf8Njl1NctxH+W4i2weKzLN2khGDL22AM2BxA5RDotTTOrvoXFGieBRtzGA9bIinguaFusU2IGypD6uFfLiCxsehFJFUfKGyQC/bPJbt0zEjqZLc4fLQh5zGc3VHtu6QPvXBxDmKnbqOFAIFwm9MQvPisDh2H79J6vRB1oxEeTVEUBalcPEFI7yIbQSTt23uaK7Wull2ZCYcAGQv8YXwgg0exn6pmyG/52VwGS/4XbpFUAd3rucYE0knvC7girEYuvoxz6L0p+IlGlY1EcrGLi7Y4UQPZRi1SIHbKZBvttw9iHLEqCGreKD9aDVECscxxGSEMOc1EQuq7frPHZaM5Dgiect4V/Fvefh7fedORMhZYSIg+R178htVa01hjoiu+7oIf/RtemHKOG9hHwjInuFEK3pNk0032sO/wwRbk/HSXYczsXfHeO1zrPKjO5wD+bRqAL4G7T0b/L1kH1EhLhAwW63Jxg0DNCZuIMisUejhrBUPMJP6EmMqLOR5H77bGMxQBrH8Zzyicwlhy6a3wr6CE98k/hPiSnohnrCT+Hq0eCX6np5XeDqZnWaUBtKDar7VWRRDw6clhgWRu+qKo X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?+GzpecACs/CoD2n5dR71/zzbw2/EWc3G4JLArVhx4VMgsCqoT0WlcSQTGWsw?= =?us-ascii?Q?XcBYRNlyQm7C5aT/FBnFti4fIE8sPLpLTeLN9W8DsCc7WkqghqYp3pzk0fNf?= =?us-ascii?Q?+xKkMN2iSTtioKJSCY6NgI91WMpCSeTEFFx+SswvitCoFOt6NqMgRU1ArWqr?= =?us-ascii?Q?3kGC5Lv77d3iZjcY+K2VbRh52vToTBkcjRfZvshkzFe6YgD9Jz7FRtOZE5/u?= =?us-ascii?Q?qRbXoFrEm6soyzg3aEYv5Nm6sMq1CP03MVsqYiNJIh2X+xTnVVTzsHDNciB3?= =?us-ascii?Q?Mt3BKqq1PJbHtxv/fvb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-ascii?Q?AxopUacgpBXN55YdIjlm3nWJJtGCC1LXy0XAMA=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 53966928-b058-4510-228e-08db507a5da5 X-MS-Exchange-CrossTenant-AuthSource: KL1PR01MB5448.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 10:44:29.5690 (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: TYZPR01MB3791 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 Every PHY chip has a reset pin. the state isn't sure of the PHY before scanning. It is resetting, Scanning phy ID will fail, so deassert reset for the chip ,normal operation. Release the reset pin, because it needs to be registered to the created phy device. Signed-off-by: Yan Wang diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index 1183ef5e203e..8fdf1293f447 100644 --- a/drivers/net/mdio/fwnode_mdio.c +++ b/drivers/net/mdio/fwnode_mdio.c @@ -11,6 +11,7 @@ #include #include #include +#include MODULE_AUTHOR("Calvin Johnson "); MODULE_LICENSE("GPL"); @@ -57,6 +58,32 @@ fwnode_find_mii_timestamper(struct fwnode_handle *fwnode) return register_mii_timestamper(arg.np, arg.args[0]); } +static void fwnode_mdiobus_deassert_reset_phy(struct fwnode_handle *fwnode) +{ + struct device_node *np; + int reset; + int rc; + + np = to_of_node(fwnode); + if (!np) + return; + reset = of_get_named_gpio(np, "reset-gpios", 0); + if (gpio_is_valid(reset)) { + rc = gpio_request(reset, NULL); + if (rc < 0) { + pr_err("The currunt state of the reset pin is %s ", + rc == -EBUSY ? "busy" : "error"); + } else { + gpio_direction_output(reset, 0); + usleep_range(1000, 2000); + gpio_direction_output(reset, 1); + /*Release the reset pin,it needs to be registeredwith the PHY.*/ + gpio_free(reset); + } + } + +} + int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio, struct phy_device *phy, struct fwnode_handle *child, u32 addr) @@ -129,6 +156,8 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, goto clean_pse; } + fwnode_mdiobus_deassert_reset_phy(child); + is_c45 = fwnode_device_is_compatible(child, "ethernet-phy-ieee802.3-c45"); if (is_c45 || fwnode_get_phy_id(child, &phy_id)) phy = get_phy_device(bus, addr, is_c45); -- 2.17.1