iMX8QM SPI dynamically switching master and slave mode for same controller

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iMX8QM SPI dynamically switching master and slave mode for same controller

646 Views
Nishal
Contributor V

Hi ,

We have Android11_2.2.0 BSP(5.10.35) running on our custom hardware (imx8qm based).

We have SPI0 connected to a SPI slave, and also to a SPI master with different chip selects CS0 and CSI respectively.

We have validated individually, that SPI controller(lpspi0) works in master and slave mode dynamically. Is it possible to configure same controller as both master and slave at different instance? So far from the dts it looks like either the controller is configured as master or slave at boot time using dts. But we want to have a usecase something like device boots as SPI in master mode, later SPI switches to slave mode. Or just switch the modes at runtime between slave/master mode.

 

From the reference module, it looks like doable with the register settings. Please let me know

 

Thanks!lpspi0_cfg1.png

0 Kudos
1 Reply

614 Views
Sanket_Parekh
NXP TechSupport
NXP TechSupport

Hi @Nishal 

I hope you are doing well.
 
In spi-fsl-lpspi driver, there is no mechanism to change between slave and master once it has been probed. it can be only decided by dts by declaring the property "spi-slave".
 
Yes, you can change between master and slave modes using the register setting in Configuration Register 1 (CFGR1) ( bit : 0), but before editing this register you have to disable LPSPI module MEN ( bit :0) in Control Register(CR).
 
Thanks & Regards
Sanket Parekh
0 Kudos