From patchwork Fri Jun 6 12:12:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4311441 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8E9E09F170 for ; Fri, 6 Jun 2014 12:15:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC075201DD for ; Fri, 6 Jun 2014 12:15:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E05F6201BC for ; Fri, 6 Jun 2014 12:15:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wst14-0002Kc-Cp; Fri, 06 Jun 2014 12:13:02 +0000 Received: from mail-pd0-x22e.google.com ([2607:f8b0:400e:c02::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wst10-0002JP-N0 for linux-arm-kernel@lists.infradead.org; Fri, 06 Jun 2014 12:12:59 +0000 Received: by mail-pd0-f174.google.com with SMTP id r10so2347437pdi.33 for ; Fri, 06 Jun 2014 05:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=EnnRf0HcjL9d4OO2Uca9DH2BhzD3hjepyzamsnG1X0Q=; b=xP2HyrIMTSs9xEdNLI7dWcHf54wZx3VwAJEr4NV2qQUj8S8P6AftBpvopEqnsvl5TH +18qLNskWmGTQtQ/0hltXYKlHEqyc0ydkKSgXltEZVJBiiKrOwZIE7o0UQmhATHStGcu NxBwQuoPQb4WIK/sqMPoVOMziN+mXYyo6+q5woTEF/ef1UL+fyfJv2tjp8oRcm0/Jfcz jyDmbA5T6mvWEjIXkDleMEPktvuKWFri7DYCIXf+aMEsVftjEnIPPKruTWcxgBKN5zEo myLO4D+p3k9Xb51LEXhcN02OshEmKs4/oPAkR+8ppLmKHxyMFLRgDlyzWev/vjaENuXT eKqg== X-Received: by 10.68.203.233 with SMTP id kt9mr181773pbc.61.1402056757729; Fri, 06 Jun 2014 05:12:37 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id su8sm35172740pbc.72.2014.06.06.05.12.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 06 Jun 2014 05:12:37 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org, linux-samsung-soc@vger.kernel.org, gregkh@linuxfoundation.org, kishon@ti.com, mathias.nyman@intel.com Subject: [PATCH 1/4] phy: Add provision for calibrating phy. Date: Fri, 6 Jun 2014 17:42:12 +0530 Message-Id: <1402056736-12674-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1402056736-12674-1-git-send-email-gautam.vivek@samsung.com> References: <1402056736-12674-1-git-send-email-gautam.vivek@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140606_051258_770224_2EC94F38 X-CRM114-Status: GOOD ( 16.29 ) X-Spam-Score: 0.2 (/) Cc: jwerner@chromium.org, kgene.kim@samsung.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Vivek Gautam X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some PHY controllers may need to calibrate certain PHY settings after initialization of the controller and sometimes even after initializing the PHY-consumer too. Add support for the same in order to let consumers do so in need. Signed-off-by: vivek Gautam --- drivers/phy/phy-core.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/phy/phy.h | 7 +++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 74d4346..92d31a3 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -376,6 +376,42 @@ int phy_power_off(struct phy *phy) EXPORT_SYMBOL_GPL(phy_power_off); /** + * phy_calibrate - calibrate a phy post initialization + * @phy: Pointer to 'phy' from consumer + * + * For certain PHYs, it may be needed to calibrate few phy parameters + * post initialization. The need to calibrate may arise after the + * initialization of consumer itself, in order to prevent further any + * loss of phy settings post consumer-initialization. + * example: USB 3.0 DRD PHY on Exynos5420/5800 systems is one such + * phy which needs calibration after the host controller reset + * has happened. + */ +int phy_calibrate(struct phy *phy) +{ + int ret = -ENOTSUPP; + + if (!phy) + return 0; + + mutex_lock(&phy->mutex); + if (phy->ops->calibrate) { + ret = phy->ops->calibrate(phy); + if (ret < 0) { + dev_err(&phy->dev, + "phy calibration failed --> %d\n", ret); + goto out; + } + } + +out: + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_calibrate); + +/** * _of_phy_get() - lookup and obtain a reference to a phy by phandle * @np: device_node for which to get the phy * @index: the index of the phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 5a537a5..1de6c0a 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -34,6 +34,7 @@ struct phy_ops { int (*exit)(struct phy *phy); int (*power_on)(struct phy *phy); int (*power_off)(struct phy *phy); + int (*calibrate)(struct phy *phy); struct module *owner; }; @@ -124,6 +125,7 @@ int phy_init(struct phy *phy); int phy_exit(struct phy *phy); int phy_power_on(struct phy *phy); int phy_power_off(struct phy *phy); +int phy_calibrate(struct phy *phy); static inline int phy_get_bus_width(struct phy *phy) { return phy->attrs.bus_width; @@ -227,6 +229,11 @@ static inline int phy_power_off(struct phy *phy) return -ENOSYS; } +static inline int phy_calibrate(struct phy *phy) +{ + return -ENOSYS; +} + static inline int phy_get_bus_width(struct phy *phy) { return -ENOSYS;