blob: 648f0ec3e3feaa369a52a19aece54dbbf9e5e44f [file] [log] [blame]
Scott Wood96b8a052007-04-16 14:54:15 -05001/*
2 * Copyright (C) Freescale Semiconductor, Inc. 2006-2007
3 *
4 * Author: Scott Wood <scottwood@freescale.com>
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25#include <common.h>
Kim Phillipsb3458d22007-12-20 15:57:28 -060026#if defined(CONFIG_OF_LIBFDT)
Kim Phillips3fde9e82007-08-15 22:30:33 -050027#include <libfdt.h>
28#endif
Scott Wood96b8a052007-04-16 14:54:15 -050029#include <pci.h>
30#include <mpc83xx.h>
Timur Tabi89c77842008-02-08 13:15:55 -060031#include <vsc7385.h>
Scott Woode4c09502008-06-30 14:13:28 -050032#include <ns16550.h>
33#include <nand.h>
Scott Wood22f44422012-12-06 13:33:18 +000034#if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
Joe Hershberger0eaf8f92011-11-11 15:55:38 -060035#include <asm/gpio.h>
36#endif
Scott Wood96b8a052007-04-16 14:54:15 -050037
38DECLARE_GLOBAL_DATA_PTR;
39
40int board_early_init_f(void)
41{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020042#ifndef CONFIG_SYS_8313ERDB_BROKEN_PMC
43 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
Scott Wood96b8a052007-04-16 14:54:15 -050044
45 if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
46 gd->flags |= GD_FLG_SILENT;
47#endif
Scott Wood22f44422012-12-06 13:33:18 +000048#if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
Joe Hershberger0eaf8f92011-11-11 15:55:38 -060049 mpc83xx_gpio_init_f();
50#endif
51
52 return 0;
53}
54
55int board_early_init_r(void)
56{
Scott Wood22f44422012-12-06 13:33:18 +000057#if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
Joe Hershberger0eaf8f92011-11-11 15:55:38 -060058 mpc83xx_gpio_init_r();
59#endif
Scott Wood96b8a052007-04-16 14:54:15 -050060
61 return 0;
62}
63
64int checkboard(void)
65{
66 puts("Board: Freescale MPC8313ERDB\n");
67 return 0;
68}
69
Scott Wood22f44422012-12-06 13:33:18 +000070#ifndef CONFIG_SPL_BUILD
Scott Wood96b8a052007-04-16 14:54:15 -050071static struct pci_region pci_regions[] = {
72 {
Kim Phillipsa2873bd2012-10-29 13:34:39 +000073 .bus_start = CONFIG_SYS_PCI1_MEM_BASE,
74 .phys_start = CONFIG_SYS_PCI1_MEM_PHYS,
75 .size = CONFIG_SYS_PCI1_MEM_SIZE,
76 .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH
Scott Wood96b8a052007-04-16 14:54:15 -050077 },
78 {
Kim Phillipsa2873bd2012-10-29 13:34:39 +000079 .bus_start = CONFIG_SYS_PCI1_MMIO_BASE,
80 .phys_start = CONFIG_SYS_PCI1_MMIO_PHYS,
81 .size = CONFIG_SYS_PCI1_MMIO_SIZE,
82 .flags = PCI_REGION_MEM
Scott Wood96b8a052007-04-16 14:54:15 -050083 },
84 {
Kim Phillipsa2873bd2012-10-29 13:34:39 +000085 .bus_start = CONFIG_SYS_PCI1_IO_BASE,
86 .phys_start = CONFIG_SYS_PCI1_IO_PHYS,
87 .size = CONFIG_SYS_PCI1_IO_SIZE,
88 .flags = PCI_REGION_IO
Scott Wood96b8a052007-04-16 14:54:15 -050089 }
90};
91
92void pci_init_board(void)
93{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020094 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
Scott Wood96b8a052007-04-16 14:54:15 -050095 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
96 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
97 struct pci_region *reg[] = { pci_regions };
Scott Wood96b8a052007-04-16 14:54:15 -050098
99 /* Enable all 3 PCI_CLK_OUTPUTs. */
100 clk->occr |= 0xe0000000;
101
102 /*
103 * Configure PCI Local Access Windows
104 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200105 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Scott Wood96b8a052007-04-16 14:54:15 -0500106 pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
107
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200108 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Scott Wood96b8a052007-04-16 14:54:15 -0500109 pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
110
Peter Tyser6aa3d3b2010-09-14 19:13:50 -0500111 mpc83xx_pci_init(1, reg);
Scott Wood96b8a052007-04-16 14:54:15 -0500112}
113
Timur Tabi89c77842008-02-08 13:15:55 -0600114/*
115 * Miscellaneous late-boot configurations
116 *
117 * If a VSC7385 microcode image is present, then upload it.
118*/
119int misc_init_r(void)
120{
121 int rc = 0;
122
123#ifdef CONFIG_VSC7385_IMAGE
124 if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE,
125 CONFIG_VSC7385_IMAGE_SIZE)) {
126 puts("Failure uploading VSC7385 microcode.\n");
127 rc = 1;
128 }
129#endif
130
131 return rc;
132}
133
Kim Phillips3fde9e82007-08-15 22:30:33 -0500134#if defined(CONFIG_OF_BOARD_SETUP)
Scott Wood96b8a052007-04-16 14:54:15 -0500135void ft_board_setup(void *blob, bd_t *bd)
136{
Kim Phillips3fde9e82007-08-15 22:30:33 -0500137 ft_cpu_setup(blob, bd);
138#ifdef CONFIG_PCI
139 ft_pci_setup(blob, bd);
140#endif
Scott Wood96b8a052007-04-16 14:54:15 -0500141}
142#endif
Scott Wood22f44422012-12-06 13:33:18 +0000143#else /* CONFIG_SPL_BUILD */
Scott Woode4c09502008-06-30 14:13:28 -0500144void board_init_f(ulong bootflag)
145{
146 board_early_init_f();
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200147 NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
148 CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
Scott Woode4c09502008-06-30 14:13:28 -0500149 puts("NAND boot... ");
150 init_timebase();
151 initdram(0);
Mingkai Hu6e1385d2009-09-11 10:53:08 +0800152 relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, (gd_t *)gd,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200153 CONFIG_SYS_NAND_U_BOOT_RELOC);
Scott Woode4c09502008-06-30 14:13:28 -0500154}
155
156void board_init_r(gd_t *gd, ulong dest_addr)
157{
158 nand_boot();
159}
160
161void putc(char c)
162{
163 if (gd->flags & GD_FLG_SILENT)
164 return;
165
166 if (c == '\n')
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200167 NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
Scott Woode4c09502008-06-30 14:13:28 -0500168
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200169 NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
Scott Woode4c09502008-06-30 14:13:28 -0500170}
171#endif