coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
spi.h
Go to the documentation of this file.
1 /* Register definitions for the IPQ BLSP SPI Controller */
2 /* SPDX-License-Identifier: BSD-3-Clause */
3 
4 #ifndef _QCS405_SPI_H_
5 #define _QCS405_SPI_H_
6 
7 #include <soc/iomap.h>
8 #include <soc/qup.h>
9 #include <spi-generic.h>
10 
11 #define BLSP0_QUP_REG_BASE ((void *)0x78b5000u)
12 #define BLSP4_QUP_REG_BASE ((void *)0x78b9000u)
13 #define BLSP5_QUP_REG_BASE ((void *)0x7af5000u)
14 
15 #define BLSP0_SPI_CONFIG_REG (BLSP0_QUP_REG_BASE + 0x00000300)
16 #define BLSP4_SPI_CONFIG_REG (BLSP4_QUP_REG_BASE + 0x00000300)
17 #define BLSP5_SPI_CONFIG_REG (BLSP5_QUP_REG_BASE + 0x00000300)
18 
19 #define BLSP0_SPI_IO_CONTROL_REG (BLSP0_QUP_REG_BASE + 0x00000304)
20 #define BLSP4_SPI_IO_CONTROL_REG (BLSP4_QUP_REG_BASE + 0x00000304)
21 #define BLSP5_SPI_IO_CONTROL_REG (BLSP5_QUP_REG_BASE + 0x00000304)
22 
23 #define BLSP0_SPI_ERROR_FLAGS_REG (BLSP0_QUP_REG_BASE + 0x00000308)
24 #define BLSP4_SPI_ERROR_FLAGS_REG (BLSP4_QUP_REG_BASE + 0x00000308)
25 #define BLSP5_SPI_ERROR_FLAGS_REG (BLSP5_QUP_REG_BASE + 0x00000308)
26 
27 #define BLSP0_SPI_DEASSERT_WAIT_REG (BLSP0_QUP_REG_BASE + 0x00000310)
28 #define BLSP4_SPI_DEASSERT_WAIT_REG (BLSP4_QUP_REG_BASE + 0x00000310)
29 #define BLSP5_SPI_DEASSERT_WAIT_REG (BLSP5_QUP_REG_BASE + 0x00000310)
30 #define BLSP0_SPI_ERROR_FLAGS_EN_REG (BLSP0_QUP_REG_BASE + 0x0000030c)
31 #define BLSP4_SPI_ERROR_FLAGS_EN_REG (BLSP4_QUP_REG_BASE + 0x0000030c)
32 #define BLSP5_SPI_ERROR_FLAGS_EN_REG (BLSP5_QUP_REG_BASE + 0x0000030c)
33 
34 #define BLSP0_QUP_CONFIG_REG (BLSP0_QUP_REG_BASE + 0x00000000)
35 #define BLSP4_QUP_CONFIG_REG (BLSP4_QUP_REG_BASE + 0x00000000)
36 #define BLSP5_QUP_CONFIG_REG (BLSP5_QUP_REG_BASE + 0x00000000)
37 
38 #define BLSP0_QUP_ERROR_FLAGS_REG (BLSP0_QUP_REG_BASE + 0x0000001c)
39 #define BLSP4_QUP_ERROR_FLAGS_REG (BLSP4_QUP_REG_BASE + 0x0000001c)
40 #define BLSP5_QUP_ERROR_FLAGS_REG (BLSP5_QUP_REG_BASE + 0x0000001c)
41 
42 #define BLSP0_QUP_ERROR_FLAGS_EN_REG (BLSP0_QUP_REG_BASE + 0x00000020)
43 #define BLSP4_QUP_ERROR_FLAGS_EN_REG (BLSP4_QUP_REG_BASE + 0x00000020)
44 #define BLSP5_QUP_ERROR_FLAGS_EN_REG (BLSP5_QUP_REG_BASE + 0x00000020)
45 
46 #define BLSP0_QUP_OPERATIONAL_MASK (BLSP0_QUP_REG_BASE + 0x00000028)
47 #define BLSP4_QUP_OPERATIONAL_MASK (BLSP4_QUP_REG_BASE + 0x00000028)
48 #define BLSP5_QUP_OPERATIONAL_MASK (BLSP5_QUP_REG_BASE + 0x00000028)
49 
50 #define BLSP0_QUP_OPERATIONAL_REG (BLSP0_QUP_REG_BASE + 0x00000018)
51 #define BLSP4_QUP_OPERATIONAL_REG (BLSP4_QUP_REG_BASE + 0x00000018)
52 #define BLSP5_QUP_OPERATIONAL_REG (BLSP5_QUP_REG_BASE + 0x00000018)
53 
54 #define BLSP0_QUP_IO_MODES_REG (BLSP0_QUP_REG_BASE + 0x00000008)
55 #define BLSP4_QUP_IO_MODES_REG (BLSP4_QUP_REG_BASE + 0x00000008)
56 #define BLSP5_QUP_IO_MODES_REG (BLSP5_QUP_REG_BASE + 0x00000008)
57 
58 #define BLSP0_QUP_STATE_REG (BLSP0_QUP_REG_BASE + 0x00000004)
59 #define BLSP4_QUP_STATE_REG (BLSP4_QUP_REG_BASE + 0x00000004)
60 #define BLSP5_QUP_STATE_REG (BLSP5_QUP_REG_BASE + 0x00000004)
61 
62 #define BLSP0_QUP_INPUT_FIFOc_REG(c) \
63  (BLSP0_QUP_REG_BASE + 0x00000218 + 4 * (c))
64 #define BLSP4_QUP_INPUT_FIFOc_REG(c) \
65  (BLSP4_QUP_REG_BASE + 0x00000218 + 4 * (c))
66 #define BLSP5_QUP_INPUT_FIFOc_REG(c) \
67  (BLSP5_QUP_REG_BASE + 0x00000218 + 4 * (c))
68 
69 #define BLSP0_QUP_OUTPUT_FIFOc_REG(c) \
70  (BLSP0_QUP_REG_BASE + 0x00000110 + 4 * (c))
71 #define BLSP4_QUP_OUTPUT_FIFOc_REG(c) \
72  (BLSP4_QUP_REG_BASE + 0x00000110 + 4 * (c))
73 #define BLSP5_QUP_OUTPUT_FIFOc_REG(c) \
74  (BLSP5_QUP_REG_BASE + 0x00000110 + 4 * (c))
75 
76 #define BLSP0_QUP_MX_INPUT_COUNT_REG (BLSP0_QUP_REG_BASE + 0x00000200)
77 #define BLSP4_QUP_MX_INPUT_COUNT_REG (BLSP4_QUP_REG_BASE + 0x00000200)
78 #define BLSP5_QUP_MX_INPUT_COUNT_REG (BLSP5_QUP_REG_BASE + 0x00000200)
79 
80 #define BLSP0_QUP_MX_OUTPUT_COUNT_REG (BLSP0_QUP_REG_BASE + 0x00000100)
81 #define BLSP4_QUP_MX_OUTPUT_COUNT_REG (BLSP4_QUP_REG_BASE + 0x00000100)
82 #define BLSP5_QUP_MX_OUTPUT_COUNT_REG (BLSP5_QUP_REG_BASE + 0x00000100)
83 
84 #define BLSP0_QUP_SW_RESET_REG (BLSP0_QUP_REG_BASE + 0x0000000c)
85 #define BLSP4_QUP_SW_RESET_REG (BLSP4_QUP_REG_BASE + 0x0000000c)
86 #define BLSP5_QUP_SW_RESET_REG (BLSP5_QUP_REG_BASE + 0x0000000c)
87 
88 #define QUP_CONFIG_MINI_CORE_MSK (0x0F << 8)
89 #define QUP_CONFIG_MINI_CORE_SPI (1 << 8)
90 #define QUP_CONF_INPUT_MSK (1 << 7)
91 #define QUP_CONF_INPUT_ENA (0 << 7)
92 #define QUP_CONF_NO_INPUT (1 << 7)
93 #define QUP_CONF_OUTPUT_MSK (1 << 6)
94 #define QUP_CONF_OUTPUT_ENA (0 << 6)
95 #define QUP_CONF_NO_OUTPUT (1 << 6)
96 #define QUP_CONF_N_MASK 0x1F
97 #define QUP_CONF_N_SPI_8_BIT_WORD 0x07
98 
99 #define SPI_CONFIG_INPUT_FIRST (1 << 9)
100 #define SPI_CONFIG_INPUT_FIRST_BACK (0 << 9)
101 #define SPI_CONFIG_LOOP_BACK_MSK (1 << 8)
102 #define SPI_CONFIG_NO_LOOP_BACK (0 << 8)
103 #define SPI_CONFIG_NO_SLAVE_OPER_MSK (1 << 5)
104 #define SPI_CONFIG_NO_SLAVE_OPER (0 << 5)
105 
106 #define SPI_IO_CTRL_CLK_ALWAYS_ON (0 << 9)
107 #define SPI_IO_CTRL_MX_CS_MODE (1 << 8)
108 #define SPI_IO_CTRL_NO_TRI_STATE (1 << 0)
109 #define SPI_IO_CTRL_FORCE_CS_MSK (1 << 11)
110 #define SPI_IO_CTRL_FORCE_CS_EN (1 << 11)
111 #define SPI_IO_CTRL_FORCE_CS_DIS (0 << 11)
112 #define SPI_IO_CTRL_CLOCK_IDLE_HIGH (1 << 10)
113 
114 #define QUP_IO_MODES_OUTPUT_BIT_SHIFT_MSK (1 << 16)
115 #define QUP_IO_MODES_OUTPUT_BIT_SHIFT_EN (1 << 16)
116 #define QUP_IO_MODES_INPUT_MODE_MSK (0x03 << 12)
117 #define QUP_IO_MODES_INPUT_BLOCK_MODE (0x01 << 12)
118 #define QUP_IO_MODES_OUTPUT_MODE_MSK (0x03 << 10)
119 #define QUP_IO_MODES_OUTPUT_BLOCK_MODE (0x01 << 10)
120 
121 #define SPI_INPUT_BLOCK_SIZE 4
122 #define SPI_OUTPUT_BLOCK_SIZE 4
123 
124 #define MAX_COUNT_SIZE 0xffff
125 
126 #define SPI_CORE_RESET 0
127 #define SPI_CORE_RUNNING 1
128 #define SPI_MODE0 0
129 #define SPI_MODE1 1
130 #define SPI_MODE2 2
131 #define SPI_MODE3 3
132 #define BLSP0_SPI 0
133 #define BLSP4_SPI 4
134 #define BLSP5_SPI 5
135 
136 struct blsp_spi {
137  void *spi_config;
138  void *io_control;
139  void *error_flags;
140  void *error_flags_en;
141  void *qup_config;
142  void *qup_error_flags;
143  void *qup_error_flags_en;
144  void *qup_operational;
145  void *qup_io_modes;
146  void *qup_state;
147  void *qup_input_fifo;
148  void *qup_output_fifo;
149  void *qup_mx_input_count;
150  void *qup_mx_output_count;
151  void *qup_sw_reset;
152  void *qup_ns_reg;
153  void *qup_md_reg;
154  void *qup_op_mask;
156 };
157 
158 #define SUCCESS 0
159 
160 #define DUMMY_DATA_VAL 0
161 #define TIMEOUT_CNT 100
162 
163 #define ETIMEDOUT -10
164 #define EINVAL -11
165 #define EIO -12
166 
167 /* MX_INPUT_COUNT and MX_OUTPUT_COUNT are 16-bits. Zero has a special meaning
168  * (count function disabled) and does not hold significance in the count. */
169 #define MAX_PACKET_COUNT ((64 * KiB) - 1)
170 
172  struct spi_slave slave;
173  const struct blsp_spi *regs;
174  unsigned int mode;
175  unsigned int initialized;
176  unsigned long freq;
178 };
179 
180 #endif
Definition: spi.h:115
void * qup_output_fifo
Definition: spi.h:127
void * io_control
Definition: spi.h:117
void * spi_config
Definition: spi.h:116
void * qup_operational
Definition: spi.h:123
void * qup_deassert_wait
Definition: spi.h:134
void * qup_state
Definition: spi.h:125
void * qup_mx_output_count
Definition: spi.h:129
void * error_flags_en
Definition: spi.h:119
void * qup_ns_reg
Definition: spi.h:131
void * qup_config
Definition: spi.h:120
void * qup_input_fifo
Definition: spi.h:126
void * qup_io_modes
Definition: spi.h:124
void * qup_md_reg
Definition: spi.h:132
void * qup_sw_reset
Definition: spi.h:130
void * qup_error_flags_en
Definition: spi.h:122
void * error_flags
Definition: spi.h:118
void * qup_error_flags
Definition: spi.h:121
void * qup_mx_input_count
Definition: spi.h:128
void * qup_op_mask
Definition: spi.h:133
const struct blsp_spi * regs
Definition: spi.h:173
unsigned int initialized
Definition: spi.h:175
struct spi_slave slave
Definition: spi.h:172
int allocated
Definition: spi.h:177
unsigned long freq
Definition: spi.h:176
unsigned int mode
Definition: spi.h:174