coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
qup.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 
3 #ifndef __QUP_H__
4 #define __QUP_H__
5 
6 #include <soc/blsp.h>
7 
8 /* QUP block registers */
9 #define QUP_CONFIG 0x000
10 #define QUP_STATE 0x004
11 #define QUP_IO_MODES 0x008
12 #define QUP_SW_RESET 0x00C
13 #define QUP_TRANSFER_CANCEL 0x014
14 #define QUP_OPERATIONAL 0x018
15 #define QUP_ERROR_FLAGS 0x01C
16 #define QUP_ERROR_FLAGS_EN 0x020
17 #define QUP_TEST_CTRL 0x024
18 #define QUP_OPERATIONAL_MASK 0x028
19 #define QUP_HW_VERSION 0x030
20 #define QUP_MX_OUTPUT_COUNT 0x100
21 #define QUP_MX_OUTPUT_CNT_CURRENT 0x104
22 #define QUP_OUTPUT_DEBUG 0x108
23 #define QUP_OUTPUT_FIFO_WORD_CNT 0x10C
24 #define QUP_OUTPUT_FIFO 0x110
25 #define QUP_OUTPUT_FIFO_SIZE 64 /* bytes */
26 #define QUP_MX_WRITE_COUNT 0x150
27 #define QUP_MX_WRITE_CNT_CURRENT 0x154
28 #define QUP_MX_INPUT_COUNT 0x200
29 #define QUP_MX_INPUT_CNT_CURRENT 0x204
30 #define QUP_MX_READ_COUNT 0x208
31 #define QUP_MX_READ_CNT_CURRENT 0x20C
32 #define QUP_INPUT_DEBUG 0x210
33 #define QUP_INPUT_FIFO_WORD_CNT 0x214
34 #define QUP_INPUT_FIFO 0x218
35 #define QUP_INPUT_FIFO_SIZE 64 /* bytes */
36 #define QUP_I2C_MASTER_CLK_CTL 0x400
37 #define QUP_I2C_MASTER_STATUS 0x404
38 #define QUP_I2C_MASTER_CONFIG 0x408
39 #define QUP_I2C_MASTER_BUS_CLEAR 0x40C
40 #define QUP_I2C_MASTER_LOCAL_ID 0x410
41 #define QUP_I2C_MASTER_COMMAND 0x414
42 
43 #define OUTPUT_FIFO_FULL (1<<6)
44 #define INPUT_FIFO_NOT_EMPTY (1<<5)
45 #define OUTPUT_FIFO_NOT_EMPTY (1<<4)
46 #define INPUT_SERVICE_FLAG (1<<9)
47 #define OUTPUT_SERVICE_FLAG (1<<8)
48 #define QUP_UNPACK_EN (1<<14)
49 #define QUP_PACK_EN (1<<15)
50 #define QUP_OUTPUT_BIT_SHIFT_EN (1<<16)
51 
52 #define QUP_MODE_MASK (0x03)
53 #define QUP_OUTPUT_MODE_SHFT (10)
54 #define QUP_INPUT_MODE_SHFT (12)
55 
56 #define QUP_FS_DIVIDER_MASK (0xFF)
57 
58 #define QUP_APP_CLK_ON_EN (1 << 12)
59 #define QUP_CORE_CLK_ON_EN (1 << 13)
60 #define QUP_MINI_CORE_PROTO_SHFT (8)
61 #define QUP_MINI_CORE_PROTO_MASK (0x0F)
62 
63 /* Mini-core states */
64 #define QUP_STATE_RESET 0x0
65 #define QUP_STATE_RUN 0x1
66 #define QUP_STATE_PAUSE 0x3
67 #define QUP_STATE_VALID (1<<2)
68 #define QUP_STATE_MASK 0x3
69 #define QUP_STATE_VALID_MASK (1<<2)
70 
71 /* Tags for output FIFO */
72 #define QUP_I2C_1CLK_NOOP_SEQ 0x1 /*MSB 8-bit NOP, LSB 8-bits 1 clk.*/
73 #define QUP_I2C_START_SEQ (0x1 << 8)
74 #define QUP_I2C_DATA_SEQ (0x2 << 8)
75 #define QUP_I2C_STOP_SEQ (0x3 << 8)
76 #define QUP_I2C_RECV_SEQ (0x4 << 8)
77 
78 /* Tags for input FIFO */
79 #define QUP_I2C_MIDATA_SEQ (0x5 << 8)
80 #define QUP_I2C_MISTOP_SEQ (0x6 << 8)
81 #define QUP_I2C_MINACK_SEQ (0x7 << 8)
82 
83 #define QUP_I2C_ADDR(x) ((x & 0xFF) << 1)
84 #define QUP_I2C_DATA(x) (x & 0xFF)
85 #define QUP_I2C_MI_TAG(x) (x & 0xFF00)
86 #define QUP_I2C_SLAVE_READ (0x1)
87 
88 /*Bit vals for I2C_MASTER_CLK_CTL register */
89 #define QUP_HS_DIVIDER_SHFT (8)
90 #define QUP_DIVIDER_MIN_VAL (0x3)
91 
92 /* Bit masks for I2C_MASTER_STATUS register */
93 #define QUP_I2C_INVALID_READ_SEQ (1 << 25)
94 #define QUP_I2C_INVALID_READ_ADDR (1 << 24)
95 #define QUP_I2C_INVALID_TAG (1 << 23)
96 #define QUP_I2C_FAILED_MASK (0x3 << 6)
97 #define QUP_I2C_INVALID_WRITE (1 << 5)
98 #define QUP_I2C_ARB_LOST (1 << 4)
99 #define QUP_I2C_PACKET_NACK (1 << 3)
100 #define QUP_I2C_BUS_ERROR (1 << 2)
101 
102 typedef enum {
117 } qup_return_t;
118 
119 typedef enum {
124 
125 typedef enum {
129 } qup_mode_t;
130 
131 typedef struct {
133  unsigned int clk_frequency;
134  unsigned int src_frequency;
136  unsigned int initialized;
137 } qup_config_t;
138 
139 typedef struct {
141  union {
142  struct {
145  unsigned int data_len;
146  } iic;
147  struct {
148  void *in;
149  void *out;
150  unsigned int size;
151  } spi;
152  } p;
153 } qup_data_t;
154 
155 /*
156  * Initialize BLSP QUP block for FIFO I2C transfers.
157  * id[IN]: BLSP for which QUP is to be initialized.
158  * config_ptr[IN]: configurations parameters for the QUP.
159  *
160  * return: QUP_SUCCESS, if initialization succeeds.
161  */
162 qup_return_t qup_init(blsp_qup_id_t id, const qup_config_t *config_ptr);
163 
164 /*
165  * Set QUP state to run, pause, reset.
166  * id[IN]: BLSP block for which QUP state is to be set.
167  * state[IN]: New state to transition to.
168  *
169  * return: QUP_SUCCESS, if state transition succeeds.
170  */
172 
173 /*
174  * Reset the status bits set during an i2c transfer.
175  * id[IN]: BLSP block for which i2c status bits are to be cleared.
176  *
177  * return: QUP_SUCCESS, if status bits are cleared successfully.
178  */
180 
181 /*
182  * Send data to the peripheral on the bus.
183  * id[IN]: BLSP block for which data is to be sent.
184  * p_tx_obj[IN]: Data to be sent to the slave on the bus.
185  * stop_seq[IN]: When set to non-zero QUP engine sends i2c stop sequnce.
186  *
187  * return: QUP_SUCCESS, when data is sent successfully to the peripheral.
188  */
190  uint8_t stop_seq);
191 
192 /*
193  * Receive data from peripheral on the bus.
194  * id[IN]: BLSP block from which data is to be received.
195  * p_tx_obj[IN]: length of data to be received, slave address.
196  * [OUT]: buffer filled with data from slave.
197  *
198  * return: QUP_SUCCESS, when data is received successfully.
199  */
201 
202 #endif //__QUP_H__
blsp_qup_id_t
Definition: blsp.h:6
qup_return_t qup_set_state(blsp_qup_id_t id, uint32_t state)
Definition: qup.c:450
qup_return_t qup_recv_data(blsp_qup_id_t id, qup_data_t *p_tx_obj)
Definition: qup.c:533
qup_protocol_t
Definition: qup.h:119
@ QUP_MINICORE_I2C_SLAVE
Definition: qup.h:122
@ QUP_MINICORE_SPI
Definition: qup.h:120
@ QUP_MINICORE_I2C_MASTER
Definition: qup.h:121
qup_return_t qup_send_data(blsp_qup_id_t id, qup_data_t *p_tx_obj, uint8_t stop_seq)
Definition: qup.c:494
qup_return_t
Definition: qup.h:102
@ QUP_ERR_I2C_INVALID_SLAVE_ADDR
Definition: qup.h:111
@ QUP_ERR_STATE_SET
Definition: qup.h:105
@ QUP_ERR_TIMEOUT
Definition: qup.h:106
@ QUP_ERR_UNSUPPORTED
Definition: qup.h:107
@ QUP_ERR_I2C_ARB_LOST
Definition: qup.h:109
@ QUP_ERR_UNDEFINED
Definition: qup.h:116
@ QUP_ERR_I2C_BUS_ERROR
Definition: qup.h:110
@ QUP_ERR_BAD_PARAM
Definition: qup.h:104
@ QUP_ERR_I2C_INVALID_WRITE
Definition: qup.h:114
@ QUP_ERR_I2C_NACK
Definition: qup.h:113
@ QUP_ERR_I2C_INVALID_TAG
Definition: qup.h:115
@ QUP_SUCCESS
Definition: qup.h:103
@ QUP_ERR_XFER_FAIL
Definition: qup.h:112
@ QUP_ERR_I2C_FAILED
Definition: qup.h:108
qup_return_t qup_reset_i2c_master_status(blsp_qup_id_t id)
Definition: qup.c:79
qup_mode_t
Definition: qup.h:125
@ QUP_MODE_BLOCK
Definition: qup.h:127
@ QUP_MODE_FIFO
Definition: qup.h:126
@ QUP_MODE_DATAMOVER
Definition: qup.h:128
qup_return_t qup_init(blsp_qup_id_t id, const qup_config_t *config_ptr)
Definition: qup.c:380
state
Definition: raminit.c:1787
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8
qup_protocol_t protocol
Definition: qup.h:132
unsigned int src_frequency
Definition: qup.h:134
qup_mode_t mode
Definition: qup.h:135
unsigned int initialized
Definition: qup.h:136
unsigned int clk_frequency
Definition: qup.h:133
uint8_t addr
Definition: qup.h:143
uint8_t * data
Definition: qup.h:144
void * out
Definition: qup.h:149
qup_protocol_t protocol
Definition: qup.h:140
void * in
Definition: qup.h:148
unsigned int data_len
Definition: qup.h:145
unsigned int size
Definition: qup.h:150