From patchwork Tue Sep 2 11:12:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 4824561 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 B86449F2ED for ; Tue, 2 Sep 2014 11:16:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 885AA20176 for ; Tue, 2 Sep 2014 11:16:28 +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 5895020170 for ; Tue, 2 Sep 2014 11:16:27 +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 1XOm1M-0000rx-R3; Tue, 02 Sep 2014 11:13:08 +0000 Received: from mail-pd0-x22b.google.com ([2607:f8b0:400e:c02::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XOm1J-0000nK-Cq for linux-arm-kernel@lists.infradead.org; Tue, 02 Sep 2014 11:13:06 +0000 Received: by mail-pd0-f171.google.com with SMTP id y13so8340730pdi.30 for ; Tue, 02 Sep 2014 04:12:42 -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=XAwLZMT+9sWNRmY6+sZGTliaHKw/NYZzpbTaxRg1ompP1l2Xl9uv9nNilmPJm42q/k UVHiEERSUrbKGkixZyTIKsuyw9UmnQ6v5QKhVdoLCU89VkMTttusL00J6yjosL0lX3jX wOzzxMr014lY7e1TMzCsljWwLY8P9gTyMtp2Ls0ZfDixyJc3FeAisujV75gYIW5pm+RG +ptN0p+ZEKtkk0EVCeHYCjVuRGMCs7j5q+fPkAGsjHT4g3JgVSNvN53NuM0Z0JtXPDe5 bLq+xEEw9nUpWwiiWSO7eIWi42vaQCuwWgQ1GyZOjRwT94fRDMxYaeRMs5iY6/uCsOLF FsAw== X-Received: by 10.68.190.229 with SMTP id gt5mr46208889pbc.15.1409656362374; Tue, 02 Sep 2014 04:12:42 -0700 (PDT) Received: from vivek-linuxpc.sisodomain.com ([14.140.216.146]) by mx.google.com with ESMTPSA id ry9sm3602503pbc.94.2014.09.02.04.12.37 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Sep 2014 04:12:41 -0700 (PDT) From: Vivek Gautam To: linux-usb@vger.kernel.org Subject: [PATCH v6 1/4] phy: Add provision for calibrating phy. Date: Tue, 2 Sep 2014 16:42:15 +0530 Message-Id: <1409656338-20337-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1409656338-20337-1-git-send-email-gautam.vivek@samsung.com> References: <1409656338-20337-1-git-send-email-gautam.vivek@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140902_041305_458613_FDC1A76E X-CRM114-Status: GOOD ( 16.02 ) X-Spam-Score: -0.4 (/) Cc: linux-samsung-soc@vger.kernel.org, sergei.shtylyov@cogentembedded.com, mathias.nyman@intel.com, gregkh@linuxfoundation.org, jg1.han@samsung.com, linux-kernel@vger.kernel.org, balbi@ti.com, kishon@ti.com, kgene.kim@samsung.com, stern@rowland.harvard.edu, Vivek Gautam , heikki.krogerus@linux.intel.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,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;