From 97ac0c2c154a6d27e99faed941e186b416d8aaca Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 15 Nov 2024 15:24:01 -0800 Subject: [PATCH] Fix for building NXP LS1028A with SPI enabled. --- hal/nxp_ls1028a.c | 43 ++++++++++++++++++++++++------------------- hal/spi/spi_drv_nxp.c | 3 ++- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/hal/nxp_ls1028a.c b/hal/nxp_ls1028a.c index a93ac516c..e7edcb431 100644 --- a/hal/nxp_ls1028a.c +++ b/hal/nxp_ls1028a.c @@ -183,15 +183,15 @@ static void spi_transaction(unsigned int sel, unsigned int pcs, /*#define TPM_TEST*/ #ifdef TPM_TEST -void read_tpm_id() +void read_tpm_id(void) { - /*Read 4 bytes from offset D40F00. Assumes 0 wait state on TPM*/ + /* Read 4 bytes from offset D40F00. Assumes 0 wait state on TPM */ unsigned char out[8] = { 0x83, 0xD4, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00 }; unsigned char in[8] = { 0 }; unsigned char in2[8] = { 0 }; unsigned int counter; - /*LS1028A SPI to the MikroBus uses SPI3 (sel is 2) and CS 0*/ + /* LS1028A SPI to the MikroBus uses SPI3 (sel is 2) and CS 0 */ #ifndef SPI_SEL_TPM #define SPI_SEL_TPM 2 #endif @@ -219,16 +219,9 @@ void read_tpm_id() } #endif -/* Exposed functions */ -extern void nxp_ls1028a_spi_init(unsigned int sel); -extern int nxp_ls1028a_spi_xfer(unsigned int sel, unsigned int cs, - const unsigned char *out, unsigned char *in, - unsigned int size, int cont); -extern void nxp_ls1028a_spi_deinit(unsigned int sel); - void nxp_ls1028a_spi_init(unsigned int sel) { - /* TODO Expose more configuration options */ + /* TODO: Expose more configuration options */ spi_open(sel); } @@ -236,7 +229,7 @@ int nxp_ls1028a_spi_xfer(unsigned int sel, unsigned int cs, const unsigned char *out, unsigned char *in, unsigned int size, int cont) { - /*TODO Make spi_transaction actually return errors */ + /* TODO Make spi_transaction actually return errors */ spi_transaction(sel, cs, out, in, size, cont); return 0; } @@ -489,12 +482,6 @@ void hal_ddr_init(void) #endif } -void hal_flash_unlock(void) {} -void hal_flash_lock(void) {} -void ext_flash_lock(void) {} -void ext_flash_unlock(void) {} - - void xspi_writereg(uint32_t* addr, uint32_t val) { *(volatile uint32_t *)(addr) = val; @@ -619,6 +606,14 @@ void xspi_flash_sec_erase(uintptr_t address) XSPI_INTR &= ~XSPI_IPCMDDONE; } + +void hal_flash_unlock(void) +{ +} +void hal_flash_lock(void) +{ +} + int hal_flash_write(uintptr_t address, const uint8_t *data, int len) { xspi_write_en(address); @@ -650,6 +645,14 @@ int hal_flash_erase(uintptr_t address, int len) return len; } +#ifdef EXT_FLASH +void ext_flash_lock(void) +{ +} + +void ext_flash_unlock(void) +{ +} int ext_flash_write(uintptr_t address, const uint8_t *data, int len) { xspi_write_en(address); @@ -660,7 +663,7 @@ int ext_flash_write(uintptr_t address, const uint8_t *data, int len) int ext_flash_read(uintptr_t address, uint8_t *data, int len) { - address = address & MASK_32BIT; + address = (address & MASK_32BIT); memcpy(data, (void*)address, len); return len; } @@ -687,6 +690,8 @@ int ext_flash_erase(uintptr_t address, int len) return len; } +#endif /* EXT_FLASH */ + void hal_prepare_boot(void) { diff --git a/hal/spi/spi_drv_nxp.c b/hal/spi/spi_drv_nxp.c index cc1f42575..76fc75cc9 100644 --- a/hal/spi/spi_drv_nxp.c +++ b/hal/spi/spi_drv_nxp.c @@ -26,7 +26,8 @@ #include #include "spi_drv.h" -#if defined(TARGET_nxp_p1021) || defined(TARGET_nxp_t1024) +#if defined(TARGET_nxp_p1021) || defined(TARGET_nxp_t1024) || \ + defined(TARGET_nxp_ls1028a) #ifdef WOLFBOOT_TPM /* functions from nxp_p1021.c and nxp_t1024.c hal */