From patchwork Fri Feb 19 07:07:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Li X-Patchwork-Id: 1442019 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.a=rsa-sha256 header.s=selector2 header.b=fSavU7KC; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DhjN23FH6z9rx6 for ; Fri, 19 Feb 2021 18:08:18 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DED5C826D4; Fri, 19 Feb 2021 08:08:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="fSavU7KC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 90D75826D4; Fri, 19 Feb 2021 08:08:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.2 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on20605.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1b::605]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 011FB825F5 for ; Fri, 19 Feb 2021 08:08:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ye.li@nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kAF+aDRU4SaKoP54+TWMKiBjl5uZOKGfX42eP1YjtX1oO+JIqcssjkXenl/3XuJuyjvPtWN52r5NLi5JpDGRBaVhcKoW2WWRzREKS9h7YX1sEnQh2aT9026LerDymI0roIkW7uIcoZP9+K2YJ5C9/0hMeSrlklJsKrg8gWpUuy1Vg9c+HKfXvJfHuoaPk2Sy7Eh8cSxfBSIwWfvbNTu8MII3iwdrswCn8Gw70Kel5egIyLOX/pn6xSYZSAiqRCS22K1D82ikHJNrFcP29vc4YrA/UN3uaNwPzQTuC6gRL3OdNMhl6lurrjO7YRLb824NMkzbN8/VX+n6IFAblOlqMQ== 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-SenderADCheck; bh=uWlactlwi2bi2bVN/DVgX2gs49B59ETwuRjW5TmxgUQ=; b=chk7sZ2YP4sfhO6h0ab96WB+gLnhNVO8QwixM1qRdOeIR5LkBLebwrxHdQSmHyuZN87R4GZ9FH0O6FAGBQCGW28rW0ETKQ+g2c6DhO56qr7WPekaSg0EQo2J/s9tDBln25fNPQzzA/+INJ+1jpjwv1K/Z6vHGo9c5H9O2PpkrKnlk3YPuHqaLEa0o8vJLBY3/A2Rz4hFCefXyOcnzQCS91C1cF5OJcV+DVboBr0Hh2pwSTYyoXQJJ8zJG3TaMyxNSCq6ORZh0YzHdCkWDkwc22YSNvvZ6bRMC92zGfWP0vyBg1xfedT2PD123ySLO7mKFY7yIxtgIIPSo2+j+ATBHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uWlactlwi2bi2bVN/DVgX2gs49B59ETwuRjW5TmxgUQ=; b=fSavU7KCLI7X3rGAwqsqM7IzGyFgJlDHdfxrd5Lo1edyRJ4nnHFqIWXC2Ud3i24j+iv2T/cRHPEuztlU0P69V8hnQ2ANw9jA7bRHJNWOOJytdECCNKT+qvCxXJ6yerYVCymTapyqioeQ+bokFqcIlJmiYX/MhKLotSmLUpFwKSc= Authentication-Results: denx.de; dkim=none (message not signed) header.d=none;denx.de; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB4414.eurprd04.prod.outlook.com (2603:10a6:803:69::13) by VI1PR0402MB3565.eurprd04.prod.outlook.com (2603:10a6:803:12::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.31; Fri, 19 Feb 2021 07:08:08 +0000 Received: from VI1PR04MB4414.eurprd04.prod.outlook.com ([fe80::181a:a4dd:a8f8:154e]) by VI1PR04MB4414.eurprd04.prod.outlook.com ([fe80::181a:a4dd:a8f8:154e%6]) with mapi id 15.20.3846.038; Fri, 19 Feb 2021 07:08:08 +0000 From: Ye Li To: sbabic@denx.de, u-boot@lists.denx.de, peng.fan@nxp.com, marex@denx.de Cc: rfried.dev@gmail.com, uboot-imx@nxp.com, s.arendt@sensopart.de Subject: [PATCH 1/9] net: eqos: Add PHY reset control for i.MX platform Date: Thu, 18 Feb 2021 23:07:39 -0800 Message-Id: <1613718467-88336-1-git-send-email-ye.li@nxp.com> X-Mailer: git-send-email 2.7.4 X-Originating-IP: [115.198.227.71] X-ClientProxiedBy: HK0PR03CA0110.apcprd03.prod.outlook.com (2603:1096:203:b0::26) To VI1PR04MB4414.eurprd04.prod.outlook.com (2603:10a6:803:69::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ubuntu.localdomain (115.198.227.71) by HK0PR03CA0110.apcprd03.prod.outlook.com (2603:1096:203:b0::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3868.27 via Frontend Transport; Fri, 19 Feb 2021 07:08:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b67ec073-a90e-4735-097c-08d8d4a51bcb X-MS-TrafficTypeDiagnostic: VI1PR0402MB3565: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:262; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3vDmJAL5EzI+aDGEZCgRRPV/ICeRUwgDxsQ1xQVahBmACldPRmGvq1dFBlOyBM/tSQ1+4ba2fqf+iGiS1w+zJpG4W3fikApqylGZ1+VT77duCGfNPciAYPFYqxskok8uso1rKdDnnXjRVEd/TBYX4ocqUsNXLM1J5XgEdvxOMO1/PwMa35bbldG10VwEnXm5+CHdxeqrtQbs7Q3KkJpPlhWO9XLZ7pdcBR+4A/QlvrAmu+qa1DYimTDtBYVeQq7fMSOOc/lVKzQcgskfrJEiABJT11KZH8e7ShUccJ1L4826jOnEqiGm4bBU5m6Bl9hBM7Ap54PhVsbWsevoFDVzYcx+j3i4QButtz94qRkm0Z6ppEhiOGkwz/w8luLx4Eu9qagOFN5JZTHxbD5Tfe1vFUCRJqlNceXsjNfYPkR+zy96kLVRvqycjOQigJjCkSwBV3RV9QlG8eig0ABcKXg/KNnukAk1L1jOdE9vSJpyUs5bi89bcSuYSiO4aPAbnW3rbGhzV/97VEfmewUcF25YRw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB4414.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(136003)(396003)(366004)(376002)(26005)(83380400001)(6486002)(2906002)(66556008)(6666004)(4326008)(66476007)(5660300002)(316002)(956004)(2616005)(52116002)(8936002)(86362001)(6512007)(186003)(8676002)(16526019)(36756003)(478600001)(6506007)(44832011)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tB1RHT6aM2f+2RTpNgZJsJ7OjarCYLPISToiEhN5j1XOdczhk1WY6rWTguzQnDdwo6FZmziKLSjfZmhg6snrAJOkaQ+WdWWP+1+KrVRx2dlBGUIpvEEeJ4nW5CiL54BG7FXrAkbtjCTS+yh64MtNaiz4w/j+C/bL3g56iJ5PFVBHPjGHwZyDKheVNVCDz4z2d2v36VUiKlfH3J53Q30Lz4fluN0egwF2vK43kH+ZJwb8k6QpIyyfYXUHdWH7Yatw1PWJI1fHZBZ47TBBOVk6loXh2LG4SXJk+L7MbVJO8rPPzwqR3bzkbUbyqpuqzDFbNPnh1pmXk5F/AOa2Dk2vHKvShykeDZ6o03YHiLtE4JJxNBjuwLDqevgMEkXaWlDychBQ04hxlewTETbRDdJL94JybwKigLOOMY9uI0lNn1LP4dESiWaUiqfuI2pymkBBxyvcG98q9PaoaHWfKLHdV2g1Ipq0cAMkGiSHJTO/P9C3v6vW5Oy8yMxPfz4HiMUHbaFTPtnh3mHvEGfyArKE/WQNfKVpyYObiCIxFPXhh/Ndl0bLSLtFUTKQNeti8dc0Fi2NEA5bqISYqOVlLjQ/64EHHBWx1DsMUYzKaITLRYVllhhlIAKVWLx+3D3O8JvmX1tp+aR+bXFLngGG0lXr3Q3nRw1jrV7SbZBq5RRgHSSFonEke5ERFs93/cocuZYzzRP1It3mqI40d3ct97Siuwu7Mo//KuBkZUokfgPnZ+z0ehxccjz6UtX0pW0l6hIIS80DicD/yK+AkiFlWuk9RZZp0w+APtA0d3w36cp+jHVtPxO4psgIM7jQRG/TLuJbxDtBALWzrk69838MMDtkhoW/WJ6mq3NpVP5XuHsmUN1usotEUbKTdy5k6xO4VcM9zXDP7Nio7xQ+ODLdBC5Qj8Gb7SnbtrOP8XwRVyyM87PAqulssfTdOeI/bbDXEP6xiziLigtu52EvYeQW+1Ly/AbF/g6p0c/t9v/SOOVhATxnErasSaKpP/77uFYb1kgYAPmDXHD8NyTuvUWYPlWi+AQGGveOh9CEiwVmWfcb5bA5Xrxa9CvwLcVVGqCh1CncpkWn3iuj3TuZTWiRyySH26VbZqZ25OqG/oB/kNOTh9sN18WlQ3V08B0ZCR896CroxhsEE9meCDOm0JsJPjTugSxBsNlbvPidbvECbV5Nm6OQnrP+Il/xCX0+GO07e5iKb7yyyJTns1sT3drX7QabnsoNoExl3+aAFqHx522bJAAS8K1oQU93wUurzViYLm9vN/u6pSnOmfL8180l6Sgebu72R3DQO8bHrUw4FjPP5ip1lFjBi0gFjc4ejE+KYYnz X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b67ec073-a90e-4735-097c-08d8d4a51bcb X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB4414.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2021 07:08:08.1634 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6ntaRGnbvNjfLq09y3jMGATJ/RcIT7+yuufbgWAr7pBuqsYyXeCydJescsrwyAvP X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3565 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Parse the "phy-reset-gpios", "phy-reset-post-delay" and "phy-reset-duration" properties from eqos node to control the ethernet PHY reset at driver probe. Reset PHY once is enough that can reduce the time cost to get IP after the first time. Signed-off-by: Ye Li --- drivers/net/dwc_eth_qos.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index e8242ca..14aafc6 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -303,6 +303,8 @@ struct eqos_priv { struct eqos_tegra186_regs *tegra186_regs; struct reset_ctl reset_ctl; struct gpio_desc phy_reset_gpio; + uint32_t reset_delay; + uint32_t reset_post_delay; struct clk clk_master_bus; struct clk clk_rx; struct clk clk_ptp_ref; @@ -1880,6 +1882,7 @@ static int eqos_probe_resources_imx(struct udevice *dev) { struct eqos_priv *eqos = dev_get_priv(dev); phy_interface_t interface; + int ret = 0; debug("%s(dev=%p):\n", __func__, dev); @@ -1890,8 +1893,52 @@ static int eqos_probe_resources_imx(struct udevice *dev) return -EINVAL; } + ret = gpio_request_by_name(dev, "phy-reset-gpios", 0, + &eqos->phy_reset_gpio, + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); + if (ret) { + pr_debug("gpio_request_by_name(phy reset) failed: %d", ret); + } + + if (dm_gpio_is_valid(&eqos->phy_reset_gpio)) { + eqos->reset_delay = dev_read_u32_default(dev, "phy-reset-duration", 1); + if (eqos->reset_delay > 1000) { + pr_err("phy reset duration should be <= 1000ms\n"); + /* property value wrong, use default value */ + eqos->reset_delay = 1; + } + + mdelay(eqos->reset_delay); + + eqos->reset_post_delay = dev_read_u32_default(dev, + "phy-reset-post-delay", + 0); + if (eqos->reset_post_delay > 1000) { + pr_err("phy reset post delay should be <= 1000ms\n"); + /* property value wrong, use default value */ + eqos->reset_post_delay = 0; + } + + ret = dm_gpio_set_value(&eqos->phy_reset_gpio, 0); + if (ret < 0) { + pr_err("dm_gpio_set_value(phy_reset, deassert) failed: %d", ret); + goto err_free_gpio_phy_reset; + } + + if (eqos->reset_post_delay) + mdelay(eqos->reset_post_delay); + } + debug("%s: OK\n", __func__); return 0; + +err_free_gpio_phy_reset: + if (dm_gpio_is_valid(&eqos->phy_reset_gpio)) { + dm_gpio_free(dev, &eqos->phy_reset_gpio); + } + + debug("%s: returns %d\n", __func__, ret); + return ret; } static phy_interface_t eqos_get_interface_imx(struct udevice *dev) @@ -1951,6 +1998,14 @@ static int eqos_remove_resources_stm32(struct udevice *dev) static int eqos_remove_resources_imx(struct udevice *dev) { + struct eqos_priv *eqos = dev_get_priv(dev); + + debug("%s(dev=%p):\n", __func__, dev); + if (dm_gpio_is_valid(&eqos->phy_reset_gpio)) { + dm_gpio_free(dev, &eqos->phy_reset_gpio); + } + + debug("%s: OK\n", __func__); return 0; }