Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dma: mpc512x: reorder mpc8308 specific instructions

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 <a13xp0p0v88@gmail.com>
Acked-by: Anatolij Gustschin <agust@denx.de>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>

authored by

Alexander Popov and committed by
Vinod Koul
78a4f036 2a5ecb79

+25 -17
+25 -17
drivers/dma/mpc512x_dma.c
··· 52 52 #define MPC_DMA_DESCRIPTORS 64 53 53 54 54 /* Macro definitions */ 55 - #define MPC_DMA_CHANNELS 64 56 55 #define MPC_DMA_TCD_OFFSET 0x1000 56 + 57 + /* 58 + * Maximum channel counts for individual hardware variants 59 + * and the maximum channel count over all supported controllers, 60 + * used for data structure size 61 + */ 62 + #define MPC8308_DMACHAN_MAX 16 63 + #define MPC512x_DMACHAN_MAX 64 64 + #define MPC_DMA_CHANNELS 64 57 65 58 66 /* Arbitration mode of group and channel */ 59 67 #define MPC_DMA_DMACR_EDCG (1 << 31) ··· 718 710 719 711 dma = &mdma->dma; 720 712 dma->dev = dev; 721 - if (!mdma->is_mpc8308) 722 - dma->chancnt = MPC_DMA_CHANNELS; 713 + if (mdma->is_mpc8308) 714 + dma->chancnt = MPC8308_DMACHAN_MAX; 723 715 else 724 - dma->chancnt = 16; /* MPC8308 DMA has only 16 channels */ 716 + dma->chancnt = MPC512x_DMACHAN_MAX; 725 717 dma->device_alloc_chan_resources = mpc_dma_alloc_chan_resources; 726 718 dma->device_free_chan_resources = mpc_dma_free_chan_resources; 727 719 dma->device_issue_pending = mpc_dma_issue_pending; ··· 755 747 * - Round-robin group arbitration, 756 748 * - Round-robin channel arbitration. 757 749 */ 758 - if (!mdma->is_mpc8308) { 750 + if (mdma->is_mpc8308) { 751 + /* MPC8308 has 16 channels and lacks some registers */ 752 + out_be32(&mdma->regs->dmacr, MPC_DMA_DMACR_ERCA); 753 + 754 + /* enable snooping */ 755 + out_be32(&mdma->regs->dmagpor, MPC_DMA_DMAGPOR_SNOOP_ENABLE); 756 + /* Disable error interrupts */ 757 + out_be32(&mdma->regs->dmaeeil, 0); 758 + 759 + /* Clear interrupts status */ 760 + out_be32(&mdma->regs->dmaintl, 0xFFFF); 761 + out_be32(&mdma->regs->dmaerrl, 0xFFFF); 762 + } else { 759 763 out_be32(&mdma->regs->dmacr, MPC_DMA_DMACR_EDCG | 760 764 MPC_DMA_DMACR_ERGA | MPC_DMA_DMACR_ERCA); 761 765 ··· 788 768 /* Route interrupts to IPIC */ 789 769 out_be32(&mdma->regs->dmaihsa, 0); 790 770 out_be32(&mdma->regs->dmailsa, 0); 791 - } else { 792 - /* MPC8308 has 16 channels and lacks some registers */ 793 - out_be32(&mdma->regs->dmacr, MPC_DMA_DMACR_ERCA); 794 - 795 - /* enable snooping */ 796 - out_be32(&mdma->regs->dmagpor, MPC_DMA_DMAGPOR_SNOOP_ENABLE); 797 - /* Disable error interrupts */ 798 - out_be32(&mdma->regs->dmaeeil, 0); 799 - 800 - /* Clear interrupts status */ 801 - out_be32(&mdma->regs->dmaintl, 0xFFFF); 802 - out_be32(&mdma->regs->dmaerrl, 0xFFFF); 803 771 } 804 772 805 773 /* Register DMA engine */