Skip to content

Commit

Permalink
usb: phy: msm: Use reset framework for LINK and PHY resets
Browse files Browse the repository at this point in the history
Using reset framework eliminate need of platform specific
callbacks and enable reset lines to be specified in DT files.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Ivan T. Ivanov authored and Felipe Balbi committed Apr 30, 2014
1 parent 8364f9a commit a273454
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
29 changes: 21 additions & 8 deletions drivers/usb/phy/phy-msm-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/pm_runtime.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/reset.h>

#include <linux/usb.h>
#include <linux/usb/otg.h>
Expand Down Expand Up @@ -235,12 +236,15 @@ static void ulpi_init(struct msm_otg *motg)

static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
{
int ret = 0;
int ret;

if (!motg->pdata->link_clk_reset)
return ret;
if (motg->pdata->link_clk_reset)
ret = motg->pdata->link_clk_reset(motg->clk, assert);
else if (assert)
ret = reset_control_assert(motg->link_rst);
else
ret = reset_control_deassert(motg->link_rst);

ret = motg->pdata->link_clk_reset(motg->clk, assert);
if (ret)
dev_err(motg->phy.dev, "usb link clk reset %s failed\n",
assert ? "assert" : "deassert");
Expand All @@ -250,12 +254,13 @@ static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)

static int msm_otg_phy_clk_reset(struct msm_otg *motg)
{
int ret = 0;
int ret;

if (!motg->pdata->phy_clk_reset)
return ret;
if (motg->pdata->phy_clk_reset)
ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
else
ret = reset_control_reset(motg->phy_rst);

ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
if (ret)
dev_err(motg->phy.dev, "usb phy clk reset failed\n");

Expand Down Expand Up @@ -1377,6 +1382,14 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg)
id = of_match_device(msm_otg_dt_match, &pdev->dev);
pdata->phy_type = (int) id->data;

motg->link_rst = devm_reset_control_get(&pdev->dev, "link");
if (IS_ERR(motg->link_rst))
return PTR_ERR(motg->link_rst);

motg->phy_rst = devm_reset_control_get(&pdev->dev, "phy");
if (IS_ERR(motg->phy_rst))
return PTR_ERR(motg->phy_rst);

pdata->mode = of_usb_get_dr_mode(node);
if (pdata->mode == USB_DR_MODE_UNKNOWN)
pdata->mode = USB_DR_MODE_OTG;
Expand Down
3 changes: 3 additions & 0 deletions include/linux/usb/msm_hsusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ struct msm_otg {
struct regulator *v3p3;
struct regulator *v1p8;
struct regulator *vddcx;

struct reset_control *phy_rst;
struct reset_control *link_rst;
};

#endif

0 comments on commit a273454

Please sign in to comment.