From patchwork Tue Jun 11 11:03:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13693448 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 24800C27C5E for ; Tue, 11 Jun 2024 11:04:29 +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=LJ/Vij/Sfj2tuM0svyyCppQfWf7BcH8w+W2S09x1WO4=; b=41VXRFP0a+erBW 2HJOg8yE6w/OTLpUUqR7kBH1qZIt4/7BBmXWtOexl60YAtlPci5UfPTKJjxGUqlL3YyS850iTyjJf F/0/WLYwq+l5FYAg9gefjyp9AvZTsScNfMEBvH3J2aj1w82/OWGfavaZpTzp/dn9SpQnzwx7KqNB8 SAGeyr/ZCUjFvStQ5zPbA2nIXUGhODwOERBmCMW6/0JW/ofX0izZINlHT20NKYVHJfMY710crhApb HjEr7xK8GDVlula/DhzJz7xhHvE5KwXauh/3klDD4j72q4VUaL+q1hHJi7HM2FbMhZ6KEI+eRo+vo 4rFH9lRc8WtvWLQx3yCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGzIi-00000008ZJw-1nYF; Tue, 11 Jun 2024 11:04:28 +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 1sGzIc-00000008ZEp-0zn2 for linux-phy@lists.infradead.org; Tue, 11 Jun 2024 11:04:26 +0000 X-IronPort-AV: E=Sophos;i="6.08,229,1712588400"; d="scan'208";a="207488186" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Jun 2024 20:04:14 +0900 Received: from localhost.localdomain (unknown [10.226.93.49]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id F170A400F953; Tue, 11 Jun 2024 20:04:09 +0900 (JST) From: Biju Das To: Philipp Zabel , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Biju Das , Liam Girdwood , Mark Brown , Vinod Koul , Kishon Vijay Abraham I , Geert Uytterhoeven , Magnus Damm , devicetree@vger.kernel.org, linux-phy@lists.infradead.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v3 1/6] dt-bindings: reset: renesas,rzg2l-usbphy-ctrl: Document USB VBUS regulator Date: Tue, 11 Jun 2024 12:03:57 +0100 Message-Id: <20240611110402.58104-2-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240611110402.58104-1-biju.das.jz@bp.renesas.com> References: <20240611110402.58104-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-20240611_040422_581347_5D0E3EE2 X-CRM114-Status: UNSURE ( 7.21 ) X-CRM114-Notice: Please train this message. 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 The VBUS enable can be controlled by the VBOUT bit of the VBUS control register. This register is part of usbphy-ctrl IP. Document the USB VBUS regulator object. Signed-off-by: Biju Das --- v3: * New patch --- .../bindings/reset/renesas,rzg2l-usbphy-ctrl.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/reset/renesas,rzg2l-usbphy-ctrl.yaml b/Documentation/devicetree/bindings/reset/renesas,rzg2l-usbphy-ctrl.yaml index 03c18611e42d..cfe479df0f41 100644 --- a/Documentation/devicetree/bindings/reset/renesas,rzg2l-usbphy-ctrl.yaml +++ b/Documentation/devicetree/bindings/reset/renesas,rzg2l-usbphy-ctrl.yaml @@ -42,6 +42,12 @@ properties: 0 = Port 1 Phy reset 1 = Port 2 Phy reset + regulator-vbus: + type: object + description: USB VBUS regulator + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + required: - compatible - reg @@ -49,6 +55,7 @@ required: - resets - power-domains - '#reset-cells' + - regulator-vbus additionalProperties: false @@ -64,4 +71,9 @@ examples: resets = <&cpg R9A07G044_USB_PRESETN>; power-domains = <&cpg>; #reset-cells = <1>; + regulator-vbus { + regulator-name = "vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; }; From patchwork Tue Jun 11 11:03:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13693449 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 D6D22C25B76 for ; Tue, 11 Jun 2024 11:04:30 +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=WOw/+ZXPtbDJcgdQIQsN8y4J4j3T+atIoVrtvxtjl8o=; b=KeAbYvusc46NAq szjZDZYzW32GP0L9nHeH+2rDgVM6QgOXWNg+EX/cU6U+KP7mgegfFqpTtPC0x4yRL4qHDuIgn/Xs6 oJElKQZsU4uCTrPtdtcNqPjPqkBsBH5s17l8RlP4YFN4U+7L2KQlzygrFovmXIUwYu9BZiVGuUifE LqK3usA7XxoRaKzO5j9uvie7g6sVhZYFhnbhMDZ+EKIlSuyhS40JdUiIWySWHFE0JWGmT06yJrm3v BSWkmJsglA0roTqO1F30Iw2ihyt5uCsDXHXxegU9hzeSu01x12g/Ws4PNpK+ZQQXv8Rdjb3WYu/+X LYM/3HSa7EZ4mNKG3/kQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGzIj-00000008ZKe-2Dkr; Tue, 11 Jun 2024 11:04:29 +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 1sGzIc-00000008ZEy-0ziX for linux-phy@lists.infradead.org; Tue, 11 Jun 2024 11:04:26 +0000 X-IronPort-AV: E=Sophos;i="6.08,229,1712588400"; d="scan'208";a="207488191" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Jun 2024 20:04:20 +0900 Received: from localhost.localdomain (unknown [10.226.93.49]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 790A3400F953; Tue, 11 Jun 2024 20:04:15 +0900 (JST) From: Biju Das To: Philipp Zabel Cc: Biju Das , Liam Girdwood , Mark Brown , Vinod Koul , Kishon Vijay Abraham I , 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 v3 2/6] reset: renesas: Add USB VBUS regulator device as child Date: Tue, 11 Jun 2024 12:03:58 +0100 Message-Id: <20240611110402.58104-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240611110402.58104-1-biju.das.jz@bp.renesas.com> References: <20240611110402.58104-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-20240611_040422_642987_A31B7CF7 X-CRM114-Status: GOOD ( 14.80 ) 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 --- 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 | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c index 8f6fbd978591..c740b3b9599d 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), @@ -153,13 +169,34 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev) writel(val, priv->base + RESET); spin_unlock_irqrestore(&priv->lock, flags); + 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); + pm_runtime_disable(&pdev->dev); + reset_control_assert(priv->rstc); + return error; } 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); From patchwork Tue Jun 11 11:03:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13693450 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 F31FCC27C5E for ; Tue, 11 Jun 2024 11:04:31 +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=Riqb+htZ/bFua4tS89LjHRhFUxJSbqu8ue8vGd+SEds=; b=Ga/mBCp37XBTKw u6xpnCNLIbojZfY3o2e/7eraTf8U8hyRgj8DYHEZgwbyCRhNFbZF3ag1DS40JShiP1Lwh6uNT2eWp ogEuM0hLBrDo5s3XkN2JBWD/QV/dn+WSDlDIL3aVluq9bZbVjV48p26FuHtUbKyID6bzBIroQy6vO CVbibvcsTXmemS5S5+v1nkyPIp1uuLGyEgeQYOu/cgzvtR2oxyO0PkZyYbeti0cwK0Onur6qbDatE u+HgtaaXcSDh6Epfh18Mp3rmqlWWewrw6kwym29XwCB0afpJNpd/zSu+zpY+03FNPO4IkRd4ixVmK I1zayHkzZbjsPecE69hQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGzIl-00000008ZMd-2jzG; Tue, 11 Jun 2024 11:04:31 +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 1sGzIh-00000008ZEJ-1GVC for linux-phy@lists.infradead.org; Tue, 11 Jun 2024 11:04:30 +0000 X-IronPort-AV: E=Sophos;i="6.08,229,1712588400"; d="scan'208";a="211446402" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 Jun 2024 20:04:26 +0900 Received: from localhost.localdomain (unknown [10.226.93.49]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id E78E240078D0; Tue, 11 Jun 2024 20:04:20 +0900 (JST) From: Biju Das To: Liam Girdwood , Mark Brown Cc: Biju Das , Philipp Zabel , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J. Wysocki" , Len Brown , Pavel Machek , linux-pm@vger.kernel.org, Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , devicetree@vger.kernel.org, linux-phy@lists.infradead.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v3 3/6] regulator: core: Add helper for allow access to enable register Date: Tue, 11 Jun 2024 12:03:59 +0100 Message-Id: <20240611110402.58104-4-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240611110402.58104-1-biju.das.jz@bp.renesas.com> References: <20240611110402.58104-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-20240611_040427_701445_6F2A21D9 X-CRM114-Status: GOOD ( 12.26 ) 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 Add a helper function that allow regulator consumers to allow low-level enable register access, in order to enable/disable regulator in atomic context. The use-case for RZ/G2L SoC is to enable VBUS selection register based on vbus detection that happens in interrupt context. Signed-off-by: Biju Das --- v3: * New patch. --- Documentation/power/regulator/consumer.rst | 5 ++++ drivers/regulator/core.c | 32 ++++++++++++++++++++++ include/linux/regulator/consumer.h | 8 ++++++ 3 files changed, 45 insertions(+) diff --git a/Documentation/power/regulator/consumer.rst b/Documentation/power/regulator/consumer.rst index 85c2bf5ac07e..b5502f4ffe46 100644 --- a/Documentation/power/regulator/consumer.rst +++ b/Documentation/power/regulator/consumer.rst @@ -227,3 +227,8 @@ directly written to the voltage selector register, use:: int regulator_list_hardware_vsel(struct regulator *regulator, unsigned selector); + +To access the hardware register for enabling/disabling the regulator, use:: + + int regulator_set_hardware_enable_register(struct regulator *regulator, + bool enable); diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 5794f4e9dd52..19df42868bbd 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3407,6 +3407,38 @@ int regulator_list_hardware_vsel(struct regulator *regulator, } EXPORT_SYMBOL_GPL(regulator_list_hardware_vsel); +/** + * regulator_set_hardware_enable_register - set the HW enable register + * @regulator: regulator source + * @enable: true for enable, false for disable + * + * Request that the regulator be enabled/disabled with the regulator output at + * the predefined voltage or current value. + * + * On success 0 is returned, otherwise a negative errno is returned. + */ +int regulator_set_hardware_enable_register(struct regulator *regulator, + bool enable) +{ + struct regulator_dev *rdev = regulator->rdev; + const struct regulator_ops *ops = rdev->desc->ops; + int ret = -EOPNOTSUPP; + + if (!ops) + return ret; + + if (enable) { + if (ops->enable == regulator_enable_regmap) + ret = ops->enable(rdev); + } else { + if (ops->disable == regulator_disable_regmap) + ret = rdev->desc->ops->disable(rdev); + } + + return ret; +} +EXPORT_SYMBOL_GPL(regulator_set_hardware_enable_register); + /** * regulator_get_linear_step - return the voltage step size between VSEL values * @regulator: regulator source diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h index e6f81fc1fb17..4aa5c57de052 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -250,6 +250,8 @@ int regulator_get_hardware_vsel_register(struct regulator *regulator, unsigned *vsel_mask); int regulator_list_hardware_vsel(struct regulator *regulator, unsigned selector); +int regulator_set_hardware_enable_register(struct regulator *regulator, + bool enable); /* regulator notifier block */ int regulator_register_notifier(struct regulator *regulator, @@ -571,6 +573,12 @@ static inline int regulator_list_hardware_vsel(struct regulator *regulator, return -EOPNOTSUPP; } +static inline int regulator_set_hardware_enable_register(struct regulator *regulator, + bool enable) +{ + return -EOPNOTSUPP; +} + static inline int regulator_register_notifier(struct regulator *regulator, struct notifier_block *nb) { From patchwork Tue Jun 11 11:04:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13693451 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 688B0C25B76 for ; Tue, 11 Jun 2024 11:04:42 +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=W1F65XSmNr5vaHqUrf4ShqtQJH2nDLYE6MlFigCfQYo=; b=G2uFiBfVgYu+Md KSbGaB3DIUzDNpt4REKO7LKkdvwJIusP6brjK0j5+2FW0/oa1Svx1/NVhnf4bH/FAJUQGMjo9v9lR fBs8Qw/sdmbquZ4x1iY7vKRzkeRRP00ptXHcnb2hTr4N8VilesobQyh7UpoR4L+orrLrDNE4bUxrA 0bzltI2ZEv6fDQ+bH6O6hs1ijJnPQRYoW5I6pLiAsvUwU3niyA3uCwTKwdD3TmZUYi+IYHEKI9XeK yQQlxEScssQG6ucLsZR7gBN8tww7NYQLSc6g0ko+gnNs/MHsXA63wPpha4kBTKI5/NfvPcZBqxd8t lvTD/w10tbu43JX7QEtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGzIw-00000008ZPL-0BvC; Tue, 11 Jun 2024 11:04:42 +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 1sGzIm-00000008ZMq-3y1I for linux-phy@lists.infradead.org; Tue, 11 Jun 2024 11:04:35 +0000 X-IronPort-AV: E=Sophos;i="6.08,229,1712588400"; d="scan'208";a="207488208" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Jun 2024 20:04:32 +0900 Received: from localhost.localdomain (unknown [10.226.93.49]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 6C7A940078D0; Tue, 11 Jun 2024 20:04:27 +0900 (JST) From: Biju Das To: Liam Girdwood , Mark Brown Cc: Biju Das , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Geert Uytterhoeven , Prabhakar Mahadev Lad , Biju Das , devicetree@vger.kernel.org, linux-phy@lists.infradead.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v3 4/6] regulator: Add Renesas RZ/G2L USB VBUS regulator driver Date: Tue, 11 Jun 2024 12:04:00 +0100 Message-Id: <20240611110402.58104-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240611110402.58104-1-biju.das.jz@bp.renesas.com> References: <20240611110402.58104-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-20240611_040433_134107_44AD9221 X-CRM114-Status: GOOD ( 17.99 ) 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 the RZ/G2L HW manual, VBUSEN can be controlled by the VBOUT bit of the VBUS Control Register. This register is mapped in the reset framework. The reset driver expose this register as regmap and instantiates this driver. The consumer will use the regulator API to control the VBOUT bit as the control need to be done in the atomic context. Signed-off-by: Biju Das --- v2->v3: * Dropped vbus_voltages table * Added support for enabling/disabling regulator through regmap API's * Updated rzg2l_usb_vbus_rdesc with enable_{reg,mask}, fixed_uV and n_voltages * Updated of_node with child node of the parent device. v1->v2: * New patch --- drivers/regulator/Kconfig | 9 +++ drivers/regulator/Makefile | 1 + .../regulator/renesas-usb-vbus-regulator.c | 67 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 drivers/regulator/renesas-usb-vbus-regulator.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index d333be2bea3b..0281a9a6f4ce 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1634,6 +1634,15 @@ config REGULATOR_UNIPHIER help Support for regulators implemented on Socionext UniPhier SoCs. +config REGULATOR_RZG2L_VBCTRL + tristate "Renesas RZ/G2L USB VBUS regulator driver" + depends on ARCH_RZG2L || COMPILE_TEST + depends on OF + select REGMAP_MMIO + default ARCH_RZG2L + help + Support for VBUS regulators implemented on Renesas RZ/G2L SoCs. + config REGULATOR_VCTRL tristate "Voltage controlled regulators" depends on OF diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index ba15fa5f30ad..6127ffb4b011 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -189,6 +189,7 @@ obj-$(CONFIG_REGULATOR_TPS65132) += tps65132-regulator.o obj-$(CONFIG_REGULATOR_TPS68470) += tps68470-regulator.o obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o twl6030-regulator.o obj-$(CONFIG_REGULATOR_UNIPHIER) += uniphier-regulator.o +obj-$(CONFIG_REGULATOR_RZG2L_VBCTRL) += renesas-usb-vbus-regulator.o obj-$(CONFIG_REGULATOR_VCTRL) += vctrl-regulator.o obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress-regulator.o obj-$(CONFIG_REGULATOR_VQMMC_IPQ4019) += vqmmc-ipq4019-regulator.o diff --git a/drivers/regulator/renesas-usb-vbus-regulator.c b/drivers/regulator/renesas-usb-vbus-regulator.c new file mode 100644 index 000000000000..d53e243d25b7 --- /dev/null +++ b/drivers/regulator/renesas-usb-vbus-regulator.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Renesas USB VBUS output regulator driver +// +// Copyright (C) 2024 Renesas Electronics Corporation +// + +#include +#include +#include +#include +#include +#include +#include +#include + +static const struct regulator_ops rzg2l_usb_vbus_reg_ops = { + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, +}; + +static const struct regulator_desc rzg2l_usb_vbus_rdesc = { + .name = "vbus", + .of_match = of_match_ptr("regulator-vbus"), + .ops = &rzg2l_usb_vbus_reg_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .enable_reg = 0, + .enable_mask = BIT(0), + .enable_is_inverted = true, + .fixed_uV = 5000000, + .n_voltages = 1, +}; + +static int rzg2l_usb_vbus_regulator_probe(struct platform_device *pdev) +{ + struct regulator_config config = { }; + struct device *dev = &pdev->dev; + struct regulator_dev *rdev; + + config.regmap = dev_get_regmap(dev->parent, NULL); + if (!config.regmap) + return dev_err_probe(dev, -ENOENT, "Failed to get regmap\n"); + + config.dev = dev; + config.of_node = of_get_child_by_name(dev->parent->of_node, "regulator-vbus"); + rdev = devm_regulator_register(dev, &rzg2l_usb_vbus_rdesc, &config); + if (IS_ERR(rdev)) + return dev_err_probe(dev, PTR_ERR(rdev), + "not able to register vbus regulator\n"); + + return 0; +} + +static struct platform_driver rzg2l_usb_vbus_regulator_driver = { + .probe = rzg2l_usb_vbus_regulator_probe, + .driver = { + .name = "rzg2l-usb-vbus-regulator", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, +}; +module_platform_driver(rzg2l_usb_vbus_regulator_driver); + +MODULE_AUTHOR("Biju Das "); +MODULE_DESCRIPTION("Renesas RZ/G2L USB Vbus Regulator Driver"); +MODULE_LICENSE("GPL"); From patchwork Tue Jun 11 11:04:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13693452 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 E3C4EC27C75 for ; Tue, 11 Jun 2024 11:04:44 +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=06a+zfRvjMMkoA288jJ70lJdDDh1nZo/6wFLm+31j0E=; b=WSr1yxdZGs2JzM rww/TfaXjejWM1ivSS770VKdTEORBsWBU5oE65CAmutetepltuLdC77Rf6PQrJFRtAYI20VgPow0H iEIadheH1YXnS+7tNeOgc1JajyrIo3f0/sXTl+8BBnbw/5tPNCGxvZpiEKBOwOoy76yVddgsgVZ63 p81C86M86SnpgCy0GGr9zGK5vDd0FAWmU/ncuDZHUW8JB0bSRTAhkLl4Ms8RpJorfM8uRESOLT3FX DKZj5IwcwzOh8JlZ81w8CnQGGHK1AfQ4iKyywUmwZ1sB+tDbUF6eWfK82//LgOzOiRYcj7CfiuyuU PPt4g1q43Tz+r+v69vhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGzIy-00000008ZQh-2Ie1; Tue, 11 Jun 2024 11:04:44 +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 1sGzIr-00000008ZMq-3klS for linux-phy@lists.infradead.org; Tue, 11 Jun 2024 11:04:42 +0000 X-IronPort-AV: E=Sophos;i="6.08,229,1712588400"; d="scan'208";a="207488227" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Jun 2024 20:04:37 +0900 Received: from localhost.localdomain (unknown [10.226.93.49]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id A1D6440078D0; Tue, 11 Jun 2024 20:04:32 +0900 (JST) From: Biju Das To: Yoshihiro Shimoda Cc: Biju Das , Philipp Zabel , Liam Girdwood , Mark Brown , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Geert Uytterhoeven devicetree @ vger . kernel . org" , linux-phy@lists.infradead.org, linux-renesas-soc@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v3 5/6] phy: renesas: phy-rcar-gen3-usb2: Control VBUS for RZ/G2L SoCs Date: Tue, 11 Jun 2024 12:04:01 +0100 Message-Id: <20240611110402.58104-6-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240611110402.58104-1-biju.das.jz@bp.renesas.com> References: <20240611110402.58104-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-20240611_040441_394924_84834EC0 X-CRM114-Status: UNSURE ( 8.21 ) X-CRM114-Notice: Please train this message. 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 regulator_set_hardware_enable_register() for controlling VBUS enable for RZ/G2L alike SoCs in interrupt context. Signed-off-by: Biju Das --- v2->v3: * Replaced regulator's regmap API with newly introduced regulator_set_hardware_enable_register to enable/disable regulator in interrupt context. * Dropped using "usb_vbus-supply" v1->v2: * Used regulator driver's regmap to handle VBUS. --- drivers/phy/renesas/phy-rcar-gen3-usb2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c index fbab6ac0f0d1..634b2b058e5f 100644 --- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c +++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c @@ -188,6 +188,9 @@ 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 (ch->vbus) + regulator_set_hardware_enable_register(ch->vbus, vbus); + vbus_ctrl_reg = USB2_VBCTRL; vbus_ctrl_val = USB2_VBCTRL_VBOUT; } From patchwork Tue Jun 11 11:04:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 13693453 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 6E541C25B76 for ; Tue, 11 Jun 2024 11:04:47 +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=sRSs3Qoo3+g6BO/ili1gYpX80MTJ+XHbDCY9l3vE0Kc=; b=P0FWY2POutZ/pU /NjCGzbYlchplaGmjJecUCVqRIHfdQgw307fXRvymZKgW1vWa5oyyG167l304Ar1gFsUa/t0lO6gB D0oKFVuXbL31G64t0HonX0dzcpftotkm3To9ehhT0Xx9yfGzH/XRef+i8xXXDyLVaucCQywdb5eOe rjcfuHXIQuQRVv4HhpszzDtRM82p07flolN9lgJpMc8xr2obFPunPtrCpsVgI2TYGDhrWB88aEpEP FxxDoccc9GdPcA3a6MdPon7sDbF2zP0GnlLw+7LbVF3W8LHsPoNc/035WKffqGNQS2pUKD4xfsN9i 5CaOdMVOrhAm9B9CaNrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGzJ1-00000008ZS6-08ys; Tue, 11 Jun 2024 11:04:47 +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 1sGzIx-00000008ZPe-3pQk for linux-phy@lists.infradead.org; Tue, 11 Jun 2024 11:04:45 +0000 X-IronPort-AV: E=Sophos;i="6.08,229,1712588400"; d="scan'208";a="211446438" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 Jun 2024 20:04:42 +0900 Received: from localhost.localdomain (unknown [10.226.93.49]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id D7C23401007F; Tue, 11 Jun 2024 20:04:37 +0900 (JST) From: Biju Das To: Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Biju Das , Liam Girdwood , Mark Brown , Vinod Koul , Kishon Vijay Abraham I , Geert Uytterhoeven , Magnus Damm , linux-renesas-soc@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, Prabhakar Mahadev Lad , Biju Das Subject: [PATCH v3 6/6] arm64: dts: renesas: rz-smarc: Replace fixed regulator for USB VBUS Date: Tue, 11 Jun 2024 12:04:02 +0100 Message-Id: <20240611110402.58104-7-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240611110402.58104-1-biju.das.jz@bp.renesas.com> References: <20240611110402.58104-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-20240611_040444_175489_40289856 X-CRM114-Status: UNSURE ( 8.68 ) X-CRM114-Notice: Please train this message. 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 Replace the fixed regulator for USB VBUS. Signed-off-by: Biju Das --- v2->v3: * Upated label name * Updated node and regulator name that matches with the bindings. v1->v2: * New patch. --- arch/arm64/boot/dts/renesas/rz-smarc-common.dtsi | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/arm64/boot/dts/renesas/rz-smarc-common.dtsi b/arch/arm64/boot/dts/renesas/rz-smarc-common.dtsi index b7a3e6caa386..a444cb6507d3 100644 --- a/arch/arm64/boot/dts/renesas/rz-smarc-common.dtsi +++ b/arch/arm64/boot/dts/renesas/rz-smarc-common.dtsi @@ -54,14 +54,6 @@ codec_dai: simple-audio-card,codec { }; }; - usb0_vbus_otg: regulator-usb0-vbus-otg { - compatible = "regulator-fixed"; - - regulator-name = "USB0_VBUS_OTG"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - }; - vccq_sdhi1: regulator-vccq-sdhi1 { compatible = "regulator-gpio"; regulator-name = "SDHI1 VccQ"; @@ -139,6 +131,11 @@ &ohci1 { &phyrst { status = "okay"; + usb0_vbus_otg: regulator-vbus { + regulator-name = "vbus"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; }; &scif0 {