From 28a0241ccd48963a13638c1dfbef161ab1bf557e Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 31 Jan 2013 19:20:26 +0000 Subject: Missing calls to class SUSPEND/RESUME methods in all USB drivers git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5590 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c | 46 ++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) (limited to 'nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c') diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c b/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c index a40d6492d..d0af116d6 100644 --- a/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_usb0dev.c @@ -1,7 +1,7 @@ /******************************************************************************* * arch/arm/src/lpc43xx/lpc43_usbdev.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Part of the NuttX OS and based, in part, on the LPC31xx USB driver: @@ -163,8 +163,9 @@ #define LPC43_TRACEINTID_IFGETSTATUS 0x0015 #define LPC43_TRACEINTID_SETCONFIG 0x0016 #define LPC43_TRACEINTID_SETFEATURE 0x0017 -#define LPC43_TRACEINTID_SUSPENDCHG 0x0018 -#define LPC43_TRACEINTID_SYNCHFRAME 0x0019 +#define LPC43_TRACEINTID_SUSPENDED 0x0018 +#define LPC43_TRACEINTID_RESUMED 0x0019 +#define LPC43_TRACEINTID_SYNCHFRAME 0x001a /* Hardware interface **********************************************************/ @@ -312,6 +313,7 @@ struct lpc43_usbdev_s uint8_t selfpowered:1; /* 1: Device is self powered */ uint8_t paddrset:1; /* 1: Peripheral addr has been set */ uint8_t attached:1; /* 1: Host attached */ + uint8_t suspended:1; /* 1: Suspended */ uint32_t softprio; /* Bitset of high priority interrupts */ uint32_t epavail; /* Bitset of available endpoints */ #ifdef CONFIG_LPC43_USBDEV_FRAME_INTERRUPT @@ -1665,10 +1667,42 @@ static int lpc43_usbinterrupt(int irq, FAR void *context) return OK; } - if (disr & USBDEV_USBSTS_SLI) + /* When the device controller enters a suspend state from an active state, + * the SLI bit will be set to a one. + */ + + if (!priv->suspended && (disr & USBDEV_USBSTS_SLI) != 0) + { + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_SUSPENDED),0); + + /* Inform the Class driver of the suspend event */ + + priv->suspended = 1; + if (priv->driver) + { + CLASS_SUSPEND(priv->driver, &priv->usbdev); + } + + /* TODO: Perform power management operations here. */ + } + + /* The device controller clears the SLI bit upon exiting from a suspend + * state. This bit can also be cleared by software writing a one to it. + */ + + else if (priv->suspended && (disr & USBDEV_USBSTS_SLI) == 0) { - // FIXME: what do we need to do here... - usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_SUSPENDCHG),0); + usbtrace(TRACE_INTDECODE(LPC43_TRACEINTID_RESUMED),0); + + /* Inform the Class driver of the resume event */ + + priv->suspended = 0; + if (priv->driver) + { + CLASS_RESUME(priv->driver, &priv->usbdev); + } + + /* TODO: Perform power management operations here. */ } if (disr & USBDEV_USBSTS_PCI) -- cgit v1.2.3