UPSTREAM: usb: dwc2: Fix dr_mode validation
authorJohn Youn <John.Youn@synopsys.com>
Thu, 17 Dec 2015 19:16:31 +0000 (11:16 -0800)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 10:47:47 +0000 (18:47 +0800)
commit93bbd5118a10954603f7ebff65a90c4bbc29d238
tree485cda17c0a00411c4abb683891e1494a2910636
parent73926bc902527350905eebd91b2215cae57c86c8
UPSTREAM: usb: dwc2: Fix dr_mode validation

The dr_mode parameter was being checked against how the dwc2 module
was being configured at compile time. But it wasn't checked against
the hardware capabilities, nor were the hardware capabilities checked
against the compilation parameters.

This commit adds those checks and adjusts dr_mode to an appropriate
value, if needed. If the hardware capabilities and module compilation
do not match then we fail as it wouldn't be possible to run properly.

The hardware, module, and dr_mode, can each be set to host, device,
or otg. Check that all these values are compatible and adjust the
value of dr_mode if possible.

The following table summarizes the behavior:

                     actual
   HW  MOD dr_mode   dr_mode
 ------------------------------
  HST  HST  any    :  HST
  HST  DEV  any    :  ---
  HST  OTG  any    :  HST

  DEV  HST  any    :  ---
  DEV  DEV  any    :  DEV
  DEV  OTG  any    :  DEV

  OTG  HST  any    :  HST
  OTG  DEV  any    :  DEV
  OTG  OTG  any    :  dr_mode

Change-Id: I46f3925adffdea510366ff5d61c1faa23d8190a3
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 5268ed9d2e3b52f703f3661eef14cecbb2b572d4)
drivers/usb/dwc2/platform.c