Commit 691e7598 authored by Declan Snyder's avatar Declan Snyder Committed by Anas Nashif
Browse files

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: default avatarDeclan Snyder <declan.snyder@nxp.com>
parent aeedf86d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ static void lpspi_isr(const struct device *dev)
	}

	if ((DIV_ROUND_UP(spi_context_rx_len_left(ctx, word_size_bytes), word_size_bytes) == 1) &&
	    (LPSPI_VERID_MAJOR(base->VERID) < 2)) {
	    (data->major_version < 2)) {
		/* Due to stalling behavior on older LPSPI,
		 * need to end xfer in order to get last bit clocked out on bus.
		 */
+2 −0
Original line number Diff line number Diff line
@@ -215,6 +215,8 @@ int spi_nxp_init_common(const struct device *dev)

	lpspi_module_system_init(base);

	data->major_version = (base->VERID & LPSPI_VERID_MAJOR_MASK) >> LPSPI_VERID_MAJOR_SHIFT;

	err = spi_context_cs_configure_all(&data->ctx);
	if (err < 0) {
		return err;
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ struct lpspi_data {
	struct spi_context ctx;
	void *driver_data;
	size_t transfer_len;
	uint8_t major_version;
};

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