Skip to content

Commit 691e759

Browse files
decsnynashif
authored andcommitted
spi_nxp_lpspi: Add version ID to data struct
Since I expect that the drivers will need to read this version ID maybe multiple times, instead of repeatedly doing so over the peripheral bus, it is probably worth it to store a byte in RAM representing this version. The behavior of the LPSPI is fairly significantly different between versions. Not enough to warrant separate drivers but enough to need a few workarounds or different code branches depending on this. Also, the interrupt based driver is currently using a wrong macro to read this, and that is a bug. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
1 parent aeedf86 commit 691e759

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static void lpspi_isr(const struct device *dev)
276276
}
277277

278278
if ((DIV_ROUND_UP(spi_context_rx_len_left(ctx, word_size_bytes), word_size_bytes) == 1) &&
279-
(LPSPI_VERID_MAJOR(base->VERID) < 2)) {
279+
(data->major_version < 2)) {
280280
/* Due to stalling behavior on older LPSPI,
281281
* need to end xfer in order to get last bit clocked out on bus.
282282
*/

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ int spi_nxp_init_common(const struct device *dev)
215215

216216
lpspi_module_system_init(base);
217217

218+
data->major_version = (base->VERID & LPSPI_VERID_MAJOR_MASK) >> LPSPI_VERID_MAJOR_SHIFT;
219+
218220
err = spi_context_cs_configure_all(&data->ctx);
219221
if (err < 0) {
220222
return err;

drivers/spi/spi_nxp_lpspi/spi_nxp_lpspi_priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct lpspi_data {
5050
struct spi_context ctx;
5151
void *driver_data;
5252
size_t transfer_len;
53+
uint8_t major_version;
5354
};
5455

5556
/* verifies spi_cfg validity and set up configuration of hardware for xfer */

0 commit comments

Comments
 (0)