Skip to content

Commit 2cc65fe

Browse files
zonqueFelipe Balbi
authored andcommitted
usb: musb: add musb_host_setup() and musb_host_cleanup()
This patch re-introduces the bits that are necessary to use the musb controller in host mode. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Peter Korsgaard <jacmet@sunsite.dk> Signed-off-by: Felipe Balbi <balbi@ti.com>
1 parent b7b741e commit 2cc65fe

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎drivers/usb/musb/musb_core.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ static void musb_shutdown(struct platform_device *pdev)
953953

954954
pm_runtime_get_sync(musb->controller);
955955

956+
musb_host_cleanup(musb);
956957
musb_gadget_cleanup(musb);
957958

958959
spin_lock_irqsave(&musb->lock, flags);
@@ -1902,6 +1903,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
19021903
musb->xceiv->state = OTG_STATE_B_IDLE;
19031904
}
19041905

1906+
status = musb_host_setup(musb, plat->power);
1907+
if (status < 0)
1908+
goto fail3;
1909+
19051910
status = musb_gadget_setup(musb);
19061911

19071912
if (status < 0)

‎drivers/usb/musb/musb_host.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,6 +2640,27 @@ void musb_host_free(struct musb *musb)
26402640
usb_put_hcd(musb->hcd);
26412641
}
26422642

2643+
int musb_host_setup(struct musb *musb, int power_budget)
2644+
{
2645+
int ret;
2646+
struct usb_hcd *hcd = musb->hcd;
2647+
2648+
MUSB_HST_MODE(musb);
2649+
musb->xceiv->otg->default_a = 1;
2650+
musb->xceiv->state = OTG_STATE_A_IDLE;
2651+
2652+
otg_set_host(musb->xceiv->otg, &hcd->self);
2653+
hcd->self.otg_port = 1;
2654+
musb->xceiv->otg->host = &hcd->self;
2655+
hcd->power_budget = 2 * (power_budget ? : 250);
2656+
2657+
ret = usb_add_hcd(hcd, 0, 0);
2658+
if (ret < 0)
2659+
return ret;
2660+
2661+
return 0;
2662+
}
2663+
26432664
void musb_host_resume_root_hub(struct musb *musb)
26442665
{
26452666
usb_hcd_resume_root_hub(musb->hcd);

‎drivers/usb/musb/musb_host.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ static inline struct musb_qh *first_qh(struct list_head *q)
8181
extern struct musb *hcd_to_musb(struct usb_hcd *);
8282
extern irqreturn_t musb_h_ep0_irq(struct musb *);
8383
extern int musb_host_alloc(struct musb *);
84+
extern int musb_host_setup(struct musb *, int);
85+
extern void musb_host_cleanup(struct musb *);
8486
extern void musb_host_tx(struct musb *, u8);
8587
extern void musb_host_rx(struct musb *, u8);
8688
extern void musb_root_disconnect(struct musb *musb);
@@ -107,6 +109,12 @@ static inline int musb_host_alloc(struct musb *musb)
107109
return 0;
108110
}
109111

112+
static inline int musb_host_setup(struct musb *musb, int power_budget)
113+
{
114+
return 0;
115+
}
116+
117+
static inline void musb_host_cleanup(struct musb *musb) {}
110118
static inline void musb_host_free(struct musb *musb) {}
111119
static inline void musb_host_tx(struct musb *musb, u8 epnum) {}
112120
static inline void musb_host_rx(struct musb *musb, u8 epnum) {}

0 commit comments

Comments
 (0)