MT7687 API Reference  LinkIt SDK v4
hal_sdio.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2017 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 
343 #ifdef __cplusplus
344 extern "C" {
345 #endif
346 
352 typedef enum {
353  HAL_SDIO_STATUS_BUSY = -2,
354  HAL_SDIO_STATUS_ERROR = -1,
355  HAL_SDIO_STATUS_OK = 0,
356 } hal_sdio_status_t;
357 
358 
360 typedef enum {
361  HAL_SDIO_BUS_WIDTH_1 = 1,
362  HAL_SDIO_BUS_WIDTH_4 = 2
363 } hal_sdio_bus_width_t;
364 
365 
367 typedef enum {
368  HAL_SDIO_DIRECTION_READ = 0,
369  HAL_SDIO_DIRECTION_WRITE = 1
370 } hal_sdio_direction_t;
371 
372 
374 typedef enum {
375  HAL_SDIO_FIXED_ADDRESS = 0,
376  HAL_SDIO_INCREMENTING_ADDRESS = 1
377 } hal_sdio_command53_operation_t;
378 
379 
381 typedef enum {
382  HAL_SDIO_FUNCTION_0 = 0,
383  HAL_SDIO_FUNCTION_1 = 1
384 } hal_sdio_function_id_t;
385 
386 typedef enum {
387  HAL_SDIO_EVENT_SUCCESS = 0,
388  HAL_SDIO_EVENT_TRANSFER_ERROR = -1,
389  HAL_SDIO_EVENT_CRC_ERROR = -2,
390  HAL_SDIO_EVENT_DATA_TIMEOUT = -3,
391 }hal_sdio_callback_event_t;
392 
403 typedef struct {
404  hal_sdio_bus_width_t bus_width;
405  uint32_t clock;
406 } hal_sdio_config_t;
407 
408 
411 typedef struct {
412  hal_sdio_direction_t direction;
413  hal_sdio_function_id_t function;
414  bool block;
415  hal_sdio_command53_operation_t operation;
416  uint16_t count;
417  uint32_t address;
418  uint32_t buffer;
419 } hal_sdio_command53_config_t;
420 
421 
424 typedef struct {
425  hal_sdio_direction_t direction;
426  hal_sdio_function_id_t function;
427  bool read_after_write;
428  bool stop;
429  uint8_t data;
430  uint32_t address;
431 } hal_sdio_command52_config_t;
432 
448 typedef void (*hal_sdio_callback_t)(hal_sdio_callback_event_t event, void *user_data);
461 hal_sdio_status_t hal_sdio_register_callback(hal_sdio_port_t sdio_port, hal_sdio_callback_t sdio_callback,void *user_data);
462 
473 hal_sdio_status_t hal_sdio_init(hal_sdio_port_t sdio_port, hal_sdio_config_t *sdio_config);
474 
475 
482 hal_sdio_status_t hal_sdio_deinit(hal_sdio_port_t sdio_port);
483 
484 
493 hal_sdio_status_t hal_sdio_set_clock(hal_sdio_port_t sdio_port, uint32_t clock);
494 
495 
503 hal_sdio_status_t hal_sdio_get_clock(hal_sdio_port_t sdio_port, uint32_t *clock);
504 
505 
514 hal_sdio_status_t hal_sdio_set_bus_width(hal_sdio_port_t sdio_port, hal_sdio_bus_width_t bus_width);
515 
516 
526 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);
527 
528 
537 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);
538 
539 
548 hal_sdio_status_t hal_sdio_execute_command52(hal_sdio_port_t sdio_port, hal_sdio_command52_config_t *command52_config);
549 
550 
551 
560 hal_sdio_status_t hal_sdio_execute_command53(hal_sdio_port_t sdio_port, hal_sdio_command53_config_t *command53_config);
561 
570 hal_sdio_status_t hal_sdio_execute_command53_dma_blocking(hal_sdio_port_t sdio_port, hal_sdio_command53_config_t *command53_config);
571 
580 hal_sdio_status_t hal_sdio_execute_command53_dma(hal_sdio_port_t sdio_port, hal_sdio_command53_config_t *command53_config);
581 
582 
583 #ifdef __cplusplus
584 }
585 #endif
586 
587 
592 #endif /*HAL_SDIO_MODULE_ENABLED*/
593 #endif /* __HAL_SDIO_H__ */
594