There seems to be a bug in the HSS / bare-metal-library:
mailbox_reg needs to be declared as “volatile uint32_t * mailbox_reg;”, otherwise the read/modify/write cycle starting at line 2021 will lead to unpredictable values
In our case, this lead to the 17th byte of the MSS_SYS_SPI_COPY_CMD operation being corrupted.
This byte contains the options / clock frequency, which explains why we were seeing wrong frequencies and data corruption.
https://github.com/polarfire-soc/platform/blob/8b4b440f7138809d7c68f66529387e58eb0ba816/drivers/mss/mss_sys_services/mss_sys_services.c#L1978
There seems to be a bug in the HSS / bare-metal-library: mailbox_reg needs to be declared as “volatile uint32_t * mailbox_reg;”, otherwise the read/modify/write cycle starting at line 2021 will lead to unpredictable values In our case, this lead to the 17th byte of the MSS_SYS_SPI_COPY_CMD operation being corrupted. This byte contains the options / clock frequency, which explains why we were seeing wrong frequencies and data corruption.
This is likely also the root cause for why this workaround is necessary: https://github.com/polarfire-soc/hart-software-services/commit/c0583945ba11372dcb9789f3cb6496d06fe3c612