The way the max delay is computed for this controller, it looks like it is searching for the max delay from an SPI message a using that. No idea if this is valid. But this change should support both `delay_usecs` and the new `delay` data which is of `spi_delay` type.
Unified · Split
| @@ -437,6 +437,7 @@ static int fsl_espi_do_one_msg(struct spi_master *master, · 436 unmodified lines | ||
| 437 | 437 | struct spi_message *m) |
| 438 | 438 | { |
| 439 | 439 | unsigned int delay_usecs = 0, rx_nbits = 0; |
| 440 | + unsigned int delay_nsecs = 0, delay_nsecs1 = 0; | |
| 440 | 441 | struct spi_transfer *t, trans = {}; |
| 441 | 442 | int ret; |
| 442 | 443 | |
| @@ -445,8 +446,16 @@ static int fsl_espi_do_one_msg(struct spi_master *master, · 2 unmodified lines | ||
| 445 | 446 | goto out; |
| 446 | 447 | |
| 447 | 448 | list_for_each_entry(t, &m->transfers, transfer_list) { |
| 448 | − if (t->delay_usecs > delay_usecs) | |
| 449 | − delay_usecs = t->delay_usecs; | |
| 449 | + if (t->delay_usecs) { | |
| 450 | + if (t->delay_usecs > delay_usecs) { | |
| 451 | + delay_usecs = t->delay_usecs; | |
| 452 | + delay_nsecs = delay_usecs * 1000; | |
| 453 | + } | |
| 454 | + } else { | |
| 455 | + delay_nsecs1 = spi_delay_to_ns(&t->delay, t); | |
| 456 | + if (delay_nsecs1 > delay_nsecs) | |
| 457 | + delay_nsecs = delay_nsecs1; | |
| 458 | + } | |
| 450 | 459 | if (t->rx_nbits > rx_nbits) |
| 451 | 460 | rx_nbits = t->rx_nbits; |
| 452 | 461 | } |
| @@ -457,7 +466,8 @@ static int fsl_espi_do_one_msg(struct spi_master *master, · 4 unmodified lines | ||
| 457 | 466 | trans.len = m->frame_length; |
| 458 | 467 | trans.speed_hz = t->speed_hz; |
| 459 | 468 | trans.bits_per_word = t->bits_per_word; |
| 460 | − trans.delay_usecs = delay_usecs; | |
| 469 | + trans.delay.value = delay_nsecs; | |
| 470 | + trans.delay.unit = SPI_DELAY_UNIT_NSECS; | |
| 461 | 471 | trans.rx_nbits = rx_nbits; |
| 462 | 472 | |
| 463 | 473 | if (trans.len) |
| @@ -1120,7 +1120,7 @@ static void _spi_transfer_delay_ns(u32 ns) · 1119 unmodified lines | ||
| 1120 | 1120 | } |
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | −static int _spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) | |
| 1123 | +int spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) | |
| 1124 | 1124 | { |
| 1125 | 1125 | u32 delay = _delay->value; |
| 1126 | 1126 | u32 unit = _delay->unit; |
| @@ -1153,6 +1153,7 @@ static int _spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer) · 26 unmodified lines | ||
| 1153 | 1153 | |
| 1154 | 1154 | return delay; |
| 1155 | 1155 | } |
| 1156 | +EXPORT_SYMBOL_GPL(spi_delay_to_ns); | |
| 1156 | 1157 | |
| 1157 | 1158 | int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer) |
| 1158 | 1159 | { |
| @@ -1161,7 +1162,7 @@ int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer) · 2 unmodified lines | ||
| 1161 | 1162 | if (!_delay) |
| 1162 | 1163 | return -EINVAL; |
| 1163 | 1164 | |
| 1164 | − delay = _spi_delay_to_ns(_delay, xfer); | |
| 1165 | + delay = spi_delay_to_ns(_delay, xfer); | |
| 1165 | 1166 | if (delay < 0) |
| 1166 | 1167 | return delay; |
| 1167 | 1168 | |
| @@ -3333,11 +3334,11 @@ static int _spi_xfer_word_delay_update(struct spi_transfer *xfer, · 2165 unmodified lines | ||
| 3333 | 3334 | { |
| 3334 | 3335 | int delay1, delay2; |
| 3335 | 3336 | |
| 3336 | − delay1 = _spi_delay_to_ns(&xfer->word_delay, xfer); | |
| 3337 | + delay1 = spi_delay_to_ns(&xfer->word_delay, xfer); | |
| 3337 | 3338 | if (delay1 < 0) |
| 3338 | 3339 | return delay1; |
| 3339 | 3340 | |
| 3340 | − delay2 = _spi_delay_to_ns(&spi->word_delay, xfer); | |
| 3341 | + delay2 = spi_delay_to_ns(&spi->word_delay, xfer); | |
| 3341 | 3342 | if (delay2 < 0) |
| 3342 | 3343 | return delay2; |
| 3343 | 3344 | |
| @@ -103,6 +103,7 @@ struct spi_delay { · 102 unmodified lines | ||
| 103 | 103 | u8 unit; |
| 104 | 104 | }; |
| 105 | 105 | |
| 106 | +extern int spi_delay_to_ns(struct spi_delay *_delay, struct spi_transfer *xfer); | |
| 106 | 107 | extern int spi_delay_exec(struct spi_delay *_delay, struct spi_transfer *xfer); |
| 107 | 108 | |
| 108 | 109 | /** |