All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/2] i.MX28: DMA fixups
@ 2012-04-09  3:09 Marek Vasut
  2012-04-09  3:09 ` [U-Boot] [PATCH 1/2] DMA: Split the APBH DMA init into block and channel init Marek Vasut
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Marek Vasut @ 2012-04-09  3:09 UTC (permalink / raw)
  To: u-boot

This patchset fixes DMA issues found on Freescale MX28EVK.

NOTE: This patch depends on:

	http://patchwork.ozlabs.org/patch/150957/

Marek Vasut (2):
  DMA: Split the APBH DMA init into block and channel init
  M28: Pull out CONFIG_APBH_DMA so it's always enabled

 arch/arm/cpu/arm926ejs/mx28/mx28.c   |    6 +++++
 arch/arm/include/asm/arch-mx28/dma.h |    4 ++-
 drivers/dma/apbh_dma.c               |   37 ++++++++++++++-------------------
 drivers/mmc/mxsmmc.c                 |    5 ++++
 drivers/mtd/nand/mxs_nand.c          |   12 ++++++++++-
 include/configs/m28evk.h             |    6 ++++-
 6 files changed, 46 insertions(+), 24 deletions(-)

Cc: Stefano Babic <sbabic@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>

-- 
1.7.9.1

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

* [U-Boot] [PATCH 1/2] DMA: Split the APBH DMA init into block and channel init
  2012-04-09  3:09 [U-Boot] [PATCH 0/2] i.MX28: DMA fixups Marek Vasut
@ 2012-04-09  3:09 ` Marek Vasut
  2012-04-09  3:28   ` [U-Boot] [PATCH 1/2 V2] " Marek Vasut
  2012-04-09  3:09 ` [U-Boot] [PATCH 2/2] M28: Pull out CONFIG_APBH_DMA so it's always enabled Marek Vasut
  2012-04-09  3:11 ` [U-Boot] [PATCH 0/2] i.MX28: DMA fixups Marek Vasut
  2 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2012-04-09  3:09 UTC (permalink / raw)
  To: u-boot

This fixes the issue where mxs_dma_init() was called either twice or never,
without introducing any new init hooks.

The idea is to allow each and every device using the APBH DMA block to
configure and request only the channels it uses, instead of making it call init
for all the channels as is now.

The common DMA block init part, which only configures the block, is then called
from CPUs arch_cpu_init() call.

NOTE: This patch depends on:

	http://patchwork.ozlabs.org/patch/150957/

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
 arch/arm/cpu/arm926ejs/mx28/mx28.c   |    6 +++++
 arch/arm/include/asm/arch-mx28/dma.h |    4 ++-
 drivers/dma/apbh_dma.c               |   37 ++++++++++++++-------------------
 drivers/mmc/mxsmmc.c                 |    5 ++++
 drivers/mtd/nand/mxs_nand.c          |   12 ++++++++++-
 5 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/mx28/mx28.c b/arch/arm/cpu/arm926ejs/mx28/mx28.c
index 01445cd..865dbb3 100644
--- a/arch/arm/cpu/arm926ejs/mx28/mx28.c
+++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c
@@ -30,6 +30,7 @@
 #include <asm/errno.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/dma.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/iomux.h>
 #include <asm/arch/imx-regs.h>
@@ -172,6 +173,11 @@ int arch_cpu_init(void)
 	 */
 	mxs_gpio_init();
 
+#ifdef	CONFIG_APBH_DMA
+	/* Start APBH DMA */
+	mxs_dma_init();
+#endif
+
 	return 0;
 }
 #endif
diff --git a/arch/arm/include/asm/arch-mx28/dma.h b/arch/arm/include/asm/arch-mx28/dma.h
index 52747e2..4a1820b 100644
--- a/arch/arm/include/asm/arch-mx28/dma.h
+++ b/arch/arm/include/asm/arch-mx28/dma.h
@@ -140,6 +140,8 @@ void mxs_dma_desc_free(struct mxs_dma_desc *);
 int mxs_dma_desc_append(int channel, struct mxs_dma_desc *pdesc);
 
 int mxs_dma_go(int chan);
-int mxs_dma_init(void);
+void mxs_dma_init(void);
+int mxs_dma_init_channel(int chan);
+int mxs_dma_release(int chan);
 
 #endif	/* __DMA_H__ */
diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index c086629..82f8ebd 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -316,7 +316,7 @@ static int mxs_dma_request(int channel)
  * The channel will NOT be released if it's marked "busy" (see
  * mxs_dma_enable()).
  */
-static int mxs_dma_release(int channel)
+int mxs_dma_release(int channel)
 {
 	struct mxs_dma_chan *pchan;
 	int ret;
@@ -552,12 +552,10 @@ int mxs_dma_go(int chan)
 /*
  * Initialize the DMA hardware
  */
-int mxs_dma_init(void)
+void mxs_dma_init(void)
 {
 	struct mx28_apbh_regs *apbh_regs =
 		(struct mx28_apbh_regs *)MXS_APBH_BASE;
-	struct mxs_dma_chan *pchan;
-	int ret, channel;
 
 	mx28_reset_block(&apbh_regs->hw_apbh_ctrl0_reg);
 
@@ -576,28 +574,25 @@ int mxs_dma_init(void)
 	writel(APBH_CTRL0_APB_BURST_EN,
 		&apbh_regs->hw_apbh_ctrl0_clr);
 #endif
+}
 
-	for (channel = 0; channel < MXS_MAX_DMA_CHANNELS; channel++) {
-		pchan = mxs_dma_channels + channel;
-		pchan->flags = MXS_DMA_FLAGS_VALID;
+int mxs_dma_init_channel(int channel) {
+	struct mxs_dma_chan *pchan;
+	int ret;
 
-		ret = mxs_dma_request(channel);
+	pchan = mxs_dma_channels + channel;
+	pchan->flags = MXS_DMA_FLAGS_VALID;
 
-		if (ret) {
-			printf("MXS DMA: Can't acquire DMA channel %i\n",
-				channel);
+	ret = mxs_dma_request(channel);
 
-			goto err;
-		}
-
-		mxs_dma_reset(channel);
-		mxs_dma_ack_irq(channel);
+	if (ret) {
+		printf("MXS DMA: Can't acquire DMA channel %i\n",
+			channel);
+		return ret;
 	}
 
-	return 0;
+	mxs_dma_reset(channel);
+	mxs_dma_ack_irq(channel);
 
-err:
-	while (--channel >= 0)
-		mxs_dma_release(channel);
-	return ret;
+	return 0;
 }
diff --git a/drivers/mmc/mxsmmc.c b/drivers/mmc/mxsmmc.c
index dfceaef..35c6bda 100644
--- a/drivers/mmc/mxsmmc.c
+++ b/drivers/mmc/mxsmmc.c
@@ -338,6 +338,7 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int))
 		(struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE;
 	struct mmc *mmc = NULL;
 	struct mxsmmc_priv *priv = NULL;
+	int ret;
 
 	mmc = malloc(sizeof(struct mmc));
 	if (!mmc)
@@ -356,6 +357,10 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int))
 		return -ENOMEM;
 	}
 
+	ret = mxs_dma_init_channel(id);
+	if (ret)
+		return ret;
+
 	priv->mmc_is_wp = wp;
 	priv->id = id;
 	switch (id) {
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 4b1297a..6d8673c 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -1058,7 +1058,7 @@ int mxs_nand_init(struct mxs_nand_info *info)
 {
 	struct mx28_gpmi_regs *gpmi_regs =
 		(struct mx28_gpmi_regs *)MXS_GPMI_BASE;
-	int i = 0;
+	int i = 0, j;
 
 	info->desc = malloc(sizeof(struct mxs_dma_desc *) *
 				MXS_NAND_DMA_DESCRIPTOR_COUNT);
@@ -1074,6 +1074,13 @@ int mxs_nand_init(struct mxs_nand_info *info)
 
 	/* Init the DMA controller. */
 	mxs_dma_init();
+	for (j = MXS_DMA_CHANNEL_AHB_APBH_GPMI0;
+		j <= MXS_DMA_CHANNEL_AHB_APBH_GPMI7; j++)
+	{
+		ret = mxs_dma_init_channel(j);
+		if (ret)
+			goto err3;
+	}
 
 	/* Reset the GPMI block. */
 	mx28_reset_block(&gpmi_regs->hw_gpmi_ctrl0_reg);
@@ -1089,6 +1096,9 @@ int mxs_nand_init(struct mxs_nand_info *info)
 
 	return 0;
 
+err3:
+	for (--j; j >= 0; j--)
+		mxs_dma_release(j);
 err2:
 	free(info->desc);
 err1:
-- 
1.7.9.1

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

* [U-Boot] [PATCH 2/2] M28: Pull out CONFIG_APBH_DMA so it's always enabled
  2012-04-09  3:09 [U-Boot] [PATCH 0/2] i.MX28: DMA fixups Marek Vasut
  2012-04-09  3:09 ` [U-Boot] [PATCH 1/2] DMA: Split the APBH DMA init into block and channel init Marek Vasut
@ 2012-04-09  3:09 ` Marek Vasut
  2012-04-11 14:15   ` Stefano Babic
  2012-04-09  3:11 ` [U-Boot] [PATCH 0/2] i.MX28: DMA fixups Marek Vasut
  2 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2012-04-09  3:09 UTC (permalink / raw)
  To: u-boot

The ABPH DMA is now used also by the SD card. Therefore it has to be enabled
even if NAND is disabled.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
 include/configs/m28evk.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/include/configs/m28evk.h b/include/configs/m28evk.h
index f58f3ad..12059db 100644
--- a/include/configs/m28evk.h
+++ b/include/configs/m28evk.h
@@ -147,12 +147,16 @@
 #endif
 
 /*
+ * APBH DMA
+ */
+#define CONFIG_APBH_DMA
+
+/*
  * NAND
  */
 #define	CONFIG_ENV_SIZE			(16 * 1024)
 #ifdef	CONFIG_CMD_NAND
 #define	CONFIG_NAND_MXS
-#define CONFIG_APBH_DMA
 #define	CONFIG_SYS_MAX_NAND_DEVICE	1
 #define	CONFIG_SYS_NAND_BASE		0x60000000
 #define	CONFIG_SYS_NAND_5_ADDR_CYCLE
-- 
1.7.9.1

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

* [U-Boot] [PATCH 0/2] i.MX28: DMA fixups
  2012-04-09  3:09 [U-Boot] [PATCH 0/2] i.MX28: DMA fixups Marek Vasut
  2012-04-09  3:09 ` [U-Boot] [PATCH 1/2] DMA: Split the APBH DMA init into block and channel init Marek Vasut
  2012-04-09  3:09 ` [U-Boot] [PATCH 2/2] M28: Pull out CONFIG_APBH_DMA so it's always enabled Marek Vasut
@ 2012-04-09  3:11 ` Marek Vasut
  2 siblings, 0 replies; 9+ messages in thread
From: Marek Vasut @ 2012-04-09  3:11 UTC (permalink / raw)
  To: u-boot

Dear Marek Vasut,

> This patchset fixes DMA issues found on Freescale MX28EVK.
> 
> NOTE: This patch depends on:
> 
> 	http://patchwork.ozlabs.org/patch/150957/
> 
> Marek Vasut (2):
>   DMA: Split the APBH DMA init into block and channel init
>   M28: Pull out CONFIG_APBH_DMA so it's always enabled
> 
>  arch/arm/cpu/arm926ejs/mx28/mx28.c   |    6 +++++
>  arch/arm/include/asm/arch-mx28/dma.h |    4 ++-
>  drivers/dma/apbh_dma.c               |   37
> ++++++++++++++------------------- drivers/mmc/mxsmmc.c                 |  
>  5 ++++
>  drivers/mtd/nand/mxs_nand.c          |   12 ++++++++++-
>  include/configs/m28evk.h             |    6 ++++-
>  6 files changed, 46 insertions(+), 24 deletions(-)
> 
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Detlev Zundel <dzu@denx.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>

Fabio, I'd like to merge this into -RC2 in favor of your patch. I think this way 
is better. Can you please test this and give Ack/Nak/T-B ASAP?

Thanks very much in advance!

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH 1/2 V2] DMA: Split the APBH DMA init into block and channel init
  2012-04-09  3:09 ` [U-Boot] [PATCH 1/2] DMA: Split the APBH DMA init into block and channel init Marek Vasut
@ 2012-04-09  3:28   ` Marek Vasut
  2012-04-09  3:34     ` [U-Boot] [PATCH 1/2 V3] " Marek Vasut
  0 siblings, 1 reply; 9+ messages in thread
From: Marek Vasut @ 2012-04-09  3:28 UTC (permalink / raw)
  To: u-boot

This fixes the issue where mxs_dma_init() was called either twice or never,
without introducing any new init hooks.

The idea is to allow each and every device using the APBH DMA block to
configure and request only the channels it uses, instead of making it call init
for all the channels as is now.

The common DMA block init part, which only configures the block, is then called
from CPUs arch_cpu_init() call.

NOTE: This patch depends on:

	http://patchwork.ozlabs.org/patch/150957/

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
 arch/arm/cpu/arm926ejs/mx28/mx28.c   |    6 +++++
 arch/arm/include/asm/arch-mx28/dma.h |    4 ++-
 drivers/dma/apbh_dma.c               |   37 ++++++++++++++-------------------
 drivers/mmc/mxsmmc.c                 |    5 ++++
 drivers/mtd/nand/mxs_nand.c          |   11 +++++++++-
 5 files changed, 40 insertions(+), 23 deletions(-)

V2: Pardon my rebasing mistake:
	mxs_nand.c: In function ?mxs_nand_init?:
	mxs_nand.c:1080:3: error: ?ret? undeclared (first use in this function)
	mxs_nand.c:1080:3: note: each undeclared identifier is reported only once for
	each function it appears in
	make[1]: *** [mxs_nand.o] Error 1
	make[1]: *** Waiting for unfinished jobs....
	make: *** [drivers/mtd/nand/libnand.o] Error 2
	make: *** Waiting for unfinished jobs....

diff --git a/arch/arm/cpu/arm926ejs/mx28/mx28.c b/arch/arm/cpu/arm926ejs/mx28/mx28.c
index 01445cd..865dbb3 100644
--- a/arch/arm/cpu/arm926ejs/mx28/mx28.c
+++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c
@@ -30,6 +30,7 @@
 #include <asm/errno.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/dma.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/iomux.h>
 #include <asm/arch/imx-regs.h>
@@ -172,6 +173,11 @@ int arch_cpu_init(void)
 	 */
 	mxs_gpio_init();
 
+#ifdef	CONFIG_APBH_DMA
+	/* Start APBH DMA */
+	mxs_dma_init();
+#endif
+
 	return 0;
 }
 #endif
diff --git a/arch/arm/include/asm/arch-mx28/dma.h b/arch/arm/include/asm/arch-mx28/dma.h
index 52747e2..4a1820b 100644
--- a/arch/arm/include/asm/arch-mx28/dma.h
+++ b/arch/arm/include/asm/arch-mx28/dma.h
@@ -140,6 +140,8 @@ void mxs_dma_desc_free(struct mxs_dma_desc *);
 int mxs_dma_desc_append(int channel, struct mxs_dma_desc *pdesc);
 
 int mxs_dma_go(int chan);
-int mxs_dma_init(void);
+void mxs_dma_init(void);
+int mxs_dma_init_channel(int chan);
+int mxs_dma_release(int chan);
 
 #endif	/* __DMA_H__ */
diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index c086629..82f8ebd 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -316,7 +316,7 @@ static int mxs_dma_request(int channel)
  * The channel will NOT be released if it's marked "busy" (see
  * mxs_dma_enable()).
  */
-static int mxs_dma_release(int channel)
+int mxs_dma_release(int channel)
 {
 	struct mxs_dma_chan *pchan;
 	int ret;
@@ -552,12 +552,10 @@ int mxs_dma_go(int chan)
 /*
  * Initialize the DMA hardware
  */
-int mxs_dma_init(void)
+void mxs_dma_init(void)
 {
 	struct mx28_apbh_regs *apbh_regs =
 		(struct mx28_apbh_regs *)MXS_APBH_BASE;
-	struct mxs_dma_chan *pchan;
-	int ret, channel;
 
 	mx28_reset_block(&apbh_regs->hw_apbh_ctrl0_reg);
 
@@ -576,28 +574,25 @@ int mxs_dma_init(void)
 	writel(APBH_CTRL0_APB_BURST_EN,
 		&apbh_regs->hw_apbh_ctrl0_clr);
 #endif
+}
 
-	for (channel = 0; channel < MXS_MAX_DMA_CHANNELS; channel++) {
-		pchan = mxs_dma_channels + channel;
-		pchan->flags = MXS_DMA_FLAGS_VALID;
+int mxs_dma_init_channel(int channel) {
+	struct mxs_dma_chan *pchan;
+	int ret;
 
-		ret = mxs_dma_request(channel);
+	pchan = mxs_dma_channels + channel;
+	pchan->flags = MXS_DMA_FLAGS_VALID;
 
-		if (ret) {
-			printf("MXS DMA: Can't acquire DMA channel %i\n",
-				channel);
+	ret = mxs_dma_request(channel);
 
-			goto err;
-		}
-
-		mxs_dma_reset(channel);
-		mxs_dma_ack_irq(channel);
+	if (ret) {
+		printf("MXS DMA: Can't acquire DMA channel %i\n",
+			channel);
+		return ret;
 	}
 
-	return 0;
+	mxs_dma_reset(channel);
+	mxs_dma_ack_irq(channel);
 
-err:
-	while (--channel >= 0)
-		mxs_dma_release(channel);
-	return ret;
+	return 0;
 }
diff --git a/drivers/mmc/mxsmmc.c b/drivers/mmc/mxsmmc.c
index dfceaef..35c6bda 100644
--- a/drivers/mmc/mxsmmc.c
+++ b/drivers/mmc/mxsmmc.c
@@ -338,6 +338,7 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int))
 		(struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE;
 	struct mmc *mmc = NULL;
 	struct mxsmmc_priv *priv = NULL;
+	int ret;
 
 	mmc = malloc(sizeof(struct mmc));
 	if (!mmc)
@@ -356,6 +357,10 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int))
 		return -ENOMEM;
 	}
 
+	ret = mxs_dma_init_channel(id);
+	if (ret)
+		return ret;
+
 	priv->mmc_is_wp = wp;
 	priv->id = id;
 	switch (id) {
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 4b1297a..0572279 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -1058,7 +1058,7 @@ int mxs_nand_init(struct mxs_nand_info *info)
 {
 	struct mx28_gpmi_regs *gpmi_regs =
 		(struct mx28_gpmi_regs *)MXS_GPMI_BASE;
-	int i = 0;
+	int i = 0, j;
 
 	info->desc = malloc(sizeof(struct mxs_dma_desc *) *
 				MXS_NAND_DMA_DESCRIPTOR_COUNT);
@@ -1074,6 +1074,12 @@ int mxs_nand_init(struct mxs_nand_info *info)
 
 	/* Init the DMA controller. */
 	mxs_dma_init();
+	for (j = MXS_DMA_CHANNEL_AHB_APBH_GPMI0;
+		j <= MXS_DMA_CHANNEL_AHB_APBH_GPMI7; j++)
+	{
+		if (mxs_dma_init_channel(j));
+			goto err3;
+	}
 
 	/* Reset the GPMI block. */
 	mx28_reset_block(&gpmi_regs->hw_gpmi_ctrl0_reg);
@@ -1089,6 +1095,9 @@ int mxs_nand_init(struct mxs_nand_info *info)
 
 	return 0;
 
+err3:
+	for (--j; j >= 0; j--)
+		mxs_dma_release(j);
 err2:
 	free(info->desc);
 err1:
-- 
1.7.9.1

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

* [U-Boot] [PATCH 1/2 V3] DMA: Split the APBH DMA init into block and channel init
  2012-04-09  3:28   ` [U-Boot] [PATCH 1/2 V2] " Marek Vasut
@ 2012-04-09  3:34     ` Marek Vasut
  2012-04-09 14:10       ` Fabio Estevam
  2012-04-11 14:14       ` Stefano Babic
  0 siblings, 2 replies; 9+ messages in thread
From: Marek Vasut @ 2012-04-09  3:34 UTC (permalink / raw)
  To: u-boot

This fixes the issue where mxs_dma_init() was called either twice or never,
without introducing any new init hooks.

The idea is to allow each and every device using the APBH DMA block to
configure and request only the channels it uses, instead of making it call init
for all the channels as is now.

The common DMA block init part, which only configures the block, is then called
from CPUs arch_cpu_init() call.

NOTE: This patch depends on:

	http://patchwork.ozlabs.org/patch/150957/

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Detlev Zundel <dzu@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
 arch/arm/cpu/arm926ejs/mx28/mx28.c   |    6 +++++
 arch/arm/include/asm/arch-mx28/dma.h |    4 ++-
 drivers/dma/apbh_dma.c               |   37 ++++++++++++++-------------------
 drivers/mmc/mxsmmc.c                 |    5 ++++
 drivers/mtd/nand/mxs_nand.c          |   12 +++++++++-
 5 files changed, 40 insertions(+), 24 deletions(-)

V2: Rebasing mistake
V3: Rebasing mistake (forgotten mxs_dma_init() in NAND init code)

diff --git a/arch/arm/cpu/arm926ejs/mx28/mx28.c b/arch/arm/cpu/arm926ejs/mx28/mx28.c
index 01445cd..865dbb3 100644
--- a/arch/arm/cpu/arm926ejs/mx28/mx28.c
+++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c
@@ -30,6 +30,7 @@
 #include <asm/errno.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/dma.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/iomux.h>
 #include <asm/arch/imx-regs.h>
@@ -172,6 +173,11 @@ int arch_cpu_init(void)
 	 */
 	mxs_gpio_init();
 
+#ifdef	CONFIG_APBH_DMA
+	/* Start APBH DMA */
+	mxs_dma_init();
+#endif
+
 	return 0;
 }
 #endif
diff --git a/arch/arm/include/asm/arch-mx28/dma.h b/arch/arm/include/asm/arch-mx28/dma.h
index 52747e2..4a1820b 100644
--- a/arch/arm/include/asm/arch-mx28/dma.h
+++ b/arch/arm/include/asm/arch-mx28/dma.h
@@ -140,6 +140,8 @@ void mxs_dma_desc_free(struct mxs_dma_desc *);
 int mxs_dma_desc_append(int channel, struct mxs_dma_desc *pdesc);
 
 int mxs_dma_go(int chan);
-int mxs_dma_init(void);
+void mxs_dma_init(void);
+int mxs_dma_init_channel(int chan);
+int mxs_dma_release(int chan);
 
 #endif	/* __DMA_H__ */
diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c
index c086629..82f8ebd 100644
--- a/drivers/dma/apbh_dma.c
+++ b/drivers/dma/apbh_dma.c
@@ -316,7 +316,7 @@ static int mxs_dma_request(int channel)
  * The channel will NOT be released if it's marked "busy" (see
  * mxs_dma_enable()).
  */
-static int mxs_dma_release(int channel)
+int mxs_dma_release(int channel)
 {
 	struct mxs_dma_chan *pchan;
 	int ret;
@@ -552,12 +552,10 @@ int mxs_dma_go(int chan)
 /*
  * Initialize the DMA hardware
  */
-int mxs_dma_init(void)
+void mxs_dma_init(void)
 {
 	struct mx28_apbh_regs *apbh_regs =
 		(struct mx28_apbh_regs *)MXS_APBH_BASE;
-	struct mxs_dma_chan *pchan;
-	int ret, channel;
 
 	mx28_reset_block(&apbh_regs->hw_apbh_ctrl0_reg);
 
@@ -576,28 +574,25 @@ int mxs_dma_init(void)
 	writel(APBH_CTRL0_APB_BURST_EN,
 		&apbh_regs->hw_apbh_ctrl0_clr);
 #endif
+}
 
-	for (channel = 0; channel < MXS_MAX_DMA_CHANNELS; channel++) {
-		pchan = mxs_dma_channels + channel;
-		pchan->flags = MXS_DMA_FLAGS_VALID;
+int mxs_dma_init_channel(int channel) {
+	struct mxs_dma_chan *pchan;
+	int ret;
 
-		ret = mxs_dma_request(channel);
+	pchan = mxs_dma_channels + channel;
+	pchan->flags = MXS_DMA_FLAGS_VALID;
 
-		if (ret) {
-			printf("MXS DMA: Can't acquire DMA channel %i\n",
-				channel);
+	ret = mxs_dma_request(channel);
 
-			goto err;
-		}
-
-		mxs_dma_reset(channel);
-		mxs_dma_ack_irq(channel);
+	if (ret) {
+		printf("MXS DMA: Can't acquire DMA channel %i\n",
+			channel);
+		return ret;
 	}
 
-	return 0;
+	mxs_dma_reset(channel);
+	mxs_dma_ack_irq(channel);
 
-err:
-	while (--channel >= 0)
-		mxs_dma_release(channel);
-	return ret;
+	return 0;
 }
diff --git a/drivers/mmc/mxsmmc.c b/drivers/mmc/mxsmmc.c
index dfceaef..35c6bda 100644
--- a/drivers/mmc/mxsmmc.c
+++ b/drivers/mmc/mxsmmc.c
@@ -338,6 +338,7 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int))
 		(struct mx28_clkctrl_regs *)MXS_CLKCTRL_BASE;
 	struct mmc *mmc = NULL;
 	struct mxsmmc_priv *priv = NULL;
+	int ret;
 
 	mmc = malloc(sizeof(struct mmc));
 	if (!mmc)
@@ -356,6 +357,10 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int))
 		return -ENOMEM;
 	}
 
+	ret = mxs_dma_init_channel(id);
+	if (ret)
+		return ret;
+
 	priv->mmc_is_wp = wp;
 	priv->id = id;
 	switch (id) {
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 4b1297a..7e19492 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -1058,7 +1058,7 @@ int mxs_nand_init(struct mxs_nand_info *info)
 {
 	struct mx28_gpmi_regs *gpmi_regs =
 		(struct mx28_gpmi_regs *)MXS_GPMI_BASE;
-	int i = 0;
+	int i = 0, j;
 
 	info->desc = malloc(sizeof(struct mxs_dma_desc *) *
 				MXS_NAND_DMA_DESCRIPTOR_COUNT);
@@ -1073,7 +1073,12 @@ int mxs_nand_init(struct mxs_nand_info *info)
 	}
 
 	/* Init the DMA controller. */
-	mxs_dma_init();
+	for (j = MXS_DMA_CHANNEL_AHB_APBH_GPMI0;
+		j <= MXS_DMA_CHANNEL_AHB_APBH_GPMI7; j++)
+	{
+		if (mxs_dma_init_channel(j))
+			goto err3;
+	}
 
 	/* Reset the GPMI block. */
 	mx28_reset_block(&gpmi_regs->hw_gpmi_ctrl0_reg);
@@ -1089,6 +1094,9 @@ int mxs_nand_init(struct mxs_nand_info *info)
 
 	return 0;
 
+err3:
+	for (--j; j >= 0; j--)
+		mxs_dma_release(j);
 err2:
 	free(info->desc);
 err1:
-- 
1.7.9.1

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

* [U-Boot] [PATCH 1/2 V3] DMA: Split the APBH DMA init into block and channel init
  2012-04-09  3:34     ` [U-Boot] [PATCH 1/2 V3] " Marek Vasut
@ 2012-04-09 14:10       ` Fabio Estevam
  2012-04-11 14:14       ` Stefano Babic
  1 sibling, 0 replies; 9+ messages in thread
From: Fabio Estevam @ 2012-04-09 14:10 UTC (permalink / raw)
  To: u-boot

On Mon, Apr 9, 2012 at 12:34 AM, Marek Vasut <marex@denx.de> wrote:
> This fixes the issue where mxs_dma_init() was called either twice or never,
> without introducing any new init hooks.
>
> The idea is to allow each and every device using the APBH DMA block to
> configure and request only the channels it uses, instead of making it call init
> for all the channels as is now.
>
> The common DMA block init part, which only configures the block, is then called
> from CPUs arch_cpu_init() call.
>
> NOTE: This patch depends on:
>
> ? ? ? ?http://patchwork.ozlabs.org/patch/150957/
>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Detlev Zundel <dzu@denx.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>

This fixes the mmc issue on mx28.

Tested-by: Fabio Estevam <fabio.estevam@freescale.com>

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

* [U-Boot] [PATCH 1/2 V3] DMA: Split the APBH DMA init into block and channel init
  2012-04-09  3:34     ` [U-Boot] [PATCH 1/2 V3] " Marek Vasut
  2012-04-09 14:10       ` Fabio Estevam
@ 2012-04-11 14:14       ` Stefano Babic
  1 sibling, 0 replies; 9+ messages in thread
From: Stefano Babic @ 2012-04-11 14:14 UTC (permalink / raw)
  To: u-boot

On 09/04/2012 05:34, Marek Vasut wrote:
> This fixes the issue where mxs_dma_init() was called either twice or never,
> without introducing any new init hooks.
> 
> The idea is to allow each and every device using the APBH DMA block to
> configure and request only the channels it uses, instead of making it call init
> for all the channels as is now.
> 
> The common DMA block init part, which only configures the block, is then called
> from CPUs arch_cpu_init() call.
> 
> NOTE: This patch depends on:
> 
> 	http://patchwork.ozlabs.org/patch/150957/
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Detlev Zundel <dzu@denx.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> ---

After fixing the following checkpatch errors:

ERROR: open brace '{' following function declarations go on the next line
#120: FILE: drivers/dma/apbh_dma.c:579:
+int mxs_dma_init_channel(int channel) {

ERROR: that open brace { should be on the previous line
#195: FILE: drivers/mtd/nand/mxs_nand.c:1076:
+	for (j = MXS_DMA_CHANNEL_AHB_APBH_GPMI0;
+		j <= MXS_DMA_CHANNEL_AHB_APBH_GPMI7; j++)
+	{

total: 2 errors, 0 warnings, 137 lines checked

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

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

* [U-Boot] [PATCH 2/2] M28: Pull out CONFIG_APBH_DMA so it's always enabled
  2012-04-09  3:09 ` [U-Boot] [PATCH 2/2] M28: Pull out CONFIG_APBH_DMA so it's always enabled Marek Vasut
@ 2012-04-11 14:15   ` Stefano Babic
  0 siblings, 0 replies; 9+ messages in thread
From: Stefano Babic @ 2012-04-11 14:15 UTC (permalink / raw)
  To: u-boot

On 09/04/2012 05:09, Marek Vasut wrote:
> The ABPH DMA is now used also by the SD card. Therefore it has to be enabled
> even if NAND is disabled.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Detlev Zundel <dzu@denx.de>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> ---


Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

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

end of thread, other threads:[~2012-04-11 14:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-09  3:09 [U-Boot] [PATCH 0/2] i.MX28: DMA fixups Marek Vasut
2012-04-09  3:09 ` [U-Boot] [PATCH 1/2] DMA: Split the APBH DMA init into block and channel init Marek Vasut
2012-04-09  3:28   ` [U-Boot] [PATCH 1/2 V2] " Marek Vasut
2012-04-09  3:34     ` [U-Boot] [PATCH 1/2 V3] " Marek Vasut
2012-04-09 14:10       ` Fabio Estevam
2012-04-11 14:14       ` Stefano Babic
2012-04-09  3:09 ` [U-Boot] [PATCH 2/2] M28: Pull out CONFIG_APBH_DMA so it's always enabled Marek Vasut
2012-04-11 14:15   ` Stefano Babic
2012-04-09  3:11 ` [U-Boot] [PATCH 0/2] i.MX28: DMA fixups Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.