blob: e5cc824f487794f5b590239c363a680da26116ac [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
Scott Wood865b8ae2007-04-16 14:54:15 -050023
24DECLARE_GLOBAL_DATA_PTR;
25
26int board_early_init_f(void)
27{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020028#ifndef CONFIG_SYS_8313ERDB_BROKEN_PMC
29 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
Scott Wood865b8ae2007-04-16 14:54:15 -050030
31 if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
32 gd->flags |= GD_FLG_SILENT;
33#endif
Scott Wood488af0d2012-12-06 13:33:18 +000034#if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
Joe Hershberger37dabcc2011-11-11 15:55:38 -060035 mpc83xx_gpio_init_f();
36#endif
37
38 return 0;
39}
40
41int board_early_init_r(void)
42{
Scott Wood488af0d2012-12-06 13:33:18 +000043#if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD)
Joe Hershberger37dabcc2011-11-11 15:55:38 -060044 mpc83xx_gpio_init_r();
45#endif
Scott Wood865b8ae2007-04-16 14:54:15 -050046
47 return 0;
48}
49
50int checkboard(void)
51{
52 puts("Board: Freescale MPC8313ERDB\n");
53 return 0;
54}
55
Scott Wood488af0d2012-12-06 13:33:18 +000056#ifndef CONFIG_SPL_BUILD
Scott Wood865b8ae2007-04-16 14:54:15 -050057static struct pci_region pci_regions[] = {
58 {
Kim Phillipsb5c312a2012-10-29 13:34:39 +000059 .bus_start = CONFIG_SYS_PCI1_MEM_BASE,
60 .phys_start = CONFIG_SYS_PCI1_MEM_PHYS,
61 .size = CONFIG_SYS_PCI1_MEM_SIZE,
62 .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH
Scott Wood865b8ae2007-04-16 14:54:15 -050063 },
64 {
Kim Phillipsb5c312a2012-10-29 13:34:39 +000065 .bus_start = CONFIG_SYS_PCI1_MMIO_BASE,
66 .phys_start = CONFIG_SYS_PCI1_MMIO_PHYS,
67 .size = CONFIG_SYS_PCI1_MMIO_SIZE,
68 .flags = PCI_REGION_MEM
Scott Wood865b8ae2007-04-16 14:54:15 -050069 },
70 {
Kim Phillipsb5c312a2012-10-29 13:34:39 +000071 .bus_start = CONFIG_SYS_PCI1_IO_BASE,
72 .phys_start = CONFIG_SYS_PCI1_IO_PHYS,
73 .size = CONFIG_SYS_PCI1_IO_SIZE,
74 .flags = PCI_REGION_IO
Scott Wood865b8ae2007-04-16 14:54:15 -050075 }
76};
77
78void pci_init_board(void)
79{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020080 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
Scott Wood865b8ae2007-04-16 14:54:15 -050081 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
82 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
83 struct pci_region *reg[] = { pci_regions };
Scott Wood865b8ae2007-04-16 14:54:15 -050084
85 /* Enable all 3 PCI_CLK_OUTPUTs. */
86 clk->occr |= 0xe0000000;
87
88 /*
89 * Configure PCI Local Access Windows
90 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020091 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
Scott Wood865b8ae2007-04-16 14:54:15 -050092 pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
93
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020094 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
Scott Wood865b8ae2007-04-16 14:54:15 -050095 pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
96
Peter Tysere2283322010-09-14 19:13:50 -050097 mpc83xx_pci_init(1, reg);
Scott Wood865b8ae2007-04-16 14:54:15 -050098}
99
Timur Tabi3e1d49a2008-02-08 13:15:55 -0600100/*
101 * Miscellaneous late-boot configurations
102 *
103 * If a VSC7385 microcode image is present, then upload it.
104*/
105int misc_init_r(void)
106{
107 int rc = 0;
108
109#ifdef CONFIG_VSC7385_IMAGE
110 if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE,
111 CONFIG_VSC7385_IMAGE_SIZE)) {
112 puts("Failure uploading VSC7385 microcode.\n");
113 rc = 1;
114 }
115#endif
116
117 return rc;
118}
119
Kim Phillips21416812007-08-15 22:30:33 -0500120#if defined(CONFIG_OF_BOARD_SETUP)
Simon Glass2aec3cc2014-10-23 18:58:47 -0600121int ft_board_setup(void *blob, bd_t *bd)
Scott Wood865b8ae2007-04-16 14:54:15 -0500122{
Kim Phillips21416812007-08-15 22:30:33 -0500123 ft_cpu_setup(blob, bd);
124#ifdef CONFIG_PCI
125 ft_pci_setup(blob, bd);
126#endif
Simon Glass2aec3cc2014-10-23 18:58:47 -0600127
128 return 0;
Scott Wood865b8ae2007-04-16 14:54:15 -0500129}
130#endif
Scott Wood488af0d2012-12-06 13:33:18 +0000131#else /* CONFIG_SPL_BUILD */
Scott Woodb71689b2008-06-30 14:13:28 -0500132void board_init_f(ulong bootflag)
133{
134 board_early_init_f();
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200135 NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200136 CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
Scott Woodb71689b2008-06-30 14:13:28 -0500137 puts("NAND boot... ");
Simon Glass4c974d72017-03-28 10:27:24 -0600138 timer_init();
Simon Glassd35f3382017-04-06 12:47:05 -0600139 dram_init();
Mingkai Hu6b2b95b2009-09-11 10:53:08 +0800140 relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, (gd_t *)gd,
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200141 CONFIG_SYS_NAND_U_BOOT_RELOC);
Scott Woodb71689b2008-06-30 14:13:28 -0500142}
143
144void board_init_r(gd_t *gd, ulong dest_addr)
145{
146 nand_boot();
147}
148
149void putc(char c)
150{
151 if (gd->flags & GD_FLG_SILENT)
152 return;
153
154 if (c == '\n')
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200155 NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
Scott Woodb71689b2008-06-30 14:13:28 -0500156
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200157 NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
Scott Woodb71689b2008-06-30 14:13:28 -0500158}
159#endif