blob: 81829dd75f3987143ffc2f6a9397e963243a8576 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
2 * (C) Copyright 2002 Wolfgang Grandegger <wg@denx.de>
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
wdenkc6097192002-11-03 00:24:07 +00005 */
6
7#include <common.h>
8#include <mpc824x.h>
Heiko Schocher76756e42009-03-26 07:33:59 +01009#include <net.h>
wdenkc6097192002-11-03 00:24:07 +000010#include <pci.h>
Ben Warrene3090532008-08-31 10:08:43 -070011#include <netdev.h>
wdenkc6097192002-11-03 00:24:07 +000012
13#include "pn62.h"
14
Wolfgang Denkd87080b2006-03-31 18:32:53 +020015DECLARE_GLOBAL_DATA_PTR;
wdenkc6097192002-11-03 00:24:07 +000016
17static int get_serial_number (char *string, int size);
Mike Frysingerb6b46252009-02-11 18:38:38 -050018static void get_mac_address(int id, u8 *mac);
wdenkc6097192002-11-03 00:24:07 +000019
20#ifdef CONFIG_SHOW_BOOT_PROGRESS
21void show_boot_progress (int phase)
22{
23 /*
24 * Show phases of the bootm command on the front panel
25 * LEDs and the scratchpad register #3 as well. We use
26 * blinking LEDs for logical "1".
27 */
28 if (phase > 0) {
29 set_led (8, (phase & 0x1) ? LED_SLOW_CLOCK : LED_0);
30 set_led (9, (phase & 0x2) ? LED_SLOW_CLOCK : LED_0);
31 set_led (10, (phase & 0x4) ? LED_SLOW_CLOCK : LED_0);
32 set_led (11, (phase & 0x8) ? LED_SLOW_CLOCK : LED_0);
33 }
34 i2155x_write_scrapad (BOOT_STATUS, phase);
35 if (phase < 0)
36 i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR);
37}
38#endif
39
40void show_startup_phase (int phase)
41{
42 /*
43 * Show the phase of U-Boot startup on the front panel
44 * LEDs and the scratchpad register #3 as well.
45 */
46 if (phase > 0) {
47 set_led (8, (phase & 0x1) ? LED_1 : LED_0);
48 set_led (9, (phase & 0x2) ? LED_1 : LED_0);
49 set_led (10, (phase & 0x4) ? LED_1 : LED_0);
50 set_led (11, (phase & 0x8) ? LED_1 : LED_0);
51 }
52 i2155x_write_scrapad (BOOT_STATUS, phase);
53 if (phase < 0)
54 i2155x_write_scrapad (BOOT_DONE, BOOT_DONE_ERROR);
55}
56
57int checkboard (void)
58{
59 show_startup_phase (1);
60 puts ("Board: PN62\n");
61 return 0;
62}
63
Becky Bruce9973e3c2008-06-09 16:03:40 -050064phys_size_t initdram (int board_type)
wdenkc6097192002-11-03 00:24:07 +000065{
wdenkc83bf6a2004-01-06 22:38:14 +000066 long size;
67 long new_bank0_end;
68 long mear1;
69 long emear1;
wdenkc6097192002-11-03 00:24:07 +000070
71 show_startup_phase (2);
72
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020073 size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
wdenkc6097192002-11-03 00:24:07 +000074
wdenkc83bf6a2004-01-06 22:38:14 +000075 new_bank0_end = size - 1;
76 mear1 = mpc824x_mpc107_getreg (MEAR1);
77 emear1 = mpc824x_mpc107_getreg (EMEAR1);
78 mear1 = (mear1 & 0xFFFFFF00) |
79 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
80 emear1 = (emear1 & 0xFFFFFF00) |
81 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
82 mpc824x_mpc107_setreg (MEAR1, mear1);
83 mpc824x_mpc107_setreg (EMEAR1, emear1);
wdenkc6097192002-11-03 00:24:07 +000084
wdenkc83bf6a2004-01-06 22:38:14 +000085 return (size);
wdenkc6097192002-11-03 00:24:07 +000086}
87
88/*
89 * Initialize PCI Devices. We rely on auto-configuration.
90 */
91#ifndef CONFIG_PCI_PNP
92#error "CONFIG_PCI_PNP is not defined, please correct!"
93#endif
94
95struct pci_controller hose = {
96};
97
stroesead10dd92003-02-14 11:21:23 +000098void pci_init_board (void)
wdenkc6097192002-11-03 00:24:07 +000099{
100 show_startup_phase (4);
101 pci_mpc824x_init (&hose);
102
103 show_startup_phase (5);
104 i2155x_init ();
105 show_startup_phase (6);
106 am79c95x_init ();
107 show_startup_phase (7);
108}
109
110int misc_init_r (void)
111{
wdenkc6097192002-11-03 00:24:07 +0000112 char str[20];
113 u8 mac[6];
114
115 show_startup_phase (8);
116 /*
117 * Get serial number and ethernet addresses if not already defined
118 * and update the board info structure and the environment.
119 */
120 if (getenv ("serial#") == NULL &&
121 get_serial_number (str, strlen (str)) > 0) {
122 setenv ("serial#", str);
123 }
124 show_startup_phase (9);
125
Mike Frysingerb6b46252009-02-11 18:38:38 -0500126 if (!eth_getenv_enetaddr("ethaddr", mac)) {
127 get_mac_address(0, mac);
128 eth_setenv_enetaddr("ethaddr", mac);
wdenkc6097192002-11-03 00:24:07 +0000129 }
130 show_startup_phase (10);
131
wdenke2ffd592004-12-31 09:32:47 +0000132#ifdef CONFIG_HAS_ETH1
Mike Frysingerb6b46252009-02-11 18:38:38 -0500133 if (!eth_getenv_enetaddr("eth1addr", mac)) {
134 get_mac_address(1, mac);
135 eth_setenv_enetaddr("eth1addr", mac);
wdenkc6097192002-11-03 00:24:07 +0000136 }
wdenke2ffd592004-12-31 09:32:47 +0000137#endif /* CONFIG_HAS_ETH1 */
wdenkc6097192002-11-03 00:24:07 +0000138 show_startup_phase (11);
139
140 /* Tell everybody that U-Boot is up and runnig */
141 i2155x_write_scrapad (0, 0x12345678);
142 return (0);
143}
144
145static int get_serial_number (char *string, int size)
146{
147 int i;
148 char c;
149
150 if (size < I2155X_VPD_SN_SIZE)
151 size = I2155X_VPD_SN_SIZE;
152 for (i = 0; i < (size - 1); i++) {
Wolfgang Denk77ddac92005-10-13 16:45:02 +0200153 i2155x_read_vpd (I2155X_VPD_SN_START + i, 1, (uchar *)&c);
wdenkc6097192002-11-03 00:24:07 +0000154 if (c == '\0')
155 break;
156 string[i] = c;
157 }
158 string[i] = '\0'; /* make sure it's terminated */
159
160 return i;
161}
162
Mike Frysingerb6b46252009-02-11 18:38:38 -0500163static void get_mac_address(int id, u8 *mac)
wdenkc6097192002-11-03 00:24:07 +0000164{
wdenkc6097192002-11-03 00:24:07 +0000165 i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac);
wdenkc6097192002-11-03 00:24:07 +0000166}
Ben Warrene3090532008-08-31 10:08:43 -0700167
168int board_eth_init(bd_t *bis)
169{
170 return pci_eth_init(bis);
171}