diff options
author | Li Jun <b47624@freescale.com> | 2014-06-28 20:24:28 -0400 |
---|---|---|
committer | Li Jun <B47624@freescale.com> | 2014-06-30 04:37:21 -0400 |
commit | b531c2ed37db29b41d96772418cf6e03b9b35c06 (patch) | |
tree | e12cfa7980d0a77dccdb4a62f98132e3bce65d02 | |
parent | 8624bcec9674554ed2538a3918dd5d4bd2b1e0ce (diff) |
ENGR00320439-5 usb: chipidea: udc: save and restore routine for power lost of udc
Set OP_ENDPTLISTADDR value to be non-zero for power lost check if its value is 0
when suspend. If the controller experienced a power lost in device mode, only
force a disconnection if vbus on, and enable vbus irq.
Signed-off-by: Li Jun <b47624@freescale.com>
-rw-r--r-- | drivers/usb/chipidea/udc.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 85cdeba60fe6..d84aefde1a79 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
@@ -1937,6 +1937,29 @@ static void udc_id_switch_for_host(struct ci_hdrc *ci) | |||
1937 | hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS); | 1937 | hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS); |
1938 | } | 1938 | } |
1939 | 1939 | ||
1940 | static void udc_suspend_for_power_lost(struct ci_hdrc *ci) | ||
1941 | { | ||
1942 | /* | ||
1943 | * Set OP_ENDPTLISTADDR to be non-zero for | ||
1944 | * checking if controller resume from power lost | ||
1945 | * in non-host mode. | ||
1946 | */ | ||
1947 | if (hw_read(ci, OP_ENDPTLISTADDR, ~0) == 0) | ||
1948 | hw_write(ci, OP_ENDPTLISTADDR, ~0, ~0); | ||
1949 | } | ||
1950 | |||
1951 | /* Power lost with device mode */ | ||
1952 | static void udc_resume_from_power_lost(struct ci_hdrc *ci) | ||
1953 | { | ||
1954 | /* Force disconnect if power lost with vbus on */ | ||
1955 | if (ci->vbus_active) | ||
1956 | usb_gadget_vbus_disconnect(&ci->gadget); | ||
1957 | |||
1958 | if (ci->is_otg) | ||
1959 | hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE, | ||
1960 | OTGSC_BSVIS | OTGSC_BSVIE); | ||
1961 | } | ||
1962 | |||
1940 | /** | 1963 | /** |
1941 | * ci_hdrc_gadget_init - initialize device related bits | 1964 | * ci_hdrc_gadget_init - initialize device related bits |
1942 | * ci: the controller | 1965 | * ci: the controller |
@@ -1957,6 +1980,8 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci) | |||
1957 | rdrv->start = udc_id_switch_for_device; | 1980 | rdrv->start = udc_id_switch_for_device; |
1958 | rdrv->stop = udc_id_switch_for_host; | 1981 | rdrv->stop = udc_id_switch_for_host; |
1959 | rdrv->irq = udc_irq; | 1982 | rdrv->irq = udc_irq; |
1983 | rdrv->save = udc_suspend_for_power_lost; | ||
1984 | rdrv->restore = udc_resume_from_power_lost; | ||
1960 | rdrv->name = "gadget"; | 1985 | rdrv->name = "gadget"; |
1961 | ci->roles[CI_ROLE_GADGET] = rdrv; | 1986 | ci->roles[CI_ROLE_GADGET] = rdrv; |
1962 | 1987 | ||