How do I tell a dual role PHY to always be host or peripheral?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux