mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
spi/s3c64xx: Use core message handling
Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
2cc6e2e0c8
commit
0732a9d2a1
1 changed files with 64 additions and 104 deletions
|
@ -879,18 +879,14 @@ static int s3c64xx_spi_prepare_message(struct spi_master *master,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
|
static int s3c64xx_spi_transfer_one(struct spi_master *master,
|
||||||
struct spi_message *msg)
|
struct spi_device *spi,
|
||||||
|
struct spi_transfer *xfer)
|
||||||
{
|
{
|
||||||
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
|
struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
|
||||||
struct spi_device *spi = msg->spi;
|
int status;
|
||||||
struct spi_transfer *xfer;
|
|
||||||
int status = 0, cs_toggle = 0;
|
|
||||||
u32 speed;
|
u32 speed;
|
||||||
u8 bpw;
|
u8 bpw;
|
||||||
|
|
||||||
list_for_each_entry(xfer, &msg->transfers, transfer_list) {
|
|
||||||
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int use_dma;
|
int use_dma;
|
||||||
|
|
||||||
|
@ -904,8 +900,7 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
|
||||||
dev_err(&spi->dev,
|
dev_err(&spi->dev,
|
||||||
"Xfer length(%u) not a multiple of word size(%u)\n",
|
"Xfer length(%u) not a multiple of word size(%u)\n",
|
||||||
xfer->len, bpw / 8);
|
xfer->len, bpw / 8);
|
||||||
status = -EIO;
|
return -EIO;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) {
|
if (bpw != sdd->cur_bpw || speed != sdd->cur_speed) {
|
||||||
|
@ -914,9 +909,6 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
|
||||||
s3c64xx_spi_config(sdd);
|
s3c64xx_spi_config(sdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Slave Select */
|
|
||||||
enable_cs(sdd, spi);
|
|
||||||
|
|
||||||
/* Polling method for xfers not bigger than FIFO capacity */
|
/* Polling method for xfers not bigger than FIFO capacity */
|
||||||
use_dma = 0;
|
use_dma = 0;
|
||||||
if (!is_polling(sdd) &&
|
if (!is_polling(sdd) &&
|
||||||
|
@ -957,43 +949,11 @@ static int s3c64xx_spi_transfer_one_message(struct spi_master *master,
|
||||||
&& (sdd->state & RXBUSY))
|
&& (sdd->state & RXBUSY))
|
||||||
s3c64xx_spi_dma_stop(sdd, &sdd->rx_dma);
|
s3c64xx_spi_dma_stop(sdd, &sdd->rx_dma);
|
||||||
}
|
}
|
||||||
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
flush_fifo(sdd);
|
|
||||||
|
|
||||||
if (xfer->delay_usecs)
|
|
||||||
udelay(xfer->delay_usecs);
|
|
||||||
|
|
||||||
if (xfer->cs_change) {
|
|
||||||
/* Hint that the next mssg is gonna be
|
|
||||||
for the same device */
|
|
||||||
if (list_is_last(&xfer->transfer_list,
|
|
||||||
&msg->transfers))
|
|
||||||
cs_toggle = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg->actual_length += xfer->len;
|
|
||||||
}
|
|
||||||
|
|
||||||
out:
|
|
||||||
if (!cs_toggle || status) {
|
|
||||||
/* Quiese the signals */
|
|
||||||
writel(S3C64XX_SPI_SLAVE_SIG_INACT,
|
|
||||||
sdd->regs + S3C64XX_SPI_SLAVE_SEL);
|
|
||||||
disable_cs(sdd, spi);
|
|
||||||
} else {
|
} else {
|
||||||
sdd->tgl_spi = spi;
|
flush_fifo(sdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
s3c64xx_spi_unmap_mssg(sdd, msg);
|
return status;
|
||||||
|
|
||||||
msg->status = status;
|
|
||||||
|
|
||||||
spi_finalize_current_message(master);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int s3c64xx_spi_unprepare_message(struct spi_master *master,
|
static int s3c64xx_spi_unprepare_message(struct spi_master *master,
|
||||||
|
@ -1379,7 +1339,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
|
||||||
master->cleanup = s3c64xx_spi_cleanup;
|
master->cleanup = s3c64xx_spi_cleanup;
|
||||||
master->prepare_transfer_hardware = s3c64xx_spi_prepare_transfer;
|
master->prepare_transfer_hardware = s3c64xx_spi_prepare_transfer;
|
||||||
master->prepare_message = s3c64xx_spi_prepare_message;
|
master->prepare_message = s3c64xx_spi_prepare_message;
|
||||||
master->transfer_one_message = s3c64xx_spi_transfer_one_message;
|
master->transfer_one = s3c64xx_spi_transfer_one;
|
||||||
master->unprepare_message = s3c64xx_spi_unprepare_message;
|
master->unprepare_message = s3c64xx_spi_unprepare_message;
|
||||||
master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer;
|
master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer;
|
||||||
master->num_chipselect = sci->num_cs;
|
master->num_chipselect = sci->num_cs;
|
||||||
|
|
Loading…
Reference in a new issue