Commit d11233e0 authored by Mark Brown's avatar Mark Brown

Merge series "spi: finalize 'delay_usecs' removal/transition" from Alexandru...

Merge series "spi: finalize 'delay_usecs' removal/transition" from Alexandru Ardelean <aardelean@deviqon.com>:

A while back I started the introduction of the 'spi_delay' data type:
  https://lore.kernel.org/linux-spi/20190926105147.7839-1-alexandru.ardelean@analog.com/

Users of the 'delay_usecs' were removed from drivers.

Now it's time to remove the 'delay_usecs' from the SPI subsystem and use
only the 'delay' field.

This changeset adapts all SPI drivers to do without 'delay_usecs'.
Additionally, for greybus we need to adapt it to use the 'delay' in
nano-seconds and convert it to micro-seconds.

Alexandru Ardelean (10):
  spi: spi-axi-spi-engine: remove usage of delay_usecs
  spi: bcm63xx-spi: don't check 'delay_usecs' field
  spi: spi-bcm-qspi: replace 'delay_usecs' with 'delay.value' check
  spi: spi-sh: replace 'delay_usecs' with 'delay.value' in pr_debug
  spi: spi-tegra20-flash: don't check 'delay_usecs' field for spi
    transfer
  staging: greybus: spilib: use 'spi_delay_to_ns' for getting xfer delay
  spi: spi-falcon: remove check for 'delay_usecs'
  spi: fsl-espi: remove usage of 'delay_usecs' field
  spi: core: remove 'delay_usecs' field from spi_transfer
  spi: docs: update info about 'delay_usecs'

 Documentation/spi/spi-summary.rst |  7 +++++--
 drivers/spi/spi-axi-spi-engine.c  | 12 ++++--------
 drivers/spi/spi-bcm-qspi.c        |  2 +-
 drivers/spi/spi-bcm63xx.c         |  2 +-
 drivers/spi/spi-falcon.c          |  2 +-
 drivers/spi/spi-fsl-espi.c        | 17 +++++------------
 drivers/spi/spi-sh.c              |  4 ++--
 drivers/spi/spi-tegra20-sflash.c  |  3 +--
 drivers/spi/spi.c                 |  1 -
 drivers/staging/greybus/spilib.c  |  5 ++++-
 include/linux/spi/spi.h           | 12 ------------
 11 files changed, 24 insertions(+), 43 deletions(-)

--
2.29.2

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
parents 12ef51b1 05d8a019
...@@ -411,8 +411,11 @@ any more such messages. ...@@ -411,8 +411,11 @@ any more such messages.
duplex (one pointer is NULL) transfers; duplex (one pointer is NULL) transfers;
+ optionally defining short delays after transfers ... using + optionally defining short delays after transfers ... using
the spi_transfer.delay_usecs setting (this delay can be the the spi_transfer.delay.value setting (this delay can be the
only protocol effect, if the buffer length is zero); only protocol effect, if the buffer length is zero) ...
when specifying this delay the default spi_transfer.delay.unit
is microseconds, however this can be adjusted to clock cycles
or nanoseconds if needed;
+ whether the chipselect becomes inactive after a transfer and + whether the chipselect becomes inactive after a transfer and
any delay ... by using the spi_transfer.cs_change flag; any delay ... by using the spi_transfer.cs_change flag;
......
...@@ -170,14 +170,10 @@ static void spi_engine_gen_sleep(struct spi_engine_program *p, bool dry, ...@@ -170,14 +170,10 @@ static void spi_engine_gen_sleep(struct spi_engine_program *p, bool dry,
unsigned int t; unsigned int t;
int delay; int delay;
if (xfer->delay_usecs) {
delay = xfer->delay_usecs;
} else {
delay = spi_delay_to_ns(&xfer->delay, xfer); delay = spi_delay_to_ns(&xfer->delay, xfer);
if (delay < 0) if (delay < 0)
return; return;
delay /= 1000; delay /= 1000;
}
if (delay == 0) if (delay == 0)
return; return;
......
...@@ -671,7 +671,7 @@ static int update_qspi_trans_byte_count(struct bcm_qspi *qspi, ...@@ -671,7 +671,7 @@ static int update_qspi_trans_byte_count(struct bcm_qspi *qspi,
if (qt->byte >= qt->trans->len) { if (qt->byte >= qt->trans->len) {
/* we're at the end of the spi_transfer */ /* we're at the end of the spi_transfer */
/* in TX mode, need to pause for a delay or CS change */ /* in TX mode, need to pause for a delay or CS change */
if (qt->trans->delay_usecs && if (qt->trans->delay.value &&
(flags & TRANS_STATUS_BREAK_DELAY)) (flags & TRANS_STATUS_BREAK_DELAY))
ret |= TRANS_STATUS_BREAK_DELAY; ret |= TRANS_STATUS_BREAK_DELAY;
if (qt->trans->cs_change && if (qt->trans->cs_change &&
......
...@@ -369,7 +369,7 @@ static int bcm63xx_spi_transfer_one(struct spi_master *master, ...@@ -369,7 +369,7 @@ static int bcm63xx_spi_transfer_one(struct spi_master *master,
} }
/* CS will be deasserted directly after transfer */ /* CS will be deasserted directly after transfer */
if (t->delay_usecs || t->delay.value) { if (t->delay.value) {
dev_err(&spi->dev, "unable to keep CS asserted after transfer\n"); dev_err(&spi->dev, "unable to keep CS asserted after transfer\n");
status = -EINVAL; status = -EINVAL;
goto exit; goto exit;
......
...@@ -377,7 +377,7 @@ static int falcon_sflash_xfer_one(struct spi_master *master, ...@@ -377,7 +377,7 @@ static int falcon_sflash_xfer_one(struct spi_master *master,
m->actual_length += t->len; m->actual_length += t->len;
WARN_ON(t->delay_usecs || t->delay.value || t->cs_change); WARN_ON(t->delay.value || t->cs_change);
spi_flags = 0; spi_flags = 0;
} }
......
...@@ -435,8 +435,7 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans) ...@@ -435,8 +435,7 @@ static int fsl_espi_trans(struct spi_message *m, struct spi_transfer *trans)
static int fsl_espi_do_one_msg(struct spi_master *master, static int fsl_espi_do_one_msg(struct spi_master *master,
struct spi_message *m) struct spi_message *m)
{ {
unsigned int delay_usecs = 0, rx_nbits = 0; unsigned int rx_nbits = 0, delay_nsecs = 0;
unsigned int delay_nsecs = 0, delay_nsecs1 = 0;
struct spi_transfer *t, trans = {}; struct spi_transfer *t, trans = {};
int ret; int ret;
...@@ -445,16 +444,10 @@ static int fsl_espi_do_one_msg(struct spi_master *master, ...@@ -445,16 +444,10 @@ static int fsl_espi_do_one_msg(struct spi_master *master,
goto out; goto out;
list_for_each_entry(t, &m->transfers, transfer_list) { list_for_each_entry(t, &m->transfers, transfer_list) {
if (t->delay_usecs) { unsigned int delay = spi_delay_to_ns(&t->delay, t);
if (t->delay_usecs > delay_usecs) {
delay_usecs = t->delay_usecs; if (delay > delay_nsecs)
delay_nsecs = delay_usecs * 1000; delay_nsecs = delay;
}
} else {
delay_nsecs1 = spi_delay_to_ns(&t->delay, t);
if (delay_nsecs1 > delay_nsecs)
delay_nsecs = delay_nsecs1;
}
if (t->rx_nbits > rx_nbits) if (t->rx_nbits > rx_nbits)
rx_nbits = t->rx_nbits; rx_nbits = t->rx_nbits;
} }
......
...@@ -290,8 +290,8 @@ static void spi_sh_work(struct work_struct *work) ...@@ -290,8 +290,8 @@ static void spi_sh_work(struct work_struct *work)
list_for_each_entry(t, &mesg->transfers, transfer_list) { list_for_each_entry(t, &mesg->transfers, transfer_list) {
pr_debug("tx_buf = %p, rx_buf = %p\n", pr_debug("tx_buf = %p, rx_buf = %p\n",
t->tx_buf, t->rx_buf); t->tx_buf, t->rx_buf);
pr_debug("len = %d, delay_usecs = %d\n", pr_debug("len = %d, delay.value = %d\n",
t->len, t->delay_usecs); t->len, t->delay.value);
if (t->tx_buf) { if (t->tx_buf) {
ret = spi_sh_send(ss, mesg, t); ret = spi_sh_send(ss, mesg, t);
......
...@@ -341,8 +341,7 @@ static int tegra_sflash_transfer_one_message(struct spi_master *master, ...@@ -341,8 +341,7 @@ static int tegra_sflash_transfer_one_message(struct spi_master *master,
goto exit; goto exit;
} }
msg->actual_length += xfer->len; msg->actual_length += xfer->len;
if (xfer->cs_change && if (xfer->cs_change && xfer->delay.value) {
(xfer->delay_usecs || xfer->delay.value)) {
tegra_sflash_writel(tsd, tsd->def_command_reg, tegra_sflash_writel(tsd, tsd->def_command_reg,
SPI_COMMAND); SPI_COMMAND);
spi_transfer_delay_exec(xfer); spi_transfer_delay_exec(xfer);
......
...@@ -3178,7 +3178,6 @@ struct spi_replaced_transfers *spi_replace_transfers( ...@@ -3178,7 +3178,6 @@ struct spi_replaced_transfers *spi_replace_transfers(
/* clear cs_change and delay for all but the last */ /* clear cs_change and delay for all but the last */
if (i) { if (i) {
xfer->cs_change = false; xfer->cs_change = false;
xfer->delay_usecs = 0;
xfer->delay.value = 0; xfer->delay.value = 0;
} }
} }
......
...@@ -245,6 +245,7 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi, ...@@ -245,6 +245,7 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,
/* Fill in the transfers array */ /* Fill in the transfers array */
xfer = spi->first_xfer; xfer = spi->first_xfer;
while (msg->state != GB_SPI_STATE_OP_DONE) { while (msg->state != GB_SPI_STATE_OP_DONE) {
int xfer_delay;
if (xfer == spi->last_xfer) if (xfer == spi->last_xfer)
xfer_len = spi->last_xfer_size; xfer_len = spi->last_xfer_size;
else else
...@@ -259,7 +260,9 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi, ...@@ -259,7 +260,9 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,
gb_xfer->speed_hz = cpu_to_le32(xfer->speed_hz); gb_xfer->speed_hz = cpu_to_le32(xfer->speed_hz);
gb_xfer->len = cpu_to_le32(xfer_len); gb_xfer->len = cpu_to_le32(xfer_len);
gb_xfer->delay_usecs = cpu_to_le16(xfer->delay_usecs); xfer_delay = spi_delay_to_ns(&xfer->delay, xfer) / 1000;
xfer_delay = clamp_t(u16, xfer_delay, 0, U16_MAX);
gb_xfer->delay_usecs = cpu_to_le16(xfer_delay);
gb_xfer->cs_change = xfer->cs_change; gb_xfer->cs_change = xfer->cs_change;
gb_xfer->bits_per_word = xfer->bits_per_word; gb_xfer->bits_per_word = xfer->bits_per_word;
......
...@@ -832,9 +832,6 @@ extern void spi_res_release(struct spi_controller *ctlr, ...@@ -832,9 +832,6 @@ extern void spi_res_release(struct spi_controller *ctlr,
* @delay: delay to be introduced after this transfer before * @delay: delay to be introduced after this transfer before
* (optionally) changing the chipselect status, then starting * (optionally) changing the chipselect status, then starting
* the next transfer or completing this @spi_message. * the next transfer or completing this @spi_message.
* @delay_usecs: microseconds to delay after this transfer before
* (optionally) changing the chipselect status, then starting
* the next transfer or completing this @spi_message.
* @word_delay: inter word delay to be introduced after each word size * @word_delay: inter word delay to be introduced after each word size
* (set by bits_per_word) transmission. * (set by bits_per_word) transmission.
* @effective_speed_hz: the effective SCK-speed that was used to * @effective_speed_hz: the effective SCK-speed that was used to
...@@ -946,7 +943,6 @@ struct spi_transfer { ...@@ -946,7 +943,6 @@ struct spi_transfer {
#define SPI_NBITS_DUAL 0x02 /* 2bits transfer */ #define SPI_NBITS_DUAL 0x02 /* 2bits transfer */
#define SPI_NBITS_QUAD 0x04 /* 4bits transfer */ #define SPI_NBITS_QUAD 0x04 /* 4bits transfer */
u8 bits_per_word; u8 bits_per_word;
u16 delay_usecs;
struct spi_delay delay; struct spi_delay delay;
struct spi_delay cs_change_delay; struct spi_delay cs_change_delay;
struct spi_delay word_delay; struct spi_delay word_delay;
...@@ -1060,14 +1056,6 @@ spi_transfer_del(struct spi_transfer *t) ...@@ -1060,14 +1056,6 @@ spi_transfer_del(struct spi_transfer *t)
static inline int static inline int
spi_transfer_delay_exec(struct spi_transfer *t) spi_transfer_delay_exec(struct spi_transfer *t)
{ {
struct spi_delay d;
if (t->delay_usecs) {
d.value = t->delay_usecs;
d.unit = SPI_DELAY_UNIT_USECS;
return spi_delay_exec(&d, NULL);
}
return spi_delay_exec(&t->delay, t); return spi_delay_exec(&t->delay, t);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment