120
120
#define BIT_FIELD (val , width , shift , newshift ) \
121
121
((((val) >> (shift)) & ((BIT(width)) - 1)) << (newshift))
122
122
123
+ /* Frame count value is fixed as 1 */
124
+ #define FCNT_VAL 0x1
125
+
123
126
/**
124
- * struct owl_dma_lli_hw - Hardware link list for dma transfer
125
- * @next_lli: physical address of the next link list
126
- * @saddr: source physical address
127
- * @daddr: destination physical address
128
- * @flen: frame length
129
- * @fcnt : frame count
130
- * @src_stride : source stride
131
- * @dst_stride : destination stride
132
- * @ctrla : dma_mode and linklist ctrl config
133
- * @ctrlb : interrupt config
134
- * @const_num : data for constant fill
127
+ * owl_dmadesc_offsets - Describe DMA descriptor, hardware link
128
+ * list for dma transfer
129
+ * @OWL_DMADESC_NEXT_LLI: physical address of the next link list
130
+ * @OWL_DMADESC_SADDR: source physical address
131
+ * @OWL_DMADESC_DADDR: destination physical address
132
+ * @OWL_DMADESC_FLEN : frame length
133
+ * @OWL_DMADESC_SRC_STRIDE : source stride
134
+ * @OWL_DMADESC_DST_STRIDE : destination stride
135
+ * @OWL_DMADESC_CTRLA : dma_mode and linklist ctrl config
136
+ * @OWL_DMADESC_CTRLB : interrupt config
137
+ * @OWL_DMADESC_CONST_NUM : data for constant fill
135
138
*/
136
- struct owl_dma_lli_hw {
137
- u32 next_lli ;
138
- u32 saddr ;
139
- u32 daddr ;
140
- u32 flen : 20 ;
141
- u32 fcnt : 12 ;
142
- u32 src_stride ;
143
- u32 dst_stride ;
144
- u32 ctrla ;
145
- u32 ctrlb ;
146
- u32 const_num ;
139
+ enum owl_dmadesc_offsets {
140
+ OWL_DMADESC_NEXT_LLI = 0 ,
141
+ OWL_DMADESC_SADDR ,
142
+ OWL_DMADESC_DADDR ,
143
+ OWL_DMADESC_FLEN ,
144
+ OWL_DMADESC_SRC_STRIDE ,
145
+ OWL_DMADESC_DST_STRIDE ,
146
+ OWL_DMADESC_CTRLA ,
147
+ OWL_DMADESC_CTRLB ,
148
+ OWL_DMADESC_CONST_NUM ,
149
+ OWL_DMADESC_SIZE
147
150
};
148
151
149
152
/**
@@ -153,7 +156,7 @@ struct owl_dma_lli_hw {
153
156
* @node: node for txd's lli_list
154
157
*/
155
158
struct owl_dma_lli {
156
- struct owl_dma_lli_hw hw ;
159
+ u32 hw [ OWL_DMADESC_SIZE ] ;
157
160
dma_addr_t phys ;
158
161
struct list_head node ;
159
162
};
@@ -318,6 +321,11 @@ static inline u32 llc_hw_ctrlb(u32 int_ctl)
318
321
return ctl ;
319
322
}
320
323
324
+ static u32 llc_hw_flen (struct owl_dma_lli * lli )
325
+ {
326
+ return lli -> hw [OWL_DMADESC_FLEN ] & GENMASK (19 , 0 );
327
+ }
328
+
321
329
static void owl_dma_free_lli (struct owl_dma * od ,
322
330
struct owl_dma_lli * lli )
323
331
{
@@ -349,8 +357,9 @@ static struct owl_dma_lli *owl_dma_add_lli(struct owl_dma_txd *txd,
349
357
list_add_tail (& next -> node , & txd -> lli_list );
350
358
351
359
if (prev ) {
352
- prev -> hw .next_lli = next -> phys ;
353
- prev -> hw .ctrla |= llc_hw_ctrla (OWL_DMA_MODE_LME , 0 );
360
+ prev -> hw [OWL_DMADESC_NEXT_LLI ] = next -> phys ;
361
+ prev -> hw [OWL_DMADESC_CTRLA ] |=
362
+ llc_hw_ctrla (OWL_DMA_MODE_LME , 0 );
354
363
}
355
364
356
365
return next ;
@@ -363,8 +372,7 @@ static inline int owl_dma_cfg_lli(struct owl_dma_vchan *vchan,
363
372
struct dma_slave_config * sconfig ,
364
373
bool is_cyclic )
365
374
{
366
- struct owl_dma_lli_hw * hw = & lli -> hw ;
367
- u32 mode ;
375
+ u32 mode , ctrlb ;
368
376
369
377
mode = OWL_DMA_MODE_PW (0 );
370
378
@@ -405,22 +413,28 @@ static inline int owl_dma_cfg_lli(struct owl_dma_vchan *vchan,
405
413
return - EINVAL ;
406
414
}
407
415
408
- hw -> next_lli = 0 ; /* One link list by default */
409
- hw -> saddr = src ;
410
- hw -> daddr = dst ;
411
-
412
- hw -> fcnt = 1 ; /* Frame count fixed as 1 */
413
- hw -> flen = len ; /* Max frame length is 1MB */
414
- hw -> src_stride = 0 ;
415
- hw -> dst_stride = 0 ;
416
- hw -> ctrla = llc_hw_ctrla (mode ,
417
- OWL_DMA_LLC_SAV_LOAD_NEXT |
418
- OWL_DMA_LLC_DAV_LOAD_NEXT );
416
+ lli -> hw [OWL_DMADESC_CTRLA ] = llc_hw_ctrla (mode ,
417
+ OWL_DMA_LLC_SAV_LOAD_NEXT |
418
+ OWL_DMA_LLC_DAV_LOAD_NEXT );
419
419
420
420
if (is_cyclic )
421
- hw -> ctrlb = llc_hw_ctrlb (OWL_DMA_INTCTL_BLOCK );
421
+ ctrlb = llc_hw_ctrlb (OWL_DMA_INTCTL_BLOCK );
422
422
else
423
- hw -> ctrlb = llc_hw_ctrlb (OWL_DMA_INTCTL_SUPER_BLOCK );
423
+ ctrlb = llc_hw_ctrlb (OWL_DMA_INTCTL_SUPER_BLOCK );
424
+
425
+ lli -> hw [OWL_DMADESC_NEXT_LLI ] = 0 ; /* One link list by default */
426
+ lli -> hw [OWL_DMADESC_SADDR ] = src ;
427
+ lli -> hw [OWL_DMADESC_DADDR ] = dst ;
428
+ lli -> hw [OWL_DMADESC_SRC_STRIDE ] = 0 ;
429
+ lli -> hw [OWL_DMADESC_DST_STRIDE ] = 0 ;
430
+ /*
431
+ * Word starts from offset 0xC is shared between frame length
432
+ * (max frame length is 1MB) and frame count, where first 20
433
+ * bits are for frame length and rest of 12 bits are for frame
434
+ * count.
435
+ */
436
+ lli -> hw [OWL_DMADESC_FLEN ] = len | FCNT_VAL << 20 ;
437
+ lli -> hw [OWL_DMADESC_CTRLB ] = ctrlb ;
424
438
425
439
return 0 ;
426
440
}
@@ -752,7 +766,7 @@ static u32 owl_dma_getbytes_chan(struct owl_dma_vchan *vchan)
752
766
/* Start from the next active node */
753
767
if (lli -> phys == next_lli_phy ) {
754
768
list_for_each_entry (lli , & txd -> lli_list , node )
755
- bytes += lli -> hw . flen ;
769
+ bytes += llc_hw_flen ( lli ) ;
756
770
break ;
757
771
}
758
772
}
@@ -783,7 +797,7 @@ static enum dma_status owl_dma_tx_status(struct dma_chan *chan,
783
797
if (vd ) {
784
798
txd = to_owl_txd (& vd -> tx );
785
799
list_for_each_entry (lli , & txd -> lli_list , node )
786
- bytes += lli -> hw . flen ;
800
+ bytes += llc_hw_flen ( lli ) ;
787
801
} else {
788
802
bytes = owl_dma_getbytes_chan (vchan );
789
803
}
0 commit comments