Skip to content

Commit 91fc25b

Browse files
ssekar15parthitce
andcommitted
arch/tricore: Set up the TC4xx clocks without the iLLD.
The startup code sets up the TC4xx flash wait states, clock dividers, oscillators and PLLs with the iLLD IfxClock_init and its TC4Dx default configuration. Add tricore_clockconfig for TC4xx, which runs the same sequence with the clock, SMU and DMU registers: set the wait states and dividers, power up the 25 MHz crystal and the ramp oscillator, set up both PLLs, ramp the system clock up and switch both clocks to the PLLs. The long waits service the watchdogs, as IfxClock does. The clock registers end up with the same values as with IfxClock_init. Co-authored-by: Parthiban Nallathambi <parthiban@linumiz.com> Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
1 parent 0422a90 commit 91fc25b

10 files changed

Lines changed: 776 additions & 2 deletions

File tree

‎arch/tricore/src/illd/tc4xx/Configurations/Ifx_Cfg_Ssw.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void Ifx_Ssw_PowerOnCrystalOsc(void)
119119

120120
void Ifx_Ssw_PllInit(void)
121121
{
122-
if (IfxClock_init(&IfxClock_defaultClockConfig) != 0U)
122+
if (tricore_clockconfig() != 0)
123123
{
124124
__debug();
125125
}

‎arch/tricore/src/illd/tc4xx/Configurations/Ifx_Cfg_Ssw.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,12 @@
7878
#define IFX_CFG_SSW_ENABLE_KEYOFF_MBIST_DSPRS_DMARAM (0U)
7979
#endif
8080

81+
/****************************************************************************
82+
* Public Function Prototypes
83+
****************************************************************************/
84+
85+
#if IFX_CFG_SSW_ENABLE_PLL_INIT == 1U
86+
int tricore_clockconfig(void);
87+
#endif
88+
8189
#endif /* __ARCH_TRICORE_SRC_ILLD_TC4XX_CONFIGURATIONS_IFX_CFG_SSW_H */

‎arch/tricore/src/tc4xx/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#
2121
# ##############################################################################
2222

23-
set(SRCS tc4xx_timerisr.c tc4xx_serial.c tc4xx_wdt.c)
23+
set(SRCS tc4xx_timerisr.c tc4xx_serial.c tc4xx_wdt.c tc4xx_clockconfig.c)
2424

2525
target_sources(arch PRIVATE ${SRCS})
2626

‎arch/tricore/src/tc4xx/Make.defs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
CHIP_CSRCS += tc4xx_timerisr.c
2424
CHIP_CSRCS += tc4xx_serial.c
2525
CHIP_CSRCS += tc4xx_wdt.c
26+
CHIP_CSRCS += tc4xx_clockconfig.c
2627

2728
VPATH += tc4xx
2829

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/****************************************************************************
2+
* arch/tricore/src/tc4xx/hardware/tc4xx_clock.h
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed to the Apache Software Foundation (ASF) under one or more
7+
* contributor license agreements. See the NOTICE file distributed with
8+
* this work for additional information regarding copyright ownership. The
9+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
* "License"); you may not use this file except in compliance with the
11+
* License. You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
* License for the specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
****************************************************************************/
22+
23+
#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_CLOCK_H
24+
#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_CLOCK_H
25+
26+
/****************************************************************************
27+
* Pre-processor Definitions
28+
****************************************************************************/
29+
30+
/* Clock module registers */
31+
32+
#define TC4XX_CLOCK_OSCCON 0xf0064100
33+
#define TC4XX_CLOCK_RAMPCON0 0xf0064200
34+
#define TC4XX_CLOCK_RAMPSTAT 0xf006420c
35+
#define TC4XX_CLOCK_SYSPLLCON0 0xf0064300
36+
#define TC4XX_CLOCK_SYSPLLCON1 0xf0064304
37+
#define TC4XX_CLOCK_SYSPLLSTAT 0xf006430c
38+
#define TC4XX_CLOCK_PERPLLCON0 0xf0064380
39+
#define TC4XX_CLOCK_PERPLLCON1 0xf0064384
40+
#define TC4XX_CLOCK_PERPLLSTAT 0xf006438c
41+
#define TC4XX_CLOCK_CCUCON 0xf0064400
42+
#define TC4XX_CLOCK_CCUSTAT 0xf0064404
43+
#define TC4XX_CLOCK_SYSCCUCON0 0xf0064410
44+
#define TC4XX_CLOCK_SYSCCUCON1 0xf0064414
45+
#define TC4XX_CLOCK_PERCCUCON0 0xf0064420
46+
#define TC4XX_CLOCK_PERCCUCON1 0xf0064424
47+
#define TC4XX_CLOCK_OSCMON1 0xf0064508
48+
#define TC4XX_CLOCK_OSCSTAT 0xf006450c
49+
#define TC4XX_CLOCK_RAMPMON 0xf0064510
50+
51+
#define TC4XX_OSCCON_MODE_SHIFT 8
52+
#define TC4XX_OSCCON_MODE_MASK (0x7 << TC4XX_OSCCON_MODE_SHIFT)
53+
#define TC4XX_OSCCON_INSEL_SHIFT 24
54+
#define TC4XX_OSCCON_INSEL_MASK (0x3 << TC4XX_OSCCON_INSEL_SHIFT)
55+
56+
#define TC4XX_OSCMON1_OSCVAL_MASK (0x7f << 0)
57+
#define TC4XX_OSCMON1_SMONEN (1 << 8)
58+
#define TC4XX_OSCMON1_PMONEN (1 << 24)
59+
#define TC4XX_OSCSTAT_WDS_MASK ((0x3 << 0) | (0x3 << 16))
60+
61+
#define TC4XX_RAMPCON0_UFL_MASK (0x3ff << 0)
62+
#define TC4XX_RAMPCON0_CMD_SHIFT 16
63+
#define TC4XX_RAMPCON0_CMD_MASK (0x7 << TC4XX_RAMPCON0_CMD_SHIFT)
64+
#define TC4XX_RAMPCON0_PWR (1 << 19)
65+
#define TC4XX_RAMPSTAT_FSTAT_SHIFT 16
66+
#define TC4XX_RAMPSTAT_FSTAT_MASK (0x3 << TC4XX_RAMPSTAT_FSTAT_SHIFT)
67+
#define TC4XX_RAMPSTAT_ACTIVE (1 << 23)
68+
#define TC4XX_RAMPSTAT_FLLLOCK (1 << 24)
69+
#define TC4XX_RAMPMON_FLLLDEN (1 << 28)
70+
71+
#define TC4XX_PLLCON0_PLLPWR (1 << 0)
72+
#define TC4XX_PLLCON0_NDIV_SHIFT 8
73+
#define TC4XX_PLLCON0_NDIV_MASK (0x7f << TC4XX_PLLCON0_NDIV_SHIFT)
74+
#define TC4XX_PLLCON0_PDIV_SHIFT 16
75+
#define TC4XX_PLLCON0_PDIV_MASK (0x7 << TC4XX_PLLCON0_PDIV_SHIFT)
76+
#define TC4XX_PLLSTAT_PWRSTAT (1 << 0)
77+
#define TC4XX_PLLSTAT_PLLLOCK (1 << 1)
78+
79+
#define TC4XX_PLLCON1_K2DIV_MASK (0xf << 0)
80+
#define TC4XX_PLLCON1_K2PRE_SHIFT 4
81+
#define TC4XX_PLLCON1_K2PRE_MASK (0x3 << TC4XX_PLLCON1_K2PRE_SHIFT)
82+
#define TC4XX_PLLCON1_K3DIV_SHIFT 8
83+
#define TC4XX_PLLCON1_K3DIV_MASK (0x7 << TC4XX_PLLCON1_K3DIV_SHIFT)
84+
#define TC4XX_PLLCON1_K3PRE_SHIFT 12
85+
#define TC4XX_PLLCON1_K3PRE_MASK (0xf << TC4XX_PLLCON1_K3PRE_SHIFT)
86+
#define TC4XX_PLLCON1_K4DIV_SHIFT 16 /* PERPLLCON1 only */
87+
#define TC4XX_PLLCON1_K4DIV_MASK (0x7 << TC4XX_PLLCON1_K4DIV_SHIFT)
88+
#define TC4XX_PLLCON1_K4PRE_SHIFT 20 /* PERPLLCON1 only */
89+
#define TC4XX_PLLCON1_K4PRE_MASK (0x3 << TC4XX_PLLCON1_K4PRE_SHIFT)
90+
91+
#define TC4XX_CCUSTAT_LCK (1 << 31)
92+
#define TC4XX_CCU_CLKSELS_MASK (0x3 << 0) /* CCUCON and CCUSTAT */
93+
#define TC4XX_CCU_CLKSELS_PLL 0
94+
#define TC4XX_CCU_CLKSELS_BACK 1
95+
#define TC4XX_CCU_CLKSELS_RAMP 2
96+
#define TC4XX_CCU_CLKSELP (1 << 16) /* Set: backup clock */
97+
#define TC4XX_CCUCON_UP (1 << 30) /* SYSCCUCON0 and 1 */
98+
99+
#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_CLOCK_H */
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/****************************************************************************
2+
* arch/tricore/src/tc4xx/hardware/tc4xx_dmu.h
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed to the Apache Software Foundation (ASF) under one or more
7+
* contributor license agreements. See the NOTICE file distributed with
8+
* this work for additional information regarding copyright ownership. The
9+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
* "License"); you may not use this file except in compliance with the
11+
* License. You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
* License for the specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
****************************************************************************/
22+
23+
#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_DMU_H
24+
#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_DMU_H
25+
26+
/****************************************************************************
27+
* Pre-processor Definitions
28+
****************************************************************************/
29+
30+
/* Data memory unit (DMU) flash wait state registers */
31+
32+
#define TC4XX_DMU_HOST_DFWAIT 0xf8040100
33+
#define TC4XX_DMU_HOST_PFWAIT 0xf804011c
34+
35+
#define TC4XX_DMU_RFLASH_MASK 0x1f
36+
37+
#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_DMU_H */
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/****************************************************************************
2+
* arch/tricore/src/tc4xx/hardware/tc4xx_smu.h
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed to the Apache Software Foundation (ASF) under one or more
7+
* contributor license agreements. See the NOTICE file distributed with
8+
* this work for additional information regarding copyright ownership. The
9+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
* "License"); you may not use this file except in compliance with the
11+
* License. You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
* License for the specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
****************************************************************************/
22+
23+
#ifndef __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_SMU_H
24+
#define __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_SMU_H
25+
26+
/****************************************************************************
27+
* Pre-processor Definitions
28+
****************************************************************************/
29+
30+
/* Safety management unit (SMU_SAFE0) registers */
31+
32+
#define TC4XX_SMU_SAFE0_CMD 0xf0029000
33+
#define TC4XX_SMU_SAFE0_KEYS 0xf002901c
34+
#define TC4XX_SMU_SAFE0_AGSF8_CON(n) (0xf00291a0 + (n) * 4)
35+
#define TC4XX_SMU_SAFE0_AGSF8_STS 0xf00291b8
36+
37+
#define TC4XX_SMU_KEYS_CFG 0xbc
38+
#define TC4XX_SMU_CMD_ALARM_CLR 5
39+
40+
#endif /* __ARCH_TRICORE_SRC_TC4XX_HARDWARE_TC4XX_SMU_H */

0 commit comments

Comments
 (0)