From: Vivek Gautam <gautam.vivek@samsung.com>
To: linux-usb@vger.kernel.org
Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, gregkh@linuxfoundation.org,
kishon@ti.com, balbi@ti.com, stern@rowland.harvard.edu,
kgene.kim@samsung.com, heikki.krogerus@linux.intel.com,
mathias.nyman@intel.com, sergei.shtylyov@cogentembedded.com,
jg1.han@samsung.com, Vivek Gautam <gautam.vivek@samsung.com>
Subject: [PATCH v6 1/4] phy: Add provision for calibrating phy.
Date: Tue, 2 Sep 2014 16:42:15 +0530 [thread overview]
Message-ID: <1409656338-20337-2-git-send-email-gautam.vivek@samsung.com> (raw)
In-Reply-To: <1409656338-20337-1-git-send-email-gautam.vivek@samsung.com>
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 <gautam.vivek@samsung.com>
---
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;
--
1.7.10.4
next prev parent reply other threads:[~2014-09-02 11:12 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 11:12 [PATCH v6 0/4] Fine tune USB 3.0 PHY on exynos5420 Vivek Gautam
2014-09-02 11:12 ` Vivek Gautam [this message]
2014-09-02 11:12 ` [PATCH v6 2/4] usb: host: xhci-plat: Get PHYs for xhci's hcds Vivek Gautam
2014-09-02 11:12 ` [PATCH v6 3/4] usb: hcd: Calibrate PHY post hcd reset Vivek Gautam
2014-09-02 11:12 ` [PATCH v6 4/4] phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800 Vivek Gautam
2014-09-02 14:34 ` Felipe Balbi
2014-09-03 7:29 ` Vivek Gautam
2014-09-03 14:42 ` Felipe Balbi
2014-09-04 6:31 ` Vivek Gautam
2014-09-05 17:56 ` Felipe Balbi
2014-09-08 4:23 ` Vivek Gautam
2014-09-08 13:44 ` Felipe Balbi
2014-09-09 1:49 ` Vivek Gautam
2014-09-09 14:42 ` Felipe Balbi
2014-09-10 3:37 ` Vivek Gautam
2014-09-10 3:39 ` Vivek Gautam
2014-09-10 4:53 ` Felipe Balbi
2014-09-10 5:23 ` Vivek Gautam
2014-09-10 7:56 ` Vivek Gautam
2014-09-10 20:22 ` Julius Werner
2014-09-11 3:20 ` Vivek Gautam
2014-09-11 15:40 ` Kishon Vijay Abraham I
2014-09-11 16:54 ` Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1409656338-20337-2-git-send-email-gautam.vivek@samsung.com \
--to=gautam.vivek@samsung.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jg1.han@samsung.com \
--cc=kgene.kim@samsung.com \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®