summaryrefslogtreecommitdiff
path: root/target/linux/coldfire/patches/046-mcfv4e_kern_to_phys.patch
blob: b11178978df55f89d5c39387686cce79c6ac73a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
From 13fc0abf4b5da6f18dea15fd31697655615a79fc Mon Sep 17 00:00:00 2001
From: Kurt Mahan <kmahan@freescale.com>
Date: Wed, 12 Mar 2008 15:39:03 -0600
Subject: [PATCH] Move kernel to physical sdram base address.

Work based on the patches from Systec GMBH.  Also DMA support,
uBoot integration, FEC fixes, and assorted cleanups.

Uber patch needs to be split up.

LTIBName: mcfv4e-kern-to-phys
Signed-off-by: Kurt Mahan <kmahan@freescale.com>
---
 arch/m68k/coldfire/config.c           |  102 ++-----
 arch/m68k/coldfire/dma.c              |    7 +-
 arch/m68k/coldfire/entry.S            |   10 +
 arch/m68k/coldfire/head.S             |   53 +++-
 arch/m68k/coldfire/mcf5445x-devices.c |    2 +
 arch/m68k/coldfire/mcf5445x-pci.c     |    3 +
 arch/m68k/coldfire/signal.c           |    3 +
 arch/m68k/configs/m5485evb_defconfig  |   79 +++++-
 arch/m68k/mm/cache.c                  |    4 +-
 arch/m68k/mm/cf-mmu.c                 |   28 ++-
 arch/m68k/mm/memory.c                 |    8 +-
 drivers/net/fec/fec.c                 |   20 +-
 include/asm-m68k/bootinfo.h           |   59 +++-
 include/asm-m68k/cf_cacheflush.h      |  547 +++++++++++----------------------
 include/asm-m68k/cf_pgalloc.h         |    5 +-
 include/asm-m68k/cf_pgtable.h         |    2 +-
 include/asm-m68k/cfcache.h            |    6 +
 include/asm-m68k/page.h               |    8 +
 include/asm-m68k/page_offset.h        |   25 +-
 19 files changed, 446 insertions(+), 525 deletions(-)

--- a/arch/m68k/coldfire/config.c
+++ b/arch/m68k/coldfire/config.c
@@ -23,7 +23,6 @@
 #include <asm/coldfire.h>
 #include <asm/cfcache.h>
 #include <asm/cacheflush.h>
-#include <asm/bootinfo.h>
 #include <asm/io.h>
 #include <asm/cfmmu.h>
 #include <asm/setup.h>
@@ -36,7 +35,14 @@
 
 #include <asm/mcfsim.h>
 
-#if 0
+#if defined(CONFIG_M54455)
+#define UBOOT_EXTRA_CLOCKS
+#elif defined(CONFIG_M547X_8X)
+#define UBOOT_PCI
+#endif
+#include <asm/bootinfo.h>
+
+#ifdef CONFIG_M54455
 #include <asm/mcf5445x_intc.h>
 #include <asm/mcf5445x_sdramc.h>
 #include <asm/mcf5445x_fbcs.h>
@@ -44,10 +50,6 @@
 #include <asm/mcf5445x_xbs.h>
 #endif
 
-/* JKM -- testing */
-#include <linux/pfn.h>
-/* JKM */
-
 extern int get_irq_list(struct seq_file *p, void *v);
 extern char _text, _end;
 extern char _etext, _edata, __init_begin, __init_end;
@@ -58,6 +60,10 @@ extern unsigned long availmem;
 static int irq_enable[NR_IRQS];
 unsigned long num_pages;
 
+/* ethernet mac addresses from uboot */
+unsigned char uboot_enet0[6];
+unsigned char uboot_enet1[6];
+
 void coldfire_sort_memrec(void)
 {
 	int i, j;
@@ -87,6 +93,9 @@ void coldfire_sort_memrec(void)
 	}
 }
 
+/*
+ * UBoot Handler
+ */
 int __init uboot_commandline(char *bootargs)
 {
 	int len = 0, cmd_line_len;
@@ -101,12 +110,17 @@ int __init uboot_commandline(char *boota
 		return 0;
 
 	/* Add offset to get post-remapped kernel memory location */
-	uboot_info.bd_info = (*(u32 *)(uboot_info_stk)) + offset;
+	uboot_info.bdi = (struct bd_info *)((*(u32 *)(uboot_info_stk)) + offset);
 	uboot_info.initrd_start = (*(u32 *)(uboot_info_stk+4)) + offset;
 	uboot_info.initrd_end = (*(u32 *)(uboot_info_stk+8)) + offset;
 	uboot_info.cmd_line_start = (*(u32 *)(uboot_info_stk+12)) + offset;
 	uboot_info.cmd_line_stop = (*(u32 *)(uboot_info_stk+16)) + offset;
 
+	/* copy over mac addresses */
+	memcpy(uboot_enet0, uboot_info.bdi->bi_enet0addr, 6);
+	memcpy(uboot_enet1, uboot_info.bdi->bi_enet1addr, 6);
+
+	/* copy command line */
 	cmd_line_len = uboot_info.cmd_line_stop - uboot_info.cmd_line_start;
 	if ((cmd_line_len > 0) && (cmd_line_len < CL_SIZE-1))
 		len = (int)strncpy(bootargs, (char *)uboot_info.cmd_line_start,\
@@ -121,7 +135,7 @@ int __init uboot_commandline(char *boota
 #if defined(CONFIG_M54455)
 #define DEFAULT_COMMAND_LINE "root=/dev/mtdblock1 rw rootfstype=jffs2 ip=none mtdparts=physmap-flash.0:5M(kernel)ro,-(jffs2)"
 #elif defined(CONFIG_M547X_8X)
-#define DEFAULT_COMMAND_LINE "debug root=/dev/nfs nfsroot=172.27.155.1:/tftpboot/rigo/rootfs/ ip=172.27.155.85:172.27.155.1"
+#define DEFAULT_COMMAND_LINE "debug root=/dev/nfs rw nfsroot=172.27.155.1:/tftpboot/rigo/rootfs/ ip=172.27.155.85:172.27.155.1"
 #endif
 asmlinkage void __init cf_early_init(void)
 {
@@ -142,7 +156,6 @@ asmlinkage void __init cf_early_init(voi
 	MCF_INTC1_IMRL = 0xFFFFFFFF;
 	MCF_INTC1_IMRH = 0xFFFFFFFF;
 #elif defined(CONFIG_M547X_8X)
-/* JKM -- ?? */
 	MCF_IMRL = 0xFFFFFFFF;
 	MCF_IMRH = 0xFFFFFFFF;
 #endif
@@ -170,7 +183,6 @@ asmlinkage void __init cf_early_init(voi
 			MCF_XBS_PRS_M6(MCF_XBS_PRI_1) |
 			MCF_XBS_PRS_M7(MCF_XBS_PRI_7));
 #endif
-	
 
 	m68k_machtype = MACH_CFMMU;
 	m68k_fputype = FPU_CFV4E;
@@ -181,7 +193,6 @@ asmlinkage void __init cf_early_init(voi
 	m68k_memory[m68k_num_memory].addr = CONFIG_SDRAM_BASE;
 	m68k_memory[m68k_num_memory++].size = CONFIG_SDRAM_SIZE;
 
-#if defined(CONFIG_M54455)
 	if (!uboot_commandline(m68k_command_line)) {
 #if defined(CONFIG_BOOTPARAM)
 		strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE-1);
@@ -189,11 +200,6 @@ asmlinkage void __init cf_early_init(voi
 		strcpy(m68k_command_line, DEFAULT_COMMAND_LINE);
 #endif
 	}
-#else
-/* JKM -- hack until mappings get resolved */
-	strcpy(m68k_command_line, DEFAULT_COMMAND_LINE);
-#endif
-
 
 #if defined(CONFIG_BLK_DEV_INITRD)
 	/* add initrd image */
@@ -372,75 +378,11 @@ void coldfire_reboot(void)
 #endif
 }
 
-/* int coldfire_hwclk(int i, struct rtc_time *t)
-{
-	printk ("Real time clock needs porting.\n");
-	return 0;
-}*/
-
 static void coldfire_get_model(char *model)
 {
 	sprintf(model, "Version 4 ColdFire");
 }
 
-/* JKM -- Why do we need these? */
-void coldfire_enable_irq(unsigned int vec)
-{
-	unsigned long flags;
-
-	vec -= 64;
-
-	if (((int)vec < 0) || (vec > 63)) {
-		printk(KERN_WARNING "enable_irq %d failed\n", vec);
-		return;
-	}
-
-	local_irq_save(flags);
-	irq_enable[vec]++;
-#if defined(CONFIG_M54455)
-	if (vec < 32)
-		MCF_INTC0_IMRL &= ~(1 << vec);
-	else
-		MCF_INTC0_IMRH &= ~(1 << (vec - 32));
-#elif defined(CONFIG_M547X_8X)
-	if (vec < 32)
-		MCF_IMRL &= ~(1 << vec);
-	else
-		MCF_IMRH &= ~(1 << (vec - 32));
-#endif
-	local_irq_restore(flags);
-}
-
-/* JKM -- Why do we need these? */
-void coldfire_disable_irq(unsigned int vec)
-{
-	unsigned long flags;
-
-	vec -= 64;
-
-	if (((int)vec < 0) || (vec > 63)) {
-		printk(KERN_WARNING "disable_irq %d failed\n", vec);
-		return;
-	}
-
-	local_irq_save(flags);
-	if (--irq_enable[vec] == 0) {
-#if defined(CONFIG_M54455)
-		if (vec < 32)
-			MCF_INTC0_IMRL |= (1 << vec);
-		else
-			MCF_INTC0_IMRH |= (1 << (vec - 32));
-#elif defined(CONFIG_M547X_8X)
-		if (vec < 32)
-			MCF_IMRL |= (1 << vec);
-		else
-			MCF_IMRH |= (1 << (vec - 32));
-#endif
-
-	}
-	local_irq_restore(flags);
-}
-
 static void __init
 coldfire_bootmem_alloc(unsigned long memory_start, unsigned long memory_end)
 {
--- a/arch/m68k/coldfire/dma.c
+++ b/arch/m68k/coldfire/dma.c
@@ -516,13 +516,8 @@ dma_init()
 	MCF_DMA_DIPR = 0xFFFFFFFF;
 
 	MCF_ICR(ISC_DMA) = ILP_DMA;
-#if 0
-// JKM
-	enable_irq( 64 + ISC_DMA );
-#endif
 
-	result =
-	    MCD_initDma((dmaRegs *) (MCF_MBAR + 0x8000),
+	result = MCD_initDma((dmaRegs *) (MCF_MBAR + 0x8000),
 			(void *) SYS_SRAM_DMA_START, MCD_RELOC_TASKS);
 	if (result != MCD_OK) {
 		printk("Cannot perform DMA initialization\n");
--- a/arch/m68k/coldfire/entry.S
+++ b/arch/m68k/coldfire/entry.S
@@ -10,6 +10,8 @@
  *  Kurt Mahan kmahan@freescale.com
  *  Copyright Freescale Semiconductor, Inc. 2007
  *
+ *  Modify irq status in buserr -- (c) Copyright 2008, SYSTEM electronic Gmbh
+ *
  * Based on:
  *
  *  arch/m68knommu/platform/5307/entry.S &
@@ -77,7 +79,15 @@ sw_usp:
 .globl inthandler
 
 ENTRY(buserr)
+#ifdef CONFIG_COLDFIRE_FOO
+	movew	#0x2700,%sr		/* lock interrupts */
+#endif
 	SAVE_ALL_INT
+#ifdef	CONFIG_COLDFIRE_FOO
+	movew	PT_SR(%sp),%d3		/* get original %sr */
+	oril	#0x2000,%d3		/* set supervisor mode in it */
+	movew	%d3,%sr			/* recover irq state */
+#endif
 	GET_CURRENT(%d0)
 	movel   %sp,%sp@-		/* stack frame pointer argument */
 	jsr     buserr_c
--- a/arch/m68k/coldfire/head.S
+++ b/arch/m68k/coldfire/head.S
@@ -5,6 +5,7 @@
  *    Matt Waddel Matt.Waddel@freescale.com
  *    Kurt Mahan kmahan@freescale.com
  *  Copyright Freescale Semiconductor, Inc. 2007, 2008
+ *  Phys kernel mapping Copyright Daniel Krueger, SYSTEC electornic GmbH 2008
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -52,7 +53,7 @@
 #define __FINIT		.previous
 #endif
 
-/* JKM -- REVISE DOCS FOR RIGO */
+/* JKM -- REVISE DOCS FOR RIGO and PHYS MAPPING */
 /*
  * Setup ACR mappings to provide the following memory map:
  *   Data
@@ -62,10 +63,17 @@
  *     None currently (mapped via TLBs)
  */
 
+#if CONFIG_SDRAM_BASE != PAGE_BASE
 #if defined(CONFIG_M54455)
+#if 0
 #define ACR0_DEFAULT	#0xA00FA048   /* ACR0 default value */
+#endif
+#define ACR0_DEFAULT	#0x400FA028   /* ACR0 default value */
 #define ACR1_DEFAULT	#0xF00FA040   /* ACR1 default value */
+#if 0
 #define ACR2_DEFAULT	#0x00000000   /* ACR2 default value */
+#endif
+#define ACR2_DEFAULT	#0x400FA028   /* ACR2 default value */
 #define ACR3_DEFAULT	#0x00000000   /* ACR3 default value */
 /* ACR mapping for FPGA (maps 0) */
 #define ACR0_FPGA	#0x000FA048   /* ACR0 enable FPGA */
@@ -76,6 +84,16 @@
 #define ACR3_DEFAULT	#0x00000000   /* ACR3 default value */
 #endif
 
+#else
+#if defined(CONFIG_M54455)
+#elif defined(CONFIG_M547X_8X)
+#define ACR0_DEFAULT	#0xE000C040   /* ACR0 default value */
+#define ACR1_DEFAULT	#0x000FA008   /* ACR1 default value */
+#define ACR2_DEFAULT	#0x00000000   /* ACR2 default value */
+#define ACR3_DEFAULT	#0x000FA008   /* ACR3 default value */
+#endif
+#endif
+
 
 /* Several macros to make the writing of subroutines easier:
  * - func_start marks the beginning of the routine which setups the frame
@@ -153,6 +171,7 @@ func_define	putn,1
 #endif
 .endm
 
+#if CONFIG_SDRAM_BASE != PAGE_OFFSET
 /*
 	mmu_map  -  creates a new TLB entry
 
@@ -222,6 +241,7 @@ func_define	putn,1
 	movew	\temp_data_reg, (MMUOR)
 1:	
 .endm	/* mmu_unmap */
+#endif /* CONFIG_SDRAM_BASE != PAGE_OFFSET */
 
 /* .text */
 .section ".text.head","ax"
@@ -235,7 +255,11 @@ ENTRY(_stext)
 
 	.long	BOOTINFOV_MAGIC
 	.long	0
+#if CONFIG_SDRAM_BASE != PAGE_OFFSET
 1:	jmp	__start-(0xc0000000-CONFIG_SDRAM_BASE)
+#else
+1:	jmp	__start
+#endif
 
 .equ	kernel_pg_dir,_stext
 .equ	.,_stext+0x1000
@@ -244,24 +268,13 @@ ENTRY(_start)
 	jra	__start
 __INIT
 ENTRY(__start)
-
-/* JKM -- make sure Rigo handles UBOOT */
 /* Save the location of u-boot info - cmd line, bd_info, etc. */
 	movel	%a7,%a4		/* Don't use %a4 before cf_early_init */
-/* JKM -- fix to use CONFIG_SDRAM_BASE) */
-#if defined(CONFIG_M54455)
-	addl	#0x80000004,%a4	/* 0x80000004= 1 stack push + high mem offset */
-#elif defined(CONFIG_M547X_8X)
-	addl	#0xc0000004,%a4	/* 0x80000004= 1 stack push + high mem offset */
-#endif
+	addl	#0x00000004,%a4	/* offset past top */
+	addl	#(PAGE_OFFSET-CONFIG_SDRAM_BASE),%a4	/* high mem offset */
 
-/* JKM -- fix this to work off of CONFIG_SDRAM_BASE */
 /* Setup initial stack pointer */
-#if defined(CONFIG_M54455)
-	movel	#0x40001000,%sp	
-#elif defined(CONFIG_M547X_8X)
-	movel	#0x00001000,%sp	
-#endif
+	movel	#CONFIG_SDRAM_BASE+0x1000,%sp
 
 /* Setup usp */
 	subl	%a0,%a0
@@ -297,16 +310,21 @@ ENTRY(__start)
 /* setup ACRs */
 	movel	ACR0_DEFAULT, %d0  		/* ACR0 (DATA) setup */
 	movec   %d0, %acr0
+	nop
 	movel	ACR1_DEFAULT, %d0  		/* ACR1 (DATA) setup */
 	movec   %d0, %acr1
+	nop
 	movel	ACR2_DEFAULT, %d0  		/* ACR2 (CODE) setup */
 	movec   %d0, %acr2
+	nop
 	movel	ACR3_DEFAULT, %d0  		/* ACR3 (CODE) setup */
 	movec   %d0, %acr3
+	nop
 
 	/* If you change the memory size to another value make a matching 
 	   change in paging_init(cf-mmu.c) to zones_size[]. */
 
+#if CONFIG_SDRAM_BASE != PAGE_OFFSET
 #if defined(CONFIG_M54455)
 	/* Map 256MB as code */
 	mmu_map	(PAGE_OFFSET+0*0x1000000),  (PHYS_OFFSET+0*0x1000000), \
@@ -511,6 +529,7 @@ ENTRY(__start)
 		MMUTR_SG, MMUDR_SZ1M, MMUDR_DCB, MMUDR_SP, MMUDR_R, \
 		MMUDR_W, 0, 0, %d0
 #endif
+#endif /* CONFIG_SDRAM_BASE != PAGE_OFFSET */
 
 	/* Turn on MMU */
 	movel	#(MMUCR_EN),%a0
@@ -531,6 +550,7 @@ ENTRY(__running_high)
 	movel	%a1,%a0@
 
 	/* Unmap unity mappings */
+#if CONFIG_SDRAM_BASE != PAGE_OFFSET
 #if defined(CONFIG_M54455)
 	mmu_unmap (PHYS_OFFSET+0*0x1000000), MMUOR_ITLB, %d0
 	mmu_unmap (PHYS_OFFSET+0*0x1000000), 0, %d0
@@ -544,6 +564,7 @@ ENTRY(__running_high)
 	mmu_unmap (PHYS_OFFSET+2*0x1000000), 0, %d0
 	mmu_unmap (PHYS_OFFSET+3*0x1000000), 0, %d0
 #endif
+#endif /* CONFIG_SDRAM_BASE != PAGE_OFFSET */
 
 /* Setup initial stack pointer */
 	lea	init_task,%a2 
@@ -574,6 +595,7 @@ func_return	set_context
  * Map in 0x00000000 -> 0x0fffffff and then do the write.
  */
 set_fpga:
+#if 0
 	movew	%sr,%d1
 	movew	#0x2700,%sr
 	movel	ACR0_FPGA, %d0
@@ -585,6 +607,7 @@ set_fpga:
 	movec   %d0, %acr0
 	nop
 	movew	%d1,%sr
+#endif
 	rts
 #endif
 
--- a/arch/m68k/coldfire/mcf5445x-devices.c
+++ b/arch/m68k/coldfire/mcf5445x-devices.c
@@ -127,7 +127,9 @@ static inline void mcf5445x_init_pata(vo
 static int __init mcf5445x_init_devices(void)
 {
 	printk(KERN_INFO "MCF5445x INIT_DEVICES\n");
+#if 0
 	mcf5445x_init_pata();
+#endif
 
 	return 0;
 }
--- a/arch/m68k/coldfire/mcf5445x-pci.c
+++ b/arch/m68k/coldfire/mcf5445x-pci.c
@@ -236,6 +236,8 @@ mcf5445x_pci_arb_interrupt(int irq, void
 int __init
 init_mcf5445x_pci(void)
 {
+	return 0;
+#if 0
 	/*
 	 * Initialize the PCI core
 	 */
@@ -331,6 +333,7 @@ init_mcf5445x_pci(void)
 	raw_pci_ops = &mcf5445x_pci_ops;
 
 	return 0;
+#endif
 }
 
 /*
--- a/arch/m68k/coldfire/signal.c
+++ b/arch/m68k/coldfire/signal.c
@@ -608,7 +608,10 @@ static inline int rt_setup_ucontext(stru
 
 static inline void push_cache(unsigned long vaddr)
 {
+#if 0 
+// JKM -- need to add into the old cpushl cache stuff
 	cf_cache_push(__pa(vaddr), 8);
+#endif
 }
 
 static inline void __user *
--- a/arch/m68k/configs/m5485evb_defconfig
+++ b/arch/m68k/configs/m5485evb_defconfig
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.24
-# Thu Feb 21 00:19:01 2008
+# Wed Mar  5 16:05:25 2008
 #
 CONFIG_M68K=y
 CONFIG_MMU=y
@@ -103,6 +103,7 @@ CONFIG_DEFAULT_IOSCHED="cfq"
 # CONFIG_SUN3 is not set
 CONFIG_COLDFIRE=y
 CONFIG_CFV4E=y
+CONFIG_MCD_DMA=y
 # CONFIG_AMIGA is not set
 # CONFIG_ATARI is not set
 # CONFIG_MAC is not set
@@ -135,7 +136,7 @@ CONFIG_M5485CFE=y
 # CONFIG_M5485DFE is not set
 # CONFIG_M5485EFE is not set
 # CONFIG_M5485FFE is not set
-CONFIG_MCFCLK=50000000
+CONFIG_MCFCLK=200000000
 # CONFIG_MCF_USER_HALT is not set
 CONFIG_MMU_CFV4E=y
 CONFIG_SDRAM_BASE=0x00000000
@@ -279,7 +280,73 @@ CONFIG_FW_LOADER=y
 # CONFIG_DEBUG_DEVRES is not set
 # CONFIG_SYS_HYPERVISOR is not set
 # CONFIG_CONNECTOR is not set
-# CONFIG_MTD is not set
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_PARTITIONS=y
+# CONFIG_MTD_REDBOOT_PARTS is not set
+CONFIG_MTD_CMDLINE_PARTS=y
+
+#
+# User Modules And Translation Layers
+#
+# CONFIG_MTD_CHAR is not set
+CONFIG_MTD_BLKDEVS=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+# CONFIG_INFTL is not set
+# CONFIG_RFD_FTL is not set
+# CONFIG_SSFDC is not set
+# CONFIG_MTD_OOPS is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+# CONFIG_MTD_CFI is not set
+# CONFIG_MTD_JEDECPROBE is not set
+CONFIG_MTD_MAP_BANK_WIDTH_1=y
+CONFIG_MTD_MAP_BANK_WIDTH_2=y
+CONFIG_MTD_MAP_BANK_WIDTH_4=y
+# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
+# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
+CONFIG_MTD_CFI_I1=y
+CONFIG_MTD_CFI_I2=y
+# CONFIG_MTD_CFI_I4 is not set
+# CONFIG_MTD_CFI_I8 is not set
+CONFIG_MTD_RAM=y
+CONFIG_MTD_ROM=y
+# CONFIG_MTD_ABSENT is not set
+
+#
+# Mapping drivers for chip access
+#
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_PLATRAM is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_SLRAM is not set
+# CONFIG_MTD_PHRAM is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLOCK2MTD is not set
+
+#
+# Disk-On-Chip Device Drivers
+#
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOC2001PLUS is not set
+# CONFIG_MTD_NAND is not set
+# CONFIG_MTD_ONENAND is not set
+
+#
+# UBI - Unsorted block images
+#
+# CONFIG_MTD_UBI is not set
 # CONFIG_PARPORT is not set
 CONFIG_BLK_DEV=y
 # CONFIG_BLK_DEV_COW_COMMON is not set
@@ -347,6 +414,9 @@ CONFIG_NETDEVICES=y
 # CONFIG_PHYLIB is not set
 CONFIG_NET_ETHERNET=y
 CONFIG_MII=y
+CONFIG_FEC_548x=y
+CONFIG_FEC_548x_AUTO_NEGOTIATION=y
+# CONFIG_FEC_548x_ENABLE_FEC2 is not set
 # CONFIG_IBM_NEW_EMAC_ZMII is not set
 # CONFIG_IBM_NEW_EMAC_RGMII is not set
 # CONFIG_IBM_NEW_EMAC_TAH is not set
@@ -530,7 +600,7 @@ CONFIG_FS_MBCACHE=y
 # CONFIG_GFS2_FS is not set
 # CONFIG_OCFS2_FS is not set
 CONFIG_MINIX_FS=y
-# CONFIG_ROMFS_FS is not set
+CONFIG_ROMFS_FS=y
 # CONFIG_INOTIFY is not set
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
@@ -578,6 +648,7 @@ CONFIG_TMPFS=y
 # CONFIG_BEFS_FS is not set
 # CONFIG_BFS_FS is not set
 # CONFIG_EFS_FS is not set
+# CONFIG_JFFS2_FS is not set
 # CONFIG_CRAMFS is not set
 # CONFIG_VXFS_FS is not set
 # CONFIG_HPFS_FS is not set
--- a/arch/m68k/mm/cache.c
+++ b/arch/m68k/mm/cache.c
@@ -81,7 +81,9 @@ static unsigned long virt_to_phys_slow(u
 void flush_icache_range(unsigned long address, unsigned long endaddr)
 {
 #ifdef CONFIG_COLDFIRE
-	cf_icache_flush_range(address, endaddr);
+// JKM -- hack until new cpushl stuff is in
+//	cf_icache_flush_range(address, endaddr);
+	flush_icache();
 #else /* !CONFIG_COLDFIRE */
 
 	if (CPU_IS_040_OR_060) {
--- a/arch/m68k/mm/cf-mmu.c
+++ b/arch/m68k/mm/cf-mmu.c
@@ -35,6 +35,12 @@
 #include <asm/coldfire.h>
 #include <asm/tlbflush.h>
 
+#if PAGE_OFFSET == CONFIG_SDRAM_BASE
+#define	KERNRAM(x) ((x >= PAGE_OFFSET) && (x < (PAGE_OFFSET + CONFIG_SDRAM_SIZE)))
+#else
+#define	KERNRAM(x) (x >= PAGE_OFFSET)
+#endif
+
 mm_context_t next_mmu_context;
 unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1];
 
@@ -53,10 +59,16 @@ extern char __init_begin, __init_end;
 
 void free_initmem(void)
 {
+#if 0
 	unsigned long addr;
 	unsigned long start = (unsigned long)&__init_begin;
 	unsigned long end = (unsigned long)&__init_end;
 
+/* 
+ * JKM -- revisit -- the latest round of vmlinux.lds changes has caused
+ * a little grief with how init areas are handled.  With the new toolchain
+ * release I'll fix this.
+ */
 	printk(KERN_INFO "free_initmem: __init_begin = 0x%lx  __init_end = 0x%lx\n", start, end);
 
 	addr = (unsigned long)&__init_begin;
@@ -67,6 +79,7 @@ void free_initmem(void)
 		free_page(addr);
 		totalram_pages++;
 	}
+#endif
 }
 
 /* Coldfire paging_init derived from sun3 */
@@ -149,8 +162,8 @@ int cf_tlb_miss(struct pt_regs *regs, in
 	mmuar = ( dtlb ) ? regs->mmuar
 			 : regs->pc + (extension_word * sizeof(long));
 
-        mm = (!user_mode(regs) && (mmuar >= PAGE_OFFSET)) ? &init_mm
-							  : current->mm;
+        mm = (!user_mode(regs) && KERNRAM(mmuar)) ? &init_mm : current->mm;
+
         if (!mm) {
 	    local_irq_restore(flags);
 	    return (-1);
@@ -167,9 +180,9 @@ int cf_tlb_miss(struct pt_regs *regs, in
 	    local_irq_restore(flags);
 	    return (-1);
 	}	
-    	
-	pte = (mmuar >= PAGE_OFFSET) ? pte_offset_kernel(pmd, mmuar)
-	                             : pte_offset_map(pmd, mmuar);
+    
+	pte = (KERNRAM(mmuar)) ? pte_offset_kernel(pmd, mmuar)
+	                       : pte_offset_map(pmd, mmuar);
     	if (pte_none(*pte) || !pte_present(*pte)) {
 	    local_irq_restore(flags);
 	    return (-1);		
@@ -185,7 +198,7 @@ int cf_tlb_miss(struct pt_regs *regs, in
 	
         set_pte(pte, pte_mkyoung(*pte));
         asid = mm->context & 0xff;
-        if (!pte_dirty(*pte) && mmuar<=PAGE_OFFSET)
+        if (!pte_dirty(*pte) && !KERNRAM(mmuar))
     	    set_pte(pte, pte_wrprotect(*pte));
 
         *MMUTR = (mmuar & PAGE_MASK) | (asid << CF_ASID_MMU_SHIFT)
@@ -201,7 +214,8 @@ int cf_tlb_miss(struct pt_regs *regs, in
 	else
 	    *MMUOR = MMUOR_ITLB | MMUOR_ACC | MMUOR_UAA;
 
-	asm ("nop");
+	asm("nop");
+
 	/*printk("cf_tlb_miss: va=%lx, pa=%lx\n", (mmuar & PAGE_MASK), 
 		  (pte_val(*pte)  & PAGE_MASK));*/
 	local_irq_restore(flags);
--- a/arch/m68k/mm/memory.c
+++ b/arch/m68k/mm/memory.c
@@ -206,7 +206,9 @@ static inline void pushcl040(unsigned lo
 void cache_clear (unsigned long paddr, int len)
 {
 #ifdef CONFIG_COLDFIRE
-	cf_cache_clear(paddr, len);
+// JKM -- revise to use proper caching
+//	cf_cache_clear(paddr, len);
+	flush_bcache();
 #else
     if (CPU_IS_040_OR_060) {
 	int tmp;
@@ -257,7 +259,9 @@ EXPORT_SYMBOL(cache_clear);
 void cache_push (unsigned long paddr, int len)
 {
 #ifdef CONFIG_COLDFIRE
-	cf_cache_push(paddr, len);
+// JKM -- revise to use proper caching
+//	cf_cache_push(paddr, len);
+	flush_bcache();
 #else
     if (CPU_IS_040_OR_060) {
 	int tmp = PAGE_SIZE;
--- a/drivers/net/fec/fec.c
+++ b/drivers/net/fec/fec.c
@@ -99,6 +99,9 @@ unsigned char fec_mac_addr_fec0[6] = { 0
 unsigned char fec_mac_addr_fec1[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x51 };	// Default address of FEC1
 #endif
 
+extern unsigned char uboot_enet0[];
+extern unsigned char uboot_enet1[];
+
 #ifndef MODULE
 int fec_str_to_mac( char *str_mac, unsigned char* addr);
 int __init fec_mac_setup0 (char *s);
@@ -175,6 +178,12 @@ printk(KERN_INFO "FEI: index=%d\n", inde
 printk(KERN_INFO "FEI: txdesc=0x%p  rxdesc=0x%p\n", fp->fecpriv_txdesc, fp->fecpriv_rxdesc);
 
 		/* mac addr */
+		if (uboot_enet0[0] || uboot_enet0[1] || uboot_enet0[2] ||
+		    uboot_enet0[3] || uboot_enet0[4] || uboot_enet0[5]) {
+			/* use uboot enet 0 addr */
+			memcpy(fec_mac_addr_fec0, uboot_enet0, 6);
+		}
+
 		fp->fecpriv_mac_addr = fec_mac_addr_fec0;
 	}
 	else {
@@ -211,6 +220,11 @@ printk(KERN_INFO "FEI: txdesc=0x%p  rxde
 		fp->fecpriv_rxdesc = (void*)FEC_RX_DESC_FEC1;
 
 		/* mac addr */
+		if (uboot_enet1[0] || uboot_enet1[1] || uboot_enet1[2] ||
+		    uboot_enet1[3] || uboot_enet1[4] || uboot_enet1[5]) {
+			/* use uboot enet 1 addr */
+			memcpy(fec_mac_addr_fec1, uboot_enet1, 6);
+		}
 		fp->fecpriv_mac_addr = fec_mac_addr_fec1;
 #endif
 	}
@@ -762,7 +776,6 @@ int fec_tx(struct sk_buff *skb, struct n
 	void *data, *data_aligned;
 	int offset;
 
-printk(KERN_INFO "fec_tx\n");
 	data = kmalloc(skb->len + 15, GFP_DMA | GFP_ATOMIC);
 
 	if (!data)
@@ -820,7 +833,6 @@ void fec_tx_timeout(struct net_device *d
 	struct fec_priv *fp = netdev_priv(dev);
 	unsigned long base_addr = (unsigned long) dev->base_addr;
 
-printk(KERN_INFO "fec_tx_timeout\n");
 	spin_lock_irq(&fp->fecpriv_lock);
 	MCD_killDma(fp->fecpriv_fec_tx_channel);
 	for (i = 0; i < FEC_TX_BUF_NUMBER; i++)
@@ -941,7 +953,6 @@ void fec_interrupt_fec_tx_handler(struct
 {
 	struct fec_priv *fp = netdev_priv(dev);
 
-printk(KERN_INFO "fectxint\n");
 	//Release the socket buffer
 	if(fp->fecpriv_txbuf[fp->fecpriv_current_tx])
 	{
@@ -977,7 +988,6 @@ void fec_interrupt_fec_rx_handler(struct
 	struct fec_priv *fp = netdev_priv(dev);
 	struct sk_buff *skb;
 
-printk(KERN_INFO "fecrxint\n");
 	fp->fecpriv_rxflag = 1;
 /*
 	// Some buffers can be missed
@@ -1070,7 +1080,6 @@ irqreturn_t fec_interrupt_handler(int ir
 	unsigned long base_addr = (unsigned long) dev->base_addr;
 	unsigned long events;
 
-printk(KERN_INFO "fecerrint\n");
 	// Read and clear the events
 	events = FEC_EIR(base_addr) & FEC_EIMR(base_addr);
 
@@ -1157,7 +1166,6 @@ void fec_interrupt_fec_reinit(unsigned l
 	struct fec_priv *fp = netdev_priv(dev);
 	unsigned long base_addr = (unsigned long) dev->base_addr;
 
-printk(KERN_INFO "fecreinit\n");
 	// Initialize reception descriptors and start DMA for the reception
 	for (i = 0; i < FEC_RX_BUF_NUMBER; i++)
 	{
--- a/include/asm-m68k/bootinfo.h
+++ b/include/asm-m68k/bootinfo.h
@@ -19,11 +19,59 @@
 **   Redesign of the boot information structure; renamed to bootinfo.h again
 ** 27/11/96 Geert Uytterhoeven:
 **   Backwards compatibility with bootinfo interface version 1.0
+** 12/03/08 Kurt Mahan
+**   Copy the bd_info structure from uboot1.3.2/include/asm-m68k/u-boot.h
+**   into this file.  The original author is Wolfgang Denk, 
+**   DENX Software Engineering, wd@denx.de.
 */
 
 #ifndef _M68K_BOOTINFO_H
 #define _M68K_BOOTINFO_H
 
+#ifndef __ASSEMBLY__
+/*
+ * UBoot Support
+ *
+ * bd_info structure from uboot1.3.2/include/asm-m68k/u-boot.h
+ */
+struct bd_info {
+	unsigned long bi_memstart;	/* start of DRAM memory */
+	unsigned long bi_memsize;	/* size  of DRAM memory in bytes */
+	unsigned long bi_flashstart;	/* start of FLASH memory */
+	unsigned long bi_flashsize;	/* size  of FLASH memory */
+	unsigned long bi_flashoffset;	/* reserved area for startup monitor */
+	unsigned long bi_sramstart;	/* start of SRAM memory */
+	unsigned long bi_sramsize;	/* size  of SRAM memory */
+	unsigned long bi_mbar_base;	/* base of internal registers */
+	unsigned long bi_bootflags;	/* boot / reboot flag (for LynxOS) */
+	unsigned long bi_boot_params;	/* where this board expects params */
+	unsigned long bi_ip_addr;	/* IP Address */
+	unsigned char bi_enet0addr[6];	/* Ethernet 0 mac address */
+	unsigned short bi_ethspeed;	/* Ethernet speed in Mbps */
+	unsigned long bi_intfreq;	/* Internal Freq, in MHz */
+	unsigned long bi_busfreq;	/* Bus Freq, in MHz */
+#ifdef UBOOT_PCI
+	unsigned long bi_pcifreq;	/* pci Freq in MHz */
+#endif
+#ifdef UBOOT_EXTRA_CLOCK
+	unsigned long bi_inpfreq;	/* input Freq in MHz */
+	unsigned long bi_vcofreq;	/* vco Freq in MHz */
+	unsigned long bi_flbfreq;	/* Flexbus Freq in MHz */
+#endif
+	unsigned long bi_baudrate;	/* Console Baudrate */
+	unsigned char bi_enet1addr[6];	/* eth1 mac address */
+	unsigned char bi_enet2addr[6];	/* eth2 mac address */
+	unsigned char bi_enet3addr[6];	/* eth3 mac address */
+};
+
+struct uboot_record {
+	struct bd_info *bdi;
+    	unsigned long initrd_start;
+    	unsigned long initrd_end;
+    	unsigned long cmd_line_start;
+    	unsigned long cmd_line_stop;
+};
+#endif /* __ASSEMBLY__ */
 
     /*
      *  Bootinfo definitions
@@ -49,17 +97,6 @@ struct bi_record {
 #endif /* __ASSEMBLY__ */
 
 
-#ifndef __ASSEMBLY__
-
-struct uboot_record {
-    unsigned long bd_info;
-    unsigned long initrd_start;
-    unsigned long initrd_end;
-    unsigned long cmd_line_start;
-    unsigned long cmd_line_stop;
-};
-
-#endif /* __ASSEMBLY__ */
 
 
     /*
--- a/include/asm-m68k/cf_cacheflush.h
+++ b/include/asm-m68k/cf_cacheflush.h
@@ -1,335 +1,92 @@
-/*
- * include/asm-m68k/cf_cacheflush.h - Coldfire Cache
- *
- * Based on include/asm-m68k/cacheflush.h
- *
- * Coldfire pieces by:
- *   Kurt Mahan kmahan@freescale.com
- *
- * Copyright Freescale Semiconductor, Inc. 2007
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
 #ifndef M68K_CF_CACHEFLUSH_H
 #define M68K_CF_CACHEFLUSH_H
 
 #include <asm/cfcache.h>
-
 /*
- * Coldfire Cache Model
- *
- * The Coldfire processors use a Harvard architecture cache configured
- * as four-way set associative.  The cache does not implement bus snooping
- * so cache coherency with other masters must be maintained in software.
- *
- * The cache is managed via the CPUSHL instruction in conjunction with
- * bits set in the CACR (cache control register).  Currently the code
- * uses the CPUSHL enhancement which adds the ability to
- * invalidate/clear/push a cacheline by physical address.  This feature
- * is designated in the Hardware Configuration Register [D1-CPES].
- *
- * CACR Bits:
- *	DPI[28]		cpushl invalidate disable for d-cache
- *	IDPI[12]	cpushl invalidate disable for i-cache
- *	SPA[14]		cpushl search by physical address
- *	IVO[20]		cpushl invalidate only
- *
- * Random Terminology:
- *  * invalidate = reset the cache line's valid bit
- *  * push = generate a line-sized store of the data if its contents are marked
- *	     as modifed (the modified flag is cleared after the store)
- *  * clear = push + invalidate
- */
-
-/**
- * flush_icache - Flush all of the instruction cache
- */
-static inline void flush_icache(void)
-{
-	asm volatile("nop\n"
-		     "moveq%.l	#0,%%d0\n"
-		     "moveq%.l	#0,%%d1\n"
-		     "move%.l	%%d0,%%a0\n"
-		     "1:\n"
-		     "cpushl	%%ic,(%%a0)\n"
-		     "add%.l	#0x0010,%%a0\n"
-		     "addq%.l	#1,%%d1\n"
-		     "cmpi%.l	%0,%%d1\n"
-		     "bne	1b\n"
-		     "moveq%.l	#0,%%d1\n"
-		     "addq%.l	#1,%%d0\n"
-		     "move%.l	%%d0,%%a0\n"
-		     "cmpi%.l	#4,%%d0\n"
-		     "bne	1b\n"
-		     : : "i" (CACHE_SETS)
-		     : "a0", "d0", "d1");
-}
-
-/**
- * flush_dcache - Flush all of the data cache
- */
-static inline void flush_dcache(void)
-{
-	asm volatile("nop\n"
-		     "moveq%.l	#0,%%d0\n"
-		     "moveq%.l	#0,%%d1\n"
-		     "move%.l	%%d0,%%a0\n"
-		     "1:\n"
-		     "cpushl	%%dc,(%%a0)\n"
-		     "add%.l	#0x0010,%%a0\n"
-		     "addq%.l	#1,%%d1\n"
-		     "cmpi%.l	%0,%%d1\n"
-		     "bne	1b\n"
-		     "moveq%.l	#0,%%d1\n"
-		     "addq%.l	#1,%%d0\n"
-		     "move%.l	%%d0,%%a0\n"
-		     "cmpi%.l	#4,%%d0\n"
-		     "bne	1b\n"
-		     : : "i" (CACHE_SETS)
-		     : "a0", "d0", "d1");
-}
-
-/**
- * flush_bcache - Flush all of both caches
+ * Cache handling functions
  */
-static inline void flush_bcache(void)
-{
-	asm volatile("nop\n"
-		     "moveq%.l	#0,%%d0\n"
-		     "moveq%.l	#0,%%d1\n"
-		     "move%.l	%%d0,%%a0\n"
-		     "1:\n"
-		     "cpushl	%%bc,(%%a0)\n"
-		     "add%.l	#0x0010,%%a0\n"
-		     "addq%.l	#1,%%d1\n"
-		     "cmpi%.l	%0,%%d1\n"
-		     "bne	1b\n"
-		     "moveq%.l	#0,%%d1\n"
-		     "addq%.l	#1,%%d0\n"
-		     "move%.l	%%d0,%%a0\n"
-		     "cmpi%.l	#4,%%d0\n"
-		     "bne	1b\n"
-		     : : "i" (CACHE_SETS)
-		     : "a0", "d0", "d1");
-}
 
-/**
- * cf_cache_clear - invalidate cache
- * @paddr: starting physical address
- * @len: number of bytes
- *
- * Invalidate cache lines starting at paddr for len bytes.
- * Those lines are not pushed.
- */
-static inline void cf_cache_clear(unsigned long paddr, int len)
-{
-	/* number of lines */
-	len = (len + (CACHE_LINE_SIZE-1)) / CACHE_LINE_SIZE;
-	if (len == 0)
-		return;
-
-	/* align on set boundary */
-	paddr &= 0xfffffff0;
-
-	asm volatile("nop\n"
-		     "move%.l   %2,%%d0\n"
-		     "or%.l	%3,%%d0\n"
-		     "movec	%%d0,%%cacr\n"
-		     "move%.l	%0,%%a0\n"
-		     "move%.l	%1,%%d0\n"
-		     "1:\n"
-		     "cpushl	%%bc,(%%a0)\n"
-		     "lea	0x10(%%a0),%%a0\n"
-		     "subq%.l	#1,%%d0\n"
-		     "bne%.b	1b\n"
-		     "movec	%2,%%cacr\n"
-		     : : "a" (paddr), "r" (len),
-			 "r" (shadow_cacr),
-			 "i" (CF_CACR_SPA+CF_CACR_IVO)
-		     : "a0", "d0");
-}
-
-/**
- * cf_cache_push - Push dirty cache out with no invalidate
- * @paddr: starting physical address
- * @len: number of bytes
- *
- * Push the any dirty lines starting at paddr for len bytes.
- * Those lines are not invalidated.
- */
-static inline void cf_cache_push(unsigned long paddr, int len)
-{
-	/* number of lines */
-	len = (len + (CACHE_LINE_SIZE-1)) / CACHE_LINE_SIZE;
-	if (len == 0)
-		return;
-
-	/* align on set boundary */
-	paddr &= 0xfffffff0;
-
-	asm volatile("nop\n"
-		     "move%.l   %2,%%d0\n"
-		     "or%.l	%3,%%d0\n"
-		     "movec	%%d0,%%cacr\n"
-		     "move%.l	%0,%%a0\n"
-		     "move%.l	%1,%%d0\n"
-		     "1:\n"
-		     "cpushl	%%bc,(%%a0)\n"
-		     "lea	0x10(%%a0),%%a0\n"
-		     "subq%.l	#1,%%d0\n"
-		     "bne.b	1b\n"
-		     "movec	%2,%%cacr\n"
-		     : : "a" (paddr), "r" (len),
-			 "r" (shadow_cacr),
-			 "i" (CF_CACR_SPA+CF_CACR_DPI+CF_CACR_IDPI)
-		     : "a0", "d0");
-}
+#define flush_icache()						\
+({								\
+  unsigned long set;						\
+  unsigned long start_set;					\
+  unsigned long end_set;					\
+								\
+  start_set = 0;						\
+  end_set = (unsigned long)LAST_DCACHE_ADDR;			\
+    								\
+  for (set = start_set; set <= end_set; set += (0x10 - 3)) {	\
+    asm volatile("cpushl %%ic,(%0)\n"				\
+                 "\taddq%.l #1,%0\n"				\
+                 "\tcpushl %%ic,(%0)\n"				\
+                 "\taddq%.l #1,%0\n"				\
+                 "\tcpushl %%ic,(%0)\n"				\
+                 "\taddq%.l #1,%0\n"				\
+                 "\tcpushl %%ic,(%0)" : "=a" (set) : "a" (set));		\
+  }								\
+})
+
+#define flush_dcache()						\
+({								\
+  unsigned long set;						\
+  unsigned long start_set;					\
+  unsigned long end_set;					\
+								\
+  start_set = 0;						\
+  end_set = (unsigned long)LAST_DCACHE_ADDR;			\
+    								\
+  for (set = start_set; set <= end_set; set += (0x10 - 3)) {	\
+    asm volatile("cpushl %%dc,(%0)\n"				\
+                 "\taddq%.l #1,%0\n"				\
+                 "\tcpushl %%dc,(%0)\n"				\
+                 "\taddq%.l #1,%0\n"				\
+                 "\tcpushl %%dc,(%0)\n"				\
+                 "\taddq%.l #1,%0\n"				\
+                 "\tcpushl %%dc,(%0)" : "=a" (set) : "a" (set));		\
+  }								\
+})
+
+#define flush_bcache()						\
+({								\
+  unsigned long set;						\
+  unsigned long start_set;					\
+  unsigned long end_set;					\
+								\
+  start_set = 0;						\
+  end_set = (unsigned long)LAST_DCACHE_ADDR;			\
+    								\
+  for (set = start_set; set <= end_set; set += (0x10 - 3)) {	\
+    asm volatile("cpushl %%bc,(%0)\n"				\
+                 "\taddq%.l #1,%0\n"				\
+                 "\tcpushl %%bc,(%0)\n"				\
+                 "\taddq%.l #1,%0\n"				\
+                 "\tcpushl %%bc,(%0)\n"				\
+                 "\taddq%.l #1,%0\n"				\
+                 "\tcpushl %%bc,(%0)" : "=a" (set) : "a" (set));		\
+  }								\
+})
 
-/**
- * cf_cache_flush - Push dirty cache out and invalidate
- * @paddr: starting physical address
- * @len: number of bytes
- *
- * Push the any dirty lines starting at paddr for len bytes and
- * invalidate those lines.
+/*
+ * invalidate the cache for the specified memory range.
+ * It starts at the physical address specified for
+ * the given number of bytes.
  */
-static inline void cf_cache_flush(unsigned long paddr, int len)
-{
-	/* number of lines */
-	len = (len + (CACHE_LINE_SIZE-1)) / CACHE_LINE_SIZE;
-	if (len == 0)
-		return;
-
-	/* align on set boundary */
-	paddr &= 0xfffffff0;
-
-	asm volatile("nop\n"
-		     "move%.l   %2,%%d0\n"
-		     "or%.l	%3,%%d0\n"
-		     "movec	%%d0,%%cacr\n"
-		     "move%.l	%0,%%a0\n"
-		     "move%.l	%1,%%d0\n"
-		     "1:\n"
-		     "cpushl	%%bc,(%%a0)\n"
-		     "lea	0x10(%%a0),%%a0\n"
-		     "subq%.l	#1,%%d0\n"
-		     "bne.b	1b\n"
-		     "movec	%2,%%cacr\n"
-		     : : "a" (paddr), "r" (len),
-			 "r" (shadow_cacr),
-			 "i" (CF_CACR_SPA)
-		     : "a0", "d0");
-}
-
-/**
- * cf_cache_flush_range - Push dirty data/inst cache in range out and invalidate
- * @vstart - starting virtual address
- * @vend: ending virtual address
- *
- * Push the any dirty data/instr lines starting at paddr for len bytes and
- * invalidate those lines.
+extern void cache_clear(unsigned long paddr, int len);
+/*
+ * push any dirty cache in the specified memory range.
+ * It starts at the physical address specified for
+ * the given number of bytes.
  */
-static inline void cf_cache_flush_range(unsigned long vstart, unsigned long vend)
-{
-	int len;
-
-	/* align on set boundary */
-	vstart &= 0xfffffff0;
-	vend = PAGE_ALIGN((vend + (CACHE_LINE_SIZE-1))) & 0xfffffff0;
-	len = vend - vstart;
-	if (len == 0)
-		return;
-	vstart = __pa(vstart);
-	vend = vstart + len;
-
-	asm volatile("nop\n"
-		     "move%.l   %2,%%d0\n"
-		     "or%.l	%3,%%d0\n"
-		     "movec	%%d0,%%cacr\n"
-		     "move%.l	%0,%%a0\n"
-		     "move%.l	%1,%%a1\n"
-		     "1:\n"
-		     "cpushl	%%bc,(%%a0)\n"
-		     "lea	0x10(%%a0),%%a0\n"
-		     "cmpa%.l	%%a0,%%a1\n"
-		     "bne.b	1b\n"
-		     "movec	%2,%%cacr\n"
-		     : /* no return */
-		     : "a" (vstart), "a" (vend),
-		       "r" (shadow_cacr),
-		       "i" (CF_CACR_SPA)
-		     : "a0", "a1", "d0");
-}
+extern void cache_push(unsigned long paddr, int len);
 
-/**
- * cf_dcache_flush_range - Push dirty data cache in range out and invalidate
- * @vstart - starting virtual address
- * @vend: ending virtual address
- *
- * Push the any dirty data lines starting at paddr for len bytes and
- * invalidate those lines.
+/*
+ * push and invalidate pages in the specified user virtual
+ * memory range.
  */
-static inline void cf_dcache_flush_range(unsigned long vstart, unsigned long vend)
-{
-	/* align on set boundary */
-	vstart &= 0xfffffff0;
-	vend = (vend + (CACHE_LINE_SIZE-1)) & 0xfffffff0;
-
-	asm volatile("nop\n"
-		     "move%.l   %2,%%d0\n"
-		     "or%.l	%3,%%d0\n"
-		     "movec	%%d0,%%cacr\n"
-		     "move%.l	%0,%%a0\n"
-		     "move%.l	%1,%%a1\n"
-		     "1:\n"
-		     "cpushl	%%dc,(%%a0)\n"
-		     "lea	0x10(%%a0),%%a0\n"
-		     "cmpa%.l	%%a0,%%a1\n"
-		     "bne.b	1b\n"
-		     "movec	%2,%%cacr\n"
-		     : /* no return */
-		     : "a" (__pa(vstart)), "a" (__pa(vend)),
-		       "r" (shadow_cacr),
-		       "i" (CF_CACR_SPA)
-		     : "a0", "a1", "d0");
-}
+extern void cache_push_v(unsigned long vaddr, int len);
 
-/**
- * cf_icache_flush_range - Push dirty inst cache in range out and invalidate
- * @vstart - starting virtual address
- * @vend: ending virtual address
- *
- * Push the any dirty instr lines starting at paddr for len bytes and
- * invalidate those lines.  This should just be an invalidate since you
- * shouldn't be able to have dirty instruction cache.
- */
-static inline void cf_icache_flush_range(unsigned long vstart, unsigned long vend)
-{
-	/* align on set boundary */
-	vstart &= 0xfffffff0;
-	vend = (vend + (CACHE_LINE_SIZE-1)) & 0xfffffff0;
-
-	asm volatile("nop\n"
-		     "move%.l   %2,%%d0\n"
-		     "or%.l	%3,%%d0\n"
-		     "movec	%%d0,%%cacr\n"
-		     "move%.l	%0,%%a0\n"
-		     "move%.l	%1,%%a1\n"
-		     "1:\n"
-		     "cpushl	%%ic,(%%a0)\n"
-		     "lea	0x10(%%a0),%%a0\n"
-		     "cmpa%.l	%%a0,%%a1\n"
-		     "bne.b	1b\n"
-		     "movec	%2,%%cacr\n"
-		     : /* no return */
-		     : "a" (__pa(vstart)), "a" (__pa(vend)),
-		       "r" (shadow_cacr),
-		       "i" (CF_CACR_SPA)
-		     : "a0", "a1", "d0");
-}
+/* This is needed whenever the virtual mapping of the current
+   process changes.  */
 
 /**
  * flush_cache_mm - Flush an mm_struct
@@ -343,6 +100,8 @@ static inline void flush_cache_mm(struct
 
 #define flush_cache_dup_mm(mm)	flush_cache_mm(mm)
 
+#define flush_cache_all()		flush_bcache()
+
 /**
  * flush_cache_range - Flush a cache range
  * @vma: vma struct
@@ -356,7 +115,8 @@ static inline void flush_cache_range(str
 	unsigned long start, unsigned long end)
 {
 	if (vma->vm_mm == current->mm)
-		cf_cache_flush_range(start, end);
+		flush_bcache();
+//		cf_cache_flush_range(start, end);
 }
 
 /**
@@ -372,76 +132,113 @@ static inline void flush_cache_page(stru
 	unsigned long vmaddr, unsigned long pfn)
 {
 	if (vma->vm_mm == current->mm)
-		cf_cache_flush_range(vmaddr, vmaddr+PAGE_SIZE);
+		flush_bcache();
+//		cf_cache_flush_range(vmaddr, vmaddr+PAGE_SIZE);
 }
 
-/**
- * __flush_page_to_ram - Push a page out of the cache
- * @vaddr: Virtual address at start of page
- *
- * Push the page at kernel virtual address *vaddr* and clear
- * the icache.
- */
-static inline void __flush_page_to_ram(void *vaddr)
-{
-	asm volatile("nop\n"
-		     "move%.l   %2,%%d0\n"
-		     "or%.l	%3,%%d0\n"
-		     "movec	%%d0,%%cacr\n"
-		     "move%.l	%0,%%d0\n"
-		     "and%.l	#0xfffffff0,%%d0\n"
-		     "move%.l	%%d0,%%a0\n"
-		     "move%.l	%1,%%d0\n"
-		     "1:\n"
-		     "cpushl	%%bc,(%%a0)\n"
-		     "lea	0x10(%%a0),%%a0\n"
-		     "subq%.l	#1,%%d0\n"
-		     "bne.b	1b\n"
-		     "movec	%2,%%cacr\n"
-		     : : "a" (__pa(vaddr)), "i" (PAGE_SIZE / CACHE_LINE_SIZE),
-			 "r" (shadow_cacr), "i" (CF_CACR_SPA)
-		     : "a0", "d0");
+/* Push the page at kernel virtual address and clear the icache */
+/* RZ: use cpush %bc instead of cpush %dc, cinv %ic */
+#define flush_page_to_ram(page) __flush_page_to_ram((void *) page_address(page))
+extern inline void __flush_page_to_ram(void *address)
+{
+  unsigned long set;
+  unsigned long start_set;
+  unsigned long end_set;
+  unsigned long addr = (unsigned long) address;
+
+  addr &= ~(PAGE_SIZE - 1); /* round down to page start address */
+
+  start_set = addr & _ICACHE_SET_MASK;
+  end_set = (addr + PAGE_SIZE-1) & _ICACHE_SET_MASK;
+
+  if (start_set > end_set) {
+    /* from the begining to the lowest address */
+    for (set = 0; set <= end_set; set += (0x10 - 3)) {
+      asm volatile("cpushl %%bc,(%0)\n"
+                   "\taddq%.l #1,%0\n"
+                   "\tcpushl %%bc,(%0)\n"
+                   "\taddq%.l #1,%0\n"
+                   "\tcpushl %%bc,(%0)\n"
+                   "\taddq%.l #1,%0\n"
+                   "\tcpushl %%bc,(%0)" : "=a" (set) : "a" (set));
+    }
+    /* next loop will finish the cache ie pass the hole */
+    end_set = LAST_ICACHE_ADDR;    
+  }
+  for (set = start_set; set <= end_set; set += (0x10 - 3)) {
+    asm volatile("cpushl %%bc,(%0)\n"
+                 "\taddq%.l #1,%0\n"
+                 "\tcpushl %%bc,(%0)\n"
+                 "\taddq%.l #1,%0\n"
+                 "\tcpushl %%bc,(%0)\n"
+                 "\taddq%.l #1,%0\n"
+                 "\tcpushl %%bc,(%0)" : "=a" (set) : "a" (set));
+  }
+}
+
+/* Use __flush_page_to_ram() for flush_dcache_page all values are same - MW */
+#define flush_dcache_page(page)			\
+	__flush_page_to_ram((void *) page_address(page))
+#define flush_icache_page(vma,pg)		\
+	__flush_page_to_ram((void *) page_address(pg))
+#define flush_icache_user_range(adr,len)	do { } while (0)
+/* NL */
+#define flush_icache_user_page(vma,page,addr,len)	do { } while (0)
+
+/* Push n pages at kernel virtual address and clear the icache */
+/* RZ: use cpush %bc instead of cpush %dc, cinv %ic */
+extern inline void flush_icache_range (unsigned long address,
+				       unsigned long endaddr)
+{
+  unsigned long set;
+  unsigned long start_set;
+  unsigned long end_set;
+
+  start_set = address & _ICACHE_SET_MASK;
+  end_set = endaddr & _ICACHE_SET_MASK;
+
+  if (start_set > end_set) {
+    /* from the begining to the lowest address */
+    for (set = 0; set <= end_set; set += (0x10 - 3)) {
+      asm volatile("cpushl %%ic,(%0)\n"
+                   "\taddq%.l #1,%0\n"
+                   "\tcpushl %%ic,(%0)\n"
+                   "\taddq%.l #1,%0\n"
+                   "\tcpushl %%ic,(%0)\n"
+                   "\taddq%.l #1,%0\n"
+                   "\tcpushl %%ic,(%0)" : "=a" (set) : "a" (set));
+    }
+    /* next loop will finish the cache ie pass the hole */
+    end_set = LAST_ICACHE_ADDR;    
+  }
+  for (set = start_set; set <= end_set; set += (0x10 - 3)) {
+    asm volatile("cpushl %%ic,(%0)\n"
+                 "\taddq%.l #1,%0\n"
+                 "\tcpushl %%ic,(%0)\n"
+                 "\taddq%.l #1,%0\n"
+                 "\tcpushl %%ic,(%0)\n"
+                 "\taddq%.l #1,%0\n"
+                 "\tcpushl %%ic,(%0)" : "=a" (set) : "a" (set));
+  }
 }
 
-/*
- * Various defines for the kernel.
- */
-
-extern void cache_clear(unsigned long paddr, int len);
-extern void cache_push(unsigned long paddr, int len);
-extern void flush_icache_range(unsigned long address, unsigned long endaddr);
-
-#define flush_cache_all()			flush_bcache()
-#define flush_cache_vmap(start, end)		flush_bcache()
-#define flush_cache_vunmap(start, end)		flush_bcache()
-
-#define flush_dcache_range(vstart, vend)	cf_dcache_flush_range(vstart, vend)
-#define flush_dcache_page(page)			__flush_page_to_ram(page_address(page))
-#define flush_dcache_mmap_lock(mapping)		do { } while (0)
-#define flush_dcache_mmap_unlock(mapping)	do { } while (0)
-
-#define flush_icache_page(vma, page)		__flush_page_to_ram(page_address(page))
-
-/**
- * copy_to_user_page - Copy memory to user page
- */
 static inline void copy_to_user_page(struct vm_area_struct *vma,
 				     struct page *page, unsigned long vaddr,
 				     void *dst, void *src, int len)
 {
 	memcpy(dst, src, len);
-	cf_cache_flush(page_to_phys(page), PAGE_SIZE);
+	flush_icache_user_page(vma, page, vaddr, len);
 }
-
-/**
- * copy_from_user_page - Copy memory from user page
- */
 static inline void copy_from_user_page(struct vm_area_struct *vma,
 				       struct page *page, unsigned long vaddr,
 				       void *dst, void *src, int len)
 {
-	cf_cache_flush(page_to_phys(page), PAGE_SIZE);
 	memcpy(dst, src, len);
 }
 
+#define flush_cache_vmap(start, end)		flush_cache_all()
+#define flush_cache_vunmap(start, end)		flush_cache_all()
+#define flush_dcache_mmap_lock(mapping)		do { } while (0)
+#define flush_dcache_mmap_unlock(mapping)	do { } while (0)
+
 #endif /* M68K_CF_CACHEFLUSH_H */
--- a/include/asm-m68k/cf_pgalloc.h
+++ b/include/asm-m68k/cf_pgalloc.h
@@ -1,13 +1,9 @@
 #ifndef M68K_CF_PGALLOC_H
 #define M68K_CF_PGALLOC_H
 
-/* JKM -- added -- needed? */
-#include <linux/highmem.h>
-
 #include <asm/coldfire.h>
 #include <asm/page.h>
 #include <asm/cf_tlbflush.h>
-/* JKM -- added -- needed? */
 #include <asm/cf_cacheflush.h>
 
 extern inline void pte_free_kernel(pte_t *pte)
@@ -41,6 +37,7 @@ extern inline pmd_t *pmd_alloc_kernel(pg
 
 #define pmd_populate(mm, pmd, page) (pmd_val(*pmd) = \
 	(unsigned long)(page_address(page)))
+
 #define pmd_populate_kernel(mm, pmd, pte) (pmd_val(*pmd) = (unsigned long)(pte))
 
 static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *page)
--- a/include/asm-m68k/cf_pgtable.h
+++ b/include/asm-m68k/cf_pgtable.h
@@ -341,7 +341,7 @@ static inline pte_t pgoff_to_pte(unsigne
 #define __pte_to_swp_entry(pte)	((swp_entry_t) { pte_val(pte) })
 #define __swp_entry_to_pte(x)	(__pte((x).val))
 
-#define pmd_page(pmd)		virt_to_page(__pmd_page(pmd))
+#define pmd_page(pmd)		(pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
 
 #define pte_offset_map(pmdp, address) ((pte_t *)__pmd_page(*pmdp) +	\
 				       __pte_offset(address))
--- a/include/asm-m68k/cfcache.h
+++ b/include/asm-m68k/cfcache.h
@@ -87,6 +87,12 @@
 #define CACHE_SETS 0x0200		/* 512 sets */
 #define CACHE_WAYS 0x0004		/* 4 way */
 
+/* in for the old cpushl caching code */
+#define _DCACHE_SET_MASK ((DCACHE_SIZE/64-1)<<CACHE_WAYS)
+#define _ICACHE_SET_MASK ((ICACHE_SIZE/64-1)<<CACHE_WAYS)
+#define LAST_DCACHE_ADDR _DCACHE_SET_MASK
+#define LAST_ICACHE_ADDR _ICACHE_SET_MASK
+
 #define CACHE_DISABLE_MODE	(CF_CACR_DCINVA+	\
 				 CF_CACR_BCINVA+	\
 				 CF_CACR_ICINVA)
--- a/include/asm-m68k/page.h
+++ b/include/asm-m68k/page.h
@@ -123,13 +123,21 @@ extern unsigned long m68k_memoffset;
 #if defined(CONFIG_COLDFIRE)
 static inline unsigned long ___pa(void *vaddr)
 {
+#if CONFIG_SDRAM_BASE != PAGE_OFFSET
 	return (((unsigned long)vaddr & 0x0fffffff) + CONFIG_SDRAM_BASE);
+#else
+	return (unsigned long)vaddr;
+#endif
 }
 #define __pa(vaddr)	___pa((void *)(vaddr))
 
 static inline void *__va(unsigned long paddr)
 {
+#if CONFIG_SDRAM_BASE != PAGE_OFFSET
 	return (void *)((paddr & 0x0fffffff) + PAGE_OFFSET);
+#else
+	return (void *)paddr;
+#endif
 }
 
 #else
--- a/include/asm-m68k/page_offset.h
+++ b/include/asm-m68k/page_offset.h
@@ -1,16 +1,15 @@
+/*
+ * Page and physical memory maps.
+ */
+#if defined(CONFIG_SUN3)
+#define PAGE_OFFSET_RAW		0x0E000000
+
+#elif defined(CONFIG_M54455) || defined(CONFIG_M547X_8X)
+#define	PHYS_OFFSET		CONFIG_SDRAM_BASE
+#define PAGE_OFFSET_RAW		(PHYS_OFFSET)
+/* #define PAGE_OFFSET_RAW		0xC0000000 */
 
-/* This handles the memory map.. */
-#if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
+#else
+/* default */
 #define PAGE_OFFSET_RAW		0x00000000
-#elif defined(CONFIG_SUN3)
-#define PAGE_OFFSET_RAW		0x0E000000
-#else /* CONFIG_COLDFIRE */
-#if defined(CONFIG_M54455)
-#define PAGE_OFFSET_RAW		0xC0000000
-#define	PHYS_OFFSET		0x40000000
-#elif defined(CONFIG_M547X_8X)
-#define PAGE_OFFSET_RAW		0xC0000000
-#define	PHYS_OFFSET		0x00000000
 #endif
-#endif
-