aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea/otg_fsm.c
diff options
context:
space:
mode:
authorLi Jun <B47624@freescale.com>2014-04-08 10:21:13 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 12:02:38 -0400
commitba892fe3203c2222a52ad8c2c6fee8cc7832ebde (patch)
tree99097627e967f17f17ea5ec8b2c6bd485a9e4c53 /drivers/usb/chipidea/otg_fsm.c
parenta34bc8dd0b5d740832e756b175d69473b97887e7 (diff)
ENGR00307558-13 usb: chipidea: otg-fsm: enable low power mode for otg fsm mode.
This patch enables runtime pm support for otg fsm mode. Signed-off-by: Li Jun <b47624@freescale.com>
Diffstat (limited to 'drivers/usb/chipidea/otg_fsm.c')
-rw-r--r--drivers/usb/chipidea/otg_fsm.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 028f7687ad29..630ae7560b75 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -229,6 +229,9 @@ static void ci_otg_add_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
229 return; 229 return;
230 } 230 }
231 231
232 if (list_empty(active_timers))
233 pm_runtime_get(ci->dev);
234
232 timer->count = timer->expires; 235 timer->count = timer->expires;
233 list_add_tail(&timer->list, active_timers); 236 list_add_tail(&timer->list, active_timers);
234 237
@@ -245,17 +248,22 @@ static void ci_otg_del_timer(struct ci_hdrc *ci, enum ci_otg_fsm_timer_index t)
245 struct ci_otg_fsm_timer *tmp_timer, *del_tmp; 248 struct ci_otg_fsm_timer *tmp_timer, *del_tmp;
246 struct ci_otg_fsm_timer *timer = ci->fsm_timer->timer_list[t]; 249 struct ci_otg_fsm_timer *timer = ci->fsm_timer->timer_list[t];
247 struct list_head *active_timers = &ci->fsm_timer->active_timers; 250 struct list_head *active_timers = &ci->fsm_timer->active_timers;
251 int flag = 0;
248 252
249 if (t >= NUM_CI_OTG_FSM_TIMERS) 253 if (t >= NUM_CI_OTG_FSM_TIMERS)
250 return; 254 return;
251 255
252 list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list) 256 list_for_each_entry_safe(tmp_timer, del_tmp, active_timers, list)
253 if (tmp_timer == timer) 257 if (tmp_timer == timer) {
254 list_del(&timer->list); 258 list_del(&timer->list);
259 flag = 1;
260 }
255 261
256 /* Disable 1ms irq if there is no any active timer */ 262 /* Disable 1ms irq if there is no any active timer */
257 if (list_empty(active_timers)) 263 if (list_empty(active_timers) && (flag == 1)) {
258 hw_write_otgsc(ci, OTGSC_1MSIE, 0); 264 hw_write_otgsc(ci, OTGSC_1MSIE, 0);
265 pm_runtime_put(ci->dev);
266 }
259} 267}
260 268
261/* 269/*
@@ -279,8 +287,10 @@ static inline int ci_otg_tick_timer(struct ci_hdrc *ci)
279 } 287 }
280 288
281 /* disable 1ms irq if there is no any timer active */ 289 /* disable 1ms irq if there is no any timer active */
282 if ((expired == 1) && list_empty(active_timers)) 290 if ((expired == 1) && list_empty(active_timers)) {
283 hw_write_otgsc(ci, OTGSC_1MSIE, 0); 291 hw_write_otgsc(ci, OTGSC_1MSIE, 0);
292 pm_runtime_put(ci->dev);
293 }
284 294
285 return expired; 295 return expired;
286} 296}
@@ -605,6 +615,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
605 return 0; 615 return 0;
606 } 616 }
607 617
618 pm_runtime_get_sync(ci->dev);
608 if (otg_statemachine(&ci->fsm)) { 619 if (otg_statemachine(&ci->fsm)) {
609 if (ci->transceiver->state == OTG_STATE_A_IDLE) { 620 if (ci->transceiver->state == OTG_STATE_A_IDLE) {
610 /* 621 /*
@@ -634,6 +645,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci)
634 } 645 }
635 } 646 }
636 } 647 }
648 pm_runtime_put_sync(ci->dev);
637 return 0; 649 return 0;
638} 650}
639 651