blob: 7555ffbdd6d62c9e82c6ce04f64d06f4b7b6dfb3 [file] [log] [blame]
Dave Liu8bd522c2008-01-11 18:48:24 +08001/*
2 * Copyright (C) 2007 Freescale Semiconductor, Inc.
3 *
4 * Author: Scott Wood <scottwood@freescale.com>
5 * Dave Liu <daveliu@freescale.com>
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25
26#include <common.h>
27#include <i2c.h>
Dave Liu8bd522c2008-01-11 18:48:24 +080028#include <libfdt.h>
Anton Vorontsov25f5f0d2008-07-08 21:00:04 +040029#include <fdt_support.h>
Dave Liu8bd522c2008-01-11 18:48:24 +080030#include <pci.h>
31#include <mpc83xx.h>
32
33DECLARE_GLOBAL_DATA_PTR;
34
35int board_early_init_f(void)
36{
37 volatile immap_t *im = (immap_t *)CFG_IMMR;
38
39 if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
40 gd->flags |= GD_FLG_SILENT;
41
42 return 0;
43}
44
45static u8 read_board_info(void)
46{
47 u8 val8;
48 i2c_set_bus_num(0);
49
50 if (i2c_read(CFG_I2C_PCF8574A_ADDR, 0, 0, &val8, 1) == 0)
51 return val8;
52 else
53 return 0;
54}
55
56int checkboard(void)
57{
58 static const char * const rev_str[] = {
59 "0.0",
60 "0.1",
61 "1.0",
62 "1.1",
63 "<unknown>",
64 };
65 u8 info;
66 int i;
67
68 info = read_board_info();
69 i = (!info) ? 4: info & 0x03;
70
71 printf("Board: Freescale MPC8315ERDB Rev %s\n", rev_str[i]);
72
73 return 0;
74}
75
76static struct pci_region pci_regions[] = {
77 {
78 bus_start: CFG_PCI_MEM_BASE,
79 phys_start: CFG_PCI_MEM_PHYS,
80 size: CFG_PCI_MEM_SIZE,
81 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
82 },
83 {
84 bus_start: CFG_PCI_MMIO_BASE,
85 phys_start: CFG_PCI_MMIO_PHYS,
86 size: CFG_PCI_MMIO_SIZE,
87 flags: PCI_REGION_MEM
88 },
89 {
90 bus_start: CFG_PCI_IO_BASE,
91 phys_start: CFG_PCI_IO_PHYS,
92 size: CFG_PCI_IO_SIZE,
93 flags: PCI_REGION_IO
94 }
95};
96
97void pci_init_board(void)
98{
99 volatile immap_t *immr = (volatile immap_t *)CFG_IMMR;
100 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
101 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
102 struct pci_region *reg[] = { pci_regions };
103 int warmboot;
104
105 /* Enable all 3 PCI_CLK_OUTPUTs. */
106 clk->occr |= 0xe0000000;
107
108 /*
109 * Configure PCI Local Access Windows
110 */
111 pci_law[0].bar = CFG_PCI_MEM_PHYS & LAWBAR_BAR;
112 pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
113
114 pci_law[1].bar = CFG_PCI_IO_PHYS & LAWBAR_BAR;
115 pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
116
117 warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM;
118 warmboot |= immr->pmc.pmccr1 & PMCCR1_POWER_OFF;
119
120 mpc83xx_pci_init(1, reg, warmboot);
121}
122
123#if defined(CONFIG_OF_BOARD_SETUP)
Anton Vorontsov25f5f0d2008-07-08 21:00:04 +0400124void fdt_tsec1_fixup(void *fdt, bd_t *bd)
125{
126 char *mpc8315erdb = getenv("mpc8315erdb");
127 const char disabled[] = "disabled";
128 const char *path;
129 int ret;
130
131 if (!mpc8315erdb) {
132 if (!strcmp(mpc8315erdb, "tsec1")) {
133 return;
134 } else if (strcmp(mpc8315erdb, "ulpi")) {
135 printf("WARNING: wrong `mpc8315erdb' environment "
136 "variable specified: `%s'. Should be `ulpi' "
137 "or `tsec1'.\n", mpc8315erdb);
138 return;
139 }
140 }
141
142 ret = fdt_path_offset(fdt, "/aliases");
143 if (ret < 0) {
144 printf("WARNING: can't find /aliases node\n");
145 return;
146 }
147
148 path = fdt_getprop(fdt, ret, "ethernet0", NULL);
149 if (!path) {
150 printf("WARNING: can't find ethernet0 alias\n");
151 return;
152 }
153
154 do_fixup_by_path(fdt, path, "status", disabled, sizeof(disabled), 1);
155}
156
Dave Liu8bd522c2008-01-11 18:48:24 +0800157void ft_board_setup(void *blob, bd_t *bd)
158{
159 ft_cpu_setup(blob, bd);
160#ifdef CONFIG_PCI
161 ft_pci_setup(blob, bd);
162#endif
Anton Vorontsov25f5f0d2008-07-08 21:00:04 +0400163 fdt_fixup_dr_usb(blob, bd);
164 fdt_tsec1_fixup(blob, bd);
Dave Liu8bd522c2008-01-11 18:48:24 +0800165}
166#endif