blob: 31406fa66d3fa227a2b824ba4a728ca53b956da5 [file] [log] [blame]
Ron Madrid5bb907a2009-01-22 15:05:24 -08001/*
2 * Copyright (C) Freescale Semiconductor, Inc. 2006-2007
3 * Copyright (C) Sheldon Instruments, Inc. 2008
4 *
5 * Author: Ron Madrid <info@sheldoninst.com>
6 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Ron Madrid5bb907a2009-01-22 15:05:24 -08008 */
9
10#include <common.h>
11#include <libfdt.h>
12#include <pci.h>
13#include <mpc83xx.h>
14#include <ns16550.h>
15#include <nand.h>
Ron Madrid3b439792010-04-28 16:04:43 -070016#include <asm/io.h>
Ron Madrid5bb907a2009-01-22 15:05:24 -080017
18DECLARE_GLOBAL_DATA_PTR;
19
Ron Madride74244c2010-05-10 15:23:20 -070020#ifndef CONFIG_NAND_SPL
Ron Madrid5bb907a2009-01-22 15:05:24 -080021int checkboard(void)
22{
23 puts("Board: Sheldon Instruments SIMPC8313\n");
24 return 0;
25}
26
Ron Madrid5bb907a2009-01-22 15:05:24 -080027static struct pci_region pci_regions[] = {
28 {
29 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
30 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
31 size: CONFIG_SYS_PCI1_MEM_SIZE,
32 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
33 },
34 {
35 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
36 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
37 size: CONFIG_SYS_PCI1_MMIO_SIZE,
38 flags: PCI_REGION_MEM
39 },
40 {
41 bus_start: CONFIG_SYS_PCI1_IO_BASE,
42 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
43 size: CONFIG_SYS_PCI1_IO_SIZE,
44 flags: PCI_REGION_IO
45 }
46};
47
48void pci_init_board(void)
49{
50 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
51 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
52 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
53 struct pci_region *reg[] = { pci_regions };
Ron Madrid5bb907a2009-01-22 15:05:24 -080054
55 /* Enable all 3 PCI_CLK_OUTPUTs. */
56 clk->occr |= 0xe0000000;
57
58 /*
59 * Configure PCI Local Access Windows
60 */
61 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
62 pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
63
64 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
65 pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
66
Peter Tyser6aa3d3b2010-09-14 19:13:50 -050067 mpc83xx_pci_init(1, reg);
Ron Madrid5bb907a2009-01-22 15:05:24 -080068}
69
70/*
71 * Miscellaneous late-boot configurations
72 */
73int misc_init_r(void)
74{
75 int rc = 0;
Ron Madrid3b439792010-04-28 16:04:43 -070076 immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Becky Brucef51cdaf2010-06-17 11:37:20 -050077 fsl_lbc_t *lbus = &immap->im_lbc;
Ron Madrid3b439792010-04-28 16:04:43 -070078 u32 *mxmr = &lbus->mamr; /* Pointer to mamr */
79
80 /* UPM Table Configuration Code */
81 static uint UPMATable[] = {
82 /* Read Single-Beat (RSS) */
83 0x0fff0c00, 0x0fffdc00, 0x0fff0c05, 0xfffffc00,
84 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
85 /* Read Burst (RBS) */
86 0x0fff0c00, 0x0ffcdc00, 0x0ffc0c00, 0x0ffc0f0c,
87 0x0ffccf0c, 0x0ffc0f0c, 0x0ffcce0c, 0x3ffc0c05,
88 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
89 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
90 /* Write Single-Beat (WSS) */
91 0x0ffc0c00, 0x0ffcdc00, 0x0ffc0c05, 0xfffffc00,
92 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
93 /* Write Burst (WBS) */
94 0x0ffc0c00, 0x0fffcc0c, 0x0fff0c00, 0x0fffcc00,
95 0x0fff1c00, 0x0fffcf0c, 0x0fff0f0c, 0x0fffcf0c,
96 0x0fff0c0c, 0x0fffcc0c, 0x0fff0c05, 0xfffffc00,
97 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
98 /* Refresh Timer (RTS) */
99 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
100 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
101 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
102 /* Exception Condition (EXS) */
103 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01
104 };
105
106 upmconfig(UPMA, UPMATable, sizeof(UPMATable) / sizeof(UPMATable[0]));
107
108 /* Set LUPWAIT to be active low and enabled */
109 out_be32(mxmr, MxMR_UWPL | MxMR_GPL_x4DIS);
Ron Madrid5bb907a2009-01-22 15:05:24 -0800110
111 return rc;
112}
113
114#if defined(CONFIG_OF_BOARD_SETUP)
115void ft_board_setup(void *blob, bd_t *bd)
116{
117 ft_cpu_setup(blob, bd);
118#ifdef CONFIG_PCI
119 ft_pci_setup(blob, bd);
120#endif
121}
122#endif
123#else /* CONFIG_NAND_SPL */
124void board_init_f(ulong bootflag)
125{
126 NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500),
127 CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
128 puts("NAND boot... ");
129 init_timebase();
130 initdram(0);
Mingkai Hu6e1385d2009-09-11 10:53:08 +0800131 relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, (gd_t *)gd,
Ron Madrid5bb907a2009-01-22 15:05:24 -0800132 CONFIG_SYS_NAND_U_BOOT_RELOC);
133}
134
135void board_init_r(gd_t *gd, ulong dest_addr)
136{
137 nand_boot();
138}
139
140void putc(char c)
141{
142 if (gd->flags & GD_FLG_SILENT)
143 return;
144
145 if (c == '\n')
146 NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r');
147
148 NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c);
149}
150#endif