[PATCH v3 4/4] usb: musb: da8xx: Remove duplicated defines

2017-09-20 Thread Alexandre Bailon
There is some registers defined in da8xx.c though they are not used.
These registers are also defined and used in musb_cppi41.c
Remove these defines from da8xx.c.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index df88123274ca..2ec2039eee86 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -50,10 +50,7 @@
 #define DA8XX_USB_CTRL_REG 0x04
 #define DA8XX_USB_STAT_REG 0x08
 #define DA8XX_USB_EMULATION_REG 0x0c
-#define DA8XX_USB_MODE_REG 0x10/* Transparent, CDC, [Generic] RNDIS */
-#define DA8XX_USB_AUTOREQ_REG  0x14
 #define DA8XX_USB_SRP_FIX_TIME_REG 0x18
-#define DA8XX_USB_TEARDOWN_REG 0x1c
 #define DA8XX_USB_INTR_SRC_REG 0x20
 #define DA8XX_USB_INTR_SRC_SET_REG 0x24
 #define DA8XX_USB_INTR_SRC_CLEAR_REG 0x28
-- 
2.13.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 v3 2/4] usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx

2017-09-20 Thread Alexandre Bailon
The way to configure the DMA mode on DA8xx is different from DSPS.
Add a new function to configure DMA mode on DA8xx and use a callback
to call the right function based on the platform.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 40 +---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index d66416a27146..b2b1306c01cf 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,6 +26,7 @@
 
 #define MUSB_DMA_NUM_CHANNELS 15
 
+#define DA8XX_USB_MODE 0x10
 #define DA8XX_USB_AUTOREQ  0x14
 #define DA8XX_USB_TEARDOWN 0x1c
 
@@ -41,6 +42,9 @@ struct cppi41_dma_controller {
 
u32 tdown_reg;
u32 autoreq_reg;
+
+   void (*set_dma_mode)(struct cppi41_dma_channel *cppi41_channel,
+unsigned int mode);
 };
 
 static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -355,6 +359,32 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel 
*cppi41_channel,
}
 }
 
+static void da8xx_set_dma_mode(struct cppi41_dma_channel *cppi41_channel,
+   unsigned int mode)
+{
+   struct cppi41_dma_controller *controller = cppi41_channel->controller;
+   struct musb *musb = controller->controller.musb;
+   unsigned int shift;
+   u32 port;
+   u32 new_mode;
+   u32 old_mode;
+
+   old_mode = controller->tx_mode;
+   port = cppi41_channel->port_num;
+
+   shift = (port - 1) * 4;
+   if (!cppi41_channel->is_tx)
+   shift += 16;
+   new_mode = old_mode & ~(3 << shift);
+   new_mode |= mode << shift;
+
+   if (new_mode == old_mode)
+   return;
+   controller->tx_mode = new_mode;
+   musb_writel(musb->ctrl_base, DA8XX_USB_MODE, new_mode);
+}
+
+
 static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel,
unsigned mode)
 {
@@ -379,6 +409,7 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
dma_addr_t dma_addr, u32 len)
 {
struct cppi41_dma_channel *cppi41_channel = channel->private_data;
+   struct cppi41_dma_controller *controller = cppi41_channel->controller;
struct dma_chan *dc = cppi41_channel->dc;
struct dma_async_tx_descriptor *dma_desc;
enum dma_transfer_direction direction;
@@ -404,7 +435,7 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
musb_writel(musb->ctrl_base,
RNDIS_REG(cppi41_channel->port_num), len);
/* gen rndis */
-   cppi41_set_dma_mode(cppi41_channel,
+   controller->set_dma_mode(cppi41_channel,
EP_MODE_DMA_GEN_RNDIS);
 
/* auto req */
@@ -413,14 +444,15 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
} else {
musb_writel(musb->ctrl_base,
RNDIS_REG(cppi41_channel->port_num), 0);
-   cppi41_set_dma_mode(cppi41_channel,
+   controller->set_dma_mode(cppi41_channel,
EP_MODE_DMA_TRANSPARENT);
cppi41_set_autoreq_mode(cppi41_channel,
EP_MODE_AUTOREQ_NONE);
}
} else {
/* fallback mode */
-   cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT);
+   controller->set_dma_mode(cppi41_channel,
+   EP_MODE_DMA_TRANSPARENT);
cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE);
len = min_t(u32, packet_sz, len);
}
@@ -737,9 +769,11 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
if (musb->io.quirks & MUSB_DA8XX) {
controller->tdown_reg = DA8XX_USB_TEARDOWN;
controller->autoreq_reg = DA8XX_USB_AUTOREQ;
+   controller->set_dma_mode = da8xx_set_dma_mode;
} else {
controller->tdown_reg = USB_TDOWN;
controller->autoreq_reg = USB_CTRL_AUTOREQ;
+   controller->set_dma_mode = cppi41_set_dma_mode;
}
 
ret = cppi41_dma_controller_start(controller);
-- 
2.13.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 v3 3/4] usb: musb: musb_cppi41: Configure the number of channels for DA8xx

2017-09-20 Thread Alexandre Bailon
Currently, the number of channels is set to 15 but in the case of DA8xx,
the number of channels is 4.
Update the driver to configure the number of channels at runtime.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 31 ++-
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index b2b1306c01cf..1ec0a4947b6b 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -30,10 +30,12 @@
 #define DA8XX_USB_AUTOREQ  0x14
 #define DA8XX_USB_TEARDOWN 0x1c
 
+#define DA8XX_DMA_NUM_CHANNELS 4
+
 struct cppi41_dma_controller {
struct dma_controller controller;
-   struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS];
-   struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS];
+   struct cppi41_dma_channel *rx_channel;
+   struct cppi41_dma_channel *tx_channel;
struct hrtimer early_tx;
struct list_head early_tx_list;
u32 rx_mode;
@@ -45,6 +47,7 @@ struct cppi41_dma_controller {
 
void (*set_dma_mode)(struct cppi41_dma_channel *cppi41_channel,
 unsigned int mode);
+   u8 num_channels;
 };
 
 static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -483,7 +486,7 @@ static struct dma_channel 
*cppi41_dma_channel_allocate(struct dma_controller *c,
struct cppi41_dma_channel *cppi41_channel = NULL;
u8 ch_num = hw_ep->epnum - 1;
 
-   if (ch_num >= MUSB_DMA_NUM_CHANNELS)
+   if (ch_num >= controller->num_channels)
return NULL;
 
if (is_tx)
@@ -643,7 +646,7 @@ static void cppi41_release_all_dma_chans(struct 
cppi41_dma_controller *ctrl)
struct dma_chan *dc;
int i;
 
-   for (i = 0; i < MUSB_DMA_NUM_CHANNELS; i++) {
+   for (i = 0; i < ctrl->num_channels; i++) {
dc = ctrl->tx_channel[i].dc;
if (dc)
dma_release_channel(dc);
@@ -695,7 +698,7 @@ static int cppi41_dma_controller_start(struct 
cppi41_dma_controller *controller)
goto err;
 
ret = -EINVAL;
-   if (port > MUSB_DMA_NUM_CHANNELS || !port)
+   if (port > controller->num_channels || !port)
goto err;
if (is_tx)
cppi41_channel = &controller->tx_channel[port - 1];
@@ -736,6 +739,8 @@ void cppi41_dma_controller_destroy(struct dma_controller *c)
 
hrtimer_cancel(&controller->early_tx);
cppi41_dma_controller_stop(controller);
+   kfree(controller->rx_channel);
+   kfree(controller->tx_channel);
kfree(controller);
 }
 EXPORT_SYMBOL_GPL(cppi41_dma_controller_destroy);
@@ -744,6 +749,7 @@ struct dma_controller *
 cppi41_dma_controller_create(struct musb *musb, void __iomem *base)
 {
struct cppi41_dma_controller *controller;
+   int channel_size;
int ret = 0;
 
if (!musb->controller->parent->of_node) {
@@ -770,18 +776,33 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
controller->tdown_reg = DA8XX_USB_TEARDOWN;
controller->autoreq_reg = DA8XX_USB_AUTOREQ;
controller->set_dma_mode = da8xx_set_dma_mode;
+   controller->num_channels = DA8XX_DMA_NUM_CHANNELS;
} else {
controller->tdown_reg = USB_TDOWN;
controller->autoreq_reg = USB_CTRL_AUTOREQ;
controller->set_dma_mode = cppi41_set_dma_mode;
+   controller->num_channels = MUSB_DMA_NUM_CHANNELS;
}
 
+   channel_size = controller->num_channels *
+   sizeof(struct cppi41_dma_channel);
+   controller->rx_channel = kzalloc(channel_size, GFP_KERNEL);
+   if (!controller->rx_channel)
+   goto rx_channel_alloc_fail;
+   controller->tx_channel = kzalloc(channel_size, GFP_KERNEL);
+   if (!controller->tx_channel)
+   goto tx_channel_alloc_fail;
+
ret = cppi41_dma_controller_start(controller);
if (ret)
goto plat_get_fail;
return &controller->controller;
 
 plat_get_fail:
+   kfree(controller->tx_channel);
+tx_channel_alloc_fail:
+   kfree(controller->rx_channel);
+rx_channel_alloc_fail:
kfree(controller);
 kzalloc_fail:
if (ret == -EPROBE_DEFER)
-- 
2.13.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 v3 1/4] usb: musb: musb_cppi41: Fix the address of teardown and autoreq registers

2017-09-20 Thread Alexandre Bailon
The DA8xx and DSPS platforms don't use the same address for few registers.
On Da8xx, this is causing some issues (e.g. teardown that doesn't work).
Configure the address of the register during the init and use them instead
of constants.

Reported-by: nsek...@ti.com
Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index ba255280a624..d66416a27146 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,6 +26,9 @@
 
 #define MUSB_DMA_NUM_CHANNELS 15
 
+#define DA8XX_USB_AUTOREQ  0x14
+#define DA8XX_USB_TEARDOWN 0x1c
+
 struct cppi41_dma_controller {
struct dma_controller controller;
struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS];
@@ -35,6 +38,9 @@ struct cppi41_dma_controller {
u32 rx_mode;
u32 tx_mode;
u32 auto_req;
+
+   u32 tdown_reg;
+   u32 autoreq_reg;
 };
 
 static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -364,8 +370,8 @@ static void cppi41_set_autoreq_mode(struct 
cppi41_dma_channel *cppi41_channel,
if (new_mode == old_mode)
return;
controller->auto_req = new_mode;
-   musb_writel(controller->controller.musb->ctrl_base, USB_CTRL_AUTOREQ,
-   new_mode);
+   musb_writel(controller->controller.musb->ctrl_base,
+   controller->autoreq_reg, new_mode);
 }
 
 static bool cppi41_configure_channel(struct dma_channel *channel,
@@ -581,12 +587,13 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
 
do {
if (is_tx)
-   musb_writel(musb->ctrl_base, USB_TDOWN, tdbit);
+   musb_writel(musb->ctrl_base, controller->tdown_reg,
+   tdbit);
ret = dmaengine_terminate_all(cppi41_channel->dc);
} while (ret == -EAGAIN);
 
if (is_tx) {
-   musb_writel(musb->ctrl_base, USB_TDOWN, tdbit);
+   musb_writel(musb->ctrl_base, controller->tdown_reg, tdbit);
 
csr = musb_readw(epio, MUSB_TXCSR);
if (csr & MUSB_TXCSR_TXPKTRDY) {
@@ -727,6 +734,14 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
controller->controller.is_compatible = cppi41_is_compatible;
controller->controller.musb = musb;
 
+   if (musb->io.quirks & MUSB_DA8XX) {
+   controller->tdown_reg = DA8XX_USB_TEARDOWN;
+   controller->autoreq_reg = DA8XX_USB_AUTOREQ;
+   } else {
+   controller->tdown_reg = USB_TDOWN;
+   controller->autoreq_reg = USB_CTRL_AUTOREQ;
+   }
+
ret = cppi41_dma_controller_start(controller);
if (ret)
goto plat_get_fail;
-- 
2.13.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 0/4] Update MUSB CPPI 4.1 driver to correctly manage the DA8xx

2017-09-20 Thread Alexandre Bailon
A couple of weeks ago, Sekhar reported a warning issue happening in
CPPI 4.1. The teardown sequence was not correctly programmed.
The caused was a couple of difference between the DSPS and the DA8xx.
These differences are the way to program the autoreq, the teardown and
the DMA mode.
This series intends to fix the teardown and to correctly program
the DMA mode.

This series has been roughly tested.
I have only tried it on the DA580 LCK and the BeagleBone Black.
Only the device mode (msc and ecm) have been tested.

Changes in v2:
 - Fix some typo (indentation and symbols name)
 - Limit the number of channels to 4 for DA8xx
 - Remove duplicated defines

Changes in v3:
 - Fix a stupid type (two NULL check reversed)

Alexandre Bailon (4):
  usb: musb: musb_cppi41: Fix the address of teardown and autoreq
registers
  usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx
  usb: musb: musb_cppi41: Configure the number of channels for DA8xx
  usb: musb: da8xx: Remove duplicated defines

 drivers/usb/musb/da8xx.c   |  3 --
 drivers/usb/musb/musb_cppi41.c | 94 --
 2 files changed, 82 insertions(+), 15 deletions(-)

-- 
2.13.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 v2 3/4] usb: musb: musb_cppi41: Configure the number of channels for DA8xx

2017-09-20 Thread Alexandre Bailon
On 09/20/2017 11:21 AM, Sergei Shtylyov wrote:
> Hello!
> 
> On 9/20/2017 10:35 AM, Alexandre Bailon wrote:
> 
>> Currently, the number of channels is set to 15 but in the case of DA8xx,
>> the number of channels is 4.
>> Update the driver to configure the number of channels at runtime.
>>
>> Signed-off-by: Alexandre Bailon 
>> ---
>>   drivers/usb/musb/musb_cppi41.c | 31 ++-
>>   1 file changed, 26 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/usb/musb/musb_cppi41.c
>> b/drivers/usb/musb/musb_cppi41.c
>> index b2b1306c01cf..2d1468cccae0 100644
>> --- a/drivers/usb/musb/musb_cppi41.c
>> +++ b/drivers/usb/musb/musb_cppi41.c
> [...]
>> @@ -770,18 +776,33 @@ cppi41_dma_controller_create(struct musb *musb,
>> void __iomem *base)
>>   controller->tdown_reg = DA8XX_USB_TEARDOWN;
>>   controller->autoreq_reg = DA8XX_USB_AUTOREQ;
>>   controller->set_dma_mode = da8xx_set_dma_mode;
>> +controller->num_channels = DA8XX_DMA_NUM_CHANNELS;
>>   } else {
>>   controller->tdown_reg = USB_TDOWN;
>>   controller->autoreq_reg = USB_CTRL_AUTOREQ;
>>   controller->set_dma_mode = cppi41_set_dma_mode;
>> +controller->num_channels = MUSB_DMA_NUM_CHANNELS;
>>   }
>>   +channel_size = controller->num_channels *
>> +sizeof(struct cppi41_dma_channel);
>> +controller->rx_channel = kzalloc(channel_size, GFP_KERNEL);
>> +if (controller->rx_channel)
> 
>How can this work? The NULL check is reversed.
Indeed! That's a good question! I have tested the series before to send
it but I could not explain why it have worked.
Anyway, I will fix it.

Best Regards,
Alexandre
--
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 2/4] usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx

2017-09-20 Thread Alexandre Bailon
The way to configure the DMA mode on DA8xx is different from DSPS.
Add a new function to configure DMA mode on DA8xx and use a callback
to call the right function based on the platform.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 40 +---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index d66416a27146..b2b1306c01cf 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,6 +26,7 @@
 
 #define MUSB_DMA_NUM_CHANNELS 15
 
+#define DA8XX_USB_MODE 0x10
 #define DA8XX_USB_AUTOREQ  0x14
 #define DA8XX_USB_TEARDOWN 0x1c
 
@@ -41,6 +42,9 @@ struct cppi41_dma_controller {
 
u32 tdown_reg;
u32 autoreq_reg;
+
+   void (*set_dma_mode)(struct cppi41_dma_channel *cppi41_channel,
+unsigned int mode);
 };
 
 static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -355,6 +359,32 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel 
*cppi41_channel,
}
 }
 
+static void da8xx_set_dma_mode(struct cppi41_dma_channel *cppi41_channel,
+   unsigned int mode)
+{
+   struct cppi41_dma_controller *controller = cppi41_channel->controller;
+   struct musb *musb = controller->controller.musb;
+   unsigned int shift;
+   u32 port;
+   u32 new_mode;
+   u32 old_mode;
+
+   old_mode = controller->tx_mode;
+   port = cppi41_channel->port_num;
+
+   shift = (port - 1) * 4;
+   if (!cppi41_channel->is_tx)
+   shift += 16;
+   new_mode = old_mode & ~(3 << shift);
+   new_mode |= mode << shift;
+
+   if (new_mode == old_mode)
+   return;
+   controller->tx_mode = new_mode;
+   musb_writel(musb->ctrl_base, DA8XX_USB_MODE, new_mode);
+}
+
+
 static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel,
unsigned mode)
 {
@@ -379,6 +409,7 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
dma_addr_t dma_addr, u32 len)
 {
struct cppi41_dma_channel *cppi41_channel = channel->private_data;
+   struct cppi41_dma_controller *controller = cppi41_channel->controller;
struct dma_chan *dc = cppi41_channel->dc;
struct dma_async_tx_descriptor *dma_desc;
enum dma_transfer_direction direction;
@@ -404,7 +435,7 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
musb_writel(musb->ctrl_base,
RNDIS_REG(cppi41_channel->port_num), len);
/* gen rndis */
-   cppi41_set_dma_mode(cppi41_channel,
+   controller->set_dma_mode(cppi41_channel,
EP_MODE_DMA_GEN_RNDIS);
 
/* auto req */
@@ -413,14 +444,15 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
} else {
musb_writel(musb->ctrl_base,
RNDIS_REG(cppi41_channel->port_num), 0);
-   cppi41_set_dma_mode(cppi41_channel,
+   controller->set_dma_mode(cppi41_channel,
EP_MODE_DMA_TRANSPARENT);
cppi41_set_autoreq_mode(cppi41_channel,
EP_MODE_AUTOREQ_NONE);
}
} else {
/* fallback mode */
-   cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT);
+   controller->set_dma_mode(cppi41_channel,
+   EP_MODE_DMA_TRANSPARENT);
cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE);
len = min_t(u32, packet_sz, len);
}
@@ -737,9 +769,11 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
if (musb->io.quirks & MUSB_DA8XX) {
controller->tdown_reg = DA8XX_USB_TEARDOWN;
controller->autoreq_reg = DA8XX_USB_AUTOREQ;
+   controller->set_dma_mode = da8xx_set_dma_mode;
} else {
controller->tdown_reg = USB_TDOWN;
controller->autoreq_reg = USB_CTRL_AUTOREQ;
+   controller->set_dma_mode = cppi41_set_dma_mode;
}
 
ret = cppi41_dma_controller_start(controller);
-- 
2.13.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 4/4] usb: musb: da8xx: Remove duplicated defines

2017-09-20 Thread Alexandre Bailon
There is some registers defined in da8xx.c though they are not used.
These registers are also defined and used in musb_cppi41.c
Remove these defines from da8xx.c.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index df88123274ca..2ec2039eee86 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -50,10 +50,7 @@
 #define DA8XX_USB_CTRL_REG 0x04
 #define DA8XX_USB_STAT_REG 0x08
 #define DA8XX_USB_EMULATION_REG 0x0c
-#define DA8XX_USB_MODE_REG 0x10/* Transparent, CDC, [Generic] RNDIS */
-#define DA8XX_USB_AUTOREQ_REG  0x14
 #define DA8XX_USB_SRP_FIX_TIME_REG 0x18
-#define DA8XX_USB_TEARDOWN_REG 0x1c
 #define DA8XX_USB_INTR_SRC_REG 0x20
 #define DA8XX_USB_INTR_SRC_SET_REG 0x24
 #define DA8XX_USB_INTR_SRC_CLEAR_REG 0x28
-- 
2.13.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 3/4] usb: musb: musb_cppi41: Configure the number of channels for DA8xx

2017-09-20 Thread Alexandre Bailon
Currently, the number of channels is set to 15 but in the case of DA8xx,
the number of channels is 4.
Update the driver to configure the number of channels at runtime.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 31 ++-
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index b2b1306c01cf..2d1468cccae0 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -30,10 +30,12 @@
 #define DA8XX_USB_AUTOREQ  0x14
 #define DA8XX_USB_TEARDOWN 0x1c
 
+#define DA8XX_DMA_NUM_CHANNELS 4
+
 struct cppi41_dma_controller {
struct dma_controller controller;
-   struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS];
-   struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS];
+   struct cppi41_dma_channel *rx_channel;
+   struct cppi41_dma_channel *tx_channel;
struct hrtimer early_tx;
struct list_head early_tx_list;
u32 rx_mode;
@@ -45,6 +47,7 @@ struct cppi41_dma_controller {
 
void (*set_dma_mode)(struct cppi41_dma_channel *cppi41_channel,
 unsigned int mode);
+   u8 num_channels;
 };
 
 static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -483,7 +486,7 @@ static struct dma_channel 
*cppi41_dma_channel_allocate(struct dma_controller *c,
struct cppi41_dma_channel *cppi41_channel = NULL;
u8 ch_num = hw_ep->epnum - 1;
 
-   if (ch_num >= MUSB_DMA_NUM_CHANNELS)
+   if (ch_num >= controller->num_channels)
return NULL;
 
if (is_tx)
@@ -643,7 +646,7 @@ static void cppi41_release_all_dma_chans(struct 
cppi41_dma_controller *ctrl)
struct dma_chan *dc;
int i;
 
-   for (i = 0; i < MUSB_DMA_NUM_CHANNELS; i++) {
+   for (i = 0; i < ctrl->num_channels; i++) {
dc = ctrl->tx_channel[i].dc;
if (dc)
dma_release_channel(dc);
@@ -695,7 +698,7 @@ static int cppi41_dma_controller_start(struct 
cppi41_dma_controller *controller)
goto err;
 
ret = -EINVAL;
-   if (port > MUSB_DMA_NUM_CHANNELS || !port)
+   if (port > controller->num_channels || !port)
goto err;
if (is_tx)
cppi41_channel = &controller->tx_channel[port - 1];
@@ -736,6 +739,8 @@ void cppi41_dma_controller_destroy(struct dma_controller *c)
 
hrtimer_cancel(&controller->early_tx);
cppi41_dma_controller_stop(controller);
+   kfree(controller->rx_channel);
+   kfree(controller->tx_channel);
kfree(controller);
 }
 EXPORT_SYMBOL_GPL(cppi41_dma_controller_destroy);
@@ -744,6 +749,7 @@ struct dma_controller *
 cppi41_dma_controller_create(struct musb *musb, void __iomem *base)
 {
struct cppi41_dma_controller *controller;
+   int channel_size;
int ret = 0;
 
if (!musb->controller->parent->of_node) {
@@ -770,18 +776,33 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
controller->tdown_reg = DA8XX_USB_TEARDOWN;
controller->autoreq_reg = DA8XX_USB_AUTOREQ;
controller->set_dma_mode = da8xx_set_dma_mode;
+   controller->num_channels = DA8XX_DMA_NUM_CHANNELS;
} else {
controller->tdown_reg = USB_TDOWN;
controller->autoreq_reg = USB_CTRL_AUTOREQ;
controller->set_dma_mode = cppi41_set_dma_mode;
+   controller->num_channels = MUSB_DMA_NUM_CHANNELS;
}
 
+   channel_size = controller->num_channels *
+   sizeof(struct cppi41_dma_channel);
+   controller->rx_channel = kzalloc(channel_size, GFP_KERNEL);
+   if (controller->rx_channel)
+   goto rx_channel_alloc_fail;
+   controller->tx_channel = kzalloc(channel_size, GFP_KERNEL);
+   if (controller->tx_channel)
+   goto tx_channel_alloc_fail;
+
ret = cppi41_dma_controller_start(controller);
if (ret)
goto plat_get_fail;
return &controller->controller;
 
 plat_get_fail:
+   kfree(controller->tx_channel);
+tx_channel_alloc_fail:
+   kfree(controller->rx_channel);
+rx_channel_alloc_fail:
kfree(controller);
 kzalloc_fail:
if (ret == -EPROBE_DEFER)
-- 
2.13.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 1/4] usb: musb: musb_cppi41: Fix the address of teardown and autoreq registers

2017-09-20 Thread Alexandre Bailon
The DA8xx and DSPS platforms don't use the same address for few registers.
On Da8xx, this is causing some issues (e.g. teardown that doesn't work).
Configure the address of the register during the init and use them instead
of constants.

Reported-by: nsek...@ti.com
Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index ba255280a624..d66416a27146 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,6 +26,9 @@
 
 #define MUSB_DMA_NUM_CHANNELS 15
 
+#define DA8XX_USB_AUTOREQ  0x14
+#define DA8XX_USB_TEARDOWN 0x1c
+
 struct cppi41_dma_controller {
struct dma_controller controller;
struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS];
@@ -35,6 +38,9 @@ struct cppi41_dma_controller {
u32 rx_mode;
u32 tx_mode;
u32 auto_req;
+
+   u32 tdown_reg;
+   u32 autoreq_reg;
 };
 
 static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -364,8 +370,8 @@ static void cppi41_set_autoreq_mode(struct 
cppi41_dma_channel *cppi41_channel,
if (new_mode == old_mode)
return;
controller->auto_req = new_mode;
-   musb_writel(controller->controller.musb->ctrl_base, USB_CTRL_AUTOREQ,
-   new_mode);
+   musb_writel(controller->controller.musb->ctrl_base,
+   controller->autoreq_reg, new_mode);
 }
 
 static bool cppi41_configure_channel(struct dma_channel *channel,
@@ -581,12 +587,13 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
 
do {
if (is_tx)
-   musb_writel(musb->ctrl_base, USB_TDOWN, tdbit);
+   musb_writel(musb->ctrl_base, controller->tdown_reg,
+   tdbit);
ret = dmaengine_terminate_all(cppi41_channel->dc);
} while (ret == -EAGAIN);
 
if (is_tx) {
-   musb_writel(musb->ctrl_base, USB_TDOWN, tdbit);
+   musb_writel(musb->ctrl_base, controller->tdown_reg, tdbit);
 
csr = musb_readw(epio, MUSB_TXCSR);
if (csr & MUSB_TXCSR_TXPKTRDY) {
@@ -727,6 +734,14 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
controller->controller.is_compatible = cppi41_is_compatible;
controller->controller.musb = musb;
 
+   if (musb->io.quirks & MUSB_DA8XX) {
+   controller->tdown_reg = DA8XX_USB_TEARDOWN;
+   controller->autoreq_reg = DA8XX_USB_AUTOREQ;
+   } else {
+   controller->tdown_reg = USB_TDOWN;
+   controller->autoreq_reg = USB_CTRL_AUTOREQ;
+   }
+
ret = cppi41_dma_controller_start(controller);
if (ret)
goto plat_get_fail;
-- 
2.13.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 0/4] Update MUSB CPPI 4.1 driver to correctly manage the DA8xx

2017-09-20 Thread Alexandre Bailon
A couple of weeks ago, Sekhar reported a warning issue happening in
CPPI 4.1. The teardown sequence was not correctly programmed.
The caused was a couple of difference between the DSPS and the DA8xx.
These differences are the way to program the autoreq, the teardown and
the DMA mode.
This series intends to fix the teardown and to correctly program
the DMA mode.

This series has been roughly tested.
I have only tried it on the DA580 LCK and the BeagleBone Black.
Only the device mode (msc and ecm) have been tested.

Changes in v2:
 - Fix some typo (indentation and symbols name)
 - Limit the number of channels to 4 for DA8xx
 - Remove duplicated defines

Alexandre Bailon (4):
  usb: musb: musb_cppi41: Fix the address of teardown and autoreq
registers
  usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx
  usb: musb: musb_cppi41: Configure the number of channels for DA8xx
  usb: musb: da8xx: Remove duplicated defines

 drivers/usb/musb/da8xx.c   |  3 --
 drivers/usb/musb/musb_cppi41.c | 94 --
 2 files changed, 82 insertions(+), 15 deletions(-)

-- 
2.13.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 1/2] usb: musb: musb_cppi41: Fix the address of teardown and autoreq registers

2017-09-11 Thread Alexandre Bailon
On 08/15/2017 12:12 PM, Sergei Shtylyov wrote:
> Hello!
>
> On 8/13/2017 3:04 PM, Alexandre Bailon wrote:
>
>> The DA8xx and DSPS platforms don't use the same address for few
>> registers.
>> On Da8xx, this is causing some issues (e.g. teardown that doesn't work).
>> Configure the address of the register during the init and use them
>> instead
>> of constants.
>>
>> Reported-by: nsek...@ti.com
>> Signed-off-by: Alexandre Bailon 
>> ---
>>   drivers/usb/musb/musb_cppi41.c | 23 +++
>>   1 file changed, 19 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/musb/musb_cppi41.c
>> b/drivers/usb/musb/musb_cppi41.c
>> index ba255280a624..dbff0e0a4ff5 100644
>> --- a/drivers/usb/musb/musb_cppi41.c
>> +++ b/drivers/usb/musb/musb_cppi41.c
>> @@ -26,6 +26,9 @@
>> #define MUSB_DMA_NUM_CHANNELS 15
>>   +#define DA8XX_USB_AUTOREQ_REG0x14
>> +#define DA8XX_USB_TEARDOWN_REG0x1c
>
>Why these _REG suffixes suddenly?
I took these defines in da8xx.c.
Actually, I think I should make a third patch to remove them from
da8xx.c because they are not even used.
>
> [...]
>
>Other than that looks sane. Need my ACK?
I don't know if that is needed but I guess it would be appreciated.

Best Regards,
Alexandre
>
> WBR, Sergei

--
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: musb: musb_cppi41: Fix the address of teardown and autoreq registers

2017-09-11 Thread Alexandre Bailon
Hi Bin, Sekhar
On 09/07/2017 07:16 PM, Bin Liu wrote:
> On Mon, Sep 04, 2017 at 06:32:11PM +0530, Sekhar Nori wrote:
>> On Monday 14 August 2017 07:06 PM, Sekhar Nori wrote:
>>> On Monday 14 August 2017 07:01 PM, Sekhar Nori wrote:
>>>> Hi,
>>>>
>>>> On Sunday 13 August 2017 05:34 PM, Alexandre Bailon wrote:
>>>>> The DA8xx and DSPS platforms don't use the same address for few registers.
>>>>> On Da8xx, this is causing some issues (e.g. teardown that doesn't work).
>>>>> Configure the address of the register during the init and use them instead
>>>>> of constants.
>>>>>
>>>>> Reported-by: nsek...@ti.com
>>> Reported-by: Sekhar Nori 
>> Tested-by: Sekhar Nori 
>>
>> Hi Bin,
>>
>> Do you have any additional comments on this series or are you waiting
>> for v2 to be posted?
> I don't have other comments, just am waiting for v2.
My apologize. I was in vacation. I will send the v2 soon.

Best Regards,
Alexandre
>
> Regards,
> -Bin.
>

--
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: musb: musb_cppi41: Fix the address of teardown and autoreq registers

2017-08-13 Thread Alexandre Bailon
The DA8xx and DSPS platforms don't use the same address for few registers.
On Da8xx, this is causing some issues (e.g. teardown that doesn't work).
Configure the address of the register during the init and use them instead
of constants.

Reported-by: nsek...@ti.com
Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index ba255280a624..dbff0e0a4ff5 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,6 +26,9 @@
 
 #define MUSB_DMA_NUM_CHANNELS 15
 
+#define DA8XX_USB_AUTOREQ_REG  0x14
+#define DA8XX_USB_TEARDOWN_REG 0x1c
+
 struct cppi41_dma_controller {
struct dma_controller controller;
struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS];
@@ -35,6 +38,9 @@ struct cppi41_dma_controller {
u32 rx_mode;
u32 tx_mode;
u32 auto_req;
+
+   u32 tdown_reg;
+   u32 autoreq_reg;
 };
 
 static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -364,8 +370,8 @@ static void cppi41_set_autoreq_mode(struct 
cppi41_dma_channel *cppi41_channel,
if (new_mode == old_mode)
return;
controller->auto_req = new_mode;
-   musb_writel(controller->controller.musb->ctrl_base, USB_CTRL_AUTOREQ,
-   new_mode);
+   musb_writel(controller->controller.musb->ctrl_base,
+   controller->autoreq_reg, new_mode);
 }
 
 static bool cppi41_configure_channel(struct dma_channel *channel,
@@ -581,12 +587,13 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
 
do {
if (is_tx)
-   musb_writel(musb->ctrl_base, USB_TDOWN, tdbit);
+   musb_writel(musb->ctrl_base, controller->tdown_reg,
+   tdbit);
ret = dmaengine_terminate_all(cppi41_channel->dc);
} while (ret == -EAGAIN);
 
if (is_tx) {
-   musb_writel(musb->ctrl_base, USB_TDOWN, tdbit);
+   musb_writel(musb->ctrl_base, controller->tdown_reg, tdbit);
 
csr = musb_readw(epio, MUSB_TXCSR);
if (csr & MUSB_TXCSR_TXPKTRDY) {
@@ -727,6 +734,14 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
controller->controller.is_compatible = cppi41_is_compatible;
controller->controller.musb = musb;
 
+   if (musb->io.quirks & MUSB_DA8XX) {
+   controller->tdown_reg = DA8XX_USB_TEARDOWN_REG;
+   controller->autoreq_reg = DA8XX_USB_AUTOREQ_REG;
+   } else {
+   controller->tdown_reg = USB_TDOWN;
+   controller->autoreq_reg = USB_CTRL_AUTOREQ;
+   }
+
ret = cppi41_dma_controller_start(controller);
if (ret)
goto plat_get_fail;
-- 
2.13.0

--
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: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx

2017-08-13 Thread Alexandre Bailon
The way to configure the DMA mode on DA8xx is different from DSPS.
Add a new function to configure DMA mode on DA8xx and use a callback
to call the right function based on the platform.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 40 +---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index dbff0e0a4ff5..7284ec7ecff7 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -26,6 +26,7 @@
 
 #define MUSB_DMA_NUM_CHANNELS 15
 
+#define DA8XX_USB_MODE_REG 0x10
 #define DA8XX_USB_AUTOREQ_REG  0x14
 #define DA8XX_USB_TEARDOWN_REG 0x1c
 
@@ -41,6 +42,9 @@ struct cppi41_dma_controller {
 
u32 tdown_reg;
u32 autoreq_reg;
+
+   void (*set_dma_mode)(struct cppi41_dma_channel *cppi41_channel,
+unsigned int mode);
 };
 
 static void save_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
@@ -355,6 +359,32 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel 
*cppi41_channel,
}
 }
 
+static void da8xx_set_dma_mode(struct cppi41_dma_channel *cppi41_channel,
+   unsigned int mode)
+{
+   struct cppi41_dma_controller *controller = cppi41_channel->controller;
+   struct musb *musb = controller->controller.musb;
+   unsigned int shift;
+   u32 port;
+   u32 new_mode;
+   u32 old_mode;
+
+   old_mode = controller->tx_mode;
+   port = cppi41_channel->port_num;
+
+   shift = (port - 1) * 4;
+   if (!cppi41_channel->is_tx)
+   shift += 16;
+   new_mode = old_mode & ~(3 << shift);
+   new_mode |= mode << shift;
+
+   if (new_mode == old_mode)
+   return;
+   controller->tx_mode = new_mode;
+   musb_writel(musb->ctrl_base, DA8XX_USB_MODE_REG, new_mode);
+}
+
+
 static void cppi41_set_autoreq_mode(struct cppi41_dma_channel *cppi41_channel,
unsigned mode)
 {
@@ -379,6 +409,7 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
dma_addr_t dma_addr, u32 len)
 {
struct cppi41_dma_channel *cppi41_channel = channel->private_data;
+   struct cppi41_dma_controller *controller = cppi41_channel->controller;
struct dma_chan *dc = cppi41_channel->dc;
struct dma_async_tx_descriptor *dma_desc;
enum dma_transfer_direction direction;
@@ -404,7 +435,7 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
musb_writel(musb->ctrl_base,
RNDIS_REG(cppi41_channel->port_num), len);
/* gen rndis */
-   cppi41_set_dma_mode(cppi41_channel,
+   controller->set_dma_mode(cppi41_channel,
EP_MODE_DMA_GEN_RNDIS);
 
/* auto req */
@@ -413,14 +444,15 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
} else {
musb_writel(musb->ctrl_base,
RNDIS_REG(cppi41_channel->port_num), 0);
-   cppi41_set_dma_mode(cppi41_channel,
+   controller->set_dma_mode(cppi41_channel,
EP_MODE_DMA_TRANSPARENT);
cppi41_set_autoreq_mode(cppi41_channel,
EP_MODE_AUTOREQ_NONE);
}
} else {
/* fallback mode */
-   cppi41_set_dma_mode(cppi41_channel, EP_MODE_DMA_TRANSPARENT);
+   controller->set_dma_mode(cppi41_channel,
+   EP_MODE_DMA_TRANSPARENT);
cppi41_set_autoreq_mode(cppi41_channel, EP_MODE_AUTOREQ_NONE);
len = min_t(u32, packet_sz, len);
}
@@ -737,9 +769,11 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
if (musb->io.quirks & MUSB_DA8XX) {
controller->tdown_reg = DA8XX_USB_TEARDOWN_REG;
controller->autoreq_reg = DA8XX_USB_AUTOREQ_REG;
+   controller->set_dma_mode = da8xx_set_dma_mode;
} else {
controller->tdown_reg = USB_TDOWN;
controller->autoreq_reg = USB_CTRL_AUTOREQ;
+   controller->set_dma_mode = cppi41_set_dma_mode;
}
 
ret = cppi41_dma_controller_start(controller);
-- 
2.13.0

--
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] Update MUSB CPPI 4.1 driver to correctly manage the DA8xx

2017-08-13 Thread Alexandre Bailon
A couple of weeks ago, Sekhar reported a warning issue happening in
CPPI 4.1. The teardown sequence was not correctly programmed.
The caused was a couple of difference between the DSPS and the DA8xx.
These differences are the way to program the autoreq, the teardown and
the DMA mode.
This series intends to fix the teardown and to correctly program
the DMA mode.

This series has been roughly tested.
I have only tried it on the DA580 LCK and the BeagleBone Black.
Only the device mode (msc and ecm) have been tested.

Alexandre Bailon (2):
  usb: musb: musb_cppi41: Fix the address of teardown and autoreq
registers
  usb: musb: musb_cppi41: Fix cppi41_set_dma_mode() for DA8xx

 drivers/usb/musb/musb_cppi41.c | 63 +-
 1 file changed, 56 insertions(+), 7 deletions(-)

-- 
2.13.0

--
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: Warning dump on OMAP-L138 when g_zero module is removed

2017-08-05 Thread Alexandre Bailon
Hi Sekhar,
On 07/21/2017 05:18 PM, Alexandre Bailon wrote:
> Hi Sekhar,
>
> On 07/10/2017 01:00 PM, Sekhar Nori wrote:
> > On Thursday 06 July 2017 10:43 PM, Alexandre Bailon wrote:
> >> On 06/29/2017 03:50 PM, Sekhar Nori wrote:
> >>> Hi Alexandre, Bin,
> >>>
> >>> With latest linux-next, I see a warning dump when I remove g_zero[1] on
> >>> OMAP-L138 LCDK board. I am building the kernel with davinci_all_defconfig.
> >>>
> >>> It is not present in latest mainline because the warnings are introduced
> >>> with CPPI DMA getting enabled in latest -next.
> >>>
> >>> Subsequent insertion of g_ether leads to a warning too[2], although the
> >>> gadget seems to work (ping test).
> >>>
> >>> Since these are pretty annoying, it will be nice to get rid of them. I
> >>> have not been able to debug any further. But if you have
> >>> ideas/experiments to try, I can do that.
> >
> >> I got a lot of these warnings during development but it was only for the
> >> host mode.
> >> If I remember correctly, the cause was a race between the teardown
> >> function and the interrupt handler.
> >> The teardwon descriptor was pop from the queue by the interrupt handler,
> >> preventing cppi41_tear_down_chan() to get it, which will result after
> >> some retries to a couple of warnings.
> >>
> >> I will take a look to see if that is the same issue.
> That is not the same issue. Still, for some reasons, we never get the
> teardown descriptor.
> Two possibilities:
>  - Like the issue I had, the teardown is pop at the wrong place.
>  - The teardown doesn't complete or the descriptor is not queued.
The teardown descriptor is not queued. I have figured out the reason.
The function cppi41_dma_channel_abort() enable the teardown by setting the bit 
corresponding to the endpoint number.
The address of the register is USB_TDOWN but actually the address is wrong in 
the case of DA8xx.
Using the right address (0x1c) fix the teardown warnings.
I will work on a fix.
> I think we should eliminate the first one before to work on the second one.
> I think adding some logs to cppi41_pop_desc() could help to figure out
> what is happening.
> >
> > Thanks! I also see similar warnings under fast ping traffic and g_ether
> > inserted on LCDK. They dont come immediately though. Only after an hour
> > or so under traffic.
The fix should also fix this issue.
> I would not have expected to have them during a ping but this probably
> happens because some USB packet have timed out, which cause may a teardown.
> >
> > I can those provide logs too if its going to be helpful.
> Currently, I think we should focus on the warnings that happens during
> the rmmod as they are always reproducible.
>
> Thanks,
> Alexandre
>
Note that the teardown is not the only thing that doesn't work correctly.
I think same kind of issue should apply to the autoreq and the dma mode.
I will work on a patch that should solve all of them.

Thanks,
Alexandre
--
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: Warning dump on OMAP-L138 when g_zero module is removed

2017-07-21 Thread Alexandre Bailon
Hi Sekhar,

On 07/10/2017 01:00 PM, Sekhar Nori wrote:
> On Thursday 06 July 2017 10:43 PM, Alexandre Bailon wrote:
>> On 06/29/2017 03:50 PM, Sekhar Nori wrote:
>>> Hi Alexandre, Bin,
>>>
>>> With latest linux-next, I see a warning dump when I remove g_zero[1] on 
>>> OMAP-L138 LCDK board. I am building the kernel with davinci_all_defconfig.
>>>
>>> It is not present in latest mainline because the warnings are introduced
>>> with CPPI DMA getting enabled in latest -next.
>>>
>>> Subsequent insertion of g_ether leads to a warning too[2], although the 
>>> gadget seems to work (ping test).
>>>
>>> Since these are pretty annoying, it will be nice to get rid of them. I 
>>> have not been able to debug any further. But if you have
>>> ideas/experiments to try, I can do that.
> 
>> I got a lot of these warnings during development but it was only for the
>> host mode.
>> If I remember correctly, the cause was a race between the teardown
>> function and the interrupt handler.
>> The teardwon descriptor was pop from the queue by the interrupt handler,
>> preventing cppi41_tear_down_chan() to get it, which will result after
>> some retries to a couple of warnings.
>>
>> I will take a look to see if that is the same issue.
That is not the same issue. Still, for some reasons, we never get the
teardown descriptor.
Two possibilities:
 - Like the issue I had, the teardown is pop at the wrong place.
 - The teardown doesn't complete or the descriptor is not queued.

I think we should eliminate the first one before to work on the second one.
I think adding some logs to cppi41_pop_desc() could help to figure out
what is happening.
> 
> Thanks! I also see similar warnings under fast ping traffic and g_ether
> inserted on LCDK. They dont come immediately though. Only after an hour
> or so under traffic.
I would not have expected to have them during a ping but this probably
happens because some USB packet have timed out, which cause may a teardown.
> 
> I can those provide logs too if its going to be helpful.
Currently, I think we should focus on the warnings that happens during
the rmmod as they are always reproducible.

Thanks,
Alexandre
--
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: Warning dump on OMAP-L138 when g_zero module is removed

2017-07-06 Thread Alexandre Bailon
On 06/29/2017 03:50 PM, Sekhar Nori wrote:
> Hi Alexandre, Bin,
> 
> With latest linux-next, I see a warning dump when I remove g_zero[1] on 
> OMAP-L138 LCDK board. I am building the kernel with davinci_all_defconfig.
> 
> It is not present in latest mainline because the warnings are introduced
> with CPPI DMA getting enabled in latest -next.
> 
> Subsequent insertion of g_ether leads to a warning too[2], although the 
> gadget seems to work (ping test).
> 
> Since these are pretty annoying, it will be nice to get rid of them. I 
> have not been able to debug any further. But if you have
> ideas/experiments to try, I can do that.
I got a lot of these warnings during development but it was only for the
host mode.
If I remember correctly, the cause was a race between the teardown
function and the interrupt handler.
The teardwon descriptor was pop from the queue by the interrupt handler,
preventing cppi41_tear_down_chan() to get it, which will result after
some retries to a couple of warnings.

I will take a look to see if that is the same issue.

Thanks,
Alexandre
> 
> Thanks,
> Sekhar
> 
> [1] 
> root@omapl138-lcdk:~# modprobe g_zero
> zero gadget: Gadget Zero, version: Cinco de Mayo 2008
> zero gadget: zero ready
> musb_g_ep0_irq 712: SetupEnd came in a wrong ep0stage setup
> root@omapl138-lcdk:~# zero gadget: high-speed config #3: source/sink
> 
> root@omapl138-lcdk:~# modprobe -r g_zero  
>   
>   
> 
> [ cut here ]
> WARNING: CPU: 0 PID: 464 at drivers/dma/cppi41.c:694 
> cppi41_stop_chan+0x208/0x338 [cppi41]
> Modules linked in: usb_f_ss_lb g_zero(-) libcomposite configfs ofpart 
> davinci_nand nand nand_ecc cppi41 mtd vpif_display tvp514x vpif_capture 
> videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_core 
> v4l2_fwnode v4l2_common vid4
> CPU: 0 PID: 464 Comm: modprobe Tainted: GW   
> 4.12.0-rc7-next-20170629-10695-g3fb8ba638d53 #76
> Hardware name: Generic DA850/OMAP-L138/AM18x
> Backtrace: 
> [] (dump_backtrace) from [] (show_stack+0x18/0x1c)
>  r7:0009 r6: r5:bf3a19f0 r4:
> [] (show_stack) from [] (dump_stack+0x20/0x28)
> [] (dump_stack) from [] (__warn+0xdc/0x104)
> [] (__warn) from [] (warn_slowpath_null+0x28/0x30)
>  r9:00d8 r8:bf2d9e00 r7:0001 r6:c5b5b010 r5:c5b5b014 r4:c7b2b8a0
> [] (warn_slowpath_null) from [] 
> (cppi41_stop_chan+0x208/0x338 [cppi41])
> [] (cppi41_stop_chan [cppi41]) from [] 
> (cppi41_dma_channel_abort+0x118/0x290 [musb_hdrc])
>  r7:c5848010 r6:0002 r5:0001 r4:c7077454
> [] (cppi41_dma_channel_abort [musb_hdrc]) from [] 
> (musb_gadget_disable+0xfc/0x240 [musb_hdrc])
>  r10:c7077000 r9:fee00410 r8:2093 r7:c5848010 r6:bf2d9de4 r5:c5848010
>  r4:c5848410
> [] (musb_gadget_disable [musb_hdrc]) from [] 
> (usb_ep_disable+0x30/0x3c [udc_core])
>  r10: r9:c7144000 r8:c000a604 r7:c7334ba0 r6:c584846c r5:
>  r4:c5848410 r3:bf2d4ad0
> [] (usb_ep_disable [udc_core]) from [] 
> (disable_endpoints+0x20/0x4c [usb_f_ss_lb])
>  r5: r4:
> [] (disable_endpoints [usb_f_ss_lb]) from [] 
> (disable_source_sink+0x34/0x3c [usb_f_ss_lb])
>  r7:c7334ba0 r6: r5:6013 r4:c7159e40
> [] (disable_source_sink [usb_f_ss_lb]) from [] 
> (sourcesink_disable+0x10/0x14 [usb_f_ss_lb])
> [] (sourcesink_disable [usb_f_ss_lb]) from [] 
> (composite_disconnect+0x58/0xd0 [libcomposite])
> [] (composite_disconnect [libcomposite]) from [] 
> (usb_gadget_remove_driver+0x58/0xa8 [udc_core])
>  r7:0081 r6:0800 r5:c5849138 r4:c7b52600
> [] (usb_gadget_remove_driver [udc_core]) from [] 
> (usb_gadget_unregister_driver+0x68/0xd0 [udc_core])
>  r5:bf3e591c r4:c7b52600
> [] (usb_gadget_unregister_driver [udc_core]) from [] 
> (usb_composite_unregister+0x14/0x18 [libcomposite])
>  r5:0003af5c r4:bf3e59e0
> [] (usb_composite_unregister [libcomposite]) from [] 
> (zero_driver_exit+0x14/0x1c [g_zero])
> [] (zero_driver_exit [g_zero]) from [] 
> (SyS_delete_module+0x168/0x1e8)
> [] (SyS_delete_module) from [] (ret_fast_syscall+0x0/0x38)
>  r6: r5:0003af5c r4:0003af20
> ---[ end trace 3d9a1549a3b9c32f ]---
> [ cut here ]
> WARNING: CPU: 0 PID: 464 at drivers/dma/cppi41.c:700 
> cppi41_stop_chan+0x248/0x338 [cppi41]
> Modules linked in: usb_f_ss_lb g_zero(-) libcomposite configfs ofpart 
> davinci_nand nand nand_ecc cppi41 mtd vpif_display tvp514x vpif_capture 
> videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_core 
> v4l2_fwnode v4l2_common vid4
> CPU: 0 PID: 464 Comm: modprobe Tainted: GW   
> 4.12.0-rc7-next-20170629-10695-g3fb8ba638d53 #76
> Hardware name: Generic DA850/OMAP-L138/AM18x
> Backtrace: 
> [] (dump_backtrace) from [] (show_stack+0x18/0x1c)
>  r7:0009 r6: r5:bf3a19f0 r4:
> [] (show_stack) from [] (dump_stack

[PATCH v4] usb: musb: musb_cppi41: Defer probe only if DMA is not ready

2017-05-19 Thread Alexandre Bailon
If dma_request_slave_channel() failed to return a channel,
then the driver will print an error and request to defer probe,
regardless of the cause of the failure.
Defer if the DMA is not ready yet otherwise print an error.

Signed-off-by: Alexandre Bailon 
Reviewed-by: Johan Hovold 
---
 drivers/usb/musb/musb_cppi41.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index e7c8b1b..ba25528 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -673,12 +673,15 @@ static int cppi41_dma_controller_start(struct 
cppi41_dma_controller *controller)
musb_dma->status = MUSB_DMA_STATUS_FREE;
musb_dma->max_len = SZ_4M;
 
-   dc = dma_request_slave_channel(dev->parent, str);
-   if (!dc) {
-   dev_err(dev, "Failed to request %s.\n", str);
-   ret = -EPROBE_DEFER;
+   dc = dma_request_chan(dev->parent, str);
+   if (IS_ERR(dc)) {
+   ret = PTR_ERR(dc);
+   if (ret != -EPROBE_DEFER)
+   dev_err(dev, "Failed to request %s: %d.\n",
+   str, ret);
goto err;
}
+
cppi41_channel->dc = dc;
}
return 0;
-- 
2.10.2

--
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


[RESEND PATCH v5] ARM: dts: da850: Add the CPPI 4.1 DMA to the USB OTG controller

2017-05-19 Thread Alexandre Bailon
This adds the CPPI 4.1 DMA controller to the USB OTG controller.

Changes since v2:
- Fixed the the property reg-names (had glue register defined)
- Removed few useless property

Signed-off-by: Alexandre Bailon 
---
 arch/arm/boot/dts/da850.dtsi | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 941d455..0bd048e 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -446,13 +446,38 @@
};
usb0: usb@20 {
compatible = "ti,da830-musb";
-   reg = <0x20 0x1>;
+   reg = <0x20 0x1000>;
+   ranges;
interrupts = <58>;
interrupt-names = "mc";
dr_mode = "otg";
phys = <&usb_phy 0>;
phy-names = "usb-phy";
status = "disabled";
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   dmas = <&cppi41dma 0 0 &cppi41dma 1 0
+   &cppi41dma 2 0 &cppi41dma 3 0
+   &cppi41dma 0 1 &cppi41dma 1 1
+   &cppi41dma 2 1 &cppi41dma 3 1>;
+   dma-names =
+   "rx1", "rx2", "rx3", "rx4",
+   "tx1", "tx2", "tx3", "tx4";
+
+   cppi41dma: dma-controller@201000 {
+   compatible = "ti,da830-cppi41";
+   reg =  <0x201000 0x1000
+   0x202000 0x1000
+   0x204000 0x4000>;
+   reg-names = "controller",
+   "scheduler", "queuemgr";
+   interrupts = <58>;
+   #dma-cells = <2>;
+   #dma-channels = <4>;
+   status = "okay";
+   };
};
sata: sata@218000 {
compatible = "ti,da850-ahci";
-- 
2.10.2

--
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 v3] usb: musb: musb_cppi41: Update an error message

2017-05-19 Thread Alexandre Bailon
If dma_request_slave_channel() failed to return a channel,
then the driver will print an error and request to defer probe,
regardless of the cause of the failure.
Defer if the DMA is not ready yet otherwise print an error.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index e7c8b1b..2c6ad93 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -673,12 +673,14 @@ static int cppi41_dma_controller_start(struct 
cppi41_dma_controller *controller)
musb_dma->status = MUSB_DMA_STATUS_FREE;
musb_dma->max_len = SZ_4M;
 
-   dc = dma_request_slave_channel(dev->parent, str);
-   if (!dc) {
-   dev_err(dev, "Failed to request %s.\n", str);
-   ret = -EPROBE_DEFER;
+   dc = dma_request_chan(dev->parent, str);
+   if (IS_ERR(dc)) {
+   ret = PTR_ERR(dc);
+   if (ret != -EPROBE_DEFER)
+   dev_err(dev, "Failed to request %s.\n", str);
goto err;
}
+
cppi41_channel->dc = dc;
}
return 0;
-- 
2.10.2

--
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: musb: musb_cppi41: Update an error message

2017-05-05 Thread Alexandre Bailon
If dma_request_slave_channel() failed to return a channel,
then the driver will print an error and request to defer probe,
regardless of the cause of the failure.
Only defer if the DMA is not ready yet and print an error to explain
that we are deferring probe.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index e7c8b1b..4718d0d 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -673,10 +673,12 @@ static int cppi41_dma_controller_start(struct 
cppi41_dma_controller *controller)
musb_dma->status = MUSB_DMA_STATUS_FREE;
musb_dma->max_len = SZ_4M;
 
-   dc = dma_request_slave_channel(dev->parent, str);
-   if (!dc) {
-   dev_err(dev, "Failed to request %s.\n", str);
-   ret = -EPROBE_DEFER;
+   dc = dma_request_chan(dev->parent, str);
+   if (IS_ERR(dc)) {
+   ret = PTR_ERR(dc);
+   dev_err(dev, "Failed to request %s%s.\n", str,
+   ret == -EPROBE_DEFER
+   ? ", deferring probe" : "");
goto err;
}
cppi41_channel->dc = dc;
-- 
2.10.2

--
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: musb: musb_cppi41: Update an error message

2017-05-02 Thread Alexandre Bailon



On 05/01/2017 04:47 PM, Bin Liu wrote:

Hi,

On Fri, Apr 28, 2017 at 06:04:54PM +0200, Alexandre Bailon wrote:

If dma_request_slave_channel() failed to return a channel,
then the driver will print an error and request to defer probe.
Update the error message to explain we are defrering probe.

Signed-off-by: Alexandre Bailon 
---
  drivers/usb/musb/musb_cppi41.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index e7c8b1b..e6b9161 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -676,6 +676,7 @@ static int cppi41_dma_controller_start(struct 
cppi41_dma_controller *controller)
dc = dma_request_slave_channel(dev->parent, str);
if (!dc) {
dev_err(dev, "Failed to request %s.\n", str);
+   dev_info(dev, "Deferring probe.\n");

Please merge the two lines above into one statement, using dev_info().
Well, if I merge the two lines, the patch won't pass checkpatch because 
the string is too long.

May be should I rephrase to have something shorter.

Regards,
Alexandre



ret = -EPROBE_DEFER;
goto err;
}

Regards,
-Bin.


--
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: musb: musb_cppi41: Update an error message

2017-04-28 Thread Alexandre Bailon
If dma_request_slave_channel() failed to return a channel,
then the driver will print an error and request to defer probe.
Update the error message to explain we are defrering probe.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index e7c8b1b..e6b9161 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -676,6 +676,7 @@ static int cppi41_dma_controller_start(struct 
cppi41_dma_controller *controller)
dc = dma_request_slave_channel(dev->parent, str);
if (!dc) {
dev_err(dev, "Failed to request %s.\n", str);
+   dev_info(dev, "Deferring probe.\n");
ret = -EPROBE_DEFER;
goto err;
}
-- 
2.10.2

--
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] ARM: davinci: Add the clock for the CPPI 4.1 DMA engine

2017-04-07 Thread Alexandre Bailon



On 04/07/2017 06:15 PM, Alexandre Bailon wrote:



On 04/07/2017 04:36 PM, Sekhar Nori wrote:

On Wednesday 05 April 2017 10:47 PM, Alexandre Bailon wrote:

The CPPI 4.1 DMA is sharing its clock with the USB OTG,
and most of the time, the clock will be enabled by USB.
But during the init of the DMA, USB is not enabled (waiting for DMA),
and then we must enable the clock before doing anything.
Add the clock for the CPPI 4.1 DMA engine.

Signed-off-by: Alexandre Bailon 
---
  arch/arm/mach-davinci/da830.c | 6 ++
  arch/arm/mach-davinci/da850.c | 6 ++
  2 files changed, 12 insertions(+)

diff --git a/arch/arm/mach-davinci/da830.c 
b/arch/arm/mach-davinci/da830.c

index 073c458..bd88470 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -304,6 +304,11 @@ static struct clk usb20_clk = {
  .gpsc= 1,
  };
  +static struct clk cppi41_clk = {
+.name= "cppi41",
+.parent= &usb20_clk,
+};
+
  static struct clk aemif_clk = {
  .name= "aemif",
  .parent= &pll0_sysclk3,
@@ -413,6 +418,7 @@ static struct clk_lookup da830_clks[] = {
  CLK("davinci-mcasp.1",NULL,&mcasp1_clk),
  CLK("davinci-mcasp.2",NULL,&mcasp2_clk),
  CLK("musb-da8xx","usb20",&usb20_clk),
+CLK("cppi41-dmaengine",NULL,&cppi41_clk),

I dont see this device name being used in current linux-next. Is this
name accepted ?

There is here a typo. The name should be cppi41-dma-engine.
I will fix it.
Actually, it is not a typo. It would have be more logical to name it 
cppi41-dma-engine

(like the driver name) but the name is correct.
The device name is not yet in linux-next as the device is created in 
da8xx driver.

http://marc.info/?l=linux-usb&m=149080474124498&w=2


The patch otherwise looks okay.

Thanks,
Sekhar

Thanks,
Alexandre


--
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] ARM: davinci: Add the clock for the CPPI 4.1 DMA engine

2017-04-07 Thread Alexandre Bailon



On 04/07/2017 04:36 PM, Sekhar Nori wrote:

On Wednesday 05 April 2017 10:47 PM, Alexandre Bailon wrote:

The CPPI 4.1 DMA is sharing its clock with the USB OTG,
and most of the time, the clock will be enabled by USB.
But during the init of the DMA, USB is not enabled (waiting for DMA),
and then we must enable the clock before doing anything.
Add the clock for the CPPI 4.1 DMA engine.

Signed-off-by: Alexandre Bailon 
---
  arch/arm/mach-davinci/da830.c | 6 ++
  arch/arm/mach-davinci/da850.c | 6 ++
  2 files changed, 12 insertions(+)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 073c458..bd88470 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -304,6 +304,11 @@ static struct clk usb20_clk = {
.gpsc   = 1,
  };
  
+static struct clk cppi41_clk = {

+   .name   = "cppi41",
+   .parent = &usb20_clk,
+};
+
  static struct clk aemif_clk = {
.name   = "aemif",
.parent = &pll0_sysclk3,
@@ -413,6 +418,7 @@ static struct clk_lookup da830_clks[] = {
CLK("davinci-mcasp.1",NULL,   &mcasp1_clk),
CLK("davinci-mcasp.2",NULL,   &mcasp2_clk),
CLK("musb-da8xx", "usb20",  &usb20_clk),
+   CLK("cppi41-dmaengine",   NULL,   &cppi41_clk),

I dont see this device name being used in current linux-next. Is this
name accepted ?

There is here a typo. The name should be cppi41-dma-engine.
I will fix it.


The patch otherwise looks okay.

Thanks,
Sekhar

Thanks,
Alexandre
--
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] ARM: davinci: Add the clock for the CPPI 4.1 DMA engine

2017-04-05 Thread Alexandre Bailon
The CPPI 4.1 DMA is sharing its clock with the USB OTG,
and most of the time, the clock will be enabled by USB.
But during the init of the DMA, USB is not enabled (waiting for DMA),
and then we must enable the clock before doing anything.
Add the clock for the CPPI 4.1 DMA engine.

Signed-off-by: Alexandre Bailon 
---
 arch/arm/mach-davinci/da830.c | 6 ++
 arch/arm/mach-davinci/da850.c | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 073c458..bd88470 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -304,6 +304,11 @@ static struct clk usb20_clk = {
.gpsc   = 1,
 };
 
+static struct clk cppi41_clk = {
+   .name   = "cppi41",
+   .parent = &usb20_clk,
+};
+
 static struct clk aemif_clk = {
.name   = "aemif",
.parent = &pll0_sysclk3,
@@ -413,6 +418,7 @@ static struct clk_lookup da830_clks[] = {
CLK("davinci-mcasp.1",  NULL,   &mcasp1_clk),
CLK("davinci-mcasp.2",  NULL,   &mcasp2_clk),
CLK("musb-da8xx",   "usb20",&usb20_clk),
+   CLK("cppi41-dmaengine", NULL,   &cppi41_clk),
CLK(NULL,   "aemif",&aemif_clk),
CLK(NULL,   "aintc",&aintc_clk),
CLK(NULL,   "secu_mgr", &secu_mgr_clk),
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index ccad2f9..07d6f0e 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -401,6 +401,11 @@ static struct clk usb20_clk = {
.gpsc   = 1,
 };
 
+static struct clk cppi41_clk = {
+   .name   = "cppi41",
+   .parent = &usb20_clk,
+};
+
 static struct clk spi0_clk = {
.name   = "spi0",
.parent = &pll0_sysclk2,
@@ -560,6 +565,7 @@ static struct clk_lookup da850_clks[] = {
CLK("davinci-nand.0",   "aemif",&aemif_nand_clk),
CLK("ohci-da8xx",   "usb11",&usb11_clk),
CLK("musb-da8xx",   "usb20",&usb20_clk),
+   CLK("cppi41-dmaengine", NULL,   &cppi41_clk),
CLK("spi_davinci.0",NULL,   &spi0_clk),
CLK("spi_davinci.1",NULL,   &spi1_clk),
CLK("vpif", NULL,   &vpif_clk),
-- 
2.10.2

--
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] ARM: davinci: Add the clock for the CPPI 4.1 DMA engine

2017-04-05 Thread Alexandre Bailon



On 04/04/2017 08:16 AM, Sekhar Nori wrote:

On Wednesday 29 March 2017 09:39 PM, Alexandre Bailon wrote:

The CPPI 4.1 DMA is sharing its clock with the USB OTG,
and most of the time, the clock will be enabled by USB.
But during the init of the DMA, USB is not enabled (waiting for DMA),
and then we must enable the clock before to do anything.
Add the clock for the CPPI 4.1 DMA engine.

Note:
This patch is to apply instead of:
"ARM: davinci: Make the usb20 clock available to PM runtime"

Okay, but I still liked the fact that that patch was using NULL as
con_id for MUSB clock. That makes sense because MUSB gets a single clock
input. I think you should still make that change. If not for v4.12, then
for v4.13.


Signed-off-by: Alexandre Bailon 
---
  arch/arm/mach-davinci/da830.c| 1 +
  arch/arm/mach-davinci/da850.c| 1 +
  arch/arm/mach-davinci/da8xx-dt.c | 2 ++
  3 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 073c458..ae4a8a5 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -413,6 +413,7 @@ static struct clk_lookup da830_clks[] = {
CLK("davinci-mcasp.1",NULL,   &mcasp1_clk),
CLK("davinci-mcasp.2",NULL,   &mcasp2_clk),
CLK("musb-da8xx", "usb20",  &usb20_clk),
+   CLK("cppi41-dmaengine",   NULL,   &usb20_clk),

Did you try reading /sys/kernel/debug/davinci_clocks after this patch?
It will hang because of the loop created here.

I have tried and I did not get any issues.


Looks like what you want is cppi4.1 dma clock to be a child of MUSB
clock. That way, even if DMA is enabled before MUSB, it still works.

OK. I will update the patch to make cppi4.1 clock a child of usb clock.


Thanks,
Sekhar

Thanks,
Alexandre
--
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][linux-next] dmaengine: cppi41: Fix an Oops happening in cppi41_dma_probe()

2017-04-05 Thread Alexandre Bailon
This fix an Oops happening on all platforms using the old dt bindings
(all platforms but da8xx).
This update cppi41_dma_probe() to use the index variable which is
required to keep compatibility between old and new dt bindings.

Fixes: 8e3ba95f4190 ("dmaengine: cppi41: use managed functions devm_*()")
Reported-by: Tony Lindgren 
Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 0be56c9..f7e965f 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -1038,17 +1038,17 @@ static int cppi41_dma_probe(struct platform_device 
*pdev)
if (index < 0)
return index;
 
-   mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   mem = platform_get_resource(pdev, IORESOURCE_MEM, index);
cdd->ctrl_mem = devm_ioremap_resource(dev, mem);
if (IS_ERR(cdd->ctrl_mem))
return PTR_ERR(cdd->ctrl_mem);
 
-   mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+   mem = platform_get_resource(pdev, IORESOURCE_MEM, index + 1);
cdd->sched_mem = devm_ioremap_resource(dev, mem);
if (IS_ERR(cdd->sched_mem))
return PTR_ERR(cdd->sched_mem);
 
-   mem = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+   mem = platform_get_resource(pdev, IORESOURCE_MEM, index + 2);
cdd->qmgr_mem = devm_ioremap_resource(dev, mem);
if (IS_ERR(cdd->qmgr_mem))
return PTR_ERR(cdd->qmgr_mem);
-- 
2.10.2

--
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 v7 2/3] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx

2017-04-05 Thread Alexandre Bailon

On 04/03/2017 04:59 PM, Bin Liu wrote:

On Wed, Mar 29, 2017 at 06:24:31PM +0200, Alexandre Bailon wrote:

Currently, only the PIO mode is supported.
This add support of CPPI 4.1 to DA8xx.
As the In DA8xx the CPPI 4.1 DMA is a part of the USB.
Create the CPPI 4.1 device as a child of USB.

Signed-off-by: Alexandre Bailon 
---
  drivers/usb/musb/Kconfig |  4 ++--
  drivers/usb/musb/da8xx.c | 43 ++-
  2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 72a2a50..5506a9c 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA
  Enable DMA transfers when TI CPPI DMA is available.
  
  config USB_TI_CPPI41_DMA

-   bool 'TI CPPI 4.1 (AM335x)'
-   depends on ARCH_OMAP && DMADEVICES
+   bool 'TI CPPI 4.1'
+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
select TI_CPPI41

TI_CPPI41 also should depend on ARCH_DAVINCI_DA8XX due to this patch.  You
might need the following change for dma Kconfig as well.
This change has been done in the series "dmaengine: cppi41: Add dma 
support to da8xx".


diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index d01d59812cf3..15e31bfae9f9 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -514,8 +514,8 @@ config TIMB_DMA
   Enable support for the Timberdale FPGA DMA engine.
  
  config TI_CPPI41

-   tristate "AM33xx CPPI41 DMA support"
-   depends on ARCH_OMAP
+   tristate "CPPI41 DMA support"
+   depends on ARCH_OMAP || ARCH_DAVINCI_DA8XX
 select DMA_ENGINE
 help
   The Communications Port Programming Interface (CPPI) 4.1 DMA engine

Regards,
-Bin.

Regards,
Alexandre
--
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 v7 3/3] usb: musb: musb_cppi41: Workaround DMA stall issue during teardown

2017-03-29 Thread Alexandre Bailon
The DMA may hang up if a teardown is initiated while an endpoint is still
active (Advisory 2.3.27 of DA8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c   | 2 +-
 drivers/usb/musb/musb_core.h   | 1 +
 drivers/usb/musb/musb_cppi41.c | 4 
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 7b9a44d..5a8a031 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -483,7 +483,7 @@ da8xx_dma_controller_create(struct musb *musb, void __iomem 
*base)
 
 static const struct musb_platform_ops da8xx_ops = {
.quirks = MUSB_INDEXED_EP | MUSB_PRESERVE_SESSION |
- MUSB_DMA_CPPI41,
+ MUSB_DMA_CPPI41 | MUSB_DA8XX,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 5b708be..3e98d42 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -172,6 +172,7 @@ struct musb_io;
  */
 struct musb_platform_ops {
 
+#define MUSB_DA8XX BIT(8)
 #define MUSB_PRESERVE_SESSION  BIT(7)
 #define MUSB_DMA_UX500 BIT(6)
 #define MUSB_DMA_CPPI41BIT(5)
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 355655f..e7c8b1b 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -571,6 +571,10 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
}
}
 
+   /* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
+   if (musb->io.quirks & MUSB_DA8XX)
+   mdelay(250);
+
tdbit = 1 << cppi41_channel->port_num;
if (is_tx)
tdbit <<= 16;
-- 
2.10.2

--
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 v7 1/3] usb: musb: Use shared irq

2017-03-29 Thread Alexandre Bailon
In the DA8xx, USB and CPPI 4.1 are sharing the same interrupt line.
Update the driver to request a shared irq.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0c3664a..870da18 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2332,7 +2332,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) 
musb);
 
/* attach to the IRQ */
-   if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
+   if (request_irq(nIrq, musb->isr, IRQF_SHARED, dev_name(dev), musb)) {
dev_err(dev, "request_irq %d failed!\n", nIrq);
status = -ENODEV;
goto fail3;
-- 
2.10.2

--
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 v7 2/3] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx

2017-03-29 Thread Alexandre Bailon
Currently, only the PIO mode is supported.
This add support of CPPI 4.1 to DA8xx.
As the In DA8xx the CPPI 4.1 DMA is a part of the USB.
Create the CPPI 4.1 device as a child of USB.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/Kconfig |  4 ++--
 drivers/usb/musb/da8xx.c | 43 ++-
 2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 72a2a50..5506a9c 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA
  Enable DMA transfers when TI CPPI DMA is available.
 
 config USB_TI_CPPI41_DMA
-   bool 'TI CPPI 4.1 (AM335x)'
-   depends on ARCH_OMAP && DMADEVICES
+   bool 'TI CPPI 4.1'
+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
select TI_CPPI41
 
 config USB_TUSB_OMAP_DMA
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d79c288..7b9a44d 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -456,12 +457,41 @@ static inline u8 get_vbus_power(struct device *dev)
return current_uA / 1000 / 2;
 }
 
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+static void da8xx_dma_controller_callback(struct dma_controller *c)
+{
+   struct musb *musb = c->musb;
+   void __iomem *reg_base = musb->ctrl_base;
+
+   musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
+}
+
+static struct dma_controller *
+da8xx_dma_controller_create(struct musb *musb, void __iomem *base)
+{
+   struct dma_controller *controller;
+
+   controller = cppi41_dma_controller_create(musb, base);
+   if (IS_ERR_OR_NULL(controller))
+   return controller;
+
+   controller->dma_callback = da8xx_dma_controller_callback;
+
+   return controller;
+}
+#endif
+
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_INDEXED_EP | MUSB_PRESERVE_SESSION,
+   .quirks = MUSB_INDEXED_EP | MUSB_PRESERVE_SESSION |
+ MUSB_DMA_CPPI41,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
.fifo_mode  = 2,
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+   .dma_init   = da8xx_dma_controller_create,
+   .dma_exit   = cppi41_dma_controller_destroy,
+#endif
.enable = da8xx_musb_enable,
.disable= da8xx_musb_disable,
 
@@ -483,6 +513,12 @@ static const struct musb_hdrc_config da8xx_config = {
.multipoint = 1,
 };
 
+static struct of_dev_auxdata da8xx_auxdata_lookup[] __initdata = {
+   OF_DEV_AUXDATA("ti,da830-cppi41", 0x01e01000, "cppi41-dmaengine",
+  NULL),
+   {}
+};
+
 static int da8xx_probe(struct platform_device *pdev)
 {
struct resource musb_resources[2];
@@ -533,6 +569,11 @@ static int da8xx_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, glue);
 
+   ret = of_platform_populate(pdev->dev.of_node, NULL,
+  da8xx_auxdata_lookup, &pdev->dev);
+   if (ret)
+   return ret;
+
memset(musb_resources, 0x00, sizeof(*musb_resources) *
ARRAY_SIZE(musb_resources));
 
-- 
2.10.2

--
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] ARM: davinci: Add the clock for the CPPI 4.1 DMA engine

2017-03-29 Thread Alexandre Bailon

Hello Serge,


On 03/29/2017 06:16 PM, Sergei Shtylyov wrote:

Hello!

On 03/29/2017 07:09 PM, Alexandre Bailon wrote:


The CPPI 4.1 DMA is sharing its clock with the USB OTG,
and most of the time, the clock will be enabled by USB.
But during the init of the DMA, USB is not enabled (waiting for DMA),
and then we must enable the clock before to do anything.


   s/to do/doing/.


Add the clock for the CPPI 4.1 DMA engine.

Note:
This patch is to apply instead of:
"ARM: davinci: Make the usb20 clock available to PM runtime"

Signed-off-by: Alexandre Bailon 
---
 arch/arm/mach-davinci/da830.c| 1 +
 arch/arm/mach-davinci/da850.c| 1 +
 arch/arm/mach-davinci/da8xx-dt.c | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-davinci/da830.c 
b/arch/arm/mach-davinci/da830.c

index 073c458..ae4a8a5 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -413,6 +413,7 @@ static struct clk_lookup da830_clks[] = {
 CLK("davinci-mcasp.1",NULL,&mcasp1_clk),
 CLK("davinci-mcasp.2",NULL,&mcasp2_clk),
 CLK("musb-da8xx","usb20",&usb20_clk),
+CLK("cppi41-dmaengine",NULL,&usb20_clk),
 CLK(NULL,"aemif",&aemif_clk),
 CLK(NULL,"aintc",&aintc_clk),
 CLK(NULL,"secu_mgr",&secu_mgr_clk),
diff --git a/arch/arm/mach-davinci/da850.c 
b/arch/arm/mach-davinci/da850.c

index ccad2f9..9739aaa 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -560,6 +560,7 @@ static struct clk_lookup da850_clks[] = {
 CLK("davinci-nand.0","aemif",&aemif_nand_clk),
 CLK("ohci-da8xx","usb11",&usb11_clk),
 CLK("musb-da8xx","usb20",&usb20_clk),
+CLK("cppi41-dmaengine",NULL,&usb20_clk),
 CLK("spi_davinci.0",NULL,&spi0_clk),
 CLK("spi_davinci.1",NULL,&spi1_clk),
 CLK("vpif",NULL,&vpif_clk),
diff --git a/arch/arm/mach-davinci/da8xx-dt.c 
b/arch/arm/mach-davinci/da8xx-dt.c

index e3cef50..5bf08ba 100644
--- a/arch/arm/mach-davinci/da8xx-dt.c
+++ b/arch/arm/mach-davinci/da8xx-dt.c
@@ -53,6 +53,8 @@ static struct of_dev_auxdata da850_auxdata_lookup[] 
__initdata = {

 OF_DEV_AUXDATA("ti,da830-musb", 0x01e0, "musb-da8xx", NULL),
 OF_DEV_AUXDATA("ti,da830-usb-phy", 0x01c1417c, "da8xx-usb-phy", 
NULL),

 OF_DEV_AUXDATA("ti,da850-ahci", 0x01e18000, "ahci_da850", NULL),
+OF_DEV_AUXDATA("ti,da830-cppi41", 0x01e01000, "cppi41-dma-engine",


   Not "cppi41-dmaengine"?
Oops. I should I removed this line. It must be made in the da8xx.c USB 
driver.


[...]

MBR, Sergei


Regards,
Alexandre
--
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 v7 0/3] usb: musb: da8xx: Add DMA support

2017-03-29 Thread Alexandre Bailon
This series update MUSB driver to add DMA support to DA8xx.
It should be applied on top of:
"[PATCH v4 0/3] dmaengine: cppi41: Add dma support to da8xx" and
"[PATCH] ARM: davinci: Add the clock for the CPPI 4.1 DMA engine"

Changes in v7:
- Remove the patch that was adding runtime PM.
  It was breaking system suspend.
- Use of_dev_auxdata to map the DT node name to the name expected by the clock.

Changes in v6:
- Rebased on linux-next. Some patches were conflicting with a series
  adding suspend and resume support.

Changes in v5:
- Fix a typo in commit message of patch 4

Changes in v4:
- Update and clarify the commit message of patch 5
- Fix the typo in patch 3

Changes in v3:
- Remove PM runtime callbacks.
  I have update arch/arm/mach-davinci/pm_domain.c to let PM runtime control
  the usb20 clock.
- Only use PM runtime sync operation.

Changes in v2:
- Clock and IRQ management has been moved to MUSB DA8xx glue
  (was in CPPI 4.1 driver)
- I have added a partial support PM runtime. The goal was to use PM
  runtime to manage clock of MUSB and CPPI 4.1 (they use the same clock).
- CPPI 4.1 is now achild of MUSB DA8xx glue.

Alexandre Bailon (3):
  usb: musb: Use shared irq
  usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx
  usb: musb: musb_cppi41: Workaround DMA stall issue during teardown

 drivers/usb/musb/Kconfig   |  4 ++--
 drivers/usb/musb/da8xx.c   | 43 +-
 drivers/usb/musb/musb_core.c   |  2 +-
 drivers/usb/musb/musb_core.h   |  1 +
 drivers/usb/musb/musb_cppi41.c |  4 
 5 files changed, 50 insertions(+), 4 deletions(-)

-- 
2.10.2

--
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] ARM: davinci: Add the clock for the CPPI 4.1 DMA engine

2017-03-29 Thread Alexandre Bailon
The CPPI 4.1 DMA is sharing its clock with the USB OTG,
and most of the time, the clock will be enabled by USB.
But during the init of the DMA, USB is not enabled (waiting for DMA),
and then we must enable the clock before to do anything.
Add the clock for the CPPI 4.1 DMA engine.

Note:
This patch is to apply instead of:
"ARM: davinci: Make the usb20 clock available to PM runtime"

Signed-off-by: Alexandre Bailon 
---
 arch/arm/mach-davinci/da830.c| 1 +
 arch/arm/mach-davinci/da850.c| 1 +
 arch/arm/mach-davinci/da8xx-dt.c | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 073c458..ae4a8a5 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -413,6 +413,7 @@ static struct clk_lookup da830_clks[] = {
CLK("davinci-mcasp.1",  NULL,   &mcasp1_clk),
CLK("davinci-mcasp.2",  NULL,   &mcasp2_clk),
CLK("musb-da8xx",   "usb20",&usb20_clk),
+   CLK("cppi41-dmaengine", NULL,   &usb20_clk),
CLK(NULL,   "aemif",&aemif_clk),
CLK(NULL,   "aintc",&aintc_clk),
CLK(NULL,   "secu_mgr", &secu_mgr_clk),
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index ccad2f9..9739aaa 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -560,6 +560,7 @@ static struct clk_lookup da850_clks[] = {
CLK("davinci-nand.0",   "aemif",&aemif_nand_clk),
CLK("ohci-da8xx",   "usb11",&usb11_clk),
CLK("musb-da8xx",   "usb20",&usb20_clk),
+   CLK("cppi41-dmaengine", NULL,   &usb20_clk),
CLK("spi_davinci.0",NULL,   &spi0_clk),
CLK("spi_davinci.1",NULL,   &spi1_clk),
CLK("vpif", NULL,   &vpif_clk),
diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c
index e3cef50..5bf08ba 100644
--- a/arch/arm/mach-davinci/da8xx-dt.c
+++ b/arch/arm/mach-davinci/da8xx-dt.c
@@ -53,6 +53,8 @@ static struct of_dev_auxdata da850_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("ti,da830-musb", 0x01e0, "musb-da8xx", NULL),
OF_DEV_AUXDATA("ti,da830-usb-phy", 0x01c1417c, "da8xx-usb-phy", NULL),
OF_DEV_AUXDATA("ti,da850-ahci", 0x01e18000, "ahci_da850", NULL),
+   OF_DEV_AUXDATA("ti,da830-cppi41", 0x01e01000, "cppi41-dma-engine",
+  NULL),
{}
 };
 
-- 
2.10.2

--
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: [RESEND PATCH v6 4/4] usb: musb: da8xx: Add a primary support of PM runtime

2017-03-27 Thread Alexandre Bailon

On 03/27/2017 07:38 PM, Grygorii Strashko wrote:



On 03/27/2017 11:39 AM, Alexandre Bailon wrote:

Hello Grygorii,
On 03/24/2017 06:26 PM, Grygorii Strashko wrote:



On 03/24/2017 09:36 AM, Alexandre Bailon wrote:

Currently, MUSB DA8xx glue driver doesn't have PM runtime support.
Because the CPPI 4.1 is using the same clock as MUSB DA8xx and
CPPI 4.1 is a child of MUSB DA8xx glue, add support of PM runtime
to the DA8xx glue driver in order to let the CPPI 4.1 driver manage
the clock by using PM runtime.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 27 ---
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index ed28afd..89e12f6 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -30,7 +30,6 @@
  */



[...]



@@ -527,12 +520,6 @@ static int da8xx_probe(struct platform_device

*pdev)

 if (!glue)
 return -ENOMEM;

-clk = devm_clk_get(&pdev->dev, "usb20");
-if (IS_ERR(clk)) {
-dev_err(&pdev->dev, "failed to get clock\n");
-return PTR_ERR(clk);
-}
-
 glue->phy = devm_phy_get(&pdev->dev, "usb-phy");
 if (IS_ERR(glue->phy)) {
 if (PTR_ERR(glue->phy) != -EPROBE_DEFER)
@@ -541,7 +528,6 @@ static int da8xx_probe(struct platform_device

*pdev)

 }

 glue->dev= &pdev->dev;
-glue->clk= clk;

 if (IS_ENABLED(CONFIG_OF) && np) {
 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
@@ -587,6 +573,8 @@ static int da8xx_probe(struct platform_device

*pdev)

 pinfo.data = pdata;
 pinfo.size_data = sizeof(*pdata);

+pm_runtime_enable(&pdev->dev);
+
 glue->musb = platform_device_register_full(&pinfo);
 ret = PTR_ERR_OR_ZERO(glue->musb);
 if (ret) {
@@ -603,6 +591,7 @@ static int da8xx_remove(struct platform_device

*pdev)


 platform_device_unregister(glue->musb);
 usb_phy_generic_unregister(glue->usb_phy);
+pm_runtime_disable(&pdev->dev);

 return 0;
 }
@@ -616,7 +605,7 @@ static int da8xx_suspend(struct device *dev)
 ret = phy_power_off(glue->phy);
 if (ret)
 return ret;
-clk_disable_unprepare(glue->clk);
+pm_runtime_put_sync(dev);


This, most probably will do nothing as Suspend framework will increase
ref counter.
Better way might be to use PM runtime force API.
pm_runtime_force_suspend()

Good catch. Effectively, the device remain active.
But we can't use pm_runtime_force_suspend() because it expect that all
child have been
runtime suspended which is usually not the case.


If this is the parent - it should be suspended the last and any children are
not expected to be accessible after that.

Yes but suspended doesn't mean runtime suspended.
In the case of system suspend, the MUSB core will be suspended but its 
runtime_status
will remain active and so pm_runtime_force_suspend() will refuse to work 
because it will

not consider the MUSB core as suspend.


Also, if there are will be force_suspend() here and force_resume() in 
da8xx_resume()
then parent should always be active before any child.

So, I seems didn't get your point :(

I think with an example and some logs it should be more clear:
rtcwake -d /dev/rtc0 -m mem -s 1
rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "mem" using /dev/rtc0 at Wed Mar 22 00:43:07 2017
PM: Syncing filesystems ... done.
Freezing user space processes ... (elapsed 0.002 seconds) done.
Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
Suspending console(s) (use no_console_suspend to debug)
davinci_mdio davinci_mdio.0: resetting idled controller
musb-da8xx musb-da8xx: runtime PM trying to suspend device but active child
PM: suspend of devices complete after 167.287 msecs
PM: late suspend of devices complete after 8.752 msecs
PM: noirq suspend of devices complete after 8.389 msecs
PM: noirq resume of devices complete after 4.385 msecs
PM: early resume of devices complete after 5.880 msecs
davinci_mdio davinci_mdio.0: resetting idled controller
SMSC LAN8710/LAN8720 davinci_mdio.0:07: attached PHY driver [SMSC 
LAN8710/LAN8720] (mii_bus:phy_addr=davinci_mdio.0:07, irq=-1)

tilcdc da8xx_lcdc.0: tilcdc_crtc_irq(0x0161): FIFO underflow
Suspended for 1.454 seconds
davinci_emac davinci_emac.1 eth0: Link is Up - 100Mbps/Full - flow 
control off

PM: resume of devices complete after 4178.211 msecs
Restarting tasks ...
usb 2-1: USB disconnect, device number 3
done.

I'm using rtcwake to test suspend / resume.
As you can see in the log, musb-da8xx doesn't complete the suspend 
because it child is active

(though it doesn't prevent the suspend to happen).
On resume, the USB device disconnects and from here the USB controller 
is dead.
It will not detect any connect / disconnect anymore. Th

Re: [RESEND PATCH v6 4/4] usb: musb: da8xx: Add a primary support of PM runtime

2017-03-27 Thread Alexandre Bailon

Hello Grygorii,
On 03/24/2017 06:26 PM, Grygorii Strashko wrote:



On 03/24/2017 09:36 AM, Alexandre Bailon wrote:
> Currently, MUSB DA8xx glue driver doesn't have PM runtime support.
> Because the CPPI 4.1 is using the same clock as MUSB DA8xx and
> CPPI 4.1 is a child of MUSB DA8xx glue, add support of PM runtime
> to the DA8xx glue driver in order to let the CPPI 4.1 driver manage
> the clock by using PM runtime.
>
> Signed-off-by: Alexandre Bailon 
> ---
>  drivers/usb/musb/da8xx.c | 27 ---
>  1 file changed, 8 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
> index ed28afd..89e12f6 100644
> --- a/drivers/usb/musb/da8xx.c
> +++ b/drivers/usb/musb/da8xx.c
> @@ -30,7 +30,6 @@
>   */
>

[...]

>
> @@ -527,12 +520,6 @@ static int da8xx_probe(struct platform_device *pdev)
>  if (!glue)
>  return -ENOMEM;
>
> -clk = devm_clk_get(&pdev->dev, "usb20");
> -if (IS_ERR(clk)) {
> -dev_err(&pdev->dev, "failed to get clock\n");
> -return PTR_ERR(clk);
> -}
> -
>  glue->phy = devm_phy_get(&pdev->dev, "usb-phy");
>  if (IS_ERR(glue->phy)) {
>  if (PTR_ERR(glue->phy) != -EPROBE_DEFER)
> @@ -541,7 +528,6 @@ static int da8xx_probe(struct platform_device *pdev)
>  }
>
>  glue->dev= &pdev->dev;
> -glue->clk= clk;
>
>  if (IS_ENABLED(CONFIG_OF) && np) {
>  pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> @@ -587,6 +573,8 @@ static int da8xx_probe(struct platform_device *pdev)
>  pinfo.data = pdata;
>  pinfo.size_data = sizeof(*pdata);
>
> +pm_runtime_enable(&pdev->dev);
> +
>  glue->musb = platform_device_register_full(&pinfo);
>  ret = PTR_ERR_OR_ZERO(glue->musb);
>  if (ret) {
> @@ -603,6 +591,7 @@ static int da8xx_remove(struct platform_device *pdev)
>
>  platform_device_unregister(glue->musb);
>  usb_phy_generic_unregister(glue->usb_phy);
> +pm_runtime_disable(&pdev->dev);
>
>  return 0;
>  }
> @@ -616,7 +605,7 @@ static int da8xx_suspend(struct device *dev)
>  ret = phy_power_off(glue->phy);
>  if (ret)
>  return ret;
> -clk_disable_unprepare(glue->clk);
> +pm_runtime_put_sync(dev);

This, most probably will do nothing as Suspend framework will increase ref 
counter.
Better way might be to use PM runtime force API. pm_runtime_force_suspend()

Good catch. Effectively, the device remain active.
But we can't use pm_runtime_force_suspend() because it expect that all child 
have been
runtime suspended which is usually not the case.


>
>  return 0;
>  }
> @@ -626,7 +615,7 @@ static int da8xx_resume(struct device *dev)
>  int ret;
>  struct da8xx_glue *glue = dev_get_drvdata(dev);
>
> -ret = clk_prepare_enable(glue->clk);
> +ret = pm_runtime_get_sync(dev);
>  if (ret)
>  return ret;

Better way might be to use PM runtime force API.

Again, it will not work. Because the forced runtime suspend will not complete
because child are not runtime suspended then the resume will not happen.


>  return phy_power_on(glue->phy);
>


Do you have any other suggestions to fix it?
My original intent was to give a way to CPPI 4.1 DMA driver to enable or
disable the usb20 clock owned DA8xx USB glue driver.

Thanks,
Alexandre
--
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


[RESEND PATCH v6 1/4] usb: musb: Use shared irq

2017-03-24 Thread Alexandre Bailon
In the DA8xx, USB and CPPI 4.1 are sharing the same interrupt line.
Update the driver to request a shared irq.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0c3664a..870da18 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2332,7 +2332,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) 
musb);
 
/* attach to the IRQ */
-   if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
+   if (request_irq(nIrq, musb->isr, IRQF_SHARED, dev_name(dev), musb)) {
dev_err(dev, "request_irq %d failed!\n", nIrq);
status = -ENODEV;
goto fail3;
-- 
2.10.2

--
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


[RESEND PATCH v6 4/4] usb: musb: da8xx: Add a primary support of PM runtime

2017-03-24 Thread Alexandre Bailon
Currently, MUSB DA8xx glue driver doesn't have PM runtime support.
Because the CPPI 4.1 is using the same clock as MUSB DA8xx and
CPPI 4.1 is a child of MUSB DA8xx glue, add support of PM runtime
to the DA8xx glue driver in order to let the CPPI 4.1 driver manage
the clock by using PM runtime.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 27 ---
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index ed28afd..89e12f6 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -30,7 +30,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -86,7 +85,6 @@ struct da8xx_glue {
struct device   *dev;
struct platform_device  *musb;
struct platform_device  *usb_phy;
-   struct clk  *clk;
struct phy  *phy;
 };
 
@@ -376,11 +374,7 @@ static int da8xx_musb_init(struct musb *musb)
 
musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
 
-   ret = clk_prepare_enable(glue->clk);
-   if (ret) {
-   dev_err(glue->dev, "failed to enable clock\n");
-   return ret;
-   }
+   pm_runtime_get_sync(musb->controller->parent);
 
/* Returns zero if e.g. not clocked */
rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
@@ -423,7 +417,7 @@ static int da8xx_musb_init(struct musb *musb)
 err_phy_power_on:
phy_exit(glue->phy);
 fail:
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put(musb->controller->parent);
return ret;
 }
 
@@ -435,7 +429,7 @@ static int da8xx_musb_exit(struct musb *musb)
 
phy_power_off(glue->phy);
phy_exit(glue->phy);
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put(musb->controller->parent);
 
usb_put_phy(musb->xceiv);
 
@@ -519,7 +513,6 @@ static int da8xx_probe(struct platform_device *pdev)
struct musb_hdrc_platform_data  *pdata = dev_get_platdata(&pdev->dev);
struct da8xx_glue   *glue;
struct platform_device_info pinfo;
-   struct clk  *clk;
struct device_node  *np = pdev->dev.of_node;
int ret;
 
@@ -527,12 +520,6 @@ static int da8xx_probe(struct platform_device *pdev)
if (!glue)
return -ENOMEM;
 
-   clk = devm_clk_get(&pdev->dev, "usb20");
-   if (IS_ERR(clk)) {
-   dev_err(&pdev->dev, "failed to get clock\n");
-   return PTR_ERR(clk);
-   }
-
glue->phy = devm_phy_get(&pdev->dev, "usb-phy");
if (IS_ERR(glue->phy)) {
if (PTR_ERR(glue->phy) != -EPROBE_DEFER)
@@ -541,7 +528,6 @@ static int da8xx_probe(struct platform_device *pdev)
}
 
glue->dev   = &pdev->dev;
-   glue->clk   = clk;
 
if (IS_ENABLED(CONFIG_OF) && np) {
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
@@ -587,6 +573,8 @@ static int da8xx_probe(struct platform_device *pdev)
pinfo.data = pdata;
pinfo.size_data = sizeof(*pdata);
 
+   pm_runtime_enable(&pdev->dev);
+
glue->musb = platform_device_register_full(&pinfo);
ret = PTR_ERR_OR_ZERO(glue->musb);
if (ret) {
@@ -603,6 +591,7 @@ static int da8xx_remove(struct platform_device *pdev)
 
platform_device_unregister(glue->musb);
usb_phy_generic_unregister(glue->usb_phy);
+   pm_runtime_disable(&pdev->dev);
 
return 0;
 }
@@ -616,7 +605,7 @@ static int da8xx_suspend(struct device *dev)
ret = phy_power_off(glue->phy);
if (ret)
return ret;
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put_sync(dev);
 
return 0;
 }
@@ -626,7 +615,7 @@ static int da8xx_resume(struct device *dev)
int ret;
struct da8xx_glue *glue = dev_get_drvdata(dev);
 
-   ret = clk_prepare_enable(glue->clk);
+   ret = pm_runtime_get_sync(dev);
if (ret)
return ret;
return phy_power_on(glue->phy);
-- 
2.10.2

--
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


[RESEND PATCH v6 2/4] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx

2017-03-24 Thread Alexandre Bailon
Currently, only the PIO mode is supported.
This add support of CPPI 4.1 to DA8xx.
As the In DA8xx the CPPI 4.1 DMA is a part of the USB.
Create the CPPI 4.1 device as a child of USB.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/Kconfig |  4 ++--
 drivers/usb/musb/da8xx.c | 36 +++-
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 72a2a50..5506a9c 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA
  Enable DMA transfers when TI CPPI DMA is available.
 
 config USB_TI_CPPI41_DMA
-   bool 'TI CPPI 4.1 (AM335x)'
-   depends on ARCH_OMAP && DMADEVICES
+   bool 'TI CPPI 4.1'
+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
select TI_CPPI41
 
 config USB_TUSB_OMAP_DMA
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d79c288..458a499 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -456,12 +457,41 @@ static inline u8 get_vbus_power(struct device *dev)
return current_uA / 1000 / 2;
 }
 
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+static void da8xx_dma_controller_callback(struct dma_controller *c)
+{
+   struct musb *musb = c->musb;
+   void __iomem *reg_base = musb->ctrl_base;
+
+   musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
+}
+
+static struct dma_controller *
+da8xx_dma_controller_create(struct musb *musb, void __iomem *base)
+{
+   struct dma_controller *controller;
+
+   controller = cppi41_dma_controller_create(musb, base);
+   if (IS_ERR_OR_NULL(controller))
+   return controller;
+
+   controller->dma_callback = da8xx_dma_controller_callback;
+
+   return controller;
+}
+#endif
+
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_INDEXED_EP | MUSB_PRESERVE_SESSION,
+   .quirks = MUSB_INDEXED_EP | MUSB_PRESERVE_SESSION |
+ MUSB_DMA_CPPI41,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
.fifo_mode  = 2,
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+   .dma_init   = da8xx_dma_controller_create,
+   .dma_exit   = cppi41_dma_controller_destroy,
+#endif
.enable = da8xx_musb_enable,
.disable= da8xx_musb_disable,
 
@@ -533,6 +563,10 @@ static int da8xx_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, glue);
 
+   ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
+   if (ret)
+   return ret;
+
memset(musb_resources, 0x00, sizeof(*musb_resources) *
ARRAY_SIZE(musb_resources));
 
-- 
2.10.2

--
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


[RESEND PATCH v6 3/4] usb: musb: musb_cppi41: Workaround DMA stall issue during teardown

2017-03-24 Thread Alexandre Bailon
The DMA may hang up if a teardown is initiated while an endpoint is still
active (Advisory 2.3.27 of DA8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c   | 2 +-
 drivers/usb/musb/musb_core.h   | 1 +
 drivers/usb/musb/musb_cppi41.c | 4 
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 458a499..ed28afd 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -483,7 +483,7 @@ da8xx_dma_controller_create(struct musb *musb, void __iomem 
*base)
 
 static const struct musb_platform_ops da8xx_ops = {
.quirks = MUSB_INDEXED_EP | MUSB_PRESERVE_SESSION |
- MUSB_DMA_CPPI41,
+ MUSB_DMA_CPPI41 | MUSB_DA8XX,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 5b708be..3e98d42 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -172,6 +172,7 @@ struct musb_io;
  */
 struct musb_platform_ops {
 
+#define MUSB_DA8XX BIT(8)
 #define MUSB_PRESERVE_SESSION  BIT(7)
 #define MUSB_DMA_UX500 BIT(6)
 #define MUSB_DMA_CPPI41BIT(5)
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 355655f..e7c8b1b 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -571,6 +571,10 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
}
}
 
+   /* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
+   if (musb->io.quirks & MUSB_DA8XX)
+   mdelay(250);
+
tdbit = 1 << cppi41_channel->port_num;
if (is_tx)
tdbit <<= 16;
-- 
2.10.2

--
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


[RESEND PATCH v6 0/4] usb: musb: da8xx: Add DMA support

2017-03-24 Thread Alexandre Bailon
This series update MUSB driver to add DMA support to DA8xx.
It should be applied on top of:
"[PATCH v4 0/3] dmaengine: cppi41: Add dma support to da8xx" and
"[PATCH v3] ARM: davinci: Make the usb20 clock available to PM runtime"

Changes in v6:
- Rebased on linux-next. Some patches were conflicting with a series
  adding suspend and resume support.

Changes in v5:
- Fix a typo in commit message of patch 4

Changes in v4:
- Update and clarify the commit message of patch 5
- Fix the typo in patch 3

Changes in v3:
- Remove PM runtime callbacks.
  I have update arch/arm/mach-davinci/pm_domain.c to let PM runtime control
  the usb20 clock.
- Only use PM runtime sync operation.

Changes in v2:
- Clock and IRQ management has been moved to MUSB DA8xx glue
  (was in CPPI 4.1 driver)
- I have added a partial support PM runtime. The goal was to use PM
  runtime to manage clock of MUSB and CPPI 4.1 (they use the same clock).
- CPPI 4.1 is now achild of MUSB DA8xx glue.

Alexandre Bailon (4):
  usb: musb: Use shared irq
  usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx
  usb: musb: musb_cppi41: Workaround DMA stall issue during teardown
  usb: musb: da8xx: Add a primary support of PM runtime

 drivers/usb/musb/Kconfig   |  4 +--
 drivers/usb/musb/da8xx.c   | 63 --
 drivers/usb/musb/musb_core.c   |  2 +-
 drivers/usb/musb/musb_core.h   |  1 +
 drivers/usb/musb/musb_cppi41.c |  4 +++
 5 files changed, 51 insertions(+), 23 deletions(-)

-- 
2.10.2

--
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: musb: cppi41: don't check early-TX-interrupt for Isoch transfer

2017-03-02 Thread Alexandre Bailon
On 03/02/2017 03:52 AM, Bin Liu wrote:
> The CPPI41 driver polls register to workaround the pre-mature TX
> interrupt issue, but it causes audio playback underrun when triggered in
> Isoch transfers.
> 
> Isoch doesn't do back-to-back transfers, the TX should be done by the
> time the next transfer is scheduled. So skip this polling workaround for
> Isoch transfer.
> 
> Fixes: a655f481d83d6 ("usb: musb: musb_cppi41: handle pre-mature TX complete 
> interrupt")
> Cc:  #4.1+
> Reported-by: Alexandre Bailon 
> Signed-off-by: Bin Liu 
> ---
>  drivers/usb/musb/musb_cppi41.c | 23 +--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
> index 00e272bfee39..355655f8a3fb 100644
> --- a/drivers/usb/musb/musb_cppi41.c
> +++ b/drivers/usb/musb/musb_cppi41.c
> @@ -238,8 +238,27 @@ static void cppi41_dma_callback(void *private_data,
>   transferred < cppi41_channel->packet_sz)
>   cppi41_channel->prog_len = 0;
>  
> - if (cppi41_channel->is_tx)
> - empty = musb_is_tx_fifo_empty(hw_ep);
> + if (cppi41_channel->is_tx) {
> + u8 type;
> +
> + if (is_host_active(musb))
> + type = hw_ep->out_qh->type;
> + else
> + type = hw_ep->ep_in.type;
> +
> + if (type == USB_ENDPOINT_XFER_ISOC)
> + /*
> +  * Don't use the early-TX-interrupt workaround below
> +  * for Isoch transfter. Since Isoch are periodic
> +  * transfer, by the time the next transfer is
> +  * scheduled, the current one should be done already.
> +  *
> +  * This avoids audio playback underrun issue.
> +  */
> + empty = true;
> + else
> + empty = musb_is_tx_fifo_empty(hw_ep);
> + }
>  
>   if (!cppi41_channel->is_tx || empty) {
>   cppi41_trans_done(cppi41_channel);
> 

Tested on omapl138-lcdk and it significantly decreases the cpu load
and then fixes the underruns.

Tested-by: Alexandre Bailon 

--
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 0/4] usb: musb: da8xx: Add DMA support

2017-02-15 Thread Alexandre Bailon
This series update MUSB driver to add DMA support to DA8xx.
It should be applied on top of:
"[PATCH v4 0/3] dmaengine: cppi41: Add dma support to da8xx" and
"[PATCH v3] ARM: davinci: Make the usb20 clock available to PM runtime"

Changes in v6:
- Rebased on linux-next. Some patches were conflicting with a series
  adding suspend and resume support.

Changes in v5:
- Fix a typo in commit message of patch 4

Changes in v4:
- Update and clarify the commit message of patch 5
- Fix the typo in patch 3

Changes in v3:
- Remove PM runtime callbacks.
  I have update arch/arm/mach-davinci/pm_domain.c to let PM runtime control
  the usb20 clock.
- Only use PM runtime sync operation.

Changes in v2:
- Clock and IRQ management has been moved to MUSB DA8xx glue
  (was in CPPI 4.1 driver)
- I have added a partial support PM runtime. The goal was to use PM
  runtime to manage clock of MUSB and CPPI 4.1 (they use the same clock).
- CPPI 4.1 is now achild of MUSB DA8xx glue.

Alexandre Bailon (4):
  usb: musb: Use shared irq
  usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx
  usb: musb: musb_cppi41: Workaround DMA stall issue during teardown
  usb: musb: da8xx: Add a primary support of PM runtime

 drivers/usb/musb/Kconfig   |  4 +--
 drivers/usb/musb/da8xx.c   | 63 --
 drivers/usb/musb/musb_core.c   |  2 +-
 drivers/usb/musb/musb_core.h   |  1 +
 drivers/usb/musb/musb_cppi41.c |  4 +++
 5 files changed, 51 insertions(+), 23 deletions(-)

-- 
2.10.2

--
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 4/4] usb: musb: da8xx: Add a primary support of PM runtime

2017-02-15 Thread Alexandre Bailon
Currently, MUSB DA8xx glue driver doesn't have PM runtime support.
Because the CPPI 4.1 is using the same clock as MUSB DA8xx and
CPPI 4.1 is a child of MUSB DA8xx glue, add support of PM runtime
to the DA8xx glue driver in order to let the CPPI 4.1 driver manage
the clock by using PM runtime.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 27 ---
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index ed28afd..89e12f6 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -30,7 +30,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -86,7 +85,6 @@ struct da8xx_glue {
struct device   *dev;
struct platform_device  *musb;
struct platform_device  *usb_phy;
-   struct clk  *clk;
struct phy  *phy;
 };
 
@@ -376,11 +374,7 @@ static int da8xx_musb_init(struct musb *musb)
 
musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
 
-   ret = clk_prepare_enable(glue->clk);
-   if (ret) {
-   dev_err(glue->dev, "failed to enable clock\n");
-   return ret;
-   }
+   pm_runtime_get_sync(musb->controller->parent);
 
/* Returns zero if e.g. not clocked */
rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
@@ -423,7 +417,7 @@ static int da8xx_musb_init(struct musb *musb)
 err_phy_power_on:
phy_exit(glue->phy);
 fail:
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put(musb->controller->parent);
return ret;
 }
 
@@ -435,7 +429,7 @@ static int da8xx_musb_exit(struct musb *musb)
 
phy_power_off(glue->phy);
phy_exit(glue->phy);
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put(musb->controller->parent);
 
usb_put_phy(musb->xceiv);
 
@@ -519,7 +513,6 @@ static int da8xx_probe(struct platform_device *pdev)
struct musb_hdrc_platform_data  *pdata = dev_get_platdata(&pdev->dev);
struct da8xx_glue   *glue;
struct platform_device_info pinfo;
-   struct clk  *clk;
struct device_node  *np = pdev->dev.of_node;
int ret;
 
@@ -527,12 +520,6 @@ static int da8xx_probe(struct platform_device *pdev)
if (!glue)
return -ENOMEM;
 
-   clk = devm_clk_get(&pdev->dev, "usb20");
-   if (IS_ERR(clk)) {
-   dev_err(&pdev->dev, "failed to get clock\n");
-   return PTR_ERR(clk);
-   }
-
glue->phy = devm_phy_get(&pdev->dev, "usb-phy");
if (IS_ERR(glue->phy)) {
if (PTR_ERR(glue->phy) != -EPROBE_DEFER)
@@ -541,7 +528,6 @@ static int da8xx_probe(struct platform_device *pdev)
}
 
glue->dev   = &pdev->dev;
-   glue->clk   = clk;
 
if (IS_ENABLED(CONFIG_OF) && np) {
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
@@ -587,6 +573,8 @@ static int da8xx_probe(struct platform_device *pdev)
pinfo.data = pdata;
pinfo.size_data = sizeof(*pdata);
 
+   pm_runtime_enable(&pdev->dev);
+
glue->musb = platform_device_register_full(&pinfo);
ret = PTR_ERR_OR_ZERO(glue->musb);
if (ret) {
@@ -603,6 +591,7 @@ static int da8xx_remove(struct platform_device *pdev)
 
platform_device_unregister(glue->musb);
usb_phy_generic_unregister(glue->usb_phy);
+   pm_runtime_disable(&pdev->dev);
 
return 0;
 }
@@ -616,7 +605,7 @@ static int da8xx_suspend(struct device *dev)
ret = phy_power_off(glue->phy);
if (ret)
return ret;
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put_sync(dev);
 
return 0;
 }
@@ -626,7 +615,7 @@ static int da8xx_resume(struct device *dev)
int ret;
struct da8xx_glue *glue = dev_get_drvdata(dev);
 
-   ret = clk_prepare_enable(glue->clk);
+   ret = pm_runtime_get_sync(dev);
if (ret)
return ret;
return phy_power_on(glue->phy);
-- 
2.10.2

--
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 3/4] usb: musb: musb_cppi41: Workaround DMA stall issue during teardown

2017-02-15 Thread Alexandre Bailon
The DMA may hang up if a teardown is initiated while an endpoint is still
active (Advisory 2.3.27 of DA8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c   | 2 +-
 drivers/usb/musb/musb_core.h   | 1 +
 drivers/usb/musb/musb_cppi41.c | 4 
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 458a499..ed28afd 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -483,7 +483,7 @@ da8xx_dma_controller_create(struct musb *musb, void __iomem 
*base)
 
 static const struct musb_platform_ops da8xx_ops = {
.quirks = MUSB_INDEXED_EP | MUSB_PRESERVE_SESSION |
- MUSB_DMA_CPPI41,
+ MUSB_DMA_CPPI41 | MUSB_DA8XX,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 5b708be..3e98d42 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -172,6 +172,7 @@ struct musb_io;
  */
 struct musb_platform_ops {
 
+#define MUSB_DA8XX BIT(8)
 #define MUSB_PRESERVE_SESSION  BIT(7)
 #define MUSB_DMA_UX500 BIT(6)
 #define MUSB_DMA_CPPI41BIT(5)
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 00e272b..2df37be 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -552,6 +552,10 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
}
}
 
+   /* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
+   if (musb->io.quirks & MUSB_DA8XX)
+   mdelay(250);
+
tdbit = 1 << cppi41_channel->port_num;
if (is_tx)
tdbit <<= 16;
-- 
2.10.2

--
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 1/4] usb: musb: Use shared irq

2017-02-15 Thread Alexandre Bailon
In the DA8xx, USB and CPPI 4.1 are sharing the same interrupt line.
Update the driver to request a shared irq.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 892088f..c476265 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2331,7 +2331,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) 
musb);
 
/* attach to the IRQ */
-   if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
+   if (request_irq(nIrq, musb->isr, IRQF_SHARED, dev_name(dev), musb)) {
dev_err(dev, "request_irq %d failed!\n", nIrq);
status = -ENODEV;
goto fail3;
-- 
2.10.2

--
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 2/4] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx

2017-02-15 Thread Alexandre Bailon
Currently, only the PIO mode is supported.
This add support of CPPI 4.1 to DA8xx.
As the In DA8xx the CPPI 4.1 DMA is a part of the USB.
Create the CPPI 4.1 device as a child of USB.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/Kconfig |  4 ++--
 drivers/usb/musb/da8xx.c | 36 +++-
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 72a2a50..5506a9c 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA
  Enable DMA transfers when TI CPPI DMA is available.
 
 config USB_TI_CPPI41_DMA
-   bool 'TI CPPI 4.1 (AM335x)'
-   depends on ARCH_OMAP && DMADEVICES
+   bool 'TI CPPI 4.1'
+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
select TI_CPPI41
 
 config USB_TUSB_OMAP_DMA
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d79c288..458a499 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -456,12 +457,41 @@ static inline u8 get_vbus_power(struct device *dev)
return current_uA / 1000 / 2;
 }
 
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+static void da8xx_dma_controller_callback(struct dma_controller *c)
+{
+   struct musb *musb = c->musb;
+   void __iomem *reg_base = musb->ctrl_base;
+
+   musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
+}
+
+static struct dma_controller *
+da8xx_dma_controller_create(struct musb *musb, void __iomem *base)
+{
+   struct dma_controller *controller;
+
+   controller = cppi41_dma_controller_create(musb, base);
+   if (IS_ERR_OR_NULL(controller))
+   return controller;
+
+   controller->dma_callback = da8xx_dma_controller_callback;
+
+   return controller;
+}
+#endif
+
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_INDEXED_EP | MUSB_PRESERVE_SESSION,
+   .quirks = MUSB_INDEXED_EP | MUSB_PRESERVE_SESSION |
+ MUSB_DMA_CPPI41,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
.fifo_mode  = 2,
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+   .dma_init   = da8xx_dma_controller_create,
+   .dma_exit   = cppi41_dma_controller_destroy,
+#endif
.enable = da8xx_musb_enable,
.disable= da8xx_musb_disable,
 
@@ -533,6 +563,10 @@ static int da8xx_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, glue);
 
+   ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
+   if (ret)
+   return ret;
+
memset(musb_resources, 0x00, sizeof(*musb_resources) *
ARRAY_SIZE(musb_resources));
 
-- 
2.10.2

--
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 3/5] dmaengine: cppi41: Move some constants to glue layer

2017-02-15 Thread Alexandre Bailon
Some constants are defined and use by the driver whereas they are
specifics to AM335x.
Add new variables to the glue layer, initialize them with the constants,
and use them in the driver.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index d1b5569..676228f 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -68,7 +68,6 @@
 #define QMGR_MEMCTRL_IDX_SH16
 #define QMGR_MEMCTRL_DESC_SH   8
 
-#define QMGR_NUM_PEND  5
 #define QMGR_PEND(x)   (0x90 + (x) * 4)
 
 #define QMGR_PENDING_SLOT_Q(x) (x / 32)
@@ -138,6 +137,8 @@ struct cppi41_dd {
const struct chan_queues *queues_rx;
const struct chan_queues *queues_tx;
struct chan_queues td_queue;
+   u16 first_completion_queue;
+   u16 qmgr_num_pend;
 
struct list_head pending;   /* Pending queued transfers */
spinlock_t lock;/* Lock for pending list */
@@ -148,7 +149,6 @@ struct cppi41_dd {
bool is_suspended;
 };
 
-#define FIST_COMPLETION_QUEUE  93
 static struct chan_queues am335x_usb_queues_tx[] = {
/* USB0 ENDP 1 */
[ 0] = { .submit = 32, .complete =  93},
@@ -226,6 +226,8 @@ struct cppi_glue_infos {
const struct chan_queues *queues_rx;
const struct chan_queues *queues_tx;
struct chan_queues td_queue;
+   u16 first_completion_queue;
+   u16 qmgr_num_pend;
 };
 
 static struct cppi41_channel *to_cpp41_chan(struct dma_chan *c)
@@ -284,19 +286,21 @@ static u32 cppi41_pop_desc(struct cppi41_dd *cdd, 
unsigned queue_num)
 static irqreturn_t cppi41_irq(int irq, void *data)
 {
struct cppi41_dd *cdd = data;
+   u16 first_completion_queue = cdd->first_completion_queue;
+   u16 qmgr_num_pend = cdd->qmgr_num_pend;
struct cppi41_channel *c;
int i;
 
-   for (i = QMGR_PENDING_SLOT_Q(FIST_COMPLETION_QUEUE); i < QMGR_NUM_PEND;
+   for (i = QMGR_PENDING_SLOT_Q(first_completion_queue); i < qmgr_num_pend;
i++) {
u32 val;
u32 q_num;
 
val = cppi_readl(cdd->qmgr_mem + QMGR_PEND(i));
-   if (i == QMGR_PENDING_SLOT_Q(FIST_COMPLETION_QUEUE) && val) {
+   if (i == QMGR_PENDING_SLOT_Q(first_completion_queue) && val) {
u32 mask;
/* set corresponding bit for completetion Q 93 */
-   mask = 1 << QMGR_PENDING_BIT_Q(FIST_COMPLETION_QUEUE);
+   mask = 1 << QMGR_PENDING_BIT_Q(first_completion_queue);
/* not set all bits for queues less than Q 93 */
mask--;
/* now invert and keep only Q 93+ set */
@@ -884,7 +888,7 @@ static int init_cppi41(struct device *dev, struct cppi41_dd 
*cdd)
return -ENOMEM;
 
cppi_writel(cdd->scratch_phys, cdd->qmgr_mem + QMGR_LRAM0_BASE);
-   cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE);
+   cppi_writel(TOTAL_DESCS_NUM, cdd->qmgr_mem + QMGR_LRAM_SIZE);
cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE);
 
ret = init_descs(dev, cdd);
@@ -967,6 +971,8 @@ static const struct cppi_glue_infos am335x_usb_infos = {
.queues_rx = am335x_usb_queues_rx,
.queues_tx = am335x_usb_queues_tx,
.td_queue = { .submit = 31, .complete = 0 },
+   .first_completion_queue = 93,
+   .qmgr_num_pend = 5,
 };
 
 static const struct of_device_id cppi41_dma_ids[] = {
@@ -1049,6 +1055,8 @@ static int cppi41_dma_probe(struct platform_device *pdev)
cdd->queues_rx = glue_info->queues_rx;
cdd->queues_tx = glue_info->queues_tx;
cdd->td_queue = glue_info->td_queue;
+   cdd->qmgr_num_pend = glue_info->qmgr_num_pend;
+   cdd->first_completion_queue = glue_info->first_completion_queue;
 
ret = init_cppi41(dev, cdd);
if (ret)
-- 
2.10.2

--
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 2/5] dmaengine: cppi41: rename platform variables

2017-02-15 Thread Alexandre Bailon
Currently, only the AM335x is supported by the driver.
Though the driver has a glue layer to support different platforms,
some platform variable names are not prefixed with the platform name.
To facilitate the addition of a new platform,
rename some variables owned by the AM335x glue.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 34a8156..d1b5569 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -149,7 +149,7 @@ struct cppi41_dd {
 };
 
 #define FIST_COMPLETION_QUEUE  93
-static struct chan_queues usb_queues_tx[] = {
+static struct chan_queues am335x_usb_queues_tx[] = {
/* USB0 ENDP 1 */
[ 0] = { .submit = 32, .complete =  93},
[ 1] = { .submit = 34, .complete =  94},
@@ -185,7 +185,7 @@ static struct chan_queues usb_queues_tx[] = {
[29] = { .submit = 90, .complete = 139},
 };
 
-static const struct chan_queues usb_queues_rx[] = {
+static const struct chan_queues am335x_usb_queues_rx[] = {
/* USB0 ENDP 1 */
[ 0] = { .submit =  1, .complete = 109},
[ 1] = { .submit =  2, .complete = 110},
@@ -932,8 +932,9 @@ static bool cpp41_dma_filter_fn(struct dma_chan *chan, void 
*param)
else
queues = cdd->queues_rx;
 
-   BUILD_BUG_ON(ARRAY_SIZE(usb_queues_rx) != ARRAY_SIZE(usb_queues_tx));
-   if (WARN_ON(cchan->port_num > ARRAY_SIZE(usb_queues_rx)))
+   BUILD_BUG_ON(ARRAY_SIZE(am335x_usb_queues_rx) !=
+ARRAY_SIZE(am335x_usb_queues_tx));
+   if (WARN_ON(cchan->port_num > ARRAY_SIZE(am335x_usb_queues_rx)))
return false;
 
cchan->q_num = queues[cchan->port_num].submit;
@@ -961,15 +962,15 @@ static struct dma_chan *cppi41_dma_xlate(struct 
of_phandle_args *dma_spec,
&dma_spec->args[0]);
 }
 
-static const struct cppi_glue_infos usb_infos = {
+static const struct cppi_glue_infos am335x_usb_infos = {
.isr = cppi41_irq,
-   .queues_rx = usb_queues_rx,
-   .queues_tx = usb_queues_tx,
+   .queues_rx = am335x_usb_queues_rx,
+   .queues_tx = am335x_usb_queues_tx,
.td_queue = { .submit = 31, .complete = 0 },
 };
 
 static const struct of_device_id cppi41_dma_ids[] = {
-   { .compatible = "ti,am3359-cppi41", .data = &usb_infos},
+   { .compatible = "ti,am3359-cppi41", .data = &am335x_usb_infos},
{},
 };
 MODULE_DEVICE_TABLE(of, cppi41_dma_ids);
-- 
2.10.2

--
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 4/5] dmaengine: cppi41: init_sched(): Get number of channels from DT

2017-02-15 Thread Alexandre Bailon
Despite the driver is already using DT to get the number of channels,
init_sched() is using an hardcoded value to get it.
Use DT to get the number of channels.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 20 
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 676228f..54337cd 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -139,6 +139,8 @@ struct cppi41_dd {
struct chan_queues td_queue;
u16 first_completion_queue;
u16 qmgr_num_pend;
+   u32 n_chans;
+   u8 platform;
 
struct list_head pending;   /* Pending queued transfers */
spinlock_t lock;/* Lock for pending list */
@@ -742,13 +744,8 @@ static int cppi41_add_chans(struct device *dev, struct 
cppi41_dd *cdd)
 {
struct cppi41_channel *cchan;
int i;
-   int ret;
-   u32 n_chans;
+   u32 n_chans = cdd->n_chans;
 
-   ret = of_property_read_u32(dev->of_node, "#dma-channels",
-   &n_chans);
-   if (ret)
-   return ret;
/*
 * The channels can only be used as TX or as RX. So we add twice
 * that much dma channels because USB can only do RX or TX.
@@ -862,7 +859,7 @@ static void init_sched(struct cppi41_dd *cdd)
 
word = 0;
cppi_writel(0, cdd->sched_mem + DMA_SCHED_CTRL);
-   for (ch = 0; ch < 15 * 2; ch += 2) {
+   for (ch = 0; ch < cdd->n_chans; ch += 2) {
 
reg = SCHED_ENTRY0_CHAN(ch);
reg |= SCHED_ENTRY1_CHAN(ch) | SCHED_ENTRY1_IS_RX;
@@ -872,7 +869,7 @@ static void init_sched(struct cppi41_dd *cdd)
cppi_writel(reg, cdd->sched_mem + DMA_SCHED_WORD(word));
word++;
}
-   reg = 15 * 2 * 2 - 1;
+   reg = cdd->n_chans * 2 - 1;
reg |= DMA_SCHED_CTRL_EN;
cppi_writel(reg, cdd->sched_mem + DMA_SCHED_CTRL);
 }
@@ -897,6 +894,7 @@ static int init_cppi41(struct device *dev, struct cppi41_dd 
*cdd)
 
cppi_writel(cdd->td_queue.submit, cdd->ctrl_mem + DMA_TDFDQ);
init_sched(cdd);
+
return 0;
 err_td:
deinit_cppi41(dev, cdd);
@@ -1058,6 +1056,11 @@ static int cppi41_dma_probe(struct platform_device *pdev)
cdd->qmgr_num_pend = glue_info->qmgr_num_pend;
cdd->first_completion_queue = glue_info->first_completion_queue;
 
+   ret = of_property_read_u32(dev->of_node,
+  "#dma-channels", &cdd->n_chans);
+   if (ret)
+   goto err_get_n_chans;
+
ret = init_cppi41(dev, cdd);
if (ret)
goto err_init_cppi;
@@ -1100,6 +1103,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
deinit_cppi41(dev, cdd);
 err_init_cppi:
pm_runtime_dont_use_autosuspend(dev);
+err_get_n_chans:
 err_get_sync:
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
-- 
2.10.2

--
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 0/5] dmaengine: cppi41: Make CPPI 4.1 driver more generic

2017-02-15 Thread Alexandre Bailon
This series intend to make the CPPI 4.1 more generic in order to
add a new platform (the DA8xx).
To achieve that, all the IRQ code present in CPPI 4.1 driver has been moved
to MUSB DSPS driver.
Other changes mainly update the glue layer and platform code to make the
whole driver more generic.

Changes in v5:
 - Rebase on linux-next
 - No dependencies on other series anymore (they have been applied)

Changes in v4:
 - Remove dev argument in patch 4
 - Remove the isr callback from glue

Changes in v3:
- To prevent build error report from kbuild test robot, move the first
  patch of v2 to another patchset.
- Make CPPI 4.1 driver compatible with old and new binddings.
- Remove the patch updating the am33xx-usb binddings.
- Remove useless changes in patch 4
- Remove a patch that was fixing PM runtime issue that was happenning
  during a teardown. Tony Lindgren's patches fix the issue.

Alexandre Bailon (5):
  dmaengine: cppi41: Remove usbss_mem
  dmaengine: cppi41: rename platform variables
  dmaengine: cppi41: Move some constants to glue layer
  dmaengine: cppi41: init_sched(): Get number of channels from DT
  dmaengine: cppi41: Remove isr callback from glue layer

 drivers/dma/cppi41.c | 79 ++--
 1 file changed, 46 insertions(+), 33 deletions(-)

-- 
2.10.2

--
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 1/5] dmaengine: cppi41: Remove usbss_mem

2017-02-15 Thread Alexandre Bailon
In order to make CPPI 4.1 DMA driver more generic, accesses to USBSS
have been removed. So it is not required anymore to map the "glue"
register's.
Remove usbss_mem.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index d74cee0..34a8156 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -131,7 +131,6 @@ struct cppi41_dd {
u32 first_td_desc;
struct cppi41_channel *chan_busy[ALLOC_DECS_NUM];
 
-   void __iomem *usbss_mem;
void __iomem *ctrl_mem;
void __iomem *sched_mem;
void __iomem *qmgr_mem;
@@ -995,6 +994,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
struct cppi41_dd *cdd;
struct device *dev = &pdev->dev;
const struct cppi_glue_infos *glue_info;
+   int index;
int irq;
int ret;
 
@@ -1021,16 +1021,20 @@ static int cppi41_dma_probe(struct platform_device 
*pdev)
INIT_LIST_HEAD(&cdd->ddev.channels);
cpp41_dma_info.dma_cap = cdd->ddev.cap_mask;
 
-   cdd->usbss_mem = of_iomap(dev->of_node, 0);
-   cdd->ctrl_mem = of_iomap(dev->of_node, 1);
-   cdd->sched_mem = of_iomap(dev->of_node, 2);
-   cdd->qmgr_mem = of_iomap(dev->of_node, 3);
+   index = of_property_match_string(dev->of_node,
+"reg-names", "controller");
+   if (index < 0)
+   return index;
+
+   cdd->ctrl_mem = of_iomap(dev->of_node, index);
+   cdd->sched_mem = of_iomap(dev->of_node, index + 1);
+   cdd->qmgr_mem = of_iomap(dev->of_node, index + 2);
spin_lock_init(&cdd->lock);
INIT_LIST_HEAD(&cdd->pending);
 
platform_set_drvdata(pdev, cdd);
 
-   if (!cdd->usbss_mem || !cdd->ctrl_mem || !cdd->sched_mem ||
+   if (!cdd->ctrl_mem || !cdd->sched_mem ||
!cdd->qmgr_mem)
return -ENXIO;
 
@@ -1090,7 +1094,6 @@ static int cppi41_dma_probe(struct platform_device *pdev)
 err_get_sync:
pm_runtime_put_sync(dev);
pm_runtime_disable(dev);
-   iounmap(cdd->usbss_mem);
iounmap(cdd->ctrl_mem);
iounmap(cdd->sched_mem);
iounmap(cdd->qmgr_mem);
@@ -1112,7 +1115,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)
devm_free_irq(&pdev->dev, cdd->irq, cdd);
cleanup_chans(cdd);
deinit_cppi41(&pdev->dev, cdd);
-   iounmap(cdd->usbss_mem);
iounmap(cdd->ctrl_mem);
iounmap(cdd->sched_mem);
iounmap(cdd->qmgr_mem);
-- 
2.10.2

--
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 5/5] dmaengine: cppi41: Remove isr callback from glue layer

2017-02-15 Thread Alexandre Bailon
All the platform code to manage IRQ has been moved to MUSB,
and now the interrupt handler is completely generic.
Remove the isr callback that is not useful anymore.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 54337cd..4573080 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -224,7 +224,6 @@ static const struct chan_queues am335x_usb_queues_rx[] = {
 };
 
 struct cppi_glue_infos {
-   irqreturn_t (*isr)(int irq, void *data);
const struct chan_queues *queues_rx;
const struct chan_queues *queues_tx;
struct chan_queues td_queue;
@@ -965,7 +964,6 @@ static struct dma_chan *cppi41_dma_xlate(struct 
of_phandle_args *dma_spec,
 }
 
 static const struct cppi_glue_infos am335x_usb_infos = {
-   .isr = cppi41_irq,
.queues_rx = am335x_usb_queues_rx,
.queues_tx = am335x_usb_queues_tx,
.td_queue = { .submit = 31, .complete = 0 },
@@ -1075,7 +1073,7 @@ static int cppi41_dma_probe(struct platform_device *pdev)
goto err_irq;
}
 
-   ret = devm_request_irq(&pdev->dev, irq, glue_info->isr, IRQF_SHARED,
+   ret = devm_request_irq(&pdev->dev, irq, cppi41_irq, IRQF_SHARED,
dev_name(dev), cdd);
if (ret)
goto err_irq;
-- 
2.10.2

--
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 v4 0/3] dmaengine: cppi41: Add dma support to da8xx

2017-01-30 Thread Alexandre Bailon
This series add support of DA8xx to CPPI 4.1 driver.
As the CPPI 4.1 is now generic, we only had to add the glue for DA8xx.

This serie should applied on top of 
"[PATCH v3 0/7] dmaengine: cppi41: Make CPPI 4.1 driver more generic".

Changes in v4:
 - Fix the address overlaping between usb and cppi41 nodes.

Changes in v3:
 - Fix few typos
 - Don't use a wildcard for the compatible property

Changes in v2:
- most of patches of v1 has been moved to the series
  "[PATCH v2 0/7] dmaengine: cppi41: Make CPPI 4.1 driver more generic".
- some patches of v1 has been removed because they were no required
  anymore because CPPI 4.1 driver has been made more generic.
- In v1, the driver were managing the clock for DA8xx paltform.
  This is not needed as CPPI 4.1 will be a child of MUSB DA8xx glue,
  we can use PM runtime and let the DA8xx glue driver manage it.

Alexandre Bailon (3):
  dt/bindings: da8xx-usb: Add binding for the CPPI 4.1 DMA controller
  dmaengine: cppi41: Add support of DA8xx to CPPI 4.1
  dmaengine: cppi41: Fix teardown warnings

 .../devicetree/bindings/usb/da8xx-usb.txt  | 41 +-
 drivers/dma/Kconfig|  6 ++--
 drivers/dma/cppi41.c   | 27 --
 3 files changed, 68 insertions(+), 6 deletions(-)

-- 
2.10.2

--
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 v4 2/3] dmaengine: cppi41: Add support of DA8xx to CPPI 4.1

2017-01-30 Thread Alexandre Bailon
The DA8xx has a CPPI 4.1 DMA controller.
This is add the glue layer required to make it work on DA8xx.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/Kconfig  |  6 +++---
 drivers/dma/cppi41.c | 23 +++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 0d6a96e..2a31e1a 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -514,12 +514,12 @@ config TIMB_DMA
  Enable support for the Timberdale FPGA DMA engine.
 
 config TI_CPPI41
-   tristate "AM33xx CPPI41 DMA support"
-   depends on ARCH_OMAP
+   tristate "CPPI 4.1 DMA support"
+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX)
select DMA_ENGINE
help
  The Communications Port Programming Interface (CPPI) 4.1 DMA engine
- is currently used by the USB driver on AM335x platforms.
+ is currently used by the USB driver on AM335x and DA8xx platforms.
 
 config TI_DMA_CROSSBAR
bool
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 21a4f79..5c501da 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -221,6 +221,20 @@ static const struct chan_queues am335x_usb_queues_rx[] = {
[29] = { .submit = 30, .complete = 155},
 };
 
+static const struct chan_queues da8xx_usb_queues_tx[] = {
+   [0] = { .submit =  16, .complete = 24},
+   [1] = { .submit =  18, .complete = 24},
+   [2] = { .submit =  20, .complete = 24},
+   [3] = { .submit =  22, .complete = 24},
+};
+
+static const struct chan_queues da8xx_usb_queues_rx[] = {
+   [0] = { .submit =  1, .complete = 26},
+   [1] = { .submit =  3, .complete = 26},
+   [2] = { .submit =  5, .complete = 26},
+   [3] = { .submit =  7, .complete = 26},
+};
+
 struct cppi_glue_infos {
const struct chan_queues *queues_rx;
const struct chan_queues *queues_tx;
@@ -949,8 +963,17 @@ static const struct cppi_glue_infos am335x_usb_infos = {
.qmgr_num_pend = 5,
 };
 
+static const struct cppi_glue_infos da8xx_usb_infos = {
+   .queues_rx = da8xx_usb_queues_rx,
+   .queues_tx = da8xx_usb_queues_tx,
+   .td_queue = { .submit = 31, .complete = 0 },
+   .first_completion_queue = 24,
+   .qmgr_num_pend = 2,
+};
+
 static const struct of_device_id cppi41_dma_ids[] = {
{ .compatible = "ti,am3359-cppi41", .data = &am335x_usb_infos},
+   { .compatible = "ti,da830-cppi41", .data = &da8xx_usb_infos},
{},
 };
 MODULE_DEVICE_TABLE(of, cppi41_dma_ids);
-- 
2.10.2

--
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 v4 3/3] dmaengine: cppi41: Fix teardown warnings

2017-01-30 Thread Alexandre Bailon
During the teardown of a RX channel, because there is only one
completion queue available for RX channel, descriptor of another
channel may be popped which will cause 2 warnings:
- the first one because we popped a wrong descriptor
  (neither the channel's descriptor, nor the teardown descriptor).
- the second one happen during the teardown of another channel,
  because we can't find the channel descriptor
  (that is, the one that caused the first warning).
To avoid that, use one free queue instead of a transmit completion queue.

Note that fix doesn't fix all the teardown warnings:
I still get some when I run some corner case.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 5c501da..9fdd824 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -629,7 +629,7 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c)
if (!c->is_tx) {
reg |= GCR_STARV_RETRY;
reg |= GCR_DESC_TYPE_HOST;
-   reg |= c->q_comp_num;
+   reg |= cdd->td_queue.complete;
}
reg |= GCR_TEARDOWN;
cppi_writel(reg, c->gcr_reg);
@@ -640,7 +640,7 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c)
if (!c->td_seen || !c->td_desc_seen) {
 
desc_phys = cppi41_pop_desc(cdd, cdd->td_queue.complete);
-   if (!desc_phys)
+   if (!desc_phys && c->is_tx)
desc_phys = cppi41_pop_desc(cdd, c->q_comp_num);
 
if (desc_phys == c->desc_phys) {
-- 
2.10.2

--
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] ARM: dts: da850: Add the CPPI 4.1 DMA to the USB OTG controller

2017-01-30 Thread Alexandre Bailon
This adds the CPPI 4.1 DMA controller to the USB OTG controller.

Changes since v4:
 - Fix the overlaping address between usb and cppi41 nodes.

Signed-off-by: Alexandre Bailon 
---
 arch/arm/boot/dts/da850.dtsi | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 104155d..70ad3e8 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -395,13 +395,38 @@
};
usb0: usb@20 {
compatible = "ti,da830-musb";
-   reg = <0x20 0x1>;
+   reg = <0x20 0x1000>;
+   ranges;
interrupts = <58>;
interrupt-names = "mc";
dr_mode = "otg";
phys = <&usb_phy 0>;
phy-names = "usb-phy";
status = "disabled";
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   dmas = <&cppi41dma 0 0 &cppi41dma 1 0
+   &cppi41dma 2 0 &cppi41dma 3 0
+   &cppi41dma 0 1 &cppi41dma 1 1
+   &cppi41dma 2 1 &cppi41dma 3 1>;
+   dma-names =
+   "rx1", "rx2", "rx3", "rx4",
+   "tx1", "tx2", "tx3", "tx4";
+
+   cppi41dma: dma-controller@201000 {
+   compatible = "ti,da830-cppi41";
+   reg =  <0x201000 0x1000
+   0x202000 0x1000
+   0x204000 0x4000>;
+   reg-names = "controller",
+   "scheduler", "queuemgr";
+   interrupts = <58>;
+   #dma-cells = <2>;
+   #dma-channels = <4>;
+   status = "okay";
+   };
};
mdio: mdio@224000 {
compatible = "ti,davinci_mdio";
-- 
2.10.2

--
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 v4 1/3] dt/bindings: da8xx-usb: Add binding for the CPPI 4.1 DMA controller

2017-01-30 Thread Alexandre Bailon
DT binding for the TI DA8xx/OMAP-L1x/AM17xx/AM18xx CPPI 4.1 DMA controller.

Signed-off-by: Alexandre Bailon 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/usb/da8xx-usb.txt  | 41 +-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/da8xx-usb.txt 
b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
index ccb844a..717c5f6 100644
--- a/Documentation/devicetree/bindings/usb/da8xx-usb.txt
+++ b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
@@ -18,10 +18,26 @@ Required properties:
 
  - phy-names: Should be "usb-phy"
 
+ - dmas: specifies the dma channels
+
+ - dma-names: specifies the names of the channels. Use "rxN" for receive
+   and "txN" for transmit endpoints. N specifies the endpoint number.
+
 Optional properties:
 
  - vbus-supply: Phandle to a regulator providing the USB bus power.
 
+DMA
+~~~
+- compatible: ti,da830-cppi41
+- reg: offset and length of the following register spaces: CPPI DMA Controller,
+  CPPI DMA Scheduler, Queue Manager
+- reg-names: "controller", "scheduler", "queuemgr"
+- #dma-cells: should be set to 2. The first number represents the
+  channel number (0 … 3 for endpoints 1 … 4).
+  The second number is 0 for RX and 1 for TX transfers.
+- #dma-channels: should be set to 4 representing the 4 endpoints.
+
 Example:
usb_phy: usb-phy {
compatible = "ti,da830-usb-phy";
@@ -30,7 +46,10 @@ Example:
};
usb0: usb@20 {
compatible = "ti,da830-musb";
-   reg =   <0x0020 0x1>;
+   reg = <0x0020 0x1000>;
+   ranges;
+   #address-cells = <1>;
+   #size-cells = <1>;
interrupts = <58>;
interrupt-names = "mc";
 
@@ -39,5 +58,25 @@ Example:
phys = <&usb_phy 0>;
phy-names = "usb-phy";
 
+   dmas = <&cppi41dma 0 0 &cppi41dma 1 0
+   &cppi41dma 2 0 &cppi41dma 3 0
+   &cppi41dma 0 1 &cppi41dma 1 1
+   &cppi41dma 2 1 &cppi41dma 3 1>;
+   dma-names =
+   "rx1", "rx2", "rx3", "rx4",
+   "tx1", "tx2", "tx3", "tx4";
+
status = "okay";
+
+   cppi41dma: dma-controller@201000 {
+   compatible = "ti,da830-cppi41";
+   reg =  <0x201000 0x1000
+   0x202000 0x1000
+   0x204000 0x4000>;
+   reg-names = "controller", "scheduler", "queuemgr";
+   interrupts = <58>;
+   #dma-cells = <2>;
+   #dma-channels = <4>;
+   };
+
};
-- 
2.10.2

--
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 v3] ARM: davinci: Make the usb20 clock available to PM runtime

2017-01-25 Thread Alexandre Bailon
Since USB20 subsystem uses just one clock, there is no need of a con_id,
so we are using NULL.

Signed-off-by: Alexandre Bailon 
Suggested-by: Sekhar Nori 
---
 arch/arm/mach-davinci/da830.c | 2 +-
 arch/arm/mach-davinci/da850.c | 2 +-
 arch/arm/mach-davinci/usb-da8xx.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 073c458..2cfd9d7 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -412,7 +412,7 @@ static struct clk_lookup da830_clks[] = {
CLK("davinci-mcasp.0",  NULL,   &mcasp0_clk),
CLK("davinci-mcasp.1",  NULL,   &mcasp1_clk),
CLK("davinci-mcasp.2",  NULL,   &mcasp2_clk),
-   CLK("musb-da8xx",   "usb20",&usb20_clk),
+   CLK("musb-da8xx",   NULL,   &usb20_clk),
CLK(NULL,   "aemif",&aemif_clk),
CLK(NULL,   "aintc",&aintc_clk),
CLK(NULL,   "secu_mgr", &secu_mgr_clk),
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 9780829..5fe32ae 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -559,7 +559,7 @@ static struct clk_lookup da850_clks[] = {
CLK("ti-aemif", NULL,   &aemif_clk),
CLK("davinci-nand.0",   "aemif",&aemif_nand_clk),
CLK("ohci-da8xx",   "usb11",&usb11_clk),
-   CLK("musb-da8xx",   "usb20",&usb20_clk),
+   CLK("musb-da8xx",   NULL,   &usb20_clk),
CLK("spi_davinci.0",NULL,   &spi0_clk),
CLK("spi_davinci.1",NULL,   &spi1_clk),
CLK("vpif", NULL,   &vpif_clk),
diff --git a/arch/arm/mach-davinci/usb-da8xx.c 
b/arch/arm/mach-davinci/usb-da8xx.c
index 9a6af0b..9b66768 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -275,7 +275,7 @@ int __init da8xx_register_usb20_phy_clk(bool 
use_usb_refclkin)
struct clk *parent;
int ret;
 
-   usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20");
+   usb20_clk = clk_get(&da8xx_usb20_dev.dev, NULL);
ret = PTR_ERR_OR_ZERO(usb20_clk);
if (ret)
return ret;
-- 
2.10.2

--
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 0/5] usb: musb: da8xx: Add DMA support

2017-01-25 Thread Alexandre Bailon
This series update MUSB driver to add DMA support to DA8xx.
It should be applied on top of
"[PATCH v3 0/3] usb: musb: cppi41: Add a way to manage DMA irq" but
"[PATCH v3 0/3] dmaengine: cppi41: Add dma support to da8xx" and
"[PATCH] arm: davinci: Make the usb20 clock available to PM runtime"
are required to make it work.

Changes in v5:
- Fix a typo in commit message of patch 4

Changes in v4:
- Update and clarify the commit message of patch 5
- Fix the typo in patch 3

Changes in v3:
- Remove PM runtime callbacks.
  I have update arch/arm/mach-davinci/pm_domain.c to let PM runtime control
  the usb20 clock.
- Only use PM runtime sync operation.

Changes in v2:
- Clock and IRQ management has been moved to MUSB DA8xx glue
  (was in CPPI 4.1 driver)
- I have added a partial support PM runtime. The goal was to use PM
  runtime to manage clock of MUSB and CPPI 4.1 (they use the same clock).
- CPPI 4.1 is now achild of MUSB DA8xx glue.

Alexandre Bailon (5):
  usb: musb: da8xx: Remove CPPI 3.0 quirk and methods
  usb: musb: Use shared irq
  usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx
  usb: musb: musb_cppi41: Workaround DMA stall issue during teardown
  usb: musb: da8xx: Add a primary support of PM runtime

 drivers/usb/musb/Kconfig   |  4 +--
 drivers/usb/musb/da8xx.c   | 60 +++---
 drivers/usb/musb/musb_core.c   |  2 +-
 drivers/usb/musb/musb_core.h   |  1 +
 drivers/usb/musb/musb_cppi41.c |  4 +++
 5 files changed, 47 insertions(+), 24 deletions(-)

-- 
2.10.2

--
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 1/5] usb: musb: da8xx: Remove CPPI 3.0 quirk and methods

2017-01-25 Thread Alexandre Bailon
DA8xx driver is registering and using the CPPI 3.0 DMA controller but
actually, the DA8xx has a CPPI 4.1 DMA controller.
Remove the CPPI 3.0 quirk and methods.

Fixes: f8e9f34f80a2 ("usb: musb: Fix up DMA related macros")
Fixes: 7f6283ed6fe8 ("usb: musb: Set up function pointers for DMA")
Signed-off-by: Alexandre Bailon 
Acked-by: Sergei Shtylyov 
Acked-by: Tony Lindgren 
---
 drivers/usb/musb/da8xx.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index e89708d..cd3d763 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -458,15 +458,11 @@ static inline u8 get_vbus_power(struct device *dev)
 }
 
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_DMA_CPPI | MUSB_INDEXED_EP,
+   .quirks = MUSB_INDEXED_EP,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
.fifo_mode  = 2,
-#ifdef CONFIG_USB_TI_CPPI_DMA
-   .dma_init   = cppi_dma_controller_create,
-   .dma_exit   = cppi_dma_controller_destroy,
-#endif
.enable = da8xx_musb_enable,
.disable= da8xx_musb_disable,
 
-- 
2.10.2

--
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 2/5] usb: musb: Use shared irq

2017-01-25 Thread Alexandre Bailon
In the DA8xx, USB and CPPI 4.1 are sharing the same interrupt line.
Update the driver to request a shared irq.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index fca288bb..cf40adf 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2329,7 +2329,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) 
musb);
 
/* attach to the IRQ */
-   if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
+   if (request_irq(nIrq, musb->isr, IRQF_SHARED, dev_name(dev), musb)) {
dev_err(dev, "request_irq %d failed!\n", nIrq);
status = -ENODEV;
goto fail3;
-- 
2.10.2

--
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 4/5] usb: musb: musb_cppi41: Workaround DMA stall issue during teardown

2017-01-25 Thread Alexandre Bailon
The DMA may hang up if a teardown is initiated while an endpoint is still
active (Advisory 2.3.27 of DA8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c   | 2 +-
 drivers/usb/musb/musb_core.h   | 1 +
 drivers/usb/musb/musb_cppi41.c | 4 
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d279438..d87fb9b 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -483,7 +483,7 @@ da8xx_dma_controller_create(struct musb *musb, void __iomem 
*base)
 #endif
 
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41,
+   .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41 | MUSB_DA8XX,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index ade902e..d129278 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -172,6 +172,7 @@ struct musb_io;
  */
 struct musb_platform_ops {
 
+#define MUSB_DA8XX BIT(7)
 #define MUSB_DMA_UX500 BIT(6)
 #define MUSB_DMA_CPPI41BIT(5)
 #define MUSB_DMA_CPPI  BIT(4)
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 00e272b..2df37be 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -552,6 +552,10 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
}
}
 
+   /* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
+   if (musb->io.quirks & MUSB_DA8XX)
+   mdelay(250);
+
tdbit = 1 << cppi41_channel->port_num;
if (is_tx)
tdbit <<= 16;
-- 
2.10.2

--
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 3/5] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx

2017-01-25 Thread Alexandre Bailon
Currently, only the PIO mode is supported.
This add support of CPPI 4.1 to DA8xx.
As the In DA8xx the CPPI 4.1 DMA is a part of the USB.
Create the CPPI 4.1 device as a child of USB.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/Kconfig |  4 ++--
 drivers/usb/musb/da8xx.c | 35 ++-
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 72a2a50..5506a9c 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA
  Enable DMA transfers when TI CPPI DMA is available.
 
 config USB_TI_CPPI41_DMA
-   bool 'TI CPPI 4.1 (AM335x)'
-   depends on ARCH_OMAP && DMADEVICES
+   bool 'TI CPPI 4.1'
+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
select TI_CPPI41
 
 config USB_TUSB_OMAP_DMA
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index cd3d763..d279438 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -457,12 +458,40 @@ static inline u8 get_vbus_power(struct device *dev)
return current_uA / 1000 / 2;
 }
 
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+static void da8xx_dma_controller_callback(struct dma_controller *c)
+{
+   struct musb *musb = c->musb;
+   void __iomem *reg_base = musb->ctrl_base;
+
+   musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
+}
+
+static struct dma_controller *
+da8xx_dma_controller_create(struct musb *musb, void __iomem *base)
+{
+   struct dma_controller *controller;
+
+   controller = cppi41_dma_controller_create(musb, base);
+   if (IS_ERR_OR_NULL(controller))
+   return controller;
+
+   controller->dma_callback = da8xx_dma_controller_callback;
+
+   return controller;
+}
+#endif
+
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_INDEXED_EP,
+   .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
.fifo_mode  = 2,
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+   .dma_init   = da8xx_dma_controller_create,
+   .dma_exit   = cppi41_dma_controller_destroy,
+#endif
.enable = da8xx_musb_enable,
.disable= da8xx_musb_disable,
 
@@ -534,6 +563,10 @@ static int da8xx_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, glue);
 
+   ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
+   if (ret)
+   return ret;
+
memset(musb_resources, 0x00, sizeof(*musb_resources) *
ARRAY_SIZE(musb_resources));
 
-- 
2.10.2

--
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 5/5] usb: musb: da8xx: Add a primary support of PM runtime

2017-01-25 Thread Alexandre Bailon
Currently, MUSB DA8xx glue driver doesn't have PM runtime support.
Because the CPPI 4.1 is using the same clock as MUSB DA8xx and
CPPI 4.1 is a child of MUSB DA8xx glue, add support of PM runtime
to the DA8xx glue driver in order to let the CPPI 4.1 driver manage
the clock by using PM runtime.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d87fb9b..bebc9ed 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -30,7 +30,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -86,7 +85,6 @@ struct da8xx_glue {
struct device   *dev;
struct platform_device  *musb;
struct platform_device  *usb_phy;
-   struct clk  *clk;
struct phy  *phy;
 };
 
@@ -377,11 +375,7 @@ static int da8xx_musb_init(struct musb *musb)
 
musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
 
-   ret = clk_prepare_enable(glue->clk);
-   if (ret) {
-   dev_err(glue->dev, "failed to enable clock\n");
-   return ret;
-   }
+   pm_runtime_get_sync(musb->controller->parent);
 
/* Returns zero if e.g. not clocked */
rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
@@ -424,7 +418,7 @@ static int da8xx_musb_init(struct musb *musb)
 err_phy_power_on:
phy_exit(glue->phy);
 fail:
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put(musb->controller->parent);
return ret;
 }
 
@@ -436,7 +430,7 @@ static int da8xx_musb_exit(struct musb *musb)
 
phy_power_off(glue->phy);
phy_exit(glue->phy);
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put(musb->controller->parent);
 
usb_put_phy(musb->xceiv);
 
@@ -519,7 +513,6 @@ static int da8xx_probe(struct platform_device *pdev)
struct musb_hdrc_platform_data  *pdata = dev_get_platdata(&pdev->dev);
struct da8xx_glue   *glue;
struct platform_device_info pinfo;
-   struct clk  *clk;
struct device_node  *np = pdev->dev.of_node;
int ret;
 
@@ -527,12 +520,6 @@ static int da8xx_probe(struct platform_device *pdev)
if (!glue)
return -ENOMEM;
 
-   clk = devm_clk_get(&pdev->dev, "usb20");
-   if (IS_ERR(clk)) {
-   dev_err(&pdev->dev, "failed to get clock\n");
-   return PTR_ERR(clk);
-   }
-
glue->phy = devm_phy_get(&pdev->dev, "usb-phy");
if (IS_ERR(glue->phy)) {
if (PTR_ERR(glue->phy) != -EPROBE_DEFER)
@@ -541,7 +528,6 @@ static int da8xx_probe(struct platform_device *pdev)
}
 
glue->dev   = &pdev->dev;
-   glue->clk   = clk;
 
if (IS_ENABLED(CONFIG_OF) && np) {
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
@@ -587,6 +573,8 @@ static int da8xx_probe(struct platform_device *pdev)
pinfo.data = pdata;
pinfo.size_data = sizeof(*pdata);
 
+   pm_runtime_enable(&pdev->dev);
+
glue->musb = platform_device_register_full(&pinfo);
ret = PTR_ERR_OR_ZERO(glue->musb);
if (ret) {
@@ -603,6 +591,7 @@ static int da8xx_remove(struct platform_device *pdev)
 
platform_device_unregister(glue->musb);
usb_phy_generic_unregister(glue->usb_phy);
+   pm_runtime_disable(&pdev->dev);
 
return 0;
 }
-- 
2.10.2

--
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 2/6] usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback()

2017-01-25 Thread Alexandre Bailon
Update cppi41_dma_callback() to detect an aborted transfer.
This was not required before because cppi41_dma_callback() was only
invoked on transfer completion.
In order to make CPPI 4.1 driver more generic, cppi41_dma_callback()
will be invoked after a transfer abort in order to let the MUSB driver
perform some action such as acknowledge the interrupt that may be fired
during a teardown.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index f7d3d27..1fe7eae 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -99,7 +99,8 @@ static bool musb_is_tx_fifo_empty(struct musb_hw_ep *hw_ep)
return true;
 }
 
-static void cppi41_dma_callback(void *private_data);
+static void cppi41_dma_callback(void *private_data,
+   const struct dmaengine_result *result);
 
 static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel)
 {
@@ -154,7 +155,7 @@ static void cppi41_trans_done(struct cppi41_dma_channel 
*cppi41_channel)
if (WARN_ON(!dma_desc))
return;
 
-   dma_desc->callback = cppi41_dma_callback;
+   dma_desc->callback_result = cppi41_dma_callback;
dma_desc->callback_param = &cppi41_channel->channel;
cppi41_channel->cookie = dma_desc->tx_submit(dma_desc);
trace_musb_cppi41_cont(cppi41_channel);
@@ -204,7 +205,8 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct 
hrtimer *timer)
return ret;
 }
 
-static void cppi41_dma_callback(void *private_data)
+static void cppi41_dma_callback(void *private_data,
+   const struct dmaengine_result *result)
 {
struct dma_channel *channel = private_data;
struct cppi41_dma_channel *cppi41_channel = channel->private_data;
@@ -221,6 +223,9 @@ static void cppi41_dma_callback(void *private_data)
if (controller->controller.dma_callback)
controller->controller.dma_callback(&controller->controller);
 
+   if (result->result == DMA_TRANS_ABORTED)
+   return;
+
spin_lock_irqsave(&musb->lock, flags);
 
dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie,
@@ -403,7 +408,7 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
if (!dma_desc)
return false;
 
-   dma_desc->callback = cppi41_dma_callback;
+   dma_desc->callback_result = cppi41_dma_callback;
dma_desc->callback_param = channel;
cppi41_channel->cookie = dma_desc->tx_submit(dma_desc);
cppi41_channel->channel.rx_packet_done = false;
-- 
2.10.2

--
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 1/6] usb: musb: dma: Add a DMA completion platform callback

2017-01-25 Thread Alexandre Bailon
Currently, the CPPI 4.1 driver is not completely generic and
only works on DSPS. This is because of IRQ management.
Add a callback to dma_controller that could be invoked on DMA completion
to acknowledge the IRQ.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 7 +--
 drivers/usb/musb/musb_dma.h| 5 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 1636385..f7d3d27 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -217,6 +217,10 @@ static void cppi41_dma_callback(void *private_data)
int is_hs = 0;
bool empty;
 
+   controller = cppi41_channel->controller;
+   if (controller->controller.dma_callback)
+   controller->controller.dma_callback(&controller->controller);
+
spin_lock_irqsave(&musb->lock, flags);
 
dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie,
@@ -249,8 +253,6 @@ static void cppi41_dma_callback(void *private_data)
 * We spin on HS (no longer than than 25us and setup a timer on
 * FS to check for the bit and complete the transfer.
 */
-   controller = cppi41_channel->controller;
-
if (is_host_active(musb)) {
if (musb->port1_status & USB_PORT_STAT_HIGH_SPEED)
is_hs = 1;
@@ -695,6 +697,7 @@ cppi41_dma_controller_create(struct musb *musb, void 
__iomem *base)
controller->controller.channel_program = cppi41_dma_channel_program;
controller->controller.channel_abort = cppi41_dma_channel_abort;
controller->controller.is_compatible = cppi41_is_compatible;
+   controller->controller.musb = musb;
 
ret = cppi41_dma_controller_start(controller);
if (ret)
diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
index 46357e1..04c3bd8 100644
--- a/drivers/usb/musb/musb_dma.h
+++ b/drivers/usb/musb/musb_dma.h
@@ -173,6 +173,7 @@ dma_channel_status(struct dma_channel *c)
 
 /**
  * struct dma_controller - A DMA Controller.
+ * @musb: the usb controller
  * @start: call this to start a DMA controller;
  * return 0 on success, else negative errno
  * @stop: call this to stop a DMA controller
@@ -181,10 +182,13 @@ dma_channel_status(struct dma_channel *c)
  * @channel_release: call this to release a DMA channel
  * @channel_abort: call this to abort a pending DMA transaction,
  * returning it to FREE (but allocated) state
+ * @dma_callback: invoked on DMA completion, useful to run platform
+ * code such IRQ acknowledgment.
  *
  * Controllers manage dma channels.
  */
 struct dma_controller {
+   struct musb *musb;
struct dma_channel  *(*channel_alloc)(struct dma_controller *,
struct musb_hw_ep *, u8 is_tx);
void(*channel_release)(struct dma_channel *);
@@ -196,6 +200,7 @@ struct dma_controller {
int (*is_compatible)(struct dma_channel *channel,
u16 maxpacket,
void *buf, u32 length);
+   void(*dma_callback)(struct dma_controller *);
 };
 
 /* called after channel_program(), may indicate a fault */
-- 
2.10.2

--
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 4/6] usb: musb: cppi_dma: Clean up cppi41_dma_controller structure

2017-01-25 Thread Alexandre Bailon
A pointer to musb is now present in the dma_controller structure.
Remove the one present in cppi41_dma_controller structure.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_cppi41.c | 29 +
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 1fe7eae..00e272b 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -30,7 +30,6 @@ struct cppi41_dma_controller {
struct dma_controller controller;
struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS];
struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS];
-   struct musb *musb;
struct hrtimer early_tx;
struct list_head early_tx_list;
u32 rx_mode;
@@ -45,7 +44,7 @@ static void save_rx_toggle(struct cppi41_dma_channel 
*cppi41_channel)
 
if (cppi41_channel->is_tx)
return;
-   if (!is_host_active(cppi41_channel->controller->musb))
+   if (!is_host_active(cppi41_channel->controller->controller.musb))
return;
 
csr = musb_readw(cppi41_channel->hw_ep->regs, MUSB_RXCSR);
@@ -78,8 +77,7 @@ static void update_rx_toggle(struct cppi41_dma_channel 
*cppi41_channel)
if (!toggle && toggle == cppi41_channel->usb_toggle) {
csr |= MUSB_RXCSR_H_DATATOGGLE | MUSB_RXCSR_H_WR_DATATOGGLE;
musb_writew(cppi41_channel->hw_ep->regs, MUSB_RXCSR, csr);
-   musb_dbg(cppi41_channel->controller->musb,
-   "Restoring DATA1 toggle.");
+   musb_dbg(musb, "Restoring DATA1 toggle.");
}
 
cppi41_channel->usb_toggle = toggle;
@@ -180,7 +178,7 @@ static enum hrtimer_restart cppi41_recheck_tx_req(struct 
hrtimer *timer)
 
controller = container_of(timer, struct cppi41_dma_controller,
early_tx);
-   musb = controller->musb;
+   musb = controller->controller.musb;
 
spin_lock_irqsave(&musb->lock, flags);
list_for_each_entry_safe(cppi41_channel, n, &controller->early_tx_list,
@@ -309,6 +307,7 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel 
*cppi41_channel,
unsigned mode)
 {
struct cppi41_dma_controller *controller = cppi41_channel->controller;
+   struct musb *musb = controller->controller.musb;
u32 port;
u32 new_mode;
u32 old_mode;
@@ -324,12 +323,10 @@ static void cppi41_set_dma_mode(struct cppi41_dma_channel 
*cppi41_channel,
return;
if (cppi41_channel->is_tx) {
controller->tx_mode = new_mode;
-   musb_writel(controller->musb->ctrl_base, USB_CTRL_TX_MODE,
-   new_mode);
+   musb_writel(musb->ctrl_base, USB_CTRL_TX_MODE, new_mode);
} else {
controller->rx_mode = new_mode;
-   musb_writel(controller->musb->ctrl_base, USB_CTRL_RX_MODE,
-   new_mode);
+   musb_writel(musb->ctrl_base, USB_CTRL_RX_MODE, new_mode);
}
 }
 
@@ -348,7 +345,8 @@ static void cppi41_set_autoreq_mode(struct 
cppi41_dma_channel *cppi41_channel,
if (new_mode == old_mode)
return;
controller->auto_req = new_mode;
-   musb_writel(controller->musb->ctrl_base, USB_CTRL_AUTOREQ, new_mode);
+   musb_writel(controller->controller.musb->ctrl_base, USB_CTRL_AUTOREQ,
+   new_mode);
 }
 
 static bool cppi41_configure_channel(struct dma_channel *channel,
@@ -359,7 +357,7 @@ static bool cppi41_configure_channel(struct dma_channel 
*channel,
struct dma_chan *dc = cppi41_channel->dc;
struct dma_async_tx_descriptor *dma_desc;
enum dma_transfer_direction direction;
-   struct musb *musb = cppi41_channel->controller->musb;
+   struct musb *musb = cppi41_channel->controller->controller.musb;
unsigned use_gen_rndis = 0;
 
cppi41_channel->buf_addr = dma_addr;
@@ -472,7 +470,7 @@ static int cppi41_dma_channel_program(struct dma_channel 
*channel,
BUG_ON(channel->status == MUSB_DMA_STATUS_UNKNOWN ||
channel->status == MUSB_DMA_STATUS_BUSY);
 
-   if (is_host_active(cppi41_channel->controller->musb)) {
+   if (is_host_active(cppi41_channel->controller->controller.musb)) {
if (cppi41_channel->is_tx)
hb_mult = cppi41_channel->hw_ep->out_qh->hb_mult;
else
@@ -497,7 +495,7 @@ static int cppi41_is_compatible(struct dma_channel 
*channel, u16 maxpacket,
 {
struct cppi41_dma_channel *cppi41_channel = channel->private_data;
struct cppi41_dma_controller *controller = cppi41_channel->controller;
-   st

[PATCH v5 5/6] usb: musb: cppi_dma: Clean up tusb_omap_dma structure

2017-01-25 Thread Alexandre Bailon
A pointer to musb is now present in the dma_controller structure.
Remove the one present in tusb_omap_dma structure.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/tusb6010_omap.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index e6959cc..8b43c4b 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -56,7 +56,6 @@ struct tusb_omap_dma_ch {
 
 struct tusb_omap_dma {
struct dma_controller   controller;
-   struct musb *musb;
void __iomem*tbase;
 
int ch;
@@ -497,7 +496,7 @@ tusb_omap_dma_allocate(struct dma_controller *c,
u32 reg;
 
tusb_dma = container_of(c, struct tusb_omap_dma, controller);
-   musb = tusb_dma->musb;
+   musb = tusb_dma->controller.musb;
tbase = musb->ctrl_base;
 
reg = musb_readl(tbase, TUSB_DMA_INT_MASK);
@@ -534,7 +533,7 @@ tusb_omap_dma_allocate(struct dma_controller *c,
dev_name = "TUSB receive";
}
 
-   chdat->musb = tusb_dma->musb;
+   chdat->musb = tusb_dma->controller.musb;
chdat->tbase = tusb_dma->tbase;
chdat->hw_ep = hw_ep;
chdat->epnum = hw_ep->epnum;
@@ -667,7 +666,7 @@ tusb_dma_controller_create(struct musb *musb, void __iomem 
*base)
if (!tusb_dma)
goto out;
 
-   tusb_dma->musb = musb;
+   tusb_dma->controller.musb = musb;
tusb_dma->tbase = musb->ctrl_base;
 
tusb_dma->ch = -1;
-- 
2.10.2

--
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 3/6] usb: musb: cppi_dma: Clean up cppi structure

2017-01-25 Thread Alexandre Bailon
A pointer to musb is now present in the dma_controller structure.
Remove the one present in cppi structure.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/cppi_dma.c | 26 +-
 drivers/usb/musb/cppi_dma.h |  1 -
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index 1ae48e6..c4fabe95 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -224,7 +224,7 @@ static void cppi_controller_stop(struct cppi *controller)
int i;
struct musb *musb;
 
-   musb = controller->musb;
+   musb = controller->controller.musb;
 
tibase = controller->tibase;
/* DISABLE INDIVIDUAL CHANNEL Interrupts */
@@ -288,7 +288,7 @@ cppi_channel_allocate(struct dma_controller *c,
 
controller = container_of(c, struct cppi, controller);
tibase = controller->tibase;
-   musb = controller->musb;
+   musb = c->musb;
 
/* ep0 doesn't use DMA; remember cppi indices are 0..N-1 */
index = ep->epnum - 1;
@@ -336,7 +336,7 @@ static void cppi_channel_release(struct dma_channel 
*channel)
c = container_of(channel, struct cppi_channel, channel);
tibase = c->controller->tibase;
if (!c->hw_ep)
-   musb_dbg(c->controller->musb,
+   musb_dbg(c->controller->controller.musb,
"releasing idle DMA channel %p", c);
else if (!c->transmit)
core_rxirq_enable(tibase, c->index + 1);
@@ -355,7 +355,7 @@ cppi_dump_rx(int level, struct cppi_channel *c, const char 
*tag)
 
musb_ep_select(base, c->index + 1);
 
-   musb_dbg(c->controller->musb,
+   musb_dbg(c->controller->controller.musb,
"RX DMA%d%s: %d left, csr %04x, "
"%08x H%08x S%08x C%08x, "
"B%08x L%08x %08x .. %08x",
@@ -385,7 +385,7 @@ cppi_dump_tx(int level, struct cppi_channel *c, const char 
*tag)
 
musb_ep_select(base, c->index + 1);
 
-   musb_dbg(c->controller->musb,
+   musb_dbg(c->controller->controller.musb,
"TX DMA%d%s: csr %04x, "
"H%08x S%08x C%08x %08x, "
"F%08x L%08x .. %08x",
@@ -954,7 +954,7 @@ static int cppi_channel_program(struct dma_channel *ch,
 
cppi_ch = container_of(ch, struct cppi_channel, channel);
controller = cppi_ch->controller;
-   musb = controller->musb;
+   musb = controller->controller.musb;
 
switch (ch->status) {
case MUSB_DMA_STATUS_BUS_ABORT:
@@ -1009,7 +1009,7 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
int i;
dma_addr_t  safe2ack;
void __iomem*regs = rx->hw_ep->regs;
-   struct musb *musb = cppi->musb;
+   struct musb *musb = cppi->controller.musb;
 
cppi_dump_rx(6, rx, "/K");
 
@@ -1121,7 +1121,7 @@ static bool cppi_rx_scan(struct cppi *cppi, unsigned ch)
 * setting it here "should" be racey, but seems to work
 */
csr = musb_readw(rx->hw_ep->regs, MUSB_RXCSR);
-   if (is_host_active(cppi->musb)
+   if (is_host_active(cppi->controller.musb)
&& bd
&& !(csr & MUSB_RXCSR_H_REQPKT)) {
csr |= MUSB_RXCSR_H_REQPKT;
@@ -1311,7 +1311,7 @@ cppi_dma_controller_create(struct musb *musb, void 
__iomem *mregs)
controller->mregs = mregs;
controller->tibase = mregs - DAVINCI_BASE_OFFSET;
 
-   controller->musb = musb;
+   controller->controller.musb = musb;
controller->controller.channel_alloc = cppi_channel_allocate;
controller->controller.channel_release = cppi_channel_release;
controller->controller.channel_program = cppi_channel_program;
@@ -1323,7 +1323,7 @@ cppi_dma_controller_create(struct musb *musb, void 
__iomem *mregs)
 
/* setup BufferPool */
controller->pool = dma_pool_create("cppi",
-   controller->musb->controller,
+   controller->controller.musb->controller,
sizeof(struct cppi_descriptor),
CPPI_DESCRIPTOR_ALIGN, 0);
if (!controller->pool) {
@@ -1357,7 +1357,7 @@ void cppi_dma_controller_destroy(struct dma_controller *c)
cppi_controller_stop(cppi);
 
if (cppi->irq)
-   free_irq(cppi->irq, cppi->musb);
+   free_irq(cppi->irq, cppi->controller.musb);
 
/* a

[PATCH v5 0/6] usb: musb: cppi41: Add a way to manage DMA irq

2017-01-25 Thread Alexandre Bailon
This series was "dmaengine: cppi41: Make the driver more generic".
I have tried to separate as munch I could CPPI 4.1 MUSB driver changes.

Currently, the DMA interrupt is managed by the CPPI 4.1 driver.
The issue here is the CPPI 4.1 driver must access to MUSB glue registers
to manage its interrupt.
In order to move the interrupts management from CPPI 4.1 driver to MUSB
(and then make it more generic), update the MUSB CPPI 4.1 driver with
changes that will help to manage DMA interrupt from MUSB driver.

Changes in v5:
- Clean up patch 4 and 5

Changes in v4:
- Remove musb pointer from struct cppi, cppi41_dma_controller and
  tusb_omap_dma.

Changes in v3:
- Move a patch from another series to this one to avoid build error report
  from kbuild test robot
- Instead of adding and exporting function, add one callback and a pointer
  to musb in struct dma_controller
- Surround the DMA function introduced in musb_dsps with #ifdef / #endif.

Changes in v2:
- Fix some typo in commit messages
- Add more explanation about some changes made by patch 2 in commit message

Alexandre Bailon (6):
  usb: musb: dma: Add a DMA completion platform callback
  usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback()
  usb: musb: cppi_dma: Clean up cppi structure
  usb: musb: cppi_dma: Clean up cppi41_dma_controller structure
  usb: musb: cppi_dma: Clean up tusb_omap_dma structure
  usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in DSPS

 drivers/dma/cppi41.c | 28 --
 drivers/usb/musb/cppi_dma.c  | 26 ++---
 drivers/usb/musb/cppi_dma.h  |  1 -
 drivers/usb/musb/musb_cppi41.c   | 49 +---
 drivers/usb/musb/musb_dma.h  |  5 +++
 drivers/usb/musb/musb_dsps.c | 81 +++-
 drivers/usb/musb/tusb6010_omap.c |  7 ++--
 7 files changed, 134 insertions(+), 63 deletions(-)

-- 
2.10.2

--
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 6/6] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in DSPS

2017-01-25 Thread Alexandre Bailon
Despite the CPPI 4.1 is a generic DMA, it is tied to USB.
On the DSPS, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue).
Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver
maps and accesses to USBSS's register, which making CPPI 4.1 driver not
really generic.
Move the interrupt management to DSPS driver.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 28 ---
 drivers/usb/musb/musb_dsps.c | 81 ++--
 2 files changed, 86 insertions(+), 23 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index d5ba43a..4999e7d 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -79,14 +79,6 @@
 #define QMGR_QUEUE_C(n)(0x2008 + (n) * 0x10)
 #define QMGR_QUEUE_D(n)(0x200c + (n) * 0x10)
 
-/* Glue layer specific */
-/* USBSS  / USB AM335x */
-#define USBSS_IRQ_STATUS   0x28
-#define USBSS_IRQ_ENABLER  0x2c
-#define USBSS_IRQ_CLEARR   0x30
-
-#define USBSS_IRQ_PD_COMP  (1 <<  2)
-
 /* Packet Descriptor */
 #define PD2_ZERO_LENGTH(1 << 19)
 
@@ -288,14 +280,8 @@ static irqreturn_t cppi41_irq(int irq, void *data)
 {
struct cppi41_dd *cdd = data;
struct cppi41_channel *c;
-   u32 status;
int i;
 
-   status = cppi_readl(cdd->usbss_mem + USBSS_IRQ_STATUS);
-   if (!(status & USBSS_IRQ_PD_COMP))
-   return IRQ_NONE;
-   cppi_writel(status, cdd->usbss_mem + USBSS_IRQ_STATUS);
-
for (i = QMGR_PENDING_SLOT_Q(FIST_COMPLETION_QUEUE); i < QMGR_NUM_PEND;
i++) {
u32 val;
@@ -599,6 +585,7 @@ static void cppi41_compute_td_desc(struct cppi41_desc *d)
 
 static int cppi41_tear_down_chan(struct cppi41_channel *c)
 {
+   struct dmaengine_result abort_result;
struct cppi41_dd *cdd = c->cdd;
struct cppi41_desc *td;
u32 reg;
@@ -682,6 +669,12 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c)
c->td_seen = 0;
c->td_desc_seen = 0;
cppi_writel(0, c->gcr_reg);
+
+   /* Invoke the callback to do the necessary clean-up */
+   abort_result.result = DMA_TRANS_ABORTED;
+   dma_cookie_complete(&c->txd);
+   dmaengine_desc_get_callback_invoke(&c->txd, &abort_result);
+
return 0;
 }
 
@@ -1044,8 +1037,6 @@ static int cppi41_dma_probe(struct platform_device *pdev)
goto err_irq;
}
 
-   cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER);
-
ret = devm_request_irq(&pdev->dev, irq, glue_info->isr, IRQF_SHARED,
dev_name(dev), cdd);
if (ret)
@@ -1069,7 +1060,6 @@ static int cppi41_dma_probe(struct platform_device *pdev)
dma_async_device_unregister(&cdd->ddev);
 err_dma_reg:
 err_irq:
-   cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
cleanup_chans(cdd);
 err_chans:
deinit_cppi41(dev, cdd);
@@ -1097,7 +1087,6 @@ static int cppi41_dma_remove(struct platform_device *pdev)
of_dma_controller_free(pdev->dev.of_node);
dma_async_device_unregister(&cdd->ddev);
 
-   cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
devm_free_irq(&pdev->dev, cdd->irq, cdd);
cleanup_chans(cdd);
deinit_cppi41(&pdev->dev, cdd);
@@ -1116,7 +1105,6 @@ static int __maybe_unused cppi41_suspend(struct device 
*dev)
struct cppi41_dd *cdd = dev_get_drvdata(dev);
 
cdd->dma_tdfdq = cppi_readl(cdd->ctrl_mem + DMA_TDFDQ);
-   cppi_writel(0, cdd->usbss_mem + USBSS_IRQ_CLEARR);
disable_sched(cdd);
 
return 0;
@@ -1142,8 +1130,6 @@ static int __maybe_unused cppi41_resume(struct device 
*dev)
cppi_writel(QMGR_SCRATCH_SIZE, cdd->qmgr_mem + QMGR_LRAM_SIZE);
cppi_writel(0, cdd->qmgr_mem + QMGR_LRAM1_BASE);
 
-   cppi_writel(USBSS_IRQ_PD_COMP, cdd->usbss_mem + USBSS_IRQ_ENABLER);
-
return 0;
 }
 
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 9f125e1..461bc09 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -121,6 +121,7 @@ struct dsps_glue {
struct timer_list timer;/* otg_workaround timer */
unsigned long last_timer;/* last timer data for each instance */
bool sw_babble_enabled;
+   void __iomem *usbss_base;
 
struct dsps_context context;
struct debugfs_regset32 regset;
@@ -145,6 +146,13 @@ static const struct debugfs_reg32 dsps_musb_regs[] = {
{ "mode",   0xe8 },
 };
 
+/* USBSS  / USB AM335x */
+#define USBSS_IRQ_STATUS   0x28
+#define USBSS_IRQ_ENABLER  0x2c
+#define USBSS_IRQ_CLEARR   0x30
+
+#define USBSS_IRQ_PD_COMP  (1 << 2)
+
 /**
  * dsps_musb_enable - enable interrupts
  */
@@ -619,14 +627,76 @@ static void dsps_r

[PATCH v2] arm: davinci: Make the usb20 clock available to PM runtime

2017-01-24 Thread Alexandre Bailon
Add usb20 to the list of clock supported by PM runtime.

Signed-off-by: Alexandre Bailon 
Suggested-by: Sekhar Nori 
---
 arch/arm/mach-davinci/da830.c | 2 +-
 arch/arm/mach-davinci/da850.c | 2 +-
 arch/arm/mach-davinci/usb-da8xx.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 073c458..2cfd9d7 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -412,7 +412,7 @@ static struct clk_lookup da830_clks[] = {
CLK("davinci-mcasp.0",  NULL,   &mcasp0_clk),
CLK("davinci-mcasp.1",  NULL,   &mcasp1_clk),
CLK("davinci-mcasp.2",  NULL,   &mcasp2_clk),
-   CLK("musb-da8xx",   "usb20",&usb20_clk),
+   CLK("musb-da8xx",   NULL,   &usb20_clk),
CLK(NULL,   "aemif",&aemif_clk),
CLK(NULL,   "aintc",&aintc_clk),
CLK(NULL,   "secu_mgr", &secu_mgr_clk),
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 9780829..5fe32ae 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -559,7 +559,7 @@ static struct clk_lookup da850_clks[] = {
CLK("ti-aemif", NULL,   &aemif_clk),
CLK("davinci-nand.0",   "aemif",&aemif_nand_clk),
CLK("ohci-da8xx",   "usb11",&usb11_clk),
-   CLK("musb-da8xx",   "usb20",&usb20_clk),
+   CLK("musb-da8xx",   NULL,   &usb20_clk),
CLK("spi_davinci.0",NULL,   &spi0_clk),
CLK("spi_davinci.1",NULL,   &spi1_clk),
CLK("vpif", NULL,   &vpif_clk),
diff --git a/arch/arm/mach-davinci/usb-da8xx.c 
b/arch/arm/mach-davinci/usb-da8xx.c
index 9a6af0b..9b66768 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -275,7 +275,7 @@ int __init da8xx_register_usb20_phy_clk(bool 
use_usb_refclkin)
struct clk *parent;
int ret;
 
-   usb20_clk = clk_get(&da8xx_usb20_dev.dev, "usb20");
+   usb20_clk = clk_get(&da8xx_usb20_dev.dev, NULL);
ret = PTR_ERR_OR_ZERO(usb20_clk);
if (ret)
return ret;
-- 
2.10.2

--
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 v4] ARM: dts: da850: Add the CPPI 4.1 DMA to the USB OTG controller

2017-01-24 Thread Alexandre Bailon
This adds the CPPI 4.1 DMA controller to the USB OTG controller.

Changes since v3:
- Don't use a wildcard for compatible property.

Signed-off-by: Alexandre Bailon 
---
 arch/arm/boot/dts/da850.dtsi | 25 +
 1 file changed, 25 insertions(+)

diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 104155d..f4a637a 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -396,12 +396,37 @@
usb0: usb@20 {
compatible = "ti,da830-musb";
reg = <0x20 0x1>;
+   ranges;
interrupts = <58>;
interrupt-names = "mc";
dr_mode = "otg";
phys = <&usb_phy 0>;
phy-names = "usb-phy";
status = "disabled";
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   dmas = <&cppi41dma 0 0 &cppi41dma 1 0
+   &cppi41dma 2 0 &cppi41dma 3 0
+   &cppi41dma 0 1 &cppi41dma 1 1
+   &cppi41dma 2 1 &cppi41dma 3 1>;
+   dma-names =
+   "rx1", "rx2", "rx3", "rx4",
+   "tx1", "tx2", "tx3", "tx4";
+
+   cppi41dma: dma-controller@201000 {
+   compatible = "ti,da830-cppi41";
+   reg =  <0x201000 0x1000
+   0x202000 0x1000
+   0x204000 0x4000>;
+   reg-names = "controller",
+   "scheduler", "queuemgr";
+   interrupts = <58>;
+   #dma-cells = <2>;
+   #dma-channels = <4>;
+   status = "okay";
+   };
};
mdio: mdio@224000 {
compatible = "ti,davinci_mdio";
-- 
2.10.2

--
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 v4 1/5] usb: musb: da8xx: Remove CPPI 3.0 quirk and methods

2017-01-24 Thread Alexandre Bailon
DA8xx driver is registering and using the CPPI 3.0 DMA controller but
actually, the DA8xx has a CPPI 4.1 DMA controller.
Remove the CPPI 3.0 quirk and methods.

Fixes: f8e9f34f80a2 ("usb: musb: Fix up DMA related macros")
Fixes: 7f6283ed6fe8 ("usb: musb: Set up function pointers for DMA")
Signed-off-by: Alexandre Bailon 
Acked-by: Sergei Shtylyov 
Acked-by: Tony Lindgren 
---
 drivers/usb/musb/da8xx.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index e89708d..cd3d763 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -458,15 +458,11 @@ static inline u8 get_vbus_power(struct device *dev)
 }
 
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_DMA_CPPI | MUSB_INDEXED_EP,
+   .quirks = MUSB_INDEXED_EP,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
.fifo_mode  = 2,
-#ifdef CONFIG_USB_TI_CPPI_DMA
-   .dma_init   = cppi_dma_controller_create,
-   .dma_exit   = cppi_dma_controller_destroy,
-#endif
.enable = da8xx_musb_enable,
.disable= da8xx_musb_disable,
 
-- 
2.10.2

--
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 v4 4/5] usb: musb: musb_cppi41: Workaround DMA stall issue during teardown

2017-01-24 Thread Alexandre Bailon
The DMA may hung up if a teardown is initiated while an endpoint is still
active (Advisory 2.3.27 of DA8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c   | 2 +-
 drivers/usb/musb/musb_core.h   | 1 +
 drivers/usb/musb/musb_cppi41.c | 4 
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d279438..d87fb9b 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -483,7 +483,7 @@ da8xx_dma_controller_create(struct musb *musb, void __iomem 
*base)
 #endif
 
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41,
+   .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41 | MUSB_DA8XX,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index ade902e..d129278 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -172,6 +172,7 @@ struct musb_io;
  */
 struct musb_platform_ops {
 
+#define MUSB_DA8XX BIT(7)
 #define MUSB_DMA_UX500 BIT(6)
 #define MUSB_DMA_CPPI41BIT(5)
 #define MUSB_DMA_CPPI  BIT(4)
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 7253ea1..2fb2b81 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -553,6 +553,10 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
}
}
 
+   /* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
+   if (musb->io.quirks & MUSB_DA8XX)
+   mdelay(250);
+
tdbit = 1 << cppi41_channel->port_num;
if (is_tx)
tdbit <<= 16;
-- 
2.10.2

--
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 v4 0/5] usb: musb: da8xx: Add DMA support

2017-01-24 Thread Alexandre Bailon
This series update MUSB driver to add DMA support to DA8xx.
It should be applied on top of
"[PATCH v3 0/3] usb: musb: cppi41: Add a way to manage DMA irq" but
"[PATCH v3 0/3] dmaengine: cppi41: Add dma support to da8xx" and
"[PATCH] arm: davinci: Make the usb20 clock available to PM runtime"
are required to make it work.

Changes in v4:
- Update and clarify the commit message of patch 5
- Fix the typo in patch 3

Changes in v3:
- Remove PM runtime callbacks.
  I have update arch/arm/mach-davinci/pm_domain.c to let PM runtime control
  the usb20 clock.
- Only use PM runtime sync operation.

Changes in v2:
- Clock and IRQ management has been moved to MUSB DA8xx glue
  (was in CPPI 4.1 driver)
- I have added a partial support PM runtime. The goal was to use PM
  runtime to manage clock of MUSB and CPPI 4.1 (they use the same clock).
- CPPI 4.1 is now achild of MUSB DA8xx glue.

Alexandre Bailon (5):
  usb: musb: da8xx: Remove CPPI 3.0 quirk and methods
  usb: musb: Use shared irq
  usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx
  usb: musb: musb_cppi41: Workaround DMA stall issue during teardown
  usb: musb: da8xx: Add a primary support of PM runtime

 drivers/usb/musb/Kconfig   |  4 +--
 drivers/usb/musb/da8xx.c   | 60 +++---
 drivers/usb/musb/musb_core.c   |  2 +-
 drivers/usb/musb/musb_core.h   |  1 +
 drivers/usb/musb/musb_cppi41.c |  4 +++
 5 files changed, 47 insertions(+), 24 deletions(-)

-- 
2.10.2

--
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 v4 2/5] usb: musb: Use shared irq

2017-01-24 Thread Alexandre Bailon
In the DA8xx, USB and CPPI 4.1 are sharing the same interrupt line.
Update the driver to request a shared irq.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/musb_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index fca288bb..cf40adf 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2329,7 +2329,7 @@ musb_init_controller(struct device *dev, int nIrq, void 
__iomem *ctrl)
setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) 
musb);
 
/* attach to the IRQ */
-   if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
+   if (request_irq(nIrq, musb->isr, IRQF_SHARED, dev_name(dev), musb)) {
dev_err(dev, "request_irq %d failed!\n", nIrq);
status = -ENODEV;
goto fail3;
-- 
2.10.2

--
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 v4 3/5] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx

2017-01-24 Thread Alexandre Bailon
Currently, only the PIO mode is supported.
This add support of CPPI 4.1 to DA8xx.
As the In DA8xx the CPPI 4.1 DMA is a part of the USB.
Create the CPPI 4.1 device as a child of USB.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/Kconfig |  4 ++--
 drivers/usb/musb/da8xx.c | 35 ++-
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 72a2a50..5506a9c 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA
  Enable DMA transfers when TI CPPI DMA is available.
 
 config USB_TI_CPPI41_DMA
-   bool 'TI CPPI 4.1 (AM335x)'
-   depends on ARCH_OMAP && DMADEVICES
+   bool 'TI CPPI 4.1'
+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
select TI_CPPI41
 
 config USB_TUSB_OMAP_DMA
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index cd3d763..d279438 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -457,12 +458,40 @@ static inline u8 get_vbus_power(struct device *dev)
return current_uA / 1000 / 2;
 }
 
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+static void da8xx_dma_controller_callback(struct dma_controller *c)
+{
+   struct musb *musb = c->musb;
+   void __iomem *reg_base = musb->ctrl_base;
+
+   musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
+}
+
+static struct dma_controller *
+da8xx_dma_controller_create(struct musb *musb, void __iomem *base)
+{
+   struct dma_controller *controller;
+
+   controller = cppi41_dma_controller_create(musb, base);
+   if (IS_ERR_OR_NULL(controller))
+   return controller;
+
+   controller->dma_callback = da8xx_dma_controller_callback;
+
+   return controller;
+}
+#endif
+
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_INDEXED_EP,
+   .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
.fifo_mode  = 2,
+#ifdef CONFIG_USB_TI_CPPI41_DMA
+   .dma_init   = da8xx_dma_controller_create,
+   .dma_exit   = cppi41_dma_controller_destroy,
+#endif
.enable = da8xx_musb_enable,
.disable= da8xx_musb_disable,
 
@@ -534,6 +563,10 @@ static int da8xx_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, glue);
 
+   ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
+   if (ret)
+   return ret;
+
memset(musb_resources, 0x00, sizeof(*musb_resources) *
ARRAY_SIZE(musb_resources));
 
-- 
2.10.2

--
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 v4 5/5] usb: musb: da8xx: Add a primary support of PM runtime

2017-01-24 Thread Alexandre Bailon
Currently, MUSB DA8xx glue driver doesn't have PM runtime support.
Because the CPPI 4.1 is using the same clock as MUSB DA8xx and
CPPI 4.1 is a child of MUSB DA8xx glue, add support of PM runtime
to the DA8xx glue driver in order to let the CPPI 4.1 driver manage
the clock by using PM runtime.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index d87fb9b..bebc9ed 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -30,7 +30,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -86,7 +85,6 @@ struct da8xx_glue {
struct device   *dev;
struct platform_device  *musb;
struct platform_device  *usb_phy;
-   struct clk  *clk;
struct phy  *phy;
 };
 
@@ -377,11 +375,7 @@ static int da8xx_musb_init(struct musb *musb)
 
musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
 
-   ret = clk_prepare_enable(glue->clk);
-   if (ret) {
-   dev_err(glue->dev, "failed to enable clock\n");
-   return ret;
-   }
+   pm_runtime_get_sync(musb->controller->parent);
 
/* Returns zero if e.g. not clocked */
rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
@@ -424,7 +418,7 @@ static int da8xx_musb_init(struct musb *musb)
 err_phy_power_on:
phy_exit(glue->phy);
 fail:
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put(musb->controller->parent);
return ret;
 }
 
@@ -436,7 +430,7 @@ static int da8xx_musb_exit(struct musb *musb)
 
phy_power_off(glue->phy);
phy_exit(glue->phy);
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put(musb->controller->parent);
 
usb_put_phy(musb->xceiv);
 
@@ -519,7 +513,6 @@ static int da8xx_probe(struct platform_device *pdev)
struct musb_hdrc_platform_data  *pdata = dev_get_platdata(&pdev->dev);
struct da8xx_glue   *glue;
struct platform_device_info pinfo;
-   struct clk  *clk;
struct device_node  *np = pdev->dev.of_node;
int ret;
 
@@ -527,12 +520,6 @@ static int da8xx_probe(struct platform_device *pdev)
if (!glue)
return -ENOMEM;
 
-   clk = devm_clk_get(&pdev->dev, "usb20");
-   if (IS_ERR(clk)) {
-   dev_err(&pdev->dev, "failed to get clock\n");
-   return PTR_ERR(clk);
-   }
-
glue->phy = devm_phy_get(&pdev->dev, "usb-phy");
if (IS_ERR(glue->phy)) {
if (PTR_ERR(glue->phy) != -EPROBE_DEFER)
@@ -541,7 +528,6 @@ static int da8xx_probe(struct platform_device *pdev)
}
 
glue->dev   = &pdev->dev;
-   glue->clk   = clk;
 
if (IS_ENABLED(CONFIG_OF) && np) {
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
@@ -587,6 +573,8 @@ static int da8xx_probe(struct platform_device *pdev)
pinfo.data = pdata;
pinfo.size_data = sizeof(*pdata);
 
+   pm_runtime_enable(&pdev->dev);
+
glue->musb = platform_device_register_full(&pinfo);
ret = PTR_ERR_OR_ZERO(glue->musb);
if (ret) {
@@ -603,6 +591,7 @@ static int da8xx_remove(struct platform_device *pdev)
 
platform_device_unregister(glue->musb);
usb_phy_generic_unregister(glue->usb_phy);
+   pm_runtime_disable(&pdev->dev);
 
return 0;
 }
-- 
2.10.2

--
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 v3 3/3] dmaengine: cppi41: Fix teardown warnings

2017-01-24 Thread Alexandre Bailon
During the teardown of a RX channel, because there is only one
completion queue available for RX channel, descriptor of another
channel may be popped which will cause 2 warnings:
- the first one because we popped a wrong descriptor
  (neither the channel's descriptor, nor the teardown descriptor).
- the second one happen during the teardown of another channel,
  because we can't find the channel descriptor
  (that is, the one that caused the first warning).
To avoid that, use one free queue instead of a transmit completion queue.

Note that fix doesn't fix all the teardown warnings:
I still get some when I run some corner case.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/cppi41.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 5c501da..9fdd824 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -629,7 +629,7 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c)
if (!c->is_tx) {
reg |= GCR_STARV_RETRY;
reg |= GCR_DESC_TYPE_HOST;
-   reg |= c->q_comp_num;
+   reg |= cdd->td_queue.complete;
}
reg |= GCR_TEARDOWN;
cppi_writel(reg, c->gcr_reg);
@@ -640,7 +640,7 @@ static int cppi41_tear_down_chan(struct cppi41_channel *c)
if (!c->td_seen || !c->td_desc_seen) {
 
desc_phys = cppi41_pop_desc(cdd, cdd->td_queue.complete);
-   if (!desc_phys)
+   if (!desc_phys && c->is_tx)
desc_phys = cppi41_pop_desc(cdd, c->q_comp_num);
 
if (desc_phys == c->desc_phys) {
-- 
2.10.2

--
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 v3 2/3] dmaengine: cppi41: Add support of DA8xx to CPPI 4.1

2017-01-24 Thread Alexandre Bailon
The DA8xx has a CPPI 4.1 DMA controller.
This is add the glue layer required to make it work on DA8xx.

Signed-off-by: Alexandre Bailon 
---
 drivers/dma/Kconfig  |  6 +++---
 drivers/dma/cppi41.c | 23 +++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 0d6a96e..2a31e1a 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -514,12 +514,12 @@ config TIMB_DMA
  Enable support for the Timberdale FPGA DMA engine.
 
 config TI_CPPI41
-   tristate "AM33xx CPPI41 DMA support"
-   depends on ARCH_OMAP
+   tristate "CPPI 4.1 DMA support"
+   depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX)
select DMA_ENGINE
help
  The Communications Port Programming Interface (CPPI) 4.1 DMA engine
- is currently used by the USB driver on AM335x platforms.
+ is currently used by the USB driver on AM335x and DA8xx platforms.
 
 config TI_DMA_CROSSBAR
bool
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
index 21a4f79..5c501da 100644
--- a/drivers/dma/cppi41.c
+++ b/drivers/dma/cppi41.c
@@ -221,6 +221,20 @@ static const struct chan_queues am335x_usb_queues_rx[] = {
[29] = { .submit = 30, .complete = 155},
 };
 
+static const struct chan_queues da8xx_usb_queues_tx[] = {
+   [0] = { .submit =  16, .complete = 24},
+   [1] = { .submit =  18, .complete = 24},
+   [2] = { .submit =  20, .complete = 24},
+   [3] = { .submit =  22, .complete = 24},
+};
+
+static const struct chan_queues da8xx_usb_queues_rx[] = {
+   [0] = { .submit =  1, .complete = 26},
+   [1] = { .submit =  3, .complete = 26},
+   [2] = { .submit =  5, .complete = 26},
+   [3] = { .submit =  7, .complete = 26},
+};
+
 struct cppi_glue_infos {
const struct chan_queues *queues_rx;
const struct chan_queues *queues_tx;
@@ -949,8 +963,17 @@ static const struct cppi_glue_infos am335x_usb_infos = {
.qmgr_num_pend = 5,
 };
 
+static const struct cppi_glue_infos da8xx_usb_infos = {
+   .queues_rx = da8xx_usb_queues_rx,
+   .queues_tx = da8xx_usb_queues_tx,
+   .td_queue = { .submit = 31, .complete = 0 },
+   .first_completion_queue = 24,
+   .qmgr_num_pend = 2,
+};
+
 static const struct of_device_id cppi41_dma_ids[] = {
{ .compatible = "ti,am3359-cppi41", .data = &am335x_usb_infos},
+   { .compatible = "ti,da830-cppi41", .data = &da8xx_usb_infos},
{},
 };
 MODULE_DEVICE_TABLE(of, cppi41_dma_ids);
-- 
2.10.2

--
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 v3 1/3] dt/bindings: da8xx-usb: Add binding for the CPPI 4.1 DMA controller

2017-01-24 Thread Alexandre Bailon
DT binding for the TI DA8xx/OMAP-L1x/AM17xx/AM18xx CPPI 4.1 DMA controller.

Signed-off-by: Alexandre Bailon 
---
 .../devicetree/bindings/usb/da8xx-usb.txt  | 39 ++
 1 file changed, 39 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/da8xx-usb.txt 
b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
index ccb844a..c3944a6 100644
--- a/Documentation/devicetree/bindings/usb/da8xx-usb.txt
+++ b/Documentation/devicetree/bindings/usb/da8xx-usb.txt
@@ -18,10 +18,26 @@ Required properties:
 
  - phy-names: Should be "usb-phy"
 
+ - dmas: specifies the dma channels
+
+ - dma-names: specifies the names of the channels. Use "rxN" for receive
+   and "txN" for transmit endpoints. N specifies the endpoint number.
+
 Optional properties:
 
  - vbus-supply: Phandle to a regulator providing the USB bus power.
 
+DMA
+~~~
+- compatible: ti,da830-cppi41
+- reg: offset and length of the following register spaces: CPPI DMA Controller,
+  CPPI DMA Scheduler, Queue Manager
+- reg-names: "controller", "scheduler", "queuemgr"
+- #dma-cells: should be set to 2. The first number represents the
+  channel number (0 … 3 for endpoints 1 … 4).
+  The second number is 0 for RX and 1 for TX transfers.
+- #dma-channels: should be set to 4 representing the 4 endpoints.
+
 Example:
usb_phy: usb-phy {
compatible = "ti,da830-usb-phy";
@@ -31,6 +47,9 @@ Example:
usb0: usb@20 {
compatible = "ti,da830-musb";
reg =   <0x0020 0x1>;
+   ranges;
+   #address-cells = <1>;
+   #size-cells = <1>;
interrupts = <58>;
interrupt-names = "mc";
 
@@ -39,5 +58,25 @@ Example:
phys = <&usb_phy 0>;
phy-names = "usb-phy";
 
+   dmas = <&cppi41dma 0 0 &cppi41dma 1 0
+   &cppi41dma 2 0 &cppi41dma 3 0
+   &cppi41dma 0 1 &cppi41dma 1 1
+   &cppi41dma 2 1 &cppi41dma 3 1>;
+   dma-names =
+   "rx1", "rx2", "rx3", "rx4",
+   "tx1", "tx2", "tx3", "tx4";
+
status = "okay";
+
+   cppi41dma: dma-controller@201000 {
+   compatible = "ti,da830-cppi41";
+   reg =  <0x201000 0x1000
+   0x202000 0x1000
+   0x204000 0x4000>;
+   reg-names = "controller", "scheduler", "queuemgr";
+   interrupts = <58>;
+   #dma-cells = <2>;
+   #dma-channels = <4>;
+   };
+
};
-- 
2.10.2

--
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 v3 0/3] dmaengine: cppi41: Add dma support to da8xx

2017-01-24 Thread Alexandre Bailon
This series add support of DA8xx to CPPI 4.1 driver.
As the CPPI 4.1 is now generic, we only had to add the glue for DA8xx.

This serie should applied on top of 
"[PATCH v3 0/7] dmaengine: cppi41: Make CPPI 4.1 driver more generic".

Changes in v3:
 - Fix few typos
 - Don't use a wildcard for the compatible property

Changes in v2:
- most of patches of v1 has been moved to the series
  "[PATCH v2 0/7] dmaengine: cppi41: Make CPPI 4.1 driver more generic".
- some patches of v1 has been removed because they were no required
  anymore because CPPI 4.1 driver has been made more generic.
- In v1, the driver were managing the clock for DA8xx paltform.
  This is not needed as CPPI 4.1 will be a child of MUSB DA8xx glue,
  we can use PM runtime and let the DA8xx glue driver manage it.

Alexandre Bailon (3):
  dt/bindings: da8xx-usb: Add binding for the CPPI 4.1 DMA controller
  dmaengine: cppi41: Add support of DA8xx to CPPI 4.1
  dmaengine: cppi41: Fix teardown warnings

 .../devicetree/bindings/usb/da8xx-usb.txt  | 39 ++
 drivers/dma/Kconfig|  6 ++--
 drivers/dma/cppi41.c   | 27 +--
 3 files changed, 67 insertions(+), 5 deletions(-)

-- 
2.10.2

--
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 0/6] usb: musb: cppi41: Add a way to manage DMA irq

2017-01-24 Thread Alexandre Bailon
On 01/23/2017 10:26 PM, Bin Liu wrote:
> On Mon, Jan 23, 2017 at 05:48:02PM +0100, Alexandre Bailon wrote:
> > This series was "dmaengine: cppi41: Make the driver more generic".
> > I have tried to separate as munch I could CPPI 4.1 MUSB driver changes.
> >
> > Currently, the DMA interrupt is managed by the CPPI 4.1 driver.
> > The issue here is the CPPI 4.1 driver must access to MUSB glue registers
> > to manage its interrupt.
> > In order to move the interrupts management from CPPI 4.1 driver to MUSB
> > (and then make it more generic), update the MUSB CPPI 4.1 driver with
> > changes that will help to manage DMA interrupt from MUSB driver.
> >
> > Changes in v4:
> > - Remove musb pointer from struct cppi, cppi41_dma_controller and
> >   tusb_omap_dma.
> >
> > Changes in v3:
> > - Move a patch from another series to this one to avoid build error report
> >   from kbuild test robot
> > - Instead of adding and exporting function, add one callback and a pointer
> >   to musb in struct dma_controller
> > - Surround the DMA function introduced in musb_dsps with #ifdef / #endif.
> >
> > Changes in v2:
> > - Fix some typo in commit messages
> > - Add more explanation about some changes made by patch 2 in commit message
> >
> > Alexandre Bailon (6):
> >   usb: musb: dma: Add a DMA completion platform callback
> >   usb: musb: cppi41: Detect aborted transfers in cppi41_dma_callback()
> >   usb: musb: cppi_dma: Clean up cppi structure
> >   usb: musb: cppi_dma: Clean up cppi41_dma_controller structure
> >   usb: musb: cppi_dma: Clean up tusb_omap_dma structure
> >   usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in DSPS
> >
> >  drivers/dma/cppi41.c | 28 --
> >  drivers/usb/musb/cppi_dma.c  | 26 ++---
> >  drivers/usb/musb/cppi_dma.h  |  1 -
> >  drivers/usb/musb/musb_cppi41.c   | 48 +---
> >  drivers/usb/musb/musb_dma.h  |  5 +++
> >  drivers/usb/musb/musb_dsps.c | 81 
> > +++-
> >  drivers/usb/musb/tusb6010_omap.c |  7 ++--
> >  7 files changed, 134 insertions(+), 62 deletions(-)
> >
>
> Please keep linux-usb list cc'd.
Sorry about that. I will be more careful.
>
> Regards,
> -Bin.
>
Regards,
Alexandre
--
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 2/3] dmaengine: cppi41: Add support of DA8xx to CPPI 4.1

2017-01-23 Thread Alexandre Bailon
On 01/19/2017 07:15 PM, Sergei Shtylyov wrote:
> On 01/19/2017 02:13 PM, Alexandre Bailon wrote:
>
> > The DA8xx has a CPPI 4.1 DMA controller.
> > This is add the glue layer required to make it work on DA8xx.
> >
> > Signed-off-by: Alexandre Bailon 
> > ---
> >  drivers/dma/Kconfig  |  6 +++---
> >  drivers/dma/cppi41.c | 24 
> >  2 files changed, 27 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
> > index 0d6a96e..03ae2a1 100644
> > --- a/drivers/dma/Kconfig
> > +++ b/drivers/dma/Kconfig
> > @@ -514,12 +514,12 @@ config TIMB_DMA
> >Enable support for the Timberdale FPGA DMA engine.
> >
> >  config TI_CPPI41
> > -tristate "AM33xx CPPI41 DMA support"
> > -depends on ARCH_OMAP
> > +tristate "CPPI41 DMA support"
>
>Grr... CPPI 4.1, please.
>
> > +depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX)
> >  select DMA_ENGINE
> >  help
> >The Communications Port Programming Interface (CPPI) 4.1 DMA
> > engine
> > -  is currently used by the USB driver on AM335x platforms.
> > +  is currently used by the USB driver on AM335x and DA8xx platforms.
> >
> >  config TI_DMA_CROSSBAR
> >  bool
> > diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
> > index 9767b97..f6f2d84 100644
> > --- a/drivers/dma/cppi41.c
> > +++ b/drivers/dma/cppi41.c
> [...]
> > @@ -951,8 +965,18 @@ static const struct cppi_glue_infos
> > am335x_usb_infos = {
> >  .qmgr_num_pend = 5,
> >  };
> >
> > +static const struct cppi_glue_infos da8xx_usb_infos = {
> > +.isr = cppi41_irq,
>
>Isn't the ISR the same for all glues now?
True. I should remove isr callback.
>
> [...]
>
> MBR, Sergei
>

--
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 1/3] usb: musb: dma: Add a DMA completion platform callback

2017-01-23 Thread Alexandre Bailon
On 01/20/2017 09:00 PM, Bin Liu wrote:
> On Thu, Jan 19, 2017 at 11:06:57AM +0100, Alexandre Bailon wrote:
>> Currently, the CPPI 4.1 driver is not completely generic and
>> only work on dsps. This is because of IRQ management.
>> Add a callback to dma_controller that could be invoked on DMA completion
>> to acknodlege the IRQ.
>>
>> Signed-off-by: Alexandre Bailon 
>> ---
>>  drivers/usb/musb/musb_cppi41.c | 7 +--
>>  drivers/usb/musb/musb_dma.h| 4 
>>  2 files changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
>> index 1636385..f7d3d27 100644
>> --- a/drivers/usb/musb/musb_cppi41.c
>> +++ b/drivers/usb/musb/musb_cppi41.c
>> @@ -217,6 +217,10 @@ static void cppi41_dma_callback(void *private_data)
>>  int is_hs = 0;
>>  bool empty;
>>  
>> +controller = cppi41_channel->controller;
>> +if (controller->controller.dma_callback)
>> +controller->controller.dma_callback(&controller->controller);
>> +
>>  spin_lock_irqsave(&musb->lock, flags);
>>  
>>  dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie,
>> @@ -249,8 +253,6 @@ static void cppi41_dma_callback(void *private_data)
>>   * We spin on HS (no longer than than 25us and setup a timer on
>>   * FS to check for the bit and complete the transfer.
>>   */
>> -controller = cppi41_channel->controller;
>> -
>>  if (is_host_active(musb)) {
>>  if (musb->port1_status & USB_PORT_STAT_HIGH_SPEED)
>>  is_hs = 1;
>> @@ -695,6 +697,7 @@ cppi41_dma_controller_create(struct musb *musb, void 
>> __iomem *base)
>>  controller->controller.channel_program = cppi41_dma_channel_program;
>>  controller->controller.channel_abort = cppi41_dma_channel_abort;
>>  controller->controller.is_compatible = cppi41_is_compatible;
>> +controller->controller.musb = musb;
>>  
>>  ret = cppi41_dma_controller_start(controller);
>>  if (ret)
>> diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h
>> index 46357e1..8bea0cd 100644
>> --- a/drivers/usb/musb/musb_dma.h
>> +++ b/drivers/usb/musb/musb_dma.h
>> @@ -181,10 +181,13 @@ dma_channel_status(struct dma_channel *c)
>>   * @channel_release: call this to release a DMA channel
>>   * @channel_abort: call this to abort a pending DMA transaction,
>>   *  returning it to FREE (but allocated) state
>> + * @platform_dma_callback: invoked on DMA completion, useful to run platform
>> + *  code such IRQ acknowledgment.
>>   *
>>   * Controllers manage dma channels.
>>   */
>>  struct dma_controller {
>> +struct musb *musb;
> 
> Since musb is added here, can we clean up the corresponding one in
> struct cppi41_dma_controller and struct cppi?
Yes, and also for the one in tusb_omap_dma.
> 
> Regards,
> -Bin.
> 
Regards,
Alexandre
--
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 3/3] usb: musb: dsps: Manage CPPI 4.1 DMA interrupt in dsps

2017-01-23 Thread Alexandre Bailon
On 01/20/2017 09:17 PM, Bin Liu wrote:
> On Thu, Jan 19, 2017 at 11:06:59AM +0100, Alexandre Bailon wrote:
>> Despite the CPPI 4.1 is a generic DMA, it is tied to USB.
>> On the dsps, CPPI 4.1 interrupt's registers are in USBSS (the MUSB glue).
>> Currently, to enable / disable and clear interrupts, the CPPI 4.1 driver
>> maps and accesses to USBSS's register, which making CPPI 4.1 driver not
>> really generic.
>> Move the interrupt management to dsps driver.
>>
>> Signed-off-by: Alexandre Bailon 
>> ---
>>  drivers/dma/cppi41.c | 28 
>>  drivers/usb/musb/musb_dsps.c | 77 
>> ++--
>>  2 files changed, 82 insertions(+), 23 deletions(-)
> 
> This patch touches both dma and musb modules, I know it makes review
> easier, but how we get it merged? One maintainer ACK it and the other
> pick it up? Sorry for the dumb question, I am new as a maintainer...
> 
>>
>> diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c
>> index d5ba43a..4999e7d 100644
>> --- a/drivers/dma/cppi41.c
>> +++ b/drivers/dma/cppi41.c
> 
> [...]
> 
>> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
>> index 9f125e1..9dad3a6 100644
>> --- a/drivers/usb/musb/musb_dsps.c
>> +++ b/drivers/usb/musb/musb_dsps.c
>> @@ -121,6 +121,7 @@ struct dsps_glue {
>>  struct timer_list timer;/* otg_workaround timer */
>>  unsigned long last_timer;/* last timer data for each instance */
>>  bool sw_babble_enabled;
>> +void __iomem *usbss_base;
>>  
>>  struct dsps_context context;
>>  struct debugfs_regset32 regset;
>> @@ -145,6 +146,13 @@ static const struct debugfs_reg32 dsps_musb_regs[] = {
>>  { "mode",   0xe8 },
>>  };
>>  
>> +/* USBSS  / USB AM335x */
>> +#define USBSS_IRQ_STATUS0x28
>> +#define USBSS_IRQ_ENABLER   0x2c
>> +#define USBSS_IRQ_CLEARR0x30
>> +
>> +#define USBSS_IRQ_PD_COMP   (1 <<  2)
> 
> Please fix the double white spaces bwteen '<' and '2' this time.
> 
>> +
>>  /**
>>   * dsps_musb_enable - enable interrupts
>>   */
>> @@ -619,14 +627,72 @@ static void dsps_read_fifo32(struct musb_hw_ep *hw_ep, 
>> u16 len, u8 *dst)
>>  }
>>  }
>>  
>> +#ifdef CONFIG_USB_TI_CPPI41_DMA
>> +static void dsps_dma_controller_callback(struct dma_controller *c)
>> +{
>> +struct musb *musb = c->musb;
>> +struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent);
>> +void __iomem *usbss_base = glue->usbss_base;
>> +u32 status;
>> +
>> +status = musb_readl(usbss_base, USBSS_IRQ_STATUS);
>> +if (status & USBSS_IRQ_PD_COMP)
>> +musb_writel(usbss_base, USBSS_IRQ_STATUS, USBSS_IRQ_PD_COMP);
>> +}
>> +
>> +static struct dma_controller *
>> +dsps_dma_controller_create(struct musb *musb, void __iomem *base)
>> +{
>> +struct dma_controller *controller;
>> +struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent);
>> +void __iomem *usbss_base = glue->usbss_base;
>> +
>> +controller = cppi41_dma_controller_create(musb, base);
>> +if (IS_ERR_OR_NULL(controller))
>> +return controller;
>> +
>> +musb_writel(usbss_base, USBSS_IRQ_ENABLER, USBSS_IRQ_PD_COMP);
>> +controller->dma_callback = dsps_dma_controller_callback;
>> +
>> +return controller;
>> +}
>> +
>> +static void dsps_dma_controller_destroy(struct dma_controller *c)
>> +{
>> +struct musb *musb = c->musb;
>> +struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent);
>> +void __iomem *usbss_base = glue->usbss_base;
>> +
>> +musb_writel(usbss_base, USBSS_IRQ_CLEARR, USBSS_IRQ_PD_COMP);
>> +cppi41_dma_controller_destroy(c);
>> +}
>> +
>> +static void dsps_dma_controller_suspend(struct dsps_glue *glue)
>> +{
>> +void __iomem *usbss_base = glue->usbss_base;
>> +
>> +musb_writel(usbss_base, USBSS_IRQ_CLEARR, USBSS_IRQ_PD_COMP);
>> +}
>> +
>> +static void dsps_dma_controller_resume(struct dsps_glue *glue)
>> +{
>> +void __iomem *usbss_base = glue->usbss_base;
>> +
>> +musb_writel(usbss_base, USBSS_IRQ_ENABLER, USBSS_IRQ_PD_COMP);
>> +}
> 
> The two functions above need to be wrapped in CONFIG_PM_SLEEP.
> 
>> +#else
>> +static void dsps_dma_controller_suspend(struct dsps_glue

Re: [PATCH v3 4/5] usb: musb: musb_cppi41: Workaround DMA stall issue during teardown

2017-01-20 Thread Alexandre Bailon
On 01/19/2017 05:56 PM, Tony Lindgren wrote:
> * Alexandre Bailon  [170119 06:09]:
>> The DMA may hung up if a teardown is initiated while an endpoint is still
>> active (Advisory 2.3.27 of DA8xx errata).
>> To workaround this issue, add a delay before to initiate the teardown.
>>
>> Signed-off-by: Alexandre Bailon 
>> ---
>>  drivers/usb/musb/da8xx.c   | 2 +-
>>  drivers/usb/musb/musb_core.h   | 1 +
>>  drivers/usb/musb/musb_cppi41.c | 4 
>>  3 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
>> index 5f50a78..8c9850c 100644
>> --- a/drivers/usb/musb/da8xx.c
>> +++ b/drivers/usb/musb/da8xx.c
>> @@ -483,7 +483,7 @@ da8xx_dma_controller_create(struct musb *musb, void 
>> __iomem *base)
>>  #endif
>>  
>>  static const struct musb_platform_ops da8xx_ops = {
>> -.quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41,
>> +.quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41 | MUSB_DA8XX,
>>  .init   = da8xx_musb_init,
>>  .exit   = da8xx_musb_exit,
>>  
>> diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
>> index ade902e..d129278 100644
>> --- a/drivers/usb/musb/musb_core.h
>> +++ b/drivers/usb/musb/musb_core.h
>> @@ -172,6 +172,7 @@ struct musb_io;
>>   */
>>  struct musb_platform_ops {
>>  
>> +#define MUSB_DA8XX  BIT(7)
>>  #define MUSB_DMA_UX500  BIT(6)
>>  #define MUSB_DMA_CPPI41 BIT(5)
>>  #define MUSB_DMA_CPPI   BIT(4)
>> diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
>> index 1fe7eae..d371d05 100644
>> --- a/drivers/usb/musb/musb_cppi41.c
>> +++ b/drivers/usb/musb/musb_cppi41.c
>> @@ -554,6 +554,10 @@ static int cppi41_dma_channel_abort(struct dma_channel 
>> *channel)
>>  }
>>  }
>>  
>> +/* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
>> +if (musb->io.quirks & MUSB_DA8XX)
>> +mdelay(250);
>> +
>>  tdbit = 1 << cppi41_channel->port_num;
>>  if (is_tx)
>>  tdbit <<= 16;
> 
> How about replace the do while loop calling  dmaengine_terminate_all() with
> deferred work doing that?
That would be great but I don't know how hard to would be to do it.
Right after the teardown, we may have to queue a new request.
But we must be sure that the teardown has completed before to start
a new transfer. And because it happen in atomic section, we must also
defer it.
> 
> That way it's more generic as it seems there's no hurry doing that
> after the musb registers are cleared. That would also allow getting rid of
> the two current udelay() calls there that also seems nasty.
> 
> Regards,
> 
> Tony
> 
Regards,
Alexandre
--
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] arm: davinci: Make the usb20 clock available to PM runtime

2017-01-20 Thread Alexandre Bailon
On 01/20/2017 10:24 AM, Sekhar Nori wrote:
> On Thursday 19 January 2017 11:01 PM, Alexandre Bailon wrote:
>> On 01/19/2017 05:49 PM, Grygorii Strashko wrote:
>>> On 01/19/2017 09:08 AM, Alexandre Bailon wrote:
>>>> On 01/19/2017 03:48 PM, Sekhar Nori wrote:
>>>>> On Thursday 19 January 2017 07:39 PM, Alexandre Bailon wrote:
>>>>>> Add usb20 to the list of clock supported by PM runtime.
>>>>>>
>>>>>> Signed-off-by: Alexandre Bailon 
>>>>>> ---
>>>>>>  arch/arm/mach-davinci/pm_domain.c | 2 +-
>>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/arch/arm/mach-davinci/pm_domain.c 
>>>>>> b/arch/arm/mach-davinci/pm_domain.c
>>>>>> index 78eac2c..66471f2 100644
>>>>>> --- a/arch/arm/mach-davinci/pm_domain.c
>>>>>> +++ b/arch/arm/mach-davinci/pm_domain.c
>>>>>> @@ -23,7 +23,7 @@ static struct dev_pm_domain davinci_pm_domain = {
>>>>>>  
>>>>>>  static struct pm_clk_notifier_block platform_bus_notifier = {
>>>>>>  .pm_domain = &davinci_pm_domain,
>>>>>> -.con_ids = { "fck", "master", "slave", NULL },
>>>>>> +.con_ids = { "fck", "master", "slave", "usb20", NULL },
>>>>>
>>>>> Instead of doing this, can we drop the con_id from musb clock? Looking
>>>>> at the USB clocking diagram in the TRM. There is a single clock input to
>>>>> the USB 2.0 subsystem. There is no real need for a con_id at all.
>>>> Currently, the con_id is required to get the usb20 clock from usb-da8xx.c
>>>> I will try to figure out which changes are required remove con_id.
>>>
>>> It most probably should be renamed to "fck" then it should work with your
>>> patch "[PATCH v3 5/5] usb: musb: da8xx: Add a primary support of PM 
>>> runtime".
> 
>> Actually, because of the USB phy, more changes are required.
>> Something like that works for me.
> 
> There are too many things going on in your patch and I am not clear why 
> all of those changes are needed. The following diff worked for me on top
> of master branch of my tree. Can you check if this works for you? If not,
> I need some more explanation of why you are making all the changes that
> you are.
Your patch works.
I guess I have forgotten something when I have tried to do it by myself
because the phy was not working.

Thanks,
Alexandre
> 
> Thanks,
> Sekhar
> 
> ---8<---
> diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
> index 073c458d0c67..2cfd9d70a818 100644
> --- a/arch/arm/mach-davinci/da830.c
> +++ b/arch/arm/mach-davinci/da830.c
> @@ -412,7 +412,7 @@ static struct clk_lookup da830_clks[] = {
>   CLK("davinci-mcasp.0",  NULL,   &mcasp0_clk),
>   CLK("davinci-mcasp.1",  NULL,   &mcasp1_clk),
>   CLK("davinci-mcasp.2",  NULL,   &mcasp2_clk),
> - CLK("musb-da8xx",   "usb20",&usb20_clk),
> + CLK("musb-da8xx",   NULL,   &usb20_clk),
>   CLK(NULL,   "aemif",&aemif_clk),
>   CLK(NULL,   "aintc",&aintc_clk),
>   CLK(NULL,   "secu_mgr", &secu_mgr_clk),
> diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
> index 55f6e1172517..946cd06d8c05 100644
> --- a/arch/arm/mach-davinci/da850.c
> +++ b/arch/arm/mach-davinci/da850.c
> @@ -567,7 +567,7 @@ static struct clk_lookup da850_clks[] = {
>*/
>   CLK(NULL,   "aemif",&aemif_nand_clk),
>   CLK("ohci-da8xx",   "usb11",&usb11_clk),
> - CLK("musb-da8xx",   "usb20",&usb20_clk),
> + CLK("musb-da8xx",   NULL,   &usb20_clk),
>   CLK("spi_davinci.0",NULL,   &spi0_clk),
>   CLK("spi_davinci.1",NULL,   &spi1_clk),
>   CLK("vpif", NULL,   &vpif_clk),
> diff --git a/arch/arm/mach-davinci/usb-da8xx.c 
> b/arch/arm/mach-davinci/usb-da8xx.c
> index 9a6af0bd5dc3..9b667689b665 100644
> --- a/arch/arm/mach-davinci/usb-da8xx.c
> +++ b/arch/arm/mach-davinci/usb-da8xx.c
> @@ -275,7 +275,7 @@ int __init da8xx_register_usb20_phy_clk(bool 
> use_usb_re

Re: [PATCH] arm: davinci: Make the usb20 clock available to PM runtime

2017-01-19 Thread Alexandre Bailon
On 01/19/2017 05:49 PM, Grygorii Strashko wrote:
> On 01/19/2017 09:08 AM, Alexandre Bailon wrote:
>> On 01/19/2017 03:48 PM, Sekhar Nori wrote:
>>> On Thursday 19 January 2017 07:39 PM, Alexandre Bailon wrote:
>>>> Add usb20 to the list of clock supported by PM runtime.
>>>>
>>>> Signed-off-by: Alexandre Bailon 
>>>> ---
>>>>  arch/arm/mach-davinci/pm_domain.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/arm/mach-davinci/pm_domain.c 
>>>> b/arch/arm/mach-davinci/pm_domain.c
>>>> index 78eac2c..66471f2 100644
>>>> --- a/arch/arm/mach-davinci/pm_domain.c
>>>> +++ b/arch/arm/mach-davinci/pm_domain.c
>>>> @@ -23,7 +23,7 @@ static struct dev_pm_domain davinci_pm_domain = {
>>>>  
>>>>  static struct pm_clk_notifier_block platform_bus_notifier = {
>>>>.pm_domain = &davinci_pm_domain,
>>>> -  .con_ids = { "fck", "master", "slave", NULL },
>>>> +  .con_ids = { "fck", "master", "slave", "usb20", NULL },
>>>
>>> Instead of doing this, can we drop the con_id from musb clock? Looking
>>> at the USB clocking diagram in the TRM. There is a single clock input to
>>> the USB 2.0 subsystem. There is no real need for a con_id at all.
>> Currently, the con_id is required to get the usb20 clock from usb-da8xx.c
>> I will try to figure out which changes are required remove con_id.
> 
> It most probably should be renamed to "fck" then it should work with your
> patch "[PATCH v3 5/5] usb: musb: da8xx: Add a primary support of PM runtime".
Actually, because of the USB phy, more changes are required.
Something like that works for me.
---
 arch/arm/mach-davinci/da850.c |  8 
 arch/arm/mach-davinci/usb-da8xx.c | 36 ++--
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 1d873d1..c143591 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -394,13 +394,6 @@ static struct clk usb11_clk = {
.gpsc   = 1,
 };
 
-static struct clk usb20_clk = {
-   .name   = "usb20",
-   .parent = &pll0_sysclk2,
-   .lpsc   = DA8XX_LPSC1_USB20,
-   .gpsc   = 1,
-};
-
 static struct clk spi0_clk = {
.name   = "spi0",
.parent = &pll0_sysclk2,
@@ -567,7 +560,6 @@ static struct clk_lookup da850_clks[] = {
 */
CLK(NULL,   "aemif",&aemif_nand_clk),
CLK("ohci-da8xx",   "usb11",&usb11_clk),
-   CLK("musb-da8xx",   "usb20",&usb20_clk),
CLK("spi_davinci.0",NULL,   &spi0_clk),
CLK("spi_davinci.1",NULL,   &spi1_clk),
CLK("vpif", NULL,   &vpif_clk),
diff --git a/arch/arm/mach-davinci/usb-da8xx.c 
b/arch/arm/mach-davinci/usb-da8xx.c
index 9a6af0b..421b4a1 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -16,13 +16,19 @@
 #include 
 #include 
 #include 
+#include "psc.h"
 
 #include "clock.h"
 
 #define DA8XX_USB0_BASE0x01e0
 #define DA8XX_USB1_BASE0x01e25000
 
-static struct clk *usb20_clk;
+static struct clk usb20_clk = {
+   .name   = "usb20",
+   .parent = NULL,
+   .lpsc   = DA8XX_LPSC1_USB20,
+   .gpsc   = 1,
+};
 
 static struct platform_device da8xx_usb_phy = {
.name   = "da8xx-usb-phy",
@@ -166,7 +172,7 @@ static void usb20_phy_clk_enable(struct clk *clk)
val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG));
 
/* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */
-   davinci_clk_enable(usb20_clk);
+   davinci_clk_enable(&usb20_clk);
 
/*
 * Turn on the USB 2.0 PHY, but just the PLL, and not OTG. The USB 1.1
@@ -186,7 +192,7 @@ static void usb20_phy_clk_enable(struct clk *clk)
 
pr_err("Timeout waiting for USB 2.0 PHY clock good\n");
 done:
-   davinci_clk_disable(usb20_clk);
+   davinci_clk_disable(&usb20_clk);
 }
 
 static void usb20_phy_clk_disable(struct clk *clk)
@@ -261,8 +267,10 @@ static struct clk usb20_phy_clk = {
.set_parent = usb20_phy_clk_set_parent,
 };
 
-static struct clk_lookup usb20_phy_clk_lookup =
-   CLK("da8xx-usb-phy", "usb20_phy", &usb20_phy_clk);
+static struct clk_lookup usb20_clks[] = {
+

Re: [PATCH v3 3/5] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx

2017-01-19 Thread Alexandre Bailon
On 01/19/2017 03:08 PM, Alexandre Bailon wrote:
> Currently, only the PIO mode is supported.
> This add support of CPPI 4.1 to DA8xx.
> As the In DA8xx the CPPI 4.1 DMA is a part of the USB.
> Create the CPPI 4.1 device as a child of USB.
> 
> Signed-off-by: Alexandre Bailon 
> ---
>  drivers/usb/musb/Kconfig |  4 ++--
>  drivers/usb/musb/da8xx.c | 35 ++-
>  2 files changed, 36 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
> index 72a2a50..5506a9c 100644
> --- a/drivers/usb/musb/Kconfig
> +++ b/drivers/usb/musb/Kconfig
> @@ -160,8 +160,8 @@ config USB_TI_CPPI_DMA
> Enable DMA transfers when TI CPPI DMA is available.
>  
>  config USB_TI_CPPI41_DMA
> - bool 'TI CPPI 4.1 (AM335x)'
> - depends on ARCH_OMAP && DMADEVICES
> + bool 'TI CPPI 4.1'
> + depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
>   select TI_CPPI41
>  
>  config USB_TUSB_OMAP_DMA
> diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
> index cd3d763..5f50a78 100644
> --- a/drivers/usb/musb/da8xx.c
> +++ b/drivers/usb/musb/da8xx.c
> @@ -33,6 +33,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -457,12 +458,40 @@ static inline u8 get_vbus_power(struct device *dev)
>   return current_uA / 1000 / 2;
>  }
>  
> +#ifdef CONFIG_USB_TI_CPPI41_DM
There is a typo here...
> +static void da8xx_dma_controller_callback(struct dma_controller *c)
> +{
> + struct musb *musb = c->musb;
> + void __iomem *reg_base = musb->ctrl_base;
> +
> + musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
> +}
> +
> +static struct dma_controller *
> +da8xx_dma_controller_create(struct musb *musb, void __iomem *base)
> +{
> + struct dma_controller *controller;
> +
> + controller = cppi41_dma_controller_create(musb, base);
> + if (IS_ERR_OR_NULL(controller))
> + return controller;
> +
> + controller->dma_callback = da8xx_dma_controller_callback;
> +
> + return controller;
> +}
> +#endif
> +
>  static const struct musb_platform_ops da8xx_ops = {
> - .quirks = MUSB_INDEXED_EP,
> + .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41,
>   .init   = da8xx_musb_init,
>   .exit   = da8xx_musb_exit,
>  
>   .fifo_mode  = 2,
> +#ifdef CONFIG_USB_TI_CPPI41_DMA
> + .dma_init   = da8xx_dma_controller_create,
> + .dma_exit   = cppi41_dma_controller_destroy,
> +#endif
>   .enable = da8xx_musb_enable,
>   .disable= da8xx_musb_disable,
>  
> @@ -534,6 +563,10 @@ static int da8xx_probe(struct platform_device *pdev)
>   }
>   platform_set_drvdata(pdev, glue);
>  
> + ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
> + if (ret)
> + return ret;
> +
>   memset(musb_resources, 0x00, sizeof(*musb_resources) *
>   ARRAY_SIZE(musb_resources));
>  
> 

--
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] arm: davinci: Make the usb20 clock available to PM runtime

2017-01-19 Thread Alexandre Bailon
On 01/19/2017 03:48 PM, Sekhar Nori wrote:
> On Thursday 19 January 2017 07:39 PM, Alexandre Bailon wrote:
>> Add usb20 to the list of clock supported by PM runtime.
>>
>> Signed-off-by: Alexandre Bailon 
>> ---
>>  arch/arm/mach-davinci/pm_domain.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-davinci/pm_domain.c 
>> b/arch/arm/mach-davinci/pm_domain.c
>> index 78eac2c..66471f2 100644
>> --- a/arch/arm/mach-davinci/pm_domain.c
>> +++ b/arch/arm/mach-davinci/pm_domain.c
>> @@ -23,7 +23,7 @@ static struct dev_pm_domain davinci_pm_domain = {
>>  
>>  static struct pm_clk_notifier_block platform_bus_notifier = {
>>  .pm_domain = &davinci_pm_domain,
>> -.con_ids = { "fck", "master", "slave", NULL },
>> +.con_ids = { "fck", "master", "slave", "usb20", NULL },
> 
> Instead of doing this, can we drop the con_id from musb clock? Looking
> at the USB clocking diagram in the TRM. There is a single clock input to
> the USB 2.0 subsystem. There is no real need for a con_id at all.
Currently, the con_id is required to get the usb20 clock from usb-da8xx.c
I will try to figure out which changes are required remove con_id.
> 
> Thanks,
> Sekhar
> 
Thanks,
Alexandre

--
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] ARM: dts: da850: Add the CPPI 4.1 DMA to the USB OTG controller

2017-01-19 Thread Alexandre Bailon
This adds the CPPI 4.1 DMA controller to the USB OTG controller.

Changes since v2:
- Fixed the the property reg-names (had glue register defined)
- Removed few useless property

Signed-off-by: Alexandre Bailon 
---
 arch/arm/boot/dts/da850.dtsi | 25 +
 1 file changed, 25 insertions(+)

diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 104155d..f4a637a 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -396,12 +396,37 @@
usb0: usb@20 {
compatible = "ti,da830-musb";
reg = <0x20 0x1>;
+   ranges;
interrupts = <58>;
interrupt-names = "mc";
dr_mode = "otg";
phys = <&usb_phy 0>;
phy-names = "usb-phy";
status = "disabled";
+
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   dmas = <&cppi41dma 0 0 &cppi41dma 1 0
+   &cppi41dma 2 0 &cppi41dma 3 0
+   &cppi41dma 0 1 &cppi41dma 1 1
+   &cppi41dma 2 1 &cppi41dma 3 1>;
+   dma-names =
+   "rx1", "rx2", "rx3", "rx4",
+   "tx1", "tx2", "tx3", "tx4";
+
+   cppi41dma: dma-controller@201000 {
+   compatible = "ti,da830-cppi41";
+   reg =  <0x201000 0x1000
+   0x202000 0x1000
+   0x204000 0x4000>;
+   reg-names = "controller",
+   "scheduler", "queuemgr";
+   interrupts = <58>;
+   #dma-cells = <2>;
+   #dma-channels = <4>;
+   status = "okay";
+   };
};
mdio: mdio@224000 {
compatible = "ti,davinci_mdio";
-- 
2.10.2

--
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 v3 5/5] usb: musb: da8xx: Add a primary support of PM runtime

2017-01-19 Thread Alexandre Bailon
Currently, DA8xx doesn't support PM runtime.
In addition, the glue driver is managing the clock itself.
But the CPPI DMA needs to manage this clock too.
Add support to PM runtime and use the callback to enable / disable
the clock. And because the CPPI 4.1 is a child of Da8xx USB,
it will be able to enable / disable the clock by using PM runtime.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 8c9850c..c4478c7 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -30,7 +30,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -86,7 +85,6 @@ struct da8xx_glue {
struct device   *dev;
struct platform_device  *musb;
struct platform_device  *usb_phy;
-   struct clk  *clk;
struct phy  *phy;
 };
 
@@ -377,11 +375,7 @@ static int da8xx_musb_init(struct musb *musb)
 
musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
 
-   ret = clk_prepare_enable(glue->clk);
-   if (ret) {
-   dev_err(glue->dev, "failed to enable clock\n");
-   return ret;
-   }
+   pm_runtime_get_sync(musb->controller->parent);
 
/* Returns zero if e.g. not clocked */
rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
@@ -424,7 +418,7 @@ static int da8xx_musb_init(struct musb *musb)
 err_phy_power_on:
phy_exit(glue->phy);
 fail:
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put_sync(musb->controller->parent);
return ret;
 }
 
@@ -436,7 +430,7 @@ static int da8xx_musb_exit(struct musb *musb)
 
phy_power_off(glue->phy);
phy_exit(glue->phy);
-   clk_disable_unprepare(glue->clk);
+   pm_runtime_put_sync(musb->controller->parent);
 
usb_put_phy(musb->xceiv);
 
@@ -519,7 +513,6 @@ static int da8xx_probe(struct platform_device *pdev)
struct musb_hdrc_platform_data  *pdata = dev_get_platdata(&pdev->dev);
struct da8xx_glue   *glue;
struct platform_device_info pinfo;
-   struct clk  *clk;
struct device_node  *np = pdev->dev.of_node;
int ret;
 
@@ -527,12 +520,6 @@ static int da8xx_probe(struct platform_device *pdev)
if (!glue)
return -ENOMEM;
 
-   clk = devm_clk_get(&pdev->dev, "usb20");
-   if (IS_ERR(clk)) {
-   dev_err(&pdev->dev, "failed to get clock\n");
-   return PTR_ERR(clk);
-   }
-
glue->phy = devm_phy_get(&pdev->dev, "usb-phy");
if (IS_ERR(glue->phy)) {
if (PTR_ERR(glue->phy) != -EPROBE_DEFER)
@@ -541,7 +528,6 @@ static int da8xx_probe(struct platform_device *pdev)
}
 
glue->dev   = &pdev->dev;
-   glue->clk   = clk;
 
if (IS_ENABLED(CONFIG_OF) && np) {
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
@@ -587,6 +573,8 @@ static int da8xx_probe(struct platform_device *pdev)
pinfo.data = pdata;
pinfo.size_data = sizeof(*pdata);
 
+   pm_runtime_enable(&pdev->dev);
+
glue->musb = platform_device_register_full(&pinfo);
ret = PTR_ERR_OR_ZERO(glue->musb);
if (ret) {
@@ -603,6 +591,7 @@ static int da8xx_remove(struct platform_device *pdev)
 
platform_device_unregister(glue->musb);
usb_phy_generic_unregister(glue->usb_phy);
+   pm_runtime_disable(&pdev->dev);
 
return 0;
 }
-- 
2.10.2

--
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] arm: davinci: Make the usb20 clock available to PM runtime

2017-01-19 Thread Alexandre Bailon
Add usb20 to the list of clock supported by PM runtime.

Signed-off-by: Alexandre Bailon 
---
 arch/arm/mach-davinci/pm_domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-davinci/pm_domain.c 
b/arch/arm/mach-davinci/pm_domain.c
index 78eac2c..66471f2 100644
--- a/arch/arm/mach-davinci/pm_domain.c
+++ b/arch/arm/mach-davinci/pm_domain.c
@@ -23,7 +23,7 @@ static struct dev_pm_domain davinci_pm_domain = {
 
 static struct pm_clk_notifier_block platform_bus_notifier = {
.pm_domain = &davinci_pm_domain,
-   .con_ids = { "fck", "master", "slave", NULL },
+   .con_ids = { "fck", "master", "slave", "usb20", NULL },
 };
 
 static int __init davinci_pm_runtime_init(void)
-- 
2.10.2

--
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 v3 4/5] usb: musb: musb_cppi41: Workaround DMA stall issue during teardown

2017-01-19 Thread Alexandre Bailon
The DMA may hung up if a teardown is initiated while an endpoint is still
active (Advisory 2.3.27 of DA8xx errata).
To workaround this issue, add a delay before to initiate the teardown.

Signed-off-by: Alexandre Bailon 
---
 drivers/usb/musb/da8xx.c   | 2 +-
 drivers/usb/musb/musb_core.h   | 1 +
 drivers/usb/musb/musb_cppi41.c | 4 
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 5f50a78..8c9850c 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -483,7 +483,7 @@ da8xx_dma_controller_create(struct musb *musb, void __iomem 
*base)
 #endif
 
 static const struct musb_platform_ops da8xx_ops = {
-   .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41,
+   .quirks = MUSB_INDEXED_EP | MUSB_DMA_CPPI41 | MUSB_DA8XX,
.init   = da8xx_musb_init,
.exit   = da8xx_musb_exit,
 
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index ade902e..d129278 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -172,6 +172,7 @@ struct musb_io;
  */
 struct musb_platform_ops {
 
+#define MUSB_DA8XX BIT(7)
 #define MUSB_DMA_UX500 BIT(6)
 #define MUSB_DMA_CPPI41BIT(5)
 #define MUSB_DMA_CPPI  BIT(4)
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index 1fe7eae..d371d05 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -554,6 +554,10 @@ static int cppi41_dma_channel_abort(struct dma_channel 
*channel)
}
}
 
+   /* DA8xx Advisory 2.3.27: wait 250 ms before to start the teardown */
+   if (musb->io.quirks & MUSB_DA8XX)
+   mdelay(250);
+
tdbit = 1 << cppi41_channel->port_num;
if (is_tx)
tdbit <<= 16;
-- 
2.10.2

--
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   3   >