From patchwork Fri Nov 1 07:19:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Popov X-Patchwork-Id: 287710 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id AFDF82C04BE for ; Fri, 1 Nov 2013 18:17:21 +1100 (EST) Received: from mail-lb0-x232.google.com (mail-lb0-x232.google.com [IPv6:2a00:1450:4010:c04::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 0E9292C03FC for ; Fri, 1 Nov 2013 18:16:23 +1100 (EST) Received: by mail-lb0-f178.google.com with SMTP id l4so978891lbv.9 for ; Fri, 01 Nov 2013 00:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=KT4VkjFQRhisx/TvBxwjrg/TIZ60rXWcqU+V1Bq/lS8=; b=jUzienB10DM5inRYKL4jQHqm2mEQ1I/PSebkdrpHUIfuypZyfh/DXDpuyni6az8fiO ZHcfVvMIA5Uc6J8pBmGqBrlPKAGa9tyw8riOWE4FKPKTcu6BGOEZKKgv3Hsi0XdadKjU K1muEfAIVoEjjDN4BFaiQc8Qj9Wlyzjq5Qunp8NNCdtZFlzhZ0E3HisLLm/mR7wQoao4 F6XgB/7BppLBl/q/rXiE1wbxlh+J6rlIfEQt0EQQwZoEz6lA57rGlq0vPqU14GbzUB9D UpMkvysrAUjKE/ZJOnyt9P/arhyqsHqav8cze9jBAnv6TmMk5YzX4xUarMbDxQvABp5f zH7g== X-Received: by 10.112.159.166 with SMTP id xd6mr952728lbb.22.1383290179574; Fri, 01 Nov 2013 00:16:19 -0700 (PDT) Received: from a13xCCC.localdomain (mail.tecon.ru. [89.175.104.62]) by mx.google.com with ESMTPSA id qj3sm5410018lbb.6.2013.11.01.00.16.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 01 Nov 2013 00:16:18 -0700 (PDT) From: Alexander Popov To: Gerhard Sittig , Dan Williams , Vinod Koul , Lars-Peter Clausen , Arnd Bergmann , Anatolij Gustschin , Alexander Popov , linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org Subject: [PATCH RFC v5 1/5] dma: mpc512x: reorder mpc8308 specific instructions Date: Fri, 1 Nov 2013 11:19:30 +0400 Message-Id: <1383290374-17484-2-git-send-email-a13xp0p0v88@gmail.com> X-Mailer: git-send-email 1.7.11.3 In-Reply-To: <1383290374-17484-1-git-send-email-a13xp0p0v88@gmail.com> References: <1383290374-17484-1-git-send-email-a13xp0p0v88@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16rc2 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Concentrate the specific code for MPC8308 in the 'if' branch and handle MPC512x in the 'else' branch. This modification only reorders instructions but doesn't change behaviour. Signed-off-by: Alexander Popov Acked-by: Anatolij Gustschin --- drivers/dma/mpc512x_dma.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/drivers/dma/mpc512x_dma.c b/drivers/dma/mpc512x_dma.c index 2fe4353..f41639f 100644 --- a/drivers/dma/mpc512x_dma.c +++ b/drivers/dma/mpc512x_dma.c @@ -50,9 +50,17 @@ #define MPC_DMA_DESCRIPTORS 64 /* Macro definitions */ -#define MPC_DMA_CHANNELS 64 #define MPC_DMA_TCD_OFFSET 0x1000 +/* + * Maximum channel counts for individual hardware variants + * and the maximum channel count over all supported controllers, + * used for data structure size + */ +#define MPC8308_DMACHAN_MAX 16 +#define MPC512x_DMACHAN_MAX 64 +#define MPC_DMA_CHANNELS 64 + /* Arbitration mode of group and channel */ #define MPC_DMA_DMACR_EDCG (1 << 31) #define MPC_DMA_DMACR_ERGA (1 << 3) @@ -708,10 +716,10 @@ static int mpc_dma_probe(struct platform_device *op) dma = &mdma->dma; dma->dev = dev; - if (!mdma->is_mpc8308) - dma->chancnt = MPC_DMA_CHANNELS; + if (mdma->is_mpc8308) + dma->chancnt = MPC8308_DMACHAN_MAX; else - dma->chancnt = 16; /* MPC8308 DMA has only 16 channels */ + dma->chancnt = MPC512x_DMACHAN_MAX; dma->device_alloc_chan_resources = mpc_dma_alloc_chan_resources; dma->device_free_chan_resources = mpc_dma_free_chan_resources; dma->device_issue_pending = mpc_dma_issue_pending; @@ -745,7 +753,19 @@ static int mpc_dma_probe(struct platform_device *op) * - Round-robin group arbitration, * - Round-robin channel arbitration. */ - if (!mdma->is_mpc8308) { + if (mdma->is_mpc8308) { + /* MPC8308 has 16 channels and lacks some registers */ + out_be32(&mdma->regs->dmacr, MPC_DMA_DMACR_ERCA); + + /* enable snooping */ + out_be32(&mdma->regs->dmagpor, MPC_DMA_DMAGPOR_SNOOP_ENABLE); + /* Disable error interrupts */ + out_be32(&mdma->regs->dmaeeil, 0); + + /* Clear interrupts status */ + out_be32(&mdma->regs->dmaintl, 0xFFFF); + out_be32(&mdma->regs->dmaerrl, 0xFFFF); + } else { out_be32(&mdma->regs->dmacr, MPC_DMA_DMACR_EDCG | MPC_DMA_DMACR_ERGA | MPC_DMA_DMACR_ERCA); @@ -766,18 +786,6 @@ static int mpc_dma_probe(struct platform_device *op) /* Route interrupts to IPIC */ out_be32(&mdma->regs->dmaihsa, 0); out_be32(&mdma->regs->dmailsa, 0); - } else { - /* MPC8308 has 16 channels and lacks some registers */ - out_be32(&mdma->regs->dmacr, MPC_DMA_DMACR_ERCA); - - /* enable snooping */ - out_be32(&mdma->regs->dmagpor, MPC_DMA_DMAGPOR_SNOOP_ENABLE); - /* Disable error interrupts */ - out_be32(&mdma->regs->dmaeeil, 0); - - /* Clear interrupts status */ - out_be32(&mdma->regs->dmaintl, 0xFFFF); - out_be32(&mdma->regs->dmaerrl, 0xFFFF); } /* Register DMA engine */