linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How do I tell a dual role PHY to always be host or peripheral?
@ 2019-05-03 14:46 Chris Brandt
  0 siblings, 0 replies; only message in thread
From: Chris Brandt @ 2019-05-03 14:46 UTC (permalink / raw)
  To: Rob Herring, devicetree, linux-usb, linux-renesas-soc

I'm preparing patches to add USB support (host and device) for the 
RZ/A2M SoC. The internal HW is similar to the R-Car Gen 3 (USB 2.0, not
USB 3.0).
So I'm reusing drivers/phy/renesas/phy-rcar-gen3-usb2.c

But, I'm not doing OTG, so I need to tell the PHY that it explicitly 
needs to be configured as host or peripheral mode.
The controllers are individual (host or peripheral), but they use the 
same internal PHY.

Looking at:

https://www.kernel.org/doc/Documentation/devicetree/bindings/usb/generic.txt

Technically, I should not add "dr_mode" to the USB controller nodes (and
let the PHY driver check that) because the "controller" is not dual 
role, only PHY is.

I was adding a new property "renesas,is_peripheral" to the 
phy-rcar-gen3-usb2.c PHY driver that it would check if it was not OTG which of course
works.

However, if I look at the PHY dt-bindings of:
  Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
  Documentation/devicetree/bindings/phy/nvidia,tegra20-usb-phy.txt

They are both using the name "dr_mode" in the PHY node.

So, instead of adding something like "renesas,is_peripheral" to the 
current R-Car USB2 PHY driver, can I just use the generic name "dr_mode"?

The PHY driver code change is pretty simple:

	if (channel->is_otg_channel) {
		x x x (existing code today)
+	} else
+		if (usb_get_dr_mode(channel->dev) == USB_DR_MODE_PERIPHERAL)
+			writel(0x80000000, usb2_base + USB2_COMMCTRL);
+		else
+			writel(0x00000000, usb2_base + USB2_COMMCTRL);



I figured I would ask BEFORE I start submitting patches for review.


Thank you,
Chris


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-03 14:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 14:46 How do I tell a dual role PHY to always be host or peripheral? Chris Brandt

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).