1
2
3
4
5
6
7
8
9
10#include <common.h>
11#include <asm/processor.h>
12#include <command.h>
13
14#include "p3p440.h"
15
16DECLARE_GLOBAL_DATA_PTR;
17
18void set_led(int color)
19{
20 switch (color) {
21 case LED_OFF:
22 out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_LED_GREEN & ~CONFIG_SYS_LED_RED);
23 break;
24
25 case LED_GREEN:
26 out32(GPIO0_OR, (in32(GPIO0_OR) | CONFIG_SYS_LED_GREEN) & ~CONFIG_SYS_LED_RED);
27 break;
28
29 case LED_RED:
30 out32(GPIO0_OR, (in32(GPIO0_OR) | CONFIG_SYS_LED_RED) & ~CONFIG_SYS_LED_GREEN);
31 break;
32
33 case LED_ORANGE:
34 out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_LED_GREEN | CONFIG_SYS_LED_RED);
35 break;
36 }
37}
38
39static int is_monarch(void)
40{
41 out32(GPIO0_OR, in32(GPIO0_OR) & ~CONFIG_SYS_GPIO_RDY);
42 udelay(1000);
43
44 if (in32(GPIO0_IR) & CONFIG_SYS_MONARCH_IO)
45 return 0;
46 else
47 return 1;
48}
49
50static void wait_for_pci_ready(void)
51{
52
53
54
55 out32(GPIO0_TCR, in32(GPIO0_TCR) & ~CONFIG_SYS_EREADY_IO);
56 udelay(1000);
57
58 for (;;) {
59 if (in32(GPIO0_IR) & CONFIG_SYS_EREADY_IO)
60 return;
61 }
62
63}
64
65int board_early_init_f(void)
66{
67 uint reg;
68
69
70
71
72 mtdcr(EBC0_CFGADDR, EBC0_CFG);
73 reg = mfdcr(EBC0_CFGDATA);
74 mtdcr(EBC0_CFGDATA, reg | 0x04000000);
75
76
77
78
79 mtdcr(CPC0_GPIO, 0x03F01F80);
80
81 out32(GPIO0_ODR, 0x00000000);
82 out32(GPIO0_TCR, CONFIG_SYS_GPIO_RDY | CONFIG_SYS_EREADY_IO | CONFIG_SYS_LED_RED | CONFIG_SYS_LED_GREEN);
83 out32(GPIO0_OR, CONFIG_SYS_GPIO_RDY);
84
85
86
87
88 mtdcr(UIC0SR, 0xffffffff);
89 mtdcr(UIC0ER, 0x00000000);
90 mtdcr(UIC0CR, 0x00000001);
91 mtdcr(UIC0PR, 0xfffffe13);
92 mtdcr(UIC0TR, 0x01c00008);
93 mtdcr(UIC0VR, 0x00000001);
94 mtdcr(UIC0SR, 0xffffffff);
95
96 mtdcr(UIC1SR, 0xffffffff);
97 mtdcr(UIC1ER, 0x00000000);
98 mtdcr(UIC1CR, 0x00000000);
99 mtdcr(UIC1PR, 0xffffe0ff);
100 mtdcr(UIC1TR, 0x00ffc000);
101 mtdcr(UIC1VR, 0x00000001);
102 mtdcr(UIC1SR, 0xffffffff);
103
104 return 0;
105}
106
107int checkboard(void)
108{
109 char buf[64];
110 int i = getenv_f("serial#", buf, sizeof(buf));
111
112 printf("Board: P3P440");
113 if (i > 0) {
114 puts(", serial# ");
115 puts(buf);
116 }
117
118 if (is_monarch()) {
119 puts(", Monarch");
120 } else {
121 puts(", None-Monarch");
122 }
123
124 putc('\n');
125
126 return (0);
127}
128
129int misc_init_r (void)
130{
131
132
133
134 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
135 gd->bd->bi_flashoffset = 0;
136
137
138
139
140 if (gd->bd->bi_flashsize != CONFIG_SYS_MAX_FLASH_BANKS * (0 - CONFIG_SYS_FLASH0)) {
141 mtebc(PB1CR, 0);
142 mtebc(PB1AP, 0);
143 mtebc(PB2CR, 0);
144 mtebc(PB2AP, 0);
145 mtebc(PB3CR, 0);
146 mtebc(PB3AP, 0);
147 }
148
149 return 0;
150}
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167#if defined(CONFIG_PCI)
168int is_pci_host(struct pci_controller *hose)
169{
170 if (is_monarch()) {
171 wait_for_pci_ready();
172 return 1;
173 } else {
174 return 0;
175 }
176}
177#endif
178