Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 1 | /* |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 2 | * SoC-specific lowlevel code for DA850 |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2011 |
| 5 | * Heiko Schocher, DENX Software Engineering, hs@denx.de. |
| 6 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 8 | */ |
| 9 | #include <common.h> |
| 10 | #include <nand.h> |
| 11 | #include <ns16550.h> |
| 12 | #include <post.h> |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 13 | #include <asm/arch/da850_lowlevel.h> |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 14 | #include <asm/arch/hardware.h> |
Christian Riesch | 6520471 | 2011-11-28 23:46:20 +0000 | [diff] [blame] | 15 | #include <asm/arch/davinci_misc.h> |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 16 | #include <asm/arch/ddr2_defs.h> |
Khoronzhuk, Ivan | 3e01ed0 | 2014-06-07 04:22:52 +0300 | [diff] [blame] | 17 | #include <asm/ti-common/davinci_nand.h> |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 18 | #include <asm/arch/pll_defs.h> |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 19 | |
Eric Benard | 81ac7e5 | 2013-04-22 05:54:59 +0000 | [diff] [blame] | 20 | void davinci_enable_uart0(void) |
| 21 | { |
| 22 | lpsc_on(DAVINCI_LPSC_UART0); |
| 23 | |
| 24 | /* Bringup UART0 out of reset */ |
| 25 | REG(UART0_PWREMU_MGMT) = 0x00006001; |
| 26 | } |
| 27 | |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 28 | #if defined(CONFIG_SYS_DA850_PLL_INIT) |
Manish Badarkhe | 893b92f | 2014-04-11 08:02:04 +0530 | [diff] [blame] | 29 | static void da850_waitloop(unsigned long loopcnt) |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 30 | { |
| 31 | unsigned long i; |
| 32 | |
| 33 | for (i = 0; i < loopcnt; i++) |
| 34 | asm(" NOP"); |
| 35 | } |
| 36 | |
Manish Badarkhe | 893b92f | 2014-04-11 08:02:04 +0530 | [diff] [blame] | 37 | static int da850_pll_init(struct davinci_pllc_regs *reg, unsigned long pllmult) |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 38 | { |
| 39 | if (reg == davinci_pllc0_regs) |
| 40 | /* Unlock PLL registers. */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 41 | clrbits_le32(&davinci_syscfg_regs->cfgchip0, PLL_MASTER_LOCK); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 42 | |
| 43 | /* |
| 44 | * Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled |
| 45 | * through MMR |
| 46 | */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 47 | clrbits_le32(®->pllctl, PLLCTL_PLLENSRC); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 48 | /* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 49 | clrbits_le32(®->pllctl, PLLCTL_EXTCLKSRC); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 50 | |
| 51 | /* Set PLLEN=0 => PLL BYPASS MODE */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 52 | clrbits_le32(®->pllctl, PLLCTL_PLLEN); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 53 | |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 54 | da850_waitloop(150); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 55 | |
| 56 | if (reg == davinci_pllc0_regs) { |
| 57 | /* |
| 58 | * Select the Clock Mode bit 8 as External Clock or On Chip |
| 59 | * Oscilator |
| 60 | */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 61 | dv_maskbits(®->pllctl, ~PLLCTL_RES_9); |
| 62 | setbits_le32(®->pllctl, |
| 63 | (CONFIG_SYS_DV_CLKMODE << PLLCTL_CLOCK_MODE_SHIFT)); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | /* Clear PLLRST bit to reset the PLL */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 67 | clrbits_le32(®->pllctl, PLLCTL_PLLRST); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 68 | |
| 69 | /* Disable the PLL output */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 70 | setbits_le32(®->pllctl, PLLCTL_PLLDIS); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 71 | |
| 72 | /* PLL initialization sequence */ |
| 73 | /* |
| 74 | * Power up the PLL- PWRDN bit set to 0 to bring the PLL out of |
| 75 | * power down bit |
| 76 | */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 77 | clrbits_le32(®->pllctl, PLLCTL_PLLPWRDN); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 78 | |
| 79 | /* Enable the PLL from Disable Mode PLLDIS bit to 0 */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 80 | clrbits_le32(®->pllctl, PLLCTL_PLLDIS); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 81 | |
Ben Gardiner | d652a34 | 2012-01-16 07:43:15 +0000 | [diff] [blame] | 82 | #if defined(CONFIG_SYS_DA850_PLL0_PREDIV) |
| 83 | /* program the prediv */ |
| 84 | if (reg == davinci_pllc0_regs && CONFIG_SYS_DA850_PLL0_PREDIV) |
| 85 | writel((PLL_DIVEN | CONFIG_SYS_DA850_PLL0_PREDIV), |
| 86 | ®->prediv); |
| 87 | #endif |
| 88 | |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 89 | /* Program the required multiplier value in PLLM */ |
| 90 | writel(pllmult, ®->pllm); |
| 91 | |
| 92 | /* program the postdiv */ |
| 93 | if (reg == davinci_pllc0_regs) |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 94 | writel((PLL_POSTDEN | CONFIG_SYS_DA850_PLL0_POSTDIV), |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 95 | ®->postdiv); |
| 96 | else |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 97 | writel((PLL_POSTDEN | CONFIG_SYS_DA850_PLL1_POSTDIV), |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 98 | ®->postdiv); |
| 99 | |
| 100 | /* |
| 101 | * Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that |
| 102 | * no GO operation is currently in progress |
| 103 | */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 104 | while ((readl(®->pllstat) & PLLCMD_GOSTAT) == PLLCMD_GOSTAT) |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 105 | ; |
| 106 | |
| 107 | if (reg == davinci_pllc0_regs) { |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 108 | writel(CONFIG_SYS_DA850_PLL0_PLLDIV1, ®->plldiv1); |
| 109 | writel(CONFIG_SYS_DA850_PLL0_PLLDIV2, ®->plldiv2); |
| 110 | writel(CONFIG_SYS_DA850_PLL0_PLLDIV3, ®->plldiv3); |
| 111 | writel(CONFIG_SYS_DA850_PLL0_PLLDIV4, ®->plldiv4); |
| 112 | writel(CONFIG_SYS_DA850_PLL0_PLLDIV5, ®->plldiv5); |
| 113 | writel(CONFIG_SYS_DA850_PLL0_PLLDIV6, ®->plldiv6); |
| 114 | writel(CONFIG_SYS_DA850_PLL0_PLLDIV7, ®->plldiv7); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 115 | } else { |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 116 | writel(CONFIG_SYS_DA850_PLL1_PLLDIV1, ®->plldiv1); |
| 117 | writel(CONFIG_SYS_DA850_PLL1_PLLDIV2, ®->plldiv2); |
| 118 | writel(CONFIG_SYS_DA850_PLL1_PLLDIV3, ®->plldiv3); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | /* |
| 122 | * Set the GOSET bit in PLLCMD to 1 to initiate a new divider |
| 123 | * transition. |
| 124 | */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 125 | setbits_le32(®->pllcmd, PLLCMD_GOSTAT); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 126 | |
| 127 | /* |
| 128 | * Wait for the GOSTAT bit in PLLSTAT to clear to 0 |
| 129 | * (completion of phase alignment). |
| 130 | */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 131 | while ((readl(®->pllstat) & PLLCMD_GOSTAT) == PLLCMD_GOSTAT) |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 132 | ; |
| 133 | |
| 134 | /* Wait for PLL to reset properly. See PLL spec for PLL reset time */ |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 135 | da850_waitloop(200); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 136 | |
| 137 | /* Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 138 | setbits_le32(®->pllctl, PLLCTL_PLLRST); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 139 | |
| 140 | /* Wait for PLL to lock. See PLL spec for PLL lock time */ |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 141 | da850_waitloop(2400); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 142 | |
| 143 | /* |
| 144 | * Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass |
| 145 | * mode |
| 146 | */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 147 | setbits_le32(®->pllctl, PLLCTL_PLLEN); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 148 | |
| 149 | |
| 150 | /* |
| 151 | * clear EMIFA and EMIFB clock source settings, let them |
| 152 | * run off SYSCLK |
| 153 | */ |
| 154 | if (reg == davinci_pllc0_regs) |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 155 | dv_maskbits(&davinci_syscfg_regs->cfgchip3, |
| 156 | ~(PLL_SCSCFG3_DIV45PENA | PLL_SCSCFG3_EMA_CLKSRC)); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 157 | |
| 158 | return 0; |
| 159 | } |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 160 | #endif /* CONFIG_SYS_DA850_PLL_INIT */ |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 161 | |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 162 | #if defined(CONFIG_SYS_DA850_DDR_INIT) |
Manish Badarkhe | 893b92f | 2014-04-11 08:02:04 +0530 | [diff] [blame] | 163 | static int da850_ddr_setup(void) |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 164 | { |
| 165 | unsigned long tmp; |
| 166 | |
| 167 | /* Enable the Clock to DDR2/mDDR */ |
Christian Riesch | 95c248f | 2011-11-08 08:55:10 -0500 | [diff] [blame] | 168 | lpsc_on(DAVINCI_LPSC_DDR_EMIF); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 169 | |
| 170 | tmp = readl(&davinci_syscfg1_regs->vtpio_ctl); |
| 171 | if ((tmp & VTP_POWERDWN) == VTP_POWERDWN) { |
| 172 | /* Begin VTP Calibration */ |
| 173 | clrbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_POWERDWN); |
| 174 | clrbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_LOCK); |
| 175 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_CLKRZ); |
| 176 | clrbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_CLKRZ); |
| 177 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_CLKRZ); |
| 178 | |
| 179 | /* Polling READY bit to see when VTP calibration is done */ |
| 180 | tmp = readl(&davinci_syscfg1_regs->vtpio_ctl); |
| 181 | while ((tmp & VTP_READY) != VTP_READY) |
| 182 | tmp = readl(&davinci_syscfg1_regs->vtpio_ctl); |
| 183 | |
| 184 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_LOCK); |
| 185 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_POWERDWN); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 186 | } |
Mikhail Kshevetskiy | 89473d2 | 2012-07-09 08:52:41 +0000 | [diff] [blame] | 187 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_IOPWRDWN); |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 188 | writel(CONFIG_SYS_DA850_DDR2_DDRPHYCR, &dv_ddr2_regs_ctrl->ddrphycr); |
Mikhail Kshevetskiy | 89473d2 | 2012-07-09 08:52:41 +0000 | [diff] [blame] | 189 | |
| 190 | if (CONFIG_SYS_DA850_DDR2_SDBCR & (1 << DV_DDR_SDCR_DDR2EN_SHIFT)) { |
| 191 | /* DDR2 */ |
| 192 | clrbits_le32(&davinci_syscfg1_regs->ddr_slew, |
| 193 | (1 << DDR_SLEW_DDR_PDENA_BIT) | |
| 194 | (1 << DDR_SLEW_CMOSEN_BIT)); |
| 195 | } else { |
| 196 | /* MOBILE DDR */ |
| 197 | setbits_le32(&davinci_syscfg1_regs->ddr_slew, |
| 198 | (1 << DDR_SLEW_DDR_PDENA_BIT) | |
| 199 | (1 << DDR_SLEW_CMOSEN_BIT)); |
| 200 | } |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 201 | |
Christian Riesch | 085d457 | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 202 | /* |
| 203 | * SDRAM Configuration Register (SDCR): |
| 204 | * First set the BOOTUNLOCK bit to make configuration bits |
| 205 | * writeable. |
| 206 | */ |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 207 | setbits_le32(&dv_ddr2_regs_ctrl->sdbcr, DV_DDR_BOOTUNLOCK); |
| 208 | |
Christian Riesch | 085d457 | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 209 | /* |
| 210 | * Write the new value of these bits and clear BOOTUNLOCK. |
| 211 | * At the same time, set the TIMUNLOCK bit to allow changing |
| 212 | * the timing registers |
| 213 | */ |
| 214 | tmp = CONFIG_SYS_DA850_DDR2_SDBCR; |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 215 | tmp &= ~DV_DDR_BOOTUNLOCK; |
| 216 | tmp |= DV_DDR_TIMUNLOCK; |
Christian Riesch | 085d457 | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 217 | writel(tmp, &dv_ddr2_regs_ctrl->sdbcr); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 218 | |
Christian Riesch | 085d457 | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 219 | /* write memory configuration and timing */ |
Mikhail Kshevetskiy | 89473d2 | 2012-07-09 08:52:41 +0000 | [diff] [blame] | 220 | if (!(CONFIG_SYS_DA850_DDR2_SDBCR & (1 << DV_DDR_SDCR_DDR2EN_SHIFT))) { |
| 221 | /* MOBILE DDR only*/ |
| 222 | writel(CONFIG_SYS_DA850_DDR2_SDBCR2, |
| 223 | &dv_ddr2_regs_ctrl->sdbcr2); |
| 224 | } |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 225 | writel(CONFIG_SYS_DA850_DDR2_SDTIMR, &dv_ddr2_regs_ctrl->sdtimr); |
| 226 | writel(CONFIG_SYS_DA850_DDR2_SDTIMR2, &dv_ddr2_regs_ctrl->sdtimr2); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 227 | |
Christian Riesch | 085d457 | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 228 | /* clear the TIMUNLOCK bit and write the value of the CL field */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 229 | tmp &= ~DV_DDR_TIMUNLOCK; |
Christian Riesch | 085d457 | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 230 | writel(tmp, &dv_ddr2_regs_ctrl->sdbcr); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 231 | |
| 232 | /* |
| 233 | * LPMODEN and MCLKSTOPEN must be set! |
| 234 | * Without this bits set, PSC don;t switch states !! |
| 235 | */ |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 236 | writel(CONFIG_SYS_DA850_DDR2_SDRCR | |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 237 | (1 << DV_DDR_SRCR_LPMODEN_SHIFT) | |
| 238 | (1 << DV_DDR_SRCR_MCLKSTOPEN_SHIFT), |
| 239 | &dv_ddr2_regs_ctrl->sdrcr); |
| 240 | |
| 241 | /* SyncReset the Clock to EMIF3A SDRAM */ |
Christian Riesch | 95c248f | 2011-11-08 08:55:10 -0500 | [diff] [blame] | 242 | lpsc_syncreset(DAVINCI_LPSC_DDR_EMIF); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 243 | /* Enable the Clock to EMIF3A SDRAM */ |
Christian Riesch | 95c248f | 2011-11-08 08:55:10 -0500 | [diff] [blame] | 244 | lpsc_on(DAVINCI_LPSC_DDR_EMIF); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 245 | |
| 246 | /* disable self refresh */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 247 | clrbits_le32(&dv_ddr2_regs_ctrl->sdrcr, |
Mikhail Kshevetskiy | 89473d2 | 2012-07-09 08:52:41 +0000 | [diff] [blame] | 248 | DV_DDR_SDRCR_LPMODEN | DV_DDR_SDRCR_MCLKSTOPEN); |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 249 | writel(CONFIG_SYS_DA850_DDR2_PBBPR, &dv_ddr2_regs_ctrl->pbbpr); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 250 | |
| 251 | return 0; |
| 252 | } |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 253 | #endif /* CONFIG_SYS_DA850_DDR_INIT */ |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 254 | |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 255 | __attribute__((weak)) |
| 256 | void board_gpio_init(void) |
| 257 | { |
| 258 | return; |
| 259 | } |
| 260 | |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 261 | int arch_cpu_init(void) |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 262 | { |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 263 | /* Unlock kick registers */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 264 | writel(DV_SYSCFG_KICK0_UNLOCK, &davinci_syscfg_regs->kick0); |
| 265 | writel(DV_SYSCFG_KICK1_UNLOCK, &davinci_syscfg_regs->kick1); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 266 | |
| 267 | dv_maskbits(&davinci_syscfg_regs->suspsrc, |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 268 | CONFIG_SYS_DA850_SYSCFG_SUSPSRC); |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 269 | |
Christian Riesch | 6520471 | 2011-11-28 23:46:20 +0000 | [diff] [blame] | 270 | /* configure pinmux settings */ |
| 271 | if (davinci_configure_pin_mux_items(pinmuxes, pinmuxes_size)) |
| 272 | return 1; |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 273 | |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 274 | #if defined(CONFIG_SYS_DA850_PLL_INIT) |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 275 | /* PLL setup */ |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 276 | da850_pll_init(davinci_pllc0_regs, CONFIG_SYS_DA850_PLL0_PLLM); |
| 277 | da850_pll_init(davinci_pllc1_regs, CONFIG_SYS_DA850_PLL1_PLLM); |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 278 | #endif |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 279 | /* setup CSn config */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 280 | #if defined(CONFIG_SYS_DA850_CS2CFG) |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 281 | writel(CONFIG_SYS_DA850_CS2CFG, &davinci_emif_regs->ab1cr); |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 282 | #endif |
| 283 | #if defined(CONFIG_SYS_DA850_CS3CFG) |
Christian Riesch | effea9d | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 284 | writel(CONFIG_SYS_DA850_CS3CFG, &davinci_emif_regs->ab2cr); |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 285 | #endif |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 286 | |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 287 | da8xx_configure_lpsc_items(lpsc, lpsc_size); |
| 288 | |
| 289 | /* GPIO setup */ |
| 290 | board_gpio_init(); |
| 291 | |
| 292 | |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 293 | NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM1), |
| 294 | CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); |
| 295 | |
| 296 | /* |
| 297 | * Fix Power and Emulation Management Register |
| 298 | * see sprufw3a.pdf page 37 Table 24 |
| 299 | */ |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 300 | writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | |
| 301 | DAVINCI_UART_PWREMU_MGMT_UTRST), |
Heiko Schocher | 9c8deae | 2013-08-05 16:00:37 +0200 | [diff] [blame] | 302 | #if (CONFIG_SYS_NS16550_COM1 == DAVINCI_UART0_BASE) |
| 303 | &davinci_uart0_ctrl_regs->pwremu_mgmt); |
| 304 | #else |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 305 | &davinci_uart2_ctrl_regs->pwremu_mgmt); |
Heiko Schocher | 9c8deae | 2013-08-05 16:00:37 +0200 | [diff] [blame] | 306 | #endif |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 307 | |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 308 | #if defined(CONFIG_SYS_DA850_DDR_INIT) |
Heiko Schocher | f3c149d | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 309 | da850_ddr_setup(); |
Sughosh Ganu | 6b873dc | 2012-02-02 00:44:41 +0000 | [diff] [blame] | 310 | #endif |
| 311 | |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 312 | return 0; |
Heiko Schocher | 310ae55 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 313 | } |