From patchwork Thu Aug 28 09:55:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kiran Kumar Raparthy X-Patchwork-Id: 36171 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 747072054F for ; Thu, 28 Aug 2014 09:56:43 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf6974839iga.10 for ; Thu, 28 Aug 2014 02:56:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=u1bokflp+TAHdd7dFTKW//9M8QSJsuwXn5A0D2EeXnU=; b=SeAm1P3s6Dj2ua0io87llZJZTNdH2M2VdjV4DkEY8zt/EBFW+lWhTzhqpEimjGKYqY A7qD+TFvZ1w0bu4sSZwoluBLLE12nBoL2Nf27+hdJ9NoLuI8U5SRfJWV+M/TF1BxMm5G EOkOI3h+GMNoVwE4rY3nDTLAb1UkVPLmFGojB8ec3lGlTvT1/+ehmlWJ3QXhGabVInCD oiREfi01bF3sqOSHaWAGVs8FOMGe3d0FKntuweOdi8p1g4j4PZ4wJbCJ3l4AySmny5By NSnDTJusMhGXotR4JMPh8swY3GIz491/nRn4o43wdw0CCSF26aP6swk0WhqsGT5utV1X jyfQ== X-Gm-Message-State: ALoCoQnkcgP/bNh8T0lIASNbrZ0IVYvQp1XBWPDbCzfGDr6m66tfXGr+9SpQWVGI2SLGf0CeIe7u X-Received: by 10.50.80.111 with SMTP id q15mr2298775igx.0.1409219802761; Thu, 28 Aug 2014 02:56:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.34 with SMTP id d31ls509508qgf.93.gmail; Thu, 28 Aug 2014 02:56:42 -0700 (PDT) X-Received: by 10.220.247.3 with SMTP id ma3mr819199vcb.29.1409219802643; Thu, 28 Aug 2014 02:56:42 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id lh7si2969425vdb.98.2014.08.28.02.56.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 02:56:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id ij19so513638vcb.40 for ; Thu, 28 Aug 2014 02:56:42 -0700 (PDT) X-Received: by 10.52.26.206 with SMTP id n14mr1934149vdg.0.1409219802527; Thu, 28 Aug 2014 02:56:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp209420vcb; Thu, 28 Aug 2014 02:56:42 -0700 (PDT) X-Received: by 10.70.96.142 with SMTP id ds14mr4050920pdb.45.1409219801633; Thu, 28 Aug 2014 02:56:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lr3si5411328pab.140.2014.08.28.02.56.11 for ; Thu, 28 Aug 2014 02:56:41 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936552AbaH1J4J (ORCPT + 26 others); Thu, 28 Aug 2014 05:56:09 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:43441 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934539AbaH1J4H (ORCPT ); Thu, 28 Aug 2014 05:56:07 -0400 Received: by mail-pa0-f47.google.com with SMTP id hz1so1898686pad.34 for ; Thu, 28 Aug 2014 02:56:06 -0700 (PDT) X-Received: by 10.68.252.229 with SMTP id zv5mr4332149pbc.16.1409219766427; Thu, 28 Aug 2014 02:56:06 -0700 (PDT) Received: from c-krapar-linux.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id pm1sm4612463pdb.58.2014.08.28.02.56.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 Aug 2014 02:56:05 -0700 (PDT) From: Kiran Kumar Raparthy To: linux-kernel@vger.kernel.org Cc: Todd Poynor , Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Android Kernel Team , John Stultz , Kiran Raparthy Subject: [RFC v1 2/2] usb: otg: Temporarily hold wakeupsource on charger and disconnect events Date: Thu, 28 Aug 2014 15:25:49 +0530 Message-Id: <1409219749-26911-1-git-send-email-kiran.kumar@linaro.org> X-Mailer: git-send-email 1.8.2.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: kiran.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Todd Poynor usb: otg: Temporarily hold wakeupsource on charger and disconnect events Allow other parts of the system to react to the charger connect/disconnect event without allowing the system to suspend before the other parts can process the event. This wakeup_source times out after 2 seconds; if nobody else holds a wakeup_source by that time then the device can sleep. Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org Cc: linux-usb@vger.kernel.org Cc: Android Kernel Team Cc: John Stultz Signed-off-by: Todd Poynor [kiran: Added context to commit message] Signed-off-by: Kiran Raparthy --- drivers/usb/phy/otg-wakeupsource.c | 10 +++++++--- include/linux/usb/otg.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/otg-wakeupsource.c b/drivers/usb/phy/otg-wakeupsource.c index 7c838d1..9f3c5c1 100644 --- a/drivers/usb/phy/otg-wakeupsource.c +++ b/drivers/usb/phy/otg-wakeupsource.c @@ -34,8 +34,11 @@ struct otgws_lock { struct wakeup_source wsource; }; -/* VBUS present lock */ - +/* + * VBUS present lock. Also used as a timed lock on charger + * connect/disconnect and USB host disconnect, to allow the system + * to react to the change in power. + */ static struct otgws_lock vbus_lock; static void otgws_handle_event(unsigned long event) @@ -59,7 +62,8 @@ static void otgws_handle_event(unsigned long event) case USB_EVENT_NONE: case USB_EVENT_ID: case USB_EVENT_CHARGER: - __pm_relax(&vbus_lock.wsource); + __pm_wakeup_event(&vbus_lock.wsource, + msecs_to_jiffies(TEMPORARY_HOLD_TIME)); break; default: diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 154332b..4243747 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h @@ -11,6 +11,8 @@ #include +#define TEMPORARY_HOLD_TIME 2000 + struct usb_otg { u8 default_a;