blob: d905b2965cc7fa0a23ccd52090664ca43e564563 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
2 * (C) Copyright 2002 Wolfgang Grandegger <wg@denx.de>
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23#include <common.h>
24#include <mpc824x.h>
25#include <pci.h>
26
27#include "pn62.h"
28
Wolfgang Denkd87080b2006-03-31 18:32:53 +020029DECLARE_GLOBAL_DATA_PTR;
wdenkc6097192002-11-03 00:24:07 +000030
31static int get_serial_number (char *string, int size);
32static int get_mac_address (int id, u8 * mac, char *string, int size);
33
34#ifdef CONFIG_SHOW_BOOT_PROGRESS
35void show_boot_progress (int phase)
36{
37 /*
38 * Show phases of the bootm command on the front panel
39 * LEDs and the scratchpad register #3 as well. We use
40 * blinking LEDs for logical "1".
41 */
42 if (phase > 0) {
43 set_led (8, (phase & 0x1) ? LED_SLOW_CLOCK : LED_0);
44 set_led (9, (phase & 0x2) ? LED_SLOW_CLOCK : LED_0);
45 set_led (10, (phase & 0x4) ? LED_SLOW_CLOCK : LED_0);
46 set_led (11, (phase & 0x8) ? LED_SLOW_CLOCK : LED_0);
47 }
48 i2155x_write_scrapad (BOOT_STATUS, phase);
49 if (phase < 0)
50 i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR);
51}
52#endif
53
54void show_startup_phase (int phase)
55{
56 /*
57 * Show the phase of U-Boot startup on the front panel
58 * LEDs and the scratchpad register #3 as well.
59 */
60 if (phase > 0) {
61 set_led (8, (phase & 0x1) ? LED_1 : LED_0);
62 set_led (9, (phase & 0x2) ? LED_1 : LED_0);
63 set_led (10, (phase & 0x4) ? LED_1 : LED_0);
64 set_led (11, (phase & 0x8) ? LED_1 : LED_0);
65 }
66 i2155x_write_scrapad (BOOT_STATUS, phase);
67 if (phase < 0)
68 i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR);
69}
70
71int checkboard (void)
72{
73 show_startup_phase (1);
74 puts ("Board: PN62\n");
75 return 0;
76}
77
Becky Bruce9973e3c2008-06-09 16:03:40 -050078phys_size_t initdram (int board_type)
wdenkc6097192002-11-03 00:24:07 +000079{
wdenkc83bf6a2004-01-06 22:38:14 +000080 long size;
81 long new_bank0_end;
82 long mear1;
83 long emear1;
wdenkc6097192002-11-03 00:24:07 +000084
85 show_startup_phase (2);
86
wdenkc83bf6a2004-01-06 22:38:14 +000087 size = get_ram_size(CFG_SDRAM_BASE, CFG_MAX_RAM_SIZE);
wdenkc6097192002-11-03 00:24:07 +000088
wdenkc83bf6a2004-01-06 22:38:14 +000089 new_bank0_end = size - 1;
90 mear1 = mpc824x_mpc107_getreg (MEAR1);
91 emear1 = mpc824x_mpc107_getreg (EMEAR1);
92 mear1 = (mear1 & 0xFFFFFF00) |
93 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
94 emear1 = (emear1 & 0xFFFFFF00) |
95 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
96 mpc824x_mpc107_setreg (MEAR1, mear1);
97 mpc824x_mpc107_setreg (EMEAR1, emear1);
wdenkc6097192002-11-03 00:24:07 +000098
wdenkc83bf6a2004-01-06 22:38:14 +000099 return (size);
wdenkc6097192002-11-03 00:24:07 +0000100}
101
102/*
103 * Initialize PCI Devices. We rely on auto-configuration.
104 */
105#ifndef CONFIG_PCI_PNP
106#error "CONFIG_PCI_PNP is not defined, please correct!"
107#endif
108
109struct pci_controller hose = {
110};
111
stroesead10dd92003-02-14 11:21:23 +0000112void pci_init_board (void)
wdenkc6097192002-11-03 00:24:07 +0000113{
114 show_startup_phase (4);
115 pci_mpc824x_init (&hose);
116
117 show_startup_phase (5);
118 i2155x_init ();
119 show_startup_phase (6);
120 am79c95x_init ();
121 show_startup_phase (7);
122}
123
124int misc_init_r (void)
125{
wdenkc6097192002-11-03 00:24:07 +0000126 char str[20];
127 u8 mac[6];
128
129 show_startup_phase (8);
130 /*
131 * Get serial number and ethernet addresses if not already defined
132 * and update the board info structure and the environment.
133 */
134 if (getenv ("serial#") == NULL &&
135 get_serial_number (str, strlen (str)) > 0) {
136 setenv ("serial#", str);
137 }
138 show_startup_phase (9);
139
140 if (getenv ("ethaddr") == NULL &&
141 get_mac_address (0, mac, str, sizeof (str)) > 0) {
142 setenv ("ethaddr", str);
143 memcpy (gd->bd->bi_enetaddr, mac, 6);
144 }
145 show_startup_phase (10);
146
wdenke2ffd592004-12-31 09:32:47 +0000147#ifdef CONFIG_HAS_ETH1
wdenkc6097192002-11-03 00:24:07 +0000148 if (getenv ("eth1addr") == NULL &&
149 get_mac_address (1, mac, str, sizeof (str)) > 0) {
150 setenv ("eth1addr", str);
151 memcpy (gd->bd->bi_enet1addr, mac, 6);
152 }
wdenke2ffd592004-12-31 09:32:47 +0000153#endif /* CONFIG_HAS_ETH1 */
wdenkc6097192002-11-03 00:24:07 +0000154 show_startup_phase (11);
155
156 /* Tell everybody that U-Boot is up and runnig */
157 i2155x_write_scrapad (0, 0x12345678);
158 return (0);
159}
160
161static int get_serial_number (char *string, int size)
162{
163 int i;
164 char c;
165
166 if (size < I2155X_VPD_SN_SIZE)
167 size = I2155X_VPD_SN_SIZE;
168 for (i = 0; i < (size - 1); i++) {
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200169 i2155x_read_vpd (I2155X_VPD_SN_START + i, 1, (uchar *)&c);
wdenkc6097192002-11-03 00:24:07 +0000170 if (c == '\0')
171 break;
172 string[i] = c;
173 }
174 string[i] = '\0'; /* make sure it's terminated */
175
176 return i;
177}
178
179static int get_mac_address (int id, u8 * mac, char *string, int size)
180{
181 if (size < 6 * 3)
182 return -1;
183
184 i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac);
185 return sprintf (string, "%02x:%02x:%02x:%02x:%02x:%02x",
186 mac[0], mac[1], mac[2],
187 mac[3], mac[4], mac[5]);
188}