Skip to content

Commit 5c5de36

Browse files
andy-shevbroonie
authored andcommitted
spi: pxa2xx: Remove DMA parameters from struct chip_data
The DMA related fields are set once and never modified. It effectively repeats the content of the same fields in struct pxa2xx_spi_controller. With that, remove DMA parameters from struct chip_data. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 513525e commit 5c5de36

File tree

3 files changed

+9
-61
lines changed

3 files changed

+9
-61
lines changed

drivers/spi/spi-pxa2xx-dma.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data,
6868
enum dma_transfer_direction dir,
6969
struct spi_transfer *xfer)
7070
{
71-
struct chip_data *chip =
72-
spi_get_ctldata(drv_data->controller->cur_msg->spi);
7371
enum dma_slave_buswidth width;
7472
struct dma_slave_config cfg;
7573
struct dma_chan *chan;
@@ -94,14 +92,14 @@ pxa2xx_spi_dma_prepare_one(struct driver_data *drv_data,
9492
if (dir == DMA_MEM_TO_DEV) {
9593
cfg.dst_addr = drv_data->ssp->phys_base + SSDR;
9694
cfg.dst_addr_width = width;
97-
cfg.dst_maxburst = chip->dma_burst_size;
95+
cfg.dst_maxburst = drv_data->controller_info->dma_burst_size;
9896

9997
sgt = &xfer->tx_sg;
10098
chan = drv_data->controller->dma_tx;
10199
} else {
102100
cfg.src_addr = drv_data->ssp->phys_base + SSDR;
103101
cfg.src_addr_width = width;
104-
cfg.src_maxburst = chip->dma_burst_size;
102+
cfg.src_maxburst = drv_data->controller_info->dma_burst_size;
105103

106104
sgt = &xfer->rx_sg;
107105
chan = drv_data->controller->dma_rx;
@@ -225,19 +223,3 @@ void pxa2xx_spi_dma_release(struct driver_data *drv_data)
225223
controller->dma_tx = NULL;
226224
}
227225
}
228-
229-
int pxa2xx_spi_set_dma_burst_and_threshold(struct chip_data *chip,
230-
struct spi_device *spi,
231-
u8 bits_per_word, u32 *burst_code,
232-
u32 *threshold)
233-
{
234-
struct driver_data *drv_data = spi_controller_get_devdata(spi->controller);
235-
u32 dma_burst_size = drv_data->controller_info->dma_burst_size;
236-
237-
/* We use the default the DMA burst size and FIFO thresholds for now */
238-
*burst_code = dma_burst_size;
239-
*threshold = SSCR1_RxTresh(RX_THRESH_DFLT)
240-
| SSCR1_TxTresh(TX_THRESH_DFLT);
241-
242-
return 0;
243-
}

drivers/spi/spi-pxa2xx.c

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -934,11 +934,11 @@ static bool pxa2xx_spi_can_dma(struct spi_controller *controller,
934934
struct spi_device *spi,
935935
struct spi_transfer *xfer)
936936
{
937-
struct chip_data *chip = spi_get_ctldata(spi);
937+
struct driver_data *drv_data = spi_controller_get_devdata(controller);
938938

939-
return chip->enable_dma &&
939+
return drv_data->controller_info->enable_dma &&
940940
xfer->len <= MAX_DMA_LEN &&
941-
xfer->len >= chip->dma_burst_size;
941+
xfer->len >= drv_data->controller_info->dma_burst_size;
942942
}
943943

944944
static int pxa2xx_spi_transfer_one(struct spi_controller *controller,
@@ -947,9 +947,8 @@ static int pxa2xx_spi_transfer_one(struct spi_controller *controller,
947947
{
948948
struct driver_data *drv_data = spi_controller_get_devdata(controller);
949949
struct chip_data *chip = spi_get_ctldata(spi);
950-
u32 dma_thresh = chip->dma_threshold;
951-
u32 dma_burst = chip->dma_burst_size;
952950
u32 change_mask = pxa2xx_spi_get_ssrc1_change_mask(drv_data);
951+
u32 dma_thresh;
953952
u32 clk_div;
954953
u8 bits;
955954
u32 speed;
@@ -959,7 +958,7 @@ static int pxa2xx_spi_transfer_one(struct spi_controller *controller,
959958
int dma_mapped;
960959

961960
/* Check if we can DMA this transfer */
962-
if (transfer->len > MAX_DMA_LEN && chip->enable_dma) {
961+
if (transfer->len > MAX_DMA_LEN && drv_data->controller_info->enable_dma) {
963962
/* Warn ... we force this to PIO mode */
964963
dev_warn_ratelimited(&spi->dev,
965964
"DMA disabled for transfer length %u greater than %d\n",
@@ -995,19 +994,8 @@ static int pxa2xx_spi_transfer_one(struct spi_controller *controller,
995994
drv_data->read = drv_data->rx ? u32_reader : null_reader;
996995
drv_data->write = drv_data->tx ? u32_writer : null_writer;
997996
}
998-
/*
999-
* If bits per word is changed in DMA mode, then must check
1000-
* the thresholds and burst also.
1001-
*/
1002-
if (chip->enable_dma) {
1003-
if (pxa2xx_spi_set_dma_burst_and_threshold(chip,
1004-
spi,
1005-
bits, &dma_burst,
1006-
&dma_thresh))
1007-
dev_warn_ratelimited(&spi->dev,
1008-
"DMA burst size reduced to match bits_per_word\n");
1009-
}
1010997

998+
dma_thresh = SSCR1_RxTresh(RX_THRESH_DFLT) | SSCR1_TxTresh(TX_THRESH_DFLT);
1011999
dma_mapped = controller->can_dma &&
10121000
controller->can_dma(controller, spi, transfer) &&
10131001
controller->cur_msg_mapped;
@@ -1213,7 +1201,6 @@ static int setup(struct spi_device *spi)
12131201
if (!chip)
12141202
return -ENOMEM;
12151203

1216-
chip->enable_dma = drv_data->controller_info->enable_dma;
12171204
chip->timeout = TIMOUT_DFLT;
12181205
}
12191206

@@ -1236,20 +1223,6 @@ static int setup(struct spi_device *spi)
12361223
chip->lpss_tx_threshold = tx_thres;
12371224
}
12381225

1239-
if (chip->enable_dma) {
1240-
/* Set up legal burst and threshold for DMA */
1241-
if (pxa2xx_spi_set_dma_burst_and_threshold(chip, spi,
1242-
spi->bits_per_word,
1243-
&chip->dma_burst_size,
1244-
&chip->dma_threshold)) {
1245-
dev_warn(&spi->dev,
1246-
"in setup: DMA burst size reduced to match bits_per_word\n");
1247-
}
1248-
dev_dbg(&spi->dev,
1249-
"in setup: DMA burst size set to %u\n",
1250-
chip->dma_burst_size);
1251-
}
1252-
12531226
switch (drv_data->ssp_type) {
12541227
case QUARK_X1000_SSP:
12551228
chip->threshold = (QUARK_X1000_SSCR1_RxTresh(rx_thres)
@@ -1439,6 +1412,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
14391412
if (IS_ERR(platform_info))
14401413
return dev_err_probe(dev, PTR_ERR(platform_info), "missing platform data\n");
14411414
}
1415+
dev_dbg(dev, "DMA burst size set to %u\n", platform_info->dma_burst_size);
14421416

14431417
ssp = pxa_ssp_request(pdev->id, pdev->name);
14441418
if (!ssp)

drivers/spi/spi-pxa2xx.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ struct chip_data {
7979
u32 cr1;
8080
u32 dds_rate;
8181
u32 timeout;
82-
u8 enable_dma;
83-
u32 dma_burst_size;
84-
u32 dma_threshold;
8582
u32 threshold;
8683
u16 lpss_rx_threshold;
8784
u16 lpss_tx_threshold;
@@ -142,10 +139,5 @@ extern void pxa2xx_spi_dma_start(struct driver_data *drv_data);
142139
extern void pxa2xx_spi_dma_stop(struct driver_data *drv_data);
143140
extern int pxa2xx_spi_dma_setup(struct driver_data *drv_data);
144141
extern void pxa2xx_spi_dma_release(struct driver_data *drv_data);
145-
extern int pxa2xx_spi_set_dma_burst_and_threshold(struct chip_data *chip,
146-
struct spi_device *spi,
147-
u8 bits_per_word,
148-
u32 *burst_code,
149-
u32 *threshold);
150142

151143
#endif /* SPI_PXA2XX_H */

0 commit comments

Comments
 (0)