Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 1 | /* |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 2 | * SoC-specific lowlevel code for DA850 |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2011 |
| 5 | * Heiko Schocher, DENX Software Engineering, hs@denx.de. |
| 6 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 23 | */ |
| 24 | #include <common.h> |
| 25 | #include <nand.h> |
| 26 | #include <ns16550.h> |
| 27 | #include <post.h> |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 28 | #include <asm/arch/da850_lowlevel.h> |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 29 | #include <asm/arch/hardware.h> |
Christian Riesch | 2eb6050 | 2011-11-28 23:46:20 +0000 | [diff] [blame] | 30 | #include <asm/arch/davinci_misc.h> |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 31 | #include <asm/arch/ddr2_defs.h> |
| 32 | #include <asm/arch/emif_defs.h> |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 33 | #include <asm/arch/pll_defs.h> |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 34 | |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 35 | void da850_waitloop(unsigned long loopcnt) |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 36 | { |
| 37 | unsigned long i; |
| 38 | |
| 39 | for (i = 0; i < loopcnt; i++) |
| 40 | asm(" NOP"); |
| 41 | } |
| 42 | |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 43 | int da850_pll_init(struct davinci_pllc_regs *reg, unsigned long pllmult) |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 44 | { |
| 45 | if (reg == davinci_pllc0_regs) |
| 46 | /* Unlock PLL registers. */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 47 | clrbits_le32(&davinci_syscfg_regs->cfgchip0, PLL_MASTER_LOCK); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled |
| 51 | * through MMR |
| 52 | */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 53 | clrbits_le32(®->pllctl, PLLCTL_PLLENSRC); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 54 | /* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 55 | clrbits_le32(®->pllctl, PLLCTL_EXTCLKSRC); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 56 | |
| 57 | /* Set PLLEN=0 => PLL BYPASS MODE */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 58 | clrbits_le32(®->pllctl, PLLCTL_PLLEN); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 59 | |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 60 | da850_waitloop(150); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 61 | |
| 62 | if (reg == davinci_pllc0_regs) { |
| 63 | /* |
| 64 | * Select the Clock Mode bit 8 as External Clock or On Chip |
| 65 | * Oscilator |
| 66 | */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 67 | dv_maskbits(®->pllctl, ~PLLCTL_RES_9); |
| 68 | setbits_le32(®->pllctl, |
| 69 | (CONFIG_SYS_DV_CLKMODE << PLLCTL_CLOCK_MODE_SHIFT)); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | /* Clear PLLRST bit to reset the PLL */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 73 | clrbits_le32(®->pllctl, PLLCTL_PLLRST); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 74 | |
| 75 | /* Disable the PLL output */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 76 | setbits_le32(®->pllctl, PLLCTL_PLLDIS); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 77 | |
| 78 | /* PLL initialization sequence */ |
| 79 | /* |
| 80 | * Power up the PLL- PWRDN bit set to 0 to bring the PLL out of |
| 81 | * power down bit |
| 82 | */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 83 | clrbits_le32(®->pllctl, PLLCTL_PLLPWRDN); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 84 | |
| 85 | /* Enable the PLL from Disable Mode PLLDIS bit to 0 */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 86 | clrbits_le32(®->pllctl, PLLCTL_PLLDIS); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 87 | |
| 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 | } |
| 159 | |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 160 | int da850_ddr_setup(void) |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 161 | { |
| 162 | unsigned long tmp; |
| 163 | |
| 164 | /* Enable the Clock to DDR2/mDDR */ |
Christian Riesch | 99271c8 | 2011-11-08 08:55:10 -0500 | [diff] [blame] | 165 | lpsc_on(DAVINCI_LPSC_DDR_EMIF); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 166 | |
| 167 | tmp = readl(&davinci_syscfg1_regs->vtpio_ctl); |
| 168 | if ((tmp & VTP_POWERDWN) == VTP_POWERDWN) { |
| 169 | /* Begin VTP Calibration */ |
| 170 | clrbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_POWERDWN); |
| 171 | clrbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_LOCK); |
| 172 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_CLKRZ); |
| 173 | clrbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_CLKRZ); |
| 174 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_CLKRZ); |
| 175 | |
| 176 | /* Polling READY bit to see when VTP calibration is done */ |
| 177 | tmp = readl(&davinci_syscfg1_regs->vtpio_ctl); |
| 178 | while ((tmp & VTP_READY) != VTP_READY) |
| 179 | tmp = readl(&davinci_syscfg1_regs->vtpio_ctl); |
| 180 | |
| 181 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_LOCK); |
| 182 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_POWERDWN); |
| 183 | |
| 184 | setbits_le32(&davinci_syscfg1_regs->vtpio_ctl, VTP_IOPWRDWN); |
| 185 | } |
| 186 | |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 187 | writel(CONFIG_SYS_DA850_DDR2_DDRPHYCR, &dv_ddr2_regs_ctrl->ddrphycr); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 188 | clrbits_le32(&davinci_syscfg1_regs->ddr_slew, |
| 189 | (1 << DDR_SLEW_CMOSEN_BIT)); |
| 190 | |
Christian Riesch | 81ad48e | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 191 | /* |
| 192 | * SDRAM Configuration Register (SDCR): |
| 193 | * First set the BOOTUNLOCK bit to make configuration bits |
| 194 | * writeable. |
| 195 | */ |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 196 | setbits_le32(&dv_ddr2_regs_ctrl->sdbcr, DV_DDR_BOOTUNLOCK); |
| 197 | |
Christian Riesch | 81ad48e | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 198 | /* |
| 199 | * Write the new value of these bits and clear BOOTUNLOCK. |
| 200 | * At the same time, set the TIMUNLOCK bit to allow changing |
| 201 | * the timing registers |
| 202 | */ |
| 203 | tmp = CONFIG_SYS_DA850_DDR2_SDBCR; |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 204 | tmp &= ~DV_DDR_BOOTUNLOCK; |
| 205 | tmp |= DV_DDR_TIMUNLOCK; |
Christian Riesch | 81ad48e | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 206 | writel(tmp, &dv_ddr2_regs_ctrl->sdbcr); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 207 | |
Christian Riesch | 81ad48e | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 208 | /* write memory configuration and timing */ |
| 209 | writel(CONFIG_SYS_DA850_DDR2_SDBCR2, &dv_ddr2_regs_ctrl->sdbcr2); |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 210 | writel(CONFIG_SYS_DA850_DDR2_SDTIMR, &dv_ddr2_regs_ctrl->sdtimr); |
| 211 | writel(CONFIG_SYS_DA850_DDR2_SDTIMR2, &dv_ddr2_regs_ctrl->sdtimr2); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 212 | |
Christian Riesch | 81ad48e | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 213 | /* clear the TIMUNLOCK bit and write the value of the CL field */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 214 | tmp &= ~DV_DDR_TIMUNLOCK; |
Christian Riesch | 81ad48e | 2011-11-08 08:55:13 -0500 | [diff] [blame] | 215 | writel(tmp, &dv_ddr2_regs_ctrl->sdbcr); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 216 | |
| 217 | /* |
| 218 | * LPMODEN and MCLKSTOPEN must be set! |
| 219 | * Without this bits set, PSC don;t switch states !! |
| 220 | */ |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 221 | writel(CONFIG_SYS_DA850_DDR2_SDRCR | |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 222 | (1 << DV_DDR_SRCR_LPMODEN_SHIFT) | |
| 223 | (1 << DV_DDR_SRCR_MCLKSTOPEN_SHIFT), |
| 224 | &dv_ddr2_regs_ctrl->sdrcr); |
| 225 | |
| 226 | /* SyncReset the Clock to EMIF3A SDRAM */ |
Christian Riesch | 99271c8 | 2011-11-08 08:55:10 -0500 | [diff] [blame] | 227 | lpsc_syncreset(DAVINCI_LPSC_DDR_EMIF); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 228 | /* Enable the Clock to EMIF3A SDRAM */ |
Christian Riesch | 99271c8 | 2011-11-08 08:55:10 -0500 | [diff] [blame] | 229 | lpsc_on(DAVINCI_LPSC_DDR_EMIF); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 230 | |
| 231 | /* disable self refresh */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 232 | clrbits_le32(&dv_ddr2_regs_ctrl->sdrcr, |
| 233 | DV_DDR_SDRCR_LPMODEN | DV_DDR_SDRCR_LPMODEN); |
| 234 | writel(CONFIG_SYS_DA850_DDR2_PBBPR, &dv_ddr2_regs_ctrl->pbbpr); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 235 | |
| 236 | return 0; |
| 237 | } |
| 238 | |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 239 | __attribute__((weak)) |
| 240 | void board_gpio_init(void) |
| 241 | { |
| 242 | return; |
| 243 | } |
| 244 | |
Christian Riesch | 2eb6050 | 2011-11-28 23:46:20 +0000 | [diff] [blame] | 245 | /* pinmux_resource[] vector is defined in the board specific file */ |
| 246 | extern const struct pinmux_resource pinmuxes[]; |
| 247 | extern const int pinmuxes_size; |
| 248 | |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 249 | int arch_cpu_init(void) |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 250 | { |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 251 | /* Unlock kick registers */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 252 | writel(DV_SYSCFG_KICK0_UNLOCK, &davinci_syscfg_regs->kick0); |
| 253 | writel(DV_SYSCFG_KICK1_UNLOCK, &davinci_syscfg_regs->kick1); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 254 | |
| 255 | dv_maskbits(&davinci_syscfg_regs->suspsrc, |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 256 | CONFIG_SYS_DA850_SYSCFG_SUSPSRC); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 257 | |
Christian Riesch | 2eb6050 | 2011-11-28 23:46:20 +0000 | [diff] [blame] | 258 | /* configure pinmux settings */ |
| 259 | if (davinci_configure_pin_mux_items(pinmuxes, pinmuxes_size)) |
| 260 | return 1; |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 261 | |
| 262 | /* PLL setup */ |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 263 | da850_pll_init(davinci_pllc0_regs, CONFIG_SYS_DA850_PLL0_PLLM); |
| 264 | da850_pll_init(davinci_pllc1_regs, CONFIG_SYS_DA850_PLL1_PLLM); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 265 | |
| 266 | /* GPIO setup */ |
| 267 | board_gpio_init(); |
| 268 | |
| 269 | /* setup CSn config */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 270 | #if defined(CONFIG_SYS_DA850_CS2CFG) |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 271 | writel(CONFIG_SYS_DA850_CS2CFG, &davinci_emif_regs->ab1cr); |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 272 | #endif |
| 273 | #if defined(CONFIG_SYS_DA850_CS3CFG) |
Christian Riesch | 0e5e0c5 | 2011-11-08 08:55:07 -0500 | [diff] [blame] | 274 | writel(CONFIG_SYS_DA850_CS3CFG, &davinci_emif_regs->ab2cr); |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 275 | #endif |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 276 | |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 277 | lpsc_on(CONFIG_SYS_DA850_LPSC_UART); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 278 | NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM1), |
| 279 | CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); |
| 280 | |
| 281 | /* |
| 282 | * Fix Power and Emulation Management Register |
| 283 | * see sprufw3a.pdf page 37 Table 24 |
| 284 | */ |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 285 | writel((DAVINCI_UART_PWREMU_MGMT_FREE | DAVINCI_UART_PWREMU_MGMT_URRST | |
| 286 | DAVINCI_UART_PWREMU_MGMT_UTRST), |
| 287 | &davinci_uart2_ctrl_regs->pwremu_mgmt); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 288 | |
Heiko Schocher | 34061e8 | 2011-11-15 10:00:02 -0500 | [diff] [blame] | 289 | da850_ddr_setup(); |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 290 | return 0; |
Heiko Schocher | fe954e3 | 2011-09-14 19:59:38 +0000 | [diff] [blame] | 291 | } |