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 _IPQ40XX_SPI_H_
5 #define _IPQ40XX_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 BLSP1_QUP_REG_BASE ((void *)0x78b6000u)
13 
14 #define BLSP0_SPI_CONFIG_REG (BLSP0_QUP_REG_BASE + 0x00000300)
15 #define BLSP1_SPI_CONFIG_REG (BLSP1_QUP_REG_BASE + 0x00000300)
16 
17 #define BLSP0_SPI_IO_CONTROL_REG (BLSP0_QUP_REG_BASE + 0x00000304)
18 #define BLSP1_SPI_IO_CONTROL_REG (BLSP1_QUP_REG_BASE + 0x00000304)
19 
20 #define BLSP0_SPI_ERROR_FLAGS_REG (BLSP0_QUP_REG_BASE + 0x00000308)
21 #define BLSP1_SPI_ERROR_FLAGS_REG (BLSP1_QUP_REG_BASE + 0x00000308)
22 
23 #define BLSP0_SPI_DEASSERT_WAIT_REG (BLSP0_QUP_REG_BASE + 0x00000310)
24 #define BLSP1_SPI_DEASSERT_WAIT_REG (BLSP1_QUP_REG_BASE + 0x00000310)
25 #define BLSP0_SPI_ERROR_FLAGS_EN_REG (BLSP0_QUP_REG_BASE + 0x0000030c)
26 #define BLSP1_SPI_ERROR_FLAGS_EN_REG (BLSP1_QUP_REG_BASE + 0x0000030c)
27 
28 #define BLSP0_QUP_CONFIG_REG (BLSP0_QUP_REG_BASE + 0x00000000)
29 #define BLSP1_QUP_CONFIG_REG (BLSP1_QUP_REG_BASE + 0x00000000)
30 
31 #define BLSP0_QUP_ERROR_FLAGS_REG (BLSP0_QUP_REG_BASE + 0x0000001c)
32 #define BLSP1_QUP_ERROR_FLAGS_REG (BLSP1_QUP_REG_BASE + 0x0000001c)
33 
34 #define BLSP0_QUP_ERROR_FLAGS_EN_REG (BLSP0_QUP_REG_BASE + 0x00000020)
35 #define BLSP1_QUP_ERROR_FLAGS_EN_REG (BLSP1_QUP_REG_BASE + 0x00000020)
36 
37 #define BLSP0_QUP_OPERATIONAL_MASK (BLSP0_QUP_REG_BASE + 0x00000028)
38 #define BLSP1_QUP_OPERATIONAL_MASK (BLSP1_QUP_REG_BASE + 0x00000028)
39 
40 #define BLSP0_QUP_OPERATIONAL_REG (BLSP0_QUP_REG_BASE + 0x00000018)
41 #define BLSP1_QUP_OPERATIONAL_REG (BLSP1_QUP_REG_BASE + 0x00000018)
42 
43 #define BLSP0_QUP_IO_MODES_REG (BLSP0_QUP_REG_BASE + 0x00000008)
44 #define BLSP1_QUP_IO_MODES_REG (BLSP1_QUP_REG_BASE + 0x00000008)
45 
46 #define BLSP0_QUP_STATE_REG (BLSP0_QUP_REG_BASE + 0x00000004)
47 #define BLSP1_QUP_STATE_REG (BLSP1_QUP_REG_BASE + 0x00000004)
48 
49 #define BLSP0_QUP_INPUT_FIFOc_REG(c) \
50  (BLSP0_QUP_REG_BASE + 0x00000218 + 4 * (c))
51 #define BLSP1_QUP_INPUT_FIFOc_REG(c) \
52  (BLSP1_QUP_REG_BASE + 0x00000218 + 4 * (c))
53 
54 #define BLSP0_QUP_OUTPUT_FIFOc_REG(c) \
55  (BLSP0_QUP_REG_BASE + 0x00000110 + 4 * (c))
56 #define BLSP1_QUP_OUTPUT_FIFOc_REG(c) \
57  (BLSP1_QUP_REG_BASE + 0x00000110 + 4 * (c))
58 
59 #define BLSP0_QUP_MX_INPUT_COUNT_REG (BLSP0_QUP_REG_BASE + 0x00000200)
60 #define BLSP1_QUP_MX_INPUT_COUNT_REG (BLSP1_QUP_REG_BASE + 0x00000200)
61 
62 #define BLSP0_QUP_MX_OUTPUT_COUNT_REG (BLSP0_QUP_REG_BASE + 0x00000100)
63 #define BLSP1_QUP_MX_OUTPUT_COUNT_REG (BLSP1_QUP_REG_BASE + 0x00000100)
64 
65 #define BLSP0_QUP_SW_RESET_REG (BLSP0_QUP_REG_BASE + 0x0000000c)
66 #define BLSP1_QUP_SW_RESET_REG (BLSP1_QUP_REG_BASE + 0x0000000c)
67 
68 #define QUP_CONFIG_MINI_CORE_MSK (0x0F << 8)
69 #define QUP_CONFIG_MINI_CORE_SPI (1 << 8)
70 #define QUP_CONF_INPUT_MSK (1 << 7)
71 #define QUP_CONF_INPUT_ENA (0 << 7)
72 #define QUP_CONF_NO_INPUT (1 << 7)
73 #define QUP_CONF_OUTPUT_MSK (1 << 6)
74 #define QUP_CONF_OUTPUT_ENA (0 << 6)
75 #define QUP_CONF_NO_OUTPUT (1 << 6)
76 #define QUP_CONF_N_MASK 0x1F
77 #define QUP_CONF_N_SPI_8_BIT_WORD 0x07
78 
79 #define SPI_CONFIG_INPUT_FIRST (1 << 9)
80 #define SPI_CONFIG_INPUT_FIRST_BACK (0 << 9)
81 #define SPI_CONFIG_LOOP_BACK_MSK (1 << 8)
82 #define SPI_CONFIG_NO_LOOP_BACK (0 << 8)
83 #define SPI_CONFIG_NO_SLAVE_OPER_MSK (1 << 5)
84 #define SPI_CONFIG_NO_SLAVE_OPER (0 << 5)
85 
86 #define SPI_IO_CTRL_CLK_ALWAYS_ON (0 << 9)
87 #define SPI_IO_CTRL_MX_CS_MODE (1 << 8)
88 #define SPI_IO_CTRL_NO_TRI_STATE (1 << 0)
89 #define SPI_IO_CTRL_FORCE_CS_MSK (1 << 11)
90 #define SPI_IO_CTRL_FORCE_CS_EN (1 << 11)
91 #define SPI_IO_CTRL_FORCE_CS_DIS (0 << 11)
92 #define SPI_IO_CTRL_CLOCK_IDLE_HIGH (1 << 10)
93 
94 #define QUP_IO_MODES_OUTPUT_BIT_SHIFT_MSK (1 << 16)
95 #define QUP_IO_MODES_OUTPUT_BIT_SHIFT_EN (1 << 16)
96 #define QUP_IO_MODES_INPUT_MODE_MSK (0x03 << 12)
97 #define QUP_IO_MODES_INPUT_BLOCK_MODE (0x01 << 12)
98 #define QUP_IO_MODES_OUTPUT_MODE_MSK (0x03 << 10)
99 #define QUP_IO_MODES_OUTPUT_BLOCK_MODE (0x01 << 10)
100 
101 #define SPI_INPUT_BLOCK_SIZE 4
102 #define SPI_OUTPUT_BLOCK_SIZE 4
103 
104 #define MAX_COUNT_SIZE 0xffff
105 
106 #define SPI_CORE_RESET 0
107 #define SPI_CORE_RUNNING 1
108 #define SPI_MODE0 0
109 #define SPI_MODE1 1
110 #define SPI_MODE2 2
111 #define SPI_MODE3 3
112 #define BLSP0_SPI 0
113 #define BLSP1_SPI 1
114 
115 struct blsp_spi {
116  void *spi_config;
117  void *io_control;
118  void *error_flags;
120  void *qup_config;
125  void *qup_state;
131  void *qup_ns_reg;
132  void *qup_md_reg;
133  void *qup_op_mask;
135 };
136 
137 #define SUCCESS 0
138 
139 #define DUMMY_DATA_VAL 0
140 #define TIMEOUT_CNT 100
141 
142 #define ETIMEDOUT -10
143 #define EINVAL -11
144 #define EIO -12
145 
146 /* MX_INPUT_COUNT and MX_OUTPUT_COUNT are 16-bits. Zero has a special meaning
147  * (count function disabled) and does not hold significance in the count. */
148 #define MAX_PACKET_COUNT ((64 * KiB) - 1)
149 
151  struct spi_slave slave;
152  const struct blsp_spi *regs;
153  unsigned int mode;
154  unsigned int initialized;
155  unsigned long freq;
157 };
158 
159 #endif /* _IPQ40XX_SPI_H_ */
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:152
unsigned int initialized
Definition: spi.h:154
struct spi_slave slave
Definition: spi.h:151
unsigned long freq
Definition: spi.h:155
int allocated
Definition: spi.h:156
unsigned int mode
Definition: spi.h:153