[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1531374448-26532-12-git-send-email-pawell@cadence.com>
Date: Thu, 12 Jul 2018 06:47:08 +0100
From: Pawel Laszczak <pawell@...ence.com>
To: unlisted-recipients:; (no To-header on input)
CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
<linux-usb@...r.kernel.org>, Felipe Balbi <balbi@...nel.org>,
<linux-kernel@...r.kernel.org>, <ltyrala@...ence.com>,
<adouglas@...ence.com>, <pawell@...ence.com>
Subject: [PATCH 11/31] usb: usbssp: added function for stopping driver.
This function is called by the gadget core when the USBSSP driver
is removed. Disable device contexts, disable IRQs, and quiesce the DC.
Reset the DC, finish any completed transactions, and cleanup memory.
Signed-off-by: Pawel Laszczak <pawell@...ence.com>
---
drivers/usb/usbssp/gadget.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/drivers/usb/usbssp/gadget.c b/drivers/usb/usbssp/gadget.c
index a66209fc069b..e84821394e85 100644
--- a/drivers/usb/usbssp/gadget.c
+++ b/drivers/usb/usbssp/gadget.c
@@ -204,6 +204,41 @@ int usbssp_init(struct usbssp_udc *usbssp_data)
return retval;
}
+/*
+ * Stop USBSSP controller.
+ *
+ * This function is called by the gadget core when the USBSSP driver is removed.
+ * Its opposite is usbssp_run().
+ *
+ * Disable device contexts, disable IRQs, and quiesce the DC.
+ * Reset the DC, finish any completed transactions, and cleanup memory.
+ */
+void usbssp_stop(struct usbssp_udc *usbssp_data)
+{
+ u32 temp;
+
+ spin_lock_irq(&usbssp_data->lock);
+ usbssp_data->usbssp_state |= USBSSP_STATE_HALTED;
+ usbssp_data->cmd_ring_state = CMD_RING_STATE_STOPPED;
+ usbssp_halt(usbssp_data);
+ usbssp_reset(usbssp_data);
+ spin_unlock_irq(&usbssp_data->lock);
+
+ usbssp_dbg_trace(usbssp_data, trace_usbssp_dbg_init,
+ "// Disabling event ring interrupts");
+ temp = readl(&usbssp_data->op_regs->status);
+ writel((temp & ~0x1fff) | STS_EINT, &usbssp_data->op_regs->status);
+ temp = readl(&usbssp_data->ir_set->irq_pending);
+ writel(ER_IRQ_DISABLE(temp), &usbssp_data->ir_set->irq_pending);
+
+ usbssp_dbg_trace(usbssp_data, trace_usbssp_dbg_init,
+ "cleaning up memory");
+ usbssp_mem_cleanup(usbssp_data);
+ usbssp_dbg_trace(usbssp_data, trace_usbssp_dbg_init,
+ "usbssp_stop completed - status = %x",
+ readl(&usbssp_data->op_regs->status));
+}
+
#ifdef CONFIG_PM
/*
* Stop DC (not bus-specific)
--
2.17.1
Powered by blists - more mailing lists