Re: [PATCH 5/8] usb: musb: Change end point selection to use new IO access

2014-11-28 Thread Linus Walleij
On Mon, Nov 24, 2014 at 8:05 PM, Tony Lindgren t...@atomide.com wrote:

 This allows the endpoints to work when multiple MUSB glue
 layers are built in.

 Cc: Fabio Baltieri fabio.balti...@linaro.org
 Cc: Lee Jones lee.jo...@linaro.org
 Cc: Linus Walleij linus.wall...@linaro.org
 Cc: Apelete Seketeli apel...@seketeli.net
 Cc: Lars-Peter Clausen l...@metafoo.de
 Signed-off-by: Tony Lindgren t...@atomide.com

Acked-by: Linus Walleij linus.wall...@linaro.org

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


Re: [PATCH 5/8] usb: musb: Change end point selection to use new IO access

2014-11-25 Thread Lars-Peter Clausen

On 11/25/2014 12:52 AM, Tony Lindgren wrote:

* Apelete Seketeli apel...@seketeli.net [141124 15:40]:

Hi Tony,

Thanks for the patch.

On Mon, Nov-24-2014 at 11:05:03 AM -0800, Tony Lindgren wrote:

This allows the endpoints to work when multiple MUSB glue
layers are built in.


Applied on top of 3.18-rc6 mainline and tested successfully on JZ4740.
Been able to use ethernet-over-usb to access the internet on
device. No issue as far as I'm concerned.


Great that's good to hear and thanks for testing.

Doing the DMA patches here right now.. For the DMA, I've set up
JZ4740 to use the MUSB_DMA_INVENTRA option by default, is that OK
or do you have some other DMA hardware on it?

If MUSB_DMA_INVENTRA does not work, and you don't have other DMA
hardware on it, we can pass MUSB_DMA_INVENTRA and leave the DMA
function pointers empty, and then the driver will bail out during
init unless the option for CONFIG_MUSB_PIO_ONLY is set.


Yea... so according to the datasheet there is no DMA support, or at least it 
is not documented in the datasheet's description of the USB core. There is a 
vendor driver for the core which has ifdefs to enable DMA which looks like 
MUSB_DMA_INVENTRA, but I think we never really go that to work too well. So 
the current configuration is to use only PIO.


- Lars

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


[PATCH 5/8] usb: musb: Change end point selection to use new IO access

2014-11-24 Thread Tony Lindgren
This allows the endpoints to work when multiple MUSB glue
layers are built in.

Cc: Fabio Baltieri fabio.balti...@linaro.org
Cc: Lee Jones lee.jo...@linaro.org
Cc: Linus Walleij linus.wall...@linaro.org
Cc: Apelete Seketeli apel...@seketeli.net
Cc: Lars-Peter Clausen l...@metafoo.de
Signed-off-by: Tony Lindgren t...@atomide.com
---
 drivers/usb/musb/am35x.c |  1 +
 drivers/usb/musb/da8xx.c |  1 +
 drivers/usb/musb/jz4740.c|  1 +
 drivers/usb/musb/musb_core.c | 38 +-
 drivers/usb/musb/musb_core.h | 37 +
 drivers/usb/musb/musb_dsps.c |  1 +
 drivers/usb/musb/musb_io.h   |  2 ++
 drivers/usb/musb/musb_regs.h | 11 ---
 drivers/usb/musb/musbhsdma.c |  7 ---
 drivers/usb/musb/tusb6010.c  | 13 +
 drivers/usb/musb/ux500.c |  1 +
 11 files changed, 62 insertions(+), 51 deletions(-)

diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 13d1d77..1ea4a67 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -438,6 +438,7 @@ static void am35x_read_fifo(struct musb_hw_ep *hw_ep, u16 
len, u8 *dst)
 }
 
 static const struct musb_platform_ops am35x_ops = {
+   .quirks = MUSB_INDEXED_EP,
.init   = am35x_musb_init,
.exit   = am35x_musb_exit,
 
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 058775e..c9079c8 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -458,6 +458,7 @@ static int da8xx_musb_exit(struct musb *musb)
 }
 
 static const struct musb_platform_ops da8xx_ops = {
+   .quirks = MUSB_INDEXED_EP,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
index d118729..40e9874 100644
--- a/drivers/usb/musb/jz4740.c
+++ b/drivers/usb/musb/jz4740.c
@@ -106,6 +106,7 @@ static int jz4740_musb_exit(struct musb *musb)
 }
 
 static const struct musb_platform_ops jz4740_musb_ops = {
+   .quirks = MUSB_INDEXED_EP,
.init   = jz4740_musb_init,
.exit   = jz4740_musb_exit,
 };
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 2fbe149..48ddc82 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -229,6 +229,27 @@ static u32 musb_default_fifo_offset(u8 epnum)
return 0x20 + (epnum * 4);
 }
 
+/* flat mapping: each endpoint has its own i/o address */
+static void musb_flat_ep_select(void __iomem *mbase, u8 epnum)
+{
+}
+
+static u32 musb_flat_ep_offset(u8 epnum, u16 offset)
+{
+   return 0x100 + (0x10 * epnum) + offset;
+}
+
+/* indexed mapping: INDEX register controls register bank select */
+static void musb_indexed_ep_select(void __iomem *mbase, u8 epnum)
+{
+   musb_writeb(mbase, MUSB_INDEX, epnum);
+}
+
+static u32 musb_indexed_ep_offset(u8 epnum, u16 offset)
+{
+   return 0x10 + offset;
+}
+
 static u8 musb_default_readb(const void __iomem *addr, unsigned offset)
 {
return __raw_readb(addr + offset);
@@ -1534,7 +1555,7 @@ static int musb_core_init(u16 musb_type, struct musb 
*musb)
}
 #endif
 
-   hw_ep-regs = MUSB_EP_OFFSET(i, 0) + mbase;
+   hw_ep-regs = musb-io.ep_offset(i, 0) + mbase;
hw_ep-target_regs = musb_read_target_reg_base(i, mbase);
hw_ep-rx_reinit = 1;
hw_ep-tx_reinit = 1;
@@ -2004,6 +2025,21 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
if (musb-ops-quirks)
musb-io.quirks = musb-ops-quirks;
 
+   /* At least tusb6010 has it's own offsets.. */
+   if (musb-ops-ep_offset)
+   musb-io.ep_offset = musb-ops-ep_offset;
+   if (musb-ops-ep_select)
+   musb-io.ep_select = musb-ops-ep_select;
+
+   /* ..and some devices use indexed offset or flat offset */
+   if (musb-io.quirks  MUSB_INDEXED_EP) {
+   musb-io.ep_offset = musb_indexed_ep_offset;
+   musb-io.ep_select = musb_indexed_ep_select;
+   } else {
+   musb-io.ep_offset = musb_flat_ep_offset;
+   musb-io.ep_select = musb_flat_ep_select;
+   }
+
if (musb-ops-fifo_offset)
musb-io.fifo_offset = musb-ops-fifo_offset;
else
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 7c7f38c..02f62cb 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -124,41 +124,6 @@ enum musb_g_ep0_state {
 #define OTG_TIME_A_AIDL_BDIS   200 /* min 200 msec */
 #define OTG_TIME_B_ASE0_BRST   100 /* min 3.125 ms */
 
-
-/*** REGISTER ACCESS /
-
-/* Endpoint registers (other than dynfifo setup) can be accessed either
- * directly with the flat model, or after setting up an index register.
- */
-
-#if defined(CONFIG_ARCH_DAVINCI) 

Re: [PATCH 5/8] usb: musb: Change end point selection to use new IO access

2014-11-24 Thread Apelete Seketeli
Hi Tony,

Thanks for the patch.

On Mon, Nov-24-2014 at 11:05:03 AM -0800, Tony Lindgren wrote:
 This allows the endpoints to work when multiple MUSB glue
 layers are built in.

Applied on top of 3.18-rc6 mainline and tested successfully on JZ4740.
Been able to use ethernet-over-usb to access the internet on
device. No issue as far as I'm concerned.

Acked-by: Apelete Seketeli apel...@seketeli.net

 Cc: Fabio Baltieri fabio.balti...@linaro.org
 Cc: Lee Jones lee.jo...@linaro.org
 Cc: Linus Walleij linus.wall...@linaro.org
 Cc: Apelete Seketeli apel...@seketeli.net
 Cc: Lars-Peter Clausen l...@metafoo.de
 Signed-off-by: Tony Lindgren t...@atomide.com
 ---
  drivers/usb/musb/am35x.c |  1 +
  drivers/usb/musb/da8xx.c |  1 +
  drivers/usb/musb/jz4740.c|  1 +
  drivers/usb/musb/musb_core.c | 38 +-
  drivers/usb/musb/musb_core.h | 37 +
  drivers/usb/musb/musb_dsps.c |  1 +
  drivers/usb/musb/musb_io.h   |  2 ++
  drivers/usb/musb/musb_regs.h | 11 ---
  drivers/usb/musb/musbhsdma.c |  7 ---
  drivers/usb/musb/tusb6010.c  | 13 +
  drivers/usb/musb/ux500.c |  1 +
  11 files changed, 62 insertions(+), 51 deletions(-)
 
 diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
 index 13d1d77..1ea4a67 100644
 --- a/drivers/usb/musb/am35x.c
 +++ b/drivers/usb/musb/am35x.c
 @@ -438,6 +438,7 @@ static void am35x_read_fifo(struct musb_hw_ep *hw_ep, u16 
 len, u8 *dst)
  }
  
  static const struct musb_platform_ops am35x_ops = {
 + .quirks = MUSB_INDEXED_EP,
   .init   = am35x_musb_init,
   .exit   = am35x_musb_exit,
  
 diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
 index 058775e..c9079c8 100644
 --- a/drivers/usb/musb/da8xx.c
 +++ b/drivers/usb/musb/da8xx.c
 @@ -458,6 +458,7 @@ static int da8xx_musb_exit(struct musb *musb)
  }
  
  static const struct musb_platform_ops da8xx_ops = {
 + .quirks = MUSB_INDEXED_EP,
   .init   = da8xx_musb_init,
   .exit   = da8xx_musb_exit,
  
 diff --git a/drivers/usb/musb/jz4740.c b/drivers/usb/musb/jz4740.c
 index d118729..40e9874 100644
 --- a/drivers/usb/musb/jz4740.c
 +++ b/drivers/usb/musb/jz4740.c
 @@ -106,6 +106,7 @@ static int jz4740_musb_exit(struct musb *musb)
  }
  
  static const struct musb_platform_ops jz4740_musb_ops = {
 + .quirks = MUSB_INDEXED_EP,
   .init   = jz4740_musb_init,
   .exit   = jz4740_musb_exit,
  };
 diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
 index 2fbe149..48ddc82 100644
 --- a/drivers/usb/musb/musb_core.c
 +++ b/drivers/usb/musb/musb_core.c
 @@ -229,6 +229,27 @@ static u32 musb_default_fifo_offset(u8 epnum)
   return 0x20 + (epnum * 4);
  }
  
 +/* flat mapping: each endpoint has its own i/o address */
 +static void musb_flat_ep_select(void __iomem *mbase, u8 epnum)
 +{
 +}
 +
 +static u32 musb_flat_ep_offset(u8 epnum, u16 offset)
 +{
 + return 0x100 + (0x10 * epnum) + offset;
 +}
 +
 +/* indexed mapping: INDEX register controls register bank select */
 +static void musb_indexed_ep_select(void __iomem *mbase, u8 epnum)
 +{
 + musb_writeb(mbase, MUSB_INDEX, epnum);
 +}
 +
 +static u32 musb_indexed_ep_offset(u8 epnum, u16 offset)
 +{
 + return 0x10 + offset;
 +}
 +
  static u8 musb_default_readb(const void __iomem *addr, unsigned offset)
  {
   return __raw_readb(addr + offset);
 @@ -1534,7 +1555,7 @@ static int musb_core_init(u16 musb_type, struct musb 
 *musb)
   }
  #endif
  
 - hw_ep-regs = MUSB_EP_OFFSET(i, 0) + mbase;
 + hw_ep-regs = musb-io.ep_offset(i, 0) + mbase;
   hw_ep-target_regs = musb_read_target_reg_base(i, mbase);
   hw_ep-rx_reinit = 1;
   hw_ep-tx_reinit = 1;
 @@ -2004,6 +2025,21 @@ musb_init_controller(struct device *dev, int nIrq, 
 void __iomem *ctrl)
   if (musb-ops-quirks)
   musb-io.quirks = musb-ops-quirks;
  
 + /* At least tusb6010 has it's own offsets.. */
 + if (musb-ops-ep_offset)
 + musb-io.ep_offset = musb-ops-ep_offset;
 + if (musb-ops-ep_select)
 + musb-io.ep_select = musb-ops-ep_select;
 +
 + /* ..and some devices use indexed offset or flat offset */
 + if (musb-io.quirks  MUSB_INDEXED_EP) {
 + musb-io.ep_offset = musb_indexed_ep_offset;
 + musb-io.ep_select = musb_indexed_ep_select;
 + } else {
 + musb-io.ep_offset = musb_flat_ep_offset;
 + musb-io.ep_select = musb_flat_ep_select;
 + }
 +
   if (musb-ops-fifo_offset)
   musb-io.fifo_offset = musb-ops-fifo_offset;
   else
 diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
 index 7c7f38c..02f62cb 100644
 --- a/drivers/usb/musb/musb_core.h
 +++ b/drivers/usb/musb/musb_core.h
 @@ -124,41 +124,6 @@ enum musb_g_ep0_state {
  #define OTG_TIME_A_AIDL_BDIS 200 

Re: [PATCH 5/8] usb: musb: Change end point selection to use new IO access

2014-11-24 Thread Tony Lindgren
* Apelete Seketeli apel...@seketeli.net [141124 15:40]:
 Hi Tony,
 
 Thanks for the patch.
 
 On Mon, Nov-24-2014 at 11:05:03 AM -0800, Tony Lindgren wrote:
  This allows the endpoints to work when multiple MUSB glue
  layers are built in.
 
 Applied on top of 3.18-rc6 mainline and tested successfully on JZ4740.
 Been able to use ethernet-over-usb to access the internet on
 device. No issue as far as I'm concerned.

Great that's good to hear and thanks for testing.

Doing the DMA patches here right now.. For the DMA, I've set up
JZ4740 to use the MUSB_DMA_INVENTRA option by default, is that OK
or do you have some other DMA hardware on it?

If MUSB_DMA_INVENTRA does not work, and you don't have other DMA
hardware on it, we can pass MUSB_DMA_INVENTRA and leave the DMA
function pointers empty, and then the driver will bail out during
init unless the option for CONFIG_MUSB_PIO_ONLY is set.

Just that I could not figure out if that's the one to use grepping
the *_defconfig files.

Regards,

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