diff options
author | Daniel Mack <zonque@gmail.com> | 2013-04-10 15:55:46 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-05-28 12:22:23 -0400 |
commit | b7b741ea38a32336b45870b76aaec1abe57badd0 (patch) | |
tree | 10d48d17c988e5f6b6743bd3d6eb97f9bc0e0679 | |
parent | 74c2e93600581d80695604126a3725a157d0ab72 (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/Kconfig | 29 | ||||
-rw-r--r-- | drivers/usb/musb/Makefile | 4 | ||||
-rw-r--r-- | drivers/usb/musb/musb_gadget.h | 21 | ||||
-rw-r--r-- | drivers/usb/musb/musb_host.h | 29 |
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 | |||
28 | if USB_MUSB_HDRC | 28 | if USB_MUSB_HDRC |
29 | 29 | ||
30 | choice | 30 | choice |
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 | |||
36 | config 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 | |||
43 | config 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 | |||
50 | config 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 | |||
57 | endchoice | ||
58 | |||
59 | choice | ||
31 | prompt "Platform Glue Layer" | 60 | prompt "Platform Glue Layer" |
32 | 61 | ||
33 | config USB_MUSB_DAVINCI | 62 | config 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 | ||
7 | musb_hdrc-y := musb_core.o | 7 | musb_hdrc-y := musb_core.o |
8 | 8 | ||
9 | musb_hdrc-y += musb_gadget_ep0.o musb_gadget.o | 9 | musb_hdrc-$(CONFIG_USB_MUSB_HOST)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_virthub.o musb_host.o |
10 | musb_hdrc-y += musb_virthub.o musb_host.o | 10 | musb_hdrc-$(CONFIG_USB_MUSB_GADGET)$(CONFIG_USB_MUSB_DUAL_ROLE) += musb_gadget_ep0.o musb_gadget.o |
11 | musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o | 11 | musb_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) | ||
40 | extern irqreturn_t musb_g_ep0_irq(struct musb *); | 41 | extern irqreturn_t musb_g_ep0_irq(struct musb *); |
41 | extern void musb_g_tx(struct musb *, u8); | 42 | extern void musb_g_tx(struct musb *, u8); |
42 | extern void musb_g_rx(struct musb *, u8); | 43 | extern void musb_g_rx(struct musb *, u8); |
@@ -48,6 +49,26 @@ extern void musb_g_disconnect(struct musb *); | |||
48 | extern void musb_gadget_cleanup(struct musb *); | 49 | extern void musb_gadget_cleanup(struct musb *); |
49 | extern int musb_gadget_setup(struct musb *); | 50 | extern int musb_gadget_setup(struct musb *); |
50 | 51 | ||
52 | #else | ||
53 | static inline irqreturn_t musb_g_ep0_irq(struct musb *musb) | ||
54 | { | ||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | static inline void musb_g_tx(struct musb *musb, u8 epnum) {} | ||
59 | static inline void musb_g_rx(struct musb *musb, u8 epnum) {} | ||
60 | static inline void musb_g_reset(struct musb *musb) {} | ||
61 | static inline void musb_g_suspend(struct musb *musb) {} | ||
62 | static inline void musb_g_resume(struct musb *musb) {} | ||
63 | static inline void musb_g_wakeup(struct musb *musb) {} | ||
64 | static inline void musb_g_disconnect(struct musb *musb) {} | ||
65 | static inline void musb_gadget_cleanup(struct musb *musb) {} | ||
66 | static inline int musb_gadget_setup(struct musb *musb) | ||
67 | { | ||
68 | return 0; | ||
69 | } | ||
70 | #endif | ||
71 | |||
51 | enum buffer_map_state { | 72 | enum 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 | ||
42 | extern 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 */ |
45 | struct musb_qh { | 43 | struct 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) | ||
81 | extern struct musb *hcd_to_musb(struct usb_hcd *); | ||
81 | extern irqreturn_t musb_h_ep0_irq(struct musb *); | 82 | extern irqreturn_t musb_h_ep0_irq(struct musb *); |
82 | extern int musb_host_alloc(struct musb *); | 83 | extern int musb_host_alloc(struct musb *); |
83 | extern void musb_host_tx(struct musb *, u8); | 84 | extern void musb_host_tx(struct musb *, u8); |
@@ -90,6 +91,30 @@ extern void musb_host_rx(struct musb *, u8); | |||
90 | extern void musb_root_disconnect(struct musb *musb); | 91 | extern void musb_root_disconnect(struct musb *musb); |
91 | extern void musb_host_resume_root_hub(struct musb *musb); | 92 | extern void musb_host_resume_root_hub(struct musb *musb); |
92 | extern void musb_host_poke_root_hub(struct musb *musb); | 93 | extern void musb_host_poke_root_hub(struct musb *musb); |
94 | #else | ||
95 | static inline struct musb *hcd_to_musb(struct usb_hcd *hcd) | ||
96 | { | ||
97 | return NULL; | ||
98 | } | ||
99 | |||
100 | static inline irqreturn_t musb_h_ep0_irq(struct musb *musb) | ||
101 | { | ||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static inline int musb_host_alloc(struct musb *musb) | ||
106 | { | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static inline void musb_host_free(struct musb *musb) {} | ||
111 | static inline void musb_host_tx(struct musb *musb, u8 epnum) {} | ||
112 | static inline void musb_host_rx(struct musb *musb, u8 epnum) {} | ||
113 | static inline void musb_root_disconnect(struct musb *musb) {} | ||
114 | static inline void musb_host_resume_root_hub(struct musb *musb) {} | ||
115 | static inline void musb_host_poll_rh_status(struct musb *musb) {} | ||
116 | static inline void musb_host_poke_root_hub(struct musb *musb) {} | ||
117 | #endif | ||
93 | 118 | ||
94 | struct usb_hcd; | 119 | struct usb_hcd; |
95 | 120 | ||