From patchwork Thu Aug 21 14:55:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4758401 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 B9AAD9F344 for ; Thu, 21 Aug 2014 14:57:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BC6E20172 for ; Thu, 21 Aug 2014 14:57:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A3E172018A for ; Thu, 21 Aug 2014 14:57:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752686AbaHUOzl (ORCPT ); Thu, 21 Aug 2014 10:55:41 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:65067 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751999AbaHUOzj (ORCPT ); Thu, 21 Aug 2014 10:55:39 -0400 Received: by mail-pd0-f171.google.com with SMTP id z10so14043576pdj.30 for ; Thu, 21 Aug 2014 07:55:39 -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=VhEX4UkPkXevaUUahbR9B5GxyHMjbocfHxlH7LhE0W4=; b=XcZDsknvHT2LhhDxbUDw2XmyxkEfMQfXTSh1uShuCNKCKt2HzilnTL7IqOjHl1S0ib oJfyCa6OwkYubYwwm8oVnW/oh1AvI0dtRk4Yrt798/8QIYwLMIPzQ+wgergKJZMLCD4t kRIuk90i1rrsnDekELKfG54VvsEwRllRfSVoZmVjpxKifebvv1hsoFv75sExdxv9P1lv a/T4Z29rSOFIJVmF2nhhgk0TsvTp9olu1aPoJ65MJrjKF9p5NnmL13dlnqUBVcHtKo4W kFkzds1Hl+bvt1HKtH2ef01qoGLeR2JS7Gx4qxxFn+tLKhMEmFBGy9BsoC8eX5rHBoZK xIgg== X-Received: by 10.70.9.100 with SMTP id y4mr60850534pda.12.1408632939197; Thu, 21 Aug 2014 07:55:39 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id wc3sm91835580pac.18.2014.08.21.07.55.35 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Aug 2014 07:55:38 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, kishon@ti.com, kgene.kim@samsung.com, mathias.nyman@intel.com, stern@rowland.harvard.edu, sergei.shtylyov@cogentembedded.com, heikki.krogerus@linux.intel.com, balbi@ti.com, Vivek Gautam Subject: [PATCH v5 1/4] phy: Add provision for calibrating phy. Date: Thu, 21 Aug 2014 20:25:20 +0530 Message-Id: <1408632923-19591-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1408632923-19591-1-git-send-email-gautam.vivek@samsung.com> References: <1408632923-19591-1-git-send-email-gautam.vivek@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 | 8 ++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 834b337..c8cb3de 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -393,6 +393,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 d983051..c70a311 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -28,6 +28,7 @@ struct phy; * @exit: operation to be performed while exiting * @power_on: powering on the phy * @power_off: powering off the phy + * @calibrate: calibrate the phy post init * @owner: the module owner containing the ops */ struct phy_ops { @@ -35,6 +36,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; }; @@ -126,6 +128,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; @@ -231,6 +234,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;