Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2008 |
| 4 | * Texas Instruments, <www.ti.com> |
| 5 | * |
| 6 | * Author : |
| 7 | * Manikandan Pillai <mani.pillai@ti.com> |
| 8 | * |
| 9 | * Derived from Beagle Board and OMAP3 SDP code by |
| 10 | * Richard Woodruff <r-woodruff2@ti.com> |
| 11 | * Syed Mohammed Khasim <khasim@ti.com> |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <common.h> |
| 15 | #include <asm/io.h> |
Lokesh Vutla | 61c517f | 2013-05-30 02:54:32 +0000 | [diff] [blame] | 16 | #include <asm/arch/clock.h> |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 17 | #include <asm/arch/clocks_omap3.h> |
| 18 | #include <asm/arch/mem.h> |
| 19 | #include <asm/arch/sys_proto.h> |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 20 | #include <command.h> |
| 21 | |
| 22 | /****************************************************************************** |
| 23 | * get_sys_clk_speed() - determine reference oscillator speed |
| 24 | * based on known 32kHz clock and gptimer. |
| 25 | *****************************************************************************/ |
Adam Ford | 7f2a606 | 2022-03-05 08:25:23 -0600 | [diff] [blame] | 26 | static u32 get_osc_clk_speed(void) |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 27 | { |
Sanjeev Premi | ef7bd71 | 2010-02-08 11:33:25 -0500 | [diff] [blame] | 28 | u32 start, cstart, cend, cdiff, cdiv, val; |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 29 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 30 | struct prm *prm_base = (struct prm *)PRM_BASE; |
| 31 | struct gptimer *gpt1_base = (struct gptimer *)OMAP34XX_GPT1; |
| 32 | struct s32ktimer *s32k_base = (struct s32ktimer *)SYNC_32KTIMER_BASE; |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 33 | |
| 34 | val = readl(&prm_base->clksrc_ctrl); |
| 35 | |
Sanjeev Premi | ef7bd71 | 2010-02-08 11:33:25 -0500 | [diff] [blame] | 36 | if (val & SYSCLKDIV_2) |
| 37 | cdiv = 2; |
Sanjeev Premi | ef7bd71 | 2010-02-08 11:33:25 -0500 | [diff] [blame] | 38 | else |
Sanjeev Premi | ef7bd71 | 2010-02-08 11:33:25 -0500 | [diff] [blame] | 39 | cdiv = 1; |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 40 | |
| 41 | /* enable timer2 */ |
| 42 | val = readl(&prcm_base->clksel_wkup) | CLKSEL_GPT1; |
| 43 | |
| 44 | /* select sys_clk for GPT1 */ |
| 45 | writel(val, &prcm_base->clksel_wkup); |
| 46 | |
| 47 | /* Enable I and F Clocks for GPT1 */ |
| 48 | val = readl(&prcm_base->iclken_wkup) | EN_GPT1 | EN_32KSYNC; |
| 49 | writel(val, &prcm_base->iclken_wkup); |
Sanjeev Premi | ef7bd71 | 2010-02-08 11:33:25 -0500 | [diff] [blame] | 50 | |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 51 | val = readl(&prcm_base->fclken_wkup) | EN_GPT1; |
| 52 | writel(val, &prcm_base->fclken_wkup); |
| 53 | |
| 54 | writel(0, &gpt1_base->tldr); /* start counting at 0 */ |
| 55 | writel(GPT_EN, &gpt1_base->tclr); /* enable clock */ |
| 56 | |
| 57 | /* enable 32kHz source, determine sys_clk via gauging */ |
| 58 | |
| 59 | /* start time in 20 cycles */ |
| 60 | start = 20 + readl(&s32k_base->s32k_cr); |
| 61 | |
| 62 | /* dead loop till start time */ |
| 63 | while (readl(&s32k_base->s32k_cr) < start); |
| 64 | |
| 65 | /* get start sys_clk count */ |
| 66 | cstart = readl(&gpt1_base->tcrr); |
| 67 | |
| 68 | /* wait for 40 cycles */ |
| 69 | while (readl(&s32k_base->s32k_cr) < (start + 20)) ; |
| 70 | cend = readl(&gpt1_base->tcrr); /* get end sys_clk count */ |
| 71 | cdiff = cend - cstart; /* get elapsed ticks */ |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 72 | cdiff *= cdiv; |
Sanjeev Premi | ef7bd71 | 2010-02-08 11:33:25 -0500 | [diff] [blame] | 73 | |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 74 | /* based on number of ticks assign speed */ |
| 75 | if (cdiff > 19000) |
| 76 | return S38_4M; |
| 77 | else if (cdiff > 15200) |
| 78 | return S26M; |
| 79 | else if (cdiff > 13000) |
| 80 | return S24M; |
| 81 | else if (cdiff > 9000) |
| 82 | return S19_2M; |
| 83 | else if (cdiff > 7600) |
| 84 | return S13M; |
| 85 | else |
| 86 | return S12M; |
| 87 | } |
| 88 | |
| 89 | /****************************************************************************** |
| 90 | * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on |
| 91 | * input oscillator clock frequency. |
| 92 | *****************************************************************************/ |
Adam Ford | 7f2a606 | 2022-03-05 08:25:23 -0600 | [diff] [blame] | 93 | static void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel) |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 94 | { |
| 95 | switch(osc_clk) { |
| 96 | case S38_4M: |
| 97 | *sys_clkin_sel = 4; |
| 98 | break; |
| 99 | case S26M: |
| 100 | *sys_clkin_sel = 3; |
| 101 | break; |
| 102 | case S19_2M: |
| 103 | *sys_clkin_sel = 2; |
| 104 | break; |
| 105 | case S13M: |
| 106 | *sys_clkin_sel = 1; |
| 107 | break; |
| 108 | case S12M: |
| 109 | default: |
| 110 | *sys_clkin_sel = 0; |
| 111 | } |
| 112 | } |
| 113 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 114 | /* |
| 115 | * OMAP34XX/35XX specific functions |
| 116 | */ |
| 117 | |
| 118 | static void dpll3_init_34xx(u32 sil_index, u32 clk_index) |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 119 | { |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 120 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 121 | dpll_param *ptr = (dpll_param *) get_core_dpll_param(); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 122 | void (*f_lock_pll) (u32, u32, u32, u32); |
| 123 | int xip_safe, p0, p1, p2, p3; |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 124 | |
| 125 | xip_safe = is_running_in_sram(); |
| 126 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 127 | /* Moving to the right sysclk and ES rev base */ |
| 128 | ptr = ptr + (3 * clk_index) + sil_index; |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 129 | |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 130 | if (xip_safe) { |
| 131 | /* |
| 132 | * CORE DPLL |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 133 | */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 134 | clrsetbits_le32(&prcm_base->clken_pll, |
| 135 | 0x00000007, PLL_FAST_RELOCK_BYPASS); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 136 | wait_on_value(ST_CORE_CLK, 0, &prcm_base->idlest_ckgen, |
| 137 | LDELAY); |
| 138 | |
| 139 | /* |
| 140 | * For OMAP3 ES1.0 Errata 1.50, default value directly doesn't |
| 141 | * work. write another value and then default value. |
| 142 | */ |
| 143 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 144 | /* CM_CLKSEL1_EMU[DIV_DPLL3] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 145 | clrsetbits_le32(&prcm_base->clksel1_emu, |
| 146 | 0x001F0000, (CORE_M3X2 + 1) << 16) ; |
| 147 | clrsetbits_le32(&prcm_base->clksel1_emu, |
| 148 | 0x001F0000, CORE_M3X2 << 16); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 149 | |
| 150 | /* M2 (CORE_DPLL_CLKOUT_DIV): CM_CLKSEL1_PLL[27:31] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 151 | clrsetbits_le32(&prcm_base->clksel1_pll, |
| 152 | 0xF8000000, ptr->m2 << 27); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 153 | |
| 154 | /* M (CORE_DPLL_MULT): CM_CLKSEL1_PLL[16:26] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 155 | clrsetbits_le32(&prcm_base->clksel1_pll, |
| 156 | 0x07FF0000, ptr->m << 16); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 157 | |
| 158 | /* N (CORE_DPLL_DIV): CM_CLKSEL1_PLL[8:14] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 159 | clrsetbits_le32(&prcm_base->clksel1_pll, |
| 160 | 0x00007F00, ptr->n << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 161 | |
| 162 | /* Source is the CM_96M_FCLK: CM_CLKSEL1_PLL[6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 163 | clrbits_le32(&prcm_base->clksel1_pll, 0x00000040); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 164 | |
| 165 | /* SSI */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 166 | clrsetbits_le32(&prcm_base->clksel_core, |
| 167 | 0x00000F00, CORE_SSI_DIV << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 168 | /* FSUSB */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 169 | clrsetbits_le32(&prcm_base->clksel_core, |
| 170 | 0x00000030, CORE_FUSB_DIV << 4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 171 | /* L4 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 172 | clrsetbits_le32(&prcm_base->clksel_core, |
| 173 | 0x0000000C, CORE_L4_DIV << 2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 174 | /* L3 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 175 | clrsetbits_le32(&prcm_base->clksel_core, |
| 176 | 0x00000003, CORE_L3_DIV); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 177 | /* GFX */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 178 | clrsetbits_le32(&prcm_base->clksel_gfx, |
| 179 | 0x00000007, GFX_DIV); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 180 | /* RESET MGR */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 181 | clrsetbits_le32(&prcm_base->clksel_wkup, |
| 182 | 0x00000006, WKUP_RSM << 1); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 183 | /* FREQSEL (CORE_DPLL_FREQSEL): CM_CLKEN_PLL[4:7] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 184 | clrsetbits_le32(&prcm_base->clken_pll, |
| 185 | 0x000000F0, ptr->fsel << 4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 186 | /* LOCK MODE */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 187 | clrsetbits_le32(&prcm_base->clken_pll, |
| 188 | 0x00000007, PLL_LOCK); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 189 | |
| 190 | wait_on_value(ST_CORE_CLK, 1, &prcm_base->idlest_ckgen, |
| 191 | LDELAY); |
| 192 | } else if (is_running_in_flash()) { |
| 193 | /* |
| 194 | * if running from flash, jump to small relocated code |
| 195 | * area in SRAM. |
| 196 | */ |
Albert ARIBAUD | e3d0ad5 | 2013-08-10 19:03:59 +0200 | [diff] [blame] | 197 | f_lock_pll = (void *) (SRAM_CLK_CODE); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 198 | |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 199 | p0 = readl(&prcm_base->clken_pll); |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 200 | clrsetbits_le32(&p0, 0x00000007, PLL_FAST_RELOCK_BYPASS); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 201 | /* FREQSEL (CORE_DPLL_FREQSEL): CM_CLKEN_PLL[4:7] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 202 | clrsetbits_le32(&p0, 0x000000F0, ptr->fsel << 4); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 203 | |
| 204 | p1 = readl(&prcm_base->clksel1_pll); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 205 | /* M2 (CORE_DPLL_CLKOUT_DIV): CM_CLKSEL1_PLL[27:31] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 206 | clrsetbits_le32(&p1, 0xF8000000, ptr->m2 << 27); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 207 | /* M (CORE_DPLL_MULT): CM_CLKSEL1_PLL[16:26] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 208 | clrsetbits_le32(&p1, 0x07FF0000, ptr->m << 16); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 209 | /* N (CORE_DPLL_DIV): CM_CLKSEL1_PLL[8:14] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 210 | clrsetbits_le32(&p1, 0x00007F00, ptr->n << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 211 | /* Source is the CM_96M_FCLK: CM_CLKSEL1_PLL[6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 212 | clrbits_le32(&p1, 0x00000040); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 213 | |
| 214 | p2 = readl(&prcm_base->clksel_core); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 215 | /* SSI */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 216 | clrsetbits_le32(&p2, 0x00000F00, CORE_SSI_DIV << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 217 | /* FSUSB */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 218 | clrsetbits_le32(&p2, 0x00000030, CORE_FUSB_DIV << 4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 219 | /* L4 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 220 | clrsetbits_le32(&p2, 0x0000000C, CORE_L4_DIV << 2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 221 | /* L3 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 222 | clrsetbits_le32(&p2, 0x00000003, CORE_L3_DIV); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 223 | |
| 224 | p3 = (u32)&prcm_base->idlest_ckgen; |
| 225 | |
| 226 | (*f_lock_pll) (p0, p1, p2, p3); |
| 227 | } |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 228 | } |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 229 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 230 | static void dpll4_init_34xx(u32 sil_index, u32 clk_index) |
| 231 | { |
| 232 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 233 | dpll_param *ptr = (dpll_param *) get_per_dpll_param(); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 234 | |
| 235 | /* Moving it to the right sysclk base */ |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 236 | ptr = ptr + clk_index; |
| 237 | |
| 238 | /* EN_PERIPH_DPLL: CM_CLKEN_PLL[16:18] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 239 | clrsetbits_le32(&prcm_base->clken_pll, 0x00070000, PLL_STOP << 16); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 240 | wait_on_value(ST_PERIPH_CLK, 0, &prcm_base->idlest_ckgen, LDELAY); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 241 | |
| 242 | /* |
| 243 | * Errata 1.50 Workaround for OMAP3 ES1.0 only |
| 244 | * If using default divisors, write default divisor + 1 |
| 245 | * and then the actual divisor value |
| 246 | */ |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 247 | /* M6 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 248 | clrsetbits_le32(&prcm_base->clksel1_emu, |
| 249 | 0x1F000000, (PER_M6X2 + 1) << 24); |
| 250 | clrsetbits_le32(&prcm_base->clksel1_emu, |
| 251 | 0x1F000000, PER_M6X2 << 24); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 252 | /* M5 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 253 | clrsetbits_le32(&prcm_base->clksel_cam, 0x0000001F, (PER_M5X2 + 1)); |
| 254 | clrsetbits_le32(&prcm_base->clksel_cam, 0x0000001F, PER_M5X2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 255 | /* M4 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 256 | clrsetbits_le32(&prcm_base->clksel_dss, 0x0000001F, (PER_M4X2 + 1)); |
| 257 | clrsetbits_le32(&prcm_base->clksel_dss, 0x0000001F, PER_M4X2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 258 | /* M3 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 259 | clrsetbits_le32(&prcm_base->clksel_dss, |
| 260 | 0x00001F00, (PER_M3X2 + 1) << 8); |
| 261 | clrsetbits_le32(&prcm_base->clksel_dss, |
| 262 | 0x00001F00, PER_M3X2 << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 263 | /* M2 (DIV_96M): CM_CLKSEL3_PLL[0:4] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 264 | clrsetbits_le32(&prcm_base->clksel3_pll, 0x0000001F, (ptr->m2 + 1)); |
| 265 | clrsetbits_le32(&prcm_base->clksel3_pll, 0x0000001F, ptr->m2); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 266 | /* Workaround end */ |
| 267 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 268 | /* M (PERIPH_DPLL_MULT): CM_CLKSEL2_PLL[8:18] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 269 | clrsetbits_le32(&prcm_base->clksel2_pll, |
| 270 | 0x0007FF00, ptr->m << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 271 | |
| 272 | /* N (PERIPH_DPLL_DIV): CM_CLKSEL2_PLL[0:6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 273 | clrsetbits_le32(&prcm_base->clksel2_pll, 0x0000007F, ptr->n); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 274 | |
| 275 | /* FREQSEL (PERIPH_DPLL_FREQSEL): CM_CLKEN_PLL[20:23] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 276 | clrsetbits_le32(&prcm_base->clken_pll, 0x00F00000, ptr->fsel << 20); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 277 | |
| 278 | /* LOCK MODE (EN_PERIPH_DPLL): CM_CLKEN_PLL[16:18] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 279 | clrsetbits_le32(&prcm_base->clken_pll, 0x00070000, PLL_LOCK << 16); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 280 | wait_on_value(ST_PERIPH_CLK, 2, &prcm_base->idlest_ckgen, LDELAY); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 281 | } |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 282 | |
Alexander Holler | 96b549e | 2011-04-19 09:27:55 -0400 | [diff] [blame] | 283 | static void dpll5_init_34xx(u32 sil_index, u32 clk_index) |
| 284 | { |
| 285 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 286 | dpll_param *ptr = (dpll_param *) get_per2_dpll_param(); |
| 287 | |
| 288 | /* Moving it to the right sysclk base */ |
| 289 | ptr = ptr + clk_index; |
| 290 | |
| 291 | /* PER2 DPLL (DPLL5) */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 292 | clrsetbits_le32(&prcm_base->clken2_pll, 0x00000007, PLL_STOP); |
Alexander Holler | 96b549e | 2011-04-19 09:27:55 -0400 | [diff] [blame] | 293 | wait_on_value(1, 0, &prcm_base->idlest2_ckgen, LDELAY); |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 294 | /* set M2 (usbtll_fck) */ |
| 295 | clrsetbits_le32(&prcm_base->clksel5_pll, 0x0000001F, ptr->m2); |
| 296 | /* set m (11-bit multiplier) */ |
| 297 | clrsetbits_le32(&prcm_base->clksel4_pll, 0x0007FF00, ptr->m << 8); |
| 298 | /* set n (7-bit divider)*/ |
| 299 | clrsetbits_le32(&prcm_base->clksel4_pll, 0x0000007F, ptr->n); |
| 300 | /* FREQSEL */ |
| 301 | clrsetbits_le32(&prcm_base->clken_pll, 0x000000F0, ptr->fsel << 4); |
| 302 | /* lock mode */ |
| 303 | clrsetbits_le32(&prcm_base->clken2_pll, 0x00000007, PLL_LOCK); |
Alexander Holler | 96b549e | 2011-04-19 09:27:55 -0400 | [diff] [blame] | 304 | wait_on_value(1, 1, &prcm_base->idlest2_ckgen, LDELAY); |
| 305 | } |
| 306 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 307 | static void mpu_init_34xx(u32 sil_index, u32 clk_index) |
| 308 | { |
| 309 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 310 | dpll_param *ptr = (dpll_param *) get_mpu_dpll_param(); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 311 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 312 | /* Moving to the right sysclk and ES rev base */ |
| 313 | ptr = ptr + (3 * clk_index) + sil_index; |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 314 | |
| 315 | /* MPU DPLL (unlocked already) */ |
| 316 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 317 | /* M2 (MPU_DPLL_CLKOUT_DIV) : CM_CLKSEL2_PLL_MPU[0:4] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 318 | clrsetbits_le32(&prcm_base->clksel2_pll_mpu, |
| 319 | 0x0000001F, ptr->m2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 320 | |
| 321 | /* M (MPU_DPLL_MULT) : CM_CLKSEL2_PLL_MPU[8:18] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 322 | clrsetbits_le32(&prcm_base->clksel1_pll_mpu, |
| 323 | 0x0007FF00, ptr->m << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 324 | |
| 325 | /* N (MPU_DPLL_DIV) : CM_CLKSEL2_PLL_MPU[0:6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 326 | clrsetbits_le32(&prcm_base->clksel1_pll_mpu, |
| 327 | 0x0000007F, ptr->n); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 328 | |
| 329 | /* FREQSEL (MPU_DPLL_FREQSEL) : CM_CLKEN_PLL_MPU[4:7] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 330 | clrsetbits_le32(&prcm_base->clken_pll_mpu, |
| 331 | 0x000000F0, ptr->fsel << 4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | static void iva_init_34xx(u32 sil_index, u32 clk_index) |
| 335 | { |
| 336 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 337 | dpll_param *ptr = (dpll_param *) get_iva_dpll_param(); |
| 338 | |
| 339 | /* Moving to the right sysclk and ES rev base */ |
| 340 | ptr = ptr + (3 * clk_index) + sil_index; |
| 341 | |
| 342 | /* IVA DPLL */ |
| 343 | /* EN_IVA2_DPLL : CM_CLKEN_PLL_IVA2[0:2] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 344 | clrsetbits_le32(&prcm_base->clken_pll_iva2, |
| 345 | 0x00000007, PLL_STOP); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 346 | wait_on_value(ST_IVA2_CLK, 0, &prcm_base->idlest_pll_iva2, LDELAY); |
| 347 | |
| 348 | /* M2 (IVA2_DPLL_CLKOUT_DIV) : CM_CLKSEL2_PLL_IVA2[0:4] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 349 | clrsetbits_le32(&prcm_base->clksel2_pll_iva2, |
| 350 | 0x0000001F, ptr->m2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 351 | |
| 352 | /* M (IVA2_DPLL_MULT) : CM_CLKSEL1_PLL_IVA2[8:18] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 353 | clrsetbits_le32(&prcm_base->clksel1_pll_iva2, |
| 354 | 0x0007FF00, ptr->m << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 355 | |
| 356 | /* N (IVA2_DPLL_DIV) : CM_CLKSEL1_PLL_IVA2[0:6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 357 | clrsetbits_le32(&prcm_base->clksel1_pll_iva2, |
| 358 | 0x0000007F, ptr->n); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 359 | |
| 360 | /* FREQSEL (IVA2_DPLL_FREQSEL) : CM_CLKEN_PLL_IVA2[4:7] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 361 | clrsetbits_le32(&prcm_base->clken_pll_iva2, |
| 362 | 0x000000F0, ptr->fsel << 4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 363 | |
| 364 | /* LOCK MODE (EN_IVA2_DPLL) : CM_CLKEN_PLL_IVA2[0:2] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 365 | clrsetbits_le32(&prcm_base->clken_pll_iva2, |
| 366 | 0x00000007, PLL_LOCK); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 367 | |
| 368 | wait_on_value(ST_IVA2_CLK, 1, &prcm_base->idlest_pll_iva2, LDELAY); |
| 369 | } |
| 370 | |
| 371 | /* |
| 372 | * OMAP3630 specific functions |
| 373 | */ |
| 374 | |
| 375 | static void dpll3_init_36xx(u32 sil_index, u32 clk_index) |
| 376 | { |
| 377 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 378 | dpll_param *ptr = (dpll_param *) get_36x_core_dpll_param(); |
| 379 | void (*f_lock_pll) (u32, u32, u32, u32); |
| 380 | int xip_safe, p0, p1, p2, p3; |
| 381 | |
| 382 | xip_safe = is_running_in_sram(); |
| 383 | |
| 384 | /* Moving it to the right sysclk base */ |
| 385 | ptr += clk_index; |
| 386 | |
| 387 | if (xip_safe) { |
| 388 | /* CORE DPLL */ |
| 389 | |
| 390 | /* Select relock bypass: CM_CLKEN_PLL[0:2] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 391 | clrsetbits_le32(&prcm_base->clken_pll, |
| 392 | 0x00000007, PLL_FAST_RELOCK_BYPASS); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 393 | wait_on_value(ST_CORE_CLK, 0, &prcm_base->idlest_ckgen, |
| 394 | LDELAY); |
| 395 | |
| 396 | /* CM_CLKSEL1_EMU[DIV_DPLL3] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 397 | clrsetbits_le32(&prcm_base->clksel1_emu, |
| 398 | 0x001F0000, CORE_M3X2 << 16); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 399 | |
| 400 | /* M2 (CORE_DPLL_CLKOUT_DIV): CM_CLKSEL1_PLL[27:31] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 401 | clrsetbits_le32(&prcm_base->clksel1_pll, |
| 402 | 0xF8000000, ptr->m2 << 27); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 403 | |
| 404 | /* M (CORE_DPLL_MULT): CM_CLKSEL1_PLL[16:26] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 405 | clrsetbits_le32(&prcm_base->clksel1_pll, |
| 406 | 0x07FF0000, ptr->m << 16); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 407 | |
| 408 | /* N (CORE_DPLL_DIV): CM_CLKSEL1_PLL[8:14] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 409 | clrsetbits_le32(&prcm_base->clksel1_pll, |
| 410 | 0x00007F00, ptr->n << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 411 | |
| 412 | /* Source is the CM_96M_FCLK: CM_CLKSEL1_PLL[6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 413 | clrbits_le32(&prcm_base->clksel1_pll, 0x00000040); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 414 | |
| 415 | /* SSI */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 416 | clrsetbits_le32(&prcm_base->clksel_core, |
| 417 | 0x00000F00, CORE_SSI_DIV << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 418 | /* FSUSB */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 419 | clrsetbits_le32(&prcm_base->clksel_core, |
| 420 | 0x00000030, CORE_FUSB_DIV << 4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 421 | /* L4 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 422 | clrsetbits_le32(&prcm_base->clksel_core, |
| 423 | 0x0000000C, CORE_L4_DIV << 2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 424 | /* L3 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 425 | clrsetbits_le32(&prcm_base->clksel_core, |
| 426 | 0x00000003, CORE_L3_DIV); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 427 | /* GFX */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 428 | clrsetbits_le32(&prcm_base->clksel_gfx, |
| 429 | 0x00000007, GFX_DIV_36X); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 430 | /* RESET MGR */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 431 | clrsetbits_le32(&prcm_base->clksel_wkup, |
| 432 | 0x00000006, WKUP_RSM << 1); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 433 | /* FREQSEL (CORE_DPLL_FREQSEL): CM_CLKEN_PLL[4:7] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 434 | clrsetbits_le32(&prcm_base->clken_pll, |
| 435 | 0x000000F0, ptr->fsel << 4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 436 | /* LOCK MODE */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 437 | clrsetbits_le32(&prcm_base->clken_pll, |
| 438 | 0x00000007, PLL_LOCK); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 439 | |
| 440 | wait_on_value(ST_CORE_CLK, 1, &prcm_base->idlest_ckgen, |
| 441 | LDELAY); |
| 442 | } else if (is_running_in_flash()) { |
| 443 | /* |
| 444 | * if running from flash, jump to small relocated code |
| 445 | * area in SRAM. |
| 446 | */ |
Albert ARIBAUD | e3d0ad5 | 2013-08-10 19:03:59 +0200 | [diff] [blame] | 447 | f_lock_pll = (void *) (SRAM_CLK_CODE); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 448 | |
| 449 | p0 = readl(&prcm_base->clken_pll); |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 450 | clrsetbits_le32(&p0, 0x00000007, PLL_FAST_RELOCK_BYPASS); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 451 | /* FREQSEL (CORE_DPLL_FREQSEL): CM_CLKEN_PLL[4:7] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 452 | clrsetbits_le32(&p0, 0x000000F0, ptr->fsel << 4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 453 | |
| 454 | p1 = readl(&prcm_base->clksel1_pll); |
| 455 | /* M2 (CORE_DPLL_CLKOUT_DIV): CM_CLKSEL1_PLL[27:31] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 456 | clrsetbits_le32(&p1, 0xF8000000, ptr->m2 << 27); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 457 | /* M (CORE_DPLL_MULT): CM_CLKSEL1_PLL[16:26] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 458 | clrsetbits_le32(&p1, 0x07FF0000, ptr->m << 16); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 459 | /* N (CORE_DPLL_DIV): CM_CLKSEL1_PLL[8:14] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 460 | clrsetbits_le32(&p1, 0x00007F00, ptr->n << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 461 | /* Source is the CM_96M_FCLK: CM_CLKSEL1_PLL[6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 462 | clrbits_le32(&p1, 0x00000040); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 463 | |
| 464 | p2 = readl(&prcm_base->clksel_core); |
| 465 | /* SSI */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 466 | clrsetbits_le32(&p2, 0x00000F00, CORE_SSI_DIV << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 467 | /* FSUSB */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 468 | clrsetbits_le32(&p2, 0x00000030, CORE_FUSB_DIV << 4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 469 | /* L4 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 470 | clrsetbits_le32(&p2, 0x0000000C, CORE_L4_DIV << 2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 471 | /* L3 */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 472 | clrsetbits_le32(&p2, 0x00000003, CORE_L3_DIV); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 473 | |
| 474 | p3 = (u32)&prcm_base->idlest_ckgen; |
| 475 | |
| 476 | (*f_lock_pll) (p0, p1, p2, p3); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | static void dpll4_init_36xx(u32 sil_index, u32 clk_index) |
| 481 | { |
| 482 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 483 | struct dpll_per_36x_param *ptr; |
| 484 | |
| 485 | ptr = (struct dpll_per_36x_param *)get_36x_per_dpll_param(); |
| 486 | |
| 487 | /* Moving it to the right sysclk base */ |
| 488 | ptr += clk_index; |
| 489 | |
| 490 | /* EN_PERIPH_DPLL: CM_CLKEN_PLL[16:18] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 491 | clrsetbits_le32(&prcm_base->clken_pll, 0x00070000, PLL_STOP << 16); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 492 | wait_on_value(ST_PERIPH_CLK, 0, &prcm_base->idlest_ckgen, LDELAY); |
| 493 | |
| 494 | /* M6 (DIV_DPLL4): CM_CLKSEL1_EMU[24:29] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 495 | clrsetbits_le32(&prcm_base->clksel1_emu, 0x3F000000, ptr->m6 << 24); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 496 | |
| 497 | /* M5 (CLKSEL_CAM): CM_CLKSEL1_EMU[0:5] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 498 | clrsetbits_le32(&prcm_base->clksel_cam, 0x0000003F, ptr->m5); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 499 | |
| 500 | /* M4 (CLKSEL_DSS1): CM_CLKSEL_DSS[0:5] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 501 | clrsetbits_le32(&prcm_base->clksel_dss, 0x0000003F, ptr->m4); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 502 | |
| 503 | /* M3 (CLKSEL_DSS1): CM_CLKSEL_DSS[8:13] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 504 | clrsetbits_le32(&prcm_base->clksel_dss, 0x00003F00, ptr->m3 << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 505 | |
| 506 | /* M2 (DIV_96M): CM_CLKSEL3_PLL[0:4] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 507 | clrsetbits_le32(&prcm_base->clksel3_pll, 0x0000001F, ptr->m2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 508 | |
| 509 | /* M (PERIPH_DPLL_MULT): CM_CLKSEL2_PLL[8:19] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 510 | clrsetbits_le32(&prcm_base->clksel2_pll, 0x000FFF00, ptr->m << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 511 | |
| 512 | /* N (PERIPH_DPLL_DIV): CM_CLKSEL2_PLL[0:6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 513 | clrsetbits_le32(&prcm_base->clksel2_pll, 0x0000007F, ptr->n); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 514 | |
| 515 | /* M2DIV (CLKSEL_96M): CM_CLKSEL_CORE[12:13] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 516 | clrsetbits_le32(&prcm_base->clksel_core, 0x00003000, ptr->m2div << 12); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 517 | |
| 518 | /* LOCK MODE (EN_PERIPH_DPLL): CM_CLKEN_PLL[16:18] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 519 | clrsetbits_le32(&prcm_base->clken_pll, 0x00070000, PLL_LOCK << 16); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 520 | wait_on_value(ST_PERIPH_CLK, 2, &prcm_base->idlest_ckgen, LDELAY); |
| 521 | } |
| 522 | |
Naumann Andreas | 7330fd7 | 2013-07-09 09:43:17 +0200 | [diff] [blame] | 523 | static void dpll5_init_36xx(u32 sil_index, u32 clk_index) |
| 524 | { |
| 525 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 526 | dpll_param *ptr = (dpll_param *) get_36x_per2_dpll_param(); |
| 527 | |
| 528 | /* Moving it to the right sysclk base */ |
| 529 | ptr = ptr + clk_index; |
| 530 | |
| 531 | /* PER2 DPLL (DPLL5) */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 532 | clrsetbits_le32(&prcm_base->clken2_pll, 0x00000007, PLL_STOP); |
Naumann Andreas | 7330fd7 | 2013-07-09 09:43:17 +0200 | [diff] [blame] | 533 | wait_on_value(1, 0, &prcm_base->idlest2_ckgen, LDELAY); |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 534 | /* set M2 (usbtll_fck) */ |
| 535 | clrsetbits_le32(&prcm_base->clksel5_pll, 0x0000001F, ptr->m2); |
| 536 | /* set m (11-bit multiplier) */ |
| 537 | clrsetbits_le32(&prcm_base->clksel4_pll, 0x0007FF00, ptr->m << 8); |
| 538 | /* set n (7-bit divider)*/ |
| 539 | clrsetbits_le32(&prcm_base->clksel4_pll, 0x0000007F, ptr->n); |
| 540 | /* lock mode */ |
| 541 | clrsetbits_le32(&prcm_base->clken2_pll, 0x00000007, PLL_LOCK); |
Naumann Andreas | 7330fd7 | 2013-07-09 09:43:17 +0200 | [diff] [blame] | 542 | wait_on_value(1, 1, &prcm_base->idlest2_ckgen, LDELAY); |
| 543 | } |
| 544 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 545 | static void mpu_init_36xx(u32 sil_index, u32 clk_index) |
| 546 | { |
| 547 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 548 | dpll_param *ptr = (dpll_param *) get_36x_mpu_dpll_param(); |
| 549 | |
| 550 | /* Moving to the right sysclk */ |
| 551 | ptr += clk_index; |
| 552 | |
| 553 | /* MPU DPLL (unlocked already */ |
| 554 | |
| 555 | /* M2 (MPU_DPLL_CLKOUT_DIV) : CM_CLKSEL2_PLL_MPU[0:4] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 556 | clrsetbits_le32(&prcm_base->clksel2_pll_mpu, 0x0000001F, ptr->m2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 557 | |
| 558 | /* M (MPU_DPLL_MULT) : CM_CLKSEL2_PLL_MPU[8:18] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 559 | clrsetbits_le32(&prcm_base->clksel1_pll_mpu, 0x0007FF00, ptr->m << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 560 | |
| 561 | /* N (MPU_DPLL_DIV) : CM_CLKSEL2_PLL_MPU[0:6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 562 | clrsetbits_le32(&prcm_base->clksel1_pll_mpu, 0x0000007F, ptr->n); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 563 | } |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 564 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 565 | static void iva_init_36xx(u32 sil_index, u32 clk_index) |
| 566 | { |
| 567 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 568 | dpll_param *ptr = (dpll_param *)get_36x_iva_dpll_param(); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 569 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 570 | /* Moving to the right sysclk */ |
| 571 | ptr += clk_index; |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 572 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 573 | /* IVA DPLL */ |
| 574 | /* EN_IVA2_DPLL : CM_CLKEN_PLL_IVA2[0:2] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 575 | clrsetbits_le32(&prcm_base->clken_pll_iva2, 0x00000007, PLL_STOP); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 576 | wait_on_value(ST_IVA2_CLK, 0, &prcm_base->idlest_pll_iva2, LDELAY); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 577 | |
| 578 | /* M2 (IVA2_DPLL_CLKOUT_DIV) : CM_CLKSEL2_PLL_IVA2[0:4] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 579 | clrsetbits_le32(&prcm_base->clksel2_pll_iva2, 0x0000001F, ptr->m2); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 580 | |
| 581 | /* M (IVA2_DPLL_MULT) : CM_CLKSEL1_PLL_IVA2[8:18] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 582 | clrsetbits_le32(&prcm_base->clksel1_pll_iva2, 0x0007FF00, ptr->m << 8); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 583 | |
| 584 | /* N (IVA2_DPLL_DIV) : CM_CLKSEL1_PLL_IVA2[0:6] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 585 | clrsetbits_le32(&prcm_base->clksel1_pll_iva2, 0x0000007F, ptr->n); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 586 | |
| 587 | /* LOCK (MODE (EN_IVA2_DPLL) : CM_CLKEN_PLL_IVA2[0:2] */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 588 | clrsetbits_le32(&prcm_base->clken_pll_iva2, 0x00000007, PLL_LOCK); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 589 | |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 590 | wait_on_value(ST_IVA2_CLK, 1, &prcm_base->idlest_pll_iva2, LDELAY); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | /****************************************************************************** |
| 594 | * prcm_init() - inits clocks for PRCM as defined in clocks.h |
| 595 | * called from SRAM, or Flash (using temp SRAM stack). |
| 596 | *****************************************************************************/ |
| 597 | void prcm_init(void) |
| 598 | { |
| 599 | u32 osc_clk = 0, sys_clkin_sel; |
| 600 | u32 clk_index, sil_index = 0; |
| 601 | struct prm *prm_base = (struct prm *)PRM_BASE; |
| 602 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 603 | |
| 604 | /* |
| 605 | * Gauge the input clock speed and find out the sys_clkin_sel |
| 606 | * value corresponding to the input clock. |
| 607 | */ |
| 608 | osc_clk = get_osc_clk_speed(); |
| 609 | get_sys_clkin_sel(osc_clk, &sys_clkin_sel); |
| 610 | |
| 611 | /* set input crystal speed */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 612 | clrsetbits_le32(&prm_base->clksel, 0x00000007, sys_clkin_sel); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 613 | |
| 614 | /* If the input clock is greater than 19.2M always divide/2 */ |
| 615 | if (sys_clkin_sel > 2) { |
| 616 | /* input clock divider */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 617 | clrsetbits_le32(&prm_base->clksrc_ctrl, 0x000000C0, 2 << 6); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 618 | clk_index = sys_clkin_sel / 2; |
| 619 | } else { |
| 620 | /* input clock divider */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 621 | clrsetbits_le32(&prm_base->clksrc_ctrl, 0x000000C0, 1 << 6); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 622 | clk_index = sys_clkin_sel; |
| 623 | } |
| 624 | |
| 625 | if (get_cpu_family() == CPU_OMAP36XX) { |
Matt Porter | ede13a4 | 2012-05-07 16:49:21 +0000 | [diff] [blame] | 626 | /* |
| 627 | * In warm reset conditions on OMAP36xx/AM/DM37xx |
| 628 | * the rom code incorrectly sets the DPLL4 clock |
| 629 | * input divider to /6.5. Section 3.5.3.3.3.2.1 of |
| 630 | * the AM/DM37x TRM explains that the /6.5 divider |
| 631 | * is used only when the input clock is 13MHz. |
| 632 | * |
| 633 | * If the part is in this cpu family *and* the input |
| 634 | * clock *is not* 13 MHz, then reset the DPLL4 clock |
| 635 | * input divider to /1 as it should never set to /6.5 |
| 636 | * in this case. |
| 637 | */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 638 | if (sys_clkin_sel != 1) { /* 13 MHz */ |
Matt Porter | ede13a4 | 2012-05-07 16:49:21 +0000 | [diff] [blame] | 639 | /* Bit 8: DPLL4_CLKINP_DIV */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 640 | clrbits_le32(&prm_base->clksrc_ctrl, 0x00000100); |
| 641 | } |
Matt Porter | ede13a4 | 2012-05-07 16:49:21 +0000 | [diff] [blame] | 642 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 643 | /* Unlock MPU DPLL (slows things down, and needed later) */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 644 | clrsetbits_le32(&prcm_base->clken_pll_mpu, |
| 645 | 0x00000007, PLL_LOW_POWER_BYPASS); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 646 | wait_on_value(ST_MPU_CLK, 0, &prcm_base->idlest_pll_mpu, |
| 647 | LDELAY); |
| 648 | |
| 649 | dpll3_init_36xx(0, clk_index); |
| 650 | dpll4_init_36xx(0, clk_index); |
Naumann Andreas | 7330fd7 | 2013-07-09 09:43:17 +0200 | [diff] [blame] | 651 | dpll5_init_36xx(0, clk_index); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 652 | iva_init_36xx(0, clk_index); |
| 653 | mpu_init_36xx(0, clk_index); |
| 654 | |
| 655 | /* Lock MPU DPLL to set frequency */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 656 | clrsetbits_le32(&prcm_base->clken_pll_mpu, |
| 657 | 0x00000007, PLL_LOCK); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 658 | wait_on_value(ST_MPU_CLK, 1, &prcm_base->idlest_pll_mpu, |
| 659 | LDELAY); |
| 660 | } else { |
| 661 | /* |
| 662 | * The DPLL tables are defined according to sysclk value and |
| 663 | * silicon revision. The clk_index value will be used to get |
| 664 | * the values for that input sysclk from the DPLL param table |
| 665 | * and sil_index will get the values for that SysClk for the |
| 666 | * appropriate silicon rev. |
| 667 | */ |
| 668 | if (((get_cpu_family() == CPU_OMAP34XX) |
| 669 | && (get_cpu_rev() >= CPU_3XX_ES20)) || |
| 670 | (get_cpu_family() == CPU_AM35XX)) |
| 671 | sil_index = 1; |
| 672 | |
| 673 | /* Unlock MPU DPLL (slows things down, and needed later) */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 674 | clrsetbits_le32(&prcm_base->clken_pll_mpu, |
| 675 | 0x00000007, PLL_LOW_POWER_BYPASS); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 676 | wait_on_value(ST_MPU_CLK, 0, &prcm_base->idlest_pll_mpu, |
| 677 | LDELAY); |
| 678 | |
| 679 | dpll3_init_34xx(sil_index, clk_index); |
| 680 | dpll4_init_34xx(sil_index, clk_index); |
Alexander Holler | 96b549e | 2011-04-19 09:27:55 -0400 | [diff] [blame] | 681 | dpll5_init_34xx(sil_index, clk_index); |
Vaibhav Hiremath | 8f612c3 | 2011-09-03 21:35:31 -0400 | [diff] [blame] | 682 | if (get_cpu_family() != CPU_AM35XX) |
| 683 | iva_init_34xx(sil_index, clk_index); |
| 684 | |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 685 | mpu_init_34xx(sil_index, clk_index); |
| 686 | |
| 687 | /* Lock MPU DPLL to set frequency */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 688 | clrsetbits_le32(&prcm_base->clken_pll_mpu, |
| 689 | 0x00000007, PLL_LOCK); |
Steve Sakoman | 24e81c1 | 2010-08-18 07:34:09 -0700 | [diff] [blame] | 690 | wait_on_value(ST_MPU_CLK, 1, &prcm_base->idlest_pll_mpu, |
| 691 | LDELAY); |
| 692 | } |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 693 | |
| 694 | /* Set up GPTimers to sys_clk source only */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 695 | setbits_le32(&prcm_base->clksel_per, 0x000000FF); |
| 696 | setbits_le32(&prcm_base->clksel_wkup, 1); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 697 | |
| 698 | sdelay(5000); |
| 699 | } |
| 700 | |
Govindraj.R | 3968a6a | 2012-02-06 03:55:35 +0000 | [diff] [blame] | 701 | /* |
| 702 | * Enable usb ehci uhh, tll clocks |
| 703 | */ |
| 704 | void ehci_clocks_enable(void) |
| 705 | { |
| 706 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
| 707 | |
| 708 | /* Enable USBHOST_L3_ICLK (USBHOST_MICLK) */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 709 | setbits_le32(&prcm_base->iclken_usbhost, 1); |
Govindraj.R | 3968a6a | 2012-02-06 03:55:35 +0000 | [diff] [blame] | 710 | /* |
| 711 | * Enable USBHOST_48M_FCLK (USBHOST_FCLK1) |
| 712 | * and USBHOST_120M_FCLK (USBHOST_FCLK2) |
| 713 | */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 714 | setbits_le32(&prcm_base->fclken_usbhost, 0x00000003); |
Govindraj.R | 3968a6a | 2012-02-06 03:55:35 +0000 | [diff] [blame] | 715 | /* Enable USBTTL_ICLK */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 716 | setbits_le32(&prcm_base->iclken3_core, 0x00000004); |
Govindraj.R | 3968a6a | 2012-02-06 03:55:35 +0000 | [diff] [blame] | 717 | /* Enable USBTTL_FCLK */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 718 | setbits_le32(&prcm_base->fclken3_core, 0x00000004); |
Govindraj.R | 3968a6a | 2012-02-06 03:55:35 +0000 | [diff] [blame] | 719 | } |
| 720 | |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 721 | /****************************************************************************** |
| 722 | * peripheral_enable() - Enable the clks & power for perifs (GPT2, UART1,...) |
| 723 | *****************************************************************************/ |
| 724 | void per_clocks_enable(void) |
| 725 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 726 | struct prcm *prcm_base = (struct prcm *)PRCM_BASE; |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 727 | |
| 728 | /* Enable GP2 timer. */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 729 | setbits_le32(&prcm_base->clksel_per, 0x01); /* GPT2 = sys clk */ |
| 730 | setbits_le32(&prcm_base->iclken_per, 0x08); /* ICKen GPT2 */ |
| 731 | setbits_le32(&prcm_base->fclken_per, 0x08); /* FCKen GPT2 */ |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 732 | |
Albert ARIBAUD \(3ADEV\) | 4934467 | 2015-01-16 09:09:47 +0100 | [diff] [blame] | 733 | /* Enable GP9 timer. */ |
| 734 | setbits_le32(&prcm_base->clksel_per, 0x80); /* GPT9 = 32kHz clk */ |
| 735 | setbits_le32(&prcm_base->iclken_per, 0x400); /* ICKen GPT9 */ |
| 736 | setbits_le32(&prcm_base->fclken_per, 0x400); /* FCKen GPT9 */ |
| 737 | |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 738 | #ifdef CONFIG_SYS_NS16550 |
| 739 | /* Enable UART1 clocks */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 740 | setbits_le32(&prcm_base->fclken1_core, 0x00002000); |
| 741 | setbits_le32(&prcm_base->iclken1_core, 0x00002000); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 742 | |
Albert ARIBAUD \(3ADEV\) | 4934467 | 2015-01-16 09:09:47 +0100 | [diff] [blame] | 743 | /* Enable UART2 clocks */ |
| 744 | setbits_le32(&prcm_base->fclken1_core, 0x00004000); |
| 745 | setbits_le32(&prcm_base->iclken1_core, 0x00004000); |
| 746 | |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 747 | /* UART 3 Clocks */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 748 | setbits_le32(&prcm_base->fclken_per, 0x00000800); |
| 749 | setbits_le32(&prcm_base->iclken_per, 0x00000800); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 750 | #endif |
Tom Rix | de8ab06 | 2009-05-29 18:57:31 -0500 | [diff] [blame] | 751 | |
Adam Ford | 4ac7541 | 2018-12-14 16:28:30 -0600 | [diff] [blame] | 752 | #if defined(CONFIG_OMAP3_GPIO_2) |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 753 | setbits_le32(&prcm_base->fclken_per, 0x00002000); |
| 754 | setbits_le32(&prcm_base->iclken_per, 0x00002000); |
Tom Rix | de8ab06 | 2009-05-29 18:57:31 -0500 | [diff] [blame] | 755 | #endif |
Adam Ford | 4ac7541 | 2018-12-14 16:28:30 -0600 | [diff] [blame] | 756 | #if defined(CONFIG_OMAP3_GPIO_3) |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 757 | setbits_le32(&prcm_base->fclken_per, 0x00004000); |
| 758 | setbits_le32(&prcm_base->iclken_per, 0x00004000); |
Tom Rix | de8ab06 | 2009-05-29 18:57:31 -0500 | [diff] [blame] | 759 | #endif |
Adam Ford | 4ac7541 | 2018-12-14 16:28:30 -0600 | [diff] [blame] | 760 | #if defined(CONFIG_OMAP3_GPIO_4) |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 761 | setbits_le32(&prcm_base->fclken_per, 0x00008000); |
| 762 | setbits_le32(&prcm_base->iclken_per, 0x00008000); |
Tom Rix | de8ab06 | 2009-05-29 18:57:31 -0500 | [diff] [blame] | 763 | #endif |
Adam Ford | 4ac7541 | 2018-12-14 16:28:30 -0600 | [diff] [blame] | 764 | #if defined(CONFIG_OMAP3_GPIO_5) |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 765 | setbits_le32(&prcm_base->fclken_per, 0x00010000); |
| 766 | setbits_le32(&prcm_base->iclken_per, 0x00010000); |
Tom Rix | de8ab06 | 2009-05-29 18:57:31 -0500 | [diff] [blame] | 767 | #endif |
Adam Ford | 4ac7541 | 2018-12-14 16:28:30 -0600 | [diff] [blame] | 768 | #if defined(CONFIG_OMAP3_GPIO_6) |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 769 | setbits_le32(&prcm_base->fclken_per, 0x00020000); |
| 770 | setbits_le32(&prcm_base->iclken_per, 0x00020000); |
Tom Rix | de8ab06 | 2009-05-29 18:57:31 -0500 | [diff] [blame] | 771 | #endif |
| 772 | |
Adam Ford | 49e96f2 | 2017-08-07 13:11:19 -0500 | [diff] [blame] | 773 | #ifdef CONFIG_SYS_I2C_OMAP24XX |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 774 | /* Turn on all 3 I2C clocks */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 775 | setbits_le32(&prcm_base->fclken1_core, 0x00038000); |
| 776 | setbits_le32(&prcm_base->iclken1_core, 0x00038000); /* I2C1,2,3 = on */ |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 777 | #endif |
| 778 | /* Enable the ICLK for 32K Sync Timer as its used in udelay */ |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 779 | setbits_le32(&prcm_base->iclken_wkup, 0x00000004); |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 780 | |
Vaibhav Hiremath | 8f612c3 | 2011-09-03 21:35:31 -0400 | [diff] [blame] | 781 | if (get_cpu_family() != CPU_AM35XX) |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 782 | out_le32(&prcm_base->fclken_iva2, FCK_IVA2_ON); |
Vaibhav Hiremath | 8f612c3 | 2011-09-03 21:35:31 -0400 | [diff] [blame] | 783 | |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 784 | out_le32(&prcm_base->fclken1_core, FCK_CORE1_ON); |
| 785 | out_le32(&prcm_base->iclken1_core, ICK_CORE1_ON); |
| 786 | out_le32(&prcm_base->iclken2_core, ICK_CORE2_ON); |
| 787 | out_le32(&prcm_base->fclken_wkup, FCK_WKUP_ON); |
| 788 | out_le32(&prcm_base->iclken_wkup, ICK_WKUP_ON); |
| 789 | out_le32(&prcm_base->fclken_dss, FCK_DSS_ON); |
| 790 | out_le32(&prcm_base->iclken_dss, ICK_DSS_ON); |
Vaibhav Hiremath | 8f612c3 | 2011-09-03 21:35:31 -0400 | [diff] [blame] | 791 | if (get_cpu_family() != CPU_AM35XX) { |
Wolfgang Denk | a38b2e7 | 2014-03-25 14:49:50 +0100 | [diff] [blame] | 792 | out_le32(&prcm_base->fclken_cam, FCK_CAM_ON); |
| 793 | out_le32(&prcm_base->iclken_cam, ICK_CAM_ON); |
Vaibhav Hiremath | 8f612c3 | 2011-09-03 21:35:31 -0400 | [diff] [blame] | 794 | } |
Dirk Behme | 595d37b | 2008-12-14 09:47:14 +0100 | [diff] [blame] | 795 | |
| 796 | sdelay(1000); |
| 797 | } |