Message ID | 1402056736-12674-2-git-send-email-gautam.vivek@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Jun 06, 2014 at 08:12:12PM +0800, Vivek Gautam wrote: > 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 | 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 For USB you may need to calibrate phy after each new connection. If so, why not to use already existing struct usb_phy's notify_connect. pratyush -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi, On Mon, Jun 9, 2014 at 9:19 AM, Pratyush Anand <pratyush.anand@st.com> wrote: > On Fri, Jun 06, 2014 at 08:12:12PM +0800, Vivek Gautam wrote: >> 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 | 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 > > For USB you may need to calibrate phy after each new connection. If > so, why not to use already existing struct usb_phy's notify_connect. The phy_calibrate will rather be a one time phenomenon. On exynos atleast the case is : the phy settings for PIPE3 phy on DWC3 controller need to be configured post hcd reset. so that we don't need to re-configure these phy settings on every connect. Moreover *there are certain devices* which need these PHY settings even to show a connect-status-change. So, it would rather be not useful to create a 'phy_notify_connect' API in drivers/phy/ and use the same for this purpose.
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;
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 | 7 +++++++ 2 files changed, 43 insertions(+)