usb: musb: omap2430: handle charger OTG xceiver event
PATCH 1/1 usb: musb: omap2430: handle charger OTG xceiver event
Set a flag on OTG charger event and check it on cable remove event (i.e. USB_EVENT_NONE). This way we will not need to power up the PHY when an external charger is detected by the transceiver itself.
--- drivers/usb/musb/musb_core.h | 1 + drivers/usb/musb/omap2430.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-)
drivers/usb/musb/musb_core.h +1 -0
@@ -497,6 +497,7 @@ struct musb {struct usb_gadget g;/* the gadget */ struct usb_gadget_driver *gadget_driver;/* its driver */ #endif + bool is_ac_charger:1;/* * FIXME: Remove this flag.
drivers/usb/musb/omap2430.c +12 -0
@@ -257,6 +257,11 @@ static int musb_otg_notifications(struct notifier_block *nb, }break ; +case USB_EVENT_CHARGER : +dev_dbg (musb->controller,"Dedicated charger connect\n" ); + musb->is_ac_charger = true; +break ; +case USB_EVENT_VBUS :dev_dbg (musb->controller,"VBUS Connect\n" );
@@ -268,6 +273,13 @@ static int musb_otg_notifications(struct notifier_block *nb,break ;case USB_EVENT_NONE : +if (musb->is_ac_charger) { +dev_dbg (musb->controller, +"Dedicated charger disconnect\n" ); + musb->is_ac_charger = false; +break ; + } +dev_dbg (musb->controller,"VBUS Disconnect\n" );#ifdef CONFIG_USB_GADGET_MUSB_HDRC
Signature · 6 lines
1.7.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Quoted 3 lines · Dima Zavin
Set a flag on OTG charger event and check it on cable remove event (i.e.
USB_EVENT_NONE). This way we will not need to power up the PHY when an external charger
s/PHY/LINK
Quoted 1 line
is detected by the transceiver itself.
... your logic is inversed. Link shouldn't be powered up to start with. We should only power up the Link after we know it *will* be needed. The way you're doing this is:
connect cable -> resume PHY -> resume Link -> if is_charger suspend Link.
Where it should be:
connect cable -> resume PHY -> if is_charger goto done.
Now, to make a generic solution (which is what we want in the long run) we still need a few changes on the OTG support and otg_transceiver on Linux.
Signature · 1 line
balbi
A message that is not in the archive (sent off-list or not yet received): 20110712060126.GB2588-UiBtZHVXSwEVvW8u9ZQWYwjfymiNCTlR@public.gmane.org
Quoted 8 lines · Felipe Balbi
Hi,
Quoted 3 lines · Dima Zavin
Set a flag on OTG charger event and check it on cable remove event (i.e.
USB_EVENT_NONE). This way we will not need to power up the PHY when an external chargers/PHY/LINK
Actually it's both, I should update the commit message.
Quoted 6 lines
Quoted 2 lines
is detected by the transceiver itself.
... your logic is inversed. Link shouldn't be powered up to start with. We should only power up the Link after we know it *will* be needed. The way you're doing this is:
The link *isn't* being powered up by my patch. On an already detected charger you should do nothing at all in musb. That's the whole point of the patch: add the ability to process the USB_EVENT_CHARGER event in musb from the otg_transceiver that has already detected the charger. Today, on USB_EVENT_VBUS, you'd resume your link and then call otg_init, which would powerup the phy on omap4, which we do not need to do for USB_EVENT_CHARGER.
Quoted 3 lines
connect cable -> resume PHY -> resume Link -> if
is_chargersuspend Link.
Not at all. Have even you looked at the patch? With the patch,
1) "connect cable", detected by otg_transceiver.
2) otg_transceiver does the detection of ID pin and/or VBUS and/or dedicated charger.
3) otg_transceiver sends USB_EVENT_xxx
4) In musb_otg_notification(), check if the transceiver detected a charger (USB_EVENT_CHARGER).
4.1) If yes, then do nothing and leave the LINK *and* the PHY in their off states.
Quoted 4 lines
Where it should be:
connect cable -> resume PHY -> if
is_chargergoto done.
We only have to resume the PHY if the transceiver didn't do the charger detection. The TWL6030 doesn't do that, but depending on your board, you may have other devices upstream from the OMAP on the USB lines that may have done the detection for you.
--Dima
Quoted 8 lines
Now, to make a generic solution (which is what we want in the long run) we still need a few changes on the OTG support and
otg_transceiveron Linux.--
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAPz4a6C_Y797S5kQVVdUyN-xiuEaz415nEcp-CDOYPwZ4xzNuA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Hi,
Quoted 11 lines · Dima Zavin
Quoted 8 lines · Felipe Balbi
Hi,
Quoted 3 lines · Dima Zavin
Set a flag on OTG charger event and check it on cable remove event (i.e.
USB_EVENT_NONE). This way we will not need to power up the PHY when an external chargers/PHY/LINK
Actually it's both, I should update the commit message.
the PHY has to be powered up during charger detection. You could power it down after charger has been started and power it back up on the rising edge (or high level, don't remember if this is edge of level triggered) of the VBUS IRQ.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
is detected by the transceiver itself.
... your logic is inversed. Link shouldn't be powered up to start with. We should only power up the Link after we know it *will* be needed. The way you're doing this is:
The link *isn't* being powered up by my patch. On an already detected
not by your patch, true. My point is that we're powering it up too early and if you want to change anything regarding Charger Detection you need to change at the right place.
Quoted 4 lines
charger you should do nothing at all in musb. That's the whole point of the patch: add the ability to process the
USB_EVENT_CHARGERevent in musb from theotg_transceiverthat has already detected the charger. Today, onUSB_EVENT_VBUS, you'd resume your link and then
and what I said (or tried to) is that USB_EVENT_VBUS isn't an event to be handled by the link at all. The link should be pm_runtime_suspend()ed right after probe() and should be kept that way until PHY sends USB_EVENT_CHARGER_DETECTION_DONE or something similar.
Quoted 2 lines
call
otg_init, which would powerup the phy on omap4, which we do not need to do forUSB_EVENT_CHARGER.
That is wrong true. Still your patch only adds a flag. It's not implementing what you're describing here.
Quoted 9 lines
Quoted 2 lines
connect cable -> resume PHY -> resume Link -> if
is_chargersuspend Link.Not at all. Have even you looked at the patch? With the patch,
1) "connect cable", detected by
otg_transceiver.
2)otg_transceiverdoes the detection of ID pin and/or VBUS and/or dedicated charger.
3)otg_transceiversendsUSB_EVENT_xxx
yes, and it will send USB_EVENT_VBUS which is resuming link.
Quoted 4 lines
4) In
musb_otg_notification(), check if the transceiver detected a charger (USB_EVENT_CHARGER).
4.1) If yes, then do nothing and leave the LINK *and* the PHY in their off states.
this is not what your patch is doing. It only enables/disables a flag which your patch added.
Quoted 6 lines
Quoted 3 lines
Where it should be:
connect cable -> resume PHY -> if
is_chargergoto done.We only have to resume the PHY if the transceiver didn't do the charger detection. The TWL6030 doesn't do that, but depending on your
PHY == transceiver.
Like I said before, if you want to put any changes regarding charger detection, do it at the right location. First add some events for different USB port types (SDP, CDP, DCP), then notify those, then add handling of those events to MUSB and PHY drivers, then fix up musb to be runtime suspended right after probe, then you only need to wake musb UP in case of SDP and CDP. If you're attached to a DCP you don't even need MUSB to handle that.
Also, while you are doing Charger detection, be sure to disable SoftConnect bit on MUSB and put PHY in NONDRIVING mode, this will prevent MUSB from even knowing there's a cable connected.
Signature · 1 line
balbi