AM243x MCU+ SDK  10.01.00
mmcsd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021-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 
55 #ifndef MMCSD_H_
56 #define MMCSD_H_
57 
58 /* ========================================================================== */
59 /* Include Files */
60 /* ========================================================================== */
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 #include <stdint.h>
66 #include <kernel/dpl/SystemP.h>
67 #include <kernel/dpl/SemaphoreP.h>
68 #include <kernel/dpl/HwiP.h>
69 #include <drivers/hw_include/csl_types.h>
70 #include <drivers/hw_include/cslr_mmcsd.h>
72 
73 /* ========================================================================== */
74 /* Macros & Typedefs */
75 /* ========================================================================== */
76 
87 #define MMCSD_MODE_BLOCKING ((uint32_t) 0U)
88 #define MMCSD_MODE_CALLBACK ((uint32_t) 1U)
89 
92 typedef void* MMCSD_Handle;
93 
94 /* ========================================================================== */
95 /* Function Pointers Declarations */
96 /* ========================================================================== */
97 
110 typedef void (*MMCSD_txnCallbackFxn) (MMCSD_Handle mmcsdHandle,
111  int32_t transferStatus);
112 
113 /* ========================================================================== */
114 /* Structure Declarations */
115 /* ========================================================================== */
116 
120 typedef struct
121 {
124  void *deviceData;
125  /* Pointer to a 512 byte dataBuffer used for temporary data transactions
126  * internal to driver like ECSD read, tuning etc.
127  * To be allocated by application */
128  uint8_t *dataBuf;
130  uint8_t transferMode;
133 
134 } MMCSD_Params;
135 
139 typedef struct
140 {
141  uint32_t ctrlBaseAddr;
143  uint32_t ssBaseAddr;
145  uint32_t inputClkFreq;
147  bool enableDma;
151  uint32_t intrNum;
153  uint32_t eventId;
155  uint32_t cardType;
157  uint32_t busWidth;
159  uint32_t phyType;
161  uint32_t tuningType;
165  uint32_t uaBusSpeed;
167  uint32_t slotType;
171  uint32_t intrPriority;
174 } MMCSD_Attrs;
175 
179 typedef struct
180 {
181  uint32_t cardType;
183  bool isOpen;
199  uint32_t transferMode;
204 } MMCSD_Object;
205 
213 typedef struct
214 {
219 } MMCSD_Config;
220 
221 /* ========================================================================== */
222 /* Externs */
223 /* ========================================================================== */
224 
226 extern MMCSD_Config gMmcsdConfig[];
228 extern uint32_t gMmcsdConfigNum;
229 
230 /* ========================================================================== */
231 /* Function Declarations */
232 /* ========================================================================== */
233 
237 void MMCSD_init(void);
238 
242 void MMCSD_deinit(void);
243 
249 void MMCSD_Params_init(MMCSD_Params *mmcsdParams);
250 
265 MMCSD_Handle MMCSD_open(uint32_t index, const MMCSD_Params *openParams);
266 
277 
291 
305 int32_t MMCSD_read(MMCSD_Handle handle, uint8_t *buf, uint32_t startBlk, uint32_t numBlks);
306 
320 int32_t MMCSD_write(MMCSD_Handle handle, uint8_t *buf, uint32_t startBlk, uint32_t numBlks);
321 
335 
349 
362 uint32_t MMCSD_isHC(MMCSD_Handle handle);
363 
375 int32_t MMCSD_change_Bus_Config(MMCSD_Handle handle, uint32_t busSpeed,
376  uint32_t busWidth);
377 
388 int32_t MMCSD_change_Tuning_Type(MMCSD_Handle handle, uint32_t tuningType);
389 
403 int32_t MMCSD_enableBootPartition(MMCSD_Handle handle, uint32_t partitionNum);
404 
418 
421 #ifdef __cplusplus
422 }
423 #endif
424 #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
gMmcsdConfig
MMCSD_Config gMmcsdConfig[]
Externally defined driver configuration array.
MMCSD_Handle
void * MMCSD_Handle
Definition: mmcsd.h:92
MMCSD_change_Bus_Config
int32_t MMCSD_change_Bus_Config(MMCSD_Handle handle, uint32_t busSpeed, uint32_t busWidth)
This function reconfigures the bus Configuration.
index
uint16_t index
Definition: tisci_rm_proxy.h:3
SystemP.h
MMCSD_Attrs::intrPriority
uint32_t intrPriority
Definition: mmcsd.h:171
MMCSD_Object::mmcsdLldInitObject
MMCSDLLD_InitObject mmcsdLldInitObject
Definition: mmcsd.h:195
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:132
MMCSD_Attrs::autoAssignMaxSpeed
bool autoAssignMaxSpeed
Definition: mmcsd.h:163
MMCSD_Object::txnCallbackFxn
MMCSD_txnCallbackFxn txnCallbackFxn
Definition: mmcsd.h:201
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:187
MMCSD_open
MMCSD_Handle MMCSD_open(uint32_t index, const MMCSD_Params *openParams)
This function opens a given MMCSD peripheral.
MMCSD_Attrs::ssBaseAddr
uint32_t ssBaseAddr
Definition: mmcsd.h:143
SemaphoreP.h
MMCSD_Attrs::inputClkFreq
uint32_t inputClkFreq
Definition: mmcsd.h:145
MMCSD_deinit
void MMCSD_deinit(void)
This function de-initializes the MMCSD module.
MMCSD_Config::object
MMCSD_Object * object
Definition: mmcsd.h:217
MMCSD_Object::isOpen
bool isOpen
Definition: mmcsd.h:183
MMCSD_Object::cardType
uint32_t cardType
Definition: mmcsd.h:181
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:193
MMCSD_Attrs::pllEnableSD
bool pllEnableSD
Definition: mmcsd.h:169
MMCSDLLD_InitObject
MMCSD Driver Initialization Object.
Definition: mmcsd_lld.h:399
MMCSD_enableBootPartition
int32_t MMCSD_enableBootPartition(MMCSD_Handle handle, uint32_t partitionNum)
This function enables the boot partition if the connected media is eMMC.
MMCSD_Config::attrs
const MMCSD_Attrs * attrs
Definition: mmcsd.h:215
MMCSD_Attrs::cardType
uint32_t cardType
Definition: mmcsd.h:155
MMCSD_isHC
uint32_t MMCSD_isHC(MMCSD_Handle handle)
This function returns if the media connected is High Capacity (> 2GB in size) or not.
MMCSD_Object::mmcsdLldObject
MMCSDLLD_Object mmcsdLldObject
Definition: mmcsd.h:191
MMCSD_Object::mutex
SemaphoreP_Object mutex
Definition: mmcsd.h:185
HwiP.h
MMCSD_Attrs::intrNum
uint32_t intrNum
Definition: mmcsd.h:151
MMCSDLLD_Object
MMCSD Driver Object.
Definition: mmcsd_lld.h:445
MMCSD_Attrs::enableDma
bool enableDma
Definition: mmcsd.h:147
MMCSD_Object::hwiObj
HwiP_Object hwiObj
Definition: mmcsd.h:189
MMCSD_Attrs::phyType
uint32_t phyType
Definition: mmcsd.h:159
MMCSD_Attrs::ctrlBaseAddr
uint32_t ctrlBaseAddr
Definition: mmcsd.h:141
MMCSD_Params::dataBuf
uint8_t * dataBuf
Definition: mmcsd.h:128
MMCSD_Attrs::intrEnable
bool intrEnable
Definition: mmcsd.h:149
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:121
MMCSD_change_Tuning_Type
int32_t MMCSD_change_Tuning_Type(MMCSD_Handle handle, uint32_t tuningType)
This function reconfigures the bus Configuration.
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_Attrs::slotType
uint32_t slotType
Definition: mmcsd.h:167
MMCSD_Object
MMCSD driver object.
Definition: mmcsd.h:180
HwiP_Object
Opaque Hwi object used with the Hwi APIs.
Definition: HwiP.h:93
MMCSD_Params::deviceData
void * deviceData
Definition: mmcsd.h:124
MMCSD_Attrs::uaBusSpeed
uint32_t uaBusSpeed
Definition: mmcsd.h:165
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:214
SemaphoreP_Object
Opaque semaphore object used with the semaphore APIs.
Definition: SemaphoreP.h:59
MMCSD_disableBootPartition
int32_t MMCSD_disableBootPartition(MMCSD_Handle handle)
This function disables the boot partition if the connected media is eMMC.
MMCSD_Attrs
MMCSD instance attributes - used during init time.
Definition: mmcsd.h:140
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:199
MMCSD_txnCallbackFxn
void(* MMCSD_txnCallbackFxn)(MMCSD_Handle mmcsdHandle, int32_t transferStatus)
MMCSD callback function.
Definition: mmcsd.h:110
MMCSD_Attrs::tuningType
uint32_t tuningType
Definition: mmcsd.h:161
MMCSD_init
void MMCSD_init(void)
This function initializes the MMCSD module.