blob: 3bf5cff1e1007fcd1f06b5e8934e3ac385b239ab [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Scott Wood865b8ae2007-04-16 14:54:15 -05002/*
3 * Copyright (C) Freescale Semiconductor, Inc. 2006-2007
4 *
5 * Author: Scott Wood <scottwood@freescale.com>
Scott Wood865b8ae2007-04-16 14:54:15 -05006 */
7
8#include <common.h>
Simon Glass85d65312019-12-28 10:44:58 -07009#include <clock_legacy.h>
Simon Glass3bbe70c2019-12-28 10:44:54 -070010#include <fdt_support.h>
Simon Glassa7b51302019-11-14 12:57:46 -070011#include <init.h>
Kim Phillips3204c7c2007-12-20 15:57:28 -060012#if defined(CONFIG_OF_LIBFDT)
Masahiro Yamada75f82d02018-03-05 01:20:11 +090013#include <linux/libfdt.h>
Kim Phillips21416812007-08-15 22:30:33 -050014#endif
Scott Wood865b8ae2007-04-16 14:54:15 -050015#include <pci.h>
16#include <mpc83xx.h>
Timur Tabi3e1d49a2008-02-08 13:15:55 -060017#include <vsc7385.h>
Scott Woodb71689b2008-06-30 14:13:28 -050018#include <ns16550.h>
19#include <nand.h>
Scott Wood488af0d2012-12-06 13:33:18 +000020#if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
Joe Hershberger37dabcc2011-11-11 15:55:38 -060021#include <asm/gpio.h>
22#endif
Simon Glass3ba929a2020-10-30 21:38:53 -060023#include <asm/global_data.h>
Scott Wood865b8ae2007-04-16 14:54:15 -050024
25DECLARE_GLOBAL_DATA_PTR;
26
27int board_early_init_f(void)
28{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020029#ifndef CONFIG_SYS_8313ERDB_BROKEN_PMC
30 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
Scott Wood865b8ae2007-04-16 14:54:15 -050031
32 if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
33 gd->flags |= GD_FLG_SILENT;
34#endif
Scott Wood488af0d2012-12-06 13:33:18 +000035#if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
Joe Hershberger37dabcc2011-11-11 15:55:38 -060036 mpc83xx_gpio_init_f();
37#endif
38
39 return 0;
40}
41
42int board_early_init_r(void)
43{
Scott Wood488af0d2012-12-06 13:33:18 +000044#if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
Joe Hershberger37dabcc2011-11-11 15:55:38 -060045 mpc83xx_gpio_init_r();
46#endif
Scott Wood865b8ae2007-04-16 14:54:15 -050047
48 return 0;
49}
50
51int checkboard(void)
52{
53 puts("Board: Freescale MPC8313ERDB\n");
54 return 0;
55}
56
Scott Wood488af0d2012-12-06 13:33:18 +000057#ifndef CONFIG_SPL_BUILD
Scott Wood865b8ae2007-04-16 14:54:15 -050058static struct pci_region pci_regions[] = {
59 {
Kim Phillipsb5c312a2012-10-29 13:34:39 +000060 .bus_start = CONFIG_SYS_PCI1_MEM_BASE,
61 .phys_start = CONFIG_SYS_PCI1_MEM_PHYS,
62 .size = CONFIG_SYS_PCI1_MEM_SIZE,
63 .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH
Scott Wood865b8ae2007-04-16 14:54:15 -050064 },
65 {
Kim Phillipsb5c312a2012-10-29 13:34:39 +000066 .bus_start = CONFIG_SYS_PCI1_MMIO_BASE,
67 .phys_start = CONFIG_SYS_PCI1_MMIO_PHYS,
68 .size = CONFIG_SYS_PCI1_MMIO_SIZE,
69 .flags = PCI_REGION_MEM
Scott Wood865b8ae2007-04-16 14:54:15 -050070 },
71 {
Kim Phillipsb5c312a2012-10-29 13:34:39 +000072 .bus_start = CONFIG_SYS_PCI1_IO_BASE,
73 .phys_start = CONFIG_SYS_PCI1_IO_PHYS,
74 .size = CONFIG_SYS_PCI1_IO_SIZE,
75 .flags = PCI_REGION_IO
Scott Wood865b8ae2007-04-16 14:54:15 -050076 }
77};
78
79void pci_init_board(void)
80{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020081 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
Scott Wood865b8ae2007-04-16 14:54:15 -050082 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
83 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
84 struct pci_region *reg[] = { pci_regions };
Scott Wood865b8ae2007-04-16 14:54:15 -050085
86 /* Enable all 3 PCI_CLK_OUTPUTs. */
87 clk->occr |= 0xe0000000;
88
89 /*
90 * Configure PCI Local Access Windows
91 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020092 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Scott Wood865b8ae2007-04-16 14:54:15 -050093 pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
94
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020095 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Scott Wood865b8ae2007-04-16 14:54:15 -050096 pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
97
Peter Tysere2283322010-09-14 19:13:50 -050098 mpc83xx_pci_init(1, reg);
Scott Wood865b8ae2007-04-16 14:54:15 -050099}
100
Timur Tabi3e1d49a2008-02-08 13:15:55 -0600101/*
102 * Miscellaneous late-boot configurations
103 *
104 * If a VSC7385 microcode image is present, then upload it.
105*/
106int misc_init_r(void)
107{
108 int rc = 0;
109
110#ifdef CONFIG_VSC7385_IMAGE
111 if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE,
112 CONFIG_VSC7385_IMAGE_SIZE)) {
113 puts("Failure uploading VSC7385 microcode.\n");
114 rc = 1;
115 }
116#endif
117
118 return rc;
119}
120
Kim Phillips21416812007-08-15 22:30:33 -0500121#if defined(CONFIG_OF_BOARD_SETUP)
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900122int ft_board_setup(void *blob, struct bd_info *bd)
Scott Wood865b8ae2007-04-16 14:54:15 -0500123{
Kim Phillips21416812007-08-15 22:30:33 -0500124 ft_cpu_setup(blob, bd);
125#ifdef CONFIG_PCI
126 ft_pci_setup(blob, bd);
127#endif
Simon Glass2aec3cc2014-10-23 18:58:47 -0600128
129 return 0;
Scott Wood865b8ae2007-04-16 14:54:15 -0500130}
131#endif
Scott Wood488af0d2012-12-06 13:33:18 +0000132#else /* CONFIG_SPL_BUILD */
Scott Woodb71689b2008-06-30 14:13:28 -0500133void board_init_f(ulong bootflag)
134{
135 board_early_init_f();
Simon Glass2b923982020-12-22 19:30:19 -0700136 ns16550_init((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500),
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200137 CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
Scott Woodb71689b2008-06-30 14:13:28 -0500138 puts("NAND boot... ");
Simon Glass4c974d72017-03-28 10:27:24 -0600139 timer_init();
Simon Glassd35f3382017-04-06 12:47:05 -0600140 dram_init();
Mingkai Hu6b2b95b2009-09-11 10:53:08 +0800141 relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, (gd_t *)gd,
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200142 CONFIG_SYS_NAND_U_BOOT_RELOC);
Scott Woodb71689b2008-06-30 14:13:28 -0500143}
144
145void board_init_r(gd_t *gd, ulong dest_addr)
146{
147 nand_boot();
148}
149
150void putc(char c)
151{
152 if (gd->flags & GD_FLG_SILENT)
153 return;
154
155 if (c == '\n')
Simon Glass2b923982020-12-22 19:30:19 -0700156 ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), '\r');
Scott Woodb71689b2008-06-30 14:13:28 -0500157
Simon Glass2b923982020-12-22 19:30:19 -0700158 ns16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), c);
Scott Woodb71689b2008-06-30 14:13:28 -0500159}
160#endif