]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/motionpro/motionpro.c
2 * (C) Copyright 2003-2007
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * modified for Promess PRO - by Andy Joseph, andy@promessdev.com
6 * modified for Promess PRO-Motion - by Robert McCullough, rob@promessdev.com
7 * modified by Chris M. Tumas 6/20/06 Change CAS latency to 2 from 3
8 * Also changed the refresh for 100MHz operation
10 * SPDX-License-Identifier: GPL-2.0+
18 #if defined(CONFIG_LED_STATUS)
19 #include <status_led.h>
20 #endif /* CONFIG_LED_STATUS */
22 DECLARE_GLOBAL_DATA_PTR
;
24 /* Kollmorgen DPR initialization data */
30 {0x500003F2, 2, "\x86\x00"}, /* HW parameter */
31 {0x500003F0, 2, "\x00\x00"},
32 {0x500003EC, 4, "\x00\x80\xc1\x52"}, /* Magic word */
36 * Initialize Kollmorgen DPR
38 static void kollmorgen_init(void)
43 for (i
= 0; i
< sizeof(init_seq
) / sizeof(struct init_elem
); ++i
) {
44 p
= (vu_char
*)init_seq
[i
].addr
;
45 for (j
= 0; j
< init_seq
[i
].len
; ++j
)
46 *(p
+ j
) = *(init_seq
[i
].data
+ j
);
49 printf("DPR: Kollmorgen DPR initialized\n");
54 * Early board initalization.
56 int board_early_init_r(void)
58 /* Now, when we are in RAM, disable Boot Chipselect and enable CS0 */
59 *(vu_long
*)MPC5XXX_ADDECR
&= ~(1 << 25);
60 *(vu_long
*)MPC5XXX_ADDECR
|= (1 << 16);
62 /* Initialize Kollmorgen DPR */
70 * Additional PHY intialization. After being reset in mpc5xxx_fec_init_phy(),
71 * PHY goes into FX mode. To take it out of the FX mode and switch into
72 * desired TX operation, one needs to clear the FX_SEL bit of Mode Control
77 unsigned short mode_control
;
79 miiphy_read("FEC", CONFIG_PHY_ADDR
, 0x15, &mode_control
);
80 miiphy_write("FEC", CONFIG_PHY_ADDR
, 0x15,
81 mode_control
& 0xfffe);
85 #ifndef CONFIG_SYS_RAMBOOT
87 * Helper function to initialize SDRAM controller.
89 static void sdram_start(int hi_addr
)
91 long hi_addr_bit
= hi_addr
? 0x01000000 : 0;
93 /* unlock mode register */
94 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000000 |
97 /* precharge all banks */
98 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000002 |
102 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000004 |
105 /* auto refresh, second time */
106 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| 0x80000004 |
109 /* set mode register */
110 *(vu_long
*)MPC5XXX_SDRAM_MODE
= SDRAM_MODE
;
112 /* normal operation */
113 *(vu_long
*)MPC5XXX_SDRAM_CTRL
= SDRAM_CONTROL
| hi_addr_bit
;
115 #endif /* !CONFIG_SYS_RAMBOOT */
119 * Initalize SDRAM - configure SDRAM controller, detect memory size.
124 #ifndef CONFIG_SYS_RAMBOOT
127 /* According to AN3221 (MPC5200B SDRAM Initialization and
128 * Configuration), the SDelay register must be written a value of
129 * 0x00000004 as the first step of the SDRAM contorller configuration.
131 *(vu_long
*)MPC5XXX_SDRAM_SDELAY
= 0x04;
133 /* configure SDRAM start/end for detection */
134 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0x0000001e; /* 2G at 0x0 */
135 *(vu_long
*)MPC5XXX_SDRAM_CS1CFG
= 0x80000000; /* disabled */
137 /* setup config registers */
138 *(vu_long
*)MPC5XXX_SDRAM_CONFIG1
= SDRAM_CONFIG1
;
139 *(vu_long
*)MPC5XXX_SDRAM_CONFIG2
= SDRAM_CONFIG2
;
142 test1
= get_ram_size((long *)CONFIG_SYS_SDRAM_BASE
, 0x80000000);
144 test2
= get_ram_size((long *)CONFIG_SYS_SDRAM_BASE
, 0x80000000);
152 /* memory smaller than 1MB is impossible */
153 if (dramsize
< (1 << 20))
156 /* set SDRAM CS0 size according to the amount of RAM found */
158 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0x13 +
159 __builtin_ffs(dramsize
>> 20) - 1;
161 *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
= 0; /* disabled */
164 /* let SDRAM CS1 start right after CS0 and disable it */
165 *(vu_long
*) MPC5XXX_SDRAM_CS1CFG
= dramsize
;
167 #else /* !CONFIG_SYS_RAMBOOT */
168 /* retrieve size of memory connected to SDRAM CS0 */
169 dramsize
= *(vu_long
*)MPC5XXX_SDRAM_CS0CFG
& 0xFF;
170 if (dramsize
>= 0x13)
171 dramsize
= (1 << (dramsize
- 0x13)) << 20;
174 #endif /* CONFIG_SYS_RAMBOOT */
176 /* return total ram size */
177 gd
->ram_size
= dramsize
;
185 uchar rev
= *(vu_char
*)CPLD_REV_REGISTER
;
186 printf("Board: Promess Motion-PRO board (CPLD rev. 0x%02x)\n", rev
);
191 #ifdef CONFIG_OF_BOARD_SETUP
192 int ft_board_setup(void *blob
, bd_t
*bd
)
194 ft_cpu_setup(blob
, bd
);
198 #endif /* CONFIG_OF_BOARD_SETUP */
201 #if defined(CONFIG_LED_STATUS)
202 vu_long
*regcode_to_regaddr(led_id_t regcode
)
204 /* GPT Enable and Mode Select Register address */
205 vu_long
*reg_translate
[] = {
206 (vu_long
*)MPC5XXX_GPT6_ENABLE
,
207 (vu_long
*)MPC5XXX_GPT7_ENABLE
,
210 if (ARRAY_SIZE(reg_translate
) <= regcode
)
212 return reg_translate
[regcode
];
215 void __led_init(led_id_t regcode
, int state
)
217 vu_long
*regaddr
= regcode_to_regaddr(regcode
);
219 *regaddr
|= ENABLE_GPIO_OUT
;
221 if (state
== CONFIG_LED_STATUS_ON
)
222 *((vu_long
*) regaddr
) |= LED_ON
;
224 *((vu_long
*) regaddr
) &= ~LED_ON
;
227 void __led_set(led_id_t regcode
, int state
)
229 vu_long
*regaddr
= regcode_to_regaddr(regcode
);
231 if (state
== CONFIG_LED_STATUS_ON
)
237 void __led_toggle(led_id_t regcode
)
239 vu_long
*regaddr
= regcode_to_regaddr(regcode
);
243 #endif /* CONFIG_LED_STATUS */