summaryrefslogtreecommitdiff
path: root/target/linux/lantiq/patches-2.6.39/110-falcon_board.patch
blob: 58f1479d7a0e6260a99e3eb0b8381f81531fb952 (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
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
--- /dev/null
+++ b/arch/mips/lantiq/falcon/Kconfig
@@ -0,0 +1,11 @@
+if SOC_FALCON
+
+menu "Mips Machine"
+
+config LANTIQ_MACH_EASY98000
+	bool "Easy98000"
+	default y
+
+endmenu
+
+endif
--- /dev/null
+++ b/arch/mips/lantiq/falcon/Makefile
@@ -0,0 +1,4 @@
+obj-y := clk-falcon.o devices.o gpio.o prom.o sysctrl.o reset.o
+obj-y += softdog_vpe.o
+obj-$(CONFIG_LANTIQ_MACH_EASY98000) += addon-easy98000.o
+obj-$(CONFIG_LANTIQ_MACH_EASY98000) += mach-easy98000.o
--- /dev/null
+++ b/arch/mips/lantiq/falcon/clk-falcon.c
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ *
+ * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
+ */
+
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include <asm/time.h>
+#include <asm/irq.h>
+#include <asm/div64.h>
+
+#include <lantiq_soc.h>
+
+#include <falcon.h>
+#include <gpon_reg_base.h>
+#include <sys1_reg.h>
+
+static struct gpon_reg_sys1 * const pSYS1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
+
+unsigned int
+ltq_get_io_region_clock(void)
+{
+	return 200000000; /* 200 MHz */
+}
+EXPORT_SYMBOL(ltq_get_io_region_clock);
+
+unsigned int
+ltq_get_cpu_hz(void)
+{
+	if ((ltq_r32(&pSYS1->cpu0cc) & CPU0CC_CPUDIV) == CPU0CC_CPUDIV_SELFHALF)
+		return 200000000; /* 200 MHz */
+	else
+		return 400000000; /* 400 MHz */
+}
+EXPORT_SYMBOL(ltq_get_cpu_hz);
+
+unsigned int
+ltq_get_fpi_hz(void)
+{
+	return 100000000;
+}
+EXPORT_SYMBOL(ltq_get_fpi_hz);
--- /dev/null
+++ b/arch/mips/lantiq/falcon/devices.c
@@ -0,0 +1,254 @@
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/mtd/physmap.h>
+#include <linux/kernel.h>
+#include <linux/reboot.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/etherdevice.h>
+#include <linux/reboot.h>
+#include <linux/time.h>
+#include <linux/io.h>
+#include <linux/gpio.h>
+#include <linux/leds.h>
+#include <linux/spi/spi.h>
+#include <linux/mtd/nand.h>
+
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+
+#include <lantiq.h>
+
+#include <falcon/falcon_irq.h>
+#include <falcon/gpon_reg_base.h>
+#include <falcon/ebu_reg.h>
+#include <falcon/sys1_reg.h>
+#include <falcon/sys_eth_reg.h>
+
+#include <falcon/sysctrl.h>
+
+#include "devices.h"
+
+unsigned char ltq_ethaddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+EXPORT_SYMBOL(ltq_ethaddr);
+
+static int __init
+falcon_set_ethaddr(char *str)
+{
+	sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
+		&ltq_ethaddr[0], &ltq_ethaddr[1], &ltq_ethaddr[2],
+		&ltq_ethaddr[3], &ltq_ethaddr[4], &ltq_ethaddr[5]);
+	return 0;
+}
+__setup("ethaddr=", falcon_set_ethaddr);
+
+/* asc ports */
+static struct resource falcon_asc0_resources[] =
+{
+	MEM_RES("asc0",GPON_ASC0_BASE,GPON_ASC0_END),
+	IRQ_RES("tx",INT_NUM_IM3_IRL0),
+	IRQ_RES("rx",INT_NUM_IM3_IRL0+1),
+	IRQ_RES("err",INT_NUM_IM3_IRL0+2),
+};
+
+static struct resource falcon_asc1_resources[] =
+{
+	MEM_RES("asc1",GPON_ASC1_BASE,GPON_ASC1_END),
+	IRQ_RES("tx",INT_NUM_IM3_IRL0+8),
+	IRQ_RES("rx",INT_NUM_IM3_IRL0+9),
+	IRQ_RES("err",INT_NUM_IM3_IRL0+10),
+};
+
+void __init falcon_register_asc(int port)
+{
+	switch (port) {
+	case 0:
+		platform_device_register_simple("ltq_asc", 0,
+			falcon_asc0_resources, ARRAY_SIZE(falcon_asc0_resources));
+		break;
+	case 1:
+		platform_device_register_simple("ltq_asc", 1,
+			falcon_asc1_resources, ARRAY_SIZE(falcon_asc1_resources));
+		break;
+	default:
+		break;
+	}
+}
+
+/* nor flash */
+static struct resource ltq_nor_resource =
+	MEM_RES("nor",LTQ_FLASH_START,LTQ_FLASH_START + LTQ_FLASH_MAX - 1);
+
+static struct platform_device ltq_nor = {
+	.name			= "ltq_nor",
+	.resource		= &ltq_nor_resource,
+	.num_resources	= 1,
+};
+
+void __init falcon_register_nor(struct physmap_flash_data *data)
+{
+	ltq_nor.dev.platform_data = data;
+	platform_device_register(&ltq_nor);
+}
+
+/* spi flash */
+static struct resource ltq_spi_resources[] = {
+	MEM_RES("ebu", GPON_EBU_BASE, GPON_EBU_END),
+	MEM_RES("sys1", GPON_SYS1_BASE, GPON_SYS1_END)
+};
+
+static struct platform_device ltq_spi = {
+	.name			= "falcon_spi",
+	.resource		= ltq_spi_resources,
+	.num_resources		= ARRAY_SIZE(ltq_spi_resources)
+};
+
+void __init falcon_register_spi_flash(struct spi_board_info *data)
+{
+	spi_register_board_info(data, 1);
+	platform_device_register(&ltq_spi);
+}
+
+/* nand flash */
+static struct gpon_reg_ebu __iomem *membase_ebu;
+static const char *part_probes[] = { "cmdlinepart", NULL };
+
+static int falcon_nand_ready(struct mtd_info *mtd)
+{
+	u32 modcon = __raw_readl(&membase_ebu->modcon);
+
+	return (((modcon & (MODCON_STS|MODCON_STSEDGE)) ==
+						(MODCON_STS|MODCON_STSEDGE)));
+}
+
+/* address lines used for NAND control signals */
+#define NAND_ADDR_ALE		(1<<16)
+#define NAND_ADDR_CLE		(1<<17)
+
+static void falcon_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
+{
+	struct nand_chip *this = mtd->priv;
+	unsigned long nandaddr = (unsigned long) this->IO_ADDR_W;
+
+	if (ctrl & NAND_CTRL_CHANGE) {
+		nandaddr &= ~(NAND_ADDR_ALE | NAND_ADDR_CLE);
+
+		if (ctrl & NAND_CLE)
+			nandaddr |= NAND_ADDR_CLE;
+		if (ctrl & NAND_ALE)
+			nandaddr |= NAND_ADDR_ALE;
+
+		this->IO_ADDR_W = (void __iomem *) nandaddr;
+	}
+
+	if (cmd != NAND_CMD_NONE)
+		writeb(cmd, this->IO_ADDR_W);
+}
+
+static struct platform_nand_data falcon_flash_nand_data = {
+	.chip = {
+		.nr_chips		= 1,
+		.chip_delay		= 25,
+		.part_probe_types 	= part_probes,
+	},
+	.ctrl = {
+		.cmd_ctrl 		= falcon_hwcontrol,
+		.dev_ready		= falcon_nand_ready,
+	}
+};
+
+static struct resource ltq_nand_resources[] = {
+	MEM_RES("nand", LTQ_FLASH_START, LTQ_FLASH_START + LTQ_FLASH_MAX - 1),
+	MEM_RES("ebu", GPON_EBU_BASE, GPON_EBU_END),
+};
+
+static struct platform_device ltq_flash_nand = {
+	.name		= "gen_nand",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(ltq_nand_resources),
+	.resource	= ltq_nand_resources,
+	.dev		= {
+		.platform_data = &falcon_flash_nand_data,
+	},
+};
+
+void __init falcon_register_nand(void)
+{
+	membase_ebu = ioremap_nocache(ltq_nand_resources[1].start,
+			resource_size(&ltq_nand_resources[1]));
+
+	if (membase_ebu)
+		platform_device_register(&ltq_flash_nand);
+}
+
+/* watchdog */
+static struct resource falcon_wdt_resource =
+	MEM_RES("watchdog",GPON_WDT_BASE,GPON_WDT_END);
+
+void __init falcon_register_wdt(void)
+{
+	platform_device_register_simple("ltq_wdt", 0, &falcon_wdt_resource, 1);
+}
+
+/* gpio */
+#define DECLARE_GPIO_RES(port) \
+static struct resource falcon_gpio ## port ## _resources[] = { \
+	MEM_RES("gpio"#port,GPON_GPIO ## port ## _BASE,GPON_GPIO ## port ## _END), \
+	MEM_RES("padctrl"#port,GPON_PADCTRL ## port ## _BASE,GPON_PADCTRL ## port ## _END), \
+	IRQ_RES("gpio_mux"#port,FALCON_IRQ_GPIO_P ## port ) \
+}
+DECLARE_GPIO_RES(0);
+DECLARE_GPIO_RES(1);
+DECLARE_GPIO_RES(2);
+#ifdef REGISTER_ALL_GPIO_PORTS
+#if NR_IRQS < 328
+#error NR_IRQS to low for all gpio irqs
+#endif
+DECLARE_GPIO_RES(3);
+DECLARE_GPIO_RES(4);
+#endif
+
+void __init falcon_register_gpio(void)
+{
+	platform_device_register_simple("falcon_gpio", 0,
+		falcon_gpio0_resources, ARRAY_SIZE(falcon_gpio0_resources));
+	platform_device_register_simple("falcon_gpio", 1,
+		falcon_gpio1_resources, ARRAY_SIZE(falcon_gpio1_resources));
+	platform_device_register_simple("falcon_gpio", 2,
+		falcon_gpio2_resources, ARRAY_SIZE(falcon_gpio2_resources));
+	sys1_hw_activate(ACTS_PADCTRL1 | ACTS_P1);
+	sys_eth_hw_activate(SYS_ETH_ACTS_PADCTRL0 | SYS_ETH_ACTS_PADCTRL2 |
+		SYS_ETH_ACTS_P0 | SYS_ETH_ACTS_P2);
+
+#ifdef REGISTER_ALL_GPIO_PORTS
+	/* optional gpio ports: not registered,
+	   as the pins are EBU specific and always used by linux */
+	platform_device_register_simple("falcon_gpio", 3,
+		falcon_gpio3_resources, ARRAY_SIZE(falcon_gpio3_resources));
+	platform_device_register_simple("falcon_gpio", 4,
+		falcon_gpio4_resources, ARRAY_SIZE(falcon_gpio4_resources));
+	sys1_hw_activate(ACTS_PADCTRL3 | ACTS_PADCTRL4 | ACTS_P3 | ACTS_P4);
+#endif
+}
+
+static struct resource falcon_i2c_resources[] = {
+	MEM_RES("i2c", GPON_I2C_BASE,GPON_I2C_END),
+	IRQ_RES("i2c_lb", FALCON_IRQ_I2C_LBREQ),
+	IRQ_RES("i2c_b", FALCON_IRQ_I2C_BREQ),
+	IRQ_RES("i2c_err", FALCON_IRQ_I2C_I2C_ERR),
+	IRQ_RES("i2c_p", FALCON_IRQ_I2C_I2C_P),
+};
+
+void __init falcon_register_i2c(void)
+{
+	platform_device_register_simple("i2c-falcon", 0,
+		falcon_i2c_resources, ARRAY_SIZE(falcon_i2c_resources));
+	sys1_hw_activate(ACTS_I2C_ACT);
+}
+
+void __init falcon_register_crypto(void)
+{
+	platform_device_register_simple("ltq_falcon_deu", 0, NULL, 0);
+}
--- /dev/null
+++ b/arch/mips/lantiq/falcon/devices.h
@@ -0,0 +1,22 @@
+#ifndef _FALCON_DEVICES_H__
+#define _FALCON_DEVICES_H__
+
+#include <linux/mtd/physmap.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
+
+extern void __init falcon_register_asc(int port);
+extern void __init falcon_register_i2c(void);
+extern void __init falcon_register_spi_flash(struct spi_board_info *data);
+extern void __init falcon_register_gpio(void);
+extern void __init falcon_register_nor(struct physmap_flash_data *data);
+extern void __init falcon_register_nand(void);
+extern void __init falcon_register_wdt(void);
+extern void __init falcon_register_crypto(void);
+
+#define IRQ_RES(resname,irq) {.name=resname,.start=(irq),.flags=IORESOURCE_IRQ}
+#define MEM_RES(resname,adr_start,adr_end) \
+	{ .name=resname, .flags=IORESOURCE_MEM, \
+	  .start=((adr_start)&~KSEG1),.end=((adr_end)&~KSEG1) }
+
+#endif
--- /dev/null
+++ b/arch/mips/lantiq/falcon/prom.c
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ *
+ * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
+ */
+
+#include <linux/module.h>
+#include <linux/clk.h>
+#include <asm/bootinfo.h>
+#include <asm/time.h>
+
+#include <lantiq_soc.h>
+
+#include <falcon.h>
+
+#include <falcon/gpon_reg_base.h>
+#include <falcon/status_reg.h>
+#include <falcon/sys1_reg.h>
+
+#include "../prom.h"
+
+static struct gpon_reg_status * const pSTATUS = (struct gpon_reg_status *)GPON_STATUS_BASE;
+
+#define SOC_FALCON		"Falcon"
+
+void __init
+ltq_soc_setup(void)
+{
+	/* not used */
+}
+
+void __init
+ltq_soc_detect(struct ltq_soc_info *i)
+{
+	i->partnum = (ltq_r32(&pSTATUS->chipid) & STATUS_CHIPID_PARTNR_MASK) >> STATUS_CHIPID_PARTNR_OFFSET;
+	i->rev = (ltq_r32(&pSTATUS->chipid) & STATUS_CHIPID_VERSION_MASK) >> STATUS_CHIPID_VERSION_OFFSET;
+	switch (i->partnum)
+	{
+	case SOC_ID_FALCON:
+		i->name = SOC_FALCON;
+		i->type = SOC_TYPE_FALCON;
+		break;
+
+	default:
+		printk(KERN_ERR "unknown partnum : 0x%08X\n", i->partnum);
+		while(1) {	};
+		break;
+	}
+}
--- /dev/null
+++ b/arch/mips/lantiq/falcon/sysctrl.c
@@ -0,0 +1,381 @@
+/*
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * Copyright (C) 2010 Thomas Langer, Lantiq Deutschland
+ */
+
+#include <linux/cpu.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/pm.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/clk.h>
+#include <asm/reboot.h>
+
+#include <falcon/gpon_reg_base.h>
+#include <falcon/status_reg.h>
+#include <falcon/sys1_reg.h>
+#include <falcon/sys_eth_reg.h>
+#include <falcon/sys_gpe_reg.h>
+
+#include <falcon/sysctrl.h>
+
+/* mapping to linux hw-accessor routines */
+#define reg_r32(reg)			__raw_readl(reg)
+#define reg_w32(val, reg)		__raw_writel(val, reg)
+#define reg_w32_mask(clear, set, reg)	reg_w32((reg_r32(reg) & ~(clear)) | (set), reg)
+
+static struct gpon_reg_sys1 * const sys1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
+static struct gpon_reg_sys_eth * const sys_eth = (struct gpon_reg_sys_eth *)GPON_SYS_ETH_BASE;
+static struct gpon_reg_sys_gpe * const sys_gpe = (struct gpon_reg_sys_gpe *)GPON_SYS_GPE_BASE;
+static struct gpon_reg_status * const status = (struct gpon_reg_status *)GPON_STATUS_BASE;
+
+/**
+ * Activate the selected module(s)
+ * Enables the clock of the module and activates the module itself.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS1.ACT
+ * \return void
+ */
+void sys1_hw_activate(u32 mask)
+{
+	sys1_w32(mask, clken);
+	sys1_w32(mask, act);
+
+	while ( (sys1_r32(acts) & mask) != mask) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys1_hw_activate);
+
+/**
+ * Deactivate the selected module(s)
+ * Disables the clock of the module and deactivates the module itself.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS1.DEACT
+ * \return void
+ */
+void sys1_hw_deactivate(u32 mask)
+{
+	sys1_w32(mask, clkclr);
+	sys1_w32(mask, deact);
+
+	while ( (sys1_r32(acts) & mask) != 0) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys1_hw_deactivate);
+
+/**
+ * Clock enable for the selected module(s)
+ * Enables the clock of the module.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS1.CLKEN
+ * \return void
+ */
+void sys1_hw_clk_enable(u32 mask)
+{
+	sys1_w32(mask, clken);
+
+	while ( (sys1_r32(clks) & mask) != mask) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys1_hw_clk_enable);
+
+/**
+ * Clock disable for the selected module(s)
+ * disables the clock of the module.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS1.CLKCLR
+ * \return void
+ */
+void sys1_hw_clk_disable(u32 mask)
+{
+	sys1_w32(mask, clkclr);
+
+	while ( (sys1_r32(clks) & mask) != 0) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys1_hw_clk_disable);
+
+/**
+ * Reboots the selected module(s)
+ * Triggers the reboot of the module.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS1.RBT
+ * \return void
+ */
+void sys1_hw_activate_or_reboot(u32 mask)
+{
+	u32 acts = sys1_r32(acts);
+	/* is not already active? */
+	if ((~acts & mask) != 0)
+		sys1_hw_activate(~acts & mask);
+	sys1_w32(acts & mask, rbt);
+	while ( (sys1_r32(acts) & mask) != mask) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys1_hw_activate_or_reboot);
+
+/**
+ * Activate the selected module(s)
+ * Enables the clock of the module and activates the module itself.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_ETH.ACT
+ * \return void
+ */
+void sys_eth_hw_activate(u32 mask)
+{
+	sys_eth_w32(mask, clken);
+	sys_eth_w32(mask, act);
+
+	while ( (sys_eth_r32(acts) & mask) != mask) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_eth_hw_activate);
+
+/**
+ * Deactivate the selected module(s)
+ * Disables the clock of the module and deactivates the module itself.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_ETH.DEACT
+ * \return void
+ */
+void sys_eth_hw_deactivate(u32 mask)
+{
+	sys_eth_w32(mask, clkclr);
+	sys_eth_w32(mask, deact);
+
+	while ( (sys_eth_r32(acts) & mask) != 0) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_eth_hw_deactivate);
+
+/**
+ * Clock enable for the selected module(s)
+ * Enables the clock of the module.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_ETH.CLKEN
+ * \return void
+ */
+void sys_eth_hw_clk_enable(u32 mask)
+{
+	sys_eth_w32(mask, clken);
+
+	while ( (sys_eth_r32(clks) & mask) != mask) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_eth_hw_clk_enable);
+
+/**
+ * Clock disable for the selected module(s)
+ * disables the clock of the module.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_ETH.CLKCLR
+ * \return void
+ */
+void sys_eth_hw_clk_disable(u32 mask)
+{
+	sys_eth_w32(mask, clkclr);
+
+	while ( (sys_eth_r32(clks) & mask) != 0) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_eth_hw_clk_disable);
+
+/**
+ * Reboots the selected module(s)
+ * Triggers the reboot of the module.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_ETH.RBT
+ * \return void
+ */
+void sys_eth_hw_activate_or_reboot(u32 mask)
+{
+	u32 acts = sys_eth_r32(acts);
+	/* is not already active? */
+	if ((~acts & mask) != 0)
+		sys_eth_hw_activate(~acts & mask);
+	sys_eth_w32(acts & mask, rbt);
+	while ( (sys_eth_r32(acts) & mask) != mask) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_eth_hw_activate_or_reboot);
+
+static int gpe_clk_is_enabled(void)
+{
+	u32 rd_data;
+
+	rd_data = sys1_r32(infrac);
+	if (rd_data & (1<<(INFRAC_GP_OFFSET+1)))
+		return 1;
+	return 0;
+}
+
+static void enable_gpe_clk(void)
+{
+	u32 aeFreq;
+	u32 rd_data;
+	u32 rd_data_to_keep;
+	int i;
+
+	if (gpe_clk_is_enabled())
+		/* clock already active, no need to change here */
+		return;
+
+	if (status_r32(config) == 0)
+		aeFreq = 1; /* use 625MHz on unfused chip */
+	else
+		aeFreq = (status_r32(config) & STATUS_CONFIG_GPEFREQ_MASK) >> STATUS_CONFIG_GPEFREQ_OFFSET;
+	rd_data = sys1_r32(infrac);
+	/* clear gpe-fsel and enable bits */
+	rd_data_to_keep = rd_data & ~(7<<(INFRAC_GP_OFFSET+1));
+
+	/* set new fsel */
+	sys1_w32(rd_data_to_keep | (aeFreq<<(INFRAC_GP_OFFSET+2)), infrac);
+
+	for (i = 0; i <10; i++) /* wait 10 cycles */
+		{}
+
+	/* keep new fsel and enable */
+	sys1_w32(rd_data_to_keep | (aeFreq<<(INFRAC_GP_OFFSET+2)) |
+		(1<<(INFRAC_GP_OFFSET+1)), infrac);
+	for (i = 0; i <100; i++) /* wait 100 cycles */
+		{}
+}
+
+/**
+ * Activate the selected module(s)
+ * Enables the clock of the module and activates the module itself.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_GPE.ACT
+ * \return void
+ */
+void sys_gpe_hw_activate(u32 mask)
+{
+	enable_gpe_clk();
+	sys_gpe_w32(mask, clken);
+	sys_gpe_w32(mask, act);
+
+	while ( (sys_gpe_r32(acts) & mask) != mask) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_gpe_hw_activate);
+
+/**
+ * Deactivate the selected module(s)
+ * Disables the clock of the module and deactivates the module itself.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_GPE.DEACT
+ * \return void
+ */
+void sys_gpe_hw_deactivate(u32 mask)
+{
+	enable_gpe_clk();
+	sys_gpe_w32(mask, clkclr);
+	sys_gpe_w32(mask, deact);
+
+	while ( (sys_gpe_r32(acts) & mask) != 0) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_gpe_hw_deactivate);
+
+/**
+ * Clock enable for the selected module(s)
+ * Enables the clock of the module.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_GPE.CLKEN
+ * \return void
+ */
+void sys_gpe_hw_clk_enable(u32 mask)
+{
+	enable_gpe_clk();
+	sys_gpe_w32(mask, clken);
+
+	while ( (sys_gpe_r32(clks) & mask) != mask) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_gpe_hw_clk_enable);
+
+/**
+ * Clock disable for the selected module(s)
+ * disables the clock of the module.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_GPE.CLKCLR
+ * \return void
+ */
+void sys_gpe_hw_clk_disable(u32 mask)
+{
+	enable_gpe_clk();
+	sys_gpe_w32(mask, clkclr);
+
+	while ( (sys_gpe_r32(clks) & mask) != 0) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_gpe_hw_clk_disable);
+
+/**
+ * Reboots the selected module(s)
+ * Triggers the reboot of the module.
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_GPE.RBT
+ * \return void
+ */
+void sys_gpe_hw_activate_or_reboot(u32 mask)
+{
+	u32 acts;
+	enable_gpe_clk();
+	acts = sys_gpe_r32(acts);
+	/* is not already active? */
+	if ((~acts & mask) != 0)
+		sys_gpe_hw_activate(~acts & mask);
+	sys_gpe_w32(acts & mask, rbt);
+	while ( (sys_gpe_r32(acts) & mask) != mask) {
+		/*NOP;*/
+	};
+}
+EXPORT_SYMBOL(sys_gpe_hw_activate_or_reboot);
+
+/**
+ * Retrieve activation status of the selected hardware module(s)
+ *
+ * \param[in]   mask    bitmask of module(s), as for registers SYS_GPE.RBT
+ * \return int 1 - if hardware module(s) is activated (including clock)
+ */
+ int sys_gpe_hw_is_activated(u32 mask)
+{
+	if (gpe_clk_is_enabled() == 0)
+		return 0;
+
+	if ((sys_gpe_r32(clks) & mask) != mask)
+		return 0;
+
+	return ((sys_gpe_r32(acts) & mask) == mask);
+}
+EXPORT_SYMBOL(sys_gpe_hw_is_activated);
--- /dev/null
+++ b/arch/mips/lantiq/falcon/gpio.c
@@ -0,0 +1,463 @@
+/*
+ *   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.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *   Copyright (C) 2010 Thomas Langer, Lantiq Deutschland
+ */
+
+/**
+	TODO:
+		- add locking?
+		- provide mask of available pins per platform_data
+*/
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/seq_file.h>
+#include <linux/platform_device.h>
+#include <linux/uaccess.h>
+#include <linux/gpio.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/slab.h>
+
+#include <falcon.h>
+#include <falcon/falcon_irq.h>
+
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
+#define for_each_set_bit for_each_bit
+#endif
+
+#define gpio_r32(reg)			__raw_readl(reg)
+#define gpio_w32(val, reg)			__raw_writel(val, reg)
+#define gpio_w32_mask(clear, set, reg)	gpio_w32((gpio_r32(reg) & ~(clear)) | (set), reg)
+
+
+/** register structure for padctrl
+    (mainly needed for mux control) */
+typedef struct gpon_padctrl_s
+{
+	/** Multiplexer Control Register
+	    The value 0 (the reset-value) is always the default function corresponding to the pad's name. The value 1 selects always the GPIO functionality (if available). */
+	unsigned int muxc[32];
+	/** Pull Up Enable Register */
+	unsigned int puen; /* 0x00000080 */
+	/** Pull Down Enable Register */
+	unsigned int pden; /* 0x00000084 */
+	/** Slew Rate Control Register */
+	unsigned int src; /* 0x00000088 */
+	/** Drive Current Control Register */
+	unsigned int dcc; /* 0x0000008C */
+	/** Reserved */
+	unsigned int res_0[24]; /* 0x00000090 */
+	/** Pad Control Availability Register */
+	unsigned int avail; /* 0x000000F0 */
+} gpon_padctrl0_t;
+
+/** register structure for gpio port */
+typedef struct gpon_gpio_s
+{
+	/** Data Output Register
+	    Via this register the output values of the different bits can be set if they are switched as outputs. */
+	unsigned int out; /* 0x00000000 */
+	/** Data Input Register
+	    Via this register the input values of the different bits can be observed. */
+	unsigned int in; /* 0x00000004 */
+	/** Direction Register
+	    Via this register the input direction of the different bits can be determined. */
+	unsigned int dir; /* 0x00000008 */
+	/** Reserved */
+	unsigned int res_0[3]; /* 0x0000000C */
+	/** External Interrupt Control Register 0 */
+	unsigned int exintcr0; /* 0x00000018 */
+	/** External Interrupt Control Register 1 */
+	unsigned int exintcr1; /* 0x0000001C */
+	/** IRN Capture Register
+	    This register shows the currently active interrupt events masked with the corresponding enable bits of the IRNEN register. The interrupts can be acknowledged by a write operation. */
+	unsigned int irncr; /* 0x00000020 */
+	/** IRN Interrupt Control Register
+	    A write operation directly effects the interrupts. This can be used to trigger events under software control for testing purposes. A read operation returns the unmasked interrupt events. */
+	unsigned int irnicr; /* 0x00000024 */
+	/** IRN Interrupt Enable Register
+	    This register contains the enable (or mask) bits for the interrupts. Disabled interrupts are not visible in the IRNCR register and are not signalled via the interrupt line towards the controller. */
+	unsigned int irnen; /* 0x00000028 */
+	/** IRN Interrupt Configuration Register
+	    Configures the interrupts bitwise to be edge-senstivie or level-sensitive. */
+	unsigned int irncfg; /* 0x0000002C */
+	/** IRN Interrupt Enable Set Register
+	    The corresponding bit in the IRNEN register can be set with an atomic access. */
+	unsigned int irnenset; /* 0x00000030 */
+	/** IRN Interrupt Enable Clear Register
+	    The corresponding bit in the IRNEN register can be cleared with an atomic access. */
+	unsigned int irnenclr; /* 0x00000034 */
+	/** Reserved */
+	unsigned int res_1[2]; /* 0x00000038 */
+	/** Output Set Register
+	    This register can be used to set certain bits within the OUT register without touching the other bits. */
+	unsigned int outset; /* 0x00000040 */
+	/** Output Clear Register
+	    This register can be used to clear certain bits within the OUT register without touching the other bits. */
+	unsigned int outclr; /* 0x00000044 */
+	/** Direction Set Register
+	    This register can be used to set certain bits within the DIR register without touching the other bits. */
+	unsigned int dirset; /* 0x00000048 */
+	/** Direction Clear Register
+	    This register can be used to clear certain bits within the DIR register without touching the other bits. */
+	unsigned int dirclr; /* 0x0000004C */
+} gpon_gpio_t;
+
+struct falcon_gpio_port {
+	struct gpio_chip gpio_chip;
+	gpon_padctrl0_t __iomem *pad;
+	gpon_gpio_t __iomem *port;
+	struct resource	*pad_req;   /* resources requested */
+	struct resource *port_req;
+	unsigned int irq_base;
+	unsigned int chained_irq;
+};
+
+static int gpio_exported = 0;
+static int __init gpio_export_setup(char *str)
+{
+	get_option(&str, &gpio_exported);
+	return 1;
+}
+__setup("gpio_exported=", gpio_export_setup);
+
+static inline struct falcon_gpio_port *to_falcon_gpio_port(struct gpio_chip *chip)
+{
+	return container_of(chip, struct falcon_gpio_port, gpio_chip);
+}
+
+static int falcon_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
+{
+	struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
+	gpio_w32(1<<offset, &gpio_port->port->dirclr);
+	return 0;
+}
+
+static int falcon_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, int value)
+{
+	struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
+	gpio_w32(1<<offset, &gpio_port->port->dirset);
+	return 0;
+}
+
+static void falcon_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
+{
+	struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
+	if (value)
+		gpio_w32(1<<offset, &gpio_port->port->outset);
+	else
+		gpio_w32(1<<offset, &gpio_port->port->outclr);
+}
+
+static int falcon_gpio_get(struct gpio_chip *chip, unsigned int offset)
+{
+	struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
+	if ((gpio_r32(&gpio_port->port->dir) >> offset) & 1)
+		return (gpio_r32(&gpio_port->port->out) >> offset) & 1;
+	else
+		return (gpio_r32(&gpio_port->port->in) >> offset) & 1;
+}
+
+static int falcon_gpio_request(struct gpio_chip *chip, unsigned offset)
+{
+	struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
+	if ( (gpio_r32(&gpio_port->pad->avail) >> offset) & 1) {
+		if (gpio_r32(&gpio_port->pad->muxc[offset]) > 1)
+			return -EBUSY;
+		/* switch on gpio function */
+		gpio_w32(1, &gpio_port->pad->muxc[offset]);
+		return 0;
+	}
+
+	return -ENODEV;
+}
+
+static void falcon_gpio_free(struct gpio_chip *chip, unsigned offset)
+{
+	struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
+	if ( (gpio_r32(&gpio_port->pad->avail) >> offset) & 1) {
+		if (gpio_r32(&gpio_port->pad->muxc[offset]) > 1)
+			return;
+		/* switch off gpio function */
+		gpio_w32(0, &gpio_port->pad->muxc[offset]);
+	}
+}
+
+static int falcon_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
+{
+	struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
+	/* no checks: this functions is only registered with valid irq_base */
+	return gpio_port->irq_base + offset;
+}
+
+static void falcon_gpio_disable_irq(struct irq_data *d)
+{
+	struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
+	unsigned int offset = d->irq-gpio_port->irq_base;
+	gpio_w32(1<<offset, &gpio_port->port->irnenclr);
+}
+
+static void falcon_gpio_enable_irq(struct irq_data *d)
+{
+	struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
+	unsigned int offset = d->irq-gpio_port->irq_base;
+
+	if (gpio_r32(&gpio_port->pad->muxc[offset]) < 1) {
+		/* switch on gpio function */
+		gpio_w32(1, &gpio_port->pad->muxc[offset]);
+	}
+
+	gpio_w32(1<<offset, &gpio_port->port->irnenset);
+}
+
+static void falcon_gpio_ack_irq(struct irq_data *d)
+{
+	struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
+	unsigned int offset = d->irq-gpio_port->irq_base;
+	gpio_w32(1<<offset, &gpio_port->port->irncr);
+}
+
+static void falcon_gpio_mask_and_ack_irq(struct irq_data *d)
+{
+	struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
+	unsigned int offset = d->irq-gpio_port->irq_base;
+	gpio_w32(1<<offset, &gpio_port->port->irnenclr);
+	gpio_w32(1<<offset, &gpio_port->port->irncr);
+}
+
+static struct irq_chip falcon_gpio_irq_chip;
+static int falcon_gpio_irq_type(struct irq_data *d, unsigned int type)
+{
+	struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
+	unsigned int offset = d->irq-gpio_port->irq_base;
+	unsigned int mask = 1 << offset;
+
+	if ((type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_NONE)
+		return 0;
+
+	if ((type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) != 0) {
+		/* level triggered */
+		gpio_w32_mask(0, mask, &gpio_port->port->irncfg);
+		irq_set_chip_and_handler_name(d->irq,
+				&falcon_gpio_irq_chip, handle_level_irq, "mux");
+	} else {
+		/* edge triggered */
+		gpio_w32_mask(mask, 0, &gpio_port->port->irncfg);
+		irq_set_chip_and_handler_name(d->irq,
+				&falcon_gpio_irq_chip, handle_simple_irq, "mux");
+	}
+
+	if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
+		gpio_w32_mask(mask, 0, &gpio_port->port->exintcr0);
+		gpio_w32_mask(0, mask, &gpio_port->port->exintcr1);
+	} else {
+		if ((type & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_LEVEL_HIGH)) != 0) {
+			/* positive logic: rising edge, high level */
+			gpio_w32_mask(mask, 0, &gpio_port->port->exintcr0);
+		} else {
+			/* negative logic: falling edge, low level */
+			gpio_w32_mask(0, mask, &gpio_port->port->exintcr0);
+		}
+		gpio_w32_mask(mask, 0, &gpio_port->port->exintcr1);
+	}
+
+	return gpio_direction_input(gpio_port->gpio_chip.base + offset);
+}
+
+static void falcon_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
+{
+	struct falcon_gpio_port *gpio_port = irq_desc_get_handler_data(desc);
+	unsigned long irncr;
+	int offset;
+
+	irncr = gpio_r32(&gpio_port->port->irncr);
+	/* acknowledge interrupt */
+	gpio_w32(irncr, &gpio_port->port->irncr);
+
+	desc->irq_data.chip->irq_ack(&desc->irq_data);
+
+	for_each_set_bit(offset, &irncr, gpio_port->gpio_chip.ngpio)
+		generic_handle_irq(gpio_port->irq_base + offset);
+}
+
+static struct irq_chip falcon_gpio_irq_chip = {
+	.name = "gpio_irq_mux",
+	.irq_mask = falcon_gpio_disable_irq,
+	.irq_unmask = falcon_gpio_enable_irq,
+	.irq_ack = falcon_gpio_ack_irq,
+	.irq_mask_ack = falcon_gpio_mask_and_ack_irq,
+	.irq_set_type = falcon_gpio_irq_type,
+};
+
+static struct irqaction gpio_cascade = {
+	.handler = no_action,
+	.flags = IRQF_DISABLED,
+	.name = "gpio_cascade",
+};
+
+static int falcon_gpio_probe(struct platform_device *pdev)
+{
+	struct falcon_gpio_port *gpio_port;
+	int ret, i;
+	struct resource *gpiores, *padres;
+	int irq;
+
+	gpiores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	padres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	irq = platform_get_irq(pdev, 0);
+	if (!gpiores || !padres)
+		return -ENODEV;
+
+	gpio_port = kzalloc(sizeof(*gpio_port), GFP_KERNEL);
+	if (gpio_port == NULL)
+		return -ENOMEM;
+
+	gpio_port->gpio_chip.label = "falcon-gpio";
+	gpio_port->gpio_chip.direction_input = falcon_gpio_direction_input;
+	gpio_port->gpio_chip.direction_output = falcon_gpio_direction_output;
+	gpio_port->gpio_chip.get = falcon_gpio_get;
+	gpio_port->gpio_chip.set = falcon_gpio_set;
+	gpio_port->gpio_chip.request = falcon_gpio_request;
+	gpio_port->gpio_chip.free = falcon_gpio_free;
+	gpio_port->gpio_chip.base = 100 * pdev->id;
+	gpio_port->gpio_chip.ngpio = 32;
+	gpio_port->gpio_chip.dev = &pdev->dev;
+	gpio_port->gpio_chip.exported = gpio_exported;
+
+	gpio_port->port_req = request_mem_region(gpiores->start,
+		resource_size(gpiores), pdev->name);
+	gpio_port->pad_req = request_mem_region(padres->start,
+		resource_size(padres), pdev->name);
+	if (!gpio_port->port_req || !gpio_port->pad_req) {
+		dev_err(&pdev->dev, "cannot claim register area\n");
+		ret = -EIO;
+		goto err;
+	}
+
+	gpio_port->port = ioremap_nocache(gpiores->start,
+		resource_size(gpiores));
+	gpio_port->pad = ioremap_nocache(padres->start,
+		resource_size(padres));
+	if (!gpio_port->port || !gpio_port->pad) {
+		dev_err(&pdev->dev, "Could not map io ranges\n");
+		ret = -ENOMEM;
+		goto err;
+	}
+
+	if (irq>0) {
+		/*
+		 * irq_chip support
+		 */
+		gpio_port->gpio_chip.to_irq = falcon_gpio_to_irq;
+		gpio_port->irq_base = INT_NUM_EXTRA_START + 32 * pdev->id;
+
+		for (i = 0; i < 32; i++) {
+			irq_set_chip_and_handler_name(gpio_port->irq_base + i,
+				&falcon_gpio_irq_chip, handle_simple_irq, "mux");
+			irq_set_chip_data(gpio_port->irq_base + i, gpio_port);
+			/* FIXME: set default cfg to level triggered */
+			//gpio_w32_mask(0, 1<<i, &gpio_port->port->irncfg);
+			/* set to negative logic (falling edge, low level) */
+			gpio_w32_mask(0, 1<<i, &gpio_port->port->exintcr0);
+		}
+
+		gpio_port->chained_irq = irq;
+		setup_irq(irq, &gpio_cascade);
+		irq_set_handler_data(irq, gpio_port);
+		irq_set_chained_handler(irq, falcon_gpio_irq_handler);
+	}
+
+	ret = gpiochip_add(&gpio_port->gpio_chip);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Could not register gpiochip %d, %d\n",
+			pdev->id, ret);
+		goto err;
+	}
+	platform_set_drvdata(pdev, gpio_port);
+	return ret;
+
+err:
+	dev_err(&pdev->dev, "Error in gpio_probe %d, %d\n", pdev->id, ret);
+	if (gpio_port->port_req)
+		release_resource(gpio_port->port_req);
+	if (gpio_port->pad_req)
+		release_resource(gpio_port->pad_req);
+
+	if (gpio_port->port)
+		iounmap(gpio_port->port);
+	if (gpio_port->pad)
+		iounmap(gpio_port->pad);
+	kfree(gpio_port);
+	return ret;
+}
+
+static int falcon_gpio_remove(struct platform_device *pdev)
+{
+	struct falcon_gpio_port *gpio_port = platform_get_drvdata(pdev);
+	int ret;
+
+	ret = gpiochip_remove(&gpio_port->gpio_chip);
+	if (gpio_port->port_req)
+		release_resource(gpio_port->port_req);
+	if (gpio_port->pad_req)
+		release_resource(gpio_port->pad_req);
+	if (gpio_port->port)
+		iounmap(gpio_port->port);
+	if (gpio_port->pad)
+		iounmap(gpio_port->pad);
+	if (ret == 0)
+		kfree(gpio_port);
+
+	return ret;
+}
+
+static struct platform_driver falcon_gpio_driver = {
+	.probe = falcon_gpio_probe,
+	.remove = __devexit_p(falcon_gpio_remove),
+	.driver = {
+		.name = "falcon_gpio",
+		.owner = THIS_MODULE,
+	},
+};
+
+int __init falcon_gpio_init(void)
+{
+	int ret;
+
+	printk(KERN_INFO "FALC(tm) ON GPIO Driver, (C) 2011 Lantiq Deutschland Gmbh\n");
+	ret = platform_driver_register(&falcon_gpio_driver);
+	if (ret)
+		pr_err( "falcon_gpio: Error registering platform driver!");
+	return ret;
+}
+
+void __exit falcon_gpio_exit(void)
+{
+	platform_driver_unregister(&falcon_gpio_driver);
+}
+
+int gpio_to_irq(unsigned int gpio)
+{
+	return __gpio_to_irq(gpio);
+}
+EXPORT_SYMBOL(gpio_to_irq);
+
+module_init(falcon_gpio_init);
+module_exit(falcon_gpio_exit);
--- /dev/null
+++ b/arch/mips/include/asm/mach-lantiq/falcon/falcon.h
@@ -0,0 +1,16 @@
+/*
+ *   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.
+ *
+ *   Copyright (C) 2005 infineon
+ *   Copyright (C) 2010 John Crispin <blogic@openwrt.org>
+ */
+
+#ifdef CONFIG_SOC_FALCON
+
+#include <lantiq_soc.h>
+#include <falcon/gpon_reg_base.h>
+
+#endif
--- /dev/null
+++ b/arch/mips/lantiq/falcon/reset.c
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ *
+ * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
+ */
+
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/pm.h>
+#include <asm/reboot.h>
+#include <linux/module.h>
+
+#include <falcon.h>
+#include <falcon/gpon_reg_base.h>
+#include <falcon/status_reg.h>
+#include <falcon/sys1_reg.h>
+
+static struct gpon_reg_sys1 * const pSYS1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
+
+#define WDT_PW1			0x00BE0000
+#define WDT_PW2			0x00DC0000
+#define WDT_REG_BASE		(KSEG1 | 0x1F8803F0)
+
+/* This function is used by the watchdog driver */
+int ltq_reset_cause(void)
+{
+	return 0;
+}
+EXPORT_SYMBOL_GPL(ltq_reset_cause);
+
+static void
+ltq_machine_restart(char *command)
+{
+	printk(KERN_NOTICE "System restart\n");
+	local_irq_disable();
+	ltq_w32(0, (void*)0xBF200000); /* reset Bootreg RVEC */
+#if 0
+	ltq_w32(RBT_CPU_TRIG, &pSYS1->rbt);
+#else
+	/* use workaround via watchdog timer */
+	ltq_w32(WDT_PW1, (void*)WDT_REG_BASE);
+	ltq_w32(WDT_PW2 |
+		(0x3 << 26) | /* PWL */
+		(0x2 << 24) | /* CLKDIV */
+		(0x1 << 31) | /* enable */
+		(1), /* reload */
+		(void*)WDT_REG_BASE);
+#endif
+	for(;;);
+}
+
+static void
+ltq_machine_halt(void)
+{
+	printk(KERN_NOTICE "System halted.\n");
+	local_irq_disable();
+	for(;;);
+}
+
+static void
+ltq_machine_power_off(void)
+{
+	printk(KERN_NOTICE "Please turn off the power now.\n");
+	local_irq_disable();
+	for(;;);
+}
+
+static int __init
+mips_reboot_setup(void)
+{
+	_machine_restart = ltq_machine_restart;
+	_machine_halt = ltq_machine_halt;
+	pm_power_off = ltq_machine_power_off;
+	return 0;
+}
+
+arch_initcall(mips_reboot_setup);
--- /dev/null
+++ b/arch/mips/lantiq/falcon/mach-easy98000.c
@@ -0,0 +1,263 @@
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/gpio.h>
+#include <linux/gpio_buttons.h>
+#include <linux/etherdevice.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/physmap.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/dm9000.h>
+#include <linux/i2c.h>
+#include <linux/i2c-gpio.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/spi_gpio.h>
+#include <linux/spi/eeprom.h>
+
+#include "../machtypes.h"
+
+#include "devices.h"
+#include "dev-leds-gpio.h"
+
+#define EASY98000_GPIO_LED_0 9
+#define EASY98000_GPIO_LED_1 10
+#define EASY98000_GPIO_LED_2 11
+#define EASY98000_GPIO_LED_3 12
+#define EASY98000_GPIO_LED_4 13
+#define EASY98000_GPIO_LED_5 14
+
+extern unsigned char ltq_ethaddr[6];
+
+#ifdef CONFIG_MTD_PARTITIONS
+static struct mtd_partition easy98000_nor_partitions[] =
+{
+	{
+		.name	= "uboot",
+		.offset	= 0x0,
+		.size	= 0x40000,
+	},
+	{
+		.name	= "uboot_env",
+		.offset	= 0x40000,
+		.size	= 0x40000,	/* 2 sectors for redundant env. */
+	},
+	{
+		.name	= "linux",
+		.offset	= 0x80000,
+		.size	= 0xF80000,	/* map only 16 MiB */
+	},
+};
+#endif
+
+static struct physmap_flash_data easy98000_nor_flash_data = {
+#ifdef CONFIG_MTD_PARTITIONS
+	.nr_parts	= ARRAY_SIZE(easy98000_nor_partitions),
+	.parts		= easy98000_nor_partitions,
+#endif
+};
+
+#ifdef CONFIG_MTD_PARTITIONS
+static struct flash_platform_data easy98000_spi_flash_platform_data = {
+	.name = "sflash",
+	.parts = easy98000_nor_partitions,
+	.nr_parts = ARRAY_SIZE(easy98000_nor_partitions)
+};
+#endif
+
+static struct spi_board_info easy98000_spi_flash_data __initdata = {
+	.modalias		= "m25p80",
+	.bus_num		= 0,
+	.chip_select		= 0,
+	.max_speed_hz		= 10 * 1000 * 1000,
+	.mode			= SPI_MODE_3,
+#ifdef CONFIG_MTD_PARTITIONS
+	.platform_data		= &easy98000_spi_flash_platform_data
+#endif
+};
+
+static struct gpio_led easy98000_leds_gpio[] __initdata = {
+	{
+		.name		= "easy98000:green:0",
+		.gpio		= EASY98000_GPIO_LED_0,
+		.active_low	= 0,
+	}, {
+		.name		= "easy98000:green:1",
+		.gpio		= EASY98000_GPIO_LED_1,
+		.active_low	= 0,
+	}, {
+		.name		= "easy98000:green:2",
+		.gpio		= EASY98000_GPIO_LED_2,
+		.active_low	= 0,
+	}, {
+		.name		= "easy98000:green:3",
+		.gpio		= EASY98000_GPIO_LED_3,
+		.active_low	= 0,
+	}, {
+		.name		= "easy98000:green:4",
+		.gpio		= EASY98000_GPIO_LED_4,
+		.active_low	= 0,
+	}, {
+		.name		= "easy98000:green:5",
+		.gpio		= EASY98000_GPIO_LED_5,
+		.active_low	= 0,
+	}
+};
+
+#define CONFIG_DM9000_BASE		0x14000000
+#define DM9000_IO			(CONFIG_DM9000_BASE + 3)
+#define DM9000_DATA			(CONFIG_DM9000_BASE + 1)
+
+static struct dm9000_plat_data dm9000_plat_data = {
+	.flags = DM9000_PLATF_8BITONLY,
+	//.dev_addr = { }, /* possibility to provide an ethernet address for the chip */
+};
+
+static struct resource dm9000_resources[] = {
+	MEM_RES("dm9000_io", DM9000_IO, DM9000_IO),
+	MEM_RES("dm9000_data", DM9000_DATA, DM9000_DATA),
+	[2] = {
+		/* with irq (210 -> gpio 110) the driver is very unreliable */
+		.start	= -1,		/* use polling */
+		.end	= -1,
+		.flags	= IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
+	},
+};
+
+static struct platform_device dm9000_platform = {
+	.name = "dm9000",
+	.id = 0,
+	.num_resources	= ARRAY_SIZE(dm9000_resources),
+	.resource	= dm9000_resources,
+	.dev = {
+		.platform_data = (void *) &dm9000_plat_data,
+	}
+};
+
+extern int easy98000_addon_has_dm9000(void);
+static void __init register_davicom(void)
+{
+	if (!easy98000_addon_has_dm9000())
+		return;
+
+	if (!is_valid_ether_addr(ltq_ethaddr))
+		random_ether_addr(dm9000_plat_data.dev_addr);
+	else {
+		memcpy(dm9000_plat_data.dev_addr, ltq_ethaddr, 6);
+		/* change to "Locally Administered Address" */
+		dm9000_plat_data.dev_addr[0] |= 0x2;
+	}
+	platform_device_register(&dm9000_platform);
+}
+
+static struct i2c_gpio_platform_data easy98000_i2c_gpio_data = {
+	.sda_pin	= 107,
+	.scl_pin	= 108,
+};
+
+static struct platform_device easy98000_i2c_gpio_device = {
+	.name		= "i2c-gpio",
+	.id		= 0,
+	.dev = {
+		.platform_data	= &easy98000_i2c_gpio_data,
+	}
+};
+
+void __init register_easy98000_cpld(void)
+{
+	platform_device_register_simple("easy98000_cpld_led", 0, NULL, 0);
+	platform_device_register_simple("easy98000_addon", 0, NULL, 0);
+}
+
+/* setup gpio based spi bus/device for access to the eeprom on the board */
+#define SPI_GPIO_MRST	102
+#define SPI_GPIO_MTSR	103
+#define SPI_GPIO_CLK	104
+#define SPI_GPIO_CS0	105
+#define SPI_GPIO_CS1	106
+#define SPI_GPIO_BUS_NUM	1
+
+static struct spi_gpio_platform_data easy98000_spi_gpio_data = {
+	.sck		= SPI_GPIO_CLK,
+	.mosi		= SPI_GPIO_MTSR,
+	.miso		= SPI_GPIO_MRST,
+	.num_chipselect	= 2,
+};
+
+static struct platform_device easy98000_spi_gpio_device = {
+	.name			= "spi_gpio",
+	.id			= SPI_GPIO_BUS_NUM,
+	.dev.platform_data	= &easy98000_spi_gpio_data,
+};
+
+static struct spi_eeprom at25160n = {
+	.byte_len	= 16 * 1024 / 8,
+	.name		= "at25160n",
+	.page_size	= 32,
+	.flags		= EE_ADDR2,
+};
+
+static struct spi_board_info easy98000_spi_gpio_devices __initdata = {
+	.modalias		= "at25",
+	.bus_num		= SPI_GPIO_BUS_NUM,
+	.max_speed_hz		= 1000 * 1000,
+	.mode			= SPI_MODE_3,
+	.chip_select		= 1,
+	.controller_data	= (void *) SPI_GPIO_CS1,
+	.platform_data		= &at25160n,
+};
+
+static void __init easy98000_spi_gpio_init(void)
+{
+	spi_register_board_info(&easy98000_spi_gpio_devices, 1);
+	platform_device_register(&easy98000_spi_gpio_device);
+}
+
+static void __init easy98000_init_common(void)
+{
+	falcon_register_asc(0);
+	falcon_register_gpio();
+	falcon_register_wdt();
+	falcon_register_i2c();
+	platform_device_register(&easy98000_i2c_gpio_device);
+	register_davicom();
+	ltq_add_device_leds_gpio(-1, ARRAY_SIZE(easy98000_leds_gpio),
+					easy98000_leds_gpio);
+	register_easy98000_cpld();
+	falcon_register_crypto();
+	easy98000_spi_gpio_init();
+}
+
+static void __init easy98000_init(void)
+{
+	easy98000_init_common();
+	falcon_register_nor(&easy98000_nor_flash_data);
+}
+
+static void __init easy98000sf_init(void)
+{
+	easy98000_init_common();
+	falcon_register_spi_flash(&easy98000_spi_flash_data);
+}
+
+static void __init easy98000nand_init(void)
+{
+	easy98000_init_common();
+	falcon_register_nand();
+}
+
+MIPS_MACHINE(LANTIQ_MACH_EASY98000,
+			"EASY98000",
+			"EASY98000 Eval Board",
+			easy98000_init);
+
+MIPS_MACHINE(LANTIQ_MACH_EASY98000SF,
+			"EASY98000SF",
+			"EASY98000 Eval Board (Serial Flash)",
+			easy98000sf_init);
+
+MIPS_MACHINE(LANTIQ_MACH_EASY98000NAND,
+			"EASY98000NAND",
+			"EASY98000 Eval Board (NAND Flash)",
+			easy98000nand_init);
--- /dev/null
+++ b/arch/mips/lantiq/falcon/softdog_vpe.c
@@ -0,0 +1,109 @@
+/*
+** =============================================================================
+** FILE NAME     : softdog_vpe.c
+** MODULES       : LXDB
+** DATE          : 24-03-2008
+** AUTHOR        : LXDB Team
+** DESCRIPTION   : This header file contains the code for the watchdog
+**                 implentation on vpe1 side.
+** REFERENCES    :
+** COPYRIGHT     : Copyright (c) 2008
+**                 Am Campeon 1-12, 85579 Neubiberg, Germany
+** Any use of this software is subject to the conclusion of a respective
+** License agreement. Without such a License agreement no rights to the
+** software are granted
+**
+** HISTORY       :
+** $Date   $Author    $Comment
+** 24-03-2008   LXDB    Initial version
+** ============================================================================
+*/
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/types.h>
+#include <linux/timer.h>
+#include <linux/reboot.h>
+#include <linux/init.h>
+#include <linux/jiffies.h>
+
+#include <falcon/vpe.h>
+
+static unsigned long last_wdog_value;
+static unsigned long vpe1_wdog_cleared;
+
+static unsigned long vpe1_wdog_dead;
+static void watchdog_vpe0_fire(unsigned long); /* Called when vpe0 timer expires */
+static void keep_alive_vpe0(unsigned long);
+VPE_SW_WDOG_RESET reset_local_fn;
+
+
+static struct timer_list watchdog_vpe0_ticktock =
+                TIMER_INITIALIZER(watchdog_vpe0_fire, 0, 0);
+
+static void watchdog_vpe0_fire (unsigned long flags)
+{
+	volatile unsigned long *wdog_ctr_value;
+	wdog_ctr_value = (void*)vpe1_wdog_ctr;
+	if (*wdog_ctr_value == last_wdog_value) { /* VPE1 watchdog expiry handling */
+		vpe1_sw_wdog_stop(flags);
+		vpe1_wdog_dead++;
+		printk(KERN_DEBUG "VPE1 watchdog reset handler called\n");
+	/* Call the reset handler function */
+		reset_local_fn(flags);
+	} else { /* Everything is OK on vpe1 side. Continue. */
+		last_wdog_value = *wdog_ctr_value;
+		vpe1_wdog_cleared++;
+		keep_alive_vpe0(flags);
+	}
+}
+
+int32_t vpe1_sw_wdog_register_reset_handler (VPE_SW_WDOG_RESET reset_fn)
+{
+	reset_local_fn = (VPE_SW_WDOG_RESET)reset_fn;
+	return 0;
+}
+
+static void keep_alive_vpe0(unsigned long flags)
+{
+	mod_timer(&watchdog_vpe0_ticktock, jiffies+ vpe1_wdog_timeout );
+}
+
+unsigned long vpe1_sw_wdog_start(unsigned long flags)
+{
+	volatile unsigned long *wdog_ctr_value;
+	wdog_ctr_value = (void*)vpe1_wdog_ctr;
+	*wdog_ctr_value = 0;
+	last_wdog_value = 0;
+	keep_alive_vpe0(flags);
+	return 0;
+}
+
+unsigned long vpe1_sw_wdog_stop(unsigned long flags)
+{
+	del_timer(&watchdog_vpe0_ticktock);
+	return 0;
+}
+
+static int __init watchdog_vpe1_init(void)
+{
+	/* Nothing to be done here */
+	return 0;
+}
+
+static void __exit watchdog_vpe1_exit(void)
+{
+	unsigned long flags=0;
+	vpe1_sw_wdog_stop(flags);
+}
+
+module_init(watchdog_vpe1_init);
+module_exit(watchdog_vpe1_exit);
+
+EXPORT_SYMBOL(vpe1_sw_wdog_register_reset_handler);
+EXPORT_SYMBOL(vpe1_sw_wdog_start);
+EXPORT_SYMBOL(vpe1_sw_wdog_stop);
+
+MODULE_AUTHOR("LXDB");
+MODULE_DESCRIPTION("Software Watchdog For VPE1");
+MODULE_LICENSE("GPL");
--- /dev/null
+++ b/arch/mips/include/asm/mach-lantiq/falcon/vpe.h
@@ -0,0 +1,44 @@
+/*
+ *   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.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *   Copyright (C) 2005 infineon
+ *   Copyright (C) 2007 John Crispin <blogic@openwrt.org>
+ *
+ */
+#ifndef _IFXMIPS_VPE_H__
+#define _IFXMIPS_VPE_H__
+
+/* For the explanation of the APIs please refer the section "MT APRP Kernel
+ * Programming" in AR9 SW Architecture Specification
+ */
+int32_t vpe1_sw_start(void* sw_start_addr, uint32_t tcmask, uint32_t flags);
+int32_t vpe1_sw_stop(uint32_t flags);
+uint32_t vpe1_get_load_addr (uint32_t flags);
+uint32_t vpe1_get_max_mem (uint32_t flags);
+
+int32_t vpe1_set_boot_param(char *field, char *value, char flags);
+int32_t vpe1_get_boot_param(char *field, char **value, char flags);
+
+/* Watchdog APIs */
+extern unsigned long vpe1_wdog_ctr;
+extern unsigned long vpe1_wdog_timeout;
+
+unsigned long vpe1_sw_wdog_start(unsigned long);
+unsigned long vpe1_sw_wdog_stop(unsigned long);
+
+typedef int (*VPE_SW_WDOG_RESET)(unsigned long wdog_cleared_ok_count);
+int32_t vpe1_sw_wdog_register_reset_handler(VPE_SW_WDOG_RESET reset_fn);
+
+#endif
--- a/arch/mips/lantiq/Kconfig
+++ b/arch/mips/lantiq/Kconfig
@@ -16,8 +16,12 @@ config SOC_XWAY
 	bool "XWAY"
 	select SOC_TYPE_XWAY
 	select HW_HAS_PCI
+
+config SOC_FALCON
+	bool "FALCON"
 endchoice
 
 source "arch/mips/lantiq/xway/Kconfig"
+source "arch/mips/lantiq/falcon/Kconfig"
 
 endif
--- a/arch/mips/lantiq/Makefile
+++ b/arch/mips/lantiq/Makefile
@@ -9,3 +9,4 @@ obj-y := irq.o setup.o clk.o prom.o devi
 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
 
 obj-$(CONFIG_SOC_TYPE_XWAY) += xway/
+obj-$(CONFIG_SOC_FALCON) += falcon/
--- a/arch/mips/lantiq/Platform
+++ b/arch/mips/lantiq/Platform
@@ -6,3 +6,4 @@ platform-$(CONFIG_LANTIQ)	+= lantiq/
 cflags-$(CONFIG_LANTIQ)		+= -I$(srctree)/arch/mips/include/asm/mach-lantiq
 load-$(CONFIG_LANTIQ)		= 0xffffffff80002000
 cflags-$(CONFIG_SOC_TYPE_XWAY)	+= -I$(srctree)/arch/mips/include/asm/mach-lantiq/xway
+cflags-$(CONFIG_SOC_FALCON)	+= -I$(srctree)/arch/mips/include/asm/mach-lantiq/falcon
--- a/arch/mips/lantiq/machtypes.h
+++ b/arch/mips/lantiq/machtypes.h
@@ -15,6 +15,11 @@ enum lantiq_mach_type {
 	LTQ_MACH_GENERIC = 0,
 	LTQ_MACH_EASY50712,	/* Danube evaluation board */
 	LTQ_MACH_EASY50601,	/* Amazon SE evaluation board */
+
+	/* FALCON */
+	LANTIQ_MACH_EASY98000,		/* Falcon Eval Board, NOR Flash */
+	LANTIQ_MACH_EASY98000SF,	/* Falcon Eval Board, Serial Flash */
+	LANTIQ_MACH_EASY98000NAND,	/* Falcon Eval Board, NAND Flash */
+	LANTIQ_MACH_EASY98020,		/* Falcon Reference Board */
 };
 
 #endif
--- /dev/null
+++ b/arch/mips/lantiq/falcon/addon-easy98000.c
@@ -0,0 +1,212 @@
+/*
+ *  EASY98000 CPLD Addon driver
+ *
+ *  Copyright (C) 2011 Thomas Langer <thomas.langer@lantiq.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License version 2  as published
+ *  by the Free Software Foundation.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+struct easy98000_reg_cpld {
+	u16 cmdreg1;		/* 0x1 */
+	u16 cmdreg0;		/* 0x0 */
+	u16 idreg0;		/* 0x3 */
+	u16 resreg;		/* 0x2 */
+	u16 intreg;		/* 0x5 */
+	u16 idreg1;		/* 0x4 */
+	u16 ledreg;		/* 0x7 */
+	u16 pcmconconfig;	/* 0x6 */
+	u16 res0;		/* 0x9 */
+	u16 ethledreg;		/* 0x8 */
+	u16 res1[4];		/* 0xa-0xd */
+	u16 cpld1v;		/* 0xf */
+	u16 cpld2v;		/* 0xe */
+};
+static struct easy98000_reg_cpld * const cpld =
+	(struct easy98000_reg_cpld *)(KSEG1 | 0x17c00000);
+#define cpld_r8(reg) (__raw_readw(&cpld->reg) & 0xFF)
+#define cpld_w8(val, reg) __raw_writew((val) & 0xFF, &cpld->reg)
+
+int easy98000_addon_has_dm9000(void)
+{
+	if ((cpld_r8(idreg0) & 0xF) == 1)
+		return 1;
+	return 0;
+}
+
+#if defined(CONFIG_PROC_FS)
+typedef void (*cpld_dump) (struct seq_file *s);
+struct proc_entry {
+	char *name;
+	void *callback;
+};
+
+static int cpld_proc_show ( struct seq_file *s, void *p )
+{
+	cpld_dump dump = s->private;
+
+	if ( dump != NULL )
+		dump(s);
+
+	return 0;
+}
+
+static int cpld_proc_open ( struct inode *inode, struct file *file )
+{
+	return single_open ( file, cpld_proc_show, PDE(inode)->data );
+}
+
+static void cpld_versions_get ( struct seq_file *s )
+{
+	seq_printf(s, "CPLD1: V%d\n", cpld_r8(cpld1v));
+	seq_printf(s, "CPLD2: V%d\n", cpld_r8(cpld2v));
+}
+
+static void cpld_ebu_module_get ( struct seq_file *s )
+{
+	u8 addon_id;
+
+	addon_id = cpld_r8(idreg0) & 0xF;
+	switch (addon_id) {
+	case 0xF: /* nothing connected */
+		break;
+	case 1:
+		seq_printf(s, "Ethernet Controller module (dm9000)\n");
+		break;
+	default:
+		seq_printf(s, "Unknown EBU module (EBU_ID=0x%02X)\n", addon_id);
+		break;
+	}
+}
+
+static void cpld_xmii_module_get ( struct seq_file *s )
+{
+	u8 addon_id;
+	char *mod = NULL;
+
+	addon_id = cpld_r8(idreg1) & 0xF;
+	switch (addon_id) {
+	case 0xF:
+		mod = "no module";
+		break;
+	case 0x1:
+		mod = "RGMII module";
+		break;
+	case 0x4:
+		mod = "GMII MAC Mode (XWAY TANTOS-3G)";
+		break;
+	case 0x6:
+		mod = "TMII MAC Mode (XWAY TANTOS-3G)";
+		break;
+	case 0x8:
+		mod = "GMII PHY module";
+		break;
+	case 0x9:
+		mod = "MII PHY module";
+		break;
+	case 0xA:
+		mod = "RMII PHY module";
+		break;
+	default:
+		break;
+	}
+	if (mod)
+		seq_printf(s, "%s\n", mod);
+	else
+		seq_printf(s, "unknown xMII module (xMII_ID=0x%02X)\n", addon_id);
+}
+
+static struct proc_entry proc_entries[] = {
+	{"versions",	cpld_versions_get},
+	{"ebu",		cpld_ebu_module_get},
+	{"xmii",	cpld_xmii_module_get},
+};
+
+static struct file_operations ops = {
+	.owner   = THIS_MODULE,
+	.open    = cpld_proc_open,
+	.read    = seq_read,
+	.llseek  = seq_lseek,
+	.release = single_release,
+};
+
+static void cpld_proc_entry_create(struct proc_dir_entry *parent_node,
+				   struct proc_entry *proc_entry)
+{
+	proc_create_data ( proc_entry->name, (S_IFREG | S_IRUGO), parent_node,
+			   &ops, proc_entry->callback);
+}
+
+static int cpld_proc_install(void)
+{
+	struct proc_dir_entry *driver_proc_node;
+
+	driver_proc_node = proc_mkdir("cpld", NULL);
+	if (driver_proc_node != NULL) {
+		int i;
+		for (i = 0; i < ARRAY_SIZE(proc_entries); i++)
+			cpld_proc_entry_create(driver_proc_node,
+					      &proc_entries[i]);
+	} else {
+		printk("cannot create proc entry");
+		return -1;
+	}
+	return 0;
+}
+#else
+static inline int cpld_proc_install(void) {}
+#endif
+
+static int easy98000_addon_probe(struct platform_device *pdev)
+{
+	return cpld_proc_install();
+}
+
+static int easy98000_addon_remove(struct platform_device *pdev)
+{
+#if defined(CONFIG_PROC_FS)
+	char buf[64];
+	int i;
+
+	for (i = 0; i < sizeof(proc_entries) / sizeof(proc_entries[0]); i++) {
+		sprintf(buf, "cpld/%s", proc_entries[i].name);
+		remove_proc_entry(buf, 0);
+	}
+	remove_proc_entry("cpld", 0);
+#endif
+	return 0;
+}
+
+static struct platform_driver easy98000_addon_driver = {
+	.probe = easy98000_addon_probe,
+	.remove = __devexit_p(easy98000_addon_remove),
+	.driver = {
+		.name = "easy98000_addon",
+		.owner = THIS_MODULE,
+	},
+};
+
+int __init easy98000_addon_init(void)
+{
+	return platform_driver_register(&easy98000_addon_driver);
+}
+
+void __exit easy98000_addon_exit(void)
+{
+	platform_driver_unregister(&easy98000_addon_driver);
+}
+
+module_init(easy98000_addon_init);
+module_exit(easy98000_addon_exit);