From patchwork Mon Apr 1 13:54:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 2371021 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 80D80DFB7B for ; Mon, 1 Apr 2013 14:00:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758560Ab3DAN5s (ORCPT ); Mon, 1 Apr 2013 09:57:48 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:25155 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758529Ab3DAN5n (ORCPT ); Mon, 1 Apr 2013 09:57:43 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MKK007A2XFX4850@mailout4.samsung.com>; Mon, 01 Apr 2013 22:57:41 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id E5.3F.05174.55299515; Mon, 01 Apr 2013 22:57:41 +0900 (KST) X-AuditID: cbfee68f-b7f4a6d000001436-9f-515992558ce0 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id E9.67.13494.55299515; Mon, 01 Apr 2013 22:57:41 +0900 (KST) Received: from vivekkumarg-linuxpc.sisodomain.com ([107.108.214.169]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MKK00JXCXD41C70@mmp1.samsung.com>; Mon, 01 Apr 2013 22:57:41 +0900 (KST) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-omap@vger.kernel.org Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, balbi@ti.com, stern@rowland.harvard.edu, sarah.a.sharp@linux.intel.com, rob.herring@calxeda.com, kgene.kim@samsung.com, kishon@ti.com, dianders@chromium.org, t.figa@samsung.com, p.paneri@samsung.com Subject: [PATCH v3 01/11] usb: phy: Add APIs for runtime power management Date: Mon, 01 Apr 2013 19:24:00 +0530 Message-id: <1364824448-14732-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.6.5 In-reply-to: <1364824448-14732-1-git-send-email-gautam.vivek@samsung.com> References: <1364824448-14732-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrCIsWRmVeSWpSXmKPExsWyRsSkWjd0UmSgwcfXEhYH79dbnF12kM2i efF6NoveBVfZLC487WGzuLxrDpvF7CX9LBYzzu9jsli0rJXZ4vyWTiaLwysOMFk0nzjFbDHh 9wU2i/UzXrM48Hks+HyF3WN2w0UWj3knAz32z10D5N39wejRt2UVo8fxG9uZPD5vkgvgiOKy SUnNySxLLdK3S+DK+L9uLkvBetmKzz0zGRsYH4l3MXJySAiYSEz92sIOYYtJXLi3nq2LkYtD SGApo8SSRceZYIq2b93ICpFYxCgxra+PHcKZwiTxbPZURpAqNgFdiaa3u4BsDg4RgTiJzROE QcLMAl1MEkuPgm0TFvCU2PlnDlgJi4CqRN/lPJAwr4CHRF/vGhaIXQoSb24/YwaxOYHKP2xd DHaDEFBN+9UTrBA199gllh2qBrFZBAQkvk0+xAIyUkJAVmLTAWaIEkmJgytusExgFF7AyLCK UTS1ILmgOCm9yFivODG3uDQvXS85P3cTIzCGTv971r+D8e4B60OMyUDjJjJLiSbnA2MwryTe 0NjMyMLUxNTYyNzSjDRhJXFetRbrQCGB9MSS1OzU1ILUovii0pzU4kOMTBycUg2M+rVFDhUv 7Bf+6+t0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r6ket7M7V5us44VPy7sVWIpzkg01GIuKk4EAN4rngMVAwAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Adding APIs to handle runtime power management on PHY devices. PHY consumers may need to wake-up/suspend PHYs when they work across autosuspend. Signed-off-by: Vivek Gautam --- include/linux/usb/phy.h | 141 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 141 insertions(+), 0 deletions(-) diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index 6b5978f..01bf9c1 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -297,4 +297,145 @@ static inline const char *usb_phy_type_string(enum usb_phy_type type) return "UNKNOWN PHY TYPE"; } } + +static inline void usb_phy_autopm_enable(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return; + } + + pm_runtime_enable(x->dev); +} + +static inline void usb_phy_autopm_disable(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return; + } + + pm_runtime_disable(x->dev); +} + +static inline int usb_phy_autopm_get(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return -ENODEV; + } + + return pm_runtime_get(x->dev); +} + +static inline int usb_phy_autopm_get_sync(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return -ENODEV; + } + + return pm_runtime_get_sync(x->dev); +} + +static inline int usb_phy_autopm_put(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return -ENODEV; + } + + return pm_runtime_put(x->dev); +} + +static inline int usb_phy_autopm_put_sync(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return -ENODEV; + } + + return pm_runtime_put_sync(x->dev); +} + +static inline void usb_phy_autopm_allow(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return; + } + + pm_runtime_allow(x->dev); +} + +static inline void usb_phy_autopm_forbid(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return; + } + + pm_runtime_forbid(x->dev); +} + +static inline int usb_phy_autopm_set_active(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return -ENODEV; + } + + return pm_runtime_set_active(x->dev); +} + +static inline void usb_phy_autopm_set_suspended(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return; + } + + pm_runtime_set_suspended(x->dev); +} + +static inline bool usb_phy_autopm_suspended(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return 0; + } + + return pm_runtime_suspended(x->dev); +} + +static inline bool usb_phy_autopm_active(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return 0; + } + + return pm_runtime_active(x->dev); +} + +static inline int usb_phy_autopm_suspend(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return -ENODEV; + } + + return pm_runtime_suspend(x->dev); +} + +static inline int usb_phy_autopm_resume(struct usb_phy *x) +{ + if (!x || !x->dev) { + dev_err(x->dev, "no PHY or attached device available\n"); + return -ENODEV; + } + + return pm_runtime_resume(x->dev); +} + #endif /* __LINUX_USB_PHY_H */