lkml.org 
[lkml]   [2018]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 11/31] usb: usbssp: added function for stopping driver.
Date
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@cadence.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 915983bc400f..2996b1d3baf7 100644
--- a/drivers/usb/usbssp/gadget.c
+++ b/drivers/usb/usbssp/gadget.c
@@ -200,6 +200,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
\
 
 \ /
  Last update: 2018-07-19 20:03    [W:0.258 / U:17.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site