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