Lines Matching +full:hnp +full:- +full:disable

1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
3 * core_intr.c - DesignWare HS OTG Controller common interrupt handling
5 * Copyright (C) 2004-2013 Synopsys, Inc.
16 #include <linux/dma-mapping.h>
29 switch (hsotg->op_state) { in dwc2_op_state_str()
46 * dwc2_handle_usb_port_intr - handles OTG PRTINT interrupts.
63 * dwc2_handle_mode_mismatch_intr() - Logs a mode mismatch warning message
72 dev_warn(hsotg->dev, "Mode Mismatch Interrupt: currently in %s mode\n", in dwc2_handle_mode_mismatch_intr()
77 * dwc2_handle_otg_intr() - Handles the OTG Interrupts. It reads the OTG
91 dev_dbg(hsotg->dev, "++OTG Interrupt gotgint=%0x [%s]\n", gotgint, in dwc2_handle_otg_intr()
95 dev_dbg(hsotg->dev, in dwc2_handle_otg_intr()
101 if (hsotg->params.eusb2_disc) { in dwc2_handle_otg_intr()
117 if (hsotg->op_state == OTG_STATE_B_HOST) { in dwc2_handle_otg_intr()
118 hsotg->op_state = OTG_STATE_B_PERIPHERAL; in dwc2_handle_otg_intr()
121 * If not B_HOST and Device HNP still set, HNP did in dwc2_handle_otg_intr()
125 dev_dbg(hsotg->dev, "Session End Detected\n"); in dwc2_handle_otg_intr()
126 dev_err(hsotg->dev, in dwc2_handle_otg_intr()
131 * If Session End Detected the B-Cable has been in dwc2_handle_otg_intr()
135 hsotg->lx_state = DWC2_L3; in dwc2_handle_otg_intr()
144 dev_dbg(hsotg->dev, in dwc2_handle_otg_intr()
148 if (hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS && in dwc2_handle_otg_intr()
149 hsotg->params.i2c_enable) { in dwc2_handle_otg_intr()
150 hsotg->srp_success = 1; in dwc2_handle_otg_intr()
162 * Print statements during the HNP interrupt handling in dwc2_handle_otg_intr()
167 * WA for 3.00a- HW is not setting cur_mode, even sometimes in dwc2_handle_otg_intr()
170 if (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a) in dwc2_handle_otg_intr()
174 hsotg->op_state = OTG_STATE_B_HOST; in dwc2_handle_otg_intr()
176 * Need to disable SOF interrupt immediately. in dwc2_handle_otg_intr()
193 spin_unlock(&hsotg->lock); in dwc2_handle_otg_intr()
197 spin_lock(&hsotg->lock); in dwc2_handle_otg_intr()
198 hsotg->op_state = OTG_STATE_B_HOST; in dwc2_handle_otg_intr()
204 dev_dbg(hsotg->dev, "HNP Failed\n"); in dwc2_handle_otg_intr()
205 dev_err(hsotg->dev, in dwc2_handle_otg_intr()
217 dev_dbg(hsotg->dev, in dwc2_handle_otg_intr()
221 dev_dbg(hsotg->dev, "a_suspend->a_peripheral (%d)\n", in dwc2_handle_otg_intr()
222 hsotg->op_state); in dwc2_handle_otg_intr()
223 spin_unlock(&hsotg->lock); in dwc2_handle_otg_intr()
225 spin_lock(&hsotg->lock); in dwc2_handle_otg_intr()
226 hsotg->op_state = OTG_STATE_A_PERIPHERAL; in dwc2_handle_otg_intr()
228 /* Need to disable SOF interrupt immediately */ in dwc2_handle_otg_intr()
232 spin_unlock(&hsotg->lock); in dwc2_handle_otg_intr()
234 spin_lock(&hsotg->lock); in dwc2_handle_otg_intr()
235 hsotg->op_state = OTG_STATE_A_HOST; in dwc2_handle_otg_intr()
240 dev_dbg(hsotg->dev, in dwc2_handle_otg_intr()
241 " ++OTG Interrupt: A-Device Timeout Change++\n"); in dwc2_handle_otg_intr()
243 dev_dbg(hsotg->dev, " ++OTG Interrupt: Debounce Done++\n"); in dwc2_handle_otg_intr()
250 * dwc2_handle_conn_id_status_change_intr() - Handles the Connector ID Status
266 /* Need to disable SOF interrupt immediately */ in dwc2_handle_conn_id_status_change_intr()
271 dev_dbg(hsotg->dev, " ++Connector ID Status Change Interrupt++ (%s)\n", in dwc2_handle_conn_id_status_change_intr()
277 if (hsotg->wq_otg) in dwc2_handle_conn_id_status_change_intr()
278 queue_work(hsotg->wq_otg, &hsotg->wf_otg); in dwc2_handle_conn_id_status_change_intr()
282 * dwc2_handle_session_req_intr() - This interrupt indicates that a device is
300 dev_dbg(hsotg->dev, "Session request interrupt - lx_state=%d\n", in dwc2_handle_session_req_intr()
301 hsotg->lx_state); in dwc2_handle_session_req_intr()
304 if (hsotg->lx_state != DWC2_L0) { in dwc2_handle_session_req_intr()
305 if (hsotg->in_ppd) { in dwc2_handle_session_req_intr()
309 dev_err(hsotg->dev, in dwc2_handle_session_req_intr()
314 if (hsotg->params.power_down == in dwc2_handle_session_req_intr()
315 DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && in dwc2_handle_session_req_intr()
316 !hsotg->params.no_clock_gating) in dwc2_handle_session_req_intr()
336 * dwc2_wakeup_from_lpm_l1 - Exit the device from LPM L1 state
347 if (hsotg->lx_state != DWC2_L1) { in dwc2_wakeup_from_lpm_l1()
348 dev_err(hsotg->dev, "Core isn't in DWC2_L1 state\n"); in dwc2_wakeup_from_lpm_l1()
354 dev_dbg(hsotg->dev, "Exit from L1 state, remotewakeup=%d\n", remotewakeup); in dwc2_wakeup_from_lpm_l1()
371 dev_warn(hsotg->dev, "%s: timeout GLPMCFG_L1RESUMEOK\n", __func__); in dwc2_wakeup_from_lpm_l1()
381 dev_warn(hsotg->dev, "%s: timeout GINTSTS_WKUPINT\n", __func__); in dwc2_wakeup_from_lpm_l1()
397 hsotg->lx_state = DWC2_L0; in dwc2_wakeup_from_lpm_l1()
398 hsotg->bus_suspended = false; in dwc2_wakeup_from_lpm_l1()
402 dev_err(hsotg->dev, "Host side LPM is not supported.\n"); in dwc2_wakeup_from_lpm_l1()
421 dev_dbg(hsotg->dev, "++Resume or Remote Wakeup Detected Interrupt++\n"); in dwc2_handle_wakeup_detected_intr()
422 dev_dbg(hsotg->dev, "%s lxstate = %d\n", __func__, hsotg->lx_state); in dwc2_handle_wakeup_detected_intr()
424 if (hsotg->lx_state == DWC2_L1) { in dwc2_handle_wakeup_detected_intr()
430 dev_dbg(hsotg->dev, "DSTS=0x%0x\n", in dwc2_handle_wakeup_detected_intr()
432 if (hsotg->lx_state == DWC2_L2) { in dwc2_handle_wakeup_detected_intr()
433 if (hsotg->in_ppd) { in dwc2_handle_wakeup_detected_intr()
441 dev_err(hsotg->dev, in dwc2_handle_wakeup_detected_intr()
447 if (hsotg->params.power_down == in dwc2_handle_wakeup_detected_intr()
448 DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && in dwc2_handle_wakeup_detected_intr()
449 !hsotg->params.no_clock_gating) in dwc2_handle_wakeup_detected_intr()
453 hsotg->lx_state = DWC2_L0; in dwc2_handle_wakeup_detected_intr()
456 if (hsotg->lx_state == DWC2_L2) { in dwc2_handle_wakeup_detected_intr()
457 if (hsotg->in_ppd) { in dwc2_handle_wakeup_detected_intr()
461 dev_err(hsotg->dev, in dwc2_handle_wakeup_detected_intr()
465 if (hsotg->params.power_down == in dwc2_handle_wakeup_detected_intr()
466 DWC2_POWER_DOWN_PARAM_NONE && hsotg->bus_suspended && in dwc2_handle_wakeup_detected_intr()
467 !hsotg->params.no_clock_gating) in dwc2_handle_wakeup_detected_intr()
473 * eventually we'll re-enumerate the device. Not great in dwc2_handle_wakeup_detected_intr()
478 if (hsotg->reset_phy_on_wake) in dwc2_handle_wakeup_detected_intr()
481 mod_timer(&hsotg->wkp_timer, in dwc2_handle_wakeup_detected_intr()
485 hsotg->lx_state = DWC2_L0; in dwc2_handle_wakeup_detected_intr()
498 dev_dbg(hsotg->dev, "++Disconnect Detected Interrupt++ (%s) %s\n", in dwc2_handle_disconnect_intr()
502 if (hsotg->op_state == OTG_STATE_A_HOST) in dwc2_handle_disconnect_intr()
509 * For HNP the USB Suspend interrupt signals the change from "a_peripheral"
522 dev_dbg(hsotg->dev, "USB SUSPEND\n"); in dwc2_handle_usb_suspend_intr()
530 dev_dbg(hsotg->dev, "%s: DSTS=0x%0x\n", __func__, dsts); in dwc2_handle_usb_suspend_intr()
531 dev_dbg(hsotg->dev, in dwc2_handle_usb_suspend_intr()
534 hsotg->hw_params.power_optimized, in dwc2_handle_usb_suspend_intr()
535 hsotg->hw_params.hibernation); in dwc2_handle_usb_suspend_intr()
539 dev_dbg(hsotg->dev, in dwc2_handle_usb_suspend_intr()
544 switch (hsotg->params.power_down) { in dwc2_handle_usb_suspend_intr()
548 dev_err(hsotg->dev, in dwc2_handle_usb_suspend_intr()
554 if (!IS_ERR_OR_NULL(hsotg->uphy)) in dwc2_handle_usb_suspend_intr()
555 usb_phy_set_suspend(hsotg->uphy, true); in dwc2_handle_usb_suspend_intr()
560 dev_err(hsotg->dev, in dwc2_handle_usb_suspend_intr()
568 if (!hsotg->params.no_clock_gating) in dwc2_handle_usb_suspend_intr()
576 hsotg->lx_state = DWC2_L2; in dwc2_handle_usb_suspend_intr()
582 if (hsotg->op_state == OTG_STATE_A_PERIPHERAL) { in dwc2_handle_usb_suspend_intr()
583 dev_dbg(hsotg->dev, "a_peripheral->a_host\n"); in dwc2_handle_usb_suspend_intr()
586 hsotg->lx_state = DWC2_L2; in dwc2_handle_usb_suspend_intr()
588 spin_unlock(&hsotg->lock); in dwc2_handle_usb_suspend_intr()
590 spin_lock(&hsotg->lock); in dwc2_handle_usb_suspend_intr()
591 hsotg->op_state = OTG_STATE_A_HOST; in dwc2_handle_usb_suspend_intr()
597 * dwc2_handle_lpm_intr - GINTSTS_LPMTRANRCVD Interrupt handler
617 dev_err(hsotg->dev, "Unexpected LPM interrupt\n"); in dwc2_handle_lpm_intr()
628 dev_dbg(hsotg->dev, "HIRD_THRES_EN = %d\n", hird_thres_en); in dwc2_handle_lpm_intr()
631 dev_dbg(hsotg->dev, "L1 with utmi_l1_suspend_n\n"); in dwc2_handle_lpm_intr()
633 dev_dbg(hsotg->dev, "L1 with utmi_sleep_n\n"); in dwc2_handle_lpm_intr()
635 dev_dbg(hsotg->dev, "Entering Sleep with L1 Gating\n"); in dwc2_handle_lpm_intr()
650 hsotg->lx_state = DWC2_L1; in dwc2_handle_lpm_intr()
651 dev_dbg(hsotg->dev, in dwc2_handle_lpm_intr()
682 dev_dbg(hsotg->dev, "gintsts=%08x gintmsk=%08x\n", in dwc2_read_common_intr()
692 * dwc_handle_gpwrdn_disc_det() - Handles the gpwrdn disconnect detect.
703 /* Switch-on voltage to the core */ in dwc_handle_gpwrdn_disc_det()
715 /* Disable Power Down Clamp */ in dwc_handle_gpwrdn_disc_det()
727 /* Disable PMU interrupt */ in dwc_handle_gpwrdn_disc_det()
737 /* De-assert Wakeup Logic */ in dwc_handle_gpwrdn_disc_det()
742 hsotg->hibernated = 0; in dwc_handle_gpwrdn_disc_det()
743 hsotg->bus_suspended = 0; in dwc_handle_gpwrdn_disc_det()
746 hsotg->op_state = OTG_STATE_B_PERIPHERAL; in dwc_handle_gpwrdn_disc_det()
752 hsotg->op_state = OTG_STATE_A_HOST; in dwc_handle_gpwrdn_disc_det()
777 dev_dbg(hsotg->dev, in dwc2_handle_gpwrdn_intr()
783 dev_dbg(hsotg->dev, "%s: GPWRDN_DISCONN_DET\n", __func__); in dwc2_handle_gpwrdn_intr()
791 dev_dbg(hsotg->dev, "%s: GPWRDN_LNSTSCHG\n", __func__); in dwc2_handle_gpwrdn_intr()
792 if (hsotg->hw_params.hibernation && in dwc2_handle_gpwrdn_intr()
793 hsotg->hibernated) { in dwc2_handle_gpwrdn_intr()
797 dev_err(hsotg->dev, in dwc2_handle_gpwrdn_intr()
803 dev_err(hsotg->dev, in dwc2_handle_gpwrdn_intr()
809 dev_dbg(hsotg->dev, "%s: GPWRDN_RST_DET\n", __func__); in dwc2_handle_gpwrdn_intr()
813 dev_err(hsotg->dev, in dwc2_handle_gpwrdn_intr()
818 dev_dbg(hsotg->dev, "%s: GPWRDN_STS_CHGINT\n", __func__); in dwc2_handle_gpwrdn_intr()
836 * - Mode Mismatch Interrupt
837 * - OTG Interrupt
838 * - Connector ID Status Change Interrupt
839 * - Disconnect Interrupt
840 * - Session Request Interrupt
841 * - Resume / Remote Wakeup Detected Interrupt
842 * - Suspend Interrupt
850 spin_lock(&hsotg->lock); in dwc2_handle_common_intr()
853 dev_warn(hsotg->dev, "Controller is dead\n"); in dwc2_handle_common_intr()
859 hsotg->frame_number = (dwc2_readl(hsotg, DSTS) in dwc2_handle_common_intr()
862 hsotg->frame_number = (dwc2_readl(hsotg, HFNUM) in dwc2_handle_common_intr()
870 if (hsotg->hibernated) { in dwc2_handle_common_intr()
896 * Port Enable/Disable in dwc2_handle_common_intr()
899 dev_dbg(hsotg->dev, in dwc2_handle_common_intr()
900 " --Port interrupt received in Device mode--\n"); in dwc2_handle_common_intr()
907 spin_unlock(&hsotg->lock); in dwc2_handle_common_intr()