Commit 62285963 authored by Felipe Balbi's avatar Felipe Balbi Committed by Greg Kroah-Hartman

usb: musb: drop a gigantic amount of ifdeferry

the MUSB IP is always OTG, so there's no point
in adding so many ifdefs on the code. Drop those
and always compile the driver for OTG support.

This also allows us to drop the useless "driver
mode" choice. For doing that, we need to make
musb depend on both Host and Peripheral side.
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e4e5b136
...@@ -8,7 +8,7 @@ comment "Enable Host or Gadget support to see Inventra options" ...@@ -8,7 +8,7 @@ comment "Enable Host or Gadget support to see Inventra options"
# (M)HDRC = (Multipoint) Highspeed Dual-Role Controller # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller
config USB_MUSB_HDRC config USB_MUSB_HDRC
depends on (USB || USB_GADGET) depends on USB && USB_GADGET
depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523)) depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523))
select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN)
select TWL4030_USB if MACH_OMAP_3430SDP select TWL4030_USB if MACH_OMAP_3430SDP
...@@ -67,79 +67,6 @@ config USB_MUSB_UX500 ...@@ -67,79 +67,6 @@ config USB_MUSB_UX500
endchoice endchoice
choice
prompt "Driver Mode"
depends on USB_MUSB_HDRC
help
Dual-Role devices can support both host and peripheral roles,
as well as a the special "OTG Device" role which can switch
between both roles as needed.
# use USB_MUSB_HDRC_HCD not USB_MUSB_HOST to #ifdef host side support;
# OTG needs both roles, not just USB_MUSB_HOST.
config USB_MUSB_HOST
depends on USB
bool "USB Host"
help
Say Y here if your system supports the USB host role.
If it has a USB "A" (rectangular), "Mini-A" (uncommon),
or "Mini-AB" connector, it supports the host role.
(With a "Mini-AB" connector, you should enable USB OTG.)
# use USB_GADGET_MUSB_HDRC not USB_MUSB_PERIPHERAL to #ifdef peripheral
# side support ... OTG needs both roles
config USB_MUSB_PERIPHERAL
depends on USB_GADGET
bool "USB Peripheral (gadget stack)"
select USB_GADGET_MUSB_HDRC
help
Say Y here if your system supports the USB peripheral role.
If it has a USB "B" (squarish), "Mini-B", or "Mini-AB"
connector, it supports the peripheral role.
(With a "Mini-AB" connector, you should enable USB OTG.)
config USB_MUSB_OTG
depends on USB && USB_GADGET && PM && EXPERIMENTAL
bool "Both host and peripheral: USB OTG (On The Go) Device"
select USB_GADGET_MUSB_HDRC
select USB_OTG
help
The most notable feature of USB OTG is support for a
"Dual-Role" device, which can act as either a device
or a host. The initial role choice can be changed
later, when two dual-role devices talk to each other.
At this writing, the OTG support in this driver is incomplete,
omitting the mandatory HNP or SRP protocols. However, some
of the cable based role switching works. (That is, grounding
the ID pin switches the controller to host mode, while leaving
it floating leaves it in peripheral mode.)
Select this if your system has a Mini-AB connector, or
to simplify certain kinds of configuration.
To implement your OTG Targeted Peripherals List (TPL), enable
USB_OTG_WHITELIST and update "drivers/usb/core/otg_whitelist.h"
to match your requirements.
endchoice
# enable peripheral support (including with OTG)
config USB_GADGET_MUSB_HDRC
bool
depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG)
# default y
# select USB_GADGET_DUALSPEED
# select USB_GADGET_SELECTED
# enables host support (including with OTG)
config USB_MUSB_HDRC_HCD
bool
depends on USB_MUSB_HDRC && (USB_MUSB_HOST || USB_MUSB_OTG)
select USB_OTG if USB_GADGET_MUSB_HDRC
default y
config MUSB_PIO_ONLY config MUSB_PIO_ONLY
bool 'Disable DMA (always use PIO)' bool 'Disable DMA (always use PIO)'
depends on USB_MUSB_HDRC depends on USB_MUSB_HDRC
......
...@@ -6,8 +6,8 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o ...@@ -6,8 +6,8 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
musb_hdrc-y := musb_core.o musb_hdrc-y := musb_core.o
musb_hdrc-$(CONFIG_USB_GADGET_MUSB_HDRC) += musb_gadget_ep0.o musb_gadget.o musb_hdrc-y += musb_gadget_ep0.o musb_gadget.o
musb_hdrc-$(CONFIG_USB_MUSB_HDRC_HCD) += musb_virthub.o musb_host.o musb_hdrc-y += musb_virthub.o musb_host.o
musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o
# Hardware Glue Layer # Hardware Glue Layer
......
...@@ -124,11 +124,7 @@ static void am35x_musb_disable(struct musb *musb) ...@@ -124,11 +124,7 @@ static void am35x_musb_disable(struct musb *musb)
musb_writel(reg_base, USB_END_OF_INTR_REG, 0); musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
} }
#ifdef CONFIG_USB_MUSB_HDRC_HCD
#define portstate(stmt) stmt #define portstate(stmt) stmt
#else
#define portstate(stmt)
#endif
static void am35x_musb_set_vbus(struct musb *musb, int is_on) static void am35x_musb_set_vbus(struct musb *musb, int is_on)
{ {
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
* So, need to either use silicon v0.2+ or disable DMA mode in MUSB. * So, need to either use silicon v0.2+ or disable DMA mode in MUSB.
*/ */
#if ANOMALY_05000380 && defined(CONFIG_BF52x) && \ #if ANOMALY_05000380 && defined(CONFIG_BF52x) && \
defined(CONFIG_USB_MUSB_HDRC) && !defined(CONFIG_MUSB_PIO_ONLY) !defined(CONFIG_MUSB_PIO_ONLY)
# error "Please use PIO mode in MUSB driver on bf52x chip v0.0 and v0.1" # error "Please use PIO mode in MUSB driver on bf52x chip v0.0 and v0.1"
#endif #endif
......
...@@ -172,11 +172,7 @@ static void da8xx_musb_disable(struct musb *musb) ...@@ -172,11 +172,7 @@ static void da8xx_musb_disable(struct musb *musb)
musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0); musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
} }
#ifdef CONFIG_USB_MUSB_HDRC_HCD #define portstate(stmt) stmt
#define portstate(stmt) stmt
#else
#define portstate(stmt)
#endif
static void da8xx_musb_set_vbus(struct musb *musb, int is_on) static void da8xx_musb_set_vbus(struct musb *musb, int is_on)
{ {
...@@ -397,21 +393,15 @@ static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode) ...@@ -397,21 +393,15 @@ static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode)
cfgchip2 &= ~CFGCHIP2_OTGMODE; cfgchip2 &= ~CFGCHIP2_OTGMODE;
switch (musb_mode) { switch (musb_mode) {
#ifdef CONFIG_USB_MUSB_HDRC_HCD
case MUSB_HOST: /* Force VBUS valid, ID = 0 */ case MUSB_HOST: /* Force VBUS valid, ID = 0 */
cfgchip2 |= CFGCHIP2_FORCE_HOST; cfgchip2 |= CFGCHIP2_FORCE_HOST;
break; break;
#endif
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */ case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */
cfgchip2 |= CFGCHIP2_FORCE_DEVICE; cfgchip2 |= CFGCHIP2_FORCE_DEVICE;
break; break;
#endif
#ifdef CONFIG_USB_MUSB_OTG
case MUSB_OTG: /* Don't override the VBUS/ID comparators */ case MUSB_OTG: /* Don't override the VBUS/ID comparators */
cfgchip2 |= CFGCHIP2_NO_OVERRIDE; cfgchip2 |= CFGCHIP2_NO_OVERRIDE;
break; break;
#endif
default: default:
dev_dbg(musb->controller, "Trying to set unsupported mode %u\n", musb_mode); dev_dbg(musb->controller, "Trying to set unsupported mode %u\n", musb_mode);
} }
......
...@@ -143,12 +143,7 @@ static void davinci_musb_disable(struct musb *musb) ...@@ -143,12 +143,7 @@ static void davinci_musb_disable(struct musb *musb)
} }
#ifdef CONFIG_USB_MUSB_HDRC_HCD
#define portstate(stmt) stmt #define portstate(stmt) stmt
#else
#define portstate(stmt)
#endif
/* /*
* VBUS SWITCHING IS BOARD-SPECIFIC ... at least for the DM6446 EVM, * VBUS SWITCHING IS BOARD-SPECIFIC ... at least for the DM6446 EVM,
......
This diff is collapsed.
...@@ -72,10 +72,6 @@ struct musb_ep; ...@@ -72,10 +72,6 @@ struct musb_ep;
#include <linux/usb/hcd.h> #include <linux/usb/hcd.h>
#include "musb_host.h" #include "musb_host.h"
#ifdef CONFIG_USB_MUSB_OTG
#define is_peripheral_enabled(musb) ((musb)->board_mode != MUSB_HOST) #define is_peripheral_enabled(musb) ((musb)->board_mode != MUSB_HOST)
#define is_host_enabled(musb) ((musb)->board_mode != MUSB_PERIPHERAL) #define is_host_enabled(musb) ((musb)->board_mode != MUSB_PERIPHERAL)
#define is_otg_enabled(musb) ((musb)->board_mode == MUSB_OTG) #define is_otg_enabled(musb) ((musb)->board_mode == MUSB_OTG)
...@@ -86,24 +82,6 @@ struct musb_ep; ...@@ -86,24 +82,6 @@ struct musb_ep;
#define is_peripheral_active(m) (!(m)->is_host) #define is_peripheral_active(m) (!(m)->is_host)
#define is_host_active(m) ((m)->is_host) #define is_host_active(m) ((m)->is_host)
#else
#define is_peripheral_enabled(musb) is_peripheral_capable()
#define is_host_enabled(musb) is_host_capable()
#define is_otg_enabled(musb) 0
#define is_peripheral_active(musb) is_peripheral_capable()
#define is_host_active(musb) is_host_capable()
#endif
#if defined(CONFIG_USB_MUSB_OTG) || defined(CONFIG_USB_MUSB_PERIPHERAL)
/* for some reason, the "select USB_GADGET_MUSB_HDRC" doesn't always
* override that choice selection (often USB_GADGET_DUMMY_HCD).
*/
#ifndef CONFIG_USB_GADGET_MUSB_HDRC
#error bogus Kconfig output ... select CONFIG_USB_GADGET_MUSB_HDRC
#endif
#endif /* need MUSB gadget selection */
#ifndef CONFIG_HAVE_CLK #ifndef CONFIG_HAVE_CLK
/* Dummy stub for clk framework */ /* Dummy stub for clk framework */
#define clk_get(dev, id) NULL #define clk_get(dev, id) NULL
...@@ -119,8 +97,6 @@ struct musb_ep; ...@@ -119,8 +97,6 @@ struct musb_ep;
/****************************** PERIPHERAL ROLE *****************************/ /****************************** PERIPHERAL ROLE *****************************/
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
#define is_peripheral_capable() (1) #define is_peripheral_capable() (1)
extern irqreturn_t musb_g_ep0_irq(struct musb *); extern irqreturn_t musb_g_ep0_irq(struct musb *);
...@@ -132,40 +108,14 @@ extern void musb_g_resume(struct musb *); ...@@ -132,40 +108,14 @@ extern void musb_g_resume(struct musb *);
extern void musb_g_wakeup(struct musb *); extern void musb_g_wakeup(struct musb *);
extern void musb_g_disconnect(struct musb *); extern void musb_g_disconnect(struct musb *);
#else
#define is_peripheral_capable() (0)
static inline irqreturn_t musb_g_ep0_irq(struct musb *m) { return IRQ_NONE; }
static inline void musb_g_reset(struct musb *m) {}
static inline void musb_g_suspend(struct musb *m) {}
static inline void musb_g_resume(struct musb *m) {}
static inline void musb_g_wakeup(struct musb *m) {}
static inline void musb_g_disconnect(struct musb *m) {}
#endif
/****************************** HOST ROLE ***********************************/ /****************************** HOST ROLE ***********************************/
#ifdef CONFIG_USB_MUSB_HDRC_HCD
#define is_host_capable() (1) #define is_host_capable() (1)
extern irqreturn_t musb_h_ep0_irq(struct musb *); extern irqreturn_t musb_h_ep0_irq(struct musb *);
extern void musb_host_tx(struct musb *, u8); extern void musb_host_tx(struct musb *, u8);
extern void musb_host_rx(struct musb *, u8); extern void musb_host_rx(struct musb *, u8);
#else
#define is_host_capable() (0)
static inline irqreturn_t musb_h_ep0_irq(struct musb *m) { return IRQ_NONE; }
static inline void musb_host_tx(struct musb *m, u8 e) {}
static inline void musb_host_rx(struct musb *m, u8 e) {}
#endif
/****************************** CONSTANTS ********************************/ /****************************** CONSTANTS ********************************/
#ifndef MUSB_C_NUM_EPS #ifndef MUSB_C_NUM_EPS
...@@ -315,7 +265,6 @@ struct musb_hw_ep { ...@@ -315,7 +265,6 @@ struct musb_hw_ep {
void __iomem *fifo_sync_va; void __iomem *fifo_sync_va;
#endif #endif
#ifdef CONFIG_USB_MUSB_HDRC_HCD
void __iomem *target_regs; void __iomem *target_regs;
/* currently scheduled peripheral endpoint */ /* currently scheduled peripheral endpoint */
...@@ -324,31 +273,20 @@ struct musb_hw_ep { ...@@ -324,31 +273,20 @@ struct musb_hw_ep {
u8 rx_reinit; u8 rx_reinit;
u8 tx_reinit; u8 tx_reinit;
#endif
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
/* peripheral side */ /* peripheral side */
struct musb_ep ep_in; /* TX */ struct musb_ep ep_in; /* TX */
struct musb_ep ep_out; /* RX */ struct musb_ep ep_out; /* RX */
#endif
}; };
static inline struct musb_request *next_in_request(struct musb_hw_ep *hw_ep) static inline struct musb_request *next_in_request(struct musb_hw_ep *hw_ep)
{ {
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
return next_request(&hw_ep->ep_in); return next_request(&hw_ep->ep_in);
#else
return NULL;
#endif
} }
static inline struct musb_request *next_out_request(struct musb_hw_ep *hw_ep) static inline struct musb_request *next_out_request(struct musb_hw_ep *hw_ep)
{ {
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
return next_request(&hw_ep->ep_out); return next_request(&hw_ep->ep_out);
#else
return NULL;
#endif
} }
struct musb_csr_regs { struct musb_csr_regs {
...@@ -393,7 +331,6 @@ struct musb { ...@@ -393,7 +331,6 @@ struct musb {
u32 port1_status; u32 port1_status;
#ifdef CONFIG_USB_MUSB_HDRC_HCD
unsigned long rh_timer; unsigned long rh_timer;
enum musb_h_ep0_state ep0_stage; enum musb_h_ep0_state ep0_stage;
...@@ -411,7 +348,6 @@ struct musb { ...@@ -411,7 +348,6 @@ struct musb {
struct list_head out_bulk; /* of musb_qh */ struct list_head out_bulk; /* of musb_qh */
struct timer_list otg_timer; struct timer_list otg_timer;
#endif
struct notifier_block nb; struct notifier_block nb;
struct dma_controller *dma_controller; struct dma_controller *dma_controller;
...@@ -472,7 +408,6 @@ struct musb { ...@@ -472,7 +408,6 @@ struct musb {
#define can_bulk_combine(musb,type) \ #define can_bulk_combine(musb,type) \
(((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_combine) (((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_combine)
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
/* is_suspended means USB B_PERIPHERAL suspend */ /* is_suspended means USB B_PERIPHERAL suspend */
unsigned is_suspended:1; unsigned is_suspended:1;
...@@ -496,7 +431,6 @@ struct musb { ...@@ -496,7 +431,6 @@ struct musb {
enum musb_g_ep0_state ep0_state; enum musb_g_ep0_state ep0_state;
struct usb_gadget g; /* the gadget */ struct usb_gadget g; /* the gadget */
struct usb_gadget_driver *gadget_driver; /* its driver */ struct usb_gadget_driver *gadget_driver; /* its driver */
#endif
/* /*
* FIXME: Remove this flag. * FIXME: Remove this flag.
...@@ -518,12 +452,10 @@ struct musb { ...@@ -518,12 +452,10 @@ struct musb {
#endif #endif
}; };
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
static inline struct musb *gadget_to_musb(struct usb_gadget *g) static inline struct musb *gadget_to_musb(struct usb_gadget *g)
{ {
return container_of(g, struct musb, g); return container_of(g, struct musb, g);
} }
#endif
#ifdef CONFIG_BLACKFIN #ifdef CONFIG_BLACKFIN
static inline int musb_read_fifosize(struct musb *musb, static inline int musb_read_fifosize(struct musb *musb,
......
...@@ -2048,9 +2048,7 @@ static int musb_gadget_stop(struct usb_gadget_driver *driver) ...@@ -2048,9 +2048,7 @@ static int musb_gadget_stop(struct usb_gadget_driver *driver)
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
#ifdef CONFIG_USB_MUSB_OTG
musb_hnp_stop(musb); musb_hnp_stop(musb);
#endif
(void) musb_gadget_vbus_draw(&musb->g, 0); (void) musb_gadget_vbus_draw(&musb->g, 0);
...@@ -2171,7 +2169,6 @@ void musb_g_disconnect(struct musb *musb) ...@@ -2171,7 +2169,6 @@ void musb_g_disconnect(struct musb *musb)
switch (musb->xceiv->state) { switch (musb->xceiv->state) {
default: default:
#ifdef CONFIG_USB_MUSB_OTG
dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n", dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n",
otg_state_string(musb->xceiv->state)); otg_state_string(musb->xceiv->state));
musb->xceiv->state = OTG_STATE_A_IDLE; musb->xceiv->state = OTG_STATE_A_IDLE;
...@@ -2183,7 +2180,6 @@ void musb_g_disconnect(struct musb *musb) ...@@ -2183,7 +2180,6 @@ void musb_g_disconnect(struct musb *musb)
break; break;
case OTG_STATE_B_WAIT_ACON: case OTG_STATE_B_WAIT_ACON:
case OTG_STATE_B_HOST: case OTG_STATE_B_HOST:
#endif
case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_PERIPHERAL:
case OTG_STATE_B_IDLE: case OTG_STATE_B_IDLE:
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->state = OTG_STATE_B_IDLE;
......
...@@ -88,7 +88,6 @@ static int service_tx_status_request( ...@@ -88,7 +88,6 @@ static int service_tx_status_request(
case USB_RECIP_DEVICE: case USB_RECIP_DEVICE:
result[0] = musb->is_self_powered << USB_DEVICE_SELF_POWERED; result[0] = musb->is_self_powered << USB_DEVICE_SELF_POWERED;
result[0] |= musb->may_wakeup << USB_DEVICE_REMOTE_WAKEUP; result[0] |= musb->may_wakeup << USB_DEVICE_REMOTE_WAKEUP;
#ifdef CONFIG_USB_MUSB_OTG
if (musb->g.is_otg) { if (musb->g.is_otg) {
result[0] |= musb->g.b_hnp_enable result[0] |= musb->g.b_hnp_enable
<< USB_DEVICE_B_HNP_ENABLE; << USB_DEVICE_B_HNP_ENABLE;
...@@ -97,7 +96,6 @@ static int service_tx_status_request( ...@@ -97,7 +96,6 @@ static int service_tx_status_request(
result[0] |= musb->g.a_hnp_support result[0] |= musb->g.a_hnp_support
<< USB_DEVICE_A_HNP_SUPPORT; << USB_DEVICE_A_HNP_SUPPORT;
} }
#endif
break; break;
case USB_RECIP_INTERFACE: case USB_RECIP_INTERFACE:
...@@ -392,7 +390,6 @@ __acquires(musb->lock) ...@@ -392,7 +390,6 @@ __acquires(musb->lock)
if (handled > 0) if (handled > 0)
musb->test_mode = true; musb->test_mode = true;
break; break;
#ifdef CONFIG_USB_MUSB_OTG
case USB_DEVICE_B_HNP_ENABLE: case USB_DEVICE_B_HNP_ENABLE:
if (!musb->g.is_otg) if (!musb->g.is_otg)
goto stall; goto stall;
...@@ -409,7 +406,6 @@ __acquires(musb->lock) ...@@ -409,7 +406,6 @@ __acquires(musb->lock)
goto stall; goto stall;
musb->g.a_alt_hnp_support = 1; musb->g.a_alt_hnp_support = 1;
break; break;
#endif
case USB_DEVICE_DEBUG_MODE: case USB_DEVICE_DEBUG_MODE:
handled = 0; handled = 0;
break; break;
......
...@@ -95,7 +95,6 @@ extern const struct hc_driver musb_hc_driver; ...@@ -95,7 +95,6 @@ extern const struct hc_driver musb_hc_driver;
static inline struct urb *next_urb(struct musb_qh *qh) static inline struct urb *next_urb(struct musb_qh *qh)
{ {
#ifdef CONFIG_USB_MUSB_HDRC_HCD
struct list_head *queue; struct list_head *queue;
if (!qh) if (!qh)
...@@ -104,9 +103,6 @@ static inline struct urb *next_urb(struct musb_qh *qh) ...@@ -104,9 +103,6 @@ static inline struct urb *next_urb(struct musb_qh *qh)
if (list_empty(queue)) if (list_empty(queue))
return NULL; return NULL;
return list_entry(queue->next, struct urb, urb_list); return list_entry(queue->next, struct urb, urb_list);
#else
return NULL;
#endif
} }
#endif /* _MUSB_HOST_H */ #endif /* _MUSB_HOST_H */
...@@ -88,14 +88,12 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) ...@@ -88,14 +88,12 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend)
OTG_TIME_A_AIDL_BDIS)); OTG_TIME_A_AIDL_BDIS));
musb_platform_try_idle(musb, 0); musb_platform_try_idle(musb, 0);
break; break;
#ifdef CONFIG_USB_MUSB_OTG
case OTG_STATE_B_HOST: case OTG_STATE_B_HOST:
musb->xceiv->state = OTG_STATE_B_WAIT_ACON; musb->xceiv->state = OTG_STATE_B_WAIT_ACON;
musb->is_active = is_otg_enabled(musb) musb->is_active = is_otg_enabled(musb)
&& musb->xceiv->host->b_hnp_enable; && musb->xceiv->host->b_hnp_enable;
musb_platform_try_idle(musb, 0); musb_platform_try_idle(musb, 0);
break; break;
#endif
default: default:
dev_dbg(musb->controller, "bogus rh suspend? %s\n", dev_dbg(musb->controller, "bogus rh suspend? %s\n",
otg_state_string(musb->xceiv->state)); otg_state_string(musb->xceiv->state));
...@@ -118,13 +116,11 @@ static void musb_port_reset(struct musb *musb, bool do_reset) ...@@ -118,13 +116,11 @@ static void musb_port_reset(struct musb *musb, bool do_reset)
u8 power; u8 power;
void __iomem *mbase = musb->mregs; void __iomem *mbase = musb->mregs;
#ifdef CONFIG_USB_MUSB_OTG
if (musb->xceiv->state == OTG_STATE_B_IDLE) { if (musb->xceiv->state == OTG_STATE_B_IDLE) {
dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n"); dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n");
musb->port1_status &= ~USB_PORT_STAT_RESET; musb->port1_status &= ~USB_PORT_STAT_RESET;
return; return;
} }
#endif
if (!is_host_active(musb)) if (!is_host_active(musb))
return; return;
...@@ -191,14 +187,12 @@ void musb_root_disconnect(struct musb *musb) ...@@ -191,14 +187,12 @@ void musb_root_disconnect(struct musb *musb)
switch (musb->xceiv->state) { switch (musb->xceiv->state) {
case OTG_STATE_A_SUSPEND: case OTG_STATE_A_SUSPEND:
#ifdef CONFIG_USB_MUSB_OTG
if (is_otg_enabled(musb) if (is_otg_enabled(musb)
&& musb->xceiv->host->b_hnp_enable) { && musb->xceiv->host->b_hnp_enable) {
musb->xceiv->state = OTG_STATE_A_PERIPHERAL; musb->xceiv->state = OTG_STATE_A_PERIPHERAL;
musb->g.is_a_peripheral = 1; musb->g.is_a_peripheral = 1;
break; break;
} }
#endif
/* FALLTHROUGH */ /* FALLTHROUGH */
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
musb->xceiv->state = OTG_STATE_A_WAIT_BCON; musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
......
...@@ -51,9 +51,7 @@ static void musb_do_idle(unsigned long _musb) ...@@ -51,9 +51,7 @@ static void musb_do_idle(unsigned long _musb)
{ {
struct musb *musb = (void *)_musb; struct musb *musb = (void *)_musb;
unsigned long flags; unsigned long flags;
#ifdef CONFIG_USB_MUSB_HDRC_HCD
u8 power; u8 power;
#endif
u8 devctl; u8 devctl;
spin_lock_irqsave(&musb->lock, flags); spin_lock_irqsave(&musb->lock, flags);
...@@ -70,7 +68,6 @@ static void musb_do_idle(unsigned long _musb) ...@@ -70,7 +68,6 @@ static void musb_do_idle(unsigned long _musb)
MUSB_HST_MODE(musb); MUSB_HST_MODE(musb);
} }
break; break;
#ifdef CONFIG_USB_MUSB_HDRC_HCD
case OTG_STATE_A_SUSPEND: case OTG_STATE_A_SUSPEND:
/* finish RESUME signaling? */ /* finish RESUME signaling? */
if (musb->port1_status & MUSB_PORT_STAT_RESUME) { if (musb->port1_status & MUSB_PORT_STAT_RESUME) {
...@@ -87,15 +84,12 @@ static void musb_do_idle(unsigned long _musb) ...@@ -87,15 +84,12 @@ static void musb_do_idle(unsigned long _musb)
musb->xceiv->state = OTG_STATE_A_HOST; musb->xceiv->state = OTG_STATE_A_HOST;
} }
break; break;
#endif
#ifdef CONFIG_USB_MUSB_HDRC_HCD
case OTG_STATE_A_HOST: case OTG_STATE_A_HOST:
devctl = musb_readb(musb->mregs, MUSB_DEVCTL); devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
if (devctl & MUSB_DEVCTL_BDEVICE) if (devctl & MUSB_DEVCTL_BDEVICE)
musb->xceiv->state = OTG_STATE_B_IDLE; musb->xceiv->state = OTG_STATE_B_IDLE;
else else
musb->xceiv->state = OTG_STATE_A_WAIT_BCON; musb->xceiv->state = OTG_STATE_A_WAIT_BCON;
#endif
default: default:
break; break;
} }
...@@ -243,13 +237,11 @@ static int musb_otg_notifications(struct notifier_block *nb, ...@@ -243,13 +237,11 @@ static int musb_otg_notifications(struct notifier_block *nb,
dev_dbg(musb->controller, "ID GND\n"); dev_dbg(musb->controller, "ID GND\n");
if (is_otg_enabled(musb)) { if (is_otg_enabled(musb)) {
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
if (musb->gadget_driver) { if (musb->gadget_driver) {
pm_runtime_get_sync(musb->controller); pm_runtime_get_sync(musb->controller);
otg_init(musb->xceiv); otg_init(musb->xceiv);
omap2430_musb_set_vbus(musb, 1); omap2430_musb_set_vbus(musb, 1);
} }
#endif
} else { } else {
pm_runtime_get_sync(musb->controller); pm_runtime_get_sync(musb->controller);
otg_init(musb->xceiv); otg_init(musb->xceiv);
...@@ -260,21 +252,16 @@ static int musb_otg_notifications(struct notifier_block *nb, ...@@ -260,21 +252,16 @@ static int musb_otg_notifications(struct notifier_block *nb,
case USB_EVENT_VBUS: case USB_EVENT_VBUS:
dev_dbg(musb->controller, "VBUS Connect\n"); dev_dbg(musb->controller, "VBUS Connect\n");
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
if (musb->gadget_driver) if (musb->gadget_driver)
pm_runtime_get_sync(musb->controller); pm_runtime_get_sync(musb->controller);
#endif
otg_init(musb->xceiv); otg_init(musb->xceiv);
break; break;
case USB_EVENT_NONE: case USB_EVENT_NONE:
dev_dbg(musb->controller, "VBUS Disconnect\n"); dev_dbg(musb->controller, "VBUS Disconnect\n");
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) if (is_otg_enabled(musb) || is_peripheral_enabled(musb))
if (musb->gadget_driver) if (musb->gadget_driver) {
#endif
{
pm_runtime_mark_last_busy(musb->controller); pm_runtime_mark_last_busy(musb->controller);
pm_runtime_put_autosuspend(musb->controller); pm_runtime_put_autosuspend(musb->controller);
} }
......
...@@ -269,8 +269,6 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf) ...@@ -269,8 +269,6 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf)
static struct musb *the_musb; static struct musb *the_musb;
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
/* This is used by gadget drivers, and OTG transceiver logic, allowing /* This is used by gadget drivers, and OTG transceiver logic, allowing
* at most mA current to be drawn from VBUS during a Default-B session * at most mA current to be drawn from VBUS during a Default-B session
* (that is, while VBUS exceeds 4.4V). In Default-A (including pure host * (that is, while VBUS exceeds 4.4V). In Default-A (including pure host
...@@ -310,10 +308,6 @@ static int tusb_draw_power(struct otg_transceiver *x, unsigned mA) ...@@ -310,10 +308,6 @@ static int tusb_draw_power(struct otg_transceiver *x, unsigned mA)
return 0; return 0;
} }
#else
#define tusb_draw_power NULL
#endif
/* workaround for issue 13: change clock during chip idle /* workaround for issue 13: change clock during chip idle
* (to be fixed in rev3 silicon) ... symptoms include disconnect * (to be fixed in rev3 silicon) ... symptoms include disconnect
* or looping suspend/resume cycles * or looping suspend/resume cycles
...@@ -440,19 +434,15 @@ static void musb_do_idle(unsigned long _musb) ...@@ -440,19 +434,15 @@ static void musb_do_idle(unsigned long _musb)
if (is_host_active(musb) && (musb->port1_status >> 16)) if (is_host_active(musb) && (musb->port1_status >> 16))
goto done; goto done;
#ifdef CONFIG_USB_GADGET_MUSB_HDRC if (is_peripheral_enabled(musb) && !musb->gadget_driver) {
if (is_peripheral_enabled(musb) && !musb->gadget_driver)
wakeups = 0; wakeups = 0;
else { } else {
wakeups = TUSB_PRCM_WHOSTDISCON wakeups = TUSB_PRCM_WHOSTDISCON
| TUSB_PRCM_WBUS | TUSB_PRCM_WBUS
| TUSB_PRCM_WVBUS; | TUSB_PRCM_WVBUS;
if (is_otg_enabled(musb)) if (is_otg_enabled(musb))
wakeups |= TUSB_PRCM_WID; wakeups |= TUSB_PRCM_WID;
} }
#else
wakeups = TUSB_PRCM_WHOSTDISCON | TUSB_PRCM_WBUS;
#endif
tusb_allow_idle(musb, wakeups); tusb_allow_idle(musb, wakeups);
} }
done: done:
...@@ -610,30 +600,22 @@ static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) ...@@ -610,30 +600,22 @@ static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode)
switch (musb_mode) { switch (musb_mode) {
#ifdef CONFIG_USB_MUSB_HDRC_HCD
case MUSB_HOST: /* Disable PHY ID detect, ground ID */ case MUSB_HOST: /* Disable PHY ID detect, ground ID */
phy_otg_ctrl &= ~TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ctrl &= ~TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP;
phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP;
dev_conf |= TUSB_DEV_CONF_ID_SEL; dev_conf |= TUSB_DEV_CONF_ID_SEL;
dev_conf &= ~TUSB_DEV_CONF_SOFT_ID; dev_conf &= ~TUSB_DEV_CONF_SOFT_ID;
break; break;
#endif
#ifdef CONFIG_USB_GADGET_MUSB_HDRC
case MUSB_PERIPHERAL: /* Disable PHY ID detect, keep ID pull-up on */ case MUSB_PERIPHERAL: /* Disable PHY ID detect, keep ID pull-up on */
phy_otg_ctrl |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ctrl |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP;
phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP;
dev_conf |= (TUSB_DEV_CONF_ID_SEL | TUSB_DEV_CONF_SOFT_ID); dev_conf |= (TUSB_DEV_CONF_ID_SEL | TUSB_DEV_CONF_SOFT_ID);
break; break;
#endif
#ifdef CONFIG_USB_MUSB_OTG
case MUSB_OTG: /* Use PHY ID detection */ case MUSB_OTG: /* Use PHY ID detection */
phy_otg_ctrl |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ctrl |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP;
phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP;
dev_conf &= ~(TUSB_DEV_CONF_ID_SEL | TUSB_DEV_CONF_SOFT_ID); dev_conf &= ~(TUSB_DEV_CONF_ID_SEL | TUSB_DEV_CONF_SOFT_ID);
break; break;
#endif
default: default:
dev_dbg(musb->controller, "Trying to set mode %i\n", musb_mode); dev_dbg(musb->controller, "Trying to set mode %i\n", musb_mode);
...@@ -684,7 +666,6 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -684,7 +666,6 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
/* B-dev state machine: no vbus ~= disconnect */ /* B-dev state machine: no vbus ~= disconnect */
if ((is_otg_enabled(musb) && !musb->xceiv->default_a) if ((is_otg_enabled(musb) && !musb->xceiv->default_a)
|| !is_host_enabled(musb)) { || !is_host_enabled(musb)) {
#ifdef CONFIG_USB_MUSB_HDRC_HCD
/* ? musb_root_disconnect(musb); */ /* ? musb_root_disconnect(musb); */
musb->port1_status &= musb->port1_status &=
~(USB_PORT_STAT_CONNECTION ~(USB_PORT_STAT_CONNECTION
...@@ -693,7 +674,6 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) ...@@ -693,7 +674,6 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase)
| USB_PORT_STAT_HIGH_SPEED | USB_PORT_STAT_HIGH_SPEED
| USB_PORT_STAT_TEST | USB_PORT_STAT_TEST
); );
#endif
if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) { if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) {
dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n"); dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment