MT7687 API Reference  LinkIt SDK v4
hal_sd.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_SD_H__
36 #define __HAL_SD_H__
37 
38 #include "hal_platform.h"
39 
40 #ifdef HAL_SD_MODULE_ENABLED
41 
642 #ifdef HAL_SD_CARD_DETECTION
643 
709 #endif
710 
717 #ifdef __cplusplus
718 extern "C" {
719 #endif
720 
726 typedef enum {
727  HAL_SD_STATUS_BUSY = -2,
728  HAL_SD_STATUS_ERROR = -1,
729  HAL_SD_STATUS_OK = 0,
730 } hal_sd_status_t;
731 
732 
734 typedef enum {
735  HAL_SD_BUS_WIDTH_1 = 1,
736  HAL_SD_BUS_WIDTH_4 = 2
737 } hal_sd_bus_width_t;
738 
739 
741 typedef enum {
742  HAL_SD_TYPE_SD_CARD = 0,
743  HAL_SD_TYPE_MMC_CARD = 1,
744  HAL_SD_TYPE_SD20_LCS_CARD = 2,
745  HAL_SD_TYPE_SD20_HCS_CARD = 3,
746  HAL_SD_TYPE_MMC42_CARD = 4,
747  HAL_SD_TYPE_CARD_TYPE_MAX = 5,
748  HAL_SD_TYPE_UNKNOWN_CARD = 0xff,
749 } hal_sd_card_type_t;
750 
751 #ifdef HAL_SD_CARD_DETECTION
752 
755 typedef enum {
756  HAL_SD_EVENT_CARD_INSERTED = 0,
757  HAL_SD_EVENT_CARD_REMOVED = 1,
758 } hal_sd_card_event_t;
759 #endif
760 
771 typedef struct {
772  hal_sd_bus_width_t bus_width;
773  uint32_t clock;
774 } hal_sd_config_t;
775 
780 #ifdef HAL_SD_CARD_DETECTION
781 
792 typedef void (*hal_sd_callback_t)(hal_sd_card_event_t event, void *user_data);
796 #endif
797 
807 hal_sd_status_t hal_sd_init(hal_sd_port_t sd_port, hal_sd_config_t *sd_config);
808 
809 
816 hal_sd_status_t hal_sd_deinit(hal_sd_port_t sd_port);
817 
818 #ifdef HAL_SD_CARD_DETECTION
819 
827 hal_sd_status_t hal_sd_register_card_detection_callback(hal_sd_port_t sd_port, hal_sd_callback_t sd_callback, void *user_data);
828 #endif
829 
837 hal_sd_status_t hal_sd_set_bus_width(hal_sd_port_t sd_port, hal_sd_bus_width_t bus_width);
838 
839 
848 hal_sd_status_t hal_sd_set_clock(hal_sd_port_t sd_port, uint32_t clock);
849 
850 
857 hal_sd_status_t hal_sd_get_clock(hal_sd_port_t sd_port, uint32_t *clock);
858 
859 
866 hal_sd_status_t hal_sd_get_capacity(hal_sd_port_t sd_port, uint64_t *capacity);
867 
868 
876 hal_sd_status_t hal_sd_get_erase_sector_size(hal_sd_port_t sd_port, uint32_t *erase_sector_size);
877 
878 
888 hal_sd_status_t hal_sd_erase_sectors(hal_sd_port_t sd_port, uint32_t start_sector, uint32_t sector_number);
889 
890 
902 hal_sd_status_t hal_sd_read_blocks(hal_sd_port_t sd_port, uint32_t *read_buffer, uint32_t start_address, uint32_t block_number);
903 
904 
916 hal_sd_status_t hal_sd_write_blocks(hal_sd_port_t sd_port, const uint32_t *write_data, uint32_t start_address, uint32_t block_number);
917 
929 hal_sd_status_t hal_sd_read_blocks_dma(hal_sd_port_t sd_port, uint32_t *read_buffer, uint32_t start_address, uint32_t block_number);
930 
931 
943 hal_sd_status_t hal_sd_write_blocks_dma(hal_sd_port_t sd_port, const uint32_t *write_data, uint32_t start_address, uint32_t block_number);
944 
945 
953 hal_sd_status_t hal_sd_get_csd(hal_sd_port_t sd_port, uint32_t *csd);
954 
955 
963 hal_sd_status_t hal_sd_get_cid(hal_sd_port_t sd_port, uint32_t *cid);
964 
965 
973 hal_sd_status_t hal_sd_get_card_type(hal_sd_port_t sd_port, hal_sd_card_type_t *card_type);
974 
975 
983 hal_sd_status_t hal_sd_get_ocr(hal_sd_port_t sd_port, uint32_t *ocr);
984 
985 
993 hal_sd_status_t hal_sd_get_card_status(hal_sd_port_t sd_port, uint32_t *card_status);
994 
995 
996 #ifdef __cplusplus
997 }
998 #endif
999 
1004 #endif /*HAL_SD_MODULE_ENABLED*/
1005 #endif /* __HAL_SD_H__ */
1006 
1007