usb: dwc2: override PHY input signals with usb role switch support
authorAmelie Delaunay <amelie.delaunay@st.com>
Tue, 16 Jun 2020 14:07:15 +0000 (16:07 +0200)
committerFelipe Balbi <balbi@kernel.org>
Thu, 23 Jul 2020 11:45:36 +0000 (14:45 +0300)
commitbc0f0d4a5853e32ba97a0318f774570428fc5634
treed48bc675590b36fd79c13208c49bc901a9db34dd
parentc17536d0abde2fd24afca542e3bb73b45a299633
usb: dwc2: override PHY input signals with usb role switch support

This patch adds support for usb role switch to dwc2, by using overriding
control of the PHY voltage valid and ID input signals.

iddig signal (ID) can be overridden:
- when setting GUSBCFG_FORCEHOSTMODE, iddig input pin is overridden with 1;
- when setting GUSBCFG_FORCEDEVMODE, iddig input pin is overridden with 0.

avalid/bvalid/vbusvalid signals can be overridden respectively with:
- GOTGCTL_AVALOEN + GOTGCTL_AVALOVAL
- GOTGCTL_BVALOEN + GOTGCTL_BVALOVAL
- GOTGCTL_VBVALEN + GOTGCTL_VBVALOVAL

It is possible to determine valid sessions thanks to usb role switch:
- if USB_ROLE_NONE then !avalid && !bvalid && !vbusvalid
- if USB_ROLE_DEVICE then !avalid && bvalid && vbusvalid
- if USB_ROLE_HOST then avalid && !bvalid && vbusvalid

Acked-by: Minas Harutyunyan <hminas@synopsys.com>
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/dwc2/Kconfig
drivers/usb/dwc2/Makefile
drivers/usb/dwc2/core.h
drivers/usb/dwc2/drd.c [new file with mode: 0644]
drivers/usb/dwc2/gadget.c
drivers/usb/dwc2/platform.c