diff mbox

[v2,3/5] usb: musb: Add support of CPPI 4.1 DMA controller to DA8xx

Message ID 20170117143528.11404-4-abailon@baylibre.com (mailing list archive)
State Superseded
Headers show

Commit Message

Alexandre Bailon Jan. 17, 2017, 2:35 p.m. UTC
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 <abailon@baylibre.com>
---
 drivers/dma/Kconfig      |  2 +-
 drivers/usb/musb/Kconfig |  4 ++--
 drivers/usb/musb/da8xx.c | 32 +++++++++++++++++++++++++++++++-
 3 files changed, 34 insertions(+), 4 deletions(-)

Comments

Tony Lindgren Jan. 17, 2017, 4:26 p.m. UTC | #1
* Alexandre Bailon <abailon@baylibre.com> [170117 06:36]:
> 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.

Are you sure there's always just one musb instance on these SoCs?

If you have more than one musb instance, chances are you have an
additional shared wrapper IP around them just like am335x/dm814x/dm816x
have.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandre Bailon Jan. 17, 2017, 4:30 p.m. UTC | #2
On 01/17/2017 05:26 PM, Tony Lindgren wrote:
> * Alexandre Bailon <abailon@baylibre.com> [170117 06:36]:
>> 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.
> 
> Are you sure there's always just one musb instance on these SoCs?
To be honest, I only haven't check for all the SoCs.
> 
> If you have more than one musb instance, chances are you have an
> additional shared wrapper IP around them just like am335x/dm814x/dm816x
> have.
Ok. I will check for the SoCs to see if that is required.
> 
> Regards,
> 
> Tony
> 
Best Regards,
Alexandre

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren Jan. 17, 2017, 4:40 p.m. UTC | #3
* Alexandre Bailon <abailon@baylibre.com> [170117 08:31]:
> On 01/17/2017 05:26 PM, Tony Lindgren wrote:
> > * Alexandre Bailon <abailon@baylibre.com> [170117 06:36]:
> >> 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.
> > 
> > Are you sure there's always just one musb instance on these SoCs?
> To be honest, I only haven't check for all the SoCs.
> > 
> > If you have more than one musb instance, chances are you have an
> > additional shared wrapper IP around them just like am335x/dm814x/dm816x
> > have.
> Ok. I will check for the SoCs to see if that is required.

OK that might avoid big headaches later on if more musb instances
are found on some variants.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexandre Bailon Jan. 17, 2017, 5:06 p.m. UTC | #4
On 01/17/2017 05:40 PM, Tony Lindgren wrote:
> * Alexandre Bailon <abailon@baylibre.com> [170117 08:31]:
>> On 01/17/2017 05:26 PM, Tony Lindgren wrote:
>>> * Alexandre Bailon <abailon@baylibre.com> [170117 06:36]:
>>>> 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.
>>>
>>> Are you sure there's always just one musb instance on these SoCs?
>> To be honest, I only haven't check for all the SoCs.
>>>
>>> If you have more than one musb instance, chances are you have an
>>> additional shared wrapper IP around them just like am335x/dm814x/dm816x
>>> have.
>> Ok. I will check for the SoCs to see if that is required.
> 
> OK that might avoid big headaches later on if more musb instances
> are found on some variants.
I have checked for the AM1705, AM1707, AM1802, AM1806, AM1808, AM1810,
OMAPL132, OMAPL137 and OMAPL138. They don't have more than one
USB OTG instance.
Anyway, if you prefer that I do the shared wrapper IP, I may do it.

Regards,
Alexandre
> 
> Regards,
> 
> Tony
> 

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren Jan. 17, 2017, 5:12 p.m. UTC | #5
* Alexandre Bailon <abailon@baylibre.com> [170117 09:07]:
> On 01/17/2017 05:40 PM, Tony Lindgren wrote:
> > * Alexandre Bailon <abailon@baylibre.com> [170117 08:31]:
> >> On 01/17/2017 05:26 PM, Tony Lindgren wrote:
> >>> * Alexandre Bailon <abailon@baylibre.com> [170117 06:36]:
> >>>> 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.
> >>>
> >>> Are you sure there's always just one musb instance on these SoCs?
> >> To be honest, I only haven't check for all the SoCs.
> >>>
> >>> If you have more than one musb instance, chances are you have an
> >>> additional shared wrapper IP around them just like am335x/dm814x/dm816x
> >>> have.
> >> Ok. I will check for the SoCs to see if that is required.
> > 
> > OK that might avoid big headaches later on if more musb instances
> > are found on some variants.
> I have checked for the AM1705, AM1707, AM1802, AM1806, AM1808, AM1810,
> OMAPL132, OMAPL137 and OMAPL138. They don't have more than one
> USB OTG instance.
> Anyway, if you prefer that I do the shared wrapper IP, I may do it.

Thanks for checking. If you only have one instance, the current solution
seems OK to me. You already have a wrapper driver there :)

Tony

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov Jan. 17, 2017, 5:33 p.m. UTC | #6
On 01/17/2017 05:35 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 <abailon@baylibre.com>
> ---
>  drivers/dma/Kconfig      |  2 +-
>  drivers/usb/musb/Kconfig |  4 ++--
>  drivers/usb/musb/da8xx.c | 32 +++++++++++++++++++++++++++++++-
>  3 files changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
> index 0d6a96e..8fe9de7 100644
> --- a/drivers/dma/Kconfig
> +++ b/drivers/dma/Kconfig
> @@ -515,7 +515,7 @@ config TIMB_DMA
>
>  config TI_CPPI41
>  	tristate "AM33xx CPPI41 DMA support"

    Please also fix this line.

> -	depends on ARCH_OMAP
> +	depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX)
>  	select DMA_ENGINE
>  	help
>  	  The Communications Port Programming Interface (CPPI) 4.1 DMA engine

    However I'm not sure this should be in the same patch with the following...

> diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
> index 72a2a50..3018518 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 (AM335x or DA8xx)'

    I'd drop the list of platforms here.

> +	depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX) && DMADEVICES
>  	select TI_CPPI41
>
>  config USB_TUSB_OMAP_DMA
[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
kernel test robot Jan. 19, 2017, 7:53 a.m. UTC | #7
Hi Alexandre,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.10-rc4 next-20170118]
[cannot apply to balbi-usb/next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Alexandre-Bailon/usb-musb-da8xx-Remove-CPPI-3-0-quirk-and-methods/20170118-064830
config: arm-davinci_all_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/usb/musb/da8xx.c: In function 'da8xx_dma_controller_create':
>> drivers/usb/musb/da8xx.c:470:3: error: implicit declaration of function 'cppi41_register_dma_callback' [-Werror=implicit-function-declaration]
      cppi41_register_dma_callback(controller,
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   At top level:
   drivers/usb/musb/da8xx.c:464:1: warning: 'da8xx_dma_controller_create' defined but not used [-Wunused-function]
    da8xx_dma_controller_create(struct musb *musb, void __iomem *base)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/cppi41_register_dma_callback +470 drivers/usb/musb/da8xx.c

   464	da8xx_dma_controller_create(struct musb *musb, void __iomem *base)
   465	{
   466		struct dma_controller *controller;
   467	
   468		controller = cppi41_dma_controller_create(musb, base);
   469		if (!IS_ERR_OR_NULL(controller))
 > 470			cppi41_register_dma_callback(controller,
   471						     da8xx_dma_controller_callback);
   472		return controller;
   473	}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 0d6a96e..8fe9de7 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -515,7 +515,7 @@  config TIMB_DMA
 
 config TI_CPPI41
 	tristate "AM33xx CPPI41 DMA support"
-	depends on ARCH_OMAP
+	depends on (ARCH_OMAP || ARCH_DAVINCI_DA8XX)
 	select DMA_ENGINE
 	help
 	  The Communications Port Programming Interface (CPPI) 4.1 DMA engine
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 72a2a50..3018518 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 (AM335x or DA8xx)'
+	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..be2d0eb 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -33,6 +33,7 @@ 
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/of_platform.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
@@ -89,6 +90,8 @@  struct da8xx_glue {
 	struct phy		*phy;
 };
 
+static void da8xx_dma_controller_callback(struct musb *musb);
+
 /*
  * Because we don't set CTRL.UINT, it's "important" to:
  *	- not read/write INTRUSB/INTRUSBE (except during
@@ -457,12 +460,35 @@  static inline u8 get_vbus_power(struct device *dev)
 	return current_uA / 1000 / 2;
 }
 
+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))
+		cppi41_register_dma_callback(controller,
+					     da8xx_dma_controller_callback);
+	return controller;
+}
+
+static void da8xx_dma_controller_callback(struct musb *musb)
+{
+	void __iomem *reg_base = musb->ctrl_base;
+
+	musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
+}
+
 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 +560,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));