aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Mack <zonque@gmail.com>2013-04-10 15:55:46 -0400
committerFelipe Balbi <balbi@ti.com>2013-05-28 12:22:23 -0400
commitb7b741ea38a32336b45870b76aaec1abe57badd0 (patch)
tree10d48d17c988e5f6b6743bd3d6eb97f9bc0e0679
parent74c2e93600581d80695604126a3725a157d0ab72 (diff)
usb: musb: add Kconfig options for HOST, GAGDET or DUAL_ROLE modes
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>
-rw-r--r--drivers/usb/musb/Kconfig29
-rw-r--r--drivers/usb/musb/Makefile4
-rw-r--r--drivers/usb/musb/musb_gadget.h21
-rw-r--r--drivers/usb/musb/musb_host.h29
4 files changed, 79 insertions, 4 deletions
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 06f8d29af1ef..797e3fd45510 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -28,6 +28,35 @@ config USB_MUSB_HDRC
28if USB_MUSB_HDRC 28if USB_MUSB_HDRC
29 29
30choice 30choice
31 bool "MUSB Mode Selection"
32 default USB_MUSB_DUAL_ROLE if (USB && USB_GADGET)
33 default USB_MUSB_HOST if (USB && !USB_GADGET)
34 default USB_MUSB_GADGET if (!USB && USB_GADGET)
35
36config USB_MUSB_HOST
37 bool "Host only mode"
38 depends on USB
39 help
40 Select this when you want to use MUSB in host mode only,
41 thereby the gadget feature will be regressed.
42
43config USB_MUSB_GADGET
44 bool "Gadget only mode"
45 depends on USB_GADGET
46 help
47 Select this when you want to use MUSB in gadget mode only,
48 thereby the host feature will be regressed.
49
50config USB_MUSB_DUAL_ROLE
51 bool "Dual Role mode"
52 depends on (USB && USB_GADGET)
53 help
54 This is the default mode of working of MUSB controller where
55 both host and gadget features are enabled.
56
57endchoice
58
59choice
31 prompt "Platform Glue Layer" 60 prompt "Platform Glue Layer"
32 61
33config USB_MUSB_DAVINCI 62config USB_MUSB_DAVINCI
diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile
index 3b858715b5ea..2b82ed7c85ca 100644
--- a/drivers/usb/musb/Makefile
+++ b/drivers/usb/musb/Makefile
@@ -6,8 +6,8 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
6 6
7musb_hdrc-y := musb_core.o 7musb_hdrc-y := musb_core.o
8 8
9musb_hdrc-y += musb_gadget_ep0.o musb_gadget.o 9musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_virthub.o musb_host.o
10musb_hdrc-y += musb_virthub.o musb_host.o 10musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_gadget_ep0.o musb_gadget.o
11musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o 11musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o
12 12
13# Hardware Glue Layer 13# Hardware Glue Layer
diff --git a/drivers/usb/musb/musb_gadget.h b/drivers/usb/musb/musb_gadget.h
index 75f821cc3d98..0314dfc770c7 100644
--- a/drivers/usb/musb/musb_gadget.h
+++ b/drivers/usb/musb/musb_gadget.h
@@ -37,6 +37,7 @@
37 37
38#include <linux/list.h> 38#include <linux/list.h>
39 39
40#if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
40extern irqreturn_t musb_g_ep0_irq(struct musb *); 41extern irqreturn_t musb_g_ep0_irq(struct musb *);
41extern void musb_g_tx(struct musb *, u8); 42extern void musb_g_tx(struct musb *, u8);
42extern void musb_g_rx(struct musb *, u8); 43extern void musb_g_rx(struct musb *, u8);
@@ -48,6 +49,26 @@ extern void musb_g_disconnect(struct musb *);
48extern void musb_gadget_cleanup(struct musb *); 49extern void musb_gadget_cleanup(struct musb *);
49extern int musb_gadget_setup(struct musb *); 50extern int musb_gadget_setup(struct musb *);
50 51
52#else
53static inline irqreturn_t musb_g_ep0_irq(struct musb *musb)
54{
55 return 0;
56}
57
58static inline void musb_g_tx(struct musb *musb, u8 epnum) {}
59static inline void musb_g_rx(struct musb *musb, u8 epnum) {}
60static inline void musb_g_reset(struct musb *musb) {}
61static inline void musb_g_suspend(struct musb *musb) {}
62static inline void musb_g_resume(struct musb *musb) {}
63static inline void musb_g_wakeup(struct musb *musb) {}
64static inline void musb_g_disconnect(struct musb *musb) {}
65static inline void musb_gadget_cleanup(struct musb *musb) {}
66static inline int musb_gadget_setup(struct musb *musb)
67{
68 return 0;
69}
70#endif
71
51enum buffer_map_state { 72enum buffer_map_state {
52 UN_MAPPED = 0, 73 UN_MAPPED = 0,
53 PRE_MAPPED, 74 PRE_MAPPED,
diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h
index e47035e1e3c9..1ce6e4ec9021 100644
--- a/drivers/usb/musb/musb_host.h
+++ b/drivers/usb/musb/musb_host.h
@@ -39,8 +39,6 @@
39 39
40#define musb_to_hcd(MUSB) ((MUSB)->hcd) 40#define musb_to_hcd(MUSB) ((MUSB)->hcd)
41 41
42extern struct musb *hcd_to_musb(struct usb_hcd *);
43
44/* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */ 42/* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
45struct musb_qh { 43struct musb_qh {
46 struct usb_host_endpoint *hep; /* usbcore info */ 44 struct usb_host_endpoint *hep; /* usbcore info */
@@ -78,6 +76,9 @@ static inline struct musb_qh *first_qh(struct list_head *q)
78 return list_entry(q->next, struct musb_qh, ring); 76 return list_entry(q->next, struct musb_qh, ring);
79} 77}
80 78
79
80#if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
81extern struct musb *hcd_to_musb(struct usb_hcd *);
81extern irqreturn_t musb_h_ep0_irq(struct musb *); 82extern irqreturn_t musb_h_ep0_irq(struct musb *);
82extern int musb_host_alloc(struct musb *); 83extern int musb_host_alloc(struct musb *);
83extern void musb_host_tx(struct musb *, u8); 84extern void musb_host_tx(struct musb *, u8);
@@ -90,6 +91,30 @@ extern void musb_host_rx(struct musb *, u8);
90extern void musb_root_disconnect(struct musb *musb); 91extern void musb_root_disconnect(struct musb *musb);
91extern void musb_host_resume_root_hub(struct musb *musb); 92extern void musb_host_resume_root_hub(struct musb *musb);
92extern void musb_host_poke_root_hub(struct musb *musb); 93extern void musb_host_poke_root_hub(struct musb *musb);
94#else
95static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
96{
97 return NULL;
98}
99
100static inline irqreturn_t musb_h_ep0_irq(struct musb *musb)
101{
102 return 0;
103}
104
105static inline int musb_host_alloc(struct musb *musb)
106{
107 return 0;
108}
109
110static inline void musb_host_free(struct musb *musb) {}
111static inline void musb_host_tx(struct musb *musb, u8 epnum) {}
112static inline void musb_host_rx(struct musb *musb, u8 epnum) {}
113static inline void musb_root_disconnect(struct musb *musb) {}
114static inline void musb_host_resume_root_hub(struct musb *musb) {}
115static inline void musb_host_poll_rh_status(struct musb *musb) {}
116static inline void musb_host_poke_root_hub(struct musb *musb) {}
117#endif
93 118
94struct usb_hcd; 119struct usb_hcd;
95 120