blob: 5c543573a81f046f88c1c1d2f5c9715151fad2ab [file] [log] [blame]
Ilya Yanok89847ef2010-07-07 20:16:13 +04001/*
2 * Copyright (C) 2010 Freescale Semiconductor, Inc.
3 * Copyright (C) 2010 Ilya Yanok, Emcraft Systems, yanok@emcraft.com
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <hwconfig.h>
26#include <i2c.h>
27#include <libfdt.h>
28#include <fdt_support.h>
29#include <pci.h>
30#include <mpc83xx.h>
31#include <vsc7385.h>
32#include <netdev.h>
33#include <asm/io.h>
34#include <asm/fsl_serdes.h>
35#include <asm/fsl_mpc83xx_serdes.h>
36
37DECLARE_GLOBAL_DATA_PTR;
38
Ilya Yanok89847ef2010-07-07 20:16:13 +040039static u8 read_board_info(void)
40{
41 u8 val8;
42 i2c_set_bus_num(0);
43
44 if (i2c_read(CONFIG_SYS_I2C_PCF8574A_ADDR, 0, 0, &val8, 1) == 0)
45 return val8;
46 else
47 return 0;
48}
49
50int checkboard(void)
51{
52 static const char * const rev_str[] = {
53 "1.0",
54 "<reserved>",
55 "<reserved>",
56 "<reserved>",
57 "<unknown>",
58 };
59 u8 info;
60 int i;
61
62 info = read_board_info();
63 i = (!info) ? 4 : info & 0x03;
64
65 printf("Board: Freescale MPC8308RDB Rev %s\n", rev_str[i]);
66
67 return 0;
68}
69
70static struct pci_region pcie_regions_0[] = {
71 {
72 .bus_start = CONFIG_SYS_PCIE1_MEM_BASE,
73 .phys_start = CONFIG_SYS_PCIE1_MEM_PHYS,
74 .size = CONFIG_SYS_PCIE1_MEM_SIZE,
75 .flags = PCI_REGION_MEM,
76 },
77 {
78 .bus_start = CONFIG_SYS_PCIE1_IO_BASE,
79 .phys_start = CONFIG_SYS_PCIE1_IO_PHYS,
80 .size = CONFIG_SYS_PCIE1_IO_SIZE,
81 .flags = PCI_REGION_IO,
82 },
83};
84
85void pci_init_board(void)
86{
87 immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
88 sysconf83xx_t *sysconf = &immr->sysconf;
Ilya Yanok89847ef2010-07-07 20:16:13 +040089 law83xx_t *pcie_law = sysconf->pcielaw;
90 struct pci_region *pcie_reg[] = { pcie_regions_0 };
91
92 fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_PEX,
93 FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
94
Ilya Yanok89847ef2010-07-07 20:16:13 +040095 /* Deassert the resets in the control register */
96 out_be32(&sysconf->pecr1, 0xE0008000);
97 udelay(2000);
98
99 /* Configure PCI Express Local Access Windows */
100 out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR);
101 out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB);
102
Peter Tysere2283322010-09-14 19:13:50 -0500103 mpc83xx_pcie_init(1, pcie_reg);
Ilya Yanok89847ef2010-07-07 20:16:13 +0400104}
105/*
106 * Miscellaneous late-boot configurations
107 *
108 * If a VSC7385 microcode image is present, then upload it.
109*/
110int misc_init_r(void)
111{
112#ifdef CONFIG_VSC7385_IMAGE
113 if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE,
114 CONFIG_VSC7385_IMAGE_SIZE)) {
115 puts("Failure uploading VSC7385 microcode.\n");
116 return 1;
117 }
118#endif
119
120 return 0;
121}
122#if defined(CONFIG_OF_BOARD_SETUP)
123void ft_board_setup(void *blob, bd_t *bd)
124{
125 ft_cpu_setup(blob, bd);
126 fdt_fixup_dr_usb(blob, bd);
127}
128#endif
129
130int board_eth_init(bd_t *bis)
131{
132 int rv, num_if = 0;
133
134 /* Initialize TSECs first */
Ilya Yanokdbdc1052010-09-17 23:41:49 +0200135 rv = cpu_eth_init(bis);
136 if (rv >= 0)
Ilya Yanok89847ef2010-07-07 20:16:13 +0400137 num_if += rv;
138 else
139 printf("ERROR: failed to initialize TSECs.\n");
140
Ilya Yanokdbdc1052010-09-17 23:41:49 +0200141 rv = pci_eth_init(bis);
142 if (rv >= 0)
Ilya Yanok89847ef2010-07-07 20:16:13 +0400143 num_if += rv;
144 else
145 printf("ERROR: failed to initialize PCI Ethernet.\n");
146
147 return num_if;
148}