OMAP4430: USB Host: Implement workaround for Errata i719
OMAP4430: USB Host: Implement workaround for Errata i719

The OMAP4 EHCI controller has the following defect (errata ID i719):

Title:
HS USB: Multiple OFF Mode Transitions Introduce Corruption

Description:
When the system enters off mode, the save-and-restore (SAR)
        process comes into play. When the save of the USB context
occurs, an extra pulse of UTMI_root clock coming from USB
DPLL is entering the IP, and generates a minor corruption.
This corrupted context is saved and restored later.
This corruption will impact the next use of the USB module:
it could be while resuming a suspended device, or it could
be upon the enumeration of a new device. The exact failure
is not predictable: disconnection or stalls have been observed.
TLL and external PHY modes are impacted.

WORKAROUND:
During ON time, anytime before starting the next save sequence:
• Set the CM_L3INIT_HSUSBHOST_CLKCTRL[1:0] MODULEMODE bit field
  to 0x2 (enabled).
• Wait 1 ms.
• Set the same bit field back to 0x0 (disabled).

All OMAP4430 devices are impacted.
ARM: OMAP4: USB: Update workaround for USB errata i719

ARM: OMAP4: USB: Update workaround for USB errata i719

Due to USB errata i719 the USB host save-and-restore context can be corrupted
if the device enters off mode more than two times without enabling the USB
host controller in between.

The corruption is occuring during the software save of the USB context which
occurs on entry to every off mode attempt. To avoid this problem only save the
USB context if the USB host controller has been enabled since the previous off
mode attempt. We do not need to save the USB context on every entry to off mode
if the USB controller has not been enabled.

Change-Id: I67e07963679af6494ef289eb10db09c0162d6f00
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Signed-off-by: Volodymyr Riazantsev <v.riazantsev@ti.com>
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
usb: ehci: fix the host wakeup state machine and fix the overall USB host logic

Current code enables host clocks and disables immediately
which can have side effects if port status change is not propagated
and clocks are cut, so enable clocks if ports are suspended
in all wakeup paths either from io-pad wakeup or through
bus resume in suspend path.
ARM: OMAP: HS USB Host: fix unbalanced pm calls

ARM: OMAP: HS USB Host: fix unbalanced pm calls

There is an issue with unbalanced pm calls.
Only EHCI or only OHCI works good but not together.
Issue appears when OHCI suspends whereas EHCI is active
or vice versa - anyway all HSUSBHOST goes to suspend.
This patch fixes this issue.