usb: dwc2: modify SOF interrupt
authorJianxin Qin <jianxin.qin@amlogic.com>
Wed, 25 Jul 2018 05:43:26 +0000 (13:43 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Thu, 2 Aug 2018 04:30:41 +0000 (21:30 -0700)
PD#170407: usb: dwc2: modify SOF interrupt

SOF interrupt leads to the system overloading, so we reduce the
workload in the SOF interrupt handler.

Change-Id: I6bf11e672e0f024ac4b2da1ba47effe1da1ab476
Signed-off-by: Jianxin Qin <jianxin.qin@amlogic.com>
drivers/amlogic/usb/dwc_otg/310/dwc_otg_cil.h
drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.c
drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c

index d438e47..a58ba8c 100644 (file)
@@ -1061,6 +1061,8 @@ struct dwc_otg_core_if {
        uint32_t phy_interface;
 
        dwc_timer_t *device_connect_timer;
+
+       uint64_t sof_counter;
 };
 
 #ifdef DEBUG
index cb6ae09..a240ef6 100644 (file)
@@ -1161,9 +1161,17 @@ static void sof_timeout(void *ptr)
 {
 #ifdef CONFIG_AMLOGIC_USB3PHY
        dwc_otg_core_if_t *core_if = (dwc_otg_core_if_t *) ptr;
+       dwc_timer_t *timer = core_if->device_connect_timer;
+       static uint64_t sof_cnt_pre;
 
-       if (core_if->phy_interface == 0)
-               set_usb_phy_device_tuning(1, 1);
+       if (core_if->phy_interface == 0) {
+               if (sof_cnt_pre == core_if->sof_counter) {
+                       set_usb_phy_device_tuning(1, 1);
+               } else {
+                       sof_cnt_pre = core_if->sof_counter;
+                       DWC_TIMER_SCHEDULE(timer, 1000);
+               }
+       }
 #endif
 }
 
index 9066ca3..ecfc09b 100644 (file)
@@ -294,19 +294,15 @@ void start_next_request(dwc_otg_pcd_ep_t *ep)
 int32_t dwc_otg_pcd_handle_sof_intr(dwc_otg_pcd_t *pcd)
 {
        dwc_otg_core_if_t *core_if = GET_CORE_IF(pcd);
-
        gintsts_data_t gintsts;
 
        DWC_DEBUGPL(DBG_PCD, "SOF\n");
-       DWC_TIMER_CANCEL(core_if->device_connect_timer);
-
+       core_if->sof_counter++;
        /* Clear interrupt */
        gintsts.d32 = 0;
        gintsts.b.sofintr = 1;
        DWC_WRITE_REG32(&core_if->core_global_regs->gintsts, gintsts.d32);
 
-       DWC_TIMER_SCHEDULE(core_if->device_connect_timer, 10);
-
        return 1;
 }
 
@@ -857,7 +853,7 @@ int32_t dwc_otg_pcd_handle_usb_reset_intr(dwc_otg_pcd_t *pcd)
        DWC_PRINTF("USB RESET\n");
 
        if (core_if->phy_interface == 0)
-               DWC_TIMER_SCHEDULE(core_if->device_connect_timer, 100);
+               DWC_TIMER_SCHEDULE(core_if->device_connect_timer, 1000);
 
 #ifdef DWC_EN_ISOC
        for (i = 1; i < 16; ++i) {