Skip to content

Commit 5eb6702

Browse files
ArcaneNibbledlech
authored andcommitted
lib/tiam1808: Add functions to set PRU constant table
1 parent 49f716f commit 5eb6702

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

lib/tiam1808/drivers/pruss.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,53 @@ void PRUSSDRVIntcSetHmr(unsigned short channel,
332332
| (((host) & 0xF) << (((channel) & 0x3) << 3));
333333
}
334334

335+
/**
336+
* \brief Set PRU constant table entries
337+
*
338+
* \param pruNum PRU instance number[0 or 1].
339+
* \param ctable_idx Index into constants table
340+
* \param value Value to set
341+
*
342+
* \return 0 in case of success, -1 otherwise.
343+
*/
344+
int PRUSSDRVPruSetCTable(unsigned int pruNum,
345+
unsigned int ctable_idx,
346+
unsigned int value)
347+
{
348+
unsigned int regAddr;
349+
350+
if(pruNum == 0)
351+
regAddr = PRU0CONTROL_PHYS_BASE;
352+
else if(pruNum == 1)
353+
regAddr = PRU1CONTROL_PHYS_BASE;
354+
else
355+
return -1;
356+
357+
switch (ctable_idx) {
358+
case 24:
359+
HWREG(regAddr + PRU_CONTABBLKIDX0) = (HWREG(regAddr + PRU_CONTABBLKIDX0) & ~0xf) | (value & 0xf);
360+
break;
361+
case 25:
362+
HWREG(regAddr + PRU_CONTABBLKIDX0) = (HWREG(regAddr + PRU_CONTABBLKIDX0) & ~0xf0000) | ((value & 0xf) << 16);
363+
break;
364+
case 28:
365+
HWREG(regAddr + PRU_CONTABPROPTR0) = (HWREG(regAddr + PRU_CONTABPROPTR0) & ~0xffff) | (value & 0xffff);
366+
break;
367+
case 29:
368+
HWREG(regAddr + PRU_CONTABPROPTR0) = (HWREG(regAddr + PRU_CONTABPROPTR0) & ~0xffff0000) | ((value & 0xffff) << 16);
369+
break;
370+
case 30:
371+
HWREG(regAddr + PRU_CONTABPROPTR1) = (HWREG(regAddr + PRU_CONTABPROPTR1) & ~0xffff) | (value & 0xffff);
372+
break;
373+
case 31:
374+
HWREG(regAddr + PRU_CONTABPROPTR1) = (HWREG(regAddr + PRU_CONTABPROPTR1) & ~0xffff0000) | ((value & 0xffff) << 16);
375+
break;
376+
default:
377+
return -1;
378+
}
379+
return 0;
380+
}
381+
335382
void ICSS_Init(void)
336383
{
337384
/* ICSS PRCM Enable */

lib/tiam1808/tiam1808/pruss.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ extern "C" {
9191
#define PRU1IRAM_PHYS_BASE 0x01C3C000
9292
#endif
9393

94+
/*
95+
* PRUSS control and status registers offsets
96+
*/
97+
#define PRU_CONTABBLKIDX0 0x20
98+
#define PRU_CONTABPROPTR0 0x28
99+
#define PRU_CONTABPROPTR1 0x2C
100+
94101
#define PRU_EVTOUT_0 0
95102
#define PRU_EVTOUT_1 1
96103
#define PRU_EVTOUT_2 2
@@ -258,6 +265,10 @@ void PRUSSDRVIntcSetCmr(unsigned short sysevt,
258265
void PRUSSDRVIntcSetHmr(unsigned short channel,
259266
unsigned short host);
260267

268+
int PRUSSDRVPruSetCTable(unsigned int pruNum,
269+
unsigned int ctable_idx,
270+
unsigned int value);
271+
261272
void ICSS_Init(void);
262273

263274
// #ifdef AM33XX

0 commit comments

Comments
 (0)