From patchwork Fri Jun 7 11:37:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13689757 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 B36BFC27C53 for ; Fri, 7 Jun 2024 11:38:14 +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=SmVQyBeE6kEJgzxxhVxaJYShuz/4mQFZ9fVcHKH2MIQ=; b=MxoiZVks7KZPiK E4J3m+pZDdw9OiDTXS6GfgwYpfZrJJ0MlPf7xMxwQWk0FIjT8H/v8mnK/4JuFnn5e0mQL0hpa5T4C wpj5074agF+kbT70m4R3pqzdgIWRez4Nu3N3liPkufybGGO/rYVm2w0ZIadc7xtltUN7M0yeiS182 qOiawbwlU8lMO2z5Dkf+ph/3UuLhbyndlG28R/if6Dsq8Swp0s8zk1BkoCZS7NT9iQioiHz3svsLt +2+Me8/rMApR2x3/g71pJsXh0aUh3NG1hmyYNn1z6H5UYMj+8qo7omW9lGB4sBeo5vbPk6oVfDvX3 vVEEYv/TmJEnJOe2DhBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFXvC-0000000DmZ4-1lOh; Fri, 07 Jun 2024 11:38:14 +0000 Received: from relmlor2.renesas.com ([210.160.252.172] helo=relmlie6.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFXv8-0000000DmWJ-1Ikf for linux-phy@lists.infradead.org; Fri, 07 Jun 2024 11:38:12 +0000 X-IronPort-AV: E=Sophos;i="6.08,220,1712588400"; d="scan'208";a="211042492" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 07 Jun 2024 20:38:09 +0900 Received: from localhost.localdomain (unknown [10.226.92.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 9242A40071E8; Fri, 7 Jun 2024 20:38:04 +0900 (JST) From: Biju Das To: Yoshihiro Shimoda , Philipp Zabel , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Biju Das , Vinod Koul , Kishon Vijay Abraham I , linux-renesas-soc@vger.kernel.org, linux-phy@lists.infradead.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das Subject: [PATCH RFC v2 3/4] phy: renesas: phy-rcar-gen3-usb2: Control VBUSEN selection Date: Fri, 7 Jun 2024 12:37:44 +0100 Message-Id: <20240607113745.73934-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240607113745.73934-1-biju.das.jz@bp.renesas.com> References: <20240607113745.73934-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240607_043810_551840_2B773927 X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Use regmap provided by the regulator driver to control VBUS for RZ/G2L alike SoCs. Signed-off-by: Biju Das --- v1->v2: * Used regulator driver's regmap to handle VBUS. --- drivers/phy/renesas/phy-rcar-gen3-usb2.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c index fbab6ac0f0d1..90561b6f9597 100644 --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -111,6 +112,7 @@ struct rcar_gen3_chan { struct extcon_dev *extcon; struct rcar_gen3_phy rphys[NUM_OF_PHYS]; struct regulator *vbus; + struct regmap *regmap; struct work_struct work; struct mutex lock; /* protects rphys[...].powered */ enum usb_dr_mode dr_mode; @@ -188,6 +190,10 @@ static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus) dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus); if (ch->soc_no_adp_ctrl) { + if (vbus) + regmap_write(ch->regmap, 0, 0); + else + regmap_write(ch->regmap, 0, 1); vbus_ctrl_reg = USB2_VBCTRL; vbus_ctrl_val = USB2_VBCTRL_VBOUT; } @@ -718,7 +724,8 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]); } - channel->vbus = devm_regulator_get_optional(dev, "vbus"); + channel->vbus = devm_regulator_get(dev, channel->soc_no_adp_ctrl ? + "usb_vbus" : "vbus"); if (IS_ERR(channel->vbus)) { if (PTR_ERR(channel->vbus) == -EPROBE_DEFER) { ret = PTR_ERR(channel->vbus); @@ -727,6 +734,14 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) channel->vbus = NULL; } + if (channel->soc_no_adp_ctrl && channel->vbus) { + channel->regmap = regulator_get_regmap(channel->vbus); + if (IS_ERR(channel->regmap)) { + ret = PTR_ERR(channel->vbus); + goto error; + } + } + platform_set_drvdata(pdev, channel); channel->dev = dev;