Commit 32dbaafa5a1fda97dbf99e6627309e7570dc14ca

Authored by Alison Wang
Committed by Jason
1 parent 849fc42471
Exists in master and in 55 other branches 8qm-imx_v2020.04_5.4.70_2.3.0, emb_lf_v2022.04, emb_lf_v2023.04, imx_v2015.04_4.1.15_1.0.0_ga, pitx_8mp_lf_v2020.04, smarc-8m-android-10.0.0_2.6.0, smarc-8m-android-11.0.0_2.0.0, smarc-8mp-android-11.0.0_2.0.0, smarc-emmc-imx_v2014.04_3.10.53_1.1.0_ga, smarc-emmc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx-l5.0.0_1.0.0-ga, smarc-imx6_v2018.03_4.14.98_2.0.0_ga, smarc-imx7_v2017.03_4.9.11_1.0.0_ga, smarc-imx7_v2018.03_4.14.98_2.0.0_ga, smarc-imx_v2014.04_3.14.28_1.0.0_ga, smarc-imx_v2015.04_4.1.15_1.0.0_ga, smarc-imx_v2017.03_4.9.11_1.0.0_ga, smarc-imx_v2017.03_4.9.88_2.0.0_ga, smarc-imx_v2017.03_o8.1.0_1.3.0_8m, smarc-imx_v2018.03_4.14.78_1.0.0_ga, smarc-m6.0.1_2.1.0-ga, smarc-n7.1.2_2.0.0-ga, smarc-rel_imx_4.1.15_2.0.0_ga, smarc_8m-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8m-imx_v2019.04_4.19.35_1.1.0, smarc_8m_00d0-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga, smarc_8mm-imx_v2019.04_4.19.35_1.1.0, smarc_8mm-imx_v2020.04_5.4.24_2.1.0, smarc_8mp_lf_v2020.04, smarc_8mq-imx_v2020.04_5.4.24_2.1.0, smarc_8mq_lf_v2020.04, ti-u-boot-2015.07, u-boot-2013.01.y, v2013.10, v2013.10-smarct33, v2013.10-smartmen, v2014.01, v2014.04, v2014.04-smarct33, v2014.04-smarct33-emmc, v2014.04-smartmen, v2014.07, v2014.07-smarct33, v2014.07-smartmen, v2015.07-smarct33, v2015.07-smarct33-emmc, v2015.07-smarct4x, v2016.05-dlt, v2016.05-smarct3x, v2016.05-smarct3x-emmc, v2016.05-smarct4x, v2017.01-smarct3x, v2017.01-smarct3x-emmc, v2017.01-smarct4x

ColdFire: Clean up checkpatch warnings for MCF52x2

Signed-off-by: Alison Wang <b18965@freescale.com>

Showing 9 changed files with 310 additions and 262 deletions Inline Diff

arch/m68k/cpu/mcf52x2/cpu.c
1 /* 1 /*
2 * (C) Copyright 2003 2 * (C) Copyright 2003
3 * Josef Baumgartner <josef.baumgartner@telex.de> 3 * Josef Baumgartner <josef.baumgartner@telex.de>
4 * 4 *
5 * MCF5282 additionals 5 * MCF5282 additionals
6 * (C) Copyright 2005 6 * (C) Copyright 2005
7 * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de> 7 * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de>
8 * 8 *
9 * MCF5275 additions 9 * MCF5275 additions
10 * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com) 10 * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com)
11 * 11 *
12 * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
13 *
12 * See file CREDITS for list of people who contributed to this 14 * See file CREDITS for list of people who contributed to this
13 * project. 15 * project.
14 * 16 *
15 * This program is free software; you can redistribute it and/or 17 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as 18 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of 19 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version. 20 * the License, or (at your option) any later version.
19 * 21 *
20 * This program is distributed in the hope that it will be useful, 22 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details. 25 * GNU General Public License for more details.
24 * 26 *
25 * You should have received a copy of the GNU General Public License 27 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software 28 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 * MA 02111-1307 USA 30 * MA 02111-1307 USA
29 */ 31 */
30 32
31 #include <common.h> 33 #include <common.h>
32 #include <watchdog.h> 34 #include <watchdog.h>
33 #include <command.h> 35 #include <command.h>
34 #include <asm/immap.h> 36 #include <asm/immap.h>
37 #include <asm/io.h>
35 #include <netdev.h> 38 #include <netdev.h>
36 #include "cpu.h" 39 #include "cpu.h"
37 40
38 DECLARE_GLOBAL_DATA_PTR; 41 DECLARE_GLOBAL_DATA_PTR;
39 42
40 #ifdef CONFIG_M5208 43 #ifdef CONFIG_M5208
41 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 44 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
42 { 45 {
43 volatile rcm_t *rcm = (rcm_t *)(MMAP_RCM); 46 rcm_t *rcm = (rcm_t *)(MMAP_RCM);
44 47
45 udelay(1000); 48 udelay(1000);
46 49
47 rcm->rcr = RCM_RCR_SOFTRST; 50 out_8(&rcm->rcr, RCM_RCR_SOFTRST);
48 51
49 /* we don't return! */ 52 /* we don't return! */
50 return 0; 53 return 0;
51 }; 54 };
52 55
53 int checkcpu(void) 56 int checkcpu(void)
54 { 57 {
55 char buf1[32], buf2[32]; 58 char buf1[32], buf2[32];
56 59
57 printf("CPU: Freescale Coldfire MCF5208\n" 60 printf("CPU: Freescale Coldfire MCF5208\n"
58 " CPU CLK %s MHz BUS CLK %s MHz\n", 61 " CPU CLK %s MHz BUS CLK %s MHz\n",
59 strmhz(buf1, gd->cpu_clk), 62 strmhz(buf1, gd->cpu_clk),
60 strmhz(buf2, gd->bus_clk)); 63 strmhz(buf2, gd->bus_clk));
61 return 0; 64 return 0;
62 }; 65 };
63 66
64 #if defined(CONFIG_WATCHDOG) 67 #if defined(CONFIG_WATCHDOG)
65 /* Called by macro WATCHDOG_RESET */ 68 /* Called by macro WATCHDOG_RESET */
66 void watchdog_reset(void) 69 void watchdog_reset(void)
67 { 70 {
68 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG); 71 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
69 wdt->sr = 0x5555; 72
70 wdt->sr = 0xAAAA; 73 out_be16(&wdt->sr, 0x5555);
74 out_be16(&wdt->sr, 0xaaaa);
71 } 75 }
72 76
73 int watchdog_disable(void) 77 int watchdog_disable(void)
74 { 78 {
75 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG); 79 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
76 80
77 wdt->sr = 0x5555; /* reset watchdog counter */ 81 /* reset watchdog counter */
78 wdt->sr = 0xAAAA; 82 out_be16(&wdt->sr, 0x5555);
79 wdt->cr = 0; /* disable watchdog timer */ 83 out_be16(&wdt->sr, 0xaaaa);
84 /* disable watchdog timer */
85 out_be16(&wdt->cr, 0);
80 86
81 puts("WATCHDOG:disabled\n"); 87 puts("WATCHDOG:disabled\n");
82 return (0); 88 return (0);
83 } 89 }
84 90
85 int watchdog_init(void) 91 int watchdog_init(void)
86 { 92 {
87 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG); 93 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
88 94
89 wdt->cr = 0; /* disable watchdog */ 95 /* disable watchdog */
96 out_be16(&wdt->cr, 0);
90 97
91 /* set timeout and enable watchdog */ 98 /* set timeout and enable watchdog */
92 wdt->mr = 99 out_be16(&wdt->mr,
93 ((CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000)) - 1; 100 (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1);
94 wdt->sr = 0x5555; /* reset watchdog counter */
95 wdt->sr = 0xAAAA;
96 101
102 /* reset watchdog counter */
103 out_be16(&wdt->sr, 0x5555);
104 out_be16(&wdt->sr, 0xaaaa);
105
97 puts("WATCHDOG:enabled\n"); 106 puts("WATCHDOG:enabled\n");
98 return (0); 107 return (0);
99 } 108 }
100 #endif /* #ifdef CONFIG_WATCHDOG */ 109 #endif /* #ifdef CONFIG_WATCHDOG */
101 #endif /* #ifdef CONFIG_M5208 */ 110 #endif /* #ifdef CONFIG_M5208 */
102 111
103 #ifdef CONFIG_M5271 112 #ifdef CONFIG_M5271
104 /* 113 /*
105 * Both MCF5270 and MCF5271 are members of the MPC5271 family. Try to 114 * Both MCF5270 and MCF5271 are members of the MPC5271 family. Try to
106 * determine which one we are running on, based on the Chip Identification 115 * determine which one we are running on, based on the Chip Identification
107 * Register (CIR). 116 * Register (CIR).
108 */ 117 */
109 int checkcpu(void) 118 int checkcpu(void)
110 { 119 {
111 char buf[32]; 120 char buf[32];
112 unsigned short cir; /* Chip Identification Register */ 121 unsigned short cir; /* Chip Identification Register */
113 unsigned short pin; /* Part identification number */ 122 unsigned short pin; /* Part identification number */
114 unsigned char prn; /* Part revision number */ 123 unsigned char prn; /* Part revision number */
115 char *cpu_model; 124 char *cpu_model;
116 125
117 cir = mbar_readShort(MCF_CCM_CIR); 126 cir = mbar_readShort(MCF_CCM_CIR);
118 pin = cir >> MCF_CCM_CIR_PIN_LEN; 127 pin = cir >> MCF_CCM_CIR_PIN_LEN;
119 prn = cir & MCF_CCM_CIR_PRN_MASK; 128 prn = cir & MCF_CCM_CIR_PRN_MASK;
120 129
121 switch (pin) { 130 switch (pin) {
122 case MCF_CCM_CIR_PIN_MCF5270: 131 case MCF_CCM_CIR_PIN_MCF5270:
123 cpu_model = "5270"; 132 cpu_model = "5270";
124 break; 133 break;
125 case MCF_CCM_CIR_PIN_MCF5271: 134 case MCF_CCM_CIR_PIN_MCF5271:
126 cpu_model = "5271"; 135 cpu_model = "5271";
127 break; 136 break;
128 default: 137 default:
129 cpu_model = NULL; 138 cpu_model = NULL;
130 break; 139 break;
131 } 140 }
132 141
133 if (cpu_model) 142 if (cpu_model)
134 printf("CPU: Freescale ColdFire MCF%s rev. %hu, at %s MHz\n", 143 printf("CPU: Freescale ColdFire MCF%s rev. %hu, at %s MHz\n",
135 cpu_model, prn, strmhz(buf, CONFIG_SYS_CLK)); 144 cpu_model, prn, strmhz(buf, CONFIG_SYS_CLK));
136 else 145 else
137 printf("CPU: Unknown - Freescale ColdFire MCF5271 family" 146 printf("CPU: Unknown - Freescale ColdFire MCF5271 family"
138 " (PIN: 0x%x) rev. %hu, at %s MHz\n", 147 " (PIN: 0x%x) rev. %hu, at %s MHz\n",
139 pin, prn, strmhz(buf, CONFIG_SYS_CLK)); 148 pin, prn, strmhz(buf, CONFIG_SYS_CLK));
140 149
141 return 0; 150 return 0;
142 } 151 }
143 152
144 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 153 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
145 { 154 {
146 /* Call the board specific reset actions first. */ 155 /* Call the board specific reset actions first. */
147 if(board_reset) { 156 if(board_reset) {
148 board_reset(); 157 board_reset();
149 } 158 }
150 159
151 mbar_writeByte(MCF_RCM_RCR, 160 mbar_writeByte(MCF_RCM_RCR,
152 MCF_RCM_RCR_SOFTRST | MCF_RCM_RCR_FRCRSTOUT); 161 MCF_RCM_RCR_SOFTRST | MCF_RCM_RCR_FRCRSTOUT);
153 return 0; 162 return 0;
154 }; 163 };
155 164
156 #if defined(CONFIG_WATCHDOG) 165 #if defined(CONFIG_WATCHDOG)
157 void watchdog_reset(void) 166 void watchdog_reset(void)
158 { 167 {
159 mbar_writeShort(MCF_WTM_WSR, 0x5555); 168 mbar_writeShort(MCF_WTM_WSR, 0x5555);
160 mbar_writeShort(MCF_WTM_WSR, 0xAAAA); 169 mbar_writeShort(MCF_WTM_WSR, 0xAAAA);
161 } 170 }
162 171
163 int watchdog_disable(void) 172 int watchdog_disable(void)
164 { 173 {
165 mbar_writeShort(MCF_WTM_WCR, 0); 174 mbar_writeShort(MCF_WTM_WCR, 0);
166 return (0); 175 return (0);
167 } 176 }
168 177
169 int watchdog_init(void) 178 int watchdog_init(void)
170 { 179 {
171 mbar_writeShort(MCF_WTM_WCR, MCF_WTM_WCR_EN); 180 mbar_writeShort(MCF_WTM_WCR, MCF_WTM_WCR_EN);
172 return (0); 181 return (0);
173 } 182 }
174 #endif /* #ifdef CONFIG_WATCHDOG */ 183 #endif /* #ifdef CONFIG_WATCHDOG */
175 184
176 #endif 185 #endif
177 186
178 #ifdef CONFIG_M5272 187 #ifdef CONFIG_M5272
179 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 188 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
180 { 189 {
181 volatile wdog_t *wdp = (wdog_t *) (MMAP_WDOG); 190 wdog_t *wdp = (wdog_t *) (MMAP_WDOG);
182 191
183 wdp->wdog_wrrr = 0; 192 out_be16(&wdp->wdog_wrrr, 0);
184 udelay(1000); 193 udelay(1000);
185 194
186 /* enable watchdog, set timeout to 0 and wait */ 195 /* enable watchdog, set timeout to 0 and wait */
187 wdp->wdog_wrrr = 1; 196 out_be16(&wdp->wdog_wrrr, 1);
188 while (1) ; 197 while (1) ;
189 198
190 /* we don't return! */ 199 /* we don't return! */
191 return 0; 200 return 0;
192 }; 201 };
193 202
194 int checkcpu(void) 203 int checkcpu(void)
195 { 204 {
196 volatile sysctrl_t *sysctrl = (sysctrl_t *) (MMAP_CFG); 205 sysctrl_t *sysctrl = (sysctrl_t *) (MMAP_CFG);
197 uchar msk; 206 uchar msk;
198 char *suf; 207 char *suf;
199 208
200 puts("CPU: "); 209 puts("CPU: ");
201 msk = (sysctrl->sc_dir > 28) & 0xf; 210 msk = (in_be32(&sysctrl->sc_dir) > 28) & 0xf;
202 switch (msk) { 211 switch (msk) {
203 case 0x2: 212 case 0x2:
204 suf = "1K75N"; 213 suf = "1K75N";
205 break; 214 break;
206 case 0x4: 215 case 0x4:
207 suf = "3K75N"; 216 suf = "3K75N";
208 break; 217 break;
209 default: 218 default:
210 suf = NULL; 219 suf = NULL;
211 printf("Freescale MCF5272 (Mask:%01x)\n", msk); 220 printf("Freescale MCF5272 (Mask:%01x)\n", msk);
212 break; 221 break;
213 } 222 }
214 223
215 if (suf) 224 if (suf)
216 printf("Freescale MCF5272 %s\n", suf); 225 printf("Freescale MCF5272 %s\n", suf);
217 return 0; 226 return 0;
218 }; 227 };
219 228
220 #if defined(CONFIG_WATCHDOG) 229 #if defined(CONFIG_WATCHDOG)
221 /* Called by macro WATCHDOG_RESET */ 230 /* Called by macro WATCHDOG_RESET */
222 void watchdog_reset(void) 231 void watchdog_reset(void)
223 { 232 {
224 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG); 233 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
225 wdt->wdog_wcr = 0; 234
235 out_be16(&wdt->wdog_wcr, 0);
226 } 236 }
227 237
228 int watchdog_disable(void) 238 int watchdog_disable(void)
229 { 239 {
230 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG); 240 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
231 241
232 wdt->wdog_wcr = 0; /* reset watchdog counter */ 242 /* reset watchdog counter */
233 wdt->wdog_wirr = 0; /* disable watchdog interrupt */ 243 out_be16(&wdt->wdog_wcr, 0);
234 wdt->wdog_wrrr = 0; /* disable watchdog timer */ 244 /* disable watchdog interrupt */
245 out_be16(&wdt->wdog_wirr, 0);
246 /* disable watchdog timer */
247 out_be16(&wdt->wdog_wrrr, 0);
235 248
236 puts("WATCHDOG:disabled\n"); 249 puts("WATCHDOG:disabled\n");
237 return (0); 250 return (0);
238 } 251 }
239 252
240 int watchdog_init(void) 253 int watchdog_init(void)
241 { 254 {
242 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG); 255 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
243 256
244 wdt->wdog_wirr = 0; /* disable watchdog interrupt */ 257 /* disable watchdog interrupt */
258 out_be16(&wdt->wdog_wirr, 0);
245 259
246 /* set timeout and enable watchdog */ 260 /* set timeout and enable watchdog */
247 wdt->wdog_wrrr = 261 out_be16(&wdt->wdog_wrrr,
248 ((CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000)) - 1; 262 (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1);
249 wdt->wdog_wcr = 0; /* reset watchdog counter */
250 263
264 /* reset watchdog counter */
265 out_be16(&wdt->wdog_wcr, 0);
266
251 puts("WATCHDOG:enabled\n"); 267 puts("WATCHDOG:enabled\n");
252 return (0); 268 return (0);
253 } 269 }
254 #endif /* #ifdef CONFIG_WATCHDOG */ 270 #endif /* #ifdef CONFIG_WATCHDOG */
255 271
256 #endif /* #ifdef CONFIG_M5272 */ 272 #endif /* #ifdef CONFIG_M5272 */
257 273
258 #ifdef CONFIG_M5275 274 #ifdef CONFIG_M5275
259 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 275 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
260 { 276 {
261 volatile rcm_t *rcm = (rcm_t *)(MMAP_RCM); 277 rcm_t *rcm = (rcm_t *)(MMAP_RCM);
262 278
263 udelay(1000); 279 udelay(1000);
264 280
265 rcm->rcr = RCM_RCR_SOFTRST; 281 out_8(&rcm->rcr, RCM_RCR_SOFTRST);
266 282
267 /* we don't return! */ 283 /* we don't return! */
268 return 0; 284 return 0;
269 }; 285 };
270 286
271 int checkcpu(void) 287 int checkcpu(void)
272 { 288 {
273 char buf[32]; 289 char buf[32];
274 290
275 printf("CPU: Freescale Coldfire MCF5275 at %s MHz\n", 291 printf("CPU: Freescale Coldfire MCF5275 at %s MHz\n",
276 strmhz(buf, CONFIG_SYS_CLK)); 292 strmhz(buf, CONFIG_SYS_CLK));
277 return 0; 293 return 0;
278 }; 294 };
279 295
280 296
281 #if defined(CONFIG_WATCHDOG) 297 #if defined(CONFIG_WATCHDOG)
282 /* Called by macro WATCHDOG_RESET */ 298 /* Called by macro WATCHDOG_RESET */
283 void watchdog_reset(void) 299 void watchdog_reset(void)
284 { 300 {
285 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG); 301 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
286 wdt->wsr = 0x5555; 302
287 wdt->wsr = 0xAAAA; 303 out_be16(&wdt->wsr, 0x5555);
304 out_be16(&wdt->wsr, 0xaaaa);
288 } 305 }
289 306
290 int watchdog_disable(void) 307 int watchdog_disable(void)
291 { 308 {
292 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG); 309 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
293 310
294 wdt->wsr = 0x5555; /* reset watchdog counter */ 311 /* reset watchdog counter */
295 wdt->wsr = 0xAAAA; 312 out_be16(&wdt->wsr, 0x5555);
296 wdt->wcr = 0; /* disable watchdog timer */ 313 out_be16(&wdt->wsr, 0xaaaa);
297 314
315 /* disable watchdog timer */
316 out_be16(&wdt->wcr, 0);
317
298 puts("WATCHDOG:disabled\n"); 318 puts("WATCHDOG:disabled\n");
299 return (0); 319 return (0);
300 } 320 }
301 321
302 int watchdog_init(void) 322 int watchdog_init(void)
303 { 323 {
304 volatile wdog_t *wdt = (volatile wdog_t *)(MMAP_WDOG); 324 wdog_t *wdt = (wdog_t *)(MMAP_WDOG);
305 325
306 wdt->wcr = 0; /* disable watchdog */ 326 /* disable watchdog */
327 out_be16(&wdt->wcr, 0);
307 328
308 /* set timeout and enable watchdog */ 329 /* set timeout and enable watchdog */
309 wdt->wmr = 330 out_be16(&wdt->wmr,
310 ((CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000)) - 1; 331 (CONFIG_WATCHDOG_TIMEOUT * CONFIG_SYS_HZ) / (32768 * 1000) - 1);
311 wdt->wsr = 0x5555; /* reset watchdog counter */ 332
312 wdt->wsr = 0xAAAA; 333 /* reset watchdog counter */
334 out_be16(&wdt->wsr, 0x5555);
335 out_be16(&wdt->wsr, 0xaaaa);
313 336
314 puts("WATCHDOG:enabled\n"); 337 puts("WATCHDOG:enabled\n");
315 return (0); 338 return (0);
316 } 339 }
317 #endif /* #ifdef CONFIG_WATCHDOG */ 340 #endif /* #ifdef CONFIG_WATCHDOG */
318 341
319 #endif /* #ifdef CONFIG_M5275 */ 342 #endif /* #ifdef CONFIG_M5275 */
320 343
321 #ifdef CONFIG_M5282 344 #ifdef CONFIG_M5282
322 int checkcpu(void) 345 int checkcpu(void)
323 { 346 {
324 unsigned char resetsource = MCFRESET_RSR; 347 unsigned char resetsource = MCFRESET_RSR;
325 348
326 printf("CPU: Freescale Coldfire MCF5282 (PIN: %2.2x REV: %2.2x)\n", 349 printf("CPU: Freescale Coldfire MCF5282 (PIN: %2.2x REV: %2.2x)\n",
327 MCFCCM_CIR >> 8, MCFCCM_CIR & MCFCCM_CIR_PRN_MASK); 350 MCFCCM_CIR >> 8, MCFCCM_CIR & MCFCCM_CIR_PRN_MASK);
328 printf("Reset:%s%s%s%s%s%s%s\n", 351 printf("Reset:%s%s%s%s%s%s%s\n",
329 (resetsource & MCFRESET_RSR_LOL) ? " Loss of Lock" : "", 352 (resetsource & MCFRESET_RSR_LOL) ? " Loss of Lock" : "",
330 (resetsource & MCFRESET_RSR_LOC) ? " Loss of Clock" : "", 353 (resetsource & MCFRESET_RSR_LOC) ? " Loss of Clock" : "",
331 (resetsource & MCFRESET_RSR_EXT) ? " External" : "", 354 (resetsource & MCFRESET_RSR_EXT) ? " External" : "",
332 (resetsource & MCFRESET_RSR_POR) ? " Power On" : "", 355 (resetsource & MCFRESET_RSR_POR) ? " Power On" : "",
333 (resetsource & MCFRESET_RSR_WDR) ? " Watchdog" : "", 356 (resetsource & MCFRESET_RSR_WDR) ? " Watchdog" : "",
334 (resetsource & MCFRESET_RSR_SOFT) ? " Software" : "", 357 (resetsource & MCFRESET_RSR_SOFT) ? " Software" : "",
335 (resetsource & MCFRESET_RSR_LVD) ? " Low Voltage" : ""); 358 (resetsource & MCFRESET_RSR_LVD) ? " Low Voltage" : "");
336 return 0; 359 return 0;
337 } 360 }
338 361
339 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 362 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
340 { 363 {
341 MCFRESET_RCR = MCFRESET_RCR_SOFTRST; 364 MCFRESET_RCR = MCFRESET_RCR_SOFTRST;
342 return 0; 365 return 0;
343 }; 366 };
344 #endif 367 #endif
345 368
346 #ifdef CONFIG_M5249 369 #ifdef CONFIG_M5249
347 int checkcpu(void) 370 int checkcpu(void)
348 { 371 {
349 char buf[32]; 372 char buf[32];
350 373
351 printf("CPU: Freescale Coldfire MCF5249 at %s MHz\n", 374 printf("CPU: Freescale Coldfire MCF5249 at %s MHz\n",
352 strmhz(buf, CONFIG_SYS_CLK)); 375 strmhz(buf, CONFIG_SYS_CLK));
353 return 0; 376 return 0;
354 } 377 }
355 378
356 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 379 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
357 { 380 {
358 /* enable watchdog, set timeout to 0 and wait */ 381 /* enable watchdog, set timeout to 0 and wait */
359 mbar_writeByte(MCFSIM_SYPCR, 0xc0); 382 mbar_writeByte(MCFSIM_SYPCR, 0xc0);
360 while (1) ; 383 while (1) ;
361 384
362 /* we don't return! */ 385 /* we don't return! */
363 return 0; 386 return 0;
364 }; 387 };
365 #endif 388 #endif
366 389
367 #ifdef CONFIG_M5253 390 #ifdef CONFIG_M5253
368 int checkcpu(void) 391 int checkcpu(void)
369 { 392 {
370 char buf[32]; 393 char buf[32];
371 394
372 unsigned char resetsource = mbar_readLong(SIM_RSR); 395 unsigned char resetsource = mbar_readLong(SIM_RSR);
373 printf("CPU: Freescale Coldfire MCF5253 at %s MHz\n", 396 printf("CPU: Freescale Coldfire MCF5253 at %s MHz\n",
374 strmhz(buf, CONFIG_SYS_CLK)); 397 strmhz(buf, CONFIG_SYS_CLK));
375 398
376 if ((resetsource & SIM_RSR_HRST) || (resetsource & SIM_RSR_SWTR)) { 399 if ((resetsource & SIM_RSR_HRST) || (resetsource & SIM_RSR_SWTR)) {
377 printf("Reset:%s%s\n", 400 printf("Reset:%s%s\n",
378 (resetsource & SIM_RSR_HRST) ? " Hardware/ System Reset" 401 (resetsource & SIM_RSR_HRST) ? " Hardware/ System Reset"
379 : "", 402 : "",
380 (resetsource & SIM_RSR_SWTR) ? " Software Watchdog" : 403 (resetsource & SIM_RSR_SWTR) ? " Software Watchdog" :
381 ""); 404 "");
382 } 405 }
383 return 0; 406 return 0;
384 } 407 }
385 408
386 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 409 int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
387 { 410 {
388 /* enable watchdog, set timeout to 0 and wait */ 411 /* enable watchdog, set timeout to 0 and wait */
389 mbar_writeByte(SIM_SYPCR, 0xc0); 412 mbar_writeByte(SIM_SYPCR, 0xc0);
390 while (1) ; 413 while (1) ;
391 414
392 /* we don't return! */ 415 /* we don't return! */
393 return 0; 416 return 0;
394 }; 417 };
395 #endif 418 #endif
396 419
397 #if defined(CONFIG_MCFFEC) 420 #if defined(CONFIG_MCFFEC)
398 /* Default initializations for MCFFEC controllers. To override, 421 /* Default initializations for MCFFEC controllers. To override,
399 * create a board-specific function called: 422 * create a board-specific function called:
400 * int board_eth_init(bd_t *bis) 423 * int board_eth_init(bd_t *bis)
401 */ 424 */
402 425
403 int cpu_eth_init(bd_t *bis) 426 int cpu_eth_init(bd_t *bis)
404 { 427 {
405 return mcffec_initialize(bis); 428 return mcffec_initialize(bis);
arch/m68k/cpu/mcf52x2/cpu_init.c
1 /* 1 /*
2 * (C) Copyright 2003 2 * (C) Copyright 2003
3 * Josef Baumgartner <josef.baumgartner@telex.de> 3 * Josef Baumgartner <josef.baumgartner@telex.de>
4 * 4 *
5 * MCF5282 additionals 5 * MCF5282 additionals
6 * (C) Copyright 2005 6 * (C) Copyright 2005
7 * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de> 7 * BuS Elektronik GmbH & Co. KG <esw@bus-elektronik.de>
8 * (c) Copyright 2010 8 * (c) Copyright 2010
9 * Arcturus Networks Inc. <www.arcturusnetworks.com> 9 * Arcturus Networks Inc. <www.arcturusnetworks.com>
10 * 10 *
11 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. 11 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
12 * TsiChung Liew (Tsi-Chung.Liew@freescale.com) 12 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
13 * Hayden Fraser (Hayden.Fraser@freescale.com) 13 * Hayden Fraser (Hayden.Fraser@freescale.com)
14 * 14 *
15 * MCF5275 additions 15 * MCF5275 additions
16 * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com) 16 * Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com)
17 * 17 *
18 * See file CREDITS for list of people who contributed to this 18 * See file CREDITS for list of people who contributed to this
19 * project. 19 * project.
20 * 20 *
21 * This program is free software; you can redistribute it and/or 21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License as 22 * modify it under the terms of the GNU General Public License as
23 * published by the Free Software Foundation; either version 2 of 23 * published by the Free Software Foundation; either version 2 of
24 * the License, or (at your option) any later version. 24 * the License, or (at your option) any later version.
25 * 25 *
26 * This program is distributed in the hope that it will be useful, 26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of 27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details. 29 * GNU General Public License for more details.
30 * 30 *
31 * You should have received a copy of the GNU General Public License 31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software 32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 33 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 * MA 02111-1307 USA 34 * MA 02111-1307 USA
35 */ 35 */
36 36
37 #include <common.h> 37 #include <common.h>
38 #include <watchdog.h> 38 #include <watchdog.h>
39 #include <asm/immap.h> 39 #include <asm/immap.h>
40 #include <asm/io.h>
40 41
41 #if defined(CONFIG_CMD_NET) 42 #if defined(CONFIG_CMD_NET)
42 #include <config.h> 43 #include <config.h>
43 #include <net.h> 44 #include <net.h>
44 #include <asm/fec.h> 45 #include <asm/fec.h>
45 #endif 46 #endif
46 47
47 #ifndef CONFIG_M5272 48 #ifndef CONFIG_M5272
48 /* Only 5272 Flexbus chipselect is different from the rest */ 49 /* Only 5272 Flexbus chipselect is different from the rest */
49 void init_fbcs(void) 50 void init_fbcs(void)
50 { 51 {
51 volatile fbcs_t *fbcs = (fbcs_t *) (MMAP_FBCS); 52 fbcs_t *fbcs = (fbcs_t *) (MMAP_FBCS);
52 53
53 #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \ 54 #if (defined(CONFIG_SYS_CS0_BASE) && defined(CONFIG_SYS_CS0_MASK) \
54 && defined(CONFIG_SYS_CS0_CTRL)) 55 && defined(CONFIG_SYS_CS0_CTRL))
55 fbcs->csar0 = CONFIG_SYS_CS0_BASE; 56 out_be32(&fbcs->csar0, CONFIG_SYS_CS0_BASE);
56 fbcs->cscr0 = CONFIG_SYS_CS0_CTRL; 57 out_be32(&fbcs->cscr0, CONFIG_SYS_CS0_CTRL);
57 fbcs->csmr0 = CONFIG_SYS_CS0_MASK; 58 out_be32(&fbcs->csmr0, CONFIG_SYS_CS0_MASK);
58 #else 59 #else
59 #warning "Chip Select 0 are not initialized/used" 60 #warning "Chip Select 0 are not initialized/used"
60 #endif 61 #endif
61 #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \ 62 #if (defined(CONFIG_SYS_CS1_BASE) && defined(CONFIG_SYS_CS1_MASK) \
62 && defined(CONFIG_SYS_CS1_CTRL)) 63 && defined(CONFIG_SYS_CS1_CTRL))
63 fbcs->csar1 = CONFIG_SYS_CS1_BASE; 64 out_be32(&fbcs->csar1, CONFIG_SYS_CS1_BASE);
64 fbcs->cscr1 = CONFIG_SYS_CS1_CTRL; 65 out_be32(&fbcs->cscr1, CONFIG_SYS_CS1_CTRL);
65 fbcs->csmr1 = CONFIG_SYS_CS1_MASK; 66 out_be32(&fbcs->csmr1, CONFIG_SYS_CS1_MASK);
66 #endif 67 #endif
67 #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \ 68 #if (defined(CONFIG_SYS_CS2_BASE) && defined(CONFIG_SYS_CS2_MASK) \
68 && defined(CONFIG_SYS_CS2_CTRL)) 69 && defined(CONFIG_SYS_CS2_CTRL))
69 fbcs->csar2 = CONFIG_SYS_CS2_BASE; 70 out_be32(&fbcs->csar2, CONFIG_SYS_CS2_BASE);
70 fbcs->cscr2 = CONFIG_SYS_CS2_CTRL; 71 out_be32(&fbcs->cscr2, CONFIG_SYS_CS2_CTRL);
71 fbcs->csmr2 = CONFIG_SYS_CS2_MASK; 72 out_be32(&fbcs->csmr2, CONFIG_SYS_CS2_MASK);
72 #endif 73 #endif
73 #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \ 74 #if (defined(CONFIG_SYS_CS3_BASE) && defined(CONFIG_SYS_CS3_MASK) \
74 && defined(CONFIG_SYS_CS3_CTRL)) 75 && defined(CONFIG_SYS_CS3_CTRL))
75 fbcs->csar3 = CONFIG_SYS_CS3_BASE; 76 out_be32(&fbcs->csar3, CONFIG_SYS_CS3_BASE);
76 fbcs->cscr3 = CONFIG_SYS_CS3_CTRL; 77 out_be32(&fbcs->cscr3, CONFIG_SYS_CS3_CTRL);
77 fbcs->csmr3 = CONFIG_SYS_CS3_MASK; 78 out_be32(&fbcs->csmr3, CONFIG_SYS_CS3_MASK);
78 #endif 79 #endif
79 #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \ 80 #if (defined(CONFIG_SYS_CS4_BASE) && defined(CONFIG_SYS_CS4_MASK) \
80 && defined(CONFIG_SYS_CS4_CTRL)) 81 && defined(CONFIG_SYS_CS4_CTRL))
81 fbcs->csar4 = CONFIG_SYS_CS4_BASE; 82 out_be32(&fbcs->csar4, CONFIG_SYS_CS4_BASE);
82 fbcs->cscr4 = CONFIG_SYS_CS4_CTRL; 83 out_be32(&fbcs->cscr4, CONFIG_SYS_CS4_CTRL);
83 fbcs->csmr4 = CONFIG_SYS_CS4_MASK; 84 out_be32(&fbcs->csmr4, CONFIG_SYS_CS4_MASK);
84 #endif 85 #endif
85 #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \ 86 #if (defined(CONFIG_SYS_CS5_BASE) && defined(CONFIG_SYS_CS5_MASK) \
86 && defined(CONFIG_SYS_CS5_CTRL)) 87 && defined(CONFIG_SYS_CS5_CTRL))
87 fbcs->csar5 = CONFIG_SYS_CS5_BASE; 88 out_be32(&fbcs->csar5, CONFIG_SYS_CS5_BASE);
88 fbcs->cscr5 = CONFIG_SYS_CS5_CTRL; 89 out_be32(&fbcs->cscr5, CONFIG_SYS_CS5_CTRL);
89 fbcs->csmr5 = CONFIG_SYS_CS5_MASK; 90 out_be32(&fbcs->csmr5, CONFIG_SYS_CS5_MASK);
90 #endif 91 #endif
91 #if (defined(CONFIG_SYS_CS6_BASE) && defined(CONFIG_SYS_CS6_MASK) \ 92 #if (defined(CONFIG_SYS_CS6_BASE) && defined(CONFIG_SYS_CS6_MASK) \
92 && defined(CONFIG_SYS_CS6_CTRL)) 93 && defined(CONFIG_SYS_CS6_CTRL))
93 fbcs->csar6 = CONFIG_SYS_CS6_BASE; 94 out_be32(&fbcs->csar6, CONFIG_SYS_CS6_BASE);
94 fbcs->cscr6 = CONFIG_SYS_CS6_CTRL; 95 out_be32(&fbcs->cscr6, CONFIG_SYS_CS6_CTRL);
95 fbcs->csmr6 = CONFIG_SYS_CS6_MASK; 96 out_be32(&fbcs->csmr6, CONFIG_SYS_CS6_MASK);
96 #endif 97 #endif
97 #if (defined(CONFIG_SYS_CS7_BASE) && defined(CONFIG_SYS_CS7_MASK) \ 98 #if (defined(CONFIG_SYS_CS7_BASE) && defined(CONFIG_SYS_CS7_MASK) \
98 && defined(CONFIG_SYS_CS7_CTRL)) 99 && defined(CONFIG_SYS_CS7_CTRL))
99 fbcs->csar7 = CONFIG_SYS_CS7_BASE; 100 out_be32(&fbcs->csar7, CONFIG_SYS_CS7_BASE);
100 fbcs->cscr7 = CONFIG_SYS_CS7_CTRL; 101 out_be32(&fbcs->cscr7, CONFIG_SYS_CS7_CTRL);
101 fbcs->csmr7 = CONFIG_SYS_CS7_MASK; 102 out_be32(&fbcs->csmr7, CONFIG_SYS_CS7_MASK);
102 #endif 103 #endif
103 } 104 }
104 #endif 105 #endif
105 106
106 #if defined(CONFIG_M5208) 107 #if defined(CONFIG_M5208)
107 void cpu_init_f(void) 108 void cpu_init_f(void)
108 { 109 {
109 volatile scm1_t *scm1 = (scm1_t *) MMAP_SCM1; 110 scm1_t *scm1 = (scm1_t *) MMAP_SCM1;
110 111
111 #ifndef CONFIG_WATCHDOG 112 #ifndef CONFIG_WATCHDOG
112 volatile wdog_t *wdg = (wdog_t *) MMAP_WDOG; 113 wdog_t *wdg = (wdog_t *) MMAP_WDOG;
113 114
114 /* Disable the watchdog if we aren't using it */ 115 /* Disable the watchdog if we aren't using it */
115 wdg->cr = 0; 116 out_be16(&wdg->cr, 0);
116 #endif 117 #endif
117 118
118 scm1->mpr = 0x77777777; 119 out_be32(&scm1->mpr, 0x77777777);
119 scm1->pacra = 0; 120 out_be32(&scm1->pacra, 0);
120 scm1->pacrb = 0; 121 out_be32(&scm1->pacrb, 0);
121 scm1->pacrc = 0; 122 out_be32(&scm1->pacrc, 0);
122 scm1->pacrd = 0; 123 out_be32(&scm1->pacrd, 0);
123 scm1->pacre = 0; 124 out_be32(&scm1->pacre, 0);
124 scm1->pacrf = 0; 125 out_be32(&scm1->pacrf, 0);
125 126
126 /* FlexBus Chipselect */ 127 /* FlexBus Chipselect */
127 init_fbcs(); 128 init_fbcs();
128 129
129 icache_enable(); 130 icache_enable();
130 } 131 }
131 132
132 /* initialize higher level parts of CPU like timers */ 133 /* initialize higher level parts of CPU like timers */
133 int cpu_init_r(void) 134 int cpu_init_r(void)
134 { 135 {
135 return (0); 136 return (0);
136 } 137 }
137 138
138 void uart_port_conf(int port) 139 void uart_port_conf(int port)
139 { 140 {
140 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; 141 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
141 142
142 /* Setup Ports: */ 143 /* Setup Ports: */
143 switch (port) { 144 switch (port) {
144 case 0: 145 case 0:
145 gpio->par_uart &= GPIO_PAR_UART0_UNMASK; 146 clrbits_be16(&gpio->par_uart, ~GPIO_PAR_UART0_UNMASK);
146 gpio->par_uart |= (GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD); 147 setbits_be16(&gpio->par_uart, GPIO_PAR_UART_U0TXD | GPIO_PAR_UART_U0RXD);
147 break; 148 break;
148 case 1: 149 case 1:
149 gpio->par_uart &= GPIO_PAR_UART0_UNMASK; 150 clrbits_be16(&gpio->par_uart, ~GPIO_PAR_UART0_UNMASK);
150 gpio->par_uart |= (GPIO_PAR_UART_U1TXD | GPIO_PAR_UART_U1RXD); 151 setbits_be16(&gpio->par_uart, GPIO_PAR_UART_U1TXD | GPIO_PAR_UART_U1RXD);
151 break; 152 break;
152 case 2: 153 case 2:
153 #ifdef CONFIG_SYS_UART2_PRI_GPIO 154 #ifdef CONFIG_SYS_UART2_PRI_GPIO
154 gpio->par_timer &= 155 clrbits_8(&gpio->par_timer,
155 (GPIO_PAR_TMR_TIN0_UNMASK | GPIO_PAR_TMR_TIN1_UNMASK); 156 ~(GPIO_PAR_TMR_TIN0_UNMASK | GPIO_PAR_TMR_TIN1_UNMASK));
156 gpio->par_timer |= 157 setbits_8(&gpio->par_timer,
157 (GPIO_PAR_TMR_TIN0_U2TXD | GPIO_PAR_TMR_TIN1_U2RXD); 158 GPIO_PAR_TMR_TIN0_U2TXD | GPIO_PAR_TMR_TIN1_U2RXD);
158 #endif 159 #endif
159 #ifdef CONFIG_SYS_UART2_ALT1_GPIO 160 #ifdef CONFIG_SYS_UART2_ALT1_GPIO
160 gpio->par_feci2c &= 161 clrbits_8(&gpio->par_feci2c,
161 (GPIO_PAR_FECI2C_MDC_UNMASK | GPIO_PAR_FECI2C_MDIO_UNMASK); 162 ~(GPIO_PAR_FECI2C_MDC_UNMASK | GPIO_PAR_FECI2C_MDIO_UNMASK));
162 gpio->par_feci2c |= 163 setbits_8(&gpio->par_feci2c,
163 (GPIO_PAR_FECI2C_MDC_U2TXD | GPIO_PAR_FECI2C_MDIO_U2RXD); 164 GPIO_PAR_FECI2C_MDC_U2TXD | GPIO_PAR_FECI2C_MDIO_U2RXD);
164 #endif 165 #endif
165 #ifdef CONFIG_SYS_UART2_ALT1_GPIO 166 #ifdef CONFIG_SYS_UART2_ALT1_GPIO
166 gpio->par_feci2c &= 167 clrbits_8(&gpio->par_feci2c,
167 (GPIO_PAR_FECI2C_SDA_UNMASK | GPIO_PAR_FECI2C_SCL_UNMASK); 168 ~(GPIO_PAR_FECI2C_SDA_UNMASK | GPIO_PAR_FECI2C_SCL_UNMASK));
168 gpio->par_feci2c |= 169 setbits_8(&gpio->par_feci2c,
169 (GPIO_PAR_FECI2C_SDA_U2TXD | GPIO_PAR_FECI2C_SCL_U2RXD); 170 GPIO_PAR_FECI2C_SDA_U2TXD | GPIO_PAR_FECI2C_SCL_U2RXD);
170 #endif 171 #endif
171 break; 172 break;
172 } 173 }
173 } 174 }
174 175
175 #if defined(CONFIG_CMD_NET) 176 #if defined(CONFIG_CMD_NET)
176 int fecpin_setclear(struct eth_device *dev, int setclear) 177 int fecpin_setclear(struct eth_device *dev, int setclear)
177 { 178 {
178 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; 179 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
179 180
180 if (setclear) { 181 if (setclear) {
181 gpio->par_fec |= 182 setbits_8(&gpio->par_fec,
182 GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC; 183 GPIO_PAR_FEC_7W_FEC | GPIO_PAR_FEC_MII_FEC);
183 gpio->par_feci2c |= 184 setbits_8(&gpio->par_feci2c,
184 GPIO_PAR_FECI2C_MDC_MDC | GPIO_PAR_FECI2C_MDIO_MDIO; 185 GPIO_PAR_FECI2C_MDC_MDC | GPIO_PAR_FECI2C_MDIO_MDIO);
185 } else { 186 } else {
186 gpio->par_fec &= 187 clrbits_8(&gpio->par_fec,
187 (GPIO_PAR_FEC_7W_UNMASK & GPIO_PAR_FEC_MII_UNMASK); 188 ~(GPIO_PAR_FEC_7W_UNMASK & GPIO_PAR_FEC_MII_UNMASK));
188 gpio->par_feci2c &= GPIO_PAR_FECI2C_RMII_UNMASK; 189 clrbits_8(&gpio->par_feci2c, ~GPIO_PAR_FECI2C_RMII_UNMASK);
189 } 190 }
190 return 0; 191 return 0;
191 } 192 }
192 #endif /* CONFIG_CMD_NET */ 193 #endif /* CONFIG_CMD_NET */
193 #endif /* CONFIG_M5208 */ 194 #endif /* CONFIG_M5208 */
194 195
195 #if defined(CONFIG_M5253) 196 #if defined(CONFIG_M5253)
196 /* 197 /*
197 * Breath some life into the CPU... 198 * Breath some life into the CPU...
198 * 199 *
199 * Set up the memory map, 200 * Set up the memory map,
200 * initialize a bunch of registers, 201 * initialize a bunch of registers,
201 * initialize the UPM's 202 * initialize the UPM's
202 */ 203 */
203 void cpu_init_f(void) 204 void cpu_init_f(void)
204 { 205 {
205 mbar_writeByte(MCFSIM_MPARK, 0x40); /* 5249 Internal Core takes priority over DMA */ 206 mbar_writeByte(MCFSIM_MPARK, 0x40); /* 5249 Internal Core takes priority over DMA */
206 mbar_writeByte(MCFSIM_SYPCR, 0x00); 207 mbar_writeByte(MCFSIM_SYPCR, 0x00);
207 mbar_writeByte(MCFSIM_SWIVR, 0x0f); 208 mbar_writeByte(MCFSIM_SWIVR, 0x0f);
208 mbar_writeByte(MCFSIM_SWSR, 0x00); 209 mbar_writeByte(MCFSIM_SWSR, 0x00);
209 mbar_writeByte(MCFSIM_SWDICR, 0x00); 210 mbar_writeByte(MCFSIM_SWDICR, 0x00);
210 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00); 211 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
211 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88); 212 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
212 mbar_writeByte(MCFSIM_I2CICR, 0x00); 213 mbar_writeByte(MCFSIM_I2CICR, 0x00);
213 mbar_writeByte(MCFSIM_UART1ICR, 0x00); 214 mbar_writeByte(MCFSIM_UART1ICR, 0x00);
214 mbar_writeByte(MCFSIM_UART2ICR, 0x00); 215 mbar_writeByte(MCFSIM_UART2ICR, 0x00);
215 mbar_writeByte(MCFSIM_ICR6, 0x00); 216 mbar_writeByte(MCFSIM_ICR6, 0x00);
216 mbar_writeByte(MCFSIM_ICR7, 0x00); 217 mbar_writeByte(MCFSIM_ICR7, 0x00);
217 mbar_writeByte(MCFSIM_ICR8, 0x00); 218 mbar_writeByte(MCFSIM_ICR8, 0x00);
218 mbar_writeByte(MCFSIM_ICR9, 0x00); 219 mbar_writeByte(MCFSIM_ICR9, 0x00);
219 mbar_writeByte(MCFSIM_QSPIICR, 0x00); 220 mbar_writeByte(MCFSIM_QSPIICR, 0x00);
220 221
221 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080); 222 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
222 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */ 223 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
223 mbar2_writeByte(MCFSIM_SPURVEC, 0x00); 224 mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
224 225
225 /*mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); */ /* Enable a 1 cycle pre-drive cycle on CS1 */ 226 /*mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); */ /* Enable a 1 cycle pre-drive cycle on CS1 */
226 227
227 /* FlexBus Chipselect */ 228 /* FlexBus Chipselect */
228 init_fbcs(); 229 init_fbcs();
229 230
230 #ifdef CONFIG_FSL_I2C 231 #ifdef CONFIG_FSL_I2C
231 CONFIG_SYS_I2C_PINMUX_REG = 232 CONFIG_SYS_I2C_PINMUX_REG =
232 CONFIG_SYS_I2C_PINMUX_REG & CONFIG_SYS_I2C_PINMUX_CLR; 233 CONFIG_SYS_I2C_PINMUX_REG & CONFIG_SYS_I2C_PINMUX_CLR;
233 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET; 234 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
234 #ifdef CONFIG_SYS_I2C2_OFFSET 235 #ifdef CONFIG_SYS_I2C2_OFFSET
235 CONFIG_SYS_I2C2_PINMUX_REG &= CONFIG_SYS_I2C2_PINMUX_CLR; 236 CONFIG_SYS_I2C2_PINMUX_REG &= CONFIG_SYS_I2C2_PINMUX_CLR;
236 CONFIG_SYS_I2C2_PINMUX_REG |= CONFIG_SYS_I2C2_PINMUX_SET; 237 CONFIG_SYS_I2C2_PINMUX_REG |= CONFIG_SYS_I2C2_PINMUX_SET;
237 #endif 238 #endif
238 #endif 239 #endif
239 240
240 /* enable instruction cache now */ 241 /* enable instruction cache now */
241 icache_enable(); 242 icache_enable();
242 } 243 }
243 244
244 /*initialize higher level parts of CPU like timers */ 245 /*initialize higher level parts of CPU like timers */
245 int cpu_init_r(void) 246 int cpu_init_r(void)
246 { 247 {
247 return (0); 248 return (0);
248 } 249 }
249 250
250 void uart_port_conf(int port) 251 void uart_port_conf(int port)
251 { 252 {
252 volatile u32 *par = (u32 *) MMAP_PAR; 253 u32 *par = (u32 *) MMAP_PAR;
253 254
254 /* Setup Ports: */ 255 /* Setup Ports: */
255 switch (port) { 256 switch (port) {
256 case 1: 257 case 1:
257 *par &= 0xFFE7FFFF; 258 clrbits_be32(par, 0x00180000);
258 *par |= 0x00180000; 259 setbits_be32(par, 0x00180000);
259 break; 260 break;
260 case 2: 261 case 2:
261 *par &= 0xFFFFFFFC; 262 clrbits_be32(par, 0x00000003);
262 *par &= 0x00000003; 263 clrbits_be32(par, 0xFFFFFFFC);
263 break; 264 break;
264 } 265 }
265 } 266 }
266 #endif /* #if defined(CONFIG_M5253) */ 267 #endif /* #if defined(CONFIG_M5253) */
267 268
268 #if defined(CONFIG_M5271) 269 #if defined(CONFIG_M5271)
269 void cpu_init_f(void) 270 void cpu_init_f(void)
270 { 271 {
271 #ifndef CONFIG_WATCHDOG 272 #ifndef CONFIG_WATCHDOG
272 /* Disable the watchdog if we aren't using it */ 273 /* Disable the watchdog if we aren't using it */
273 mbar_writeShort(MCF_WTM_WCR, 0); 274 mbar_writeShort(MCF_WTM_WCR, 0);
274 #endif 275 #endif
275 276
276 /* FlexBus Chipselect */ 277 /* FlexBus Chipselect */
277 init_fbcs(); 278 init_fbcs();
278 279
279 #ifdef CONFIG_SYS_MCF_SYNCR 280 #ifdef CONFIG_SYS_MCF_SYNCR
280 /* Set clockspeed according to board header file */ 281 /* Set clockspeed according to board header file */
281 mbar_writeLong(MCF_FMPLL_SYNCR, CONFIG_SYS_MCF_SYNCR); 282 mbar_writeLong(MCF_FMPLL_SYNCR, CONFIG_SYS_MCF_SYNCR);
282 #else 283 #else
283 /* Set clockspeed to 100MHz */ 284 /* Set clockspeed to 100MHz */
284 mbar_writeLong(MCF_FMPLL_SYNCR, 285 mbar_writeLong(MCF_FMPLL_SYNCR,
285 MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0)); 286 MCF_FMPLL_SYNCR_MFD(0) | MCF_FMPLL_SYNCR_RFD(0));
286 #endif 287 #endif
287 while (!(mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK)) ; 288 while (!(mbar_readByte(MCF_FMPLL_SYNSR) & MCF_FMPLL_SYNSR_LOCK)) ;
288 } 289 }
289 290
290 /* 291 /*
291 * initialize higher level parts of CPU like timers 292 * initialize higher level parts of CPU like timers
292 */ 293 */
293 int cpu_init_r(void) 294 int cpu_init_r(void)
294 { 295 {
295 return (0); 296 return (0);
296 } 297 }
297 298
298 void uart_port_conf(int port) 299 void uart_port_conf(int port)
299 { 300 {
300 u16 temp; 301 u16 temp;
301 302
302 /* Setup Ports: */ 303 /* Setup Ports: */
303 switch (port) { 304 switch (port) {
304 case 0: 305 case 0:
305 temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xFFF3; 306 temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xFFF3;
306 temp |= (MCF_GPIO_PAR_UART_U0TXD | MCF_GPIO_PAR_UART_U0RXD); 307 temp |= (MCF_GPIO_PAR_UART_U0TXD | MCF_GPIO_PAR_UART_U0RXD);
307 mbar_writeShort(MCF_GPIO_PAR_UART, temp); 308 mbar_writeShort(MCF_GPIO_PAR_UART, temp);
308 break; 309 break;
309 case 1: 310 case 1:
310 temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xF0FF; 311 temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xF0FF;
311 temp |= (MCF_GPIO_PAR_UART_U1RXD_UART1 | MCF_GPIO_PAR_UART_U1TXD_UART1); 312 temp |= (MCF_GPIO_PAR_UART_U1RXD_UART1 | MCF_GPIO_PAR_UART_U1TXD_UART1);
312 mbar_writeShort(MCF_GPIO_PAR_UART, temp); 313 mbar_writeShort(MCF_GPIO_PAR_UART, temp);
313 break; 314 break;
314 case 2: 315 case 2:
315 temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xCFFF; 316 temp = mbar_readShort(MCF_GPIO_PAR_UART) & 0xCFFF;
316 temp |= (0x3000); 317 temp |= (0x3000);
317 mbar_writeShort(MCF_GPIO_PAR_UART, temp); 318 mbar_writeShort(MCF_GPIO_PAR_UART, temp);
318 break; 319 break;
319 } 320 }
320 } 321 }
321 322
322 #if defined(CONFIG_CMD_NET) 323 #if defined(CONFIG_CMD_NET)
323 int fecpin_setclear(struct eth_device *dev, int setclear) 324 int fecpin_setclear(struct eth_device *dev, int setclear)
324 { 325 {
325 if (setclear) { 326 if (setclear) {
326 /* Enable Ethernet pins */ 327 /* Enable Ethernet pins */
327 mbar_writeByte(MCF_GPIO_PAR_FECI2C, 328 mbar_writeByte(MCF_GPIO_PAR_FECI2C,
328 (mbar_readByte(MCF_GPIO_PAR_FECI2C) | 0xF0)); 329 (mbar_readByte(MCF_GPIO_PAR_FECI2C) | 0xF0));
329 } else { 330 } else {
330 } 331 }
331 332
332 return 0; 333 return 0;
333 } 334 }
334 #endif /* CONFIG_CMD_NET */ 335 #endif /* CONFIG_CMD_NET */
335 #endif 336 #endif
336 337
337 #if defined(CONFIG_M5272) 338 #if defined(CONFIG_M5272)
338 /* 339 /*
339 * Breath some life into the CPU... 340 * Breath some life into the CPU...
340 * 341 *
341 * Set up the memory map, 342 * Set up the memory map,
342 * initialize a bunch of registers, 343 * initialize a bunch of registers,
343 * initialize the UPM's 344 * initialize the UPM's
344 */ 345 */
345 void cpu_init_f(void) 346 void cpu_init_f(void)
346 { 347 {
347 /* if we come from RAM we assume the CPU is 348 /* if we come from RAM we assume the CPU is
348 * already initialized. 349 * already initialized.
349 */ 350 */
350 #ifndef CONFIG_MONITOR_IS_IN_RAM 351 #ifndef CONFIG_MONITOR_IS_IN_RAM
351 volatile sysctrl_t *sysctrl = (sysctrl_t *) (CONFIG_SYS_MBAR); 352 sysctrl_t *sysctrl = (sysctrl_t *) (CONFIG_SYS_MBAR);
352 volatile gpio_t *gpio = (gpio_t *) (MMAP_GPIO); 353 gpio_t *gpio = (gpio_t *) (MMAP_GPIO);
353 volatile csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS); 354 csctrl_t *csctrl = (csctrl_t *) (MMAP_FBCS);
354 355
355 sysctrl->sc_scr = CONFIG_SYS_SCR; 356 out_be16(&sysctrl->sc_scr, CONFIG_SYS_SCR);
356 sysctrl->sc_spr = CONFIG_SYS_SPR; 357 out_be16(&sysctrl->sc_spr, CONFIG_SYS_SPR);
357 358
358 /* Setup Ports: */ 359 /* Setup Ports: */
359 gpio->gpio_pacnt = CONFIG_SYS_PACNT; 360 out_be32(&gpio->gpio_pacnt, CONFIG_SYS_PACNT);
360 gpio->gpio_paddr = CONFIG_SYS_PADDR; 361 out_be16(&gpio->gpio_paddr, CONFIG_SYS_PADDR);
361 gpio->gpio_padat = CONFIG_SYS_PADAT; 362 out_be16(&gpio->gpio_padat, CONFIG_SYS_PADAT);
362 gpio->gpio_pbcnt = CONFIG_SYS_PBCNT; 363 out_be32(&gpio->gpio_pbcnt, CONFIG_SYS_PBCNT);
363 gpio->gpio_pbddr = CONFIG_SYS_PBDDR; 364 out_be16(&gpio->gpio_pbddr, CONFIG_SYS_PBDDR);
364 gpio->gpio_pbdat = CONFIG_SYS_PBDAT; 365 out_be16(&gpio->gpio_pbdat, CONFIG_SYS_PBDAT);
365 gpio->gpio_pdcnt = CONFIG_SYS_PDCNT; 366 out_be32(&gpio->gpio_pdcnt, CONFIG_SYS_PDCNT);
366 367
367 /* Memory Controller: */ 368 /* Memory Controller: */
368 csctrl->cs_br0 = CONFIG_SYS_BR0_PRELIM; 369 out_be32(&csctrl->cs_br0, CONFIG_SYS_BR0_PRELIM);
369 csctrl->cs_or0 = CONFIG_SYS_OR0_PRELIM; 370 out_be32(&csctrl->cs_or0, CONFIG_SYS_OR0_PRELIM);
370 371
371 #if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM)) 372 #if (defined(CONFIG_SYS_OR1_PRELIM) && defined(CONFIG_SYS_BR1_PRELIM))
372 csctrl->cs_br1 = CONFIG_SYS_BR1_PRELIM; 373 out_be32(&csctrl->cs_br1, CONFIG_SYS_BR1_PRELIM);
373 csctrl->cs_or1 = CONFIG_SYS_OR1_PRELIM; 374 out_be32(&csctrl->cs_or1, CONFIG_SYS_OR1_PRELIM);
374 #endif 375 #endif
375 376
376 #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM) 377 #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
377 csctrl->cs_br2 = CONFIG_SYS_BR2_PRELIM; 378 out_be32(&csctrl->cs_br2, CONFIG_SYS_BR2_PRELIM);
378 csctrl->cs_or2 = CONFIG_SYS_OR2_PRELIM; 379 out_be32(&csctrl->cs_or2, CONFIG_SYS_OR2_PRELIM);
379 #endif 380 #endif
380 381
381 #if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM) 382 #if defined(CONFIG_SYS_OR3_PRELIM) && defined(CONFIG_SYS_BR3_PRELIM)
382 csctrl->cs_br3 = CONFIG_SYS_BR3_PRELIM; 383 out_be32(&csctrl->cs_br3, CONFIG_SYS_BR3_PRELIM);
383 csctrl->cs_or3 = CONFIG_SYS_OR3_PRELIM; 384 out_be32(&csctrl->cs_or3, CONFIG_SYS_OR3_PRELIM);
384 #endif 385 #endif
385 386
386 #if defined(CONFIG_SYS_OR4_PRELIM) && defined(CONFIG_SYS_BR4_PRELIM) 387 #if defined(CONFIG_SYS_OR4_PRELIM) && defined(CONFIG_SYS_BR4_PRELIM)
387 csctrl->cs_br4 = CONFIG_SYS_BR4_PRELIM; 388 out_be32(&csctrl->cs_br4, CONFIG_SYS_BR4_PRELIM);
388 csctrl->cs_or4 = CONFIG_SYS_OR4_PRELIM; 389 out_be32(&csctrl->cs_or4, CONFIG_SYS_OR4_PRELIM);
389 #endif 390 #endif
390 391
391 #if defined(CONFIG_SYS_OR5_PRELIM) && defined(CONFIG_SYS_BR5_PRELIM) 392 #if defined(CONFIG_SYS_OR5_PRELIM) && defined(CONFIG_SYS_BR5_PRELIM)
392 csctrl->cs_br5 = CONFIG_SYS_BR5_PRELIM; 393 out_be32(&csctrl->cs_br5, CONFIG_SYS_BR5_PRELIM);
393 csctrl->cs_or5 = CONFIG_SYS_OR5_PRELIM; 394 out_be32(&csctrl->cs_or5, CONFIG_SYS_OR5_PRELIM);
394 #endif 395 #endif
395 396
396 #if defined(CONFIG_SYS_OR6_PRELIM) && defined(CONFIG_SYS_BR6_PRELIM) 397 #if defined(CONFIG_SYS_OR6_PRELIM) && defined(CONFIG_SYS_BR6_PRELIM)
397 csctrl->cs_br6 = CONFIG_SYS_BR6_PRELIM; 398 out_be32(&csctrl->cs_br6, CONFIG_SYS_BR6_PRELIM);
398 csctrl->cs_or6 = CONFIG_SYS_OR6_PRELIM; 399 out_be32(&csctrl->cs_or6, CONFIG_SYS_OR6_PRELIM);
399 #endif 400 #endif
400 401
401 #if defined(CONFIG_SYS_OR7_PRELIM) && defined(CONFIG_SYS_BR7_PRELIM) 402 #if defined(CONFIG_SYS_OR7_PRELIM) && defined(CONFIG_SYS_BR7_PRELIM)
402 csctrl->cs_br7 = CONFIG_SYS_BR7_PRELIM; 403 out_be32(&csctrl->cs_br7, CONFIG_SYS_BR7_PRELIM);
403 csctrl->cs_or7 = CONFIG_SYS_OR7_PRELIM; 404 out_be32(&csctrl->cs_or7, CONFIG_SYS_OR7_PRELIM);
404 #endif 405 #endif
405 406
406 #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */ 407 #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
407 408
408 /* enable instruction cache now */ 409 /* enable instruction cache now */
409 icache_enable(); 410 icache_enable();
410 411
411 } 412 }
412 413
413 /* 414 /*
414 * initialize higher level parts of CPU like timers 415 * initialize higher level parts of CPU like timers
415 */ 416 */
416 int cpu_init_r(void) 417 int cpu_init_r(void)
417 { 418 {
418 return (0); 419 return (0);
419 } 420 }
420 421
421 void uart_port_conf(int port) 422 void uart_port_conf(int port)
422 { 423 {
423 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; 424 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
424 425
425 /* Setup Ports: */ 426 /* Setup Ports: */
426 switch (port) { 427 switch (port) {
427 case 0: 428 case 0:
428 gpio->gpio_pbcnt &= ~(GPIO_PBCNT_PB0MSK | GPIO_PBCNT_PB1MSK); 429 clrbits_be32(&gpio->gpio_pbcnt,
429 gpio->gpio_pbcnt |= (GPIO_PBCNT_URT0_TXD | GPIO_PBCNT_URT0_RXD); 430 GPIO_PBCNT_PB0MSK | GPIO_PBCNT_PB1MSK);
431 setbits_be32(&gpio->gpio_pbcnt,
432 GPIO_PBCNT_URT0_TXD | GPIO_PBCNT_URT0_RXD);
430 break; 433 break;
431 case 1: 434 case 1:
432 gpio->gpio_pdcnt &= ~(GPIO_PDCNT_PD1MSK | GPIO_PDCNT_PD4MSK); 435 clrbits_be32(&gpio->gpio_pdcnt,
433 gpio->gpio_pdcnt |= (GPIO_PDCNT_URT1_RXD | GPIO_PDCNT_URT1_TXD); 436 GPIO_PDCNT_PD1MSK | GPIO_PDCNT_PD4MSK);
437 setbits_be32(&gpio->gpio_pdcnt,
438 GPIO_PDCNT_URT1_RXD | GPIO_PDCNT_URT1_TXD);
434 break; 439 break;
435 } 440 }
436 } 441 }
437 442
438 #if defined(CONFIG_CMD_NET) 443 #if defined(CONFIG_CMD_NET)
439 int fecpin_setclear(struct eth_device *dev, int setclear) 444 int fecpin_setclear(struct eth_device *dev, int setclear)
440 { 445 {
441 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; 446 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
442 447
443 if (setclear) { 448 if (setclear) {
444 gpio->gpio_pbcnt |= GPIO_PBCNT_E_MDC | GPIO_PBCNT_E_RXER | 449 setbits_be32(&gpio->gpio_pbcnt,
445 GPIO_PBCNT_E_RXD1 | GPIO_PBCNT_E_RXD2 | 450 GPIO_PBCNT_E_MDC | GPIO_PBCNT_E_RXER |
446 GPIO_PBCNT_E_RXD3 | GPIO_PBCNT_E_TXD1 | 451 GPIO_PBCNT_E_RXD1 | GPIO_PBCNT_E_RXD2 |
447 GPIO_PBCNT_E_TXD2 | GPIO_PBCNT_E_TXD3; 452 GPIO_PBCNT_E_RXD3 | GPIO_PBCNT_E_TXD1 |
453 GPIO_PBCNT_E_TXD2 | GPIO_PBCNT_E_TXD3);
448 } else { 454 } else {
449 } 455 }
450 return 0; 456 return 0;
451 } 457 }
452 #endif /* CONFIG_CMD_NET */ 458 #endif /* CONFIG_CMD_NET */
453 #endif /* #if defined(CONFIG_M5272) */ 459 #endif /* #if defined(CONFIG_M5272) */
454 460
455 #if defined(CONFIG_M5275) 461 #if defined(CONFIG_M5275)
456 462
457 /* 463 /*
458 * Breathe some life into the CPU... 464 * Breathe some life into the CPU...
459 * 465 *
460 * Set up the memory map, 466 * Set up the memory map,
461 * initialize a bunch of registers, 467 * initialize a bunch of registers,
462 * initialize the UPM's 468 * initialize the UPM's
463 */ 469 */
464 void cpu_init_f(void) 470 void cpu_init_f(void)
465 { 471 {
466 /* 472 /*
467 * if we come from RAM we assume the CPU is 473 * if we come from RAM we assume the CPU is
468 * already initialized. 474 * already initialized.
469 */ 475 */
470 476
471 #ifndef CONFIG_MONITOR_IS_IN_RAM 477 #ifndef CONFIG_MONITOR_IS_IN_RAM
472 volatile wdog_t *wdog_reg = (wdog_t *) (MMAP_WDOG); 478 wdog_t *wdog_reg = (wdog_t *) (MMAP_WDOG);
473 volatile gpio_t *gpio_reg = (gpio_t *) (MMAP_GPIO); 479 gpio_t *gpio_reg = (gpio_t *) (MMAP_GPIO);
474 480
475 /* Kill watchdog so we can initialize the PLL */ 481 /* Kill watchdog so we can initialize the PLL */
476 wdog_reg->wcr = 0; 482 out_be16(&wdog_reg->wcr, 0);
477 483
478 /* FlexBus Chipselect */ 484 /* FlexBus Chipselect */
479 init_fbcs(); 485 init_fbcs();
480 #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */ 486 #endif /* #ifndef CONFIG_MONITOR_IS_IN_RAM */
481 487
482 #ifdef CONFIG_FSL_I2C 488 #ifdef CONFIG_FSL_I2C
483 CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR; 489 CONFIG_SYS_I2C_PINMUX_REG &= CONFIG_SYS_I2C_PINMUX_CLR;
484 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET; 490 CONFIG_SYS_I2C_PINMUX_REG |= CONFIG_SYS_I2C_PINMUX_SET;
485 #endif 491 #endif
486 492
487 /* enable instruction cache now */ 493 /* enable instruction cache now */
488 icache_enable(); 494 icache_enable();
489 } 495 }
490 496
491 /* 497 /*
492 * initialize higher level parts of CPU like timers 498 * initialize higher level parts of CPU like timers
493 */ 499 */
494 int cpu_init_r(void) 500 int cpu_init_r(void)
495 { 501 {
496 return (0); 502 return (0);
497 } 503 }
498 504
499 void uart_port_conf(int port) 505 void uart_port_conf(int port)
500 { 506 {
501 volatile gpio_t *gpio = (gpio_t *) MMAP_GPIO; 507 gpio_t *gpio = (gpio_t *) MMAP_GPIO;
502 508
503 /* Setup Ports: */ 509 /* Setup Ports: */
504 switch (port) { 510 switch (port) {
505 case 0: 511 case 0:
506 gpio->par_uart &= ~UART0_ENABLE_MASK; 512 clrbits_be16(&gpio->par_uart, UART0_ENABLE_MASK);
507 gpio->par_uart |= UART0_ENABLE_MASK; 513 setbits_be16(&gpio->par_uart, UART0_ENABLE_MASK);
508 break; 514 break;
509 case 1: 515 case 1:
510 gpio->par_uart &= ~UART1_ENABLE_MASK; 516 clrbits_be16(&gpio->par_uart, UART1_ENABLE_MASK);
511 gpio->par_uart |= UART1_ENABLE_MASK; 517 setbits_be16(&gpio->par_uart, UART1_ENABLE_MASK);
512 break; 518 break;
513 case 2: 519 case 2:
514 gpio->par_uart &= ~UART2_ENABLE_MASK; 520 clrbits_be16(&gpio->par_uart, UART2_ENABLE_MASK);
515 gpio->par_uart |= UART2_ENABLE_MASK; 521 setbits_be16(&gpio->par_uart, UART2_ENABLE_MASK);
516 break; 522 break;
517 } 523 }
518 } 524 }
519 525
520 #if defined(CONFIG_CMD_NET) 526 #if defined(CONFIG_CMD_NET)
521 int fecpin_setclear(struct eth_device *dev, int setclear) 527 int fecpin_setclear(struct eth_device *dev, int setclear)
522 { 528 {
523 struct fec_info_s *info = (struct fec_info_s *) dev->priv; 529 struct fec_info_s *info = (struct fec_info_s *) dev->priv;
524 volatile gpio_t *gpio = (gpio_t *)MMAP_GPIO; 530 gpio_t *gpio = (gpio_t *)MMAP_GPIO;
525 531
526 if (setclear) { 532 if (setclear) {
527 /* Enable Ethernet pins */ 533 /* Enable Ethernet pins */
528 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) { 534 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
529 gpio->par_feci2c |= 0x0F00; 535 setbits_be16(&gpio->par_feci2c, 0x0f00);
530 gpio->par_fec0hl |= 0xC0; 536 setbits_8(&gpio->par_fec0hl, 0xc0);
531 } else { 537 } else {
532 gpio->par_feci2c |= 0x00A0; 538 setbits_be16(&gpio->par_feci2c, 0x00a0);
533 gpio->par_fec1hl |= 0xC0; 539 setbits_8(&gpio->par_fec1hl, 0xc0);
534 } 540 }
535 } else { 541 } else {
536 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) { 542 if (info->iobase == CONFIG_SYS_FEC0_IOBASE) {
537 gpio->par_feci2c &= ~0x0F00; 543 clrbits_be16(&gpio->par_feci2c, 0x0f00);
538 gpio->par_fec0hl &= ~0xC0; 544 clrbits_8(&gpio->par_fec0hl, 0xc0);
539 } else { 545 } else {
540 gpio->par_feci2c &= ~0x00A0; 546 clrbits_be16(&gpio->par_feci2c, 0x00a0);
541 gpio->par_fec1hl &= ~0xC0; 547 clrbits_8(&gpio->par_fec1hl, 0xc0);
542 } 548 }
543 } 549 }
544 550
545 return 0; 551 return 0;
546 } 552 }
547 #endif /* CONFIG_CMD_NET */ 553 #endif /* CONFIG_CMD_NET */
548 #endif /* #if defined(CONFIG_M5275) */ 554 #endif /* #if defined(CONFIG_M5275) */
549 555
550 #if defined(CONFIG_M5282) 556 #if defined(CONFIG_M5282)
551 /* 557 /*
552 * Breath some life into the CPU... 558 * Breath some life into the CPU...
553 * 559 *
554 * Set up the memory map, 560 * Set up the memory map,
555 * initialize a bunch of registers, 561 * initialize a bunch of registers,
556 * initialize the UPM's 562 * initialize the UPM's
557 */ 563 */
558 void cpu_init_f(void) 564 void cpu_init_f(void)
559 { 565 {
560 #ifndef CONFIG_WATCHDOG 566 #ifndef CONFIG_WATCHDOG
561 /* disable watchdog if we aren't using it */ 567 /* disable watchdog if we aren't using it */
562 MCFWTM_WCR = 0; 568 MCFWTM_WCR = 0;
563 #endif 569 #endif
564 570
565 #ifndef CONFIG_MONITOR_IS_IN_RAM 571 #ifndef CONFIG_MONITOR_IS_IN_RAM
566 /* Set speed /PLL */ 572 /* Set speed /PLL */
567 MCFCLOCK_SYNCR = 573 MCFCLOCK_SYNCR =
568 MCFCLOCK_SYNCR_MFD(CONFIG_SYS_MFD) | 574 MCFCLOCK_SYNCR_MFD(CONFIG_SYS_MFD) |
569 MCFCLOCK_SYNCR_RFD(CONFIG_SYS_RFD); 575 MCFCLOCK_SYNCR_RFD(CONFIG_SYS_RFD);
570 while (!(MCFCLOCK_SYNSR & MCFCLOCK_SYNSR_LOCK)) ; 576 while (!(MCFCLOCK_SYNSR & MCFCLOCK_SYNSR_LOCK)) ;
571 577
572 MCFGPIO_PBCDPAR = 0xc0; 578 MCFGPIO_PBCDPAR = 0xc0;
573 579
574 /* Set up the GPIO ports */ 580 /* Set up the GPIO ports */
575 #ifdef CONFIG_SYS_PEPAR 581 #ifdef CONFIG_SYS_PEPAR
576 MCFGPIO_PEPAR = CONFIG_SYS_PEPAR; 582 MCFGPIO_PEPAR = CONFIG_SYS_PEPAR;
577 #endif 583 #endif
578 #ifdef CONFIG_SYS_PFPAR 584 #ifdef CONFIG_SYS_PFPAR
579 MCFGPIO_PFPAR = CONFIG_SYS_PFPAR; 585 MCFGPIO_PFPAR = CONFIG_SYS_PFPAR;
580 #endif 586 #endif
581 #ifdef CONFIG_SYS_PJPAR 587 #ifdef CONFIG_SYS_PJPAR
582 MCFGPIO_PJPAR = CONFIG_SYS_PJPAR; 588 MCFGPIO_PJPAR = CONFIG_SYS_PJPAR;
583 #endif 589 #endif
584 #ifdef CONFIG_SYS_PSDPAR 590 #ifdef CONFIG_SYS_PSDPAR
585 MCFGPIO_PSDPAR = CONFIG_SYS_PSDPAR; 591 MCFGPIO_PSDPAR = CONFIG_SYS_PSDPAR;
586 #endif 592 #endif
587 #ifdef CONFIG_SYS_PASPAR 593 #ifdef CONFIG_SYS_PASPAR
588 MCFGPIO_PASPAR = CONFIG_SYS_PASPAR; 594 MCFGPIO_PASPAR = CONFIG_SYS_PASPAR;
589 #endif 595 #endif
590 #ifdef CONFIG_SYS_PEHLPAR 596 #ifdef CONFIG_SYS_PEHLPAR
591 MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR; 597 MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
592 #endif 598 #endif
593 #ifdef CONFIG_SYS_PQSPAR 599 #ifdef CONFIG_SYS_PQSPAR
594 MCFGPIO_PQSPAR = CONFIG_SYS_PQSPAR; 600 MCFGPIO_PQSPAR = CONFIG_SYS_PQSPAR;
595 #endif 601 #endif
596 #ifdef CONFIG_SYS_PTCPAR 602 #ifdef CONFIG_SYS_PTCPAR
597 MCFGPIO_PTCPAR = CONFIG_SYS_PTCPAR; 603 MCFGPIO_PTCPAR = CONFIG_SYS_PTCPAR;
598 #endif 604 #endif
599 #if defined(CONFIG_SYS_PORTTC) 605 #if defined(CONFIG_SYS_PORTTC)
600 MCFGPIO_PORTTC = CONFIG_SYS_PORTTC; 606 MCFGPIO_PORTTC = CONFIG_SYS_PORTTC;
601 #endif 607 #endif
602 #if defined(CONFIG_SYS_DDRTC) 608 #if defined(CONFIG_SYS_DDRTC)
603 MCFGPIO_DDRTC = CONFIG_SYS_DDRTC; 609 MCFGPIO_DDRTC = CONFIG_SYS_DDRTC;
604 #endif 610 #endif
605 #ifdef CONFIG_SYS_PTDPAR 611 #ifdef CONFIG_SYS_PTDPAR
606 MCFGPIO_PTDPAR = CONFIG_SYS_PTDPAR; 612 MCFGPIO_PTDPAR = CONFIG_SYS_PTDPAR;
607 #endif 613 #endif
608 #ifdef CONFIG_SYS_PUAPAR 614 #ifdef CONFIG_SYS_PUAPAR
609 MCFGPIO_PUAPAR = CONFIG_SYS_PUAPAR; 615 MCFGPIO_PUAPAR = CONFIG_SYS_PUAPAR;
610 #endif 616 #endif
611 617
612 #if defined(CONFIG_SYS_DDRD) 618 #if defined(CONFIG_SYS_DDRD)
613 MCFGPIO_DDRD = CONFIG_SYS_DDRD; 619 MCFGPIO_DDRD = CONFIG_SYS_DDRD;
614 #endif 620 #endif
615 #ifdef CONFIG_SYS_DDRUA 621 #ifdef CONFIG_SYS_DDRUA
616 MCFGPIO_DDRUA = CONFIG_SYS_DDRUA; 622 MCFGPIO_DDRUA = CONFIG_SYS_DDRUA;
617 #endif 623 #endif
618 624
619 /* FlexBus Chipselect */ 625 /* FlexBus Chipselect */
620 init_fbcs(); 626 init_fbcs();
621 627
622 #endif /* CONFIG_MONITOR_IS_IN_RAM */ 628 #endif /* CONFIG_MONITOR_IS_IN_RAM */
623 629
624 /* defer enabling cache until boot (see do_go) */ 630 /* defer enabling cache until boot (see do_go) */
625 /* icache_enable(); */ 631 /* icache_enable(); */
626 } 632 }
627 633
628 /* 634 /*
629 * initialize higher level parts of CPU like timers 635 * initialize higher level parts of CPU like timers
630 */ 636 */
631 int cpu_init_r(void) 637 int cpu_init_r(void)
632 { 638 {
633 return (0); 639 return (0);
634 } 640 }
635 641
636 void uart_port_conf(int port) 642 void uart_port_conf(int port)
637 { 643 {
638 /* Setup Ports: */ 644 /* Setup Ports: */
639 switch (port) { 645 switch (port) {
640 case 0: 646 case 0:
641 MCFGPIO_PUAPAR &= 0xFc; 647 MCFGPIO_PUAPAR &= 0xFc;
642 MCFGPIO_PUAPAR |= 0x03; 648 MCFGPIO_PUAPAR |= 0x03;
643 break; 649 break;
644 case 1: 650 case 1:
645 MCFGPIO_PUAPAR &= 0xF3; 651 MCFGPIO_PUAPAR &= 0xF3;
646 MCFGPIO_PUAPAR |= 0x0C; 652 MCFGPIO_PUAPAR |= 0x0C;
647 break; 653 break;
648 case 2: 654 case 2:
649 MCFGPIO_PASPAR &= 0xFF0F; 655 MCFGPIO_PASPAR &= 0xFF0F;
650 MCFGPIO_PASPAR |= 0x00A0; 656 MCFGPIO_PASPAR |= 0x00A0;
651 break; 657 break;
652 } 658 }
653 } 659 }
654 660
655 #if defined(CONFIG_CMD_NET) 661 #if defined(CONFIG_CMD_NET)
656 int fecpin_setclear(struct eth_device *dev, int setclear) 662 int fecpin_setclear(struct eth_device *dev, int setclear)
657 { 663 {
658 if (setclear) { 664 if (setclear) {
659 MCFGPIO_PASPAR |= 0x0F00; 665 MCFGPIO_PASPAR |= 0x0F00;
660 MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR; 666 MCFGPIO_PEHLPAR = CONFIG_SYS_PEHLPAR;
661 } else { 667 } else {
662 MCFGPIO_PASPAR &= 0xF0FF; 668 MCFGPIO_PASPAR &= 0xF0FF;
663 MCFGPIO_PEHLPAR &= ~CONFIG_SYS_PEHLPAR; 669 MCFGPIO_PEHLPAR &= ~CONFIG_SYS_PEHLPAR;
664 } 670 }
665 return 0; 671 return 0;
666 } 672 }
667 #endif /* CONFIG_CMD_NET */ 673 #endif /* CONFIG_CMD_NET */
668 #endif 674 #endif
669 675
670 #if defined(CONFIG_M5249) 676 #if defined(CONFIG_M5249)
671 /* 677 /*
672 * Breath some life into the CPU... 678 * Breath some life into the CPU...
673 * 679 *
674 * Set up the memory map, 680 * Set up the memory map,
675 * initialize a bunch of registers, 681 * initialize a bunch of registers,
676 * initialize the UPM's 682 * initialize the UPM's
677 */ 683 */
678 void cpu_init_f(void) 684 void cpu_init_f(void)
679 { 685 {
680 /* 686 /*
681 * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins 687 * NOTE: by setting the GPIO_FUNCTION registers, we ensure that the UART pins
682 * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins 688 * (UART0: gpio 30,27, UART1: gpio 31, 28) will be used as UART pins
683 * which is their primary function. 689 * which is their primary function.
684 * ~Jeremy 690 * ~Jeremy
685 */ 691 */
686 mbar2_writeLong(MCFSIM_GPIO_FUNC, CONFIG_SYS_GPIO_FUNC); 692 mbar2_writeLong(MCFSIM_GPIO_FUNC, CONFIG_SYS_GPIO_FUNC);
687 mbar2_writeLong(MCFSIM_GPIO1_FUNC, CONFIG_SYS_GPIO1_FUNC); 693 mbar2_writeLong(MCFSIM_GPIO1_FUNC, CONFIG_SYS_GPIO1_FUNC);
688 mbar2_writeLong(MCFSIM_GPIO_EN, CONFIG_SYS_GPIO_EN); 694 mbar2_writeLong(MCFSIM_GPIO_EN, CONFIG_SYS_GPIO_EN);
689 mbar2_writeLong(MCFSIM_GPIO1_EN, CONFIG_SYS_GPIO1_EN); 695 mbar2_writeLong(MCFSIM_GPIO1_EN, CONFIG_SYS_GPIO1_EN);
690 mbar2_writeLong(MCFSIM_GPIO_OUT, CONFIG_SYS_GPIO_OUT); 696 mbar2_writeLong(MCFSIM_GPIO_OUT, CONFIG_SYS_GPIO_OUT);
691 mbar2_writeLong(MCFSIM_GPIO1_OUT, CONFIG_SYS_GPIO1_OUT); 697 mbar2_writeLong(MCFSIM_GPIO1_OUT, CONFIG_SYS_GPIO1_OUT);
692 698
693 /* 699 /*
694 * dBug Compliance: 700 * dBug Compliance:
695 * You can verify these values by using dBug's 'ird' 701 * You can verify these values by using dBug's 'ird'
696 * (Internal Register Display) command 702 * (Internal Register Display) command
697 * ~Jeremy 703 * ~Jeremy
698 * 704 *
699 */ 705 */
700 mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */ 706 mbar_writeByte(MCFSIM_MPARK, 0x30); /* 5249 Internal Core takes priority over DMA */
701 mbar_writeByte(MCFSIM_SYPCR, 0x00); 707 mbar_writeByte(MCFSIM_SYPCR, 0x00);
702 mbar_writeByte(MCFSIM_SWIVR, 0x0f); 708 mbar_writeByte(MCFSIM_SWIVR, 0x0f);
703 mbar_writeByte(MCFSIM_SWSR, 0x00); 709 mbar_writeByte(MCFSIM_SWSR, 0x00);
704 mbar_writeLong(MCFSIM_IMR, 0xfffffbff); 710 mbar_writeLong(MCFSIM_IMR, 0xfffffbff);
705 mbar_writeByte(MCFSIM_SWDICR, 0x00); 711 mbar_writeByte(MCFSIM_SWDICR, 0x00);
706 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00); 712 mbar_writeByte(MCFSIM_TIMER1ICR, 0x00);
707 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88); 713 mbar_writeByte(MCFSIM_TIMER2ICR, 0x88);
708 mbar_writeByte(MCFSIM_I2CICR, 0x00); 714 mbar_writeByte(MCFSIM_I2CICR, 0x00);
709 mbar_writeByte(MCFSIM_UART1ICR, 0x00); 715 mbar_writeByte(MCFSIM_UART1ICR, 0x00);
710 mbar_writeByte(MCFSIM_UART2ICR, 0x00); 716 mbar_writeByte(MCFSIM_UART2ICR, 0x00);
711 mbar_writeByte(MCFSIM_ICR6, 0x00); 717 mbar_writeByte(MCFSIM_ICR6, 0x00);
712 mbar_writeByte(MCFSIM_ICR7, 0x00); 718 mbar_writeByte(MCFSIM_ICR7, 0x00);
713 mbar_writeByte(MCFSIM_ICR8, 0x00); 719 mbar_writeByte(MCFSIM_ICR8, 0x00);
714 mbar_writeByte(MCFSIM_ICR9, 0x00); 720 mbar_writeByte(MCFSIM_ICR9, 0x00);
715 mbar_writeByte(MCFSIM_QSPIICR, 0x00); 721 mbar_writeByte(MCFSIM_QSPIICR, 0x00);
716 722
717 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080); 723 mbar2_writeLong(MCFSIM_GPIO_INT_EN, 0x00000080);
718 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */ 724 mbar2_writeByte(MCFSIM_INTBASE, 0x40); /* Base interrupts at 64 */
719 mbar2_writeByte(MCFSIM_SPURVEC, 0x00); 725 mbar2_writeByte(MCFSIM_SPURVEC, 0x00);
720 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */ 726 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); /* Enable a 1 cycle pre-drive cycle on CS1 */
721 727
722 /* Setup interrupt priorities for gpio7 */ 728 /* Setup interrupt priorities for gpio7 */
723 /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */ 729 /* mbar2_writeLong(MCFSIM_INTLEV5, 0x70000000); */
724 730
725 /* IDE Config registers */ 731 /* IDE Config registers */
726 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020); 732 mbar2_writeLong(MCFSIM_IDECONFIG1, 0x00000020);
727 mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000); 733 mbar2_writeLong(MCFSIM_IDECONFIG2, 0x00000000);
728 734
729 /* FlexBus Chipselect */ 735 /* FlexBus Chipselect */
730 init_fbcs(); 736 init_fbcs();
731 737
732 /* enable instruction cache now */ 738 /* enable instruction cache now */
733 icache_enable(); 739 icache_enable();
734 } 740 }
735 741
736 /* 742 /*
737 * initialize higher level parts of CPU like timers 743 * initialize higher level parts of CPU like timers
738 */ 744 */
739 int cpu_init_r(void) 745 int cpu_init_r(void)
740 { 746 {
741 return (0); 747 return (0);
742 } 748 }
743 749
744 void uart_port_conf(int port) 750 void uart_port_conf(int port)
745 { 751 {
746 } 752 }
747 #endif /* #if defined(CONFIG_M5249) */ 753 #endif /* #if defined(CONFIG_M5249) */
748 754
arch/m68k/cpu/mcf52x2/interrupts.c
1 /* 1 /*
2 * (C) Copyright 2000-2004 2 * (C) Copyright 2000-2004
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. 5 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
6 * TsiChung Liew (Tsi-Chung.Liew@freescale.com) 6 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
7 * 7 *
8 * See file CREDITS for list of people who contributed to this 8 * See file CREDITS for list of people who contributed to this
9 * project. 9 * project.
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of 13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version. 14 * the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA 24 * MA 02111-1307 USA
25 */ 25 */
26 26
27 #include <common.h> 27 #include <common.h>
28 #include <watchdog.h> 28 #include <watchdog.h>
29 #include <asm/processor.h> 29 #include <asm/processor.h>
30 #include <asm/immap.h> 30 #include <asm/immap.h>
31 #include <asm/io.h>
31 32
32 #ifdef CONFIG_M5272 33 #ifdef CONFIG_M5272
33 int interrupt_init(void) 34 int interrupt_init(void)
34 { 35 {
35 volatile intctrl_t *intp = (intctrl_t *) (MMAP_INTC); 36 intctrl_t *intp = (intctrl_t *) (MMAP_INTC);
36 37
37 /* disable all external interrupts */ 38 /* disable all external interrupts */
38 intp->int_icr1 = 0x88888888; 39 out_be32(&intp->int_icr1, 0x88888888);
39 intp->int_icr2 = 0x88888888; 40 out_be32(&intp->int_icr2, 0x88888888);
40 intp->int_icr3 = 0x88888888; 41 out_be32(&intp->int_icr3, 0x88888888);
41 intp->int_icr4 = 0x88888888; 42 out_be32(&intp->int_icr4, 0x88888888);
42 intp->int_pitr = 0x00000000; 43 out_be32(&intp->int_pitr, 0x00000000);
44
43 /* initialize vector register */ 45 /* initialize vector register */
44 intp->int_pivr = 0x40; 46 out_8(&intp->int_pivr, 0x40);
45 47
46 enable_interrupts(); 48 enable_interrupts();
47 49
48 return 0; 50 return 0;
49 } 51 }
50 52
51 #if defined(CONFIG_MCFTMR) 53 #if defined(CONFIG_MCFTMR)
52 void dtimer_intr_setup(void) 54 void dtimer_intr_setup(void)
53 { 55 {
54 volatile intctrl_t *intp = (intctrl_t *) (CONFIG_SYS_INTR_BASE); 56 intctrl_t *intp = (intctrl_t *) (CONFIG_SYS_INTR_BASE);
55 57
56 intp->int_icr1 &= ~INT_ICR1_TMR3MASK; 58 clrbits_be32(&intp->int_icr1, INT_ICR1_TMR3MASK);
57 intp->int_icr1 |= CONFIG_SYS_TMRINTR_PRI; 59 setbits_be32(&intp->int_icr1, CONFIG_SYS_TMRINTR_PRI);
58 } 60 }
59 #endif /* CONFIG_MCFTMR */ 61 #endif /* CONFIG_MCFTMR */
60 #endif /* CONFIG_M5272 */ 62 #endif /* CONFIG_M5272 */
61 63
62 #if defined(CONFIG_M5208) || defined(CONFIG_M5282) || \ 64 #if defined(CONFIG_M5208) || defined(CONFIG_M5282) || \
63 defined(CONFIG_M5271) || defined(CONFIG_M5275) 65 defined(CONFIG_M5271) || defined(CONFIG_M5275)
64 int interrupt_init(void) 66 int interrupt_init(void)
65 { 67 {
66 volatile int0_t *intp = (int0_t *) (CONFIG_SYS_INTR_BASE); 68 int0_t *intp = (int0_t *) (CONFIG_SYS_INTR_BASE);
67 69
68 /* Make sure all interrupts are disabled */ 70 /* Make sure all interrupts are disabled */
69 #if defined(CONFIG_M5208) 71 #if defined(CONFIG_M5208)
70 intp->imrl0 = 0xFFFFFFFF; 72 out_be32(&intp->imrl0, 0xffffffff);
71 intp->imrh0 = 0xFFFFFFFF; 73 out_be32(&intp->imrh0, 0xffffffff);
72 #else 74 #else
73 intp->imrl0 |= 0x1; 75 setbits_be32(&intp->imrl0, 0x1);
74 #endif 76 #endif
75 77
76 enable_interrupts(); 78 enable_interrupts();
77 return 0; 79 return 0;
78 } 80 }
79 81
80 #if defined(CONFIG_MCFTMR) 82 #if defined(CONFIG_MCFTMR)
81 void dtimer_intr_setup(void) 83 void dtimer_intr_setup(void)
82 { 84 {
83 volatile int0_t *intp = (int0_t *) (CONFIG_SYS_INTR_BASE); 85 int0_t *intp = (int0_t *) (CONFIG_SYS_INTR_BASE);
84 86
85 intp->icr0[CONFIG_SYS_TMRINTR_NO] = CONFIG_SYS_TMRINTR_PRI; 87 out_8(&intp->icr0[CONFIG_SYS_TMRINTR_NO], CONFIG_SYS_TMRINTR_PRI);
86 intp->imrl0 &= 0xFFFFFFFE; 88 clrbits_be32(&intp->imrl0, 0x00000001);
87 intp->imrl0 &= ~CONFIG_SYS_TMRINTR_MASK; 89 clrbits_be32(&intp->imrl0, CONFIG_SYS_TMRINTR_MASK);
88 } 90 }
89 #endif /* CONFIG_MCFTMR */ 91 #endif /* CONFIG_MCFTMR */
90 #endif /* CONFIG_M5282 | CONFIG_M5271 | CONFIG_M5275 */ 92 #endif /* CONFIG_M5282 | CONFIG_M5271 | CONFIG_M5275 */
91 93
92 #if defined(CONFIG_M5249) || defined(CONFIG_M5253) 94 #if defined(CONFIG_M5249) || defined(CONFIG_M5253)
93 int interrupt_init(void) 95 int interrupt_init(void)
94 { 96 {
95 enable_interrupts(); 97 enable_interrupts();
96 98
97 return 0; 99 return 0;
98 } 100 }
99 101
100 #if defined(CONFIG_MCFTMR) 102 #if defined(CONFIG_MCFTMR)
101 void dtimer_intr_setup(void) 103 void dtimer_intr_setup(void)
102 { 104 {
103 mbar_writeLong(MCFSIM_IMR, mbar_readLong(MCFSIM_IMR) & ~0x00000400); 105 mbar_writeLong(MCFSIM_IMR, mbar_readLong(MCFSIM_IMR) & ~0x00000400);
104 mbar_writeByte(MCFSIM_TIMER2ICR, CONFIG_SYS_TMRINTR_PRI); 106 mbar_writeByte(MCFSIM_TIMER2ICR, CONFIG_SYS_TMRINTR_PRI);
105 } 107 }
106 #endif /* CONFIG_MCFTMR */ 108 #endif /* CONFIG_MCFTMR */
107 #endif /* CONFIG_M5249 || CONFIG_M5253 */ 109 #endif /* CONFIG_M5249 || CONFIG_M5253 */
108 110
arch/m68k/cpu/mcf52x2/speed.c
1 /* 1 /*
2 * (C) Copyright 2003 2 * (C) Copyright 2003
3 * Josef Baumgartner <josef.baumgartner@telex.de> 3 * Josef Baumgartner <josef.baumgartner@telex.de>
4 * 4 *
5 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. 5 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
6 * Hayden Fraser (Hayden.Fraser@freescale.com) 6 * Hayden Fraser (Hayden.Fraser@freescale.com)
7 * 7 *
8 * See file CREDITS for list of people who contributed to this 8 * See file CREDITS for list of people who contributed to this
9 * project. 9 * project.
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of 13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version. 14 * the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA 24 * MA 02111-1307 USA
25 */ 25 */
26 26
27 #include <common.h> 27 #include <common.h>
28 #include <asm/processor.h> 28 #include <asm/processor.h>
29 #include <asm/immap.h> 29 #include <asm/immap.h>
30 #include <asm/io.h>
30 31
31 DECLARE_GLOBAL_DATA_PTR; 32 DECLARE_GLOBAL_DATA_PTR;
32 33
33 /* get_clocks() fills in gd->cpu_clock and gd->bus_clk */ 34 /* get_clocks() fills in gd->cpu_clock and gd->bus_clk */
34 int get_clocks (void) 35 int get_clocks (void)
35 { 36 {
36 #if defined(CONFIG_M5208) 37 #if defined(CONFIG_M5208)
37 volatile pll_t *pll = (pll_t *) MMAP_PLL; 38 pll_t *pll = (pll_t *) MMAP_PLL;
38 39
39 pll->odr = CONFIG_SYS_PLL_ODR; 40 out_8(&pll->odr, CONFIG_SYS_PLL_ODR);
40 pll->fdr = CONFIG_SYS_PLL_FDR; 41 out_8(&pll->fdr, CONFIG_SYS_PLL_FDR);
41 #endif 42 #endif
42 43
43 #if defined(CONFIG_M5249) || defined(CONFIG_M5253) 44 #if defined(CONFIG_M5249) || defined(CONFIG_M5253)
44 volatile unsigned long cpll = mbar2_readLong(MCFSIM_PLLCR); 45 volatile unsigned long cpll = mbar2_readLong(MCFSIM_PLLCR);
45 unsigned long pllcr; 46 unsigned long pllcr;
46 47
47 #ifndef CONFIG_SYS_PLL_BYPASS 48 #ifndef CONFIG_SYS_PLL_BYPASS
48 49
49 #ifdef CONFIG_M5249 50 #ifdef CONFIG_M5249
50 /* Setup the PLL to run at the specified speed */ 51 /* Setup the PLL to run at the specified speed */
51 #ifdef CONFIG_SYS_FAST_CLK 52 #ifdef CONFIG_SYS_FAST_CLK
52 pllcr = 0x925a3100; /* ~140MHz clock (PLL bypass = 0) */ 53 pllcr = 0x925a3100; /* ~140MHz clock (PLL bypass = 0) */
53 #else 54 #else
54 pllcr = 0x135a4140; /* ~72MHz clock (PLL bypass = 0) */ 55 pllcr = 0x135a4140; /* ~72MHz clock (PLL bypass = 0) */
55 #endif 56 #endif
56 #endif /* CONFIG_M5249 */ 57 #endif /* CONFIG_M5249 */
57 58
58 #ifdef CONFIG_M5253 59 #ifdef CONFIG_M5253
59 pllcr = CONFIG_SYS_PLLCR; 60 pllcr = CONFIG_SYS_PLLCR;
60 #endif /* CONFIG_M5253 */ 61 #endif /* CONFIG_M5253 */
61 62
62 cpll = cpll & 0xfffffffe; /* Set PLL bypass mode = 0 (PSTCLK = crystal) */ 63 cpll = cpll & 0xfffffffe; /* Set PLL bypass mode = 0 (PSTCLK = crystal) */
63 mbar2_writeLong(MCFSIM_PLLCR, cpll); /* Set the PLL to bypass mode (PSTCLK = crystal) */ 64 mbar2_writeLong(MCFSIM_PLLCR, cpll); /* Set the PLL to bypass mode (PSTCLK = crystal) */
64 mbar2_writeLong(MCFSIM_PLLCR, pllcr); /* set the clock speed */ 65 mbar2_writeLong(MCFSIM_PLLCR, pllcr); /* set the clock speed */
65 pllcr ^= 0x00000001; /* Set pll bypass to 1 */ 66 pllcr ^= 0x00000001; /* Set pll bypass to 1 */
66 mbar2_writeLong(MCFSIM_PLLCR, pllcr); /* Start locking (pll bypass = 1) */ 67 mbar2_writeLong(MCFSIM_PLLCR, pllcr); /* Start locking (pll bypass = 1) */
67 udelay(0x20); /* Wait for a lock ... */ 68 udelay(0x20); /* Wait for a lock ... */
68 #endif /* #ifndef CONFIG_SYS_PLL_BYPASS */ 69 #endif /* #ifndef CONFIG_SYS_PLL_BYPASS */
69 70
70 #endif /* CONFIG_M5249 || CONFIG_M5253 */ 71 #endif /* CONFIG_M5249 || CONFIG_M5253 */
71 72
72 #if defined(CONFIG_M5275) 73 #if defined(CONFIG_M5275)
73 volatile pll_t *pll = (volatile pll_t *)(MMAP_PLL); 74 pll_t *pll = (pll_t *)(MMAP_PLL);
74 75
75 /* Setup PLL */ 76 /* Setup PLL */
76 pll->syncr = 0x01080000; 77 out_be32(&pll->syncr, 0x01080000);
77 while (!(pll->synsr & FMPLL_SYNSR_LOCK)) 78 while (!(in_be32(&pll->synsr) & FMPLL_SYNSR_LOCK))
78 ; 79 ;
79 pll->syncr = 0x01000000; 80 out_be32(&pll->syncr, 0x01000000);
80 while (!(pll->synsr & FMPLL_SYNSR_LOCK)) 81 while (!(in_be32(&pll->synsr) & FMPLL_SYNSR_LOCK))
81 ; 82 ;
82 #endif 83 #endif
83 84
84 gd->cpu_clk = CONFIG_SYS_CLK; 85 gd->cpu_clk = CONFIG_SYS_CLK;
85 #if defined(CONFIG_M5208) || defined(CONFIG_M5249) || defined(CONFIG_M5253) || \ 86 #if defined(CONFIG_M5208) || defined(CONFIG_M5249) || defined(CONFIG_M5253) || \
86 defined(CONFIG_M5271) || defined(CONFIG_M5275) 87 defined(CONFIG_M5271) || defined(CONFIG_M5275)
87 gd->bus_clk = gd->cpu_clk / 2; 88 gd->bus_clk = gd->cpu_clk / 2;
88 #else 89 #else
89 gd->bus_clk = gd->cpu_clk; 90 gd->bus_clk = gd->cpu_clk;
90 #endif 91 #endif
91 92
92 #ifdef CONFIG_FSL_I2C 93 #ifdef CONFIG_FSL_I2C
93 gd->i2c1_clk = gd->bus_clk; 94 gd->i2c1_clk = gd->bus_clk;
94 #ifdef CONFIG_SYS_I2C2_OFFSET 95 #ifdef CONFIG_SYS_I2C2_OFFSET
95 gd->i2c2_clk = gd->bus_clk; 96 gd->i2c2_clk = gd->bus_clk;
96 #endif 97 #endif
97 #endif 98 #endif
98 99
99 return (0); 100 return (0);
100 } 101 }
101 102
board/freescale/m5208evbe/m5208evbe.c
1 /* 1 /*
2 * (C) Copyright 2000-2003 2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * Copyright (C) 2004-2008 Freescale Semiconductor, Inc. 5 * Copyright (C) 2004-2008, 2012 Freescale Semiconductor, Inc.
6 * TsiChung Liew (Tsi-Chung.Liew@freescale.com) 6 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
7 * 7 *
8 * See file CREDITS for list of people who contributed to this 8 * See file CREDITS for list of people who contributed to this
9 * project. 9 * project.
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of 13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version. 14 * the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA 24 * MA 02111-1307 USA
25 */ 25 */
26 26
27 #include <config.h> 27 #include <config.h>
28 #include <common.h> 28 #include <common.h>
29 #include <asm/immap.h> 29 #include <asm/immap.h>
30 #include <asm/io.h>
30 31
31 DECLARE_GLOBAL_DATA_PTR; 32 DECLARE_GLOBAL_DATA_PTR;
32 33
33 int checkboard(void) 34 int checkboard(void)
34 { 35 {
35 puts("Board: "); 36 puts("Board: ");
36 puts("Freescale M5208EVBe\n"); 37 puts("Freescale M5208EVBe\n");
37 return 0; 38 return 0;
38 }; 39 };
39 40
40 phys_size_t initdram(int board_type) 41 phys_size_t initdram(int board_type)
41 { 42 {
42 volatile sdram_t *sdram = (volatile sdram_t *)(MMAP_SDRAM); 43 sdram_t *sdram = (sdram_t *)(MMAP_SDRAM);
43 u32 dramsize, i; 44 u32 dramsize, i;
44 45
45 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000; 46 dramsize = CONFIG_SYS_SDRAM_SIZE * 0x100000;
46 47
47 for (i = 0x13; i < 0x20; i++) { 48 for (i = 0x13; i < 0x20; i++) {
48 if (dramsize == (1 << i)) 49 if (dramsize == (1 << i))
49 break; 50 break;
50 } 51 }
51 i--; 52 i--;
52 53
53 sdram->cs0 = (CONFIG_SYS_SDRAM_BASE | i); 54 out_be32(&sdram->cs0, CONFIG_SYS_SDRAM_BASE | i);
54 #ifdef CONFIG_SYS_SDRAM_BASE1 55 #ifdef CONFIG_SYS_SDRAM_BASE1
55 sdram->cs1 = (CONFIG_SYS_SDRAM_BASE | i); 56 out_be32(&sdram->cs1, CONFIG_SYS_SDRAM_BASE | i);
56 #endif 57 #endif
57 sdram->cfg1 = CONFIG_SYS_SDRAM_CFG1; 58 out_be32(&sdram->cfg1, CONFIG_SYS_SDRAM_CFG1);
58 sdram->cfg2 = CONFIG_SYS_SDRAM_CFG2; 59 out_be32(&sdram->cfg2, CONFIG_SYS_SDRAM_CFG2);
59 60
60 udelay(500); 61 udelay(500);
61 62
62 /* Issue PALL */ 63 /* Issue PALL */
63 sdram->ctrl = (CONFIG_SYS_SDRAM_CTRL | 2); 64 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
64 asm("nop"); 65 asm("nop");
65 66
66 /* Perform two refresh cycles */ 67 /* Perform two refresh cycles */
67 sdram->ctrl = CONFIG_SYS_SDRAM_CTRL | 4; 68 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
68 sdram->ctrl = CONFIG_SYS_SDRAM_CTRL | 4; 69 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 4);
69 asm("nop"); 70 asm("nop");
70 71
71 /* Issue LEMR */ 72 /* Issue LEMR */
72 sdram->mode = CONFIG_SYS_SDRAM_MODE; 73 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_MODE);
73 asm("nop"); 74 asm("nop");
74 sdram->mode = CONFIG_SYS_SDRAM_EMOD; 75 out_be32(&sdram->mode, CONFIG_SYS_SDRAM_EMOD);
75 asm("nop"); 76 asm("nop");
76 77
77 sdram->ctrl = (CONFIG_SYS_SDRAM_CTRL | 2); 78 out_be32(&sdram->ctrl, CONFIG_SYS_SDRAM_CTRL | 2);
78 asm("nop"); 79 asm("nop");
79 80
80 sdram->ctrl = (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00; 81 out_be32(&sdram->ctrl,
82 (CONFIG_SYS_SDRAM_CTRL & ~0x80000000) | 0x10000F00);
81 asm("nop"); 83 asm("nop");
82 84
83 udelay(100); 85 udelay(100);
84 86
85 return dramsize; 87 return dramsize;
86 }; 88 };
87 89
88 int testdram(void) 90 int testdram(void)
89 { 91 {
90 /* TODO: XXX XXX XXX */ 92 /* TODO: XXX XXX XXX */
91 printf("DRAM test not implemented!\n"); 93 printf("DRAM test not implemented!\n");
92 94
93 return (0); 95 return (0);
94 } 96 }
95 97
board/freescale/m5253demo/m5253demo.c
1 /* 1 /*
2 * (C) Copyright 2000-2003 2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. 5 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
6 * Hayden Fraser (Hayden.Fraser@freescale.com) 6 * Hayden Fraser (Hayden.Fraser@freescale.com)
7 * 7 *
8 * See file CREDITS for list of people who contributed to this 8 * See file CREDITS for list of people who contributed to this
9 * project. 9 * project.
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of 13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version. 14 * the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA 24 * MA 02111-1307 USA
25 */ 25 */
26 26
27 #include <common.h> 27 #include <common.h>
28 #include <asm/immap.h> 28 #include <asm/immap.h>
29 #include <netdev.h> 29 #include <netdev.h>
30 #include <asm/io.h> 30 #include <asm/io.h>
31 31
32 int checkboard(void) 32 int checkboard(void)
33 { 33 {
34 puts("Board: "); 34 puts("Board: ");
35 puts("Freescale MCF5253 DEMO\n"); 35 puts("Freescale MCF5253 DEMO\n");
36 return 0; 36 return 0;
37 }; 37 };
38 38
39 phys_size_t initdram(int board_type) 39 phys_size_t initdram(int board_type)
40 { 40 {
41 u32 dramsize = 0; 41 u32 dramsize = 0;
42 42
43 /* 43 /*
44 * Check to see if the SDRAM has already been initialized 44 * Check to see if the SDRAM has already been initialized
45 * by a run control tool 45 * by a run control tool
46 */ 46 */
47 if (!(mbar_readLong(MCFSIM_DCR) & 0x8000)) { 47 if (!(mbar_readLong(MCFSIM_DCR) & 0x8000)) {
48 u32 RC, temp; 48 u32 RC, temp;
49 49
50 RC = (CONFIG_SYS_CLK / 1000000) >> 1; 50 RC = (CONFIG_SYS_CLK / 1000000) >> 1;
51 RC = (RC * 15) >> 4; 51 RC = (RC * 15) >> 4;
52 52
53 /* Initialize DRAM Control Register: DCR */ 53 /* Initialize DRAM Control Register: DCR */
54 mbar_writeShort(MCFSIM_DCR, (0x8400 | RC)); 54 mbar_writeShort(MCFSIM_DCR, (0x8400 | RC));
55 __asm__("nop"); 55 __asm__("nop");
56 56
57 mbar_writeLong(MCFSIM_DACR0, 0x00003224); 57 mbar_writeLong(MCFSIM_DACR0, 0x00003224);
58 __asm__("nop"); 58 __asm__("nop");
59 59
60 /* Initialize DMR0 */ 60 /* Initialize DMR0 */
61 dramsize = (CONFIG_SYS_SDRAM_SIZE << 20); 61 dramsize = (CONFIG_SYS_SDRAM_SIZE << 20);
62 temp = (dramsize - 1) & 0xFFFC0000; 62 temp = (dramsize - 1) & 0xFFFC0000;
63 mbar_writeLong(MCFSIM_DMR0, temp | 1); 63 mbar_writeLong(MCFSIM_DMR0, temp | 1);
64 __asm__("nop"); 64 __asm__("nop");
65 65
66 mbar_writeLong(MCFSIM_DACR0, 0x0000322c); 66 mbar_writeLong(MCFSIM_DACR0, 0x0000322c);
67 mb(); 67 mb();
68 __asm__("nop"); 68 __asm__("nop");
69 69
70 /* Write to this block to initiate precharge */ 70 /* Write to this block to initiate precharge */
71 *(u32 *) (CONFIG_SYS_SDRAM_BASE) = 0xa5a5a5a5; 71 *(u32 *) (CONFIG_SYS_SDRAM_BASE) = 0xa5a5a5a5;
72 mb(); 72 mb();
73 __asm__("nop"); 73 __asm__("nop");
74 74
75 /* Set RE bit in DACR */ 75 /* Set RE bit in DACR */
76 mbar_writeLong(MCFSIM_DACR0, 76 mbar_writeLong(MCFSIM_DACR0,
77 mbar_readLong(MCFSIM_DACR0) | 0x8000); 77 mbar_readLong(MCFSIM_DACR0) | 0x8000);
78 __asm__("nop"); 78 __asm__("nop");
79 79
80 /* Wait for at least 8 auto refresh cycles to occur */ 80 /* Wait for at least 8 auto refresh cycles to occur */
81 udelay(500); 81 udelay(500);
82 82
83 /* Finish the configuration by issuing the MRS */ 83 /* Finish the configuration by issuing the MRS */
84 mbar_writeLong(MCFSIM_DACR0, 84 mbar_writeLong(MCFSIM_DACR0,
85 mbar_readLong(MCFSIM_DACR0) | 0x0040); 85 mbar_readLong(MCFSIM_DACR0) | 0x0040);
86 __asm__("nop"); 86 __asm__("nop");
87 87
88 *(u32 *) (CONFIG_SYS_SDRAM_BASE + 0x800) = 0xa5a5a5a5; 88 *(u32 *) (CONFIG_SYS_SDRAM_BASE + 0x800) = 0xa5a5a5a5;
89 mb(); 89 mb();
90 } 90 }
91 91
92 return dramsize; 92 return dramsize;
93 } 93 }
94 94
95 int testdram(void) 95 int testdram(void)
96 { 96 {
97 /* TODO: XXX XXX XXX */ 97 /* TODO: XXX XXX XXX */
98 printf("DRAM test not implemented!\n"); 98 printf("DRAM test not implemented!\n");
99 99
100 return (0); 100 return (0);
101 } 101 }
102 102
103 #ifdef CONFIG_CMD_IDE 103 #ifdef CONFIG_CMD_IDE
104 #include <ata.h> 104 #include <ata.h>
105 int ide_preinit(void) 105 int ide_preinit(void)
106 { 106 {
107 return (0); 107 return (0);
108 } 108 }
109 109
110 void ide_set_reset(int idereset) 110 void ide_set_reset(int idereset)
111 { 111 {
112 volatile atac_t *ata = (atac_t *) CONFIG_SYS_ATA_BASE_ADDR; 112 atac_t *ata = (atac_t *) CONFIG_SYS_ATA_BASE_ADDR;
113 long period; 113 long period;
114 /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */ 114 /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */
115 int piotms[5][9] = { {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */ 115 int piotms[5][9] = { {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */
116 {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */ 116 {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */
117 {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */ 117 {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */
118 {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */ 118 {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */
119 {25, 70, 20, 10, 20, 5, 10, 0, 35} /* PIO 4 */ 119 {25, 70, 20, 10, 20, 5, 10, 0, 35} /* PIO 4 */
120 }; 120 };
121 121
122 if (idereset) { 122 if (idereset) {
123 ata->cr = 0; /* control reset */ 123 /* control reset */
124 out_8(&ata->cr, 0);
124 udelay(100); 125 udelay(100);
125 } else { 126 } else {
126 mbar2_writeLong(CIM_MISCCR, CIM_MISCCR_CPUEND); 127 mbar2_writeLong(CIM_MISCCR, CIM_MISCCR_CPUEND);
127 128
128 #define CALC_TIMING(t) (t + period - 1) / period 129 #define CALC_TIMING(t) (t + period - 1) / period
129 period = 1000000000 / (CONFIG_SYS_CLK / 2); /* period in ns */ 130 period = 1000000000 / (CONFIG_SYS_CLK / 2); /* period in ns */
130 131
131 /*ata->ton = CALC_TIMING (180); */ 132 /*ata->ton = CALC_TIMING (180); */
132 ata->t1 = CALC_TIMING(piotms[2][0]); 133 out_8(&ata->t1, CALC_TIMING(piotms[2][0]));
133 ata->t2w = CALC_TIMING(piotms[2][1]); 134 out_8(&ata->t2w, CALC_TIMING(piotms[2][1]));
134 ata->t2r = CALC_TIMING(piotms[2][1]); 135 out_8(&ata->t2r, CALC_TIMING(piotms[2][1]));
135 ata->ta = CALC_TIMING(piotms[2][8]); 136 out_8(&ata->ta, CALC_TIMING(piotms[2][8]));
136 ata->trd = CALC_TIMING(piotms[2][7]); 137 out_8(&ata->trd, CALC_TIMING(piotms[2][7]));
137 ata->t4 = CALC_TIMING(piotms[2][3]); 138 out_8(&ata->t4, CALC_TIMING(piotms[2][3]));
138 ata->t9 = CALC_TIMING(piotms[2][6]); 139 out_8(&ata->t9, CALC_TIMING(piotms[2][6]));
139 140
140 ata->cr = 0x40; /* IORDY enable */ 141 /* IORDY enable */
142 out_8(&ata->cr, 0x40);
141 udelay(2000); 143 udelay(2000);
142 ata->cr |= 0x01; /* IORDY enable */ 144 /* IORDY enable */
145 setbits_8(&ata->cr, 0x01);
143 } 146 }
144 } 147 }
145 #endif /* CONFIG_CMD_IDE */ 148 #endif /* CONFIG_CMD_IDE */
146 149
147 150
148 #ifdef CONFIG_DRIVER_DM9000 151 #ifdef CONFIG_DRIVER_DM9000
149 int board_eth_init(bd_t *bis) 152 int board_eth_init(bd_t *bis)
150 { 153 {
151 return dm9000_initialize(bis); 154 return dm9000_initialize(bis);
152 } 155 }
153 #endif 156 #endif
154 157
board/freescale/m5253evbe/m5253evbe.c
1 /* 1 /*
2 * (C) Copyright 2000-2003 2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * Copyright (C) 2004-2007 Freescale Semiconductor, Inc. 5 * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
6 * Hayden Fraser (Hayden.Fraser@freescale.com) 6 * Hayden Fraser (Hayden.Fraser@freescale.com)
7 * 7 *
8 * See file CREDITS for list of people who contributed to this 8 * See file CREDITS for list of people who contributed to this
9 * project. 9 * project.
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of 13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version. 14 * the License, or (at your option) any later version.
15 * 15 *
16 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details. 19 * GNU General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU General Public License 21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software 22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA 24 * MA 02111-1307 USA
25 */ 25 */
26 26
27 #include <common.h> 27 #include <common.h>
28 #include <asm/immap.h> 28 #include <asm/immap.h>
29 #include <asm/io.h>
29 30
30 int checkboard(void) 31 int checkboard(void)
31 { 32 {
32 puts("Board: "); 33 puts("Board: ");
33 puts("Freescale MCF5253 EVBE\n"); 34 puts("Freescale MCF5253 EVBE\n");
34 return 0; 35 return 0;
35 }; 36 };
36 37
37 phys_size_t initdram(int board_type) 38 phys_size_t initdram(int board_type)
38 { 39 {
39 /* 40 /*
40 * Check to see if the SDRAM has already been initialized 41 * Check to see if the SDRAM has already been initialized
41 * by a run control tool 42 * by a run control tool
42 */ 43 */
43 if (!(mbar_readLong(MCFSIM_DCR) & 0x8000)) { 44 if (!(mbar_readLong(MCFSIM_DCR) & 0x8000)) {
44 u32 RC, dramsize; 45 u32 RC, dramsize;
45 46
46 RC = (CONFIG_SYS_CLK / 1000000) >> 1; 47 RC = (CONFIG_SYS_CLK / 1000000) >> 1;
47 RC = (RC * 15) >> 4; 48 RC = (RC * 15) >> 4;
48 49
49 /* Initialize DRAM Control Register: DCR */ 50 /* Initialize DRAM Control Register: DCR */
50 mbar_writeShort(MCFSIM_DCR, (0x8400 | RC)); 51 mbar_writeShort(MCFSIM_DCR, (0x8400 | RC));
51 asm("nop"); 52 asm("nop");
52 53
53 mbar_writeLong(MCFSIM_DACR0, 0x00002320); 54 mbar_writeLong(MCFSIM_DACR0, 0x00002320);
54 asm("nop"); 55 asm("nop");
55 56
56 /* Initialize DMR0 */ 57 /* Initialize DMR0 */
57 dramsize = ((CONFIG_SYS_SDRAM_SIZE << 20) - 1) & 0xFFFC0000; 58 dramsize = ((CONFIG_SYS_SDRAM_SIZE << 20) - 1) & 0xFFFC0000;
58 mbar_writeLong(MCFSIM_DMR0, dramsize | 1); 59 mbar_writeLong(MCFSIM_DMR0, dramsize | 1);
59 asm("nop"); 60 asm("nop");
60 61
61 mbar_writeLong(MCFSIM_DACR0, 0x00002328); 62 mbar_writeLong(MCFSIM_DACR0, 0x00002328);
62 asm("nop"); 63 asm("nop");
63 64
64 /* Write to this block to initiate precharge */ 65 /* Write to this block to initiate precharge */
65 *(u32 *) (CONFIG_SYS_SDRAM_BASE) = 0xa5a5a5a5; 66 *(u32 *) (CONFIG_SYS_SDRAM_BASE) = 0xa5a5a5a5;
66 asm("nop"); 67 asm("nop");
67 68
68 /* Set RE bit in DACR */ 69 /* Set RE bit in DACR */
69 mbar_writeLong(MCFSIM_DACR0, 70 mbar_writeLong(MCFSIM_DACR0,
70 mbar_readLong(MCFSIM_DACR0) | 0x8000); 71 mbar_readLong(MCFSIM_DACR0) | 0x8000);
71 asm("nop"); 72 asm("nop");
72 73
73 /* Wait for at least 8 auto refresh cycles to occur */ 74 /* Wait for at least 8 auto refresh cycles to occur */
74 udelay(500); 75 udelay(500);
75 76
76 /* Finish the configuration by issuing the MRS */ 77 /* Finish the configuration by issuing the MRS */
77 mbar_writeLong(MCFSIM_DACR0, 78 mbar_writeLong(MCFSIM_DACR0,
78 mbar_readLong(MCFSIM_DACR0) | 0x0040); 79 mbar_readLong(MCFSIM_DACR0) | 0x0040);
79 asm("nop"); 80 asm("nop");
80 81
81 *(u32 *) (CONFIG_SYS_SDRAM_BASE + 0x800) = 0xa5a5a5a5; 82 *(u32 *) (CONFIG_SYS_SDRAM_BASE + 0x800) = 0xa5a5a5a5;
82 } 83 }
83 84
84 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024; 85 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
85 } 86 }
86 87
87 int testdram(void) 88 int testdram(void)
88 { 89 {
89 /* TODO: XXX XXX XXX */ 90 /* TODO: XXX XXX XXX */
90 printf("DRAM test not implemented!\n"); 91 printf("DRAM test not implemented!\n");
91 92
92 return (0); 93 return (0);
93 } 94 }
94 95
95 #ifdef CONFIG_CMD_IDE 96 #ifdef CONFIG_CMD_IDE
96 #include <ata.h> 97 #include <ata.h>
97 int ide_preinit(void) 98 int ide_preinit(void)
98 { 99 {
99 return (0); 100 return (0);
100 } 101 }
101 102
102 void ide_set_reset(int idereset) 103 void ide_set_reset(int idereset)
103 { 104 {
104 volatile atac_t *ata = (atac_t *) CONFIG_SYS_ATA_BASE_ADDR; 105 atac_t *ata = (atac_t *) CONFIG_SYS_ATA_BASE_ADDR;
105 long period; 106 long period;
106 /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */ 107 /* t1, t2, t3, t4, t5, t6, t9, tRD, tA */
107 int piotms[5][9] = { {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */ 108 int piotms[5][9] = { {70, 165, 60, 30, 50, 5, 20, 0, 35}, /* PIO 0 */
108 {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */ 109 {50, 125, 45, 20, 35, 5, 15, 0, 35}, /* PIO 1 */
109 {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */ 110 {30, 100, 30, 15, 20, 5, 10, 0, 35}, /* PIO 2 */
110 {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */ 111 {30, 80, 30, 10, 20, 5, 10, 0, 35}, /* PIO 3 */
111 {25, 70, 20, 10, 20, 5, 10, 0, 35} /* PIO 4 */ 112 {25, 70, 20, 10, 20, 5, 10, 0, 35} /* PIO 4 */
112 }; 113 };
113 114
114 if (idereset) { 115 if (idereset) {
115 ata->cr = 0; /* control reset */ 116 /* control reset */
117 out_8(&ata->cr, 0);
116 udelay(100); 118 udelay(100);
117 } else { 119 } else {
118 mbar2_writeLong(CIM_MISCCR, CIM_MISCCR_CPUEND); 120 mbar2_writeLong(CIM_MISCCR, CIM_MISCCR_CPUEND);
119 121
120 #define CALC_TIMING(t) (t + period - 1) / period 122 #define CALC_TIMING(t) (t + period - 1) / period
121 period = 1000000000 / (CONFIG_SYS_CLK / 2); /* period in ns */ 123 period = 1000000000 / (CONFIG_SYS_CLK / 2); /* period in ns */
122 124
123 /*ata->ton = CALC_TIMING (180); */ 125 /*ata->ton = CALC_TIMING (180); */
124 ata->t1 = CALC_TIMING(piotms[2][0]); 126 out_8(&ata->t1, CALC_TIMING(piotms[2][0]));
125 ata->t2w = CALC_TIMING(piotms[2][1]); 127 out_8(&ata->t2w, CALC_TIMING(piotms[2][1]));
126 ata->t2r = CALC_TIMING(piotms[2][1]); 128 out_8(&ata->t2r, CALC_TIMING(piotms[2][1]));
127 ata->ta = CALC_TIMING(piotms[2][8]); 129 out_8(&ata->ta, CALC_TIMING(piotms[2][8]));
128 ata->trd = CALC_TIMING(piotms[2][7]); 130 out_8(&ata->trd, CALC_TIMING(piotms[2][7]));
129 ata->t4 = CALC_TIMING(piotms[2][3]); 131 out_8(&ata->t4, CALC_TIMING(piotms[2][3]));
130 ata->t9 = CALC_TIMING(piotms[2][6]); 132 out_8(&ata->t9, CALC_TIMING(piotms[2][6]));
131 133
132 ata->cr = 0x40; /* IORDY enable */ 134 /* IORDY enable */
135 out_8(&ata->cr, 0x40);
133 udelay(2000); 136 udelay(2000);
134 ata->cr |= 0x01; /* IORDY enable */ 137 /* IORDY enable */
138 setbits_8(&ata->cr, 0x01);
135 } 139 }
136 } 140 }
137 #endif /* CONFIG_CMD_IDE */ 141 #endif /* CONFIG_CMD_IDE */
138 142
board/freescale/m5272c3/m5272c3.c
1 /* 1 /*
2 * (C) Copyright 2000-2003 2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
6 *
5 * See file CREDITS for list of people who contributed to this 7 * See file CREDITS for list of people who contributed to this
6 * project. 8 * project.
7 * 9 *
8 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 11 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 12 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 13 * the License, or (at your option) any later version.
12 * 14 *
13 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 18 * GNU General Public License for more details.
17 * 19 *
18 * You should have received a copy of the GNU General Public License 20 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA 23 * MA 02111-1307 USA
22 */ 24 */
23 25
24 #include <common.h> 26 #include <common.h>
25 #include <asm/immap.h> 27 #include <asm/immap.h>
28 #include <asm/io.h>
26 29
27 30
28 int checkboard (void) { 31 int checkboard (void) {
29 puts ("Board: "); 32 puts ("Board: ");
30 puts ("Freescale MCF5272C3 EVB\n"); 33 puts ("Freescale MCF5272C3 EVB\n");
31 return 0; 34 return 0;
32 }; 35 };
33 36
34 phys_size_t initdram (int board_type) { 37 phys_size_t initdram (int board_type) {
35 volatile sdramctrl_t * sdp = (sdramctrl_t *)(MMAP_SDRAM); 38 sdramctrl_t * sdp = (sdramctrl_t *)(MMAP_SDRAM);
36 39
37 sdp->sdram_sdtr = 0xf539; 40 out_be16(&sdp->sdram_sdtr, 0xf539);
38 sdp->sdram_sdcr = 0x4211; 41 out_be16(&sdp->sdram_sdcr, 0x4211);
39 42
40 /* Dummy write to start SDRAM */ 43 /* Dummy write to start SDRAM */
41 *((volatile unsigned long *)0) = 0; 44 *((volatile unsigned long *)0) = 0;
42 45
43 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024; 46 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
44 }; 47 };
45 48
46 int testdram (void) { 49 int testdram (void) {
47 /* TODO: XXX XXX XXX */ 50 /* TODO: XXX XXX XXX */
48 printf ("DRAM test not implemented!\n"); 51 printf ("DRAM test not implemented!\n");
49 52
50 return (0); 53 return (0);
51 } 54 }
52 55
board/freescale/m5275evb/m5275evb.c
1 /* 1 /*
2 * (C) Copyright 2000-2003 2 * (C) Copyright 2000-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 * 4 *
5 * Copyright (C) 2005-2008 Arthur Shipkowski (art@videon-central.com) 5 * Copyright (C) 2005-2008 Arthur Shipkowski (art@videon-central.com)
6 * 6 *
7 * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
8 *
7 * See file CREDITS for list of people who contributed to this 9 * See file CREDITS for list of people who contributed to this
8 * project. 10 * project.
9 * 11 *
10 * This program is free software; you can redistribute it and/or 12 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as 13 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of 14 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version. 15 * the License, or (at your option) any later version.
14 * 16 *
15 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details. 20 * GNU General Public License for more details.
19 * 21 *
20 * You should have received a copy of the GNU General Public License 22 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software 23 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA 25 * MA 02111-1307 USA
24 */ 26 */
25 27
26 #include <common.h> 28 #include <common.h>
27 #include <asm/immap.h> 29 #include <asm/immap.h>
30 #include <asm/io.h>
28 31
29 #define PERIOD 13 /* system bus period in ns */ 32 #define PERIOD 13 /* system bus period in ns */
30 #define SDRAM_TREFI 7800 /* in ns */ 33 #define SDRAM_TREFI 7800 /* in ns */
31 34
32 int checkboard(void) 35 int checkboard(void)
33 { 36 {
34 puts("Board: "); 37 puts("Board: ");
35 puts("Freescale MCF5275 EVB\n"); 38 puts("Freescale MCF5275 EVB\n");
36 return 0; 39 return 0;
37 }; 40 };
38 41
39 phys_size_t initdram(int board_type) 42 phys_size_t initdram(int board_type)
40 { 43 {
41 volatile sdramctrl_t *sdp = (sdramctrl_t *)(MMAP_SDRAM); 44 sdramctrl_t *sdp = (sdramctrl_t *)(MMAP_SDRAM);
42 volatile gpio_t *gpio_reg = (gpio_t *)(MMAP_GPIO); 45 gpio_t *gpio_reg = (gpio_t *)(MMAP_GPIO);
43 46
44 gpio_reg->par_sdram = 0x3FF; /* Enable SDRAM */ 47 /* Enable SDRAM */
48 out_be16(&gpio_reg->par_sdram, 0x3FF);
45 49
46 /* Set up chip select */ 50 /* Set up chip select */
47 sdp->sdbar0 = CONFIG_SYS_SDRAM_BASE; 51 out_be32(&sdp->sdbar0, CONFIG_SYS_SDRAM_BASE);
48 sdp->sdbmr0 = MCF_SDRAMC_SDMRn_BAM_32M | MCF_SDRAMC_SDMRn_V; 52 out_be32(&sdp->sdbmr0, MCF_SDRAMC_SDMRn_BAM_32M | MCF_SDRAMC_SDMRn_V);
49 53
50 /* Set up timing */ 54 /* Set up timing */
51 sdp->sdcfg1 = 0x83711630; 55 out_be32(&sdp->sdcfg1, 0x83711630);
52 sdp->sdcfg2 = 0x46770000; 56 out_be32(&sdp->sdcfg2, 0x46770000);
53 57
54 /* Enable clock */ 58 /* Enable clock */
55 sdp->sdcr = MCF_SDRAMC_SDCR_MODE_EN | MCF_SDRAMC_SDCR_CKE; 59 out_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN | MCF_SDRAMC_SDCR_CKE);
56 60
57 /* Set precharge */ 61 /* Set precharge */
58 sdp->sdcr |= MCF_SDRAMC_SDCR_IPALL; 62 setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
59 63
60 /* Dummy write to start SDRAM */ 64 /* Dummy write to start SDRAM */
61 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696; 65 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
62 66
63 /* Send LEMR */ 67 /* Send LEMR */
64 sdp->sdmr = MCF_SDRAMC_SDMR_BNKAD_LEMR 68 setbits_be32(&sdp->sdmr,
65 | MCF_SDRAMC_SDMR_AD(0x0) 69 MCF_SDRAMC_SDMR_BNKAD_LEMR | MCF_SDRAMC_SDMR_AD(0x0) |
66 | MCF_SDRAMC_SDMR_CMD; 70 MCF_SDRAMC_SDMR_CMD);
67 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696; 71 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
68 72
69 /* Send LMR */ 73 /* Send LMR */
70 sdp->sdmr = 0x058d0000; 74 out_be32(&sdp->sdmr, 0x058d0000);
71 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696; 75 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
72 76
73 /* Stop sending commands */ 77 /* Stop sending commands */
74 sdp->sdmr &= ~(MCF_SDRAMC_SDMR_CMD); 78 clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
75 79
76 /* Set precharge */ 80 /* Set precharge */
77 sdp->sdcr |= MCF_SDRAMC_SDCR_IPALL; 81 setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
78 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696; 82 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
79 83
80 /* Stop manual precharge, send 2 IREF */ 84 /* Stop manual precharge, send 2 IREF */
81 sdp->sdcr &= ~(MCF_SDRAMC_SDCR_IPALL); 85 clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
82 sdp->sdcr |= MCF_SDRAMC_SDCR_IREF; 86 setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IREF);
83 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696; 87 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
84 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696; 88 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
85 89
86 /* Write mode register, clear reset DLL */ 90
87 sdp->sdmr = 0x018d0000; 91 out_be32(&sdp->sdmr, 0x018d0000);
88 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696; 92 *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
89 93
90 /* Stop sending commands */ 94 /* Stop sending commands */
91 sdp->sdmr &= ~(MCF_SDRAMC_SDMR_CMD); 95 clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
92 sdp->sdcr &= ~(MCF_SDRAMC_SDCR_MODE_EN); 96 clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN);
93 97
94 /* Turn on auto refresh, lock SDMR */ 98 /* Turn on auto refresh, lock SDMR */
95 sdp->sdcr = 99 out_be32(&sdp->sdcr,
96 MCF_SDRAMC_SDCR_CKE 100 MCF_SDRAMC_SDCR_CKE
97 | MCF_SDRAMC_SDCR_REF 101 | MCF_SDRAMC_SDCR_REF
98 | MCF_SDRAMC_SDCR_MUX(1) 102 | MCF_SDRAMC_SDCR_MUX(1)
99 /* 1 added to round up */ 103 /* 1 added to round up */
100 | MCF_SDRAMC_SDCR_RCNT((SDRAM_TREFI/(PERIOD*64)) - 1 + 1) 104 | MCF_SDRAMC_SDCR_RCNT((SDRAM_TREFI/(PERIOD*64)) - 1 + 1)
101 | MCF_SDRAMC_SDCR_DQS_OE(0x3); 105 | MCF_SDRAMC_SDCR_DQS_OE(0x3));
102 106
103 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024; 107 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
104 }; 108 };
105 109
106 int testdram(void) 110 int testdram(void)
107 { 111 {
108 /* TODO: XXX XXX XXX */ 112 /* TODO: XXX XXX XXX */
109 printf("DRAM test not implemented!\n"); 113 printf("DRAM test not implemented!\n");
110 114
111 return (0); 115 return (0);
112 } 116 }
113 117