Mistake on this page?
Report an issue in GitHub or email us
whd_bus_sdio_protocol.h
1 /*
2  * Copyright 2020 Cypress Semiconductor Corporation
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include "whd.h"
19 #include "bus_protocols/whd_bus_protocol_interface.h"
20 
21 #ifndef INCLUDED_SDIO_WHD_BUS_PROTOCOL_H
22 #define INCLUDED_SDIO_WHD_BUS_PROTOCOL_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /******************************************************
29 * Macros
30 ******************************************************/
31 #define BIT_MASK(x) ( (1 << x) - 1 )
32 
33 #define WHD_BUS_HEADER_SIZE (0)
34 
35 #define WHD_BUS_SDIO_MAX_BACKPLANE_TRANSFER_SIZE (1536)
36 #define WHD_BUS_SDIO_BACKPLANE_READ_PADD_SIZE (0)
37 
38 /******************************************************
39 * Structures
40 ******************************************************/
41 #pragma pack(1)
42 typedef struct
43 {
44  unsigned char stuff_bits;
45  unsigned int ocr : 24;
47 
48 typedef struct
49 {
50  unsigned int _unique2 : 9; /* 0-8 */
51  unsigned int register_address : 17; /* 9-25 */
52  unsigned int _unique : 2; /* 26-27 */
53  unsigned int function_number : 3; /* 28-30 */
54  unsigned int rw_flag : 1; /* 31 */
56 
57 typedef struct
58 {
59  uint8_t write_data; /* 0 - 7 */
60  unsigned int _stuff2 : 1; /* 8 */
61  unsigned int register_address : 17; /* 9-25 */
62  unsigned int _stuff : 1; /* 26 */
63  unsigned int raw_flag : 1; /* 27 */
64  unsigned int function_number : 3; /* 28-30 */
65  unsigned int rw_flag : 1; /* 31 */
67 
68 typedef struct
69 {
70  unsigned int count : 9; /* 0-8 */
71  unsigned int register_address : 17; /* 9-25 */
72  unsigned int op_code : 1; /* 26 */
73  unsigned int block_mode : 1; /* 27 */
74  unsigned int function_number : 3; /* 28-30 */
75  unsigned int rw_flag : 1; /* 31 */
77 
78 typedef union
79 {
80  uint32_t value;
86 
87 typedef struct
88 {
89  unsigned int ocr : 24; /* 0-23 */
90  unsigned int stuff_bits : 3; /* 24-26 */
91  unsigned int memory_present : 1; /* 27 */
92  unsigned int function_count : 3; /* 28-30 */
93  unsigned int c : 1; /* 31 */
95 
96 typedef struct
97 {
98  uint8_t data; /* 0-7 */
99  uint8_t response_flags; /* 8-15 */
100  uint16_t stuff; /* 16-31 */
102 
103 typedef struct
104 {
105  uint16_t card_status; /* 0-15 */
106  uint16_t rca; /* 16-31 */
108 
109 typedef union
110 {
111  uint32_t value;
112  sdio_response4_t r4;
113  sdio_response5_t r5;
114  sdio_response6_t r6;
116 
117 typedef enum
118 {
119  SDIO_BLOCK_MODE = (0 << 2), /* These are STM32 implementation specific */
120  SDIO_BYTE_MODE = (1 << 2) /* These are STM32 implementation specific */
121 } sdio_transfer_mode_t;
122 
123 typedef enum
124 {
125  SDIO_1B_BLOCK = 1, SDIO_2B_BLOCK = 2, SDIO_4B_BLOCK = 4, SDIO_8B_BLOCK = 8, SDIO_16B_BLOCK = 16,
126  SDIO_32B_BLOCK = 32, SDIO_64B_BLOCK = 64, SDIO_128B_BLOCK = 128, SDIO_256B_BLOCK = 256, SDIO_512B_BLOCK = 512,
127  SDIO_1024B_BLOCK = 1024, SDIO_2048B_BLOCK = 2048
128 } sdio_block_size_t;
129 
130 typedef enum
131 {
132  RESPONSE_NEEDED, NO_RESPONSE
133 } sdio_response_needed_t;
134 
135 
136 #pragma pack()
137 
138 /******************************************************
139 * Macros
140 ******************************************************/
141 #define WHD_BUS_STATS_INCREMENT_VARIABLE(bus_priv, var) \
142  do { bus_priv->whd_bus_stats.var++; } while (0)
143 
144 #define WHD_BUS_STATS_CONDITIONAL_INCREMENT_VARIABLE(bus_priv, condition, var) \
145  do { if (condition){ bus_priv->whd_bus_stats.var++; }} while (0)
146 
147 typedef struct
148 {
149  uint32_t cmd52; /* Number of cmd52 reads/writes issued */
150  uint32_t cmd53_read; /* Number of cmd53 reads */
151  uint32_t cmd53_write; /* Number of cmd53 writes */
152  uint32_t cmd52_fail; /* Number of cmd52 read/write fails */
153  uint32_t cmd53_read_fail; /* Number of cmd53 read fails */
154  uint32_t cmd53_write_fail; /* Number of cmd53 write fails */
155  uint32_t oob_intrs; /* Number of OOB interrupts generated by wlan chip */
156  uint32_t sdio_intrs; /* Number of SDIO interrupts generated by wlan chip */
157  uint32_t error_intrs; /* Number of SDIO error interrupts generated by wlan chip */
158  uint32_t read_aborts; /* Number of times read aborts are called */
160 
161 /******************************************************
162 * Structures
163 ******************************************************/
164 
165 /******************************************************
166 * Function declarations
167 ******************************************************/
168 /* Initialisation functions */
169 extern whd_result_t whd_bus_sdio_init(whd_driver_t whd_driver);
170 extern whd_result_t whd_bus_sdio_resume_after_deep_sleep(whd_driver_t whd_driver);
171 extern whd_result_t whd_bus_sdio_deinit(whd_driver_t whd_driver);
172 
173 /* Device register access functions */
174 extern whd_result_t whd_bus_sdio_write_backplane_value(whd_driver_t whd_driver, uint32_t address,
175  uint8_t register_length, uint32_t value);
176 extern whd_result_t whd_bus_sdio_read_backplane_value(whd_driver_t whd_driver, uint32_t address,
177  uint8_t register_length, uint8_t *value);
178 extern whd_result_t whd_bus_sdio_write_register_value(whd_driver_t whd_driver, whd_bus_function_t function,
179  uint32_t address, uint8_t value_length, uint32_t value);
180 extern whd_result_t whd_bus_sdio_read_register_value(whd_driver_t whd_driver, whd_bus_function_t function,
181  uint32_t address, uint8_t value_length, uint8_t *value);
182 
183 /* Device data transfer functions */
184 extern whd_result_t whd_bus_sdio_send_buffer(whd_driver_t whd_driver, whd_buffer_t buffer);
185 extern whd_result_t whd_bus_sdio_transfer_bytes(whd_driver_t whd_driver, whd_bus_transfer_direction_t direction,
186  whd_bus_function_t function, uint32_t address, uint16_t size,
188 extern whd_result_t whd_bus_sdio_transfer_backplane_bytes(whd_driver_t whd_driver,
189  whd_bus_transfer_direction_t direction, uint32_t address,
190  uint32_t size, uint8_t *data);
191 
192 /* Frame transfer function */
193 extern whd_result_t whd_bus_sdio_read_frame(whd_driver_t whd_driver, whd_buffer_t *buffer);
194 
195 extern whd_result_t whd_bus_sdio_poke_wlan(whd_driver_t whd_driver);
196 extern uint32_t whd_bus_sdio_packet_available_to_read(whd_driver_t whd_driver);
197 extern whd_result_t whd_bus_sdio_ack_interrupt(whd_driver_t whd_driver, uint32_t intstatus);
198 
199 extern whd_result_t whd_bus_sdio_set_backplane_window(whd_driver_t whd_driver, uint32_t addr);
200 
201 extern void whd_delayed_bus_release_schedule_update(whd_driver_t whd_driver, whd_bool_t is_scheduled);
202 #define DELAYED_BUS_RELEASE_SCHEDULE(whd_driver, schedule) \
203  do { whd_delayed_bus_release_schedule_update(whd_driver, schedule); } while (0)
204 
205 extern whd_bool_t whd_bus_sdio_wake_interrupt_present(whd_driver_t whd_driver);
206 
207 extern whd_result_t whd_bus_sdio_wakeup(whd_driver_t whd_driver);
208 extern whd_result_t whd_bus_sdio_sleep(whd_driver_t whd_driver);
209 
210 extern void whd_bus_sdio_init_stats(whd_driver_t whd_driver);
211 extern whd_result_t whd_bus_sdio_print_stats(whd_driver_t whd_driver, whd_bool_t reset_after_print);
212 extern whd_result_t whd_bus_sdio_reinit_stats(whd_driver_t whd_driver, whd_bool_t wake_from_firmware);
213 
214 uint8_t whd_bus_sdio_backplane_read_padd_size(whd_driver_t whd_driver);
215 
216 extern whd_result_t whd_bus_sdio_wait_for_wlan_event(whd_driver_t whd_driver,
217  cy_semaphore_t *transceive_semaphore);
218 extern whd_bool_t whd_bus_sdio_use_status_report_scheme(whd_driver_t whd_driver);
219 extern uint32_t whd_bus_sdio_get_max_transfer_size(whd_driver_t whd_driver);
220 /******************************************************
221 * Global variables
222 ******************************************************/
223 
224 #ifdef __cplusplus
225 } /*extern "C" */
226 #endif
227 
228 #endif /* ifndef INCLUDED_SDIO_WHD_BUS_PROTOCOL_H */
229 
Provides abstract pointer type to act as instance for: driver, interface, buffer funcs, network funcs, resource funcs and bus funcs.
whd_bus_transfer_direction_t
Transfer direction for the WHD platform bus interface.
Definition: whd_types.h:172
whd_bool_t
Boolean values.
Definition: whd_types.h:162
uint32_t whd_result_t
WHD result is specified as uint32_t value.
Definition: whd_types.h:776
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.