From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 685922D5A0C for ; Tue, 7 Oct 2025 14:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759846426; cv=none; b=m3/3tW00y6a1MMbd3GDxQUf8ryMEsfgL/LtN8YUGi9J29M8FGXJl5tkXIZoVRnPnXxz3qeKL+Ar3GE+hpP6jDxcS5rpsVqH8YhkIktzPM6+vVRI8HiJjF2vi+qKmjxd7nnouFGp+/RCnSe3UlXI/+XVz1nS9tRIbv89cLj+OrSE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759846426; c=relaxed/simple; bh=Uqtt/4tM4AV0md7Ic2QU6kx7zP0JgCxghbEpzs/Y9BQ=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=Ha7uIkeQiB15MGxIHNsKwFwn+M2BsRU1fg5UuCldl9NMIJ0fyIXMfXawE0/7cK73Q/9Jf3WC/ZlgJ19vU09NiYjSujvDaYCMw27xsLfesrKstFmaVZlgGFsvVtIhpuUI4pgtKdUvvlgECejNrF0/tSblzZk/x+hcsGw7vuPwfQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1v68R6-0000Tf-32; Tue, 07 Oct 2025 16:13:04 +0200 Received: from lupine.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::4e] helo=lupine) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v68R4-002Phx-33; Tue, 07 Oct 2025 16:13:02 +0200 Received: from pza by lupine with local (Exim 4.98.2) (envelope-from ) id 1v68R4-000000004MN-3brl; Tue, 07 Oct 2025 16:13:02 +0200 Message-ID: <988658d3485232a0bb6c433b6533ebf0ae41226a.camel@pengutronix.de> Subject: Re: [PATCH 04/18] reset: rzv2h-usb2phy: Set VBENCTL register for OTG mode From: Philipp Zabel To: Biju Das , Tommaso Merciai , Tommaso Merciai Cc: "linux-renesas-soc@vger.kernel.org" , Yoshihiro Shimoda , Vinod Koul , Kishon Vijay Abraham I , Geert Uytterhoeven , "magnus.damm" , Fabrizio Castro , Prabhakar Mahadev Lad , "linux-phy@lists.infradead.org" , "linux-kernel@vger.kernel.org" Date: Tue, 07 Oct 2025 16:13:02 +0200 In-Reply-To: References: <20251001212709.579080-1-tommaso.merciai.xr@bp.renesas.com> <20251001212709.579080-5-tommaso.merciai.xr@bp.renesas.com> <593eb851ae6ce0ec03ddeacf436180b6538fdd1e.camel@pengutronix.de> <01fc3101ab2e3898932afeaaaf060a6676cdf323.camel@pengutronix.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.1-1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Hi Biju, On Di, 2025-10-07 at 11:04 +0000, Biju Das wrote: > Hi Philipp, >=20 > > -----Original Message----- > > From: Philipp Zabel > > Sent: 07 October 2025 10:44 > > Subject: Re: [PATCH 04/18] reset: rzv2h-usb2phy: Set VBENCTL register f= or OTG mode > >=20 > > Hi Biju, > >=20 > > On Di, 2025-10-07 at 04:02 +0000, Biju Das wrote: > > > Hi Philipp, > > >=20 > > > Thanks for the feedback. > > >=20 > > > > -----Original Message----- > > > > From: Philipp Zabel > > > > Sent: 06 October 2025 17:32 > > > > Subject: Re: [PATCH 04/18] reset: rzv2h-usb2phy: Set VBENCTL > > > > register for OTG mode > > > >=20 > > > > On Mi, 2025-10-01 at 23:26 +0200, Tommaso Merciai wrote: > > > > > Add logic to set the VBENCTL register when the USB controller > > > > > operates in OTG mode. This is required to ensure proper USB > > > > > transceiver behavior when the device is configured as OTG. > > > > >=20 > > > > > Signed-off-by: Tommaso Merciai > > > >=20 > > > > I had reservations about this driver before, because of the opaque > > > > register initialization sequence, and I was told that no, this is a= reset driver alright [1]. > > >=20 > > > The latest hardware manual document about VBENCTRL register which set= s source for VBUS selection. > > > s > >=20 > > I still can't look at this, right? The USB2PHY control register space a= ppears to be documented in > > the "RZ/V2H Group User's Manual: Hardware (Additional document)" (under= NDA).=09 >=20 > It is documented here[1], Page 2177, USB2PHY Control Register (USB2m_PHY_= VBENCTL) >=20 > [1] > https://www.renesas.com/en/document/mah/rzg3e-group-users-manual-hardware= ?r=3D25574493 For me, that link points to a document without the USB2m_PHY_* register definitions. Page 2177 is unrelated (documenting PCI_EP_HLOG2_Fn, somewhere in the PCIe interface chapter). > > > > Can you please try to find a proper abstraction for this, because > > > > drivers/reset is not the correct place for USB OTG mode handling. > > >=20 > > > Sorry for the confusion. This driver is not handling USB OTG mode. It > > > just configures VBENCTRL(one time setting) that selects the source fo= r > > > VBUS_SEL. Actual USB OTG mode handling is done USB PHY driver which s= ets host/device mode based on > > ID detection. > >=20 > > So this is a mux for the VBUS_SEL signal? >=20 > Yes, Please find the bit definition. >=20 > 0 VBUS_SEL 0h RW Select VBUSEN control > 0b: Output PP controlled by PORTSC1 register of the Host Controller as VB= USEN. > 1b: Output VBOUT controlled by VBCTRL register of the Host Controller as = VBUSEN. >=20 > We have USB PHY control driver(This driver)-> USB PHY driver->| USB HOST(= Generic ehci/ohci) > | USB function = (renesas usbhs) >=20 > We plan to set 1b for this IP in this driver for OTG channel during probe= . > After that using VBOUT register the PHY driver can switch between Host an= d device. Thank you for the explanation. > > Why don't the USB host controller drivers parse their "dr_mode" > > property themselves and control USB2PHY VBENCTRL via the mux API, for e= xample? >=20 > Currently for OTG channel, based ID detection IRQ, the USB PHY driver swi= tches between host > and device. We use method2 below for the host operation. >=20 > For Host operation: > Method1: USB2m_PHY_VBENCTL.VBUS_SEL=3D0 > or > method2: USB2m_PHY_VBENCTL.VBUS_SEL=3D1 and USB_HOST_VBCTRL.VBOUT =3D 1 >=20 > For device operation: > USB2m_PHY_VBENCTL.VBUS_SEL=3D1 and USB_HOST_VBCTRL.VBOUT =3D 0 >=20 > Are you suggesting to use method1(mux) for host operation? No, not necessarily. I was thinking of letting the PHY driver, before registering the VBOUT controlled VBUS regulator in its probe function, call into the mux API to set VBENCTL.VBUS_SEL=3D1 and thus make the VBOUT bit functional. > Currently this is one time configuration. If we plan to > use mux, then it becomes dynamic. > > How we can we make use of PHY driver using mux API to select the mux regi= ster(VBUS_SEL) > in USB PHY control Driver? For example, this driver could spawn an auxiliary mux device with a driver in drivers/mux that registers a mux for VBENCTL.VBUS_SEL on the &usb20phyrst node. The phy could then get a "mux-states =3D <&usb20phyrst 1>;" property in its device tree node and call the equivalent of: mux_state =3D devm_mux_state_get_optional(dev, NULL); mux_state_select(mux_state); to switch to VBOUT controlled VBUSEN. regards Philipp