From: Dinh Nguyen <dinguyen@xxxxxxxxxx> Only build the core components of the dual-role driver, and only build the necessary functions for the various modes. When buildling for host mode, s3c_hsotg will not get built. When building for peripheral mode, the dwc2 host functions will not get built. Signed-off-by: Dinh Nguyen <dinguyen@xxxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Paul Zimmerman <paulz@xxxxxxxxxxxx> Cc: Felipe Balbi <balbi@xxxxxx> Cc: Ben Dooks <ben-linux@xxxxxxxxx> Cc: Matt Porter <mporter@xxxxxxxxxx> Cc: Kukjin Kim <kgene.kim@xxxxxxxxxxx> Cc: Stephen Warren <swarren@xxxxxxxxxxxxx> Cc: Matthijs Kooijman <matthijs@xxxxxxxx> Cc: Jingoo Han <jg1.han@xxxxxxxxxxx> Cc: Sachin Kamat <sachin.kamat@xxxxxxxxxx> Cc: Robert Baldyga <r.baldyga@xxxxxxxxxxx> --- drivers/usb/dwc2/Makefile | 10 ++++++++-- drivers/usb/dwc2/core.h | 26 ++++++++++++++++++++++++++ drivers/usb/dwc2/hcd.h | 23 +++++++++++++++++------ 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/drivers/usb/dwc2/Makefile b/drivers/usb/dwc2/Makefile index eca1bd9..1fe222d 100644 --- a/drivers/usb/dwc2/Makefile +++ b/drivers/usb/dwc2/Makefile @@ -3,9 +3,15 @@ ccflags-$(CONFIG_USB_DWC2_VERBOSE) += -DVERBOSE_DEBUG obj-$(CONFIG_USB_DWC2) += dwc2.o dwc2-y += core.o core_intr.o -dwc2-y += hcd.o hcd_intr.o -dwc2-y += hcd_queue.o hcd_ddma.o + +ifneq ($(filter y,$(CONFIG_USB_DWC2_HOST) $(CONFIG_USB_DWC2_DUAL_ROLE)),) +dwc2-y += hcd.o hcd_intr.o +dwc2-y += hcd_queue.o hcd_ddma.o +endif + +ifneq ($(filter y,$(CONFIG_USB_S3C_HSOTG) $(CONFIG_USB_DWC2_DUAL_ROLE)),) dwc2-y += s3c-hsotg.o +endif ifneq ($(CONFIG_PCI),) obj-$(CONFIG_USB_DWC2) += dwc2_pci.o diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 9bbbe53..e112dd4 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -948,6 +948,7 @@ extern void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg); extern u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg); /* Gadget externs */ +#if defined(CONFIG_USB_S3C_HSOTG) || defined(CONFIG_USB_DWC2_DUAL_ROLE) extern int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq); extern void s3c_hsotg_remove(struct dwc2_hsotg *dwc2); extern void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2); @@ -961,5 +962,30 @@ extern void s3c_hsotg_disable_gsint(struct dwc2_hsotg *dwc2, u32 ints); extern void s3c_hsotg_irq_fifoempty(struct dwc2_hsotg *dwc2, bool periodic); extern void s3c_hsotg_handle_rx(struct dwc2_hsotg *dwc2); extern void s3c_hsotg_dump(struct dwc2_hsotg *dwc2); +#else +static inline int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq) +{ return 0; } +static inline void s3c_hsotg_remove(struct dwc2_hsotg *dwc2) +{ } +static inline void s3c_hsotg_disconnect(struct dwc2_hsotg *dwc2) +{ } +static inline void s3c_hsotg_irq_enumdone(struct dwc2_hsotg *dwc2) +{ } +static inline void s3c_hsotg_epint(struct dwc2_hsotg *dwc2, unsigned int idx, int dir_in) +{ } +static inline void kill_all_requests(struct dwc2_hsotg *dwc2, struct s3c_hsotg_ep *ep, + int result, bool force) +{ } +static inline void s3c_hsotg_core_init(struct dwc2_hsotg *dwc2) +{ } +static inline void s3c_hsotg_disable_gsint(struct dwc2_hsotg *dwc2, u32 ints) +{ } +static inline void s3c_hsotg_irq_fifoempty(struct dwc2_hsotg *dwc2, bool periodic) +{ } +static inline void s3c_hsotg_handle_rx(struct dwc2_hsotg *dwc2) +{ } +static inline void s3c_hsotg_dump(struct dwc2_hsotg *dwc2) +{ } +#endif #endif /* __DWC2_CORE_H__ */ diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h index fdc6d48..457e0ce 100644 --- a/drivers/usb/dwc2/hcd.h +++ b/drivers/usb/dwc2/hcd.h @@ -454,7 +454,6 @@ extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg); extern void dwc2_set_parameters(struct dwc2_hsotg *hsotg, const struct dwc2_core_params *params); -extern void dwc2_set_all_params(struct dwc2_core_params *params, int value); extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg); /* Transaction Execution Functions */ @@ -666,23 +665,35 @@ extern irqreturn_t dwc2_handle_hcd_intr(struct dwc2_hsotg *hsotg); */ extern void dwc2_hcd_stop(struct dwc2_hsotg *hsotg); +#if defined(CONFIG_USB_DWC2_HOST) || defined(CONFIG_USB_DWC2_DUAL_ROLE) extern void dwc2_hcd_start(struct dwc2_hsotg *hsotg); extern void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg); /** - * dwc2_hcd_is_b_host() - Returns 1 if core currently is acting as B host, - * and 0 otherwise + * dwc2_hcd_get_frame_number() - Returns current frame number * * @hsotg: The DWC2 HCD */ -extern int dwc2_hcd_is_b_host(struct dwc2_hsotg *hsotg); +extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg); +extern void dwc2_set_all_params(struct dwc2_core_params *params, int value); +#else +static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) +{ } +static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg) +{ } +static inline int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg) +{ return 0; } +static inline void dwc2_set_all_params(struct dwc2_core_params *params, int value) +{ } +#endif /** - * dwc2_hcd_get_frame_number() - Returns current frame number + * dwc2_hcd_is_b_host() - Returns 1 if core currently is acting as B host, + * and 0 otherwise * * @hsotg: The DWC2 HCD */ -extern int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg); +extern int dwc2_hcd_is_b_host(struct dwc2_hsotg *hsotg); /** * dwc2_hcd_dump_state() - Dumps hsotg state -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html