From d5f0d6596544f65ef9bedbeb20775f3c6b4a7fb7 Mon Sep 17 00:00:00 2001 From: Jianxin Qin Date: Wed, 25 Jul 2018 13:43:26 +0800 Subject: [PATCH] usb: dwc2: modify SOF interrupt 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 --- drivers/amlogic/usb/dwc_otg/310/dwc_otg_cil.h | 2 ++ drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.c | 12 ++++++++++-- drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c | 8 ++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_cil.h b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_cil.h index d438e47582f3..a58ba8cb5d04 100644 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_cil.h +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_cil.h @@ -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 diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.c b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.c index cb6ae0928ec1..a240ef693274 100644 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.c +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd.c @@ -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 } diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c index 9066ca36642e..ecfc09be3ba1 100644 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_pcd_intr.c @@ -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) { -- 2.20.1