From patchwork Tue Sep 2 11:49:18 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: 36453 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CFFE7203BE for ; Tue, 2 Sep 2014 11:49:54 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf38773116pdb.9 for ; Tue, 02 Sep 2014 04:49:53 -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=j0fU4UJy/nW/O9JdiaTK98JeRN6YIh0sK34n5WZb0CE=; b=T2BIucWqTVqDNE7x/NQYTtVcourE+1zL8mwU3sdZ5Fka+VVxPNmVu/3QBSK1chOQCd DqaL33KDPVmrdSdh/3dzkRoezbMNB51SC5DWVAN4XaYxxx5d8hYw6I7KJbDIacIcyWJp /fdDUXf//lz27ku0d+9oNpVooKbkbxakJK8x1kAgqrUPFWEsMKYlRzAzZwOQUO1h4+HQ sjAezsZXQdJBA8S7xNHGHaWOOQrSaZ3fi0Vx6fbdDUrRi8NlsiZqRWxui3taKTeIbzlD J5A3e3MZYKg9TrCaJfDU80cuHax1VH3FXZUR9ZuGGL/16q+ffvERw/HQRyZwtg+BRqa1 dWOA== X-Gm-Message-State: ALoCoQk4eQufKab36WqsJ978VfXfGzEHKmGhn++ilSUC3rOjxqu1N7GJgK/+C1yV4ro+eDr0PHD+ X-Received: by 10.66.100.196 with SMTP id fa4mr19222039pab.11.1409658591826; Tue, 02 Sep 2014 04:49:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.200 with SMTP id 66ls2462783qgl.75.gmail; Tue, 02 Sep 2014 04:49:51 -0700 (PDT) X-Received: by 10.220.184.70 with SMTP id cj6mr29515104vcb.5.1409658591723; Tue, 02 Sep 2014 04:49:51 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id nu10si2119581vcb.93.2014.09.02.04.49.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Sep 2014 04:49:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hq11so6712563vcb.22 for ; Tue, 02 Sep 2014 04:49:51 -0700 (PDT) X-Received: by 10.52.168.134 with SMTP id zw6mr1101887vdb.37.1409658591642; Tue, 02 Sep 2014 04:49:51 -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 uj3csp514339vcb; Tue, 2 Sep 2014 04:49:51 -0700 (PDT) X-Received: by 10.70.93.8 with SMTP id cq8mr3754489pdb.160.1409658590718; Tue, 02 Sep 2014 04:49:50 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rd7si5737016pab.38.2014.09.02.04.49.50 for ; Tue, 02 Sep 2014 04:49:50 -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 S1753592AbaIBLts (ORCPT + 2 others); Tue, 2 Sep 2014 07:49:48 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:55757 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753048AbaIBLts (ORCPT ); Tue, 2 Sep 2014 07:49:48 -0400 Received: by mail-pa0-f45.google.com with SMTP id bj1so14445590pad.4 for ; Tue, 02 Sep 2014 04:49:47 -0700 (PDT) X-Received: by 10.70.96.142 with SMTP id ds14mr46748895pdb.45.1409658587885; Tue, 02 Sep 2014 04:49:47 -0700 (PDT) Received: from c-krapar-linux.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id xp1sm10985242pab.14.2014.09.02.04.49.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Sep 2014 04:49: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 v2 2/2] usb: phy: Temporarily hold wakeupsource on charger connect and disconnect events Date: Tue, 2 Sep 2014 17:19:18 +0530 Message-Id: <1409658558-12318-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.177 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: phy: Temporarily hold wakeupsource on charger connect 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 wakeupsource handling implemented per PHY in phy core] Signed-off-by: Kiran Raparthy --- drivers/usb/phy/otg-wakeupsource.c | 2 +- drivers/usb/phy/phy.c | 10 ++++++++++ include/linux/usb/phy.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/usb/phy/otg-wakeupsource.c b/drivers/usb/phy/otg-wakeupsource.c index fca2010..70fa05e 100644 --- a/drivers/usb/phy/otg-wakeupsource.c +++ b/drivers/usb/phy/otg-wakeupsource.c @@ -48,7 +48,7 @@ static void otgws_handle_event(struct usb_phy *otgws_xceiv, unsigned long event) case USB_EVENT_NONE: case USB_EVENT_ID: case USB_EVENT_CHARGER: - usb_drop_wsource(otgws_xceiv); + usb_temporary_hold_wsource(otgws_xceiv); break; default: diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index 659b1e8..c488716 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c @@ -483,3 +483,13 @@ void usb_drop_wsource(struct usb_phy *x) __pm_relax(&x->wsource); } EXPORT_SYMBOL_GPL(usb_drop_wsource); + +/** + * usb_temporary_hold_wsource - temporarily hold wakeupsource + * @usb_phy: the phy returned by usb_get_phy() + */ +void usb_temporary_hold_wsource(struct usb_phy *x) +{ + __pm_wakeup_event(&x->wsource, msecs_to_jiffies(TEMPORARY_HOLD_TIME)); +} +EXPORT_SYMBOL_GPL(usb_temporary_hold_wsource); diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index 6c680e6..5f9b70e 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -13,6 +13,8 @@ #include #include +#define TEMPORARY_HOLD_TIME 2000 + enum usb_phy_interface { USBPHY_INTERFACE_MODE_UNKNOWN, USBPHY_INTERFACE_MODE_UTMI, @@ -218,6 +220,7 @@ void usb_wsource_init(struct usb_phy *x, char *phy_dev_name); void usb_wsource_trash(struct usb_phy *x); void usb_grab_wsource(struct usb_phy *x); void usb_drop_wsource(struct usb_phy *x); +void usb_temporary_hold_wsource(struct usb_phy *x); #else static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) {