Files
kunlun/driver/inc/smc.h
2024-09-28 14:24:04 +08:00

98 lines
3.2 KiB
C

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef __QSPI_H
#define __QSPI_H
#ifdef __cplusplus
extern "C" {
#endif
#define HAL_QPSI_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000U)/* 5 s */
#define SFC_WIP_IS_BUSY_BIT (1<<0)
/**
* @brief QSPI Status structures definition
*/
typedef enum
{
SMC_QSPI_OK = 0x00U,
SMC_QSPI_ERROR = 0x01U,
SMC_QSPI_BUSY = 0x02U,
SMC_QSPI_TIMEOUT = 0x03U,
SMC_QSPI_NOT_SUPPORTED = 0x04U
} smc_sts_type_t;
typedef enum
{
MOD_SMC_OP_REV0 = 0x00U,
MOD_SMC_OP_ERV1 = 0x01U,
MOD_SMC_OP_TRANS = 0x02U,
MOD_SMC_OP_REG_WR = 0x03U
} smc_operation_mode_t;
typedef enum
{
MOD_SMC_READ_SIG = 0x00U,
MOD_SMC_READ_FAST = 0x01U,
MOD_SMC_READ_QUAD = 0x02U
} smc_read_mode_t;
typedef enum
{
SMC_REG_ACCESS = 0x00U,
SMC_BUF_ACCESS = 0x01U
} smc_access_type_t;
/**
* @brief QSPI Command structure definition
*/
typedef struct
{
uint8_t smc_dlen; /* spi trans data length, unit is byte */
uint8_t smc_cmode; /* Operation Mode */
smc_operation_mode_t smc_mode; /* spi continus mode byte */
bool_t emc_crypt_mode; /* emc data cryption mode, 0- bypass mode, 1- cryption mode */
smc_read_mode_t cache_rd_mode; /* read mode */
bool_t qpi_mode; /* qpi mode en */
uint8_t cmd; /* Specifies the Instruction to be sent */
uint32_t addr; /* Specifies the Address to be sent */
uint32_t pe_wait_time; /* program or erase wait time, unit is clock cycle num */
uint32_t smc_rd_sts; /* status */
uint32_t smc_wr_sts; /* status */
} smc_op_t;
bool_t is_smc_cmd_busy();
smc_sts_type_t hal_smc_qspi_start();
smc_sts_type_t hal_smc_qspi_quad_cfg(uint8_t clk);
smc_sts_type_t hal_smc_spi_cfg(uint8_t clk);
smc_sts_type_t hal_smc_qspi_rst_en();
smc_sts_type_t hal_smc_qspi_rst();
smc_sts_type_t hal_smc_qspi_command(smc_op_t *cmd, uint32_t timeout);
smc_sts_type_t hal_smc_qspi_receive(uint8_t *data, uint32_t len, uint8_t is_buf, uint32_t timeout);
smc_sts_type_t hal_smc_qspi_transmit(uint8_t *data, uint32_t len, uint8_t is_buf, uint32_t timeout);
smc_sts_type_t hal_smc_disable();
void hal_smc_clk_div_set(uint8_t div);
void hal_smc_clk_out(int enable);
#ifdef __cplusplus
}
#endif
#endif