23
23
#define TX_BUSY 1
24
24
#define TX_BURST_LEVEL 16
25
25
26
- static bool mid_spi_dma_chan_filter (struct dma_chan * chan , void * param )
26
+ static bool dw_spi_dma_chan_filter (struct dma_chan * chan , void * param )
27
27
{
28
28
struct dw_dma_slave * s = param ;
29
29
@@ -34,7 +34,7 @@ static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param)
34
34
return true;
35
35
}
36
36
37
- static void mid_spi_maxburst_init (struct dw_spi * dws )
37
+ static void dw_spi_dma_maxburst_init (struct dw_spi * dws )
38
38
{
39
39
struct dma_slave_caps caps ;
40
40
u32 max_burst , def_burst ;
@@ -59,7 +59,7 @@ static void mid_spi_maxburst_init(struct dw_spi *dws)
59
59
dws -> txburst = min (max_burst , def_burst );
60
60
}
61
61
62
- static int mid_spi_dma_init_mfld (struct device * dev , struct dw_spi * dws )
62
+ static int dw_spi_dma_init_mfld (struct device * dev , struct dw_spi * dws )
63
63
{
64
64
struct dw_dma_slave slave = {
65
65
.src_id = 0 ,
@@ -81,13 +81,13 @@ static int mid_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws)
81
81
82
82
/* 1. Init rx channel */
83
83
slave .dma_dev = & dma_dev -> dev ;
84
- dws -> rxchan = dma_request_channel (mask , mid_spi_dma_chan_filter , & slave );
84
+ dws -> rxchan = dma_request_channel (mask , dw_spi_dma_chan_filter , & slave );
85
85
if (!dws -> rxchan )
86
86
goto err_exit ;
87
87
88
88
/* 2. Init tx channel */
89
89
slave .dst_id = 1 ;
90
- dws -> txchan = dma_request_channel (mask , mid_spi_dma_chan_filter , & slave );
90
+ dws -> txchan = dma_request_channel (mask , dw_spi_dma_chan_filter , & slave );
91
91
if (!dws -> txchan )
92
92
goto free_rxchan ;
93
93
@@ -96,7 +96,7 @@ static int mid_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws)
96
96
97
97
init_completion (& dws -> dma_completion );
98
98
99
- mid_spi_maxburst_init (dws );
99
+ dw_spi_dma_maxburst_init (dws );
100
100
101
101
return 0 ;
102
102
@@ -107,7 +107,7 @@ static int mid_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws)
107
107
return - EBUSY ;
108
108
}
109
109
110
- static int mid_spi_dma_init_generic (struct device * dev , struct dw_spi * dws )
110
+ static int dw_spi_dma_init_generic (struct device * dev , struct dw_spi * dws )
111
111
{
112
112
dws -> rxchan = dma_request_slave_channel (dev , "rx" );
113
113
if (!dws -> rxchan )
@@ -125,12 +125,12 @@ static int mid_spi_dma_init_generic(struct device *dev, struct dw_spi *dws)
125
125
126
126
init_completion (& dws -> dma_completion );
127
127
128
- mid_spi_maxburst_init (dws );
128
+ dw_spi_dma_maxburst_init (dws );
129
129
130
130
return 0 ;
131
131
}
132
132
133
- static void mid_spi_dma_exit (struct dw_spi * dws )
133
+ static void dw_spi_dma_exit (struct dw_spi * dws )
134
134
{
135
135
if (dws -> txchan ) {
136
136
dmaengine_terminate_sync (dws -> txchan );
@@ -145,7 +145,7 @@ static void mid_spi_dma_exit(struct dw_spi *dws)
145
145
dw_writel (dws , DW_SPI_DMACR , 0 );
146
146
}
147
147
148
- static irqreturn_t dma_transfer (struct dw_spi * dws )
148
+ static irqreturn_t dw_spi_dma_transfer_handler (struct dw_spi * dws )
149
149
{
150
150
u16 irq_status = dw_readl (dws , DW_SPI_ISR );
151
151
@@ -161,15 +161,16 @@ static irqreturn_t dma_transfer(struct dw_spi *dws)
161
161
return IRQ_HANDLED ;
162
162
}
163
163
164
- static bool mid_spi_can_dma (struct spi_controller * master ,
165
- struct spi_device * spi , struct spi_transfer * xfer )
164
+ static bool dw_spi_can_dma (struct spi_controller * master ,
165
+ struct spi_device * spi , struct spi_transfer * xfer )
166
166
{
167
167
struct dw_spi * dws = spi_controller_get_devdata (master );
168
168
169
169
return xfer -> len > dws -> fifo_len ;
170
170
}
171
171
172
- static enum dma_slave_buswidth convert_dma_width (u8 n_bytes ) {
172
+ static enum dma_slave_buswidth dw_spi_dma_convert_width (u8 n_bytes )
173
+ {
173
174
if (n_bytes == 1 )
174
175
return DMA_SLAVE_BUSWIDTH_1_BYTE ;
175
176
else if (n_bytes == 2 )
@@ -244,8 +245,8 @@ static void dw_spi_dma_tx_done(void *arg)
244
245
complete (& dws -> dma_completion );
245
246
}
246
247
247
- static struct dma_async_tx_descriptor * dw_spi_dma_prepare_tx ( struct dw_spi * dws ,
248
- struct spi_transfer * xfer )
248
+ static struct dma_async_tx_descriptor *
249
+ dw_spi_dma_prepare_tx ( struct dw_spi * dws , struct spi_transfer * xfer )
249
250
{
250
251
struct dma_slave_config txconf ;
251
252
struct dma_async_tx_descriptor * txdesc ;
@@ -258,7 +259,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws,
258
259
txconf .dst_addr = dws -> dma_addr ;
259
260
txconf .dst_maxburst = dws -> txburst ;
260
261
txconf .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES ;
261
- txconf .dst_addr_width = convert_dma_width (dws -> n_bytes );
262
+ txconf .dst_addr_width = dw_spi_dma_convert_width (dws -> n_bytes );
262
263
txconf .device_fc = false;
263
264
264
265
dmaengine_slave_config (dws -> txchan , & txconf );
@@ -350,7 +351,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,
350
351
rxconf .src_addr = dws -> dma_addr ;
351
352
rxconf .src_maxburst = dws -> rxburst ;
352
353
rxconf .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES ;
353
- rxconf .src_addr_width = convert_dma_width (dws -> n_bytes );
354
+ rxconf .src_addr_width = dw_spi_dma_convert_width (dws -> n_bytes );
354
355
rxconf .device_fc = false;
355
356
356
357
dmaengine_slave_config (dws -> rxchan , & rxconf );
@@ -369,7 +370,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,
369
370
return rxdesc ;
370
371
}
371
372
372
- static int mid_spi_dma_setup (struct dw_spi * dws , struct spi_transfer * xfer )
373
+ static int dw_spi_dma_setup (struct dw_spi * dws , struct spi_transfer * xfer )
373
374
{
374
375
u16 imr = 0 , dma_ctrl = 0 ;
375
376
@@ -391,12 +392,12 @@ static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer)
391
392
392
393
reinit_completion (& dws -> dma_completion );
393
394
394
- dws -> transfer_handler = dma_transfer ;
395
+ dws -> transfer_handler = dw_spi_dma_transfer_handler ;
395
396
396
397
return 0 ;
397
398
}
398
399
399
- static int mid_spi_dma_transfer (struct dw_spi * dws , struct spi_transfer * xfer )
400
+ static int dw_spi_dma_transfer (struct dw_spi * dws , struct spi_transfer * xfer )
400
401
{
401
402
struct dma_async_tx_descriptor * txdesc , * rxdesc ;
402
403
int ret ;
@@ -436,7 +437,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, struct spi_transfer *xfer)
436
437
return ret ;
437
438
}
438
439
439
- static void mid_spi_dma_stop (struct dw_spi * dws )
440
+ static void dw_spi_dma_stop (struct dw_spi * dws )
440
441
{
441
442
if (test_bit (TX_BUSY , & dws -> dma_chan_busy )) {
442
443
dmaengine_terminate_sync (dws -> txchan );
@@ -450,32 +451,32 @@ static void mid_spi_dma_stop(struct dw_spi *dws)
450
451
dw_writel (dws , DW_SPI_DMACR , 0 );
451
452
}
452
453
453
- static const struct dw_spi_dma_ops mfld_dma_ops = {
454
- .dma_init = mid_spi_dma_init_mfld ,
455
- .dma_exit = mid_spi_dma_exit ,
456
- .dma_setup = mid_spi_dma_setup ,
457
- .can_dma = mid_spi_can_dma ,
458
- .dma_transfer = mid_spi_dma_transfer ,
459
- .dma_stop = mid_spi_dma_stop ,
454
+ static const struct dw_spi_dma_ops dw_spi_dma_mfld_ops = {
455
+ .dma_init = dw_spi_dma_init_mfld ,
456
+ .dma_exit = dw_spi_dma_exit ,
457
+ .dma_setup = dw_spi_dma_setup ,
458
+ .can_dma = dw_spi_can_dma ,
459
+ .dma_transfer = dw_spi_dma_transfer ,
460
+ .dma_stop = dw_spi_dma_stop ,
460
461
};
461
462
462
- void dw_spi_mid_setup_dma_mfld (struct dw_spi * dws )
463
+ void dw_spi_dma_setup_mfld (struct dw_spi * dws )
463
464
{
464
- dws -> dma_ops = & mfld_dma_ops ;
465
+ dws -> dma_ops = & dw_spi_dma_mfld_ops ;
465
466
}
466
- EXPORT_SYMBOL_GPL (dw_spi_mid_setup_dma_mfld );
467
-
468
- static const struct dw_spi_dma_ops generic_dma_ops = {
469
- .dma_init = mid_spi_dma_init_generic ,
470
- .dma_exit = mid_spi_dma_exit ,
471
- .dma_setup = mid_spi_dma_setup ,
472
- .can_dma = mid_spi_can_dma ,
473
- .dma_transfer = mid_spi_dma_transfer ,
474
- .dma_stop = mid_spi_dma_stop ,
467
+ EXPORT_SYMBOL_GPL (dw_spi_dma_setup_mfld );
468
+
469
+ static const struct dw_spi_dma_ops dw_spi_dma_generic_ops = {
470
+ .dma_init = dw_spi_dma_init_generic ,
471
+ .dma_exit = dw_spi_dma_exit ,
472
+ .dma_setup = dw_spi_dma_setup ,
473
+ .can_dma = dw_spi_can_dma ,
474
+ .dma_transfer = dw_spi_dma_transfer ,
475
+ .dma_stop = dw_spi_dma_stop ,
475
476
};
476
477
477
- void dw_spi_mid_setup_dma_generic (struct dw_spi * dws )
478
+ void dw_spi_dma_setup_generic (struct dw_spi * dws )
478
479
{
479
- dws -> dma_ops = & generic_dma_ops ;
480
+ dws -> dma_ops = & dw_spi_dma_generic_ops ;
480
481
}
481
- EXPORT_SYMBOL_GPL (dw_spi_mid_setup_dma_generic );
482
+ EXPORT_SYMBOL_GPL (dw_spi_dma_setup_generic );
0 commit comments