blob: ea4b04fd3de73724d41c9a148c438d775cef1041 [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>
Ben Warren10efa022008-08-31 20:37:00 -070032#include <netdev.h>
Dave Liu8bd522c2008-01-11 18:48:24 +080033
34DECLARE_GLOBAL_DATA_PTR;
35
36int board_early_init_f(void)
37{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020038 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
Dave Liu8bd522c2008-01-11 18:48:24 +080039
40 if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
41 gd->flags |= GD_FLG_SILENT;
42
43 return 0;
44}
45
46static u8 read_board_info(void)
47{
48 u8 val8;
49 i2c_set_bus_num(0);
50
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020051 if (i2c_read(CONFIG_SYS_I2C_PCF8574A_ADDR, 0, 0, &val8, 1) == 0)
Dave Liu8bd522c2008-01-11 18:48:24 +080052 return val8;
53 else
54 return 0;
55}
56
57int checkboard(void)
58{
59 static const char * const rev_str[] = {
60 "0.0",
61 "0.1",
62 "1.0",
63 "1.1",
64 "<unknown>",
65 };
66 u8 info;
67 int i;
68
69 info = read_board_info();
70 i = (!info) ? 4: info & 0x03;
71
72 printf("Board: Freescale MPC8315ERDB Rev %s\n", rev_str[i]);
73
74 return 0;
75}
76
77static struct pci_region pci_regions[] = {
78 {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020079 bus_start: CONFIG_SYS_PCI_MEM_BASE,
80 phys_start: CONFIG_SYS_PCI_MEM_PHYS,
81 size: CONFIG_SYS_PCI_MEM_SIZE,
Dave Liu8bd522c2008-01-11 18:48:24 +080082 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
83 },
84 {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020085 bus_start: CONFIG_SYS_PCI_MMIO_BASE,
86 phys_start: CONFIG_SYS_PCI_MMIO_PHYS,
87 size: CONFIG_SYS_PCI_MMIO_SIZE,
Dave Liu8bd522c2008-01-11 18:48:24 +080088 flags: PCI_REGION_MEM
89 },
90 {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020091 bus_start: CONFIG_SYS_PCI_IO_BASE,
92 phys_start: CONFIG_SYS_PCI_IO_PHYS,
93 size: CONFIG_SYS_PCI_IO_SIZE,
Dave Liu8bd522c2008-01-11 18:48:24 +080094 flags: PCI_REGION_IO
95 }
96};
97
98void pci_init_board(void)
99{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200100 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
Dave Liu8bd522c2008-01-11 18:48:24 +0800101 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
102 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
103 struct pci_region *reg[] = { pci_regions };
104 int warmboot;
105
106 /* Enable all 3 PCI_CLK_OUTPUTs. */
107 clk->occr |= 0xe0000000;
108
109 /*
110 * Configure PCI Local Access Windows
111 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200112 pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
Dave Liu8bd522c2008-01-11 18:48:24 +0800113 pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
114
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200115 pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
Dave Liu8bd522c2008-01-11 18:48:24 +0800116 pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
117
118 warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM;
119 warmboot |= immr->pmc.pmccr1 & PMCCR1_POWER_OFF;
120
121 mpc83xx_pci_init(1, reg, warmboot);
122}
123
124#if defined(CONFIG_OF_BOARD_SETUP)
Anton Vorontsov25f5f0d2008-07-08 21:00:04 +0400125void fdt_tsec1_fixup(void *fdt, bd_t *bd)
126{
127 char *mpc8315erdb = getenv("mpc8315erdb");
128 const char disabled[] = "disabled";
129 const char *path;
130 int ret;
131
Anton Vorontsov021f6df2008-07-10 17:20:51 +0400132 if (!mpc8315erdb)
133 return;
134
135 if (!strcmp(mpc8315erdb, "tsec1")) {
136 return;
137 } else if (strcmp(mpc8315erdb, "ulpi")) {
138 printf("WARNING: wrong `mpc8315erdb' environment "
139 "variable specified: `%s'. Should be `ulpi' "
140 "or `tsec1'.\n", mpc8315erdb);
141 return;
Anton Vorontsov25f5f0d2008-07-08 21:00:04 +0400142 }
143
144 ret = fdt_path_offset(fdt, "/aliases");
145 if (ret < 0) {
146 printf("WARNING: can't find /aliases node\n");
147 return;
148 }
149
150 path = fdt_getprop(fdt, ret, "ethernet0", NULL);
151 if (!path) {
152 printf("WARNING: can't find ethernet0 alias\n");
153 return;
154 }
155
156 do_fixup_by_path(fdt, path, "status", disabled, sizeof(disabled), 1);
157}
158
Dave Liu8bd522c2008-01-11 18:48:24 +0800159void ft_board_setup(void *blob, bd_t *bd)
160{
161 ft_cpu_setup(blob, bd);
162#ifdef CONFIG_PCI
163 ft_pci_setup(blob, bd);
164#endif
Anton Vorontsov25f5f0d2008-07-08 21:00:04 +0400165 fdt_fixup_dr_usb(blob, bd);
166 fdt_tsec1_fixup(blob, bd);
Dave Liu8bd522c2008-01-11 18:48:24 +0800167}
168#endif
Ben Warren10efa022008-08-31 20:37:00 -0700169
170int board_eth_init(bd_t *bis)
171{
172 cpu_eth_init(bis); /* Initialize TSECs first */
173 return pci_eth_init(bis);
174}