18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * arch/arm/mach-ep93xx/dma.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Platform support code for the EP93xx dmaengine driver. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright (C) 2011 Mika Westerberg 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This work is based on the original dma-m2p implementation with 108c2ecf20Sopenharmony_ci * following copyrights: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org> 138c2ecf20Sopenharmony_ci * Copyright (C) 2006 Applied Data Systems 148c2ecf20Sopenharmony_ci * Copyright (C) 2009 Ryan Mallon <rmallon@gmail.com> 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <linux/dmaengine.h> 188c2ecf20Sopenharmony_ci#include <linux/dma-mapping.h> 198c2ecf20Sopenharmony_ci#include <linux/init.h> 208c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 218c2ecf20Sopenharmony_ci#include <linux/kernel.h> 228c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#include <linux/platform_data/dma-ep93xx.h> 258c2ecf20Sopenharmony_ci#include "hardware.h" 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#include "soc.h" 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define DMA_CHANNEL(_name, _base, _irq) \ 308c2ecf20Sopenharmony_ci { .name = (_name), .base = (_base), .irq = (_irq) } 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* 338c2ecf20Sopenharmony_ci * DMA M2P channels. 348c2ecf20Sopenharmony_ci * 358c2ecf20Sopenharmony_ci * On the EP93xx chip the following peripherals my be allocated to the 10 368c2ecf20Sopenharmony_ci * Memory to Internal Peripheral (M2P) channels (5 transmit + 5 receive). 378c2ecf20Sopenharmony_ci * 388c2ecf20Sopenharmony_ci * I2S contains 3 Tx and 3 Rx DMA Channels 398c2ecf20Sopenharmony_ci * AAC contains 3 Tx and 3 Rx DMA Channels 408c2ecf20Sopenharmony_ci * UART1 contains 1 Tx and 1 Rx DMA Channels 418c2ecf20Sopenharmony_ci * UART2 contains 1 Tx and 1 Rx DMA Channels 428c2ecf20Sopenharmony_ci * UART3 contains 1 Tx and 1 Rx DMA Channels 438c2ecf20Sopenharmony_ci * IrDA contains 1 Tx and 1 Rx DMA Channels 448c2ecf20Sopenharmony_ci * 458c2ecf20Sopenharmony_ci * Registers are mapped statically in ep93xx_map_io(). 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_cistatic struct ep93xx_dma_chan_data ep93xx_dma_m2p_channels[] = { 488c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p0", EP93XX_DMA_BASE + 0x0000, IRQ_EP93XX_DMAM2P0), 498c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p1", EP93XX_DMA_BASE + 0x0040, IRQ_EP93XX_DMAM2P1), 508c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p2", EP93XX_DMA_BASE + 0x0080, IRQ_EP93XX_DMAM2P2), 518c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p3", EP93XX_DMA_BASE + 0x00c0, IRQ_EP93XX_DMAM2P3), 528c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p4", EP93XX_DMA_BASE + 0x0240, IRQ_EP93XX_DMAM2P4), 538c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p5", EP93XX_DMA_BASE + 0x0200, IRQ_EP93XX_DMAM2P5), 548c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p6", EP93XX_DMA_BASE + 0x02c0, IRQ_EP93XX_DMAM2P6), 558c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p7", EP93XX_DMA_BASE + 0x0280, IRQ_EP93XX_DMAM2P7), 568c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p8", EP93XX_DMA_BASE + 0x0340, IRQ_EP93XX_DMAM2P8), 578c2ecf20Sopenharmony_ci DMA_CHANNEL("m2p9", EP93XX_DMA_BASE + 0x0300, IRQ_EP93XX_DMAM2P9), 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistatic struct ep93xx_dma_platform_data ep93xx_dma_m2p_data = { 618c2ecf20Sopenharmony_ci .channels = ep93xx_dma_m2p_channels, 628c2ecf20Sopenharmony_ci .num_channels = ARRAY_SIZE(ep93xx_dma_m2p_channels), 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic u64 ep93xx_dma_m2p_mask = DMA_BIT_MASK(32); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistatic struct platform_device ep93xx_dma_m2p_device = { 688c2ecf20Sopenharmony_ci .name = "ep93xx-dma-m2p", 698c2ecf20Sopenharmony_ci .id = -1, 708c2ecf20Sopenharmony_ci .dev = { 718c2ecf20Sopenharmony_ci .platform_data = &ep93xx_dma_m2p_data, 728c2ecf20Sopenharmony_ci .dma_mask = &ep93xx_dma_m2p_mask, 738c2ecf20Sopenharmony_ci .coherent_dma_mask = DMA_BIT_MASK(32), 748c2ecf20Sopenharmony_ci }, 758c2ecf20Sopenharmony_ci}; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* 788c2ecf20Sopenharmony_ci * DMA M2M channels. 798c2ecf20Sopenharmony_ci * 808c2ecf20Sopenharmony_ci * There are 2 M2M channels which support memcpy/memset and in addition simple 818c2ecf20Sopenharmony_ci * hardware requests from/to SSP and IDE. We do not implement an external 828c2ecf20Sopenharmony_ci * hardware requests. 838c2ecf20Sopenharmony_ci * 848c2ecf20Sopenharmony_ci * Registers are mapped statically in ep93xx_map_io(). 858c2ecf20Sopenharmony_ci */ 868c2ecf20Sopenharmony_cistatic struct ep93xx_dma_chan_data ep93xx_dma_m2m_channels[] = { 878c2ecf20Sopenharmony_ci DMA_CHANNEL("m2m0", EP93XX_DMA_BASE + 0x0100, IRQ_EP93XX_DMAM2M0), 888c2ecf20Sopenharmony_ci DMA_CHANNEL("m2m1", EP93XX_DMA_BASE + 0x0140, IRQ_EP93XX_DMAM2M1), 898c2ecf20Sopenharmony_ci}; 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistatic struct ep93xx_dma_platform_data ep93xx_dma_m2m_data = { 928c2ecf20Sopenharmony_ci .channels = ep93xx_dma_m2m_channels, 938c2ecf20Sopenharmony_ci .num_channels = ARRAY_SIZE(ep93xx_dma_m2m_channels), 948c2ecf20Sopenharmony_ci}; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cistatic u64 ep93xx_dma_m2m_mask = DMA_BIT_MASK(32); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistatic struct platform_device ep93xx_dma_m2m_device = { 998c2ecf20Sopenharmony_ci .name = "ep93xx-dma-m2m", 1008c2ecf20Sopenharmony_ci .id = -1, 1018c2ecf20Sopenharmony_ci .dev = { 1028c2ecf20Sopenharmony_ci .platform_data = &ep93xx_dma_m2m_data, 1038c2ecf20Sopenharmony_ci .dma_mask = &ep93xx_dma_m2m_mask, 1048c2ecf20Sopenharmony_ci .coherent_dma_mask = DMA_BIT_MASK(32), 1058c2ecf20Sopenharmony_ci }, 1068c2ecf20Sopenharmony_ci}; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_cistatic int __init ep93xx_dma_init(void) 1098c2ecf20Sopenharmony_ci{ 1108c2ecf20Sopenharmony_ci platform_device_register(&ep93xx_dma_m2p_device); 1118c2ecf20Sopenharmony_ci platform_device_register(&ep93xx_dma_m2m_device); 1128c2ecf20Sopenharmony_ci return 0; 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ciarch_initcall(ep93xx_dma_init); 115