linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 9/9] rcar-phy: handle platform data
@ 2013-04-23 15:42 Sergei Shtylyov
  2013-04-30 10:42 ` Felipe Balbi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2013-04-23 15:42 UTC (permalink / raw)
  To: linux-sh

Set the USBPCTRL0 register from the passed platform data in rcar_usb_phy_init();
don't reset it to 0 in  rcar_usb_phy_shutdown()  anymore as that does not make
sense.  Also, don't allow the driver's probe to succeed when the platform data
are not supplied with a device.

The patch has been tested on the Marzen and BOCK-W boards.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>

---
Changes since version 3:
- moved USBPCTRL0 register bit #define's from patch #7, removing the prefixes;
- implemented parsing of the platform data to set USBPCTRL0 register.

Changes since version 2:
- added a note about testing to the changelog;
- added ACKs from Simon Horman and Kuninori Morimoto.

 drivers/usb/phy/rcar-phy.c |   53 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 46 insertions(+), 7 deletions(-)

Index: renesas/drivers/usb/phy/rcar-phy.c
=================================--- renesas.orig/drivers/usb/phy/rcar-phy.c
+++ renesas/drivers/usb/phy/rcar-phy.c
@@ -1,8 +1,9 @@
 /*
  * Renesas R-Car USB phy driver
  *
- * Copyright (C) 2012 Renesas Solutions Corp.
+ * Copyright (C) 2012-2013 Renesas Solutions Corp.
  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ * Copyright (C) 2013 Cogent Embedded, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -11,10 +12,11 @@
 
 #include <linux/delay.h>
 #include <linux/io.h>
-#include <linux/usb/otg.h>
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
 #include <linux/module.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/rcar-phy.h>
 
 /* REGS block */
 #define USBPCTRL0	0x00
@@ -24,6 +26,25 @@
 #define USBOH0		0x1C
 #define USBCTL0		0x58
 
+/* USBPCTRL0 */
+#define OVC2		(1 << 10) /* Switches the OVC input pin for port 2: */
+				/* 1: USB_OVC2, 0: OVC2			*/
+#define OVC1_VBUS1	(1 << 9) /* Switches the OVC input pin for port 1: */
+				/* 1: USB_OVC1, 0: OVC1/VBUS1		*/
+				/* Function mode: set to 0		*/
+#define OVC0		(1 << 8) /* Switches the OVC input pin for port 0: */
+				/* 1: USB_OVC0 pin, 0: OVC0		*/
+#define OVC2_ACT 	(1 << 6) /* Host mode: OVC2 polarity:		*/
+				/* 1: active-high, 0: active-low	*/
+#define PENC		(1 << 4) /* Function mode: output level of PENC1 pin: */
+				/* 1: high, 0: low			*/
+#define OVC0_ACT 	(1 << 3) /* Host mode: OVC0 polarity:		*/
+				/* 1: active-high, 0: active-low	*/
+#define OVC1_ACT	(1 << 1) /* Host mode: OVC1 polarity:		*/
+				/* 1: active-high, 0: active-low	*/
+				/* Function mode: be sure to set to 1	*/
+#define PORT1		(1 << 0) /* Selects port 1 mode:		*/
+				/* 1: function, 0: host			*/
 /* USBPCTRL1 */
 #define PHY_RST		(1 << 2)
 #define PLL_ENB		(1 << 1)
@@ -55,7 +76,9 @@ static int rcar_usb_phy_init(struct usb_
 {
 	struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy);
 	struct device *dev = phy->dev;
+	struct rcar_phy_platform_data *pdata = dev->platform_data;
 	void __iomem *reg0 = priv->reg0;
+	const u8 ovcn_act[] = { OVC0_ACT, OVC1_ACT, OVC2_ACT };
 	int i;
 	u32 val;
 	unsigned long flags;
@@ -89,8 +112,21 @@ static int rcar_usb_phy_init(struct usb_
 		/* (4) USB-PHY reset clear */
 		iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
 
-		/* set platform specific port settings */
-		iowrite32(0x00000000, (reg0 + USBPCTRL0));
+		/* Board specific port settings */
+		val = 0;
+		if (pdata->port1_func)
+			val |= PORT1;
+		if (pdata->penc1)
+			val |= PENC;
+		for (i = 0; i < 3; i++) {
+			/* OVCn bits follow each other in the right order */
+			if (pdata->ovc_pin[i].select_3_3v)
+				val |= OVC0 << i;
+			/* OVCn_ACT bits are spaced by irregular intervals */
+			if (pdata->ovc_pin[i].active_high)
+				val |= ovcn_act[i];
+		}
+		iowrite32(val, (reg0 + USBPCTRL0));
 
 		/*
 		 * Bus alignment settings
@@ -117,10 +153,8 @@ static void rcar_usb_phy_shutdown(struct
 
 	spin_lock_irqsave(&priv->lock, flags);
 
-	if (priv->counter-- = 1) { /* last user */
-		iowrite32(0x00000000, (reg0 + USBPCTRL0));
+	if (priv->counter-- = 1)	/* last user */
 		iowrite32(0x00000000, (reg0 + USBPCTRL1));
-	}
 
 	spin_unlock_irqrestore(&priv->lock, flags);
 }
@@ -133,6 +167,11 @@ static int rcar_usb_phy_probe(struct pla
 	void __iomem *reg0;
 	int ret;
 
+	if (!pdev->dev.platform_data) {
+		dev_err(dev, "No platform data\n");
+		return -EINVAL;
+	}
+
 	res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res0) {
 		dev_err(dev, "Not enough platform resources\n");


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v6 9/9] rcar-phy: handle platform data
  2013-04-23 15:42 [PATCH v6 9/9] rcar-phy: handle platform data Sergei Shtylyov
@ 2013-04-30 10:42 ` Felipe Balbi
  2013-04-30 19:02 ` Sergei Shtylyov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Felipe Balbi @ 2013-04-30 10:42 UTC (permalink / raw)
  To: linux-sh

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

On Tue, Apr 23, 2013 at 07:42:07PM +0400, Sergei Shtylyov wrote:
> Set the USBPCTRL0 register from the passed platform data in rcar_usb_phy_init();
> don't reset it to 0 in  rcar_usb_phy_shutdown()  anymore as that does not make
> sense.  Also, don't allow the driver's probe to succeed when the platform data
> are not supplied with a device.
> 
> The patch has been tested on the Marzen and BOCK-W boards.
> 
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Acked-by: Simon Horman <horms+renesas@verge.net.au>

Acked-by: Felipe Balbi <balbi@ti.com>

> Index: renesas/drivers/usb/phy/rcar-phy.c
> ===================================================================
> --- renesas.orig/drivers/usb/phy/rcar-phy.c
> +++ renesas/drivers/usb/phy/rcar-phy.c
> @@ -11,10 +12,11 @@
>  
>  #include <linux/delay.h>
>  #include <linux/io.h>
> -#include <linux/usb/otg.h>
>  #include <linux/platform_device.h>
>  #include <linux/spinlock.h>
>  #include <linux/module.h>
> +#include <linux/usb/otg.h>

trailing change here. Please just mention it on the commit log. It
doesn't a patch of its own :-p

> @@ -89,8 +112,21 @@ static int rcar_usb_phy_init(struct usb_
>  		/* (4) USB-PHY reset clear */
>  		iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
>  
> -		/* set platform specific port settings */
> -		iowrite32(0x00000000, (reg0 + USBPCTRL0));
> +		/* Board specific port settings */
> +		val = 0;
> +		if (pdata->port1_func)
> +			val |= PORT1;
> +		if (pdata->penc1)
> +			val |= PENC;
> +		for (i = 0; i < 3; i++) {
> +			/* OVCn bits follow each other in the right order */
> +			if (pdata->ovc_pin[i].select_3_3v)
> +				val |= OVC0 << i;
> +			/* OVCn_ACT bits are spaced by irregular intervals */
> +			if (pdata->ovc_pin[i].active_high)
> +				val |= ovcn_act[i];
> +		}
> +		iowrite32(val, (reg0 + USBPCTRL0));

not all architectures provide iowrite32(). Please make sure your driver
builds on x86 and ARM by using SHOW_ALL_DRIVERS (on Kconfig).

BTW, conversion away from iowrite32() could (should) be part of a
separate patch. No need to prevent this one from being applied.

-- 
balbi

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v6 9/9] rcar-phy: handle platform data
  2013-04-23 15:42 [PATCH v6 9/9] rcar-phy: handle platform data Sergei Shtylyov
  2013-04-30 10:42 ` Felipe Balbi
@ 2013-04-30 19:02 ` Sergei Shtylyov
  2013-05-15 14:01 ` Felipe Balbi
  2013-05-15 14:05 ` Sergei Shtylyov
  3 siblings, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2013-04-30 19:02 UTC (permalink / raw)
  To: linux-sh

Hello.

On 04/30/2013 02:42 PM, Felipe Balbi wrote:

>
>> Set the USBPCTRL0 register from the passed platform data in rcar_usb_phy_init();
>> don't reset it to 0 in  rcar_usb_phy_shutdown()  anymore as that does not make
>> sense.  Also, don't allow the driver's probe to succeed when the platform data
>> are not supplied with a device.
>>
>> The patch has been tested on the Marzen and BOCK-W boards.
>>
>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
>> Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
>> Acked-by: Simon Horman <horms+renesas@verge.net.au>
> Acked-by: Felipe Balbi <balbi@ti.com>
>
>> Index: renesas/drivers/usb/phy/rcar-phy.c
>> =================================>> --- renesas.orig/drivers/usb/phy/rcar-phy.c
>> +++ renesas/drivers/usb/phy/rcar-phy.c
>> @@ -11,10 +12,11 @@
>>   
>>   #include <linux/delay.h>
>>   #include <linux/io.h>
>> -#include <linux/usb/otg.h>
>>   #include <linux/platform_device.h>
>>   #include <linux/spinlock.h>
>>   #include <linux/module.h>
>> +#include <linux/usb/otg.h>
> trailing change here.

    What do you mean by "trailing"? I just naturally grouped together 
headers from the same directory.

>   Please just mention it on the commit log. It doesn't a patch of its own :-p

    I'll drop it now probably as you told me to switch to 
include/linux/platfrom_data/...

>
>> @@ -89,8 +112,21 @@ static int rcar_usb_phy_init(struct usb_
>>   		/* (4) USB-PHY reset clear */
>>   		iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
>>   
>> -		/* set platform specific port settings */
>> -		iowrite32(0x00000000, (reg0 + USBPCTRL0));
>> +		/* Board specific port settings */
>> +		val = 0;
>> +		if (pdata->port1_func)
>> +			val |= PORT1;
>> +		if (pdata->penc1)
>> +			val |= PENC;
>> +		for (i = 0; i < 3; i++) {
>> +			/* OVCn bits follow each other in the right order */
>> +			if (pdata->ovc_pin[i].select_3_3v)
>> +				val |= OVC0 << i;
>> +			/* OVCn_ACT bits are spaced by irregular intervals */
>> +			if (pdata->ovc_pin[i].active_high)
>> +				val |= ovcn_act[i];
>> +		}
>> +		iowrite32(val, (reg0 + USBPCTRL0));
> not all architectures provide iowrite32(). Please make sure your driver
> builds on x86 and ARM by using SHOW_ALL_DRIVERS (on Kconfig).

    Sure, it builds on ARM because it was designed for ARM SH Mobile 
subarch.
I'll check x86 just in case.

> BTW, conversion away from iowrite32() could (should) be part of a
> separate patch. No need to prevent this one from being applied.
>

    Of course. You mean conversion to plain writel(), right?

WBR, Sergei


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v6 9/9] rcar-phy: handle platform data
  2013-04-23 15:42 [PATCH v6 9/9] rcar-phy: handle platform data Sergei Shtylyov
  2013-04-30 10:42 ` Felipe Balbi
  2013-04-30 19:02 ` Sergei Shtylyov
@ 2013-05-15 14:01 ` Felipe Balbi
  2013-05-15 14:05 ` Sergei Shtylyov
  3 siblings, 0 replies; 5+ messages in thread
From: Felipe Balbi @ 2013-05-15 14:01 UTC (permalink / raw)
  To: linux-sh

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

Hi,

On Tue, Apr 30, 2013 at 11:02:18PM +0400, Sergei Shtylyov wrote:
> >BTW, conversion away from iowrite32() could (should) be part of a
> >separate patch. No need to prevent this one from being applied.
> >
> 
>    Of course. You mean conversion to plain writel(), right?

right, "away" from iowrite32() ;-)

-- 
balbi

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v6 9/9] rcar-phy: handle platform data
  2013-04-23 15:42 [PATCH v6 9/9] rcar-phy: handle platform data Sergei Shtylyov
                   ` (2 preceding siblings ...)
  2013-05-15 14:01 ` Felipe Balbi
@ 2013-05-15 14:05 ` Sergei Shtylyov
  3 siblings, 0 replies; 5+ messages in thread
From: Sergei Shtylyov @ 2013-05-15 14:05 UTC (permalink / raw)
  To: linux-sh

Hello.

On 15-05-2013 18:01, Felipe Balbi wrote:

>>> BTW, conversion away from iowrite32() could (should) be part of a
>>> separate patch. No need to prevent this one from being applied.

>>     Of course. You mean conversion to plain writel(), right?

> right, "away" from iowrite32() ;-)

    Well, I used to think it's implemented everywhere now, as the recent 
trend seems to use it in preference to readl(), at least in several 
subsystems...

    BTW, how about ACKing patch #7 now that I've recast it?

WBR, Sergei


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-05-15 14:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-23 15:42 [PATCH v6 9/9] rcar-phy: handle platform data Sergei Shtylyov
2013-04-30 10:42 ` Felipe Balbi
2013-04-30 19:02 ` Sergei Shtylyov
2013-05-15 14:01 ` Felipe Balbi
2013-05-15 14:05 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).