]>
Commit | Line | Data |
---|---|---|
c609719b WD |
1 | /* |
2 | * (C) Copyright 2002 Wolfgang Grandegger <wg@denx.de> | |
3 | * | |
1a459660 | 4 | * SPDX-License-Identifier: GPL-2.0+ |
c609719b WD |
5 | */ |
6 | ||
7 | #include <common.h> | |
8 | #include <mpc824x.h> | |
76756e41 | 9 | #include <net.h> |
c609719b | 10 | #include <pci.h> |
e3090534 | 11 | #include <netdev.h> |
c609719b WD |
12 | |
13 | #include "pn62.h" | |
14 | ||
d87080b7 | 15 | DECLARE_GLOBAL_DATA_PTR; |
c609719b WD |
16 | |
17 | static int get_serial_number (char *string, int size); | |
b6b4625d | 18 | static void get_mac_address(int id, u8 *mac); |
c609719b WD |
19 | |
20 | #ifdef CONFIG_SHOW_BOOT_PROGRESS | |
21 | void 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 | ||
40 | void 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 | ||
57 | int checkboard (void) | |
58 | { | |
59 | show_startup_phase (1); | |
60 | puts ("Board: PN62\n"); | |
61 | return 0; | |
62 | } | |
63 | ||
9973e3c6 | 64 | phys_size_t initdram (int board_type) |
c609719b | 65 | { |
c83bf6a2 WD |
66 | long size; |
67 | long new_bank0_end; | |
68 | long mear1; | |
69 | long emear1; | |
c609719b WD |
70 | |
71 | show_startup_phase (2); | |
72 | ||
6d0f6bcf | 73 | size = get_ram_size(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE); |
c609719b | 74 | |
c83bf6a2 WD |
75 | 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); | |
c609719b | 84 | |
c83bf6a2 | 85 | return (size); |
c609719b WD |
86 | } |
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 | ||
95 | struct pci_controller hose = { | |
96 | }; | |
97 | ||
ad10dd9a | 98 | void pci_init_board (void) |
c609719b WD |
99 | { |
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 | ||
110 | int misc_init_r (void) | |
111 | { | |
c609719b WD |
112 | 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 | ||
b6b4625d MF |
126 | if (!eth_getenv_enetaddr("ethaddr", mac)) { |
127 | get_mac_address(0, mac); | |
128 | eth_setenv_enetaddr("ethaddr", mac); | |
c609719b WD |
129 | } |
130 | show_startup_phase (10); | |
131 | ||
e2ffd59b | 132 | #ifdef CONFIG_HAS_ETH1 |
b6b4625d MF |
133 | if (!eth_getenv_enetaddr("eth1addr", mac)) { |
134 | get_mac_address(1, mac); | |
135 | eth_setenv_enetaddr("eth1addr", mac); | |
c609719b | 136 | } |
e2ffd59b | 137 | #endif /* CONFIG_HAS_ETH1 */ |
c609719b WD |
138 | 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 | ||
145 | static 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++) { | |
77ddac94 | 153 | i2155x_read_vpd (I2155X_VPD_SN_START + i, 1, (uchar *)&c); |
c609719b WD |
154 | 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 | ||
b6b4625d | 163 | static void get_mac_address(int id, u8 *mac) |
c609719b | 164 | { |
c609719b | 165 | i2155x_read_vpd (I2155X_VPD_MAC0_START + 6 * id, 6, mac); |
c609719b | 166 | } |
e3090534 BW |
167 | |
168 | int board_eth_init(bd_t *bis) | |
169 | { | |
170 | return pci_eth_init(bis); | |
171 | } |