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 357ECEB64D8 for ; Thu, 22 Jun 2023 13:08:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3334286374; Thu, 22 Jun 2023 15:08:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.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=collabora.com header.i=@collabora.com header.b="O3VlVda5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 18A1886373; Thu, 22 Jun 2023 15:08:10 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E8E4F86384 for ; Thu, 22 Jun 2023 15:08:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=eugen.hristev@collabora.com Received: from eugen-station.. (unknown [192.166.149.251]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ehristev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 9FBD46607115; Thu, 22 Jun 2023 14:07:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1687439280; bh=MTl5yYflT93MxkHMIT5yyELYMGkRQu9ACtlw87plyvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3VlVda5yzAP/Xhn5Cedw6t3ZGDczSV8P5mgb08GBYkVoXT+cds1R3pIyLx3EWnKu ZwRDEgdOtsBV8nL7Nl55GGfooVSgQmObds3cY3i4eQoyC9rXB2Ynnv4qzGfBTdoIrz FEAXtEW9KSyk2IX+a3PgQEOBwsolDBMEor6SURdSuk3b4P/6ItnBXxgodvG8mIy3MQ iSVmSY3sydetmv5P3iOy4F6SuoGX+9XE2l1yAUg+n4r7t22R3kBffEeukA2a48KUk7 svDIbci9g2QK86LoB4yvGxYgxUrr1cjQkUV43pI5QiS5JkyfdSUIwY8yQRk6Q6NuUI 0gLzy/WBX/CUw== From: Eugen Hristev To: marex@denx.de Cc: u-boot@lists.denx.de, eugen.hristev@collabora.com, Sergiu Moga , Mihai Sain Subject: [PATCH v4 3/3] usb: ohci-at91: Add USB PHY functionality Date: Thu, 22 Jun 2023 16:07:01 +0300 Message-Id: <20230622130701.505234-3-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230622130701.505234-1-eugen.hristev@collabora.com> References: <20230622130701.505234-1-eugen.hristev@collabora.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.8 at phobos.denx.de X-Virus-Status: Clean From: Sergiu Moga Add the ability to enable/disable whatever USB PHY's are passed to the AT91 OHCI driver through DT. Signed-off-by: Sergiu Moga Tested-by: Mihai Sain Reviewed-by: Marek Vasut [eugen.hristev@collabora.com: disable PHYs in at91_start_clock if clk_enable_bulk fails] Signed-off-by: Eugen Hristev --- v1 -> v2: - use *_bulk API's v2 -> v3: - use if (CONFIG_IS_ENABLED(...)) v3 -> v4 [eugen.hristev@collabora.com: disable PHYs in at91_start_clock if clk_enable_bulk fails] drivers/usb/host/ohci-at91.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 92d0ab7184c4..3d4f31d240aa 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c @@ -73,6 +73,7 @@ int usb_cpu_init_fail(void) #include #include #include "ohci.h" +#include #define AT91_MAX_USBH_PORTS 3 @@ -90,15 +91,36 @@ struct at91_usbh_data { struct ohci_at91_priv { ohci_t ohci; struct clk_bulk clks; + struct phy_bulk phys; }; static int at91_start_clock(struct ohci_at91_priv *ohci_at91) { - return clk_enable_bulk(&ohci_at91->clks); + int ret; + + if (CONFIG_IS_ENABLED(PHY_MICROCHIP_SAMA7_USB)) { + ret = generic_phy_power_on_bulk(&ohci_at91->phys); + if (ret) + return ret; + } + + ret = clk_enable_bulk(&ohci_at91->clks); + if (ret) + generic_phy_power_off_bulk(&ohci_at91->phys); + + return ret; } static int at91_stop_clock(struct ohci_at91_priv *ohci_at91) { + if (CONFIG_IS_ENABLED(PHY_MICROCHIP_SAMA7_USB)) { + int ret; + + ret = generic_phy_power_off_bulk(&ohci_at91->phys); + if (ret) + return ret; + } + return clk_disable_bulk(&ohci_at91->clks); } @@ -185,6 +207,16 @@ static int ohci_atmel_probe(struct udevice *dev) if (ret) goto fail; + if (CONFIG_IS_ENABLED(PHY_MICROCHIP_SAMA7_USB)) { + ret = generic_phy_get_bulk(dev, &ohci_at91->phys); + if (ret) + goto fail; + + ret = generic_phy_init_bulk(&ohci_at91->phys); + if (ret) + goto fail; + } + ret = at91_start_hc(dev); if (ret) goto fail; -- 2.34.1