1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include <common.h>
22#include <asm/ppc4xx.h>
23#include <asm/processor.h>
24#include <asm/io.h>
25#include <asm/u-boot.h>
26#include "../common/nm.h"
27
28DECLARE_GLOBAL_DATA_PTR;
29
30#define HCU_MACH_VERSIONS_REGISTER (0x7C000000 + 0xF00000)
31#define HCU_SLOT_ADDRESS (0x7C000000 + 0x400000)
32#define HCU_DIGITAL_IO_REGISTER (0x7C000000 + 0x500000)
33#define HCU_SW_INSTALL_REQUESTED 0x10
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49#define CPC0_CR0_VALUE 0x0030103c
50#define CPC0_CR1_VALUE 0x00004051
51
52int board_early_init_f (void)
53{
54
55
56
57
58
59
60
61 mtdcr(UIC0SR, 0xFFFFFFFF);
62 mtdcr(UIC0ER, 0x00000000);
63 mtdcr(UIC0CR, 0x00000000);
64 mtdcr(UIC0PR, 0xFFFFE000);
65 mtdcr(UIC0TR, 0x00000000);
66 mtdcr(UIC0SR, 0xFFFFFFFF);
67
68 mtdcr(CPC0_CR1, CPC0_CR1_VALUE);
69 mtdcr(CPC0_ECR, 0x60606000);
70 mtdcr(CPC0_EIRR, 0x7C000000);
71
72 return 0;
73}
74
75#ifdef CONFIG_BOARD_PRE_INIT
76int board_pre_init (void)
77{
78 return board_early_init_f ();
79}
80#endif
81
82int sys_install_requested(void)
83{
84 u16 ioValue = in_be16((u16 *)HCU_DIGITAL_IO_REGISTER);
85 return (ioValue & HCU_SW_INSTALL_REQUESTED) != 0;
86}
87
88int checkboard (void)
89{
90 u16 boardVersReg = in_be16((u16 *)HCU_MACH_VERSIONS_REGISTER);
91 u16 generation = boardVersReg & 0xf0;
92 u16 index = boardVersReg & 0x0f;
93
94
95 mtdcr(CPC0_CR0, CPC0_CR0_VALUE);
96
97
98
99
100
101 writeb (readb (0xef600404) | 0x03, 0xef600404);
102 nm_show_print(generation, index, 0);
103
104 return 0;
105}
106
107u32 hcu_led_get(void)
108{
109 return (~(in_be32((u32 *)GPIO0_OR)) >> 23) & 0xff;
110}
111
112
113
114
115void hcu_led_set(u32 value)
116{
117 u32 tmp = ~value;
118
119 tmp = (tmp << 23) | 0x7FFFFF;
120 out_be32((u32 *)GPIO0_OR, tmp);
121}
122
123
124
125
126u32 hcu_get_slot(void)
127{
128 u16 slot = in_be16((u16 *)HCU_SLOT_ADDRESS);
129 return slot & 0x7f;
130}
131
132
133
134
135u32 get_serial_number(void)
136{
137 u32 serial = in_be32((u32 *)CONFIG_SYS_FLASH_BASE);
138
139 if (serial == 0xffffffff)
140 return 0;
141
142 return serial;
143}
144
145
146
147
148
149
150int misc_init_r(void)
151{
152 common_misc_init_r();
153 set_params_for_sw_install( sys_install_requested(), "hcu4" );
154 return 0;
155}
156
157phys_size_t initdram(int board_type)
158{
159 long dram_size = 0;
160 u16 boardVersReg = in_be16((u16 *)HCU_MACH_VERSIONS_REGISTER);
161 u16 generation = boardVersReg & 0xf0;
162 u16 index = boardVersReg & 0x0f;
163
164 if (generation == HW_GENERATION_HCU3 && index < 0xf)
165 dram_size = 32 << 20;
166 else
167 dram_size = 64 << 20;
168 init_ppc405_sdram(dram_size);
169
170#ifdef DEBUG
171 show_sdram_registers();
172#endif
173
174 return dram_size;
175}
176
177#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
178void ft_board_setup(void *blob, bd_t *bd)
179{
180 ft_cpu_setup(blob, bd);
181
182}
183#endif
184
185
186
187
188
189ulong board_flash_get_legacy (ulong base, int banknum, flash_info_t * info)
190{
191 if (banknum == 0) {
192 info->portwidth = 1;
193 info->chipwidth = 1;
194 info->interface = FLASH_CFI_X8;
195 return 1;
196 } else
197 return 0;
198}
199