Skip to content

Commit 50d36f4

Browse files
committed
hal: renesas: Add Flash support for RZ/A series
Add SPIBSC FSP HAL driver to support Zephyr Flash driver for RZ/A3UL Signed-off-by: Tien Nguyen <[email protected]>
1 parent 6b33e3d commit 50d36f4

File tree

4 files changed

+2603
-0
lines changed

4 files changed

+2603
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*
2+
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
/*******************************************************************************************************************//**
8+
* @addtogroup SPIBSC
9+
* @{
10+
**********************************************************************************************************************/
11+
12+
#ifndef R_SPIBSC_H
13+
#define R_SPIBSC_H
14+
15+
/***********************************************************************************************************************
16+
* Includes
17+
**********************************************************************************************************************/
18+
#include "bsp_api.h"
19+
#include "r_spibsc_cfg.h"
20+
#include "r_spi_flash_api.h"
21+
22+
/* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */
23+
FSP_HEADER
24+
25+
/***********************************************************************************************************************
26+
* Typedef definitions
27+
**********************************************************************************************************************/
28+
29+
/* Delay settings. */
30+
typedef struct st_spibsc_delay
31+
{
32+
uint8_t slch : 3; ///< SLCH (Select to Clock Delay) cycles
33+
uint8_t clsh : 3; ///< CLSH (Clock Low to Deselect Delay) cycles
34+
uint8_t shsl : 3; ///< SHSL (Deselect to Select Delay) cycles
35+
} spibsc_delay_t;
36+
37+
/* Extended configuration. */
38+
typedef struct st_spibsc_extended_cfg
39+
{
40+
spibsc_delay_t delay; ///< Delay setting
41+
uint8_t io_fix_mask; ///< Enable to fixture IOn signal level during idle state (bit mapped)
42+
uint8_t io_fix_value; ///< Value to fixture IOn signal level during idle state (bit mapped)
43+
} spibsc_extended_cfg_t;
44+
45+
/** Instance control block. DO NOT INITIALIZE. Initialization occurs when @ref spi_flash_api_t::open is called */
46+
typedef struct st_spibsc_instance_ctrl
47+
{
48+
spi_flash_cfg_t cfg; // Copy of configuration
49+
spibsc_extended_cfg_t ext; // Copy of extended configuration
50+
spi_flash_erase_command_t * p_erase_command_list; // Copy of erase command list (dynamically allocated)
51+
uint32_t open; // Whether or not driver is open
52+
bool is_xip_enabled; // The driver enables XIP (omitting cmd) mode
53+
R_SPIBSC_Type * p_reg; // Controller register base address
54+
} spibsc_instance_ctrl_t;
55+
56+
/**********************************************************************************************************************
57+
* Exported global variables
58+
**********************************************************************************************************************/
59+
60+
/** @cond INC_HEADER_DEFS_SEC */
61+
/** Filled in Interface API structure for this Instance. */
62+
extern const spi_flash_api_t g_spi_flash_on_spibsc;
63+
64+
/** @endcond */
65+
66+
fsp_err_t R_SPIBSC_Open(spi_flash_ctrl_t * p_api_ctrl, spi_flash_cfg_t const * const p_cfg) BSP_PLACE_IN_SECTION(
67+
SPIBSC_CFG_CODE_SECTION);
68+
fsp_err_t R_SPIBSC_Close(spi_flash_ctrl_t * p_api_ctrl) BSP_PLACE_IN_SECTION(SPIBSC_CFG_CODE_SECTION);
69+
fsp_err_t R_SPIBSC_DirectWrite(spi_flash_ctrl_t * p_api_ctrl,
70+
uint8_t const * const p_src,
71+
uint32_t const bytes,
72+
bool const read_after_write) BSP_PLACE_IN_SECTION(SPIBSC_CFG_CODE_SECTION);
73+
fsp_err_t R_SPIBSC_DirectRead(spi_flash_ctrl_t * p_api_ctrl, uint8_t * const p_dest,
74+
uint32_t const bytes) BSP_PLACE_IN_SECTION(SPIBSC_CFG_CODE_SECTION);
75+
fsp_err_t R_SPIBSC_SpiProtocolSet(spi_flash_ctrl_t * p_api_ctrl,
76+
spi_flash_protocol_t spi_protocol) BSP_PLACE_IN_SECTION(SPIBSC_CFG_CODE_SECTION);
77+
fsp_err_t R_SPIBSC_XipEnter(spi_flash_ctrl_t * p_api_ctrl) BSP_PLACE_IN_SECTION(SPIBSC_CFG_CODE_SECTION);
78+
fsp_err_t R_SPIBSC_XipExit(spi_flash_ctrl_t * p_api_ctrl) BSP_PLACE_IN_SECTION(SPIBSC_CFG_CODE_SECTION);
79+
fsp_err_t R_SPIBSC_Write(spi_flash_ctrl_t * p_api_ctrl,
80+
uint8_t const * const p_src,
81+
uint8_t * const p_dest,
82+
uint32_t byte_count) BSP_PLACE_IN_SECTION(SPIBSC_CFG_CODE_SECTION);
83+
fsp_err_t R_SPIBSC_Erase(spi_flash_ctrl_t * p_api_ctrl, uint8_t * const p_device_address,
84+
uint32_t byte_count) BSP_PLACE_IN_SECTION(SPIBSC_CFG_CODE_SECTION);
85+
fsp_err_t R_SPIBSC_StatusGet(spi_flash_ctrl_t * p_api_ctrl, spi_flash_status_t * const p_status) BSP_PLACE_IN_SECTION(
86+
SPIBSC_CFG_CODE_SECTION);
87+
fsp_err_t R_SPIBSC_BankSet(spi_flash_ctrl_t * p_api_ctrl, uint32_t bank) BSP_PLACE_IN_SECTION(SPIBSC_CFG_CODE_SECTION);
88+
fsp_err_t R_SPIBSC_DirectTransfer(spi_flash_ctrl_t * p_api_ctrl,
89+
spi_flash_direct_transfer_t * const p_transfer,
90+
spi_flash_direct_transfer_dir_t direction) BSP_PLACE_IN_SECTION(
91+
SPIBSC_CFG_CODE_SECTION);
92+
fsp_err_t R_SPIBSC_AutoCalibrate(spi_flash_ctrl_t * p_api_ctrl);
93+
94+
/* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */
95+
FSP_FOOTER
96+
97+
#endif
98+
99+
/*******************************************************************************************************************//**
100+
* @} (end defgroup SPIBSC)
101+
**********************************************************************************************************************/

0 commit comments

Comments
 (0)