On Tue, Mar 6, 2012 at 11:49 AM, Heiko Stübner <heiko@xxxxxxxxx> wrote: > Am Dienstag 06 März 2012, 19:49:03 schrieb Dima Zavin: >> On Tue, Mar 6, 2012 at 2:51 AM, Heiko Stübner <heiko@xxxxxxxxx> wrote: >> > Am Mittwoch, 29. Februar 2012, 23:03:11 schrieb Heiko Stübner: >> >> Commit 9ad63986c606 (pda_power: Add support for using otg transceiver >> >> events) converted the pda-power driver to use otg events to determine >> >> the status of the power supply. >> >> >> >> As gpio-vbus didn't use otg events until now, this change breaks setups >> >> of pda-power with a gpio-vbus transceiver. >> >> >> >> This patch adds the necessary otg events and notifiers to gpio-vbus. >> >> >> >> Signed-off-by: Heiko Stuebner <heiko@xxxxxxxxx> >> > >> > I'm not sure whom to pester more with this, as usb/otg/* does not contain >> > a MAINTAINERS entry itself. But it would be cool if someone could take a >> > look at it, as the underlying problem breaks battery indication probably >> > not only on my machines. >> >> Could you describe how you use pda_power? The change only uses OTG >> events if you did not supply your own is_ac_online/is_usb_online >> callbacks from the boardfile for pda_power. Were you previously >> relying on polling? >> >> Looking closer at it, I think there may be a bug if you are relying on >> polling and not supplying your own is_XX_online callbacks. Could you >> try the attached patch? (untested/uncompiled) > > Nope, nothing to do with polling. For reference, my pda_power device can be > found on [1]. > > pda_power gets to share the vbus-irq for ac and usb with gpio-vbus. For > ac_online there is a machine-specific callback registered (not finished > yet). > > By not specifying the usb_is_online callback but enabling OTG_UTILS, the > pda_power driver uses the otg_is_online function automatically. > > Before the change > static int otg_is_usb_online(void) > { > - return (transceiver->state == OTG_STATE_B_PERIPHERAL); > + return (transceiver->last_event == USB_EVENT_VBUS || > + transceiver->last_event == USB_EVENT_ENUMERATED); > +} > > this function simply checked the otg state, which is implemented in gpio-vbus, > i.e. it sets the state on connect and disconnect. > > So, the cause of problem is not in the pda_power change itself, but in > gpio_vbus which did not create otg events before, which is fixed by my patch. Ah, right ok. > > > Heiko > > [1] http://gitorious.org/oyo-hack/kernel/blobs/topic/board/sg060/arch/arm/mach-s3c2416/es600-common.c#line702 > > > >> >> --Dima >> >> > Thanks >> > Heiko >> > >> >> --- >> >> To not break the otg rework which also touched gpio-vbus, the patch is >> >> done against the xceiv branch of >> >> http://git.kernel.org/?p=linux/kernel/git/balbi/usb.git >> >> >> >> drivers/usb/otg/gpio_vbus.c | 15 ++++++++++++++- >> >> 1 files changed, 14 insertions(+), 1 deletions(-) >> >> >> >> diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c >> >> index 3ece43a..a0a2178 100644 >> >> --- a/drivers/usb/otg/gpio_vbus.c >> >> +++ b/drivers/usb/otg/gpio_vbus.c >> >> @@ -96,7 +96,7 @@ static void gpio_vbus_work(struct work_struct *work) >> >> struct gpio_vbus_data *gpio_vbus = >> >> container_of(work, struct gpio_vbus_data, work); >> >> struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data; >> >> - int gpio; >> >> + int gpio, status; >> >> >> >> if (!gpio_vbus->phy.otg->gadget) >> >> return; >> >> @@ -108,7 +108,9 @@ static void gpio_vbus_work(struct work_struct *work) >> >> */ >> >> gpio = pdata->gpio_pullup; >> >> if (is_vbus_powered(pdata)) { >> >> + status = USB_EVENT_VBUS; >> >> gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL; >> >> + gpio_vbus->phy.last_event = status; >> >> usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget); >> >> >> >> /* drawing a "unit load" is *always* OK, except for OTG */ >> >> @@ -117,6 +119,9 @@ static void gpio_vbus_work(struct work_struct *work) >> >> /* optionally enable D+ pullup */ >> >> if (gpio_is_valid(gpio)) >> >> gpio_set_value(gpio, >> >> !pdata->gpio_pullup_inverted); + >> >> + atomic_notifier_call_chain(&gpio_vbus->phy.notifier, >> >> + status, >> >> gpio_vbus->phy.otg->gadget); } else { >> >> /* optionally disable D+ pullup */ >> >> if (gpio_is_valid(gpio)) >> >> @@ -125,7 +130,12 @@ static void gpio_vbus_work(struct work_struct >> >> *work) set_vbus_draw(gpio_vbus, 0); >> >> >> >> usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget); >> >> + status = USB_EVENT_NONE; >> >> gpio_vbus->phy.state = OTG_STATE_B_IDLE; >> >> + gpio_vbus->phy.last_event = status; >> >> + >> >> + atomic_notifier_call_chain(&gpio_vbus->phy.notifier, >> >> + status, >> >> gpio_vbus->phy.otg->gadget); } >> >> } >> >> >> >> @@ -287,6 +297,9 @@ static int __init gpio_vbus_probe(struct >> >> platform_device *pdev) irq, err); >> >> goto err_irq; >> >> } >> >> + >> >> + ATOMIC_INIT_NOTIFIER_HEAD(&gpio_vbus->phy.notifier); >> >> + >> >> INIT_WORK(&gpio_vbus->work, gpio_vbus_work); >> >> >> >> gpio_vbus->vbus_draw = regulator_get(&pdev->dev, "vbus_draw"); > -- 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