public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>
To: Venu Byravarasu <vbyravarasu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
	balbi-l0cyMroinI0@public.gmane.org,
	stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org,
	linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/4] USB: PHY: Get rid of instance number to differentiate legacy controller
Date: Fri, 18 Jan 2013 20:34:16 +0200	[thread overview]
Message-ID: <20130118183416.GA1776@arwen.pp.htv.fi> (raw)
In-Reply-To: <1358343022-28919-3-git-send-email-vbyravarasu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 5699 bytes --]

On Wed, Jan 16, 2013 at 07:00:20PM +0530, Venu Byravarasu wrote:
> Tegra20 USB has 3 PHY instances. Instance 0 is based on
> legacy PHY interface and other two are standard interfaces.
> 
> As instance number was used to differentiate legacy from
> standard interfaces, used DT param to get this info and
> processed accordingly.
> 
> Signed-off-by: Venu Byravarasu <vbyravarasu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>

Acked-by: Felipe Balbi <balbi-l0cyMroinI0@public.gmane.org>

> ---
>  drivers/usb/phy/tegra_usb_phy.c   |   32 +++++++++++++++-----------------
>  include/linux/usb/tegra_usb_phy.h |    1 +
>  2 files changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
> index 3059384..79280fe 100644
> --- a/drivers/usb/phy/tegra_usb_phy.c
> +++ b/drivers/usb/phy/tegra_usb_phy.c
> @@ -24,6 +24,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/io.h>
>  #include <linux/gpio.h>
> +#include <linux/of.h>
>  #include <linux/of_gpio.h>
>  #include <linux/usb/otg.h>
>  #include <linux/usb/ulpi.h>
> @@ -221,7 +222,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
>  		return PTR_ERR(phy->pad_clk);
>  	}
>  
> -	if (phy->instance == 0) {
> +	if (phy->is_legacy_phy) {
>  		phy->pad_regs = phy->regs;
>  	} else {
>  		phy->pad_regs = ioremap(TEGRA_USB_BASE, TEGRA_USB_SIZE);
> @@ -236,7 +237,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
>  
>  static void utmip_pad_close(struct tegra_usb_phy *phy)
>  {
> -	if (phy->instance != 0)
> +	if (!phy->is_legacy_phy)
>  		iounmap(phy->pad_regs);
>  	clk_put(phy->pad_clk);
>  }
> @@ -305,7 +306,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
>  	unsigned long val;
>  	void __iomem *base = phy->regs;
>  
> -	if (phy->instance == 0) {
> +	if (phy->is_legacy_phy) {
>  		val = readl(base + USB_SUSP_CTRL);
>  		val |= USB_SUSP_SET;
>  		writel(val, base + USB_SUSP_CTRL);
> @@ -315,9 +316,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
>  		val = readl(base + USB_SUSP_CTRL);
>  		val &= ~USB_SUSP_SET;
>  		writel(val, base + USB_SUSP_CTRL);
> -	}
> -
> -	if (phy->instance == 2) {
> +	} else {
>  		val = readl(base + USB_PORTSC1);
>  		val |= USB_PORTSC1_PHCD;
>  		writel(val, base + USB_PORTSC1);
> @@ -332,7 +331,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
>  	unsigned long val;
>  	void __iomem *base = phy->regs;
>  
> -	if (phy->instance == 0) {
> +	if (phy->is_legacy_phy) {
>  		val = readl(base + USB_SUSP_CTRL);
>  		val |= USB_SUSP_CLR;
>  		writel(val, base + USB_SUSP_CTRL);
> @@ -342,9 +341,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
>  		val = readl(base + USB_SUSP_CTRL);
>  		val &= ~USB_SUSP_CLR;
>  		writel(val, base + USB_SUSP_CTRL);
> -	}
> -
> -	if (phy->instance == 2) {
> +	} else {
>  		val = readl(base + USB_PORTSC1);
>  		val &= ~USB_PORTSC1_PHCD;
>  		writel(val, base + USB_PORTSC1);
> @@ -365,7 +362,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
>  	val |= UTMIP_RESET;
>  	writel(val, base + USB_SUSP_CTRL);
>  
> -	if (phy->instance == 0) {
> +	if (phy->is_legacy_phy) {
>  		val = readl(base + USB1_LEGACY_CTRL);
>  		val |= USB1_NO_LEGACY_MODE;
>  		writel(val, base + USB1_LEGACY_CTRL);
> @@ -440,16 +437,14 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
>  	val |= UTMIP_BIAS_PDTRK_COUNT(0x5);
>  	writel(val, base + UTMIP_BIAS_CFG1);
>  
> -	if (phy->instance == 0) {
> +	if (phy->is_legacy_phy) {
>  		val = readl(base + UTMIP_SPARE_CFG0);
>  		if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE)
>  			val &= ~FUSE_SETUP_SEL;
>  		else
>  			val |= FUSE_SETUP_SEL;
>  		writel(val, base + UTMIP_SPARE_CFG0);
> -	}
> -
> -	if (phy->instance == 2) {
> +	} else {
>  		val = readl(base + USB_SUSP_CTRL);
>  		val |= UTMIP_PHY_ENABLE;
>  		writel(val, base + USB_SUSP_CTRL);
> @@ -459,7 +454,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
>  	val &= ~UTMIP_RESET;
>  	writel(val, base + USB_SUSP_CTRL);
>  
> -	if (phy->instance == 0) {
> +	if (phy->is_legacy_phy) {
>  		val = readl(base + USB1_LEGACY_CTRL);
>  		val &= ~USB1_VBUS_SENSE_CTL_MASK;
>  		val |= USB1_VBUS_SENSE_CTL_A_SESS_VLD;
> @@ -472,7 +467,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
>  
>  	utmi_phy_clk_enable(phy);
>  
> -	if (phy->instance == 2) {
> +	if (!phy->is_legacy_phy) {
>  		val = readl(base + USB_PORTSC1);
>  		val &= ~USB_PORTSC1_PTS(~0);
>  		writel(val, base + USB_PORTSC1);
> @@ -739,6 +734,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
>  	unsigned long parent_rate;
>  	int i;
>  	int err;
> +	struct device_node *np = dev->of_node;
>  
>  	phy = kzalloc(sizeof(struct tegra_usb_phy), GFP_KERNEL);
>  	if (!phy)
> @@ -749,6 +745,8 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
>  	phy->config = config;
>  	phy->mode = phy_mode;
>  	phy->dev = dev;
> +	phy->is_legacy_phy =
> +		of_property_read_bool(np, "nvidia,has-legacy-mode");
>  
>  	if (!phy->config) {
>  		if (phy_is_ulpi(phy)) {
> diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h
> index 34e6355..f03e157 100644
> --- a/include/linux/usb/tegra_usb_phy.h
> +++ b/include/linux/usb/tegra_usb_phy.h
> @@ -59,6 +59,7 @@ struct tegra_usb_phy {
>  	struct usb_phy *ulpi;
>  	struct usb_phy u_phy;
>  	struct device *dev;
> +	bool is_legacy_phy;
>  };
>  
>  struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
> -- 
> 1.7.0.4
> 

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2013-01-18 18:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 13:30 [PATCH 0/4] usb: Supporting patches for registering Tegra USB PHY as a platform driver Venu Byravarasu
2013-01-16 13:30 ` [PATCH 1/4] arm: tegra: Add DT nodes for Tegra USB PHY Venu Byravarasu
2013-01-16 21:49   ` Stephen Warren
2013-01-16 13:30 ` [PATCH 2/4] USB: PHY: Get rid of instance number to differentiate legacy controller Venu Byravarasu
     [not found]   ` <1358343022-28919-3-git-send-email-vbyravarasu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-18 18:34     ` Felipe Balbi [this message]
2013-01-16 13:30 ` [PATCH 3/4] USB: PHY: Tegra: Get rid of instance number to differentiate PHY type Venu Byravarasu
2013-01-18 17:04   ` Stephen Warren
     [not found]     ` <50F98089.6040008-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-01-18 17:07       ` Stephen Warren
     [not found]   ` <1358343022-28919-4-git-send-email-vbyravarasu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-18 18:34     ` Felipe Balbi
     [not found] ` <1358343022-28919-1-git-send-email-vbyravarasu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-16 13:30   ` [PATCH 4/4] usb: Add APIs to access host registers from Tegra PHY Venu Byravarasu
     [not found]     ` <1358343022-28919-5-git-send-email-vbyravarasu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-01-16 15:08       ` Alan Stern
2013-01-16 21:56         ` Stephen Warren
2013-01-16 22:25           ` Alan Stern

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=20130118183416.GA1776@arwen.pp.htv.fi \
    --to=balbi-l0cymroini0@public.gmane.org \
    --cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
    --cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
    --cc=vbyravarasu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox