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