AM263Px MCU+ SDK  10.01.00
mmcsd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022-24 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
50 #ifndef MMCSD_H_
51 #define MMCSD_H_
52 
53 /* ========================================================================== */
54 /* Include Files */
55 /* ========================================================================== */
56 
57 #include <stdint.h>
58 #include <kernel/dpl/SystemP.h>
59 #include <kernel/dpl/SemaphoreP.h>
60 #include <kernel/dpl/HwiP.h>
61 #include <drivers/hw_include/csl_types.h>
62 #include <drivers/hw_include/cslr_mmcsd.h>
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 /* ========================================================================== */
70 /* Macros & Typedefs */
71 /* ========================================================================== */
72 
83 #define MMCSD_MODE_BLOCKING ((uint32_t) 0U)
84 #define MMCSD_MODE_CALLBACK ((uint32_t) 1U)
85 
88 typedef void* MMCSD_Handle;
89 
90 /* ========================================================================== */
91 /* Function Pointers Declarations */
92 /* ========================================================================== */
93 
106 typedef void (*MMCSD_txnCallbackFxn) (MMCSD_Handle mmcsdHandle,
107  int32_t transferStatus);
108 
109 /* ========================================================================== */
110 /* Structures and Enums */
111 /* ========================================================================== */
112 
116 typedef struct
117 {
118  /* Pointer to eMMC/SD device data structure. Memory for this structure
119  has to be allocated in application */
120  void *deviceData;
121  /* Pointer to a 512 byte dataBuffer used for temporary data transactions
122  * internal to driver like ECSD read, tuning etc.
123  * To be allocated by application */
124  uint8_t *dataBuf;
126  uint8_t transferMode;
129 
130 } MMCSD_Params;
131 
135 typedef struct
136 {
137  uint32_t baseAddr;
139  uint32_t inputClk;
141  bool enableDma;
145  uint32_t intrPriority;
147  uint32_t intrNum;
149  uint32_t eventId;
151  uint32_t cardType;
153  uint32_t busWidth;
157  uint32_t uaBusSpeed;
160 } MMCSD_Attrs;
161 
165 typedef struct
166 {
167  uint32_t cardType;
169  bool isOpen;
184  uint32_t transferMode;
189 } MMCSD_Object;
190 
198 typedef struct
199 {
204 } MMCSD_Config;
205 
206 /* ========================================================================== */
207 /* Externs */
208 /* ========================================================================== */
209 
211 extern MMCSD_Config gMmcsdConfig[];
213 extern uint32_t gMmcsdConfigNum;
214 
215 /* ========================================================================== */
216 /* Internal/Private Structure Declarations */
217 /* ========================================================================== */
218 
219 /* ========================================================================== */
220 /* Function Declarations */
221 /* ========================================================================== */
222 
226 void MMCSD_init(void);
227 
231 void MMCSD_deinit(void);
232 
238 void MMCSD_Params_init(MMCSD_Params *mmcsdParams);
239 
254 MMCSD_Handle MMCSD_open(uint32_t index, const MMCSD_Params *openParams);
255 
266 
280 
294 int32_t MMCSD_read(MMCSD_Handle handle, uint8_t *buf, uint32_t startBlk, uint32_t numBlks);
295 
309 int32_t MMCSD_write(MMCSD_Handle handle, uint8_t *buf, uint32_t startBlk, uint32_t numBlks);
310 
324 
338 
339 #ifdef __cplusplus
340 }
341 #endif
342 
343 #endif /* MMCSD_H_ */
MMCSD_Params_init
void MMCSD_Params_init(MMCSD_Params *mmcsdParams)
Initialize data structure with defaults.
MMCSD_Attrs::eventId
uint32_t eventId
Definition: mmcsd.h:149
MMCSD_Config::attrs
MMCSD_Attrs * attrs
Definition: mmcsd.h:200
MMCSD_Attrs::baseAddr
uint32_t baseAddr
Definition: mmcsd.h:137
gMmcsdConfig
MMCSD_Config gMmcsdConfig[]
Externally defined driver configuration array.
MMCSD_Handle
void * MMCSD_Handle
Definition: mmcsd.h:88
SystemP.h
MMCSD_Attrs::intrPriority
uint32_t intrPriority
Definition: mmcsd.h:145
MMCSD_Object::mmcsdLldInitObject
MMCSDLLD_InitObject mmcsdLldInitObject
Definition: mmcsd.h:181
MMCSD_getHandle
MMCSD_Handle MMCSD_getHandle(uint32_t index)
This function returns the handle of an open MMCSD Instance from the instance index.
MMCSD_Params::txnCallbackFxn
MMCSD_txnCallbackFxn txnCallbackFxn
Definition: mmcsd.h:128
MMCSD_Attrs::autoAssignMaxSpeed
bool autoAssignMaxSpeed
Definition: mmcsd.h:155
MMCSD_Object::txnCallbackFxn
MMCSD_txnCallbackFxn txnCallbackFxn
Definition: mmcsd.h:186
mmcsd_lld.h
MMCSD LLD Driver API/interface file.
MMCSD_read
int32_t MMCSD_read(MMCSD_Handle handle, uint8_t *buf, uint32_t startBlk, uint32_t numBlks)
Function to perform block reads from the MMC/SD media.
MMCSD_Object::xferCompleteSemObj
SemaphoreP_Object xferCompleteSemObj
Definition: mmcsd.h:173
MMCSD_open
MMCSD_Handle MMCSD_open(uint32_t index, const MMCSD_Params *openParams)
This function opens a given MMCSD peripheral.
SemaphoreP.h
MMCSD_deinit
void MMCSD_deinit(void)
This function de-initializes the MMCSD module.
MMCSD_Config::object
MMCSD_Object * object
Definition: mmcsd.h:202
MMCSD_Object::isOpen
bool isOpen
Definition: mmcsd.h:169
MMCSD_Object::cardType
uint32_t cardType
Definition: mmcsd.h:167
MMCSD_getBlockCount
uint32_t MMCSD_getBlockCount(MMCSD_Handle handle)
This function returns the block count of User Data Area of the MMC/SD media connected to the MMCSD co...
MMCSD_Attrs::busWidth
uint32_t busWidth
Definition: mmcsd.h:153
MMCSD_Object::mmcsdLldHandle
MMCSDLLD_Handle mmcsdLldHandle
Definition: mmcsd.h:179
MMCSDLLD_InitObject
MMCSD Driver Initialization Object.
Definition: mmcsd_lld.h:323
MMCSD_Attrs::inputClk
uint32_t inputClk
Definition: mmcsd.h:139
MMCSD_Attrs::cardType
uint32_t cardType
Definition: mmcsd.h:151
MMCSD_Object::mmcsdLldObject
MMCSDLLD_Object mmcsdLldObject
Definition: mmcsd.h:177
MMCSD_Object::mutex
SemaphoreP_Object mutex
Definition: mmcsd.h:171
HwiP.h
MMCSD_Attrs::intrNum
uint32_t intrNum
Definition: mmcsd.h:147
MMCSDLLD_Object
MMCSD Driver Object.
Definition: mmcsd_lld.h:356
MMCSD_Attrs::enableDma
bool enableDma
Definition: mmcsd.h:141
MMCSD_Object::hwiObj
HwiP_Object hwiObj
Definition: mmcsd.h:175
MMCSD_Params::dataBuf
uint8_t * dataBuf
Definition: mmcsd.h:124
MMCSD_Attrs::intrEnable
bool intrEnable
Definition: mmcsd.h:143
MMCSD_write
int32_t MMCSD_write(MMCSD_Handle handle, uint8_t *buf, uint32_t startBlk, uint32_t numBlks)
Function to perform block writes to the MMC/SD media.
MMCSD_Params
MMCSD instance attributes - used during initialization.
Definition: mmcsd.h:117
MMCSD_getBlockSize
uint32_t MMCSD_getBlockSize(MMCSD_Handle handle)
This function returns the block size of the MMC/SD media connected to the MMCSD controller.
MMCSD_Object
MMCSD driver object.
Definition: mmcsd.h:166
HwiP_Object
Opaque Hwi object used with the Hwi APIs.
Definition: HwiP.h:93
MMCSD_Params::deviceData
void * deviceData
Definition: mmcsd.h:120
MMCSD_Attrs::uaBusSpeed
uint32_t uaBusSpeed
Definition: mmcsd.h:157
MMCSD_close
void MMCSD_close(MMCSD_Handle handle)
Function to close a MMCSD peripheral specified by the MMCSD handle.
MMCSD_Config
MMCSD Global configuration.
Definition: mmcsd.h:199
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
MMCSD_Attrs
MMCSD instance attributes - used during init time.
Definition: mmcsd.h:136
MMCSD_Params::transferMode
uint8_t transferMode
Definition: mmcsd.h:126
gMmcsdConfigNum
uint32_t gMmcsdConfigNum
Externally defined driver configuration array size.
MMCSD_Object::transferMode
uint32_t transferMode
Definition: mmcsd.h:184
MMCSD_txnCallbackFxn
void(* MMCSD_txnCallbackFxn)(MMCSD_Handle mmcsdHandle, int32_t transferStatus)
MMCSD callback function.
Definition: mmcsd.h:106
MMCSD_init
void MMCSD_init(void)
This function initializes the MMCSD module.