Skip to content

Commit 6faf1cc

Browse files
MesihKvinodkoul
authored andcommitted
dma-engine: sun4i: Add support for Allwinner suniv F1C100s
DMA of Allwinner suniv F1C100s is similar to sun4i. It has 4 NDMA, 4 DDMA channels and endpoints are different. Also F1C100s has reset bit for DMA in CCU. Add support for it. Signed-off-by: Mesih Kilinc <[email protected]> [ csokas.bence: Rebased on current master ] Signed-off-by: Csókás Bence <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent fdcdcc5 commit 6faf1cc

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

drivers/dma/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ config DMA_SA11X0
162162

163163
config DMA_SUN4I
164164
tristate "Allwinner A10 DMA SoCs support"
165-
depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
166-
default (MACH_SUN4I || MACH_SUN5I || MACH_SUN7I)
165+
depends on MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNIV
166+
default (MACH_SUN4I || MACH_SUN5I || MACH_SUN7I || MACH_SUNIV)
167167
select DMA_ENGINE
168168
select DMA_VIRTUAL_CHANNELS
169169
help

drivers/dma/sun4i-dma.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,21 @@
3333
#define SUN4I_DMA_CFG_SRC_ADDR_MODE(mode) ((mode) << 5)
3434
#define SUN4I_DMA_CFG_SRC_DRQ_TYPE(type) (type)
3535

36+
#define SUNIV_DMA_CFG_DST_DATA_WIDTH(width) ((width) << 24)
37+
#define SUNIV_DMA_CFG_SRC_DATA_WIDTH(width) ((width) << 8)
38+
3639
#define SUN4I_MAX_BURST 8
40+
#define SUNIV_MAX_BURST 4
3741

3842
/** Normal DMA register values **/
3943

4044
/* Normal DMA source/destination data request type values */
4145
#define SUN4I_NDMA_DRQ_TYPE_SDRAM 0x16
4246
#define SUN4I_NDMA_DRQ_TYPE_LIMIT (0x1F + 1)
4347

48+
#define SUNIV_NDMA_DRQ_TYPE_SDRAM 0x11
49+
#define SUNIV_NDMA_DRQ_TYPE_LIMIT (0x17 + 1)
50+
4451
/** Normal DMA register layout **/
4552

4653
/* Dedicated DMA source/destination address mode values */
@@ -54,6 +61,9 @@
5461
#define SUN4I_NDMA_CFG_BYTE_COUNT_MODE_REMAIN BIT(15)
5562
#define SUN4I_NDMA_CFG_SRC_NON_SECURE BIT(6)
5663

64+
#define SUNIV_NDMA_CFG_CONT_MODE BIT(29)
65+
#define SUNIV_NDMA_CFG_WAIT_STATE(n) ((n) << 26)
66+
5767
/** Dedicated DMA register values **/
5868

5969
/* Dedicated DMA source/destination address mode values */
@@ -66,6 +76,9 @@
6676
#define SUN4I_DDMA_DRQ_TYPE_SDRAM 0x1
6777
#define SUN4I_DDMA_DRQ_TYPE_LIMIT (0x1F + 1)
6878

79+
#define SUNIV_DDMA_DRQ_TYPE_SDRAM 0x1
80+
#define SUNIV_DDMA_DRQ_TYPE_LIMIT (0x9 + 1)
81+
6982
/** Dedicated DMA register layout **/
7083

7184
/* Dedicated DMA configuration register layout */
@@ -119,6 +132,11 @@
119132
#define SUN4I_DMA_NR_MAX_VCHANS \
120133
(SUN4I_NDMA_NR_MAX_VCHANS + SUN4I_DDMA_NR_MAX_VCHANS)
121134

135+
#define SUNIV_NDMA_NR_MAX_CHANNELS 4
136+
#define SUNIV_DDMA_NR_MAX_CHANNELS 4
137+
#define SUNIV_NDMA_NR_MAX_VCHANS (24 * 2 - 1)
138+
#define SUNIV_DDMA_NR_MAX_VCHANS 10
139+
122140
/* This set of SUN4I_DDMA timing parameters were found experimentally while
123141
* working with the SPI driver and seem to make it behave correctly */
124142
#define SUN4I_DDMA_MAGIC_SPI_PARAMETERS \
@@ -243,6 +261,16 @@ static void set_src_data_width_a10(u32 *p_cfg, s8 data_width)
243261
*p_cfg |= SUN4I_DMA_CFG_SRC_DATA_WIDTH(data_width);
244262
}
245263

264+
static void set_dst_data_width_f1c100s(u32 *p_cfg, s8 data_width)
265+
{
266+
*p_cfg |= SUNIV_DMA_CFG_DST_DATA_WIDTH(data_width);
267+
}
268+
269+
static void set_src_data_width_f1c100s(u32 *p_cfg, s8 data_width)
270+
{
271+
*p_cfg |= SUNIV_DMA_CFG_SRC_DATA_WIDTH(data_width);
272+
}
273+
246274
static int convert_burst_a10(u32 maxburst)
247275
{
248276
if (maxburst > 8)
@@ -252,6 +280,15 @@ static int convert_burst_a10(u32 maxburst)
252280
return (maxburst >> 2);
253281
}
254282

283+
static int convert_burst_f1c100s(u32 maxburst)
284+
{
285+
if (maxburst > 4)
286+
return -EINVAL;
287+
288+
/* 1 -> 0, 4 -> 1 */
289+
return (maxburst >> 2);
290+
}
291+
255292
static int convert_buswidth(enum dma_slave_buswidth addr_width)
256293
{
257294
if (addr_width > DMA_SLAVE_BUSWIDTH_4_BYTES)
@@ -1368,8 +1405,31 @@ static struct sun4i_dma_config sun4i_a10_dma_cfg = {
13681405
.has_reset = false,
13691406
};
13701407

1408+
static struct sun4i_dma_config suniv_f1c100s_dma_cfg = {
1409+
.ndma_nr_max_channels = SUNIV_NDMA_NR_MAX_CHANNELS,
1410+
.ndma_nr_max_vchans = SUNIV_NDMA_NR_MAX_VCHANS,
1411+
1412+
.ddma_nr_max_channels = SUNIV_DDMA_NR_MAX_CHANNELS,
1413+
.ddma_nr_max_vchans = SUNIV_DDMA_NR_MAX_VCHANS,
1414+
1415+
.dma_nr_max_channels = SUNIV_NDMA_NR_MAX_CHANNELS +
1416+
SUNIV_DDMA_NR_MAX_CHANNELS,
1417+
1418+
.set_dst_data_width = set_dst_data_width_f1c100s,
1419+
.set_src_data_width = set_src_data_width_f1c100s,
1420+
.convert_burst = convert_burst_f1c100s,
1421+
1422+
.ndma_drq_sdram = SUNIV_NDMA_DRQ_TYPE_SDRAM,
1423+
.ddma_drq_sdram = SUNIV_DDMA_DRQ_TYPE_SDRAM,
1424+
1425+
.max_burst = SUNIV_MAX_BURST,
1426+
.has_reset = true,
1427+
};
1428+
13711429
static const struct of_device_id sun4i_dma_match[] = {
13721430
{ .compatible = "allwinner,sun4i-a10-dma", .data = &sun4i_a10_dma_cfg },
1431+
{ .compatible = "allwinner,suniv-f1c100s-dma",
1432+
.data = &suniv_f1c100s_dma_cfg },
13731433
{ /* sentinel */ },
13741434
};
13751435
MODULE_DEVICE_TABLE(of, sun4i_dma_match);

0 commit comments

Comments
 (0)