[PATCH resend] usb: ehci-sh: convert to SPDX identifiers

2018-09-06 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch updates license to use SPDX-License-Identifier
instead of verbose license text.

Signed-off-by: Kuninori Morimoto 
---
- 2weeks passed. resend this patch again

 include/linux/platform_data/ehci-sh.h | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/include/linux/platform_data/ehci-sh.h 
b/include/linux/platform_data/ehci-sh.h
index 5c15a73..219bd79d 100644
--- a/include/linux/platform_data/ehci-sh.h
+++ b/include/linux/platform_data/ehci-sh.h
@@ -1,21 +1,9 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0
+ *
  * EHCI SuperH driver platform data
  *
  * Copyright (C) 2012  Nobuhiro Iwamatsu 
  * Copyright (C) 2012  Renesas Solutions Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #ifndef __USB_EHCI_SH_H
-- 
2.7.4



[PATCH v2] usb: ehci-sh: convert to SPDX identifiers

2018-08-05 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch updates license to use SPDX-License-Identifier
instead of verbose license text.

Signed-off-by: Kuninori Morimoto 
---
v1 -> v2

 - add changlog

 include/linux/platform_data/ehci-sh.h | 16 ++--
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/include/linux/platform_data/ehci-sh.h 
b/include/linux/platform_data/ehci-sh.h
index 5c15a73..219bd79d 100644
--- a/include/linux/platform_data/ehci-sh.h
+++ b/include/linux/platform_data/ehci-sh.h
@@ -1,21 +1,9 @@
-/*
+/* SPDX-License-Identifier: GPL-2.0
+ *
  * EHCI SuperH driver platform data
  *
  * Copyright (C) 2012  Nobuhiro Iwamatsu 
  * Copyright (C) 2012  Renesas Solutions Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #ifndef __USB_EHCI_SH_H
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: ehci-sh: convert to SPDX identifiers

2018-08-02 Thread Kuninori Morimoto


Hi Greg

> > From: Kuninori Morimoto 
> > 
> > Signed-off-by: Kuninori Morimoto 
> > ---
> >  include/linux/platform_data/ehci-sh.h | 14 +-
> >  1 file changed, 1 insertion(+), 13 deletions(-)
> 
> I can not take patches without any changelog text at all, sorry.

OK, will post v2 with changelog tomorrow

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: ehci-sh: convert to SPDX identifiers

2018-08-01 Thread Kuninori Morimoto


From: Kuninori Morimoto 

Signed-off-by: Kuninori Morimoto 
---
 include/linux/platform_data/ehci-sh.h | 14 +-
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/include/linux/platform_data/ehci-sh.h 
b/include/linux/platform_data/ehci-sh.h
index 5c15a73..d8397df 100644
--- a/include/linux/platform_data/ehci-sh.h
+++ b/include/linux/platform_data/ehci-sh.h
@@ -1,21 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * EHCI SuperH driver platform data
  *
  * Copyright (C) 2012  Nobuhiro Iwamatsu 
  * Copyright (C) 2012  Renesas Solutions Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #ifndef __USB_EHCI_SH_H
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: Kconfig: convert to SPDX identifiers

2018-07-30 Thread Kuninori Morimoto


From: Kuninori Morimoto 

By default all files without license information are under the default
license of the kernel, which is GPL version 2.

Signed-off-by: Kuninori Morimoto 
---
 drivers/usb/renesas_usbhs/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/renesas_usbhs/Kconfig 
b/drivers/usb/renesas_usbhs/Kconfig
index b26d7c3..7fdbff2 100644
--- a/drivers/usb/renesas_usbhs/Kconfig
+++ b/drivers/usb/renesas_usbhs/Kconfig
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
 #
 # Renesas USBHS Controller Drivers
 #
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] renesas_usbhs: use renesas_usbhs_get_info()

2017-11-07 Thread Kuninori Morimoto

From: Kuninori Morimoto <kuninori.morimoto...@renesas.com>

We already have renesas_usbhs_get_info() macro.
Let's use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto...@renesas.com>
---
Shimoda-san

can you please check this patch ?

 drivers/usb/renesas_usbhs/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c 
b/drivers/usb/renesas_usbhs/common.c
index 490ebc7..e1fdb95 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -534,7 +534,7 @@ static struct renesas_usbhs_platform_info 
*usbhs_parse_dt(struct device *dev)
 
 static int usbhs_probe(struct platform_device *pdev)
 {
-   struct renesas_usbhs_platform_info *info = dev_get_platdata(>dev);
+   struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
struct renesas_usbhs_driver_callback *dfunc;
struct usbhs_priv *priv;
struct resource *res, *irq_res;
@@ -712,7 +712,7 @@ static int usbhs_probe(struct platform_device *pdev)
 static int usbhs_remove(struct platform_device *pdev)
 {
struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
-   struct renesas_usbhs_platform_info *info = dev_get_platdata(>dev);
+   struct renesas_usbhs_platform_info *info = renesas_usbhs_get_info(pdev);
struct renesas_usbhs_driver_callback *dfunc = >driver_callback;
 
dev_dbg(>dev, "usb remove\n");
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/3] usb: renesas_usbhs: More compat strings

2015-12-10 Thread Kuninori Morimoto

Hi

> this short series adds generic, and soc-specific r8a7792 and r8a7793 compat
> strings to the Renesas USBHS driver. The intention is to provide a complete
> set of compat strings for known R-Car SoCs.
> 
> Changes since v2:
> * Split documentation of SoC names into separate patch
> * Use correct fallback compatibility string in example
> 
> Changes since v1:
> * Add R-Car Gen2 and Gen3 fallback compatibility strings rather than
>   a single compatibility string for all of R-Car.
> 
> Simon Horman (3):
>   usb: renesas_usbhs: add SoC names to compatibility string
> documentation
>   usb: renesas_usbhs: add fallback compatibility strings
>   usb: renesas_usbhs: add device tree support for r8a779[23]
> 
>  .../devicetree/bindings/usb/renesas_usbhs.txt| 20 
> +++-
>  drivers/usb/renesas_usbhs/common.c   |  9 +
>  2 files changed, 24 insertions(+), 5 deletions(-)

For all patches

Acked-by: Kuninori Morimoto <kuninori.morimoto...@renesas.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] usb: renesas_usbhs: add fallback compatibility strings

2015-12-09 Thread Kuninori Morimoto

Hi Simon

Thank you for your patch

> Add fallback compatibility strings for R-Car Gen2 and Gen3.
> This is in keeping with the fallback scheme being adopted wherever
> appropriate for drivers for Renesas SoCs.
> 
> Also add SoC names.
> 
> Signed-off-by: Simon Horman 
> ---
(snip)
>  Required properties:
>- compatible: Must contain one of the following:
> - - "renesas,usbhs-r8a7790"
> - - "renesas,usbhs-r8a7791"
> - - "renesas,usbhs-r8a7794"
> - - "renesas,usbhs-r8a7795"
> +
> + - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
> + - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
> + - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device
> + - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device
> + - "renesas,rcar-gen2-usbhs" for R-Car Gen2 compatibile device
> + - "renesas,rcar-gen3-usbhs" for R-Car Gen3 compatibile device
> +
> + When compatible with the generic version, nodes must list the
> + SoC-specific version corresponding to the platform first followed
> + by the generic version.

I think these can be separated ?

 1. document update for "renesas,usbhs-r8a77xx"
 2. add new "rcar-genX" (this patch)

>  Example:
>   usbhs: usb@e659 {
> - compatible = "renesas,usbhs-r8a7790";
> + compatible = "renesas,usbhs-r8a7790", "renesas,rcar-usbhs";

I think you want

 -  compatible = "renesas,usbhs-r8a7790", "renesas,rcar-usbhs";
 +  compatible = "renesas,usbhs-r8a7790", "renesas,rcar-gen2-usbhs";
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] usb: renesas_usbhs: add fallback compatibility string

2015-12-08 Thread Kuninori Morimoto

Hi Simon

> > > Add fallback compatibility string.
> > > This is in keeping with the fallback scheme being adopted wherever
> > > appropriate for drivers for Renesas SoCs.
> > > 
> > > Signed-off-by: Simon Horman 
> > > ---
> > (snip)
> > > + {
> > > + .compatible = "renesas,usbhs",
> > > + .data = (void *)USBHS_TYPE_RCAR_GEN2,
> > > + },
> > >   { },
> > >  };
> > 
> > I think this is too much. This driver is used not only from R-Car Gen2.
> > It will work as normal mode if .data was 0.
> > see usbhs_parse_dt()
> 
> Are you suggesting that we remove USBHS_TYPE_RCAR_GEN2 from the driver?

I mean this

+   {
+   .compatible = "renesas,usbhs",
+   },

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] usb: renesas_usbhs: add fallback compatibility string

2015-12-08 Thread Kuninori Morimoto

Hi Simon

> > > (As Sergei noted elsewhere, "renesas,rcar-usbhs" is consistent
> > >  with what I documented elsewhere in the patch)
> > 
> > "renesas,rcar-usbhs" is better,
> > but I guess you want to have "renesas,rcar-gen2-usbhs" ?
> > 
> > My understanding is these
> > 
> >  * renesas,usbhs-r8a77xx# SoC specific
> >  * renesas,rcar-usbhs   # R-Car common
> >  * renesas,rcar-gen2-usbhs  # R-Car Gen2 common
> >  * renesas,rcar-gen3-usbhs  # R-Car Gen3 common
> >  * renesas,usbhs# Renesas USBHS common
> > 
> 
> I was intentionally including gen3 as well. So I think we have two options:
> 
> 1. renesas,rcar-usbhs
> 2. renesas,rcar-gen2-usbhs and renesas,rcar-gen3-usbhs

Renesas USB always have pick feature/settings.
Thus, generic name (= "renesas,rcar-usbhs") is very risky IMO.
I think 2 is more safety.

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] usb: renesas_usbhs: add fallback compatibility string

2015-12-08 Thread Kuninori Morimoto

Hi Simon

> (As Sergei noted elsewhere, "renesas,rcar-usbhs" is consistent
>  with what I documented elsewhere in the patch)

"renesas,rcar-usbhs" is better,
but I guess you want to have "renesas,rcar-gen2-usbhs" ?

My understanding is these

 * renesas,usbhs-r8a77xx# SoC specific
 * renesas,rcar-usbhs   # R-Car common
 * renesas,rcar-gen2-usbhs  # R-Car Gen2 common
 * renesas,rcar-gen3-usbhs  # R-Car Gen3 common
 * renesas,usbhs# Renesas USBHS common
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] usb: renesas_usbhs: add fallback compatibility string

2015-12-07 Thread Kuninori Morimoto

Hi Simon

> Add fallback compatibility string.
> This is in keeping with the fallback scheme being adopted wherever
> appropriate for drivers for Renesas SoCs.
> 
> Signed-off-by: Simon Horman 
> ---
(snip)
> + {
> + .compatible = "renesas,usbhs",
> + .data = (void *)USBHS_TYPE_RCAR_GEN2,
> + },
>   { },
>  };

I think this is too much. This driver is used not only from R-Car Gen2.
It will work as normal mode if .data was 0.
see usbhs_parse_dt()
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: renesas_usbhs: Add support for R-Car H3

2015-09-18 Thread Kuninori Morimoto

Hi Shimoda-san

> This patch adds a compatible string to support for R-Car H3.
> 
> Since the HS-USB controller of R-Car H3 is almost the same specification
> with R-Car Gen2 (these have 16 pipes and usb-dmac), this patch
> sets the "type" of renesas_usbhs_driver_param to USBHS_TYPE_RCAR_GEN2.
> 
> Signed-off-by: Yoshihiro Shimoda 
> ---
(snip)
> diff --git a/drivers/usb/renesas_usbhs/common.c 
> b/drivers/usb/renesas_usbhs/common.c
> index 7b98e1d..2becd6b 100644
> --- a/drivers/usb/renesas_usbhs/common.c
> +++ b/drivers/usb/renesas_usbhs/common.c
> @@ -476,6 +476,10 @@ static const struct of_device_id usbhs_of_match[] = {
>   .compatible = "renesas,usbhs-r8a7794",
>   .data = (void *)USBHS_TYPE_RCAR_GEN2,
>   },
> + {
> + .compatible = "renesas,usbhs-r8a7795",
> + .data = (void *)USBHS_TYPE_RCAR_GEN2,
> + },

It is helpful for user if it is indicating Gen2 compatible.
Because r8a7795 is Gen3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: tidyup usbhs_for_each_dfifo macro

2015-04-13 Thread Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto...@renesas.com

Current usbhs_for_each_dfifo macro will read out-of-array's
memory after last loop operation.
It was not good C language operation, and the binary which was
compiled by (at least) gcc 4.8.1 is broken.

This patch is based on
925403f425a4a9c503f2fc295652647b1eb10d82
(usb: renesas_usbhs: tidyup original usbhsx_for_each_xxx macro)

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
Tested-by: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
---
 Felip

eoriginal patch was posted in

Subject: [PATCH][RFC] usb: renesas_usbhs: tidyup usbhs_for_each_dfifo macro
Date: Fri, 3 Apr 2015 00:42:53 +

This is non RFC version

 drivers/usb/renesas_usbhs/fifo.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h
index 04d3f8a..c7d9b86 100644
--- a/drivers/usb/renesas_usbhs/fifo.h
+++ b/drivers/usb/renesas_usbhs/fifo.h
@@ -44,10 +44,11 @@ struct usbhs_fifo_info {
struct usbhs_fifo dfifo[USBHS_MAX_NUM_DFIFO];
 };
 #define usbhsf_get_dnfifo(p, n)(((p)-fifo_info.dfifo[n]))
-#define usbhs_for_each_dfifo(priv, dfifo, i)   \
-   for ((i) = 0, dfifo = usbhsf_get_dnfifo(priv, (i)); \
-((i)  USBHS_MAX_NUM_DFIFO);   \
-(i)++, dfifo = usbhsf_get_dnfifo(priv, (i)))
+#define usbhs_for_each_dfifo(priv, dfifo, i)   \
+   for ((i) = 0;   \
+((i)  USBHS_MAX_NUM_DFIFO)  \
+((dfifo) = usbhsf_get_dnfifo(priv, (i)));  \
+(i)++)
 
 struct usbhs_pkt_handle;
 struct usbhs_pkt {
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH][RFC] usb: renesas_usbhs: tidyup usbhs_for_each_dfifo macro

2015-04-02 Thread Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto...@renesas.com

Current usbhs_for_each_dfifo macro will read out-of-array's
memory after last loop operation.
It was not good C language operation, and the kernel which was
compiled by (at least) gcc 4.8.1 will be broken.

This patch is based on
925403f425a4a9c503f2fc295652647b1eb10d82
(usb: renesas_usbhs: tidyup original usbhsx_for_each_xxx macro)

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 Shimoda-san
I didn't test patch on real board. Colud you please check/test it ?

 drivers/usb/renesas_usbhs/fifo.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h
index 04d3f8a..c7d9b86 100644
--- a/drivers/usb/renesas_usbhs/fifo.h
+++ b/drivers/usb/renesas_usbhs/fifo.h
@@ -44,10 +44,11 @@ struct usbhs_fifo_info {
struct usbhs_fifo dfifo[USBHS_MAX_NUM_DFIFO];
 };
 #define usbhsf_get_dnfifo(p, n)(((p)-fifo_info.dfifo[n]))
-#define usbhs_for_each_dfifo(priv, dfifo, i)   \
-   for ((i) = 0, dfifo = usbhsf_get_dnfifo(priv, (i)); \
-((i)  USBHS_MAX_NUM_DFIFO);   \
-(i)++, dfifo = usbhsf_get_dnfifo(priv, (i)))
+#define usbhs_for_each_dfifo(priv, dfifo, i)   \
+   for ((i) = 0;   \
+((i)  USBHS_MAX_NUM_DFIFO)  \
+((dfifo) = usbhsf_get_dnfifo(priv, (i)));  \
+(i)++)
 
 struct usbhs_pkt_handle;
 struct usbhs_pkt {
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] usb: renesas_usbhs: add support for requesting DT DMA

2015-01-21 Thread Kuninori Morimoto

Hi shimoda-san

 This patch series is based on Felipe's usb.git / testing/next branch.
 (commit id = 05cf6e00b8ff2b80c8b2d1e69f07cdd6c830efe0)
 
 Yoshihiro Shimoda (2):
   usb: renesas_usbhs: add usbhsf_dma_init_pdev() function
   usb: renesas_usbhs: add support for requesting DT DMA
 
  .../devicetree/bindings/usb/renesas_usbhs.txt  |2 ++
  drivers/usb/renesas_usbhs/fifo.c   |   21 
 +---
  2 files changed, 20 insertions(+), 3 deletions(-)

I guess we can (should ?) use dma_request_slave_channel_compat()
instead of dma_request_slave_channel_reason().
And, we can use shdma_chan_filter instead of original usbhsf_dma_filter()

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] usb: renesas_usbhs: gadget: fix NULL pointer dereference in ep_disable()

2014-09-10 Thread Kuninori Morimoto

Hi Shimoda-san

 --- a/drivers/usb/renesas_usbhs/mod_gadget.c
 +++ b/drivers/usb/renesas_usbhs/mod_gadget.c
 @@ -602,6 +602,9 @@ static int usbhsg_ep_disable(struct usb_ep *ep)
   struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
   struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
 
 + if (!uep || !uep-pipe)
 + return -EINVAL;
 +
   usbhsg_pipe_disable(uep);
   usbhs_pipe_free(pipe);

If uep can be NULL,
we need care about usbhsg_uep_to_pipe(uep) too.

and, uep-pipe is same as pipe ?

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2

2014-08-04 Thread Kuninori Morimoto

Hi

 This driver supports other SoCs, but they need boards/Soc depend code.
 So, this patch adds device tree support for R-Car H2 and M2 initially.
 
 Changes from v1:
  - Change an optional property name from buswait_bwait to buswait in
patch 1.
  - Add the prefix renesas, to buswait and enable-gpio in patch 1.
  - Modify the usbhs_parse_dt() to remove the check of some
of_device_is_compatible() in patch 2.
 
 Yoshihiro Shimoda (2):
   usb: renesas_usbhs: Add device tree bindings documentation
   usb: renesas_usbhs: Add device tree support for R-Car H2 and M2
 
  .../devicetree/bindings/usb/renesas_usbhs.txt  |   24 +++
  drivers/usb/renesas_usbhs/common.c |   44 
 
  2 files changed, 68 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/usb/renesas_usbhs.txt

For all patches

Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] usb: renesas_usbhs: Add device tree support for R-Car H2 and M2

2014-08-03 Thread Kuninori Morimoto

Hi Shimoda-san

 This driver supports other SoCs, but they need boards/Soc depend code.
 So, this patch adds device tree support for R-Car H2 and M2 initially.
 
 Signed-off-by: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
 ---
(snip)
 +static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
 +{
 + struct renesas_usbhs_platform_info *info;
 + struct renesas_usbhs_driver_param *dparam;
 + u32 tmp;
 + int gpio;
 +
 + info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
 + if (!info)
 + return NULL;
 +
 + dparam = info-driver_param;
 +
 + if (of_device_is_compatible(dev-of_node, renesas,usbhs-r8a7790))
 + dparam-type = USBHS_TYPE_R8A7790;
 +
 + if (of_device_is_compatible(dev-of_node, renesas,usbhs-r8a7791))
 + dparam-type = USBHS_TYPE_R8A7791;
 +
 + if (!of_property_read_u32(dev-of_node, buswait_bwait, tmp))
 + dparam-buswait_bwait = tmp;
 + gpio = of_get_named_gpio_flags(dev-of_node, enable-gpio, 0, NULL);
 + if (gpio  0)
 + dparam-enable_gpio = gpio;
(snip)
 +static const struct of_device_id usbhs_of_match[] = {
 + { .compatible = renesas,usbhs-r8a7790},
 + { .compatible = renesas,usbhs-r8a7791},
 + { },

How about to use of_device_id :: data for USBHS_TYPE_xxx ?

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/2] ARM: shmobile: lager: USBHS callback elimination

2014-07-10 Thread Kuninori Morimoto

Hi

 Changes in v2:
 - move phy handle to struct usbhs_priv
 - add new default pipe type to driver
 - remove pipe type from Lager board code
 
 Ulrich Hecht (2):
   usb: renesas_usbhs: add R-Car Gen. 2 init and power control
   ARM: shmobile: lager: remove USBHS callbacks
 
  arch/arm/mach-shmobile/board-lager.c | 126 
 ---
  drivers/usb/renesas_usbhs/Makefile   |   2 +-
  drivers/usb/renesas_usbhs/common.c   |  66 --
  drivers/usb/renesas_usbhs/common.h   |   2 +
  drivers/usb/renesas_usbhs/rcar2.c|  76 +
  drivers/usb/renesas_usbhs/rcar2.h|   4 ++
  include/linux/usb/renesas_usbhs.h|   6 ++
  7 files changed, 163 insertions(+), 119 deletions(-)
  create mode 100644 drivers/usb/renesas_usbhs/rcar2.c
  create mode 100644 drivers/usb/renesas_usbhs/rcar2.h

For all patches

Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] usb: renesas_usbhs: gadget: fix for g_zero

2014-07-09 Thread Kuninori Morimoto
Hi

 From a5aea0fe3afcdfea82f08806856747e426ba8064 Mon Sep 17 00:00:00 2001
 From: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
 Date: Wed, 9 Jul 2014 20:18:56 +0900
 Subject: [PATCH 0/2] usb: renesas_usbhs: gadget: fix for g_zero
 
 This patch fixes an issue that the renesas_usbhs driver in gadget mode
 cannot work correctly even if I disabled DMAC of the driver when I used
 the g_zero driver and the testusb tool.
 
 Yoshihiro Shimoda (2):
   usb: renesas_usbhs: fix usbhs_pipe_malloc() to re-enable a pipe.
   usb: renesas_usbhs: gadget: fix re-enabling pipe without
 re-connecting
 
  drivers/usb/renesas_usbhs/mod_gadget.c |2 ++
  drivers/usb/renesas_usbhs/pipe.c   |   11 +++
  drivers/usb/renesas_usbhs/pipe.h   |1 +
  3 files changed, 14 insertions(+)

For all patches

Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] usb: renesas_usbhs: add R-Car Gen. 2 init and power control

2014-07-08 Thread Kuninori Morimoto

Hi Ulrich

Thank you for your patch

 In preparation for DT conversion to reduce reliance on platform device
 callbacks.
 
 Signed-off-by: Ulrich Hecht ulrich.hecht+rene...@gmail.com
 ---
(snip)
 @@ -186,6 +192,8 @@ struct renesas_usbhs_platform_info {
* driver use these param for some register
*/
   struct renesas_usbhs_driver_param   driver_param;
 +
 + struct usb_phy *phy;
  };

Using renesas_usbhs_platform_info for *phy is not good idea from my point of 
view.
Because its memory is located on platform side.
(this is the reason why usbhs_probe() using memcpy() for getting info-xxx)

I guess struct usbhs_priv is good place,
and you can use usbhs_pdev_to_priv() for this purpose ?

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: renesas: gadget: fixup: complete STATUS stage after receiving

2014-06-18 Thread Kuninori Morimoto

ping ?

 From: Kuninori Morimoto kuninori.morimoto...@renesas.com
 
 Current usbhs gadget driver didn't complete STATUS stage after receiving.
 It wasn't problem for us before, because some USB class doesn't use
 DATA OUT stage in control transfer.
 But, it is required on some device.
 
 Signed-off-by: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
 Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 ---
  drivers/usb/renesas_usbhs/fifo.c |8 
  1 file changed, 8 insertions(+)
 
 diff --git a/drivers/usb/renesas_usbhs/fifo.c 
 b/drivers/usb/renesas_usbhs/fifo.c
 index d49f9c3..4fd3653 100644
 --- a/drivers/usb/renesas_usbhs/fifo.c
 +++ b/drivers/usb/renesas_usbhs/fifo.c
 @@ -681,6 +681,14 @@ usbhs_fifo_read_end:
   usbhs_pipe_number(pipe),
   pkt-length, pkt-actual, *is_done, pkt-zero);
  
 + /*
 +  * Transmission end
 +  */
 + if (*is_done) {
 + if (usbhs_pipe_is_dcp(pipe))
 + usbhs_dcp_control_transfer_done(pipe);
 + }
 +
  usbhs_fifo_read_busy:
   usbhsf_fifo_unselect(pipe, fifo);
  
 -- 
 1.7.9.5
 
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: renesas: gadget: fixup: complete STATUS stage after receiving

2014-06-02 Thread Kuninori Morimoto

Hi Sergei

  +   /*
  +* Transmission end
  +*/
  +   if (*is_done) {
  +   if (usbhs_pipe_is_dcp(pipe))
 
 Why not collapse these into single *if*? That would decrease the 
 indentation level...

This is same style with TX case

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas: gadget: fixup: complete STATUS stage after receiving

2014-06-01 Thread Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto...@renesas.com

Current usbhs gadget driver didn't complete STATUS stage after receiving.
It wasn't problem for us before, because some USB class doesn't use
DATA OUT stage in control transfer.
But, it is required on some device.

Signed-off-by: Yoshihiro Shimoda yoshihiro.shimoda...@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/fifo.c |8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index d49f9c3..4fd3653 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -681,6 +681,14 @@ usbhs_fifo_read_end:
usbhs_pipe_number(pipe),
pkt-length, pkt-actual, *is_done, pkt-zero);
 
+   /*
+* Transmission end
+*/
+   if (*is_done) {
+   if (usbhs_pipe_is_dcp(pipe))
+   usbhs_dcp_control_transfer_done(pipe);
+   }
+
 usbhs_fifo_read_busy:
usbhsf_fifo_unselect(pipe, fifo);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] usb: renesas_usbhs: remove original filter from usbhsf_dma_init()

2013-12-12 Thread Kuninori Morimoto

Hi Felipe

  +   chan = dma_request_slave_channel_compat(mask,
  +   shdma_chan_filter, (void *)id, dev, name);
 
 this adds a build warning:
 
 drivers/usb/renesas_usbhs/fifo.c:1012:24: warning: cast to pointer from
 integer of different size [-Wint-to-pointer-cast]
  shdma_chan_filter, (void *)id, dev, name);
 
 Please fix it, I'll drop this patch for now.

Thank you.
shdma_chan_filer requests int id as void * somehow.
I will fix it first, and send v2 patch after that.
Thank you
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] usb: renesas_usbhs: DMAEngine cleanup

2013-12-10 Thread Kuninori Morimoto

Hi Felipe again

# my previous email didn't include USB-ML

These patches cleanup DMAEngine port on renesas_usbhs.
#1 is bugfix patch
#2 is new feature patch

Kuninori Morimoto (2):
  usb: renesas_usbhs: fifo: request DMAEngine once
  usb: renesas_usbhs: remove original filter from usbhsf_dma_init()

 drivers/usb/renesas_usbhs/fifo.c |   90 +-
 drivers/usb/renesas_usbhs/fifo.h |3 --
 2 files changed, 41 insertions(+), 52 deletions(-)

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] usb: renesas_usbhs: fifo: request DMAEngine once

2013-12-10 Thread Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto...@renesas.com

DMAEngine uses IRQ if dma_request_channel() was called,
and it is using devm_request_irq() today,
OTOH, dma_request_channel() will be called when each
USB connection happened on this driver.
This means same IRQ will be requested many times
whenever each USB connected,
and this IRQ isn't freed when USB disconnected.
Request DMAEngine once.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/fifo.c |   18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 45b9401..d49f9c3 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -1124,19 +1124,8 @@ void usbhs_fifo_init(struct usbhs_priv *priv)
mod-irq_brdysts= 0;
 
cfifo-pipe = NULL;
-   cfifo-tx_chan  = NULL;
-   cfifo-rx_chan  = NULL;
-
d0fifo-pipe= NULL;
-   d0fifo-tx_chan = NULL;
-   d0fifo-rx_chan = NULL;
-
d1fifo-pipe= NULL;
-   d1fifo-tx_chan = NULL;
-   d1fifo-rx_chan = NULL;
-
-   usbhsf_dma_init(priv, usbhsf_get_d0fifo(priv));
-   usbhsf_dma_init(priv, usbhsf_get_d1fifo(priv));
 }
 
 void usbhs_fifo_quit(struct usbhs_priv *priv)
@@ -1147,9 +1136,6 @@ void usbhs_fifo_quit(struct usbhs_priv *priv)
mod-irq_ready  = NULL;
mod-irq_bempsts= 0;
mod-irq_brdysts= 0;
-
-   usbhsf_dma_quit(priv, usbhsf_get_d0fifo(priv));
-   usbhsf_dma_quit(priv, usbhsf_get_d1fifo(priv));
 }
 
 int usbhs_fifo_probe(struct usbhs_priv *priv)
@@ -1171,6 +1157,7 @@ int usbhs_fifo_probe(struct usbhs_priv *priv)
fifo-ctr   = D0FIFOCTR;
fifo-tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, 
d0_tx_id);
fifo-rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, 
d0_rx_id);
+   usbhsf_dma_init(priv, fifo);
 
/* D1FIFO */
fifo = usbhsf_get_d1fifo(priv);
@@ -1180,10 +1167,13 @@ int usbhs_fifo_probe(struct usbhs_priv *priv)
fifo-ctr   = D1FIFOCTR;
fifo-tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, 
d1_tx_id);
fifo-rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, 
d1_rx_id);
+   usbhsf_dma_init(priv, fifo);
 
return 0;
 }
 
 void usbhs_fifo_remove(struct usbhs_priv *priv)
 {
+   usbhsf_dma_quit(priv, usbhsf_get_d0fifo(priv));
+   usbhsf_dma_quit(priv, usbhsf_get_d1fifo(priv));
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] usb: renesas_usbhs: remove original filter from usbhsf_dma_init()

2013-12-10 Thread Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto...@renesas.com

Remove original filter from usbhsf_dma_init(),
and use SH-DMA suitable filter.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/fifo.c |   76 +++---
 drivers/usb/renesas_usbhs/fifo.h |3 --
 2 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index d49f9c3..7f4aec4 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -981,23 +981,6 @@ struct usbhs_pkt_handle usbhs_fifo_dma_pop_handler = {
 /*
  * DMA setting
  */
-static bool usbhsf_dma_filter(struct dma_chan *chan, void *param)
-{
-   struct sh_dmae_slave *slave = param;
-
-   /*
-* FIXME
-*
-* usbhs doesn't recognize id = 0 as valid DMA
-*/
-   if (0 == slave-shdma_slave.slave_id)
-   return false;
-
-   chan-private = slave;
-
-   return true;
-}
-
 static void usbhsf_dma_quit(struct usbhs_priv *priv, struct usbhs_fifo *fifo)
 {
if (fifo-tx_chan)
@@ -1009,27 +992,46 @@ static void usbhsf_dma_quit(struct usbhs_priv *priv, 
struct usbhs_fifo *fifo)
fifo-rx_chan = NULL;
 }
 
-static void usbhsf_dma_init(struct usbhs_priv *priv,
-   struct usbhs_fifo *fifo)
+static struct dma_chan*
+__usbhsf_dma_init(struct usbhs_priv *priv, int id, char *name,
+ enum dma_transfer_direction direction)
 {
struct device *dev = usbhs_priv_to_dev(priv);
+   struct dma_slave_config cfg;
+   struct dma_chan *chan;
dma_cap_mask_t mask;
+   int ret;
 
-   dma_cap_zero(mask);
-   dma_cap_set(DMA_SLAVE, mask);
-   fifo-tx_chan = dma_request_channel(mask, usbhsf_dma_filter,
-   fifo-tx_slave);
+   if (!id)
+   return NULL;
 
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
-   fifo-rx_chan = dma_request_channel(mask, usbhsf_dma_filter,
-   fifo-rx_slave);
-
-   if (fifo-tx_chan || fifo-rx_chan)
-   dev_dbg(dev, enable DMAEngine (%s%s%s)\n,
-fifo-name,
-fifo-tx_chan ? [TX] : ,
-fifo-rx_chan ? [RX] : );
+
+   chan = dma_request_slave_channel_compat(mask,
+   shdma_chan_filter, (void *)id, dev, name);
+   if (!chan)
+   return NULL;
+
+   cfg.slave_id= id;
+   cfg.dst_addr= 0; /* use default addr */
+   cfg.src_addr= 0; /* use default addr */
+   cfg.direction   = direction;
+
+   ret = dmaengine_slave_config(chan, cfg);
+   if (ret  0) {
+   dma_release_channel(chan);
+   return NULL;
+   }
+
+   return chan;
+}
+
+static void usbhsf_dma_init(struct usbhs_priv *priv, struct usbhs_fifo *fifo,
+   int tx_id, int rx_id)
+{
+   fifo-tx_chan = __usbhsf_dma_init(priv, tx_id, tx, DMA_MEM_TO_DEV);
+   fifo-rx_chan = __usbhsf_dma_init(priv, rx_id, rx, DMA_DEV_TO_MEM);
 }
 
 /*
@@ -1155,9 +1157,9 @@ int usbhs_fifo_probe(struct usbhs_priv *priv)
fifo-port  = D0FIFO;
fifo-sel   = D0FIFOSEL;
fifo-ctr   = D0FIFOCTR;
-   fifo-tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, 
d0_tx_id);
-   fifo-rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, 
d0_rx_id);
-   usbhsf_dma_init(priv, fifo);
+   usbhsf_dma_init(priv, fifo,
+   usbhs_get_dparam(priv, d0_tx_id),
+   usbhs_get_dparam(priv, d0_rx_id));
 
/* D1FIFO */
fifo = usbhsf_get_d1fifo(priv);
@@ -1165,9 +1167,9 @@ int usbhs_fifo_probe(struct usbhs_priv *priv)
fifo-port  = D1FIFO;
fifo-sel   = D1FIFOSEL;
fifo-ctr   = D1FIFOCTR;
-   fifo-tx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, 
d1_tx_id);
-   fifo-rx_slave.shdma_slave.slave_id = usbhs_get_dparam(priv, 
d1_rx_id);
-   usbhsf_dma_init(priv, fifo);
+   usbhsf_dma_init(priv, fifo,
+   usbhs_get_dparam(priv, d1_tx_id),
+   usbhs_get_dparam(priv, d1_rx_id));
 
return 0;
 }
diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h
index a168a17..7c5706a 100644
--- a/drivers/usb/renesas_usbhs/fifo.h
+++ b/drivers/usb/renesas_usbhs/fifo.h
@@ -33,9 +33,6 @@ struct usbhs_fifo {
 
struct dma_chan *tx_chan;
struct dma_chan *rx_chan;
-
-   struct sh_dmae_slavetx_slave;
-   struct sh_dmae_slaverx_slave;
 };
 
 struct usbhs_fifo_info {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo

Re: [PATCH 3/3] arm: shmobile: lager: Add USBHS support

2013-10-08 Thread Kuninori Morimoto

Hi Valentine

  +/* USBHS */
  +#if IS_ENABLED(CONFIG_USB_RENESAS_USBHS_UDC)
  +static const struct resource usbhs_resources[] __initconst = {
  +  DEFINE_RES_MEM(0xe659, 0x100),
  +  DEFINE_RES_IRQ(gic_spi(107)),
  +};
 
  Why it needs #if IS_ENABLED() ?
  I guess nothing happen if renesas_usbhs driver
  registered without CONFIG_USB_RENESAS_USBHS_UDC.
  But am I misunderstanding ?
 
 
 Since USB channel 0 is shared between PCI USB host and USBHS
 we'll still need it later to properly configure the channel.
 Besides, is saves us some bits leaving all the unused callbacks and 
 device structures out if we do not register the device when the driver 
 is disabled.

Ahh, I see.
Sorry for my noise

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] usb: phy: Add RCAR Gen2 USB phy

2013-10-08 Thread Kuninori Morimoto

Hi Valentine

   From my point of view, if you use clk_enable() on setup(),
  then, it is easy to read if it has exit() or similar name function
  which calls clk_disable()
 
 Since in this case all is needed is to disable the clocks, I've decided 
 not to put it in a separate exit function. I'll add one for better 
 readability.

Thank you

  Are these usecount++/usecount-- position correct ?
 
 The idea was to disable the clocks here if the phy is not used by other 
 drivers (PCI USB host or USBSS), so that suspending the gadget would 
 disable USBHS clocks. However, this needs phy enabled before the 
 shutdown is called. I guess I'll drop the clock handling here and leave 
 it solely to init/shutdown callbacks.

Thank you

  +  clk = devm_clk_get(pdev-dev, usbhs);
  +  if (IS_ERR(clk)) {
  +  dev_err(pdev-dev, Can't get the clock\n);
  +  return PTR_ERR(clk);
  +  }
 
  This case (if you use usb_phy_rcar_gen2 driver),
  you can use pm_runtime_xxx instead of clk_get/enable/disable()
 
 
 Yes, I could. The reason I did not is that I'm not sure that a phy 
 driver should use runtime PM, since it is actually mastered by other 
 drivers which are supposed to control its power via init/shutdown and 
 set_suspend callbacks. Thus, looks like the phy driver can't really 
 auto-suspend and doesn't really support runtime PM.
 
 I think that handling clocks in the init/shutdown is a bit cleaner.
 It gives us more control over the phy power, where pm_runtime_xxx will 
 do nothing if CONFIG_PM_RUNTIME is disabled.

OK, it is reasonable for me

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] Add USBHS support to Lager (take 2)

2013-10-08 Thread Kuninori Morimoto

Hi

 This patch set adds internal USB PHY support to RCAR Gen2 SoC, and
 also enables USBHS for the Lager board. It has been updated, based
 on the comments to the previous version.
 
 The patches apply fine to the renesas-devel-20131008 tag of the renesas.git.
 The first patch also applies fine to the usb.git at kernel.org.
 It adds RCAR Gen2 phy driver which is used to configure the shared USB
 channels 0/2 and to control USBHS internal PHY.
 All the drivers that use the shared USB channels (USBHS/USBSS/PCI USB host)
 should acquire the USB phy first to set proper channel configuration.
 
 The other two patches add USBHS support to Lager board, which requires
 RCAR Gen2 phy driver.
 
 Changes from previous version:
 * use-counting and clock handling done in the usb_phy_init/shutdown
   callbacks only;
 * a minor typo in the comments fixed;
 * phy clean up moved to __rcar_gen2_usb_phy_shutdown function;
 * usb_phy_init/shutdown called from usbhs_power_ctrl callback
   to allow renesas_usbhs driver disable USB PHY completely
   when it is not needed.
 
 Valentine Barshak (3):
   usb: phy: Add RCAR Gen2 USB phy
   arm: shmobile: r8a7790: Add USBHS clock support
   arm: shmobile: lager: Add USBHS support
 
  arch/arm/mach-shmobile/board-lager.c| 106 ++
  arch/arm/mach-shmobile/clock-r8a7790.c  |   4 +
  drivers/usb/phy/Kconfig |  13 ++
  drivers/usb/phy/Makefile|   1 +
  drivers/usb/phy/phy-rcar-gen2-usb.c | 255 
 
  include/linux/platform_data/usb-rcar-gen2-phy.h |  22 ++
  6 files changed, 401 insertions(+)
  create mode 100644 drivers/usb/phy/phy-rcar-gen2-usb.c
  create mode 100644 include/linux/platform_data/usb-rcar-gen2-phy.h

For all patches

Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com

# I think we can implement usb_phy_xxx() method
# in renesas_usbhs driver someday.

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] arm: shmobile: r8a7790: Add USBHS clock support

2013-10-07 Thread Kuninori Morimoto

Hi Valentine

 @@ -296,6 +298,8 @@ static struct clk_lookup lookups[] = {
   CLKDEV_DEV_ID(ee22.mmcif, mstp_clks[MSTP305]),
   CLKDEV_DEV_ID(sh_mmcif.1, mstp_clks[MSTP305]),
   CLKDEV_DEV_ID(sh_cmt.0, mstp_clks[MSTP124]),
 + CLKDEV_DEV_ID(renesas_usbhs, mstp_clks[MSTP704]),
 + CLKDEV_ICK_ID(usbhs, usb_phy_rcar_gen2, mstp_clks[MSTP704]),

This case, you can use

CLKDEV_DEV_ID(usb_phy_rcar_gen2, mstp_clks[MSTP704]),

and no clk_get() is needed.
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/3] usb: phy: Add RCAR Gen2 USB phy

2013-10-07 Thread Kuninori Morimoto

Hi Valentine

Thank you for your patch

 +/* Setup USB channels */
 +static void __rcar_gen2_usb_phy_setup(struct rcar_gen2_usb_phy_priv *priv)
 +{
 + u32 val;
 +
 + clk_prepare_enable(priv-clk);
 +
 + /* Set USB channels in the USBHS UGCTRL2 register */
 + val = ioread32(priv-base);
 + val = ~(USBHS_UGCTRL2_USB0_HS | USBHS_UGCTRL2_USB2_SS);
 + val |= priv-ugctrl2;
 + iowrite32(val, priv-base);
 +}

From my point of view, if you use clk_enable() on setup(),
then, it is easy to read if it has exit() or similar name function
which calls clk_disable()

 +static int rcar_gen2_usb_phy_set_suspend(struct usb_phy *phy, int suspend)
 +{
 + struct rcar_gen2_usb_phy_priv *priv = usb_phy_to_priv(phy);
 + unsigned long flags;
 + int retval;
 +
 + spin_lock_irqsave(priv-lock, flags);
 + if (suspend) {
 + /* Suspend USBHS internal phy */
 + retval = __rcar_gen2_usbhs_phy_disable(priv-base);
 + /*
 +  * If nothing else is using USB channel 0/2
 +  * disable the clocks as well
 +  */
 + if (priv-usecount == 1) {
 + clk_disable_unprepare(priv-clk);
 + priv-usecount--;
 + }
 + } else {
 + /*
 +  * Enable the clock and setup USB channels
 +  * if needed.
 +  */
 + if (!priv-usecount) {
 + priv-usecount++;
 + __rcar_gen2_usb_phy_setup(priv);
 + }
 + /* Resume USBHS internal phy */
 + retval = __rcar_gen2_usbhs_phy_enable(priv-base);
 + }

Are these usecount++/usecount-- position correct ?

 +static int rcar_gen2_usb_phy_probe(struct platform_device *pdev)
 +{
 + struct device *dev = pdev-dev;
 + struct rcar_gen2_phy_platform_data *pdata;
 + struct rcar_gen2_usb_phy_priv *priv;
 + struct resource *res;
 + void __iomem *base;
 + struct clk *clk;
 + int retval;
 +
 + pdata = dev_get_platdata(pdev-dev);
 + if (!pdata) {
 + dev_err(dev, No platform data\n);
 + return -EINVAL;
 + }
 +
 + clk = devm_clk_get(pdev-dev, usbhs);
 + if (IS_ERR(clk)) {
 + dev_err(pdev-dev, Can't get the clock\n);
 + return PTR_ERR(clk);
 + }

This case (if you use usb_phy_rcar_gen2 driver),
you can use pm_runtime_xxx instead of clk_get/enable/disable()

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] arm: shmobile: lager: Add USBHS support

2013-10-07 Thread Kuninori Morimoto

Hi Valentine

 This adds USBHS PHY and registers USBHS device if the driver is enabled.
 
 Signed-off-by: Valentine Barshak valentine.bars...@cogentembedded.com
 ---
(snip)
 +/* USBHS */
 +#if IS_ENABLED(CONFIG_USB_RENESAS_USBHS_UDC)
 +static const struct resource usbhs_resources[] __initconst = {
 + DEFINE_RES_MEM(0xe659, 0x100),
 + DEFINE_RES_IRQ(gic_spi(107)),
 +};

Why it needs #if IS_ENABLED() ?
I guess nothing happen if renesas_usbhs driver
registered without CONFIG_USB_RENESAS_USBHS_UDC.
But am I misunderstanding ?
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: tidyup original usbhsx_for_each_xxx macro

2013-07-11 Thread Kuninori Morimoto
Current usbhsx_for_each_xxx macro will read out-of-array's
memory after last loop operation.
It was not good C language operation, and the binary which was
compiled by (at least) gcc 4.8.1 is broken
This patch tidyup these issues

Reported-by: Yusuke Goda yusuke.goda...@renesas.com
Reviewed-by: Takashi Yoshii takashi.yoshii...@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod_gadget.c |6 +++---
 drivers/usb/renesas_usbhs/mod_host.c   |6 +++---
 drivers/usb/renesas_usbhs/pipe.h   |6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index ed4949f..28a07de 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -77,9 +77,9 @@ struct usbhsg_recip_handle {
struct usbhsg_gpriv, mod)
 
 #define __usbhsg_for_each_uep(start, pos, g, i)\
-   for (i = start, pos = (g)-uep + i; \
-i  (g)-uep_size; \
-i++, pos = (g)-uep + i)
+   for ((i) = start;   \
+((i)  (g)-uep_size)  ((pos) = (g)-uep + (i)); \
+(i)++)
 
 #define usbhsg_for_each_uep(pos, gpriv, i) \
__usbhsg_for_each_uep(1, pos, gpriv, i)
diff --git a/drivers/usb/renesas_usbhs/mod_host.c 
b/drivers/usb/renesas_usbhs/mod_host.c
index b868154..e40f565 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -111,9 +111,9 @@ static const char usbhsh_hcd_name[] = renesas_usbhs host;
container_of(usbhs_mod_get(priv, USBHS_HOST), struct usbhsh_hpriv, mod)
 
 #define __usbhsh_for_each_udev(start, pos, h, i)   \
-   for (i = start, pos = (h)-udev + i;\
-i  USBHSH_DEVICE_MAX; \
-i++, pos = (h)-udev + i)
+   for ((i) = start;   \
+((i)  USBHSH_DEVICE_MAX)  ((pos) = (h)-udev + (i));\
+(i)++)
 
 #define usbhsh_for_each_udev(pos, hpriv, i)\
__usbhsh_for_each_udev(1, pos, hpriv, i)
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h
index b476fde..3e53498 100644
--- a/drivers/usb/renesas_usbhs/pipe.h
+++ b/drivers/usb/renesas_usbhs/pipe.h
@@ -54,9 +54,9 @@ struct usbhs_pipe_info {
  * pipe list
  */
 #define __usbhs_for_each_pipe(start, pos, info, i) \
-   for (i = start, pos = (info)-pipe + i; \
-i  (info)-size;  \
-i++, pos = (info)-pipe + i)
+   for ((i) = start;   \
+((i)  (info)-size)  ((pos) = (info)-pipe + (i));  \
+(i)++)
 
 #define usbhs_for_each_pipe(pos, priv, i)  \
__usbhs_for_each_pipe(1, pos, ((priv)-pipe_info), i)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: gadget: remove extra check on udc_stop

2013-07-08 Thread Kuninori Morimoto
usb_gadget_ops :: udc_stop might be called with driver = NULL since
511f3c5326eabe1ece35202a404c24c0aeacc246
(usb: gadget: udc-core: fix a regression during gadget driver unbinding)

Because of that, 2nd times insmod goes fail.
This patch fixes it up.

Reported-by: Yusuke Goda yusuke.goda...@renesas.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod_gadget.c |4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index ed4949f..805940c 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -855,10 +855,6 @@ static int usbhsg_gadget_stop(struct usb_gadget *gadget,
struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
 
-   if (!driver ||
-   !driver-unbind)
-   return -EINVAL;
-
usbhsg_try_stop(priv, USBHSG_STATUS_REGISTERD);
gpriv-driver = NULL;
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 2/3] ARM: shmobile: r8a7778: add USB support

2013-06-04 Thread Kuninori Morimoto

Hi

  Could you please teach me who/how/when free resource memory
  which was kmemdup'ed by platform_device_add_xxx()
  (and kmalloc'ed dma_mask) on platform_device_register_full() ??
 
 I don't think there's a need to free them. The EHCI/OHCI devices
 are always there after all.

Yes, you are correct.
Many devices are existing in Renesas chip, not only EHCI/OHCI.

But in r8a7778 case, these ehci/ohci doesn't work if usb-phy wasn't enabled,
and without PFC settings from platform.


  I just copied your approach from the R8A7779 code.
 
  Ahh, yes, indeed
 
  Moreover, from our prior testing, I'm afraid registering USB PHY 
 and EHCI/OHCI in one function wouldn't work. Unless maybe if it's done 
 from the init_late() machine's method...

I'm sorry.
This mention (= phy and ohci/ehci registration in one function) was my fault.
Your style is correct I think.

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 2/3] ARM: shmobile: r8a7778: add USB support

2013-06-03 Thread Kuninori Morimoto

Hi

  The ohci/ehci resource will be  used vainly if platform doesn't have USB
 
 The platform device resources are never used vainly. And remember 
 that if PHY doesn't get registered, OHCI/EHCI won't get probed 
 successfully either -- mind the usb_power_on() platform method.

?
Could you please teach me who/how/when free resource memory
which was kmemdup'ed by platform_device_add_xxx()
(and kmalloc'ed dma_mask) on platform_device_register_full() ??

 ohci/ehci and phy should be registered in same time/function.

I just copied your approach from the R8A7779 code.

Ahh, yes, indeed


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 2/3] ARM: shmobile: r8a7778: add USB support

2013-06-02 Thread Kuninori Morimoto

Hi


 Add USB clock and EHCI, OHCI, and USB PHY platform devices for R8A7778 SoC;  
 add
 a function to register PHY device with board-specific platform data and 
 register
 EHCI and OHCI platfrom devices from the init_late() board method.
 
 Also,  don't forget to enable CONFIG_ARCH_HAS_[EO]HCI options for R8A7778 SoC 
 in
 Kconfig...
 
 The patch has been tested on the BOCK-W board.
 
 Signed-off-by: Sergei Shtylyov sergei.shtyl...@cogentembedded.com
 ---
(snip)
 +void __init r8a7778_add_usb_phy_device(struct rcar_phy_platform_data *pdata)
 +{
 + platform_device_register_resndata(platform_bus, rcar_usb_phy, -1,
 +   usb_phy_resources,
 +   ARRAY_SIZE(usb_phy_resources),
 +   pdata, sizeof(*pdata));
 +}
(snip)
 +void __init r8a7778_init_late(void)
 +{
 + phy = usb_get_phy(USB_PHY_TYPE_USB2);
 +
 + platform_device_register_full(ehci_info);
 + platform_device_register_full(ohci_info);
 +}

This means ehci/ohci device registration happened compulsorily if Soc/platform 
calls r8a7778_init_late().
but, usb phy isn't registered without r8a7778_add_usb_phy_device().

The ohci/ehci resource will be  used vainly if platform doesn't have USB

ohci/ehci and phy should be registered in same time/function.

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/9] Reorganize R8A7779/Marzen USB code

2013-04-18 Thread Kuninori Morimoto

Hi Sergei

I'm going to post R8A7778/BOCK-W series following this one, and 
   all the
   patches in 1st series should additionally be tested on BOCK-W. Well, I
   probably can hold up posting version 3 until I have the second 
   series verified.
BTW, about R8A7778/BOCK-W, R-Car M1A user manual talks about a 
   ferrite
   bead in 49.4.1 (3) Setting USB-PHY. Do you know for sure if it's 
   used or not
   on BOCK-W board? PHY initialization seems to work with either 
   settings...
   I can ask it to HW team if you want me.
  
  Yes, ask them please.
 
 Now, I'm asking it to HW team
 Please wait

According to HW team,
this setting is for some kind of USB compliance test (?).
So, in general, we can use No ferrite bead.

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/9] Reorganize R8A7779/Marzen USB code

2013-04-16 Thread Kuninori Morimoto

Hi Sergei

   I'm going to post R8A7778/BOCK-W series following this one, and 
  all the
  patches in 1st series should additionally be tested on BOCK-W. Well, I
  probably can hold up posting version 3 until I have the second 
  series verified.
   BTW, about R8A7778/BOCK-W, R-Car M1A user manual talks about a 
  ferrite
  bead in 49.4.1 (3) Setting USB-PHY. Do you know for sure if it's 
  used or not
  on BOCK-W board? PHY initialization seems to work with either 
  settings...
  I can ask it to HW team if you want me.
 
 Yes, ask them please.

Now, I'm asking it to HW team
Please wait

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/9] Reorganize R8A7779/Marzen USB code

2013-04-09 Thread Kuninori Morimoto

Hi Sergei

  Please add this tested on xxx comment on each patch's log area, not only 
  on [0/x].
  We need it on git log
 
 I'm going to post R8A7778/BOCK-W series following this one, and all the 
 patches in 1st series should additionally be tested on BOCK-W. Well, I 
 probably can hold up posting version 3 until I have the second series 
 verified.
 BTW, about R8A7778/BOCK-W, R-Car M1A user manual talks about a ferrite 
 bead in 49.4.1 (3) Setting USB-PHY. Do you know for sure if it's used or not
 on BOCK-W board? PHY initialization seems to work with either settings...

I can ask it to HW team if you want me.
But our local BSP is using No ferrite bead settings...


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/9] Reorganize R8A7779/Marzen USB code

2013-04-08 Thread Kuninori Morimoto

Hi

Here's the set of 9 patches against the Simon Horman's 'renesas.git' repo,
 'renesas-next-20130405v2' tag.  It was created to fix the shortcomings in the
 R8A7779/Marzen USB platform code and R8A7779 USB common PHY driver, and so
 spans both arch/arm/mach-shmobile/ and drivers/usb/ subtrees (some patches 
 have
 to touch both subtrees). The patches were conceived with the complete
 bisectability goal in mind. The patches have been tested on the Marzen board.

Please add this tested on xxx comment on each patch's log area, not only on 
[0/x].
We need it on git log

 [1/9] ARM: shmobile: Marzen: move USB EHCI, OHCI, and PHY devices to R8A7779 
 code
 [2/9] ehci-platform: add pre_setup() method to platform data
 [3/9] ARM: shmobile: R8A7779: setup EHCI internal buffer
 [4/9] rcar-phy: remove EHCI internal buffer setup
 [5/9] ARM: shmobile: R8A7779: remove USB PHY 2nd memory resource
 [6/9] rcar-phy: correct base address
 [7/9] rcar-phy: add platform data
 [8/9] ARM: shmobile: Marzen: pass platform data to USB PHY device
 [9/9] rcar-phy: handle platform data

I didn't get [7/9][9/9] patch somehow

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/8] Reorganize R8A7779/Marzen USB code

2013-04-04 Thread Kuninori Morimoto

Hi

Here's the set of 4 patches against the Simon Horman's 'renesas.git' repo,
 'renesas-next-20130404v2' tag and the 2 Ether patches I've reposted yesterday.
 It was created to fix the shortcomings in the R8A7779/Marzen USB platform code
 and R8A7779 USB common PHY driver, and so spans both arch/arm/mach-shmobile/
 and drivers/usb/ subtrees (some patches have to touch both subtrees).
 The patches were conceived with the complete bisectability goal in mind.
 
 [1/8] ARM: shmobile:Marzen: move USB EHCI, OHCI, and PHY devices to R8A7779 
 code
 [2/8] ehci-platform: add init() method to platform data
 [3/8] ARM: shmobile: R8A7779: setup EHCI internal buffer
 [4/8] rcar-phy: remove EHCI internal buffer setup
 [5/8] rcar-phy: correct base address
 [6/8] rcar-phy: add platform data
 [7/8] ARM: shmobile: Marzen: pass platform data to USB PHY device
 [8/8] rcar-phy: handle platform data
 
I'm not sure thru which tree this patchset should be merged, however it 
 turns
 out that it's too late now to push it thru Felipe Balbi's USB tree for 3.10, 
 so
 maybe the patchset can be merged thru Simon's tree with Felipe's and Alan
 Stern's ACKs.

I guess you already got request about patch style from Simon.
When you send v2 patch, could you please add this patch is tested on  bard
on each patch's comment area ?

Then,
for all patches

Acked-by: Kuninori Morimoto kuninori.morimoto...@renesas.com

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Renesas sparse errors

2013-03-31 Thread Kuninori Morimoto

Hi Felipe

  On Wed, Mar 27, 2013 at 06:21:19PM -0700, Kuninori Morimoto wrote:
linux/drivers/usb/renesas_usbhs/common.c:313:17: error: incompatible 
types in conditional expression (different base types)
linux/drivers/usb/renesas_usbhs/common.c:322:17: error: incompatible 
types in conditional expression (different base types)
linux/drivers/usb/renesas_usbhs/common.c:384:17: error: incompatible 
types in conditional expression (different base types)
linux/drivers/usb/renesas_usbhs/common.c:524:9: error: incompatible 
types in conditional expression (different base types)
linux/drivers/usb/renesas_usbhs/common.c:545:9: error: incompatible 
types in conditional expression (different base types)
linux/drivers/usb/renesas_usbhs/common.c:574:9: error: incompatible 
types in conditional expression (different base types)
linux/drivers/usb/renesas_usbhs/common.c:606:9: error: incompatible 
types in conditional expression (different base types)
(snip)
   CHECK   /home/balbi/workspace/linux/drivers/usb/renesas_usbhs/common.c
   CHECK   /home/balbi/workspace/linux/drivers/usb/renesas_usbhs/mod.c
   CHECK   /home/balbi/workspace/linux/drivers/usb/renesas_usbhs/pipe.c
   CHECK   /home/balbi/workspace/linux/drivers/usb/renesas_usbhs/fifo.c
   CHECK   /home/balbi/workspace/linux/drivers/usb/renesas_usbhs/mod_host.c
   CHECK   /home/balbi/workspace/linux/drivers/usb/renesas_usbhs/mod_gadget.c
   CC  drivers/usb/renesas_usbhs/mod.o
   CC  drivers/usb/renesas_usbhs/pipe.o
   CC  drivers/usb/renesas_usbhs/fifo.o
 drivers/usb/renesas_usbhs/mod_gadget.c:233:28: warning: symbol 
 'req_clear_feature' was not declared. Should it be static?
 drivers/usb/renesas_usbhs/mod_gadget.c:274:28: warning: symbol 
 'req_set_feature' was not declared. Should it be static?
 drivers/usb/renesas_usbhs/mod_gadget.c:375:28: warning: symbol 
 'req_get_status' was not declared. Should it be static?
 drivers/usb/renesas_usbhs/common.c:313:17: error: incompatible types in 
 conditional expression (different base types)
   CC  drivers/usb/renesas_usbhs/mod_gadget.o
 drivers/usb/renesas_usbhs/common.c:322:17: error: incompatible types in 
 conditional expression (different base types)
 drivers/usb/renesas_usbhs/common.c:384:17: error: incompatible types in 
 conditional expression (different base types)
 drivers/usb/renesas_usbhs/common.c:524:9: error: incompatible types in 
 conditional expression (different base types)
 drivers/usb/renesas_usbhs/common.c:545:9: error: incompatible types in 
 conditional expression (different base types)
 drivers/usb/renesas_usbhs/common.c:574:9: error: incompatible types in 
 conditional expression (different base types)
 drivers/usb/renesas_usbhs/common.c:606:9: error: incompatible types in 
 conditional expression (different base types)
   CC  drivers/usb/renesas_usbhs/common.o
   CC  drivers/usb/renesas_usbhs/mod_host.o
   LD  drivers/usb/renesas_usbhs/renesas_usbhs.o
   LD  drivers/usb/renesas_usbhs/built-in.o

Thank you. I could understand.
I send fixup patch in next email.
It solve above error.
But renesas_usbhs common.c still has warning...

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: fixup sparse errors for common.c

2013-03-31 Thread Kuninori Morimoto
This patch fixup below sparse errors

${RENESAS_USB} = ${LINUX}/drivers/usb/renesas_usbhs

CHECK   ${RENESAS_USB}/common.c
${RENESAS_USB}/common.c:313:17: error: incompatible types in conditional 
expression (different base types)
${RENESAS_USB}/common.c:322:17: error: incompatible types in conditional 
expression (different base types)
${RENESAS_USB}/common.c:384:17: error: incompatible types in conditional 
expression (different base types)
${RENESAS_USB}/common.c:524:9: error: incompatible types in conditional 
expression (different base types)
${RENESAS_USB}/common.c:545:9: error: incompatible types in conditional 
expression (different base types)
${RENESAS_USB}/common.c:574:9: error: incompatible types in conditional 
expression (different base types)
${RENESAS_USB}/common.c:606:9: error: incompatible types in conditional 
expression (different base types)

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 Felipe

Does this solve error issue ?
# I guess common.c still has warning though...

 arch/arm/mach-shmobile/board-armadillo800eva.c |8 ++--
 arch/arm/mach-shmobile/board-kzm9g.c   |8 ++--
 arch/arm/mach-shmobile/board-mackerel.c|   12 +---
 arch/sh/boards/mach-ecovec24/setup.c   |4 +++-
 include/linux/usb/renesas_usbhs.h  |6 +++---
 5 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c 
b/arch/arm/mach-shmobile/board-armadillo800eva.c
index 81db74a..2dfb1f8 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -172,7 +172,7 @@ static int usbhsf_get_id(struct platform_device *pdev)
return USBHS_GADGET;
 }
 
-static void usbhsf_power_ctrl(struct platform_device *pdev,
+static int usbhsf_power_ctrl(struct platform_device *pdev,
  void __iomem *base, int enable)
 {
struct usbhsf_private *priv = usbhsf_get_priv(pdev);
@@ -226,6 +226,8 @@ static void usbhsf_power_ctrl(struct platform_device *pdev,
clk_disable(priv-pci); /* usb work around */
clk_disable(priv-usb24);   /* usb work around */
}
+
+   return 0;
 }
 
 static int usbhsf_get_vbus(struct platform_device *pdev)
@@ -242,7 +244,7 @@ static irqreturn_t usbhsf_interrupt(int irq, void *data)
return IRQ_HANDLED;
 }
 
-static void usbhsf_hardware_exit(struct platform_device *pdev)
+static int usbhsf_hardware_exit(struct platform_device *pdev)
 {
struct usbhsf_private *priv = usbhsf_get_priv(pdev);
 
@@ -267,6 +269,8 @@ static void usbhsf_hardware_exit(struct platform_device 
*pdev)
priv-usbh_base = NULL;
 
free_irq(IRQ7, pdev);
+
+   return 0;
 }
 
 static int usbhsf_hardware_init(struct platform_device *pdev)
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c 
b/arch/arm/mach-shmobile/board-kzm9g.c
index e2d3324..e6b775a 100644
--- a/arch/arm/mach-shmobile/board-kzm9g.c
+++ b/arch/arm/mach-shmobile/board-kzm9g.c
@@ -157,12 +157,14 @@ static int usbhs_get_vbus(struct platform_device *pdev)
return !((1  7)  __raw_readw(priv-cr2));
 }
 
-static void usbhs_phy_reset(struct platform_device *pdev)
+static int usbhs_phy_reset(struct platform_device *pdev)
 {
struct usbhs_private *priv = usbhs_get_priv(pdev);
 
/* init phy */
__raw_writew(0x8a0a, priv-cr2);
+
+   return 0;
 }
 
 static int usbhs_get_id(struct platform_device *pdev)
@@ -204,7 +206,7 @@ static int usbhs_hardware_init(struct platform_device *pdev)
return 0;
 }
 
-static void usbhs_hardware_exit(struct platform_device *pdev)
+static int usbhs_hardware_exit(struct platform_device *pdev)
 {
struct usbhs_private *priv = usbhs_get_priv(pdev);
 
@@ -212,6 +214,8 @@ static void usbhs_hardware_exit(struct platform_device 
*pdev)
__raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv-phy);
 
free_irq(IRQ15, pdev);
+
+   return 0;
 }
 
 static u32 usbhs_pipe_cfg[] = {
diff --git a/arch/arm/mach-shmobile/board-mackerel.c 
b/arch/arm/mach-shmobile/board-mackerel.c
index 1a9c753..2b60f2b 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -597,12 +597,14 @@ static int usbhs_get_vbus(struct platform_device *pdev)
return usbhs_is_connected(usbhs_get_priv(pdev));
 }
 
-static void usbhs_phy_reset(struct platform_device *pdev)
+static int usbhs_phy_reset(struct platform_device *pdev)
 {
struct usbhs_private *priv = usbhs_get_priv(pdev);
 
/* init phy */
__raw_writew(0x8a0a, priv-usbcrcaddr);
+
+   return 0;
 }
 
 static int usbhs0_get_id(struct platform_device *pdev)
@@ -629,11 +631,13 @@ static int usbhs0_hardware_init(struct platform_device 
*pdev)
return 0;
 }
 
-static void usbhs0_hardware_exit(struct platform_device *pdev)
+static int usbhs0_hardware_exit(struct platform_device *pdev)
 {
struct

Re: Renesas sparse errors

2013-03-27 Thread Kuninori Morimoto

Hi Felipe

 linux/drivers/usb/renesas_usbhs/common.c:313:17: error: incompatible types in 
 conditional expression (different base types)
 linux/drivers/usb/renesas_usbhs/common.c:322:17: error: incompatible types in 
 conditional expression (different base types)
 linux/drivers/usb/renesas_usbhs/common.c:384:17: error: incompatible types in 
 conditional expression (different base types)
 linux/drivers/usb/renesas_usbhs/common.c:524:9: error: incompatible types in 
 conditional expression (different base types)
 linux/drivers/usb/renesas_usbhs/common.c:545:9: error: incompatible types in 
 conditional expression (different base types)
 linux/drivers/usb/renesas_usbhs/common.c:574:9: error: incompatible types in 
 conditional expression (different base types)
 linux/drivers/usb/renesas_usbhs/common.c:606:9: error: incompatible types in 
 conditional expression (different base types)
 
 Could you look into fixing them for v3.10 or v3.11 ? That would be
 great as it would make my build-testing scripts a lot happier :-p

Hmmm... strange...

I can't get this error.
I tried x86(32bit/64bit)/sh/arm compiler on your next and master branch.

1b0563f888d14f877ef0b5602ba240f3e857df06
(Merge branch 'next')

6b0cfc656f8a649fbfbe11e76e0aa301ee26879e
(usb: musb: ux500_dma: fix sparse warning)

my all result are..

  ...
  CC  drivers/usb/renesas_usbhs/common.o
  CC  drivers/usb/renesas_usbhs/mod.o
  CC  drivers/usb/renesas_usbhs/pipe.o
  CC  drivers/usb/renesas_usbhs/fifo.o
  CC  drivers/usb/renesas_usbhs/mod_host.o
  LD  drivers/usb/renesas_usbhs/renesas_usbhs.o
  LD  drivers/usb/renesas_usbhs/built-in.o
  ...

Could you please teach me
 - which branch or commit are you using ?
 - which compiler are you using ?

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] usb: phy: add R-Car USB phy driver

2013-03-14 Thread Kuninori Morimoto

Hi Sergei

  0x  ===
   EHCI
--
  0x0094 PHY
  0x009C PHY
--
   EHCI
  0x0400  ==
  ...
  0x0800  --
   PHY
  0x0900  --
 
  This driver couldn't probe if it used request_mem_region()
 
  Fair enough. I must say, though. That's a peculiar register mapping ;-)
 
   Not peculiar enough to not be able to overcome it. Those registers
  at 0x009[4C]
  are not really PHY related, they control EHCI internal buffering. They
  probably shouldn't
  have been a part of this driver even...
 
  I'm not sure what is the best solution.
 
 I suspect that these registers should be intialized as a part of 
 ehci-platform driver's power_on() platform callback.

I had same opinion before, and of course I agree your opinion.
But, not in power_on() callback.
I guess you need to create new callback (for init), 
since power_on() and ioremap() timing

if (pdata-power_on) {
err = pdata-power_on(dev);
if (err  0)
return err;
}
...
hcd-regs = devm_ioremap_resource(dev-dev, res_mem);
if (IS_ERR(hcd-regs)) {
err = PTR_ERR(hcd-regs);
goto err_put_hcd;
}

# init() here ?
if (pdata-init)
err = pdata-init(dev, hcd-regs);


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6] usb: phy: add R-Car USB phy driver

2013-03-13 Thread Kuninori Morimoto

Hi Sergei

Thank you for pointing it

  +   /* set platform specific port settings */
  +   iowrite32(0x, (reg0 + USBPCTRL0));
 
 This register contains completely board specific setting, 
 hard-coding it to 0 is wrong.
 Shouldn't you have passed its value as platform data instead?
(snip)
  +   iowrite32(0x00ff0040, (reg0 + EIIBC1));
  +   iowrite32(0x00ff0040, (reg1 + EIIBC1));
  +
  +   iowrite32(0x0001, (reg0 + EIIBC2));
  +   iowrite32(0x0001, (reg1 + EIIBC2));
 
 Why write each of these register twice, at different bases? The USB 
 section of
 the R-Car H1 manual doesn't seem to mention that they are dual mapped...
(snip)
  +   if (priv-counter-- == 1) { /* last user */
  +   iowrite32(0x, (reg0 + USBPCTRL0));
 
 Why change this register at all at shutdown?

Sorry, I didn't mention about these settings value on this patch.
This driver is using the fixed value for particular applications at this point,
because of prototype driver at that point.
This means it should use platform/chip specific callback function



Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3] usb: phy: add R-Car USB phy driver

2013-03-13 Thread Kuninori Morimoto

Hi Sergei

Thank you for pointing it

  0x  ===
  EHCI
   --
  0x0094 PHY
  0x009C PHY
   --
  EHCI
  0x0400  ==
  ...
  0x0800  --
  PHY
  0x0900  --
 
  This driver couldn't probe if it used request_mem_region()
  Fair enough. I must say, though. That's a peculiar register mapping ;-)
 
 
 Not peculiar enough to not be able to overcome it. Those registers 
 at 0x009[4C]
 are not really PHY related, they control EHCI internal buffering. They 
 probably shouldn't
 have been a part of this driver even...

I'm not sure what is the best solution.
But current rcar_usb_phy is expecting above (strange) mapping,
and initialize method is came from datasheet

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: Add EHCI and OHCI for Renesas R-Mobile SoC (r8a7740)

2013-02-13 Thread Kuninori Morimoto

Hi Iwamatsu-san

 The Renesas R-Mobile SoC (r8a7740) has USB EHCI and OHCI controllers.
 
 The ehci and ohci blocks share a common register and clocking infrastructure.
 Initialization of the host controller and clocks is common between these and
 is factored out into the rmobile-common.c file.

(snip)

 +void rmobile_hc_start(struct usb_hcd *hcd, struct platform_device *pdev)
...
 + data = SMODE_READY_CTR | MMODE_HBUSREQ |
 + MMODE_WR_INCR | MMODE_BYTE_BURST | MMODE_HTRANS;
 +
 + if (data == __raw_readl(hci-base + AHB_BUS_CTR))
 + return;
 +
 + /* AHB-PCI Bridge Communication Registers */
 + AHB_WRITE(hci, data, AHB_BUS_CTR);
 + AHB_WRITE(hci, (PHYS_OFFSET  0xf000) | PREFETCH,
 + PCIAHB_WIN1_CTR);
 + AHB_WRITE(hci, 0xf000 | PREFETCH, PCIAHB_WIN2_CTR);
 + AHB_WRITE(hci, hci-phys_base | PCIWIN2_PCICMD, AHBPCI_WIN2_CTR);
 + data = __raw_readl(hci-base + PCI_ARBITER_CTR);
 + AHB_WRITE(hci, data | PCIBP_MODE | PCIREQ1 | PCIREQ0,
 + PCI_ARBITER_CTR);
 +
 + /* PCI Configuration Registers for AHBPCI */
 + AHB_WRITE(hci, PCIWIN1_PCICMD | AHB_CFG_AHBPCI, AHBPCI_WIN1_CTR);
 + AHB_WRITE(hci, hci-phys_base + AHBPCI_OFFSET,
 + PCI_CONF_AHBPCI_BASEAD);
 + AHB_WRITE(hci, PHYS_OFFSET  0xf000, PCI_CONF_AHBPCI_WIN1_BASEAD);
 + AHB_WRITE(hci, 0xf000, PCI_CONF_AHBPCI_WIN2_BASEAD);
 + AHB_WRITE(hci, SERREN | PERREN | MASTEREN | MEMEN,
 + PCI_CONF_AHBPCI_CMND_STS);
 +
 + /* PCI Configuration Registers for EHCI */
 + AHB_WRITE(hci, PCIWIN1_PCICMD | AHB_CFG_HOST, AHBPCI_WIN1_CTR);
 + AHB_WRITE(hci, hci-phys_base + OHCI_OFFSET, OHCI_BASEAD);
 + AHB_WRITE(hci, hci-phys_base + EHCI_OFFSET, EHCI_BASEAD);
 +
 + data = SERREN | PERREN | MASTEREN | MEMEN;
 + AHB_WRITE(hci, data, OHCI_CMND_STS);
 + AHB_WRITE(hci, data, EHCI_CMND_STS);
 +
 + /* enable pci interrupt */
 + data = __raw_readl(hci-base + PCI_INT_ENABLE);
 + data |= USBH_PMEEN | USBH_INTBEN | USBH_INTAEN;
 + AHB_WRITE(hci, data, PCI_INT_ENABLE);

Are these setting Renesas mobile Common ???
I don't think so.
It is R8A7740 specific settings


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: Add EHCI and OHCI for Renesas R-Mobile SoC (r8a7740)

2013-02-13 Thread Kuninori Morimoto

Hi

  +void rmobile_hc_start(struct usb_hcd *hcd, struct platform_device *pdev)
  ...
  + data = SMODE_READY_CTR | MMODE_HBUSREQ |
  + MMODE_WR_INCR | MMODE_BYTE_BURST | MMODE_HTRANS;
  +
  + if (data == __raw_readl(hci-base + AHB_BUS_CTR))
  + return;
  +
  + /* AHB-PCI Bridge Communication Registers */
  + AHB_WRITE(hci, data, AHB_BUS_CTR);
  + AHB_WRITE(hci, (PHYS_OFFSET  0xf000) | PREFETCH,
  + PCIAHB_WIN1_CTR);
  + AHB_WRITE(hci, 0xf000 | PREFETCH, PCIAHB_WIN2_CTR);
  + AHB_WRITE(hci, hci-phys_base | PCIWIN2_PCICMD, AHBPCI_WIN2_CTR);
  + data = __raw_readl(hci-base + PCI_ARBITER_CTR);
  + AHB_WRITE(hci, data | PCIBP_MODE | PCIREQ1 | PCIREQ0,
  + PCI_ARBITER_CTR);
  +
  + /* PCI Configuration Registers for AHBPCI */
  + AHB_WRITE(hci, PCIWIN1_PCICMD | AHB_CFG_AHBPCI, AHBPCI_WIN1_CTR);
  + AHB_WRITE(hci, hci-phys_base + AHBPCI_OFFSET,
  + PCI_CONF_AHBPCI_BASEAD);
  + AHB_WRITE(hci, PHYS_OFFSET  0xf000, 
  PCI_CONF_AHBPCI_WIN1_BASEAD);
  + AHB_WRITE(hci, 0xf000, PCI_CONF_AHBPCI_WIN2_BASEAD);
  + AHB_WRITE(hci, SERREN | PERREN | MASTEREN | MEMEN,
  + PCI_CONF_AHBPCI_CMND_STS);
  +
  + /* PCI Configuration Registers for EHCI */
  + AHB_WRITE(hci, PCIWIN1_PCICMD | AHB_CFG_HOST, AHBPCI_WIN1_CTR);
  + AHB_WRITE(hci, hci-phys_base + OHCI_OFFSET, OHCI_BASEAD);
  + AHB_WRITE(hci, hci-phys_base + EHCI_OFFSET, EHCI_BASEAD);
  +
  + data = SERREN | PERREN | MASTEREN | MEMEN;
  + AHB_WRITE(hci, data, OHCI_CMND_STS);
  + AHB_WRITE(hci, data, EHCI_CMND_STS);
  +
  + /* enable pci interrupt */
  + data = __raw_readl(hci-base + PCI_INT_ENABLE);
  + data |= USBH_PMEEN | USBH_INTBEN | USBH_INTAEN;
  + AHB_WRITE(hci, data, PCI_INT_ENABLE);
 
  Are these setting Renesas mobile Common ???
  I don't think so.
  It is R8A7740 specific settings
 
 This is a problem only for the names, I think.
 It is only only rmobile as r8a7740 now to use this driver.
 Should we switch to ehci-r8a7740 and other?

Now, latest Renesas chip which has ehci/ohci is using
ehci/ohci-platform.c driver.
Your driver will be used only from r8a7740 chip.
(Since, Renesas don't create Mobile chip in the future)

I don't know detail,
but can you re-use ehci/ohci-sh.c somehow instead of creating new 
ehci/ohci-rmobile.c ?
I don't like this kind of series-name driver which is 
useless/pointless/flexibilityless

ohci-rmobile.c - ohci-sh.c
ohci-common.c  - ohci-r8a7740.c

 drivers/usb/host/Kconfig  |4 +
 drivers/usb/host/Makefile |1 +
 drivers/usb/host/ehci-hcd.c   |5 +
 drivers/usb/host/ehci-rmobile.c   |  384 +
 drivers/usb/host/ohci-hcd.c   |   21 +-
 drivers/usb/host/ohci-rmobile.c   |  377 
 drivers/usb/host/rmobile-common.c |  145 ++
 drivers/usb/host/rmobile-common.h |   53 +
 include/linux/usb/rmobile.h   |  254 


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 03/11] usb: dwc3: gadget: introduce and use enable/disable irq methods

2013-02-12 Thread Kuninori Morimoto
);
 - goto err6;
 + goto err5;
   }
  
   return 0;
  
 -err6:
 - dwc3_writel(dwc-regs, DWC3_DEVTEN, 0x00);
 - free_irq(irq, dwc);
 -
  err5:
   dwc3_gadget_free_endpoints(dwc);
  
 @@ -2514,13 +2530,7 @@ err0:
  
  void dwc3_gadget_exit(struct dwc3 *dwc)
  {
 - int irq;
 -
   usb_del_gadget_udc(dwc-gadget);
 - irq = platform_get_irq(to_platform_device(dwc-dev), 0);
 -
 - dwc3_writel(dwc-regs, DWC3_DEVTEN, 0x00);
 - free_irq(irq, dwc);
  
   dwc3_gadget_free_endpoints(dwc);
  
 -- 
 1.8.1.rc1.5.g7e0651a
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-usb in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 03/11] usb: dwc3: gadget: introduce and use enable/disable irq methods

2013-02-12 Thread Kuninori Morimoto

Hi Felipe

  How about using devm_request_irq() instead of request_irq() ?
  Then, free_irq() is not needed
 
 if I do, we will try to request and IRQ which is already request.
 
 -udc_stop() doesn't destroy the underlying struct device * so the IRQ
 won't be freed.

OK, I see
Sorry for my noise

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: renesas_usbhs: mod_host: fixup usbhsh_ureq_free() timing

2012-12-10 Thread Kuninori Morimoto

Hi Felipe

  usbhsh_ureq_free() free ureq which includes ubshs_pkt.
  But current driver used usbhs_pkt after freed ureq.
  This patch fixup this bug.
  Special thanks to Chen
  
  Reported-by: Chen Gang gang.c...@asianux.com
  Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 
 does this need to go to stable too ?

It was bug, but no-one got trouble at this point.
So, I guess v3.8 is very enough

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] usb: renesas_usbhs: fixup gadget suspned/resume issue

2012-12-10 Thread Kuninori Morimoto

Hi felipe, Greg
Cc Simon

These are renesas_usbhs gadget suspned/resume fixup patches.
Without these patches, renesas_usbhs gadget resume will break.

Kuninori Morimoto (2):
  usb: renesas_usbhs: gadget: remove usbhsg_uep_init()
  usb: renesas_usbhs: gadget: usbhsg_ep_disable() care pipe settings

 drivers/usb/renesas_usbhs/mod_gadget.c |   22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Suggestion] drivers/usb/renesas_usbhs: pkt is still in use, after it was already free.

2012-12-09 Thread Kuninori Morimoto

Hi Chen

 Hello Greg Kroah-Hartman:
 
 in drivers/usb/renesas_usbhs/mod_host.c, in function usbhsh_queue_done:
 
 get ureq from pkt, by using the macro usbhsh_pkt_to_ureq (at line 637)
 pkt is the sub-object of ureq (line 73..76, line 157..158)
 
 free ureq, by calling function usbhsh_ureq_free (at line 655)
 use kfree to free ureq in function usbhsh_ureq_free (line 184..191)
 originally ureq is call kzalloc in function usbhsh_ureq_alloc (line 
 171..179)
 so pkt also free, too.
 
 still use pkt, by calling function usbhsh_endpoint_sequence_save (at line 
 657)
 use pkt-zero in funcion usbhsh_endpoint_sequence_save (at line 243)
 
 
   I find it through code review, please help to check this suggestion whether 
 valid.
 
   if it was valid:
 I prefer the relative member to provide relative patch.
 if can not find relative member, I should try (although it seems not a 
 good idea)

Thank you for your review, and nice catch !
I think this is bug, and I didn't notice it.

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: mod_host: fixup usbhsh_ureq_free() timing

2012-12-09 Thread Kuninori Morimoto
usbhsh_ureq_free() free ureq which includes ubshs_pkt.
But current driver used usbhs_pkt after freed ureq.
This patch fixup this bug.
Special thanks to Chen

Reported-by: Chen Gang gang.c...@asianux.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod_host.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/mod_host.c 
b/drivers/usb/renesas_usbhs/mod_host.c
index 3d3cd6c..b868154 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -661,9 +661,10 @@ static void usbhsh_queue_done(struct usbhs_priv *priv, 
struct usbhs_pkt *pkt)
status = -ESHUTDOWN;
 
urb-actual_length = pkt-actual;
-   usbhsh_ureq_free(hpriv, ureq);
 
usbhsh_endpoint_sequence_save(hpriv, urb, pkt);
+   usbhsh_ureq_free(hpriv, ureq);
+
usbhsh_pipe_detach(hpriv, usbhsh_ep_to_uep(urb-ep));
 
usb_hcd_unlink_urb_from_ep(hcd, urb);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] usb: renesas_usbhs: fixup patches for host

2012-11-06 Thread Kuninori Morimoto

Hi Felipe, GregKH

These pathces fixup renesas_usbhs host side strange behavior for v3.8 kernel.
based on felipe/master branch

Kuninori Morimoto (3):
  usb: renesas_usbhs: remove debug information from usbhsh_hub_status_data()
  usb: renesas_usbhs: use transfer counter if IN direction bulk pipe
  usb: renesas_usbhs: host: add endpoint user counter

 drivers/usb/renesas_usbhs/fifo.c |4 ++
 drivers/usb/renesas_usbhs/mod_host.c |   28 +-
 drivers/usb/renesas_usbhs/pipe.c |  101 ++
 drivers/usb/renesas_usbhs/pipe.h |1 +
 4 files changed, 119 insertions(+), 15 deletions(-)

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] usb: renesas_usbhs: remove debug information from usbhsh_hub_status_data()

2012-11-06 Thread Kuninori Morimoto
Because usbhsh_hub_status_data() will be called many times,
there are too many obstructive/useless debug informations if driver has #define 
DEBUG.
Thus, other important dev_dbg() information will hide.
This patch removed obstructive/useless dev_dbg().

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod_host.c |4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_host.c 
b/drivers/usb/renesas_usbhs/mod_host.c
index ff38a30..9bc8c2b 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -1085,8 +1085,6 @@ static void usbhsh_endpoint_disable(struct usb_hcd *hcd,
 static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd);
-   struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv);
-   struct device *dev = usbhs_priv_to_dev(priv);
int roothub_id = 1; /* only 1 root hub */
 
/*
@@ -1098,8 +1096,6 @@ static int usbhsh_hub_status_data(struct usb_hcd *hcd, 
char *buf)
else
*buf = 0;
 
-   dev_dbg(dev, %s (%02x)\n, __func__, *buf);
-
return !!(*buf);
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] usb: renesas_usbhs: use transfer counter if IN direction bulk pipe

2012-11-06 Thread Kuninori Morimoto
received data will break if it was bulk pipe and large data size,
because pipe kept BUF PID even though it doesn't have enough buffer.
To avoid this issue, renesas_usbhs can use transfer counter.
Pipe PID will be NAK if it didn't have enough buffer by this patch.

renesas_usbhs has strange address mapping.
Thus, it is difficult to calculate transfer counter setting address.
This patch use fixed table for it.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/fifo.c |4 ++
 drivers/usb/renesas_usbhs/pipe.c |  101 ++
 drivers/usb/renesas_usbhs/pipe.h |1 +
 3 files changed, 106 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 4f60e03..6aab515 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -488,6 +488,8 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int 
*is_done)
usbhs_pipe_data_sequence(pipe, pkt-sequence);
pkt-sequence = -1; /* -1 sequence will be ignored */
 
+   usbhs_pipe_set_trans_count_if_bulk(pipe, pkt-length);
+
ret = usbhsf_fifo_select(pipe, fifo, 1);
if (ret  0)
return 0;
@@ -594,6 +596,7 @@ static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int 
*is_done)
usbhs_pipe_data_sequence(pipe, pkt-sequence);
pkt-sequence = -1; /* -1 sequence will be ignored */
 
+   usbhs_pipe_set_trans_count_if_bulk(pipe, pkt-length);
usbhs_pipe_enable(pipe);
usbhsf_rx_irq_ctrl(pipe, 1);
 
@@ -795,6 +798,7 @@ static void xfer_work(struct work_struct *work)
dev_dbg(dev,   %s %d (%d/ %d)\n,
fifo-name, usbhs_pipe_number(pipe), pkt-length, pkt-zero);
 
+   usbhs_pipe_set_trans_count_if_bulk(pipe, pkt-trans);
usbhs_pipe_enable(pipe);
usbhsf_dma_start(pipe, fifo);
dma_async_issue_pending(chan);
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c
index 122526c..7926e1c 100644
--- a/drivers/usb/renesas_usbhs/pipe.c
+++ b/drivers/usb/renesas_usbhs/pipe.c
@@ -93,6 +93,82 @@ static void usbhsp_pipe_cfg_set(struct usbhs_pipe *pipe, u16 
mask, u16 val)
 }
 
 /*
+ * PIPEnTRN/PIPEnTRE functions
+ */
+static void usbhsp_pipe_trn_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
+{
+   struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
+   struct device *dev = usbhs_priv_to_dev(priv);
+   int num = usbhs_pipe_number(pipe);
+   u16 reg;
+
+   /*
+* It is impossible to calculate address,
+* since PIPEnTRN addresses were mapped randomly.
+*/
+#define CASE_PIPExTRN(a)   \
+   case 0x ## a:   \
+   reg = PIPE ## a ## TRN; \
+   break;
+
+   switch (num) {
+   CASE_PIPExTRN(1);
+   CASE_PIPExTRN(2);
+   CASE_PIPExTRN(3);
+   CASE_PIPExTRN(4);
+   CASE_PIPExTRN(5);
+   CASE_PIPExTRN(B);
+   CASE_PIPExTRN(C);
+   CASE_PIPExTRN(D);
+   CASE_PIPExTRN(E);
+   CASE_PIPExTRN(F);
+   CASE_PIPExTRN(9);
+   CASE_PIPExTRN(A);
+   default:
+   dev_err(dev, unknown pipe (%d)\n, num);
+   return;
+   }
+   __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val);
+}
+
+static void usbhsp_pipe_tre_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
+{
+   struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
+   struct device *dev = usbhs_priv_to_dev(priv);
+   int num = usbhs_pipe_number(pipe);
+   u16 reg;
+
+   /*
+* It is impossible to calculate address,
+* since PIPEnTRE addresses were mapped randomly.
+*/
+#define CASE_PIPExTRE(a)   \
+   case 0x ## a:   \
+   reg = PIPE ## a ## TRE; \
+   break;
+
+   switch (num) {
+   CASE_PIPExTRE(1);
+   CASE_PIPExTRE(2);
+   CASE_PIPExTRE(3);
+   CASE_PIPExTRE(4);
+   CASE_PIPExTRE(5);
+   CASE_PIPExTRE(B);
+   CASE_PIPExTRE(C);
+   CASE_PIPExTRE(D);
+   CASE_PIPExTRE(E);
+   CASE_PIPExTRE(F);
+   CASE_PIPExTRE(9);
+   CASE_PIPExTRE(A);
+   default:
+   dev_err(dev, unknown pipe (%d)\n, num);
+   return;
+   }
+
+   __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val);
+}
+
+/*
  * PIPEBUF
  */
 static void usbhsp_pipe_buf_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
@@ -264,6 +340,31 @@ int usbhs_pipe_is_stall(struct usbhs_pipe *pipe)
return (int)(pid == PID_STALL10 || pid == PID_STALL11);
 }
 
+void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len)
+{
+   if (!usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK))
+   return;
+
+   /*
+* clear and disable transfer counter for IN/OUT pipe
+*/
+   usbhsp_pipe_tre_set(pipe, TRCLR | TRENB, TRCLR);
+
+   /*
+* Only IN direction bulk pipe

[PATCH 3/3] usb: renesas_usbhs: host: add endpoint user counter

2012-11-06 Thread Kuninori Morimoto
renesas_usbhs attaches pipe to endpoint when urb was queued, and it will be 
detached when transfer was done.
Multi device controlling was enabled by this behavior.
Now renesas_usbhs driver tried to wait until detaching
if urb was queued to endpoint which already has been attached to pipe,
and it created strange driver behavior.
But it can re-use this attached pipe if multi urb was queued.
This patch implements it.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod_host.c |   24 +---
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_host.c 
b/drivers/usb/renesas_usbhs/mod_host.c
index 9bc8c2b..3d3cd6c 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -85,6 +85,7 @@ struct usbhsh_ep {
struct usbhsh_device*udev;   /* attached udev */
struct usb_host_endpoint *ep;
struct list_headep_list; /* list to usbhsh_device */
+   unsigned intcounter; /* pipe attach counter */
 };
 
 #define USBHSH_DEVICE_MAX  10 /* see DEVADDn / DCPMAXP / PIPEMAXP */
@@ -271,8 +272,12 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv,
/  spin lock /
usbhs_lock(priv, flags);
 
-   if (unlikely(usbhsh_uep_to_pipe(uep))) {
-   dev_err(dev, uep already has pipe\n);
+   /*
+* if uep has been attached to pipe,
+* reuse it
+*/
+   if (usbhsh_uep_to_pipe(uep)) {
+   ret = 0;
goto usbhsh_pipe_attach_done;
}
 
@@ -320,6 +325,9 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv,
}
 
 usbhsh_pipe_attach_done:
+   if (0 == ret)
+   uep-counter++;
+
usbhs_unlock(priv, flags);
/  spin unlock **/
 
@@ -346,7 +354,7 @@ static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv,
 
if (unlikely(!pipe)) {
dev_err(dev, uep doens't have pipe\n);
-   } else {
+   } else if (1 == uep-counter--) { /* last user */
struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep);
struct usbhsh_device *udev = usbhsh_uep_to_udev(uep);
 
@@ -391,6 +399,7 @@ static int usbhsh_endpoint_attach(struct usbhsh_hpriv 
*hpriv,
/*
 * init endpoint
 */
+   uep-counter = 0;
INIT_LIST_HEAD(uep-ep_list);
list_add_tail(uep-ep_list, udev-ep_list_head);
 
@@ -959,7 +968,6 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
struct usb_host_endpoint *ep = urb-ep;
struct usbhsh_device *new_udev = NULL;
int is_dir_in = usb_pipein(urb-pipe);
-   int i;
int ret;
 
dev_dbg(dev, %s (%s)\n, __func__, is_dir_in ? in : out);
@@ -1005,13 +1013,7 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd,
 * attach pipe to endpoint
 * see [image of mod_host]
 */
-   for (i = 0; i  1024; i++) {
-   ret = usbhsh_pipe_attach(hpriv, urb);
-   if (ret  0)
-   msleep(100);
-   else
-   break;
-   }
+   ret = usbhsh_pipe_attach(hpriv, urb);
if (ret  0) {
dev_err(dev, pipe attach failed\n);
goto usbhsh_urb_enqueue_error_free_endpoint;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3 v2] usb: renesas_usbhs: use transfer counter if IN direction bulk pipe

2012-11-06 Thread Kuninori Morimoto
received data will break if it was bulk pipe and large data size,
because pipe kept BUF PID even though it doesn't have enough buffer.
To avoid this issue, renesas_usbhs can use transfer counter.
Pipe PID will be NAK if it didn't have enough buffer by this patch.

renesas_usbhs has strange address mapping.
Thus, it is difficult to calculate transfer counter setting address.
This patch use fixed table for it.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 Felipe

This patch is based on felipe/gadget branch.
But you will get conflict when you merged with felipe/master branch.
1cb60156defa4f23d5318ea1ddd400f25b2d0ce5
(usb: renesas_usbhs: fixup dma transfer stall)

Then, please fix it as

 - usbhs_pipe_set_trans_count_if_bulk(pipe, pkt-trans);
 - usbhs_pipe_enable(pipe);
usbhsf_dma_start(pipe, fifo);
dma_async_issue_pending(chan);

 drivers/usb/renesas_usbhs/fifo.c |4 ++
 drivers/usb/renesas_usbhs/pipe.c |  101 ++
 drivers/usb/renesas_usbhs/pipe.h |1 +
 3 files changed, 106 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 77f1adc..72ad375 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -488,6 +488,8 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int 
*is_done)
usbhs_pipe_data_sequence(pipe, pkt-sequence);
pkt-sequence = -1; /* -1 sequence will be ignored */
 
+   usbhs_pipe_set_trans_count_if_bulk(pipe, pkt-length);
+
ret = usbhsf_fifo_select(pipe, fifo, 1);
if (ret  0)
return 0;
@@ -594,6 +596,7 @@ static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int 
*is_done)
usbhs_pipe_data_sequence(pipe, pkt-sequence);
pkt-sequence = -1; /* -1 sequence will be ignored */
 
+   usbhs_pipe_set_trans_count_if_bulk(pipe, pkt-length);
usbhs_pipe_enable(pipe);
usbhsf_rx_irq_ctrl(pipe, 1);
 
@@ -795,6 +798,7 @@ static void xfer_work(struct work_struct *work)
dev_dbg(dev,   %s %d (%d/ %d)\n,
fifo-name, usbhs_pipe_number(pipe), pkt-length, pkt-zero);
 
+   usbhs_pipe_set_trans_count_if_bulk(pipe, pkt-trans);
usbhsf_dma_start(pipe, fifo);
dma_async_issue_pending(chan);
 }
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c
index 122526c..7926e1c 100644
--- a/drivers/usb/renesas_usbhs/pipe.c
+++ b/drivers/usb/renesas_usbhs/pipe.c
@@ -93,6 +93,82 @@ static void usbhsp_pipe_cfg_set(struct usbhs_pipe *pipe, u16 
mask, u16 val)
 }
 
 /*
+ * PIPEnTRN/PIPEnTRE functions
+ */
+static void usbhsp_pipe_trn_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
+{
+   struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
+   struct device *dev = usbhs_priv_to_dev(priv);
+   int num = usbhs_pipe_number(pipe);
+   u16 reg;
+
+   /*
+* It is impossible to calculate address,
+* since PIPEnTRN addresses were mapped randomly.
+*/
+#define CASE_PIPExTRN(a)   \
+   case 0x ## a:   \
+   reg = PIPE ## a ## TRN; \
+   break;
+
+   switch (num) {
+   CASE_PIPExTRN(1);
+   CASE_PIPExTRN(2);
+   CASE_PIPExTRN(3);
+   CASE_PIPExTRN(4);
+   CASE_PIPExTRN(5);
+   CASE_PIPExTRN(B);
+   CASE_PIPExTRN(C);
+   CASE_PIPExTRN(D);
+   CASE_PIPExTRN(E);
+   CASE_PIPExTRN(F);
+   CASE_PIPExTRN(9);
+   CASE_PIPExTRN(A);
+   default:
+   dev_err(dev, unknown pipe (%d)\n, num);
+   return;
+   }
+   __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val);
+}
+
+static void usbhsp_pipe_tre_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
+{
+   struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
+   struct device *dev = usbhs_priv_to_dev(priv);
+   int num = usbhs_pipe_number(pipe);
+   u16 reg;
+
+   /*
+* It is impossible to calculate address,
+* since PIPEnTRE addresses were mapped randomly.
+*/
+#define CASE_PIPExTRE(a)   \
+   case 0x ## a:   \
+   reg = PIPE ## a ## TRE; \
+   break;
+
+   switch (num) {
+   CASE_PIPExTRE(1);
+   CASE_PIPExTRE(2);
+   CASE_PIPExTRE(3);
+   CASE_PIPExTRE(4);
+   CASE_PIPExTRE(5);
+   CASE_PIPExTRE(B);
+   CASE_PIPExTRE(C);
+   CASE_PIPExTRE(D);
+   CASE_PIPExTRE(E);
+   CASE_PIPExTRE(F);
+   CASE_PIPExTRE(9);
+   CASE_PIPExTRE(A);
+   default:
+   dev_err(dev, unknown pipe (%d)\n, num);
+   return;
+   }
+
+   __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val);
+}
+
+/*
  * PIPEBUF
  */
 static void usbhsp_pipe_buf_set(struct usbhs_pipe *pipe, u16 mask, u16 val)
@@ -264,6 +340,31 @@ int usbhs_pipe_is_stall(struct usbhs_pipe *pipe)
return (int)(pid == PID_STALL10 || pid

[PATCH] USB: rcar-phy: fixup implicit declaration of function 'iowrite32'

2012-11-04 Thread Kuninori Morimoto
Current rcar-phy driver used iowerite32/ioread32,
but it cause compile error on some architectures.
This patch used writel/readl and HAS_IOMEM to solve this issue.

drivers/usb/phy/rcar-phy.c: In function 'rcar_usb_phy_init':
drivers/usb/phy/rcar-phy.c:75:3: error: implicit declaration of function\
'iowrite32' [-Werror=implicit-function-declaration]
drivers/usb/phy/rcar-phy.c:83:4: error: implicit declaration of function\
'ioread32' [-Werror=implicit-function-declaration]

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 Felipe

Sorry for late response.
Does this patch solve the issue ?

 drivers/usb/phy/Kconfig|1 +
 drivers/usb/phy/rcar-phy.c |   26 +-
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 7eb73c5..39f920b 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -36,6 +36,7 @@ config MV_U3D_PHY
 config USB_RCAR_PHY
tristate Renesas R-Car USB phy support
depends on USB || USB_GADGET
+   depends on HAS_IOMEM
select USB_OTG_UTILS
help
  Say Y here to add support for the Renesas R-Car USB phy driver.
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c
index 792f505..0096660c 100644
--- a/drivers/usb/phy/rcar-phy.c
+++ b/drivers/usb/phy/rcar-phy.c
@@ -72,15 +72,15 @@ static int rcar_usb_phy_init(struct usb_phy *phy)
 */
 
/* (1) USB-PHY standby release */
-   iowrite32(PHY_ENB, (reg0 + USBPCTRL1));
+   writel(PHY_ENB, (reg0 + USBPCTRL1));
 
/* (2) start USB-PHY internal PLL */
-   iowrite32(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1));
+   writel(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1));
 
/* (3) USB module status check */
for (i = 0; i  1024; i++) {
udelay(10);
-   val = ioread32(reg0 + USBST);
+   val = readl(reg0 + USBST);
if (val == (ST_ACT | ST_PLL))
break;
}
@@ -91,10 +91,10 @@ static int rcar_usb_phy_init(struct usb_phy *phy)
}
 
/* (4) USB-PHY reset clear */
-   iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
+   writel(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
 
/* set platform specific port settings */
-   iowrite32(0x, (reg0 + USBPCTRL0));
+   writel(0x, (reg0 + USBPCTRL0));
 
/*
 * EHCI IP internal buffer setting
@@ -103,21 +103,21 @@ static int rcar_usb_phy_init(struct usb_phy *phy)
 * These are recommended value of a datasheet
 * see [USB :: EHCI internal buffer setting]
 */
-   iowrite32(0x00ff0040, (reg0 + EIIBC1));
-   iowrite32(0x00ff0040, (reg1 + EIIBC1));
+   writel(0x00ff0040, (reg0 + EIIBC1));
+   writel(0x00ff0040, (reg1 + EIIBC1));
 
-   iowrite32(0x0001, (reg0 + EIIBC2));
-   iowrite32(0x0001, (reg1 + EIIBC2));
+   writel(0x0001, (reg0 + EIIBC2));
+   writel(0x0001, (reg1 + EIIBC2));
 
/*
 * Bus alignment settings
 */
 
/* (1) EHCI bus alignment (little endian) */
-   iowrite32(0x, (reg0 + USBEH0));
+   writel(0x, (reg0 + USBEH0));
 
/* (1) OHCI bus alignment (little endian) */
-   iowrite32(0x, (reg0 + USBOH0));
+   writel(0x, (reg0 + USBOH0));
}
 
 phy_init_end:
@@ -135,8 +135,8 @@ static void rcar_usb_phy_shutdown(struct usb_phy *phy)
spin_lock_irqsave(priv-lock, flags);
 
if (priv-counter-- == 1) { /* last user */
-   iowrite32(0x, (reg0 + USBPCTRL0));
-   iowrite32(0x, (reg0 + USBPCTRL1));
+   writel(0x, (reg0 + USBPCTRL0));
+   writel(0x, (reg0 + USBPCTRL1));
}
 
spin_unlock_irqrestore(priv-lock, flags);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6] usb: phy: add R-Car USB phy driver

2012-10-31 Thread Kuninori Morimoto
This patch adds Renesas R-Car USB phy driver.
It supports R8A7779 chip at this point.

R-Car has some USB controllers, but has only one phy-initializer.
So, this driver is counting users.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v5 - v6

 - used if (priv-counter++ == 0)
 - used if (priv-counter-- == 1)
 - fixup missing *
 - fixup macro prefix
 - fixup __devexit

 But as I explained before, this driver can't use devm_request_and_ioremap(),
 because this Renesas R-Car PHY address has strange mapping.
 Some registers of this PHY address are mapped to crevice of USB EHCI/OHCI 
register area.
 like below, so I added /* CAUTION */ to explain why it didn't use 
devm_request_and_ioremap()

  0x  ===
 EHCI
  0x0094 PHY
  0x009C PHY
 EHCI
  0x0400  ==
  ...
  0x0800  ==
 PHY
  0x0900  ==

 drivers/usb/phy/Kconfig|   12 +++
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/rcar-phy.c |  220 
 3 files changed, 233 insertions(+)
 create mode 100644 drivers/usb/phy/rcar-phy.c

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 63c339b..7eb73c5 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -32,3 +32,15 @@ config MV_U3D_PHY
help
  Enable this to support Marvell USB 3.0 phy controller for Marvell
  SoC.
+
+config USB_RCAR_PHY
+   tristate Renesas R-Car USB phy support
+   depends on USB || USB_GADGET
+   select USB_OTG_UTILS
+   help
+ Say Y here to add support for the Renesas R-Car USB phy driver.
+ This chip is typically used as USB phy for USB host, gadget.
+ This driver supports: R8A7779
+
+ To compile this driver as a module, choose M here: the
+ module will be called rcar-phy.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..1a579a8 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c
new file mode 100644
index 000..792f505
--- /dev/null
+++ b/drivers/usb/phy/rcar-phy.c
@@ -0,0 +1,220 @@
+/*
+ * Renesas R-Car USB phy driver
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ * Kuninori Morimoto kuninori.morimoto...@renesas.com
+ *
+ * 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
+ * published by the Free Software Foundation.
+ */
+
+#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
+
+/* USBH common register */
+#define USBPCTRL0  0x0800
+#define USBPCTRL1  0x0804
+#define USBST  0x0808
+#define USBEH0 0x080C
+#define USBOH0 0x081C
+#define USBCTL00x0858
+#define EIIBC1 0x0094
+#define EIIBC2 0x009C
+
+/* USBPCTRL1 */
+#define PHY_RST(1  2)
+#define PLL_ENB(1  1)
+#define PHY_ENB(1  0)
+
+/* USBST */
+#define ST_ACT (1  31)
+#define ST_PLL (1  30)
+
+struct rcar_usb_phy_priv {
+   struct usb_phy phy;
+   spinlock_t lock;
+
+   void __iomem *reg0;
+   void __iomem *reg1;
+   int counter;
+};
+
+#define usb_phy_to_priv(p) container_of(p, struct rcar_usb_phy_priv, phy)
+
+
+/*
+ * USB initial/install operation.
+ *
+ * This function setup USB phy.
+ * The used value and setting order came from
+ * [USB :: Initial setting] on datasheet.
+ */
+static int rcar_usb_phy_init(struct usb_phy *phy)
+{
+   struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy);
+   struct device *dev = phy-dev;
+   void __iomem *reg0 = priv-reg0;
+   void __iomem *reg1 = priv-reg1;
+   int i;
+   u32 val;
+   unsigned long flags;
+
+   spin_lock_irqsave(priv-lock, flags);
+   if (priv-counter++ == 0) {
+
+   /*
+* USB phy start-up
+*/
+
+   /* (1) USB-PHY standby release */
+   iowrite32(PHY_ENB, (reg0 + USBPCTRL1));
+
+   /* (2) start USB-PHY internal PLL */
+   iowrite32(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1));
+
+   /* (3) USB module status check */
+   for (i = 0; i  1024; i++) {
+   udelay(10);
+   val = ioread32(reg0 + USBST);
+   if (val == (ST_ACT | ST_PLL))
+   break;
+   }
+
+   if (val != (ST_ACT | ST_PLL

Re: [PATCH] usb: renesas_usbhs: add DMAEngine support on mod_host

2012-10-18 Thread Kuninori Morimoto

Hi Felipe

  This patch enabled dma mapping, and used dma transfer handler
  on mod_host
  
  Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
  ---
  Felipe
  
  I sent some patches before, and I guess it will go to v3.8 branch.
  please let me know if you want me to resend these.
  
   drivers/usb/renesas_usbhs/mod_host.c |   17 +++--
   1 file changed, 15 insertions(+), 2 deletions(-)
  
  diff --git a/drivers/usb/renesas_usbhs/mod_host.c 
  b/drivers/usb/renesas_usbhs/mod_host.c
  index 9b69a13..e856b44 100644
  --- a/drivers/usb/renesas_usbhs/mod_host.c
  +++ b/drivers/usb/renesas_usbhs/mod_host.c
  @@ -681,9 +681,9 @@ static int usbhsh_queue_push(struct usb_hcd *hcd,
  }
   
  if (usb_pipein(urb-pipe))
  -   pipe-handler = usbhs_fifo_pio_pop_handler;
  +   pipe-handler = usbhs_fifo_dma_pop_handler;
  else
  -   pipe-handler = usbhs_fifo_pio_push_handler;
  +   pipe-handler = usbhs_fifo_dma_push_handler;
   
  buf = (void *)(urb-transfer_buffer + urb-actual_length);
  len = urb-transfer_buffer_length - urb-actual_length;
  @@ -916,6 +916,19 @@ static int usbhsh_dcp_queue_push(struct usb_hcd *hcd,
*/
   static int usbhsh_dma_map_ctrl(struct usbhs_pkt *pkt, int map)
   {
  +   if (map) {
  +   struct usbhsh_request *ureq = usbhsh_pkt_to_ureq(pkt);
  +   struct urb *urb = ureq-urb;
  +
  +   /* it can not use scatter/gather */
  +   if (urb-num_sgs)
  +   return -EINVAL;
 
 I'm not the most knowledgeable on the host stack, but is this really
 necessary ? Isn't host stack supposed to check sg_tablesize and handle
 that properly ?
 
 Alan ? Greg ?

In my check,
${LINUX}/drivers/usb/host/xhci-ring.c
${LINUX}/drivers/usb/host/ehci-tegra.c
are checking num_sgs,
but no driver is checking sg_tablesize in drivers/usb/host


 
  +   pkt-dma = urb-transfer_dma;
  +   if (!pkt-dma)
  +   return -EINVAL;
  +   }
  +
  return 0;
   }
   
  -- 
  1.7.9.5
  
 
 -- 
 balbi


Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: fixup: avoid NULL access on error case pipe detach

2012-10-17 Thread Kuninori Morimoto
If renesas_usbhs or DMAEngine interrupt didn't happen by a certain cause,
urb-ep will be NULL by usb time out.
Then, host mode will access to it and crash kernel.
This patch fixes it.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod_host.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/mod_host.c 
b/drivers/usb/renesas_usbhs/mod_host.c
index e856b44..ff38a30 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -334,6 +334,11 @@ static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv,
struct device *dev = usbhs_priv_to_dev(priv);
unsigned long flags;
 
+   if (unlikely(!uep)) {
+   dev_err(dev, no uep\n);
+   return;
+   }
+
/  spin lock /
usbhs_lock(priv, flags);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: fixup dma transfer stall

2012-10-17 Thread Kuninori Morimoto
renesas_usbhs driver can switch DMA/PIO transfer by using handler,
and each handler have push/pop direction.
But unfortunately, current dma push handler didn't a path
which calls usbhs_pipe_enable(). Thus, dma transfer never happened.
this patch fixes it.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/fifo.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 3818c82..4f60e03 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -795,6 +795,7 @@ static void xfer_work(struct work_struct *work)
dev_dbg(dev,   %s %d (%d/ %d)\n,
fifo-name, usbhs_pipe_number(pipe), pkt-length, pkt-zero);
 
+   usbhs_pipe_enable(pipe);
usbhsf_dma_start(pipe, fifo);
dma_async_issue_pending(chan);
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] usb: renesas_usbhs: gadget: add usb_gadget_ops :: pullup support

2012-10-16 Thread Kuninori Morimoto
This patch adds usbhs_sys_function_pullup() to control
D+ line for USB function, and enabled pullup support on mod_gadget.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v1 - v2

 - add explain on log

 drivers/usb/renesas_usbhs/common.c |5 +
 drivers/usb/renesas_usbhs/common.h |1 +
 drivers/usb/renesas_usbhs/mod_gadget.c |   11 +++
 3 files changed, 17 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/common.c 
b/drivers/usb/renesas_usbhs/common.c
index 072edc1..3bf922ab 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -132,6 +132,11 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int 
enable)
usbhs_bset(priv, SYSCFG, mask, enable ? val : 0);
 }
 
+void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable)
+{
+   usbhs_bset(priv, SYSCFG, DPRPU, enable ? DPRPU : 0);
+}
+
 void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode)
 {
usbhs_write(priv, TESTMODE, mode);
diff --git a/drivers/usb/renesas_usbhs/common.h 
b/drivers/usb/renesas_usbhs/common.h
index dddf40a..c69dd2f 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -285,6 +285,7 @@ void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, 
u16 data);
  */
 void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable);
 void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable);
+void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable);
 void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode);
 
 /*
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index 28478ce..dd41f61 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -883,6 +883,16 @@ static int usbhsg_get_frame(struct usb_gadget *gadget)
return usbhs_frame_get_num(priv);
 }
 
+static int usbhsg_pullup(struct usb_gadget *gadget, int is_on)
+{
+   struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
+   struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
+
+   usbhs_sys_function_pullup(priv, is_on);
+
+   return 0;
+}
+
 static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self)
 {
struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
@@ -900,6 +910,7 @@ static struct usb_gadget_ops usbhsg_gadget_ops = {
.set_selfpowered= usbhsg_set_selfpowered,
.udc_start  = usbhsg_gadget_start,
.udc_stop   = usbhsg_gadget_stop,
+   .pullup = usbhsg_pullup,
 };
 
 static int usbhsg_start(struct usbhs_priv *priv)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] usb: renesas_usbhs: fixup __usbhs_for_each_pipe 1st pos

2012-10-16 Thread Kuninori Morimoto
__usbhs_for_each_pipe() is the macro which moves around each pipe,
but it has a bug which didn't care about 1st pipe's position.
Because of this bug, it moves around
pipe0, pipe2, pipe3 ... even though it requested pipe1, pipe2, pipe3...
This patch modifies it.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v1 - v2

 - add detail explain on log

 drivers/usb/renesas_usbhs/pipe.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h
index 08786c0..3d80c7b 100644
--- a/drivers/usb/renesas_usbhs/pipe.h
+++ b/drivers/usb/renesas_usbhs/pipe.h
@@ -54,7 +54,7 @@ struct usbhs_pipe_info {
  * pipe list
  */
 #define __usbhs_for_each_pipe(start, pos, info, i) \
-   for (i = start, pos = (info)-pipe; \
+   for (i = start, pos = (info)-pipe + i; \
 i  (info)-size;  \
 i++, pos = (info)-pipe + i)
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: renesas_usbhs: return -EINVAL if scatter/gather type DMA

2012-10-15 Thread Kuninori Morimoto

Hi Felipe

Thank you for checking patch


 On Wed, Oct 10, 2012 at 07:18:45PM -0700, Kuninori Morimoto wrote:
  renesas_usbhs can't handle scatter/gather type DMA.
  Thus, return -EINVAL is better than WARNING() on mod_gadget
  
  Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
  ---
   drivers/usb/renesas_usbhs/mod_gadget.c |3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
  
  diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
  b/drivers/usb/renesas_usbhs/mod_gadget.c
  index 28478ce..40256bf 100644
  --- a/drivers/usb/renesas_usbhs/mod_gadget.c
  +++ b/drivers/usb/renesas_usbhs/mod_gadget.c
  @@ -180,7 +180,8 @@ static int usbhsg_dma_map_ctrl(struct usbhs_pkt *pkt, 
  int map)
   
  if (map) {
  /* it can not use scatter/gather */
  -   WARN_ON(req-num_sgs);
  +   if (req-num_sgs)
  +   return -EINVAL;
 
 I would leave the WARN_ON. Did this even trigger at any point ? If it
 did you found a bug on a gadget driver as those should be checking for
 gadget-sg_supported flag before queueing a scatterlist to the
 controller.

OK, I see.
Please drop it.

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: renesas_usbhs: fixup interrupt status clear method

2012-10-15 Thread Kuninori Morimoto

Hi Felipe

 On Thu, Oct 11, 2012 at 09:49:38PM -0700, Kuninori Morimoto wrote:
  When interrupt happened, renesas_usbhs driver gets irq status
  by usbhs_status_get_each_irq(), and cleared all status by using 0.
  But, this method is incorrect,
  since extra interrupt might occur between them.
  This patch cleared corresponding bits only
 
 should this be sent to stable tree also ?

This is not critical patch.
v3.8 is very enough.

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: fixup unreadable macro

2012-10-12 Thread Kuninori Morimoto
mod.h has irq_bempsts/irq_brdysts to keep each irq status,
but it was difficult to find where they were used
on renesas_usbhs driver by using grep irq_ command,
since it used irq_##status macro.
This patch fixup them

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/fifo.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 143c4e9..3818c82 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -192,8 +192,8 @@ void usbhs_pkt_start(struct usbhs_pipe *pipe)
 /*
  * irq enable/disable function
  */
-#define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, bempsts, e)
-#define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, brdysts, e)
+#define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_bempsts, e)
+#define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_brdysts, e)
 #define usbhsf_irq_callback_ctrl(pipe, status, enable) \
({  \
struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); \
@@ -202,9 +202,9 @@ void usbhs_pkt_start(struct usbhs_pipe *pipe)
if (!mod)   \
return; \
if (enable) \
-   mod-irq_##status |= status;\
+   mod-status |= status;  \
else\
-   mod-irq_##status = ~status;   \
+   mod-status = ~status; \
usbhs_irq_callback_update(priv, mod);   \
})
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: fixup __usbhs_for_each_pipe 1st pos

2012-10-11 Thread Kuninori Morimoto
1st pos of __usbhs_for_each_pipe() was wrong.
Each pipe were pipe0, pipe2, pipe3 ...
This patch modifies it.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/pipe.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h
index 08786c0..3d80c7b 100644
--- a/drivers/usb/renesas_usbhs/pipe.h
+++ b/drivers/usb/renesas_usbhs/pipe.h
@@ -54,7 +54,7 @@ struct usbhs_pipe_info {
  * pipe list
  */
 #define __usbhs_for_each_pipe(start, pos, info, i) \
-   for (i = start, pos = (info)-pipe; \
+   for (i = start, pos = (info)-pipe + i; \
 i  (info)-size;  \
 i++, pos = (info)-pipe + i)
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: gadget: add usb_gadget_ops :: pullup support

2012-10-11 Thread Kuninori Morimoto
Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/common.c |5 +
 drivers/usb/renesas_usbhs/common.h |1 +
 drivers/usb/renesas_usbhs/mod_gadget.c |   11 +++
 3 files changed, 17 insertions(+)

diff --git a/drivers/usb/renesas_usbhs/common.c 
b/drivers/usb/renesas_usbhs/common.c
index 072edc1..3bf922ab 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -132,6 +132,11 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int 
enable)
usbhs_bset(priv, SYSCFG, mask, enable ? val : 0);
 }
 
+void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable)
+{
+   usbhs_bset(priv, SYSCFG, DPRPU, enable ? DPRPU : 0);
+}
+
 void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode)
 {
usbhs_write(priv, TESTMODE, mode);
diff --git a/drivers/usb/renesas_usbhs/common.h 
b/drivers/usb/renesas_usbhs/common.h
index dddf40a..c69dd2f 100644
--- a/drivers/usb/renesas_usbhs/common.h
+++ b/drivers/usb/renesas_usbhs/common.h
@@ -285,6 +285,7 @@ void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, 
u16 data);
  */
 void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable);
 void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable);
+void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable);
 void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode);
 
 /*
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index 28478ce..dd41f61 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -883,6 +883,16 @@ static int usbhsg_get_frame(struct usb_gadget *gadget)
return usbhs_frame_get_num(priv);
 }
 
+static int usbhsg_pullup(struct usb_gadget *gadget, int is_on)
+{
+   struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
+   struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv);
+
+   usbhs_sys_function_pullup(priv, is_on);
+
+   return 0;
+}
+
 static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self)
 {
struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget);
@@ -900,6 +910,7 @@ static struct usb_gadget_ops usbhsg_gadget_ops = {
.set_selfpowered= usbhsg_set_selfpowered,
.udc_start  = usbhsg_gadget_start,
.udc_stop   = usbhsg_gadget_stop,
+   .pullup = usbhsg_pullup,
 };
 
 static int usbhsg_start(struct usbhs_priv *priv)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: fixup interrupt status clear method

2012-10-11 Thread Kuninori Morimoto
When interrupt happened, renesas_usbhs driver gets irq status
by usbhs_status_get_each_irq(), and cleared all status by using 0.
But, this method is incorrect,
since extra interrupt might occur between them.
This patch cleared corresponding bits only

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 35c5208..61933a9 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -273,9 +273,9 @@ static irqreturn_t usbhs_interrupt(int irq, void *data)
usbhs_write(priv, INTSTS0, ~irq_state.intsts0  INTSTS0_MAGIC);
usbhs_write(priv, INTSTS1, ~irq_state.intsts1  INTSTS1_MAGIC);
 
-   usbhs_write(priv, BRDYSTS, 0);
-   usbhs_write(priv, NRDYSTS, 0);
-   usbhs_write(priv, BEMPSTS, 0);
+   usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);
+   usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts);
+   usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);
 
/*
 * call irq callback functions
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: return -EINVAL if scatter/gather type DMA

2012-10-10 Thread Kuninori Morimoto
renesas_usbhs can't handle scatter/gather type DMA.
Thus, return -EINVAL is better than WARNING() on mod_gadget

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod_gadget.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c 
b/drivers/usb/renesas_usbhs/mod_gadget.c
index 28478ce..40256bf 100644
--- a/drivers/usb/renesas_usbhs/mod_gadget.c
+++ b/drivers/usb/renesas_usbhs/mod_gadget.c
@@ -180,7 +180,8 @@ static int usbhsg_dma_map_ctrl(struct usbhs_pkt *pkt, int 
map)
 
if (map) {
/* it can not use scatter/gather */
-   WARN_ON(req-num_sgs);
+   if (req-num_sgs)
+   return -EINVAL;
 
ret = usb_gadget_map_request(gpriv-gadget, req, dir);
if (ret  0)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: renesas_usbhs: use devm_request_irq()

2012-10-03 Thread Kuninori Morimoto
This patch uses devm_request_irq() instead of request_irq(),
and removed free_irq() from driver

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 35c5208..2672487 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -151,7 +151,7 @@ int usbhs_mod_probe(struct usbhs_priv *priv)
goto mod_init_host_err;
 
/* irq settings */
-   ret = request_irq(priv-irq, usbhs_interrupt,
+   ret = devm_request_irq(dev, priv-irq, usbhs_interrupt,
  priv-irqflags, dev_name(dev), priv);
if (ret) {
dev_err(dev, irq request err\n);
@@ -172,7 +172,6 @@ void usbhs_mod_remove(struct usbhs_priv *priv)
 {
usbhs_mod_host_remove(priv);
usbhs_mod_gadget_remove(priv);
-   free_irq(priv-irq, priv);
 }
 
 /*
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5] usb: phy: add R-Car USB phy driver

2012-09-13 Thread Kuninori Morimoto
This patch adds Renesas R-Car USB phy driver.
It supports R8A7779 chip at this point.

R-Car has some USB controllers, but has only one phy-initializer.
So, this driver is counting users.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v4 - v5

 - removed LITTLE/BIG define
 - use if (val == (ACT | PLL))
   if (val != (ACT | PLL))

 drivers/usb/phy/Kconfig|   12 +++
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/rcar-phy.c |  217 
 3 files changed, 230 insertions(+)
 create mode 100644 drivers/usb/phy/rcar-phy.c

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 63c339b..7eb73c5 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -32,3 +32,15 @@ config MV_U3D_PHY
help
  Enable this to support Marvell USB 3.0 phy controller for Marvell
  SoC.
+
+config USB_RCAR_PHY
+   tristate Renesas R-Car USB phy support
+   depends on USB || USB_GADGET
+   select USB_OTG_UTILS
+   help
+ Say Y here to add support for the Renesas R-Car USB phy driver.
+ This chip is typically used as USB phy for USB host, gadget.
+ This driver supports: R8A7779
+
+ To compile this driver as a module, choose M here: the
+ module will be called rcar-phy.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index b069f29..1a579a8 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
 obj-$(CONFIG_USB_EHCI_TEGRA)   += tegra_usb_phy.o
+obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c
new file mode 100644
index 000..0ad180f
--- /dev/null
+++ b/drivers/usb/phy/rcar-phy.c
@@ -0,0 +1,217 @@
+/*
+ * Renesas R-Car USB phy driver
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ * Kuninori Morimoto kuninori.morimoto...@renesas.com
+ *
+
+ * 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
+ * published by the Free Software Foundation.
+ */
+
+#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
+
+/* USBH common register */
+#define USBPCTRL0  0x0800
+#define USBPCTRL1  0x0804
+#define USBST  0x0808
+#define USBEH0 0x080C
+#define USBOH0 0x081C
+#define USBCTL00x0858
+#define EIIBC1 0x0094
+#define EIIBC2 0x009C
+
+/* USBPCTRL1 */
+#define PHY_RST(1  2)
+#define PLL_ENB(1  1)
+#define PHY_ENB(1  0)
+
+/* USBST */
+#define ACT(1  31)
+#define PLL(1  30)
+
+struct rcar_usb_phy_priv {
+   struct usb_phy phy;
+   spinlock_t lock;
+
+   void __iomem *reg0;
+   void __iomem *reg1;
+   int counter;
+};
+
+#define usb_phy_to_priv(p) container_of(p, struct rcar_usb_phy_priv, phy)
+
+
+/*
+ * USB initial/install operation.
+ *
+ * This function setup USB phy.
+ * The used value and setting order came from
+ * [USB :: Initial setting] on datasheet.
+ */
+static int rcar_usb_phy_init(struct usb_phy *phy)
+{
+   struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy);
+   struct device *dev = phy-dev;
+   void __iomem *reg0 = priv-reg0;
+   void __iomem *reg1 = priv-reg1;
+   int i;
+   u32 val;
+   unsigned long flags;
+
+   spin_lock_irqsave(priv-lock, flags);
+   if (priv-counter == 0) {
+
+   /*
+* USB phy start-up
+*/
+
+   /* (1) USB-PHY standby release */
+   iowrite32(PHY_ENB, (reg0 + USBPCTRL1));
+
+   /* (2) start USB-PHY internal PLL */
+   iowrite32(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1));
+
+   /* (3) USB module status check */
+   for (i = 0; i  1024; i++) {
+   udelay(10);
+   val = ioread32(reg0 + USBST);
+   if (val == (ACT | PLL))
+   break;
+   }
+
+   if (val != (ACT | PLL)) {
+   dev_err(dev, USB phy not ready\n);
+   goto phy_init_end;
+   }
+
+   /* (4) USB-PHY reset clear */
+   iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
+
+   /* set platform specific port settings */
+   iowrite32(0x, (reg0 + USBPCTRL0));
+
+   /*
+* EHCI IP internal buffer setting
+* EHCI IP internal buffer enable
+*
+* These are recommended value of a datasheet
+* see [USB :: EHCI

Re: [PATCH v3] usb: phy: add R-Car USB phy driver

2012-09-10 Thread Kuninori Morimoto

Hi Felipe

Thank you for checking this patch

  +/* USBH common register */
  +#define USBPCTRL0  0x0800
  +#define USBPCTRL1  0x0804
  +#define USBST  0x0808
  +#define USBEH0 0x080C
  +#define USBOH0 0x081C
  +#define USBCTL00x0858
  +#define EIIBC1 0x0094
  +#define EIIBC2 0x009C
(snip)
  +   reg0 = devm_ioremap_nocache(dev, res0-start, resource_size(res0));
  +   reg1 = devm_ioremap_nocache(dev, res1-start, resource_size(res1));
 
 please use devm_request_and_ioremap().

Sorry about this, but I would like to keep devm_ioremap_nocache() here,
because this Renesas R-Car PHY address has strange mapping.
Some registers of this PHY address are mapped to crevice of USB EHCI/OHCI 
register area.
like this

0x  ===
   EHCI
--
0x0094 PHY
0x009C PHY
--
   EHCI
0x0400  ==
...
0x0800  --
   PHY
0x0900  --

This driver couldn't probe if it used request_mem_region()

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] usb: renesas_usbhs: convert to devm_xxx()

2012-09-10 Thread Kuninori Morimoto
Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v1 - v2

 - used devm_request_and_ioremap()

 drivers/usb/renesas_usbhs/common.c |   15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c 
b/drivers/usb/renesas_usbhs/common.c
index 681da06..072edc1 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -432,17 +432,16 @@ static int usbhs_probe(struct platform_device *pdev)
}
 
/* usb private data */
-   priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+   priv = devm_kzalloc(pdev-dev, sizeof(*priv), GFP_KERNEL);
if (!priv) {
dev_err(pdev-dev, Could not allocate priv\n);
return -ENOMEM;
}
 
-   priv-base = ioremap_nocache(res-start, resource_size(res));
+   priv-base = devm_request_and_ioremap(pdev-dev, res);
if (!priv-base) {
dev_err(pdev-dev, ioremap error.\n);
-   ret = -ENOMEM;
-   goto probe_end_kfree;
+   return -ENOMEM;
}
 
/*
@@ -485,7 +484,7 @@ static int usbhs_probe(struct platform_device *pdev)
/* call pipe and module init */
ret = usbhs_pipe_probe(priv);
if (ret  0)
-   goto probe_end_iounmap;
+   return ret;
 
ret = usbhs_fifo_probe(priv);
if (ret  0)
@@ -546,10 +545,6 @@ probe_end_fifo_exit:
usbhs_fifo_remove(priv);
 probe_end_pipe_exit:
usbhs_pipe_remove(priv);
-probe_end_iounmap:
-   iounmap(priv-base);
-probe_end_kfree:
-   kfree(priv);
 
dev_info(pdev-dev, probe failed\n);
 
@@ -576,8 +571,6 @@ static int __devexit usbhs_remove(struct platform_device 
*pdev)
usbhs_mod_remove(priv);
usbhs_fifo_remove(priv);
usbhs_pipe_remove(priv);
-   iounmap(priv-base);
-   kfree(priv);
 
return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: phy: add R-Car R8A7779 USB phy driver.

2012-09-05 Thread Kuninori Morimoto

Hi Abraham

  EHCI/OHCI.
  Now, I'm using ohci/ehci-platform.c
 
 Thats a generic ehci driver. I was interested in the specific usb
 controller that uses this phy. Anyways now I know its a host only
 driver :-)
(snip)
 Yeah. We are in the process of cleaning it up. Indeed it's normal in
 the sense quite a few host only drivers use it (ehci-fsl.c,
 ehci-msm.c, ehci-mv.c, ehci-tegra.c, ohci-omap.c).
 
  Now, I'm using ehci/ohci-platform.
  When I support this usb_xxx_phy(), do I need to customize these drivers ?
 
 You can't change ehci-platform.c because thats a generic driver. But
 you have to do those modifications in your controller specific file.

OK. I see.

 However if two modules add themselves to the same *initcall* section,
 the order in which the files are compiled determine the order in which
 the modules are probed (I think this is what is happening in your
 case).

Yes. exactly
OK, I use subsys_initcall() for my phy

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] usb: phy: add R-Car USB phy driver

2012-09-05 Thread Kuninori Morimoto
This patch adds Renesas R-Car USB phy driver.
It supports R8A7779 chip at this point.

R-Car has some USB controllers, but has only one phy-initializer.
So, this driver is counting users.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v1 - v2

- enable usb_phy_xxx()
- used subsys_initcall()

 drivers/usb/phy/Kconfig|   11 ++
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/rcar-phy.c |  241 
 3 files changed, 253 insertions(+)
 create mode 100644 drivers/usb/phy/rcar-phy.c

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 2838adb..f55b6f6 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -23,3 +23,14 @@ config MV_U3D_PHY
help
  Enable this to support Marvell USB 3.0 phy controller for Marvell
  SoC.
+
+config USB_RCAR_PHY
+   tristate Renesas R-Car USB phy support
+   depends on (USB || USB_GADGET)  ARCH_R8A7779
+   help
+ Say Y here to add support for the Renesas R-Car USB phy driver.
+ This chip is typically used as USB phy for USB host, gadget.
+ This driver supports: R8A7779
+
+ To compile this driver as a module, choose M here: the
+ module will be called rcar-phy.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index cf38f08..9af83f0 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -6,3 +6,4 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
+obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c
new file mode 100644
index 000..2169a1a
--- /dev/null
+++ b/drivers/usb/phy/rcar-phy.c
@@ -0,0 +1,241 @@
+/*
+ * Renesas R-Car USB phy driver
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ * Kuninori Morimoto kuninori.morimoto...@renesas.com
+ *
+ * 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
+ * published by the Free Software Foundation.
+ */
+
+#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
+
+/* USBH common register */
+#define USBPCTRL0  0x0800
+#define USBPCTRL1  0x0804
+#define USBST  0x0808
+#define USBEH0 0x080C
+#define USBOH0 0x081C
+#define USBCTL00x0858
+#define EIIBC1 0x0094
+#define EIIBC2 0x009C
+
+#ifdef CONFIG_ARCH_SUPPORTS_BIG_ENDIAN
+# define PHY_ENDIAN BIG
+# define PHY_NO_SWAP 0x0003
+#else
+# define PHY_ENDIAN LITTLE
+# define PHY_NO_SWAP 0x
+#endif
+
+/* USBPCTRL1 */
+#define PHY_RST(1  2)
+#define PLL_ENB(1  1)
+#define PHY_ENB(1  0)
+
+/* USBST */
+#define ACT(1  31)
+#define PLL(1  30)
+
+struct rcar_usb_phy_priv {
+   struct usb_phy phy;
+   spinlock_t lock;
+
+   void __iomem *reg0;
+   void __iomem *reg1;
+   int counter;
+};
+
+#define usb_phy_to_priv(p) container_of(p, struct rcar_usb_phy_priv, phy)
+
+
+/*
+ * USB initial/install operation.
+ *
+ * This function setup USB phy.
+ * The used value and setting order came from
+ * [USB :: Initial setting] on datasheet.
+ */
+static int rcar_usb_phy_init(struct usb_phy *phy)
+{
+   struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy);
+   struct device *dev = phy-dev;
+   void __iomem *reg0 = priv-reg0;
+   void __iomem *reg1 = priv-reg1;
+   int i;
+   u32 val;
+   unsigned long flags;
+
+   /  spin lock /
+   spin_lock_irqsave(priv-lock, flags);
+   if (0 == priv-counter) {
+
+   /**
+* USB phy start-up
+**/
+
+   /* (1) USB-PHY standby release */
+   iowrite32(PHY_ENB, (reg0 + USBPCTRL1));
+
+   /* (2) start USB-PHY internal PLL */
+   iowrite32(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1));
+
+   /* (3) USB module status check */
+   for (i = 0; i  1024; i++) {
+   udelay(10);
+   val = ioread32(reg0 + USBST);
+   if ((ACT | PLL) == val)
+   goto usb_module_is_working;
+   }
+   dev_err(dev, USB phy not ready\n);
+   return -EIO;
+
+usb_module_is_working:
+   /* (4) USB-PHY reset clear */
+   iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1));
+
+   /* set platform specific port settings */
+   iowrite32(0x, (reg0 + USBPCTRL0

Re: [PATCH] usb: phy: add R-Car R8A7779 USB phy driver.

2012-09-04 Thread Kuninori Morimoto

Hi Abraham

Thank you for checking patch


  +config USB_RCAR_PHY
  +   tristate Renesas R-Car USB phy support
  +   depends on (USB || USB_GADGET)  ARCH_R8A7779
  +   help
  + Say Y here to add support for the Renesas R-Car USB phy driver.
 
 Just out of curiosity, which USB contoller will/is using this PHY?

EHCI/OHCI.
Now, I'm using ohci/ehci-platform.c

  +   reg0 = ioremap_nocache(res0-start, resource_size(res0));
  +   reg1 = ioremap_nocache(res1-start, resource_size(res1));
 
 Instead use devm_ioremap_nocache?

will do in v2 patch

  +   /* (1) USB-PHY standby release */
  +   iowrite32(0x0001, (reg0 + USBPCTRL1));
 
 Can we have some macros to define the above constant (and for the
 constants used below)?

will do in v2 patch

  +
  +   /* (2) start USB-PHY internal PLL */
  +   iowrite32(0x0003, (reg0 + USBPCTRL1));
 
 No power management stuff added?? Dont we need to stop this PLL during 
 suspend??
(snip)
 I see you are doing one time initialization of the phy during probe.
 But I think this phy will be pointless without the usb controller.
 Instead how about using the library functions like
 usb_add_phy/usb_get_phy/usb_phy_init?

I'm not sure detail, but this usb_xxx_phy() is under otg.
Our system don't support it, but is it normal ?

Now, I'm using ehci/ohci-platform.
When I support this usb_xxx_phy(), do I need to customize these drivers ?

And, this is extra stuff, but I have 1 question.
it is ${LINUX}/driver/usb/Makefile's order.

obj-(xxx) += host/
...
obj-(xxx) += phy/

This means that usb phy driver probe function is called
after host driver probe function().
Now, I'm using a technique which delays usb host driver registration,
but why phy driver is called after host driver ?

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: phy: add R-Car R8A7779 USB phy driver.

2012-09-03 Thread Kuninori Morimoto
This patch adds Renesas R-Car USB phy driver.
It supports R8A7779 chip at this point.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/phy/Kconfig|   11 
 drivers/usb/phy/Makefile   |1 +
 drivers/usb/phy/rcar-phy.c |  137 
 3 files changed, 149 insertions(+)
 create mode 100644 drivers/usb/phy/rcar-phy.c

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 2838adb..f55b6f6 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -23,3 +23,14 @@ config MV_U3D_PHY
help
  Enable this to support Marvell USB 3.0 phy controller for Marvell
  SoC.
+
+config USB_RCAR_PHY
+   tristate Renesas R-Car USB phy support
+   depends on (USB || USB_GADGET)  ARCH_R8A7779
+   help
+ Say Y here to add support for the Renesas R-Car USB phy driver.
+ This chip is typically used as USB phy for USB host, gadget.
+ This driver supports: R8A7779
+
+ To compile this driver as a module, choose M here: the
+ module will be called rcar-phy.
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index cf38f08..9af83f0 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -6,3 +6,4 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
 
 obj-$(CONFIG_USB_ISP1301)  += isp1301.o
 obj-$(CONFIG_MV_U3D_PHY)   += mv_u3d_phy.o
+obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c
new file mode 100644
index 000..deec078
--- /dev/null
+++ b/drivers/usb/phy/rcar-phy.c
@@ -0,0 +1,137 @@
+/*
+ * Renesas R-Car USB phy driver
+ *
+ * Copyright (C) 2012 Renesas Solutions Corp.
+ * Kuninori Morimoto kuninori.morimoto...@renesas.com
+ *
+ * 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
+ * published by the Free Software Foundation.
+ */
+
+#include linux/delay.h
+#include linux/io.h
+#include linux/platform_device.h
+#include linux/module.h
+
+/* USBH common register */
+#define USBPCTRL0  0x0800
+#define USBPCTRL1  0x0804
+#define USBST  0x0808
+#define USBEH0 0x080C
+#define USBOH0 0x081C
+#define USBCTL00x0858
+#define EIIBC1 0x0094
+#define EIIBC2 0x009C
+
+#ifdef CONFIG_ARCH_SUPPORTS_BIG_ENDIAN
+# define PHY_ENDIAN BIG
+# define PHY_NO_SWAP 0x0003
+#else
+# define PHY_ENDIAN LITTLE
+# define PHY_NO_SWAP 0x
+#endif
+
+/*
+ * USB initial/install operation.
+ *
+ * This function setup USB phy.
+ * The used value and setting order came from
+ * [USB :: Initial setting] on datasheet.
+ */
+static int rcar_phy_probe(struct platform_device *pdev)
+{
+   struct resource *res0, *res1;
+   void __iomem *reg0, *reg1;
+   int i, ret = 0;
+   u32 val;
+
+   res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+   if (!res0 || !res1) {
+   dev_err(pdev-dev, Not enough platform resources\n);
+   return -ENODEV;
+   }
+
+   reg0 = ioremap_nocache(res0-start, resource_size(res0));
+   reg1 = ioremap_nocache(res1-start, resource_size(res1));
+   if (!reg0 || !reg1) {
+   dev_err(pdev-dev, ioremap error.\n);
+   ret = -ENOMEM;
+   goto end;
+   }
+
+   /**
+* USB phy start-up
+**/
+
+   /* (1) USB-PHY standby release */
+   iowrite32(0x0001, (reg0 + USBPCTRL1));
+
+   /* (2) start USB-PHY internal PLL */
+   iowrite32(0x0003, (reg0 + USBPCTRL1));
+
+   /* (3) USB module status check */
+   for (i = 0; i  1024; i++) {
+   udelay(10);
+   val = ioread32(reg0 + USBST);
+   if (0xc000 == val)
+   goto usb_module_is_working;
+   }
+   dev_err(pdev-dev, USB module not ready\n);
+   ret = -EIO;
+   goto end;
+
+usb_module_is_working:
+   /* (4) USB-PHY reset clear */
+   iowrite32(0x0007, (reg0 + USBPCTRL1));
+
+   /* set platform specific port settings */
+   iowrite32(0x, (reg0 + USBPCTRL0));
+
+   /**
+* EHCI IP Internal Buffer Setting
+**/
+
+   /* (1) EHCI IP internal buffer setting */
+   iowrite32(0x00ff0040, (reg0 + EIIBC1));
+   iowrite32(0x00ff0040, (reg1 + EIIBC1));
+
+   /* (2) EHCI IP internal buffer enable */
+   iowrite32(0x0001, (reg0 + EIIBC2));
+   iowrite32(0x0001, (reg1 + EIIBC2));
+
+   /**
+* Bus alignment settings
+**/
+
+   /* (1) EHCI bus alignment

[PATCH] usb: renesas_usbhs: fixup DMA transport data alignment

2012-08-22 Thread Kuninori Morimoto
renesas_usbhs dma can transport 8byte alignment data, not 4byte.
This patch fixup it.

Reported-by: Sugnan Prabhu S sugnan.pra...@renesasmobile.com
Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/fifo.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index ecd1730..143c4e9 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -818,7 +818,7 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, 
int *is_done)
usbhs_pipe_is_dcp(pipe))
goto usbhsf_pio_prepare_push;
 
-   if (len % 4) /* 32bit alignment */
+   if (len  0x7) /* 8byte alignment */
goto usbhsf_pio_prepare_push;
 
if ((uintptr_t)(pkt-buf + pkt-actual)  0x7) /* 8byte alignment */
@@ -905,7 +905,7 @@ static int usbhsf_dma_try_pop(struct usbhs_pkt *pkt, int 
*is_done)
/* use PIO if packet is less than pio_dma_border */
len = usbhsf_fifo_rcv_len(priv, fifo);
len = min(pkt-length - pkt-actual, len);
-   if (len % 4) /* 32bit alignment */
+   if (len  0x7) /* 8byte alignment */
goto usbhsf_pio_prepare_pop_unselect;
 
if (len  usbhs_get_dparam(priv, pio_dma_border))
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 1/4 v3] usb: host: ehci-platform: BUG_ON() to WARN_ON() on probe

2012-08-06 Thread Kuninori Morimoto

Hi Simon

Thank you for checking patch

  +#define ehci_pdata_get(pdata, x) ((pdata) ? (pdata)-x : 0)
  +
 
 FWIW, I think that an inline function would be a slight improvement over
 a macro here.  Likewise for the 2nd patch of this series.

All these patches have this kind of macros.
I needs maintainer's opinion.
If he said it should be inline, I'm happy to send v4 patches.

Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 0/4 v4] usb: host: ehci-platform: add platform specific .power callback

2012-08-06 Thread kuninori . morimoto . gx

Hi Alan, Felipe, Greg

These are v4 of ehci/ohci-platform patches

Kuninori Morimoto (4):
  usb: host: ehci-platform: BUG_ON() to WARN_ON() on probe
  usb: host: ohci-platform: BUG_ON() to WARN_ON() on probe
  usb: host: ehci-platform: add platform specific power callback
  usb: host: ohci-platform: add platform specific power callback

 drivers/usb/host/ehci-platform.c |   46 ++---
 drivers/usb/host/ohci-platform.c |   42 --
 include/linux/usb/ehci_pdriver.h |8 ++
 include/linux/usb/ohci_pdriver.h |8 ++
 4 files changed, 97 insertions(+), 7 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 1/4 v4] usb: host: ehci-platform: BUG_ON() to WARN_ON() on probe

2012-08-06 Thread Kuninori Morimoto
usb_ehci_pdata is certainly required in ehci-platform driver.
This patch avoids using BUG_ON() from driver,
and return from probe with WARN_ON() if pdata was NULL.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v3 - v4
 - remove macro
 - return probe if pdata was NULL

 drivers/usb/host/ehci-platform.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index 4b1d896..a2aaef6 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -82,10 +82,14 @@ static int __devinit ehci_platform_probe(struct 
platform_device *dev)
 {
struct usb_hcd *hcd;
struct resource *res_mem;
+   struct usb_ehci_pdata *pdata = dev-dev.platform_data;
int irq;
int err = -ENOMEM;
 
-   BUG_ON(!dev-dev.platform_data);
+   if (!pdata) {
+   WARN_ON(1);
+   return -ENODEV;
+   }
 
if (usb_disabled())
return -ENODEV;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 2/4 v4] usb: host: ohci-platform: BUG_ON() to WARN_ON() on probe

2012-08-06 Thread Kuninori Morimoto
usb_ohci_pdata is certainly required in ohci-platform driver.
This patch avoids using BUG_ON() from driver,
and return from probe with WARN_ON() if pdata was NULL.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v3 - v4

 - remove macro
 - return probe if pdata was NULL

 drivers/usb/host/ohci-platform.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 670c705..4c886f9 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -83,10 +83,14 @@ static int __devinit ohci_platform_probe(struct 
platform_device *dev)
 {
struct usb_hcd *hcd;
struct resource *res_mem;
+   struct usb_ohci_pdata *pdata = dev-dev.platform_data;
int irq;
int err = -ENOMEM;
 
-   BUG_ON(!dev-dev.platform_data);
+   if (!pdata) {
+   WARN_ON(1);
+   return -ENODEV;
+   }
 
if (usb_disabled())
return -ENODEV;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 3/4] usb: host: ehci-platform: add platform specific power callback

2012-08-06 Thread Kuninori Morimoto
This patch enables to call platform specific power callback function.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v3 - v4

 - remove macro
 - remove .power_suspend
 - check return value on resume

 drivers/usb/host/ehci-platform.c |   40 +++--
 include/linux/usb/ehci_pdriver.h |8 +++
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index a2aaef6..91acdde 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -105,10 +105,18 @@ static int __devinit ehci_platform_probe(struct 
platform_device *dev)
return -ENXIO;
}
 
+   if (pdata-power_on) {
+   err = pdata-power_on(dev);
+   if (err  0)
+   return err;
+   }
+
hcd = usb_create_hcd(ehci_platform_hc_driver, dev-dev,
 dev_name(dev-dev));
-   if (!hcd)
-   return -ENOMEM;
+   if (!hcd) {
+   err = -ENOMEM;
+   goto err_power;
+   }
 
hcd-rsrc_start = res_mem-start;
hcd-rsrc_len = resource_size(res_mem);
@@ -136,12 +144,17 @@ err_release_region:
release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
 err_put_hcd:
usb_put_hcd(hcd);
+err_power:
+   if (pdata-power_off)
+   pdata-power_off(dev);
+
return err;
 }
 
 static int __devexit ehci_platform_remove(struct platform_device *dev)
 {
struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct usb_ehci_pdata *pdata = dev-dev.platform_data;
 
usb_remove_hcd(hcd);
iounmap(hcd-regs);
@@ -149,6 +162,9 @@ static int __devexit ehci_platform_remove(struct 
platform_device *dev)
usb_put_hcd(hcd);
platform_set_drvdata(dev, NULL);
 
+   if (pdata-power_off)
+   pdata-power_off(dev);
+
return 0;
 }
 
@@ -157,14 +173,32 @@ static int __devexit ehci_platform_remove(struct 
platform_device *dev)
 static int ehci_platform_suspend(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
+   struct usb_ehci_pdata *pdata = dev-platform_data;
+   struct platform_device *pdev =
+   container_of(dev, struct platform_device, dev);
bool do_wakeup = device_may_wakeup(dev);
+   int ret;
+
+   ret = ehci_suspend(hcd, do_wakeup);
 
-   return ehci_suspend(hcd, do_wakeup);
+   if (pdata-power_suspend)
+   pdata-power_suspend(pdev);
+
+   return ret;
 }
 
 static int ehci_platform_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
+   struct usb_ehci_pdata *pdata = dev-platform_data;
+   struct platform_device *pdev =
+   container_of(dev, struct platform_device, dev);
+
+   if (pdata-power_on) {
+   int err = pdata-power_on(pdev);
+   if (err  0)
+   return err;
+   }
 
ehci_resume(hcd, false);
return 0;
diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h
index 1894f42..c9d09f8 100644
--- a/include/linux/usb/ehci_pdriver.h
+++ b/include/linux/usb/ehci_pdriver.h
@@ -41,6 +41,14 @@ struct usb_ehci_pdata {
unsignedbig_endian_mmio:1;
unsignedport_power_on:1;
unsignedport_power_off:1;
+
+   /* Turn on all power and clocks */
+   int (*power_on)(struct platform_device *pdev);
+   /* Turn off all power and clocks */
+   void (*power_off)(struct platform_device *pdev);
+   /* Turn on only VBUS suspend power and hotplug detection,
+* turn off everything else */
+   void (*power_suspend)(struct platform_device *pdev);
 };
 
 #endif /* __USB_CORE_EHCI_PDRIVER_H */
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 4/4] usb: host: ohci-platform: add platform specific power callback

2012-08-06 Thread Kuninori Morimoto
This patch enables to call platform specific power callback function.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v3 - v4

 - remove macro
 - remove .power_suspen
 - check return value on resume

 drivers/usb/host/ohci-platform.c |   36 ++--
 include/linux/usb/ohci_pdriver.h |8 
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 4c886f9..10d85b9 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -107,10 +107,18 @@ static int __devinit ohci_platform_probe(struct 
platform_device *dev)
return -ENXIO;
}
 
+   if (pdata-power_on) {
+   err = pdata-power_on(dev);
+   if (err  0)
+   return err;
+   }
+
hcd = usb_create_hcd(ohci_platform_hc_driver, dev-dev,
dev_name(dev-dev));
-   if (!hcd)
-   return -ENOMEM;
+   if (!hcd) {
+   err = -ENOMEM;
+   goto err_power;
+   }
 
hcd-rsrc_start = res_mem-start;
hcd-rsrc_len = resource_size(res_mem);
@@ -138,12 +146,17 @@ err_release_region:
release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
 err_put_hcd:
usb_put_hcd(hcd);
+err_power:
+   if (pdata-power_off)
+   pdata-power_off(dev);
+
return err;
 }
 
 static int __devexit ohci_platform_remove(struct platform_device *dev)
 {
struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct usb_ohci_pdata *pdata = dev-dev.platform_data;
 
usb_remove_hcd(hcd);
iounmap(hcd-regs);
@@ -151,6 +164,9 @@ static int __devexit ohci_platform_remove(struct 
platform_device *dev)
usb_put_hcd(hcd);
platform_set_drvdata(dev, NULL);
 
+   if (pdata-power_off)
+   pdata-power_off(dev);
+
return 0;
 }
 
@@ -158,12 +174,28 @@ static int __devexit ohci_platform_remove(struct 
platform_device *dev)
 
 static int ohci_platform_suspend(struct device *dev)
 {
+   struct usb_ohci_pdata *pdata = dev-platform_data;
+   struct platform_device *pdev =
+   container_of(dev, struct platform_device, dev);
+
+   if (pdata-power_suspend)
+   pdata-power_suspend(pdev);
+
return 0;
 }
 
 static int ohci_platform_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
+   struct usb_ohci_pdata *pdata = dev-platform_data;
+   struct platform_device *pdev =
+   container_of(dev, struct platform_device, dev);
+
+   if (pdata-power_on) {
+   int err = pdata-power_on(pdev);
+   if (err  0)
+   return err;
+   }
 
ohci_finish_controller_resume(hcd);
return 0;
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h
index 2808f2a..74e7755 100644
--- a/include/linux/usb/ohci_pdriver.h
+++ b/include/linux/usb/ohci_pdriver.h
@@ -33,6 +33,14 @@ struct usb_ohci_pdata {
unsignedbig_endian_desc:1;
unsignedbig_endian_mmio:1;
unsignedno_big_frame_no:1;
+
+   /* Turn on all power and clocks */
+   int (*power_on)(struct platform_device *pdev);
+   /* Turn off all power and clocks */
+   void (*power_off)(struct platform_device *pdev);
+   /* Turn on only VBUS suspend power and hotplug detection,
+* turn off everything else */
+   void (*power_suspend)(struct platform_device *pdev);
 };
 
 #endif /* __USB_CORE_OHCI_PDRIVER_H */
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC][PATCH 0/4 v3] usb: host: ehci-platform: add platform specific .power callback

2012-08-05 Thread kuninori . morimoto . gx

Hi Alan, Felipe, Greg

These are v3 of ehci/ohci-platform patches

Kuninori Morimoto (4):
  usb: host: ehci-platform: BUG_ON() to WARN_ON() on probe
  usb: host: ohci-platform: BUG_ON() to WARN_ON() on probe
  usb: host: ehci-platform: add platform specific power callback
  usb: host: ohci-platform: add platform specific power callback

 drivers/usb/host/ehci-platform.c |   56 ++---
 drivers/usb/host/ohci-platform.c |   44 +
 include/linux/usb/ehci_pdriver.h |5 +++
 include/linux/usb/ohci_pdriver.h |5 +++
 4 files changed, 93 insertions(+), 17 deletions(-)
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 2/4 v3] usb: host: ohci-platform: BUG_ON() to WARN_ON() on probe

2012-08-05 Thread kuninori . morimoto . gx
We should avoid using BUG_ON() in drivers.
This patch switch to use WARN_ON() from BUG_ON(),
and avoid NULL pointer access by new macro.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v2 - v3

 - BUG_ON - WARN_ON

 drivers/usb/host/ohci-platform.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 670c705..d2893e6 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -16,6 +16,8 @@
 #include linux/platform_device.h
 #include linux/usb/ohci_pdriver.h
 
+#define ohci_pdata_get(pdata, x) ((pdata) ? (pdata)-x : 0)
+
 static int ohci_platform_reset(struct usb_hcd *hcd)
 {
struct platform_device *pdev = to_platform_device(hcd-self.controller);
@@ -23,11 +25,11 @@ static int ohci_platform_reset(struct usb_hcd *hcd)
struct ohci_hcd *ohci = hcd_to_ohci(hcd);
int err;
 
-   if (pdata-big_endian_desc)
+   if (ohci_pdata_get(pdata, big_endian_desc))
ohci-flags |= OHCI_QUIRK_BE_DESC;
-   if (pdata-big_endian_mmio)
+   if (ohci_pdata_get(pdata, big_endian_mmio))
ohci-flags |= OHCI_QUIRK_BE_MMIO;
-   if (pdata-no_big_frame_no)
+   if (ohci_pdata_get(pdata, no_big_frame_no))
ohci-flags |= OHCI_QUIRK_FRAME_NO;
 
ohci_hcd_init(ohci);
@@ -86,7 +88,7 @@ static int __devinit ohci_platform_probe(struct 
platform_device *dev)
int irq;
int err = -ENOMEM;
 
-   BUG_ON(!dev-dev.platform_data);
+   WARN_ON(!dev-dev.platform_data);
 
if (usb_disabled())
return -ENODEV;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 3/4 v3] usb: host: ehci-platform: add platform specific power callback

2012-08-05 Thread kuninori . morimoto . gx
This patch enables to call platform specific power callback function.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v2 - v3

 - add power multi functions
 - call it by macro

 drivers/usb/host/ehci-platform.c |   40 ++---
 include/linux/usb/ehci_pdriver.h |5 
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index db27dfe..bcdb9e4 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -22,6 +22,8 @@
 #include linux/usb/ehci_pdriver.h
 
 #define ehci_pdata_get(pdata, x) ((pdata) ? (pdata)-x : 0)
+#define ehci_pdata_call(pdata, x, args...) \
+   ((!(pdata) || !((pdata)-x)) ? 0 : (pdata)-x(args))
 
 static int ehci_platform_reset(struct usb_hcd *hcd)
 {
@@ -84,10 +86,11 @@ static int __devinit ehci_platform_probe(struct 
platform_device *dev)
 {
struct usb_hcd *hcd;
struct resource *res_mem;
+   struct usb_ehci_pdata *pdata = dev-dev.platform_data;
int irq;
int err = -ENOMEM;
 
-   WARN_ON(!dev-dev.platform_data);
+   WARN_ON(!pdata);
 
if (usb_disabled())
return -ENODEV;
@@ -103,10 +106,17 @@ static int __devinit ehci_platform_probe(struct 
platform_device *dev)
return -ENXIO;
}
 
+   /* power ON if platform supported */
+   err = ehci_pdata_call(pdata, power_on, dev);
+   if (err  0)
+   return err;
+
hcd = usb_create_hcd(ehci_platform_hc_driver, dev-dev,
 dev_name(dev-dev));
-   if (!hcd)
-   return -ENOMEM;
+   if (!hcd) {
+   err = -ENOMEM;
+   goto err_power;
+   }
 
hcd-rsrc_start = res_mem-start;
hcd-rsrc_len = resource_size(res_mem);
@@ -134,12 +144,16 @@ err_release_region:
release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
 err_put_hcd:
usb_put_hcd(hcd);
+err_power:
+   ehci_pdata_call(pdata, power_off, dev);
+
return err;
 }
 
 static int __devexit ehci_platform_remove(struct platform_device *dev)
 {
struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct usb_ehci_pdata *pdata = dev-dev.platform_data;
 
usb_remove_hcd(hcd);
iounmap(hcd-regs);
@@ -147,6 +161,9 @@ static int __devexit ehci_platform_remove(struct 
platform_device *dev)
usb_put_hcd(hcd);
platform_set_drvdata(dev, NULL);
 
+   /* power OFF if platform supported */
+   ehci_pdata_call(pdata, power_off, dev);
+
return 0;
 }
 
@@ -155,14 +172,29 @@ static int __devexit ehci_platform_remove(struct 
platform_device *dev)
 static int ehci_platform_suspend(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
+   struct usb_ehci_pdata *pdata = dev-platform_data;
+   struct platform_device *pdev =
+   container_of(dev, struct platform_device, dev);
bool do_wakeup = device_may_wakeup(dev);
+   int ret;
 
-   return ehci_suspend(hcd, do_wakeup);
+   ret = ehci_suspend(hcd, do_wakeup);
+
+   /* power suspend if platform supported */
+   ehci_pdata_call(pdata, power_suspend, pdev);
+
+   return ret;
 }
 
 static int ehci_platform_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
+   struct usb_ehci_pdata *pdata = dev-platform_data;
+   struct platform_device *pdev =
+   container_of(dev, struct platform_device, dev);
+
+   /* power resume if platform supported */
+   ehci_pdata_call(pdata, power_resume, pdev);
 
ehci_resume(hcd, false);
return 0;
diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h
index 1894f42..23a2f38 100644
--- a/include/linux/usb/ehci_pdriver.h
+++ b/include/linux/usb/ehci_pdriver.h
@@ -41,6 +41,11 @@ struct usb_ehci_pdata {
unsignedbig_endian_mmio:1;
unsignedport_power_on:1;
unsignedport_power_off:1;
+
+   int (*power_on)(struct platform_device *pdev);
+   void (*power_off)(struct platform_device *pdev);
+   void (*power_suspend)(struct platform_device *pdev);
+   void (*power_resume)(struct platform_device *pdev);
 };
 
 #endif /* __USB_CORE_EHCI_PDRIVER_H */
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 4/4 v3] usb: host: ohci-platform: add platform specific power callback

2012-08-05 Thread kuninori . morimoto . gx
This patch enables to call platform specific power callback function.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v2 - v3

 - add power multi functions
 - call it by macro

 drivers/usb/host/ohci-platform.c |   36 +---
 include/linux/usb/ohci_pdriver.h |5 +
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index d2893e6..b147680 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -17,6 +17,8 @@
 #include linux/usb/ohci_pdriver.h
 
 #define ohci_pdata_get(pdata, x) ((pdata) ? (pdata)-x : 0)
+#define ohci_pdata_call(pdata, x, args...) \
+   ((!(pdata) || !((pdata)-x)) ? 0 : (pdata)-x(args))
 
 static int ohci_platform_reset(struct usb_hcd *hcd)
 {
@@ -85,10 +87,11 @@ static int __devinit ohci_platform_probe(struct 
platform_device *dev)
 {
struct usb_hcd *hcd;
struct resource *res_mem;
+   struct usb_ohci_pdata *pdata = dev-dev.platform_data;
int irq;
int err = -ENOMEM;
 
-   WARN_ON(!dev-dev.platform_data);
+   WARN_ON(!pdata);
 
if (usb_disabled())
return -ENODEV;
@@ -105,10 +108,17 @@ static int __devinit ohci_platform_probe(struct 
platform_device *dev)
return -ENXIO;
}
 
+   /* power ON if platform supported */
+   err = ohci_pdata_call(pdata, power_on, dev);
+   if (err  0)
+   return err;
+
hcd = usb_create_hcd(ohci_platform_hc_driver, dev-dev,
dev_name(dev-dev));
-   if (!hcd)
-   return -ENOMEM;
+   if (!hcd) {
+   err = -ENOMEM;
+   goto err_power;
+   }
 
hcd-rsrc_start = res_mem-start;
hcd-rsrc_len = resource_size(res_mem);
@@ -136,12 +146,16 @@ err_release_region:
release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
 err_put_hcd:
usb_put_hcd(hcd);
+err_power:
+   ohci_pdata_call(pdata, power_off, dev);
+
return err;
 }
 
 static int __devexit ohci_platform_remove(struct platform_device *dev)
 {
struct usb_hcd *hcd = platform_get_drvdata(dev);
+   struct usb_ohci_pdata *pdata = dev-dev.platform_data;
 
usb_remove_hcd(hcd);
iounmap(hcd-regs);
@@ -149,6 +163,9 @@ static int __devexit ohci_platform_remove(struct 
platform_device *dev)
usb_put_hcd(hcd);
platform_set_drvdata(dev, NULL);
 
+   /* power OFF if platform supported */
+   ohci_pdata_call(pdata, power_off, dev);
+
return 0;
 }
 
@@ -156,12 +173,25 @@ static int __devexit ohci_platform_remove(struct 
platform_device *dev)
 
 static int ohci_platform_suspend(struct device *dev)
 {
+   struct usb_ohci_pdata *pdata = dev-platform_data;
+   struct platform_device *pdev =
+   container_of(dev, struct platform_device, dev);
+
+   /* power suspend if platform supported */
+   ohci_pdata_call(pdata, power_suspend, pdev);
+
return 0;
 }
 
 static int ohci_platform_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
+   struct usb_ohci_pdata *pdata = dev-platform_data;
+   struct platform_device *pdev =
+   container_of(dev, struct platform_device, dev);
+
+   /* power resume if platform supported */
+   ohci_pdata_call(pdata, power_resume, pdev);
 
ohci_finish_controller_resume(hcd);
return 0;
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h
index 2808f2a..4562960 100644
--- a/include/linux/usb/ohci_pdriver.h
+++ b/include/linux/usb/ohci_pdriver.h
@@ -33,6 +33,11 @@ struct usb_ohci_pdata {
unsignedbig_endian_desc:1;
unsignedbig_endian_mmio:1;
unsignedno_big_frame_no:1;
+
+   int (*power_on)(struct platform_device *pdev);
+   void (*power_off)(struct platform_device *pdev);
+   void (*power_suspend)(struct platform_device *pdev);
+   void (*power_resume)(struct platform_device *pdev);
 };
 
 #endif /* __USB_CORE_OHCI_PDRIVER_H */
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] usb: renesas_usbhs: bugfix patches

2012-08-05 Thread Kuninori Morimoto

Hi Felipe, Greg

These are bug fix patches of renesas_usbhs.
Without these patches, renesas_usbhs suspend/resume will be failed
on Host mode.

Kuninori Morimoto (2):
  usb: renesas_usbhs: mod_host: add missing .bus_suspend/resume
  usb: renesas_usbhs: fixup resume method for autonomy mode

 drivers/usb/renesas_usbhs/common.c   |6 +++---
 drivers/usb/renesas_usbhs/mod_host.c |8 
 2 files changed, 11 insertions(+), 3 deletions(-)



Best regards
---
Kuninori Morimoto
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] usb: renesas_usbhs: mod_host: add missing .bus_suspend/resume

2012-08-05 Thread Kuninori Morimoto
suspend/resume will failed on renesas_usbhs without this patch.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/mod_host.c |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/mod_host.c 
b/drivers/usb/renesas_usbhs/mod_host.c
index 1834cf5..9b69a13 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -1266,6 +1266,12 @@ static int usbhsh_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
return ret;
 }
 
+static int usbhsh_bus_nop(struct usb_hcd *hcd)
+{
+   /* nothing to do */
+   return 0;
+}
+
 static struct hc_driver usbhsh_driver = {
.description =  usbhsh_hcd_name,
.hcd_priv_size =sizeof(struct usbhsh_hpriv),
@@ -1290,6 +1296,8 @@ static struct hc_driver usbhsh_driver = {
 */
.hub_status_data =  usbhsh_hub_status_data,
.hub_control =  usbhsh_hub_control,
+   .bus_suspend =  usbhsh_bus_nop,
+   .bus_resume =   usbhsh_bus_nop,
 };
 
 /*
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] usb: renesas_usbhs: fixup resume method for autonomy mode

2012-08-05 Thread Kuninori Morimoto
If renesas_usbhs is probed as autonomy mode,
phy reset should be called after power resumed,
and manual cold-plug should be called with slight delay.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
 drivers/usb/renesas_usbhs/common.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/renesas_usbhs/common.c 
b/drivers/usb/renesas_usbhs/common.c
index e9a5b1d..6259ff6 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -602,12 +602,12 @@ static int usbhsc_resume(struct device *dev)
struct usbhs_priv *priv = dev_get_drvdata(dev);
struct platform_device *pdev = usbhs_priv_to_pdev(priv);
 
-   usbhs_platform_call(priv, phy_reset, pdev);
-
if (!usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL))
usbhsc_power_ctrl(priv, 1);
 
-   usbhsc_hotplug(priv);
+   usbhs_platform_call(priv, phy_reset, pdev);
+
+   usbhsc_drvcllbck_notify_hotplug(pdev);
 
return 0;
 }
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >