From patchwork Mon Apr 9 03:09:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 151384 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 7027BB6FF6 for ; Mon, 9 Apr 2012 13:10:02 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EFE642807F; Mon, 9 Apr 2012 05:09:59 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U3SIYe1QCPGA; Mon, 9 Apr 2012 05:09:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 308C528085; Mon, 9 Apr 2012 05:09:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 153242807D for ; Mon, 9 Apr 2012 05:09:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1qju+a8ImjdW for ; Mon, 9 Apr 2012 05:09:20 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTPS id 8F6982807E for ; Mon, 9 Apr 2012 05:09:18 +0200 (CEST) Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3VQxLj1s4Cz3hhTn; Mon, 9 Apr 2012 05:09:17 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.8.164]) by mail.m-online.net (Postfix) with ESMTP id 3VQxLj2b5Tz4KK39; Mon, 9 Apr 2012 05:09:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from smtp-auth.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.8.164]) (amavisd-new, port 10024) with ESMTP id ceozeYXtZtxW; Mon, 9 Apr 2012 05:09:16 +0200 (CEST) Received: from mashiro.lan (unknown [195.140.253.167]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA; Mon, 9 Apr 2012 05:09:15 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Mon, 9 Apr 2012 05:09:05 +0200 Message-Id: <1333940946-15436-2-git-send-email-marex@denx.de> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1333940946-15436-1-git-send-email-marex@denx.de> References: <1333940946-15436-1-git-send-email-marex@denx.de> Cc: Marek Vasut , Fabio Estevam Subject: [U-Boot] [PATCH 1/2] DMA: Split the APBH DMA init into block and channel init X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 Cc: Stefano Babic Cc: Wolfgang Denk Cc: Detlev Zundel Cc: Fabio Estevam --- 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 #include #include +#include #include #include #include @@ -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: