From patchwork Wed Feb 23 15:06:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1596763 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=TRXEdz2+; dkim-atps=neutral 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4K3fXS2hXZz9sG8 for ; Thu, 24 Feb 2022 02:07:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A7F883CA5; Wed, 23 Feb 2022 16:07:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="TRXEdz2+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 08A1683CB0; Wed, 23 Feb 2022 16:07:04 +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.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C5C6F83CA5 for ; Wed, 23 Feb 2022 16:07:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ed1-x530.google.com with SMTP id bq11so23371484edb.2 for ; Wed, 23 Feb 2022 07:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=77nRA+QI/MmpQhEnL/KBhxrIf1XLcCIn/HXPqH8GBac=; b=TRXEdz2+L0H3UAIWQE/7QNyafc35UNFOU3Gs0+OX6C0eJeKx6vnz1X+PB2QLWPk3GI 2q8F4HO3c+5YpEB0zf4aZ9UV5psD7HIHWO2TuXDm3/SOGZenY6LYcsjS9oTEWgg9ksVx SJ7gwpuuNdCxJ6HODpo/1RJrhVQvzhL8gpNcJdU30IR4sL51Pnb8XasCPnGn807KksJK pB0CqPFWViq5vN/7O7VZ4kRdcE8t3MSxrog0ia08kvrgLdEGcH1ZwUpn1lmVaIo9pjoY CwUC1ZPaSsd/hcB0nwcaLQZcV8Lu3+zdBB7CV/7IgIXK05JhAZqLae8x7/uU22uK2nkL Pc9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=77nRA+QI/MmpQhEnL/KBhxrIf1XLcCIn/HXPqH8GBac=; b=ZRe9Wi9VTroqJMb9aEkj8f2arcBZjIbWeR9VzcxN5BAln9CLYMEu0AArgXr/i/6IRE V9Jm5KDcs6d2u0VcADWKx437sc/cEWDpiHpVdLtBXSpIchrdN2JWJKYYvu6qMRcDSm3B AhuHjmjhhFo5s9g+osE/qMK4Y9SBzjlyQ/5vMtbX9vypgOjmhFxevmOcEWKlU9P0gxyt P3XdsvTwZ0FkG4aLvscTD3nKy0mVivBQsgRD/GSNtxvVUliUHDTcsSXE+ZlplUr3/Tx6 TQcCHxgUkWIndj2Qbd6jrKzdO1kosGVshAhVuGuY2tDx3XsJIaXojHYRnpq7Bjz6q2rK 7O5A== X-Gm-Message-State: AOAM532uTN48llLbzWUYEhesClkc3eDqgI2EJgnUfc6NOqCABPLsg2Ee 6KS8CrkKo058pEH50CvIMHHCWF6gVla1Xw== X-Google-Smtp-Source: ABdhPJzcB3G50n5IjFOQfPXultkNlfiZRU7bSqc9mGSb19hauvDNE8Ywvn72mXQBKz40wAcerH9fRA== X-Received: by 2002:a05:6402:2790:b0:412:8379:f248 with SMTP id b16-20020a056402279000b004128379f248mr31822705ede.285.1645628820186; Wed, 23 Feb 2022 07:07:00 -0800 (PST) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id 1sm7507967ejm.186.2022.02.23.07.06.59 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Feb 2022 07:06:59 -0800 (PST) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: T Karthik Reddy , Angus Ainslie , Kunihiko Hayashi , Marek Vasut , Michael Walle , Priyanka Jain , Simon Glass Subject: [PATCH] usb: dwc3: Add support to reset usb ULPI phy Date: Wed, 23 Feb 2022 16:06:58 +0100 Message-Id: X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy When usb PHY initialization is done, the PHY need to be reset. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- drivers/usb/dwc3/Kconfig | 2 +- drivers/usb/dwc3/dwc3-generic.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 62aa65bf0cd2..685bda3729e5 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -25,7 +25,7 @@ config USB_DWC3_OMAP config USB_DWC3_GENERIC bool "Generic implementation of a DWC3 wrapper (aka dwc3 glue)" - depends on DM_USB && USB_DWC3 && MISC + depends on DM_USB && USB_DWC3 && MISC && DM_GPIO help Select this for Xilinx ZynqMP and similar Platforms. This wrapper supports Host and Peripheral operation modes. diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index b1e019b5b91a..17d35a6dc60c 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -25,6 +25,7 @@ #include #include #include +#include struct dwc3_glue_data { struct clk_bulk clks; @@ -42,6 +43,7 @@ struct dwc3_generic_priv { void *base; struct dwc3 dwc3; struct phy_bulk phys; + struct gpio_desc ulpi_reset; }; struct dwc3_generic_host_priv { @@ -77,6 +79,26 @@ static int dwc3_generic_probe(struct udevice *dev, if (rc && rc != -ENOTSUPP) return rc; + if (device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) { + rc = gpio_request_by_name(dev->parent, "reset-gpios", 0, + &priv->ulpi_reset, GPIOD_ACTIVE_LOW); + if (rc != -EBUSY && rc) + return rc; + + /* Toggle ulpi to reset the phy. */ + rc = dm_gpio_set_value(&priv->ulpi_reset, 1); + if (rc) + return rc; + + mdelay(5); + + rc = dm_gpio_set_value(&priv->ulpi_reset, 0); + if (rc) + return rc; + + mdelay(5); + } + if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3")) reset_deassert_bulk(&glue->resets); @@ -98,6 +120,12 @@ static int dwc3_generic_remove(struct udevice *dev, { struct dwc3 *dwc3 = &priv->dwc3; + if (device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) { + struct gpio_desc *ulpi_reset = &priv->ulpi_reset; + + dm_gpio_free(ulpi_reset->dev, ulpi_reset); + } + dwc3_remove(dwc3); dwc3_shutdown_phy(dev, &priv->phys); unmap_physmem(dwc3->regs, MAP_NOCACHE);