AM263Px MCU+ SDK  11.00.00
mmcsd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022-2025 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 struct MMCSD_Config_s;
89 
90 typedef struct MMCSD_Config_s* MMCSD_Handle;
91 
92 /* ========================================================================== */
93 /* Function Pointers Declarations */
94 /* ========================================================================== */
95 
108 typedef void (*MMCSD_txnCallbackFxn) (MMCSD_Handle mmcsdHandle,
109  int32_t transferStatus);
110 
111 /* ========================================================================== */
112 /* Structures and Enums */
113 /* ========================================================================== */
114 
118 typedef struct
119 {
120  /* Pointer to eMMC/SD device data structure. Memory for this structure
121  has to be allocated in application */
122  void *deviceData;
123  /* Pointer to a 512 byte dataBuffer used for temporary data transactions
124  * internal to driver like ECSD read, tuning etc.
125  * To be allocated by application */
126  uint8_t *dataBuf;
128  uint32_t edmaInst;
130  uint8_t transferMode;
133 
134 } MMCSD_Params;
135 
139 typedef struct
140 {
141  uint32_t baseAddr;
143  uint32_t inputClk;
145  bool enableDma;
149  uint32_t intrPriority;
151  uint32_t intrNum;
153  uint32_t eventId;
155  uint32_t cardType;
157  uint32_t busWidth;
161  uint32_t uaBusSpeed;
164 } MMCSD_Attrs;
165 
169 typedef struct
170 {
171  uint32_t cardType;
173  bool isOpen;
175  SemaphoreP_Object mutex;
177  SemaphoreP_Object xferCompleteSemObj;
188  uint32_t transferMode;
193 } MMCSD_Object;
194 
202 typedef struct MMCSD_Config_s
203 {
208 } MMCSD_Config;
209 
210 /* ========================================================================== */
211 /* Externs */
212 /* ========================================================================== */
213 
215 extern MMCSD_Config gMmcsdConfig[];
217 extern uint32_t gMmcsdConfigNum;
218 
219 /* ========================================================================== */
220 /* Internal/Private Structure Declarations */
221 /* ========================================================================== */
222 
223 /* ========================================================================== */
224 /* Function Declarations */
225 /* ========================================================================== */
226 
230 void MMCSD_init(void);
231 
235 void MMCSD_deinit(void);
236 
242 void MMCSD_Params_init(MMCSD_Params *mmcsdParams);
243 
258 MMCSD_Handle MMCSD_open(uint32_t index, const MMCSD_Params *openParams);
259 
270 
284 
298 int32_t MMCSD_read(MMCSD_Handle handle, uint8_t *buf, uint32_t startBlk, uint32_t numBlks);
299 
313 int32_t MMCSD_write(MMCSD_Handle handle, uint8_t *buf, uint32_t startBlk, uint32_t numBlks);
314 
328 
342 
343 #ifdef __cplusplus
344 }
345 #endif
346 
347 #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:153
MMCSD_Config::attrs
MMCSD_Attrs * attrs
Definition: mmcsd.h:204
MMCSD_Attrs::baseAddr
uint32_t baseAddr
Definition: mmcsd.h:141
gMmcsdConfig
MMCSD_Config gMmcsdConfig[]
Externally defined driver configuration array.
SystemP.h
MMCSD_Attrs::intrPriority
uint32_t intrPriority
Definition: mmcsd.h:149
MMCSD_Object::mmcsdLldInitObject
MMCSDLLD_InitObject mmcsdLldInitObject
Definition: mmcsd.h:185
MMCSD_getHandle
MMCSD_Handle MMCSD_getHandle(uint32_t index)
This function returns the handle of an open MMCSD Instance from the instance index.
MMCSD_Handle
struct MMCSD_Config_s * MMCSD_Handle
Definition: mmcsd.h:90
MMCSD_Params::txnCallbackFxn
MMCSD_txnCallbackFxn txnCallbackFxn
Definition: mmcsd.h:132
MMCSD_Attrs::autoAssignMaxSpeed
bool autoAssignMaxSpeed
Definition: mmcsd.h:159
MMCSD_Object::txnCallbackFxn
MMCSD_txnCallbackFxn txnCallbackFxn
Definition: mmcsd.h:190
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:177
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:206
MMCSD_Object::isOpen
bool isOpen
Definition: mmcsd.h:173
MMCSD_Object::cardType
uint32_t cardType
Definition: mmcsd.h:171
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:157
MMCSD_Object::mmcsdLldHandle
MMCSDLLD_Handle mmcsdLldHandle
Definition: mmcsd.h:183
MMCSDLLD_InitObject
MMCSD Driver Initialization Object.
Definition: mmcsd_lld.h:355
MMCSD_Attrs::inputClk
uint32_t inputClk
Definition: mmcsd.h:143
MMCSD_Attrs::cardType
uint32_t cardType
Definition: mmcsd.h:155
MMCSD_Object::mmcsdLldObject
MMCSDLLD_Object mmcsdLldObject
Definition: mmcsd.h:181
MMCSD_Object::mutex
SemaphoreP_Object mutex
Definition: mmcsd.h:175
HwiP.h
MMCSD_Attrs::intrNum
uint32_t intrNum
Definition: mmcsd.h:151
MMCSDLLD_Object
MMCSD Driver Object.
Definition: mmcsd_lld.h:389
MMCSD_Attrs::enableDma
bool enableDma
Definition: mmcsd.h:145
MMCSD_Object::hwiObj
HwiP_Object hwiObj
Definition: mmcsd.h:179
MMCSD_Params::dataBuf
uint8_t * dataBuf
Definition: mmcsd.h:126
MMCSD_Attrs::intrEnable
bool intrEnable
Definition: mmcsd.h:147
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:119
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:170
HwiP_Object
Opaque Hwi object used with the Hwi APIs.
Definition: HwiP.h:142
MMCSD_Params::deviceData
void * deviceData
Definition: mmcsd.h:122
MMCSD_Attrs::uaBusSpeed
uint32_t uaBusSpeed
Definition: mmcsd.h:161
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:203
MMCSD_Attrs
MMCSD instance attributes - used during init time.
Definition: mmcsd.h:140
MMCSD_Params::edmaInst
uint32_t edmaInst
Definition: mmcsd.h:128
MMCSD_Params::transferMode
uint8_t transferMode
Definition: mmcsd.h:130
gMmcsdConfigNum
uint32_t gMmcsdConfigNum
Externally defined driver configuration array size.
MMCSD_Object::transferMode
uint32_t transferMode
Definition: mmcsd.h:188
MMCSD_txnCallbackFxn
void(* MMCSD_txnCallbackFxn)(MMCSD_Handle mmcsdHandle, int32_t transferStatus)
MMCSD callback function.
Definition: mmcsd.h:108
MMCSD_init
void MMCSD_init(void)
This function initializes the MMCSD module.