S32K3XX Progmem fixes and size config
This commit is contained in:
parent
5826e8eeb1
commit
75631e6169
@ -1677,4 +1677,17 @@ config FS26_SPI_FREQUENCY
|
||||
|
||||
endmenu
|
||||
|
||||
|
||||
menu "Progmem (Data-flash) Configuration"
|
||||
depends on S32K3XX_PROGMEM
|
||||
|
||||
config S32K3XX_PROGMEM_SIZE
|
||||
int "Progmem size"
|
||||
default 128
|
||||
---help---
|
||||
Size of the Data Flash data memory used as a
|
||||
Memory-Technology-Device (MTD).
|
||||
|
||||
endmenu
|
||||
|
||||
endif # ARCH_CHIP_S32K3XX
|
||||
|
@ -213,7 +213,7 @@
|
||||
|
||||
#define S32K3XX_FMU_MCR (S32K3XX_FMU_BASE + S32K3XX_FMU_MCR_OFFSET)
|
||||
#define S32K3XX_FMU_MCRS (S32K3XX_FMU_BASE + S32K3XX_FMU_MCRS_OFFSET)
|
||||
#define S32K3XX_FMU_PD(n) (S32K3XX_FMU_BASE + S32K3XX_FMU_PD_OFFSET + (n * 4))
|
||||
#define S32K3XX_FMU_PD(n) (S32K3XX_FMU_BASE + S32K3XX_FMU_PD_OFFSET + (n) * 4)
|
||||
|
||||
/* PFLASH Register Bitfield Definitions *************************************/
|
||||
|
||||
|
@ -43,6 +43,14 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_S32K3XX_PROGMEM_SIZE > DFLASH_SIZE
|
||||
# error Progmem size too big
|
||||
#endif
|
||||
|
||||
#if CONFIG_S32K3XX_PROGMEM_SIZE % 8 != 0
|
||||
# error Progmem must be a multiple of 8
|
||||
#endif
|
||||
|
||||
#define min(a,b) \
|
||||
({ __typeof__ (a) _a = (a); \
|
||||
__typeof__ (b) _b = (b); \
|
||||
@ -54,14 +62,13 @@
|
||||
|
||||
uint32_t get_sector(uint32_t address)
|
||||
{
|
||||
if ((address >= S32K3XX_PROGMEM_START_ADDR) &&
|
||||
(address <= S32K3XX_PROGMEM_END_ADDR))
|
||||
{
|
||||
/* The address is from the data sectors */
|
||||
DEBUGASSERT(((address >= S32K3XX_PROGMEM_START_ADDR) &&
|
||||
(address <= S32K3XX_PROGMEM_END_ADDR)));
|
||||
|
||||
return ((address - (uint32_t)S32K3XX_PROGMEM_START_ADDR) /
|
||||
/* The address is from the data sectors */
|
||||
|
||||
return ((address - (uint32_t)S32K3XX_PROGMEM_START_ADDR) /
|
||||
S32K3XX_PROGMEM_SECTOR_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
void data_sector_lock(uint32_t sector, uint32_t lock)
|
||||
@ -362,6 +369,10 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Address with or without flash offset */
|
||||
|
||||
addr = ((addr % S32K3XX_PROGMEM_START_ADDR) + S32K3XX_PROGMEM_START_ADDR);
|
||||
|
||||
offset = addr % S32K3XX_PROGMEM_WRITE_SIZE;
|
||||
dest = addr - offset;
|
||||
words_to_write = ((count + offset) / 4);
|
||||
@ -392,6 +403,8 @@ ssize_t up_progmem_write(size_t addr, const void *buf, size_t count)
|
||||
{
|
||||
putreg32(*p_src++, S32K3XX_FMU_PD(i));
|
||||
}
|
||||
|
||||
dest += 4;
|
||||
}
|
||||
|
||||
words_to_write = words_to_write - i;
|
||||
|
@ -50,7 +50,7 @@
|
||||
|
||||
#define S32K3XX_PROGMEM_BLOCK_COUNT 1
|
||||
|
||||
#define S32K3XX_PROGMEM_BLOCK_SIZE DFLASH_SIZE * 1024
|
||||
#define S32K3XX_PROGMEM_BLOCK_SIZE CONFIG_S32K3XX_PROGMEM_SIZE * 1024
|
||||
|
||||
#define S32K3XX_PROGMEM_BLOCK_SECTOR_SIZE 8192
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user