Initial import of NFC GNSS SDK project
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
#ifndef _EFUSE_H
|
||||
#define _EFUSE_H
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* define fuse value for psram devie
|
||||
* PSRAM Type Code:
|
||||
* AP 16M 00000
|
||||
* Winbond 16M 00001
|
||||
* AP 8M + 8M 00010
|
||||
* Winbond 8M + 8M 00100
|
||||
* AP 8M 00101
|
||||
* Winbond 8M 00110
|
||||
* Winbond 250MHz 8M 00111
|
||||
* AP UHS 8M + UHS 8M 01000
|
||||
* Winbond 250MHz 8M + 250MHz 8M 01001
|
||||
*/
|
||||
#define AP_16M 0
|
||||
#define WB_16M 1
|
||||
#define AP_8M8M 2
|
||||
#define UNIIC_16M 3
|
||||
#define WB_8M8M 4
|
||||
#define AP_8M 5
|
||||
#define WB_8M 6
|
||||
#define WB_250MHZ_8M 7
|
||||
#define AP_UHS_8M8M 8
|
||||
#define WB_250MHZ_8M8M 9
|
||||
#define AP_250MHZ_8M8M 10
|
||||
#define WB_XCCELA_8M 11
|
||||
#define WB_XCCELA_8M8M 12
|
||||
#define WB_4M 13
|
||||
#define AP_4M 14
|
||||
#define WB_XCCELA_4M 15
|
||||
#define AP_250MHZ_8M 16
|
||||
#define WB_32M 17
|
||||
#define AP_250MHZ_16M 18
|
||||
#define WB_250MHZ_16M 19
|
||||
#define UNIIC_4M 20
|
||||
#define GD_4M 21
|
||||
#define GD_8M 22
|
||||
#define WB_8M_HYPER21 23
|
||||
#define WB_8M8M_HYPER21 24
|
||||
|
||||
typedef enum {
|
||||
NO_PHY_AP_4M, /* 0 */
|
||||
NO_PHY_WB_4M, /* 1 */
|
||||
NO_PHY_AP_8M, /* 2 */
|
||||
NO_PHY_WB_8M, /* 3 */
|
||||
NO_PHY_AP_16M, /* 4 */
|
||||
NO_PHY_WB_16M, /* 5 */
|
||||
NO_PHY_UNIIC_16M, /* 6 */
|
||||
NO_PHY_UNIIC_4M, /* 7 */
|
||||
NO_PHY_PSRAM_TYPE_MAX /* 8 */
|
||||
} NO_PHY_PSRAM_TYPE_T;
|
||||
|
||||
#define AP_16M_NAME "AP_16M" /* 0 */
|
||||
#define WB_16M_NAME "WB_16M" /* 1 */
|
||||
#define AP_8M8M_NAME "AP_8M8M" /* 2 */
|
||||
#define UNIIC_16M_NAME "UNIIC_16M" /* 3 */
|
||||
#define WB_8M8M_NAME "WB_8M8M" /* 4 */
|
||||
#define AP_8MB_NAME "AP_8M" /* 5 */
|
||||
#define WB_8MB_NAME "WB_8M" /* 6 */
|
||||
#define WB_250MHZ_8M_NAME "WB_250MHZ_8M" /* 7 */
|
||||
#define AP_UHS_8M8M_NAME "AP_UHS_8M8M" /* 8 */
|
||||
#define WB_250MHZ_8M8M_NAME "WB_250MHZ_8M8M" /* 9 */
|
||||
#define AP_250MHZ_8M8M_NAME "AP_250MHZ_8M8M" /* 10 */
|
||||
#define WB_XCCELA_8M_NAME "WB_XCCELA_8M" /* 11 */
|
||||
#define WB_XCCELA_8M8M_NAME "WB_XCCELA_8M8M" /* 12 */
|
||||
#define WB_4MB_NAME "WB_4M" /* 13 */
|
||||
#define AP_4MB_NAME "AP_4M" /* 14 */
|
||||
#define WB_XCCELA_4M_NAME "WB_XCCELA_4M" /* 15 */
|
||||
#define AP_250MHZ_8M_NAME "AP_250MHZ_8M" /* 16 */
|
||||
#define WB_32M_NAME "WB_32M" /* 17 */
|
||||
#define AP_250MHZ_16M_NAME "AP_250MHZ_16M" /* 18 */
|
||||
#define WB_250MHZ_16M_NAME "WB_250MHZ_16M" /* 19 */
|
||||
#define UNIIC_4M_NAME "UNIIC_4M" /* 20 */
|
||||
#define GD_4M_NAME "GD_4M" /* 21 */
|
||||
#define GD_8M_NAME "GD_8M" /* 22 */
|
||||
/* 3660 CR5 boot by mcu, not in preboot, preboot only read psram type for scrtach reg, and set prop */
|
||||
#define WB_8M_HYPER21_NAME "WB_8M_HYPER21" /* 23 */
|
||||
#define WB_8M8M_HYPER21_NAME "WB_8M8M_HYPER21" /* 24 */
|
||||
|
||||
/* psram_crane_mcu.h defined psram type id instead of efuse.h */
|
||||
#define AP256Mb_1_2V_X16_CS0_NAME "AP256Mb_1_2V_X16_CS0" /* 0 */
|
||||
#define AP256Mb_1_2V_X16_CS1_NAME "AP256Mb_1_2V_X16_CS1" /* 1 */
|
||||
#define AP256Mb_1_2V_X16_CS0_CS1_NAME "AP256Mb_1_2V_X16_CS0_CS1" /* 2 */
|
||||
#define WB256Mb_1_8V_X16_CS0_NAME "WB256Mb_1_8V_X16_CS0" /* 3 */
|
||||
#define WB256Mb_1_8V_X16_CS1_NAME "WB256Mb_1_8V_X16_CS1" /* 4 */
|
||||
#define WB256Mb_1_8V_X16_CS0_CS1_NAME "WB256Mb_1_8V_X16_CS0_CS1" /* 5 */
|
||||
|
||||
|
||||
#define PSRAM_SIZE_4M 0x400000
|
||||
#define PSRAM_SIZE_8M 0x800000
|
||||
#define PSRAM_SIZE_16M 0x1000000
|
||||
#define PSRAM_SIZE_32M 0x2000000
|
||||
|
||||
/* software defined ddr type, can diff with fuse value for ddr device:
|
||||
* DDR Type Code:
|
||||
* CraneGT use DDR, connect flash instead of SIP
|
||||
* 3605S: DDR 32MB + Nor flash 16MB
|
||||
* 3605E: DDR 64MB + Nand flash 64MB
|
||||
*/
|
||||
typedef enum {
|
||||
DRAM_AP_32M, /* 0 / * 3605S-111 * / */
|
||||
DRAM_UniIC_32M, /* 1 / * 3605S-110 * / */
|
||||
DRAM_AP_64M, /* 2 / * 3605E-110 * / */
|
||||
DSRAM_TYPE_MAX /* 3 */
|
||||
} DRAM_TYPE_T;
|
||||
|
||||
#define DRAM_AP_32M_NAME "DRAM_AP_32M" /*Bytes */
|
||||
#define DRAM_AP_64M_NAME "DRAM_AP_64M"
|
||||
#define DRAM_UniIC_32M_NAME "DRAM_UniIC_32M"
|
||||
#define DRAM_UniIC_64M_NAME "DRAM_UniIC_64M"
|
||||
|
||||
|
||||
/* reversed fuse ddr bits, but not use fuse now, use autodetect */
|
||||
#define DRAM_SIZE_32M 0x2000000
|
||||
#define DRAM_SIZE_64M 0x4000000
|
||||
#define DRAM_SIZE_128M 0x8000000
|
||||
|
||||
unsigned int efuse_get_psram_version(void);
|
||||
unsigned efuse_cranew_mcu_psram(void);
|
||||
unsigned int get_psram_size(void);
|
||||
unsigned int get_ddr_size(void);
|
||||
void fuse_read_lotid(void);
|
||||
int fuse_trust_boot_enabled(void);
|
||||
bool is_chip_support_auto_detect(void);
|
||||
bool efuse_modem_type_is_radio(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _EFUSE_H */
|
||||
/** @} */
|
||||
@@ -0,0 +1,278 @@
|
||||
#ifndef __FLASH_H__
|
||||
#define __FLASH_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <pt.h>
|
||||
#include <process.h>
|
||||
|
||||
#ifndef FLASH_VERIFY_EN
|
||||
#define FLASH_VERIFY_EN (1) /* defaultly need verify flash written data */
|
||||
#endif
|
||||
|
||||
#ifndef FLASH_CHECK_FF_EN
|
||||
#define FLASH_CHECK_FF_EN (1) /* defaultly need read flash and check whether are erased, all 0xFF */
|
||||
#endif
|
||||
|
||||
#define FLASH_INFO_MAGIC 0x46494E46
|
||||
#define MAX_FLASH_DEVICE_NAME 64
|
||||
#define MAX_FLASH_DEVICE_TYPE 32
|
||||
|
||||
#define FLASH_TYPE_QSPI_NAND "QSPI_NAND"
|
||||
/* the first QSPI flash, crane is extern QSPI flash, craneM/craneG is internal QSPI flash.*/
|
||||
#define FLASH_TYPE_QSPI_NOR "QSPI_NOR"
|
||||
#define FLASH_TYPE_SPI_NOR "SPI_NOR"
|
||||
#define FLASH_TYPE_SPI_NAND "SPI_NAND"
|
||||
#define FLASH_TYPE_EMMC "EMMC"
|
||||
#define FLASH_TYPE_MEM "MEM"
|
||||
#define FLASH_TYPE_DUMMY "DUMMY"
|
||||
#define FLASH_TYPE_QSPI2_NOR "QSPI2_NOR"
|
||||
|
||||
#define FLASH_ERR_OTHERS (-1)
|
||||
#define FLASH_ERR_BAD_BLOCK (-2)
|
||||
#define FLASH_ERR_BAD_PARAMETER (-3)
|
||||
#define FLASH_ERR_ECC_ERR (-4)
|
||||
#define FLASH_ERR_PROGRAM_ERR (-5)
|
||||
#define FLASH_ERR_ERASE_ERR (-6)
|
||||
|
||||
#define SPI_PORT_QSPI 0
|
||||
#define SPI_PORT_QSPI0 0
|
||||
#define SPI_PORT_SSP0 1
|
||||
#define SPI_PORT_SSP1 2
|
||||
#define SPI_PORT_SSP2 3
|
||||
#define SPI_PORT_QSPI2 4
|
||||
#define SPI_PORT_EMMC 5
|
||||
#define SPI_PORT_MEM 6
|
||||
#define SPI_PORT_QSPI1 7
|
||||
|
||||
/* SSP_<CLK>_<FRM>_<RXD>_<TXD> */
|
||||
typedef enum {
|
||||
SSP_GPIO_CONFIG_DEFAULT,
|
||||
SSP_GPIO4_FUNC2_GPIO5_FUNC2_GPIO6_FUNC2_GPIO7_FUNC2,
|
||||
SSP_GPIO4_FUNC7_GPIO5_FUNC7_GPIO6_FUNC7_GPIO7_FUNC7,
|
||||
SSP_GPIO12_FUNC1_GPIO13_FUNC1_GPIO14_FUNC1_GPIO15_FUNC1,
|
||||
SSP_GPIO16_FUNC2_GPIO17_FUNC2_GPIO19_FUNC2_GPIO18_FUNC2,
|
||||
SSP_GPIO16_FUNC2_GPIO17_FUNC2_GPIO18_FUNC4_GPIO19_FUNC4,
|
||||
SSP_GPIO33_FUNC1_GPIO34_FUNC1_GPIO35_FUNC1_GPIO36_FUNC1,
|
||||
SSP_GPIO33_FUNC2_GPIO34_FUNC2_GPIO35_FUNC2_GPIO36_FUNC2,
|
||||
SSP_GPIO64_FUNC7_GPIO63_FUNC7_GPIO61_FUNC7_GPIO62_FUNC7,
|
||||
SSP_GPIO71_FUNC2_GPIO72_FUNC2_GPIO73_FUNC2_GPIO74_FUNC2,
|
||||
SSP_QSPI_CLK_FUNC2_QSPI_CS1_FUNC2_QSPI_DAT1_FUNC2_QSPI_DAT0_FUNC2,
|
||||
SSP_QSPI_CLK_FUNC4_QSPI_CS1_FUNC4_QSPI_DAT1_FUNC4_QSPI_DAT0_FUNC4,
|
||||
SSP_GPIO4_FUNC2_GPIO55_FUNC0_GPIO6_FUNC2_GPIO7_FUNC2,
|
||||
} ssp_gpio_config_t;
|
||||
|
||||
struct compatible_device {
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
uint32_t reserved1;
|
||||
char device_name[MAX_FLASH_DEVICE_NAME];
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Flash information
|
||||
*/
|
||||
struct flash_info {
|
||||
uint32_t magic;
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
char device_name[MAX_FLASH_DEVICE_NAME];
|
||||
char device_type[MAX_FLASH_DEVICE_TYPE];
|
||||
/* the following two parameters are used by ubi */
|
||||
uint32_t min_io_size;
|
||||
uint32_t peb_size;
|
||||
/* the following three parameters are used by erase and program */
|
||||
uint32_t page_size;
|
||||
uint32_t sector_size;
|
||||
uint32_t block_size;
|
||||
uint8_t reserved1[3];
|
||||
uint8_t ssp_gpio : 6;
|
||||
uint8_t ssp_clk : 2;
|
||||
/* total flash size */
|
||||
uint64_t flash_size;
|
||||
uint8_t erased_value; /*/< Contents of erased memory (usually 0xFF) */
|
||||
uint8_t chained;
|
||||
uint8_t spi_port;
|
||||
uint8_t combined_flash_size_in_mb; /* combined flash size in MB */
|
||||
uint32_t compatible_device_num;
|
||||
struct compatible_device compatible_device_list[1];
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
SSP_CLK_52M,
|
||||
SSP_CLK_26M,
|
||||
SSP_CLK_13M,
|
||||
SSP_CLK_6500K,
|
||||
} ssp_clk_config_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t pnum;
|
||||
uint32_t offset;
|
||||
} ubi_addr_t;
|
||||
|
||||
typedef struct {
|
||||
const void *flash;
|
||||
size_t partition_size;
|
||||
} sparse_param_t;
|
||||
|
||||
typedef struct {
|
||||
/* Containers for the State */
|
||||
struct pt pt;
|
||||
|
||||
/* Input Variables */
|
||||
process_event_t ev;
|
||||
union {
|
||||
uint64_t addr;
|
||||
ubi_addr_t ubi_addr;
|
||||
sparse_param_t sparse_param;
|
||||
};
|
||||
const void *data;
|
||||
size_t size;
|
||||
size_t repeats;
|
||||
|
||||
/* Output Variables */
|
||||
int result; /**< Result Code */
|
||||
} flash_state_t;
|
||||
|
||||
/* support spi_nor_flash.c use qspi controller common interface, although spi did not use qspi controller */
|
||||
typedef int (*qspi_read_t)(unsigned seqid, unsigned addr, void *data, size_t size);
|
||||
typedef int (*qspi_write_t)(unsigned seqid, unsigned addr, const void *data, size_t size);
|
||||
typedef void (*qspi_cmd_t)(unsigned seqid, unsigned addr);
|
||||
|
||||
typedef struct {
|
||||
qspi_read_t qspi_read;
|
||||
qspi_write_t qspi_write;
|
||||
qspi_cmd_t qspi_cmd;
|
||||
} qpsi_lut_operation_t;
|
||||
|
||||
typedef int (*flash_read_t)(uint64_t addr, void *data, size_t size);
|
||||
typedef char (*flash_write_t)(flash_state_t *state);
|
||||
typedef char (*flash_erase_t)(flash_state_t *state);
|
||||
typedef const struct flash_info *(*flash_get_info_t)(void);
|
||||
typedef int (*flash_erase_sync_t)(uint64_t addr, size_t size);
|
||||
typedef int (*flash_write_sync_t)(uint64_t addr, const void *data, size_t size);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef void (*flash_quad_enable_cb_t)(const qpsi_lut_operation_t *lut_op, bool enable);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
struct flash_operation {
|
||||
flash_read_t read;
|
||||
flash_write_t write;
|
||||
flash_erase_t erase;
|
||||
flash_write_sync_t write_sync;
|
||||
flash_erase_sync_t erase_sync;
|
||||
flash_get_info_t info;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
FLASH_ID_FIRST, /* first flash */
|
||||
FLASH_ID_SECOND, /* second flash */
|
||||
FLASH_ID_THIRD, /* third flash */
|
||||
FLASH_ID_MAX
|
||||
} flash_id_t;
|
||||
|
||||
/* start a protothread to do thread_fun(uint64_t address, const void *buf, size_t sz).
|
||||
* state: supply parent pt for thread_fun.
|
||||
* child_state: pt for thread_fun.(if multi pt threads, child_state may be custom defined)
|
||||
* state->result: return result of thread_fun.
|
||||
*
|
||||
* eg: if thread_fun is partition_raw_flash(uint64_t address, const void *buf, size_t sz),
|
||||
* invoke FLASH_BASE_TASK(state, partition_raw_flash_state, partition_raw_flash, address, buf, sz);
|
||||
*/
|
||||
#define FLASH_BASE_TASK(state, child_state, thread_fun, address, buf, sz, repts) \
|
||||
{ \
|
||||
static flash_state_t child_state; \
|
||||
memset(&child_state, 0, sizeof(child_state)); \
|
||||
child_state.ev = state->ev; \
|
||||
child_state.addr = address; \
|
||||
child_state.data = buf; \
|
||||
child_state.size = sz; \
|
||||
child_state.repeats = repts; \
|
||||
PT_SPAWN(&state->pt, &(child_state.pt), thread_fun(&child_state)); \
|
||||
state->result = child_state.result; \
|
||||
}
|
||||
|
||||
#define INPUT_VOID_TASK(state, child_state, thread_fun) \
|
||||
FLASH_BASE_TASK(state, child_state, thread_fun, 0, NULL, 0, 0)
|
||||
|
||||
/* start a protothread to do thread_fun(void).
|
||||
* state: supply parent pt for thread_fun(void).
|
||||
* state->result: return result of thread_fun(void).
|
||||
*
|
||||
* eg: if thread_fun(void) is wait_for_complete_task(void),
|
||||
* invoke WAIT_TASK(state, wait_for_complete_task);
|
||||
*/
|
||||
#define WAIT_TASK(state, thread_fun) \
|
||||
FLASH_BASE_TASK(state, wait_state, thread_fun, 0, NULL, 0, 0)
|
||||
|
||||
/* start a protothread to do thread_fun(uint64_t address, size_t sz).
|
||||
* state: supply parent pt for thread_fun.
|
||||
* state->result: return result of thread_fun.
|
||||
*
|
||||
* eg: if thread_fun is flash->erase(uint64_t address, size_t sz),
|
||||
* invoke FLASH_ERASE_TASK(state, flash->erase, address, sz);
|
||||
*/
|
||||
#define FLASH_ERASE_TASK(state, thread_fun, address, sz) \
|
||||
FLASH_BASE_TASK(state, erase_state, thread_fun, address, NULL, sz, 0)
|
||||
|
||||
/* start a protothread to do thread_fun(uint64_t address, const void *buf, size_t sz, size_t repeats).
|
||||
* state: supply parent pt for thread_fun.
|
||||
* state->result: return result of thread_fun.
|
||||
*
|
||||
* eg: if thread_fun is flash->write(uint64_t address, const void *buf, size_t sz, size_t repeats),
|
||||
* invoke FLASH_WRITE_TASK(state, flash->write, address, buf, sz, repeats);
|
||||
*/
|
||||
#define FLASH_WRITE_TASK(state, thread_fun, address, buf, sz, repeats) \
|
||||
FLASH_BASE_TASK(state, write_state, thread_fun, address, buf, sz, repeats)
|
||||
|
||||
int flash_info_init(const void *data, size_t size);
|
||||
int flash_force_all_probe(void);
|
||||
const struct flash_operation *flash_set_operation(flash_id_t flash_id);
|
||||
const struct flash_operation *flash_get_operation(void);
|
||||
const struct flash_operation *flash_get_operation_with_id(flash_id_t flash_id);
|
||||
int flash_verify(uint64_t addr, const void *data, size_t size);
|
||||
|
||||
bool flash_is_chip_erased(flash_id_t id);
|
||||
void flash_set_chip_erased(flash_id_t id);
|
||||
void flash_reset_chip_erased(void);
|
||||
flash_id_t flash_get_current_flash_id(void);
|
||||
|
||||
/* read current flash from any address */
|
||||
int flash_read_unaligned(uint64_t addr, void *data, size_t size);
|
||||
|
||||
uint8_t *flash_get_tmp_buffer(size_t sz);
|
||||
|
||||
#define FLASH_IS_ALL_FF_TASK(state, address, sz) \
|
||||
FLASH_BASE_TASK(state, flash_is_all_ff_state, flash_is_all_ff, address, NULL, sz, 0)
|
||||
|
||||
PT_THREAD(flash_is_all_ff(flash_state_t * state));
|
||||
|
||||
#define FLASH_VERIFY_TASK(state, address, data, sz) \
|
||||
FLASH_BASE_TASK(state, flash_verify_state, flash_verify_pt, address, data, sz, 0)
|
||||
|
||||
PT_THREAD(flash_verify_pt(flash_state_t * state));
|
||||
|
||||
#ifdef USE_QSPI_NOR_FLASH
|
||||
extern bool flash_with_qspi2_nor;
|
||||
int flash_nor_write_by_page(uint64_t address, const void *data, size_t size);
|
||||
int flash_nor_erase_by_sector(uint64_t address, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef USE_QSPI_NAND_FLASH
|
||||
int flash_nand_write_by_page(uint64_t address, const void *data, size_t size);
|
||||
int flash_nand_erase_by_sector(uint64_t address, size_t size);
|
||||
#endif
|
||||
|
||||
void flash_get_info_base(uintptr_t *base, size_t *size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* __FLASH_H__ */
|
||||
@@ -0,0 +1,68 @@
|
||||
#ifndef PERIPH_PSRAM_H
|
||||
#define PERIPH_PSRAM_H
|
||||
#include "syscall-arom.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* craneg not support clk mode, but bit8 reserved */
|
||||
typedef enum {
|
||||
CLK_MODE_1X = 0, /* 1x mode */
|
||||
CLK_MODE_2X, /* 2x mode */
|
||||
CLK_MODE_MAX
|
||||
} clk_mode_t;
|
||||
|
||||
/*
|
||||
* PHYCLK clk select , bit20~18
|
||||
* craneg: phy clk = phy_sel/(phy_clk_divider+1), eg: phy clk = phy_sel/2 = 156/2=78M
|
||||
* craneLR A0/cranew cr5: phy clk = phy_sel/(phy_clk_divider+1)/clk_mode. clk_mode=1(1xmode), clk_mode=2(2xmode),
|
||||
* psram two edge samples, so Mbps = MHz *2;
|
||||
* If mcu is 208MHz, means it is 416Mbps(PSRAM_FREQ_416M).
|
||||
* PSRAM_FREQ_156Mbps: phy clk 78MHz
|
||||
*/
|
||||
struct PsramPP_t {
|
||||
unsigned freq;
|
||||
unsigned clkSel; /*clock selection ( pc clk select: bit28~26, phy clk select: bit20~18,) */
|
||||
unsigned clkDiv; /*phy clk divider (bit17~16) */
|
||||
clk_mode_t clkMode; /*0: 1x mode; 1: 2xmode, add after craneLR, include cranew cr5 */
|
||||
};
|
||||
|
||||
#define PSRAM_FREQ_156M 0 /*LV0: 78M 156Mps*/
|
||||
#define PSRAM_FREQ_312M 1 /*LV1: 156M 312Mps*/
|
||||
#define PSRAM_FREQ_350M 2 /*LV2: 175M 350Mbps, craneLR: 356Mbps */
|
||||
#define PSRAM_FREQ_416M 3 /*LV3: 208M 416Mps*/
|
||||
#define PSRAM_FREQ_500M 4 /*LV4: 250M 500Mps*/
|
||||
|
||||
#if 0
|
||||
//test lower freq can use it
|
||||
#define PSRAM_FREQ_LV4 4 /*LV4: */
|
||||
#define PSRAM_FREQ_LV5 5 /*LV5: */
|
||||
#endif
|
||||
/*
|
||||
* preboot will not use psram LV4 PSRAM_FREQ_533M, cp use LV4.
|
||||
* phy clk 533M ~2000M need enable PLL2, see Asic code: psram_fc_init -> phy_pll2_fc
|
||||
*/
|
||||
/*PCCLK clk select , bit28~26 */
|
||||
#define PSRAM_PCCLK_PLL1_312M 0
|
||||
#define PSRAM_PCCLK_PLL1_350M 1
|
||||
#define PSRAM_PCCLK_PLL1_416M 2
|
||||
#define PSRAM_PCCLK_PLL1_208M 4
|
||||
#define PSRAM_PCCLK_PLL1_156M 5
|
||||
|
||||
#define PSRAM_CACHELINE_64B 0
|
||||
#define PSRAM_CACHELINE_128B 1
|
||||
#define PSRAM_CACHELINE_256B 2
|
||||
#define PSRAM_CACHELINE_512B 3
|
||||
|
||||
void psram_init(void);
|
||||
void psram_pll1_enable(void);
|
||||
void psram_test(void);
|
||||
void psram_phy_fc_config(unsigned phyclk_level);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PERIPH_PSRAM_H */
|
||||
/** @} */
|
||||
@@ -0,0 +1,111 @@
|
||||
#ifndef PSRAM_MEM_VERIFY_H
|
||||
#define PSRAM_MEM_VERIFY_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "pt.h"
|
||||
#include "process.h"
|
||||
#include "contiki.h"
|
||||
#include "flash.h"
|
||||
|
||||
#define PSRAM_MEM_TEST_ALL 0
|
||||
|
||||
/*
|
||||
* crane_flasehr and psram.c will use it
|
||||
* If scan psram memory to test psram, enable it
|
||||
*/
|
||||
/*#define PSRAM_MEM_TEST_ALL 1 */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef unsigned long ul;
|
||||
typedef unsigned long long ull;
|
||||
typedef unsigned long volatile ulv;
|
||||
typedef unsigned char volatile u8v;
|
||||
typedef unsigned short volatile u16v;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
/* Containers for the State */
|
||||
struct pt pt;
|
||||
/* Input Variables */
|
||||
process_event_t ev;
|
||||
union {
|
||||
unsigned long volatile *bufa;
|
||||
unsigned long start;
|
||||
};
|
||||
union {
|
||||
unsigned long volatile *bufb;
|
||||
unsigned long end;
|
||||
};
|
||||
union {
|
||||
size_t count;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
unsigned int id;
|
||||
/* Output Variables */
|
||||
int result; /**< Result Code */
|
||||
} pmem_state_t;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* start a protothread to do thread_fun(uint64_t address, const void *buf, size_t sz).
|
||||
* state: supply parent pt for thread_fun.
|
||||
* child_state: pt for thread_fun.(if multi pt threads, child_state may be custom defined)
|
||||
* state->result: return result of thread_fun.
|
||||
*
|
||||
* eg: if thread_fun is test_xor_comparison(unsigned long volatile *bufa, unsigned long volatile *bufb, size_t count),
|
||||
* invoke PMEM_BASE_TASK(state, test_xor_comparison_state, test_xor_comparison, bufa, bufb, count);
|
||||
*/
|
||||
#define PMEM_BASE_TASK(state, child_state, thread_fun, buf_a, buf_b, sz, case_id) \
|
||||
{ \
|
||||
static pmem_state_t child_state; \
|
||||
memset(&child_state, 0, sizeof(child_state)); \
|
||||
child_state.ev = state->ev; \
|
||||
child_state.bufa = buf_a; \
|
||||
child_state.bufb = buf_b; \
|
||||
child_state.count = sz; \
|
||||
child_state.id = case_id; \
|
||||
PT_SPAWN(&state->pt, &(child_state.pt), thread_fun(&child_state)); \
|
||||
state->result = child_state.result; \
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define ADD_FAIL_NUM(state) \
|
||||
{ \
|
||||
if(!state->result) { \
|
||||
LOG_INFO(" ok\n"); \
|
||||
} else { \
|
||||
LOG_INFO(" fail\n"); \
|
||||
pmem_fail_num++; \
|
||||
} \
|
||||
LOG_INFO("\n\r"); \
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
typedef enum {
|
||||
PMEM_ID_TEST_RANDOM, /*0*/
|
||||
PMEM_ID_TEST_XOR, /*1*/
|
||||
PMEM_ID_TEST_SUB, /*2*/
|
||||
PMEM_ID_TEST_MUL, /*3*/
|
||||
PMEM_ID_TEST_DIV, /*4*/
|
||||
PMEM_ID_TEST_OR, /*5*/
|
||||
PMEM_ID_TEST_AND, /*6*/
|
||||
PMEM_ID_TEST_SEQINC, /*7*/
|
||||
PMEM_ID_TEST_SOLIDBITS, /*8*/
|
||||
PMEM_ID_TEST_BLOCKSEQ, /*9*/
|
||||
PMEM_ID_TEST_CHECHERBORD, /*10*/
|
||||
PMEM_ID_TEST_BITSPREAD, /*11*/
|
||||
PMEM_ID_TEST_BITFLIP, /*12*/
|
||||
PMEM_ID_TEST_WALKBITS1, /*13*/
|
||||
PMEM_ID_TEST_WALKBITS0, /*14*/
|
||||
PMEM_ID_TEST_8BIT_WIDE_RANDOM, /*15*/
|
||||
PMEM_ID_TEST_16BIT_WIDE_RANDOM, /*16*/
|
||||
PMEM_ID_TEST_DDR_PATTERN_ALL_0, /*17*/
|
||||
PMEM_ID_TEST_DDR_PATTERN_ALL_1, /*18*/
|
||||
PMEM_ID_TEST_DDR_PATTERN_SPLIT_1, /*19*/
|
||||
|
||||
PMEM_ID_MAX
|
||||
} pmem_id_t;
|
||||
|
||||
PT_THREAD(psram_mem_test_all(pmem_state_t * state));
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef __USB_SERIAL_H__
|
||||
#define __USB_SERIAL_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool usb_enumeration_is_complete(void);
|
||||
|
||||
#endif /* __USB_SERIAL_H__ */
|
||||
Reference in New Issue
Block a user