From patchwork Wed Nov 19 10:43:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kiran Kumar Raparthy X-Patchwork-Id: 41123 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B0CCC20CBB for ; Wed, 19 Nov 2014 10:46:18 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf509392wiv.9 for ; Wed, 19 Nov 2014 02:46:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references:mime-version:sender :precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=V9CjyVR085ll2cTvyLgo0vj+vDt2/1Sw6UkXNLXep58=; b=cP1lm0BwHW/QcRBZ1m8T1PQ3eufcE0B5dCX8XAnb1JC5awoqUdn2LZRXsY2KUHRDix sMDvx0VMXo48cT3MPx0bu5lOqYV4k92tchUilC2SwoQgierTeSH5vA2QhCP0t6hkc8p7 ET33dMVLnuzGeZrOLc12f5ACyhASYo3/ptkfgzRCjUThQ82CxhM0H04tvPlMBQscbmMc ib+pDQEBmbvcsdgnxvFbaWwUHpStRkf6g/1HB3uZvmvG9GcE/YtEnX/luEajZqiKlYLV 6H2jFu993C/eg5mMgNWcyDMJRXjqTvkPyWc82QWi0BPk3vxNzmqUrBn4reZOX5swVNWm NR4A== X-Gm-Message-State: ALoCoQkSLyz5eHIgKhaH6rZGWWVqcayMY+qVlnXRjObNA5TNdm+cEx2mC0GHPiqeMkhKRvEf8RRW X-Received: by 10.112.143.136 with SMTP id se8mr247112lbb.18.1416393977950; Wed, 19 Nov 2014 02:46:17 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.170 with SMTP id d10ls279154lad.37.gmail; Wed, 19 Nov 2014 02:46:17 -0800 (PST) X-Received: by 10.112.136.37 with SMTP id px5mr4782140lbb.36.1416393977587; Wed, 19 Nov 2014 02:46:17 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id v1si1392321lag.49.2014.11.19.02.46.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Nov 2014 02:46:17 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id l4so249067lbv.26 for ; Wed, 19 Nov 2014 02:46:17 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr4718350lbc.34.1416393977413; Wed, 19 Nov 2014 02:46:17 -0800 (PST) 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.112.184.201 with SMTP id ew9csp60847lbc; Wed, 19 Nov 2014 02:46:16 -0800 (PST) X-Received: by 10.70.130.72 with SMTP id oc8mr31027987pdb.88.1416393975818; Wed, 19 Nov 2014 02:46:15 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1si1860314pdo.143.2014.11.19.02.46.15 for ; Wed, 19 Nov 2014 02:46:15 -0800 (PST) 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 S1755074AbaKSKqM (ORCPT + 26 others); Wed, 19 Nov 2014 05:46:12 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:60242 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754356AbaKSKqI (ORCPT ); Wed, 19 Nov 2014 05:46:08 -0500 Received: by mail-pa0-f51.google.com with SMTP id ey11so348933pad.10 for ; Wed, 19 Nov 2014 02:46:08 -0800 (PST) X-Received: by 10.70.118.165 with SMTP id kn5mr18839828pdb.140.1416393968058; Wed, 19 Nov 2014 02:46:08 -0800 (PST) Received: from c-krapar-linux.qualcomm.com ([202.46.23.54]) by mx.google.com with ESMTPSA id fn7sm1547762pad.38.2014.11.19.02.46.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 19 Nov 2014 02:46:07 -0800 (PST) From: Kiran Kumar Raparthy To: linux-kernel@vger.kernel.org Cc: balbi@ti.com, john.stultz@linaro.org, sumit.semwal@linaro.org, Todd Poynor , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Android Kernel Team , =?UTF-8?q?Arve=20Hj=F8nnev=E5g?= , Benoit Goby , Kiran Raparthy Subject: [PATCH 2/3] usb: phy: Handle per-PHY event for connect and disconnect events Date: Wed, 19 Nov 2014 16:13:59 +0530 Message-Id: X-Mailer: git-send-email 1.8.2.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 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.217.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: phy: Handle per-PHY event for connnect and disconnect events When usb is connected and enumerated in device mode or when usb is disconnected,call usb_phy_set_event from phy drivers to handle per-PHY event. 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 Cc: Sumit Semwal Cc: Arve Hjřnnevĺg Cc: Benoit Goby Signed-off-by: Todd Poynor [kiran: Added context to commit message, squished build fixes from Benoit Goby and Arve Hjřnnevĺg, changed wakelocks usage to wakeupsource, merged Todd's refactoring logic and simplified the structures and code and addressed community feedback] Signed-off-by: Kiran Raparthy --- drivers/usb/phy/phy-ab8500-usb.c | 15 +++++++++++++++ drivers/usb/phy/phy-gpio-vbus-usb.c | 2 ++ drivers/usb/phy/phy-mv-usb.c | 2 ++ drivers/usb/phy/phy-tahvo.c | 2 ++ 4 files changed, 21 insertions(+) diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c index 11ab2c4..d79fa3e 100644 --- a/drivers/usb/phy/phy-ab8500-usb.c +++ b/drivers/usb/phy/phy-ab8500-usb.c @@ -447,6 +447,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, event = UX500_MUSB_NONE; /* Fallback to default B_IDLE as nothing is connected. */ ab->phy.state = OTG_STATE_B_IDLE; + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); break; case USB_LINK_ACA_RID_C_NM_9540: @@ -461,12 +462,14 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, ab8500_usb_peri_phy_en(ab); atomic_notifier_call_chain(&ab->phy.notifier, UX500_MUSB_PREPARE, &ab->vbus_draw); + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); } if (ab->mode == USB_IDLE) { ab->mode = USB_PERIPHERAL; ab8500_usb_peri_phy_en(ab); atomic_notifier_call_chain(&ab->phy.notifier, UX500_MUSB_PREPARE, &ab->vbus_draw); + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); } if (event != UX500_MUSB_RIDC) event = UX500_MUSB_VBUS; @@ -502,6 +505,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, event = UX500_MUSB_CHARGER; atomic_notifier_call_chain(&ab->phy.notifier, event, &ab->vbus_draw); + usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); break; case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_9540: @@ -526,6 +530,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab, ab->mode = USB_IDLE; ab->phy.otg->default_a = false; ab->vbus_draw = 0; + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); } } break; @@ -585,6 +590,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, * is connected */ ab->phy.state = OTG_STATE_B_IDLE; + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); break; case USB_LINK_ACA_RID_C_NM_8540: @@ -598,6 +604,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, ab8500_usb_peri_phy_en(ab); atomic_notifier_call_chain(&ab->phy.notifier, UX500_MUSB_PREPARE, &ab->vbus_draw); + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); } if (event != UX500_MUSB_RIDC) event = UX500_MUSB_VBUS; @@ -626,6 +633,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, event = UX500_MUSB_CHARGER; atomic_notifier_call_chain(&ab->phy.notifier, event, &ab->vbus_draw); + usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); break; case USB_LINK_PHYEN_NO_VBUS_NO_IDGND_8540: @@ -648,6 +656,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab, ab->mode = USB_IDLE; ab->phy.otg->default_a = false; ab->vbus_draw = 0; + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); } break; @@ -694,6 +703,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, * is connected */ ab->phy.state = OTG_STATE_B_IDLE; + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); break; case USB_LINK_ACA_RID_C_NM_8505: @@ -707,6 +717,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, ab8500_usb_peri_phy_en(ab); atomic_notifier_call_chain(&ab->phy.notifier, UX500_MUSB_PREPARE, &ab->vbus_draw); + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); } if (event != UX500_MUSB_RIDC) event = UX500_MUSB_VBUS; @@ -734,6 +745,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab, event = UX500_MUSB_CHARGER; atomic_notifier_call_chain(&ab->phy.notifier, event, &ab->vbus_draw); + usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); break; default: @@ -777,6 +789,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, event = UX500_MUSB_NONE; /* Fallback to default B_IDLE as nothing is connected */ ab->phy.state = OTG_STATE_B_IDLE; + usb_phy_set_event(&ab->phy, USB_EVENT_NONE); break; case USB_LINK_ACA_RID_C_NM_8500: @@ -794,6 +807,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, ab8500_usb_peri_phy_en(ab); atomic_notifier_call_chain(&ab->phy.notifier, UX500_MUSB_PREPARE, &ab->vbus_draw); + usb_phy_set_event(&ab->phy, USB_EVENT_ENUMERATED); } if (event != UX500_MUSB_RIDC) event = UX500_MUSB_VBUS; @@ -820,6 +834,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab, event = UX500_MUSB_CHARGER; atomic_notifier_call_chain(&ab->phy.notifier, event, &ab->vbus_draw); + usb_phy_set_event(&ab->phy, USB_EVENT_CHARGER); break; case USB_LINK_RESERVED_8500: diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c index f4b14bd..840dc2b 100644 --- a/drivers/usb/phy/phy-gpio-vbus-usb.c +++ b/drivers/usb/phy/phy-gpio-vbus-usb.c @@ -134,6 +134,7 @@ static void gpio_vbus_work(struct work_struct *work) atomic_notifier_call_chain(&gpio_vbus->phy.notifier, status, gpio_vbus->phy.otg->gadget); + usb_phy_set_event(&gpio_vbus->phy, USB_EVENT_ENUMERATED); } else { /* optionally disable D+ pullup */ if (gpio_is_valid(gpio)) @@ -148,6 +149,7 @@ static void gpio_vbus_work(struct work_struct *work) atomic_notifier_call_chain(&gpio_vbus->phy.notifier, status, gpio_vbus->phy.otg->gadget); + usb_phy_set_event(&gpio_vbus->phy, USB_EVENT_NONE); } } diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index 7d80c54..8ed9f95 100644 --- a/drivers/usb/phy/phy-mv-usb.c +++ b/drivers/usb/phy/phy-mv-usb.c @@ -441,10 +441,12 @@ run: mv_otg_start_periphrals(mvotg, 0); mv_otg_reset(mvotg); mv_otg_disable(mvotg); + usb_phy_set_event(&mvotg->phy, USB_EVENT_NONE); break; case OTG_STATE_B_PERIPHERAL: mv_otg_enable(mvotg); mv_otg_start_periphrals(mvotg, 1); + usb_phy_set_event(&mvotg->phy, USB_EVENT_ENUMERATED); break; case OTG_STATE_A_IDLE: otg->default_a = 1; diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c index cc61ee4..5551ef0 100644 --- a/drivers/usb/phy/phy-tahvo.c +++ b/drivers/usb/phy/phy-tahvo.c @@ -87,6 +87,7 @@ static void check_vbus_state(struct tahvo_usb *tu) if (tu->phy.otg->gadget) usb_gadget_vbus_connect(tu->phy.otg->gadget); tu->phy.state = OTG_STATE_B_PERIPHERAL; + usb_phy_set_event(&tu->phy, USB_EVENT_ENUMERATED); break; case OTG_STATE_A_IDLE: /* @@ -105,6 +106,7 @@ static void check_vbus_state(struct tahvo_usb *tu) if (tu->phy.otg->gadget) usb_gadget_vbus_disconnect(tu->phy.otg->gadget); tu->phy.state = OTG_STATE_B_IDLE; + usb_phy_set_event(&tu->phy, USB_EVENT_NONE); break; case OTG_STATE_A_HOST: tu->phy.state = OTG_STATE_A_IDLE;