Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8049b938 authored by Tarun Gupta's avatar Tarun Gupta
Browse files

USB: gadget: Add support to disable interrupt and timer



'commit b4ae4b99 ("USB: gadget: Perform BAM reset as part of
disconnect processing")' adds changes to disble USB interrupt before
scheduling disconnect work in function drivers which uses BAM2BAM mode
and reenbale it once either disconnect processing and BAM reset is done
or one second timer expires to enable forcefully.

Add required changes to ci13xxx msm which adds functions to disable
and enable interrupts and timer to enable interrupts forcefully

Change-Id: I9db575756519ebb833076bca8f0748e139eb9d00
Signed-off-by: default avatarTarun Gupta <tarung@codeaurora.org>
parent f412722a
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -26,9 +26,12 @@ struct ci13xxx_udc_context {
	int wake_irq;
	bool wake_irq_state;
	struct pinctrl *ci13xxx_pinctrl;
	struct timer_list irq_enable_timer;
	bool irq_disabled;
};

static struct ci13xxx_udc_context _udc_ctxt;
#define IRQ_ENABLE_DELAY	(jiffies + msecs_to_jiffies(1000))

static irqreturn_t msm_udc_irq(int irq, void *data)
{
@@ -374,6 +377,7 @@ static void ci13xxx_msm_uninstall_wake_gpio(struct platform_device *pdev)
	}
}

static void enable_usb_irq_timer_func(unsigned long data);
static int ci13xxx_msm_probe(struct platform_device *pdev)
{
	struct resource *res;
@@ -458,6 +462,9 @@ static int ci13xxx_msm_probe(struct platform_device *pdev)
		goto gpio_uninstall;
	}

	setup_timer(&_udc_ctxt.irq_enable_timer, enable_usb_irq_timer_func,
							(unsigned long)NULL);

	pm_runtime_no_callbacks(&pdev->dev);
	pm_runtime_enable(&pdev->dev);

@@ -501,6 +508,39 @@ void msm_hw_bam_disable(bool bam_disable)
	writel_relaxed(val, USB_GENCONFIG);
}

void msm_usb_irq_disable(bool disable)
{
	struct ci13xxx *udc = _udc;
	unsigned long flags;

	spin_lock_irqsave(udc->lock, flags);

	if (_udc_ctxt.irq_disabled == disable) {
		mod_timer(&_udc_ctxt.irq_enable_timer, IRQ_ENABLE_DELAY);
		spin_unlock_irqrestore(udc->lock, flags);
		return;
	}

	if (disable) {
		disable_irq_nosync(_udc_ctxt.irq);
		/* start timer here */
		mod_timer(&_udc_ctxt.irq_enable_timer, IRQ_ENABLE_DELAY);
		_udc_ctxt.irq_disabled = true;

	} else {
		del_timer(&_udc_ctxt.irq_enable_timer);
		enable_irq(_udc_ctxt.irq);
		_udc_ctxt.irq_disabled = false;
	}

	spin_unlock_irqrestore(udc->lock, flags);
}

static void enable_usb_irq_timer_func(unsigned long data)
{
	msm_usb_irq_disable(false);
}

static struct platform_driver ci13xxx_msm_driver = {
	.probe = ci13xxx_msm_probe,
	.driver = {