Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8400344rwr; Thu, 11 May 2023 00:14:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6TOR3jVKxSx66A02xx/0jl3nX2B4H5YkvosKDSv8EmGt1zlKh0SBDxHd9gZeLwBx45MsAJ X-Received: by 2002:a17:90a:6349:b0:24e:246e:6454 with SMTP id v9-20020a17090a634900b0024e246e6454mr21075030pjs.33.1683789251474; Thu, 11 May 2023 00:14:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683789251; cv=pass; d=google.com; s=arc-20160816; b=xzn5QTMhO7Rkf+j4hqkNQmyTQokU3Z9SZhr/tmJHz2E0gh9gbgmRXGoMLXWX9525+N u7Imw/Ztlos0Q6F78VB5xD5xeyutSRk4vK64mm/KEOjW9qfy9o6iPA4ENQaWD/MOhHQA zldEgQ0hIMaeR1MKeVD57zsAuqvwBx84qTnCIscsKkovACup513UYj/HXz0SkKcdTloA XH0L8EbyGs5uDJL5vnmGlNP8kxzJememnrgV7rKJKsxFCjzj2ok+MbR0XMpABXVcOlaf SpjtlmI+IkdDRdfiIxeqATR+BIWXIj0KYHTiJYqT5WY7BQJyon8icESwBV/yXqVLWaZZ HlGw== 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=zwm3bT0OHUUbgkLF3YHQagTln1G6CZmA+7H01PQWkmk=; b=v9vFYJQ+W/dnyHer0+SPNfY1l7smX9EJG6mw8stUegxjFB4hCkWU1NfSud1iCuDLj0 yInA/8gjHi8vXIeRFUPOYDQg+jy4US23HWWClRabm9t1HGD3OxRsGSc4LXAwC+k4n9UB t2EIuMQZYABDx9w/54n90v+wFR7QiZiNtHPe70sQ/7FgMiON+bOR2FjudgVAyUy+gRAz 5TFAWCPlbhu6WyQLoqh6GjhUEF3SG1lYquDM4Jy7YqfGBR5jxPmFWIaXZN+PLgOtGrj8 BYXean23NNB0oomBzNfoaRp3qW408Za9WMnS8SY79/mAucnxxBzlyfecCrxJeotIO9yP IBpw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=h5wx8J61; 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 x3-20020a170902ec8300b001ab19e023a1si6376340plg.375.2023.05.11.00.13.59; Thu, 11 May 2023 00:14:11 -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=h5wx8J61; 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 S236672AbjEKHAr (ORCPT + 99 others); Thu, 11 May 2023 03:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237230AbjEKHAZ (ORCPT ); Thu, 11 May 2023 03:00:25 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01olkn2021.outbound.protection.outlook.com [40.92.53.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A56DC5265; Wed, 10 May 2023 23:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UeUC1oJ4PUNA9rwJ9pYqBooPhiMhDCxeSx5WIM/Hw50oPgYlseCMd924Nuk93jcbkDVuOEZ+jGcT9lZT8Irqo9RqCXMkCEZR1GOkzt7IBqGBJ1PRyMs/p6EifradB+1KO5a/csPlBU7pD/IiZ7SHqLHXlqtvPqsZRwCLIeEuOKg+peOxZkJNxza7hrAvyGgkkh5bxkg5JovIHCyHLGq+N5ypVoVbck93+abKu8hYuBITHZENnrQIpXbPTdBO+5uxTx03DYvb4K7yZEge9I3eJKgJLH+IyeucvOw3NiIa0THYzfpUwDyXt/bL/jsArI+ZYcadKde7fK8uTt/a6QqV7w== 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=zwm3bT0OHUUbgkLF3YHQagTln1G6CZmA+7H01PQWkmk=; b=hY8kPlQBhjL5/RBwvMgNkOEKdCILIcfGw4UNy0224nOimD+Q9HOKSBzLfpVveN+wpqJIXDQXAmPzxHwPHb3Zv1mWMkj9zTQlVnDJlGvHMA7nC1A081sQZvNtTOGQDpviKG0tFe5VTagJO9lF4/xUcatT4Et1ouX1g8ZGaWYT3zdNTcnEuZ67hphQNqF7udszeSxsoSaCnD5V2Eg+hgg18gnB9ljP15w8+JsbTKOyujsYZoqqZm/8xkUtbnoiNeTaF6UmrOsQchKZdjD440QocLohGer0zzvX3Ywjjcsoo8QQugLLsAQIvFRuevoIlY6G+Bhftfb13OXBDMGe956THQ== 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=zwm3bT0OHUUbgkLF3YHQagTln1G6CZmA+7H01PQWkmk=; b=h5wx8J61Qoa4cRAMFiv8WHrXBgZtgRtKvO1T7aC324y0MWdycD7m48XCTPoQ7bVqcSc0WNiZmrzyaC59IUtde87ZMBAYKeGv/c+sOOAspTVOV95FJrnPddeJqj4P4YZJD2nBcr4ADS6n3BIWY9KteHIMYYoQt/YOs1CYroSGhx/y+JKPXeSAZsV7clnnuuqeskE24aChzqKyjlB1tiUaC4Yr7CAZaiatRXPQYFNbd6ChU6A7IG4Jp7WEQPv4eVc+0k/lUT7rSY7j+P3thLctYXa/LidfmA4Ja0gGcEvwGEB9JvYgEuvp880V/tgix5mOXEHCl+pT0Byuu7PMJblJHg== Received: from KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) by TYZPR01MB4140.apcprd01.prod.exchangelabs.com (2603:1096:400:1c8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.31; Thu, 11 May 2023 06:59:30 +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 06:59:30 +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 v4] net: mdiobus: Add a function to deassert reset Date: Thu, 11 May 2023 14:59:09 +0800 Message-ID: X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-TMN: [HLsnJVlr1CdsThsnyTyvNoBu0cOg29N4] X-ClientProxiedBy: SG2PR01CA0196.apcprd01.prod.exchangelabs.com (2603:1096:4:189::23) To KL1PR01MB5448.apcprd01.prod.exchangelabs.com (2603:1096:820:9a::12) X-Microsoft-Original-Message-ID: <20230511065909.1920-1-rk.code@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR01MB5448:EE_|TYZPR01MB4140:EE_ X-MS-Office365-Filtering-Correlation-Id: 91420bb8-717e-4cb3-7359-08db51ed446b X-MS-Exchange-SLBlob-MailProps: ZILSnhm0P3k2XayEnZ/FXgv66CsfMCS1CpyJ1582nDelJTLmLlEk7YU7wM7TwsPqY6G+1N2g87q67s3q1apWzJrks0oeEDnEi1j81Rp/L+a1/PzPmChWOg54OJMLOIJSuG2zbpjFAyvIhbS4RgguxmE3m6aiflEtgNLbEf8JhxkXrHg3jTUnZ85Y5SvEvK/H5ZpyH6DMnEJkxCQi7GDD/85grEvj3dwaoJ0uTFLD97OS6p+ZW5GZ1pLtFoLtZCHSJ8CX/zrulFeANkG1uTH3gTqsMWSbl54Nq+YUSG949yXhx09EafcQDQJSsUbqGqzyLggYjDkZ9VlBo46WGn931V/OzcDTqgVrKXWK/k440o/bZdyLaus5sgVlhsLc3vo+DRVa9jYtA4WI7lxrJNyPBuvEfMq/uS/okpOgA8a+ooQ1ytkArSCuCjSwinWB0vgDZyCMI16eEwgFBCR8qq6lc73hqd3dyiuiuCA1fpn7AtI1DU8KjJBhbpItUfrglz0CXmuRNaLRsal5FZ2kvCB5S6qDxAg85jKebWlrxK0Ivlv16syVQ/Ei22VBbKP9bpmlNr5GAmWdZWyCgwcWLMHRTV0FkfLgdCOok+7/fsb37Qb8e97sARUvWfLAvSLOcSeR1gniAaW3D7HP0aN+do1d4qTZ6lVaWIfV7UIRVx5TGCvzgpEPIovRiVQnPqYGguc9b/peUNSuTLNmpjS7hn2NIXtl9qi1BY3rTvzGGSEdy6qYVSQlTyAAjlEpiPLeJcaNxV/t+fubGcytDCcMlJ9OUOPhO3OugW6/ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QSmbsbyUP9UWMZ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YITjML9taHj0lQeV+F/Q9LNHsVkg4xzccobcj/CV11N7JDuwu5VL?= =?us-ascii?Q?Du4fildH6XYDm/zVjNisNUY46hA6I344dusUnA=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91420bb8-717e-4cb3-7359-08db51ed446b X-MS-Exchange-CrossTenant-AuthSource: KL1PR01MB5448.apcprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 06:59:30.4051 (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: TYZPR01MB4140 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_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 not be scanned. So,before adding a reset to the scan, make sure the device is in normal working mode. Reported-by: kernel test robot Link: https://lore.kernel.org/oe-kbuild-all/202305101702.4xW6vT72-lkp@intel.com/ Signed-off-by: Yan Wang --- v4: - Get pulse width and settling time from the device tree - Add logic for processing (PTR_ERR(reset) == -EPROBE_DEFER) - included - fixed commit message v3: https://lore.kernel.org/all/KL1PR01MB5448A33A549CDAD7D68945B9E6779@KL1PR01MB5448.apcprd01.prod.exchangelabs.com/ - 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 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index 1183ef5e203e..9d7df6393059 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,35 @@ 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; + unsigned int reset_assert_delay; + unsigned int reset_deassert_delay; + + reset = fwnode_gpiod_get_index(fwnode, "reset", 0, GPIOD_OUT_LOW, NULL); + if (IS_ERR(reset)) { + if (PTR_ERR(reset) == -EPROBE_DEFER) + pr_debug("%pOFn: %s: GPIOs not yet available, retry later\n", + to_of_node(fwnode), __func__); + else + pr_err("%pOFn: %s: Can't get reset line property\n", + to_of_node(fwnode), __func__); + + return; + } + fwnode_property_read_u32(fwnode, "reset-assert-us", + &reset_assert_delay); + fwnode_property_read_u32(fwnode, "reset-deassert-us", + &reset_deassert_delay); + gpiod_set_value_cansleep(reset, 1); + fsleep(reset_assert_delay); + gpiod_set_value_cansleep(reset, 0); + fsleep(reset_deassert_delay); + /*Release phy's reset line, mdiobus_register_gpiod() need to request it*/ + 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 +149,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