21
21
#define DMA_MAX_TRANSFER_COUNT 1024
22
22
#define DMA_CH_PRIORITY_HIGH 1
23
23
#define DMA_CH_PRIORITY_LOW 0
24
- #define VALID_BURST_LENGTH 0
25
24
#define UDMA_ADDR_INC_NONE 0x03
26
25
27
26
LOG_MODULE_REGISTER (si91x_dma , CONFIG_DMA_LOG_LEVEL );
28
27
28
+ enum {
29
+ TRANSFER_MEM_TO_MEM ,
30
+ TRANSFER_TO_OR_FROM_PER ,
31
+ };
32
+
29
33
struct dma_siwx91x_config {
30
34
UDMA0_Type * reg ; /* UDMA register base address */
31
35
uint8_t channels ; /* UDMA channel count */
@@ -45,17 +49,17 @@ struct dma_siwx91x_data {
45
49
*/
46
50
};
47
51
48
- static int siwx91x_is_peripheral_request (uint32_t dir )
52
+ static int siwx91x_transfer_direction (uint32_t dir )
49
53
{
50
54
if (dir == MEMORY_TO_MEMORY ) {
51
- return 0 ;
55
+ return TRANSFER_MEM_TO_MEM ;
52
56
}
53
57
54
58
if (dir == MEMORY_TO_PERIPHERAL || dir == PERIPHERAL_TO_MEMORY ) {
55
- return 1 ;
59
+ return TRANSFER_TO_OR_FROM_PER ;
56
60
}
57
61
58
- return -1 ;
62
+ return - EINVAL ;
59
63
}
60
64
61
65
static int siwx91x_data_width (uint32_t data_width )
@@ -72,13 +76,13 @@ static int siwx91x_data_width(uint32_t data_width)
72
76
}
73
77
}
74
78
75
- static int siwx91x_burst_length (uint32_t blen )
79
+ static bool siwx91x_is_burst_length_valid (uint32_t blen )
76
80
{
77
81
switch (blen / 8 ) {
78
82
case 1 :
79
- return VALID_BURST_LENGTH ; /* 8-bit burst */
83
+ return true ; /* 8-bit burst */
80
84
default :
81
- return - EINVAL ;
85
+ return false ;
82
86
}
83
87
}
84
88
@@ -112,12 +116,12 @@ static int siwx91x_channel_config(const struct device *dev, RSI_UDMA_HANDLE_T ud
112
116
RSI_UDMA_CHA_CFG_T channel_config = {};
113
117
int status ;
114
118
115
- if (siwx91x_is_peripheral_request (config -> channel_direction ) < 0 ) {
119
+ if (siwx91x_transfer_direction (config -> channel_direction ) < 0 ) {
116
120
return - EINVAL ;
117
121
}
118
122
119
123
channel_config .channelPrioHigh = config -> channel_priority ;
120
- channel_config .periphReq = siwx91x_is_peripheral_request (config -> channel_direction );
124
+ channel_config .periphReq = siwx91x_transfer_direction (config -> channel_direction );
121
125
channel_config .dmaCh = channel ;
122
126
123
127
if (channel_config .periphReq ) {
@@ -140,8 +144,8 @@ static int siwx91x_channel_config(const struct device *dev, RSI_UDMA_HANDLE_T ud
140
144
siwx91x_data_width (config -> dest_data_size ) < 0 ) {
141
145
return - EINVAL ;
142
146
}
143
- if (siwx91x_burst_length (config -> source_burst_length ) < 0 ||
144
- siwx91x_burst_length (config -> dest_burst_length ) < 0 ) {
147
+ if (siwx91x_is_burst_length_valid (config -> source_burst_length ) == false ||
148
+ siwx91x_is_burst_length_valid (config -> dest_burst_length ) == false ) {
145
149
return - EINVAL ;
146
150
}
147
151
0 commit comments