Skip to content

Commit d410231

Browse files
Chenhongrenfabiobaltieri
authored andcommitted
usb: it82xx2: enable RESUME interrupt
This commit enables RESUME interrupt mask. Signed-off-by: Ren Chen <[email protected]>
1 parent 9f6b66f commit d410231

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

drivers/usb/device/usb_dc_it82xx2.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,11 @@ static int it82xx2_usb_dc_ip_init(void)
512512
usb_regs->host_device_control = 0;
513513

514514
usb_regs->dc_interrupt_status =
515-
DC_TRANS_DONE | DC_RESET_EVENT | DC_SOF_RECEIVED;
515+
DC_TRANS_DONE | DC_RESET_EVENT | DC_SOF_RECEIVED | DC_RESUME_INT;
516516

517517
usb_regs->dc_interrupt_mask = 0x00;
518518
usb_regs->dc_interrupt_mask =
519-
DC_TRANS_DONE | DC_RESET_EVENT | DC_SOF_RECEIVED;
519+
DC_TRANS_DONE | DC_RESET_EVENT | DC_SOF_RECEIVED | DC_RESUME_INT;
520520

521521
usb_regs->dc_address = DC_ADDR_NULL;
522522

@@ -834,6 +834,17 @@ static void it82xx2_usb_dc_trans_done(void)
834834
}
835835
}
836836

837+
static inline void emit_resume_event(void)
838+
{
839+
if (udata0.suspended) {
840+
udata0.suspended = false;
841+
k_sem_give(&udata0.suspended_sem);
842+
if (udata0.usb_status_cb) {
843+
(*(udata0.usb_status_cb))(USB_DC_RESUME, NULL);
844+
}
845+
}
846+
}
847+
837848
static void it82xx2_usb_dc_isr(void)
838849
{
839850
struct usb_it82xx2_regs *const usb_regs = it82xx2_get_usb_regs();
@@ -855,8 +866,14 @@ static void it82xx2_usb_dc_isr(void)
855866
/* sof received */
856867
if (status & DC_SOF_RECEIVED) {
857868
it82xx2_enable_sof_int(false);
869+
emit_resume_event();
858870
k_work_reschedule(&udata0.check_suspended_work, K_MSEC(5));
859871
}
872+
/* resume received */
873+
if (status & DC_RESUME_INT) {
874+
usb_regs->dc_interrupt_status = DC_RESUME_INT;
875+
emit_resume_event();
876+
}
860877
/* transaction done */
861878
if (status & DC_TRANS_DONE) {
862879
/* clear interrupt before new transaction */
@@ -877,13 +894,6 @@ static void suspended_check_handler(struct k_work *item)
877894

878895
if (usb_regs->dc_interrupt_status & DC_SOF_RECEIVED) {
879896
usb_regs->dc_interrupt_status = DC_SOF_RECEIVED;
880-
if (udata->suspended) {
881-
if (udata->usb_status_cb) {
882-
(*(udata->usb_status_cb))(USB_DC_RESUME, NULL);
883-
}
884-
udata->suspended = false;
885-
k_sem_give(&udata->suspended_sem);
886-
}
887897
k_work_reschedule(&udata->check_suspended_work, K_MSEC(5));
888898
return;
889899
}

0 commit comments

Comments
 (0)