Skip to content

Commit 463c482

Browse files
dgarskedanielinux
authored andcommitted
Fix for building NXP LS1028A with SPI enabled.
1 parent 2709af2 commit 463c482

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

hal/nxp_ls1028a.c

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ static void spi_transaction(unsigned int sel, unsigned int pcs,
183183

184184
/*#define TPM_TEST*/
185185
#ifdef TPM_TEST
186-
void read_tpm_id()
186+
void read_tpm_id(void)
187187
{
188-
/*Read 4 bytes from offset D40F00. Assumes 0 wait state on TPM*/
188+
/* Read 4 bytes from offset D40F00. Assumes 0 wait state on TPM */
189189
unsigned char out[8] = { 0x83, 0xD4, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00 };
190190
unsigned char in[8] = { 0 };
191191
unsigned char in2[8] = { 0 };
192192
unsigned int counter;
193193

194-
/*LS1028A SPI to the MikroBus uses SPI3 (sel is 2) and CS 0*/
194+
/* LS1028A SPI to the MikroBus uses SPI3 (sel is 2) and CS 0 */
195195
#ifndef SPI_SEL_TPM
196196
#define SPI_SEL_TPM 2
197197
#endif
@@ -219,24 +219,17 @@ void read_tpm_id()
219219
}
220220
#endif
221221

222-
/* Exposed functions */
223-
extern void nxp_ls1028a_spi_init(unsigned int sel);
224-
extern int nxp_ls1028a_spi_xfer(unsigned int sel, unsigned int cs,
225-
const unsigned char *out, unsigned char *in,
226-
unsigned int size, int cont);
227-
extern void nxp_ls1028a_spi_deinit(unsigned int sel);
228-
229222
void nxp_ls1028a_spi_init(unsigned int sel)
230223
{
231-
/* TODO Expose more configuration options */
224+
/* TODO: Expose more configuration options */
232225
spi_open(sel);
233226
}
234227

235228
int nxp_ls1028a_spi_xfer(unsigned int sel, unsigned int cs,
236229
const unsigned char *out, unsigned char *in,
237230
unsigned int size, int cont)
238231
{
239-
/*TODO Make spi_transaction actually return errors */
232+
/* TODO Make spi_transaction actually return errors */
240233
spi_transaction(sel, cs, out, in, size, cont);
241234
return 0;
242235
}
@@ -489,12 +482,6 @@ void hal_ddr_init(void)
489482
#endif
490483
}
491484

492-
void hal_flash_unlock(void) {}
493-
void hal_flash_lock(void) {}
494-
void ext_flash_lock(void) {}
495-
void ext_flash_unlock(void) {}
496-
497-
498485
void xspi_writereg(uint32_t* addr, uint32_t val)
499486
{
500487
*(volatile uint32_t *)(addr) = val;
@@ -619,6 +606,14 @@ void xspi_flash_sec_erase(uintptr_t address)
619606
XSPI_INTR &= ~XSPI_IPCMDDONE;
620607
}
621608

609+
610+
void hal_flash_unlock(void)
611+
{
612+
}
613+
void hal_flash_lock(void)
614+
{
615+
}
616+
622617
int hal_flash_write(uintptr_t address, const uint8_t *data, int len)
623618
{
624619
xspi_write_en(address);
@@ -650,6 +645,14 @@ int hal_flash_erase(uintptr_t address, int len)
650645
return len;
651646
}
652647

648+
#ifdef EXT_FLASH
649+
void ext_flash_lock(void)
650+
{
651+
}
652+
653+
void ext_flash_unlock(void)
654+
{
655+
}
653656
int ext_flash_write(uintptr_t address, const uint8_t *data, int len)
654657
{
655658
xspi_write_en(address);
@@ -660,7 +663,7 @@ int ext_flash_write(uintptr_t address, const uint8_t *data, int len)
660663

661664
int ext_flash_read(uintptr_t address, uint8_t *data, int len)
662665
{
663-
address = address & MASK_32BIT;
666+
address = (address & MASK_32BIT);
664667
memcpy(data, (void*)address, len);
665668
return len;
666669
}
@@ -687,6 +690,8 @@ int ext_flash_erase(uintptr_t address, int len)
687690

688691
return len;
689692
}
693+
#endif /* EXT_FLASH */
694+
690695

691696
void hal_prepare_boot(void)
692697
{

hal/spi/spi_drv_nxp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
#include <stddef.h>
2727
#include "spi_drv.h"
2828

29-
#if defined(TARGET_nxp_p1021) || defined(TARGET_nxp_t1024)
29+
#if defined(TARGET_nxp_p1021) || defined(TARGET_nxp_t1024) || \
30+
defined(TARGET_nxp_ls1028a)
3031
#ifdef WOLFBOOT_TPM
3132

3233
/* functions from nxp_p1021.c and nxp_t1024.c hal */

0 commit comments

Comments
 (0)