From patchwork Mon May 22 17:03:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 13250894 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 615C9C77B75 for ; Mon, 22 May 2023 17:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=H6hl9EDJ+WEf2afsSeM2G+PftYLv9z+6VUnYPcN+OIo=; b=ak+PrD3V6oaSOo +nIqC2jPoPcZkE/5srJM/m/+wBC8c2chywc/zhKUSGUXqMLME1beJmB0t0XebLaLB7trh+BWnKqoq roo6HDE65314gzrgaJzbk5wm5qxK3p9TqAylBBp9rLW8p/gsV8Dvn44hv2g1PMgjusdRL7RIM5djF 8uth8/eAwNCE6jeibCHuJJrLxLDBe8S6dE07I7BHcGeTAxwxvdWadoVHZWp7F9BUF4uP+ql0SnOr1 duKqlK+hmmrMB82XZF3UKFCxEL0ebb3e4YglrSuwGuvR72cShlI/QcG+uboeJF8+zY/zgIrCaQOC5 uRLnfCQTenPGZwFcwxUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q18x1-007IQg-0L; Mon, 22 May 2023 17:04:03 +0000 Received: from madras.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e5ab]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q18wl-007IHf-1N; Mon, 22 May 2023 17:03:50 +0000 Received: from jupiter.universe (dyndsl-091-248-208-162.ewe-ip-backbone.de [91.248.208.162]) (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) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id E81F76606E69; Mon, 22 May 2023 18:03:42 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684775023; bh=O4ESAX1oWkZABPepXOkCKY7w4k1fSpZvKClJj0JDRNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AISvuS2BSnXpHERZfMru4pssu3VeuPPykVBFscd4PkG8VwQf9aMKyEdMsOmlo9+C6 juowKS4HCBlXa2WLmnv0SCnZjS6rJ2g/q6SfJ36E7rFS2t+W9cNr0B9nJG/uCIcuAW 5CfwBBNggFiGuaKRsyk2bTjK7oYVUfXQmGwj7NJBUR/Mig71w0EdaV30iolLCnAKOg h62GjIeGetDj4RUa9RJmzaGtrC1GF44Zk5QhB5VSQEbzCTZr84ZpQmFeWgmjDEy1PW 5lXLeQNXKO+99+IN0UZa/BPbWSiy10VQ7LZwM3zpZB/c6wc2Clzk/163qV3PtM3Uvm ekZGfqxxAZuYg== Received: by jupiter.universe (Postfix, from userid 1000) id 7C96C4807E2; Mon, 22 May 2023 19:03:40 +0200 (CEST) From: Sebastian Reichel To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski Cc: Heiko Stuebner , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCH v3 3/7] phy: phy-rockchip-inno-usb2: add reset support Date: Mon, 22 May 2023 19:03:20 +0200 Message-Id: <20230522170324.61349-4-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230522170324.61349-1-sebastian.reichel@collabora.com> References: <20230522170324.61349-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230522_100347_622076_8CDF5076 X-CRM114-Status: GOOD ( 15.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add reset handling support, which is needed for proper operation with RK3588. Signed-off-by: Sebastian Reichel --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 2c4683c67a8e..101b46939f0b 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -223,6 +224,7 @@ struct rockchip_usb2phy_port { * @clk: clock struct of phy input clk. * @clk480m: clock struct of phy output clk. * @clk480m_hw: clock struct of phy output clk management. + * @phy_reset: phy reset control. * @chg_state: states involved in USB charger detection. * @chg_type: USB charger types. * @dcd_retries: The retry count used to track Data contact @@ -239,6 +241,7 @@ struct rockchip_usb2phy { struct clk *clk; struct clk *clk480m; struct clk_hw clk480m_hw; + struct reset_control *phy_reset; enum usb_chg_state chg_state; enum power_supply_type chg_type; u8 dcd_retries; @@ -280,6 +283,25 @@ static inline bool property_enabled(struct regmap *base, return tmp != reg->disable; } +static int rockchip_usb2phy_reset(struct rockchip_usb2phy *rphy) +{ + int ret; + + ret = reset_control_assert(rphy->phy_reset); + if (ret) + return ret; + + udelay(10); + + ret = reset_control_deassert(rphy->phy_reset); + if (ret) + return ret; + + usleep_range(100, 200); + + return 0; +} + static int rockchip_usb2phy_clk480m_prepare(struct clk_hw *hw) { struct rockchip_usb2phy *rphy = @@ -534,6 +556,18 @@ static int rockchip_usb2phy_power_on(struct phy *phy) return ret; } + /* + * For rk3588, it needs to reset phy when exit from + * suspend mode with common_on_n 1'b1(aka REFCLK_LOGIC, + * Bias, and PLL blocks are powered down) for lower + * power consumption. If you don't want to reset phy, + * please keep the common_on_n 1'b0 to set these blocks + * remain powered. + */ + ret = rockchip_usb2phy_reset(rphy); + if (ret) + return ret; + /* waiting for the utmi_clk to become stable */ usleep_range(1500, 2000); @@ -1348,6 +1382,10 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) return -EINVAL; } + rphy->phy_reset = devm_reset_control_get_optional(dev, "phy"); + if (IS_ERR(rphy->phy_reset)) + return PTR_ERR(rphy->phy_reset); + rphy->clk = of_clk_get_by_name(np, "phyclk"); if (!IS_ERR(rphy->clk)) { clk_prepare_enable(rphy->clk);