Support for SUSPEND and RESUME for USB chargers
cover Support for SUSPEND and RESUME for USB chargers
Hi,
The charging should be prevented if the bus is suspended.
These notifications will come from the udc drivers. I'll create a separate patch set for those, as I guess the maintainers of the controller drivers need to approve those.
Heikki Krogerus (3):
usb: otg: add events for suspend/resume states
isp1704_charger: Handle suspended and resumed events
twl4030_charger: Handle suspended and resumed events
drivers/power/isp1704_charger.c | 13 +++++++++++++ drivers/power/twl4030_charger.c | 4 ++++ include/linux/usb/otg.h | 2 ++ 3 files changed, 19 insertions(+), 0 deletions(-)
Signature · 1 line
1.7.4.1
PATCH 1/3 usb: otg: add events for suspend/resume states
Those will be used by the charger driver to cut current drawing when suspended and restart it when resumed.
--- include/linux/usb/otg.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/usb/otg.h +2 -0
@@ -41,6 +41,8 @@ enum usb_xceiv_events {USB_EVENT_ID ,/* id was grounded */ USB_EVENT_CHARGER ,/* usb dedicated charger */ USB_EVENT_ENUMERATED ,/* gadget driver enumerated */ +USB_EVENT_SUSPENDED ,/* gadget driver suspended */ + USB_EVENT_RESUMED, /* gadget driver resumed */ };struct otg_transceiver ;
Signature · 1 line
1.7.4.1
PATCH 2/3 isp1704_charger: Handle suspended and resumed events
In reply to Heikki KrogerusTo prevent charging when the bus is suspended, handling suspended and resumed events.
--- drivers/power/isp1704_charger.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/power/isp1704_charger.c +13 -0
@@ -294,6 +294,19 @@ static void isp1704_charger_work(struct work_struct *data)else isp->current_max = power;break ; +case USB_EVENT_SUSPENDED : +/* Ignore SUSPEND with CDP */ +if (isp->present) + goto out; +else + isp->current_max =2 ; +break ; +case USB_EVENT_RESUMED : +if (isp->present) + goto out; +else + isp->current_max = power; +break ;default : goto out; }
Signature · 1 line
1.7.4.1
PATCH 3/3 twl4030_charger: Handle suspended and resumed events
In reply to Heikki KrogerusTo prevent charging when the bus is suspended, handling suspended and resumed events.
--- drivers/power/twl4030_charger.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/power/twl4030_charger.c +4 -0
@@ -268,11 +268,15 @@ static void twl4030_bci_usb_work(struct work_struct *data)switch (bci->event) {case USB_EVENT_VBUS :case USB_EVENT_CHARGER : +case USB_EVENT_RESUMED :twl4030_charger_enable_usb (bci, true);break ;case USB_EVENT_NONE : +case USB_EVENT_SUSPENDED :twl4030_charger_enable_usb (bci, false);break ; +default : +break ; } }
Signature · 1 line
1.7.4.1
Quoted 7 lines · Heikki Krogerus
Hi,
The charging should be prevented if the bus is suspended.
These notifications will come from the udc drivers. I'll create a separate patch set for those, as I guess the maintainers of the controller drivers need to approve those.
Can you send them here as well? These patches never set this value, so I don't see why you did it this way, instead of just getting the "normal" suspend/resume callback and triggering off of that.
Still confused,
greg k-h
Quoted 10 lines · Greg KH
Quoted 5 lines · Heikki Krogerus
The charging should be prevented if the bus is suspended.
These notifications will come from the udc drivers. I'll create a separate patch set for those, as I guess the maintainers of the controller drivers need to approve those.
Can you send them here as well? These patches never set this value, so I don't see why you did it this way, instead of just getting the "normal" suspend/resume callback and triggering off of that.
I'm not completely sure what you mean with "normal" suspend/resume callback? I want to get the information about the SUSPEND and RESUME bus states to the charger drivers and I don't want to tie them with any USB transceiver or controller driver. Wasn't this the reason for having the otg notifiers in the first place?
I'll spend a bit more time with these and resend when I have everything ready. Gražvydas noticed an issue with the isp1704_charger.c so that patch is broken in any case.
Quoted 1 line
Still confused,
I did not think this through. Sorry about that. I should have send everything from the beginning and I should have been more clear what I'm after with these.
Signature · 1 line
heikki