From patchwork Tue Jul 2 18:00:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13720125 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 6FBBAC30658 for ; Tue, 2 Jul 2024 18:00:54 +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=3AZ/yQrzKpg0JQAYER6q18ollcqJwn6xspFx0b0uEYI=; b=tuiqwoVPpU/G/t jnnhTkxB/JT2v2ag5CICNyoNP3wPrtptj0f3OuPg7FSojKOisC8etE45N5zvjvP1Qt9SW7EfPCtvV 9WTasgcGvVYMFd5NyZAK5pSo5n+S4tZZ8VUnzN+/SN5hJIaST//jqd6N1QtvGNVDxfMoIams92b6Z jZRnGpZd0O4GST7WlcdxKD4fe249eOcEZbUHKh46Ppio9JW0A09dML3PArBW6BzAxXXNfsK77HOjZ DNDSfs7GMQm5j8SiI08ARa98EX9+2VuHQn7f+RJWmNRF1so1G0c2FrWsejlBIfubXNrX9JmDGCcbX 1P1iQvbmOa8zL0dUer+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOhoE-00000007ZdI-0fj1; Tue, 02 Jul 2024 18:00:54 +0000 Received: from relmlor1.renesas.com ([210.160.252.171] helo=relmlie5.idc.renesas.com) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOhoB-00000007Zbr-0nMe for linux-phy@lists.infradead.org; Tue, 02 Jul 2024 18:00:52 +0000 X-IronPort-AV: E=Sophos;i="6.09,178,1716217200"; d="scan'208";a="210052559" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 03 Jul 2024 03:00:50 +0900 Received: from localhost.localdomain (unknown [10.226.93.72]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 44746400294B; Wed, 3 Jul 2024 03:00:45 +0900 (JST) From: Biju Das To: Philipp Zabel Cc: Biju Das , Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , devicetree@vger.kernel.org, linux-phy@lists.infradead.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v5 2/4] reset: renesas: Add USB VBUS regulator device as child Date: Tue, 2 Jul 2024 19:00:16 +0100 Message-ID: <20240702180032.207275-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240702180032.207275-1-biju.das.jz@bp.renesas.com> References: <20240702180032.207275-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-20240702_110051_359400_D7698CB0 X-CRM114-Status: GOOD ( 14.46 ) 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 As per RZ/G2L HW manual, VBUS enable can be controlled by the VBOUT bit of the VBUS Control Register(VBENCTL) register in the USBPHY Control. Expose this register as regmap and instantiate the USB VBUS regulator device, so that consumer can control the vbus using regulator API's Signed-off-by: Biju Das --- v4->v5: * Rebased and fixed the merge conflicts. v3->v4: * No change. v2->v3: * Updated commit description and header * Moved regulator device creation and instantiation at the end of probe(). v1->v2: * Instantiated regulator driver --- drivers/reset/reset-rzg2l-usbphy-ctrl.c | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c index 29b852a8ac5a..1cd157f4f03b 100644 --- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c +++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c @@ -10,10 +10,12 @@ #include #include #include +#include #include #include #define RESET 0x000 +#define VBENCTL 0x03c #define RESET_SEL_PLLRESET BIT(12) #define RESET_PLLRESET BIT(8) @@ -32,6 +34,7 @@ struct rzg2l_usbphy_ctrl_priv { struct reset_controller_dev rcdev; struct reset_control *rstc; void __iomem *base; + struct platform_device *vdev; spinlock_t lock; }; @@ -100,10 +103,19 @@ static const struct reset_control_ops rzg2l_usbphy_ctrl_reset_ops = { .status = rzg2l_usbphy_ctrl_status, }; +static const struct regmap_config rzg2l_usb_regconf = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, + .max_register = 1, +}; + static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct rzg2l_usbphy_ctrl_priv *priv; + struct platform_device *vdev; + struct regmap *regmap; unsigned long flags; int error; u32 val; @@ -116,6 +128,10 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev) if (IS_ERR(priv->base)) return PTR_ERR(priv->base); + regmap = devm_regmap_init_mmio(dev, priv->base + VBENCTL, &rzg2l_usb_regconf); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (IS_ERR(priv->rstc)) return dev_err_probe(dev, PTR_ERR(priv->rstc), @@ -152,8 +168,22 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev) if (error) goto err_pm_runtime_put; + vdev = platform_device_alloc("rzg2l-usb-vbus-regulator", pdev->id); + if (!vdev) { + error = -ENOMEM; + goto err_pm_runtime_put; + } + vdev->dev.parent = dev; + priv->vdev = vdev; + + error = platform_device_add(vdev); + if (error) + goto err_device_put; + return 0; +err_device_put: + platform_device_put(vdev); err_pm_runtime_put: pm_runtime_put(&pdev->dev); err_pm_disable_reset_deassert: @@ -166,6 +196,7 @@ static void rzg2l_usbphy_ctrl_remove(struct platform_device *pdev) { struct rzg2l_usbphy_ctrl_priv *priv = dev_get_drvdata(&pdev->dev); + platform_device_unregister(priv->vdev); pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); reset_control_assert(priv->rstc);