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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E9BEAC433EF for ; Sat, 19 Feb 2022 23:10:04 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 46CAE83C79; Sun, 20 Feb 2022 00:09:30 +0100 (CET) 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="K53Pv2tu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EA17383C58; Sun, 20 Feb 2022 00:09:17 +0100 (CET) Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 19BF783C78 for ; Sun, 20 Feb 2022 00:09:08 +0100 (CET) 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-x12f.google.com with SMTP id e11so7336523ils.3 for ; Sat, 19 Feb 2022 15:09:08 -0800 (PST) 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=Q6yrlvRR/s5B07/yeCQ32KphWeQFmGSZticZFBUzwBM=; b=K53Pv2tuSNLzf8eljzSV+9xvjFLJNcC1+E5CNI4cBOY/gd29M6oMpC1sZ7SKDHwxJQ aF/Aku959htK3shDKVBzotb0uPbM3TUWVMg7TKz/uHoRavXvv+V6gSqZ8T/rKaojJ9KE iHQyifObGIbuBANdzn7B2lVGm4TbkdPOXFwN96gnPDvhfFYs3SiyD4k/mtaTT+PVHOHN 2L/AAxRImm1eL/Ts7nOEnebXr98KiNx+GjqHQbXnqLACsokfTdwAZOuMDN5bfubnnDP9 c9Ls1E2MbIzv7sHJHQuh+WIAvBrzj3Lh9DSn6Mat7155ADin2GtVBaMko2e1f4VDIBMy pjfQ== 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=Q6yrlvRR/s5B07/yeCQ32KphWeQFmGSZticZFBUzwBM=; b=zyjlUDgn2bwPeD089IydzKKKe6AVa785LR2HVEV7wvPmt45EqKnAO0dW2NGSbPuFrr Q9SZmmaGRgI9XISzAx59XxB1dTxx0jMjB0v6PcUOxwgPak41rAcvPFJZD0P2BjlsbP7f 2p6Mhwwk6MSZRseYf60cqV7cs8bSAuTckIWjqXMD6Kjj4MytM0TQ3QmGZJdcVc0ytjYg DtIUPUGMLt4QdFu2FTsYcmSw0ffky9PGmTetvpuIWCOXLoA6hp3QHMCUbxfJz+4XSQH5 s61Ny3v/J6hZXbfpAzs+jHzLhJRpsMhpK5EgnOuleUnPVdXlTXDa3HdYVETWrHX9nJ7F 4GjQ== X-Gm-Message-State: AOAM530D3yssU8XPNypydQp5vJZpx/M89DGjY4QsnkT+Pup752PsqFAB enYO6fIruyt//1UoJ+TqS/kThfV2duY6hQ== X-Google-Smtp-Source: ABdhPJxEPxrPcLqnvLLN4wf0c/X/nDdYXbzdUi4DV6S+9I6TAJav3q+oC7NTfd5MizkW/RxgqYAHNg== X-Received: by 2002:a05:6e02:1b87:b0:2c1:a5be:a2d4 with SMTP id h7-20020a056e021b8700b002c1a5bea2d4mr7782174ili.186.1645312146278; Sat, 19 Feb 2022 15:09:06 -0800 (PST) Received: from aford-IdeaCentre-A730.lan ([2601:448:8400:9e8:4655:df85:f9da:7170]) by smtp.gmail.com with ESMTPSA id u12sm5642173ilg.51.2022.02.19.15.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Feb 2022 15:09:05 -0800 (PST) From: Adam Ford To: u-boot@lists.denx.de Cc: marex@denx.de, trini@konsulko.com, woods.technical@gmail.com, Adam Ford Subject: [PATCH 5/7] usb: ehci-omap: Use PHY system to manage phy resets Date: Sat, 19 Feb 2022 17:08:45 -0600 Message-Id: <20220219230847.798484-6-aford173@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220219230847.798484-1-aford173@gmail.com> References: <20220219230847.798484-1-aford173@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 There are a few boards that use hard-coded GPIO definitions in their respective defconfig files. If the GPIO's are listed in their device trees, the nop-phy can toggle the GPIO's, so the EHCI driver does not need to know anything about the GPIO's. Add functions for getting the phys and remove the GPIO toggles since the phy will now do that. Signed-off-by: Adam Ford --- drivers/usb/host/ehci-omap.c | 106 ++++++++++++++++++----------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index 5f79279fe2..765336a3c4 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -128,47 +128,25 @@ 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) +struct ehci_omap_priv_data { + struct ehci_ctrl ctrl; + struct omap_ehci *ehci; +#ifdef CONFIG_DM_REGULATOR + struct udevice *vbus_supply; #endif + enum usb_init_type init_type; + int portnr; + struct phy phy[OMAP_HS_USB_PORTS]; + int nports; +}; /* * Initialize the OMAP EHCI controller and PHY. * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1 * See there for additional Copyrights. */ -static int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata) +static int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata, + struct udevice *dev) { int ret; unsigned int i, reg = 0, rev = 0; @@ -179,8 +157,9 @@ static int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pda if (ret < 0) return ret; - /* Put the PHY in RESET */ - omap_ehci_phy_reset(1, 10); + /* Hold the PHY in RESET for enough time till DIR is high */ + /* Refer: ISSUE1 */ + udelay(10); ret = omap_uhh_reset(); if (ret < 0) @@ -259,7 +238,12 @@ static int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pda if (is_ehci_hsic_mode(usbhs_pdata->port_mode[i])) omap_usbhs_hsic_init(i); - omap_ehci_phy_reset(0, 10); + /* + * Refer ISSUE1: + * Hold the PHY in RESET for enough time till + * PHY is settled and ready + */ + udelay(10); /* * An undocumented "feature" in the OMAP3 EHCI controller, @@ -328,18 +312,6 @@ U_BOOT_DRIVER(usb_omaphs_host) = { .flags = DM_FLAG_ALLOC_PRIV_DMA, }; -struct ehci_omap_priv_data { - struct ehci_ctrl ctrl; - struct omap_ehci *ehci; -#ifdef CONFIG_DM_REGULATOR - struct udevice *vbus_supply; -#endif - enum usb_init_type init_type; - int portnr; - struct phy phy[OMAP_HS_USB_PORTS]; - int nports; -}; - static int ehci_usb_of_to_plat(struct udevice *dev) { struct usb_plat *plat = dev_get_plat(dev); @@ -349,6 +321,26 @@ static int ehci_usb_of_to_plat(struct udevice *dev) return 0; } +/* + * This driver references phys based on the USB port. If + * the port is unused, the corresponding phy is listed as NULL + * which generic_phy_init_bulk treats as an error, so we need + * a custom one that tolerates empty phys + */ +static int omap_ehci_phy_get(struct udevice *dev) +{ + struct ehci_omap_priv_data *priv = dev_get_priv(dev); + int i, ret; + + for (i = 0; i < OMAP_HS_USB_PORTS; i++) { + ret = generic_phy_get_by_index(dev, i, &priv->phy[i]); + if (ret && ret != -ENOENT) + return ret; + }; + + return 0; +}; + static int omap_ehci_probe(struct udevice *dev) { struct usb_plat *plat = dev_get_plat(dev); @@ -364,7 +356,21 @@ static int omap_ehci_probe(struct udevice *dev) hccr = (struct ehci_hccr *)&priv->ehci->hccapbase; hcor = (struct ehci_hcor *)&priv->ehci->usbcmd; - ret = omap_ehci_hcd_init(0, &usbhs_bdata); + /* Identify Phys */ + ret = omap_ehci_phy_get(dev); + if (ret) { + printf("Failed to get phys\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; + } + + ret = omap_ehci_hcd_init(0, &usbhs_bdata, dev); if (ret) return ret; -- 2.32.0