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 05615C001DE for ; Tue, 25 Jul 2023 15:43:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1BFFD8679D; Tue, 25 Jul 2023 17:43:49 +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="TeRcv9qH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 86EBB866C1; Tue, 25 Jul 2023 17:43:42 +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 0CD4C867F7 for ; Tue, 25 Jul 2023 17:43:37 +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 [82.76.24.202]) (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 2C7AC6607108; Tue, 25 Jul 2023 16:43:36 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1690299816; bh=SdOgjX7TuK+7764xePqCaCWj0fI8g0hTHA5lpCitXqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TeRcv9qHmwjGV2ziAzG+Y0CKhrY9r4NzTT9GFogNJDaapEZi0ozPM/tpULKPs7DHI +Cxl7jlWaGuc0DBChDjJnXQqMS8FYqHFUtSvwTZ/hENSgg0vurj5dFh0oZppC1Whua HQRytmx0hwGrUEL3AXJisfHGg/55Y9kcGtG3OuRveAcsttxJEWAyVqMTjTCtLENJMS PyiD/HsnYdDWzemM8T91gNnJGItg/Cdc8oF/aRCH+ko0DR1dhZsPHKk0VE6h7cvY6l +HGqDrPJJOypuKbvUlohOiw8rL7uTkQ9AsXm/70ZgU5edfYHr5hwT9Ruyldy6FK/so BE+Wf4mypRvKQ== From: Eugen Hristev To: marex@denx.de Cc: u-boot@lists.denx.de, eugen.hristev@collabora.com, mihai.sain@microchip.com, Sergiu Moga Subject: [PATCH v5 3/3] usb: ohci-at91: Add USB PHY functionality Date: Tue, 25 Jul 2023 18:43:17 +0300 Message-Id: <20230725154317.663337-3-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230725154317.663337-1-eugen.hristev@collabora.com> References: <20230725154317.663337-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 [eugen.hristev@collabora.com: rewrite error paths according to Marek's review] 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] v4->v5: [eugen.hristev@collabora.com: rewrite error paths according to Marek's review] 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..4f4689745896 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) + goto at91_start_clock_err; + + return 0; + +at91_start_clock_err: + 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)) + generic_phy_power_off_bulk(&ohci_at91->phys); + 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