else
musb->io.set_toggle = musb_default_set_toggle;
- if (!musb->xceiv->io_ops) {
+ if (IS_ENABLED(CONFIG_USB_PHY) && musb->xceiv && !musb->xceiv->io_ops) {
musb->xceiv->io_dev = musb->controller;
musb->xceiv->io_priv = musb->mregs;
musb->xceiv->io_ops = &musb_ulpi_access;
struct usb_phy *xceiv;
struct phy *phy;
+ enum usb_otg_state otg_state;
+
int nIrq;
unsigned irq_wake:1;
static inline void musb_set_state(struct musb *musb,
enum usb_otg_state otg_state)
{
- musb->xceiv->otg->state = otg_state;
+ if (musb->xceiv)
+ musb->xceiv->otg->state = otg_state;
+ else
+ musb->otg_state = otg_state;
}
static inline enum usb_otg_state musb_get_state(struct musb *musb)
{
- return musb->xceiv->otg->state;
+ if (musb->xceiv)
+ return musb->xceiv->otg->state;
+
+ return musb->otg_state;
}
static inline const char *musb_otg_state_string(struct musb *musb)
break;
}
- spin_unlock_irqrestore(&musb->lock, flags);
- otg_start_srp(musb->xceiv->otg);
- spin_lock_irqsave(&musb->lock, flags);
+ if (musb->xceiv) {
+ spin_unlock_irqrestore(&musb->lock, flags);
+ otg_start_srp(musb->xceiv->otg);
+ spin_lock_irqsave(&musb->lock, flags);
+ }
/* Block idling for at least 1s */
musb_platform_try_idle(musb,
{
struct musb *musb = gadget_to_musb(gadget);
- if (!musb->xceiv->set_power)
+ if (!musb->xceiv || !musb->xceiv->set_power)
return -EOPNOTSUPP;
return usb_phy_set_power(musb->xceiv, mA);
}
struct usb_gadget_driver *driver)
{
struct musb *musb = gadget_to_musb(g);
- struct usb_otg *otg = musb->xceiv->otg;
unsigned long flags;
int retval = 0;
spin_lock_irqsave(&musb->lock, flags);
musb->is_active = 1;
- otg_set_peripheral(otg, &musb->g);
+ if (musb->xceiv)
+ otg_set_peripheral(musb->xceiv->otg, &musb->g);
+
musb_set_state(musb, OTG_STATE_B_IDLE);
spin_unlock_irqrestore(&musb->lock, flags);
* handles power budgeting ... this way also
* ensures HdrcStart is indirectly called.
*/
- if (musb->xceiv->last_event == USB_EVENT_ID)
+ if (musb->xceiv && musb->xceiv->last_event == USB_EVENT_ID)
musb_platform_set_vbus(musb, 1);
pm_runtime_mark_last_busy(musb->controller);
musb_set_state(musb, OTG_STATE_UNDEFINED);
musb_stop(musb);
- otg_set_peripheral(musb->xceiv->otg, NULL);
+
+ if (musb->xceiv)
+ otg_set_peripheral(musb->xceiv->otg, NULL);
musb->is_active = 0;
musb->gadget_driver = NULL;
MUSB_HST_MODE(musb);
musb_set_state(musb, OTG_STATE_A_IDLE);
}
- otg_set_host(musb->xceiv->otg, &hcd->self);
+
+ if (musb->xceiv) {
+ otg_set_host(musb->xceiv->otg, &hcd->self);
+ musb->xceiv->otg->host = &hcd->self;
+ }
+
/* don't support otg protocols */
hcd->self.otg_port = 0;
- musb->xceiv->otg->host = &hcd->self;
hcd->power_budget = 2 * (power_budget ? : 250);
hcd->skip_phy_initialization = 1;
int musb_port_suspend(struct musb *musb, bool do_suspend)
{
- struct usb_otg *otg = musb->xceiv->otg;
u8 power;
void __iomem *mbase = musb->mregs;
switch (musb_get_state(musb)) {
case OTG_STATE_A_HOST:
musb_set_state(musb, OTG_STATE_A_SUSPEND);
- musb->is_active = otg->host->b_hnp_enable;
+ musb->is_active = musb->xceiv &&
+ musb->xceiv->otg->host->b_hnp_enable;
if (musb->is_active)
mod_timer(&musb->otg_timer, jiffies
+ msecs_to_jiffies(
break;
case OTG_STATE_B_HOST:
musb_set_state(musb, OTG_STATE_B_WAIT_ACON);
- musb->is_active = otg->host->b_hnp_enable;
+ musb->is_active = musb->xceiv &&
+ musb->xceiv->otg->host->b_hnp_enable;
musb_platform_try_idle(musb, 0);
break;
default:
void musb_root_disconnect(struct musb *musb)
{
- struct usb_otg *otg = musb->xceiv->otg;
-
musb->port1_status = USB_PORT_STAT_POWER
| (USB_PORT_STAT_C_CONNECTION << 16);
switch (musb_get_state(musb)) {
case OTG_STATE_A_SUSPEND:
- if (otg->host->b_hnp_enable) {
+ if (musb->xceiv && musb->xceiv->otg->host->b_hnp_enable) {
musb_set_state(musb, OTG_STATE_A_PERIPHERAL);
musb->g.is_a_peripheral = 1;
break;