usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes
authorDaniel Mack <zonque@gmail.com>
Wed, 10 Apr 2013 19:55:46 +0000 (21:55 +0200)
committerFelipe Balbi <balbi@ti.com>
Tue, 28 May 2013 16:22:23 +0000 (19:22 +0300)
This makes building the actual object files optional to the selected
mode, which saves users who know which kind of USB mode support they
need some binary size.

Unimplemented functions are stubbed out with static inline functions.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/musb/Kconfig
drivers/usb/musb/Makefile
drivers/usb/musb/musb_gadget.h
drivers/usb/musb/musb_host.h

index 06f8d29..797e3fd 100644 (file)
@@ -27,6 +27,35 @@ config USB_MUSB_HDRC
 
 if USB_MUSB_HDRC
 
+choice
+       bool "MUSB Mode Selection"
+       default USB_MUSB_DUAL_ROLE if (USB && USB_GADGET)
+       default USB_MUSB_HOST if (USB && !USB_GADGET)
+       default USB_MUSB_GADGET if (!USB && USB_GADGET)
+
+config USB_MUSB_HOST
+       bool "Host only mode"
+       depends on USB
+       help
+         Select this when you want to use MUSB in host mode only,
+         thereby the gadget feature will be regressed.
+
+config USB_MUSB_GADGET
+       bool "Gadget only mode"
+       depends on USB_GADGET
+       help
+         Select this when you want to use MUSB in gadget mode only,
+         thereby the host feature will be regressed.
+
+config USB_MUSB_DUAL_ROLE
+       bool "Dual Role mode"
+       depends on (USB && USB_GADGET)
+       help
+         This is the default mode of working of MUSB controller where
+         both host and gadget features are enabled.
+
+endchoice
+
 choice
        prompt "Platform Glue Layer"
 
index 3b85871..2b82ed7 100644 (file)
@@ -6,8 +6,8 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
 
 musb_hdrc-y := musb_core.o
 
-musb_hdrc-y                                    += musb_gadget_ep0.o musb_gadget.o
-musb_hdrc-y                                    += musb_virthub.o musb_host.o
+musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_virthub.o musb_host.o
+musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_gadget_ep0.o musb_gadget.o
 musb_hdrc-$(CONFIG_DEBUG_FS)                   += musb_debugfs.o
 
 # Hardware Glue Layer
index 75f821c..0314dfc 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <linux/list.h>
 
+#if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
 extern irqreturn_t musb_g_ep0_irq(struct musb *);
 extern void musb_g_tx(struct musb *, u8);
 extern void musb_g_rx(struct musb *, u8);
@@ -48,6 +49,26 @@ extern void musb_g_disconnect(struct musb *);
 extern void musb_gadget_cleanup(struct musb *);
 extern int musb_gadget_setup(struct musb *);
 
+#else
+static inline irqreturn_t musb_g_ep0_irq(struct musb *musb)
+{
+       return 0;
+}
+
+static inline void musb_g_tx(struct musb *musb, u8 epnum)      {}
+static inline void musb_g_rx(struct musb *musb, u8 epnum)      {}
+static inline void musb_g_reset(struct musb *musb)             {}
+static inline void musb_g_suspend(struct musb *musb)           {}
+static inline void musb_g_resume(struct musb *musb)            {}
+static inline void musb_g_wakeup(struct musb *musb)            {}
+static inline void musb_g_disconnect(struct musb *musb)                {}
+static inline void musb_gadget_cleanup(struct musb *musb)      {}
+static inline int musb_gadget_setup(struct musb *musb)
+{
+       return 0;
+}
+#endif
+
 enum buffer_map_state {
        UN_MAPPED = 0,
        PRE_MAPPED,
index e47035e..1ce6e4e 100644 (file)
@@ -39,8 +39,6 @@
 
 #define musb_to_hcd(MUSB) ((MUSB)->hcd)
 
-extern struct musb *hcd_to_musb(struct usb_hcd *);
-
 /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
 struct musb_qh {
        struct usb_host_endpoint *hep;          /* usbcore info */
@@ -78,6 +76,9 @@ static inline struct musb_qh *first_qh(struct list_head *q)
        return list_entry(q->next, struct musb_qh, ring);
 }
 
+
+#if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
+extern struct musb *hcd_to_musb(struct usb_hcd *);
 extern irqreturn_t musb_h_ep0_irq(struct musb *);
 extern int musb_host_alloc(struct musb *);
 extern void musb_host_tx(struct musb *, u8);
@@ -90,6 +91,30 @@ extern void musb_host_rx(struct musb *, u8);
 extern void musb_root_disconnect(struct musb *musb);
 extern void musb_host_resume_root_hub(struct musb *musb);
 extern void musb_host_poke_root_hub(struct musb *musb);
+#else
+static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
+{
+       return NULL;
+}
+
+static inline irqreturn_t musb_h_ep0_irq(struct musb *musb)
+{
+       return 0;
+}
+
+static inline int musb_host_alloc(struct musb *musb)
+{
+       return 0;
+}
+
+static inline void musb_host_free(struct musb *musb)           {}
+static inline void musb_host_tx(struct musb *musb, u8 epnum)   {}
+static inline void musb_host_rx(struct musb *musb, u8 epnum)   {}
+static inline void musb_root_disconnect(struct musb *musb)     {}
+static inline void musb_host_resume_root_hub(struct musb *musb)        {}
+static inline void musb_host_poll_rh_status(struct musb *musb) {}
+static inline void musb_host_poke_root_hub(struct musb *musb)  {}
+#endif
 
 struct usb_hcd;