Commit 8b63229c authored by David Brownell's avatar David Brownell Committed by Tony Lindgren

musb_hdrc: Minor cleanups involving name changes

Minor cleanups involving name changes, primarily on the peripheral side:

 - musb->bMayWakeup becomes may_wakeup (camelcase bad)
 - musb->bIsSelfPowered becomes is_self_powered (camelcase bad)
 - pThis (as parameter or variable) becomes musb (camelcase bad)
 - tusb_set_power becomes tusb_draw_power (more meaningful name)
 - tusb_set_vbus becomes tusb_source_power (more meaningful name)

Also, add a flag to track if a B-Peripheral device draws any VBUS power
(currently only tusb6010 can set that).
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
parent fceaff4d
This diff is collapsed.
This diff is collapsed.
...@@ -430,8 +430,16 @@ struct musb { ...@@ -430,8 +430,16 @@ struct musb {
#endif #endif
#ifdef CONFIG_USB_GADGET_MUSB_HDRC #ifdef CONFIG_USB_GADGET_MUSB_HDRC
unsigned bIsSelfPowered:1; /* may_wakeup means remote wakeup is enabled */
unsigned bMayWakeup:1; unsigned may_wakeup:1;
/* is_self_powered is reported in device status and the
* config descriptor. is_bus_powered means B_PERIPHERAL
* draws some VBUS current; both can be true.
*/
unsigned is_self_powered:1;
unsigned is_bus_powered:1;
unsigned bSetAddress:1; unsigned bSetAddress:1;
unsigned bTestMode:1; unsigned bTestMode:1;
unsigned softconnect:1; unsigned softconnect:1;
......
...@@ -142,13 +142,15 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf) ...@@ -142,13 +142,15 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf)
} }
} }
#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
* mode), or low power Default-B sessions, something else supplies power. * mode), or low power Default-B sessions, something else supplies power.
* Caller must take care of locking. * Caller must take care of locking.
*/ */
static int tusb_set_power(struct otg_transceiver *x, unsigned mA) static int tusb_draw_power(struct otg_transceiver *x, unsigned mA)
{ {
struct musb *musb = container_of(x, struct musb, xceiv); struct musb *musb = container_of(x, struct musb, xceiv);
void __iomem *base = musb->ctrl_base; void __iomem *base = musb->ctrl_base;
...@@ -165,16 +167,23 @@ static int tusb_set_power(struct otg_transceiver *x, unsigned mA) ...@@ -165,16 +167,23 @@ static int tusb_set_power(struct otg_transceiver *x, unsigned mA)
mA = 0; mA = 0;
reg = musb_readl(base, TUSB_PRCM_MNGMT); reg = musb_readl(base, TUSB_PRCM_MNGMT);
if (mA) if (mA) {
musb->is_bus_powered = 1;
reg |= TUSB_PRCM_MNGMT_15_SW_EN | TUSB_PRCM_MNGMT_33_SW_EN; reg |= TUSB_PRCM_MNGMT_15_SW_EN | TUSB_PRCM_MNGMT_33_SW_EN;
else } else {
musb->is_bus_powered = 0;
reg &= ~(TUSB_PRCM_MNGMT_15_SW_EN | TUSB_PRCM_MNGMT_33_SW_EN); reg &= ~(TUSB_PRCM_MNGMT_15_SW_EN | TUSB_PRCM_MNGMT_33_SW_EN);
}
musb_writel(base, TUSB_PRCM_MNGMT, reg); musb_writel(base, TUSB_PRCM_MNGMT, reg);
DBG(2, "draw max %d mA VBUS\n", mA); DBG(2, "draw max %d mA VBUS\n", 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
...@@ -330,7 +339,7 @@ void musb_platform_try_idle(struct musb *musb) ...@@ -330,7 +339,7 @@ void musb_platform_try_idle(struct musb *musb)
| TUSB_DEV_OTG_TIMER_ENABLE) \ | TUSB_DEV_OTG_TIMER_ENABLE) \
: 0) : 0)
static void tusb_set_vbus(struct musb *musb, int is_on) static void tusb_source_power(struct musb *musb, int is_on)
{ {
void __iomem *base = musb->ctrl_base; void __iomem *base = musb->ctrl_base;
u32 conf, prcm, timer; u32 conf, prcm, timer;
...@@ -399,7 +408,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *base) ...@@ -399,7 +408,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *base)
default_a = is_host_enabled(musb); default_a = is_host_enabled(musb);
DBG(2, "Default-%c\n", default_a ? 'A' : 'B'); DBG(2, "Default-%c\n", default_a ? 'A' : 'B');
musb->xceiv.default_a = default_a; musb->xceiv.default_a = default_a;
tusb_set_vbus(musb, default_a); tusb_source_power(musb, default_a);
} }
/* VBUS state change */ /* VBUS state change */
...@@ -447,7 +456,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *base) ...@@ -447,7 +456,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *base)
*/ */
if (musb->vbuserr_retry) { if (musb->vbuserr_retry) {
musb->vbuserr_retry--; musb->vbuserr_retry--;
tusb_set_vbus(musb, 1); tusb_source_power(musb, 1);
} }
break; break;
default: default:
...@@ -491,12 +500,12 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *base) ...@@ -491,12 +500,12 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *base)
} else { } else {
/* REVISIT report overcurrent to hub? */ /* REVISIT report overcurrent to hub? */
ERR("vbus too slow, devctl %02x\n", devctl); ERR("vbus too slow, devctl %02x\n", devctl);
tusb_set_vbus(musb, 0); tusb_source_power(musb, 0);
} }
break; break;
case OTG_STATE_A_WAIT_BCON: case OTG_STATE_A_WAIT_BCON:
if (OTG_TIME_A_WAIT_BCON) if (OTG_TIME_A_WAIT_BCON)
tusb_set_vbus(musb, 0); tusb_source_power(musb, 0);
break; break;
case OTG_STATE_A_SUSPEND: case OTG_STATE_A_SUSPEND:
break; break;
...@@ -832,9 +841,9 @@ int __init musb_platform_init(struct musb *musb) ...@@ -832,9 +841,9 @@ int __init musb_platform_init(struct musb *musb)
musb->isr = tusb_interrupt; musb->isr = tusb_interrupt;
if (is_host_enabled(musb)) if (is_host_enabled(musb))
musb->board_set_vbus = tusb_set_vbus; musb->board_set_vbus = tusb_source_power;
if (is_peripheral_enabled(musb)) if (is_peripheral_enabled(musb))
musb->xceiv.set_power = tusb_set_power; musb->xceiv.set_power = tusb_draw_power;
setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb); setup_timer(&musb_idle_timer, musb_do_idle, (unsigned long) musb);
......
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