AM243x MCU+ SDK  11.00.00
ram.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021-2024 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 
33 #ifndef RAM_H_
34 #define RAM_H_
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 #include <stdint.h>
42 #include <kernel/dpl/SystemP.h>
43 #include <drivers/hw_include/soc_config.h>
44 
57 typedef void *Ram_Handle;
58 
62 typedef struct Ram_Config_s Ram_Config;
63 
67 typedef struct Ram_Params_s Ram_Params;
68 
69 typedef struct Ram_Devconfig_s
70 {
71  uint8_t cmdRd;
72  uint8_t cmdWr;
73  uint8_t cmdReset;
74  uint8_t cmdRegRd;
75  uint8_t cmdRegWr;
76  uint8_t dummyClksRd;
77  uint8_t dummyClksWr;
78  uint8_t dummyClksCmd;
79 
81 
82 typedef struct Ram_Attrs_s {
83 
84  uint32_t ramType;
85  char *ramName;
86  uint32_t deviceId;
87  uint32_t manufacturerId;
88  uint32_t driverInstance;
89  uint32_t ramSize;
91 } Ram_Attrs;
92 
109 typedef int32_t (*Ram_OpenFxn)(Ram_Config *config);
110 
121 typedef void (*Ram_CloseFxn)(Ram_Config *config);
122 
136 typedef int32_t (*Ram_ReadFxn)(Ram_Config *config, uint32_t offset,
137  uint8_t *buf, uint32_t len) ;
138 
152 typedef int32_t (*Ram_WriteFxn)(Ram_Config *config, uint32_t offset,
153  uint8_t *buf, uint32_t len) ;
154 
158 typedef struct Ram_Fxns_s
159 {
164 } Ram_Fxns;
165 
169 typedef struct Ram_Config_s
170 {
174  void *object;
176 } Ram_Config;
177 
194 typedef int32_t (*Ram_quirksFxn)(Ram_Config *config);
195 
203 typedef int32_t (*Ram_custProtocolFxn)(Ram_Config *config);
204 
211 typedef struct Ram_Params_s {
212 
215 
216 } Ram_Params;
217 
218 #if defined (DRV_VERSION_RAM_V0)
219 #include <board/ram/gpmc/psram_gpmc.h>
220 #endif
221 
222 #if defined (DRV_VERSION_RAM_V0) && defined (DRV_VERSION_OSPI_V0)
223 #include <board/ram/ospi/psram_ospi.h>
224 #endif
225 
226 Ram_Attrs *Ram_getAttrs(uint32_t instanceId);
227 
243 Ram_Handle Ram_open(uint32_t instanceId, Ram_Params *params);
244 
250 void Ram_close(Ram_Handle handle);
251 
262 int32_t Ram_write(Ram_Handle handle, uint32_t offset, uint8_t *buf, uint32_t len);
263 
274 int32_t Ram_read(Ram_Handle handle, uint32_t offset, uint8_t *buf, uint32_t len);
275 
279 #ifdef __cplusplus
280 }
281 #endif
282 
283 #endif /* RAM_H_ */
Ram_Fxns
Driver implementation callbacks.
Definition: ram.h:159
Ram_Attrs::ramName
char * ramName
Definition: ram.h:85
Ram_DevConfig::dummyClksWr
uint8_t dummyClksWr
Definition: ram.h:77
Ram_open
Ram_Handle Ram_open(uint32_t instanceId, Ram_Params *params)
Open RAM driver.
Ram_quirksFxn
int32_t(* Ram_quirksFxn)(Ram_Config *config)
Ram device config. This will be part of the ram config, so has to be filled by sysconfig or otherwise...
Definition: ram.h:194
Ram_DevConfig::cmdRegRd
uint8_t cmdRegRd
Definition: ram.h:74
Ram_Attrs::driverInstance
uint32_t driverInstance
Definition: ram.h:88
SystemP.h
Ram_getAttrs
Ram_Attrs * Ram_getAttrs(uint32_t instanceId)
Ram_WriteFxn
int32_t(* Ram_WriteFxn)(Ram_Config *config, uint32_t offset, uint8_t *buf, uint32_t len)
Driver implementation to write to RAM using specific RAM driver.
Definition: ram.h:152
Ram_Fxns::readFxn
Ram_ReadFxn readFxn
Definition: ram.h:162
Ram_Attrs
Definition: ram.h:82
Ram_Config
struct Ram_Config_s Ram_Config
Forward declaration of Ram_Config.
Definition: ram.h:62
Ram_custProtocolFxn
int32_t(* Ram_custProtocolFxn)(Ram_Config *config)
User implementation of a custom function to configure RAM to operate in a specific protocol.
Definition: ram.h:203
Ram_Attrs::deviceId
uint32_t deviceId
Definition: ram.h:86
Ram_Fxns::writeFxn
Ram_WriteFxn writeFxn
Definition: ram.h:163
Ram_read
int32_t Ram_read(Ram_Handle handle, uint32_t offset, uint8_t *buf, uint32_t len)
Read data from RAM device.
Ram_DevConfig::cmdWr
uint8_t cmdWr
Definition: ram.h:72
Ram_DevConfig::dummyClksCmd
uint8_t dummyClksCmd
Definition: ram.h:78
Ram_Attrs::manufacturerId
uint32_t manufacturerId
Definition: ram.h:87
Ram_Config::devConfig
Ram_DevConfig * devConfig
Definition: ram.h:173
Ram_Attrs::ramType
uint32_t ramType
Definition: ram.h:84
Ram_CloseFxn
void(* Ram_CloseFxn)(Ram_Config *config)
Driver implementation to close a specific RAM driver.
Definition: ram.h:121
Ram_Fxns::openFxn
Ram_OpenFxn openFxn
Definition: ram.h:160
Ram_Config::fxns
Ram_Fxns * fxns
Definition: ram.h:172
Ram_Params
Parameters passed during RAM_open()
Definition: ram.h:211
Ram_OpenFxn
int32_t(* Ram_OpenFxn)(Ram_Config *config)
Driver implementation to open a specific RAM driver.
Definition: ram.h:109
Ram_Params::quirksFxn
Ram_quirksFxn quirksFxn
Definition: ram.h:213
Ram_Config::object
void * object
Definition: ram.h:174
Ram_Fxns::closeFxn
Ram_CloseFxn closeFxn
Definition: ram.h:161
Ram_DevConfig::cmdReset
uint8_t cmdReset
Definition: ram.h:73
Ram_Config::attrs
Ram_Attrs * attrs
Definition: ram.h:171
Ram_Handle
void * Ram_Handle
Handle to the RAM driver returned by Ram_open()
Definition: ram.h:57
Ram_DevConfig
Definition: ram.h:70
Ram_DevConfig::cmdRd
uint8_t cmdRd
Definition: ram.h:71
Ram_DevConfig::cmdRegWr
uint8_t cmdRegWr
Definition: ram.h:75
Ram_write
int32_t Ram_write(Ram_Handle handle, uint32_t offset, uint8_t *buf, uint32_t len)
Write to RAM device.
Ram_ReadFxn
int32_t(* Ram_ReadFxn)(Ram_Config *config, uint32_t offset, uint8_t *buf, uint32_t len)
Driver implementation to read from RAM using a specific RAM driver.
Definition: ram.h:136
Ram_Attrs::ramSize
uint32_t ramSize
Definition: ram.h:89
Ram_Params::custProtoFxn
Ram_custProtocolFxn custProtoFxn
Definition: ram.h:214
Ram_close
void Ram_close(Ram_Handle handle)
Close RAM driver.
Ram_Config
Ram driver configuration, these are filled by SysCfg based on the ram device that is selected.
Definition: ram.h:170
Ram_Params
struct Ram_Params_s Ram_Params
Forward declaration of Ram_Params.
Definition: ram.h:67
Ram_DevConfig::dummyClksRd
uint8_t dummyClksRd
Definition: ram.h:76