]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - psdk_cust/pdk_k2g_1_0_1_2_eng/packages/ti/board/src/flash/platform_flash/evmc66x_pllc.h
Modified messaging code after code review.
[processor-sdk/performance-audio-sr.git] / psdk_cust / pdk_k2g_1_0_1_2_eng / packages / ti / board / src / flash / platform_flash / evmc66x_pllc.h
1 /*
2  * Copyright (c) 2011-2015, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the 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 "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
34 #ifndef _EVMC66X_PLLC_H_
35 #define _EVMC66X_PLLC_H_
37 /**
38  *
39  * \file  evmc66x_pllc.h
40  *
41  * \brief This contains PLL Control specific functions and defines
42  *                prototypes.
43  *
44  ******************************************************************************/
46 #define PLLC_DIVEN_PLLDIV2    (1)
47 #define PLLC_DIVDS_PLLDIV2    (0)
48 #define PLLC_DIVEN_PLLDIV3    (1)
49 #define PLLC_DIVDS_PLLDIV3    (0)
51 /***********************************************************************
52  *                  PLL clock dividers and multipliers                 *
53  ***********************************************************************/
55 /******************* Main PLL divider and multipliers *******************/
56 /* Divider and multiplier macros for main PLL clock indicates
57    actual values. Value 2 means divide/multiply by 2 */
58 /* PREDIV - PLL divider value */
59 #define PLATFORM_PLL_PREDIV_val  (1)
61 /* POSTDIV - PLL output divider value */
62 #define PLATFORM_PLL_POSTDIV_val (4)
64 /* Default PLL PLLM value (24/1*(100/4)) = 600MHz) */
65 #define  PLATFORM_PLL1_PLLM_val  (100)
67 /* 1/x-rate clock for gem_trace_clk. Divider to generate SYSCLK2 from PLLOUT */
68 #define  PLATFORM_PLLDIV2_val    (3)
69 /* 1/y-rate clock for STMXPT_CLK. Divider to generate SYSCLK3 from PLLOUT */
70 #define  PLATFORM_PLLDIV3_val    (5)
72 /* Divider and multiplier macros for module PLL clock indicates
73    value written to the register. Value 1 means divide/multiply by 2 */
74 /******************* NSS PLL divider and multipliers *******************/
75 /* NSS PLL settings for 1000 MHz */
76 #define PLLM_NSS     (249)  // Multiply by 250
77 #define PLLD_NSS     (2)    // Divide by 3
78 #define CLKOD_NSS    (1)    // Divide by 2
80 /******************* DDR PLL divider and multipliers *******************/
81 /* DDR3 PLL settings for 200 MHz */
83 /* DDR3 clock settings used when input clock is provided by DDRCLKP */
84 #define DDRCLKP_PLLM_DDR3    (59)   // Multiply by 60
85 #define DDRCLKP_PLLD_DDR3    (2)   // Divide by 3
86 #define DDRCLKP_PLLOD_DDR3   (9)   // Divide by 10
88 /* DDR3 clock settings used when input clock is provided by DDRCLKP */
89 #define PLLM_DDR3    (249)  // Multiply by 250
90 #define PLLD_DDR3    (2)   // Divide by 3
91 #define PLLOD_DDR3   (9)   // Divide by 10
94 /******************* DSS PLL divider and multipliers *******************/
95 /* DSS PLL settings for 74.2 MHz */
96 #define PLLM_DSS     (197)  // Multiply by 198
97 #define PLLD_DSS     (3)   // Divide by 4
98 #define CLKOD_DSS    (15)   // Divide by 16
100 /******************* ICSS PLL divider and multipliers *******************/
101 /* ICSS PLL settings for 200 MHz */
102 #define PLLM_ICSS    (249)  // Multiply by 250
103 #define PLLD_ICSS    (2)   // Divide by 3
104 #define CLKOD_ICSS   (9)   // Divide by 10
106 /******************* UART PLL divider and multipliers *******************/
107 /* UART PLL settings for 384 MHz UART PLL output clock */
108 #define PLLM_UART    (127)  // Multiply by 128
109 #define PLLD_UART    (0)   // Divide by 1
110 #define CLKOD_UART   (7)   // Divide by 8
112 /* Value of the PLL input clock rate in MHz */
113 #define PLATFORM_BASE_CLK_RATE_MHZ (24u)    /* External 24 MHz clock */
115 /********************************************************************************************
116  *                     PLL controller register local Declarations                          *
117  *******************************************************************************************/
118 #define   MAINPLLCTL0_REG        (*((volatile uint32_t *) 0x02620350))
119 #define   MAINPLLCTL1_REG        (*((volatile uint32_t *) 0x02620354))
121 /* NSS PLL control registers */
122 #define   NSSPLLCTL0_REG         (*((volatile uint32_t *) 0x02620358))
123 #define   NSSPLLCTL1_REG         (*((volatile uint32_t *) 0x0262035C))
125 /* DDR3A and DDR3B PLL control registers */
126 #define   DDR3PLLCTL0_REG(x)     (*((volatile uint32_t *) (0x02620360+(8*x))))
127 #define   DDR3PLLCTL1_REG(x)     (*((volatile uint32_t *) (0x02620364+(8*x))))
129 /* DSS PLL control registers */
130 #define   DSSPLLCTL0_REG         (*((volatile uint32_t *) 0x02620380))
131 #define   DSSPLLCTL1_REG         (*((volatile uint32_t *) 0x02620384))
133 /* ICSS PLL control registers */
134 #define   ICSSPLLCTL0_REG        (*((volatile uint32_t *) 0x02620388))
135 #define   ICSSPLLCTL1_REG        (*((volatile uint32_t *) 0x0262038C))
137 /* UART PLL control registers */
138 #define   UARTPLLCTL0_REG        (*((volatile uint32_t *) 0x02620390))
139 #define   UARTPLLCTL1_REG        (*((volatile uint32_t *) 0x02620394))
141 #define   OBSCLCTL_REG           (*((volatile uint32_t *) 0x026203AC))
143 /* PLL controller registers */
144 #define   PLLCTL_REG            (*((volatile uint32_t *) 0x02310100))
145 #define   SECCTL_REG            (*((volatile uint32_t *) 0x02310108))
146 #define   PLLM_REG              (*((volatile uint32_t *) 0x02310110))
147 #define   PLLCMD_REG            (*((volatile uint32_t *) 0x02310138))
148 #define   PLLSTAT_REG           (*((volatile uint32_t *) 0x0231013C))
149 #define   PLLALNCTL_REG         (*((volatile uint32_t *) 0x02310140))
150 #define   PLLDIV2_REG           (*((volatile uint32_t *) 0x0231011C))
151 #define   PLLDIV3_REG           (*((volatile uint32_t *) 0x02310120))
153 /* NSS PLL Registers */
154 #define NSS_PLL_CLKM_MASK   (0x0007FFC0) /* Tells the multiplier value for the NSS PLL */
155 #define NSS_PLL_CLKD_MASK   (0x0000003F) /* Tells the divider value for the NSS PLL */
156 #define NSS_PLL_CLKOD_MASK  (0x00780000) /* Tells the output divider value for the NSS PLL */
158 /* PLL multiplier mask value */
159 #define MODULE_PLL_CLKM_MASK   (0x0007FFC0)
160 /* PLL divider mask value */
161 #define MODULE_PLL_CLKD_MASK   (0x0000003F)
162 /* PLL output divider mask value */
163 #define MODULE_PLL_CLKOD_MASK  (0x00780000)
165 #define PLL1_BASE                (0x02310000)
166 #define PLL1_PLLCTL              (*(unsigned int*)(PLL1_BASE + 0x100))   // PLL1 Control
167 #define PLL1_SECCTL              (*(unsigned int*)(PLL1_BASE + 0x108))   // PLL1 Sec Control
168 #define PLL1_PLLM                (*(unsigned int*)(PLL1_BASE + 0x110))   // PLL1 Multiplier
169 #define PLL1_DIV1                (*(unsigned int*)(PLL1_BASE + 0x118))   // DIV1 divider
170 #define PLL1_DIV2                (*(unsigned int*)(PLL1_BASE + 0x11C))   // DIV2 divider
171 #define PLL1_DIV3                (*(unsigned int*)(PLL1_BASE + 0x120))   // DIV3 divider
172 #define PLL1_CMD                 (*(unsigned int*)(PLL1_BASE + 0x138))   // CMD control
173 #define PLL1_STAT                (*(unsigned int*)(PLL1_BASE + 0x13C))   // STAT control
174 #define PLL1_ALNCTL              (*(unsigned int*)(PLL1_BASE + 0x140))   // ALNCTL control
175 #define PLL1_DCHANGE             (*(unsigned int*)(PLL1_BASE + 0x144))   // DCHANGE status
176 #define PLL1_CKEN                (*(unsigned int*)(PLL1_BASE + 0x148))   // CKEN control
177 #define PLL1_CKSTAT              (*(unsigned int*)(PLL1_BASE + 0x14C))   // CKSTAT status
178 #define PLL1_SYSTAT              (*(unsigned int*)(PLL1_BASE + 0x150))   // SYSTAT status
179 #define PLL1_DIV4                (*(unsigned int*)(PLL1_BASE + 0x160))   // DIV4 divider
180 #define PLL1_DIV5                (*(unsigned int*)(PLL1_BASE + 0x164))   // DIV5 divider
181 #define PLL1_DIV6                (*(unsigned int*)(PLL1_BASE + 0x168))   // DIV6 divider
182 #define PLL1_DIV7                (*(unsigned int*)(PLL1_BASE + 0x16C))   // DIV7 divider
183 #define PLL1_DIV8                (*(unsigned int*)(PLL1_BASE + 0x170))   // DIV8 divider
184 #define PLL1_DIV9                (*(unsigned int*)(PLL1_BASE + 0x174))   // DIV9 divider
185 #define PLL1_DIV10               (*(unsigned int*)(PLL1_BASE + 0x178))   // DIV10 divider
186 #define PLL1_DIV11               (*(unsigned int*)(PLL1_BASE + 0x17C))   // DIV11 divider
187 #define PLL1_DIV12               (*(unsigned int*)(PLL1_BASE + 0x180))   // DIV12 divider
188 #define PLL1_DIV13               (*(unsigned int*)(PLL1_BASE + 0x184))   // DIV13 divider
189 #define PLL1_DIV14               (*(unsigned int*)(PLL1_BASE + 0x188))   // DIV14 divider
190 #define PLL1_DIV15               (*(unsigned int*)(PLL1_BASE + 0x18C))   // DIV15 divider
191 #define PLL1_DIV16               (*(unsigned int*)(PLL1_BASE + 0x190))   // DIV16 divider
193 /* Shift values for PLL control register bits */
194 #define BWADJ_BIT_SHIFT     (24)
195 #define BYPASS_BIT_SHIFT    (23)
196 #define CLKF_BIT_SHIFT      (6)
198 #define ENSAT_BIT_SHIFT     (6)
199 #define RESET_BIT_SHIFT     (14)
200 #define PLLSEL_BIT_SHIFT    (13)
202 /* UART internal divider value */
203 #define UART_INT_DIV (2)
205 /* DSS PLL Register mask values */
206 #define DSS_PLL_CLKM_MASK   (0x0007FFC0) /* Tells the multiplier value for the DSS PLL */
207 #define DSS_PLL_CLKD_MASK   (0x0000003F) /* Tells the divider value for the DSS PLL */
208 #define DSS_PLL_CLKOD_MASK  (0x00780000) /* Tells the output divider value for the DSS PLL */
210 /* ICSS PLL Registers mask values */
211 #define ICSS_PLL_CLKM_MASK   (0x0007FFC0) /* Tells the multiplier value for the ICSS PLL */
212 #define ICSS_PLL_CLKD_MASK   (0x0000003F) /* Tells the divider value for the ICSS PLL */
213 #define ICSS_PLL_CLKOD_MASK  (0x00780000) /* Tells the output divider value for the ICSS PLL */
215 /* UART PLL Registers mask values */
216 #define UART_PLL_CLKM_MASK   (0x0007FFC0) /* Tells the multiplier value for the UART PLL */
217 #define UART_PLL_CLKD_MASK   (0x0000003F) /* Tells the divider value for the UART PLL */
218 #define UART_PLL_CLKOD_MASK  (0x00780000) /* Tells the output divider value for the UART PLL */
220 /* UART input clock rate */
221 #define PLATFORM_UART_INPUT_CLOCK_RATE ((uint32_t)(PLATFORM_BASE_CLK_RATE_MHZ * (PLLM_UART + 1) * 1000000)/((PLLD_UART + 1) * (CLKOD_UART + 1) * UART_INT_DIV))
223 /* PLL identifiers */
224 enum pll_type_e
226         DDR3A_PLL
227 };
229 /* PLL observation clock selection */
230 typedef enum _PllObsClk
232         OBSCLK_BAW_OSC = 0,
233     OBSCLK_MAIN_PLL,
234     OBSCLK_DSS_PLL,
235     OBSCLK_ARM_PLL,
236     OBSCLK_UART_PLL,
237     OBSCLK_ICSS_PLL,
238     OBSCLK_DDR3A_PLL,
239     OBSCLK_PLLCTRL,
240     OBSCLK_NSS_PLL,
241     OBSCLK_HF_OSC,
242     OBSCLK_RC_OSC
244 } PllObsClk;
246 typedef struct PllcHwSetup {
247     /** \brief Divider Enable/Disable
248      *  \param CSL_BitMask32
249      */
250     CSL_BitMask32 divEnable;
251     /** \brief PLL Multiplier
252      *  \param Uint32
253      */
254     Uint32        pllM;
255     /** \brief PLL Divider 2
256      *  \param Uint32
257      */
258     Uint32        pllDiv2;
259     /** \brief PLL Divider 2
260      *  \param Uint32
261      */
262     Uint32        pllDiv3;
263     /** \brief PLL Divider 3
264      *  \param Uint32
265      */
266     Uint32        preDiv;
267     /** \brief post Divider value
268      *  \param Uint32
269      */
270     Uint32        postDiv;
271     /** \brief Setup that can be used for future implementation
272      *  \param void*
273      */
274     void*         extendSetup;
275 } PllcHwSetup;
277 /* PLL configuration data */
278 typedef struct pll_init_data {
279         uint32_t pll;
280         uint32_t pll_m;         /* PLL Multiplier */
281         uint32_t pll_d;         /* PLL divider */
282         uint32_t pll_od;        /* PLL output divider    */
283 } pll_init_data;
285 CSL_Status  CorePllcGetHwSetup (PllcHwSetup*);
286 CSL_Status  CorePllcHwSetup (PllcHwSetup*);
287 CSL_Status  corePllcInit (void *);
288 CSL_Status SetNssPllConfig (pll_init_data *data);
289 CSL_Status SetDssPllConfig (pll_init_data *data);
290 CSL_Status SetIcssPllConfig (pll_init_data *data);
291 CSL_Status SetUartPllConfig (pll_init_data *data);
292 CSL_Status  SetDDR3PllConfig (pll_init_data *data);
293 void configPllClkSelection (uint8_t sysClkSel);
294 void enablePllObsClk (PllObsClk obsClk);
296 #endif /* _EVMC66X_PLLC_H_ */
298 /* Nothing past this point */