MT7687 API Reference  LinkIt SDK v4
hal_sdio.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_SDIO_H__
36 #define __HAL_SDIO_H__
37 #include "hal_platform.h"
38 
39 #ifdef HAL_SDIO_MODULE_ENABLED
40 
244 #ifdef __cplusplus
245 extern "C" {
246 #endif
247 
253 typedef enum {
254  HAL_SDIO_STATUS_BUSY = -2,
255  HAL_SDIO_STATUS_ERROR = -1,
256  HAL_SDIO_STATUS_OK = 0,
257 } hal_sdio_status_t;
258 
259 
261 typedef enum {
262  HAL_SDIO_BUS_WIDTH_1 = 1,
263  HAL_SDIO_BUS_WIDTH_4 = 2
264 } hal_sdio_bus_width_t;
265 
266 
268 typedef enum {
269  HAL_SDIO_DIRECTION_READ = 0,
270  HAL_SDIO_DIRECTION_WRITE = 1
271 } hal_sdio_direction_t;
272 
273 
275 typedef enum {
276  HAL_SDIO_FIXED_ADDRESS = 0,
277  HAL_SDIO_INCREMENTING_ADDRESS = 1
278 } hal_sdio_command53_operation_t;
279 
280 
282 typedef enum {
283  HAL_SDIO_FUNCTION_0 = 0,
284  HAL_SDIO_FUNCTION_1 = 1
285 } hal_sdio_function_id_t;
286 
287 
298 typedef struct {
299  hal_sdio_bus_width_t bus_width;
300  uint32_t clock;
301 } hal_sdio_config_t;
302 
303 
306 typedef struct {
307  hal_sdio_direction_t direction;
308  hal_sdio_function_id_t function;
309  bool block;
310  hal_sdio_command53_operation_t operation;
311  uint16_t count;
312  uint32_t address;
313  uint32_t buffer;
314 } hal_sdio_command53_config_t;
315 
316 
319 typedef struct {
320  hal_sdio_direction_t direction;
321  hal_sdio_function_id_t function;
322  bool read_after_write;
323  bool stop;
324  uint8_t data;
325  uint32_t address;
326 } hal_sdio_command52_config_t;
327 
343 hal_sdio_status_t hal_sdio_init(hal_sdio_port_t sdio_port, hal_sdio_config_t *sdio_config);
344 
345 
352 hal_sdio_status_t hal_sdio_deinit(hal_sdio_port_t sdio_port);
353 
354 
363 hal_sdio_status_t hal_sdio_set_clock(hal_sdio_port_t sdio_port, uint32_t clock);
364 
365 
373 hal_sdio_status_t hal_sdio_get_clock(hal_sdio_port_t sdio_port, uint32_t *clock);
374 
375 
384 hal_sdio_status_t hal_sdio_set_bus_width(hal_sdio_port_t sdio_port, hal_sdio_bus_width_t bus_width);
385 
386 
396 hal_sdio_status_t hal_sdio_set_block_size(hal_sdio_port_t sdio_port, hal_sdio_function_id_t function, uint32_t block_size);
397 
398 
407 hal_sdio_status_t hal_sdio_get_block_size(hal_sdio_port_t sdio_port, hal_sdio_function_id_t function, uint32_t *block_size);
408 
409 
418 hal_sdio_status_t hal_sdio_execute_command52(hal_sdio_port_t sdio_port, hal_sdio_command52_config_t *command52_config);
419 
420 
421 
430 hal_sdio_status_t hal_sdio_execute_command53(hal_sdio_port_t sdio_port, hal_sdio_command53_config_t *command53_config);
431 
432 
441 hal_sdio_status_t hal_sdio_execute_command53_dma(hal_sdio_port_t sdio_port, hal_sdio_command53_config_t *command53_config);
442 
443 
444 #ifdef __cplusplus
445 }
446 #endif
447 
448 
453 #endif /*HAL_SDIO_MODULE_ENABLED*/
454 #endif /* __HAL_SDIO_H__ */
455