1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) Freescale Semiconductor, Inc. 2006-2007
5 * Author: Scott Wood <scottwood@freescale.com>
8 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
12 #include <fdt_support.h>
14 #include <linux/libfdt.h>
20 #include <asm/bitops.h>
23 DECLARE_GLOBAL_DATA_PTR;
25 extern void disable_addr_trans (void);
26 extern void enable_addr_trans (void);
30 puts("Board: ve8313\n");
34 static long fixed_sdram(void)
36 u32 msize = CONFIG_SYS_DDR_SIZE * 1024 * 1024;
38 #ifndef CONFIG_SYS_RAMBOOT
39 volatile immap_t *im = (volatile immap_t *)CONFIG_SYS_IMMR;
40 u32 msize_log2 = __ilog2(msize);
42 out_be32(&im->sysconf.ddrlaw[0].bar,
43 (CONFIG_SYS_SDRAM_BASE & 0xfffff000));
44 out_be32(&im->sysconf.ddrlaw[0].ar, (LBLAWAR_EN | (msize_log2 - 1)));
45 out_be32(&im->sysconf.ddrcdr, CONFIG_SYS_DDRCDR_VALUE);
48 * Erratum DDR3 requires a 50ms delay after clearing DDRCDR[DDR_cfg],
49 * or the DDR2 controller may fail to initialize correctly.
53 #if ((CONFIG_SYS_SDRAM_BASE & 0x00FFFFFF) != 0)
54 #warning Chip select bounds is only configurable in 16MB increments
56 out_be32(&im->ddr.csbnds[0].csbnds,
57 ((CONFIG_SYS_SDRAM_BASE >> CSBNDS_SA_SHIFT) & CSBNDS_SA) |
58 (((CONFIG_SYS_SDRAM_BASE + msize - 1) >> CSBNDS_EA_SHIFT) &
60 out_be32(&im->ddr.cs_config[0], CONFIG_SYS_DDR_CS0_CONFIG);
62 /* Currently we use only one CS, so disable the other bank. */
63 out_be32(&im->ddr.cs_config[1], 0);
65 out_be32(&im->ddr.sdram_clk_cntl, CONFIG_SYS_DDR_CLK_CNTL);
66 out_be32(&im->ddr.timing_cfg_3, CONFIG_SYS_DDR_TIMING_3);
67 out_be32(&im->ddr.timing_cfg_1, CONFIG_SYS_DDR_TIMING_1);
68 out_be32(&im->ddr.timing_cfg_2, CONFIG_SYS_DDR_TIMING_2);
69 out_be32(&im->ddr.timing_cfg_0, CONFIG_SYS_DDR_TIMING_0);
71 out_be32(&im->ddr.sdram_cfg, CONFIG_SYS_SDRAM_CFG);
73 out_be32(&im->ddr.sdram_cfg2, CONFIG_SYS_SDRAM_CFG2);
74 out_be32(&im->ddr.sdram_mode, CONFIG_SYS_DDR_MODE);
75 out_be32(&im->ddr.sdram_mode2, CONFIG_SYS_DDR_MODE_2);
77 out_be32(&im->ddr.sdram_interval, CONFIG_SYS_DDR_INTERVAL);
80 /* enable DDR controller */
81 setbits_be32(&im->ddr.sdram_cfg, SDRAM_CFG_MEM_EN);
83 /* now check the real size */
84 disable_addr_trans ();
85 msize = get_ram_size(CONFIG_SYS_SDRAM_BASE, msize);
94 volatile immap_t *im = (volatile immap_t *)CONFIG_SYS_IMMR;
95 volatile fsl_lbc_t *lbc = &im->im_lbc;
98 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
101 /* DDR SDRAM - Main SODIMM */
102 msize = fixed_sdram();
104 /* Local Bus setup lbcr and mrtpr */
105 out_be32(&lbc->lbcr, 0x00040000);
106 out_be32(&lbc->mrtpr, 0x20000000);
109 /* return total bus SDRAM size(bytes) -- DDR */
110 gd->ram_size = msize;
115 #define VE8313_WDT_EN 0x00020000
116 #define VE8313_WDT_TRIG 0x00040000
118 int board_early_init_f (void)
120 volatile immap_t *im = (volatile immap_t *)CONFIG_SYS_IMMR;
121 volatile gpio83xx_t *gpio = (volatile gpio83xx_t *)im->gpio;
123 #if defined(CONFIG_HW_WATCHDOG)
125 clrbits_be32(&gpio->dat, VE8313_WDT_EN | VE8313_WDT_TRIG);
128 setbits_be32(&gpio->dat, VE8313_WDT_EN | VE8313_WDT_TRIG);
130 /* set WDT pins as output */
131 setbits_be32(&gpio->dir, VE8313_WDT_EN | VE8313_WDT_TRIG);
136 #if defined(CONFIG_HW_WATCHDOG)
137 void hw_watchdog_reset(void)
139 volatile immap_t *im = (volatile immap_t *)CONFIG_SYS_IMMR;
140 volatile gpio83xx_t *gpio = (volatile gpio83xx_t *)im->gpio;
143 reg = in_be32(&gpio->dat);
144 if (reg & VE8313_WDT_TRIG)
145 clrbits_be32(&gpio->dat, VE8313_WDT_TRIG);
147 setbits_be32(&gpio->dat, VE8313_WDT_TRIG);
152 #if defined(CONFIG_PCI)
153 static struct pci_region pci_regions[] = {
155 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
156 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
157 size: CONFIG_SYS_PCI1_MEM_SIZE,
158 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
161 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
162 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
163 size: CONFIG_SYS_PCI1_MMIO_SIZE,
164 flags: PCI_REGION_MEM
167 bus_start: CONFIG_SYS_PCI1_IO_BASE,
168 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
169 size: CONFIG_SYS_PCI1_IO_SIZE,
174 void pci_init_board(void)
176 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
177 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
178 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
179 struct pci_region *reg[] = { pci_regions };
181 /* Enable all 3 PCI_CLK_OUTPUTs. */
182 setbits_be32(&clk->occr, 0xe0000000);
185 * Configure PCI Local Access Windows
187 out_be32(&pci_law[0].bar, CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR);
188 out_be32(&pci_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB);
190 out_be32(&pci_law[1].bar, CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR);
191 out_be32(&pci_law[1].ar, LBLAWAR_EN | LBLAWAR_1MB);
193 mpc83xx_pci_init(1, reg);
197 #if defined(CONFIG_OF_BOARD_SETUP)
198 int ft_board_setup(void *blob, bd_t *bd)
200 ft_cpu_setup(blob, bd);
202 ft_pci_setup(blob, bd);