summaryrefslogtreecommitdiff
path: root/target/linux/storm/patches/008-serial.patch
blob: b7009af251967de541eb5eff759704363eb08997 (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
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
--- /dev/null
+++ b/drivers/serial/it8712.c
@@ -0,0 +1,858 @@
+/*
+ *  linux/drivers/char/serial_uart00.c
+ *
+ *  Driver for UART00 serial ports
+ *
+ *  Based on drivers/char/serial_amba.c, by ARM Limited &
+ *                                          Deep Blue Solutions Ltd.
+ *  Copyright 2001 Altera Corporation
+ *
+ * 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
+ *
+ *  $Id: it8712.c,v 1.2 2006/06/06 06:36:04 middle Exp $
+ *
+ */
+#include <linux/module.h>
+#include <linux/tty.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/serial.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+#include <asm/hardware.h>
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+#include <asm/bitops.h>
+#include <asm/sizes.h>
+
+#if defined(CONFIG_SERIAL_IT8712_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/serial_core.h>
+#include <asm/arch/sl2312.h>
+#include <asm/arch/int_ctrl.h>
+#include <asm/arch/it8712.h>
+#include "it8712.h"
+
+//#define DEBUG           1
+#define UART_NR		1
+
+#define SERIAL_IT8712_NAME	"ttySI"
+#define SERIAL_IT8712_MAJOR	204
+#define SERIAL_IT8712_MINOR	41      /* Temporary - will change in future */
+#define SERIAL_IT8712_NR	UART_NR
+#define UART_PORT_SIZE 0x50
+#define LPC_HOST_CONTINUE_MODE	0x00000040
+
+#define IT8712_NO_PORTS         UART_NR
+#define IT8712_ISR_PASS_LIMIT	256
+
+#define LPC_BUS_CTRL	*(unsigned int*)(IO_ADDRESS(SL2312_LPC_HOST_BASE + 4))
+#define LPC_BUS_STATUS	*(unsigned int*)(IO_ADDRESS(SL2312_LPC_HOST_BASE + 4))
+#define LPC_SERIAL_IRQ_CTRL	*(unsigned int*)(IO_ADDRESS(SL2312_LPC_HOST_BASE + 8))
+#define LPC_SERIAL_IRQ_STATUS	*(unsigned int*)(IO_ADDRESS(SL2312_LPC_HOST_BASE + 0x0c))
+#define LPC_SERIAL_IRQ_TRITYPE *(unsigned int*)(IO_ADDRESS(SL2312_LPC_HOST_BASE + 0x10))
+#define LPC_SERIAL_IRQ_POLARITY	*(unsigned int*)(IO_ADDRESS(SL2312_LPC_HOST_BASE + 0x14))
+#define LPC_SERIAL_IRQ_ENABLE	*(unsigned int*)(IO_ADDRESS(SL2312_LPC_HOST_BASE + 0x18))
+
+
+
+
+/*
+ * Access macros for the SL2312 UARTs
+ */
+#define UART_GET_INT_STATUS(p)	(inb(((p)->membase+UART_IIR)) & 0x0F)  // interrupt identification
+#define UART_PUT_IER(p, c)      outb(c,((p)->membase+UART_IER))         // interrupt enable
+#define UART_GET_IER(p)         inb(((p)->membase+UART_IER))
+#define UART_PUT_CHAR(p, c)     outb(c,((p)->membase+UART_TX))         // transmitter holding
+#define UART_GET_CHAR(p)        inb(((p)->membase+UART_RX))            // receive buffer
+#define UART_GET_LSR(p)         inb(((p)->membase+UART_LSR))            // line status
+#define UART_GET_MSR(p)         inb(((p)->membase+UART_MSR))            // modem status
+#define UART_GET_MCR(p)         inb(((p)->membase+UART_MCR))            // modem control
+#define UART_PUT_MCR(p, c)      outb(c,((p)->membase+UART_MCR))
+#define UART_GET_LCR(p)         inb(((p)->membase+UART_LCR))       // mode control
+#define UART_PUT_LCR(p, c)      outb(c,((p)->membase+UART_LCR))
+#define UART_PUT_FCR(p, c)      outb(c,((p)->membase+UART_FCR))       // fifo control
+#define UART_GET_DIV_HI(p)	inb(((p)->membase+UART_DLM))
+#define UART_PUT_DIV_HI(p, c)	outb(c,((p)->membase+UART_DLM))
+#define UART_GET_DIV_LO(p)	inb(((p)->membase+UART_DLL))
+#define UART_PUT_DIV_LO(p, c)	outb(c,((p)->membase+UART_DLL))
+#define UART_PUT_MDR(p, c)      outb(c,UART_MDR((p)->membase))
+#define UART_RX_DATA(s)		((s) & UART_LSR_DR)
+#define UART_TX_READY(s)	((s) & UART_LSR_THRE)
+
+static void it8712_stop_tx(struct uart_port *port, u_int from_tty)
+{
+        unsigned int reg;
+
+        //printk("it8712 stop tx : \n");
+        reg = UART_GET_IER(port);
+        reg &= ~(UART_IER_THRI);
+	UART_PUT_IER(port, reg);
+}
+
+static void it8712_stop_rx(struct uart_port *port)
+{
+        unsigned int reg;
+
+        //printk("it8712 stop rx : \n");
+        reg = UART_GET_IER(port);
+        reg &= ~(UART_IER_RDI);
+	UART_PUT_IER(port, reg);
+
+}
+
+static void it8712_enable_ms(struct uart_port *port)
+{
+        unsigned int reg;
+
+        //printk("it8712 enable ms : \n");
+
+        reg = UART_GET_IER(port);
+        reg |= (UART_IER_MSI);
+	UART_PUT_IER(port, reg);
+
+}
+
+static void it8712_rx_chars(struct uart_port *port, struct pt_regs *regs)
+{
+	struct tty_struct *tty = port->info->tty;
+	unsigned int status, mask, ch, flg, ignored = 0;
+
+ //       printk("it8712_rx_chars : \n");
+	status = UART_GET_LSR(port);
+	while (UART_RX_DATA(status)) {
+
+		/*
+		 * We need to read rds before reading the
+		 * character from the fifo
+		 */
+		ch = UART_GET_CHAR(port);
+		port->icount.rx++;
+
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+			goto ignore_char;
+
+		flg = TTY_NORMAL;
+
+		/*
+		 * Note that the error handling code is
+		 * out of the main execution path
+		 */
+
+		if (status & (UART_LSR_OE|UART_LSR_PE|UART_LSR_FE|UART_LSR_BI|UART_LSR_DE))
+			goto handle_error;
+		if (uart_handle_sysrq_char(port, ch, regs))
+			goto ignore_char;
+
+	error_return:
+		*tty->flip.flag_buf_ptr++ = flg;
+		*tty->flip.char_buf_ptr++ = ch;
+		tty->flip.count++;
+	ignore_char:
+		status = UART_GET_LSR(port);
+	} // end of while
+out:
+	tty_flip_buffer_push(tty);
+	return;
+
+handle_error:
+	if (status & UART_LSR_BI) {
+		status &= ~(UART_LSR_FE);
+		port->icount.brk++;
+
+#ifdef SUPPORT_SYSRQ
+		if (uart_handle_break(port))
+			goto ignore_char;
+#endif
+	} else if (status & UART_LSR_PE)
+		port->icount.parity++;
+	else if (status & UART_LSR_FE)
+		port->icount.frame++;
+
+	if (status & UART_LSR_OE)
+		port->icount.overrun++;
+
+	if (status & port->ignore_status_mask) {
+		if (++ignored > 100)
+			goto out;
+		goto ignore_char;
+	}
+
+	mask = status & port->read_status_mask;
+
+	if (mask & UART_LSR_BI)
+		flg = TTY_BREAK;
+	else if (mask & UART_LSR_PE)
+		flg = TTY_PARITY;
+	else if (mask & UART_LSR_FE)
+		flg = TTY_FRAME;
+
+	if (status & UART_LSR_OE) {
+		/*
+		 * CHECK: does overrun affect the current character?
+		 * ASSUMPTION: it does not.
+		 */
+		*tty->flip.flag_buf_ptr++ = flg;
+		*tty->flip.char_buf_ptr++ = ch;
+		tty->flip.count++;
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+			goto ignore_char;
+		ch = 0;
+		flg = TTY_OVERRUN;
+	}
+#ifdef SUPPORT_SYSRQ
+	port->sysrq = 0;
+#endif
+	goto error_return;
+}
+
+static void it8712_tx_chars(struct uart_port *port)
+{
+        struct circ_buf *xmit = &port->info->xmit;
+	int count;
+
+	if (port->x_char) {
+		while(!(UART_GET_LSR(port)&UART_LSR_THRE));
+		UART_PUT_CHAR(port, port->x_char);
+		port->icount.tx++;
+		port->x_char = 0;
+
+		return;
+	}
+	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
+		it8712_stop_tx(port, 0);
+		return;
+	}
+
+	count = port->fifosize >> 1;
+	do {
+		while(!(UART_GET_LSR(port)&UART_LSR_THRE));
+		UART_PUT_CHAR(port, xmit->buf[xmit->tail]);
+		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+		port->icount.tx++;
+		if (uart_circ_empty(xmit))
+			break;
+	} while (--count > 0);
+
+	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+		uart_write_wakeup(port);
+
+	if (uart_circ_empty(xmit))
+		it8712_stop_tx(port, 0);
+}
+
+static void it8712_start_tx(struct uart_port *port, unsigned int tty_start)
+{
+        unsigned int reg;
+
+        //printk("it8712 start tx : \n");
+        reg = UART_GET_IER(port);
+        reg |= (UART_IER_THRI);
+	UART_PUT_IER(port, reg);
+	it8712_tx_chars(port);
+}
+
+static void it8712_modem_status(struct uart_port *port)
+{
+	unsigned int status;
+
+//        printk("it8712 modem status : \n");
+
+	status = UART_GET_MSR(port);
+
+	if (!(status & (UART_MSR_DCTS | UART_MSR_DDSR |
+		       UART_MSR_TERI | UART_MSR_DDCD)))
+		return;
+
+        if (status & UART_MSR_DDCD)
+                uart_handle_dcd_change(port, status & UART_MSR_DCD);
+
+        if (status & UART_MSR_DDSR)
+                port->icount.dsr++;
+
+        if (status & UART_MSR_DCTS)
+                uart_handle_cts_change(port, status & UART_MSR_CTS);
+
+	wake_up_interruptible(&port->info->delta_msr_wait);
+
+}
+
+static irqreturn_t  it8712_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct uart_port *port = dev_id;
+	unsigned int status, pass_counter = 0, data;
+
+
+		data = LPC_SERIAL_IRQ_STATUS;
+	if((data&0x10)==0x10)
+	{
+		status = UART_GET_INT_STATUS(port);
+		do {
+//			     printk("it8712_int: status %x \n", status);
+			switch(status)
+			{
+			   case UART_IIR_RDI:
+			   case UART_IIR_RLSI:
+			   case UART_IIR_RCTO:
+				it8712_rx_chars(port, regs);
+			   break;
+			   case UART_IIR_THRI:
+				it8712_tx_chars(port);
+			   break;
+			   case UART_IIR_MSI:
+				it8712_modem_status(port);
+			   break;
+			   default:
+			   break;
+			}
+			if (pass_counter++ > IT8712_ISR_PASS_LIMIT)
+				break;
+
+			status = UART_GET_INT_STATUS(port);
+		} while (status);
+	}
+
+		status = 0;
+        status |= (IRQ_LPC_MASK);
+        *((volatile unsigned int *)IRQ_CLEAR(IO_ADDRESS(SL2312_INTERRUPT_BASE))) = status;
+
+	//cnt=0;
+	//do{
+	//	data = LPC_SERIAL_IRQ_STATUS;
+		LPC_SERIAL_IRQ_STATUS = data;
+	//	cnt++;
+	//}while(data);
+	//if(cnt>2)
+	//	printf("it8712_uart_Isr clear LPC_SERIAL_IRQ_STATUS %x \n", cnt);
+        return IRQ_HANDLED;
+}
+
+static u_int it8712_tx_empty(struct uart_port *port)
+{
+//        printk("it8712 tx empty : \n");
+
+	return ((UART_GET_LSR(port) & UART_LSR_THRE)? TIOCSER_TEMT : 0);
+}
+
+static u_int it8712_get_mctrl(struct uart_port *port)
+{
+	unsigned int result = 0;
+	unsigned int status;
+
+//        printk("it8712 get mctrl : \n");
+
+	status = UART_GET_MSR(port);
+	if (status & UART_MSR_DCD)
+		result |= TIOCM_CAR;
+	if (status & UART_MSR_DSR)
+		result |= TIOCM_DSR;
+	if (status & UART_MSR_CTS)
+		result |= TIOCM_CTS;
+	if (status & UART_MSR_RI)
+		result |= TIOCM_RI;
+
+	return result;
+}
+
+static void it8712_set_mctrl_null(struct uart_port *port, u_int mctrl)
+{
+}
+
+static void it8712_break_ctl(struct uart_port *port, int break_state)
+{
+	unsigned int lcr;
+
+//        printk("it8712 break ctl : \n");
+
+	lcr = UART_GET_LCR(port);
+	if (break_state == -1)
+		lcr |= UART_LCR_SBC;
+	else
+		lcr &= ~UART_LCR_SBC;
+	UART_PUT_LCR(port, lcr);
+}
+
+static inline u_int uart_calculate_quot(struct uart_port *port, u_int baud)
+{
+	u_int quot;
+
+	/* Special case: B0 rate */
+	if (!baud)
+		baud = 9600;
+
+	quot = (port->uartclk/(16 * baud)) ;
+
+	return quot;
+}
+static void it8712_set_termios(struct uart_port *port, struct termios *termios,
+                               struct termios *old)
+{
+	unsigned int  uart_mc, old_ier, baud, quot;
+	unsigned long flags;
+
+        termios->c_cflag |= CREAD;
+        termios->c_cflag |= CLOCAL;
+#ifdef DEBUG
+	printk("it8712_set_cflag(0x%x) called\n", cflag);
+#endif
+        baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
+        quot = uart_get_divisor(port, baud);
+
+	/* byte size and parity */
+	switch (termios->c_cflag & CSIZE) {
+	case CS5:
+              uart_mc = UART_LCR_WLEN5;
+              break;
+	case CS6:
+              uart_mc = UART_LCR_WLEN6;
+              break;
+	case CS7:
+              uart_mc = UART_LCR_WLEN7;
+              break;
+	default: // CS8
+              uart_mc = UART_LCR_WLEN8;
+              break;
+	}
+
+	if (termios->c_cflag & CSTOPB)
+		uart_mc|= UART_LCR_STOP;
+	if (termios->c_cflag & PARENB) {
+		uart_mc |= UART_LCR_EVEN;
+		if (!(termios->c_cflag & PARODD))
+			uart_mc |= UART_LCR_ODD;
+	}
+
+        spin_lock_irqsave(&port->lock, flags);
+        /*
+         * Update the per-port timeout
+         */
+        uart_update_timeout(port, termios->c_cflag, baud);
+	port->read_status_mask = UART_LSR_OE;
+	if (termios->c_iflag & INPCK)
+		port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
+	if (termios->c_iflag & (BRKINT | PARMRK))
+		port->read_status_mask |= UART_LSR_BI;
+
+	/*
+	 * Characters to ignore
+	 */
+	port->ignore_status_mask = 0;
+	if (termios->c_iflag & IGNPAR)
+		port->ignore_status_mask |= UART_LSR_FE | UART_LSR_PE;
+	if (termios->c_iflag & IGNBRK) {
+		port->ignore_status_mask |= UART_LSR_BI;
+		/*
+		 * If we're ignoring parity and break indicators,
+		 * ignore overruns to (for real raw support).
+		 */
+		if (termios->c_iflag & IGNPAR)
+			port->ignore_status_mask |= UART_LSR_OE;
+	}
+
+	old_ier = UART_GET_IER(port);
+
+        if(UART_ENABLE_MS(port, termios->c_cflag))
+             old_ier |= UART_IER_MSI;
+
+	/* Set baud rate */
+	quot = quot / 13;
+	UART_PUT_LCR(port, UART_LCR_DLAB);
+	UART_PUT_DIV_LO(port, (quot & 0xff));
+	UART_PUT_DIV_HI(port, ((quot & 0xf00) >> 8));
+
+	UART_PUT_LCR(port, uart_mc);
+//	UART_PUT_LCR(port, 0x07); // ???? it is wired
+        UART_PUT_MCR(port, 0x08);
+        UART_PUT_FCR(port, 0x01);
+	UART_PUT_IER(port, 0x07);
+
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static int it8712_startup(struct uart_port *port)
+{
+	int retval, i;
+	unsigned int regs;
+
+        //printk("it8712 startup : \n");
+
+	/*
+	 * Use iobase to store a pointer to info. We need this to start a
+	 * transmission as the tranmittr interrupt is only generated on
+	 * the transition to the idle state
+	 */
+
+	//	regs = 0;
+    //    regs |= (IRQ_LPC_MASK);
+    //    *((volatile unsigned int *)IRQ_CLEAR(IO_ADDRESS(SL2312_INTERRUPT_BASE))) = regs;
+
+	/*
+	 * Allocate the IRQ
+	 */
+	retval = request_irq(port->irq, it8712_int, SA_INTERRUPT, "it8712", port);
+	if (retval)
+		return retval;
+
+	//printk("Init LPC int...........\n");
+        /* setup interrupt controller  */
+        regs = *((volatile unsigned int *)IRQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
+        regs &= ~(IRQ_LPC_MASK);
+        *((volatile unsigned int *)IRQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE))) = regs;
+        regs = *((volatile unsigned int *)IRQ_TLEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
+        regs &= ~(IRQ_LPC_MASK);
+        *((volatile unsigned int *)IRQ_TLEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE))) = regs;
+        *((volatile unsigned int *)IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE))) |= (unsigned int)(IRQ_LPC_MASK);
+
+	LPC_SERIAL_IRQ_POLARITY = 0x10; //0x10; //0x02;
+	LPC_SERIAL_IRQ_TRITYPE = 0x10; //0x10;//
+	LPC_SERIAL_IRQ_ENABLE = 0x10;
+
+	LPC_BUS_CTRL = 0xc0;
+	LPC_SERIAL_IRQ_CTRL = 0xc0;
+	for(i=0;i<1000;i++) ;
+	LPC_SERIAL_IRQ_CTRL = 0x80;
+	/*
+	 * Finally, enable interrupts. Use the TII interrupt to minimise
+	 * the number of interrupts generated. If higher performance is
+	 * needed, consider using the TI interrupt with a suitable FIFO
+	 * threshold
+	 */
+	//UART_PUT_IER(port, (UART_IER_RDI|UART_IER_THRI));
+	UART_PUT_IER(port, (UART_IER_RDI|UART_IER_THRI|UART_IER_RLSI));//middle
+
+	return 0;
+}
+
+static void it8712_shutdown(struct uart_port *port)
+{
+        //printk("it8712 shutdown : \n");
+
+	/*
+	 * disable all interrupts, disable the port
+	 */
+	UART_PUT_IER(port, 0x0);
+
+	/* disable break condition and fifos */
+//	UART_PUT_MCR(port, (UART_GET_MCR(port)&UART_MCR_MASK));
+
+	/*
+	 * Free the interrupt
+	 */
+	free_irq(port->irq, port);
+}
+
+static const char *it8712_type(struct uart_port *port)
+{
+	return port->type == PORT_IT8712 ? "IT8712" : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'
+ */
+static void it8712_release_port(struct uart_port *port)
+{
+//        printk("it8712 release port : \n");
+
+	release_mem_region(port->mapbase, UART_PORT_SIZE);
+}
+
+/*
+ * Request the memory region(s) being used by 'port'
+ */
+static int it8712_request_port(struct uart_port *port)
+{
+	return request_mem_region(port->mapbase, UART_PORT_SIZE,
+				    "serial_it8712") != NULL ? 0 : -EBUSY;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void it8712_config_port(struct uart_port *port, int flags)
+{
+
+	if (flags & UART_CONFIG_TYPE) {
+		if (it8712_request_port(port) == 0)
+			port->type = PORT_IT8712;
+	}
+}
+
+/*
+ * verify the new serial_struct (for TIOCSSERIAL).
+ */
+static int it8712_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+	int ret = 0;
+
+	if (ser->type != PORT_UNKNOWN && ser->type != PORT_UART00)
+		ret = -EINVAL;
+	if (ser->irq < 0 || ser->irq >= NR_IRQS)
+		ret = -EINVAL;
+	if (ser->baud_base < 9600)
+		ret = -EINVAL;
+	return ret;
+}
+
+static struct uart_ops it8712_pops = {
+	.tx_empty	= it8712_tx_empty,
+	.set_mctrl	= it8712_set_mctrl_null,
+	.get_mctrl	= it8712_get_mctrl,
+	.stop_tx	= it8712_stop_tx,
+	.start_tx	= it8712_start_tx,
+	.stop_rx	= it8712_stop_rx,
+	.enable_ms	= it8712_enable_ms,
+	.break_ctl	= it8712_break_ctl,
+	.startup	= it8712_startup,
+	.shutdown	= it8712_shutdown,
+	.set_termios	= it8712_set_termios,
+	.type		= it8712_type,
+	.release_port	= it8712_release_port,
+	.request_port	= it8712_request_port,
+	.config_port	= it8712_config_port,
+	.verify_port	= it8712_verify_port,
+};
+
+#ifdef CONFIG_ARCH_SL2312
+
+static struct uart_port it8712_ports[UART_NR] = {
+	{
+		membase:	(void *)0,
+		mapbase:	0,
+		iotype:		SERIAL_IO_MEM,
+		irq:		0,
+		uartclk:	UART_CLK/2,
+		fifosize:	16,
+		ops:		&it8712_pops,
+		flags:		ASYNC_BOOT_AUTOCONF,
+	}
+};
+
+#endif
+
+#ifdef CONFIG_SERIAL_IT8712_CONSOLE
+#ifdef used_and_not_const_char_pointer
+static int it8712_console_read(struct uart_port *port, char *s, u_int count)
+{
+	unsigned int status;
+	int c;
+#ifdef DEBUG
+	printk("it8712_console_read() called\n");
+#endif
+
+	c = 0;
+	while (c < count) {
+		status = UART_GET_LSR(port);
+ 		if (UART_RX_DATA(status)) {
+			*s++ = UART_GET_CHAR(port);
+			c++;
+		} else {
+			// nothing more to get, return
+			return c;
+		}
+	}
+	// return the count
+	return c;
+}
+#endif
+static void it8712_console_write(struct console *co, const char *s, unsigned count)
+{
+#ifdef CONFIG_ARCH_SL2312
+	struct uart_port *port = it8712_ports + co->index;
+	unsigned int status, old_ies;
+	int i;
+
+	/*
+	 *	First save the CR then disable the interrupts
+	 */
+	old_ies = UART_GET_IER(port);
+	//if(old_ies!=7)
+	//{
+	//
+	//	printk("old_ies = %x\n",old_ies);
+	//	old_ies = 7;
+	//}
+	UART_PUT_IER(port,0x0);
+
+	/*
+	 *	Now, do each character
+	 */
+	for (i = 0; i < count; i++) {
+		do {
+			status = UART_GET_LSR(port);
+		} while (!UART_TX_READY(status));
+		UART_PUT_CHAR(port, s[i]);
+		if (s[i] == '\n') {
+			do {
+				status = UART_GET_LSR(port);
+			} while (!UART_TX_READY(status));
+			UART_PUT_CHAR(port, '\r');
+		}
+	}
+
+	/*
+	 *	Finally, wait for transmitter to become empty
+	 *	and restore the IES
+	 */
+	do {
+		status = UART_GET_LSR(port);
+	} while (!(status&UART_LSR_THRE));
+	UART_PUT_IER(port, old_ies);
+#endif
+}
+
+static void /*__init*/ it8712_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
+{
+	//printk("it8712 console get options : \n");
+
+	u_int uart_mc, quot;
+	uart_mc= UART_GET_MCR(port);
+
+	*parity = 'n';
+	if (uart_mc & UART_LCR_PARITY) {
+		if (uart_mc & UART_LCR_EVEN)
+			*parity = 'e';
+		else
+			*parity = 'o';
+	}
+
+	switch (uart_mc & UART_LCR_MSK){
+
+	case UART_LCR_WLEN5:
+		*bits = 5;
+		break;
+	case UART_LCR_WLEN6:
+		*bits = 6;
+		break;
+	case UART_LCR_WLEN7:
+		*bits = 7;
+		break;
+	case UART_LCR_WLEN8:
+		*bits = 8;
+		break;
+	}
+	UART_PUT_MCR(port,UART_LCR_DLAB);
+	quot = UART_GET_DIV_LO(port) | (UART_GET_DIV_HI(port) << 8);
+	UART_PUT_MCR(port,uart_mc);
+	*baud = (port->uartclk / (16 *quot));
+}
+
+static int __init it8712_console_setup(struct console *co, char *options)
+{
+	struct uart_port *port;
+	int baud = 38400;
+	int bits = 8;
+	int parity = 'n';
+	int flow= 'n';
+	int base;//, irq;
+	int i ;
+
+	printk("it8712 console setup : \n");
+
+	LPCSetConfig(0, 0x02, 0x01);
+        LPCSetConfig(LDN_SERIAL1, 0x30, 0x1);
+        LPCSetConfig(LDN_SERIAL1, 0x23, 0x0);
+	base = IT8712_IO_BASE;
+	base += ((LPCGetConfig(LDN_SERIAL1, 0x60) << 8) + LPCGetConfig(LDN_SERIAL1, 0x61));
+	it8712_ports[0].mapbase = base;
+	it8712_ports[0].membase = (void *)IO_ADDRESS(base);
+	it8712_ports[0].irq = IRQ_LPC_OFFSET;
+    //   	irq = LPCGetConfig(LDN_SERIAL1, 0x70);
+	//it8712_ports[0].irq += irq;
+
+	//printk("it8712 irq is %x \n", it8712_ports[0].irq);
+
+	// setup LPC Host 'quiet mode'
+	//*((volatile unsigned int *)IO_ADDRESS((SL2312_LPC_HOST_BASE+0x04))) |= LPC_HOST_CONTINUE_MODE ;
+	//for(i=0;i<1000;i++) ;						// delay
+	//*((volatile unsigned int *)IO_ADDRESS((SL2312_LPC_HOST_BASE+0x04))) &= ~(LPC_HOST_CONTINUE_MODE) ;
+	LPC_BUS_CTRL = 0xc0;
+	LPC_SERIAL_IRQ_CTRL = 0xc0;
+	for(i=0;i<1000;i++) ;
+	LPC_SERIAL_IRQ_CTRL = 0x80;
+
+#ifdef CONFIG_ARCH_SL2312
+	/*
+	 * Check whether an invalid uart number has been specified, and
+	 * if so, search for the first available port that does have
+	 * console support.
+	 */
+	port = uart_get_console(it8712_ports,IT8712_NO_PORTS,co);
+#else
+	return -ENODEV;
+#endif
+
+	if (options)
+		uart_parse_options(options, &baud, &parity, &bits, &flow);
+	else
+		it8712_console_get_options(port, &baud, &parity, &bits);
+
+	return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+extern struct uart_driver it8712_reg;
+static struct console it8712_console = {
+	.name           = SERIAL_IT8712_NAME,
+	.write		= it8712_console_write,
+	.device		= uart_console_device,
+        .setup          = it8712_console_setup,
+	.flags		= CON_PRINTBUFFER,
+	.index		= 0,
+        .data           = &it8712_reg,
+};
+
+static int __init it8712_console_init(void)
+{
+	register_console(&it8712_console);
+        return 0;
+}
+
+console_initcall(it8712_console_init);
+
+#define IT8712_CONSOLE	&it8712_console
+#else
+#define IT8712_CONSOLE	NULL
+#endif
+
+static struct uart_driver it8712_reg = {
+	.owner                  = NULL,
+	.driver_name		= SERIAL_IT8712_NAME,
+	.dev_name		= SERIAL_IT8712_NAME,
+        .major                  = SERIAL_IT8712_MAJOR,
+	.minor			= SERIAL_IT8712_MINOR,
+	.nr			= UART_NR,
+	.cons			= IT8712_CONSOLE,
+};
+
+static int __init it8712_init(void)
+{
+        int result;
+	//printk("serial_it8712: it871212_init \n");
+
+
+        result = uart_register_driver(&it8712_reg);
+        if(result)
+             return result;
+	result = uart_add_one_port(&it8712_reg, &it8712_ports[0]);
+
+        return result;
+
+}
+
+
+__initcall(it8712_init);
--- /dev/null
+++ b/drivers/serial/it8712.h
@@ -0,0 +1,135 @@
+#define UART_RX		0	/* In:  Receive buffer (DLAB=0) */
+#define UART_TX		0	/* Out: Transmit buffer (DLAB=0) */
+#define UART_DLL	0	/* Out: Divisor Latch Low (DLAB=1) */
+#define UART_TRG	0	/* (LCR=BF) FCTR bit 7 selects Rx or Tx
+				 * In: Fifo count
+				 * Out: Fifo custom trigger levels
+				 * XR16C85x only */
+
+#define UART_DLM	1	/* Out: Divisor Latch High (DLAB=1) */
+#define UART_IER	1	/* Out: Interrupt Enable Register */
+#define UART_FCTR	1	/* (LCR=BF) Feature Control Register
+				 * XR16C85x only */
+
+#define UART_IIR	2	/* In:  Interrupt ID Register */
+#define UART_FCR	2	/* Out: FIFO Control Register */
+#define UART_EFR	2	/* I/O: Extended Features Register */
+				/* (DLAB=1, 16C660 only) */
+
+#define UART_LCR	3	/* Out: Line Control Register */
+#define UART_MCR	4	/* Out: Modem Control Register */
+#define UART_LSR	5	/* In:  Line Status Register */
+#define UART_MSR	6	/* In:  Modem Status Register */
+#define UART_SCR	7	/* I/O: Scratch Register */
+#define UART_EMSR	7	/* (LCR=BF) Extended Mode Select Register
+				 * FCTR bit 6 selects SCR or EMSR
+				 * XR16c85x only */
+
+/*
+ * These are the definitions for the FIFO Control Register
+ * (16650 only)
+ */
+#define UART_FCR_ENABLE_FIFO	0x01 /* Enable the FIFO */
+#define UART_FCR_CLEAR_RCVR	0x02 /* Clear the RCVR FIFO */
+#define UART_FCR_CLEAR_XMIT	0x04 /* Clear the XMIT FIFO */
+#define UART_FCR_DMA_SELECT	0x08 /* For DMA applications */
+#define UART_FCR_TRIGGER_MASK	0xC0 /* Mask for the FIFO trigger range */
+#define UART_FCR_TRIGGER_1	0x00 /* Mask for trigger set at 1 */
+#define UART_FCR_TRIGGER_4	0x40 /* Mask for trigger set at 4 */
+#define UART_FCR_TRIGGER_8	0x80 /* Mask for trigger set at 8 */
+#define UART_FCR_TRIGGER_14	0xC0 /* Mask for trigger set at 14 */
+/* 16650 redefinitions */
+#define UART_FCR6_R_TRIGGER_8	0x00 /* Mask for receive trigger set at 1 */
+#define UART_FCR6_R_TRIGGER_16	0x40 /* Mask for receive trigger set at 4 */
+#define UART_FCR6_R_TRIGGER_24  0x80 /* Mask for receive trigger set at 8 */
+#define UART_FCR6_R_TRIGGER_28	0xC0 /* Mask for receive trigger set at 14 */
+#define UART_FCR6_T_TRIGGER_16	0x00 /* Mask for transmit trigger set at 16 */
+#define UART_FCR6_T_TRIGGER_8	0x10 /* Mask for transmit trigger set at 8 */
+#define UART_FCR6_T_TRIGGER_24  0x20 /* Mask for transmit trigger set at 24 */
+#define UART_FCR6_T_TRIGGER_30	0x30 /* Mask for transmit trigger set at 30 */
+/* TI 16750 definitions */
+#define UART_FCR7_64BYTE	0x20 /* Go into 64 byte mode */
+
+/*
+ * These are the definitions for the Line Control Register
+ *
+ * Note: if the word length is 5 bits (UART_LCR_WLEN5), then setting
+ * UART_LCR_STOP will select 1.5 stop bits, not 2 stop bits.
+ */
+#define UART_LCR_DLAB	0x80	/* Divisor latch access bit */
+#define UART_LCR_SBC	0x40	/* Set break control */
+#define UART_LCR_SPAR	0x20	/* Stick parity (?) */
+#define UART_LCR_EPAR	0x10	/* Even parity select */
+#define UART_LCR_PARITY	0x08	/* Parity Enable */
+#define UART_LCR_STOP	0x04	/* Stop bits: 0=1 stop bit, 1= 2 stop bits */
+#define UART_LCR_WLEN5  0x00	/* Wordlength: 5 bits */
+#define UART_LCR_WLEN6  0x01	/* Wordlength: 6 bits */
+#define UART_LCR_WLEN7  0x02	/* Wordlength: 7 bits */
+#define UART_LCR_WLEN8  0x03	/* Wordlength: 8 bits */
+#define UART_LCR_EVEN   0x18    /* Even parity */
+#define UART_LCR_ODD    0x08    /* Odd parity */
+#define UART_LCR_MSK    0x03
+/*
+ * These are the definitions for the Line Status Register
+ */
+#define UART_LSR_DE     0x80    /* FIFO Data Error */
+#define UART_LSR_TEMT	0x40	/* Transmitter empty */
+#define UART_LSR_THRE	0x20	/* Transmit-hold-register empty */
+#define UART_LSR_BI	0x10	/* Break interrupt indicator */
+#define UART_LSR_FE	0x08	/* Frame error indicator */
+#define UART_LSR_PE	0x04	/* Parity error indicator */
+#define UART_LSR_OE	0x02	/* Overrun error indicator */
+#define UART_LSR_DR	0x01	/* Receiver data ready */
+
+/*
+ * These are the definitions for the Interrupt Identification Register
+ */
+#define UART_IIR_NO_INT	0x01	/* No interrupts pending */
+#define UART_IIR_ID	0x06	/* Mask for the interrupt ID */
+
+#define UART_IIR_MSI	0x00	/* Modem status interrupt */
+#define UART_IIR_THRI	0x02	/* Transmitter holding register empty */
+#define UART_IIR_RDI	0x04	/* Receiver data interrupt */
+#define UART_IIR_RLSI	0x06	/* Receiver line status interrupt */
+#define UART_IIR_RCTO	0x0c	/* Receiver character timeout interrupt */
+/*
+ * These are the definitions for the Interrupt Enable Register
+ */
+#define UART_IER_MSI	0x08	/* Enable Modem status interrupt */
+#define UART_IER_RLSI	0x04	/* Enable receiver line status interrupt */
+#define UART_IER_THRI	0x02	/* Enable Transmitter holding register int. */
+#define UART_IER_RDI	0x01	/* Enable receiver data interrupt */
+/*
+ * Sleep mode for ST16650 and TI16750.
+ * Note that for 16650, EFR-bit 4 must be selected as well.
+ */
+#define UART_IERX_SLEEP  0x10	/* Enable sleep mode */
+
+/*
+ * These are the definitions for the Modem Control Register
+ */
+#define UART_MCR_LOOP	0x10	/* Enable loopback test mode */
+#define UART_MCR_OUT2	0x08	/* Out2 complement */
+#define UART_MCR_OUT1	0x04	/* Out1 complement */
+#define UART_MCR_RTS	0x02	/* RTS complement */
+#define UART_MCR_DTR	0x01	/* DTR complement */
+
+/*
+ * These are the definitions for the Modem Status Register
+ */
+#define UART_MSR_DCD	0x80	/* Data Carrier Detect */
+#define UART_MSR_RI	0x40	/* Ring Indicator */
+#define UART_MSR_DSR	0x20	/* Data Set Ready */
+#define UART_MSR_CTS	0x10	/* Clear to Send */
+#define UART_MSR_DDCD	0x08	/* Delta DCD */
+#define UART_MSR_TERI	0x04	/* Trailing edge ring indicator */
+#define UART_MSR_DDSR	0x02	/* Delta DSR */
+#define UART_MSR_DCTS	0x01	/* Delta CTS */
+#define UART_MSR_ANY_DELTA 0x0F	/* Any of the delta bits! */
+
+#define UART_PARITY_NONE	0x00
+#define UART_PARITY_ODD		0x01
+#define UART_PARITY_EVEN	0x02
+
+
+
--- /dev/null
+++ b/drivers/serial/serial_it8712.c
@@ -0,0 +1,876 @@
+/*
+ *  linux/drivers/char/serial_uart00.c
+ *
+ *  Driver for UART00 serial ports
+ *
+ *  Based on drivers/char/serial_amba.c, by ARM Limited &
+ *                                          Deep Blue Solutions Ltd.
+ *  Copyright 2001 Altera Corporation
+ *
+ * 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
+ *
+ *  $Id: serial_it8712.c,v 1.1.1.1 2006/04/03 08:41:00 amos_lee Exp $
+ *
+ */
+#include <linux/module.h>
+
+#include <linux/errno.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/major.h>
+#include <linux/string.h>
+#include <linux/fcntl.h>
+#include <linux/ptrace.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/circ_buf.h>
+#include <linux/serial.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+#include <asm/bitops.h>
+#include <asm/sizes.h>
+
+#if defined(CONFIG_SERIAL_IT8712_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/serial_core.h>
+#include <asm/arch/sl2312.h>
+#include <asm/arch/int_ctrl.h>
+#include <asm/arch/it8712.h>
+#include "serial_it8712.h"
+
+//#define DEBUG           1
+#define UART_NR		1
+
+#define SERIAL_IT8712_NAME	"ttySI"
+#define SERIAL_IT8712_MAJOR	204
+#define SERIAL_IT8712_MINOR	41      /* Temporary - will change in future */
+#define SERIAL_IT8712_NR	UART_NR
+#define UART_PORT_SIZE 0x50
+
+#define CALLOUT_IT8712_NAME	"cuaslI"
+#define CALLOUT_IT8712_MAJOR	205
+#define CALLOUT_IT8712_MINOR	41      /* Temporary - will change in future */
+#define CALLOUT_IT8712_NR	UART_NR
+#define LPC_HOST_CONTINUE_MODE	0x00000040
+
+#define IT8712_NO_PORTS         UART_NR
+
+static struct tty_driver normal, callout;
+static struct tty_struct *it8712_table[UART_NR];
+static struct termios *it8712_termios[UART_NR], *it8712_termios_locked[UART_NR];
+static struct console it8712_console;
+
+#define IT8712_ISR_PASS_LIMIT	256
+
+/*
+ * Access macros for the SL2312 UARTs
+ */
+#define UART_GET_INT_STATUS(p)	(inb(((p)->membase+UART_IIR)) & 0x0F)  // interrupt identification
+#define UART_PUT_IER(p, c)      outb(c,((p)->membase+UART_IER))         // interrupt enable
+#define UART_GET_IER(p)         inb(((p)->membase+UART_IER))
+#define UART_PUT_CHAR(p, c)     outb(c,((p)->membase+UART_TX))         // transmitter holding
+#define UART_GET_CHAR(p)        inb(((p)->membase+UART_RX))            // receive buffer
+#define UART_GET_LSR(p)         inb(((p)->membase+UART_LSR))            // line status
+#define UART_GET_MSR(p)         inb(((p)->membase+UART_MSR))            // modem status
+#define UART_GET_MCR(p)         inb(((p)->membase+UART_MCR))            // modem control
+#define UART_PUT_MCR(p, c)      outb(c,((p)->membase+UART_MCR))
+#define UART_GET_LCR(p)         inb(((p)->membase+UART_LCR))       // mode control
+#define UART_PUT_LCR(p, c)      outb(c,((p)->membase+UART_LCR))
+#define UART_PUT_FCR(p, c)      outb(c,((p)->membase+UART_FCR))       // fifo control
+#define UART_GET_DIV_HI(p)	inb(((p)->membase+UART_DLM))
+#define UART_PUT_DIV_HI(p, c)	outb(c,((p)->membase+UART_DLM))
+#define UART_GET_DIV_LO(p)	inb(((p)->membase+UART_DLL))
+#define UART_PUT_DIV_LO(p, c)	outb(c,((p)->membase+UART_DLL))
+#define UART_PUT_MDR(p, c)      outb(c,UART_MDR((p)->membase))
+#define UART_RX_DATA(s)		((s) & UART_LSR_DR)
+#define UART_TX_READY(s)	((s) & UART_LSR_THRE)
+
+static void it8712_stop_tx(struct uart_port *port, u_int from_tty)
+{
+        unsigned int reg;
+
+//        printk("it8712 stop tx : \n");
+        reg = UART_GET_IER(port);
+        reg &= ~(UART_IER_THRI);
+	UART_PUT_IER(port, reg);
+}
+
+static void it8712_stop_rx(struct uart_port *port)
+{
+        unsigned int reg;
+
+//        printk("it8712 stop rx : \n");
+        reg = UART_GET_IER(port);
+        reg &= ~(UART_IER_RDI);
+	UART_PUT_IER(port, reg);
+
+}
+
+static void it8712_enable_ms(struct uart_port *port)
+{
+        unsigned int reg;
+
+//        printk("it8712 enable ms : \n");
+
+        reg = UART_GET_IER(port);
+        reg |= (UART_IER_MSI);
+	UART_PUT_IER(port, reg);
+
+}
+
+static void
+it8712_rx_chars(struct uart_info *info, struct pt_regs *regs)
+{
+	struct tty_struct *tty = info->tty;
+	unsigned int status, mask, ch, flg, ignored = 0;
+	struct uart_port *port = info->port;
+
+ //       printk("it8712_rx_chars : \n");
+	status = UART_GET_LSR(port);
+	while (UART_RX_DATA(status)) {
+
+		/*
+		 * We need to read rds before reading the
+		 * character from the fifo
+		 */
+		ch = UART_GET_CHAR(port);
+		port->icount.rx++;
+
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+			goto ignore_char;
+
+		flg = TTY_NORMAL;
+
+		/*
+		 * Note that the error handling code is
+		 * out of the main execution path
+		 */
+
+		if (status & (UART_LSR_OE|UART_LSR_PE|UART_LSR_FE|UART_LSR_BI|UART_LSR_DE))
+			goto handle_error;
+		if (uart_handle_sysrq_char(info, ch, regs))
+			goto ignore_char;
+
+	error_return:
+		*tty->flip.flag_buf_ptr++ = flg;
+		*tty->flip.char_buf_ptr++ = ch;
+		tty->flip.count++;
+	ignore_char:
+		status = UART_GET_LSR(port);
+	} // end of while
+out:
+	tty_flip_buffer_push(tty);
+	return;
+
+handle_error:
+	if (status & UART_LSR_BI) {
+		status &= ~(UART_LSR_FE);
+		port->icount.brk++;
+
+#ifdef SUPPORT_SYSRQ
+		if (uart_handle_break(info, &it8712_console))
+			goto ignore_char;
+#endif
+	} else if (status & UART_LSR_PE)
+		port->icount.parity++;
+	else if (status & UART_LSR_FE)
+		port->icount.frame++;
+
+	if (status & UART_LSR_OE)
+		port->icount.overrun++;
+
+	if (status & port->ignore_status_mask) {
+		if (++ignored > 100)
+			goto out;
+		goto ignore_char;
+	}
+
+	mask = status & port->read_status_mask;
+
+	if (mask & UART_LSR_BI)
+		flg = TTY_BREAK;
+	else if (mask & UART_LSR_PE)
+		flg = TTY_PARITY;
+	else if (mask & UART_LSR_FE)
+		flg = TTY_FRAME;
+
+	if (status & UART_LSR_OE) {
+		/*
+		 * CHECK: does overrun affect the current character?
+		 * ASSUMPTION: it does not.
+		 */
+		*tty->flip.flag_buf_ptr++ = flg;
+		*tty->flip.char_buf_ptr++ = ch;
+		tty->flip.count++;
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+			goto ignore_char;
+		ch = 0;
+		flg = TTY_OVERRUN;
+	}
+#ifdef SUPPORT_SYSRQ
+	info->sysrq = 0;
+#endif
+	goto error_return;
+}
+
+static void it8712_tx_chars(struct uart_info *info)
+{
+	int count;
+	struct uart_port *port=info->port;
+
+	if (port->x_char) {
+		while(!(UART_GET_LSR(port)&UART_LSR_THRE));
+		UART_PUT_CHAR(port, port->x_char);
+		port->icount.tx++;
+		port->x_char = 0;
+
+		return;
+	}
+	if (info->xmit.head == info->xmit.tail
+	    || info->tty->stopped
+	    || info->tty->hw_stopped) {
+		it8712_stop_tx(info->port, 0);
+		return;
+	}
+
+	count = port->fifosize >> 1;
+	do {
+		while(!(UART_GET_LSR(port)&UART_LSR_THRE));
+		UART_PUT_CHAR(port, info->xmit.buf[info->xmit.tail]);
+		info->xmit.tail = (info->xmit.tail + 1) & (UART_XMIT_SIZE - 1);
+		port->icount.tx++;
+		if (info->xmit.head == info->xmit.tail)
+			break;
+	} while (--count > 0);
+
+	if (CIRC_CNT(info->xmit.head,
+		     info->xmit.tail,
+		     UART_XMIT_SIZE) < WAKEUP_CHARS)
+		uart_event(info, EVT_WRITE_WAKEUP);
+
+	if (info->xmit.head == info->xmit.tail)
+		it8712_stop_tx(info->port, 0);
+}
+
+static void it8712_start_tx(struct uart_port *port, u_int nonempty, u_int from_tty)
+{
+        unsigned int reg;
+	struct uart_info *info=(struct uart_info*)(port->iobase);
+
+//        printk("it8712 start tx : \n");
+        reg = UART_GET_IER(port);
+        reg |= (UART_IER_THRI);
+	UART_PUT_IER(port, reg);
+	it8712_tx_chars(info);
+}
+
+static void it8712_modem_status(struct uart_info *info)
+{
+	unsigned int status;
+	struct uart_icount *icount = &info->port->icount;
+
+//        printk("it8712 modem status : \n");
+
+	status = UART_GET_MSR(info->port);
+
+	if (!(status & (UART_MSR_DCTS | UART_MSR_DDSR |
+		       UART_MSR_TERI | UART_MSR_DDCD)))
+		return;
+
+	if (status & UART_MSR_DCD) {
+		icount->dcd++;
+#ifdef CONFIG_HARD_PPS
+		if ((info->flags & ASYNC_HARDPPS_CD) &&
+		    (status & UART_MSR_DCD_MSK))
+			hardpps();
+#endif
+		if (info->flags & ASYNC_CHECK_CD) {
+			if (status & UART_MSR_DCD)
+				wake_up_interruptible(&info->open_wait);
+			else if (!((info->flags & ASYNC_CALLOUT_ACTIVE) &&
+				   (info->flags & ASYNC_CALLOUT_NOHUP))) {
+				if (info->tty)
+					tty_hangup(info->tty);
+			}
+		}
+	}
+
+	if (status & UART_MSR_DDSR)
+		icount->dsr++;
+
+	if (status & UART_MSR_DCTS) {
+		icount->cts++;
+
+		if (info->flags & ASYNC_CTS_FLOW) {
+			status &= UART_MSR_CTS;
+
+			if (info->tty->hw_stopped) {
+				if (status) {
+					info->tty->hw_stopped = 0;
+					info->ops->start_tx(info->port, 1, 0);
+					uart_event(info, EVT_WRITE_WAKEUP);
+				}
+			} else {
+				if (!status) {
+					info->tty->hw_stopped = 1;
+					info->ops->stop_tx(info->port, 0);
+				}
+			}
+		}
+	}
+	wake_up_interruptible(&info->delta_msr_wait);
+
+}
+
+static void it8712_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+	struct uart_info *info = dev_id;
+	unsigned int status, pass_counter = 0;
+
+	status = UART_GET_INT_STATUS(info->port);
+	do {
+//		     printk("it8712_int: status %x \n", status);
+		switch(status)
+		{
+		   case UART_IIR_RDI:
+		   case UART_IIR_RLSI:
+		   case UART_IIR_RCTO:
+			it8712_rx_chars(info, regs);
+		   break;
+		   case UART_IIR_THRI:
+			it8712_tx_chars(info);
+		   break;
+		   case UART_IIR_MSI:
+			it8712_modem_status(info);
+		   break;
+		   default:
+		   break;
+		}
+		if (pass_counter++ > IT8712_ISR_PASS_LIMIT)
+			break;
+
+		status = UART_GET_INT_STATUS(info->port);
+	} while (status);
+}
+
+static u_int it8712_tx_empty(struct uart_port *port)
+{
+//        printk("it8712 tx empty : \n");
+
+	return ((UART_GET_LSR(port) & UART_LSR_THRE)? TIOCSER_TEMT : 0);
+}
+
+static u_int it8712_get_mctrl(struct uart_port *port)
+{
+	unsigned int result = 0;
+	unsigned int status;
+
+//        printk("it8712 get mctrl : \n");
+
+	status = UART_GET_MSR(port);
+	if (status & UART_MSR_DCD)
+		result |= TIOCM_CAR;
+	if (status & UART_MSR_DSR)
+		result |= TIOCM_DSR;
+	if (status & UART_MSR_CTS)
+		result |= TIOCM_CTS;
+	if (status & UART_MSR_RI)
+		result |= TIOCM_RI;
+
+	return result;
+}
+
+static void it8712_set_mctrl_null(struct uart_port *port, u_int mctrl)
+{
+}
+
+static void it8712_break_ctl(struct uart_port *port, int break_state)
+{
+	unsigned int lcr;
+
+//        printk("it8712 break ctl : \n");
+
+	lcr = UART_GET_LCR(port);
+	if (break_state == -1)
+		lcr |= UART_LCR_SBC;
+	else
+		lcr &= ~UART_LCR_SBC;
+	UART_PUT_LCR(port, lcr);
+}
+
+static inline u_int uart_calculate_quot(struct uart_info *info, u_int baud)
+{
+	u_int quot;
+
+	/* Special case: B0 rate */
+	if (!baud)
+		baud = 9600;
+
+	quot = (info->port->uartclk/(16 * baud)) ;
+
+	return quot;
+}
+static void it8712_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
+{
+	u_int uart_mc=0, old_ier;
+	unsigned long flags;
+
+#ifdef DEBUG
+	printk("it8712_set_cflag(0x%x) called\n", cflag);
+#endif
+
+
+	/* byte size and parity */
+	switch (cflag & CSIZE) {
+	case CS5: uart_mc = UART_LCR_WLEN5; break;
+	case CS6: uart_mc = UART_LCR_WLEN6; break;
+	case CS7: uart_mc = UART_LCR_WLEN7; break;
+	default:  uart_mc = UART_LCR_WLEN8; break; // CS8
+	}
+	if (cflag & CSTOPB)
+		uart_mc|= UART_LCR_STOP;
+	if (cflag & PARENB) {
+		uart_mc |= UART_LCR_EVEN;
+		if (!(cflag & PARODD))
+			uart_mc |= UART_LCR_ODD;
+	}
+
+	port->read_status_mask = UART_LSR_OE;
+	if (iflag & INPCK)
+		port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
+	if (iflag & (BRKINT | PARMRK))
+		port->read_status_mask |= UART_LSR_BI;
+
+	/*
+	 * Characters to ignore
+	 */
+	port->ignore_status_mask = 0;
+	if (iflag & IGNPAR)
+		port->ignore_status_mask |= UART_LSR_FE | UART_LSR_PE;
+	if (iflag & IGNBRK) {
+		port->ignore_status_mask |= UART_LSR_BI;
+		/*
+		 * If we're ignoring parity and break indicators,
+		 * ignore overruns to (for real raw support).
+		 */
+		if (iflag & IGNPAR)
+			port->ignore_status_mask |= UART_LSR_OE;
+	}
+
+	/* first, disable everything */
+	save_flags(flags); cli();
+	old_ier = UART_GET_IER(port);
+
+	if ((port->flags & ASYNC_HARDPPS_CD) ||
+	    (cflag & CRTSCTS) || !(cflag & CLOCAL))
+		old_ier |= UART_IER_MSI;
+
+	/* Set baud rate */
+	quot = quot / 13;
+	UART_PUT_LCR(port, UART_LCR_DLAB);
+	UART_PUT_DIV_LO(port, (quot & 0xff));
+	UART_PUT_DIV_HI(port, ((quot & 0xf00) >> 8));
+
+	UART_PUT_LCR(port, uart_mc);
+//	UART_PUT_LCR(port, 0x07); // ???? it is wired
+        UART_PUT_MCR(port, 0x08);
+        UART_PUT_FCR(port, 0x01);
+	UART_PUT_IER(port, 0x05);
+
+	restore_flags(flags);
+}
+
+static int it8712_startup(struct uart_port *port, struct uart_info *info)
+{
+	int retval;
+	unsigned int regs;
+
+//        printk("it8712 startup : \n");
+
+	/*
+	 * Use iobase to store a pointer to info. We need this to start a
+	 * transmission as the tranmittr interrupt is only generated on
+	 * the transition to the idle state
+	 */
+
+	port->iobase=(u_int)info;
+
+	/*
+	 * Allocate the IRQ
+	 */
+	retval = request_irq(port->irq, it8712_int, SA_INTERRUPT, "it8712", info);
+	if (retval)
+		return retval;
+
+        /* setup interrupt controller  */
+        regs = *((volatile unsigned int *)IRQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
+        regs |= (IRQ_SERIRQ0_MASK);
+        *((volatile unsigned int *)IRQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE))) = regs;
+        regs = *((volatile unsigned int *)IRQ_LEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
+        regs &= ~(IRQ_SERIRQ0_MASK);
+        *((volatile unsigned int *)IRQ_LEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE))) = regs;
+        *((volatile unsigned int *)IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE))) |= (unsigned int)(IRQ_SERIRQ0_MASK);
+
+	/*
+	 * Finally, enable interrupts. Use the TII interrupt to minimise
+	 * the number of interrupts generated. If higher performance is
+	 * needed, consider using the TI interrupt with a suitable FIFO
+	 * threshold
+	 */
+	UART_PUT_IER(port, (UART_IER_RDI|UART_IER_THRI));
+
+	return 0;
+}
+
+static void it8712_shutdown(struct uart_port *port, struct uart_info *info)
+{
+//        printk("it8712 shutdown : \n");
+
+	/*
+	 * disable all interrupts, disable the port
+	 */
+	UART_PUT_IER(port, 0x0);
+
+	/* disable break condition and fifos */
+//	UART_PUT_MCR(port, (UART_GET_MCR(port)&UART_MCR_MASK));
+
+	/*
+	 * Free the interrupt
+	 */
+	free_irq(port->irq, info);
+}
+
+static const char *it8712_type(struct uart_port *port)
+{
+	return port->type == PORT_IT8712 ? "IT8712" : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'
+ */
+static void it8712_release_port(struct uart_port *port)
+{
+//        printk("it8712 release port : \n");
+
+	release_mem_region(port->mapbase, UART_PORT_SIZE);
+}
+
+/*
+ * Request the memory region(s) being used by 'port'
+ */
+static int it8712_request_port(struct uart_port *port)
+{
+	return request_mem_region(port->mapbase, UART_PORT_SIZE,
+				    "serial_it8712") != NULL ? 0 : -EBUSY;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void it8712_config_port(struct uart_port *port, int flags)
+{
+
+	if (flags & UART_CONFIG_TYPE) {
+		if (it8712_request_port(port) == 0)
+			port->type = PORT_IT8712;
+	}
+}
+
+/*
+ * verify the new serial_struct (for TIOCSSERIAL).
+ */
+static int it8712_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+	int ret = 0;
+
+	if (ser->type != PORT_UNKNOWN && ser->type != PORT_UART00)
+		ret = -EINVAL;
+	if (ser->irq < 0 || ser->irq >= NR_IRQS)
+		ret = -EINVAL;
+	if (ser->baud_base < 9600)
+		ret = -EINVAL;
+	return ret;
+}
+
+static struct uart_ops it8712_pops = {
+	tx_empty:	it8712_tx_empty,
+	set_mctrl:	it8712_set_mctrl_null,
+	get_mctrl:	it8712_get_mctrl,
+	stop_tx:	it8712_stop_tx,
+	start_tx:	it8712_start_tx,
+	stop_rx:	it8712_stop_rx,
+	enable_ms:	it8712_enable_ms,
+	break_ctl:	it8712_break_ctl,
+	startup:	it8712_startup,
+	shutdown:	it8712_shutdown,
+	change_speed:	it8712_change_speed,
+	type:		it8712_type,
+	release_port:	it8712_release_port,
+	request_port:	it8712_request_port,
+	config_port:	it8712_config_port,
+	verify_port:	it8712_verify_port,
+};
+
+#ifdef CONFIG_ARCH_SL2312
+
+static struct uart_port it8712_ports[UART_NR] = {
+	{
+		membase:	(void *)0,
+		mapbase:	0,
+		iotype:		SERIAL_IO_MEM,
+		irq:		0,
+		uartclk:	UART_CLK/2,
+		fifosize:	16,
+		ops:		&it8712_pops,
+		flags:		ASYNC_BOOT_AUTOCONF,
+	}
+};
+
+#endif
+
+#ifdef CONFIG_SERIAL_IT8712_CONSOLE
+#ifdef used_and_not_const_char_pointer
+static int it8712_console_read(struct uart_port *port, char *s, u_int count)
+{
+	unsigned int status;
+	int c;
+#ifdef DEBUG
+	printk("it8712_console_read() called\n");
+#endif
+
+	c = 0;
+	while (c < count) {
+		status = UART_GET_LSR(port);
+ 		if (UART_RX_DATA(status)) {
+			*s++ = UART_GET_CHAR(port);
+			c++;
+		} else {
+			// nothing more to get, return
+			return c;
+		}
+	}
+	// return the count
+	return c;
+}
+#endif
+static void it8712_console_write(struct console *co, const char *s, unsigned count)
+{
+#ifdef CONFIG_ARCH_SL2312
+	struct uart_port *port = it8712_ports + co->index;
+	unsigned int status, old_ies;
+	int i;
+
+	/*
+	 *	First save the CR then disable the interrupts
+	 */
+	old_ies = UART_GET_IER(port);
+	UART_PUT_IER(port,0x0);
+
+	/*
+	 *	Now, do each character
+	 */
+	for (i = 0; i < count; i++) {
+		do {
+			status = UART_GET_LSR(port);
+		} while (!UART_TX_READY(status));
+		UART_PUT_CHAR(port, s[i]);
+		if (s[i] == '\n') {
+			do {
+				status = UART_GET_LSR(port);
+			} while (!UART_TX_READY(status));
+			UART_PUT_CHAR(port, '\r');
+		}
+	}
+
+	/*
+	 *	Finally, wait for transmitter to become empty
+	 *	and restore the IES
+	 */
+	do {
+		status = UART_GET_LSR(port);
+	} while (!(status&UART_LSR_THRE));
+	UART_PUT_IER(port, old_ies);
+#endif
+}
+
+static kdev_t it8712_console_device(struct console *co)
+{
+	return MKDEV(SERIAL_IT8712_MAJOR, SERIAL_IT8712_MINOR + co->index);
+}
+
+static int it8712_console_wait_key(struct console *co)
+{
+#ifdef CONFIG_ARCH_SL2312
+	struct uart_port *port = (it8712_ports + co->index);
+	unsigned int status;
+
+	do {
+		status = UART_GET_LSR(port);
+	} while (!UART_RX_DATA(status));
+	return UART_GET_CHAR(port);
+#else
+	return 0;
+#endif
+}
+
+static void /*__init*/ it8712_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
+{
+	printk("it8712 console get options : \n");
+
+	u_int uart_mc, quot;
+	uart_mc= UART_GET_MCR(port);
+
+	*parity = 'n';
+	if (uart_mc & UART_LCR_PARITY) {
+		if (uart_mc & UART_LCR_EVEN)
+			*parity = 'e';
+		else
+			*parity = 'o';
+	}
+
+	switch (uart_mc & UART_LCR_MSK){
+
+	case UART_LCR_WLEN5:
+		*bits = 5;
+		break;
+	case UART_LCR_WLEN6:
+		*bits = 6;
+		break;
+	case UART_LCR_WLEN7:
+		*bits = 7;
+		break;
+	case UART_LCR_WLEN8:
+		*bits = 8;
+		break;
+	}
+	UART_PUT_MCR(port,UART_LCR_DLAB);
+	quot = UART_GET_DIV_LO(port) | (UART_GET_DIV_HI(port) << 8);
+	UART_PUT_MCR(port,uart_mc);
+	*baud = (port->uartclk / (16 *quot));
+}
+
+static int __init it8712_console_setup(struct console *co, char *options)
+{
+	struct uart_port *port;
+	int baud = 38400;
+	int bits = 8;
+	int parity = 'n';
+	int flow= 'n';
+	int base, irq;
+	int i ;
+
+//	printk("it8712 console setup : \n");
+
+	LPCSetConfig(0, 0x02, 0x01);
+        LPCSetConfig(LDN_SERIAL1, 0x30, 0x1);
+        LPCSetConfig(LDN_SERIAL1, 0x23, 0x0);
+	base = IT8712_IO_BASE;
+	base += ((LPCGetConfig(LDN_SERIAL1, 0x60) << 8) + LPCGetConfig(LDN_SERIAL1, 0x61));
+	it8712_ports[0].mapbase = base;
+	it8712_ports[0].membase = IO_ADDRESS(base);
+	it8712_ports[0].irq = IRQ_SERIRQ0_OFFSET;
+       	irq = LPCGetConfig(LDN_SERIAL1, 0x70);
+	it8712_ports[0].irq += irq;
+
+	printk("it8712 irq is %x %x \n", it8712_ports[0].irq, irq);
+
+	// setup LPC Host 'quiet mode'
+	*((volatile unsigned int *)IO_ADDRESS((SL2312_LPC_HOST_BASE+0x04))) |= LPC_HOST_CONTINUE_MODE ;
+	for(i=0;i<1000;i++) ;						// delay
+	*((volatile unsigned int *)IO_ADDRESS((SL2312_LPC_HOST_BASE+0x04))) &= ~(LPC_HOST_CONTINUE_MODE) ;
+
+#ifdef CONFIG_ARCH_SL2312
+	/*
+	 * Check whether an invalid uart number has been specified, and
+	 * if so, search for the first available port that does have
+	 * console support.
+	 */
+	port = uart_get_console(it8712_ports,IT8712_NO_PORTS,co);
+#else
+	return -ENODEV;
+#endif
+
+	if (options)
+		uart_parse_options(options, &baud, &parity, &bits, &flow);
+	else
+		it8712_console_get_options(port, &baud, &parity, &bits);
+
+	return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct console it8712_console = {
+	name:           SERIAL_IT8712_NAME,
+	write:		it8712_console_write,
+#ifdef used_and_not_const_char_pointer
+	read:		it8712_console_read,
+#endif
+	device:		it8712_console_device,
+//	wait_key:	it8712_console_wait_key,
+	setup:		it8712_console_setup,
+	flags:		(CON_PRINTBUFFER|CON_ENABLED),
+	index:		-1,
+};
+
+void __init it8712_console_init(void)
+{
+	register_console(&it8712_console);
+}
+
+#define IT8712_CONSOLE	&it8712_console
+#else
+#define IT8712_CONSOLE	NULL
+#endif
+
+static struct uart_driver it8712_reg = {
+	owner:                  NULL,
+	normal_major:		SERIAL_IT8712_MAJOR,
+	normal_name:		SERIAL_IT8712_NAME,
+	normal_driver:		&normal,
+	callout_major:		CALLOUT_IT8712_MAJOR,
+	callout_name:		CALLOUT_IT8712_NAME,
+	callout_driver:		&callout,
+	table:			it8712_table,
+	termios:		it8712_termios,
+	termios_locked:		it8712_termios_locked,
+	minor:			SERIAL_IT8712_MINOR,
+	nr:			UART_NR,
+#ifdef CONFIG_ARCH_SL2312
+	port:			it8712_ports,
+#endif
+	state:			NULL,
+	cons:			IT8712_CONSOLE,
+};
+
+static int __init it8712_init(void)
+{
+//	printk("serial_it8712: it871212_init \n");
+
+	return uart_register_driver(&it8712_reg);
+}
+
+
+__initcall(it8712_init);
--- /dev/null
+++ b/drivers/serial/serial_sl2312.c
@@ -0,0 +1,827 @@
+/*
+ *  linux/drivers/char/serial_uart00.c
+ *
+ *  Driver for UART00 serial ports
+ *
+ *  Based on drivers/char/serial_amba.c, by ARM Limited &
+ *                                          Deep Blue Solutions Ltd.
+ *  Copyright 2001 Altera Corporation
+ *
+ * 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
+ *
+ *  $Id: serial_sl2312.c,v 1.1.1.1 2006/04/03 08:41:00 amos_lee Exp $
+ *
+ */
+#include <linux/module.h>
+
+#include <linux/errno.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/major.h>
+#include <linux/string.h>
+#include <linux/fcntl.h>
+#include <linux/ptrace.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/circ_buf.h>
+#include <linux/serial.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+#include <linux/serial_core.h>
+
+#include <asm/system.h>
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+#include <asm/bitops.h>
+#include <asm/sizes.h>
+#include <linux/spinlock.h>
+#include <linux/irq.h>
+
+
+#if defined(CONFIG_SERIAL_SL2312_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <asm/arch/sl2312.h>
+#define UART_TYPE (volatile unsigned int*)
+#include <asm/arch/uart.h>
+#include <asm/arch/int_ctrl.h>
+
+// #define DEBUG           1
+#define UART_NR		1
+
+
+#define SERIAL_SL2312_NAME	"ttyS"
+#define SERIAL_SL2312_MAJOR	204
+#define SERIAL_SL2312_MINOR	40      /* Temporary - will change in future */
+#define SERIAL_SL2312_NR	UART_NR
+#define UART_PORT_SIZE 0x50
+
+#define SL2312_NO_PORTS         UART_NR
+#define SL2312_ISR_PASS_LIMIT	256
+
+/*
+ * Access macros for the SL2312 UARTs
+ */
+#define UART_GET_INT_STATUS(p)	(inl(UART_IIR((p)->membase)) & 0x0F)      // interrupt identification
+#define UART_PUT_IER(p, c)      outl(c,UART_IER((p)->membase))    // interrupt enable
+#define UART_GET_IER(p)         inl(UART_IER((p)->membase))
+#define UART_PUT_CHAR(p, c)     outl(c,UART_THR((p)->membase))    // transmitter holding
+#define UART_GET_CHAR(p)        inl(UART_RBR((p)->membase))       // receive buffer
+#define UART_GET_LSR(p)         inl(UART_LSR((p)->membase))       // line status
+#define UART_GET_MSR(p)         inl(UART_MSR((p)->membase))       // modem status
+#define UART_GET_MCR(p)         inl(UART_MCR((p)->membase))       // modem control
+#define UART_PUT_MCR(p, c)      outl(c,UART_MCR((p)->membase))
+#define UART_GET_LCR(p)         inl(UART_LCR((p)->membase))       // mode control
+#define UART_PUT_LCR(p, c)      outl(c,UART_LCR((p)->membase))
+#define UART_GET_DIV_HI(p)	inl(UART_DIV_HI((p)->membase))
+#define UART_PUT_DIV_HI(p, c)	outl(c,UART_DIV_HI((p)->membase))
+#define UART_GET_DIV_LO(p)	inl(UART_DIV_LO((p)->membase))
+#define UART_PUT_DIV_LO(p, c)	outl(c,UART_DIV_LO((p)->membase))
+#define UART_PUT_MDR(p, c)      outl(c,UART_MDR((p)->membase))
+#define UART_RX_DATA(s)		((s) & UART_LSR_DR)
+#define UART_TX_READY(s)	((s) & UART_LSR_THRE)
+
+
+static void sl2312_stop_tx(struct uart_port *port)
+{
+        unsigned int reg;
+
+//        printk("sl2312 stop tx : \n");
+        reg = UART_GET_IER(port);
+        reg &= ~(UART_IER_TE);
+	UART_PUT_IER(port, reg);
+}
+
+static void sl2312_stop_rx(struct uart_port *port)
+{
+        unsigned int reg;
+
+//        printk("sl2312 stop rx : \n");
+        reg = UART_GET_IER(port);
+        reg &= ~(UART_IER_DR);
+	UART_PUT_IER(port, reg);
+
+}
+
+static void sl2312_enable_ms(struct uart_port *port)
+{
+        unsigned int reg;
+
+//        printk("sl2312 enable ms : \n");
+
+        reg = UART_GET_IER(port);
+        reg |= (UART_IER_MS);
+	UART_PUT_IER(port, reg);
+
+}
+
+static void
+sl2312_rx_chars(struct uart_port *port)
+{
+	struct tty_struct *tty = port->info->tty;
+	unsigned int status, mask, ch, flg, ignored = 0;
+
+
+ //       printk("sl2312_rx_chars : \n");
+	status = UART_GET_LSR(port);
+	while (UART_RX_DATA(status)) {
+
+		/*
+		 * We need to read rds before reading the
+		 * character from the fifo
+		 */
+		ch = UART_GET_CHAR(port);
+		port->icount.rx++;
+
+		//if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+		if (tty && !tty_buffer_request_room(tty, 1))
+			goto ignore_char;
+
+		flg = TTY_NORMAL;
+
+		/*
+		 * Note that the error handling code is
+		 * out of the main execution path
+		 */
+
+		if (status & (UART_LSR_OE|UART_LSR_PE|UART_LSR_FE|UART_LSR_BI|UART_LSR_DE))
+			goto handle_error;
+		if (uart_handle_sysrq_char(port, ch))
+			goto ignore_char;
+
+	error_return:
+		//*tty->flip.flag_buf_ptr++ = flg;
+		//*tty->flip.char_buf_ptr++ = ch;
+		//tty->flip.count++;
+		tty_insert_flip_char(tty, ch, flg);
+	ignore_char:
+		status = UART_GET_LSR(port);
+	} // end of while
+out:
+	tty_flip_buffer_push(tty);
+	return;
+
+handle_error:
+	if (status & UART_LSR_BI) {
+		status &= ~(UART_LSR_FE);
+		port->icount.brk++;
+
+#ifdef SUPPORT_SYSRQ
+		if (uart_handle_break(port))
+			goto ignore_char;
+#endif
+	} else if (status & UART_LSR_PE)
+		port->icount.parity++;
+	else if (status & UART_LSR_FE)
+		port->icount.frame++;
+
+	if (status & UART_LSR_OE)
+		port->icount.overrun++;
+
+	if (status & port->ignore_status_mask) {
+		if (++ignored > 100)
+			goto out;
+		goto ignore_char;
+	}
+
+	mask = status & port->read_status_mask;
+
+	if (mask & UART_LSR_BI)
+		flg = TTY_BREAK;
+	else if (mask & UART_LSR_PE)
+		flg = TTY_PARITY;
+	else if (mask & UART_LSR_FE)
+		flg = TTY_FRAME;
+
+	if (status & UART_LSR_OE) {
+		/*
+		 * CHECK: does overrun affect the current character?
+		 * ASSUMPTION: it does not.
+		 */
+		//*tty->flip.flag_buf_ptr++ = flg;
+		//*tty->flip.char_buf_ptr++ = ch;
+		//tty->flip.count++;
+
+		tty_insert_flip_char(tty, 0, TTY_BREAK);
+
+		// if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+		if (tty_buffer_request_room(tty, 1))
+			goto ignore_char;
+		ch = 0;
+		flg = TTY_OVERRUN;
+	}
+#ifdef SUPPORT_SYSRQ
+	port->sysrq = 0;
+#endif
+	goto error_return;
+}
+
+static void sl2312_tx_chars(struct uart_port *port)
+{
+	struct circ_buf *xmit = &port->info->xmit;
+	int count;
+
+
+	if (port->x_char) {
+		while(!(UART_GET_LSR(port)&UART_LSR_THRE));
+		UART_PUT_CHAR(port, port->x_char);
+		port->icount.tx++;
+		port->x_char = 0;
+
+		return;
+	}
+	if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
+		sl2312_stop_tx(port);
+
+		return;
+	}
+
+	count = port->fifosize >> 1;
+	do {
+		while(!(UART_GET_LSR(port)&UART_LSR_THRE));
+		UART_PUT_CHAR(port, xmit->buf[xmit->tail]);
+		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+		port->icount.tx++;
+		if (uart_circ_empty(xmit))
+			break;
+	} while (--count > 0);
+
+	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+		uart_write_wakeup(port);
+
+	if (uart_circ_empty(xmit))
+		sl2312_stop_tx(port);
+
+}
+
+static void sl2312_start_tx(struct uart_port *port)
+{
+        unsigned int reg;
+
+//        printk("sl2312 start tx : \n");
+        reg = UART_GET_IER(port);
+        reg |= (UART_IER_TE);
+	UART_PUT_IER(port, reg);
+
+	sl2312_tx_chars(port);
+}
+
+static void sl2312_modem_status(struct uart_port *port)
+{
+	unsigned int status;
+
+//        printk("it8712 modem status : \n");
+
+	status = UART_GET_MSR(port);
+
+	if (!(status & (UART_MSR_DCTS | UART_MSR_DDSR |
+		       UART_MSR_TERI | UART_MSR_DDCD)))
+		return;
+
+        if (status & UART_MSR_DDCD)
+                uart_handle_dcd_change(port, status & UART_MSR_DCD);
+
+        if (status & UART_MSR_DDSR)
+                port->icount.dsr++;
+
+        if (status & UART_MSR_DCTS)
+                uart_handle_cts_change(port, status & UART_MSR_CTS);
+
+	wake_up_interruptible(&port->info->delta_msr_wait);
+
+}
+
+static irqreturn_t sl2312_int(int irq, void *dev_id)
+{
+	struct uart_port *port = dev_id;
+	unsigned int status, pass_counter = 0;
+
+	status = UART_GET_INT_STATUS(port);
+	do {
+		switch(status)
+		{
+		   case UART_IIR_DR:
+		   case UART_IIR_RLS:
+			sl2312_rx_chars(port);
+		   break;
+		   case UART_IIR_TE:
+			sl2312_tx_chars(port);
+		   break;
+		   case UART_IIR_MODEM:
+			sl2312_modem_status(port);
+		   break;
+		   default:
+		   break;
+		}
+		if (pass_counter++ > SL2312_ISR_PASS_LIMIT)
+			break;
+
+		status = UART_GET_INT_STATUS(port);
+	} while (status);
+
+	return IRQ_HANDLED;
+}
+
+static u_int sl2312_tx_empty(struct uart_port *port)
+{
+//        printk("sl2312 tx empty : \n");
+
+	return ((UART_GET_LSR(port) & UART_LSR_TE)? TIOCSER_TEMT : 0);
+}
+
+static u_int sl2312_get_mctrl(struct uart_port *port)
+{
+	unsigned int result = 0;
+	unsigned int status;
+
+//        printk("sl2312 get mctrl : \n");
+
+	status = UART_GET_MSR(port);
+	if (status & UART_MSR_DCD)
+		result |= TIOCM_CAR;
+	if (status & UART_MSR_DSR)
+		result |= TIOCM_DSR;
+	if (status & UART_MSR_CTS)
+		result |= TIOCM_CTS;
+	if (status & UART_MSR_RI)
+		result |= TIOCM_RI;
+
+	return result;
+}
+
+static void sl2312_set_mctrl_null(struct uart_port *port, u_int mctrl)
+{
+}
+
+static void sl2312_break_ctl(struct uart_port *port, int break_state)
+{
+	unsigned int lcr;
+
+//        printk("sl2312 break ctl : \n");
+
+	lcr = UART_GET_LCR(port);
+	if (break_state == -1)
+		lcr |= UART_LCR_SETBREAK;
+	else
+		lcr &= ~UART_LCR_SETBREAK;
+	UART_PUT_LCR(port, lcr);
+}
+
+static inline u_int uart_calculate_quot(struct uart_port *port, u_int baud)
+{
+	u_int quot;
+
+	/* Special case: B0 rate */
+	if (!baud)
+		baud = 9600;
+
+	quot = (port->uartclk / (16 * baud)-1)  ;
+
+	return quot;
+}
+
+static void sl2312_set_termios(struct uart_port *port, struct ktermios *termios,
+                               struct ktermios *old)
+{
+	unsigned int  uart_mc, old_ier, baud, quot;
+	unsigned long flags;
+
+        termios->c_cflag |= CREAD;
+#ifdef DEBUG
+	printk("it8712_set_cflag(0x%x) called\n", cflag);
+#endif
+        baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
+        quot = (port->uartclk / (16 * baud))  ;
+        //uart_get_divisor(port, baud);
+
+	/* byte size and parity */
+	switch (termios->c_cflag & CSIZE) {
+	case CS5:
+              uart_mc = UART_LCR_LEN5;
+              break;
+	case CS6:
+              uart_mc = UART_LCR_LEN6;
+              break;
+	case CS7:
+              uart_mc = UART_LCR_LEN7;
+              break;
+	default: // CS8
+              uart_mc = UART_LCR_LEN8;
+              break;
+	}
+
+	if (termios->c_cflag & CSTOPB)
+		uart_mc|= UART_LCR_STOP;
+	if (termios->c_cflag & PARENB) {
+		uart_mc |= UART_LCR_EVEN;
+		if (!(termios->c_cflag & PARODD))
+			uart_mc |= UART_LCR_ODD;
+	}
+
+    spin_lock_irqsave(&port->lock, flags);
+        /*
+         * Update the per-port timeout
+         */
+        uart_update_timeout(port, termios->c_cflag, baud);
+	port->read_status_mask = UART_LSR_OE;
+	if (termios->c_iflag & INPCK)
+		port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
+	if (termios->c_iflag & (BRKINT | PARMRK))
+		port->read_status_mask |= UART_LSR_BI;
+
+	/*
+	 * Characters to ignore
+	 */
+	port->ignore_status_mask = 0;
+	if (termios->c_iflag & IGNPAR)
+		port->ignore_status_mask |= UART_LSR_FE | UART_LSR_PE;
+	if (termios->c_iflag & IGNBRK) {
+		port->ignore_status_mask |= UART_LSR_BI;
+		/*
+		 * If we're ignoring parity and break indicators,
+		 * ignore overruns to (for real raw support).
+		 */
+		if (termios->c_iflag & IGNPAR)
+			port->ignore_status_mask |= UART_LSR_OE;
+	}
+
+	//save_flags(flags); cli();
+	old_ier = UART_GET_IER(port);
+
+        if(UART_ENABLE_MS(port, termios->c_cflag))
+             old_ier |= UART_IER_MS;
+
+	/* Set baud rate */
+	UART_PUT_LCR(port, UART_LCR_DLAB);
+	UART_PUT_DIV_LO(port, (quot & 0xff));
+	UART_PUT_DIV_HI(port, ((quot & 0xf00) >> 8));
+
+	UART_PUT_LCR(port, uart_mc);
+	UART_PUT_IER(port, old_ier);
+
+	//restore_flags(flags);
+	spin_unlock_irqrestore(&port->lock, flags);
+}
+
+
+
+static int sl2312_startup(struct uart_port *port)
+{
+	int retval;
+	unsigned int regs;
+
+//        printk("sl2312 startup : \n");
+
+	/*
+	 * Use iobase to store a pointer to info. We need this to start a
+	 * transmission as the tranmittr interrupt is only generated on
+	 * the transition to the idle state
+	 */
+
+	/*
+	 * Allocate the IRQ
+	 */
+	retval = request_irq(port->irq, sl2312_int, IRQF_DISABLED, "sl2312", port);
+	if (retval)
+		return retval;
+
+        /* setup interrupt controller  */
+        regs = *((volatile unsigned int *)IRQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
+        regs &= ~(IRQ_UART_MASK);
+        *((volatile unsigned int *)IRQ_TMODE(IO_ADDRESS(SL2312_INTERRUPT_BASE))) = regs;
+        regs = *((volatile unsigned int *)IRQ_TLEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE)));
+        regs &= ~(IRQ_UART_MASK);
+        *((volatile unsigned int *)IRQ_TLEVEL(IO_ADDRESS(SL2312_INTERRUPT_BASE))) = regs;
+        *((volatile unsigned int *)IRQ_MASK(IO_ADDRESS(SL2312_INTERRUPT_BASE))) |= (unsigned int)(IRQ_UART_MASK);
+
+	/*
+	 * Finally, enable interrupts. Use the TII interrupt to minimise
+	 * the number of interrupts generated. If higher performance is
+	 * needed, consider using the TI interrupt with a suitable FIFO
+	 * threshold
+	 */
+	UART_PUT_IER(port, (UART_IER_DR|UART_IER_TE));
+
+	return 0;
+}
+
+static void sl2312_shutdown(struct uart_port *port)
+{
+//        printk("sl2312 shutdown : \n");
+
+	/*
+	 * disable all interrupts, disable the port
+	 */
+	UART_PUT_IER(port, 0x0);
+
+	/* disable break condition and fifos */
+//	UART_PUT_MCR(port, (UART_GET_MCR(port)&UART_MCR_MASK));
+
+	/*
+	 * Free the interrupt
+	 */
+	free_irq(port->irq, port);
+}
+
+static const char *sl2312_type(struct uart_port *port)
+{
+	return port->type == PORT_SL2312 ? "SL2312" : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'
+ */
+static void sl2312_release_port(struct uart_port *port)
+{
+//        printk("sl2312 release port : \n");
+
+	release_mem_region(port->mapbase, UART_PORT_SIZE);
+}
+
+/*
+ * Request the memory region(s) being used by 'port'
+ */
+static int sl2312_request_port(struct uart_port *port)
+{
+	return request_mem_region(port->mapbase, UART_PORT_SIZE,
+				    "serial_sl2312") != NULL ? 0 : -EBUSY;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void sl2312_config_port(struct uart_port *port, int flags)
+{
+
+	if (flags & UART_CONFIG_TYPE) {
+		if (sl2312_request_port(port) == 0)
+			port->type = PORT_SL2312;
+	}
+}
+
+/*
+ * verify the new serial_struct (for TIOCSSERIAL).
+ */
+static int sl2312_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+	int ret = 0;
+
+	if (ser->type != PORT_UNKNOWN && ser->type != PORT_UART00)
+		ret = -EINVAL;
+	if (ser->irq < 0 || ser->irq >= NR_IRQS)
+		ret = -EINVAL;
+	if (ser->baud_base < 9600)
+		ret = -EINVAL;
+	return ret;
+}
+
+static struct uart_ops sl2312_pops = {
+	.tx_empty		=sl2312_tx_empty,
+	.set_mctrl		=sl2312_set_mctrl_null,
+	.get_mctrl		=sl2312_get_mctrl,
+	.stop_tx		=sl2312_stop_tx,
+	.start_tx		=sl2312_start_tx,
+	.stop_rx		=sl2312_stop_rx,
+	.enable_ms		=sl2312_enable_ms,
+	.break_ctl		=sl2312_break_ctl,
+	.startup		=sl2312_startup,
+	.shutdown		=sl2312_shutdown,
+	.set_termios	=sl2312_set_termios,
+	.type			=sl2312_type,
+	.release_port	=sl2312_release_port,
+	.request_port	=sl2312_request_port,
+	.config_port	=sl2312_config_port,
+	.verify_port	=sl2312_verify_port,
+};
+
+#ifdef CONFIG_ARCH_SL2312
+
+static struct uart_port sl2312_ports[UART_NR] = {
+	{
+		membase:	(void *)IO_ADDRESS(SL2312_UART_BASE),
+		mapbase:	SL2312_UART_BASE,
+		iotype:		SERIAL_IO_MEM,
+		irq:		IRQ_UART,
+		uartclk:	UART_CLK,
+		fifosize:	16,
+		ops:		&sl2312_pops,
+		flags:		ASYNC_BOOT_AUTOCONF,
+	}
+};
+
+#endif
+
+#ifdef CONFIG_SERIAL_SL2312_CONSOLE
+#ifdef used_and_not_const_char_pointer
+static int sl2312_console_read(struct uart_port *port, char *s, u_int count)
+{
+	unsigned int status;
+	int c;
+#ifdef DEBUG
+	printk("sl2312_console_read() called\n");
+#endif
+
+	c = 0;
+	while (c < count) {
+		status = UART_GET_LSR(port);
+ 		if (UART_RX_DATA(status)) {
+			*s++ = UART_GET_CHAR(port);
+			c++;
+		} else {
+			// nothing more to get, return
+			return c;
+		}
+	}
+	// return the count
+	return c;
+}
+#endif
+static void sl2312_console_write(struct console *co, const char *s, unsigned count)
+{
+#ifdef CONFIG_ARCH_SL2312
+	struct uart_port *port = sl2312_ports + co->index;
+	unsigned int status, old_ies;
+	int i;
+
+	/*
+	 *	First save the CR then disable the interrupts
+	 */
+	old_ies = UART_GET_IER(port);
+	UART_PUT_IER(port,0x0);
+
+	/*
+	 *	Now, do each character
+	 */
+	for (i = 0; i < count; i++) {
+		do {
+			status = UART_GET_LSR(port);
+		} while (!UART_TX_READY(status));
+		UART_PUT_CHAR(port, s[i]);
+		if (s[i] == '\n') {
+			do {
+				status = UART_GET_LSR(port);
+			} while (!UART_TX_READY(status));
+			UART_PUT_CHAR(port, '\r');
+		}
+	}
+
+	/*
+	 *	Finally, wait for transmitter to become empty
+	 *	and restore the IES
+	 */
+	do {
+		status = UART_GET_LSR(port);
+	} while (!(status&UART_LSR_TE));
+	UART_PUT_IER(port, old_ies);
+#endif
+}
+
+#if 0
+static void sl2312_console_device(struct console *co,int *index)
+{
+
+	struct uart_driver *p = co->data;
+    *index = co->index;
+    return p->tty_driver;
+
+}
+#endif
+
+static void /*__init*/ sl2312_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
+{
+//	printk("sl2312 console get options : \n");
+
+	u_int uart_mc, quot;
+	uart_mc= UART_GET_MCR(port);
+
+	*parity = 'n';
+	if (uart_mc & UART_LCR_PE) {
+		if (uart_mc & UART_LCR_EVEN)
+			*parity = 'e';
+		else
+			*parity = 'o';
+	}
+
+	switch (uart_mc & UART_LCR_MSK){
+
+	case UART_LCR_LEN5:
+		*bits = 5;
+		break;
+	case UART_LCR_LEN6:
+		*bits = 6;
+		break;
+	case UART_LCR_LEN7:
+		*bits = 7;
+		break;
+	case UART_LCR_LEN8:
+		*bits = 8;
+		break;
+	}
+	UART_PUT_MCR(port,UART_LCR_DLAB);
+	quot = UART_GET_DIV_LO(port) | (UART_GET_DIV_HI(port) << 8);
+	UART_PUT_MCR(port,uart_mc);
+	*baud = port->uartclk / (16 *quot );
+}
+
+static int __init sl2312_console_setup(struct console *co, char *options)
+{
+	struct uart_port *port;
+	int baud = 19200;
+	int bits = 8;
+	int parity = 'n';
+	int flow= 'n';
+
+	printk("sl2312 console setup : \n");
+
+#ifdef CONFIG_ARCH_SL2312
+	/*
+	 * Check whether an invalid uart number has been specified, and
+	 * if so, search for the first available port that does have
+	 * console support.
+	 */
+	port = uart_get_console(sl2312_ports,SL2312_NO_PORTS,co);
+#else
+	return -ENODEV;
+#endif
+
+	if (options)
+		uart_parse_options(options, &baud, &parity, &bits, &flow);
+	else
+		sl2312_console_get_options(port, &baud, &parity, &bits);
+
+	return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+extern struct uart_driver sl2312_reg;
+static struct console sl2312_console = {
+	.name      = SERIAL_SL2312_NAME,
+	.write		= sl2312_console_write,
+	.device		= uart_console_device,
+//	.device		= sl2312_console_device,
+	.setup		= sl2312_console_setup,
+//	.flags		= (CON_PRINTBUFFER|CON_ENABLED),
+	.flags		= CON_PRINTBUFFER,
+	.index		= -1,
+	.data       = &sl2312_reg,
+};
+
+static int __init sl2312_console_init(void)
+{
+	register_console(&sl2312_console);
+	return 0;
+
+}
+
+console_initcall(sl2312_console_init);
+
+#define SL2312_CONSOLE	&sl2312_console
+#else
+#define SL2312_CONSOLE	NULL
+#endif
+
+// static
+struct uart_driver sl2312_reg = {
+	.owner         = NULL,
+	.driver_name	= SERIAL_SL2312_NAME,
+	.dev_name		= SERIAL_SL2312_NAME,
+	.major          = SERIAL_SL2312_MAJOR,
+	.minor			= SERIAL_SL2312_MINOR,
+	.nr				= UART_NR,
+	.cons			= SL2312_CONSOLE,
+};
+
+static int __init sl2312_init(void)
+{
+       int result;
+	//printk("serial_it8712: it871212_init \n");
+
+        result = uart_register_driver(&sl2312_reg);
+        if(result)
+             return result;
+	result = uart_add_one_port(&sl2312_reg, &sl2312_ports[0]);
+
+        return result;
+}
+
+
+__initcall(sl2312_init);
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -147,6 +147,10 @@
 #define PORT_SB1250_DUART	77
 
 
+/* Storlink Soc */
+#define PORT_SL2312     72
+#define PORT_IT8712     73
+
 #ifdef __KERNEL__
 
 #include <linux/compiler.h>
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -70,6 +70,16 @@
 obj-$(CONFIG_APPLICOM)		+= applicom.o
 obj-$(CONFIG_SONYPI)		+= sonypi.o
 obj-$(CONFIG_RTC)		+= rtc.o
+
+###  for Storlink SoC ###
+obj-$(CONFIG_SL2312_RTC) += sl2312_rtc.o
+obj-$(CONFIG_IT8712_GPIO)   += it8712_gpio.o
+obj-$(CONFIG_GEMINI_GPIO)   += gemini_gpio.o
+obj-$(CONFIG_GEMINI_PWC) += gemini_pwr.o
+obj-$(CONFIG_GEMINI_CIR)    += gemini_cir.o
+obj-$(CONFIG_GEMINI_I2S)    += gemini_i2s.o
+obj-$(CONFIG_SL2312_WATCHDOG) += sl2312_wd.o
+
 obj-$(CONFIG_HPET)		+= hpet.o
 obj-$(CONFIG_GEN_RTC)		+= genrtc.o
 obj-$(CONFIG_EFI_RTC)		+= efirtc.o
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -280,6 +280,56 @@
 
 comment "Non-8250 serial port support"
 
+config SERIAL_SL2312
+	bool "SL2312  serial port (sl2312) support"
+	depends on ARCH_SL2312
+	select SERIAL_CORE
+	select SERIAL_SL2312_CONSOLE
+	help
+         Say Y here if you want to use the hard logic uart on SWORD. This
+         driver also supports soft logic implentations of this uart core.
+
+config SERIAL_SL2312_CONSOLE
+	bool "Support for console on SL2312 serial port"
+	depends on SERIAL_SL2312
+	select SERIAL_CORE_CONSOLE
+	help
+        Say Y here if you want to support a serial console on an SWORD
+        hard logic uart or uart00 IP core.
+
+        Even if you say Y here, the currently visible virtual console
+        (/dev/tty0) will still be used as the system console by default, but
+        you can alter that using a kernel command line option such as
+        "console=ttyS0". (Try "man bootparam" or see the documentation of
+        your boot loader (lilo or loadlin) about how to pass options to the
+        kernel at boot time.)
+
+
+config SERIAL_IT8712
+	bool "Sl2312 serial port(IT8712) support"
+	depends on ARM && ARCH_SL2312 && SL2312_LPC
+	select SERIAL_CORE
+	select SERIAL_IT8712_CONSOLE
+	help
+	  Say Y here if you want to use the hard logic uart on Excalibur. This
+	  driver also supports soft logic implentations of this uart core.
+
+config SERIAL_IT8712_CONSOLE
+	bool "Support for console on Sword serial port(IT8712)"
+	depends on SERIAL_IT8712
+	select SERIAL_CORE_CONSOLE
+	help
+	  Say Y here if you want to support a serial console on an Excalibur
+	  hard logic uart or uart00 IP core.
+
+	  Even if you say Y here, the currently visible virtual console
+	  (/dev/tty0) will still be used as the system console by default, but
+	  you can alter that using a kernel command line option such as
+	  "console=ttySI0". (Try "man bootparam" or see the documentation of
+	  your boot loader (lilo or loadlin) about how to pass options to the
+	  kernel at boot time.)
+
+
 config SERIAL_AMBA_PL010
 	tristate "ARM AMBA PL010 serial port support"
 	depends on ARM_AMBA && (BROKEN || !ARCH_VERSATILE)
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -62,5 +62,7 @@
 obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o
 obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o
 obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
+obj-$(CONFIG_SERIAL_IT8712) += it8712.o
+obj-$(CONFIG_SERIAL_SL2312) += serial_sl2312.o
 obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o
 obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o