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 */
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 */
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 */
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+
246274static 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+
255292static 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+
13711429static 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};
13751435MODULE_DEVICE_TABLE (of , sun4i_dma_match );
0 commit comments