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>
This commit is contained in:
parent
aeedf86da6
commit
691e7598ff
3 changed files with 4 additions and 1 deletions
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue