linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L
@ 2023-05-18 15:56 Biju Das
  2023-05-18 15:56 ` [PATCH RFC 1/3] reset: Add reset_controller_get_dev() Biju Das
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Biju Das @ 2023-05-18 15:56 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Biju Das, Vinod Koul, Kishon Vijay Abraham I, linux-phy,
	Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc

This patch series aims to add support for VBUSEN selection control for
RZ/G2L alike SoCs.

As per RZ/G2L HW(Rev.1.30 May2023) manual, VBUSEN can be controlled by
the Port Power bit of the EHCI/OHCI operational register or by the VBOUT
bit of the VBUS Control Register.

A reset consumer(phy-rcar-gen3-usb2) needs to find the reset controller
device and then call the provider(reset-rzg2l-usbphy-ctrl) to configure
it.

Please share your thoughts on this patch series.

Biju Das (3):
  reset: Add reset_controller_get_dev()
  reset: renesas: Add rzg2l_usbphy_ctrl_select_vbus_ctrl()
  phy: renesas: phy-rcar-gen3-usb2: Control VBUSEN selection

 drivers/phy/renesas/phy-rcar-gen3-usb2.c |  9 ++++++++
 drivers/reset/core.c                     | 14 ++++++++++++
 drivers/reset/reset-rzg2l-usbphy-ctrl.c  | 27 ++++++++++++++++++++++++
 include/linux/reset-controller.h         |  9 ++++++++
 include/linux/reset/rzg2l-usbphy-ctrl.h  | 16 ++++++++++++++
 5 files changed, 75 insertions(+)
 create mode 100644 include/linux/reset/rzg2l-usbphy-ctrl.h

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH RFC 1/3] reset: Add reset_controller_get_dev()
  2023-05-18 15:56 [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L Biju Das
@ 2023-05-18 15:56 ` Biju Das
  2023-05-18 15:56 ` [PATCH RFC 2/3] reset: renesas: Add rzg2l_usbphy_ctrl_select_vbus_ctrl() Biju Das
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Biju Das @ 2023-05-18 15:56 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Biju Das, Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc

Add support for finding the device associated with the reset controller.

A reset consumer can use this API to find the reset controller device
and then call the corresponding provider device to configure some register.
(eg: As per latest RZ/G2L HW manual Rev 1.30 RZ/G2L USB phy controller
IP exposes a register for vbus control selection)

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/reset/core.c             | 14 ++++++++++++++
 include/linux/reset-controller.h |  9 +++++++++
 2 files changed, 23 insertions(+)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index f0a076e94118..e85d268ada98 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -191,6 +191,20 @@ void reset_controller_add_lookup(struct reset_control_lookup *lookup,
 }
 EXPORT_SYMBOL_GPL(reset_controller_add_lookup);
 
+/**
+ * reset_controller_get_dev - get reset controller device
+ * @rstc: reset controller
+ */
+struct reset_controller_dev *
+reset_controller_get_dev(struct reset_control *rstc)
+{
+	if (!rstc)
+		return NULL;
+
+	return rstc->rcdev;
+}
+EXPORT_SYMBOL_GPL(reset_controller_get_dev);
+
 static inline struct reset_control_array *
 rstc_to_array(struct reset_control *rstc) {
 	return container_of(rstc, struct reset_control_array, base);
diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h
index 0fa4f60e1186..304f79b3eb44 100644
--- a/include/linux/reset-controller.h
+++ b/include/linux/reset-controller.h
@@ -5,6 +5,7 @@
 #include <linux/list.h>
 
 struct reset_controller_dev;
+struct reset_control;
 
 /**
  * struct reset_control_ops - reset controller driver callbacks
@@ -89,6 +90,8 @@ int devm_reset_controller_register(struct device *dev,
 
 void reset_controller_add_lookup(struct reset_control_lookup *lookup,
 				 unsigned int num_entries);
+
+struct reset_controller_dev *reset_controller_get_dev(struct reset_control *rstc);
 #else
 static inline int reset_controller_register(struct reset_controller_dev *rcdev)
 {
@@ -109,6 +112,12 @@ static inline void reset_controller_add_lookup(struct reset_control_lookup *look
 					       unsigned int num_entries)
 {
 }
+
+static inline struct reset_controller_dev *
+reset_controller_get_dev(struct reset_control *rstc)
+{
+	return 0;
+}
 #endif
 
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH RFC 2/3] reset: renesas: Add rzg2l_usbphy_ctrl_select_vbus_ctrl()
  2023-05-18 15:56 [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L Biju Das
  2023-05-18 15:56 ` [PATCH RFC 1/3] reset: Add reset_controller_get_dev() Biju Das
@ 2023-05-18 15:56 ` Biju Das
  2023-05-18 15:56 ` [PATCH RFC 3/3] phy: renesas: phy-rcar-gen3-usb2: Control VBUSEN selection Biju Das
  2024-02-27 12:02 ` [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L Biju Das
  3 siblings, 0 replies; 6+ messages in thread
From: Biju Das @ 2023-05-18 15:56 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: Biju Das, Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc

As per RZ/G2L HW(Rev.1.30 May2023) manual, VBUSEN can be controlled by
the Port Power bit of the EHCI/OHCI operational register or by the VBOUT
bit of the VBUS Control Register. VBUSEN selection is determined by the
VBUSEN control (VBENCTL) register in USBPHY Control.

Add support for VBUSEN selection.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/reset/reset-rzg2l-usbphy-ctrl.c | 27 +++++++++++++++++++++++++
 include/linux/reset/rzg2l-usbphy-ctrl.h | 16 +++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 include/linux/reset/rzg2l-usbphy-ctrl.h

diff --git a/drivers/reset/reset-rzg2l-usbphy-ctrl.c b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
index a8dde4606360..83de261bf460 100644
--- a/drivers/reset/reset-rzg2l-usbphy-ctrl.c
+++ b/drivers/reset/reset-rzg2l-usbphy-ctrl.c
@@ -14,6 +14,7 @@
 #include <linux/reset-controller.h>
 
 #define RESET			0x000
+#define VBENCTL			0x03c
 
 #define RESET_SEL_PLLRESET	BIT(12)
 #define RESET_PLLRESET		BIT(8)
@@ -88,6 +89,32 @@ static int rzg2l_usbphy_ctrl_status(struct reset_controller_dev *rcdev,
 	return !!(readl(priv->base + RESET) & port_mask);
 }
 
+int rzg2l_usbphy_ctrl_select_vbus_ctrl(struct reset_control *rstc, bool vbctrl)
+{
+	struct reset_controller_dev *rcdev = reset_controller_get_dev(rstc);
+	struct rzg2l_usbphy_ctrl_priv *priv;
+	unsigned long flags;
+	u32 val;
+
+	if (!rstc)
+		return 0;
+
+	priv = rcdev_to_priv(rcdev);
+
+	spin_lock_irqsave(&priv->lock, flags);
+	val = readl(priv->base + VBENCTL);
+	if (vbctrl)
+		val |= BIT(0);
+	else
+		val &= ~BIT(0);
+
+	writel(val, priv->base + VBENCTL);
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	return 0;
+}
+EXPORT_SYMBOL(rzg2l_usbphy_ctrl_select_vbus_ctrl);
+
 static const struct of_device_id rzg2l_usbphy_ctrl_match_table[] = {
 	{ .compatible = "renesas,rzg2l-usbphy-ctrl" },
 	{ /* Sentinel */ }
diff --git a/include/linux/reset/rzg2l-usbphy-ctrl.h b/include/linux/reset/rzg2l-usbphy-ctrl.h
new file mode 100644
index 000000000000..c531bd4a6a63
--- /dev/null
+++ b/include/linux/reset/rzg2l-usbphy-ctrl.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_RESET_RZG2L_USBPHY_CTRL_H_
+#define _LINUX_RESET_RZG2L_USBPHY_CTRL_H_
+
+#if IS_ENABLED(CONFIG_RESET_RZG2L_USBPHY_CTRL)
+int rzg2l_usbphy_ctrl_select_vbus_ctrl(struct reset_control *rstc,
+				       bool vbctrl);
+#else
+static inline int
+rzg2l_usbphy_ctrl_select_vbus_ctrl(struct reset_control *rstc, bool vbctrl)
+{
+	return 0;
+}
+#endif
+
+#endif /* _LINUX_RESET_RZG2L_USBPHY_CTRL_H_ */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH RFC 3/3] phy: renesas: phy-rcar-gen3-usb2: Control VBUSEN selection
  2023-05-18 15:56 [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L Biju Das
  2023-05-18 15:56 ` [PATCH RFC 1/3] reset: Add reset_controller_get_dev() Biju Das
  2023-05-18 15:56 ` [PATCH RFC 2/3] reset: renesas: Add rzg2l_usbphy_ctrl_select_vbus_ctrl() Biju Das
@ 2023-05-18 15:56 ` Biju Das
  2024-02-27 12:02 ` [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L Biju Das
  3 siblings, 0 replies; 6+ messages in thread
From: Biju Das @ 2023-05-18 15:56 UTC (permalink / raw)
  To: Yoshihiro Shimoda, Philipp Zabel
  Cc: Biju Das, Vinod Koul, Kishon Vijay Abraham I, linux-renesas-soc,
	linux-phy, Geert Uytterhoeven, Fabrizio Castro

As per RZ/G2L HW(Rev.1.30 May2023) manual, VBUSEN can be controlled by
the Port Power bit of the EHCI/OHCI operational register or by the VBOUT
bit of the VBUS Control Register. Control VBUSEN selection such that bit
is set to 0 (Port Power bit of the EHCI/OHCI operational register) for
host operation and set the bit to 1 (VBOUT bit of the VBUS Control
Register) for device operation.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/phy/renesas/phy-rcar-gen3-usb2.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index d4e2ee7e4efb..429b1d44eee7 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -21,6 +21,8 @@
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
+#include <linux/reset.h>
+#include <linux/reset/rzg2l-usbphy-ctrl.h>
 #include <linux/string.h>
 #include <linux/usb/of.h>
 #include <linux/workqueue.h>
@@ -113,6 +115,7 @@ struct rcar_gen3_chan {
 	struct extcon_dev *extcon;
 	struct rcar_gen3_phy rphys[NUM_OF_PHYS];
 	struct regulator *vbus;
+	struct reset_control *rstc;
 	struct work_struct work;
 	struct mutex lock;	/* protects rphys[...].powered */
 	enum usb_dr_mode dr_mode;
@@ -190,6 +193,7 @@ 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) {
+		rzg2l_usbphy_ctrl_select_vbus_ctrl(ch->rstc, vbus ? 0 : 1);
 		vbus_ctrl_reg = USB2_VBCTRL;
 		vbus_ctrl_val = USB2_VBCTRL_VBOUT;
 	}
@@ -670,6 +674,11 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 	if (IS_ERR(channel->base))
 		return PTR_ERR(channel->base);
 
+	channel->rstc = devm_reset_control_get_optional_shared(&pdev->dev,
+							       NULL);
+	if (IS_ERR(channel->rstc))
+		return PTR_ERR(channel->rstc);
+
 	channel->obint_enable_bits = USB2_OBINT_BITS;
 	/* get irq number here and request_irq for OTG in phy_init */
 	channel->irq = platform_get_irq_optional(pdev, 0);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L
  2023-05-18 15:56 [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L Biju Das
                   ` (2 preceding siblings ...)
  2023-05-18 15:56 ` [PATCH RFC 3/3] phy: renesas: phy-rcar-gen3-usb2: Control VBUSEN selection Biju Das
@ 2024-02-27 12:02 ` Biju Das
  2024-04-15 12:18   ` Biju Das
  3 siblings, 1 reply; 6+ messages in thread
From: Biju Das @ 2024-02-27 12:02 UTC (permalink / raw)
  To: Philipp Zabel, Geert Uytterhoeven
  Cc: Vinod Koul, Kishon Vijay Abraham I, linux-phy,
	Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc

Hi All,

> -----Original Message-----
> From: Biju Das <biju.das.jz@bp.renesas.com>
> Sent: Thursday, May 18, 2023 4:57 PM
> To: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Biju Das <biju.das.jz@bp.renesas.com>; Vinod Koul <vkoul@kernel.org>;
> Kishon Vijay Abraham I <kishon@kernel.org>; linux-phy@lists.infradead.org;
> Geert Uytterhoeven <geert+renesas@glider.be>; Fabrizio Castro
> <fabrizio.castro.jz@renesas.com>; linux-renesas-soc@vger.kernel.org
> Subject: [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L
> 
> This patch series aims to add support for VBUSEN selection control for
> RZ/G2L alike SoCs.
> 
> As per RZ/G2L HW(Rev.1.30 May2023) manual, VBUSEN can be controlled by the
> Port Power bit of the EHCI/OHCI operational register or by the VBOUT bit
> of the VBUS Control Register.
> 
> A reset consumer(phy-rcar-gen3-usb2) needs to find the reset controller
> device and then call the provider(reset-rzg2l-usbphy-ctrl) to configure
> it.
> 
> Please share your thoughts on this patch series.

Gentle ping for this RFC series. Is this series is in the right direction?

Cheers,
Biju

> 
> Biju Das (3):
>   reset: Add reset_controller_get_dev()
>   reset: renesas: Add rzg2l_usbphy_ctrl_select_vbus_ctrl()
>   phy: renesas: phy-rcar-gen3-usb2: Control VBUSEN selection
> 
>  drivers/phy/renesas/phy-rcar-gen3-usb2.c |  9 ++++++++
>  drivers/reset/core.c                     | 14 ++++++++++++
>  drivers/reset/reset-rzg2l-usbphy-ctrl.c  | 27 ++++++++++++++++++++++++
>  include/linux/reset-controller.h         |  9 ++++++++
>  include/linux/reset/rzg2l-usbphy-ctrl.h  | 16 ++++++++++++++
>  5 files changed, 75 insertions(+)
>  create mode 100644 include/linux/reset/rzg2l-usbphy-ctrl.h
> 
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L
  2024-02-27 12:02 ` [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L Biju Das
@ 2024-04-15 12:18   ` Biju Das
  0 siblings, 0 replies; 6+ messages in thread
From: Biju Das @ 2024-04-15 12:18 UTC (permalink / raw)
  To: Philipp Zabel, Geert Uytterhoeven
  Cc: Vinod Koul, Kishon Vijay Abraham I, linux-phy,
	Geert Uytterhoeven, Fabrizio Castro, linux-renesas-soc,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS

Hi All,

What about modelling VBUSEN as a regulator?

USB phy ctrl driver shares the resource to VBUSEN regulator driver
for enable/disable VBUS and PHY driver uses regulator to control the
VBUS??

+ DT as it involves different modelling

Cheers,
Biju

> -----Original Message-----
> From: Biju Das
> Sent: Tuesday, February 27, 2024 12:03 PM
> Subject: RE: [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L
> 
> Hi All,
> 
> > -----Original Message-----
> > From: Biju Das <biju.das.jz@bp.renesas.com>
> > Sent: Thursday, May 18, 2023 4:57 PM
> > To: Philipp Zabel <p.zabel@pengutronix.de>
> > Cc: Biju Das <biju.das.jz@bp.renesas.com>; Vinod Koul
> > <vkoul@kernel.org>; Kishon Vijay Abraham I <kishon@kernel.org>;
> > linux-phy@lists.infradead.org; Geert Uytterhoeven
> > <geert+renesas@glider.be>; Fabrizio Castro
> > <fabrizio.castro.jz@renesas.com>; linux-renesas-soc@vger.kernel.org
> > Subject: [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L
> >
> > This patch series aims to add support for VBUSEN selection control for
> > RZ/G2L alike SoCs.
> >
> > As per RZ/G2L HW(Rev.1.30 May2023) manual, VBUSEN can be controlled by
> > the Port Power bit of the EHCI/OHCI operational register or by the
> > VBOUT bit of the VBUS Control Register.
> >
> > A reset consumer(phy-rcar-gen3-usb2) needs to find the reset
> > controller device and then call the provider(reset-rzg2l-usbphy-ctrl)
> > to configure it.
> >
> > Please share your thoughts on this patch series.
> 
> Gentle ping for this RFC series. Is this series is in the right direction?
> 
> Cheers,
> Biju
> 
> >
> > Biju Das (3):
> >   reset: Add reset_controller_get_dev()
> >   reset: renesas: Add rzg2l_usbphy_ctrl_select_vbus_ctrl()
> >   phy: renesas: phy-rcar-gen3-usb2: Control VBUSEN selection
> >
> >  drivers/phy/renesas/phy-rcar-gen3-usb2.c |  9 ++++++++
> >  drivers/reset/core.c                     | 14 ++++++++++++
> >  drivers/reset/reset-rzg2l-usbphy-ctrl.c  | 27 ++++++++++++++++++++++++
> >  include/linux/reset-controller.h         |  9 ++++++++
> >  include/linux/reset/rzg2l-usbphy-ctrl.h  | 16 ++++++++++++++
> >  5 files changed, 75 insertions(+)
> >  create mode 100644 include/linux/reset/rzg2l-usbphy-ctrl.h
> >
> > --
> > 2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-15 12:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-18 15:56 [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L Biju Das
2023-05-18 15:56 ` [PATCH RFC 1/3] reset: Add reset_controller_get_dev() Biju Das
2023-05-18 15:56 ` [PATCH RFC 2/3] reset: renesas: Add rzg2l_usbphy_ctrl_select_vbus_ctrl() Biju Das
2023-05-18 15:56 ` [PATCH RFC 3/3] phy: renesas: phy-rcar-gen3-usb2: Control VBUSEN selection Biju Das
2024-02-27 12:02 ` [PATCH RFC 0/3] Support VBUSEN selection control for RZ/G2L Biju Das
2024-04-15 12:18   ` Biju Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).