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@xxxxxxxxxxx> --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html