1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
|
/*
* Copyright (c) 2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** ============================================================================
* @file pruicss.h
*
* @brief pruicss driver interface
*
* The pruss header file should be included in an application as follows:
* @code
* #include <ti/drv/pruss/pruss.h>
* @endcode
*
* ============================================================================
*/
#ifndef ti_drivers_PRUICSS__include
#define ti_drivers_PRUICSS__include
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#define PRUICSS_NUM_PRU_HOSTS (10U)
#define PRUICSS_NUM_PRU_CHANNELS (10U)
#define PRUICSS_NUM_PRU_SYS_EVTS (64U)
#define PRUICSS_MAX_WAIT_EVENTS (10U)
#define PRUICSS_PRU0_DATARAM (0U)
#define PRUICSS_PRU1_DATARAM (1U)
#define PRUICSS_PRU0_IRAM (2U)
#define PRUICSS_PRU1_IRAM (3U)
#define PRUICSS_SHARED_DATARAM (4U)
#define PRUICSS_CFG (5U)
#define PRUICSS_UART (6U)
#define PRUICSS_IEP (7U)
#define PRUICSS_ECAP (8U)
#define PRUICSS_MII_RT (9U)
#define PRUICSS_MDIO (10U)
/**< Invalid Intc Mux number, intc Mux not used if assigned PRUSS_INVALID_INTC_MUX_NUM */
#define PRUSS_INVALID_INTC_MUX_NUM ((uint32_t)0xffff)
/*!
* @brief PRUICSS Instance IDs
*/
typedef enum PRUICSS_MaxInstances_s
{
PRUICCSS_INSTANCE_ONE=1,
PRUICCSS_INSTANCE_TWO=2,
PRUICCSS_INSTANCE_MAX=3
}PRUICSS_MaxInstances;
/** \brief Interrupt handler */
typedef void (*PRUICSSDRV_IRQ_HANDLER)(void* buf);
typedef struct PRUICSS_Config_s *PRUICSS_Handle;
/*!
* @brief PRUICSS Constant Table Register Entries
*/
typedef enum PRUICSS_ConstTblEntry_s
{
PRUICCSS_ConstTblEntryC24,
PRUICCSS_ConstTblEntryC25,
PRUICCSS_ConstTblEntryC26,
PRUICCSS_ConstTblEntryC27,
PRUICCSS_ConstTblEntryC28,
PRUICCSS_ConstTblEntryC29,
PRUICCSS_ConstTblEntryC30,
PRUICCSS_ConstTblEntryC31,
PRUICCSS_ConstTblEntryMax
}PRUICSS_ConstTblEntry;
/***********************************************************************
* Macros to support dynamic chip detecting feature
***********************************************************************/
typedef void *(*prussdrv_function_handler) (void * buf);
/*!
* @brief PRUICSS system to channel map
*
*/
typedef struct PRUICSS_SysevtToChannelMap_s
{
uint8_t sysevt; /*System event number */
uint8_t channel; /*Channel number */
uint8_t polarity; /*Interrupt polarity [ 0 - active low , 1 - active high ] */
uint8_t type; /*Interrupt type [ 0 - level or pulse interrupt , 1 - edge interrupt ] */
}PRUICSS_SysevtToChannelMap;
/*!
* @brief PRUICSS channel to host map
*
*/
typedef struct PRUICSS_ChannelToHostMap_s
{
int16_t channel;
int16_t host;
}PRUICSS_ChannelToHostMap;
/*!
* @brief PRUICSS Interrupt controller initialisation data structure
*
*/
typedef struct PRUICSS_IntcInitData_s
{
/*Enabled SYSEVTs - Range:0..63
{-1} indicates end of list*/
int8_t sysevts_enabled[PRUICSS_NUM_PRU_SYS_EVTS];
/*SysEvt to Channel map. SYSEVTs - Range:0..63 Channels -Range: 0..9
{-1, -1} indicates end of list*/
PRUICSS_SysevtToChannelMap sysevt_to_channel_map[PRUICSS_NUM_PRU_SYS_EVTS];
/*Channel to Host map.Channels -Range: 0..9 HOSTs - Range:0..9
{-1, -1} indicates end of list*/
PRUICSS_ChannelToHostMap channel_to_host_map[PRUICSS_NUM_PRU_CHANNELS];
/*10-bit mask - Enable Host0-Host9 {Host0/1:PRU0/1, Host2..9 : PRUEVT_OUT0..7)*/
uint32_t host_enable_bitmask;
}PRUICSS_IntcInitData;
/*!
* @brief brief PRUICSS Global configuration
*
*/
typedef struct PRUICSS_Config_s {
/*! Pointer to a driver specific data object */
void *object;
/*! Pointer to a driver specific hardware attributes structure */
void const *hwAttrs;
} PRUICSS_Config;
extern PRUICSS_Config pruss_config[];
/*!
* @brief brief PRUICSS IRQ handlers mapping
*
*/
typedef struct PRUICSS_IrqFunMap_s
{
PRUICSSDRV_IRQ_HANDLER irqHandler;
/**< Interrupt handler*/
void* semHandle;
/**< Binary semaphore to wait on */
void* handle;
}PRUICSS_IrqFunMap;
/**
* \brief PRU Firmware binary header
*
*/
typedef struct PRUICSS_FirmwareBinHeader_s
{
uint32_t image_size;
/**< Image size */
uint32_t load_addr;
/**< Address to which this binary need to be loaded */
uint32_t run_addr;
/**< Address at which the execution should start */
}PRUICSS_FirmwareBinHeader;
/*!
* @brief PRUICSS interrupt config structure
*
* Default interrrupt configuration parametetrs
*/
typedef struct PRUICSS_IntrCfg_s
{
uint32_t pruEvtoutNum; /**< PRU Event number */
uint8_t waitEnable; /**< Flag specifying whether application can wait on this interrupt
using PRUICSSPruWaitEvent function */
PRUICSSDRV_IRQ_HANDLER irqHandler; /**< Pointer to a function which will be called on interrupt.*/
/**< DSP: int vector number; ARM: GIC int number (peripheral event ID + 32) */
uint32_t intNum;
/**< CorePac specific Event ID, input to CorePac interrupt controller */
uint32_t eventId;
/**< intc mux number, Keystone inc mux is Chip Interrupt Controller
if assigned -1, system resource manager will decide the mux num */
int32_t intcMuxNum;
/**< intc mux input event ID, for Keystone, it is the input event to CIC
if assigned -1, system resource manager will decide the mux input event ID */
int32_t intcMuxInEvent;
/**< intc mux output event ID, for Keystone, it is the Host interrupt num
if assigned -1, system resource manager will decide the mux output event ID */
int32_t intcMuxOutEvent;
}PRUICSS_IntrCfg;
typedef enum PRUICSS_Return_e
{
PRUICSS_RETURN_FAILURE = -1,
PRUICSS_RETURN_SUCCESS = 0
}PRUICSS_Return;
/**
* @brief This function creates the handle for the PRUICSS instance \n
*
* @param config configuration structure of PRUICSS.
* @param instance PRUICSS instance no.
*
* @return PRUICSS handle. \n
*/
PRUICSS_Handle PRUICSS_create(PRUICSS_Config *config ,int32_t instance);
/**
* @brief This function Executes the program in the specified PRU \n
*
* @param handle Pruss's driver handle
* @param pruNum PRU instance number.\n
*
* @return 0 in case of successful transition, -1 otherwise. \n
*/
int32_t PRUICSS_pruExecProgram(PRUICSS_Handle handle,int32_t pruNum );
/**
* @brief Routine to
*
* @param handle Pruss's driver handle
* @param pru_instance PRU instance number
* @param spi_offset Offset on SPI flash to where this need to be flashed
*
*
* @return None.
*
**/
int8_t PRUICSS_loadBinary (PRUICSS_Handle handle, uint8_t pru_instance,uint32_t spi_offset);
/**
* @brief This function waits for a System event to happen \n
*
* @param handle Pruss's driver handle
* @param pruEvtoutNum The AINTC Event number.\n
*
* @return 0 in case of successful transition, -1 otherwise. \n
*/
int32_t PRUICSS_pruWaitEvent(PRUICSS_Handle handle,uint32_t pruEvtoutNum );
/**
* @brief This function does Interrupt-Channel-host mapping.
*
* @param handle Pruss's driver handle
* @param prussintc_init_data The pointer to structure containing mapping information.
*
* @return 0 in case of successful transition, -1 otherwise. \n
*/
int32_t PRUICSS_pruIntcInit(PRUICSS_Handle handle, const PRUICSS_IntcInitData * prussintc_init_data);
/**
* \brief This function generates and INTC event, waits for AINTC event and
* clears an INTC event \n
*
* @param handle Pruss's driver handle
* @param sendEventNum Event number.\n
* @param pruEvtoutNum PRU Event number.\n
* @param ackEventNum Acknowlodegement event number.\n
*
* \return 0 in case of successful transition, -1 otherwise. \n
*/
int32_t PRUICSS_pruSendWaitCearEvent(PRUICSS_Handle handle,uint32_t sendEventNum,
uint32_t pruEvtoutNum,
uint32_t ackEventNum
);
/**
* @brief This function Registers an Interrupt Handler for an event.\n
*
* @param handle Pruss's driver handle
*
* @param pruEvtoutNum The ARM side event number.\n
*
* @param intrNum Interrupt number of MPU/C66x
*
* @param eventNum Event number of PRUICSS
*
* @param waitEnable Flag specifying whether application can wait on this interrupt
* using PRUICSSPruWaitEvent function
*
* @param irqHandler Pointer to a function which will be called on interrupt.\n
*
*
* \return 0 in case of successful registration, -1 otherwise. \n
*/
int32_t PRUICSS_registerIrqHandler(PRUICSS_Handle handle,uint32_t pruEvtoutNum,
int32_t intrNum,
int32_t eventNum,
uint8_t waitEnable,
PRUICSSDRV_IRQ_HANDLER irqHandler
);
/**
* @brief This function Registers an Interrupt Handler for an event.\n
*
* @param handle Pruss's driver handle
*
*
* @param intrCfg pointer to interrupt configuration parameter
*
* \return 0 in case of successful registration, -1 otherwise. \n
*/
int32_t PRUICSS_registerIrqHandler2(PRUICSS_Handle handle,
PRUICSS_IntrCfg* intrCfg);
/**
* @brief This function sets the buffer pointer for PRU. The contents of this buffer will be \n
* loaded to IRAM.\n
*
* @param handle Pruss's driver handle
* @param pruNum The PRU number.\n
* @param buffer Pointer to buffer.\n
* @param numBytes Number of bytes in the buffer.\n
*
* @return 0 in case of successful transition, -1 otherwise. \n
*/
int32_t PRUICSS_setPRUBuffer(PRUICSS_Handle handle,
uint32_t pruNum,
void *buffer,
uint32_t numBytes);
/**
* @brief Configure PIN_MUX_SEL
*
* @param handle Pruss's driver handle
* @param regVal value to be written
*
* @return None.
*
**/
void PRUICSS_pinMuxConfig(PRUICSS_Handle handle, uint64_t regVal);
/*The following are the static functions to be moved to .c file.*/
/**
* @brief Resets PRU: \n
*
* @param handle Pruss's driver handle
* @param pruNum PRU instance number[0 or 1].
*
* @return 0 in case of successful reset, -1 otherwise.
**/
int32_t PRUICSS_pruReset(PRUICSS_Handle handle ,uint8_t pruNum);
/**
* @brief Disables PRU: \n
*
* @param handle Pruss's driver handle
* @param pruNum PRU instance number[0 or 1].
*
* @return 0 in case of successful disable, -1 otherwise.
**/
int32_t PRUICSS_pruDisable(PRUICSS_Handle handle,uint8_t pruNum);
/**
* @brief Enables PRU: \n
*
* @param handle Pruss's driver handle
* @param pruNum PRU instance number[0 or 1].
*
* @return 0 in case of successful enable, -1 otherwise.
**/
int32_t PRUICSS_pruEnable(PRUICSS_Handle handle,uint8_t pruNum);
/**
*
* @brief This function writes the given data to PRU memory
*
* @param handle Pruss's driver handle
* @param pruMem PRU Memory Macro [DATARAM0_PHYS_BASE
* @param wordoffset Offset at which the write will happen.
* @param source_mem Source memory[ Array of uint32_tegers ]
* @param bytelength Total number of bytes to be writen
*
* pruMem can have values
* PRU0_DATARAM\n
* PRU0_IRAM\n
* PRU1_DATARAM\n
* PRU1_IRAM\n
* PRUICSS_SHARED_DATARAM
* @return word length written or 0 on error.
*
**/
int32_t PRUICSS_pruWriteMemory(PRUICSS_Handle handle,
uint32_t pruMem,
uint32_t wordoffset,
const uint32_t *source_mem,
uint32_t bytelength
);
/**
*
* @brief This function initializes the PRU memory to zero
*
* @param handle Pruss's driver handle
* @param pruMem PRU Memory Macro [DATARAM0_PHYS_BASE
*
* pruMem can have values
* PRU0_DATARAM\n
* PRU0_IRAM\n
* PRU1_DATARAM\n
* PRU1_IRAM\n
* PRUICSS_SHARED_DATARAM
* @return word length written or 0 on error.
*
**/
int32_t PRUICSS_pruInitMemory(PRUICSS_Handle handle,
uint32_t pruMem
);
/**
* @brief This function Generates an INTC event \n
*
* @param handle Pruss's driver handle
* @param eventnum The INTC Event number.\n
*
* @return 0 in case of successful transition, -1 otherwise. \n
**/
int32_t PRUICSS_pruSendEvent(PRUICSS_Handle handle,uint32_t eventnum);
/**
* @brief This function clears an INTC event \n
*
* @param handle Pruss's driver handle
* @param eventnum The INTC Event number.\n
*
* @return 0 in case of successful transition, -1 otherwise. \n
**/
int32_t PRUICSS_pruClearEvent(PRUICSS_Handle handle,uint32_t eventnum);
/**
* @brief This function returns the address of PRU components.
*
* @param handle Pruss's driver handle
* @param pru_ram_id PRU components' Id. \n
* @param address Memory to which address to be copied. \n
*
* @return 0 in case of success, -1 otherwise. \n
**/
int32_t PRUICSS_mapPruMem(PRUICSS_Handle handle,uint32_t pru_ram_id, void **address);
/**
* @brief This function returns the base address of peripheral IO modules.
*
* @param per_id Peripheral Module's Id.
*
* @param handle Pruss's driver handle
* @param address Memory to which address to be copied. \n
*
* @return 0 in case of success, -1 otherwise. \n
**/
int32_t PRUICSS_mapPeripheralIO(PRUICSS_Handle handle,uint32_t per_id, void **address);
void PRUICSS_enableOCPMasterAccess(PRUICSS_Handle handle );
/**
* @brief Detects the Chip Type \n
*
*/
uint32_t PRUICSS_detectHWVersion(void);
/**
* @brief Get PRU ICSS version \n
*
* @param handle Pruss's driver handle
*
* @return PRU ICSS version
**/
uint32_t PRUICSS_getICSSVersion(PRUICSS_Handle handle);
/**
* \brief This API gets the SoC level of PRUICSS intial configuration
*
* \param cfg Pointer to PRUICSS SOC initial config.
*
* \return 0 success
*
*/
int32_t PRUICSS_socGetInitCfg( PRUICSS_Config **cfg);
/**
* \brief This API sets the SoC level of PRUICSS intial configuration
*
* \param cfg Pointer to PRUICSS SOC initial config.
*
* \return 0 success
*
*/
int32_t PRUICSS_socSetInitCfg(PRUICSS_Config *cfg);
/**
* @brief This function clears all Interrupt-Channel-host mapping.
*
* @param handle Pruss's driver handle
*
* @return 0 in case of successful transition, -1 otherwise. \n
*/
int32_t PRUICSS_pruIntcClear(PRUICSS_Handle handle);
/**
* \brief This API updates the constant table for specified constant table entry
which have write permissions.
*
* @param handle Pruss's driver handle
* @param pruNum PRU number[0 or 1] for which constant table is being updated.
* @param constantTblEntry contant table entry being updated
* @param constantTblVal contant table value to be written
*
* \return 0 success, -1 on error
*
*/
int32_t PRUICSS_setConstantTblEntry(PRUICSS_Handle handle, uint8_t pruNum, int32_t constantTblEntry, uint32_t constantTblVal);
/**
* \brief This API configures the General Purpose Mux Selector field of
* the General Purpose Config Register (PRUSS_GPCFG)
*
* @param handle Pruss's driver handle
* @param pruNum PRU number[0 or 1].
* @param mode PRU-ICSS wrap mux selection
*
* \return 0 success, -1 on error
*
*/
int32_t PRUICSS_setGpMuxSel(PRUICSS_Handle handle, uint8_t pruNum, uint32_t mode);
/**
* \brief This API configures the source of the IEP clock to be either
* IEP CLK as the source or Interface Bus CLK as the source (such as OCP/ICLK/VCLK)
* This is accomplished by updating the IEP clock field of the General Purpose Config
* Register (PRUSS_GPCFG)
*
* @param handle Pruss's driver handle
* @param source source of the IEP clock (0 == IEP CLK, 1 == OCP/ICLK/VCLK)
*
* \return 0 success, -1 on error
*
*/
int32_t PRUICSS_setIepClkSrc(PRUICSS_Handle handle, uint32_t source);
#ifdef __cplusplus
}
#endif
#endif /* ti_drivers_PRUICSS__include */
|