Skip to content

Commit 3071190

Browse files
smalaefabiobaltieri
authored andcommitted
drivers: dma: siwx917: Apply cosmetic changes
1. Updated multi-line comments 2. Grouping logical blocks by adding vertical spaces Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
1 parent b1ec724 commit 3071190

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

drivers/dma/dma_silabs_siwx91x.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define DMA_CH_PRIORITY_HIGH 1
2323
#define DMA_CH_PRIORITY_LOW 0
2424
#define VALID_BURST_LENGTH 0
25-
#define UDMA_ADDR_INC_NONE 0X03
25+
#define UDMA_ADDR_INC_NONE 0x03
2626

2727
LOG_MODULE_REGISTER(si91x_dma, CONFIG_DMA_LOG_LEVEL);
2828

@@ -40,18 +40,21 @@ struct dma_siwx91x_data {
4040
UDMA_Channel_Info *chan_info;
4141
dma_callback_t dma_callback; /* User callback */
4242
void *cb_data; /* User callback data */
43-
RSI_UDMA_DATACONTEXT_T dma_rom_buff; /* Buffer to store UDMA handle */
44-
/* related information */
43+
RSI_UDMA_DATACONTEXT_T dma_rom_buff; /* Buffer to store UDMA handle
44+
* related information
45+
*/
4546
};
4647

4748
static inline int siwx91x_dma_is_peripheral_request(uint32_t dir)
4849
{
4950
if (dir == MEMORY_TO_MEMORY) {
5051
return 0;
5152
}
53+
5254
if (dir == MEMORY_TO_PERIPHERAL || dir == PERIPHERAL_TO_MEMORY) {
5355
return 1;
5456
}
57+
5558
return -1;
5659
}
5760

@@ -108,19 +111,22 @@ static int dma_channel_config(const struct device *dev, RSI_UDMA_HANDLE_T udma_h
108111
RSI_UDMA_CHA_CFG_T channel_config = {};
109112
int status;
110113

111-
channel_config.channelPrioHigh = config->channel_priority;
112114
if (siwx91x_dma_is_peripheral_request(config->channel_direction) < 0) {
113115
return -EINVAL;
114116
}
117+
118+
channel_config.channelPrioHigh = config->channel_priority;
115119
channel_config.periphReq = siwx91x_dma_is_peripheral_request(config->channel_direction);
116120
channel_config.dmaCh = channel;
121+
117122
if (channel_config.periphReq) {
118123
/* Arbitration power for peripheral<->memory transfers */
119124
channel_control.rPower = ARBSIZE_1;
120125
} else {
121126
/* Arbitration power for mem-mem transfers */
122127
channel_control.rPower = ARBSIZE_1024;
123128
}
129+
124130
/* Obtain the number of transfers */
125131
config->head_block->block_size /= config->source_data_size;
126132
if (config->head_block->block_size >= DMA_MAX_TRANSFER_COUNT) {
@@ -129,6 +135,7 @@ static int dma_channel_config(const struct device *dev, RSI_UDMA_HANDLE_T udma_h
129135
} else {
130136
channel_control.totalNumOfDMATrans = config->head_block->block_size;
131137
}
138+
132139
if (siwx91x_dma_data_width(config->source_data_size) < 0 ||
133140
siwx91x_dma_data_width(config->dest_data_size) < 0) {
134141
return -EINVAL;
@@ -137,22 +144,26 @@ static int dma_channel_config(const struct device *dev, RSI_UDMA_HANDLE_T udma_h
137144
siwx91x_dma_burst_length(config->dest_burst_length) < 0) {
138145
return -EINVAL;
139146
}
147+
140148
channel_control.srcSize = siwx91x_dma_data_width(config->source_data_size);
141149
channel_control.dstSize = siwx91x_dma_data_width(config->dest_data_size);
142150
if (siwx91x_dma_addr_adjustment(config->head_block->source_addr_adj) < 0 ||
143151
siwx91x_dma_addr_adjustment(config->head_block->dest_addr_adj) < 0) {
144152
return -EINVAL;
145153
}
154+
146155
if (siwx91x_dma_addr_adjustment(config->head_block->source_addr_adj) == 0) {
147156
channel_control.srcInc = channel_control.srcSize;
148157
} else {
149158
channel_control.srcInc = UDMA_SRC_INC_NONE;
150159
}
160+
151161
if (siwx91x_dma_addr_adjustment(config->head_block->dest_addr_adj) == 0) {
152162
channel_control.dstInc = channel_control.dstSize;
153163
} else {
154164
channel_control.dstInc = UDMA_DST_INC_NONE;
155165
}
166+
156167
status = UDMAx_ChannelConfigure(&udma_resources, (uint8_t)channel,
157168
config->head_block->source_address,
158169
config->head_block->dest_address,
@@ -161,6 +172,7 @@ static int dma_channel_config(const struct device *dev, RSI_UDMA_HANDLE_T udma_h
161172
if (status) {
162173
return -EIO;
163174
}
175+
164176
return 0;
165177
}
166178

@@ -193,8 +205,10 @@ static int dma_siwx91x_configure(const struct device *dev, uint32_t channel,
193205
if (status) {
194206
return status;
195207
}
208+
196209
data->dma_callback = config->dma_callback;
197210
data->cb_data = config->user_data;
211+
198212
return 0;
199213
}
200214

@@ -231,19 +245,22 @@ static int dma_siwx91x_reload(const struct device *dev, uint32_t channel, uint32
231245
} else {
232246
data->chan_info[channel].Cnt = size;
233247
}
248+
234249
/* Program the DMA descriptors with new transfer data information. */
235250
if (udma_table[channel].vsUDMAChaConfigData1.srcInc != UDMA_SRC_INC_NONE) {
236251
length = data->chan_info[channel].Cnt
237252
<< udma_table[channel].vsUDMAChaConfigData1.srcInc;
238253
desc_src_addr = src + (length - 1);
239254
udma_table[channel].pSrcEndAddr = (void *)desc_src_addr;
240255
}
256+
241257
if (udma_table[channel].vsUDMAChaConfigData1.dstInc != UDMA_SRC_INC_NONE) {
242258
length = data->chan_info[channel].Cnt
243259
<< udma_table[channel].vsUDMAChaConfigData1.dstInc;
244260
desc_dst_addr = dst + (length - 1);
245261
udma_table[channel].pDstEndAddr = (void *)desc_dst_addr;
246262
}
263+
247264
udma_table[channel].vsUDMAChaConfigData1.totalNumOfDMATrans = data->chan_info[channel].Cnt;
248265
udma_table[channel].vsUDMAChaConfigData1.transferType = UDMA_MODE_BASIC;
249266

@@ -262,6 +279,7 @@ static int dma_siwx91x_start(const struct device *dev, uint32_t channel)
262279
if (channel >= cfg->channels) {
263280
return -EINVAL;
264281
}
282+
265283
if (RSI_UDMA_ChannelEnable(udma_handle, channel) != 0) {
266284
return -EINVAL;
267285
}
@@ -272,6 +290,7 @@ static int dma_siwx91x_start(const struct device *dev, uint32_t channel)
272290
/* Apply software trigger to start transfer */
273291
sys_set_bit((mem_addr_t)&cfg->reg->CHNL_SW_REQUEST, channel);
274292
}
293+
275294
return 0;
276295
}
277296

@@ -286,9 +305,11 @@ static int dma_siwx91x_stop(const struct device *dev, uint32_t channel)
286305
if (channel >= cfg->channels) {
287306
return -EINVAL;
288307
}
308+
289309
if (RSI_UDMA_ChannelDisable(udma_handle, channel) != 0) {
290310
return -EIO;
291311
}
312+
292313
return 0;
293314
}
294315

@@ -303,6 +324,7 @@ static int dma_siwx91x_get_status(const struct device *dev, uint32_t channel,
303324
if (channel >= cfg->channels) {
304325
return -EINVAL;
305326
}
327+
306328
/* Read the channel status register */
307329
stat->busy = sys_test_bit((mem_addr_t)&cfg->reg->CHANNEL_STATUS_REG, channel);
308330

@@ -314,6 +336,7 @@ static int dma_siwx91x_get_status(const struct device *dev, uint32_t channel,
314336
} else {
315337
stat->dir = MEMORY_TO_MEMORY;
316338
}
339+
317340
return 0;
318341
}
319342

@@ -347,6 +370,7 @@ static int dma_siwx91x_init(const struct device *dev)
347370
if (UDMAx_DMAEnable(&udma_resources, udma_handle) != 0) {
348371
return -EBUSY;
349372
}
373+
350374
return 0;
351375
}
352376

@@ -361,16 +385,19 @@ static void dma_siwx91x_isr(const struct device *dev)
361385
};
362386
uint8_t channel;
363387

364-
/* Disable the IRQ to prevent the ISR from being triggered by */
365-
/* interrupts from other DMA channels */
388+
/* Disable the IRQ to prevent the ISR from being triggered by
389+
* interrupts from other DMA channels.
390+
*/
366391
irq_disable(cfg->irq_number);
392+
367393
channel = find_lsb_set(cfg->reg->UDMA_DONE_STATUS_REG);
368394
/* Identify the interrupt channel */
369395
if (!channel || channel > cfg->channels) {
370396
goto out;
371397
}
372398
/* find_lsb_set() returns 1 indexed value */
373399
channel -= 1;
400+
374401
if (data->chan_info[channel].Cnt == data->chan_info[channel].Size) {
375402
if (data->dma_callback) {
376403
/* Transfer complete, call user callback */
@@ -388,6 +415,7 @@ static void dma_siwx91x_isr(const struct device *dev)
388415
sys_set_bit((mem_addr_t)&cfg->reg->CHNL_SW_REQUEST, channel);
389416
}
390417
}
418+
391419
out:
392420
/* Enable the IRQ to restore interrupt functionality for other DMA channels */
393421
irq_enable(cfg->irq_number);

0 commit comments

Comments
 (0)