All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sshtylyov@mvista.com>
To: Pavankumar Kondeti <pkondeti@codeaurora.org>
Cc: greg@kroah.com, linux-usb@vger.kernel.org,
	linux-arm-msm@vger.kernel.org,
	Anji jonnala <anjir@codeaurora.org>
Subject: Re: [PATCH 4/5] USB: OTG: msm: Configure PHY Analog and Digital voltage domains
Date: Fri, 29 Apr 2011 14:14:05 +0400	[thread overview]
Message-ID: <4DBA8F6D.7000508@ru.mvista.com> (raw)
In-Reply-To: <1303977693-18389-4-git-send-email-pkondeti@codeaurora.org>

On 28.04.2011 12:01, Pavankumar Kondeti wrote:

> From: Anji jonnala <anjir@codeaurora.org>

> Signed-off-by: Anji jonnala <anjir@codeaurora.org>
> Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
[...]

> diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c
> index 526a650..425418d 100644
> --- a/drivers/usb/otg/msm_otg.c
> +++ b/drivers/usb/otg/msm_otg.c
> @@ -38,6 +38,7 @@
>   #include<linux/usb/hcd.h>
>   #include<linux/usb/msm_hsusb.h>
>   #include<linux/usb/msm_hsusb_hw.h>
> +#include<linux/regulator/consumer.h>
>
>   #include<mach/clk.h>
>
> @@ -45,6 +46,175 @@
>   #define DRIVER_NAME	"msm_otg"
>
>   #define ULPI_IO_TIMEOUT_USEC	(10 * 1000)
> +
> +#define USB_PHY_3P3_VOL_MIN	3050000 /* uV */
> +#define USB_PHY_3P3_VOL_MAX	3300000 /* uV */
> +#define USB_PHY_3P3_HPM_LOAD	50000	/* uA */
> +#define USB_PHY_3P3_LPM_LOAD	4000	/* uA */
> +
> +#define USB_PHY_1P8_VOL_MIN	1800000 /* uV */
> +#define USB_PHY_1P8_VOL_MAX	1800000 /* uV */
> +#define USB_PHY_1P8_HPM_LOAD	50000	/* uA */
> +#define USB_PHY_1P8_LPM_LOAD	4000	/* uA */
> +
> +#define USB_PHY_VDD_DIG_VOL_MIN	1000000 /* uV */
> +#define USB_PHY_VDD_DIG_VOL_MAX	1320000 /* uV */
> +
> +static struct regulator *hsusb_3p3;
> +static struct regulator *hsusb_1p8;
> +static struct regulator *hsusb_vddcx;
> +
> +static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
> +{
> +	int ret = 0;
> +
> +	if (init) {
> +		hsusb_vddcx = regulator_get(motg->otg.dev, "HSUSB_VDDCX");
> +		if (IS_ERR(hsusb_vddcx)) {
> +			dev_err(motg->otg.dev, "unable to get hsusb vddcx\n");
> +			return PTR_ERR(hsusb_vddcx);
> +		}
> +
> +		ret = regulator_set_voltage(hsusb_vddcx,
> +				USB_PHY_VDD_DIG_VOL_MIN,
> +				USB_PHY_VDD_DIG_VOL_MAX);
> +		if (ret) {
> +			dev_err(motg->otg.dev, "unable to set the voltage"
> +					"for hsusb vddcx\n");
> +			regulator_put(hsusb_vddcx);
> +			return ret;
> +		}
> +
> +		ret = regulator_enable(hsusb_vddcx);
> +		if (ret) {
> +			dev_err(motg->otg.dev, "unable to enable hsusb vddcx\n");
> +			regulator_put(hsusb_vddcx);
> +		}
> +	} else {
> +		ret = regulator_set_voltage(hsusb_vddcx, 0,
> +			USB_PHY_VDD_DIG_VOL_MIN);
> +		if (ret) {
> +			dev_err(motg->otg.dev, "unable to set the voltage"
> +					"for hsusb vddcx\n");
> +			return ret;
> +		}
> +		ret = regulator_disable(hsusb_vddcx);
> +		if (ret) {
> +			dev_err(motg->otg.dev, "unable to disable hsusb vddcx\n");
> +			return ret;

    I suspect you should call regulator_put() on error cases as well...

> +		}
> +
> +		regulator_put(hsusb_vddcx);
> +	}
> +
> +	return ret;
> +}
> +
> +static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
> +{
> +	int rc = 0;
> +
> +	if (init) {
> +		hsusb_3p3 = regulator_get(motg->otg.dev, "HSUSB_3p3");
> +		if (IS_ERR(hsusb_3p3)) {
> +			dev_err(motg->otg.dev, "unable to get hsusb 3p3\n");
> +			return PTR_ERR(hsusb_3p3);
> +		}
> +
> +		rc = regulator_set_voltage(hsusb_3p3, USB_PHY_3P3_VOL_MIN,
> +				USB_PHY_3P3_VOL_MAX);
> +		if (rc) {
> +			dev_err(motg->otg.dev, "unable to set voltage level for"
> +					"hsusb 3p3\n");
> +			goto put_3p3;
> +		}
> +		rc = regulator_enable(hsusb_3p3);
> +		if (rc) {
> +			dev_err(motg->otg.dev, "unable to enable the hsusb 3p3\n");
> +			goto put_3p3_lpm;
> +		}
> +		hsusb_1p8 = regulator_get(motg->otg.dev, "HSUSB_1p8");
> +		if (IS_ERR(hsusb_1p8)) {
> +			dev_err(motg->otg.dev, "unable to get hsusb 1p8\n");
> +			rc = PTR_ERR(hsusb_1p8);
> +			goto put_3p3_lpm;
> +		}
> +		rc = regulator_set_voltage(hsusb_1p8, USB_PHY_1P8_VOL_MIN,
> +				USB_PHY_1P8_VOL_MAX);
> +		if (rc) {
> +			dev_err(motg->otg.dev, "unable to set voltage level for"
> +					"hsusb 1p8\n");
> +			goto put_1p8;
> +		}
> +		rc = regulator_enable(hsusb_1p8);
> +		if (rc) {
> +			dev_err(motg->otg.dev, "unable to enable the hsusb 1p8\n");
> +			goto disable_1p8;
> +		}
> +
> +		return 0;
> +	}
> +
> +disable_1p8:
> +	regulator_set_voltage(hsusb_1p8, 0, USB_PHY_1P8_VOL_MAX);
> +	regulator_disable(hsusb_1p8);

    Why call regualator_disable() if regulator_enable() has just failed?

> +put_1p8:
> +	regulator_put(hsusb_1p8);
> +put_3p3_lpm:
> +	regulator_set_voltage(hsusb_3p3, 0, USB_PHY_3P3_VOL_MAX);
> +put_3p3:
> +	regulator_put(hsusb_3p3);
> +	return rc;
> +}
[...]
> @@ -1345,6 +1532,10 @@ free_irq:
>   disable_clks:
>   	clk_disable(motg->pclk);
>   	clk_disable(motg->clk);
> +free_ldo_init:

    'ldo_exit' perhaps?

> +	msm_hsusb_ldo_init(motg, 0);
> +free_config_vddcx:

    'vddcx_exit' perhaps?

> +	msm_hsusb_init_vddcx(motg, 0);
>   free_regs:
>   	iounmap(motg->regs);
>   put_core_clk:

WBR, Sergei

  reply	other threads:[~2011-04-29 10:15 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-28  8:01 [PATCH 1/5] USB: gadget: Use Zero Interrupt Threshold Control for ci13xxx_msm Pavankumar Kondeti
2011-04-28  8:01 ` [PATCH 2/5] USB: OTG: vote for dayatona fabric clock Pavankumar Kondeti
2011-04-28  8:01 ` [PATCH 3/5] USB: OTG: msm: Implement charger detection Pavankumar Kondeti
2011-04-28  8:01 ` [PATCH 4/5] USB: OTG: msm: Configure PHY Analog and Digital voltage domains Pavankumar Kondeti
2011-04-29 10:14   ` Sergei Shtylyov [this message]
2011-05-02  6:03     ` Pavan Kondeti
2011-04-28  8:01 ` [PATCH 5/5] USB: OTG: msm: Add PHY suspend support for MSM8960 Pavankumar Kondeti
2011-04-28 14:49   ` Sergei Shtylyov
2011-04-29  5:20     ` Pavan Kondeti
2011-04-28 12:18 ` [PATCH 1/5] USB: gadget: Use Zero Interrupt Threshold Control for ci13xxx_msm Sergei Shtylyov
2011-04-29  5:16   ` Pavan Kondeti
2011-04-29  5:22 ` Pavankumar Kondeti
2011-04-29  5:22   ` [PATCH 2/5] USB: OTG: vote for dayatona fabric clock Pavankumar Kondeti
2011-04-29  5:22   ` [PATCH 4/5] USB: OTG: msm: Configure PHY Analog and Digital voltage domains Pavankumar Kondeti
     [not found]   ` <1304054532-3523-1-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-04-29  5:22     ` [PATCH 3/5] USB: OTG: msm: Implement charger detection Pavankumar Kondeti
2011-04-29  5:22     ` [PATCH 5/5] USB: OTG: msm: Add PHY suspend support for MSM8960 Pavankumar Kondeti
2011-05-02  6:36 ` [PATCH V2 0/5] USB Charging, PHY init and " Pavankumar Kondeti
2011-05-02  6:36   ` [PATCH V2 1/5] USB: gadget: Use Zero Interrupt Threshold Control for ci13xxx_msm Pavankumar Kondeti
2011-05-02  6:36   ` [PATCH V2 2/5] USB: OTG: vote for dayatona fabric clock Pavankumar Kondeti
2011-05-02  6:36   ` [PATCH V2 3/5] USB: OTG: msm: Implement charger detection Pavankumar Kondeti
     [not found]   ` <1304318192-24374-1-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-05-02  6:36     ` [PATCH V2 4/5] USB: OTG: msm: Configure PHY Analog and Digital voltage domains Pavankumar Kondeti
2011-05-02  6:36   ` [PATCH V2 5/5] USB: OTG: msm: Add PHY suspend support for MSM8960 Pavankumar Kondeti
2011-05-02 12:22     ` Sergei Shtylyov
2011-05-03  5:01       ` Pavan Kondeti
     [not found] ` <1303977693-18389-1-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-05-02  9:58   ` [PATCH V3 0/5] USB Charging, PHY init and " Pavankumar Kondeti
     [not found]     ` <1304330325-21982-1-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-05-02  9:58       ` [PATCH V3 1/5] USB: gadget: Use Zero Interrupt Threshold Control for ci13xxx_msm Pavankumar Kondeti
2011-05-02  9:58       ` [PATCH V3 2/5] USB: OTG: msm: vote for dayatona fabric clock Pavankumar Kondeti
2011-05-02  9:58       ` [PATCH V3 3/5] USB: OTG: msm: Implement charger detection Pavankumar Kondeti
2011-05-02  9:58     ` [PATCH V3 4/5] USB: OTG: msm: Configure PHY Analog and Digital voltage domains Pavankumar Kondeti
2011-05-02  9:58     ` [PATCH V3 5/5] USB: OTG: msm: Add PHY suspend support for MSM8960 Pavankumar Kondeti
2011-05-03  5:13 ` [PATCH V4 0/5] USB Charging, PHY init and " Pavankumar Kondeti
     [not found]   ` <1304399633-16120-1-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-05-03  5:13     ` [PATCH V4 1/5] USB: gadget: Use Zero Interrupt Threshold Control for ci13xxx_msm Pavankumar Kondeti
2011-05-03  5:13   ` [PATCH V4 2/5] USB: OTG: msm: vote for dayatona fabric clock Pavankumar Kondeti
     [not found]     ` <1304399633-16120-3-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-05-03 11:14       ` Sergei Shtylyov
2011-05-03 12:29         ` Pavan Kondeti
2011-05-03 17:15           ` Greg KH
2011-05-04  4:48             ` Pavan Kondeti
2011-05-03  5:13   ` [PATCH V4 3/5] USB: OTG: msm: Implement charger detection Pavankumar Kondeti
2011-05-03  5:13   ` [PATCH V4 4/5] USB: OTG: msm: Configure PHY Analog and Digital voltage domains Pavankumar Kondeti
2011-05-03  5:13   ` [PATCH V4 5/5] USB: OTG: msm: Add PHY suspend support for MSM8960 Pavankumar Kondeti
2011-05-04  4:49 ` [PATCH V5 0/4] USB Charging, PHY init and " Pavankumar Kondeti
2011-05-04  4:49   ` [PATCH V5 1/4] USB: OTG: msm: vote for dayatona fabric clock Pavankumar Kondeti
2011-05-04  4:49   ` [PATCH V5 2/4] USB: OTG: msm: Implement charger detection Pavankumar Kondeti
     [not found]   ` <1304484589-17186-1-git-send-email-pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2011-05-04  4:49     ` [PATCH V5 3/4] USB: OTG: msm: Configure PHY Analog and Digital voltage domains Pavankumar Kondeti
2011-05-04  4:49     ` [PATCH V5 4/4] USB: OTG: msm: Add PHY suspend support for MSM8960 Pavankumar Kondeti

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=4DBA8F6D.7000508@ru.mvista.com \
    --to=sshtylyov@mvista.com \
    --cc=anjir@codeaurora.org \
    --cc=greg@kroah.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pkondeti@codeaurora.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.