mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
usb: chipidea: udc: add a helper ci_udc_enable_vbus_irq()
The VBUS interrupt is configured in multiple places, add a helper function ci_udc_enable_vbus_irq() to simplify the code. Acked-by: Peter Chen <peter.chen@kernel.org> Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Link: https://patch.msgid.link/20260427075653.3611180-1-xu.yang_2@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
16abda69f4
commit
a3fe1408e8
|
|
@ -1835,6 +1835,20 @@ static const struct usb_ep_ops usb_ep_ops = {
|
|||
* GADGET block
|
||||
*****************************************************************************/
|
||||
|
||||
static void ci_udc_enable_vbus_irq(struct ci_hdrc *ci, bool enable)
|
||||
{
|
||||
u32 reg = OTGSC_BSVIS;
|
||||
|
||||
if (!ci->is_otg)
|
||||
return;
|
||||
|
||||
if (enable)
|
||||
reg |= OTGSC_BSVIE;
|
||||
|
||||
/* Clear pending BSVIS and enable/disable BSVIE */
|
||||
hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, reg);
|
||||
}
|
||||
|
||||
static int ci_udc_get_frame(struct usb_gadget *_gadget)
|
||||
{
|
||||
struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget);
|
||||
|
|
@ -2352,23 +2366,13 @@ static int udc_id_switch_for_device(struct ci_hdrc *ci)
|
|||
pinctrl_select_state(ci->platdata->pctl,
|
||||
ci->platdata->pins_device);
|
||||
|
||||
if (ci->is_otg)
|
||||
/* Clear and enable BSV irq */
|
||||
hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
|
||||
OTGSC_BSVIS | OTGSC_BSVIE);
|
||||
|
||||
ci_udc_enable_vbus_irq(ci, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void udc_id_switch_for_host(struct ci_hdrc *ci)
|
||||
{
|
||||
/*
|
||||
* host doesn't care B_SESSION_VALID event
|
||||
* so clear and disable BSV irq
|
||||
*/
|
||||
if (ci->is_otg)
|
||||
hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS);
|
||||
|
||||
ci_udc_enable_vbus_irq(ci, false);
|
||||
ci->vbus_active = 0;
|
||||
|
||||
if (ci->platdata->pins_device && ci->platdata->pins_default)
|
||||
|
|
@ -2395,9 +2399,7 @@ static void udc_suspend(struct ci_hdrc *ci)
|
|||
static void udc_resume(struct ci_hdrc *ci, bool power_lost)
|
||||
{
|
||||
if (power_lost) {
|
||||
if (ci->is_otg)
|
||||
hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE,
|
||||
OTGSC_BSVIS | OTGSC_BSVIE);
|
||||
ci_udc_enable_vbus_irq(ci, true);
|
||||
if (ci->vbus_active)
|
||||
usb_gadget_vbus_disconnect(&ci->gadget);
|
||||
} else if (ci->vbus_active && ci->driver &&
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user