usb: dwc3: core: make dwc3_set_mode() work properly
[linux-2.6-block.git] / drivers / usb / dwc3 / core.h
index 3464dbfe153be83c83c4e562f93d803e3af21d85..1fe23e36485f53c807ca11fe77d187028b790fc8 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/mm.h>
 #include <linux/debugfs.h>
 #include <linux/wait.h>
+#include <linux/workqueue.h>
 
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
@@ -760,6 +761,7 @@ struct dwc3_scratchpad_array {
 
 /**
  * struct dwc3 - representation of our controller
+ * @drd_work - workqueue used for role swapping
  * @ep0_trb: trb which is used for the ctrl_req
  * @setup_buf: used while precessing STD USB requests
  * @ep0_trb: dma address of ep0_trb
@@ -782,6 +784,7 @@ struct dwc3_scratchpad_array {
  * @revision: revision register contents
  * @dr_mode: requested mode of operation
  * @current_dr_role: current role of operation when in dual-role mode
+ * @desired_dr_role: desired role of operation when in dual-role mode
  * @hsphy_mode: UTMI phy mode, one of following:
  *             - USBPHY_INTERFACE_MODE_UTMI
  *             - USBPHY_INTERFACE_MODE_UTMIW
@@ -855,6 +858,7 @@ struct dwc3_scratchpad_array {
  *                 increments or 0 to disable.
  */
 struct dwc3 {
+       struct work_struct      drd_work;
        struct dwc3_trb         *ep0_trb;
        void                    *bounce;
        void                    *scratchbuf;
@@ -893,6 +897,7 @@ struct dwc3 {
 
        enum usb_dr_mode        dr_mode;
        u32                     current_dr_role;
+       u32                     desired_dr_role;
        enum usb_phy_interface  hsphy_mode;
 
        u32                     fladj;
@@ -1002,7 +1007,7 @@ struct dwc3 {
        u16                     imod_interval;
 };
 
-/* -------------------------------------------------------------------------- */
+#define work_to_dwc(w)         (container_of((w), struct dwc3, drd_work))
 
 /* -------------------------------------------------------------------------- */