From patchwork Thu Aug 28 09:59:10 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: 36172 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4C1652054F for ; Thu, 28 Aug 2014 10:00:16 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf16257214pad.2 for ; Thu, 28 Aug 2014 03:00:15 -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=sXrJXSb/lgbdyYy6fF6qZlFe+Qdq2zSRES+JnTAyJ5Y=; b=JcFMy/fThexn9zXYuBVj9u0Emq166LMKZYocQKk5DLLeBkHv6BCUPgpoSTLDwevxWy Zq8VF8PqKqISvW7imnReoqVJlmqQxHm9YwAHtbdLvm5zJH5JV863Rj1V7tC5hk5QfGiu NteqPZILR5vCyu1TLpg9fuxFH9he5Q9qNUW9CVQiTmYQQvzu5iHLDm9SjtxVE0CrygnL Nb4uWHVd6e98hrWXGLTxciMrBAp4afVjrtg4umJV2KiYz2hTl4bScRNkEFvwBRqUnJ0D +jPwhockC65ReFy6IPYBdYrp1cCsDGcMyhP00IavZtaWm41Lj507djCJXLGVOIUjdSqV SmDQ== X-Gm-Message-State: ALoCoQmWJ70DZvzwDthy1B0HDpx3suR9DjhlsDlCNXwqo7SkLM24xwUtMpRoQllzYl/d9R7EMU3J X-Received: by 10.66.218.162 with SMTP id ph2mr1613089pac.3.1409220015496; Thu, 28 Aug 2014 03:00:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.86.176 with SMTP id p45ls459623qgd.57.gmail; Thu, 28 Aug 2014 03:00:15 -0700 (PDT) X-Received: by 10.52.30.2 with SMTP id o2mr1924088vdh.12.1409220015372; Thu, 28 Aug 2014 03:00:15 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id gz8si3019594vdc.4.2014.08.28.03.00.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 03:00:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id lf12so518276vcb.20 for ; Thu, 28 Aug 2014 03:00:15 -0700 (PDT) X-Received: by 10.220.105.201 with SMTP id u9mr2198877vco.11.1409220015272; Thu, 28 Aug 2014 03:00:15 -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 uj3csp209759vcb; Thu, 28 Aug 2014 03:00:14 -0700 (PDT) X-Received: by 10.66.168.204 with SMTP id zy12mr4089401pab.19.1409220014137; Thu, 28 Aug 2014 03:00:14 -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.03.00.13 for ; Thu, 28 Aug 2014 03:00:14 -0700 (PDT) Received-SPF: none (google.com: linux-usb-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 S936552AbaH1J7t (ORCPT + 2 others); Thu, 28 Aug 2014 05:59:49 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:34735 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934503AbaH1J7t (ORCPT ); Thu, 28 Aug 2014 05:59:49 -0400 Received: by mail-pa0-f53.google.com with SMTP id fa1so1896005pad.40 for ; Thu, 28 Aug 2014 02:59:48 -0700 (PDT) X-Received: by 10.68.65.36 with SMTP id u4mr3993057pbs.127.1409219988556; Thu, 28 Aug 2014 02:59:48 -0700 (PDT) Received: from c-krapar-linux.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id xj5sm3098434pbb.7.2014.08.28.02.59.44 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 Aug 2014 02:59:47 -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:29:10 +0530 Message-Id: <1409219950-27037-1-git-send-email-kiran.kumar@linaro.org> X-Mailer: git-send-email 1.8.2.1 Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@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.175 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;