From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36CA1C433F5 for ; Mon, 4 Oct 2021 00:24:53 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5939261269 for ; Mon, 4 Oct 2021 00:24:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5939261269 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DDC6C83498; Mon, 4 Oct 2021 02:24:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NWnvbRxV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2A19683460; Mon, 4 Oct 2021 02:24:30 +0200 (CEST) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 5594B83484 for ; Mon, 4 Oct 2021 02:24:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=aford173@gmail.com Received: by mail-il1-x12e.google.com with SMTP id t11so5984713ilf.11 for ; Sun, 03 Oct 2021 17:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b9XFn01cqFekD9SjSHPh6g9pEnxYIH4F1A0vEF94iTA=; b=NWnvbRxVxemZTc8T/Ypsqs3nDqgB0zqocWzT0DXMAYPUyNvNs7xznucSJvk8SFllCZ +0zSyftTT/QDSMhAdIis8ARnmK+4bI/yZsyAKMAgk6g5YqN2AxkTN6K+68qbheojynzk vthKtLc6GjWVgv5GcdTxQ/mV3X9CEQiUUfExfaJnLPLwC1859SNh4MeHV7oobG8gZd7h +XorZSTbqdWgpL5+uEJIMmlBblj2QeU9GxbSYZgbTn4LrX49QvGrAxOaSLIPHroO92TP 9PuCNC6XmBYoBXRz6baL9nAHyLHq0Zmny0vkV2TwdguBUfBNJAiWjOtICt649cSstM5F jVFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b9XFn01cqFekD9SjSHPh6g9pEnxYIH4F1A0vEF94iTA=; b=D2pKuu27cxpR/m426sj582weOKSxUb9zj33hw5Gb3GLMCs/iQldxjpuXtcAkX+lkgP mDCMN9qFBA1dQpOjGiygOe7NEVoAD+bWg7TaZvUn8ew20W8e8dUh+13TiQCz6EQTfftm leh/4QF392atMRwu5agMU4NwSwT7BtFhbpe2P/wunmBmBKDlvnjuQrQxqOOyWKhS2vCa LKOoLc3EjxTQ5qdRdGXEOpbunqLf7QnlWVGtinXc0uloKbvP99JyJKm1t4rF3O0Qhiy6 3I804cFfJDIEX56YrMGGhNhfddrv0h8WxGVmgsFHQLs/If+uVnW64u0wLF0/MT2lz9Y6 u9jw== X-Gm-Message-State: AOAM533sa+974F5U3VjiDhCk74ukagaNpAS1CW56ZKTfML73dJMqTFNA bdPTmS0BJz/AbMAMlE4KEgyIkL/tjVI= X-Google-Smtp-Source: ABdhPJzAtGkzcsP//7xD2YXZ+bc/czJ0CJBIXPj3T6odxKJ6iZtV8gyb2dSLeRI2ecvo152Rqg7m2Q== X-Received: by 2002:a05:6e02:15c6:: with SMTP id q6mr7715245ilu.221.1633307057425; Sun, 03 Oct 2021 17:24:17 -0700 (PDT) Received: from aford-IdeaCentre-A730.lan ([2601:448:8400:9e8:cc4e:ab52:cc12:32be]) by smtp.gmail.com with ESMTPSA id v14sm4687236iln.23.2021.10.03.17.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 17:24:17 -0700 (PDT) From: Adam Ford To: u-boot@lists.denx.de Cc: lokeshvutla@ti.com, marex@denx.de, sjg@chromium.org, woods.technical@gmail.com, Adam Ford Subject: [RFC 3/3] usb: ehci-omap: Enable phy drivers to enable/reset phy Date: Sun, 3 Oct 2021 19:24:07 -0500 Message-Id: <20211004002407.464910-3-aford173@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211004002407.464910-1-aford173@gmail.com> References: <20211004002407.464910-1-aford173@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean Several omap boards use CONFIG_OMAP_EHCI_PHYx_RESET_GPIO to pull the phy out of reset, when this should really be done inside the phy driver. Add functions to determine which phys are associated the EHCI driver, hold them in reset before EHCI is initialized, initialize the EHCI, then release the phys from reset. Signed-off-by: Adam Ford --- This is an RFC because it hangs when generic_phy_get_bulk is called, and more specifically dev_read_prop is hanging when called by generic_phy_get_bulk. The nop_phy shows before 'usb start' is run. phy 0 [ ] nop_phy |-- hsusb2_phy diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 324d2c0db1..3e707ccef5 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -128,41 +127,6 @@ static void omap_ehci_soft_phy_reset(int port) } #endif -#if defined(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO) || \ - defined(CONFIG_OMAP_EHCI_PHY2_RESET_GPIO) || \ - defined(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO) -/* controls PHY(s) reset signal(s) */ -static inline void omap_ehci_phy_reset(int on, int delay) -{ - /* - * Refer ISSUE1: - * Hold the PHY in RESET for enough time till - * PHY is settled and ready - */ - if (delay && !on) - udelay(delay); -#ifdef CONFIG_OMAP_EHCI_PHY1_RESET_GPIO - gpio_request(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, "USB PHY1 reset"); - gpio_direction_output(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO, !on); -#endif -#ifdef CONFIG_OMAP_EHCI_PHY2_RESET_GPIO - gpio_request(CONFIG_OMAP_EHCI_PHY2_RESET_GPIO, "USB PHY2 reset"); - gpio_direction_output(CONFIG_OMAP_EHCI_PHY2_RESET_GPIO, !on); -#endif -#ifdef CONFIG_OMAP_EHCI_PHY3_RESET_GPIO - gpio_request(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO, "USB PHY3 reset"); - gpio_direction_output(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO, !on); -#endif - - /* Hold the PHY in RESET for enough time till DIR is high */ - /* Refer: ISSUE1 */ - if (delay && on) - udelay(delay); -} -#else -#define omap_ehci_phy_reset(on, delay) do {} while (0) -#endif - /* * Initialize the OMAP EHCI controller and PHY. * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1 @@ -180,9 +144,6 @@ int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata) if (ret < 0) return ret; - /* Put the PHY in RESET */ - omap_ehci_phy_reset(1, 10); - ret = omap_uhh_reset(); if (ret < 0) return ret; @@ -260,8 +221,6 @@ int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata) if (is_ehci_hsic_mode(usbhs_pdata->port_mode[i])) omap_usbhs_hsic_init(i); - omap_ehci_phy_reset(0, 10); - /* * An undocumented "feature" in the OMAP3 EHCI controller, * causes suspended ports to be taken out of suspend when @@ -337,7 +296,7 @@ struct ehci_omap_priv_data { #endif enum usb_init_type init_type; int portnr; - struct phy phy[OMAP_HS_USB_PORTS]; + struct phy_bulk *phys; int nports; }; @@ -356,6 +315,7 @@ static int omap_ehci_probe(struct udevice *dev) struct ehci_omap_priv_data *priv = dev_get_priv(dev); struct ehci_hccr *hccr; struct ehci_hcor *hcor; + int i, ret; priv->ehci = dev_read_addr_ptr(dev); priv->portnr = dev_seq(dev); @@ -364,7 +324,34 @@ static int omap_ehci_probe(struct udevice *dev) hccr = (struct ehci_hccr *)&priv->ehci->hccapbase; hcor = (struct ehci_hcor *)&priv->ehci->usbcmd; - return ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST); + /* Identify Phys */ + ret = generic_phy_get_bulk(dev, priv->phys); + if (ret) { + printf("Failed to get bulk phys\n"); + return ret; + } + + /* Hold Phys in reset */ + for (i = 0; i < priv->phys->count; i++) { + ret = generic_phy_reset(&priv->phys->phys[i]); + if (ret) { + printf("Failed to register EHCI\n"); + return ret; + } + } + + /* Register the EHCI */ + ret = ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST); + if (ret) { + printf("Failed to register EHCI\n"); + return ret; + } + + /* Pull the phys out of reset */ + ret = generic_phy_init_bulk(priv->phys); + if (ret) + printf("Failed to initialize phys\n"); + return ret; } static const struct udevice_id omap_ehci_dt_ids[] = { -- 2.25.1