summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Livingston2019-06-28 10:09:36 -0500
committerFrank Livingston2019-06-28 10:09:36 -0500
commit0ed1f3a71ac469a61bcd08fd7675590bf1452e0b (patch)
treee792c1ecffa66a4075c1c75a91ad13fe94471285
parent278a7d0f7ef2e3add42cc2c4cb029481d63be826 (diff)
downloadpruss-lld-0ed1f3a71ac469a61bcd08fd7675590bf1452e0b.tar.gz
pruss-lld-0ed1f3a71ac469a61bcd08fd7675590bf1452e0b.tar.xz
pruss-lld-0ed1f3a71ac469a61bcd08fd7675590bf1452e0b.zip
PRSDK-5738:Update IEP PWM control
- Move IEPx global control bits from PWM object to IEP PWM control object - Add IEP0 & IEP1 clock synchronization in case IEP0 & 1 PWMs are both enabled Signed-off-by: Frank Livingston <frank-livingston@ti.com>
-rw-r--r--example/apps/icssg_pwm/firmware/src/iepPwm.c68
-rw-r--r--example/apps/icssg_pwm/firmware/src/iepPwm.h24
-rw-r--r--example/apps/icssg_pwm/firmware/src/main.c14
3 files changed, 83 insertions, 23 deletions
diff --git a/example/apps/icssg_pwm/firmware/src/iepPwm.c b/example/apps/icssg_pwm/firmware/src/iepPwm.c
index 7290eaa..6bd7cab 100644
--- a/example/apps/icssg_pwm/firmware/src/iepPwm.c
+++ b/example/apps/icssg_pwm/firmware/src/iepPwm.c
@@ -272,7 +272,6 @@ IcssgIepPwmCtrlObj gIcssgIepPwmCtrlObj; /* IEP PWM control object */
272IcssgIepPwmObj gIcssgIep0PwmObj; /* IEP 0 PWM object */ 272IcssgIepPwmObj gIcssgIep0PwmObj; /* IEP 0 PWM object */
273IcssgIepPwmObj gIcssgIep1PwmObj; /* IEP 1 PWM object */ 273IcssgIepPwmObj gIcssgIep1PwmObj; /* IEP 1 PWM object */
274 274
275
276/* State Machine function, perform LHS processing */ 275/* State Machine function, perform LHS processing */
277static void iepPwmLhs( 276static void iepPwmLhs(
278 IcssgIepPwmObj *pIcssgIepPwmObj 277 IcssgIepPwmObj *pIcssgIepPwmObj
@@ -552,11 +551,19 @@ static Int32 updateIepPwmCmpxShRegDb(
552 * External Functions * 551 * External Functions *
553 * ------------------------------------------------------------------------- */ 552 * ------------------------------------------------------------------------- */
554 553
555/* Reset PWM FW control */ 554/* Reset PWM FW control object */
556Int32 resetPwmCtrlFwRegs( 555Int32 resetPwmCtrlObj(
557 IcssgIepPwmCtrlObj *pIcssgIepPwmCtrlObj 556 IcssgIepPwmCtrlObj *pIcssgIepPwmCtrlObj
558) 557)
559{ 558{
559 Uint8 i;
560
561 for (i = 0; i < ICSSG_NUM_IEP; i++)
562 {
563 pIcssgIepPwmCtrlObj->iepPwmGblEn[i] = FALSE;
564 }
565
566 pIcssgIepPwmCtrlObj->pIcssgCfgHwRegs = (CSL_icss_g_pr1_cfg_slvRegs *)CSL_ICSS_CFG_BASE;
560 pIcssgIepPwmCtrlObj->pIepPwmCtrlFwRegs = (IepPwmCtrlFwRegs *)ICSSG_IEPPWM_PWM_CTRL_ADDR; 567 pIcssgIepPwmCtrlObj->pIepPwmCtrlFwRegs = (IepPwmCtrlFwRegs *)ICSSG_IEPPWM_PWM_CTRL_ADDR;
561 return IEP_STS_NERR; 568 return IEP_STS_NERR;
562} 569}
@@ -574,7 +581,6 @@ Int32 resetIepPwmObj(
574 581
575 memset(pIcssgIepPwmObj, 0, sizeof(IcssgIepPwmObj)); 582 memset(pIcssgIepPwmObj, 0, sizeof(IcssgIepPwmObj));
576 pIcssgIepPwmObj->iepId = iepId; 583 pIcssgIepPwmObj->iepId = iepId;
577 pIcssgIepPwmObj->iepPwmGblEn = FALSE;
578 if (iepId == IEP_ID_0) { 584 if (iepId == IEP_ID_0) {
579 pIcssgIepPwmObj->pIepPwmFwRegs = (IepPwmFwRegs *)ICSSG_PWM_IEP0_PWM_BASE_ADDR; 585 pIcssgIepPwmObj->pIepPwmFwRegs = (IepPwmFwRegs *)ICSSG_PWM_IEP0_PWM_BASE_ADDR;
580 pIcssgIepPwmObj->pIepHwRegs = (CSL_icss_g_pr1_iep1_slvRegs *)ICSS_IEP0_CFG_BASE; 586 pIcssgIepPwmObj->pIepHwRegs = (CSL_icss_g_pr1_iep1_slvRegs *)ICSS_IEP0_CFG_BASE;
@@ -613,6 +619,48 @@ Int32 resetIepPwmObj(
613 return IEP_STS_NERR; 619 return IEP_STS_NERR;
614} 620}
615 621
622/* Initialize PWM FW control */
623Int32 initPwmCtrl(
624 IcssgIepPwmCtrlObj *pIcssgIepPwmCtrlObj
625)
626{
627 IepPwmCtrlFwRegs *pIepPwmCtrlFwRegs = pIcssgIepPwmCtrlObj->pIepPwmCtrlFwRegs;
628 Bool iepSync;
629 volatile Uint32 iepClkReg;
630 Uint8 i;
631
632 iepSync = TRUE;
633 for (i = 0; i < ICSSG_NUM_IEP; i++)
634 {
635 /* Latch IEP PWM global enable.
636 Global enable can't change after Initialization. */
637 pIcssgIepPwmCtrlObj->iepPwmGblEn[i] =
638 (Bool)((pIepPwmCtrlFwRegs->PWM_CTRL >> i ) & IEP_PWM_GBL_EN_MASK);
639 /* Acknowledge IEP PWM global enable */
640 pIepPwmCtrlFwRegs->PWM_STAT |= (Uint32)pIcssgIepPwmCtrlObj->iepPwmGblEn[i] << i;
641
642 /* Update IEP clock synchronization flag.
643 All IEPs must be enabled for IEP clock synchronization to be enabled. */
644 iepSync = iepSync && pIcssgIepPwmCtrlObj->iepPwmGblEn[i];
645 }
646
647 if (iepSync == TRUE) {
648 /* Set IEP0 & 1 synchronization */
649
650 /* Read ICSSG_IEPCLK_REG HW register */
651 iepClkReg = pIcssgIepPwmCtrlObj->pIcssgCfgHwRegs->IEPCLK_REG;
652 /* ICSSG_IEPCLK_REG:IEP1_SLV_EN=0 */
653 iepClkReg &= ~CSL_ICSS_G_PR1_CFG_SLV_IEPCLK_REG_IEP1_SLV_EN_MASK;
654 /* ICSSG_IEPCLK_REG:IEP1_SLV_EN=1,
655 IEP1 Master Counter Slave enable is Enabled */
656 iepClkReg |= 1<< CSL_ICSS_G_PR1_CFG_SLV_IEPCLK_REG_IEP1_SLV_EN_SHIFT;
657 /* Write ICSSG_IEPCLK_REG HW register */
658 pIcssgIepPwmCtrlObj->pIcssgCfgHwRegs->IEPCLK_REG = iepClkReg;
659 }
660
661 return IEP_STS_NERR;
662}
663
616/* Initialize IEP PWM object 664/* Initialize IEP PWM object
617 * 665 *
618 * Initial Configuration is located in Host I/F FW Regs. 666 * Initial Configuration is located in Host I/F FW Regs.
@@ -628,7 +676,6 @@ Int32 initIepPwm(
628) 676)
629{ 677{
630 IepId iepId = pIcssgIepPwmObj->iepId; 678 IepId iepId = pIcssgIepPwmObj->iepId;
631 IepPwmCtrlFwRegs *pIepPwmCtrlFwRegs = pIcssgIepPwmCtrlObj->pIepPwmCtrlFwRegs;
632 IepPwmFwRegs *pIepPwmFwRegs = pIcssgIepPwmObj->pIepPwmFwRegs; 679 IepPwmFwRegs *pIepPwmFwRegs = pIcssgIepPwmObj->pIepPwmFwRegs;
633 Uint16 iepPwmSnglEn; 680 Uint16 iepPwmSnglEn;
634 Uint8 iepPwmDiffEn; 681 Uint8 iepPwmDiffEn;
@@ -636,13 +683,11 @@ Int32 initIepPwm(
636 683
637 /* Latch IEP PWM global enable. 684 /* Latch IEP PWM global enable.
638 Global enable can't change after Initialization. */ 685 Global enable can't change after Initialization. */
639 pIcssgIepPwmObj->iepPwmGblEn = (Bool)((pIepPwmCtrlFwRegs->PWM_CTRL >> iepId ) & IEP_PWM_GBL_EN_MASK);
640 /* Acknowledge IEP PWM global enable */ 686 /* Acknowledge IEP PWM global enable */
641 pIepPwmCtrlFwRegs->PWM_STAT |= (Uint32)pIcssgIepPwmObj->iepPwmGblEn << iepId;
642 687
643 /* Configure PWMs */ 688 /* Configure PWMs */
644 689
645 if (pIcssgIepPwmObj->iepPwmGblEn == TRUE) { 690 if (pIcssgIepPwmCtrlObj->iepPwmGblEn[iepId] == TRUE) {
646 /* Latch IEP PWM mode. 691 /* Latch IEP PWM mode.
647 IEP PWM mode can't change after Initialization. */ 692 IEP PWM mode can't change after Initialization. */
648 latchIepPwmMode(pIcssgIepPwmObj); 693 latchIepPwmMode(pIcssgIepPwmObj);
@@ -705,16 +750,15 @@ Int32 setPwmFwInitFlag(
705 - IEP0 enabled, IEP1 disabled 750 - IEP0 enabled, IEP1 disabled
706 - IEP0 enabled, IEP1 enabled */ 751 - IEP0 enabled, IEP1 enabled */
707IepSm_Config getIepPwmSmConfig( 752IepSm_Config getIepPwmSmConfig(
708 IcssgIepPwmObj *pIcssgIep0PwmCtrlObj, 753 IcssgIepPwmCtrlObj *pIcssgIepPwmCtrlObj
709 IcssgIepPwmObj *pIcssgIep1PwmCtrlObj
710) 754)
711{ 755{
712 Bool iep0PwmGblEn, iep1PwmGblEn; 756 Bool iep0PwmGblEn, iep1PwmGblEn;
713 IepSm_Config ret; 757 IepSm_Config ret;
714 758
715 759
716 iep0PwmGblEn = pIcssgIep0PwmCtrlObj->iepPwmGblEn; 760 iep0PwmGblEn = pIcssgIepPwmCtrlObj->iepPwmGblEn[0];
717 iep1PwmGblEn = pIcssgIep1PwmCtrlObj->iepPwmGblEn; 761 iep1PwmGblEn = pIcssgIepPwmCtrlObj->iepPwmGblEn[1];
718 762
719 if (iep0PwmGblEn == FALSE) { 763 if (iep0PwmGblEn == FALSE) {
720 ret = (iep1PwmGblEn == FALSE) ? IEP_SM_CONFIG_NONE : IEP_SM_CONFIG_IEP1; 764 ret = (iep1PwmGblEn == FALSE) ? IEP_SM_CONFIG_NONE : IEP_SM_CONFIG_IEP1;
diff --git a/example/apps/icssg_pwm/firmware/src/iepPwm.h b/example/apps/icssg_pwm/firmware/src/iepPwm.h
index c52631b..0ffe6a4 100644
--- a/example/apps/icssg_pwm/firmware/src/iepPwm.h
+++ b/example/apps/icssg_pwm/firmware/src/iepPwm.h
@@ -44,6 +44,12 @@
44#define IEP_STS_ERR_INV_IEP_ID ( -1 ) /* error, invalid IEP ID */ 44#define IEP_STS_ERR_INV_IEP_ID ( -1 ) /* error, invalid IEP ID */
45#define IPE_STS_ERR_INV_DC_COUNT ( -2 ) /* error, invalid Duty Cycle Count */ 45#define IPE_STS_ERR_INV_DC_COUNT ( -2 ) /* error, invalid Duty Cycle Count */
46 46
47/* IEPs per ICSSG */
48#define ICSSG_NUM_IEP ( 2 )
49
50/* PWM sets per IEP */
51#define IEP_NUM_PWM_SET ( 2 )
52
47/* Number of PWMs per Differential PWM pair */ 53/* Number of PWMs per Differential PWM pair */
48#define NUM_PWM_PER_DIFF_PWM ( 2 ) 54#define NUM_PWM_PER_DIFF_PWM ( 2 )
49/* Number of differential PWMs per PWM set */ 55/* Number of differential PWMs per PWM set */
@@ -51,9 +57,6 @@
51/* Number of single-ended PWMs per PWM set, two sets per IEP */ 57/* Number of single-ended PWMs per PWM set, two sets per IEP */
52#define SNGL_PWM_PER_SET ( DIFF_PWM_PER_SET * NUM_PWM_PER_DIFF_PWM ) 58#define SNGL_PWM_PER_SET ( DIFF_PWM_PER_SET * NUM_PWM_PER_DIFF_PWM )
53 59
54/* PWM sets per IEP */
55#define IEP_NUM_PWM_SET ( 2 )
56
57/* IEP maximum number of Differential PWMs */ 60/* IEP maximum number of Differential PWMs */
58#define IEP_MAX_NUM_DIFF_PWM ( IEP_NUM_PWM_SET * DIFF_PWM_PER_SET ) 61#define IEP_MAX_NUM_DIFF_PWM ( IEP_NUM_PWM_SET * DIFF_PWM_PER_SET )
59/* IEP maximum number of Single-Ended PWMs */ 62/* IEP maximum number of Single-Ended PWMs */
@@ -144,14 +147,15 @@ typedef enum IepSm_States_e
144/* ICSSG IEP PWM control object */ 147/* ICSSG IEP PWM control object */
145typedef struct IcssgIepPwmCtrlObj_s 148typedef struct IcssgIepPwmCtrlObj_s
146{ 149{
147 IepPwmCtrlFwRegs *pIepPwmCtrlFwRegs; /* IEP PWM FW control registers, init to &PWM_CTRL */ 150 Bool iepPwmGblEn[ICSSG_NUM_IEP]; /* IEP PWM global disable/enable flags */
151 CSL_icss_g_pr1_cfg_slvRegs *pIcssgCfgHwRegs; /* ICSSG CFG registers, init to CSL_ICSS_CFG_BASE */
152 IepPwmCtrlFwRegs *pIepPwmCtrlFwRegs; /* IEP PWM FW control registers, init to &PWM_CTRL */
148} IcssgIepPwmCtrlObj; 153} IcssgIepPwmCtrlObj;
149 154
150/* ICSSG IEP PWM object */ 155/* ICSSG IEP PWM object */
151typedef struct IcssgIepPwmObj_s 156typedef struct IcssgIepPwmObj_s
152{ 157{
153 IepId iepId; /* IEP ID, init to 0 or 1 */ 158 IepId iepId; /* IEP ID, init to 0 or 1 */
154 Bool iepPwmGblEn; /* IEP PWM global disable/enable flag */
155 Uint32 iepPwmMode; /* IEP mode */ 159 Uint32 iepPwmMode; /* IEP mode */
156 Uint32 iepPwmEn; /* IEP enable */ 160 Uint32 iepPwmEn; /* IEP enable */
157 Uint32 iepPwmPeriodCount; /* IEP period count */ 161 Uint32 iepPwmPeriodCount; /* IEP period count */
@@ -179,7 +183,12 @@ extern IcssgIepPwmObj gIcssgIep0PwmObj; /* IEP 0 PWM object */
179extern IcssgIepPwmObj gIcssgIep1PwmObj; /* IEP 1 PWM object */ 183extern IcssgIepPwmObj gIcssgIep1PwmObj; /* IEP 1 PWM object */
180 184
181/* Reset PWM FW control object */ 185/* Reset PWM FW control object */
182Int32 resetPwmCtrlFwRegs( 186Int32 resetPwmCtrlObj(
187 IcssgIepPwmCtrlObj *pIcssgIepPwmCtrlObj
188);
189
190/* Initialize PWM FW control */
191Int32 initPwmCtrl(
183 IcssgIepPwmCtrlObj *pIcssgIepPwmCtrlObj 192 IcssgIepPwmCtrlObj *pIcssgIepPwmCtrlObj
184); 193);
185 194
@@ -215,8 +224,7 @@ Int32 setPwmFwInitFlag(
215 - IEP0 enabled, IEP1 disabled 224 - IEP0 enabled, IEP1 disabled
216 - IEP0 enabled, IEP1 enabled */ 225 - IEP0 enabled, IEP1 enabled */
217IepSm_Config getIepPwmSmConfig( 226IepSm_Config getIepPwmSmConfig(
218 IcssgIepPwmObj *pIcssgIep0PwmCtrlObj, 227 IcssgIepPwmCtrlObj *pIcssgIepPwmCtrlObj
219 IcssgIepPwmObj *pIcssgIep1PwmCtrlObj
220); 228);
221 229
222/* Initialize IEP PWM State Machine */ 230/* Initialize IEP PWM State Machine */
diff --git a/example/apps/icssg_pwm/firmware/src/main.c b/example/apps/icssg_pwm/firmware/src/main.c
index 8c0df73..9323ff4 100644
--- a/example/apps/icssg_pwm/firmware/src/main.c
+++ b/example/apps/icssg_pwm/firmware/src/main.c
@@ -41,7 +41,7 @@ void main(void)
41 IepSm_Config iepSmConfig; 41 IepSm_Config iepSmConfig;
42 42
43 /* Reset PWM FW control object */ 43 /* Reset PWM FW control object */
44 status = resetPwmCtrlFwRegs(&gIcssgIepPwmCtrlObj); 44 status = resetPwmCtrlObj(&gIcssgIepPwmCtrlObj);
45 if (status != IEP_STS_NERR) 45 if (status != IEP_STS_NERR)
46 { 46 {
47 /* Indicate Error to Host */ 47 /* Indicate Error to Host */
@@ -63,6 +63,14 @@ void main(void)
63 /* Indicate Error to Host */ 63 /* Indicate Error to Host */
64 ; 64 ;
65 } 65 }
66
67 /* Initialize PWM FW control */
68 status = initPwmCtrl(&gIcssgIepPwmCtrlObj);
69 if (status != IEP_STS_NERR)
70 {
71 /* Indicate Error to Host */
72 ;
73 }
66 74
67 /* Initialize IEP0 PWM */ 75 /* Initialize IEP0 PWM */
68 status = initIepPwm(&gIcssgIepPwmCtrlObj, &gIcssgIep0PwmObj); 76 status = initIepPwm(&gIcssgIepPwmCtrlObj, &gIcssgIep0PwmObj);
@@ -89,8 +97,8 @@ void main(void)
89 } 97 }
90 98
91 /* Get State Machine configuration */ 99 /* Get State Machine configuration */
92 iepSmConfig = getIepPwmSmConfig(&gIcssgIep0PwmObj, &gIcssgIep1PwmObj); 100 iepSmConfig = getIepPwmSmConfig(&gIcssgIepPwmCtrlObj);
93 101
94 /* Execute State Machine(s) */ 102 /* Execute State Machine(s) */
95 if (iepSmConfig == IEP_SM_CONFIG_IEP0) 103 if (iepSmConfig == IEP_SM_CONFIG_IEP0)
96 { 104 {