Line data Source code
1 1 : /*
2 : * Copyright (c) 2023 Nuvoton Technology Corporation.
3 : *
4 : * SPDX-License-Identifier: Apache-2.0
5 : */
6 :
7 : /**
8 : * @file
9 : * @brief Header file for NPCX flash extended operations.
10 : * @ingroup npcx_flash_ex_op
11 : */
12 :
13 : #ifndef __ZEPHYR_INCLUDE_DRIVERS_NPCX_FLASH_API_EX_H__
14 : #define __ZEPHYR_INCLUDE_DRIVERS_NPCX_FLASH_API_EX_H__
15 :
16 : /**
17 : * @brief Extended operations for NPCX flash controllers.
18 : * @defgroup npcx_flash_ex_op NPCX
19 : * @ingroup flash_ex_op
20 : * @{
21 : */
22 :
23 : #ifdef __cplusplus
24 : extern "C" {
25 : #endif
26 :
27 : #include <zephyr/drivers/flash.h>
28 :
29 : /**
30 : * @brief Enumeration for NPCX flash extended operations.
31 : */
32 0 : enum flash_npcx_ex_ops {
33 : /**
34 : * User Mode Access (UMA) mode execution.
35 : *
36 : * Execute a SPI transaction via User Mode Access (UMA) mode. Users can
37 : * perform a customized SPI transaction to read or write the device's
38 : * configuration such as status registers of nor flash, power on/off,
39 : * and so on.
40 : *
41 : * @param in Pointer to a @ref npcx_ex_ops_uma_in structure specifying the
42 : * UMA transaction.
43 : * @param out Pointer to a @ref npcx_ex_ops_uma_out structure to store the
44 : * result of the UMA transaction.
45 : */
46 : FLASH_NPCX_EX_OP_EXEC_UMA = FLASH_EX_OP_VENDOR_BASE,
47 : /**
48 : * Configure specific operation for Quad-SPI nor flash.
49 : *
50 : * It configures specific operation for Quad-SPI nor flash such as lock
51 : * or unlock UMA mode, set write protection pin of internal flash, and
52 : * so on.
53 : *
54 : * @param in Pointer to a @ref npcx_ex_ops_qspi_oper_in structure specifying the
55 : * operation to set.
56 : */
57 : FLASH_NPCX_EX_OP_SET_QSPI_OPER,
58 : /**
59 : * Get specific operation for Quad-SPI nor flash.
60 : *
61 : * It returns current specific operation for Quad-SPI nor flash.
62 : *
63 : * @param out Pointer to a @ref npcx_ex_ops_qspi_oper_out structure to store the
64 : * result of the operation.
65 : */
66 : FLASH_NPCX_EX_OP_GET_QSPI_OPER,
67 : /*
68 : * NPCX General DMA (GDMA) mode execution.
69 : *
70 : * Execute transaction via GDMA module.
71 : */
72 : FLASH_NPCX_EX_OP_EXEC_GDMA,
73 : };
74 :
75 : /**
76 : * @brief Input parameters for @ref FLASH_NPCX_EX_OP_EXEC_UMA operation.
77 : *
78 : * Defines the content of a UMA transaction.
79 : */
80 1 : struct npcx_ex_ops_uma_in {
81 1 : uint8_t opcode; /**< SPI opcode (command byte). */
82 1 : uint8_t *tx_buf; /**< Pointer to transmit buffer (may be NULL). */
83 1 : size_t tx_count; /**< Number of bytes to transmit. */
84 1 : uint32_t addr; /**< Address for address phase. */
85 1 : size_t addr_count; /**< Number of address bytes (0–4). */
86 1 : size_t rx_count; /**< Number of bytes expected to be read. */
87 : };
88 :
89 : /**
90 : * @brief Output parameters for @ref FLASH_NPCX_EX_OP_EXEC_UMA operation.
91 : *
92 : * Defines where received data is stored.
93 : */
94 1 : struct npcx_ex_ops_uma_out {
95 1 : uint8_t *rx_buf; /**< Pointer to receive buffer (must be large enough). */
96 : };
97 :
98 : /**
99 : * @brief Input parameters for @ref FLASH_NPCX_EX_OP_SET_QSPI_OPER operation.
100 : *
101 : * Used to enable or disable specific NPCX Quad-SPI operations.
102 : */
103 1 : struct npcx_ex_ops_qspi_oper_in {
104 1 : bool enable; /**< True to enable, false to disable. */
105 1 : uint32_t mask; /**< Mask of operations to configure. */
106 : };
107 :
108 : /**
109 : * @brief Output parameters for @ref FLASH_NPCX_EX_OP_GET_QSPI_OPER operation.
110 : *
111 : * Used to report the current QSPI operation state.
112 : */
113 1 : struct npcx_ex_ops_qspi_oper_out {
114 1 : uint32_t oper; /**< Bitfield of currently active operations. */
115 : };
116 :
117 : /* Structures used by FLASH_NPCX_EX_OP_EXEC_GDMA */
118 0 : struct npcx_ex_ops_gdma_in {
119 0 : uint32_t src;
120 0 : uint32_t dst;
121 0 : uint16_t length;
122 : };
123 :
124 : /**
125 : * @name NPCX QSPI operation control bits
126 : * @{
127 : */
128 1 : #define NPCX_EX_OP_LOCK_UMA BIT(0) /**< Lock/Unlock UMA mode */
129 1 : #define NPCX_EX_OP_INT_FLASH_WP BIT(1) /**< Issue write protection of internal flash */
130 : /** @} */
131 :
132 : #ifdef __cplusplus
133 : }
134 : #endif
135 :
136 : /**
137 : * @}
138 : */
139 :
140 : #endif /* __ZEPHYR_INCLUDE_DRIVERS_NPCX_FLASH_API_EX_H__ */
|