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
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
15990
15991
15992
15993
15994
15995
15996
15997
15998
15999
16000
16001
16002
16003
16004
16005
16006
16007
16008
16009
16010
16011
16012
16013
16014
16015
16016
16017
16018
16019
16020
16021
16022
16023
16024
16025
16026
16027
16028
16029
16030
16031
16032
16033
16034
16035
16036
16037
16038
16039
16040
16041
16042
16043
16044
16045
16046
16047
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057
16058
16059
16060
16061
16062
16063
16064
16065
16066
16067
16068
16069
16070
16071
16072
16073
16074
16075
16076
16077
16078
16079
16080
16081
16082
16083
16084
16085
16086
16087
16088
16089
16090
16091
16092
16093
16094
16095
16096
16097
16098
16099
16100
16101
16102
16103
16104
16105
16106
16107
16108
16109
16110
16111
16112
16113
16114
16115
16116
16117
16118
16119
16120
16121
16122
16123
16124
16125
16126
16127
16128
16129
16130
16131
16132
16133
16134
16135
16136
16137
16138
16139
16140
16141
16142
16143
16144
16145
16146
16147
16148
16149
16150
16151
16152
16153
16154
16155
16156
16157
16158
16159
16160
16161
16162
16163
16164
16165
16166
16167
16168
16169
16170
16171
16172
16173
16174
16175
16176
16177
16178
16179
16180
16181
16182
16183
16184
16185
16186
16187
16188
16189
16190
16191
16192
16193
16194
16195
16196
16197
16198
16199
16200
16201
16202
16203
16204
16205
16206
16207
16208
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221
16222
16223
16224
16225
16226
16227
16228
16229
16230
16231
16232
16233
16234
16235
16236
16237
16238
16239
16240
16241
16242
16243
16244
16245
16246
16247
16248
16249
16250
16251
16252
16253
16254
16255
16256
16257
16258
16259
16260
16261
16262
16263
16264
16265
16266
16267
16268
16269
16270
16271
16272
16273
16274
16275
16276
16277
16278
16279
16280
16281
16282
16283
16284
16285
16286
16287
16288
16289
16290
16291
16292
16293
16294
16295
16296
16297
16298
16299
16300
16301
16302
16303
16304
16305
16306
16307
16308
16309
16310
16311
16312
16313
16314
16315
16316
16317
16318
16319
16320
16321
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331
16332
16333
16334
16335
16336
16337
16338
16339
16340
16341
16342
16343
16344
16345
16346
16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
16360
16361
16362
16363
16364
16365
16366
16367
16368
16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
16381
16382
16383
16384
16385
16386
16387
16388
16389
16390
16391
16392
16393
16394
16395
16396
16397
16398
16399
16400
16401
16402
16403
16404
16405
16406
16407
16408
16409
16410
16411
16412
16413
16414
16415
16416
16417
16418
16419
16420
16421
16422
16423
16424
16425
16426
16427
16428
16429
16430
16431
16432
16433
16434
16435
16436
16437
16438
16439
16440
16441
16442
16443
16444
16445
16446
16447
16448
16449
16450
16451
16452
16453
16454
16455
16456
16457
16458
16459
16460
16461
16462
16463
16464
16465
16466
16467
16468
16469
16470
16471
16472
16473
16474
16475
16476
16477
16478
16479
16480
16481
16482
16483
16484
16485
16486
16487
16488
16489
16490
16491
16492
16493
16494
16495
16496
16497
16498
16499
16500
16501
16502
16503
16504
16505
16506
16507
16508
16509
16510
16511
16512
16513
16514
16515
16516
16517
16518
16519
16520
16521
16522
16523
16524
16525
16526
16527
16528
16529
16530
16531
16532
16533
16534
16535
16536
16537
16538
16539
16540
16541
16542
16543
16544
16545
16546
16547
16548
16549
16550
16551
16552
16553
16554
16555
16556
16557
16558
16559
16560
16561
16562
16563
16564
16565
16566
16567
16568
16569
16570
16571
16572
16573
16574
16575
16576
16577
16578
16579
16580
16581
16582
16583
16584
16585
16586
16587
16588
16589
16590
16591
16592
16593
16594
16595
16596
16597
16598
16599
16600
16601
16602
16603
16604
16605
16606
16607
16608
16609
16610
16611
16612
16613
16614
16615
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625
16626
16627
16628
16629
16630
16631
16632
16633
16634
16635
16636
16637
16638
16639
16640
16641
16642
16643
16644
16645
16646
16647
16648
16649
16650
16651
16652
16653
16654
16655
16656
16657
16658
16659
16660
16661
16662
16663
16664
16665
16666
16667
16668
16669
16670
16671
16672
16673
16674
16675
16676
16677
16678
16679
16680
16681
16682
16683
16684
16685
16686
16687
16688
16689
16690
16691
16692
16693
16694
16695
16696
16697
16698
16699
16700
16701
16702
16703
16704
16705
16706
16707
16708
16709
16710
16711
16712
16713
16714
16715
16716
16717
16718
16719
16720
16721
16722
16723
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733
16734
16735
16736
16737
16738
16739
16740
16741
16742
16743
16744
16745
16746
16747
16748
16749
16750
16751
16752
16753
16754
16755
16756
16757
16758
16759
16760
16761
16762
16763
16764
16765
16766
16767
16768
16769
16770
16771
16772
16773
16774
16775
16776
16777
16778
16779
16780
16781
16782
16783
16784
16785
16786
16787
16788
16789
16790
16791
16792
16793
16794
16795
16796
16797
16798
16799
16800
16801
16802
16803
16804
16805
16806
16807
16808
16809
16810
16811
16812
16813
16814
16815
16816
16817
16818
16819
16820
16821
16822
16823
16824
16825
16826
16827
16828
16829
16830
16831
16832
16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
16852
16853
16854
16855
16856
16857
16858
16859
16860
16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884
16885
16886
16887
16888
16889
16890
16891
16892
16893
16894
16895
16896
16897
16898
16899
16900
16901
16902
16903
16904
16905
16906
16907
16908
16909
16910
16911
16912
16913
16914
16915
16916
16917
16918
16919
16920
16921
16922
16923
16924
16925
16926
16927
16928
16929
16930
16931
16932
16933
16934
16935
16936
16937
16938
16939
16940
16941
16942
16943
16944
16945
16946
16947
16948
16949
16950
16951
16952
16953
16954
16955
16956
16957
16958
16959
16960
16961
16962
16963
16964
16965
16966
16967
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999
17000
17001
17002
17003
17004
17005
17006
17007
17008
17009
17010
17011
17012
17013
17014
17015
17016
17017
17018
17019
17020
17021
17022
17023
17024
17025
17026
17027
17028
17029
17030
17031
17032
17033
17034
17035
17036
17037
17038
17039
17040
17041
17042
17043
17044
17045
17046
17047
17048
17049
17050
17051
17052
17053
17054
17055
17056
17057
17058
17059
17060
17061
17062
17063
17064
17065
17066
17067
17068
17069
17070
17071
17072
17073
17074
17075
17076
17077
17078
17079
17080
17081
17082
17083
17084
17085
17086
17087
17088
17089
17090
17091
17092
17093
17094
17095
17096
17097
17098
17099
17100
17101
17102
17103
17104
17105
17106
17107
17108
17109
17110
17111
17112
17113
17114
17115
17116
17117
17118
17119
17120
17121
17122
17123
17124
17125
17126
17127
17128
17129
17130
17131
17132
17133
17134
17135
17136
17137
17138
17139
17140
17141
17142
17143
17144
17145
17146
17147
17148
17149
17150
17151
17152
17153
17154
17155
17156
17157
17158
17159
17160
17161
17162
17163
17164
17165
17166
17167
17168
17169
17170
17171
17172
17173
17174
17175
17176
17177
17178
17179
17180
17181
17182
17183
17184
17185
17186
17187
17188
17189
17190
17191
17192
17193
17194
17195
17196
17197
17198
17199
17200
17201
17202
17203
17204
17205
17206
17207
17208
17209
17210
17211
17212
17213
17214
17215
17216
17217
17218
17219
17220
17221
17222
17223
17224
17225
17226
17227
17228
17229
17230
17231
17232
17233
17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
17250
17251
17252
17253
17254
17255
17256
17257
17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
17271
17272
17273
17274
17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
17294
17295
17296
17297
17298
17299
17300
17301
17302
17303
17304
17305
17306
17307
17308
17309
17310
17311
17312
17313
17314
17315
17316
17317
17318
17319
17320
17321
17322
17323
17324
17325
17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
17350
17351
17352
17353
17354
17355
17356
17357
17358
17359
17360
17361
17362
17363
17364
17365
17366
17367
17368
17369
17370
17371
17372
17373
17374
17375
17376
17377
17378
17379
17380
17381
17382
17383
17384
17385
17386
17387
17388
17389
17390
17391
17392
17393
17394
17395
17396
17397
17398
17399
17400
17401
17402
17403
17404
17405
17406
17407
17408
17409
17410
17411
17412
17413
17414
17415
17416
17417
17418
17419
17420
17421
17422
17423
17424
17425
17426
17427
17428
17429
17430
17431
17432
17433
17434
17435
17436
17437
17438
17439
17440
17441
17442
17443
17444
17445
17446
17447
17448
17449
17450
17451
17452
17453
17454
17455
17456
17457
17458
17459
17460
17461
17462
17463
17464
17465
17466
17467
17468
17469
17470
17471
17472
17473
17474
17475
17476
17477
17478
17479
17480
17481
17482
17483
17484
17485
17486
17487
17488
17489
17490
17491
17492
17493
17494
17495
17496
17497
17498
17499
17500
17501
17502
17503
17504
17505
17506
17507
17508
17509
17510
17511
17512
17513
17514
17515
17516
17517
17518
17519
17520
17521
17522
17523
17524
17525
17526
17527
17528
17529
17530
17531
17532
17533
17534
17535
17536
17537
17538
17539
17540
17541
17542
17543
17544
17545
17546
17547
17548
17549
17550
17551
17552
17553
17554
17555
17556
17557
17558
17559
17560
17561
17562
17563
17564
17565
17566
17567
17568
17569
17570
17571
17572
17573
17574
17575
17576
17577
17578
17579
17580
17581
17582
17583
17584
17585
17586
17587
17588
17589
17590
17591
17592
17593
17594
17595
17596
17597
17598
17599
17600
17601
17602
17603
17604
17605
17606
17607
17608
17609
17610
17611
17612
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624
17625
17626
17627
17628
17629
17630
17631
17632
17633
17634
17635
17636
17637
17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709
17710
17711
17712
17713
17714
17715
17716
17717
17718
17719
17720
17721
17722
17723
17724
17725
17726
17727
17728
17729
17730
17731
17732
17733
17734
17735
17736
17737
17738
17739
17740
17741
17742
17743
17744
17745
17746
17747
17748
17749
17750
17751
17752
17753
17754
17755
17756
17757
17758
17759
17760
17761
17762
17763
17764
17765
17766
17767
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779
17780
17781
17782
17783
17784
17785
17786
17787
17788
17789
17790
17791
17792
17793
17794
17795
17796
17797
17798
17799
17800
17801
17802
17803
17804
17805
17806
17807
17808
17809
17810
17811
17812
17813
17814
17815
17816
17817
17818
17819
17820
17821
17822
17823
17824
17825
17826
17827
17828
17829
17830
17831
17832
17833
17834
17835
17836
17837
17838
17839
17840
17841
17842
17843
17844
17845
17846
17847
17848
17849
17850
17851
17852
17853
17854
17855
17856
17857
17858
17859
17860
17861
17862
17863
17864
17865
17866
17867
17868
17869
17870
17871
17872
17873
17874
17875
17876
17877
17878
17879
17880
17881
17882
17883
17884
17885
17886
17887
17888
17889
17890
17891
17892
17893
17894
17895
17896
17897
17898
17899
17900
17901
17902
17903
17904
17905
17906
17907
17908
17909
17910
17911
17912
17913
17914
17915
17916
17917
17918
17919
17920
17921
17922
17923
17924
17925
17926
17927
17928
17929
17930
17931
17932
17933
17934
17935
17936
17937
17938
17939
17940
17941
17942
17943
17944
17945
17946
17947
17948
17949
17950
17951
17952
17953
17954
17955
17956
17957
17958
17959
17960
17961
17962
17963
17964
17965
17966
17967
17968
17969
17970
17971
17972
17973
17974
17975
17976
17977
17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
17989
17990
17991
17992
17993
17994
17995
17996
17997
17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
18009
18010
18011
18012
18013
18014
18015
18016
18017
18018
18019
18020
18021
18022
18023
18024
18025
18026
18027
18028
18029
18030
18031
18032
18033
18034
18035
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047
18048
18049
18050
18051
18052
18053
18054
18055
18056
18057
18058
18059
18060
18061
18062
18063
18064
18065
18066
18067
18068
18069
18070
18071
18072
18073
18074
18075
18076
18077
18078
18079
18080
18081
18082
18083
18084
18085
18086
18087
18088
18089
18090
18091
18092
18093
18094
18095
18096
18097
18098
18099
18100
18101
18102
18103
18104
18105
18106
18107
18108
18109
18110
18111
18112
18113
18114
18115
18116
18117
18118
18119
18120
18121
18122
18123
18124
18125
18126
18127
18128
18129
18130
18131
18132
18133
18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
18157
18158
18159
18160
18161
18162
18163
18164
18165
18166
18167
18168
18169
18170
18171
18172
18173
18174
18175
18176
18177
18178
18179
18180
18181
18182
18183
18184
18185
18186
18187
18188
18189
18190
18191
18192
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204
18205
18206
18207
18208
18209
18210
18211
18212
18213
18214
18215
18216
18217
18218
18219
18220
18221
18222
18223
18224
18225
18226
18227
18228
18229
18230
18231
18232
18233
18234
18235
18236
18237
18238
18239
18240
18241
18242
18243
18244
18245
18246
18247
18248
18249
18250
18251
18252
18253
18254
18255
18256
18257
18258
18259
18260
18261
18262
18263
18264
18265
18266
18267
18268
18269
18270
18271
18272
18273
18274
18275
18276
18277
18278
18279
18280
18281
18282
18283
18284
18285
18286
18287
18288
18289
18290
18291
18292
18293
18294
18295
18296
18297
18298
18299
18300
18301
18302
18303
18304
18305
18306
18307
18308
18309
18310
18311
18312
18313
18314
18315
18316
18317
18318
18319
18320
18321
18322
18323
18324
18325
18326
18327
18328
18329
18330
18331
18332
18333
18334
18335
18336
18337
18338
18339
18340
18341
18342
18343
18344
18345
18346
18347
18348
18349
18350
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387
18388
18389
18390
18391
18392
18393
18394
18395
18396
18397
18398
18399
18400
18401
18402
18403
18404
18405
18406
18407
18408
18409
18410
18411
18412
18413
18414
18415
18416
18417
18418
18419
18420
18421
18422
18423
18424
18425
18426
18427
18428
18429
18430
18431
18432
18433
18434
18435
18436
18437
18438
18439
18440
18441
18442
18443
18444
18445
18446
18447
18448
18449
18450
18451
18452
18453
18454
18455
18456
18457
18458
18459
18460
18461
18462
18463
18464
18465
18466
18467
18468
18469
18470
18471
18472
18473
18474
18475
18476
18477
18478
18479
18480
18481
18482
18483
18484
18485
18486
18487
18488
18489
18490
18491
18492
18493
18494
18495
18496
18497
18498
18499
18500
18501
18502
18503
18504
18505
18506
18507
18508
18509
18510
18511
18512
18513
18514
18515
18516
18517
18518
18519
18520
18521
18522
18523
18524
18525
18526
18527
18528
18529
18530
18531
18532
18533
18534
18535
18536
18537
18538
18539
18540
18541
18542
18543
18544
18545
18546
18547
18548
18549
18550
18551
18552
18553
18554
18555
18556
18557
18558
18559
18560
18561
18562
18563
18564
18565
18566
18567
18568
18569
18570
18571
18572
18573
18574
18575
18576
18577
18578
18579
18580
18581
18582
18583
18584
18585
18586
18587
18588
18589
18590
18591
18592
18593
18594
18595
18596
18597
18598
18599
18600
18601
18602
18603
18604
18605
18606
18607
18608
18609
18610
18611
18612
18613
18614
18615
18616
18617
18618
18619
18620
18621
18622
18623
18624
18625
18626
18627
18628
18629
18630
18631
18632
18633
18634
18635
18636
18637
18638
18639
18640
18641
18642
18643
18644
18645
18646
18647
18648
18649
18650
18651
18652
18653
18654
18655
18656
18657
18658
18659
18660
18661
18662
18663
18664
18665
18666
18667
18668
18669
18670
18671
18672
18673
18674
18675
18676
18677
18678
18679
18680
18681
18682
18683
18684
18685
18686
18687
18688
18689
18690
18691
18692
18693
18694
18695
18696
18697
18698
18699
18700
18701
18702
18703
18704
18705
18706
18707
18708
18709
18710
18711
18712
18713
18714
18715
18716
18717
18718
18719
18720
18721
18722
18723
18724
18725
18726
18727
18728
18729
18730
18731
18732
18733
18734
18735
18736
18737
18738
18739
18740
18741
18742
18743
18744
18745
18746
18747
18748
18749
18750
18751
18752
18753
18754
18755
18756
18757
18758
18759
18760
18761
18762
18763
18764
18765
18766
18767
18768
18769
18770
18771
18772
18773
18774
18775
18776
18777
18778
18779
18780
18781
18782
18783
18784
18785
18786
18787
18788
18789
18790
18791
18792
18793
18794
18795
18796
18797
18798
18799
18800
18801
18802
18803
18804
18805
18806
18807
18808
18809
18810
18811
18812
18813
18814
18815
18816
18817
18818
18819
18820
18821
18822
18823
18824
18825
18826
18827
18828
18829
18830
18831
18832
18833
18834
18835
18836
18837
18838
18839
18840
18841
18842
18843
18844
18845
18846
18847
18848
18849
18850
18851
18852
18853
18854
18855
18856
18857
18858
18859
18860
18861
18862
18863
18864
18865
18866
18867
18868
18869
18870
18871
18872
18873
18874
18875
18876
18877
18878
18879
18880
18881
18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
18893
18894
18895
18896
18897
18898
18899
18900
18901
18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
18912
18913
18914
18915
18916
18917
18918
18919
18920
18921
18922
18923
18924
18925
18926
18927
18928
18929
18930
18931
18932
18933
18934
18935
18936
18937
18938
18939
18940
18941
18942
18943
18944
18945
18946
18947
18948
18949
18950
18951
18952
18953
18954
18955
18956
18957
18958
18959
18960
18961
18962
18963
18964
18965
18966
18967
18968
18969
18970
18971
18972
18973
18974
18975
18976
18977
18978
18979
18980
18981
18982
18983
18984
18985
18986
18987
18988
18989
18990
18991
18992
18993
18994
18995
18996
18997
18998
18999
19000
19001
19002
19003
19004
19005
19006
19007
19008
19009
19010
19011
19012
19013
19014
19015
19016
19017
19018
19019
19020
19021
19022
19023
19024
19025
19026
19027
19028
19029
19030
19031
19032
19033
19034
19035
19036
19037
19038
19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
19184
19185
19186
19187
19188
19189
19190
19191
19192
19193
19194
19195
19196
19197
19198
19199
19200
19201
19202
19203
19204
19205
19206
19207
19208
19209
19210
19211
19212
19213
19214
19215
19216
19217
19218
19219
19220
19221
19222
19223
19224
19225
19226
19227
19228
19229
19230
19231
19232
19233
19234
19235
19236
19237
19238
19239
19240
19241
19242
19243
19244
19245
19246
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256
19257
19258
19259
19260
19261
19262
19263
19264
19265
19266
19267
19268
19269
19270
19271
19272
19273
19274
19275
19276
19277
19278
19279
19280
19281
19282
19283
19284
19285
19286
19287
19288
19289
19290
19291
19292
19293
19294
19295
19296
19297
19298
19299
19300
19301
19302
19303
19304
19305
19306
19307
19308
19309
19310
19311
19312
19313
19314
19315
19316
19317
19318
19319
19320
19321
19322
19323
19324
19325
19326
19327
19328
19329
19330
19331
19332
19333
19334
19335
19336
19337
19338
19339
19340
19341
19342
19343
19344
19345
19346
19347
19348
19349
19350
19351
19352
19353
19354
19355
19356
19357
19358
19359
19360
19361
19362
19363
19364
19365
19366
19367
19368
19369
19370
19371
19372
19373
19374
19375
19376
19377
19378
19379
19380
19381
19382
19383
19384
19385
19386
19387
19388
19389
19390
19391
19392
19393
19394
19395
19396
19397
19398
19399
19400
19401
19402
19403
19404
19405
19406
19407
19408
19409
19410
19411
19412
19413
19414
19415
19416
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426
19427
19428
19429
19430
19431
19432
19433
19434
19435
19436
19437
19438
19439
19440
19441
19442
19443
19444
19445
19446
19447
19448
19449
19450
19451
19452
19453
19454
19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
19471
19472
19473
19474
19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
19494
19495
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
19517
19518
19519
19520
19521
19522
19523
19524
19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
19538
19539
19540
19541
19542
19543
19544
19545
19546
19547
19548
19549
19550
19551
19552
19553
19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
19566
19567
19568
19569
19570
19571
19572
19573
19574
19575
19576
19577
19578
19579
19580
19581
19582
19583
19584
19585
19586
19587
19588
19589
19590
19591
19592
19593
19594
19595
19596
19597
19598
19599
19600
19601
19602
19603
19604
19605
19606
19607
19608
19609
19610
19611
19612
19613
19614
19615
19616
19617
19618
19619
19620
19621
19622
19623
19624
19625
19626
19627
19628
19629
19630
19631
19632
19633
19634
19635
19636
19637
19638
19639
19640
19641
19642
19643
19644
19645
19646
19647
19648
19649
19650
19651
19652
19653
19654
19655
19656
19657
19658
19659
19660
19661
19662
19663
19664
19665
19666
19667
19668
19669
19670
19671
19672
19673
19674
19675
19676
19677
19678
19679
19680
19681
19682
19683
19684
19685
19686
19687
19688
19689
19690
19691
19692
19693
19694
19695
19696
19697
19698
19699
19700
19701
19702
19703
19704
19705
19706
19707
19708
19709
19710
19711
19712
19713
19714
19715
19716
19717
19718
19719
19720
19721
19722
19723
19724
19725
19726
19727
19728
19729
19730
19731
19732
19733
19734
19735
19736
19737
19738
19739
19740
19741
19742
19743
19744
19745
19746
19747
19748
19749
19750
19751
19752
19753
19754
19755
19756
19757
19758
19759
19760
19761
19762
19763
19764
19765
19766
19767
19768
19769
19770
19771
19772
19773
19774
19775
19776
19777
19778
19779
19780
19781
19782
19783
19784
19785
19786
19787
19788
19789
19790
19791
19792
19793
19794
19795
19796
19797
19798
19799
19800
19801
19802
19803
19804
19805
19806
19807
19808
19809
19810
19811
19812
19813
19814
19815
19816
19817
19818
19819
19820
19821
19822
19823
19824
19825
19826
19827
19828
19829
19830
19831
19832
19833
19834
19835
19836
19837
19838
19839
19840
19841
19842
19843
19844
19845
19846
19847
19848
19849
19850
19851
19852
19853
19854
19855
19856
19857
19858
19859
19860
19861
19862
19863
19864
19865
19866
19867
19868
19869
19870
19871
19872
19873
19874
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885
19886
19887
19888
19889
19890
19891
19892
19893
19894
19895
19896
19897
19898
19899
19900
19901
19902
19903
19904
19905
19906
19907
19908
19909
19910
19911
19912
19913
19914
19915
19916
19917
19918
19919
19920
19921
19922
19923
19924
19925
19926
19927
19928
19929
19930
19931
19932
19933
19934
19935
19936
19937
19938
19939
19940
19941
19942
19943
19944
19945
19946
19947
19948
19949
19950
19951
19952
19953
19954
19955
19956
19957
19958
19959
19960
19961
19962
19963
19964
19965
19966
19967
19968
19969
19970
19971
19972
19973
19974
19975
19976
19977
19978
19979
19980
19981
19982
19983
19984
19985
19986
19987
19988
19989
19990
19991
19992
19993
19994
19995
19996
19997
19998
19999
20000
20001
20002
20003
20004
20005
20006
20007
20008
20009
20010
20011
20012
20013
20014
20015
20016
20017
20018
20019
20020
20021
20022
20023
20024
20025
20026
20027
20028
20029
20030
20031
20032
20033
20034
20035
20036
20037
20038
20039
20040
20041
20042
20043
20044
20045
20046
20047
20048
20049
20050
20051
20052
20053
20054
20055
20056
20057
20058
20059
20060
20061
20062
20063
20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
20080
20081
20082
20083
20084
20085
20086
20087
20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
20101
20102
20103
20104
20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
20131
20132
20133
20134
20135
20136
20137
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148
20149
20150
20151
20152
20153
20154
20155
20156
20157
20158
20159
20160
20161
20162
20163
20164
20165
20166
20167
20168
20169
20170
20171
20172
20173
20174
20175
20176
20177
20178
20179
20180
20181
20182
20183
20184
20185
20186
20187
20188
20189
20190
20191
20192
20193
20194
20195
20196
20197
20198
20199
20200
20201
20202
20203
20204
20205
20206
20207
20208
20209
20210
20211
20212
20213
20214
20215
20216
20217
20218
20219
20220
20221
20222
20223
20224
20225
20226
20227
20228
20229
20230
20231
20232
20233
20234
20235
20236
20237
20238
20239
20240
20241
20242
20243
20244
20245
20246
20247
20248
20249
20250
20251
20252
20253
20254
20255
20256
20257
20258
20259
20260
20261
20262
20263
20264
20265
20266
20267
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277
20278
20279
20280
20281
20282
20283
20284
20285
20286
20287
20288
20289
20290
20291
20292
20293
20294
20295
20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
20321
20322
20323
20324
20325
20326
20327
20328
20329
20330
20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
20352
20353
20354
20355
20356
20357
20358
20359
20360
20361
20362
20363
20364
20365
20366
20367
20368
20369
20370
20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
20381
20382
20383
20384
20385
20386
20387
20388
20389
20390
20391
20392
20393
20394
20395
20396
20397
20398
20399
20400
20401
20402
20403
20404
20405
20406
20407
20408
20409
20410
20411
20412
20413
20414
20415
20416
20417
20418
20419
20420
20421
20422
20423
20424
20425
20426
20427
20428
20429
20430
20431
20432
20433
20434
20435
20436
20437
20438
20439
20440
20441
20442
20443
20444
20445
20446
20447
20448
20449
20450
20451
20452
20453
20454
20455
20456
20457
20458
20459
20460
20461
20462
20463
20464
20465
20466
20467
20468
20469
20470
20471
20472
20473
20474
20475
20476
20477
20478
20479
20480
20481
20482
20483
20484
20485
20486
20487
20488
20489
20490
20491
20492
20493
20494
20495
20496
20497
20498
20499
20500
20501
20502
20503
20504
20505
20506
20507
20508
20509
20510
20511
20512
20513
20514
20515
20516
20517
20518
20519
20520
20521
20522
20523
20524
20525
20526
20527
20528
20529
20530
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540
20541
20542
20543
20544
20545
20546
20547
20548
20549
20550
20551
20552
20553
20554
20555
20556
20557
20558
20559
20560
20561
20562
20563
20564
20565
20566
20567
20568
20569
20570
20571
20572
20573
20574
20575
20576
20577
20578
20579
20580
20581
20582
20583
20584
20585
20586
20587
20588
20589
20590
20591
20592
20593
20594
20595
20596
20597
20598
20599
20600
20601
20602
20603
20604
20605
20606
20607
20608
20609
20610
20611
20612
20613
20614
20615
20616
20617
20618
20619
20620
20621
20622
20623
20624
20625
20626
20627
20628
20629
20630
20631
20632
20633
20634
20635
20636
20637
20638
20639
20640
20641
20642
20643
20644
20645
20646
20647
20648
20649
20650
20651
20652
20653
20654
20655
20656
20657
20658
20659
20660
20661
20662
20663
20664
20665
20666
20667
20668
20669
20670
20671
20672
20673
20674
20675
20676
20677
20678
20679
20680
20681
20682
20683
20684
20685
20686
20687
20688
20689
20690
20691
20692
20693
20694
20695
20696
20697
20698
20699
20700
20701
20702
20703
20704
20705
20706
20707
20708
20709
20710
20711
20712
20713
20714
20715
20716
20717
20718
20719
20720
20721
20722
20723
20724
20725
20726
20727
20728
20729
20730
20731
20732
20733
20734
20735
20736
20737
20738
20739
20740
20741
20742
20743
20744
20745
20746
20747
20748
20749
20750
20751
20752
20753
20754
20755
20756
20757
20758
20759
20760
20761
20762
20763
20764
20765
20766
20767
20768
20769
20770
20771
20772
20773
20774
20775
20776
20777
20778
20779
20780
20781
20782
20783
20784
20785
20786
20787
20788
20789
20790
20791
20792
20793
20794
20795
20796
20797
20798
20799
20800
20801
20802
20803
20804
20805
20806
20807
20808
20809
20810
20811
20812
20813
20814
20815
20816
20817
20818
20819
20820
20821
20822
20823
20824
20825
20826
20827
20828
20829
20830
20831
20832
20833
20834
20835
20836
20837
20838
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848
20849
20850
20851
20852
20853
20854
20855
20856
20857
20858
20859
20860
20861
20862
20863
20864
20865
20866
20867
20868
20869
20870
20871
20872
20873
20874
20875
20876
20877
20878
20879
20880
20881
20882
20883
20884
20885
20886
20887
20888
20889
20890
20891
20892
20893
20894
20895
20896
20897
20898
20899
20900
20901
20902
20903
20904
20905
20906
20907
20908
20909
20910
20911
20912
20913
20914
20915
20916
20917
20918
20919
20920
20921
20922
20923
20924
20925
20926
20927
20928
20929
20930
20931
20932
20933
20934
20935
20936
20937
20938
20939
20940
20941
20942
20943
20944
20945
20946
20947
20948
20949
20950
20951
20952
20953
20954
20955
20956
20957
20958
20959
20960
20961
20962
20963
20964
20965
20966
20967
20968
20969
20970
20971
20972
20973
20974
20975
20976
20977
20978
20979
20980
20981
20982
20983
20984
20985
20986
20987
20988
20989
20990
20991
20992
20993
20994
20995
20996
20997
20998
20999
21000
21001
21002
21003
21004
21005
21006
21007
21008
21009
21010
21011
21012
21013
21014
21015
21016
21017
21018
21019
21020
21021
21022
21023
21024
21025
21026
21027
21028
21029
21030
21031
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041
21042
21043
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063
21064
21065
21066
21067
21068
21069
21070
21071
21072
21073
21074
21075
21076
21077
21078
21079
21080
21081
21082
21083
21084
21085
21086
21087
21088
21089
21090
21091
21092
21093
21094
21095
21096
21097
21098
21099
21100
21101
21102
21103
21104
21105
21106
21107
21108
21109
21110
21111
21112
21113
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123
21124
21125
21126
21127
21128
21129
21130
21131
21132
21133
21134
21135
21136
21137
21138
21139
21140
21141
21142
21143
21144
21145
21146
21147
21148
21149
21150
21151
21152
21153
21154
21155
21156
21157
21158
21159
21160
21161
21162
21163
21164
21165
21166
21167
21168
21169
21170
21171
21172
21173
21174
21175
21176
21177
21178
21179
21180
21181
21182
21183
21184
21185
21186
21187
21188
21189
21190
21191
21192
21193
21194
21195
21196
21197
21198
21199
21200
21201
21202
21203
21204
21205
21206
21207
21208
21209
21210
21211
21212
21213
21214
21215
21216
21217
21218
21219
21220
21221
21222
21223
21224
21225
21226
21227
21228
21229
21230
21231
21232
21233
21234
21235
21236
21237
21238
21239
21240
21241
21242
21243
21244
21245
21246
21247
21248
21249
21250
21251
21252
21253
21254
21255
21256
21257
21258
21259
21260
21261
21262
21263
21264
21265
21266
21267
21268
21269
21270
21271
21272
21273
21274
21275
21276
21277
21278
21279
21280
21281
21282
21283
21284
21285
21286
21287
21288
21289
21290
21291
21292
21293
21294
21295
21296
21297
21298
21299
21300
21301
21302
21303
21304
21305
21306
21307
21308
21309
21310
21311
21312
21313
21314
21315
21316
21317
21318
21319
21320
21321
21322
21323
21324
21325
21326
21327
21328
21329
21330
21331
21332
21333
21334
21335
21336
21337
21338
21339
21340
21341
21342
21343
21344
21345
21346
21347
21348
21349
21350
21351
21352
21353
21354
21355
21356
21357
21358
21359
21360
21361
21362
21363
21364
21365
21366
21367
21368
21369
21370
21371
21372
21373
21374
21375
21376
21377
21378
21379
21380
21381
21382
21383
21384
21385
21386
21387
21388
21389
21390
21391
21392
21393
21394
21395
21396
21397
21398
21399
21400
21401
21402
21403
21404
21405
21406
21407
21408
21409
21410
21411
21412
21413
21414
21415
21416
21417
21418
21419
21420
21421
21422
21423
21424
21425
21426
21427
21428
21429
21430
21431
21432
21433
21434
21435
21436
21437
21438
21439
21440
21441
21442
21443
21444
21445
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458
21459
21460
21461
21462
21463
21464
21465
21466
21467
21468
21469
21470
21471
21472
21473
21474
21475
21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
21495
21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
21526
21527
21528
21529
21530
21531
21532
21533
21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
21547
21548
21549
21550
21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
21577
21578
21579
21580
21581
21582
21583
21584
21585
21586
21587
21588
21589
21590
21591
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
21689
21690
21691
21692
21693
21694
21695
21696
21697
21698
21699
21700
21701
21702
21703
21704
21705
21706
21707
21708
21709
21710
21711
21712
21713
21714
21715
21716
21717
21718
21719
21720
21721
21722
21723
21724
21725
21726
21727
21728
21729
21730
21731
21732
21733
21734
21735
21736
21737
21738
21739
21740
21741
21742
21743
21744
21745
21746
21747
21748
21749
21750
21751
21752
21753
21754
21755
21756
21757
21758
21759
21760
21761
21762
21763
21764
21765
21766
21767
21768
21769
21770
21771
21772
21773
21774
21775
21776
21777
21778
21779
21780
21781
21782
21783
21784
21785
21786
21787
21788
21789
21790
21791
21792
21793
21794
21795
21796
21797
21798
21799
21800
21801
21802
21803
21804
21805
21806
21807
21808
21809
21810
21811
21812
21813
21814
21815
21816
21817
21818
21819
21820
21821
21822
21823
21824
21825
21826
21827
21828
21829
21830
21831
21832
21833
21834
21835
21836
21837
21838
21839
21840
21841
21842
21843
21844
21845
21846
21847
21848
21849
21850
21851
21852
21853
21854
21855
21856
21857
21858
21859
21860
21861
21862
21863
21864
21865
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876
21877
21878
21879
21880
21881
21882
21883
21884
21885
21886
21887
21888
21889
21890
21891
21892
21893
21894
21895
21896
21897
21898
21899
21900
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911
21912
21913
21914
21915
21916
21917
21918
21919
21920
21921
21922
21923
21924
21925
21926
21927
21928
21929
21930
21931
21932
21933
21934
21935
21936
21937
21938
21939
21940
21941
21942
21943
21944
21945
21946
21947
21948
21949
21950
21951
21952
21953
21954
21955
21956
21957
21958
21959
21960
21961
21962
21963
21964
21965
21966
21967
21968
21969
21970
21971
21972
21973
21974
21975
21976
21977
21978
21979
21980
21981
21982
21983
21984
21985
21986
21987
21988
21989
21990
21991
21992
21993
21994
21995
21996
21997
21998
21999
22000
22001
22002
22003
22004
22005
22006
22007
22008
22009
22010
22011
22012
22013
22014
22015
22016
22017
22018
22019
22020
22021
22022
22023
22024
22025
22026
22027
22028
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038
22039
22040
22041
22042
22043
22044
22045
22046
22047
22048
22049
22050
22051
22052
22053
22054
22055
22056
22057
22058
22059
22060
22061
22062
22063
22064
22065
22066
22067
22068
22069
22070
22071
22072
22073
22074
22075
22076
22077
22078
22079
22080
22081
22082
22083
22084
22085
22086
22087
22088
22089
22090
22091
22092
22093
22094
22095
22096
22097
22098
22099
22100
22101
22102
22103
22104
22105
22106
22107
22108
22109
22110
22111
22112
22113
22114
22115
22116
22117
22118
22119
22120
22121
22122
22123
22124
22125
22126
22127
22128
22129
22130
22131
22132
22133
22134
22135
22136
22137
22138
22139
22140
22141
22142
22143
22144
22145
22146
22147
22148
22149
22150
22151
22152
22153
22154
22155
22156
22157
22158
22159
22160
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170
22171
22172
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193
22194
22195
22196
22197
22198
22199
22200
22201
22202
22203
22204
22205
22206
22207
22208
22209
22210
22211
22212
22213
22214
22215
22216
22217
22218
22219
22220
22221
22222
22223
22224
22225
22226
22227
22228
22229
22230
22231
22232
22233
22234
22235
22236
22237
22238
22239
22240
22241
22242
22243
22244
22245
22246
22247
22248
22249
22250
22251
22252
22253
22254
22255
22256
22257
22258
22259
22260
22261
22262
22263
22264
22265
22266
22267
22268
22269
22270
22271
22272
22273
22274
22275
22276
22277
22278
22279
22280
22281
22282
22283
22284
22285
22286
22287
22288
22289
22290
22291
22292
22293
22294
22295
22296
22297
22298
22299
22300
22301
22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
22315
22316
22317
22318
22319
22320
22321
22322
22323
22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
22337
22338
22339
22340
22341
22342
22343
22344
22345
22346
22347
22348
22349
22350
22351
22352
22353
22354
22355
22356
22357
22358
22359
22360
22361
22362
22363
22364
22365
22366
22367
22368
22369
22370
22371
22372
22373
22374
22375
22376
22377
22378
22379
22380
22381
22382
22383
22384
22385
22386
22387
22388
22389
22390
22391
22392
22393
22394
22395
22396
22397
22398
22399
22400
22401
22402
22403
22404
22405
22406
22407
22408
22409
22410
22411
22412
22413
22414
22415
22416
22417
22418
22419
22420
22421
22422
22423
22424
22425
22426
22427
22428
22429
22430
22431
22432
22433
22434
22435
22436
22437
22438
22439
22440
22441
22442
22443
22444
22445
22446
22447
22448
22449
22450
22451
22452
22453
22454
22455
22456
22457
22458
22459
22460
22461
22462
22463
22464
22465
22466
22467
22468
22469
22470
22471
22472
22473
22474
22475
22476
22477
22478
22479
22480
22481
22482
22483
22484
22485
22486
22487
22488
22489
22490
22491
22492
22493
22494
22495
22496
22497
22498
22499
22500
22501
22502
22503
22504
22505
22506
22507
22508
22509
22510
22511
22512
22513
22514
22515
22516
22517
22518
22519
22520
22521
22522
22523
22524
22525
22526
22527
22528
22529
22530
22531
22532
22533
22534
22535
22536
22537
22538
22539
22540
22541
22542
22543
22544
22545
22546
22547
22548
22549
22550
22551
22552
22553
22554
22555
22556
22557
22558
22559
22560
22561
22562
22563
22564
22565
22566
22567
22568
22569
22570
22571
22572
22573
22574
22575
22576
22577
22578
22579
22580
22581
22582
22583
22584
22585
22586
22587
22588
22589
22590
22591
22592
22593
22594
22595
22596
22597
22598
22599
22600
22601
22602
22603
22604
22605
22606
22607
22608
22609
22610
22611
22612
22613
22614
22615
22616
22617
22618
22619
22620
22621
22622
22623
22624
22625
22626
22627
22628
22629
22630
22631
22632
22633
22634
22635
22636
22637
22638
22639
22640
22641
22642
22643
22644
22645
22646
22647
22648
22649
22650
22651
22652
22653
22654
22655
22656
22657
22658
22659
22660
22661
22662
22663
22664
22665
22666
22667
22668
22669
22670
22671
22672
22673
22674
22675
22676
22677
22678
22679
22680
22681
22682
22683
22684
22685
22686
22687
22688
22689
22690
22691
22692
22693
22694
22695
22696
22697
22698
22699
22700
22701
22702
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717
22718
22719
22720
22721
22722
22723
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812
22813
22814
22815
22816
22817
22818
22819
22820
22821
22822
22823
22824
22825
22826
22827
22828
22829
22830
22831
22832
22833
22834
22835
22836
22837
22838
22839
22840
22841
22842
22843
22844
22845
22846
22847
22848
22849
22850
22851
22852
22853
22854
22855
22856
22857
22858
22859
22860
22861
22862
22863
22864
22865
22866
22867
22868
22869
22870
22871
22872
22873
22874
22875
22876
22877
22878
22879
22880
22881
22882
22883
22884
22885
22886
22887
22888
22889
22890
22891
22892
22893
22894
22895
22896
22897
22898
22899
22900
22901
22902
22903
22904
22905
22906
22907
22908
22909
22910
22911
22912
22913
22914
22915
22916
22917
22918
22919
22920
22921
22922
22923
22924
22925
22926
22927
22928
22929
22930
22931
22932
22933
22934
22935
22936
22937
22938
22939
22940
22941
22942
22943
22944
22945
22946
22947
22948
22949
22950
22951
22952
22953
22954
22955
22956
22957
22958
22959
22960
22961
22962
22963
22964
22965
22966
22967
22968
22969
22970
22971
22972
22973
22974
22975
22976
22977
22978
22979
22980
22981
22982
22983
22984
22985
22986
22987
22988
22989
22990
22991
22992
22993
22994
22995
22996
22997
22998
22999
23000
23001
23002
23003
23004
23005
23006
23007
23008
23009
23010
23011
23012
23013
23014
23015
23016
23017
23018
23019
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031
23032
23033
23034
23035
23036
23037
23038
23039
23040
23041
23042
23043
23044
23045
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056
23057
23058
23059
23060
23061
23062
23063
23064
23065
23066
23067
23068
23069
23070
23071
23072
23073
23074
23075
23076
23077
23078
23079
23080
23081
23082
23083
23084
23085
23086
23087
23088
23089
23090
23091
23092
23093
23094
23095
23096
23097
23098
23099
23100
23101
23102
23103
23104
23105
23106
23107
23108
23109
23110
23111
23112
23113
23114
23115
23116
23117
23118
23119
23120
23121
23122
23123
23124
23125
23126
23127
23128
23129
23130
23131
23132
23133
23134
23135
23136
23137
23138
23139
23140
23141
23142
23143
23144
23145
23146
23147
23148
23149
23150
23151
23152
23153
23154
23155
23156
23157
23158
23159
23160
23161
23162
23163
23164
23165
23166
23167
23168
23169
23170
23171
23172
23173
23174
23175
23176
23177
23178
23179
23180
23181
23182
23183
23184
23185
23186
23187
23188
23189
23190
23191
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201
23202
23203
23204
23205
23206
23207
23208
23209
23210
23211
23212
23213
23214
23215
23216
23217
23218
23219
23220
23221
23222
23223
23224
23225
23226
23227
23228
23229
23230
23231
23232
23233
23234
23235
23236
23237
23238
23239
23240
23241
23242
23243
23244
23245
23246
23247
23248
23249
23250
23251
23252
23253
23254
23255
23256
23257
23258
23259
23260
23261
23262
23263
23264
23265
23266
23267
23268
23269
23270
23271
23272
23273
23274
23275
23276
23277
23278
23279
23280
23281
23282
23283
23284
23285
23286
23287
23288
23289
23290
23291
23292
23293
23294
23295
23296
23297
23298
23299
23300
23301
23302
23303
23304
23305
23306
23307
23308
23309
23310
23311
23312
23313
23314
23315
23316
23317
23318
23319
23320
23321
23322
23323
23324
23325
23326
23327
23328
23329
23330
23331
23332
23333
23334
23335
23336
23337
23338
23339
23340
23341
23342
23343
23344
23345
23346
23347
23348
23349
23350
23351
23352
23353
23354
23355
23356
23357
23358
23359
23360
23361
23362
23363
23364
23365
23366
23367
23368
23369
23370
23371
23372
23373
23374
23375
23376
23377
23378
23379
23380
23381
23382
23383
23384
23385
23386
23387
23388
23389
23390
23391
23392
23393
23394
23395
23396
23397
23398
23399
23400
23401
23402
23403
23404
23405
23406
23407
23408
23409
23410
23411
23412
23413
23414
23415
23416
23417
23418
23419
23420
23421
23422
23423
23424
23425
23426
23427
23428
23429
23430
23431
23432
23433
23434
23435
23436
23437
23438
23439
23440
23441
23442
23443
23444
23445
23446
23447
23448
23449
23450
23451
23452
23453
23454
23455
23456
23457
23458
23459
23460
23461
23462
23463
23464
23465
23466
23467
23468
23469
23470
23471
23472
23473
23474
23475
23476
23477
23478
23479
23480
23481
23482
23483
23484
23485
23486
23487
23488
23489
23490
23491
23492
23493
23494
23495
23496
23497
23498
23499
23500
23501
23502
23503
23504
23505
23506
23507
23508
23509
23510
23511
23512
23513
23514
23515
23516
23517
23518
23519
23520
23521
23522
23523
23524
23525
23526
23527
23528
23529
23530
23531
23532
23533
23534
23535
23536
23537
23538
23539
23540
23541
23542
23543
23544
23545
23546
23547
23548
23549
23550
23551
23552
23553
23554
23555
23556
23557
23558
23559
23560
23561
23562
23563
23564
23565
23566
23567
23568
23569
23570
23571
23572
23573
23574
23575
23576
23577
23578
23579
23580
23581
23582
23583
23584
23585
23586
23587
23588
23589
23590
23591
23592
23593
23594
23595
23596
23597
23598
23599
23600
23601
23602
23603
23604
23605
23606
23607
23608
23609
23610
23611
23612
23613
23614
23615
23616
23617
23618
23619
23620
23621
23622
23623
23624
23625
23626
23627
23628
23629
23630
23631
23632
23633
23634
23635
23636
23637
23638
23639
23640
23641
23642
23643
23644
23645
23646
23647
23648
23649
23650
23651
23652
23653
23654
23655
23656
23657
23658
23659
23660
23661
23662
23663
23664
23665
23666
23667
23668
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679
23680
23681
23682
23683
23684
23685
23686
23687
23688
23689
23690
23691
23692
23693
23694
23695
23696
23697
23698
23699
23700
23701
23702
23703
23704
23705
23706
23707
23708
23709
23710
23711
23712
23713
23714
23715
23716
23717
23718
23719
23720
23721
23722
23723
23724
23725
23726
23727
23728
23729
23730
23731
23732
23733
23734
23735
23736
23737
23738
23739
23740
23741
23742
23743
23744
23745
23746
23747
23748
23749
23750
23751
23752
23753
23754
23755
23756
23757
23758
23759
23760
23761
23762
23763
23764
23765
23766
23767
23768
23769
23770
23771
23772
23773
23774
23775
23776
23777
23778
23779
23780
23781
23782
23783
23784
23785
23786
23787
23788
23789
23790
23791
23792
23793
23794
23795
23796
23797
23798
23799
23800
23801
23802
23803
23804
23805
23806
23807
23808
23809
23810
23811
23812
23813
23814
23815
23816
23817
23818
23819
23820
23821
23822
23823
23824
23825
23826
23827
23828
23829
23830
23831
23832
23833
23834
23835
23836
23837
23838
23839
23840
23841
23842
23843
23844
23845
23846
23847
23848
23849
23850
23851
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865
23866
23867
23868
23869
23870
23871
23872
23873
23874
23875
23876
23877
23878
23879
23880
23881
23882
23883
23884
23885
23886
23887
23888
23889
23890
23891
23892
23893
23894
23895
23896
23897
23898
23899
23900
23901
23902
23903
23904
23905
23906
23907
23908
23909
23910
23911
23912
23913
23914
23915
23916
23917
23918
23919
23920
23921
23922
23923
23924
23925
23926
23927
23928
23929
23930
23931
23932
23933
23934
23935
23936
23937
23938
23939
23940
23941
23942
23943
23944
23945
23946
23947
23948
23949
23950
23951
23952
23953
23954
23955
23956
23957
23958
23959
23960
23961
23962
23963
23964
23965
23966
23967
23968
23969
23970
23971
23972
23973
23974
23975
23976
23977
23978
23979
23980
23981
23982
23983
23984
23985
23986
23987
23988
23989
23990
23991
23992
23993
23994
23995
23996
23997
23998
23999
24000
24001
24002
24003
24004
24005
24006
24007
24008
24009
24010
24011
24012
24013
24014
24015
24016
24017
24018
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028
24029
24030
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043
24044
24045
24046
24047
24048
24049
24050
24051
24052
24053
24054
24055
24056
24057
24058
24059
24060
24061
24062
24063
24064
24065
24066
24067
24068
24069
24070
24071
24072
24073
24074
24075
24076
24077
24078
24079
24080
24081
24082
24083
24084
24085
24086
24087
24088
24089
24090
24091
24092
24093
24094
24095
24096
24097
24098
24099
24100
24101
24102
24103
24104
24105
24106
24107
24108
24109
24110
24111
24112
24113
24114
24115
24116
24117
24118
24119
24120
24121
24122
24123
24124
24125
24126
24127
24128
24129
24130
24131
24132
24133
24134
24135
24136
24137
24138
24139
24140
24141
24142
24143
24144
24145
24146
24147
24148
24149
24150
24151
24152
24153
24154
24155
24156
24157
24158
24159
24160
24161
24162
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172
24173
24174
24175
24176
24177
24178
24179
24180
24181
24182
24183
24184
24185
24186
24187
24188
24189
24190
24191
24192
24193
24194
24195
24196
24197
24198
24199
24200
24201
24202
24203
24204
24205
24206
24207
24208
24209
24210
24211
24212
24213
24214
24215
24216
24217
24218
24219
24220
24221
24222
24223
24224
24225
24226
24227
24228
24229
24230
24231
24232
24233
24234
24235
24236
24237
24238
24239
24240
24241
24242
24243
24244
24245
24246
24247
24248
24249
24250
24251
24252
24253
24254
24255
24256
24257
24258
24259
24260
24261
24262
24263
24264
24265
24266
24267
24268
24269
24270
24271
24272
24273
24274
24275
24276
24277
24278
24279
24280
24281
24282
24283
24284
24285
24286
24287
24288
24289
24290
24291
24292
24293
24294
24295
24296
24297
24298
24299
24300
24301
24302
24303
24304
24305
24306
24307
24308
24309
24310
24311
24312
24313
24314
24315
24316
24317
24318
24319
24320
24321
24322
24323
24324
24325
24326
24327
24328
24329
24330
24331
24332
24333
24334
24335
24336
24337
24338
24339
24340
24341
24342
24343
24344
24345
24346
24347
24348
24349
24350
24351
24352
24353
24354
24355
24356
24357
24358
24359
24360
24361
24362
24363
24364
24365
24366
24367
24368
24369
24370
24371
24372
24373
24374
24375
24376
24377
24378
24379
24380
24381
24382
24383
24384
24385
24386
24387
24388
24389
24390
24391
24392
24393
24394
24395
24396
24397
24398
24399
24400
24401
24402
24403
24404
24405
24406
24407
24408
24409
24410
24411
24412
24413
24414
24415
24416
24417
24418
24419
24420
24421
24422
24423
24424
24425
24426
24427
24428
24429
24430
24431
24432
24433
24434
24435
24436
24437
24438
24439
24440
24441
24442
24443
24444
24445
24446
24447
24448
24449
24450
24451
24452
24453
24454
24455
24456
24457
24458
24459
24460
24461
24462
24463
24464
24465
24466
24467
24468
24469
24470
24471
24472
24473
24474
24475
24476
24477
24478
24479
24480
24481
24482
24483
24484
24485
24486
24487
24488
24489
24490
24491
24492
24493
24494
24495
24496
24497
24498
24499
24500
24501
24502
24503
24504
24505
24506
24507
24508
24509
24510
24511
24512
24513
24514
24515
24516
24517
24518
24519
24520
24521
24522
24523
24524
24525
24526
24527
24528
24529
24530
24531
24532
24533
24534
24535
24536
24537
24538
24539
24540
24541
24542
24543
24544
24545
24546
24547
24548
24549
24550
24551
24552
24553
24554
24555
24556
24557
24558
24559
24560
24561
24562
24563
24564
24565
24566
24567
24568
24569
24570
24571
24572
24573
24574
24575
24576
24577
24578
24579
24580
24581
24582
24583
24584
24585
24586
24587
24588
24589
24590
24591
24592
24593
24594
24595
24596
24597
24598
24599
24600
24601
24602
24603
24604
24605
24606
24607
24608
24609
24610
24611
24612
24613
24614
24615
24616
24617
24618
24619
24620
24621
24622
24623
24624
24625
24626
24627
24628
24629
24630
24631
24632
24633
24634
24635
24636
24637
24638
24639
24640
24641
24642
24643
24644
24645
24646
24647
24648
24649
24650
24651
24652
24653
24654
24655
24656
24657
24658
24659
24660
24661
24662
24663
24664
24665
24666
24667
24668
24669
24670
24671
24672
24673
24674
24675
24676
24677
24678
24679
24680
24681
24682
24683
24684
24685
24686
24687
24688
24689
24690
24691
24692
24693
24694
24695
24696
24697
24698
24699
24700
24701
24702
24703
24704
24705
24706
24707
24708
24709
24710
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721
24722
24723
24724
24725
24726
24727
24728
24729
24730
24731
24732
24733
24734
24735
24736
24737
24738
24739
24740
24741
24742
24743
24744
24745
24746
24747
24748
24749
24750
24751
24752
24753
24754
24755
24756
24757
24758
24759
24760
24761
24762
24763
24764
24765
24766
24767
24768
24769
24770
24771
24772
24773
24774
24775
24776
24777
24778
24779
24780
24781
24782
24783
24784
24785
24786
24787
24788
24789
24790
24791
24792
24793
24794
24795
24796
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807
24808
24809
24810
24811
24812
24813
24814
24815
24816
24817
24818
24819
24820
24821
24822
24823
24824
24825
24826
24827
24828
24829
24830
24831
24832
24833
24834
24835
24836
24837
24838
24839
24840
24841
24842
24843
24844
24845
24846
24847
24848
24849
24850
24851
24852
24853
24854
24855
24856
24857
24858
24859
24860
24861
24862
24863
24864
24865
24866
24867
24868
24869
24870
24871
24872
24873
24874
24875
24876
24877
24878
24879
24880
24881
24882
24883
24884
24885
24886
24887
24888
24889
24890
24891
24892
24893
24894
24895
24896
24897
24898
24899
24900
24901
24902
24903
24904
24905
24906
24907
24908
24909
24910
24911
24912
24913
24914
24915
24916
24917
24918
24919
24920
24921
24922
24923
24924
24925
24926
24927
24928
24929
24930
24931
24932
24933
24934
24935
24936
24937
24938
24939
24940
24941
24942
24943
24944
24945
24946
24947
24948
24949
24950
24951
24952
24953
24954
24955
24956
24957
24958
24959
24960
24961
24962
24963
24964
24965
24966
24967
24968
24969
24970
24971
24972
24973
24974
24975
24976
24977
24978
24979
24980
24981
24982
24983
24984
24985
24986
24987
24988
24989
24990
24991
24992
24993
24994
24995
24996
24997
24998
24999
25000
25001
25002
25003
25004
25005
25006
25007
25008
25009
25010
25011
25012
25013
25014
25015
25016
25017
25018
25019
25020
25021
25022
25023
25024
25025
25026
25027
25028
25029
25030
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040
25041
25042
25043
25044
25045
25046
25047
25048
25049
25050
25051
25052
25053
25054
25055
25056
25057
25058
25059
25060
25061
25062
25063
25064
25065
25066
25067
25068
25069
25070
25071
25072
25073
25074
25075
25076
25077
25078
25079
25080
25081
25082
25083
25084
25085
25086
25087
25088
25089
25090
25091
25092
25093
25094
25095
25096
25097
25098
25099
25100
25101
25102
25103
25104
25105
25106
25107
25108
25109
25110
25111
25112
25113
25114
25115
25116
25117
25118
25119
25120
25121
25122
25123
25124
25125
25126
25127
25128
25129
25130
25131
25132
25133
25134
25135
25136
25137
25138
25139
25140
25141
25142
25143
25144
25145
25146
25147
25148
25149
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159
25160
25161
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183
25184
25185
25186
25187
25188
25189
25190
25191
25192
25193
25194
25195
25196
25197
25198
25199
25200
25201
25202
25203
25204
25205
25206
25207
25208
25209
25210
25211
25212
25213
25214
25215
25216
25217
25218
25219
25220
25221
25222
25223
25224
25225
25226
25227
25228
25229
25230
25231
25232
25233
25234
25235
25236
25237
25238
25239
25240
25241
25242
25243
25244
25245
25246
25247
25248
25249
25250
25251
25252
25253
25254
25255
25256
25257
25258
25259
25260
25261
25262
25263
25264
25265
25266
25267
25268
25269
25270
25271
25272
25273
25274
25275
25276
25277
25278
25279
25280
25281
25282
25283
25284
25285
25286
25287
25288
25289
25290
25291
25292
25293
25294
25295
25296
25297
25298
25299
25300
25301
25302
25303
25304
25305
25306
25307
25308
25309
25310
25311
25312
25313
25314
25315
25316
25317
25318
25319
25320
25321
25322
25323
25324
25325
25326
25327
25328
25329
25330
25331
25332
25333
25334
25335
25336
25337
25338
25339
25340
25341
25342
25343
25344
25345
25346
25347
25348
25349
25350
25351
25352
25353
25354
25355
25356
25357
25358
25359
25360
25361
25362
25363
25364
25365
25366
25367
25368
25369
25370
25371
25372
25373
25374
25375
25376
25377
25378
25379
25380
25381
25382
25383
25384
25385
25386
25387
25388
25389
25390
25391
25392
25393
25394
25395
25396
25397
25398
25399
25400
25401
25402
25403
25404
25405
25406
25407
25408
25409
25410
25411
25412
25413
25414
25415
25416
25417
25418
25419
25420
25421
25422
25423
25424
25425
25426
25427
25428
25429
25430
25431
25432
25433
25434
25435
25436
25437
25438
25439
25440
25441
25442
25443
25444
25445
25446
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458
25459
25460
25461
25462
25463
25464
25465
25466
25467
25468
25469
25470
25471
25472
25473
25474
25475
25476
25477
25478
25479
25480
25481
25482
25483
25484
25485
25486
25487
25488
25489
25490
25491
25492
25493
25494
25495
25496
25497
25498
25499
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513
25514
25515
25516
25517
25518
25519
25520
25521
25522
25523
25524
25525
25526
25527
25528
25529
25530
25531
25532
25533
25534
25535
25536
25537
25538
25539
25540
25541
25542
25543
25544
25545
25546
25547
25548
25549
25550
25551
25552
25553
25554
25555
25556
25557
25558
25559
25560
25561
25562
25563
25564
25565
25566
25567
25568
25569
25570
25571
25572
25573
25574
25575
25576
25577
25578
25579
25580
25581
25582
25583
25584
25585
25586
25587
25588
25589
25590
25591
25592
25593
25594
25595
25596
25597
25598
25599
25600
25601
25602
25603
25604
25605
25606
25607
25608
25609
25610
25611
25612
25613
25614
25615
25616
25617
25618
25619
25620
25621
25622
25623
25624
25625
25626
25627
25628
25629
25630
25631
25632
25633
25634
25635
25636
25637
25638
25639
25640
25641
25642
25643
25644
25645
25646
25647
25648
25649
25650
25651
25652
25653
25654
25655
25656
25657
25658
25659
25660
25661
25662
25663
25664
25665
25666
25667
25668
25669
25670
25671
25672
25673
25674
25675
25676
25677
25678
25679
25680
25681
25682
25683
25684
25685
25686
25687
25688
25689
25690
25691
25692
25693
25694
25695
25696
25697
25698
25699
25700
25701
25702
25703
25704
25705
25706
25707
25708
25709
25710
25711
25712
25713
25714
25715
25716
25717
25718
25719
25720
25721
25722
25723
25724
25725
25726
25727
25728
25729
25730
25731
25732
25733
25734
25735
25736
25737
25738
25739
25740
25741
25742
25743
25744
25745
25746
25747
25748
25749
25750
25751
25752
25753
25754
25755
25756
25757
25758
25759
25760
25761
25762
25763
25764
25765
25766
25767
25768
25769
25770
25771
25772
25773
25774
25775
25776
25777
25778
25779
25780
25781
25782
25783
25784
25785
25786
25787
25788
25789
25790
25791
25792
25793
25794
25795
25796
25797
25798
25799
25800
25801
25802
25803
25804
25805
25806
25807
25808
25809
25810
25811
25812
25813
25814
25815
25816
25817
25818
25819
25820
25821
25822
25823
25824
25825
25826
25827
25828
25829
25830
25831
25832
25833
25834
25835
25836
25837
25838
25839
25840
25841
25842
25843
25844
25845
25846
25847
25848
25849
25850
25851
25852
25853
25854
25855
25856
25857
25858
25859
25860
25861
25862
25863
25864
25865
25866
25867
25868
25869
25870
25871
25872
25873
25874
25875
25876
25877
25878
25879
25880
25881
25882
25883
25884
25885
25886
25887
25888
25889
25890
25891
25892
25893
25894
25895
25896
25897
25898
25899
25900
25901
25902
25903
25904
25905
25906
25907
25908
25909
25910
25911
25912
25913
25914
25915
25916
25917
25918
25919
25920
25921
25922
25923
25924
25925
25926
25927
25928
25929
25930
25931
25932
25933
25934
25935
25936
25937
25938
25939
25940
25941
25942
25943
25944
25945
25946
25947
25948
25949
25950
25951
25952
25953
25954
25955
25956
25957
25958
25959
25960
25961
25962
25963
25964
25965
25966
25967
25968
25969
25970
25971
25972
25973
25974
25975
25976
25977
25978
25979
25980
25981
25982
25983
25984
25985
25986
25987
25988
25989
25990
25991
25992
25993
25994
25995
25996
25997
25998
25999
26000
26001
26002
26003
26004
26005
26006
26007
26008
26009
26010
26011
26012
26013
26014
26015
26016
26017
26018
26019
26020
26021
26022
26023
26024
26025
26026
26027
26028
26029
26030
26031
26032
26033
26034
26035
26036
26037
26038
26039
26040
26041
26042
26043
26044
26045
26046
26047
26048
26049
26050
26051
26052
26053
26054
26055
26056
26057
26058
26059
26060
26061
26062
26063
26064
26065
26066
26067
26068
26069
26070
26071
26072
26073
26074
26075
26076
26077
26078
26079
26080
26081
26082
26083
26084
26085
26086
26087
26088
26089
26090
26091
26092
26093
26094
26095
26096
26097
26098
26099
26100
26101
26102
26103
26104
26105
26106
26107
26108
26109
26110
26111
26112
26113
26114
26115
26116
26117
26118
26119
26120
26121
26122
26123
26124
26125
26126
26127
26128
26129
26130
26131
26132
26133
26134
26135
26136
26137
26138
26139
26140
26141
26142
26143
26144
26145
26146
26147
26148
26149
26150
26151
26152
26153
26154
26155
26156
26157
26158
26159
26160
26161
26162
26163
26164
26165
26166
26167
26168
26169
26170
26171
26172
26173
26174
26175
26176
26177
26178
26179
26180
26181
26182
26183
26184
26185
26186
26187
26188
26189
26190
26191
26192
26193
26194
26195
26196
26197
26198
26199
26200
26201
26202
26203
26204
26205
26206
26207
26208
26209
26210
26211
26212
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230
26231
26232
26233
26234
26235
26236
26237
26238
26239
26240
26241
26242
26243
26244
26245
26246
26247
26248
26249
26250
26251
26252
26253
26254
26255
26256
26257
26258
26259
26260
26261
26262
26263
26264
26265
26266
26267
26268
26269
26270
26271
26272
26273
26274
26275
26276
26277
26278
26279
26280
26281
26282
26283
26284
26285
26286
26287
26288
26289
26290
26291
26292
26293
26294
26295
26296
26297
26298
26299
26300
26301
26302
26303
26304
26305
26306
26307
26308
26309
26310
26311
26312
26313
26314
26315
26316
26317
26318
26319
26320
26321
26322
26323
26324
26325
26326
26327
26328
26329
26330
26331
26332
26333
26334
26335
26336
26337
26338
26339
26340
26341
26342
26343
26344
26345
26346
26347
26348
26349
26350
26351
26352
26353
26354
26355
26356
26357
26358
26359
26360
26361
26362
26363
26364
26365
26366
26367
26368
26369
26370
26371
26372
26373
26374
26375
26376
26377
26378
26379
26380
26381
26382
26383
26384
26385
26386
26387
26388
26389
26390
26391
26392
26393
26394
26395
26396
26397
26398
26399
26400
26401
26402
26403
26404
26405
26406
26407
26408
26409
26410
26411
26412
26413
26414
26415
26416
26417
26418
26419
26420
26421
26422
26423
26424
26425
26426
26427
26428
26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
26442
26443
26444
26445
26446
26447
26448
26449
26450
26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
26464
26465
26466
26467
26468
26469
26470
26471
26472
26473
26474
26475
26476
26477
26478
26479
26480
26481
26482
26483
26484
26485
26486
26487
26488
26489
26490
26491
26492
26493
26494
26495
26496
26497
26498
26499
26500
26501
26502
26503
26504
26505
26506
26507
26508
26509
26510
26511
26512
26513
26514
26515
26516
26517
26518
26519
26520
26521
26522
26523
26524
26525
26526
26527
26528
26529
26530
26531
26532
26533
26534
26535
26536
26537
26538
26539
26540
26541
26542
26543
26544
26545
26546
26547
26548
26549
26550
26551
26552
26553
26554
26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
26580
26581
26582
26583
26584
26585
26586
26587
26588
26589
26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
26611
26612
26613
26614
26615
26616
26617
26618
26619
26620
26621
26622
26623
26624
26625
26626
26627
26628
26629
26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
26640
26641
26642
26643
26644
26645
26646
26647
26648
26649
26650
26651
26652
26653
26654
26655
26656
26657
26658
26659
26660
26661
26662
26663
26664
26665
26666
26667
26668
26669
26670
26671
26672
26673
26674
26675
26676
26677
26678
26679
26680
26681
26682
26683
26684
26685
26686
26687
26688
26689
26690
26691
26692
26693
26694
26695
26696
26697
26698
26699
26700
26701
26702
26703
26704
26705
26706
26707
26708
26709
26710
26711
26712
26713
26714
26715
26716
26717
26718
26719
26720
26721
26722
26723
26724
26725
26726
26727
26728
26729
26730
26731
26732
26733
26734
26735
26736
26737
26738
26739
26740
26741
26742
26743
26744
26745
26746
26747
26748
26749
26750
26751
26752
26753
26754
26755
26756
26757
26758
26759
26760
26761
26762
26763
26764
26765
26766
26767
26768
26769
26770
26771
26772
26773
26774
26775
26776
26777
26778
26779
26780
26781
26782
26783
26784
26785
26786
26787
26788
26789
26790
26791
26792
26793
26794
26795
26796
26797
26798
26799
26800
26801
26802
26803
26804
26805
26806
26807
26808
26809
26810
26811
26812
26813
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
26824
26825
26826
26827
26828
26829
26830
26831
26832
26833
26834
26835
26836
26837
26838
26839
26840
26841
26842
26843
26844
26845
26846
26847
26848
26849
26850
26851
26852
26853
26854
26855
26856
26857
26858
26859
26860
26861
26862
26863
26864
26865
26866
26867
26868
26869
26870
26871
26872
26873
26874
26875
26876
26877
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887
26888
26889
26890
26891
26892
26893
26894
26895
26896
26897
26898
26899
26900
26901
26902
26903
26904
26905
26906
26907
26908
26909
26910
26911
26912
26913
26914
26915
26916
26917
26918
26919
26920
26921
26922
26923
26924
26925
26926
26927
26928
26929
26930
26931
26932
26933
26934
26935
26936
26937
26938
26939
26940
26941
26942
26943
26944
26945
26946
26947
26948
26949
26950
26951
26952
26953
26954
26955
26956
26957
26958
26959
26960
26961
26962
26963
26964
26965
26966
26967
26968
26969
26970
26971
26972
26973
26974
26975
26976
26977
26978
26979
26980
26981
26982
26983
26984
26985
26986
26987
26988
26989
26990
26991
26992
26993
26994
26995
26996
26997
26998
26999
27000
27001
27002
27003
27004
27005
27006
27007
27008
27009
27010
27011
27012
27013
27014
27015
27016
27017
27018
27019
27020
27021
27022
27023
27024
27025
27026
27027
27028
27029
27030
27031
27032
27033
27034
27035
27036
27037
27038
27039
27040
27041
27042
27043
27044
27045
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055
27056
27057
27058
27059
27060
27061
27062
27063
27064
27065
27066
27067
27068
27069
27070
27071
27072
27073
27074
27075
27076
27077
27078
27079
27080
27081
27082
27083
27084
27085
27086
27087
27088
27089
27090
27091
27092
27093
27094
27095
27096
27097
27098
27099
27100
27101
27102
27103
27104
27105
27106
27107
27108
27109
27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
27135
27136
27137
27138
27139
27140
27141
27142
27143
27144
27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
27166
27167
27168
27169
27170
27171
27172
27173
27174
27175
27176
27177
27178
27179
27180
27181
27182
27183
27184
27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
27195
27196
27197
27198
27199
27200
27201
27202
27203
27204
27205
27206
27207
27208
27209
27210
27211
27212
27213
27214
27215
27216
27217
27218
27219
27220
27221
27222
27223
27224
27225
27226
27227
27228
27229
27230
27231
27232
27233
27234
27235
27236
27237
27238
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262
27263
27264
27265
27266
27267
27268
27269
27270
27271
27272
27273
27274
27275
27276
27277
27278
27279
27280
27281
27282
27283
27284
27285
27286
27287
27288
27289
27290
27291
27292
27293
27294
27295
27296
27297
27298
27299
27300
27301
27302
27303
27304
27305
27306
27307
27308
27309
27310
27311
27312
27313
27314
27315
27316
27317
27318
27319
27320
27321
27322
27323
27324
27325
27326
27327
27328
27329
27330
27331
27332
27333
27334
27335
27336
27337
27338
27339
27340
27341
27342
27343
27344
27345
27346
27347
27348
27349
27350
27351
27352
27353
27354
27355
27356
27357
27358
27359
27360
27361
27362
27363
27364
27365
27366
27367
27368
27369
27370
27371
27372
27373
27374
27375
27376
27377
27378
27379
27380
27381
27382
27383
27384
27385
27386
27387
27388
27389
27390
27391
27392
27393
27394
27395
27396
27397
27398
27399
27400
27401
27402
27403
27404
27405
27406
27407
27408
27409
27410
27411
27412
27413
27414
27415
27416
27417
27418
27419
27420
27421
27422
27423
27424
27425
27426
27427
27428
27429
27430
27431
27432
27433
27434
27435
27436
27437
27438
27439
27440
27441
27442
27443
27444
27445
27446
27447
27448
27449
27450
27451
27452
27453
27454
27455
27456
27457
27458
27459
27460
27461
27462
27463
27464
27465
27466
27467
27468
27469
27470
27471
27472
27473
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498
27499
27500
27501
27502
27503
27504
27505
27506
27507
27508
27509
27510
27511
27512
27513
27514
27515
27516
27517
27518
27519
27520
27521
27522
27523
27524
27525
27526
27527
27528
27529
27530
27531
27532
27533
27534
27535
27536
27537
27538
27539
27540
27541
27542
27543
27544
27545
27546
27547
27548
27549
27550
27551
27552
27553
27554
27555
27556
27557
27558
27559
27560
27561
27562
27563
27564
27565
27566
27567
27568
27569
27570
27571
27572
27573
27574
27575
27576
27577
27578
27579
27580
27581
27582
27583
27584
27585
27586
27587
27588
27589
27590
27591
27592
27593
27594
27595
27596
27597
27598
27599
27600
27601
27602
27603
27604
27605
27606
27607
27608
27609
27610
27611
27612
27613
27614
27615
27616
27617
27618
27619
27620
27621
27622
27623
27624
27625
27626
27627
27628
27629
27630
27631
27632
27633
27634
27635
27636
27637
27638
27639
27640
27641
27642
27643
27644
27645
27646
27647
27648
27649
27650
27651
27652
27653
27654
27655
27656
27657
27658
27659
27660
27661
27662
27663
27664
27665
27666
27667
27668
27669
27670
27671
27672
27673
27674
27675
27676
27677
27678
27679
27680
27681
27682
27683
27684
27685
27686
27687
27688
27689
27690
27691
27692
27693
27694
27695
27696
27697
27698
27699
27700
27701
27702
27703
27704
27705
27706
27707
27708
27709
27710
27711
27712
27713
27714
27715
27716
27717
27718
27719
27720
27721
27722
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732
27733
27734
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751
27752
27753
27754
27755
27756
27757
27758
27759
27760
27761
27762
27763
27764
27765
27766
27767
27768
27769
27770
27771
27772
27773
27774
27775
27776
27777
27778
27779
27780
27781
27782
27783
27784
27785
27786
27787
27788
27789
27790
27791
27792
27793
27794
27795
27796
27797
27798
27799
27800
27801
27802
27803
27804
27805
27806
27807
27808
27809
27810
27811
27812
27813
27814
27815
27816
27817
27818
27819
27820
27821
27822
27823
27824
27825
27826
27827
27828
27829
27830
27831
27832
27833
27834
27835
27836
27837
27838
27839
27840
27841
27842
27843
27844
27845
27846
27847
27848
27849
27850
27851
27852
27853
27854
27855
27856
27857
27858
27859
27860
27861
27862
27863
27864
27865
27866
27867
27868
27869
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879
27880
27881
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897
27898
27899
27900
27901
27902
27903
27904
27905
27906
27907
27908
27909
27910
27911
27912
27913
27914
27915
27916
27917
27918
27919
27920
27921
27922
27923
27924
27925
27926
27927
27928
27929
27930
27931
27932
27933
27934
27935
27936
27937
27938
27939
27940
27941
27942
27943
27944
27945
27946
27947
27948
27949
27950
27951
27952
27953
27954
27955
27956
27957
27958
27959
27960
27961
27962
27963
27964
27965
27966
27967
27968
27969
27970
27971
27972
27973
27974
27975
27976
27977
27978
27979
27980
27981
27982
27983
27984
27985
27986
27987
27988
27989
27990
27991
27992
27993
27994
27995
27996
27997
27998
27999
28000
28001
28002
28003
28004
28005
28006
28007
28008
28009
28010
28011
28012
28013
28014
28015
28016
28017
28018
28019
28020
28021
28022
28023
28024
28025
28026
28027
28028
28029
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046
28047
28048
28049
28050
28051
28052
28053
28054
28055
28056
28057
28058
28059
28060
28061
28062
28063
28064
28065
28066
28067
28068
28069
28070
28071
28072
28073
28074
28075
28076
28077
28078
28079
28080
28081
28082
28083
28084
28085
28086
28087
28088
28089
28090
28091
28092
28093
28094
28095
28096
28097
28098
28099
28100
28101
28102
28103
28104
28105
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115
28116
28117
28118
28119
28120
28121
28122
28123
28124
28125
28126
28127
28128
28129
28130
28131
28132
28133
28134
28135
28136
28137
28138
28139
28140
28141
28142
28143
28144
28145
28146
28147
28148
28149
28150
28151
28152
28153
28154
28155
28156
28157
28158
28159
28160
28161
28162
28163
28164
28165
28166
28167
28168
28169
28170
28171
28172
28173
28174
28175
28176
28177
28178
28179
28180
28181
28182
28183
28184
28185
28186
28187
28188
28189
28190
28191
28192
28193
28194
28195
28196
28197
28198
28199
28200
28201
28202
28203
28204
28205
28206
28207
28208
28209
28210
28211
28212
28213
28214
28215
28216
28217
28218
28219
28220
28221
28222
28223
28224
28225
28226
28227
28228
28229
28230
28231
28232
28233
28234
28235
28236
28237
28238
28239
28240
28241
28242
28243
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258
28259
28260
28261
28262
28263
28264
28265
28266
28267
28268
28269
28270
28271
28272
28273
28274
28275
28276
28277
28278
28279
28280
28281
28282
28283
28284
28285
28286
28287
28288
28289
28290
28291
28292
28293
28294
28295
28296
28297
28298
28299
28300
28301
28302
28303
28304
28305
28306
28307
28308
28309
28310
28311
28312
28313
28314
28315
28316
28317
28318
28319
28320
28321
28322
28323
28324
28325
28326
28327
28328
28329
28330
28331
28332
28333
28334
28335
28336
28337
28338
28339
28340
28341
28342
28343
28344
28345
28346
28347
28348
28349
28350
28351
28352
28353
28354
28355
28356
28357
28358
28359
28360
28361
28362
28363
28364
28365
28366
28367
28368
28369
28370
28371
28372
28373
28374
28375
28376
28377
28378
28379
28380
28381
28382
28383
28384
28385
28386
28387
28388
28389
28390
28391
28392
28393
28394
28395
28396
28397
28398
28399
28400
28401
28402
28403
28404
28405
28406
28407
28408
28409
28410
28411
28412
28413
28414
28415
28416
28417
28418
28419
28420
28421
28422
28423
28424
28425
28426
28427
28428
28429
28430
28431
28432
28433
28434
28435
28436
28437
28438
28439
28440
28441
28442
28443
28444
28445
28446
28447
28448
28449
28450
28451
28452
28453
28454
28455
28456
28457
28458
28459
28460
28461
28462
28463
28464
28465
28466
28467
28468
28469
28470
28471
28472
28473
28474
28475
28476
28477
28478
28479
28480
28481
28482
28483
28484
28485
28486
28487
28488
28489
28490
28491
28492
28493
28494
28495
28496
28497
28498
28499
28500
28501
28502
28503
28504
28505
28506
28507
28508
28509
28510
28511
28512
28513
28514
28515
28516
28517
28518
28519
28520
28521
28522
28523
28524
28525
28526
28527
28528
28529
28530
28531
28532
28533
28534
28535
28536
28537
28538
28539
28540
28541
28542
28543
28544
28545
28546
28547
28548
28549
28550
28551
28552
28553
28554
28555
28556
28557
28558
28559
28560
28561
28562
28563
28564
28565
28566
28567
28568
28569
28570
28571
28572
28573
28574
28575
28576
28577
28578
28579
28580
28581
28582
28583
28584
28585
28586
28587
28588
28589
28590
28591
28592
28593
28594
28595
28596
28597
28598
28599
28600
28601
28602
28603
28604
28605
28606
28607
28608
28609
28610
28611
28612
28613
28614
28615
28616
28617
28618
28619
28620
28621
28622
28623
28624
28625
28626
28627
28628
28629
28630
28631
28632
28633
28634
28635
28636
28637
28638
28639
28640
28641
28642
28643
28644
28645
28646
28647
28648
28649
28650
28651
28652
28653
28654
28655
28656
28657
28658
28659
28660
28661
28662
28663
28664
28665
28666
28667
28668
28669
28670
28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
28681
28682
28683
28684
28685
28686
28687
28688
28689
28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
28700
28701
28702
28703
28704
28705
28706
28707
28708
28709
28710
28711
28712
28713
28714
28715
28716
28717
28718
28719
28720
28721
28722
28723
28724
28725
28726
28727
28728
28729
28730
28731
28732
28733
28734
28735
28736
28737
28738
28739
28740
28741
28742
28743
28744
28745
28746
28747
28748
28749
28750
28751
28752
28753
28754
28755
28756
28757
28758
28759
28760
28761
28762
28763
28764
28765
28766
28767
28768
28769
28770
28771
28772
28773
28774
28775
28776
28777
28778
28779
28780
28781
28782
28783
28784
28785
28786
28787
28788
28789
28790
28791
28792
28793
28794
28795
28796
28797
28798
28799
28800
28801
28802
28803
28804
28805
28806
28807
28808
28809
28810
28811
28812
28813
28814
28815
28816
28817
28818
28819
28820
28821
28822
28823
28824
28825
28826
28827
28828
28829
28830
28831
28832
28833
28834
28835
28836
28837
28838
28839
28840
28841
28842
28843
28844
28845
28846
28847
28848
28849
28850
28851
28852
28853
28854
28855
28856
28857
28858
28859
28860
28861
28862
28863
28864
28865
28866
28867
28868
28869
28870
28871
28872
28873
28874
28875
28876
28877
28878
28879
28880
28881
28882
28883
28884
28885
28886
28887
28888
28889
28890
28891
28892
28893
28894
28895
28896
28897
28898
28899
28900
28901
28902
28903
28904
28905
28906
28907
28908
28909
28910
28911
28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
28928
28929
28930
28931
28932
28933
28934
28935
28936
28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968
28969
28970
28971
28972
28973
28974
28975
28976
28977
28978
28979
28980
28981
28982
28983
28984
28985
28986
28987
28988
28989
28990
28991
28992
28993
28994
28995
28996
28997
28998
28999
29000
29001
29002
29003
29004
29005
29006
29007
29008
29009
29010
29011
29012
29013
29014
29015
29016
29017
29018
29019
29020
29021
29022
29023
29024
29025
29026
29027
29028
29029
29030
29031
29032
29033
29034
29035
29036
29037
29038
29039
29040
29041
29042
29043
29044
29045
29046
29047
29048
29049
29050
29051
29052
29053
29054
29055
29056
29057
29058
29059
29060
29061
29062
29063
29064
29065
29066
29067
29068
29069
29070
29071
29072
29073
29074
29075
29076
29077
29078
29079
29080
29081
29082
29083
29084
29085
29086
29087
29088
29089
29090
29091
29092
29093
29094
29095
29096
29097
29098
29099
29100
29101
29102
29103
29104
29105
29106
29107
29108
29109
29110
29111
29112
29113
29114
29115
29116
29117
29118
29119
29120
29121
29122
29123
29124
29125
29126
29127
29128
29129
29130
29131
29132
29133
29134
29135
29136
29137
29138
29139
29140
29141
29142
29143
29144
29145
29146
29147
29148
29149
29150
29151
29152
29153
29154
29155
29156
29157
29158
29159
29160
29161
29162
29163
29164
29165
29166
29167
29168
29169
29170
29171
29172
29173
29174
29175
29176
29177
29178
29179
29180
29181
29182
29183
29184
29185
29186
29187
29188
29189
29190
29191
29192
29193
29194
29195
29196
29197
29198
29199
29200
29201
29202
29203
29204
29205
29206
29207
29208
29209
29210
29211
29212
29213
29214
29215
29216
29217
29218
29219
29220
29221
29222
29223
29224
29225
29226
29227
29228
29229
29230
29231
29232
29233
29234
29235
29236
29237
29238
29239
29240
29241
29242
29243
29244
29245
29246
29247
29248
29249
29250
29251
29252
29253
29254
29255
29256
29257
29258
29259
29260
29261
29262
29263
29264
29265
29266
29267
29268
29269
29270
29271
29272
29273
29274
29275
29276
29277
29278
29279
29280
29281
29282
29283
29284
29285
29286
29287
29288
29289
29290
29291
29292
29293
29294
29295
29296
29297
29298
29299
29300
29301
29302
29303
29304
29305
29306
29307
29308
29309
29310
29311
29312
29313
29314
29315
29316
29317
29318
29319
29320
29321
29322
29323
29324
29325
29326
29327
29328
29329
29330
29331
29332
29333
29334
29335
29336
29337
29338
29339
29340
29341
29342
29343
29344
29345
29346
29347
29348
29349
29350
29351
29352
29353
29354
29355
29356
29357
29358
29359
29360
29361
29362
29363
29364
29365
29366
29367
29368
29369
29370
29371
29372
29373
29374
29375
29376
29377
29378
29379
29380
29381
29382
29383
29384
29385
29386
29387
29388
29389
29390
29391
29392
29393
29394
29395
29396
29397
29398
29399
29400
29401
29402
29403
29404
29405
29406
29407
29408
29409
29410
29411
29412
29413
29414
29415
29416
29417
29418
29419
29420
29421
29422
29423
29424
29425
29426
29427
29428
29429
29430
29431
29432
29433
29434
29435
29436
29437
29438
29439
29440
29441
29442
29443
29444
29445
29446
29447
29448
29449
29450
29451
29452
29453
29454
29455
29456
29457
29458
29459
29460
29461
29462
29463
29464
29465
29466
29467
29468
29469
29470
29471
29472
29473
29474
29475
29476
29477
29478
29479
29480
29481
29482
29483
29484
29485
29486
29487
29488
29489
29490
29491
29492
29493
29494
29495
29496
29497
29498
29499
29500
29501
29502
29503
29504
29505
29506
29507
29508
29509
29510
29511
29512
29513
29514
29515
29516
29517
29518
29519
29520
29521
29522
29523
29524
29525
29526
29527
29528
29529
29530
29531
29532
29533
29534
29535
29536
29537
29538
29539
29540
29541
29542
29543
29544
29545
29546
29547
29548
29549
29550
29551
29552
29553
29554
29555
29556
29557
29558
29559
29560
29561
29562
29563
29564
29565
29566
29567
29568
29569
29570
29571
29572
29573
29574
29575
29576
29577
29578
29579
29580
29581
29582
29583
29584
29585
29586
29587
29588
29589
29590
29591
29592
29593
29594
29595
29596
29597
29598
29599
29600
29601
29602
29603
29604
29605
29606
29607
29608
29609
29610
29611
29612
29613
29614
29615
29616
29617
29618
29619
29620
29621
29622
29623
29624
29625
29626
29627
29628
29629
29630
29631
29632
29633
29634
29635
29636
29637
29638
29639
29640
29641
29642
29643
29644
29645
29646
29647
29648
29649
29650
29651
29652
29653
29654
29655
29656
29657
29658
29659
29660
29661
29662
29663
29664
29665
29666
29667
29668
29669
29670
29671
29672
29673
29674
29675
29676
29677
29678
29679
29680
29681
29682
29683
29684
29685
29686
29687
29688
29689
29690
29691
29692
29693
29694
29695
29696
29697
29698
29699
29700
29701
29702
29703
29704
29705
29706
29707
29708
29709
29710
29711
29712
29713
29714
29715
29716
29717
29718
29719
29720
29721
29722
29723
29724
29725
29726
29727
29728
29729
29730
29731
29732
29733
29734
29735
29736
29737
29738
29739
29740
29741
29742
29743
29744
29745
29746
29747
29748
29749
29750
29751
29752
29753
29754
29755
29756
29757
29758
29759
29760
29761
29762
29763
29764
29765
29766
29767
29768
29769
29770
29771
29772
29773
29774
29775
29776
29777
29778
29779
29780
29781
29782
29783
29784
29785
29786
29787
29788
29789
29790
29791
29792
29793
29794
29795
29796
29797
29798
29799
29800
29801
29802
29803
29804
29805
29806
29807
29808
29809
29810
29811
29812
29813
29814
29815
29816
29817
29818
29819
29820
29821
29822
29823
29824
29825
29826
29827
29828
29829
29830
29831
29832
29833
29834
29835
29836
29837
29838
29839
29840
29841
29842
29843
29844
29845
29846
29847
29848
29849
29850
29851
29852
29853
29854
29855
29856
29857
29858
29859
29860
29861
29862
29863
29864
29865
29866
29867
29868
29869
29870
29871
29872
29873
29874
29875
29876
29877
29878
29879
29880
29881
29882
29883
29884
29885
29886
29887
29888
29889
29890
29891
29892
29893
29894
29895
29896
29897
29898
29899
29900
29901
29902
29903
29904
29905
29906
29907
29908
29909
29910
29911
29912
29913
29914
29915
29916
29917
29918
29919
29920
29921
29922
29923
29924
29925
29926
29927
29928
29929
29930
29931
29932
29933
29934
29935
29936
29937
29938
29939
29940
29941
29942
29943
29944
29945
29946
29947
29948
29949
29950
29951
29952
29953
29954
29955
29956
29957
29958
29959
29960
29961
29962
29963
29964
29965
29966
29967
29968
29969
29970
29971
29972
29973
29974
29975
29976
29977
29978
29979
29980
29981
29982
29983
29984
29985
29986
29987
29988
29989
29990
29991
29992
29993
29994
29995
29996
29997
29998
29999
30000
30001
30002
30003
30004
30005
30006
30007
30008
30009
30010
30011
30012
30013
30014
30015
30016
30017
30018
30019
30020
30021
30022
30023
30024
30025
30026
30027
30028
30029
30030
30031
30032
30033
30034
30035
30036
30037
30038
30039
30040
30041
30042
30043
30044
30045
30046
30047
30048
30049
30050
30051
30052
30053
30054
30055
30056
30057
30058
30059
30060
30061
30062
30063
30064
30065
30066
30067
30068
30069
30070
30071
30072
30073
30074
30075
30076
30077
30078
30079
30080
30081
30082
30083
30084
30085
30086
30087
30088
30089
30090
30091
30092
30093
30094
30095
30096
30097
30098
30099
30100
30101
30102
30103
30104
30105
30106
30107
30108
30109
30110
30111
30112
30113
30114
30115
30116
30117
30118
30119
30120
30121
30122
30123
30124
30125
30126
30127
30128
30129
30130
30131
30132
30133
30134
30135
30136
30137
30138
30139
30140
30141
30142
30143
30144
30145
30146
30147
30148
30149
30150
30151
30152
30153
30154
30155
30156
30157
30158
30159
30160
30161
30162
30163
30164
30165
30166
30167
30168
30169
30170
30171
30172
30173
30174
30175
30176
30177
30178
30179
30180
30181
30182
30183
30184
30185
30186
30187
30188
30189
30190
30191
30192
30193
30194
30195
30196
30197
30198
30199
30200
30201
30202
30203
30204
30205
30206
30207
30208
30209
30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
30223
30224
30225
30226
30227
30228
30229
30230
30231
30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
30245
30246
30247
30248
30249
30250
30251
30252
30253
30254
30255
30256
30257
30258
30259
30260
30261
30262
30263
30264
30265
30266
30267
30268
30269
30270
30271
30272
30273
30274
30275
30276
30277
30278
30279
30280
30281
30282
30283
30284
30285
30286
30287
30288
30289
30290
30291
30292
30293
30294
30295
30296
30297
30298
30299
30300
30301
30302
30303
30304
30305
30306
30307
30308
30309
30310
30311
30312
30313
30314
30315
30316
30317
30318
30319
30320
30321
30322
30323
30324
30325
30326
30327
30328
30329
30330
30331
30332
30333
30334
30335
30336
30337
30338
30339
30340
30341
30342
30343
30344
30345
30346
30347
30348
30349
30350
30351
30352
30353
30354
30355
30356
30357
30358
30359
30360
30361
30362
30363
30364
30365
30366
30367
30368
30369
30370
30371
30372
30373
30374
30375
30376
30377
30378
30379
30380
30381
30382
30383
30384
30385
30386
30387
30388
30389
30390
30391
30392
30393
30394
30395
30396
30397
30398
30399
30400
30401
30402
30403
30404
30405
30406
30407
30408
30409
30410
30411
30412
30413
30414
30415
30416
30417
30418
30419
30420
30421
30422
30423
30424
30425
30426
30427
30428
30429
30430
30431
30432
30433
30434
30435
30436
30437
30438
30439
30440
30441
30442
30443
30444
30445
30446
30447
30448
30449
30450
30451
30452
30453
30454
30455
30456
30457
30458
30459
30460
30461
30462
30463
30464
30465
30466
30467
30468
30469
30470
30471
30472
30473
30474
30475
30476
30477
30478
30479
30480
30481
30482
30483
30484
30485
30486
30487
30488
30489
30490
30491
30492
30493
30494
30495
30496
30497
30498
30499
30500
30501
30502
30503
30504
30505
30506
30507
30508
30509
30510
30511
30512
30513
30514
30515
30516
30517
30518
30519
30520
30521
30522
30523
30524
30525
30526
30527
30528
30529
30530
30531
30532
30533
30534
30535
30536
30537
30538
30539
30540
30541
30542
30543
30544
30545
30546
30547
30548
30549
30550
30551
30552
30553
30554
30555
30556
30557
30558
30559
30560
30561
30562
30563
30564
30565
30566
30567
30568
30569
30570
30571
30572
30573
30574
30575
30576
30577
30578
30579
30580
30581
30582
30583
30584
30585
30586
30587
30588
30589
30590
30591
30592
30593
30594
30595
30596
30597
30598
30599
30600
30601
30602
30603
30604
30605
30606
30607
30608
30609
30610
30611
30612
30613
30614
30615
30616
30617
30618
30619
30620
30621
30622
30623
30624
30625
30626
30627
30628
30629
30630
30631
30632
30633
30634
30635
30636
30637
30638
30639
30640
30641
30642
30643
30644
30645
30646
30647
30648
30649
30650
30651
30652
30653
30654
30655
30656
30657
30658
30659
30660
30661
30662
30663
30664
30665
30666
30667
30668
30669
30670
30671
30672
30673
30674
30675
30676
30677
30678
30679
30680
30681
30682
30683
30684
30685
30686
30687
30688
30689
30690
30691
30692
30693
30694
30695
30696
30697
30698
30699
30700
30701
30702
30703
30704
30705
30706
30707
30708
30709
30710
30711
30712
30713
30714
30715
30716
30717
30718
30719
30720
30721
30722
30723
30724
30725
30726
30727
30728
30729
30730
30731
30732
30733
30734
30735
30736
30737
30738
30739
30740
30741
30742
30743
30744
30745
30746
30747
30748
30749
30750
30751
30752
30753
30754
30755
30756
30757
30758
30759
30760
30761
30762
30763
30764
30765
30766
30767
30768
30769
30770
30771
30772
30773
30774
30775
30776
30777
30778
30779
30780
30781
30782
30783
30784
30785
30786
30787
30788
30789
30790
30791
30792
30793
30794
30795
30796
30797
30798
30799
30800
30801
30802
30803
30804
30805
30806
30807
30808
30809
30810
30811
30812
30813
30814
30815
30816
30817
30818
30819
30820
30821
30822
30823
30824
30825
30826
30827
30828
30829
30830
30831
30832
30833
30834
30835
30836
30837
30838
30839
30840
30841
30842
30843
30844
30845
30846
30847
30848
30849
30850
30851
30852
30853
30854
30855
30856
30857
30858
30859
30860
30861
30862
30863
30864
30865
30866
30867
30868
30869
30870
30871
30872
30873
30874
30875
30876
30877
30878
30879
30880
30881
30882
30883
30884
30885
30886
30887
30888
30889
30890
30891
30892
30893
30894
30895
30896
30897
30898
30899
30900
30901
30902
30903
30904
30905
30906
30907
30908
30909
30910
30911
30912
30913
30914
30915
30916
30917
30918
30919
30920
30921
30922
30923
30924
30925
30926
30927
30928
30929
30930
30931
30932
30933
30934
30935
30936
30937
30938
30939
30940
30941
30942
30943
30944
30945
30946
30947
30948
30949
30950
30951
30952
30953
30954
30955
30956
30957
30958
30959
30960
30961
30962
30963
30964
30965
30966
30967
30968
30969
30970
30971
30972
30973
30974
30975
30976
30977
30978
30979
30980
30981
30982
30983
30984
30985
30986
30987
30988
30989
30990
30991
30992
30993
30994
30995
30996
30997
30998
30999
31000
31001
31002
31003
31004
31005
31006
31007
31008
31009
31010
31011
31012
31013
31014
31015
31016
31017
31018
31019
31020
31021
31022
31023
31024
31025
31026
31027
31028
31029
31030
31031
31032
31033
31034
31035
31036
31037
31038
31039
31040
31041
31042
31043
31044
31045
31046
31047
31048
31049
31050
31051
31052
31053
31054
31055
31056
31057
31058
31059
31060
31061
31062
31063
31064
31065
31066
31067
31068
31069
31070
31071
31072
31073
31074
31075
31076
31077
31078
31079
31080
31081
31082
31083
31084
31085
31086
31087
31088
31089
31090
31091
31092
31093
31094
31095
31096
31097
31098
31099
31100
31101
31102
31103
31104
31105
31106
31107
31108
31109
31110
31111
31112
31113
31114
31115
31116
31117
31118
31119
31120
31121
31122
31123
31124
31125
31126
31127
31128
31129
31130
31131
31132
31133
31134
31135
31136
31137
31138
31139
31140
31141
31142
31143
31144
31145
31146
31147
31148
31149
31150
31151
31152
31153
31154
31155
31156
31157
31158
31159
31160
31161
31162
31163
31164
31165
31166
31167
31168
31169
31170
31171
31172
31173
31174
31175
31176
31177
31178
31179
31180
31181
31182
31183
31184
31185
31186
31187
31188
31189
31190
31191
31192
31193
31194
31195
31196
31197
31198
31199
31200
31201
31202
31203
31204
31205
31206
31207
31208
31209
31210
31211
31212
31213
31214
31215
31216
31217
31218
31219
31220
31221
31222
31223
31224
31225
31226
31227
31228
31229
31230
31231
31232
31233
31234
31235
31236
31237
31238
31239
31240
31241
31242
31243
31244
31245
31246
31247
31248
31249
31250
31251
31252
31253
31254
31255
31256
31257
31258
31259
31260
31261
31262
31263
31264
31265
31266
31267
31268
31269
31270
31271
31272
31273
31274
31275
31276
31277
31278
31279
31280
31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
31426
31427
31428
31429
31430
31431
31432
31433
31434
31435
31436
31437
31438
31439
31440
31441
31442
31443
31444
31445
31446
31447
31448
31449
31450
31451
31452
31453
31454
31455
31456
31457
31458
31459
31460
31461
31462
31463
31464
31465
31466
31467
31468
31469
31470
31471
31472
31473
31474
31475
31476
31477
31478
31479
31480
31481
31482
31483
31484
31485
31486
31487
31488
31489
31490
31491
31492
31493
31494
31495
31496
31497
31498
31499
31500
31501
31502
31503
31504
31505
31506
31507
31508
31509
31510
31511
31512
31513
31514
31515
31516
31517
31518
31519
31520
31521
31522
31523
31524
31525
31526
31527
31528
31529
31530
31531
31532
31533
31534
31535
31536
31537
31538
31539
31540
31541
31542
31543
31544
31545
31546
31547
31548
31549
31550
31551
31552
31553
31554
31555
31556
31557
31558
31559
31560
31561
31562
31563
31564
31565
31566
31567
31568
31569
31570
31571
31572
31573
31574
31575
31576
31577
31578
31579
31580
31581
31582
31583
31584
31585
31586
31587
31588
31589
31590
31591
31592
31593
31594
31595
31596
31597
31598
31599
31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
31618
31619
31620
31621
31622
31623
31624
31625
31626
31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
31644
31645
31646
31647
31648
31649
31650
31651
31652
31653
31654
31655
31656
31657
31658
31659
31660
31661
31662
31663
31664
31665
31666
31667
31668
31669
31670
31671
31672
31673
31674
31675
31676
31677
31678
31679
31680
31681
31682
31683
31684
31685
31686
31687
31688
31689
31690
31691
31692
31693
31694
31695
31696
31697
31698
31699
31700
31701
31702
31703
31704
31705
31706
31707
31708
31709
31710
31711
31712
31713
31714
31715
31716
31717
31718
31719
31720
31721
31722
31723
31724
31725
31726
31727
31728
31729
31730
31731
31732
31733
31734
31735
31736
31737
31738
31739
31740
31741
31742
31743
31744
31745
31746
31747
31748
31749
31750
31751
31752
31753
31754
31755
31756
31757
31758
31759
31760
31761
31762
31763
31764
31765
31766
31767
31768
31769
31770
31771
31772
31773
31774
31775
31776
31777
31778
31779
31780
31781
31782
31783
31784
31785
31786
31787
31788
31789
31790
31791
31792
31793
31794
31795
31796
31797
31798
31799
31800
31801
31802
31803
31804
31805
31806
31807
31808
31809
31810
31811
31812
31813
31814
31815
31816
31817
31818
31819
31820
31821
31822
31823
31824
31825
31826
31827
31828
31829
31830
31831
31832
31833
31834
31835
31836
31837
31838
31839
31840
31841
31842
31843
31844
31845
31846
31847
31848
31849
31850
31851
31852
31853
31854
31855
31856
31857
31858
31859
31860
31861
31862
31863
31864
31865
31866
31867
31868
31869
31870
31871
31872
31873
31874
31875
31876
31877
31878
31879
31880
31881
31882
31883
31884
31885
31886
31887
31888
31889
31890
31891
31892
31893
31894
31895
31896
31897
31898
31899
31900
31901
31902
31903
31904
31905
31906
31907
31908
31909
31910
31911
31912
31913
31914
31915
31916
31917
31918
31919
31920
31921
31922
31923
31924
31925
31926
31927
31928
31929
31930
31931
31932
31933
31934
31935
31936
31937
31938
31939
31940
31941
31942
31943
31944
31945
31946
31947
31948
31949
31950
31951
31952
31953
31954
31955
31956
31957
31958
31959
31960
31961
31962
31963
31964
31965
31966
31967
31968
31969
31970
31971
31972
31973
31974
31975
31976
31977
31978
31979
31980
31981
31982
31983
31984
31985
31986
31987
31988
31989
31990
31991
31992
31993
31994
31995
31996
31997
31998
31999
32000
32001
32002
32003
32004
32005
32006
32007
32008
32009
32010
32011
32012
32013
32014
32015
32016
32017
32018
32019
32020
32021
32022
32023
32024
32025
32026
32027
32028
32029
32030
32031
32032
32033
32034
32035
32036
32037
32038
32039
32040
32041
32042
32043
32044
32045
32046
32047
32048
32049
32050
32051
32052
32053
32054
32055
32056
32057
32058
32059
32060
32061
32062
32063
32064
32065
32066
32067
32068
32069
32070
32071
32072
32073
32074
32075
32076
32077
32078
32079
32080
32081
32082
32083
32084
32085
32086
32087
32088
32089
32090
32091
32092
32093
32094
32095
32096
32097
32098
32099
32100
32101
32102
32103
32104
32105
32106
32107
32108
32109
32110
32111
32112
32113
32114
32115
32116
32117
32118
32119
32120
32121
32122
32123
32124
32125
32126
32127
32128
32129
32130
32131
32132
32133
32134
32135
32136
32137
32138
32139
32140
32141
32142
32143
32144
32145
32146
32147
32148
32149
32150
32151
32152
32153
32154
32155
32156
32157
32158
32159
32160
32161
32162
32163
32164
32165
32166
32167
32168
32169
32170
32171
32172
32173
32174
32175
32176
32177
32178
32179
32180
32181
32182
32183
32184
32185
32186
32187
32188
32189
32190
32191
32192
32193
32194
32195
32196
32197
32198
32199
32200
32201
32202
32203
32204
32205
32206
32207
32208
32209
32210
32211
32212
32213
32214
32215
32216
32217
32218
32219
32220
32221
32222
32223
32224
32225
32226
32227
32228
32229
32230
32231
32232
32233
32234
32235
32236
32237
32238
32239
32240
32241
32242
32243
32244
32245
32246
32247
32248
32249
32250
32251
32252
32253
32254
32255
32256
32257
32258
32259
32260
32261
32262
32263
32264
32265
32266
32267
32268
32269
32270
32271
32272
32273
32274
32275
32276
32277
32278
32279
32280
32281
32282
32283
32284
32285
32286
32287
32288
32289
32290
32291
32292
32293
32294
32295
32296
32297
32298
32299
32300
32301
32302
32303
32304
32305
32306
32307
32308
32309
32310
32311
32312
32313
32314
32315
32316
32317
32318
32319
32320
32321
32322
32323
32324
32325
32326
32327
32328
32329
32330
32331
32332
32333
32334
32335
32336
32337
32338
32339
32340
32341
32342
32343
32344
32345
32346
32347
32348
32349
32350
32351
32352
32353
32354
32355
32356
32357
32358
32359
32360
32361
32362
32363
32364
32365
32366
32367
32368
32369
32370
32371
32372
32373
32374
32375
32376
32377
32378
32379
32380
32381
32382
32383
32384
32385
32386
32387
32388
32389
32390
32391
32392
32393
32394
32395
32396
32397
32398
32399
32400
32401
32402
32403
32404
32405
32406
32407
32408
32409
32410
32411
32412
32413
32414
32415
32416
32417
32418
32419
32420
32421
32422
32423
32424
32425
32426
32427
32428
32429
32430
32431
32432
32433
32434
32435
32436
32437
32438
32439
32440
32441
32442
32443
32444
32445
32446
32447
32448
32449
32450
32451
32452
32453
32454
32455
32456
32457
32458
32459
32460
32461
32462
32463
32464
32465
32466
32467
32468
32469
32470
32471
32472
32473
32474
32475
32476
32477
32478
32479
32480
32481
32482
32483
32484
32485
32486
32487
32488
32489
32490
32491
32492
32493
32494
32495
32496
32497
32498
32499
32500
32501
32502
32503
32504
32505
32506
32507
32508
32509
32510
32511
32512
32513
32514
32515
32516
32517
32518
32519
32520
32521
32522
32523
32524
32525
32526
32527
32528
32529
32530
32531
32532
32533
32534
32535
32536
32537
32538
32539
32540
32541
32542
32543
32544
32545
32546
32547
32548
32549
32550
32551
32552
32553
32554
32555
32556
32557
32558
32559
32560
32561
32562
32563
32564
32565
32566
32567
32568
32569
32570
32571
32572
32573
32574
32575
32576
32577
32578
32579
32580
32581
32582
32583
32584
32585
32586
32587
32588
32589
32590
32591
32592
32593
32594
32595
32596
32597
32598
32599
32600
32601
32602
32603
32604
32605
32606
32607
32608
32609
32610
32611
32612
32613
32614
32615
32616
32617
32618
32619
32620
32621
32622
32623
32624
32625
32626
32627
32628
32629
32630
32631
32632
32633
32634
32635
32636
32637
32638
32639
32640
32641
32642
32643
32644
32645
32646
32647
32648
32649
32650
32651
32652
32653
32654
32655
32656
32657
32658
32659
32660
32661
32662
32663
32664
32665
32666
32667
32668
32669
32670
32671
32672
32673
32674
32675
32676
32677
32678
32679
32680
32681
32682
32683
32684
32685
32686
32687
32688
32689
32690
32691
32692
32693
32694
32695
32696
32697
32698
32699
32700
32701
32702
32703
32704
32705
32706
32707
32708
32709
32710
32711
32712
32713
32714
32715
32716
32717
32718
32719
32720
32721
32722
32723
32724
32725
32726
32727
32728
32729
32730
32731
32732
32733
32734
32735
32736
32737
32738
32739
32740
32741
32742
32743
32744
32745
32746
32747
32748
32749
32750
32751
32752
32753
32754
32755
32756
32757
32758
32759
32760
32761
32762
32763
32764
32765
32766
32767
32768
32769
32770
32771
32772
32773
32774
32775
32776
32777
32778
32779
32780
32781
32782
32783
32784
32785
32786
32787
32788
32789
32790
32791
32792
32793
32794
32795
32796
32797
32798
32799
32800
32801
32802
32803
32804
32805
32806
32807
32808
32809
32810
32811
32812
32813
32814
32815
32816
32817
32818
32819
32820
32821
32822
32823
32824
32825
32826
32827
32828
32829
32830
32831
32832
32833
32834
32835
32836
32837
32838
32839
32840
32841
32842
32843
32844
32845
32846
32847
32848
32849
32850
32851
32852
32853
32854
32855
32856
32857
32858
32859
32860
32861
32862
32863
32864
32865
32866
32867
32868
32869
32870
32871
32872
32873
32874
32875
32876
32877
32878
32879
32880
32881
32882
32883
32884
32885
32886
32887
32888
32889
32890
32891
32892
32893
32894
32895
32896
32897
32898
32899
32900
32901
32902
32903
32904
32905
32906
32907
32908
32909
32910
32911
32912
32913
32914
32915
32916
32917
32918
32919
32920
32921
32922
32923
32924
32925
32926
32927
32928
32929
32930
32931
32932
32933
32934
32935
32936
32937
32938
32939
32940
32941
32942
32943
32944
32945
32946
32947
32948
32949
32950
32951
32952
32953
32954
32955
32956
32957
32958
32959
32960
32961
32962
32963
32964
32965
32966
32967
32968
32969
32970
32971
32972
32973
32974
32975
32976
32977
32978
32979
32980
32981
32982
32983
32984
32985
32986
32987
32988
32989
32990
32991
32992
32993
32994
32995
32996
32997
32998
32999
33000
33001
33002
33003
33004
33005
33006
33007
33008
33009
33010
33011
33012
33013
33014
33015
33016
33017
33018
33019
33020
33021
33022
33023
33024
33025
33026
33027
33028
33029
33030
33031
33032
33033
33034
33035
33036
33037
33038
33039
33040
33041
33042
33043
33044
33045
33046
33047
33048
33049
33050
33051
33052
33053
33054
33055
33056
33057
33058
33059
33060
33061
33062
33063
33064
33065
33066
33067
33068
33069
33070
33071
33072
33073
33074
33075
33076
33077
33078
33079
33080
33081
33082
33083
33084
33085
33086
33087
33088
33089
33090
33091
33092
33093
33094
33095
33096
33097
33098
33099
33100
33101
33102
33103
33104
33105
33106
33107
33108
33109
33110
33111
33112
33113
33114
33115
33116
33117
33118
33119
33120
33121
33122
33123
33124
33125
33126
33127
33128
33129
33130
33131
33132
33133
33134
33135
33136
33137
33138
33139
33140
33141
33142
33143
33144
33145
33146
33147
33148
33149
33150
33151
33152
33153
33154
33155
33156
33157
33158
33159
33160
33161
33162
33163
33164
33165
33166
33167
33168
33169
33170
33171
33172
33173
33174
33175
33176
33177
33178
33179
33180
33181
33182
33183
33184
33185
33186
33187
33188
33189
33190
33191
33192
33193
33194
33195
33196
33197
33198
33199
33200
33201
33202
33203
33204
33205
33206
33207
33208
33209
33210
33211
33212
33213
33214
33215
33216
33217
33218
33219
33220
33221
33222
33223
33224
33225
33226
33227
33228
33229
33230
33231
33232
33233
33234
33235
33236
33237
33238
33239
33240
33241
33242
33243
33244
33245
33246
33247
33248
33249
33250
33251
33252
33253
33254
33255
33256
33257
33258
33259
33260
33261
33262
33263
33264
33265
33266
33267
33268
33269
33270
33271
33272
33273
33274
33275
33276
33277
33278
33279
33280
33281
33282
33283
33284
33285
33286
33287
33288
33289
33290
33291
33292
33293
33294
33295
33296
33297
33298
33299
33300
33301
33302
33303
33304
33305
33306
33307
33308
33309
33310
33311
33312
33313
33314
33315
33316
33317
33318
33319
33320
33321
33322
33323
33324
33325
33326
33327
33328
33329
33330
33331
33332
33333
33334
33335
33336
33337
33338
33339
33340
33341
33342
33343
33344
33345
33346
33347
33348
33349
33350
33351
33352
33353
33354
33355
33356
33357
33358
33359
33360
33361
33362
33363
33364
33365
33366
33367
33368
33369
33370
33371
33372
33373
33374
33375
33376
33377
33378
33379
33380
33381
33382
33383
33384
33385
33386
33387
33388
33389
33390
33391
33392
33393
33394
33395
33396
33397
33398
33399
33400
33401
33402
33403
33404
33405
33406
33407
33408
33409
33410
33411
33412
33413
33414
33415
33416
33417
33418
33419
33420
33421
33422
33423
33424
33425
33426
33427
33428
33429
33430
33431
33432
33433
33434
33435
33436
33437
33438
33439
33440
33441
33442
33443
33444
33445
33446
33447
33448
33449
33450
33451
33452
33453
33454
33455
33456
33457
33458
33459
33460
33461
33462
33463
33464
33465
33466
33467
33468
33469
33470
33471
33472
33473
33474
33475
33476
33477
33478
33479
33480
33481
33482
33483
33484
33485
33486
33487
33488
33489
33490
33491
33492
33493
33494
33495
33496
33497
33498
33499
33500
33501
33502
33503
33504
33505
33506
33507
33508
33509
33510
33511
33512
33513
33514
33515
33516
33517
33518
33519
33520
33521
33522
33523
33524
33525
33526
33527
33528
33529
33530
33531
33532
33533
33534
33535
33536
33537
33538
33539
33540
33541
33542
33543
33544
33545
33546
33547
33548
33549
33550
33551
33552
33553
33554
33555
33556
33557
33558
33559
33560
33561
33562
33563
33564
33565
33566
33567
33568
33569
33570
33571
33572
33573
33574
33575
33576
33577
33578
33579
33580
33581
33582
33583
33584
33585
33586
33587
33588
33589
33590
33591
33592
33593
33594
33595
33596
33597
33598
33599
33600
33601
33602
33603
33604
33605
33606
33607
33608
33609
33610
33611
33612
33613
33614
33615
33616
33617
33618
33619
33620
33621
33622
33623
33624
33625
33626
33627
33628
33629
33630
33631
33632
33633
33634
33635
33636
33637
33638
33639
33640
33641
33642
33643
33644
33645
33646
33647
33648
33649
33650
33651
33652
33653
33654
33655
33656
33657
33658
33659
33660
33661
33662
33663
33664
33665
33666
33667
33668
33669
33670
33671
33672
33673
33674
33675
33676
33677
33678
33679
33680
33681
33682
33683
33684
33685
33686
33687
33688
33689
33690
33691
33692
33693
33694
33695
33696
33697
33698
33699
33700
33701
33702
33703
33704
33705
33706
33707
33708
33709
33710
33711
33712
33713
33714
33715
33716
33717
33718
33719
33720
33721
33722
33723
33724
33725
33726
33727
33728
33729
33730
33731
33732
33733
33734
33735
33736
33737
33738
33739
33740
33741
33742
33743
33744
33745
33746
33747
33748
33749
33750
33751
33752
33753
33754
33755
33756
33757
33758
33759
33760
33761
33762
33763
33764
33765
33766
33767
33768
33769
33770
33771
33772
33773
33774
33775
33776
33777
33778
33779
33780
33781
33782
33783
33784
33785
33786
33787
33788
33789
33790
33791
33792
33793
33794
33795
33796
33797
33798
33799
33800
33801
33802
33803
33804
33805
33806
33807
33808
33809
33810
33811
33812
33813
33814
33815
33816
33817
33818
33819
33820
33821
33822
33823
33824
33825
33826
33827
33828
33829
33830
33831
33832
33833
33834
33835
33836
33837
33838
33839
33840
33841
33842
33843
33844
33845
33846
33847
33848
33849
33850
33851
33852
33853
33854
33855
33856
33857
33858
33859
33860
33861
33862
33863
33864
33865
33866
33867
33868
33869
33870
33871
33872
33873
33874
33875
33876
33877
33878
33879
33880
33881
33882
33883
33884
33885
33886
33887
33888
33889
33890
33891
33892
33893
33894
33895
33896
33897
33898
33899
33900
33901
33902
33903
33904
33905
33906
33907
33908
33909
33910
33911
33912
33913
33914
33915
33916
33917
33918
33919
33920
33921
33922
33923
33924
33925
33926
33927
33928
33929
33930
33931
33932
33933
33934
33935
33936
33937
33938
33939
33940
33941
33942
33943
33944
33945
33946
33947
33948
33949
33950
33951
33952
33953
33954
33955
33956
33957
33958
33959
33960
33961
33962
33963
33964
33965
33966
33967
33968
33969
33970
33971
33972
33973
33974
33975
33976
33977
33978
33979
33980
33981
33982
33983
33984
33985
33986
33987
33988
33989
33990
33991
33992
33993
33994
33995
33996
33997
33998
33999
34000
34001
34002
34003
34004
34005
34006
34007
34008
34009
34010
34011
34012
34013
34014
34015
34016
34017
34018
34019
34020
34021
34022
34023
34024
34025
34026
34027
34028
34029
34030
34031
34032
34033
34034
34035
34036
34037
34038
34039
34040
34041
34042
34043
34044
34045
34046
34047
34048
34049
34050
34051
34052
34053
34054
34055
34056
34057
34058
34059
34060
34061
34062
34063
34064
34065
34066
34067
34068
34069
34070
34071
34072
34073
34074
34075
34076
34077
34078
34079
34080
34081
34082
34083
34084
34085
34086
34087
34088
34089
34090
34091
34092
34093
34094
34095
34096
34097
34098
34099
34100
34101
34102
34103
34104
34105
34106
34107
34108
34109
34110
34111
34112
34113
34114
34115
34116
34117
34118
34119
34120
34121
34122
34123
34124
34125
34126
34127
34128
34129
34130
34131
34132
34133
34134
34135
34136
34137
34138
34139
34140
34141
34142
34143
34144
34145
34146
34147
34148
34149
34150
34151
34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
34162
34163
34164
34165
34166
34167
34168
34169
34170
34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
34181
34182
34183
34184
34185
34186
34187
34188
34189
34190
34191
34192
34193
34194
34195
34196
34197
34198
34199
34200
34201
34202
34203
34204
34205
34206
34207
34208
34209
34210
34211
34212
34213
34214
34215
34216
34217
34218
34219
34220
34221
34222
34223
34224
34225
34226
34227
34228
34229
34230
34231
34232
34233
34234
34235
34236
34237
34238
34239
34240
34241
34242
34243
34244
34245
34246
34247
34248
34249
34250
34251
34252
34253
34254
34255
34256
34257
34258
34259
34260
34261
34262
34263
34264
34265
34266
34267
34268
34269
34270
34271
34272
34273
34274
34275
34276
34277
34278
34279
34280
34281
34282
34283
34284
34285
34286
34287
34288
34289
34290
34291
34292
34293
34294
34295
34296
34297
34298
34299
34300
34301
34302
34303
34304
34305
34306
34307
34308
34309
34310
34311
34312
34313
34314
34315
34316
34317
34318
34319
34320
34321
34322
34323
34324
34325
34326
34327
34328
34329
34330
34331
34332
34333
34334
34335
34336
34337
34338
34339
34340
34341
34342
34343
34344
34345
34346
34347
34348
34349
34350
34351
34352
34353
34354
34355
34356
34357
34358
34359
34360
34361
34362
34363
34364
34365
34366
34367
34368
34369
34370
34371
34372
34373
34374
34375
34376
34377
34378
34379
34380
34381
34382
34383
34384
34385
34386
34387
34388
34389
34390
34391
34392
34393
34394
34395
34396
34397
34398
34399
34400
34401
34402
34403
34404
34405
34406
34407
34408
34409
34410
34411
34412
34413
34414
34415
34416
34417
34418
34419
34420
34421
34422
34423
34424
34425
34426
34427
34428
34429
34430
34431
34432
34433
34434
34435
34436
34437
34438
34439
34440
34441
34442
34443
34444
34445
34446
34447
34448
34449
34450
34451
34452
34453
34454
34455
34456
34457
34458
34459
34460
34461
34462
34463
34464
34465
34466
34467
34468
34469
34470
34471
34472
34473
34474
34475
34476
34477
34478
34479
34480
34481
34482
34483
34484
34485
34486
34487
34488
34489
34490
34491
34492
34493
34494
34495
34496
34497
34498
34499
34500
34501
34502
34503
34504
34505
34506
34507
34508
34509
34510
34511
34512
34513
34514
34515
34516
34517
34518
34519
34520
34521
34522
34523
34524
34525
34526
34527
34528
34529
34530
34531
34532
34533
34534
34535
34536
34537
34538
34539
34540
34541
34542
34543
34544
34545
34546
34547
34548
34549
34550
34551
34552
34553
34554
34555
34556
34557
34558
34559
34560
34561
34562
34563
34564
34565
34566
34567
34568
34569
34570
34571
34572
34573
34574
34575
34576
34577
34578
34579
34580
34581
34582
34583
34584
34585
34586
34587
34588
34589
34590
34591
34592
34593
34594
34595
34596
34597
34598
34599
34600
34601
34602
34603
34604
34605
34606
34607
34608
34609
34610
34611
34612
34613
34614
34615
34616
34617
34618
34619
34620
34621
34622
34623
34624
34625
34626
34627
34628
34629
34630
34631
34632
34633
34634
34635
34636
34637
34638
34639
34640
34641
34642
34643
34644
34645
34646
34647
34648
34649
34650
34651
34652
34653
34654
34655
34656
34657
34658
34659
34660
34661
34662
34663
34664
34665
34666
34667
34668
34669
34670
34671
34672
34673
34674
34675
34676
34677
34678
34679
34680
34681
34682
34683
34684
34685
34686
34687
34688
34689
34690
34691
34692
34693
34694
34695
34696
34697
34698
34699
34700
34701
34702
34703
34704
34705
34706
34707
34708
34709
34710
34711
34712
34713
34714
34715
34716
34717
34718
34719
34720
34721
34722
34723
34724
34725
34726
34727
34728
34729
34730
34731
34732
34733
34734
34735
34736
34737
34738
34739
34740
34741
34742
34743
34744
34745
34746
34747
34748
34749
34750
34751
34752
34753
34754
34755
34756
34757
34758
34759
34760
34761
34762
34763
34764
34765
34766
34767
34768
34769
34770
34771
34772
34773
34774
34775
34776
34777
34778
34779
34780
34781
34782
34783
34784
34785
34786
34787
34788
34789
34790
34791
34792
34793
34794
34795
34796
34797
34798
34799
34800
34801
34802
34803
34804
34805
34806
34807
34808
34809
34810
34811
34812
34813
34814
34815
34816
34817
34818
34819
34820
34821
34822
34823
34824
34825
34826
34827
34828
34829
34830
34831
34832
34833
34834
34835
34836
34837
34838
34839
34840
34841
34842
34843
34844
34845
34846
34847
34848
34849
34850
34851
34852
34853
34854
34855
34856
34857
34858
34859
34860
34861
34862
34863
34864
34865
34866
34867
34868
34869
34870
34871
34872
34873
34874
34875
34876
34877
34878
34879
34880
34881
34882
34883
34884
34885
34886
34887
34888
34889
34890
34891
34892
34893
34894
34895
34896
34897
34898
34899
34900
34901
34902
34903
34904
34905
34906
34907
34908
34909
34910
34911
34912
34913
34914
34915
34916
34917
34918
34919
34920
34921
34922
34923
34924
34925
34926
34927
34928
34929
34930
34931
34932
34933
34934
34935
34936
34937
34938
34939
34940
34941
34942
34943
34944
34945
34946
34947
34948
34949
34950
34951
34952
34953
34954
34955
34956
34957
34958
34959
34960
34961
34962
34963
34964
34965
34966
34967
34968
34969
34970
34971
34972
34973
34974
34975
34976
34977
34978
34979
34980
34981
34982
34983
34984
34985
34986
34987
34988
34989
34990
34991
34992
34993
34994
34995
34996
34997
34998
34999
35000
35001
35002
35003
35004
35005
35006
35007
35008
35009
35010
35011
35012
35013
35014
35015
35016
35017
35018
35019
35020
35021
35022
35023
35024
35025
35026
35027
35028
35029
35030
35031
35032
35033
35034
35035
35036
35037
35038
35039
35040
35041
35042
35043
35044
35045
35046
35047
35048
35049
35050
35051
35052
35053
35054
35055
35056
35057
35058
35059
35060
35061
35062
35063
35064
35065
35066
35067
35068
35069
35070
35071
35072
35073
35074
35075
35076
35077
35078
35079
35080
35081
35082
35083
35084
35085
35086
35087
35088
35089
35090
35091
35092
35093
35094
35095
35096
35097
35098
35099
35100
35101
35102
35103
35104
35105
35106
35107
35108
35109
35110
35111
35112
35113
35114
35115
35116
35117
35118
35119
35120
35121
35122
35123
35124
35125
35126
35127
35128
35129
35130
35131
35132
35133
35134
35135
35136
35137
35138
35139
35140
35141
35142
35143
35144
35145
35146
35147
35148
35149
35150
35151
35152
35153
35154
35155
35156
35157
35158
35159
35160
35161
35162
35163
35164
35165
35166
35167
35168
35169
35170
35171
35172
35173
35174
35175
35176
35177
35178
35179
35180
35181
35182
35183
35184
35185
35186
35187
35188
35189
35190
35191
35192
35193
35194
35195
35196
35197
35198
35199
35200
35201
35202
35203
35204
35205
35206
35207
35208
35209
35210
35211
35212
35213
35214
35215
35216
35217
35218
35219
35220
35221
35222
35223
35224
35225
35226
35227
35228
35229
35230
35231
35232
35233
35234
35235
35236
35237
35238
35239
35240
35241
35242
35243
35244
35245
35246
35247
35248
35249
35250
35251
35252
35253
35254
35255
35256
35257
35258
35259
35260
35261
35262
35263
35264
35265
35266
35267
35268
35269
35270
35271
35272
35273
35274
35275
35276
35277
35278
35279
35280
35281
35282
35283
35284
35285
35286
35287
35288
35289
35290
35291
35292
35293
35294
35295
35296
35297
35298
35299
35300
35301
35302
35303
35304
35305
35306
35307
35308
35309
35310
35311
35312
35313
35314
35315
35316
35317
35318
35319
35320
35321
35322
35323
35324
35325
35326
35327
35328
35329
35330
35331
35332
35333
35334
35335
35336
35337
35338
35339
35340
35341
35342
35343
35344
35345
35346
35347
35348
35349
35350
35351
35352
35353
35354
35355
35356
35357
35358
35359
35360
35361
35362
35363
35364
35365
35366
35367
35368
35369
35370
35371
35372
35373
35374
35375
35376
35377
35378
35379
35380
35381
35382
35383
35384
35385
35386
35387
35388
35389
35390
35391
35392
35393
35394
35395
35396
35397
35398
35399
35400
35401
35402
35403
35404
35405
35406
35407
35408
35409
35410
35411
35412
35413
35414
35415
35416
35417
35418
35419
35420
35421
35422
35423
35424
35425
35426
35427
35428
35429
35430
35431
35432
35433
35434
35435
35436
35437
35438
35439
35440
35441
35442
35443
35444
35445
35446
35447
35448
35449
35450
35451
35452
35453
35454
35455
35456
35457
35458
35459
35460
35461
35462
35463
35464
35465
35466
35467
35468
35469
35470
35471
35472
35473
35474
35475
35476
35477
35478
35479
35480
35481
35482
35483
35484
35485
35486
35487
35488
35489
35490
35491
35492
35493
35494
35495
35496
35497
35498
35499
35500
35501
35502
35503
35504
35505
35506
35507
35508
35509
35510
35511
35512
35513
35514
35515
35516
35517
35518
35519
35520
35521
35522
35523
35524
35525
35526
35527
35528
35529
35530
35531
35532
35533
35534
35535
35536
35537
35538
35539
35540
35541
35542
35543
35544
35545
35546
35547
35548
35549
35550
35551
35552
35553
35554
35555
35556
35557
35558
35559
35560
35561
35562
35563
35564
35565
35566
35567
35568
35569
35570
35571
35572
35573
35574
35575
35576
35577
35578
35579
35580
35581
35582
35583
35584
35585
35586
35587
35588
35589
35590
35591
35592
35593
35594
35595
35596
35597
35598
35599
35600
35601
35602
35603
35604
35605
35606
35607
35608
35609
35610
35611
35612
35613
35614
35615
35616
35617
35618
35619
35620
35621
35622
35623
35624
35625
35626
35627
35628
35629
35630
35631
35632
35633
35634
35635
35636
35637
35638
35639
35640
35641
35642
35643
35644
35645
35646
35647
35648
35649
35650
35651
35652
35653
35654
35655
35656
35657
35658
35659
35660
35661
35662
35663
35664
35665
35666
35667
35668
35669
35670
35671
35672
35673
35674
35675
35676
35677
35678
35679
35680
35681
35682
35683
35684
35685
35686
35687
35688
35689
35690
35691
35692
35693
35694
35695
35696
35697
35698
35699
35700
35701
35702
35703
35704
35705
35706
35707
35708
35709
35710
35711
35712
35713
35714
35715
35716
35717
35718
35719
35720
35721
35722
35723
35724
35725
35726
35727
35728
35729
35730
35731
35732
35733
35734
35735
35736
35737
35738
35739
35740
35741
35742
35743
35744
35745
35746
35747
35748
35749
35750
35751
35752
35753
35754
35755
35756
35757
35758
35759
35760
35761
35762
35763
35764
35765
35766
35767
35768
35769
35770
35771
35772
35773
35774
35775
35776
35777
35778
35779
35780
35781
35782
35783
35784
35785
35786
35787
35788
35789
35790
35791
35792
35793
35794
35795
35796
35797
35798
35799
35800
35801
35802
35803
35804
35805
35806
35807
35808
35809
35810
35811
35812
35813
35814
35815
35816
35817
35818
35819
35820
35821
35822
35823
35824
35825
35826
35827
35828
35829
35830
35831
35832
35833
35834
35835
35836
35837
35838
35839
35840
35841
35842
35843
35844
35845
35846
35847
35848
35849
35850
35851
35852
35853
35854
35855
35856
35857
35858
35859
35860
35861
35862
35863
35864
35865
35866
35867
35868
35869
35870
35871
35872
35873
35874
35875
35876
35877
35878
35879
35880
35881
35882
35883
35884
35885
35886
35887
35888
35889
35890
35891
35892
35893
35894
35895
35896
35897
35898
35899
35900
35901
35902
35903
35904
35905
35906
35907
35908
35909
35910
35911
35912
35913
35914
35915
35916
35917
35918
35919
35920
35921
35922
35923
35924
35925
35926
35927
35928
35929
35930
35931
35932
35933
35934
35935
35936
35937
35938
35939
35940
35941
35942
35943
35944
35945
35946
35947
35948
35949
35950
35951
35952
35953
35954
35955
35956
35957
35958
35959
35960
35961
35962
35963
35964
35965
35966
35967
35968
35969
35970
35971
35972
35973
35974
35975
35976
35977
35978
35979
35980
35981
35982
35983
35984
35985
35986
35987
35988
35989
35990
35991
35992
35993
35994
35995
35996
35997
35998
35999
36000
36001
36002
36003
36004
36005
36006
36007
36008
36009
36010
36011
36012
36013
36014
36015
36016
36017
36018
36019
36020
36021
36022
36023
36024
36025
36026
36027
36028
36029
36030
36031
36032
36033
36034
36035
36036
36037
36038
36039
36040
36041
36042
36043
36044
36045
36046
36047
36048
36049
36050
36051
36052
36053
36054
36055
36056
36057
36058
36059
36060
36061
36062
36063
36064
36065
36066
36067
36068
36069
36070
36071
36072
36073
36074
36075
36076
36077
36078
36079
36080
36081
36082
36083
36084
36085
36086
36087
36088
36089
36090
36091
36092
36093
36094
36095
36096
36097
36098
36099
36100
36101
36102
36103
36104
36105
36106
36107
36108
36109
36110
36111
36112
36113
36114
36115
36116
36117
36118
36119
36120
36121
36122
36123
36124
36125
36126
36127
36128
36129
36130
36131
36132
36133
36134
36135
36136
36137
36138
36139
36140
36141
36142
36143
36144
36145
36146
36147
36148
36149
36150
36151
36152
36153
36154
36155
36156
36157
36158
36159
36160
36161
36162
36163
36164
36165
36166
36167
36168
36169
36170
36171
36172
36173
36174
36175
36176
36177
36178
36179
36180
36181
36182
36183
36184
36185
36186
36187
36188
36189
36190
36191
36192
36193
36194
36195
36196
36197
36198
36199
36200
36201
36202
36203
36204
36205
36206
36207
36208
36209
36210
36211
36212
36213
36214
36215
36216
36217
36218
36219
36220
36221
36222
36223
36224
36225
36226
36227
36228
36229
36230
36231
36232
36233
36234
36235
36236
36237
36238
36239
36240
36241
36242
36243
36244
36245
36246
36247
36248
36249
36250
36251
36252
36253
36254
36255
36256
36257
36258
36259
36260
36261
36262
36263
36264
36265
36266
36267
36268
36269
36270
36271
36272
36273
36274
36275
36276
36277
36278
36279
36280
36281
36282
36283
36284
36285
36286
36287
36288
36289
36290
36291
36292
36293
36294
36295
36296
36297
36298
36299
36300
36301
36302
36303
36304
36305
36306
36307
36308
36309
36310
36311
36312
36313
36314
36315
36316
36317
36318
36319
36320
36321
36322
36323
36324
36325
36326
36327
36328
36329
36330
36331
36332
36333
36334
36335
36336
36337
36338
36339
36340
36341
36342
36343
36344
36345
36346
36347
36348
36349
36350
36351
36352
36353
36354
36355
36356
36357
36358
36359
36360
36361
36362
36363
36364
36365
36366
36367
36368
36369
36370
36371
36372
36373
36374
36375
36376
36377
36378
36379
36380
36381
36382
36383
36384
36385
36386
36387
36388
36389
36390
36391
36392
36393
36394
36395
36396
36397
36398
36399
36400
36401
36402
36403
36404
36405
36406
36407
36408
36409
36410
36411
36412
36413
36414
36415
36416
36417
36418
36419
36420
36421
36422
36423
36424
36425
36426
36427
36428
36429
36430
36431
36432
36433
36434
36435
36436
36437
36438
36439
36440
36441
36442
36443
36444
36445
36446
36447
36448
36449
36450
36451
36452
36453
36454
36455
36456
36457
36458
36459
36460
36461
36462
36463
36464
36465
36466
36467
36468
36469
36470
36471
36472
36473
36474
36475
36476
36477
36478
36479
36480
36481
36482
36483
36484
36485
36486
36487
36488
36489
36490
36491
36492
36493
36494
36495
36496
36497
36498
36499
36500
36501
36502
36503
36504
36505
36506
36507
36508
36509
36510
36511
36512
36513
36514
36515
36516
36517
36518
36519
36520
36521
36522
36523
36524
36525
36526
36527
36528
36529
36530
36531
36532
36533
36534
36535
36536
36537
36538
36539
36540
36541
36542
36543
36544
36545
36546
36547
36548
36549
36550
36551
36552
36553
36554
36555
36556
36557
36558
36559
36560
36561
36562
36563
36564
36565
36566
36567
36568
36569
36570
36571
36572
36573
36574
36575
36576
36577
36578
36579
36580
36581
36582
36583
36584
36585
36586
36587
36588
36589
36590
36591
36592
36593
36594
36595
36596
36597
36598
36599
36600
36601
36602
36603
36604
36605
36606
36607
36608
36609
36610
36611
36612
36613
36614
36615
36616
36617
36618
36619
36620
36621
36622
36623
36624
36625
36626
36627
36628
36629
36630
36631
36632
36633
36634
36635
36636
36637
36638
36639
36640
36641
36642
36643
36644
36645
36646
36647
36648
36649
36650
36651
36652
36653
36654
36655
36656
36657
36658
36659
36660
36661
36662
36663
36664
36665
36666
36667
36668
36669
36670
36671
36672
36673
36674
36675
36676
36677
36678
36679
36680
36681
36682
36683
36684
36685
36686
36687
36688
36689
36690
36691
36692
36693
36694
36695
36696
36697
36698
36699
36700
36701
36702
36703
36704
36705
36706
36707
36708
36709
36710
36711
36712
36713
36714
36715
36716
36717
36718
36719
36720
36721
36722
36723
36724
36725
36726
36727
36728
36729
36730
36731
36732
36733
36734
36735
36736
36737
36738
36739
36740
36741
36742
36743
36744
36745
36746
36747
36748
36749
36750
36751
36752
36753
36754
36755
36756
36757
36758
36759
36760
36761
36762
36763
36764
36765
36766
36767
36768
36769
36770
36771
36772
36773
36774
36775
36776
36777
36778
36779
36780
36781
36782
36783
36784
36785
36786
36787
36788
36789
36790
36791
36792
36793
36794
36795
36796
36797
36798
36799
36800
36801
36802
36803
36804
36805
36806
36807
36808
36809
36810
36811
36812
36813
36814
36815
36816
36817
36818
36819
36820
36821
36822
36823
36824
36825
36826
36827
36828
36829
36830
36831
36832
36833
36834
36835
36836
36837
36838
36839
36840
36841
36842
36843
36844
36845
36846
36847
36848
36849
36850
36851
36852
36853
36854
36855
36856
36857
36858
36859
36860
36861
36862
36863
36864
36865
36866
36867
36868
36869
36870
36871
36872
36873
36874
36875
36876
36877
36878
36879
36880
36881
36882
36883
36884
36885
36886
36887
36888
36889
36890
36891
36892
36893
36894
36895
36896
36897
36898
36899
36900
36901
36902
36903
36904
36905
36906
36907
36908
36909
36910
36911
36912
36913
36914
36915
36916
36917
36918
36919
36920
36921
36922
36923
36924
36925
36926
36927
36928
36929
36930
36931
36932
36933
36934
36935
36936
36937
36938
36939
36940
36941
36942
36943
36944
36945
36946
36947
36948
36949
36950
36951
36952
36953
36954
36955
36956
36957
36958
36959
36960
36961
36962
36963
36964
36965
36966
36967
36968
36969
36970
36971
36972
36973
36974
36975
36976
36977
36978
36979
36980
36981
36982
36983
36984
36985
36986
36987
36988
36989
36990
36991
36992
36993
36994
36995
36996
36997
36998
36999
37000
37001
37002
37003
37004
37005
37006
37007
37008
37009
37010
37011
37012
37013
37014
37015
37016
37017
37018
37019
37020
37021
37022
37023
37024
37025
37026
37027
37028
37029
37030
37031
37032
37033
37034
37035
37036
37037
37038
37039
37040
37041
37042
37043
37044
37045
37046
37047
37048
37049
37050
37051
37052
37053
37054
37055
37056
37057
37058
37059
37060
37061
37062
37063
37064
37065
37066
37067
37068
37069
37070
37071
37072
37073
37074
37075
37076
37077
37078
37079
37080
37081
37082
37083
37084
37085
37086
37087
37088
37089
37090
37091
37092
37093
37094
37095
37096
37097
37098
37099
37100
37101
37102
37103
37104
37105
37106
37107
37108
37109
37110
37111
37112
37113
37114
37115
37116
37117
37118
37119
37120
37121
37122
37123
37124
37125
37126
37127
37128
37129
37130
37131
37132
37133
37134
37135
37136
37137
37138
37139
37140
37141
37142
37143
37144
37145
37146
37147
37148
37149
37150
37151
37152
37153
37154
37155
37156
37157
37158
37159
37160
37161
37162
37163
37164
37165
37166
37167
37168
37169
37170
37171
37172
37173
37174
37175
37176
37177
37178
37179
37180
37181
37182
37183
37184
37185
37186
37187
37188
37189
37190
37191
37192
37193
37194
37195
37196
37197
37198
37199
37200
37201
37202
37203
37204
37205
37206
37207
37208
37209
37210
37211
37212
37213
37214
37215
37216
37217
37218
37219
37220
37221
37222
37223
37224
37225
37226
37227
37228
37229
37230
37231
37232
37233
37234
37235
37236
37237
37238
37239
37240
37241
37242
37243
37244
37245
37246
37247
37248
37249
37250
37251
37252
37253
37254
37255
37256
37257
37258
37259
37260
37261
37262
37263
37264
37265
37266
37267
37268
37269
37270
37271
37272
37273
37274
37275
37276
37277
37278
37279
37280
37281
37282
37283
37284
37285
37286
37287
37288
37289
37290
37291
37292
37293
37294
37295
37296
37297
37298
37299
37300
37301
37302
37303
37304
37305
37306
37307
37308
37309
37310
37311
37312
37313
37314
37315
37316
37317
37318
37319
37320
37321
37322
37323
37324
37325
37326
37327
37328
37329
37330
37331
37332
37333
37334
37335
37336
37337
37338
37339
37340
37341
37342
37343
37344
37345
37346
37347
37348
37349
37350
37351
37352
37353
37354
37355
37356
37357
37358
37359
37360
37361
37362
37363
37364
37365
37366
37367
37368
37369
37370
37371
37372
37373
37374
37375
37376
37377
37378
37379
37380
37381
37382
37383
37384
37385
37386
37387
37388
37389
37390
37391
37392
37393
37394
37395
37396
37397
37398
37399
37400
37401
37402
37403
37404
37405
37406
37407
37408
37409
37410
37411
37412
37413
37414
37415
37416
37417
37418
37419
37420
37421
37422
37423
37424
37425
37426
37427
37428
37429
37430
37431
37432
37433
37434
37435
37436
37437
37438
37439
37440
37441
37442
37443
37444
37445
37446
37447
37448
37449
37450
37451
37452
37453
37454
37455
37456
37457
37458
37459
37460
37461
37462
37463
37464
37465
37466
37467
37468
37469
37470
37471
37472
37473
37474
37475
37476
37477
37478
37479
37480
37481
37482
37483
37484
37485
37486
37487
37488
37489
37490
37491
37492
37493
37494
37495
37496
37497
37498
37499
37500
37501
37502
37503
37504
37505
37506
37507
37508
37509
37510
37511
37512
37513
37514
37515
37516
37517
37518
37519
37520
37521
37522
37523
37524
37525
37526
37527
37528
37529
37530
37531
37532
37533
37534
37535
37536
37537
37538
37539
37540
37541
37542
37543
37544
37545
37546
37547
37548
37549
37550
37551
37552
37553
37554
37555
37556
37557
37558
37559
37560
37561
37562
37563
37564
37565
37566
37567
37568
37569
37570
37571
37572
37573
37574
37575
37576
37577
37578
37579
37580
37581
37582
37583
37584
37585
37586
37587
37588
37589
37590
37591
37592
37593
37594
37595
37596
37597
37598
37599
37600
37601
37602
37603
37604
37605
37606
37607
37608
37609
37610
37611
37612
37613
37614
37615
37616
37617
37618
37619
37620
37621
37622
37623
37624
37625
37626
37627
37628
37629
37630
37631
37632
37633
37634
37635
37636
37637
37638
37639
37640
37641
37642
37643
37644
37645
37646
37647
37648
37649
37650
37651
37652
37653
37654
37655
37656
37657
37658
37659
37660
37661
37662
37663
37664
37665
37666
37667
37668
37669
37670
37671
37672
37673
37674
37675
37676
37677
37678
37679
37680
37681
37682
37683
37684
37685
37686
37687
37688
37689
37690
37691
37692
37693
37694
37695
37696
37697
37698
37699
37700
37701
37702
37703
37704
37705
37706
37707
37708
37709
37710
37711
37712
37713
37714
37715
37716
37717
37718
37719
37720
37721
37722
37723
37724
37725
37726
37727
37728
37729
37730
37731
37732
37733
37734
37735
37736
37737
37738
37739
37740
37741
37742
37743
37744
37745
37746
37747
37748
37749
37750
37751
37752
37753
37754
37755
37756
37757
37758
37759
37760
37761
37762
37763
37764
37765
37766
37767
37768
37769
37770
37771
37772
37773
37774
37775
37776
37777
37778
37779
37780
37781
37782
37783
37784
37785
37786
37787
37788
37789
37790
37791
37792
37793
37794
37795
37796
37797
37798
37799
37800
37801
37802
37803
37804
37805
37806
37807
37808
37809
37810
37811
37812
37813
37814
37815
37816
37817
37818
37819
37820
37821
37822
37823
37824
37825
37826
37827
37828
37829
37830
37831
37832
37833
37834
37835
37836
37837
37838
37839
37840
37841
37842
37843
37844
37845
37846
37847
37848
37849
37850
37851
37852
37853
37854
37855
37856
37857
37858
37859
37860
37861
37862
37863
37864
37865
37866
37867
37868
37869
37870
37871
37872
37873
37874
37875
37876
37877
37878
37879
37880
37881
37882
37883
37884
37885
37886
37887
37888
37889
37890
37891
37892
37893
37894
37895
37896
37897
37898
37899
37900
37901
37902
37903
37904
37905
37906
37907
37908
37909
37910
37911
37912
37913
37914
37915
37916
37917
37918
37919
37920
37921
37922
37923
37924
37925
37926
37927
37928
37929
37930
37931
37932
37933
37934
37935
37936
37937
37938
37939
37940
37941
37942
37943
37944
37945
37946
37947
37948
37949
37950
37951
37952
37953
37954
37955
37956
37957
37958
37959
37960
37961
37962
37963
37964
37965
37966
37967
37968
37969
37970
37971
37972
37973
37974
37975
37976
37977
37978
37979
37980
37981
37982
37983
37984
37985
37986
37987
37988
37989
37990
37991
37992
37993
37994
37995
37996
37997
37998
37999
38000
38001
38002
38003
38004
38005
38006
38007
38008
38009
38010
38011
38012
38013
38014
38015
38016
38017
38018
38019
38020
38021
38022
38023
38024
38025
38026
38027
38028
38029
38030
38031
38032
38033
38034
38035
38036
38037
38038
38039
38040
38041
38042
38043
38044
38045
38046
38047
38048
38049
38050
38051
38052
38053
38054
38055
38056
38057
38058
38059
38060
38061
38062
38063
38064
38065
38066
38067
38068
38069
38070
38071
38072
38073
38074
38075
38076
38077
38078
38079
38080
38081
38082
38083
38084
38085
38086
38087
38088
38089
38090
38091
38092
38093
38094
38095
38096
38097
38098
38099
38100
38101
38102
38103
38104
38105
38106
38107
38108
38109
38110
38111
38112
38113
38114
38115
38116
38117
38118
38119
38120
38121
38122
38123
38124
38125
38126
38127
38128
38129
38130
38131
38132
38133
38134
38135
38136
38137
38138
38139
38140
38141
38142
38143
38144
38145
38146
38147
38148
38149
38150
38151
38152
38153
38154
38155
38156
38157
38158
38159
38160
38161
38162
38163
38164
38165
38166
38167
38168
38169
38170
38171
38172
38173
38174
38175
38176
38177
38178
38179
38180
38181
38182
38183
38184
38185
38186
38187
38188
38189
38190
38191
38192
38193
38194
38195
38196
38197
38198
38199
38200
38201
38202
38203
38204
38205
38206
38207
38208
38209
38210
38211
38212
38213
38214
38215
38216
38217
38218
38219
38220
38221
38222
38223
38224
38225
38226
38227
38228
38229
38230
38231
38232
38233
38234
38235
38236
38237
38238
38239
38240
38241
38242
38243
38244
38245
38246
38247
38248
38249
38250
38251
38252
38253
38254
38255
38256
38257
38258
38259
38260
38261
38262
38263
38264
38265
38266
38267
38268
38269
38270
38271
38272
38273
38274
38275
38276
38277
38278
38279
38280
38281
38282
38283
38284
38285
38286
38287
38288
38289
38290
38291
38292
38293
38294
38295
38296
38297
38298
38299
38300
38301
38302
38303
38304
38305
38306
38307
38308
38309
38310
38311
38312
38313
38314
38315
38316
38317
38318
38319
38320
38321
38322
38323
38324
38325
38326
38327
38328
38329
38330
38331
38332
38333
38334
38335
38336
38337
38338
38339
38340
38341
38342
38343
38344
38345
38346
38347
38348
38349
38350
38351
38352
38353
38354
38355
38356
38357
38358
38359
38360
38361
38362
38363
38364
38365
38366
38367
38368
38369
38370
38371
38372
38373
38374
38375
38376
38377
38378
38379
38380
38381
38382
38383
38384
38385
38386
38387
38388
38389
38390
38391
38392
38393
38394
38395
38396
38397
38398
38399
38400
38401
38402
38403
38404
38405
38406
38407
38408
38409
38410
38411
38412
38413
38414
38415
38416
38417
38418
38419
38420
38421
38422
38423
38424
38425
38426
38427
38428
38429
38430
38431
38432
38433
38434
38435
38436
38437
38438
38439
38440
38441
38442
38443
38444
38445
38446
38447
38448
38449
38450
38451
38452
38453
38454
38455
38456
38457
38458
38459
38460
38461
38462
38463
38464
38465
38466
38467
38468
38469
38470
38471
38472
38473
38474
38475
38476
38477
38478
38479
38480
38481
38482
38483
38484
38485
38486
38487
38488
38489
38490
38491
38492
38493
38494
38495
38496
38497
38498
38499
38500
38501
38502
38503
38504
38505
38506
38507
38508
38509
38510
38511
38512
38513
38514
38515
38516
38517
38518
38519
38520
38521
38522
38523
38524
38525
38526
38527
38528
38529
38530
38531
38532
38533
38534
38535
38536
38537
38538
38539
38540
38541
38542
38543
38544
38545
38546
38547
38548
38549
38550
38551
38552
38553
38554
38555
38556
38557
38558
38559
38560
38561
38562
38563
38564
38565
38566
38567
38568
38569
38570
38571
38572
38573
38574
38575
38576
38577
38578
38579
38580
38581
38582
38583
38584
38585
38586
38587
38588
38589
38590
38591
38592
38593
38594
38595
38596
38597
38598
38599
38600
38601
38602
38603
38604
38605
38606
38607
38608
38609
38610
38611
38612
38613
38614
38615
38616
38617
38618
38619
38620
38621
38622
38623
38624
38625
38626
38627
38628
38629
38630
38631
38632
38633
38634
38635
38636
38637
38638
38639
38640
38641
38642
38643
38644
38645
38646
38647
38648
38649
38650
38651
38652
38653
38654
38655
38656
38657
38658
38659
38660
38661
38662
38663
38664
38665
38666
38667
38668
38669
38670
38671
38672
38673
38674
38675
38676
38677
38678
38679
38680
38681
38682
38683
38684
38685
38686
38687
38688
38689
38690
38691
38692
38693
38694
38695
38696
38697
38698
38699
38700
38701
38702
38703
38704
38705
38706
38707
38708
38709
38710
38711
38712
38713
38714
38715
38716
38717
38718
38719
38720
38721
38722
38723
38724
38725
38726
38727
38728
38729
38730
38731
38732
38733
38734
38735
38736
38737
38738
38739
38740
38741
38742
38743
38744
38745
38746
38747
38748
38749
38750
38751
38752
38753
38754
38755
38756
38757
38758
38759
38760
38761
38762
38763
38764
38765
38766
38767
38768
38769
38770
38771
38772
38773
38774
38775
38776
38777
38778
38779
38780
38781
38782
38783
38784
38785
38786
38787
38788
38789
38790
38791
38792
38793
38794
38795
38796
38797
38798
38799
38800
38801
38802
38803
38804
38805
38806
38807
38808
38809
38810
38811
38812
38813
38814
38815
38816
38817
38818
38819
38820
38821
38822
38823
38824
38825
38826
38827
38828
38829
38830
38831
38832
38833
38834
38835
38836
38837
38838
38839
38840
38841
38842
38843
38844
38845
38846
38847
38848
38849
38850
38851
38852
38853
38854
38855
38856
38857
38858
38859
38860
38861
38862
38863
38864
38865
38866
38867
38868
38869
38870
38871
38872
38873
38874
38875
38876
38877
38878
38879
38880
38881
38882
38883
38884
38885
38886
38887
38888
38889
38890
38891
38892
38893
38894
38895
38896
38897
38898
38899
38900
38901
38902
38903
38904
38905
38906
38907
38908
38909
38910
38911
38912
38913
38914
38915
38916
38917
38918
38919
38920
38921
38922
38923
38924
38925
38926
38927
38928
38929
38930
38931
38932
38933
38934
38935
38936
38937
38938
38939
38940
38941
38942
38943
38944
38945
38946
38947
38948
38949
38950
38951
38952
38953
38954
38955
38956
38957
38958
38959
38960
38961
38962
38963
38964
38965
38966
38967
38968
38969
38970
38971
38972
38973
38974
38975
38976
38977
38978
38979
38980
38981
38982
38983
38984
38985
38986
38987
38988
38989
38990
38991
38992
38993
38994
38995
38996
38997
38998
38999
39000
39001
39002
39003
39004
39005
39006
39007
39008
39009
39010
39011
39012
39013
39014
39015
39016
39017
39018
39019
39020
39021
39022
39023
39024
39025
39026
39027
39028
39029
39030
39031
39032
39033
39034
39035
39036
39037
39038
39039
39040
39041
39042
39043
39044
39045
39046
39047
39048
39049
39050
39051
39052
39053
39054
39055
39056
39057
39058
39059
39060
39061
39062
39063
39064
39065
39066
39067
39068
39069
39070
39071
39072
39073
39074
39075
39076
39077
39078
39079
39080
39081
39082
39083
39084
39085
39086
39087
39088
39089
39090
39091
39092
39093
39094
39095
39096
39097
39098
39099
39100
39101
39102
39103
39104
39105
39106
39107
39108
39109
39110
39111
39112
39113
39114
39115
39116
39117
39118
39119
39120
39121
39122
39123
39124
39125
39126
39127
39128
39129
39130
39131
39132
39133
39134
39135
39136
39137
39138
39139
39140
39141
39142
39143
39144
39145
39146
39147
39148
39149
39150
39151
39152
39153
39154
39155
39156
39157
39158
39159
39160
39161
39162
39163
39164
39165
39166
39167
39168
39169
39170
39171
39172
39173
39174
39175
39176
39177
39178
39179
39180
39181
39182
39183
39184
39185
39186
39187
39188
39189
39190
39191
39192
39193
39194
39195
39196
39197
39198
39199
39200
39201
39202
39203
39204
39205
39206
39207
39208
39209
39210
39211
39212
39213
39214
39215
39216
39217
39218
39219
39220
39221
39222
39223
39224
39225
39226
39227
39228
39229
39230
39231
39232
39233
39234
39235
39236
39237
39238
39239
39240
39241
39242
39243
39244
39245
39246
39247
39248
39249
39250
39251
39252
39253
39254
39255
39256
39257
39258
39259
39260
39261
39262
39263
39264
39265
39266
39267
39268
39269
39270
39271
39272
39273
39274
39275
39276
39277
39278
39279
39280
39281
39282
39283
39284
39285
39286
39287
39288
39289
39290
39291
39292
39293
39294
39295
39296
39297
39298
39299
39300
39301
39302
39303
39304
39305
39306
39307
39308
39309
39310
39311
39312
39313
39314
39315
39316
39317
39318
39319
39320
39321
39322
39323
39324
39325
39326
39327
39328
39329
39330
39331
39332
39333
39334
39335
39336
39337
39338
39339
39340
39341
39342
39343
39344
39345
39346
39347
39348
39349
39350
39351
39352
39353
39354
39355
39356
39357
39358
39359
39360
39361
39362
39363
39364
39365
39366
39367
39368
39369
39370
39371
39372
39373
39374
39375
39376
39377
39378
39379
39380
39381
39382
39383
39384
39385
39386
39387
39388
39389
39390
39391
39392
39393
39394
39395
39396
39397
39398
39399
39400
39401
39402
39403
39404
39405
39406
39407
39408
39409
39410
39411
39412
39413
39414
39415
39416
39417
39418
39419
39420
39421
39422
39423
39424
39425
39426
39427
39428
39429
39430
39431
39432
39433
39434
39435
39436
39437
39438
39439
39440
39441
39442
39443
39444
39445
39446
39447
39448
39449
39450
39451
39452
39453
39454
39455
39456
39457
39458
39459
39460
39461
39462
39463
39464
39465
39466
39467
39468
39469
39470
39471
39472
39473
39474
39475
39476
39477
39478
39479
39480
39481
39482
39483
39484
39485
39486
39487
39488
39489
39490
39491
39492
39493
39494
39495
39496
39497
39498
39499
39500
39501
39502
39503
39504
39505
39506
39507
39508
39509
39510
39511
39512
39513
39514
39515
39516
39517
39518
39519
39520
39521
39522
39523
39524
39525
39526
39527
39528
39529
39530
39531
39532
39533
39534
39535
39536
39537
39538
39539
39540
39541
39542
39543
39544
39545
39546
39547
39548
39549
39550
39551
39552
39553
39554
39555
39556
39557
39558
39559
39560
39561
39562
39563
39564
39565
39566
39567
39568
39569
39570
39571
39572
39573
39574
39575
39576
39577
39578
39579
39580
39581
39582
39583
39584
39585
39586
39587
39588
39589
39590
39591
39592
39593
39594
39595
39596
39597
39598
39599
39600
39601
39602
39603
39604
39605
39606
39607
39608
39609
39610
39611
39612
39613
39614
39615
39616
39617
39618
39619
39620
39621
39622
39623
39624
39625
39626
39627
39628
39629
39630
39631
39632
39633
39634
39635
39636
39637
39638
39639
39640
39641
39642
39643
39644
39645
39646
39647
39648
39649
39650
39651
39652
39653
39654
39655
39656
39657
39658
39659
39660
39661
39662
39663
39664
39665
39666
39667
39668
39669
39670
39671
39672
39673
39674
39675
39676
39677
39678
39679
39680
39681
39682
39683
39684
39685
39686
39687
39688
39689
39690
39691
39692
39693
39694
39695
39696
39697
39698
39699
39700
39701
39702
39703
39704
39705
39706
39707
39708
39709
39710
39711
39712
39713
39714
39715
39716
39717
39718
39719
39720
39721
39722
39723
39724
39725
39726
39727
39728
39729
39730
39731
39732
39733
39734
39735
39736
39737
39738
39739
39740
39741
39742
39743
39744
39745
39746
39747
39748
39749
39750
39751
39752
39753
39754
39755
39756
39757
39758
39759
39760
39761
39762
39763
39764
39765
39766
39767
39768
39769
39770
39771
39772
39773
39774
39775
39776
39777
39778
39779
39780
39781
39782
39783
39784
39785
39786
39787
39788
39789
39790
39791
39792
39793
39794
39795
39796
39797
39798
39799
39800
39801
39802
39803
39804
39805
39806
39807
39808
39809
39810
39811
39812
39813
39814
39815
39816
39817
39818
39819
39820
39821
39822
39823
39824
39825
39826
39827
39828
39829
39830
39831
39832
39833
39834
39835
39836
39837
39838
39839
39840
39841
39842
39843
39844
39845
39846
39847
39848
39849
39850
39851
39852
39853
39854
39855
39856
39857
39858
39859
39860
39861
39862
39863
39864
39865
39866
39867
39868
39869
39870
39871
39872
39873
39874
39875
39876
39877
39878
39879
39880
39881
39882
39883
39884
39885
39886
39887
39888
39889
39890
39891
39892
39893
39894
39895
39896
39897
39898
39899
39900
39901
39902
39903
39904
39905
39906
39907
39908
39909
39910
39911
39912
39913
39914
39915
39916
39917
39918
39919
39920
39921
39922
39923
39924
39925
39926
39927
39928
39929
39930
39931
39932
39933
39934
39935
39936
39937
39938
39939
39940
39941
39942
39943
39944
39945
39946
39947
39948
39949
39950
39951
39952
39953
39954
39955
39956
39957
39958
39959
39960
39961
39962
39963
39964
39965
39966
39967
39968
39969
39970
39971
39972
39973
39974
39975
39976
39977
39978
39979
39980
39981
39982
39983
39984
39985
39986
39987
39988
39989
39990
39991
39992
39993
39994
39995
39996
39997
39998
39999
40000
40001
40002
40003
40004
40005
40006
40007
40008
40009
40010
40011
40012
40013
40014
40015
40016
40017
40018
40019
40020
40021
40022
40023
40024
40025
40026
40027
40028
40029
40030
40031
40032
40033
40034
40035
40036
40037
40038
40039
40040
40041
40042
40043
40044
40045
40046
40047
40048
40049
40050
40051
40052
40053
40054
40055
40056
40057
40058
40059
40060
40061
40062
40063
40064
40065
40066
40067
40068
40069
40070
40071
40072
40073
40074
40075
40076
40077
40078
40079
40080
40081
40082
40083
40084
40085
40086
40087
40088
40089
40090
40091
40092
40093
40094
40095
40096
40097
40098
40099
40100
40101
40102
40103
40104
40105
40106
40107
40108
40109
40110
40111
40112
40113
40114
40115
40116
40117
40118
40119
40120
40121
40122
40123
40124
40125
40126
40127
40128
40129
40130
40131
40132
40133
40134
40135
40136
40137
40138
40139
40140
40141
40142
40143
40144
40145
40146
40147
40148
40149
40150
40151
40152
40153
40154
40155
40156
40157
40158
40159
40160
40161
40162
40163
40164
40165
40166
40167
40168
40169
40170
40171
40172
40173
40174
40175
40176
40177
40178
40179
40180
40181
40182
40183
40184
40185
40186
40187
40188
40189
40190
40191
40192
40193
40194
40195
40196
40197
40198
40199
40200
40201
40202
40203
40204
40205
40206
40207
40208
40209
40210
40211
40212
40213
40214
40215
40216
40217
40218
40219
40220
40221
40222
40223
40224
40225
40226
40227
40228
40229
40230
40231
40232
40233
40234
40235
40236
40237
40238
40239
40240
40241
40242
40243
40244
40245
40246
40247
40248
40249
40250
40251
40252
40253
40254
40255
40256
40257
40258
40259
40260
40261
40262
40263
40264
40265
40266
40267
40268
40269
40270
40271
40272
40273
40274
40275
40276
40277
40278
40279
40280
40281
40282
40283
40284
40285
40286
40287
40288
40289
40290
40291
40292
40293
40294
40295
40296
40297
40298
40299
40300
40301
40302
40303
40304
40305
40306
40307
40308
40309
40310
40311
40312
40313
40314
40315
40316
40317
40318
40319
40320
40321
40322
40323
40324
40325
40326
40327
40328
40329
40330
40331
40332
40333
40334
40335
40336
40337
40338
40339
40340
40341
40342
40343
40344
40345
40346
40347
40348
40349
40350
40351
40352
40353
40354
40355
40356
40357
40358
40359
40360
40361
40362
40363
40364
40365
40366
40367
40368
40369
40370
40371
40372
40373
40374
40375
40376
40377
40378
40379
40380
40381
40382
40383
40384
40385
40386
40387
40388
40389
40390
40391
40392
40393
40394
40395
40396
40397
40398
40399
40400
40401
40402
40403
40404
40405
40406
40407
40408
40409
40410
40411
40412
40413
40414
40415
40416
40417
40418
40419
40420
40421
40422
40423
40424
40425
40426
40427
40428
40429
40430
40431
40432
40433
40434
40435
40436
40437
40438
40439
40440
40441
40442
40443
40444
40445
40446
40447
40448
40449
40450
40451
40452
40453
40454
40455
40456
40457
40458
40459
40460
40461
40462
40463
40464
40465
40466
40467
40468
40469
40470
40471
40472
40473
40474
40475
40476
40477
40478
40479
40480
40481
40482
40483
40484
40485
40486
40487
40488
40489
40490
40491
40492
40493
40494
40495
40496
40497
40498
40499
40500
40501
40502
40503
40504
40505
40506
40507
40508
40509
40510
40511
40512
40513
40514
40515
40516
40517
40518
40519
40520
40521
40522
40523
40524
40525
40526
40527
40528
40529
40530
40531
40532
40533
40534
40535
40536
40537
40538
40539
40540
40541
40542
40543
40544
40545
40546
40547
40548
40549
40550
40551
40552
40553
40554
40555
40556
40557
40558
40559
40560
40561
40562
40563
40564
40565
40566
40567
40568
40569
40570
40571
40572
40573
40574
40575
40576
40577
40578
40579
40580
40581
40582
40583
40584
40585
40586
40587
40588
40589
40590
40591
40592
40593
40594
40595
40596
40597
40598
40599
40600
40601
40602
40603
40604
40605
40606
40607
40608
40609
40610
40611
40612
40613
40614
40615
40616
40617
40618
40619
40620
40621
40622
40623
40624
40625
40626
40627
40628
40629
40630
40631
40632
40633
40634
40635
40636
40637
40638
40639
40640
40641
40642
40643
40644
40645
40646
40647
40648
40649
40650
40651
40652
40653
40654
40655
40656
40657
40658
40659
40660
40661
40662
40663
40664
40665
40666
40667
40668
40669
40670
40671
40672
40673
40674
40675
40676
40677
40678
40679
40680
40681
40682
40683
40684
40685
40686
40687
40688
40689
40690
40691
40692
40693
40694
40695
40696
40697
40698
40699
40700
40701
40702
40703
40704
40705
40706
40707
40708
40709
40710
40711
40712
40713
40714
40715
40716
40717
40718
40719
40720
40721
40722
40723
40724
40725
40726
40727
40728
40729
40730
40731
40732
40733
40734
40735
40736
40737
40738
40739
40740
40741
40742
40743
40744
40745
40746
40747
40748
40749
40750
40751
40752
40753
40754
40755
40756
40757
40758
40759
40760
40761
40762
40763
40764
40765
40766
40767
40768
40769
40770
40771
40772
40773
40774
40775
40776
40777
40778
40779
40780
40781
40782
40783
40784
40785
40786
40787
40788
40789
40790
40791
40792
40793
40794
40795
40796
40797
40798
40799
40800
40801
40802
40803
40804
40805
40806
40807
40808
40809
40810
40811
40812
40813
40814
40815
40816
40817
40818
40819
40820
40821
40822
40823
40824
40825
40826
40827
40828
40829
40830
40831
40832
40833
40834
40835
40836
40837
40838
40839
40840
40841
40842
40843
40844
40845
40846
40847
40848
40849
40850
40851
40852
40853
40854
40855
40856
40857
40858
40859
40860
40861
40862
40863
40864
40865
40866
40867
40868
40869
40870
40871
40872
40873
40874
40875
40876
40877
40878
40879
40880
40881
40882
40883
40884
40885
40886
40887
40888
40889
40890
40891
40892
40893
40894
40895
40896
40897
40898
40899
40900
40901
40902
40903
40904
40905
40906
40907
40908
40909
40910
40911
40912
40913
40914
40915
40916
40917
40918
40919
40920
40921
40922
40923
40924
40925
40926
40927
40928
40929
40930
40931
40932
40933
40934
40935
40936
40937
40938
40939
40940
40941
40942
40943
40944
40945
40946
40947
40948
40949
40950
40951
40952
40953
40954
40955
40956
40957
40958
40959
40960
40961
40962
40963
40964
40965
40966
40967
40968
40969
40970
40971
40972
40973
40974
40975
40976
40977
40978
40979
40980
40981
40982
40983
40984
40985
40986
40987
40988
40989
40990
40991
40992
40993
40994
40995
40996
40997
40998
40999
41000
41001
41002
41003
41004
41005
41006
41007
41008
41009
41010
41011
41012
41013
41014
41015
41016
41017
41018
41019
41020
41021
41022
41023
41024
41025
41026
41027
41028
41029
41030
41031
41032
41033
41034
41035
41036
41037
41038
41039
41040
41041
41042
41043
41044
41045
41046
41047
41048
41049
41050
41051
41052
41053
41054
41055
41056
41057
41058
41059
41060
41061
41062
41063
41064
41065
41066
41067
41068
41069
41070
41071
41072
41073
41074
41075
41076
41077
41078
41079
41080
41081
41082
41083
41084
41085
41086
41087
41088
41089
41090
41091
41092
41093
41094
41095
41096
41097
41098
41099
41100
41101
41102
41103
41104
41105
41106
41107
41108
41109
41110
41111
41112
41113
41114
41115
41116
41117
41118
41119
41120
41121
41122
41123
41124
41125
41126
41127
41128
41129
41130
41131
41132
41133
41134
41135
41136
41137
41138
41139
41140
41141
41142
41143
41144
41145
41146
41147
41148
41149
41150
41151
41152
41153
41154
41155
41156
41157
41158
41159
41160
41161
41162
41163
41164
41165
41166
41167
41168
41169
41170
41171
41172
41173
41174
41175
41176
41177
41178
41179
41180
41181
41182
41183
41184
41185
41186
41187
41188
41189
41190
41191
41192
41193
41194
41195
41196
41197
41198
41199
41200
41201
41202
41203
41204
41205
41206
41207
41208
41209
41210
41211
41212
41213
41214
41215
41216
41217
41218
41219
41220
41221
41222
41223
41224
41225
41226
41227
41228
41229
41230
41231
41232
41233
41234
41235
41236
41237
41238
41239
41240
41241
41242
41243
41244
41245
41246
41247
41248
41249
41250
41251
41252
41253
41254
41255
41256
41257
41258
41259
41260
41261
41262
41263
41264
41265
41266
41267
41268
41269
41270
41271
41272
41273
41274
41275
41276
41277
41278
41279
41280
41281
41282
41283
41284
41285
41286
41287
41288
41289
41290
41291
41292
41293
41294
41295
41296
41297
41298
41299
41300
41301
41302
41303
41304
41305
41306
41307
41308
41309
41310
41311
41312
41313
41314
41315
41316
41317
41318
41319
41320
41321
41322
41323
41324
41325
41326
41327
41328
41329
41330
41331
41332
41333
41334
41335
41336
41337
41338
41339
41340
41341
41342
41343
41344
41345
41346
41347
41348
41349
41350
41351
41352
41353
41354
41355
41356
41357
41358
41359
41360
41361
41362
41363
41364
41365
41366
41367
41368
41369
41370
41371
41372
41373
41374
41375
41376
41377
41378
41379
41380
41381
41382
41383
41384
41385
41386
41387
41388
41389
41390
41391
41392
41393
41394
41395
41396
41397
41398
41399
41400
41401
41402
41403
41404
41405
41406
41407
41408
41409
41410
41411
41412
41413
41414
41415
41416
41417
41418
41419
41420
41421
41422
41423
41424
41425
41426
41427
41428
41429
41430
41431
41432
41433
41434
41435
41436
41437
41438
41439
41440
41441
41442
41443
41444
41445
41446
41447
41448
41449
41450
41451
41452
41453
41454
41455
41456
41457
41458
41459
41460
41461
41462
41463
41464
41465
41466
41467
41468
41469
41470
41471
41472
41473
41474
41475
41476
41477
41478
41479
41480
41481
41482
41483
41484
41485
41486
41487
41488
41489
41490
41491
41492
41493
41494
41495
41496
41497
41498
41499
41500
41501
41502
41503
41504
41505
41506
41507
41508
41509
41510
41511
41512
41513
41514
41515
41516
41517
41518
41519
41520
41521
41522
41523
41524
41525
41526
41527
41528
41529
41530
41531
41532
41533
41534
41535
41536
41537
41538
41539
41540
41541
41542
41543
41544
41545
41546
41547
41548
41549
41550
41551
41552
41553
41554
41555
41556
41557
41558
41559
41560
41561
41562
41563
41564
41565
41566
41567
41568
41569
41570
41571
41572
41573
41574
41575
41576
41577
41578
41579
41580
41581
41582
41583
41584
41585
41586
41587
41588
41589
41590
41591
41592
41593
41594
41595
41596
41597
41598
41599
41600
41601
41602
41603
41604
41605
41606
41607
41608
41609
41610
41611
41612
41613
41614
41615
41616
41617
41618
41619
41620
41621
41622
41623
41624
41625
41626
41627
41628
41629
41630
41631
41632
41633
41634
41635
41636
41637
41638
41639
41640
41641
41642
41643
41644
41645
41646
41647
41648
41649
41650
41651
41652
41653
41654
41655
41656
41657
41658
41659
41660
41661
41662
41663
41664
41665
41666
41667
41668
41669
41670
41671
41672
41673
41674
41675
41676
41677
41678
41679
41680
41681
41682
41683
41684
41685
41686
41687
41688
41689
41690
41691
41692
41693
41694
41695
41696
41697
41698
41699
41700
41701
41702
41703
41704
41705
41706
41707
41708
41709
41710
41711
41712
41713
41714
41715
41716
41717
41718
41719
41720
41721
41722
41723
41724
41725
41726
41727
41728
41729
41730
41731
41732
41733
41734
41735
41736
41737
41738
41739
41740
41741
41742
41743
41744
41745
41746
41747
41748
41749
41750
41751
41752
41753
41754
41755
41756
41757
41758
41759
41760
41761
41762
41763
41764
41765
41766
41767
41768
41769
41770
41771
41772
41773
41774
41775
41776
41777
41778
41779
41780
41781
41782
41783
41784
41785
41786
41787
41788
41789
41790
41791
41792
41793
41794
41795
41796
41797
41798
41799
41800
41801
41802
41803
41804
41805
41806
41807
41808
41809
41810
41811
41812
41813
41814
41815
41816
41817
41818
41819
41820
41821
41822
41823
41824
41825
41826
41827
41828
41829
41830
41831
41832
41833
41834
41835
41836
41837
41838
41839
41840
41841
41842
41843
41844
41845
41846
41847
41848
41849
41850
41851
41852
41853
41854
41855
41856
41857
41858
41859
41860
41861
41862
41863
41864
41865
41866
41867
41868
41869
41870
41871
41872
41873
41874
41875
41876
41877
41878
41879
41880
41881
41882
41883
41884
41885
41886
41887
41888
41889
41890
41891
41892
41893
41894
41895
41896
41897
41898
41899
41900
41901
41902
41903
41904
41905
41906
41907
41908
41909
41910
41911
41912
41913
41914
41915
41916
41917
41918
41919
41920
41921
41922
41923
41924
41925
41926
41927
41928
41929
41930
41931
41932
41933
41934
41935
41936
41937
41938
41939
41940
41941
41942
41943
41944
41945
41946
41947
41948
41949
41950
41951
41952
41953
41954
41955
41956
41957
41958
41959
41960
41961
41962
41963
41964
41965
41966
41967
41968
41969
41970
41971
41972
41973
41974
41975
41976
41977
41978
41979
41980
41981
41982
41983
41984
41985
41986
41987
41988
41989
41990
41991
41992
41993
41994
41995
41996
41997
41998
41999
42000
42001
42002
42003
42004
42005
42006
42007
42008
42009
42010
42011
42012
42013
42014
42015
42016
42017
42018
42019
42020
42021
42022
42023
42024
42025
42026
42027
42028
42029
42030
42031
42032
42033
42034
42035
42036
42037
42038
42039
42040
42041
42042
42043
42044
42045
42046
42047
42048
42049
42050
42051
42052
42053
42054
42055
42056
42057
42058
42059
42060
42061
42062
42063
42064
42065
42066
42067
42068
42069
42070
42071
42072
42073
42074
42075
42076
42077
42078
42079
42080
42081
42082
42083
42084
42085
42086
42087
42088
42089
42090
42091
42092
42093
42094
42095
42096
42097
42098
42099
42100
42101
42102
42103
42104
42105
42106
42107
42108
42109
42110
42111
42112
42113
42114
42115
42116
42117
42118
42119
42120
42121
42122
42123
42124
42125
42126
42127
42128
42129
42130
42131
42132
42133
42134
42135
42136
42137
42138
42139
42140
42141
42142
42143
42144
42145
42146
42147
42148
42149
42150
42151
42152
42153
42154
42155
42156
42157
42158
42159
42160
42161
42162
42163
42164
42165
42166
42167
42168
42169
42170
42171
42172
42173
42174
42175
42176
42177
42178
42179
42180
42181
42182
42183
42184
42185
42186
42187
42188
42189
42190
42191
42192
42193
42194
42195
42196
42197
42198
42199
42200
42201
42202
42203
42204
42205
42206
42207
42208
42209
42210
42211
42212
42213
42214
42215
42216
42217
42218
42219
42220
42221
42222
42223
42224
42225
42226
42227
42228
42229
42230
42231
42232
42233
42234
42235
42236
42237
42238
42239
42240
42241
42242
42243
42244
42245
42246
42247
42248
42249
42250
42251
42252
42253
42254
42255
42256
42257
42258
42259
42260
42261
42262
42263
42264
42265
42266
42267
42268
42269
42270
42271
42272
42273
42274
42275
42276
42277
42278
42279
42280
42281
42282
42283
42284
42285
42286
42287
42288
42289
42290
42291
42292
42293
42294
42295
42296
42297
42298
42299
42300
42301
42302
42303
42304
42305
42306
42307
42308
42309
42310
42311
42312
42313
42314
42315
42316
42317
42318
42319
42320
42321
42322
42323
42324
42325
42326
42327
42328
42329
42330
42331
42332
42333
42334
42335
42336
42337
42338
42339
42340
42341
42342
42343
42344
42345
42346
42347
42348
42349
42350
42351
42352
42353
42354
42355
42356
42357
42358
42359
42360
42361
42362
42363
42364
42365
42366
42367
42368
42369
42370
42371
42372
42373
42374
42375
42376
42377
42378
42379
42380
42381
42382
42383
42384
42385
42386
42387
42388
42389
42390
42391
42392
42393
42394
42395
42396
42397
42398
42399
42400
42401
42402
42403
42404
42405
42406
42407
42408
42409
42410
42411
42412
42413
42414
42415
42416
42417
42418
42419
42420
42421
42422
42423
42424
42425
42426
42427
42428
42429
42430
42431
42432
42433
42434
42435
42436
42437
42438
42439
42440
42441
42442
42443
42444
42445
42446
42447
42448
42449
42450
42451
42452
42453
42454
42455
42456
42457
42458
42459
42460
42461
42462
42463
42464
42465
42466
42467
42468
42469
42470
42471
42472
42473
42474
42475
42476
42477
42478
42479
42480
42481
42482
42483
42484
42485
42486
42487
42488
42489
42490
42491
42492
42493
42494
42495
42496
42497
42498
42499
42500
42501
42502
42503
42504
42505
42506
42507
42508
42509
42510
42511
42512
42513
42514
42515
42516
42517
42518
42519
42520
42521
42522
42523
42524
42525
42526
42527
42528
42529
42530
42531
42532
42533
42534
42535
42536
42537
42538
42539
42540
42541
42542
42543
42544
42545
42546
42547
42548
42549
42550
42551
42552
42553
42554
42555
42556
42557
42558
42559
42560
42561
42562
42563
42564
42565
42566
42567
42568
42569
42570
42571
42572
42573
42574
42575
42576
42577
42578
42579
42580
42581
42582
42583
42584
42585
42586
42587
42588
42589
42590
42591
42592
42593
42594
42595
42596
42597
42598
42599
42600
42601
42602
42603
42604
42605
42606
42607
42608
42609
42610
42611
42612
42613
42614
42615
42616
42617
42618
42619
42620
42621
42622
42623
42624
42625
42626
42627
42628
42629
42630
42631
42632
42633
42634
42635
42636
42637
42638
42639
42640
42641
42642
42643
42644
42645
42646
42647
42648
42649
42650
42651
42652
42653
42654
42655
42656
42657
42658
42659
42660
42661
42662
42663
42664
42665
42666
42667
42668
42669
42670
42671
42672
42673
42674
42675
42676
42677
42678
42679
42680
42681
42682
42683
42684
42685
42686
42687
42688
42689
42690
42691
42692
42693
42694
42695
42696
42697
42698
42699
42700
42701
42702
42703
42704
42705
42706
42707
42708
42709
42710
42711
42712
42713
42714
42715
42716
42717
42718
42719
42720
42721
42722
42723
42724
42725
42726
42727
42728
42729
42730
42731
42732
42733
42734
42735
42736
42737
42738
42739
42740
42741
42742
42743
42744
42745
42746
42747
42748
42749
42750
42751
42752
42753
42754
42755
42756
42757
42758
42759
42760
42761
42762
42763
42764
42765
42766
42767
42768
42769
42770
42771
42772
42773
42774
42775
42776
42777
42778
42779
42780
42781
42782
42783
42784
42785
42786
42787
42788
42789
42790
42791
42792
42793
42794
42795
42796
42797
42798
42799
42800
42801
42802
42803
42804
42805
42806
42807
42808
42809
42810
42811
42812
42813
42814
42815
42816
42817
42818
42819
42820
42821
42822
42823
42824
42825
42826
42827
42828
42829
42830
42831
42832
42833
42834
42835
42836
42837
42838
42839
42840
42841
42842
42843
42844
42845
42846
42847
42848
42849
42850
42851
42852
42853
42854
42855
42856
42857
42858
42859
42860
42861
42862
42863
42864
42865
42866
42867
42868
42869
42870
42871
42872
42873
42874
42875
42876
42877
42878
42879
42880
42881
42882
42883
42884
42885
42886
42887
42888
42889
42890
42891
42892
42893
42894
42895
42896
42897
42898
42899
42900
42901
42902
42903
42904
42905
42906
42907
42908
42909
42910
42911
42912
42913
42914
42915
42916
42917
42918
42919
42920
42921
42922
42923
42924
42925
42926
42927
42928
42929
42930
42931
42932
42933
42934
42935
42936
42937
42938
42939
42940
42941
42942
42943
42944
42945
42946
42947
42948
42949
42950
42951
42952
42953
42954
42955
42956
42957
42958
42959
42960
42961
42962
42963
42964
42965
42966
42967
42968
42969
42970
42971
42972
42973
42974
42975
42976
42977
42978
42979
42980
42981
42982
42983
42984
42985
42986
42987
42988
42989
42990
42991
42992
42993
42994
42995
42996
42997
42998
42999
43000
43001
43002
43003
43004
43005
43006
43007
43008
43009
43010
43011
43012
43013
43014
43015
43016
43017
43018
43019
43020
43021
43022
43023
43024
43025
43026
43027
43028
43029
43030
43031
43032
43033
43034
43035
43036
43037
43038
43039
43040
43041
43042
43043
43044
43045
43046
43047
43048
43049
43050
43051
43052
43053
43054
43055
43056
43057
43058
43059
43060
43061
43062
43063
43064
43065
43066
43067
43068
43069
43070
43071
43072
43073
43074
43075
43076
43077
43078
43079
43080
43081
43082
43083
43084
43085
43086
43087
43088
43089
43090
43091
43092
43093
43094
43095
43096
43097
43098
43099
43100
43101
43102
43103
43104
43105
43106
43107
43108
43109
43110
43111
43112
43113
43114
43115
43116
43117
43118
43119
43120
43121
43122
43123
43124
43125
43126
43127
43128
43129
43130
43131
43132
43133
43134
43135
43136
43137
43138
43139
43140
43141
43142
43143
43144
43145
43146
43147
43148
43149
43150
43151
43152
43153
43154
43155
43156
43157
43158
43159
43160
43161
43162
43163
43164
43165
43166
43167
43168
43169
43170
43171
43172
43173
43174
43175
43176
43177
43178
43179
43180
43181
43182
43183
43184
43185
43186
43187
43188
43189
43190
43191
43192
43193
43194
43195
43196
43197
43198
43199
43200
43201
43202
43203
43204
43205
43206
43207
43208
43209
43210
43211
43212
43213
43214
43215
43216
43217
43218
43219
43220
43221
43222
43223
43224
43225
43226
43227
43228
43229
43230
43231
43232
43233
43234
43235
43236
43237
43238
43239
43240
43241
43242
43243
43244
43245
43246
43247
43248
43249
43250
43251
43252
43253
43254
43255
43256
43257
43258
43259
43260
43261
43262
43263
43264
43265
43266
43267
43268
43269
43270
43271
43272
43273
43274
43275
43276
43277
43278
43279
43280
43281
43282
43283
43284
43285
43286
43287
43288
43289
43290
43291
43292
43293
43294
43295
43296
43297
43298
43299
43300
43301
43302
43303
43304
43305
43306
43307
43308
43309
43310
43311
43312
43313
43314
43315
43316
43317
43318
43319
43320
43321
43322
43323
43324
43325
43326
43327
43328
43329
43330
43331
43332
43333
43334
43335
43336
43337
43338
43339
43340
43341
43342
43343
43344
43345
43346
43347
43348
43349
43350
43351
43352
43353
43354
43355
43356
43357
43358
43359
43360
43361
43362
43363
43364
43365
43366
43367
43368
43369
43370
43371
43372
43373
43374
43375
43376
43377
43378
43379
43380
43381
43382
43383
43384
43385
43386
43387
43388
43389
43390
43391
43392
43393
43394
43395
43396
43397
43398
43399
43400
43401
43402
43403
43404
43405
43406
43407
43408
43409
43410
43411
43412
43413
43414
43415
43416
43417
43418
43419
43420
43421
43422
43423
43424
43425
43426
43427
43428
43429
43430
43431
43432
43433
43434
43435
43436
43437
43438
43439
43440
43441
43442
43443
43444
43445
43446
43447
43448
43449
43450
43451
43452
43453
43454
43455
43456
43457
43458
43459
43460
43461
43462
43463
43464
43465
43466
43467
43468
43469
43470
43471
43472
43473
43474
43475
43476
43477
43478
43479
43480
43481
43482
43483
43484
43485
43486
43487
43488
43489
43490
43491
43492
43493
43494
43495
43496
43497
43498
43499
43500
43501
43502
43503
43504
43505
43506
43507
43508
43509
43510
43511
43512
43513
43514
43515
43516
43517
43518
43519
43520
43521
43522
43523
43524
43525
43526
43527
43528
43529
43530
43531
43532
43533
43534
43535
43536
43537
43538
43539
43540
43541
43542
43543
43544
43545
43546
43547
43548
43549
43550
43551
43552
43553
43554
43555
43556
43557
43558
43559
43560
43561
43562
43563
43564
43565
43566
43567
43568
43569
43570
43571
43572
43573
43574
43575
43576
43577
43578
43579
43580
43581
43582
43583
43584
43585
43586
43587
43588
43589
43590
43591
43592
43593
43594
43595
43596
43597
43598
43599
43600
43601
43602
43603
43604
43605
43606
43607
43608
43609
43610
43611
43612
43613
43614
43615
43616
43617
43618
43619
43620
43621
43622
43623
43624
43625
43626
43627
43628
43629
43630
43631
43632
43633
43634
43635
43636
43637
43638
43639
43640
43641
43642
43643
43644
43645
43646
43647
43648
43649
43650
43651
43652
43653
43654
43655
43656
43657
43658
43659
43660
43661
43662
43663
43664
43665
43666
43667
43668
43669
43670
43671
43672
43673
43674
43675
43676
43677
43678
43679
43680
43681
43682
43683
43684
43685
43686
43687
43688
43689
43690
43691
43692
43693
43694
43695
43696
43697
43698
43699
43700
43701
43702
43703
43704
43705
43706
43707
43708
43709
43710
43711
43712
43713
43714
43715
43716
43717
43718
43719
43720
43721
43722
43723
43724
43725
43726
43727
43728
43729
43730
43731
43732
43733
43734
43735
43736
43737
43738
43739
43740
43741
43742
43743
43744
43745
43746
43747
43748
43749
43750
43751
43752
43753
43754
43755
43756
43757
43758
43759
43760
43761
43762
43763
43764
43765
43766
43767
43768
43769
43770
43771
43772
43773
43774
43775
43776
43777
43778
43779
43780
43781
43782
43783
43784
43785
43786
43787
43788
43789
43790
43791
43792
43793
43794
43795
43796
43797
43798
43799
43800
43801
43802
43803
43804
43805
43806
43807
43808
43809
43810
43811
43812
43813
43814
43815
43816
43817
43818
43819
43820
43821
43822
43823
43824
43825
43826
43827
43828
43829
43830
43831
43832
43833
43834
43835
43836
43837
43838
43839
43840
43841
43842
43843
43844
43845
43846
43847
43848
43849
43850
43851
43852
43853
43854
43855
43856
43857
43858
43859
43860
43861
43862
43863
43864
43865
43866
43867
43868
43869
43870
43871
43872
43873
43874
43875
43876
43877
43878
43879
43880
43881
43882
43883
43884
43885
43886
43887
43888
43889
43890
43891
43892
43893
43894
43895
43896
43897
43898
43899
43900
43901
43902
43903
43904
43905
43906
43907
43908
43909
43910
43911
43912
43913
43914
43915
43916
43917
43918
43919
43920
43921
43922
43923
43924
43925
43926
43927
43928
43929
43930
43931
43932
43933
43934
43935
43936
43937
43938
43939
43940
43941
43942
43943
43944
43945
43946
43947
43948
43949
43950
43951
43952
43953
43954
43955
43956
43957
43958
43959
43960
43961
43962
43963
43964
43965
43966
43967
43968
43969
43970
43971
43972
43973
43974
43975
43976
43977
43978
43979
43980
43981
43982
43983
43984
43985
43986
43987
43988
43989
43990
43991
43992
43993
43994
43995
43996
43997
43998
43999
44000
44001
44002
44003
44004
44005
44006
44007
44008
44009
44010
44011
44012
44013
44014
44015
44016
44017
44018
44019
44020
44021
44022
44023
44024
44025
44026
44027
44028
44029
44030
44031
44032
44033
44034
44035
44036
44037
44038
44039
44040
44041
44042
44043
44044
44045
44046
44047
44048
44049
44050
44051
44052
44053
44054
44055
44056
44057
44058
44059
44060
44061
44062
44063
44064
44065
44066
44067
44068
44069
44070
44071
44072
44073
44074
44075
44076
44077
44078
44079
44080
44081
44082
44083
44084
44085
44086
44087
44088
44089
44090
44091
44092
44093
44094
44095
44096
44097
44098
44099
44100
44101
44102
44103
44104
44105
44106
44107
44108
44109
44110
44111
44112
44113
44114
44115
44116
44117
44118
44119
44120
44121
44122
44123
44124
44125
44126
44127
44128
44129
44130
44131
44132
44133
44134
44135
44136
44137
44138
44139
44140
44141
44142
44143
44144
44145
44146
44147
44148
44149
44150
44151
44152
44153
44154
44155
44156
44157
44158
44159
44160
44161
44162
44163
44164
44165
44166
44167
44168
44169
44170
44171
44172
44173
44174
44175
44176
44177
44178
44179
44180
44181
44182
44183
44184
44185
44186
44187
44188
44189
44190
44191
44192
44193
44194
44195
44196
44197
44198
44199
44200
44201
44202
44203
44204
44205
44206
44207
44208
44209
44210
44211
44212
44213
44214
44215
44216
44217
44218
44219
44220
44221
44222
44223
44224
44225
44226
44227
44228
44229
44230
44231
44232
44233
44234
44235
44236
44237
44238
44239
44240
44241
44242
44243
44244
44245
44246
44247
44248
44249
44250
44251
44252
44253
44254
44255
44256
44257
44258
44259
44260
44261
44262
44263
44264
44265
44266
44267
44268
44269
44270
44271
44272
44273
44274
44275
44276
44277
44278
44279
44280
44281
44282
44283
44284
44285
44286
44287
44288
44289
44290
44291
44292
44293
44294
44295
44296
44297
44298
44299
44300
44301
44302
44303
44304
44305
44306
44307
44308
44309
44310
44311
44312
44313
44314
44315
44316
44317
44318
44319
44320
44321
44322
44323
44324
44325
44326
44327
44328
44329
44330
44331
44332
44333
44334
44335
44336
44337
44338
44339
44340
44341
44342
44343
44344
44345
44346
44347
44348
44349
44350
44351
44352
44353
44354
44355
44356
44357
44358
44359
44360
44361
44362
44363
44364
44365
44366
44367
44368
44369
44370
44371
44372
44373
44374
44375
44376
44377
44378
44379
44380
44381
44382
44383
44384
44385
44386
44387
44388
44389
44390
44391
44392
44393
44394
44395
44396
44397
44398
44399
44400
44401
44402
44403
44404
44405
44406
44407
44408
44409
44410
44411
44412
44413
44414
44415
44416
44417
44418
44419
44420
44421
44422
44423
44424
44425
44426
44427
44428
44429
44430
44431
44432
44433
44434
44435
44436
44437
44438
44439
44440
44441
44442
44443
44444
44445
44446
44447
44448
44449
44450
44451
44452
44453
44454
44455
44456
44457
44458
44459
44460
44461
44462
44463
44464
44465
44466
44467
44468
44469
44470
44471
44472
44473
44474
44475
44476
44477
44478
44479
44480
44481
44482
44483
44484
44485
44486
44487
44488
44489
44490
44491
44492
44493
44494
44495
44496
44497
44498
44499
44500
44501
44502
44503
44504
44505
44506
44507
44508
44509
44510
44511
44512
44513
44514
44515
44516
44517
44518
44519
44520
44521
44522
44523
44524
44525
44526
44527
44528
44529
44530
44531
44532
44533
44534
44535
44536
44537
44538
44539
44540
44541
44542
44543
44544
44545
44546
44547
44548
44549
44550
44551
44552
44553
44554
44555
44556
44557
44558
44559
44560
44561
44562
44563
44564
44565
44566
44567
44568
44569
44570
44571
44572
44573
44574
44575
44576
44577
44578
44579
44580
44581
44582
44583
44584
44585
44586
44587
44588
44589
44590
44591
44592
44593
44594
44595
44596
44597
44598
44599
44600
44601
44602
44603
44604
44605
44606
44607
44608
44609
44610
44611
44612
44613
44614
44615
44616
44617
44618
44619
44620
44621
44622
44623
44624
44625
44626
44627
44628
44629
44630
44631
44632
44633
44634
44635
44636
44637
44638
44639
44640
44641
44642
44643
44644
44645
44646
44647
44648
44649
44650
44651
44652
44653
44654
44655
44656
44657
44658
44659
44660
44661
44662
44663
44664
44665
44666
44667
44668
44669
44670
44671
44672
44673
44674
44675
44676
44677
44678
44679
44680
44681
44682
44683
44684
44685
44686
44687
44688
44689
44690
44691
44692
44693
44694
44695
44696
44697
44698
44699
44700
44701
44702
44703
44704
44705
44706
44707
44708
44709
44710
44711
44712
44713
44714
44715
44716
44717
44718
44719
44720
44721
44722
44723
44724
44725
44726
44727
44728
44729
44730
44731
44732
44733
44734
44735
44736
44737
44738
44739
44740
44741
44742
44743
44744
44745
44746
44747
44748
44749
44750
44751
44752
44753
44754
44755
44756
44757
44758
44759
44760
44761
44762
44763
44764
44765
44766
44767
44768
44769
44770
44771
44772
44773
44774
44775
44776
44777
44778
44779
44780
44781
44782
44783
44784
44785
44786
44787
44788
44789
44790
44791
44792
44793
44794
44795
44796
44797
44798
44799
44800
44801
44802
44803
44804
44805
44806
44807
44808
44809
44810
44811
44812
44813
44814
44815
44816
44817
44818
44819
44820
44821
44822
44823
44824
44825
44826
44827
44828
44829
44830
44831
44832
44833
44834
44835
44836
44837
44838
44839
44840
44841
44842
44843
44844
44845
44846
44847
44848
44849
44850
44851
44852
44853
44854
44855
44856
44857
44858
44859
44860
44861
44862
44863
44864
44865
44866
44867
44868
44869
44870
44871
44872
44873
44874
44875
44876
44877
44878
44879
44880
44881
44882
44883
44884
44885
44886
44887
44888
44889
44890
44891
44892
44893
44894
44895
44896
44897
44898
44899
44900
44901
44902
44903
44904
44905
44906
44907
44908
44909
44910
44911
44912
44913
44914
44915
44916
44917
44918
44919
44920
44921
44922
44923
44924
44925
44926
44927
44928
44929
44930
44931
44932
44933
44934
44935
44936
44937
44938
44939
44940
44941
44942
44943
44944
44945
44946
44947
44948
44949
44950
44951
44952
44953
44954
44955
44956
44957
44958
44959
44960
44961
44962
44963
44964
44965
44966
44967
44968
44969
44970
44971
44972
44973
44974
44975
44976
44977
44978
44979
44980
44981
44982
44983
44984
44985
44986
44987
44988
44989
44990
44991
44992
44993
44994
44995
44996
44997
44998
44999
45000
45001
45002
45003
45004
45005
45006
45007
45008
45009
45010
45011
45012
45013
45014
45015
45016
45017
45018
45019
45020
45021
45022
45023
45024
45025
45026
45027
45028
45029
45030
45031
45032
45033
45034
45035
45036
45037
45038
45039
45040
45041
45042
45043
45044
45045
45046
45047
45048
45049
45050
45051
45052
45053
45054
45055
45056
45057
45058
45059
45060
45061
45062
45063
45064
45065
45066
45067
45068
45069
45070
45071
45072
45073
45074
45075
45076
45077
45078
45079
45080
45081
45082
45083
45084
45085
45086
45087
45088
45089
45090
45091
45092
45093
45094
45095
45096
45097
45098
45099
45100
45101
45102
45103
45104
45105
45106
45107
45108
45109
45110
45111
45112
45113
45114
45115
45116
45117
45118
45119
45120
45121
45122
45123
45124
45125
45126
45127
45128
45129
45130
45131
45132
45133
45134
45135
45136
45137
45138
45139
45140
45141
45142
45143
45144
45145
45146
45147
45148
45149
45150
45151
45152
45153
45154
45155
45156
45157
45158
45159
45160
45161
45162
45163
45164
45165
45166
45167
45168
45169
45170
45171
45172
45173
45174
45175
45176
45177
45178
45179
45180
45181
45182
45183
45184
45185
45186
45187
45188
45189
45190
45191
45192
45193
45194
45195
45196
45197
45198
45199
45200
45201
45202
45203
45204
45205
45206
45207
45208
45209
45210
45211
45212
45213
45214
45215
45216
45217
45218
45219
45220
45221
45222
45223
45224
45225
45226
45227
45228
45229
45230
45231
45232
45233
45234
45235
45236
45237
45238
45239
45240
45241
45242
45243
45244
45245
45246
45247
45248
45249
45250
45251
45252
45253
45254
45255
45256
45257
45258
45259
45260
45261
45262
45263
45264
45265
45266
45267
45268
45269
45270
45271
45272
45273
45274
45275
45276
45277
45278
45279
45280
45281
45282
45283
45284
45285
45286
45287
45288
45289
45290
45291
45292
45293
45294
45295
45296
45297
45298
45299
45300
45301
45302
45303
45304
45305
45306
45307
45308
45309
45310
45311
45312
45313
45314
45315
45316
45317
45318
45319
45320
45321
45322
45323
45324
45325
45326
45327
45328
45329
45330
45331
45332
45333
45334
45335
45336
45337
45338
45339
45340
45341
45342
45343
45344
45345
45346
45347
45348
45349
45350
45351
45352
45353
45354
45355
45356
45357
45358
45359
45360
45361
45362
45363
45364
45365
45366
45367
45368
45369
45370
45371
45372
45373
45374
45375
45376
45377
45378
45379
45380
45381
45382
45383
45384
45385
45386
45387
45388
45389
45390
45391
45392
45393
45394
45395
45396
45397
45398
45399
45400
45401
45402
45403
45404
45405
45406
45407
45408
45409
45410
45411
45412
45413
45414
45415
45416
45417
45418
45419
45420
45421
45422
45423
45424
45425
45426
45427
45428
45429
45430
45431
45432
45433
45434
45435
45436
45437
45438
45439
45440
45441
45442
45443
45444
45445
45446
45447
45448
45449
45450
45451
45452
45453
45454
45455
45456
45457
45458
45459
45460
45461
45462
45463
45464
45465
45466
45467
45468
45469
45470
45471
45472
45473
45474
45475
45476
45477
45478
45479
45480
45481
45482
45483
45484
45485
45486
45487
45488
45489
45490
45491
45492
45493
45494
45495
45496
45497
45498
45499
45500
45501
45502
45503
45504
45505
45506
45507
45508
45509
45510
45511
45512
45513
45514
45515
45516
45517
45518
45519
45520
45521
45522
45523
45524
45525
45526
45527
45528
45529
45530
45531
45532
45533
45534
45535
45536
45537
45538
45539
45540
45541
45542
45543
45544
45545
45546
45547
45548
45549
45550
45551
45552
45553
45554
45555
45556
45557
45558
45559
45560
45561
45562
45563
45564
45565
45566
45567
45568
45569
45570
45571
45572
45573
45574
45575
45576
45577
45578
45579
45580
45581
45582
45583
45584
45585
45586
45587
45588
45589
45590
45591
45592
45593
45594
45595
45596
45597
45598
45599
45600
45601
45602
45603
45604
45605
45606
45607
45608
45609
45610
45611
45612
45613
45614
45615
45616
45617
45618
45619
45620
45621
45622
45623
45624
45625
45626
45627
45628
45629
45630
45631
45632
45633
45634
45635
45636
45637
45638
45639
45640
45641
45642
45643
45644
45645
45646
45647
45648
45649
45650
45651
45652
45653
45654
45655
45656
45657
45658
45659
45660
45661
45662
45663
45664
45665
45666
45667
45668
45669
45670
45671
45672
45673
45674
45675
45676
45677
45678
45679
45680
45681
45682
45683
45684
45685
45686
45687
45688
45689
45690
45691
45692
45693
45694
45695
45696
45697
45698
45699
45700
45701
45702
45703
45704
45705
45706
45707
45708
45709
45710
45711
45712
45713
45714
45715
45716
45717
45718
45719
45720
45721
45722
45723
45724
45725
45726
45727
45728
45729
45730
45731
45732
45733
45734
45735
45736
45737
45738
45739
45740
45741
45742
45743
45744
45745
45746
45747
45748
45749
45750
45751
45752
45753
45754
45755
45756
45757
45758
45759
45760
45761
45762
45763
45764
45765
45766
45767
45768
45769
45770
45771
45772
45773
45774
45775
45776
45777
45778
45779
45780
45781
45782
45783
45784
45785
45786
45787
45788
45789
45790
45791
45792
45793
45794
45795
45796
45797
45798
45799
45800
45801
45802
45803
45804
45805
45806
45807
45808
45809
45810
45811
45812
45813
45814
45815
45816
45817
45818
45819
45820
45821
45822
45823
45824
45825
45826
45827
45828
45829
45830
45831
45832
45833
45834
45835
45836
45837
45838
45839
45840
45841
45842
45843
45844
45845
45846
45847
45848
45849
45850
45851
45852
45853
45854
45855
45856
45857
45858
45859
45860
45861
45862
45863
45864
45865
45866
45867
45868
45869
45870
45871
45872
45873
45874
45875
45876
45877
45878
45879
45880
45881
45882
45883
45884
45885
45886
45887
45888
45889
45890
45891
45892
45893
45894
45895
45896
45897
45898
45899
45900
45901
45902
45903
45904
45905
45906
45907
45908
45909
45910
45911
45912
45913
45914
45915
45916
45917
45918
45919
45920
45921
45922
45923
45924
45925
45926
45927
45928
45929
45930
45931
45932
45933
45934
45935
45936
45937
45938
45939
45940
45941
45942
45943
45944
45945
45946
45947
45948
45949
45950
45951
45952
45953
45954
45955
45956
45957
45958
45959
45960
45961
45962
45963
45964
45965
45966
45967
45968
45969
45970
45971
45972
45973
45974
45975
45976
45977
45978
45979
45980
45981
45982
45983
45984
45985
45986
45987
45988
45989
45990
45991
45992
45993
45994
45995
45996
45997
45998
45999
46000
46001
46002
46003
46004
46005
46006
46007
46008
46009
46010
46011
46012
46013
46014
46015
46016
46017
46018
46019
46020
46021
46022
46023
46024
46025
46026
46027
46028
46029
46030
46031
46032
46033
46034
46035
46036
46037
46038
46039
46040
46041
46042
46043
46044
46045
46046
46047
46048
46049
46050
46051
46052
46053
46054
46055
46056
46057
46058
46059
46060
46061
46062
46063
46064
46065
46066
46067
46068
46069
46070
46071
46072
46073
46074
46075
46076
46077
46078
46079
46080
46081
46082
46083
46084
46085
46086
46087
46088
46089
46090
46091
46092
46093
46094
46095
46096
46097
46098
46099
46100
46101
46102
46103
46104
46105
46106
46107
46108
46109
46110
46111
46112
46113
46114
46115
46116
46117
46118
46119
46120
46121
46122
46123
46124
46125
46126
46127
46128
46129
46130
46131
46132
46133
46134
46135
46136
46137
46138
46139
46140
46141
46142
46143
46144
46145
46146
46147
46148
46149
46150
46151
46152
46153
46154
46155
46156
46157
46158
46159
46160
46161
46162
46163
46164
46165
46166
46167
46168
46169
46170
46171
46172
46173
46174
46175
46176
46177
46178
46179
46180
46181
46182
46183
46184
46185
46186
46187
46188
46189
46190
46191
46192
46193
46194
46195
46196
46197
46198
46199
46200
46201
46202
46203
46204
46205
46206
46207
46208
46209
46210
46211
46212
46213
46214
46215
46216
46217
46218
46219
46220
46221
46222
46223
46224
46225
46226
46227
46228
46229
46230
46231
46232
46233
46234
46235
46236
46237
46238
46239
46240
46241
46242
46243
46244
46245
46246
46247
46248
46249
46250
46251
46252
46253
46254
46255
46256
46257
46258
46259
46260
46261
46262
46263
46264
46265
46266
46267
46268
46269
46270
46271
46272
46273
46274
46275
46276
46277
46278
46279
46280
46281
46282
46283
46284
46285
46286
46287
46288
46289
46290
46291
46292
46293
46294
46295
46296
46297
46298
46299
46300
46301
46302
46303
46304
46305
46306
46307
46308
46309
46310
46311
46312
46313
46314
46315
46316
46317
46318
46319
46320
46321
46322
46323
46324
46325
46326
46327
46328
46329
46330
46331
46332
46333
46334
46335
46336
46337
46338
46339
46340
46341
46342
46343
46344
46345
46346
46347
46348
46349
46350
46351
46352
46353
46354
46355
46356
46357
46358
46359
46360
46361
46362
46363
46364
46365
46366
46367
46368
46369
46370
46371
46372
46373
46374
46375
46376
46377
46378
46379
46380
46381
46382
46383
46384
46385
46386
46387
46388
46389
46390
46391
46392
46393
46394
46395
46396
46397
46398
46399
46400
46401
46402
46403
46404
46405
46406
46407
46408
46409
46410
46411
46412
46413
46414
46415
46416
46417
46418
46419
46420
46421
46422
46423
46424
46425
46426
46427
46428
46429
46430
46431
46432
46433
46434
46435
46436
46437
46438
46439
46440
46441
46442
46443
46444
46445
46446
46447
46448
46449
46450
46451
46452
46453
46454
46455
46456
46457
46458
46459
46460
46461
46462
46463
46464
46465
46466
46467
46468
46469
46470
46471
46472
46473
46474
46475
46476
46477
46478
46479
46480
46481
46482
46483
46484
46485
46486
46487
46488
46489
46490
46491
46492
46493
46494
46495
46496
46497
46498
46499
46500
46501
46502
46503
46504
46505
46506
46507
46508
46509
46510
46511
46512
46513
46514
46515
46516
46517
46518
46519
46520
46521
46522
46523
46524
46525
46526
46527
46528
46529
46530
46531
46532
46533
46534
46535
46536
46537
46538
46539
46540
46541
46542
46543
46544
46545
46546
46547
46548
46549
46550
46551
46552
46553
46554
46555
46556
46557
46558
46559
46560
46561
46562
46563
46564
46565
46566
46567
46568
46569
46570
46571
46572
46573
46574
46575
46576
46577
46578
46579
46580
46581
46582
46583
46584
46585
46586
46587
46588
46589
46590
46591
46592
46593
46594
46595
46596
46597
46598
46599
46600
46601
46602
46603
46604
46605
46606
46607
46608
46609
46610
46611
46612
46613
46614
46615
46616
46617
46618
46619
46620
46621
46622
46623
46624
46625
46626
46627
46628
46629
46630
46631
46632
46633
46634
46635
46636
46637
46638
46639
46640
46641
46642
46643
46644
46645
46646
46647
46648
46649
46650
46651
46652
46653
46654
46655
46656
46657
46658
46659
46660
46661
46662
46663
46664
46665
46666
46667
46668
46669
46670
46671
46672
46673
46674
46675
46676
46677
46678
46679
46680
46681
46682
46683
46684
46685
46686
46687
46688
46689
46690
46691
46692
46693
46694
46695
46696
46697
46698
46699
46700
46701
46702
46703
46704
46705
46706
46707
46708
46709
46710
46711
46712
46713
46714
46715
46716
46717
46718
46719
46720
46721
46722
46723
46724
46725
46726
46727
46728
46729
46730
46731
46732
46733
46734
46735
46736
46737
46738
46739
46740
46741
46742
46743
46744
46745
46746
46747
46748
46749
46750
46751
46752
46753
46754
46755
46756
46757
46758
46759
46760
46761
46762
46763
46764
46765
46766
46767
46768
46769
46770
46771
46772
46773
46774
46775
46776
46777
46778
46779
46780
46781
46782
46783
46784
46785
46786
46787
46788
46789
46790
46791
46792
46793
46794
46795
46796
46797
46798
46799
46800
46801
46802
46803
46804
46805
46806
46807
46808
46809
46810
46811
46812
46813
46814
46815
46816
46817
46818
46819
46820
46821
46822
46823
46824
46825
46826
46827
46828
46829
46830
46831
46832
46833
46834
46835
46836
46837
46838
46839
46840
46841
46842
46843
46844
46845
46846
46847
46848
46849
46850
46851
46852
46853
46854
46855
46856
46857
46858
46859
46860
46861
46862
46863
46864
46865
46866
46867
46868
46869
46870
46871
46872
46873
46874
46875
46876
46877
46878
46879
46880
46881
46882
46883
46884
46885
46886
46887
46888
46889
46890
46891
46892
46893
46894
46895
46896
46897
46898
46899
46900
46901
46902
46903
46904
46905
46906
46907
46908
46909
46910
46911
46912
46913
46914
46915
46916
46917
46918
46919
46920
46921
46922
46923
46924
46925
46926
46927
46928
46929
46930
46931
46932
46933
46934
46935
46936
46937
46938
46939
46940
46941
46942
46943
46944
46945
46946
46947
46948
46949
46950
46951
46952
46953
46954
46955
46956
46957
46958
46959
46960
46961
46962
46963
46964
46965
46966
46967
46968
46969
46970
46971
46972
46973
46974
46975
46976
46977
46978
46979
46980
46981
46982
46983
46984
46985
46986
46987
46988
46989
46990
46991
46992
46993
46994
46995
46996
46997
46998
46999
47000
47001
47002
47003
47004
47005
47006
47007
47008
47009
47010
47011
47012
47013
47014
47015
47016
47017
47018
47019
47020
47021
47022
47023
47024
47025
47026
47027
47028
47029
47030
47031
47032
47033
47034
47035
47036
47037
47038
47039
47040
47041
47042
47043
47044
47045
47046
47047
47048
47049
47050
47051
47052
47053
47054
47055
47056
47057
47058
47059
47060
47061
47062
47063
47064
47065
47066
47067
47068
47069
47070
47071
47072
47073
47074
47075
47076
47077
47078
47079
47080
47081
47082
47083
47084
47085
47086
47087
47088
47089
47090
47091
47092
47093
47094
47095
47096
47097
47098
47099
47100
47101
47102
47103
47104
47105
47106
47107
47108
47109
47110
47111
47112
47113
47114
47115
47116
47117
47118
47119
47120
47121
47122
47123
47124
47125
47126
47127
47128
47129
47130
47131
47132
47133
47134
47135
47136
47137
47138
47139
47140
47141
47142
47143
47144
47145
47146
47147
47148
47149
47150
47151
47152
47153
47154
47155
47156
47157
47158
47159
47160
47161
47162
47163
47164
47165
47166
47167
47168
47169
47170
47171
47172
47173
47174
47175
47176
47177
47178
47179
47180
47181
47182
47183
47184
47185
47186
47187
47188
47189
47190
47191
47192
47193
47194
47195
47196
47197
47198
47199
47200
47201
47202
47203
47204
47205
47206
47207
47208
47209
47210
47211
47212
47213
47214
47215
47216
47217
47218
47219
47220
47221
47222
47223
47224
47225
47226
47227
47228
47229
47230
47231
47232
47233
47234
47235
47236
47237
47238
47239
47240
47241
47242
47243
47244
47245
47246
47247
47248
47249
47250
47251
47252
47253
47254
47255
47256
47257
47258
47259
47260
47261
47262
47263
47264
47265
47266
47267
47268
47269
47270
47271
47272
47273
47274
47275
47276
47277
47278
47279
47280
47281
47282
47283
47284
47285
47286
47287
47288
47289
47290
47291
47292
47293
47294
47295
47296
47297
47298
47299
47300
47301
47302
47303
47304
47305
47306
47307
47308
47309
47310
47311
47312
47313
47314
47315
47316
47317
47318
47319
47320
47321
47322
47323
47324
47325
47326
47327
47328
47329
47330
47331
47332
47333
47334
47335
47336
47337
47338
47339
47340
47341
47342
47343
47344
47345
47346
47347
47348
47349
47350
47351
47352
47353
47354
47355
47356
47357
47358
47359
47360
47361
47362
47363
47364
47365
47366
47367
47368
47369
47370
47371
47372
47373
47374
47375
47376
47377
47378
47379
47380
47381
47382
47383
47384
47385
47386
47387
47388
47389
47390
47391
47392
47393
47394
47395
47396
47397
47398
47399
47400
47401
47402
47403
47404
47405
47406
47407
47408
47409
47410
47411
47412
47413
47414
47415
47416
47417
47418
47419
47420
47421
47422
47423
47424
47425
47426
47427
47428
47429
47430
47431
47432
47433
47434
47435
47436
47437
47438
47439
47440
47441
47442
47443
47444
47445
47446
47447
47448
47449
47450
47451
47452
47453
47454
47455
47456
47457
47458
47459
47460
47461
47462
47463
47464
47465
47466
47467
47468
47469
47470
47471
47472
47473
47474
47475
47476
47477
47478
47479
47480
47481
47482
47483
47484
47485
47486
47487
47488
47489
47490
47491
47492
47493
47494
47495
47496
47497
47498
47499
47500
47501
47502
47503
47504
47505
47506
47507
47508
47509
47510
47511
47512
47513
47514
47515
47516
47517
47518
47519
47520
47521
47522
47523
47524
47525
47526
47527
47528
47529
47530
47531
47532
47533
47534
47535
47536
47537
47538
47539
47540
47541
47542
47543
47544
47545
47546
47547
47548
47549
47550
47551
47552
47553
47554
47555
47556
47557
47558
47559
47560
47561
47562
47563
47564
47565
47566
47567
47568
47569
47570
47571
47572
47573
47574
47575
47576
47577
47578
47579
47580
47581
47582
47583
47584
47585
47586
47587
47588
47589
47590
47591
47592
47593
47594
47595
47596
47597
47598
47599
47600
47601
47602
47603
47604
47605
47606
47607
47608
47609
47610
47611
47612
47613
47614
47615
47616
47617
47618
47619
47620
47621
47622
47623
47624
47625
47626
47627
47628
47629
47630
47631
47632
47633
47634
47635
47636
47637
47638
47639
47640
47641
47642
47643
47644
47645
47646
47647
47648
47649
47650
47651
47652
47653
47654
47655
47656
47657
47658
47659
47660
47661
47662
47663
47664
47665
47666
47667
47668
47669
47670
47671
47672
47673
47674
47675
47676
47677
47678
47679
47680
47681
47682
47683
47684
47685
47686
47687
47688
47689
47690
47691
47692
47693
47694
47695
47696
47697
47698
47699
47700
47701
47702
47703
47704
47705
47706
47707
47708
47709
47710
47711
47712
47713
47714
47715
47716
47717
47718
47719
47720
47721
47722
47723
47724
47725
47726
47727
47728
47729
47730
47731
47732
47733
47734
47735
47736
47737
47738
47739
47740
47741
47742
47743
47744
47745
47746
47747
47748
47749
47750
47751
47752
47753
47754
47755
47756
47757
47758
47759
47760
47761
47762
47763
47764
47765
47766
47767
47768
47769
47770
47771
47772
47773
47774
47775
47776
47777
47778
47779
47780
47781
47782
47783
47784
47785
47786
47787
47788
47789
47790
47791
47792
47793
47794
47795
47796
47797
47798
47799
47800
47801
47802
47803
47804
47805
47806
47807
47808
47809
47810
47811
47812
47813
47814
47815
47816
47817
47818
47819
47820
47821
47822
47823
47824
47825
47826
47827
47828
47829
47830
47831
47832
47833
47834
47835
47836
47837
47838
47839
47840
47841
47842
47843
47844
47845
47846
47847
47848
47849
47850
47851
47852
47853
47854
47855
47856
47857
47858
47859
47860
47861
47862
47863
47864
47865
47866
47867
47868
47869
47870
47871
47872
47873
47874
47875
47876
47877
47878
47879
47880
47881
47882
47883
47884
47885
47886
47887
47888
47889
47890
47891
47892
47893
47894
47895
47896
47897
47898
47899
47900
47901
47902
47903
47904
47905
47906
47907
47908
47909
47910
47911
47912
47913
47914
47915
47916
47917
47918
47919
47920
47921
47922
47923
47924
47925
47926
47927
47928
47929
47930
47931
47932
47933
47934
47935
47936
47937
47938
47939
47940
47941
47942
47943
47944
47945
47946
47947
47948
47949
47950
47951
47952
47953
47954
47955
47956
47957
47958
47959
47960
47961
47962
47963
47964
47965
47966
47967
47968
47969
47970
47971
47972
47973
47974
47975
47976
47977
47978
47979
47980
47981
47982
47983
47984
47985
47986
47987
47988
47989
47990
47991
47992
47993
47994
47995
47996
47997
47998
47999
48000
48001
48002
48003
48004
48005
48006
48007
48008
48009
48010
48011
48012
48013
48014
48015
48016
48017
48018
48019
48020
48021
48022
48023
48024
48025
48026
48027
48028
48029
48030
48031
48032
48033
48034
48035
48036
48037
48038
48039
48040
48041
48042
48043
48044
48045
48046
48047
48048
48049
48050
48051
48052
48053
48054
48055
48056
48057
48058
48059
48060
48061
48062
48063
48064
48065
48066
48067
48068
48069
48070
48071
48072
48073
48074
48075
48076
48077
48078
48079
48080
48081
48082
48083
48084
48085
48086
48087
48088
48089
48090
48091
48092
48093
48094
48095
48096
48097
48098
48099
48100
48101
48102
48103
48104
48105
48106
48107
48108
48109
48110
48111
48112
48113
48114
48115
48116
48117
48118
48119
48120
48121
48122
48123
48124
48125
48126
48127
48128
48129
48130
48131
48132
48133
48134
48135
48136
48137
48138
48139
48140
48141
48142
48143
48144
48145
48146
48147
48148
48149
48150
48151
48152
48153
48154
48155
48156
48157
48158
48159
48160
48161
48162
48163
48164
48165
48166
48167
48168
48169
48170
48171
48172
48173
48174
48175
48176
48177
48178
48179
48180
48181
48182
48183
48184
48185
48186
48187
48188
48189
48190
48191
48192
48193
48194
48195
48196
48197
48198
48199
48200
48201
48202
48203
48204
48205
48206
48207
48208
48209
48210
48211
48212
48213
48214
48215
48216
48217
48218
48219
48220
48221
48222
48223
48224
48225
48226
48227
48228
48229
48230
48231
48232
48233
48234
48235
48236
48237
48238
48239
48240
48241
48242
48243
48244
48245
48246
48247
48248
48249
48250
48251
48252
48253
48254
48255
48256
48257
48258
48259
48260
48261
48262
48263
48264
48265
48266
48267
48268
48269
48270
48271
48272
48273
48274
48275
48276
48277
48278
48279
48280
48281
48282
48283
48284
48285
48286
48287
48288
48289
48290
48291
48292
48293
48294
48295
48296
48297
48298
48299
48300
48301
48302
48303
48304
48305
48306
48307
48308
48309
48310
48311
48312
48313
48314
48315
48316
48317
48318
48319
48320
48321
48322
48323
48324
48325
48326
48327
48328
48329
48330
48331
48332
48333
48334
48335
48336
48337
48338
48339
48340
48341
48342
48343
48344
48345
48346
48347
48348
48349
48350
48351
48352
48353
48354
48355
48356
48357
48358
48359
48360
48361
48362
48363
48364
48365
48366
48367
48368
48369
48370
48371
48372
48373
48374
48375
48376
48377
48378
48379
48380
48381
48382
48383
48384
48385
48386
48387
48388
48389
48390
48391
48392
48393
48394
48395
48396
48397
48398
48399
48400
48401
48402
48403
48404
48405
48406
48407
48408
48409
48410
48411
48412
48413
48414
48415
48416
48417
48418
48419
48420
48421
48422
48423
48424
48425
48426
48427
48428
48429
48430
48431
48432
48433
48434
48435
48436
48437
48438
48439
48440
48441
48442
48443
48444
48445
48446
48447
48448
48449
48450
48451
48452
48453
48454
48455
48456
48457
48458
48459
48460
48461
48462
48463
48464
48465
48466
48467
48468
48469
48470
48471
48472
48473
48474
48475
48476
48477
48478
48479
48480
48481
48482
48483
48484
48485
48486
48487
48488
48489
48490
48491
48492
48493
48494
48495
48496
48497
48498
48499
48500
48501
48502
48503
48504
48505
48506
48507
48508
48509
48510
48511
48512
48513
48514
48515
48516
48517
48518
48519
48520
48521
48522
48523
48524
48525
48526
48527
48528
48529
48530
48531
48532
48533
48534
48535
48536
48537
48538
48539
48540
48541
48542
48543
48544
48545
48546
48547
48548
48549
48550
48551
48552
48553
48554
48555
48556
48557
48558
48559
48560
48561
48562
48563
48564
48565
48566
48567
48568
48569
48570
48571
48572
48573
48574
48575
48576
48577
48578
48579
48580
48581
48582
48583
48584
48585
48586
48587
48588
48589
48590
48591
48592
48593
48594
48595
48596
48597
48598
48599
48600
48601
48602
48603
48604
48605
48606
48607
48608
48609
48610
48611
48612
48613
48614
48615
48616
48617
48618
48619
48620
48621
48622
48623
48624
48625
48626
48627
48628
48629
48630
48631
48632
48633
48634
48635
48636
48637
48638
48639
48640
48641
48642
48643
48644
48645
48646
48647
48648
48649
48650
48651
48652
48653
48654
48655
48656
48657
48658
48659
48660
48661
48662
48663
48664
48665
48666
48667
48668
48669
48670
48671
48672
48673
48674
48675
48676
48677
48678
48679
48680
48681
48682
48683
48684
48685
48686
48687
48688
48689
48690
48691
48692
48693
48694
48695
48696
48697
48698
48699
48700
48701
48702
48703
48704
48705
48706
48707
48708
48709
48710
48711
48712
48713
48714
48715
48716
48717
48718
48719
48720
48721
48722
48723
48724
48725
48726
48727
48728
48729
48730
48731
48732
48733
48734
48735
48736
48737
48738
48739
48740
48741
48742
48743
48744
48745
48746
48747
48748
48749
48750
48751
48752
48753
48754
48755
48756
48757
48758
48759
48760
48761
48762
48763
48764
48765
48766
48767
48768
48769
48770
48771
48772
48773
48774
48775
48776
48777
48778
48779
48780
48781
48782
48783
48784
48785
48786
48787
48788
48789
48790
48791
48792
48793
48794
48795
48796
48797
48798
48799
48800
48801
48802
48803
48804
48805
48806
48807
48808
48809
48810
48811
48812
48813
48814
48815
48816
48817
48818
48819
48820
48821
48822
48823
48824
48825
48826
48827
48828
48829
48830
48831
48832
48833
48834
48835
48836
48837
48838
48839
48840
48841
48842
48843
48844
48845
48846
48847
48848
48849
48850
48851
48852
48853
48854
48855
48856
48857
48858
48859
48860
48861
48862
48863
48864
48865
48866
48867
48868
48869
48870
48871
48872
48873
48874
48875
48876
48877
48878
48879
48880
48881
48882
48883
48884
48885
48886
48887
48888
48889
48890
48891
48892
48893
48894
48895
48896
48897
48898
48899
48900
48901
48902
48903
48904
48905
48906
48907
48908
48909
48910
48911
48912
48913
48914
48915
48916
48917
48918
48919
48920
48921
48922
48923
48924
48925
48926
48927
48928
48929
48930
48931
48932
48933
48934
48935
48936
48937
48938
48939
48940
48941
48942
48943
48944
48945
48946
48947
48948
48949
48950
48951
48952
48953
48954
48955
48956
48957
48958
48959
48960
48961
48962
48963
48964
48965
48966
48967
48968
48969
48970
48971
48972
48973
48974
48975
48976
48977
48978
48979
48980
48981
48982
48983
48984
48985
48986
48987
48988
48989
48990
48991
48992
48993
48994
48995
48996
48997
48998
48999
49000
49001
49002
49003
49004
49005
49006
49007
49008
49009
49010
49011
49012
49013
49014
49015
49016
49017
49018
49019
49020
49021
49022
49023
49024
49025
49026
49027
49028
49029
49030
49031
49032
49033
49034
49035
49036
49037
49038
49039
49040
49041
49042
49043
49044
49045
49046
49047
49048
49049
49050
49051
49052
49053
49054
49055
49056
49057
49058
49059
49060
49061
49062
49063
49064
49065
49066
49067
49068
49069
49070
49071
49072
49073
49074
49075
49076
49077
49078
49079
49080
49081
49082
49083
49084
49085
49086
49087
49088
49089
49090
49091
49092
49093
49094
49095
49096
49097
49098
49099
49100
49101
49102
49103
49104
49105
49106
49107
49108
49109
49110
49111
49112
49113
49114
49115
49116
49117
49118
49119
49120
49121
49122
49123
49124
49125
49126
49127
49128
49129
49130
49131
49132
49133
49134
49135
49136
49137
49138
49139
49140
49141
49142
49143
49144
49145
49146
49147
49148
49149
49150
49151
49152
49153
49154
49155
49156
49157
49158
49159
49160
49161
49162
49163
49164
49165
49166
49167
49168
49169
49170
49171
49172
49173
49174
49175
49176
49177
49178
49179
49180
49181
49182
49183
49184
49185
49186
49187
49188
49189
49190
49191
49192
49193
49194
49195
49196
49197
49198
49199
49200
49201
49202
49203
49204
49205
49206
49207
49208
49209
49210
49211
49212
49213
49214
49215
49216
49217
49218
49219
49220
49221
49222
49223
49224
49225
49226
49227
49228
49229
49230
49231
49232
49233
49234
49235
49236
49237
49238
49239
49240
49241
49242
49243
49244
49245
49246
49247
49248
49249
49250
49251
49252
49253
49254
49255
49256
49257
49258
49259
49260
49261
49262
49263
49264
49265
49266
49267
49268
49269
49270
49271
49272
49273
49274
49275
49276
49277
49278
49279
49280
49281
49282
49283
49284
49285
49286
49287
49288
49289
49290
49291
49292
49293
49294
49295
49296
49297
49298
49299
49300
49301
49302
49303
49304
49305
49306
49307
49308
49309
49310
49311
49312
49313
49314
49315
49316
49317
49318
49319
49320
49321
49322
49323
49324
49325
49326
49327
49328
49329
49330
49331
49332
49333
49334
49335
49336
49337
49338
49339
49340
49341
49342
49343
49344
49345
49346
49347
49348
49349
49350
49351
49352
49353
49354
49355
49356
49357
49358
49359
49360
49361
49362
49363
49364
49365
49366
49367
49368
49369
49370
49371
49372
49373
49374
49375
49376
49377
49378
49379
49380
49381
49382
49383
49384
49385
49386
49387
49388
49389
49390
49391
49392
49393
49394
49395
49396
49397
49398
49399
49400
49401
49402
49403
49404
49405
49406
49407
49408
49409
49410
49411
49412
49413
49414
49415
49416
49417
49418
49419
49420
49421
49422
49423
49424
49425
49426
49427
49428
49429
49430
49431
49432
49433
49434
49435
49436
49437
49438
49439
49440
49441
49442
49443
49444
49445
49446
49447
49448
49449
49450
49451
49452
49453
49454
49455
49456
49457
49458
49459
49460
49461
49462
49463
49464
49465
49466
49467
49468
49469
49470
49471
49472
49473
49474
49475
49476
49477
49478
49479
49480
49481
49482
49483
49484
49485
49486
49487
49488
49489
49490
49491
49492
49493
49494
49495
49496
49497
49498
49499
49500
49501
49502
49503
49504
49505
49506
49507
49508
49509
49510
49511
49512
49513
49514
49515
49516
49517
49518
49519
49520
49521
49522
49523
49524
49525
49526
49527
49528
49529
49530
49531
49532
49533
49534
49535
49536
49537
49538
49539
49540
49541
49542
49543
49544
49545
49546
49547
49548
49549
49550
49551
49552
49553
49554
49555
49556
49557
49558
49559
49560
49561
49562
49563
49564
49565
49566
49567
49568
49569
49570
49571
49572
49573
49574
49575
49576
49577
49578
49579
49580
49581
49582
49583
49584
49585
49586
49587
49588
49589
49590
49591
49592
49593
49594
49595
49596
49597
49598
49599
49600
49601
49602
49603
49604
49605
49606
49607
49608
49609
49610
49611
49612
49613
49614
49615
49616
49617
49618
49619
49620
49621
49622
49623
49624
49625
49626
49627
49628
49629
49630
49631
49632
49633
49634
49635
49636
49637
49638
49639
49640
49641
49642
49643
49644
49645
49646
49647
49648
49649
49650
49651
49652
49653
49654
49655
49656
49657
49658
49659
49660
49661
49662
49663
49664
49665
49666
49667
49668
49669
49670
49671
49672
49673
49674
49675
49676
49677
49678
49679
49680
49681
49682
49683
49684
49685
49686
49687
49688
49689
49690
49691
49692
49693
49694
49695
49696
49697
49698
49699
49700
49701
49702
49703
49704
49705
49706
49707
49708
49709
49710
49711
49712
49713
49714
49715
49716
49717
49718
49719
49720
49721
49722
49723
49724
49725
49726
49727
49728
49729
49730
49731
49732
49733
49734
49735
49736
49737
49738
49739
49740
49741
49742
49743
49744
49745
49746
49747
49748
49749
49750
49751
49752
49753
49754
49755
49756
49757
49758
49759
49760
49761
49762
49763
49764
49765
49766
49767
49768
49769
49770
49771
49772
49773
49774
49775
49776
49777
49778
49779
49780
49781
49782
49783
49784
49785
49786
49787
49788
49789
49790
49791
49792
49793
49794
49795
49796
49797
49798
49799
49800
49801
49802
49803
49804
49805
49806
49807
49808
49809
49810
49811
49812
49813
49814
49815
49816
49817
49818
49819
49820
49821
49822
49823
49824
49825
49826
49827
49828
49829
49830
49831
49832
49833
49834
49835
49836
49837
49838
49839
49840
49841
49842
49843
49844
49845
49846
49847
49848
49849
49850
49851
49852
49853
49854
49855
49856
49857
49858
49859
49860
49861
49862
49863
49864
49865
49866
49867
49868
49869
49870
49871
49872
49873
49874
49875
49876
49877
49878
49879
49880
49881
49882
49883
49884
49885
49886
49887
49888
49889
49890
49891
49892
49893
49894
49895
49896
49897
49898
49899
49900
49901
49902
49903
49904
49905
49906
49907
49908
49909
49910
49911
49912
49913
49914
49915
49916
49917
49918
49919
49920
49921
49922
49923
49924
49925
49926
49927
49928
49929
49930
49931
49932
49933
49934
49935
49936
49937
49938
49939
49940
49941
49942
49943
49944
49945
49946
49947
49948
49949
49950
49951
49952
49953
49954
49955
49956
49957
49958
49959
49960
49961
49962
49963
49964
49965
49966
49967
49968
49969
49970
49971
49972
49973
49974
49975
49976
49977
49978
49979
49980
49981
49982
49983
49984
49985
49986
49987
49988
49989
49990
49991
49992
49993
49994
49995
49996
49997
49998
49999
50000
50001
50002
50003
50004
50005
50006
50007
50008
50009
50010
50011
50012
50013
50014
50015
50016
50017
50018
50019
50020
50021
50022
50023
50024
50025
50026
50027
50028
50029
50030
50031
50032
50033
50034
50035
50036
50037
50038
50039
50040
50041
50042
50043
50044
50045
50046
50047
50048
50049
50050
50051
50052
50053
50054
50055
50056
50057
50058
50059
50060
50061
50062
50063
50064
50065
50066
50067
50068
50069
50070
50071
50072
50073
50074
50075
50076
50077
50078
50079
50080
50081
50082
50083
50084
50085
50086
50087
50088
50089
50090
50091
50092
50093
50094
50095
50096
50097
50098
50099
50100
50101
50102
50103
50104
50105
50106
50107
50108
50109
50110
50111
50112
50113
50114
50115
50116
50117
50118
50119
50120
50121
50122
50123
50124
50125
50126
50127
50128
50129
50130
50131
50132
50133
50134
50135
50136
50137
50138
50139
50140
50141
50142
50143
50144
50145
50146
50147
50148
50149
50150
50151
50152
50153
50154
50155
50156
50157
50158
50159
50160
50161
50162
50163
50164
50165
50166
50167
50168
50169
50170
50171
50172
50173
50174
50175
50176
50177
50178
50179
50180
50181
50182
50183
50184
50185
50186
50187
50188
50189
50190
50191
50192
50193
50194
50195
50196
50197
50198
50199
50200
50201
50202
50203
50204
50205
50206
50207
50208
50209
50210
50211
50212
50213
50214
50215
50216
50217
50218
50219
50220
50221
50222
50223
50224
50225
50226
50227
50228
50229
50230
50231
50232
50233
50234
50235
50236
50237
50238
50239
50240
50241
50242
50243
50244
50245
50246
50247
50248
50249
50250
50251
50252
50253
50254
50255
50256
50257
50258
50259
50260
50261
50262
50263
50264
50265
50266
50267
50268
50269
50270
50271
50272
50273
50274
50275
50276
50277
50278
50279
50280
50281
50282
50283
50284
50285
50286
50287
50288
50289
50290
50291
50292
50293
50294
50295
50296
50297
50298
50299
50300
50301
50302
50303
50304
50305
50306
50307
50308
50309
50310
50311
50312
50313
50314
50315
50316
50317
50318
50319
50320
50321
50322
50323
50324
50325
50326
50327
50328
50329
50330
50331
50332
50333
50334
50335
50336
50337
50338
50339
50340
50341
50342
50343
50344
50345
50346
50347
50348
50349
50350
50351
50352
50353
50354
50355
50356
50357
50358
50359
50360
50361
50362
50363
50364
50365
50366
50367
50368
50369
50370
50371
50372
50373
50374
50375
50376
50377
50378
50379
50380
50381
50382
50383
50384
50385
50386
50387
50388
50389
50390
50391
50392
50393
50394
50395
50396
50397
50398
50399
50400
50401
50402
50403
50404
50405
50406
50407
50408
50409
50410
50411
50412
50413
50414
50415
50416
50417
50418
50419
50420
50421
50422
50423
50424
50425
50426
50427
50428
50429
50430
50431
50432
50433
50434
50435
50436
50437
50438
50439
50440
50441
50442
50443
50444
50445
50446
50447
50448
50449
50450
50451
50452
50453
50454
50455
50456
50457
50458
50459
50460
50461
50462
50463
50464
50465
50466
50467
50468
50469
50470
50471
50472
50473
50474
50475
50476
50477
50478
50479
50480
50481
50482
50483
50484
50485
50486
50487
50488
50489
50490
50491
50492
50493
50494
50495
50496
50497
50498
50499
50500
50501
50502
50503
50504
50505
50506
50507
50508
50509
50510
50511
50512
50513
50514
50515
50516
50517
50518
50519
50520
50521
50522
50523
50524
50525
50526
50527
50528
50529
50530
50531
50532
50533
50534
50535
50536
50537
50538
50539
50540
50541
50542
50543
50544
50545
50546
50547
50548
50549
50550
50551
50552
50553
50554
50555
50556
50557
50558
50559
50560
50561
50562
50563
50564
50565
50566
50567
50568
50569
50570
50571
50572
50573
50574
50575
50576
50577
50578
50579
50580
50581
50582
50583
50584
50585
50586
50587
50588
50589
50590
50591
50592
50593
50594
50595
50596
50597
50598
50599
50600
50601
50602
50603
50604
50605
50606
50607
50608
50609
50610
50611
50612
50613
50614
50615
50616
50617
50618
50619
50620
50621
50622
50623
50624
50625
50626
50627
50628
50629
50630
50631
50632
50633
50634
50635
50636
50637
50638
50639
50640
50641
50642
50643
50644
50645
50646
50647
50648
50649
50650
50651
50652
50653
50654
50655
50656
50657
50658
50659
50660
50661
50662
50663
50664
50665
50666
50667
50668
50669
50670
50671
50672
50673
50674
50675
50676
50677
50678
50679
50680
50681
50682
50683
50684
50685
50686
50687
50688
50689
50690
50691
50692
50693
50694
50695
50696
50697
50698
50699
50700
50701
50702
50703
50704
50705
50706
50707
50708
50709
50710
50711
50712
50713
50714
50715
50716
50717
50718
50719
50720
50721
50722
50723
50724
50725
50726
50727
50728
50729
50730
50731
50732
50733
50734
50735
50736
50737
50738
50739
50740
50741
50742
50743
50744
50745
50746
50747
50748
50749
50750
50751
50752
50753
50754
50755
50756
50757
50758
50759
50760
50761
50762
50763
50764
50765
50766
50767
50768
50769
50770
50771
50772
50773
50774
50775
50776
50777
50778
50779
50780
50781
50782
50783
50784
50785
50786
50787
50788
50789
50790
50791
50792
50793
50794
50795
50796
50797
50798
50799
50800
50801
50802
50803
50804
50805
50806
50807
50808
50809
50810
50811
50812
50813
50814
50815
50816
50817
50818
50819
50820
50821
50822
50823
50824
50825
50826
50827
50828
50829
50830
50831
50832
50833
50834
50835
50836
50837
50838
50839
50840
50841
50842
50843
50844
50845
50846
50847
50848
50849
50850
50851
50852
50853
50854
50855
50856
50857
50858
50859
50860
50861
50862
50863
50864
50865
50866
50867
50868
50869
50870
50871
50872
50873
50874
50875
50876
50877
50878
50879
50880
50881
50882
50883
50884
50885
50886
50887
50888
50889
50890
50891
50892
50893
50894
50895
50896
50897
50898
50899
50900
50901
50902
50903
50904
50905
50906
50907
50908
50909
50910
50911
50912
50913
50914
50915
50916
50917
50918
50919
50920
50921
50922
50923
50924
50925
50926
50927
50928
50929
50930
50931
50932
50933
50934
50935
50936
50937
50938
50939
50940
50941
50942
50943
50944
50945
50946
50947
50948
50949
50950
50951
50952
50953
50954
50955
50956
50957
50958
50959
50960
50961
50962
50963
50964
50965
50966
50967
50968
50969
50970
50971
50972
50973
50974
50975
50976
50977
50978
50979
50980
50981
50982
50983
50984
50985
50986
50987
50988
50989
50990
50991
50992
50993
50994
50995
50996
50997
50998
50999
51000
51001
51002
51003
51004
51005
51006
51007
51008
51009
51010
51011
51012
51013
51014
51015
51016
51017
51018
51019
51020
51021
51022
51023
51024
51025
51026
51027
51028
51029
51030
51031
51032
51033
51034
51035
51036
51037
51038
51039
51040
51041
51042
51043
51044
51045
51046
51047
51048
51049
51050
51051
51052
51053
51054
51055
51056
51057
51058
51059
51060
51061
51062
51063
51064
51065
51066
51067
51068
51069
51070
51071
51072
51073
51074
51075
51076
51077
51078
51079
51080
51081
51082
51083
51084
51085
51086
51087
51088
51089
51090
51091
51092
51093
51094
51095
51096
51097
51098
51099
51100
51101
51102
51103
51104
51105
51106
51107
51108
51109
51110
51111
51112
51113
51114
51115
51116
51117
51118
51119
51120
51121
51122
51123
51124
51125
51126
51127
51128
51129
51130
51131
51132
51133
51134
51135
51136
51137
51138
51139
51140
51141
51142
51143
51144
51145
51146
51147
51148
51149
51150
51151
51152
51153
51154
51155
51156
51157
51158
51159
51160
51161
51162
51163
51164
51165
51166
51167
51168
51169
51170
51171
51172
51173
51174
51175
51176
51177
51178
51179
51180
51181
51182
51183
51184
51185
51186
51187
51188
51189
51190
51191
51192
51193
51194
51195
51196
51197
51198
51199
51200
51201
51202
51203
51204
51205
51206
51207
51208
51209
51210
51211
51212
51213
51214
51215
51216
51217
51218
51219
51220
51221
51222
51223
51224
51225
51226
51227
51228
51229
51230
51231
51232
51233
51234
51235
51236
51237
51238
51239
51240
51241
51242
51243
51244
51245
51246
51247
51248
51249
51250
51251
51252
51253
51254
51255
51256
51257
51258
51259
51260
51261
51262
51263
51264
51265
51266
51267
51268
51269
51270
51271
51272
51273
51274
51275
51276
51277
51278
51279
51280
51281
51282
51283
51284
51285
51286
51287
51288
51289
51290
51291
51292
51293
51294
51295
51296
51297
51298
51299
51300
51301
51302
51303
51304
51305
51306
51307
51308
51309
51310
51311
51312
51313
51314
51315
51316
51317
51318
51319
51320
51321
51322
51323
51324
51325
51326
51327
51328
51329
51330
51331
51332
51333
51334
51335
51336
51337
51338
51339
51340
51341
51342
51343
51344
51345
51346
51347
51348
51349
51350
51351
51352
51353
51354
51355
51356
51357
51358
51359
51360
51361
51362
51363
51364
51365
51366
51367
51368
51369
51370
51371
51372
51373
51374
51375
51376
51377
51378
51379
51380
51381
51382
51383
51384
51385
51386
51387
51388
51389
51390
51391
51392
51393
51394
51395
51396
51397
51398
51399
51400
51401
51402
51403
51404
51405
51406
51407
51408
51409
51410
51411
51412
51413
51414
51415
51416
51417
51418
51419
51420
51421
51422
51423
51424
51425
51426
51427
51428
51429
51430
51431
51432
51433
51434
51435
51436
51437
51438
51439
51440
51441
51442
51443
51444
51445
51446
51447
51448
51449
51450
51451
51452
51453
51454
51455
51456
51457
51458
51459
51460
51461
51462
51463
51464
51465
51466
51467
51468
51469
51470
51471
51472
51473
51474
51475
51476
51477
51478
51479
51480
51481
51482
51483
51484
51485
51486
51487
51488
51489
51490
51491
51492
51493
51494
51495
51496
51497
51498
51499
51500
51501
51502
51503
51504
51505
51506
51507
51508
51509
51510
51511
51512
51513
51514
51515
51516
51517
51518
51519
51520
51521
51522
51523
51524
51525
51526
51527
51528
51529
51530
51531
51532
51533
51534
51535
51536
51537
51538
51539
51540
51541
51542
51543
51544
51545
51546
51547
51548
51549
51550
51551
51552
51553
51554
51555
51556
51557
51558
51559
51560
51561
51562
51563
51564
51565
51566
51567
51568
51569
51570
51571
51572
51573
51574
51575
51576
51577
51578
51579
51580
51581
51582
51583
51584
51585
51586
51587
51588
51589
51590
51591
51592
51593
51594
51595
51596
51597
51598
51599
51600
51601
51602
51603
51604
51605
51606
51607
51608
51609
51610
51611
51612
51613
51614
51615
51616
51617
51618
51619
51620
51621
51622
51623
51624
51625
51626
51627
51628
51629
51630
51631
51632
51633
51634
51635
51636
51637
51638
51639
51640
51641
51642
51643
51644
51645
51646
51647
51648
51649
51650
51651
51652
51653
51654
51655
51656
51657
51658
51659
51660
51661
51662
51663
51664
51665
51666
51667
51668
51669
51670
51671
51672
51673
51674
51675
51676
51677
51678
51679
51680
51681
51682
51683
51684
51685
51686
51687
51688
51689
51690
51691
51692
51693
51694
51695
51696
51697
51698
51699
51700
51701
51702
51703
51704
51705
51706
51707
51708
51709
51710
51711
51712
51713
51714
51715
51716
51717
51718
51719
51720
51721
51722
51723
51724
51725
51726
51727
51728
51729
51730
51731
51732
51733
51734
51735
51736
51737
51738
51739
51740
51741
51742
51743
51744
51745
51746
51747
51748
51749
51750
51751
51752
51753
51754
51755
51756
51757
51758
51759
51760
51761
51762
51763
51764
51765
51766
51767
51768
51769
51770
51771
51772
51773
51774
51775
51776
51777
51778
51779
51780
51781
51782
51783
51784
51785
51786
51787
51788
51789
51790
51791
51792
51793
51794
51795
51796
51797
51798
51799
51800
51801
51802
51803
51804
51805
51806
51807
51808
51809
51810
51811
51812
51813
51814
51815
51816
51817
51818
51819
51820
51821
51822
51823
51824
51825
51826
51827
51828
51829
51830
51831
51832
51833
51834
51835
51836
51837
51838
51839
51840
51841
51842
51843
51844
51845
51846
51847
51848
51849
51850
51851
51852
51853
51854
51855
51856
51857
51858
51859
51860
51861
51862
51863
51864
51865
51866
51867
51868
51869
51870
51871
51872
51873
51874
51875
51876
51877
51878
51879
51880
51881
51882
51883
51884
51885
51886
51887
51888
51889
51890
51891
51892
51893
51894
51895
51896
51897
51898
51899
51900
51901
51902
51903
51904
51905
51906
51907
51908
51909
51910
51911
51912
51913
51914
51915
51916
51917
51918
51919
51920
51921
51922
51923
51924
51925
51926
51927
51928
51929
51930
51931
51932
51933
51934
51935
51936
51937
51938
51939
51940
51941
51942
51943
51944
51945
51946
51947
51948
51949
51950
51951
51952
51953
51954
51955
51956
51957
51958
51959
51960
51961
51962
51963
51964
51965
51966
51967
51968
51969
51970
51971
51972
51973
51974
51975
51976
51977
51978
51979
51980
51981
51982
51983
51984
51985
51986
51987
51988
51989
51990
51991
51992
51993
51994
51995
51996
51997
51998
51999
52000
52001
52002
52003
52004
52005
52006
52007
52008
52009
52010
52011
52012
52013
52014
52015
52016
52017
52018
52019
52020
52021
52022
52023
52024
52025
52026
52027
52028
52029
52030
52031
52032
52033
52034
52035
52036
52037
52038
52039
52040
52041
52042
52043
52044
52045
52046
52047
52048
52049
52050
52051
52052
52053
52054
52055
52056
52057
52058
52059
52060
52061
52062
52063
52064
52065
52066
52067
52068
52069
52070
52071
52072
52073
52074
52075
52076
52077
52078
52079
52080
52081
52082
52083
52084
52085
52086
52087
52088
52089
52090
52091
52092
52093
52094
52095
52096
52097
52098
52099
52100
52101
52102
52103
52104
52105
52106
52107
52108
52109
52110
52111
52112
52113
52114
52115
52116
52117
52118
52119
52120
52121
52122
52123
52124
52125
52126
52127
52128
52129
52130
52131
52132
52133
52134
52135
52136
52137
52138
52139
52140
52141
52142
52143
52144
52145
52146
52147
52148
52149
52150
52151
52152
52153
52154
52155
52156
52157
52158
52159
52160
52161
52162
52163
52164
52165
52166
52167
52168
52169
52170
52171
52172
52173
52174
52175
52176
52177
52178
52179
52180
52181
52182
52183
52184
52185
52186
52187
52188
52189
52190
52191
52192
52193
52194
52195
52196
52197
52198
52199
52200
52201
52202
52203
52204
52205
52206
52207
52208
52209
52210
52211
52212
52213
52214
52215
52216
52217
52218
52219
52220
52221
52222
52223
52224
52225
52226
52227
52228
52229
52230
52231
52232
52233
52234
52235
52236
52237
52238
52239
52240
52241
52242
52243
52244
52245
52246
52247
52248
52249
52250
52251
52252
52253
52254
52255
52256
52257
52258
52259
52260
52261
52262
52263
52264
52265
52266
52267
52268
52269
52270
52271
52272
52273
52274
52275
52276
52277
52278
52279
52280
52281
52282
52283
52284
52285
52286
52287
52288
52289
52290
52291
52292
52293
52294
52295
52296
52297
52298
52299
52300
52301
52302
52303
52304
52305
52306
52307
52308
52309
52310
52311
52312
52313
52314
52315
52316
52317
52318
52319
52320
52321
52322
52323
52324
52325
52326
52327
52328
52329
52330
52331
52332
52333
52334
52335
52336
52337
52338
52339
52340
52341
52342
52343
52344
52345
52346
52347
52348
52349
52350
52351
52352
52353
52354
52355
52356
52357
52358
52359
52360
52361
52362
52363
52364
52365
52366
52367
52368
52369
52370
52371
52372
52373
52374
52375
52376
52377
52378
52379
52380
52381
52382
52383
52384
52385
52386
52387
52388
52389
52390
52391
52392
52393
52394
52395
52396
52397
52398
52399
52400
52401
52402
52403
52404
52405
52406
52407
52408
52409
52410
52411
52412
52413
52414
52415
52416
52417
52418
52419
52420
52421
52422
52423
52424
52425
52426
52427
52428
52429
52430
52431
52432
52433
52434
52435
52436
52437
52438
52439
52440
52441
52442
52443
52444
52445
52446
52447
52448
52449
52450
52451
52452
52453
52454
52455
52456
52457
52458
52459
52460
52461
52462
52463
52464
52465
52466
52467
52468
52469
52470
52471
52472
52473
52474
52475
52476
52477
52478
52479
52480
52481
52482
52483
52484
52485
52486
52487
52488
52489
52490
52491
52492
52493
52494
52495
52496
52497
52498
52499
52500
52501
52502
52503
52504
52505
52506
52507
52508
52509
52510
52511
52512
52513
52514
52515
52516
52517
52518
52519
52520
52521
52522
52523
52524
52525
52526
52527
52528
52529
52530
52531
52532
52533
52534
52535
52536
52537
52538
52539
52540
52541
52542
52543
52544
52545
52546
52547
52548
52549
52550
52551
52552
52553
52554
52555
52556
52557
52558
52559
52560
52561
52562
52563
52564
52565
52566
52567
52568
52569
52570
52571
52572
52573
52574
52575
52576
52577
52578
52579
52580
52581
52582
52583
52584
52585
52586
52587
52588
52589
52590
52591
52592
52593
52594
52595
52596
52597
52598
52599
52600
52601
52602
52603
52604
52605
52606
52607
52608
52609
52610
52611
52612
52613
52614
52615
52616
52617
52618
52619
52620
52621
52622
52623
52624
52625
52626
52627
52628
52629
52630
52631
52632
52633
52634
52635
52636
52637
52638
52639
52640
52641
52642
52643
52644
52645
52646
52647
52648
52649
52650
52651
52652
52653
52654
52655
52656
52657
52658
52659
52660
52661
52662
52663
52664
52665
52666
52667
52668
52669
52670
52671
52672
52673
52674
52675
52676
52677
52678
52679
52680
52681
52682
52683
52684
52685
52686
52687
52688
52689
52690
52691
52692
52693
52694
52695
52696
52697
52698
52699
52700
52701
52702
52703
52704
52705
52706
52707
52708
52709
52710
52711
52712
52713
52714
52715
52716
52717
52718
52719
52720
52721
52722
52723
52724
52725
52726
52727
52728
52729
52730
52731
52732
52733
52734
52735
52736
52737
52738
52739
52740
52741
52742
52743
52744
52745
52746
52747
52748
52749
52750
52751
52752
52753
52754
52755
52756
52757
52758
52759
52760
52761
52762
52763
52764
52765
52766
52767
52768
52769
52770
52771
52772
52773
52774
52775
52776
52777
52778
52779
52780
52781
52782
52783
52784
52785
52786
52787
52788
52789
52790
52791
52792
52793
52794
52795
52796
52797
52798
52799
52800
52801
52802
52803
52804
52805
52806
52807
52808
52809
52810
52811
52812
52813
52814
52815
52816
52817
52818
52819
52820
52821
52822
52823
52824
52825
52826
52827
52828
52829
52830
52831
52832
52833
52834
52835
52836
52837
52838
52839
52840
52841
52842
52843
52844
52845
52846
52847
52848
52849
52850
52851
52852
52853
52854
52855
52856
52857
52858
52859
52860
52861
52862
52863
52864
52865
52866
52867
52868
52869
52870
52871
52872
52873
52874
52875
52876
52877
52878
52879
52880
52881
52882
52883
52884
52885
52886
52887
52888
52889
52890
52891
52892
52893
52894
52895
52896
52897
52898
52899
52900
52901
52902
52903
52904
52905
52906
52907
52908
52909
52910
52911
52912
52913
52914
52915
52916
52917
52918
52919
52920
52921
52922
52923
52924
52925
52926
52927
52928
52929
52930
52931
52932
52933
52934
52935
52936
52937
52938
52939
52940
52941
52942
52943
52944
52945
52946
52947
52948
52949
52950
52951
52952
52953
52954
52955
52956
52957
52958
52959
52960
52961
52962
52963
52964
52965
52966
52967
52968
52969
52970
52971
52972
52973
52974
52975
52976
52977
52978
52979
52980
52981
52982
52983
52984
52985
52986
52987
52988
52989
52990
52991
52992
52993
52994
52995
52996
52997
52998
52999
53000
53001
53002
53003
53004
53005
53006
53007
53008
53009
53010
53011
53012
53013
53014
53015
53016
53017
53018
53019
53020
53021
53022
53023
53024
53025
53026
53027
53028
53029
53030
53031
53032
53033
53034
53035
53036
53037
53038
53039
53040
53041
53042
53043
53044
53045
53046
53047
53048
53049
53050
53051
53052
53053
53054
53055
53056
53057
53058
53059
53060
53061
53062
53063
53064
53065
53066
53067
53068
53069
53070
53071
53072
53073
53074
53075
53076
53077
53078
53079
53080
53081
53082
53083
53084
53085
53086
53087
53088
53089
53090
53091
53092
53093
53094
53095
53096
53097
53098
53099
53100
53101
53102
53103
53104
53105
53106
53107
53108
53109
53110
53111
53112
53113
53114
53115
53116
53117
53118
53119
53120
53121
53122
53123
53124
53125
53126
53127
53128
53129
53130
53131
53132
53133
53134
53135
53136
53137
53138
53139
53140
53141
53142
53143
53144
53145
53146
53147
53148
53149
53150
53151
53152
53153
53154
53155
53156
53157
53158
53159
53160
53161
53162
53163
53164
53165
53166
53167
53168
53169
53170
53171
53172
53173
53174
53175
53176
53177
53178
53179
53180
53181
53182
53183
53184
53185
53186
53187
53188
53189
53190
53191
53192
53193
53194
53195
53196
53197
53198
53199
53200
53201
53202
53203
53204
53205
53206
53207
53208
53209
53210
53211
53212
53213
53214
53215
53216
53217
53218
53219
53220
53221
53222
53223
53224
53225
53226
53227
53228
53229
53230
53231
53232
53233
53234
53235
53236
53237
53238
53239
53240
53241
53242
53243
53244
53245
53246
53247
53248
53249
53250
53251
53252
53253
53254
53255
53256
53257
53258
53259
53260
53261
53262
53263
53264
53265
53266
53267
53268
53269
53270
53271
53272
53273
53274
53275
53276
53277
53278
53279
53280
53281
53282
53283
53284
53285
53286
53287
53288
53289
53290
53291
53292
53293
53294
53295
53296
53297
53298
53299
53300
53301
53302
53303
53304
53305
53306
53307
53308
53309
53310
53311
53312
53313
53314
53315
53316
53317
53318
53319
53320
53321
53322
53323
53324
53325
53326
53327
53328
53329
53330
53331
53332
53333
53334
53335
53336
53337
53338
53339
53340
53341
53342
53343
53344
53345
53346
53347
53348
53349
53350
53351
53352
53353
53354
53355
53356
53357
53358
53359
53360
53361
53362
53363
53364
53365
53366
53367
53368
53369
53370
53371
53372
53373
53374
53375
53376
53377
53378
53379
53380
53381
53382
53383
53384
53385
53386
53387
53388
53389
53390
53391
53392
53393
53394
53395
53396
53397
53398
53399
53400
53401
53402
53403
53404
53405
53406
53407
53408
53409
53410
53411
53412
53413
53414
53415
53416
53417
53418
53419
53420
53421
53422
53423
53424
53425
53426
53427
53428
53429
53430
53431
53432
53433
53434
53435
53436
53437
53438
53439
53440
53441
53442
53443
53444
53445
53446
53447
53448
53449
53450
53451
53452
53453
53454
53455
53456
53457
53458
53459
53460
53461
53462
53463
53464
53465
53466
53467
53468
53469
53470
53471
53472
53473
53474
53475
53476
53477
53478
53479
53480
53481
53482
53483
53484
53485
53486
53487
53488
53489
53490
53491
53492
53493
53494
53495
53496
53497
53498
53499
53500
53501
53502
53503
53504
53505
53506
53507
53508
53509
53510
53511
53512
53513
53514
53515
53516
53517
53518
53519
53520
53521
53522
53523
53524
53525
53526
53527
53528
53529
53530
53531
53532
53533
53534
53535
53536
53537
53538
53539
53540
53541
53542
53543
53544
53545
53546
53547
53548
53549
53550
53551
53552
53553
53554
53555
53556
53557
53558
53559
53560
53561
53562
53563
53564
53565
53566
53567
53568
53569
53570
53571
53572
53573
53574
53575
53576
53577
53578
53579
53580
53581
53582
53583
53584
53585
53586
53587
53588
53589
53590
53591
53592
53593
53594
53595
53596
53597
53598
53599
53600
53601
53602
53603
53604
53605
53606
53607
53608
53609
53610
53611
53612
53613
53614
53615
53616
53617
53618
53619
53620
53621
53622
53623
53624
53625
53626
53627
53628
53629
53630
53631
53632
53633
53634
53635
53636
53637
53638
53639
53640
53641
53642
53643
53644
53645
53646
53647
53648
53649
53650
53651
53652
53653
53654
53655
53656
53657
53658
53659
53660
53661
53662
53663
53664
53665
53666
53667
53668
53669
53670
53671
53672
53673
53674
53675
53676
53677
53678
53679
53680
53681
53682
53683
53684
53685
53686
53687
53688
53689
53690
53691
53692
53693
53694
53695
53696
53697
53698
53699
53700
53701
53702
53703
53704
53705
53706
53707
53708
53709
53710
53711
53712
53713
53714
53715
53716
53717
53718
53719
53720
53721
53722
53723
53724
53725
53726
53727
53728
53729
53730
53731
53732
53733
53734
53735
53736
53737
53738
53739
53740
53741
53742
53743
53744
53745
53746
53747
53748
53749
53750
53751
53752
53753
53754
53755
53756
53757
53758
53759
53760
53761
53762
53763
53764
53765
53766
53767
53768
53769
53770
53771
53772
53773
53774
53775
53776
53777
53778
53779
53780
53781
53782
53783
53784
53785
53786
53787
53788
53789
53790
53791
53792
53793
53794
53795
53796
53797
53798
53799
53800
53801
53802
53803
53804
53805
53806
53807
53808
53809
53810
53811
53812
53813
53814
53815
53816
53817
53818
53819
53820
53821
53822
53823
53824
53825
53826
53827
53828
53829
53830
53831
53832
53833
53834
53835
53836
53837
53838
53839
53840
53841
53842
53843
53844
53845
53846
53847
53848
53849
53850
53851
53852
53853
53854
53855
53856
53857
53858
53859
53860
53861
53862
53863
53864
53865
53866
53867
53868
53869
53870
53871
53872
53873
53874
53875
53876
53877
53878
53879
53880
53881
53882
53883
53884
53885
53886
53887
53888
53889
53890
53891
53892
53893
53894
53895
53896
53897
53898
53899
53900
53901
53902
53903
53904
53905
53906
53907
53908
53909
53910
53911
53912
53913
53914
53915
53916
53917
53918
53919
53920
53921
53922
53923
53924
53925
53926
53927
53928
53929
53930
53931
53932
53933
53934
53935
53936
53937
53938
53939
53940
53941
53942
53943
53944
53945
53946
53947
53948
53949
53950
53951
53952
53953
53954
53955
53956
53957
53958
53959
53960
53961
53962
53963
53964
53965
53966
53967
53968
53969
53970
53971
53972
53973
53974
53975
53976
53977
53978
53979
53980
53981
53982
53983
53984
53985
53986
53987
53988
53989
53990
53991
53992
53993
53994
53995
53996
53997
53998
53999
54000
54001
54002
54003
54004
54005
54006
54007
54008
54009
54010
54011
54012
54013
54014
54015
54016
54017
54018
54019
54020
54021
54022
54023
54024
54025
54026
54027
54028
54029
54030
54031
54032
54033
54034
54035
54036
54037
54038
54039
54040
54041
54042
54043
54044
54045
54046
54047
54048
54049
54050
54051
54052
54053
54054
54055
54056
54057
54058
54059
54060
54061
54062
54063
54064
54065
54066
54067
54068
54069
54070
54071
54072
54073
54074
54075
54076
54077
54078
54079
54080
54081
54082
54083
54084
54085
54086
54087
54088
54089
54090
54091
54092
54093
54094
54095
54096
54097
54098
54099
54100
54101
54102
54103
54104
54105
54106
54107
54108
54109
54110
54111
54112
54113
54114
54115
54116
54117
54118
54119
54120
54121
54122
54123
54124
54125
54126
54127
54128
54129
54130
54131
54132
54133
54134
54135
54136
54137
54138
54139
54140
54141
54142
54143
54144
54145
54146
54147
54148
54149
54150
54151
54152
54153
54154
54155
54156
54157
54158
54159
54160
54161
54162
54163
54164
54165
54166
54167
54168
54169
54170
54171
54172
54173
54174
54175
54176
54177
54178
54179
54180
54181
54182
54183
54184
54185
54186
54187
54188
54189
54190
54191
54192
54193
54194
54195
54196
54197
54198
54199
54200
54201
54202
54203
54204
54205
54206
54207
54208
54209
54210
54211
54212
54213
54214
54215
54216
54217
54218
54219
54220
54221
54222
54223
54224
54225
54226
54227
54228
54229
54230
54231
54232
54233
54234
54235
54236
54237
54238
54239
54240
54241
54242
54243
54244
54245
54246
54247
54248
54249
54250
54251
54252
54253
54254
54255
54256
54257
54258
54259
54260
54261
54262
54263
54264
54265
54266
54267
54268
54269
54270
54271
54272
54273
54274
54275
54276
54277
54278
54279
54280
54281
54282
54283
54284
54285
54286
54287
54288
54289
54290
54291
54292
54293
54294
54295
54296
54297
54298
54299
54300
54301
54302
54303
54304
54305
54306
54307
54308
54309
54310
54311
54312
54313
54314
54315
54316
54317
54318
54319
54320
54321
54322
54323
54324
54325
54326
54327
54328
54329
54330
54331
54332
54333
54334
54335
54336
54337
54338
54339
54340
54341
54342
54343
54344
54345
54346
54347
54348
54349
54350
54351
54352
54353
54354
54355
54356
54357
54358
54359
54360
54361
54362
54363
54364
54365
54366
54367
54368
54369
54370
54371
54372
54373
54374
54375
54376
54377
54378
54379
54380
54381
54382
54383
54384
54385
54386
54387
54388
54389
54390
54391
54392
54393
54394
54395
54396
54397
54398
54399
54400
54401
54402
54403
54404
54405
54406
54407
54408
54409
54410
54411
54412
54413
54414
54415
54416
54417
54418
54419
54420
54421
54422
54423
54424
54425
54426
54427
54428
54429
54430
54431
54432
54433
54434
54435
54436
54437
54438
54439
54440
54441
54442
54443
54444
54445
54446
54447
54448
54449
54450
54451
54452
54453
54454
54455
54456
54457
54458
54459
54460
54461
54462
54463
54464
54465
54466
54467
54468
54469
54470
54471
54472
54473
54474
54475
54476
54477
54478
54479
54480
54481
54482
54483
54484
54485
54486
54487
54488
54489
54490
54491
54492
54493
54494
54495
54496
54497
54498
54499
54500
54501
54502
54503
54504
54505
54506
54507
54508
54509
54510
54511
54512
54513
54514
54515
54516
54517
54518
54519
54520
54521
54522
54523
54524
54525
54526
54527
54528
54529
54530
54531
54532
54533
54534
54535
54536
54537
54538
54539
54540
54541
54542
54543
54544
54545
54546
54547
54548
54549
54550
54551
54552
54553
54554
54555
54556
54557
54558
54559
54560
54561
54562
54563
54564
54565
54566
54567
54568
54569
54570
54571
54572
54573
54574
54575
54576
54577
54578
54579
54580
54581
54582
54583
54584
54585
54586
54587
54588
54589
54590
54591
54592
54593
54594
54595
54596
54597
54598
54599
54600
54601
54602
54603
54604
54605
54606
54607
54608
54609
54610
54611
54612
54613
54614
54615
54616
54617
54618
54619
54620
54621
54622
54623
54624
54625
54626
54627
54628
54629
54630
54631
54632
54633
54634
54635
54636
54637
54638
54639
54640
54641
54642
54643
54644
54645
54646
54647
54648
54649
54650
54651
54652
54653
54654
54655
54656
54657
54658
54659
54660
54661
54662
54663
54664
54665
54666
54667
54668
54669
54670
54671
54672
54673
54674
54675
54676
54677
54678
54679
54680
54681
54682
54683
54684
54685
54686
54687
54688
54689
54690
54691
54692
54693
54694
54695
54696
54697
54698
54699
54700
54701
54702
54703
54704
54705
54706
54707
54708
54709
54710
54711
54712
54713
54714
54715
54716
54717
54718
54719
54720
54721
54722
54723
54724
54725
54726
54727
54728
54729
54730
54731
54732
54733
54734
54735
54736
54737
54738
54739
54740
54741
54742
54743
54744
54745
54746
54747
54748
54749
54750
54751
54752
54753
54754
54755
54756
54757
54758
54759
54760
54761
54762
54763
54764
54765
54766
54767
54768
54769
54770
54771
54772
54773
54774
54775
54776
54777
54778
54779
54780
54781
54782
54783
54784
54785
54786
54787
54788
54789
54790
54791
54792
54793
54794
54795
54796
54797
54798
54799
54800
54801
54802
54803
54804
54805
54806
54807
54808
54809
54810
54811
54812
54813
54814
54815
54816
54817
54818
54819
54820
54821
54822
54823
54824
54825
54826
54827
54828
54829
54830
54831
54832
54833
54834
54835
54836
54837
54838
54839
54840
54841
54842
54843
54844
54845
54846
54847
54848
54849
54850
54851
54852
54853
54854
54855
54856
54857
54858
54859
54860
54861
54862
54863
54864
54865
54866
54867
54868
54869
54870
54871
54872
54873
54874
54875
54876
54877
54878
54879
54880
54881
54882
54883
54884
54885
54886
54887
54888
54889
54890
54891
54892
54893
54894
54895
54896
54897
54898
54899
54900
54901
54902
54903
54904
54905
54906
54907
54908
54909
54910
54911
54912
54913
54914
54915
54916
54917
54918
54919
54920
54921
54922
54923
54924
54925
54926
54927
54928
54929
54930
54931
54932
54933
54934
54935
54936
54937
54938
54939
54940
54941
54942
54943
54944
54945
54946
54947
54948
54949
54950
54951
54952
54953
54954
54955
54956
54957
54958
54959
54960
54961
54962
54963
54964
54965
54966
54967
54968
54969
54970
54971
54972
54973
54974
54975
54976
54977
54978
54979
54980
54981
54982
54983
54984
54985
54986
54987
54988
54989
54990
54991
54992
54993
54994
54995
54996
54997
54998
54999
55000
55001
55002
55003
55004
55005
55006
55007
55008
55009
55010
55011
55012
55013
55014
55015
55016
55017
55018
55019
55020
55021
55022
55023
55024
55025
55026
55027
55028
55029
55030
55031
55032
55033
55034
55035
55036
55037
55038
55039
55040
55041
55042
55043
55044
55045
55046
55047
55048
55049
55050
55051
55052
55053
55054
55055
55056
55057
55058
55059
55060
55061
55062
55063
55064
55065
55066
55067
55068
55069
55070
55071
55072
55073
55074
55075
55076
55077
55078
55079
55080
55081
55082
55083
55084
55085
55086
55087
55088
55089
55090
55091
55092
55093
55094
55095
55096
55097
55098
55099
55100
55101
55102
55103
55104
55105
55106
55107
55108
55109
55110
55111
55112
55113
55114
55115
55116
55117
55118
55119
55120
55121
55122
55123
55124
55125
55126
55127
55128
55129
55130
55131
55132
55133
55134
55135
55136
55137
55138
55139
55140
55141
55142
55143
55144
55145
55146
55147
55148
55149
55150
55151
55152
55153
55154
55155
55156
55157
55158
55159
55160
55161
55162
55163
55164
55165
55166
55167
55168
55169
55170
55171
55172
55173
55174
55175
55176
55177
55178
55179
55180
55181
55182
55183
55184
55185
55186
55187
55188
55189
55190
55191
55192
55193
55194
55195
55196
55197
55198
55199
55200
55201
55202
55203
55204
55205
55206
55207
55208
55209
55210
55211
55212
55213
55214
55215
55216
55217
55218
55219
55220
55221
55222
55223
55224
55225
55226
55227
55228
55229
55230
55231
55232
55233
55234
55235
55236
55237
55238
55239
55240
55241
55242
55243
55244
55245
55246
55247
55248
55249
55250
55251
55252
55253
55254
55255
55256
55257
55258
55259
55260
55261
55262
55263
55264
55265
55266
55267
55268
55269
55270
55271
55272
55273
55274
55275
55276
55277
55278
55279
55280
55281
55282
55283
55284
55285
55286
55287
55288
55289
55290
55291
55292
55293
55294
55295
55296
55297
55298
55299
55300
55301
55302
55303
55304
55305
55306
55307
55308
55309
55310
55311
55312
55313
55314
55315
55316
55317
55318
55319
55320
55321
55322
55323
55324
55325
55326
55327
55328
55329
55330
55331
55332
55333
55334
55335
55336
55337
55338
55339
55340
55341
55342
55343
55344
55345
55346
55347
55348
55349
55350
55351
55352
55353
55354
55355
55356
55357
55358
55359
55360
55361
55362
55363
55364
55365
55366
55367
55368
55369
55370
55371
55372
55373
55374
55375
55376
55377
55378
55379
55380
55381
55382
55383
55384
55385
55386
55387
55388
55389
55390
55391
55392
55393
55394
55395
55396
55397
55398
55399
55400
55401
55402
55403
55404
55405
55406
55407
55408
55409
55410
55411
55412
55413
55414
55415
55416
55417
55418
55419
55420
55421
55422
55423
55424
55425
55426
55427
55428
55429
55430
55431
55432
55433
55434
55435
55436
55437
55438
55439
55440
55441
55442
55443
55444
55445
55446
55447
55448
55449
55450
55451
55452
55453
55454
55455
55456
55457
55458
55459
55460
55461
55462
55463
55464
55465
55466
55467
55468
55469
55470
55471
55472
55473
55474
55475
55476
55477
55478
55479
55480
55481
55482
55483
55484
55485
55486
55487
55488
55489
55490
55491
55492
55493
55494
55495
55496
55497
55498
55499
55500
55501
55502
55503
55504
55505
55506
55507
55508
55509
55510
55511
55512
55513
55514
55515
55516
55517
55518
55519
55520
55521
55522
55523
55524
55525
55526
55527
55528
55529
55530
55531
55532
55533
55534
55535
55536
55537
55538
55539
55540
55541
55542
55543
55544
55545
55546
55547
55548
55549
55550
55551
55552
55553
55554
55555
55556
55557
55558
55559
55560
55561
55562
55563
55564
55565
55566
55567
55568
55569
55570
55571
55572
55573
55574
55575
55576
55577
55578
55579
55580
55581
55582
55583
55584
55585
55586
55587
55588
55589
55590
55591
55592
55593
55594
55595
55596
55597
55598
55599
55600
55601
55602
55603
55604
55605
55606
55607
55608
55609
55610
55611
55612
55613
55614
55615
55616
55617
55618
55619
55620
55621
55622
55623
55624
55625
55626
55627
55628
55629
55630
55631
55632
55633
55634
55635
55636
55637
55638
55639
55640
55641
55642
55643
55644
55645
55646
55647
55648
55649
55650
55651
55652
55653
55654
55655
55656
55657
55658
55659
55660
55661
55662
55663
55664
55665
55666
55667
55668
55669
55670
55671
55672
55673
55674
55675
55676
55677
55678
55679
55680
55681
55682
55683
55684
55685
55686
55687
55688
55689
55690
55691
55692
55693
55694
55695
55696
55697
55698
55699
55700
55701
55702
55703
55704
55705
55706
55707
55708
55709
55710
55711
55712
55713
55714
55715
55716
55717
55718
55719
55720
55721
55722
55723
55724
55725
55726
55727
55728
55729
55730
55731
55732
55733
55734
55735
55736
55737
55738
55739
55740
55741
55742
55743
55744
55745
55746
55747
55748
55749
55750
55751
55752
55753
55754
55755
55756
55757
55758
55759
55760
55761
55762
55763
55764
55765
55766
55767
55768
55769
55770
55771
55772
55773
55774
55775
55776
55777
55778
55779
55780
55781
55782
55783
55784
55785
55786
55787
55788
55789
55790
55791
55792
55793
55794
55795
55796
55797
55798
55799
55800
55801
55802
55803
55804
55805
55806
55807
55808
55809
55810
55811
55812
55813
55814
55815
55816
55817
55818
55819
55820
55821
55822
55823
55824
55825
55826
55827
55828
55829
55830
55831
55832
55833
55834
55835
55836
55837
55838
55839
55840
55841
55842
55843
55844
55845
55846
55847
55848
55849
55850
55851
55852
55853
55854
55855
55856
55857
55858
55859
55860
55861
55862
55863
55864
55865
55866
55867
55868
55869
55870
55871
55872
55873
55874
55875
55876
55877
55878
55879
55880
55881
55882
55883
55884
55885
55886
55887
55888
55889
55890
55891
55892
55893
55894
55895
55896
55897
55898
55899
55900
55901
55902
55903
55904
55905
55906
55907
55908
55909
55910
55911
55912
55913
55914
55915
55916
55917
55918
55919
55920
55921
55922
55923
55924
55925
55926
55927
55928
55929
55930
55931
55932
55933
55934
55935
55936
55937
55938
55939
55940
55941
55942
55943
55944
55945
55946
55947
55948
55949
55950
55951
55952
55953
55954
55955
55956
55957
55958
55959
55960
55961
55962
55963
55964
55965
55966
55967
55968
55969
55970
55971
55972
55973
55974
55975
55976
55977
55978
55979
55980
55981
55982
55983
55984
55985
55986
55987
55988
55989
55990
55991
55992
55993
55994
55995
55996
55997
55998
55999
56000
56001
56002
56003
56004
56005
56006
56007
56008
56009
56010
56011
56012
56013
56014
56015
56016
56017
56018
56019
56020
56021
56022
56023
56024
56025
56026
56027
56028
56029
56030
56031
56032
56033
56034
56035
56036
56037
56038
56039
56040
56041
56042
56043
56044
56045
56046
56047
56048
56049
56050
56051
56052
56053
56054
56055
56056
56057
56058
56059
56060
56061
56062
56063
56064
56065
56066
56067
56068
56069
56070
56071
56072
56073
56074
56075
56076
56077
56078
56079
56080
56081
56082
56083
56084
56085
56086
56087
56088
56089
56090
56091
56092
56093
56094
56095
56096
56097
56098
56099
56100
56101
56102
56103
56104
56105
56106
56107
56108
56109
56110
56111
56112
56113
56114
56115
56116
56117
56118
56119
56120
56121
56122
56123
56124
56125
56126
56127
56128
56129
56130
56131
56132
56133
56134
56135
56136
56137
56138
56139
56140
56141
56142
56143
56144
56145
56146
56147
56148
56149
56150
56151
56152
56153
56154
56155
56156
56157
56158
56159
56160
56161
56162
56163
56164
56165
56166
56167
56168
56169
56170
56171
56172
56173
56174
56175
56176
56177
56178
56179
56180
56181
56182
56183
56184
56185
56186
56187
56188
56189
56190
56191
56192
56193
56194
56195
56196
56197
56198
56199
56200
56201
56202
56203
56204
56205
56206
56207
56208
56209
56210
56211
56212
56213
56214
56215
56216
56217
56218
56219
56220
56221
56222
56223
56224
56225
56226
56227
56228
56229
56230
56231
56232
56233
56234
56235
56236
56237
56238
56239
56240
56241
56242
56243
56244
56245
56246
56247
56248
56249
56250
56251
56252
56253
56254
56255
56256
56257
56258
56259
56260
56261
56262
56263
56264
56265
56266
56267
56268
56269
56270
56271
56272
56273
56274
56275
56276
56277
56278
56279
56280
56281
56282
56283
56284
56285
56286
56287
56288
56289
56290
56291
56292
56293
56294
56295
56296
56297
56298
56299
56300
56301
56302
56303
56304
56305
56306
56307
56308
56309
56310
56311
56312
56313
56314
56315
56316
56317
56318
56319
56320
56321
56322
56323
56324
56325
56326
56327
56328
56329
56330
56331
56332
56333
56334
56335
56336
56337
56338
56339
56340
56341
56342
56343
56344
56345
56346
56347
56348
56349
56350
56351
56352
56353
56354
56355
56356
56357
56358
56359
56360
56361
56362
56363
56364
56365
56366
56367
56368
56369
56370
56371
56372
56373
56374
56375
56376
56377
56378
56379
56380
56381
56382
56383
56384
56385
56386
56387
56388
56389
56390
56391
56392
56393
56394
56395
56396
56397
56398
56399
56400
56401
56402
56403
56404
56405
56406
56407
56408
56409
56410
56411
56412
56413
56414
56415
56416
56417
56418
56419
56420
56421
56422
56423
56424
56425
56426
56427
56428
56429
56430
56431
56432
56433
56434
56435
56436
56437
56438
56439
56440
56441
56442
56443
56444
56445
56446
56447
56448
56449
56450
56451
56452
56453
56454
56455
56456
56457
56458
56459
56460
56461
56462
56463
56464
56465
56466
56467
56468
56469
56470
56471
56472
56473
56474
56475
56476
56477
56478
56479
56480
56481
56482
56483
56484
56485
56486
56487
56488
56489
56490
56491
56492
56493
56494
56495
56496
56497
56498
56499
56500
56501
56502
56503
56504
56505
56506
56507
56508
56509
56510
56511
56512
56513
56514
56515
56516
56517
56518
56519
56520
56521
56522
56523
56524
56525
56526
56527
56528
56529
56530
56531
56532
56533
56534
56535
56536
56537
56538
56539
56540
56541
56542
56543
56544
56545
56546
56547
56548
56549
56550
56551
56552
56553
56554
56555
56556
56557
56558
56559
56560
56561
56562
56563
56564
56565
56566
56567
56568
56569
56570
56571
56572
56573
56574
56575
56576
56577
56578
56579
56580
56581
56582
56583
56584
56585
56586
56587
56588
56589
56590
56591
56592
56593
56594
56595
56596
56597
56598
56599
56600
56601
56602
56603
56604
56605
56606
56607
56608
56609
56610
56611
56612
56613
56614
56615
56616
56617
56618
56619
56620
56621
56622
56623
56624
56625
56626
56627
56628
56629
56630
56631
56632
56633
56634
56635
56636
56637
56638
56639
56640
56641
56642
56643
56644
56645
56646
56647
56648
56649
56650
56651
56652
56653
56654
56655
56656
56657
56658
56659
56660
56661
56662
56663
56664
56665
56666
56667
56668
56669
56670
56671
56672
56673
56674
56675
56676
56677
56678
56679
56680
56681
56682
56683
56684
56685
56686
56687
56688
56689
56690
56691
56692
56693
56694
56695
56696
56697
56698
56699
56700
56701
56702
56703
56704
56705
56706
56707
56708
56709
56710
56711
56712
56713
56714
56715
56716
56717
56718
56719
56720
56721
56722
56723
56724
56725
56726
56727
56728
56729
56730
56731
56732
56733
56734
56735
56736
56737
56738
56739
56740
56741
56742
56743
56744
56745
56746
56747
56748
56749
56750
56751
56752
56753
56754
56755
56756
56757
56758
56759
56760
56761
56762
56763
56764
56765
56766
56767
56768
56769
56770
56771
56772
56773
56774
56775
56776
56777
56778
56779
56780
56781
56782
56783
56784
56785
56786
56787
56788
56789
56790
56791
56792
56793
56794
56795
56796
56797
56798
56799
56800
56801
56802
56803
56804
56805
56806
56807
56808
56809
56810
56811
56812
56813
56814
56815
56816
56817
56818
56819
56820
56821
56822
56823
56824
56825
56826
56827
56828
56829
56830
56831
56832
56833
56834
56835
56836
56837
56838
56839
56840
56841
56842
56843
56844
56845
56846
56847
56848
56849
56850
56851
56852
56853
56854
56855
56856
56857
56858
56859
56860
56861
56862
56863
56864
56865
56866
56867
56868
56869
56870
56871
56872
56873
56874
56875
56876
56877
56878
56879
56880
56881
56882
56883
56884
56885
56886
56887
56888
56889
56890
56891
56892
56893
56894
56895
56896
56897
56898
56899
56900
56901
56902
56903
56904
56905
56906
56907
56908
56909
56910
56911
56912
56913
56914
56915
56916
56917
56918
56919
56920
56921
56922
56923
56924
56925
56926
56927
56928
56929
56930
56931
56932
56933
56934
56935
56936
56937
56938
56939
56940
56941
56942
56943
56944
56945
56946
56947
56948
56949
56950
56951
56952
56953
56954
56955
56956
56957
56958
56959
56960
56961
56962
56963
56964
56965
56966
56967
56968
56969
56970
56971
56972
56973
56974
56975
56976
56977
56978
56979
56980
56981
56982
56983
56984
56985
56986
56987
56988
56989
56990
56991
56992
56993
56994
56995
56996
56997
56998
56999
57000
57001
57002
57003
57004
57005
57006
57007
57008
57009
57010
57011
57012
57013
57014
57015
57016
57017
57018
57019
57020
57021
57022
57023
57024
57025
57026
57027
57028
57029
57030
57031
57032
57033
57034
57035
57036
57037
57038
57039
57040
57041
57042
57043
57044
57045
57046
57047
57048
57049
57050
57051
57052
57053
57054
57055
57056
57057
57058
57059
57060
57061
57062
57063
57064
57065
57066
57067
57068
57069
57070
57071
57072
57073
57074
57075
57076
57077
57078
57079
57080
57081
57082
57083
57084
57085
57086
57087
57088
57089
57090
57091
57092
57093
57094
57095
57096
57097
57098
57099
57100
57101
57102
57103
57104
57105
57106
57107
57108
57109
57110
57111
57112
57113
57114
57115
57116
57117
57118
57119
57120
57121
57122
57123
57124
57125
57126
57127
57128
57129
57130
57131
57132
57133
57134
57135
57136
57137
57138
57139
57140
57141
57142
57143
57144
57145
57146
57147
57148
57149
57150
57151
57152
57153
57154
57155
57156
57157
57158
57159
57160
57161
57162
57163
57164
57165
57166
57167
57168
57169
57170
57171
57172
57173
57174
57175
57176
57177
57178
57179
57180
57181
57182
57183
57184
57185
57186
57187
57188
57189
57190
57191
57192
57193
57194
57195
57196
57197
57198
57199
57200
57201
57202
57203
57204
57205
57206
57207
57208
57209
57210
57211
57212
57213
57214
57215
57216
57217
57218
57219
57220
57221
57222
57223
57224
57225
57226
57227
57228
57229
57230
57231
57232
57233
57234
57235
57236
57237
57238
57239
57240
57241
57242
57243
57244
57245
57246
57247
57248
57249
57250
57251
57252
57253
57254
57255
57256
57257
57258
57259
57260
57261
57262
57263
57264
57265
57266
57267
57268
57269
57270
57271
57272
57273
57274
57275
57276
57277
57278
57279
57280
57281
57282
57283
57284
57285
57286
57287
57288
57289
57290
57291
57292
57293
57294
57295
57296
57297
57298
57299
57300
57301
57302
57303
57304
57305
57306
57307
57308
57309
57310
57311
57312
57313
57314
57315
57316
57317
57318
57319
57320
57321
57322
57323
57324
57325
57326
57327
57328
57329
57330
57331
57332
57333
57334
57335
57336
57337
57338
57339
57340
57341
57342
57343
57344
57345
57346
57347
57348
57349
57350
57351
57352
57353
57354
57355
57356
57357
57358
57359
57360
57361
57362
57363
57364
57365
57366
57367
57368
57369
57370
57371
57372
57373
57374
57375
57376
57377
57378
57379
57380
57381
57382
57383
57384
57385
57386
57387
57388
57389
57390
57391
57392
57393
57394
57395
57396
57397
57398
57399
57400
57401
57402
57403
57404
57405
57406
57407
57408
57409
57410
57411
57412
57413
57414
57415
57416
57417
57418
57419
57420
57421
57422
57423
57424
57425
57426
57427
57428
57429
57430
57431
57432
57433
57434
57435
57436
57437
57438
57439
57440
57441
57442
57443
57444
57445
57446
57447
57448
57449
57450
57451
57452
57453
57454
57455
57456
57457
57458
57459
57460
57461
57462
57463
57464
57465
57466
57467
57468
57469
57470
57471
57472
57473
57474
57475
57476
57477
57478
57479
57480
57481
57482
57483
57484
57485
57486
57487
57488
57489
57490
57491
57492
57493
57494
57495
57496
57497
57498
57499
57500
57501
57502
57503
57504
57505
57506
57507
57508
57509
57510
57511
57512
57513
57514
57515
57516
57517
57518
57519
57520
57521
57522
57523
57524
57525
57526
57527
57528
57529
57530
57531
57532
57533
57534
57535
57536
57537
57538
57539
57540
57541
57542
57543
57544
57545
57546
57547
57548
57549
57550
57551
57552
57553
57554
57555
57556
57557
57558
57559
57560
57561
57562
57563
57564
57565
57566
57567
57568
57569
57570
57571
57572
57573
57574
57575
57576
57577
57578
57579
57580
57581
57582
57583
57584
57585
57586
57587
57588
57589
57590
57591
57592
57593
57594
57595
57596
57597
57598
57599
57600
57601
57602
57603
57604
57605
57606
57607
57608
57609
57610
57611
57612
57613
57614
57615
57616
57617
57618
57619
57620
57621
57622
57623
57624
57625
57626
57627
57628
57629
57630
57631
57632
57633
57634
57635
57636
57637
57638
57639
57640
57641
57642
57643
57644
57645
57646
57647
57648
57649
57650
57651
57652
57653
57654
57655
57656
57657
57658
57659
57660
57661
57662
57663
57664
57665
57666
57667
57668
57669
57670
57671
57672
57673
57674
57675
57676
57677
57678
57679
57680
57681
57682
57683
57684
57685
57686
57687
57688
57689
57690
57691
57692
57693
57694
57695
57696
57697
57698
57699
57700
57701
57702
57703
57704
57705
57706
57707
57708
57709
57710
57711
57712
57713
57714
57715
57716
57717
57718
57719
57720
57721
57722
57723
57724
57725
57726
57727
57728
57729
57730
57731
57732
57733
57734
57735
57736
57737
57738
57739
57740
57741
57742
57743
57744
57745
57746
57747
57748
57749
57750
57751
57752
57753
57754
57755
57756
57757
57758
57759
57760
57761
57762
57763
57764
57765
57766
57767
57768
57769
57770
57771
57772
57773
57774
57775
57776
57777
57778
57779
57780
57781
57782
57783
57784
57785
57786
57787
57788
57789
57790
57791
57792
57793
57794
57795
57796
57797
57798
57799
57800
57801
57802
57803
57804
57805
57806
57807
57808
57809
57810
57811
57812
57813
57814
57815
57816
57817
57818
57819
57820
57821
57822
57823
57824
57825
57826
57827
57828
57829
57830
57831
57832
57833
57834
57835
57836
57837
57838
57839
57840
57841
57842
57843
57844
57845
57846
57847
57848
57849
57850
57851
57852
57853
57854
57855
57856
57857
57858
57859
57860
57861
57862
57863
57864
57865
57866
57867
57868
57869
57870
57871
57872
57873
57874
57875
57876
57877
57878
57879
57880
57881
57882
57883
57884
57885
57886
57887
57888
57889
57890
57891
57892
57893
57894
57895
57896
57897
57898
57899
57900
57901
57902
57903
57904
57905
57906
57907
57908
57909
57910
57911
57912
57913
57914
57915
57916
57917
57918
57919
57920
57921
57922
57923
57924
57925
57926
57927
57928
57929
57930
57931
57932
57933
57934
57935
57936
57937
57938
57939
57940
57941
57942
57943
57944
57945
57946
57947
57948
57949
57950
57951
57952
57953
57954
57955
57956
57957
57958
57959
57960
57961
57962
57963
57964
57965
57966
57967
57968
57969
57970
57971
57972
57973
57974
57975
57976
57977
57978
57979
57980
57981
57982
57983
57984
57985
57986
57987
57988
57989
57990
57991
57992
57993
57994
57995
57996
57997
57998
57999
58000
58001
58002
58003
58004
58005
58006
58007
58008
58009
58010
58011
58012
58013
58014
58015
58016
58017
58018
58019
58020
58021
58022
58023
58024
58025
58026
58027
58028
58029
58030
58031
58032
58033
58034
58035
58036
58037
58038
58039
58040
58041
58042
58043
58044
58045
58046
58047
58048
58049
58050
58051
58052
58053
58054
58055
58056
58057
58058
58059
58060
58061
58062
58063
58064
58065
58066
58067
58068
58069
58070
58071
58072
58073
58074
58075
58076
58077
58078
58079
58080
58081
58082
58083
58084
58085
58086
58087
58088
58089
58090
58091
58092
58093
58094
58095
58096
58097
58098
58099
58100
58101
58102
58103
58104
58105
58106
58107
58108
58109
58110
58111
58112
58113
58114
58115
58116
58117
58118
58119
58120
58121
58122
58123
58124
58125
58126
58127
58128
58129
58130
58131
58132
58133
58134
58135
58136
58137
58138
58139
58140
58141
58142
58143
58144
58145
58146
58147
58148
58149
58150
58151
58152
58153
58154
58155
58156
58157
58158
58159
58160
58161
58162
58163
58164
58165
58166
58167
58168
58169
58170
58171
58172
58173
58174
58175
58176
58177
58178
58179
58180
58181
58182
58183
58184
58185
58186
58187
58188
58189
58190
58191
58192
58193
58194
58195
58196
58197
58198
58199
58200
58201
58202
58203
58204
58205
58206
58207
58208
58209
58210
58211
58212
58213
58214
58215
58216
58217
58218
58219
58220
58221
58222
58223
58224
58225
58226
58227
58228
58229
58230
58231
58232
58233
58234
58235
58236
58237
58238
58239
58240
58241
58242
58243
58244
58245
58246
58247
58248
58249
58250
58251
58252
58253
58254
58255
58256
58257
58258
58259
58260
58261
58262
58263
58264
58265
58266
58267
58268
58269
58270
58271
58272
58273
58274
58275
58276
58277
58278
58279
58280
58281
58282
58283
58284
58285
58286
58287
58288
58289
58290
58291
58292
58293
58294
58295
58296
58297
58298
58299
58300
58301
58302
58303
58304
58305
58306
58307
58308
58309
58310
58311
58312
58313
58314
58315
58316
58317
58318
58319
58320
58321
58322
58323
58324
58325
58326
58327
58328
58329
58330
58331
58332
58333
58334
58335
58336
58337
58338
58339
58340
58341
58342
58343
58344
58345
58346
58347
58348
58349
58350
58351
58352
58353
58354
58355
58356
58357
58358
58359
58360
58361
58362
58363
58364
58365
58366
58367
58368
58369
58370
58371
58372
58373
58374
58375
58376
58377
58378
58379
58380
58381
58382
58383
58384
58385
58386
58387
58388
58389
58390
58391
58392
58393
58394
58395
58396
58397
58398
58399
58400
58401
58402
58403
58404
58405
58406
58407
58408
58409
58410
58411
58412
58413
58414
58415
58416
58417
58418
58419
58420
58421
58422
58423
58424
58425
58426
58427
58428
58429
58430
58431
58432
58433
58434
58435
58436
58437
58438
58439
58440
58441
58442
58443
58444
58445
58446
58447
58448
58449
58450
58451
58452
58453
58454
58455
58456
58457
58458
58459
58460
58461
58462
58463
58464
58465
58466
58467
58468
58469
58470
58471
58472
58473
58474
58475
58476
58477
58478
58479
58480
58481
58482
58483
58484
58485
58486
58487
58488
58489
58490
58491
58492
58493
58494
58495
58496
58497
58498
58499
58500
58501
58502
58503
58504
58505
58506
58507
58508
58509
58510
58511
58512
58513
58514
58515
58516
58517
58518
58519
58520
58521
58522
58523
58524
58525
58526
58527
58528
58529
58530
58531
58532
58533
58534
58535
58536
58537
58538
58539
58540
58541
58542
58543
58544
58545
58546
58547
58548
58549
58550
58551
58552
58553
58554
58555
58556
58557
58558
58559
58560
58561
58562
58563
58564
58565
58566
58567
58568
58569
58570
58571
58572
58573
58574
58575
58576
58577
58578
58579
58580
58581
58582
58583
58584
58585
58586
58587
58588
58589
58590
58591
58592
58593
58594
58595
58596
58597
58598
58599
58600
58601
58602
58603
58604
58605
58606
58607
58608
58609
58610
58611
58612
58613
58614
58615
58616
58617
58618
58619
58620
58621
58622
58623
58624
58625
58626
58627
58628
58629
58630
58631
58632
58633
58634
58635
58636
58637
58638
58639
58640
58641
58642
58643
58644
58645
58646
58647
58648
58649
58650
58651
58652
58653
58654
58655
58656
58657
58658
58659
58660
58661
58662
58663
58664
58665
58666
58667
58668
58669
58670
58671
58672
58673
58674
58675
58676
58677
58678
58679
58680
58681
58682
58683
58684
58685
58686
58687
58688
58689
58690
58691
58692
58693
58694
58695
58696
58697
58698
58699
58700
58701
58702
58703
58704
58705
58706
58707
58708
58709
58710
58711
58712
58713
58714
58715
58716
58717
58718
58719
58720
58721
58722
58723
58724
58725
58726
58727
58728
58729
58730
58731
58732
58733
58734
58735
58736
58737
58738
58739
58740
58741
58742
58743
58744
58745
58746
58747
58748
58749
58750
58751
58752
58753
58754
58755
58756
58757
58758
58759
58760
58761
58762
58763
58764
58765
58766
58767
58768
58769
58770
58771
58772
58773
58774
58775
58776
58777
58778
58779
58780
58781
58782
58783
58784
58785
58786
58787
58788
58789
58790
58791
58792
58793
58794
58795
58796
58797
58798
58799
58800
58801
58802
58803
58804
58805
58806
58807
58808
58809
58810
58811
58812
58813
58814
58815
58816
58817
58818
58819
58820
58821
58822
58823
58824
58825
58826
58827
58828
58829
58830
58831
58832
58833
58834
58835
58836
58837
58838
58839
58840
58841
58842
58843
58844
58845
58846
58847
58848
58849
58850
58851
58852
58853
58854
58855
58856
58857
58858
58859
58860
58861
58862
58863
58864
58865
58866
58867
58868
58869
58870
58871
58872
58873
58874
58875
58876
58877
58878
58879
58880
58881
58882
58883
58884
58885
58886
58887
58888
58889
58890
58891
58892
58893
58894
58895
58896
58897
58898
58899
58900
58901
58902
58903
58904
58905
58906
58907
58908
58909
58910
58911
58912
58913
58914
58915
58916
58917
58918
58919
58920
58921
58922
58923
58924
58925
58926
58927
58928
58929
58930
58931
58932
58933
58934
58935
58936
58937
58938
58939
58940
58941
58942
58943
58944
58945
58946
58947
58948
58949
58950
58951
58952
58953
58954
58955
58956
58957
58958
58959
58960
58961
58962
58963
58964
58965
58966
58967
58968
58969
58970
58971
58972
58973
58974
58975
58976
58977
58978
58979
58980
58981
58982
58983
58984
58985
58986
58987
58988
58989
58990
58991
58992
58993
58994
58995
58996
58997
58998
58999
59000
59001
59002
59003
59004
59005
59006
59007
59008
59009
59010
59011
59012
59013
59014
59015
59016
59017
59018
59019
59020
59021
59022
59023
59024
59025
59026
59027
59028
59029
59030
59031
59032
59033
59034
59035
59036
59037
59038
59039
59040
59041
59042
59043
59044
59045
59046
59047
59048
59049
59050
59051
59052
59053
59054
59055
59056
59057
59058
59059
59060
59061
59062
59063
59064
59065
59066
59067
59068
59069
59070
59071
59072
59073
59074
59075
59076
59077
59078
59079
59080
59081
59082
59083
59084
59085
59086
59087
59088
59089
59090
59091
59092
59093
59094
59095
59096
59097
59098
59099
59100
59101
59102
59103
59104
59105
59106
59107
59108
59109
59110
59111
59112
59113
59114
59115
59116
59117
59118
59119
59120
59121
59122
59123
59124
59125
59126
59127
59128
59129
59130
59131
59132
59133
59134
59135
59136
59137
59138
59139
59140
59141
59142
59143
59144
59145
59146
59147
59148
59149
59150
59151
59152
59153
59154
59155
59156
59157
59158
59159
59160
59161
59162
59163
59164
59165
59166
59167
59168
59169
59170
59171
59172
59173
59174
59175
59176
59177
59178
59179
59180
59181
59182
59183
59184
59185
59186
59187
59188
59189
59190
59191
59192
59193
59194
59195
59196
59197
59198
59199
59200
59201
59202
59203
59204
59205
59206
59207
59208
59209
59210
59211
59212
59213
59214
59215
59216
59217
59218
59219
59220
59221
59222
59223
59224
59225
59226
59227
59228
59229
59230
59231
59232
59233
59234
59235
59236
59237
59238
59239
59240
59241
59242
59243
59244
59245
59246
59247
59248
59249
59250
59251
59252
59253
59254
59255
59256
59257
59258
59259
59260
59261
59262
59263
59264
59265
59266
59267
59268
59269
59270
59271
59272
59273
59274
59275
59276
59277
59278
59279
59280
59281
59282
59283
59284
59285
59286
59287
59288
59289
59290
59291
59292
59293
59294
59295
59296
59297
59298
59299
59300
59301
59302
59303
59304
59305
59306
59307
59308
59309
59310
59311
59312
59313
59314
59315
59316
59317
59318
59319
59320
59321
59322
59323
59324
59325
59326
59327
59328
59329
59330
59331
59332
59333
59334
59335
59336
59337
59338
59339
59340
59341
59342
59343
59344
59345
59346
59347
59348
59349
59350
59351
59352
59353
59354
59355
59356
59357
59358
59359
59360
59361
59362
59363
59364
59365
59366
59367
59368
59369
59370
59371
59372
59373
59374
59375
59376
59377
59378
59379
59380
59381
59382
59383
59384
59385
59386
59387
59388
59389
59390
59391
59392
59393
59394
59395
59396
59397
59398
59399
59400
59401
59402
59403
59404
59405
59406
59407
59408
59409
59410
59411
59412
59413
59414
59415
59416
59417
59418
59419
59420
59421
59422
59423
59424
59425
59426
59427
59428
59429
59430
59431
59432
59433
59434
59435
59436
59437
59438
59439
59440
59441
59442
59443
59444
59445
59446
59447
59448
59449
59450
59451
59452
59453
59454
59455
59456
59457
59458
59459
59460
59461
59462
59463
59464
59465
59466
59467
59468
59469
59470
59471
59472
59473
59474
59475
59476
59477
59478
59479
59480
59481
59482
59483
59484
59485
59486
59487
59488
59489
59490
59491
59492
59493
59494
59495
59496
59497
59498
59499
59500
59501
59502
59503
59504
59505
59506
59507
59508
59509
59510
59511
59512
59513
59514
59515
59516
59517
59518
59519
59520
59521
59522
59523
59524
59525
59526
59527
59528
59529
59530
59531
59532
59533
59534
59535
59536
59537
59538
59539
59540
59541
59542
59543
59544
59545
59546
59547
59548
59549
59550
59551
59552
59553
59554
59555
59556
59557
59558
59559
59560
59561
59562
59563
59564
59565
59566
59567
59568
59569
59570
59571
59572
59573
59574
59575
59576
59577
59578
59579
59580
59581
59582
59583
59584
59585
59586
59587
59588
59589
59590
59591
59592
59593
59594
59595
59596
59597
59598
59599
59600
59601
59602
59603
59604
59605
59606
59607
59608
59609
59610
59611
59612
59613
59614
59615
59616
59617
59618
59619
59620
59621
59622
59623
59624
59625
59626
59627
59628
59629
59630
59631
59632
59633
59634
59635
59636
59637
59638
59639
59640
59641
59642
59643
59644
59645
59646
59647
59648
59649
59650
59651
59652
59653
59654
59655
59656
59657
59658
59659
59660
59661
59662
59663
59664
59665
59666
59667
59668
59669
59670
59671
59672
59673
59674
59675
59676
59677
59678
59679
59680
59681
59682
59683
59684
59685
59686
59687
59688
59689
59690
59691
59692
59693
59694
59695
59696
59697
59698
59699
59700
59701
59702
59703
59704
59705
59706
59707
59708
59709
59710
59711
59712
59713
59714
59715
59716
59717
59718
59719
59720
59721
59722
59723
59724
59725
59726
59727
59728
59729
59730
59731
59732
59733
59734
59735
59736
59737
59738
59739
59740
59741
59742
59743
59744
59745
59746
59747
59748
59749
59750
59751
59752
59753
59754
59755
59756
59757
59758
59759
59760
59761
59762
59763
59764
59765
59766
59767
59768
59769
59770
59771
59772
59773
59774
59775
59776
59777
59778
59779
59780
59781
59782
59783
59784
59785
59786
59787
59788
59789
59790
59791
59792
59793
59794
59795
59796
59797
59798
59799
59800
59801
59802
59803
59804
59805
59806
59807
59808
59809
59810
59811
59812
59813
59814
59815
59816
59817
59818
59819
59820
59821
59822
59823
59824
59825
59826
59827
59828
59829
59830
59831
59832
59833
59834
59835
59836
59837
59838
59839
59840
59841
59842
59843
59844
59845
59846
59847
59848
59849
59850
59851
59852
59853
59854
59855
59856
59857
59858
59859
59860
59861
59862
59863
59864
59865
59866
59867
59868
59869
59870
59871
59872
59873
59874
59875
59876
59877
59878
59879
59880
59881
59882
59883
59884
59885
59886
59887
59888
59889
59890
59891
59892
59893
59894
59895
59896
59897
59898
59899
59900
59901
59902
59903
59904
59905
59906
59907
59908
59909
59910
59911
59912
59913
59914
59915
59916
59917
59918
59919
59920
59921
59922
59923
59924
59925
59926
59927
59928
59929
59930
59931
59932
59933
59934
59935
59936
59937
59938
59939
59940
59941
59942
59943
59944
59945
59946
59947
59948
59949
59950
59951
59952
59953
59954
59955
59956
59957
59958
59959
59960
59961
59962
59963
59964
59965
59966
59967
59968
59969
59970
59971
59972
59973
59974
59975
59976
59977
59978
59979
59980
59981
59982
59983
59984
59985
59986
59987
59988
59989
59990
59991
59992
59993
59994
59995
59996
59997
59998
59999
60000
60001
60002
60003
60004
60005
60006
60007
60008
60009
60010
60011
60012
60013
60014
60015
60016
60017
60018
60019
60020
60021
60022
60023
60024
60025
60026
60027
60028
60029
60030
60031
60032
60033
60034
60035
60036
60037
60038
60039
60040
60041
60042
60043
60044
60045
60046
60047
60048
60049
60050
60051
60052
60053
60054
60055
60056
60057
60058
60059
60060
60061
60062
60063
60064
60065
60066
60067
60068
60069
60070
60071
60072
60073
60074
60075
60076
60077
60078
60079
60080
60081
60082
60083
60084
60085
60086
60087
60088
60089
60090
60091
60092
60093
60094
60095
60096
60097
60098
60099
60100
60101
60102
60103
60104
60105
60106
60107
60108
60109
60110
60111
60112
60113
60114
60115
60116
60117
60118
60119
60120
60121
60122
60123
60124
60125
60126
60127
60128
60129
60130
60131
60132
60133
60134
60135
60136
60137
60138
60139
60140
60141
60142
60143
60144
60145
60146
60147
60148
60149
60150
60151
60152
60153
60154
60155
60156
60157
60158
60159
60160
60161
60162
60163
60164
60165
60166
60167
60168
60169
60170
60171
60172
60173
60174
60175
60176
60177
60178
60179
60180
60181
60182
60183
60184
60185
60186
60187
60188
60189
60190
60191
60192
60193
60194
60195
60196
60197
60198
60199
60200
60201
60202
60203
60204
60205
60206
60207
60208
60209
60210
60211
60212
60213
60214
60215
60216
60217
60218
60219
60220
60221
60222
60223
60224
60225
60226
60227
60228
60229
60230
60231
60232
60233
60234
60235
60236
60237
60238
60239
60240
60241
60242
60243
60244
60245
60246
60247
60248
60249
60250
60251
60252
60253
60254
60255
60256
60257
60258
60259
60260
60261
60262
60263
60264
60265
60266
60267
60268
60269
60270
60271
60272
60273
60274
60275
60276
60277
60278
60279
60280
60281
60282
60283
60284
60285
60286
60287
60288
60289
60290
60291
60292
60293
60294
60295
60296
60297
60298
60299
60300
60301
60302
60303
60304
60305
60306
60307
60308
60309
60310
60311
60312
60313
60314
60315
60316
60317
60318
60319
60320
60321
60322
60323
60324
60325
60326
60327
60328
60329
60330
60331
60332
60333
60334
60335
60336
60337
60338
60339
60340
60341
60342
60343
60344
60345
60346
60347
60348
60349
60350
60351
60352
60353
60354
60355
60356
60357
60358
60359
60360
60361
60362
60363
60364
60365
60366
60367
60368
60369
60370
60371
60372
60373
60374
60375
60376
60377
60378
60379
60380
60381
60382
60383
60384
60385
60386
60387
60388
60389
60390
60391
60392
60393
60394
60395
60396
60397
60398
60399
60400
60401
60402
60403
60404
60405
60406
60407
60408
60409
60410
60411
60412
60413
60414
60415
60416
60417
60418
60419
60420
60421
60422
60423
60424
60425
60426
60427
60428
60429
60430
60431
60432
60433
60434
60435
60436
60437
60438
60439
60440
60441
60442
60443
60444
60445
60446
60447
60448
60449
60450
60451
60452
60453
60454
60455
60456
60457
60458
60459
60460
60461
60462
60463
60464
60465
60466
60467
60468
60469
60470
60471
60472
60473
60474
60475
60476
60477
60478
60479
60480
60481
60482
60483
60484
60485
60486
60487
60488
60489
60490
60491
60492
60493
60494
60495
60496
60497
60498
60499
60500
60501
60502
60503
60504
60505
60506
60507
60508
60509
60510
60511
60512
60513
60514
60515
60516
60517
60518
60519
60520
60521
60522
60523
60524
60525
60526
60527
60528
60529
60530
60531
60532
60533
60534
60535
60536
60537
60538
60539
60540
60541
60542
60543
60544
60545
60546
60547
60548
60549
60550
60551
60552
60553
60554
60555
60556
60557
60558
60559
60560
60561
60562
60563
60564
60565
60566
60567
60568
60569
60570
60571
60572
60573
60574
60575
60576
60577
60578
60579
60580
60581
60582
60583
60584
60585
60586
60587
60588
60589
60590
60591
60592
60593
60594
60595
60596
60597
60598
60599
60600
60601
60602
60603
60604
60605
60606
60607
60608
60609
60610
60611
60612
60613
60614
60615
60616
60617
60618
60619
60620
60621
60622
60623
60624
60625
60626
60627
60628
60629
60630
60631
60632
60633
60634
60635
60636
60637
60638
60639
60640
60641
60642
60643
60644
60645
60646
60647
60648
60649
60650
60651
60652
60653
60654
60655
60656
60657
60658
60659
60660
60661
60662
60663
60664
60665
60666
60667
60668
60669
60670
60671
60672
60673
60674
60675
60676
60677
60678
60679
60680
60681
60682
60683
60684
60685
60686
60687
60688
60689
60690
60691
60692
60693
60694
60695
60696
60697
60698
60699
60700
60701
60702
60703
60704
60705
60706
60707
60708
60709
60710
60711
60712
60713
60714
60715
60716
60717
60718
60719
60720
60721
60722
60723
60724
60725
60726
60727
60728
60729
60730
60731
60732
60733
60734
60735
60736
60737
60738
60739
60740
60741
60742
60743
60744
60745
60746
60747
60748
60749
60750
60751
60752
60753
60754
60755
60756
60757
60758
60759
60760
60761
60762
60763
60764
60765
60766
60767
60768
60769
60770
60771
60772
60773
60774
60775
60776
60777
60778
60779
60780
60781
60782
60783
60784
60785
60786
60787
60788
60789
60790
60791
60792
60793
60794
60795
60796
60797
60798
60799
60800
60801
60802
60803
60804
60805
60806
60807
60808
60809
60810
60811
60812
60813
60814
60815
60816
60817
60818
60819
60820
60821
60822
60823
60824
60825
60826
60827
60828
60829
60830
60831
60832
60833
60834
60835
60836
60837
60838
60839
60840
60841
60842
60843
60844
60845
60846
60847
60848
60849
60850
60851
60852
60853
60854
60855
60856
60857
60858
60859
60860
60861
60862
60863
60864
60865
60866
60867
60868
60869
60870
60871
60872
60873
60874
60875
60876
60877
60878
60879
60880
60881
60882
60883
60884
60885
60886
60887
60888
60889
60890
60891
60892
60893
60894
60895
60896
60897
60898
60899
60900
60901
60902
60903
60904
60905
60906
60907
60908
60909
60910
60911
60912
60913
60914
60915
60916
60917
60918
60919
60920
60921
60922
60923
60924
60925
60926
60927
60928
60929
60930
60931
60932
60933
60934
60935
60936
60937
60938
60939
60940
60941
60942
60943
60944
60945
60946
60947
60948
60949
60950
60951
60952
60953
60954
60955
60956
60957
60958
60959
60960
60961
60962
60963
60964
60965
60966
60967
60968
60969
60970
60971
60972
60973
60974
60975
60976
60977
60978
60979
60980
60981
60982
60983
60984
60985
60986
60987
60988
60989
60990
60991
60992
60993
60994
60995
60996
60997
60998
60999
61000
61001
61002
61003
61004
61005
61006
61007
61008
61009
61010
61011
61012
61013
61014
61015
61016
61017
61018
61019
61020
61021
61022
61023
61024
61025
61026
61027
61028
61029
61030
61031
61032
61033
61034
61035
61036
61037
61038
61039
61040
61041
61042
61043
61044
61045
61046
61047
61048
61049
61050
61051
61052
61053
61054
61055
61056
61057
61058
61059
61060
61061
61062
61063
61064
61065
61066
61067
61068
61069
61070
61071
61072
61073
61074
61075
61076
61077
61078
61079
61080
61081
61082
61083
61084
61085
61086
61087
61088
61089
61090
61091
61092
61093
61094
61095
61096
61097
61098
61099
61100
61101
61102
61103
61104
61105
61106
61107
61108
61109
61110
61111
61112
61113
61114
61115
61116
61117
61118
61119
61120
61121
61122
61123
61124
61125
61126
61127
61128
61129
61130
61131
61132
61133
61134
61135
61136
61137
61138
61139
61140
61141
61142
61143
61144
61145
61146
61147
61148
61149
61150
61151
61152
61153
61154
61155
61156
61157
61158
61159
61160
61161
61162
61163
61164
61165
61166
61167
61168
61169
61170
61171
61172
61173
61174
61175
61176
61177
61178
61179
61180
61181
61182
61183
61184
61185
61186
61187
61188
61189
61190
61191
61192
61193
61194
61195
61196
61197
61198
61199
61200
61201
61202
61203
61204
61205
61206
61207
61208
61209
61210
61211
61212
61213
61214
61215
61216
61217
61218
61219
61220
61221
61222
61223
61224
61225
61226
61227
61228
61229
61230
61231
61232
61233
61234
61235
61236
61237
61238
61239
61240
61241
61242
61243
61244
61245
61246
61247
61248
61249
61250
61251
61252
61253
61254
61255
61256
61257
61258
61259
61260
61261
61262
61263
61264
61265
61266
61267
61268
61269
61270
61271
61272
61273
61274
61275
61276
61277
61278
61279
61280
61281
61282
61283
61284
61285
61286
61287
61288
61289
61290
61291
61292
61293
61294
61295
61296
61297
61298
61299
61300
61301
61302
61303
61304
61305
61306
61307
61308
61309
61310
61311
61312
61313
61314
61315
61316
61317
61318
61319
61320
61321
61322
61323
61324
61325
61326
61327
61328
61329
61330
61331
61332
61333
61334
61335
61336
61337
61338
61339
61340
61341
61342
61343
61344
61345
61346
61347
61348
61349
61350
61351
61352
61353
61354
61355
61356
61357
61358
61359
61360
61361
61362
61363
61364
61365
61366
61367
61368
61369
61370
61371
61372
61373
61374
61375
61376
61377
61378
61379
61380
61381
61382
61383
61384
61385
61386
61387
61388
61389
61390
61391
61392
61393
61394
61395
61396
61397
61398
61399
61400
61401
61402
61403
61404
61405
61406
61407
61408
61409
61410
61411
61412
61413
61414
61415
61416
61417
61418
61419
61420
61421
61422
61423
61424
61425
61426
61427
61428
61429
61430
61431
61432
61433
61434
61435
61436
61437
61438
61439
61440
61441
61442
61443
61444
61445
61446
61447
61448
61449
61450
61451
61452
61453
61454
61455
61456
61457
61458
61459
61460
61461
61462
61463
61464
61465
61466
61467
61468
61469
61470
61471
61472
61473
61474
61475
61476
61477
61478
61479
61480
61481
61482
61483
61484
61485
61486
61487
61488
61489
61490
61491
61492
61493
61494
61495
61496
61497
61498
61499
61500
61501
61502
61503
61504
61505
61506
61507
61508
61509
61510
61511
61512
61513
61514
61515
61516
61517
61518
61519
61520
61521
61522
61523
61524
61525
61526
61527
61528
61529
61530
61531
61532
61533
61534
61535
61536
61537
61538
61539
61540
61541
61542
61543
61544
61545
61546
61547
61548
61549
61550
61551
61552
61553
61554
61555
61556
61557
61558
61559
61560
61561
61562
61563
61564
61565
61566
61567
61568
61569
61570
61571
61572
61573
61574
61575
61576
61577
61578
61579
61580
61581
61582
61583
61584
61585
61586
61587
61588
61589
61590
61591
61592
61593
61594
61595
61596
61597
61598
61599
61600
61601
61602
61603
61604
61605
61606
61607
61608
61609
61610
61611
61612
61613
61614
61615
61616
61617
61618
61619
61620
61621
61622
61623
61624
61625
61626
61627
61628
61629
61630
61631
61632
61633
61634
61635
61636
61637
61638
61639
61640
61641
61642
61643
61644
61645
61646
61647
61648
61649
61650
61651
61652
61653
61654
61655
61656
61657
61658
61659
61660
61661
61662
61663
61664
61665
61666
61667
61668
61669
61670
61671
61672
61673
61674
61675
61676
61677
61678
61679
61680
61681
61682
61683
61684
61685
61686
61687
61688
61689
61690
61691
61692
61693
61694
61695
61696
61697
61698
61699
61700
61701
61702
61703
61704
61705
61706
61707
61708
61709
61710
61711
61712
61713
61714
61715
61716
61717
61718
61719
61720
61721
61722
61723
61724
61725
61726
61727
61728
61729
61730
61731
61732
61733
61734
61735
61736
61737
61738
61739
61740
61741
61742
61743
61744
61745
61746
61747
61748
61749
61750
61751
61752
61753
61754
61755
61756
61757
61758
61759
61760
61761
61762
61763
61764
61765
61766
61767
61768
61769
61770
61771
61772
61773
61774
61775
61776
61777
61778
61779
61780
61781
61782
61783
61784
61785
61786
61787
61788
61789
61790
61791
61792
61793
61794
61795
61796
61797
61798
61799
61800
61801
61802
61803
61804
61805
61806
61807
61808
61809
61810
61811
61812
61813
61814
61815
61816
61817
61818
61819
61820
61821
61822
61823
61824
61825
61826
61827
61828
61829
61830
61831
61832
61833
61834
61835
61836
61837
61838
61839
61840
61841
61842
61843
61844
61845
61846
61847
61848
61849
61850
61851
61852
61853
61854
61855
61856
61857
61858
61859
61860
61861
61862
61863
61864
61865
61866
61867
61868
61869
61870
61871
61872
61873
61874
61875
61876
61877
61878
61879
61880
61881
61882
61883
61884
61885
61886
61887
61888
61889
61890
61891
61892
61893
61894
61895
61896
61897
61898
61899
61900
61901
61902
61903
61904
61905
61906
61907
61908
61909
61910
61911
61912
61913
61914
61915
61916
61917
61918
61919
61920
61921
61922
61923
61924
61925
61926
61927
61928
61929
61930
61931
61932
61933
61934
61935
61936
61937
61938
61939
61940
61941
61942
61943
61944
61945
61946
61947
61948
61949
61950
61951
61952
61953
61954
61955
61956
61957
61958
61959
61960
61961
61962
61963
61964
61965
61966
61967
61968
61969
61970
61971
61972
61973
61974
61975
61976
61977
61978
61979
61980
61981
61982
61983
61984
61985
61986
61987
61988
61989
61990
61991
61992
61993
61994
61995
61996
61997
61998
61999
62000
62001
62002
62003
62004
62005
62006
62007
62008
62009
62010
62011
62012
62013
62014
62015
62016
62017
62018
62019
62020
62021
62022
62023
62024
62025
62026
62027
62028
62029
62030
62031
62032
62033
62034
62035
62036
62037
62038
62039
62040
62041
62042
62043
62044
62045
62046
62047
62048
62049
62050
62051
62052
62053
62054
62055
62056
62057
62058
62059
62060
62061
62062
62063
62064
62065
62066
62067
62068
62069
62070
62071
62072
62073
62074
62075
62076
62077
62078
62079
62080
62081
62082
62083
62084
62085
62086
62087
62088
62089
62090
62091
62092
62093
62094
62095
62096
62097
62098
62099
62100
62101
62102
62103
62104
62105
62106
62107
62108
62109
62110
62111
62112
62113
62114
62115
62116
62117
62118
62119
62120
62121
62122
62123
62124
62125
62126
62127
62128
62129
62130
62131
62132
62133
62134
62135
62136
62137
62138
62139
62140
62141
62142
62143
62144
62145
62146
62147
62148
62149
62150
62151
62152
62153
62154
62155
62156
62157
62158
62159
62160
62161
62162
62163
62164
62165
62166
62167
62168
62169
62170
62171
62172
62173
62174
62175
62176
62177
62178
62179
62180
62181
62182
62183
62184
62185
62186
62187
62188
62189
62190
62191
62192
62193
62194
62195
62196
62197
62198
62199
62200
62201
62202
62203
62204
62205
62206
62207
62208
62209
62210
62211
62212
62213
62214
62215
62216
62217
62218
62219
62220
62221
62222
62223
62224
62225
62226
62227
62228
62229
62230
62231
62232
62233
62234
62235
62236
62237
62238
62239
62240
62241
62242
62243
62244
62245
62246
62247
62248
62249
62250
62251
62252
62253
62254
62255
62256
62257
62258
62259
62260
62261
62262
62263
62264
62265
62266
62267
62268
62269
62270
62271
62272
62273
62274
62275
62276
62277
62278
62279
62280
62281
62282
62283
62284
62285
62286
62287
62288
62289
62290
62291
62292
62293
62294
62295
62296
62297
62298
62299
62300
62301
62302
62303
62304
62305
62306
62307
62308
62309
62310
62311
62312
62313
62314
62315
62316
62317
62318
62319
62320
62321
62322
62323
62324
62325
62326
62327
62328
62329
62330
62331
62332
62333
62334
62335
62336
62337
62338
62339
62340
62341
62342
62343
62344
62345
62346
62347
62348
62349
62350
62351
62352
62353
62354
62355
62356
62357
62358
62359
62360
62361
62362
62363
62364
62365
62366
62367
62368
62369
62370
62371
62372
62373
62374
62375
62376
62377
62378
62379
62380
62381
62382
62383
62384
62385
62386
62387
62388
62389
62390
62391
62392
62393
62394
62395
62396
62397
62398
62399
62400
62401
62402
62403
62404
62405
62406
62407
62408
62409
62410
62411
62412
62413
62414
62415
62416
62417
62418
62419
62420
62421
62422
62423
62424
62425
62426
62427
62428
62429
62430
62431
62432
62433
62434
62435
62436
62437
62438
62439
62440
62441
62442
62443
62444
62445
62446
62447
62448
62449
62450
62451
62452
62453
62454
62455
62456
62457
62458
62459
62460
62461
62462
62463
62464
62465
62466
62467
62468
62469
62470
62471
62472
62473
62474
62475
62476
62477
62478
62479
62480
62481
62482
62483
62484
62485
62486
62487
62488
62489
62490
62491
62492
62493
62494
62495
62496
62497
62498
62499
62500
62501
62502
62503
62504
62505
62506
62507
62508
62509
62510
62511
62512
62513
62514
62515
62516
62517
62518
62519
62520
62521
62522
62523
62524
62525
62526
62527
62528
62529
62530
62531
62532
62533
62534
62535
62536
62537
62538
62539
62540
62541
62542
62543
62544
62545
62546
62547
62548
62549
62550
62551
62552
62553
62554
62555
62556
62557
62558
62559
62560
62561
62562
62563
62564
62565
62566
62567
62568
62569
62570
62571
62572
62573
62574
62575
62576
62577
62578
62579
62580
62581
62582
62583
62584
62585
62586
62587
62588
62589
62590
62591
62592
62593
62594
62595
62596
62597
62598
62599
62600
62601
62602
62603
62604
62605
62606
62607
62608
62609
62610
62611
62612
62613
62614
62615
62616
62617
62618
62619
62620
62621
62622
62623
62624
62625
62626
62627
62628
62629
62630
62631
62632
62633
62634
62635
62636
62637
62638
62639
62640
62641
62642
62643
62644
62645
62646
62647
62648
62649
62650
62651
62652
62653
62654
62655
62656
62657
62658
62659
62660
62661
62662
62663
62664
62665
62666
62667
62668
62669
62670
62671
62672
62673
62674
62675
62676
62677
62678
62679
62680
62681
62682
62683
62684
62685
62686
62687
62688
62689
62690
62691
62692
62693
62694
62695
62696
62697
62698
62699
62700
62701
62702
62703
62704
62705
62706
62707
62708
62709
62710
62711
62712
62713
62714
62715
62716
62717
62718
62719
62720
62721
62722
62723
62724
62725
62726
62727
62728
62729
62730
62731
62732
62733
62734
62735
62736
62737
62738
62739
62740
62741
62742
62743
62744
62745
62746
62747
62748
62749
62750
62751
62752
62753
62754
62755
62756
62757
62758
62759
62760
62761
62762
62763
62764
62765
62766
62767
62768
62769
62770
62771
62772
62773
62774
62775
62776
62777
62778
62779
62780
62781
62782
62783
62784
62785
62786
62787
62788
62789
62790
62791
62792
62793
62794
62795
62796
62797
62798
62799
62800
62801
62802
62803
62804
62805
62806
62807
62808
62809
62810
62811
62812
62813
62814
62815
62816
62817
62818
62819
62820
62821
62822
62823
62824
62825
62826
62827
62828
62829
62830
62831
62832
62833
62834
62835
62836
62837
62838
62839
62840
62841
62842
62843
62844
62845
62846
62847
62848
62849
62850
62851
62852
62853
62854
62855
62856
62857
62858
62859
62860
62861
62862
62863
62864
62865
62866
62867
62868
62869
62870
62871
62872
62873
62874
62875
62876
62877
62878
62879
62880
62881
62882
62883
62884
62885
62886
62887
62888
62889
62890
62891
62892
62893
62894
62895
62896
62897
62898
62899
62900
62901
62902
62903
62904
62905
62906
62907
62908
62909
62910
62911
62912
62913
62914
62915
62916
62917
62918
62919
62920
62921
62922
62923
62924
62925
62926
62927
62928
62929
62930
62931
62932
62933
62934
62935
62936
62937
62938
62939
62940
62941
62942
62943
62944
62945
62946
62947
62948
62949
62950
62951
62952
62953
62954
62955
62956
62957
62958
62959
62960
62961
62962
62963
62964
62965
62966
62967
62968
62969
62970
62971
62972
62973
62974
62975
62976
62977
62978
62979
62980
62981
62982
62983
62984
62985
62986
62987
62988
62989
62990
62991
62992
62993
62994
62995
62996
62997
62998
62999
63000
63001
63002
63003
63004
63005
63006
63007
63008
63009
63010
63011
63012
63013
63014
63015
63016
63017
63018
63019
63020
63021
63022
63023
63024
63025
63026
63027
63028
63029
63030
63031
63032
63033
63034
63035
63036
63037
63038
63039
63040
63041
63042
63043
63044
63045
63046
63047
63048
63049
63050
63051
63052
63053
63054
63055
63056
63057
63058
63059
63060
63061
63062
63063
63064
63065
63066
63067
63068
63069
63070
63071
63072
63073
63074
63075
63076
63077
63078
63079
63080
63081
63082
63083
63084
63085
63086
63087
63088
63089
63090
63091
63092
63093
63094
63095
63096
63097
63098
63099
63100
63101
63102
63103
63104
63105
63106
63107
63108
63109
63110
63111
63112
63113
63114
63115
63116
63117
63118
63119
63120
63121
63122
63123
63124
63125
63126
63127
63128
63129
63130
63131
63132
63133
63134
63135
63136
63137
63138
63139
63140
63141
63142
63143
63144
63145
63146
63147
63148
63149
63150
63151
63152
63153
63154
63155
63156
63157
63158
63159
63160
63161
63162
63163
63164
63165
63166
63167
63168
63169
63170
63171
63172
63173
63174
63175
63176
63177
63178
63179
63180
63181
63182
63183
63184
63185
63186
63187
63188
63189
63190
63191
63192
63193
63194
63195
63196
63197
63198
63199
63200
63201
63202
63203
63204
63205
63206
63207
63208
63209
63210
63211
63212
63213
63214
63215
63216
63217
63218
63219
63220
63221
63222
63223
63224
63225
63226
63227
63228
63229
63230
63231
63232
63233
63234
63235
63236
63237
63238
63239
63240
63241
63242
63243
63244
63245
63246
63247
63248
63249
63250
63251
63252
63253
63254
63255
63256
63257
63258
63259
63260
63261
63262
63263
63264
63265
63266
63267
63268
63269
63270
63271
63272
63273
63274
63275
63276
63277
63278
63279
63280
63281
63282
63283
63284
63285
63286
63287
63288
63289
63290
63291
63292
63293
63294
63295
63296
63297
63298
63299
63300
63301
63302
63303
63304
63305
63306
63307
63308
63309
63310
63311
63312
63313
63314
63315
63316
63317
63318
63319
63320
63321
63322
63323
63324
63325
63326
63327
63328
63329
63330
63331
63332
63333
63334
63335
63336
63337
63338
63339
63340
63341
63342
63343
63344
63345
63346
63347
63348
63349
63350
63351
63352
63353
63354
63355
63356
63357
63358
63359
63360
63361
63362
63363
63364
63365
63366
63367
63368
63369
63370
63371
63372
63373
63374
63375
63376
63377
63378
63379
63380
63381
63382
63383
63384
63385
63386
63387
63388
63389
63390
63391
63392
63393
63394
63395
63396
63397
63398
63399
63400
63401
63402
63403
63404
63405
63406
63407
63408
63409
63410
63411
63412
63413
63414
63415
63416
63417
63418
63419
63420
63421
63422
63423
63424
63425
63426
63427
63428
63429
63430
63431
63432
63433
63434
63435
63436
63437
63438
63439
63440
63441
63442
63443
63444
63445
63446
63447
63448
63449
63450
63451
63452
63453
63454
63455
63456
63457
63458
63459
63460
63461
63462
63463
63464
63465
63466
63467
63468
63469
63470
63471
63472
63473
63474
63475
63476
63477
63478
63479
63480
63481
63482
63483
63484
63485
63486
63487
63488
63489
63490
63491
63492
63493
63494
63495
63496
63497
63498
63499
63500
63501
63502
63503
63504
63505
63506
63507
63508
63509
63510
63511
63512
63513
63514
63515
63516
63517
63518
63519
63520
63521
63522
63523
63524
63525
63526
63527
63528
63529
63530
63531
63532
63533
63534
63535
63536
63537
63538
63539
63540
63541
63542
63543
63544
63545
63546
63547
63548
63549
63550
63551
63552
63553
63554
63555
63556
63557
63558
63559
63560
63561
63562
63563
63564
63565
63566
63567
63568
63569
63570
63571
63572
63573
63574
63575
63576
63577
63578
63579
63580
63581
63582
63583
63584
63585
63586
63587
63588
63589
63590
63591
63592
63593
63594
63595
63596
63597
63598
63599
63600
63601
63602
63603
63604
63605
63606
63607
63608
63609
63610
63611
63612
63613
63614
63615
63616
63617
63618
63619
63620
63621
63622
63623
63624
63625
63626
63627
63628
63629
63630
63631
63632
63633
63634
63635
63636
63637
63638
63639
63640
63641
63642
63643
63644
63645
63646
63647
63648
63649
63650
63651
63652
63653
63654
63655
63656
63657
63658
63659
63660
63661
63662
63663
63664
63665
63666
63667
63668
63669
63670
63671
63672
63673
63674
63675
63676
63677
63678
63679
63680
63681
63682
63683
63684
63685
63686
63687
63688
63689
63690
63691
63692
63693
63694
63695
63696
63697
63698
63699
63700
63701
63702
63703
63704
63705
63706
63707
63708
63709
63710
63711
63712
63713
63714
63715
63716
63717
63718
63719
63720
63721
63722
63723
63724
63725
63726
63727
63728
63729
63730
63731
63732
63733
63734
63735
63736
63737
63738
63739
63740
63741
63742
63743
63744
63745
63746
63747
63748
63749
63750
63751
63752
63753
63754
63755
63756
63757
63758
63759
63760
63761
63762
63763
63764
63765
63766
63767
63768
63769
63770
63771
63772
63773
63774
63775
63776
63777
63778
63779
63780
63781
63782
63783
63784
63785
63786
63787
63788
63789
63790
63791
63792
63793
63794
63795
63796
63797
63798
63799
63800
63801
63802
63803
63804
63805
63806
63807
63808
63809
63810
63811
63812
63813
63814
63815
63816
63817
63818
63819
63820
63821
63822
63823
63824
63825
63826
63827
63828
63829
63830
63831
63832
63833
63834
63835
63836
63837
63838
63839
63840
63841
63842
63843
63844
63845
63846
63847
63848
63849
63850
63851
63852
63853
63854
63855
63856
63857
63858
63859
63860
63861
63862
63863
63864
63865
63866
63867
63868
63869
63870
63871
63872
63873
63874
63875
63876
63877
63878
63879
63880
63881
63882
63883
63884
63885
63886
63887
63888
63889
63890
63891
63892
63893
63894
63895
63896
63897
63898
63899
63900
63901
63902
63903
63904
63905
63906
63907
63908
63909
63910
63911
63912
63913
63914
63915
63916
63917
63918
63919
63920
63921
63922
63923
63924
63925
63926
63927
63928
63929
63930
63931
63932
63933
63934
63935
63936
63937
63938
63939
63940
63941
63942
63943
63944
63945
63946
63947
63948
63949
63950
63951
63952
63953
63954
63955
63956
63957
63958
63959
63960
63961
63962
63963
63964
63965
63966
63967
63968
63969
63970
63971
63972
63973
63974
63975
63976
63977
63978
63979
63980
63981
63982
63983
63984
63985
63986
63987
63988
63989
63990
63991
63992
63993
63994
63995
63996
63997
63998
63999
64000
64001
64002
64003
64004
64005
64006
64007
64008
64009
64010
64011
64012
64013
64014
64015
64016
64017
64018
64019
64020
64021
64022
64023
64024
64025
64026
64027
64028
64029
64030
64031
64032
64033
64034
64035
64036
64037
64038
64039
64040
64041
64042
64043
64044
64045
64046
64047
64048
64049
64050
64051
64052
64053
64054
64055
64056
64057
64058
64059
64060
64061
64062
64063
64064
64065
64066
64067
64068
64069
64070
64071
64072
64073
64074
64075
64076
64077
64078
64079
64080
64081
64082
64083
64084
64085
64086
64087
64088
64089
64090
64091
64092
64093
64094
64095
64096
64097
64098
64099
64100
64101
64102
64103
64104
64105
64106
64107
64108
64109
64110
64111
64112
64113
64114
64115
64116
64117
64118
64119
64120
64121
64122
64123
64124
64125
64126
64127
64128
64129
64130
64131
64132
64133
64134
64135
64136
64137
64138
64139
64140
64141
64142
64143
64144
64145
64146
64147
64148
64149
64150
64151
64152
64153
64154
64155
64156
64157
64158
64159
64160
64161
64162
64163
64164
64165
64166
64167
64168
64169
64170
64171
64172
64173
64174
64175
64176
64177
64178
64179
64180
64181
64182
64183
64184
64185
64186
64187
64188
64189
64190
64191
64192
64193
64194
64195
64196
64197
64198
64199
64200
64201
64202
64203
64204
64205
64206
64207
64208
64209
64210
64211
64212
64213
64214
64215
64216
64217
64218
64219
64220
64221
64222
64223
64224
64225
64226
64227
64228
64229
64230
64231
64232
64233
64234
64235
64236
64237
64238
64239
64240
64241
64242
64243
64244
64245
64246
64247
64248
64249
64250
64251
64252
64253
64254
64255
64256
64257
64258
64259
64260
64261
64262
64263
64264
64265
64266
64267
64268
64269
64270
64271
64272
64273
64274
64275
64276
64277
64278
64279
64280
64281
64282
64283
64284
64285
64286
64287
64288
64289
64290
64291
64292
64293
64294
64295
64296
64297
64298
64299
64300
64301
64302
64303
64304
64305
64306
64307
64308
64309
64310
64311
64312
64313
64314
64315
64316
64317
64318
64319
64320
64321
64322
64323
64324
64325
64326
64327
64328
64329
64330
64331
64332
64333
64334
64335
64336
64337
64338
64339
64340
64341
64342
64343
64344
64345
64346
64347
64348
64349
64350
64351
64352
64353
64354
64355
64356
64357
64358
64359
64360
64361
64362
64363
64364
64365
64366
64367
64368
64369
64370
64371
64372
64373
64374
64375
64376
64377
64378
64379
64380
64381
64382
64383
64384
64385
64386
64387
64388
64389
64390
64391
64392
64393
64394
64395
64396
64397
64398
64399
64400
64401
64402
64403
64404
64405
64406
64407
64408
64409
64410
64411
64412
64413
64414
64415
64416
64417
64418
64419
64420
64421
64422
64423
64424
64425
64426
64427
64428
64429
64430
64431
64432
64433
64434
64435
64436
64437
64438
64439
64440
64441
64442
64443
64444
64445
64446
64447
64448
64449
64450
64451
64452
64453
64454
64455
64456
64457
64458
64459
64460
64461
64462
64463
64464
64465
64466
64467
64468
64469
64470
64471
64472
64473
64474
64475
64476
64477
64478
64479
64480
64481
64482
64483
64484
64485
64486
64487
64488
64489
64490
64491
64492
64493
64494
64495
64496
64497
64498
64499
64500
64501
64502
64503
64504
64505
64506
64507
64508
64509
64510
64511
64512
64513
64514
64515
64516
64517
64518
64519
64520
64521
64522
64523
64524
64525
64526
64527
64528
64529
64530
64531
64532
64533
64534
64535
64536
64537
64538
64539
64540
64541
64542
64543
64544
64545
64546
64547
64548
64549
64550
64551
64552
64553
64554
64555
64556
64557
64558
64559
64560
64561
64562
64563
64564
64565
64566
64567
64568
64569
64570
64571
64572
64573
64574
64575
64576
64577
64578
64579
64580
64581
64582
64583
64584
64585
64586
64587
64588
64589
64590
64591
64592
64593
64594
64595
64596
64597
64598
64599
64600
64601
64602
64603
64604
64605
64606
64607
64608
64609
64610
64611
64612
64613
64614
64615
64616
64617
64618
64619
64620
64621
64622
64623
64624
64625
64626
64627
64628
64629
64630
64631
64632
64633
64634
64635
64636
64637
64638
64639
64640
64641
64642
64643
64644
64645
64646
64647
64648
64649
64650
64651
64652
64653
64654
64655
64656
64657
64658
64659
64660
64661
64662
64663
64664
64665
64666
64667
64668
64669
64670
64671
64672
64673
64674
64675
64676
64677
64678
64679
64680
64681
64682
64683
64684
64685
64686
64687
64688
64689
64690
64691
64692
64693
64694
64695
64696
64697
64698
64699
64700
64701
64702
64703
64704
64705
64706
64707
64708
64709
64710
64711
64712
64713
64714
64715
64716
64717
64718
64719
64720
64721
64722
64723
64724
64725
64726
64727
64728
64729
64730
64731
64732
64733
64734
64735
64736
64737
64738
64739
64740
64741
64742
64743
64744
64745
64746
64747
64748
64749
64750
64751
64752
64753
64754
64755
64756
64757
64758
64759
64760
64761
64762
64763
64764
64765
64766
64767
64768
64769
64770
64771
64772
64773
64774
64775
64776
64777
64778
64779
64780
64781
64782
64783
64784
64785
64786
64787
64788
64789
64790
64791
64792
64793
64794
64795
64796
64797
64798
64799
64800
64801
64802
64803
64804
64805
64806
64807
64808
64809
64810
64811
64812
64813
64814
64815
64816
64817
64818
64819
64820
64821
64822
64823
64824
64825
64826
64827
64828
64829
64830
64831
64832
64833
64834
64835
64836
64837
64838
64839
64840
64841
64842
64843
64844
64845
64846
64847
64848
64849
64850
64851
64852
64853
64854
64855
64856
64857
64858
64859
64860
64861
64862
64863
64864
64865
64866
64867
64868
64869
64870
64871
64872
64873
64874
64875
64876
64877
64878
64879
64880
64881
64882
64883
64884
64885
64886
64887
64888
64889
64890
64891
64892
64893
64894
64895
64896
64897
64898
64899
64900
64901
64902
64903
64904
64905
64906
64907
64908
64909
64910
64911
64912
64913
64914
64915
64916
64917
64918
64919
64920
64921
64922
64923
64924
64925
64926
64927
64928
64929
64930
64931
64932
64933
64934
64935
64936
64937
64938
64939
64940
64941
64942
64943
64944
64945
64946
64947
64948
64949
64950
64951
64952
64953
64954
64955
64956
64957
64958
64959
64960
64961
64962
64963
64964
64965
64966
64967
64968
64969
64970
64971
64972
64973
64974
64975
64976
64977
64978
64979
64980
64981
64982
64983
64984
64985
64986
64987
64988
64989
64990
64991
64992
64993
64994
64995
64996
64997
64998
64999
65000
65001
65002
65003
65004
65005
65006
65007
65008
65009
65010
65011
65012
65013
65014
65015
65016
65017
65018
65019
65020
65021
65022
65023
65024
65025
65026
65027
65028
65029
65030
65031
65032
65033
65034
65035
65036
65037
65038
65039
65040
65041
65042
65043
65044
65045
65046
65047
65048
65049
65050
65051
65052
65053
65054
65055
65056
65057
65058
65059
65060
65061
65062
65063
65064
65065
65066
65067
65068
65069
65070
65071
65072
65073
65074
65075
65076
65077
65078
65079
65080
65081
65082
65083
65084
65085
65086
65087
65088
65089
65090
65091
65092
65093
65094
65095
65096
65097
65098
65099
65100
65101
65102
65103
65104
65105
65106
65107
65108
65109
65110
65111
65112
65113
65114
65115
65116
65117
65118
65119
65120
65121
65122
65123
65124
65125
65126
65127
65128
65129
65130
65131
65132
65133
65134
65135
65136
65137
65138
65139
65140
65141
65142
65143
65144
65145
65146
65147
65148
65149
65150
65151
65152
65153
65154
65155
65156
65157
65158
65159
65160
65161
65162
65163
65164
65165
65166
65167
65168
65169
65170
65171
65172
65173
65174
65175
65176
65177
65178
65179
65180
65181
65182
65183
65184
65185
65186
65187
65188
65189
65190
65191
65192
65193
65194
65195
65196
65197
65198
65199
65200
65201
65202
65203
65204
65205
65206
65207
65208
65209
65210
65211
65212
65213
65214
65215
65216
65217
65218
65219
65220
65221
65222
65223
65224
65225
65226
65227
65228
65229
65230
65231
65232
65233
65234
65235
65236
65237
65238
65239
65240
65241
65242
65243
65244
65245
65246
65247
65248
65249
65250
65251
65252
65253
65254
65255
65256
65257
65258
65259
65260
65261
65262
65263
65264
65265
65266
65267
65268
65269
65270
65271
65272
65273
65274
65275
65276
65277
65278
65279
65280
65281
65282
65283
65284
65285
65286
65287
65288
65289
65290
65291
65292
65293
65294
65295
65296
65297
65298
65299
65300
65301
65302
65303
65304
65305
65306
65307
65308
65309
65310
65311
65312
65313
65314
65315
65316
65317
65318
65319
65320
65321
65322
65323
65324
65325
65326
65327
65328
65329
65330
65331
65332
65333
65334
65335
65336
65337
65338
65339
65340
65341
65342
65343
65344
65345
65346
65347
65348
65349
65350
65351
65352
65353
65354
65355
65356
65357
65358
65359
65360
65361
65362
65363
65364
65365
65366
65367
65368
65369
65370
65371
65372
65373
65374
65375
65376
65377
65378
65379
65380
65381
65382
65383
65384
65385
65386
65387
65388
65389
65390
65391
65392
65393
65394
65395
65396
65397
65398
65399
65400
65401
65402
65403
65404
65405
65406
65407
65408
65409
65410
65411
65412
65413
65414
65415
65416
65417
65418
65419
65420
65421
65422
65423
65424
65425
65426
65427
65428
65429
65430
65431
65432
65433
65434
65435
65436
65437
65438
65439
65440
65441
65442
65443
65444
65445
65446
65447
65448
65449
65450
65451
65452
65453
65454
65455
65456
65457
65458
65459
65460
65461
65462
65463
65464
65465
65466
65467
65468
65469
65470
65471
65472
65473
65474
65475
65476
65477
65478
65479
65480
65481
65482
65483
65484
65485
65486
65487
65488
65489
65490
65491
65492
65493
65494
65495
65496
65497
65498
65499
65500
65501
65502
65503
65504
65505
65506
65507
65508
65509
65510
65511
65512
65513
65514
65515
65516
65517
65518
65519
65520
65521
65522
65523
65524
65525
65526
65527
65528
65529
65530
65531
65532
65533
65534
65535
65536
65537
65538
65539
65540
65541
65542
65543
65544
65545
65546
65547
65548
65549
65550
65551
65552
65553
65554
65555
65556
65557
65558
65559
65560
65561
65562
65563
65564
65565
65566
65567
65568
65569
65570
65571
65572
65573
65574
65575
65576
65577
65578
65579
65580
65581
65582
65583
65584
65585
65586
65587
65588
65589
65590
65591
65592
65593
65594
65595
65596
65597
65598
65599
65600
65601
65602
65603
65604
65605
65606
65607
65608
65609
65610
65611
65612
65613
65614
65615
65616
65617
65618
65619
65620
65621
65622
65623
65624
65625
65626
65627
65628
65629
65630
65631
65632
65633
65634
65635
65636
65637
65638
65639
65640
65641
65642
65643
65644
65645
65646
65647
65648
65649
65650
65651
65652
65653
65654
65655
65656
65657
65658
65659
65660
65661
65662
65663
65664
65665
65666
65667
65668
65669
65670
65671
65672
65673
65674
65675
65676
65677
65678
65679
65680
65681
65682
65683
65684
65685
65686
65687
65688
65689
65690
65691
65692
65693
65694
65695
65696
65697
65698
65699
65700
65701
65702
65703
65704
65705
65706
65707
65708
65709
65710
65711
65712
65713
65714
65715
65716
65717
65718
65719
65720
65721
65722
65723
65724
65725
65726
65727
65728
65729
65730
65731
65732
65733
65734
65735
65736
65737
65738
65739
65740
65741
65742
65743
65744
65745
65746
65747
65748
65749
65750
65751
65752
65753
65754
65755
65756
65757
65758
65759
65760
65761
65762
65763
65764
65765
65766
65767
65768
65769
65770
65771
65772
65773
65774
65775
65776
65777
65778
65779
65780
65781
65782
65783
65784
65785
65786
65787
65788
65789
65790
65791
65792
65793
65794
65795
65796
65797
65798
65799
65800
65801
65802
65803
65804
65805
65806
65807
65808
65809
65810
65811
65812
65813
65814
65815
65816
65817
65818
65819
65820
65821
65822
65823
65824
65825
65826
65827
65828
65829
65830
65831
65832
65833
65834
65835
65836
65837
65838
65839
65840
65841
65842
65843
65844
65845
65846
65847
65848
65849
65850
65851
65852
65853
65854
65855
65856
65857
65858
65859
65860
65861
65862
65863
65864
65865
65866
65867
65868
65869
65870
65871
65872
65873
65874
65875
65876
65877
65878
65879
65880
65881
65882
65883
65884
65885
65886
65887
65888
65889
65890
65891
65892
65893
65894
65895
65896
65897
65898
65899
65900
65901
65902
65903
65904
65905
65906
65907
65908
65909
65910
65911
65912
65913
65914
65915
65916
65917
65918
65919
65920
65921
65922
65923
65924
65925
65926
65927
65928
65929
65930
65931
65932
65933
65934
65935
65936
65937
65938
65939
65940
65941
65942
65943
65944
65945
65946
65947
65948
65949
65950
65951
65952
65953
65954
65955
65956
65957
65958
65959
65960
65961
65962
65963
65964
65965
65966
65967
65968
65969
65970
65971
65972
65973
65974
65975
65976
65977
65978
65979
65980
65981
65982
65983
65984
65985
65986
65987
65988
65989
65990
65991
65992
65993
65994
65995
65996
65997
65998
65999
66000
66001
66002
66003
66004
66005
66006
66007
66008
66009
66010
66011
66012
66013
66014
66015
66016
66017
66018
66019
66020
66021
66022
66023
66024
66025
66026
66027
66028
66029
66030
66031
66032
66033
66034
66035
66036
66037
66038
66039
66040
66041
66042
66043
66044
66045
66046
66047
66048
66049
66050
66051
66052
66053
66054
66055
66056
66057
66058
66059
66060
66061
66062
66063
66064
66065
66066
66067
66068
66069
66070
66071
66072
66073
66074
66075
66076
66077
66078
66079
66080
66081
66082
66083
66084
66085
66086
66087
66088
66089
66090
66091
66092
66093
66094
66095
66096
66097
66098
66099
66100
66101
66102
66103
66104
66105
66106
66107
66108
66109
66110
66111
66112
66113
66114
66115
66116
66117
66118
66119
66120
66121
66122
66123
66124
66125
66126
66127
66128
66129
66130
66131
66132
66133
66134
66135
66136
66137
66138
66139
66140
66141
66142
66143
66144
66145
66146
66147
66148
66149
66150
66151
66152
66153
66154
66155
66156
66157
66158
66159
66160
66161
66162
66163
66164
66165
66166
66167
66168
66169
66170
66171
66172
66173
66174
66175
66176
66177
66178
66179
66180
66181
66182
66183
66184
66185
66186
66187
66188
66189
66190
66191
66192
66193
66194
66195
66196
66197
66198
66199
66200
66201
66202
66203
66204
66205
66206
66207
66208
66209
66210
66211
66212
66213
66214
66215
66216
66217
66218
66219
66220
66221
66222
66223
66224
66225
66226
66227
66228
66229
66230
66231
66232
66233
66234
66235
66236
66237
66238
66239
66240
66241
66242
66243
66244
66245
66246
66247
66248
66249
66250
66251
66252
66253
66254
66255
66256
66257
66258
66259
66260
66261
66262
66263
66264
66265
66266
66267
66268
66269
66270
66271
66272
66273
66274
66275
66276
66277
66278
66279
66280
66281
66282
66283
66284
66285
66286
66287
66288
66289
66290
66291
66292
66293
66294
66295
66296
66297
66298
66299
66300
66301
66302
66303
66304
66305
66306
66307
66308
66309
66310
66311
66312
66313
66314
66315
66316
66317
66318
66319
66320
66321
66322
66323
66324
66325
66326
66327
66328
66329
66330
66331
66332
66333
66334
66335
66336
66337
66338
66339
66340
66341
66342
66343
66344
66345
66346
66347
66348
66349
66350
66351
66352
66353
66354
66355
66356
66357
66358
66359
66360
66361
66362
66363
66364
66365
66366
66367
66368
66369
66370
66371
66372
66373
66374
66375
66376
66377
66378
66379
66380
66381
66382
66383
66384
66385
66386
66387
66388
66389
66390
66391
66392
66393
66394
66395
66396
66397
66398
66399
66400
66401
66402
66403
66404
66405
66406
66407
66408
66409
66410
66411
66412
66413
66414
66415
66416
66417
66418
66419
66420
66421
66422
66423
66424
66425
66426
66427
66428
66429
66430
66431
66432
66433
66434
66435
66436
66437
66438
66439
66440
66441
66442
66443
66444
66445
66446
66447
66448
66449
66450
66451
66452
66453
66454
66455
66456
66457
66458
66459
66460
66461
66462
66463
66464
66465
66466
66467
66468
66469
66470
66471
66472
66473
66474
66475
66476
66477
66478
66479
66480
66481
66482
66483
66484
66485
66486
66487
66488
66489
66490
66491
66492
66493
66494
66495
66496
66497
66498
66499
66500
66501
66502
66503
66504
66505
66506
66507
66508
66509
66510
66511
66512
66513
66514
66515
66516
66517
66518
66519
66520
66521
66522
66523
66524
66525
66526
66527
66528
66529
66530
66531
66532
66533
66534
66535
66536
66537
66538
66539
66540
66541
66542
66543
66544
66545
66546
66547
66548
66549
66550
66551
66552
66553
66554
66555
66556
66557
66558
66559
66560
66561
66562
66563
66564
66565
66566
66567
66568
66569
66570
66571
66572
66573
66574
66575
66576
66577
66578
66579
66580
66581
66582
66583
66584
66585
66586
66587
66588
66589
66590
66591
66592
66593
66594
66595
66596
66597
66598
66599
66600
66601
66602
66603
66604
66605
66606
66607
66608
66609
66610
66611
66612
66613
66614
66615
66616
66617
66618
66619
66620
66621
66622
66623
66624
66625
66626
66627
66628
66629
66630
66631
66632
66633
66634
66635
66636
66637
66638
66639
66640
66641
66642
66643
66644
66645
66646
66647
66648
66649
66650
66651
66652
66653
66654
66655
66656
66657
66658
66659
66660
66661
66662
66663
66664
66665
66666
66667
66668
66669
66670
66671
66672
66673
66674
66675
66676
66677
66678
66679
66680
66681
66682
66683
66684
66685
66686
66687
66688
66689
66690
66691
66692
66693
66694
66695
66696
66697
66698
66699
66700
66701
66702
66703
66704
66705
66706
66707
66708
66709
66710
66711
66712
66713
66714
66715
66716
66717
66718
66719
66720
66721
66722
66723
66724
66725
66726
66727
66728
66729
66730
66731
66732
66733
66734
66735
66736
66737
66738
66739
66740
66741
66742
66743
66744
66745
66746
66747
66748
66749
66750
66751
66752
66753
66754
66755
66756
66757
66758
66759
66760
66761
66762
66763
66764
66765
66766
66767
66768
66769
66770
66771
66772
66773
66774
66775
66776
66777
66778
66779
66780
66781
66782
66783
66784
66785
66786
66787
66788
66789
66790
66791
66792
66793
66794
66795
66796
66797
66798
66799
66800
66801
66802
66803
66804
66805
66806
66807
66808
66809
66810
66811
66812
66813
66814
66815
66816
66817
66818
66819
66820
66821
66822
66823
66824
66825
66826
66827
66828
66829
66830
66831
66832
66833
66834
66835
66836
66837
66838
66839
66840
66841
66842
66843
66844
66845
66846
66847
66848
66849
66850
66851
66852
66853
66854
66855
66856
66857
66858
66859
66860
66861
66862
66863
66864
66865
66866
66867
66868
66869
66870
66871
66872
66873
66874
66875
66876
66877
66878
66879
66880
66881
66882
66883
66884
66885
66886
66887
66888
66889
66890
66891
66892
66893
66894
66895
66896
66897
66898
66899
66900
66901
66902
66903
66904
66905
66906
66907
66908
66909
66910
66911
66912
66913
66914
66915
66916
66917
66918
66919
66920
66921
66922
66923
66924
66925
66926
66927
66928
66929
66930
66931
66932
66933
66934
66935
66936
66937
66938
66939
66940
66941
66942
66943
66944
66945
66946
66947
66948
66949
66950
66951
66952
66953
66954
66955
66956
66957
66958
66959
66960
66961
66962
66963
66964
66965
66966
66967
66968
66969
66970
66971
66972
66973
66974
66975
66976
66977
66978
66979
66980
66981
66982
66983
66984
66985
66986
66987
66988
66989
66990
66991
66992
66993
66994
66995
66996
66997
66998
66999
67000
67001
67002
67003
67004
67005
67006
67007
67008
67009
67010
67011
67012
67013
67014
67015
67016
67017
67018
67019
67020
67021
67022
67023
67024
67025
67026
67027
67028
67029
67030
67031
67032
67033
67034
67035
67036
67037
67038
67039
67040
67041
67042
67043
67044
67045
67046
67047
67048
67049
67050
67051
67052
67053
67054
67055
67056
67057
67058
67059
67060
67061
67062
67063
67064
67065
67066
67067
67068
67069
67070
67071
67072
67073
67074
67075
67076
67077
67078
67079
67080
67081
67082
67083
67084
67085
67086
67087
67088
67089
67090
67091
67092
67093
67094
67095
67096
67097
67098
67099
67100
67101
67102
67103
67104
67105
67106
67107
67108
67109
67110
67111
67112
67113
67114
67115
67116
67117
67118
67119
67120
67121
67122
67123
67124
67125
67126
67127
67128
67129
67130
67131
67132
67133
67134
67135
67136
67137
67138
67139
67140
67141
67142
67143
67144
67145
67146
67147
67148
67149
67150
67151
67152
67153
67154
67155
67156
67157
67158
67159
67160
67161
67162
67163
67164
67165
67166
67167
67168
67169
67170
67171
67172
67173
67174
67175
67176
67177
67178
67179
67180
67181
67182
67183
67184
67185
67186
67187
67188
67189
67190
67191
67192
67193
67194
67195
67196
67197
67198
67199
67200
67201
67202
67203
67204
67205
67206
67207
67208
67209
67210
67211
67212
67213
67214
67215
67216
67217
67218
67219
67220
67221
67222
67223
67224
67225
67226
67227
67228
67229
67230
67231
67232
67233
67234
67235
67236
67237
67238
67239
67240
67241
67242
67243
67244
67245
67246
67247
67248
67249
67250
67251
67252
67253
67254
67255
67256
67257
67258
67259
67260
67261
67262
67263
67264
67265
67266
67267
67268
67269
67270
67271
67272
67273
67274
67275
67276
67277
67278
67279
67280
67281
67282
67283
67284
67285
67286
67287
67288
67289
67290
67291
67292
67293
67294
67295
67296
67297
67298
67299
67300
67301
67302
67303
67304
67305
67306
67307
67308
67309
67310
67311
67312
67313
67314
67315
67316
67317
67318
67319
67320
67321
67322
67323
67324
67325
67326
67327
67328
67329
67330
67331
67332
67333
67334
67335
67336
67337
67338
67339
67340
67341
67342
67343
67344
67345
67346
67347
67348
67349
67350
67351
67352
67353
67354
67355
67356
67357
67358
67359
67360
67361
67362
67363
67364
67365
67366
67367
67368
67369
67370
67371
67372
67373
67374
67375
67376
67377
67378
67379
67380
67381
67382
67383
67384
67385
67386
67387
67388
67389
67390
67391
67392
67393
67394
67395
67396
67397
67398
67399
67400
67401
67402
67403
67404
67405
67406
67407
67408
67409
67410
67411
67412
67413
67414
67415
67416
67417
67418
67419
67420
67421
67422
67423
67424
67425
67426
67427
67428
67429
67430
67431
67432
67433
67434
67435
67436
67437
67438
67439
67440
67441
67442
67443
67444
67445
67446
67447
67448
67449
67450
67451
67452
67453
67454
67455
67456
67457
67458
67459
67460
67461
67462
67463
67464
67465
67466
67467
67468
67469
67470
67471
67472
67473
67474
67475
67476
67477
67478
67479
67480
67481
67482
67483
67484
67485
67486
67487
67488
67489
67490
67491
67492
67493
67494
67495
67496
67497
67498
67499
67500
67501
67502
67503
67504
67505
67506
67507
67508
67509
67510
67511
67512
67513
67514
67515
67516
67517
67518
67519
67520
67521
67522
67523
67524
67525
67526
67527
67528
67529
67530
67531
67532
67533
67534
67535
67536
67537
67538
67539
67540
67541
67542
67543
67544
67545
67546
67547
67548
67549
67550
67551
67552
67553
67554
67555
67556
67557
67558
67559
67560
67561
67562
67563
67564
67565
67566
67567
67568
67569
67570
67571
67572
67573
67574
67575
67576
67577
67578
67579
67580
67581
67582
67583
67584
67585
67586
67587
67588
67589
67590
67591
67592
67593
67594
67595
67596
67597
67598
67599
67600
67601
67602
67603
67604
67605
67606
67607
67608
67609
67610
67611
67612
67613
67614
67615
67616
67617
67618
67619
67620
67621
67622
67623
67624
67625
67626
67627
67628
67629
67630
67631
67632
67633
67634
67635
67636
67637
67638
67639
67640
67641
67642
67643
67644
67645
67646
67647
67648
67649
67650
67651
67652
67653
67654
67655
67656
67657
67658
67659
67660
67661
67662
67663
67664
67665
67666
67667
67668
67669
67670
67671
67672
67673
67674
67675
67676
67677
67678
67679
67680
67681
67682
67683
67684
67685
67686
67687
67688
67689
67690
67691
67692
67693
67694
67695
67696
67697
67698
67699
67700
67701
67702
67703
67704
67705
67706
67707
67708
67709
67710
67711
67712
67713
67714
67715
67716
67717
67718
67719
67720
67721
67722
67723
67724
67725
67726
67727
67728
67729
67730
67731
67732
67733
67734
67735
67736
67737
67738
67739
67740
67741
67742
67743
67744
67745
67746
67747
67748
67749
67750
67751
67752
67753
67754
67755
67756
67757
67758
67759
67760
67761
67762
67763
67764
67765
67766
67767
67768
67769
67770
67771
67772
67773
67774
67775
67776
67777
67778
67779
67780
67781
67782
67783
67784
67785
67786
67787
67788
67789
67790
67791
67792
67793
67794
67795
67796
67797
67798
67799
67800
67801
67802
67803
67804
67805
67806
67807
67808
67809
67810
67811
67812
67813
67814
67815
67816
67817
67818
67819
67820
67821
67822
67823
67824
67825
67826
67827
67828
67829
67830
67831
67832
67833
67834
67835
67836
67837
67838
67839
67840
67841
67842
67843
67844
67845
67846
67847
67848
67849
67850
67851
67852
67853
67854
67855
67856
67857
67858
67859
67860
67861
67862
67863
67864
67865
67866
67867
67868
67869
67870
67871
67872
67873
67874
67875
67876
67877
67878
67879
67880
67881
67882
67883
67884
67885
67886
67887
67888
67889
67890
67891
67892
67893
67894
67895
67896
67897
67898
67899
67900
67901
67902
67903
67904
67905
67906
67907
67908
67909
67910
67911
67912
67913
67914
67915
67916
67917
67918
67919
67920
67921
67922
67923
67924
67925
67926
67927
67928
67929
67930
67931
67932
67933
67934
67935
67936
67937
67938
67939
67940
67941
67942
67943
67944
67945
67946
67947
67948
67949
67950
67951
67952
67953
67954
67955
67956
67957
67958
67959
67960
67961
67962
67963
67964
67965
67966
67967
67968
67969
67970
67971
67972
67973
67974
67975
67976
67977
67978
67979
67980
67981
67982
67983
67984
67985
67986
67987
67988
67989
67990
67991
67992
67993
67994
67995
67996
67997
67998
67999
68000
68001
68002
68003
68004
68005
68006
68007
68008
68009
68010
68011
68012
68013
68014
68015
68016
68017
68018
68019
68020
68021
68022
68023
68024
68025
68026
68027
68028
68029
68030
68031
68032
68033
68034
68035
68036
68037
68038
68039
68040
68041
68042
68043
68044
68045
68046
68047
68048
68049
68050
68051
68052
68053
68054
68055
68056
68057
68058
68059
68060
68061
68062
68063
68064
68065
68066
68067
68068
68069
68070
68071
68072
68073
68074
68075
68076
68077
68078
68079
68080
68081
68082
68083
68084
68085
68086
68087
68088
68089
68090
68091
68092
68093
68094
68095
68096
68097
68098
68099
68100
68101
68102
68103
68104
68105
68106
68107
68108
68109
68110
68111
68112
68113
68114
68115
68116
68117
68118
68119
68120
68121
68122
68123
68124
68125
68126
68127
68128
68129
68130
68131
68132
68133
68134
68135
68136
68137
68138
68139
68140
68141
68142
68143
68144
68145
68146
68147
68148
68149
68150
68151
68152
68153
68154
68155
68156
68157
68158
68159
68160
68161
68162
68163
68164
68165
68166
68167
68168
68169
68170
68171
68172
68173
68174
68175
68176
68177
68178
68179
68180
68181
68182
68183
68184
68185
68186
68187
68188
68189
68190
68191
68192
68193
68194
68195
68196
68197
68198
68199
68200
68201
68202
68203
68204
68205
68206
68207
68208
68209
68210
68211
68212
68213
68214
68215
68216
68217
68218
68219
68220
68221
68222
68223
68224
68225
68226
68227
68228
68229
68230
68231
68232
68233
68234
68235
68236
68237
68238
68239
68240
68241
68242
68243
68244
68245
68246
68247
68248
68249
68250
68251
68252
68253
68254
68255
68256
68257
68258
68259
68260
68261
68262
68263
68264
68265
68266
68267
68268
68269
68270
68271
68272
68273
68274
68275
68276
68277
68278
68279
68280
68281
68282
68283
68284
68285
68286
68287
68288
68289
68290
68291
68292
68293
68294
68295
68296
68297
68298
68299
68300
68301
68302
68303
68304
68305
68306
68307
68308
68309
68310
68311
68312
68313
68314
68315
68316
68317
68318
68319
68320
68321
68322
68323
68324
68325
68326
68327
68328
68329
68330
68331
68332
68333
68334
68335
68336
68337
68338
68339
68340
68341
68342
68343
68344
68345
68346
68347
68348
68349
68350
68351
68352
68353
68354
68355
68356
68357
68358
68359
68360
68361
68362
68363
68364
68365
68366
68367
68368
68369
68370
68371
68372
68373
68374
68375
68376
68377
68378
68379
68380
68381
68382
68383
68384
68385
68386
68387
68388
68389
68390
68391
68392
68393
68394
68395
68396
68397
68398
68399
68400
68401
68402
68403
68404
68405
68406
68407
68408
68409
68410
68411
68412
68413
68414
68415
68416
68417
68418
68419
68420
68421
68422
68423
68424
68425
68426
68427
68428
68429
68430
68431
68432
68433
68434
68435
68436
68437
68438
68439
68440
68441
68442
68443
68444
68445
68446
68447
68448
68449
68450
68451
68452
68453
68454
68455
68456
68457
68458
68459
68460
68461
68462
68463
68464
68465
68466
68467
68468
68469
68470
68471
68472
68473
68474
68475
68476
68477
68478
68479
68480
68481
68482
68483
68484
68485
68486
68487
68488
68489
68490
68491
68492
68493
68494
68495
68496
68497
68498
68499
68500
68501
68502
68503
68504
68505
68506
68507
68508
68509
68510
68511
68512
68513
68514
68515
68516
68517
68518
68519
68520
68521
68522
68523
68524
68525
68526
68527
68528
68529
68530
68531
68532
68533
68534
68535
68536
68537
68538
68539
68540
68541
68542
68543
68544
68545
68546
68547
68548
68549
68550
68551
68552
68553
68554
68555
68556
68557
68558
68559
68560
68561
68562
68563
68564
68565
68566
68567
68568
68569
68570
68571
68572
68573
68574
68575
68576
68577
68578
68579
68580
68581
68582
68583
68584
68585
68586
68587
68588
68589
68590
68591
68592
68593
68594
68595
68596
68597
68598
68599
68600
68601
68602
68603
68604
68605
68606
68607
68608
68609
68610
68611
68612
68613
68614
68615
68616
68617
68618
68619
68620
68621
68622
68623
68624
68625
68626
68627
68628
68629
68630
68631
68632
68633
68634
68635
68636
68637
68638
68639
68640
68641
68642
68643
68644
68645
68646
68647
68648
68649
68650
68651
68652
68653
68654
68655
68656
68657
68658
68659
68660
68661
68662
68663
68664
68665
68666
68667
68668
68669
68670
68671
68672
68673
68674
68675
68676
68677
68678
68679
68680
68681
68682
68683
68684
68685
68686
68687
68688
68689
68690
68691
68692
68693
68694
68695
68696
68697
68698
68699
68700
68701
68702
68703
68704
68705
68706
68707
68708
68709
68710
68711
68712
68713
68714
68715
68716
68717
68718
68719
68720
68721
68722
68723
68724
68725
68726
68727
68728
68729
68730
68731
68732
68733
68734
68735
68736
68737
68738
68739
68740
68741
68742
68743
68744
68745
68746
68747
68748
68749
68750
68751
68752
68753
68754
68755
68756
68757
68758
68759
68760
68761
68762
68763
68764
68765
68766
68767
68768
68769
68770
68771
68772
68773
68774
68775
68776
68777
68778
68779
68780
68781
68782
68783
68784
68785
68786
68787
68788
68789
68790
68791
68792
68793
68794
68795
68796
68797
68798
68799
68800
68801
68802
68803
68804
68805
68806
68807
68808
68809
68810
68811
68812
68813
68814
68815
68816
68817
68818
68819
68820
68821
68822
68823
68824
68825
68826
68827
68828
68829
68830
68831
68832
68833
68834
68835
68836
68837
68838
68839
68840
68841
68842
68843
68844
68845
68846
68847
68848
68849
68850
68851
68852
68853
68854
68855
68856
68857
68858
68859
68860
68861
68862
68863
68864
68865
68866
68867
68868
68869
68870
68871
68872
68873
68874
68875
68876
68877
68878
68879
68880
68881
68882
68883
68884
68885
68886
68887
68888
68889
68890
68891
68892
68893
68894
68895
68896
68897
68898
68899
68900
68901
68902
68903
68904
68905
68906
68907
68908
68909
68910
68911
68912
68913
68914
68915
68916
68917
68918
68919
68920
68921
68922
68923
68924
68925
68926
68927
68928
68929
68930
68931
68932
68933
68934
68935
68936
68937
68938
68939
68940
68941
68942
68943
68944
68945
68946
68947
68948
68949
68950
68951
68952
68953
68954
68955
68956
68957
68958
68959
68960
68961
68962
68963
68964
68965
68966
68967
68968
68969
68970
68971
68972
68973
68974
68975
68976
68977
68978
68979
68980
68981
68982
68983
68984
68985
68986
68987
68988
68989
68990
68991
68992
68993
68994
68995
68996
68997
68998
68999
69000
69001
69002
69003
69004
69005
69006
69007
69008
69009
69010
69011
69012
69013
69014
69015
69016
69017
69018
69019
69020
69021
69022
69023
69024
69025
69026
69027
69028
69029
69030
69031
69032
69033
69034
69035
69036
69037
69038
69039
69040
69041
69042
69043
69044
69045
69046
69047
69048
69049
69050
69051
69052
69053
69054
69055
69056
69057
69058
69059
69060
69061
69062
69063
69064
69065
69066
69067
69068
69069
69070
69071
69072
69073
69074
69075
69076
69077
69078
69079
69080
69081
69082
69083
69084
69085
69086
69087
69088
69089
69090
69091
69092
69093
69094
69095
69096
69097
69098
69099
69100
69101
69102
69103
69104
69105
69106
69107
69108
69109
69110
69111
69112
69113
69114
69115
69116
69117
69118
69119
69120
69121
69122
69123
69124
69125
69126
69127
69128
69129
69130
69131
69132
69133
69134
69135
69136
69137
69138
69139
69140
69141
69142
69143
69144
69145
69146
69147
69148
69149
69150
69151
69152
69153
69154
69155
69156
69157
69158
69159
69160
69161
69162
69163
69164
69165
69166
69167
69168
69169
69170
69171
69172
69173
69174
69175
69176
69177
69178
69179
69180
69181
69182
69183
69184
69185
69186
69187
69188
69189
69190
69191
69192
69193
69194
69195
69196
69197
69198
69199
69200
69201
69202
69203
69204
69205
69206
69207
69208
69209
69210
69211
69212
69213
69214
69215
69216
69217
69218
69219
69220
69221
69222
69223
69224
69225
69226
69227
69228
69229
69230
69231
69232
69233
69234
69235
69236
69237
69238
69239
69240
69241
69242
69243
69244
69245
69246
69247
69248
69249
69250
69251
69252
69253
69254
69255
69256
69257
69258
69259
69260
69261
69262
69263
69264
69265
69266
69267
69268
69269
69270
69271
69272
69273
69274
69275
69276
69277
69278
69279
69280
69281
69282
69283
69284
69285
69286
69287
69288
69289
69290
69291
69292
69293
69294
69295
69296
69297
69298
69299
69300
69301
69302
69303
69304
69305
69306
69307
69308
69309
69310
69311
69312
69313
69314
69315
69316
69317
69318
69319
69320
69321
69322
69323
69324
69325
69326
69327
69328
69329
69330
69331
69332
69333
69334
69335
69336
69337
69338
69339
69340
69341
69342
69343
69344
69345
69346
69347
69348
69349
69350
69351
69352
69353
69354
69355
69356
69357
69358
69359
69360
69361
69362
69363
69364
69365
69366
69367
69368
69369
69370
69371
69372
69373
69374
69375
69376
69377
69378
69379
69380
69381
69382
69383
69384
69385
69386
69387
69388
69389
69390
69391
69392
69393
69394
69395
69396
69397
69398
69399
69400
69401
69402
69403
69404
69405
69406
69407
69408
69409
69410
69411
69412
69413
69414
69415
69416
69417
69418
69419
69420
69421
69422
69423
69424
69425
69426
69427
69428
69429
69430
69431
69432
69433
69434
69435
69436
69437
69438
69439
69440
69441
69442
69443
69444
69445
69446
69447
69448
69449
69450
69451
69452
69453
69454
69455
69456
69457
69458
69459
69460
69461
69462
69463
69464
69465
69466
69467
69468
69469
69470
69471
69472
69473
69474
69475
69476
69477
69478
69479
69480
69481
69482
69483
69484
69485
69486
69487
69488
69489
69490
69491
69492
69493
69494
69495
69496
69497
69498
69499
69500
69501
69502
69503
69504
69505
69506
69507
69508
69509
69510
69511
69512
69513
69514
69515
69516
69517
69518
69519
69520
69521
69522
69523
69524
69525
69526
69527
69528
69529
69530
69531
69532
69533
69534
69535
69536
69537
69538
69539
69540
69541
69542
69543
69544
69545
69546
69547
69548
69549
69550
69551
69552
69553
69554
69555
69556
69557
69558
69559
69560
69561
69562
69563
69564
69565
69566
69567
69568
69569
69570
69571
69572
69573
69574
69575
69576
69577
69578
69579
69580
69581
69582
69583
69584
69585
69586
69587
69588
69589
69590
69591
69592
69593
69594
69595
69596
69597
69598
69599
69600
69601
69602
69603
69604
69605
69606
69607
69608
69609
69610
69611
69612
69613
69614
69615
69616
69617
69618
69619
69620
69621
69622
69623
69624
69625
69626
69627
69628
69629
69630
69631
69632
69633
69634
69635
69636
69637
69638
69639
69640
69641
69642
69643
69644
69645
69646
69647
69648
69649
69650
69651
69652
69653
69654
69655
69656
69657
69658
69659
69660
69661
69662
69663
69664
69665
69666
69667
69668
69669
69670
69671
69672
69673
69674
69675
69676
69677
69678
69679
69680
69681
69682
69683
69684
69685
69686
69687
69688
69689
69690
69691
69692
69693
69694
69695
69696
69697
69698
69699
69700
69701
69702
69703
69704
69705
69706
69707
69708
69709
69710
69711
69712
69713
69714
69715
69716
69717
69718
69719
69720
69721
69722
69723
69724
69725
69726
69727
69728
69729
69730
69731
69732
69733
69734
69735
69736
69737
69738
69739
69740
69741
69742
69743
69744
69745
69746
69747
69748
69749
69750
69751
69752
69753
69754
69755
69756
69757
69758
69759
69760
69761
69762
69763
69764
69765
69766
69767
69768
69769
69770
69771
69772
69773
69774
69775
69776
69777
69778
69779
69780
69781
69782
69783
69784
69785
69786
69787
69788
69789
69790
69791
69792
69793
69794
69795
69796
69797
69798
69799
69800
69801
69802
69803
69804
69805
69806
69807
69808
69809
69810
69811
69812
69813
69814
69815
69816
69817
69818
69819
69820
69821
69822
69823
69824
69825
69826
69827
69828
69829
69830
69831
69832
69833
69834
69835
69836
69837
69838
69839
69840
69841
69842
69843
69844
69845
69846
69847
69848
69849
69850
69851
69852
69853
69854
69855
69856
69857
69858
69859
69860
69861
69862
69863
69864
69865
69866
69867
69868
69869
69870
69871
69872
69873
69874
69875
69876
69877
69878
69879
69880
69881
69882
69883
69884
69885
69886
69887
69888
69889
69890
69891
69892
69893
69894
69895
69896
69897
69898
69899
69900
69901
69902
69903
69904
69905
69906
69907
69908
69909
69910
69911
69912
69913
69914
69915
69916
69917
69918
69919
69920
69921
69922
69923
69924
69925
69926
69927
69928
69929
69930
69931
69932
69933
69934
69935
69936
69937
69938
69939
69940
69941
69942
69943
69944
69945
69946
69947
69948
69949
69950
69951
69952
69953
69954
69955
69956
69957
69958
69959
69960
69961
69962
69963
69964
69965
69966
69967
69968
69969
69970
69971
69972
69973
69974
69975
69976
69977
69978
69979
69980
69981
69982
69983
69984
69985
69986
69987
69988
69989
69990
69991
69992
69993
69994
69995
69996
69997
69998
69999
70000
70001
70002
70003
70004
70005
70006
70007
70008
70009
70010
70011
70012
70013
70014
70015
70016
70017
70018
70019
70020
70021
70022
70023
70024
70025
70026
70027
70028
70029
70030
70031
70032
70033
70034
70035
70036
70037
70038
70039
70040
70041
70042
70043
70044
70045
70046
70047
70048
70049
70050
70051
70052
70053
70054
70055
70056
70057
70058
70059
70060
70061
70062
70063
70064
70065
70066
70067
70068
70069
70070
70071
70072
70073
70074
70075
70076
70077
70078
70079
70080
70081
70082
70083
70084
70085
70086
70087
70088
70089
70090
70091
70092
70093
70094
70095
70096
70097
70098
70099
70100
70101
70102
70103
70104
70105
70106
70107
70108
70109
70110
70111
70112
70113
70114
70115
70116
70117
70118
70119
70120
70121
70122
70123
70124
70125
70126
70127
70128
70129
70130
70131
70132
70133
70134
70135
70136
70137
70138
70139
70140
70141
70142
70143
70144
70145
70146
70147
70148
70149
70150
70151
70152
70153
70154
70155
70156
70157
70158
70159
70160
70161
70162
70163
70164
70165
70166
70167
70168
70169
70170
70171
70172
70173
70174
70175
70176
70177
70178
70179
70180
70181
70182
70183
70184
70185
70186
70187
70188
70189
70190
70191
70192
70193
70194
70195
70196
70197
70198
70199
70200
70201
70202
70203
70204
70205
70206
70207
70208
70209
70210
70211
70212
70213
70214
70215
70216
70217
70218
70219
70220
70221
70222
70223
70224
70225
70226
70227
70228
70229
70230
70231
70232
70233
70234
70235
70236
70237
70238
70239
70240
70241
70242
70243
70244
70245
70246
70247
70248
70249
70250
70251
70252
70253
70254
70255
70256
70257
70258
70259
70260
70261
70262
70263
70264
70265
70266
70267
70268
70269
70270
70271
70272
70273
70274
70275
70276
70277
70278
70279
70280
70281
70282
70283
70284
70285
70286
70287
70288
70289
70290
70291
70292
70293
70294
70295
70296
70297
70298
70299
70300
70301
70302
70303
70304
70305
70306
70307
70308
70309
70310
70311
70312
70313
70314
70315
70316
70317
70318
70319
70320
70321
70322
70323
70324
70325
70326
70327
70328
70329
70330
70331
70332
70333
70334
70335
70336
70337
70338
70339
70340
70341
70342
70343
70344
70345
70346
70347
70348
70349
70350
70351
70352
70353
70354
70355
70356
70357
70358
70359
70360
70361
70362
70363
70364
70365
70366
70367
70368
70369
70370
70371
70372
70373
70374
70375
70376
70377
70378
70379
70380
70381
70382
70383
70384
70385
70386
70387
70388
70389
70390
70391
70392
70393
70394
70395
70396
70397
70398
70399
70400
70401
70402
70403
70404
70405
70406
70407
70408
70409
70410
70411
70412
70413
70414
70415
70416
70417
70418
70419
70420
70421
70422
70423
70424
70425
70426
70427
70428
70429
70430
70431
70432
70433
70434
70435
70436
70437
70438
70439
70440
70441
70442
70443
70444
70445
70446
70447
70448
70449
70450
70451
70452
70453
70454
70455
70456
70457
70458
70459
70460
70461
70462
70463
70464
70465
70466
70467
70468
70469
70470
70471
70472
70473
70474
70475
70476
70477
70478
70479
70480
70481
70482
70483
70484
70485
70486
70487
70488
70489
70490
70491
70492
70493
70494
70495
70496
70497
70498
70499
70500
70501
70502
70503
70504
70505
70506
70507
70508
70509
70510
70511
70512
70513
70514
70515
70516
70517
70518
70519
70520
70521
70522
70523
70524
70525
70526
70527
70528
70529
70530
70531
70532
70533
70534
70535
70536
70537
70538
70539
70540
70541
70542
70543
70544
70545
70546
70547
70548
70549
70550
70551
70552
70553
70554
70555
70556
70557
70558
70559
70560
70561
70562
70563
70564
70565
70566
70567
70568
70569
70570
70571
70572
70573
70574
70575
70576
70577
70578
70579
70580
70581
70582
70583
70584
70585
70586
70587
70588
70589
70590
70591
70592
70593
70594
70595
70596
70597
70598
70599
70600
70601
70602
70603
70604
70605
70606
70607
70608
70609
70610
70611
70612
70613
70614
70615
70616
70617
70618
70619
70620
70621
70622
70623
70624
70625
70626
70627
70628
70629
70630
70631
70632
70633
70634
70635
70636
70637
70638
70639
70640
70641
70642
70643
70644
70645
70646
70647
70648
70649
70650
70651
70652
70653
70654
70655
70656
70657
70658
70659
70660
70661
70662
70663
70664
70665
70666
70667
70668
70669
70670
70671
70672
70673
70674
70675
70676
70677
70678
70679
70680
70681
70682
70683
70684
70685
70686
70687
70688
70689
70690
70691
70692
70693
70694
70695
70696
70697
70698
70699
70700
70701
70702
70703
70704
70705
70706
70707
70708
70709
70710
70711
70712
70713
70714
70715
70716
70717
70718
70719
70720
70721
70722
70723
70724
70725
70726
70727
70728
70729
70730
70731
70732
70733
70734
70735
70736
70737
70738
70739
70740
70741
70742
70743
70744
70745
70746
70747
70748
70749
70750
70751
70752
70753
70754
70755
70756
70757
70758
70759
70760
70761
70762
70763
70764
70765
70766
70767
70768
70769
70770
70771
70772
70773
70774
70775
70776
70777
70778
70779
70780
70781
70782
70783
70784
70785
70786
70787
70788
70789
70790
70791
70792
70793
70794
70795
70796
70797
70798
70799
70800
70801
70802
70803
70804
70805
70806
70807
70808
70809
70810
70811
70812
70813
70814
70815
70816
70817
70818
70819
70820
70821
70822
70823
70824
70825
70826
70827
70828
70829
70830
70831
70832
70833
70834
70835
70836
70837
70838
70839
70840
70841
70842
70843
70844
70845
70846
70847
70848
70849
70850
70851
70852
70853
70854
70855
70856
70857
70858
70859
70860
70861
70862
70863
70864
70865
70866
70867
70868
70869
70870
70871
70872
70873
70874
70875
70876
70877
70878
70879
70880
70881
70882
70883
70884
70885
70886
70887
70888
70889
70890
70891
70892
70893
70894
70895
70896
70897
70898
70899
70900
70901
70902
70903
70904
70905
70906
70907
70908
70909
70910
70911
70912
70913
70914
70915
70916
70917
70918
70919
70920
70921
70922
70923
70924
70925
70926
70927
70928
70929
70930
70931
70932
70933
70934
70935
70936
70937
70938
70939
70940
70941
70942
70943
70944
70945
70946
70947
70948
70949
70950
70951
70952
70953
70954
70955
70956
70957
70958
70959
70960
70961
70962
70963
70964
70965
70966
70967
70968
70969
70970
70971
70972
70973
70974
70975
70976
70977
70978
70979
70980
70981
70982
70983
70984
70985
70986
70987
70988
70989
70990
70991
70992
70993
70994
70995
70996
70997
70998
70999
71000
71001
71002
71003
71004
71005
71006
71007
71008
71009
71010
71011
71012
71013
71014
71015
71016
71017
71018
71019
71020
71021
71022
71023
71024
71025
71026
71027
71028
71029
71030
71031
71032
71033
71034
71035
71036
71037
71038
71039
71040
71041
71042
71043
71044
71045
71046
71047
71048
71049
71050
71051
71052
71053
71054
71055
71056
71057
71058
71059
71060
71061
71062
71063
71064
71065
71066
71067
71068
71069
71070
71071
71072
71073
71074
71075
71076
71077
71078
71079
71080
71081
71082
71083
71084
71085
71086
71087
71088
71089
71090
71091
71092
71093
71094
71095
71096
71097
71098
71099
71100
71101
71102
71103
71104
71105
71106
71107
71108
71109
71110
71111
71112
71113
71114
71115
71116
71117
71118
71119
71120
71121
71122
71123
71124
71125
71126
71127
71128
71129
71130
71131
71132
71133
71134
71135
71136
71137
71138
71139
71140
71141
71142
71143
71144
71145
71146
71147
71148
71149
71150
71151
71152
71153
71154
71155
71156
71157
71158
71159
71160
71161
71162
71163
71164
71165
71166
71167
71168
71169
71170
71171
71172
71173
71174
71175
71176
71177
71178
71179
71180
71181
71182
71183
71184
71185
71186
71187
71188
71189
71190
71191
71192
71193
71194
71195
71196
71197
71198
71199
71200
71201
71202
71203
71204
71205
71206
71207
71208
71209
71210
71211
71212
71213
71214
71215
71216
71217
71218
71219
71220
71221
71222
71223
71224
71225
71226
71227
71228
71229
71230
71231
71232
71233
71234
71235
71236
71237
71238
71239
71240
71241
71242
71243
71244
71245
71246
71247
71248
71249
71250
71251
71252
71253
71254
71255
71256
71257
71258
71259
71260
71261
71262
71263
71264
71265
71266
71267
71268
71269
71270
71271
71272
71273
71274
71275
71276
71277
71278
71279
71280
71281
71282
71283
71284
71285
71286
71287
71288
71289
71290
71291
71292
71293
71294
71295
71296
71297
71298
71299
71300
71301
71302
71303
71304
71305
71306
71307
71308
71309
71310
71311
71312
71313
71314
71315
71316
71317
71318
71319
71320
71321
71322
71323
71324
71325
71326
71327
71328
71329
71330
71331
71332
71333
71334
71335
71336
71337
71338
71339
71340
71341
71342
71343
71344
71345
71346
71347
71348
71349
71350
71351
71352
71353
71354
71355
71356
71357
71358
71359
71360
71361
71362
71363
71364
71365
71366
71367
71368
71369
71370
71371
71372
71373
71374
71375
71376
71377
71378
71379
71380
71381
71382
71383
71384
71385
71386
71387
71388
71389
71390
71391
71392
71393
71394
71395
71396
71397
71398
71399
71400
71401
71402
71403
71404
71405
71406
71407
71408
71409
71410
71411
71412
71413
71414
71415
71416
71417
71418
71419
71420
71421
71422
71423
71424
71425
71426
71427
71428
71429
71430
71431
71432
71433
71434
71435
71436
71437
71438
71439
71440
71441
71442
71443
71444
71445
71446
71447
71448
71449
71450
71451
71452
71453
71454
71455
71456
71457
71458
71459
71460
71461
71462
71463
71464
71465
71466
71467
71468
71469
71470
71471
71472
71473
71474
71475
71476
71477
71478
71479
71480
71481
71482
71483
71484
71485
71486
71487
71488
71489
71490
71491
71492
71493
71494
71495
71496
71497
71498
71499
71500
71501
71502
71503
71504
71505
71506
71507
71508
71509
71510
71511
71512
71513
71514
71515
71516
71517
71518
71519
71520
71521
71522
71523
71524
71525
71526
71527
71528
71529
71530
71531
71532
71533
71534
71535
71536
71537
71538
71539
71540
71541
71542
71543
71544
71545
71546
71547
71548
71549
71550
71551
71552
71553
71554
71555
71556
71557
71558
71559
71560
71561
71562
71563
71564
71565
71566
71567
71568
71569
71570
71571
71572
71573
71574
71575
71576
71577
71578
71579
71580
71581
71582
71583
71584
71585
71586
71587
71588
71589
71590
71591
71592
71593
71594
71595
71596
71597
71598
71599
71600
71601
71602
71603
71604
71605
71606
71607
71608
71609
71610
71611
71612
71613
71614
71615
71616
71617
71618
71619
71620
71621
71622
71623
71624
71625
71626
71627
71628
71629
71630
71631
71632
71633
71634
71635
71636
71637
71638
71639
71640
71641
71642
71643
71644
71645
71646
71647
71648
71649
71650
71651
71652
71653
71654
71655
71656
71657
71658
71659
71660
71661
71662
71663
71664
71665
71666
71667
71668
71669
71670
71671
71672
71673
71674
71675
71676
71677
71678
71679
71680
71681
71682
71683
71684
71685
71686
71687
71688
71689
71690
71691
71692
71693
71694
71695
71696
71697
71698
71699
71700
71701
71702
71703
71704
71705
71706
71707
71708
71709
71710
71711
71712
71713
71714
71715
71716
71717
71718
71719
71720
71721
71722
71723
71724
71725
71726
71727
71728
71729
71730
71731
71732
71733
71734
71735
71736
71737
71738
71739
71740
71741
71742
71743
71744
71745
71746
71747
71748
71749
71750
71751
71752
71753
71754
71755
71756
71757
71758
71759
71760
71761
71762
71763
71764
71765
71766
71767
71768
71769
71770
71771
71772
71773
71774
71775
71776
71777
71778
71779
71780
71781
71782
71783
71784
71785
71786
71787
71788
71789
71790
71791
71792
71793
71794
71795
71796
71797
71798
71799
71800
71801
71802
71803
71804
71805
71806
71807
71808
71809
71810
71811
71812
71813
71814
71815
71816
71817
71818
71819
71820
71821
71822
71823
71824
71825
71826
71827
71828
71829
71830
71831
71832
71833
71834
71835
71836
71837
71838
71839
71840
71841
71842
71843
71844
71845
71846
71847
71848
71849
71850
71851
71852
71853
71854
71855
71856
71857
71858
71859
71860
71861
71862
71863
71864
71865
71866
71867
71868
71869
71870
71871
71872
71873
71874
71875
71876
71877
71878
71879
71880
71881
71882
71883
71884
71885
71886
71887
71888
71889
71890
71891
71892
71893
71894
71895
71896
71897
71898
71899
71900
71901
71902
71903
71904
71905
71906
71907
71908
71909
71910
71911
71912
71913
71914
71915
71916
71917
71918
71919
71920
71921
71922
71923
71924
71925
71926
71927
71928
71929
71930
71931
71932
71933
71934
71935
71936
71937
71938
71939
71940
71941
71942
71943
71944
71945
71946
71947
71948
71949
71950
71951
71952
71953
71954
71955
71956
71957
71958
71959
71960
71961
71962
71963
71964
71965
71966
71967
71968
71969
71970
71971
71972
71973
71974
71975
71976
71977
71978
71979
71980
71981
71982
71983
71984
71985
71986
71987
71988
71989
71990
71991
71992
71993
71994
71995
71996
71997
71998
71999
72000
72001
72002
72003
72004
72005
72006
72007
72008
72009
72010
72011
72012
72013
72014
72015
72016
72017
72018
72019
72020
72021
72022
72023
72024
72025
72026
72027
72028
72029
72030
72031
72032
72033
72034
72035
72036
72037
72038
72039
72040
72041
72042
72043
72044
72045
72046
72047
72048
72049
72050
72051
72052
72053
72054
72055
72056
72057
72058
72059
72060
72061
72062
72063
72064
72065
72066
72067
72068
72069
72070
72071
72072
72073
72074
72075
72076
72077
72078
72079
72080
72081
72082
72083
72084
72085
72086
72087
72088
72089
72090
72091
72092
72093
72094
72095
72096
72097
72098
72099
72100
72101
72102
72103
72104
72105
72106
72107
72108
72109
72110
72111
72112
72113
72114
72115
72116
72117
72118
72119
72120
72121
72122
72123
72124
72125
72126
72127
72128
72129
72130
72131
72132
72133
72134
72135
72136
72137
72138
72139
72140
72141
72142
72143
72144
72145
72146
72147
72148
72149
72150
72151
72152
72153
72154
72155
72156
72157
72158
72159
72160
72161
72162
72163
72164
72165
72166
72167
72168
72169
72170
72171
72172
72173
72174
72175
72176
72177
72178
72179
72180
72181
72182
72183
72184
72185
72186
72187
72188
72189
72190
72191
72192
72193
72194
72195
72196
72197
72198
72199
72200
72201
72202
72203
72204
72205
72206
72207
72208
72209
72210
72211
72212
72213
72214
72215
72216
72217
72218
72219
72220
72221
72222
72223
72224
72225
72226
72227
72228
72229
72230
72231
72232
72233
72234
72235
72236
72237
72238
72239
72240
72241
72242
72243
72244
72245
72246
72247
72248
72249
72250
72251
72252
72253
72254
72255
72256
72257
72258
72259
72260
72261
72262
72263
72264
72265
72266
72267
72268
72269
72270
72271
72272
72273
72274
72275
72276
72277
72278
72279
72280
72281
72282
72283
72284
72285
72286
72287
72288
72289
72290
72291
72292
72293
72294
72295
72296
72297
72298
72299
72300
72301
72302
72303
72304
72305
72306
72307
72308
72309
72310
72311
72312
72313
72314
72315
72316
72317
72318
72319
72320
72321
72322
72323
72324
72325
72326
72327
72328
72329
72330
72331
72332
72333
72334
72335
72336
72337
72338
72339
72340
72341
72342
72343
72344
72345
72346
72347
72348
72349
72350
72351
72352
72353
72354
72355
72356
72357
72358
72359
72360
72361
72362
72363
72364
72365
72366
72367
72368
72369
72370
72371
72372
72373
72374
72375
72376
72377
72378
72379
72380
72381
72382
72383
72384
72385
72386
72387
72388
72389
72390
72391
72392
72393
72394
72395
72396
72397
72398
72399
72400
72401
72402
72403
72404
72405
72406
72407
72408
72409
72410
72411
72412
72413
72414
72415
72416
72417
72418
72419
72420
72421
72422
72423
72424
72425
72426
72427
72428
72429
72430
72431
72432
72433
72434
72435
72436
72437
72438
72439
72440
72441
72442
72443
72444
72445
72446
72447
72448
72449
72450
72451
72452
72453
72454
72455
72456
72457
72458
72459
72460
72461
72462
72463
72464
72465
72466
72467
72468
72469
72470
72471
72472
72473
72474
72475
72476
72477
72478
72479
72480
72481
72482
72483
72484
72485
72486
72487
72488
72489
72490
72491
72492
72493
72494
72495
72496
72497
72498
72499
72500
72501
72502
72503
72504
72505
72506
72507
72508
72509
72510
72511
72512
72513
72514
72515
72516
72517
72518
72519
72520
72521
72522
72523
72524
72525
72526
72527
72528
72529
72530
72531
72532
72533
72534
72535
72536
72537
72538
72539
72540
72541
72542
72543
72544
72545
72546
72547
72548
72549
72550
72551
72552
72553
72554
72555
72556
72557
72558
72559
72560
72561
72562
72563
72564
72565
72566
72567
72568
72569
72570
72571
72572
72573
72574
72575
72576
72577
72578
72579
72580
72581
72582
72583
72584
72585
72586
72587
72588
72589
72590
72591
72592
72593
72594
72595
72596
72597
72598
72599
72600
72601
72602
72603
72604
72605
72606
72607
72608
72609
72610
72611
72612
72613
72614
72615
72616
72617
72618
72619
72620
72621
72622
72623
72624
72625
72626
72627
72628
72629
72630
72631
72632
72633
72634
72635
72636
72637
72638
72639
72640
72641
72642
72643
72644
72645
72646
72647
72648
72649
72650
72651
72652
72653
72654
72655
72656
72657
72658
72659
72660
72661
72662
72663
72664
72665
72666
72667
72668
72669
72670
72671
72672
72673
72674
72675
72676
72677
72678
72679
72680
72681
72682
72683
72684
72685
72686
72687
72688
72689
72690
72691
72692
72693
72694
72695
72696
72697
72698
72699
72700
72701
72702
72703
72704
72705
72706
72707
72708
72709
72710
72711
72712
72713
72714
72715
72716
72717
72718
72719
72720
72721
72722
72723
72724
72725
72726
72727
72728
72729
72730
72731
72732
72733
72734
72735
72736
72737
72738
72739
72740
72741
72742
72743
72744
72745
72746
72747
72748
72749
72750
72751
72752
72753
72754
72755
72756
72757
72758
72759
72760
72761
72762
72763
72764
72765
72766
72767
72768
72769
72770
72771
72772
72773
72774
72775
72776
72777
72778
72779
72780
72781
72782
72783
72784
72785
72786
72787
72788
72789
72790
72791
72792
72793
72794
72795
72796
72797
72798
72799
72800
72801
72802
72803
72804
72805
72806
72807
72808
72809
72810
72811
72812
72813
72814
72815
72816
72817
72818
72819
72820
72821
72822
72823
72824
72825
72826
72827
72828
72829
72830
72831
72832
72833
72834
72835
72836
72837
72838
72839
72840
72841
72842
72843
72844
72845
72846
72847
72848
72849
72850
72851
72852
72853
72854
72855
72856
72857
72858
72859
72860
72861
72862
72863
72864
72865
72866
72867
72868
72869
72870
72871
72872
72873
72874
72875
72876
72877
72878
72879
72880
72881
72882
72883
72884
72885
72886
72887
72888
72889
72890
72891
72892
72893
72894
72895
72896
72897
72898
72899
72900
72901
72902
72903
72904
72905
72906
72907
72908
72909
72910
72911
72912
72913
72914
72915
72916
72917
72918
72919
72920
72921
72922
72923
72924
72925
72926
72927
72928
72929
72930
72931
72932
72933
72934
72935
72936
72937
72938
72939
72940
72941
72942
72943
72944
72945
72946
72947
72948
72949
72950
72951
72952
72953
72954
72955
72956
72957
72958
72959
72960
72961
72962
72963
72964
72965
72966
72967
72968
72969
72970
72971
72972
72973
72974
72975
72976
72977
72978
72979
72980
72981
72982
72983
72984
72985
72986
72987
72988
72989
72990
72991
72992
72993
72994
72995
72996
72997
72998
72999
73000
73001
73002
73003
73004
73005
73006
73007
73008
73009
73010
73011
73012
73013
73014
73015
73016
73017
73018
73019
73020
73021
73022
73023
73024
73025
73026
73027
73028
73029
73030
73031
73032
73033
73034
73035
73036
73037
73038
73039
73040
73041
73042
73043
73044
73045
73046
73047
73048
73049
73050
73051
73052
73053
73054
73055
73056
73057
73058
73059
73060
73061
73062
73063
73064
73065
73066
73067
73068
73069
73070
73071
73072
73073
73074
73075
73076
73077
73078
73079
73080
73081
73082
73083
73084
73085
73086
73087
73088
73089
73090
73091
73092
73093
73094
73095
73096
73097
73098
73099
73100
73101
73102
73103
73104
73105
73106
73107
73108
73109
73110
73111
73112
73113
73114
73115
73116
73117
73118
73119
73120
73121
73122
73123
73124
73125
73126
73127
73128
73129
73130
73131
73132
73133
73134
73135
73136
73137
73138
73139
73140
73141
73142
73143
73144
73145
73146
73147
73148
73149
73150
73151
73152
73153
73154
73155
73156
73157
73158
73159
73160
73161
73162
73163
73164
73165
73166
73167
73168
73169
73170
73171
73172
73173
73174
73175
73176
73177
73178
73179
73180
73181
73182
73183
73184
73185
73186
73187
73188
73189
73190
73191
73192
73193
73194
73195
73196
73197
73198
73199
73200
73201
73202
73203
73204
73205
73206
73207
73208
73209
73210
73211
73212
73213
73214
73215
73216
73217
73218
73219
73220
73221
73222
73223
73224
73225
73226
73227
73228
73229
73230
73231
73232
73233
73234
73235
73236
73237
73238
73239
73240
73241
73242
73243
73244
73245
73246
73247
73248
73249
73250
73251
73252
73253
73254
73255
73256
73257
73258
73259
73260
73261
73262
73263
73264
73265
73266
73267
73268
73269
73270
73271
73272
73273
73274
73275
73276
73277
73278
73279
73280
73281
73282
73283
73284
73285
73286
73287
73288
73289
73290
73291
73292
73293
73294
73295
73296
73297
73298
73299
73300
73301
73302
73303
73304
73305
73306
73307
73308
73309
73310
73311
73312
73313
73314
73315
73316
73317
73318
73319
73320
73321
73322
73323
73324
73325
73326
73327
73328
73329
73330
73331
73332
73333
73334
73335
73336
73337
73338
73339
73340
73341
73342
73343
73344
73345
73346
73347
73348
73349
73350
73351
73352
73353
73354
73355
73356
73357
73358
73359
73360
73361
73362
73363
73364
73365
73366
73367
73368
73369
73370
73371
73372
73373
73374
73375
73376
73377
73378
73379
73380
73381
73382
73383
73384
73385
73386
73387
73388
73389
73390
73391
73392
73393
73394
73395
73396
73397
73398
73399
73400
73401
73402
73403
73404
73405
73406
73407
73408
73409
73410
73411
73412
73413
73414
73415
73416
73417
73418
73419
73420
73421
73422
73423
73424
73425
73426
73427
73428
73429
73430
73431
73432
73433
73434
73435
73436
73437
73438
73439
73440
73441
73442
73443
73444
73445
73446
73447
73448
73449
73450
73451
73452
73453
73454
73455
73456
73457
73458
73459
73460
73461
73462
73463
73464
73465
73466
73467
73468
73469
73470
73471
73472
73473
73474
73475
73476
73477
73478
73479
73480
73481
73482
73483
73484
73485
73486
73487
73488
73489
73490
73491
73492
73493
73494
73495
73496
73497
73498
73499
73500
73501
73502
73503
73504
73505
73506
73507
73508
73509
73510
73511
73512
73513
73514
73515
73516
73517
73518
73519
73520
73521
73522
73523
73524
73525
73526
73527
73528
73529
73530
73531
73532
73533
73534
73535
73536
73537
73538
73539
73540
73541
73542
73543
73544
73545
73546
73547
73548
73549
73550
73551
73552
73553
73554
73555
73556
73557
73558
73559
73560
73561
73562
73563
73564
73565
73566
73567
73568
73569
73570
73571
73572
73573
73574
73575
73576
73577
73578
73579
73580
73581
73582
73583
73584
73585
73586
73587
73588
73589
73590
73591
73592
73593
73594
73595
73596
73597
73598
73599
73600
73601
73602
73603
73604
73605
73606
73607
73608
73609
73610
73611
73612
73613
73614
73615
73616
73617
73618
73619
73620
73621
73622
73623
73624
73625
73626
73627
73628
73629
73630
73631
73632
73633
73634
73635
73636
73637
73638
73639
73640
73641
73642
73643
73644
73645
73646
73647
73648
73649
73650
73651
73652
73653
73654
73655
73656
73657
73658
73659
73660
73661
73662
73663
73664
73665
73666
73667
73668
73669
73670
73671
73672
73673
73674
73675
73676
73677
73678
73679
73680
73681
73682
73683
73684
73685
73686
73687
73688
73689
73690
73691
73692
73693
73694
73695
73696
73697
73698
73699
73700
73701
73702
73703
73704
73705
73706
73707
73708
73709
73710
73711
73712
73713
73714
73715
73716
73717
73718
73719
73720
73721
73722
73723
73724
73725
73726
73727
73728
73729
73730
73731
73732
73733
73734
73735
73736
73737
73738
73739
73740
73741
73742
73743
73744
73745
73746
73747
73748
73749
73750
73751
73752
73753
73754
73755
73756
73757
73758
73759
73760
73761
73762
73763
73764
73765
73766
73767
73768
73769
73770
73771
73772
73773
73774
73775
73776
73777
73778
73779
73780
73781
73782
73783
73784
73785
73786
73787
73788
73789
73790
73791
73792
73793
73794
73795
73796
73797
73798
73799
73800
73801
73802
73803
73804
73805
73806
73807
73808
73809
73810
73811
73812
73813
73814
73815
73816
73817
73818
73819
73820
73821
73822
73823
73824
73825
73826
73827
73828
73829
73830
73831
73832
73833
73834
73835
73836
73837
73838
73839
73840
73841
73842
73843
73844
73845
73846
73847
73848
73849
73850
73851
73852
73853
73854
73855
73856
73857
73858
73859
73860
73861
73862
73863
73864
73865
73866
73867
73868
73869
73870
73871
73872
73873
73874
73875
73876
73877
73878
73879
73880
73881
73882
73883
73884
73885
73886
73887
73888
73889
73890
73891
73892
73893
73894
73895
73896
73897
73898
73899
73900
73901
73902
73903
73904
73905
73906
73907
73908
73909
73910
73911
73912
73913
73914
73915
73916
73917
73918
73919
73920
73921
73922
73923
73924
73925
73926
73927
73928
73929
73930
73931
73932
73933
73934
73935
73936
73937
73938
73939
73940
73941
73942
73943
73944
73945
73946
73947
73948
73949
73950
73951
73952
73953
73954
73955
73956
73957
73958
73959
73960
73961
73962
73963
73964
73965
73966
73967
73968
73969
73970
73971
73972
73973
73974
73975
73976
73977
73978
73979
73980
73981
73982
73983
73984
73985
73986
73987
73988
73989
73990
73991
73992
73993
73994
73995
73996
73997
73998
73999
74000
74001
74002
74003
74004
74005
74006
74007
74008
74009
74010
74011
74012
74013
74014
74015
74016
74017
74018
74019
74020
74021
74022
74023
74024
74025
74026
74027
74028
74029
74030
74031
74032
74033
74034
74035
74036
74037
74038
74039
74040
74041
74042
74043
74044
74045
74046
74047
74048
74049
74050
74051
74052
74053
74054
74055
74056
74057
74058
74059
74060
74061
74062
74063
74064
74065
74066
74067
74068
74069
74070
74071
74072
74073
74074
74075
74076
74077
74078
74079
74080
74081
74082
74083
74084
74085
74086
74087
74088
74089
74090
74091
74092
74093
74094
74095
74096
74097
74098
74099
74100
74101
74102
74103
74104
74105
74106
74107
74108
74109
74110
74111
74112
74113
74114
74115
74116
74117
74118
74119
74120
74121
74122
74123
74124
74125
74126
74127
74128
74129
74130
74131
74132
74133
74134
74135
74136
74137
74138
74139
74140
74141
74142
74143
74144
74145
74146
74147
74148
74149
74150
74151
74152
74153
74154
74155
74156
74157
74158
74159
74160
74161
74162
74163
74164
74165
74166
74167
74168
74169
74170
74171
74172
74173
74174
74175
74176
74177
74178
74179
74180
74181
74182
74183
74184
74185
74186
74187
74188
74189
74190
74191
74192
74193
74194
74195
74196
74197
74198
74199
74200
74201
74202
74203
74204
74205
74206
74207
74208
74209
74210
74211
74212
74213
74214
74215
74216
74217
74218
74219
74220
74221
74222
74223
74224
74225
74226
74227
74228
74229
74230
74231
74232
74233
74234
74235
74236
74237
74238
74239
74240
74241
74242
74243
74244
74245
74246
74247
74248
74249
74250
74251
74252
74253
74254
74255
74256
74257
74258
74259
74260
74261
74262
74263
74264
74265
74266
74267
74268
74269
74270
74271
74272
74273
74274
74275
74276
74277
74278
74279
74280
74281
74282
74283
74284
74285
74286
74287
74288
74289
74290
74291
74292
74293
74294
74295
74296
74297
74298
74299
74300
74301
74302
74303
74304
74305
74306
74307
74308
74309
74310
74311
74312
74313
74314
74315
74316
74317
74318
74319
74320
74321
74322
74323
74324
74325
74326
74327
74328
74329
74330
74331
74332
74333
74334
74335
74336
74337
74338
74339
74340
74341
74342
74343
74344
74345
74346
74347
74348
74349
74350
74351
74352
74353
74354
74355
74356
74357
74358
74359
74360
74361
74362
74363
74364
74365
74366
74367
74368
74369
74370
74371
74372
74373
74374
74375
74376
74377
74378
74379
74380
74381
74382
74383
74384
74385
74386
74387
74388
74389
74390
74391
74392
74393
74394
74395
74396
74397
74398
74399
74400
74401
74402
74403
74404
74405
74406
74407
74408
74409
74410
74411
74412
74413
74414
74415
74416
74417
74418
74419
74420
74421
74422
74423
74424
74425
74426
74427
74428
74429
74430
74431
74432
74433
74434
74435
74436
74437
74438
74439
74440
74441
74442
74443
74444
74445
74446
74447
74448
74449
74450
74451
74452
74453
74454
74455
74456
74457
74458
74459
74460
74461
74462
74463
74464
74465
74466
74467
74468
74469
74470
74471
74472
74473
74474
74475
74476
74477
74478
74479
74480
74481
74482
74483
74484
74485
74486
74487
74488
74489
74490
74491
74492
74493
74494
74495
74496
74497
74498
74499
74500
74501
74502
74503
74504
74505
74506
74507
74508
74509
74510
74511
74512
74513
74514
74515
74516
74517
74518
74519
74520
74521
74522
74523
74524
74525
74526
74527
74528
74529
74530
74531
74532
74533
74534
74535
74536
74537
74538
74539
74540
74541
74542
74543
74544
74545
74546
74547
74548
74549
74550
74551
74552
74553
74554
74555
74556
74557
74558
74559
74560
74561
74562
74563
74564
74565
74566
74567
74568
74569
74570
74571
74572
74573
74574
74575
74576
74577
74578
74579
74580
74581
74582
74583
74584
74585
74586
74587
74588
74589
74590
74591
74592
74593
74594
74595
74596
74597
74598
74599
74600
74601
74602
74603
74604
74605
74606
74607
74608
74609
74610
74611
74612
74613
74614
74615
74616
74617
74618
74619
74620
74621
74622
74623
74624
74625
74626
74627
74628
74629
74630
74631
74632
74633
74634
74635
74636
74637
74638
74639
74640
74641
74642
74643
74644
74645
74646
74647
74648
74649
74650
74651
74652
74653
74654
74655
74656
74657
74658
74659
74660
74661
74662
74663
74664
74665
74666
74667
74668
74669
74670
74671
74672
74673
74674
74675
74676
74677
74678
74679
74680
74681
74682
74683
74684
74685
74686
74687
74688
74689
74690
74691
74692
74693
74694
74695
74696
74697
74698
74699
74700
74701
74702
74703
74704
74705
74706
74707
74708
74709
74710
74711
74712
74713
74714
74715
74716
74717
74718
74719
74720
74721
74722
74723
74724
74725
74726
74727
74728
74729
74730
74731
74732
74733
74734
74735
74736
74737
74738
74739
74740
74741
74742
74743
74744
74745
74746
74747
74748
74749
74750
74751
74752
74753
74754
74755
74756
74757
74758
74759
74760
74761
74762
74763
74764
74765
74766
74767
74768
74769
74770
74771
74772
74773
74774
74775
74776
74777
74778
74779
74780
74781
74782
74783
74784
74785
74786
74787
74788
74789
74790
74791
74792
74793
74794
74795
74796
74797
74798
74799
74800
74801
74802
74803
74804
74805
74806
74807
74808
74809
74810
74811
74812
74813
74814
74815
74816
74817
74818
74819
74820
74821
74822
74823
74824
74825
74826
74827
74828
74829
74830
74831
74832
74833
74834
74835
74836
74837
74838
74839
74840
74841
74842
74843
74844
74845
74846
74847
74848
74849
74850
74851
74852
74853
74854
74855
74856
74857
74858
74859
74860
74861
74862
74863
74864
74865
74866
74867
74868
74869
74870
74871
74872
74873
74874
74875
74876
74877
74878
74879
74880
74881
74882
74883
74884
74885
74886
74887
74888
74889
74890
74891
74892
74893
74894
74895
74896
74897
74898
74899
74900
74901
74902
74903
74904
74905
74906
74907
74908
74909
74910
74911
74912
74913
74914
74915
74916
74917
74918
74919
74920
74921
74922
74923
74924
74925
74926
74927
74928
74929
74930
74931
74932
74933
74934
74935
74936
74937
74938
74939
74940
74941
74942
74943
74944
74945
74946
74947
74948
74949
74950
74951
74952
74953
74954
74955
74956
74957
74958
74959
74960
74961
74962
74963
74964
74965
74966
74967
74968
74969
74970
74971
74972
74973
74974
74975
74976
74977
74978
74979
74980
74981
74982
74983
74984
74985
74986
74987
74988
74989
74990
74991
74992
74993
74994
74995
74996
74997
74998
74999
75000
75001
75002
75003
75004
75005
75006
75007
75008
75009
75010
75011
75012
75013
75014
75015
75016
75017
75018
75019
75020
75021
75022
75023
75024
75025
75026
75027
75028
75029
75030
75031
75032
75033
75034
75035
75036
75037
75038
75039
75040
75041
75042
75043
75044
75045
75046
75047
75048
75049
75050
75051
75052
75053
75054
75055
75056
75057
75058
75059
75060
75061
75062
75063
75064
75065
75066
75067
75068
75069
75070
75071
75072
75073
75074
75075
75076
75077
75078
75079
75080
75081
75082
75083
75084
75085
75086
75087
75088
75089
75090
75091
75092
75093
75094
75095
75096
75097
75098
75099
75100
75101
75102
75103
75104
75105
75106
75107
75108
75109
75110
75111
75112
75113
75114
75115
75116
75117
75118
75119
75120
75121
75122
75123
75124
75125
75126
75127
75128
75129
75130
75131
75132
75133
75134
75135
75136
75137
75138
75139
75140
75141
75142
75143
75144
75145
75146
75147
75148
75149
75150
75151
75152
75153
75154
75155
75156
75157
75158
75159
75160
75161
75162
75163
75164
75165
75166
75167
75168
75169
75170
75171
75172
75173
75174
75175
75176
75177
75178
75179
75180
75181
75182
75183
75184
75185
75186
75187
75188
75189
75190
75191
75192
75193
75194
75195
75196
75197
75198
75199
75200
75201
75202
75203
75204
75205
75206
75207
75208
75209
75210
75211
75212
75213
75214
75215
75216
75217
75218
75219
75220
75221
75222
75223
75224
75225
75226
75227
75228
75229
75230
75231
75232
75233
75234
75235
75236
75237
75238
75239
75240
75241
75242
75243
75244
75245
75246
75247
75248
75249
75250
75251
75252
75253
75254
75255
75256
75257
75258
75259
75260
75261
75262
75263
75264
75265
75266
75267
75268
75269
75270
75271
75272
75273
75274
75275
75276
75277
75278
75279
75280
75281
75282
75283
75284
75285
75286
75287
75288
75289
75290
75291
75292
75293
75294
75295
75296
75297
75298
75299
75300
75301
75302
75303
75304
75305
75306
75307
75308
75309
75310
75311
75312
75313
75314
75315
75316
75317
75318
75319
75320
75321
75322
75323
75324
75325
75326
75327
75328
75329
75330
75331
75332
75333
75334
75335
75336
75337
75338
75339
75340
75341
75342
75343
75344
75345
75346
75347
75348
75349
75350
75351
75352
75353
75354
75355
75356
75357
75358
75359
75360
75361
75362
75363
75364
75365
75366
75367
75368
75369
75370
75371
75372
75373
75374
75375
75376
75377
75378
75379
75380
75381
75382
75383
75384
75385
75386
75387
75388
75389
75390
75391
75392
75393
75394
75395
75396
75397
75398
75399
75400
75401
75402
75403
75404
75405
75406
75407
75408
75409
75410
75411
75412
75413
75414
75415
75416
75417
75418
75419
75420
75421
75422
75423
75424
75425
75426
75427
75428
75429
75430
75431
75432
75433
75434
75435
75436
75437
75438
75439
75440
75441
75442
75443
75444
75445
75446
75447
75448
75449
75450
75451
75452
75453
75454
75455
75456
75457
75458
75459
75460
75461
75462
75463
75464
75465
75466
75467
75468
75469
75470
75471
75472
75473
75474
75475
75476
75477
75478
75479
75480
75481
75482
75483
75484
75485
75486
75487
75488
75489
75490
75491
75492
75493
75494
75495
75496
75497
75498
75499
75500
75501
75502
75503
75504
75505
75506
75507
75508
75509
75510
75511
75512
75513
75514
75515
75516
75517
75518
75519
75520
75521
75522
75523
75524
75525
75526
75527
75528
75529
75530
75531
75532
75533
75534
75535
75536
75537
75538
75539
75540
75541
75542
75543
75544
75545
75546
75547
75548
75549
75550
75551
75552
75553
75554
75555
75556
75557
75558
75559
75560
75561
75562
75563
75564
75565
75566
75567
75568
75569
75570
75571
75572
75573
75574
75575
75576
75577
75578
75579
75580
75581
75582
75583
75584
75585
75586
75587
75588
75589
75590
75591
75592
75593
75594
75595
75596
75597
75598
75599
75600
75601
75602
75603
75604
75605
75606
75607
75608
75609
75610
75611
75612
75613
75614
75615
75616
75617
75618
75619
75620
75621
75622
75623
75624
75625
75626
75627
75628
75629
75630
75631
75632
75633
75634
75635
75636
75637
75638
75639
75640
75641
75642
75643
75644
75645
75646
75647
75648
75649
75650
75651
75652
75653
75654
75655
75656
75657
75658
75659
75660
75661
75662
75663
75664
75665
75666
75667
75668
75669
75670
75671
75672
75673
75674
75675
75676
75677
75678
75679
75680
75681
75682
75683
75684
75685
75686
75687
75688
75689
75690
75691
75692
75693
75694
75695
75696
75697
75698
75699
75700
75701
75702
75703
75704
75705
75706
75707
75708
75709
75710
75711
75712
75713
75714
75715
75716
75717
75718
75719
75720
75721
75722
75723
75724
75725
75726
75727
75728
75729
75730
75731
75732
75733
75734
75735
75736
75737
75738
75739
75740
75741
75742
75743
75744
75745
75746
75747
75748
75749
75750
75751
75752
75753
75754
75755
75756
75757
75758
75759
75760
75761
75762
75763
75764
75765
75766
75767
75768
75769
75770
75771
75772
75773
75774
75775
75776
75777
75778
75779
75780
75781
75782
75783
75784
75785
75786
75787
75788
75789
75790
75791
75792
75793
75794
75795
75796
75797
75798
75799
75800
75801
75802
75803
75804
75805
75806
75807
75808
75809
75810
75811
75812
75813
75814
75815
75816
75817
75818
75819
75820
75821
75822
75823
75824
75825
75826
75827
75828
75829
75830
75831
75832
75833
75834
75835
75836
75837
75838
75839
75840
75841
75842
75843
75844
75845
75846
75847
75848
75849
75850
75851
75852
75853
75854
75855
75856
75857
75858
75859
75860
75861
75862
75863
75864
75865
75866
75867
75868
75869
75870
75871
75872
75873
75874
75875
75876
75877
75878
75879
75880
75881
75882
75883
75884
75885
75886
75887
75888
75889
75890
75891
75892
75893
75894
75895
75896
75897
75898
75899
75900
75901
75902
75903
75904
75905
75906
75907
75908
75909
75910
75911
75912
75913
75914
75915
75916
75917
75918
75919
75920
75921
75922
75923
75924
75925
75926
75927
75928
75929
75930
75931
75932
75933
75934
75935
75936
75937
75938
75939
75940
75941
75942
75943
75944
75945
75946
75947
75948
75949
75950
75951
75952
75953
75954
75955
75956
75957
75958
75959
75960
75961
75962
75963
75964
75965
75966
75967
75968
75969
75970
75971
75972
75973
75974
75975
75976
75977
75978
75979
75980
75981
75982
75983
75984
75985
75986
75987
75988
75989
75990
75991
75992
75993
75994
75995
75996
75997
75998
75999
76000
76001
76002
76003
76004
76005
76006
76007
76008
76009
76010
76011
76012
76013
76014
76015
76016
76017
76018
76019
76020
76021
76022
76023
76024
76025
76026
76027
76028
76029
76030
76031
76032
76033
76034
76035
76036
76037
76038
76039
76040
76041
76042
76043
76044
76045
76046
76047
76048
76049
76050
76051
76052
76053
76054
76055
76056
76057
76058
76059
76060
76061
76062
76063
76064
76065
76066
76067
76068
76069
76070
76071
76072
76073
76074
76075
76076
76077
76078
76079
76080
76081
76082
76083
76084
76085
76086
76087
76088
76089
76090
76091
76092
76093
76094
76095
76096
76097
76098
76099
76100
76101
76102
76103
76104
76105
76106
76107
76108
76109
76110
76111
76112
76113
76114
76115
76116
76117
76118
76119
76120
76121
76122
76123
76124
76125
76126
76127
76128
76129
76130
76131
76132
76133
76134
76135
76136
76137
76138
76139
76140
76141
76142
76143
76144
76145
76146
76147
76148
76149
76150
76151
76152
76153
76154
76155
76156
76157
76158
76159
76160
76161
76162
76163
76164
76165
76166
76167
76168
76169
76170
76171
76172
76173
76174
76175
76176
76177
76178
76179
76180
76181
76182
76183
76184
76185
76186
76187
76188
76189
76190
76191
76192
76193
76194
76195
76196
76197
76198
76199
76200
76201
76202
76203
76204
76205
76206
76207
76208
76209
76210
76211
76212
76213
76214
76215
76216
76217
76218
76219
76220
76221
76222
76223
76224
76225
76226
76227
76228
76229
76230
76231
76232
76233
76234
76235
76236
76237
76238
76239
76240
76241
76242
76243
76244
76245
76246
76247
76248
76249
76250
76251
76252
76253
76254
76255
76256
76257
76258
76259
76260
76261
76262
76263
76264
76265
76266
76267
76268
76269
76270
76271
76272
76273
76274
76275
76276
76277
76278
76279
76280
76281
76282
76283
76284
76285
76286
76287
76288
76289
76290
76291
76292
76293
76294
76295
76296
76297
76298
76299
76300
76301
76302
76303
76304
76305
76306
76307
76308
76309
76310
76311
76312
76313
76314
76315
76316
76317
76318
76319
76320
76321
76322
76323
76324
76325
76326
76327
76328
76329
76330
76331
76332
76333
76334
76335
76336
76337
76338
76339
76340
76341
76342
76343
76344
76345
76346
76347
76348
76349
76350
76351
76352
76353
76354
76355
76356
76357
76358
76359
76360
76361
76362
76363
76364
76365
76366
76367
76368
76369
76370
76371
76372
76373
76374
76375
76376
76377
76378
76379
76380
76381
76382
76383
76384
76385
76386
76387
76388
76389
76390
76391
76392
76393
76394
76395
76396
76397
76398
76399
76400
76401
76402
76403
76404
76405
76406
76407
76408
76409
76410
76411
76412
76413
76414
76415
76416
76417
76418
76419
76420
76421
76422
76423
76424
76425
76426
76427
76428
76429
76430
76431
76432
76433
76434
76435
76436
76437
76438
76439
76440
76441
76442
76443
76444
76445
76446
76447
76448
76449
76450
76451
76452
76453
76454
76455
76456
76457
76458
76459
76460
76461
76462
76463
76464
76465
76466
76467
76468
76469
76470
76471
76472
76473
76474
76475
76476
76477
76478
76479
76480
76481
76482
76483
76484
76485
76486
76487
76488
76489
76490
76491
76492
76493
76494
76495
76496
76497
76498
76499
76500
76501
76502
76503
76504
76505
76506
76507
76508
76509
76510
76511
76512
76513
76514
76515
76516
76517
76518
76519
76520
76521
76522
76523
76524
76525
76526
76527
76528
76529
76530
76531
76532
76533
76534
76535
76536
76537
76538
76539
76540
76541
76542
76543
76544
76545
76546
76547
76548
76549
76550
76551
76552
76553
76554
76555
76556
76557
76558
76559
76560
76561
76562
76563
76564
76565
76566
76567
76568
76569
76570
76571
76572
76573
76574
76575
76576
76577
76578
76579
76580
76581
76582
76583
76584
76585
76586
76587
76588
76589
76590
76591
76592
76593
76594
76595
76596
76597
76598
76599
76600
76601
76602
76603
76604
76605
76606
76607
76608
76609
76610
76611
76612
76613
76614
76615
76616
76617
76618
76619
76620
76621
76622
76623
76624
76625
76626
76627
76628
76629
76630
76631
76632
76633
76634
76635
76636
76637
76638
76639
76640
76641
76642
76643
76644
76645
76646
76647
76648
76649
76650
76651
76652
76653
76654
76655
76656
76657
76658
76659
76660
76661
76662
76663
76664
76665
76666
76667
76668
76669
76670
76671
76672
76673
76674
76675
76676
76677
76678
76679
76680
76681
76682
76683
76684
76685
76686
76687
76688
76689
76690
76691
76692
76693
76694
76695
76696
76697
76698
76699
76700
76701
76702
76703
76704
76705
76706
76707
76708
76709
76710
76711
76712
76713
76714
76715
76716
76717
76718
76719
76720
76721
76722
76723
76724
76725
76726
76727
76728
76729
76730
76731
76732
76733
76734
76735
76736
76737
76738
76739
76740
76741
76742
76743
76744
76745
76746
76747
76748
76749
76750
76751
76752
76753
76754
76755
76756
76757
76758
76759
76760
76761
76762
76763
76764
76765
76766
76767
76768
76769
76770
76771
76772
76773
76774
76775
76776
76777
76778
76779
76780
76781
76782
76783
76784
76785
76786
76787
76788
76789
76790
76791
76792
76793
76794
76795
76796
76797
76798
76799
76800
76801
76802
76803
76804
76805
76806
76807
76808
76809
76810
76811
76812
76813
76814
76815
76816
76817
76818
76819
76820
76821
76822
76823
76824
76825
76826
76827
76828
76829
76830
76831
76832
76833
76834
76835
76836
76837
76838
76839
76840
76841
76842
76843
76844
76845
76846
76847
76848
76849
76850
76851
76852
76853
76854
76855
76856
76857
76858
76859
76860
76861
76862
76863
76864
76865
76866
76867
76868
76869
76870
76871
76872
76873
76874
76875
76876
76877
76878
76879
76880
76881
76882
76883
76884
76885
76886
76887
76888
76889
76890
76891
76892
76893
76894
76895
76896
76897
76898
76899
76900
76901
76902
76903
76904
76905
76906
76907
76908
76909
76910
76911
76912
76913
76914
76915
76916
76917
76918
76919
76920
76921
76922
76923
76924
76925
76926
76927
76928
76929
76930
76931
76932
76933
76934
76935
76936
76937
76938
76939
76940
76941
76942
76943
76944
76945
76946
76947
76948
76949
76950
76951
76952
76953
76954
76955
76956
76957
76958
76959
76960
76961
76962
76963
76964
76965
76966
76967
76968
76969
76970
76971
76972
76973
76974
76975
76976
76977
76978
76979
76980
76981
76982
76983
76984
76985
76986
76987
76988
76989
76990
76991
76992
76993
76994
76995
76996
76997
76998
76999
77000
77001
77002
77003
77004
77005
77006
77007
77008
77009
77010
77011
77012
77013
77014
77015
77016
77017
77018
77019
77020
77021
77022
77023
77024
77025
77026
77027
77028
77029
77030
77031
77032
77033
77034
77035
77036
77037
77038
77039
77040
77041
77042
77043
77044
77045
77046
77047
77048
77049
77050
77051
77052
77053
77054
77055
77056
77057
77058
77059
77060
77061
77062
77063
77064
77065
77066
77067
77068
77069
77070
77071
77072
77073
77074
77075
77076
77077
77078
77079
77080
77081
77082
77083
77084
77085
77086
77087
77088
77089
77090
77091
77092
77093
77094
77095
77096
77097
77098
77099
77100
77101
77102
77103
77104
77105
77106
77107
77108
77109
77110
77111
77112
77113
77114
77115
77116
77117
77118
77119
77120
77121
77122
77123
77124
77125
77126
77127
77128
77129
77130
77131
77132
77133
77134
77135
77136
77137
77138
77139
77140
77141
77142
77143
77144
77145
77146
77147
77148
77149
77150
77151
77152
77153
77154
77155
77156
77157
77158
77159
77160
77161
77162
77163
77164
77165
77166
77167
77168
77169
77170
77171
77172
77173
77174
77175
77176
77177
77178
77179
77180
77181
77182
77183
77184
77185
77186
77187
77188
77189
77190
77191
77192
77193
77194
77195
77196
77197
77198
77199
77200
77201
77202
77203
77204
77205
77206
77207
77208
77209
77210
77211
77212
77213
77214
77215
77216
77217
77218
77219
77220
77221
77222
77223
77224
77225
77226
77227
77228
77229
77230
77231
77232
77233
77234
77235
77236
77237
77238
77239
77240
77241
77242
77243
77244
77245
77246
77247
77248
77249
77250
77251
77252
77253
77254
77255
77256
77257
77258
77259
77260
77261
77262
77263
77264
77265
77266
77267
77268
77269
77270
77271
77272
77273
77274
77275
77276
77277
77278
77279
77280
77281
77282
77283
77284
77285
77286
77287
77288
77289
77290
77291
77292
77293
77294
77295
77296
77297
77298
77299
77300
77301
77302
77303
77304
77305
77306
77307
77308
77309
77310
77311
77312
77313
77314
77315
77316
77317
77318
77319
77320
77321
77322
77323
77324
77325
77326
77327
77328
77329
77330
77331
77332
77333
77334
77335
77336
77337
77338
77339
77340
77341
77342
77343
77344
77345
77346
77347
77348
77349
77350
77351
77352
77353
77354
77355
77356
77357
77358
77359
77360
77361
77362
77363
77364
77365
77366
77367
77368
77369
77370
77371
77372
77373
77374
77375
77376
77377
77378
77379
77380
77381
77382
77383
77384
77385
77386
77387
77388
77389
77390
77391
77392
77393
77394
77395
77396
77397
77398
77399
77400
77401
77402
77403
77404
77405
77406
77407
77408
77409
77410
77411
77412
77413
77414
77415
77416
77417
77418
77419
77420
77421
77422
77423
77424
77425
77426
77427
77428
77429
77430
77431
77432
77433
77434
77435
77436
77437
77438
77439
77440
77441
77442
77443
77444
77445
77446
77447
77448
77449
77450
77451
77452
77453
77454
77455
77456
77457
77458
77459
77460
77461
77462
77463
77464
77465
77466
77467
77468
77469
77470
77471
77472
77473
77474
77475
77476
77477
77478
77479
77480
77481
77482
77483
77484
77485
77486
77487
77488
77489
77490
77491
77492
77493
77494
77495
77496
77497
77498
77499
77500
77501
77502
77503
77504
77505
77506
77507
77508
77509
77510
77511
77512
77513
77514
77515
77516
77517
77518
77519
77520
77521
77522
77523
77524
77525
77526
77527
77528
77529
77530
77531
77532
77533
77534
77535
77536
77537
77538
77539
77540
77541
77542
77543
77544
77545
77546
77547
77548
77549
77550
77551
77552
77553
77554
77555
77556
77557
77558
77559
77560
77561
77562
77563
77564
77565
77566
77567
77568
77569
77570
77571
77572
77573
77574
77575
77576
77577
77578
77579
77580
77581
77582
77583
77584
77585
77586
77587
77588
77589
77590
77591
77592
77593
77594
77595
77596
77597
77598
77599
77600
77601
77602
77603
77604
77605
77606
77607
77608
77609
77610
77611
77612
77613
77614
77615
77616
77617
77618
77619
77620
77621
77622
77623
77624
77625
77626
77627
77628
77629
77630
77631
77632
77633
77634
77635
77636
77637
77638
77639
77640
77641
77642
77643
77644
77645
77646
77647
77648
77649
77650
77651
77652
77653
77654
77655
77656
77657
77658
77659
77660
77661
77662
77663
77664
77665
77666
77667
77668
77669
77670
77671
77672
77673
77674
77675
77676
77677
77678
77679
77680
77681
77682
77683
77684
77685
77686
77687
77688
77689
77690
77691
77692
77693
77694
77695
77696
77697
77698
77699
77700
77701
77702
77703
77704
77705
77706
77707
77708
77709
77710
77711
77712
77713
77714
77715
77716
77717
77718
77719
77720
77721
77722
77723
77724
77725
77726
77727
77728
77729
77730
77731
77732
77733
77734
77735
77736
77737
77738
77739
77740
77741
77742
77743
77744
77745
77746
77747
77748
77749
77750
77751
77752
77753
77754
77755
77756
77757
77758
77759
77760
77761
77762
77763
77764
77765
77766
77767
77768
77769
77770
77771
77772
77773
77774
77775
77776
77777
77778
77779
77780
77781
77782
77783
77784
77785
77786
77787
77788
77789
77790
77791
77792
77793
77794
77795
77796
77797
77798
77799
77800
77801
77802
77803
77804
77805
77806
77807
77808
77809
77810
77811
77812
77813
77814
77815
77816
77817
77818
77819
77820
77821
77822
77823
77824
77825
77826
77827
77828
77829
77830
77831
77832
77833
77834
77835
77836
77837
77838
77839
77840
77841
77842
77843
77844
77845
77846
77847
77848
77849
77850
77851
77852
77853
77854
77855
77856
77857
77858
77859
77860
77861
77862
77863
77864
77865
77866
77867
77868
77869
77870
77871
77872
77873
77874
77875
77876
77877
77878
77879
77880
77881
77882
77883
77884
77885
77886
77887
77888
77889
77890
77891
77892
77893
77894
77895
77896
77897
77898
77899
77900
77901
77902
77903
77904
77905
77906
77907
77908
77909
77910
77911
77912
77913
77914
77915
77916
77917
77918
77919
77920
77921
77922
77923
77924
77925
77926
77927
77928
77929
77930
77931
77932
77933
77934
77935
77936
77937
77938
77939
77940
77941
77942
77943
77944
77945
77946
77947
77948
77949
77950
77951
77952
77953
77954
77955
77956
77957
77958
77959
77960
77961
77962
77963
77964
77965
77966
77967
77968
77969
77970
77971
77972
77973
77974
77975
77976
77977
77978
77979
77980
77981
77982
77983
77984
77985
77986
77987
77988
77989
77990
77991
77992
77993
77994
77995
77996
77997
77998
77999
78000
78001
78002
78003
78004
78005
78006
78007
78008
78009
78010
78011
78012
78013
78014
78015
78016
78017
78018
78019
78020
78021
78022
78023
78024
78025
78026
78027
78028
78029
78030
78031
78032
78033
78034
78035
78036
78037
78038
78039
78040
78041
78042
78043
78044
78045
78046
78047
78048
78049
78050
78051
78052
78053
78054
78055
78056
78057
78058
78059
78060
78061
78062
78063
78064
78065
78066
78067
78068
78069
78070
78071
78072
78073
78074
78075
78076
78077
78078
78079
78080
78081
78082
78083
78084
78085
78086
78087
78088
78089
78090
78091
78092
78093
78094
78095
78096
78097
78098
78099
78100
78101
78102
78103
78104
78105
78106
78107
78108
78109
78110
78111
78112
78113
78114
78115
78116
78117
78118
78119
78120
78121
78122
78123
78124
78125
78126
78127
78128
78129
78130
78131
78132
78133
78134
78135
78136
78137
78138
78139
78140
78141
78142
78143
78144
78145
78146
78147
78148
78149
78150
78151
78152
78153
78154
78155
78156
78157
78158
78159
78160
78161
78162
78163
78164
78165
78166
78167
78168
78169
78170
78171
78172
78173
78174
78175
78176
78177
78178
78179
78180
78181
78182
78183
78184
78185
78186
78187
78188
78189
78190
78191
78192
78193
78194
78195
78196
78197
78198
78199
78200
78201
78202
78203
78204
78205
78206
78207
78208
78209
78210
78211
78212
78213
78214
78215
78216
78217
78218
78219
78220
78221
78222
78223
78224
78225
78226
78227
78228
78229
78230
78231
78232
78233
78234
78235
78236
78237
78238
78239
78240
78241
78242
78243
78244
78245
78246
78247
78248
78249
78250
78251
78252
78253
78254
78255
78256
78257
78258
78259
78260
78261
78262
78263
78264
78265
78266
78267
78268
78269
78270
78271
78272
78273
78274
78275
78276
78277
78278
78279
78280
78281
78282
78283
78284
78285
78286
78287
78288
78289
78290
78291
78292
78293
78294
78295
78296
78297
78298
78299
78300
78301
78302
78303
78304
78305
78306
78307
78308
78309
78310
78311
78312
78313
78314
78315
78316
78317
78318
78319
78320
78321
78322
78323
78324
78325
78326
78327
78328
78329
78330
78331
78332
78333
78334
78335
78336
78337
78338
78339
78340
78341
78342
78343
78344
78345
78346
78347
78348
78349
78350
78351
78352
78353
78354
78355
78356
78357
78358
78359
78360
78361
78362
78363
78364
78365
78366
78367
78368
78369
78370
78371
78372
78373
78374
78375
78376
78377
78378
78379
78380
78381
78382
78383
78384
78385
78386
78387
78388
78389
78390
78391
78392
78393
78394
78395
78396
78397
78398
78399
78400
78401
78402
78403
78404
78405
78406
78407
78408
78409
78410
78411
78412
78413
78414
78415
78416
78417
78418
78419
78420
78421
78422
78423
78424
78425
78426
78427
78428
78429
78430
78431
78432
78433
78434
78435
78436
78437
78438
78439
78440
78441
78442
78443
78444
78445
78446
78447
78448
78449
78450
78451
78452
78453
78454
78455
78456
78457
78458
78459
78460
78461
78462
78463
78464
78465
78466
78467
78468
78469
78470
78471
78472
78473
78474
78475
78476
78477
78478
78479
78480
78481
78482
78483
78484
78485
78486
78487
78488
78489
78490
78491
78492
78493
78494
78495
78496
78497
78498
78499
78500
78501
78502
78503
78504
78505
78506
78507
78508
78509
78510
78511
78512
78513
78514
78515
78516
78517
78518
78519
78520
78521
78522
78523
78524
78525
78526
78527
78528
78529
78530
78531
78532
78533
78534
78535
78536
78537
78538
78539
78540
78541
78542
78543
78544
78545
78546
78547
78548
78549
78550
78551
78552
78553
78554
78555
78556
78557
78558
78559
78560
78561
78562
78563
78564
78565
78566
78567
78568
78569
78570
78571
78572
78573
78574
78575
78576
78577
78578
78579
78580
78581
78582
78583
78584
78585
78586
78587
78588
78589
78590
78591
78592
78593
78594
78595
78596
78597
78598
78599
78600
78601
78602
78603
78604
78605
78606
78607
78608
78609
78610
78611
78612
78613
78614
78615
78616
78617
78618
78619
78620
78621
78622
78623
78624
78625
78626
78627
78628
78629
78630
78631
78632
78633
78634
78635
78636
78637
78638
78639
78640
78641
78642
78643
78644
78645
78646
78647
78648
78649
78650
78651
78652
78653
78654
78655
78656
78657
78658
78659
78660
78661
78662
78663
78664
78665
78666
78667
78668
78669
78670
78671
78672
78673
78674
78675
78676
78677
78678
78679
78680
78681
78682
78683
78684
78685
78686
78687
78688
78689
78690
78691
78692
78693
78694
78695
78696
78697
78698
78699
78700
78701
78702
78703
78704
78705
78706
78707
78708
78709
78710
78711
78712
78713
78714
78715
78716
78717
78718
78719
78720
78721
78722
78723
78724
78725
78726
78727
78728
78729
78730
78731
78732
78733
78734
78735
78736
78737
78738
78739
78740
78741
78742
78743
78744
78745
78746
78747
78748
78749
78750
78751
78752
78753
78754
78755
78756
78757
78758
78759
78760
78761
78762
78763
78764
78765
78766
78767
78768
78769
78770
78771
78772
78773
78774
78775
78776
78777
78778
78779
78780
78781
78782
78783
78784
78785
78786
78787
78788
78789
78790
78791
78792
78793
78794
78795
78796
78797
78798
78799
78800
78801
78802
78803
78804
78805
78806
78807
78808
78809
78810
78811
78812
78813
78814
78815
78816
78817
78818
78819
78820
78821
78822
78823
78824
78825
78826
78827
78828
78829
78830
78831
78832
78833
78834
78835
78836
78837
78838
78839
78840
78841
78842
78843
78844
78845
78846
78847
78848
78849
78850
78851
78852
78853
78854
78855
78856
78857
78858
78859
78860
78861
78862
78863
78864
78865
78866
78867
78868
78869
78870
78871
78872
78873
78874
78875
78876
78877
78878
78879
78880
78881
78882
78883
78884
78885
78886
78887
78888
78889
78890
78891
78892
78893
78894
78895
78896
78897
78898
78899
78900
78901
78902
78903
78904
78905
78906
78907
78908
78909
78910
78911
78912
78913
78914
78915
78916
78917
78918
78919
78920
78921
78922
78923
78924
78925
78926
78927
78928
78929
78930
78931
78932
78933
78934
78935
78936
78937
78938
78939
78940
78941
78942
78943
78944
78945
78946
78947
78948
78949
78950
78951
78952
78953
78954
78955
78956
78957
78958
78959
78960
78961
78962
78963
78964
78965
78966
78967
78968
78969
78970
78971
78972
78973
78974
78975
78976
78977
78978
78979
78980
78981
78982
78983
78984
78985
78986
78987
78988
78989
78990
78991
78992
78993
78994
78995
78996
78997
78998
78999
79000
79001
79002
79003
79004
79005
79006
79007
79008
79009
79010
79011
79012
79013
79014
79015
79016
79017
79018
79019
79020
79021
79022
79023
79024
79025
79026
79027
79028
79029
79030
79031
79032
79033
79034
79035
79036
79037
79038
79039
79040
79041
79042
79043
79044
79045
79046
79047
79048
79049
79050
79051
79052
79053
79054
79055
79056
79057
79058
79059
79060
79061
79062
79063
79064
79065
79066
79067
79068
79069
79070
79071
79072
79073
79074
79075
79076
79077
79078
79079
79080
79081
79082
79083
79084
79085
79086
79087
79088
79089
79090
79091
79092
79093
79094
79095
79096
79097
79098
79099
79100
79101
79102
79103
79104
79105
79106
79107
79108
79109
79110
79111
79112
79113
79114
79115
79116
79117
79118
79119
79120
79121
79122
79123
79124
79125
79126
79127
79128
79129
79130
79131
79132
79133
79134
79135
79136
79137
79138
79139
79140
79141
79142
79143
79144
79145
79146
79147
79148
79149
79150
79151
79152
79153
79154
79155
79156
79157
79158
79159
79160
79161
79162
79163
79164
79165
79166
79167
79168
79169
79170
79171
79172
79173
79174
79175
79176
79177
79178
79179
79180
79181
79182
79183
79184
79185
79186
79187
79188
79189
79190
79191
79192
79193
79194
79195
79196
79197
79198
79199
79200
79201
79202
79203
79204
79205
79206
79207
79208
79209
79210
79211
79212
79213
79214
79215
79216
79217
79218
79219
79220
79221
79222
79223
79224
79225
79226
79227
79228
79229
79230
79231
79232
79233
79234
79235
79236
79237
79238
79239
79240
79241
79242
79243
79244
79245
79246
79247
79248
79249
79250
79251
79252
79253
79254
79255
79256
79257
79258
79259
79260
79261
79262
79263
79264
79265
79266
79267
79268
79269
79270
79271
79272
79273
79274
79275
79276
79277
79278
79279
79280
79281
79282
79283
79284
79285
79286
79287
79288
79289
79290
79291
79292
79293
79294
79295
79296
79297
79298
79299
79300
79301
79302
79303
79304
79305
79306
79307
79308
79309
79310
79311
79312
79313
79314
79315
79316
79317
79318
79319
79320
79321
79322
79323
79324
79325
79326
79327
79328
79329
79330
79331
79332
79333
79334
79335
79336
79337
79338
79339
79340
79341
79342
79343
79344
79345
79346
79347
79348
79349
79350
79351
79352
79353
79354
79355
79356
79357
79358
79359
79360
79361
79362
79363
79364
79365
79366
79367
79368
79369
79370
79371
79372
79373
79374
79375
79376
79377
79378
79379
79380
79381
79382
79383
79384
79385
79386
79387
79388
79389
79390
79391
79392
79393
79394
79395
79396
79397
79398
79399
79400
79401
79402
79403
79404
79405
79406
79407
79408
79409
79410
79411
79412
79413
79414
79415
79416
79417
79418
79419
79420
79421
79422
79423
79424
79425
79426
79427
79428
79429
79430
79431
79432
79433
79434
79435
79436
79437
79438
79439
79440
79441
79442
79443
79444
79445
79446
79447
79448
79449
79450
79451
79452
79453
79454
79455
79456
79457
79458
79459
79460
79461
79462
79463
79464
79465
79466
79467
79468
79469
79470
79471
79472
79473
79474
79475
79476
79477
79478
79479
79480
79481
79482
79483
79484
79485
79486
79487
79488
79489
79490
79491
79492
79493
79494
79495
79496
79497
79498
79499
79500
79501
79502
79503
79504
79505
79506
79507
79508
79509
79510
79511
79512
79513
79514
79515
79516
79517
79518
79519
79520
79521
79522
79523
79524
79525
79526
79527
79528
79529
79530
79531
79532
79533
79534
79535
79536
79537
79538
79539
79540
79541
79542
79543
79544
79545
79546
79547
79548
79549
79550
79551
79552
79553
79554
79555
79556
79557
79558
79559
79560
79561
79562
79563
79564
79565
79566
79567
79568
79569
79570
79571
79572
79573
79574
79575
79576
79577
79578
79579
79580
79581
79582
79583
79584
79585
79586
79587
79588
79589
79590
79591
79592
79593
79594
79595
79596
79597
79598
79599
79600
79601
79602
79603
79604
79605
79606
79607
79608
79609
79610
79611
79612
79613
79614
79615
79616
79617
79618
79619
79620
79621
79622
79623
79624
79625
79626
79627
79628
79629
79630
79631
79632
79633
79634
79635
79636
79637
79638
79639
79640
79641
79642
79643
79644
79645
79646
79647
79648
79649
79650
79651
79652
79653
79654
79655
79656
79657
79658
79659
79660
79661
79662
79663
79664
79665
79666
79667
79668
79669
79670
79671
79672
79673
79674
79675
79676
79677
79678
79679
79680
79681
79682
79683
79684
79685
79686
79687
79688
79689
79690
79691
79692
79693
79694
79695
79696
79697
79698
79699
79700
79701
79702
79703
79704
79705
79706
79707
79708
79709
79710
79711
79712
79713
79714
79715
79716
79717
79718
79719
79720
79721
79722
79723
79724
79725
79726
79727
79728
79729
79730
79731
79732
79733
79734
79735
79736
79737
79738
79739
79740
79741
79742
79743
79744
79745
79746
79747
79748
79749
79750
79751
79752
79753
79754
79755
79756
79757
79758
79759
79760
79761
79762
79763
79764
79765
79766
79767
79768
79769
79770
79771
79772
79773
79774
79775
79776
79777
79778
79779
79780
79781
79782
79783
79784
79785
79786
79787
79788
79789
79790
79791
79792
79793
79794
79795
79796
79797
79798
79799
79800
79801
79802
79803
79804
79805
79806
79807
79808
79809
79810
79811
79812
79813
79814
79815
79816
79817
79818
79819
79820
79821
79822
79823
79824
79825
79826
79827
79828
79829
79830
79831
79832
79833
79834
79835
79836
79837
79838
79839
79840
79841
79842
79843
79844
79845
79846
79847
79848
79849
79850
79851
79852
79853
79854
79855
79856
79857
79858
79859
79860
79861
79862
79863
79864
79865
79866
79867
79868
79869
79870
79871
79872
79873
79874
79875
79876
79877
79878
79879
79880
79881
79882
79883
79884
79885
79886
79887
79888
79889
79890
79891
79892
79893
79894
79895
79896
79897
79898
79899
79900
79901
79902
79903
79904
79905
79906
79907
79908
79909
79910
79911
79912
79913
79914
79915
79916
79917
79918
79919
79920
79921
79922
79923
79924
79925
79926
79927
79928
79929
79930
79931
79932
79933
79934
79935
79936
79937
79938
79939
79940
79941
79942
79943
79944
79945
79946
79947
79948
79949
79950
79951
79952
79953
79954
79955
79956
79957
79958
79959
79960
79961
79962
79963
79964
79965
79966
79967
79968
79969
79970
79971
79972
79973
79974
79975
79976
79977
79978
79979
79980
79981
79982
79983
79984
79985
79986
79987
79988
79989
79990
79991
79992
79993
79994
79995
79996
79997
79998
79999
80000
80001
80002
80003
80004
80005
80006
80007
80008
80009
80010
80011
80012
80013
80014
80015
80016
80017
80018
80019
80020
80021
80022
80023
80024
80025
80026
80027
80028
80029
80030
80031
80032
80033
80034
80035
80036
80037
80038
80039
80040
80041
80042
80043
80044
80045
80046
80047
80048
80049
80050
80051
80052
80053
80054
80055
80056
80057
80058
80059
80060
80061
80062
80063
80064
80065
80066
80067
80068
80069
80070
80071
80072
80073
80074
80075
80076
80077
80078
80079
80080
80081
80082
80083
80084
80085
80086
80087
80088
80089
80090
80091
80092
80093
80094
80095
80096
80097
80098
80099
80100
80101
80102
80103
80104
80105
80106
80107
80108
80109
80110
80111
80112
80113
80114
80115
80116
80117
80118
80119
80120
80121
80122
80123
80124
80125
80126
80127
80128
80129
80130
80131
80132
80133
80134
80135
80136
80137
80138
80139
80140
80141
80142
80143
80144
80145
80146
80147
80148
80149
80150
80151
80152
80153
80154
80155
80156
80157
80158
80159
80160
80161
80162
80163
80164
80165
80166
80167
80168
80169
80170
80171
80172
80173
80174
80175
80176
80177
80178
80179
80180
80181
80182
80183
80184
80185
80186
80187
80188
80189
80190
80191
80192
80193
80194
80195
80196
80197
80198
80199
80200
80201
80202
80203
80204
80205
80206
80207
80208
80209
80210
80211
80212
80213
80214
80215
80216
80217
80218
80219
80220
80221
80222
80223
80224
80225
80226
80227
80228
80229
80230
80231
80232
80233
80234
80235
80236
80237
80238
80239
80240
80241
80242
80243
80244
80245
80246
80247
80248
80249
80250
80251
80252
80253
80254
80255
80256
80257
80258
80259
80260
80261
80262
80263
80264
80265
80266
80267
80268
80269
80270
80271
80272
80273
80274
80275
80276
80277
80278
80279
80280
80281
80282
80283
80284
80285
80286
80287
80288
80289
80290
80291
80292
80293
80294
80295
80296
80297
80298
80299
80300
80301
80302
80303
80304
80305
80306
80307
80308
80309
80310
80311
80312
80313
80314
80315
80316
80317
80318
80319
80320
80321
80322
80323
80324
80325
80326
80327
80328
80329
80330
80331
80332
80333
80334
80335
80336
80337
80338
80339
80340
80341
80342
80343
80344
80345
80346
80347
80348
80349
80350
80351
80352
80353
80354
80355
80356
80357
80358
80359
80360
80361
80362
80363
80364
80365
80366
80367
80368
80369
80370
80371
80372
80373
80374
80375
80376
80377
80378
80379
80380
80381
80382
80383
80384
80385
80386
80387
80388
80389
80390
80391
80392
80393
80394
80395
80396
80397
80398
80399
80400
80401
80402
80403
80404
80405
80406
80407
80408
80409
80410
80411
80412
80413
80414
80415
80416
80417
80418
80419
80420
80421
80422
80423
80424
80425
80426
80427
80428
80429
80430
80431
80432
80433
80434
80435
80436
80437
80438
80439
80440
80441
80442
80443
80444
80445
80446
80447
80448
80449
80450
80451
80452
80453
80454
80455
80456
80457
80458
80459
80460
80461
80462
80463
80464
80465
80466
80467
80468
80469
80470
80471
80472
80473
80474
80475
80476
80477
80478
80479
80480
80481
80482
80483
80484
80485
80486
80487
80488
80489
80490
80491
80492
80493
80494
80495
80496
80497
80498
80499
80500
80501
80502
80503
80504
80505
80506
80507
80508
80509
80510
80511
80512
80513
80514
80515
80516
80517
80518
80519
80520
80521
80522
80523
80524
80525
80526
80527
80528
80529
80530
80531
80532
80533
80534
80535
80536
80537
80538
80539
80540
80541
80542
80543
80544
80545
80546
80547
80548
80549
80550
80551
80552
80553
80554
80555
80556
80557
80558
80559
80560
80561
80562
80563
80564
80565
80566
80567
80568
80569
80570
80571
80572
80573
80574
80575
80576
80577
80578
80579
80580
80581
80582
80583
80584
80585
80586
80587
80588
80589
80590
80591
80592
80593
80594
80595
80596
80597
80598
80599
80600
80601
80602
80603
80604
80605
80606
80607
80608
80609
80610
80611
80612
80613
80614
80615
80616
80617
80618
80619
80620
80621
80622
80623
80624
80625
80626
80627
80628
80629
80630
80631
80632
80633
80634
80635
80636
80637
80638
80639
80640
80641
80642
80643
80644
80645
80646
80647
80648
80649
80650
80651
80652
80653
80654
80655
80656
80657
80658
80659
80660
80661
80662
80663
80664
80665
80666
80667
80668
80669
80670
80671
80672
80673
80674
80675
80676
80677
80678
80679
80680
80681
80682
80683
80684
80685
80686
80687
80688
80689
80690
80691
80692
80693
80694
80695
80696
80697
80698
80699
80700
80701
80702
80703
80704
80705
80706
80707
80708
80709
80710
80711
80712
80713
80714
80715
80716
80717
80718
80719
80720
80721
80722
80723
80724
80725
80726
80727
80728
80729
80730
80731
80732
80733
80734
80735
80736
80737
80738
80739
80740
80741
80742
80743
80744
80745
80746
80747
80748
80749
80750
80751
80752
80753
80754
80755
80756
80757
80758
80759
80760
80761
80762
80763
80764
80765
80766
80767
80768
80769
80770
80771
80772
80773
80774
80775
80776
80777
80778
80779
80780
80781
80782
80783
80784
80785
80786
80787
80788
80789
80790
80791
80792
80793
80794
80795
80796
80797
80798
80799
80800
80801
80802
80803
80804
80805
80806
80807
80808
80809
80810
80811
80812
80813
80814
80815
80816
80817
80818
80819
80820
80821
80822
80823
80824
80825
80826
80827
80828
80829
80830
80831
80832
80833
80834
80835
80836
80837
80838
80839
80840
80841
80842
80843
80844
80845
80846
80847
80848
80849
80850
80851
80852
80853
80854
80855
80856
80857
80858
80859
80860
80861
80862
80863
80864
80865
80866
80867
80868
80869
80870
80871
80872
80873
80874
80875
80876
80877
80878
80879
80880
80881
80882
80883
80884
80885
80886
80887
80888
80889
80890
80891
80892
80893
80894
80895
80896
80897
80898
80899
80900
80901
80902
80903
80904
80905
80906
80907
80908
80909
80910
80911
80912
80913
80914
80915
80916
80917
80918
80919
80920
80921
80922
80923
80924
80925
80926
80927
80928
80929
80930
80931
80932
80933
80934
80935
80936
80937
80938
80939
80940
80941
80942
80943
80944
80945
80946
80947
80948
80949
80950
80951
80952
80953
80954
80955
80956
80957
80958
80959
80960
80961
80962
80963
80964
80965
80966
80967
80968
80969
80970
80971
80972
80973
80974
80975
80976
80977
80978
80979
80980
80981
80982
80983
80984
80985
80986
80987
80988
80989
80990
80991
80992
80993
80994
80995
80996
80997
80998
80999
81000
81001
81002
81003
81004
81005
81006
81007
81008
81009
81010
81011
81012
81013
81014
81015
81016
81017
81018
81019
81020
81021
81022
81023
81024
81025
81026
81027
81028
81029
81030
81031
81032
81033
81034
81035
81036
81037
81038
81039
81040
81041
81042
81043
81044
81045
81046
81047
81048
81049
81050
81051
81052
81053
81054
81055
81056
81057
81058
81059
81060
81061
81062
81063
81064
81065
81066
81067
81068
81069
81070
81071
81072
81073
81074
81075
81076
81077
81078
81079
81080
81081
81082
81083
81084
81085
81086
81087
81088
81089
81090
81091
81092
81093
81094
81095
81096
81097
81098
81099
81100
81101
81102
81103
81104
81105
81106
81107
81108
81109
81110
81111
81112
81113
81114
81115
81116
81117
81118
81119
81120
81121
81122
81123
81124
81125
81126
81127
81128
81129
81130
81131
81132
81133
81134
81135
81136
81137
81138
81139
81140
81141
81142
81143
81144
81145
81146
81147
81148
81149
81150
81151
81152
81153
81154
81155
81156
81157
81158
81159
81160
81161
81162
81163
81164
81165
81166
81167
81168
81169
81170
81171
81172
81173
81174
81175
81176
81177
81178
81179
81180
81181
81182
81183
81184
81185
81186
81187
81188
81189
81190
81191
81192
81193
81194
81195
81196
81197
81198
81199
81200
81201
81202
81203
81204
81205
81206
81207
81208
81209
81210
81211
81212
81213
81214
81215
81216
81217
81218
81219
81220
81221
81222
81223
81224
81225
81226
81227
81228
81229
81230
81231
81232
81233
81234
81235
81236
81237
81238
81239
81240
81241
81242
81243
81244
81245
81246
81247
81248
81249
81250
81251
81252
81253
81254
81255
81256
81257
81258
81259
81260
81261
81262
81263
81264
81265
81266
81267
81268
81269
81270
81271
81272
81273
81274
81275
81276
81277
81278
81279
81280
81281
81282
81283
81284
81285
81286
81287
81288
81289
81290
81291
81292
81293
81294
81295
81296
81297
81298
81299
81300
81301
81302
81303
81304
81305
81306
81307
81308
81309
81310
81311
81312
81313
81314
81315
81316
81317
81318
81319
81320
81321
81322
81323
81324
81325
81326
81327
81328
81329
81330
81331
81332
81333
81334
81335
81336
81337
81338
81339
81340
81341
81342
81343
81344
81345
81346
81347
81348
81349
81350
81351
81352
81353
81354
81355
81356
81357
81358
81359
81360
81361
81362
81363
81364
81365
81366
81367
81368
81369
81370
81371
81372
81373
81374
81375
81376
81377
81378
81379
81380
81381
81382
81383
81384
81385
81386
81387
81388
81389
81390
81391
81392
81393
81394
81395
81396
81397
81398
81399
81400
81401
81402
81403
81404
81405
81406
81407
81408
81409
81410
81411
81412
81413
81414
81415
81416
81417
81418
81419
81420
81421
81422
81423
81424
81425
81426
81427
81428
81429
81430
81431
81432
81433
81434
81435
81436
81437
81438
81439
81440
81441
81442
81443
81444
81445
81446
81447
81448
81449
81450
81451
81452
81453
81454
81455
81456
81457
81458
81459
81460
81461
81462
81463
81464
81465
81466
81467
81468
81469
81470
81471
81472
81473
81474
81475
81476
81477
81478
81479
81480
81481
81482
81483
81484
81485
81486
81487
81488
81489
81490
81491
81492
81493
81494
81495
81496
81497
81498
81499
81500
81501
81502
81503
81504
81505
81506
81507
81508
81509
81510
81511
81512
81513
81514
81515
81516
81517
81518
81519
81520
81521
81522
81523
81524
81525
81526
81527
81528
81529
81530
81531
81532
81533
81534
81535
81536
81537
81538
81539
81540
81541
81542
81543
81544
81545
81546
81547
81548
81549
81550
81551
81552
81553
81554
81555
81556
81557
81558
81559
81560
81561
81562
81563
81564
81565
81566
81567
81568
81569
81570
81571
81572
81573
81574
81575
81576
81577
81578
81579
81580
81581
81582
81583
81584
81585
81586
81587
81588
81589
81590
81591
81592
81593
81594
81595
81596
81597
81598
81599
81600
81601
81602
81603
81604
81605
81606
81607
81608
81609
81610
81611
81612
81613
81614
81615
81616
81617
81618
81619
81620
81621
81622
81623
81624
81625
81626
81627
81628
81629
81630
81631
81632
81633
81634
81635
81636
81637
81638
81639
81640
81641
81642
81643
81644
81645
81646
81647
81648
81649
81650
81651
81652
81653
81654
81655
81656
81657
81658
81659
81660
81661
81662
81663
81664
81665
81666
81667
81668
81669
81670
81671
81672
81673
81674
81675
81676
81677
81678
81679
81680
81681
81682
81683
81684
81685
81686
81687
81688
81689
81690
81691
81692
81693
81694
81695
81696
81697
81698
81699
81700
81701
81702
81703
81704
81705
81706
81707
81708
81709
81710
81711
81712
81713
81714
81715
81716
81717
81718
81719
81720
81721
81722
81723
81724
81725
81726
81727
81728
81729
81730
81731
81732
81733
81734
81735
81736
81737
81738
81739
81740
81741
81742
81743
81744
81745
81746
81747
81748
81749
81750
81751
81752
81753
81754
81755
81756
81757
81758
81759
81760
81761
81762
81763
81764
81765
81766
81767
81768
81769
81770
81771
81772
81773
81774
81775
81776
81777
81778
81779
81780
81781
81782
81783
81784
81785
81786
81787
81788
81789
81790
81791
81792
81793
81794
81795
81796
81797
81798
81799
81800
81801
81802
81803
81804
81805
81806
81807
81808
81809
81810
81811
81812
81813
81814
81815
81816
81817
81818
81819
81820
81821
81822
81823
81824
81825
81826
81827
81828
81829
81830
81831
81832
81833
81834
81835
81836
81837
81838
81839
81840
81841
81842
81843
81844
81845
81846
81847
81848
81849
81850
81851
81852
81853
81854
81855
81856
81857
81858
81859
81860
81861
81862
81863
81864
81865
81866
81867
81868
81869
81870
81871
81872
81873
81874
81875
81876
81877
81878
81879
81880
81881
81882
81883
81884
81885
81886
81887
81888
81889
81890
81891
81892
81893
81894
81895
81896
81897
81898
81899
81900
81901
81902
81903
81904
81905
81906
81907
81908
81909
81910
81911
81912
81913
81914
81915
81916
81917
81918
81919
81920
81921
81922
81923
81924
81925
81926
81927
81928
81929
81930
81931
81932
81933
81934
81935
81936
81937
81938
81939
81940
81941
81942
81943
81944
81945
81946
81947
81948
81949
81950
81951
81952
81953
81954
81955
81956
81957
81958
81959
81960
81961
81962
81963
81964
81965
81966
81967
81968
81969
81970
81971
81972
81973
81974
81975
81976
81977
81978
81979
81980
81981
81982
81983
81984
81985
81986
81987
81988
81989
81990
81991
81992
81993
81994
81995
81996
81997
81998
81999
82000
82001
82002
82003
82004
82005
82006
82007
82008
82009
82010
82011
82012
82013
82014
82015
82016
82017
82018
82019
82020
82021
82022
82023
82024
82025
82026
82027
82028
82029
82030
82031
82032
82033
82034
82035
82036
82037
82038
82039
82040
82041
82042
82043
82044
82045
82046
82047
82048
82049
82050
82051
82052
82053
82054
82055
82056
82057
82058
82059
82060
82061
82062
82063
82064
82065
82066
82067
82068
82069
82070
82071
82072
82073
82074
82075
82076
82077
82078
82079
82080
82081
82082
82083
82084
82085
82086
82087
82088
82089
82090
82091
82092
82093
82094
82095
82096
82097
82098
82099
82100
82101
82102
82103
82104
82105
82106
82107
82108
82109
82110
82111
82112
82113
82114
82115
82116
82117
82118
82119
82120
82121
82122
82123
82124
82125
82126
82127
82128
82129
82130
82131
82132
82133
82134
82135
82136
82137
82138
82139
82140
82141
82142
82143
82144
82145
82146
82147
82148
82149
82150
82151
82152
82153
82154
82155
82156
82157
82158
82159
82160
82161
82162
82163
82164
82165
82166
82167
82168
82169
82170
82171
82172
82173
82174
82175
82176
82177
82178
82179
82180
82181
82182
82183
82184
82185
82186
82187
82188
82189
82190
82191
82192
82193
82194
82195
82196
82197
82198
82199
82200
82201
82202
82203
82204
82205
82206
82207
82208
82209
82210
82211
82212
82213
82214
82215
82216
82217
82218
82219
82220
82221
82222
82223
82224
82225
82226
82227
82228
82229
82230
82231
82232
82233
82234
82235
82236
82237
82238
82239
82240
82241
82242
82243
82244
82245
82246
82247
82248
82249
82250
82251
82252
82253
82254
82255
82256
82257
82258
82259
82260
82261
82262
82263
82264
82265
82266
82267
82268
82269
82270
82271
82272
82273
82274
82275
82276
82277
82278
82279
82280
82281
82282
82283
82284
82285
82286
82287
82288
82289
82290
82291
82292
82293
82294
82295
82296
82297
82298
82299
82300
82301
82302
82303
82304
82305
82306
82307
82308
82309
82310
82311
82312
82313
82314
82315
82316
82317
82318
82319
82320
82321
82322
82323
82324
82325
82326
82327
82328
82329
82330
82331
82332
82333
82334
82335
82336
82337
82338
82339
82340
82341
82342
82343
82344
82345
82346
82347
82348
82349
82350
82351
82352
82353
82354
82355
82356
82357
82358
82359
82360
82361
82362
82363
82364
82365
82366
82367
82368
82369
82370
82371
82372
82373
82374
82375
82376
82377
82378
82379
82380
82381
82382
82383
82384
82385
82386
82387
82388
82389
82390
82391
82392
82393
82394
82395
82396
82397
82398
82399
82400
82401
82402
82403
82404
82405
82406
82407
82408
82409
82410
82411
82412
82413
82414
82415
82416
82417
82418
82419
82420
82421
82422
82423
82424
82425
82426
82427
82428
82429
82430
82431
82432
82433
82434
82435
82436
82437
82438
82439
82440
82441
82442
82443
82444
82445
82446
82447
82448
82449
82450
82451
82452
82453
82454
82455
82456
82457
82458
82459
82460
82461
82462
82463
82464
82465
82466
82467
82468
82469
82470
82471
82472
82473
82474
82475
82476
82477
82478
82479
82480
82481
82482
82483
82484
82485
82486
82487
82488
82489
82490
82491
82492
82493
82494
82495
82496
82497
82498
82499
82500
82501
82502
82503
82504
82505
82506
82507
82508
82509
82510
82511
82512
82513
82514
82515
82516
82517
82518
82519
82520
82521
82522
82523
82524
82525
82526
82527
82528
82529
82530
82531
82532
82533
82534
82535
82536
82537
82538
82539
82540
82541
82542
82543
82544
82545
82546
82547
82548
82549
82550
82551
82552
82553
82554
82555
82556
82557
82558
82559
82560
82561
82562
82563
82564
82565
82566
82567
82568
82569
82570
82571
82572
82573
82574
82575
82576
82577
82578
82579
82580
82581
82582
82583
82584
82585
82586
82587
82588
82589
82590
82591
82592
82593
82594
82595
82596
82597
82598
82599
82600
82601
82602
82603
82604
82605
82606
82607
82608
82609
82610
82611
82612
82613
82614
82615
82616
82617
82618
82619
82620
82621
82622
82623
82624
82625
82626
82627
82628
82629
82630
82631
82632
82633
82634
82635
82636
82637
82638
82639
82640
82641
82642
82643
82644
82645
82646
82647
82648
82649
82650
82651
82652
82653
82654
82655
82656
82657
82658
82659
82660
82661
82662
82663
82664
82665
82666
82667
82668
82669
82670
82671
82672
82673
82674
82675
82676
82677
82678
82679
82680
82681
82682
82683
82684
82685
82686
82687
82688
82689
82690
82691
82692
82693
82694
82695
82696
82697
82698
82699
82700
82701
82702
82703
82704
82705
82706
82707
82708
82709
82710
82711
82712
82713
82714
82715
82716
82717
82718
82719
82720
82721
82722
82723
82724
82725
82726
82727
82728
82729
82730
82731
82732
82733
82734
82735
82736
82737
82738
82739
82740
82741
82742
82743
82744
82745
82746
82747
82748
82749
82750
82751
82752
82753
82754
82755
82756
82757
82758
82759
82760
82761
82762
82763
82764
82765
82766
82767
82768
82769
82770
82771
82772
82773
82774
82775
82776
82777
82778
82779
82780
82781
82782
82783
82784
82785
82786
82787
82788
82789
82790
82791
82792
82793
82794
82795
82796
82797
82798
82799
82800
82801
82802
82803
82804
82805
82806
82807
82808
82809
82810
82811
82812
82813
82814
82815
82816
82817
82818
82819
82820
82821
82822
82823
82824
82825
82826
82827
82828
82829
82830
82831
82832
82833
82834
82835
82836
82837
82838
82839
82840
82841
82842
82843
82844
82845
82846
82847
82848
82849
82850
82851
82852
82853
82854
82855
82856
82857
82858
82859
82860
82861
82862
82863
82864
82865
82866
82867
82868
82869
82870
82871
82872
82873
82874
82875
82876
82877
82878
82879
82880
82881
82882
82883
82884
82885
82886
82887
82888
82889
82890
82891
82892
82893
82894
82895
82896
82897
82898
82899
82900
82901
82902
82903
82904
82905
82906
82907
82908
82909
82910
82911
82912
82913
82914
82915
82916
82917
82918
82919
82920
82921
82922
82923
82924
82925
82926
82927
82928
82929
82930
82931
82932
82933
82934
82935
82936
82937
82938
82939
82940
82941
82942
82943
82944
82945
82946
82947
82948
82949
82950
82951
82952
82953
82954
82955
82956
82957
82958
82959
82960
82961
82962
82963
82964
82965
82966
82967
82968
82969
82970
82971
82972
82973
82974
82975
82976
82977
82978
82979
82980
82981
82982
82983
82984
82985
82986
82987
82988
82989
82990
82991
82992
82993
82994
82995
82996
82997
82998
82999
83000
83001
83002
83003
83004
83005
83006
83007
83008
83009
83010
83011
83012
83013
83014
83015
83016
83017
83018
83019
83020
83021
83022
83023
83024
83025
83026
83027
83028
83029
83030
83031
83032
83033
83034
83035
83036
83037
83038
83039
83040
83041
83042
83043
83044
83045
83046
83047
83048
83049
83050
83051
83052
83053
83054
83055
83056
83057
83058
83059
83060
83061
83062
83063
83064
83065
83066
83067
83068
83069
83070
83071
83072
83073
83074
83075
83076
83077
83078
83079
83080
83081
83082
83083
83084
83085
83086
83087
83088
83089
83090
83091
83092
83093
83094
83095
83096
83097
83098
83099
83100
83101
83102
83103
83104
83105
83106
83107
83108
83109
83110
83111
83112
83113
83114
83115
83116
83117
83118
83119
83120
83121
83122
83123
83124
83125
83126
83127
83128
83129
83130
83131
83132
83133
83134
83135
83136
83137
83138
83139
83140
83141
83142
83143
83144
83145
83146
83147
83148
83149
83150
83151
83152
83153
83154
83155
83156
83157
83158
83159
83160
83161
83162
83163
83164
83165
83166
83167
83168
83169
83170
83171
83172
83173
83174
83175
83176
83177
83178
83179
83180
83181
83182
83183
83184
83185
83186
83187
83188
83189
83190
83191
83192
83193
83194
83195
83196
83197
83198
83199
83200
83201
83202
83203
83204
83205
83206
83207
83208
83209
83210
83211
83212
83213
83214
83215
83216
83217
83218
83219
83220
83221
83222
83223
83224
83225
83226
83227
83228
83229
83230
83231
83232
83233
83234
83235
83236
83237
83238
83239
83240
83241
83242
83243
83244
83245
83246
83247
83248
83249
83250
83251
83252
83253
83254
83255
83256
83257
83258
83259
83260
83261
83262
83263
83264
83265
83266
83267
83268
83269
83270
83271
83272
83273
83274
83275
83276
83277
83278
83279
83280
83281
83282
83283
83284
83285
83286
83287
83288
83289
83290
83291
83292
83293
83294
83295
83296
83297
83298
83299
83300
83301
83302
83303
83304
83305
83306
83307
83308
83309
83310
83311
83312
83313
83314
83315
83316
83317
83318
83319
83320
83321
83322
83323
83324
83325
83326
83327
83328
83329
83330
83331
83332
83333
83334
83335
83336
83337
83338
83339
83340
83341
83342
83343
83344
83345
83346
83347
83348
83349
83350
83351
83352
83353
83354
83355
83356
83357
83358
83359
83360
83361
83362
83363
83364
83365
83366
83367
83368
83369
83370
83371
83372
83373
83374
83375
83376
83377
83378
83379
83380
83381
83382
83383
83384
83385
83386
83387
83388
83389
83390
83391
83392
83393
83394
83395
83396
83397
83398
83399
83400
83401
83402
83403
83404
83405
83406
83407
83408
83409
83410
83411
83412
83413
83414
83415
83416
83417
83418
83419
83420
83421
83422
83423
83424
83425
83426
83427
83428
83429
83430
83431
83432
83433
83434
83435
83436
83437
83438
83439
83440
83441
83442
83443
83444
83445
83446
83447
83448
83449
83450
83451
83452
83453
83454
83455
83456
83457
83458
83459
83460
83461
83462
83463
83464
83465
83466
83467
83468
83469
83470
83471
83472
83473
83474
83475
83476
83477
83478
83479
83480
83481
83482
83483
83484
83485
83486
83487
83488
83489
83490
83491
83492
83493
83494
83495
83496
83497
83498
83499
83500
83501
83502
83503
83504
83505
83506
83507
83508
83509
83510
83511
83512
83513
83514
83515
83516
83517
83518
83519
83520
83521
83522
83523
83524
83525
83526
83527
83528
83529
83530
83531
83532
83533
83534
83535
83536
83537
83538
83539
83540
83541
83542
83543
83544
83545
83546
83547
83548
83549
83550
83551
83552
83553
83554
83555
83556
83557
83558
83559
83560
83561
83562
83563
83564
83565
83566
83567
83568
83569
83570
83571
83572
83573
83574
83575
83576
83577
83578
83579
83580
83581
83582
83583
83584
83585
83586
83587
83588
83589
83590
83591
83592
83593
83594
83595
83596
83597
83598
83599
83600
83601
83602
83603
83604
83605
83606
83607
83608
83609
83610
83611
83612
83613
83614
83615
83616
83617
83618
83619
83620
83621
83622
83623
83624
83625
83626
83627
83628
83629
83630
83631
83632
83633
83634
83635
83636
83637
83638
83639
83640
83641
83642
83643
83644
83645
83646
83647
83648
83649
83650
83651
83652
83653
83654
83655
83656
83657
83658
83659
83660
83661
83662
83663
83664
83665
83666
83667
83668
83669
83670
83671
83672
83673
83674
83675
83676
83677
83678
83679
83680
83681
83682
83683
83684
83685
83686
83687
83688
83689
83690
83691
83692
83693
83694
83695
83696
83697
83698
83699
83700
83701
83702
83703
83704
83705
83706
83707
83708
83709
83710
83711
83712
83713
83714
83715
83716
83717
83718
83719
83720
83721
83722
83723
83724
83725
83726
83727
83728
83729
83730
83731
83732
83733
83734
83735
83736
83737
83738
83739
83740
83741
83742
83743
83744
83745
83746
83747
83748
83749
83750
83751
83752
83753
83754
83755
83756
83757
83758
83759
83760
83761
83762
83763
83764
83765
83766
83767
83768
83769
83770
83771
83772
83773
83774
83775
83776
83777
83778
83779
83780
83781
83782
83783
83784
83785
83786
83787
83788
83789
83790
83791
83792
83793
83794
83795
83796
83797
83798
83799
83800
83801
83802
83803
83804
83805
83806
83807
83808
83809
83810
83811
83812
83813
83814
83815
83816
83817
83818
83819
83820
83821
83822
83823
83824
83825
83826
83827
83828
83829
83830
83831
83832
83833
83834
83835
83836
83837
83838
83839
83840
83841
83842
83843
83844
83845
83846
83847
83848
83849
83850
83851
83852
83853
83854
83855
83856
83857
83858
83859
83860
83861
83862
83863
83864
83865
83866
83867
83868
83869
83870
83871
83872
83873
83874
83875
83876
83877
83878
83879
83880
83881
83882
83883
83884
83885
83886
83887
83888
83889
83890
83891
83892
83893
83894
83895
83896
83897
83898
83899
83900
83901
83902
83903
83904
83905
83906
83907
83908
83909
83910
83911
83912
83913
83914
83915
83916
83917
83918
83919
83920
83921
83922
83923
83924
83925
83926
83927
83928
83929
83930
83931
83932
83933
83934
83935
83936
83937
83938
83939
83940
83941
83942
83943
83944
83945
83946
83947
83948
83949
83950
83951
83952
83953
83954
83955
83956
83957
83958
83959
83960
83961
83962
83963
83964
83965
83966
83967
83968
83969
83970
83971
83972
83973
83974
83975
83976
83977
83978
83979
83980
83981
83982
83983
83984
83985
83986
83987
83988
83989
83990
83991
83992
83993
83994
83995
83996
83997
83998
83999
84000
84001
84002
84003
84004
84005
84006
84007
84008
84009
84010
84011
84012
84013
84014
84015
84016
84017
84018
84019
84020
84021
84022
84023
84024
84025
84026
84027
84028
84029
84030
84031
84032
84033
84034
84035
84036
84037
84038
84039
84040
84041
84042
84043
84044
84045
84046
84047
84048
84049
84050
84051
84052
84053
84054
84055
84056
84057
84058
84059
84060
84061
84062
84063
84064
84065
84066
84067
84068
84069
84070
84071
84072
84073
84074
84075
84076
84077
84078
84079
84080
84081
84082
84083
84084
84085
84086
84087
84088
84089
84090
84091
84092
84093
84094
84095
84096
84097
84098
84099
84100
84101
84102
84103
84104
84105
84106
84107
84108
84109
84110
84111
84112
84113
84114
84115
84116
84117
84118
84119
84120
84121
84122
84123
84124
84125
84126
84127
84128
84129
84130
84131
84132
84133
84134
84135
84136
84137
84138
84139
84140
84141
84142
84143
84144
84145
84146
84147
84148
84149
84150
84151
84152
84153
84154
84155
84156
84157
84158
84159
84160
84161
84162
84163
84164
84165
84166
84167
84168
84169
84170
84171
84172
84173
84174
84175
84176
84177
84178
84179
84180
84181
84182
84183
84184
84185
84186
84187
84188
84189
84190
84191
84192
84193
84194
84195
84196
84197
84198
84199
84200
84201
84202
84203
84204
84205
84206
84207
84208
84209
84210
84211
84212
84213
84214
84215
84216
84217
84218
84219
84220
84221
84222
84223
84224
84225
84226
84227
84228
84229
84230
84231
84232
84233
84234
84235
84236
84237
84238
84239
84240
84241
84242
84243
84244
84245
84246
84247
84248
84249
84250
84251
84252
84253
84254
84255
84256
84257
84258
84259
84260
84261
84262
84263
84264
84265
84266
84267
84268
84269
84270
84271
84272
84273
84274
84275
84276
84277
84278
84279
84280
84281
84282
84283
84284
84285
84286
84287
84288
84289
84290
84291
84292
84293
84294
84295
84296
84297
84298
84299
84300
84301
84302
84303
84304
84305
84306
84307
84308
84309
84310
84311
84312
84313
84314
84315
84316
84317
84318
84319
84320
84321
84322
84323
84324
84325
84326
84327
84328
84329
84330
84331
84332
84333
84334
84335
84336
84337
84338
84339
84340
84341
84342
84343
84344
84345
84346
84347
84348
84349
84350
84351
84352
84353
84354
84355
84356
84357
84358
84359
84360
84361
84362
84363
84364
84365
84366
84367
84368
84369
84370
84371
84372
84373
84374
84375
84376
84377
84378
84379
84380
84381
84382
84383
84384
84385
84386
84387
84388
84389
84390
84391
84392
84393
84394
84395
84396
84397
84398
84399
84400
84401
84402
84403
84404
84405
84406
84407
84408
84409
84410
84411
84412
84413
84414
84415
84416
84417
84418
84419
84420
84421
84422
84423
84424
84425
84426
84427
84428
84429
84430
84431
84432
84433
84434
84435
84436
84437
84438
84439
84440
84441
84442
84443
84444
84445
84446
84447
84448
84449
84450
84451
84452
84453
84454
84455
84456
84457
84458
84459
84460
84461
84462
84463
84464
84465
84466
84467
84468
84469
84470
84471
84472
84473
84474
84475
84476
84477
84478
84479
84480
84481
84482
84483
84484
84485
84486
84487
84488
84489
84490
84491
84492
84493
84494
84495
84496
84497
84498
84499
84500
84501
84502
84503
84504
84505
84506
84507
84508
84509
84510
84511
84512
84513
84514
84515
84516
84517
84518
84519
84520
84521
84522
84523
84524
84525
84526
84527
84528
84529
84530
84531
84532
84533
84534
84535
84536
84537
84538
84539
84540
84541
84542
84543
84544
84545
84546
84547
84548
84549
84550
84551
84552
84553
84554
84555
84556
84557
84558
84559
84560
84561
84562
84563
84564
84565
84566
84567
84568
84569
84570
84571
84572
84573
84574
84575
84576
84577
84578
84579
84580
84581
84582
84583
84584
84585
84586
84587
84588
84589
84590
84591
84592
84593
84594
84595
84596
84597
84598
84599
84600
84601
84602
84603
84604
84605
84606
84607
84608
84609
84610
84611
84612
84613
84614
84615
84616
84617
84618
84619
84620
84621
84622
84623
84624
84625
84626
84627
84628
84629
84630
84631
84632
84633
84634
84635
84636
84637
84638
84639
84640
84641
84642
84643
84644
84645
84646
84647
84648
84649
84650
84651
84652
84653
84654
84655
84656
84657
84658
84659
84660
84661
84662
84663
84664
84665
84666
84667
84668
84669
84670
84671
84672
84673
84674
84675
84676
84677
84678
84679
84680
84681
84682
84683
84684
84685
84686
84687
84688
84689
84690
84691
84692
84693
84694
84695
84696
84697
84698
84699
84700
84701
84702
84703
84704
84705
84706
84707
84708
84709
84710
84711
84712
84713
84714
84715
84716
84717
84718
84719
84720
84721
84722
84723
84724
84725
84726
84727
84728
84729
84730
84731
84732
84733
84734
84735
84736
84737
84738
84739
84740
84741
84742
84743
84744
84745
84746
84747
84748
84749
84750
84751
84752
84753
84754
84755
84756
84757
84758
84759
84760
84761
84762
84763
84764
84765
84766
84767
84768
84769
84770
84771
84772
84773
84774
84775
84776
84777
84778
84779
84780
84781
84782
84783
84784
84785
84786
84787
84788
84789
84790
84791
84792
84793
84794
84795
84796
84797
84798
84799
84800
84801
84802
84803
84804
84805
84806
84807
84808
84809
84810
84811
84812
84813
84814
84815
84816
84817
84818
84819
84820
84821
84822
84823
84824
84825
84826
84827
84828
84829
84830
84831
84832
84833
84834
84835
84836
84837
84838
84839
84840
84841
84842
84843
84844
84845
84846
84847
84848
84849
84850
84851
84852
84853
84854
84855
84856
84857
84858
84859
84860
84861
84862
84863
84864
84865
84866
84867
84868
84869
84870
84871
84872
84873
84874
84875
84876
84877
84878
84879
84880
84881
84882
84883
84884
84885
84886
84887
84888
84889
84890
84891
84892
84893
84894
84895
84896
84897
84898
84899
84900
84901
84902
84903
84904
84905
84906
84907
84908
84909
84910
84911
84912
84913
84914
84915
84916
84917
84918
84919
84920
84921
84922
84923
84924
84925
84926
84927
84928
84929
84930
84931
84932
84933
84934
84935
84936
84937
84938
84939
84940
84941
84942
84943
84944
84945
84946
84947
84948
84949
84950
84951
84952
84953
84954
84955
84956
84957
84958
84959
84960
84961
84962
84963
84964
84965
84966
84967
84968
84969
84970
84971
84972
84973
84974
84975
84976
84977
84978
84979
84980
84981
84982
84983
84984
84985
84986
84987
84988
84989
84990
84991
84992
84993
84994
84995
84996
84997
84998
84999
85000
85001
85002
85003
85004
85005
85006
85007
85008
85009
85010
85011
85012
85013
85014
85015
85016
85017
85018
85019
85020
85021
85022
85023
85024
85025
85026
85027
85028
85029
85030
85031
85032
85033
85034
85035
85036
85037
85038
85039
85040
85041
85042
85043
85044
85045
85046
85047
85048
85049
85050
85051
85052
85053
85054
85055
85056
85057
85058
85059
85060
85061
85062
85063
85064
85065
85066
85067
85068
85069
85070
85071
85072
85073
85074
85075
85076
85077
85078
85079
85080
85081
85082
85083
85084
85085
85086
85087
85088
85089
85090
85091
85092
85093
85094
85095
85096
85097
85098
85099
85100
85101
85102
85103
85104
85105
85106
85107
85108
85109
85110
85111
85112
85113
85114
85115
85116
85117
85118
85119
85120
85121
85122
85123
85124
85125
85126
85127
85128
85129
85130
85131
85132
85133
85134
85135
85136
85137
85138
85139
85140
85141
85142
85143
85144
85145
85146
85147
85148
85149
85150
85151
85152
85153
85154
85155
85156
85157
85158
85159
85160
85161
85162
85163
85164
85165
85166
85167
85168
85169
85170
85171
85172
85173
85174
85175
85176
85177
85178
85179
85180
85181
85182
85183
85184
85185
85186
85187
85188
85189
85190
85191
85192
85193
85194
85195
85196
85197
85198
85199
85200
85201
85202
85203
85204
85205
85206
85207
85208
85209
85210
85211
85212
85213
85214
85215
85216
85217
85218
85219
85220
85221
85222
85223
85224
85225
85226
85227
85228
85229
85230
85231
85232
85233
85234
85235
85236
85237
85238
85239
85240
85241
85242
85243
85244
85245
85246
85247
85248
85249
85250
85251
85252
85253
85254
85255
85256
85257
85258
85259
85260
85261
85262
85263
85264
85265
85266
85267
85268
85269
85270
85271
85272
85273
85274
85275
85276
85277
85278
85279
85280
85281
85282
85283
85284
85285
85286
85287
85288
85289
85290
85291
85292
85293
85294
85295
85296
85297
85298
85299
85300
85301
85302
85303
85304
85305
85306
85307
85308
85309
85310
85311
85312
85313
85314
85315
85316
85317
85318
85319
85320
85321
85322
85323
85324
85325
85326
85327
85328
85329
85330
85331
85332
85333
85334
85335
85336
85337
85338
85339
85340
85341
85342
85343
85344
85345
85346
85347
85348
85349
85350
85351
85352
85353
85354
85355
85356
85357
85358
85359
85360
85361
85362
85363
85364
85365
85366
85367
85368
85369
85370
85371
85372
85373
85374
85375
85376
85377
85378
85379
85380
85381
85382
85383
85384
85385
85386
85387
85388
85389
85390
85391
85392
85393
85394
85395
85396
85397
85398
85399
85400
85401
85402
85403
85404
85405
85406
85407
85408
85409
85410
85411
85412
85413
85414
85415
85416
85417
85418
85419
85420
85421
85422
85423
85424
85425
85426
85427
85428
85429
85430
85431
85432
85433
85434
85435
85436
85437
85438
85439
85440
85441
85442
85443
85444
85445
85446
85447
85448
85449
85450
85451
85452
85453
85454
85455
85456
85457
85458
85459
85460
85461
85462
85463
85464
85465
85466
85467
85468
85469
85470
85471
85472
85473
85474
85475
85476
85477
85478
85479
85480
85481
85482
85483
85484
85485
85486
85487
85488
85489
85490
85491
85492
85493
85494
85495
85496
85497
85498
85499
85500
85501
85502
85503
85504
85505
85506
85507
85508
85509
85510
85511
85512
85513
85514
85515
85516
85517
85518
85519
85520
85521
85522
85523
85524
85525
85526
85527
85528
85529
85530
85531
85532
85533
85534
85535
85536
85537
85538
85539
85540
85541
85542
85543
85544
85545
85546
85547
85548
85549
85550
85551
85552
85553
85554
85555
85556
85557
85558
85559
85560
85561
85562
85563
85564
85565
85566
85567
85568
85569
85570
85571
85572
85573
85574
85575
85576
85577
85578
85579
85580
85581
85582
85583
85584
85585
85586
85587
85588
85589
85590
85591
85592
85593
85594
85595
85596
85597
85598
85599
85600
85601
85602
85603
85604
85605
85606
85607
85608
85609
85610
85611
85612
85613
85614
85615
85616
85617
85618
85619
85620
85621
85622
85623
85624
85625
85626
85627
85628
85629
85630
85631
85632
85633
85634
85635
85636
85637
85638
85639
85640
85641
85642
85643
85644
85645
85646
85647
85648
85649
85650
85651
85652
85653
85654
85655
85656
85657
85658
85659
85660
85661
85662
85663
85664
85665
85666
85667
85668
85669
85670
85671
85672
85673
85674
85675
85676
85677
85678
85679
85680
85681
85682
85683
85684
85685
85686
85687
85688
85689
85690
85691
85692
85693
85694
85695
85696
85697
85698
85699
85700
85701
85702
85703
85704
85705
85706
85707
85708
85709
85710
85711
85712
85713
85714
85715
85716
85717
85718
85719
85720
85721
85722
85723
85724
85725
85726
85727
85728
85729
85730
85731
85732
85733
85734
85735
85736
85737
85738
85739
85740
85741
85742
85743
85744
85745
85746
85747
85748
85749
85750
85751
85752
85753
85754
85755
85756
85757
85758
85759
85760
85761
85762
85763
85764
85765
85766
85767
85768
85769
85770
85771
85772
85773
85774
85775
85776
85777
85778
85779
85780
85781
85782
85783
85784
85785
85786
85787
85788
85789
85790
85791
85792
85793
85794
85795
85796
85797
85798
85799
85800
85801
85802
85803
85804
85805
85806
85807
85808
85809
85810
85811
85812
85813
85814
85815
85816
85817
85818
85819
85820
85821
85822
85823
85824
85825
85826
85827
85828
85829
85830
85831
85832
85833
85834
85835
85836
85837
85838
85839
85840
85841
85842
85843
85844
85845
85846
85847
85848
85849
85850
85851
85852
85853
85854
85855
85856
85857
85858
85859
85860
85861
85862
85863
85864
85865
85866
85867
85868
85869
85870
85871
85872
85873
85874
85875
85876
85877
85878
85879
85880
85881
85882
85883
85884
85885
85886
85887
85888
85889
85890
85891
85892
85893
85894
85895
85896
85897
85898
85899
85900
85901
85902
85903
85904
85905
85906
85907
85908
85909
85910
85911
85912
85913
85914
85915
85916
85917
85918
85919
85920
85921
85922
85923
85924
85925
85926
85927
85928
85929
85930
85931
85932
85933
85934
85935
85936
85937
85938
85939
85940
85941
85942
85943
85944
85945
85946
85947
85948
85949
85950
85951
85952
85953
85954
85955
85956
85957
85958
85959
85960
85961
85962
85963
85964
85965
85966
85967
85968
85969
85970
85971
85972
85973
85974
85975
85976
85977
85978
85979
85980
85981
85982
85983
85984
85985
85986
85987
85988
85989
85990
85991
85992
85993
85994
85995
85996
85997
85998
85999
86000
86001
86002
86003
86004
86005
86006
86007
86008
86009
86010
86011
86012
86013
86014
86015
86016
86017
86018
86019
86020
86021
86022
86023
86024
86025
86026
86027
86028
86029
86030
86031
86032
86033
86034
86035
86036
86037
86038
86039
86040
86041
86042
86043
86044
86045
86046
86047
86048
86049
86050
86051
86052
86053
86054
86055
86056
86057
86058
86059
86060
86061
86062
86063
86064
86065
86066
86067
86068
86069
86070
86071
86072
86073
86074
86075
86076
86077
86078
86079
86080
86081
86082
86083
86084
86085
86086
86087
86088
86089
86090
86091
86092
86093
86094
86095
86096
86097
86098
86099
86100
86101
86102
86103
86104
86105
86106
86107
86108
86109
86110
86111
86112
86113
86114
86115
86116
86117
86118
86119
86120
86121
86122
86123
86124
86125
86126
86127
86128
86129
86130
86131
86132
86133
86134
86135
86136
86137
86138
86139
86140
86141
86142
86143
86144
86145
86146
86147
86148
86149
86150
86151
86152
86153
86154
86155
86156
86157
86158
86159
86160
86161
86162
86163
86164
86165
86166
86167
86168
86169
86170
86171
86172
86173
86174
86175
86176
86177
86178
86179
86180
86181
86182
86183
86184
86185
86186
86187
86188
86189
86190
86191
86192
86193
86194
86195
86196
86197
86198
86199
86200
86201
86202
86203
86204
86205
86206
86207
86208
86209
86210
86211
86212
86213
86214
86215
86216
86217
86218
86219
86220
86221
86222
86223
86224
86225
86226
86227
86228
86229
86230
86231
86232
86233
86234
86235
86236
86237
86238
86239
86240
86241
86242
86243
86244
86245
86246
86247
86248
86249
86250
86251
86252
86253
86254
86255
86256
86257
86258
86259
86260
86261
86262
86263
86264
86265
86266
86267
86268
86269
86270
86271
86272
86273
86274
86275
86276
86277
86278
86279
86280
86281
86282
86283
86284
86285
86286
86287
86288
86289
86290
86291
86292
86293
86294
86295
86296
86297
86298
86299
86300
86301
86302
86303
86304
86305
86306
86307
86308
86309
86310
86311
86312
86313
86314
86315
86316
86317
86318
86319
86320
86321
86322
86323
86324
86325
86326
86327
86328
86329
86330
86331
86332
86333
86334
86335
86336
86337
86338
86339
86340
86341
86342
86343
86344
86345
86346
86347
86348
86349
86350
86351
86352
86353
86354
86355
86356
86357
86358
86359
86360
86361
86362
86363
86364
86365
86366
86367
86368
86369
86370
86371
86372
86373
86374
86375
86376
86377
86378
86379
86380
86381
86382
86383
86384
86385
86386
86387
86388
86389
86390
86391
86392
86393
86394
86395
86396
86397
86398
86399
86400
86401
86402
86403
86404
86405
86406
86407
86408
86409
86410
86411
86412
86413
86414
86415
86416
86417
86418
86419
86420
86421
86422
86423
86424
86425
86426
86427
86428
86429
86430
86431
86432
86433
86434
86435
86436
86437
86438
86439
86440
86441
86442
86443
86444
86445
86446
86447
86448
86449
86450
86451
86452
86453
86454
86455
86456
86457
86458
86459
86460
86461
86462
86463
86464
86465
86466
86467
86468
86469
86470
86471
86472
86473
86474
86475
86476
86477
86478
86479
86480
86481
86482
86483
86484
86485
86486
86487
86488
86489
86490
86491
86492
86493
86494
86495
86496
86497
86498
86499
86500
86501
86502
86503
86504
86505
86506
86507
86508
86509
86510
86511
86512
86513
86514
86515
86516
86517
86518
86519
86520
86521
86522
86523
86524
86525
86526
86527
86528
86529
86530
86531
86532
86533
86534
86535
86536
86537
86538
86539
86540
86541
86542
86543
86544
86545
86546
86547
86548
86549
86550
86551
86552
86553
86554
86555
86556
86557
86558
86559
86560
86561
86562
86563
86564
86565
86566
86567
86568
86569
86570
86571
86572
86573
86574
86575
86576
86577
86578
86579
86580
86581
86582
86583
86584
86585
86586
86587
86588
86589
86590
86591
86592
86593
86594
86595
86596
86597
86598
86599
86600
86601
86602
86603
86604
86605
86606
86607
86608
86609
86610
86611
86612
86613
86614
86615
86616
86617
86618
86619
86620
86621
86622
86623
86624
86625
86626
86627
86628
86629
86630
86631
86632
86633
86634
86635
86636
86637
86638
86639
86640
86641
86642
86643
86644
86645
86646
86647
86648
86649
86650
86651
86652
86653
86654
86655
86656
86657
86658
86659
86660
86661
86662
86663
86664
86665
86666
86667
86668
86669
86670
86671
86672
86673
86674
86675
86676
86677
86678
86679
86680
86681
86682
86683
86684
86685
86686
86687
86688
86689
86690
86691
86692
86693
86694
86695
86696
86697
86698
86699
86700
86701
86702
86703
86704
86705
86706
86707
86708
86709
86710
86711
86712
86713
86714
86715
86716
86717
86718
86719
86720
86721
86722
86723
86724
86725
86726
86727
86728
86729
86730
86731
86732
86733
86734
86735
86736
86737
86738
86739
86740
86741
86742
86743
86744
86745
86746
86747
86748
86749
86750
86751
86752
86753
86754
86755
86756
86757
86758
86759
86760
86761
86762
86763
86764
86765
86766
86767
86768
86769
86770
86771
86772
86773
86774
86775
86776
86777
86778
86779
86780
86781
86782
86783
86784
86785
86786
86787
86788
86789
86790
86791
86792
86793
86794
86795
86796
86797
86798
86799
86800
86801
86802
86803
86804
86805
86806
86807
86808
86809
86810
86811
86812
86813
86814
86815
86816
86817
86818
86819
86820
86821
86822
86823
86824
86825
86826
86827
86828
86829
86830
86831
86832
86833
86834
86835
86836
86837
86838
86839
86840
86841
86842
86843
86844
86845
86846
86847
86848
86849
86850
86851
86852
86853
86854
86855
86856
86857
86858
86859
86860
86861
86862
86863
86864
86865
86866
86867
86868
86869
86870
86871
86872
86873
86874
86875
86876
86877
86878
86879
86880
86881
86882
86883
86884
86885
86886
86887
86888
86889
86890
86891
86892
86893
86894
86895
86896
86897
86898
86899
86900
86901
86902
86903
86904
86905
86906
86907
86908
86909
86910
86911
86912
86913
86914
86915
86916
86917
86918
86919
86920
86921
86922
86923
86924
86925
86926
86927
86928
86929
86930
86931
86932
86933
86934
86935
86936
86937
86938
86939
86940
86941
86942
86943
86944
86945
86946
86947
86948
86949
86950
86951
86952
86953
86954
86955
86956
86957
86958
86959
86960
86961
86962
86963
86964
86965
86966
86967
86968
86969
86970
86971
86972
86973
86974
86975
86976
86977
86978
86979
86980
86981
86982
86983
86984
86985
86986
86987
86988
86989
86990
86991
86992
86993
86994
86995
86996
86997
86998
86999
87000
87001
87002
87003
87004
87005
87006
87007
87008
87009
87010
87011
87012
87013
87014
87015
87016
87017
87018
87019
87020
87021
87022
87023
87024
87025
87026
87027
87028
87029
87030
87031
87032
87033
87034
87035
87036
87037
87038
87039
87040
87041
87042
87043
87044
87045
87046
87047
87048
87049
87050
87051
87052
87053
87054
87055
87056
87057
87058
87059
87060
87061
87062
87063
87064
87065
87066
87067
87068
87069
87070
87071
87072
87073
87074
87075
87076
87077
87078
87079
87080
87081
87082
87083
87084
87085
87086
87087
87088
87089
87090
87091
87092
87093
87094
87095
87096
87097
87098
87099
87100
87101
87102
87103
87104
87105
87106
87107
87108
87109
87110
87111
87112
87113
87114
87115
87116
87117
87118
87119
87120
87121
87122
87123
87124
87125
87126
87127
87128
87129
87130
87131
87132
87133
87134
87135
87136
87137
87138
87139
87140
87141
87142
87143
87144
87145
87146
87147
87148
87149
87150
87151
87152
87153
87154
87155
87156
87157
87158
87159
87160
87161
87162
87163
87164
87165
87166
87167
87168
87169
87170
87171
87172
87173
87174
87175
87176
87177
87178
87179
87180
87181
87182
87183
87184
87185
87186
87187
87188
87189
87190
87191
87192
87193
87194
87195
87196
87197
87198
87199
87200
87201
87202
87203
87204
87205
87206
87207
87208
87209
87210
87211
87212
87213
87214
87215
87216
87217
87218
87219
87220
87221
87222
87223
87224
87225
87226
87227
87228
87229
87230
87231
87232
87233
87234
87235
87236
87237
87238
87239
87240
87241
87242
87243
87244
87245
87246
87247
87248
87249
87250
87251
87252
87253
87254
87255
87256
87257
87258
87259
87260
87261
87262
87263
87264
87265
87266
87267
87268
87269
87270
87271
87272
87273
87274
87275
87276
87277
87278
87279
87280
87281
87282
87283
87284
87285
87286
87287
87288
87289
87290
87291
87292
87293
87294
87295
87296
87297
87298
87299
87300
87301
87302
87303
87304
87305
87306
87307
87308
87309
87310
87311
87312
87313
87314
87315
87316
87317
87318
87319
87320
87321
87322
87323
87324
87325
87326
87327
87328
87329
87330
87331
87332
87333
87334
87335
87336
87337
87338
87339
87340
87341
87342
87343
87344
87345
87346
87347
87348
87349
87350
87351
87352
87353
87354
87355
87356
87357
87358
87359
87360
87361
87362
87363
87364
87365
87366
87367
87368
87369
87370
87371
87372
87373
87374
87375
87376
87377
87378
87379
87380
87381
87382
87383
87384
87385
87386
87387
87388
87389
87390
87391
87392
87393
87394
87395
87396
87397
87398
87399
87400
87401
87402
87403
87404
87405
87406
87407
87408
87409
87410
87411
87412
87413
87414
87415
87416
87417
87418
87419
87420
87421
87422
87423
87424
87425
87426
87427
87428
87429
87430
87431
87432
87433
87434
87435
87436
87437
87438
87439
87440
87441
87442
87443
87444
87445
87446
87447
87448
87449
87450
87451
87452
87453
87454
87455
87456
87457
87458
87459
87460
87461
87462
87463
87464
87465
87466
87467
87468
87469
87470
87471
87472
87473
87474
87475
87476
87477
87478
87479
87480
87481
87482
87483
87484
87485
87486
87487
87488
87489
87490
87491
87492
87493
87494
87495
87496
87497
87498
87499
87500
87501
87502
87503
87504
87505
87506
87507
87508
87509
87510
87511
87512
87513
87514
87515
87516
87517
87518
87519
87520
87521
87522
87523
87524
87525
87526
87527
87528
87529
87530
87531
87532
87533
87534
87535
87536
87537
87538
87539
87540
87541
87542
87543
87544
87545
87546
87547
87548
87549
87550
87551
87552
87553
87554
87555
87556
87557
87558
87559
87560
87561
87562
87563
87564
87565
87566
87567
87568
87569
87570
87571
87572
87573
87574
87575
87576
87577
87578
87579
87580
87581
87582
87583
87584
87585
87586
87587
87588
87589
87590
87591
87592
87593
87594
87595
87596
87597
87598
87599
87600
87601
87602
87603
87604
87605
87606
87607
87608
87609
87610
87611
87612
87613
87614
87615
87616
87617
87618
87619
87620
87621
87622
87623
87624
87625
87626
87627
87628
87629
87630
87631
87632
87633
87634
87635
87636
87637
87638
87639
87640
87641
87642
87643
87644
87645
87646
87647
87648
87649
87650
87651
87652
87653
87654
87655
87656
87657
87658
87659
87660
87661
87662
87663
87664
87665
87666
87667
87668
87669
87670
87671
87672
87673
87674
87675
87676
87677
87678
87679
87680
87681
87682
87683
87684
87685
87686
87687
87688
87689
87690
87691
87692
87693
87694
87695
87696
87697
87698
87699
87700
87701
87702
87703
87704
87705
87706
87707
87708
87709
87710
87711
87712
87713
87714
87715
87716
87717
87718
87719
87720
87721
87722
87723
87724
87725
87726
87727
87728
87729
87730
87731
87732
87733
87734
87735
87736
87737
87738
87739
87740
87741
87742
87743
87744
87745
87746
87747
87748
87749
87750
87751
87752
87753
87754
87755
87756
87757
87758
87759
87760
87761
87762
87763
87764
87765
87766
87767
87768
87769
87770
87771
87772
87773
87774
87775
87776
87777
87778
87779
87780
87781
87782
87783
87784
87785
87786
87787
87788
87789
87790
87791
87792
87793
87794
87795
87796
87797
87798
87799
87800
87801
87802
87803
87804
87805
87806
87807
87808
87809
87810
87811
87812
87813
87814
87815
87816
87817
87818
87819
87820
87821
87822
87823
87824
87825
87826
87827
87828
87829
87830
87831
87832
87833
87834
87835
87836
87837
87838
87839
87840
87841
87842
87843
87844
87845
87846
87847
87848
87849
87850
87851
87852
87853
87854
87855
87856
87857
87858
87859
87860
87861
87862
87863
87864
87865
87866
87867
87868
87869
87870
87871
87872
87873
87874
87875
87876
87877
87878
87879
87880
87881
87882
87883
87884
87885
87886
87887
87888
87889
87890
87891
87892
87893
87894
87895
87896
87897
87898
87899
87900
87901
87902
87903
87904
87905
87906
87907
87908
87909
87910
87911
87912
87913
87914
87915
87916
87917
87918
87919
87920
87921
87922
87923
87924
87925
87926
87927
87928
87929
87930
87931
87932
87933
87934
87935
87936
87937
87938
87939
87940
87941
87942
87943
87944
87945
87946
87947
87948
87949
87950
87951
87952
87953
87954
87955
87956
87957
87958
87959
87960
87961
87962
87963
87964
87965
87966
87967
87968
87969
87970
87971
87972
87973
87974
87975
87976
87977
87978
87979
87980
87981
87982
87983
87984
87985
87986
87987
87988
87989
87990
87991
87992
87993
87994
87995
87996
87997
87998
87999
88000
88001
88002
88003
88004
88005
88006
88007
88008
88009
88010
88011
88012
88013
88014
88015
88016
88017
88018
88019
88020
88021
88022
88023
88024
88025
88026
88027
88028
88029
88030
88031
88032
88033
88034
88035
88036
88037
88038
88039
88040
88041
88042
88043
88044
88045
88046
88047
88048
88049
88050
88051
88052
88053
88054
88055
88056
88057
88058
88059
88060
88061
88062
88063
88064
88065
88066
88067
88068
88069
88070
88071
88072
88073
88074
88075
88076
88077
88078
88079
88080
88081
88082
88083
88084
88085
88086
88087
88088
88089
88090
88091
88092
88093
88094
88095
88096
88097
88098
88099
88100
88101
88102
88103
88104
88105
88106
88107
88108
88109
88110
88111
88112
88113
88114
88115
88116
88117
88118
88119
88120
88121
88122
88123
88124
88125
88126
88127
88128
88129
88130
88131
88132
88133
88134
88135
88136
88137
88138
88139
88140
88141
88142
88143
88144
88145
88146
88147
88148
88149
88150
88151
88152
88153
88154
88155
88156
88157
88158
88159
88160
88161
88162
88163
88164
88165
88166
88167
88168
88169
88170
88171
88172
88173
88174
88175
88176
88177
88178
88179
88180
88181
88182
88183
88184
88185
88186
88187
88188
88189
88190
88191
88192
88193
88194
88195
88196
88197
88198
88199
88200
88201
88202
88203
88204
88205
88206
88207
88208
88209
88210
88211
88212
88213
88214
88215
88216
88217
88218
88219
88220
88221
88222
88223
88224
88225
88226
88227
88228
88229
88230
88231
88232
88233
88234
88235
88236
88237
88238
88239
88240
88241
88242
88243
88244
88245
88246
88247
88248
88249
88250
88251
88252
88253
88254
88255
88256
88257
88258
88259
88260
88261
88262
88263
88264
88265
88266
88267
88268
88269
88270
88271
88272
88273
88274
88275
88276
88277
88278
88279
88280
88281
88282
88283
88284
88285
88286
88287
88288
88289
88290
88291
88292
88293
88294
88295
88296
88297
88298
88299
88300
88301
88302
88303
88304
88305
88306
88307
88308
88309
88310
88311
88312
88313
88314
88315
88316
88317
88318
88319
88320
88321
88322
88323
88324
88325
88326
88327
88328
88329
88330
88331
88332
88333
88334
88335
88336
88337
88338
88339
88340
88341
88342
88343
88344
88345
88346
88347
88348
88349
88350
88351
88352
88353
88354
88355
88356
88357
88358
88359
88360
88361
88362
88363
88364
88365
88366
88367
88368
88369
88370
88371
88372
88373
88374
88375
88376
88377
88378
88379
88380
88381
88382
88383
88384
88385
88386
88387
88388
88389
88390
88391
88392
88393
88394
88395
88396
88397
88398
88399
88400
88401
88402
88403
88404
88405
88406
88407
88408
88409
88410
88411
88412
88413
88414
88415
88416
88417
88418
88419
88420
88421
88422
88423
88424
88425
88426
88427
88428
88429
88430
88431
88432
88433
88434
88435
88436
88437
88438
88439
88440
88441
88442
88443
88444
88445
88446
88447
88448
88449
88450
88451
88452
88453
88454
88455
88456
88457
88458
88459
88460
88461
88462
88463
88464
88465
88466
88467
88468
88469
88470
88471
88472
88473
88474
88475
88476
88477
88478
88479
88480
88481
88482
88483
88484
88485
88486
88487
88488
88489
88490
88491
88492
88493
88494
88495
88496
88497
88498
88499
88500
88501
88502
88503
88504
88505
88506
88507
88508
88509
88510
88511
88512
88513
88514
88515
88516
88517
88518
88519
88520
88521
88522
88523
88524
88525
88526
88527
88528
88529
88530
88531
88532
88533
88534
88535
88536
88537
88538
88539
88540
88541
88542
88543
88544
88545
88546
88547
88548
88549
88550
88551
88552
88553
88554
88555
88556
88557
88558
88559
88560
88561
88562
88563
88564
88565
88566
88567
88568
88569
88570
88571
88572
88573
88574
88575
88576
88577
88578
88579
88580
88581
88582
88583
88584
88585
88586
88587
88588
88589
88590
88591
88592
88593
88594
88595
88596
88597
88598
88599
88600
88601
88602
88603
88604
88605
88606
88607
88608
88609
88610
88611
88612
88613
88614
88615
88616
88617
88618
88619
88620
88621
88622
88623
88624
88625
88626
88627
88628
88629
88630
88631
88632
88633
88634
88635
88636
88637
88638
88639
88640
88641
88642
88643
88644
88645
88646
88647
88648
88649
88650
88651
88652
88653
88654
88655
88656
88657
88658
88659
88660
88661
88662
88663
88664
88665
88666
88667
88668
88669
88670
88671
88672
88673
88674
88675
88676
88677
88678
88679
88680
88681
88682
88683
88684
88685
88686
88687
88688
88689
88690
88691
88692
88693
88694
88695
88696
88697
88698
88699
88700
88701
88702
88703
88704
88705
88706
88707
88708
88709
88710
88711
88712
88713
88714
88715
88716
88717
88718
88719
88720
88721
88722
88723
88724
88725
88726
88727
88728
88729
88730
88731
88732
88733
88734
88735
88736
88737
88738
88739
88740
88741
88742
88743
88744
88745
88746
88747
88748
88749
88750
88751
88752
88753
88754
88755
88756
88757
88758
88759
88760
88761
88762
88763
88764
88765
88766
88767
88768
88769
88770
88771
88772
88773
88774
88775
88776
88777
88778
88779
88780
88781
88782
88783
88784
88785
88786
88787
88788
88789
88790
88791
88792
88793
88794
88795
88796
88797
88798
88799
88800
88801
88802
88803
88804
88805
88806
88807
88808
88809
88810
88811
88812
88813
88814
88815
88816
88817
88818
88819
88820
88821
88822
88823
88824
88825
88826
88827
88828
88829
88830
88831
88832
88833
88834
88835
88836
88837
88838
88839
88840
88841
88842
88843
88844
88845
88846
88847
88848
88849
88850
88851
88852
88853
88854
88855
88856
88857
88858
88859
88860
88861
88862
88863
88864
88865
88866
88867
88868
88869
88870
88871
88872
88873
88874
88875
88876
88877
88878
88879
88880
88881
88882
88883
88884
88885
88886
88887
88888
88889
88890
88891
88892
88893
88894
88895
88896
88897
88898
88899
88900
88901
88902
88903
88904
88905
88906
88907
88908
88909
88910
88911
88912
88913
88914
88915
88916
88917
88918
88919
88920
88921
88922
88923
88924
88925
88926
88927
88928
88929
88930
88931
88932
88933
88934
88935
88936
88937
88938
88939
88940
88941
88942
88943
88944
88945
88946
88947
88948
88949
88950
88951
88952
88953
88954
88955
88956
88957
88958
88959
88960
88961
88962
88963
88964
88965
88966
88967
88968
88969
88970
88971
88972
88973
88974
88975
88976
88977
88978
88979
88980
88981
88982
88983
88984
88985
88986
88987
88988
88989
88990
88991
88992
88993
88994
88995
88996
88997
88998
88999
89000
89001
89002
89003
89004
89005
89006
89007
89008
89009
89010
89011
89012
89013
89014
89015
89016
89017
89018
89019
89020
89021
89022
89023
89024
89025
89026
89027
89028
89029
89030
89031
89032
89033
89034
89035
89036
89037
89038
89039
89040
89041
89042
89043
89044
89045
89046
89047
89048
89049
89050
89051
89052
89053
89054
89055
89056
89057
89058
89059
89060
89061
89062
89063
89064
89065
89066
89067
89068
89069
89070
89071
89072
89073
89074
89075
89076
89077
89078
89079
89080
89081
89082
89083
89084
89085
89086
89087
89088
89089
89090
89091
89092
89093
89094
89095
89096
89097
89098
89099
89100
89101
89102
89103
89104
89105
89106
89107
89108
89109
89110
89111
89112
89113
89114
89115
89116
89117
89118
89119
89120
89121
89122
89123
89124
89125
89126
89127
89128
89129
89130
89131
89132
89133
89134
89135
89136
89137
89138
89139
89140
89141
89142
89143
89144
89145
89146
89147
89148
89149
89150
89151
89152
89153
89154
89155
89156
89157
89158
89159
89160
89161
89162
89163
89164
89165
89166
89167
89168
89169
89170
89171
89172
89173
89174
89175
89176
89177
89178
89179
89180
89181
89182
89183
|
diff -urN linux-2.4.26/Documentation/Configure.help linux-2.4.26-vrs1/Documentation/Configure.help
--- linux-2.4.26/Documentation/Configure.help 2004-04-19 11:44:14.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/Configure.help 2004-04-18 21:47:49.000000000 +0100
@@ -4879,6 +4879,13 @@
Say Y to enable support for Permedia2 AGP frame buffer card from
3Dlabs (aka `Graphic Blaster Exxtreme') on the PCI bus.
+Permedia3 support (EXPERIMENTAL)
+CONFIG_FB_PM3
+ This is the frame buffer device driver for the 3DLabs Permedia3
+ chipset, used in Formac ProFormance III, 3DLabs Oxygen VX1 &
+ similar boards, 3DLabs Permedia3 Create!, Appian Jeronimo 2000
+ and maybe other boards.
+
Phase5 CVisionPPC/BVisionPPC support
CONFIG_FB_PM2_CVPPC
Say Y to enable support for the Amiga Phase 5 CVisionPPC BVisionPPC
@@ -13213,6 +13220,17 @@
The module will be called tmspci.o. If you want to compile it
as a module, say M here and read <file:Documentation/modules.txt>.
+Altera ether00 support
+CONFIG_ETHER00
+ This is the driver for Altera's ether00 ethernet mac IP core. Say
+ Y here if you want to build support for this into the kernel. It
+ is also available as a module (say M here) that can be inserted/
+ removed from the kernel at the same time as the PLD is configured.
+ If this driver is running on an epxa10 development board then it
+ will generate a suitable hw address based on the board serial
+ number (MTD support is required for this). Otherwise you will
+ need to set a suitable hw address using ifconfig.
+
Generic TMS380 ISA support
CONFIG_TMSISA
This tms380 module supports generic TMS380-based ISA cards.
@@ -15157,6 +15175,16 @@
support" be compiled as a module for this driver to be used
properly.
+Altera's uart00 serial driver
+CONFIG_SERIAL_UART00
+ 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.
+
+Serial console on uart00
+CONFIG_SERIAL_UART00_CONSOLE
+ Say Y here if you want to support a serial console on an Excalibur
+ hard logic uart or uart00 IP core.
+
USB ConnectTech WhiteHEAT Serial Driver
CONFIG_USB_SERIAL_WHITEHEAT
Say Y here if you want to use a ConnectTech WhiteHEAT 4 port
@@ -19173,6 +19201,20 @@
<file:Documentation/modules.txt>.
The module will be called i2c-velleman.o.
+Guide GPIO adapter
+CONFIG_I2C_GUIDE
+ This supports the Iders GUIDE I2C bit-bashing adapter. If you have
+ selected the GUIDE A07 as your ARM system type, you cannot deselect
+ this option, as it is required for proper operation of the GUIDE.
+
+ This interface uses /dev/i2c-0 (major 89, minor 0).
+
+ Say Y if you own such an adapter.
+
+ This driver is also available as a module. If you want to compile
+ it as a module, say M here and read Documentation/modules.txt. The
+ module will be called i2c-guide.o.
+
I2C PCF 8584 interfaces
CONFIG_I2C_ALGOPCF
This allows you to use a range of I2C adapters called PCF adapters.
@@ -20310,6 +20352,17 @@
<file:Documentation/modules.txt>. The module will be called
softdog.o.
+SA1100 Internal Watchdog
+CONFIG_SA1100_WATCHDOG
+ Watchdog timer embedded into SA11x0 chips. This will reboot your
+ system when timeout is reached.
+ NOTE, that once enabled, this timer cannot be disabled.
+
+ This driver is also available as a module ( = code which can be
+ inserted in and removed from the running kernel whenever you want).
+ If you want to compile it as a module, say M here and read
+ Documentation/modules.txt. The module will be called sa1100_wdt.o.
+
Berkshire Products PC Watchdog
CONFIG_PCWATCHDOG
This is the driver for the Berkshire Products PC Watchdog card.
@@ -21971,6 +22024,30 @@
from RME. If you want to acess advanced features of the card, read
Documentation/sound/rme96xx.
+Assabet audio (UDA1341) support
+CONFIG_SOUND_ASSABET_UDA1341
+ Say Y or M if you have an Intel Assabet evaluation board and want to
+ use the Philips UDA 1341 audio chip (the one that drives the stereo
+ audio output) on the SA1100 SSP port.
+
+Compaq iPAQ audio support
+CONFIG_SOUND_H3600_UDA1341
+ Say Y or M if you have a Compaq iPaq handheld computer and want to
+ use its Philips UDA 1341 audio chip.
+
+Audio support for SA1111/UDA1341
+CONFIG_SOUND_SA1111_UDA1341
+ Say Y or M if you have an SA11x0 system with a Philips UDA 1341
+ connected to the SA11x1. An example of such a system is the Intel
+ Assabet evaluation board connected to a Neponset expansion board.
+
+Generic DAC on the SA11x0 SSP port
+CONFIG_SOUND_SA1100SSP
+ Say Y or M if you have an SA-11x0 system with a DAC on the SSP port.
+ The LART has an Burr-Brown PCM 1710 digital to analog convertor on
+ the SSP port, so you want to say Y or M for the LART. It might work
+ on other SA-1100 platforms, too, but this is not tested.
+
Are you using a crosscompiler
CONFIG_CROSSCOMPILE
Say Y here if you are compiling the kernel on a different
@@ -25674,6 +25751,20 @@
Say Y if configuring for a Pangolin.
Say N otherwise.
+Shannon
+CONFIG_SA1100_SHANNON
+ The Shannon (also known as a Tuxscreen, and also as a IS2630) was a
+ limited edition webphone produced by Philips. The Shannon is a SA1100
+ platform with a 640x480 LCD, touchscreen, CIR keyboard, PCMCIA slots,
+ and a telco interface.
+
+Simputer
+CONFIG_SA1100_SIMPUTER
+ Say Y here if you are using an Intel(R) StrongARM(R) SA-1110
+ based Simputer. See http://www.simputer.org/ for information
+ on the Simputer. The Simputer software is actively maintained
+ by PicoPeta Simputers Pvt. Ltd. (http://www.picopeta.com)
+
Victor
CONFIG_SA1100_VICTOR
Say Y here if you are using a Visu Aide Intel(R) StrongARM(R)
@@ -25681,6 +25772,14 @@
<http://www.visuaide.com/pagevictor.en.html> for information on
this system.
+Radisys Corp. Tulsa
+CONFIG_SA1100_PFS168
+ The Radisys Corp. PFS-168 (aka Tulsa) is an Intel® StrongArm® SA-1110 based
+ computer which includes the SA-1111 Microprocessor Companion Chip and other
+ custom I/O designed to add connectivity and multimedia features for vending
+ and business machine applications. Say Y here if you require support for
+ this target.
+
# Choice: cerf_ram
Cerf on-board RAM size
CONFIG_SA1100_CERF_8MB
@@ -25748,37 +25847,65 @@
Say Y if you want support for the ARM920T processor.
Otherwise, say N.
-Support ARM1020 processor
-CONFIG_CPU_ARM1020
- The ARM1020 is the cached version of the ARM10 processor,
- with an addition of a floating-point unit.
+Support ARM922T processor
+CONFIG_CPU_ARM922T
+ The ARM922T is a version of the ARM920T, but with smaller
+ instruction and data caches. It is used in Altera's
+ Excalibur XA device family.
- Say Y if you want support for the ARM1020 processor.
+ Say Y if you want support for the ARM922T processor.
Otherwise, say N.
-Disable I-Cache
+Disable instruction cache
CONFIG_CPU_ICACHE_DISABLE
- Say Y here to disable the processor instruction cache. Unless
- you have a reason not to or are unsure, say N.
+ Say Y here to disable the processor instruction cache. Unless
+ you have a reason to do this, say N.
-Disable D-Cache
+Disable data cache
CONFIG_CPU_DCACHE_DISABLE
- Say Y here to disable the processor data cache. Unless
- you have a reason not to or are unsure, say N.
+ Say Y here to disable the processor data cache. Unless
+ you have a reason to do this, say N.
-Force write through D-cache
+Use data cache in writethrough mode
CONFIG_CPU_DCACHE_WRITETHROUGH
- Say Y here to use the data cache in write-through mode. Unless you
- specifically require this or are unsure, say N.
+ Say Y here to use the data cache in writethough mode. Unless you
+ specifically require this, say N.
+
+Support ARM1020 processor
+CONFIG_CPU_ARM1020
+ The ARM1020 is the 32K cached version of the ARM10 processor,
+ with an addition of a floating-point unit.
+
+ Say Y if you want support for the ARM1020 processor.
+ Otherwise, say N.
+
+Support ARM1022 processor
+CONFIG_CPU_ARM1022
+ The ARM1022E is the 16K cached version of the ARM10 processor,
+ with an addition of a floating-point unit.
+
+ Say Y if you want support for the ARM1022 processor.
+ Otherwise, say N.
-Round robin I and D cache replacement algorithm
+Force round-robin cache line replacement
CONFIG_CPU_CACHE_ROUND_ROBIN
- Say Y here to use the predictable round-robin cache replacement
- policy. Unless you specifically require this or are unsure, say N.
+ Say Y here to force the caches to use a round-robin
+ algorithm when picking a cache line to evict. Unless you
+ specifically require this, say N.
+
+Disable the write buffer
+CONFIG_CPU_WB_DISABLE
+ Say Y here to turn off the write buffer (if possible)
+ Unless you specifically require this, say N. Note that
+ not all ARM processors allow the write buffer to be
+ disabled.
Disable branch prediction
CONFIG_CPU_BPREDICT_DISABLE
- Say Y here to disable branch prediction. If unsure, say N.
+ The ARM10 family of processors support branch prediction,
+ which can significantly speed up execution of loops.
+ Say Y here to disable branch prediction. Unless you
+ specifically require this, say N.
Compressed boot loader in ROM/flash
CONFIG_ZBOOT_ROM
@@ -25825,6 +25952,11 @@
Say Y here if you are using the inhand electronics OmniMeter. See
<http://www.inhandelectronics.com/html/omni1.html> for details.
+HP Laboratories BadgePAD 4
+CONFIG_SA1100_BADGE4
+ Say Y here if you want to build a kernel for the HP Laboratories
+ BadgePAD 4.
+
Load kernel using Angel Debug Monitor
CONFIG_ANGELBOOT
Say Y if you plan to load the kernel using Angel, ARM Ltd's target
@@ -25837,6 +25969,15 @@
board includes 2 serial ports, Ethernet, IRDA, and expansion headers.
It comes with 16 MB SDRAM and 8 MB flash ROM.
+GUIDEA07
+CONFIG_ARCH_GUIDEA07
+ Say Y if you are using a GUIDE (A07) board.
+
+ This board is based on the cs89712 processor and shares much common
+ hardware with the CDB89712 configuration. When you select this
+ option and the CDB89712 becomes enabled also, don't worry. It's
+ supposed to be that way.
+
CLPS-711X internal ROM bootstrap
CONFIG_EP72XX_ROM_BOOT
If you say Y here, your CLPS711x-based kernel will use the bootstrap
@@ -25865,19 +26006,27 @@
You may say N here if you are going to load the Acorn FPEmulator
early in the bootup.
+Math emulation 80-bit support
+CONFIG_FPE_NWFPE_XP
+ Say Y to include 80-bit support in the kernel floating-point
+ emulator. Otherwise, only 32 and 64-bit support is compiled in.
+ Note that gcc does not generate 80-bit operations by default,
+ so in most cases this option only enlarges the size of the
+ floating point emulator without any good reason.
+
+ You almost surely want to say N here.
+
FastFPE math emulation
CONFIG_FPE_FASTFPE
Say Y here to include the FAST floating point emulator in the kernel.
- This is an experimental much faster emulator which has only 32 bit
+ This is an experimental much faster emulator which now also has full
precision for the mantissa. It does not support any exceptions.
- This makes it very simple, it is approximately 4-8 times faster than
- NWFPE.
+ It is very simple, and approximately 3-6 times faster than NWFPE.
- It should be sufficient for most programs. It is definitely not
- suitable if you do scientific calculations that need double
- precision for iteration formulas that sum up lots of very small
- numbers. If you do not feel you need a faster FP emulation you
- should better choose NWFPE.
+ It should be sufficient for most programs. It may be not suitable
+ for scientific calculations, but you have to check this for yourself.
+ If you do not feel you need a faster FP emulation you should better
+ choose NWFPE.
It is also possible to say M to build the emulator as a module
(fastfpe.o). But keep in mind that you should only load the FP
diff -urN linux-2.4.26/Documentation/arm/Porting linux-2.4.26-vrs1/Documentation/arm/Porting
--- linux-2.4.26/Documentation/arm/Porting 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/arm/Porting 2004-02-22 17:29:23.000000000 +0000
@@ -0,0 +1,135 @@
+Taken from list archive at http://lists.arm.linux.org.uk/pipermail/linux-arm-kernel/2001-July/004064.html
+
+Initial definitions
+-------------------
+
+The following symbol definitions rely on you knowing the translation that
+__virt_to_phys() does for your machine. This macro converts the passed
+virtual address to a physical address. Normally, it is simply:
+
+ phys = virt - PAGE_OFFSET + PHYS_OFFSET
+
+
+Decompressor Symbols
+--------------------
+
+ZTEXTADDR
+ Start address of decompressor. There's no point in talking about
+ virtual or physical addresses here, since the MMU will be off at
+ the time when you call the decompressor code. You normally call
+ the kernel at this address to start it booting. This doesn't have
+ to be located in RAM, it can be in flash or other read-only or
+ read-write addressable medium.
+
+ZBSSADDR
+ Start address of zero-initialised work area for the decompressor.
+ This must be pointing at RAM. The decompressor will zero initialise
+ this for you. Again, the MMU will be off.
+
+ZRELADDR
+ This is the address where the decompressed kernel will be written,
+ and eventually executed. The following constraint must be valid:
+
+ __virt_to_phys(TEXTADDR) == ZRELADDR
+
+ The initial part of the kernel is carefully coded to be position
+ independent.
+
+INITRD_PHYS
+ Physical address to place the initial RAM disk. Only relevant if
+ you are using the bootpImage stuff (which only works on the old
+ struct param_struct).
+
+INITRD_VIRT
+ Virtual address of the initial RAM disk. The following constraint
+ must be valid:
+
+ __virt_to_phys(INITRD_VIRT) == INITRD_PHYS
+
+PARAMS_PHYS
+ Physical address of the struct param_struct or tag list, giving the
+ kernel various parameters about its execution environment.
+
+
+Kernel Symbols
+--------------
+
+PHYS_OFFSET
+ Physical start address of the first bank of RAM.
+
+PAGE_OFFSET
+ Virtual start address of the first bank of RAM. During the kernel
+ boot phase, virtual address PAGE_OFFSET will be mapped to physical
+ address PHYS_OFFSET, along with any other mappings you supply.
+ This should be the same value as TASK_SIZE.
+
+TASK_SIZE
+ The maximum size of a user process in bytes. Since user space
+ always starts at zero, this is the maximum address that a user
+ process can access+1. The user space stack grows down from this
+ address.
+
+ Any virtual address below TASK_SIZE is deemed to be user process
+ area, and therefore managed dynamically on a process by process
+ basis by the kernel. I'll call this the user segment.
+
+ Anything above TASK_SIZE is common to all processes. I'll call
+ this the kernel segment.
+
+ (In other words, you can't put IO mappings below TASK_SIZE, and
+ hence PAGE_OFFSET).
+
+TEXTADDR
+ Virtual start address of kernel, normally PAGE_OFFSET + 0x8000.
+ This is where the kernel image ends up. With the latest kernels,
+ it must be located at 32768 bytes into a 128MB region. Previous
+ kernels placed a restriction of 256MB here.
+
+DATAADDR
+ Virtual address for the kernel data segment. Must not be defined
+ when using the decompressor.
+
+VMALLOC_START
+VMALLOC_END
+ Virtual addresses bounding the vmalloc() area. There must not be
+ any static mappings in this area; vmalloc will overwrite them.
+ The addresses must also be in the kernel segment (see above).
+ Normally, the vmalloc() area starts VMALLOC_OFFSET bytes above the
+ last virtual RAM address (found using variable high_memory).
+
+VMALLOC_OFFSET
+ Offset normally incorporated into VMALLOC_START to provide a hole
+ between virtual RAM and the vmalloc area. We do this to allow
+ out of bounds memory accesses (eg, something writing off the end
+ of the mapped memory map) to be caught. Normally set to 8MB.
+
+Architecture Specific Macros
+----------------------------
+
+BOOT_MEM(pram,pio,vio)
+ `pram' specifies the physical start address of RAM. Must always
+ be present, and should be the same as PHYS_OFFSET.
+
+ `pio' is the physical address of an 8MB region containing IO for
+ use with the debugging macros in arch/arm/kernel/debug-armv.S.
+
+ `vio' is the virtual address of the 8MB debugging region.
+
+ It is expected that the debugging region will be re-initialised
+ by the architecture specific code later in the code (via the
+ MAPIO function).
+
+BOOT_PARAMS
+ Same as, and see PARAMS_PHYS.
+
+FIXUP(func)
+ Machine specific fixups, run before memory subsystems have been
+ initialised.
+
+MAPIO(func)
+ Machine specific function to map IO areas (including the debug
+ region above).
+
+INITIRQ(func)
+ Machine specific function to initialise interrupts.
+
diff -urN linux-2.4.26/Documentation/arm/mem_alignment linux-2.4.26-vrs1/Documentation/arm/mem_alignment
--- linux-2.4.26/Documentation/arm/mem_alignment 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/arm/mem_alignment 2004-04-09 15:09:44.000000000 +0100
@@ -0,0 +1,58 @@
+Too many problems poped up because of unnoticed misaligned memory access in
+kernel code lately. Therefore the alignment fixup is now unconditionally
+configured in for SA11x0 based targets. According to Alan Cox, this is a
+bad idea to configure it out, but Russell King has some good reasons for
+doing so on some f***ed up ARM architectures like the EBSA110. However
+this is not the case on many design I'm aware of, like all SA11x0 based
+ones.
+
+Of course this is a bad idea to rely on the alignment trap to perform
+unaligned memory access in general. If those access are predictable, you
+are better to use the macros provided by include/asm/unaligned.h. The
+alignment trap can fixup misaligned access for the exception cases, but at
+a high performance cost. It better be rare.
+
+Now for user space applications, it is possible to configure the alignment
+trap to SIGBUS any code performing unaligned access (good for debugging bad
+code), or even fixup the access by software like for kernel code. The later
+mode isn't recommended for performance reasons (just think about the
+floating point emulation that works about the same way). Fix your code
+instead!
+
+Please note that randomly changing the behaviour without good thought is
+real bad - it changes the behaviour of all unaligned instructions in user
+space, and might cause programs to fail unexpectedly.
+
+To change the alignment trap behavior, simply echo a number into
+/proc/cpu/alignment. The number is made up from various bits:
+
+bit behavior when set
+--- -----------------
+
+0 A user process performing an unaligned memory access
+ will cause the kernel to print a message indicating
+ process name, pid, pc, instruction, address, and the
+ fault code.
+
+1 The kernel will attempt to fix up the user process
+ performing the unaligned access. This is of course
+ slow (think about the floating point emulator) and
+ not recommended for production use.
+
+2 The kernel will send a SIGBUS signal to the user process
+ performing the unaligned access.
+
+Note that not all combinations are supported - only values 0 through 5.
+(6 and 7 don't make sense).
+
+For example, the following will turn on the warnings, but without
+fixing up or sending SIGBUS signals:
+
+ echo 1 > /proc/cpu/alignment
+
+You can also read the content of the same file to get statistical
+information on unaligned access occurrences plus the current mode of
+operation for user space code.
+
+
+Nicolas Pitre, Mar 13, 2001. Modified Russell King, Nov 30, 2001.
diff -urN linux-2.4.26/Documentation/arm/memory.txt linux-2.4.26-vrs1/Documentation/arm/memory.txt
--- linux-2.4.26/Documentation/arm/memory.txt 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/arm/memory.txt 2004-02-22 17:32:57.000000000 +0000
@@ -0,0 +1,74 @@
+ Kernel Memory Layout on ARM Linux
+
+ Russell King <rmk@arm.linux.org.uk>
+ April 27, 2003 (2.5.68)
+
+This document describes the virtual memory layout which the Linux
+kernel uses for ARM processors. It indicates which regions are
+free for platforms to use, and which are used by generic code.
+
+The ARM CPU is capable of addressing a maximum of 4GB virtual memory
+space, and this must be shared between user space processes, the
+kernel, and hardware devices.
+
+As the ARM architecture matures, it becomes necessary to reserve
+certain regions of VM space for use for new facilities; therefore
+this document may reserve more VM space over time.
+
+Start End Use
+--------------------------------------------------------------------------
+ffff8000 ffffffff copy_user_page / clear_user_page use.
+ For SA11xx and Xscale, this is used to
+ setup a minicache mapping.
+
+ffff1000 ffff7fff Reserved.
+ Platforms must not use this address range.
+
+ffff0000 ffff0fff CPU vector page.
+ The CPU vectors are mapped here if the
+ CPU supports vector relocation (control
+ register V bit.)
+
+ffe00000 fffeffff Free for platform use, not recommended.
+
+ffc00000 ffdfffff 2MB consistent memory mapping.
+ Memory returned by the consistent_alloc
+ low level function will be dynamically
+ mapped here.
+
+ff000000 ffbfffff Free for platform use, not recommended.
+
+VMALLOC_END ff000000 Free for platform use, recommended.
+
+VMALLOC_START VMALLOC_END vmalloc() / ioremap() space.
+ Memory returned by vmalloc/ioremap will
+ be dynamically placed in this region.
+ VMALLOC_START may be based upon the value
+ of the high_memory variable.
+
+PAGE_OFFSET high_memory Kernel direct-mapped RAM region.
+ This maps the platforms RAM, and typically
+ maps all platform RAM in a 1:1 relationship.
+
+TASK_SIZE PAGE_OFFSET Kernel module space
+ Kernel modules inserted via insmod are
+ placed here using dynamic mappings.
+
+00001000 TASK_SIZE User space mappings
+ Per-thread mappings are placed here via
+ the mmap() system call.
+
+00000000 00000fff CPU vector page / null pointer trap
+ CPUs which do not support vector remapping
+ place their vector page here. NULL pointer
+ dereferences by both the kernel and user
+ space are also caught via this mapping.
+
+Please note that mappings which collide with the above areas may result
+in a non-bootable kernel, or may cause the kernel to (eventually) panic
+at run time.
+
+Since future CPUs may impact the kernel mapping layout, user programs
+must not access any memory which is not mapped inside their 0x0001000
+to TASK_SIZE address range. If they wish to access these areas, they
+must set up their own mappings using open() and mmap().
diff -urN linux-2.4.26/Documentation/cpufreq/core.txt linux-2.4.26-vrs1/Documentation/cpufreq/core.txt
--- linux-2.4.26/Documentation/cpufreq/core.txt 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/cpufreq/core.txt 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,94 @@
+ CPU frequency and voltage scaling code in the Linux(TM) kernel
+
+
+ L i n u x C P U F r e q
+
+ C P U F r e q C o r e
+
+
+ Dominik Brodowski <linux@brodo.de>
+ David Kimdon <dwhedon@debian.org>
+
+
+
+ Clock scaling allows you to change the clock speed of the CPUs on the
+ fly. This is a nice method to save battery power, because the lower
+ the clock speed, the less power the CPU consumes.
+
+
+Contents:
+---------
+1. CPUFreq core and interfaces
+2. CPUFreq notifiers
+
+1. General Information
+=======================
+
+The CPUFreq core code is located in linux/kernel/cpufreq.c. This
+cpufreq code offers a standardized interface for the CPUFreq
+architecture drivers (those pieces of code that do actual
+frequency transitions), as well as to "notifiers". These are device
+drivers or other part of the kernel that need to be informed of
+policy changes (ex. thermal modules like ACPI) or of all
+frequency changes (ex. timing code) or even need to force certain
+speed limits (like LCD drivers on ARM architecture). Additionally, the
+kernel "constant" loops_per_jiffy is updated on frequency changes
+here.
+
+Reference counting is done by cpufreq_get_cpu and cpufreq_put_cpu,
+which make sure that the cpufreq processor driver is correctly
+registered with the core, and will not be unloaded until
+cpufreq_put_cpu is called.
+
+2. CPUFreq notifiers
+====================
+
+CPUFreq notifiers conform to the standard kernel notifier interface.
+See linux/include/linux/notifier.h for details on notifiers.
+
+There are two different CPUFreq notifiers - policy notifiers and
+transition notifiers.
+
+
+2.1 CPUFreq policy notifiers
+----------------------------
+
+These are notified when a new policy is intended to be set. Each
+CPUFreq policy notifier is called three times for a policy transition:
+
+1.) During CPUFREQ_ADJUST all CPUFreq notifiers may change the limit if
+ they see a need for this - may it be thermal considerations or
+ hardware limitations.
+
+2.) During CPUFREQ_INCOMPATIBLE only changes may be done in order to avoid
+ hardware failure.
+
+3.) And during CPUFREQ_NOTIFY all notifiers are informed of the new policy
+ - if two hardware drivers failed to agree on a new policy before this
+ stage, the incompatible hardware shall be shut down, and the user
+ informed of this.
+
+The phase is specified in the second argument to the notifier.
+
+The third argument, a void *pointer, points to a struct cpufreq_policy
+consisting of five values: cpu, min, max, policy and max_cpu_freq. min
+and max are the lower and upper frequencies (in kHz) of the new
+policy, policy the new policy, cpu the number of the affected CPU or
+CPUFREQ_ALL_CPUS for all CPUs; and max_cpu_freq the maximum supported
+CPU frequency. This value is given for informational purposes only.
+
+
+2.2 CPUFreq transition notifiers
+--------------------------------
+
+These are notified twice when the CPUfreq driver switches the CPU core
+frequency and this change has any external implications.
+
+The second argument specifies the phase - CPUFREQ_PRECHANGE or
+CPUFREQ_POSTCHANGE.
+
+The third argument is a struct cpufreq_freqs with the following
+values:
+cpu - number of the affected CPU or CPUFREQ_ALL_CPUS
+old - old frequency
+new - new frequency
diff -urN linux-2.4.26/Documentation/cpufreq/cpu-drivers.txt linux-2.4.26-vrs1/Documentation/cpufreq/cpu-drivers.txt
--- linux-2.4.26/Documentation/cpufreq/cpu-drivers.txt 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/cpufreq/cpu-drivers.txt 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,210 @@
+ CPU frequency and voltage scaling code in the Linux(TM) kernel
+
+
+ L i n u x C P U F r e q
+
+ C P U D r i v e r s
+
+ - information for developers -
+
+
+ Dominik Brodowski <linux@brodo.de>
+
+
+
+ Clock scaling allows you to change the clock speed of the CPUs on the
+ fly. This is a nice method to save battery power, because the lower
+ the clock speed, the less power the CPU consumes.
+
+
+Contents:
+---------
+1. What To Do?
+1.1 Initialization
+1.2 Per-CPU Initialization
+1.3 verify
+1.4 target or setpolicy?
+1.5 target
+1.6 setpolicy
+2. Frequency Table Helpers
+
+
+
+1. What To Do?
+==============
+
+So, you just got a brand-new CPU / chipset with datasheets and want to
+add cpufreq support for this CPU / chipset? Great. Here are some hints
+on what is neccessary:
+
+
+1.1 Initialization
+------------------
+
+First of all, in an __initcall level 7 or later (preferrably
+module_init() so that your driver is modularized) function check
+whether this kernel runs on the right CPU and the right chipset. If
+so, register a struct cpufreq_driver with the CPUfreq core using
+cpufreq_register_driver()
+
+What shall this struct cpufreq_driver contain?
+
+cpufreq_driver.name - The name of this driver.
+
+cpufreq_driver.init - A pointer to the per-CPU initialization
+ function.
+
+cpufreq_driver.verify - A pointer to a "verfication" funciton.
+
+cpufreq_driver.setpolicy _or_
+cpufreq_driver.target - See below on the differences.
+
+And optionally
+
+cpufreq_driver.exit - A pointer to a per-CPU cleanup function.
+
+cpufreq_driver.attr - A pointer to a NULL-terminated list of
+ "struct freq_attr" which allow to
+ export values to sysfs.
+
+
+1.2 Per-CPU Initialization
+--------------------------
+
+Whenever a new CPU is registered with the device model, or after the
+cpufreq driver registers itself, the per-CPU initialization fucntion
+cpufreq_driver.init is called. It takes a struct cpufreq_policy
+*policy as argument. What to do now?
+
+If necessary, activate the CPUfreq support on your CPU (unlock that
+register etc.).
+
+Then, the driver must fill in the following values:
+
+policy->cpuinfo.min_freq _and_
+policy->cpuinfo.max_freq - the minimum and maximum frequency
+ (in kHz) which is supported by
+ this CPU
+policy->cpuinfo.transition_latency the time it takes on this CPU to
+ switch between two frequencies (if
+ appropriate, else specify
+ CPUFREQ_ETERNAL)
+
+policy->cur The current operating frequency of
+ this CPU (if appropriate)
+policy->min,
+policy->max,
+policy->policy and, if neccessary,
+policy->governor must contain the "default policy" for
+ this CPU. A few moments later,
+ cpufreq_driver.verify and either
+ cpufreq_driver.setpolicy or
+ cpufreq_driver.target is called with
+ these values.
+
+For setting some of these values, the frequency table helpers might be
+helpful. See the section 2 for more information on them.
+
+
+1.3 verify
+------------
+
+When the user decides a new policy (consisting of
+"policy,governor,min,max") shall be set, this policy must be validated
+so that incompatible values can be corrected. For verifying these
+values, a frequency table helper and/or the
+cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned
+int min_freq, unsigned int max_freq) function might be helpful. See
+section 2 for details on frequency table helpers.
+
+You need to make sure that at least one valid frequency (or operating
+range) is within policy->min and policy->max. If necessary, increase
+policy->max fist, and only if this is no solution, decreas policy->min.
+
+
+1.4 target or setpolicy?
+----------------------------
+
+Most cpufreq drivers or even most cpu frequency scaling algorithms
+only allow the CPU to be set to one frequency. For these, you use the
+->target call.
+
+Some cpufreq-capable processors switch the frequency between certain
+limits on their own. These shall use the ->setpolicy call
+
+
+1.4. target
+-------------
+
+The target call has three arguments: struct cpufreq_policy *policy,
+unsigned int target_frequency, unsigned int relation.
+
+The CPUfreq driver must set the new frequency when called here. The
+actual frequency must be determined using the following rules:
+
+- keep close to "target_freq"
+- policy->min <= new_freq <= policy->max (THIS MUST BE VALID!!!)
+- if relation==CPUFREQ_REL_L, try to select a new_freq higher than or equal
+ target_freq. ("L for lowest, but no lower than")
+- if relation==CPUFREQ_REL_H, try to select a new_freq lower than or equal
+ target_freq. ("H for highest, but no higher than")
+
+Here again the frequency table helper might assist you - see section 3
+for details.
+
+
+1.5 setpolicy
+---------------
+
+The setpolicy call only takes a struct cpufreq_policy *policy as
+argument. You need to set the lower limit of the in-processor or
+in-chipset dynamic frequency switching to policy->min, the upper limit
+to policy->max, and -if supported- select a performance-oriented
+setting when policy->policy is CPUFREQ_POLICY_PERFORMANCE, and a
+powersaving-oriented setting when CPUFREQ_POLICY_POWERSAVE. Also check
+the reference implementation in arch/i386/kernel/cpu/cpufreq/longrun.c
+
+
+
+2. Frequency Table Helpers
+==========================
+
+As most cpufreq processors only allow for being set to a few specific
+frequencies, a "frequency table" with some functions might assist in
+some work of the processor driver. Such a "frequency table" consists
+of an array of struct cpufreq_freq_table entries, with any value in
+"index" you want to use, and the corresponding frequency in
+"frequency". At the end of the table, you need to add a
+cpufreq_freq_table entry with frequency set to CPUFREQ_TABLE_END. And
+if you want to skip one entry in the table, set the frequency to
+CPUFREQ_ENTRY_INVALID. The entries don't need to be in ascending
+order.
+
+By calling cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table);
+the cpuinfo.min_freq and cpuinfo.max_freq values are detected, and
+policy->min and policy->max are set to the same values. This is
+helpful for the per-CPU initialization stage.
+
+int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table);
+assures that at least one valid frequency is within policy->min and
+policy->max, and all other criteria are met. This is helpful for the
+->verify call.
+
+int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table,
+ unsigned int target_freq,
+ unsigned int relation,
+ unsigned int *index);
+
+is the corresponding frequency table helper for the ->target
+stage. Just pass the values to this function, and the unsigned int
+index returns the number of the frequency table entry which contains
+the frequency the CPU shall be set to. PLEASE NOTE: This is not the
+"index" which is in this cpufreq_table_entry.index, but instead
+cpufreq_table[index]. So, the new frequency is
+cpufreq_table[index].frequency, and the value you stored into the
+frequency table "index" field is
+cpufreq_table[index].index.
+
diff -urN linux-2.4.26/Documentation/cpufreq/governors.txt linux-2.4.26-vrs1/Documentation/cpufreq/governors.txt
--- linux-2.4.26/Documentation/cpufreq/governors.txt 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/cpufreq/governors.txt 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,155 @@
+ CPU frequency and voltage scaling code in the Linux(TM) kernel
+
+
+ L i n u x C P U F r e q
+
+ C P U F r e q G o v e r n o r s
+
+ - information for users and developers -
+
+
+ Dominik Brodowski <linux@brodo.de>
+
+
+
+ Clock scaling allows you to change the clock speed of the CPUs on the
+ fly. This is a nice method to save battery power, because the lower
+ the clock speed, the less power the CPU consumes.
+
+
+Contents:
+---------
+1. What is a CPUFreq Governor?
+
+2. Governors In the Linux Kernel
+2.1 Performance
+2.2 Powersave
+2.3 Userspace
+
+3. The Governor Interface in the CPUfreq Core
+
+
+
+1. What Is A CPUFreq Governor?
+==============================
+
+Most cpufreq drivers (in fact, all except one, longrun) or even most
+cpu frequency scaling algorithms only offer the CPU to be set to one
+frequency. In order to offer dynamic frequency scaling, the cpufreq
+core must be able to tell these drivers of a "target frequency". So
+these specific drivers will be transformed to offer a "->target"
+call instead of the existing "->setpolicy" call. For "longrun", all
+stays the same, though.
+
+How to decide what frequency within the CPUfreq policy should be used?
+That's done using "cpufreq governors". Two are already in this patch
+-- they're the already existing "powersave" and "performance" which
+set the frequency statically to the lowest or highest frequency,
+respectively. At least two more such governors will be ready for
+addition in the near future, but likely many more as there are various
+different theories and models about dynamic frequency scaling
+around. Using such a generic interface as cpufreq offers to scaling
+governors, these can be tested extensively, and the best one can be
+selected for each specific use.
+
+Basically, it's the following flow graph:
+
+CPU can be set to switch independetly | CPU can only be set
+ within specific "limits" | to specific frequencies
+
+ "CPUfreq policy"
+ consists of frequency limits (policy->{min,max})
+ and CPUfreq governor to be used
+ / \
+ / \
+ / the cpufreq governor decides
+ / (dynamically or statically)
+ / what target_freq to set within
+ / the limits of policy->{min,max}
+ / \
+ / \
+ Using the ->setpolicy call, Using the ->target call,
+ the limits and the the frequency closest
+ "policy" is set. to target_freq is set.
+ It is assured that it
+ is within policy->{min,max}
+
+
+2. Governors In the Linux Kernel
+================================
+
+2.1 Performance
+---------------
+
+The CPUfreq governor "performance" sets the CPU statically to the
+highest frequency within the borders of scaling_min_freq and
+scaling_max_freq.
+
+
+2.1 Powersave
+-------------
+
+The CPUfreq governor "powersave" sets the CPU statically to the
+lowest frequency within the borders of scaling_min_freq and
+scaling_max_freq.
+
+
+2.2 Userspace
+-------------
+
+The CPUfreq governor "userspace" allows the user, or any userspace
+program running with UID "root", to set the CPU to a specifc frequency
+by making a sysfs file "scaling_setspeed" available in the CPU-device
+directory.
+
+
+
+3. The Governor Interface in the CPUfreq Core
+=============================================
+
+A new governor must register itself with the CPUfreq core using
+"cpufreq_register_governor". The struct cpufreq_governor, which has to
+be passed to that function, must contain the following values:
+
+governor->name - A unique name for this governor
+governor->governor - The governor callback function
+governor->owner - .THIS_MODULE for the governor module (if
+ appropriate)
+
+The governor->governor callback is called with the current (or to-be-set)
+cpufreq_policy struct for that CPU, and an unsigned int event. The
+following events are currently defined:
+
+CPUFREQ_GOV_START: This governor shall start its duty for the CPU
+ policy->cpu
+CPUFREQ_GOV_STOP: This governor shall end its duty for the CPU
+ policy->cpu
+CPUFREQ_GOV_LIMITS: The limits for CPU policy->cpu have changed to
+ policy->min and policy->max.
+
+If you need other "events" externally of your driver, _only_ use the
+cpufreq_governor_l(unsigned int cpu, unsigned int event) call to the
+CPUfreq core to ensure proper locking.
+
+
+The CPUfreq governor may call the CPU processor driver using one of
+these two functions:
+
+inline int cpufreq_driver_target(struct cpufreq_policy *policy,
+ unsigned int target_freq,
+ unsigned int relation);
+
+inline int cpufreq_driver_target_l(struct cpufreq_policy *policy,
+ unsigned int target_freq,
+ unsigned int relation);
+
+target_freq must be within policy->min and policy->max, of course.
+What's the difference between these two functions? When your governor
+still is in a direct code path of a call to governor->governor, the
+cpufreq_driver_sem lock is still held in the cpufreq core, and there's
+no need to lock it again (in fact, this would cause a deadlock). So
+use cpufreq_driver_target only in these cases. In all other cases (for
+example, when there's a "daemonized" function that wakes up every
+second), use cpufreq_driver_target_l to lock the cpufreq_driver_sem
+before the command is passed to the cpufreq processor driver.
+
diff -urN linux-2.4.26/Documentation/cpufreq/index.txt linux-2.4.26-vrs1/Documentation/cpufreq/index.txt
--- linux-2.4.26/Documentation/cpufreq/index.txt 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/cpufreq/index.txt 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,56 @@
+ CPU frequency and voltage scaling code in the Linux(TM) kernel
+
+
+ L i n u x C P U F r e q
+
+
+
+
+ Dominik Brodowski <linux@brodo.de>
+
+
+
+ Clock scaling allows you to change the clock speed of the CPUs on the
+ fly. This is a nice method to save battery power, because the lower
+ the clock speed, the less power the CPU consumes.
+
+
+
+Documents in this directory:
+----------------------------
+core.txt - General description of the CPUFreq core and
+ of CPUFreq notifiers
+
+cpu-drivers.txt - How to implement a new cpufreq processor driver
+
+governors.txt - What are cpufreq governors and how to
+ implement them?
+
+index.txt - File index, Mailing list and Links (this document)
+
+user-guide.txt - User Guide to CPUFreq
+
+
+Mailing List
+------------
+There is a CPU frequency changing CVS commit and general list where
+you can report bugs, problems or submit patches. To post a message,
+send an email to cpufreq@www.linux.org.uk, to subscribe go to
+http://www.linux.org.uk/mailman/listinfo/cpufreq. Previous post to the
+mailing list are available to subscribers at
+http://www.linux.org.uk/mailman/private/cpufreq/.
+
+
+Links
+-----
+the FTP archives:
+* ftp://ftp.linux.org.uk/pub/linux/cpufreq/
+
+how to access the CVS repository:
+* http://cvs.arm.linux.org.uk/
+
+the CPUFreq Mailing list:
+* http://www.linux.org.uk/mailman/listinfo/cpufreq
+
+Clock and voltage scaling for the SA-1100:
+* http://www.lart.tudelft.nl/projects/scaling
diff -urN linux-2.4.26/Documentation/cpufreq/user-guide.txt linux-2.4.26-vrs1/Documentation/cpufreq/user-guide.txt
--- linux-2.4.26/Documentation/cpufreq/user-guide.txt 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/cpufreq/user-guide.txt 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,166 @@
+ CPU frequency and voltage scaling code in the Linux(TM) kernel
+
+
+ L i n u x C P U F r e q
+
+ U S E R G U I D E
+
+
+ Dominik Brodowski <linux@brodo.de>
+
+
+
+ Clock scaling allows you to change the clock speed of the CPUs on the
+ fly. This is a nice method to save battery power, because the lower
+ the clock speed, the less power the CPU consumes.
+
+
+Contents:
+---------
+1. Supported Architectures and Processors
+1.1 ARM
+1.2 x86
+1.3 sparc64
+
+2. "Policy" / "Governor"?
+2.1 Policy
+2.2 Governor
+
+3. How to change the CPU cpufreq policy and/or speed
+3.1 Preferred interface: sysfs
+3.2 Deprecated interfaces
+
+
+
+1. Supported Architectures and Processors
+=========================================
+
+1.1 ARM
+-------
+
+The following ARM processors are supported by cpufreq:
+
+ARM Integrator
+ARM-SA1100
+ARM-SA1110
+
+
+1.2 x86
+-------
+
+The following processors for the x86 architecture are supported by cpufreq:
+
+AMD Elan - SC400, SC410
+AMD mobile K6-2+
+AMD mobile K6-3+
+Cyrix Media GXm
+Intel mobile PIII [*] and Intel mobile PIII-M on certain chipsets
+Intel Pentium 4, Intel Xeon
+National Semiconductors Geode GX
+Transmeta Crusoe
+varios processors on some ACPI 2.0-compatible systems [**]
+
+[*] only certain Intel mobile PIII processors are supported. If you
+know that you own a speedstep-capable processor, pass the option
+"speedstep_coppermine=1" to the module speedstep.o
+
+[**] Only if "ACPI Processor Performance States" are available
+to the ACPI<->BIOS interface.
+
+
+1.3 sparc64
+-----------
+
+The following processors for the sparc64 architecture are supported by
+cpufreq:
+
+UltraSPARC-III
+
+
+
+2. "Policy" / "Governor" ?
+==========================
+
+Some CPU frequency scaling-capable processor switch between varios
+frequencies and operating voltages "on the fly" without any kernel or
+user involvement. This guarantuees very fast switching to a frequency
+which is high enough to serve the user's needs, but low enough to save
+power.
+
+
+2.1 Policy
+----------
+
+On these systems, all you can do is select the lower and upper
+frequency limit as well as whether you want more aggressive
+power-saving or more instantly avaialble processing power.
+
+
+2.2 Governor
+------------
+
+On all other cpufreq implementations, these boundaries still need to
+be set. Then, a "governor" must be selected. Such a "governor" decides
+what speed the processor shall run within the boundaries. One such
+"governor" is the "userspace" governor. This one allows the user - or
+a yet-to-implement userspace program - to decide what specific speed
+the processor shall run at.
+
+
+3. How to change the CPU cpufreq policy and/or speed
+====================================================
+
+3.1 Preferred Interface: sysfs
+------------------------------
+
+The preferred interface is located in the sysfs filesystem. If you
+mounted it at /sys, the cpufreq interface is located in a subdirectory
+"cpufreq" within the cpu-device directory
+(e.g. /sys/devices/sys/cpu0/cpufreq/ for the first CPU).
+
+cpuinfo_min_freq : this file shows the minimum operating
+ frequency the processor can run at(in kHz)
+cpuinfo_max_freq : this file shows the maximum operating
+ frequency the processor can run at(in kHz)
+scaling_driver : this file shows what cpufreq driver is
+ used to set the frequency on this CPU
+
+scaling_available_governors : this file shows the CPUfreq governors
+ available in this kernel. You can see the
+ currently activated governor in
+
+scaling_governor, and by "echoing" the name of another
+ governor you can change it. Please note
+ that some governors won't load - they only
+ work on some specific architectures or
+ processors.
+scaling_min_freq and
+scaling_max_freq show the current "policy limits" (in
+ kHz). By echoing new values into these
+ files, you can change these limits.
+
+
+If you have selected the "userspace" governor which allows you to
+set the CPU operating frequency to a specific value, you can read out
+the current frequency in
+
+scaling_setspeed. By "echoing" a new frequency into this
+ you can change the speed of the CPU,
+ but only within the limits of
+ scaling_min_freq and scaling_max_freq.
+
+
+3.2 Deprecated Interfaces
+-------------------------
+
+Depending on your kernel configuration, you might find the following
+cpufreq-related files:
+/proc/cpufreq
+/proc/sys/cpu/*/speed
+/proc/sys/cpu/*/speed-min
+/proc/sys/cpu/*/speed-max
+
+These are files for deprecated interfaces to cpufreq, which offer far
+less functionality. Because of this, these interfaces aren't described
+here.
+
diff -urN linux-2.4.26/Documentation/cpufreq-old linux-2.4.26-vrs1/Documentation/cpufreq-old
--- linux-2.4.26/Documentation/cpufreq-old 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/cpufreq-old 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,332 @@
+ CPU frequency and voltage scaling code in the Linux(TM) kernel
+
+
+ L i n u x C P U F r e q
+
+
+
+
+ Dominik Brodowski <devel@brodo.de>
+
+
+
+ Clock scaling allows you to change the clock speed of the CPUs on the
+ fly. This is a nice method to save battery power, because the lower
+ the clock speed, the less power the CPU consumes.
+
+
+
+Contents:
+---------
+1. Supported architectures
+2. User interface
+2.1 Sample script for command line interface
+3. CPUFreq core and interfaces
+3.1 General information
+3.2 CPUFreq notifiers
+3.3 CPUFreq architecture drivers
+4. Mailing list and Links
+
+
+
+1. Supported architectures
+==========================
+
+Some architectures detect the lowest and highest possible speed
+settings, while others rely on user information on this. For the
+latter, a boot parameter is required, for the former, you can specify
+one to set the limits between speed settings may occur.
+The boot parameter has the following syntax:
+
+ cpufreq=minspeed-maxspeed
+
+with both minspeed and maxspeed being given in kHz. To set the lower
+limit to 59 MHz and the upper limit to 221 MHz, specify:
+
+ cpufreq=59000-221000
+
+Check the "Speed Limits Detection" information below on whether
+the driver detects the lowest and highest allowed speed setting
+automatically.
+
+
+ARM Integrator:
+ SA 1100, SA1110
+--------------------------------
+ Speed Limits Detection: On Integrators, the minimum speed is set
+ and the maximum speed has to be specified using the boot
+ parameter. On SA11x0s, the frequencies are fixed (59 - 287 MHz)
+
+
+AMD Elan:
+ SC400, SC410
+--------------------------------
+ Speed Limits Detection: Not implemented. You need to specify the
+ minimum and maximum frequency in the boot parameter (see above).
+
+
+VIA Cyrix Longhaul:
+ VIA Samuel/CyrixIII, VIA Cyrix Samuel/C3,
+ VIA Cyrix Ezra, VIA Cyrix Ezra-T
+--------------------------------
+ Speed Limits Detection: working. No need for boot parameters.
+ NOTE: Support for certain processors is currently disabled,
+ waiting on updated docs from VIA.
+
+
+Intel SpeedStep:
+ certain mobile Intel Pentium III (Coppermine), and all mobile
+ Intel Pentium III-M (Tulatin) and mobile Intel Pentium 4 P4-Ms.
+--------------------------------
+ Speed Limits Detection: working. No need for boot parameters.
+ NOTE:
+ 1.) mobile Intel Pentium III (Coppermine):
+ The SpeedStep interface may only be used on SpeedStep
+ capable processors. Unforunately, due to lack of documentation,
+ such detection is not yet possible on mobile Intel PIII
+ (Coppermine) processors. In order to activate SpeedStep on such a
+ processor, you have to remove one line manually in
+ linux/drivers/arch/i386/speedstep.c
+
+
+P4 CPU Clock Modulation:
+ Intel Pentium 4 Xeon processors
+--------------------------------
+ Speed Limits Detection: Not implemented. You need to specify the
+ minimum and maximum frequency in the boot parameter (see above).
+
+
+
+2. User Interface
+=================
+
+CPUFreq uses a "sysctl" interface which is located in
+ /proc/sys/cpu/0/ on UP (uniprocessor) kernels, or
+ /proc/sys/cpu/any/ on SMP (symmetric multiprocessoring) kernels.
+
+
+In this directory, you will find three files of importance for
+CPUFreq: speed-max, speed-min, and speed:
+
+speed shows the current CPU frequency in kHz,
+speed-min the minimal supported CPU frequency, and
+speed-max the maximal supported CPU frequency.
+
+Please note that you might have to specify these limits as a boot
+parameter depending on the architecture (see above).
+
+
+To change the CPU frequency, "echo" the desired CPU frequency (in kHz)
+to speed. For example, to set the CPU speed to the lowest/highest
+allowed frequency do:
+
+root@notebook:# cat /proc/sys/cpu/0/speed-min > /proc/sys/cpu/0/speed
+root@notebook:# cat /proc/sys/cpu/0/speed-max > /proc/sys/cpu/0/speed
+
+
+2.1 Sample script for command line interface
+**********************************************
+
+
+Michael Ossmann <mike@ossmann.com> has written a small command line
+interface for the infinitely lazy.
+
+#!/bin/bash
+#
+# /usr/local/bin/freq
+# simple command line interface to cpufreq
+
+[ -n "$1" ] && case "$1" in
+ "min" )
+ # set frequency to minimum
+ cat /proc/sys/cpu/0/speed-min >/proc/sys/cpu/0/speed
+ ;;
+ "max" )
+ # set frequency to maximum
+ cat /proc/sys/cpu/0/speed-max >/proc/sys/cpu/0/speed
+ ;;
+ * )
+ echo "Usage: $0 [min|max]"
+ echo " min: set frequency to minimum and display new frequency"
+ echo " max: set frequency to maximum and display new frequency"
+ echo " no options: display current frequency"
+ exit 1
+ ;;
+esac
+
+# display current frequency
+cat /proc/sys/cpu/0/speed
+exit 0
+
+
+
+3. CPUFreq core and interfaces
+===============================
+
+3.1 General information
+*************************
+
+The CPUFreq core code is located in linux/kernel/cpufreq.c. This
+cpufreq code offers a standardized interface for the CPUFreq
+architecture drivers (those pieces of code that do the actual
+frequency transition), as well as to "notifiers". These are device
+drivers or other part of the kernel that need to be informed of
+frequency changes (like timing code) or even need to force certain
+speed limits (like LCD drivers on ARM architecture). Aditionally, the
+kernel "constant" loops_per_jiffy is updated on frequency changes
+here.
+
+
+3.2 CPUFreq notifiers
+***********************
+
+CPUFreq notifiers are kernel code that need to be called to either
+a) define certain minimum or maximum speed settings,
+b) be informed of frequency changes in advance of the transition, or
+c) be informed of frequency changes directly after the transition.
+
+A standard kernel notifier interface is offered for this. See
+linux/include/linux/notifier.h for details on notifiers.
+
+
+Data and value passed to CPUFreq notifiers
+------------------------------------------
+The second argument passed to any notifier is an unsigned int stating
+the phase of the transition:
+CPUFREQ_MINMAX during the process of determing a valid new CPU
+ frequency,
+CPUFREQ_PRECHANGE right before the transition, and
+CPUFREQ_POSTCHANGE right after the transition.
+
+The third argument, a void *pointer, points to a struct
+cpufreq_freqs. This consists of four values: min, max, cur and new.
+
+min and max are the current speed limits. Please note: Never update
+these values directly, use cpufreq_updateminmax(struct cpufreq_freqs
+*freqs, unsigned int min, unsigned int max) instead. cur is the
+current/old speed, and new is the new speed, but might only be valid
+on CPUFREQ_PRECHANGE or CPUFREQ_POSTCHANGE.
+
+Each notifier gets called all three times on any transition:
+
+CPUFREQ_MINMAX
+Here the notifier is supposed to update the min and max values to the
+limits the protected device / kernel code needs. As stated above,
+always use cpufreq_updateminmax for this.
+
+CPUFREQ_PRECHANGE
+CPUFREQ_POSTCHANGE
+Here the notifier is supposed to update all internal (e.g. device
+driver) code which is dependend on the CPU frequency.
+
+
+3.3 CPUFreq architecture drivers
+**********************************
+
+CPUFreq architecture drivers are the pieces of kernel code that
+actually perform CPU frequency transitions. These need to be
+initialised seperately (seperate initcalls), and may be
+modularized. They interact with the CPUFreq core in the following way:
+
+
+cpufreq_register()
+------------------
+cpufreq_register registers an arch driver to the CPUFreq core. Please
+note that only one arch driver may be registered at any time, -EBUSY
+is returned when an arch driver is already registered. The argument to
+cpufreq_register, cpufreq_driver_t driver, is described later.
+
+
+cpufreq_unregister()
+--------------------
+cpufreq_unregister unregisters an arch driver, e.g. on module
+unloading. Please note that there is no check done that this is called
+from the driver which actually registered itself to the core, so
+please only call this function when you are sure the arch driver got
+registered correctly before.
+
+
+struct cpufreq_driver
+----------------
+On initialisation, the arch driver is supposed to pass the following
+entries in struct cpufreq_driver cpufreq_driver:
+
+cpufreq_verify_t validate: This is a pointer to a function with the
+following definition:
+ unsigned int validating_function (unsigned int kHz).
+It is called right before a transition occurs. The proposed new
+speed setting is passed as an argument in kHz; the validating code
+should verify this is a valid speed setting which is currently
+supported by the CPU. It shall return the closest valid CPU frequency
+in kHz.
+
+cpufreq_setspeed_t setspeed: This is a pointer to a function with the
+following definition:
+ void setspeed_function (unsigned int kHz).
+This function shall perform the transition to the new CPU frequency
+given as argument in kHz. Note that this argument is exactly the same
+as the one returned by cpufreq_verify_t validate.
+
+
+unsigned int freq.cur: The current CPU core frequency. Note that this
+is a requirement while the next two entries are optional.
+
+
+unsigned int freq.min (optional): The minimal CPU core frequency this
+CPU supports. This value may be limited further by the
+cpufreq_verify_t validate function, and so this value should be the
+minimal core frequency allowed "theoretically" on this system in this
+configuration.
+
+
+unsigned int freq.max (optional): The maximum CPU core frequency this
+CPU supports. This value may be limited further by the
+cpufreq_verify_t validate function, and so this value should be the
+maximum core frequency allowed "theoretically" on this system in this
+configuration.
+
+
+Some Requirements to CPUFreq architecture drivers
+-------------------------------------------------
+* Only call cpufreq_register() when the ability to switch CPU
+ frequencies is _verified_ or can't be missing
+* cpufreq_unregister() may only be called if cpufreq_register() has
+ been successfully(!) called before
+* All CPUs have to be set to the same speed whenever setspeed() is
+ called
+* Be aware that there is currently no error management in the
+ setspeed() code in the CPUFreq core. So only call yourself a
+ cpufreq_driver if you are really a working cpufreq_driver!
+
+
+
+4. Mailing list and Links
+**************************
+
+
+Mailing List
+------------
+There is a CPU frequency changing CVS commit and general list where
+you can report bugs, problems or submit patches. To post a message,
+send an email to cpufreq@www.linux.org.uk, to subscribe go to
+http://www.linux.org.uk/mailman/listinfo/cpufreq. Previous post to the
+mailing list are available to subscribers at
+http://www.linux.org.uk/mailman/private/cpufreq/.
+
+
+Links
+-----
+the FTP archives:
+* ftp://ftp.linux.org.uk/pub/linux/cpufreq/
+
+how to access the CVS repository:
+* http://www.arm.linux.org.uk/cvs/
+
+the CPUFreq Mailing list:
+* http://www.linux.org.uk/mailman/listinfo/cpufreq
+
+Clock and voltage scaling for the SA-1100:
+* http://www.lart.tudelft.nl/projects/scaling
+
+CPUFreq project homepage
+* http://www.brodo.de/cpufreq/
diff -urN linux-2.4.26/Documentation/l3/structure linux-2.4.26-vrs1/Documentation/l3/structure
--- linux-2.4.26/Documentation/l3/structure 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/l3/structure 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,36 @@
+L3 Bus Driver
+-------------
+
+The structure of the driver is as follows:
+
+ +----------+ +----------+ +----------+
+ | client 1 | | client 2 | | client 3 |
+ +-----^----+ +----^-----+ +----^-----+
+ | | |
+ +-----v--------------v---------------v-----+
+ | |
+ +-----^-------+ +-------^-----+
+ | | core | |
+ +-----v----+ | | +----v-----+
+ | device | | | | device |
+ | driver 1 | | | | driver 2 |
+ +-----^----+ | | +----^-----+
+ | | services | |
+ +-----v-------+ +-------v-----+
+ | |
+ +-----------------^----^-------------------+
+ | |
+ | +-v---------+
+ | | algorithm |
+ | | driver |
+ | +-v---------+
+ | |
+ +-v----v-+
+ | bus |
+ | driver |
+ +--------+
+
+Clients talk to the core to attach device drivers and bus adapters, and
+to instruct device drivers to perform actions. Device drivers then talk
+to the core to perform L3 bus transactions via the algorithm driver and
+ultimately bus driver.
diff -urN linux-2.4.26/Documentation/serial/driver linux-2.4.26-vrs1/Documentation/serial/driver
--- linux-2.4.26/Documentation/serial/driver 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/Documentation/serial/driver 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,208 @@
+
+ Low Level Serial API
+ --------------------
+
+
+ $Id: driver,v 1.3 2001/11/24 23:24:47 rmk Exp $
+
+
+This document is meant as a brief overview of some aspects of the new serial
+driver. It is not complete, any questions you have should be directed to
+<rmk@arm.linux.org.uk>
+
+The reference implementation is contained within serial_amba.c.
+
+
+
+Low Level Serial Hardware Driver
+--------------------------------
+
+The low level serial hardware driver is responsible for supplying port
+information (defined by uart_port) and a set of control methods (defined
+by uart_ops) to the core serial driver. The low level driver is also
+responsible for handling interrupts for the port, and providing any
+console support.
+
+
+Console Support
+---------------
+
+The serial core provides a few helper functions. This includes identifing
+the correct port structure (via uart_get_console) and decoding command line
+arguments (uart_parse_options).
+
+
+Locking
+-------
+
+Generally, all locking is done by the core driver, except for the interrupt
+functions. It is the responsibility of the low level hardware driver to
+perform the necessary locking there using info->lock. (since it is running
+in an interrupt, you only need to use spin_lock() and spin_unlock() from
+the interrupt handler).
+
+
+uart_ops
+--------
+
+The uart_ops structure is the main interface between serial_core and the
+hardware specific driver. It contains all the methods to control the
+hardware.
+
+ tx_empty(port)
+ This function tests whether the transmitter fifo and shifter
+ for the port described by 'port' is empty. If it is empty,
+ this function should return TIOCSER_TEMT, otherwise return 0.
+ If the port does not support this operation, then it should
+ return TIOCSER_TEMT.
+
+ set_mctrl(port, mctrl)
+ This function sets the modem control lines for port described
+ by 'port' to the state described by mctrl. The relevant bits
+ of mctrl are:
+ - TIOCM_RTS RTS signal.
+ - TIOCM_DTR DTR signal.
+ - TIOCM_OUT1 OUT1 signal.
+ - TIOCM_OUT2 OUT2 signal.
+ If the appropriate bit is set, the signal should be driven
+ active. If the bit is clear, the signal should be driven
+ inactive.
+
+ get_mctrl(port)
+ Returns the current state of modem control inputs. The state
+ of the outputs should not be returned, since the core keeps
+ track of their state. The state information should include:
+ - TIOCM_DCD state of DCD signal
+ - TIOCM_CTS state of CTS signal
+ - TIOCM_DSR state of DSR signal
+ - TIOCM_RI state of RI signal
+ The bit is set if the signal is currently driven active. If
+ the port does not support CTS, DCD or DSR, the driver should
+ indicate that the signal is permanently active. If RI is
+ not available, the signal should not be indicated as active.
+
+ stop_tx(port,from_tty)
+ Stop transmitting characters. This might be due to the CTS
+ line becoming inactive or the tty layer indicating we want
+ to stop transmission.
+
+ start_tx(port,nonempty,from_tty)
+ start transmitting characters. (incidentally, nonempty will
+ always be nonzero, and shouldn't be used - it will be dropped).
+
+ stop_rx(port)
+ Stop receiving characters; the port is in the process of
+ being closed.
+
+ enable_ms(port)
+ Enable the modem status interrupts.
+
+ break_ctl(port,ctl)
+ Control the transmission of a break signal. If ctl is
+ nonzero, the break signal should be transmitted. The signal
+ should be terminated when another call is made with a zero
+ ctl.
+
+ startup(port,info)
+ Grab any interrupt resources and initialise any low level driver
+ state. Enable the port for reception. It should not activate
+ RTS nor DTR; this will be done via a separate call to set_mctrl.
+
+ shutdown(port,info)
+ Disable the port, disable any break condition that may be in
+ effect, and free any interrupt resources. It should not disable
+ RTS nor DTR; this will have already been done via a separate
+ call to set_mctrl.
+
+ change_speed(port,cflag,iflag,quot)
+ Change the port parameters, including word length, parity, stop
+ bits. Update read_status_mask and ignore_status_mask to indicate
+ the types of events we are interested in receiving. Relevant
+ cflag bits are:
+ CSIZE - word size
+ CSTOPB - 2 stop bits
+ PARENB - parity enable
+ PARODD - odd parity (when PARENB is in force)
+ CREAD - enable reception of characters (if not set,
+ still receive characters from the port, but
+ throw them away.
+ CRTSCTS - if set, enable CTS status change reporting
+ CLOCAL - if not set, enable modem status change
+ reporting.
+ Relevant iflag bits are:
+ INPCK - enable frame and parity error events to be
+ passed to the TTY layer.
+ BRKINT
+ PARMRK - both of these enable break events to be
+ passed to the TTY layer.
+
+ IGNPAR - ignore parity and framing errors
+ IGNBRK - ignore break errors, If IGNPAR is also
+ set, ignore overrun errors as well.
+ The interaction of the iflag bits is as follows (parity error
+ given as an example):
+ Parity error INPCK IGNPAR
+ None n/a n/a character received
+ Yes n/a 0 character discarded
+ Yes 0 1 character received, marked as
+ TTY_NORMAL
+ Yes 1 1 character received, marked as
+ TTY_PARITY
+
+ pm(port,state,oldstate)
+ perform any power management related activities on the specified
+ port. state indicates the new state (defined by ACPI D0-D3),
+ oldstate indicates the previous state. Essentially, D0 means
+ fully on, D3 means powered down.
+
+ This function should not be used to grab any resources.
+
+ type(port)
+ Return a pointer to a string constant describing the specified
+ port, or return NULL, in which case the string 'unknown' is
+ substituted.
+
+ release_port(port)
+ Release any memory and IO region resources currently in use by
+ the port.
+
+ request_port(port)
+ Request any memory and IO region resources required by the port.
+ If any fail, no resources should be registered when this function
+ returns, and it should return -EBUSY on failure.
+
+ config_port(port,type)
+ Perform any autoconfiguration steps required for the port. `type`
+ contains a bit mask of the required configuration. UART_CONFIG_TYPE
+ indicates that the port requires detection and identification.
+ port->type should be set to the type found, or PORT_UNKNOWN if
+ no port was detected.
+
+ UART_CONFIG_IRQ indicates autoconfiguration of the interrupt signal,
+ which should be probed using standard kernel autoprobing techniques.
+ This is not necessary on platforms where ports have interrupts
+ internally hard wired (eg, system on a chip implementations).
+
+ verify_port(port,serinfo)
+ Verify the new serial port information contained within serinfo is
+ suitable for this port type.
+
+ ioctl(port,cmd,arg)
+ Perform any port specific IOCTLs. IOCTL commands must be defined
+ using the standard numbering system found in <asm/ioctl.h>
+
+
+Other notes
+-----------
+
+It is intended some day to drop the 'unused' entries from uart_port, and
+allow low level drivers to register their own individual uart_port's with
+the core. This will allow drivers to use uart_port as a pointer to a
+structure containing both the uart_port entry with their own extensions,
+thus:
+
+ struct my_port {
+ struct uart_port port;
+ int my_stuff;
+ };
+
diff -urN linux-2.4.26/MAINTAINERS linux-2.4.26-vrs1/MAINTAINERS
--- linux-2.4.26/MAINTAINERS 2004-04-19 11:44:14.000000000 +0100
+++ linux-2.4.26-vrs1/MAINTAINERS 2004-04-18 21:47:49.000000000 +0100
@@ -256,6 +256,8 @@
ARM/STRONGARM110 PORT
P: Russell King
M: rmk@arm.linux.org.uk
+P: Vincent Sanders
+M: vince@arm.linux.org.uk
L: linux-arm-kernel@lists.arm.linux.org.uk
W: http://www.arm.linux.org.uk/
S: Maintained
diff -urN linux-2.4.26/Makefile linux-2.4.26-vrs1/Makefile
--- linux-2.4.26/Makefile 2004-04-19 11:44:14.000000000 +0100
+++ linux-2.4.26-vrs1/Makefile 2004-04-18 21:50:41.000000000 +0100
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 26
-EXTRAVERSION =
+EXTRAVERSION =-vrs1
KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
@@ -137,7 +137,10 @@
DRIVERS-$(CONFIG_ACPI_BOOT) += drivers/acpi/acpi.o
DRIVERS-$(CONFIG_PARPORT) += drivers/parport/driver.o
-DRIVERS-y += drivers/char/char.o \
+DRIVERS-$(CONFIG_I2C) += drivers/i2c/i2c.o
+DRIVERS-$(CONFIG_L3) += drivers/l3/l3.o
+DRIVERS-y += drivers/serial/serial.o \
+ drivers/char/char.o \
drivers/block/block.o \
drivers/misc/misc.o \
drivers/net/net.o
@@ -161,6 +164,7 @@
DRIVERS-y += drivers/cdrom/driver.o
endif
+DRIVERS-$(CONFIG_SSI) += drivers/ssi/ssi.o
DRIVERS-$(CONFIG_SOUND) += drivers/sound/sounddrivers.o
DRIVERS-$(CONFIG_PCI) += drivers/pci/driver.o
DRIVERS-$(CONFIG_MTD) += drivers/mtd/mtdlink.o
@@ -186,7 +190,6 @@
DRIVERS-$(CONFIG_HIL) += drivers/hil/hil.o
DRIVERS-$(CONFIG_I2O) += drivers/message/i2o/i2o.o
DRIVERS-$(CONFIG_IRDA) += drivers/net/irda/irda.o
-DRIVERS-$(CONFIG_I2C) += drivers/i2c/i2c.o
DRIVERS-$(CONFIG_PHONE) += drivers/telephony/telephony.o
DRIVERS-$(CONFIG_MD) += drivers/md/mddev.o
DRIVERS-$(CONFIG_GSC) += drivers/gsc/gscbus.o
@@ -194,6 +197,8 @@
DRIVERS-$(CONFIG_HOTPLUG_PCI) += drivers/hotplug/vmlinux-obj.o
DRIVERS-$(CONFIG_ISDN_BOOL) += drivers/isdn/vmlinux-obj.o
DRIVERS-$(CONFIG_CRYPTO) += crypto/crypto.o
+DRIVERS-$(CONFIG_PLD) += drivers/pld/pld.o
+DRIVERS-$(CONFIG_ARCH_AT91RM9200) += drivers/at91/at91drv.o
DRIVERS := $(DRIVERS-y)
@@ -274,11 +279,6 @@
export NETWORKS DRIVERS LIBS HEAD LDFLAGS LINKFLAGS MAKEBOOT ASFLAGS
-.S.s:
- $(CPP) $(AFLAGS) $(AFLAGS_KERNEL) -traditional -o $*.s $<
-.S.o:
- $(CC) $(AFLAGS) $(AFLAGS_KERNEL) -traditional -c -o $*.o $<
-
Version: dummy
@rm -f include/linux/compile.h
diff -urN linux-2.4.26/Rules.make linux-2.4.26-vrs1/Rules.make
--- linux-2.4.26/Rules.make 2004-02-27 20:03:23.000000000 +0000
+++ linux-2.4.26-vrs1/Rules.make 2004-02-23 13:36:21.000000000 +0000
@@ -51,15 +51,15 @@
#
%.s: %.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -S $< -o $@
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$(*F)) $(CFLAGS_$@) -S $< -o $@
%.i: %.c
- $(CPP) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) $< > $@
+ $(CPP) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$(*F)) $(CFLAGS_$@) $< > $@
%.o: %.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -c -o $@ $<
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$(*F)) $(CFLAGS_$@) -c -o $@ $<
@ ( \
- echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS_nostdinc) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS_nostdinc) $$(CFLAGS_$@))))' ; \
+ echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS_nostdinc) $(CFLAGS_$(*F)) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS_nostdinc) $$(CFLAGS_$(*F)) $$(CFLAGS_$@))))' ; \
echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
echo 'endif' \
) > $(dir $@)/.$(notdir $@).flags
@@ -272,7 +272,8 @@
endif # CONFIG_MODVERSIONS
ifneq "$(strip $(export-objs))" ""
-$(export-objs): $(export-objs:.o=.c) $(TOPDIR)/include/linux/modversions.h
+$(export-objs): $(TOPDIR)/include/linux/modversions.h
+$(export-objs): %.o: %.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS_nostdinc) -DKBUILD_BASENAME=$(subst $(comma),_,$(subst -,_,$(*F))) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c)
@ ( \
echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS_nostdinc) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS_nostdinc) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
diff -urN linux-2.4.26/arch/alpha/config.in linux-2.4.26-vrs1/arch/alpha/config.in
--- linux-2.4.26/arch/alpha/config.in 2004-02-27 20:03:23.000000000 +0000
+++ linux-2.4.26-vrs1/arch/alpha/config.in 2004-02-23 13:36:21.000000000 +0000
@@ -7,6 +7,7 @@
define_bool CONFIG_UID16 n
define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n
define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y
+define_bool CONFIG_GENERIC_ISA_DMA y
mainmenu_name "Kernel configuration of Linux for Alpha machines"
diff -urN linux-2.4.26/arch/arm/Makefile linux-2.4.26-vrs1/arch/arm/Makefile
--- linux-2.4.26/arch/arm/Makefile 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/Makefile 2004-01-14 21:32:23.000000000 +0000
@@ -52,7 +52,7 @@
CFLAGS_BOOT :=$(apcs-y) $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Uarm
CFLAGS +=$(apcs-y) $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Uarm
-AFLAGS +=$(apcs-y) $(arch-y) -mno-fpu -msoft-float
+AFLAGS +=$(apcs-y) $(arch-y) -msoft-float
ifeq ($(CONFIG_CPU_26),y)
PROCESSOR := armo
diff -urN linux-2.4.26/arch/arm/boot/compressed/head.S linux-2.4.26-vrs1/arch/arm/boot/compressed/head.S
--- linux-2.4.26/arch/arm/boot/compressed/head.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/boot/compressed/head.S 2004-03-04 20:31:57.000000000 +0000
@@ -40,6 +40,14 @@
.macro writeb, rb
strb \rb, [r3, #0x3f8 << 2]
.endm
+#elif defined(CONFIG_ARCH_RISCSTATION)
+ .macro loadsp, rb
+ mov \rb, #0x03000000
+ orr \rb, \rb, #0x00010000
+ .endm
+ .macro writeb, rb
+ strb \rb, [r3, #0x3f8 << 2]
+ .endm
#elif defined(CONFIG_ARCH_INTEGRATOR)
.macro loadsp, rb
mov \rb, #0x16000000
@@ -396,6 +404,20 @@
mcr p15, 0, r0, c1, c0, 0 @ load control register
mov pc, r12
+__arm7_cache_on:
+ mov r12, lr
+ bl __setup_mmu
+ mov r0, #0
+ mcr p15, 0, r0, c7, c0, 0 @ invalidate whole cache v3
+ mcr p15, 0, r0, c5, c0, 0 @ invalidate whole TLB v3
+ mcr p15, 0, r3, c2, c0, 0 @ load page table pointer
+ mov r0, #-1
+ mcr p15, 0, r0, c3, c0, 0 @ load domain access control
+ mov r0, #0x7d
+ mcr p15, 0, r0, c1, c0, 0 @ load control register
+ mov pc, r12
+
+
/*
* All code following this line is relocatable. It is relocated by
* the above code to the end of the decompressed kernel image and
@@ -480,9 +502,9 @@
.word 0x41007000 @ ARM7/710
.word 0xfff8fe00
+ b __arm7_cache_on
b __arm7_cache_off
- b __arm7_cache_off
- mov pc, lr
+ b __armv3_cache_flush
.word 0x41807200 @ ARM720T (writethrough)
.word 0xffffff00
@@ -490,14 +512,14 @@
b __armv4_cache_off
mov pc, lr
- .word 0x41129200 @ ARM920T
- .word 0xff00fff0
+ .word 0x41009200 @ ARM920T, ARM922T, ARM926TEJ-S
+ .word 0xff00ff90
b __armv4_cache_on
b __armv4_cache_off
b __armv4_cache_flush
- .word 0x41029220 @ ARM922T
- .word 0xff00fff0
+ .word 0x4100a200 @ ARM1020T/E, ARM1022E, ARM1026TEJ-S
+ .word 0xff00ff90
b __armv4_cache_on
b __armv4_cache_off
b __armv4_cache_flush
diff -urN linux-2.4.26/arch/arm/config.in linux-2.4.26-vrs1/arch/arm/config.in
--- linux-2.4.26/arch/arm/config.in 2004-02-27 20:03:23.000000000 +0000
+++ linux-2.4.26-vrs1/arch/arm/config.in 2004-04-10 12:21:08.000000000 +0100
@@ -144,6 +144,7 @@
mainmenu_option next_comment
comment 'AT91RM9200 Implementations'
dep_bool ' Atmel AT91RM9200 Development Board' CONFIG_ARCH_AT91RM9200DK $CONFIG_ARCH_AT91RM9200
+dep_bool ' Cogent CSB337' CONFIG_MACH_CSB337 $CONFIG_ARCH_AT91RM9200
endmenu
mainmenu_option next_comment
@@ -189,6 +190,12 @@
define_bool CONFIG_ARCH_ACORN n
fi
+if [ "$CONFIG_ARCH_CAMELOT" = "y" ]; then
+ define_bool CONFIG_PLD y
+else
+ define_bool CONFIG_PLD n
+fi
+
#####################################################################
# Footbridge support
if [ "$CONFIG_ARCH_CO285" = "y" -o \
@@ -315,26 +322,42 @@
# ARM922T
if [ "$CONFIG_ARCH_CAMELOT" = "y" ]; then
define_bool CONFIG_CPU_ARM922T y
- define_bool CONFIG_PLD y
else
- define_bool CONFIG_CPU_ARM922T n
- define_bool CONFIG_PLD n
+ if [ "$CONFIG_ARCH_INTEGRATOR" = "y" ]; then
+ bool 'Support ARM922T(Excalibur) processor' CONFIG_ARM922T
+ else
+ define_bool CONFIG_CPU_ARM922T n
+ fi
fi
# ARM926T
if [ "$CONFIG_ARCH_INTEGRATOR" = "y" ]; then
- bool 'Support ARM926T processor' CONFIG_CPU_ARM926T
+ bool 'Support ARM926TEJ-S processor' CONFIG_CPU_ARM926T
else
define_bool CONFIG_CPU_ARM926T n
fi
# ARM1020
if [ "$CONFIG_ARCH_INTEGRATOR" = "y" ]; then
- bool 'Support ARM1020 processor' CONFIG_CPU_ARM1020
+ bool 'Support ARM1020T (Rev0) processor' CONFIG_CPU_ARM1020
else
define_bool CONFIG_CPU_ARM1020 n
fi
+# ARM1020E
+if [ "$CONFIG_ARCH_INTEGRATOR" = "y" ]; then
+ bool 'Support ARM1020E (Rev1) processor' CONFIG_CPU_ARM1020E
+else
+ define_bool CONFIG_CPU_ARM1020E n
+fi
+
+# ARM1022
+if [ "$CONFIG_ARCH_INTEGRATOR" = "y" ]; then
+ bool 'Support ARM1022 processor' CONFIG_CPU_ARM1020E
+else
+ define_bool CONFIG_CPU_ARM1022 n
+fi
+
# ARM1026EJ-S
if [ "$CONFIG_ARCH_INTEGRATOR" = "y" ]; then
bool 'Support ARM1026EJ-S processor' CONFIG_CPU_ARM1026
@@ -388,25 +411,29 @@
if [ "$CONFIG_CPU_ARM720T" = "y" -o "$CONFIG_CPU_ARM920T" = "y" -o \
"$CONFIG_CPU_ARM922T" = "y" -o "$CONFIG_CPU_ARM926T" = "y" -o \
- "$CONFIG_CPU_ARM1020" = "y" -o "$CONFIG_CPU_ARM1026" = "y" ]; then
+ "$CONFIG_CPU_ARM1020" = "y" -o "$CONFIG_CPU_ARM1020E" = "y" -o \
+ "$CONFIG_CPU_ARM1022" = "y" -o "$CONFIG_CPU_ARM1026" = "y" ]; then
dep_bool 'Support Thumb instructions (EXPERIMENTAL)' CONFIG_ARM_THUMB $CONFIG_EXPERIMENTAL
fi
if [ "$CONFIG_CPU_ARM920T" = "y" -o "$CONFIG_CPU_ARM922T" = "y" -o \
"$CONFIG_CPU_ARM926T" = "y" -o "$CONFIG_CPU_ARM1020" = "y" -o \
+ "$CONFIG_CPU_ARM1020E" = "y" -o "$CONFIG_CPU_ARM1022" = "y" -o \
"$CONFIG_CPU_ARM1026" = "y" ]; then
bool 'Disable I-Cache' CONFIG_CPU_ICACHE_DISABLE
bool 'Disable D-Cache' CONFIG_CPU_DCACHE_DISABLE
- if [ "$CONFIG_CPU_DISABLE_DCACHE" = "n" ]; then
+ if [ "$CONFIG_CPU_DCACHE_DISABLE" = "n" ]; then
bool 'Force write through D-cache' CONFIG_CPU_DCACHE_WRITETHROUGH
fi
fi
if [ "$CONFIG_CPU_ARM926T" = "y" -o "$CONFIG_CPU_ARM1020" = "y" -o \
+ "$CONFIG_CPU_ARM1020E" = "y" -o "$CONFIG_CPU_ARM1022" = "y" -o \
"$CONFIG_CPU_ARM1026" = "y" ]; then
if [ "$CONFIG_CPU_ICACHE_DISABLE" = "n" -o "$CONFIG_CPU_DCACHE_DISABLE" = "n" ]; then
bool 'Round robin I and D cache replacement algorithm' CONFIG_CPU_CACHE_ROUND_ROBIN
fi
fi
-if [ "$CONFIG_CPU_ARM1020" = "y" -o "$CONFIG_CPU_ARM1026" = "y" ]; then
+if [ "$CONFIG_CPU_ARM1020" = "y" -o "$CONFIG_CPU_ARM1020E" = "y" -o \
+ "$CONFIG_CPU_ARM1026" = "y" -o "$CONFIG_CPU_ARM1022" = "y" ]; then
bool 'Disable branch prediction' CONFIG_CPU_BPREDICT_DISABLE
fi
@@ -514,7 +541,8 @@
"$CONFIG_ARCH_INTEGRATOR" = "y" -o \
"$CONFIG_ARCH_CDB89712" = "y" -o \
"$CONFIG_ARCH_P720T" = "y" -o \
- "$CONFIG_ARCH_OMAHA" = "y" ]; then
+ "$CONFIG_ARCH_OMAHA" = "y" -o \
+ "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
bool 'Timer and CPU usage LEDs' CONFIG_LEDS
if [ "$CONFIG_LEDS" = "y" ]; then
if [ "$CONFIG_ARCH_NETWINDER" = "y" -o \
@@ -524,7 +552,8 @@
"$CONFIG_ARCH_SA1100" = "y" -o \
"$CONFIG_ARCH_INTEGRATOR" = "y" -o \
"$CONFIG_ARCH_P720T" = "y" -o \
- "$CONFIG_ARCH_OMAHA" = "y" ]; then
+ "$CONFIG_ARCH_OMAHA" = "y" -o \
+ "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
bool ' Timer LED' CONFIG_LEDS_TIMER
bool ' CPU usage LED' CONFIG_LEDS_CPU
fi
@@ -729,10 +758,7 @@
dep_bool ' Kernel low-level debugging functions' CONFIG_DEBUG_LL $CONFIG_DEBUG_KERNEL
dep_bool ' Kernel low-level debugging messages via footbridge serial port' CONFIG_DEBUG_DC21285_PORT $CONFIG_DEBUG_LL $CONFIG_FOOTBRIDGE
dep_bool ' Kernel low-level debugging messages via UART2' CONFIG_DEBUG_CLPS711X_UART2 $CONFIG_DEBUG_LL $CONFIG_ARCH_CLPS711X
-
-int 'Kernel messages buffer length shift (0 = default)' CONFIG_LOG_BUF_SHIFT 0
-
endmenu
-source crypto/Config.in
source lib/Config.in
+
diff -urN linux-2.4.26/arch/arm/def-configs/at91rm9200dk linux-2.4.26-vrs1/arch/arm/def-configs/at91rm9200dk
--- linux-2.4.26/arch/arm/def-configs/at91rm9200dk 2004-02-27 20:03:23.000000000 +0000
+++ linux-2.4.26-vrs1/arch/arm/def-configs/at91rm9200dk 2004-03-04 22:47:46.000000000 +0000
@@ -111,6 +111,7 @@
# AT91RM9200 Implementations
#
CONFIG_ARCH_AT91RM9200DK=y
+# CONFIG_MACH_CSB337 is not set
#
# CLPS711X/EP721X Implementations
@@ -125,6 +126,7 @@
# CONFIG_ARCH_EP7211 is not set
# CONFIG_ARCH_EP7212 is not set
# CONFIG_ARCH_ACORN is not set
+# CONFIG_PLD is not set
# CONFIG_FOOTBRIDGE is not set
# CONFIG_FOOTBRIDGE_HOST is not set
# CONFIG_FOOTBRIDGE_ADDIN is not set
@@ -135,9 +137,10 @@
# CONFIG_CPU_ARM720T is not set
CONFIG_CPU_ARM920T=y
# CONFIG_CPU_ARM922T is not set
-# CONFIG_PLD is not set
# CONFIG_CPU_ARM926T is not set
# CONFIG_CPU_ARM1020 is not set
+# CONFIG_CPU_ARM1020E is not set
+# CONFIG_CPU_ARM1022 is not set
# CONFIG_CPU_ARM1026 is not set
# CONFIG_CPU_SA110 is not set
# CONFIG_CPU_SA1100 is not set
@@ -146,6 +149,7 @@
# CONFIG_ARM_THUMB is not set
# CONFIG_CPU_ICACHE_DISABLE is not set
# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
# CONFIG_DISCONTIGMEM is not set
#
@@ -164,6 +168,7 @@
# CONFIG_BSD_PROCESS_ACCT is not set
CONFIG_SYSCTL=y
CONFIG_FPE_NWFPE=y
+# CONFIG_FPE_NWFPE_XP is not set
# CONFIG_FPE_FASTFPE is not set
CONFIG_KCORE_ELF=y
# CONFIG_KCORE_AOUT is not set
@@ -173,6 +178,9 @@
# CONFIG_PM is not set
# CONFIG_ARTHUR is not set
CONFIG_CMDLINE="mem=32M console=ttyS0,115200 initrd=0x20210000,3145728 root=/dev/ram rw"
+CONFIG_LEDS=y
+CONFIG_LEDS_TIMER=y
+# CONFIG_LEDS_CPU is not set
CONFIG_ALIGNMENT_TRAP=y
#
@@ -204,6 +212,7 @@
# CONFIG_MTD_CFI_ADV_OPTIONS is not set
# CONFIG_MTD_CFI_INTELEXT is not set
CONFIG_MTD_CFI_AMDSTD=y
+# CONFIG_MTD_CFI_STAA is not set
# CONFIG_MTD_RAM is not set
# CONFIG_MTD_ROM is not set
# CONFIG_MTD_ABSENT is not set
@@ -230,7 +239,9 @@
# CONFIG_MTD_AUTCPU12 is not set
# CONFIG_MTD_EDB7312 is not set
# CONFIG_MTD_IMPA7 is not set
+# CONFIG_MTD_CEIVA is not set
# CONFIG_MTD_PCI is not set
+# CONFIG_MTD_PCMCIA is not set
#
# Self-contained MTD device drivers
@@ -250,9 +261,9 @@
# NAND Flash Device Drivers
#
CONFIG_MTD_NAND=y
-CONFIG_MTD_NAND_ECC=y
# CONFIG_MTD_NAND_VERIFY_WRITE is not set
-CONFIG_MTD_AT91_SMARTMEDIA=y
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_AT91_SMARTMEDIA is not set
#
# Plug and Play configuration
@@ -269,6 +280,7 @@
# CONFIG_BLK_CPQ_DA is not set
# CONFIG_BLK_CPQ_CISS_DA is not set
# CONFIG_CISS_SCSI_TAPE is not set
+# CONFIG_CISS_MONITOR_THREAD is not set
# CONFIG_BLK_DEV_DAC960 is not set
# CONFIG_BLK_DEV_UMEM is not set
# CONFIG_BLK_DEV_LOOP is not set
@@ -276,6 +288,7 @@
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=8192
CONFIG_BLK_DEV_INITRD=y
+# CONFIG_BLK_STATS is not set
#
# Multi-device support (RAID and LVM)
@@ -312,6 +325,12 @@
# CONFIG_SYN_COOKIES is not set
# CONFIG_IPV6 is not set
# CONFIG_KHTTPD is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IPV6_SCTP__=y
+# CONFIG_IP_SCTP is not set
# CONFIG_ATM is not set
# CONFIG_VLAN_8021Q is not set
# CONFIG_IPX is not set
@@ -382,10 +401,12 @@
#
# CONFIG_ACENIC is not set
# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
# CONFIG_MYRI_SBUS is not set
# CONFIG_NS83820 is not set
# CONFIG_HAMACHI is not set
# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
# CONFIG_SK98LIN is not set
# CONFIG_TIGON3 is not set
# CONFIG_FDDI is not set
@@ -455,6 +476,8 @@
# CONFIG_INPUT_MOUSEDEV is not set
# CONFIG_INPUT_JOYDEV is not set
# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_UINPUT is not set
+# CONFIG_INPUT_MX1TS is not set
#
# Character devices
@@ -502,6 +525,7 @@
#
CONFIG_I2C=y
# CONFIG_I2C_ALGOBIT is not set
+# CONFIG_SCx200_ACB is not set
# CONFIG_I2C_ALGOPCF is not set
CONFIG_I2C_AT91=y
CONFIG_I2C_CHARDEV=y
@@ -528,6 +552,11 @@
#
# CONFIG_INPUT_GAMEPORT is not set
# CONFIG_QIC02_TAPE is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_IPMI_PANIC_EVENT is not set
+# CONFIG_IPMI_DEVICE_INTERFACE is not set
+# CONFIG_IPMI_KCS is not set
+# CONFIG_IPMI_WATCHDOG is not set
#
# Watchdog Cards
@@ -536,12 +565,14 @@
CONFIG_WATCHDOG_NOWAYOUT=y
# CONFIG_ACQUIRE_WDT is not set
# CONFIG_ADVANTECH_WDT is not set
+# CONFIG_ALIM1535_WDT is not set
# CONFIG_ALIM7101_WDT is not set
# CONFIG_SC520_WDT is not set
# CONFIG_PCWATCHDOG is not set
# CONFIG_21285_WATCHDOG is not set
# CONFIG_977_WATCHDOG is not set
# CONFIG_SA1100_WATCHDOG is not set
+# CONFIG_EPXA_WATCHDOG is not set
# CONFIG_OMAHA_WATCHDOG is not set
CONFIG_AT91_WATCHDOG=y
# CONFIG_EUROTECH_WDT is not set
@@ -551,11 +582,16 @@
# CONFIG_MIXCOMWD is not set
# CONFIG_60XX_WDT is not set
# CONFIG_SC1200_WDT is not set
+# CONFIG_SCx200_WDT is not set
# CONFIG_SOFT_WATCHDOG is not set
# CONFIG_W83877F_WDT is not set
# CONFIG_WDT is not set
# CONFIG_WDTPCI is not set
# CONFIG_MACHZ_WDT is not set
+# CONFIG_AMD7XX_TCO is not set
+# CONFIG_SCx200 is not set
+# CONFIG_SCx200_GPIO is not set
+# CONFIG_AMD_PM768 is not set
# CONFIG_NVRAM is not set
# CONFIG_RTC is not set
CONFIG_AT91_RTC=y
@@ -568,6 +604,10 @@
#
# CONFIG_FTAPE is not set
# CONFIG_AGP is not set
+
+#
+# Direct Rendering Manager (XFree86 DRI support)
+#
# CONFIG_DRM is not set
#
@@ -579,6 +619,7 @@
# File systems
#
# CONFIG_QUOTA is not set
+# CONFIG_QFMT_V2 is not set
# CONFIG_AUTOFS_FS is not set
# CONFIG_AUTOFS4_FS is not set
# CONFIG_REISERFS_FS is not set
@@ -588,6 +629,9 @@
# CONFIG_ADFS_FS_RW is not set
# CONFIG_AFFS_FS is not set
# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BEFS_DEBUG is not set
# CONFIG_BFS_FS is not set
# CONFIG_EXT3_FS is not set
# CONFIG_JBD is not set
@@ -605,6 +649,9 @@
# CONFIG_ISO9660_FS is not set
# CONFIG_JOLIET is not set
# CONFIG_ZISOFS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
# CONFIG_MINIX_FS is not set
# CONFIG_VXFS_FS is not set
# CONFIG_NTFS_FS is not set
@@ -624,6 +671,11 @@
# CONFIG_UDF_RW is not set
# CONFIG_UFS_FS is not set
# CONFIG_UFS_FS_WRITE is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_TRACE is not set
+# CONFIG_XFS_DEBUG is not set
#
# Network File Systems
@@ -632,9 +684,11 @@
# CONFIG_INTERMEZZO_FS is not set
# CONFIG_NFS_FS is not set
# CONFIG_NFS_V3 is not set
+# CONFIG_NFS_DIRECTIO is not set
# CONFIG_ROOT_NFS is not set
# CONFIG_NFSD is not set
# CONFIG_NFSD_V3 is not set
+# CONFIG_NFSD_TCP is not set
# CONFIG_SUNRPC is not set
# CONFIG_LOCKD is not set
# CONFIG_SMB_FS is not set
@@ -648,7 +702,6 @@
# CONFIG_NCPFS_NLS is not set
# CONFIG_NCPFS_EXTRAS is not set
# CONFIG_ZISOFS_FS is not set
-# CONFIG_ZLIB_FS_INFLATE is not set
#
# Partition Types
@@ -674,16 +727,18 @@
# CONFIG_USB_DEBUG is not set
# CONFIG_USB_DEVICEFS is not set
# CONFIG_USB_BANDWIDTH is not set
-# CONFIG_USB_LONG_TIMEOUT is not set
# CONFIG_USB_EHCI_HCD is not set
# CONFIG_USB_UHCI is not set
# CONFIG_USB_UHCI_ALT is not set
# CONFIG_USB_OHCI is not set
# CONFIG_USB_OHCI_SA1111 is not set
+# CONFIG_USB_SL811HS_ALT is not set
+# CONFIG_USB_SL811HS is not set
CONFIG_USB_OHCI_AT91=y
# CONFIG_USB_AUDIO is not set
# CONFIG_USB_EMI26 is not set
# CONFIG_USB_BLUETOOTH is not set
+# CONFIG_USB_MIDI is not set
# CONFIG_USB_STORAGE is not set
# CONFIG_USB_STORAGE_DEBUG is not set
# CONFIG_USB_STORAGE_DATAFAB is not set
@@ -692,6 +747,7 @@
# CONFIG_USB_STORAGE_DPCM is not set
# CONFIG_USB_STORAGE_HP8200e is not set
# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
# CONFIG_USB_STORAGE_JUMPSHOT is not set
# CONFIG_USB_ACM is not set
# CONFIG_USB_PRINTER is not set
@@ -700,7 +756,10 @@
# CONFIG_USB_HIDDEV is not set
# CONFIG_USB_KBD is not set
# CONFIG_USB_MOUSE is not set
+# CONFIG_USB_AIPTEK is not set
# CONFIG_USB_WACOM is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
# CONFIG_USB_DC2XX is not set
# CONFIG_USB_MDC800 is not set
# CONFIG_USB_SCANNER is not set
@@ -718,35 +777,16 @@
# USB Serial Converter support
#
# CONFIG_USB_SERIAL is not set
-# CONFIG_USB_SERIAL_GENERIC is not set
-# CONFIG_USB_SERIAL_BELKIN is not set
-# CONFIG_USB_SERIAL_WHITEHEAT is not set
-# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
-# CONFIG_USB_SERIAL_EMPEG is not set
-# CONFIG_USB_SERIAL_FTDI_SIO is not set
-# CONFIG_USB_SERIAL_VISOR is not set
-# CONFIG_USB_SERIAL_IPAQ is not set
-# CONFIG_USB_SERIAL_IR is not set
-# CONFIG_USB_SERIAL_EDGEPORT is not set
-# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
-# CONFIG_USB_SERIAL_KEYSPAN is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28 is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28X is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XA is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA28XB is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA19 is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA18X is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA19W is not set
-# CONFIG_USB_SERIAL_KEYSPAN_USA49W is not set
-# CONFIG_USB_SERIAL_MCT_U232 is not set
-# CONFIG_USB_SERIAL_KLSI is not set
-# CONFIG_USB_SERIAL_PL2303 is not set
-# CONFIG_USB_SERIAL_CYBERJACK is not set
-# CONFIG_USB_SERIAL_XIRCOM is not set
-# CONFIG_USB_SERIAL_OMNINET is not set
# CONFIG_USB_RIO500 is not set
# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_TIGL is not set
# CONFIG_USB_BRLVGER is not set
+# CONFIG_USB_LCD is not set
+
+#
+# Support for USB gadgets
+#
+# CONFIG_USB_GADGET is not set
#
# Bluetooth support
@@ -770,3 +810,10 @@
CONFIG_DEBUG_LL=y
# CONFIG_DEBUG_DC21285_PORT is not set
# CONFIG_DEBUG_CLPS711X_UART2 is not set
+
+#
+# Library routines
+#
+CONFIG_CRC32=y
+# CONFIG_ZLIB_INFLATE is not set
+# CONFIG_ZLIB_DEFLATE is not set
diff -urN linux-2.4.26/arch/arm/def-configs/csb337 linux-2.4.26-vrs1/arch/arm/def-configs/csb337
--- linux-2.4.26/arch/arm/def-configs/csb337 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/def-configs/csb337 2004-03-04 22:44:33.000000000 +0000
@@ -0,0 +1,760 @@
+#
+# Automatically generated by make menuconfig: don't edit
+#
+CONFIG_ARM=y
+# CONFIG_EISA is not set
+# CONFIG_SBUS is not set
+# CONFIG_MCA is not set
+CONFIG_UID16=y
+CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
+# CONFIG_GENERIC_BUST_SPINLOCK is not set
+# CONFIG_GENERIC_ISA_DMA is not set
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+# CONFIG_OBSOLETE is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+# CONFIG_MODVERSIONS is not set
+CONFIG_KMOD=y
+
+#
+# System Type
+#
+# CONFIG_ARCH_ANAKIN is not set
+# CONFIG_ARCH_ARCA5K is not set
+# CONFIG_ARCH_CLPS7500 is not set
+# CONFIG_ARCH_CLPS711X is not set
+# CONFIG_ARCH_CO285 is not set
+# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_CAMELOT is not set
+# CONFIG_ARCH_FOOTBRIDGE is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_OMAHA is not set
+# CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_MX1ADS is not set
+# CONFIG_ARCH_RPC is not set
+# CONFIG_ARCH_RISCSTATION is not set
+# CONFIG_ARCH_SA1100 is not set
+# CONFIG_ARCH_SHARK is not set
+CONFIG_ARCH_AT91RM9200=y
+
+#
+# Archimedes/A5000 Implementations
+#
+# CONFIG_ARCH_ARC is not set
+# CONFIG_ARCH_A5K is not set
+
+#
+# Footbridge Implementations
+#
+# CONFIG_ARCH_CATS is not set
+# CONFIG_ARCH_PERSONAL_SERVER is not set
+# CONFIG_ARCH_EBSA285_ADDIN is not set
+# CONFIG_ARCH_EBSA285_HOST is not set
+# CONFIG_ARCH_NETWINDER is not set
+
+#
+# SA11x0 Implementations
+#
+# CONFIG_SA1100_ACCELENT is not set
+# CONFIG_SA1100_ASSABET is not set
+# CONFIG_ASSABET_NEPONSET is not set
+# CONFIG_SA1100_ADSAGC is not set
+# CONFIG_SA1100_ADSBITSY is not set
+# CONFIG_SA1100_ADSBITSYPLUS is not set
+# CONFIG_SA1100_BRUTUS is not set
+# CONFIG_SA1100_CEP is not set
+# CONFIG_SA1100_CERF is not set
+# CONFIG_SA1100_H3100 is not set
+# CONFIG_SA1100_H3600 is not set
+# CONFIG_SA1100_H3800 is not set
+# CONFIG_SA1100_H3XXX is not set
+# CONFIG_H3600_SLEEVE is not set
+# CONFIG_SA1100_EXTENEX1 is not set
+# CONFIG_SA1100_FLEXANET is not set
+# CONFIG_SA1100_FREEBIRD is not set
+# CONFIG_SA1100_FRODO is not set
+# CONFIG_SA1100_GRAPHICSCLIENT is not set
+# CONFIG_SA1100_GRAPHICSMASTER is not set
+# CONFIG_SA1100_HACKKIT is not set
+# CONFIG_SA1100_BADGE4 is not set
+# CONFIG_SA1100_JORNADA720 is not set
+# CONFIG_SA1100_HUW_WEBPANEL is not set
+# CONFIG_SA1100_ITSY is not set
+# CONFIG_SA1100_LART is not set
+# CONFIG_SA1100_NANOENGINE is not set
+# CONFIG_SA1100_OMNIMETER is not set
+# CONFIG_SA1100_PANGOLIN is not set
+# CONFIG_SA1100_PLEB is not set
+# CONFIG_SA1100_PT_SYSTEM3 is not set
+# CONFIG_SA1100_SHANNON is not set
+# CONFIG_SA1100_SHERMAN is not set
+# CONFIG_SA1100_SIMPAD is not set
+# CONFIG_SA1100_SIMPUTER is not set
+# CONFIG_SA1100_PFS168 is not set
+# CONFIG_SA1100_VICTOR is not set
+# CONFIG_SA1100_XP860 is not set
+# CONFIG_SA1100_YOPY is not set
+# CONFIG_SA1100_USB is not set
+# CONFIG_SA1100_USB_NETLINK is not set
+# CONFIG_SA1100_USB_CHAR is not set
+# CONFIG_SA1100_SSP is not set
+
+#
+# AT91RM9200 Implementations
+#
+# CONFIG_ARCH_AT91RM9200DK is not set
+CONFIG_MACH_CSB337=y
+
+#
+# CLPS711X/EP721X Implementations
+#
+# CONFIG_ARCH_AUTCPU12 is not set
+# CONFIG_ARCH_CDB89712 is not set
+# CONFIG_ARCH_CLEP7312 is not set
+# CONFIG_ARCH_EDB7211 is not set
+# CONFIG_ARCH_FORTUNET is not set
+# CONFIG_ARCH_GUIDEA07 is not set
+# CONFIG_ARCH_P720T is not set
+# CONFIG_ARCH_EP7211 is not set
+# CONFIG_ARCH_EP7212 is not set
+# CONFIG_ARCH_ACORN is not set
+# CONFIG_PLD is not set
+# CONFIG_FOOTBRIDGE is not set
+# CONFIG_FOOTBRIDGE_HOST is not set
+# CONFIG_FOOTBRIDGE_ADDIN is not set
+CONFIG_CPU_32=y
+# CONFIG_CPU_26 is not set
+# CONFIG_CPU_ARM610 is not set
+# CONFIG_CPU_ARM710 is not set
+# CONFIG_CPU_ARM720T is not set
+CONFIG_CPU_ARM920T=y
+# CONFIG_CPU_ARM922T is not set
+# CONFIG_CPU_ARM926T is not set
+# CONFIG_CPU_ARM1020 is not set
+# CONFIG_CPU_ARM1020E is not set
+# CONFIG_CPU_ARM1022 is not set
+# CONFIG_CPU_ARM1026 is not set
+# CONFIG_CPU_SA110 is not set
+# CONFIG_CPU_SA1100 is not set
+# CONFIG_CPU_32v3 is not set
+CONFIG_CPU_32v4=y
+# CONFIG_ARM_THUMB is not set
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
+# CONFIG_DISCONTIGMEM is not set
+
+#
+# General setup
+#
+# CONFIG_PCI is not set
+# CONFIG_ISA is not set
+# CONFIG_ISA_DMA is not set
+# CONFIG_ZBOOT_ROM is not set
+CONFIG_ZBOOT_ROM_TEXT=0
+CONFIG_ZBOOT_ROM_BSS=0
+# CONFIG_HOTPLUG is not set
+# CONFIG_PCMCIA is not set
+CONFIG_NET=y
+CONFIG_SYSVIPC=y
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+CONFIG_FPE_NWFPE=y
+# CONFIG_FPE_NWFPE_XP is not set
+# CONFIG_FPE_FASTFPE is not set
+CONFIG_KCORE_ELF=y
+# CONFIG_KCORE_AOUT is not set
+# CONFIG_BINFMT_AOUT is not set
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+# CONFIG_PM is not set
+# CONFIG_ARTHUR is not set
+CONFIG_CMDLINE="mem=32M console=ttyS0,38400 initrd=0x20210000,3145728 root=/dev/ram rw"
+# CONFIG_LEDS is not set
+CONFIG_ALIGNMENT_TRAP=y
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+CONFIG_MTD=y
+# CONFIG_MTD_DEBUG is not set
+# CONFIG_MTD_PARTITIONS is not set
+# CONFIG_MTD_CONCAT is not set
+# CONFIG_MTD_REDBOOT_PARTS is not set
+# CONFIG_MTD_CMDLINE_PARTS is not set
+# CONFIG_MTD_AFS_PARTS is not set
+CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLOCK=y
+# CONFIG_FTL is not set
+# CONFIG_NFTL is not set
+
+#
+# RAM/ROM/Flash chip drivers
+#
+CONFIG_MTD_CFI=y
+CONFIG_MTD_JEDECPROBE=y
+CONFIG_MTD_GEN_PROBE=y
+# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_CFI_INTELEXT=y
+# CONFIG_MTD_CFI_AMDSTD is not set
+# CONFIG_MTD_CFI_STAA is not set
+# CONFIG_MTD_RAM is not set
+CONFIG_MTD_ROM=y
+# CONFIG_MTD_ABSENT is not set
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
+# CONFIG_MTD_AMDSTD is not set
+# CONFIG_MTD_SHARP is not set
+# CONFIG_MTD_JEDEC is not set
+
+#
+# Mapping drivers for chip access
+#
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_START=10000000
+CONFIG_MTD_PHYSMAP_LEN=200000
+CONFIG_MTD_PHYSMAP_BUSWIDTH=2
+# CONFIG_MTD_NORA is not set
+# CONFIG_MTD_ARM_INTEGRATOR is not set
+# CONFIG_MTD_CDB89712 is not set
+# CONFIG_MTD_SA1100 is not set
+# CONFIG_MTD_DC21285 is not set
+# CONFIG_MTD_IQ80310 is not set
+# CONFIG_MTD_FORTUNET is not set
+# CONFIG_MTD_EPXA is not set
+# CONFIG_MTD_AUTCPU12 is not set
+# CONFIG_MTD_EDB7312 is not set
+# CONFIG_MTD_IMPA7 is not set
+# CONFIG_MTD_CEIVA is not set
+# CONFIG_MTD_PCI is not set
+# CONFIG_MTD_PCMCIA is not set
+
+#
+# Self-contained MTD device drivers
+#
+# CONFIG_MTD_PMC551 is not set
+# CONFIG_MTD_SLRAM is not set
+CONFIG_MTD_AT91_DATAFLASH=y
+# CONFIG_MTD_AT91_DATAFLASH_CARD is not set
+# CONFIG_MTD_MTDRAM is not set
+# CONFIG_MTD_BLKMTD is not set
+# CONFIG_MTD_DOC1000 is not set
+# CONFIG_MTD_DOC2000 is not set
+# CONFIG_MTD_DOC2001 is not set
+# CONFIG_MTD_DOCPROBE is not set
+
+#
+# NAND Flash Device Drivers
+#
+CONFIG_MTD_NAND=y
+# CONFIG_MTD_NAND_VERIFY_WRITE is not set
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_AT91_SMARTMEDIA is not set
+
+#
+# Plug and Play configuration
+#
+# CONFIG_PNP is not set
+# CONFIG_ISAPNP is not set
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_XD is not set
+# CONFIG_PARIDE is not set
+# CONFIG_BLK_CPQ_DA is not set
+# CONFIG_BLK_CPQ_CISS_DA is not set
+# CONFIG_CISS_SCSI_TAPE is not set
+# CONFIG_CISS_MONITOR_THREAD is not set
+# CONFIG_BLK_DEV_DAC960 is not set
+# CONFIG_BLK_DEV_UMEM is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=8192
+# CONFIG_BLK_DEV_INITRD is not set
+# CONFIG_BLK_STATS is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+# CONFIG_BLK_DEV_MD is not set
+# CONFIG_MD_LINEAR is not set
+# CONFIG_MD_RAID0 is not set
+# CONFIG_MD_RAID1 is not set
+# CONFIG_MD_RAID5 is not set
+# CONFIG_MD_MULTIPATH is not set
+# CONFIG_BLK_DEV_LVM is not set
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+# CONFIG_NETLINK_DEV is not set
+# CONFIG_NETFILTER is not set
+# CONFIG_FILTER is not set
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_INET_ECN is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_IPV6 is not set
+# CONFIG_KHTTPD is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+CONFIG_IPV6_SCTP__=y
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+
+#
+# Appletalk devices
+#
+# CONFIG_DEV_APPLETALK is not set
+# CONFIG_DECNET is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+# CONFIG_LLC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+# CONFIG_NET_FASTROUTE is not set
+# CONFIG_NET_HW_FLOWCONTROL is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+
+#
+# ARCnet devices
+#
+# CONFIG_ARCNET is not set
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+# CONFIG_ETHERTAP is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+# CONFIG_ARM_AM79C961A is not set
+# CONFIG_ARM_CIRRUS is not set
+CONFIG_AT91_ETHER=y
+# CONFIG_AT91_ETHER_RMII is not set
+# CONFIG_SUNLANCE is not set
+# CONFIG_SUNBMAC is not set
+# CONFIG_SUNQE is not set
+# CONFIG_SUNGEM is not set
+# CONFIG_NET_VENDOR_3COM is not set
+# CONFIG_LANCE is not set
+# CONFIG_NET_VENDOR_SMC is not set
+# CONFIG_NET_VENDOR_RACAL is not set
+# CONFIG_NET_ISA is not set
+# CONFIG_NET_PCI is not set
+# CONFIG_NET_POCKET is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+# CONFIG_ACENIC is not set
+# CONFIG_DL2K is not set
+# CONFIG_E1000 is not set
+# CONFIG_MYRI_SBUS is not set
+# CONFIG_NS83820 is not set
+# CONFIG_HAMACHI is not set
+# CONFIG_YELLOWFIN is not set
+# CONFIG_R8169 is not set
+# CONFIG_SK98LIN is not set
+# CONFIG_TIGON3 is not set
+# CONFIG_FDDI is not set
+# CONFIG_HIPPI is not set
+# CONFIG_PLIP is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Token Ring devices
+#
+# CONFIG_TR is not set
+# CONFIG_NET_FC is not set
+# CONFIG_RCPCI is not set
+# CONFIG_SHAPER is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+
+#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
+# IrDA (infrared) support
+#
+# CONFIG_IRDA is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+# CONFIG_BLK_DEV_HD is not set
+
+#
+# SCSI support
+#
+# CONFIG_SCSI is not set
+
+#
+# I2O device support
+#
+# CONFIG_I2O is not set
+# CONFIG_I2O_BLOCK is not set
+# CONFIG_I2O_LAN is not set
+# CONFIG_I2O_SCSI is not set
+# CONFIG_I2O_PROC is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Input core support
+#
+# CONFIG_INPUT is not set
+# CONFIG_INPUT_KEYBDEV is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_UINPUT is not set
+# CONFIG_INPUT_MX1TS is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL is not set
+# CONFIG_SERIAL_EXTENDED is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+CONFIG_AT91_SPIDEV=y
+
+#
+# Serial drivers
+#
+# CONFIG_SERIAL_ANAKIN is not set
+# CONFIG_SERIAL_ANAKIN_CONSOLE is not set
+# CONFIG_SERIAL_AMBA is not set
+# CONFIG_SERIAL_AMBA_CONSOLE is not set
+# CONFIG_SERIAL_CLPS711X is not set
+# CONFIG_SERIAL_CLPS711X_CONSOLE is not set
+# CONFIG_SERIAL_21285 is not set
+# CONFIG_SERIAL_21285_OLD is not set
+# CONFIG_SERIAL_21285_CONSOLE is not set
+# CONFIG_SERIAL_UART00 is not set
+# CONFIG_SERIAL_UART00_CONSOLE is not set
+# CONFIG_SERIAL_SA1100 is not set
+# CONFIG_SERIAL_SA1100_CONSOLE is not set
+# CONFIG_SERIAL_OMAHA is not set
+# CONFIG_SERIAL_OMAHA_CONSOLE is not set
+CONFIG_SERIAL_AT91=y
+CONFIG_SERIAL_AT91_CONSOLE=y
+# CONFIG_SERIAL_8250 is not set
+# CONFIG_SERIAL_8250_CONSOLE is not set
+# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250_MANY_PORTS is not set
+# CONFIG_SERIAL_8250_SHARE_IRQ is not set
+# CONFIG_SERIAL_8250_DETECT_IRQ is not set
+# CONFIG_SERIAL_8250_MULTIPORT is not set
+# CONFIG_SERIAL_8250_HUB6 is not set
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+# CONFIG_UNIX98_PTYS is not set
+
+#
+# I2C support
+#
+CONFIG_I2C=y
+# CONFIG_I2C_ALGOBIT is not set
+# CONFIG_SCx200_ACB is not set
+# CONFIG_I2C_ALGOPCF is not set
+CONFIG_I2C_AT91=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_I2C_PROC=y
+CONFIG_I2C_DS1307=y
+
+#
+# L3 serial bus support
+#
+# CONFIG_L3 is not set
+# CONFIG_L3_ALGOBIT is not set
+# CONFIG_L3_BIT_SA1100_GPIO is not set
+# CONFIG_L3_SA1111 is not set
+# CONFIG_BIT_SA1100_GPIO is not set
+
+#
+# Mice
+#
+# CONFIG_BUSMOUSE is not set
+# CONFIG_MOUSE is not set
+
+#
+# Joysticks
+#
+# CONFIG_INPUT_GAMEPORT is not set
+# CONFIG_QIC02_TAPE is not set
+# CONFIG_IPMI_HANDLER is not set
+# CONFIG_IPMI_PANIC_EVENT is not set
+# CONFIG_IPMI_DEVICE_INTERFACE is not set
+# CONFIG_IPMI_KCS is not set
+# CONFIG_IPMI_WATCHDOG is not set
+
+#
+# Watchdog Cards
+#
+CONFIG_WATCHDOG=y
+CONFIG_WATCHDOG_NOWAYOUT=y
+# CONFIG_ACQUIRE_WDT is not set
+# CONFIG_ADVANTECH_WDT is not set
+# CONFIG_ALIM1535_WDT is not set
+# CONFIG_ALIM7101_WDT is not set
+# CONFIG_SC520_WDT is not set
+# CONFIG_PCWATCHDOG is not set
+# CONFIG_21285_WATCHDOG is not set
+# CONFIG_977_WATCHDOG is not set
+# CONFIG_SA1100_WATCHDOG is not set
+# CONFIG_EPXA_WATCHDOG is not set
+# CONFIG_OMAHA_WATCHDOG is not set
+CONFIG_AT91_WATCHDOG=y
+# CONFIG_EUROTECH_WDT is not set
+# CONFIG_IB700_WDT is not set
+# CONFIG_WAFER_WDT is not set
+# CONFIG_I810_TCO is not set
+# CONFIG_MIXCOMWD is not set
+# CONFIG_60XX_WDT is not set
+# CONFIG_SC1200_WDT is not set
+# CONFIG_SCx200_WDT is not set
+# CONFIG_SOFT_WATCHDOG is not set
+# CONFIG_W83877F_WDT is not set
+# CONFIG_WDT is not set
+# CONFIG_WDTPCI is not set
+# CONFIG_MACHZ_WDT is not set
+# CONFIG_AMD7XX_TCO is not set
+# CONFIG_SCx200 is not set
+# CONFIG_SCx200_GPIO is not set
+# CONFIG_AMD_PM768 is not set
+# CONFIG_NVRAM is not set
+# CONFIG_RTC is not set
+CONFIG_AT91_RTC=y
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+# CONFIG_APPLICOM is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
+# CONFIG_AGP is not set
+
+#
+# Direct Rendering Manager (XFree86 DRI support)
+#
+# CONFIG_DRM is not set
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# File systems
+#
+# CONFIG_QUOTA is not set
+# CONFIG_QFMT_V2 is not set
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_REISERFS_CHECK is not set
+# CONFIG_REISERFS_PROC_INFO is not set
+# CONFIG_ADFS_FS is not set
+# CONFIG_ADFS_FS_RW is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BEFS_DEBUG is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_JBD is not set
+# CONFIG_JBD_DEBUG is not set
+# CONFIG_FAT_FS is not set
+# CONFIG_MSDOS_FS is not set
+# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_JFFS_FS is not set
+# CONFIG_JFFS2_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_TMPFS is not set
+CONFIG_RAMFS=y
+# CONFIG_ISO9660_FS is not set
+# CONFIG_JOLIET is not set
+# CONFIG_ZISOFS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_JFS_DEBUG is not set
+# CONFIG_JFS_STATISTICS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_NTFS_FS is not set
+# CONFIG_NTFS_RW is not set
+# CONFIG_HPFS_FS is not set
+CONFIG_PROC_FS=y
+CONFIG_DEVFS_FS=y
+CONFIG_DEVFS_MOUNT=y
+# CONFIG_DEVFS_DEBUG is not set
+# CONFIG_DEVPTS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_QNX4FS_RW is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_EXT2_FS=y
+# CONFIG_SYSV_FS is not set
+# CONFIG_UDF_FS is not set
+# CONFIG_UDF_RW is not set
+# CONFIG_UFS_FS is not set
+# CONFIG_UFS_FS_WRITE is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_XFS_QUOTA is not set
+# CONFIG_XFS_RT is not set
+# CONFIG_XFS_TRACE is not set
+# CONFIG_XFS_DEBUG is not set
+
+#
+# Network File Systems
+#
+# CONFIG_CODA_FS is not set
+# CONFIG_INTERMEZZO_FS is not set
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3=y
+# CONFIG_NFS_DIRECTIO is not set
+CONFIG_ROOT_NFS=y
+# CONFIG_NFSD is not set
+# CONFIG_NFSD_V3 is not set
+# CONFIG_NFSD_TCP is not set
+CONFIG_SUNRPC=y
+CONFIG_LOCKD=y
+CONFIG_LOCKD_V4=y
+# CONFIG_SMB_FS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_NCPFS_PACKET_SIGNING is not set
+# CONFIG_NCPFS_IOCTL_LOCKING is not set
+# CONFIG_NCPFS_STRONG is not set
+# CONFIG_NCPFS_NFS_NS is not set
+# CONFIG_NCPFS_OS2_NS is not set
+# CONFIG_NCPFS_SMALLDOS is not set
+# CONFIG_NCPFS_NLS is not set
+# CONFIG_NCPFS_EXTRAS is not set
+# CONFIG_ZISOFS_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+# CONFIG_SMB_NLS is not set
+# CONFIG_NLS is not set
+
+#
+# Multimedia Capabilities Port drivers
+#
+# CONFIG_MCP is not set
+# CONFIG_MCP_SA1100 is not set
+# CONFIG_MCP_UCB1200 is not set
+# CONFIG_MCP_UCB1200_AUDIO is not set
+# CONFIG_MCP_UCB1200_TS is not set
+
+#
+# USB support
+#
+# CONFIG_USB is not set
+
+#
+# Support for USB gadgets
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# Bluetooth support
+#
+# CONFIG_BLUEZ is not set
+
+#
+# Kernel hacking
+#
+CONFIG_FRAME_POINTER=y
+CONFIG_DEBUG_USER=y
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_NO_PGT_CACHE is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SLAB is not set
+# CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_WAITQ is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
+# CONFIG_DEBUG_ERRORS is not set
+CONFIG_DEBUG_LL=y
+# CONFIG_DEBUG_DC21285_PORT is not set
+# CONFIG_DEBUG_CLPS711X_UART2 is not set
+
+#
+# Library routines
+#
+CONFIG_CRC32=y
+# CONFIG_ZLIB_INFLATE is not set
+# CONFIG_ZLIB_DEFLATE is not set
diff -urN linux-2.4.26/arch/arm/fastfpe/CPDO.S linux-2.4.26-vrs1/arch/arm/fastfpe/CPDO.S
--- linux-2.4.26/arch/arm/fastfpe/CPDO.S 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/fastfpe/CPDO.S 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,682 @@
+/*
+The FP structure has 4 words reserved for each register, the first is used just
+for the sign in bit 31, the second and third are for the mantissa (unsigned
+integer, high 32 bit first) and the fourth is the exponent (signed integer).
+The mantissa is always normalized.
+
+If the exponent is 0x80000000, that is the most negative value, the number
+represented is 0 and both mantissa words are also 0.
+
+If the exponent is 0x7fffffff, that is the biggest positive value, the number
+represented is infinity if the high 32 mantissa bit are also 0, otherwise it is
+a NaN. The low 32 mantissa bit are 0 if the number represented is infinity.
+
+Decimal and packed decimal numbers are not supported yet.
+
+The parameters to these functions are r0=destination pointer, r1 and r2
+source pointers. r4 is the instruction. They may use r0-r8 and r14. They return
+to fastfpe_next, except CPDO_rnf_core which expects the return address in r14.
+*/
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_adf
+CPDO_adf:
+ ldmia r1,{r1,r3,r5,r7}
+ ldmia r2,{r2,r4,r6,r8}
+
+ cmp r7,#0x7fffffff
+ cmpne r8,#0x7fffffff
+ beq CPDO_adf_extra
+
+ cmp r1,r2
+ bne CPDO_suf_s
+
+CPDO_adf_s:
+ subs r2,r7,r8
+ bge CPDO_adf_2nd
+
+ mov r7,r8
+ rsb r2,r2,#0
+ cmp r2,#32
+ ble CPDO_adf_1st2
+
+ sub r2,r2,#32
+ cmp r2,#32
+ movgt r2,#32
+ mov r5,r3,lsr r2
+ mov r3,#0
+ b CPDO_adf_add
+
+CPDO_adf_1st2:
+ rsb r8,r2,#32
+ mov r5,r5,lsr r2
+ orr r5,r5,r3,lsl r8
+ mov r3,r3,lsr r2 @ 1. op normalized
+ b CPDO_adf_add
+
+CPDO_adf_2nd:
+ cmp r2,#32
+ ble CPDO_adf_2nd2
+
+ sub r2,r2,#32
+ cmp r2,#32
+ movgt r2,#32
+ mov r6,r4,lsr r2
+ mov r4,#0
+ b CPDO_adf_add
+
+CPDO_adf_2nd2:
+ rsb r8,r2,#32
+ mov r6,r6,lsr r2
+ orr r6,r6,r4,lsl r8
+ mov r4,r4,lsr r2 @ 2. op normalized
+
+CPDO_adf_add:
+ adds r5,r5,r6
+ adcs r3,r3,r4 @ do addition
+ bcc CPDO_adf_end
+
+ add r7,r7,#1
+ movs r3,r3,rrx
+ mov r5,r5,rrx @ correct for overflow
+
+CPDO_adf_end:
+ cmp r7,#0x20000000
+ bge CPDO_inf
+
+ stmia r0,{r1,r3,r5,r7}
+ b fastfpe_next
+
+CPDO_adf_extra:
+ cmp r7,#0x7fffffff @ was it the 1st ?
+ bne CPDO_infnan_2 @ no it was the 2nd
+ cmp r8,#0x7fffffff @ if 1st, 2nd too ?
+ bne CPDO_infnan_1 @ no only 1st
+ cmp r3,#0
+ cmpeq r4,#0
+ bne CPDO_nan_12
+ b CPDO_inf
+
+/*---------------------------------------------------------------------------*/
+
+CPDO_infnan_1:
+ stmia r0,{r1,r3,r5,r7}
+ b fastfpe_next
+
+CPDO_infnan_2:
+ stmia r0,{r2,r4,r6,r8}
+ b fastfpe_next
+
+CPDO_nan_12:
+ orr r2,r3,r4
+ b CPDO_inf_1
+
+CPDO_nan:
+ mov r2,#0x40000000 @ create non signalling NaN
+ b CPDO_inf_1
+
+CPDO_inf:
+ mov r2,#0
+CPDO_inf_1:
+ mov r3,#0
+ mov r4,#0x7fffffff
+CPDO_store_1234:
+ stmia r0,{r1,r2,r3,r4}
+ b fastfpe_next
+
+CPDO_zero:
+ mov r1,#0
+CPDO_zero_1:
+ mov r2,#0
+ mov r3,#0
+ mov r4,#0x80000000
+ stmia r0,{r1,r2,r3,r4}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_suf
+CPDO_suf:
+ ldmia r1,{r1,r3,r5,r7}
+ ldmia r2,{r2,r4,r6,r8}
+
+CPDO_suf_l:
+ cmp r7,#0x7fffffff
+ cmpne r8,#0x7fffffff
+ beq CPDO_suf_extra
+
+ cmp r1,r2
+ bne CPDO_adf_s
+
+CPDO_suf_s:
+ subs r2,r7,r8 @ determine greater number
+ bgt CPDO_suf_2nd @ first number is greater
+ blt CPDO_suf_1st @ second number is greater
+ cmp r3,r4 @ also mantissa is important
+ cmpeq r5,r6
+ bhi CPDO_suf_2nd @ first number is greater
+ beq CPDO_zero
+
+CPDO_suf_1st:
+ eor r1,r1,#0x80000000 @ second number is greater, invert sign
+ mov r7,r8
+ rsb r2,r2,#0
+ cmp r2,#32
+ ble CPDO_suf_1st2
+
+ sub r2,r2,#32
+ cmp r2,#32
+ movgt r2,#32
+ mov r5,r3,lsr r2
+ mov r3,#0
+ b CPDO_suf_1st_sub
+
+CPDO_suf_1st2:
+ rsb r8,r2,#32
+ mov r5,r5,lsr r2
+ orr r5,r5,r3,lsl r8
+ mov r3,r3,lsr r2 @ 1. op normalized
+
+CPDO_suf_1st_sub:
+ subs r5,r6,r5 @ do subtraction
+ sbc r3,r4,r3
+ b CPDO_suf_norm
+
+CPDO_suf_2nd:
+ cmp r2,#32
+ ble CPDO_suf_2nd2
+
+ sub r2,r2,#32
+ cmp r2,#32
+ movgt r2,#32
+ mov r6,r4,lsr r2
+ mov r4,#0
+ b CPDO_suf_2nd_sub
+
+CPDO_suf_2nd2:
+ rsb r8,r2,#32
+ mov r6,r6,lsr r2
+ orr r6,r6,r4,lsl r8
+ mov r4,r4,lsr r2 @ 2. op normalized
+
+CPDO_suf_2nd_sub:
+ subs r5,r5,r6
+ sbc r3,r3,r4 @ do subtraction
+
+CPDO_suf_norm:
+ teq r3,#0 @ normalize 32bit
+ moveq r3,r5
+ moveq r5,#0
+ subeq r7,r7,#32
+
+ cmp r3,#0x00010000 @ 16bit
+ movcc r3,r3,lsl#16
+ orrcc r3,r3,r5,lsr#16
+ movcc r5,r5,lsl#16
+ subcc r7,r7,#16
+
+ cmp r3,#0x01000000 @ 8bit
+ movcc r3,r3,lsl#8
+ orrcc r3,r3,r5,lsr#24
+ movcc r5,r5,lsl#8
+ subcc r7,r7,#8
+
+ cmp r3,#0x10000000 @ 4bit
+ movcc r3,r3,lsl#4
+ orrcc r3,r3,r5,lsr#28
+ movcc r5,r5,lsl#4
+ subcc r7,r7,#4
+
+ cmp r3,#0x40000000 @ 2bit
+ movcc r3,r3,lsl#2
+ orrcc r3,r3,r5,lsr#30
+ movcc r5,r5,lsl#2
+ subcc r7,r7,#2
+
+ cmp r3,#0x80000000 @ 1bit
+ movcc r3,r3,lsl#1
+ orrcc r3,r3,r5,lsr#31
+ movcc r5,r5,lsl#1
+ subcc r7,r7,#1
+
+ cmp r7,#0xe0000000
+ ble CPDO_zero_1
+
+ stmia r0,{r1,r3,r5,r7}
+ b fastfpe_next
+
+CPDO_suf_extra:
+ cmp r7,#0x7fffffff @ was it the 1st ?
+ eorne r2,r2,#0x80000000 @ change sign, might have been INF
+ bne CPDO_infnan_2 @ no it was the 2nd
+ cmp r8,#0x7fffffff @ if 1st, 2nd too ?
+ bne CPDO_infnan_1 @ no only 1st
+ cmp r3,#0
+ cmpeq r4,#0
+ bne CPDO_nan_12
+ b CPDO_nan @ here is difference with adf !
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_rsf
+CPDO_rsf:
+ mov r3,r2
+ ldmia r1,{r2,r4,r6,r8}
+ ldmia r3,{r1,r3,r5,r7}
+ b CPDO_suf_l
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_muf
+CPDO_muf:
+ ldmia r1,{r1,r3,r5,r7}
+ ldmia r2,{r2,r4,r6,r8}
+
+ cmp r7,#0x7fffffff
+ cmpne r8,#0x7fffffff
+ beq CPDO_muf_extra
+
+ eor r1,r1,r2
+ adds r8,r7,r8
+ bvs CPDO_zero_1
+
+ umull r7,r2,r3,r4
+ umull r14,r3,r6,r3
+ adds r7,r7,r3 @ r2|r7|r14 = r2|r7|#0 + #0|r3|r14
+ adc r2,r2,#0
+ umull r4,r3,r5,r4
+ adds r14,r14,r4 @ r2|r7|r14 += #0|r3|r4
+ adcs r7,r7,r3
+ adc r2,r2,#0
+ umull r4,r3,r5,r6
+ adds r14,r14,r3 @ r2|r7|r14 += #0|#0|r3
+ adcs r7,r7,#0
+ adcs r2,r2,#0
+
+ bpl CPDO_muf_norm
+
+ add r8,r8,#1
+ b CPDO_muf_end
+
+CPDO_muf_norm:
+ adds r14,r14,r14
+ adcs r7,r7,r7
+ adcs r2,r2,r2
+
+CPDO_muf_end:
+ cmp r8,#0x20000000
+ bge CPDO_inf
+ cmp r8,#0xe0000000
+ ble CPDO_zero_1
+ stmia r0,{r1,r2,r7,r8}
+ b fastfpe_next
+
+CPDO_muf_extra:
+ cmp r7,#0x7fffffff @ was it the first?
+ bne CPDO_muf_extra_2nd @ no, so it was the second
+ cmp r8,#0x7fffffff @ yes, second too?
+ bne CPDO_muf_extra_1st @ no, only first
+ orr r3,r3,r4 @ if both inf -> inf, otherwise nan
+ eor r1,r1,r2 @ sign for the inf case
+ b CPDO_infnan_1
+
+CPDO_muf_extra_1st:
+ cmp r3,#0 @ is it a nan?
+ bne CPDO_infnan_1
+ cmp r8,#0x80000000 @ is the second 0?
+ beq CPDO_nan
+ eor r1,r1,r2 @ correct sign for inf
+ b CPDO_inf
+
+CPDO_muf_extra_2nd:
+ cmp r4,#0 @ is it a nan?
+ bne CPDO_infnan_2
+ cmp r7,#0x80000000 @ is the first 0?
+ beq CPDO_nan
+ eor r1,r1,r2 @ correct sign for inf
+ b CPDO_inf
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_dvf
+CPDO_dvf:
+ ldmia r1,{r1,r3,r5,r7}
+ ldmia r2,{r2,r4,r6,r8}
+
+CPDO_dvf_l:
+ cmp r7,#0x7fffffff
+ cmpne r8,#0x7fffffff
+ beq CPDO_dvf_extra
+ cmp r8,#0x80000000
+ beq CPDO_dvf_by0
+
+ eor r1,r1,r2
+ cmp r7,#0x80000000
+ beq CPDO_zero_1
+
+ sub r8,r7,r8
+
+ mov r2,#0
+ mov r7,#1
+
+ cmp r3,r4
+ cmpeq r5,r6
+ bcs CPDO_dvf_loop_
+
+ sub r8,r8,#1
+
+CPDO_dvf_loop:
+ adds r5,r5,r5
+ adcs r3,r3,r3
+ bcs CPDO_dvf_anyway
+CPDO_dvf_loop_:
+ subs r5,r5,r6
+ sbcs r3,r3,r4
+ bcs CPDO_dvf_okay
+
+ adds r5,r5,r6
+ adc r3,r3,r4
+ adds r7,r7,r7
+ adcs r2,r2,r2
+ bcc CPDO_dvf_loop
+ b CPDO_dvf_end
+
+CPDO_dvf_anyway:
+ adcs r7,r7,r7
+ adcs r2,r2,r2
+ bcs CPDO_dvf_end
+ subs r5,r5,r6
+ sbc r3,r3,r4
+ b CPDO_dvf_loop
+
+CPDO_dvf_okay:
+ adcs r7,r7,r7
+ adcs r2,r2,r2
+ bcc CPDO_dvf_loop
+
+CPDO_dvf_end:
+ b CPDO_muf_end
+
+CPDO_dvf_by0:
+ cmp R7,#0x80000000
+ beq CPDO_nan @ first also 0 -> nan
+ eor r1,r1,r2 @ otherwise calculatesign for inf
+ b CPDO_inf
+
+CPDO_dvf_extra:
+ cmp r7,#0x7fffffff @ was it the first?
+ bne CPDO_dvf_extra_2nd @ no, so it was the second
+ cmp r8,#0x7fffffff @ yes, second too?
+ bne CPDO_dvf_extra_1st @ no, only first
+ orrs r3,r3,r4
+ beq CPDO_nan @ if both inf -> create nan
+ b CPDO_nan_12 @ otherwise keep nan
+
+CPDO_dvf_extra_1st:
+ eor r1,r1,r2 @ correct sign for inf
+ b CPDO_infnan_1
+
+CPDO_dvf_extra_2nd:
+ cmp r4,#0 @ is it a nan?
+ bne CPDO_infnan_2
+ eor r1,r1,r2 @ correct sign for zero
+ b CPDO_zero_1
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_rdf
+CPDO_rdf:
+ mov r3,r2
+ ldmia r1,{r2,r4,r6,r8}
+ ldmia r3,{r1,r3,r5,r7}
+ b CPDO_dvf_l
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_rmf
+CPDO_rmf:
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_mvf
+CPDO_mvf:
+ ldmia r2,{r1,r2,r3,r4}
+ stmia r0,{r1,r2,r3,r4}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_mnf
+CPDO_mnf:
+ ldmia r2,{r1,r2,r3,r4}
+ eor r1,r1,#0x80000000
+ stmia r0,{r1,r2,r3,r4}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_abs
+CPDO_abs:
+ ldmia r2,{r1,r2,r3,r4}
+ bic r1,r1,#0x80000000
+ stmia r0,{r1,r2,r3,r4}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_sqt
+CPDO_sqt:
+ ldmia r2,{r1,r2,r3,r4}
+ cmp r1,#0
+ bne CPDO_nan
+ cmp r4,#0x7fffffff
+ beq CPDO_store_1234
+
+ tst r4,r4,lsr#1 @carry=exponent bit 0
+ bcc CPDO_sqt_exponenteven
+ adds r3,r3,r3
+ adcs r2,r2,r2 @carry is needed in loop!
+CPDO_sqt_exponenteven:
+ mov r4,r4,asr #1
+ str r4,[r0,#12]
+
+ mov r4,#0x80000000
+ mov r5,#0
+ sub r2,r2,#0x80000000
+
+ mov r8,#0x40000000
+ mov r14,#0x80000000
+
+ mov r1,#1
+ b CPDO_sqt_loop1_first
+CPDO_sqt_loop1:
+ adds r3,r3,r3
+ adcs r2,r2,r2
+CPDO_sqt_loop1_first:
+ add r6,r4,r8,lsr r1 @r7 const = r5
+ bcs CPDO_sqt_loop1_1
+ cmp r2,r6
+ cmpeq r3,r5 @r5 for r7
+ bcc CPDO_sqt_loop1_0
+CPDO_sqt_loop1_1:
+ orr r4,r4,r14,lsr r1
+ subs r3,r3,r5 @r5 for r7
+ sbc r2,r2,r6
+CPDO_sqt_loop1_0:
+ add r1,r1,#1
+ cmp r1,#30
+ ble CPDO_sqt_loop1
+
+ adds r3,r3,r3
+ adcs r2,r2,r2
+ bcs CPDO_sqt_between_1
+ adds r7,r5,#0x80000000
+ adc r6,r4,#0
+ cmp r2,r6
+ cmpeq r3,r7
+ bcc CPDO_sqt_between_0
+CPDO_sqt_between_1:
+ orr r4,r4,#0x00000001
+ subs r3,r3,r5
+ sbc r2,r2,r4
+ subs r3,r3,#0x80000000
+ sbc r2,r2,#0
+CPDO_sqt_between_0:
+ mov r1,#0
+
+CPDO_sqt_loop2:
+ adds r3,r3,r3
+ adcs r2,r2,r2
+ bcs CPDO_sqt_loop2_1
+ adds r7,r5,r8,lsr r1
+ adc r6,r4,#0
+ cmp r2,r6
+ cmpeq r3,r7
+ bcc CPDO_sqt_loop2_0
+CPDO_sqt_loop2_1:
+ orr r5,r5,r14,lsr r1
+ subs r3,r3,r5
+ sbc r2,r2,r4
+ subs r3,r3,r8,lsr r1
+ sbc r2,r2,#0
+CPDO_sqt_loop2_0:
+ add r1,r1,#1
+ cmp r1,#30
+ ble CPDO_sqt_loop2
+
+ adds r3,r3,r3
+ adcs r2,r2,r2
+ bcs CPDO_sqt_after_1
+ cmp r2,r6
+ cmpeq r3,r7
+ bcc CPDO_sqt_after_0
+CPDO_sqt_after_1:
+ orr r5,r5,#0x00000001
+CPDO_sqt_after_0:
+
+ mov r1,#0
+ stmia r0,{r1,r4,r5}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_rnd
+CPDO_rnd:
+ ldmia r2,{r1,r2,r3,r5}
+ bl CPDO_rnd_core
+
+CPDO_rnd_store:
+ stmia r0,{r1,r2,r3,r5}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDO_rnd_core
+CPDO_rnd_core:
+ and r4,r4,#0x00000060
+ add pc,pc,r4,lsr#3
+ mov r0,r0
+ b CPDO_rnd_N
+ b CPDO_rnd_P
+ b CPDO_rnd_M
+ b CPDO_rnd_Z
+
+CPDO_rnd_N:
+ cmp r5,#-1
+ blt CPDO_rnd_zero
+ cmp r5,#63
+ movge pc,r14
+ mov r4,#0x40000000
+ cmp r5,#31
+ bge CPDO_rnd_N_2
+
+ adds r2,r2,r4,lsr r5
+ bcc CPDO_rnd_end
+ b CPDO_rnd_end_norm
+
+CPDO_rnd_N_2:
+CPDO_rnd_P_2:
+ sub r6,r5,#32
+ adds r3,r3,r4,ror r6 @ror ist needed to handle a -1 correctly
+ adcs r2,r2,#0
+ bcc CPDO_rnd_end
+ b CPDO_rnd_end_norm
+
+CPDO_rnd_P:
+ tst r1,#0x80000000
+ bne CPDO_rnd_M_entry
+CPDO_rnd_P_entry:
+ cmp r5,#0
+ blt CPDO_rnd_P_small
+ cmp r5,#63
+ movge pc,r14
+ mov r4,#0x7fffffff
+ cmp r5,#32
+ bge CPDO_rnd_P_2
+
+ adds r3,r3,#0xffffffff
+ adcs r2,r2,r4,lsr r5
+ bcc CPDO_rnd_end
+ b CPDO_rnd_end_norm
+
+CPDO_rnd_P_small:
+ cmp r5,#0x80000000
+ moveq pc,r14
+ b CPDO_rnd_one
+
+CPDO_rnd_M:
+ tst r1,#0x80000000
+ bne CPDO_rnd_P_entry
+CPDO_rnd_M_entry:
+ cmp r5,#0
+ blt CPDO_rnd_zero
+ cmp r5,#63
+ movge pc,r14
+
+ b CPDO_rnd_end
+
+CPDO_rnd_Z:
+ cmp r5,#0
+ blt CPDO_rnd_zero
+ cmp r5,#63
+ movge pc,r14
+ b CPDO_rnd_end
+
+CPDO_rnd_end_norm:
+ add r5,r5,#1
+ movs r2,r2,rrx
+ mov r3,r3,rrx
+CPDO_rnd_end:
+ rsbs r4,r5,#31
+ bmi CPDO_rnd_end_2
+ mov r3,#0
+ mov r2,r2,lsr r4
+ mov r2,r2,lsl r4
+ mov pc,r14
+
+CPDO_rnd_end_2:
+ rsb r4,r5,#63
+ mov r3,r3,lsr r4
+ mov r3,r3,lsl r4
+ mov pc,r14
+
+CPDO_rnd_one:
+ mov r2,#0x80000000
+ mov r3,#0
+ mov r5,#0
+ mov pc,r14
+
+CPDO_rnd_zero:
+ mov r1,#0
+ mov r2,#0
+ mov r3,#0
+ mov r5,#0x80000000
+ mov pc,r14
+
+/*---------------------------------------------------------------------------*/
diff -urN linux-2.4.26/arch/arm/fastfpe/CPDT.S linux-2.4.26-vrs1/arch/arm/fastfpe/CPDT.S
--- linux-2.4.26/arch/arm/fastfpe/CPDT.S 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/fastfpe/CPDT.S 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,430 @@
+/*
+The FP structure has 4 words reserved for each register, the first is used just
+for the sign in bit 31, the second and third are for the mantissa (unsigned
+integer, high 32 bit first) and the fourth is the exponent (signed integer).
+The mantissa is always normalized.
+
+If the exponent is 0x80000000, that is the most negative value, the number
+represented is 0 and both mantissa words are also 0.
+
+If the exponent is 0x7fffffff, that is the biggest positive value, the number
+represented is infinity if the high 32 mantissa bit are also 0, otherwise it is
+a NaN. The low 32 mantissa bit are 0 if the number represented is infinity.
+
+Decimal and packed decimal numbers are not supported yet.
+*/
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_load_single
+CPDT_load_single:
+ ldr r1,[r6]
+
+ and r2,r1,#0x80000000 @ r2 = sign
+
+ mov r5,r1,lsr#23
+ bics r5,r5,#0x100
+ beq CPDT_ls_e0 @ exponent = 0; zero/denormalized
+ teq r5,#255
+ beq CPDT_ls_e255 @ exponent = 255; infinity/NaN
+
+ sub r5,r5,#127 @ r5 = exponent, remove normalized bias
+
+ mov r3,r1,lsl#8
+ orr r3,r3,#0x80000000
+ mov r4,#0 @ r3,r4 = mantissa
+
+ stmia r0,{r2-r5}
+ b fastfpe_next
+
+CPDT_ls_e0:
+ movs r3,r1,lsl#9
+ beq CPDT_load_zero
+
+ mov r5,#-127
+
+CPDT_ls_e0_norm:
+ tst r3,#0x80000000
+ subeq r5,r5,#1
+ moveq r3,r3,lsl#1
+ beq CPDT_ls_e0_norm
+
+ mov r4,#0
+ stmia r0,{r2-r5}
+ b fastfpe_next
+
+CPDT_ls_e255:
+ mov r3,r1,lsl#9
+ mov r4,#0
+ mov r5,#0x7fffffff
+ stmia r0,{r2-r5}
+ b fastfpe_next
+
+CPDT_load_zero:
+ mov r3,#0
+ mov r4,#0
+ mov r5,#0x80000000
+ stmia r0,{r2-r5}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_load_double
+CPDT_load_double:
+ ldr r1,[r6]
+ ldr r6,[r6,#4]
+
+ and r2,r1,#0x80000000 @ r2 = sign
+
+ mov r5,r1,lsr#20
+ bics r5,r5,#0x800
+ beq CPDT_ld_e0 @ exponent = 0; zero/denormalized
+ add r4,r5,#1
+ teq r4,#2048
+ beq CPDT_ld_e2047 @ exponent = 2047; infinity/NaN
+
+ add r5,r5,#1
+ sub r5,r5,#1024 @ r5 = exponent, remove normalized bias
+
+ mov r3,r1,lsl#11
+ orr r3,r3,#0x80000000
+ orr r3,r3,r6,lsr #21
+ mov r4,r6,lsl#11 @ r3,r4 = mantissa
+
+ stmia r0,{r2-r5}
+ b fastfpe_next
+
+CPDT_ld_e0:
+ mov r3,r1,lsl#12
+ orr r3,r3,r6,lsr#20
+ movs r4,r6,lsl#12
+ teqeq r3,#0
+ beq CPDT_load_zero
+
+ mov r5,#1
+ sub r5,r5,#1024
+
+CPDT_ld_e0_norm:
+ tst r3,#0x80000000
+ subeq r5,r5,#1
+ moveqs r4,r4,lsl#1
+ adceq r3,r3,r3
+ beq CPDT_ld_e0_norm
+
+ stmia r0,{r2-r5}
+ b fastfpe_next
+
+CPDT_ld_e2047:
+ mov r3,r1,lsl#12
+ orr r3,r3,r6,lsr#1
+ bic r6,r6,#0x80000000
+ orr r3,r3,r6 @ to get all fraction bits !
+ mov r4,#0
+ mov r5,#0x7fffffff
+ stmia r0,{r2-r5}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_load_extended
+CPDT_load_extended:
+ ldr r1,[r6]
+ ldr r3,[r6,#4]
+ ldr r4,[r6,#8]
+
+ and r2,r1,#0x80000000
+ bics r5,r1,#0x80000000
+ beq CPDT_le_e0
+ add r1,r5,#1
+ teq r4,#32768
+ beq CPDT_le_e32767
+
+ add r5,r5,#1
+ sub r5,r5,#16384
+
+ stmia r0,{r2-r5}
+ b fastfpe_next
+
+CPDT_le_e0:
+ teq r3,#0
+ teqeq r4,#0
+ beq CPDT_load_zero
+
+ mov r5,#2
+ sub r5,r5,#16384
+ b CPDT_ld_e0_norm
+
+CPDT_le_e32767:
+ mov r3,r3,lsl#1
+ orr r3,r3,r4,lsr#1
+ bic r4,r4,#0x80000000
+ orr r3,r3,r4
+ mov r5,#0x7fffffff
+ stmia r0,{r2-r5}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_load_decimal
+CPDT_load_decimal:
+
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_store_single
+CPDT_store_single:
+ ldmia r0,{r1-r4}
+
+ cmp r4,#-127
+ ble CPDT_ss_e0
+ cmp r4,#128
+ bge CPDT_ss_e255
+
+ adds r2,r2,#1<<7 @ round to nearest
+ bcs CPDT_ss_rnd_ovfl @ very very seldom taken
+
+CPDT_ss_store:
+ add r4,r4,#127
+ orr r1,r1,r4,lsl#23
+
+ bic r2,r2,#0x80000000
+ orr r1,r1,r2,lsr#8
+
+ str r1,[r6]
+ b fastfpe_next
+
+CPDT_ss_rnd_ovfl:
+ add r4,r4,#1
+ cmp r4,#128
+ bge CPDT_ss_e255
+
+ mov r2,#0x80000000
+ mov r3,#0
+ b CPDT_ss_store
+
+CPDT_ss_e0:
+ cmp r4,#-150
+ ble CPDT_ss_zero
+
+ add r4,r4,#126
+CPDT_ss_unnormalize:
+ mov r2,r2,lsr#1
+ adds r4,r4,#1
+ bne CPDT_ss_unnormalize
+
+ orr r1,r1,r2,lsr#8
+
+CPDT_ss_zero:
+ str r1,[r6]
+ b fastfpe_next
+
+CPDT_ss_e255:
+ cmp r4,#0x7fffffff
+ bne CPDT_ss_inf
+ cmp r2,#0
+ beq CPDT_ss_inf
+
+ orr r1,r1,#0x00200000 @ for safety so that it is not INF
+ orr r1,r1,r2,lsr#9 @ get highest bit of mantissa
+
+CPDT_ss_inf:
+ orr r1,r1,#0x7f000000
+ orr r1,r1,#0x00800000
+ str r1,[r6]
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_store_double
+CPDT_store_double:
+ ldmia r0,{r1-r4}
+
+ cmp r4,#1024 @ this check has to be first, or
+ bge CPDT_sd_e2047 @ overflow can occur on second !
+ add r0,r4,#3
+ cmp r0,#-1023+3 @ cmp with -1023
+ ble CPDT_sd_e0
+
+ adds r3,r3,#1<<10 @ round to nearest
+ adcs r2,r2,#0
+ bcs CPDT_sd_rnd_ovfl @ very very seldom taken
+
+CPDT_sd_store:
+ sub r4,r4,#1
+ add r4,r4,#1024
+ orr r1,r1,r4,lsl#20
+
+ bic r2,r2,#0x80000000
+ orr r1,r1,r2,lsr#11
+
+ mov r2,r2,lsl#21
+ orr r2,r2,r3,lsr#11
+
+ stmia r6,{r1,r2}
+ b fastfpe_next
+
+CPDT_sd_rnd_ovfl:
+ add r4,r4,#1
+ cmp r4,#1024
+ bge CPDT_sd_e2047
+
+ mov r2,#0x80000000
+ mov r3,#0
+ b CPDT_sd_store
+
+CPDT_sd_e0:
+ add r0,r4,#1075-1024
+ cmp r0,#-1024
+ ble CPDT_sd_zero
+
+ add r4,r4,#1024
+ sub r4,r4,#2
+CPDT_sd_unnormalize:
+ movs r2,r2,lsr#1
+ mov r3,r3,rrx
+ adds r4,r4,#1
+ bne CPDT_sd_unnormalize
+
+ orr r1,r1,r2,lsr#11
+ mov r2,r2,lsl#21
+ orr r2,r2,r3,lsr#11
+
+ stmia r6,{r1,r2}
+ b fastfpe_next
+
+CPDT_sd_zero:
+ mov r2,#0
+ stmia r6,{r1,r2}
+ b fastfpe_next
+
+CPDT_sd_e2047:
+ cmp r4,#0x7fffffff
+ bne CPDT_sd_inf
+ cmp r2,#0
+ beq CPDT_sd_inf
+
+ orr r1,r1,#0x00040000 @ for safety so that it is not INF
+ orr r1,r1,r2,lsr#12 @ get highest bit of mantissa
+
+CPDT_sd_inf:
+ orr r1,r1,#0x7f000000
+ orr r1,r1,#0x00f00000
+ stmia r6,{r1,r2}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_store_extended
+CPDT_store_extended:
+ ldmia r0,{r1-r4}
+
+ cmp r4,#16384 @ this check has to be first, or
+ bge CPDT_se_e32767 @ overflow can occur with second !
+ add r0,r4,#63
+ cmp r0,#-16383+63
+ ble CPDT_se_e0
+
+ sub r4,r4,#1
+ add r4,r4,#16384
+ orr r1,r1,r4
+
+ stmia r6,{r1-r3}
+ b fastfpe_next
+
+CPDT_se_e0:
+ add r0,r4,#16446-16384
+ cmp r0,#-16384
+ ble CPDT_se_zero
+
+ add r4,r4,#16384
+ sub r4,r4,#2
+CPDT_se_unnormalize:
+ movs r2,r2,lsr#1
+ mov r3,r3,rrx
+ adds r4,r4,#1
+ bne CPDT_se_unnormalize
+
+ stmia r6,{r1-r3}
+ b fastfpe_next
+
+CPDT_se_zero:
+ mov r2,#0
+ mov r3,#0
+ stmia r6,{r1-r3}
+ b fastfpe_next
+
+CPDT_se_e32767:
+ cmp r4,#0x7fffffff
+ bne CPDT_se_inf
+ cmp r2,#0
+ beq CPDT_se_inf
+
+ mov r2,r2,lsl#1
+ orr r2,r2,#0x20000000
+
+CPDT_se_inf:
+ orr r1,r1,#0x00007f00
+ orr r1,r1,#0x000000ff
+ stmia r6,{r1-r3}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_store_decimal
+CPDT_store_decimal:
+
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_sfm
+CPDT_sfm:
+ add r2,r10,r0,lsr#8
+ ldr r4,[r2,#0]
+ ldr r3,[r2,#4]
+ bic r3,r3,#0x80000000
+ orr r3,r3,r4
+ str r3,[r6],#4
+ ldr r3,[r2,#8]
+ str r3,[r6],#4
+ ldr r3,[r2,#12]
+ str r3,[r6],#4
+
+ add r0,r0,#1<<12
+ and r0,r0,#7<<12
+ subs r1,r1,#1
+ bne CPDT_sfm
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPDT_lfm
+CPDT_lfm:
+ add r2,r10,r0,lsr#8
+ ldr r4,[r6],#4
+ and r3,r4,#0x80000000
+ str r3,[r2,#0]
+ ldr r3,[r6],#4
+ str r3,[r2,#8]
+ ldr r3,[r6],#4
+ str r3,[r2,#12]
+
+ cmp r3,#0x80000000 @ does the exp indicate zero?
+ biceq r4,r4,#0x80000000 @ if so, indicate 'denormalized'
+ beq CPDT_lfm_storer4
+ cmp r3,#0x7fffffff @ does the exp indicate inf or NaN?
+ biceq r4,r4,#0x80000000 @ if so, indicate 'denormalized'
+ beq CPDT_lfm_storer4
+ orrne r4,r4,#0x80000000 @ otherwise, set normalized bit
+
+CPDT_lfm_storer4:
+ str r4,[r2,#4]
+
+ add r0,r0,#1<<12
+ and r0,r0,#7<<12
+ subs r1,r1,#1
+ bne CPDT_lfm
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
diff -urN linux-2.4.26/arch/arm/fastfpe/CPRT.S linux-2.4.26-vrs1/arch/arm/fastfpe/CPRT.S
--- linux-2.4.26/arch/arm/fastfpe/CPRT.S 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/fastfpe/CPRT.S 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,185 @@
+/*
+The FP structure has 4 words reserved for each register, the first is used
+just
+for the sign in bit 31, the second and third are for the mantissa (unsigned
+integer, high 32 bit first) and the fourth is the exponent (signed integer).
+The mantissa is always normalized.
+
+If the exponent is 0x80000000, that is the most negative value, the number
+represented is 0 and both mantissa words are also 0.
+
+If the exponent is 0x7fffffff, that is the biggest positive value, the
+number
+represented is infinity if the high 32 mantissa bit are also 0, otherwise it
+is
+a NaN. The low 32 mantissa bit are 0 if the number represented is infinity.
+
+Decimal and packed decimal numbers are not supported yet.
+*/
+
+/*---------------------------------------------------------------------------*/
+
+ .text
+ .globl CPRT_flt
+CPRT_flt:
+ add r0,r13,r0,lsr#10
+ ldr r2,[r0]
+ mov r3,#0
+ cmp r2,#0
+ beq CPRT_flt_zero
+
+ ands r0,r2,#0x80000000
+ rsbne r2,r2,#0
+ mov r4,#31
+
+ cmp r2,#0x00010000
+ movcc r2,r2,lsl#16
+ subcc r4,r4,#16
+
+ cmp r2,#0x01000000
+ movcc r2,r2,lsl#8
+ subcc r4,r4,#8
+
+ cmp r2,#0x10000000
+ movcc r2,r2,lsl#4
+ subcc r4,r4,#4
+
+ cmp r2,#0x40000000
+ movcc r2,r2,lsl#2
+ subcc r4,r4,#2
+
+ cmp r2,#0x80000000
+ movcc r2,r2,lsl#1
+ subcc r4,r4,#1
+
+ stmia r1,{r0,r2,r3,r4}
+ b fastfpe_next
+
+CPRT_flt_zero:
+ mov r0,#0
+ mov r4,#0x80000000
+ stmia r1,{r0,r2,r3,r4}
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPRT_fix
+CPRT_fix:
+ ldmia r2,{r1,r2,r3,r5}
+ bl CPDO_rnd_core
+
+CPRT_back:
+ add r0,r13,r0,lsr#10
+ cmp r5,#0
+ blt CPRT_int_zero
+ cmp r5,#30
+ bgt CPRT_overflow
+
+ rsb r5,r5,#31
+ mov r2,r2,lsr r5
+ tst r1,#0x80000000
+ rsbne r2,r2,#0
+
+ str r2,[r0]
+ b fastfpe_next
+
+CPRT_int_zero:
+ mov r2,#0
+ str r2,[r0]
+ b fastfpe_next
+
+CPRT_overflow:
+ mov r2,#0x80000000
+ tst r1,#0x80000000
+ subeq r2,r2,#1
+ str r2,[r0]
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPRT_wfs
+CPRT_wfs:
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPRT_rfs
+CPRT_rfs:
+ add r0,r13,r0,lsr#10
+ mov r1,#0x02000000 @ Software Emulation, not Acorn FPE
+ str r1,[r0]
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPRT_cmf
+CPRT_cmf:
+ ldmia r1,{r1,r3,r5,r7}
+ ldmia r2,{r2,r4,r6,r8}
+
+CPRT_cmf_e:
+ ldr r0,[r13,#16*4]
+
+ cmp r7,#0x7fffffff
+ bic r0,r0,#0xf0000000
+
+ cmpeq r3,#0xffffffff
+ beq CPRT_cmf_unordered
+ cmp r8,#0x7fffffff
+ cmpeq r4,#0xffffffff
+ beq CPRT_cmf_unordered
+
+ cmp r1,r2
+ beq CPRT_cmf_equalsign
+ b CPRT_cmf_sign
+
+CPRT_cmf_equalsign:
+ cmp r7,r8
+ beq CPRT_cmf_equalexponent
+ bgt CPRT_cmf_sign
+ b CPRT_cmf_signb
+
+CPRT_cmf_equalexponent:
+ cmp r3,r4
+ cmpeq r5,r6
+ beq CPRT_cmf_equal
+ bhi CPRT_cmf_sign
+ b CPRT_cmf_signb
+
+CPRT_cmf_sign:
+ cmp r7,#0x80000000 @ (0.0 == -0.0)?
+ cmpeq r7,r8
+ beq CPRT_cmf_equal
+ tst r1,#0x80000000
+ orreq r0,r0,#0x20000000
+ orrne r0,r0,#0x80000000
+ str r0,[r13,#16*4]
+ b fastfpe_next
+
+CPRT_cmf_signb:
+ tst r1,#0x80000000
+ orrne r0,r0,#0x20000000
+ orreq r0,r0,#0x80000000
+ str r0,[r13,#16*4]
+ b fastfpe_next
+
+CPRT_cmf_equal:
+ orr r0,r0,#0x60000000
+ str r0,[r13,#16*4]
+ b fastfpe_next
+
+CPRT_cmf_unordered:
+ orr r0,r0,#0x10000000
+ str r0,[r13,#16*4]
+ b fastfpe_next
+
+/*---------------------------------------------------------------------------*/
+
+ .globl CPRT_cnf
+CPRT_cnf:
+ ldmia r1,{r1,r3,r5,r7}
+ ldmia r2,{r2,r4,r6,r8}
+ eor r2,r2,#0x80000000
+ b CPRT_cmf_e
+
+/*---------------------------------------------------------------------------*/
diff -urN linux-2.4.26/arch/arm/fastfpe/Makefile linux-2.4.26-vrs1/arch/arm/fastfpe/Makefile
--- linux-2.4.26/arch/arm/fastfpe/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/fastfpe/Makefile 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,25 @@
+#
+# linux/arch/arm/fastfpe/Makefile
+#
+# Copyright (C) Peter Teichmann
+#
+
+O_TARGET := fast-math-emu.o
+
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+fastfpe-objs := module.o entry.o CPDO.o CPRT.o CPDT.o
+
+list-multi := fastfpe.o
+
+obj-$(CONFIG_FPE_FASTFPE) += fastfpe.o
+
+USE_STANDARD_AS_RULE := true
+
+include $(TOPDIR)/Rules.make
+
+fastfpe.o: $(fastfpe-objs)
+ $(LD) -r -o $@ $(fastfpe-objs)
diff -urN linux-2.4.26/arch/arm/fastfpe/entry.S linux-2.4.26-vrs1/arch/arm/fastfpe/entry.S
--- linux-2.4.26/arch/arm/fastfpe/entry.S 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/fastfpe/entry.S 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,295 @@
+/*
+At entry the registers contain the following information:
+
+r14 return address for undefined exception return
+r9 return address for return from exception
+r13 user registers on stack, offset 0 up to offset 4*15 contains
+ registers r0..15, then the psr
+r10 FP workspace 35 words (init, reg[8][4], fpsr, fpcr)
+
+*/
+
+/*---------------------------------------------------------------------------*/
+
+ .data
+fp_const:
+ .word 0, 0x00000000, 0, 0x80000000 @ 0
+ .word 0, 0x80000000, 0, 0 @ 1
+ .word 0, 0x80000000, 0, 1 @ 2
+ .word 0, 0xc0000000, 0, 1 @ 3
+ .word 0, 0x80000000, 0, 2 @ 4
+ .word 0, 0xa0000000, 0, 2 @ 5
+ .word 0, 0x80000000, 0, -1 @ 0.5
+ .word 0, 0xa0000000, 0, 3 @ 10
+fp_undef:
+ .word 0
+fp_cond:
+ .word 0xf0f0 @ eq
+ .word 0x0f0f @ ne
+ .word 0xcccc @ cs
+ .word 0x3333 @ cc
+ .word 0xff00 @ mi
+ .word 0x00ff @ pl
+ .word 0xaaaa @ vs
+ .word 0x5555 @ vc
+ .word 0x0c0c @ hi
+ .word 0xf3f3 @ ls
+ .word 0xaa55 @ ge
+ .word 0x55aa @ lt
+ .word 0x0a05 @ gt
+ .word 0xf5fa @ le
+ .word 0xffff @ al
+ .word 0x0000 @ nv
+
+/*---------------------------------------------------------------------------*/
+
+ .text
+ .globl fastfpe_enter
+fastfpe_enter:
+ ldr r4,=fp_undef
+ str r14,[r4] @ to free one register
+ add r10,r10,#4 @ to make the code simpler
+ ldr r4,[r13,#60] @ r4=saved PC
+ ldr r4,[r4,#-4] @ r4=trapped instruction
+ and r1,r4,#0x00000f00 @ r1=coprocessor << 8
+next_enter:
+ cmp r1,#1<<8 @ copro 1 ?
+ beq copro_1
+ cmp r1,#2<<8
+ movne pc,r14
+
+copro_2:
+ and r1,r4,#0x0f000000
+ cmp r1,#0x0c000000 @ CPDT with post indexing
+ cmpne r1,#0x0d000000 @ CPDT with pre indexing
+ beq CPDT_M_enter
+ mov pc,r14
+
+copro_1:
+ and r1,r4,#0x0f000000
+ cmp r1,#0x0e000000 @ CPDO
+ beq CPDO_CPRT_enter
+ cmp r1,#0x0c000000 @ CPDT with post indexing
+ cmpne r1,#0x0d000000 @ CPDT with pre indexing
+ beq CPDT_1_enter
+ mov pc,r14
+
+/*---------------------------------------------------------------------------*/
+
+ .globl fastfpe_next
+fastfpe_next:
+ ldr r5,[r13,#60]
+next_after_cond:
+__x1:
+ ldrt r4,[r5],#4
+
+ ldr r0,=fp_cond @ check condition of next instruction
+ ldr r1,[r13,#64] @ psr containing flags
+ mov r2,r4,lsr#28
+ mov r1,r1,lsr#28
+ ldr r0,[r0,r2,lsl#2]
+ mov r0,r0,lsr r1
+ tst r0,#1
+ beq next_after_cond @ must not necessarily have been an
+ @ FP instruction !
+ and r1,r4,#0x0f000000 @ Test for copro instruction
+ cmp r1,#0x0c000000
+ rsbgts r0,r1,#0x0e000000 @ cmpgt #0x0e000000,r1
+ movlt pc,r9 @ next is no copro instruction, return
+
+ ands r1,r4,#0x00000f00 @ r1 = coprocessor << 8
+ cmpne r1,#3<<8
+ movge pc,r9 @ copro = 0 or >=3, return
+
+ str r5,[r13,#60] @ save updated pc
+ b next_enter
+
+/*---------------------------------------------------------------------------*/
+
+undefined:
+ ldr r4,=fp_undef
+ ldr pc,[r4]
+
+/*---------------------------------------------------------------------------*/
+
+CPDT_1_enter:
+ and r5,r4,#0x000f0000 @ r5=base register number << 16
+ ldr r6,[r13,r5,lsr#14] @ r6=base address
+ cmp r5,#0x000f0000 @ base register = pc ?
+ addeq r6,r6,#4
+ and r7,r4,#0x000000ff @ r7=offset value
+
+ tst r4,#0x00800000 @ up or down?
+ addne r7,r6,r7,lsl#2
+ subeq r7,r6,r7,lsl#2 @ r6=base address +/- offset
+ tst r4,#0x01000000 @ preindexing ?
+ movne r6,r7
+ tst r4,#0x00200000 @ write back ?
+ cmpne r5,#0x000f0000 @ base register = pc ?
+ strne r7,[r13,r5,lsr#14]
+
+ and r0,r4,#0x00007000 @ r0=fp register number << 12
+ add r0,r10,r0,lsr#8 @ r0=address of fp register
+ mov r1,#0
+ tst r4,#0x00008000
+ orrne r1,r1,#1 @ T0
+ tst r4,#0x00400000
+ orrne r1,r1,#2 @ T1
+ tst r4,#0x00100000
+ orrne r1,r1,#4 @ L/S
+
+ add pc,pc,r1,lsl#2
+ mov r0,r0
+ b CPDT_store_single @ these functions get
+ b CPDT_store_double @ r0=address of fp register
+ b CPDT_store_extended @ r6=address of data
+ b undefined @ CPDT_store_decimal
+ b CPDT_load_single
+ b CPDT_load_double
+ b CPDT_load_extended
+ b undefined @ CPDT_load_decimal
+
+/*---------------------------------------------------------------------------*/
+
+CPDT_M_enter:
+ and r5,r4,#0x000f0000 @ r5=base register number << 16
+ ldr r6,[r13,r5,lsr#14] @ r6=base address
+ cmp r5,#0x000f0000 @ base register = pc ?
+ addeq r6,r6,#4
+ and r7,r4,#0x000000ff @ r7=offset value
+
+ tst r4,#0x00800000 @ up or down?
+ addne r7,r6,r7,lsl#2
+ subeq r7,r6,r7,lsl#2 @ r7=base address +/- offset
+ tst r4,#0x01000000 @ preindexing ?
+ movne r6,r7
+ tst r4,#0x00200000 @ write back ?
+ cmpne r5,#0x000f0000 @ base register = pc ?
+ strne r7,[r13,r5,lsr#14]
+
+ and r0,r4,#0x00007000 @ r0=fp register number << 12
+ and r1,r4,#0x00008000
+ mov r1,r1,lsr#15 @ N0
+ and r2,r4,#0x00400000
+ orrs r1,r1,r2,lsr#21 @ N1
+ addeq r1,r1,#4 @ r1=register count
+
+ tst r4,#0x00100000 @ load/store
+ beq CPDT_sfm
+ b CPDT_lfm
+
+/*---------------------------------------------------------------------------*/
+
+CPDO_CPRT_enter:
+ tst r4,#0x00000010
+ bne CPRT_enter
+
+ and r0,r4,#0x00007000
+ add r0,r10,r0,lsr#8 @ r0=address of Fd
+ and r1,r4,#0x00070000
+ add r1,r10,r1,lsr#12 @ r1=address of Fn
+ tst r4,#0x00000008
+ bne CPDO_const
+ and r2,r4,#0x00000007
+ add r2,r10,r2,lsl#4 @ r2=address of Fm
+
+CPDO_constback:
+ and r3,r4,#0x00f00000
+ tst r4,#0x00008000
+ orrne r3,r3,#0x01000000
+
+ add pc,pc,r3,lsr#18
+ mov r0,r0
+ b CPDO_adf
+ b CPDO_muf
+ b CPDO_suf
+ b CPDO_rsf
+ b CPDO_dvf
+ b CPDO_rdf
+ b undefined
+ b undefined
+ b undefined @ CPDO_rmf
+ b CPDO_muf
+ b CPDO_dvf
+ b CPDO_rdf
+ b undefined
+ b undefined
+ b undefined
+ b undefined
+ b CPDO_mvf
+ b CPDO_mnf
+ b CPDO_abs
+ b CPDO_rnd
+ b CPDO_sqt
+ b undefined
+ b undefined
+ b undefined
+ b undefined
+ b undefined
+ b undefined
+ b undefined
+ b undefined
+ b undefined
+ b CPDO_rnd
+ b fastfpe_next
+
+CPDO_const:
+ ldr r2,=fp_const
+ and r3,r4,#0x00000007
+ add r2,r2,r3,lsl#4
+ b CPDO_constback
+
+/*---------------------------------------------------------------------------*/
+
+CPRT_enter:
+ and r0,r4,#0x0000f000 @ r0=Rd<<12
+ and r1,r4,#0x00070000
+ add r1,r10,r1,lsr#12 @ r1=address of Fn
+ tst r4,#0x00000008
+ bne CPRT_const
+ and r2,r4,#0x00000007
+ add r2,r10,r2,lsl#4 @ r2=address of Fm
+
+CPRT_constback:
+ and r3,r4,#0x00f00000
+
+ add pc,pc,r3,lsr#18
+ mov r0,r0
+ b CPRT_flt
+ b CPRT_fix
+ b CPRT_wfs
+ b CPRT_rfs
+ b undefined
+ b undefined
+ b undefined
+ b undefined
+ b undefined
+ b CPRT_cmf
+ b undefined
+ b CPRT_cnf
+ b undefined
+ b CPRT_cmf
+ b undefined
+ b CPRT_cnf
+
+CPRT_const:
+ ldr r2,=fp_const
+ and r3,r4,#0x00000007
+ add r2,r2,r3,lsl#4
+ b CPRT_constback
+
+/*---------------------------------------------------------------------------*/
+
+ @ The fetch of the next instruction to emulate could fault
+
+ .section .fixup,"ax"
+ .align
+__f1:
+ mov pc,r9
+ .previous
+ .section __ex_table,"a"
+ .align 3
+ .long __x1,__f1
+ .previous
+
+/*---------------------------------------------------------------------------*/
diff -urN linux-2.4.26/arch/arm/fastfpe/module.c linux-2.4.26-vrs1/arch/arm/fastfpe/module.c
--- linux-2.4.26/arch/arm/fastfpe/module.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/fastfpe/module.c 2004-01-14 21:32:23.000000000 +0000
@@ -0,0 +1,78 @@
+/*
+ Fast Floating Point Emulator
+ (c) Peter Teichmann <mail@peter-teichmann.de>
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/init.h>
+
+#ifndef MODULE
+#define kern_fp_enter fp_enter
+
+extern char fpe_type[];
+#endif
+
+static void (*orig_fp_enter)(void); /* old kern_fp_enter value */
+extern void (*kern_fp_enter)(void); /* current FP handler */
+extern void fastfpe_enter(void); /* forward declarations */
+
+#ifdef MODULE
+/*
+ * Return 0 if we can be unloaded. This can only happen if
+ * kern_fp_enter is still pointing at fastfpe_enter
+ */
+static int fpe_unload(void)
+{
+ return (kern_fp_enter == fastfpe_enter) ? 0 : 1;
+}
+#endif
+
+static int __init fpe_init(void)
+{
+#ifdef MODULE
+ if (!mod_member_present(&__this_module, can_unload))
+ return -EINVAL;
+ __this_module.can_unload = fpe_unload;
+#else
+ if (fpe_type[0] && strcmp(fpe_type, "fastfpe"))
+ return 0;
+#endif
+
+ printk("Fast Floating Point Emulator V0.9 (c) Peter Teichmann.\n");
+
+ /* Save pointer to the old FP handler and then patch ourselves in */
+ orig_fp_enter = kern_fp_enter;
+ kern_fp_enter = fastfpe_enter;
+
+ return 0;
+}
+
+static void __exit fpe_exit(void)
+{
+ /* Restore the values we saved earlier. */
+ kern_fp_enter = orig_fp_enter;
+}
+
+module_init(fpe_init);
+module_exit(fpe_exit);
+
+MODULE_AUTHOR("Peter Teichmann <mail@peter-teichmann.de>");
+MODULE_DESCRIPTION("Fast floating point emulator with full precision");
diff -urN linux-2.4.26/arch/arm/kernel/calls.S linux-2.4.26-vrs1/arch/arm/kernel/calls.S
--- linux-2.4.26/arch/arm/kernel/calls.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/kernel/calls.S 2004-03-04 21:01:56.000000000 +0000
@@ -115,7 +115,7 @@
.long SYMBOL_NAME(sys_ni_syscall) /* was sys_profil */
.long SYMBOL_NAME(sys_statfs)
/* 100 */ .long SYMBOL_NAME(sys_fstatfs)
- .long SYMBOL_NAME(sys_ni_syscall)
+ .long SYMBOL_NAME(sys_ni_syscall) /* 101 was sys_ioperm */
.long SYMBOL_NAME(sys_socketcall)
.long SYMBOL_NAME(sys_syslog)
.long SYMBOL_NAME(sys_setitimer)
@@ -126,7 +126,7 @@
.long SYMBOL_NAME(sys_ni_syscall) /* was sys_uname */
/* 110 */ .long SYMBOL_NAME(sys_ni_syscall) /* was sys_iopl */
.long SYMBOL_NAME(sys_vhangup)
- .long SYMBOL_NAME(sys_ni_syscall)
+ .long SYMBOL_NAME(sys_ni_syscall) /* 112 was sys_idle */
.long SYMBOL_NAME(sys_syscall) /* call a syscall */
.long SYMBOL_NAME(sys_wait4)
/* 115 */ .long SYMBOL_NAME(sys_swapoff)
@@ -137,7 +137,7 @@
/* 120 */ .long SYMBOL_NAME(sys_clone_wapper)
.long SYMBOL_NAME(sys_setdomainname)
.long SYMBOL_NAME(sys_newuname)
- .long SYMBOL_NAME(sys_ni_syscall)
+ .long SYMBOL_NAME(sys_ni_syscall) /* 123 was sys_modify_ldt */
.long SYMBOL_NAME(sys_adjtimex)
/* 125 */ .long SYMBOL_NAME(sys_mprotect)
.long SYMBOL_NAME(sys_sigprocmask)
@@ -180,7 +180,7 @@
.long SYMBOL_NAME(sys_arm_mremap)
.long SYMBOL_NAME(sys_setresuid16)
/* 165 */ .long SYMBOL_NAME(sys_getresuid16)
- .long SYMBOL_NAME(sys_ni_syscall)
+ .long SYMBOL_NAME(sys_ni_syscall) /* 166 was sys_vm86 */
.long SYMBOL_NAME(sys_query_module)
.long SYMBOL_NAME(sys_poll)
.long SYMBOL_NAME(sys_nfsservctl)
diff -urN linux-2.4.26/arch/arm/kernel/dma-rpc.c linux-2.4.26-vrs1/arch/arm/kernel/dma-rpc.c
--- linux-2.4.26/arch/arm/kernel/dma-rpc.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/kernel/dma-rpc.c 2004-01-14 21:38:42.000000000 +0000
@@ -26,19 +26,6 @@
#include <asm/mach/dma.h>
#include <asm/hardware/iomd.h>
-#if 0
-typedef enum {
- dma_size_8 = 1,
- dma_size_16 = 2,
- dma_size_32 = 4,
- dma_size_128 = 16
-} dma_size_t;
-
-typedef struct {
- dma_size_t transfersize;
-} dma_t;
-#endif
-
#define TRANSFER_SIZE 2
#define CURA (0)
@@ -48,10 +35,6 @@
#define CR (IOMD_IO0CR - IOMD_IO0CURA)
#define ST (IOMD_IO0ST - IOMD_IO0CURA)
-#define state_prog_a 0
-#define state_wait_a 1
-#define state_wait_b 2
-
static void iomd_get_next_sg(struct scatterlist *sg, dma_t *dma)
{
unsigned long end, offset, flags = 0;
@@ -65,7 +48,7 @@
if (end > PAGE_SIZE)
end = PAGE_SIZE;
- if (offset + (int) TRANSFER_SIZE > end)
+ if (offset + TRANSFER_SIZE >= end)
flags |= DMA_END_L;
sg->length = end - TRANSFER_SIZE;
@@ -103,27 +86,31 @@
if (!(status & DMA_ST_INT))
return;
- if (status & DMA_ST_OFL && !dma->sg)
- break;
-
- iomd_get_next_sg(&dma->cur_sg, dma);
+ if ((dma->state ^ status) & DMA_ST_AB)
+ iomd_get_next_sg(&dma->cur_sg, dma);
switch (status & (DMA_ST_OFL | DMA_ST_AB)) {
case DMA_ST_OFL: /* OIA */
case DMA_ST_AB: /* .IB */
iomd_writel(dma->cur_sg.dma_address, base + CURA);
iomd_writel(dma->cur_sg.length, base + ENDA);
+ dma->state = DMA_ST_AB;
break;
case DMA_ST_OFL | DMA_ST_AB: /* OIB */
case 0: /* .IA */
iomd_writel(dma->cur_sg.dma_address, base + CURB);
iomd_writel(dma->cur_sg.length, base + ENDB);
+ dma->state = 0;
break;
}
+
+ if (status & DMA_ST_OFL &&
+ dma->cur_sg.length == (DMA_END_S|DMA_END_L))
+ break;
} while (1);
- iomd_writeb(0, base + CR);
+ dma->state = ~DMA_ST_AB;
disable_irq(irq);
}
@@ -158,6 +145,7 @@
}
iomd_writeb(DMA_CR_C, dma_base + CR);
+ dma->state = DMA_ST_AB;
}
if (dma->dma_mode == DMA_MODE_READ)
@@ -171,13 +159,11 @@
{
unsigned long dma_base = dma->dma_base;
unsigned long flags;
- unsigned int ctrl;
local_irq_save(flags);
- ctrl = iomd_readb(dma_base + CR);
- if (ctrl & DMA_CR_E)
+ if (dma->state != ~DMA_ST_AB)
disable_irq(dma->dma_irq);
- iomd_writeb(ctrl & ~DMA_CR_E, dma_base + CR);
+ iomd_writeb(0, dma_base + CR);
local_irq_restore(flags);
}
diff -urN linux-2.4.26/arch/arm/kernel/entry-armv.S linux-2.4.26-vrs1/arch/arm/kernel/entry-armv.S
--- linux-2.4.26/arch/arm/kernel/entry-armv.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/kernel/entry-armv.S 2004-01-14 21:32:24.000000000 +0000
@@ -677,12 +677,11 @@
mrs r9, cpsr @ Enable interrupts if they were
tst r3, #I_BIT
biceq r9, r9, #I_BIT @ previously
- mov r0, r2 @ *** remove once everyones in sync
/*
* This routine must not corrupt r9
*/
#ifdef MULTI_CPU
- ldr r4, .LCprocfns @ pass r0, r3 to
+ ldr r4, .LCprocfns @ pass r2, r3 to
mov lr, pc @ processor code
ldr pc, [r4] @ call processor specific code
#else
@@ -788,9 +787,8 @@
stmdb r5, {sp, lr}^
alignment_trap r7, r7, __temp_abt
zero_fp
- mov r0, r2 @ remove once everyones in sync
#ifdef MULTI_CPU
- ldr r4, .LCprocfns @ pass r0, r3 to
+ ldr r4, .LCprocfns @ pass r2, r3 to
mov lr, pc @ processor code
ldr pc, [r4] @ call processor specific code
#else
@@ -840,7 +838,8 @@
adrsvc al, r9, ret_from_exception @ r9 = normal FP return
adrsvc al, lr, fpundefinstr @ lr = undefined instr return
-call_fpe: get_current_task r10
+call_fpe: enable_irq r10
+ get_current_task r10
mov r8, #1
strb r8, [r10, #TSK_USED_MATH] @ set current->used_math
ldr r4, .LCfp
diff -urN linux-2.4.26/arch/arm/kernel/fiq.c linux-2.4.26-vrs1/arch/arm/kernel/fiq.c
--- linux-2.4.26/arch/arm/kernel/fiq.c 2003-06-13 15:51:29.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/kernel/fiq.c 2004-04-09 19:55:21.000000000 +0100
@@ -122,23 +122,23 @@
register unsigned long tmp, tmp2;
__asm__ volatile (
#ifdef CONFIG_CPU_26
- "mov %0, pc
- bic %1, %0, #0x3
- orr %1, %1, %3
- teqp %1, #0 @ select FIQ mode
- mov r0, r0
- ldmia %2, {r8 - r14}
- teqp %0, #0 @ return to SVC mode
- mov r0, r0"
+ "mov %0, pc \n"
+ "bic %1, %0, #0x3 \n"
+ "orr %1, %1, %3 \n"
+ "teqp %1, #0 @ select FIQ mode \n"
+ "mov r0, r0 \n"
+ "ldmia %2, {r8 - r14} \n"
+ "teqp %0, #0 @ return to SVC mode \n"
+ "mov r0, r0 \n"
#endif
#ifdef CONFIG_CPU_32
- "mrs %0, cpsr
- mov %1, %3
- msr cpsr_c, %1 @ select FIQ mode
- mov r0, r0
- ldmia %2, {r8 - r14}
- msr cpsr_c, %0 @ return to SVC mode
- mov r0, r0"
+ "mrs %0, cpsr \n"
+ "mov %1, %3 \n"
+ "msr cpsr_c, %1 @ select FIQ mode \n"
+ "mov r0, r0 \n"
+ "ldmia %2, {r8 - r14} \n"
+ "msr cpsr_c, %0 @ return to SVC mode \n"
+ "mov r0, r0 \n"
#endif
: "=&r" (tmp), "=&r" (tmp2)
: "r" (®s->ARM_r8), "I" (I_BIT | F_BIT | FIQ_MODE)
@@ -154,23 +154,23 @@
register unsigned long tmp, tmp2;
__asm__ volatile (
#ifdef CONFIG_CPU_26
- "mov %0, pc
- bic %1, %0, #0x3
- orr %1, %1, %3
- teqp %1, #0 @ select FIQ mode
- mov r0, r0
- stmia %2, {r8 - r14}
- teqp %0, #0 @ return to SVC mode
- mov r0, r0"
+ "mov %0, pc \n"
+ "bic %1, %0, #0x3 \n"
+ "orr %1, %1, %3 \n"
+ "teqp %1, #0 @ select FIQ mode \n"
+ "mov r0, r0 \n"
+ "stmia %2, {r8 - r14} \n"
+ "teqp %0, #0 @ return to SVC mode \n"
+ "mov r0, r0 \n"
#endif
#ifdef CONFIG_CPU_32
- "mrs %0, cpsr
- mov %1, %3
- msr cpsr_c, %1 @ select FIQ mode
- mov r0, r0
- stmia %2, {r8 - r14}
- msr cpsr_c, %0 @ return to SVC mode
- mov r0, r0"
+ "mrs %0, cpsr \n"
+ "mov %1, %3 \n"
+ "msr cpsr_c, %1 @ select FIQ mode \n"
+ "mov r0, r0 \n"
+ "stmia %2, {r8 - r14} \n"
+ "msr cpsr_c, %0 @ return to SVC mode \n"
+ "mov r0, r0 \n"
#endif
: "=&r" (tmp), "=&r" (tmp2)
: "r" (®s->ARM_r8), "I" (I_BIT | F_BIT | FIQ_MODE)
diff -urN linux-2.4.26/arch/arm/kernel/head-armv.S linux-2.4.26-vrs1/arch/arm/kernel/head-armv.S
--- linux-2.4.26/arch/arm/kernel/head-armv.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/kernel/head-armv.S 2004-01-14 21:32:24.000000000 +0000
@@ -1,7 +1,7 @@
/*
* linux/arch/arm/kernel/head-armv.S
*
- * Copyright (C) 1994-1999 Russell King
+ * Copyright (C) 1994-2003 Russell King
*
* 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
@@ -163,10 +163,10 @@
*/
.type __ret, %function
__ret: ldr lr, __switch_data
- mcr p15, 0, r0, c1, c0
- mrc p15, 0, r0, c1, c0, 0 @ read it back.
- mov r0, r0
- mov r0, r0
+ mcr p15, 0, r0, c1, c0, 0
+ mrc p15, 0, r3, c0, c0, 0
+ mov r3, r3
+ mov r3, r3
mov pc, lr
/*
@@ -214,6 +214,11 @@
*/
__create_page_tables:
pgtbl r4, r5 @ page table address
+#if defined(CONFIG_CPU_DCACHE_DISABLE)
+ bic r8, r8, #0x00c @ clear B, C
+#elif defined(CONFIG_CPU_DCACHE_WRITETHROUGH)
+ bic r8, r8, #0x004 @ clear B
+#endif
/*
* Clear the 16K level 1 swapper page table
diff -urN linux-2.4.26/arch/arm/kernel/irq.c linux-2.4.26-vrs1/arch/arm/kernel/irq.c
--- linux-2.4.26/arch/arm/kernel/irq.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/kernel/irq.c 2004-01-14 21:32:24.000000000 +0000
@@ -549,7 +549,7 @@
kfree(action);
goto out;
}
- printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
+ printk(KERN_ERR "Trying to free IRQ%d\n",irq);
#ifdef CONFIG_DEBUG_ERRORS
__backtrace();
#endif
diff -urN linux-2.4.26/arch/arm/kernel/ptrace.c linux-2.4.26-vrs1/arch/arm/kernel/ptrace.c
--- linux-2.4.26/arch/arm/kernel/ptrace.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/kernel/ptrace.c 2004-01-14 21:32:24.000000000 +0000
@@ -725,11 +725,8 @@
goto out_tsk;
}
ret = -ESRCH;
- if (!(child->ptrace & PT_PTRACED))
- goto out_tsk;
- if (child->state != TASK_STOPPED && request != PTRACE_KILL)
- goto out_tsk;
- if (child->p_pptr != current)
+ ret = ptrace_check_attach(child, request == PTRACE_KILL);
+ if (ret)
goto out_tsk;
ret = do_ptrace(request, child, addr, data);
diff -urN linux-2.4.26/arch/arm/kernel/semaphore.c linux-2.4.26-vrs1/arch/arm/kernel/semaphore.c
--- linux-2.4.26/arch/arm/kernel/semaphore.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/kernel/semaphore.c 2004-01-14 21:38:42.000000000 +0000
@@ -193,7 +193,7 @@
bl __down_interruptible \n\
mov ip, r0 \n\
ldmfd sp!, {r0 - r3, pc}^ \n\
-
+ \n\
.align 5 \n\
.globl __down_trylock_failed \n\
__down_trylock_failed: \n\
diff -urN linux-2.4.26/arch/arm/kernel/signal.c linux-2.4.26-vrs1/arch/arm/kernel/signal.c
--- linux-2.4.26/arch/arm/kernel/signal.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/kernel/signal.c 2004-01-14 21:32:24.000000000 +0000
@@ -641,10 +641,7 @@
/* FALLTHRU */
default:
- sigaddset(¤t->pending.signal, signr);
- recalc_sigpending(current);
- current->flags |= PF_SIGNALED;
- do_exit(exit_code);
+ sig_exit(signr, exit_code, &info);
/* NOTREACHED */
}
}
diff -urN linux-2.4.26/arch/arm/lib/Makefile linux-2.4.26-vrs1/arch/arm/lib/Makefile
--- linux-2.4.26/arch/arm/lib/Makefile 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/lib/Makefile 2004-01-14 21:32:24.000000000 +0000
@@ -15,7 +15,7 @@
strnlen_user.o strchr.o strrchr.o testchangebit.o \
testclearbit.o testsetbit.o uaccess.o getuser.o \
putuser.o ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
- ucmpdi2.o udivdi3.o lib1funcs.o
+ ucmpdi2.o udivdi3.o lib1funcs.o div64.o
obj-m :=
obj-n :=
diff -urN linux-2.4.26/arch/arm/lib/div64.S linux-2.4.26-vrs1/arch/arm/lib/div64.S
--- linux-2.4.26/arch/arm/lib/div64.S 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/lib/div64.S 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,59 @@
+#include <linux/linkage.h>
+
+#ifndef __ARMEB__
+ql .req r0 @ quotient low
+qh .req r1 @ quotient high
+onl .req r0 @ original dividend low
+onh .req r1 @ original dividend high
+nl .req r4 @ dividend low
+nh .req r5 @ dividend high
+res .req r4 @ result
+#else
+ql .req r1
+qh .req r0
+onl .req r1
+onh .req r0
+nl .req r5
+nh .req r4
+res .req r5
+#endif
+
+dl .req r3 @ divisor low
+dh .req r2 @ divsor high
+
+
+ENTRY(do_div64)
+ stmfd sp!, {r4, r5, lr}
+ mov nl, onl
+ movs nh, onh @ if high bits are zero
+ movne lr, #33
+ moveq lr, #1 @ only divide low bits
+ moveq nh, onl
+
+ tst dh, #0x80000000
+ bne 2f
+1: cmp nh, dh
+ bls 2f
+ add lr, lr, #1
+ movs dh, dh, lsl #1 @ left justify disor
+ bpl 1b
+
+2: movs nh, onh
+ moveq dl, dh
+ moveq dh, #0
+ movne dl, #0
+ mov ql, #0
+ mov qh, #0
+3: subs ip, nl, dl @ trial subtraction
+ sbcs ip, nh, dh
+ movcs nh, ip @ only update if successful
+ subcs nl, nl, dl @ (repeat the subtraction)
+ adcs ql, ql, ql @ C=1 if successful, shift into
+ adc qh, qh, qh @ quotient
+ movs dh, dh, lsr #1 @ shift base high part right
+ mov dl, dl, rrx @ shift base low part right
+ subs lr, lr, #1
+ bne 3b
+
+ mov r2, res
+ ldmfd sp!, {r4, r5, pc}
diff -urN linux-2.4.26/arch/arm/lib/putuser.S linux-2.4.26-vrs1/arch/arm/lib/putuser.S
--- linux-2.4.26/arch/arm/lib/putuser.S 2001-10-11 17:04:57.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/lib/putuser.S 2004-01-14 21:32:24.000000000 +0000
@@ -30,11 +30,11 @@
.global __put_user_1
__put_user_1:
- bic r2, sp, #0x1f00
- bic r2, r2, #0x00ff
- ldr r2, [r2, #TSK_ADDR_LIMIT]
- sub r2, r2, #1
- cmp r0, r2
+ bic ip, sp, #0x1f00
+ bic ip, ip, #0x00ff
+ ldr ip, [ip, #TSK_ADDR_LIMIT]
+ sub ip, ip, #1
+ cmp r0, ip
1: strlsbt r1, [r0]
movls r0, #0
movls pc, lr
@@ -42,11 +42,11 @@
.global __put_user_2
__put_user_2:
- bic r2, sp, #0x1f00
- bic r2, r2, #0x00ff
- ldr r2, [r2, #TSK_ADDR_LIMIT]
- sub r2, r2, #2
- cmp r0, r2
+ bic ip, sp, #0x1f00
+ bic ip, ip, #0x00ff
+ ldr ip, [ip, #TSK_ADDR_LIMIT]
+ sub ip, ip, #2
+ cmp r0, ip
2: strlsbt r1, [r0], #1
movls r1, r1, lsr #8
3: strlsbt r1, [r0]
@@ -56,11 +56,11 @@
.global __put_user_4
__put_user_4:
- bic r2, sp, #0x1f00
- bic r2, r2, #0x00ff
- ldr r2, [r2, #TSK_ADDR_LIMIT]
- sub r2, r2, #4
- cmp r0, r2
+ bic ip, sp, #0x1f00
+ bic ip, ip, #0x00ff
+ ldr ip, [ip, #TSK_ADDR_LIMIT]
+ sub ip, ip, #4
+ cmp r0, ip
4: strlst r1, [r0]
movls r0, #0
movls pc, lr
diff -urN linux-2.4.26/arch/arm/mach-at91rm9200/Makefile linux-2.4.26-vrs1/arch/arm/mach-at91rm9200/Makefile
--- linux-2.4.26/arch/arm/mach-at91rm9200/Makefile 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-at91rm9200/Makefile 2004-04-10 12:21:08.000000000 +0100
@@ -18,4 +18,8 @@
export-objs :=
+# LEDs support
+leds-$(CONFIG_ARCH_AT91RM9200DK) += dk-leds.o
+obj-$(CONFIG_LEDS) += $(leds-y)
+
include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/arch/arm/mach-at91rm9200/dk-leds.c linux-2.4.26-vrs1/arch/arm/mach-at91rm9200/dk-leds.c
--- linux-2.4.26/arch/arm/mach-at91rm9200/dk-leds.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-at91rm9200/dk-leds.c 2004-04-10 12:21:08.000000000 +0100
@@ -0,0 +1,97 @@
+/*
+ * LED driver for the Atmel AT91RM9200 Development Kit.
+ *
+ * (c) SAN People (Pty) Ltd
+ *
+ * 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.
+*/
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include <asm/mach-types.h>
+#include <asm/leds.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/pio.h>
+
+
+static inline void at91_led_on(void)
+{
+ AT91_SYS->PIOB_CODR = AT91C_PIO_PB2;
+}
+
+static inline void at91_led_off(void)
+{
+ AT91_SYS->PIOB_SODR = AT91C_PIO_PB2;
+}
+
+static inline void at91_led_toggle(void)
+{
+ unsigned long curr = AT91_SYS->PIOB_ODSR;
+ if (curr & AT91C_PIO_PB2)
+ AT91_SYS->PIOB_CODR = AT91C_PIO_PB2;
+ else
+ AT91_SYS->PIOB_SODR = AT91C_PIO_PB2;
+}
+
+
+/*
+ * Handle LED events.
+ */
+static void at91rm9200dk_leds_event(led_event_t evt)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+
+ switch(evt) {
+ case led_start: /* System startup */
+ at91_led_on();
+ break;
+
+ case led_stop: /* System stop / suspend */
+ at91_led_off();
+ break;
+
+#ifdef CONFIG_LEDS_TIMER
+ case led_timer: /* Every 50 timer ticks */
+ at91_led_toggle();
+ break;
+#endif
+
+#ifdef CONFIG_LEDS_CPU
+ case led_idle_start: /* Entering idle state */
+ at91_led_off();
+ break;
+
+ case led_idle_end: /* Exit idle state */
+ at91_led_on();
+ break;
+#endif
+
+ default:
+ break;
+ }
+
+ local_irq_restore(flags);
+}
+
+
+static int __init leds_init(void)
+{
+ /* Enable PIO to access the LEDs */
+ AT91_SYS->PIOB_PER = AT91C_PIO_PB2;
+ AT91_SYS->PIOB_OER = AT91C_PIO_PB2;
+
+ leds_event = at91rm9200dk_leds_event;
+
+ leds_event(led_start);
+ return 0;
+}
+
+__initcall(leds_init);
diff -urN linux-2.4.26/arch/arm/mach-integrator/pci_v3.c linux-2.4.26-vrs1/arch/arm/mach-integrator/pci_v3.c
--- linux-2.4.26/arch/arm/mach-integrator/pci_v3.c 2003-06-13 15:51:29.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-integrator/pci_v3.c 2004-01-14 21:32:24.000000000 +0000
@@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/config.h>
-#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/ptrace.h>
@@ -32,6 +31,7 @@
#include <linux/init.h>
#include <asm/hardware.h>
+#include <asm/io.h>
#include <asm/irq.h>
#include <asm/system.h>
#include <asm/mach/pci.h>
@@ -447,15 +447,16 @@
#define SC_LBFADDR (IO_ADDRESS(INTEGRATOR_SC_BASE) + 0x20)
#define SC_LBFCODE (IO_ADDRESS(INTEGRATOR_SC_BASE) + 0x24)
-static int v3_fault(unsigned long addr, struct pt_regs *regs)
+static int
+v3_pci_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{
unsigned long pc = instruction_pointer(regs);
unsigned long instr = *(unsigned long *)pc;
#if 0
char buf[128];
- sprintf(buf, "V3 fault: address=0x%08lx, pc=0x%08lx [%08lx] LBFADDR=%08x LBFCODE=%02x ISTAT=%02x\n",
- addr, pc, instr, __raw_readl(SC_LBFADDR), __raw_readl(SC_LBFCODE) & 255,
+ sprintf(buf, "V3 fault: addr 0x%08lx, FSR 0x%03x, PC 0x%08lx [%08lx] LBFADDR=%08x LBFCODE=%02x ISTAT=%02x\n",
+ addr, fsr, pc, instr, __raw_readl(SC_LBFADDR), __raw_readl(SC_LBFCODE) & 255,
v3_readb(V3_LB_ISTAT));
printk(KERN_DEBUG "%s", buf);
printascii(buf);
@@ -523,8 +524,6 @@
#endif
}
-extern int (*external_fault)(unsigned long addr, struct pt_regs *regs);
-
/*
* V3_LB_BASE? - local bus address
* V3_LB_MAP? - pci bus address
@@ -539,7 +538,10 @@
/*
* Hook in our fault handler for PCI errors
*/
- external_fault = v3_fault;
+ hook_fault_code(4, v3_pci_fault, SIGBUS, "external abort on linefetch");
+ hook_fault_code(6, v3_pci_fault, SIGBUS, "external abort on linefetch");
+ hook_fault_code(8, v3_pci_fault, SIGBUS, "external abort on non-linefetch");
+ hook_fault_code(10, v3_pci_fault, SIGBUS, "external abort on non-linefetch");
spin_lock_irqsave(&v3_lock, flags);
@@ -629,7 +631,7 @@
#if 0
ret = request_irq(IRQ_LBUSTIMEOUT, lb_timeout, 0, "bus timeout", NULL);
if (ret)
- printk(KERN_ERR "PCI: unable to grab local bus timeout ".
+ printk(KERN_ERR "PCI: unable to grab local bus timeout "
"interrupt: %d\n", ret);
#endif
}
diff -urN linux-2.4.26/arch/arm/mach-sa1100/pm.c linux-2.4.26-vrs1/arch/arm/mach-sa1100/pm.c
--- linux-2.4.26/arch/arm/mach-sa1100/pm.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/pm.c 2004-01-14 21:38:43.000000000 +0000
@@ -21,6 +21,8 @@
*
* 2002-05-27: Nicolas Pitre Killed sleep.h and the kmalloced save array.
* Storage is local on the stack now.
+ * 2003-06-25: Jeff Corrall <jcorrall@mac.com>
+ * Saved the GPIO levels for resume after sleep.
*/
#include <linux/config.h>
#include <linux/init.h>
@@ -70,13 +72,20 @@
int pm_do_suspend(void)
{
unsigned long sleep_save[SLEEP_SAVE_SIZE];
+ unsigned long sleep_save_gpsr;
+ unsigned long sleep_save_gpcr;
+ unsigned long delta;
cli();
leds_event(led_stop);
/* preserve current time */
- RCNR = xtime.tv_sec;
+ delta = xtime.tv_sec - RCNR;
+
+ /* save the current state of the GPIO output pins */
+ sleep_save_gpsr = GPDR & GPLR;
+ sleep_save_gpcr = GPDR & ~GPLR;
/* save vital registers */
SAVE(OSCR);
@@ -121,6 +130,10 @@
printk(KERN_DEBUG "*** made it back from resume\n");
#endif
+ /* restore GPIO output state before enabling the pins */
+ GPSR = sleep_save_gpsr;
+ GPCR = sleep_save_gpcr;
+
/* restore registers */
RESTORE(GPDR);
RESTORE(GRER);
@@ -151,7 +164,7 @@
RESTORE(ICMR);
/* restore current time */
- xtime.tv_sec = RCNR;
+ xtime.tv_sec = RCNR + delta;
leds_event(led_start);
diff -urN linux-2.4.26/arch/arm/mach-sa1100/sa1100_usb.h linux-2.4.26-vrs1/arch/arm/mach-sa1100/sa1100_usb.h
--- linux-2.4.26/arch/arm/mach-sa1100/sa1100_usb.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/sa1100_usb.h 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,193 @@
+/*
+ * sa1100_usb.h
+ *
+ * Public interface to the sa1100 USB core. For use by client modules
+ * like usb-eth and usb-char.
+ *
+ */
+
+#ifndef _SA1100_USB_H
+#define _SA1100_USB_H
+#include <asm/byteorder.h>
+
+typedef void (*usb_callback_t)(int flag, int size);
+
+/* in usb_ctl.c (see also descriptor methods at bottom of file) */
+
+// Open the USB client for client and initialize data structures
+// to default values, but _do not_ start UDC.
+int sa1100_usb_open( const char * client_name );
+
+// Start UDC running
+int sa1100_usb_start( void );
+
+// Immediately stop udc, fire off completion routines w/-EINTR
+int sa1100_usb_stop( void ) ;
+
+// Disconnect client from usb core
+int sa1100_usb_close( void ) ;
+
+// set notify callback for when core reaches configured state
+// return previous pointer (if any)
+typedef void (*usb_notify_t)(void);
+usb_notify_t sa1100_set_configured_callback( usb_notify_t callback );
+
+/* in usb_send.c */
+int sa1100_usb_xmitter_avail( void );
+int sa1100_usb_send(char *buf, int len, usb_callback_t callback);
+void sa1100_usb_send_reset(void);
+
+/* in usb_recev.c */
+int sa1100_usb_recv(char *buf, int len, usb_callback_t callback);
+void sa1100_usb_recv_reset(void);
+
+//////////////////////////////////////////////////////////////////////////////
+// Descriptor Management
+//////////////////////////////////////////////////////////////////////////////
+
+#define DescriptorHeader \
+ __u8 bLength; \
+ __u8 bDescriptorType
+
+
+// --- Device Descriptor -------------------
+
+typedef struct {
+ DescriptorHeader;
+ __u16 bcdUSB; /* USB specification revision number in BCD */
+ __u8 bDeviceClass; /* USB class for entire device */
+ __u8 bDeviceSubClass; /* USB subclass information for entire device */
+ __u8 bDeviceProtocol; /* USB protocol information for entire device */
+ __u8 bMaxPacketSize0; /* Max packet size for endpoint zero */
+ __u16 idVendor; /* USB vendor ID */
+ __u16 idProduct; /* USB product ID */
+ __u16 bcdDevice; /* vendor assigned device release number */
+ __u8 iManufacturer; /* index of manufacturer string */
+ __u8 iProduct; /* index of string that describes product */
+ __u8 iSerialNumber; /* index of string containing device serial number */
+ __u8 bNumConfigurations; /* number fo configurations */
+} __attribute__ ((packed)) device_desc_t;
+
+// --- Configuration Descriptor ------------
+
+typedef struct {
+ DescriptorHeader;
+ __u16 wTotalLength; /* total # of bytes returned in the cfg buf 4 this cfg */
+ __u8 bNumInterfaces; /* number of interfaces in this cfg */
+ __u8 bConfigurationValue; /* used to uniquely ID this cfg */
+ __u8 iConfiguration; /* index of string describing configuration */
+ __u8 bmAttributes; /* bitmap of attributes for ths cfg */
+ __u8 MaxPower; /* power draw in 2ma units */
+} __attribute__ ((packed)) config_desc_t;
+
+// bmAttributes:
+enum { USB_CONFIG_REMOTEWAKE=0x20, USB_CONFIG_SELFPOWERED=0x40,
+ USB_CONFIG_BUSPOWERED=0x80 };
+// MaxPower:
+#define USB_POWER( x) ((x)>>1) /* convert mA to descriptor units of A for MaxPower */
+
+// --- Interface Descriptor ---------------
+
+typedef struct {
+ DescriptorHeader;
+ __u8 bInterfaceNumber; /* Index uniquely identfying this interface */
+ __u8 bAlternateSetting; /* ids an alternate setting for this interface */
+ __u8 bNumEndpoints; /* number of endpoints in this interface */
+ __u8 bInterfaceClass; /* USB class info applying to this interface */
+ __u8 bInterfaceSubClass; /* USB subclass info applying to this interface */
+ __u8 bInterfaceProtocol; /* USB protocol info applying to this interface */
+ __u8 iInterface; /* index of string describing interface */
+} __attribute__ ((packed)) intf_desc_t;
+
+// --- Endpoint Descriptor ---------------
+
+typedef struct {
+ DescriptorHeader;
+ __u8 bEndpointAddress; /* 0..3 ep num, bit 7: 0 = 0ut 1= in */
+ __u8 bmAttributes; /* 0..1 = 0: ctrl, 1: isoc, 2: bulk 3: intr */
+ __u16 wMaxPacketSize; /* data payload size for this ep in this cfg */
+ __u8 bInterval; /* polling interval for this ep in this cfg */
+} __attribute__ ((packed)) ep_desc_t;
+
+// bEndpointAddress:
+enum { USB_OUT= 0, USB_IN=1 };
+#define USB_EP_ADDRESS(a,d) (((a)&0xf) | ((d) << 7))
+// bmAttributes:
+enum { USB_EP_CNTRL=0, USB_EP_BULK=2, USB_EP_INT=3 };
+
+// --- String Descriptor -------------------
+
+typedef struct {
+ DescriptorHeader;
+ __u16 bString[1]; /* unicode string .. actaully 'n' __u16s */
+} __attribute__ ((packed)) string_desc_t;
+
+/*=======================================================
+ * Handy helpers when working with above
+ *
+ */
+// these are x86-style 16 bit "words" ...
+#define make_word_c( w ) __constant_cpu_to_le16(w)
+#define make_word( w ) __cpu_to_le16(w)
+
+// descriptor types
+enum { USB_DESC_DEVICE=1, USB_DESC_CONFIG=2, USB_DESC_STRING=3,
+ USB_DESC_INTERFACE=4, USB_DESC_ENDPOINT=5 };
+
+
+/*=======================================================
+ * Default descriptor layout for SA-1100 and SA-1110 UDC
+ */
+
+/* "config descriptor buffer" - that is, one config,
+ ..one interface and 2 endpoints */
+struct cdb {
+ config_desc_t cfg;
+ intf_desc_t intf;
+ ep_desc_t ep1;
+ ep_desc_t ep2;
+} __attribute__ ((packed));
+
+
+/* all SA device descriptors */
+typedef struct {
+ device_desc_t dev; /* device descriptor */
+ struct cdb b; /* bundle of descriptors for this cfg */
+} __attribute__ ((packed)) desc_t;
+
+
+/*=======================================================
+ * Descriptor API
+ */
+
+/* Get the address of the statically allocated desc_t structure
+ in the usb core driver. Clients can modify this between
+ the time they call sa1100_usb_open() and sa1100_usb_start()
+*/
+desc_t *
+sa1100_usb_get_descriptor_ptr( void );
+
+
+/* Set a pointer to the string descriptor at "index". The driver
+ ..has room for 8 string indicies internally. Index zero holds
+ ..a LANGID code and is set to US English by default. Inidices
+ ..1-7 are available for use in the config descriptors as client's
+ ..see fit. This pointer is assumed to be good as long as the
+ ..SA usb core is open (so statically allocate them). Returnes -EINVAL
+ ..if index out of range */
+int sa1100_usb_set_string_descriptor( int index, string_desc_t * p );
+
+/* reverse of above */
+string_desc_t *
+sa1100_usb_get_string_descriptor( int index );
+
+/* kmalloc() a string descriptor and convert "p" to unicode in it */
+string_desc_t *
+sa1100_usb_kmalloc_string_descriptor( const char * p );
+
+
+
+
+
+
+#endif /* _SA1100_USB_H */
diff -urN linux-2.4.26/arch/arm/mach-sa1100/sa1111-ohci.c linux-2.4.26-vrs1/arch/arm/mach-sa1100/sa1111-ohci.c
--- linux-2.4.26/arch/arm/mach-sa1100/sa1111-ohci.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/sa1111-ohci.c 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,140 @@
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/mm.h>
+
+#ifdef CONFIG_USB_OHCI
+
+/*
+ * The SA-1111 errata says that the DMA hardware needs to be exercised
+ * before the clocks are turned on to work properly. This code does
+ * a tiny dma transfer to prime to hardware.
+ *
+ * What DMA errata? I've checked October 1999 and February 2001, both
+ * of which do not mention such a bug, let alone any details of this
+ * work-around.
+ */
+static void __init sa1111_dma_setup(void)
+{
+ dma_addr_t dma_buf;
+ void * vbuf;
+
+ /* DMA init & setup */
+
+ /* WARNING: The SA-1111 L3 function is used as part of this
+ * SA-1111 DMA errata workaround.
+ *
+ * N.B., When the L3 function is enabled, it uses GPIO_B<4:5>
+ * and takes precedence over the PS/2 mouse and GPIO_B
+ * functions. Refer to "Intel StrongARM SA-1111 Microprocessor
+ * Companion Chip, Sect 10.2" for details. So this "fix" may
+ * "break" support of either PS/2 mouse or GPIO_B if
+ * precautions are not taken to avoid collisions in
+ * configuration and use of these pins. AFAIK, no precautions
+ * are taken at this time. So it is likely that the action
+ * taken here may cause problems in PS/2 mouse and/or GPIO_B
+ * pin use elsewhere.
+ *
+ * But wait, there's more... What we're doing here is
+ * obviously altogether a bad idea. We're indiscrimanately bit
+ * flipping config for a few different functions here which
+ * are "owned" by other drivers. This needs to be handled
+ * better than it is being done here at this time. */
+
+ /* prime the dma engine with a tiny dma */
+ SKPCR |= SKPCR_I2SCLKEN;
+ SKAUD |= SKPCR_L3CLKEN | SKPCR_SCLKEN;
+
+ SACR0 |= 0x00003305;
+ SACR1 = 0x00000000;
+
+ /*
+ * We need memory below 1MB.
+ * NOTE: consistent_alloc gives you some random virtual
+ * address as its return value, and the DMA address via
+ * the dma_addr_t pointer.
+ */
+ vbuf = consistent_alloc(GFP_KERNEL | GFP_DMA, 4, &dma_buf);
+
+ SADTSA = (unsigned long)dma_buf;
+ SADTCA = 4;
+
+ SADTCS |= 0x00000011;
+ SKPCR |= SKPCR_DCLKEN;
+
+ /* wait */
+ udelay(100);
+
+ /* clear reserved but, then disable SAC */
+ SACR0 &= ~(0x00000002);
+ SACR0 &= ~(0x00000001);
+
+ /* toggle bit clock direction */
+ SACR0 |= 0x00000004;
+ SACR0 &= ~(0x00000004);
+
+ SKAUD &= ~(SKPCR_L3CLKEN | SKPCR_SCLKEN);
+
+ SKPCR &= ~SKPCR_I2SCLKEN;
+
+ consistent_free(vbuf, 4, dma_buf);
+}
+
+/*
+ * reset the SA-1111 usb controller and turn on it's clocks
+ */
+int __init sa1111_ohci_hcd_init(void)
+{
+ unsigned int usb_reset = 0;
+
+ if (machine_is_xp860() ||
+ machine_has_neponset() ||
+ machine_is_pfs168() ||
+ machine_is_badge4())
+ usb_reset = USB_RESET_PWRSENSELOW | USB_RESET_PWRCTRLLOW;
+
+ /*
+ * turn on USB clocks
+ */
+ SKPCR |= SKPCR_UCLKEN;
+ udelay(100);
+
+ /*
+ * Force USB reset
+ */
+ USB_RESET = USB_RESET_FORCEIFRESET;
+ USB_RESET |= USB_RESET_FORCEHCRESET;
+ udelay(100);
+
+ /*
+ * Take out of reset
+ */
+ USB_RESET = 0;
+
+ /*
+ * set power sense and control lines (this from the diags code)
+ */
+ USB_RESET = usb_reset;
+
+ /*
+ * Huh? This is a _read only_ register --rmk
+ */
+ USB_STATUS = 0;
+
+ udelay(10);
+
+ /*
+ * compensate for dma bug
+ */
+ sa1111_dma_setup();
+
+ return 0;
+}
+
+void sa1111_ohci_hcd_cleanup(void)
+{
+ /* turn the USB clock off */
+ SKPCR &= ~SKPCR_UCLKEN;
+}
+
+#endif /* CONFIG_USB_OHCI */
diff -urN linux-2.4.26/arch/arm/mach-sa1100/usb-char.c linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb-char.c
--- linux-2.4.26/arch/arm/mach-sa1100/usb-char.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb-char.c 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,723 @@
+/*
+ * (C) Copyright 2000-2001 Extenex 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * usb-char.c
+ *
+ * Miscellaneous character device interface for SA1100 USB function
+ * driver.
+ *
+ * Background:
+ * The SA1100 function driver ported from the Compaq Itsy project
+ * has an interface, usb-eth.c, to feed network packets over the
+ * usb wire and into the Linux TCP/IP stack.
+ *
+ * This file replaces that one with a simple character device
+ * interface that allows unstructured "byte pipe" style reads and
+ * writes over the USB bulk endpoints by userspace programs.
+ *
+ * A new define, CONFIG_SA1100_USB_NETLINK, has been created that,
+ * when set, (the default) causes the ethernet interface to be used.
+ * When not set, this more pedestrian character interface is linked
+ * in instead.
+ *
+ * Please see linux/Documentation/arm/SA1100/SA1100_USB for details.
+ *
+ * ward.willats@extenex.com
+ *
+ * To do:
+ * - Can't dma into ring buffer directly with pci_map/unmap usb_recv
+ * uses and get bytes out at the same time DMA is going on. Investigate:
+ * a) changing usb_recv to use alloc_consistent() at client request; or
+ * b) non-ring-buffer based data structures. In the meantime, I am using
+ * a bounce buffer. Simple, but wasteful.
+ */
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/miscdevice.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/cache.h>
+#include <linux/poll.h>
+#include <linux/circ_buf.h>
+#include <linux/timer.h>
+
+#include <asm/io.h>
+#include <asm/semaphore.h>
+#include <asm/proc/page.h>
+#include <asm/mach-types.h>
+
+#include "usb-char.h"
+#include "sa1100_usb.h"
+
+
+
+//////////////////////////////////////////////////////////////////////////////
+// Driver Options
+//////////////////////////////////////////////////////////////////////////////
+
+#define VERSION "0.4"
+
+
+#define VERBOSITY 1
+
+#if VERBOSITY
+# define PRINTK(x, a...) printk (x, ## a)
+#else
+# define PRINTK(x, a...) /**/
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+// Globals - Macros - Enums - Structures
+//////////////////////////////////////////////////////////////////////////////
+#ifndef MIN
+#define MIN( a, b ) ((a)<(b)?(a):(b))
+#endif
+
+typedef int bool; enum { false = 0, true = 1 };
+
+static const char pszMe[] = "usbchr: ";
+
+static wait_queue_head_t wq_read;
+static wait_queue_head_t wq_write;
+static wait_queue_head_t wq_poll;
+
+/* Serialze multiple writers onto the transmit hardware
+.. since we sleep the writer during transmit to stay in
+.. sync. (Multiple writers don't make much sense, but..) */
+static DECLARE_MUTEX( xmit_sem );
+
+// size of usb DATA0/1 packets. 64 is standard maximum
+// for bulk transport, though most hosts seem to be able
+// to handle larger.
+#define TX_PACKET_SIZE 64
+#define RX_PACKET_SIZE 64
+#define RBUF_SIZE (4*PAGE_SIZE)
+
+static struct wcirc_buf {
+ char *buf;
+ int in;
+ int out;
+} rx_ring = { NULL, 0, 0 };
+
+static struct {
+ unsigned long cnt_rx_complete;
+ unsigned long cnt_rx_errors;
+ unsigned long bytes_rx;
+ unsigned long cnt_tx_timeouts;
+ unsigned long cnt_tx_errors;
+ unsigned long bytes_tx;
+} charstats;
+
+
+static char * tx_buf = NULL;
+static char * packet_buffer = NULL;
+static int sending = 0;
+static int usb_ref_count = 0;
+static int last_tx_result = 0;
+static int last_rx_result = 0;
+static int last_tx_size = 0;
+static struct timer_list tx_timer;
+
+//////////////////////////////////////////////////////////////////////////////
+// Prototypes
+//////////////////////////////////////////////////////////////////////////////
+static char * what_the_f( int e );
+static void free_txrx_buffers( void );
+static void twiddle_descriptors( void );
+static void free_string_descriptors( void ) ;
+static int usbc_open( struct inode *pInode, struct file *pFile );
+static void rx_done_callback_packet_buffer( int flag, int size );
+
+static void tx_timeout( unsigned long );
+static void tx_done_callback( int flag, int size );
+
+static ssize_t usbc_read( struct file *, char *, size_t, loff_t * );
+static ssize_t usbc_write( struct file *, const char *, size_t, loff_t * );
+static unsigned int usbc_poll( struct file *pFile, poll_table * pWait );
+static int usbc_ioctl( struct inode *pInode, struct file *pFile,
+ unsigned int nCmd, unsigned long argument );
+static int usbc_close( struct inode *pInode, struct file *pFile );
+
+#ifdef CONFIG_SA1100_EXTENEX1
+static void extenex_configured_notify_proc( void );
+#endif
+//////////////////////////////////////////////////////////////////////////////
+// Private Helpers
+//////////////////////////////////////////////////////////////////////////////
+
+static char * what_the_f( int e )
+{
+ char * p;
+ switch( e ) {
+ case 0:
+ p = "noErr";
+ break;
+ case -ENODEV:
+ p = "ENODEV - usb not in config state";
+ break;
+ case -EBUSY:
+ p = "EBUSY - another request on the hardware";
+ break;
+ case -EAGAIN:
+ p = "EAGAIN";
+ break;
+ case -EINTR:
+ p = "EINTR - interrupted\n";
+ break;
+ case -EPIPE:
+ p = "EPIPE - zero length xfer\n";
+ break;
+ default:
+ p = "????";
+ break;
+ }
+ return p;
+}
+
+static void free_txrx_buffers( void )
+{
+ if ( rx_ring.buf != NULL ) {
+ kfree( rx_ring.buf );
+ rx_ring.buf = NULL;
+ }
+ if ( packet_buffer != NULL ) {
+ kfree( packet_buffer );
+ packet_buffer = NULL;
+ }
+ if ( tx_buf != NULL ) {
+ kfree( tx_buf );
+ tx_buf = NULL;
+ }
+}
+
+/* twiddle_descriptors()
+ * It is between open() and start(). Setup descriptors.
+ */
+static void twiddle_descriptors( void )
+{
+ desc_t * pDesc = sa1100_usb_get_descriptor_ptr();
+ string_desc_t * pString;
+
+ pDesc->b.ep1.wMaxPacketSize = make_word_c( RX_PACKET_SIZE );
+ pDesc->b.ep1.bmAttributes = USB_EP_BULK;
+ pDesc->b.ep2.wMaxPacketSize = make_word_c( TX_PACKET_SIZE );
+ pDesc->b.ep2.bmAttributes = USB_EP_BULK;
+
+ if ( machine_is_extenex1() ) {
+#ifdef CONFIG_SA1100_EXTENEX1
+ pDesc->dev.idVendor = make_word_c( 0xC9F );
+ pDesc->dev.idProduct = 1;
+ pDesc->dev.bcdDevice = make_word_c( 0x0001 );
+ pDesc->b.cfg.bmAttributes = USB_CONFIG_SELFPOWERED;
+ pDesc->b.cfg.MaxPower = 0;
+
+ pString = sa1100_usb_kmalloc_string_descriptor( "Extenex" );
+ if ( pString ) {
+ sa1100_usb_set_string_descriptor( 1, pString );
+ pDesc->dev.iManufacturer = 1;
+ }
+
+ pString = sa1100_usb_kmalloc_string_descriptor( "Handheld Theater" );
+ if ( pString ) {
+ sa1100_usb_set_string_descriptor( 2, pString );
+ pDesc->dev.iProduct = 2;
+ }
+
+ pString = sa1100_usb_kmalloc_string_descriptor( "00000000" );
+ if ( pString ) {
+ sa1100_usb_set_string_descriptor( 3, pString );
+ pDesc->dev.iSerialNumber = 3;
+ }
+
+ pString = sa1100_usb_kmalloc_string_descriptor( "HHT Bulk Transfer" );
+ if ( pString ) {
+ sa1100_usb_set_string_descriptor( 4, pString );
+ pDesc->b.intf.iInterface = 4;
+ }
+ sa1100_set_configured_callback( extenex_configured_notify_proc );
+#endif
+ }
+}
+
+static void free_string_descriptors( void )
+{
+ if ( machine_is_extenex1() ) {
+ string_desc_t * pString;
+ int i;
+ for( i = 1 ; i <= 4 ; i++ ) {
+ pString = sa1100_usb_get_string_descriptor( i );
+ if ( pString )
+ kfree( pString );
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// ASYNCHRONOUS
+//////////////////////////////////////////////////////////////////////////////
+static void kick_start_rx( void )
+{
+ if ( usb_ref_count ) {
+ int total_space = CIRC_SPACE( rx_ring.in, rx_ring.out, RBUF_SIZE );
+ if ( total_space >= RX_PACKET_SIZE ) {
+ sa1100_usb_recv( packet_buffer,
+ RX_PACKET_SIZE,
+ rx_done_callback_packet_buffer
+ );
+ }
+ }
+}
+/*
+ * rx_done_callback_packet_buffer()
+ * We have completed a DMA xfer into the temp packet buffer.
+ * Move to ring.
+ *
+ * flag values:
+ * on init, -EAGAIN
+ * on reset, -EINTR
+ * on RPE, -EIO
+ * on short packet -EPIPE
+ */
+static void
+rx_done_callback_packet_buffer( int flag, int size )
+{
+ charstats.cnt_rx_complete++;
+
+ if ( flag == 0 || flag == -EPIPE ) {
+ size_t n;
+
+ charstats.bytes_rx += size;
+
+ n = CIRC_SPACE_TO_END( rx_ring.in, rx_ring.out, RBUF_SIZE );
+ n = MIN( n, size );
+ size -= n;
+
+ memcpy( &rx_ring.buf[ rx_ring.in ], packet_buffer, n );
+ rx_ring.in = (rx_ring.in + n) & (RBUF_SIZE-1);
+ memcpy( &rx_ring.buf[ rx_ring.in ], packet_buffer + n, size );
+ rx_ring.in = (rx_ring.in + size) & (RBUF_SIZE-1);
+
+ wake_up_interruptible( &wq_read );
+ wake_up_interruptible( &wq_poll );
+
+ last_rx_result = 0;
+
+ kick_start_rx();
+
+ } else if ( flag != -EAGAIN ) {
+ charstats.cnt_rx_errors++;
+ last_rx_result = flag;
+ wake_up_interruptible( &wq_read );
+ wake_up_interruptible( &wq_poll );
+ }
+ else /* init, start a read */
+ kick_start_rx();
+}
+
+
+static void tx_timeout( unsigned long unused )
+{
+ printk( "%stx timeout\n", pszMe );
+ sa1100_usb_send_reset();
+ charstats.cnt_tx_timeouts++;
+}
+
+
+// on init, -EAGAIN
+// on reset, -EINTR
+// on TPE, -EIO
+static void tx_done_callback( int flags, int size )
+{
+ if ( flags == 0 )
+ charstats.bytes_tx += size;
+ else
+ charstats.cnt_tx_errors++;
+ last_tx_size = size;
+ last_tx_result = flags;
+ sending = 0;
+ wake_up_interruptible( &wq_write );
+ wake_up_interruptible( &wq_poll );
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// Workers
+//////////////////////////////////////////////////////////////////////////////
+
+static int usbc_open( struct inode *pInode, struct file *pFile )
+{
+ int retval = 0;
+
+ PRINTK( KERN_DEBUG "%sopen()\n", pszMe );
+
+ /* start usb core */
+ retval = sa1100_usb_open( "usb-char" );
+ if ( retval ) return retval;
+
+ /* allocate memory */
+ if ( usb_ref_count == 0 ) {
+ tx_buf = (char*) kmalloc( TX_PACKET_SIZE, GFP_KERNEL | GFP_DMA );
+ if ( tx_buf == NULL ) {
+ printk( "%sARGHH! COULD NOT ALLOCATE TX BUFFER\n", pszMe );
+ goto malloc_fail;
+ }
+ rx_ring.buf =
+ (char*) kmalloc( RBUF_SIZE, GFP_KERNEL );
+
+ if ( rx_ring.buf == NULL ) {
+ printk( "%sARGHH! COULD NOT ALLOCATE RX BUFFER\n", pszMe );
+ goto malloc_fail;
+ }
+
+ packet_buffer =
+ (char*) kmalloc( RX_PACKET_SIZE, GFP_KERNEL | GFP_DMA );
+
+ if ( packet_buffer == NULL ) {
+ printk( "%sARGHH! COULD NOT ALLOCATE RX PACKET BUFFER\n", pszMe );
+ goto malloc_fail;
+ }
+ rx_ring.in = rx_ring.out = 0;
+ memset( &charstats, 0, sizeof( charstats ) );
+ sending = 0;
+ last_tx_result = 0;
+ last_tx_size = 0;
+ }
+
+ /* modify default descriptors */
+ twiddle_descriptors();
+
+ retval = sa1100_usb_start();
+ if ( retval ) {
+ printk( "%sAGHH! Could not USB core\n", pszMe );
+ free_txrx_buffers();
+ return retval;
+ }
+ usb_ref_count++; /* must do _before_ kick_start() */
+ MOD_INC_USE_COUNT;
+ kick_start_rx();
+ return 0;
+
+ malloc_fail:
+ free_txrx_buffers();
+ return -ENOMEM;
+}
+
+/*
+ * Read endpoint. Note that you can issue a read to an
+ * unconfigured endpoint. Eventually, the host may come along
+ * and configure underneath this module and data will appear.
+ */
+static ssize_t usbc_read( struct file *pFile, char *pUserBuffer,
+ size_t stCount, loff_t *pPos )
+{
+ ssize_t retval;
+ int flags;
+ DECLARE_WAITQUEUE( wait, current );
+
+ PRINTK( KERN_DEBUG "%sread()\n", pszMe );
+
+ local_irq_save( flags );
+ if ( last_rx_result == 0 ) {
+ local_irq_restore( flags );
+ } else { /* an error happended and receiver is paused */
+ local_irq_restore( flags );
+ last_rx_result = 0;
+ kick_start_rx();
+ }
+
+ add_wait_queue( &wq_read, &wait );
+ while( 1 ) {
+ ssize_t bytes_avail;
+ ssize_t bytes_to_end;
+
+ set_current_state( TASK_INTERRUPTIBLE );
+
+ /* snap ring buf state */
+ local_irq_save( flags );
+ bytes_avail = CIRC_CNT( rx_ring.in, rx_ring.out, RBUF_SIZE );
+ bytes_to_end = CIRC_CNT_TO_END( rx_ring.in, rx_ring.out, RBUF_SIZE );
+ local_irq_restore( flags );
+
+ if ( bytes_avail != 0 ) {
+ ssize_t bytes_to_move = MIN( stCount, bytes_avail );
+ retval = 0; // will be bytes transfered
+ if ( bytes_to_move != 0 ) {
+ size_t n = MIN( bytes_to_end, bytes_to_move );
+ if ( copy_to_user( pUserBuffer,
+ &rx_ring.buf[ rx_ring.out ],
+ n ) ) {
+ retval = -EFAULT;
+ break;
+ }
+ bytes_to_move -= n;
+ retval += n;
+ // might go 1 char off end, so wrap
+ rx_ring.out = ( rx_ring.out + n ) & (RBUF_SIZE-1);
+ if ( copy_to_user( pUserBuffer + n,
+ &rx_ring.buf[ rx_ring.out ],
+ bytes_to_move )
+ ) {
+ retval = -EFAULT;
+ break;
+ }
+ rx_ring.out += bytes_to_move; // cannot wrap
+ retval += bytes_to_move;
+ kick_start_rx();
+ }
+ break;
+ }
+ else if ( last_rx_result ) {
+ retval = last_rx_result;
+ break;
+ }
+ else if ( pFile->f_flags & O_NONBLOCK ) { // no data, can't sleep
+ retval = -EAGAIN;
+ break;
+ }
+ else if ( signal_pending( current ) ) { // no data, can sleep, but signal
+ retval = -ERESTARTSYS;
+ break;
+ }
+ schedule(); // no data, can sleep
+ }
+ set_current_state( TASK_RUNNING );
+ remove_wait_queue( &wq_read, &wait );
+
+ if ( retval < 0 )
+ printk( "%sread error %d - %s\n", pszMe, retval, what_the_f( retval ) );
+ return retval;
+}
+
+/*
+ * Write endpoint. This routine attempts to break the passed in buffer
+ * into usb DATA0/1 packet size chunks and send them to the host.
+ * (The lower-level driver tries to do this too, but easier for us
+ * to manage things here.)
+ *
+ * We are at the mercy of the host here, in that it must send an IN
+ * token to us to pull this data back, so hopefully some higher level
+ * protocol is expecting traffic to flow in that direction so the host
+ * is actually polling us. To guard against hangs, a 5 second timeout
+ * is used.
+ *
+ * This routine takes some care to only report bytes sent that have
+ * actually made it across the wire. Thus we try to stay in lockstep
+ * with the completion routine and only have one packet on the xmit
+ * hardware at a time. Multiple simultaneous writers will get
+ * "undefined" results.
+ *
+ */
+static ssize_t usbc_write( struct file *pFile, const char * pUserBuffer,
+ size_t stCount, loff_t *pPos )
+{
+ ssize_t retval = 0;
+ ssize_t stSent = 0;
+
+ DECLARE_WAITQUEUE( wait, current );
+
+ PRINTK( KERN_DEBUG "%swrite() %d bytes\n", pszMe, stCount );
+
+ down( &xmit_sem ); // only one thread onto the hardware at a time
+
+ while( stCount != 0 && retval == 0 ) {
+ int nThisTime = MIN( TX_PACKET_SIZE, stCount );
+ copy_from_user( tx_buf, pUserBuffer, nThisTime );
+ sending = nThisTime;
+ retval = sa1100_usb_send( tx_buf, nThisTime, tx_done_callback );
+ if ( retval < 0 ) {
+ char * p = what_the_f( retval );
+ printk( "%sCould not queue xmission. rc=%d - %s\n",
+ pszMe, retval, p );
+ sending = 0;
+ break;
+ }
+ /* now have something on the diving board */
+ add_wait_queue( &wq_write, &wait );
+ tx_timer.expires = jiffies + ( HZ * 5 );
+ add_timer( &tx_timer );
+ while( 1 ) {
+ set_current_state( TASK_INTERRUPTIBLE );
+ if ( sending == 0 ) { /* it jumped into the pool */
+ del_timer( &tx_timer );
+ retval = last_tx_result;
+ if ( retval == 0 ) {
+ stSent += last_tx_size;
+ pUserBuffer += last_tx_size;
+ stCount -= last_tx_size;
+ }
+ else
+ printk( "%sxmission error rc=%d - %s\n",
+ pszMe, retval, what_the_f(retval) );
+ break;
+ }
+ else if ( signal_pending( current ) ) {
+ del_timer( &tx_timer );
+ printk( "%ssignal\n", pszMe );
+ retval = -ERESTARTSYS;
+ break;
+ }
+ schedule();
+ }
+ set_current_state( TASK_RUNNING );
+ remove_wait_queue( &wq_write, &wait );
+ }
+
+ up( &xmit_sem );
+
+ if ( 0 == retval )
+ retval = stSent;
+ return retval;
+}
+
+static unsigned int usbc_poll( struct file *pFile, poll_table * pWait )
+{
+ unsigned int retval = 0;
+
+ PRINTK( KERN_DEBUG "%poll()\n", pszMe );
+
+ poll_wait( pFile, &wq_poll, pWait );
+
+ if ( CIRC_CNT( rx_ring.in, rx_ring.out, RBUF_SIZE ) )
+ retval |= POLLIN | POLLRDNORM;
+ if ( sa1100_usb_xmitter_avail() )
+ retval |= POLLOUT | POLLWRNORM;
+ return retval;
+}
+
+static int usbc_ioctl( struct inode *pInode, struct file *pFile,
+ unsigned int nCmd, unsigned long argument )
+{
+ int retval = 0;
+
+ switch( nCmd ) {
+
+ case USBC_IOC_FLUSH_RECEIVER:
+ sa1100_usb_recv_reset();
+ rx_ring.in = rx_ring.out = 0;
+ break;
+
+ case USBC_IOC_FLUSH_TRANSMITTER:
+ sa1100_usb_send_reset();
+ break;
+
+ case USBC_IOC_FLUSH_ALL:
+ sa1100_usb_recv_reset();
+ rx_ring.in = rx_ring.out = 0;
+ sa1100_usb_send_reset();
+ break;
+
+ default:
+ retval = -ENOIOCTLCMD;
+ break;
+
+ }
+ return retval;
+}
+
+
+static int usbc_close( struct inode *pInode, struct file * pFile )
+{
+ PRINTK( KERN_DEBUG "%sclose()\n", pszMe );
+ if ( --usb_ref_count == 0 ) {
+ down( &xmit_sem );
+ sa1100_usb_stop();
+ free_txrx_buffers();
+ free_string_descriptors();
+ del_timer( &tx_timer );
+ sa1100_usb_close();
+ up( &xmit_sem );
+ }
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+#ifdef CONFIG_SA1100_EXTENEX1
+#include "../../../drivers/char/ex_gpio.h"
+void extenex_configured_notify_proc( void )
+{
+ if ( exgpio_play_string( "440,1:698,1" ) == -EAGAIN )
+ printk( "%sWanted to BEEP but ex_gpio not open\n", pszMe );
+}
+#endif
+//////////////////////////////////////////////////////////////////////////////
+// Initialization
+//////////////////////////////////////////////////////////////////////////////
+
+static struct file_operations usbc_fops = {
+ owner: THIS_MODULE,
+ open: usbc_open,
+ read: usbc_read,
+ write: usbc_write,
+ poll: usbc_poll,
+ ioctl: usbc_ioctl,
+ release: usbc_close,
+};
+
+static struct miscdevice usbc_misc_device = {
+ USBC_MINOR, "usb_char", &usbc_fops
+};
+
+/*
+ * usbc_init()
+ */
+
+int __init usbc_init( void )
+{
+ int rc;
+
+#if !defined( CONFIG_ARCH_SA1100 )
+ return -ENODEV;
+#endif
+
+ if ( (rc = misc_register( &usbc_misc_device )) != 0 ) {
+ printk( KERN_WARNING "%sCould not register device 10, "
+ "%d. (%d)\n", pszMe, USBC_MINOR, rc );
+ return -EBUSY;
+ }
+
+ // initialize wait queues
+ init_waitqueue_head( &wq_read );
+ init_waitqueue_head( &wq_write );
+ init_waitqueue_head( &wq_poll );
+
+ // initialize tx timeout timer
+ init_timer( &tx_timer );
+ tx_timer.function = tx_timeout;
+
+ printk( KERN_INFO "USB Function Character Driver Interface"
+ " - %s, (C) 2001, Extenex Corp.\n", VERSION
+ );
+
+ return rc;
+}
+
+void __exit usbc_exit( void )
+{
+}
+
+EXPORT_NO_SYMBOLS;
+
+module_init(usbc_init);
+module_exit(usbc_exit);
+
+
+
+// end: usb-char.c
+
+
+
diff -urN linux-2.4.26/arch/arm/mach-sa1100/usb-char.h linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb-char.h
--- linux-2.4.26/arch/arm/mach-sa1100/usb-char.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb-char.h 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2001 Extenex Corporation
+ *
+ * usb-char.h
+ *
+ * Character device emulation client for SA-1100 client usb core.
+ *
+ *
+ *
+ */
+#ifndef _USB_CHAR_H
+#define _USB_CHAR_H
+
+#define USBC_MAJOR 10 /* miscellaneous character device */
+#define USBC_MINOR 240 /* in the "reserved for local use" range */
+
+#define USBC_MAGIC 0x8E
+
+/* zap everything in receive ring buffer */
+#define USBC_IOC_FLUSH_RECEIVER _IO( USBC_MAGIC, 0x01 )
+
+/* reset transmitter */
+#define USBC_IOC_FLUSH_TRANSMITTER _IO( USBC_MAGIC, 0x02 )
+
+/* do both of above */
+#define USBC_IOC_FLUSH_ALL _IO( USBC_MAGIC, 0x03 )
+
+
+
+
+
+
+#endif /* _USB_CHAR_H */
+
diff -urN linux-2.4.26/arch/arm/mach-sa1100/usb-eth.c linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb-eth.c
--- linux-2.4.26/arch/arm/mach-sa1100/usb-eth.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb-eth.c 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,447 @@
+ /*
+ * Ethernet driver for the SA1100 USB client function
+ * Copyright (c) 2001 by Nicolas Pitre
+ *
+ * This code was loosely inspired by the original initial ethernet test driver
+ * Copyright (c) Compaq Computer Corporation, 1999
+ *
+ * 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.
+ *
+ * This is still work in progress...
+ *
+ * 19/02/2001 - Now we are compatible with generic usbnet driver. green@iXcelerator.com
+ * 09/03/2001 - Dropped 'framing' scheme, as it seems to cause a lot of problems with little benefit.
+ * Now, since we do not know what size of packet we are receiving
+ * last usb packet in sequence will always be less than max packet
+ * receive endpoint can accept.
+ * Now the only way to check correct start of frame is to compare
+ * MAC address. Also now we are stalling on each receive error.
+ *
+ * 15/03/2001 - Using buffer to get data from UDC. DMA needs to have 8 byte
+ * aligned buffer, but this breaks IP code (unaligned access).
+ *
+ * 01/04/2001 - stall endpoint operations appeared to be very unstable, so
+ * they are disabled now.
+ *
+ * 03/06/2001 - Readded "zerocopy" receive path (tunable).
+ *
+ */
+
+// Define DMA_NO_COPY if you want data to arrive directly into the
+// receive network buffers, instead of arriving into bounce buffer
+// and then get copied to network buffer.
+// This does not work correctly right now.
+#undef DMA_NO_COPY
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/timer.h>
+
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/random.h>
+
+#include "sa1100_usb.h"
+
+
+#define ETHERNET_VENDOR_ID 0x49f
+#define ETHERNET_PRODUCT_ID 0x505A
+#define MAX_PACKET 32768
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+
+// Should be global, so that insmod can change these
+int usb_rsize=64;
+int usb_wsize=64;
+
+static struct usbe_info_t {
+ struct net_device *dev;
+ u16 packet_id;
+ struct net_device_stats stats;
+} usbe_info;
+
+static char usb_eth_name[16] = "usbf";
+static struct net_device usb_eth_device;
+static struct sk_buff *cur_tx_skb, *next_tx_skb;
+static struct sk_buff *cur_rx_skb, *next_rx_skb;
+static volatile int terminating;
+#ifndef DMA_NO_COPY
+static char *dmabuf; // we need that, as dma expect it's buffers to be aligned on 8 bytes boundary
+#endif
+
+static int usb_change_mtu (struct net_device *net, int new_mtu)
+{
+ if (new_mtu <= sizeof (struct ethhdr) || new_mtu > MAX_PACKET)
+ return -EINVAL;
+ // no second zero-length packet read wanted after mtu-sized packets
+ if (((new_mtu + sizeof (struct ethhdr)) % usb_rsize) == 0)
+ return -EDOM;
+
+ net->mtu = new_mtu;
+ return 0;
+}
+
+static struct sk_buff *
+usb_new_recv_skb(void)
+{
+ struct sk_buff *skb = alloc_skb( 2 + sizeof (struct ethhdr) + usb_eth_device.mtu,GFP_ATOMIC);
+
+ if (skb) {
+ skb_reserve(skb, 2);
+ }
+ return skb;
+}
+
+static u8 bcast_hwaddr[ETH_ALEN]={0xff,0xff,0xff,0xff,0xff,0xff};
+static void
+usb_recv_callback(int flag, int size)
+{
+ struct sk_buff *skb;
+
+ if (terminating)
+ return;
+
+ skb = cur_rx_skb;
+
+ /* flag validation */
+ if (flag == 0) {
+ if ( skb_tailroom (skb) < size ) { // hey! we are overloaded!!!
+ usbe_info.stats.rx_over_errors++;
+ goto error;
+ }
+#ifndef DMA_NO_COPY
+ memcpy(skb->tail,dmabuf,size);
+#endif
+ skb_put(skb, size);
+ } else {
+ if (flag == -EIO) {
+ usbe_info.stats.rx_errors++;
+ }
+ goto error;
+ }
+
+ /* validate packet length */
+ if (size == usb_rsize ) {
+ /* packet not complete yet */
+ skb = NULL;
+ }
+
+ /*
+ * At this point skb is non null if we have a complete packet.
+ * If so take a fresh skb right away and restart USB receive without
+ * further delays, then process the packet. Otherwise resume USB
+ * receive on the current skb and exit.
+ */
+
+ if (skb)
+ cur_rx_skb = next_rx_skb;
+#ifndef DMA_NO_COPY
+ sa1100_usb_recv(dmabuf, usb_rsize,
+ usb_recv_callback);
+#else
+ sa1100_usb_recv(cur_rx_skb->tail, MIN(usb_rsize, skb_tailroom (cur_rx_skb)),
+ usb_recv_callback);
+#endif
+ if (!skb)
+ return;
+
+ next_rx_skb = usb_new_recv_skb();
+ if (!next_rx_skb) {
+ /*
+ * We can't aford loosing buffer space...
+ * So we drop the current packet and recycle its skb.
+ */
+ printk("%s: can't allocate new skb\n", __FUNCTION__);
+ usbe_info.stats.rx_dropped++;
+ skb_trim(skb, 0);
+ next_rx_skb = skb;
+ return;
+ }
+ if ( skb->len >= sizeof(struct ethhdr)) {
+ if (memcmp(skb->data,usb_eth_device.dev_addr,ETH_ALEN) && memcmp(skb->data,bcast_hwaddr,ETH_ALEN) ) {
+ // This frame is not for us. nor it is broadcast
+ usbe_info.stats.rx_frame_errors++;
+ kfree_skb(skb);
+ goto error;
+ }
+ }
+
+ if (skb->len) {
+ int status;
+// FIXME: eth_copy_and_csum "small" packets to new SKB (small < ~200 bytes) ?
+
+ skb->dev = &usb_eth_device;
+ skb->protocol = eth_type_trans (skb, &usb_eth_device);
+ usbe_info.stats.rx_packets++;
+ usbe_info.stats.rx_bytes += skb->len;
+ skb->ip_summed = CHECKSUM_NONE;
+ status = netif_rx (skb);
+ if (status != NET_RX_SUCCESS)
+ printk("netif_rx failed with code %d\n",status);
+ } else {
+error:
+ /*
+ * Error due to HW addr mismatch, or IO error.
+ * Recycle the current skb and reset USB reception.
+ */
+ skb_trim(cur_rx_skb, 0);
+// if ( flag == -EINTR || flag == -EAGAIN ) // only if we are coming out of stall
+#ifndef DMA_NO_COPY
+ sa1100_usb_recv(dmabuf, usb_rsize, usb_recv_callback);
+#else
+ sa1100_usb_recv(cur_rx_skb->tail, MIN(usb_rsize, skb_tailroom (cur_rx_skb)), usb_recv_callback);
+#endif
+ }
+}
+
+
+static void
+usb_send_callback(int flag, int size)
+{
+ struct net_device *dev = usbe_info.dev;
+ struct net_device_stats *stats;
+ struct sk_buff *skb=cur_tx_skb;
+ int ret;
+
+ if (terminating)
+ return;
+
+ stats = &usbe_info.stats;
+ switch (flag) {
+ case 0:
+ stats->tx_packets++;
+ stats->tx_bytes += size;
+ break;
+ case -EIO:
+ stats->tx_errors++;
+ break;
+ default:
+ stats->tx_dropped++;
+ break;
+ }
+
+ cur_tx_skb = next_tx_skb;
+ next_tx_skb = NULL;
+ dev_kfree_skb_irq(skb);
+ if (!cur_tx_skb)
+ return;
+
+ dev->trans_start = jiffies;
+ ret = sa1100_usb_send(cur_tx_skb->data, cur_tx_skb->len, usb_send_callback);
+ if (ret) {
+ /* If the USB core can't accept the packet, we drop it. */
+ dev_kfree_skb_irq(cur_tx_skb);
+ cur_tx_skb = NULL;
+ usbe_info.stats.tx_carrier_errors++;
+ }
+ netif_wake_queue(dev);
+}
+
+static int
+usb_eth_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ int ret;
+ unsigned long flags;
+
+ if (next_tx_skb) {
+ printk("%s: called with next_tx_skb != NULL\n", __FUNCTION__);
+ return 1;
+ }
+
+ if (skb_shared (skb)) {
+ struct sk_buff *skb2 = skb_unshare(skb, GFP_ATOMIC);
+ if (!skb2) {
+ usbe_info.stats.tx_dropped++;
+ dev_kfree_skb(skb);
+ return 1;
+ }
+ skb = skb2;
+ }
+
+ if ((skb->len % usb_wsize) == 0) {
+ skb->len++; // other side will ignore this one, anyway.
+ }
+
+ local_irq_save(flags);
+ if (cur_tx_skb) {
+ next_tx_skb = skb;
+ netif_stop_queue(dev);
+ } else {
+ cur_tx_skb = skb;
+ dev->trans_start = jiffies;
+ ret = sa1100_usb_send(skb->data, skb->len, usb_send_callback);
+ if (ret) {
+ /* If the USB core can't accept the packet, we drop it. */
+ dev_kfree_skb(skb);
+ cur_tx_skb = NULL;
+ usbe_info.stats.tx_carrier_errors++;
+ }
+ }
+ local_irq_restore(flags);
+ return 0;
+}
+
+static void
+usb_xmit_timeout(struct net_device *dev )
+{
+ sa1100_usb_send_reset();
+ dev->trans_start = jiffies;
+ netif_wake_queue(dev);
+}
+
+
+static int
+usb_eth_open(struct net_device *dev)
+{
+ terminating = 0;
+ cur_tx_skb = next_tx_skb = NULL;
+ cur_rx_skb = usb_new_recv_skb();
+ next_rx_skb = usb_new_recv_skb();
+ if (!cur_rx_skb || !next_rx_skb) {
+ printk("%s: can't allocate new skb\n", __FUNCTION__);
+ if (cur_rx_skb)
+ kfree_skb(cur_rx_skb);
+ if (next_rx_skb)
+ kfree_skb(next_rx_skb);
+ return -ENOMEM;;
+ }
+
+ MOD_INC_USE_COUNT;
+#ifndef DMA_NO_COPY
+ sa1100_usb_recv(dmabuf, usb_rsize, usb_recv_callback);
+#else
+ sa1100_usb_recv(cur_rx_skb->tail, MIN(usb_rsize, skb_tailroom (cur_rx_skb)),
+ usb_recv_callback);
+#endif
+ return 0;
+}
+
+static int
+usb_eth_release(struct net_device *dev)
+{
+ terminating = 1;
+ sa1100_usb_send_reset();
+ sa1100_usb_recv_reset();
+ if (cur_tx_skb)
+ kfree_skb(cur_tx_skb);
+ if (next_tx_skb)
+ kfree_skb(next_tx_skb);
+ if (cur_rx_skb)
+ kfree_skb(cur_rx_skb);
+ if (next_rx_skb)
+ kfree_skb(next_rx_skb);
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+static struct net_device_stats *
+usb_eth_stats(struct net_device *dev)
+{
+ struct usbe_info_t *priv = (struct usbe_info_t*) dev->priv;
+ struct net_device_stats *stats=NULL;
+
+ if (priv)
+ stats = &priv->stats;
+ return stats;
+}
+
+static int
+usb_eth_probe(struct net_device *dev)
+{
+ u8 node_id [ETH_ALEN];
+
+ get_random_bytes (node_id, sizeof node_id);
+ node_id [0] &= 0xfe; // clear multicast bit
+
+ /*
+ * Assign the hardware address of the board:
+ * generate it randomly, as there can be many such
+ * devices on the bus.
+ */
+ memcpy (dev->dev_addr, node_id, sizeof node_id);
+
+ dev->open = usb_eth_open;
+ dev->change_mtu = usb_change_mtu;
+ dev->stop = usb_eth_release;
+ dev->hard_start_xmit = usb_eth_xmit;
+ dev->get_stats = usb_eth_stats;
+ dev->watchdog_timeo = 1*HZ;
+ dev->tx_timeout = usb_xmit_timeout;
+ dev->priv = &usbe_info;
+
+ usbe_info.dev = dev;
+
+ /* clear the statistics */
+ memset(&usbe_info.stats, 0, sizeof(struct net_device_stats));
+
+ ether_setup(dev);
+ dev->flags &= ~IFF_MULTICAST;
+ dev->flags &= ~IFF_BROADCAST;
+ //dev->flags |= IFF_NOARP;
+
+ return 0;
+}
+
+#ifdef MODULE
+MODULE_PARM(usb_rsize, "1i");
+MODULE_PARM_DESC(usb_rsize, "number of bytes in packets from host to sa1100");
+MODULE_PARM(usb_wsize, "1i");
+MODULE_PARM_DESC(usb_wsize, "number of bytes in packets from sa1100 to host");
+#endif
+
+static int __init
+usb_eth_init(void)
+{
+ int rc;
+
+#ifndef DMA_NO_COPY
+ dmabuf = kmalloc( usb_rsize, GFP_KERNEL | GFP_DMA );
+ if (!dmabuf)
+ return -ENOMEM;
+#endif
+ strncpy(usb_eth_device.name, usb_eth_name, IFNAMSIZ);
+ usb_eth_device.init = usb_eth_probe;
+ if (register_netdev(&usb_eth_device) != 0)
+ return -EIO;
+
+ rc = sa1100_usb_open( "usb-eth" );
+ if ( rc == 0 ) {
+ string_desc_t * pstr;
+ desc_t * pd = sa1100_usb_get_descriptor_ptr();
+
+ pd->b.ep1.wMaxPacketSize = make_word( usb_rsize );
+ pd->b.ep2.wMaxPacketSize = make_word( usb_wsize );
+ pd->dev.idVendor = ETHERNET_VENDOR_ID;
+ pd->dev.idProduct = ETHERNET_PRODUCT_ID;
+ pstr = sa1100_usb_kmalloc_string_descriptor( "SA1100 USB NIC" );
+ if ( pstr ) {
+ sa1100_usb_set_string_descriptor( 1, pstr );
+ pd->dev.iProduct = 1;
+ }
+ rc = sa1100_usb_start();
+ }
+ return rc;
+}
+
+module_init(usb_eth_init);
+
+static void __exit
+usb_eth_cleanup(void)
+{
+ string_desc_t * pstr;
+ sa1100_usb_stop();
+ sa1100_usb_close();
+ if ( (pstr = sa1100_usb_get_string_descriptor(1)) != NULL )
+ kfree( pstr );
+#ifndef DMA_NO_COPY
+ kfree(dmabuf);
+#endif
+ unregister_netdev(&usb_eth_device);
+}
+
+module_exit(usb_eth_cleanup);
diff -urN linux-2.4.26/arch/arm/mach-sa1100/usb_ctl.c linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_ctl.c
--- linux-2.4.26/arch/arm/mach-sa1100/usb_ctl.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_ctl.c 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,774 @@
+ /*
+ * Copyright (C) Compaq Computer Corporation, 1998, 1999
+ * Copyright (C) Extenex Corporation, 2001
+ *
+ * usb_ctl.c
+ *
+ * SA1100 USB controller core driver.
+ *
+ * This file provides interrupt routing and overall coordination
+ * of the three endpoints in usb_ep0, usb_receive (1), and usb_send (2).
+ *
+ * Please see linux/Documentation/arm/SA1100/SA1100_USB for details.
+ *
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/tqueue.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <asm/io.h>
+#include <asm/dma.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+
+#include "sa1100_usb.h"
+#include "usb_ctl.h"
+
+//////////////////////////////////////////////////////////////////////////////
+// Prototypes
+//////////////////////////////////////////////////////////////////////////////
+
+int usbctl_next_state_on_event( int event );
+static void udc_int_hndlr(int, void *, struct pt_regs *);
+static void initialize_descriptors( void );
+static void soft_connect_hook( int enable );
+static void udc_disable(void);
+static void udc_enable(void);
+
+#if CONFIG_PROC_FS
+#define PROC_NODE_NAME "sausb"
+static int usbctl_read_proc(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+// Globals
+//////////////////////////////////////////////////////////////////////////////
+static const char pszMe[] = "usbctl: ";
+struct usb_info_t usbd_info; /* global to ep0, usb_recv, usb_send */
+
+/* device descriptors */
+static desc_t desc;
+
+#define MAX_STRING_DESC 8
+static string_desc_t * string_desc_array[ MAX_STRING_DESC ];
+static string_desc_t sd_zero; /* special sd_zero holds language codes */
+
+// called when configured
+static usb_notify_t configured_callback = NULL;
+
+enum { kStateZombie = 0, kStateZombieSuspend = 1,
+ kStateDefault = 2, kStateDefaultSuspend = 3,
+ kStateAddr = 4, kStateAddrSuspend = 5,
+ kStateConfig = 6, kStateConfigSuspend = 7
+};
+
+static int device_state_machine[8][6] = {
+// suspend reset resume adddr config deconfig
+/* zombie */ { kStateZombieSuspend, kStateDefault, kError, kError, kError, kError },
+/* zom sus */ { kError, kStateDefault, kStateZombie, kError, kError, kError },
+/* default */ { kStateDefaultSuspend, kError, kStateDefault, kStateAddr, kError, kError },
+/* def sus */ { kError, kStateDefault, kStateDefault, kError, kError, kError },
+/* addr */ { kStateAddrSuspend, kStateDefault, kError, kError, kStateConfig, kError },
+/* addr sus */{ kError, kStateDefault, kStateAddr, kError, kError, kError },
+/* config */ { kStateConfigSuspend, kStateDefault, kError, kError, kError, kStateAddr },
+/* cfg sus */ { kError, kStateDefault, kStateConfig, kError, kError, kError }
+};
+
+/* "device state" is the usb device framework state, as opposed to the
+ "state machine state" which is whatever the driver needs and is much
+ more fine grained
+*/
+static int sm_state_to_device_state[8] =
+// zombie zom suspend default default sus
+{ USB_STATE_POWERED, USB_STATE_SUSPENDED, USB_STATE_DEFAULT, USB_STATE_SUSPENDED,
+// addr addr sus config config sus
+ USB_STATE_ADDRESS, USB_STATE_SUSPENDED, USB_STATE_CONFIGURED, USB_STATE_SUSPENDED
+};
+
+static char * state_names[8] =
+{ "zombie", "zombie suspended", "default", "default suspended",
+ "address", "address suspended", "configured", "config suspended"
+};
+
+static char * event_names[6] =
+{ "suspend", "reset", "resume",
+ "address assigned", "configure", "de-configure"
+};
+
+static char * device_state_names[] =
+{ "not attached", "attached", "powered", "default",
+ "address", "configured", "suspended" };
+
+static int sm_state = kStateZombie;
+
+//////////////////////////////////////////////////////////////////////////////
+// Async
+//////////////////////////////////////////////////////////////////////////////
+static void core_kicker(void);
+
+static inline void enable_resume_mask_suspend( void );
+static inline void enable_suspend_mask_resume(void);
+
+static void
+udc_int_hndlr(int irq, void *dev_id, struct pt_regs *regs)
+{
+ __u32 status = Ser0UDCSR;
+
+ /* ReSeT Interrupt Request - UDC has been reset */
+ if ( status & UDCSR_RSTIR )
+ {
+ if ( usbctl_next_state_on_event( kEvReset ) != kError )
+ {
+ /* starting 20ms or so reset sequence now... */
+ printk("%sResetting\n", pszMe);
+ ep0_reset(); // just set state to idle
+ ep1_reset(); // flush dma, clear false stall
+ ep2_reset(); // flush dma, clear false stall
+ }
+ // mask reset ints, they flood during sequence, enable
+ // suspend and resume
+ Ser0UDCCR |= UDCCR_REM; // mask reset
+ Ser0UDCCR &= ~(UDCCR_SUSIM | UDCCR_RESIM); // enable suspend and resume
+ UDC_flip( Ser0UDCSR, status ); // clear all pending sources
+ return; // <-- no reason to continue if resetting
+ }
+ // else we have done something other than reset, so be sure reset enabled
+ UDC_clear( Ser0UDCCR, UDCCR_REM );
+
+ /* RESume Interrupt Request */
+ if ( status & UDCSR_RESIR )
+ {
+ usbctl_next_state_on_event( kEvResume );
+ core_kicker();
+ enable_suspend_mask_resume();
+ }
+
+ /* SUSpend Interrupt Request */
+ if ( status & UDCSR_SUSIR )
+ {
+ usbctl_next_state_on_event( kEvSuspend );
+ enable_resume_mask_suspend();
+ }
+
+ UDC_flip(Ser0UDCSR, status); // clear all pending sources
+
+ if (status & UDCSR_EIR)
+ ep0_int_hndlr();
+
+ if (status & UDCSR_RIR)
+ ep1_int_hndlr(status);
+
+ if (status & UDCSR_TIR)
+ ep2_int_hndlr(status);
+}
+
+static inline void enable_resume_mask_suspend( void )
+{
+ int i = 0;
+
+ while( 1 ) {
+ Ser0UDCCR |= UDCCR_SUSIM; // mask future suspend events
+ udelay( i );
+ if ( (Ser0UDCCR & UDCCR_SUSIM) || (Ser0UDCSR & UDCSR_RSTIR) )
+ break;
+ if ( ++i == 50 ) {
+ printk( "%senable_resume(): Could not set SUSIM %8.8X\n",
+ pszMe, Ser0UDCCR );
+ break;
+ }
+ }
+
+ i = 0;
+ while( 1 ) {
+ Ser0UDCCR &= ~UDCCR_RESIM;
+ udelay( i );
+ if ( ( Ser0UDCCR & UDCCR_RESIM ) == 0
+ ||
+ (Ser0UDCSR & UDCSR_RSTIR)
+ )
+ break;
+ if ( ++i == 50 ) {
+ printk( "%senable_resume(): Could not clear RESIM %8.8X\n",
+ pszMe, Ser0UDCCR );
+ break;
+ }
+ }
+}
+
+static inline void enable_suspend_mask_resume(void)
+{
+ int i = 0;
+ while( 1 ) {
+ Ser0UDCCR |= UDCCR_RESIM; // mask future resume events
+ udelay( i );
+ if ( Ser0UDCCR & UDCCR_RESIM || (Ser0UDCSR & UDCSR_RSTIR) )
+ break;
+ if ( ++i == 50 ) {
+ printk( "%senable_suspend(): Could not set RESIM %8.8X\n",
+ pszMe, Ser0UDCCR );
+ break;
+ }
+ }
+ i = 0;
+ while( 1 ) {
+ Ser0UDCCR &= ~UDCCR_SUSIM;
+ udelay( i );
+ if ( ( Ser0UDCCR & UDCCR_SUSIM ) == 0
+ ||
+ (Ser0UDCSR & UDCSR_RSTIR)
+ )
+ break;
+ if ( ++i == 50 ) {
+ printk( "%senable_suspend(): Could not clear SUSIM %8.8X\n",
+ pszMe, Ser0UDCCR );
+ break;
+ }
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// Public Interface
+//////////////////////////////////////////////////////////////////////////////
+
+/* Open SA usb core on behalf of a client, but don't start running */
+
+int
+sa1100_usb_open( const char * client )
+{
+ if ( usbd_info.client_name != NULL )
+ return -EBUSY;
+
+ usbd_info.client_name = (char*) client;
+ memset(&usbd_info.stats, 0, sizeof(struct usb_stats_t));
+ memset(string_desc_array, 0, sizeof(string_desc_array));
+
+ /* hack to start in zombie suspended state */
+ sm_state = kStateZombieSuspend;
+ usbd_info.state = USB_STATE_SUSPENDED;
+
+ /* create descriptors for enumeration */
+ initialize_descriptors();
+
+ printk( "%sOpened for %s\n", pszMe, client );
+ return 0;
+}
+
+/* Start running. Must have called usb_open (above) first */
+int
+sa1100_usb_start( void )
+{
+ if ( usbd_info.client_name == NULL ) {
+ printk( "%s%s - no client registered\n",
+ pszMe, __FUNCTION__ );
+ return -EPERM;
+ }
+
+ /* start UDC internal machinery running */
+ udc_enable();
+ udelay( 100 );
+
+ /* clear stall - receiver seems to start stalled? 19Jan01ww */
+ /* also clear other stuff just to be thurough 22Feb01ww */
+ UDC_clear(Ser0UDCCS1, UDCCS1_FST | UDCCS1_RPE | UDCCS1_RPC );
+ UDC_clear(Ser0UDCCS2, UDCCS2_FST | UDCCS2_TPE | UDCCS2_TPC );
+
+ /* mask everything */
+ Ser0UDCCR = 0xFC;
+
+ /* flush DMA and fire through some -EAGAINs */
+ ep1_init( usbd_info.dmach_rx );
+ ep2_init( usbd_info.dmach_tx );
+
+ /* give endpoint notification we are starting */
+ ep1_state_change_notify( USB_STATE_SUSPENDED );
+ ep2_state_change_notify( USB_STATE_SUSPENDED );
+
+ /* enable any platform specific hardware */
+ soft_connect_hook( 1 );
+
+ /* clear all top-level sources */
+ Ser0UDCSR = UDCSR_RSTIR | UDCSR_RESIR | UDCSR_EIR |
+ UDCSR_RIR | UDCSR_TIR | UDCSR_SUSIR ;
+
+ /* EXERIMENT - a short line in the spec says toggling this
+ ..bit diddles the internal state machine in the udc to
+ ..expect a suspend */
+ Ser0UDCCR |= UDCCR_RESIM;
+ /* END EXPERIMENT 10Feb01ww */
+
+ /* enable any platform specific hardware */
+ soft_connect_hook( 1 );
+
+ /* enable interrupts. If you are unplugged you will
+ immediately get a suspend interrupt. If you are plugged
+ and have a soft connect-circuit, you will get a reset
+ If you are plugged without a soft-connect, I think you
+ also get suspend. In short, start with suspend masked
+ and everything else enabled */
+ UDC_write( Ser0UDCCR, UDCCR_SUSIM );
+
+ printk( "%sStarted for %s\n", pszMe, usbd_info.client_name );
+ return 0;
+}
+
+/* Stop USB core from running */
+int
+sa1100_usb_stop( void )
+{
+ if ( usbd_info.client_name == NULL ) {
+ printk( "%s%s - no client registered\n",
+ pszMe, __FUNCTION__ );
+ return -EPERM;
+ }
+ /* mask everything */
+ Ser0UDCCR = 0xFC;
+ ep1_reset();
+ ep2_reset();
+ udc_disable();
+ printk( "%sStopped\n", pszMe );
+ return 0;
+}
+
+/* Tell SA core client is through using it */
+int
+sa1100_usb_close( void )
+{
+ if ( usbd_info.client_name == NULL ) {
+ printk( "%s%s - no client registered\n",
+ pszMe, __FUNCTION__ );
+ return -EPERM;
+ }
+ usbd_info.client_name = NULL;
+ printk( "%sClosed\n", pszMe );
+ return 0;
+}
+
+/* set a proc to be called when device is configured */
+usb_notify_t sa1100_set_configured_callback( usb_notify_t func )
+{
+ usb_notify_t retval = configured_callback;
+ configured_callback = func;
+ return retval;
+}
+
+/*====================================================
+ * Descriptor Manipulation.
+ * Use these between open() and start() above to setup
+ * the descriptors for your device.
+ *
+ */
+
+/* get pointer to static default descriptor */
+desc_t *
+sa1100_usb_get_descriptor_ptr( void ) { return &desc; }
+
+/* optional: set a string descriptor */
+int
+sa1100_usb_set_string_descriptor( int i, string_desc_t * p )
+{
+ int retval;
+ if ( i < MAX_STRING_DESC ) {
+ string_desc_array[i] = p;
+ retval = 0;
+ } else {
+ retval = -EINVAL;
+ }
+ return retval;
+}
+
+/* optional: get a previously set string descriptor */
+string_desc_t *
+sa1100_usb_get_string_descriptor( int i )
+{
+ return ( i < MAX_STRING_DESC )
+ ? string_desc_array[i]
+ : NULL;
+}
+
+
+/* optional: kmalloc and unicode up a string descriptor */
+string_desc_t *
+sa1100_usb_kmalloc_string_descriptor( const char * p )
+{
+ string_desc_t * pResult = NULL;
+
+ if ( p ) {
+ int len = strlen( p );
+ int uni_len = len * sizeof( __u16 );
+ pResult = (string_desc_t*) kmalloc( uni_len + 2, GFP_KERNEL ); /* ugh! */
+ if ( pResult != NULL ) {
+ int i;
+ pResult->bLength = uni_len + 2;
+ pResult->bDescriptorType = USB_DESC_STRING;
+ for( i = 0; i < len ; i++ ) {
+ pResult->bString[i] = make_word( (__u16) p[i] );
+ }
+ }
+ }
+ return pResult;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Exports to rest of driver
+//////////////////////////////////////////////////////////////////////////////
+
+/* called by the int handler here and the two endpoint files when interesting
+ .."events" happen */
+
+int
+usbctl_next_state_on_event( int event )
+{
+ int next_state = device_state_machine[ sm_state ][ event ];
+ if ( next_state != kError )
+ {
+ int next_device_state = sm_state_to_device_state[ next_state ];
+ printk( "%s%s --> [%s] --> %s. Device in %s state.\n",
+ pszMe, state_names[ sm_state ], event_names[ event ],
+ state_names[ next_state ], device_state_names[ next_device_state ] );
+
+ sm_state = next_state;
+ if ( usbd_info.state != next_device_state )
+ {
+ if ( configured_callback != NULL
+ &&
+ next_device_state == USB_STATE_CONFIGURED
+ &&
+ usbd_info.state != USB_STATE_SUSPENDED
+ ) {
+ configured_callback();
+ }
+ usbd_info.state = next_device_state;
+ ep1_state_change_notify( next_device_state );
+ ep2_state_change_notify( next_device_state );
+ }
+ }
+#if 0
+ else
+ printk( "%s%s --> [%s] --> ??? is an error.\n",
+ pszMe, state_names[ sm_state ], event_names[ event ] );
+#endif
+ return next_state;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Private Helpers
+//////////////////////////////////////////////////////////////////////////////
+
+/* setup default descriptors */
+
+static void
+initialize_descriptors(void)
+{
+ desc.dev.bLength = sizeof( device_desc_t );
+ desc.dev.bDescriptorType = USB_DESC_DEVICE;
+ desc.dev.bcdUSB = 0x100; /* 1.0 */
+ desc.dev.bDeviceClass = 0xFF; /* vendor specific */
+ desc.dev.bDeviceSubClass = 0;
+ desc.dev.bDeviceProtocol = 0;
+ desc.dev.bMaxPacketSize0 = 8; /* ep0 max fifo size */
+ desc.dev.idVendor = 0; /* vendor ID undefined */
+ desc.dev.idProduct = 0; /* product */
+ desc.dev.bcdDevice = 0; /* vendor assigned device release num */
+ desc.dev.iManufacturer = 0; /* index of manufacturer string */
+ desc.dev.iProduct = 0; /* index of product description string */
+ desc.dev.iSerialNumber = 0; /* index of string holding product s/n */
+ desc.dev.bNumConfigurations = 1;
+
+ desc.b.cfg.bLength = sizeof( config_desc_t );
+ desc.b.cfg.bDescriptorType = USB_DESC_CONFIG;
+ desc.b.cfg.wTotalLength = make_word_c( sizeof(struct cdb) );
+ desc.b.cfg.bNumInterfaces = 1;
+ desc.b.cfg.bConfigurationValue = 1;
+ desc.b.cfg.iConfiguration = 0;
+ desc.b.cfg.bmAttributes = USB_CONFIG_BUSPOWERED;
+ desc.b.cfg.MaxPower = USB_POWER( 500 );
+
+ desc.b.intf.bLength = sizeof( intf_desc_t );
+ desc.b.intf.bDescriptorType = USB_DESC_INTERFACE;
+ desc.b.intf.bInterfaceNumber = 0; /* unique intf index*/
+ desc.b.intf.bAlternateSetting = 0;
+ desc.b.intf.bNumEndpoints = 2;
+ desc.b.intf.bInterfaceClass = 0xFF; /* vendor specific */
+ desc.b.intf.bInterfaceSubClass = 0;
+ desc.b.intf.bInterfaceProtocol = 0;
+ desc.b.intf.iInterface = 0;
+
+ desc.b.ep1.bLength = sizeof( ep_desc_t );
+ desc.b.ep1.bDescriptorType = USB_DESC_ENDPOINT;
+ desc.b.ep1.bEndpointAddress = USB_EP_ADDRESS( 1, USB_OUT );
+ desc.b.ep1.bmAttributes = USB_EP_BULK;
+ desc.b.ep1.wMaxPacketSize = make_word_c( 64 );
+ desc.b.ep1.bInterval = 0;
+
+ desc.b.ep2.bLength = sizeof( ep_desc_t );
+ desc.b.ep2.bDescriptorType = USB_DESC_ENDPOINT;
+ desc.b.ep2.bEndpointAddress = USB_EP_ADDRESS( 2, USB_IN );
+ desc.b.ep2.bmAttributes = USB_EP_BULK;
+ desc.b.ep2.wMaxPacketSize = make_word_c( 64 );
+ desc.b.ep2.bInterval = 0;
+
+ /* set language */
+ /* See: http://www.usb.org/developers/data/USB_LANGIDs.pdf */
+ sd_zero.bDescriptorType = USB_DESC_STRING;
+ sd_zero.bLength = sizeof( string_desc_t );
+ sd_zero.bString[0] = make_word_c( 0x409 ); /* American English */
+ sa1100_usb_set_string_descriptor( 0, &sd_zero );
+}
+
+/* soft_connect_hook()
+ * Some devices have platform-specific circuitry to make USB
+ * not seem to be plugged in, even when it is. This allows
+ * software to control when a device 'appears' on the USB bus
+ * (after Linux has booted and this driver has loaded, for
+ * example). If you have such a circuit, control it here.
+ */
+static void
+soft_connect_hook( int enable )
+{
+#ifdef CONFIG_SA1100_EXTENEX1
+ if (machine_is_extenex1() ) {
+ if ( enable ) {
+ PPDR |= PPC_USB_SOFT_CON;
+ PPSR |= PPC_USB_SOFT_CON;
+ } else {
+ PPSR &= ~PPC_USB_SOFT_CON;
+ PPDR &= ~PPC_USB_SOFT_CON;
+ }
+ }
+#endif
+}
+
+/* disable the UDC at the source */
+static void
+udc_disable(void)
+{
+ soft_connect_hook( 0 );
+ UDC_set( Ser0UDCCR, UDCCR_UDD );
+}
+
+
+/* enable the udc at the source */
+static void
+udc_enable(void)
+{
+ UDC_clear(Ser0UDCCR, UDCCR_UDD);
+}
+
+// HACK DEBUG 3Mar01ww
+// Well, maybe not, it really seems to help! 08Mar01ww
+static void
+core_kicker( void )
+{
+ __u32 car = Ser0UDCAR;
+ __u32 imp = Ser0UDCIMP;
+ __u32 omp = Ser0UDCOMP;
+
+ UDC_set( Ser0UDCCR, UDCCR_UDD );
+ udelay( 300 );
+ UDC_clear(Ser0UDCCR, UDCCR_UDD);
+
+ Ser0UDCAR = car;
+ Ser0UDCIMP = imp;
+ Ser0UDCOMP = omp;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Proc Filesystem Support
+//////////////////////////////////////////////////////////////////////////////
+
+#if CONFIG_PROC_FS
+
+#define SAY( fmt, args... ) p += sprintf(p, fmt, ## args )
+#define SAYV( num ) p += sprintf(p, num_fmt, "Value", num )
+#define SAYC( label, yn ) p += sprintf(p, yn_fmt, label, yn )
+#define SAYS( label, v ) p += sprintf(p, cnt_fmt, label, v )
+
+static int usbctl_read_proc(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ const char * num_fmt = "%25.25s: %8.8lX\n";
+ const char * cnt_fmt = "%25.25s: %lu\n";
+ const char * yn_fmt = "%25.25s: %s\n";
+ const char * yes = "YES";
+ const char * no = "NO";
+ unsigned long v;
+ char * p = page;
+ int len;
+
+ SAY( "SA1100 USB Controller Core\n" );
+ SAY( "USB state: %s (%s) %d\n",
+ device_state_names[ sm_state_to_device_state[ sm_state ] ],
+ state_names[ sm_state ],
+ sm_state );
+
+ SAYS( "ep0 bytes read", usbd_info.stats.ep0_bytes_read );
+ SAYS( "ep0 bytes written", usbd_info.stats.ep0_bytes_written );
+ SAYS( "ep0 FIFO read failures", usbd_info.stats.ep0_fifo_write_failures );
+ SAYS( "ep0 FIFO write failures", usbd_info.stats.ep0_fifo_write_failures );
+
+ SAY( "\n" );
+
+ v = Ser0UDCAR;
+ SAY( "%25.25s: 0x%8.8lX - %ld\n", "Address Register", v, v );
+ v = Ser0UDCIMP;
+ SAY( "%25.25s: %ld (%8.8lX)\n", "IN max packet size", v+1, v );
+ v = Ser0UDCOMP;
+ SAY( "%25.25s: %ld (%8.8lX)\n", "OUT max packet size", v+1, v );
+
+ v = Ser0UDCCR;
+ SAY( "\nUDC Mask Register\n" );
+ SAYV( v );
+ SAYC( "UDC Active", ( v & UDCCR_UDA ) ? yes : no );
+ SAYC( "Suspend interrupts masked", ( v & UDCCR_SUSIM ) ? yes : no );
+ SAYC( "Resume interrupts masked", ( v & UDCCR_RESIM ) ? yes : no );
+ SAYC( "Reset interrupts masked", ( v & UDCCR_REM ) ? yes : no );
+
+ v = Ser0UDCSR;
+ SAY( "\nUDC Interrupt Request Register\n" );
+ SAYV( v );
+ SAYC( "Reset pending", ( v & UDCSR_RSTIR ) ? yes : no );
+ SAYC( "Suspend pending", ( v & UDCSR_SUSIR ) ? yes : no );
+ SAYC( "Resume pending", ( v & UDCSR_RESIR ) ? yes : no );
+ SAYC( "ep0 pending", ( v & UDCSR_EIR ) ? yes : no );
+ SAYC( "receiver pending", ( v & UDCSR_RIR ) ? yes : no );
+ SAYC( "tramsitter pending", ( v & UDCSR_TIR ) ? yes : no );
+
+#ifdef CONFIG_SA1100_EXTENEX1
+ SAYC( "\nSoft connect", (PPSR & PPC_USB_SOFT_CON) ? "Visible" : "Hidden" );
+#endif
+
+#if 0
+ v = Ser0UDCCS0;
+ SAY( "\nUDC Endpoint Zero Status Register\n" );
+ SAYV( v );
+ SAYC( "Out Packet Ready", ( v & UDCCS0_OPR ) ? yes : no );
+ SAYC( "In Packet Ready", ( v & UDCCS0_IPR ) ? yes : no );
+ SAYC( "Sent Stall", ( v & UDCCS0_SST ) ? yes : no );
+ SAYC( "Force Stall", ( v & UDCCS0_FST ) ? yes : no );
+ SAYC( "Data End", ( v & UDCCS0_DE ) ? yes : no );
+ SAYC( "Data Setup End", ( v & UDCCS0_SE ) ? yes : no );
+ SAYC( "Serviced (SO)", ( v & UDCCS0_SO ) ? yes : no );
+
+ v = Ser0UDCCS1;
+ SAY( "\nUDC Receiver Status Register\n" );
+ SAYV( v );
+ SAYC( "Receive Packet Complete", ( v & UDCCS1_RPC ) ? yes : no );
+ SAYC( "Sent Stall", ( v & UDCCS1_SST ) ? yes : no );
+ SAYC( "Force Stall", ( v & UDCCS1_FST ) ? yes : no );
+ SAYC( "Receive Packet Error", ( v & UDCCS1_RPE ) ? yes : no );
+ SAYC( "Receive FIFO not empty", ( v & UDCCS1_RNE ) ? yes : no );
+
+ v = Ser0UDCCS2;
+ SAY( "\nUDC Transmitter Status Register\n" );
+ SAYV( v );
+ SAYC( "FIFO has < 8 of 16 chars", ( v & UDCCS2_TFS ) ? yes : no );
+ SAYC( "Transmit Packet Complete", ( v & UDCCS2_TPC ) ? yes : no );
+ SAYC( "Transmit FIFO underrun", ( v & UDCCS2_TUR ) ? yes : no );
+ SAYC( "Transmit Packet Error", ( v & UDCCS2_TPE ) ? yes : no );
+ SAYC( "Sent Stall", ( v & UDCCS2_SST ) ? yes : no );
+ SAYC( "Force Stall", ( v & UDCCS2_FST ) ? yes : no );
+#endif
+
+ len = ( p - page ) - off;
+ if ( len < 0 )
+ len = 0;
+ *eof = ( len <=count ) ? 1 : 0;
+ *start = page + off;
+ return len;
+}
+
+#endif /* CONFIG_PROC_FS */
+
+//////////////////////////////////////////////////////////////////////////////
+// Module Initialization and Shutdown
+//////////////////////////////////////////////////////////////////////////////
+/*
+ * usbctl_init()
+ * Module load time. Allocate dma and interrupt resources. Setup /proc fs
+ * entry. Leave UDC disabled.
+ */
+int __init usbctl_init( void )
+{
+ int retval = 0;
+
+ udc_disable();
+
+ memset( &usbd_info, 0, sizeof( usbd_info ) );
+
+#if CONFIG_PROC_FS
+ create_proc_read_entry ( PROC_NODE_NAME, 0, NULL, usbctl_read_proc, NULL);
+#endif
+
+ /* setup rx dma */
+ retval = sa1100_request_dma(&usbd_info.dmach_rx, "USB receive", DMA_Ser0UDCRd);
+ if (retval) {
+ printk("%sunable to register for rx dma rc=%d\n", pszMe, retval );
+ goto err_rx_dma;
+ }
+
+ /* setup tx dma */
+ retval = sa1100_request_dma(&usbd_info.dmach_tx, "USB transmit", DMA_Ser0UDCWr);
+ if (retval) {
+ printk("%sunable to register for tx dma rc=%d\n",pszMe,retval);
+ goto err_tx_dma;
+ }
+
+ /* now allocate the IRQ. */
+ retval = request_irq(IRQ_Ser0UDC, udc_int_hndlr, SA_INTERRUPT,
+ "SA USB core", NULL);
+ if (retval) {
+ printk("%sCouldn't request USB irq rc=%d\n",pszMe, retval);
+ goto err_irq;
+ }
+
+ printk( "SA1100 USB Controller Core Initialized\n");
+ return 0;
+
+err_irq:
+ sa1100_free_dma(usbd_info.dmach_tx);
+ usbd_info.dmach_tx = 0;
+err_tx_dma:
+ sa1100_free_dma(usbd_info.dmach_rx);
+ usbd_info.dmach_rx = 0;
+err_rx_dma:
+ return retval;
+}
+/*
+ * usbctl_exit()
+ * Release DMA and interrupt resources
+ */
+void __exit usbctl_exit( void )
+{
+ printk("Unloading SA1100 USB Controller\n");
+
+ udc_disable();
+
+#if CONFIG_PROC_FS
+ remove_proc_entry ( PROC_NODE_NAME, NULL);
+#endif
+
+ sa1100_free_dma(usbd_info.dmach_rx);
+ sa1100_free_dma(usbd_info.dmach_tx);
+ free_irq(IRQ_Ser0UDC, NULL);
+}
+
+EXPORT_SYMBOL( sa1100_usb_open );
+EXPORT_SYMBOL( sa1100_usb_start );
+EXPORT_SYMBOL( sa1100_usb_stop );
+EXPORT_SYMBOL( sa1100_usb_close );
+
+
+EXPORT_SYMBOL( sa1100_usb_get_descriptor_ptr );
+EXPORT_SYMBOL( sa1100_usb_set_string_descriptor );
+EXPORT_SYMBOL( sa1100_usb_get_string_descriptor );
+EXPORT_SYMBOL( sa1100_usb_kmalloc_string_descriptor );
+
+
+module_init( usbctl_init );
+module_exit( usbctl_exit );
diff -urN linux-2.4.26/arch/arm/mach-sa1100/usb_ctl.h linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_ctl.h
--- linux-2.4.26/arch/arm/mach-sa1100/usb_ctl.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_ctl.h 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) Compaq Computer Corporation, 1998, 1999
+ * Copyright (C) Extenex Corporation 2001
+ *
+ * usb_ctl.h
+ *
+ * PRIVATE interface used to share info among components of the SA-1100 USB
+ * core: usb_ctl, usb_ep0, usb_recv and usb_send. Clients of the USB core
+ * should use sa1100_usb.h.
+ *
+ */
+
+#ifndef _USB_CTL_H
+#define _USB_CTL_H
+
+#include <asm/dma.h> /* dmach_t */
+
+
+/*
+ * These states correspond to those in the USB specification v1.0
+ * in chapter 8, Device Framework.
+ */
+enum { USB_STATE_NOTATTACHED=0, USB_STATE_ATTACHED=1,USB_STATE_POWERED=2,
+ USB_STATE_DEFAULT=3, USB_STATE_ADDRESS=4, USB_STATE_CONFIGURED=5,
+ USB_STATE_SUSPENDED=6};
+
+struct usb_stats_t {
+ unsigned long ep0_fifo_write_failures;
+ unsigned long ep0_bytes_written;
+ unsigned long ep0_fifo_read_failures;
+ unsigned long ep0_bytes_read;
+};
+
+struct usb_info_t
+{
+ char * client_name;
+ dmach_t dmach_tx, dmach_rx;
+ int state;
+ unsigned char address;
+ struct usb_stats_t stats;
+};
+
+/* in usb_ctl.c */
+extern struct usb_info_t usbd_info;
+
+/*
+ * Function Prototypes
+ */
+enum { kError=-1, kEvSuspend=0, kEvReset=1,
+ kEvResume=2, kEvAddress=3, kEvConfig=4, kEvDeConfig=5 };
+int usbctl_next_state_on_event( int event );
+
+/* endpoint zero */
+void ep0_reset(void);
+void ep0_int_hndlr(void);
+
+/* receiver */
+void ep1_state_change_notify( int new_state );
+int ep1_recv(void);
+int ep1_init(int chn);
+void ep1_int_hndlr(int status);
+void ep1_reset(void);
+void ep1_stall(void);
+
+/* xmitter */
+void ep2_state_change_notify( int new_state );
+void ep2_reset(void);
+int ep2_init(int chn);
+void ep2_int_hndlr(int status);
+void ep2_stall(void);
+
+#define UDC_write(reg, val) { \
+ int i = 10000; \
+ do { \
+ (reg) = (val); \
+ if (i-- <= 0) { \
+ printk( "%s [%d]: write %#x to %p (%#x) failed\n", \
+ __FUNCTION__, __LINE__, (val), &(reg), (reg)); \
+ break; \
+ } \
+ } while((reg) != (val)); \
+}
+
+#define UDC_set(reg, val) { \
+ int i = 10000; \
+ do { \
+ (reg) |= (val); \
+ if (i-- <= 0) { \
+ printk( "%s [%d]: set %#x of %p (%#x) failed\n", \
+ __FUNCTION__, __LINE__, (val), &(reg), (reg)); \
+ break; \
+ } \
+ } while(!((reg) & (val))); \
+}
+
+#define UDC_clear(reg, val) { \
+ int i = 10000; \
+ do { \
+ (reg) &= ~(val); \
+ if (i-- <= 0) { \
+ printk( "%s [%d]: clear %#x of %p (%#x) failed\n", \
+ __FUNCTION__, __LINE__, (val), &(reg), (reg)); \
+ break; \
+ } \
+ } while((reg) & (val)); \
+}
+
+#define UDC_flip(reg, val) { \
+ int i = 10000; \
+ (reg) = (val); \
+ do { \
+ (reg) = (val); \
+ if (i-- <= 0) { \
+ printk( "%s [%d]: flip %#x of %p (%#x) failed\n", \
+ __FUNCTION__, __LINE__, (val), &(reg), (reg)); \
+ break; \
+ } \
+ } while(((reg) & (val))); \
+}
+
+
+#define CHECK_ADDRESS { if ( Ser0UDCAR == 1 ) { printk("%s:%d I lost my address!!!\n",__FUNCTION__, __LINE__);}}
+#endif /* _USB_CTL_H */
diff -urN linux-2.4.26/arch/arm/mach-sa1100/usb_ep0.c linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_ep0.c
--- linux-2.4.26/arch/arm/mach-sa1100/usb_ep0.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_ep0.c 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,911 @@
+/*
+ * Copyright (C) Extenex Corporation 2001
+ * Much folklore gleaned from original code:
+ * Copyright (C) Compaq Computer Corporation, 1998, 1999
+ *
+ * usb_ep0.c - SA1100 USB controller driver.
+ * Endpoint zero management
+ *
+ * Please see:
+ * linux/Documentation/arm/SA1100/SA1100_USB
+ * for details. (Especially since Intel docs are full of
+ * errors about ep0 operation.) ward.willats@extenex.com.
+ *
+ * Intel also has a "Universal Serial Bus Client Device
+ * Validation for the StrongARM SA-1100 Microprocessor"
+ * document, which has flow charts and assembler test driver,
+ * but be careful, since it is just for validation and not
+ * a "real world" solution.
+ *
+ * A summary of three types of data-returning setups:
+ *
+ * 1. Setup request <= 8 bytes. That is, requests that can
+ * be fullfilled in one write to the FIFO. DE is set
+ * with IPR in queue_and_start_write(). (I don't know
+ * if there really are any of these!)
+ *
+ * 2. Setup requests > 8 bytes (requiring more than one
+ * IN to get back to the host), and we have at least
+ * as much or more data than the host requested. In
+ * this case we pump out everything we've got, and
+ * when the final interrupt comes in due to the UDC
+ * clearing the last IPR, we just set DE.
+ *
+ * 3. Setup requests > 8 bytes, but we don't have enough
+ * data to satisfy the request. In this case, we send
+ * everything we've got, and when the final interrupt
+ * comes in due to the UDC clearing the last IPR
+ * we write nothing to the FIFO and set both IPR and DE
+ * so the UDC sends an empty packet and forces the host
+ * to perform short packet retirement instead of stalling
+ * out.
+ *
+ */
+
+#include <linux/delay.h>
+#include "sa1100_usb.h" /* public interface */
+#include "usb_ctl.h" /* private stuff */
+
+
+// 1 == lots of trace noise, 0 = only "important' stuff
+#define VERBOSITY 0
+
+enum { true = 1, false = 0 };
+typedef int bool;
+#ifndef MIN
+#define MIN( a, b ) ((a)<(b)?(a):(b))
+#endif
+
+#if 1 && !defined( ASSERT )
+# define ASSERT(expr) \
+ if(!(expr)) { \
+ printk( "Assertion failed! %s,%s,%s,line=%d\n",\
+ #expr,__FILE__,__FUNCTION__,__LINE__); \
+ }
+#else
+# define ASSERT(expr)
+#endif
+
+#if VERBOSITY
+#define PRINTKD(fmt, args...) printk( fmt , ## args)
+#else
+#define PRINTKD(fmt, args...)
+#endif
+
+/*================================================
+ * USB Protocol Stuff
+ */
+
+/* Request Codes */
+enum { GET_STATUS=0, CLEAR_FEATURE=1, SET_FEATURE=3,
+ SET_ADDRESS=5, GET_DESCRIPTOR=6, SET_DESCRIPTOR=7,
+ GET_CONFIGURATION=8, SET_CONFIGURATION=9, GET_INTERFACE=10,
+ SET_INTERFACE=11 };
+
+
+/* USB Device Requests */
+typedef struct
+{
+ __u8 bmRequestType;
+ __u8 bRequest;
+ __u16 wValue;
+ __u16 wIndex;
+ __u16 wLength;
+} usb_dev_request_t __attribute__ ((packed));
+
+/***************************************************************************
+Prototypes
+***************************************************************************/
+/* "setup handlers" -- the main functions dispatched to by the
+ .. isr. These represent the major "modes" of endpoint 0 operaton */
+static void sh_setup_begin(void); /* setup begin (idle) */
+static void sh_write( void ); /* writing data */
+static void sh_write_with_empty_packet( void ); /* empty packet at end of xfer*/
+/* called before both sh_write routines above */
+static void common_write_preamble( void );
+
+/* other subroutines */
+static __u32 queue_and_start_write( void * p, int req, int act );
+static void write_fifo( void );
+static int read_fifo( usb_dev_request_t * p );
+static void get_descriptor( usb_dev_request_t * pReq );
+
+/* some voodo helpers 01Mar01ww */
+static void set_cs_bits( __u32 set_bits );
+static void set_de( void );
+static void set_ipr( void );
+static void set_ipr_and_de( void );
+static bool clear_opr( void );
+
+/***************************************************************************
+Inline Helpers
+***************************************************************************/
+
+/* Data extraction from usb_request_t fields */
+enum { kTargetDevice=0, kTargetInterface=1, kTargetEndpoint=2 };
+static inline int request_target( __u8 b ) { return (int) ( b & 0x0F); }
+
+static inline int windex_to_ep_num( __u16 w ) { return (int) ( w & 0x000F); }
+inline int type_code_from_request( __u8 by ) { return (( by >> 4 ) & 3); }
+
+/* following is hook for self-powered flag in GET_STATUS. Some devices
+ .. might like to override and return real info */
+static inline bool self_powered_hook( void ) { return true; }
+
+/* print string descriptor */
+static inline void psdesc( string_desc_t * p )
+{
+ int i;
+ int nchars = ( p->bLength - 2 ) / sizeof( __u16 );
+ printk( "'" );
+ for( i = 0 ; i < nchars ; i++ ) {
+ printk( "%c", (char) p->bString[i] );
+ }
+ printk( "'\n" );
+}
+
+
+#if VERBOSITY
+/* "pcs" == "print control status" */
+static inline void pcs( void )
+{
+ __u32 foo = Ser0UDCCS0;
+ printk( "%8.8X: %s %s %s %s\n",
+ foo,
+ foo & UDCCS0_SE ? "SE" : "",
+ foo & UDCCS0_OPR ? "OPR" : "",
+ foo & UDCCS0_IPR ? "IPR" : "",
+ foo & UDCCS0_SST ? "SST" : ""
+ );
+}
+static inline void preq( usb_dev_request_t * pReq )
+{
+ static char * tnames[] = { "dev", "intf", "ep", "oth" };
+ static char * rnames[] = { "std", "class", "vendor", "???" };
+ char * psz;
+ switch( pReq->bRequest ) {
+ case GET_STATUS: psz = "get stat"; break;
+ case CLEAR_FEATURE: psz = "clr feat"; break;
+ case SET_FEATURE: psz = "set feat"; break;
+ case SET_ADDRESS: psz = "set addr"; break;
+ case GET_DESCRIPTOR: psz = "get desc"; break;
+ case SET_DESCRIPTOR: psz = "set desc"; break;
+ case GET_CONFIGURATION: psz = "get cfg"; break;
+ case SET_CONFIGURATION: psz = "set cfg"; break;
+ case GET_INTERFACE: psz = "get intf"; break;
+ case SET_INTERFACE: psz = "set intf"; break;
+ default: psz = "unknown"; break;
+ }
+ printk( "- [%s: %s req to %s. dir=%s]\n", psz,
+ rnames[ (pReq->bmRequestType >> 5) & 3 ],
+ tnames[ pReq->bmRequestType & 3 ],
+ ( pReq->bmRequestType & 0x80 ) ? "in" : "out" );
+}
+
+#else
+static inline void pcs( void ){}
+static inline void preq( void ){}
+#endif
+
+/***************************************************************************
+Globals
+***************************************************************************/
+static const char pszMe[] = "usbep0: ";
+
+/* pointer to current setup handler */
+static void (*current_handler)(void) = sh_setup_begin;
+
+/* global write struct to keep write
+ ..state around across interrupts */
+static struct {
+ unsigned char *p;
+ int bytes_left;
+} wr;
+
+/***************************************************************************
+Public Interface
+***************************************************************************/
+
+/* reset received from HUB (or controller just went nuts and reset by itself!)
+ so udc core has been reset, track this state here */
+void
+ep0_reset(void)
+{
+ /* reset state machine */
+ current_handler = sh_setup_begin;
+ wr.p = NULL;
+ wr.bytes_left = 0;
+ usbd_info.address=0;
+}
+
+/* handle interrupt for endpoint zero */
+void
+ep0_int_hndlr( void )
+{
+ PRINTKD( "/\\(%d)\n", Ser0UDCAR );
+ pcs();
+
+ /* if not in setup begin, we are returning data.
+ execute a common preamble to both write handlers
+ */
+ if ( current_handler != sh_setup_begin )
+ common_write_preamble();
+
+ (*current_handler)();
+
+ PRINTKD( "---\n" );
+ pcs();
+ PRINTKD( "\\/\n" );
+}
+
+/***************************************************************************
+Setup Handlers
+***************************************************************************/
+/*
+ * sh_setup_begin()
+ * This setup handler is the "idle" state of endpoint zero. It looks for OPR
+ * (OUT packet ready) to see if a setup request has been been received from the
+ * host. Requests without a return data phase are immediately handled. Otherwise,
+ * in the case of GET_XXXX the handler may be set to one of the sh_write_xxxx
+ * data pumpers if more than 8 bytes need to get back to the host.
+ *
+ */
+static void
+sh_setup_begin( void )
+{
+ unsigned char status_buf[2]; /* returned in GET_STATUS */
+ usb_dev_request_t req;
+ int request_type;
+ int n;
+ __u32 cs_bits;
+ __u32 address;
+ __u32 cs_reg_in = Ser0UDCCS0;
+
+ if (cs_reg_in & UDCCS0_SST) {
+ PRINTKD( "%ssetup begin: sent stall. Continuing\n", pszMe );
+ set_cs_bits( UDCCS0_SST );
+ }
+
+ if ( cs_reg_in & UDCCS0_SE ) {
+ PRINTKD( "%ssetup begin: Early term of setup. Continuing\n", pszMe );
+ set_cs_bits( UDCCS0_SSE ); /* clear setup end */
+ }
+
+ /* Be sure out packet ready, otherwise something is wrong */
+ if ( (cs_reg_in & UDCCS0_OPR) == 0 ) {
+ /* we can get here early...if so, we'll int again in a moment */
+ PRINTKD( "%ssetup begin: no OUT packet available. Exiting\n", pszMe );
+ goto sh_sb_end;
+ }
+
+ /* read the setup request */
+ n = read_fifo( &req );
+ if ( n != sizeof( req ) ) {
+ printk( "%ssetup begin: fifo READ ERROR wanted %d bytes got %d. "
+ " Stalling out...\n",
+ pszMe, sizeof( req ), n );
+ /* force stall, serviced out */
+ set_cs_bits( UDCCS0_FST | UDCCS0_SO );
+ goto sh_sb_end;
+ }
+
+ /* Is it a standard request? (not vendor or class request) */
+ request_type = type_code_from_request( req.bmRequestType );
+ if ( request_type != 0 ) {
+ printk( "%ssetup begin: unsupported bmRequestType: %d ignored\n",
+ pszMe, request_type );
+ set_cs_bits( UDCCS0_DE | UDCCS0_SO );
+ goto sh_sb_end;
+ }
+
+#if VERBOSITY
+ {
+ unsigned char * pdb = (unsigned char *) &req;
+ PRINTKD( "%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X ",
+ pdb[0], pdb[1], pdb[2], pdb[3], pdb[4], pdb[5], pdb[6], pdb[7]
+ );
+ preq( &req );
+ }
+#endif
+
+ /* Handle it */
+ switch( req.bRequest ) {
+
+ /* This first bunch have no data phase */
+
+ case SET_ADDRESS:
+ address = (__u32) (req.wValue & 0x7F);
+ /* when SO and DE sent, UDC will enter status phase and ack,
+ ..propagating new address to udc core. Next control transfer
+ ..will be on the new address. You can't see the change in a
+ ..read back of CAR until then. (about 250us later, on my box).
+ ..The original Intel driver sets S0 and DE and code to check
+ ..that address has propagated here. I tried this, but it
+ ..would only work sometimes! The rest of the time it would
+ ..never propagate and we'd spin forever. So now I just set
+ ..it and pray...
+ */
+ Ser0UDCAR = address;
+ usbd_info.address = address;
+ usbctl_next_state_on_event( kEvAddress );
+ set_cs_bits( UDCCS0_SO | UDCCS0_DE ); /* no data phase */
+ printk( "%sI have been assigned address: %d\n", pszMe, address );
+ break;
+
+
+ case SET_CONFIGURATION:
+ if ( req.wValue == 1 ) {
+ /* configured */
+ if (usbctl_next_state_on_event( kEvConfig ) != kError){
+ /* (re)set the out and in max packet sizes */
+ desc_t * pDesc = sa1100_usb_get_descriptor_ptr();
+ __u32 out = __le16_to_cpu( pDesc->b.ep1.wMaxPacketSize );
+ __u32 in = __le16_to_cpu( pDesc->b.ep2.wMaxPacketSize );
+ Ser0UDCOMP = ( out - 1 );
+ Ser0UDCIMP = ( in - 1 );
+ printk( "%sConfigured (OMP=%8.8X IMP=%8.8X)\n", pszMe, out, in );
+ }
+ } else if ( req.wValue == 0 ) {
+ /* de-configured */
+ if (usbctl_next_state_on_event( kEvDeConfig ) != kError )
+ printk( "%sDe-Configured\n", pszMe );
+ } else {
+ printk( "%ssetup phase: Unknown "
+ "\"set configuration\" data %d\n",
+ pszMe, req.wValue );
+ }
+ set_cs_bits( UDCCS0_SO | UDCCS0_DE ); /* no data phase */
+ break;
+
+ case CLEAR_FEATURE:
+ /* could check data length, direction...26Jan01ww */
+ if ( req.wValue == 0 ) { /* clearing ENDPOINT_HALT/STALL */
+ int ep = windex_to_ep_num( req.wIndex );
+ if ( ep == 1 ) {
+ printk( "%sclear feature \"endpoint halt\" "
+ " on receiver\n", pszMe );
+ ep1_reset();
+ }
+ else if ( ep == 2 ) {
+ printk( "%sclear feature \"endpoint halt\" "
+ "on xmitter\n", pszMe );
+ ep2_reset();
+ } else {
+ printk( "%sclear feature \"endpoint halt\" "
+ "on unsupported ep # %d\n",
+ pszMe, ep );
+ }
+ } else {
+ printk( "%sUnsupported feature selector (%d) "
+ "in clear feature. Ignored.\n" ,
+ pszMe, req.wValue );
+ }
+ set_cs_bits( UDCCS0_SO | UDCCS0_DE ); /* no data phase */
+ break;
+
+ case SET_FEATURE:
+ if ( req.wValue == 0 ) { /* setting ENDPOINT_HALT/STALL */
+ int ep = windex_to_ep_num( req.wValue );
+ if ( ep == 1 ) {
+ printk( "%set feature \"endpoint halt\" "
+ "on receiver\n", pszMe );
+ ep1_stall();
+ }
+ else if ( ep == 2 ) {
+ printk( "%sset feature \"endpoint halt\" "
+ " on xmitter\n", pszMe );
+ ep2_stall();
+ } else {
+ printk( "%sset feature \"endpoint halt\" "
+ "on unsupported ep # %d\n",
+ pszMe, ep );
+ }
+ }
+ else {
+ printk( "%sUnsupported feature selector "
+ "(%d) in set feature\n",
+ pszMe, req.wValue );
+ }
+ set_cs_bits( UDCCS0_SO | UDCCS0_DE ); /* no data phase */
+ break;
+
+
+ /* The rest have a data phase that writes back to the host */
+ case GET_STATUS:
+ /* return status bit flags */
+ status_buf[0] = status_buf[1] = 0;
+ n = request_target(req.bmRequestType);
+ switch( n ) {
+ case kTargetDevice:
+ if ( self_powered_hook() )
+ status_buf[0] |= 1;
+ break;
+ case kTargetInterface:
+ break;
+ case kTargetEndpoint:
+ /* return stalled bit */
+ n = windex_to_ep_num( req.wIndex );
+ if ( n == 1 )
+ status_buf[0] |= (Ser0UDCCS1 & UDCCS1_FST) >> 4;
+ else if ( n == 2 )
+ status_buf[0] |= (Ser0UDCCS2 & UDCCS2_FST) >> 5;
+ else {
+ printk( "%sUnknown endpoint (%d) "
+ "in GET_STATUS\n", pszMe, n );
+ }
+ break;
+ default:
+ printk( "%sUnknown target (%d) in GET_STATUS\n",
+ pszMe, n );
+ /* fall thru */
+ break;
+ }
+ cs_bits = queue_and_start_write( status_buf,
+ req.wLength,
+ sizeof( status_buf ) );
+ set_cs_bits( cs_bits );
+ break;
+ case GET_DESCRIPTOR:
+ get_descriptor( &req );
+ break;
+
+ case GET_CONFIGURATION:
+ status_buf[0] = (usbd_info.state == USB_STATE_CONFIGURED)
+ ? 1
+ : 0;
+ cs_bits = queue_and_start_write( status_buf, req.wLength, 1 );
+ set_cs_bits( cs_bits );
+ break;
+ case GET_INTERFACE:
+ printk( "%sfixme: get interface not supported\n", pszMe );
+ cs_bits = queue_and_start_write( NULL, req.wLength, 0 );
+ set_cs_bits( cs_bits );
+ break;
+ case SET_INTERFACE:
+ printk( "%sfixme: set interface not supported\n", pszMe );
+ set_cs_bits( UDCCS0_DE | UDCCS0_SO );
+ break;
+ default :
+ printk("%sunknown request 0x%x\n", pszMe, req.bRequest);
+ break;
+ } /* switch( bRequest ) */
+
+sh_sb_end:
+ return;
+
+}
+/*
+ * common_wrtie_preamble()
+ * Called before execution of sh_write() or sh_write_with_empty_packet()
+ * Handles common abort conditions.
+ *
+ */
+static void common_write_preamble( void )
+{
+ /* If "setup end" has been set, the usb controller has
+ ..terminated a setup transaction before we set DE. This
+ ..happens during enumeration with some hosts. For example,
+ ..the host will ask for our device descriptor and specify
+ ..a return of 64 bytes. When we hand back the first 8, the
+ ..host will know our max packet size and turn around and
+ ..issue a new setup immediately. This causes the UDC to auto-ack
+ ..the new setup and set SE. We must then "unload" (process)
+ ..the new setup, which is what will happen after this preamble
+ ..is finished executing.
+ */
+ __u32 cs_reg_in = Ser0UDCCS0;
+
+ if ( cs_reg_in & UDCCS0_SE ) {
+ PRINTKD( "%swrite_preamble(): Early termination of setup\n", pszMe );
+ Ser0UDCCS0 = UDCCS0_SSE; /* clear setup end */
+ current_handler = sh_setup_begin;
+ }
+
+ if ( cs_reg_in & UDCCS0_SST ) {
+ PRINTKD( "%swrite_preamble(): UDC sent stall\n", pszMe );
+ Ser0UDCCS0 = UDCCS0_SST; /* clear setup end */
+ current_handler = sh_setup_begin;
+ }
+
+ if ( cs_reg_in & UDCCS0_OPR ) {
+ PRINTKD( "%swrite_preamble(): see OPR. Stopping write to "
+ "handle new SETUP\n", pszMe );
+ /* very rarely, you can get OPR and leftover IPR. Try to clear */
+ UDC_clear( Ser0UDCCS0, UDCCS0_IPR );
+ current_handler = sh_setup_begin;
+ }
+}
+
+/*
+ * sh_write()
+ * This is the setup handler when we are in the data return phase of
+ * a setup request and have as much (or more) data than the host
+ * requested. If we enter this routine and bytes left is zero, the
+ * last data packet has gone (int is because IPR was just cleared)
+ * so we just set DE and reset. Otheriwse, we write another packet
+ * and set IPR.
+ */
+static void sh_write()
+{
+ PRINTKD( "W\n" );
+
+ if ( Ser0UDCCS0 & UDCCS0_IPR ) {
+ PRINTKD( "%ssh_write(): IPR set, exiting\n", pszMe );
+ return;
+ }
+
+ /* If bytes left is zero, we are coming in on the
+ ..interrupt after the last packet went out. And
+ ..we know we don't have to empty packet this transfer
+ ..so just set DE and we are done */
+
+ if ( 0 == wr.bytes_left ) {
+ /* that's it, so data end */
+ set_de();
+ wr.p = NULL; /* be anal */
+ current_handler = sh_setup_begin;
+ } else {
+ /* Otherwise, more data to go */
+ write_fifo();
+ set_ipr();
+ }
+}
+/*
+ * sh_write_with_empty_packet()
+ * This is the setup handler when we don't have enough data to
+ * satisfy the host's request. After we send everything we've got
+ * we must send an empty packet (by setting IPR and DE) so the
+ * host can perform "short packet retirement" and not stall.
+ *
+ */
+static void sh_write_with_empty_packet( void )
+{
+ __u32 cs_reg_out = 0;
+ PRINTKD( "WE\n" );
+
+ if ( Ser0UDCCS0 & UDCCS0_IPR ) {
+ PRINTKD( "%ssh_write(): IPR set, exiting\n", pszMe );
+ return;
+ }
+
+ /* If bytes left is zero, we are coming in on the
+ ..interrupt after the last packet went out.
+ ..we must do short packet suff, so set DE and IPR
+ */
+
+ if ( 0 == wr.bytes_left ) {
+ set_ipr_and_de();
+ wr.p = NULL;
+ current_handler = sh_setup_begin;
+ PRINTKD( "%ssh_write empty() Sent empty packet \n", pszMe );
+ } else {
+ write_fifo(); /* send data */
+ set_ipr(); /* flag a packet is ready */
+ }
+ Ser0UDCCS0 = cs_reg_out;
+}
+
+/***************************************************************************
+Other Private Subroutines
+***************************************************************************/
+/*
+ * queue_and_start_write()
+ * p == data to send
+ * req == bytes host requested
+ * act == bytes we actually have
+ * Returns: bits to be flipped in ep0 control/status register
+ *
+ * Called from sh_setup_begin() to begin a data return phase. Sets up the
+ * global "wr"-ite structure and load the outbound FIFO with data.
+ * If can't send all the data, set appropriate handler for next interrupt.
+ *
+ */
+static __u32 queue_and_start_write( void * in, int req, int act )
+{
+ __u32 cs_reg_bits = UDCCS0_IPR;
+ unsigned char * p = (unsigned char*) in;
+
+ PRINTKD( "Qr=%d a=%d\n",req,act );
+
+ /* thou shalt not enter data phase until the serviced OUT is clear */
+ if ( ! clear_opr() ) {
+ printk( "%sSO did not clear OPR\n", pszMe );
+ return ( UDCCS0_DE | UDCCS0_SO ) ;
+ }
+ wr.p = p;
+ wr.bytes_left = MIN( act, req );
+
+ write_fifo();
+
+ if ( 0 == wr.bytes_left ) {
+ cs_reg_bits |= UDCCS0_DE; /* out in 1 so data end */
+ wr.p = NULL; /* be anal */
+ }
+ else if ( act < req ) /* we are going to short-change host */
+ current_handler = sh_write_with_empty_packet; /* so need nul to not stall */
+ else /* we have as much or more than requested */
+ current_handler = sh_write;
+
+ return cs_reg_bits; /* note: IPR was set uncondtionally at start of routine */
+}
+/*
+ * write_fifo()
+ * Stick bytes in the 8 bytes endpoint zero FIFO.
+ * This version uses a variety of tricks to make sure the bytes
+ * are written correctly. 1. The count register is checked to
+ * see if the byte went in, and the write is attempted again
+ * if not. 2. An overall counter is used to break out so we
+ * don't hang in those (rare) cases where the UDC reverses
+ * direction of the FIFO underneath us without notification
+ * (in response to host aborting a setup transaction early).
+ *
+ */
+static void write_fifo( void )
+{
+ int bytes_this_time = MIN( wr.bytes_left, 8 );
+ int bytes_written = 0;
+ int i=0;
+
+ PRINTKD( "WF=%d: ", bytes_this_time );
+
+ while( bytes_this_time-- ) {
+ PRINTKD( "%2.2X ", *wr.p );
+ i = 0;
+ do {
+ Ser0UDCD0 = *wr.p;
+ udelay( 20 ); /* voodo 28Feb01ww */
+ i++;
+ } while( Ser0UDCWC == bytes_written && i < 10 );
+ if ( i == 50 ) {
+ printk( "%swrite_fifo: write failure\n", pszMe );
+ usbd_info.stats.ep0_fifo_write_failures++;
+ }
+
+ wr.p++;
+ bytes_written++;
+ }
+ wr.bytes_left -= bytes_written;
+
+ /* following propagation voodo so maybe caller writing IPR in
+ ..a moment might actually get it to stick 28Feb01ww */
+ udelay( 300 );
+
+ usbd_info.stats.ep0_bytes_written += bytes_written;
+ PRINTKD( "L=%d WCR=%8.8X\n", wr.bytes_left, Ser0UDCWC );
+}
+/*
+ * read_fifo()
+ * Read 1-8 bytes out of FIFO and put in request.
+ * Called to do the initial read of setup requests
+ * from the host. Return number of bytes read.
+ *
+ * Like write fifo above, this driver uses multiple
+ * reads checked agains the count register with an
+ * overall timeout.
+ *
+ */
+static int
+read_fifo( usb_dev_request_t * request )
+{
+ int bytes_read = 0;
+ int fifo_count;
+ int i;
+
+ unsigned char * pOut = (unsigned char*) request;
+
+ fifo_count = ( Ser0UDCWC & 0xFF );
+
+ ASSERT( fifo_count <= 8 );
+ PRINTKD( "RF=%d ", fifo_count );
+
+ while( fifo_count-- ) {
+ i = 0;
+ do {
+ *pOut = (unsigned char) Ser0UDCD0;
+ udelay( 10 );
+ } while( ( Ser0UDCWC & 0xFF ) != fifo_count && i < 10 );
+ if ( i == 10 ) {
+ printk( "%sread_fifo(): read failure\n", pszMe );
+ usbd_info.stats.ep0_fifo_read_failures++;
+ }
+ pOut++;
+ bytes_read++;
+ }
+
+ PRINTKD( "fc=%d\n", bytes_read );
+ usbd_info.stats.ep0_bytes_read++;
+ return bytes_read;
+}
+
+/*
+ * get_descriptor()
+ * Called from sh_setup_begin to handle data return
+ * for a GET_DESCRIPTOR setup request.
+ */
+static void get_descriptor( usb_dev_request_t * pReq )
+{
+ __u32 cs_bits = 0;
+ string_desc_t * pString;
+ ep_desc_t * pEndpoint;
+
+ desc_t * pDesc = sa1100_usb_get_descriptor_ptr();
+ int type = pReq->wValue >> 8;
+ int idx = pReq->wValue & 0xFF;
+
+ switch( type ) {
+ case USB_DESC_DEVICE:
+ cs_bits =
+ queue_and_start_write( &pDesc->dev,
+ pReq->wLength,
+ pDesc->dev.bLength );
+ break;
+
+ // return config descriptor buffer, cfg, intf, 2 ep
+ case USB_DESC_CONFIG:
+ cs_bits =
+ queue_and_start_write( &pDesc->b,
+ pReq->wLength,
+ sizeof( struct cdb ) );
+ break;
+
+ // not quite right, since doesn't do language code checking
+ case USB_DESC_STRING:
+ pString = sa1100_usb_get_string_descriptor( idx );
+ if ( pString ) {
+ if ( idx != 0 ) { // if not language index
+ printk( "%sReturn string %d: ", pszMe, idx );
+ psdesc( pString );
+ }
+ cs_bits =
+ queue_and_start_write( pString,
+ pReq->wLength,
+ pString->bLength );
+ }
+ else {
+ printk("%sunkown string index %d Stall.\n", pszMe, idx );
+ cs_bits = ( UDCCS0_DE | UDCCS0_SO | UDCCS0_FST );
+ }
+ break;
+
+ case USB_DESC_INTERFACE:
+ if ( idx == pDesc->b.intf.bInterfaceNumber ) {
+ cs_bits =
+ queue_and_start_write( &pDesc->b.intf,
+ pReq->wLength,
+ pDesc->b.intf.bLength );
+ }
+ break;
+
+ case USB_DESC_ENDPOINT: /* correct? 21Feb01ww */
+ if ( idx == 1 )
+ pEndpoint = &pDesc->b.ep1;
+ else if ( idx == 2 )
+ pEndpoint = &pDesc->b.ep2;
+ else
+ pEndpoint = NULL;
+ if ( pEndpoint ) {
+ cs_bits =
+ queue_and_start_write( pEndpoint,
+ pReq->wLength,
+ pEndpoint->bLength );
+ } else {
+ printk("%sunkown endpoint index %d Stall.\n", pszMe, idx );
+ cs_bits = ( UDCCS0_DE | UDCCS0_SO | UDCCS0_FST );
+ }
+ break;
+
+
+ default :
+ printk("%sunknown descriptor type %d. Stall.\n", pszMe, type );
+ cs_bits = ( UDCCS0_DE | UDCCS0_SO | UDCCS0_FST );
+ break;
+
+ }
+ set_cs_bits( cs_bits );
+}
+
+
+/* some voodo I am adding, since the vanilla macros just aren't doing it 1Mar01ww */
+
+#define ABORT_BITS ( UDCCS0_SST | UDCCS0_SE )
+#define OK_TO_WRITE (!( Ser0UDCCS0 & ABORT_BITS ))
+#define BOTH_BITS (UDCCS0_IPR | UDCCS0_DE)
+
+static void set_cs_bits( __u32 bits )
+{
+ if ( bits & ( UDCCS0_SO | UDCCS0_SSE | UDCCS0_FST ) )
+ Ser0UDCCS0 = bits;
+ else if ( (bits & BOTH_BITS) == BOTH_BITS )
+ set_ipr_and_de();
+ else if ( bits & UDCCS0_IPR )
+ set_ipr();
+ else if ( bits & UDCCS0_DE )
+ set_de();
+}
+
+static void set_de( void )
+{
+ int i = 1;
+ while( 1 ) {
+ if ( OK_TO_WRITE ) {
+ Ser0UDCCS0 |= UDCCS0_DE;
+ } else {
+ PRINTKD( "%sQuitting set DE because SST or SE set\n", pszMe );
+ break;
+ }
+ if ( Ser0UDCCS0 & UDCCS0_DE )
+ break;
+ udelay( i );
+ if ( ++i == 50 ) {
+ printk( "%sDangnabbbit! Cannot set DE! (DE=%8.8X CCS0=%8.8X)\n",
+ pszMe, UDCCS0_DE, Ser0UDCCS0 );
+ break;
+ }
+ }
+}
+
+static void set_ipr( void )
+{
+ int i = 1;
+ while( 1 ) {
+ if ( OK_TO_WRITE ) {
+ Ser0UDCCS0 |= UDCCS0_IPR;
+ } else {
+ PRINTKD( "%sQuitting set IPR because SST or SE set\n", pszMe );
+ break;
+ }
+ if ( Ser0UDCCS0 & UDCCS0_IPR )
+ break;
+ udelay( i );
+ if ( ++i == 50 ) {
+ printk( "%sDangnabbbit! Cannot set IPR! (IPR=%8.8X CCS0=%8.8X)\n",
+ pszMe, UDCCS0_IPR, Ser0UDCCS0 );
+ break;
+ }
+ }
+}
+
+
+
+static void set_ipr_and_de( void )
+{
+ int i = 1;
+ while( 1 ) {
+ if ( OK_TO_WRITE ) {
+ Ser0UDCCS0 |= BOTH_BITS;
+ } else {
+ PRINTKD( "%sQuitting set IPR/DE because SST or SE set\n", pszMe );
+ break;
+ }
+ if ( (Ser0UDCCS0 & BOTH_BITS) == BOTH_BITS)
+ break;
+ udelay( i );
+ if ( ++i == 50 ) {
+ printk( "%sDangnabbbit! Cannot set DE/IPR! (DE=%8.8X IPR=%8.8X CCS0=%8.8X)\n",
+ pszMe, UDCCS0_DE, UDCCS0_IPR, Ser0UDCCS0 );
+ break;
+ }
+ }
+}
+
+static bool clear_opr( void )
+{
+ int i = 10000;
+ bool is_clear;
+ do {
+ Ser0UDCCS0 = UDCCS0_SO;
+ is_clear = ! ( Ser0UDCCS0 & UDCCS0_OPR );
+ if ( i-- <= 0 ) {
+ printk( "%sclear_opr(): failed\n", pszMe );
+ break;
+ }
+ } while( ! is_clear );
+ return is_clear;
+}
+
+
+
+
+
+/* end usb_ep0.c */
+
diff -urN linux-2.4.26/arch/arm/mach-sa1100/usb_recv.c linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_recv.c
--- linux-2.4.26/arch/arm/mach-sa1100/usb_recv.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_recv.c 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,205 @@
+/*
+ * Generic receive layer for the SA1100 USB client function
+ * Copyright (c) 2001 by Nicolas Pitre
+ *
+ * This code was loosely inspired by the original version which was
+ * Copyright (c) Compaq Computer Corporation, 1998-1999
+ *
+ * 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.
+ *
+ * This is still work in progress...
+ *
+ * Please see linux/Documentation/arm/SA1100/SA1100_USB for details.
+ */
+
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/errno.h>
+#include <asm/dma.h>
+#include <asm/system.h>
+
+#include "sa1100_usb.h"
+#include "usb_ctl.h"
+
+
+static char *ep1_buf;
+static int ep1_len;
+static usb_callback_t ep1_callback;
+static char *ep1_curdmabuf;
+static dma_addr_t ep1_curdmapos;
+static int ep1_curdmalen;
+static int ep1_remain;
+static int dmachn_rx;
+static int rx_pktsize;
+
+static int naking;
+
+static void
+ep1_start(void)
+{
+ sa1100_dma_flush_all(dmachn_rx);
+ if (!ep1_curdmalen) {
+ ep1_curdmalen = rx_pktsize;
+ if (ep1_curdmalen > ep1_remain)
+ ep1_curdmalen = ep1_remain;
+ ep1_curdmapos = pci_map_single(NULL, ep1_curdmabuf, ep1_curdmalen,
+ PCI_DMA_FROMDEVICE);
+ }
+ sa1100_dma_queue_buffer(dmachn_rx, NULL, ep1_curdmapos, ep1_curdmalen);
+ if ( naking ) {
+ /* turn off NAK of OUT packets, if set */
+ UDC_flip( Ser0UDCCS1, UDCCS1_RPC );
+ naking = 0;
+ }
+}
+
+static void
+ep1_done(int flag)
+{
+ int size = ep1_len - ep1_remain;
+
+ if (!ep1_len)
+ return;
+ if (ep1_curdmalen)
+ pci_unmap_single(NULL, ep1_curdmapos, ep1_curdmalen,
+ PCI_DMA_FROMDEVICE);
+ ep1_len = ep1_curdmalen = 0;
+ if (ep1_callback) {
+ ep1_callback(flag, size);
+ }
+}
+
+void
+ep1_state_change_notify( int new_state )
+{
+
+}
+
+void
+ep1_stall( void )
+{
+ /* SET_FEATURE force stall at UDC */
+ UDC_set( Ser0UDCCS1, UDCCS1_FST );
+}
+
+int
+ep1_init(int chn)
+{
+ desc_t * pd = sa1100_usb_get_descriptor_ptr();
+ rx_pktsize = __le16_to_cpu( pd->b.ep1.wMaxPacketSize );
+ dmachn_rx = chn;
+ sa1100_dma_flush_all(dmachn_rx);
+ ep1_done(-EAGAIN);
+ return 0;
+}
+
+void
+ep1_reset(void)
+{
+ desc_t * pd = sa1100_usb_get_descriptor_ptr();
+ rx_pktsize = __le16_to_cpu( pd->b.ep1.wMaxPacketSize );
+ sa1100_dma_flush_all(dmachn_rx);
+ UDC_clear(Ser0UDCCS1, UDCCS1_FST);
+ ep1_done(-EINTR);
+}
+
+void
+ep1_int_hndlr(int udcsr)
+{
+ dma_addr_t dma_addr;
+ unsigned int len;
+ int status = Ser0UDCCS1;
+
+ if ( naking ) printk( "%sEh? in ISR but naking = %d\n", "usbrx: ", naking );
+
+ if (status & UDCCS1_RPC) {
+
+ if (!ep1_curdmalen) {
+ printk("usb_recv: RPC for non-existent buffer\n");
+ naking=1;
+ return;
+ }
+
+ sa1100_dma_stop(dmachn_rx);
+
+ if (status & UDCCS1_SST) {
+ printk("usb_recv: stall sent OMP=%d\n",Ser0UDCOMP);
+ UDC_flip(Ser0UDCCS1, UDCCS1_SST);
+ ep1_done(-EIO); // UDC aborted current transfer, so we do
+ return;
+ }
+
+ if (status & UDCCS1_RPE) {
+ printk("usb_recv: RPError %x\n", status);
+ UDC_flip(Ser0UDCCS1, UDCCS1_RPC);
+ ep1_done(-EIO);
+ return;
+ }
+
+ sa1100_dma_get_current(dmachn_rx, NULL, &dma_addr);
+ pci_unmap_single(NULL, ep1_curdmapos, ep1_curdmalen,
+ PCI_DMA_FROMDEVICE);
+ len = dma_addr - ep1_curdmapos;
+ if (len < ep1_curdmalen) {
+ char *buf = ep1_curdmabuf + len;
+ while (Ser0UDCCS1 & UDCCS1_RNE) {
+ if (len >= ep1_curdmalen) {
+ printk("usb_recv: too much data in fifo\n");
+ break;
+ }
+ *buf++ = Ser0UDCDR;
+ len++;
+ }
+ } else if (Ser0UDCCS1 & UDCCS1_RNE) {
+ printk("usb_recv: fifo screwed, shouldn't contain data\n");
+ len = 0;
+ }
+ ep1_curdmalen = 0; /* dma unmap already done */
+ ep1_remain -= len;
+ naking = 1;
+ ep1_done((len) ? 0 : -EPIPE);
+ }
+ /* else, you can get here if we are holding NAK */
+}
+
+int
+sa1100_usb_recv(char *buf, int len, usb_callback_t callback)
+{
+ int flags;
+
+ if (ep1_len)
+ return -EBUSY;
+
+ local_irq_save(flags);
+ ep1_buf = buf;
+ ep1_len = len;
+ ep1_callback = callback;
+ ep1_remain = len;
+ ep1_curdmabuf = buf;
+ ep1_curdmalen = 0;
+ ep1_start();
+ local_irq_restore(flags);
+
+ return 0;
+}
+
+EXPORT_SYMBOL(sa1100_usb_recv);
+
+void
+sa1100_usb_recv_reset(void)
+{
+ ep1_reset();
+}
+
+EXPORT_SYMBOL(sa1100_usb_recv_reset);
+
+void
+sa1100_usb_recv_stall(void)
+{
+ ep1_stall();
+}
+
+EXPORT_SYMBOL(sa1100_usb_recv_stall);
+
diff -urN linux-2.4.26/arch/arm/mach-sa1100/usb_send.c linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_send.c
--- linux-2.4.26/arch/arm/mach-sa1100/usb_send.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mach-sa1100/usb_send.c 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,205 @@
+/*
+ * Generic xmit layer for the SA1100 USB client function
+ * Copyright (c) 2001 by Nicolas Pitre
+ *
+ * This code was loosely inspired by the original version which was
+ * Copyright (c) Compaq Computer Corporation, 1998-1999
+ *
+ * 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.
+ *
+ * This is still work in progress...
+ *
+ * Please see linux/Documentation/arm/SA1100/SA1100_USB for details.
+ * 15/03/2001 - ep2_start now sets UDCAR to overcome something that is hardware
+ * bug, I think. green@iXcelerator.com
+ */
+
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/errno.h>
+#include <linux/delay.h> // for the massive_attack hack 28Feb01ww
+#include <asm/hardware.h>
+#include <asm/dma.h>
+#include <asm/system.h>
+#include <asm/byteorder.h>
+
+#include "sa1100_usb.h"
+#include "usb_ctl.h"
+
+
+static char *ep2_buf;
+static int ep2_len;
+static usb_callback_t ep2_callback;
+static dma_addr_t ep2_dma;
+static dma_addr_t ep2_curdmapos;
+static int ep2_curdmalen;
+static int ep2_remain;
+static int dmachn_tx;
+static int tx_pktsize;
+
+/* device state is changing, async */
+void
+ep2_state_change_notify( int new_state )
+{
+}
+
+/* set feature stall executing, async */
+void
+ep2_stall( void )
+{
+ UDC_set( Ser0UDCCS2, UDCCS2_FST ); /* force stall at UDC */
+}
+
+static void
+ep2_start(void)
+{
+ if (!ep2_len)
+ return;
+
+ ep2_curdmalen = tx_pktsize;
+ if (ep2_curdmalen > ep2_remain)
+ ep2_curdmalen = ep2_remain;
+
+ /* must do this _before_ queue buffer.. */
+ UDC_flip( Ser0UDCCS2,UDCCS2_TPC ); /* stop NAKing IN tokens */
+ UDC_write( Ser0UDCIMP, ep2_curdmalen-1 );
+
+ /* Remove if never seen...8Mar01ww */
+ {
+ int massive_attack = 20;
+ while ( Ser0UDCIMP != ep2_curdmalen-1 && massive_attack-- ) {
+ printk( "usbsnd: Oh no you don't! Let me spin..." );
+ udelay( 500 );
+ printk( "and try again...\n" );
+ UDC_write( Ser0UDCIMP, ep2_curdmalen-1 );
+ }
+ if ( massive_attack != 20 ) {
+ if ( Ser0UDCIMP != ep2_curdmalen-1 )
+ printk( "usbsnd: Massive attack FAILED :-( %d\n",
+ 20 - massive_attack );
+ else
+ printk( "usbsnd: Massive attack WORKED :-) %d\n",
+ 20 - massive_attack );
+ }
+ }
+ /* End remove if never seen... 8Mar01ww */
+
+ Ser0UDCAR = usbd_info.address; // fighting stupid silicon bug
+ sa1100_dma_queue_buffer(dmachn_tx, NULL, ep2_curdmapos, ep2_curdmalen);
+}
+
+static void
+ep2_done(int flag)
+{
+ int size = ep2_len - ep2_remain;
+ if (ep2_len) {
+ pci_unmap_single(NULL, ep2_dma, ep2_len, PCI_DMA_TODEVICE);
+ ep2_len = 0;
+ if (ep2_callback)
+ ep2_callback(flag, size);
+ }
+}
+
+int
+ep2_init(int chn)
+{
+ desc_t * pd = sa1100_usb_get_descriptor_ptr();
+ tx_pktsize = __le16_to_cpu( pd->b.ep2.wMaxPacketSize );
+ dmachn_tx = chn;
+ sa1100_dma_flush_all(dmachn_tx);
+ ep2_done(-EAGAIN);
+ return 0;
+}
+
+void
+ep2_reset(void)
+{
+ desc_t * pd = sa1100_usb_get_descriptor_ptr();
+ tx_pktsize = __le16_to_cpu( pd->b.ep2.wMaxPacketSize );
+ UDC_clear(Ser0UDCCS2, UDCCS2_FST);
+ sa1100_dma_flush_all(dmachn_tx);
+ ep2_done(-EINTR);
+}
+
+void
+ep2_int_hndlr(int udcsr)
+{
+ int status = Ser0UDCCS2;
+
+ if (Ser0UDCAR != usbd_info.address) // check for stupid silicon bug.
+ Ser0UDCAR = usbd_info.address;
+
+ UDC_flip(Ser0UDCCS2, UDCCS2_SST);
+
+ if (status & UDCCS2_TPC) {
+ sa1100_dma_flush_all(dmachn_tx);
+
+ if (status & (UDCCS2_TPE | UDCCS2_TUR)) {
+ printk("usb_send: transmit error %x\n", status);
+ ep2_done(-EIO);
+ } else {
+#if 1 // 22Feb01ww/Oleg
+ ep2_curdmapos += ep2_curdmalen;
+ ep2_remain -= ep2_curdmalen;
+#else
+ ep2_curdmapos += Ser0UDCIMP + 1; // this is workaround
+ ep2_remain -= Ser0UDCIMP + 1; // for case when setting of Ser0UDCIMP was failed
+#endif
+
+ if (ep2_remain != 0) {
+ ep2_start();
+ } else {
+ ep2_done(0);
+ }
+ }
+ } else {
+ printk("usb_send: Not TPC: UDCCS2 = %x\n", status);
+ }
+}
+
+int
+sa1100_usb_send(char *buf, int len, usb_callback_t callback)
+{
+ int flags;
+
+ if (usbd_info.state != USB_STATE_CONFIGURED)
+ return -ENODEV;
+
+ if (ep2_len)
+ return -EBUSY;
+
+ local_irq_save(flags);
+ ep2_buf = buf;
+ ep2_len = len;
+ ep2_dma = pci_map_single(NULL, buf, len, PCI_DMA_TODEVICE);
+ ep2_callback = callback;
+ ep2_remain = len;
+ ep2_curdmapos = ep2_dma;
+ ep2_start();
+ local_irq_restore(flags);
+
+ return 0;
+}
+
+
+void
+sa1100_usb_send_reset(void)
+{
+ ep2_reset();
+}
+
+int sa1100_usb_xmitter_avail( void )
+{
+ if (usbd_info.state != USB_STATE_CONFIGURED)
+ return -ENODEV;
+ if (ep2_len)
+ return -EBUSY;
+ return 0;
+}
+
+
+EXPORT_SYMBOL(sa1100_usb_xmitter_avail);
+EXPORT_SYMBOL(sa1100_usb_send);
+EXPORT_SYMBOL(sa1100_usb_send_reset);
diff -urN linux-2.4.26/arch/arm/mm/Makefile linux-2.4.26-vrs1/arch/arm/mm/Makefile
--- linux-2.4.26/arch/arm/mm/Makefile 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/Makefile 2004-01-14 21:38:43.000000000 +0000
@@ -39,6 +39,8 @@
p-$(CONFIG_CPU_ARM925T) += proc-arm925.o
p-$(CONFIG_CPU_ARM926T) += proc-arm926.o
p-$(CONFIG_CPU_ARM1020) += proc-arm1020.o
+p-$(CONFIG_CPU_ARM1020E) += proc-arm1020E.o
+p-$(CONFIG_CPU_ARM1022) += proc-arm1022.o
p-$(CONFIG_CPU_ARM1026) += proc-arm1026.o
p-$(CONFIG_CPU_SA110) += proc-sa110.o
p-$(CONFIG_CPU_SA1100) += proc-sa110.o
diff -urN linux-2.4.26/arch/arm/mm/alignment.c linux-2.4.26-vrs1/arch/arm/mm/alignment.c
--- linux-2.4.26/arch/arm/mm/alignment.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/alignment.c 2004-04-09 15:09:44.000000000 +0100
@@ -11,7 +11,6 @@
#include <linux/config.h>
#include <linux/compiler.h>
#include <linux/signal.h>
-#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
@@ -19,7 +18,6 @@
#include <linux/ptrace.h>
#include <linux/mman.h>
#include <linux/mm.h>
-#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/bitops.h>
#include <linux/init.h>
@@ -30,13 +28,11 @@
#include <asm/pgtable.h>
#include <asm/unaligned.h>
-extern void
-do_bad_area(struct task_struct *tsk, struct mm_struct *mm, unsigned long addr,
- int error_code, struct pt_regs *regs);
+#include "fault.h"
/*
* 32-bit misaligned trap handler (c) 1998 San Mehat (CCC) -July 1998
- * /proc/sys/debug/alignment, modified and integrated into
+ * /proc/cpu/alignment, modified and integrated into
* Linux 2.1 by Russell King
*
* Speed optimisations and better fault handling by Russell King.
@@ -130,31 +126,6 @@
return count;
}
-/*
- * This needs to be done after sysctl_init, otherwise sys/ will be
- * overwritten. Actually, this shouldn't be in sys/ at all since
- * it isn't a sysctl, and it doesn't contain sysctl information.
- * We now locate it in /proc/cpu/alignment instead.
- */
-static int __init alignment_init(void)
-{
- struct proc_dir_entry *res;
-
- res = proc_mkdir("cpu", NULL);
- if (!res)
- return -ENOMEM;
-
- res = create_proc_entry("alignment", S_IWUSR | S_IRUGO, res);
- if (!res)
- return -ENOMEM;
-
- res->read_proc = proc_alignment_read;
- res->write_proc = proc_alignment_write;
-
- return 0;
-}
-
-__initcall(alignment_init);
#endif /* CONFIG_PROC_FS */
union offset_union {
@@ -429,7 +400,7 @@
* For alignment faults on the ARM922T/ARM920T the MMU makes
* the FSR (and hence addr) equal to the updated base address
* of the multiple access rather than the restored value.
- * Switch this messsage off if we've got a ARM92[02], otherwise
+ * Switch this message off if we've got a ARM92[02], otherwise
* [ls]dm alignment faults are noisy!
*/
#if !(defined CONFIG_CPU_ARM922T) && !(defined CONFIG_CPU_ARM920T)
@@ -486,7 +457,8 @@
return TYPE_ERROR;
}
-int do_alignment(unsigned long addr, int error_code, struct pt_regs *regs)
+static int
+do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{
union offset_union offset;
unsigned long instr, instrptr;
@@ -541,7 +513,7 @@
case SHIFT_RORRRX:
if (shiftval == 0) {
offset.un >>= 1;
- if (regs->ARM_cpsr & CC_C_BIT)
+ if (regs->ARM_cpsr & PSR_C_BIT)
offset.un |= 1 << 31;
} else
offset.un = offset.un >> shiftval |
@@ -577,7 +549,7 @@
/*
* We got a fault - fix it up, or die.
*/
- do_bad_area(current, current->mm, addr, error_code, regs);
+ do_bad_area(current, current->mm, addr, fsr, regs);
return 0;
bad:
@@ -594,8 +566,8 @@
if (ai_usermode & 1)
printk("Alignment trap: %s (%d) PC=0x%08lx Instr=0x%08lx "
- "Address=0x%08lx Code 0x%02x\n", current->comm,
- current->pid, instrptr, instr, addr, error_code);
+ "Address=0x%08lx FSR 0x%03x\n", current->comm,
+ current->pid, instrptr, instr, addr, fsr);
if (ai_usermode & 2)
goto fixup;
@@ -607,3 +579,34 @@
return 0;
}
+
+/*
+ * This needs to be done after sysctl_init, otherwise sys/ will be
+ * overwritten. Actually, this shouldn't be in sys/ at all since
+ * it isn't a sysctl, and it doesn't contain sysctl information.
+ * We now locate it in /proc/cpu/alignment instead.
+ */
+static int __init alignment_init(void)
+{
+#ifdef CONFIG_PROC_FS
+ struct proc_dir_entry *res;
+
+ res = proc_mkdir("cpu", NULL);
+ if (!res)
+ return -ENOMEM;
+
+ res = create_proc_entry("alignment", S_IWUSR | S_IRUGO, res);
+ if (!res)
+ return -ENOMEM;
+
+ res->read_proc = proc_alignment_read;
+ res->write_proc = proc_alignment_write;
+#endif
+
+ hook_fault_code(1, do_alignment, SIGILL, "alignment exception");
+ hook_fault_code(3, do_alignment, SIGILL, "alignment exception");
+
+ return 0;
+}
+
+__initcall(alignment_init);
diff -urN linux-2.4.26/arch/arm/mm/fault-armv.c linux-2.4.26-vrs1/arch/arm/mm/fault-armv.c
--- linux-2.4.26/arch/arm/mm/fault-armv.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/fault-armv.c 2004-04-09 21:22:20.000000000 +0100
@@ -2,116 +2,90 @@
* linux/arch/arm/mm/fault-armv.c
*
* Copyright (C) 1995 Linus Torvalds
- * Modifications for ARM processor (c) 1995-2001 Russell King
+ * Modifications for ARM processor (c) 1995-2003 Russell King
*
* 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/config.h>
-#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
#include <linux/types.h>
#include <linux/ptrace.h>
-#include <linux/mman.h>
#include <linux/mm.h>
-#include <linux/interrupt.h>
-#include <linux/proc_fs.h>
#include <linux/bitops.h>
#include <linux/init.h>
-#include <asm/system.h>
-#include <asm/uaccess.h>
#include <asm/pgalloc.h>
#include <asm/pgtable.h>
+#include <asm/io.h>
-extern void show_pte(struct mm_struct *mm, unsigned long addr);
-extern int do_page_fault(unsigned long addr, int error_code,
- struct pt_regs *regs);
-extern int do_translation_fault(unsigned long addr, int error_code,
- struct pt_regs *regs);
-extern void do_bad_area(struct task_struct *tsk, struct mm_struct *mm,
- unsigned long addr, int error_code,
- struct pt_regs *regs);
-
-#ifdef CONFIG_ALIGNMENT_TRAP
-extern int do_alignment(unsigned long addr, int error_code, struct pt_regs *regs);
-#else
-#define do_alignment do_bad
-#endif
-
+#include "fault.h"
/*
* Some section permission faults need to be handled gracefully.
* They can happen due to a __{get,put}_user during an oops.
*/
static int
-do_sect_fault(unsigned long addr, int error_code, struct pt_regs *regs)
+do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{
struct task_struct *tsk = current;
- do_bad_area(tsk, tsk->active_mm, addr, error_code, regs);
+ do_bad_area(tsk, tsk->active_mm, addr, fsr, regs);
return 0;
}
/*
- * Hook for things that need to trap external faults. Note that
- * we don't guarantee that this will be the final version of the
- * interface.
- */
-int (*external_fault)(unsigned long addr, struct pt_regs *regs);
-
-static int
-do_external_fault(unsigned long addr, int error_code, struct pt_regs *regs)
-{
- if (external_fault)
- return external_fault(addr, regs);
- return 1;
-}
-
-/*
* This abort handler always returns "fault".
*/
static int
-do_bad(unsigned long addr, int error_code, struct pt_regs *regs)
+do_bad(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{
return 1;
}
-static const struct fsr_info {
- int (*fn)(unsigned long addr, int error_code, struct pt_regs *regs);
+static struct fsr_info {
+ int (*fn)(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
int sig;
const char *name;
} fsr_info[] = {
{ do_bad, SIGSEGV, "vector exception" },
- { do_alignment, SIGILL, "alignment exception" },
+ { do_bad, SIGILL, "alignment exception" },
{ do_bad, SIGKILL, "terminal exception" },
- { do_alignment, SIGILL, "alignment exception" },
- { do_external_fault, SIGBUS, "external abort on linefetch" },
+ { do_bad, SIGILL, "alignment exception" },
+ { do_bad, SIGBUS, "external abort on linefetch" },
{ do_translation_fault, SIGSEGV, "section translation fault" },
- { do_external_fault, SIGBUS, "external abort on linefetch" },
+ { do_bad, SIGBUS, "external abort on linefetch" },
{ do_page_fault, SIGSEGV, "page translation fault" },
- { do_external_fault, SIGBUS, "external abort on non-linefetch" },
+ { do_bad, SIGBUS, "external abort on non-linefetch" },
{ do_bad, SIGSEGV, "section domain fault" },
- { do_external_fault, SIGBUS, "external abort on non-linefetch" },
+ { do_bad, SIGBUS, "external abort on non-linefetch" },
{ do_bad, SIGSEGV, "page domain fault" },
{ do_bad, SIGBUS, "external abort on translation" },
{ do_sect_fault, SIGSEGV, "section permission fault" },
{ do_bad, SIGBUS, "external abort on translation" },
- { do_page_fault, SIGSEGV, "page permission fault" }
+ { do_page_fault, SIGSEGV, "page permission fault" },
};
+void __init
+hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *),
+ int sig, const char *name)
+{
+ if (nr >= 0 && nr < ARRAY_SIZE(fsr_info)) {
+ fsr_info[nr].fn = fn;
+ fsr_info[nr].sig = sig;
+ fsr_info[nr].name = name;
+ }
+}
+
/*
* Dispatch a data abort to the relevant handler.
*/
asmlinkage void
-do_DataAbort(unsigned long addr, int error_code, struct pt_regs *regs, int fsr)
+do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{
const struct fsr_info *inf = fsr_info + (fsr & 15);
- if (!inf->fn(addr, error_code, regs))
+ if (!inf->fn(addr, fsr, regs))
return;
printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
@@ -127,25 +101,28 @@
do_translation_fault(addr, 0, regs);
}
+static unsigned long shared_pte_mask = L_PTE_CACHEABLE;
+
/*
* We take the easy way out of this problem - we make the
* PTE uncacheable. However, we leave the write buffer on.
*/
-static void adjust_pte(struct vm_area_struct *vma, unsigned long address)
+static int adjust_pte(struct vm_area_struct *vma, unsigned long address)
{
pgd_t *pgd;
pmd_t *pmd;
pte_t *pte, entry;
+ int ret = 0;
pgd = pgd_offset(vma->vm_mm, address);
if (pgd_none(*pgd))
- return;
+ goto no_pgd;
if (pgd_bad(*pgd))
goto bad_pgd;
pmd = pmd_offset(pgd, address);
if (pmd_none(*pmd))
- return;
+ goto no_pmd;
if (pmd_bad(*pmd))
goto bad_pmd;
@@ -156,33 +133,38 @@
* If this page isn't present, or is already setup to
* fault (ie, is old), we can safely ignore any issues.
*/
- if (pte_present(entry) && pte_val(entry) & L_PTE_CACHEABLE) {
+ if (pte_present(entry) && pte_val(entry) & shared_pte_mask) {
flush_cache_page(vma, address);
- pte_val(entry) &= ~L_PTE_CACHEABLE;
+ pte_val(entry) &= ~shared_pte_mask;
set_pte(pte, entry);
flush_tlb_page(vma, address);
+ ret = 1;
}
- return;
+ return ret;
bad_pgd:
pgd_ERROR(*pgd);
pgd_clear(pgd);
- return;
+no_pgd:
+ return 0;
bad_pmd:
pmd_ERROR(*pmd);
pmd_clear(pmd);
- return;
+no_pmd:
+ return 0;
}
static void
-make_coherent(struct vm_area_struct *vma, unsigned long addr, struct page *page)
+make_coherent(struct vm_area_struct *vma, unsigned long addr, struct page *page, int dirty)
{
struct vm_area_struct *mpnt;
struct mm_struct *mm = vma->vm_mm;
- unsigned long pgoff = (addr - vma->vm_start) >> PAGE_SHIFT;
+ unsigned long pgoff;
int aliases = 0;
+ pgoff = vma->vm_pgoff + ((addr - vma->vm_start) >> PAGE_SHIFT);
+
/*
* If we have any shared mappings that are in the same mm
* space, then we need to handle them specially to maintain
@@ -194,7 +176,7 @@
/*
* If this VMA is not in our MM, we can ignore it.
- * Note that we intentionally don't mask out the VMA
+ * Note that we intentionally mask out the VMA
* that we are fixing up.
*/
if (mpnt->vm_mm != mm || mpnt == vma)
@@ -210,14 +192,17 @@
if (off >= (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT)
continue;
+ off = mpnt->vm_start + (off << PAGE_SHIFT);
+
/*
* Ok, it is within mpnt. Fix it up.
*/
- adjust_pte(mpnt, mpnt->vm_start + (off << PAGE_SHIFT));
- aliases ++;
+ aliases += adjust_pte(mpnt, off);
}
if (aliases)
adjust_pte(vma, addr);
+ else if (dirty)
+ flush_cache_page(vma, addr);
}
/*
@@ -242,11 +227,85 @@
return;
page = pfn_to_page(pfn);
if (page->mapping) {
- if (test_and_clear_bit(PG_dcache_dirty, &page->flags)) {
+ int dirty = test_and_clear_bit(PG_dcache_dirty, &page->flags);
+
+ if (dirty) {
unsigned long kvirt = (unsigned long)page_address(page);
cpu_cache_clean_invalidate_range(kvirt, kvirt + PAGE_SIZE, 0);
}
- make_coherent(vma, addr, page);
+ make_coherent(vma, addr, page, dirty);
+ }
+}
+
+/*
+ * Check whether the write buffer has physical address aliasing
+ * issues. If it has, we need to avoid them for the case where
+ * we have several shared mappings of the same object in user
+ * space.
+ */
+static int __init check_writebuffer(unsigned long *p1, unsigned long *p2)
+{
+ register unsigned long zero = 0, one = 1, val;
+
+ mb();
+ *p1 = one;
+ mb();
+ *p2 = zero;
+ mb();
+ val = *p1;
+ mb();
+ return val != zero;
+}
+
+static inline void *map_page(struct page *page)
+{
+ void *map;
+
+ map = __ioremap(page_to_phys(page), PAGE_SIZE, L_PTE_BUFFERABLE);
+ if (map)
+ get_page(page);
+ return map;
+}
+
+static inline void unmap_page(void *map)
+{
+ iounmap(map);
+}
+
+void __init check_writebuffer_bugs(void)
+{
+ struct page *page;
+ const char *reason;
+ unsigned long v = 1;
+
+ printk(KERN_INFO "CPU: Testing write buffer: ");
+
+ page = alloc_page(GFP_KERNEL);
+ if (page) {
+ unsigned long *p1, *p2;
+
+ p1 = map_page(page);
+ p2 = map_page(page);
+
+ if (p1 && p2) {
+ v = check_writebuffer(p1, p2);
+ reason = "enabling work-around";
+ } else {
+ reason = "unable to map memory\n";
+ }
+
+ unmap_page(p1);
+ unmap_page(p2);
+ put_page(page);
+ } else {
+ reason = "unable to grab page\n";
+ }
+
+ if (v) {
+ printk("FAIL - %s\n", reason);
+ shared_pte_mask |= L_PTE_BUFFERABLE;
+ } else {
+ printk("pass\n");
}
}
diff -urN linux-2.4.26/arch/arm/mm/fault-common.c linux-2.4.26-vrs1/arch/arm/mm/fault-common.c
--- linux-2.4.26/arch/arm/mm/fault-common.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/fault-common.c 2004-01-14 21:38:43.000000000 +0000
@@ -11,21 +11,17 @@
#include <linux/config.h>
#include <linux/signal.h>
#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
#include <linux/string.h>
-#include <linux/types.h>
#include <linux/ptrace.h>
-#include <linux/mman.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
-#include <linux/proc_fs.h>
#include <linux/init.h>
#include <asm/system.h>
-#include <asm/uaccess.h>
#include <asm/pgtable.h>
-#include <asm/unaligned.h>
+#include <asm/uaccess.h>
+
+#include "fault.h"
#ifdef CONFIG_CPU_26
#define FAULT_CODE_WRITE 0x02
@@ -34,13 +30,11 @@
#define READ_FAULT(m) (!((m) & FAULT_CODE_WRITE))
#else
/*
- * On 32-bit processors, we define "mode" to be zero when reading,
- * non-zero when writing. This now ties up nicely with the polarity
- * of the 26-bit machines, and also means that we avoid the horrible
- * gcc code for "int val = !other_val;".
+ * "code" is actually the FSR register. Bit 11 set means the
+ * instruction was performing a write.
*/
-#define DO_COW(m) (m)
-#define READ_FAULT(m) (!(m))
+#define DO_COW(code) ((code) & (1 << 11))
+#define READ_FAULT(code) (!DO_COW(code))
#endif
/*
@@ -54,16 +48,17 @@
if (!mm)
mm = &init_mm;
- printk(KERN_ALERT "mm = %p pgd = %p\n", mm, mm->pgd);
-
fs = get_fs();
set_fs(get_ds());
+
do {
- pgd_t pg, *pgd = pgd_offset(mm, addr);
+ pgd_t pg, *pgd;
pmd_t pm, *pmd;
pte_t pt, *pte;
- printk(KERN_ALERT "*pgd = ");
+ printk(KERN_ALERT "pgd = %p\n", mm->pgd);
+ pgd = pgd_offset(mm, addr);
+ printk(KERN_ALERT "[%08lx] *pgd=", addr);
if (__get_user(pgd_val(pg), (unsigned long *)pgd)) {
printk("(faulted)");
@@ -122,7 +117,7 @@
* Oops. The kernel tried to access some page that wasn't present.
*/
static void
-__do_kernel_fault(struct mm_struct *mm, unsigned long addr, int error_code,
+__do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
struct pt_regs *regs)
{
unsigned long fixup;
@@ -148,7 +143,7 @@
"paging request", addr);
show_pte(mm, addr);
- die("Oops", regs, error_code);
+ die("Oops", regs, fsr);
do_exit(SIGKILL);
}
@@ -157,20 +152,20 @@
* User mode accesses just cause a SIGSEGV
*/
static void
-__do_user_fault(struct task_struct *tsk, unsigned long addr, int error_code,
- int code, struct pt_regs *regs)
+__do_user_fault(struct task_struct *tsk, unsigned long addr,
+ unsigned int fsr, int code, struct pt_regs *regs)
{
struct siginfo si;
#ifdef CONFIG_DEBUG_USER
printk(KERN_DEBUG "%s: unhandled page fault at pc=0x%08lx, "
"lr=0x%08lx (bad address=0x%08lx, code %d)\n",
- tsk->comm, regs->ARM_pc, regs->ARM_lr, addr, error_code);
+ tsk->comm, regs->ARM_pc, regs->ARM_lr, addr, fsr);
show_regs(regs);
#endif
tsk->thread.address = addr;
- tsk->thread.error_code = error_code;
+ tsk->thread.error_code = fsr;
tsk->thread.trap_no = 14;
si.si_signo = SIGSEGV;
si.si_errno = 0;
@@ -181,20 +176,20 @@
void
do_bad_area(struct task_struct *tsk, struct mm_struct *mm, unsigned long addr,
- int error_code, struct pt_regs *regs)
+ unsigned int fsr, struct pt_regs *regs)
{
/*
* If we are in kernel mode at this point, we
* have no context to handle this fault with.
*/
if (user_mode(regs))
- __do_user_fault(tsk, addr, error_code, SEGV_MAPERR, regs);
+ __do_user_fault(tsk, addr, fsr, SEGV_MAPERR, regs);
else
- __do_kernel_fault(mm, addr, error_code, regs);
+ __do_kernel_fault(mm, addr, fsr, regs);
}
static int
-__do_page_fault(struct mm_struct *mm, unsigned long addr, int error_code,
+__do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
struct task_struct *tsk)
{
struct vm_area_struct *vma;
@@ -212,7 +207,7 @@
* memory access, so we can handle it.
*/
good_area:
- if (READ_FAULT(error_code)) /* read? */
+ if (READ_FAULT(fsr)) /* read? */
mask = VM_READ|VM_EXEC;
else
mask = VM_WRITE;
@@ -227,7 +222,7 @@
* than endlessly redo the fault.
*/
survive:
- fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, DO_COW(error_code));
+ fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, DO_COW(fsr));
/*
* Handle the "normal" cases first - successful and sigbus
@@ -260,7 +255,7 @@
return fault;
}
-int do_page_fault(unsigned long addr, int error_code, struct pt_regs *regs)
+int do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
{
struct task_struct *tsk;
struct mm_struct *mm;
@@ -277,7 +272,7 @@
goto no_context;
down_read(&mm->mmap_sem);
- fault = __do_page_fault(mm, addr, error_code, tsk);
+ fault = __do_page_fault(mm, addr, fsr, tsk);
up_read(&mm->mmap_sem);
/*
@@ -308,7 +303,7 @@
printk("VM: killing process %s\n", tsk->comm);
do_exit(SIGKILL);
} else
- __do_user_fault(tsk, addr, error_code, fault == -1 ?
+ __do_user_fault(tsk, addr, fsr, fault == -1 ?
SEGV_ACCERR : SEGV_MAPERR, regs);
return 0;
@@ -323,7 +318,7 @@
* or user mode.
*/
tsk->thread.address = addr;
- tsk->thread.error_code = error_code;
+ tsk->thread.error_code = fsr;
tsk->thread.trap_no = 14;
force_sig(SIGBUS, tsk);
#ifdef CONFIG_DEBUG_USER
@@ -336,7 +331,7 @@
return 0;
no_context:
- __do_kernel_fault(mm, addr, error_code, regs);
+ __do_kernel_fault(mm, addr, fsr, regs);
return 0;
}
@@ -357,21 +352,23 @@
* interrupt or a critical region, and should only copy the information
* from the master page table, nothing more.
*/
-int do_translation_fault(unsigned long addr, int error_code, struct pt_regs *regs)
+int do_translation_fault(unsigned long addr, unsigned int fsr,
+ struct pt_regs *regs)
{
struct task_struct *tsk;
- struct mm_struct *mm;
int offset;
pgd_t *pgd, *pgd_k;
pmd_t *pmd, *pmd_k;
if (addr < TASK_SIZE)
- return do_page_fault(addr, error_code, regs);
+ return do_page_fault(addr, fsr, regs);
offset = __pgd_offset(addr);
/*
* FIXME: CP15 C1 is write only on ARMv3 architectures.
+ * You really need to read the value in the page table
+ * register, not a copy.
*/
pgd = cpu_get_pgd() + offset;
pgd_k = init_mm.pgd + offset;
@@ -395,8 +392,7 @@
bad_area:
tsk = current;
- mm = tsk->active_mm;
- do_bad_area(tsk, mm, addr, error_code, regs);
+ do_bad_area(tsk, tsk->active_mm, addr, fsr, regs);
return 0;
}
diff -urN linux-2.4.26/arch/arm/mm/fault.h linux-2.4.26-vrs1/arch/arm/mm/fault.h
--- linux-2.4.26/arch/arm/mm/fault.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/fault.h 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,9 @@
+void do_bad_area(struct task_struct *tsk, struct mm_struct *mm,
+ unsigned long addr, unsigned int fsr, struct pt_regs *regs);
+
+void show_pte(struct mm_struct *mm, unsigned long addr);
+
+int do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
+
+int do_translation_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
+
diff -urN linux-2.4.26/arch/arm/mm/init.c linux-2.4.26-vrs1/arch/arm/mm/init.c
--- linux-2.4.26/arch/arm/mm/init.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/init.c 2004-01-14 21:32:24.000000000 +0000
@@ -9,7 +9,6 @@
*/
#include <linux/config.h>
#include <linux/signal.h>
-#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
@@ -18,7 +17,6 @@
#include <linux/mman.h>
#include <linux/mm.h>
#include <linux/swap.h>
-#include <linux/swapctl.h>
#include <linux/smp.h>
#include <linux/init.h>
#include <linux/bootmem.h>
diff -urN linux-2.4.26/arch/arm/mm/ioremap.c linux-2.4.26-vrs1/arch/arm/mm/ioremap.c
--- linux-2.4.26/arch/arm/mm/ioremap.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/ioremap.c 2004-02-25 22:03:38.000000000 +0000
@@ -144,7 +144,7 @@
*/
offset = phys_addr & ~PAGE_MASK;
phys_addr &= PAGE_MASK;
- size = PAGE_ALIGN(last_addr) - phys_addr;
+ size = PAGE_ALIGN(last_addr + 1) - phys_addr;
/*
* Ok, go for it..
diff -urN linux-2.4.26/arch/arm/mm/mm-armv.c linux-2.4.26-vrs1/arch/arm/mm/mm-armv.c
--- linux-2.4.26/arch/arm/mm/mm-armv.c 2003-11-28 18:26:19.000000000 +0000
+++ linux-2.4.26-vrs1/arch/arm/mm/mm-armv.c 2004-01-14 21:38:43.000000000 +0000
@@ -9,7 +9,6 @@
*
* Page table sludge for ARM v3 and v4 processor architectures.
*/
-#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/bootmem.h>
@@ -390,6 +389,9 @@
init_maps->bufferable = 0;
create_mapping(init_maps);
+
+ flush_cache_all();
+ flush_tlb_all();
}
/*
diff -urN linux-2.4.26/arch/arm/mm/proc-arm1020.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm1020.S
--- linux-2.4.26/arch/arm/mm/proc-arm1020.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm1020.S 2004-01-14 21:32:24.000000000 +0000
@@ -65,18 +65,21 @@
*
* Returns:
* r0 = address of abort
- * r1 != 0 if writing
- * r3 = FSR
+ * r1 = FSR
+ * r3 = corrupted
* r4 = corrupted
*/
.align 5
ENTRY(cpu_arm1020_data_abort)
- mrc p15, 0, r3, c5, c0, 0 @ get FSR
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
mrc p15, 0, r0, c6, c0, 0 @ get FAR
- ldr r1, [r2] @ read aborted instruction
- and r3, r3, #255
- tst r1, r1, lsr #21 @ C = bit 20
- sbc r1, r1, r1 @ r1 = C - 1
+ tst r3, #PSR_T_BIT
+ ldrneh r3, [r2] @ read aborted thumb instruction
+ ldreq r3, [r2] @ read aborted ARM instruction
+ bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
+ movne r3, r3, lsl #(21 - 12) @ move thumb bit 11 to ARM bit 20
+ tst r3, #1 << 20 @ check write
+ orreq r1, r1, #1 << 11
mov pc, lr
/*
@@ -170,10 +173,10 @@
#endif
subs r3, r3, #1
cmp r3, #0
- bge 2b @ entries 3F to 0
+ bhs 2b @ entries 3F to 0
subs r1, r1, #1
cmp r1, #0
- bge 1b @ segments 7 to 0
+ bhs 1b @ segments 7 to 0
#endif
#ifndef CONFIG_CPU_ICACHE_DISABLE
@@ -201,7 +204,7 @@
bic r0, r0, #DCACHELINESIZE - 1
sub r3, r1, r0
cmp r3, #MAX_AREA_SIZE
- bgt cpu_arm1020_cache_clean_invalidate_all_r2
+ bhi cpu_arm1020_cache_clean_invalidate_all_r2
mcr p15, 0, r3, c7, c10, 4
#ifndef CONFIG_CPU_DCACHE_DISABLE
1: mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
@@ -214,7 +217,7 @@
#endif
add r0, r0, #DCACHELINESIZE
cmp r0, r1
- blt 1b
+ blo 1b
#endif
#ifndef CONFIG_CPU_ICACHE_DISABLE
@@ -302,7 +305,7 @@
#endif
add r0, r0, #DCACHELINESIZE
cmp r0, r1
- blt 1b
+ blo 1b
#else
/* D cache off, but still drain the write buffer */
mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
@@ -328,7 +331,7 @@
bic r0, r0, #DCACHELINESIZE - 1
sub r3, r1, r0
cmp r3, #MAX_AREA_SIZE
- bgt cpu_arm1020_cache_clean_invalidate_all_r2
+ bhi cpu_arm1020_cache_clean_invalidate_all_r2
mcr p15, 0, r3, c7, c10, 4
#ifndef CONFIG_CPU_DCACHE_DISABLE
1: mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
@@ -341,7 +344,7 @@
#endif
add r0, r0, #DCACHELINESIZE
cmp r0, r1
- blt 1b
+ blo 1b
#endif
#ifndef CONFIG_CPU_BPREDICT_DISABLE
@@ -488,7 +491,7 @@
mov r0, r0
#endif
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
/*
@@ -541,10 +544,10 @@
#endif
subs r3, r3, #1
cmp r3, #0
- bge 2b @ entries 3F to 0
+ bhs 2b @ entries 3F to 0
subs r1, r1, #1
cmp r1, #0
- bge 1b @ segments 15 to 0
+ bhs 1b @ segments 15 to 0
#endif
mov r1, #0
@@ -603,7 +606,7 @@
bic r2, r2, #3
orr r2, r2, #HPTE_TYPE_SMALL
- tst r1, #LPTE_USER | LPTE_EXEC @ User or Exec?
+ tst r1, #LPTE_USER @ User?
orrne r2, r2, #HPTE_AP_READ
tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
@@ -740,12 +743,12 @@
.type cpu_arch_name, #object
cpu_arch_name:
- .asciz "armv4"
+ .asciz "armv5t"
.size cpu_arch_name, . - cpu_arch_name
.type cpu_elf_name, #object
cpu_elf_name:
- .asciz "v4"
+ .asciz "v5"
.size cpu_elf_name, . - cpu_elf_name
.align
@@ -753,9 +756,9 @@
.type __arm1020_proc_info,#object
__arm1020_proc_info:
- .long 0x4100a200
- .long 0xff00fff0
- .long 0x00000c02 @ mmuflags
+ .long 0x4104a200 @ ARM 1020T (Architecture v5T)
+ .long 0xff0ffff0
+ .long 0x00000c0e @ mmuflags
b __arm1020_setup
.long cpu_arch_name
.long cpu_elf_name
diff -urN linux-2.4.26/arch/arm/mm/proc-arm1020E.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm1020E.S
--- linux-2.4.26/arch/arm/mm/proc-arm1020E.S 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm1020E.S 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,718 @@
+/*
+ * linux/arch/arm/mm/proc-arm1020E.S: MMU functions for ARM1020E
+ *
+ * Copyright (C) 2000 ARM Limited
+ * Copyright (C) 2000 Deep Blue Solutions Ltd.
+ *
+ * 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
+ *
+ *
+ * These are the low level assembler for performing cache and TLB
+ * functions on the arm1020E.
+ */
+#include <linux/linkage.h>
+#include <linux/config.h>
+#include <asm/assembler.h>
+#include <asm/constants.h>
+#include <asm/procinfo.h>
+#include <asm/hardware.h>
+
+/*
+ * This is the maximum size of an area which will be invalidated
+ * using the single invalidate entry instructions. Anything larger
+ * than this, and we go for the whole cache.
+ *
+ * This value should be chosen such that we choose the cheapest
+ * alternative.
+ */
+#define MAX_AREA_SIZE 32768
+
+/*
+ * the cache line size of the I and D cache
+ */
+#define DCACHELINESIZE 32
+#define ICACHELINESIZE 32
+
+/*
+ * and the page size
+ */
+#define LOG2PAGESIZE 12 /* == 4096 Bytes */
+#define PAGESIZE (1 << LOG2PAGESIZE)
+
+/*
+ * create some useful conditional macro definitions
+ * we often need to know if we are ((not dcache disable) and writethrough) or ((not dcache disable) and writeback)
+ */
+#ifdef CONFIG_CPU_DCACHE_DISABLE
+ #undef CONFIG_CPU_DCACHE_WRITETHROUGH
+ #undef CONFIG_CPU_DCACHE_WRITEBACK
+ #undef CONFIG_CPU_DCACHE_ENABLE
+#else
+ #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ #undef CONFIG_CPU_DCACHE_WRITEBACK
+ #else
+ #define CONFIG_CPU_DCACHE_WRITEBACK
+ #endif
+ #define CONFIG_CPU_DCACHE_ENABLE
+#endif
+
+#ifdef CONFIG_CPU_ICACHE_DISABLE
+ #undef CONFIG_CPU_ICACHE_ENABLE
+#else
+ #define CONFIG_CPU_ICACHE_ENABLE
+#endif
+
+ .text
+
+/*
+ * cpu_arm1020E_data_abort()
+ *
+ * obtain information about current aborted instruction
+ * Note: we read user space. This means we might cause a data
+ * abort here if the I-TLB and D-TLB aren't seeing the same
+ * picture. Unfortunately, this does happen. We live with it.
+ *
+ * r2 = address of aborted instruction
+ * r3 = cpsr
+ *
+ * Returns:
+ * r0 = address of abort
+ * r1 = FSR
+ * r3 = corrupted
+ * r4 = corrupted
+ */
+ .align 5
+ENTRY(cpu_arm1020E_data_abort)
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
+ mrc p15, 0, r0, c6, c0, 0 @ get FAR
+ tst r3, #PSR_T_BIT
+ ldrneh r3, [r2] @ read aborted thumb instruction
+ ldreq r3, [r2] @ read aborted ARM instruction
+ bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
+ movne r3, r3, lsl #(21 - 12) @ move thumb bit 11 to ARM bit 20
+ tst r3, #1 << 20 @ check write
+ orreq r1, r1, #1 << 11
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_check_bugs()
+ */
+ENTRY(cpu_arm1020E_check_bugs)
+ mrs ip, cpsr
+ bic ip, ip, #F_BIT
+ msr cpsr, ip
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_proc_init()
+ */
+ENTRY(cpu_arm1020E_proc_init)
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_proc_fin()
+ */
+ENTRY(cpu_arm1020E_proc_fin)
+ stmfd sp!, {lr}
+ mov ip, #F_BIT | I_BIT | SVC_MODE
+ msr cpsr_c, ip
+ bl cpu_arm1020E_cache_clean_invalidate_all
+ mrc p15, 0, r0, c1, c0, 0 @ ctrl register
+ bic r0, r0, #0x1000 @ ...i............
+ bic r0, r0, #0x000e @ ............wca.
+ mcr p15, 0, r0, c1, c0, 0 @ disable caches
+ ldmfd sp!, {pc}
+
+/*
+ * cpu_arm1020E_reset(loc)
+ *
+ * Perform a soft reset of the system. Put the CPU into the
+ * same state as it would be if it had been reset, and branch
+ * to what would be the reset vector.
+ *
+ * loc: location to jump to for soft reset
+ */
+ .align 5
+ENTRY(cpu_arm1020E_reset)
+ mov ip, #0
+ mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
+ mcr p15, 0, ip, c7, c10, 4 @ drain WB
+ mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
+ mrc p15, 0, ip, c1, c0, 0 @ ctrl register
+ bic ip, ip, #0x000f @ ............wcam
+ bic ip, ip, #0x1100 @ ...i...s........
+ mcr p15, 0, ip, c1, c0, 0 @ ctrl register
+ mov pc, r0
+
+/*
+ * cpu_arm1020E_do_idle()
+ */
+ .align 5
+ENTRY(cpu_arm1020E_do_idle)
+ mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
+ mov pc, lr
+
+/* ================================= CACHE ================================ */
+
+
+/*
+ * cpu_arm1020E_cache_clean_invalidate_all()
+ *
+ * clean and invalidate all cache lines
+ *
+ * Note:
+ * 1. we should preserve r0 and ip at all times
+ */
+ .align 5
+ENTRY(cpu_arm1020E_cache_clean_invalidate_all)
+ mov r2, #1
+cpu_arm1020E_cache_clean_invalidate_all_r2:
+
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mov r1, #0x0F << 5 @ 16 segments
+1: orr r3, r1, #63 << 26 @ 64 entries
+2: mcr p15, 0, r3, c7, c14, 2 @ clean and invalidate D index
+ subs r3, r3, #1 << 26
+ bcs 2b
+ subs r1, r1, #1 << 5
+ bcs 1b @ segments 15 to 0
+#endif
+
+ mov r1, #0
+
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ mcr p15, 0, r1, c7, c6, 0 @ invalidate D cache
+#endif
+
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ teq r2, #0
+ mcrne p15, 0, r1, c7, c5, 0 @ invalidate I cache
+#endif
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_cache_clean_invalidate_range(start, end, flags)
+ *
+ * clean and invalidate all cache lines associated with this area of memory
+ *
+ * start: Area start address
+ * end: Area end address
+ * flags: nonzero for I cache as well
+ */
+ .align 5
+ENTRY(cpu_arm1020E_cache_clean_invalidate_range)
+ bic r0, r0, #DCACHELINESIZE - 1
+ sub r3, r1, r0
+ cmp r3, #MAX_AREA_SIZE
+ bhs cpu_arm1020E_cache_clean_invalidate_all_r2
+1:
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
+#endif
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ teq r2, #0
+ mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
+#endif
+ add r0, r0, #DCACHELINESIZE
+ cmp r0, r1
+ bls 1b @ unsigned lower or same - must include end point (r1)!
+
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_flush_ram_page(page)
+ *
+ * clean and invalidate all cache lines associated with this area of memory
+ *
+ * page: page to clean and invalidate
+ */
+ .align 5
+ENTRY(cpu_arm1020E_flush_ram_page)
+ mov r1, #PAGESIZE
+ mov r0, r0, LSR #LOG2PAGESIZE @ round down to nearest page
+ mov r0, r0, LSL #LOG2PAGESIZE
+1:
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
+#endif
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
+#endif
+ add r0, r0, #DCACHELINESIZE
+ subs r1, r1, #DCACHELINESIZE
+ bne 1b
+
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/* ================================ D-CACHE =============================== */
+
+/*
+ * cpu_arm1020E_dcache_invalidate_range(start, end)
+ *
+ * throw away all D-cached data in specified region without an obligation
+ * to write them back. Note however that we must clean the D-cached entries
+ * around the boundaries if the start and/or end address are not cache
+ * aligned.
+ *
+ * start: virtual start address
+ * end: virtual end address
+ */
+ .align 5
+ENTRY(cpu_arm1020E_dcache_invalidate_range)
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ bic r0, r0, #DCACHELINESIZE - 1
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ tst r0, #DCACHELINESIZE - 1
+ bic r0, r0, #DCACHELINESIZE - 1
+ mcrne p15, 0, r0, c7, c10, 1 @ clean D entry at start
+ tst r1, #DCACHELINESIZE - 1
+ mcrne p15, 0, r1, c7, c10, 1 @ clean D entry at end
+#endif
+
+1:
+#ifdef CONFIG_CPU_DCACHE_ENABLE
+ mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
+#endif
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
+#endif
+ add r0, r0, #DCACHELINESIZE
+ cmp r0, r1
+ bls 1b
+
+ /* Even if the D cache is off still drain the write buffer */
+ mov r0, #0
+ mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_dcache_clean_range(start, end)
+ *
+ * For the specified virtual address range, ensure that all caches contain
+ * clean data, such that peripheral accesses to the physical RAM fetch
+ * correct data.
+ *
+ * start: virtual start address
+ * end: virtual end address
+ */
+ .align 5
+ENTRY(cpu_arm1020E_dcache_clean_range)
+
+ mov r2, #0
+
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ bic r0, r0, #DCACHELINESIZE - 1
+ sub r3, r1, r0
+ cmp r3, #MAX_AREA_SIZE
+ bhs cpu_arm1020E_cache_clean_invalidate_all_r2
+
+1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
+ add r0, r0, #DCACHELINESIZE
+ cmp r0, r1
+ bls 1b
+#endif
+
+ mcr p15, 0, r2, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_dcache_clean_page(page)
+ *
+ * Cleans a single page of dcache so that if we have any future aliased
+ * mappings, they will be consistent at the time that they are created.
+ *
+ * page: virtual address of page to clean from dcache
+ *
+ * Note:
+ * we don't invalidate the entries since when we write the page
+ * out to disk, the entries may get reloaded into the cache.
+ */
+ .align 5
+ENTRY(cpu_arm1020E_dcache_clean_page)
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mov r0, r0, LSR #LOG2PAGESIZE @ round down to nearest page
+ mov r0, r0, LSL #LOG2PAGESIZE
+ mov r1, #PAGESIZE
+1:
+ mcr p15, 0, r0, c7, c10, 1 @ clean D entry
+ add r0, r0, #DCACHELINESIZE
+ subs r1, r1, #DCACHELINESIZE
+ bne 1b
+#endif
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_dcache_clean_entry(addr)
+ *
+ * Clean the specified entry of any caches such that the MMU
+ * translation fetches will obtain correct data.
+ *
+ * addr: cache-unaligned virtual address
+ */
+ .align 5
+ENTRY(cpu_arm1020E_dcache_clean_entry)
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ bic r0, r0, #DCACHELINESIZE - 1
+ mcr p15, 0, r0, c7, c10, 1 @ clean single D entry
+#endif
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/* ================================ I-CACHE =============================== */
+
+/*
+ * cpu_arm1020E_icache_invalidate_range(start, end)
+ *
+ * invalidate a range of virtual addresses from the Icache
+ *
+ * This is a little misleading, it is not intended to clean out
+ * the i-cache but to make sure that any data written to the
+ * range is made consistent. This means that when we execute code
+ * in that region, everything works as we expect.
+ *
+ * This generally means writing back data in the Dcache and
+ * write buffer and invalidating the Icache over that region
+ *
+ * start: virtual start address
+ * end: virtual end address
+ *
+ * NOTE: ICACHELINESIZE == DCACHELINESIZE (so we don't need to
+ * loop twice, once for i-cache, once for d-cache)
+ */
+ .align 5
+ENTRY(cpu_arm1020E_icache_invalidate_range)
+ bic r0, r0, #ICACHELINESIZE - 1
+ sub r3, r1, r0
+ cmp r3, #MAX_AREA_SIZE
+ movhs r2, #1
+ bhs cpu_arm1020E_cache_clean_invalidate_all_r2
+
+1:
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c10, 1 @ Clean D entry
+#endif
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ mcr p15, 0, r0, c7, c5, 1 @ Invalidate I entry
+#endif
+ add r0, r0, #DCACHELINESIZE
+ cmp r0, r1
+ bls 1b @ unsigned lower or same - includes r1 entry
+
+ mov r0, #0
+ mcr p15, 0, r0, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+ENTRY(cpu_arm1020E_icache_invalidate_page)
+ mov r0, r0, LSR #LOG2PAGESIZE @ round down to nearest page
+ mov r0, r0, LSL #LOG2PAGESIZE
+ add r1, r0, #PAGESIZE
+ b cpu_arm1020E_icache_invalidate_range
+
+/* ================================== TLB ================================= */
+
+/*
+ * cpu_arm1020E_tlb_invalidate_all()
+ *
+ * Invalidate all TLB entries
+ */
+ .align 5
+ENTRY(cpu_arm1020E_tlb_invalidate_all)
+ mov r0, #0
+ mcr p15, 0, r0, c7, c10, 4 @ drain WB
+ mcr p15, 0, r0, c8, c7, 0 @ invalidate I & D tlbs
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_tlb_invalidate_range(start, end)
+ *
+ * invalidate TLB entries covering the specified range
+ *
+ * start: range start address
+ * end: range end address
+ */
+ .align 5
+ENTRY(cpu_arm1020E_tlb_invalidate_range)
+ sub r3, r1, r0
+ cmp r3, #256 * PAGESIZE
+ bhs cpu_arm1020E_tlb_invalidate_all
+ mov r3, #0
+ mcr p15, 0, r3, c7, c10, 4 @ drain WB
+ mov r3, #PAGESIZE
+ sub r3, r3, #1
+ bic r0, r0, r3
+1: mcr p15, 0, r0, c8, c6, 1 @ invalidate D TLB entry
+ mcr p15, 0, r0, c8, c5, 1 @ invalidate I TLB entry
+ add r0, r0, #PAGESIZE
+ cmp r0, r1
+ bls 1b
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_tlb_invalidate_page(page, flags)
+ *
+ * invalidate the TLB entries for the specified page.
+ *
+ * page: page to invalidate
+ * flags: non-zero if we include the I TLB
+ */
+ .align 5
+ENTRY(cpu_arm1020E_tlb_invalidate_page)
+ mov r3, #0
+ mcr p15, 0, r3, c7, c10, 4 @ drain WB
+ mov r0, r0, LSR #LOG2PAGESIZE @ round down to nearest page
+ mov r0, r0, LSL #LOG2PAGESIZE
+ teq r1, #0
+ mcr p15, 0, r0, c8, c6, 1 @ invalidate D TLB entry
+ mcrne p15, 0, r0, c8, c5, 1 @ invalidate I TLB entry
+ mov pc, lr
+
+/* =============================== PageTable ============================== */
+
+/*
+ * cpu_arm1020E_set_pgd(pgd)
+ *
+ * Set the translation base pointer to be as described by pgd.
+ *
+ * pgd: new page tables
+ */
+ .align 5
+ENTRY(cpu_arm1020E_set_pgd)
+ stmfd sp!, {lr}
+ bl cpu_arm1020E_cache_clean_invalidate_all @ preserves r0
+ mov r1, #0
+ mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
+ mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
+ ldmfd sp!, {pc}
+
+/*
+ * cpu_arm1020E_set_pmd(pmdp, pmd)
+ *
+ * Set a level 1 translation table entry, and clean it out of
+ * any caches such that the MMUs can load it correctly.
+ *
+ * pmdp: pointer to PMD entry
+ * pmd: PMD value to store
+ */
+ .align 5
+ENTRY(cpu_arm1020E_set_pmd)
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ eor r2, r1, #0x0a @ C & Section
+ tst r2, #0x0b
+ biceq r1, r1, #4 @ clear bufferable bit
+#endif
+ str r1, [r0]
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c10, 1 @ clean D entry
+#endif
+ mov r0, #0
+ mcr p15, 0, r0, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1020E_set_pte(ptep, pte)
+ *
+ * Set a PTE and flush it out
+ */
+ .align 5
+ENTRY(cpu_arm1020E_set_pte)
+ str r1, [r0], #-1024 @ linux version
+
+ eor r1, r1, #LPTE_PRESENT | LPTE_YOUNG | LPTE_WRITE | LPTE_DIRTY
+
+ bic r2, r1, #0xff0
+ bic r2, r2, #3
+ orr r2, r2, #HPTE_TYPE_SMALL
+
+ tst r1, #LPTE_USER @ User?
+ orrne r2, r2, #HPTE_AP_READ
+
+ tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
+ orreq r2, r2, #HPTE_AP_WRITE
+
+ tst r1, #LPTE_PRESENT | LPTE_YOUNG @ Present and Young?
+ movne r2, #0
+
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ eor r3, r2, #0x0a @ C and Small Page?
+ tst r3, #0x0b @ if so..
+ biceq r2, r2, #0x04 @ clear the bufferable bit
+#endif
+ str r2, [r0] @ hardware version
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c10, 1 @ clean D entry
+#endif
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+
+cpu_manu_name:
+ .asciz "ARM"
+ENTRY(cpu_arm1020E_name)
+ .ascii "Arm1020E"
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ .ascii "i"
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ .ascii "d"
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ .ascii "(wt)"
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ .ascii "(wb)"
+#endif
+#endif
+#ifndef CONFIG_CPU_BPREDICT_DISABLE
+ .ascii "B"
+#endif
+#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
+ .ascii "RR"
+#endif
+ .ascii "\0"
+ .align
+
+ .section ".text.init", #alloc, #execinstr
+
+__arm1020E_setup:
+ mov r0, #0
+ mcr p15, 0, r0, c7, c7, 0 @ invalidate I,D caches on v4
+ mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
+ mcr p15, 0, r0, c8, c7, 0 @ invalidate I,D TLBs on v4
+ mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
+ mov r0, #0x1f @ Domains 0, 1 = client
+ mcr p15, 0, r0, c3, c0, 0 @ load domain access register
+
+ mrc p15, 0, r0, c1, c0, 0 @ Read current control register
+/*
+ * The only thing worth keeping from the initial control register is the endian bit
+ */
+
+ and r0, r0, #0x0080 @ ........B....... Preserve endian bit, zero all others.
+ orr r0, r0, #0x0070 @ .........111.... Set the SBO (Should Be One) bits
+/*
+ * Turn on what we want.
+ */
+ orr r0, r0, #0x0001 @ ...............M Enable MMU (Alignment is special cased elsewhere)
+ orr r0, r0, #0x0100 @ .......S........ Enable system MMU protection
+ orr r0, r0, #0x2000 @ ..V............. Enable high vectors
+
+#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
+ orr r0, r0, #0x4000 @ .R.............. Force round-robin replacement
+#endif
+
+#ifndef CONFIG_CPU_BPREDICT_DISABLE
+ orr r0, r0, #0x0800 @ ....Z........... Enable branch prediction
+#endif
+
+#ifdef CONFIG_CPU_DCACHE_ENABLE
+ orr r0, r0, #0x0004 @ .............C.. Enable D cache
+#endif
+#ifndef CONFIG_CPU_WB_DISABLE
+ orr r0, r0, #0x0008 @ ............W... Write Buffer enabled
+#endif
+
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ orr r0, r0, #0x1000 @ ...I............ Enable I Cache
+#endif
+
+ mov pc, lr
+
+ .text
+
+/*
+ * Purpose : Function pointers used to access above functions - all calls
+ * come through these
+ */
+ .type arm1020E_processor_functions, #object
+arm1020E_processor_functions:
+ .word cpu_arm1020E_data_abort
+ .word cpu_arm1020E_check_bugs
+ .word cpu_arm1020E_proc_init
+ .word cpu_arm1020E_proc_fin
+ .word cpu_arm1020E_reset
+ .word cpu_arm1020E_do_idle
+
+ /* cache */
+ .word cpu_arm1020E_cache_clean_invalidate_all
+ .word cpu_arm1020E_cache_clean_invalidate_range
+ .word cpu_arm1020E_flush_ram_page
+
+ /* dcache */
+ .word cpu_arm1020E_dcache_invalidate_range
+ .word cpu_arm1020E_dcache_clean_range
+ .word cpu_arm1020E_dcache_clean_page
+ .word cpu_arm1020E_dcache_clean_entry
+
+ /* icache */
+ .word cpu_arm1020E_icache_invalidate_range
+ .word cpu_arm1020E_icache_invalidate_page
+
+ /* tlb */
+ .word cpu_arm1020E_tlb_invalidate_all
+ .word cpu_arm1020E_tlb_invalidate_range
+ .word cpu_arm1020E_tlb_invalidate_page
+
+ /* pgtable */
+ .word cpu_arm1020E_set_pgd
+ .word cpu_arm1020E_set_pmd
+ .word cpu_arm1020E_set_pte
+ .size arm1020E_processor_functions, . - arm1020E_processor_functions
+
+ .type cpu_arm1020E_info, #object
+cpu_arm1020E_info:
+ .long cpu_manu_name
+ .long cpu_arm1020E_name
+ .size cpu_arm1020E_info, . - cpu_arm1020E_info
+
+ .type cpu_arch_name, #object
+cpu_arch_name:
+ .asciz "armv5te"
+ .size cpu_arch_name, . - cpu_arch_name
+
+ .type cpu_elf_name, #object
+cpu_elf_name:
+ .asciz "v5"
+ .size cpu_elf_name, . - cpu_elf_name
+ .align
+
+ .section ".proc.info", #alloc, #execinstr
+
+ .type __arm1020E_proc_info,#object
+__arm1020E_proc_info:
+ .long 0x4105a200 @ ARM 1020E (Architecture v5TE)
+ .long 0xff0ffff0
+ .long 0x00000c1e @ mmuflags
+ b __arm1020E_setup
+ .long cpu_arch_name
+ .long cpu_elf_name
+ .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
+ .long cpu_arm1020E_info
+ .long arm1020E_processor_functions
+ .size __arm1020E_proc_info, . - __arm1020E_proc_info
+
diff -urN linux-2.4.26/arch/arm/mm/proc-arm1022.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm1022.S
--- linux-2.4.26/arch/arm/mm/proc-arm1022.S 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm1022.S 2004-01-14 21:32:24.000000000 +0000
@@ -0,0 +1,716 @@
+/*
+ * linux/arch/arm/mm/proc-arm1022.S: MMU functions for ARM1022E
+ *
+ * Copyright (C) 2000 ARM Limited
+ * Copyright (C) 2000 Deep Blue Solutions Ltd.
+ *
+ * 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
+ *
+ *
+ * These are the low level assembler for performing cache and TLB
+ * functions on the arm1022E.
+ */
+#include <linux/linkage.h>
+#include <linux/config.h>
+#include <asm/assembler.h>
+#include <asm/constants.h>
+#include <asm/procinfo.h>
+#include <asm/hardware.h>
+
+/*
+ * This is the maximum size of an area which will be invalidated
+ * using the single invalidate entry instructions. Anything larger
+ * than this, and we go for the whole cache.
+ *
+ * This value should be chosen such that we choose the cheapest
+ * alternative.
+ */
+#define MAX_AREA_SIZE 16384
+
+/*
+ * the cache line size of the I and D cache
+ */
+#define DCACHELINESIZE 32
+#define ICACHELINESIZE 32
+
+/*
+ * and the page size
+ */
+#define LOG2PAGESIZE 12 /* == 4096 Bytes */
+#define PAGESIZE (1 << LOG2PAGESIZE)
+
+/*
+ * create some useful conditional macro definitions
+ * we often need to know if we are ((not dcache disable) and writethrough) or ((not dcache disable) and writeback)
+ */
+#ifdef CONFIG_CPU_DCACHE_DISABLE
+ #undef CONFIG_CPU_DCACHE_WRITETHROUGH
+ #undef CONFIG_CPU_DCACHE_WRITEBACK
+ #undef CONFIG_CPU_DCACHE_ENABLE
+#else
+ #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ #undef CONFIG_CPU_DCACHE_WRITEBACK
+ #else
+ #define CONFIG_CPU_DCACHE_WRITEBACK
+ #endif
+ #define CONFIG_CPU_DCACHE_ENABLE
+#endif
+
+#ifdef CONFIG_CPU_ICACHE_DISABLE
+ #undef CONFIG_CPU_ICACHE_ENABLE
+#else
+ #define CONFIG_CPU_ICACHE_ENABLE
+#endif
+
+ .text
+
+/*
+ * cpu_arm1022_data_abort()
+ *
+ * obtain information about current aborted instruction
+ * Note: we read user space. This means we might cause a data
+ * abort here if the I-TLB and D-TLB aren't seeing the same
+ * picture. Unfortunately, this does happen. We live with it.
+ *
+ * r2 = address of aborted instruction
+ * r3 = cpsr
+ *
+ * Returns:
+ * r0 = address of abort
+ * r1 = FSR
+ * r3 = corrupted
+ * r4 = corrupted
+ */
+ .align 5
+ENTRY(cpu_arm1022_data_abort)
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
+ mrc p15, 0, r0, c6, c0, 0 @ get FAR
+ tst r3, #PSR_T_BIT
+ ldrneh r3, [r2] @ read aborted thumb instruction
+ ldreq r3, [r2] @ read aborted ARM instruction
+ bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
+ movne r3, r3, lsl #(21 - 12) @ move thumb bit 11 to ARM bit 20
+ tst r3, #1 << 20 @ check write
+ orreq r1, r1, #1 << 11
+ mov pc, lr
+
+/*
+ * cpu_arm1022_check_bugs()
+ */
+ENTRY(cpu_arm1022_check_bugs)
+ mrs ip, cpsr
+ bic ip, ip, #F_BIT
+ msr cpsr, ip
+ mov pc, lr
+
+/*
+ * cpu_arm1022_proc_init()
+ */
+ENTRY(cpu_arm1022_proc_init)
+ mov pc, lr
+
+/*
+ * cpu_arm1022_proc_fin()
+ */
+ENTRY(cpu_arm1022_proc_fin)
+ stmfd sp!, {lr}
+ mov ip, #F_BIT | I_BIT | SVC_MODE
+ msr cpsr_c, ip
+ bl cpu_arm1022_cache_clean_invalidate_all
+ mrc p15, 0, r0, c1, c0, 0 @ ctrl register
+ bic r0, r0, #0x1000 @ ...i............
+ bic r0, r0, #0x000e @ ............wca.
+ mcr p15, 0, r0, c1, c0, 0 @ disable caches
+ ldmfd sp!, {pc}
+
+/*
+ * cpu_arm1022_reset(loc)
+ *
+ * Perform a soft reset of the system. Put the CPU into the
+ * same state as it would be if it had been reset, and branch
+ * to what would be the reset vector.
+ *
+ * loc: location to jump to for soft reset
+ */
+ .align 5
+ENTRY(cpu_arm1022_reset)
+ mov ip, #0
+ mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
+ mcr p15, 0, ip, c7, c10, 4 @ drain WB
+ mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
+ mrc p15, 0, ip, c1, c0, 0 @ ctrl register
+ bic ip, ip, #0x000f @ ............wcam
+ bic ip, ip, #0x1100 @ ...i...s........
+ mcr p15, 0, ip, c1, c0, 0 @ ctrl register
+ mov pc, r0
+
+/*
+ * cpu_arm1022_do_idle()
+ */
+ .align 5
+ENTRY(cpu_arm1022_do_idle)
+ mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
+ mov pc, lr
+
+/* ================================= CACHE ================================ */
+
+
+/*
+ * cpu_arm1022_cache_clean_invalidate_all()
+ *
+ * clean and invalidate all cache lines
+ *
+ * Note:
+ * 1. we should preserve r0 and ip at all times
+ */
+ .align 5
+ENTRY(cpu_arm1022_cache_clean_invalidate_all)
+ mov r2, #1
+cpu_arm1022_cache_clean_invalidate_all_r2:
+
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mov r1, #7 << 5 @ 8 segments
+1: orr r3, r1, #63 << 26 @ 64 entries
+2: mcr p15, 0, r3, c7, c14, 2 @ clean and invalidate D index
+ subs r3, r3, #1 << 26
+ bcs 2b
+ subs r1, r1, #1 << 5
+ bcs 1b @ segments 7 to 0
+#endif
+
+ mov r1, #0
+
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ mcr p15, 0, r1, c7, c6, 0 @ invalidate D cache
+#endif
+
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ teq r2, #0
+ mcrne p15, 0, r1, c7, c5, 0 @ invalidate I cache
+#endif
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1022_cache_clean_invalidate_range(start, end, flags)
+ *
+ * clean and invalidate all cache lines associated with this area of memory
+ *
+ * start: Area start address
+ * end: Area end address
+ * flags: nonzero for I cache as well
+ */
+ .align 5
+ENTRY(cpu_arm1022_cache_clean_invalidate_range)
+ bic r0, r0, #DCACHELINESIZE - 1
+ sub r3, r1, r0
+ cmp r3, #MAX_AREA_SIZE
+ bhs cpu_arm1022_cache_clean_invalidate_all_r2
+1:
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
+#endif
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ teq r2, #0
+ mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
+#endif
+ add r0, r0, #DCACHELINESIZE
+ cmp r0, r1
+ bls 1b @ unsigned lower or same - must include end point (r1)!
+
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1022_flush_ram_page(page)
+ *
+ * clean and invalidate all cache lines associated with this area of memory
+ *
+ * page: page to clean and invalidate
+ */
+ .align 5
+ENTRY(cpu_arm1022_flush_ram_page)
+ mov r1, #PAGESIZE
+ mov r0, r0, LSR #LOG2PAGESIZE @ round down to nearest page
+ mov r0, r0, LSL #LOG2PAGESIZE
+1:
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
+#endif
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
+#endif
+ add r0, r0, #DCACHELINESIZE
+ subs r1, r1, #DCACHELINESIZE
+ bne 1b
+
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/* ================================ D-CACHE =============================== */
+
+/*
+ * cpu_arm1022_dcache_invalidate_range(start, end)
+ *
+ * throw away all D-cached data in specified region without an obligation
+ * to write them back. Note however that we must clean the D-cached entries
+ * around the boundaries if the start and/or end address are not cache
+ * aligned.
+ *
+ * start: virtual start address
+ * end: virtual end address
+ */
+ .align 5
+ENTRY(cpu_arm1022_dcache_invalidate_range)
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ bic r0, r0, #DCACHELINESIZE - 1
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ tst r0, #DCACHELINESIZE - 1
+ bic r0, r0, #DCACHELINESIZE - 1
+ mcrne p15, 0, r0, c7, c10, 1 @ clean D entry at start
+ tst r1, #DCACHELINESIZE - 1
+ mcrne p15, 0, r1, c7, c10, 1 @ clean D entry at end
+#endif
+
+1:
+#ifdef CONFIG_CPU_DCACHE_ENABLE
+ mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
+#endif
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
+#endif
+ add r0, r0, #DCACHELINESIZE
+ cmp r0, r1
+ bls 1b
+
+ /* Even if the D cache is off still drain the write buffer */
+ mov r0, #0
+ mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
+ mov pc, lr
+
+/*
+ * cpu_arm1022_dcache_clean_range(start, end)
+ *
+ * For the specified virtual address range, ensure that all caches contain
+ * clean data, such that peripheral accesses to the physical RAM fetch
+ * correct data.
+ *
+ * start: virtual start address
+ * end: virtual end address
+ */
+ .align 5
+ENTRY(cpu_arm1022_dcache_clean_range)
+
+ mov r2, #0
+
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ bic r0, r0, #DCACHELINESIZE - 1
+ sub r3, r1, r0
+ cmp r3, #MAX_AREA_SIZE
+ bhs cpu_arm1022_cache_clean_invalidate_all_r2
+
+1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
+ add r0, r0, #DCACHELINESIZE
+ cmp r0, r1
+ bls 1b
+#endif
+
+ mcr p15, 0, r2, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1022_dcache_clean_page(page)
+ *
+ * Cleans a single page of dcache so that if we have any future aliased
+ * mappings, they will be consistent at the time that they are created.
+ *
+ * page: virtual address of page to clean from dcache
+ *
+ * Note:
+ * we don't invalidate the entries since when we write the page
+ * out to disk, the entries may get reloaded into the cache.
+ */
+ .align 5
+ENTRY(cpu_arm1022_dcache_clean_page)
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mov r0, r0, LSR #LOG2PAGESIZE @ round down to nearest page
+ mov r0, r0, LSL #LOG2PAGESIZE
+ mov r1, #PAGESIZE
+1:
+ mcr p15, 0, r0, c7, c10, 1 @ clean D entry
+ add r0, r0, #DCACHELINESIZE
+ subs r1, r1, #DCACHELINESIZE
+ bne 1b
+#endif
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1022_dcache_clean_entry(addr)
+ *
+ * Clean the specified entry of any caches such that the MMU
+ * translation fetches will obtain correct data.
+ *
+ * addr: cache-unaligned virtual address
+ */
+ .align 5
+ENTRY(cpu_arm1022_dcache_clean_entry)
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ bic r0, r0, #DCACHELINESIZE - 1
+ mcr p15, 0, r0, c7, c10, 1 @ clean single D entry
+#endif
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/* ================================ I-CACHE =============================== */
+
+/*
+ * cpu_arm1022_icache_invalidate_range(start, end)
+ *
+ * invalidate a range of virtual addresses from the Icache
+ *
+ * This is a little misleading, it is not intended to clean out
+ * the i-cache but to make sure that any data written to the
+ * range is made consistent. This means that when we execute code
+ * in that region, everything works as we expect.
+ *
+ * This generally means writing back data in the Dcache and
+ * write buffer and invalidating the Icache over that region
+ *
+ * start: virtual start address
+ * end: virtual end address
+ *
+ * NOTE: ICACHELINESIZE == DCACHELINESIZE (so we don't need to
+ * loop twice, once for i-cache, once for d-cache)
+ */
+ .align 5
+ENTRY(cpu_arm1022_icache_invalidate_range)
+ bic r0, r0, #ICACHELINESIZE - 1
+ sub r3, r1, r0
+ cmp r3, #MAX_AREA_SIZE
+ movhs r2, #1
+ bhs cpu_arm1022_cache_clean_invalidate_all_r2
+1:
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c10, 1 @ Clean D entry
+#endif
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ mcr p15, 0, r0, c7, c5, 1 @ Invalidate I entry
+#endif
+ add r0, r0, #DCACHELINESIZE
+ cmp r0, r1
+ bls 1b @ unsigned lower or same - includes r1 entry
+
+ mov r0, #0
+ mcr p15, 0, r0, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+ENTRY(cpu_arm1022_icache_invalidate_page)
+ mov r0, r0, LSR #LOG2PAGESIZE @ round down to nearest page
+ mov r0, r0, LSL #LOG2PAGESIZE
+ add r1, r0, #PAGESIZE
+ b cpu_arm1022_icache_invalidate_range
+
+/* ================================== TLB ================================= */
+
+/*
+ * cpu_arm1022_tlb_invalidate_all()
+ *
+ * Invalidate all TLB entries
+ */
+ .align 5
+ENTRY(cpu_arm1022_tlb_invalidate_all)
+ mov r0, #0
+ mcr p15, 0, r0, c7, c10, 4 @ drain WB
+ mcr p15, 0, r0, c8, c7, 0 @ invalidate I & D tlbs
+ mov pc, lr
+
+/*
+ * cpu_arm1022_tlb_invalidate_range(start, end)
+ *
+ * invalidate TLB entries covering the specified range
+ *
+ * start: range start address
+ * end: range end address
+ */
+ .align 5
+ENTRY(cpu_arm1022_tlb_invalidate_range)
+ sub r3, r1, r0
+ cmp r3, #256 * PAGESIZE
+ bhs cpu_arm1022_tlb_invalidate_all
+ mov r3, #0
+ mcr p15, 0, r3, c7, c10, 4 @ drain WB
+ mov r3, #PAGESIZE
+ sub r3, r3, #1
+ bic r0, r0, r3
+1: mcr p15, 0, r0, c8, c6, 1 @ invalidate D TLB entry
+ mcr p15, 0, r0, c8, c5, 1 @ invalidate I TLB entry
+ add r0, r0, #PAGESIZE
+ cmp r0, r1
+ bls 1b
+ mov pc, lr
+
+/*
+ * cpu_arm1022_tlb_invalidate_page(page, flags)
+ *
+ * invalidate the TLB entries for the specified page.
+ *
+ * page: page to invalidate
+ * flags: non-zero if we include the I TLB
+ */
+ .align 5
+ENTRY(cpu_arm1022_tlb_invalidate_page)
+ mov r3, #0
+ mcr p15, 0, r3, c7, c10, 4 @ drain WB
+ mov r0, r0, LSR #LOG2PAGESIZE @ round down to nearest page
+ mov r0, r0, LSL #LOG2PAGESIZE
+ teq r1, #0
+ mcr p15, 0, r0, c8, c6, 1 @ invalidate D TLB entry
+ mcrne p15, 0, r0, c8, c5, 1 @ invalidate I TLB entry
+ mov pc, lr
+
+/* =============================== PageTable ============================== */
+
+/*
+ * cpu_arm1022_set_pgd(pgd)
+ *
+ * Set the translation base pointer to be as described by pgd.
+ *
+ * pgd: new page tables
+ */
+ .align 5
+ENTRY(cpu_arm1022_set_pgd)
+ stmfd sp!, {lr}
+ bl cpu_arm1022_cache_clean_invalidate_all @ preserves r0
+ mov r1, #0
+ mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
+ mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
+ ldmfd sp!, {pc}
+
+/*
+ * cpu_arm1022_set_pmd(pmdp, pmd)
+ *
+ * Set a level 1 translation table entry, and clean it out of
+ * any caches such that the MMUs can load it correctly.
+ *
+ * pmdp: pointer to PMD entry
+ * pmd: PMD value to store
+ */
+ .align 5
+ENTRY(cpu_arm1022_set_pmd)
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ eor r2, r1, #0x0a @ C & Section
+ tst r2, #0x0b
+ biceq r1, r1, #4 @ clear bufferable bit
+#endif
+ str r1, [r0]
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c10, 1 @ clean D entry
+#endif
+ mov r0, #0
+ mcr p15, 0, r0, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+/*
+ * cpu_arm1022_set_pte(ptep, pte)
+ *
+ * Set a PTE and flush it out
+ */
+ .align 5
+ENTRY(cpu_arm1022_set_pte)
+ str r1, [r0], #-1024 @ linux version
+
+ eor r1, r1, #LPTE_PRESENT | LPTE_YOUNG | LPTE_WRITE | LPTE_DIRTY
+
+ bic r2, r1, #0xff0
+ bic r2, r2, #3
+ orr r2, r2, #HPTE_TYPE_SMALL
+
+ tst r1, #LPTE_USER @ User?
+ orrne r2, r2, #HPTE_AP_READ
+
+ tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
+ orreq r2, r2, #HPTE_AP_WRITE
+
+ tst r1, #LPTE_PRESENT | LPTE_YOUNG @ Present and Young?
+ movne r2, #0
+
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ eor r3, r2, #0x0a @ C and Small Page?
+ tst r3, #0x0b @ if so..
+ biceq r2, r2, #0x04 @ clear the bufferable bit
+#endif
+ str r2, [r0] @ hardware version
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ mcr p15, 0, r0, c7, c10, 1 @ clean D entry
+#endif
+ mov r1, #0
+ mcr p15, 0, r1, c7, c10, 4 @ drain WB
+ mov pc, lr
+
+
+cpu_manu_name:
+ .asciz "ARM"
+ENTRY(cpu_arm1022_name)
+ .ascii "Arm1022E"
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ .ascii "i"
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ .ascii "d"
+#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
+ .ascii "(wt)"
+#endif
+#ifdef CONFIG_CPU_DCACHE_WRITEBACK
+ .ascii "(wb)"
+#endif
+#endif
+#ifndef CONFIG_CPU_BPREDICT_DISABLE
+ .ascii "B"
+#endif
+#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
+ .ascii "RR"
+#endif
+ .ascii "\0"
+ .align
+
+ .section ".text.init", #alloc, #execinstr
+
+__arm1022_setup:
+ mov r0, #0
+ mcr p15, 0, r0, c7, c7, 0 @ invalidate I,D caches on v4
+ mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
+ mcr p15, 0, r0, c8, c7, 0 @ invalidate I,D TLBs on v4
+ mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
+ mov r0, #0x1f @ Domains 0, 1 = client
+ mcr p15, 0, r0, c3, c0, 0 @ load domain access register
+
+ mrc p15, 0, r0, c1, c0, 0 @ Read current control register
+/*
+ * The only thing worth keeping from the initial control register is the endian bit
+ */
+
+ and r0, r0, #0x0080 @ ........B....... Preserve endian bit, zero all others.
+ orr r0, r0, #0x0070 @ .........111.... Set the SBO (Should Be One) bits
+/*
+ * Turn on what we want.
+ */
+ orr r0, r0, #0x0001 @ ...............M Enable MMU (Alignment is special cased elsewhere)
+ orr r0, r0, #0x0100 @ .......S........ Enable system MMU protection
+ orr r0, r0, #0x2000 @ ..V............. Enable high vectors
+
+#ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
+ orr r0, r0, #0x4000 @ .R.............. Force round-robin replacement
+#endif
+
+#ifndef CONFIG_CPU_BPREDICT_DISABLE
+ orr r0, r0, #0x0800 @ ....Z........... Enable branch prediction
+#endif
+
+#ifdef CONFIG_CPU_DCACHE_ENABLE
+ orr r0, r0, #0x0004 @ .............C.. Enable D cache
+#endif
+#ifndef CONFIG_CPU_WB_DISABLE
+ orr r0, r0, #0x0008 @ ............W... Write Buffer enabled
+#endif
+
+#ifdef CONFIG_CPU_ICACHE_ENABLE
+ orr r0, r0, #0x1000 @ ...I............ Enable I Cache
+#endif
+
+ mov pc, lr
+
+ .text
+
+/*
+ * Purpose : Function pointers used to access above functions - all calls
+ * come through these
+ */
+ .type arm1022_processor_functions, #object
+arm1022_processor_functions:
+ .word cpu_arm1022_data_abort
+ .word cpu_arm1022_check_bugs
+ .word cpu_arm1022_proc_init
+ .word cpu_arm1022_proc_fin
+ .word cpu_arm1022_reset
+ .word cpu_arm1022_do_idle
+
+ /* cache */
+ .word cpu_arm1022_cache_clean_invalidate_all
+ .word cpu_arm1022_cache_clean_invalidate_range
+ .word cpu_arm1022_flush_ram_page
+
+ /* dcache */
+ .word cpu_arm1022_dcache_invalidate_range
+ .word cpu_arm1022_dcache_clean_range
+ .word cpu_arm1022_dcache_clean_page
+ .word cpu_arm1022_dcache_clean_entry
+
+ /* icache */
+ .word cpu_arm1022_icache_invalidate_range
+ .word cpu_arm1022_icache_invalidate_page
+
+ /* tlb */
+ .word cpu_arm1022_tlb_invalidate_all
+ .word cpu_arm1022_tlb_invalidate_range
+ .word cpu_arm1022_tlb_invalidate_page
+
+ /* pgtable */
+ .word cpu_arm1022_set_pgd
+ .word cpu_arm1022_set_pmd
+ .word cpu_arm1022_set_pte
+ .size arm1022_processor_functions, . - arm1022_processor_functions
+
+ .type cpu_arm1022_info, #object
+cpu_arm1022_info:
+ .long cpu_manu_name
+ .long cpu_arm1022_name
+ .size cpu_arm1022_info, . - cpu_arm1022_info
+
+ .type cpu_arch_name, #object
+cpu_arch_name:
+ .asciz "armv5t"
+ .size cpu_arch_name, . - cpu_arch_name
+
+ .type cpu_elf_name, #object
+cpu_elf_name:
+ .asciz "v5"
+ .size cpu_elf_name, . - cpu_elf_name
+ .align
+
+ .section ".proc.info", #alloc, #execinstr
+
+ .type __arm1022_proc_info,#object
+__arm1022_proc_info:
+ .long 0x4100a220 @ ARM 1022
+ .long 0xff00fff0
+ .long 0x00000c1e @ mmuflags
+ b __arm1022_setup
+ .long cpu_arch_name
+ .long cpu_elf_name
+ .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
+ .long cpu_arm1022_info
+ .long arm1022_processor_functions
+ .size __arm1022_proc_info, . - __arm1022_proc_info
diff -urN linux-2.4.26/arch/arm/mm/proc-arm1026.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm1026.S
--- linux-2.4.26/arch/arm/mm/proc-arm1026.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm1026.S 2004-02-10 23:03:10.000000000 +0000
@@ -66,19 +66,24 @@
*
* Returns:
* r0 = address of abort
- * r1 != 0 if writing
- * r3 = FSR
+ * r1 = FSR, bit 11 set if writing
+ * r3 = corrupted
* r4 = corrupted
*/
.align 5
ENTRY(cpu_arm1026_data_abort)
- mrc p15, 0, r3, c5, c0, 0 @ get FSR
- and r2, r3, #0b1101 @ Check for translation error
- sub r1, r2, #0b0101
-
- and r3, r3, #255
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
mrc p15, 0, r0, c6, c0, 0 @ get FAR
-
+ bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
+ tst r3, #PSR_J_BIT @ Java?
+ orrne r1, r1, #1 << 11 @ always assume write
+ movne pc, lr
+ tst r3, #PSR_T_BIT
+ ldrneh r3, [r2] @ read aborted thumb instruction
+ ldreq r3, [r2] @ read aborted ARM instruction
+ movne r3, r3, lsl #(21 - 12) @ move thumb bit 11 to ARM bit 20
+ tst r3, #1 << 20 @ check write
+ orreq r1, r1, #1 << 11
mov pc, lr
/*
@@ -254,7 +259,7 @@
*/
.align 5
ENTRY(cpu_arm1026_dcache_invalidate_range)
-#ifndef CONFIG_CPU_ARM1026_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
tst r0, #DCACHELINESIZE - 1
mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
tst r1, #DCACHELINESIZE - 1
@@ -279,7 +284,7 @@
*/
.align 5
ENTRY(cpu_arm1026_dcache_clean_range)
-#ifndef CONFIG_CPU_ARM1026_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
bic r0, r0, #DCACHELINESIZE - 1
sub r3, r1, r0
cmp r3, #MAX_AREA_SIZE
@@ -309,7 +314,7 @@
*/
.align 5
ENTRY(cpu_arm1026_dcache_clean_page)
-#ifndef CONFIG_CPU_ARM1026_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mov r1, #PAGESIZE
1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
add r0, r0, #DCACHELINESIZE
@@ -330,7 +335,7 @@
*/
.align 5
ENTRY(cpu_arm1026_dcache_clean_entry)
-#ifndef CONFIG_CPU_ARM1026_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mcr p15, 0, r0, c7, c10, 1 @ clean D entry
#endif
mcr p15, 0, r0, c7, c10, 4 @ drain WB
@@ -473,7 +478,7 @@
biceq r1, r1, #4 @ clear bufferable bit
#endif
str r1, [r0]
-#ifndef CONFIG_CPU_ARM1026_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mcr p15, 0, r0, c7, c10, 1 @ clean D entry
#endif
mcr p15, 0, r0, c7, c10, 4 @ drain WB
@@ -494,7 +499,7 @@
bic r2, r2, #3
orr r2, r2, #HPTE_TYPE_SMALL
- tst r1, #LPTE_USER | LPTE_EXEC @ User or Exec?
+ tst r1, #LPTE_USER @ User?
orrne r2, r2, #HPTE_AP_READ
tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
@@ -634,12 +639,12 @@
.type cpu_arch_name, #object
cpu_arch_name:
- .asciz "armv5EJ"
+ .asciz "armv5tej"
.size cpu_arch_name, . - cpu_arch_name
.type cpu_elf_name, #object
cpu_elf_name:
- .asciz "v5EJ"
+ .asciz "v5"
.size cpu_elf_name, . - cpu_elf_name
.align
diff -urN linux-2.4.26/arch/arm/mm/proc-arm6,7.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm6,7.S
--- linux-2.4.26/arch/arm/mm/proc-arm6,7.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm6,7.S 2004-01-14 21:38:43.000000000 +0000
@@ -72,7 +72,7 @@
1: mcr p15, 0, r0, c6, c0, 0 @ purge TLB
add r0, r0, #4096
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
ENTRY(cpu_arm7_tlb_invalidate_range)
@@ -85,7 +85,7 @@
1: mcr p15, 0, r0, c6, c0, 0 @ purge TLB
add r0, r0, #0x4000
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
#endif
@@ -110,15 +110,13 @@
* Purpose : obtain information about current aborted instruction
*
* Returns : r0 = address of abort
- * : r1 != 0 if writing
- * : r3 = FSR
+ * : r1 = FSR, bit 11 set if writing
+ * : r3 = corrupted
* : sp = pointer to registers
*/
ENTRY(cpu_arm6_data_abort)
ldr r4, [r0] @ read instruction causing problem
- tst r4, r4, lsr #21 @ C = bit 20
- sbc r1, r1, r1 @ r1 = C - 1
and r2, r4, #14 << 24
teq r2, #8 << 24 @ was it ldm/stm
bne Ldata_simple
@@ -144,14 +142,14 @@
addeq r7, r0, r7, lsl #2 @ Do correction (signed)
Ldata_saver7: str r7, [sp, r5, lsr #14] @ Put register
Ldata_simple: mrc p15, 0, r0, c6, c0, 0 @ get FAR
- mrc p15, 0, r3, c5, c0, 0 @ get FSR
- and r3, r3, #255
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
+ bic r1, r1, #1 << 11 | 1 << 10
+ tst r4, #1 << 20
+ orreq r1, r1, #1 << 11
mov pc, lr
ENTRY(cpu_arm7_data_abort)
ldr r4, [r0] @ read instruction causing problem
- tst r4, r4, lsr #21 @ C = bit 20
- sbc r1, r1, r1 @ r1 = C - 1
and r2, r4, #15 << 24
add pc, pc, r2, lsr #22 @ Now branch to the relevent processing routine
movs pc, lr
@@ -336,7 +334,7 @@
bic r2, r2, #3
orr r2, r2, #HPTE_TYPE_SMALL
- tst r1, #LPTE_USER | LPTE_EXEC @ User or Exec?
+ tst r1, #LPTE_USER @ User?
orrne r2, r2, #HPTE_AP_READ
tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
diff -urN linux-2.4.26/arch/arm/mm/proc-arm720.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm720.S
--- linux-2.4.26/arch/arm/mm/proc-arm720.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm720.S 2004-02-24 09:30:43.000000000 +0000
@@ -97,7 +97,7 @@
1: mcr p15, 0, r0, c8, c7, 1 @ flush TLB (v4)
add r0, r0, #PAGESIZE
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
/*
@@ -124,8 +124,8 @@
* picture. Unfortunately, this does happen. We live with it.
*
* Returns : r0 = address of abort
- * : r1 != 0 if writing
- * : r3 = FSR
+ * : r1 = FSR, bit 11 set if writing
+ * : r3 = corrupted
* : sp = pointer to registers
*/
@@ -150,16 +150,16 @@
addeq r7, r0, r7, lsl #2 @ Do correction (signed)
Ldata_saver7: str r7, [sp, r5, lsr #14] @ Put register
Ldata_simple: mrc p15, 0, r0, c6, c0, 0 @ get FAR
- mrc p15, 0, r3, c5, c0, 0 @ get FSR
- and r3, r3, #255
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
+ bic r1, r1, #1 << 11 | 1 << 10
+ tst r4, #1 << 20
+ orreq r1, r1, #1 << 11
mov pc, lr
ENTRY(cpu_arm720_data_abort)
- tst r3, #T_BIT
+ tst r3, #PSR_T_BIT
bne .data_thumb_abort
- ldr r4, [r0] @ read instruction causing problem
- tst r4, r4, lsr #21 @ C = bit 20
- sbc r1, r1, r1 @ r1 = C - 1
+ ldr r4, [r2] @ read instruction causing problem
and r2, r4, #15 << 24
add pc, pc, r2, lsr #22 @ Now branch to the relevent processing routine
movs pc, lr
@@ -270,9 +270,9 @@
b Ldata_saver7
.data_thumb_abort:
- ldrh r4, [r0] @ read instruction
- tst r4, r4, lsr #12 @ C = bit 11
- sbc r1, r1, r1 @ r1 = C - 1
+ ldrh r4, [r2] @ read instruction
+ tst r4, #1 << 11
+ orrne r4, r4, #1 << 20
and r2, r4, #15 << 12
add pc, pc, r2, lsr #10 @ lookup in table
nop
@@ -318,8 +318,8 @@
and r0, r0, #15 @ number of regs to transfer
ldr r7, [sp, #13 << 2]
tst r4, #1 << 11
- addne r7, r7, r0, lsl #2 @ increment SP if PUSH
- subeq r7, r7, r0, lsr #2 @ decrement SP if POP
+ addeq r7, r7, r0, lsl #2 @ increment SP if PUSH
+ subne r7, r7, r0, lsl #2 @ decrement SP if POP
str r7, [sp, #13 << 2]
b Ldata_simple
@@ -336,7 +336,7 @@
and r0, r0, #15 @ number of regs to transfer
and r5, r4, #7 << 8
ldr r7, [sp, r5, lsr #6]
- sub r7, r7, r0, lsr #2 @ always decrement
+ sub r7, r7, r0, lsl #2 @ always decrement
str r7, [sp, r5, lsr #6]
b Ldata_simple
@@ -418,7 +418,7 @@
bic r2, r2, #3
orr r2, r2, #HPTE_TYPE_SMALL
- tst r1, #LPTE_USER | LPTE_EXEC @ User or Exec?
+ tst r1, #LPTE_USER @ User?
orrne r2, r2, #HPTE_AP_READ
tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
diff -urN linux-2.4.26/arch/arm/mm/proc-arm920.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm920.S
--- linux-2.4.26/arch/arm/mm/proc-arm920.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm920.S 2004-01-14 21:32:24.000000000 +0000
@@ -71,12 +71,16 @@
*/
.align 5
ENTRY(cpu_arm920_data_abort)
- mrc p15, 0, r3, c5, c0, 0 @ get FSR
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
mrc p15, 0, r0, c6, c0, 0 @ get FAR
- ldr r1, [r2] @ read aborted instruction
- and r3, r3, #255
- tst r1, r1, lsr #21 @ C = bit 20
- sbc r1, r1, r1 @ r1 = C - 1
+
+ tst r3, #PSR_T_BIT
+ ldrneh r3, [r2] @ read aborted thumb instruction
+ ldreq r3, [r2] @ read aborted ARM instruction
+ bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
+ movne r3, r3, lsl #(21 - 12) @ move thumb bit 11 to ARM bit 20
+ tst r3, #1 << 20 @ check write
+ orreq r1, r1, #1 << 11
mov pc, lr
/*
@@ -186,10 +190,9 @@
.align 5
ENTRY(cpu_arm920_cache_clean_invalidate_range)
bic r0, r0, #DCACHELINESIZE - 1 @ && added by PGM
- bic r1, r1, #DCACHELINESIZE - 1 @ && added by DHM
sub r3, r1, r0
cmp r3, #MAX_AREA_SIZE
- bgt cpu_arm920_cache_clean_invalidate_all_r2
+ bhi cpu_arm920_cache_clean_invalidate_all_r2
1: teq r2, #0
#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
@@ -207,7 +210,7 @@
add r0, r0, #DCACHELINESIZE
#endif
cmp r0, r1
- blt 1b
+ blo 1b
mcr p15, 0, r1, c7, c10, 4 @ drain WB
mov pc, lr
@@ -253,18 +256,17 @@
*/
.align 5
ENTRY(cpu_arm920_dcache_invalidate_range)
-#ifndef CONFIG_CPU_ARM920_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
tst r0, #DCACHELINESIZE - 1
mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
tst r1, #DCACHELINESIZE - 1
mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
#endif @ clean D entry
bic r0, r0, #DCACHELINESIZE - 1
- bic r1, r1, #DCACHELINESIZE - 1
1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
add r0, r0, #DCACHELINESIZE
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
/*
@@ -279,20 +281,17 @@
*/
.align 5
ENTRY(cpu_arm920_dcache_clean_range)
-#ifndef CONFIG_CPU_ARM920_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
bic r0, r0, #DCACHELINESIZE - 1
sub r1, r1, r0
cmp r1, #MAX_AREA_SIZE
mov r2, #0
- bgt cpu_arm920_cache_clean_invalidate_all_r2
-
- bic r1, r1, #DCACHELINESIZE -1
- add r1, r1, #DCACHELINESIZE
+ bhi cpu_arm920_cache_clean_invalidate_all_r2
1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
add r0, r0, #DCACHELINESIZE
subs r1, r1, #DCACHELINESIZE
- bpl 1b
+ bcs 1b
#endif
mcr p15, 0, r2, c7, c10, 4 @ drain WB
mov pc, lr
@@ -312,7 +311,7 @@
*/
.align 5
ENTRY(cpu_arm920_dcache_clean_page)
-#ifndef CONFIG_CPU_ARM920_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mov r1, #PAGESIZE
1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
add r0, r0, #DCACHELINESIZE
@@ -333,7 +332,7 @@
*/
.align 5
ENTRY(cpu_arm920_dcache_clean_entry)
-#ifndef CONFIG_CPU_ARM920_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mcr p15, 0, r0, c7, c10, 1 @ clean D entry
#endif
mcr p15, 0, r0, c7, c10, 4 @ drain WB
@@ -365,16 +364,13 @@
bic r0, r0, #ICACHELINESIZE - 1 @ Safety check
sub r1, r1, r0
cmp r1, #MAX_AREA_SIZE
- bgt cpu_arm920_cache_clean_invalidate_all_r2
-
- bic r1, r1, #ICACHELINESIZE - 1
- add r1, r1, #ICACHELINESIZE
+ bhi cpu_arm920_cache_clean_invalidate_all_r2
1: mcr p15, 0, r0, c7, c5, 1 @ Clean I entry
mcr p15, 0, r0, c7, c10, 1 @ Clean D entry
add r0, r0, #ICACHELINESIZE
subs r1, r1, #ICACHELINESIZE
- bne 1b
+ bcs 1b
mov r0, #0
mcr p15, 0, r0, c7, c10, 4 @ drain WB
@@ -418,13 +414,12 @@
mov r3, #PAGESIZE
sub r3, r3, #1
bic r0, r0, r3
- bic r1, r1, r3
1: mcr p15, 0, r0, c8, c6, 1 @ invalidate D TLB entry
mcr p15, 0, r0, c8, c5, 1 @ invalidate I TLB entry
add r0, r0, #PAGESIZE
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
/*
@@ -457,7 +452,6 @@
ENTRY(cpu_arm920_set_pgd)
mov ip, #0
#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
- /* Any reason why we don't use mcr p15, 0, r0, c7, c7, 0 here? --rmk */
mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
#else
@ && 'Clean & Invalidate whole DCache'
@@ -514,7 +508,7 @@
bic r2, r2, #3
orr r2, r2, #HPTE_TYPE_SMALL
- tst r1, #LPTE_USER | LPTE_EXEC @ User or Exec?
+ tst r1, #LPTE_USER @ User?
orrne r2, r2, #HPTE_AP_READ
tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
diff -urN linux-2.4.26/arch/arm/mm/proc-arm922.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm922.S
--- linux-2.4.26/arch/arm/mm/proc-arm922.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm922.S 2004-01-14 21:32:24.000000000 +0000
@@ -62,17 +62,20 @@
*
* Returns:
* r0 = address of abort
- * r1 != 0 if writing
- * r3 = FSR
+ * r1 = FSR, bit 11 set if writing
+ * r3 = corrupted
*/
.align 5
ENTRY(cpu_arm922_data_abort)
- ldr r1, [r0] @ read aborted instruction
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
mrc p15, 0, r0, c6, c0, 0 @ get FAR
- tst r1, r1, lsr #21 @ C = bit 20
- mrc p15, 0, r3, c5, c0, 0 @ get FSR
- sbc r1, r1, r1 @ r1 = C - 1
- and r3, r3, #255
+ tst r3, #PSR_T_BIT
+ ldrneh r3, [r2] @ read aborted thumb instruction
+ ldreq r3, [r2] @ read aborted ARM instruction
+ bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
+ movne r3, r3, lsl #(21 - 12) @ move thumb bit 11 to ARM bit 20
+ tst r3, #1 << 20 @ check write
+ orreq r1, r1, #1 << 11
mov pc, lr
/*
@@ -185,7 +188,7 @@
bic r1, r1, #DCACHELINESIZE - 1 @ && added by DHM
sub r3, r1, r0
cmp r3, #MAX_AREA_SIZE
- bgt cpu_arm922_cache_clean_invalidate_all_r2
+ bhi cpu_arm922_cache_clean_invalidate_all_r2
1: teq r2, #0
#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
@@ -203,7 +206,7 @@
add r0, r0, #DCACHELINESIZE
#endif
cmp r0, r1
- blt 1b
+ blo 1b
mcr p15, 0, r1, c7, c10, 4 @ drain WB
mov pc, lr
@@ -249,7 +252,7 @@
*/
.align 5
ENTRY(cpu_arm922_dcache_invalidate_range)
-#ifndef CONFIG_CPU_ARM922_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
tst r0, #DCACHELINESIZE - 1
mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
tst r1, #DCACHELINESIZE - 1
@@ -260,7 +263,7 @@
1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
add r0, r0, #DCACHELINESIZE
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
/*
@@ -275,12 +278,12 @@
*/
.align 5
ENTRY(cpu_arm922_dcache_clean_range)
-#ifndef CONFIG_CPU_ARM922_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
bic r0, r0, #DCACHELINESIZE - 1
sub r1, r1, r0
cmp r1, #MAX_AREA_SIZE
mov r2, #0
- bgt cpu_arm922_cache_clean_invalidate_all_r2
+ bhi cpu_arm922_cache_clean_invalidate_all_r2
bic r1, r1, #DCACHELINESIZE -1
add r1, r1, #DCACHELINESIZE
@@ -308,7 +311,7 @@
*/
.align 5
ENTRY(cpu_arm922_dcache_clean_page)
-#ifndef CONFIG_CPU_ARM922_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mov r1, #PAGESIZE
1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
add r0, r0, #DCACHELINESIZE
@@ -329,7 +332,7 @@
*/
.align 5
ENTRY(cpu_arm922_dcache_clean_entry)
-#ifndef CONFIG_CPU_ARM922_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mcr p15, 0, r0, c7, c10, 1 @ clean D entry
#endif
mcr p15, 0, r0, c7, c10, 4 @ drain WB
@@ -361,7 +364,7 @@
bic r0, r0, #ICACHELINESIZE - 1 @ Safety check
sub r1, r1, r0
cmp r1, #MAX_AREA_SIZE
- bgt cpu_arm922_cache_clean_invalidate_all_r2
+ bhi cpu_arm922_cache_clean_invalidate_all_r2
bic r1, r1, #ICACHELINESIZE - 1
add r1, r1, #ICACHELINESIZE
@@ -420,7 +423,7 @@
mcr p15, 0, r0, c8, c5, 1 @ invalidate I TLB entry
add r0, r0, #PAGESIZE
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
/*
@@ -510,7 +513,7 @@
bic r2, r2, #3
orr r2, r2, #HPTE_TYPE_SMALL
- tst r1, #LPTE_USER | LPTE_EXEC @ User or Exec?
+ tst r1, #LPTE_USER @ User?
orrne r2, r2, #HPTE_AP_READ
tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
diff -urN linux-2.4.26/arch/arm/mm/proc-arm925.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm925.S
--- linux-2.4.26/arch/arm/mm/proc-arm925.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm925.S 2004-01-14 21:32:24.000000000 +0000
@@ -69,24 +69,24 @@
*
* Returns:
* r0 = address of abort
- * r1 != 0 if writing
- * r3 = FSR
+ * r1 = FSR, bit 11 set if writing
+ * r3 = corrupted
* r4 = corrupted
*/
.align 5
ENTRY(cpu_arm925_data_abort)
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
mrc p15, 0, r0, c6, c0, 0 @ get FAR
- mrc p15, 0, r4, c5, c0, 0 @ get FSR
-
- tst r3, #1<<5 @ Check for Thumb-bit (NE -> found)
- ldrneh r1, [r2] @ Read aborted Thumb instruction
- tstne r1, r1, lsr #12 @ C = bit 11
-
- ldreq r1, [r2] @ Read aborted ARM instruction
- tsteq r1, r1, lsr #21 @ C = bit 20
-
- sbc r1, r1, r1 @ r1 = C - 1
- and r3, r4, #255
+ bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
+ tst r3, #PSR_J_BIT @ Java?
+ orrne r1, r1, #1 << 11 @ always assume write
+ movne pc, lr
+ tst r3, #PSR_T_BIT @ Thumb?
+ ldrneh r3, [r2] @ read aborted thumb instruction
+ ldreq r3, [r2] @ read aborted ARM instruction
+ movne r3, r3, lsl #(21 - 12) @ move thumb bit 11 to ARM bit 20
+ tst r3, #1 << 20 @ L = 0 -> write
+ orreq r1, r1, #1 << 11 @ yes.
mov pc, lr
/*
@@ -207,7 +207,7 @@
bic r1, r1, #DCACHELINESIZE - 1 @ && added by DHM
sub r3, r1, r0
cmp r3, #MAX_AREA_SIZE
- bgt cpu_arm925_cache_clean_invalidate_all_r2
+ bhi cpu_arm925_cache_clean_invalidate_all_r2
1: teq r2, #0
#ifdef CONFIG_CPU_ARM925_WRITETHROUGH
mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
@@ -225,7 +225,7 @@
add r0, r0, #DCACHELINESIZE
#endif
cmp r0, r1
- blt 1b
+ blo 1b
mcr p15, 0, r1, c7, c10, 4 @ drain WB
mov pc, lr
@@ -282,7 +282,7 @@
1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
add r0, r0, #DCACHELINESIZE
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
/*
@@ -302,7 +302,7 @@
sub r1, r1, r0
cmp r1, #MAX_AREA_SIZE
mov r2, #0
- bgt cpu_arm925_cache_clean_invalidate_all_r2
+ bhi cpu_arm925_cache_clean_invalidate_all_r2
bic r1, r1, #DCACHELINESIZE -1
add r1, r1, #DCACHELINESIZE
@@ -383,7 +383,7 @@
bic r0, r0, #ICACHELINESIZE - 1 @ Safety check
sub r1, r1, r0
cmp r1, #MAX_AREA_SIZE
- bgt cpu_arm925_cache_clean_invalidate_all_r2
+ bhi cpu_arm925_cache_clean_invalidate_all_r2
bic r1, r1, #ICACHELINESIZE - 1
add r1, r1, #ICACHELINESIZE
@@ -443,7 +443,7 @@
mcr p15, 0, r0, c8, c5, 1 @ invalidate I TLB entry
add r0, r0, #PAGESIZE
cmp r0, r1
- blt 1b
+ blo 1b
mov pc, lr
/*
@@ -532,7 +532,7 @@
bic r2, r2, #3
orr r2, r2, #HPTE_TYPE_SMALL
- tst r1, #LPTE_USER | LPTE_EXEC @ User or Exec?
+ tst r1, #LPTE_USER @ User?
orrne r2, r2, #HPTE_AP_READ
tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
diff -urN linux-2.4.26/arch/arm/mm/proc-arm926.S linux-2.4.26-vrs1/arch/arm/mm/proc-arm926.S
--- linux-2.4.26/arch/arm/mm/proc-arm926.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-arm926.S 2004-01-14 21:38:43.000000000 +0000
@@ -66,28 +66,24 @@
*
* Returns:
* r0 = address of abort
- * r1 != 0 if writing
- * r3 = FSR
+ * r1 = FSR, bit 11 set if writing
+ * r3 = corrupted
* r4 = corrupted
*/
.align 5
ENTRY(cpu_arm926_data_abort)
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
mrc p15, 0, r0, c6, c0, 0 @ get FAR
- mrc p15, 0, r4, c5, c0, 0 @ get FSR
-
- tst r3, #1<<24 @ Check for Jbit (NE -> found)
- movne r3, #-1 @ Mark as writing
- bne 2f
-
- tst r3, #1<<5 @ Check for Thumb-bit (NE -> found)
- ldrneh r1, [r2] @ Read aborted Thumb instruction
- ldreq r1, [r2] @ Read aborted ARM instruction
- movne r1, r1, lsl #(20-12) @ shift thumb bit 10 to ARM bit 20
- tsteq r1, r1, lsr #21 @ C = bit 20
-
- sbc r1, r1, r1 @ r1 = C - 1
-2:
- and r3, r4, #255
+ bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
+ tst r3, #PSR_J_BIT @ Java?
+ orrne r1, r1, #1 << 11 @ always assume write
+ movne pc, lr
+ tst r3, #PSR_T_BIT @ Thumb?
+ ldrneh r3, [r2] @ read aborted thumb instruction
+ ldreq r3, [r2] @ read aborted ARM instruction
+ movne r3, r3, lsl #(21 - 12) @ move thumb bit 11 to ARM bit 20
+ tst r3, #1 << 20 @ L = 0 -> write
+ orreq r1, r1, #1 << 11 @ yes.
mov pc, lr
/*
@@ -263,7 +259,7 @@
*/
.align 5
ENTRY(cpu_arm926_dcache_invalidate_range)
-#ifndef CONFIG_CPU_ARM926_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
tst r0, #DCACHELINESIZE - 1
mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
tst r1, #DCACHELINESIZE - 1
@@ -288,7 +284,7 @@
*/
.align 5
ENTRY(cpu_arm926_dcache_clean_range)
-#ifndef CONFIG_CPU_ARM926_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
bic r0, r0, #DCACHELINESIZE - 1
sub r3, r1, r0
cmp r3, #MAX_AREA_SIZE
@@ -318,7 +314,7 @@
*/
.align 5
ENTRY(cpu_arm926_dcache_clean_page)
-#ifndef CONFIG_CPU_ARM926_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mov r1, #PAGESIZE
1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
add r0, r0, #DCACHELINESIZE
@@ -339,7 +335,7 @@
*/
.align 5
ENTRY(cpu_arm926_dcache_clean_entry)
-#ifndef CONFIG_CPU_ARM926_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mcr p15, 0, r0, c7, c10, 1 @ clean D entry
#endif
mcr p15, 0, r0, c7, c10, 4 @ drain WB
@@ -482,7 +478,7 @@
biceq r1, r1, #4 @ clear bufferable bit
#endif
str r1, [r0]
-#ifndef CONFIG_CPU_ARM926_WRITETHROUGH
+#ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
mcr p15, 0, r0, c7, c10, 1 @ clean D entry
#endif
mcr p15, 0, r0, c7, c10, 4 @ drain WB
@@ -503,7 +499,7 @@
bic r2, r2, #3
orr r2, r2, #HPTE_TYPE_SMALL
- tst r1, #LPTE_USER | LPTE_EXEC @ User or Exec?
+ tst r1, #LPTE_USER @ User?
orrne r2, r2, #HPTE_AP_READ
tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
diff -urN linux-2.4.26/arch/arm/mm/proc-sa110.S linux-2.4.26-vrs1/arch/arm/mm/proc-sa110.S
--- linux-2.4.26/arch/arm/mm/proc-sa110.S 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/mm/proc-sa110.S 2004-01-14 21:32:24.000000000 +0000
@@ -86,12 +86,12 @@
.align 5
ENTRY(cpu_sa110_data_abort)
ENTRY(cpu_sa1100_data_abort)
- mrc p15, 0, r3, c5, c0, 0 @ get FSR
+ mrc p15, 0, r1, c5, c0, 0 @ get FSR
mrc p15, 0, r0, c6, c0, 0 @ get FAR
- ldr r1, [r2] @ read aborted instruction
- and r3, r3, #255
- tst r1, r1, lsr #21 @ C = bit 20
- sbc r1, r1, r1 @ r1 = C - 1
+ ldr r3, [r2] @ read aborted instruction
+ bic r1, r1, #1 << 11 | 1 << 10 @ clear bits 11 and 10 of FSR
+ tst r3, #1 << 20 @ check write
+ orreq r1, r1, #1 << 11
mov pc, lr
/*
@@ -551,7 +551,7 @@
bic r2, r2, #3
orr r2, r2, #HPTE_TYPE_SMALL
- tst r1, #LPTE_USER | LPTE_EXEC @ User or Exec?
+ tst r1, #LPTE_USER @ User?
orrne r2, r2, #HPTE_AP_READ
tst r1, #LPTE_WRITE | LPTE_DIRTY @ Write and Dirty?
diff -urN linux-2.4.26/arch/arm/tools/mach-types linux-2.4.26-vrs1/arch/arm/tools/mach-types
--- linux-2.4.26/arch/arm/tools/mach-types 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/arm/tools/mach-types 2004-04-19 21:11:38.000000000 +0100
@@ -6,7 +6,7 @@
# To add an entry into this database, please see Documentation/arm/README,
# or contact rmk@arm.linux.org.uk
#
-# Last update: Sat Jun 28 12:10:54 2003
+# Last update: Mon Apr 19 21:11:35 2004
#
# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number
#
@@ -202,7 +202,7 @@
fester SA1100_FESTER FESTER 191
gpi ARCH_GPI GPI 192
smdk2410 ARCH_SMDK2410 SMDK2410 193
-premium ARCH_PREMIUM PREMIUM 194
+i519 ARCH_I519 I519 194
nexio SA1100_NEXIO NEXIO 195
bitbox SA1100_BITBOX BITBOX 196
g200 SA1100_G200 G200 197
@@ -228,7 +228,7 @@
arnold SA1100_ARNOLD ARNOLD 217
psiboard SA1100_PSIBOARD PSIBOARD 218
jz8028 ARCH_JZ8028 JZ8028 219
-h5400 ARCH_IPAQ3 IPAQ3 220
+h5400 ARCH_H5400 H5400 220
forte SA1100_FORTE FORTE 221
acam SA1100_ACAM ACAM 222
abox SA1100_ABOX ABOX 223
@@ -259,7 +259,7 @@
stork_egg ARCH_STORK_EGG STORK_EGG 248
wismo SA1100_WISMO WISMO 249
ezlinx ARCH_EZLINX EZLINX 250
-at91rm9200 ARCH_AT91 AT91 251
+at91rm9200 ARCH_AT91RM9200 AT91RM9200 251
orion ARCH_ORION ORION 252
neptune ARCH_NEPTUNE NEPTUNE 253
hackkit SA1100_HACKKIT HACKKIT 254
@@ -295,12 +295,12 @@
adsbitsyplus SA1100_ADSBITSYPLUS ADSBITSYPLUS 284
adsagc SA1100_ADSAGC ADSAGC 285
stp7312 ARCH_STP7312 STP7312 286
-nx_phnx ARCH_PXA255 PXA255 287
+nx_phnx MACH_NX_PHNX NX_PHNX 287
wep_ep250 ARCH_WEP_EP250 WEP_EP250 288
inhandelf3 ARCH_INHANDELF3 INHANDELF3 289
adi_coyote ARCH_ADI_COYOTE ADI_COYOTE 290
iyonix ARCH_IYONIX IYONIX 291
-damicam_sa1110 ARCH_DAMICAM_SA1110 DAMICAM_SA1110 292
+damicam1 ARCH_DAMICAM_SA1110 DAMICAM_SA1110 292
meg03 ARCH_MEG03 MEG03 293
pxa_whitechapel ARCH_PXA_WHITECHAPEL PXA_WHITECHAPEL 294
nwsc ARCH_NWSC NWSC 295
@@ -356,3 +356,172 @@
seedpxa_c2 ARCH_SEEDPXA_C2 SEEDPXA_C2 345
ixp4xx_mguardpci ARCH_IXP4XX_MGUARD_PCI IXP4XX_MGUARD_PCI 346
h1940 ARCH_H1940 H1940 347
+scorpio ARCH_SCORPIO SCORPIO 348
+viva ARCH_VIVA VIVA 349
+pxa_xcard ARCH_PXA_XCARD PXA_XCARD 350
+csb335 ARCH_CSB335 CSB335 351
+ixrd425 ARCH_IXRD425 IXRD425 352
+iq80315 ARCH_IQ80315 IQ80315 353
+nmp7312 ARCH_NMP7312 NMP7312 354
+cx861xx ARCH_CX861XX CX861XX 355
+enp2611 ARCH_ENP2611 ENP2611 356
+xda SA1100_XDA XDA 357
+csir_ims ARCH_CSIR_IMS CSIR_IMS 358
+ixp421_dnaeeth ARCH_IXP421_DNAEETH IXP421_DNAEETH 359
+pocketserv9200 ARCH_POCKETSERV9200 POCKETSERV9200 360
+toto ARCH_TOTO TOTO 361
+s3c2440 ARCH_S3C2440 S3C2440 362
+ks8695p ARCH_KS8695P KS8695P 363
+se4000 ARCH_SE4000 SE4000 364
+quadriceps ARCH_QUADRICEPS QUADRICEPS 365
+bronco ARCH_BRONCO BRONCO 366
+esl_wireless_tab ARCH_ESL_WIRELESS_TABLETESL_WIRELESS_TABLET 367
+esl_sofcomp ARCH_ESL_SOFCOMP ESL_SOFCOMP 368
+s5c7375 ARCH_S5C7375 S5C7375 369
+spearhead ARCH_SPEARHEAD SPEARHEAD 370
+pantera ARCH_PANTERA PANTERA 371
+prayoglite ARCH_PRAYOGLITE PRAYOGLITE 372
+gumstik ARCH_GUMSTIK GUMSTIK 373
+rcube ARCH_RCUBE RCUBE 374
+rea_olv ARCH_REA_OLV REA_OLV 375
+pxa_iphone ARCH_PXA_IPHONE PXA_IPHONE 376
+s3c3410 ARCH_S3C3410 S3C3410 377
+espd_4510b ARCH_ESPD_4510B ESPD_4510B 378
+mp1x ARCH_MP1X MP1X 379
+at91rm9200tb ARCH_AT91RM9200TB AT91RM9200TB 380
+adsvgx ARCH_ADSVGX ADSVGX 381
+omap_h2 ARCH_OMAP_H2 OMAP_H2 382
+pelee ARCH_PELEE PELEE 383
+e740 MACH_E740 E740 384
+iq80331 ARCH_IQ80331 IQ80331 385
+versatile_pb ARCH_VERSATILE_PB VERSATILE_PB 387
+kev7a400 MACH_KEV7A400 KEV7A400 388
+lpd7a400 MACH_LPD7A400 LPD7A400 389
+lpd7a404 MACH_LPD7A404 LPD7A404 390
+fujitsu_camelot ARCH_FUJITSU_CAMELOT FUJITSU_CAMELOT 391
+janus2m ARCH_JANUS2M JANUS2M 392
+embtf MACH_EMBTF EMBTF 393
+hpm MACH_HPM HPM 394
+smdk2410tk MACH_SMDK2410TK SMDK2410TK 395
+smdk2410aj MACH_SMDK2410AJ SMDK2410AJ 396
+streetracer MACH_STREETRACER STREETRACER 397
+eframe MACH_EFRAME EFRAME 398
+csb337 MACH_CSB337 CSB337 399
+pxa_lark MACH_PXA_LARK PXA_LARK 400
+pxa_pnp2110 MACH_PNP2110 PNP2110 401
+tcc72x MACH_TCC72X TCC72X 402
+altair MACH_ALTAIR ALTAIR 403
+kc3 MACH_KC3 KC3 404
+sinteftd MACH_SINTEFTD SINTEFTD 405
+mainstone MACH_MAINSTONE MAINSTONE 406
+aday4x MACH_ADAY4X ADAY4X 407
+lite300 MACH_LITE300 LITE300 408
+s5c7376 MACH_S5C7376 S5C7376 409
+mt02 MACH_MT02 MT02 410
+mport3s MACH_MPORT3S MPORT3S 411
+ra_alpha MACH_RA_ALPHA RA_ALPHA 412
+xcep MACH_XCEP XCEP 413
+arcom_mercury MACH_ARCOM_MERCURY ARCOM_MERCURY 414
+stargate MACH_STARGATE STARGATE 415
+armadilloj MACH_ARMADILLOJ ARMADILLOJ 416
+elroy_jack MACH_ELROY_JACK ELROY_JACK 417
+backend MACH_BACKEND BACKEND 418
+s5linbox MACH_S5LINBOX S5LINBOX 419
+nomadik MACH_NOMADIK NOMADIK 420
+ia_cpu_9200 MACH_IA_CPU_9200 IA_CPU_9200 421
+at91_bja1 MACH_AT91_BJA1 AT91_BJA1 422
+corgi MACH_CORGI CORGI 423
+poodle MACH_POODLE POODLE 424
+ten MACH_TEN TEN 425
+roverp5p MACH_ROVERP5P ROVERP5P 426
+sc2700 MACH_SC2700 SC2700 427
+ex_eagle MACH_EX_EAGLE EX_EAGLE 428
+nx_pxa12 MACH_NX_PXA12 NX_PXA12 429
+nx_pxa5 MACH_NX_PXA5 NX_PXA5 430
+blackboard2 MACH_BLACKBOARD2 BLACKBOARD2 431
+i819 MACH_I819 I819 432
+ixmb995e MACH_IXMB995E IXMB995E 433
+skyrider MACH_SKYRIDER SKYRIDER 434
+skyhawk MACH_SKYHAWK SKYHAWK 435
+enterprise MACH_ENTERPRISE ENTERPRISE 436
+dep2410 MACH_DEP2410 DEP2410 437
+armcore MACH_ARMCORE ARMCORE 438
+hobbit MACH_HOBBIT HOBBIT 439
+h7210 MACH_H7210 H7210 440
+pxa_netdcu5 MACH_PXA_NETDCU5 PXA_NETDCU5 441
+acc MACH_ACC ACC 442
+esl_sarva MACH_ESL_SARVA ESL_SARVA 443
+xm250 MACH_XM250 XM250 444
+t6tc1xb MACH_T6TC1XB T6TC1XB 445
+ess710 MACH_ESS710 ESS710 446
+mx3ads MACH_MX3ADS MX3ADS 447
+himalaya MACH_HIMALAYA HIMALAYA 448
+bolfenk MACH_BOLFENK BOLFENK 449
+at91rm9200kr MACH_AT91RM9200KR AT91RM9200KR 450
+edb9312 MACH_EDB9312 EDB9312 451
+omap_generic MACH_OMAP_GENERIC OMAP_GENERIC 452
+aximx3 MACH_AXIMX3 AXIMX3 453
+eb67xdip MACH_EB67XDIP EB67XDIP 454
+webtxs MACH_WEBTXS WEBTXS 455
+hawk MACH_HAWK HAWK 456
+ccat91sbc001 MACH_CCAT91SBC001 CCAT91SBC001 457
+expresso MACH_EXPRESSO EXPRESSO 458
+h4000 MACH_H4000 H4000 459
+dino MACH_DINO DINO 460
+ml675k MACH_ML675K ML675K 461
+edb9301 MACH_EDB9301 EDB9301 462
+edb9315 MACH_EDB9315 EDB9315 463
+reciva_tt MACH_RECIVA_TT RECIVA_TT 464
+cstcb01 MACH_CSTCB01 CSTCB01 465
+cstcb1 MACH_CSTCB1 CSTCB1 466
+shadwell MACH_SHADWELL SHADWELL 467
+goepel263 MACH_GOEPEL263 GOEPEL263 468
+acq100 MACH_ACQ100 ACQ100 469
+mx1fs2 MACH_MX1FS2 MX1FS2 470
+hiptop_g1 MACH_HIPTOP_G1 HIPTOP_G1 471
+sparky MACH_SPARKY SPARKY 472
+ns9750 MACH_NS9750 NS9750 473
+phoenix MACH_PHOENIX PHOENIX 474
+vr1000 MACH_VR1000 VR1000 475
+deisterpxa MACH_DEISTERPXA DEISTERPXA 476
+bcm1160 MACH_BCM1160 BCM1160 477
+pcm022 MACH_PCM022 PCM022 478
+adsgcx MACH_ADSGCX ADSGCX 479
+dreadnaught MACH_DREADNAUGHT DREADNAUGHT 480
+dm320 MACH_DM320 DM320 481
+markov MACH_MARKOV MARKOV 482
+cos7a400 MACH_COS7A400 COS7A400 483
+milano MACH_MILANO MILANO 484
+ue9328 MACH_UE9328 UE9328 485
+uex255 MACH_UEX255 UEX255 486
+ue2410 MACH_UE2410 UE2410 487
+a620 MACH_A620 A620 488
+ocelot MACH_OCELOT OCELOT 489
+cheetah MACH_CHEETAH CHEETAH 490
+omap_perseus2 MACH_OMAP_PERSEUS2 OMAP_PERSEUS2 491
+zvue MACH_ZVUE ZVUE 492
+roverp1 MACH_ROVERP1 ROVERP1 493
+asidial2 MACH_ASIDIAL2 ASIDIAL2 494
+s3c24a0 MACH_S3C24A0 S3C24A0 495
+e800 MACH_E800 E800 496
+e750 MACH_E750 E750 497
+s3c5500 MACH_S3C5500 S3C5500 498
+smdk5500 MACH_SMDK5500 SMDK5500 499
+signalsync MACH_SIGNALSYNC SIGNALSYNC 500
+nbc MACH_NBC NBC 501
+er4525 MACH_ER4525 ER4525 502
+netbookpro MACH_NETBOOKPRO NETBOOKPRO 503
+hw90200 MACH_HW90200 HW90200 504
+condor MACH_CONDOR CONDOR 505
+cup MACH_CUP CUP 506
+kite MACH_KITE KITE 507
+scb9328 MACH_SCB9328 SCB9328 508
+omap_h3 MACH_OMAP_H3 OMAP_H3 509
+omap_h4 MACH_OMAP_H4 OMAP_H4 510
+n10 MACH_N10 N10 511
+montajade MACH_MONTAJADE MONTAJADE 512
+sg560 MACH_SG560 SG560 513
+dp1000 MACH_DP1000 DP1000 514
+omap_osk MACH_OMAP_OSK OMAP_OSK 515
+rg100v3 MACH_RG100V3 RG100V3 516
+mx2ads MACH_MX2ADS MX2ADS 517
diff -urN linux-2.4.26/arch/i386/config.in linux-2.4.26-vrs1/arch/i386/config.in
--- linux-2.4.26/arch/i386/config.in 2004-02-27 20:03:23.000000000 +0000
+++ linux-2.4.26-vrs1/arch/i386/config.in 2004-02-23 13:36:21.000000000 +0000
@@ -9,6 +9,7 @@
define_bool CONFIG_UID16 y
+define_bool CONFIG_GENERIC_ISA_DMA y
mainmenu_option next_comment
comment 'Code maturity level options'
bool 'Prompt for development and/or incomplete code/drivers' CONFIG_EXPERIMENTAL
diff -urN linux-2.4.26/arch/i386/kernel/Makefile linux-2.4.26-vrs1/arch/i386/kernel/Makefile
--- linux-2.4.26/arch/i386/kernel/Makefile 2003-11-28 18:26:19.000000000 +0000
+++ linux-2.4.26-vrs1/arch/i386/kernel/Makefile 2004-01-14 21:38:44.000000000 +0000
@@ -7,8 +7,8 @@
#
# Note 2! The CFLAGS definitions are now in the main makefile...
-.S.o:
- $(CC) $(AFLAGS) -traditional -c $< -o $*.o
+USE_STANDARD_AS_RULE := true
+EXTRA_AFLAGS := -traditional
all: kernel.o head.o init_task.o
diff -urN linux-2.4.26/arch/i386/kernel/apm.c linux-2.4.26-vrs1/arch/i386/kernel/apm.c
--- linux-2.4.26/arch/i386/kernel/apm.c 2003-08-25 12:44:39.000000000 +0100
+++ linux-2.4.26-vrs1/arch/i386/kernel/apm.c 2004-01-14 21:38:44.000000000 +0000
@@ -1267,6 +1267,7 @@
as->suspend_wait = 0;
as->suspend_result = err;
}
+ ignore_normal_resume = 1;
wake_up_interruptible(&apm_suspend_waitqueue);
return err;
}
@@ -1319,6 +1320,8 @@
if (ignore_bounce
&& ((jiffies - last_resume) > bounce_interval))
ignore_bounce = 0;
+ if (ignore_normal_resume && (event != APM_NORMAL_RESUME))
+ ignore_normal_resume = 0;
switch (event) {
case APM_SYS_STANDBY:
diff -urN linux-2.4.26/arch/i386/lib/Makefile linux-2.4.26-vrs1/arch/i386/lib/Makefile
--- linux-2.4.26/arch/i386/lib/Makefile 2001-09-10 15:31:30.000000000 +0100
+++ linux-2.4.26-vrs1/arch/i386/lib/Makefile 2004-01-14 21:32:24.000000000 +0000
@@ -2,8 +2,7 @@
# Makefile for i386-specific library files..
#
-.S.o:
- $(CC) $(AFLAGS) -c $< -o $*.o
+USE_STANDARD_AS_RULE := true
L_TARGET = lib.a
diff -urN linux-2.4.26/arch/i386/math-emu/Makefile linux-2.4.26-vrs1/arch/i386/math-emu/Makefile
--- linux-2.4.26/arch/i386/math-emu/Makefile 2000-12-29 22:07:20.000000000 +0000
+++ linux-2.4.26-vrs1/arch/i386/math-emu/Makefile 2004-01-14 21:32:24.000000000 +0000
@@ -2,15 +2,15 @@
# Makefile for wm-FPU-emu
#
+USE_STANDARD_AS_RULE := true
+
O_TARGET := math.o
#DEBUG = -DDEBUGGING
DEBUG =
PARANOID = -DPARANOID
CFLAGS := $(CFLAGS) $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION)
-
-.S.o:
- $(CC) $(AFLAGS) $(PARANOID) -c $<
+EXTRA_AFLAGS := $(PARANOID)
# From 'C' language sources:
C_OBJS =fpu_entry.o errors.o \
diff -urN linux-2.4.26/arch/ia64/config.in linux-2.4.26-vrs1/arch/ia64/config.in
--- linux-2.4.26/arch/ia64/config.in 2004-02-27 20:03:23.000000000 +0000
+++ linux-2.4.26-vrs1/arch/ia64/config.in 2004-02-23 13:36:21.000000000 +0000
@@ -25,6 +25,7 @@
define_bool CONFIG_SBUS n
define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n
define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y
+define_bool CONFIG_GENERIC_ISA_DMA y
choice 'IA-64 processor type' \
"Itanium CONFIG_ITANIUM \
diff -urN linux-2.4.26/arch/m68k/config.in linux-2.4.26-vrs1/arch/m68k/config.in
--- linux-2.4.26/arch/m68k/config.in 2004-02-27 20:03:23.000000000 +0000
+++ linux-2.4.26-vrs1/arch/m68k/config.in 2004-02-23 13:36:22.000000000 +0000
@@ -6,6 +6,7 @@
define_bool CONFIG_UID16 y
define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y
define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
+define_bool CONFIG_GENERIC_ISA_DMA y
mainmenu_name "Linux/68k Kernel Configuration"
diff -urN linux-2.4.26/arch/mips/config.in linux-2.4.26-vrs1/arch/mips/config.in
--- linux-2.4.26/arch/mips/config.in 2002-11-28 23:53:09.000000000 +0000
+++ linux-2.4.26-vrs1/arch/mips/config.in 2004-01-14 21:32:24.000000000 +0000
@@ -5,5 +5,6 @@
define_bool CONFIG_MIPS y
define_bool CONFIG_MIPS32 y
define_bool CONFIG_MIPS64 n
+define_bool CONFIG_GENERIC_ISA_DMA y
source arch/mips/config-shared.in
diff -urN linux-2.4.26/arch/parisc/config.in linux-2.4.26-vrs1/arch/parisc/config.in
--- linux-2.4.26/arch/parisc/config.in 2004-02-27 20:03:24.000000000 +0000
+++ linux-2.4.26-vrs1/arch/parisc/config.in 2004-02-23 13:36:26.000000000 +0000
@@ -9,6 +9,7 @@
define_bool CONFIG_UID16 n
define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y
define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
+define_bool CONFIG_GENERIC_ISA_DMA y
mainmenu_option next_comment
comment 'Code maturity level options'
diff -urN linux-2.4.26/arch/ppc/config.in linux-2.4.26-vrs1/arch/ppc/config.in
--- linux-2.4.26/arch/ppc/config.in 2004-04-19 11:44:15.000000000 +0100
+++ linux-2.4.26-vrs1/arch/ppc/config.in 2004-04-18 21:47:50.000000000 +0100
@@ -6,6 +6,7 @@
define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n
define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y
define_bool CONFIG_HAVE_DEC_LOCK y
+define_bool CONFIG_GENERIC_ISA_DMA y
mainmenu_name "Linux/PowerPC Kernel Configuration"
diff -urN linux-2.4.26/arch/sh/config.in linux-2.4.26-vrs1/arch/sh/config.in
--- linux-2.4.26/arch/sh/config.in 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/arch/sh/config.in 2004-02-23 13:36:27.000000000 +0000
@@ -9,6 +9,7 @@
define_bool CONFIG_UID16 y
define_bool CONFIG_RWSEM_GENERIC_SPINLOCK y
define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM n
+define_bool CONFIG_GENERIC_ISA_DMA y
mainmenu_option next_comment
comment 'Code maturity level options'
diff -urN linux-2.4.26/arch/sparc/config.in linux-2.4.26-vrs1/arch/sparc/config.in
--- linux-2.4.26/arch/sparc/config.in 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/arch/sparc/config.in 2004-02-23 13:36:27.000000000 +0000
@@ -6,6 +6,7 @@
define_bool CONFIG_UID16 y
define_bool CONFIG_HIGHMEM y
+define_bool CONFIG_GENERIC_ISA_DMA y
mainmenu_option next_comment
comment 'Code maturity level options'
diff -urN linux-2.4.26/arch/sparc64/config.in linux-2.4.26-vrs1/arch/sparc64/config.in
--- linux-2.4.26/arch/sparc64/config.in 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/arch/sparc64/config.in 2004-02-23 13:36:27.000000000 +0000
@@ -41,6 +41,7 @@
define_bool CONFIG_HAVE_DEC_LOCK y
define_bool CONFIG_RWSEM_GENERIC_SPINLOCK n
define_bool CONFIG_RWSEM_XCHGADD_ALGORITHM y
+define_bool CONFIG_GENERIC_ISA_DMA y
define_bool CONFIG_ISA n
define_bool CONFIG_ISAPNP n
define_bool CONFIG_EISA n
diff -urN linux-2.4.26/drivers/Makefile linux-2.4.26-vrs1/drivers/Makefile
--- linux-2.4.26/drivers/Makefile 2003-11-28 18:26:19.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/Makefile 2004-02-04 04:11:33.000000000 +0000
@@ -8,9 +8,9 @@
mod-subdirs := dio hil mtd sbus video macintosh usb input telephony ide \
message/i2o message/fusion scsi md ieee1394 pnp isdn atm \
- fc4 net/hamradio i2c acpi bluetooth usb/gadget
+ fc4 net/hamradio i2c l3 acpi bluetooth serial usb/gadget
-subdir-y := parport char block net sound misc media cdrom hotplug
+subdir-y := parport serial char block net sound misc media cdrom hotplug pld
subdir-m := $(subdir-y)
@@ -45,8 +45,12 @@
# CONFIG_HAMRADIO can be set without CONFIG_NETDEVICE being set -- ch
subdir-$(CONFIG_HAMRADIO) += net/hamradio
subdir-$(CONFIG_I2C) += i2c
+subdir-$(CONFIG_L3) += l3
subdir-$(CONFIG_ACPI_BOOT) += acpi
subdir-$(CONFIG_BLUEZ) += bluetooth
+subdir-$(CONFIG_SSI) += ssi
+
+subdir-$(CONFIG_ARCH_AT91RM9200)+= at91
include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/acorn/char/i2c.c linux-2.4.26-vrs1/drivers/acorn/char/i2c.c
--- linux-2.4.26/drivers/acorn/char/i2c.c 2004-01-05 13:53:56.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/acorn/char/i2c.c 2004-04-10 11:43:00.000000000 +0100
@@ -33,9 +33,13 @@
static struct i2c_client *rtc_client;
static const unsigned char days_in_mon[] =
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
-static unsigned int rtc_epoch = 1900;
#define CMOS_CHECKSUM (63)
+
+/*
+ * Acorn machines store the year in the static RAM at
+ * location 128.
+ */
#define CMOS_YEAR (64 + 128)
static inline int rtc_command(int cmd, void *data)
@@ -49,51 +53,91 @@
}
/*
+ * Update the century + year bytes in the CMOS RAM, ensuring
+ * that the check byte is correctly adjusted for the change.
+ */
+static int rtc_update_year(unsigned int new_year)
+{
+ unsigned char yr[2], chk;
+ struct mem cmos_year = { CMOS_YEAR, sizeof(yr), yr };
+ struct mem cmos_check = { CMOS_CHECKSUM, 1, &chk };
+ int ret;
+
+ ret = rtc_command(MEM_READ, &cmos_check);
+ if (ret)
+ goto out;
+ ret = rtc_command(MEM_READ, &cmos_year);
+ if (ret)
+ goto out;
+
+ chk -= yr[1] + yr[0];
+
+ yr[1] = new_year / 100;
+ yr[0] = new_year % 100;
+
+ chk += yr[1] + yr[0];
+
+ ret = rtc_command(MEM_WRITE, &cmos_year);
+ if (ret == 0)
+ ret = rtc_command(MEM_WRITE, &cmos_check);
+ out:
+ return ret;
+}
+
+
+/*
* Read the current RTC time and date, and update xtime.
*/
static void get_rtc_time(struct rtc_tm *rtctm, unsigned int *year)
{
unsigned char ctrl, yr[2];
struct mem rtcmem = { CMOS_YEAR, sizeof(yr), yr };
+ int real_year, year_offset;
/*
* Ensure that the RTC is running.
*/
rtc_command(RTC_GETCTRL, &ctrl);
if (ctrl & 0xc0) {
- unsigned char new_ctrl;
-
- new_ctrl = ctrl & ~0xc0;
+ unsigned char new_ctrl = ctrl & ~0xc0;
- printk("RTC: resetting control %02X -> %02X\n",
- ctrl, new_ctrl);
+ printk(KERN_WARNING "RTC: resetting control %02x -> %02x\n",
+ ctrl, new_ctrl);
rtc_command(RTC_SETCTRL, &new_ctrl);
}
+ if (rtc_command(RTC_GETDATETIME, rtctm) ||
+ rtc_command(MEM_READ, &rtcmem))
+ return;
+
+ real_year = yr[0];
+
/*
- * Acorn machines store the year in
- * the static RAM at location 192.
+ * The RTC year holds the LSB two bits of the current
+ * year, which should reflect the LSB two bits of the
+ * CMOS copy of the year. Any difference indicates
+ * that we have to correct the CMOS version.
*/
- if (rtc_command(MEM_READ, &rtcmem))
- return;
+ year_offset = rtctm->year_off - (real_year & 3);
+ if (year_offset < 0)
+ /*
+ * RTC year wrapped. Adjust it appropriately.
+ */
+ year_offset += 4;
- if (rtc_command(RTC_GETDATETIME, rtctm))
- return;
+ *year = real_year + year_offset + yr[1] * 100;
- *year = yr[1] * 100 + yr[0];
}
static int set_rtc_time(struct rtc_tm *rtctm, unsigned int year)
{
- unsigned char yr[2], leap, chk;
- struct mem cmos_year = { CMOS_YEAR, sizeof(yr), yr };
- struct mem cmos_check = { CMOS_CHECKSUM, 1, &chk };
+ unsigned char leap;
int ret;
leap = (!(year % 4) && (year % 100)) || !(year % 400);
- if (rtctm->mon > 12 || rtctm->mday == 0)
+ if (rtctm->mon > 12 || rtctm->mon == 0 || rtctm->mday == 0)
return -EINVAL;
if (rtctm->mday > (days_in_mon[rtctm->mon] + (rtctm->mon == 2 && leap)))
@@ -102,21 +146,16 @@
if (rtctm->hours >= 24 || rtctm->mins >= 60 || rtctm->secs >= 60)
return -EINVAL;
- ret = rtc_command(RTC_SETDATETIME, rtctm);
- if (ret == 0) {
- rtc_command(MEM_READ, &cmos_check);
- rtc_command(MEM_READ, &cmos_year);
-
- chk -= yr[1] + yr[0];
-
- yr[1] = year / 100;
- yr[0] = year % 100;
+ /*
+ * The RTC's own 2-bit year must reflect the least
+ * significant two bits of the CMOS year.
+ */
+ rtctm->year_off = (year % 100) & 3;
- chk += yr[1] + yr[0];
+ ret = rtc_command(RTC_SETDATETIME, rtctm);
+ if (ret == 0)
+ ret = rtc_update_year(year);
- rtc_command(MEM_WRITE, &cmos_year);
- rtc_command(MEM_WRITE, &cmos_check);
- }
return ret;
}
@@ -166,7 +205,6 @@
break;
case RTC_RD_TIME:
- memset(&rtctm, 0, sizeof(struct rtc_time));
get_rtc_time(&rtc_raw, &year);
rtctm.tm_sec = rtc_raw.secs;
rtctm.tm_min = rtc_raw.mins;
@@ -188,13 +226,12 @@
rtc_raw.hours = rtctm.tm_hour;
rtc_raw.mday = rtctm.tm_mday;
rtc_raw.mon = rtctm.tm_mon + 1;
- rtc_raw.year_off = 2;
year = rtctm.tm_year + 1900;
return set_rtc_time(&rtc_raw, year);
break;
case RTC_EPOCH_READ:
- return put_user(rtc_epoch, (unsigned long *)arg);
+ return put_user(1900, (unsigned long *)arg);
}
return -EINVAL;
diff -urN linux-2.4.26/drivers/acorn/net/ether1.c linux-2.4.26-vrs1/drivers/acorn/net/ether1.c
--- linux-2.4.26/drivers/acorn/net/ether1.c 2003-08-25 12:44:40.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/acorn/net/ether1.c 2004-04-09 19:55:21.000000000 +0100
@@ -80,7 +80,7 @@
#define BUS_16 16
#define BUS_8 8
-static const card_ids __init ether1_cids[] = {
+static card_ids __initdata ether1_cids[] = {
{ MANU_ACORN, PROD_ACORN_ETHER1 },
{ 0xffff, 0xffff }
};
@@ -153,35 +153,35 @@
length -= thislen;
__asm__ __volatile__(
- "subs %3, %3, #2
- bmi 2f
-1: ldr %0, [%1], #2
- mov %0, %0, lsl #16
- orr %0, %0, %0, lsr #16
- str %0, [%2], #4
- subs %3, %3, #2
- bmi 2f
- ldr %0, [%1], #2
- mov %0, %0, lsl #16
- orr %0, %0, %0, lsr #16
- str %0, [%2], #4
- subs %3, %3, #2
- bmi 2f
- ldr %0, [%1], #2
- mov %0, %0, lsl #16
- orr %0, %0, %0, lsr #16
- str %0, [%2], #4
- subs %3, %3, #2
- bmi 2f
- ldr %0, [%1], #2
- mov %0, %0, lsl #16
- orr %0, %0, %0, lsr #16
- str %0, [%2], #4
- subs %3, %3, #2
- bpl 1b
-2: adds %3, %3, #1
- ldreqb %0, [%1]
- streqb %0, [%2]"
+" subs %3, %3, #2 \n"
+" bmi 2f \n"
+"1: ldr %0, [%1], #2 \n"
+" mov %0, %0, lsl #16 \n"
+" orr %0, %0, %0, lsr #16 \n"
+" str %0, [%2], #4 \n"
+" subs %3, %3, #2 \n"
+" bmi 2f \n"
+" ldr %0, [%1], #2 \n"
+" mov %0, %0, lsl #16 \n"
+" orr %0, %0, %0, lsr #16 \n"
+" str %0, [%2], #4 \n"
+" subs %3, %3, #2 \n"
+" bmi 2f \n"
+" ldr %0, [%1], #2 \n"
+" mov %0, %0, lsl #16 \n"
+" orr %0, %0, %0, lsr #16 \n"
+" str %0, [%2], #4 \n"
+" subs %3, %3, #2 \n"
+" bmi 2f \n"
+" ldr %0, [%1], #2 \n"
+" mov %0, %0, lsl #16 \n"
+" orr %0, %0, %0, lsr #16 \n"
+" str %0, [%2], #4 \n"
+" subs %3, %3, #2 \n"
+" bpl 1b \n"
+"2: adds %3, %3, #1 \n"
+" ldreqb %0, [%1] \n"
+" streqb %0, [%2] \n"
: "=&r" (used), "=&r" (data)
: "r" (addr), "r" (thislen), "1" (data));
@@ -215,35 +215,35 @@
length -= thislen;
__asm__ __volatile__(
- "subs %3, %3, #2
- bmi 2f
-1: ldr %0, [%2], #4
- strb %0, [%1], #1
- mov %0, %0, lsr #8
- strb %0, [%1], #1
- subs %3, %3, #2
- bmi 2f
- ldr %0, [%2], #4
- strb %0, [%1], #1
- mov %0, %0, lsr #8
- strb %0, [%1], #1
- subs %3, %3, #2
- bmi 2f
- ldr %0, [%2], #4
- strb %0, [%1], #1
- mov %0, %0, lsr #8
- strb %0, [%1], #1
- subs %3, %3, #2
- bmi 2f
- ldr %0, [%2], #4
- strb %0, [%1], #1
- mov %0, %0, lsr #8
- strb %0, [%1], #1
- subs %3, %3, #2
- bpl 1b
-2: adds %3, %3, #1
- ldreqb %0, [%2]
- streqb %0, [%1]"
+" subs %3, %3, #2 \n"
+" bmi 2f \n"
+"1: ldr %0, [%2], #4 \n"
+" strb %0, [%1], #1 \n"
+" mov %0, %0, lsr #8 \n"
+" strb %0, [%1], #1 \n"
+" subs %3, %3, #2 \n"
+" bmi 2f \n"
+" ldr %0, [%2], #4 \n"
+" strb %0, [%1], #1 \n"
+" mov %0, %0, lsr #8 \n"
+" strb %0, [%1], #1 \n"
+" subs %3, %3, #2 \n"
+" bmi 2f \n"
+" ldr %0, [%2], #4 \n"
+" strb %0, [%1], #1 \n"
+" mov %0, %0, lsr #8 \n"
+" strb %0, [%1], #1 \n"
+" subs %3, %3, #2 \n"
+" bmi 2f \n"
+" ldr %0, [%2], #4 \n"
+" strb %0, [%1], #1 \n"
+" mov %0, %0, lsr #8 \n"
+" strb %0, [%1], #1 \n"
+" subs %3, %3, #2 \n"
+" bpl 1b \n"
+"2: adds %3, %3, #1 \n"
+" ldreqb %0, [%2] \n"
+" streqb %0, [%1] \n"
: "=&r" (used), "=&r" (data)
: "r" (addr), "r" (thislen), "1" (data));
diff -urN linux-2.4.26/drivers/acorn/net/ether3.c linux-2.4.26-vrs1/drivers/acorn/net/ether3.c
--- linux-2.4.26/drivers/acorn/net/ether3.c 2003-08-25 12:44:40.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/acorn/net/ether3.c 2004-01-14 21:32:24.000000000 +0000
@@ -75,7 +75,7 @@
#include "ether3.h"
static unsigned int net_debug = NET_DEBUG;
-static const card_ids __init ether3_cids[] = {
+static card_ids __initdata ether3_cids[] = {
{ MANU_ANT2, PROD_ANT_ETHER3 },
{ MANU_ANT, PROD_ANT_ETHER3 },
{ MANU_ANT, PROD_ANT_ETHERB },
diff -urN linux-2.4.26/drivers/acorn/net/etherh.c linux-2.4.26-vrs1/drivers/acorn/net/etherh.c
--- linux-2.4.26/drivers/acorn/net/etherh.c 2003-08-25 12:44:40.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/acorn/net/etherh.c 2004-01-14 21:32:24.000000000 +0000
@@ -57,7 +57,7 @@
static unsigned int net_debug = NET_DEBUG;
-static const card_ids __init etherh_cids[] = {
+static card_ids __initdata etherh_cids[] = {
{ MANU_ANT, PROD_ANT_ETHERM },
{ MANU_I3, PROD_I3_ETHERLAN500 },
{ MANU_I3, PROD_I3_ETHERLAN600 },
diff -urN linux-2.4.26/drivers/acorn/scsi/cumana_1.c linux-2.4.26-vrs1/drivers/acorn/scsi/cumana_1.c
--- linux-2.4.26/drivers/acorn/scsi/cumana_1.c 2001-09-13 23:21:32.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/acorn/scsi/cumana_1.c 2004-03-07 11:05:38.000000000 +0000
@@ -153,20 +153,20 @@
((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
outb(0x00, instance->io_port - 577);
- if (instance->irq != IRQ_NONE)
+ if (instance->irq != SCSI_IRQ_NONE)
if (request_irq(instance->irq, do_cumanascsi_intr, SA_INTERRUPT, "CumanaSCSI-1", NULL)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
instance->host_no, instance->irq);
- instance->irq = IRQ_NONE;
+ instance->irq = SCSI_IRQ_NONE;
}
- if (instance->irq == IRQ_NONE) {
+ if (instance->irq == SCSI_IRQ_NONE) {
printk("scsi%d: interrupts not enabled. for better interactive performance,\n", instance->host_no);
printk("scsi%d: please jumper the board for a free IRQ.\n", instance->host_no);
}
printk("scsi%d: at port %lX irq", instance->host_no, instance->io_port);
- if (instance->irq == IRQ_NONE)
+ if (instance->irq == SCSI_IRQ_NONE)
printk ("s disabled");
else
printk (" %d", instance->irq);
@@ -185,7 +185,7 @@
{
int i;
- if (shpnt->irq != IRQ_NONE)
+ if (shpnt->irq != SCSI_IRQ_NONE)
free_irq (shpnt->irq, NULL);
if (shpnt->io_port)
release_region (shpnt->io_port, shpnt->n_io_port);
diff -urN linux-2.4.26/drivers/acorn/scsi/ecoscsi.c linux-2.4.26-vrs1/drivers/acorn/scsi/ecoscsi.c
--- linux-2.4.26/drivers/acorn/scsi/ecoscsi.c 2002-08-03 01:39:43.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/acorn/scsi/ecoscsi.c 2004-03-07 11:06:45.000000000 +0000
@@ -106,7 +106,7 @@
instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
instance->io_port = 0x80ce8000;
instance->n_io_port = 144;
- instance->irq = IRQ_NONE;
+ instance->irq = SCSI_IRQ_NONE;
if (check_region (instance->io_port, instance->n_io_port)) {
scsi_unregister (instance);
@@ -130,20 +130,20 @@
return 0;
}
- if (instance->irq != IRQ_NONE)
+ if (instance->irq != SCSI_IRQ_NONE)
if (request_irq(instance->irq, do_ecoscsi_intr, SA_INTERRUPT, "ecoscsi", NULL)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
instance->host_no, instance->irq);
- instance->irq = IRQ_NONE;
+ instance->irq = SCSI_IRQ_NONE;
}
- if (instance->irq != IRQ_NONE) {
+ if (instance->irq != SCSI_IRQ_NONE) {
printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no);
printk("scsi%d: that the board had an interrupt!\n", instance->host_no);
}
printk("scsi%d: at port %X irq", instance->host_no, instance->io_port);
- if (instance->irq == IRQ_NONE)
+ if (instance->irq == SCSI_IRQ_NONE)
printk ("s disabled");
else
printk (" %d", instance->irq);
@@ -157,7 +157,7 @@
int ecoscsi_release (struct Scsi_Host *shpnt)
{
- if (shpnt->irq != IRQ_NONE)
+ if (shpnt->irq != SCSI_IRQ_NONE)
free_irq (shpnt->irq, NULL);
if (shpnt->io_port)
release_region (shpnt->io_port, shpnt->n_io_port);
diff -urN linux-2.4.26/drivers/acorn/scsi/oak.c linux-2.4.26-vrs1/drivers/acorn/scsi/oak.c
--- linux-2.4.26/drivers/acorn/scsi/oak.c 2001-10-11 17:04:57.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/acorn/scsi/oak.c 2004-03-07 11:05:55.000000000 +0000
@@ -97,7 +97,7 @@
};
#define OAK_ADDRESS(card) (ecard_address((card), ECARD_MEMC, 0))
-#define OAK_IRQ(card) (IRQ_NONE)
+#define OAK_IRQ(card) (SCSI_IRQ_NONE)
/*
* Function : int oakscsi_detect(Scsi_Host_Template * tpnt)
*
@@ -136,20 +136,20 @@
instance->n_io_port = 255;
request_region (instance->io_port, instance->n_io_port, "Oak SCSI");
- if (instance->irq != IRQ_NONE)
+ if (instance->irq != SCSI_IRQ_NONE)
if (request_irq(instance->irq, do_oakscsi_intr, SA_INTERRUPT, "Oak SCSI", NULL)) {
printk("scsi%d: IRQ%d not free, interrupts disabled\n",
instance->host_no, instance->irq);
- instance->irq = IRQ_NONE;
+ instance->irq = SCSI_IRQ_NONE;
}
- if (instance->irq != IRQ_NONE) {
+ if (instance->irq != SCSI_IRQ_NONE) {
printk("scsi%d: eek! Interrupts enabled, but I don't think\n", instance->host_no);
printk("scsi%d: that the board had an interrupt!\n", instance->host_no);
}
printk("scsi%d: at port %lX irq", instance->host_no, instance->io_port);
- if (instance->irq == IRQ_NONE)
+ if (instance->irq == SCSI_IRQ_NONE)
printk ("s disabled");
else
printk (" %d", instance->irq);
@@ -172,7 +172,7 @@
{
int i;
- if (shpnt->irq != IRQ_NONE)
+ if (shpnt->irq != SCSI_IRQ_NONE)
free_irq (shpnt->irq, NULL);
if (shpnt->io_port)
release_region (shpnt->io_port, shpnt->n_io_port);
diff -urN linux-2.4.26/drivers/at91/Makefile linux-2.4.26-vrs1/drivers/at91/Makefile
--- linux-2.4.26/drivers/at91/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,23 @@
+#
+# Makefile for the AT91RM9200-specific Linux kernel device drivers.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (not a .c file).
+
+O_TARGET := at91drv.o
+
+subdir-y := serial net watchdog rtc usb i2c spi mtd
+subdir-m := $(subdir-y)
+
+obj-$(CONFIG_SERIAL_AT91) += serial/at91serial.o
+obj-$(CONFIG_AT91_ETHER) += net/at91net.o
+obj-$(CONFIG_AT91_WATCHDOG) += watchdog/at91wdt.o
+obj-$(CONFIG_AT91_RTC) += rtc/at91rtc.o
+obj-$(CONFIG_USB) += usb/at91usb.o
+obj-$(CONFIG_I2C_AT91) += i2c/at91i2c.o
+obj-$(CONFIG_AT91_SPIDEV) += spi/at91spi.o
+obj-$(CONFIG_MTD_AT91_DATAFLASH) += spi/at91spi.o mtd/at91mtd.o
+obj-$(CONFIG_MTD_AT91_SMARTMEDIA) += mtd/at91mtd.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/at91/i2c/Makefile linux-2.4.26-vrs1/drivers/at91/i2c/Makefile
--- linux-2.4.26/drivers/at91/i2c/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/i2c/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,15 @@
+# File: drivers/at91/i2c/Makefile
+#
+# Makefile for the Atmel AT91RM9200 I2C (TWI) device drivers
+#
+
+O_TARGET := at91i2c.o
+
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_I2C_AT91) += at91_i2c.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/at91/i2c/at91_i2c.c linux-2.4.26-vrs1/drivers/at91/i2c/at91_i2c.c
--- linux-2.4.26/drivers/at91/i2c/at91_i2c.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/i2c/at91_i2c.c 2004-03-07 15:59:15.000000000 +0000
@@ -0,0 +1,257 @@
+/*
+ i2c Support for Atmel's AT91RM9200 Two-Wire Interface
+
+ (c) Rick Bronson
+
+ Borrowed heavily from original work by:
+ Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com>
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/pci.h>
+#include <linux/types.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+
+#include <asm/arch/AT91RM9200_TWI.h>
+#include <asm/arch/pio.h>
+#include "at91_i2c.h"
+
+#define DBG(x...) do {\
+ if (debug > 0) \
+ printk(KERN_DEBUG "i2c:" x); \
+ } while(0)
+
+int debug = 0;
+
+static struct at91_i2c_local *at91_i2c_device;
+
+/*
+ * Poll the i2c status register until the specified bit is set.
+ * Returns 0 if timed out (100 msec)
+ */
+static short at91_poll_status(AT91PS_TWI twi, unsigned long bit) {
+ int loop_cntr = 10000;
+ do {
+ udelay(10);
+ } while (!(twi->TWI_SR & bit) && (--loop_cntr > 0));
+
+ return (loop_cntr > 0);
+}
+
+/*
+ * Generic i2c master transfer entrypoint
+ */
+static int at91_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
+{
+ struct at91_i2c_local *device = (struct at91_i2c_local *) adap->data;
+ AT91PS_TWI twi = (AT91PS_TWI) device->base_addr;
+
+ struct i2c_msg *pmsg;
+ int length;
+ unsigned char *buf;
+
+ /*
+ * i2c_smbus_xfer_emulated() in drivers/i2c/i2c-core.c states:
+ * "... In the case of writing, we need to use only one message;
+ * when reading, we need two..."
+ */
+
+ pmsg = msgs; /* look at 1st message, it contains the address/command */
+ if (num >= 1 && num <= 2) {
+ DBG("xfer: doing %s %d bytes to 0x%02x - %d messages\n",
+ pmsg->flags & I2C_M_RD ? "read" : "write",
+ pmsg->len, pmsg->buf[0], num);
+
+ /* Set the TWI Master Mode Register */
+ twi->TWI_MMR = (pmsg->addr << 16) | (pmsg->len << 8)
+ | ((pmsg + 1)->flags & I2C_M_RD ? AT91C_TWI_MREAD : 0);
+
+ /* Set TWI Internal Address Register with first messages data field */
+ if (pmsg->len == 1)
+ twi->TWI_IADR = pmsg->buf[0];
+ else if (pmsg->len == 2)
+ twi->TWI_IADR = pmsg->buf[0] << 8 | pmsg->buf[1];
+ else /* must be 3 */
+ twi->TWI_IADR = pmsg->buf[0] << 16 | pmsg->buf[1] << 8 | pmsg->buf[2];
+
+ /* 1st message contains the address/command */
+ if (num > 1)
+ pmsg++; /* go to real message */
+
+ length = pmsg->len;
+ buf = pmsg->buf;
+ if (length && buf) { /* sanity check */
+ if (pmsg->flags & I2C_M_RD) {
+ twi->TWI_CR = AT91C_TWI_START;
+ while (length--) {
+ if (!length)
+ twi->TWI_CR = AT91C_TWI_STOP;
+ /* Wait until transfer is finished */
+ if (!at91_poll_status(twi, AT91C_TWI_RXRDY)) {
+ printk(KERN_ERR "at91_i2c: timeout 1\n");
+ return 0;
+ }
+ *buf++ = twi->TWI_RHR;
+ }
+ if (!at91_poll_status(twi, AT91C_TWI_TXCOMP)) {
+ printk(KERN_ERR "at91_i2c: timeout 2\n");
+ return 0;
+ }
+ } else {
+ twi->TWI_CR = AT91C_TWI_START;
+ while (length--) {
+ twi->TWI_THR = *buf++;
+ if (!length)
+ twi->TWI_CR = AT91C_TWI_STOP;
+ if (!at91_poll_status(twi, AT91C_TWI_TXRDY)) {
+ printk(KERN_ERR "at91_i2c: timeout 3\n");
+ return 0;
+ }
+ }
+ /* Wait until transfer is finished */
+ if (!at91_poll_status(twi, AT91C_TWI_TXCOMP)) {
+ printk(KERN_ERR "at91_i2c: timeout 4\n");
+ return 0;
+ }
+ }
+ }
+ DBG("transfer complete\n");
+ return num;
+ }
+ else {
+ printk(KERN_ERR "at91_i2c: unexpected number of messages: %d\n", num);
+ return 0;
+ }
+}
+
+/*
+ * Return list of supported functionality
+ */
+static u32 at91_func(struct i2c_adapter *adapter)
+{
+ return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE
+ | I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA
+ | I2C_FUNC_SMBUS_BLOCK_DATA;
+}
+
+/*
+ * Open
+ */
+static void at91_inc(struct i2c_adapter *adapter)
+{
+ MOD_INC_USE_COUNT;
+}
+
+/*
+ * Close
+ */
+static void at91_dec(struct i2c_adapter *adapter)
+{
+ MOD_DEC_USE_COUNT;
+}
+
+/* For now, we only handle combined mode (smbus) */
+static struct i2c_algorithm at91_algorithm = {
+ name:"at91 i2c",
+ id:I2C_ALGO_SMBUS,
+ master_xfer:at91_xfer,
+ functionality:at91_func,
+};
+
+/*
+ * Main initialization routine
+ */
+static int __init i2c_at91_init(void)
+{
+ AT91PS_TWI twi = (AT91PS_TWI) AT91C_VA_BASE_TWI;
+ struct at91_i2c_local *device;
+ int rc;
+
+ AT91_CfgPIO_TWI();
+ AT91_SYS->PMC_PCER = 1 << AT91C_ID_TWI; /* enable peripheral clock */
+
+ twi->TWI_IDR = 0x3ff; /* Disable all interrupts */
+ twi->TWI_CR = AT91C_TWI_SWRST; /* Reset peripheral */
+ twi->TWI_CR = AT91C_TWI_MSEN | AT91C_TWI_SVDIS; /* Set Master mode */
+
+ /* Here, CKDIV = 1 and CHDIV=CLDIV ==> CLDIV = CHDIV = 1/4*((Fmclk/FTWI) -6) */
+ twi->TWI_CWGR = AT91C_TWI_CKDIV1 | AT91C_TWI_CLDIV3 | (AT91C_TWI_CLDIV3 << 8);
+
+ device = (struct at91_i2c_local *) kmalloc(sizeof(struct at91_i2c_local), GFP_KERNEL);
+ if (device == NULL) {
+ printk(KERN_ERR "at91_i2c: can't allocate inteface!\n");
+ return -ENOMEM;
+ }
+ memset(device, 0, sizeof(struct at91_i2c_local));
+ at91_i2c_device = device;
+
+ sprintf(device->adapter.name, "AT91RM9200");
+ device->adapter.data = (void *) device;
+ device->adapter.id = I2C_ALGO_SMBUS;
+ device->adapter.algo = &at91_algorithm;
+ device->adapter.algo_data = NULL;
+ device->adapter.inc_use = at91_inc;
+ device->adapter.dec_use = at91_dec;
+ device->adapter.client_register = NULL;
+ device->adapter.client_unregister = NULL;
+ device->base_addr = AT91C_VA_BASE_TWI;
+
+ rc = i2c_add_adapter(&device->adapter);
+ if (rc) {
+ printk(KERN_ERR "at91_i2c: Adapter %s registration failed\n", device->adapter.name);
+ device->adapter.data = NULL;
+ kfree(device);
+ }
+ else
+ printk(KERN_INFO "Found AT91 i2c\n");
+ return rc;
+}
+
+/*
+ * Clean up routine
+ */
+static void __exit i2c_at91_cleanup(void)
+{
+ struct at91_i2c_local *device = at91_i2c_device;
+ int rc;
+
+ rc = i2c_del_adapter(&device->adapter);
+ device->adapter.data = NULL;
+ kfree(device);
+
+ AT91_SYS->PMC_PCDR = 1 << AT91C_ID_TWI; /* disable peripheral clock */
+
+ /* We aren't that prepared to deal with this... */
+ if (rc)
+ printk(KERN_ERR "at91_i2c: i2c_del_adapter failed (%i), that's bad!\n", rc);
+}
+
+module_init(i2c_at91_init);
+module_exit(i2c_at91_cleanup);
+
+MODULE_AUTHOR("Rick Bronson");
+MODULE_DESCRIPTION("I2C driver for Atmel AT91RM9200");
+MODULE_LICENSE("GPL");
+MODULE_PARM(debug, "i");
+
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/at91/i2c/at91_i2c.h linux-2.4.26-vrs1/drivers/at91/i2c/at91_i2c.h
--- linux-2.4.26/drivers/at91/i2c/at91_i2c.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/i2c/at91_i2c.h 2004-03-07 15:59:15.000000000 +0000
@@ -0,0 +1,43 @@
+/*
+ i2c Support for Atmel's AT91RM9200 Two-Wire Interface
+
+ (c) Rick Bronson
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef AT91_I2C_H
+#define AT91_I2C_H
+
+#define AT91C_TWI_CLOCK 100000
+#define AT91C_TWI_SCLOCK (10 * AT91C_MASTER_CLOCK / AT91C_TWI_CLOCK)
+#define AT91C_TWI_CKDIV1 (2 << 16) /* TWI clock divider. NOTE: see Errata #22 */
+
+#if (AT91C_TWI_SCLOCK % 10) >= 5
+#define AT91C_TWI_CLDIV2 ((AT91C_TWI_SCLOCK / 10) - 5)
+#else
+#define AT91C_TWI_CLDIV2 ((AT91C_TWI_SCLOCK / 10) - 6)
+#endif
+#define AT91C_TWI_CLDIV3 ((AT91C_TWI_CLDIV2 + (4 - AT91C_TWI_CLDIV2 % 4)) >> 2)
+
+#define AT91C_EEPROM_I2C_ADDRESS (0x50 << 16)
+
+/* Physical interface */
+struct at91_i2c_local {
+ struct i2c_adapter adapter;
+ unsigned long base_addr;
+};
+
+#endif
diff -urN linux-2.4.26/drivers/at91/mtd/Makefile linux-2.4.26-vrs1/drivers/at91/mtd/Makefile
--- linux-2.4.26/drivers/at91/mtd/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/mtd/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,19 @@
+# File: drivers/at91/mtd/Makefile
+#
+# Makefile for the Atmel AT91RM9200 MTD devices.
+# Includes: NAND flash (SmartMedia) & DataFlash
+#
+
+O_TARGET := at91mtd.o
+
+export-objs :=
+
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_MTD_AT91_DATAFLASH) += at91_dataflash.o
+obj-$(CONFIG_MTD_AT91_SMARTMEDIA) += at91_nand.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/at91/mtd/at91_dataflash.c linux-2.4.26-vrs1/drivers/at91/mtd/at91_dataflash.c
--- linux-2.4.26/drivers/at91/mtd/at91_dataflash.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/mtd/at91_dataflash.c 2004-04-10 12:48:53.000000000 +0100
@@ -0,0 +1,509 @@
+/*
+ * Atmel DataFlash driver for Atmel AT91RM9200 (Thunder)
+ *
+ * (c) SAN People (Pty) Ltd
+ *
+ * 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.
+*/
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/pci.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/arch/AT91RM9200_SPI.h>
+#include <asm/arch/pio.h>
+#include "at91_dataflash.h"
+#include "../spi/at91_spi.h"
+
+#undef DEBUG_DATAFLASH
+
+/* Detected DataFlash devices */
+static struct mtd_info* mtd_devices[DATAFLASH_MAX_DEVICES];
+static int nr_devices = 0;
+
+/* ......................................................................... */
+
+#ifdef CONFIG_MTD_PARTITIONS
+
+static struct mtd_partition *mtd_parts = 0;
+static int mtd_parts_nr = 0;
+
+#define NB_OF(x) (sizeof(x)/sizeof(x[0]))
+
+static struct mtd_partition static_partitions[] =
+{
+ {
+ name: "bootloader",
+ offset: 0,
+ size: 64 * 1024, /* 64 Kb */
+ mask_flags: MTD_WRITEABLE /* read-only */
+ },
+ {
+ name: "kernel",
+ offset: MTDPART_OFS_NXTBLK,
+ size: 768 *1024, /* 768 Kb */
+ },
+ {
+ name: "filesystem",
+ offset: MTDPART_OFS_NXTBLK,
+ size: MTDPART_SIZ_FULL,
+ }
+};
+
+int parse_cmdline_partitions(struct mtd_info *master,
+ struct mtd_partition **pparts, const char *mtd_id);
+
+#endif
+
+/* ......................................................................... */
+
+/* Allocate a single SPI transfer descriptor. We're assuming that if multiple
+ SPI transfers occur at the same time, spi_access_bus() will serialize them.
+ If this is not valid, then either (i) each dataflash 'priv' structure
+ needs it's own transfer descriptor, (ii) we lock this one, or (iii) use
+ another mechanism. */
+struct spi_transfer_list* spi_transfer_desc;
+
+/*
+ * Perform a SPI transfer to access the DataFlash device.
+ */
+int do_spi_transfer(int nr, char* tx, int tx_len, char* rx, int rx_len,
+ char* txnext, int txnext_len, char* rxnext, int rxnext_len)
+{
+ struct spi_transfer_list* list = spi_transfer_desc;
+
+ list->tx[0] = tx; list->txlen[0] = tx_len;
+ list->rx[0] = rx; list->rxlen[0] = rx_len;
+
+ list->tx[1] = txnext; list->txlen[1] = txnext_len;
+ list->rx[1] = rxnext; list->rxlen[1] = rxnext_len;
+
+ list->nr_transfers = nr;
+
+ return spi_transfer(list);
+}
+
+/* ......................................................................... */
+
+/*
+ * Poll the DataFlash device until it is READY.
+ */
+void at91_dataflash_waitready(void)
+{
+ char* command = kmalloc(2, GFP_KERNEL);
+
+ if (!command)
+ return;
+
+ do {
+ command[0] = OP_READ_STATUS;
+ command[1] = 0;
+
+ do_spi_transfer(1, command, 2, command, 2, NULL, 0, NULL, 0);
+ } while ((command[1] & 0x80) == 0);
+
+ kfree(command);
+}
+
+/*
+ * Return the status of the DataFlash device.
+ */
+unsigned short at91_dataflash_status(void)
+{
+ unsigned short status;
+ char* command = kmalloc(2, GFP_KERNEL);
+
+ if (!command)
+ return 0;
+
+ command[0] = OP_READ_STATUS;
+ command[1] = 0;
+
+ do_spi_transfer(1, command, 2, command, 2, NULL, 0, NULL, 0);
+ status = command[1];
+
+ kfree(command);
+ return status;
+}
+
+/* ......................................................................... */
+
+/*
+ * Erase blocks of flash.
+ */
+int at91_dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
+{
+ struct dataflash_local *priv = (struct dataflash_local *) mtd->priv;
+ unsigned int pageaddr;
+ char* command;
+
+#ifdef DEBUG_DATAFLASH
+ printk("dataflash_erase: addr=%i len=%i\n", instr->addr, instr->len);
+#endif
+
+ /* Sanity checks */
+ if (instr->addr + instr->len > mtd->size)
+ return -EINVAL;
+ if ((instr->len % mtd->erasesize != 0) || (instr->len % priv->page_size != 0))
+ return -EINVAL;
+ if ((instr->addr % priv->page_size) != 0)
+ return -EINVAL;
+
+ command = kmalloc(4, GFP_KERNEL);
+ if (!command)
+ return -ENOMEM;
+
+ while (instr->len > 0) {
+ /* Calculate flash page address */
+ pageaddr = (instr->addr / priv->page_size) << priv->page_offset;
+
+ command[0] = OP_ERASE_PAGE;
+ command[1] = (pageaddr & 0x00FF0000) >> 16;
+ command[2] = (pageaddr & 0x0000FF00) >> 8;
+ command[3] = 0;
+#ifdef DEBUG_DATAFLASH
+ printk("ERASE: (%x) %x %x %x [%i]\n", command[0], command[1], command[2], command[3], pageaddr);
+#endif
+
+ /* Send command to SPI device */
+ spi_access_bus(priv->spi);
+ do_spi_transfer(1, command, 4, command, 4, NULL, 0, NULL, 0);
+
+ at91_dataflash_waitready(); /* poll status until ready */
+ spi_release_bus(priv->spi);
+
+ instr->addr += priv->page_size; /* next page */
+ instr->len -= priv->page_size;
+ }
+
+ kfree(command);
+
+ /* Inform MTD subsystem that erase is complete */
+ instr->state = MTD_ERASE_DONE;
+ if (instr->callback)
+ instr->callback(instr);
+
+ return 0;
+}
+
+/*
+ * Read from the DataFlash device.
+ * from : Start offset in flash device
+ * len : Amount to read
+ * retlen : About of data actually read
+ * buf : Buffer containing the data
+ */
+int at91_dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
+{
+ struct dataflash_local *priv = (struct dataflash_local *) mtd->priv;
+ unsigned int addr;
+ char* command;
+
+#ifdef DEBUG_DATAFLASH
+ printk("dataflash_read: %lli .. %lli\n", from, from+len);
+#endif
+
+ *retlen = 0;
+
+ /* Sanity checks */
+ if (!len)
+ return 0;
+ if (from + len > mtd->size)
+ return -EINVAL;
+
+ /* Calculate flash page/byte address */
+ addr = (((unsigned)from / priv->page_size) << priv->page_offset) + ((unsigned)from % priv->page_size);
+
+ command = kmalloc(8, GFP_KERNEL);
+ if (!command)
+ return -ENOMEM;
+
+ command[0] = OP_READ_CONTINUOUS;
+ command[1] = (addr & 0x00FF0000) >> 16;
+ command[2] = (addr & 0x0000FF00) >> 8;
+ command[3] = (addr & 0x000000FF);
+#ifdef DEBUG_DATAFLASH
+ printk("READ: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]);
+#endif
+
+ /* Send command to SPI device */
+ spi_access_bus(priv->spi);
+ do_spi_transfer(2, command, 8, command, 8, buf, len, buf, len);
+ spi_release_bus(priv->spi);
+
+ *retlen = len;
+ kfree(command);
+ return 0;
+}
+
+/*
+ * Write to the DataFlash device.
+ * to : Start offset in flash device
+ * len : Amount to write
+ * retlen : Amount of data actually written
+ * buf : Buffer containing the data
+ */
+int at91_dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
+{
+ struct dataflash_local *priv = (struct dataflash_local *) mtd->priv;
+ unsigned int pageaddr, addr, offset, writelen;
+ size_t remaining;
+ u_char *writebuf;
+ unsigned short status;
+ int res = 0;
+ char* command;
+ char* tmpbuf = NULL;
+
+#ifdef DEBUG_DATAFLASH
+ printk("dataflash_write: %lli .. %lli\n", to, to+len);
+#endif
+
+ *retlen = 0;
+
+ /* Sanity checks */
+ if (!len)
+ return 0;
+ if (to + len > mtd->size)
+ return -EINVAL;
+
+ command = kmalloc(4, GFP_KERNEL);
+ if (!command)
+ return -ENOMEM;
+
+ pageaddr = ((unsigned)to / priv->page_size);
+ offset = ((unsigned)to % priv->page_size);
+ if (offset + len > priv->page_size)
+ writelen = priv->page_size - offset;
+ else
+ writelen = len;
+ writebuf = buf;
+ remaining = len;
+
+ /* Allocate temporary buffer */
+ tmpbuf = kmalloc(priv->page_size, GFP_KERNEL);
+ if (!tmpbuf) {
+ kfree(command);
+ return -ENOMEM;
+ }
+
+ /* Gain access to the SPI bus */
+ spi_access_bus(priv->spi);
+
+ while (remaining > 0) {
+#ifdef DEBUG_DATAFLASH
+ printk("write @ %i:%i len=%i\n", pageaddr, offset, writelen);
+#endif
+
+ /* (1) Transfer to Buffer1 */
+ if (writelen != priv->page_size) {
+ addr = pageaddr << priv->page_offset;
+ command[0] = OP_TRANSFER_BUF1;
+ command[1] = (addr & 0x00FF0000) >> 16;
+ command[2] = (addr & 0x0000FF00) >> 8;
+ command[3] = 0;
+#ifdef DEBUG_DATAFLASH
+ printk("TRANSFER: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]);
+#endif
+ do_spi_transfer(1, command, 4, command, 4, NULL, 0, NULL, 0);
+ at91_dataflash_waitready();
+ }
+
+ /* (2) Program via Buffer1 */
+ addr = (pageaddr << priv->page_offset) + offset;
+ command[0] = OP_PROGRAM_VIA_BUF1;
+ command[1] = (addr & 0x00FF0000) >> 16;
+ command[2] = (addr & 0x0000FF00) >> 8;
+ command[3] = (addr & 0x000000FF);
+#ifdef DEBUG_DATAFLASH
+ printk("PROGRAM: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]);
+#endif
+ do_spi_transfer(2, command, 4, command, 4, writebuf, writelen, tmpbuf, writelen);
+ at91_dataflash_waitready();
+
+ /* (3) Compare to Buffer1 */
+ addr = pageaddr << priv->page_offset;
+ command[0] = OP_COMPARE_BUF1;
+ command[1] = (addr & 0x00FF0000) >> 16;
+ command[2] = (addr & 0x0000FF00) >> 8;
+ command[3] = 0;
+#ifdef DEBUG_DATAFLASH
+ printk("COMPARE: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]);
+#endif
+ do_spi_transfer(1, command, 4, command, 4, NULL, 0, NULL, 0);
+ at91_dataflash_waitready();
+
+ /* Get result of the compare operation */
+ status = at91_dataflash_status();
+ if ((status & 0x40) == 1) {
+ printk("at91_dataflash: Write error on page %i\n", pageaddr);
+ remaining = 0;
+ res = -EIO;
+ }
+
+ remaining = remaining - writelen;
+ pageaddr++;
+ offset = 0;
+ writebuf += writelen;
+ *retlen += writelen;
+
+ if (remaining > priv->page_size)
+ writelen = priv->page_size;
+ else
+ writelen = remaining;
+ }
+
+ /* Release SPI bus */
+ spi_release_bus(priv->spi);
+
+ kfree(tmpbuf);
+ kfree(command);
+ return res;
+}
+
+/* ......................................................................... */
+
+/*
+ * Initialize and register DataFlash device with MTD subsystem.
+ */
+int add_dataflash(int channel, char *name, int size, int pagesize, int pageoffset)
+{
+ struct mtd_info *device;
+ struct dataflash_local *priv;
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+ char mtdID[14];
+#endif
+
+ if (nr_devices >= DATAFLASH_MAX_DEVICES) {
+ printk(KERN_ERR "at91_dataflash: Too many devices detected\n");
+ return 0;
+ }
+
+ device = (struct mtd_info *) kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
+ if (!device)
+ return -ENOMEM;
+ memset(device, 0, sizeof(struct mtd_info));
+
+ device->name = name;
+ device->size = size;
+ device->erasesize = pagesize;
+ device->module = THIS_MODULE;
+ device->type = MTD_NORFLASH;
+ device->flags = MTD_CAP_NORFLASH;
+ device->erase = at91_dataflash_erase;
+ device->read = at91_dataflash_read;
+ device->write = at91_dataflash_write;
+
+ priv = (struct dataflash_local *) kmalloc(sizeof(struct dataflash_local), GFP_KERNEL);
+ if (!priv) {
+ kfree(device);
+ return -ENOMEM;
+ }
+ memset(priv, 0, sizeof(struct dataflash_local));
+
+ priv->spi = channel;
+ priv->page_size = pagesize;
+ priv->page_offset = pageoffset;
+ device->priv = priv;
+
+ mtd_devices[nr_devices] = device;
+ nr_devices++;
+ printk("at91_dataflash: %s detected [spi%i] (%i bytes)\n", name, channel, size);
+
+#ifdef CONFIG_MTD_PARTITIONS
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+ sprintf(mtdID, "dataflash%i", nr_devices-1);
+ mtd_parts_nr = parse_cmdline_partitions(device, &mtd_parts, mtdID);
+#endif
+ if (mtd_parts_nr <= 0) {
+ mtd_parts = static_partitions;
+ mtd_parts_nr = NB_OF(static_partitions);
+ }
+
+ return add_mtd_partitions(device, mtd_parts, mtd_parts_nr);
+#else
+ return add_mtd_device(device);
+#endif
+}
+
+/*
+ * Detect and initialize DataFlash device connected to specified SPI channel.
+ */
+int at91_dataflash_detect(int channel)
+{
+ int res = 0;
+ unsigned short status;
+
+ spi_access_bus(channel);
+ status = at91_dataflash_status();
+ if (status != 0xff) { /* no dataflash device there */
+ switch (status & 0x3c) {
+ case 0x2c: /* 1 0 1 1 */
+ res = add_dataflash(channel, "Atmel AT45DB161B", 4096*528, 528, 10);
+ break;
+ case 0x34: /* 1 1 0 1 */
+ res = add_dataflash(channel, "Atmel AT45DB321B", 8192*528, 528, 10);
+ break;
+ case 0x3c: /* 1 1 1 1 */
+ res = add_dataflash(channel, "Atmel AT45DB642", 8192*1056, 1056, 11);
+ break;
+ default:
+ printk(KERN_ERR "at91_dataflash: Unknown device (%x)\n", status & 0x3c);
+ }
+ }
+ spi_release_bus(channel);
+
+ return res;
+}
+
+int __init at91_dataflash_init(void)
+{
+ spi_transfer_desc = kmalloc(sizeof(struct spi_transfer_list), GFP_KERNEL);
+ if (!spi_transfer_desc)
+ return -ENOMEM;
+
+ /* DataFlash (SPI chip select 0) */
+ at91_dataflash_detect(0);
+
+#ifdef CONFIG_MTD_AT91_DATAFLASH_CARD
+ /* DataFlash card (SPI chip select 3) */
+ AT91_CfgPIO_DataFlashCard();
+ at91_dataflash_detect(3);
+#endif
+
+ return 0;
+}
+
+void __exit at91_dataflash_exit(void)
+{
+ int i;
+
+ for (i = 0; i < DATAFLASH_MAX_DEVICES; i++) {
+ if (mtd_devices[i]) {
+#ifdef CONFIG_MTD_PARTITIONS
+ del_mtd_partitions(mtd_devices[i]);
+#else
+ del_mtd_device(mtd_devices[i]);
+#endif
+ kfree(mtd_devices[i]->priv);
+ kfree(mtd_devices[i]);
+ }
+ }
+ nr_devices = 0;
+ kfree(spi_transfer_desc);
+}
+
+
+EXPORT_NO_SYMBOLS;
+
+module_init(at91_dataflash_init);
+module_exit(at91_dataflash_exit);
+
+MODULE_LICENSE("GPL")
+MODULE_AUTHOR("Andrew Victor")
+MODULE_DESCRIPTION("DataFlash driver for Atmel AT91RM9200")
diff -urN linux-2.4.26/drivers/at91/mtd/at91_dataflash.h linux-2.4.26-vrs1/drivers/at91/mtd/at91_dataflash.h
--- linux-2.4.26/drivers/at91/mtd/at91_dataflash.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/mtd/at91_dataflash.h 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,42 @@
+/*
+ * Atmel DataFlash driver for the Atmel AT91RM9200 (Thunder)
+ *
+ * (c) SAN People (Pty) Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef AT91_DATAFLASH_H
+#define AT91_DATAFLASH_H
+
+#define DATAFLASH_MAX_DEVICES 4 /* max number of dataflash devices */
+
+#define OP_READ_CONTINUOUS 0xE8
+#define OP_READ_PAGE 0xD2
+#define OP_READ_BUFFER1 0xD4
+#define OP_READ_BUFFER2 0xD6
+#define OP_READ_STATUS 0xD7
+
+#define OP_ERASE_PAGE 0x81
+#define OP_ERASE_BLOCK 0x50
+
+#define OP_TRANSFER_BUF1 0x53
+#define OP_TRANSFER_BUF2 0x55
+#define OP_COMPARE_BUF1 0x60
+#define OP_COMPARE_BUF2 0x61
+
+#define OP_PROGRAM_VIA_BUF1 0x82
+#define OP_PROGRAM_VIA_BUF2 0x85
+
+struct dataflash_local
+{
+ int spi; /* SPI chip-select number */
+
+ unsigned int page_size; /* number of bytes per page */
+ unsigned short page_offset; /* page offset in flash address */
+};
+
+#endif
diff -urN linux-2.4.26/drivers/at91/mtd/at91_nand.c linux-2.4.26-vrs1/drivers/at91/mtd/at91_nand.c
--- linux-2.4.26/drivers/at91/mtd/at91_nand.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/mtd/at91_nand.c 2004-03-04 22:11:35.000000000 +0000
@@ -0,0 +1,328 @@
+/*
+ * drivers/at91/mtd/at91_nand.c
+ *
+ * Copyright (c) 2003 Rick Bronson
+ *
+ * Derived from drivers/mtd/nand/autcpu12.c
+ * Copyright (c) 2001 Thomas Gleixner (gleixner@autronix.de)
+ *
+ * Derived from drivers/mtd/spia.c
+ * Copyright (C) 2000 Steven J. Hill (sjhill@cotw.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/slab.h>
+#include <linux/module.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/partitions.h>
+#include <asm/io.h>
+#include <asm/arch/hardware.h>
+#include <asm/sizes.h>
+
+#include <asm/arch/pio.h>
+#include "at91_nand.h"
+
+/*
+ * MTD structure for AT91 board
+ */
+static struct mtd_info *at91_mtd = NULL;
+static struct nand_chip *my_nand_chip = NULL;
+
+static int at91_fio_base;
+
+#ifdef CONFIG_MTD_PARTITIONS
+
+/*
+ * Define partitions for flash devices
+ */
+
+static struct mtd_partition partition_info32k[] = {
+ { name: "AT91 NAND partition 1, kernel",
+ offset: 0,
+ size: 1 * SZ_1M },
+ { name: "AT91 NAND partition 2, filesystem",
+ offset: 1 * SZ_1M,
+ size: 16 * SZ_1M },
+ { name: "AT91 NAND partition 3a, storage",
+ offset: (1 * SZ_1M) + (16 * SZ_1M),
+ size: 1 * SZ_1M },
+ { name: "AT91 NAND partition 3b, storage",
+ offset: (2 * SZ_1M) + (16 * SZ_1M),
+ size: 1 * SZ_1M },
+ { name: "AT91 NAND partition 3c, storage",
+ offset: (3 * SZ_1M) + (16 * SZ_1M),
+ size: 1 * SZ_1M },
+ { name: "AT91 NAND partition 3d, storage",
+ offset: (4 * SZ_1M) + (16 * SZ_1M),
+ size: 1 * SZ_1M },
+};
+
+static struct mtd_partition partition_info64k[] = {
+ { name: "AT91 NAND partition 1, kernel",
+ offset: 0,
+ size: 1 * SZ_1M },
+ { name: "AT91 NAND partition 2, filesystem",
+ offset: 1 * SZ_1M,
+ size: 16 * SZ_1M },
+ { name: "AT91 NAND partition 3, storage",
+ offset: (1 * SZ_1M) + (16 * SZ_1M),
+ size: 47 * SZ_1M },
+};
+
+#endif
+
+/*
+ * Hardware specific access to control-lines
+ */
+static void at91_hwcontrol(int cmd)
+{
+ struct nand_chip *my_nand = my_nand_chip;
+ switch(cmd)
+ {
+ case NAND_CTL_SETCLE:
+ my_nand->IO_ADDR_W = at91_fio_base + AT91_SMART_MEDIA_CLE;
+ break;
+ case NAND_CTL_CLRCLE:
+ my_nand->IO_ADDR_W = at91_fio_base;
+ break;
+ case NAND_CTL_SETALE:
+ my_nand->IO_ADDR_W = at91_fio_base + AT91_SMART_MEDIA_ALE;
+ break;
+ case NAND_CTL_CLRALE:
+ my_nand->IO_ADDR_W = at91_fio_base;
+ break;
+ case NAND_CTL_SETNCE:
+ break;
+ case NAND_CTL_CLRNCE:
+ break;
+ }
+}
+
+/*
+ * Send command to NAND device
+ */
+static void at91_nand_command (struct mtd_info *mtd, unsigned command, int column, int page_addr)
+{
+ register struct nand_chip *my_nand = mtd->priv;
+
+ /* Begin command latch cycle */
+ register unsigned long NAND_IO_ADDR = my_nand->IO_ADDR_W + AT91_SMART_MEDIA_CLE;
+
+ /*
+ * Write out the command to the device.
+ */
+ if (command != NAND_CMD_SEQIN)
+ writeb (command, NAND_IO_ADDR);
+ else {
+ if (mtd->oobblock == 256 && column >= 256) {
+ column -= 256;
+ writeb (NAND_CMD_RESET, NAND_IO_ADDR);
+ writeb (NAND_CMD_READOOB, NAND_IO_ADDR);
+ writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
+ }
+ else
+ if (mtd->oobblock == 512 && column >= 256) {
+ if (column < 512) {
+ column -= 256;
+ writeb (NAND_CMD_READ1, NAND_IO_ADDR);
+ writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
+ } else {
+ column -= 512;
+ writeb (NAND_CMD_READOOB, NAND_IO_ADDR);
+ writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
+ }
+ } else {
+ writeb (NAND_CMD_READ0, NAND_IO_ADDR);
+ writeb (NAND_CMD_SEQIN, NAND_IO_ADDR);
+ }
+ }
+
+ /* Set ALE and clear CLE to start address cycle */
+ NAND_IO_ADDR = at91_fio_base;
+
+ if (column != -1 || page_addr != -1)
+ NAND_IO_ADDR += AT91_SMART_MEDIA_ALE;
+
+ /* Serially input address */
+ if (column != -1)
+ writeb (column, NAND_IO_ADDR);
+ if (page_addr != -1) {
+ writeb ((unsigned char) (page_addr & 0xff), NAND_IO_ADDR);
+ writeb ((unsigned char) ((page_addr >> 8) & 0xff), NAND_IO_ADDR);
+ /* One more address cycle for higher density devices */
+ if (mtd->size & 0x0c000000) {
+ writeb ((unsigned char) ((page_addr >> 16) & 0x0f), NAND_IO_ADDR);
+ }
+ }
+
+ /* wait until command is processed */
+ while (!my_nand->dev_ready())
+ ;
+}
+
+/*
+ * Read the Device Ready pin.
+ */
+static int at91_device_ready(void)
+{
+ return AT91_PIO_SmartMedia_RDY();
+}
+/*
+ * Main initialization routine
+ */
+static int __init at91_init (void)
+{
+ struct nand_chip *my_nand;
+ int err = 0;
+
+ /* Allocate memory for MTD device structure and private data */
+ at91_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip), GFP_KERNEL);
+ if (!at91_mtd) {
+ printk ("Unable to allocate AT91 NAND MTD device structure.\n");
+ err = -ENOMEM;
+ goto out;
+ }
+
+ /* map physical adress */
+ at91_fio_base = (unsigned long) ioremap(AT91_SMARTMEDIA_BASE, SZ_8M);
+ if(!at91_fio_base) {
+ printk("ioremap AT91 NAND failed\n");
+ err = -EIO;
+ goto out_mtd;
+ }
+
+ /* Get pointer to private data */
+ my_nand_chip = my_nand = (struct nand_chip *) (&at91_mtd[1]);
+
+ /* Initialize structures */
+ memset((char *) at91_mtd, 0, sizeof(struct mtd_info));
+ memset((char *) my_nand, 0, sizeof(struct nand_chip));
+
+ /* Link the private data with the MTD structure */
+ at91_mtd->priv = my_nand;
+
+ /* Set address of NAND IO lines */
+ my_nand->IO_ADDR_R = at91_fio_base;
+ my_nand->IO_ADDR_W = at91_fio_base;
+ my_nand->hwcontrol = at91_hwcontrol;
+ my_nand->dev_ready = at91_device_ready;
+ my_nand->cmdfunc = at91_nand_command; /* we need our own */
+ my_nand->eccmode = NAND_ECC_SOFT; /* enable ECC */
+ /* 20 us command delay time */
+ my_nand->chip_delay = 20;
+
+ /* Setup Smart Media, first enable the address range of CS3 */
+ AT91_SYS->EBI_CSA |= AT91C_EBI_CS3A_SMC_SmartMedia;
+ /* set the bus interface characteristics based on
+ tDS Data Set up Time 30 - ns
+ tDH Data Hold Time 20 - ns
+ tALS ALE Set up Time 20 - ns
+ 16ns at 60 MHz ~= 3 */
+#define AT91C_SM_ID_RWH (5 << 28) /* orig = 5 */
+#define AT91C_SM_RWH (1 << 28) /* orig = 1 */
+#define AT91C_SM_RWS (0 << 24) /* orig = 0 */
+#define AT91C_SM_TDF (1 << 8) /* orig = 1 */
+#define AT91C_SM_NWS (5) /* orig = 3 */
+ AT91_SYS->EBI_SMC2_CSR[3] = ( AT91C_SM_RWH | AT91C_SM_RWS |
+ AT91C_SMC2_ACSS_STANDARD |
+ AT91C_SMC2_DBW_8 | AT91C_SM_TDF |
+ AT91C_SMC2_WSEN | AT91C_SM_NWS);
+
+ AT91_CfgPIO_SmartMedia();
+
+ if (AT91_PIO_SmartMedia_CardDetect())
+ printk ("No ");
+ printk ("SmartMedia card inserted.\n");
+
+ /* Scan to find existance of the device */
+ if (nand_scan (at91_mtd)) {
+ err = -ENXIO;
+ goto out_ior;
+ }
+
+ /* Allocate memory for internal data buffer */
+ my_nand->data_buf = kmalloc (sizeof(u_char) * (at91_mtd->oobblock + at91_mtd->oobsize), GFP_KERNEL);
+ if (!my_nand->data_buf) {
+ printk ("Unable to allocate AT91 NAND data buffer.\n");
+ err = -ENOMEM;
+ goto out_ior;
+ }
+
+ /* Allocate memory for internal data buffer */
+ my_nand->data_cache = kmalloc (sizeof(u_char) * (at91_mtd->oobblock + at91_mtd->oobsize), GFP_KERNEL);
+ if (!my_nand->data_cache) {
+ printk ("Unable to allocate AT91 NAND data cache.\n");
+ err = -ENOMEM;
+ goto out_buf;
+ }
+ my_nand->cache_page = -1;
+
+#ifdef CONFIG_MTD_PARTITIONS
+ /* Register the partitions */
+ switch(at91_mtd->size)
+ {
+ case SZ_32M:
+ err = add_mtd_partitions(at91_mtd, partition_info32k,
+ ARRAY_SIZE (partition_info32k));
+ break;
+ case SZ_64M:
+ err = add_mtd_partitions(at91_mtd, partition_info64k,
+ ARRAY_SIZE (partition_info64k));
+ break;
+ default:
+ printk ("Unsupported SmartMedia device\n");
+ err = -ENXIO;
+ goto out_cac;
+ }
+#else
+ err = add_mtd_device(at91_mtd);
+#endif
+ goto out;
+
+ out_cac:
+ kfree (my_nand->data_cache);
+ out_buf:
+ kfree (my_nand->data_buf);
+ out_ior:
+ iounmap((void *)at91_fio_base);
+ out_mtd:
+ kfree (at91_mtd);
+ out:
+ return err;
+}
+
+/*
+ * Clean up routine
+ */
+static void __exit at91_cleanup (void)
+{
+ struct nand_chip *my_nand = (struct nand_chip *) &at91_mtd[1];
+
+ /* Unregister partitions */
+ del_mtd_partitions(at91_mtd);
+
+ /* Unregister the device */
+ del_mtd_device (at91_mtd);
+
+ /* Free internal data buffers */
+ kfree (my_nand->data_buf);
+ kfree (my_nand->data_cache);
+
+ /* unmap physical adress */
+ iounmap((void *)at91_fio_base);
+
+ /* Free the MTD device structure */
+ kfree (at91_mtd);
+}
+
+module_init(at91_init);
+module_exit(at91_cleanup);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Rick Bronson");
+MODULE_DESCRIPTION("Glue layer for SmartMediaCard on ATMEL AT91RM9200");
diff -urN linux-2.4.26/drivers/at91/mtd/at91_nand.h linux-2.4.26-vrs1/drivers/at91/mtd/at91_nand.h
--- linux-2.4.26/drivers/at91/mtd/at91_nand.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/mtd/at91_nand.h 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,27 @@
+/*
+ * AT91RM9200 specific NAND (SmartMedia) defines
+ *
+ * (c) 2003 Rick Bronson
+ *
+ * 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
+ */
+
+#ifndef __AT91_NAND_H
+#define __AT91_NAND_H
+
+#define AT91_SMART_MEDIA_ALE (1 << 22) /* our ALE is AD22 */
+#define AT91_SMART_MEDIA_CLE (1 << 21) /* our CLE is AD21 */
+
+#endif
diff -urN linux-2.4.26/drivers/at91/net/Makefile linux-2.4.26-vrs1/drivers/at91/net/Makefile
--- linux-2.4.26/drivers/at91/net/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/net/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,15 @@
+# File: drivers/at91/net/Makefile
+#
+# Makefile for the Atmel AT91RM9200 ethernet device drivers
+#
+
+O_TARGET := at91net.o
+
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_AT91_ETHER) += at91_ether.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/at91/net/at91_ether.c linux-2.4.26-vrs1/drivers/at91/net/at91_ether.c
--- linux-2.4.26/drivers/at91/net/at91_ether.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/net/at91_ether.c 2004-03-04 22:07:29.000000000 +0000
@@ -0,0 +1,877 @@
+/*
+ * Ethernet driver for the Atmel AT91RM9200 (Thunder)
+ *
+ * (c) SAN People (Pty) Ltd
+ *
+ * Based on an earlier Atmel EMAC macrocell driver by Atmel and Lineo Inc.
+ * Initial version by Rick Bronson 01/11/2003
+ *
+ * Intel LXT971A PHY support by Christopher Bahns & David Knickerbocker
+ * (Polaroid 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.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/config.h>
+#include <linux/mii.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <asm/io.h>
+#include <linux/pci.h>
+#include <linux/crc32.h>
+#include <asm/uaccess.h>
+#include <linux/ethtool.h>
+
+#include <asm/arch/AT91RM9200_EMAC.h>
+#include <asm/arch/pio.h>
+#include "at91_ether.h"
+
+static struct net_device at91_dev;
+
+/* ........................... PHY INTERFACE ........................... */
+
+/*
+ * Enable the MDIO bit in MAC control register
+ * When not called from an interrupt-handler, access to the PHY must be
+ * protected by a spinlock.
+ */
+static void enable_mdi(AT91PS_EMAC regs)
+{
+ regs->EMAC_CTL |= AT91C_EMAC_MPE; /* enable management port */
+}
+
+/*
+ * Disable the MDIO bit in the MAC control register
+ */
+static void disable_mdi(AT91PS_EMAC regs)
+{
+ regs->EMAC_CTL &= ~AT91C_EMAC_MPE; /* disable management port */
+}
+
+/*
+ * Write value to the a PHY register
+ * Note: MDI interface is assumed to already have been enabled.
+ */
+static void write_phy(AT91PS_EMAC regs, unsigned char phy_addr, unsigned char address, unsigned int value)
+{
+ regs->EMAC_MAN = (AT91C_EMAC_HIGH | AT91C_EMAC_CODE_802_3 | AT91C_EMAC_RW_W
+ | ((phy_addr & 0x1f) << 23) | (address << 18)) + (value & 0xffff);
+
+ /* Wait until IDLE bit in Network Status register is cleared */
+ // TODO: Enforce some maximum loop-count?
+ while (!(regs->EMAC_SR & AT91C_EMAC_IDLE)) { barrier(); }
+}
+
+/*
+ * Read value stored in a PHY register.
+ * Note: MDI interface is assumed to already have been enabled.
+ */
+static void read_phy(AT91PS_EMAC regs, unsigned char phy_addr, unsigned char address, unsigned int *value)
+{
+ regs->EMAC_MAN = AT91C_EMAC_HIGH | AT91C_EMAC_CODE_802_3 | AT91C_EMAC_RW_R
+ | ((phy_addr & 0x1f) << 23) | (address << 18);
+
+ /* Wait until IDLE bit in Network Status register is cleared */
+ // TODO: Enforce some maximum loop-count?
+ while (!(regs->EMAC_SR & AT91C_EMAC_IDLE)) { barrier(); }
+
+ *value = (regs->EMAC_MAN & 0x0000ffff);
+}
+
+/* ........................... PHY MANAGEMENT .......................... */
+
+/*
+ * Access the PHY to determine the current Link speed and Mode, and update the
+ * MAC accordingly.
+ * If no link or auto-negotiation is busy, then no changes are made.
+ * Returns: 0 : OK
+ * -1 : No link
+ * -2 : AutoNegotiation still in progress
+ */
+static int update_linkspeed(struct net_device *dev, AT91PS_EMAC regs) {
+ unsigned int bmsr, bmcr, lpa, mac_cfg;
+ unsigned int speed, duplex;
+
+ /* Link status is latched, so read twice to get current value */
+ read_phy(regs, 0, MII_BMSR, &bmsr);
+ read_phy(regs, 0, MII_BMSR, &bmsr);
+ if (!(bmsr & BMSR_LSTATUS)) return -1; /* no link */
+
+ read_phy(regs, 0, MII_BMCR, &bmcr);
+ if (bmcr & BMCR_ANENABLE) { /* AutoNegotiation is enabled */
+ if (!(bmsr & BMSR_ANEGCOMPLETE)) return -2; /* auto-negotitation in progress */
+
+ read_phy(regs, 0, MII_LPA, &lpa);
+ if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF)) speed = SPEED_100;
+ else speed = SPEED_10;
+ if ((lpa & LPA_100FULL) || (lpa & LPA_10FULL)) duplex = DUPLEX_FULL;
+ else duplex = DUPLEX_HALF;
+ } else {
+ speed = (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
+ duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
+ }
+
+ /* Update the MAC */
+ mac_cfg = regs->EMAC_CFG & ~(AT91C_EMAC_SPD | AT91C_EMAC_FD);
+ if (speed == SPEED_100) {
+ if (duplex == DUPLEX_FULL) /* 100 Full Duplex */
+ regs->EMAC_CFG = mac_cfg | AT91C_EMAC_SPD | AT91C_EMAC_FD;
+ else /* 100 Half Duplex */
+ regs->EMAC_CFG = mac_cfg | AT91C_EMAC_SPD;
+ } else {
+ if (duplex == DUPLEX_FULL) /* 10 Full Duplex */
+ regs->EMAC_CFG = mac_cfg | AT91C_EMAC_FD;
+ else /* 10 Half Duplex */
+ regs->EMAC_CFG = mac_cfg;
+ }
+
+ printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex");
+ return 0;
+}
+
+/*
+ * Handle interrupts from the PHY
+ */
+static void at91ether_phy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct net_device *dev = (struct net_device *) dev_id;
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ AT91PS_EMAC emac = (AT91PS_EMAC) dev->base_addr;
+ int status;
+ unsigned int phy;
+
+ enable_mdi(emac);
+ if (lp->phy_type == MII_DM9161_ID)
+ read_phy(emac, 0, MII_DSINTR_REG, &phy); /* ack interrupt in Davicom PHY */
+ else if (lp->phy_type == MII_LXT971A_ID)
+ read_phy(emac, 0, MII_ISINTS_REG, &phy); /* ack interrupt in Intel PHY */
+
+ status = AT91_SYS->PIOC_ISR; /* acknowledge interrupt in PIO */
+
+ status = update_linkspeed(dev, emac);
+ if (status == -1) { /* link is down */
+ netif_carrier_off(dev);
+ printk(KERN_INFO "%s: Link down.\n", dev->name);
+ } else if (status == -2) { /* auto-negotiation in progress */
+ /* Do nothing - another interrupt generated when negotiation complete */
+ } else { /* link is operational */
+ netif_carrier_on(dev);
+ }
+ disable_mdi(emac);
+}
+
+/*
+ * Initialize and enable the PHY interrupt when link-state changes
+ */
+static void enable_phyirq(struct net_device *dev, AT91PS_EMAC regs)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned int dsintr, status;
+
+ // TODO: Check error code. Really need a generic PIO (interrupt)
+ // layer since we're really only interested in the PC4 (DK) or PC2 (CSB337) line.
+ (void) request_irq(AT91C_ID_PIOC, at91ether_phy_interrupt, 0, dev->name, dev);
+
+ status = AT91_SYS->PIOC_ISR; /* clear any pending PIO interrupts */
+#ifdef CONFIG_MACH_CSB337
+ AT91_SYS->PIOC_IER = AT91C_PIO_PC2; /* Enable interrupt */
+#else
+ AT91_SYS->PIOC_IER = AT91C_PIO_PC4; /* Enable interrupt */
+#endif
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi(regs);
+
+ if (lp->phy_type == MII_DM9161_ID) { /* for Davicom PHY */
+ read_phy(regs, 0, MII_DSINTR_REG, &dsintr);
+ dsintr = dsintr & ~0xf00; /* clear bits 8..11 */
+ write_phy(regs, 0, MII_DSINTR_REG, dsintr);
+ }
+ else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
+ read_phy(regs, 0, MII_ISINTE_REG, &dsintr);
+ dsintr = dsintr | 0xf2; /* set bits 1, 4..7 */
+ write_phy(regs, 0, MII_ISINTE_REG, dsintr);
+ }
+
+ disable_mdi(regs);
+ spin_unlock_irq(&lp->lock);
+}
+
+/*
+ * Disable the PHY interrupt
+ */
+static void disable_phyirq(struct net_device *dev, AT91PS_EMAC regs)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned int dsintr;
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi(regs);
+
+ if (lp->phy_type == MII_DM9161_ID) { /* for Davicom PHY */
+ read_phy(regs, 0, MII_DSINTR_REG, &dsintr);
+ dsintr = dsintr | 0xf00; /* set bits 8..11 */
+ write_phy(regs, 0, MII_DSINTR_REG, dsintr);
+ }
+ else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
+ read_phy(regs, 0, MII_ISINTE_REG, &dsintr);
+ dsintr = dsintr & ~0xf2; /* clear bits 1, 4..7 */
+ write_phy(regs, 0, MII_ISINTE_REG, dsintr);
+ }
+
+ disable_mdi(regs);
+ spin_unlock_irq(&lp->lock);
+
+#ifdef CONFIG_MACH_CSB337
+ AT91_SYS->PIOC_IDR = AT91C_PIO_PC2; /* Disable interrupt */
+#else
+ AT91_SYS->PIOC_IDR = AT91C_PIO_PC4; /* Disable interrupt */
+#endif
+ free_irq(AT91C_ID_PIOC, dev); /* Free interrupt handler */
+}
+
+/*
+ * Perform a software reset of the PHY.
+ */
+static void reset_phy(struct net_device *dev, AT91PS_EMAC regs)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned int bmcr;
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi(regs);
+
+ /* Perform PHY reset */
+ write_phy(regs, 0, MII_BMCR, BMCR_RESET);
+
+ /* Wait until PHY reset is complete */
+ do {
+ read_phy(regs, 0, MII_BMCR, &bmcr);
+ } while (!(bmcr && BMCR_RESET));
+
+ disable_mdi(regs);
+ spin_unlock_irq(&lp->lock);
+}
+
+
+/* ......................... ADDRESS MANAGEMENT ........................ */
+
+/*
+ * Set the ethernet MAC address in dev->dev_addr
+ */
+static void get_mac_address(struct net_device *dev) {
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+ char addr[6];
+ unsigned int hi, lo;
+
+ /* Check if bootloader set address in Specific-Address 1 */
+ hi = regs->EMAC_SA1H;
+ lo = regs->EMAC_SA1L;
+ addr[0] = (lo & 0xff);
+ addr[1] = (lo & 0xff00) >> 8;
+ addr[2] = (lo & 0xff0000) >> 16;
+ addr[3] = (lo & 0xff000000) >> 24;
+ addr[4] = (hi & 0xff);
+ addr[5] = (hi & 0xff00) >> 8;
+
+ if (is_valid_ether_addr(addr)) {
+ memcpy(dev->dev_addr, &addr, 6);
+ return;
+ }
+
+ /* Check if bootloader set address in Specific-Address 2 */
+ hi = regs->EMAC_SA2H;
+ lo = regs->EMAC_SA2L;
+ addr[0] = (lo & 0xff);
+ addr[1] = (lo & 0xff00) >> 8;
+ addr[2] = (lo & 0xff0000) >> 16;
+ addr[3] = (lo & 0xff000000) >> 24;
+ addr[4] = (hi & 0xff);
+ addr[5] = (hi & 0xff00) >> 8;
+
+ if (is_valid_ether_addr(addr)) {
+ memcpy(dev->dev_addr, &addr, 6);
+ return;
+ }
+}
+
+/*
+ * Program the hardware MAC address from dev->dev_addr.
+ */
+static void update_mac_address(struct net_device *dev)
+{
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+
+ regs->EMAC_SA1L = (dev->dev_addr[3] << 24) | (dev->dev_addr[2] << 16) | (dev->dev_addr[1] << 8) | (dev->dev_addr[0]);
+ regs->EMAC_SA1H = (dev->dev_addr[5] << 8) | (dev->dev_addr[4]);
+}
+
+#ifdef AT91_ETHER_ADDR_CONFIGURABLE
+/*
+ * Store the new hardware address in dev->dev_addr, and update the MAC.
+ */
+static int set_mac_address(struct net_device *dev, void* addr)
+{
+ struct sockaddr *address = addr;
+
+ if (!is_valid_ether_addr(address->sa_data))
+ return -EADDRNOTAVAIL;
+
+ memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
+ update_mac_address(dev);
+
+ printk("%s: Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n", dev->name,
+ dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
+ dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
+
+ return 0;
+}
+#endif
+
+/*
+ * Add multicast addresses to the internal multicast-hash table.
+ */
+static void at91ether_sethashtable(struct net_device *dev, AT91PS_EMAC regs)
+{
+ struct dev_mc_list *curr;
+ unsigned char mc_filter[2];
+ unsigned int i, bitnr;
+
+ mc_filter[0] = mc_filter[1] = 0;
+
+ curr = dev->mc_list;
+ for (i = 0; i < dev->mc_count; i++, curr = curr->next) {
+ if (!curr) break; /* unexpected end of list */
+
+ bitnr = ether_crc(ETH_ALEN, curr->dmi_addr) >> 26;
+ mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
+ }
+
+ regs->EMAC_HSH = mc_filter[1];
+ regs->EMAC_HSL = mc_filter[0];
+}
+
+/*
+ * Enable/Disable promiscuous and multicast modes.
+ */
+static void at91ether_set_rx_mode(struct net_device *dev)
+{
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+
+ if (dev->flags & IFF_PROMISC) { /* Enable promiscuous mode */
+ regs->EMAC_CFG |= AT91C_EMAC_CAF;
+ } else if (dev->flags & (~IFF_PROMISC)) { /* Disable promiscuous mode */
+ regs->EMAC_CFG &= ~AT91C_EMAC_CAF;
+ }
+
+ if (dev->flags & IFF_ALLMULTI) { /* Enable all multicast mode */
+ regs->EMAC_HSH = -1;
+ regs->EMAC_HSL = -1;
+ regs->EMAC_CFG |= AT91C_EMAC_MTI;
+ } else if (dev->mc_count > 0) { /* Enable specific multicasts */
+ at91ether_sethashtable(dev, regs);
+ regs->EMAC_CFG |= AT91C_EMAC_MTI;
+ } else if (dev->flags & (~IFF_ALLMULTI)) { /* Disable all multicast mode */
+ regs->EMAC_HSH = 0;
+ regs->EMAC_HSL = 0;
+ regs->EMAC_CFG &= ~AT91C_EMAC_MTI;
+ }
+}
+
+/* ............................... IOCTL ............................... */
+
+static int mdio_read(struct net_device *dev, int phy_id, int location)
+{
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+ unsigned int value;
+
+ read_phy(regs, phy_id, location, &value);
+ return value;
+}
+
+static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
+{
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+
+ write_phy(regs, phy_id, location, value);
+}
+
+/*
+ * ethtool support.
+ */
+static int at91ether_ethtool_ioctl (struct net_device *dev, void *useraddr)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+ u32 ethcmd;
+ int res = 0;
+
+ if (copy_from_user (ðcmd, useraddr, sizeof (ethcmd)))
+ return -EFAULT;
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi(regs);
+
+ switch (ethcmd) {
+ case ETHTOOL_GSET: {
+ struct ethtool_cmd ecmd = { ETHTOOL_GSET };
+ res = mii_ethtool_gset(&lp->mii, &ecmd);
+ if (lp->phy_media == PORT_FIBRE) { /* override media type since mii.c doesn't know */
+ ecmd.supported = SUPPORTED_FIBRE;
+ ecmd.port = PORT_FIBRE;
+ }
+ if (copy_to_user(useraddr, &ecmd, sizeof(ecmd)))
+ res = -EFAULT;
+ break;
+ }
+ case ETHTOOL_SSET: {
+ struct ethtool_cmd ecmd;
+ if (copy_from_user(&ecmd, useraddr, sizeof(ecmd)))
+ res = -EFAULT;
+ else
+ res = mii_ethtool_sset(&lp->mii, &ecmd);
+ break;
+ }
+ case ETHTOOL_NWAY_RST: {
+ res = mii_nway_restart(&lp->mii);
+ break;
+ }
+ case ETHTOOL_GLINK: {
+ struct ethtool_value edata = { ETHTOOL_GLINK };
+ edata.data = mii_link_ok(&lp->mii);
+ if (copy_to_user(useraddr, &edata, sizeof(edata)))
+ res = -EFAULT;
+ break;
+ }
+ default:
+ res = -EOPNOTSUPP;
+ }
+
+ disable_mdi(regs);
+ spin_unlock_irq(&lp->lock);
+
+ return res;
+}
+
+/*
+ * User-space ioctl interface.
+ */
+static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+ switch(cmd) {
+ case SIOCETHTOOL:
+ return at91ether_ethtool_ioctl(dev, (void *) rq->ifr_data);
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+/* ................................ MAC ................................ */
+
+/*
+ * Initialize and start the Receiver and Transmit subsystems
+ */
+static void at91ether_start(struct net_device *dev)
+{
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ int i;
+ struct recv_desc_bufs *dlist, *dlist_phys;
+
+ dlist = lp->dlist;
+ dlist_phys = lp->dlist_phys;
+
+ for (i = 0; i < MAX_RX_DESCR; i++) {
+ dlist->descriptors[i].addr = (unsigned int) &dlist_phys->recv_buf[i][0];
+ dlist->descriptors[i].size = 0;
+ }
+
+ /* Set the Wrap bit on the last descriptor */
+ dlist->descriptors[i-1].addr |= EMAC_DESC_WRAP;
+
+ /* Reset buffer index */
+ lp->rxBuffIndex = 0;
+
+ /* Program address of descriptor list in Rx Buffer Queue register */
+ regs->EMAC_RBQP = (AT91_REG) dlist_phys;
+
+ /* Enable Receive and Transmit */
+ regs->EMAC_CTL |= (AT91C_EMAC_RE | AT91C_EMAC_TE);
+}
+
+/*
+ * Open the ethernet interface
+ */
+static int at91ether_open(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+
+ if (!is_valid_ether_addr(dev->dev_addr))
+ return -EADDRNOTAVAIL;
+
+ AT91_SYS->PMC_PCER = 1 << AT91C_ID_EMAC; /* Re-enable Peripheral clock */
+ regs->EMAC_CTL |= AT91C_EMAC_CSR; /* Clear internal statistics */
+
+ /* Enable PHY interrupt */
+ enable_phyirq(dev, regs);
+
+ /* Enable MAC interrupts */
+ regs->EMAC_IER = AT91C_EMAC_RCOM | AT91C_EMAC_RBNA
+ | AT91C_EMAC_TUND | AT91C_EMAC_RTRY | AT91C_EMAC_TCOM
+ | AT91C_EMAC_ROVR | AT91C_EMAC_HRESP;
+
+ /* Determine current link speed */
+ spin_lock_irq(&lp->lock);
+ enable_mdi(regs);
+ (void) update_linkspeed(dev, regs);
+ disable_mdi(regs);
+ spin_unlock_irq(&lp->lock);
+
+ at91ether_start(dev);
+ netif_start_queue(dev);
+ return 0;
+}
+
+/*
+ * Close the interface
+ */
+static int at91ether_close(struct net_device *dev)
+{
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+
+ /* Disable Receiver and Transmitter */
+ regs->EMAC_CTL &= ~(AT91C_EMAC_TE | AT91C_EMAC_RE);
+
+ /* Disable PHY interrupt */
+ disable_phyirq(dev, regs);
+
+ /* Disable MAC interrupts */
+ regs->EMAC_IDR = AT91C_EMAC_RCOM | AT91C_EMAC_RBNA
+ | AT91C_EMAC_TUND | AT91C_EMAC_RTRY | AT91C_EMAC_TCOM
+ | AT91C_EMAC_ROVR | AT91C_EMAC_HRESP;
+
+ netif_stop_queue(dev);
+
+ AT91_SYS->PMC_PCDR = 1 << AT91C_ID_EMAC; /* Disable Peripheral clock */
+
+ return 0;
+}
+
+/*
+ * Transmit packet.
+ */
+static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
+{
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+
+ if (regs->EMAC_TSR & AT91C_EMAC_BNQ) {
+ netif_stop_queue(dev);
+
+ /* Store packet information (to free when Tx completed) */
+ lp->skb = skb;
+ lp->skb_length = skb->len;
+ lp->skb_physaddr = pci_map_single(NULL, skb->data, skb->len, PCI_DMA_TODEVICE);
+ lp->stats.tx_bytes += skb->len;
+
+ /* Set address of the data in the Transmit Address register */
+ regs->EMAC_TAR = lp->skb_physaddr;
+ /* Set length of the packet in the Transmit Control register */
+ regs->EMAC_TCR = skb->len;
+
+ dev->trans_start = jiffies;
+ } else {
+ printk(KERN_ERR "at91_ether.c: at91ether_tx() called, but device is busy!\n");
+ return 1; /* if we return anything but zero, dev.c:1055 calls kfree_skb(skb)
+ on this skb, he also reports -ENETDOWN and printk's, so either
+ we free and return(0) or don't free and return 1 */
+ }
+
+ return 0;
+}
+
+/*
+ * Update the current statistics from the internal statistics registers.
+ */
+static struct net_device_stats *at91ether_stats(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ AT91PS_EMAC regs = (AT91PS_EMAC) dev->base_addr;
+ int ale, lenerr, seqe, lcol, ecol;
+
+ if (netif_running(dev)) {
+ lp->stats.rx_packets += regs->EMAC_OK; /* Good frames received */
+ ale = regs->EMAC_ALE;
+ lp->stats.rx_frame_errors += ale; /* Alignment errors */
+ lenerr = regs->EMAC_ELR + regs->EMAC_USF;
+ lp->stats.rx_length_errors += lenerr; /* Excessive Length or Undersize Frame error */
+ seqe = regs->EMAC_SEQE;
+ lp->stats.rx_crc_errors += seqe; /* CRC error */
+ lp->stats.rx_fifo_errors += regs->EMAC_DRFC; /* Receive buffer not available */
+ lp->stats.rx_errors += (ale + lenerr + seqe + regs->EMAC_CDE + regs->EMAC_RJB);
+
+ lp->stats.tx_packets += regs->EMAC_FRA; /* Frames successfully transmitted */
+ lp->stats.tx_fifo_errors += regs->EMAC_TUE; /* Transmit FIFO underruns */
+ lp->stats.tx_carrier_errors += regs->EMAC_CSE; /* Carrier Sense errors */
+ lp->stats.tx_heartbeat_errors += regs->EMAC_SQEE; /* Heartbeat error */
+
+ lcol = regs->EMAC_LCOL;
+ ecol = regs->EMAC_ECOL;
+ lp->stats.tx_window_errors += lcol; /* Late collisions */
+ lp->stats.tx_aborted_errors += ecol; /* 16 collisions */
+
+ lp->stats.collisions += (regs->EMAC_SCOL + regs->EMAC_MCOL + lcol + ecol);
+ }
+ return &lp->stats;
+}
+
+/*
+ * Extract received frame from buffer descriptors and sent to upper layers.
+ * (Called from interrupt context)
+ */
+static void at91ether_rx(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ struct recv_desc_bufs *dlist;
+ unsigned char *p_recv;
+ struct sk_buff *skb;
+ unsigned int pktlen;
+
+ dlist = lp->dlist;
+ while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
+ p_recv = dlist->recv_buf[lp->rxBuffIndex];
+ pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
+ skb = alloc_skb(pktlen + 2, GFP_ATOMIC);
+ if (skb != NULL) {
+ skb_reserve(skb, 2);
+ memcpy(skb_put(skb, pktlen), p_recv, pktlen);
+
+ skb->dev = dev;
+ skb->protocol = eth_type_trans(skb, dev);
+ skb->len = pktlen;
+ dev->last_rx = jiffies;
+ lp->stats.rx_bytes += pktlen;
+ netif_rx(skb);
+ }
+ else {
+ lp->stats.rx_dropped += 1;
+ printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
+ }
+
+ if (dlist->descriptors[lp->rxBuffIndex].size & EMAC_MULTICAST)
+ lp->stats.multicast++;
+
+ dlist->descriptors[lp->rxBuffIndex].addr &= ~EMAC_DESC_DONE; /* reset ownership bit */
+ if (lp->rxBuffIndex == MAX_RX_DESCR-1) /* wrap after last buffer */
+ lp->rxBuffIndex = 0;
+ else
+ lp->rxBuffIndex++;
+ }
+}
+
+/*
+ * MAC interrupt handler
+ */
+static void at91ether_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct net_device *dev = (struct net_device *) dev_id;
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ AT91PS_EMAC emac = (AT91PS_EMAC) dev->base_addr;
+ unsigned long intstatus;
+
+ /* MAC Interrupt Status register indicates what interrupts are pending.
+ It is automatically cleared once read. */
+ intstatus = emac->EMAC_ISR;
+
+ if (intstatus & AT91C_EMAC_RCOM) /* Receive complete */
+ at91ether_rx(dev);
+
+ if (intstatus & AT91C_EMAC_TCOM) { /* Transmit complete */
+ /* The TCOM bit is set even if the transmission failed. */
+ if (intstatus & (AT91C_EMAC_TUND | AT91C_EMAC_RTRY))
+ lp->stats.tx_errors += 1;
+
+ dev_kfree_skb_irq(lp->skb);
+ pci_unmap_single(NULL, lp->skb_physaddr, lp->skb_length, PCI_DMA_TODEVICE);
+ netif_wake_queue(dev);
+ }
+
+ if (intstatus & AT91C_EMAC_RBNA)
+ printk("%s: RBNA error\n", dev->name);
+ if (intstatus & AT91C_EMAC_ROVR)
+ printk("%s: ROVR error\n", dev->name);
+}
+
+/*
+ * Initialize the ethernet interface
+ */
+static int at91ether_setup(struct net_device *dev, unsigned long phy_type)
+{
+ struct at91_private *lp;
+ AT91PS_EMAC regs;
+ static int already_initialized = 0;
+ unsigned int val;
+
+ if (already_initialized)
+ return 0;
+
+ dev = init_etherdev(dev, sizeof(struct at91_private));
+ dev->base_addr = AT91C_VA_BASE_EMAC;
+ dev->irq = AT91C_ID_EMAC;
+ SET_MODULE_OWNER(dev);
+
+ /* Install the interrupt handler */
+ if (request_irq(dev->irq, at91ether_interrupt, 0, dev->name, dev))
+ return -EBUSY;
+
+ /* Allocate memory for private data structure */
+ lp = (struct at91_private *) kmalloc(sizeof(struct at91_private), GFP_KERNEL);
+ if (lp == NULL) {
+ free_irq(dev->irq, dev);
+ return -ENOMEM;
+ }
+ memset(lp, 0, sizeof(struct at91_private));
+ dev->priv = lp;
+
+ /* Allocate memory for DMA Receive descriptors */
+ lp->dlist = (struct recv_desc_bufs *) consistent_alloc(GFP_DMA | GFP_KERNEL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys);
+ if (lp->dlist == NULL) {
+ kfree(dev->priv);
+ free_irq(dev->irq, dev);
+ return -ENOMEM;
+ }
+
+ spin_lock_init(&lp->lock);
+
+ ether_setup(dev);
+ dev->open = at91ether_open;
+ dev->stop = at91ether_close;
+ dev->hard_start_xmit = at91ether_tx;
+ dev->get_stats = at91ether_stats;
+ dev->set_multicast_list = at91ether_set_rx_mode;
+ dev->do_ioctl = at91ether_ioctl;
+
+#ifdef AT91_ETHER_ADDR_CONFIGURABLE
+ dev->set_mac_address = set_mac_address;
+#endif
+
+ get_mac_address(dev); /* Get ethernet address and store it in dev->dev_addr */
+ update_mac_address(dev); /* Program ethernet address into MAC */
+
+ regs = (AT91PS_EMAC) dev->base_addr;
+ regs->EMAC_CTL = 0;
+
+#ifdef CONFIG_AT91_ETHER_RMII
+ regs->EMAC_CFG = AT91C_EMAC_BIG | AT91C_EMAC_RMII;
+#else
+ regs->EMAC_CFG = AT91C_EMAC_BIG;
+#endif
+ if (phy_type == MII_LXT971A_ID)
+ regs->EMAC_CFG |= AT91C_EMAC_CLK_HCLK_64; /* MDIO clock = system clock/64 */
+
+ if (phy_type == MII_DM9161_ID) {
+ spin_lock_irq(&lp->lock);
+ enable_mdi(regs);
+
+ read_phy(regs, 0, MII_DSCR_REG, &val);
+ if ((val & (1 << 10)) == 0) /* DSCR bit 10 is 0 -- fiber mode */
+ lp->phy_media = PORT_FIBRE;
+
+ disable_mdi(regs);
+ spin_unlock_irq(&lp->lock);
+ }
+
+ lp->mii.dev = dev; /* Support for ethtool */
+ lp->mii.mdio_read = mdio_read;
+ lp->mii.mdio_write = mdio_write;
+
+ lp->phy_type = phy_type; /* Type of PHY connected */
+
+ /* Determine current link speed */
+ spin_lock_irq(&lp->lock);
+ enable_mdi(regs);
+ (void) update_linkspeed(dev, regs);
+ disable_mdi(regs);
+ spin_unlock_irq(&lp->lock);
+
+ /* Display ethernet banner */
+ printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%02x:%02x:%02x:%02x:%02x:%02x)\n",
+ dev->name, (uint) dev->base_addr, dev->irq,
+ regs->EMAC_CFG & AT91C_EMAC_SPD ? "100-" : "10-",
+ regs->EMAC_CFG & AT91C_EMAC_FD ? "FullDuplex" : "HalfDuplex",
+ dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
+ dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
+ if (phy_type == MII_DM9161_ID)
+ printk(KERN_INFO "%s: Davicom 9196 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)");
+ else if (phy_type == MII_LXT971A_ID)
+ printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name);
+
+ already_initialized = 1;
+ return 0;
+}
+
+/*
+ * Detect MAC and PHY and perform initialization
+ */
+static int at91ether_probe(struct net_device *dev)
+{
+ AT91PS_EMAC regs = (AT91PS_EMAC) AT91C_VA_BASE_EMAC;
+ unsigned int phyid1, phyid2;
+ int detected = -1;
+
+ /* Configure the hardware - RMII vs MII mode */
+#ifdef CONFIG_AT91_ETHER_RMII
+ AT91_CfgPIO_EMAC_RMII();
+#else
+ AT91_CfgPIO_EMAC_MII();
+#endif
+
+ AT91_CfgPIO_EMAC_PHY(); /* Configure PHY interrupt */
+ AT91_SYS->PMC_PCER = 1 << AT91C_ID_EMAC; /* Enable Peripheral clock */
+
+ /* Read the PHY ID registers */
+ enable_mdi(regs);
+ read_phy(regs, 0, MII_PHYSID1, &phyid1);
+ read_phy(regs, 0, MII_PHYSID2, &phyid2);
+ disable_mdi(regs);
+
+ /* Davicom 9161: PHY_ID1 = 0x181 PHY_ID2 = B881 */
+ if (((phyid1 << 16) | (phyid2 & 0xfff0)) == MII_DM9161_ID) {
+ detected = at91ether_setup(dev, MII_DM9161_ID);
+ }
+ /* Intel LXT971A: PHY_ID1 = 0x13 PHY_ID2 = 78E0 */
+ else if (((phyid1 << 16) | (phyid2 & 0xfff0)) == MII_LXT971A_ID) {
+ detected = at91ether_setup(dev, MII_LXT971A_ID);
+ }
+
+ AT91_SYS->PMC_PCDR = 1 << AT91C_ID_EMAC; /* Disable Peripheral clock */
+
+ return detected;
+}
+
+static int __init at91ether_init(void)
+{
+ if (!at91ether_probe(&at91_dev))
+ return register_netdev(&at91_dev);
+
+ return -1;
+}
+
+static void __exit at91ether_exit(void)
+{
+ unregister_netdev(&at91_dev);
+}
+
+module_init(at91ether_init)
+module_exit(at91ether_exit)
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("AT91RM9200 EMAC Ethernet driver");
+MODULE_AUTHOR("Andrew Victor");
diff -urN linux-2.4.26/drivers/at91/net/at91_ether.h linux-2.4.26-vrs1/drivers/at91/net/at91_ether.h
--- linux-2.4.26/drivers/at91/net/at91_ether.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/net/at91_ether.h 2004-03-04 22:07:29.000000000 +0000
@@ -0,0 +1,81 @@
+/*
+ * Ethernet driver for the Atmel AT91RM9200 (Thunder)
+ *
+ * (c) SAN People (Pty) Ltd
+ *
+ * Based on an earlier Atmel EMAC macrocell driver by Atmel and Lineo Inc.
+ * Initial version by Rick Bronson.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef AT91_ETHERNET
+#define AT91_ETHERNET
+
+#undef AT91_ETHER_ADDR_CONFIGURABLE /* MAC address can be changed? */
+
+
+/* Davicom 9161 PHY */
+#define MII_DM9161_ID 0x0181b880
+
+/* Davicom specific registers */
+#define MII_DSCR_REG 16
+#define MII_DSCSR_REG 17
+#define MII_DSINTR_REG 21
+
+/* Intel LXT971A PHY */
+#define MII_LXT971A_ID 0x001378E0
+
+/* Intel specific registers */
+#define MII_ISINTE_REG 18
+#define MII_ISINTS_REG 19
+
+/* ........................................................................ */
+
+#define MAX_RBUFF_SZ 0x600 /* 1518 rounded up */
+#define MAX_RX_DESCR 9 /* max number of receive buffers */
+
+#define EMAC_DESC_DONE 0x00000001 /* bit for if DMA is done */
+#define EMAC_DESC_WRAP 0x00000002 /* bit for wrap */
+
+#define EMAC_BROADCAST 0x80000000 /* broadcast address */
+#define EMAC_MULTICAST 0x40000000 /* multicast address */
+#define EMAC_UNICAST 0x20000000 /* unicast address */
+
+struct rbf_t
+{
+ unsigned int addr;
+ unsigned long size;
+};
+
+struct recv_desc_bufs
+{
+ struct rbf_t descriptors[MAX_RX_DESCR]; /* must be on sizeof (rbf_t) boundary */
+ char recv_buf[MAX_RX_DESCR][MAX_RBUFF_SZ]; /* must be on long boundary */
+};
+
+struct at91_private
+{
+ struct net_device_stats stats;
+ struct mii_if_info mii; /* ethtool support */
+
+ /* PHY */
+ unsigned long phy_type; /* type of PHY (PHY_ID) */
+ spinlock_t lock; /* lock for MDI interface */
+ short phy_media; /* media interface type */
+
+ /* Transmit */
+ struct sk_buff *skb; /* holds skb until xmit interrupt completes */
+ dma_addr_t skb_physaddr; /* phys addr from pci_map_single */
+ int skb_length; /* saved skb length for pci_unmap_single */
+
+ /* Receive */
+ int rxBuffIndex; /* index into receive descriptor list */
+ struct recv_desc_bufs *dlist; /* descriptor list address */
+ struct recv_desc_bufs *dlist_phys; /* descriptor list physical address */
+};
+
+#endif
diff -urN linux-2.4.26/drivers/at91/rtc/Makefile linux-2.4.26-vrs1/drivers/at91/rtc/Makefile
--- linux-2.4.26/drivers/at91/rtc/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/rtc/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,15 @@
+# File: drivers/at91/rtc/Makefile
+#
+# Makefile for the Atmel AT91RM9200 real time clock device drivers
+#
+
+O_TARGET := at91rtc.o
+
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_AT91_RTC) += at91_rtc.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/at91/rtc/at91_rtc.c linux-2.4.26-vrs1/drivers/at91/rtc/at91_rtc.c
--- linux-2.4.26/drivers/at91/rtc/at91_rtc.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/rtc/at91_rtc.c 2004-03-04 22:31:24.000000000 +0000
@@ -0,0 +1,441 @@
+/*
+ * Real Time Clock interface for Linux on Atmel AT91RM9200
+ *
+ * Copyright (c) 2002 Rick Bronson
+ *
+ * Based on sa1100-rtc.c by Nils Faerber
+ * Based on rtc.c by Paul Gortmaker
+ * Date/time conversion routines taken from arch/arm/kernel/time.c
+ * by Linus Torvalds and Russell King
+ * and the GNU C Library
+ * ( ... I love the GPL ... just take what you need! ;)
+ *
+ * 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.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/poll.h>
+#include <linux/proc_fs.h>
+#include <asm/bitops.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <linux/rtc.h>
+
+#define AT91_RTC_FREQ 1
+#define EPOCH 1970
+
+/* Those are the bits from a classic RTC we want to mimic */
+#define AT91_RTC_IRQF 0x80 /* any of the following 3 is active */
+#define AT91_RTC_PF 0x40
+#define AT91_RTC_AF 0x20
+#define AT91_RTC_UF 0x10
+
+#define BCD2BIN(val) (((val)&15) + ((val)>>4)*10)
+#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
+
+static unsigned long rtc_status = 0;
+static unsigned long rtc_irq_data;
+static unsigned int at91_alarm_year = EPOCH;
+
+static struct fasync_struct *at91_rtc_async_queue;
+static DECLARE_WAIT_QUEUE_HEAD(at91_rtc_wait);
+static DECLARE_WAIT_QUEUE_HEAD(at91_rtc_update);
+static spinlock_t at91_rtc_updlock; /* some spinlocks for saving/restoring interrupt levels */
+extern spinlock_t at91_rtc_lock;
+
+static const unsigned char days_in_mo[] =
+ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+#define is_leap(year) \
+ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
+
+static const unsigned short int __mon_yday[2][13] =
+{
+ /* Normal years. */
+ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
+ /* Leap years. */
+ { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
+};
+
+/*
+ * Returns day since start of the year [0-365]
+ * (from drivers/char/efirtc.c)
+ */
+static inline int compute_yday(int year, int month, int day)
+{
+ return __mon_yday[is_leap(year)][month] + day-1;
+}
+
+/*
+ * Set current time and date in RTC
+ */
+static void at91_rtc_settime(struct rtc_time *tval)
+{
+ unsigned long flags;
+
+ /* Stop Time/Calendar from counting */
+ AT91_SYS->RTC_CR |= (AT91C_RTC_UPDCAL | AT91C_RTC_UPDTIM);
+
+ spin_lock_irqsave(&at91_rtc_updlock, flags); /* stop int's else we wakeup b4 we sleep */
+ AT91_SYS->RTC_IER = AT91C_RTC_ACKUPD;
+ interruptible_sleep_on(&at91_rtc_update); /* wait for ACKUPD interrupt to hit */
+ spin_unlock_irqrestore(&at91_rtc_updlock, flags);
+ AT91_SYS->RTC_IDR = AT91C_RTC_ACKUPD;
+
+ AT91_SYS->RTC_TIMR = BIN2BCD(tval->tm_sec) << 0
+ | BIN2BCD(tval->tm_min) << 8
+ | BIN2BCD(tval->tm_hour) << 16;
+
+ AT91_SYS->RTC_CALR = BIN2BCD((tval->tm_year + 1900) / 100) /* century */
+ | BIN2BCD(tval->tm_year % 100) << 8 /* year */
+ | BIN2BCD(tval->tm_mon + 1) << 16 /* tm_mon starts at zero */
+ | BIN2BCD(tval->tm_wday + 1) << 21 /* day of the week [0-6], Sunday=0 */
+ | BIN2BCD(tval->tm_mday) << 24;
+
+ /* Restart Time/Calendar */
+ AT91_SYS->RTC_CR &= ~(AT91C_RTC_UPDCAL | AT91C_RTC_UPDTIM);
+}
+
+/*
+ * Decode time/date into rtc_time structure
+ */
+static void at91_rtc_decodetime(AT91_REG *timereg, AT91_REG *calreg, struct rtc_time *tval)
+{
+ unsigned int time, date;
+
+ do { /* must read twice in case it changes */
+ time = *timereg;
+ date = *calreg;
+ } while ((time != *timereg) || (date != *calreg));
+
+ tval->tm_sec = BCD2BIN((time & AT91C_RTC_SEC) >> 0);
+ tval->tm_min = BCD2BIN((time & AT91C_RTC_MIN) >> 8);
+ tval->tm_hour = BCD2BIN((time & AT91C_RTC_HOUR) >> 16);
+
+ /* The Calendar Alarm register does not have a field for
+ the year - so these will return an invalid value. When an
+ alarm is set, at91_alarm_year wille store the current year. */
+ tval->tm_year = BCD2BIN(date & AT91C_RTC_CENT) * 100; /* century */
+ tval->tm_year += BCD2BIN((date & AT91C_RTC_YEAR) >> 8); /* year */
+
+ tval->tm_wday = BCD2BIN((date & AT91C_RTC_DAY) >> 21) - 1; /* day of the week [0-6], Sunday=0 */
+ tval->tm_mon = BCD2BIN(((date & AT91C_RTC_MONTH) >> 16) - 1);
+ tval->tm_mday = BCD2BIN((date & AT91C_RTC_DATE) >> 24);
+}
+
+/*
+ * IRQ handler for the RTC
+ */
+static void at91_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned int rtsr = AT91_SYS->RTC_SR & AT91_SYS->RTC_IMR;
+
+ /* update irq data & counter */
+ if (rtsr) { /* this interrupt is shared! Is it ours? */
+ if (rtsr & AT91C_RTC_ALARM)
+ rtc_irq_data |= (AT91_RTC_AF | AT91_RTC_IRQF);
+ if (rtsr & AT91C_RTC_SECEV)
+ rtc_irq_data |= (AT91_RTC_UF | AT91_RTC_IRQF);
+ if (rtsr & AT91C_RTC_ACKUPD)
+ wake_up_interruptible(&at91_rtc_update);
+ rtc_irq_data += 0x100;
+ AT91_SYS->RTC_SCCR = rtsr; /* clear status reg */
+
+ /* wake up waiting process */
+ wake_up_interruptible(&at91_rtc_wait);
+ kill_fasync(&at91_rtc_async_queue, SIGIO, POLL_IN);
+ }
+}
+
+static int at91_rtc_open(struct inode *inode, struct file *file)
+{
+ if (test_and_set_bit(1, &rtc_status))
+ return -EBUSY;
+ rtc_irq_data = 0;
+ return 0;
+}
+
+static int at91_rtc_release(struct inode *inode, struct file *file)
+{
+ rtc_status = 0;
+ return 0;
+}
+
+static int at91_rtc_fasync(int fd, struct file *filp, int on)
+{
+ return fasync_helper(fd, filp, on, &at91_rtc_async_queue);
+}
+
+static unsigned int at91_rtc_poll(struct file *file, poll_table * wait)
+{
+ poll_wait(file, &at91_rtc_wait, wait);
+ return (rtc_irq_data) ? 0 : POLLIN | POLLRDNORM;
+}
+
+static ssize_t at91_rtc_read(struct file * file, char *buf, size_t count, loff_t * ppos)
+{
+ DECLARE_WAITQUEUE(wait, current);
+ unsigned long data;
+ ssize_t retval;
+
+ if (count < sizeof(unsigned long))
+ return -EINVAL;
+
+ add_wait_queue(&at91_rtc_wait, &wait);
+ set_current_state(TASK_INTERRUPTIBLE);
+ for (;;) {
+ spin_lock_irq(&at91_rtc_lock);
+ data = rtc_irq_data;
+ if (data != 0) {
+ rtc_irq_data = 0;
+ break;
+ }
+ spin_unlock_irq(&at91_rtc_lock);
+
+ if (file->f_flags & O_NONBLOCK) {
+ retval = -EAGAIN;
+ goto out;
+ }
+
+ if (signal_pending(current)) {
+ retval = -ERESTARTSYS;
+ goto out;
+ }
+
+ schedule();
+ }
+ spin_unlock_irq(&at91_rtc_lock);
+
+ data -= 0x100; /* the first IRQ wasn't actually missed */
+ retval = put_user(data, (unsigned long *) buf);
+ if (!retval)
+ retval = sizeof(unsigned long);
+
+out:
+ set_current_state(TASK_RUNNING);
+ remove_wait_queue(&at91_rtc_wait, &wait);
+ return retval;
+}
+
+/*
+ * Handle commands from user-space
+ */
+static int at91_rtc_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ struct rtc_time tm, tm2;
+ int ret = 0;
+
+ spin_lock_irq(&at91_rtc_lock);
+ switch (cmd) {
+ case RTC_AIE_OFF: /* alarm off */
+ AT91_SYS->RTC_IDR = AT91C_RTC_ALARM;
+ rtc_irq_data = 0;
+ break;
+ case RTC_AIE_ON: /* alarm on */
+ AT91_SYS->RTC_IER = AT91C_RTC_ALARM;
+ rtc_irq_data = 0;
+ break;
+ case RTC_UIE_OFF: /* update off */
+ AT91_SYS->RTC_IDR = AT91C_RTC_SECEV;
+ rtc_irq_data = 0;
+ break;
+ case RTC_UIE_ON: /* update on */
+ AT91_SYS->RTC_IER = AT91C_RTC_SECEV;
+ rtc_irq_data = 0;
+ break;
+ case RTC_PIE_OFF: /* periodic off */
+ AT91_SYS->RTC_IDR = AT91C_RTC_SECEV;
+ rtc_irq_data = 0;
+ break;
+ case RTC_PIE_ON: /* periodic on */
+ AT91_SYS->RTC_IER = AT91C_RTC_SECEV;
+ rtc_irq_data = 0;
+ break;
+ case RTC_ALM_READ: /* read alarm */
+ memset(&tm, 0, sizeof(struct rtc_time));
+ at91_rtc_decodetime(&(AT91_SYS->RTC_TIMALR), &(AT91_SYS->RTC_CALALR), &tm);
+ tm.tm_yday = compute_yday(tm.tm_year, tm.tm_mon, tm.tm_mday);
+ tm.tm_year = at91_alarm_year - 1900;
+ ret = copy_to_user((void *) arg, &tm, sizeof(tm)) ? -EFAULT : 0;
+ break;
+ case RTC_ALM_SET: /* set alarm */
+ if (copy_from_user(&tm2, (struct rtc_time *) arg, sizeof(tm2)))
+ ret = -EFAULT;
+ else {
+ at91_rtc_decodetime(&(AT91_SYS->RTC_TIMR), &(AT91_SYS->RTC_CALR), &tm);
+ at91_alarm_year = tm.tm_year;
+ if ((unsigned) tm2.tm_hour < 24) /* do some range checking */
+ tm.tm_hour = tm2.tm_hour;
+ if ((unsigned) tm2.tm_min < 60)
+ tm.tm_min = tm2.tm_min;
+ if ((unsigned) tm2.tm_sec < 60)
+ tm.tm_sec = tm2.tm_sec;
+ AT91_SYS->RTC_TIMALR = BIN2BCD(tm.tm_sec) << 0
+ | BIN2BCD(tm.tm_min) << 8
+ | BIN2BCD(tm.tm_hour) << 16
+ | AT91C_RTC_HOUREN | AT91C_RTC_MINEN
+ | AT91C_RTC_SECEN;
+ AT91_SYS->RTC_CALALR = BIN2BCD(tm.tm_mon + 1) << 16 /* tm_mon starts at zero */
+ | BIN2BCD(tm.tm_mday) << 24
+ | AT91C_RTC_DATEEN | AT91C_RTC_MONTHEN;
+ }
+ break;
+ case RTC_RD_TIME: /* read time */
+ memset(&tm, 0, sizeof(struct rtc_time));
+ at91_rtc_decodetime(&(AT91_SYS->RTC_TIMR), &(AT91_SYS->RTC_CALR), &tm);
+ tm.tm_yday = compute_yday(tm.tm_year, tm.tm_mon, tm.tm_mday);
+ tm.tm_year = tm.tm_year - 1900;
+ ret = copy_to_user((void *) arg, &tm, sizeof(tm)) ? -EFAULT : 0;
+ break;
+ case RTC_SET_TIME: /* set time */
+ if (!capable(CAP_SYS_TIME))
+ ret = -EACCES;
+ else {
+ if (copy_from_user(&tm, (struct rtc_time *) arg, sizeof(tm)))
+ ret = -EFAULT;
+ else {
+ int tm_year = tm.tm_year + 1900;
+ if (tm_year < EPOCH
+ || (unsigned) tm.tm_mon >= 12
+ || tm.tm_mday < 1
+ || tm.tm_mday > (days_in_mo[tm.tm_mon] + (tm.tm_mon == 1 && is_leap(tm_year)))
+ || (unsigned) tm.tm_hour >= 24
+ || (unsigned) tm.tm_min >= 60
+ || (unsigned) tm.tm_sec >= 60)
+ ret = -EINVAL;
+ else
+ at91_rtc_settime(&tm);
+ }
+ }
+ break;
+ case RTC_IRQP_READ: /* read periodic alarm frequency */
+ ret = put_user(AT91_RTC_FREQ, (unsigned long *) arg);
+ break;
+ case RTC_IRQP_SET: /* set periodic alarm frequency */
+ if (arg != AT91_RTC_FREQ)
+ ret = -EINVAL;
+ break;
+ case RTC_EPOCH_READ: /* read epoch */
+ ret = put_user(EPOCH, (unsigned long *) arg);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+ spin_unlock_irq(&at91_rtc_lock);
+ return ret;
+}
+
+/*
+ * Provide RTC information in /proc/driver/rtc
+ */
+static int at91_rtc_read_proc(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ char *p = page;
+ int len;
+ struct rtc_time tm;
+
+ at91_rtc_decodetime(&(AT91_SYS->RTC_TIMR), &(AT91_SYS->RTC_CALR), &tm);
+ p += sprintf(p, "rtc_time\t: %02d:%02d:%02d\n"
+ "rtc_date\t: %04d-%02d-%02d\n"
+ "rtc_epoch\t: %04d\n",
+ tm.tm_hour, tm.tm_min, tm.tm_sec,
+ tm.tm_year, tm.tm_mon + 1, tm.tm_mday, EPOCH);
+ at91_rtc_decodetime(&(AT91_SYS->RTC_TIMALR), &(AT91_SYS->RTC_CALALR), &tm);
+ p += sprintf(p, "alrm_time\t: %02d:%02d:%02d\n"
+ "alrm_date\t: %04d-%02d-%02d\n",
+ tm.tm_hour, tm.tm_min, tm.tm_sec,
+ at91_alarm_year, tm.tm_mon + 1, tm.tm_mday);
+ p += sprintf(p, "alarm_IRQ\t: %s\n", (AT91_SYS->RTC_IMR & AT91C_RTC_ALARM) ? "yes" : "no");
+ p += sprintf(p, "update_IRQ\t: %s\n", (AT91_SYS->RTC_IMR & AT91C_RTC_ACKUPD) ? "yes" : "no");
+ p += sprintf(p, "periodic_IRQ\t: %s\n", (AT91_SYS->RTC_IMR & AT91C_RTC_SECEV) ? "yes" : "no");
+ p += sprintf(p, "periodic_freq\t: %ld\n", (unsigned long) AT91_RTC_FREQ);
+
+ len = (p - page) - off;
+ if (len < 0)
+ len = 0;
+
+ *eof = (len <= count) ? 1 : 0;
+ *start = page + off;
+
+ return len;
+}
+
+static struct file_operations at91_rtc_fops = {
+ owner:THIS_MODULE,
+ llseek:no_llseek,
+ read:at91_rtc_read,
+ poll:at91_rtc_poll,
+ ioctl:at91_rtc_ioctl,
+ open:at91_rtc_open,
+ release:at91_rtc_release,
+ fasync:at91_rtc_fasync,
+};
+
+static struct miscdevice at91_rtc_miscdev = {
+ minor:RTC_MINOR,
+ name:"rtc",
+ fops:&at91_rtc_fops,
+};
+
+/*
+ * Initialize and install RTC driver
+ */
+static int __init at91_rtc_init(void)
+{
+ int ret;
+
+ AT91_SYS->RTC_CR = 0;
+ AT91_SYS->RTC_MR = 0; /* put in 24 hour format */
+ /* Disable all interrupts */
+ AT91_SYS->RTC_IDR = AT91C_RTC_ACKUPD | AT91C_RTC_ALARM | AT91C_RTC_SECEV | AT91C_RTC_TIMEV | AT91C_RTC_CALEV;
+
+ spin_lock_init(&at91_rtc_updlock);
+ spin_lock_init(&at91_rtc_lock);
+
+ misc_register(&at91_rtc_miscdev);
+ create_proc_read_entry("driver/rtc", 0, 0, at91_rtc_read_proc, NULL);
+ ret = request_irq(AT91C_ID_SYS, at91_rtc_interrupt, SA_SHIRQ,
+ "at91_rtc", &rtc_status);
+ if (ret) {
+ printk(KERN_ERR "at91_rtc: IRQ %d already in use.\n", AT91C_ID_SYS);
+ remove_proc_entry("driver/rtc", NULL);
+ misc_deregister(&at91_rtc_miscdev);
+ return ret;
+ }
+
+ printk(KERN_INFO "AT91 Real Time Clock driver\n");
+ return 0;
+}
+
+/*
+ * Disable and remove the RTC driver
+ */
+static void __exit at91_rtc_exit(void)
+{
+ /* Disable all interrupts */
+ AT91_SYS->RTC_IDR = AT91C_RTC_ACKUPD | AT91C_RTC_ALARM | AT91C_RTC_SECEV | AT91C_RTC_TIMEV | AT91C_RTC_CALEV;
+ free_irq(AT91C_ID_SYS, &rtc_status);
+
+ rtc_status = 0;
+ remove_proc_entry("driver/rtc", NULL);
+ misc_deregister(&at91_rtc_miscdev);
+}
+
+module_init(at91_rtc_init);
+module_exit(at91_rtc_exit);
+
+MODULE_AUTHOR("Rick Bronson");
+MODULE_DESCRIPTION("AT91 Realtime Clock Driver (AT91_RTC)");
+MODULE_LICENSE("GPL");
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/at91/serial/Makefile linux-2.4.26-vrs1/drivers/at91/serial/Makefile
--- linux-2.4.26/drivers/at91/serial/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/serial/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,15 @@
+# File: drivers/at91/serial/Makefile
+#
+# Makefile for the Atmel AT91RM9200 serial and console device drivers
+#
+
+O_TARGET := at91serial.o
+
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_SERIAL_AT91) += at91_serial.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/at91/serial/at91_serial.c linux-2.4.26-vrs1/drivers/at91/serial/at91_serial.c
--- linux-2.4.26/drivers/at91/serial/at91_serial.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/serial/at91_serial.c 2004-04-09 15:12:35.000000000 +0100
@@ -0,0 +1,870 @@
+/*
+ * linux/drivers/char/at91_serial.c
+ *
+ * Driver for Atmel AT91RM9200 Serial ports
+ *
+ * Copyright (c) Rick Bronson
+ *
+ * Based on drivers/char/serial_sa1100.c, by Deep Blue Solutions Ltd.
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * 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
+ *
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/tty.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/serial.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+
+#include <asm/arch/AT91RM9200_USART.h>
+#include <asm/mach/serial_at91rm9200.h>
+#include <asm/arch/pio.h>
+
+
+#if defined(CONFIG_SERIAL_AT91_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/serial_core.h>
+
+#define SERIAL_AT91_MAJOR TTY_MAJOR
+#define CALLOUT_AT91_MAJOR TTYAUX_MAJOR
+#define MINOR_START 64
+
+#define AT91C_VA_BASE_DBGU ((unsigned long) &(AT91_SYS->DBGU_CR))
+#define AT91_ISR_PASS_LIMIT 256
+
+#define UART_PUT_CR(port,v) ((AT91PS_USART)(port)->membase)->US_CR = v
+#define UART_GET_MR(port) ((AT91PS_USART)(port)->membase)->US_MR
+#define UART_PUT_MR(port,v) ((AT91PS_USART)(port)->membase)->US_MR = v
+#define UART_PUT_IER(port,v) ((AT91PS_USART)(port)->membase)->US_IER = v
+#define UART_PUT_IDR(port,v) ((AT91PS_USART)(port)->membase)->US_IDR = v
+#define UART_GET_IMR(port) ((AT91PS_USART)(port)->membase)->US_IMR
+#define UART_GET_CSR(port) ((AT91PS_USART)(port)->membase)->US_CSR
+#define UART_GET_CHAR(port) ((AT91PS_USART)(port)->membase)->US_RHR
+#define UART_PUT_CHAR(port,v) ((AT91PS_USART)(port)->membase)->US_THR = v
+#define UART_GET_BRGR(port) ((AT91PS_USART)(port)->membase)->US_BRGR
+#define UART_PUT_BRGR(port,v) ((AT91PS_USART)(port)->membase)->US_BRGR = v
+#define UART_PUT_RTOR(port,v) ((AT91PS_USART)(port)->membase)->US_RTOR = v
+
+// #define UART_GET_CR(port) ((AT91PS_USART)(port)->membase)->US_CR // is write-only
+
+ /* PDC registers */
+#define UART_PUT_PTCR(port,v) ((AT91PS_USART)(port)->membase)->US_PTCR = v
+#define UART_PUT_RPR(port,v) ((AT91PS_USART)(port)->membase)->US_RPR = v
+#define UART_PUT_RCR(port,v) ((AT91PS_USART)(port)->membase)->US_RCR = v
+#define UART_GET_RCR(port) ((AT91PS_USART)(port)->membase)->US_RCR
+#define UART_PUT_RNPR(port,v) ((AT91PS_USART)(port)->membase)->US_RNPR = v
+#define UART_PUT_RNCR(port,v) ((AT91PS_USART)(port)->membase)->US_RNCR = v
+
+static struct tty_driver normal, callout;
+static struct tty_struct *at91_table[AT91C_NR_UART];
+static struct termios *at91_termios[AT91C_NR_UART], *at91_termios_locked[AT91C_NR_UART];
+
+const int at91_serialmap[AT91C_NR_UART] = AT91C_UART_MAP;
+
+static int (*at91_open)(struct uart_port *);
+static void (*at91_close)(struct uart_port *);
+
+#ifdef SUPPORT_SYSRQ
+static struct console at91_console;
+#endif
+
+/*
+ * Return TIOCSER_TEMT when transmitter FIFO and Shift register is empty.
+ */
+static u_int at91_tx_empty(struct uart_port *port)
+{
+ return UART_GET_CSR(port) & AT91C_US_TXEMPTY ? TIOCSER_TEMT : 0;
+}
+
+/*
+ * Set state of the modem control output lines
+ */
+static void at91_set_mctrl(struct uart_port *port, u_int mctrl)
+{
+ unsigned int control = 0;
+
+ if (mctrl & TIOCM_RTS)
+ control |= AT91C_US_RTSEN;
+ else
+ control |= AT91C_US_RTSDIS;
+
+ if (mctrl & TIOCM_DTR)
+ control |= AT91C_US_DTREN;
+ else
+ control |= AT91C_US_DTRDIS;
+
+ UART_PUT_CR(port,control);
+}
+
+/*
+ * Get state of the modem control input lines
+ */
+static u_int at91_get_mctrl(struct uart_port *port)
+{
+ unsigned int status, ret = 0;
+
+ status = UART_GET_CSR(port);
+ if (status & AT91C_US_DCD)
+ ret |= TIOCM_CD;
+ if (status & AT91C_US_CTS)
+ ret |= TIOCM_CTS;
+ if (status & AT91C_US_DSR)
+ ret |= TIOCM_DSR;
+ if (status & AT91C_US_RI)
+ ret |= TIOCM_RI;
+
+ return ret;
+}
+
+/*
+ * Stop transmitting.
+ */
+static void at91_stop_tx(struct uart_port *port, u_int from_tty)
+{
+ UART_PUT_IDR(port, AT91C_US_TXRDY);
+ port->read_status_mask &= ~AT91C_US_TXRDY;
+}
+
+/*
+ * Start transmitting.
+ */
+static void at91_start_tx(struct uart_port *port, u_int from_tty)
+{
+ unsigned long flags;
+
+ local_irq_save(flags);
+ port->read_status_mask |= AT91C_US_TXRDY;
+ UART_PUT_IER(port, AT91C_US_TXRDY);
+ local_irq_restore(flags);
+}
+
+/*
+ * Stop receiving - port is in process of being closed.
+ */
+static void at91_stop_rx(struct uart_port *port)
+{
+ UART_PUT_IDR(port, AT91C_US_RXRDY);
+}
+
+/*
+ * Enable modem status interrupts
+ */
+static void at91_enable_ms(struct uart_port *port)
+{
+ UART_PUT_IER(port, AT91C_US_RIIC | AT91C_US_DSRIC | AT91C_US_DCDIC | AT91C_US_CTSIC);
+}
+
+/*
+ * Control the transmission of a break signal
+ */
+static void at91_break_ctl(struct uart_port *port, int break_state)
+{
+ if (break_state != 0)
+ UART_PUT_CR(port, AT91C_US_STTBRK); /* start break */
+ else
+ UART_PUT_CR(port, AT91C_US_STPBRK); /* stop break */
+}
+
+/*
+ * Characters received (called from interrupt handler)
+ */
+static void at91_rx_chars(struct uart_port *port, struct pt_regs *regs)
+{
+ struct uart_info *info = port->info;
+ struct tty_struct *tty = info->tty;
+ unsigned int status, ch, flg, ignored = 0;
+
+ status = UART_GET_CSR(port);
+ while (status & (AT91C_US_RXRDY)) {
+ ch = UART_GET_CHAR(port);
+
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+ goto ignore_char;
+ port->icount.rx++;
+
+ flg = TTY_NORMAL;
+
+ /*
+ * note that the error handling code is
+ * out of the main execution path
+ */
+ if (status & (AT91C_US_PARE | AT91C_US_FRAME | AT91C_US_OVRE))
+ 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_CSR(port);
+ }
+out:
+ tty_flip_buffer_push(tty);
+ return;
+
+handle_error:
+ if (status & (AT91C_US_PARE | AT91C_US_FRAME | AT91C_US_OVRE))
+ UART_PUT_CR(port, AT91C_US_RSTSTA); /* clear error */
+ if (status & (AT91C_US_PARE))
+ port->icount.parity++;
+ else if (status & (AT91C_US_FRAME))
+ port->icount.frame++;
+ if (status & (AT91C_US_OVRE))
+ port->icount.overrun++;
+
+ if (status & port->ignore_status_mask) {
+ if (++ignored > 100)
+ goto out;
+ goto ignore_char;
+ }
+
+ status &= port->read_status_mask;
+
+ UART_PUT_CR(port, AT91C_US_RSTSTA); /* clear error */
+ if (status & AT91C_US_PARE)
+ flg = TTY_PARITY;
+ else if (status & AT91C_US_FRAME)
+ flg = TTY_FRAME;
+
+ if (status & AT91C_US_OVRE) {
+ /*
+ * overrun does *not* affect the character
+ * we read from the FIFO
+ */
+ *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;
+}
+
+/*
+ * Transmit characters (called from interrupt handler)
+ */
+static void at91_tx_chars(struct uart_port *port)
+{
+ struct circ_buf *xmit = &port->info->xmit;
+
+ if (port->x_char) {
+ UART_PUT_CHAR(port, port->x_char);
+ port->icount.tx++;
+ port->x_char = 0;
+ return;
+ }
+ if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
+ at91_stop_tx(port, 0);
+ return;
+ }
+
+ while (UART_GET_CSR(port) & AT91C_US_TXRDY) {
+ 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;
+ }
+
+ if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+ uart_write_wakeup(port);
+
+ if (uart_circ_empty(xmit))
+ at91_stop_tx(port, 0);
+}
+
+/*
+ * Interrupt handler
+ */
+static void at91_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct uart_port *port = dev_id;
+ unsigned int status, pending, pass_counter = 0;
+
+ status = UART_GET_CSR(port);
+ pending = status & port->read_status_mask;
+ if (pending) {
+ do {
+ if (pending & AT91C_US_RXRDY)
+ at91_rx_chars(port, regs);
+
+ /* Clear the relevent break bits */
+ if (pending & AT91C_US_RXBRK) {
+ UART_PUT_CR(port, AT91C_US_RSTSTA);
+ port->icount.brk++;
+#ifdef SUPPORT_SYSRQ
+ if (port->line == at91_console.index && !port->sysrq) {
+ port->sysrq = jiffies + HZ*5;
+ }
+#endif
+ }
+
+ // TODO: All reads to CSR will clear these interrupts!
+ if (pending & AT91C_US_RIIC) port->icount.rng++;
+ if (pending & AT91C_US_DSRIC) port->icount.dsr++;
+ if (pending & AT91C_US_DCDIC) {
+ port->icount.dcd++;
+ uart_handle_dcd_change(port, status & AT91C_US_DCD);
+ }
+ if (pending & AT91C_US_CTSIC) {
+ port->icount.cts++;
+ uart_handle_cts_change(port, status & AT91C_US_CTS);
+ }
+ if (pending & (AT91C_US_RIIC | AT91C_US_DSRIC | AT91C_US_DCDIC | AT91C_US_CTSIC))
+ wake_up_interruptible(&port->info->delta_msr_wait);
+
+ if (pending & AT91C_US_TXRDY)
+ at91_tx_chars(port);
+ if (pass_counter++ > AT91_ISR_PASS_LIMIT)
+ break;
+
+ status = UART_GET_CSR(port);
+ pending = status & port->read_status_mask;
+ } while (pending);
+ }
+}
+
+/*
+ * Perform initialization and enable port for reception
+ */
+static int at91_startup(struct uart_port *port)
+{
+ int retval;
+
+ /*
+ * Allocate the IRQ
+ */
+ retval = request_irq(port->irq, at91_interrupt, SA_SHIRQ, "at91_serial", port);
+ if (retval) {
+ printk("at91_serial: at91_startup - Can't get irq\n");
+ return retval;
+ }
+ /*
+ * If there is a specific "open" function (to register
+ * control line interrupts)
+ */
+ if (at91_open) {
+ retval = at91_open(port);
+ if (retval) {
+ free_irq(port->irq, port);
+ return retval;
+ }
+ }
+
+ /* Enable peripheral clock if required */
+ if (port->irq != AT91C_ID_SYS)
+ AT91_SYS->PMC_PCER = 1 << port->irq;
+
+ port->read_status_mask = AT91C_US_RXRDY | AT91C_US_TXRDY | AT91C_US_OVRE
+ | AT91C_US_FRAME | AT91C_US_PARE | AT91C_US_RXBRK;
+ /*
+ * Finally, clear and enable interrupts
+ */
+ UART_PUT_IDR(port, -1);
+ UART_PUT_CR(port, AT91C_US_TXEN | AT91C_US_RXEN); /* enable xmit & rcvr */
+ UART_PUT_IER(port, AT91C_US_RXRDY); /* do receive only */
+ return 0;
+}
+
+/*
+ * Disable the port
+ */
+static void at91_shutdown(struct uart_port *port)
+{
+ /*
+ * Free the interrupt
+ */
+ free_irq(port->irq, port);
+
+ /*
+ * If there is a specific "close" function (to unregister
+ * control line interrupts)
+ */
+ if (at91_close)
+ at91_close(port);
+
+ /*
+ * Disable all interrupts, port and break condition.
+ */
+ UART_PUT_CR(port, AT91C_US_RSTSTA);
+ UART_PUT_IDR(port, -1);
+
+ /* Disable peripheral clock if required */
+ if (port->irq != AT91C_ID_SYS)
+ AT91_SYS->PMC_PCDR = 1 << port->irq;
+}
+
+static struct uart_ops at91_pops; /* forward declaration */
+
+/*
+ * Change the port parameters
+ */
+static void at91_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
+{
+ unsigned long flags;
+ unsigned int mode, imr;
+
+ /* Get current mode register */
+ mode = UART_GET_MR(port) & ~(AT91C_US_CHRL | AT91C_US_NBSTOP | AT91C_US_PAR);
+
+ /* byte size */
+ switch (cflag & CSIZE) {
+ case CS5:
+ mode |= AT91C_US_CHRL_5_BITS;
+ break;
+ case CS6:
+ mode |= AT91C_US_CHRL_6_BITS;
+ break;
+ case CS7:
+ mode |= AT91C_US_CHRL_7_BITS;
+ break;
+ default:
+ mode |= AT91C_US_CHRL_8_BITS;
+ break;
+ }
+
+ /* stop bits */
+ if (cflag & CSTOPB)
+ mode |= AT91C_US_NBSTOP_2_BIT;
+
+ /* parity */
+ if (cflag & PARENB) {
+ if (cflag & CMSPAR) { /* Mark or Space parity */
+ if (cflag & PARODD)
+ mode |= AT91C_US_PAR_MARK;
+ else
+ mode |= AT91C_US_PAR_SPACE;
+ }
+ else if (cflag & PARODD)
+ mode |= AT91C_US_PAR_ODD;
+ else
+ mode |= AT91C_US_PAR_EVEN;
+ }
+ else
+ mode |= AT91C_US_PAR_NONE;
+
+ port->read_status_mask |= AT91C_US_OVRE;
+ if (iflag & INPCK)
+ port->read_status_mask |= AT91C_US_FRAME | AT91C_US_PARE;
+ if (iflag & (BRKINT | PARMRK))
+ port->read_status_mask |= AT91C_US_RXBRK;
+
+ /*
+ * Characters to ignore
+ */
+ port->ignore_status_mask = 0;
+ if (iflag & IGNPAR)
+ port->ignore_status_mask |= (AT91C_US_FRAME | AT91C_US_PARE);
+ if (iflag & IGNBRK) {
+ port->ignore_status_mask |= AT91C_US_RXBRK;
+ /*
+ * If we're ignoring parity and break indicators,
+ * ignore overruns too (for real raw support).
+ */
+ if (iflag & IGNPAR)
+ port->ignore_status_mask |= AT91C_US_OVRE;
+ }
+
+ // TODO: Ignore all characters if CREAD is set.
+
+ /* first, disable interrupts and drain transmitter */
+ local_irq_save(flags);
+ imr = UART_GET_IMR(port); /* get interrupt mask */
+ UART_PUT_IDR(port, -1); /* disable all interrupts */
+ local_irq_restore(flags);
+ while (!(UART_GET_CSR(port) & AT91C_US_TXEMPTY)) { barrier(); }
+
+ /* disable receiver and transmitter */
+ UART_PUT_CR(port, AT91C_US_TXDIS | AT91C_US_RXDIS);
+
+ /* set the parity, stop bits and data size */
+ UART_PUT_MR(port, mode);
+
+ /* set the baud rate */
+ UART_PUT_BRGR(port, quot);
+ UART_PUT_CR(port, AT91C_US_TXEN | AT91C_US_RXEN);
+
+ /* restore interrupts */
+ UART_PUT_IER(port, imr);
+
+ /* CTS flow-control and modem-status interrupts */
+ if (UART_ENABLE_MS(port, cflag))
+ at91_pops.enable_ms(port);
+}
+
+/*
+ * Return string describing the specified port
+ */
+static const char *at91_type(struct uart_port *port)
+{
+ return port->type == PORT_AT91RM9200 ? "AT91_SERIAL" : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'.
+ */
+static void at91_release_port(struct uart_port *port)
+{
+ release_mem_region(port->mapbase,
+ port->mapbase == AT91C_VA_BASE_DBGU ? 512 : SZ_16K);
+}
+
+/*
+ * Request the memory region(s) being used by 'port'.
+ */
+static int at91_request_port(struct uart_port *port)
+{
+ return request_mem_region(port->mapbase,
+ port->mapbase == AT91C_VA_BASE_DBGU ? 512 : SZ_16K,
+ "at91_serial") != NULL ? 0 : -EBUSY;
+
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void at91_config_port(struct uart_port *port, int flags)
+{
+ if (flags & UART_CONFIG_TYPE) {
+ port->type = PORT_AT91RM9200;
+ at91_request_port(port);
+ }
+}
+
+/*
+ * Verify the new serial_struct (for TIOCSSERIAL).
+ */
+static int at91_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+ int ret = 0;
+ if (ser->type != PORT_UNKNOWN && ser->type != PORT_AT91RM9200)
+ ret = -EINVAL;
+ if (port->irq != ser->irq)
+ ret = -EINVAL;
+ if (ser->io_type != SERIAL_IO_MEM)
+ ret = -EINVAL;
+ if (port->uartclk / 16 != ser->baud_base)
+ ret = -EINVAL;
+ if ((void *)port->mapbase != ser->iomem_base)
+ ret = -EINVAL;
+ if (port->iobase != ser->port)
+ ret = -EINVAL;
+ if (ser->hub6 != 0)
+ ret = -EINVAL;
+ return ret;
+}
+
+static struct uart_ops at91_pops = {
+ tx_empty: at91_tx_empty,
+ set_mctrl: at91_set_mctrl,
+ get_mctrl: at91_get_mctrl,
+ stop_tx: at91_stop_tx,
+ start_tx: at91_start_tx,
+ stop_rx: at91_stop_rx,
+ enable_ms: at91_enable_ms,
+ break_ctl: at91_break_ctl,
+ startup: at91_startup,
+ shutdown: at91_shutdown,
+ change_speed: at91_change_speed,
+ type: at91_type,
+ release_port: at91_release_port,
+ request_port: at91_request_port,
+ config_port: at91_config_port,
+ verify_port: at91_verify_port,
+};
+
+static struct uart_port at91_ports[AT91C_NR_UART];
+
+void __init at91_init_ports(void)
+{
+ static int first = 1;
+ int i;
+
+ if (!first)
+ return;
+ first = 0;
+
+ for (i = 0; i < AT91C_NR_UART; i++) {
+ at91_ports[i].iotype = SERIAL_IO_MEM;
+ at91_ports[i].flags = ASYNC_BOOT_AUTOCONF;
+ at91_ports[i].uartclk = AT91C_MASTER_CLOCK;
+ at91_ports[i].ops = &at91_pops;
+ at91_ports[i].fifosize = 1;
+ at91_ports[i].line = i;
+ }
+}
+
+void __init at91_register_uart_fns(struct at91rm9200_port_fns *fns)
+{
+ if (fns->enable_ms)
+ at91_pops.enable_ms = fns->enable_ms;
+ if (fns->get_mctrl)
+ at91_pops.get_mctrl = fns->get_mctrl;
+ if (fns->set_mctrl)
+ at91_pops.set_mctrl = fns->set_mctrl;
+ at91_open = fns->open;
+ at91_close = fns->close;
+ at91_pops.pm = fns->pm;
+ at91_pops.set_wake = fns->set_wake;
+}
+
+/*
+ * Setup ports.
+ */
+void __init at91_register_uart(int idx, int port)
+{
+ if ((idx < 0) || (idx >= AT91C_NR_UART)) {
+ printk(KERN_ERR __FUNCTION__ ": bad index number %d\n", idx);
+ return;
+ }
+
+ switch (port) {
+ case 0:
+ at91_ports[idx].membase = (void *) AT91C_VA_BASE_US0;
+ at91_ports[idx].mapbase = AT91C_VA_BASE_US0;
+ at91_ports[idx].irq = AT91C_ID_US0;
+ AT91_CfgPIO_USART0();
+ break;
+ case 1:
+ at91_ports[idx].membase = (void *) AT91C_VA_BASE_US1;
+ at91_ports[idx].mapbase = AT91C_VA_BASE_US1;
+ at91_ports[idx].irq = AT91C_ID_US1;
+ AT91_CfgPIO_USART1();
+ break;
+ case 2:
+ at91_ports[idx].membase = (void *) AT91C_VA_BASE_US2;
+ at91_ports[idx].mapbase = AT91C_VA_BASE_US2;
+ at91_ports[idx].irq = AT91C_ID_US2;
+ AT91_CfgPIO_USART2();
+ break;
+ case 3:
+ at91_ports[idx].membase = (void *) AT91C_VA_BASE_US3;
+ at91_ports[idx].mapbase = AT91C_VA_BASE_US3;
+ at91_ports[idx].irq = AT91C_ID_US3;
+ AT91_CfgPIO_USART3();
+ break;
+ case 4:
+ at91_ports[idx].membase = (void *) AT91C_VA_BASE_DBGU;
+ at91_ports[idx].mapbase = AT91C_VA_BASE_DBGU;
+ at91_ports[idx].irq = AT91C_ID_SYS;
+ AT91_CfgPIO_DBGU();
+ break;
+ default:
+ printk(KERN_ERR __FUNCTION__ ": bad port number %d\n", port);
+ }
+}
+
+#ifdef CONFIG_SERIAL_AT91_CONSOLE
+
+/*
+ * Interrupts are disabled on entering
+ */
+static void at91_console_write(struct console *co, const char *s, u_int count)
+{
+ struct uart_port *port = at91_ports + co->index;
+ unsigned int status, i, imr;
+
+ /*
+ * First, save IMR and then disable interrupts
+ */
+ imr = UART_GET_IMR(port); /* get interrupt mask */
+ UART_PUT_IDR(port, AT91C_US_RXRDY | AT91C_US_TXRDY);
+
+ /*
+ * Now, do each character
+ */
+ for (i = 0; i < count; i++) {
+ do {
+ status = UART_GET_CSR(port);
+ } while (!(status & AT91C_US_TXRDY));
+ UART_PUT_CHAR(port, s[i]);
+ if (s[i] == '\n') {
+ do {
+ status = UART_GET_CSR(port);
+ } while (!(status & AT91C_US_TXRDY));
+ UART_PUT_CHAR(port, '\r');
+ }
+ }
+
+ /*
+ * Finally, wait for transmitter to become empty
+ * and restore IMR
+ */
+ do {
+ status = UART_GET_CSR(port);
+ } while (status & AT91C_US_TXRDY);
+ UART_PUT_IER(port, imr); /* set interrupts back the way they were */
+}
+
+static kdev_t at91_console_device(struct console *co)
+{
+ return MKDEV(SERIAL_AT91_MAJOR, MINOR_START + co->index);
+}
+
+/*
+ * If the port was already initialised (eg, by a boot loader), try to determine
+ * the current setup.
+ */
+static void __init at91_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
+{
+ unsigned int mr, quot;
+
+// TODO: CR is a write-only register
+// unsigned int cr;
+//
+// cr = UART_GET_CR(port) & (AT91C_US_RXEN | AT91C_US_TXEN);
+// if (cr == (AT91C_US_RXEN | AT91C_US_TXEN)) {
+// /* ok, the port was enabled */
+//
+// mr = UART_GET_MR(port) & AT91C_US_PAR;
+//
+// *parity = 'n';
+// if (mr == AT91C_US_PAR_EVEN)
+// *parity = 'e';
+// else if (mr == AT91C_US_PAR_ODD)
+// *parity = 'o';
+// }
+
+ mr = UART_GET_MR(port) & AT91C_US_CHRL;
+ if (mr == AT91C_US_CHRL_8_BITS)
+ *bits = 8;
+ else
+ *bits = 7;
+
+ quot = UART_GET_BRGR(port);
+ *baud = port->uartclk / (16 * (quot));
+}
+
+static int __init at91_console_setup(struct console *co, char *options)
+{
+ struct uart_port *port;
+ int baud = AT91C_CONSOLE_DEFAULT_BAUDRATE;
+ int bits = 8;
+ int parity = 'n';
+ int flow = 'n';
+
+ /*
+ * 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(at91_ports, AT91C_NR_UART, co);
+
+ // TODO: The console port should be initialized, and clock enabled if
+ // we're not relying on the bootloader to do it.
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+ else
+ at91_console_get_options(port, &baud, &parity, &bits);
+
+ return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct console at91_console = {
+ name: "ttyS",
+ write: at91_console_write,
+ device: at91_console_device,
+ setup: at91_console_setup,
+ flags: CON_PRINTBUFFER,
+ index: AT91C_CONSOLE,
+};
+
+#define AT91_CONSOLE_DEVICE &at91_console
+
+void __init at91_console_init(void)
+{
+ at91_init_ports();
+ register_console(&at91_console);
+}
+
+#else
+#define AT91_CONSOLE_DEVICE NULL
+#endif
+
+static struct uart_driver at91_reg = {
+ owner: THIS_MODULE,
+ normal_major: SERIAL_AT91_MAJOR,
+#ifdef CONFIG_DEVFS_FS
+ normal_name: "ttyS%d",
+ callout_name: "cua%d",
+#else
+ normal_name: "ttyS",
+ callout_name: "cua",
+#endif
+ normal_driver: &normal,
+ callout_major: CALLOUT_AT91_MAJOR,
+ callout_driver: &callout,
+ table: at91_table,
+ termios: at91_termios,
+ termios_locked: at91_termios_locked,
+ minor: MINOR_START,
+ nr: AT91C_NR_UART,
+ cons: AT91_CONSOLE_DEVICE,
+};
+
+static int __init at91_serial_init(void)
+{
+ int ret, i;
+
+ at91_init_ports();
+
+ ret = uart_register_driver(&at91_reg);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < AT91C_NR_UART; i++) {
+ if (at91_serialmap[i] >= 0)
+ uart_add_one_port(&at91_reg, &at91_ports[i]);
+ }
+
+ return 0;
+}
+
+static void __exit at91_serial_exit(void)
+{
+ int i;
+
+ for (i = 0; i < AT91C_NR_UART; i++) {
+ if (at91_serialmap[i] >= 0)
+ uart_remove_one_port(&at91_reg, &at91_ports[i]);
+ }
+
+ uart_unregister_driver(&at91_reg);
+}
+
+module_init(at91_serial_init);
+module_exit(at91_serial_exit);
+
+EXPORT_NO_SYMBOLS;
+
+MODULE_AUTHOR("Rick Bronson");
+MODULE_DESCRIPTION("AT91 generic serial port driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/at91/spi/Makefile linux-2.4.26-vrs1/drivers/at91/spi/Makefile
--- linux-2.4.26/drivers/at91/spi/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/spi/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,17 @@
+# File: drivers/at91/spi/Makefile
+#
+# Makefile for the Atmel AT91RM9200 SPI device drivers
+#
+
+O_TARGET := at91spi.o
+
+export-objs := at91_spi.o
+
+obj-y := at91_spi.o
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_AT91_SPIDEV) += at91_spidev.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/at91/spi/at91_spi.c linux-2.4.26-vrs1/drivers/at91/spi/at91_spi.c
--- linux-2.4.26/drivers/at91/spi/at91_spi.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/spi/at91_spi.c 2004-04-10 12:23:48.000000000 +0100
@@ -0,0 +1,275 @@
+/*
+ * Serial Peripheral Interface (SPI) driver for the Atmel AT91RM9200 (Thunder)
+ *
+ * (c) SAN People (Pty) Ltd
+ *
+ * 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.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <asm/semaphore.h>
+#include <linux/pci.h>
+#include <linux/sched.h>
+#include <linux/completion.h>
+
+#include <asm/arch/AT91RM9200_SPI.h>
+#include <asm/arch/pio.h>
+#include "at91_spi.h"
+
+#undef DEBUG_SPI
+
+static struct spi_local spi_dev[NR_SPI_DEVICES]; /* state of the SPI devices */
+static int spi_enabled = 0;
+static struct semaphore spi_lock; /* protect access to SPI bus */
+static int current_device = -1; /* currently selected SPI device */
+
+DECLARE_COMPLETION(transfer_complete);
+
+/* SPI controller device */
+static AT91PS_SPI controller = (AT91PS_SPI) AT91C_VA_BASE_SPI;
+
+/* ......................................................................... */
+
+/*
+ * Access and enable the SPI bus.
+ * This MUST be called before any transfers are performed.
+ */
+void spi_access_bus(short device)
+{
+ /* Ensure that requested device is valid */
+ if ((device < 0) || (device >= NR_SPI_DEVICES))
+ panic("at91_spi: spi_access_bus called with invalid device");
+
+ if (spi_enabled == 0) {
+ AT91_SYS->PMC_PCER = 1 << AT91C_ID_SPI; /* Enable Peripheral clock */
+ controller->SPI_CR = AT91C_SPI_SPIEN; /* Enable SPI */
+#ifdef DEBUG_SPI
+ printk("SPI on\n");
+#endif
+ }
+ MOD_INC_USE_COUNT;
+ spi_enabled++;
+
+ /* Lock the SPI bus */
+ down(&spi_lock);
+ current_device = device;
+
+ /* Enable PIO */
+ if (!spi_dev[device].pio_enabled) {
+ switch (device) {
+ case 0: AT91_CfgPIO_SPI_CS0();
+ case 1: AT91_CfgPIO_SPI_CS1();
+ case 2: AT91_CfgPIO_SPI_CS2();
+ case 3: AT91_CfgPIO_SPI_CS3();
+ }
+ spi_dev[device].pio_enabled = 1;
+#ifdef DEBUG_SPI
+ printk("SPI CS%i enabled\n", device);
+#endif
+ }
+
+ /* Configure SPI bus for device */
+ controller->SPI_MR = AT91C_SPI_MSTR | AT91C_SPI_MODFDIS | (spi_dev[device].pcs << 16);
+}
+
+/*
+ * Relinquish control of the SPI bus.
+ */
+void spi_release_bus(short device)
+{
+ if (device != current_device)
+ panic("at91_spi: spi_release called with invalid device");
+
+ /* Release the SPI bus */
+ current_device = -1;
+ up(&spi_lock);
+
+ spi_enabled--;
+ MOD_DEC_USE_COUNT;
+ if (spi_enabled == 0) {
+ controller->SPI_CR = AT91C_SPI_SPIDIS; /* Disable SPI */
+ AT91_SYS->PMC_PCER = 1 << AT91C_ID_SPI; /* Disable Peripheral clock */
+#ifdef DEBUG_SPI
+ printk("SPI off\n");
+#endif
+ }
+}
+
+/*
+ * Perform a data transfer over the SPI bus
+ */
+int spi_transfer(struct spi_transfer_list* list)
+{
+ struct spi_local *device = (struct spi_local *) &spi_dev[current_device];
+
+ if (!list)
+ panic("at91_spi: spi_transfer called with NULL transfer list");
+ if (current_device == -1)
+ panic("at91_spi: spi_transfer called without acquiring bus");
+
+#ifdef DEBUG_SPI
+ printk("SPI transfer start [%i]\n", list->nr_transfers);
+#endif
+
+ /* Store transfer list */
+ device->xfers = list;
+ list->curr = 0;
+
+ /* Assume there must be at least one transfer */
+ device->tx = pci_map_single(NULL, list->tx[0], list->txlen[0], PCI_DMA_TODEVICE);
+ device->rx = pci_map_single(NULL, list->rx[0], list->rxlen[0], PCI_DMA_FROMDEVICE);
+
+ /* Program PDC registers */
+ controller->SPI_TPR = device->tx;
+ controller->SPI_RPR = device->rx;
+ controller->SPI_TCR = list->txlen[0];
+ controller->SPI_RCR = list->rxlen[0];
+
+ /* Is there a second transfer? */
+ if (list->nr_transfers > 1) {
+ device->txnext = pci_map_single(NULL, list->tx[1], list->txlen[1], PCI_DMA_TODEVICE);
+ device->rxnext = pci_map_single(NULL, list->rx[1], list->rxlen[1], PCI_DMA_FROMDEVICE);
+
+ /* Program Next PDC registers */
+ controller->SPI_TNPR = device->txnext;
+ controller->SPI_RNPR = device->rxnext;
+ controller->SPI_TNCR = list->txlen[1];
+ controller->SPI_RNCR = list->rxlen[1];
+ }
+ else {
+ device->txnext = 0;
+ device->rxnext = 0;
+ controller->SPI_TNCR = 0;
+ controller->SPI_RNCR = 0;
+ }
+
+ // TODO: If we are doing consecutive transfers (at high speed, or
+ // small buffers), then it might be worth modifying the 'Delay between
+ // Consecutive Transfers' in the CSR registers.
+ // This is an issue if we cannot chain the next buffer fast enough
+ // in the interrupt handler.
+
+ /* Enable transmitter and receiver */
+ controller->SPI_PTCR = AT91C_PDC_RXTEN | AT91C_PDC_TXTEN;
+
+ controller->SPI_IER = AT91C_SPI_SPENDRX; /* enable buffer complete interrupt */
+ wait_for_completion(&transfer_complete);
+
+#ifdef DEBUG_SPI
+ printk("SPI transfer end\n");
+#endif
+
+ return 0;
+}
+
+/* ......................................................................... */
+
+/*
+ * Handle interrupts from the SPI controller.
+ */
+static void spi_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned int status;
+ struct spi_local *device = (struct spi_local *) &spi_dev[current_device];
+ struct spi_transfer_list *list = device->xfers;
+
+#ifdef DEBUG_SPI
+ printk("SPI interrupt %i\n", current_device);
+#endif
+
+ if (!list)
+ panic("at91_spi: spi_interrupt with a NULL transfer list");
+
+ status = controller->SPI_SR & controller->SPI_IMR; /* read status */
+
+ pci_unmap_single(NULL, device->tx, list->txlen[list->curr], PCI_DMA_TODEVICE);
+ pci_unmap_single(NULL, device->rx, list->rxlen[list->curr], PCI_DMA_FROMDEVICE);
+
+ device->tx = device->txnext; /* move next transfer to current transfer */
+ device->rx = device->rxnext;
+
+ list->curr = list->curr + 1;
+ if (list->curr == list->nr_transfers) { /* all transfers complete */
+ controller->SPI_IDR = AT91C_SPI_SPENDRX; /* disable interrupt */
+
+ /* Disable transmitter and receiver */
+ controller->SPI_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS;
+
+ device->xfers = NULL;
+ complete(&transfer_complete);
+ }
+ else if (list->curr+1 == list->nr_transfers) { /* no more next transfers */
+ device->txnext = 0;
+ device->rxnext = 0;
+ controller->SPI_TNCR = 0;
+ controller->SPI_RNCR = 0;
+ }
+ else {
+ int i = (list->curr)+1;
+
+ device->txnext = pci_map_single(NULL, list->tx[i], list->txlen[i], PCI_DMA_TODEVICE);
+ device->rxnext = pci_map_single(NULL, list->rx[i], list->rxlen[i], PCI_DMA_FROMDEVICE);
+ controller->SPI_TNPR = device->txnext;
+ controller->SPI_RNPR = device->rxnext;
+ controller->SPI_TNCR = list->txlen[i];
+ controller->SPI_RNCR = list->rxlen[i];
+ }
+}
+
+/* ......................................................................... */
+
+/*
+ * Initialize the SPI controller
+ */
+static int __init at91_spi_init(void)
+{
+ init_MUTEX(&spi_lock);
+
+ AT91_CfgPIO_SPI();
+
+ controller->SPI_CR = AT91C_SPI_SWRST; /* software reset of SPI controller */
+
+ /* Set Chip Select registers to good defaults */
+ controller->SPI_CSR0 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8);
+ controller->SPI_CSR1 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8);
+ controller->SPI_CSR2 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8);
+ controller->SPI_CSR3 = AT91C_SPI_CPOL | AT91C_SPI_BITS_8 | (16 << 16) | (DEFAULT_SPI_BAUD << 8);
+
+ controller->SPI_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS;
+
+ memset(&spi_dev, 0, sizeof(spi_dev));
+ spi_dev[0].pcs = 0xE;
+ spi_dev[1].pcs = 0xD;
+ spi_dev[2].pcs = 0xB;
+ spi_dev[3].pcs = 0x7;
+
+ if (request_irq(AT91C_ID_SPI, spi_interrupt, 0, "spi", NULL))
+ return -EBUSY;
+
+ controller->SPI_CR = AT91C_SPI_SPIEN; /* Enable SPI */
+
+ return 0;
+}
+
+static void at91_spi_exit(void)
+{
+ controller->SPI_CR = AT91C_SPI_SPIDIS; /* Disable SPI */
+
+ free_irq(AT91C_ID_SPI, 0);
+}
+
+
+EXPORT_SYMBOL(spi_access_bus);
+EXPORT_SYMBOL(spi_release_bus);
+EXPORT_SYMBOL(spi_transfer);
+
+module_init(at91_spi_init);
+module_exit(at91_spi_exit);
+
+MODULE_LICENSE("GPL")
+MODULE_AUTHOR("Andrew Victor")
+MODULE_DESCRIPTION("SPI driver for Atmel AT91RM9200")
diff -urN linux-2.4.26/drivers/at91/spi/at91_spi.h linux-2.4.26-vrs1/drivers/at91/spi/at91_spi.h
--- linux-2.4.26/drivers/at91/spi/at91_spi.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/spi/at91_spi.h 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,56 @@
+/*
+ * Serial Peripheral Interface (SPI) driver for the Atmel AT91RM9200
+ *
+ * (c) SAN People (Pty) Ltd
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef AT91_SPI_H
+#define AT91_SPI_H
+
+/* Maximum number of buffers in a single SPI transfer.
+ * DataFlash uses maximum of 2
+ * spidev interface supports up to 8.
+ */
+#define MAX_SPI_TRANSFERS 8
+
+#define NR_SPI_DEVICES 4 /* number of devices on SPI bus */
+
+#define DATAFLASH_CLK 6000000
+#define DEFAULT_SPI_BAUD AT91C_MASTER_CLOCK / (2 * DATAFLASH_CLK)
+
+#define SPI_MAJOR 153 /* registered device number */
+
+/*
+ * Describes the buffers for a SPI transfer.
+ * A transmit & receive buffer must be specified for each transfer
+ */
+struct spi_transfer_list {
+ void* tx[MAX_SPI_TRANSFERS]; /* transmit */
+ int txlen[MAX_SPI_TRANSFERS];
+ void* rx[MAX_SPI_TRANSFERS]; /* receive */
+ int rxlen[MAX_SPI_TRANSFERS];
+ int nr_transfers; /* number of transfers */
+ int curr; /* current transfer */
+};
+
+struct spi_local {
+ unsigned int pcs; /* Peripheral Chip Select value */
+ short pio_enabled; /* has PIO been enabled? */
+
+ struct spi_transfer_list *xfers; /* current transfer list */
+ dma_addr_t tx, rx; /* DMA address for current transfer */
+ dma_addr_t txnext, rxnext; /* DMA address for next transfer */
+};
+
+
+/* Exported functions */
+extern void spi_access_bus(short device);
+extern void spi_release_bus(short device);
+extern int spi_transfer(struct spi_transfer_list* list);
+
+#endif
diff -urN linux-2.4.26/drivers/at91/spi/at91_spidev.c linux-2.4.26-vrs1/drivers/at91/spi/at91_spidev.c
--- linux-2.4.26/drivers/at91/spi/at91_spidev.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/spi/at91_spidev.c 2004-04-10 12:23:48.000000000 +0100
@@ -0,0 +1,226 @@
+/*
+ * User-space interface to the SPI bus on Atmel AT91RM9200
+ *
+ * (c) SAN People (Pty) Ltd
+ *
+ * Based on SPI driver by Rick Bronson
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/iobuf.h>
+#include <linux/highmem.h>
+
+#ifdef CONFIG_DEVFS_FS
+#include <linux/devfs_fs_kernel.h>
+#endif
+
+#include "at91_spi.h"
+
+#undef DEBUG_SPIDEV
+
+#ifdef CONFIG_DEVFS_FS
+static devfs_handle_t devfs_handle = NULL;
+static devfs_handle_t devfs_spi[NR_SPI_DEVICES];
+#endif
+
+/* ......................................................................... */
+
+/*
+ * Read or Write to SPI bus.
+ */
+static ssize_t spidev_rd_wr(struct file *file, char *buf, size_t count, loff_t *offset)
+{
+ unsigned int spi_device = (unsigned int) file->private_data;
+ struct kiobuf *iobuf;
+ unsigned int ofs, pagelen;
+ int res, i;
+
+ struct spi_transfer_list* list = kmalloc(sizeof(struct spi_transfer_list), GFP_KERNEL);
+ if (!list)
+ return -ENOMEM;
+
+ res = alloc_kiovec(1, &iobuf);
+ if (res) {
+ kfree(list);
+ return res;
+ }
+
+ res = map_user_kiobuf(READ, iobuf, (unsigned long) buf, count);
+ if (res) {
+ free_kiovec(1, &iobuf);
+ kfree(list);
+ return res;
+ }
+
+ /* More pages than transfer slots in spi_transfer_list */
+ if (iobuf->nr_pages >= MAX_SPI_TRANSFERS) {
+ unmap_kiobuf(iobuf);
+ free_kiovec(1, &iobuf);
+ kfree(list);
+ return -EFBIG;
+ }
+
+#ifdef DEBUG_SPIDEV
+ printk("spidev_rd_rw: %i %i\n", count, iobuf->nr_pages);
+#endif
+
+ /* Set default return value = transfer length */
+ res = count;
+
+ /*
+ * At this point, the virtual area buf[0] .. buf[count-1] will have
+ * corresponding pages mapped in the physical memory and locked until
+ * we unmap the kiobuf. The pages cannot be swapped out or moved
+ * around.
+ */
+ ofs = iobuf->offset;
+ pagelen = PAGE_SIZE - iobuf->offset;
+ if (count < pagelen)
+ pagelen = count;
+
+ for (i = 0; i < iobuf->nr_pages; i++) {
+ list->tx[i] = list->rx[i] = page_address(iobuf->maplist[i]) + ofs;
+ list->txlen[i] = list->rxlen[i] = pagelen;
+
+#ifdef DEBUG_SPIDEV
+ printk(" %i: %x (%i)\n", i, list->tx[i], list->txlen[i]);
+#endif
+
+ ofs = 0; /* all subsequent transfers start at beginning of a page */
+ count = count - pagelen;
+ pagelen = (count < PAGE_SIZE) ? count : PAGE_SIZE;
+ }
+ list->nr_transfers = iobuf->nr_pages;
+
+ /* Perform transfer on SPI bus */
+ spi_access_bus(spi_device);
+ spi_transfer(list);
+ spi_release_bus(spi_device);
+
+ unmap_kiobuf(iobuf);
+ free_kiovec(1, &iobuf);
+ kfree(list);
+
+ return res;
+}
+
+static int spidev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int spi_device = MINOR(inode->i_rdev);
+
+ if (spi_device >= NR_SPI_DEVICES)
+ return -ENODEV;
+
+ // TODO: This interface can be used to configure the SPI bus.
+ // Configurable options could include: Speed, Clock Polarity, Clock Phase
+
+ switch(cmd) {
+ default:
+ return -ENOIOCTLCMD;
+ }
+}
+
+/*
+ * Open the SPI device
+ */
+static int spidev_open(struct inode *inode, struct file *file)
+{
+ unsigned int spi_device = MINOR(inode->i_rdev);
+
+ if (spi_device >= NR_SPI_DEVICES)
+ return -ENODEV;
+
+ MOD_INC_USE_COUNT;
+
+ /*
+ * 'private_data' is actually a pointer, but we overload it with the
+ * value we want to store.
+ */
+ (unsigned int) file->private_data = spi_device;
+
+ return 0;
+}
+
+/*
+ * Close the SPI device
+ */
+static int spidev_close(struct inode *inode, struct file *file)
+{
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+/* ......................................................................... */
+
+static struct file_operations spidev_fops = {
+ owner: THIS_MODULE,
+ llseek: no_llseek,
+ read: spidev_rd_wr,
+ write: spidev_rd_wr,
+ ioctl: spidev_ioctl,
+ open: spidev_open,
+ release: spidev_close,
+};
+
+/*
+ * Install the SPI /dev interface driver
+ */
+static int __init at91_spidev_init(void)
+{
+ int i;
+ char name[3];
+
+#ifdef CONFIG_DEVFS_FS
+ if (devfs_register_chrdev(SPI_MAJOR, "spi", &spidev_fops)) {
+#else
+ if (register_chrdev(SPI_MAJOR, "spi", &spidev_fops)) {
+#endif
+ printk(KERN_ERR "at91_spidev: Unable to get major %d for SPI bus\n", SPI_MAJOR);
+ return -EIO;
+ }
+
+#ifdef CONFIG_DEVFS_FS
+ devfs_handle = devfs_mk_dir(NULL, "spi", NULL);
+
+ for (i = 0; i < NR_SPI_DEVICES; i++) {
+ sprintf (name, "%d", i);
+ devfs_spi[i] = devfs_register (devfs_handle, name,
+ DEVFS_FL_DEFAULT, SPI_MAJOR, i, S_IFCHR | S_IRUSR | S_IWUSR,
+ &spidev_fops, NULL);
+ }
+#endif
+ printk(KERN_INFO "AT91 SPI driver loaded\n");
+
+ return 0;
+}
+
+/*
+ * Remove the SPI /dev interface driver
+ */
+static void __exit at91_spidev_exit(void)
+{
+#ifdef CONFIG_DEVFS_FS
+ devfs_unregister(devfs_handle);
+ if (devfs_unregister_chrdev(SPI_MAJOR, "spi")) {
+#else
+ if (unregister_chrdev(SPI_MAJOR,"spi")) {
+#endif
+ printk(KERN_ERR "at91_spidev: Unable to release major %d for SPI bus\n", SPI_MAJOR);
+ return;
+ }
+}
+
+module_init(at91_spidev_init);
+module_exit(at91_spidev_exit);
+
+MODULE_LICENSE("GPL")
+MODULE_AUTHOR("Andrew Victor")
+MODULE_DESCRIPTION("SPI /dev interface for Atmel AT91RM9200")
diff -urN linux-2.4.26/drivers/at91/usb/Makefile linux-2.4.26-vrs1/drivers/at91/usb/Makefile
--- linux-2.4.26/drivers/at91/usb/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/usb/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,17 @@
+# File: drivers/at91/usb/Makefile
+#
+# Makefile for the Atmel AT91RM9200 USB device drivers
+#
+
+O_TARGET := at91usb.o
+
+export-objs :=
+
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_USB_OHCI_AT91) += at91_usb-ohci.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/at91/usb/at91_usb-ohci.c linux-2.4.26-vrs1/drivers/at91/usb/at91_usb-ohci.c
--- linux-2.4.26/drivers/at91/usb/at91_usb-ohci.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/usb/at91_usb-ohci.c 2004-04-10 12:44:07.000000000 +0100
@@ -0,0 +1,85 @@
+/*
+ * linux/drivers/at91/usb/at91_usb_ohci-at91.c
+ *
+ * (c) Rick Bronson
+ *
+ * The outline of this code was taken from Brad Parkers <brad@heeltoe.com>
+ * original OHCI driver modifications, and reworked into a cleaner form
+ * by Russell King <rmk@arm.linux.org.uk>.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/slab.h>
+#include <linux/usb.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+
+#include <asm/arch/AT91RM9200_UHP.h>
+
+/*
+ NOTE:
+ The following is so that we don't have to include usb-ohci.h or pci.h as the
+ usb-ohci.c driver needs these routines even when the architecture
+ has no PCI bus...
+*/
+
+extern int __devinit hc_add_ohci(struct pci_dev *dev, int irq, void *membase,
+ unsigned long flags, void *ohci, const char *name,
+ const char *slot_name);
+extern void hc_remove_ohci(void *ohci);
+
+static void *at91_ohci;
+AT91PS_UHP ohci_regs;
+
+static int __init at91_ohci_init(void)
+{
+ int ret;
+
+ ohci_regs = ioremap(AT91_UHP_BASE, SZ_4K);
+ if (!ohci_regs) {
+ printk(KERN_ERR "at91_usb-ohci: ioremap failed\n");
+ return -EIO;
+ }
+
+ /* Enable PLLB */
+ AT91_SYS->CKGR_PLLBR = AT91_PLLB_INIT;
+ while ((AT91_SYS->PMC_SR & 4) == 0);
+
+ /* Now, enable the USB clock */
+ AT91_SYS->PMC_SCER = AT91C_PMC_UHP; /* enable system clock */
+ AT91_SYS->PMC_PCER = 1 << AT91C_ID_UHP; /* enable peripheral clock */
+
+ /* Take Hc out of reset */
+ ohci_regs->UHP_HcControl = 2 << 6;
+
+ /* Initialise the generic OHCI driver. */
+ ret = hc_add_ohci((struct pci_dev *) 1, AT91C_ID_UHP,
+ (void *)ohci_regs, 0, &at91_ohci,
+ "usb-ohci", "at91");
+ if (ret)
+ iounmap(ohci_regs);
+
+ return ret;
+}
+
+static void __exit at91_ohci_exit(void)
+{
+ hc_remove_ohci(at91_ohci);
+
+ /* Force UHP_Hc to reset */
+ ohci_regs->UHP_HcControl = 0;
+
+ /* Stop the USB clock. */
+ AT91_SYS->PMC_SCDR = AT91C_PMC_UHP; /* disable system clock */
+ AT91_SYS->PMC_PCDR = 1 << AT91C_ID_UHP; /* disable peripheral clock */
+
+ iounmap(ohci_regs);
+}
+
+module_init(at91_ohci_init);
+module_exit(at91_ohci_exit);
diff -urN linux-2.4.26/drivers/at91/watchdog/Makefile linux-2.4.26-vrs1/drivers/at91/watchdog/Makefile
--- linux-2.4.26/drivers/at91/watchdog/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/watchdog/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,15 @@
+# File: drivers/at91/watchdog/Makefile
+#
+# Makefile for the Atmel AT91RM9200 watchdog device driver
+#
+
+O_TARGET := at91wdt.o
+
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_AT91_WATCHDOG) += at91_wdt.o
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/at91/watchdog/at91_wdt.c linux-2.4.26-vrs1/drivers/at91/watchdog/at91_wdt.c
--- linux-2.4.26/drivers/at91/watchdog/at91_wdt.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/at91/watchdog/at91_wdt.c 2004-04-10 12:23:48.000000000 +0100
@@ -0,0 +1,193 @@
+/*
+ * Watchdog driver for Atmel AT91RM9200 (Thunder)
+ *
+ * (c) SAN People (Pty) Ltd
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <asm/uaccess.h>
+#include <linux/init.h>
+
+#define WDT_DEFAULT_TIME 5 /* 5 seconds */
+#define WDT_MAX_TIME 256 /* 256 seconds */
+
+static int at91wdt_time = WDT_DEFAULT_TIME;
+static int at91wdt_busy;
+
+/* ......................................................................... */
+
+/*
+ * Disable the watchdog.
+ */
+static void at91_wdt_stop(void)
+{
+ AT91_SYS->ST_WDMR = AT91C_ST_EXTEN;
+}
+
+/*
+ * Enable and reset the watchdog.
+ */
+static void at91_wdt_start(void)
+{
+ AT91_SYS->ST_WDMR = AT91C_ST_EXTEN | AT91C_ST_RSTEN | (((65536 * at91wdt_time) >> 8) & AT91C_ST_WDV);
+ AT91_SYS->ST_CR = AT91C_ST_WDRST;
+}
+
+/* ......................................................................... */
+
+/*
+ * Watchdog device is opened, and watchdog starts running.
+ */
+static int at91_wdt_open(struct inode *inode, struct file *file)
+{
+ if (test_and_set_bit(1, &at91wdt_busy))
+ return -EBUSY;
+ MOD_INC_USE_COUNT;
+
+ /*
+ * All counting occurs at SLOW_CLOCK / 128 = 0.256 Hz
+ *
+ * Since WDV is a 16-bit counter, the maximum period is
+ * 65536 / 0.256 = 256 seconds.
+ */
+
+ at91_wdt_start();
+ return 0;
+}
+
+/*
+ * Close the watchdog device.
+ * If CONFIG_WATCHDOG_NOWAYOUT is NOT defined then the watchdog is also
+ * disabled.
+ */
+static int at91_wdt_close(struct inode *inode, struct file *file)
+{
+#ifndef CONFIG_WATCHDOG_NOWAYOUT
+ /* Disable the watchdog when file is closed */
+ at91_wdt_stop();
+#endif
+
+ at91wdt_busy = 0;
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+/*
+ * Handle commands from user-space.
+ */
+static int at91_wdt_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ unsigned int new_value;
+ static struct watchdog_info info = {
+ identity: "at91 watchdog",
+ options: WDIOF_SETTIMEOUT,
+ };
+
+ switch(cmd) {
+ case WDIOC_KEEPALIVE:
+ AT91_SYS->ST_CR = AT91C_ST_WDRST; /* Pat the watchdog */
+ return 0;
+
+ case WDIOC_GETSUPPORT:
+ return copy_to_user((struct watchdog_info *)arg, &info, sizeof(info));
+
+ case WDIOC_SETTIMEOUT:
+ if (get_user(new_value, (int *)arg))
+ return -EFAULT;
+ if ((new_value <= 0) || (new_value > WDT_MAX_TIME))
+ return -EINVAL;
+
+ /* Restart watchdog with new time */
+ at91wdt_time = new_value;
+ at91_wdt_start();
+
+ /* Return current value */
+ return put_user(at91wdt_time, (int *)arg);
+
+ case WDIOC_GETTIMEOUT:
+ return put_user(at91wdt_time, (int *)arg);
+
+ case WDIOC_GETSTATUS:
+ return put_user(0, (int *)arg);
+
+ case WDIOC_SETOPTIONS:
+ if (get_user(new_value, (int *)arg))
+ return -EFAULT;
+ if (new_value & WDIOS_DISABLECARD)
+ at91_wdt_stop();
+ if (new_value & WDIOS_ENABLECARD)
+ at91_wdt_start();
+ return 0;
+
+ default:
+ return -ENOIOCTLCMD;
+ }
+}
+
+/*
+ * Pat the watchdog whenever device is written to.
+ */
+static ssize_t at91_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
+{
+ /* Can't seek (pwrite) on this device */
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+
+ if (len) {
+ AT91_SYS->ST_CR = AT91C_ST_WDRST; /* Pat the watchdog */
+ return len;
+ }
+
+ return 0;
+}
+
+/* ......................................................................... */
+
+static struct file_operations at91wdt_fops =
+{
+ .owner = THIS_MODULE,
+ .ioctl = at91_wdt_ioctl,
+ .open = at91_wdt_open,
+ .release = at91_wdt_close,
+ .write = at91_wdt_write,
+};
+
+static struct miscdevice at91wdt_miscdev =
+{
+ .minor = WATCHDOG_MINOR,
+ .name = "watchdog",
+ .fops = &at91wdt_fops,
+};
+
+static int __init at91_wdt_init(void)
+{
+ int res;
+
+ res = misc_register(&at91wdt_miscdev);
+ if (res)
+ return res;
+
+ printk("AT91 Watchdog Timer enabled (%d seconds)\n", WDT_DEFAULT_TIME);
+ return 0;
+}
+
+static void __exit at91_wdt_exit(void)
+{
+ misc_deregister(&at91wdt_miscdev);
+}
+
+module_init(at91_wdt_init);
+module_exit(at91_wdt_exit);
+
+MODULE_LICENSE("GPL")
+MODULE_AUTHOR("Andrew Victor")
+MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200")
diff -urN linux-2.4.26/drivers/block/Makefile linux-2.4.26-vrs1/drivers/block/Makefile
--- linux-2.4.26/drivers/block/Makefile 2003-06-13 15:51:32.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/block/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -27,11 +27,17 @@
obj-$(CONFIG_BLK_DEV_PS2) += ps2esdi.o
obj-$(CONFIG_BLK_DEV_XD) += xd.o
obj-$(CONFIG_BLK_CPQ_DA) += cpqarray.o
-obj-$(CONFIG_BLK_CPQ_CISS_DA) += cciss.o
+obj-$(CONFIG_BLK_CPQ_CISS_DA) += cciss.o
obj-$(CONFIG_BLK_DEV_DAC960) += DAC960.o
obj-$(CONFIG_BLK_DEV_UMEM) += umem.o
obj-$(CONFIG_BLK_DEV_NBD) += nbd.o
subdir-$(CONFIG_PARIDE) += paride
+ifeq ($(CONFIG_ARCH_ACORN),y)
+mod-subdirs += ../acorn/block
+subdir-y += ../acorn/block
+obj-y += ../acorn/block/acorn-block.o
+endif
+
include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/block/ll_rw_blk.c linux-2.4.26-vrs1/drivers/block/ll_rw_blk.c
--- linux-2.4.26/drivers/block/ll_rw_blk.c 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/block/ll_rw_blk.c 2004-04-18 21:47:50.000000000 +0100
@@ -32,6 +32,19 @@
#include <linux/slab.h>
#include <linux/module.h>
+/* Maybe something to cleanup in 2.3?
+ * We shouldn't touch 0x3f2 on machines which don't have a PC floppy controller
+ * - it may contain something else which could cause a system hang. This is
+ * now selected by a configuration option, but maybe it ought to be in the
+ * floppy code itself? - rmk
+ */
+#if defined(__i386__) || (defined(__arm__) && defined(CONFIG_ARCH_ACORN))
+#define FLOPPY_BOOT_DISABLE
+#endif
+#ifdef CONFIG_BLK_DEV_FD
+#undef FLOPPY_BOOT_DISABLE
+#endif
+
/*
* MAC Floppy IWM hooks
*/
@@ -524,7 +537,7 @@
elevator_init(&q->elevator, ELEVATOR_LINUS);
blk_init_free_list(q);
q->request_fn = rfn;
- q->back_merge_fn = ll_back_merge_fn;
+ q->back_merge_fn = ll_back_merge_fn;
q->front_merge_fn = ll_front_merge_fn;
q->merge_requests_fn = ll_merge_requests_fn;
q->make_request_fn = __make_request;
@@ -1549,7 +1562,7 @@
mfm_init();
#endif
#ifdef CONFIG_PARIDE
- { extern void paride_init(void); paride_init(); };
+ { extern void paride_init(void); paride_init(); }
#endif
#ifdef CONFIG_MAC_FLOPPY
swim3_init();
@@ -1563,12 +1576,14 @@
#ifdef CONFIG_ATARI_FLOPPY
atari_floppy_init();
#endif
+#ifdef CONFIG_BLK_DEV_FD1772
+ fd1772_init();
+#endif
#ifdef CONFIG_BLK_DEV_FD
floppy_init();
-#else
-#if defined(__i386__) /* Do we even need this? */
- outb_p(0xc, 0x3f2);
#endif
+#ifdef FLOPPY_BOOT_DISABLE
+ outb_p(0xc, 0x3f2);
#endif
#ifdef CONFIG_CDU31A
cdu31a_init();
@@ -1626,7 +1641,7 @@
jsfd_init();
#endif
return 0;
-};
+}
EXPORT_SYMBOL(io_request_lock);
EXPORT_SYMBOL(end_that_request_first);
diff -urN linux-2.4.26/drivers/cdrom/cdrom.c linux-2.4.26-vrs1/drivers/cdrom/cdrom.c
--- linux-2.4.26/drivers/cdrom/cdrom.c 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/cdrom/cdrom.c 2004-01-14 21:38:59.000000000 +0000
@@ -246,8 +246,8 @@
#define CD_DVD 0x80
/* Define this to remove _all_ the debugging messages */
-/* #define ERRLOGMASK CD_NOTHING */
-#define ERRLOGMASK (CD_WARNING)
+#define ERRLOGMASK CD_NOTHING
+/* #define ERRLOGMASK (CD_WARNING) */
/* #define ERRLOGMASK (CD_WARNING|CD_OPEN|CD_COUNT_TRACKS|CD_CLOSE) */
/* #define ERRLOGMASK (CD_WARNING|CD_REG_UNREG|CD_DO_IOCTL|CD_OPEN|CD_CLOSE|CD_COUNT_TRACKS) */
diff -urN linux-2.4.26/drivers/char/Config.in linux-2.4.26-vrs1/drivers/char/Config.in
--- linux-2.4.26/drivers/char/Config.in 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/char/Config.in 2004-04-10 12:04:15.000000000 +0100
@@ -20,10 +20,10 @@
if [ "$CONFIG_IA64" = "y" ]; then
bool ' Support for serial port described by EFI HCDP table' CONFIG_SERIAL_HCDP
fi
- if [ "$CONFIG_ARCH_ACORN" = "y" ]; then
- tristate ' Atomwide serial port support' CONFIG_ATOMWIDE_SERIAL
- tristate ' Dual serial port support' CONFIG_DUALSP_SERIAL
- fi
+fi
+if [ "$CONFIG_ARCH_ACORN" = "y" ]; then
+ dep_tristate ' Atomwide serial port support' CONFIG_ATOMWIDE_SERIAL $CONFIG_SERIAL
+ dep_tristate ' Dual serial port support' CONFIG_DUALSP_SERIAL $CONFIG_SERIAL
fi
dep_mbool 'Extended dumb serial driver options' CONFIG_SERIAL_EXTENDED $CONFIG_SERIAL
if [ "$CONFIG_SERIAL_EXTENDED" = "y" ]; then
@@ -132,18 +132,6 @@
bool ' SGI SN2 IOC4 serial port support' CONFIG_SGI_IOC4_SERIAL
fi
fi
-fi
-if [ "$CONFIG_EXPERIMENTAL" = "y" -a "$CONFIG_ZORRO" = "y" ]; then
- tristate 'Commodore A2232 serial support (EXPERIMENTAL)' CONFIG_A2232
-fi
-if [ "$CONFIG_FOOTBRIDGE" = "y" ]; then
- bool 'DC21285 serial port support' CONFIG_SERIAL_21285
- if [ "$CONFIG_SERIAL_21285" = "y" ]; then
- if [ "$CONFIG_OBSOLETE" = "y" ]; then
- bool ' Use /dev/ttyS0 device (OBSOLETE)' CONFIG_SERIAL_21285_OLD
- fi
- bool ' Console on DC21285 serial port' CONFIG_SERIAL_21285_CONSOLE
- fi
if [ "$CONFIG_PARISC" = "y" ]; then
bool ' PDC software console support' CONFIG_PDC_CONSOLE
fi
@@ -168,6 +156,16 @@
if [ "$CONFIG_CPU_VR41XX" = "y" ]; then
bool 'NEC VR4100 series Keyboard Interface Unit Support ' CONFIG_VR41XX_KIU
fi
+if [ "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
+ tristate 'AT91RM9200 SPI device interface' CONFIG_AT91_SPIDEV
+fi
+
+source drivers/serial/Config.in
+
+if [ "$CONFIG_ARCH_ANAKIN" = "y" ]; then
+ tristate 'Anakin touchscreen support' CONFIG_TOUCHSCREEN_ANAKIN
+fi
+
bool 'Unix98 PTY support' CONFIG_UNIX98_PTYS
if [ "$CONFIG_UNIX98_PTYS" = "y" ]; then
int 'Maximum number of Unix98 PTYs in use (0-2048)' CONFIG_UNIX98_PTY_COUNT 256
@@ -190,6 +188,12 @@
source drivers/i2c/Config.in
+if [ "$CONFIG_I2C" != "n" ]; then
+ dep_tristate ' DS1307 RTC' CONFIG_I2C_DS1307 $CONFIG_I2C
+fi
+
+source drivers/l3/Config.in
+
mainmenu_option next_comment
comment 'Mice'
tristate 'Bus Mouse Support' CONFIG_BUSMOUSE
@@ -245,11 +249,13 @@
tristate ' ALi M7101 PMU Watchdog Timer' CONFIG_ALIM7101_WDT
tristate ' AMD "Elan" SC520 Watchdog Timer' CONFIG_SC520_WDT
tristate ' Berkshire Products PC Watchdog' CONFIG_PCWATCHDOG
- if [ "$CONFIG_FOOTBRIDGE" = "y" ]; then
- tristate ' DC21285 watchdog' CONFIG_21285_WATCHDOG
- if [ "$CONFIG_ARCH_NETWINDER" = "y" ]; then
- tristate ' NetWinder WB83C977 watchdog' CONFIG_977_WATCHDOG
- fi
+ if [ "$CONFIG_ARM" = "y" ]; then
+ dep_tristate ' DC21285 watchdog' CONFIG_21285_WATCHDOG $CONFIG_FOOTBRIDGE
+ dep_tristate ' NetWinder WB83C977 watchdog' CONFIG_977_WATCHDOG $CONFIG_ARCH_NETWINDER
+ dep_tristate ' SA1100 watchdog' CONFIG_SA1100_WATCHDOG $CONFIG_ARCH_SA1100
+ dep_tristate ' EPXA watchdog' CONFIG_EPXA_WATCHDOG $CONFIG_ARCH_CAMELOT
+ dep_tristate ' Omaha watchdog' CONFIG_OMAHA_WATCHDOG $CONFIG_ARCH_OMAHA
+ dep_tristate ' AT91RM9200 watchdog' CONFIG_AT91_WATCHDOG $CONFIG_ARCH_AT91RM9200
fi
tristate ' Eurotech CPU-1220/1410 Watchdog Timer' CONFIG_EUROTECH_WDT
tristate ' IB700 SBC Watchdog Timer' CONFIG_IB700_WDT
@@ -326,6 +332,15 @@
if [ "$CONFIG_TOSHIBA_RBTX4927" = "y" -o "$CONFIG_TOSHIBA_JMR3927" = "y" ]; then
tristate 'Dallas DS1742 RTC support' CONFIG_DS1742
fi
+if [ "$CONFIG_ARCH_SA1100" = "y" ]; then
+ tristate 'SA1100 Real Time Clock' CONFIG_SA1100_RTC
+fi
+if [ "$CONFIG_ARCH_OMAHA" = "y" ]; then
+ tristate 'Omaha Real Time Clock' CONFIG_OMAHA_RTC
+fi
+if [ "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
+ tristate 'AT91RM9200 Real Time Clock' CONFIG_AT91_RTC
+fi
tristate 'Double Talk PC internal speech card support' CONFIG_DTLK
tristate 'Siemens R3964 line discipline' CONFIG_R3964
diff -urN linux-2.4.26/drivers/char/Makefile linux-2.4.26-vrs1/drivers/char/Makefile
--- linux-2.4.26/drivers/char/Makefile 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/char/Makefile 2004-04-10 12:07:34.000000000 +0100
@@ -29,7 +29,7 @@
mod-subdirs := joystick ftape drm drm-4.0 pcmcia
-list-multi :=
+list-multi :=
KEYMAP =defkeymap.o
KEYBD =pc_keyb.o
@@ -106,11 +106,39 @@
endif
ifeq ($(ARCH),arm)
- ifneq ($(CONFIG_PC_KEYMAP),y)
- KEYMAP =
+ KEYMAP :=
+ KEYBD :=
+ ifeq ($(CONFIG_PC_KEYMAP),y)
+ KEYMAP := defkeymap.o
endif
- ifneq ($(CONFIG_PC_KEYB),y)
- KEYBD =
+ ifeq ($(CONFIG_PC_KEYB),y)
+ KEYBD += pc_keyb.o
+ endif
+ ifeq ($(CONFIG_KMI_KEYB),y)
+ KEYBD += amba_kmi_keyb.o
+ endif
+ ifeq ($(CONFIG_SA1111),y)
+ KEYBD += sa1111_keyb.o
+ endif
+ ifeq ($(CONFIG_ARCH_EDB7211),y)
+ KEYBD += edb7211_keyb.o
+ endif
+ ifeq ($(CONFIG_ARCH_AUTCPU12),y)
+ KEYMAP := defkeymap.o
+ KEYBD += clps711x_keyb.o
+ endif
+ ifeq ($(CONFIG_SA1100_GRAPHICSCLIENT),y)
+ KEYMAP = gckeymap.o
+ KEYBD += gc_keyb.o
+ endif
+ ifeq ($(CONFIG_SA1100_CERF_CPLD),y)
+ KEYBD += cerf_keyb.o
+ endif
+ ifeq ($(CONFIG_ARCH_FORTUNET),y)
+ KEYMAP := defkeymap.o
+ endif
+ ifeq ($(CONFIG_ARCH_GUIDEA07),y)
+ KEYMAP := defkeymap.o
endif
endif
@@ -172,11 +200,9 @@
obj-$(CONFIG_VT) += vt.o vc_screen.o consolemap.o consolemap_deftbl.o $(CONSOLE) selection.o
obj-$(CONFIG_SERIAL) += $(SERIAL)
obj-$(CONFIG_SERIAL_HCDP) += hcdp_serial.o
-obj-$(CONFIG_SERIAL_21285) += serial_21285.o
-obj-$(CONFIG_SERIAL_SA1100) += serial_sa1100.o
-obj-$(CONFIG_SERIAL_AMBA) += serial_amba.o
obj-$(CONFIG_TS_AU1X00_ADS7846) += au1000_ts.o
obj-$(CONFIG_SERIAL_DEC) += decserial.o
+obj-$(CONFIG_TOUCHSCREEN_ANAKIN) += anakin_ts.o
ifndef CONFIG_SUN_KEYBOARD
obj-$(CONFIG_VT) += keyboard.o $(KEYMAP) $(KEYBD)
@@ -253,6 +279,8 @@
obj-$(CONFIG_SGI_DS1286) += ds1286.o
obj-$(CONFIG_MIPS_RTC) += mips_rtc.o
obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o
+obj-$(CONFIG_SA1100_RTC) += sa1100-rtc.o
+obj-$(CONFIG_OMAHA_RTC) += omaha-rtc.o
ifeq ($(CONFIG_PPC),)
obj-$(CONFIG_NVRAM) += nvram.o
endif
@@ -291,6 +319,7 @@
obj-$(CONFIG_NWFLASH) += nwflash.o
obj-$(CONFIG_SCx200) += scx200.o
obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
+obj-$(CONFIG_SA1100_CONSUS) += consusbutton.o
# Only one watchdog can succeed. We probe the hardware watchdog
# drivers first, then the softdog driver. This means if your hardware
@@ -319,16 +348,28 @@
obj-$(CONFIG_SC1200_WDT) += sc1200wdt.o
obj-$(CONFIG_SCx200_WDT) += scx200_wdt.o
obj-$(CONFIG_WAFER_WDT) += wafer5823wdt.o
+obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
+obj-$(CONFIG_EPXA_WATCHDOG) += epxa_wdt.o
+obj-$(CONFIG_OMAHA_WATCHDOG) += omaha_wdt.o
obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
obj-$(CONFIG_AMD7XX_TCO) += amd7xx_tco.o
obj-$(CONFIG_INDYDOG) += indydog.o
obj-$(CONFIG_8xx_WDT) += mpc8xx_wdt.o
+# I2C char devices
+obj-$(CONFIG_I2C_DS1307) += ds1307.o
+
subdir-$(CONFIG_MWAVE) += mwave
ifeq ($(CONFIG_MWAVE),y)
obj-y += mwave/mwave.o
endif
+ifeq ($(CONFIG_ARCH_ACORN),y)
+mod-subdirs += ../acorn/char
+subdir-y += ../acorn/char
+obj-y += ../acorn/char/acorn-char.o
+endif
+
subdir-$(CONFIG_IPMI_HANDLER) += ipmi
ifeq ($(CONFIG_IPMI_HANDLER),y)
obj-y += ipmi/ipmi.o
diff -urN linux-2.4.26/drivers/char/amba_kmi_keyb.c linux-2.4.26-vrs1/drivers/char/amba_kmi_keyb.c
--- linux-2.4.26/drivers/char/amba_kmi_keyb.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/amba_kmi_keyb.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,999 @@
+/*
+ * linux/drivers/char/amba_kmi_keyb.c
+ *
+ * AMBA Keyboard and Mouse Interface Driver
+ *
+ * Copyright (C) 2000 Deep Blue Solutions Ltd.
+ *
+ * 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
+ *
+ * This keyboard driver drives a PS/2 keyboard and mouse connected
+ * to the KMI interfaces. The KMI interfaces are nothing more than
+ * a uart; there is no inteligence in them to do keycode translation.
+ * We leave all that up to the keyboard itself.
+ *
+ * FIXES:
+ * dirk.uffmann@nokia.com: enabled PS/2 reconnection
+ */
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h> /* for in_interrupt */
+#include <linux/timer.h>
+#include <linux/init.h>
+#include <linux/delay.h> /* for udelay */
+#include <linux/kbd_kern.h> /* for keyboard_tasklet */
+#include <linux/kbd_ll.h>
+
+#include <asm/io.h>
+#include <asm/hardware/amba_kmi.h>
+#include <asm/mach/amba_kmi.h>
+#include <asm/keyboard.h>
+
+//#define DEBUG(s) printk s
+#define DEBUG(s) do { } while (0)
+
+#define CONFIG_AMBA_PS2_RECONNECT
+
+#define KMI_BASE (kmi->base)
+
+#define KMI_RESET 0x00
+#define KMI_RESET_POR 0x01
+#define KMI_RESET_DONE 0x02
+
+#define KMI_NO_ACK 0xffff
+
+#define PS2_O_RESET 0xff
+#define PS2_O_RESEND 0xfe
+#define PS2_O_DISABLE 0xf5
+#define PS2_O_ENABLE 0xf4
+#define PS2_O_ECHO 0xee
+
+/*
+ * Keyboard
+ */
+#define PS2_O_SET_DEFAULT 0xf6
+#define PS2_O_SET_RATE_DELAY 0xf3
+#define PS2_O_SET_SCANSET 0xf0
+#define PS2_O_INDICATORS 0xed
+
+/*
+ * Mouse
+ */
+#define PS2_O_SET_SAMPLE 0xf3
+#define PS2_O_SET_STREAM 0xea
+#define PS2_O_SET_RES 0xe8
+#define PS2_O_SET_SCALE21 0xe7
+#define PS2_O_SET_SCALE11 0xe6
+#define PS2_O_REQ_STATUS 0xe9
+
+/*
+ * Responses
+ */
+#define PS2_I_RESEND 0xfe
+#define PS2_I_DIAGFAIL 0xfc
+#define PS2_I_ACK 0xfa
+#define PS2_I_BREAK 0xf0
+#define PS2_I_ECHO 0xee
+#define PS2_I_BAT_OK 0xaa
+
+static char *kmi_type[] = { "Keyboard", "Mouse" };
+
+static struct kmi_info *kmi_keyb;
+static struct kmi_info *kmi_mouse;
+
+static inline void __kmi_send(struct kmi_info *kmi, u_int val)
+{
+ u_int status;
+
+ do {
+ status = __raw_readb(KMISTAT);
+ } while (!(status & KMISTAT_TXEMPTY));
+
+ kmi->resend_count += 1;
+ __raw_writeb(val, KMIDATA);
+}
+
+static void kmi_send(struct kmi_info *kmi, u_int val)
+{
+ kmi->last_tx = val;
+ kmi->resend_count = -1;
+ __kmi_send(kmi, val);
+}
+
+static u_int kmi_send_and_wait(struct kmi_info *kmi, u_int val, u_int timeo)
+{
+ DECLARE_WAITQUEUE(wait, current);
+
+ if (kmi->present == 0)
+ return KMI_NO_ACK;
+
+ kmi->res = KMI_NO_ACK;
+ kmi->last_tx = val;
+ kmi->resend_count = -1;
+
+ if (current->pid != 0 && !in_interrupt()) {
+ add_wait_queue(&kmi->wait_q, &wait);
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ __kmi_send(kmi, val);
+ schedule_timeout(timeo);
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&kmi->wait_q, &wait);
+ } else {
+ int i;
+
+ __kmi_send(kmi, val);
+ for (i = 0; i < 1000; i++) {
+ if (kmi->res != KMI_NO_ACK)
+ break;
+ udelay(100);
+ }
+ }
+
+ return kmi->res;
+}
+
+/*
+ * This lot should probably be separated into a separate file...
+ */
+#ifdef CONFIG_KMI_MOUSE
+
+#include <linux/fs.h> /* for struct file_ops */
+#include <linux/poll.h> /* for poll_table */
+#include <linux/miscdevice.h> /* for struct miscdev */
+#include <linux/random.h> /* for add_mouse_randomness */
+#include <linux/slab.h> /* for kmalloc */
+#include <linux/smp_lock.h> /* for {un,}lock_kernel */
+#include <linux/spinlock.h>
+
+#include <asm/uaccess.h>
+
+#define BUF_SZ 2048
+
+static spinlock_t kmi_mouse_lock;
+static int kmi_mouse_count;
+static struct queue {
+ u_int head;
+ u_int tail;
+ struct fasync_struct *fasync;
+ unsigned char buf[BUF_SZ];
+} *queue;
+
+#define queue_empty() (queue->head == queue->tail)
+
+static u_char get_from_queue(void)
+{
+ unsigned long flags;
+ u_char res;
+
+ spin_lock_irqsave(&kmi_mouse_lock, flags);
+ res = queue->buf[queue->tail];
+ queue->tail = (queue->tail + 1) & (BUF_SZ-1);
+ spin_unlock_irqrestore(&kmi_mouse_lock, flags);
+
+ return res;
+}
+
+static ssize_t
+kmi_mouse_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+ ssize_t i = count;
+
+ if (queue_empty()) {
+ int ret;
+
+ if (file->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+ ret = wait_event_interruptible(kmi_mouse->wait_q, !queue_empty());
+ if (ret)
+ return ret;
+ }
+ while (i > 0 && !queue_empty()) {
+ u_char c;
+ c = get_from_queue();
+ put_user(c, buf++);
+ i--;
+ }
+ if (count - i)
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+ return count - i;
+}
+
+static ssize_t
+kmi_mouse_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+{
+ ssize_t retval = 0;
+
+ if (count > 32)
+ count = 32;
+
+ do {
+ char c;
+ get_user(c, buf++);
+ kmi_send_and_wait(kmi_mouse, c, HZ);
+ retval++;
+ } while (--count);
+
+ if (retval)
+ file->f_dentry->d_inode->i_mtime = CURRENT_TIME;
+
+ return retval;
+}
+
+static unsigned int
+kmi_mouse_poll(struct file *file, poll_table *wait)
+{
+ poll_wait(file, &kmi_mouse->wait_q, wait);
+ return (!queue_empty()) ? POLLIN | POLLRDNORM : 0;
+}
+
+static int
+kmi_mouse_release(struct inode *inode, struct file *file)
+{
+ lock_kernel();
+ fasync_helper(-1, file, 0, &queue->fasync);
+ if (--kmi_mouse_count == 0)
+ kmi_send_and_wait(kmi_mouse, PS2_O_DISABLE, HZ);
+ unlock_kernel();
+ return 0;
+}
+
+static int
+kmi_mouse_open(struct inode *inode, struct file *file)
+{
+ if (kmi_mouse_count++)
+ return 0;
+ queue->head = queue->tail = 0;
+ kmi_send_and_wait(kmi_mouse, PS2_O_ENABLE, HZ);
+ return 0;
+}
+
+static int
+kmi_mouse_fasync(int fd, struct file *filp, int on)
+{
+ int retval = fasync_helper(fd, filp, on, &queue->fasync);
+ if (retval > 0)
+ retval = 0;
+ return retval;
+}
+
+static struct file_operations ps_fops = {
+ read: kmi_mouse_read,
+ write: kmi_mouse_write,
+ poll: kmi_mouse_poll,
+ open: kmi_mouse_open,
+ release: kmi_mouse_release,
+ fasync: kmi_mouse_fasync,
+};
+
+static struct miscdevice ps_mouse = {
+ minor: PSMOUSE_MINOR,
+ name: "psaux",
+ fops: &ps_fops,
+};
+
+static u_char kmi_mse_init_string[] = {
+ PS2_O_DISABLE,
+ PS2_O_SET_SAMPLE, 100,
+ PS2_O_SET_RES, 3,
+ PS2_O_SET_SCALE21
+};
+
+/*
+ * The "normal" mouse scancode processing
+ */
+static void kmi_mse_intr(struct kmi_info *kmi, u_int val, struct pt_regs *regs)
+{
+ u_int head;
+
+ add_mouse_randomness(val);
+
+#ifdef CONFIG_AMBA_PS2_RECONNECT
+ /* Try to detect a hot-plug event on the PS/2 mouse port */
+ switch (kmi->hotplug_state) {
+ case 0:
+ /* Maybe we lost contact... */
+ if (val == PS2_I_BAT_OK) {
+ kmi->hotplug_state++;
+ DEBUG(("%s: Saw 0xAA. Going to hotplug state %d\n", kmi->name, kmi->hotplug_state));
+ }
+ break;
+
+ case 1:
+ /* Again, maybe (but only maybe) we lost contact... */
+ if (val == 0) {
+ kmi->hotplug_state++;
+ kmi_send(kmi, PS2_O_REQ_STATUS);
+ DEBUG(("%s: Got 0xAA 0x00. Sent Status Request\n", kmi->name));
+ } else {
+ kmi->hotplug_state = 0;
+ DEBUG(("%s: No 0x00 followed 0xAA. No reconnect.\n", kmi->name));
+ }
+ break;
+
+ case 2:
+ /* Eat up acknowledge */
+ if (val == PS2_I_ACK)
+ kmi->hotplug_state++;
+ else {
+ kmi->hotplug_state = 0;
+ DEBUG(("%s: didn't get ack (0x%2.2x)\n", kmi->name, val));
+ }
+ break;
+
+ case 3:
+ /* check if data reporting is still enabled, then no POR has happend */
+ kmi->reconnect = !(val & 1<<5);
+ DEBUG(("%s: Data reporting disabled?: (%d)\n", kmi->name, kmi->reconnect));
+ kmi->hotplug_state++;
+ DEBUG(("%s: Going to hotplug state %d\n", kmi->name, kmi->hotplug_state));
+ break;
+
+ case 4:
+ /* Eat up one status byte */
+ kmi->hotplug_state++;
+ DEBUG(("%s: Going to hotplug state %d\n", kmi->name, kmi->hotplug_state));
+ break;
+
+ case 5:
+ /* Eat up another status byte */
+ if (kmi->reconnect) {
+ kmi->config_num = 0;
+ kmi_send(kmi, kmi_mse_init_string[kmi->config_num]);
+ kmi->config_num++;
+ kmi->hotplug_state++;
+ DEBUG(("%s: Sending byte %d of PS/2 init string.\n", kmi->name, kmi->config_num));
+ } else {
+ kmi->hotplug_state = 0;
+ DEBUG(("%s: False Alarm...\n", kmi->name));
+ }
+ break;
+
+ case 6:
+ if (val == PS2_I_ACK && kmi->config_num < sizeof(kmi_mse_init_string)) {
+ kmi_send(kmi, kmi_mse_init_string[kmi->config_num]);
+ kmi->config_num++;
+ DEBUG(("%s: Sending byte %d of PS/2 init string.\n", kmi->name, kmi->config_num));
+ } else {
+ if (val == PS2_I_ACK) {
+ DEBUG(("%s: Now enable the mouse again...\n", kmi->name));
+ queue->head = queue->tail = 0;
+ kmi_send(kmi, PS2_O_ENABLE);
+ kmi->hotplug_state++;
+ } else {
+ kmi->hotplug_state = 0;
+ DEBUG(("%s: didn't get ack (0x%2.2x)\n", kmi->name, val));
+ }
+ }
+ break;
+
+ case 7:
+ /* Eat up last acknowledge from enable */
+ if (val == PS2_I_ACK)
+ printk(KERN_ERR "%s: reconnected\n", kmi->name);
+ else
+ DEBUG(("%s: didn't get ack (0x%2.2x)\n", kmi->name, val));
+
+ kmi->hotplug_state = 0;
+ break;
+
+ } /* switch (kmi->hotplug_state) */
+
+ /* while inside hotplug mechanism, don't misinterpret values */
+ if (kmi->hotplug_state > 2)
+ return;
+#endif
+
+ /* We are waiting for the mouse to respond to a kmi_send_and_wait() */
+ if (kmi->res == KMI_NO_ACK) {
+ if (val == PS2_I_RESEND) {
+ if (kmi->resend_count < 5)
+ __kmi_send(kmi, kmi->last_tx);
+ else {
+ printk(KERN_ERR "%s: too many resends\n", kmi->name);
+ return;
+ }
+ }
+
+ if (val == PS2_I_ACK) {
+ kmi->res = val;
+ wake_up(&kmi->wait_q);
+ }
+ return;
+ }
+
+ /* The mouse autonomously send new data, so wake up mouse_read() */
+ if (queue) {
+ head = queue->head;
+ queue->buf[head] = val;
+ head = (head + 1) & (BUF_SZ - 1);
+ if (head != queue->tail) {
+ queue->head = head;
+ kill_fasync(&queue->fasync, SIGIO, POLL_IN);
+ wake_up_interruptible(&kmi->wait_q);
+ }
+ }
+}
+
+static int kmi_init_mouse(struct kmi_info *kmi)
+{
+ u_int ret, i;
+
+ if (kmi->present) {
+ kmi->rx = kmi_mse_intr;
+
+ for (i = 0; i < sizeof(kmi_mse_init_string); i++) {
+ ret = kmi_send_and_wait(kmi, kmi_mse_init_string[i], HZ);
+ if (ret != PS2_I_ACK)
+ printk("%s: didn't get ack (0x%2.2x)\n",
+ kmi->name, ret);
+ }
+ }
+
+ queue = kmalloc(sizeof(*queue), GFP_KERNEL);
+ if (queue) {
+ memset(queue, 0, sizeof(*queue));
+ misc_register(&ps_mouse);
+ ret = 0;
+ } else
+ ret = -ENOMEM;
+
+ return ret;
+}
+#endif /* CONFIG_KMI_MOUSE */
+
+/*
+ * The "program" we send to the keyboard to set it up how we want it:
+ * - default typematic delays
+ * - scancode set 1
+ */
+static u_char kmi_kbd_init_string[] = {
+ PS2_O_DISABLE,
+ PS2_O_SET_DEFAULT,
+ PS2_O_SET_SCANSET, 0x01,
+ PS2_O_ENABLE
+};
+
+static void kmi_kbd_intr(struct kmi_info *kmi, u_int val, struct pt_regs *regs);
+
+static int __kmi_init_keyboard(struct kmi_info *kmi)
+{
+ u_int ret, i;
+
+ if (!kmi->present)
+ return 0;
+
+ kmi->rx = kmi_kbd_intr;
+
+ for (i = 0; i < sizeof(kmi_kbd_init_string); i++) {
+ ret = kmi_send_and_wait(kmi, kmi_kbd_init_string[i], HZ);
+ if (ret != PS2_I_ACK)
+ printk("%s: didn't ack (0x%2.2x)\n",
+ kmi->name, ret);
+ }
+
+ return 0;
+}
+
+static void kmi_kbd_init_tasklet(unsigned long k)
+{
+ struct kmi_info *kmi = (struct kmi_info *)k;
+ __kmi_init_keyboard(kmi);
+}
+
+static DECLARE_TASKLET_DISABLED(kmikbd_init_tasklet, kmi_kbd_init_tasklet, 0);
+
+/*
+ * The "normal" keyboard scancode processing
+ */
+static void kmi_kbd_intr(struct kmi_info *kmi, u_int val, struct pt_regs *regs)
+{
+#ifdef CONFIG_AMBA_PS2_RECONNECT
+ /* Try to detect a hot-plug event on the PS/2 keyboard port */
+ switch (kmi->hotplug_state) {
+ case 0:
+ /* Maybe we lost contact... */
+ if (val == PS2_I_BAT_OK) {
+ kmi_send(kmi, PS2_O_SET_SCANSET);
+ kmi->hotplug_state++;
+ DEBUG(("%s: Saw 0xAA. Going to hotplug state %d\n", kmi->name, kmi->hotplug_state));
+ }
+ break;
+
+ case 1:
+ /* Eat up acknowledge */
+ if (val == PS2_I_ACK) {
+ /* Request scan code set: '2' if POR has happend, '1' is false alarm */
+ kmi_send(kmi, 0);
+ kmi->hotplug_state++;
+ }
+ else {
+ kmi->hotplug_state = 0;
+ DEBUG(("%s: didn't get ack (0x%2.2x)\n", kmi->name, val));
+ }
+ break;
+
+ case 2:
+ /* Eat up acknowledge */
+ if (val == PS2_I_ACK)
+ kmi->hotplug_state++;
+ else {
+ kmi->hotplug_state = 0;
+ DEBUG(("%s: didn't get ack (0x%2.2x)\n", kmi->name, val));
+ }
+ break;
+
+ case 3:
+ kmi->hotplug_state = 0;
+ if (val == 2) {
+ DEBUG(("%s: POR detected. Scan code is: (%d)\n", kmi->name, val));
+ kmi->present = 1;
+ tasklet_schedule(&kmikbd_init_tasklet);
+ printk(KERN_ERR "%s: reconnected\n", kmi->name);
+ return;
+ }
+ else
+ DEBUG(("%s: False Alarm...\n", kmi->name));
+ break;
+
+ } /* switch (kmi->hotplug_state) */
+#endif
+
+ if (val == PS2_I_DIAGFAIL) {
+ printk(KERN_ERR "%s: diagnostic failed\n", kmi->name);
+ return;
+ }
+
+ /* We are waiting for the keyboard to respond to a kmi_send_and_wait() */
+ if (kmi->res == KMI_NO_ACK) {
+ if (val == PS2_I_RESEND) {
+ if (kmi->resend_count < 5)
+ __kmi_send(kmi, kmi->last_tx);
+ else {
+ printk(KERN_ERR "%s: too many resends\n", kmi->name);
+ return;
+ }
+ }
+
+ if (val >= 0xee) {
+ kmi->res = val;
+ wake_up(&kmi->wait_q);
+ }
+ return;
+ }
+
+#ifdef CONFIG_VT
+ kbd_pt_regs = regs;
+ handle_scancode(val, !(val & 0x80));
+ tasklet_schedule(&keyboard_tasklet);
+#endif
+}
+
+static void kmi_intr(int nr, void *devid, struct pt_regs *regs)
+{
+ struct kmi_info *kmi = devid;
+ u_int status = __raw_readb(KMIIR);
+
+ if (status & KMIIR_RXINTR) {
+ u_int val = __raw_readb(KMIDATA);
+
+ if (kmi->rx)
+ kmi->rx(kmi, val, regs);
+ }
+}
+
+static int kmi_init_keyboard(struct kmi_info *kmi)
+{
+ kmikbd_init_tasklet.data = (unsigned long)kmi;
+ tasklet_enable(&kmikbd_init_tasklet);
+
+ return __kmi_init_keyboard(kmi);
+}
+
+/*
+ * Reset interrupt handler
+ */
+static void __init
+kmi_reset_intr(struct kmi_info *kmi, u_int val, struct pt_regs *regs)
+{
+ if (kmi->state == KMI_RESET) {
+ if (val == PS2_I_ACK)
+ kmi->state = KMI_RESET_POR;
+ else {
+ val = KMI_NO_ACK;
+ goto finished;
+ }
+ } else if (kmi->state == KMI_RESET_POR) {
+finished:
+ kmi->res = val;
+ kmi->state = KMI_RESET_DONE;
+ kmi->rx = NULL;
+ wake_up(&kmi->wait_q);
+ }
+}
+
+/*
+ * Reset the device plugged into this interface
+ */
+static int __init kmi_reset(struct kmi_info *kmi)
+{
+ u_int res;
+ int ret = 0;
+
+ kmi->state = KMI_RESET;
+ kmi->rx = kmi_reset_intr;
+ res = kmi_send_and_wait(kmi, PS2_O_RESET, HZ);
+ kmi->rx = NULL;
+
+ if (res != PS2_I_BAT_OK) {
+ printk(KERN_ERR "%s: reset failed; ", kmi->name);
+ if (kmi->res != KMI_NO_ACK)
+ printk("code 0x%2.2x\n", kmi->res);
+ else
+ printk("no ack\n");
+ ret = -EINVAL;
+ }
+ return ret;
+}
+
+static int __init kmi_init_one_interface(struct kmi_info *kmi)
+{
+ u_int stat;
+ int ret = -ENODEV;
+
+ init_waitqueue_head(&kmi->wait_q);
+
+ printk(KERN_INFO "%s at 0x%8.8x on irq %d (%s)\n", kmi->name,
+ kmi->base, kmi->irq, kmi_type[kmi->type]);
+
+ /*
+ * Initialise the KMI interface
+ */
+ __raw_writeb(kmi->divisor, KMICLKDIV);
+ __raw_writeb(KMICR_EN, KMICR);
+
+ /*
+ * Check that the data and clock lines are OK.
+ */
+ stat = __raw_readb(KMISTAT);
+ if ((stat & (KMISTAT_IC|KMISTAT_ID)) != (KMISTAT_IC|KMISTAT_ID)) {
+ printk(KERN_ERR "%s: %s%s%sline%s stuck low\n", kmi->name,
+ (stat & KMISTAT_IC) ? "" : "clock ",
+ (stat & (KMISTAT_IC | KMISTAT_ID)) ? "" : "and ",
+ (stat & KMISTAT_ID) ? "" : "data ",
+ (stat & (KMISTAT_IC | KMISTAT_ID)) ? "" : "s");
+ goto bad;
+ }
+
+ /*
+ * Claim the appropriate interrupts
+ */
+ ret = request_irq(kmi->irq, kmi_intr, 0, kmi->name, kmi);
+ if (ret)
+ goto bad;
+
+ /*
+ * Enable the receive interrupt, and reset the device.
+ */
+ __raw_writeb(KMICR_EN | KMICR_RXINTREN, KMICR);
+ kmi->present = 1;
+ kmi->present = kmi_reset(kmi) == 0;
+
+ switch (kmi->type) {
+ case KMI_KEYBOARD:
+ ret = kmi_init_keyboard(kmi);
+ break;
+
+#ifdef CONFIG_KMI_MOUSE
+ case KMI_MOUSE:
+ ret = kmi_init_mouse(kmi);
+ break;
+#endif
+ }
+
+ return ret;
+
+bad:
+ /*
+ * Oh dear, the interface was bad, disable it.
+ */
+ __raw_writeb(0, KMICR);
+ return ret;
+}
+
+#ifdef CONFIG_VT
+/*
+ * The fragment between #ifdef above and #endif * CONFIG_VT *
+ * is from the pc_keyb.c driver. It is not copyrighted under the
+ * above notice. This code is by various authors; please see
+ * drivers/char/pc_keyb.c for further information.
+ */
+
+/*
+ * Translation of escaped scancodes to keycodes.
+ * This is now user-settable.
+ * The keycodes 1-88,96-111,119 are fairly standard, and
+ * should probably not be changed - changing might confuse X.
+ * X also interprets scancode 0x5d (KEY_Begin).
+ *
+ * For 1-88 keycode equals scancode.
+ */
+
+#define E0_KPENTER 96
+#define E0_RCTRL 97
+#define E0_KPSLASH 98
+#define E0_PRSCR 99
+#define E0_RALT 100
+#define E0_BREAK 101 /* (control-pause) */
+#define E0_HOME 102
+#define E0_UP 103
+#define E0_PGUP 104
+#define E0_LEFT 105
+#define E0_RIGHT 106
+#define E0_END 107
+#define E0_DOWN 108
+#define E0_PGDN 109
+#define E0_INS 110
+#define E0_DEL 111
+
+#define E1_PAUSE 119
+
+/* BTC */
+#define E0_MACRO 112
+/* LK450 */
+#define E0_F13 113
+#define E0_F14 114
+#define E0_HELP 115
+#define E0_DO 116
+#define E0_F17 117
+#define E0_KPMINPLUS 118
+/*
+ * My OmniKey generates e0 4c for the "OMNI" key and the
+ * right alt key does nada. [kkoller@nyx10.cs.du.edu]
+ */
+#define E0_OK 124
+/*
+ * New microsoft keyboard is rumoured to have
+ * e0 5b (left window button), e0 5c (right window button),
+ * e0 5d (menu button). [or: LBANNER, RBANNER, RMENU]
+ * [or: Windows_L, Windows_R, TaskMan]
+ */
+#define E0_MSLW 125
+#define E0_MSRW 126
+#define E0_MSTM 127
+
+static u_char e0_keys[128] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ E0_KPENTER, E0_RCTRL, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, E0_KPSLASH, 0, E0_PRSCR,
+ E0_RALT, 0, 0, 0,
+ 0, E0_F13, E0_F14, E0_HELP,
+ E0_DO, E0_F17, 0, 0,
+ 0, 0, E0_BREAK, E0_HOME,
+ E0_UP, E0_PGUP, 0, E0_LEFT,
+ E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END,
+ E0_DOWN, E0_PGDN, E0_INS, E0_DEL,
+ 0, 0, 0, 0,
+ 0, 0, 0, E0_MSLW,
+ E0_MSRW, E0_MSTM, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, E0_MACRO,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0
+};
+
+#ifdef CONFIG_MAGIC_SYSRQ
+u_char kmi_kbd_sysrq_xlate[128] =
+ "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
+ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
+ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
+ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
+ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
+ "\r\000/"; /* 0x60 - 0x6f */
+#endif
+
+int kmi_kbd_setkeycode(u_int scancode, u_int keycode)
+{
+ if (scancode < 128 || scancode > 255 || keycode > 127)
+ return -EINVAL;
+ e0_keys[scancode - 128] = keycode;
+ return 0;
+}
+
+int kmi_kbd_getkeycode(u_int scancode)
+{
+ if (scancode < 128 || scancode > 255)
+ return -EINVAL;
+ return e0_keys[scancode - 128];
+}
+
+int kmi_kbd_translate(u_char scancode, u_char *keycode, char raw_mode)
+{
+ static int prev_scancode = 0;
+
+ /* special prefix scancodes.. */
+ if (scancode == 0xe0 || scancode == 0xe1) {
+ prev_scancode = scancode;
+ return 0;
+ }
+
+ /* 0xff is sent by a few keyboards, ignore it. 0x00 is error */
+ if (scancode == 0x00 || scancode == 0xff) {
+ prev_scancode = 0;
+ return 0;
+ }
+
+ scancode &= 0x7f;
+
+ if (prev_scancode) {
+ int old_scancode = prev_scancode;
+
+ prev_scancode = 0;
+ switch (old_scancode) {
+ case 0xe0:
+ /*
+ * The keyboard maintains its own internal caps lock
+ * and num lock status. In caps lock mode, E0 AA
+ * precedes make code and E0 2A follows break code.
+ * In numlock mode, E0 2A precedes make code, and
+ * E0 AA follows break code. We do our own book-
+ * keeping, so we will just ignore these.
+ *
+ * For my keyboard there is no caps lock mode, but
+ * there are both Shift-L and Shift-R modes. The
+ * former mode generates E0 2A / E0 AA pairs, the
+ * latter E0 B6 / E0 36 pairs. So, we should also
+ * ignore the latter. - aeb@cwi.nl
+ */
+ if (scancode == 0x2a || scancode == 0x36)
+ return 0;
+ if (e0_keys[scancode])
+ *keycode = e0_keys[scancode];
+ else {
+ if (!raw_mode)
+ printk(KERN_INFO "kbd: unknown "
+ "scancode e0 %02x\n",
+ scancode);
+ return 0;
+ }
+ break;
+
+ case 0xe1:
+ if (scancode == 0x1d)
+ prev_scancode = 0x100;
+ else {
+ if (!raw_mode)
+ printk(KERN_INFO "kbd: unknown "
+ "scancode e1 %02x\n",
+ scancode);
+ return 0;
+ }
+ break;
+
+ case 0x100:
+ if (scancode == 0x45)
+ *keycode = E1_PAUSE;
+ else {
+ if (!raw_mode)
+ printk(KERN_INFO "kbd: unknown "
+ "scan code e1 1d %02x\n",
+ scancode);
+ return 0;
+ }
+ break;
+ }
+ } else
+ *keycode = scancode;
+ return 1;
+}
+
+char kmi_kbd_unexpected_up(u_char keycode)
+{
+ return 0x80;
+}
+
+void kmi_kbd_leds(u_char leds)
+{
+ struct kmi_info *kmi = kmi_keyb;
+ u_int ret;
+
+ if (kmi) {
+ ret = kmi_send_and_wait(kmi, PS2_O_INDICATORS, HZ);
+ if (ret != KMI_NO_ACK)
+ ret = kmi_send_and_wait(kmi, leds, HZ);
+ if (ret == KMI_NO_ACK)
+ kmi->present = 0;
+ }
+}
+
+int __init kmi_kbd_init(void)
+{
+ int ret = -ENODEV;
+
+ if (kmi_keyb) {
+ strcpy(kmi_keyb->name, "kmikbd");
+ ret = kmi_init_one_interface(kmi_keyb);
+ }
+
+ if (ret == 0) {
+ k_setkeycode = kmi_kbd_setkeycode;
+ k_getkeycode = kmi_kbd_getkeycode;
+ k_translate = kmi_kbd_translate;
+ k_unexpected_up = kmi_kbd_unexpected_up;
+ k_leds = kmi_kbd_leds;
+#ifdef CONFIG_MAGIC_SYSRQ
+ k_sysrq_xlate = kmi_kbd_sysrq_xlate;
+ k_sysrq_key = 0x54;
+#endif
+ }
+
+ return ret;
+}
+
+#endif /* CONFIG_VT */
+
+int register_kmi(struct kmi_info *kmi)
+{
+ struct kmi_info **kmip = NULL;
+ int ret;
+
+ if (kmi->type == KMI_KEYBOARD)
+ kmip = &kmi_keyb;
+ else if (kmi->type == KMI_MOUSE)
+ kmip = &kmi_mouse;
+
+ ret = -EINVAL;
+ if (kmip) {
+ ret = -EBUSY;
+ if (!*kmip) {
+ *kmip = kmi;
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
+#ifdef CONFIG_KMI_MOUSE
+static int __init kmi_init(void)
+{
+ int ret = -ENODEV;
+
+ if (kmi_mouse) {
+ strcpy(kmi_mouse->name, "kmimouse");
+ ret = kmi_init_one_interface(kmi_mouse);
+ }
+
+ return ret;
+}
+
+__initcall(kmi_init);
+#endif
diff -urN linux-2.4.26/drivers/char/anakin_ts.c linux-2.4.26-vrs1/drivers/char/anakin_ts.c
--- linux-2.4.26/drivers/char/anakin_ts.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/anakin_ts.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,208 @@
+/*
+ * linux/drivers/char/anakin_ts.c
+ *
+ * Copyright (C) 2001 Aleph One Ltd. for Acunia N.V.
+ *
+ * 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.
+ *
+ * Changelog:
+ * 18-Apr-2001 TTC Created
+ * 23-Oct-2001 dwmw2 Cleanup
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/wait.h>
+#include <linux/fs.h>
+#include <linux/sched.h>
+#include <linux/poll.h>
+#include <linux/miscdevice.h>
+#include <linux/init.h>
+#include <linux/compiler.h>
+#include <linux/interrupt.h>
+
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/irq.h>
+
+/*
+ * TSBUF_SIZE must be a power of two
+ */
+#define ANAKIN_TS_MINOR 16
+#define TSBUF_SIZE 256
+#define NEXT(index) (((index) + 1) & (TSBUF_SIZE - 1))
+
+static unsigned short buffer[TSBUF_SIZE][4];
+static int head, tail;
+static DECLARE_WAIT_QUEUE_HEAD(queue);
+static DECLARE_MUTEX(open_sem);
+static spinlock_t tailptr_lock = SPIN_LOCK_UNLOCKED;
+static struct fasync_struct *fasync;
+
+/*
+ * Interrupt handler and standard file operations
+ */
+static void
+anakin_ts_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned int status = __raw_readl(IO_BASE + IO_CONTROLLER + 0x24);
+
+ /*
+ * iPAQ format (u16 pressure, x, y, millisecs)
+ */
+ switch (status >> 20 & 3) {
+ case 0:
+ return;
+ case 2:
+ buffer[head][0] = 0;
+ break;
+ default:
+ buffer[head][0] = 0x7f;
+ }
+
+ if (unlikely((volatile int)tail == NEXT(head))) {
+ /* Run out of space in the buffer. Move the tail pointer */
+ spin_lock(&tailptr_lock);
+
+ if ((volatile int)tail == NEXT(head)) {
+ tail = NEXT(NEXT(head));
+ }
+ spin_unlock(&tailptr_lock);
+ }
+
+ buffer[head][1] = status >> 2 & 0xff;
+ buffer[head][2] = status >> 12 & 0xff;
+ buffer[head][3] = jiffies;
+ mb();
+ head = NEXT(head);
+
+ wake_up_interruptible(&queue);
+ kill_fasync(&fasync, SIGIO, POLL_IN);
+
+}
+
+static ssize_t
+anakin_ts_read(struct file *filp, char *buf, size_t count, loff_t *l)
+{
+ unsigned short data[4];
+ ssize_t written = 0;
+
+ if (head == tail) {
+ if (filp->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+ if (wait_event_interruptible(queue, (volatile int)head != (volatile int)tail))
+ return -ERESTARTSYS;
+ }
+
+ while ((volatile int)head != (volatile int)tail && count >= sizeof data) {
+ /* Copy the data out with the spinlock held, so the
+ interrupt can't fill the buffer and move the tail
+ pointer while we're doing it */
+ spin_lock_irq(&tailptr_lock);
+
+ memcpy(data, buffer[tail], sizeof data);
+ tail = NEXT(tail);
+
+ spin_unlock_irq(&tailptr_lock);
+
+ if (copy_to_user(buf, data, sizeof data))
+ return -EFAULT;
+ count -= sizeof data;
+ buf += sizeof data;
+ written += sizeof data;
+ }
+ return written ? written : -EINVAL;
+}
+
+static unsigned int
+anakin_ts_poll(struct file *filp, poll_table *wait)
+{
+ poll_wait(filp, &queue, wait);
+ return head != tail ? POLLIN | POLLRDNORM : 0;
+}
+
+static int
+anakin_ts_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ /*
+ * Future ioctl goes here
+ */
+ return 0;
+}
+
+static int
+anakin_ts_open(struct inode *inode, struct file *filp)
+{
+ if (down_trylock(&open_sem))
+ return -EBUSY;
+ return 0;
+}
+
+static int
+anakin_ts_fasync(int fd, struct file *filp, int on)
+{
+ return fasync_helper(fd, filp, on, &fasync);
+}
+
+static int
+anakin_ts_release(struct inode *inode, struct file *filp)
+{
+ anakin_ts_fasync(-1, filp, 0);
+ up(&open_sem);
+ return 0;
+}
+
+static struct file_operations anakin_ts_fops = {
+ owner: THIS_MODULE,
+ read: anakin_ts_read,
+ poll: anakin_ts_poll,
+ ioctl: anakin_ts_ioctl,
+ open: anakin_ts_open,
+ release: anakin_ts_release,
+ fasync: anakin_ts_fasync,
+};
+
+static struct miscdevice anakin_ts_miscdev = {
+ ANAKIN_TS_MINOR,
+ "anakin_ts",
+ &anakin_ts_fops
+};
+
+/*
+ * Initialization and exit routines
+ */
+int __init
+anakin_ts_init(void)
+{
+ int retval;
+
+ if ((retval = request_irq(IRQ_TOUCHSCREEN, anakin_ts_handler,
+ SA_INTERRUPT, "anakin_ts", 0))) {
+ printk(KERN_WARNING "anakin_ts: failed to get IRQ\n");
+ return retval;
+ }
+ __raw_writel(1, IO_BASE + IO_CONTROLLER + 8);
+ misc_register(&anakin_ts_miscdev);
+
+ printk(KERN_NOTICE "Anakin touchscreen driver initialised\n");
+
+ return 0;
+}
+
+void __exit
+anakin_ts_exit(void)
+{
+ __raw_writel(0, IO_BASE + IO_CONTROLLER + 8);
+ free_irq(IRQ_TOUCHSCREEN, 0);
+ misc_deregister(&anakin_ts_miscdev);
+}
+
+module_init(anakin_ts_init);
+module_exit(anakin_ts_exit);
+
+MODULE_AUTHOR("Tak-Shing Chan <chan@aleph1.co.uk>");
+MODULE_DESCRIPTION("Anakin touchscreen driver");
+MODULE_SUPPORTED_DEVICE("touchscreen/anakin");
diff -urN linux-2.4.26/drivers/char/cerf_keyb.c linux-2.4.26-vrs1/drivers/char/cerf_keyb.c
--- linux-2.4.26/drivers/char/cerf_keyb.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/cerf_keyb.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,380 @@
+/*
+ cerf_keyb.c: This is the end. Daniel is writing a device driver!!!
+*/
+#include <linux/config.h>
+
+#include <linux/spinlock.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/mm.h>
+#include <linux/signal.h>
+#include <linux/init.h>
+#include <linux/kbd_ll.h>
+#include <linux/delay.h>
+#include <linux/random.h>
+#include <linux/poll.h>
+#include <linux/miscdevice.h>
+#include <linux/slab.h>
+#include <linux/kbd_kern.h>
+#include <linux/smp_lock.h>
+#include <linux/timer.h>
+
+#include <asm/keyboard.h>
+#include <asm/bitops.h>
+#include <asm/uaccess.h>
+#include <asm/irq.h>
+#include <asm/system.h>
+
+#include <asm/io.h>
+
+#define KBD_REPORT_UNKN
+
+#define KBD_REPORT_ERR /* Report keyboard errors */
+#define KBD_REPORT_UNKN /* Report unknown scan codes */
+#define KBD_REPORT_TIMEOUTS /* Report keyboard timeouts */
+#define KBD_NO_DATA (-1) /* No data */
+#define KBD_REPEAT_START (0x20)
+#define KBD_REPEAT_CONTINUE (0x05)
+#define KBD_KEY_DOWN_MAX (0x10)
+#define UINT_LEN (20)
+#define SC_LIM (69)
+#define KBD_ROWS (5)
+#define KBD_COLUMNS (8)
+
+#define KBD_KEYUP (0x80)
+#define KBD_MODESCAN (0x7f)
+#define KBD_CAPSSCAN (0x3a)
+#define KBD_SHIFTSCAN (0x2a)
+#define KBD_NUMCURSCAN (0x7c)
+#define KBD_CTRLSCAN (0x1d)
+#define KBD_ALTSCAN (0x38)
+
+#define KBD_UP_OFF (0)
+#define KBD_UP_ON (1)
+#define KBD_DOWN (2)
+#define KBD_DOWN_HOLD (3)
+
+
+
+static unsigned char handle_kbd_event(void);
+static unsigned char kbd_read_input(void);
+static void column_set(unsigned int column);
+static int scancodes(unsigned char codeval[KBD_ROWS][KBD_COLUMNS]);
+
+static spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED;
+static struct timer_list kbd_timer;
+
+static short mode_ena = 0;
+static short numcur_ena = 0;
+static short shift_ena = 0;
+
+#define E0_KPENTER 96
+#define E0_RCTRL 97
+#define E0_KPSLASH 98
+#define E0_PRSCR 99
+#define E0_RALT 100
+#define E0_BREAK 101 /* (control-pause) */
+#define E0_HOME 102
+#define E0_UP 103
+#define E0_PGUP 104
+#define E0_LEFT 105
+#define E0_RIGHT 106
+#define E0_END 107
+#define E0_DOWN 108
+#define E0_PGDN 109
+#define E0_INS 110
+#define E0_DEL 111
+#define E1_PAUSE 119
+#define E0_MACRO 112
+#define E0_F13 113
+#define E0_F14 114
+#define E0_HELP 115
+#define E0_DO 116
+#define E0_F17 117
+#define E0_KPMINPLUS 118
+#define E0_OK 124
+#define E0_MSLW 125
+#define E0_MSRW 126
+#define E0_MSTM 127
+
+static unsigned char e0_keys[128] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00-0x07 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x08-0x0f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */
+ 0, 0, 0, 0, E0_KPENTER, E0_RCTRL, 0, 0, /* 0x18-0x1f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */
+ 0, 0, 0, 0, 0, E0_KPSLASH, 0, E0_PRSCR, /* 0x30-0x37 */
+ E0_RALT, 0, 0, 0, 0, E0_F13, E0_F14, E0_HELP, /* 0x38-0x3f */
+ E0_DO, E0_F17, 0, 0, 0, 0, E0_BREAK, E0_HOME, /* 0x40-0x47 */
+ E0_UP, E0_PGUP, 0, E0_LEFT, E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END,/* 0x48-0x4f */
+ E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 0, 0, 0, 0, /* 0x50-0x57 */
+ 0, 0, 0, E0_MSLW, E0_MSRW, E0_MSTM, 0, 0, /* 0x58-0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
+ 0, 0, 0, 0, 0, 0, 0, E0_MACRO, /* 0x68-0x6f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0 /* 0x78-0x7f */
+};
+
+static unsigned char cerf_normal_map[KBD_ROWS][KBD_COLUMNS] = {
+ {KBD_ALTSCAN, KBD_MODESCAN, 0x1e, 0x30, 0x2e, 0x20, 0x00, 0x00},
+ {0x12, 0x21, 0x22, 0x23, 0x17, 0x24, 0x25, 0x00},
+ {0x26, 0x32, 0x31, 0x18, 0x19, 0x10, 0x13, 0x00},
+ {0x1f, 0x14, 0x16, 0x2f, 0x11, 0x2d, 0x15, 0x00},
+ {0x2c, KBD_SHIFTSCAN, KBD_CTRLSCAN, 0x39, KBD_NUMCURSCAN, 0x2b, 0x1c, 0x00}
+};
+
+static unsigned char cerf_mode_map[KBD_ROWS][KBD_COLUMNS] = {
+ {0x00, 0x00, 0x02, 0x03, 0x04, 0x05, 0x00, 0x00},
+ {0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x00, 0x00}, //
+ {0x0d, 0x0c, 0x37, 0x35, 0x0d, 0x48, 0x28, 0x00},
+ {0x01, 0x33, 0x34, 0x00, 0x4b, 0x27, 0x4d, 0x00}, //
+ {0x0f, 0x00, KBD_CAPSSCAN, 0x0e, 0x00, 0x50, 0x00, 0x00}
+};
+
+static unsigned char cerf_numcur_map[KBD_ROWS][KBD_COLUMNS] = {
+ {0x00, 0x00, 0x02, 0x03, 0x04, 0x05, 0x00, 0x00},
+ {0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x00, 0x00},
+ {0x0d, 0x0c, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x4d, 0x00},
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00}
+};
+
+static void column_set(unsigned int column)
+{
+ if (column < 0)
+ {
+ CERF_PDA_CPLD_UnSet(CERF_PDA_CPLD_KEYPAD_A, 0xFF, 0xFF);
+ CERF_PDA_CPLD_UnSet(CERF_PDA_CPLD_KEYPAD_B, 0xFF, 0xFF);
+ }
+ else
+ {
+ if(column < 4)
+ {
+ CERF_PDA_CPLD_Set(CERF_PDA_CPLD_KEYPAD_A, 1 << (column % 4), 0xFF);
+ CERF_PDA_CPLD_UnSet(CERF_PDA_CPLD_KEYPAD_B, 0xFF, 0xFF);
+ }
+ else
+ {
+ CERF_PDA_CPLD_UnSet(CERF_PDA_CPLD_KEYPAD_A, 0xFF, 0xFF);
+ CERF_PDA_CPLD_Set(CERF_PDA_CPLD_KEYPAD_B, 1 << (column % 4), 0xFF);
+ }
+ }
+}
+
+static int scancodes(unsigned char codeval[KBD_ROWS][KBD_COLUMNS])
+{
+ int i, j;
+
+ for(i = 0; i < KBD_COLUMNS; i++)
+ {
+ column_set(i);
+ udelay(50);
+ for(j = 0; j < KBD_ROWS; j++)
+ {
+ if(mode_ena)
+ codeval[j][i] = (GPLR & (1 << (20 + j)))?(cerf_mode_map[j][i]?cerf_mode_map[j][i]:cerf_normal_map[j][i]):0;
+ else if(numcur_ena)
+ codeval[j][i] = (GPLR & (1 << (20 + j)))?(cerf_numcur_map[j][i]?cerf_numcur_map[j][i]:cerf_normal_map[j][i]):0;
+ else
+ codeval[j][i] = (GPLR & (1 << (20 + j)))?cerf_normal_map[j][i]:0;
+ }
+ }
+ column_set(-1);
+
+ return 0;
+}
+
+static unsigned char kbd_read_input(void)
+{
+ int i, j, k, l;
+ unsigned char prev;
+ static unsigned char count = 0;
+
+ static unsigned char oldcodes[KBD_ROWS][KBD_COLUMNS]={{0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0}};
+ unsigned char inputcode[KBD_ROWS][KBD_COLUMNS];
+
+ memset(inputcode, 0, sizeof(unsigned char) * (KBD_ROWS * KBD_COLUMNS));
+ scancodes(inputcode);
+
+ for(i = 0; i < KBD_COLUMNS; i++)
+ {
+ for(j = 0; j < KBD_ROWS; j++)
+ {
+// if(oldcodes[j][i] == 0xe0)
+// oldcodes[j][i] =
+ if(oldcodes[j][i] != inputcode[j][i])
+ {
+ // Value of the key before entering this function
+ prev = oldcodes[j][i];
+
+ // KEYUP
+ if(inputcode[j][i] == 0 && oldcodes[j][i] != 0 && !(oldcodes[j][i] & KBD_KEYUP))
+ {
+ oldcodes[j][i] |= KBD_KEYUP;
+
+ if(mode_ena == KBD_UP_ON)
+ mode_ena = KBD_UP_OFF;
+ if(prev == KBD_MODESCAN)
+ if(mode_ena == KBD_DOWN_HOLD)
+ mode_ena = KBD_UP_OFF;
+ else if(mode_ena == KBD_DOWN)
+ mode_ena = KBD_UP_ON;
+ if(mode_ena == KBD_DOWN)
+ mode_ena = KBD_DOWN_HOLD;
+ }
+ // RESET KEYUP
+ else if(oldcodes[j][i] & KBD_KEYUP)
+ oldcodes[j][i] = 0;
+ // KEY DOWN
+ else
+ {
+ oldcodes[j][i] = inputcode[j][i];
+
+ // Parse out mode modifiers before the keyboard interpreter can touch them
+ if(inputcode[j][i] == KBD_MODESCAN)
+ {
+ if(!mode_ena)
+ mode_ena = KBD_DOWN;
+ continue;
+ }
+ if(inputcode[j][i] == KBD_NUMCURSCAN)
+ {
+ numcur_ena = numcur_ena?0:1;
+ continue;
+ }
+ }
+ //printk("Modified: (%#x,%#x), ipv:%#x, To: (%#.2x), From: (%#.2x), Flags:%d,%d,%d\r\n", j, i, inputcode[j][i], oldcodes[j][i], prev, mode_ena, shift_ena, numcur_ena);
+ return oldcodes[j][i];
+ }
+ }
+ }
+
+ return (unsigned char)(KBD_NO_DATA);
+}
+
+int cerf_kbd_translate(unsigned char scancode, unsigned char *keycode,
+ char raw_mode)
+{
+ static int prev_scancode;
+
+ if (scancode == 0xe0 || scancode == 0xe1) {
+ prev_scancode = scancode;
+ return 0;
+ }
+
+ if (scancode == 0x00 || scancode == 0xff) {
+ prev_scancode = 0;
+ return 0;
+ }
+
+ scancode &= 0x7f;
+
+ if (prev_scancode) {
+ if (prev_scancode != 0xe0) {
+ if (prev_scancode == 0xe1 && scancode == 0x1d) {
+ prev_scancode = 0x100;
+ return 0;
+ } else if (prev_scancode == 0x100 && scancode == 0x45) {
+ prev_scancode = 0;
+ } else {
+#ifdef KBD_REPORT_UNKN
+ if (!raw_mode)
+ printk(KERN_INFO "keyboard: unknown e1 escape sequence\n");
+#endif
+ prev_scancode = 0;
+ return 0;
+ }
+ } else {
+ prev_scancode = 0;
+ if (scancode == 0x2a || scancode == 0x36)
+ return 0;
+ else {
+#ifdef KBD_REPORT_UNKN
+ if (!raw_mode)
+ printk(KERN_INFO "keyboard: unknown scancode e0 %02x\n",
+ scancode);
+#endif
+ return 0;
+ }
+ }
+ } else
+ *keycode = scancode;
+ return 1;
+}
+
+static inline void handle_keyboard_event(unsigned char scancode)
+{
+ if(scancode != (unsigned char)(KBD_NO_DATA))
+ {
+#ifdef CONFIG_VT
+ handle_scancode(scancode, !(scancode & KBD_KEYUP));
+#endif
+ tasklet_schedule(&keyboard_tasklet);
+ }
+}
+
+static unsigned char handle_kbd_event(void)
+{
+ unsigned char scancode;
+
+ scancode = kbd_read_input();
+ handle_keyboard_event(scancode);
+
+ return 0;
+}
+
+/* Handle the automatic interrupts handled by the timer */
+static void keyboard_interrupt(unsigned long foo)
+{
+ spin_lock_irq(&kbd_controller_lock);
+ handle_kbd_event();
+ spin_unlock_irq(&kbd_controller_lock);
+
+ kbd_timer.expires = 8 + jiffies;
+ kbd_timer.data = 0x00000000;
+ kbd_timer.function = (void(*)(unsigned long))&keyboard_interrupt;
+
+ add_timer(&kbd_timer);
+}
+
+void cerf_leds(unsigned char leds)
+{
+}
+char cerf_unexpected_up(unsigned char keycode)
+{
+return 0;
+}
+int cerf_getkeycode(unsigned int scancode)
+{
+return 0;
+}
+int cerf_setkeycode(unsigned int scancode, unsigned int keycode)
+{
+return 0;
+}
+
+void cerf_kbd_init_hw(void)
+{
+ printk("Starting Cerf PDA Keyboard Driver... ");
+
+ k_setkeycode = cerf_setkeycode;
+ k_getkeycode = cerf_getkeycode;
+ k_translate = cerf_kbd_translate;
+ k_unexpected_up = cerf_unexpected_up;
+ k_leds = cerf_leds;
+
+ GPDR &= ~(GPIO_GPIO(20) | GPIO_GPIO(21) | GPIO_GPIO(22) | GPIO_GPIO(23) | GPIO_GPIO(24));
+ kbd_timer.expires = 40 + jiffies;
+ kbd_timer.data = 0x00000000;
+ kbd_timer.function = (void(*)(unsigned long))&keyboard_interrupt;
+
+ add_timer(&kbd_timer);
+
+ printk("Done\r\n");
+}
diff -urN linux-2.4.26/drivers/char/clps711x_keyb.c linux-2.4.26-vrs1/drivers/char/clps711x_keyb.c
--- linux-2.4.26/drivers/char/clps711x_keyb.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/clps711x_keyb.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,547 @@
+/*
+ * drivers/char/clps711x_keyb.c
+ *
+ * Copyright (C) 2001 Thomas Gleixner <gleixner@autronix.de>
+ *
+ * based on drivers/edb7211_keyb.c, which is copyright (C) 2000 Bluemug Inc.
+ *
+ * Keyboard driver for ARM Linux on EP7xxx and CS89712 processors
+ *
+ * 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. See the file COPYING
+ * in the main directory of this archive for more details.
+ *
+ *
+ * Hardware:
+ *
+ * matrix scan keyboards based on EP7209,7211,7212,7312 and CS89712
+ * on chip keyboard scanner.
+ * Adaption for different machines is done in init function.
+ *
+ * Basic Function:
+ *
+ * Basicly the driver is interrupt driven. It sets all column drivers
+ * high. If any key is pressed, a interrupt occures. Now a seperate scan of
+ * each column is done. This scan is timer based, because we use a keyboard
+ * interface with decoupling capacitors (neccecary if you want to survive
+ * EMC compliance tests). Always one line is set high. When next timer event
+ * occures the scan data on port A are valid. This makes also sure, that no
+ * spurious keys are scanned. The kbd int on these CPU's is not deglitched!
+ * After scanning all columns, we switch back to int mode, if no key is
+ * pressed. If any is pressed we reschedule the scan within a programmable
+ * delay. If we would switch back to interrupt mode as long as a key is pressed,
+ * we come right back to the interrupt, because the int. is level triggered !
+ * The timer based scan of the seperate columns can also be done in one
+ * timer event (set fastscan to 1).
+ *
+ * Summary:
+ * The design of this keyboard controller chip is stupid at all !
+ *
+ * Matrix translation:
+ * The matrix translation table is based on standard XT scancodes. Maybe
+ * you have to adjust the KEYISPRINTABLE macro if you set other codes.
+ *
+ * HandyKey:
+ *
+ * On small matrix keyboards you don't have enough keys for operation.
+ * The intention was to implement a operation mode as it's used on handys.
+ * You can rotate trough four scancode levels and produce e.g. with a 4x3
+ * matrix 4*3*4 = 48 different keycodes. That's basicly enough for editing
+ * filenames or things like that. The HandyKey function takes care about
+ * nonprintable keys like cursors, backspace, del ...
+ * If a key is pressed and is a printable keycode, the code is put to the
+ * main keyboard handler and a cursor left is applied. If you press the same
+ * key again, the current character is deleted and the next level character
+ * is applied. (e.g. 1, a, b, c, 1 ....). If you press a different key, the
+ * driver applies cursor right, before processing the new key.
+ * The autocomplete feature moves the cursor right, if you do not press a
+ * key within a programmable time.
+ * If HandyKey is off, the keyboard behaviour is that of a standard keyboard
+ * HandyKey can be en/disabled from userspace with the proc/keyboard entry
+ *
+ * proc/keyboard:
+ *
+ * Read access gives back the actual state of the HandyKey function
+ * h:0 Disabled
+ * h:1 Enabled
+ * Write access has two functions. Changing the HandyKey mode and applying
+ * a different scancode translation table.
+ * Syntax is: h:0 disable Handykey
+ * h:1 enabled Handykey
+ * t:array[256] of bytes Transfer translation table
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/ptrace.h>
+#include <linux/signal.h>
+#include <linux/timer.h>
+#include <linux/tqueue.h>
+#include <linux/random.h>
+#include <linux/ctype.h>
+#include <linux/init.h>
+#include <linux/kbd_ll.h>
+#include <linux/kbd_kern.h>
+#include <linux/delay.h>
+#include <linux/proc_fs.h>
+
+#include <asm/bitops.h>
+#include <asm/keyboard.h>
+#include <asm/irq.h>
+#include <asm/hardware.h>
+#include <asm/uaccess.h>
+
+#include <asm/io.h>
+#include <asm/system.h>
+
+void clps711x_kbd_init_hw(void);
+
+/*
+ * Values for the keyboard column scan control register.
+ */
+#define KBSC_HI 0x0 /* All driven high */
+#define KBSC_LO 0x1 /* All driven low */
+#define KBSC_X 0x2 /* All high impedance */
+#define KBSC_COL0 0x8 /* Column 0 high, others high impedance */
+#define KBSC_COL1 0x9 /* Column 1 high, others high impedance */
+#define KBSC_COL2 0xa /* Column 2 high, others high impedance */
+#define KBSC_COL3 0xb /* Column 3 high, others high impedance */
+#define KBSC_COL4 0xc /* Column 4 high, others high impedance */
+#define KBSC_COL5 0xd /* Column 5 high, others high impedance */
+#define KBSC_COL6 0xe /* Column 6 high, others high impedance */
+#define KBSC_COL7 0xf /* Column 7 high, others high impedance */
+
+/*
+* Keycodes for cursor left/right and delete (used by HandyKey)
+*/
+#define KEYCODE_CLEFT 0x4b
+#define KEYCODE_CRIGHT 0x4d
+#define KEYCODE_DEL 0x53
+#define KEYISPRINTABLE(code) ( (code > 0x01 && code < 0x37 && code != 0x1c \
+ && code != 0x0e) || code == 0x39)
+
+/* Simple translation table for the SysRq keys */
+#ifdef CONFIG_MAGIC_SYSRQ
+unsigned char clps711x_kbd_sysrq_xlate[128] =
+ "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
+ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
+ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
+ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
+ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
+ "\r\000/"; /* 0x60 - 0x6f */
+#endif
+
+/*
+ * This table maps row/column keyboard matrix positions to XT scancodes.
+ * It's a default table, which can be overriden by writing to proc/keyboard
+ */
+#ifdef CONFIG_ARCH_AUTCPU12
+static unsigned char autcpu12_scancode[256] =
+{
+/* Column:
+ Row 0 1 2 3 4 5 6 7 */
+/* A0 */ 0x08, 0x09, 0x0a, 0x0e, 0x05, 0x06, 0x00, 0x00,
+/* A1 */ 0x07, 0x53, 0x02, 0x03, 0x04, 0x0f, 0x00, 0x00,
+/* A2 */ 0x0c, 0x0b, 0x33, 0x1c, 0xff, 0x4b, 0x00, 0x00,
+/* A3 */ 0x48, 0x50, 0x4d, 0x3b, 0x3c, 0x3d, 0x00, 0x00,
+/* A4 */ 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A5 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A6 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+/* A0 */ 0x1e, 0x20, 0x22, 0x0e, 0x24, 0x32, 0x00, 0x00,
+/* A1 */ 0x19, 0x53, 0x1f, 0x2f, 0x15, 0x0f, 0x00, 0x00,
+/* A2 */ 0x0c, 0x39, 0x34, 0x1c, 0xff, 0x4b, 0x00, 0x00,
+/* A3 */ 0x48, 0x50, 0x4d, 0x3b, 0x3c, 0x3d, 0x00, 0x00,
+/* A4 */ 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A5 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A6 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+/* A0 */ 0x30, 0x12, 0x23, 0x0e, 0x25, 0x31, 0x00, 0x00,
+/* A1 */ 0x10, 0x53, 0x14, 0x11, 0x2c, 0x0f, 0x00, 0x00,
+/* A2 */ 0x0c, 0x0b, 0x27, 0x1c, 0xff, 0x4b, 0x00, 0x00,
+/* A3 */ 0x48, 0x50, 0x4d, 0x3b, 0x3c, 0x3d, 0x00, 0x00,
+/* A4 */ 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A5 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A6 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+/* A0 */ 0x2e, 0x21, 0x17, 0x0e, 0x26, 0x18, 0x00, 0x00,
+/* A1 */ 0x13, 0x53, 0x16, 0x2D, 0x04, 0x0f, 0x00, 0x00,
+/* A2 */ 0x0c, 0x39, 0x35, 0x1c, 0xff, 0x4b, 0x00, 0x00,
+/* A3 */ 0x48, 0x50, 0x4d, 0x3b, 0x3c, 0x3d, 0x00, 0x00,
+/* A4 */ 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A5 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A6 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* A7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+#endif
+
+static int keys[8];
+static int new_keys[8];
+static int previous_keys[8];
+
+static int fastscan;
+static int scan_interval;
+static int scan_delay;
+static int last_column;
+static int key_is_pressed;
+
+static unsigned char *act_scancode;
+
+static struct kbd_handy_key {
+ int ena;
+ int code;
+ int shift;
+ int autocomplete;
+ unsigned long expires;
+ unsigned long delay;
+ unsigned char left;
+ unsigned char right;
+ unsigned char del;
+} khandy;
+
+static struct tq_struct kbd_process_task;
+static struct timer_list clps711x_kbd_timer;
+static struct timer_list clps711x_kbdhandy_timer;
+static struct proc_dir_entry *clps711x_keyboard_proc_entry = NULL;
+
+/*
+ * Translate a raw keycode to an XT keyboard scancode.
+ */
+static int clps711x_translate(unsigned char scancode, unsigned char *keycode,
+ char raw_mode)
+{
+ *keycode = act_scancode[scancode];
+ return 1;
+}
+
+/*
+* Initialize handykey structure
+* clear code, clear shift
+* scan scancode for cursor right/left and delete
+*/
+static void clps711x_handykey_init(void) {
+
+ int i;
+
+ khandy.ena = 0;
+ khandy.code = 0;
+ khandy.shift = 0;
+ khandy.autocomplete = 0;
+ for(i = 0; i < 64; i++) {
+ switch(act_scancode[i]) {
+ case KEYCODE_CLEFT: khandy.left = i; break;
+ case KEYCODE_CRIGHT: khandy.right = i; break;
+ case KEYCODE_DEL: khandy.del = i; break;
+ }
+ }
+}
+
+/*
+* Check for handy key and process it
+*/
+void inline clps711x_checkhandy(int col, int row) {
+
+ int scode, down;
+ unsigned char kcode;
+
+ scode = (row<<3) + col;
+ down = keys[col]>>row & 0x01;
+ kcode = act_scancode[scode];
+
+ if (!khandy.ena) {
+ if (khandy.code) {
+ handle_scancode(khandy.right,1);
+ handle_scancode(khandy.right,0);
+ }
+ khandy.code = 0;
+ khandy.shift = 0;
+ khandy.autocomplete = 0;
+ }
+
+ if(!kcode)
+ return;
+
+ if (!down || !khandy.ena) {
+ if (khandy.ena && KEYISPRINTABLE(act_scancode[scode]))
+ khandy.autocomplete = 1;
+ else
+ handle_scancode(scode + khandy.shift, down);
+ return;
+ }
+
+ khandy.autocomplete = 0;
+ if (KEYISPRINTABLE(kcode)) {
+ if (khandy.code) {
+ if(khandy.code == (scode|0x100)) {
+ handle_scancode(khandy.del,1);
+ handle_scancode(khandy.del,0);
+ khandy.shift = khandy.shift < 3*64 ? khandy.shift + 64 : 0 ;
+ } else {
+ handle_scancode(khandy.right,1);
+ handle_scancode(khandy.right,0);
+ khandy.shift = 0;
+ }
+ }
+ handle_scancode(scode + khandy.shift, 1);
+ handle_scancode(scode + khandy.shift, 0);
+ khandy.code = scode | 0x100;
+ handle_scancode(khandy.left,1);
+ handle_scancode(khandy.left,0);
+ } else {
+ if (khandy.code) {
+ khandy.code = 0;
+ handle_scancode(khandy.right,1);
+ handle_scancode(khandy.right,0);
+ }
+ khandy.shift = 0;
+ handle_scancode(scode, down);
+ }
+}
+
+
+/*
+ * Process the new key data
+ */
+static void clps711x_kbd_process(void* data)
+{
+ int col,row,res;
+
+ for (col = 0; col < 8; col++) {
+ if (( res = previous_keys[col] ^ keys[col]) == 0)
+ continue;
+ for(row = 0; row < 8; row++) {
+ if ( ((res >> row) & 0x01) != 0)
+ clps711x_checkhandy(col,row);
+ }
+ }
+ /* Update the state variables. */
+ memcpy(previous_keys, keys, 8 * sizeof(int));
+
+ /* reschedule, if autocomplete pending */
+ if (khandy.autocomplete) {
+ khandy.expires = jiffies + khandy.delay;
+ mod_timer(&clps711x_kbdhandy_timer,khandy.expires);
+ }
+
+}
+
+static char clps711x_unexpected_up(unsigned char scancode)
+{
+ return 0200;
+}
+
+/*
+* Handle timer event, for autocomplete function
+* Reschedule keyboard process task
+*/
+static void clps711x_kbdhandy_timeout(unsigned long data)
+{
+ if(khandy.autocomplete) {
+ khandy.code = 0;
+ khandy.shift = 0;
+ khandy.autocomplete = 0;
+ handle_scancode(khandy.right,1);
+ handle_scancode(khandy.right,0);
+ }
+}
+
+/*
+* Handle timer event, while in pollmode
+*/
+static void clps711x_kbd_timeout(unsigned long data)
+{
+ int i;
+ unsigned long flags;
+ /*
+ * read bits of actual column or all columns in fastscan-mode
+ */
+ for (i = 0; i < 8; i++) {
+ new_keys[last_column - KBSC_COL0] = clps_readb(PADR) & 0xff;
+ key_is_pressed |= new_keys[last_column - KBSC_COL0];
+ last_column = last_column < KBSC_COL7 ? last_column + 1 : KBSC_COL0;
+ local_irq_save(flags);
+ clps_writel( (clps_readl(SYSCON1) & ~SYSCON1_KBDSCANMASK)
+ | last_column, SYSCON1);
+ local_irq_restore(flags);
+ /*
+ * For fastscan, apply a short delay to settle scanlines
+ * else break and wait for next timeout
+ */
+ if (fastscan)
+ udelay(5);
+ else
+ break;
+ }
+
+ if (key_is_pressed)
+ khandy.autocomplete = 0;
+
+ /*
+ * switch to interupt mode, if all columns scanned and no key pressed
+ * else reschedule scan
+ */
+ if (last_column == KBSC_COL0) {
+ if (!key_is_pressed) {
+ local_irq_save(flags);
+ clps_writel( (clps_readl(SYSCON1) & ~SYSCON1_KBDSCANMASK)
+ | KBSC_HI, SYSCON1);
+ local_irq_restore(flags);
+ clps_writel(0,KBDEOI);
+ enable_irq(IRQ_KBDINT);
+ } else {
+ clps711x_kbd_timer.expires = jiffies + scan_interval;
+ add_timer(&clps711x_kbd_timer);
+ }
+ key_is_pressed = 0;
+ memcpy(keys, new_keys, 8 * sizeof(int));
+ for (i = 0; i < 8; i++) {
+ if (previous_keys[i] != keys[i]) {
+ queue_task(&kbd_process_task, &tq_timer);
+ return;
+ }
+ }
+ } else {
+ clps711x_kbd_timer.expires = jiffies + scan_delay;
+ add_timer(&clps711x_kbd_timer);
+ }
+}
+
+/*
+* Keyboard interrupt, change to scheduling mode
+*/
+static void clps711x_kbd_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+
+#ifdef CONFIG_VT
+ kbd_pt_regs = regs;
+#endif
+ disable_irq(IRQ_KBDINT);
+ khandy.autocomplete = 0;
+ clps_writel( (clps_readl(SYSCON1) & ~SYSCON1_KBDSCANMASK)
+ | KBSC_COL0, SYSCON1);
+ clps711x_kbd_timer.expires = jiffies + scan_delay;
+ add_timer(&clps711x_kbd_timer);
+}
+
+
+static int clps711x_kbd_proc_keyboard_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ if (count < 2)
+ return -EINVAL;
+
+ return sprintf(page,"h:%d\n",khandy.ena);
+}
+
+static int clps711x_kbd_proc_keyboard_write(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ unsigned char buf[260];
+
+ if (count < 3|| count > 258)
+ return -EINVAL;
+ if (copy_from_user(buf, buffer, count))
+ return -EFAULT;
+ if (buf[1] != ':')
+ return -EINVAL;
+
+ if (buf[0] == 'h') {
+ switch (buf[2]) {
+ case '0':
+ case '1':
+ case '2': khandy.ena = buf[2]-'0'; return count;
+ }
+ }
+
+ if (buf[0] == 't' && count == 258) {
+ memcpy(act_scancode,buf+2,256);
+ /* rescan cursor left/right and del */
+ clps711x_handykey_init();
+ return count;
+ }
+
+ return -EINVAL;
+}
+
+
+/*
+ * Initialize the keyboard hardware.
+ * Set all columns high
+ * Install interrupt handler
+ *
+ * Machine dependent parameters:
+ *
+ * fastscan: 0 = timer based scan for each column
+ * 1 = full scan is done in one timer event
+ * scan_delay: time between column scans
+ * setup even if you use fastscan (leeds to timer mode)
+ * scan_interval: time between full scans
+ * handy.delay: timeout before last entry get's automatically valid
+ *
+ */
+void __init clps711x_kbd_init_hw(void)
+{
+
+ /*
+ * put here machine dependent init stuff
+ */
+ if (machine_is_autcpu12()) {
+ fastscan = 0;
+ scan_interval = 50*HZ/1000;
+ scan_delay = 20*HZ/1000;
+ khandy.delay = 750*HZ/1000;
+ act_scancode = autcpu12_scancode;
+ } else {
+ printk("No initialization, keyboard killed\n");
+ return;
+ }
+
+ last_column = KBSC_COL0;
+ key_is_pressed = 0;
+
+ clps711x_handykey_init();
+
+ /* Register the /proc entry */
+ clps711x_keyboard_proc_entry = create_proc_entry("keyboard", 0444,
+ &proc_root);
+ if (clps711x_keyboard_proc_entry == NULL)
+ printk("Couldn't create the /proc entry for the keyboard\n");
+ else {
+ clps711x_keyboard_proc_entry->read_proc =
+ &clps711x_kbd_proc_keyboard_read;
+ clps711x_keyboard_proc_entry->write_proc =
+ &clps711x_kbd_proc_keyboard_write;
+ }
+
+ /* Initialize the matrix processing task. */
+ k_translate = clps711x_translate;
+ k_unexpected_up = clps711x_unexpected_up;
+ kbd_process_task.routine = clps711x_kbd_process;
+ kbd_process_task.data = 0;
+
+ /* Setup the timer for keyboard polling, after kbd int */
+ init_timer(&clps711x_kbd_timer);
+ clps711x_kbd_timer.function = clps711x_kbd_timeout;
+ clps711x_kbd_timer.data = 0;
+ init_timer(&clps711x_kbdhandy_timer);
+ clps711x_kbdhandy_timer.function = clps711x_kbdhandy_timeout;
+ clps711x_kbdhandy_timer.data = 1;
+
+ /* Initialise scan hardware, request int */
+ clps_writel( (clps_readl(SYSCON1) & ~SYSCON1_KBDSCANMASK)
+ | KBSC_HI, SYSCON1);
+ request_irq(IRQ_KBDINT, clps711x_kbd_int, 0,"keyboard", NULL);
+
+ printk("clps711x keyboard init done\n");
+
+}
diff -urN linux-2.4.26/drivers/char/console.c linux-2.4.26-vrs1/drivers/char/console.c
--- linux-2.4.26/drivers/char/console.c 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/char/console.c 2004-01-14 21:38:59.000000000 +0000
@@ -72,8 +72,14 @@
*
* Removed console_lock, enabled interrupts across all console operations
* 13 March 2001, Andrew Morton
+ *
+ * Split out con_write_ctrl_* functions from do_con_write & changed
+ * vc_state to function pointer
+ * by Russell King <rmk@arm.linux.org.uk>, July 1998
*/
+#define CONSOLE_WIP
+
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/tty.h>
@@ -228,7 +234,7 @@
static inline unsigned short *screenpos(int currcons, int offset, int viewed)
{
unsigned short *p;
-
+
if (!viewed)
p = (unsigned short *)(origin + offset);
else if (!sw->con_screen_pos)
@@ -729,7 +735,7 @@
else {
unsigned short *p = (unsigned short *) kmalloc(ss, GFP_USER);
if (!p) {
- for (i = first; i < currcons; i++)
+ for (i = first; i< currcons; i++)
if (newscreens[i])
kfree(newscreens[i]);
return -ENOMEM;
@@ -847,7 +853,7 @@
/* the default colour table, for VGA+ colour systems */
int default_red[] = {0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,
0x55,0xff,0x55,0xff,0x55,0xff,0x55,0xff};
-int default_grn[] = {0x00,0x00,0xaa,0x55,0x00,0x00,0xaa,0xaa,
+int default_grn[] = {0x00,0x00,0xaa,0xaa,0x00,0x00,0xaa,0xaa,
0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff};
int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,
0x55,0x55,0x55,0x55,0xff,0xff,0xff,0xff};
@@ -1393,6 +1399,19 @@
need_wrap = 0;
}
+static int con_write_ctrl_ESnormal(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESesc(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESnonstd(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESpalette(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESsquare(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESgetpars(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESgotpars(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESpercent(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESfunckey(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_EShash(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESsetG0(int, struct tty_struct *, unsigned int);
+static int con_write_ctrl_ESsetG1(int, struct tty_struct *, unsigned int);
+
enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,
ESpalette };
@@ -1402,7 +1421,7 @@
{
top = 0;
bottom = video_num_lines;
- vc_state = ESnormal;
+ vc_state = con_write_ctrl_ESnormal;
ques = 0;
translate = set_translate(LAT1_MAP,currcons);
G0_charset = LAT1_MAP;
@@ -1500,328 +1519,426 @@
disp_ctrl = 0;
return;
case 24: case 26:
- vc_state = ESnormal;
+ vc_state = con_write_ctrl_ESnormal;
return;
case 27:
- vc_state = ESesc;
+ vc_state = con_write_ctrl_ESesc;
return;
case 127:
del(currcons);
return;
case 128+27:
- vc_state = ESsquare;
+ vc_state = con_write_ctrl_ESsquare;
return;
}
- switch(vc_state) {
- case ESesc:
- vc_state = ESnormal;
- switch (c) {
- case '[':
- vc_state = ESsquare;
- return;
- case ']':
- vc_state = ESnonstd;
- return;
- case '%':
- vc_state = ESpercent;
- return;
- case 'E':
- cr(currcons);
- lf(currcons);
- return;
- case 'M':
- ri(currcons);
- return;
- case 'D':
- lf(currcons);
- return;
- case 'H':
- tab_stop[x >> 5] |= (1 << (x & 31));
- return;
- case 'Z':
- respond_ID(tty);
- return;
- case '7':
- save_cur(currcons);
- return;
- case '8':
- restore_cur(currcons);
- return;
- case '(':
- vc_state = ESsetG0;
- return;
- case ')':
- vc_state = ESsetG1;
- return;
- case '#':
- vc_state = EShash;
- return;
- case 'c':
- reset_terminal(currcons,1);
- return;
- case '>': /* Numeric keypad */
- clr_kbd(kbdapplic);
- return;
- case '=': /* Appl. keypad */
- set_kbd(kbdapplic);
- return;
+ vc_state(currcons, tty, c);
+}
+
+static int con_write_utf(int currcons, int c)
+{
+ unsigned int chr;
+
+ /* Combine UTF-8 into Unicode */
+ /* Incomplete characters silently ignored */
+ if (c < 0x80) {
+ utf_count = 0;
+ return c;
+ }
+
+ if (utf_count > 0 && (c & 0xc0) == 0x80) {
+ chr = (utf_char << 6) | (c & 0x3f);
+ utf_count--;
+ if (utf_count == 0)
+ return chr;
+ } else {
+ unsigned int count;
+ if ((c & 0xe0) == 0xc0) {
+ count = 1;
+ chr = (c & 0x1f);
+ } else if ((c & 0xf0) == 0xe0) {
+ count = 2;
+ chr = (c & 0x0f);
+ } else if ((c & 0xf8) == 0xf0) {
+ count = 3;
+ chr = (c & 0x07);
+ } else if ((c & 0xfc) == 0xf8) {
+ count = 4;
+ chr = (c & 0x03);
+ } else if ((c & 0xfe) == 0xfc) {
+ count = 5;
+ chr = (c & 0x01);
+ } else {
+ count = 0;
+ chr = 0;
}
- return;
- case ESnonstd:
- if (c=='P') { /* palette escape sequence */
- for (npar=0; npar<NPAR; npar++)
- par[npar] = 0 ;
- npar = 0 ;
- vc_state = ESpalette;
- return;
- } else if (c=='R') { /* reset palette */
- reset_palette(currcons);
- vc_state = ESnormal;
- } else
- vc_state = ESnormal;
- return;
- case ESpalette:
- if ( (c>='0'&&c<='9') || (c>='A'&&c<='F') || (c>='a'&&c<='f') ) {
- par[npar++] = (c>'9' ? (c&0xDF)-'A'+10 : c-'0') ;
- if (npar==7) {
- int i = par[0]*3, j = 1;
- palette[i] = 16*par[j++];
- palette[i++] += par[j++];
- palette[i] = 16*par[j++];
- palette[i++] += par[j++];
- palette[i] = 16*par[j++];
- palette[i] += par[j];
- set_palette(currcons);
- vc_state = ESnormal;
- }
- } else
- vc_state = ESnormal;
- return;
- case ESsquare:
- for(npar = 0 ; npar < NPAR ; npar++)
- par[npar] = 0;
- npar = 0;
- vc_state = ESgetpars;
- if (c == '[') { /* Function key */
- vc_state=ESfunckey;
- return;
+ utf_count = count;
+ }
+
+ utf_char = chr;
+ return -1;
+}
+
+static int con_write_ctrl_ESnormal(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ return 0;
+}
+
+static int con_write_ctrl_ESesc(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ vc_state = con_write_ctrl_ESnormal;
+ switch (c) {
+ case '[':
+ vc_state = con_write_ctrl_ESsquare;
+ break;
+ case ']':
+ vc_state = con_write_ctrl_ESnonstd;
+ break;
+ case '%':
+ vc_state = con_write_ctrl_ESpercent;
+ break;
+ case 'E':
+ cr(currcons);
+ lf(currcons);
+ break;
+ case 'M':
+ ri(currcons);
+ break;
+ case 'D':
+ lf(currcons);
+ break;
+ case 'H':
+ tab_stop[x >> 5] |= (1 << (x & 31));
+ break;
+ case 'Z':
+ respond_ID(tty);
+ break;
+ case '7':
+ save_cur(currcons);
+ break;
+ case '8':
+ restore_cur(currcons);
+ return 1;
+ case '(':
+ vc_state = con_write_ctrl_ESsetG0;
+ break;
+ case ')':
+ vc_state = con_write_ctrl_ESsetG1;
+ break;
+ case '#':
+ vc_state = con_write_ctrl_EShash;
+ break;
+ case 'c':
+ reset_terminal(currcons,1);
+ return 1;
+ case '>': /* Numeric keypad */
+ clr_kbd(kbdapplic);
+ break;
+ case '=': /* Appl. keypad */
+ set_kbd(kbdapplic);
+ break;
+ }
+ return 0;
+}
+
+static int con_write_ctrl_ESnonstd(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ switch (c) {
+ case 'P': /* palette escape sequence */
+ for (npar=0; npar<NPAR; npar++)
+ par[npar] = 0 ;
+ npar = 0 ;
+ vc_state = con_write_ctrl_ESpalette;
+ break;
+ case 'R': /* reset palette */
+ reset_palette (currcons);
+ default:
+ vc_state = con_write_ctrl_ESnormal;
+ }
+ return 0;
+}
+
+static int con_write_ctrl_ESpalette(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ if ( (c>='0'&&c<='9') || (c>='A'&&c<='F') || (c>='a'&&c<='f') ) {
+ par[npar++] = (c>'9' ? (c&0xDF)-'A'+10 : c-'0') ;
+ if (npar==7) {
+ int i = par[0]*3, j = 1;
+ palette[i] = 16*par[j++];
+ palette[i++] += par[j++];
+ palette[i] = 16*par[j++];
+ palette[i++] += par[j++];
+ palette[i] = 16*par[j++];
+ palette[i] += par[j];
+ set_palette(currcons);
+ vc_state = con_write_ctrl_ESnormal;
}
- ques = (c=='?');
- if (ques)
- return;
- case ESgetpars:
- if (c==';' && npar<NPAR-1) {
- npar++;
- return;
- } else if (c>='0' && c<='9') {
- par[npar] *= 10;
- par[npar] += c-'0';
- return;
- } else vc_state=ESgotpars;
- case ESgotpars:
- vc_state = ESnormal;
- switch(c) {
- case 'h':
- set_mode(currcons,1);
- return;
- case 'l':
- set_mode(currcons,0);
- return;
- case 'c':
- if (ques) {
- if (par[0])
- cursor_type = par[0] | (par[1]<<8) | (par[2]<<16);
- else
- cursor_type = CUR_DEFAULT;
- return;
- }
- break;
- case 'm':
- if (ques) {
- clear_selection();
- if (par[0])
- complement_mask = par[0]<<8 | par[1];
- else
- complement_mask = s_complement_mask;
- return;
- }
- break;
- case 'n':
- if (!ques) {
- if (par[0] == 5)
- status_report(tty);
- else if (par[0] == 6)
- cursor_report(currcons,tty);
- }
- return;
+ } else
+ vc_state = con_write_ctrl_ESnormal;
+ return 0;
+}
+
+static int con_write_ctrl_ESsquare(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ for(npar = 0 ; npar < NPAR ; npar++)
+ par[npar] = 0;
+ npar = 0;
+ vc_state = con_write_ctrl_ESgetpars;
+ if (c == '[') { /* Function key */
+ vc_state = con_write_ctrl_ESfunckey;
+ return 0;
+ }
+ ques = (c=='?');
+ if (ques)
+ return 0;
+ return con_write_ctrl_ESgetpars(currcons, tty, c);
+}
+
+static int con_write_ctrl_ESgetpars(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ if (c==';' && npar<NPAR-1) {
+ npar++;
+ return 0;
+ } else if (c>='0' && c<='9') {
+ par[npar] *= 10;
+ par[npar] += c-'0';
+ return 0;
+ } else vc_state = con_write_ctrl_ESgotpars;
+ return con_write_ctrl_ESgotpars(currcons, tty, c);
+}
+
+static int con_write_ctrl_ESgotpars(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ vc_state = con_write_ctrl_ESnormal;
+ switch(c) {
+ case 'h':
+ set_mode(currcons,1);
+ return 0;
+ case 'l':
+ set_mode(currcons,0);
+ return 0;
+ case 'c':
+ if (ques) {
+ if (par[0])
+ cursor_type = par[0] | (par[1]<<8) | (par[2]<<16);
+ else
+ cursor_type = CUR_DEFAULT;
+ return 0;
}
+ break;
+ case 'm':
if (ques) {
- ques = 0;
- return;
+ clear_selection();
+ if (par[0])
+ complement_mask = par[0]<<8 | par[1];
+ else
+ complement_mask = s_complement_mask;
+ return 0;
}
- switch(c) {
- case 'G': case '`':
- if (par[0]) par[0]--;
- gotoxy(currcons,par[0],y);
- return;
- case 'A':
- if (!par[0]) par[0]++;
- gotoxy(currcons,x,y-par[0]);
- return;
- case 'B': case 'e':
- if (!par[0]) par[0]++;
- gotoxy(currcons,x,y+par[0]);
- return;
- case 'C': case 'a':
- if (!par[0]) par[0]++;
- gotoxy(currcons,x+par[0],y);
- return;
- case 'D':
- if (!par[0]) par[0]++;
- gotoxy(currcons,x-par[0],y);
- return;
- case 'E':
- if (!par[0]) par[0]++;
- gotoxy(currcons,0,y+par[0]);
- return;
- case 'F':
- if (!par[0]) par[0]++;
- gotoxy(currcons,0,y-par[0]);
- return;
- case 'd':
- if (par[0]) par[0]--;
- gotoxay(currcons,x,par[0]);
- return;
- case 'H': case 'f':
- if (par[0]) par[0]--;
- if (par[1]) par[1]--;
- gotoxay(currcons,par[1],par[0]);
- return;
- case 'J':
- csi_J(currcons,par[0]);
- return;
- case 'K':
- csi_K(currcons,par[0]);
- return;
- case 'L':
- csi_L(currcons,par[0]);
- return;
- case 'M':
- csi_M(currcons,par[0]);
- return;
- case 'P':
- csi_P(currcons,par[0]);
- return;
- case 'c':
- if (!par[0])
- respond_ID(tty);
- return;
- case 'g':
- if (!par[0])
- tab_stop[x >> 5] &= ~(1 << (x & 31));
- else if (par[0] == 3) {
- tab_stop[0] =
- tab_stop[1] =
- tab_stop[2] =
- tab_stop[3] =
- tab_stop[4] = 0;
- }
- return;
- case 'm':
- csi_m(currcons);
- return;
- case 'q': /* DECLL - but only 3 leds */
- /* map 0,1,2,3 to 0,1,2,4 */
- if (par[0] < 4)
- setledstate(kbd_table + currcons,
- (par[0] < 3) ? par[0] : 4);
- return;
- case 'r':
- if (!par[0])
- par[0]++;
- if (!par[1])
- par[1] = video_num_lines;
- /* Minimum allowed region is 2 lines */
- if (par[0] < par[1] &&
- par[1] <= video_num_lines) {
- top=par[0]-1;
- bottom=par[1];
- gotoxay(currcons,0,0);
- }
- return;
- case 's':
- save_cur(currcons);
- return;
- case 'u':
- restore_cur(currcons);
- return;
- case 'X':
- csi_X(currcons, par[0]);
- return;
- case '@':
- csi_at(currcons,par[0]);
- return;
- case ']': /* setterm functions */
- setterm_command(currcons);
- return;
+ break;
+ case 'n':
+ if (!ques) {
+ if (par[0] == 5)
+ status_report(tty);
+ else if (par[0] == 6)
+ cursor_report(currcons,tty);
}
- return;
- case ESpercent:
- vc_state = ESnormal;
- switch (c) {
- case '@': /* defined in ISO 2022 */
- utf = 0;
- return;
- case 'G': /* prelim official escape code */
- case '8': /* retained for compatibility */
- utf = 1;
- return;
+ return 0;
+ }
+ if (ques) {
+ ques = 0;
+ return 0;
+ }
+ switch(c) {
+ case 'G': case '`':
+ if (par[0]) par[0]--;
+ gotoxy(currcons,par[0],y);
+ break;
+ case 'A':
+ if (!par[0]) par[0]++;
+ gotoxy(currcons,x,y-par[0]);
+ break;
+ case 'B': case 'e':
+ if (!par[0]) par[0]++;
+ gotoxy(currcons,x,y+par[0]);
+ break;
+ case 'C': case 'a':
+ if (!par[0]) par[0]++;
+ gotoxy(currcons,x+par[0],y);
+ break;
+ case 'D':
+ if (!par[0]) par[0]++;
+ gotoxy(currcons,x-par[0],y);
+ break;
+ case 'E':
+ if (!par[0]) par[0]++;
+ gotoxy(currcons,0,y+par[0]);
+ break;
+ case 'F':
+ if (!par[0]) par[0]++;
+ gotoxy(currcons,0,y-par[0]);
+ break;
+ case 'd':
+ if (par[0]) par[0]--;
+ gotoxay(currcons,x,par[0]);
+ break;
+ case 'H': case 'f':
+ if (par[0]) par[0]--;
+ if (par[1]) par[1]--;
+ gotoxay(currcons,par[1],par[0]);
+ break;
+ case 'J':
+ csi_J(currcons,par[0]);
+ break;
+ case 'K':
+ csi_K(currcons,par[0]);
+ break;
+ case 'L':
+ csi_L(currcons,par[0]);
+ break;
+ case 'M':
+ csi_M(currcons,par[0]);
+ break;
+ case 'P':
+ csi_P(currcons,par[0]);
+ break;
+ case 'c':
+ if (!par[0])
+ respond_ID(tty);
+ break;
+ case 'g':
+ if (!par[0])
+ tab_stop[x >> 5] &= ~(1 << (x & 31));
+ else if (par[0] == 3) {
+ tab_stop[0] =
+ tab_stop[1] =
+ tab_stop[2] =
+ tab_stop[3] =
+ tab_stop[4] = 0;
}
- return;
- case ESfunckey:
- vc_state = ESnormal;
- return;
- case EShash:
- vc_state = ESnormal;
- if (c == '8') {
- /* DEC screen alignment test. kludge :-) */
- video_erase_char =
- (video_erase_char & 0xff00) | 'E';
- csi_J(currcons, 2);
- video_erase_char =
- (video_erase_char & 0xff00) | ' ';
- do_update_region(currcons, origin, screenbuf_size/2);
+ break;
+ case 'm':
+ csi_m(currcons);
+ return 1;
+ case 'q': /* DECLL - but only 3 leds */
+ /* map 0,1,2,3 to 0,1,2,4 */
+ if (par[0] < 4)
+ setledstate(kbd_table + currcons,
+ (par[0] < 3) ? par[0] : 4);
+ break;
+ case 'r':
+ if (!par[0])
+ par[0]++;
+ if (!par[1])
+ par[1] = video_num_lines;
+ /* Minimum allowed region is 2 lines */
+ if (par[0] < par[1] &&
+ par[1] <= video_num_lines) {
+ top=par[0]-1;
+ bottom=par[1];
+ gotoxay(currcons,0,0);
}
- return;
- case ESsetG0:
- if (c == '0')
- G0_charset = GRAF_MAP;
- else if (c == 'B')
- G0_charset = LAT1_MAP;
- else if (c == 'U')
- G0_charset = IBMPC_MAP;
- else if (c == 'K')
- G0_charset = USER_MAP;
- if (charset == 0)
- translate = set_translate(G0_charset,currcons);
- vc_state = ESnormal;
- return;
- case ESsetG1:
- if (c == '0')
- G1_charset = GRAF_MAP;
- else if (c == 'B')
- G1_charset = LAT1_MAP;
- else if (c == 'U')
- G1_charset = IBMPC_MAP;
- else if (c == 'K')
- G1_charset = USER_MAP;
- if (charset == 1)
- translate = set_translate(G1_charset,currcons);
- vc_state = ESnormal;
- return;
- default:
- vc_state = ESnormal;
+ break;
+ case 's':
+ save_cur(currcons);
+ break;
+ case 'u':
+ restore_cur(currcons);
+ return 1;
+ case 'X':
+ csi_X(currcons, par[0]);
+ break;
+ case '@':
+ csi_at(currcons,par[0]);
+ break;
+ case ']': /* setterm functions */
+ setterm_command(currcons);
+ break;
+ }
+ return 0;
+}
+
+static int con_write_ctrl_ESpercent(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ vc_state = con_write_ctrl_ESnormal;
+ switch (c) {
+ case '@': /* defined in ISO 2022 */
+ utf = 0;
+ break;
+ case 'G': /* prelim official escape code */
+ case '8': /* retained for compatibility */
+ utf = 1;
+ break;
+ }
+ return 0;
+}
+
+static int con_write_ctrl_ESfunckey(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ vc_state = con_write_ctrl_ESnormal;
+ return 0;
+}
+
+static int con_write_ctrl_EShash(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ vc_state = con_write_ctrl_ESnormal;
+ if (c == '8') {
+ /* DEC screen alignment test. kludge :-) */
+ video_erase_char =
+ (video_erase_char & 0xff00) | 'E';
+ csi_J(currcons, 2);
+ video_erase_char =
+ (video_erase_char & 0xff00) | ' ';
+ do_update_region(currcons, origin, screenbuf_size/2);
+ }
+ return 0;
+}
+
+static int con_write_ctrl_ESsetG0(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ switch (c) {
+ case '0':
+ G0_charset = GRAF_MAP;
+ break;
+ case 'B':
+ G0_charset = LAT1_MAP;
+ break;
+ case 'U':
+ G0_charset = IBMPC_MAP;
+ break;
+ case 'K':
+ G0_charset = USER_MAP;
+ break;
+ }
+ if (charset == 0) {
+ translate = set_translate(G0_charset,currcons);
+ return 1;
+ }
+ vc_state = con_write_ctrl_ESnormal;
+ return 0;
+}
+
+static int con_write_ctrl_ESsetG1(int currcons, struct tty_struct *tty, unsigned int c)
+{
+ switch (c) {
+ case '0':
+ G1_charset = GRAF_MAP;
+ break;
+ case 'B':
+ G1_charset = LAT1_MAP;
+ break;
+ case 'U':
+ G1_charset = IBMPC_MAP;
+ break;
+ case 'K':
+ G1_charset = USER_MAP;
+ break;
+ }
+ if (charset == 1) {
+ translate = set_translate(G1_charset,currcons);
+ return 1;
}
+ vc_state = con_write_ctrl_ESnormal;
+ return 0;
}
/* This is a temporary buffer used to prepare a tty console write
@@ -1855,7 +1972,7 @@
unsigned long draw_from = 0, draw_to = 0;
struct vt_struct *vt = (struct vt_struct *)tty->driver_data;
u16 himask, charmask;
- const unsigned char *orig_buf = NULL;
+ const unsigned char *orig_buf;
int orig_count;
if (in_interrupt())
@@ -1913,42 +2030,12 @@
count--;
if (utf) {
- /* Combine UTF-8 into Unicode */
- /* Incomplete characters silently ignored */
- if(c > 0x7f) {
- if (utf_count > 0 && (c & 0xc0) == 0x80) {
- utf_char = (utf_char << 6) | (c & 0x3f);
- utf_count--;
- if (utf_count == 0)
- tc = c = utf_char;
- else continue;
- } else {
- if ((c & 0xe0) == 0xc0) {
- utf_count = 1;
- utf_char = (c & 0x1f);
- } else if ((c & 0xf0) == 0xe0) {
- utf_count = 2;
- utf_char = (c & 0x0f);
- } else if ((c & 0xf8) == 0xf0) {
- utf_count = 3;
- utf_char = (c & 0x07);
- } else if ((c & 0xfc) == 0xf8) {
- utf_count = 4;
- utf_char = (c & 0x03);
- } else if ((c & 0xfe) == 0xfc) {
- utf_count = 5;
- utf_char = (c & 0x01);
- } else
- utf_count = 0;
+ tc = con_write_utf(currcons, c);
+ if (tc < 0)
continue;
- }
- } else {
- tc = c;
- utf_count = 0;
- }
- } else { /* no utf */
- tc = translate[toggle_meta ? (c|0x80) : c];
- }
+ c = tc;
+ } else /* no utf */
+ tc = translate[toggle_meta ? (c|0x80) : c];
/* If the original code was a control character we
* only allow a glyph to be displayed if the code is
@@ -1966,7 +2053,7 @@
&& (c != 127 || disp_ctrl)
&& (c != 128+27);
- if (vc_state == ESnormal && ok) {
+ if (vc_state == con_write_ctrl_ESnormal && ok) {
/* Now try to find out how to display it */
tc = conv_uni_to_pc(vc_cons[currcons].d, tc);
if ( tc == -4 ) {
@@ -2112,7 +2199,7 @@
if (kmsg_redirect && vc_cons_allocated(kmsg_redirect - 1))
currcons = kmsg_redirect - 1;
- /* read `x' only after setting currecons properly (otherwise
+ /* read `x' only after setting currcons properly (otherwise
the `x' macro will read the x of the foreground console). */
myx = x;
@@ -2475,8 +2562,8 @@
console_driver.init_termios = tty_std_termios;
console_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
/* Tell tty_register_driver() to skip consoles because they are
- * registered before kmalloc() is ready. We'll patch them in later.
- * See comments at console_init(); see also con_init_devfs().
+ * registered before kmalloc() is ready. We'll patch them in later.
+ * See comments at console_init(); see also con_init_devfs().
*/
console_driver.flags |= TTY_DRIVER_NO_DEVFS;
console_driver.refcount = &console_refcount;
@@ -2719,7 +2806,7 @@
if (console_blank_hook && console_blank_hook(1))
return;
- if (vesa_blank_mode)
+ if (vesa_blank_mode)
sw->con_blank(vc_cons[currcons].d, vesa_blank_mode + 1);
}
@@ -2893,7 +2980,7 @@
if (!op->height) { /* Need to guess font height [compat] */
int h, i;
u8 *charmap = op->data, tmp;
-
+
/* If from KDFONTOP ioctl, don't allow things which can be done in userland,
so that we can get rid of this soon */
if (!(op->flags & KD_FONT_FLAG_OLD))
@@ -2940,18 +3027,18 @@
op->data = old_op.data;
if (!rc && !set) {
int c = (op->width+7)/8 * 32 * op->charcount;
-
+
if (op->data && op->charcount > old_op.charcount)
rc = -ENOSPC;
if (!(op->flags & KD_FONT_FLAG_OLD)) {
- if (op->width > old_op.width ||
+ if (op->width > old_op.width ||
op->height > old_op.height)
rc = -ENOSPC;
} else {
if (op->width != 8)
rc = -EIO;
else if ((old_op.height && op->height > old_op.height) ||
- op->height > 32)
+ op->height > 32)
rc = -ENOSPC;
}
if (!rc && op->data && copy_to_user(op->data, temp, c))
diff -urN linux-2.4.26/drivers/char/ds1307.c linux-2.4.26-vrs1/drivers/char/ds1307.c
--- linux-2.4.26/drivers/char/ds1307.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/ds1307.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,604 @@
+/*
+ * ds1307.c
+ *
+ * Device driver for Dallas Semiconductor's Real Time Controller DS1307.
+ *
+ * Copyright (C) 2002 Intrinsyc Software Inc.
+ *
+ * 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/config.h>
+#include <linux/module.h>
+#include <linux/version.h>
+
+#include <linux/kernel.h>
+#include <linux/poll.h>
+#include <linux/i2c.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/rtc.h>
+#include <linux/string.h>
+#include <linux/miscdevice.h>
+#include <linux/proc_fs.h>
+
+#include "ds1307.h"
+
+#define DEBUG 0
+
+#if DEBUG
+static unsigned int rtc_debug = DEBUG;
+#else
+#define rtc_debug 0 /* gcc will remove all the debug code for us */
+#endif
+
+static unsigned short slave_address = DS1307_I2C_SLAVE_ADDR;
+
+struct i2c_driver ds1307_driver;
+struct i2c_client *ds1307_i2c_client = 0;
+
+static unsigned short ignore[] = { I2C_CLIENT_END };
+static unsigned short normal_addr[] = { DS1307_I2C_SLAVE_ADDR, I2C_CLIENT_END };
+
+static struct i2c_client_address_data addr_data = {
+ normal_i2c: normal_addr,
+ normal_i2c_range: ignore,
+ probe: ignore,
+ probe_range: ignore,
+ ignore: ignore,
+ ignore_range: ignore,
+ force: ignore,
+};
+
+static int ds1307_rtc_ioctl( struct inode *, struct file *, unsigned int, unsigned long);
+static int ds1307_rtc_open(struct inode *inode, struct file *file);
+static int ds1307_rtc_release(struct inode *inode, struct file *file);
+
+static struct file_operations rtc_fops = {
+ owner: THIS_MODULE,
+ ioctl: ds1307_rtc_ioctl,
+ open: ds1307_rtc_open,
+ release: ds1307_rtc_release,
+};
+
+static struct miscdevice ds1307_rtc_miscdev = {
+ RTC_MINOR,
+ "rtc",
+ &rtc_fops
+};
+
+static int ds1307_probe(struct i2c_adapter *adap);
+static int ds1307_detach(struct i2c_client *client);
+static int ds1307_command(struct i2c_client *client, unsigned int cmd, void *arg);
+
+struct i2c_driver ds1307_driver = {
+ name: "DS1307",
+ id: I2C_DRIVERID_DS1307,
+ flags: I2C_DF_NOTIFY,
+ attach_adapter: ds1307_probe,
+ detach_client: ds1307_detach,
+ command: ds1307_command
+};
+
+static spinlock_t ds1307_rtc_lock = SPIN_LOCK_UNLOCKED;
+
+#define DAT(x) ((unsigned int)((x)->data)) /* keep the control register info */
+
+static int
+ds1307_readram( char *buf, int len)
+{
+ unsigned long flags;
+ unsigned char ad[1] = { 0 };
+ int ret;
+ struct i2c_msg msgs[2] = {
+ { ds1307_i2c_client->addr , 0, 1, ad },
+ { ds1307_i2c_client->addr , I2C_M_RD, len, buf } };
+
+ spin_lock_irqsave(&ds1307_rtc_lock, flags);
+ ret = i2c_transfer(ds1307_i2c_client->adapter, msgs, 2);
+ spin_unlock_irqrestore(&ds1307_rtc_lock,flags);
+
+ return ret;
+}
+
+static void
+ds1307_dumpram( void)
+{
+ unsigned char buf[DS1307_RAM_SIZE];
+ int ret;
+
+ ret = ds1307_readram( buf, DS1307_RAM_SIZE);
+
+ if( ret > 0)
+ {
+ int i;
+ for( i=0; i<DS1307_RAM_SIZE; i++)
+ {
+ printk ("%02X ", buf[i]);
+ if( (i%8) == 7) printk ("\n");
+ }
+ printk ("\n");
+ }
+}
+
+static void
+ds1307_enable_clock( int enable)
+{
+ unsigned char buf[2], ad[1] = { 0 };
+ struct i2c_msg msgs[2] = {
+ { ds1307_i2c_client->addr , 0, 1, ad },
+ { ds1307_i2c_client->addr , I2C_M_RD, 1, buf }
+ };
+ unsigned char ctrl_info;
+ int ret;
+
+ if( enable)
+ ctrl_info = SQW_ENABLE | RATE_32768HZ;
+ else
+ ctrl_info = SQW_DISABLE;
+ ds1307_command(ds1307_i2c_client, DS1307_SETCTRL, &ctrl_info);
+
+ /* read addr 0 (Clock-Halt bit and second counter */
+ ret = i2c_transfer(ds1307_i2c_client->adapter, msgs, 2);
+
+ if( enable)
+ buf[1] = buf[0] & ~CLOCK_HALT; /* clear Clock-Halt bit */
+ else
+ buf[1] = buf[0] | CLOCK_HALT; /* set Clock-Halt bit */
+ buf[0] = 0; /* control register address on DS1307 */
+
+ ret = i2c_master_send(ds1307_i2c_client, (char *)buf, 2);
+}
+
+static int
+ds1307_attach(struct i2c_adapter *adap, int addr, unsigned short flags,int kind)
+{
+ struct i2c_client *c;
+ unsigned char buf[1], ad[1] = { 7 };
+ struct i2c_msg msgs[2] = {
+ { addr , 0, 1, ad },
+ { addr , I2C_M_RD, 1, buf }
+ };
+ int ret;
+
+ c = (struct i2c_client *)kmalloc(sizeof(*c), GFP_KERNEL);
+ if (!c)
+ return -ENOMEM;
+
+ strcpy(c->name, "DS1307");
+ c->id = ds1307_driver.id;
+ c->flags = 0;
+ c->addr = addr;
+ c->adapter = adap;
+ c->driver = &ds1307_driver;
+ c->data = NULL;
+
+ ret = i2c_transfer(c->adapter, msgs, 2);
+
+ if ( ret == 2 )
+ {
+ DAT(c) = buf[0];
+ }
+ else
+ printk ("ds1307_attach(): i2c_transfer() returned %d.\n",ret);
+
+ ds1307_i2c_client = c;
+ ds1307_enable_clock( 1);
+
+ return i2c_attach_client(c);
+}
+
+static int
+ds1307_probe(struct i2c_adapter *adap)
+{
+ return i2c_probe(adap, &addr_data, ds1307_attach);
+}
+
+static int
+ds1307_detach(struct i2c_client *client)
+{
+ i2c_detach_client(client);
+ ds1307_enable_clock( 0);
+
+ return 0;
+}
+
+static void
+ds1307_convert_to_time( struct rtc_time *dt, char *buf)
+{
+ dt->tm_sec = BCD_TO_BIN(buf[0]);
+ dt->tm_min = BCD_TO_BIN(buf[1]);
+
+ if ( TWELVE_HOUR_MODE(buf[2]) )
+ {
+ dt->tm_hour = HOURS_12(buf[2]);
+ if (HOURS_AP(buf[2])) /* PM */
+ {
+ dt->tm_hour += 12;
+ }
+ }
+ else /* 24-hour-mode */
+ {
+ dt->tm_hour = HOURS_24(buf[2]);
+ }
+
+ dt->tm_mday = BCD_TO_BIN(buf[4]);
+ /* dt->tm_mon is zero-based */
+ dt->tm_mon = BCD_TO_BIN(buf[5]) - 1;
+ /* year is 1900 + dt->tm_year */
+ dt->tm_year = BCD_TO_BIN(buf[6]) + 100;
+
+ if( rtc_debug > 2)
+ {
+ printk("ds1307_get_datetime: year = %d\n", dt->tm_year);
+ printk("ds1307_get_datetime: mon = %d\n", dt->tm_mon);
+ printk("ds1307_get_datetime: mday = %d\n", dt->tm_mday);
+ printk("ds1307_get_datetime: hour = %d\n", dt->tm_hour);
+ printk("ds1307_get_datetime: min = %d\n", dt->tm_min);
+ printk("ds1307_get_datetime: sec = %d\n", dt->tm_sec);
+ }
+}
+
+static int
+ds1307_get_datetime(struct i2c_client *client, struct rtc_time *dt)
+{
+ unsigned char buf[7], addr[1] = { 0 };
+ struct i2c_msg msgs[2] = {
+ { client->addr, 0, 1, addr },
+ { client->addr, I2C_M_RD, 7, buf }
+ };
+ int ret = -EIO;
+
+ memset(buf, 0, sizeof(buf));
+
+ ret = i2c_transfer(client->adapter, msgs, 2);
+
+ if (ret == 2) {
+ ds1307_convert_to_time( dt, buf);
+ ret = 0;
+ }
+ else
+ printk("ds1307_get_datetime(), i2c_transfer() returned %d\n",ret);
+
+ return ret;
+}
+
+static int
+ds1307_set_datetime(struct i2c_client *client, struct rtc_time *dt, int datetoo)
+{
+ unsigned char buf[8];
+ int ret, len = 4;
+
+ if( rtc_debug > 2)
+ {
+ printk("ds1307_set_datetime: tm_year = %d\n", dt->tm_year);
+ printk("ds1307_set_datetime: tm_mon = %d\n", dt->tm_mon);
+ printk("ds1307_set_datetime: tm_mday = %d\n", dt->tm_mday);
+ printk("ds1307_set_datetime: tm_hour = %d\n", dt->tm_hour);
+ printk("ds1307_set_datetime: tm_min = %d\n", dt->tm_min);
+ printk("ds1307_set_datetime: tm_sec = %d\n", dt->tm_sec);
+ }
+
+ buf[0] = 0; /* register address on DS1307 */
+ buf[1] = (BIN_TO_BCD(dt->tm_sec));
+ buf[2] = (BIN_TO_BCD(dt->tm_min));
+ buf[3] = (BIN_TO_BCD(dt->tm_hour));
+
+ if (datetoo) {
+ len = 8;
+ /* we skip buf[4] as we don't use day-of-week. */
+ buf[5] = (BIN_TO_BCD(dt->tm_mday));
+ buf[6] = (BIN_TO_BCD(dt->tm_mon + 1));
+ /* The year only ranges from 0-99, we are being passed an offset from 1900,
+ * and the chip calulates leap years based on 2000, thus we adjust by 100.
+ */
+ buf[7] = (BIN_TO_BCD(dt->tm_year - 100));
+ }
+ ret = i2c_master_send(client, (char *)buf, len);
+ if (ret == len)
+ ret = 0;
+ else
+ printk("ds1307_set_datetime(), i2c_master_send() returned %d\n",ret);
+
+
+ return ret;
+}
+
+static int
+ds1307_get_ctrl(struct i2c_client *client, unsigned char *ctrl)
+{
+ *ctrl = DAT(client);
+
+ return 0;
+}
+
+static int
+ds1307_set_ctrl(struct i2c_client *client, unsigned char *cinfo)
+{
+ unsigned char buf[2];
+ int ret;
+
+
+ buf[0] = 7; /* control register address on DS1307 */
+ buf[1] = *cinfo;
+ /* save the control reg info in the client data field so that get_ctrl
+ * function doesn't have to do an I2C transfer to get it.
+ */
+ DAT(client) = buf[1];
+
+ ret = i2c_master_send(client, (char *)buf, 2);
+
+ return ret;
+}
+
+static int
+ds1307_read_mem(struct i2c_client *client, struct rtc_mem *mem)
+{
+ unsigned char addr[1];
+ struct i2c_msg msgs[2] = {
+ { client->addr, 0, 1, addr },
+ { client->addr, I2C_M_RD, mem->nr, mem->data }
+ };
+
+ if ( (mem->loc < DS1307_RAM_ADDR_START) ||
+ ((mem->loc + mem->nr -1) > DS1307_RAM_ADDR_END) )
+ return -EINVAL;
+
+ addr[0] = mem->loc;
+
+ return i2c_transfer(client->adapter, msgs, 2) == 2 ? 0 : -EIO;
+}
+
+static int
+ds1307_write_mem(struct i2c_client *client, struct rtc_mem *mem)
+{
+ unsigned char addr[1];
+ struct i2c_msg msgs[2] = {
+ { client->addr, 0, 1, addr },
+ { client->addr, 0, mem->nr, mem->data }
+ };
+
+ if ( (mem->loc < DS1307_RAM_ADDR_START) ||
+ ((mem->loc + mem->nr -1) > DS1307_RAM_ADDR_END) )
+ return -EINVAL;
+
+ addr[0] = mem->loc;
+
+ return i2c_transfer(client->adapter, msgs, 2) == 2 ? 0 : -EIO;
+}
+
+static int
+ds1307_command(struct i2c_client *client, unsigned int cmd, void *arg)
+{
+ switch (cmd) {
+ case DS1307_GETDATETIME:
+ return ds1307_get_datetime(client, arg);
+
+ case DS1307_SETTIME:
+ return ds1307_set_datetime(client, arg, 0);
+
+ case DS1307_SETDATETIME:
+ return ds1307_set_datetime(client, arg, 1);
+
+ case DS1307_GETCTRL:
+ return ds1307_get_ctrl(client, arg);
+
+ case DS1307_SETCTRL:
+ return ds1307_set_ctrl(client, arg);
+
+ case DS1307_MEM_READ:
+ return ds1307_read_mem(client, arg);
+
+ case DS1307_MEM_WRITE:
+ return ds1307_write_mem(client, arg);
+
+ default:
+ return -EINVAL;
+ }
+}
+
+static int
+ds1307_rtc_open(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+
+static int
+ds1307_rtc_release(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+
+static int
+ds1307_rtc_ioctl( struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ unsigned long flags;
+ struct rtc_time wtime;
+ int status = 0;
+
+ switch (cmd) {
+ default:
+ case RTC_UIE_ON:
+ case RTC_UIE_OFF:
+ case RTC_PIE_ON:
+ case RTC_PIE_OFF:
+ case RTC_AIE_ON:
+ case RTC_AIE_OFF:
+ case RTC_ALM_SET:
+ case RTC_ALM_READ:
+ case RTC_IRQP_READ:
+ case RTC_IRQP_SET:
+ case RTC_EPOCH_READ:
+ case RTC_EPOCH_SET:
+ case RTC_WKALM_SET:
+ case RTC_WKALM_RD:
+ status = -EINVAL;
+ break;
+
+ case RTC_RD_TIME:
+ spin_lock_irqsave(&ds1307_rtc_lock, flags);
+ ds1307_command( ds1307_i2c_client, DS1307_GETDATETIME, &wtime);
+ spin_unlock_irqrestore(&ds1307_rtc_lock,flags);
+
+ if( copy_to_user((void *)arg, &wtime, sizeof (struct rtc_time)))
+ status = -EFAULT;
+ break;
+
+ case RTC_SET_TIME:
+ if (!capable(CAP_SYS_TIME))
+ {
+ status = -EACCES;
+ break;
+ }
+
+ if (copy_from_user(&wtime, (struct rtc_time *)arg, sizeof(struct rtc_time)) )
+ {
+ status = -EFAULT;
+ break;
+ }
+
+ spin_lock_irqsave(&ds1307_rtc_lock, flags);
+ ds1307_command( ds1307_i2c_client, DS1307_SETDATETIME, &wtime);
+ spin_unlock_irqrestore(&ds1307_rtc_lock,flags);
+ break;
+ }
+
+ return status;
+}
+
+static char *
+ds1307_mon2str( unsigned int mon)
+{
+ char *mon2str[12] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ };
+ if( mon > 11) return "error";
+ else return mon2str[ mon];
+}
+
+static int ds1307_rtc_proc_output( char *buf)
+{
+#define CHECK(ctrl,bit) ((ctrl & bit) ? "yes" : "no")
+ unsigned char ram[DS1307_RAM_SIZE];
+ int ret;
+
+ char *p = buf;
+
+ ret = ds1307_readram( ram, DS1307_RAM_SIZE);
+ if( ret > 0)
+ {
+ int i;
+ struct rtc_time dt;
+ char text[9];
+
+ p += sprintf(p, "DS1307 (64x8 Serial Real Time Clock)\n");
+
+ ds1307_convert_to_time( &dt, ram);
+ p += sprintf(p, "Date/Time : %02d-%s-%04d %02d:%02d:%02d\n",
+ dt.tm_mday, ds1307_mon2str(dt.tm_mon), dt.tm_year + 1900,
+ dt.tm_hour, dt.tm_min, dt.tm_sec);
+
+ p += sprintf(p, "Clock halted : %s\n", CHECK(ram[0],0x80));
+ p += sprintf(p, "24h mode : %s\n", CHECK(ram[2],0x40));
+ p += sprintf(p, "Square wave enabled : %s\n", CHECK(ram[7],0x10));
+ p += sprintf(p, "Freq : ");
+
+ switch( ram[7] & 0x03)
+ {
+ case RATE_1HZ:
+ p += sprintf(p, "1Hz\n");
+ break;
+ case RATE_4096HZ:
+ p += sprintf(p, "4.096kHz\n");
+ break;
+ case RATE_8192HZ:
+ p += sprintf(p, "8.192kHz\n");
+ break;
+ case RATE_32768HZ:
+ default:
+ p += sprintf(p, "32.768kHz\n");
+ break;
+
+ }
+
+ p += sprintf(p, "RAM dump:\n");
+ text[8]='\0';
+ for( i=0; i<DS1307_RAM_SIZE; i++)
+ {
+ p += sprintf(p, "%02X ", ram[i]);
+
+ if( (ram[i] < 32) || (ram[i]>126)) ram[i]='.';
+ text[i%8] = ram[i];
+ if( (i%8) == 7) p += sprintf(p, "%s\n",text);
+ }
+ p += sprintf(p, "\n");
+ }
+ else
+ {
+ p += sprintf(p, "Failed to read RTC memory!\n");
+ }
+
+ return p - buf;
+}
+
+static int ds1307_rtc_read_proc(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ int len = ds1307_rtc_proc_output (page);
+ if (len <= off+count) *eof = 1;
+ *start = page + off;
+ len -= off;
+ if (len>count) len = count;
+ if (len<0) len = 0;
+ return len;
+}
+
+static __init int ds1307_init(void)
+{
+ int retval=0;
+
+ if( slave_address != 0xffff)
+ {
+ normal_addr[0] = slave_address;
+ }
+
+ if( normal_addr[0] == 0xffff)
+ {
+ printk(KERN_ERR"I2C: Invalid slave address for DS1307 RTC (%#x)\n",
+ normal_addr[0]);
+ return -EINVAL;
+ }
+
+ retval = i2c_add_driver(&ds1307_driver);
+
+ if (retval==0)
+ {
+ misc_register (&ds1307_rtc_miscdev);
+ create_proc_read_entry (PROC_DS1307_NAME, 0, 0, ds1307_rtc_read_proc, NULL);
+ printk("I2C: DS1307 RTC driver successfully loaded\n");
+
+ if( rtc_debug) ds1307_dumpram();
+ }
+ return retval;
+}
+
+static __exit void ds1307_exit(void)
+{
+ remove_proc_entry (PROC_DS1307_NAME, NULL);
+ misc_deregister(&ds1307_rtc_miscdev);
+ i2c_del_driver(&ds1307_driver);
+}
+
+module_init(ds1307_init);
+module_exit(ds1307_exit);
+
+MODULE_PARM (slave_address, "i");
+MODULE_PARM_DESC (slave_address, "I2C slave address for DS1307 RTC.");
+
+MODULE_AUTHOR ("Intrinsyc Software Inc.");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/char/ds1307.h linux-2.4.26-vrs1/drivers/char/ds1307.h
--- linux-2.4.26/drivers/char/ds1307.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/ds1307.h 2004-03-04 22:44:33.000000000 +0000
@@ -0,0 +1,58 @@
+/*
+ * ds1307.h
+ *
+ * Copyright (C) 2002 Intrinsyc Software Inc.
+ *
+ * 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.
+ *
+ */
+#ifndef DS1307_H
+#define DS1307_H
+
+#if defined(CONFIG_PXA_EMERSON_SBC) || defined(CONFIG_PXA_CERF_BOARD) || defined(CONFIG_MACH_CSB337)
+ #define DS1307_I2C_SLAVE_ADDR 0x68
+#else
+ #define DS1307_I2C_SLAVE_ADDR 0xffff
+#endif
+
+#define DS1307_RAM_ADDR_START 0x08
+#define DS1307_RAM_ADDR_END 0x3F
+#define DS1307_RAM_SIZE 0x40
+
+#define PROC_DS1307_NAME "driver/ds1307"
+
+struct rtc_mem {
+ unsigned int loc;
+ unsigned int nr;
+ unsigned char *data;
+};
+
+#define DS1307_GETDATETIME 0
+#define DS1307_SETTIME 1
+#define DS1307_SETDATETIME 2
+#define DS1307_GETCTRL 3
+#define DS1307_SETCTRL 4
+#define DS1307_MEM_READ 5
+#define DS1307_MEM_WRITE 6
+
+#define SQW_ENABLE 0x10 /* Square Wave Enable */
+#define SQW_DISABLE 0x00 /* Square Wave disable */
+
+#define RATE_32768HZ 0x03 /* Rate Select 32.768KHz */
+#define RATE_8192HZ 0x02 /* Rate Select 8.192KHz */
+#define RATE_4096HZ 0x01 /* Rate Select 4.096KHz */
+#define RATE_1HZ 0x00 /* Rate Select 1Hz */
+
+#define CLOCK_HALT 0x80 /* Clock Halt */
+
+#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10)
+#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10)
+
+#define TWELVE_HOUR_MODE(n) (((n)>>6)&1)
+#define HOURS_AP(n) (((n)>>5)&1)
+#define HOURS_12(n) BCD_TO_BIN((n)&0x1F)
+#define HOURS_24(n) BCD_TO_BIN((n)&0x3F)
+
+#endif
diff -urN linux-2.4.26/drivers/char/edb7211_keyb.c linux-2.4.26-vrs1/drivers/char/edb7211_keyb.c
--- linux-2.4.26/drivers/char/edb7211_keyb.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/edb7211_keyb.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,335 @@
+/*
+ * drivers/char/edb7211_keyb.c
+ *
+ * Copyright (C) 2000 Blue Mug, Inc. All Rights Reserved.
+ *
+ * EDB7211 Keyboard driver for ARM Linux.
+ *
+ * The EP7211 keyboard hardware only supports generating interrupts for 64 keys.
+ * The EBD7211's keyboard has 84 keys. Therefore we need to poll for keys,
+ * instead of waiting for interrupts.
+ *
+ * In a real-world hardware situation, this would be a bad thing. It would
+ * kill power management.
+ */
+
+#include <linux/config.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/ptrace.h>
+#include <linux/signal.h>
+#include <linux/timer.h>
+#include <linux/tqueue.h>
+#include <linux/random.h>
+#include <linux/ctype.h>
+#include <linux/init.h>
+#include <linux/kbd_ll.h>
+#include <linux/kbd_kern.h>
+#include <linux/delay.h>
+
+#include <asm/bitops.h>
+#include <asm/keyboard.h>
+#include <asm/irq.h>
+#include <asm/hardware.h>
+
+#include <asm/io.h>
+#include <asm/system.h>
+
+
+/*
+ * The number of jiffies between keyboard scans.
+ */
+#define KEYBOARD_SCAN_INTERVAL 5
+
+/*
+ * Values for the keyboard column scan control register.
+ */
+#define KBSC_HI 0x0 /* All driven high */
+#define KBSC_LO 0x1 /* All driven low */
+#define KBSC_X 0x2 /* All high impedance */
+#define KBSC_COL0 0x8 /* Column 0 high, others high impedance */
+#define KBSC_COL1 0x9 /* Column 1 high, others high impedance */
+#define KBSC_COL2 0xa /* Column 2 high, others high impedance */
+#define KBSC_COL3 0xb /* Column 3 high, others high impedance */
+#define KBSC_COL4 0xc /* Column 4 high, others high impedance */
+#define KBSC_COL5 0xd /* Column 5 high, others high impedance */
+#define KBSC_COL6 0xe /* Column 6 high, others high impedance */
+#define KBSC_COL7 0xf /* Column 7 high, others high impedance */
+
+
+/* XXX: Figure out what these values should be... */
+/* Simple translation table for the SysRq keys */
+#ifdef CONFIG_MAGIC_SYSRQ
+unsigned char edb7211_kbd_sysrq_xlate[128] =
+ "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
+ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
+ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
+ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
+ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
+ "\r\000/"; /* 0x60 - 0x6f */
+#endif
+
+/*
+ * Row/column to scancode mappings.
+ *
+ * This table maps row/column keyboard matrix positions to XT scancodes.
+ *
+ * The port A rows come first, followed by the extended rows.
+ */
+static unsigned char colrow_2_scancode[128] =
+{
+/* Column:
+ Row 0 1 2 3 4 5 6 7 */
+/* A0 */ 0x01, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x40, 0x41,
+/* A1 */ 0x02, 0x07, 0x06, 0x05, 0x04, 0x03, 0x08, 0x09,
+/* A2 */ 0x0f, 0x14, 0x13, 0x12, 0x11, 0x10, 0x15, 0x16,
+/* A3 */ 0x3a, 0x22, 0x21, 0x20, 0x1f, 0x1e, 0x23, 0x24,
+/* A4 */ 0x29, 0x30, 0x2f, 0x2e, 0x2d, 0x2c, 0x31, 0x32,
+/* A5 */ 0x39, 0x35, 0x6F, 0x52, 0x00, 0x6B, 0x34, 0x33,
+/* A6 */ 0x6A, 0x27, 0x28, 0x00, 0x1c, 0x6D, 0x26, 0x25,
+/* A7 */ 0x67, 0x19, 0x1a, 0x1b, 0x2b, 0x68, 0x18, 0x17,
+/* E0 */ 0x6C, 0x0c, 0x0d, 0x0e, 0x00, 0x66, 0x0b, 0x0a,
+/* E1 */ 0x69, 0x44, 0x45, 0x37, 0x46, 0x77, 0x43, 0x42,
+/* E2 */ 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* E3 */ 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* E4 */ 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* E5 */ 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* E6 */ 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* E7 */ 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+/*
+ * A bitfield array which contains the state of the keyboard after the last
+ * scan. A bit set in this array corresponds to a key down. Only the lower
+ * 16 bits of each array element are used.
+ */
+static unsigned long previous_keys[8];
+static unsigned long keys[8];
+
+
+/* This will be set to a non-zero value if a key was found to be pressed
+ * in the last scan. */
+static int key_is_pressed;
+
+static struct tq_struct kbd_process_task;
+static struct timer_list edb7211_kbd_timer;
+
+/*
+ * External methods.
+ */
+void edb7211_kbd_init_hw(void);
+
+/*
+ * Internal methods.
+ */
+static int edb7211_kbd_scan_matrix(u_long* keys);
+static void edb7211_kbd_timeout(unsigned long data);
+static void edb7211_kbd_process(void* data);
+
+/*
+ * Translate a raw keycode to an XT keyboard scancode.
+ */
+static int
+edb7211_translate(unsigned char scancode, unsigned char *keycode,
+ char raw_mode)
+{
+ *keycode = colrow_2_scancode[scancode & 0x7f];
+ return 1;
+}
+
+/*
+ * Scan the keyboard matrix; for each key that is pressed, set the
+ * corresponding bit in the bitfield array.
+ *
+ * The parameter is expected to be an array of 8 32-bit values. Only the lower
+ * 16 bits of each value is used. Each value contains the row bits for the
+ * corresponding column.
+ */
+static int
+edb7211_kbd_scan_matrix(u_long* keys)
+{
+ int column, row, key_pressed;
+ unsigned char port_a_data, ext_port_data;
+
+ key_pressed = 0;
+
+ /* Drive all the columns low. */
+ clps_writel((clps_readl(SYSCON1) & ~SYSCON1_KBDSCANMASK) | KBSC_LO,
+ SYSCON1);
+
+ for (column = 0; column < 8; column++) {
+
+ /* Drive the column high. */
+ clps_writel((clps_readl(SYSCON1) & ~SYSCON1_KBDSCANMASK) |
+ (KBSC_COL0 + column), SYSCON1);
+
+ /* Read port A and the extended port. */
+ port_a_data = clps_readb(PADR) & 0xff;
+ ext_port_data = __raw_readb(EP7211_VIRT_EXTKBD) & 0xff;
+
+ /* Drive all columns tri-state. */
+ clps_writel((clps_readl(SYSCON1) & ~SYSCON1_KBDSCANMASK) | KBSC_X,
+ SYSCON1);
+
+ /* Look at each column in port A. */
+ for (row=0; row < 8; row++) {
+ /* If the row's bit is set, set the bit in the bitfield.
+ * Otherwise, clear it.
+ */
+ if (port_a_data & (1 << row)) {
+ keys[column] |= (1 << row);
+ key_pressed = 1;
+ } else {
+ keys[column] &= ~(1 << row);
+ }
+ }
+
+ /* Look at each column in the extended port. */
+ for (row=0; row < 8; row++) {
+ /* If the row's bit is set, set the bit in the bitfield.
+ * Otherwise, clear it.
+ */
+ if (ext_port_data & (1 << row)) {
+ keys[column] |= (1 << (row + 8));
+ key_pressed = 1;
+ } else {
+ keys[column] &= ~(1 << (row + 8));
+ }
+ }
+
+ /*
+ * Short delay: The example code for the EDB7211 runs an empty
+ * loop 256 times. At this rate, there were some spurious keys
+ * generated. I doubled the delay to let the column drives
+ * settle some.
+ */
+ for (row=0; row < 512; row++) { }
+ }
+
+ /* If we could use interrupts, we would drive all columns high so
+ * that interrupts will be generated on key presses. But we can't,
+ * so we leave all columns floating.
+ */
+ clps_writel((clps_readl(SYSCON1) & ~SYSCON1_KBDSCANMASK) | KBSC_X,
+ SYSCON1);
+
+ return key_pressed;
+}
+
+/*
+ * XXX: This is really ugly; this needs to be reworked to have less levels of
+ * indentation.
+ */
+static void
+edb7211_kbd_timeout(unsigned long data)
+{
+ /* Schedule the next timer event. */
+ edb7211_kbd_timer.expires = jiffies + KEYBOARD_SCAN_INTERVAL;
+ add_timer(&edb7211_kbd_timer);
+
+ if (edb7211_kbd_scan_matrix(keys) || key_is_pressed) {
+ queue_task(&kbd_process_task, &tq_timer);
+ } else {
+ key_is_pressed = 0;
+ }
+}
+
+/*
+ * Process the keys that have been pressed.
+ */
+static void
+edb7211_kbd_process(void* data)
+{
+ int i;
+
+ /* First check if any keys have been released. */
+ if (key_is_pressed) {
+ for (i=0; i < 8; i++) {
+ if (previous_keys[i]) {
+ int row;
+
+ for (row=0; row < 16; row++) {
+ if ((previous_keys[i] & (1 << row)) &&
+ !(keys[i] & (1 << row))) {
+ /* Generate the up event. */
+ handle_scancode(
+ (row<<3)+i, 0);
+ }
+ }
+ }
+ }
+ }
+
+ key_is_pressed = 0;
+
+ /* Now scan the keys and send press events. */
+ for (i=0; i < 8; i++) {
+ if (keys[i]) {
+ int row;
+
+ for (row=0; row < 16; row++) {
+ if (keys[i] & (1 << row)) {
+ if (previous_keys[i] & (1 << row)) {
+ /* Generate the hold event. */
+ handle_scancode((row<<3)+i, 1);
+ } else {
+ /* Generate the down event. */
+ handle_scancode((row<<3)+i, 1);
+ }
+
+ key_is_pressed = 1;
+ }
+ }
+ }
+ }
+
+ /* Update the state variables. */
+ memcpy(previous_keys, keys, 8 * sizeof(unsigned long));
+}
+
+static char edb7211_unexpected_up(unsigned char scancode)
+{
+ return 0200;
+}
+
+static void edb7211_leds(unsigned char leds)
+{
+}
+
+/*
+ * Initialize the keyboard hardware. Set the column drives low and
+ * start the timer.
+ */
+void __init
+edb7211_kbd_init_hw(void)
+{
+ k_translate = edb7211_translate;
+ k_unexpected_up = edb7211_unexpected_up;
+ k_leds = edb7211_leds;
+
+ /*
+ * If we had the ability to use interrupts, we would want to drive all
+ * columns high. But we have more keys than can generate interrupts, so
+ * we leave them floating.
+ */
+ clps_writel((clps_readl(SYSCON1) & ~SYSCON1_KBDSCANMASK) | KBSC_X,
+ SYSCON1);
+
+ /* Initialize the matrix processing task. */
+ kbd_process_task.routine = edb7211_kbd_process;
+ kbd_process_task.data = NULL;
+
+ /* Setup the timer to poll the keyboard. */
+ init_timer(&edb7211_kbd_timer);
+ edb7211_kbd_timer.function = edb7211_kbd_timeout;
+ edb7211_kbd_timer.data = (unsigned long)NULL;
+ edb7211_kbd_timer.expires = jiffies + KEYBOARD_SCAN_INTERVAL;
+ add_timer(&edb7211_kbd_timer);
+}
+
+
diff -urN linux-2.4.26/drivers/char/epxa_wdt.c linux-2.4.26-vrs1/drivers/char/epxa_wdt.c
--- linux-2.4.26/drivers/char/epxa_wdt.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/epxa_wdt.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,178 @@
+/*
+ * Watchdog driver for the Altera Excalibur EPXA1DB
+ *
+ * (c) Copyright 2003 Krzysztof Marianski <kmarian@konin.lm.pl>
+ * Based on SA11x0 Watchdog driver by Oleg Drokin <green@crimea.edu>
+ *
+ * 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 material is provided "AS-IS" and at no charge
+ *
+ * (c) Copyright 2003 Krzysztof Marianski <kmarian@konin.lm.pl>
+ *
+ * 1/08/2003 Initial release
+ */
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <linux/reboot.h>
+#include <linux/smp_lock.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <asm/hardware.h>
+
+#define WATCHDOG00_TYPE (volatile unsigned int*)
+#include <asm/arch/watchdog00.h>
+#include <asm/bitops.h>
+
+#define TIMER_MARGIN 30 /* (secs) Default is 30 seconds */
+
+static int margin = TIMER_MARGIN; /* in seconds */
+static int epxa1wdt_users;
+static unsigned char last_written_byte;
+
+#ifdef CONFIG_WATCHDOG_NOWAYOUT
+static int nowayout=1;
+#else
+static int nowayout=0;
+#endif
+
+#ifdef MODULE
+MODULE_PARM(margin,"i");
+MODULE_PARM(nowayout, "i");
+#endif
+
+/*
+ * Allow only one person to hold it open
+ */
+
+static int epxa1dog_open(struct inode *inode, struct file *file)
+{
+ if(test_and_set_bit(1,&epxa1wdt_users))
+ return -EBUSY;
+
+ /* Reset the Watchdog, just to be sure we don't set
+ a value close to actual value of WDOG_COUNT register */
+ *WDOG_RELOAD(IO_ADDRESS(EXC_WATCHDOG00_BASE))=WDOG_RELOAD_MAGIC_1;
+ *WDOG_RELOAD(IO_ADDRESS(EXC_WATCHDOG00_BASE))=WDOG_RELOAD_MAGIC_2;
+
+ /* Activate EPXA1DB Watchdog timer */
+ *WDOG_CR(IO_ADDRESS(EXC_WATCHDOG00_BASE))= (EXC_INPUT_CLK_FREQUENCY * margin) & WDOG_CR_TRIGGER_MSK;
+
+ last_written_byte = 'V'; //in case user opens it only to ioctl
+ return 0;
+}
+
+static int epxa1dog_release(struct inode *inode, struct file *file)
+{
+ /*
+ * Shut off the timer and set lock bit when no special
+ * character 'V' was last written
+ */
+
+ if ((last_written_byte != 'V') && (nowayout)) {
+ *WDOG_CR(IO_ADDRESS(EXC_WATCHDOG00_BASE)) |= WDOG_CR_LK_MSK;
+ printk("No special character 'V' was written to Watchdog just before closing it\n");
+ printk("WATCHDOG LOCKED - Reboot expected!!!\n");
+ } else
+ *WDOG_CR(IO_ADDRESS(EXC_WATCHDOG00_BASE))=0;
+
+ epxa1wdt_users = 0;
+
+ return 0;
+}
+
+static ssize_t epxa1dog_write(struct file *file, const char *data, size_t len, loff_t *ppos)
+{
+ /* Can't seek (pwrite) on this device */
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+
+ /* Reset Watchdog timer. */
+ if(len) {
+ *WDOG_RELOAD(IO_ADDRESS(EXC_WATCHDOG00_BASE))=WDOG_RELOAD_MAGIC_1;
+ *WDOG_RELOAD(IO_ADDRESS(EXC_WATCHDOG00_BASE))=WDOG_RELOAD_MAGIC_2;
+ last_written_byte = *data;
+ return 1;
+ }
+ return 0;
+}
+
+static int epxa1dog_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ static struct watchdog_info ident = {
+ identity: "EPXA Watchdog",
+ };
+
+ switch(cmd){
+ default:
+ return -ENOIOCTLCMD;
+ case WDIOC_GETSUPPORT:
+ return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident));
+// case WDIOC_GETSTATUS: //TODO
+// return put_user(0,(int *)arg);
+// case WDIOC_GETBOOTSTATUS: //TODO
+// return 0;
+ case WDIOC_KEEPALIVE:
+ *WDOG_RELOAD(IO_ADDRESS(EXC_WATCHDOG00_BASE))=WDOG_RELOAD_MAGIC_1;
+ *WDOG_RELOAD(IO_ADDRESS(EXC_WATCHDOG00_BASE))=WDOG_RELOAD_MAGIC_2;
+ return 0;
+ case WDIOC_SETTIMEOUT:
+ *WDOG_CR(IO_ADDRESS(EXC_WATCHDOG00_BASE))= (EXC_INPUT_CLK_FREQUENCY * margin) & WDOG_CR_TRIGGER_MSK;
+ return 0;
+ case WDIOC_GETTIMEOUT:
+ return put_user( ((*WDOG_CR(IO_ADDRESS(EXC_WATCHDOG00_BASE)))/EXC_INPUT_CLK_FREQUENCY), (int*)arg);
+ }
+}
+
+static struct file_operations epxa1dog_fops = {
+ .owner = THIS_MODULE,
+ .write = epxa1dog_write,
+ .ioctl = epxa1dog_ioctl,
+ .open = epxa1dog_open,
+ .release = epxa1dog_release,
+};
+
+static struct miscdevice epxa1dog_miscdev=
+{
+ .minor = WATCHDOG_MINOR,
+ .name = "EPXA watchdog",
+ .fops = &epxa1dog_fops
+};
+
+static int __init epxa1dog_init(void)
+{
+ int ret;
+
+ ret = misc_register(&epxa1dog_miscdev);
+
+ if (ret)
+ return ret;
+
+ printk("EPXA Watchdog Timer: timer margin %d sec\n", margin);
+ printk("EPXA Watchdog Timer: no way out is %s\n", nowayout ? "enabled" : "disabled");
+
+ return 0;
+}
+
+static void __exit epxa1dog_exit(void)
+{
+ misc_deregister(&epxa1dog_miscdev);
+}
+
+module_init(epxa1dog_init);
+module_exit(epxa1dog_exit);
+
+MODULE_AUTHOR("Krzysztof Marianski <kmarian@konin.lm.pl>");
+MODULE_DESCRIPTION("EPXA Watchdog Timer");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/char/gc_kbmap.h linux-2.4.26-vrs1/drivers/char/gc_kbmap.h
--- linux-2.4.26/drivers/char/gc_kbmap.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/gc_kbmap.h 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,162 @@
+
+
+#define KK_NONE 0x7f
+#define KK_ESC 0x00
+#define KK_F1 0x01
+#define KK_F2 0x02
+#define KK_F3 0x03
+#define KK_F4 0x04
+#define KK_F5 0x05
+#define KK_F6 0x06
+#define KK_F7 0x07
+#define KK_F8 0x08
+#define KK_F9 0x09
+#define KK_F10 0x0a
+#define KK_F11 0x0b
+#define KK_F12 0x0c
+#define KK_PRNT 0x0d
+#define KK_SCRL 0x0e
+#define KK_BRK 0x0f
+#define KK_AGR 0x10
+#define KK_1 0x11
+#define KK_2 0x12
+#define KK_3 0x13
+#define KK_4 0x14
+#define KK_5 0x15
+#define KK_6 0x16
+#define KK_7 0x17
+#define KK_8 0x18
+#define KK_9 0x19
+#define KK_0 0x1a
+#define KK_MINS 0x1b
+#define KK_EQLS 0x1c
+#define KK_BKSP 0x1e
+#define KK_INS 0x1f
+#define KK_HOME 0x20
+#define KK_PGUP 0x21
+#define KK_NUML 0x22
+#define KP_SLH 0x23
+#define KP_STR 0x24
+#define KP_MNS 0x3a
+#define KK_TAB 0x26
+#define KK_Q 0x27
+#define KK_W 0x28
+#define KK_E 0x29
+#define KK_R 0x2a
+#define KK_T 0x2b
+#define KK_Y 0x2c
+#define KK_U 0x2d
+#define KK_I 0x2e
+#define KK_O 0x2f
+#define KK_P 0x30
+#define KK_LSBK 0x31
+#define KK_RSBK 0x32
+#define KK_ENTR 0x47
+#define KK_DEL 0x34
+#define KK_END 0x35
+#define KK_PGDN 0x36
+#define KP_7 0x37
+#define KP_8 0x38
+#define KP_9 0x39
+#define KP_PLS 0x4b
+#define KK_CAPS 0x5d
+#define KK_A 0x3c
+#define KK_S 0x3d
+#define KK_D 0x3e
+#define KK_F 0x3f
+#define KK_G 0x40
+#define KK_H 0x41
+#define KK_J 0x42
+#define KK_K 0x43
+#define KK_L 0x44
+#define KK_SEMI 0x45
+#define KK_SQOT 0x46
+#define KK_HASH 0x1d
+#define KP_4 0x48
+#define KP_5 0x49
+#define KP_6 0x4a
+#define KK_LSFT 0x4c
+#define KK_BSLH 0x33
+#define KK_Z 0x4e
+#define KK_X 0x4f
+#define KK_C 0x50
+#define KK_V 0x51
+#define KK_B 0x52
+#define KK_N 0x53
+#define KK_M 0x54
+#define KK_COMA 0x55
+#define KK_DOT 0x56
+#define KK_FSLH 0x57
+#define KK_RSFT 0x58
+#define KK_UP 0x59
+#define KP_1 0x5a
+#define KP_2 0x5b
+#define KP_3 0x5c
+#define KP_ENT 0x67
+#define KK_LCTL 0x3b
+#define KK_LALT 0x5e
+#define KK_SPCE 0x5f
+#define KK_RALT 0x60
+#define KK_RCTL 0x61
+#define KK_LEFT 0x62
+#define KK_DOWN 0x63
+#define KK_RGHT 0x64
+#define KP_0 0x65
+#define KP_DOT 0x66
+
+static char kbmap[128] = {
+KK_NONE, KK_LALT, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_AGR, KK_BSLH, KK_TAB, KK_Z, KK_A, KK_X, KK_NONE,
+KK_NONE, KK_NONE, KK_LSFT, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_LCTL, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, 0x21, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_ESC, KK_DEL, KK_Q, KK_CAPS, KK_S, KK_C, KK_3,
+KK_NONE, KK_1, KK_NONE, KK_W, KK_NONE, KK_D, KK_V, KK_4,
+KK_NONE, KK_2, KK_T, KK_E, KK_NONE, KK_F, KK_B, KK_5,
+KK_NONE, KK_9, KK_Y, KK_R, KK_K, KK_G, KK_N, KK_6,
+KK_NONE, KK_0, KK_U, KK_O, KK_L, KK_H, KK_M, KK_7,
+KK_NONE, KK_MINS, KK_I, KK_P, KK_SEMI, KK_J, KK_COMA, KK_8,
+KK_NONE, KK_EQLS, KK_ENTR, KK_LSBK, KK_BSLH, KK_FSLH, KK_DOT, KK_NONE,
+KK_NONE, KK_NONE, KK_RSFT, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_BKSP, KK_DOWN, KK_RSBK, KK_UP, KK_LEFT, KK_SPCE, KK_RGHT,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE};
+
+static char kbmapFN[128] = {
+KK_NONE, KK_LALT, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_LSFT, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_LCTL, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, 0x21, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_F3,
+KK_NONE, KK_F1, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_F4,
+KK_NONE, KK_F2, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_F5,
+KK_NONE, KK_F9, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_F6,
+KK_NONE, KK_F10, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_F7,
+KK_NONE, KK_NUML, KK_NONE, KK_INS, KK_PRNT, KK_NONE, KK_NONE, KK_F8,
+KK_NONE, KK_BRK, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_RSFT, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_PGDN, KK_SCRL, KK_PGUP, KK_HOME, KK_NONE, KK_END,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE};
+
+static char kbmapNL[128] = {
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KP_9, KK_NONE, KK_NONE, KP_2, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KP_STR, KP_4, KP_6, KP_3, KK_NONE, KP_0, KP_7,
+KK_NONE, KK_NONE, KP_5, KP_MNS, KP_PLS, KP_1, KK_NONE, KP_8,
+KK_NONE, KK_NONE, KP_ENT, KK_NONE, KK_NONE, KP_SLH, KP_DOT, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE,
+KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE, KK_NONE};
+
+
+
diff -urN linux-2.4.26/drivers/char/gc_keyb.c linux-2.4.26-vrs1/drivers/char/gc_keyb.c
--- linux-2.4.26/drivers/char/gc_keyb.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/gc_keyb.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,1145 @@
+/*
+ * linux/arch/arm/drivers/char/gc_keyb.c
+ *
+ * Copyright 2000 Applied Data Systems
+ *
+ * Keyboard & Smartio driver for GraphicsClient ARM Linux.
+ * Graphics Client is SA1110 based single board computer by
+ * Applied Data Systems (http://www.applieddata.net)
+ *
+ * Change log:
+ * 7-10/6/01 Thomas Thaele <tthaele@papenmeier.de>
+ * - Added Keyboard Sniffer on /dev/sio12 <minor = 12>
+ * - First implementation of PC- compatible Scancodes (thanks to pc_keyb.c)
+ * 3/23/01 Woojung Huh
+ * Power Management added
+ * 12/01/00 Woojung Huh
+ * Bug fixed
+ * 11/16/00 Woojung Huh [whuh@applieddata.net]
+ * Added smartio device driver on it
+ */
+
+/*
+ * Introduced setkeycode, ketkeycode for the GC+ by Thomas Thaele
+ * <tthaele@papenmeier.de> GC+ now performs like a real PC on the keyboard.
+ * Warning: this code is still beta! PrntScrn and Pause keys are not
+ * completely tested and implemented!!! Keyboard driver can be confused
+ * by hacking like crazy on the keyboard. (hardware problem on serial line?)
+ */
+
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/kbd_ll.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/kbd_kern.h>
+
+#include <asm/irq.h>
+#include <asm/hardware.h>
+#include <asm/keyboard.h>
+#include <linux/tqueue.h>
+#include <linux/proc_fs.h>
+#include <linux/pm.h>
+
+#define ADS_AVR_IRQ 63
+
+#define SMARTIO_IOCTL_BASES 's'
+#define SMARTIO_KPD_TIMEOUT _IOW(SMARTIO_IOCTL_BASES, 0, int)
+#define SMARTIO_KPD_SETUP _IOW(SMARTIO_IOCTL_BASES, 1, short)
+#define SMARTIO_BL_CONTROL _IOW(SMARTIO_IOCTL_BASES, 2, char)
+#define SMARTIO_BL_CONTRAST _IOW(SMARTIO_IOCTL_BASES, 3, char)
+#define SMARTIO_PORT_CONFIG _IOW(SMARTIO_IOCTL_BASES, 4, char)
+#define SMARTIO_SNIFFER_TIMEOUT _IOW(SMARTIO_IOCTL_BASES, 5, long)
+
+
+/* Simple translation table for the SysRq keys */
+
+#ifdef CONFIG_MAGIC_SYSRQ
+unsigned char pckbd_sysrq_xlate[128] =
+ "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
+ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
+ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
+ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
+ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
+ "\r\000/"; /* 0x60 - 0x6f */
+#endif
+
+/*
+ * Translation of escaped scancodes to keycodes.
+ * This is now user-settable.
+ * The keycodes 1-88,96-111,119 are fairly standard, and
+ * should probably not be changed - changing might confuse X.
+ * X also interprets scancode 0x5d (KEY_Begin).
+ *
+ * For 1-88 keycode equals scancode.
+ */
+
+#define E0_KPENTER 96
+#define E0_RCTRL 97
+#define E0_KPSLASH 98
+#define E0_PRSCR 99
+#define E0_RALT 100
+#define E0_BREAK 101 /* (control-pause) */
+#define E0_HOME 102
+#define E0_UP 103
+#define E0_PGUP 104
+#define E0_LEFT 105
+#define E0_RIGHT 106
+#define E0_END 107
+#define E0_DOWN 108
+#define E0_PGDN 109
+#define E0_INS 110
+#define E0_DEL 111
+
+#define E1_PAUSE 119
+
+/*
+ * The keycodes below are randomly located in 89-95,112-118,120-127.
+ * They could be thrown away (and all occurrences below replaced by 0),
+ * but that would force many users to use the `setkeycodes' utility, where
+ * they needed not before. It does not matter that there are duplicates, as
+ * long as no duplication occurs for any single keyboard.
+ */
+#define SC_LIM 89
+
+#define FOCUS_PF1 85 /* actual code! */
+#define FOCUS_PF2 89
+#define FOCUS_PF3 90
+#define FOCUS_PF4 91
+#define FOCUS_PF5 92
+#define FOCUS_PF6 93
+#define FOCUS_PF7 94
+#define FOCUS_PF8 95
+#define FOCUS_PF9 120
+#define FOCUS_PF10 121
+#define FOCUS_PF11 122
+#define FOCUS_PF12 123
+
+#define JAP_86 124
+/* tfj@olivia.ping.dk:
+ * The four keys are located over the numeric keypad, and are
+ * labelled A1-A4. It's an rc930 keyboard, from
+ * Regnecentralen/RC International, Now ICL.
+ * Scancodes: 59, 5a, 5b, 5c.
+ */
+#define RGN1 124
+#define RGN2 125
+#define RGN3 126
+#define RGN4 127
+
+static unsigned char high_keys[128 - SC_LIM] = {
+ RGN1, RGN2, RGN3, RGN4, 0, 0, 0, /* 0x59-0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
+ 0, 0, 0, 0, 0, FOCUS_PF11, 0, FOCUS_PF12, /* 0x68-0x6f */
+ 0, 0, 0, FOCUS_PF2, FOCUS_PF9, 0, 0, FOCUS_PF3, /* 0x70-0x77 */
+ FOCUS_PF4, FOCUS_PF5, FOCUS_PF6, FOCUS_PF7, /* 0x78-0x7b */
+ FOCUS_PF8, JAP_86, FOCUS_PF10, 0 /* 0x7c-0x7f */
+};
+
+/* BTC */
+#define E0_MACRO 112
+/* LK450 */
+#define E0_F13 113
+#define E0_F14 114
+#define E0_HELP 115
+#define E0_DO 116
+#define E0_F17 117
+#define E0_KPMINPLUS 118
+/*
+ * My OmniKey generates e0 4c for the "OMNI" key and the
+ * right alt key does nada. [kkoller@nyx10.cs.du.edu]
+ */
+#define E0_OK 124
+/*
+ * New microsoft keyboard is rumoured to have
+ * e0 5b (left window button), e0 5c (right window button),
+ * e0 5d (menu button). [or: LBANNER, RBANNER, RMENU]
+ * [or: Windows_L, Windows_R, TaskMan]
+ */
+#define E0_MSLW 125
+#define E0_MSRW 126
+#define E0_MSTM 127
+
+static unsigned char e0_keys[128] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00-0x07 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x08-0x0f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */
+ 0, 0, 0, 0, E0_KPENTER, E0_RCTRL, 0, 0, /* 0x18-0x1f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */
+ 0, 0, 0, 0, 0, E0_KPSLASH, 0, E0_PRSCR, /* 0x30-0x37 */
+ E0_RALT, 0, 0, 0, 0, E0_F13, E0_F14, E0_HELP, /* 0x38-0x3f */
+ E0_DO, E0_F17, 0, 0, 0, 0, E0_BREAK, E0_HOME, /* 0x40-0x47 */
+ E0_UP, E0_PGUP, 0, E0_LEFT, E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END,/* 0x48-0x4f */
+ E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 0, 0, 0, 0, /* 0x50-0x57 */
+ 0, 0, 0, E0_MSLW, E0_MSRW, E0_MSTM, 0, 0, /* 0x58-0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
+ 0, 0, 0, 0, 0, 0, 0, E0_MACRO, /* 0x68-0x6f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0 /* 0x78-0x7f */
+};
+
+int gc_kbd_setkeycode(unsigned int scancode, unsigned int keycode)
+{
+ if (scancode < SC_LIM || scancode > 255 || keycode > 127)
+ return -EINVAL;
+ if (scancode < 128)
+ high_keys[scancode - SC_LIM] = keycode;
+ else
+ e0_keys[scancode - 128] = keycode;
+ return 0;
+}
+
+int gc_kbd_getkeycode(unsigned int scancode)
+{
+ return
+ (scancode < SC_LIM || scancode > 255) ? -EINVAL :
+ (scancode < 128) ? high_keys[scancode - SC_LIM] :
+ e0_keys[scancode - 128];
+}
+
+int gc_kbd_translate(unsigned char scancode, unsigned char *keycode,
+ char raw_mode)
+{
+ static int prev_scancode;
+
+ /* special prefix scancodes.. */
+ if (scancode == 0xe0 || scancode == 0xe1) {
+ prev_scancode = scancode;
+ return 0;
+ }
+
+ /* 0xFF is sent by a few keyboards, ignore it. 0x00 is error */
+ if (scancode == 0x00 || scancode == 0xff) {
+ prev_scancode = 0;
+ return 0;
+ }
+
+ scancode &= 0x7f;
+
+ if (prev_scancode) {
+ /*
+ * usually it will be 0xe0, but a Pause key generates
+ * e1 1d 45 e1 9d c5 when pressed, and nothing when released
+ */
+ if (prev_scancode != 0xe0) {
+ if (prev_scancode == 0xe1 && scancode == 0x1d) {
+ prev_scancode = 0x100;
+ return 0;
+ } else if (prev_scancode == 0x100 && scancode == 0x45) {
+ *keycode = E1_PAUSE;
+ prev_scancode = 0;
+ } else {
+#ifdef KBD_REPORT_UNKN
+ if (!raw_mode)
+ printk(KERN_INFO "keyboard: unknown e1 escape sequence\n");
+#endif
+ prev_scancode = 0;
+ return 0;
+ }
+ } else {
+ prev_scancode = 0;
+ /*
+ * The keyboard maintains its own internal caps lock and
+ * num lock statuses. In caps lock mode E0 AA precedes make
+ * code and E0 2A follows break code. In num lock mode,
+ * E0 2A precedes make code and E0 AA follows break code.
+ * We do our own book-keeping, so we will just ignore these.
+ */
+ /*
+ * For my keyboard there is no caps lock mode, but there are
+ * both Shift-L and Shift-R modes. The former mode generates
+ * E0 2A / E0 AA pairs, the latter E0 B6 / E0 36 pairs.
+ * So, we should also ignore the latter. - aeb@cwi.nl
+ */
+ if (scancode == 0x2a || scancode == 0x36)
+ return 0;
+
+ if (e0_keys[scancode])
+ *keycode = e0_keys[scancode];
+ else {
+#ifdef KBD_REPORT_UNKN
+ if (!raw_mode)
+ printk(KERN_INFO "keyboard: unknown scancode e0 %02x\n",
+ scancode);
+#endif
+ return 0;
+ }
+ }
+ } else if (scancode >= SC_LIM) {
+ /* This happens with the FOCUS 9000 keyboard
+ Its keys PF1..PF12 are reported to generate
+ 55 73 77 78 79 7a 7b 7c 74 7e 6d 6f
+ Moreover, unless repeated, they do not generate
+ key-down events, so we have to zero up_flag below */
+ /* Also, Japanese 86/106 keyboards are reported to
+ generate 0x73 and 0x7d for \ - and \ | respectively. */
+ /* Also, some Brazilian keyboard is reported to produce
+ 0x73 and 0x7e for \ ? and KP-dot, respectively. */
+
+ *keycode = high_keys[scancode - SC_LIM];
+
+ if (!*keycode) {
+ if (!raw_mode) {
+#ifdef KBD_REPORT_UNKN
+ printk(KERN_INFO "keyboard: unrecognized scancode (%02x)"
+ " - ignored\n", scancode);
+#endif
+ }
+ return 0;
+ }
+ } else
+ *keycode = scancode;
+ return 1;
+}
+
+// this table converts the hardware dependent codes of a MF-2 Keyboard to
+// the codes normally comming out of a i8042. This table is 128 Bytes too
+// big, but for stability reasons it should be kept like it is!
+// There is no range checking in the code!
+static int mf_two_kbdmap[256] = {
+ 00, 67, 65, 63, 61, 59, 60, 88, 00, 68, 66, 64, 62, 15, 41, 00,
+ 00, 56, 42, 00, 29, 16, 02, 00, 00, 00, 44, 31, 30, 17, 03, 00,
+ 00, 46, 45, 32, 18, 05, 04, 00, 00, 57, 47, 33, 20, 19, 06, 00,
+ 00, 49, 48, 35, 34, 21, 7, 00, 00, 00, 50, 36, 22, 8, 9, 00,
+ 00, 51, 37, 23, 24, 11, 10, 00, 00, 52, 53, 38, 39, 25, 12, 00,
+ 00, 00, 40, 00, 26, 13, 00, 00, 58, 54, 28, 27, 00, 43, 00, 00,
+ 00, 86, 00, 00, 00, 00, 14, 00, 00, 79, 00, 75, 71, 00, 00, 00,
+ 82, 83, 80, 76, 77, 72, 01, 69, 87, 78, 81, 74, 55, 73, 70, 00,
+ 00, 00, 00, 65, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00,
+ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 };
+
+
+// some texts displayed by the proc_file_system
+static char *kbd_sniff[2] = { "off", "on" };
+static char *kbd_sniff_mode[2] = { "passive", "active" };
+
+#define PASSIVE 0
+#define ACTIVE 1
+
+// is the sniffer active (1) or inactive (0)
+static int SNIFFER = 0;
+// do we get a copy (SNIFFMODE = PASSIVE) or do we get the original data (SNIFFMODE = ACTIVE)
+// and have to reinsert the data
+static int SNIFFMODE = PASSIVE;
+
+// we allow only one process to sniff
+static int sniffer_in_use = 0;
+
+// timeout for the keyboard sniffer -1 = blocking, otherwise timeout in msecs
+static long sniffer_timeout = -1;
+
+// the value we sniffed from the keyboard
+static int sniffed_value;
+
+static char *smartio_version = "1.02 MF-II compatibility patch <tthaele@papenmeier.de>";
+static char *smartio_date = "Aug-27-2001";
+
+static int sio_reset_flag;
+static int kbd_press_flag;
+
+static void send_SSP_msg(unchar *pBuf, int num)
+{
+ ushort tmp;
+ int i;
+
+ for (i=0;i<num;i++) {
+ while ((Ser4SSSR & SSSR_TNF) == 0);
+ tmp = pBuf[i];
+ Ser4SSDR = (tmp << 8);
+ }
+
+ // Throw away Echo
+ for (i=0;i<num;i++) {
+ while ((Ser4SSSR & SSSR_RNE) == 0);
+ tmp = Ser4SSDR;
+ }
+}
+
+static unchar ReadSSPByte(void)
+{
+ if (Ser4SSSR & SSSR_ROR) {
+ printk("%s() : Overrun\n", __FUNCTION__);
+ return 0;
+ }
+
+ Ser4SSDR = 0x00;
+
+ while ((Ser4SSSR & SSSR_RNE) == 0);
+
+ return ((unchar) Ser4SSDR);
+}
+
+static ulong read_SSP_response(int num)
+{
+ int i;
+ ulong ret;
+
+ // discard leading 0x00 and command echo 0 (command group value)
+ while (ReadSSPByte() == 0);
+ // discard command echo 1 (command code value)
+ ReadSSPByte();
+
+ // data from SMARTIO
+ // It assumes LSB first.
+ // NOTE:Some command uses MSB first order
+ ret = 0;
+ for (i=0;i<num;i++) {
+ ret |= ReadSSPByte() << (8*i);
+ }
+
+ return ret;
+}
+
+typedef struct t_SMARTIO_CMD {
+ unchar Group;
+ unchar Code;
+ unchar Opt[2];
+} SMARTIO_CMD;
+
+static SMARTIO_CMD RD_INT_CMD = { 0x83, 0x01, { 0x00, 0x00 } };
+static SMARTIO_CMD RD_KBD_CMD = { 0x83, 0x02, { 0x00, 0x00 } };
+static SMARTIO_CMD RD_ADC_CMD = { 0x83, 0x28, { 0x00, 0x00 } };
+static SMARTIO_CMD RD_KPD_CMD = { 0x83, 0x04, { 0x00, 0x00 } };
+
+static volatile ushort adc_value;
+static volatile unchar kpd_value;
+static unsigned int kpd_timeout = 10000; // 10000 msec
+
+static ulong kbd_int, kpd_int, adc_int;
+
+static void smartio_interrupt_task(void *data);
+
+static struct tq_struct tq_smartio = {
+ { NULL, NULL }, // struct list_head
+ 0, // unsigned long sync
+ smartio_interrupt_task, // void (*routine)(void *)
+ NULL, // void *data
+};
+
+DECLARE_WAIT_QUEUE_HEAD(smartio_queue);
+DECLARE_WAIT_QUEUE_HEAD(smartio_adc_queue);
+DECLARE_WAIT_QUEUE_HEAD(smartio_kpd_queue);
+DECLARE_WAIT_QUEUE_HEAD(keyboard_done_queue);
+DECLARE_WAIT_QUEUE_HEAD(sniffer_queue);
+
+static spinlock_t smartio_busy_lock = SPIN_LOCK_UNLOCKED;
+static atomic_t smartio_busy = ATOMIC_INIT(0);
+
+static int f_five_pressed = 0;
+static int f_seven_pressed = 0;
+//static int e_null_counter = 0;
+//static int f_null_counter = 0;
+//static int keydown = 0;
+static unchar previous_code = 0;
+//static int e0 = 0;
+
+static void smartio_interrupt_task(void *arg)
+{
+ unchar code;
+ unsigned long flags;
+ unchar dummy;
+
+ spin_lock_irqsave(&smartio_busy_lock, flags);
+ if (atomic_read(&smartio_busy) == 1) {
+ spin_unlock_irqrestore(&smartio_busy_lock, flags);
+ queue_task(&tq_smartio, &tq_timer);
+ }
+ else {
+ atomic_set(&smartio_busy, 1);
+ spin_unlock_irqrestore(&smartio_busy_lock, flags);
+ }
+
+ /* Read SMARTIO Interrupt Status to check which Interrupt is occurred
+ * and Clear SMARTIO Interrupt */
+ send_SSP_msg((unchar *) &RD_INT_CMD, 2);
+ code = (unchar) (read_SSP_response(1) & 0xFF);
+
+#ifdef CONFIG_VT
+ if (code & 0x04) { // Keyboard Interrupt
+ kbd_int++;
+ /* Read Scan code */
+ send_SSP_msg((unchar *) &RD_KBD_CMD, 2);
+ code = (unchar) (read_SSP_response(1) & 0xFF);
+ dummy = code & 0x80;
+ if ((code == 0xE0) || (code == 0xE1) || (code == 0xF0)) { // combined code
+ if (code == 0xF0) {
+ if (!previous_code) {
+ code = 0xE0;
+ previous_code = 0xF0;
+ } else {
+ code = mf_two_kbdmap[code & 0x7F] | dummy;
+ previous_code = 0;
+ }
+ } else if (code == 0xE0) {
+ if (previous_code != 0) {
+ code = mf_two_kbdmap[code & 0x7F] | dummy;
+ previous_code = 0;
+ } else previous_code = code;
+ } else { // 0xE1
+ if (!previous_code) {
+ code = mf_two_kbdmap[code &0x7F] | dummy;
+ previous_code = 0;
+ } else {
+ previous_code = code;
+ }
+ }
+ } else {
+ if (code == 0x03) {
+ f_five_pressed = 1;
+ } else if (code == 0x83) {
+ if (f_five_pressed != 0) {
+ f_five_pressed = 0;
+ code = 0x03;
+ } else if (f_seven_pressed == 0) {
+ f_seven_pressed = 1;
+ code = 2;
+ dummy = 0;
+ } else {
+ f_seven_pressed = 0;
+ code = 2;
+ }
+ }
+ previous_code = 0;
+ code &= 0x7F;
+ code = mf_two_kbdmap[code] | dummy;
+ }
+ sniffed_value = (ushort)code;
+ if (SNIFFER) wake_up_interruptible(&sniffer_queue);
+ if (SNIFFMODE == PASSIVE) {
+ handle_scancode( code, (code & 0x80) ? 0 : 1 );
+ if (code & 0x80) {
+ wake_up_interruptible(&keyboard_done_queue);
+ mdelay(10); // this makes the whole thing a bit more stable
+ // keyboard handling can be corrupted when hitting
+ // thousands of keys like crazy. kbd_translate might catch up
+ // with irq routine? or there is simply a buffer overflow on
+ // the serial device? somehow it looses some key sequences.
+ // if a break code is lost or coruppted the keyboard starts
+ // to autorepeat like crazy and appears to hang.
+ // this needs further investigations! Thomas
+ kbd_press_flag = 0;
+ }
+ else
+ kbd_press_flag = 1;
+ }
+ code = 0; // prevent furthermore if ... then to react!
+ }
+#endif
+ // ADC resolution is 10bit (0x000 ~ 0x3FF)
+ if (code & 0x02) { // ADC Complete Interrupt
+ adc_int++;
+ send_SSP_msg((unchar *) &RD_ADC_CMD, 2);
+ adc_value = (ushort) (read_SSP_response(2) & 0x3FF);
+ wake_up_interruptible(&smartio_adc_queue);
+ }
+
+ if (code & 0x08) { // Keypad interrupt
+ kpd_int++;
+ send_SSP_msg((unchar *) &RD_KPD_CMD, 2);
+ kpd_value = (unchar) (read_SSP_response(1) & 0xFF);
+ wake_up_interruptible(&smartio_kpd_queue);
+ }
+
+ spin_lock_irqsave(&smartio_busy_lock, flags);
+ atomic_set(&smartio_busy, 0);
+ spin_unlock_irqrestore(&smartio_busy_lock, flags);
+
+ enable_irq(ADS_AVR_IRQ);
+
+ wake_up_interruptible(&smartio_queue);
+}
+
+static void gc_sio_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+#ifdef CONFIG_VT
+ kbd_pt_regs = regs;
+#endif
+
+ // *NOTE*
+ // ADS SMARTIO interrupt is cleared after reading interrupt status
+ // from smartio.
+ // disable SMARTIO IRQ here and re-enable at samrtio_bh.
+ // 11/13/00 Woojung
+ disable_irq(ADS_AVR_IRQ);
+
+ queue_task(&tq_smartio, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+char gc_kbd_unexpected_up(unsigned char keycode)
+{
+ return 0;
+}
+
+static inline void gc_sio_init(void)
+{
+ GPDR |= (GPIO_GPIO10 | GPIO_GPIO12 | GPIO_GPIO13); // Output
+ GPDR &= ~GPIO_GPIO11;
+
+ // Alternative Function
+ GAFR |= (GPIO_GPIO10 | GPIO_GPIO11 | GPIO_GPIO12 | GPIO_GPIO13);
+
+ Ser4SSCR0 = 0xA707;
+ Ser4SSSR = SSSR_ROR;
+ Ser4SSCR1 = 0x0010;
+ Ser4SSCR0 = 0xA787;
+
+ // Reset SMARTIO
+ ADS_AVR_REG &= 0xFE;
+ mdelay(300); // 10 mSec
+ ADS_AVR_REG |= 0x01;
+ mdelay(10); // 10 mSec
+
+}
+
+void __init gc_kbd_init_hw(void)
+{
+ printk (KERN_INFO "Graphics Client keyboard driver v1.0\n");
+
+ k_setkeycode = gc_kbd_setkeycode;
+ k_getkeycode = gc_kbd_getkeycode;
+ k_translate = gc_kbd_translate;
+ k_unexpected_up = gc_kbd_unexpected_up;
+#ifdef CONFIG_MAGIC_SYSRQ
+ k_sysrq_key = 0x54;
+ /* sysrq table??? --rmk */
+#endif
+
+ gc_sio_init();
+
+ if (request_irq(ADS_AVR_IRQ,gc_sio_interrupt,0,"smartio", NULL) != 0)
+ printk("Could not allocate SMARTIO IRQ!\n");
+
+ sio_reset_flag = 1;
+}
+
+/* SMARTIO ADC Interface */
+#define SMARTIO_VERSION 0
+#define SMARTIO_PORT_A 1
+#define SMARTIO_PORT_B 2
+#define SMARTIO_PORT_C 3
+#define SMARTIO_PORT_D 4
+#define SMARTIO_SELECT_OPTION 5
+#define SMARTIO_BACKLITE 6
+#define SMARTIO_KEYPAD 7
+#define SMARTIO_ADC 8
+#define SMARTIO_VEE_PWM 9
+#define SMARTIO_SLEEP 11
+#define SMARTIO_KBD_SNIFFER 12
+
+static SMARTIO_CMD CONV_ADC_CMD = { 0x80, 0x28, { 0x00, 0x00 } };
+static SMARTIO_CMD READ_PORT_CMD = { 0x82, 0x00, { 0x00, 0x00 } };
+
+static SMARTIO_CMD READ_DEVVER_CMD = { 0x82, 0x05, { 0x00, 0x00 } };
+static SMARTIO_CMD READ_DEVTYPE_CMD = { 0x82, 0x06, { 0x00, 0x00 } };
+static SMARTIO_CMD READ_FWLEVEL_CMD = { 0x82, 0x07, { 0x00, 0x00 } };
+
+static int lock_smartio(unsigned long *flags)
+{
+ spin_lock_irqsave(&smartio_busy_lock, *flags);
+ if (atomic_read(&smartio_busy) == 1) {
+ spin_unlock_irqrestore(&smartio_busy_lock, *flags);
+ interruptible_sleep_on(&smartio_queue);
+ }
+ else {
+ atomic_set(&smartio_busy, 1);
+ spin_unlock_irqrestore(&smartio_busy_lock, *flags);
+ }
+
+ return 1;
+}
+
+static int unlock_smartio(unsigned long *flags)
+{
+ spin_lock_irqsave(&smartio_busy_lock, *flags);
+ atomic_set(&smartio_busy, 0);
+ spin_unlock_irqrestore(&smartio_busy_lock, *flags);
+
+ return 1;
+}
+
+static ushort read_sio_adc(int channel)
+{
+ unsigned long flags;
+
+ if ((channel < 0) || (channel > 7))
+ return 0xFFFF;
+
+ CONV_ADC_CMD.Opt[0] = (unchar) channel;
+
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &CONV_ADC_CMD, 3);
+ unlock_smartio(&flags);
+
+ interruptible_sleep_on(&smartio_adc_queue);
+
+ return adc_value & 0x3FF;
+}
+
+static ushort read_sio_port(int port)
+{
+ unsigned long flags;
+ ushort ret;
+
+ if ((port < SMARTIO_PORT_B) || (port > SMARTIO_PORT_D))
+ return 0xFFFF;
+
+ READ_PORT_CMD.Code = (unchar) port;
+
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &READ_PORT_CMD, 2);
+ ret = read_SSP_response(1);
+ unlock_smartio(&flags);
+
+ return ret;
+}
+
+static ushort read_sio_kpd(void)
+{
+ long timeout;
+
+ // kpd_timeout is mSec order
+ // interrupt_sleep_on_timeout is based on 10msec timer tick
+ if (kpd_timeout == -1) {
+ interruptible_sleep_on(&smartio_kpd_queue);
+ }
+ else {
+ timeout = interruptible_sleep_on_timeout(&smartio_kpd_queue,
+ kpd_timeout/10);
+ if (timeout == 0) {
+ // timeout without keypad input
+ return 0xFFFF;
+ }
+ }
+ return kpd_value;
+}
+
+static ushort read_sio_sniff(void)
+{
+ long timeout;
+
+ // kpd_timeout is mSec order
+ // interrupt_sleep_on_timeout is based on 10msec timer tick
+ if (sniffer_timeout == -1) {
+ interruptible_sleep_on(&sniffer_queue);
+ }
+ else {
+ timeout = interruptible_sleep_on_timeout(&sniffer_queue,
+ sniffer_timeout/10);
+ if (timeout == 0) {
+ // timeout without keypad input
+ return -1;
+ }
+ }
+ return (ushort)sniffed_value;
+}
+
+static struct sio_ver {
+ uint DevVer;
+ uint DevType;
+ uint FwLevel;
+};
+
+static ushort read_sio_version(struct sio_ver *ptr)
+{
+ unsigned long flags;
+ ushort ret;
+
+ // Read Device Version
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &READ_DEVVER_CMD, 2);
+ ret = read_SSP_response(1);
+ unlock_smartio(&flags);
+ ptr->DevVer = (uint)ret;
+ // Read Device Type
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &READ_DEVTYPE_CMD, 2);
+ ret = read_SSP_response(2);
+ unlock_smartio(&flags);
+ // swap MSB & LSB
+ ret = ((ret & 0xFF) << 8) | ((ret & 0xFF00) >> 8);
+ ptr->DevType = (uint)ret;
+ // Read Firmware Level
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &READ_FWLEVEL_CMD, 2);
+ ret = read_SSP_response(2);
+ unlock_smartio(&flags);
+ // swap MSB & LSB
+ ret = ((ret & 0xFF) << 8) | ((ret & 0xFF00) >> 8);
+ ptr->FwLevel = (uint)ret;
+
+ return 0;
+}
+
+static ssize_t sio_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+ struct inode *inode = file->f_dentry->d_inode;
+ unsigned int minor = MINOR(inode->i_rdev);
+ ushort *ret = (ushort *)buf;
+
+ switch (minor) {
+ case SMARTIO_ADC:
+ if ((*ret = read_sio_adc(buf[0])) != 0xFFFF)
+ return sizeof(ushort); // 2 bytes
+ case SMARTIO_PORT_B:
+ case SMARTIO_PORT_C:
+ case SMARTIO_PORT_D:
+ if ((*ret = read_sio_port(minor)) != 0xFFFF)
+ return sizeof(ushort);
+ case SMARTIO_VERSION:
+ if ((read_sio_version((struct sio_ver *)buf)) != 0xFFFF)
+ return sizeof(struct sio_ver);
+ case SMARTIO_KEYPAD:
+ if ((*ret = read_sio_kpd()) != 0xFFFF)
+ return sizeof(ushort);
+ case SMARTIO_KBD_SNIFFER:
+ if ((*ret = read_sio_sniff()) != (ushort)-1)
+ return 1;
+ default :
+ return -ENXIO;
+ }
+}
+
+static SMARTIO_CMD WRITE_PORT_CMD = { 0x81, 0x00, { 0x00, 0x00 } };
+static SMARTIO_CMD SELECT_OPT_CMD = { 0x80, 0x00, { 0x00, 0x00 } };
+static SMARTIO_CMD CONTROL_BL_CMD = { 0x80, 0x00, { 0x00, 0x00 } };
+static SMARTIO_CMD CONTRAST_BL_CMD = { 0x80, 0x21, { 0x00, 0x00 } };
+static SMARTIO_CMD CONTROL_KPD_CMD = { 0x80, 0x27, { 0x00, 0x00 } };
+static SMARTIO_CMD CONTROL_VEE_CMD = { 0x80, 0x22, { 0x00, 0x00 } };
+
+static ushort write_sio_port(int port, unchar value)
+{
+ unsigned long flags;
+
+ if ((port < SMARTIO_PORT_B) || (port > SMARTIO_PORT_D))
+ return 0xFFFF;
+
+ WRITE_PORT_CMD.Code = (unchar) port;
+ WRITE_PORT_CMD.Opt[0] = (unchar) value;
+
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &WRITE_PORT_CMD, 3);
+ unlock_smartio(&flags);
+
+ return 0;
+}
+
+static ushort write_sio_select(unchar select)
+{
+ unsigned long flags;
+
+ if ((select < 1) || (select > 2))
+ return 0xFFFF;
+
+ SELECT_OPT_CMD.Code = (unchar) (select + 0x28);
+
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &SELECT_OPT_CMD, 2);
+ unlock_smartio(&flags);
+
+ return 0;
+}
+
+static ushort control_sio_backlite(int cmd, int value)
+{
+ unsigned long flags;
+
+ if (cmd == SMARTIO_BL_CONTRAST) {
+ value &= 0xFF;
+ CONTRAST_BL_CMD.Opt[0] = (unchar) value;
+
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &CONTRAST_BL_CMD, 3);
+ unlock_smartio(&flags);
+ }
+ else if (cmd == SMARTIO_BL_CONTROL) {
+ if (value == 0x00) {
+ // Backlite OFF
+ CONTROL_BL_CMD.Code = 0x24;
+ }
+ else {
+ // Backlite ON
+ CONTROL_BL_CMD.Code = 0x23;
+ }
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &CONTROL_BL_CMD, 2);
+ unlock_smartio(&flags);
+ }
+ else
+ return 0xFFFF;
+
+ return 0;
+}
+
+static ushort control_sio_keypad(int x, int y)
+{
+ unsigned long flags;
+
+ if ( (x<1) || (x>8) || (y<1) || (y>8)) {
+ return 0xFFFF;
+ }
+
+ CONTROL_KPD_CMD.Opt[0] = (unchar) x;
+ CONTROL_KPD_CMD.Opt[1] = (unchar) y;
+
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &CONTROL_KPD_CMD, 4);
+ unlock_smartio(&flags);
+
+ return 0;
+}
+
+static ushort control_sio_vee(int value)
+{
+ unsigned long flags;
+
+ value &= 0xFF;
+ CONTROL_VEE_CMD.Opt[0] = (unchar) value;
+
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &CONTROL_VEE_CMD, 3);
+ unlock_smartio(&flags);
+
+ return 0;
+}
+
+static ssize_t sio_write(struct file *file, const char *buf, size_t cont, loff_t *ppos)
+{
+ struct inode *inode = file->f_dentry->d_inode;
+ unsigned int minor = MINOR(inode->i_rdev);
+
+ switch (minor) {
+ case SMARTIO_PORT_B:
+ case SMARTIO_PORT_C:
+ case SMARTIO_PORT_D:
+ if (write_sio_port(minor, buf[0]) != 0xFFFF)
+ return 1;
+ case SMARTIO_SELECT_OPTION:
+ if (write_sio_select(buf[0]) != 0xFFFF)
+ return 1;
+ case SMARTIO_BACKLITE:
+ if (control_sio_backlite(SMARTIO_BL_CONTROL, buf[0]) != 0xFFFF)
+ return 1;
+ case SMARTIO_KEYPAD:
+ if (control_sio_keypad(buf[0], buf[1]) != 0xFFFF)
+ return 2;
+ case SMARTIO_VEE_PWM:
+ if (control_sio_vee(buf[0]) != 0xFFFF)
+ return 1;
+ case SMARTIO_KBD_SNIFFER:
+ // here are the scancodes injected
+ handle_scancode((unchar)buf[0], (buf[0] & 0x80) ? 0 : 1);
+ wake_up_interruptible(&keyboard_done_queue);
+ // give some time to process! File IO is a bit faster than manual typing ;-)
+ udelay(10000);
+ return 1;
+ default:
+ return -ENXIO;
+ }
+}
+
+static unsigned int sio_poll(struct file *file, struct poll_table_struct *wait)
+{
+ return 0;
+}
+
+static SMARTIO_CMD IOCTL_PORT_CMD = { 0x81, 0x00, { 0x00, 0x00 } };
+
+static ushort ioctl_sio_port(int port, unchar value)
+{
+ unsigned long flags;
+
+ if ((port < SMARTIO_PORT_B) || (port > SMARTIO_PORT_D))
+ return 0xFFFF;
+
+ IOCTL_PORT_CMD.Code = (unchar) port + 0x04; // 0x05 ~ 0x08
+ if (port == SMARTIO_PORT_B) {
+ // Port B has 4 bits only
+ IOCTL_PORT_CMD.Opt[0] = (unchar) value & 0x0F;
+ }
+ else
+ IOCTL_PORT_CMD.Opt[0] = (unchar) value;
+
+ lock_smartio(&flags);
+ send_SSP_msg((unchar *) &IOCTL_PORT_CMD, 3);
+ unlock_smartio(&flags);
+
+ return 0;
+}
+
+static int sio_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ unsigned int minor = MINOR(inode->i_rdev);
+ unchar *buf = (unchar *)arg;
+
+ switch (minor) {
+ case SMARTIO_PORT_B:
+ case SMARTIO_PORT_C:
+ case SMARTIO_PORT_D:
+ if (cmd == SMARTIO_PORT_CONFIG) {
+ if (ioctl_sio_port(minor, buf[0]) != 0xFFFF)
+ return 0;
+ }
+ return -EINVAL;
+ case SMARTIO_SELECT_OPTION:
+ if (write_sio_select(buf[0]) != 0xFFFF) return 0;
+ return -EINVAL;
+ case SMARTIO_BACKLITE:
+ if (cmd == SMARTIO_BL_CONTROL) {
+ if (control_sio_backlite(SMARTIO_BL_CONTROL, buf[0]) != 0xFFFF) return 0;
+ }
+ else if (cmd == SMARTIO_BL_CONTRAST) {
+ if (control_sio_backlite(SMARTIO_BL_CONTRAST, buf[0]) != 0xFFFF) return 0;
+ }
+ else return -EINVAL;
+ case SMARTIO_KEYPAD:
+ if (cmd == SMARTIO_KPD_TIMEOUT) {
+ kpd_timeout = *(long*)buf;
+ return 0;
+ }
+ else if (cmd == SMARTIO_KPD_SETUP) {
+ if (control_sio_keypad(buf[0], buf[1]) != 0xFFFF) return 0;
+ }
+ return -EINVAL;
+ case SMARTIO_VEE_PWM:
+ if (control_sio_vee(buf[0]) != 0xFFFF) return 0;
+ return -EINVAL;
+ case SMARTIO_KBD_SNIFFER:
+ if (cmd == SMARTIO_SNIFFER_TIMEOUT) {
+ sniffer_timeout = *(long*)buf;
+ if (sniffer_timeout < 0) sniffer_timeout = -1;
+ // the value will be devided by 10 later on
+ if (!sniffer_timeout) sniffer_timeout = 10;
+ return 0;
+ }
+ return -EINVAL;
+ default:
+ return -ENXIO;
+ }
+}
+
+static int sio_open(struct inode *inode, struct file *file)
+{
+ unsigned int minor = MINOR(inode->i_rdev);
+
+ // we open all by default. we only have a special handler for the kbd sniffer
+ switch (minor) {
+ case SMARTIO_KBD_SNIFFER:
+ if (sniffer_in_use) return -EBUSY;
+ sniffer_in_use = 1;
+ SNIFFER = 1;
+ // sniff in active or passive mode
+ if ((file->f_flags & O_RDWR) == O_RDWR) SNIFFMODE = 1; else SNIFFMODE = 0;
+ // do we have a blocking or non blocking sniffer?
+ if ((file->f_flags & O_NONBLOCK) == O_NONBLOCK) sniffer_timeout = 100; else sniffer_timeout = -1;
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+static int sio_close(struct inode *inode, struct file *file)
+{
+ unsigned int minor = MINOR(inode->i_rdev);
+
+ switch (minor) {
+ case SMARTIO_KBD_SNIFFER:
+ SNIFFER = 0;
+ SNIFFMODE = 0;
+ sniffer_in_use = 0;
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+static struct file_operations sio_fops = {
+ read: sio_read,
+ write: sio_write,
+ poll: sio_poll,
+ ioctl: sio_ioctl,
+ open: sio_open,
+ release: sio_close,
+};
+
+static struct proc_dir_entry *sio_dir, *parent_dir = NULL;
+
+#define SMARTIO_MAJOR 58
+#define MAJOR_NR SMARTIO_MAJOR
+
+#define PROC_NAME "sio"
+
+static int sio_read_proc(char *buf, char **start, off_t pos, int count, int *eof, void *data)
+{
+ char *p = buf;
+
+ p += sprintf(p, "ADS SMARTIO Status: \n");
+ p += sprintf(p, "\t Keyboard Interrupt : %lu\n", kbd_int);
+ p += sprintf(p, "\t Keypad Interrupt : %lu\n", kpd_int);
+ p += sprintf(p, "\t ADC Interrupt : %lu\n", adc_int);
+ p += sprintf(p, "\t Keyboard Sniffer : %s mode : %s\n", kbd_sniff[ SNIFFER ], kbd_sniff_mode [ SNIFFMODE ]);
+
+ return (p-buf);
+}
+
+#ifdef CONFIG_PM
+static int pm_smartio_callback(struct pm_dev *dev, pm_request_t rqst, void *data)
+{
+ switch (rqst) {
+ case PM_RESUME:
+ gc_sio_init();
+ break;
+ case PM_SUSPEND:
+ // 4/5/01 Woojung
+ // It checks Keybard received pair of press/release code.
+ // System can sleep before receiving release code
+ if (kbd_press_flag) {
+ interruptible_sleep_on(&keyboard_done_queue);
+ }
+ break;
+ }
+
+ return 0;
+}
+#endif
+
+void __init sio_init(void)
+{
+ if (register_chrdev(MAJOR_NR, "sio", &sio_fops)) {
+ printk("smartio : unable to get major %d\n", MAJOR_NR);
+ return;
+ }
+ else {
+ printk("smartio driver initialized. version %s, date:%s\n",
+ smartio_version, smartio_date);
+
+ if (sio_reset_flag != 1) {
+ gc_sio_init();
+ if (request_irq(ADS_AVR_IRQ, gc_sio_interrupt,0,"sio",NULL) != 0){
+ printk("smartio : Could not allocate IRQ!\n");
+ return;
+ }
+ }
+
+ if ((sio_dir = create_proc_entry(PROC_NAME, 0, parent_dir)) == NULL) {
+ printk("smartio : Unable to create /proc entry\n");
+ return;
+ }
+ else {
+ sio_dir->read_proc = sio_read_proc;
+#ifdef CONFIG_PM
+ pm_register(PM_SYS_DEV, PM_SYS_KBC, pm_smartio_callback);
+#endif
+ }
+ }
+}
diff -urN linux-2.4.26/drivers/char/gckeymap.c linux-2.4.26-vrs1/drivers/char/gckeymap.c
--- linux-2.4.26/drivers/char/gckeymap.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/gckeymap.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,262 @@
+/* Do not edit this file! It was automatically generated by */
+/* loadkeys --mktable defkeymap.map > defkeymap.c */
+
+#include <linux/types.h>
+#include <linux/keyboard.h>
+#include <linux/kd.h>
+
+u_short plain_map[NR_KEYS] = {
+ 0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036,
+ 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009,
+ 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69,
+ 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73,
+ 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b,
+ 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76,
+ 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c,
+ 0xf703, 0xf020, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104,
+ 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307,
+ 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
+ 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a,
+ 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603,
+ 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
+ 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+};
+
+u_short shift_map[NR_KEYS] = {
+ 0xf200, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e,
+ 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009,
+ 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49,
+ 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53,
+ 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a,
+ 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56,
+ 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c,
+ 0xf703, 0xf020, 0xf207, 0xf10a, 0xf10b, 0xf10c, 0xf10d, 0xf10e,
+ 0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf213, 0xf203, 0xf307,
+ 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
+ 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf10a,
+ 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
+ 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116,
+ 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+};
+
+u_short altgr_map[NR_KEYS] = {
+ 0xf200, 0xf200, 0xf200, 0xf040, 0xf200, 0xf024, 0xf200, 0xf200,
+ 0xf07b, 0xf05b, 0xf05d, 0xf07d, 0xf05c, 0xf200, 0xf200, 0xf200,
+ 0xfb71, 0xfb77, 0xf918, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69,
+ 0xfb6f, 0xfb70, 0xf200, 0xf07e, 0xf201, 0xf702, 0xf914, 0xfb73,
+ 0xf917, 0xf919, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf200,
+ 0xf200, 0xf200, 0xf700, 0xf200, 0xfb7a, 0xfb78, 0xf916, 0xfb76,
+ 0xf915, 0xfb6e, 0xfb6d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c,
+ 0xf703, 0xf200, 0xf207, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510,
+ 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf202, 0xf911,
+ 0xf912, 0xf913, 0xf30b, 0xf90e, 0xf90f, 0xf910, 0xf30a, 0xf90b,
+ 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516,
+ 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
+ 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
+ 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+};
+
+u_short ctrl_map[NR_KEYS] = {
+ 0xf200, 0xf200, 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01d, 0xf01e,
+ 0xf01f, 0xf07f, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf200,
+ 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009,
+ 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf201, 0xf702, 0xf001, 0xf013,
+ 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200,
+ 0xf007, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016,
+ 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c,
+ 0xf703, 0xf000, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104,
+ 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf204, 0xf307,
+ 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
+ 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf10a,
+ 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603,
+ 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
+ 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+};
+
+u_short shift_ctrl_map[NR_KEYS] = {
+ 0xf200, 0xf200, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf200,
+ 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009,
+ 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013,
+ 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200,
+ 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016,
+ 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c,
+ 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307,
+ 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
+ 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
+ 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
+ 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+};
+
+u_short alt_map[NR_KEYS] = {
+ 0xf200, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836,
+ 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809,
+ 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869,
+ 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873,
+ 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b,
+ 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876,
+ 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c,
+ 0xf703, 0xf820, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504,
+ 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf907,
+ 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901,
+ 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a,
+ 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603,
+ 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116,
+ 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+};
+
+u_short ctrl_alt_map[NR_KEYS] = {
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809,
+ 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813,
+ 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200,
+ 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816,
+ 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c,
+ 0xf703, 0xf200, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504,
+ 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf200, 0xf307,
+ 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301,
+ 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf50a,
+ 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+ 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603,
+ 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c,
+ 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d,
+ 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200,
+};
+
+ushort *key_maps[MAX_NR_KEYMAPS] = {
+ plain_map, shift_map, altgr_map, 0,
+ ctrl_map, shift_ctrl_map, 0, 0,
+ alt_map, 0, 0, 0,
+ ctrl_alt_map, 0
+};
+
+unsigned int keymap_count = 7;
+
+/*
+ * Philosophy: most people do not define more strings, but they who do
+ * often want quite a lot of string space. So, we statically allocate
+ * the default and allocate dynamically in chunks of 512 bytes.
+ */
+
+char func_buf[] = {
+ '\033', '[', '[', 'A', 0,
+ '\033', '[', '[', 'B', 0,
+ '\033', '[', '[', 'C', 0,
+ '\033', '[', '[', 'D', 0,
+ '\033', '[', '[', 'E', 0,
+ '\033', '[', '1', '7', '~', 0,
+ '\033', '[', '1', '8', '~', 0,
+ '\033', '[', '1', '9', '~', 0,
+ '\033', '[', '2', '0', '~', 0,
+ '\033', '[', '2', '1', '~', 0,
+ '\033', '[', '2', '3', '~', 0,
+ '\033', '[', '2', '4', '~', 0,
+ '\033', '[', '2', '5', '~', 0,
+ '\033', '[', '2', '6', '~', 0,
+ '\033', '[', '2', '8', '~', 0,
+ '\033', '[', '2', '9', '~', 0,
+ '\033', '[', '3', '1', '~', 0,
+ '\033', '[', '3', '2', '~', 0,
+ '\033', '[', '3', '3', '~', 0,
+ '\033', '[', '3', '4', '~', 0,
+ '\033', '[', '1', '~', 0,
+ '\033', '[', '2', '~', 0,
+ '\033', '[', '3', '~', 0,
+ '\033', '[', '4', '~', 0,
+ '\033', '[', '5', '~', 0,
+ '\033', '[', '6', '~', 0,
+ '\033', '[', 'M', 0,
+ '\033', '[', 'P', 0,
+};
+
+char *funcbufptr = func_buf;
+int funcbufsize = sizeof(func_buf);
+int funcbufleft = 0; /* space left */
+
+char *func_table[MAX_NR_FUNC] = {
+ func_buf + 0,
+ func_buf + 5,
+ func_buf + 10,
+ func_buf + 15,
+ func_buf + 20,
+ func_buf + 25,
+ func_buf + 31,
+ func_buf + 37,
+ func_buf + 43,
+ func_buf + 49,
+ func_buf + 55,
+ func_buf + 61,
+ func_buf + 67,
+ func_buf + 73,
+ func_buf + 79,
+ func_buf + 85,
+ func_buf + 91,
+ func_buf + 97,
+ func_buf + 103,
+ func_buf + 109,
+ func_buf + 115,
+ func_buf + 120,
+ func_buf + 125,
+ func_buf + 130,
+ func_buf + 135,
+ func_buf + 140,
+ func_buf + 145,
+ 0,
+ 0,
+ func_buf + 149,
+ 0,
+};
+
+struct kbdiacr accent_table[MAX_DIACR] = {
+ {'`', 'A', '\300'}, {'`', 'a', '\340'},
+ {'\'', 'A', '\301'}, {'\'', 'a', '\341'},
+ {'^', 'A', '\302'}, {'^', 'a', '\342'},
+ {'~', 'A', '\303'}, {'~', 'a', '\343'},
+ {'"', 'A', '\304'}, {'"', 'a', '\344'},
+ {'O', 'A', '\305'}, {'o', 'a', '\345'},
+ {'0', 'A', '\305'}, {'0', 'a', '\345'},
+ {'A', 'A', '\305'}, {'a', 'a', '\345'},
+ {'A', 'E', '\306'}, {'a', 'e', '\346'},
+ {',', 'C', '\307'}, {',', 'c', '\347'},
+ {'`', 'E', '\310'}, {'`', 'e', '\350'},
+ {'\'', 'E', '\311'}, {'\'', 'e', '\351'},
+ {'^', 'E', '\312'}, {'^', 'e', '\352'},
+ {'"', 'E', '\313'}, {'"', 'e', '\353'},
+ {'`', 'I', '\314'}, {'`', 'i', '\354'},
+ {'\'', 'I', '\315'}, {'\'', 'i', '\355'},
+ {'^', 'I', '\316'}, {'^', 'i', '\356'},
+ {'"', 'I', '\317'}, {'"', 'i', '\357'},
+ {'-', 'D', '\320'}, {'-', 'd', '\360'},
+ {'~', 'N', '\321'}, {'~', 'n', '\361'},
+ {'`', 'O', '\322'}, {'`', 'o', '\362'},
+ {'\'', 'O', '\323'}, {'\'', 'o', '\363'},
+ {'^', 'O', '\324'}, {'^', 'o', '\364'},
+ {'~', 'O', '\325'}, {'~', 'o', '\365'},
+ {'"', 'O', '\326'}, {'"', 'o', '\366'},
+ {'/', 'O', '\330'}, {'/', 'o', '\370'},
+ {'`', 'U', '\331'}, {'`', 'u', '\371'},
+ {'\'', 'U', '\332'}, {'\'', 'u', '\372'},
+ {'^', 'U', '\333'}, {'^', 'u', '\373'},
+ {'"', 'U', '\334'}, {'"', 'u', '\374'},
+ {'\'', 'Y', '\335'}, {'\'', 'y', '\375'},
+ {'T', 'H', '\336'}, {'t', 'h', '\376'},
+ {'s', 's', '\337'}, {'"', 'y', '\377'},
+ {'s', 'z', '\337'}, {'i', 'j', '\377'},
+};
+
+unsigned int accent_table_size = 68;
diff -urN linux-2.4.26/drivers/char/gckeymap.map linux-2.4.26-vrs1/drivers/char/gckeymap.map
--- linux-2.4.26/drivers/char/gckeymap.map 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/gckeymap.map 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,357 @@
+# Default kernel keymap. This uses 7 modifier combinations.
+keymaps 0-2,4-5,8,12
+# Change the above line into
+# keymaps 0-2,4-6,8,12
+# in case you want the entries
+# altgr control keycode 83 = Boot
+# altgr control keycode 111 = Boot
+# below.
+#
+# In fact AltGr is used very little, and one more keymap can
+# be saved by mapping AltGr to Alt (and adapting a few entries):
+# keycode 100 = Alt
+#
+keycode 1 = Escape Escape
+ alt keycode 1 = Meta_Escape
+keycode 2 = one exclam
+ alt keycode 2 = Meta_one
+keycode 3 = two at at
+ control keycode 3 = nul
+ shift control keycode 3 = nul
+ alt keycode 3 = Meta_two
+keycode 4 = three numbersign
+ control keycode 4 = Escape
+ alt keycode 4 = Meta_three
+keycode 5 = four dollar dollar
+ control keycode 5 = Control_backslash
+ alt keycode 5 = Meta_four
+keycode 6 = five percent
+ control keycode 6 = Control_bracketright
+ alt keycode 6 = Meta_five
+keycode 7 = six asciicircum
+ control keycode 7 = Control_asciicircum
+ alt keycode 7 = Meta_six
+keycode 8 = seven ampersand braceleft
+ control keycode 8 = Control_underscore
+ alt keycode 8 = Meta_seven
+keycode 9 = eight asterisk bracketleft
+ control keycode 9 = Delete
+ alt keycode 9 = Meta_eight
+keycode 10 = nine parenleft bracketright
+ alt keycode 10 = Meta_nine
+keycode 11 = zero parenright braceright
+ alt keycode 11 = Meta_zero
+keycode 12 = minus underscore backslash
+ control keycode 12 = Control_underscore
+ shift control keycode 12 = Control_underscore
+ alt keycode 12 = Meta_minus
+keycode 13 = equal plus
+ alt keycode 13 = Meta_equal
+keycode 14 = Delete Delete
+ control keycode 14 = BackSpace
+ alt keycode 14 = Meta_Delete
+keycode 15 = Tab Tab
+ alt keycode 15 = Meta_Tab
+keycode 16 = q
+keycode 17 = w
+keycode 18 = e
+ altgr keycode 18 = Hex_E
+keycode 19 = r
+keycode 20 = t
+keycode 21 = y
+keycode 22 = u
+keycode 23 = i
+keycode 24 = o
+keycode 25 = p
+keycode 26 = bracketleft braceleft
+ control keycode 26 = Escape
+ alt keycode 26 = Meta_bracketleft
+keycode 27 = bracketright braceright asciitilde
+ control keycode 27 = Control_bracketright
+ alt keycode 27 = Meta_bracketright
+keycode 28 = Return
+ alt keycode 28 = Meta_Control_m
+keycode 29 = Control
+keycode 30 = a
+ altgr keycode 30 = Hex_A
+keycode 31 = s
+keycode 32 = d
+ altgr keycode 32 = Hex_D
+keycode 33 = f
+ altgr keycode 33 = Hex_F
+keycode 34 = g
+keycode 35 = h
+keycode 36 = j
+keycode 37 = k
+keycode 38 = l
+keycode 39 = semicolon colon
+ alt keycode 39 = Meta_semicolon
+keycode 40 = apostrophe quotedbl
+ control keycode 40 = Control_g
+ alt keycode 40 = Meta_apostrophe
+keycode 41 = grave asciitilde
+ control keycode 41 = nul
+ alt keycode 41 = Meta_grave
+keycode 42 = Shift
+keycode 43 = backslash bar
+ control keycode 43 = Control_backslash
+ alt keycode 43 = Meta_backslash
+keycode 44 = z
+keycode 45 = x
+keycode 46 = c
+ altgr keycode 46 = Hex_C
+keycode 47 = v
+keycode 48 = b
+ altgr keycode 48 = Hex_B
+keycode 49 = n
+keycode 50 = m
+keycode 51 = comma less
+ alt keycode 51 = Meta_comma
+keycode 52 = period greater
+ control keycode 52 = Compose
+ alt keycode 52 = Meta_period
+keycode 53 = slash question
+ control keycode 53 = Delete
+ alt keycode 53 = Meta_slash
+keycode 54 = Shift
+keycode 55 = KP_Multiply
+keycode 56 = Alt
+keycode 57 = space space
+ control keycode 57 = nul
+ alt keycode 57 = Meta_space
+keycode 58 = Caps_Lock
+keycode 59 = F1 F11 Console_13
+ control keycode 59 = F1
+ alt keycode 59 = Console_1
+ control alt keycode 59 = Console_1
+keycode 60 = F2 F12 Console_14
+ control keycode 60 = F2
+ alt keycode 60 = Console_2
+ control alt keycode 60 = Console_2
+keycode 61 = F3 F13 Console_15
+ control keycode 61 = F3
+ alt keycode 61 = Console_3
+ control alt keycode 61 = Console_3
+keycode 62 = F4 F14 Console_16
+ control keycode 62 = F4
+ alt keycode 62 = Console_4
+ control alt keycode 62 = Console_4
+keycode 63 = F5 F15 Console_17
+ control keycode 63 = F5
+ alt keycode 63 = Console_5
+ control alt keycode 63 = Console_5
+keycode 64 = F6 F16 Console_18
+ control keycode 64 = F6
+ alt keycode 64 = Console_6
+ control alt keycode 64 = Console_6
+keycode 65 = F7 F17 Console_19
+ control keycode 65 = F7
+ alt keycode 65 = Console_7
+ control alt keycode 65 = Console_7
+keycode 66 = F8 F18 Console_20
+ control keycode 66 = F8
+ alt keycode 66 = Console_8
+ control alt keycode 66 = Console_8
+keycode 67 = F9 F19 Console_21
+ control keycode 67 = F9
+ alt keycode 67 = Console_9
+ control alt keycode 67 = Console_9
+keycode 68 = F10 F20 Console_22
+ control keycode 68 = F10
+ alt keycode 68 = Console_10
+ control alt keycode 68 = Console_10
+keycode 69 = Num_Lock
+ shift keycode 69 = Bare_Num_Lock
+keycode 70 = Scroll_Lock Show_Memory Show_Registers
+ control keycode 70 = Show_State
+ alt keycode 70 = Scroll_Lock
+keycode 71 = KP_7
+ alt keycode 71 = Ascii_7
+ altgr keycode 71 = Hex_7
+keycode 72 = KP_8
+ alt keycode 72 = Ascii_8
+ altgr keycode 72 = Hex_8
+keycode 73 = KP_9
+ alt keycode 73 = Ascii_9
+ altgr keycode 73 = Hex_9
+keycode 74 = KP_Subtract
+keycode 75 = KP_4
+ alt keycode 75 = Ascii_4
+ altgr keycode 75 = Hex_4
+keycode 76 = KP_5
+ alt keycode 76 = Ascii_5
+ altgr keycode 76 = Hex_5
+keycode 77 = KP_6
+ alt keycode 77 = Ascii_6
+ altgr keycode 77 = Hex_6
+keycode 78 = KP_Add
+keycode 79 = KP_1
+ alt keycode 79 = Ascii_1
+ altgr keycode 79 = Hex_1
+keycode 80 = KP_2
+ alt keycode 80 = Ascii_2
+ altgr keycode 80 = Hex_2
+keycode 81 = KP_3
+ alt keycode 81 = Ascii_3
+ altgr keycode 81 = Hex_3
+keycode 82 = KP_0
+ alt keycode 82 = Ascii_0
+ altgr keycode 82 = Hex_0
+keycode 83 = KP_Period
+# altgr control keycode 83 = Boot
+ control alt keycode 83 = Boot
+keycode 84 = Last_Console
+keycode 85 =
+keycode 86 = less greater bar
+ alt keycode 86 = Meta_less
+keycode 87 = F11 F11 Console_23
+ control keycode 87 = F11
+ alt keycode 87 = Console_11
+ control alt keycode 87 = Console_11
+keycode 88 = F12 F12 Console_24
+ control keycode 88 = F12
+ alt keycode 88 = Console_12
+ control alt keycode 88 = Console_12
+keycode 89 =
+keycode 90 =
+keycode 91 =
+keycode 92 =
+keycode 93 =
+keycode 94 =
+keycode 95 =
+keycode 96 = KP_Enter
+keycode 97 = Control
+keycode 98 = KP_Divide
+keycode 99 = Control_backslash
+ control keycode 99 = Control_backslash
+ alt keycode 99 = Control_backslash
+keycode 100 = AltGr
+keycode 101 = Break
+keycode 102 = Find
+keycode 103 = Up
+keycode 104 = Prior
+ shift keycode 104 = Scroll_Backward
+keycode 105 = Left
+ alt keycode 105 = Decr_Console
+keycode 106 = Right
+ alt keycode 106 = Incr_Console
+keycode 107 = Select
+keycode 108 = Down
+keycode 109 = Next
+ shift keycode 109 = Scroll_Forward
+keycode 110 = Insert
+keycode 111 = Remove
+# altgr control keycode 111 = Boot
+ control alt keycode 111 = Boot
+keycode 112 = Macro
+keycode 113 = F13
+keycode 114 = F14
+keycode 115 = Help
+keycode 116 = Do
+keycode 117 = F17
+keycode 118 = KP_MinPlus
+keycode 119 = Pause
+keycode 120 =
+keycode 121 =
+keycode 122 =
+keycode 123 =
+keycode 124 =
+keycode 125 =
+keycode 126 =
+keycode 127 =
+string F1 = "\033[[A"
+string F2 = "\033[[B"
+string F3 = "\033[[C"
+string F4 = "\033[[D"
+string F5 = "\033[[E"
+string F6 = "\033[17~"
+string F7 = "\033[18~"
+string F8 = "\033[19~"
+string F9 = "\033[20~"
+string F10 = "\033[21~"
+string F11 = "\033[23~"
+string F12 = "\033[24~"
+string F13 = "\033[25~"
+string F14 = "\033[26~"
+string F15 = "\033[28~"
+string F16 = "\033[29~"
+string F17 = "\033[31~"
+string F18 = "\033[32~"
+string F19 = "\033[33~"
+string F20 = "\033[34~"
+string Find = "\033[1~"
+string Insert = "\033[2~"
+string Remove = "\033[3~"
+string Select = "\033[4~"
+string Prior = "\033[5~"
+string Next = "\033[6~"
+string Macro = "\033[M"
+string Pause = "\033[P"
+compose '`' 'A' to 'À'
+compose '`' 'a' to 'à'
+compose '\'' 'A' to 'Á'
+compose '\'' 'a' to 'á'
+compose '^' 'A' to 'Â'
+compose '^' 'a' to 'â'
+compose '~' 'A' to 'Ã'
+compose '~' 'a' to 'ã'
+compose '"' 'A' to 'Ä'
+compose '"' 'a' to 'ä'
+compose 'O' 'A' to 'Å'
+compose 'o' 'a' to 'å'
+compose '0' 'A' to 'Å'
+compose '0' 'a' to 'å'
+compose 'A' 'A' to 'Å'
+compose 'a' 'a' to 'å'
+compose 'A' 'E' to 'Æ'
+compose 'a' 'e' to 'æ'
+compose ',' 'C' to 'Ç'
+compose ',' 'c' to 'ç'
+compose '`' 'E' to 'È'
+compose '`' 'e' to 'è'
+compose '\'' 'E' to 'É'
+compose '\'' 'e' to 'é'
+compose '^' 'E' to 'Ê'
+compose '^' 'e' to 'ê'
+compose '"' 'E' to 'Ë'
+compose '"' 'e' to 'ë'
+compose '`' 'I' to 'Ì'
+compose '`' 'i' to 'ì'
+compose '\'' 'I' to 'Í'
+compose '\'' 'i' to 'í'
+compose '^' 'I' to 'Î'
+compose '^' 'i' to 'î'
+compose '"' 'I' to 'Ï'
+compose '"' 'i' to 'ï'
+compose '-' 'D' to 'Ð'
+compose '-' 'd' to 'ð'
+compose '~' 'N' to 'Ñ'
+compose '~' 'n' to 'ñ'
+compose '`' 'O' to 'Ò'
+compose '`' 'o' to 'ò'
+compose '\'' 'O' to 'Ó'
+compose '\'' 'o' to 'ó'
+compose '^' 'O' to 'Ô'
+compose '^' 'o' to 'ô'
+compose '~' 'O' to 'Õ'
+compose '~' 'o' to 'õ'
+compose '"' 'O' to 'Ö'
+compose '"' 'o' to 'ö'
+compose '/' 'O' to 'Ø'
+compose '/' 'o' to 'ø'
+compose '`' 'U' to 'Ù'
+compose '`' 'u' to 'ù'
+compose '\'' 'U' to 'Ú'
+compose '\'' 'u' to 'ú'
+compose '^' 'U' to 'Û'
+compose '^' 'u' to 'û'
+compose '"' 'U' to 'Ü'
+compose '"' 'u' to 'ü'
+compose '\'' 'Y' to 'Ý'
+compose '\'' 'y' to 'ý'
+compose 'T' 'H' to 'Þ'
+compose 't' 'h' to 'þ'
+compose 's' 's' to 'ß'
+compose '"' 'y' to 'ÿ'
+compose 's' 'z' to 'ß'
+compose 'i' 'j' to 'ÿ'
diff -urN linux-2.4.26/drivers/char/generic_serial.c linux-2.4.26-vrs1/drivers/char/generic_serial.c
--- linux-2.4.26/drivers/char/generic_serial.c 2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/char/generic_serial.c 2004-01-14 21:32:25.000000000 +0000
@@ -883,6 +883,9 @@
if(!memcmp(tiosp->c_cc, old_termios->c_cc, NCC)) printk("c_cc changed\n");
}
+ /*
+ * should be using tty_get_baud_rate() here -- rmk
+ */
baudrate = tiosp->c_cflag & CBAUD;
if (baudrate & CBAUDEX) {
baudrate &= ~CBAUDEX;
@@ -957,6 +960,11 @@
unsigned long flags;
unsigned long page;
+ /*
+ * Do we expect to allocate tmp_buf from an interrupt routine?
+ * If not, then save_flags() cli() and restore_flags() are
+ * redundant here and should be replaced by a semaphore. -- rmk
+ */
save_flags (flags);
if (!tmp_buf) {
page = get_free_page(GFP_KERNEL);
@@ -976,6 +984,11 @@
if (port->flags & ASYNC_INITIALIZED)
return 0;
+ /*
+ * Do we expect to allocate xmit_buf from an interrupt routine?
+ * If not, then save_flags() cli() and restore_flags() are
+ * redundant here and should be replaced by a semaphore. -- rmk
+ */
if (!port->xmit_buf) {
/* We may sleep in get_free_page() */
unsigned long tmp;
@@ -1016,7 +1029,7 @@
struct serial_struct sio;
if (copy_from_user(&sio, sp, sizeof(struct serial_struct)))
- return(-EFAULT);
+ return -EFAULT;
if (!capable(CAP_SYS_ADMIN)) {
if ((sio.baud_base != port->baud_base) ||
diff -urN linux-2.4.26/drivers/char/keyboard.c linux-2.4.26-vrs1/drivers/char/keyboard.c
--- linux-2.4.26/drivers/char/keyboard.c 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/char/keyboard.c 2004-02-11 01:12:05.000000000 +0000
@@ -14,13 +14,17 @@
* `Sticky' modifier keys, 951006.
*
* 11-11-96: SAK should now work in the raw mode (Martin Mares)
- *
+ *
* Modified to provide 'generic' keyboard support by Hamish Macdonald
* Merge with the m68k keyboard driver and split-off of the PC low-level
* parts by Geert Uytterhoeven, May 1997
*
* 27-05-97: Added support for the Magic SysRq Key (Martin Mares)
* 30-07-98: Dead keys redone, aeb@cwi.nl.
+ *
+ * 04-04-1998: Added keyboard autorepeat support (some keyboards don't
+ * autorepeat, and some keyboard changers interfere with keyboard
+ * autorepeat settings). - Russell King (rmk@arm.linux.org.uk)
*/
#include <linux/config.h>
@@ -30,6 +34,7 @@
#include <linux/tty_flip.h>
#include <linux/mm.h>
#include <linux/string.h>
+#include <linux/timer.h>
#include <linux/random.h>
#include <linux/init.h>
@@ -61,6 +66,14 @@
#define KBD_DEFLOCK 0
#endif
+/*
+ * Default autorepeat settings.
+ * DEFAULT_REPEAT_TIMEOUT is the timeout from the keypress to the first repeat
+ * DEFAULT_REPEAT_INTERVAL is the timeout between successive repeats
+ */
+#define DEFAULT_REPEAT_TIMEOUT HZ*300/1000
+#define DEFAULT_REPEAT_INTERVAL HZ*30/1000
+
void (*kbd_ledfunc)(unsigned int led);
EXPORT_SYMBOL(handle_scancode);
EXPORT_SYMBOL(kbd_ledfunc);
@@ -82,21 +95,25 @@
static unsigned long key_down[256/BITS_PER_LONG];
static int dead_key_next;
-/*
+/*
* In order to retrieve the shift_state (for the mouse server), either
- * the variable must be global, or a new procedure must be created to
+ * the variable must be global, or a new procedure must be created to
* return the value. I chose the former way.
*/
int shift_state;
static int npadch = -1; /* -1 or number assembled on pad */
static unsigned char diacr;
static char rep; /* flag telling character repeat */
+static int kbd_repeatkeycode= -1;
+static int kbd_repeattimeout = DEFAULT_REPEAT_TIMEOUT;
+static int kbd_repeatinterval= DEFAULT_REPEAT_INTERVAL;
struct kbd_struct kbd_table[MAX_NR_CONSOLES];
static struct tty_struct **ttytab;
static struct kbd_struct * kbd = kbd_table;
static struct tty_struct * tty;
static unsigned char prev_scancode;
+static void kbd_processkeycode(unsigned char scancode, char up_flag, int autorepeat);
void compute_shiftstate(void);
typedef void (*k_hand)(unsigned char value, char up_flag);
@@ -163,7 +180,8 @@
* string, and in both cases we might assume that it is
* in utf-8 already.
*/
-void to_utf8(ushort c) {
+void to_utf8(ushort c)
+{
if (c < 0x80)
put_queue(c); /* 0******* */
else if (c < 0x800) {
@@ -182,17 +200,23 @@
* Translation of escaped scancodes to keycodes.
* This is now user-settable (for machines were it makes sense).
*/
-
int setkeycode(unsigned int scancode, unsigned int keycode)
{
- return kbd_setkeycode(scancode, keycode);
+ return kbd_setkeycode(scancode, keycode);
}
int getkeycode(unsigned int scancode)
{
- return kbd_getkeycode(scancode);
+ return kbd_getkeycode(scancode);
}
+static void key_callback(unsigned long nr);
+
+static struct timer_list key_autorepeat_timer =
+{
+ function: key_callback
+};
+
void handle_scancode(unsigned char scancode, int down)
{
unsigned char keycode;
@@ -201,6 +225,7 @@
char have_keycode;
pm_access(pm_kbd);
+
add_keyboard_randomness(scancode | up_flag);
tty = ttytab? ttytab[fg_console]: NULL;
@@ -223,15 +248,15 @@
if (raw_mode) {
/*
* The following is a workaround for hardware
- * which sometimes send the key release event twice
+ * which sometimes send the key release event twice
*/
unsigned char next_scancode = scancode|up_flag;
if (have_keycode && up_flag && next_scancode==prev_scancode) {
/* unexpected 2nd release event */
} else {
- /*
+ /*
* Only save previous scancode if it was a key-up
- * and had a single-byte scancode.
+ * and had a single-byte scancode.
*/
if (!have_keycode)
prev_scancode = 1;
@@ -256,12 +281,35 @@
* return the keycode if in MEDIUMRAW mode.
*/
+ kbd_processkeycode(keycode, up_flag, 0);
+
+out:
+ do_poke_blanked_console = 1;
+ schedule_console_callback();
+}
+
+static void
+kbd_processkeycode(unsigned char keycode, char up_flag, int autorepeat)
+{
+ char raw_mode = (kbd->kbdmode == VC_RAW);
+
if (up_flag) {
rep = 0;
if(!test_and_clear_bit(keycode, key_down))
up_flag = kbd_unexpected_up(keycode);
- } else
+ } else {
rep = test_and_set_bit(keycode, key_down);
+ /* If the keyboard autorepeated for us, ignore it.
+ * We do our own autorepeat processing.
+ */
+ if (rep && !autorepeat)
+ return;
+ }
+
+ if (kbd_repeatkeycode == keycode || !up_flag || raw_mode) {
+ kbd_repeatkeycode = -1;
+ del_timer(&key_autorepeat_timer);
+ }
#ifdef CONFIG_MAGIC_SYSRQ /* Handle the SysRq Hack */
if (keycode == SYSRQ_KEY) {
@@ -275,6 +323,23 @@
}
#endif
+ /*
+ * Calculate the next time when we have to do some autorepeat
+ * processing. Note that we do not do autorepeat processing
+ * while in raw mode but we do do autorepeat processing in
+ * medium raw mode.
+ */
+ if (!up_flag && !raw_mode) {
+ kbd_repeatkeycode = keycode;
+ if (vc_kbd_mode(kbd, VC_REPEAT)) {
+ if (rep)
+ key_autorepeat_timer.expires = jiffies + kbd_repeatinterval;
+ else
+ key_autorepeat_timer.expires = jiffies + kbd_repeattimeout;
+ add_timer(&key_autorepeat_timer);
+ }
+ }
+
if (kbd->kbdmode == VC_MEDIUMRAW) {
/* soon keycodes will require more than one byte */
put_queue(keycode + up_flag);
@@ -343,9 +408,24 @@
#endif
}
}
+ rep = 0;
out:
- do_poke_blanked_console = 1;
- schedule_console_callback();
+}
+
+/*
+ * This clears the key down arrays when the keyboard is reset. On
+ * keyboard reset, this must be called before any keycodes are
+ * received.
+ */
+void kbd_reset_kdown(void)
+{
+ int i;
+
+ for (i = 0; i < NR_SHIFT; i++)
+ k_down[i] = 0;
+ for (i = 0; i < SIZE(key_down); i++)
+ key_down[i] = 0;
+ shift_state = 0;
}
void put_queue(int ch)
@@ -453,7 +533,7 @@
static void decr_console(void)
{
int i;
-
+
for (i = fg_console-1; i != fg_console; i--) {
if (i == -1)
i = MAX_NR_CONSOLES-1;
@@ -531,7 +611,7 @@
{
}
-static void do_null()
+static void do_null(void)
{
compute_shiftstate();
}
@@ -646,8 +726,8 @@
static void do_pad(unsigned char value, char up_flag)
{
- static const char *pad_chars = "0123456789+-*/\015,.?()";
- static const char *app_map = "pqrstuvwxylSRQMnnmPQ";
+ static const char *pad_chars = "0123456789+-*/\015,.?()#";
+ static const char *app_map = "pqrstuvwxylSRQMnnmPQS";
if (up_flag)
return; /* no action, if this is a key release */
@@ -748,9 +828,10 @@
}
}
-/* called after returning from RAW mode or when changing consoles -
- recompute k_down[] and shift_state from key_down[] */
-/* maybe called when keymap is undefined, so that shiftkey release is seen */
+/* Called after returning from RAW mode or when changing consoles -
+ * recompute k_down[] and shift_state from key_down[]
+ * Maybe called when keymap is undefined so that shift key release is seen
+ */
void compute_shiftstate(void)
{
int i, j, k, sym, val;
@@ -829,19 +910,22 @@
}
/*
- * The leds display either (i) the status of NumLock, CapsLock, ScrollLock,
- * or (ii) whatever pattern of lights people want to show using KDSETLED,
- * or (iii) specified bits of specified words in kernel memory.
+ * The leds display either
+ * (i) the status of NumLock, CapsLock, ScrollLock, or
+ * (ii) whatever pattern of lights people want to show using KDSETLED, or
+ * (iii) specified bits of specified words in kernel memory.
*/
static unsigned char ledstate = 0xff; /* undefined */
static unsigned char ledioctl;
-unsigned char getledstate(void) {
+unsigned char getledstate(void)
+{
return ledstate;
}
-void setledstate(struct kbd_struct *kbd, unsigned int led) {
+void setledstate(struct kbd_struct *kbd, unsigned int led)
+{
if (!(led & ~7)) {
ledioctl = led;
kbd->ledmode = LED_SHOW_IOCTL;
@@ -857,7 +941,8 @@
} ledptrs[3];
void register_leds(int console, unsigned int led,
- unsigned int *addr, unsigned int mask) {
+ unsigned int *addr, unsigned int mask)
+{
struct kbd_struct *kbd = kbd_table + console;
if (led < 3) {
ledptrs[led].addr = addr;
@@ -868,7 +953,8 @@
kbd->ledmode = LED_SHOW_FLAGS;
}
-static inline unsigned char getleds(void){
+static inline unsigned char getleds(void)
+{
struct kbd_struct *kbd = kbd_table + fg_console;
unsigned char leds;
@@ -915,6 +1001,19 @@
{
unsigned char leds = getleds();
+ if (rep && kbd_repeatkeycode != -1) {
+ tty = ttytab? ttytab[fg_console]: NULL;
+ kbd = kbd_table + fg_console;
+
+ /* This prevents the kbd_key routine from being called
+ * twice, once by this BH, and once by the interrupt
+ * routine.
+ */
+ kbd_disable_irq();
+ kbd_processkeycode(kbd_repeatkeycode, 0, 1);
+ kbd_enable_irq();
+ }
+
if (leds != ledstate) {
ledstate = leds;
kbd_leds(leds);
@@ -937,6 +1036,12 @@
tasklet_enable(&keyboard_tasklet);
}
+static void key_callback(unsigned long nr)
+{
+ rep = 1;
+ tasklet_schedule(&keyboard_tasklet);
+}
+
typedef void (pm_kbd_func) (void);
pm_callback pm_kbd_request_override = NULL;
@@ -953,7 +1058,7 @@
kbd0.slockstate = 0;
kbd0.modeflags = KBD_DEFMODE;
kbd0.kbdmode = VC_XLATE;
-
+
for (i = 0 ; i < MAX_NR_CONSOLES ; i++)
kbd_table[i] = kbd0;
@@ -963,7 +1068,7 @@
tasklet_enable(&keyboard_tasklet);
tasklet_schedule(&keyboard_tasklet);
-
+
pm_kbd = pm_register(PM_SYS_DEV, PM_SYS_KBC, pm_kbd_request_override);
return 0;
diff -urN linux-2.4.26/drivers/char/mem.c linux-2.4.26-vrs1/drivers/char/mem.c
--- linux-2.4.26/drivers/char/mem.c 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/char/mem.c 2004-01-14 21:39:01.000000000 +0000
@@ -27,9 +27,6 @@
#include <asm/io.h>
#include <asm/pgalloc.h>
-#ifdef CONFIG_I2C
-extern int i2c_init_all(void);
-#endif
#ifdef CONFIG_FB
extern void fbmem_init(void);
#endif
@@ -740,9 +737,6 @@
printk("unable to get major %d for memory devs\n", MEM_MAJOR);
memory_devfs_register();
rand_initialize();
-#ifdef CONFIG_I2C
- i2c_init_all();
-#endif
#if defined (CONFIG_FB)
fbmem_init();
#endif
diff -urN linux-2.4.26/drivers/char/omaha-rtc.c linux-2.4.26-vrs1/drivers/char/omaha-rtc.c
--- linux-2.4.26/drivers/char/omaha-rtc.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/omaha-rtc.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,566 @@
+/*
+ * (C) ARM Limited 2002.
+ *
+ * Real Time Clock interface for Linux on Omaha
+ *
+ * Based on sa1100-rtc.c
+ *
+ * Copyright (c) 2000 Nils Faerber
+ *
+ * Based on rtc.c by Paul Gortmaker
+ * Date/time conversion routines taken from arch/arm/kernel/time.c
+ * by Linus Torvalds and Russell King
+ * and the GNU C Library
+ * ( ... I love the GPL ... just take what you need! ;)
+ *
+ * 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.
+ *
+ * 1.00 2001-06-08 Nicolas Pitre <nico@cam.org>
+ * - added periodic timer capability using OSMR1
+ * - flag compatibility with other RTC chips
+ * - permission checks for ioctls
+ * - major cleanup, partial rewrite
+ *
+ * 0.03 2001-03-07 CIH <cih@coventive.com>
+ * - Modify the bug setups RTC clock.
+ *
+ * 0.02 2001-02-27 Nils Faerber <nils@@kernelconcepts.de>
+ * - removed mktime(), added alarm irq clear
+ *
+ * 0.01 2000-10-01 Nils Faerber <nils@@kernelconcepts.de>
+ * - initial release
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/poll.h>
+#include <linux/proc_fs.h>
+#include <asm/bitops.h>
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <linux/rtc.h>
+#include <linux/mc146818rtc.h>
+
+#define DRIVER_VERSION "1.00"
+
+#define epoch 1970
+
+#define TIMER_FREQ 3686400
+
+#define RTC_DEF_DIVIDER 32768 - 1
+#define RTC_DEF_TRIM 0
+
+/* Those are the bits from a classic RTC we want to mimic */
+#define RTC_IRQF 0x80 /* any of the following 3 is active */
+#define RTC_PF 0x40
+#define RTC_AF 0x20
+#define RTC_UF 0x10
+
+// bitdefs for rtc registers
+#define TICNT_ENABLE 0x80 // Enable tick interrupt
+#define TICNT_PERIOD 0x7F // Divisor required for 1Hz tick
+#define RTC_ENABLE 0x1 // Enable bit for RTC
+
+static unsigned long rtc_status;
+static unsigned long rtc_irq_data;
+static unsigned long rtc_freq = 1024;
+
+static struct fasync_struct *rtc_async_queue;
+static DECLARE_WAIT_QUEUE_HEAD(rtc_wait);
+
+extern spinlock_t rtc_lock;
+
+static const unsigned char days_in_mo[] =
+ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
+#define is_leap(year) \
+ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
+
+// all the alarm and rtc registers
+static volatile unsigned int almsec = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_ALMSEC);
+static volatile unsigned int almmin = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_ALMMIN);
+static volatile unsigned int almhour = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_ALMHOUR);
+static volatile unsigned int almday = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_ALMDAY);
+static volatile unsigned int almmon = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_ALMMON);
+static volatile unsigned int almyear = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_ALMYEAR);
+
+static volatile unsigned int bcdsec = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_BCDSEC);
+static volatile unsigned int bcdmin = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_BCDMIN);
+static volatile unsigned int bcdhour = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_BCDHOUR);
+static volatile unsigned int bcdday = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_BCDDAY);
+static volatile unsigned int bcddate = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_BCDDATE);
+static volatile unsigned int bcdmon = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_BCDMON);
+static volatile unsigned int bcdyear = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_BCDYEAR);
+
+/*
+ * Converts seconds since 1970-01-01 00:00:00 to Gregorian date.
+ */
+
+static void decodetime (unsigned long t, struct rtc_time *tval)
+{
+ long days, month, year, rem;
+
+ days = t / 86400;
+ rem = t % 86400;
+ tval->tm_hour = rem / 3600;
+ rem %= 3600;
+ tval->tm_min = rem / 60;
+ tval->tm_sec = rem % 60;
+ tval->tm_wday = (4 + days) % 7;
+
+#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)
+
+ year = epoch;
+ while (days >= (365 + is_leap(year))) {
+ unsigned long yg = year + days / 365;
+ days -= ((yg - year) * 365
+ + LEAPS_THRU_END_OF (yg - 1)
+ - LEAPS_THRU_END_OF (year - 1));
+ year = yg;
+ }
+ tval->tm_year = year - 1900;
+ tval->tm_yday = days + 1;
+
+ month = 0;
+ if (days >= 31) {
+ days -= 31;
+ month++;
+ if (days >= (28 + is_leap(year))) {
+ days -= (28 + is_leap(year));
+ month++;
+ while (days >= days_in_mo[month]) {
+ days -= days_in_mo[month];
+ month++;
+ }
+ }
+ }
+ tval->tm_mon = month;
+ tval->tm_mday = days + 1;
+}
+
+// Get alarm time in seconds
+static unsigned long get_alarm_time(void)
+{
+ int sec, min,hour,date,mon,year;
+
+ // Read data from h/w
+ year = __raw_readb(almyear);
+ mon = __raw_readb(almmon);
+ date = __raw_readb(almday);
+ hour = __raw_readb(almhour);
+ min = __raw_readb(almmin);
+ sec = __raw_readb(almsec);
+
+ // convert all the data into binary
+ year = BCD_TO_BIN(year);
+ mon = BCD_TO_BIN(mon);
+ date = BCD_TO_BIN(date);
+ hour = BCD_TO_BIN(hour);
+ min = BCD_TO_BIN(min);
+ sec = BCD_TO_BIN(sec);
+
+ // convert year to 19xx or 20xx as appropriate
+ if (year > 69)
+ year += 1900;
+ else
+ year += 2000;
+
+ // Now calculate number of seconds since time began...
+ return mktime(year,mon,date,hour,min,sec);
+}
+
+// Get rtc time in seconds
+static unsigned long get_rtc_time(void)
+{
+ int sec,min,hour,day,date,mon,year;
+
+ // Read data from h/w
+ year = __raw_readb(bcdyear);
+ mon = __raw_readb(bcdmon);
+ date = __raw_readb(bcdday);
+ day = __raw_readb(bcddate);
+ hour = __raw_readb(bcdhour);
+ min = __raw_readb(bcdmin);
+ sec = __raw_readb(bcdsec);
+
+ // convert all the data into binary
+ year = BCD_TO_BIN(year);
+ mon = BCD_TO_BIN(mon);
+ date = BCD_TO_BIN(date);
+ day = BCD_TO_BIN(day);
+ hour = BCD_TO_BIN(hour);
+ min = BCD_TO_BIN(min);
+ sec = BCD_TO_BIN(sec);
+
+ // convert year to 19xx or 20xx as appropriate
+ if (year > 69)
+ year += 1900;
+ else
+ year += 2000;
+
+ // Now calculate number of seconds since time began...
+ return mktime(year,mon,date,hour,min,sec);
+}
+
+/* Sets time of alarm */
+static void set_alarm_time(struct rtc_time *tval)
+{
+
+ int sec,min,hour,day,mon,year;
+
+ // Convert data from binary to 8-bit bcd
+ sec = BIN_TO_BCD(tval->tm_sec);
+ min = BIN_TO_BCD(tval->tm_min);
+ hour = BIN_TO_BCD(tval->tm_hour);
+ day = BIN_TO_BCD(tval->tm_mday);
+ mon = BIN_TO_BCD(tval->tm_mon);
+
+ // Year is special
+ year = tval->tm_year;
+ if(year > 1999)
+ year -=2000;
+ else
+ year -=1900;
+
+ year = BIN_TO_BCD(year);
+
+ // Write all the registers
+ __raw_writeb(year,almyear);
+ __raw_writeb(mon,almmon);
+ __raw_writeb(day,almday);
+ __raw_writeb(hour,almhour);
+ __raw_writeb(min,almmin);
+ __raw_writeb(sec,almsec);
+}
+
+/* Sets time of alarm */
+static void set_rtc_time(struct rtc_time *tval)
+{
+
+ int sec,min,hour,day,date,mon,year;
+
+ // Convert data from binary to 8-bit bcd
+ sec = BIN_TO_BCD(tval->tm_sec);
+ min = BIN_TO_BCD(tval->tm_min);
+ hour = BIN_TO_BCD(tval->tm_hour);
+ day = BIN_TO_BCD(tval->tm_mday);
+ date = BIN_TO_BCD(tval->tm_wday);
+ mon = BIN_TO_BCD(tval->tm_mon);
+
+ // Year is special
+ year = tval->tm_year;
+ if(year > 1999)
+ year -=2000;
+ else
+ year -=1900;
+
+ year = BIN_TO_BCD(year);
+
+ // Write all the registers
+ __raw_writeb(year,bcdyear);
+ __raw_writeb(mon,bcdmon);
+ __raw_writeb(date,bcddate);
+ __raw_writeb(day,bcdday);
+ __raw_writeb(hour,bcdhour);
+ __raw_writeb(min,bcdmin);
+ __raw_writeb(sec,bcdsec);
+}
+
+static void rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ /* update irq data & counter */
+ rtc_irq_data += 0x100;
+
+ /* wake up waiting process */
+ wake_up_interruptible(&rtc_wait);
+ kill_fasync (&rtc_async_queue, SIGIO, POLL_IN);
+}
+
+static int rtc_open(struct inode *inode, struct file *file)
+{
+ if (test_and_set_bit (1, &rtc_status))
+ return -EBUSY;
+ MOD_INC_USE_COUNT;
+ rtc_irq_data = 0;
+ return 0;
+}
+
+static int rtc_release(struct inode *inode, struct file *file)
+{
+ rtc_status = 0;
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+static int rtc_fasync (int fd, struct file *filp, int on)
+{
+ return fasync_helper (fd, filp, on, &rtc_async_queue);
+}
+
+static unsigned int rtc_poll(struct file *file, poll_table *wait)
+{
+ poll_wait (file, &rtc_wait, wait);
+ return (rtc_irq_data) ? 0 : POLLIN | POLLRDNORM;
+}
+
+static loff_t rtc_llseek(struct file *file, loff_t offset, int origin)
+{
+ return -ESPIPE;
+}
+
+ssize_t rtc_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+ DECLARE_WAITQUEUE(wait, current);
+ unsigned long data;
+ ssize_t retval;
+
+ if (count < sizeof(unsigned long))
+ return -EINVAL;
+
+ add_wait_queue(&rtc_wait, &wait);
+ set_current_state(TASK_INTERRUPTIBLE);
+ for (;;) {
+ spin_lock_irq (&rtc_lock);
+ data = rtc_irq_data;
+ if (data != 0) {
+ rtc_irq_data = 0;
+ break;
+ }
+ spin_unlock_irq (&rtc_lock);
+
+ if (file->f_flags & O_NONBLOCK) {
+ retval = -EAGAIN;
+ goto out;
+ }
+
+ if (signal_pending(current)) {
+ retval = -ERESTARTSYS;
+ goto out;
+ }
+
+ schedule();
+ }
+
+ spin_unlock_irq (&rtc_lock);
+
+ data -= 0x100; /* the first IRQ wasn't actually missed */
+
+ retval = put_user(data, (unsigned long *)buf);
+ if (!retval)
+ retval = sizeof(unsigned long);
+
+out:
+ set_current_state(TASK_RUNNING);
+ remove_wait_queue(&rtc_wait, &wait);
+ return retval;
+}
+
+static int rtc_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ volatile unsigned int rtcalm = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_RTCALM);
+ volatile unsigned int ticnt = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_TICINT);
+
+ struct rtc_time tm, tm2;
+ switch (cmd) {
+ case RTC_AIE_OFF:
+ spin_lock_irq(&rtc_lock);
+ __raw_writel(0,rtcalm);
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_AIE_ON:
+ spin_lock_irq(&rtc_lock);
+ __raw_writel(0x7F,rtcalm);
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_UIE_OFF:
+ spin_lock_irq(&rtc_lock);
+ __raw_writel(~TICNT_ENABLE,ticnt);
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_UIE_ON:
+ spin_lock_irq(&rtc_lock);
+ __raw_writel(TICNT_ENABLE|TICNT_PERIOD,ticnt);
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_PIE_OFF:
+ spin_lock_irq(&rtc_lock);
+ // Periodic int not available
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_PIE_ON:
+ spin_lock_irq(&rtc_lock);
+ // Periodic int not available
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_ALM_READ:
+ decodetime(get_alarm_time(),&tm);
+ break;
+ case RTC_ALM_SET:
+ if (copy_from_user (&tm2, (struct rtc_time*)arg, sizeof (tm2)))
+ return -EFAULT;
+ decodetime(get_rtc_time(),&tm);
+ if ((unsigned)tm2.tm_hour < 24)
+ tm.tm_hour = tm2.tm_hour;
+ if ((unsigned)tm2.tm_min < 60)
+ tm.tm_min = tm2.tm_min;
+ if ((unsigned)tm2.tm_sec < 60)
+ tm.tm_sec = tm2.tm_sec;
+
+ // Munge (as per sa1100)
+ tm.tm_year+=1900;
+ tm.tm_mon+=1;
+
+ // Set the alarm
+ set_alarm_time(&tm);
+ return 0;
+ case RTC_RD_TIME:
+ decodetime (get_rtc_time(), &tm);
+ break;
+ case RTC_SET_TIME:
+ if (!capable(CAP_SYS_TIME))
+ return -EACCES;
+ if (copy_from_user (&tm, (struct rtc_time*)arg, sizeof (tm)))
+ return -EFAULT;
+ tm.tm_year += 1900;
+ if (tm.tm_year < epoch || (unsigned)tm.tm_mon >= 12 ||
+ tm.tm_mday < 1 || tm.tm_mday > (days_in_mo[tm.tm_mon] +
+ (tm.tm_mon == 1 && is_leap(tm.tm_year))) ||
+ (unsigned)tm.tm_hour >= 24 ||
+ (unsigned)tm.tm_min >= 60 ||
+ (unsigned)tm.tm_sec >= 60)
+ return -EINVAL;
+ tm.tm_mon +=1; // wierd: same as sa1100 though (gets month wrong otherwise!)
+ set_rtc_time(&tm);
+ return 0;
+ case RTC_IRQP_READ:
+ return put_user(rtc_freq, (unsigned long *)arg);
+ case RTC_IRQP_SET:
+ if (arg < 1 || arg > TIMER_FREQ)
+ return -EINVAL;
+ if ((arg > 64) && (!capable(CAP_SYS_RESOURCE)))
+ return -EACCES;
+ rtc_freq = arg;
+ return 0;
+ case RTC_EPOCH_READ:
+ return put_user (epoch, (unsigned long *)arg);
+ default:
+ return -EINVAL;
+ }
+ return copy_to_user ((void *)arg, &tm, sizeof (tm)) ? -EFAULT : 0;
+}
+
+static struct file_operations rtc_fops = {
+ .owner = THIS_MODULE,
+ .llseek = rtc_llseek,
+ .read = rtc_read,
+ .poll = rtc_poll,
+ .ioctl = rtc_ioctl,
+ .open = rtc_open,
+ .release = rtc_release,
+ .fasync = rtc_fasync,
+};
+
+static struct miscdevice omahartc_miscdev = {
+ .minor = RTC_MINOR,
+ .name = "rtc",
+ .fops = &rtc_fops,
+};
+
+static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ char *p = page;
+ int len;
+ struct rtc_time tm;
+
+ decodetime (get_rtc_time(), &tm);
+ p += sprintf(p, "rtc_time\t: %02d:%02d:%02d\n"
+ "rtc_date\t: %04d-%02d-%02d\n"
+ "rtc_epoch\t: %04d\n",
+ tm.tm_hour, tm.tm_min, tm.tm_sec,
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, epoch);
+ decodetime (get_alarm_time(), &tm);
+ p += sprintf(p, "alrm_time\t: %02d:%02d:%02d\n"
+ "alrm_date\t: %04d-%02d-%02d\n",
+ tm.tm_hour, tm.tm_min, tm.tm_sec,
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
+ p += sprintf(p, "periodic_freq\t: %ld\n", rtc_freq);
+
+ len = (p - page) - off;
+ if (len < 0)
+ len = 0;
+
+ *eof = (len <= count) ? 1 : 0;
+ *start = page + off;
+
+ return len;
+}
+
+static int __init rtc_init(void)
+{
+ volatile unsigned int ticnt = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_TICINT);
+ volatile unsigned int rtccon = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_RTCCON);
+ int ret;
+
+ misc_register (&omahartc_miscdev);
+ create_proc_read_entry ("driver/rtc", 0, 0, rtc_read_proc, NULL);
+
+ // Enable RTC
+ __raw_writel(RTC_ENABLE,rtccon);
+
+ // Acquire 1Hz timer
+ ret = request_irq (OMAHA_INT_TICK, rtc_interrupt, SA_INTERRUPT, "rtc 1Hz", NULL);
+ if (ret) {
+ printk (KERN_ERR "rtc: IRQ %d already in use.\n", OMAHA_INT_TICK);
+ goto IRQ_TICK_failed;
+ }
+
+ // Acquire RTC (Alarm interrupt)
+ ret = request_irq (OMAHA_INT_RTC, rtc_interrupt, SA_INTERRUPT, "rtc Alrm", NULL);
+ if (ret) {
+ printk (KERN_ERR "rtc: IRQ %d already in use.\n", OMAHA_INT_RTC);
+ goto IRQ_RTC_failed;
+ }
+
+ printk (KERN_INFO "Omaha Real Time Clock driver v" DRIVER_VERSION "\n");
+
+ // Program tick interrupt divisor to generate real 1Hz clock and enable the interrupt
+ __raw_writeb(TICNT_ENABLE|TICNT_PERIOD,ticnt);
+
+ return 0;
+
+IRQ_TICK_failed:
+ free_irq (OMAHA_INT_TICK, NULL);
+IRQ_RTC_failed:
+ free_irq(OMAHA_INT_RTC, NULL);
+ remove_proc_entry ("driver/rtc", NULL);
+ misc_deregister (&omahartc_miscdev);
+ return ret;
+}
+
+static void __exit rtc_exit(void)
+{
+ free_irq (OMAHA_INT_TICK, NULL);
+ remove_proc_entry ("driver/rtc", NULL);
+ misc_deregister (&omahartc_miscdev);
+}
+
+module_init(rtc_init);
+module_exit(rtc_exit);
+
+MODULE_AUTHOR("ARM Limited <support@arm.com>");
+MODULE_DESCRIPTION("Omaha Realtime Clock Driver (RTC)");
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/char/omaha_wdt.c linux-2.4.26-vrs1/drivers/char/omaha_wdt.c
--- linux-2.4.26/drivers/char/omaha_wdt.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/omaha_wdt.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,193 @@
+/*
+ * Watchdog driver for the Omaha
+ * (C) ARM Limited 2002.
+ *
+ * Based on sa1100_wdt.c
+ *
+ * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
+ * Based on SoftDog driver by Alan Cox <alan@redhat.com>
+ *
+ * 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.
+ *
+ * Neither Oleg Drokin nor iXcelerator.com admit liability nor provide
+ * warranty for any of this software. This material is provided
+ * "AS-IS" and at no charge.
+ *
+ * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
+ *
+ * 27/11/2000 Initial release
+ */
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <linux/reboot.h>
+#include <linux/smp_lock.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/bitops.h>
+
+#define TIMER_MARGIN 8 /* (secs) Default is 1 minute */
+#define WT_TPS 7812 /* Watchdog ticks per second. */
+#define WT_ENABLE 0x21 // Enable bits for watchdog
+#define WT_CLKSEL_128 0x18 // Select 1/128 divider
+
+static int omaha_margin = TIMER_MARGIN; /* in seconds */
+static int omahawdt_users;
+static int pre_margin;
+#ifdef MODULE
+MODULE_PARM(omaha_margin,"i");
+#endif
+
+/*
+ * Allow only one person to hold it open
+ */
+
+static int omahadog_open(struct inode *inode, struct file *file)
+{
+ volatile unsigned int wtcon = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_WTCON);
+ volatile unsigned int wtdat = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_WTDAT);
+ volatile unsigned int wtcnt = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_WTCNT);
+ unsigned int tmp;
+
+ if(test_and_set_bit(1,&omahawdt_users))
+ return -EBUSY;
+ MOD_INC_USE_COUNT;
+ /* Activate omaha Watchdog timer */
+
+ /* Assume that uhal has set up pre-scaler according
+ * to the system clock frequency (don't change it!)
+ *
+ * Ie. all counting occurs at 1MHz / 128 = 7812.5Hz
+ *
+ * Since we have 16-bit counter, maximum period is
+ * 65536/7812.5 = 8.338608 seconds!
+ */
+
+ pre_margin = WT_TPS * omaha_margin;
+
+ // Set count to the maximum
+ __raw_writel(pre_margin,wtcnt);
+
+ // Set the clock division factor
+ tmp = __raw_readl(wtcon);
+ tmp |= WT_CLKSEL_128;
+ __raw_writel(tmp,wtcon);
+
+ // Program an initial count into WTDAT
+ __raw_writel(0x8000,wtdat);
+
+ // enable the watchdog
+ tmp = __raw_readl(wtcon);
+ tmp |= WT_ENABLE;
+
+ __raw_writel(tmp,wtcon);
+
+ return 0;
+}
+
+static int omahadog_release(struct inode *inode, struct file *file)
+{
+ volatile unsigned int wtcon = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_WTCON);
+ unsigned int tmp;
+
+ /*
+ * Shut off the timer.
+ * Lock it in if it's a module and we defined ...NOWAYOUT
+ */
+#ifndef CONFIG_WATCHDOG_NOWAYOUT
+ tmp = __raw_readl(wtcon);
+ tmp &= ~WT_ENABLE;
+ __raw_writel(tmp,wtcon);
+#endif
+ omahawdt_users = 0;
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+static ssize_t omahadog_write(struct file *file, const char *data, size_t len, loff_t *ppos)
+{
+ volatile unsigned int wtcnt = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_WTCNT);
+
+ /* Can't seek (pwrite) on this device */
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+
+ /* Refresh timer. */
+ if(len) {
+ __raw_writel(pre_margin,wtcnt);
+ return 1;
+ }
+ return 0;
+}
+
+static int omahadog_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ volatile unsigned int wtdat = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_WTDAT);
+ static struct watchdog_info ident = {
+ identity: "omaha Watchdog",
+ };
+
+ switch(cmd){
+ default:
+ return -ENOIOCTLCMD;
+ case WDIOC_GETSUPPORT:
+ return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident));
+ case WDIOC_GETSTATUS:
+ return put_user(0,(int *)arg);
+ case WDIOC_GETBOOTSTATUS:
+ return 0;
+ case WDIOC_KEEPALIVE:
+ __raw_writel(pre_margin,wtdat);
+ return 0;
+ }
+}
+
+static struct file_operations omahadog_fops=
+{
+ .owner = THIS_MODULE,
+ .write = omahadog_write,
+ .ioctl = omahadog_ioctl,
+ .open = omahadog_open,
+ .release = omahadog_release,
+};
+
+static struct miscdevice omahadog_miscdev=
+{
+ .minor = WATCHDOG_MINOR,
+ .name = "omaha watchdog",
+ .fops = &omahadog_fops
+};
+
+static int __init omahadog_init(void)
+{
+ int ret;
+
+ ret = misc_register(&omahadog_miscdev);
+
+ if (ret)
+ return ret;
+
+ printk("Omaha Watchdog Timer: timer margin %d sec\n", omaha_margin);
+
+ return 0;
+}
+
+static void __exit omahadog_exit(void)
+{
+ misc_deregister(&omahadog_miscdev);
+}
+
+module_init(omahadog_init);
+module_exit(omahadog_exit);
diff -urN linux-2.4.26/drivers/char/pcmcia/Config.in linux-2.4.26-vrs1/drivers/char/pcmcia/Config.in
--- linux-2.4.26/drivers/char/pcmcia/Config.in 2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/char/pcmcia/Config.in 2004-01-14 21:32:25.000000000 +0000
@@ -5,7 +5,13 @@
mainmenu_option next_comment
comment 'PCMCIA character devices'
-dep_tristate 'PCMCIA serial device support' CONFIG_PCMCIA_SERIAL_CS $CONFIG_SERIAL
+if [ "$CONFIG_SERIAL" = "y" -o "$CONFIG_SERIAL_8250" = "y" ]; then
+ dep_tristate 'PCMCIA serial device support' CONFIG_PCMCIA_SERIAL_CS y
+else
+ if [ "$CONFIG_SERIAL" = "m" -o "$CONFIG_SERIAL_8250" = "m" ]; then
+ dep_tristate 'PCMCIA serial device support' CONFIG_PCMCIA_SERIAL_CS m
+ fi
+fi
if [ "$CONFIG_PCMCIA_SERIAL_CS" = "y" ]; then
define_bool CONFIG_PCMCIA_CHRDEV y
fi
diff -urN linux-2.4.26/drivers/char/pcmcia/memory_cs.c linux-2.4.26-vrs1/drivers/char/pcmcia/memory_cs.c
--- linux-2.4.26/drivers/char/pcmcia/memory_cs.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/pcmcia/memory_cs.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,214 @@
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/mtd.h>
+
+#include <pcmcia/version.h>
+#include <pcmcia/cs_types.h>
+#include <pcmcia/cs.h>
+#include <pcmcia/cistpl.h>
+#include <pcmcia/ciscode.h>
+#include <pcmcia/ds.h>
+#include <pcmcia/cisreg.h>
+
+#include <linux/mtd/map.h>
+#include <linux/mtd/mtd.h>
+
+static dev_info_t dev_info = "memory_cs";
+static dev_link_t *dev_list;
+
+struct memcs_dev {
+ dev_link_t link;
+ struct map_info map;
+};
+
+static __u8 mem_cs_read8(struct map_info *map, unsigned long ofs)
+{
+ return readb(map->map_priv_1 + ofs);
+}
+
+static __u16 mem_cs_read16(struct map_info *map, unsigned long ofs)
+{
+ return readw(map->map_priv_1 + ofs);
+}
+
+static __u32 mem_cs_read32(struct map_info *map, unsigned long ofs)
+{
+ return readl(map->map_priv_1 + ofs);
+}
+
+static void mem_cs_copy_from(struct map_info *map, void *to, unsigned long ofs, ssize_t size)
+{
+ memcpy_fromio(to, map->map_priv_1 + ofs, size);
+}
+
+static void mem_cs_write8(struct map_info *map, __u8 val, unsigned long ofs)
+{
+ writeb(val, map->map_priv_1 + ofs);
+}
+
+static void mem_cs_write16(struct map_info *map, __u16 val, unsigned long ofs)
+{
+ writew(val, map->map_priv_1 + ofs);
+}
+
+static void mem_cs_write32(struct map_info *map, __u32 val, unsigned long ofs)
+{
+ writel(val, map->map_priv_1 + ofs);
+}
+
+static void mem_cs_copy_to(struct map_info *map, unsigned long ofs, const void *to, ssize_t size)
+{
+ memcpy_toio(map->map_priv_1 + ofs, from, size);
+}
+
+static void mem_cs_release(u_long arg);
+
+static void mem_cs_detach(dev_link_t *link)
+{
+ del_timer(&link->release);
+ if (link->state & DEV_CONFIG) {
+ mem_cs_release((u_long)link);
+ if (link->state & DEV_STALE_CONFIG) {
+ link->state |= DEV_STALE_LINK;
+ return;
+ }
+ }
+
+ if (link->handle)
+ CardServices(DeregisterClient, link->handle);
+
+ kfree(link);
+}
+
+static void mem_cs_release(u_long arg)
+{
+ dev_link_t *link = (dev_link_t *)arg;
+
+ link->dev = NULL;
+ if (link->win) {
+ CardServices(ReleaseWindow, link->win);
+ }
+ link->state &= ~DEV_CONFIG;
+
+ if (link->state & DEV_STALE_LINK)
+ mem_cs_detach(link);
+}
+
+static void mem_cs_config(dev_link_t *link)
+{
+ struct memcs_dev *dev = link->priv;
+ cs_status_t status;
+ win_req_t req;
+
+ link->state |= DEV_CONFIG;
+
+ req.Attributes = word_width ? WIN_DATA_WIDTH_16 : WIN_DATA_WIDTH_8;
+ req.Base = 0;
+ req.Size = 0;
+ req.AccessSpeed = mem_speed;
+
+ link->win = (window_handle_t)link->handle;
+
+ CS_CHECK(RequestWindow, &link->win, &req);
+
+ CS_CHECK(GetStatus, link->handle, &status);
+
+ dev->map.buswidth = word_width ? 2 : 1;
+ dev->map.size = req.Size;
+ dev->map.map_priv_1 = ioremap(req.Base, req.Size);
+}
+
+static int
+mem_cs_event(event_t event, int priority, event_callback_args_t *args)
+{
+ dev_link_t *link = args->client_data;
+
+ switch (event) {
+ case CS_EVENT_CARD_REMOVAL:
+ link->state &= ~DEV_PRESENT;
+ if (link->state & DEV_CONFIG)
+ mod_timer(&link->release, jiffies + HZ/20);
+ break;
+
+ case CS_EVENT_CARD_INSERTION:
+ link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
+ mem_cs_config(link);
+ break;
+ }
+ return 0;
+}
+
+static dev_link_t *mem_cs_attach(void)
+{
+ struct memcs_dev *dev;
+ client_reg_t clnt;
+
+ dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+ if (dev) {
+ memset(dev, 0, sizeof(*dev));
+
+ dev->map.read8 = mem_cs_read8;
+ dev->map.read16 = mem_cs_read16;
+ dev->map.read32 = mem_cs_read32;
+ dev->map.copy_from = mem_cs_copy_from;
+ dev->map.write8 = mem_cs_write8;
+ dev->map.write16 = mem_cs_write16;
+ dev->map.write32 = mem_cs_write32;
+ dev->map.copy_to = mem_cs_copy_to;
+
+ dev->link.release.function = &mem_cs_release;
+ dev->link.release.data = (u_long)link;
+ dev->link.priv = dev;
+
+ dev->link.next = dev_list;
+ dev_list = &dev->link;
+
+ clnt.dev_info = &dev_info;
+ clnt.Attributes = INOF_IO_CLIENT | INFO_CARD_SHARE;
+ clnt.EventMask =
+ CS_EVENT_WRITE_PROTECT | CS_EVENT_CARD_INSERTION |
+ CS_EVENT_CARD_REMOVAL | CS_EVENT_BATTERY_DEAD |
+ CS_EVENT_BATTERY_LOW;
+
+ clnt.event_handler = &mem_cs_event;
+ clnt.Version = 0x0210;
+ clnt.event_callback_args.client_data = &dev->link;
+
+ ret = CardServices(RegisterClient, &dev->link.handle, &clnt);
+ if (ret != CS_SUCCESS) {
+ error_info_t err = { RegisterClient, ret };
+ CardServices(ReportError, dev->link.handle, &err);
+ mem_cs_detach(&dev->link);
+ dev = NULL;
+ }
+ }
+
+ return &dev->link;
+}
+
+static int __init mem_cs_init(void)
+{
+ servinfo_t serv;
+
+ CardServices(GetCardServicesInfo, &serv);
+ if (serv.Revision != CS_RELEASE_CODE) {
+ printk(KERN_NOTICE "memory_cs: Card services release "
+ "does not match\n");
+ return -ENXIO;
+ }
+ register_pccard_driver(&dev_info, mem_cs_attach, mem_cs_detach);
+ return 0;
+}
+
+static void __exit mem_cs_exit(void)
+{
+ unregister_pccard_driver(&dev_info);
+ while (dev_list != NULL)
+ memory_detach(dev_list);
+}
+
+module_init(mem_cs_init);
+module_exit(mem_cs_exit);
+
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/char/sa1100-rtc.c linux-2.4.26-vrs1/drivers/char/sa1100-rtc.c
--- linux-2.4.26/drivers/char/sa1100-rtc.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/sa1100-rtc.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,474 @@
+/*
+ * Real Time Clock interface for Linux on StrongARM SA1100
+ *
+ * Copyright (c) 2000 Nils Faerber
+ *
+ * Based on rtc.c by Paul Gortmaker
+ * Date/time conversion routines taken from arch/arm/kernel/time.c
+ * by Linus Torvalds and Russel King
+ * and the GNU C Library
+ * ( ... I love the GPL ... just take what you need! ;)
+ *
+ * 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.
+ *
+ * 1.00 2001-06-08 Nicolas Pitre <nico@cam.org>
+ * - added periodic timer capability using OSMR1
+ * - flag compatibility with other RTC chips
+ * - permission checks for ioctls
+ * - major cleanup, partial rewrite
+ *
+ * 0.03 2001-03-07 CIH <cih@coventive.com>
+ * - Modify the bug setups RTC clock.
+ *
+ * 0.02 2001-02-27 Nils Faerber <nils@@kernelconcepts.de>
+ * - removed mktime(), added alarm irq clear
+ *
+ * 0.01 2000-10-01 Nils Faerber <nils@@kernelconcepts.de>
+ * - initial release
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/poll.h>
+#include <linux/proc_fs.h>
+#include <asm/bitops.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <linux/rtc.h>
+
+#define DRIVER_VERSION "1.00"
+
+#define TIMER_FREQ 3686400
+
+#define RTC_DEF_DIVIDER 32768 - 1
+#define RTC_DEF_TRIM 0
+
+/* Those are the bits from a classic RTC we want to mimic */
+#define RTC_IRQF 0x80 /* any of the following 3 is active */
+#define RTC_PF 0x40
+#define RTC_AF 0x20
+#define RTC_UF 0x10
+
+static unsigned long rtc_status;
+static unsigned long rtc_irq_data;
+static unsigned long rtc_freq = 1024;
+
+static struct fasync_struct *rtc_async_queue;
+static DECLARE_WAIT_QUEUE_HEAD(rtc_wait);
+
+extern spinlock_t rtc_lock;
+
+static const unsigned char days_in_mo[] =
+ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
+
+#define is_leap(year) \
+ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
+
+/*
+ * Converts seconds since 1970-01-01 00:00:00 to Gregorian date.
+ */
+
+static void decodetime (unsigned long t, struct rtc_time *tval)
+{
+ long days, month, year, rem;
+
+ days = t / 86400;
+ rem = t % 86400;
+ tval->tm_hour = rem / 3600;
+ rem %= 3600;
+ tval->tm_min = rem / 60;
+ tval->tm_sec = rem % 60;
+ tval->tm_wday = (4 + days) % 7;
+
+#define LEAPS_THRU_END_OF(y) ((y)/4 - (y)/100 + (y)/400)
+
+ year = 1970 + days / 365;
+ days -= ((year - 1970) * 365
+ + LEAPS_THRU_END_OF (year - 1)
+ - LEAPS_THRU_END_OF (1970 - 1));
+ if (days < 0) {
+ year -= 1;
+ days += 365 + is_leap(year);
+ }
+ tval->tm_year = year - 1900;
+ tval->tm_yday = days + 1;
+
+ month = 0;
+ if (days >= 31) {
+ days -= 31;
+ month++;
+ if (days >= (28 + is_leap(year))) {
+ days -= (28 + is_leap(year));
+ month++;
+ while (days >= days_in_mo[month]) {
+ days -= days_in_mo[month];
+ month++;
+ }
+ }
+ }
+ tval->tm_mon = month;
+ tval->tm_mday = days + 1;
+}
+
+static void rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned int rtsr = RTSR;
+
+ /* clear interrupt sources */
+ RTSR = 0;
+ RTSR = (RTSR_AL|RTSR_HZ);
+
+ /* clear alarm interrupt if it has occurred */
+ if (rtsr & RTSR_AL)
+ rtsr &= ~RTSR_ALE;
+ RTSR = rtsr & (RTSR_ALE|RTSR_HZE);
+
+ /* update irq data & counter */
+ if (rtsr & RTSR_AL)
+ rtc_irq_data |= (RTC_AF|RTC_IRQF);
+ if (rtsr & RTSR_HZ)
+ rtc_irq_data |= (RTC_UF|RTC_IRQF);
+ rtc_irq_data += 0x100;
+
+ /* wake up waiting process */
+ wake_up_interruptible(&rtc_wait);
+ kill_fasync (&rtc_async_queue, SIGIO, POLL_IN);
+}
+
+static void timer1_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ /*
+ * If we match for the first time, the periodic interrupt flag won't
+ * be set. If it is, then we did wrap around (very unlikely but
+ * still possible) and compute the amount of missed periods.
+ * The match reg is updated only when the data is actually retrieved
+ * to avoid unnecessary interrupts.
+ */
+ OSSR = OSSR_M1; /* clear match on timer1 */
+ if (rtc_irq_data & RTC_PF) {
+ rtc_irq_data += (rtc_freq * ((1<<30)/(TIMER_FREQ>>2))) << 8;
+ } else {
+ rtc_irq_data += (0x100|RTC_PF|RTC_IRQF);
+ }
+
+ wake_up_interruptible(&rtc_wait);
+ kill_fasync (&rtc_async_queue, SIGIO, POLL_IN);
+}
+
+static int rtc_open(struct inode *inode, struct file *file)
+{
+ if (test_and_set_bit (1, &rtc_status))
+ return -EBUSY;
+ rtc_irq_data = 0;
+ return 0;
+}
+
+static int rtc_release(struct inode *inode, struct file *file)
+{
+ spin_lock_irq (&rtc_lock);
+ RTSR = 0;
+ RTSR = (RTSR_AL|RTSR_HZ);
+ OIER &= ~OIER_E1;
+ OSSR = OSSR_M1;
+ spin_unlock_irq (&rtc_lock);
+ rtc_status = 0;
+ return 0;
+}
+
+static int rtc_fasync (int fd, struct file *filp, int on)
+{
+ return fasync_helper (fd, filp, on, &rtc_async_queue);
+}
+
+static unsigned int rtc_poll(struct file *file, poll_table *wait)
+{
+ poll_wait (file, &rtc_wait, wait);
+ return (rtc_irq_data) ? 0 : POLLIN | POLLRDNORM;
+}
+
+static loff_t rtc_llseek(struct file *file, loff_t offset, int origin)
+{
+ return -ESPIPE;
+}
+
+ssize_t rtc_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+ DECLARE_WAITQUEUE(wait, current);
+ unsigned long data;
+ ssize_t retval;
+
+ if (count < sizeof(unsigned long))
+ return -EINVAL;
+
+ add_wait_queue(&rtc_wait, &wait);
+ set_current_state(TASK_INTERRUPTIBLE);
+ for (;;) {
+ spin_lock_irq (&rtc_lock);
+ data = rtc_irq_data;
+ if (data != 0) {
+ rtc_irq_data = 0;
+ break;
+ }
+ spin_unlock_irq (&rtc_lock);
+
+ if (file->f_flags & O_NONBLOCK) {
+ retval = -EAGAIN;
+ goto out;
+ }
+
+ if (signal_pending(current)) {
+ retval = -ERESTARTSYS;
+ goto out;
+ }
+
+ schedule();
+ }
+
+ if (data & RTC_PF) {
+ /* interpolate missed periods and set match for the next one */
+ unsigned long period = TIMER_FREQ/rtc_freq;
+ unsigned long oscr = OSCR;
+ unsigned long osmr1 = OSMR1;
+ unsigned long missed = (oscr - osmr1)/period;
+ data += missed << 8;
+ OSSR = OSSR_M1; /* clear match on timer 1 */
+ OSMR1 = osmr1 + (missed + 1)*period;
+ /* ensure we didn't miss another match in the mean time */
+ while( (signed long)((osmr1 = OSMR1) - OSCR) <= 0 ) {
+ data += 0x100;
+ OSSR = OSSR_M1; /* clear match on timer 1 */
+ OSMR1 = osmr1 + period;
+ }
+ }
+ spin_unlock_irq (&rtc_lock);
+
+ data -= 0x100; /* the first IRQ wasn't actually missed */
+
+ retval = put_user(data, (unsigned long *)buf);
+ if (!retval)
+ retval = sizeof(unsigned long);
+
+out:
+ set_current_state(TASK_RUNNING);
+ remove_wait_queue(&rtc_wait, &wait);
+ return retval;
+}
+
+static int rtc_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ struct rtc_time tm, tm2;
+
+ switch (cmd) {
+ case RTC_AIE_OFF:
+ spin_lock_irq(&rtc_lock);
+ RTSR &= ~RTSR_ALE;
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_AIE_ON:
+ spin_lock_irq(&rtc_lock);
+ RTSR |= RTSR_ALE;
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_UIE_OFF:
+ spin_lock_irq(&rtc_lock);
+ RTSR &= ~RTSR_HZE;
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_UIE_ON:
+ spin_lock_irq(&rtc_lock);
+ RTSR |= RTSR_HZE;
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_PIE_OFF:
+ spin_lock_irq(&rtc_lock);
+ OIER &= ~OIER_E1;
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_PIE_ON:
+ if ((rtc_freq > 64) && !capable(CAP_SYS_RESOURCE))
+ return -EACCES;
+ spin_lock_irq(&rtc_lock);
+ OSMR1 = TIMER_FREQ/rtc_freq + OSCR;
+ OIER |= OIER_E1;
+ rtc_irq_data = 0;
+ spin_unlock_irq(&rtc_lock);
+ return 0;
+ case RTC_ALM_READ:
+ decodetime (RTAR, &tm);
+ break;
+ case RTC_ALM_SET:
+ if (copy_from_user (&tm2, (struct rtc_time*)arg, sizeof (tm2)))
+ return -EFAULT;
+ decodetime (RCNR, &tm);
+ if ((unsigned)tm2.tm_hour < 24)
+ tm.tm_hour = tm2.tm_hour;
+ if ((unsigned)tm2.tm_min < 60)
+ tm.tm_min = tm2.tm_min;
+ if ((unsigned)tm2.tm_sec < 60)
+ tm.tm_sec = tm2.tm_sec;
+ RTAR = mktime ( tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+ return 0;
+ case RTC_RD_TIME:
+ decodetime (RCNR, &tm);
+ break;
+ case RTC_SET_TIME:
+ if (!capable(CAP_SYS_TIME))
+ return -EACCES;
+ if (copy_from_user (&tm, (struct rtc_time*)arg, sizeof (tm)))
+ return -EFAULT;
+ tm.tm_year += 1900;
+ if (tm.tm_year < 1970 || (unsigned)tm.tm_mon >= 12 ||
+ tm.tm_mday < 1 || tm.tm_mday > (days_in_mo[tm.tm_mon] +
+ (tm.tm_mon == 1 && is_leap(tm.tm_year))) ||
+ (unsigned)tm.tm_hour >= 24 ||
+ (unsigned)tm.tm_min >= 60 ||
+ (unsigned)tm.tm_sec >= 60)
+ return -EINVAL;
+ RCNR = mktime ( tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec);
+ return 0;
+ case RTC_IRQP_READ:
+ return put_user(rtc_freq, (unsigned long *)arg);
+ case RTC_IRQP_SET:
+ if (arg < 1 || arg > TIMER_FREQ)
+ return -EINVAL;
+ if ((arg > 64) && (!capable(CAP_SYS_RESOURCE)))
+ return -EACCES;
+ rtc_freq = arg;
+ return 0;
+ case RTC_EPOCH_READ:
+ return put_user (1970, (unsigned long *)arg);
+ default:
+ return -EINVAL;
+ }
+ return copy_to_user ((void *)arg, &tm, sizeof (tm)) ? -EFAULT : 0;
+}
+
+static struct file_operations rtc_fops = {
+ owner: THIS_MODULE,
+ llseek: rtc_llseek,
+ read: rtc_read,
+ poll: rtc_poll,
+ ioctl: rtc_ioctl,
+ open: rtc_open,
+ release: rtc_release,
+ fasync: rtc_fasync,
+};
+
+static struct miscdevice sa1100rtc_miscdev = {
+ RTC_MINOR,
+ "rtc",
+ &rtc_fops
+};
+
+static int rtc_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data)
+{
+ char *p = page;
+ int len;
+ struct rtc_time tm;
+
+ decodetime (RCNR, &tm);
+ p += sprintf(p, "rtc_time\t: %02d:%02d:%02d\n"
+ "rtc_date\t: %04d-%02d-%02d\n"
+ "rtc_epoch\t: %04d\n",
+ tm.tm_hour, tm.tm_min, tm.tm_sec,
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 1970);
+ decodetime (RTAR, &tm);
+ p += sprintf(p, "alrm_time\t: %02d:%02d:%02d\n"
+ "alrm_date\t: %04d-%02d-%02d\n",
+ tm.tm_hour, tm.tm_min, tm.tm_sec,
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday);
+ p += sprintf(p, "trim/divider\t: 0x%08x\n", RTTR);
+ p += sprintf(p, "alarm_IRQ\t: %s\n", (RTSR & RTSR_ALE) ? "yes" : "no" );
+ p += sprintf(p, "update_IRQ\t: %s\n", (RTSR & RTSR_HZE) ? "yes" : "no");
+ p += sprintf(p, "periodic_IRQ\t: %s\n", (OIER & OIER_E1) ? "yes" : "no");
+ p += sprintf(p, "periodic_freq\t: %ld\n", rtc_freq);
+
+ len = (p - page) - off;
+ if (len < 0)
+ len = 0;
+
+ *eof = (len <= count) ? 1 : 0;
+ *start = page + off;
+
+ return len;
+}
+
+static int __init rtc_init(void)
+{
+ int ret;
+
+ misc_register (&sa1100rtc_miscdev);
+ create_proc_read_entry ("driver/rtc", 0, 0, rtc_read_proc, NULL);
+ ret = request_irq (IRQ_RTC1Hz, rtc_interrupt, SA_INTERRUPT, "rtc 1Hz", NULL);
+ if (ret) {
+ printk (KERN_ERR "rtc: IRQ %d already in use.\n", IRQ_RTC1Hz);
+ goto IRQ_RTC1Hz_failed;
+ }
+ ret = request_irq (IRQ_RTCAlrm, rtc_interrupt, SA_INTERRUPT, "rtc Alrm", NULL);
+ if (ret) {
+ printk(KERN_ERR "rtc: IRQ %d already in use.\n", IRQ_RTCAlrm);
+ goto IRQ_RTCAlrm_failed;
+ }
+ ret = request_irq (IRQ_OST1, timer1_interrupt, SA_INTERRUPT, "rtc timer", NULL);
+ if (ret) {
+ printk(KERN_ERR "rtc: IRQ %d already in use.\n", IRQ_OST1);
+ goto IRQ_OST1_failed;
+ }
+
+ printk (KERN_INFO "SA1100 Real Time Clock driver v" DRIVER_VERSION "\n");
+
+ /*
+ * According to the manual we should be able to let RTTR be zero
+ * and then a default diviser for a 32.768KHz clock is used.
+ * Apparently this doesn't work, at least for my SA1110 rev 5.
+ * If the clock divider is uninitialized then reset it to the
+ * default value to get the 1Hz clock.
+ */
+ if (RTTR == 0) {
+ RTTR = RTC_DEF_DIVIDER + (RTC_DEF_TRIM << 16);
+ printk (KERN_WARNING "rtc: warning: initializing default clock divider/trim value\n");
+ /* The current RTC value probably doesn't make sense either */
+ RCNR = 0;
+ }
+
+ return 0;
+
+IRQ_OST1_failed:
+ free_irq (IRQ_RTCAlrm, NULL);
+IRQ_RTCAlrm_failed:
+ free_irq (IRQ_RTC1Hz, NULL);
+IRQ_RTC1Hz_failed:
+ remove_proc_entry ("driver/rtc", NULL);
+ misc_deregister (&sa1100rtc_miscdev);
+ return ret;
+}
+
+static void __exit rtc_exit(void)
+{
+ free_irq (IRQ_OST1, NULL);
+ free_irq (IRQ_RTCAlrm, NULL);
+ free_irq (IRQ_RTC1Hz, NULL);
+ remove_proc_entry ("driver/rtc", NULL);
+ misc_deregister (&sa1100rtc_miscdev);
+}
+
+module_init(rtc_init);
+module_exit(rtc_exit);
+
+MODULE_AUTHOR("Nils Faerber <nils@@kernelconcepts.de>");
+MODULE_DESCRIPTION("SA1100 Realtime Clock Driver (RTC)");
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/char/sa1100_wdt.c linux-2.4.26-vrs1/drivers/char/sa1100_wdt.c
--- linux-2.4.26/drivers/char/sa1100_wdt.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/sa1100_wdt.c 2004-04-10 12:04:15.000000000 +0100
@@ -0,0 +1,150 @@
+/*
+ * Watchdog driver for the SA11x0
+ *
+ * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
+ * Based on SoftDog driver by Alan Cox <alan@redhat.com>
+ *
+ * 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.
+ *
+ * Neither Oleg Drokin nor iXcelerator.com admit liability nor provide
+ * warranty for any of this software. This material is provided
+ * "AS-IS" and at no charge.
+ *
+ * (c) Copyright 2000 Oleg Drokin <green@crimea.edu>
+ *
+ * 27/11/2000 Initial release
+ */
+
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <linux/reboot.h>
+#include <linux/smp_lock.h>
+#include <linux/init.h>
+#include <asm/uaccess.h>
+#include <asm/hardware.h>
+#include <asm/bitops.h>
+
+#define TIMER_MARGIN 60 /* (secs) Default is 1 minute */
+
+static int sa1100_margin = TIMER_MARGIN; /* in seconds */
+static int sa1100wdt_users;
+static int pre_margin;
+#ifdef MODULE
+MODULE_PARM(sa1100_margin,"i");
+#endif
+
+/*
+ * Allow only one person to hold it open
+ */
+
+static int sa1100dog_open(struct inode *inode, struct file *file)
+{
+ if(test_and_set_bit(1,&sa1100wdt_users))
+ return -EBUSY;
+ MOD_INC_USE_COUNT;
+ /* Activate SA1100 Watchdog timer */
+ pre_margin=3686400 * sa1100_margin;
+ OSMR3 = OSCR + pre_margin;
+ OSSR = OSSR_M3;
+ OWER = OWER_WME;
+ OIER |= OIER_E3;
+ return 0;
+}
+
+static int sa1100dog_release(struct inode *inode, struct file *file)
+{
+ /*
+ * Shut off the timer.
+ * Lock it in if it's a module and we defined ...NOWAYOUT
+ */
+ OSMR3 = OSCR + pre_margin;
+#ifndef CONFIG_WATCHDOG_NOWAYOUT
+ OIER &= ~OIER_E3;
+#endif
+ sa1100wdt_users = 0;
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+static ssize_t sa1100dog_write(struct file *file, const char *data, size_t len, loff_t *ppos)
+{
+ /* Can't seek (pwrite) on this device */
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+
+ /* Refresh OSMR3 timer. */
+ if(len) {
+ OSMR3 = OSCR + pre_margin;
+ return 1;
+ }
+ return 0;
+}
+
+static int sa1100dog_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ static struct watchdog_info ident = {
+ identity: "SA1100 Watchdog",
+ };
+
+ switch(cmd){
+ default:
+ return -ENOIOCTLCMD;
+ case WDIOC_GETSUPPORT:
+ return copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident));
+ case WDIOC_GETSTATUS:
+ return put_user(0,(int *)arg);
+ case WDIOC_GETBOOTSTATUS:
+ return put_user((RCSR & RCSR_WDR) ? WDIOF_CARDRESET : 0, (int *)arg);
+ case WDIOC_KEEPALIVE:
+ OSMR3 = OSCR + pre_margin;
+ return 0;
+ }
+}
+
+static struct file_operations sa1100dog_fops=
+{
+ owner: THIS_MODULE,
+ write: sa1100dog_write,
+ ioctl: sa1100dog_ioctl,
+ open: sa1100dog_open,
+ release: sa1100dog_release,
+};
+
+static struct miscdevice sa1100dog_miscdev=
+{
+ WATCHDOG_MINOR,
+ "SA1100 watchdog",
+ &sa1100dog_fops
+};
+
+static int __init sa1100dog_init(void)
+{
+ int ret;
+
+ ret = misc_register(&sa1100dog_miscdev);
+
+ if (ret)
+ return ret;
+
+ printk("SA1100 Watchdog Timer: timer margin %d sec\n", sa1100_margin);
+
+ return 0;
+}
+
+static void __exit sa1100dog_exit(void)
+{
+ misc_deregister(&sa1100dog_miscdev);
+}
+
+module_init(sa1100dog_init);
+module_exit(sa1100dog_exit);
diff -urN linux-2.4.26/drivers/char/sa1111_keyb.c linux-2.4.26-vrs1/drivers/char/sa1111_keyb.c
--- linux-2.4.26/drivers/char/sa1111_keyb.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/sa1111_keyb.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,1153 @@
+/*
+ * SA1111 PS/2 keyboard/mouse driver
+ *
+ * 2000 by VASARA RESEARCH INC.
+ *
+ * Changelog:
+ * Jun.xx,2000: Kunihiko IMAI <imai@vasara.co.jp>
+ * Port to 2.4.0test1-ac19-rmk1-np1
+ * Apr.17,2000: Takafumi Kawana <kawana@pro.or.jp>
+ * Internal Release for XP860
+ *
+ *
+ * This driver is based on linux/drivers/char/pc_keyb.c
+ * Original declaration follows:
+
+ *
+ * linux/drivers/char/pc_keyb.c
+ *
+ * Separation of the PC low-level part by Geert Uytterhoeven, May 1997
+ * See keyboard.c for the whole history.
+ *
+ * Major cleanup by Martin Mares, May 1997
+ *
+ * Combined the keyboard and PS/2 mouse handling into one file,
+ * because they share the same hardware.
+ * Johan Myreen <jem@iki.fi> 1998-10-08.
+ *
+ * Code fixes to handle mouse ACKs properly.
+ * C. Scott Ananian <cananian@alumni.princeton.edu> 1999-01-29.
+ *
+ */
+#include <linux/config.h>
+#include <linux/spinlock.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/mm.h>
+#include <linux/signal.h>
+#include <linux/init.h>
+#include <linux/kbd_ll.h>
+#include <linux/delay.h>
+#include <linux/random.h>
+#include <linux/poll.h>
+#include <linux/miscdevice.h>
+#include <linux/slab.h>
+#include <linux/kbd_kern.h>
+#include <linux/ioport.h>
+
+#include <asm/hardware.h>
+#include <asm/bitops.h>
+#include <asm/uaccess.h>
+#include <asm/irq.h>
+#include <asm/system.h>
+
+#include <asm/io.h>
+
+/* Some configuration switches are present in the include file... */
+
+#include <linux/pc_keyb.h>
+#include <asm/keyboard.h>
+#include <asm/hardware/sa1111.h>
+
+#define KBD_STAT_RXB (1<<4)
+#define KBD_STAT_RXF (1<<5)
+#define KBD_STAT_TXB (1<<6)
+#define KBD_STAT_TXE (1<<7)
+#define KBD_STAT_STP (1<<8)
+
+#define MSE_STAT_RXB (1<<4)
+#define MSE_STAT_RXF (1<<5)
+#define MSE_STAT_TXB (1<<6)
+#define MSE_STAT_TXE (1<<7)
+#define MSE_STAT_STP (1<<8)
+
+/* Simple translation table for the SysRq keys */
+
+#ifdef CONFIG_MAGIC_SYSRQ
+unsigned char sa1111_sysrq_xlate[128] = "\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
+ "qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
+ "dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
+ "bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
+ "\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
+ "230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
+ "\r\000/"; /* 0x60 - 0x6f */
+#endif
+
+// static void kbd_write_command_w(int data);
+static void kbd_write_output_w(int data);
+
+spinlock_t kbd_controller_lock = SPIN_LOCK_UNLOCKED;
+static void handle_kbd_event(void);
+
+/* used only by send_data - set by keyboard_interrupt */
+static volatile unsigned char reply_expected = 0;
+static volatile unsigned char acknowledge = 0;
+static volatile unsigned char resend = 0;
+
+
+#if defined CONFIG_PSMOUSE
+/*
+ * PS/2 Auxiliary Device
+ */
+
+static int __init psaux_init(void);
+
+static struct aux_queue *queue; /* Mouse data buffer. */
+static int aux_count = 0;
+/* used when we send commands to the mouse that expect an ACK. */
+static unsigned char mouse_reply_expected = 0;
+
+#define AUX_INTS_OFF (KBD_MODE_KCC | KBD_MODE_DISABLE_MOUSE | KBD_MODE_SYS | KBD_MODE_KBD_INT)
+#define AUX_INTS_ON (KBD_MODE_KCC | KBD_MODE_SYS | KBD_MODE_MOUSE_INT | KBD_MODE_KBD_INT)
+
+#define MAX_RETRIES 60 /* some aux operations take long time */
+#endif /* CONFIG_PSMOUSE */
+
+/*
+ * Wait for keyboard controller input buffer to drain.
+ *
+ * Don't use 'jiffies' so that we don't depend on
+ * interrupts..
+ *
+ * Quote from PS/2 System Reference Manual:
+ *
+ * "Address hex 0060 and address hex 0064 should be written only when
+ * the input-buffer-full bit and output-buffer-full bit in the
+ * Controller Status register are set 0."
+ */
+
+static void kb_wait(void)
+{
+ unsigned long timeout = KBC_TIMEOUT;
+
+ do {
+ /*
+ * "handle_kbd_event()" will handle any incoming events
+ * while we wait - keypresses or mouse movement.
+ */
+ handle_kbd_event();
+ if (KBDSTAT & KBD_STAT_TXE)
+ return;
+ mdelay(1);
+ timeout--;
+ }
+ while (timeout);
+#ifdef KBD_REPORT_TIMEOUTS
+ printk(KERN_WARNING "Keyboard timed out[1]\n");
+#endif
+}
+
+/*
+ * Translation of escaped scancodes to keycodes.
+ * This is now user-settable.
+ * The keycodes 1-88,96-111,119 are fairly standard, and
+ * should probably not be changed - changing might confuse X.
+ * X also interprets scancode 0x5d (KEY_Begin).
+ *
+ * For 1-88 keycode equals scancode.
+ */
+
+#define E0_KPENTER 96
+#define E0_RCTRL 97
+#define E0_KPSLASH 98
+#define E0_PRSCR 99
+#define E0_RALT 100
+#define E0_BREAK 101 /* (control-pause) */
+#define E0_HOME 102
+#define E0_UP 103
+#define E0_PGUP 104
+#define E0_LEFT 105
+#define E0_RIGHT 106
+#define E0_END 107
+#define E0_DOWN 108
+#define E0_PGDN 109
+#define E0_INS 110
+#define E0_DEL 111
+
+/* for USB 106 keyboard */
+#define E0_YEN 124
+#define E0_BACKSLASH 89
+
+
+#define E1_PAUSE 119
+
+/*
+ * The keycodes below are randomly located in 89-95,112-118,120-127.
+ * They could be thrown away (and all occurrences below replaced by 0),
+ * but that would force many users to use the `setkeycodes' utility, where
+ * they needed not before. It does not matter that there are duplicates, as
+ * long as no duplication occurs for any single keyboard.
+ */
+#define SC_LIM 89
+
+#define FOCUS_PF1 85 /* actual code! */
+#define FOCUS_PF2 89
+#define FOCUS_PF3 90
+#define FOCUS_PF4 91
+#define FOCUS_PF5 92
+#define FOCUS_PF6 93
+#define FOCUS_PF7 94
+#define FOCUS_PF8 95
+#define FOCUS_PF9 120
+#define FOCUS_PF10 121
+#define FOCUS_PF11 122
+#define FOCUS_PF12 123
+
+#define JAP_86 124
+/* tfj@olivia.ping.dk:
+ * The four keys are located over the numeric keypad, and are
+ * labelled A1-A4. It's an rc930 keyboard, from
+ * Regnecentralen/RC International, Now ICL.
+ * Scancodes: 59, 5a, 5b, 5c.
+ */
+#define RGN1 124
+#define RGN2 125
+#define RGN3 126
+#define RGN4 127
+
+static unsigned char high_keys[128 - SC_LIM] = {
+ RGN1, RGN2, RGN3, RGN4, 0, 0, 0, /* 0x59-0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
+ 0, 0, 0, 0, 0, FOCUS_PF11, 0, FOCUS_PF12, /* 0x68-0x6f */
+ 0, 0, 0, FOCUS_PF2, FOCUS_PF9, 0, 0, FOCUS_PF3, /* 0x70-0x77 */
+ FOCUS_PF4, FOCUS_PF5, FOCUS_PF6, FOCUS_PF7, /* 0x78-0x7b */
+ FOCUS_PF8, JAP_86, FOCUS_PF10, 0 /* 0x7c-0x7f */
+};
+
+/* BTC */
+#define E0_MACRO 112
+/* LK450 */
+#define E0_F13 113
+#define E0_F14 114
+#define E0_HELP 115
+#define E0_DO 116
+#define E0_F17 117
+#define E0_KPMINPLUS 118
+/*
+ * My OmniKey generates e0 4c for the "OMNI" key and the
+ * right alt key does nada. [kkoller@nyx10.cs.du.edu]
+ */
+#define E0_OK 124
+/*
+ * New microsoft keyboard is rumoured to have
+ * e0 5b (left window button), e0 5c (right window button),
+ * e0 5d (menu button). [or: LBANNER, RBANNER, RMENU]
+ * [or: Windows_L, Windows_R, TaskMan]
+ */
+#define E0_MSLW 125
+#define E0_MSRW 126
+#define E0_MSTM 127
+
+static unsigned char e0_keys[128] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00-0x07 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x08-0x0f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */
+ 0, 0, 0, 0, E0_KPENTER, E0_RCTRL, 0, 0, /* 0x18-0x1f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */
+ 0, 0, 0, 0, 0, E0_KPSLASH, 0, E0_PRSCR, /* 0x30-0x37 */
+ E0_RALT, 0, 0, 0, 0, E0_F13, E0_F14, E0_HELP, /* 0x38-0x3f */
+ E0_DO, E0_F17, 0, 0, 0, 0, E0_BREAK, E0_HOME, /* 0x40-0x47 */
+ E0_UP, E0_PGUP, 0, E0_LEFT, E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END, /* 0x48-0x4f */
+ E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 0, 0, 0, 0, /* 0x50-0x57 */
+ 0, 0, 0, E0_MSLW, E0_MSRW, E0_MSTM, 0, 0, /* 0x58-0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
+ 0, 0, 0, 0, 0, 0, 0, E0_MACRO, /* 0x68-0x6f */
+ //0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */
+ 0, 0, 0, 0, 0, E0_BACKSLASH, 0, 0, /* 0x70-0x77 */
+ 0, 0, 0, E0_YEN, 0, 0, 0, 0 /* 0x78-0x7f */
+};
+
+int sa1111_setkeycode(unsigned int scancode, unsigned int keycode)
+{
+ if (scancode < SC_LIM || scancode > 255 || keycode > 127)
+ return -EINVAL;
+ if (scancode < 128)
+ high_keys[scancode - SC_LIM] = keycode;
+ else
+ e0_keys[scancode - 128] = keycode;
+ return 0;
+}
+
+int sa1111_getkeycode(unsigned int scancode)
+{
+ return
+ (scancode < SC_LIM || scancode > 255) ? -EINVAL :
+ (scancode <
+ 128) ? high_keys[scancode - SC_LIM] : e0_keys[scancode - 128];
+}
+
+static int do_acknowledge(unsigned char scancode)
+{
+ if (reply_expected) {
+ /* Unfortunately, we must recognise these codes only if we know they
+ * are known to be valid (i.e., after sending a command), because there
+ * are some brain-damaged keyboards (yes, FOCUS 9000 again) which have
+ * keys with such codes :(
+ */
+ if (scancode == KBD_REPLY_ACK) {
+ acknowledge = 1;
+ reply_expected = 0;
+ return 0;
+ } else if (scancode == KBD_REPLY_RESEND) {
+ resend = 1;
+ reply_expected = 0;
+ return 0;
+ }
+ /* Should not happen... */
+#if 0
+ printk(KERN_DEBUG "keyboard reply expected - got %02x\n",
+ scancode);
+#endif
+ }
+ return 1;
+}
+
+int
+sa1111_translate(unsigned char scancode, unsigned char *keycode,
+ char raw_mode)
+{
+ static int prev_scancode = 0;
+
+ /* special prefix scancodes.. */
+ if (scancode == 0xe0 || scancode == 0xe1) {
+ prev_scancode = scancode;
+ return 0;
+ }
+
+ /* 0xFF is sent by a few keyboards, ignore it. 0x00 is error */
+ if (scancode == 0x00 || scancode == 0xff) {
+ prev_scancode = 0;
+ return 0;
+ }
+
+ scancode &= 0x7f;
+
+ if (prev_scancode) {
+ /*
+ * usually it will be 0xe0, but a Pause key generates
+ * e1 1d 45 e1 9d c5 when pressed, and nothing when released
+ */
+ if (prev_scancode != 0xe0) {
+ if (prev_scancode == 0xe1 && scancode == 0x1d) {
+ prev_scancode = 0x100;
+ return 0;
+ }
+ else if (prev_scancode == 0x100
+ && scancode == 0x45) {
+ *keycode = E1_PAUSE;
+ prev_scancode = 0;
+ } else {
+#ifdef KBD_REPORT_UNKN
+ if (!raw_mode)
+ printk(KERN_INFO
+ "keyboard: unknown e1 escape sequence\n");
+#endif
+ prev_scancode = 0;
+ return 0;
+ }
+ } else {
+ prev_scancode = 0;
+ /*
+ * The keyboard maintains its own internal caps lock and
+ * num lock statuses. In caps lock mode E0 AA precedes make
+ * code and E0 2A follows break code. In num lock mode,
+ * E0 2A precedes make code and E0 AA follows break code.
+ * We do our own book-keeping, so we will just ignore these.
+ */
+ /*
+ * For my keyboard there is no caps lock mode, but there are
+ * both Shift-L and Shift-R modes. The former mode generates
+ * E0 2A / E0 AA pairs, the latter E0 B6 / E0 36 pairs.
+ * So, we should also ignore the latter. - aeb@cwi.nl
+ */
+ if (scancode == 0x2a || scancode == 0x36)
+ return 0;
+
+ if (e0_keys[scancode])
+ *keycode = e0_keys[scancode];
+ else {
+#ifdef KBD_REPORT_UNKN
+ if (!raw_mode)
+ printk(KERN_INFO
+ "keyboard: unknown scancode e0 %02x\n",
+ scancode);
+#endif
+ return 0;
+ }
+ }
+ } else if (scancode >= SC_LIM) {
+ /* This happens with the FOCUS 9000 keyboard
+ Its keys PF1..PF12 are reported to generate
+ 55 73 77 78 79 7a 7b 7c 74 7e 6d 6f
+ Moreover, unless repeated, they do not generate
+ key-down events, so we have to zero up_flag below */
+ /* Also, Japanese 86/106 keyboards are reported to
+ generate 0x73 and 0x7d for \ - and \ | respectively. */
+ /* Also, some Brazilian keyboard is reported to produce
+ 0x73 and 0x7e for \ ? and KP-dot, respectively. */
+
+ *keycode = high_keys[scancode - SC_LIM];
+
+ if (!*keycode) {
+ if (!raw_mode) {
+#ifdef KBD_REPORT_UNKN
+ printk(KERN_INFO
+ "keyboard: unrecognized scancode (%02x)"
+ " - ignored\n", scancode);
+#endif
+ }
+ return 0;
+ }
+ } else
+ *keycode = scancode;
+ return 1;
+}
+
+char sa1111_unexpected_up(unsigned char keycode)
+{
+ /* unexpected, but this can happen: maybe this was a key release for a
+ FOCUS 9000 PF key; if we want to see it, we have to clear up_flag */
+ if (keycode >= SC_LIM || keycode == 85)
+ return 0;
+ else
+ return 0200;
+}
+
+static unsigned char kbd_exists = 1;
+
+static inline void handle_keyboard_event(unsigned char scancode)
+{
+#ifdef CONFIG_VT
+ kbd_exists = 1;
+ if (do_acknowledge(scancode))
+ handle_scancode(scancode, !(scancode & 0x80));
+#endif
+ tasklet_schedule(&keyboard_tasklet);
+}
+
+/*
+ * This reads the keyboard status port, and does the
+ * appropriate action.
+ *
+ * It requires that we hold the keyboard controller
+ * spinlock.
+ */
+static void handle_kbd_event(void)
+{
+ unsigned int status = KBDSTAT;
+ unsigned int work = 10000;
+ unsigned char scancode;
+
+ while (status & KBD_STAT_RXF) {
+ while (status & KBD_STAT_RXF) {
+ scancode = KBDDATA & 0xff;
+ if (!(status & KBD_STAT_STP))
+ handle_keyboard_event(scancode);
+ if (!--work) {
+ printk(KERN_ERR
+ "pc_keyb: keyboard controller jammed (0x%02X).\n",
+ status);
+ return;
+ }
+ status = KBDSTAT;
+ }
+ work = 10000;
+ }
+
+ if (status & KBD_STAT_STP)
+ KBDSTAT = KBD_STAT_STP;
+}
+
+static void keyboard_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned long flags;
+
+#ifdef CONFIG_VT
+ kbd_pt_regs = regs;
+#endif
+ spin_lock_irqsave(&kbd_controller_lock, flags);
+ handle_kbd_event();
+ spin_unlock_irqrestore(&kbd_controller_lock, flags);
+}
+
+/*
+ * send_data sends a character to the keyboard and waits
+ * for an acknowledge, possibly retrying if asked to. Returns
+ * the success status.
+ *
+ * Don't use 'jiffies', so that we don't depend on interrupts
+ */
+static int send_data(unsigned char data)
+{
+ int retries = 3;
+
+ do {
+ unsigned long timeout = KBD_TIMEOUT;
+
+ acknowledge = 0; /* Set by interrupt routine on receipt of ACK. */
+ resend = 0;
+ reply_expected = 1;
+ kbd_write_output_w(data);
+ for (;;) {
+ if (acknowledge)
+ return 1;
+ if (resend)
+ break;
+ mdelay(1);
+ if (!--timeout) {
+#ifdef KBD_REPORT_TIMEOUTS
+ printk(KERN_WARNING
+ "keyboard: Timeout - AT keyboard not present?\n");
+#endif
+ return 0;
+ }
+ }
+ }
+ while (retries-- > 0);
+#ifdef KBD_REPORT_TIMEOUTS
+ printk(KERN_WARNING
+ "keyboard: Too many NACKs -- noisy kbd cable?\n");
+#endif
+ return 0;
+}
+
+void sa1111_leds(unsigned char leds)
+{
+ if (kbd_exists
+ && (!send_data(KBD_CMD_SET_LEDS) || !send_data(leds))) {
+ send_data(KBD_CMD_ENABLE); /* re-enable kbd if any errors */
+ kbd_exists = 0;
+ }
+}
+
+#define KBD_NO_DATA (-1) /* No data */
+#define KBD_BAD_DATA (-2) /* Parity or other error */
+
+static int __init kbd_read_data(void)
+{
+ int retval = KBD_NO_DATA;
+ unsigned int status;
+
+ status = KBDSTAT;
+ if (status & KBD_STAT_RXF) {
+ unsigned char data = KBDDATA;
+
+ retval = data;
+ if (status & KBD_STAT_STP)
+ retval = KBD_BAD_DATA;
+ }
+ return retval;
+}
+
+static void __init kbd_clear_input(void)
+{
+ int maxread = 100; /* Random number */
+
+ do {
+ if (kbd_read_data() == KBD_NO_DATA)
+ break;
+ }
+ while (--maxread);
+}
+
+static int __init kbd_wait_for_input(void)
+{
+ long timeout = KBD_INIT_TIMEOUT;
+
+ do {
+ int retval = kbd_read_data();
+ if (retval >= 0)
+ return retval;
+ mdelay(1);
+ }
+ while (--timeout);
+ return -1;
+}
+
+#if 0
+static void kbd_write_command_w(int data)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&kbd_controller_lock, flags);
+ kb_wait();
+ kbd_write_command(data);
+ spin_unlock_irqrestore(&kbd_controller_lock, flags);
+}
+#endif
+
+static void kbd_write_output_w(int data)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&kbd_controller_lock, flags);
+ kb_wait();
+ KBDDATA = data & 0xff;
+ spin_unlock_irqrestore(&kbd_controller_lock, flags);
+}
+
+/*
+ * Test the keyboard interface. We basically check to make sure that
+ * we can drive each line to the keyboard independently of each other.
+ */
+static int kbdif_test(void)
+{
+ int ret = 0;
+
+ KBDCR = KBDCR_ENA | KBDCR_FKC;
+ udelay(2);
+ if ((KBDSTAT & (KBDSTAT_KBC | KBDSTAT_KBD)) != KBDSTAT_KBD) {
+ printk("Keyboard interface test failed[1]: %02x\n",
+ KBDSTAT);
+ ret = -ENODEV;
+ }
+
+ KBDCR = KBDCR_ENA;
+ udelay(2);
+ if ((KBDSTAT & (KBDSTAT_KBC | KBDSTAT_KBD)) != (KBDSTAT_KBC | KBDSTAT_KBD)) {
+ printk("Keyboard interface test failed[2]: %02x\n",
+ KBDSTAT);
+ ret = -ENODEV;
+ }
+
+ KBDCR = KBDCR_ENA | KBDCR_FKD;
+ udelay(2);
+ if ((KBDSTAT & (KBDSTAT_KBC | KBDSTAT_KBD)) != KBDSTAT_KBC) {
+ printk("Keyboard interface test failed[3]: %02x\n",
+ KBDSTAT);
+ ret = -ENODEV;
+ }
+
+ return ret;
+}
+
+static char *__init initialize_kbd(void)
+{
+ int status;
+
+ /*
+ * Test the keyboard interface.
+ */
+ kbdif_test();
+
+ /*
+ * Ok, drop the force low bits, and wait a while,
+ * and clear the stop bit error flag.
+ */
+ KBDCR = KBDCR_ENA;
+ udelay(4);
+ KBDSTAT = KBD_STAT_STP;
+
+ /*
+ * Ok, we're now ready to talk to the keyboard. Reset
+ * it, just to make sure we're starting in a sane state.
+ *
+ * Set up to try again if the keyboard asks for RESEND.
+ */
+ do {
+ KBDDATA = KBD_CMD_RESET;
+ status = kbd_wait_for_input();
+ if (status == KBD_REPLY_ACK)
+ break;
+ if (status != KBD_REPLY_RESEND)
+ return "Keyboard reset failed, no ACK";
+ } while (1);
+
+ if (kbd_wait_for_input() != KBD_REPLY_POR)
+ return "Keyboard reset failed, no POR";
+
+ /*
+ * Set keyboard controller mode. During this, the keyboard should be
+ * in the disabled state.
+ *
+ * Set up to try again if the keyboard asks for RESEND.
+ */
+ do {
+ kbd_write_output_w(KBD_CMD_DISABLE);
+ status = kbd_wait_for_input();
+ if (status == KBD_REPLY_ACK)
+ break;
+ if (status != KBD_REPLY_RESEND)
+ return "Disable keyboard: no ACK";
+ } while (1);
+
+#if 0 /*@@@ */
+ kbd_write_command_w(KBD_CCMD_WRITE_MODE);
+ kbd_write_output_w(KBD_MODE_KBD_INT
+ | KBD_MODE_SYS | KBD_MODE_DISABLE_MOUSE |
+ KBD_MODE_KCC);
+
+ /* ibm powerpc portables need this to use scan-code set 1 -- Cort */
+ kbd_write_command_w(KBD_CCMD_READ_MODE);
+ if (!(kbd_wait_for_input() & KBD_MODE_KCC)) {
+ /*
+ * If the controller does not support conversion,
+ * Set the keyboard to scan-code set 1.
+ */
+ kbd_write_output_w(0xF0);
+ kbd_wait_for_input();
+ kbd_write_output_w(0x01);
+ kbd_wait_for_input();
+ }
+#else
+ kbd_write_output_w(0xf0);
+ kbd_wait_for_input();
+ kbd_write_output_w(0x01);
+ kbd_wait_for_input();
+#endif
+
+
+ kbd_write_output_w(KBD_CMD_ENABLE);
+ if (kbd_wait_for_input() != KBD_REPLY_ACK)
+ return "Enable keyboard: no ACK";
+
+ /*
+ * Finally, set the typematic rate to maximum.
+ */
+ kbd_write_output_w(KBD_CMD_SET_RATE);
+ if (kbd_wait_for_input() != KBD_REPLY_ACK)
+ return "Set rate: no ACK";
+ kbd_write_output_w(0x00);
+ if (kbd_wait_for_input() != KBD_REPLY_ACK)
+ return "Set rate: no ACK";
+
+ return NULL;
+}
+
+int __init sa1111_kbd_init_hw(void)
+{
+ char *msg;
+ int ret;
+
+ if (!request_mem_region(_KBDCR, 512, "keyboard"))
+ return -EBUSY;
+
+ SKPCR |= SKPCR_PTCLKEN;
+ KBDCLKDIV = 0;
+ KBDPRECNT = 127;
+
+ /* Flush any pending input. */
+ kbd_clear_input();
+
+ msg = initialize_kbd();
+ if (msg)
+ printk(KERN_WARNING "initialize_kbd: %s\n", msg);
+
+#if defined CONFIG_PSMOUSE
+ psaux_init();
+#endif
+
+ k_setkeycode = sa1111_setkeycode;
+ k_getkeycode = sa1111_getkeycode;
+ k_translate = sa1111_translate;
+ k_unexpected_up = sa1111_unexpected_up;
+ k_leds = sa1111_leds;
+#ifdef CONFIG_MAGIC_SYSRQ
+ k_sysrq_xlate = sa1111_sysrq_xlate;
+ k_sysrq_key = 0x54;
+#endif
+
+ /* Ok, finally allocate the IRQ, and off we go.. */
+ ret = request_irq(IRQ_TPRXINT, keyboard_interrupt, 0, "keyboard", NULL);
+ if (ret)
+ release_mem_region(_KBDCR, 512);
+
+ return ret;
+}
+
+#if defined CONFIG_PSMOUSE
+
+static inline void handle_mouse_event(unsigned char scancode)
+{
+ if (mouse_reply_expected) {
+ if (scancode == AUX_ACK) {
+ mouse_reply_expected--;
+ return;
+ }
+ mouse_reply_expected = 0;
+ }
+
+ add_mouse_randomness(scancode);
+ if (aux_count) {
+ int head = queue->head;
+
+ queue->buf[head] = scancode;
+ head = (head + 1) & (AUX_BUF_SIZE - 1);
+ if (head != queue->tail) {
+ queue->head = head;
+ if (queue->fasync)
+ kill_fasync(&queue->fasync, SIGIO,
+ POLL_IN);
+ wake_up_interruptible(&queue->proc_list);
+ }
+ }
+}
+
+static void handle_mse_event(void)
+{
+ unsigned int msests = MSESTAT;
+ unsigned int work = 10000;
+ unsigned char scancode;
+
+ while (msests & MSE_STAT_RXF) {
+ while (msests & MSE_STAT_RXF) {
+ scancode = MSEDATA & 0xff;
+ if (!(msests & MSE_STAT_STP))
+ handle_mouse_event(scancode);
+ if (!--work) {
+ printk(KERN_ERR
+ "pc_keyb: mouse controller jammed (0x%02X).\n",
+ msests);
+ return;
+ /*XXX*/}
+ msests = MSESTAT;
+ }
+ work = 10000;
+ }
+}
+
+static void ms_wait(void)
+{
+ unsigned long timeout = KBC_TIMEOUT;
+
+ do {
+ /*
+ * "handle_kbd_event()" will handle any incoming events
+ * while we wait - keypresses or mouse movement.
+ */
+ handle_mse_event();
+ if (MSESTAT & MSE_STAT_TXE)
+ return;
+ mdelay(1);
+ timeout--;
+ }
+ while (timeout);
+#ifdef KBD_REPORT_TIMEOUTS
+ printk(KERN_WARNING "Mouse timed out[1]\n");
+#endif
+}
+
+static void mouse_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&kbd_controller_lock, flags);
+ handle_mse_event();
+ spin_unlock_irqrestore(&kbd_controller_lock, flags);
+}
+
+/*
+ * Check if this is a dual port controller.
+ */
+static int __init detect_auxiliary_port(void)
+{
+ unsigned long flags;
+ int loops = 10;
+ int retval = 0;
+
+ /* Check if the BIOS detected a device on the auxiliary port. */
+ if (aux_device_present == 0xaa)
+ return 1;
+
+ spin_lock_irqsave(&kbd_controller_lock, flags);
+
+ /* Put the value 0x5A in the output buffer using the "Write
+ * Auxiliary Device Output Buffer" command (0xD3). Poll the
+ * Status Register for a while to see if the value really
+ * turns up in the Data Register. If the KBD_STAT_MOUSE_OBF
+ * bit is also set to 1 in the Status Register, we assume this
+ * controller has an Auxiliary Port (a.k.a. Mouse Port).
+ */
+ // kb_wait();
+ // kbd_write_command(KBD_CCMD_WRITE_AUX_OBUF);
+
+ SKPCR |= SKPCR_PMCLKEN;
+
+ MSECLKDIV = 0;
+ MSEPRECNT = 127;
+ MSECR = MSECR_ENA;
+ mdelay(50);
+ MSEDATA = 0xf4;
+ mdelay(50);
+
+ do {
+ unsigned int msests = MSESTAT;
+
+ if (msests & MSE_STAT_RXF) {
+ do {
+ msests = MSEDATA; /* dummy read */
+ mdelay(50);
+ msests = MSESTAT;
+ }
+ while (msests & MSE_STAT_RXF);
+ printk(KERN_INFO "Detected PS/2 Mouse Port.\n");
+ retval = 1;
+ break;
+ }
+ mdelay(1);
+ }
+ while (--loops);
+ spin_unlock_irqrestore(&kbd_controller_lock, flags);
+
+ return retval;
+}
+
+/*
+ * Send a byte to the mouse.
+ */
+static void aux_write_dev(int val)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&kbd_controller_lock, flags);
+ // kb_wait();
+ // kbd_write_command(KBD_CCMD_WRITE_MOUSE);
+ ms_wait();
+ MSEDATA = val;
+ spin_unlock_irqrestore(&kbd_controller_lock, flags);
+}
+
+/*
+ * Send a byte to the mouse & handle returned ack
+ */
+static void aux_write_ack(int val)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&kbd_controller_lock, flags);
+ // kb_wait();
+ // kbd_write_command(KBD_CCMD_WRITE_MOUSE);
+ ms_wait();
+ MSEDATA = val;
+ /* we expect an ACK in response. */
+ mouse_reply_expected++;
+ ms_wait();
+ spin_unlock_irqrestore(&kbd_controller_lock, flags);
+}
+
+static unsigned char get_from_queue(void)
+{
+ unsigned char result;
+ unsigned long flags;
+
+ spin_lock_irqsave(&kbd_controller_lock, flags);
+ result = queue->buf[queue->tail];
+ queue->tail = (queue->tail + 1) & (AUX_BUF_SIZE - 1);
+ spin_unlock_irqrestore(&kbd_controller_lock, flags);
+ return result;
+}
+
+
+static inline int queue_empty(void)
+{
+ return queue->head == queue->tail;
+}
+
+static int fasync_aux(int fd, struct file *filp, int on)
+{
+ int retval;
+
+ retval = fasync_helper(fd, filp, on, &queue->fasync);
+ if (retval < 0)
+ return retval;
+ return 0;
+}
+
+
+/*
+ * Random magic cookie for the aux device
+ */
+#define AUX_DEV ((void *)queue)
+
+static int release_aux(struct inode *inode, struct file *file)
+{
+ fasync_aux(-1, file, 0);
+ if (--aux_count)
+ return 0;
+ // kbd_write_cmd(AUX_INTS_OFF); /* Disable controller ints */
+ // kbd_write_command_w(KBD_CCMD_MOUSE_DISABLE);
+ aux_write_ack(AUX_DISABLE_DEV); /* Disable aux device */
+ MSECR &= ~MSECR_ENA;
+ free_irq(IRQ_MSRXINT, AUX_DEV);
+ return 0;
+}
+
+/*
+ * Install interrupt handler.
+ * Enable auxiliary device.
+ */
+
+static int open_aux(struct inode *inode, struct file *file)
+{
+ if (aux_count++) {
+ return 0;
+ }
+ queue->head = queue->tail = 0; /* Flush input queue */
+ /* Don't enable the mouse controller until we've registered IRQ handler */
+ if (request_irq(IRQ_MSRXINT, mouse_interrupt, SA_SHIRQ, "PS/2 Mouse", AUX_DEV)) {
+ aux_count--;
+ return -EBUSY;
+ }
+ MSECLKDIV = 0;
+ MSEPRECNT = 127;
+ MSECR &= ~MSECR_ENA;
+ mdelay(50);
+ MSECR = MSECR_ENA;
+ mdelay(50);
+ MSEDATA = 0xf4;
+ mdelay(50);
+ if (MSESTAT & 0x0100) {
+ MSESTAT = 0x0100; /* clear IRQ status */
+ }
+/* kbd_write_command_w(KBD_CCMD_MOUSE_ENABLE); *//* Enable the
+ auxiliary port on
+ controller. */
+ aux_write_ack(AUX_ENABLE_DEV); /* Enable aux device */
+ // kbd_write_cmd(AUX_INTS_ON); /* Enable controller ints */
+
+ // send_data(KBD_CMD_ENABLE); /* try to workaround toshiba4030cdt problem */
+
+ return 0;
+}
+
+/*
+ * Put bytes from input queue to buffer.
+ */
+
+static ssize_t
+read_aux(struct file *file, char *buffer, size_t count, loff_t * ppos)
+{
+ DECLARE_WAITQUEUE(wait, current);
+ ssize_t i = count;
+ unsigned char c;
+
+ if (queue_empty()) {
+ if (file->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+ add_wait_queue(&queue->proc_list, &wait);
+ repeat:
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (queue_empty() && !signal_pending(current)) {
+ schedule();
+ goto repeat;
+ }
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&queue->proc_list, &wait);
+ }
+ while (i > 0 && !queue_empty()) {
+ c = get_from_queue();
+ put_user(c, buffer++);
+ i--;
+ }
+ if (count - i) {
+ file->f_dentry->d_inode->i_atime = CURRENT_TIME;
+ return count - i;
+ }
+ if (signal_pending(current))
+ return -ERESTARTSYS;
+ return 0;
+}
+
+/*
+ * Write to the aux device.
+ */
+
+static ssize_t
+write_aux(struct file *file, const char *buffer, size_t count,
+ loff_t * ppos)
+{
+ ssize_t retval = 0;
+
+ if (count) {
+ ssize_t written = 0;
+
+ if (count > 32)
+ count = 32; /* Limit to 32 bytes. */
+ do {
+ char c;
+ get_user(c, buffer++);
+ aux_write_dev(c);
+ written++;
+ }
+ while (--count);
+ retval = -EIO;
+ if (written) {
+ retval = written;
+ file->f_dentry->d_inode->i_mtime = CURRENT_TIME;
+ }
+ }
+
+ return retval;
+}
+
+static unsigned int aux_poll(struct file *file, poll_table * wait)
+{
+ poll_wait(file, &queue->proc_list, wait);
+ if (!queue_empty())
+ return POLLIN | POLLRDNORM;
+ return 0;
+}
+
+struct file_operations psaux_fops = {
+ read: read_aux,
+ write: write_aux,
+ poll: aux_poll,
+ open: open_aux,
+ release: release_aux,
+ fasync: fasync_aux,
+};
+
+/*
+ * Initialize driver.
+ */
+static struct miscdevice psaux_mouse = {
+ PSMOUSE_MINOR, "psaux", &psaux_fops
+};
+
+
+static int __init psaux_init(void)
+{
+ int ret;
+
+ if (!request_mem_region(_MSECR, 512, "psaux"))
+ return -EBUSY;
+
+ if (!detect_auxiliary_port()) {
+ ret = -EIO;
+ goto out;
+ }
+
+ misc_register(&psaux_mouse);
+ queue = (struct aux_queue *) kmalloc(sizeof(*queue), GFP_KERNEL);
+ memset(queue, 0, sizeof(*queue));
+ queue->head = queue->tail = 0;
+ init_waitqueue_head(&queue->proc_list);
+
+#ifdef CONFIG_PSMOUSE
+ aux_write_ack(AUX_SET_SAMPLE);
+ aux_write_ack(100); /* 100 samples/sec */
+ aux_write_ack(AUX_SET_RES);
+ aux_write_ack(3); /* 8 counts per mm */
+ aux_write_ack(AUX_SET_SCALE21); /* 2:1 scaling */
+#endif
+ ret = 0;
+
+ out:
+ if (ret)
+ release_mem_region(_MSECR, 512);
+ return ret;
+}
+
+#endif /* CONFIG_PSMOUSE */
diff -urN linux-2.4.26/drivers/char/serial.c linux-2.4.26-vrs1/drivers/char/serial.c
--- linux-2.4.26/drivers/char/serial.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/char/serial.c 2004-02-23 13:36:30.000000000 +0000
@@ -4527,6 +4527,14 @@
}
/*
+ * If there is exactly one port of 8 bytes, use it.
+ */
+ if (num_port == 1 && pci_resource_len(dev, first_port) == 8) {
+ board->flags = first_port;
+ return 0;
+ }
+
+ /*
* If there is 1 or 0 iomem regions, and exactly one port, use
* it.
*/
diff -urN linux-2.4.26/drivers/char/serial_21285.c linux-2.4.26-vrs1/drivers/char/serial_21285.c
--- linux-2.4.26/drivers/char/serial_21285.c 2002-08-03 01:39:43.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/serial_21285.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,498 +0,0 @@
-/*
- * linux/drivers/char/serial_21285.c
- *
- * Driver for the serial port on the 21285 StrongArm-110 core logic chip.
- *
- * Based on drivers/char/serial.c
- */
-
-#include <linux/config.h>
-#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/serial.h>
-#include <linux/major.h>
-#include <linux/ptrace.h>
-#include <linux/ioport.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <linux/console.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/dec21285.h>
-#include <asm/hardware.h>
-
-#define BAUD_BASE (mem_fclk_21285/64)
-
-#define SERIAL_21285_NAME "ttyFB"
-#define SERIAL_21285_MAJOR 204
-#define SERIAL_21285_MINOR 4
-
-#define SERIAL_21285_AUXNAME "cuafb"
-#define SERIAL_21285_AUXMAJOR 205
-#define SERIAL_21285_AUXMINOR 4
-
-static struct tty_driver rs285_driver, callout_driver;
-static int rs285_refcount;
-static struct tty_struct *rs285_table[1];
-
-static struct termios *rs285_termios[1];
-static struct termios *rs285_termios_locked[1];
-
-static char wbuf[1000], *putp = wbuf, *getp = wbuf, x_char;
-static struct tty_struct *rs285_tty;
-static int rs285_use_count;
-
-static int rs285_write_room(struct tty_struct *tty)
-{
- return putp >= getp ? (sizeof(wbuf) - (long) putp + (long) getp) : ((long) getp - (long) putp - 1);
-}
-
-static void rs285_rx_int(int irq, void *dev_id, struct pt_regs *regs)
-{
- if (!rs285_tty) {
- disable_irq(IRQ_CONRX);
- return;
- }
- while (!(*CSR_UARTFLG & 0x10)) {
- int ch, flag;
- ch = *CSR_UARTDR;
- flag = *CSR_RXSTAT;
- if (flag & 4)
- tty_insert_flip_char(rs285_tty, 0, TTY_OVERRUN);
- if (flag & 2)
- flag = TTY_PARITY;
- else if (flag & 1)
- flag = TTY_FRAME;
- tty_insert_flip_char(rs285_tty, ch, flag);
- }
- tty_flip_buffer_push(rs285_tty);
-}
-
-static void rs285_send_xchar(struct tty_struct *tty, char ch)
-{
- x_char = ch;
- enable_irq(IRQ_CONTX);
-}
-
-static void rs285_throttle(struct tty_struct *tty)
-{
- if (I_IXOFF(tty))
- rs285_send_xchar(tty, STOP_CHAR(tty));
-}
-
-static void rs285_unthrottle(struct tty_struct *tty)
-{
- if (I_IXOFF(tty)) {
- if (x_char)
- x_char = 0;
- else
- rs285_send_xchar(tty, START_CHAR(tty));
- }
-}
-
-static void rs285_tx_int(int irq, void *dev_id, struct pt_regs *regs)
-{
- while (!(*CSR_UARTFLG & 0x20)) {
- if (x_char) {
- *CSR_UARTDR = x_char;
- x_char = 0;
- continue;
- }
- if (putp == getp) {
- disable_irq(IRQ_CONTX);
- break;
- }
- *CSR_UARTDR = *getp;
- if (++getp >= wbuf + sizeof(wbuf))
- getp = wbuf;
- }
- if (rs285_tty)
- wake_up_interruptible(&rs285_tty->write_wait);
-}
-
-static inline int rs285_xmit(int ch)
-{
- if (putp + 1 == getp || (putp + 1 == wbuf + sizeof(wbuf) && getp == wbuf))
- return 0;
- *putp = ch;
- if (++putp >= wbuf + sizeof(wbuf))
- putp = wbuf;
- enable_irq(IRQ_CONTX);
- return 1;
-}
-
-static int rs285_write(struct tty_struct *tty, int from_user,
- const u_char * buf, int count)
-{
- int i;
-
- if (from_user && verify_area(VERIFY_READ, buf, count))
- return -EINVAL;
-
- for (i = 0; i < count; i++) {
- char ch;
- if (from_user)
- __get_user(ch, buf + i);
- else
- ch = buf[i];
- if (!rs285_xmit(ch))
- break;
- }
- return i;
-}
-
-static void rs285_put_char(struct tty_struct *tty, u_char ch)
-{
- rs285_xmit(ch);
-}
-
-static int rs285_chars_in_buffer(struct tty_struct *tty)
-{
- return sizeof(wbuf) - rs285_write_room(tty);
-}
-
-static void rs285_flush_buffer(struct tty_struct *tty)
-{
- disable_irq(IRQ_CONTX);
- putp = getp = wbuf;
- if (x_char)
- enable_irq(IRQ_CONTX);
-}
-
-static inline void rs285_set_cflag(int cflag)
-{
- int h_lcr, baud, quot;
-
- switch (cflag & CSIZE) {
- case CS5:
- h_lcr = 0x10;
- break;
- case CS6:
- h_lcr = 0x30;
- break;
- case CS7:
- h_lcr = 0x50;
- break;
- default: /* CS8 */
- h_lcr = 0x70;
- break;
-
- }
- if (cflag & CSTOPB)
- h_lcr |= 0x08;
- if (cflag & PARENB)
- h_lcr |= 0x02;
- if (!(cflag & PARODD))
- h_lcr |= 0x04;
-
- switch (cflag & CBAUD) {
- case B200: baud = 200; break;
- case B300: baud = 300; break;
- case B1200: baud = 1200; break;
- case B1800: baud = 1800; break;
- case B2400: baud = 2400; break;
- case B4800: baud = 4800; break;
- default:
- case B9600: baud = 9600; break;
- case B19200: baud = 19200; break;
- case B38400: baud = 38400; break;
- case B57600: baud = 57600; break;
- case B115200: baud = 115200; break;
- }
-
- /*
- * The documented expression for selecting the divisor is:
- * BAUD_BASE / baud - 1
- * However, typically BAUD_BASE is not divisible by baud, so
- * we want to select the divisor that gives us the minimum
- * error. Therefore, we want:
- * int(BAUD_BASE / baud - 0.5) ->
- * int(BAUD_BASE / baud - (baud >> 1) / baud) ->
- * int((BAUD_BASE - (baud >> 1)) / baud)
- */
- quot = (BAUD_BASE - (baud >> 1)) / baud;
-
- *CSR_UARTCON = 0;
- *CSR_L_UBRLCR = quot & 0xff;
- *CSR_M_UBRLCR = (quot >> 8) & 0x0f;
- *CSR_H_UBRLCR = h_lcr;
- *CSR_UARTCON = 1;
-}
-
-static void rs285_set_termios(struct tty_struct *tty, struct termios *old)
-{
- if (old && tty->termios->c_cflag == old->c_cflag)
- return;
- rs285_set_cflag(tty->termios->c_cflag);
-}
-
-
-static void rs285_stop(struct tty_struct *tty)
-{
- disable_irq(IRQ_CONTX);
-}
-
-static void rs285_start(struct tty_struct *tty)
-{
- enable_irq(IRQ_CONTX);
-}
-
-static void rs285_wait_until_sent(struct tty_struct *tty, int timeout)
-{
- int orig_jiffies = jiffies;
- while (*CSR_UARTFLG & 8) {
- current->state = TASK_INTERRUPTIBLE;
- schedule_timeout(1);
- if (signal_pending(current))
- break;
- if (timeout && time_after(jiffies, orig_jiffies + timeout))
- break;
- }
- current->state = TASK_RUNNING;
-}
-
-static int rs285_open(struct tty_struct *tty, struct file *filp)
-{
- int line;
-
- MOD_INC_USE_COUNT;
- line = MINOR(tty->device) - tty->driver.minor_start;
- if (line) {
- MOD_DEC_USE_COUNT;
- return -ENODEV;
- }
-
- tty->driver_data = NULL;
- if (!rs285_tty)
- rs285_tty = tty;
-
- enable_irq(IRQ_CONRX);
- rs285_use_count++;
- return 0;
-}
-
-static void rs285_close(struct tty_struct *tty, struct file *filp)
-{
- if (!--rs285_use_count) {
- rs285_wait_until_sent(tty, 0);
- disable_irq(IRQ_CONRX);
- disable_irq(IRQ_CONTX);
- rs285_tty = NULL;
- }
- MOD_DEC_USE_COUNT;
-}
-
-static int __init rs285_init(void)
-{
- int baud = B9600;
-
- if (machine_is_personal_server())
- baud = B57600;
-
- rs285_driver.magic = TTY_DRIVER_MAGIC;
- rs285_driver.driver_name = "serial_21285";
- rs285_driver.name = SERIAL_21285_NAME;
- rs285_driver.major = SERIAL_21285_MAJOR;
- rs285_driver.minor_start = SERIAL_21285_MINOR;
- rs285_driver.num = 1;
- rs285_driver.type = TTY_DRIVER_TYPE_SERIAL;
- rs285_driver.subtype = SERIAL_TYPE_NORMAL;
- rs285_driver.init_termios = tty_std_termios;
- rs285_driver.init_termios.c_cflag = baud | CS8 | CREAD | HUPCL | CLOCAL;
- rs285_driver.flags = TTY_DRIVER_REAL_RAW;
- rs285_driver.refcount = &rs285_refcount;
- rs285_driver.table = rs285_table;
- rs285_driver.termios = rs285_termios;
- rs285_driver.termios_locked = rs285_termios_locked;
-
- rs285_driver.open = rs285_open;
- rs285_driver.close = rs285_close;
- rs285_driver.write = rs285_write;
- rs285_driver.put_char = rs285_put_char;
- rs285_driver.write_room = rs285_write_room;
- rs285_driver.chars_in_buffer = rs285_chars_in_buffer;
- rs285_driver.flush_buffer = rs285_flush_buffer;
- rs285_driver.throttle = rs285_throttle;
- rs285_driver.unthrottle = rs285_unthrottle;
- rs285_driver.send_xchar = rs285_send_xchar;
- rs285_driver.set_termios = rs285_set_termios;
- rs285_driver.stop = rs285_stop;
- rs285_driver.start = rs285_start;
- rs285_driver.wait_until_sent = rs285_wait_until_sent;
-
- callout_driver = rs285_driver;
- callout_driver.name = SERIAL_21285_AUXNAME;
- callout_driver.major = SERIAL_21285_AUXMAJOR;
- callout_driver.subtype = SERIAL_TYPE_CALLOUT;
-
- if (request_irq(IRQ_CONRX, rs285_rx_int, 0, "rs285", NULL))
- panic("Couldn't get rx irq for rs285");
-
- if (request_irq(IRQ_CONTX, rs285_tx_int, 0, "rs285", NULL))
- panic("Couldn't get tx irq for rs285");
-
- if (tty_register_driver(&rs285_driver))
- printk(KERN_ERR "Couldn't register 21285 serial driver\n");
- if (tty_register_driver(&callout_driver))
- printk(KERN_ERR "Couldn't register 21285 callout driver\n");
-
- return 0;
-}
-
-static void __exit rs285_fini(void)
-{
- unsigned long flags;
- int ret;
-
- save_flags(flags);
- cli();
- ret = tty_unregister_driver(&callout_driver);
- if (ret)
- printk(KERN_ERR "Unable to unregister 21285 callout driver "
- "(%d)\n", ret);
- ret = tty_unregister_driver(&rs285_driver);
- if (ret)
- printk(KERN_ERR "Unable to unregister 21285 driver (%d)\n",
- ret);
- free_irq(IRQ_CONTX, NULL);
- free_irq(IRQ_CONRX, NULL);
- restore_flags(flags);
-}
-
-module_init(rs285_init);
-module_exit(rs285_fini);
-
-#ifdef CONFIG_SERIAL_21285_CONSOLE
-/************** console driver *****************/
-
-static void rs285_console_write(struct console *co, const char *s, u_int count)
-{
- int i;
-
- disable_irq(IRQ_CONTX);
- for (i = 0; i < count; i++) {
- while (*CSR_UARTFLG & 0x20);
- *CSR_UARTDR = s[i];
- if (s[i] == '\n') {
- while (*CSR_UARTFLG & 0x20);
- *CSR_UARTDR = '\r';
- }
- }
- enable_irq(IRQ_CONTX);
-}
-
-static kdev_t rs285_console_device(struct console *c)
-{
- return MKDEV(SERIAL_21285_MAJOR, SERIAL_21285_MINOR);
-}
-
-static int __init rs285_console_setup(struct console *co, char *options)
-{
- int baud = 9600;
- int bits = 8;
- int parity = 'n';
- int cflag = CREAD | HUPCL | CLOCAL;
-
- if (machine_is_personal_server())
- baud = 57600;
-
- if (options) {
- char *s = options;
- baud = simple_strtoul(options, NULL, 10);
- while (*s >= '0' && *s <= '9')
- s++;
- if (*s)
- parity = *s++;
- if (*s)
- bits = *s - '0';
- }
-
- /*
- * Now construct a cflag setting.
- */
- switch (baud) {
- case 1200:
- cflag |= B1200;
- break;
- case 2400:
- cflag |= B2400;
- break;
- case 4800:
- cflag |= B4800;
- break;
- case 9600:
- cflag |= B9600;
- break;
- case 19200:
- cflag |= B19200;
- break;
- case 38400:
- cflag |= B38400;
- break;
- case 57600:
- cflag |= B57600;
- break;
- case 115200:
- cflag |= B115200;
- break;
- default:
- cflag |= B9600;
- break;
- }
- switch (bits) {
- case 7:
- cflag |= CS7;
- break;
- default:
- cflag |= CS8;
- break;
- }
- switch (parity) {
- case 'o':
- case 'O':
- cflag |= PARODD;
- break;
- case 'e':
- case 'E':
- cflag |= PARENB;
- break;
- }
- co->cflag = cflag;
- rs285_set_cflag(cflag);
- rs285_console_write(NULL, "\e[2J\e[Hboot ", 12);
- if (options)
- rs285_console_write(NULL, options, strlen(options));
- else
- rs285_console_write(NULL, "no options", 10);
- rs285_console_write(NULL, "\n", 1);
-
- return 0;
-}
-
-static struct console rs285_cons =
-{
- name: SERIAL_21285_NAME,
- write: rs285_console_write,
- device: rs285_console_device,
- setup: rs285_console_setup,
- flags: CON_PRINTBUFFER,
- index: -1,
-};
-
-void __init rs285_console_init(void)
-{
- register_console(&rs285_cons);
-}
-
-#endif /* CONFIG_SERIAL_21285_CONSOLE */
-
-MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/char/serial_amba.c linux-2.4.26-vrs1/drivers/char/serial_amba.c
--- linux-2.4.26/drivers/char/serial_amba.c 2002-08-03 01:39:43.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/serial_amba.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,2015 +0,0 @@
-/*
- * linux/drivers/char/serial_amba.c
- *
- * Driver for AMBA serial ports
- *
- * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
- *
- * Copyright 1999 ARM Limited
- * Copyright (C) 2000 Deep Blue Solutions Ltd.
- *
- * 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
- *
- *
- * This is a generic driver for ARM AMBA-type serial ports. They
- * have a lot of 16550-like features, but are not register compatable.
- * Note that although they do have CTS, DCD and DSR inputs, they do
- * not have an RI input, nor do they have DTR or RTS outputs. If
- * required, these have to be supplied via some other means (eg, GPIO)
- * and hooked into this driver.
- *
- * This could very easily become a generic serial driver for dumb UARTs
- * (eg, {82,16x}50, 21285, SA1100).
- */
-
-#include <linux/config.h>
-#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/hardware/serial_amba.h>
-
-#define SERIAL_AMBA_NAME "ttyAM"
-#define SERIAL_AMBA_MAJOR 204
-#define SERIAL_AMBA_MINOR 16
-#define SERIAL_AMBA_NR 2
-
-#define CALLOUT_AMBA_NAME "cuaam"
-#define CALLOUT_AMBA_MAJOR 205
-#define CALLOUT_AMBA_MINOR 16
-#define CALLOUT_AMBA_NR SERIAL_AMBA_NR
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#define DEBUG 0
-#define DEBUG_LEDS 0
-
-#if DEBUG_LEDS
-extern int get_leds(void);
-extern int set_leds(int);
-#endif
-
-/*
- * Access routines for the AMBA UARTs
- */
-#define UART_GET_INT_STATUS(p) IO_READ((p)->uart_base + AMBA_UARTIIR)
-#define UART_GET_FR(p) IO_READ((p)->uart_base + AMBA_UARTFR)
-#define UART_GET_CHAR(p) IO_READ((p)->uart_base + AMBA_UARTDR)
-#define UART_PUT_CHAR(p, c) IO_WRITE((p)->uart_base + AMBA_UARTDR, (c))
-#define UART_GET_RSR(p) IO_READ((p)->uart_base + AMBA_UARTRSR)
-#define UART_GET_CR(p) IO_READ((p)->uart_base + AMBA_UARTCR)
-#define UART_PUT_CR(p,c) IO_WRITE((p)->uart_base + AMBA_UARTCR, (c))
-#define UART_GET_LCRL(p) IO_READ((p)->uart_base + AMBA_UARTLCR_L)
-#define UART_PUT_LCRL(p,c) IO_WRITE((p)->uart_base + AMBA_UARTLCR_L, (c))
-#define UART_GET_LCRM(p) IO_READ((p)->uart_base + AMBA_UARTLCR_M)
-#define UART_PUT_LCRM(p,c) IO_WRITE((p)->uart_base + AMBA_UARTLCR_M, (c))
-#define UART_GET_LCRH(p) IO_READ((p)->uart_base + AMBA_UARTLCR_H)
-#define UART_PUT_LCRH(p,c) IO_WRITE((p)->uart_base + AMBA_UARTLCR_H, (c))
-#define UART_RX_DATA(s) (((s) & AMBA_UARTFR_RXFE) == 0)
-#define UART_TX_READY(s) (((s) & AMBA_UARTFR_TXFF) == 0)
-#define UART_TX_EMPTY(p) ((UART_GET_FR(p) & AMBA_UARTFR_TMSK) == 0)
-
-#define AMBA_UARTRSR_ANY (AMBA_UARTRSR_OE|AMBA_UARTRSR_BE|AMBA_UARTRSR_PE|AMBA_UARTRSR_FE)
-#define AMBA_UARTFR_MODEM_ANY (AMBA_UARTFR_DCD|AMBA_UARTFR_DSR|AMBA_UARTFR_CTS)
-
-/*
- * Things needed by tty driver
- */
-static struct tty_driver ambanormal_driver, ambacallout_driver;
-static int ambauart_refcount;
-static struct tty_struct *ambauart_table[SERIAL_AMBA_NR];
-static struct termios *ambauart_termios[SERIAL_AMBA_NR];
-static struct termios *ambauart_termios_locked[SERIAL_AMBA_NR];
-
-#if defined(CONFIG_SERIAL_AMBA_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-/*
- * Things needed internally to this driver
- */
-
-/*
- * tmp_buf is used as a temporary buffer by serial_write. We need to
- * lock it in case the copy_from_user blocks while swapping in a page,
- * and some other program tries to do a serial write at the same time.
- * Since the lock will only come under contention when the system is
- * swapping and available memory is low, it makes sense to share one
- * buffer across all the serial ports, since it significantly saves
- * memory if large numbers of serial ports are open.
- */
-static u_char *tmp_buf;
-static DECLARE_MUTEX(tmp_buf_sem);
-
-#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
-
-/* number of characters left in xmit buffer before we ask for more */
-#define WAKEUP_CHARS 256
-#define AMBA_ISR_PASS_LIMIT 256
-
-#define EVT_WRITE_WAKEUP 0
-
-struct amba_icount {
- __u32 cts;
- __u32 dsr;
- __u32 rng;
- __u32 dcd;
- __u32 rx;
- __u32 tx;
- __u32 frame;
- __u32 overrun;
- __u32 parity;
- __u32 brk;
- __u32 buf_overrun;
-};
-
-/*
- * Static information about the port
- */
-struct amba_port {
- unsigned int uart_base;
- unsigned int irq;
- unsigned int uartclk;
- unsigned int fifosize;
- unsigned int tiocm_support;
- void (*set_mctrl)(struct amba_port *, u_int mctrl);
-};
-
-/*
- * This is the state information which is persistent across opens
- */
-struct amba_state {
- struct amba_icount icount;
- unsigned int line;
- unsigned int close_delay;
- unsigned int closing_wait;
- unsigned int custom_divisor;
- unsigned int flags;
- struct termios normal_termios;
- struct termios callout_termios;
-
- int count;
- struct amba_info *info;
-};
-
-#define AMBA_XMIT_SIZE 1024
-/*
- * This is the state information which is only valid when the port is open.
- */
-struct amba_info {
- struct amba_port *port;
- struct amba_state *state;
- struct tty_struct *tty;
- unsigned char x_char;
- unsigned char old_status;
- unsigned char read_status_mask;
- unsigned char ignore_status_mask;
- struct circ_buf xmit;
- unsigned int flags;
-#ifdef SUPPORT_SYSRQ
- unsigned long sysrq;
-#endif
-
- unsigned int event;
- unsigned int timeout;
- unsigned int lcr_h;
- unsigned int mctrl;
- int blocked_open;
- pid_t session;
- pid_t pgrp;
-
- struct tasklet_struct tlet;
-
- wait_queue_head_t open_wait;
- wait_queue_head_t close_wait;
- wait_queue_head_t delta_msr_wait;
-};
-
-#ifdef CONFIG_SERIAL_AMBA_CONSOLE
-static struct console ambauart_cons;
-#endif
-static void ambauart_change_speed(struct amba_info *info, struct termios *old_termios);
-static void ambauart_wait_until_sent(struct tty_struct *tty, int timeout);
-
-#if 1 //def CONFIG_SERIAL_INTEGRATOR
-static void amba_set_mctrl_null(struct amba_port *port, u_int mctrl)
-{
-}
-
-static struct amba_port amba_ports[SERIAL_AMBA_NR] = {
- {
- uart_base: IO_ADDRESS(INTEGRATOR_UART0_BASE),
- irq: IRQ_UARTINT0,
- uartclk: 14745600,
- fifosize: 8,
- set_mctrl: amba_set_mctrl_null,
- },
- {
- uart_base: IO_ADDRESS(INTEGRATOR_UART1_BASE),
- irq: IRQ_UARTINT1,
- uartclk: 14745600,
- fifosize: 8,
- set_mctrl: amba_set_mctrl_null,
- }
-};
-#endif
-
-static struct amba_state amba_state[SERIAL_AMBA_NR];
-
-static void ambauart_enable_rx_interrupt(struct amba_info *info)
-{
- unsigned int cr;
-
- cr = UART_GET_CR(info->port);
- cr |= AMBA_UARTCR_RIE | AMBA_UARTCR_RTIE;
- UART_PUT_CR(info->port, cr);
-}
-
-static void ambauart_disable_rx_interrupt(struct amba_info *info)
-{
- unsigned int cr;
-
- cr = UART_GET_CR(info->port);
- cr &= ~(AMBA_UARTCR_RIE | AMBA_UARTCR_RTIE);
- UART_PUT_CR(info->port, cr);
-}
-
-static void ambauart_enable_tx_interrupt(struct amba_info *info)
-{
- unsigned int cr;
-
- cr = UART_GET_CR(info->port);
- cr |= AMBA_UARTCR_TIE;
- UART_PUT_CR(info->port, cr);
-}
-
-static void ambauart_disable_tx_interrupt(struct amba_info *info)
-{
- unsigned int cr;
-
- cr = UART_GET_CR(info->port);
- cr &= ~AMBA_UARTCR_TIE;
- UART_PUT_CR(info->port, cr);
-}
-
-static void ambauart_stop(struct tty_struct *tty)
-{
- struct amba_info *info = tty->driver_data;
- unsigned long flags;
-
- save_flags(flags); cli();
- ambauart_disable_tx_interrupt(info);
- restore_flags(flags);
-}
-
-static void ambauart_start(struct tty_struct *tty)
-{
- struct amba_info *info = tty->driver_data;
- unsigned long flags;
-
- save_flags(flags); cli();
- if (info->xmit.head != info->xmit.tail
- && info->xmit.buf)
- ambauart_enable_tx_interrupt(info);
- restore_flags(flags);
-}
-
-
-/*
- * This routine is used by the interrupt handler to schedule
- * processing in the software interrupt portion of the driver.
- */
-static void ambauart_event(struct amba_info *info, int event)
-{
- info->event |= 1 << event;
- tasklet_schedule(&info->tlet);
-}
-
-static void
-#ifdef SUPPORT_SYSRQ
-ambauart_rx_chars(struct amba_info *info, struct pt_regs *regs)
-#else
-ambauart_rx_chars(struct amba_info *info)
-#endif
-{
- struct tty_struct *tty = info->tty;
- unsigned int status, ch, rsr, flg, ignored = 0;
- struct amba_icount *icount = &info->state->icount;
- struct amba_port *port = info->port;
-
- status = UART_GET_FR(port);
- while (UART_RX_DATA(status)) {
- ch = UART_GET_CHAR(port);
-
- if (tty->flip.count >= TTY_FLIPBUF_SIZE)
- goto ignore_char;
- icount->rx++;
-
- flg = TTY_NORMAL;
-
- /*
- * Note that the error handling code is
- * out of the main execution path
- */
- rsr = UART_GET_RSR(port);
- if (rsr & AMBA_UARTRSR_ANY)
- goto handle_error;
-#ifdef SUPPORT_SYSRQ
- if (info->sysrq) {
- if (ch && time_before(jiffies, info->sysrq)) {
- handle_sysrq(ch, regs, NULL, NULL);
- info->sysrq = 0;
- goto ignore_char;
- }
- info->sysrq = 0;
- }
-#endif
- error_return:
- *tty->flip.flag_buf_ptr++ = flg;
- *tty->flip.char_buf_ptr++ = ch;
- tty->flip.count++;
- ignore_char:
- status = UART_GET_FR(port);
- }
-out:
- tty_flip_buffer_push(tty);
- return;
-
-handle_error:
- if (rsr & AMBA_UARTRSR_BE) {
- rsr &= ~(AMBA_UARTRSR_FE | AMBA_UARTRSR_PE);
- icount->brk++;
-
-#ifdef SUPPORT_SYSRQ
- if (info->state->line == ambauart_cons.index) {
- if (!info->sysrq) {
- info->sysrq = jiffies + HZ*5;
- goto ignore_char;
- }
- }
-#endif
- } else if (rsr & AMBA_UARTRSR_PE)
- icount->parity++;
- else if (rsr & AMBA_UARTRSR_FE)
- icount->frame++;
- if (rsr & AMBA_UARTRSR_OE)
- icount->overrun++;
-
- if (rsr & info->ignore_status_mask) {
- if (++ignored > 100)
- goto out;
- goto ignore_char;
- }
- rsr &= info->read_status_mask;
-
- if (rsr & AMBA_UARTRSR_BE)
- flg = TTY_BREAK;
- else if (rsr & AMBA_UARTRSR_PE)
- flg = TTY_PARITY;
- else if (rsr & AMBA_UARTRSR_FE)
- flg = TTY_FRAME;
-
- if (rsr & AMBA_UARTRSR_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 ambauart_tx_chars(struct amba_info *info)
-{
- struct amba_port *port = info->port;
- int count;
-
- if (info->x_char) {
- UART_PUT_CHAR(port, info->x_char);
- info->state->icount.tx++;
- info->x_char = 0;
- return;
- }
- if (info->xmit.head == info->xmit.tail
- || info->tty->stopped
- || info->tty->hw_stopped) {
- ambauart_disable_tx_interrupt(info);
- return;
- }
-
- count = port->fifosize;
- do {
- UART_PUT_CHAR(port, info->xmit.buf[info->xmit.tail]);
- info->xmit.tail = (info->xmit.tail + 1) & (AMBA_XMIT_SIZE - 1);
- info->state->icount.tx++;
- if (info->xmit.head == info->xmit.tail)
- break;
- } while (--count > 0);
-
- if (CIRC_CNT(info->xmit.head,
- info->xmit.tail,
- AMBA_XMIT_SIZE) < WAKEUP_CHARS)
- ambauart_event(info, EVT_WRITE_WAKEUP);
-
- if (info->xmit.head == info->xmit.tail) {
- ambauart_disable_tx_interrupt(info);
- }
-}
-
-static void ambauart_modem_status(struct amba_info *info)
-{
- unsigned int status, delta;
- struct amba_icount *icount = &info->state->icount;
-
- status = UART_GET_FR(info->port) & AMBA_UARTFR_MODEM_ANY;
-
- delta = status ^ info->old_status;
- info->old_status = status;
-
- if (!delta)
- return;
-
- if (delta & AMBA_UARTFR_DCD) {
- icount->dcd++;
-#ifdef CONFIG_HARD_PPS
- if ((info->flags & ASYNC_HARDPPS_CD) &&
- (status & AMBA_UARTFR_DCD)
- hardpps();
-#endif
- if (info->flags & ASYNC_CHECK_CD) {
- if (status & AMBA_UARTFR_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 (delta & AMBA_UARTFR_DSR)
- icount->dsr++;
-
- if (delta & AMBA_UARTFR_CTS) {
- icount->cts++;
-
- if (info->flags & ASYNC_CTS_FLOW) {
- status &= AMBA_UARTFR_CTS;
-
- if (info->tty->hw_stopped) {
- if (status) {
- info->tty->hw_stopped = 0;
- ambauart_enable_tx_interrupt(info);
- ambauart_event(info, EVT_WRITE_WAKEUP);
- }
- } else {
- if (!status) {
- info->tty->hw_stopped = 1;
- ambauart_disable_tx_interrupt(info);
- }
- }
- }
- }
- wake_up_interruptible(&info->delta_msr_wait);
-
-}
-
-static void ambauart_int(int irq, void *dev_id, struct pt_regs *regs)
-{
- struct amba_info *info = dev_id;
- unsigned int status, pass_counter = 0;
-
-#if DEBUG_LEDS
- // tell the world
- set_leds(get_leds() | RED_LED);
-#endif
-
- status = UART_GET_INT_STATUS(info->port);
- do {
- /*
- * FIXME: what about clearing the interrupts?
- */
-
- if (status & (AMBA_UARTIIR_RTIS | AMBA_UARTIIR_RIS))
-#ifdef SUPPORT_SYSRQ
- ambauart_rx_chars(info, regs);
-#else
- ambauart_rx_chars(info);
-#endif
- if (status & AMBA_UARTIIR_TIS)
- ambauart_tx_chars(info);
- if (status & AMBA_UARTIIR_MIS)
- ambauart_modem_status(info);
- if (pass_counter++ > AMBA_ISR_PASS_LIMIT)
- break;
-
- status = UART_GET_INT_STATUS(info->port);
- } while (status & (AMBA_UARTIIR_RTIS | AMBA_UARTIIR_RIS | AMBA_UARTIIR_TIS));
-
-#if DEBUG_LEDS
- // tell the world
- set_leds(get_leds() & ~RED_LED);
-#endif
-}
-
-static void ambauart_tasklet_action(unsigned long data)
-{
- struct amba_info *info = (struct amba_info *)data;
- struct tty_struct *tty;
-
- tty = info->tty;
- if (!tty || !test_and_clear_bit(EVT_WRITE_WAKEUP, &info->event))
- return;
-
- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
- tty->ldisc.write_wakeup)
- (tty->ldisc.write_wakeup)(tty);
- wake_up_interruptible(&tty->write_wait);
-}
-
-static int ambauart_startup(struct amba_info *info)
-{
- unsigned long flags;
- unsigned long page;
- int retval = 0;
-
- page = get_zeroed_page(GFP_KERNEL);
- if (!page)
- return -ENOMEM;
-
- save_flags(flags); cli();
-
- if (info->flags & ASYNC_INITIALIZED) {
- free_page(page);
- goto errout;
- }
-
- if (info->xmit.buf)
- free_page(page);
- else
- info->xmit.buf = (unsigned char *) page;
-
- /*
- * Allocate the IRQ
- */
- retval = request_irq(info->port->irq, ambauart_int, 0, "amba", info);
- if (retval) {
- if (capable(CAP_SYS_ADMIN)) {
- if (info->tty)
- set_bit(TTY_IO_ERROR, &info->tty->flags);
- retval = 0;
- }
- goto errout;
- }
-
- info->mctrl = 0;
- if (info->tty->termios->c_cflag & CBAUD)
- info->mctrl = TIOCM_RTS | TIOCM_DTR;
- info->port->set_mctrl(info->port, info->mctrl);
-
- /*
- * initialise the old status of the modem signals
- */
- info->old_status = UART_GET_FR(info->port) & AMBA_UARTFR_MODEM_ANY;
-
- /*
- * Finally, enable interrupts
- */
- ambauart_enable_rx_interrupt(info);
-
- if (info->tty)
- clear_bit(TTY_IO_ERROR, &info->tty->flags);
- info->xmit.head = info->xmit.tail = 0;
-
- /*
- * Set up the tty->alt_speed kludge
- */
- if (info->tty) {
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
- info->tty->alt_speed = 57600;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
- info->tty->alt_speed = 115200;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
- info->tty->alt_speed = 230400;
- if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
- info->tty->alt_speed = 460800;
- }
-
- /*
- * and set the speed of the serial port
- */
- ambauart_change_speed(info, 0);
-
- info->flags |= ASYNC_INITIALIZED;
- restore_flags(flags);
- return 0;
-
-errout:
- restore_flags(flags);
- return retval;
-}
-
-/*
- * This routine will shutdown a serial port; interrupts are disabled, and
- * DTR is dropped if the hangup on close termio flag is on.
- */
-static void ambauart_shutdown(struct amba_info *info)
-{
- unsigned long flags;
-
- if (!(info->flags & ASYNC_INITIALIZED))
- return;
-
- save_flags(flags); cli(); /* Disable interrupts */
-
- /*
- * clear delta_msr_wait queue to avoid mem leaks: we may free the irq
- * here so the queue might never be woken up
- */
- wake_up_interruptible(&info->delta_msr_wait);
-
- /*
- * Free the IRQ
- */
- free_irq(info->port->irq, info);
-
- if (info->xmit.buf) {
- unsigned long pg = (unsigned long) info->xmit.buf;
- info->xmit.buf = NULL;
- free_page(pg);
- }
-
- /*
- * disable all interrupts, disable the port
- */
- UART_PUT_CR(info->port, 0);
-
- /* disable break condition and fifos */
- UART_PUT_LCRH(info->port, UART_GET_LCRH(info->port) &
- ~(AMBA_UARTLCR_H_BRK | AMBA_UARTLCR_H_FEN));
-
- if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
- info->mctrl &= ~(TIOCM_DTR|TIOCM_RTS);
- info->port->set_mctrl(info->port, info->mctrl);
-
- /* kill off our tasklet */
- tasklet_kill(&info->tlet);
- if (info->tty)
- set_bit(TTY_IO_ERROR, &info->tty->flags);
-
- info->flags &= ~ASYNC_INITIALIZED;
- restore_flags(flags);
-}
-
-static void ambauart_change_speed(struct amba_info *info, struct termios *old_termios)
-{
- unsigned int lcr_h, baud, quot, cflag, old_cr, bits;
- unsigned long flags;
-
- if (!info->tty || !info->tty->termios)
- return;
-
- cflag = info->tty->termios->c_cflag;
-
-#if DEBUG
- printk("ambauart_set_cflag(0x%x) called\n", cflag);
-#endif
- /* byte size and parity */
- switch (cflag & CSIZE) {
- case CS5: lcr_h = AMBA_UARTLCR_H_WLEN_5; bits = 7; break;
- case CS6: lcr_h = AMBA_UARTLCR_H_WLEN_6; bits = 8; break;
- case CS7: lcr_h = AMBA_UARTLCR_H_WLEN_7; bits = 9; break;
- default: lcr_h = AMBA_UARTLCR_H_WLEN_8; bits = 10; break; // CS8
- }
- if (cflag & CSTOPB) {
- lcr_h |= AMBA_UARTLCR_H_STP2;
- bits ++;
- }
- if (cflag & PARENB) {
- lcr_h |= AMBA_UARTLCR_H_PEN;
- bits++;
- if (!(cflag & PARODD))
- lcr_h |= AMBA_UARTLCR_H_EPS;
- }
- if (info->port->fifosize > 1)
- lcr_h |= AMBA_UARTLCR_H_FEN;
-
- do {
- /* Determine divisor based on baud rate */
- baud = tty_get_baud_rate(info->tty);
- if (!baud)
- baud = 9600;
-
- if (baud == 38400 &&
- ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
- quot = info->state->custom_divisor;
- else
- quot = (info->port->uartclk / (16 * baud)) - 1;
-
- if (!quot && old_termios) {
- info->tty->termios->c_cflag &= ~CBAUD;
- info->tty->termios->c_cflag |= (old_termios->c_cflag & CBAUD);
- old_termios = NULL;
- }
- } while (quot == 0 && old_termios);
-
- /* As a last resort, if the quotient is zero, default to 9600 bps */
- if (!quot)
- quot = (info->port->uartclk / (16 * 9600)) - 1;
-
- info->timeout = (info->port->fifosize * HZ * bits * quot) /
- (info->port->uartclk / 16);
- info->timeout += HZ/50; /* Add .02 seconds of slop */
-
- if (cflag & CRTSCTS)
- info->flags |= ASYNC_CTS_FLOW;
- else
- info->flags &= ~ASYNC_CTS_FLOW;
- if (cflag & CLOCAL)
- info->flags &= ~ASYNC_CHECK_CD;
- else
- info->flags |= ASYNC_CHECK_CD;
-
- /*
- * Set up parity check flag
- */
-#define RELEVENT_IFLAG(iflag) ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
-
- info->read_status_mask = AMBA_UARTRSR_OE;
- if (I_INPCK(info->tty))
- info->read_status_mask |= AMBA_UARTRSR_FE | AMBA_UARTRSR_PE;
- if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
- info->read_status_mask |= AMBA_UARTRSR_BE;
-
- /*
- * Characters to ignore
- */
- info->ignore_status_mask = 0;
- if (I_IGNPAR(info->tty))
- info->ignore_status_mask |= AMBA_UARTRSR_FE | AMBA_UARTRSR_PE;
- if (I_IGNBRK(info->tty)) {
- info->ignore_status_mask |= AMBA_UARTRSR_BE;
- /*
- * If we're ignoring parity and break indicators,
- * ignore overruns to (for real raw support).
- */
- if (I_IGNPAR(info->tty))
- info->ignore_status_mask |= AMBA_UARTRSR_OE;
- }
-
- /* first, disable everything */
- save_flags(flags); cli();
- old_cr = UART_GET_CR(info->port) &= ~AMBA_UARTCR_MSIE;
-
- if ((info->flags & ASYNC_HARDPPS_CD) ||
- (cflag & CRTSCTS) ||
- !(cflag & CLOCAL))
- old_cr |= AMBA_UARTCR_MSIE;
-
- UART_PUT_CR(info->port, 0);
- restore_flags(flags);
-
- /* Set baud rate */
- UART_PUT_LCRM(info->port, ((quot & 0xf00) >> 8));
- UART_PUT_LCRL(info->port, (quot & 0xff));
-
- /*
- * ----------v----------v----------v----------v-----
- * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L
- * ----------^----------^----------^----------^-----
- */
- UART_PUT_LCRH(info->port, lcr_h);
- UART_PUT_CR(info->port, old_cr);
-}
-
-static void ambauart_put_char(struct tty_struct *tty, u_char ch)
-{
- struct amba_info *info = tty->driver_data;
- unsigned long flags;
-
- if (!tty || !info->xmit.buf)
- return;
-
- save_flags(flags); cli();
- if (CIRC_SPACE(info->xmit.head, info->xmit.tail, AMBA_XMIT_SIZE) != 0) {
- info->xmit.buf[info->xmit.head] = ch;
- info->xmit.head = (info->xmit.head + 1) & (AMBA_XMIT_SIZE - 1);
- }
- restore_flags(flags);
-}
-
-static void ambauart_flush_chars(struct tty_struct *tty)
-{
- struct amba_info *info = tty->driver_data;
- unsigned long flags;
-
- if (info->xmit.head == info->xmit.tail
- || tty->stopped
- || tty->hw_stopped
- || !info->xmit.buf)
- return;
-
- save_flags(flags); cli();
- ambauart_enable_tx_interrupt(info);
- restore_flags(flags);
-}
-
-static int ambauart_write(struct tty_struct *tty, int from_user,
- const u_char * buf, int count)
-{
- struct amba_info *info = tty->driver_data;
- unsigned long flags;
- int c, ret = 0;
-
- if (!tty || !info->xmit.buf || !tmp_buf)
- return 0;
-
- save_flags(flags);
- if (from_user) {
- down(&tmp_buf_sem);
- while (1) {
- int c1;
- c = CIRC_SPACE_TO_END(info->xmit.head,
- info->xmit.tail,
- AMBA_XMIT_SIZE);
- if (count < c)
- c = count;
- if (c <= 0)
- break;
-
- c -= copy_from_user(tmp_buf, buf, c);
- if (!c) {
- if (!ret)
- ret = -EFAULT;
- break;
- }
- cli();
- c1 = CIRC_SPACE_TO_END(info->xmit.head,
- info->xmit.tail,
- AMBA_XMIT_SIZE);
- if (c1 < c)
- c = c1;
- memcpy(info->xmit.buf + info->xmit.head, tmp_buf, c);
- info->xmit.head = (info->xmit.head + c) &
- (AMBA_XMIT_SIZE - 1);
- restore_flags(flags);
- buf += c;
- count -= c;
- ret += c;
- }
- up(&tmp_buf_sem);
- } else {
- cli();
- while (1) {
- c = CIRC_SPACE_TO_END(info->xmit.head,
- info->xmit.tail,
- AMBA_XMIT_SIZE);
- if (count < c)
- c = count;
- if (c <= 0)
- break;
- memcpy(info->xmit.buf + info->xmit.head, buf, c);
- info->xmit.head = (info->xmit.head + c) &
- (AMBA_XMIT_SIZE - 1);
- buf += c;
- count -= c;
- ret += c;
- }
- restore_flags(flags);
- }
- if (info->xmit.head != info->xmit.tail
- && !tty->stopped
- && !tty->hw_stopped)
- ambauart_enable_tx_interrupt(info);
- return ret;
-}
-
-static int ambauart_write_room(struct tty_struct *tty)
-{
- struct amba_info *info = tty->driver_data;
-
- return CIRC_SPACE(info->xmit.head, info->xmit.tail, AMBA_XMIT_SIZE);
-}
-
-static int ambauart_chars_in_buffer(struct tty_struct *tty)
-{
- struct amba_info *info = tty->driver_data;
-
- return CIRC_CNT(info->xmit.head, info->xmit.tail, AMBA_XMIT_SIZE);
-}
-
-static void ambauart_flush_buffer(struct tty_struct *tty)
-{
- struct amba_info *info = tty->driver_data;
- unsigned long flags;
-
-#if DEBUG
- printk("ambauart_flush_buffer(%d) called\n",
- MINOR(tty->device) - tty->driver.minor_start);
-#endif
- save_flags(flags); cli();
- info->xmit.head = info->xmit.tail = 0;
- restore_flags(flags);
- wake_up_interruptible(&tty->write_wait);
- if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
- tty->ldisc.write_wakeup)
- (tty->ldisc.write_wakeup)(tty);
-}
-
-/*
- * This function is used to send a high-priority XON/XOFF character to
- * the device
- */
-static void ambauart_send_xchar(struct tty_struct *tty, char ch)
-{
- struct amba_info *info = tty->driver_data;
-
- info->x_char = ch;
- if (ch)
- ambauart_enable_tx_interrupt(info);
-}
-
-static void ambauart_throttle(struct tty_struct *tty)
-{
- struct amba_info *info = tty->driver_data;
- unsigned long flags;
-
- if (I_IXOFF(tty))
- ambauart_send_xchar(tty, STOP_CHAR(tty));
-
- if (tty->termios->c_cflag & CRTSCTS) {
- save_flags(flags); cli();
- info->mctrl &= ~TIOCM_RTS;
- info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
- }
-}
-
-static void ambauart_unthrottle(struct tty_struct *tty)
-{
- struct amba_info *info = (struct amba_info *) tty->driver_data;
- unsigned long flags;
-
- if (I_IXOFF(tty)) {
- if (info->x_char)
- info->x_char = 0;
- else
- ambauart_send_xchar(tty, START_CHAR(tty));
- }
-
- if (tty->termios->c_cflag & CRTSCTS) {
- save_flags(flags); cli();
- info->mctrl |= TIOCM_RTS;
- info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
- }
-}
-
-static int get_serial_info(struct amba_info *info, struct serial_struct *retinfo)
-{
- struct amba_state *state = info->state;
- struct amba_port *port = info->port;
- struct serial_struct tmp;
-
- memset(&tmp, 0, sizeof(tmp));
- tmp.type = 0;
- tmp.line = state->line;
- tmp.port = port->uart_base;
- if (HIGH_BITS_OFFSET)
- tmp.port_high = port->uart_base >> HIGH_BITS_OFFSET;
- tmp.irq = port->irq;
- tmp.flags = 0;
- tmp.xmit_fifo_size = port->fifosize;
- tmp.baud_base = port->uartclk / 16;
- tmp.close_delay = state->close_delay;
- tmp.closing_wait = state->closing_wait;
- tmp.custom_divisor = state->custom_divisor;
-
- if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
- return -EFAULT;
- return 0;
-}
-
-static int set_serial_info(struct amba_info *info,
- struct serial_struct *newinfo)
-{
- struct serial_struct new_serial;
- struct amba_state *state, old_state;
- struct amba_port *port;
- unsigned long new_port;
- unsigned int i, change_irq, change_port;
- int retval = 0;
-
- if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
- return -EFAULT;
-
- state = info->state;
- old_state = *state;
- port = info->port;
-
- new_port = new_serial.port;
- if (HIGH_BITS_OFFSET)
- new_port += (unsigned long) new_serial.port_high << HIGH_BITS_OFFSET;
-
- change_irq = new_serial.irq != port->irq;
- change_port = new_port != port->uart_base;
-
- if (!capable(CAP_SYS_ADMIN)) {
- if (change_irq || change_port ||
- (new_serial.baud_base != port->uartclk / 16) ||
- (new_serial.close_delay != state->close_delay) ||
- (new_serial.xmit_fifo_size != port->fifosize) ||
- ((new_serial.flags & ~ASYNC_USR_MASK) !=
- (state->flags & ~ASYNC_USR_MASK)))
- return -EPERM;
- state->flags = ((state->flags & ~ASYNC_USR_MASK) |
- (new_serial.flags & ASYNC_USR_MASK));
- info->flags = ((info->flags & ~ASYNC_USR_MASK) |
- (new_serial.flags & ASYNC_USR_MASK));
- state->custom_divisor = new_serial.custom_divisor;
- goto check_and_exit;
- }
-
- if ((new_serial.irq >= NR_IRQS) || (new_serial.irq < 0) ||
- (new_serial.baud_base < 9600))
- return -EINVAL;
-
- if (new_serial.type && change_port) {
- for (i = 0; i < SERIAL_AMBA_NR; i++)
- if ((port != amba_ports + i) &&
- amba_ports[i].uart_base != new_port)
- return -EADDRINUSE;
- }
-
- if ((change_port || change_irq) && (state->count > 1))
- return -EBUSY;
-
- /*
- * OK, past this point, all the error checking has been done.
- * At this point, we start making changes.....
- */
- port->uartclk = new_serial.baud_base * 16;
- state->flags = ((state->flags & ~ASYNC_FLAGS) |
- (new_serial.flags & ASYNC_FLAGS));
- info->flags = ((state->flags & ~ASYNC_INTERNAL_FLAGS) |
- (info->flags & ASYNC_INTERNAL_FLAGS));
- state->custom_divisor = new_serial.custom_divisor;
- state->close_delay = new_serial.close_delay * HZ / 100;
- state->closing_wait = new_serial.closing_wait * HZ / 100;
- info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
- port->fifosize = new_serial.xmit_fifo_size;
-
- if (change_port || change_irq) {
- /*
- * We need to shutdown the serial port at the old
- * port/irq combination.
- */
- ambauart_shutdown(info);
- port->irq = new_serial.irq;
- port->uart_base = new_port;
- }
-
-check_and_exit:
- if (!port->uart_base)
- return 0;
- if (info->flags & ASYNC_INITIALIZED) {
- if ((old_state.flags & ASYNC_SPD_MASK) !=
- (state->flags & ASYNC_SPD_MASK) ||
- (old_state.custom_divisor != state->custom_divisor)) {
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
- info->tty->alt_speed = 57600;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
- info->tty->alt_speed = 115200;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
- info->tty->alt_speed = 230400;
- if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
- info->tty->alt_speed = 460800;
- ambauart_change_speed(info, NULL);
- }
- } else
- retval = ambauart_startup(info);
- return retval;
-}
-
-
-/*
- * get_lsr_info - get line status register info
- */
-static int get_lsr_info(struct amba_info *info, unsigned int *value)
-{
- unsigned int result, status;
- unsigned long flags;
-
- save_flags(flags); cli();
- status = UART_GET_FR(info->port);
- restore_flags(flags);
- result = status & AMBA_UARTFR_BUSY ? TIOCSER_TEMT : 0;
-
- /*
- * If we're about to load something into the transmit
- * register, we'll pretend the transmitter isn't empty to
- * avoid a race condition (depending on when the transmit
- * interrupt happens).
- */
- if (info->x_char ||
- ((CIRC_CNT(info->xmit.head, info->xmit.tail,
- AMBA_XMIT_SIZE) > 0) &&
- !info->tty->stopped && !info->tty->hw_stopped))
- result &= TIOCSER_TEMT;
-
- return put_user(result, value);
-}
-
-static int get_modem_info(struct amba_info *info, unsigned int *value)
-{
- unsigned int result = info->mctrl;
- unsigned int status;
-
- status = UART_GET_FR(info->port);
- if (status & AMBA_UARTFR_DCD)
- result |= TIOCM_CAR;
- if (status & AMBA_UARTFR_DSR)
- result |= TIOCM_DSR;
- if (status & AMBA_UARTFR_CTS)
- result |= TIOCM_CTS;
-
- return put_user(result, value);
-}
-
-static int set_modem_info(struct amba_info *info, unsigned int cmd,
- unsigned int *value)
-{
- unsigned int arg, old;
- unsigned long flags;
-
- if (get_user(arg, value))
- return -EFAULT;
-
- old = info->mctrl;
- switch (cmd) {
- case TIOCMBIS:
- info->mctrl |= arg;
- break;
-
- case TIOCMBIC:
- info->mctrl &= ~arg;
- break;
-
- case TIOCMSET:
- info->mctrl = arg;
- break;
-
- default:
- return -EINVAL;
- }
- save_flags(flags); cli();
- if (old != info->mctrl)
- info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
- return 0;
-}
-
-static void ambauart_break_ctl(struct tty_struct *tty, int break_state)
-{
- struct amba_info *info = tty->driver_data;
- unsigned long flags;
- unsigned int lcr_h;
-
- save_flags(flags); cli();
- lcr_h = UART_GET_LCRH(info->port);
- if (break_state == -1)
- lcr_h |= AMBA_UARTLCR_H_BRK;
- else
- lcr_h &= ~AMBA_UARTLCR_H_BRK;
- UART_PUT_LCRH(info->port, lcr_h);
- restore_flags(flags);
-}
-
-static int ambauart_ioctl(struct tty_struct *tty, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- struct amba_info *info = tty->driver_data;
- struct amba_icount cprev, cnow;
- struct serial_icounter_struct icount;
- unsigned long flags;
-
- if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
- (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
- (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
- if (tty->flags & (1 << TTY_IO_ERROR))
- return -EIO;
- }
-
- switch (cmd) {
- case TIOCMGET:
- return get_modem_info(info, (unsigned int *)arg);
- case TIOCMBIS:
- case TIOCMBIC:
- case TIOCMSET:
- return set_modem_info(info, cmd, (unsigned int *)arg);
- case TIOCGSERIAL:
- return get_serial_info(info,
- (struct serial_struct *)arg);
- case TIOCSSERIAL:
- return set_serial_info(info,
- (struct serial_struct *)arg);
- case TIOCSERGETLSR: /* Get line status register */
- return get_lsr_info(info, (unsigned int *)arg);
- /*
- * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
- * - mask passed in arg for lines of interest
- * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
- * Caller should use TIOCGICOUNT to see which one it was
- */
- case TIOCMIWAIT:
- save_flags(flags); cli();
- /* note the counters on entry */
- cprev = info->state->icount;
- /* Force modem status interrupts on */
- UART_PUT_CR(info->port, UART_GET_CR(info->port) | AMBA_UARTCR_MSIE);
- restore_flags(flags);
- while (1) {
- interruptible_sleep_on(&info->delta_msr_wait);
- /* see if a signal did it */
- if (signal_pending(current))
- return -ERESTARTSYS;
- save_flags(flags); cli();
- cnow = info->state->icount; /* atomic copy */
- restore_flags(flags);
- if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
- cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
- return -EIO; /* no change => error */
- if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
- ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
- ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
- ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
- return 0;
- }
- cprev = cnow;
- }
- /* NOTREACHED */
-
- /*
- * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
- * Return: write counters to the user passed counter struct
- * NB: both 1->0 and 0->1 transitions are counted except for
- * RI where only 0->1 is counted.
- */
- case TIOCGICOUNT:
- save_flags(flags); cli();
- cnow = info->state->icount;
- restore_flags(flags);
- icount.cts = cnow.cts;
- icount.dsr = cnow.dsr;
- icount.rng = cnow.rng;
- icount.dcd = cnow.dcd;
- icount.rx = cnow.rx;
- icount.tx = cnow.tx;
- icount.frame = cnow.frame;
- icount.overrun = cnow.overrun;
- icount.parity = cnow.parity;
- icount.brk = cnow.brk;
- icount.buf_overrun = cnow.buf_overrun;
-
- return copy_to_user((void *)arg, &icount, sizeof(icount))
- ? -EFAULT : 0;
-
- default:
- return -ENOIOCTLCMD;
- }
- return 0;
-}
-
-static void ambauart_set_termios(struct tty_struct *tty, struct termios *old_termios)
-{
- struct amba_info *info = tty->driver_data;
- unsigned long flags;
- unsigned int cflag = tty->termios->c_cflag;
-
- if ((cflag ^ old_termios->c_cflag) == 0 &&
- RELEVENT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0)
- return;
-
- ambauart_change_speed(info, old_termios);
-
- /* Handle transition to B0 status */
- if ((old_termios->c_cflag & CBAUD) &&
- !(cflag & CBAUD)) {
- save_flags(flags); cli();
- info->mctrl &= ~(TIOCM_RTS | TIOCM_DTR);
- info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
- }
-
- /* Handle transition away from B0 status */
- if (!(old_termios->c_cflag & CBAUD) &&
- (cflag & CBAUD)) {
- save_flags(flags); cli();
- info->mctrl |= TIOCM_DTR;
- if (!(cflag & CRTSCTS) ||
- !test_bit(TTY_THROTTLED, &tty->flags))
- info->mctrl |= TIOCM_RTS;
- info->port->set_mctrl(info->port, info->mctrl);
- restore_flags(flags);
- }
-
- /* Handle turning off CRTSCTS */
- if ((old_termios->c_cflag & CRTSCTS) &&
- !(cflag & CRTSCTS)) {
- tty->hw_stopped = 0;
- ambauart_start(tty);
- }
-
-#if 0
- /*
- * No need to wake up processes in open wait, since they
- * sample the CLOCAL flag once, and don't recheck it.
- * XXX It's not clear whether the current behavior is correct
- * or not. Hence, this may change.....
- */
- if (!(old_termios->c_cflag & CLOCAL) &&
- (tty->termios->c_cflag & CLOCAL))
- wake_up_interruptible(&info->open_wait);
-#endif
-}
-
-static void ambauart_close(struct tty_struct *tty, struct file *filp)
-{
- struct amba_info *info = tty->driver_data;
- struct amba_state *state;
- unsigned long flags;
-
- if (!info)
- return;
-
- state = info->state;
-
-#if DEBUG
- printk("ambauart_close() called\n");
-#endif
-
- save_flags(flags); cli();
-
- if (tty_hung_up_p(filp)) {
- MOD_DEC_USE_COUNT;
- restore_flags(flags);
- return;
- }
-
- if ((tty->count == 1) && (state->count != 1)) {
- /*
- * Uh, oh. tty->count is 1, which means that the tty
- * structure will be freed. state->count should always
- * be one in these conditions. If it's greater than
- * one, we've got real problems, since it means the
- * serial port won't be shutdown.
- */
- printk("ambauart_close: bad serial port count; tty->count is 1, "
- "state->count is %d\n", state->count);
- state->count = 1;
- }
- if (--state->count < 0) {
- printk("rs_close: bad serial port count for %s%d: %d\n",
- tty->driver.name, info->state->line, state->count);
- state->count = 0;
- }
- if (state->count) {
- MOD_DEC_USE_COUNT;
- restore_flags(flags);
- return;
- }
- info->flags |= ASYNC_CLOSING;
- restore_flags(flags);
- /*
- * Save the termios structure, since this port may have
- * separate termios for callout and dialin.
- */
- if (info->flags & ASYNC_NORMAL_ACTIVE)
- info->state->normal_termios = *tty->termios;
- if (info->flags & ASYNC_CALLOUT_ACTIVE)
- info->state->callout_termios = *tty->termios;
- /*
- * Now we wait for the transmit buffer to clear; and we notify
- * the line discipline to only process XON/XOFF characters.
- */
- tty->closing = 1;
- if (info->state->closing_wait != ASYNC_CLOSING_WAIT_NONE)
- tty_wait_until_sent(tty, info->state->closing_wait);
- /*
- * At this point, we stop accepting input. To do this, we
- * disable the receive line status interrupts.
- */
- if (info->flags & ASYNC_INITIALIZED) {
- ambauart_disable_rx_interrupt(info);
- /*
- * Before we drop DTR, make sure the UART transmitter
- * has completely drained; this is especially
- * important if there is a transmit FIFO!
- */
- ambauart_wait_until_sent(tty, info->timeout);
- }
- ambauart_shutdown(info);
- if (tty->driver.flush_buffer)
- tty->driver.flush_buffer(tty);
- if (tty->ldisc.flush_buffer)
- tty->ldisc.flush_buffer(tty);
- tty->closing = 0;
- info->event = 0;
- info->tty = NULL;
- if (info->blocked_open) {
- if (info->state->close_delay) {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(info->state->close_delay);
- }
- wake_up_interruptible(&info->open_wait);
- }
- info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE|
- ASYNC_CLOSING);
- wake_up_interruptible(&info->close_wait);
- MOD_DEC_USE_COUNT;
-}
-
-static void ambauart_wait_until_sent(struct tty_struct *tty, int timeout)
-{
- struct amba_info *info = (struct amba_info *) tty->driver_data;
- unsigned long char_time, expire;
- unsigned int status;
-
- if (info->port->fifosize == 0)
- return;
-
- /*
- * Set the check interval to be 1/5 of the estimated time to
- * send a single character, and make it at least 1. The check
- * interval should also be less than the timeout.
- *
- * Note: we have to use pretty tight timings here to satisfy
- * the NIST-PCTS.
- */
- char_time = (info->timeout - HZ/50) / info->port->fifosize;
- char_time = char_time / 5;
- if (char_time == 0)
- char_time = 1;
- if (timeout && timeout < char_time)
- char_time = timeout;
- /*
- * If the transmitter hasn't cleared in twice the approximate
- * amount of time to send the entire FIFO, it probably won't
- * ever clear. This assumes the UART isn't doing flow
- * control, which is currently the case. Hence, if it ever
- * takes longer than info->timeout, this is probably due to a
- * UART bug of some kind. So, we clamp the timeout parameter at
- * 2*info->timeout.
- */
- if (!timeout || timeout > 2 * info->timeout)
- timeout = 2 * info->timeout;
-
- expire = jiffies + timeout;
-#if DEBUG
- printk("ambauart_wait_until_sent(%d), jiff=%lu, expire=%lu...\n",
- MINOR(tty->device) - tty->driver.minor_start, jiffies,
- expire);
-#endif
- while (UART_GET_FR(info->port) & AMBA_UARTFR_BUSY) {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(char_time);
- if (signal_pending(current))
- break;
- if (timeout && time_after(jiffies, expire))
- break;
- status = UART_GET_FR(info->port);
- }
- set_current_state(TASK_RUNNING);
-}
-
-static void ambauart_hangup(struct tty_struct *tty)
-{
- struct amba_info *info = tty->driver_data;
- struct amba_state *state = info->state;
-
- ambauart_flush_buffer(tty);
- if (info->flags & ASYNC_CLOSING)
- return;
- ambauart_shutdown(info);
- info->event = 0;
- state->count = 0;
- info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE);
- info->tty = NULL;
- wake_up_interruptible(&info->open_wait);
-}
-
-static int block_til_ready(struct tty_struct *tty, struct file *filp,
- struct amba_info *info)
-{
- DECLARE_WAITQUEUE(wait, current);
- struct amba_state *state = info->state;
- unsigned long flags;
- int do_clocal = 0, extra_count = 0, retval;
-
- /*
- * If the device is in the middle of being closed, then block
- * until it's done, and then try again.
- */
- if (tty_hung_up_p(filp) ||
- (info->flags & ASYNC_CLOSING)) {
- if (info->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->close_wait);
- return (info->flags & ASYNC_HUP_NOTIFY) ?
- -EAGAIN : -ERESTARTSYS;
- }
-
- /*
- * If this is a callout device, then just make sure the normal
- * device isn't being used.
- */
- if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
- if (info->flags & ASYNC_NORMAL_ACTIVE)
- return -EBUSY;
- if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
- (info->flags & ASYNC_SESSION_LOCKOUT) &&
- (info->session != current->session))
- return -EBUSY;
- if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
- (info->flags & ASYNC_PGRP_LOCKOUT) &&
- (info->pgrp != current->pgrp))
- return -EBUSY;
- info->flags |= ASYNC_CALLOUT_ACTIVE;
- return 0;
- }
-
- /*
- * If non-blocking mode is set, or the port is not enabled,
- * then make the check up front and then exit.
- */
- if ((filp->f_flags & O_NONBLOCK) ||
- (tty->flags & (1 << TTY_IO_ERROR))) {
- if (info->flags & ASYNC_CALLOUT_ACTIVE)
- return -EBUSY;
- info->flags |= ASYNC_NORMAL_ACTIVE;
- return 0;
- }
-
- if (info->flags & ASYNC_CALLOUT_ACTIVE) {
- if (state->normal_termios.c_cflag & CLOCAL)
- do_clocal = 1;
- } else {
- if (tty->termios->c_cflag & CLOCAL)
- do_clocal = 1;
- }
-
- /*
- * Block waiting for the carrier detect and the line to become
- * free (i.e., not in use by the callout). While we are in
- * this loop, state->count is dropped by one, so that
- * rs_close() knows when to free things. We restore it upon
- * exit, either normal or abnormal.
- */
- retval = 0;
- add_wait_queue(&info->open_wait, &wait);
- save_flags(flags); cli();
- if (!tty_hung_up_p(filp)) {
- extra_count = 1;
- state->count--;
- }
- restore_flags(flags);
- info->blocked_open++;
- while (1) {
- save_flags(flags); cli();
- if (!(info->flags & ASYNC_CALLOUT_ACTIVE) &&
- (tty->termios->c_cflag & CBAUD)) {
- info->mctrl = TIOCM_DTR | TIOCM_RTS;
- info->port->set_mctrl(info->port, info->mctrl);
- }
- restore_flags(flags);
- set_current_state(TASK_INTERRUPTIBLE);
- if (tty_hung_up_p(filp) ||
- !(info->flags & ASYNC_INITIALIZED)) {
- if (info->flags & ASYNC_HUP_NOTIFY)
- retval = -EAGAIN;
- else
- retval = -ERESTARTSYS;
- break;
- }
- if (!(info->flags & ASYNC_CALLOUT_ACTIVE) &&
- !(info->flags & ASYNC_CLOSING) &&
- (do_clocal || (UART_GET_FR(info->port) & AMBA_UARTFR_DCD)))
- break;
- if (signal_pending(current)) {
- retval = -ERESTARTSYS;
- break;
- }
- schedule();
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&info->open_wait, &wait);
- if (extra_count)
- state->count++;
- info->blocked_open--;
- if (retval)
- return retval;
- info->flags |= ASYNC_NORMAL_ACTIVE;
- return 0;
-}
-
-static struct amba_info *ambauart_get(int line)
-{
- struct amba_info *info;
- struct amba_state *state = amba_state + line;
-
- state->count++;
- if (state->info)
- return state->info;
- info = kmalloc(sizeof(struct amba_info), GFP_KERNEL);
- if (info) {
- memset(info, 0, sizeof(struct amba_info));
- init_waitqueue_head(&info->open_wait);
- init_waitqueue_head(&info->close_wait);
- init_waitqueue_head(&info->delta_msr_wait);
- info->flags = state->flags;
- info->state = state;
- info->port = amba_ports + line;
- tasklet_init(&info->tlet, ambauart_tasklet_action,
- (unsigned long)info);
- }
- if (state->info) {
- kfree(info);
- return state->info;
- }
- state->info = info;
- return info;
-}
-
-static int ambauart_open(struct tty_struct *tty, struct file *filp)
-{
- struct amba_info *info;
- int retval, line = MINOR(tty->device) - tty->driver.minor_start;
-
-#if DEBUG
- printk("ambauart_open(%d) called\n", line);
-#endif
-
- // is this a line that we've got?
- MOD_INC_USE_COUNT;
- if (line >= SERIAL_AMBA_NR) {
- MOD_DEC_USE_COUNT;
- return -ENODEV;
- }
-
- info = ambauart_get(line);
- if (!info)
- return -ENOMEM;
-
- tty->driver_data = info;
- info->tty = tty;
- info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
-
- /*
- * Make sure we have the temporary buffer allocated
- */
- if (!tmp_buf) {
- unsigned long page = get_zeroed_page(GFP_KERNEL);
- if (tmp_buf)
- free_page(page);
- else if (!page) {
- MOD_DEC_USE_COUNT;
- return -ENOMEM;
- }
- tmp_buf = (u_char *)page;
- }
-
- /*
- * If the port is in the middle of closing, bail out now.
- */
- if (tty_hung_up_p(filp) ||
- (info->flags & ASYNC_CLOSING)) {
- if (info->flags & ASYNC_CLOSING)
- interruptible_sleep_on(&info->close_wait);
- MOD_DEC_USE_COUNT;
- return -EAGAIN;
- }
-
- /*
- * Start up the serial port
- */
- retval = ambauart_startup(info);
- if (retval) {
- MOD_DEC_USE_COUNT;
- return retval;
- }
-
- retval = block_til_ready(tty, filp, info);
- if (retval) {
- MOD_DEC_USE_COUNT;
- return retval;
- }
-
- if ((info->state->count == 1) &&
- (info->flags & ASYNC_SPLIT_TERMIOS)) {
- if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
- *tty->termios = info->state->normal_termios;
- else
- *tty->termios = info->state->callout_termios;
- }
-#ifdef CONFIG_SERIAL_AMBA_CONSOLE
- if (ambauart_cons.cflag && ambauart_cons.index == line) {
- tty->termios->c_cflag = ambauart_cons.cflag;
- ambauart_cons.cflag = 0;
- }
-#endif
- ambauart_change_speed(info, NULL);
- info->session = current->session;
- info->pgrp = current->pgrp;
- return 0;
-}
-
-int __init ambauart_init(void)
-{
- int i;
-
- ambanormal_driver.magic = TTY_DRIVER_MAGIC;
- ambanormal_driver.driver_name = "serial_amba";
- ambanormal_driver.name = SERIAL_AMBA_NAME;
- ambanormal_driver.major = SERIAL_AMBA_MAJOR;
- ambanormal_driver.minor_start = SERIAL_AMBA_MINOR;
- ambanormal_driver.num = SERIAL_AMBA_NR;
- ambanormal_driver.type = TTY_DRIVER_TYPE_SERIAL;
- ambanormal_driver.subtype = SERIAL_TYPE_NORMAL;
- ambanormal_driver.init_termios = tty_std_termios;
- ambanormal_driver.init_termios.c_cflag = B38400 | CS8 | CREAD | HUPCL | CLOCAL;
- ambanormal_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
- ambanormal_driver.refcount = &ambauart_refcount;
- ambanormal_driver.table = ambauart_table;
- ambanormal_driver.termios = ambauart_termios;
- ambanormal_driver.termios_locked = ambauart_termios_locked;
-
- ambanormal_driver.open = ambauart_open;
- ambanormal_driver.close = ambauart_close;
- ambanormal_driver.write = ambauart_write;
- ambanormal_driver.put_char = ambauart_put_char;
- ambanormal_driver.flush_chars = ambauart_flush_chars;
- ambanormal_driver.write_room = ambauart_write_room;
- ambanormal_driver.chars_in_buffer = ambauart_chars_in_buffer;
- ambanormal_driver.flush_buffer = ambauart_flush_buffer;
- ambanormal_driver.ioctl = ambauart_ioctl;
- ambanormal_driver.throttle = ambauart_throttle;
- ambanormal_driver.unthrottle = ambauart_unthrottle;
- ambanormal_driver.send_xchar = ambauart_send_xchar;
- ambanormal_driver.set_termios = ambauart_set_termios;
- ambanormal_driver.stop = ambauart_stop;
- ambanormal_driver.start = ambauart_start;
- ambanormal_driver.hangup = ambauart_hangup;
- ambanormal_driver.break_ctl = ambauart_break_ctl;
- ambanormal_driver.wait_until_sent = ambauart_wait_until_sent;
- ambanormal_driver.read_proc = NULL;
-
- /*
- * The callout device is just like the normal device except for
- * the major number and the subtype code.
- */
- ambacallout_driver = ambanormal_driver;
- ambacallout_driver.name = CALLOUT_AMBA_NAME;
- ambacallout_driver.major = CALLOUT_AMBA_MAJOR;
- ambacallout_driver.subtype = SERIAL_TYPE_CALLOUT;
- ambacallout_driver.read_proc = NULL;
- ambacallout_driver.proc_entry = NULL;
-
- if (tty_register_driver(&ambanormal_driver))
- panic("Couldn't register AMBA serial driver\n");
- if (tty_register_driver(&ambacallout_driver))
- panic("Couldn't register AMBA callout driver\n");
-
- for (i = 0; i < SERIAL_AMBA_NR; i++) {
- struct amba_state *state = amba_state + i;
- state->line = i;
- state->close_delay = 5 * HZ / 10;
- state->closing_wait = 30 * HZ;
- state->callout_termios = ambacallout_driver.init_termios;
- state->normal_termios = ambanormal_driver.init_termios;
- }
-
- return 0;
-}
-
-__initcall(ambauart_init);
-
-#ifdef CONFIG_SERIAL_AMBA_CONSOLE
-/************** console driver *****************/
-
-/*
- * This code is currently never used; console->read is never called.
- * Therefore, although we have an implementation, we don't use it.
- * FIXME: the "const char *s" should be fixed to "char *s" some day.
- * (when the definition in include/linux/console.h is also fixed)
- */
-#ifdef used_and_not_const_char_pointer
-static int ambauart_console_read(struct console *co, const char *s, u_int count)
-{
- struct amba_port *port = &amba_ports[co->index];
- unsigned int status;
- char *w;
- int c;
-#if DEBUG
- printk("ambauart_console_read() called\n");
-#endif
-
- c = 0;
- w = s;
- while (c < count) {
- status = UART_GET_FR(port);
- if (UART_RX_DATA(status)) {
- *w++ = UART_GET_CHAR(port);
- c++;
- } else {
- // nothing more to get, return
- return c;
- }
- }
- // return the count
- return c;
-}
-#endif
-
-/*
- * Print a string to the serial port trying not to disturb
- * any possible real use of the port...
- *
- * The console must be locked when we get here.
- */
-static void ambauart_console_write(struct console *co, const char *s, u_int count)
-{
- struct amba_port *port = &amba_ports[co->index];
- unsigned int status, old_cr;
- int i;
-
- /*
- * First save the CR then disable the interrupts
- */
- old_cr = UART_GET_CR(port);
- UART_PUT_CR(port, AMBA_UARTCR_UARTEN);
-
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++) {
- do {
- status = UART_GET_FR(port);
- } while (!UART_TX_READY(status));
- UART_PUT_CHAR(port, s[i]);
- if (s[i] == '\n') {
- do {
- status = UART_GET_FR(port);
- } while (!UART_TX_READY(status));
- UART_PUT_CHAR(port, '\r');
- }
- }
-
- /*
- * Finally, wait for transmitter to become empty
- * and restore the TCR
- */
- do {
- status = UART_GET_FR(port);
- } while (status & AMBA_UARTFR_BUSY);
- UART_PUT_CR(port, old_cr);
-}
-
-static kdev_t ambauart_console_device(struct console *c)
-{
- return MKDEV(SERIAL_AMBA_MAJOR, SERIAL_AMBA_MINOR + c->index);
-}
-
-static int __init ambauart_console_setup(struct console *co, char *options)
-{
- struct amba_port *port;
- int baud = 38400;
- int bits = 8;
- int parity = 'n';
- u_int cflag = CREAD | HUPCL | CLOCAL;
- u_int lcr_h, quot;
-
- if (co->index >= SERIAL_AMBA_NR)
- co->index = 0;
-
- port = &amba_ports[co->index];
-
- if (options) {
- char *s = options;
- baud = simple_strtoul(s, NULL, 10);
- while (*s >= '0' && *s <= '9')
- s++;
- if (*s) parity = *s++;
- if (*s) bits = *s - '0';
- }
-
- /*
- * Now construct a cflag setting.
- */
- switch (baud) {
- case 1200: cflag |= B1200; break;
- case 2400: cflag |= B2400; break;
- case 4800: cflag |= B4800; break;
- default: cflag |= B9600; baud = 9600; break;
- case 19200: cflag |= B19200; break;
- case 38400: cflag |= B38400; break;
- case 57600: cflag |= B57600; break;
- case 115200: cflag |= B115200; break;
- }
- switch (bits) {
- case 7: cflag |= CS7; lcr_h = AMBA_UARTLCR_H_WLEN_7; break;
- default: cflag |= CS8; lcr_h = AMBA_UARTLCR_H_WLEN_8; break;
- }
- switch (parity) {
- case 'o':
- case 'O': cflag |= PARODD; lcr_h |= AMBA_UARTLCR_H_PEN; break;
- case 'e':
- case 'E': cflag |= PARENB; lcr_h |= AMBA_UARTLCR_H_PEN |
- AMBA_UARTLCR_H_EPS; break;
- }
-
- co->cflag = cflag;
-
- if (port->fifosize > 1)
- lcr_h |= AMBA_UARTLCR_H_FEN;
-
- quot = (port->uartclk / (16 * baud)) - 1;
-
- UART_PUT_LCRL(port, (quot & 0xff));
- UART_PUT_LCRM(port, (quot >> 8));
- UART_PUT_LCRH(port, lcr_h);
-
- /* we will enable the port as we need it */
- UART_PUT_CR(port, 0);
-
- return 0;
-}
-
-static struct console ambauart_cons =
-{
- name: SERIAL_AMBA_NAME,
- write: ambauart_console_write,
-#ifdef used_and_not_const_char_pointer
- read: ambauart_console_read,
-#endif
- device: ambauart_console_device,
- setup: ambauart_console_setup,
- flags: CON_PRINTBUFFER,
- index: -1,
-};
-
-void __init ambauart_console_init(void)
-{
- register_console(&ambauart_cons);
-}
-
-#endif /* CONFIG_SERIAL_AMBA_CONSOLE */
-
-MODULE_LICENSE("GPL");
-EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/char/tty_io.c linux-2.4.26-vrs1/drivers/char/tty_io.c
--- linux-2.4.26/drivers/char/tty_io.c 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/tty_io.c 2004-04-18 21:47:50.000000000 +0100
@@ -19,7 +19,7 @@
* Also restructured routines so that there is more of a separation
* between the high-level tty routines (tty_io.c and tty_ioctl.c) and
* the low-level tty routines (serial.c, pty.c, console.c). This
- * makes for cleaner and more compact code. -TYT, 9/17/92
+ * makes for cleaner and more compact code. -TYT, 9/17/92
*
* Modified by Fred N. van Kempen, 01/29/93, to add line disciplines
* which can be dynamically activated and de-activated by the line
@@ -41,7 +41,7 @@
*
* New TIOCLINUX variants added.
* -- mj@k332.feld.cvut.cz, 19-Nov-95
- *
+ *
* Restrict vt switching via ioctl()
* -- grif@cs.ucr.edu, 5-Dec-95
*
@@ -151,8 +151,7 @@
extern void tty3215_init(void);
extern void tub3270_con_init(void);
extern void tub3270_init(void);
-extern void rs285_console_init(void);
-extern void sa1100_rs_console_init(void);
+extern void uart_console_init(void);
extern void sgi_serial_console_init(void);
extern void sn_sal_serial_console_init(void);
extern void sci_console_init(void);
@@ -164,6 +163,7 @@
extern void txx9_serial_console_init(void);
extern void sb1250_serial_console_init(void);
extern void arc_console_init(void);
+extern void rs285_console_init(void);
extern int hvc_console_init(void);
#ifndef MIN
@@ -201,7 +201,7 @@
else
sprintf(buf, name,
idx + tty->driver.name_base);
-
+
return buf;
}
@@ -239,7 +239,7 @@
#ifdef CHECK_TTY_COUNT
struct list_head *p;
int count = 0;
-
+
file_list_lock();
for(p = tty->tty_files.next; p != &tty->tty_files; p = p->next) {
if(list_entry(p, struct file, f_list)->private_data == tty)
@@ -255,7 +255,7 @@
"!= #fd's(%d) in %s\n",
kdevname(tty->device), tty->count, count, routine);
return count;
- }
+ }
#endif
return 0;
}
@@ -264,14 +264,14 @@
{
if (disc < N_TTY || disc >= NR_LDISCS)
return -EINVAL;
-
+
if (new_ldisc) {
ldiscs[disc] = *new_ldisc;
ldiscs[disc].flags |= LDISC_FLAG_DEFINED;
ldiscs[disc].num = disc;
} else
memset(&ldiscs[disc], 0, sizeof(struct tty_ldisc));
-
+
return 0;
}
@@ -301,7 +301,7 @@
o_ldisc = tty->ldisc;
tty_wait_until_sent(tty, 0);
-
+
/* Shutdown the current discipline. */
if (tty->ldisc.close)
(tty->ldisc.close)(tty);
@@ -339,7 +339,7 @@
{
int major, minor;
struct tty_driver *p;
-
+
minor = MINOR(device);
major = MAJOR(device);
@@ -456,7 +456,7 @@
redirect = NULL;
}
spin_unlock(&redirect_lock);
-
+
check_tty_count(tty, "do_tty_hangup");
file_list_lock();
for (l = tty->tty_files.next; l != &tty->tty_files; l = l->next) {
@@ -473,7 +473,7 @@
filp->f_op = &hung_up_tty_fops;
}
file_list_unlock();
-
+
/* FIXME! What are the locking issues here? This may me overdoing things.. */
{
unsigned long flags;
@@ -510,7 +510,7 @@
"error %d\n", -i);
}
}
-
+
read_lock(&tasklist_lock);
for_each_task(p) {
if ((tty->session > 0) && (p->session == tty->session) &&
@@ -550,7 +550,7 @@
{
#ifdef TTY_DEBUG_HANGUP
char buf[64];
-
+
printk(KERN_DEBUG "%s hangup...\n", tty_name(tty, buf));
#endif
schedule_task(&tty->tq_hangup);
@@ -650,7 +650,7 @@
wake_up_interruptible(&tty->write_wait);
}
-static ssize_t tty_read(struct file * file, char * buf, size_t count,
+static ssize_t tty_read(struct file * file, char * buf, size_t count,
loff_t *ppos)
{
int i;
@@ -707,7 +707,7 @@
size_t count)
{
ssize_t ret = 0, written = 0;
-
+
if (file->f_flags & O_NONBLOCK) {
if (down_trylock(&tty->atomic_write))
return -EAGAIN;
@@ -835,7 +835,7 @@
struct tty_struct *tty, *o_tty;
struct termios *tp, **tp_loc, *o_tp, **o_tp_loc;
struct termios *ltp, **ltp_loc, *o_ltp, **o_ltp_loc;
- struct tty_driver *driver;
+ struct tty_driver *driver;
int retval=0;
int idx;
@@ -845,7 +845,7 @@
idx = MINOR(device) - driver->minor_start;
- /*
+ /*
* Check whether we need to acquire the tty semaphore to avoid
* race conditions. For now, play it safe.
*/
@@ -859,7 +859,7 @@
* First time open is complex, especially for PTY devices.
* This code guarantees that either everything succeeds and the
* TTY is ready for operation, or else the table slots are vacated
- * and the allocated memory released. (Except that the termios
+ * and the allocated memory released. (Except that the termios
* and locked termios may be retained.)
*/
@@ -938,13 +938,13 @@
o_tty->link = tty;
}
- /*
+ /*
* All structures have been allocated, so now we install them.
- * Failures after this point use release_mem to clean up, so
+ * Failures after this point use release_mem to clean up, so
* there's no need to null out the local pointers.
*/
driver->table[idx] = tty;
-
+
if (!*tp_loc)
*tp_loc = tp;
if (!*ltp_loc)
@@ -954,7 +954,7 @@
(*driver->refcount)++;
tty->count++;
- /*
+ /*
* Structures all installed ... call the ldisc open routines.
* If we fail here just call release_mem to clean up. No need
* to decrement the use counts, as release_mem doesn't care.
@@ -988,7 +988,7 @@
if (driver->type == TTY_DRIVER_TYPE_PTY &&
driver->subtype == PTY_TYPE_MASTER) {
/*
- * special case for PTY masters: only one open permitted,
+ * special case for PTY masters: only one open permitted,
* and the slave side open count is incremented as well.
*/
if (tty->count) {
@@ -1002,7 +1002,7 @@
success:
*ret_tty = tty;
-
+
/* All paths come through here to release the semaphore */
end_init:
up_tty_sem(idx);
@@ -1080,7 +1080,7 @@
int pty_master, tty_closing, o_tty_closing, do_sleep;
int idx;
char buf[64];
-
+
tty = (struct tty_struct *)filp->private_data;
if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "release_dev"))
return;
@@ -1138,7 +1138,7 @@
idx, kdevname(tty->device));
return;
}
- if (o_tty->termios_locked !=
+ if (o_tty->termios_locked !=
tty->driver.other->termios_locked[idx]) {
printk(KERN_DEBUG "release_dev: other->termios_locked["
"%d] not o_termios_locked for (%s)\n",
@@ -1204,11 +1204,11 @@
printk(KERN_WARNING "release_dev: %s: read/write wait queue "
"active!\n", tty_name(tty, buf));
schedule();
- }
+ }
/*
- * The closing flags are now consistent with the open counts on
- * both sides, and we've completed the last operation that could
+ * The closing flags are now consistent with the open counts on
+ * both sides, and we've completed the last operation that could
* block, so it's safe to proceed with closing.
*/
if (pty_master) {
@@ -1266,7 +1266,7 @@
/* check whether both sides are closing ... */
if (!tty_closing || (o_tty && !o_tty_closing))
return;
-
+
#ifdef TTY_DEBUG_HANGUP
printk(KERN_DEBUG "freeing tty structure...");
#endif
@@ -1284,14 +1284,14 @@
(o_tty->ldisc.close)(o_tty);
o_tty->ldisc = ldiscs[N_TTY];
}
-
+
/*
- * Make sure that the tty's task queue isn't activated.
+ * Make sure that the tty's task queue isn't activated.
*/
run_task_queue(&tq_timer);
flush_scheduled_tasks();
- /*
+ /*
* The release_mem function takes care of the details of clearing
* the slots and preserving the termios structure.
*/
@@ -1482,7 +1482,7 @@
tty = (struct tty_struct *)filp->private_data;
if (tty_paranoia_check(tty, filp->f_dentry->d_inode->i_rdev, "tty_fasync"))
return 0;
-
+
retval = fasync_helper(fd, filp, on, &tty->fasync);
if (retval <= 0)
return retval;
@@ -1697,7 +1697,7 @@
static int tty_generic_brk(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
{
- if (cmd == TCSBRK && arg)
+ if (cmd == TCSBRK && arg)
{
/* tcdrain case */
int retval = tty_check_change(tty);
@@ -1718,7 +1718,7 @@
{
struct tty_struct *tty, *real_tty;
int retval;
-
+
tty = (struct tty_struct *)file->private_data;
if (tty_paranoia_check(tty, inode->i_rdev, "tty_ioctl"))
return -EINVAL;
@@ -1738,7 +1738,7 @@
if (tty->driver.ioctl)
return tty->driver.ioctl(tty, file, cmd, arg);
return -EINVAL;
-
+
/* These two ioctl's always return success; even if */
/* the driver doesn't support them. */
case TCSBRK:
@@ -1761,7 +1761,7 @@
case TIOCSBRK:
case TIOCCBRK:
case TCSBRK:
- case TCSBRKP:
+ case TCSBRKP:
retval = tty_check_change(tty);
if (retval)
return retval;
@@ -1824,7 +1824,7 @@
case TIOCSBRK: /* Turn break on, unconditionally */
tty->driver.break_ctl(tty, -1);
return 0;
-
+
case TIOCCBRK: /* Turn break off, unconditionally */
tty->driver.break_ctl(tty, 0);
return 0;
@@ -1837,7 +1837,7 @@
if (!arg)
return send_break(tty, HZ/4);
return 0;
- case TCSBRKP: /* support for POSIX tcsendbreak() */
+ case TCSBRKP: /* support for POSIX tcsendbreak() */
return send_break(tty, arg ? arg*(HZ/10) : HZ/4);
}
if (tty->driver.ioctl) {
@@ -1859,7 +1859,7 @@
* prevent trojan horses by killing all processes associated with this
* tty when the user hits the "Secure Attention Key". Required for
* super-paranoid applications --- see the Orange Book for more details.
- *
+ *
* This code could be nicer; ideally it should send a HUP, wait a few
* seconds, then send a INT, and then a KILL signal. But you then
* have to coordinate with the init process, since all processes associated
@@ -1883,7 +1883,7 @@
int session;
int i;
struct file *filp;
-
+
if (!tty)
return;
session = tty->session;
@@ -1968,7 +1968,7 @@
count = tty->flip.count;
tty->flip.count = 0;
restore_flags(flags);
-
+
tty->ldisc.receive_buf(tty, cp, fp, count);
}
@@ -2000,7 +2000,7 @@
i = cflag & CBAUD;
if (i & CBAUDEX) {
i &= ~CBAUDEX;
- if (i < 1 || i+15 >= n_baud_table)
+ if (i < 1 || i+15 >= n_baud_table)
tty->termios->c_cflag &= ~CBAUDEX;
else
i += 15;
@@ -2013,7 +2013,7 @@
}
return(tty->alt_speed);
}
-
+
return baud_table[i];
}
@@ -2079,7 +2079,7 @@
mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
break;
}
- if ( (minor < driver->minor_start) ||
+ if ( (minor < driver->minor_start) ||
(minor >= driver->minor_start + driver->num) ) {
printk(KERN_ERR "Attempt to register invalid minor number "
"with devfs (%d:%d).\n", (int)driver->major,(int)minor);
@@ -2132,12 +2132,12 @@
if (!driver->put_char)
driver->put_char = tty_default_put_char;
-
+
driver->prev = 0;
driver->next = tty_drivers;
if (tty_drivers) tty_drivers->prev = driver;
tty_drivers = driver;
-
+
if ( !(driver->flags & TTY_DRIVER_NO_DEVFS) ) {
for(i = 0; i < driver->num; i++)
tty_register_devfs(driver, 0, driver->minor_start + i);
@@ -2156,7 +2156,7 @@
int i, found = 0;
struct termios *tp;
const char *othername = NULL;
-
+
if (*driver->refcount)
return -EBUSY;
@@ -2166,7 +2166,7 @@
else if (p->major == driver->major)
othername = p->name;
}
-
+
if (!found)
return -ENOENT;
@@ -2181,7 +2181,7 @@
driver->prev->next = driver->next;
else
tty_drivers = driver->next;
-
+
if (driver->next)
driver->next->prev = driver->prev;
@@ -2221,7 +2221,7 @@
(void) tty_register_ldisc(N_TTY, &tty_ldisc_N_TTY);
/*
- * Set up the standard termios. Individual tty drivers may
+ * Set up the standard termios. Individual tty drivers may
* deviate from this; this is used as a template.
*/
memset(&tty_std_termios, 0, sizeof(struct termios));
@@ -2233,11 +2233,11 @@
ECHOCTL | ECHOKE | IEXTEN;
/*
- * set up the console device so that later boot sequences can
+ * set up the console device so that later boot sequences can
* inform about problems etc..
*/
#ifdef CONFIG_EARLY_PRINTK
- disable_early_printk();
+ disable_early_printk();
#endif
#ifdef CONFIG_HVC_CONSOLE
hvc_console_init();
@@ -2288,18 +2288,12 @@
#ifdef CONFIG_STDIO_CONSOLE
stdio_console_init();
#endif
-#ifdef CONFIG_SERIAL_21285_CONSOLE
- rs285_console_init();
-#endif
-#ifdef CONFIG_SERIAL_SA1100_CONSOLE
- sa1100_rs_console_init();
+#ifdef CONFIG_SERIAL_CORE_CONSOLE
+ uart_console_init();
#endif
#ifdef CONFIG_ARC_CONSOLE
arc_console_init();
#endif
-#ifdef CONFIG_SERIAL_AMBA_CONSOLE
- ambauart_console_init();
-#endif
#ifdef CONFIG_SERIAL_TX3912_CONSOLE
tx3912_console_init();
#endif
@@ -2315,6 +2309,9 @@
#ifdef CONFIG_IP22_SERIAL
sgi_serial_console_init();
#endif
+#ifdef CONFIG_SERIAL_21285_CONSOLE
+ rs285_console_init();
+#endif
}
static struct tty_driver dev_tty_driver, dev_syscons_driver;
@@ -2347,7 +2344,7 @@
dev_tty_driver.num = 1;
dev_tty_driver.type = TTY_DRIVER_TYPE_SYSTEM;
dev_tty_driver.subtype = SYSTEM_TYPE_TTY;
-
+
if (tty_register_driver(&dev_tty_driver))
panic("Couldn't register /dev/tty driver\n");
@@ -2363,7 +2360,7 @@
panic("Couldn't register /dev/console driver\n");
/* console calls tty_register_driver() before kmalloc() works.
- * Thus, we can't devfs_register() then. Do so now, instead.
+ * Thus, we can't devfs_register() then. Do so now, instead.
*/
#ifdef CONFIG_VT
con_init_devfs();
@@ -2381,7 +2378,7 @@
if (tty_register_driver(&dev_ptmx_driver))
panic("Couldn't register /dev/ptmx driver\n");
#endif
-
+
#ifdef CONFIG_VT
dev_console_driver = dev_tty_driver;
dev_console_driver.driver_name = "/dev/vc/0";
@@ -2441,10 +2438,10 @@
pty_init();
#ifdef CONFIG_MOXA_SMARTIO
mxser_init();
-#endif
+#endif
#ifdef CONFIG_MOXA_INTELLIO
moxa_init();
-#endif
+#endif
#ifdef CONFIG_VT
vcs_init();
#endif
diff -urN linux-2.4.26/drivers/char/wdt285.c linux-2.4.26-vrs1/drivers/char/wdt285.c
--- linux-2.4.26/drivers/char/wdt285.c 2003-06-13 15:51:33.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/char/wdt285.c 2004-01-14 21:32:25.000000000 +0000
@@ -151,7 +151,7 @@
if (get_user(new_margin, (int *)arg))
return -EFAULT;
/* Arbitrary, can't find the card's limits */
- if ((new_marg < 0) || (new_margin > 60))
+ if ((new_margin < 0) || (new_margin > 60))
return -EINVAL;
soft_margin = new_margin;
watchdog_ping();
diff -urN linux-2.4.26/drivers/char/wdt977.c linux-2.4.26-vrs1/drivers/char/wdt977.c
--- linux-2.4.26/drivers/char/wdt977.c 2002-11-28 23:53:12.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/char/wdt977.c 2004-01-14 21:32:25.000000000 +0000
@@ -27,6 +27,7 @@
#include <asm/io.h>
#include <asm/system.h>
#include <asm/mach-types.h>
+#include <asm/uaccess.h>
#define WATCHDOG_MINOR 130
diff -urN linux-2.4.26/drivers/cpufreq/Kconfig linux-2.4.26-vrs1/drivers/cpufreq/Kconfig
--- linux-2.4.26/drivers/cpufreq/Kconfig 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/cpufreq/Kconfig 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,38 @@
+config CPU_FREQ_PROC_INTF
+ tristate "/proc/cpufreq interface (deprecated)"
+ depends on CPU_FREQ && PROC_FS
+ help
+ This enables the /proc/cpufreq interface for controlling
+ CPUFreq. Please note that it is recommended to use the sysfs
+ interface instead (which is built automatically).
+
+ For details, take a look at linux/Documentation/cpufreq.
+
+ If in doubt, say N.
+
+config CPU_FREQ_GOV_USERSPACE
+ tristate "'userspace' governor for userspace frequency scaling"
+ depends on CPU_FREQ
+ help
+ Enable this cpufreq governor when you either want to set the
+ CPU frequency manually or when an userspace programm shall
+ be able to set the CPU dynamically, like on LART
+ ( http://www.lart.tudelft.nl/ )
+
+ For details, take a look at linux/Documentation/cpufreq.
+
+ If in doubt, say Y.
+
+config CPU_FREQ_24_API
+ bool "/proc/sys/cpu/ interface (2.4. / OLD)"
+ depends on CPU_FREQ && SYSCTL && CPU_FREQ_GOV_USERSPACE
+ help
+ This enables the /proc/sys/cpu/ sysctl interface for controlling
+ the CPUFreq,"userspace" governor. This is the same interface
+ as known from the.4.-kernel patches for CPUFreq, and offers
+ the same functionality as long as "userspace" is the
+ selected governor for the specified CPU.
+
+ For details, take a look at linux/Documentation/cpufreq.
+
+ If in doubt, say N.
diff -urN linux-2.4.26/drivers/cpufreq/Makefile linux-2.4.26-vrs1/drivers/cpufreq/Makefile
--- linux-2.4.26/drivers/cpufreq/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/cpufreq/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,4 @@
+#CPUfreq governors and cross-arch helpers
+obj-$(CONFIG_CPU_FREQ_TABLE) += freq_table.o
+obj-$(CONFIG_CPU_FREQ_PROC_INTF) += proc_intf.o
+obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE) += userspace.o
diff -urN linux-2.4.26/drivers/cpufreq/cpufreq.c linux-2.4.26-vrs1/drivers/cpufreq/cpufreq.c
--- linux-2.4.26/drivers/cpufreq/cpufreq.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/cpufreq/cpufreq.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,720 @@
+/*
+ * linux/kernel/cpufreq.c
+ *
+ * Copyright (C) 2001 Russell King
+ * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
+ *
+ * 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/module.h>
+#include <linux/init.h>
+#include <linux/notifier.h>
+#include <linux/cpufreq.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+
+#include <asm/semaphore.h>
+/**
+ * The "cpufreq driver" - the arch- or hardware-dependend low
+ * level driver of CPUFreq support, and its spinlock. This lock
+ * also protects the cpufreq_cpu_data array.
+ */
+static struct cpufreq_driver *cpufreq_driver;
+static struct cpufreq_policy *cpufreq_cpu_data[NR_CPUS];
+static spinlock_t cpufreq_driver_lock = SPIN_LOCK_UNLOCKED;
+
+/* internal prototype */
+static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event);
+
+
+/**
+ * Two notifier lists: the "policy" list is involved in the
+ * validation process for a new CPU frequency policy; the
+ * "transition" list for kernel code that needs to handle
+ * changes to devices when the CPU clock speed changes.
+ * The mutex locks both lists.
+ */
+static struct notifier_block *cpufreq_policy_notifier_list;
+static struct notifier_block *cpufreq_transition_notifier_list;
+static DECLARE_RWSEM (cpufreq_notifier_rwsem);
+
+
+static LIST_HEAD(cpufreq_governor_list);
+static DECLARE_MUTEX (cpufreq_governor_sem);
+
+/*
+ * backport info:
+ * we don't have a kobj we can use for ref-counting, so use a
+ * "unsigned int policy->use_count" and an "unload_sem" [idea from
+ * Pat Mochel's struct driver unload_sem] for proper reference counting.
+ */
+
+static struct cpufreq_policy * cpufreq_cpu_get(unsigned int cpu)
+{
+ struct cpufreq_policy *data;
+ unsigned long flags;
+
+ if (cpu >= NR_CPUS)
+ goto err_out;
+
+ /* get the cpufreq driver */
+ spin_lock_irqsave(&cpufreq_driver_lock, flags);
+
+ if (!cpufreq_driver)
+ goto err_out_unlock;
+
+ /* get the CPU */
+ data = cpufreq_cpu_data[cpu];
+
+ if (!data)
+ goto err_out_unlock;
+
+ if (!data->use_count)
+ goto err_out_unlock;
+
+ data->use_count += 1;
+
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
+ return data;
+
+ err_out_unlock:
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ err_out:
+ return NULL;
+}
+
+static void cpufreq_cpu_put(struct cpufreq_policy *data)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&cpufreq_driver_lock, flags);
+ data->use_count -= 1;
+ if (!data->use_count) {
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ up(&data->unload_sem);
+ return;
+ }
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+}
+
+/*********************************************************************
+ * SYSFS INTERFACE *
+ *********************************************************************/
+
+/**
+ * cpufreq_parse_governor - parse a governor string
+ */
+int cpufreq_parse_governor (char *str_governor, unsigned int *policy,
+ struct cpufreq_governor **governor)
+{
+ if (!strnicmp(str_governor, "performance", CPUFREQ_NAME_LEN)) {
+ *policy = CPUFREQ_POLICY_PERFORMANCE;
+ return 0;
+ } else if (!strnicmp(str_governor, "powersave", CPUFREQ_NAME_LEN)) {
+ *policy = CPUFREQ_POLICY_POWERSAVE;
+ return 0;
+ } else {
+ struct cpufreq_governor *t;
+ down(&cpufreq_governor_sem);
+ if (!cpufreq_driver || !cpufreq_driver->target)
+ goto out;
+ list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
+ if (!strnicmp(str_governor,t->name,CPUFREQ_NAME_LEN)) {
+ *governor = t;
+ *policy = CPUFREQ_POLICY_GOVERNOR;
+ up(&cpufreq_governor_sem);
+ return 0;
+ }
+ }
+ out:
+ up(&cpufreq_governor_sem);
+ }
+ return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(cpufreq_parse_governor);
+
+
+/* backport info:
+ * all the sysfs stuff is missing -- of course
+ */
+
+/**
+ * cpufreq_add_dev - add a CPU device
+ *
+ * Adds the cpufreq interface for a CPU device.
+ */
+static int cpufreq_add_dev (unsigned int cpu)
+{
+ int ret = 0;
+ struct cpufreq_policy new_policy;
+ struct cpufreq_policy *policy;
+ unsigned long flags;
+
+ policy = kmalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
+ if (!policy)
+ return -ENOMEM;
+ memset(policy, 0, sizeof(struct cpufreq_policy));
+
+ policy->cpu = cpu;
+ policy->use_count = 1;
+ init_MUTEX_LOCKED(&policy->lock);
+ init_MUTEX_LOCKED(&policy->unload_sem);
+
+ /* call driver. From then on the cpufreq must be able
+ * to accept all calls to ->verify and ->setpolicy for this CPU
+ */
+ ret = cpufreq_driver->init(policy);
+ if (ret)
+ goto err_out;
+
+ memcpy(&new_policy, policy, sizeof(struct cpufreq_policy));
+
+ spin_lock_irqsave(&cpufreq_driver_lock, flags);
+ cpufreq_cpu_data[cpu] = policy;
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
+ up(&policy->lock);
+
+ /* set default policy */
+ ret = cpufreq_set_policy(&new_policy);
+ if (ret)
+ goto err_out_unregister;
+
+ return 0;
+
+
+ err_out_unregister:
+ spin_lock_irqsave(&cpufreq_driver_lock, flags);
+ cpufreq_cpu_data[cpu] = NULL;
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
+ err_out:
+ kfree(policy);
+ return ret;
+}
+
+
+/**
+ * cpufreq_remove_dev - remove a CPU device
+ *
+ * Removes the cpufreq interface for a CPU device.
+ */
+static int cpufreq_remove_dev (unsigned int cpu)
+{
+ unsigned long flags;
+ struct cpufreq_policy *data;
+
+ spin_lock_irqsave(&cpufreq_driver_lock, flags);
+ data = cpufreq_cpu_data[cpu];
+ if (!data) {
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ return -EINVAL;
+ }
+ cpufreq_cpu_data[cpu] = NULL;
+
+ data->use_count -= 1;
+ if (!data->use_count) {
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ up(&data->unload_sem);
+ } else {
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ /* this will sleep until data->use_count gets to zero */
+ down(&data->unload_sem);
+ up(&data->unload_sem);
+ }
+
+ if (cpufreq_driver->target)
+ __cpufreq_governor(data, CPUFREQ_GOV_STOP);
+
+ if (cpufreq_driver->exit)
+ cpufreq_driver->exit(data);
+
+ kfree(data);
+
+ return 0;
+}
+
+
+/*********************************************************************
+ * NOTIFIER LISTS INTERFACE *
+ *********************************************************************/
+
+/**
+ * cpufreq_register_notifier - register a driver with cpufreq
+ * @nb: notifier function to register
+ * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER
+ *
+ * Add a driver to one of two lists: either a list of drivers that
+ * are notified about clock rate changes (once before and once after
+ * the transition), or a list of drivers that are notified about
+ * changes in cpufreq policy.
+ *
+ * This function may sleep, and has the same return conditions as
+ * notifier_chain_register.
+ */
+int cpufreq_register_notifier(struct notifier_block *nb, unsigned int list)
+{
+ int ret;
+
+ down_write(&cpufreq_notifier_rwsem);
+ switch (list) {
+ case CPUFREQ_TRANSITION_NOTIFIER:
+ ret = notifier_chain_register(&cpufreq_transition_notifier_list, nb);
+ break;
+ case CPUFREQ_POLICY_NOTIFIER:
+ ret = notifier_chain_register(&cpufreq_policy_notifier_list, nb);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ up_write(&cpufreq_notifier_rwsem);
+
+ return ret;
+}
+EXPORT_SYMBOL(cpufreq_register_notifier);
+
+
+/**
+ * cpufreq_unregister_notifier - unregister a driver with cpufreq
+ * @nb: notifier block to be unregistered
+ * @list: CPUFREQ_TRANSITION_NOTIFIER or CPUFREQ_POLICY_NOTIFIER
+ *
+ * Remove a driver from the CPU frequency notifier list.
+ *
+ * This function may sleep, and has the same return conditions as
+ * notifier_chain_unregister.
+ */
+int cpufreq_unregister_notifier(struct notifier_block *nb, unsigned int list)
+{
+ int ret;
+
+ down_write(&cpufreq_notifier_rwsem);
+ switch (list) {
+ case CPUFREQ_TRANSITION_NOTIFIER:
+ ret = notifier_chain_unregister(&cpufreq_transition_notifier_list, nb);
+ break;
+ case CPUFREQ_POLICY_NOTIFIER:
+ ret = notifier_chain_unregister(&cpufreq_policy_notifier_list, nb);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ up_write(&cpufreq_notifier_rwsem);
+
+ return ret;
+}
+EXPORT_SYMBOL(cpufreq_unregister_notifier);
+
+
+/*********************************************************************
+ * GOVERNORS *
+ *********************************************************************/
+
+
+int __cpufreq_driver_target(struct cpufreq_policy *policy,
+ unsigned int target_freq,
+ unsigned int relation)
+{
+ return cpufreq_driver->target(policy, target_freq, relation);
+}
+EXPORT_SYMBOL_GPL(__cpufreq_driver_target);
+
+
+int cpufreq_driver_target(struct cpufreq_policy *policy,
+ unsigned int target_freq,
+ unsigned int relation)
+{
+ unsigned int ret;
+
+ policy = cpufreq_cpu_get(policy->cpu);
+ if (!policy)
+ return -EINVAL;
+
+ down(&policy->lock);
+
+ ret = __cpufreq_driver_target(policy, target_freq, relation);
+
+ up(&policy->lock);
+
+ cpufreq_cpu_put(policy);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(cpufreq_driver_target);
+
+
+static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event)
+{
+ int ret = 0;
+
+ switch (policy->policy) {
+ case CPUFREQ_POLICY_POWERSAVE:
+ if ((event == CPUFREQ_GOV_LIMITS) || (event == CPUFREQ_GOV_START)) {
+ ret = __cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
+ }
+ break;
+ case CPUFREQ_POLICY_PERFORMANCE:
+ if ((event == CPUFREQ_GOV_LIMITS) || (event == CPUFREQ_GOV_START)) {
+ ret = __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
+ }
+ break;
+ case CPUFREQ_POLICY_GOVERNOR:
+ ret = policy->governor->governor(policy, event);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+
+ return ret;
+}
+
+
+int cpufreq_governor(unsigned int cpu, unsigned int event)
+{
+ int ret = 0;
+ struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
+
+ if (!policy)
+ return -EINVAL;
+
+ down(&policy->lock);
+ ret = __cpufreq_governor(policy, event);
+ up(&policy->lock);
+
+ cpufreq_cpu_put(policy);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(cpufreq_governor);
+
+
+int cpufreq_register_governor(struct cpufreq_governor *governor)
+{
+ struct cpufreq_governor *t;
+
+ if (!governor)
+ return -EINVAL;
+
+ if (!strnicmp(governor->name,"powersave",CPUFREQ_NAME_LEN))
+ return -EBUSY;
+ if (!strnicmp(governor->name,"performance",CPUFREQ_NAME_LEN))
+ return -EBUSY;
+
+ down(&cpufreq_governor_sem);
+
+ list_for_each_entry(t, &cpufreq_governor_list, governor_list) {
+ if (!strnicmp(governor->name,t->name,CPUFREQ_NAME_LEN)) {
+ up(&cpufreq_governor_sem);
+ return -EBUSY;
+ }
+ }
+ list_add(&governor->governor_list, &cpufreq_governor_list);
+
+ up(&cpufreq_governor_sem);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(cpufreq_register_governor);
+
+
+void cpufreq_unregister_governor(struct cpufreq_governor *governor)
+{
+ /* backport info:
+ * As the module usage count isn't assured in 2.4., check for removal
+ * of running cpufreq governor
+ */
+ unsigned int i;
+
+ if (!governor)
+ return;
+
+ down(&cpufreq_governor_sem);
+
+ for (i=0; i<NR_CPUS; i++) {
+ struct cpufreq_policy *policy = cpufreq_cpu_get(i);
+ if (!policy)
+ goto done;
+ down(&policy->lock);
+
+ if (policy->policy != CPUFREQ_POLICY_GOVERNOR)
+ goto unlock_done;
+ if (policy->governor != governor)
+ goto unlock_done;
+
+ /* stop old one, start performance [always present] */
+ __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
+ policy->policy = CPUFREQ_POLICY_PERFORMANCE;
+ __cpufreq_governor(policy, CPUFREQ_GOV_START);
+
+ unlock_done:
+ up(&policy->lock);
+ done:
+ cpufreq_cpu_put(policy);
+ }
+ list_del(&governor->governor_list);
+ up(&cpufreq_governor_sem);
+ return;
+}
+EXPORT_SYMBOL_GPL(cpufreq_unregister_governor);
+
+
+
+/*********************************************************************
+ * POLICY INTERFACE *
+ *********************************************************************/
+
+/**
+ * cpufreq_get_policy - get the current cpufreq_policy
+ * @policy: struct cpufreq_policy into which the current cpufreq_policy is written
+ *
+ * Reads the current cpufreq policy.
+ */
+int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)
+{
+ struct cpufreq_policy *cpu_policy;
+ if (!policy)
+ return -EINVAL;
+
+ cpu_policy = cpufreq_cpu_get(cpu);
+ if (!cpu_policy)
+ return -EINVAL;
+
+ down(&cpu_policy->lock);
+ memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy));
+ up(&cpu_policy->lock);
+
+ cpufreq_cpu_put(cpu_policy);
+
+ return 0;
+}
+EXPORT_SYMBOL(cpufreq_get_policy);
+
+
+/**
+ * cpufreq_set_policy - set a new CPUFreq policy
+ * @policy: policy to be set.
+ *
+ * Sets a new CPU frequency and voltage scaling policy.
+ */
+int cpufreq_set_policy(struct cpufreq_policy *policy)
+{
+ int ret = 0;
+ struct cpufreq_policy *data;
+
+ if (!policy)
+ return -EINVAL;
+
+ data = cpufreq_cpu_get(policy->cpu);
+ if (!data)
+ return -EINVAL;
+
+ /* lock this CPU */
+ down(&data->lock);
+
+ memcpy(&policy->cpuinfo,
+ &data->cpuinfo,
+ sizeof(struct cpufreq_cpuinfo));
+
+ /* verify the cpu speed can be set within this limit */
+ ret = cpufreq_driver->verify(policy);
+ if (ret)
+ goto error_out;
+
+ down_read(&cpufreq_notifier_rwsem);
+
+ /* adjust if necessary - all reasons */
+ notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_ADJUST,
+ policy);
+
+ /* adjust if necessary - hardware incompatibility*/
+ notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_INCOMPATIBLE,
+ policy);
+
+ /* verify the cpu speed can be set within this limit,
+ which might be different to the first one */
+ ret = cpufreq_driver->verify(policy);
+ if (ret) {
+ up_read(&cpufreq_notifier_rwsem);
+ goto error_out;
+ }
+
+ /* notification of the new policy */
+ notifier_call_chain(&cpufreq_policy_notifier_list, CPUFREQ_NOTIFY,
+ policy);
+
+ up_read(&cpufreq_notifier_rwsem);
+
+ data->min = policy->min;
+ data->max = policy->max;
+
+ if (cpufreq_driver->setpolicy) {
+ data->policy = policy->policy;
+ ret = cpufreq_driver->setpolicy(policy);
+ } else {
+ if ((policy->policy != data->policy) ||
+ ((policy->policy == CPUFREQ_POLICY_GOVERNOR) && (policy->governor != data->governor))) {
+ /* save old, working values */
+ unsigned int old_pol = data->policy;
+ struct cpufreq_governor *old_gov = data->governor;
+
+ /* end old governor */
+ __cpufreq_governor(data, CPUFREQ_GOV_STOP);
+
+ /* start new governor */
+ data->policy = policy->policy;
+ data->governor = policy->governor;
+ if (__cpufreq_governor(data, CPUFREQ_GOV_START)) {
+ /* new governor failed, so re-start old one */
+ data->policy = old_pol;
+ data->governor = old_gov;
+ __cpufreq_governor(data, CPUFREQ_GOV_START);
+ }
+ /* might be a policy change, too, so fall through */
+ }
+ __cpufreq_governor(data, CPUFREQ_GOV_LIMITS);
+ }
+
+ error_out:
+ up(&data->lock);
+ cpufreq_cpu_put(data);
+
+ return ret;
+}
+EXPORT_SYMBOL(cpufreq_set_policy);
+
+
+
+/*********************************************************************
+ * EXTERNALLY AFFECTING FREQUENCY CHANGES *
+ *********************************************************************/
+
+/**
+ * adjust_jiffies - adjust the system "loops_per_jiffy"
+ *
+ * This function alters the system "loops_per_jiffy" for the clock
+ * speed change. Note that loops_per_jiffy cannot be updated on SMP
+ * systems as each CPU might be scaled differently. So, use the arch
+ * per-CPU loops_per_jiffy value wherever possible.
+ */
+#ifndef CONFIG_SMP
+static unsigned long l_p_j_ref = 0;
+static unsigned int l_p_j_ref_freq = 0;
+
+static inline void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
+{
+ if (!l_p_j_ref_freq) {
+ l_p_j_ref = loops_per_jiffy;
+ l_p_j_ref_freq = ci->old;
+ }
+ if ((val == CPUFREQ_PRECHANGE && ci->old < ci->new) ||
+ (val == CPUFREQ_POSTCHANGE && ci->old > ci->new))
+ loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq, ci->new);
+}
+#else
+#define adjust_jiffies(x...) do {} while (0)
+#endif
+
+
+/**
+ * cpufreq_notify_transition - call notifier chain and adjust_jiffies on frequency transition
+ *
+ * This function calls the transition notifiers and the "adjust_jiffies" function. It is called
+ * twice on all CPU frequency changes that have external effects.
+ */
+void cpufreq_notify_transition(struct cpufreq_freqs *freqs, unsigned int state)
+{
+ down_read(&cpufreq_notifier_rwsem);
+ switch (state) {
+ case CPUFREQ_PRECHANGE:
+ notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_PRECHANGE, freqs);
+ adjust_jiffies(CPUFREQ_PRECHANGE, freqs);
+ break;
+ case CPUFREQ_POSTCHANGE:
+ adjust_jiffies(CPUFREQ_POSTCHANGE, freqs);
+ notifier_call_chain(&cpufreq_transition_notifier_list, CPUFREQ_POSTCHANGE, freqs);
+ cpufreq_cpu_data[freqs->cpu]->cur = freqs->new;
+ break;
+ }
+ up_read(&cpufreq_notifier_rwsem);
+}
+EXPORT_SYMBOL_GPL(cpufreq_notify_transition);
+
+
+
+/*********************************************************************
+ * REGISTER / UNREGISTER CPUFREQ DRIVER *
+ *********************************************************************/
+
+/**
+ * cpufreq_register_driver - register a CPU Frequency driver
+ * @driver_data: A struct cpufreq_driver containing the values#
+ * submitted by the CPU Frequency driver.
+ *
+ * Registers a CPU Frequency driver to this core code. This code
+ * returns zero on success, -EBUSY when another driver got here first
+ * (and isn't unregistered in the meantime).
+ *
+ */
+int cpufreq_register_driver(struct cpufreq_driver *driver_data)
+{
+ unsigned long flags;
+ unsigned int i;
+
+ if (!driver_data || !driver_data->verify || !driver_data->init ||
+ ((!driver_data->setpolicy) && (!driver_data->target)))
+ return -EINVAL;
+
+ spin_lock_irqsave(&cpufreq_driver_lock, flags);
+ if (cpufreq_driver) {
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+ return -EBUSY;
+ }
+ cpufreq_driver = driver_data;
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
+ for (i=0; i<NR_CPUS; i++) {
+ if (cpu_online(i))
+ cpufreq_add_dev(i);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(cpufreq_register_driver);
+
+
+/**
+ * cpufreq_unregister_driver - unregister the current CPUFreq driver
+ *
+ * Unregister the current CPUFreq driver. Only call this if you have
+ * the right to do so, i.e. if you have succeeded in initialising before!
+ * Returns zero if successful, and -EINVAL if the cpufreq_driver is
+ * currently not initialised.
+ */
+int cpufreq_unregister_driver(struct cpufreq_driver *driver)
+{
+ unsigned long flags;
+ unsigned int i;
+
+ if (!cpufreq_driver || (driver != cpufreq_driver))
+ return -EINVAL;
+
+ for (i=0; i<NR_CPUS; i++) {
+ if (cpu_online(i))
+ cpufreq_remove_dev(i);
+ }
+
+ spin_lock_irqsave(&cpufreq_driver_lock, flags);
+ cpufreq_driver = NULL;
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(cpufreq_unregister_driver);
diff -urN linux-2.4.26/drivers/cpufreq/freq_table.c linux-2.4.26-vrs1/drivers/cpufreq/freq_table.c
--- linux-2.4.26/drivers/cpufreq/freq_table.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/cpufreq/freq_table.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,203 @@
+/*
+ * linux/drivers/cpufreq/freq_table.c
+ *
+ * Copyright (C) 2002 - 2003 Dominik Brodowski
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/cpufreq.h>
+
+/*********************************************************************
+ * FREQUENCY TABLE HELPERS *
+ *********************************************************************/
+
+int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table)
+{
+ unsigned int min_freq = ~0;
+ unsigned int max_freq = 0;
+ unsigned int i = 0;
+
+ for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
+ unsigned int freq = table[i].frequency;
+ if (freq == CPUFREQ_ENTRY_INVALID)
+ continue;
+ if (freq < min_freq)
+ min_freq = freq;
+ if (freq > max_freq)
+ max_freq = freq;
+ }
+
+ policy->min = policy->cpuinfo.min_freq = min_freq;
+ policy->max = policy->cpuinfo.max_freq = max_freq;
+
+ if (policy->min == ~0)
+ return -EINVAL;
+ else
+ return 0;
+}
+EXPORT_SYMBOL_GPL(cpufreq_frequency_table_cpuinfo);
+
+
+int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table)
+{
+ unsigned int next_larger = ~0;
+ unsigned int i = 0;
+ unsigned int count = 0;
+
+ if (!cpu_online(policy->cpu))
+ return -EINVAL;
+
+ cpufreq_verify_within_limits(policy,
+ policy->cpuinfo.min_freq,
+ policy->cpuinfo.max_freq);
+
+ for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
+ unsigned int freq = table[i].frequency;
+ if (freq == CPUFREQ_ENTRY_INVALID)
+ continue;
+ if ((freq >= policy->min) && (freq <= policy->max))
+ count++;
+ else if ((next_larger > freq) && (freq > policy->max))
+ next_larger = freq;
+ }
+
+ if (!count)
+ policy->max = next_larger;
+
+ cpufreq_verify_within_limits(policy,
+ policy->cpuinfo.min_freq,
+ policy->cpuinfo.max_freq);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(cpufreq_frequency_table_verify);
+
+
+int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
+ struct cpufreq_frequency_table *table,
+ unsigned int target_freq,
+ unsigned int relation,
+ unsigned int *index)
+{
+ struct cpufreq_frequency_table optimal = { .index = ~0, };
+ struct cpufreq_frequency_table suboptimal = { .index = ~0, };
+ unsigned int i;
+
+ switch (relation) {
+ case CPUFREQ_RELATION_H:
+ optimal.frequency = 0;
+ suboptimal.frequency = ~0;
+ break;
+ case CPUFREQ_RELATION_L:
+ optimal.frequency = ~0;
+ suboptimal.frequency = 0;
+ break;
+ }
+
+ if (!cpu_online(policy->cpu))
+ return -EINVAL;
+
+ for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
+ unsigned int freq = table[i].frequency;
+ if (freq == CPUFREQ_ENTRY_INVALID)
+ continue;
+ if ((freq < policy->min) || (freq > policy->max))
+ continue;
+ switch(relation) {
+ case CPUFREQ_RELATION_H:
+ if (freq <= target_freq) {
+ if (freq >= optimal.frequency) {
+ optimal.frequency = freq;
+ optimal.index = i;
+ }
+ } else {
+ if (freq <= suboptimal.frequency) {
+ suboptimal.frequency = freq;
+ suboptimal.index = i;
+ }
+ }
+ break;
+ case CPUFREQ_RELATION_L:
+ if (freq >= target_freq) {
+ if (freq <= optimal.frequency) {
+ optimal.frequency = freq;
+ optimal.index = i;
+ }
+ } else {
+ if (freq >= suboptimal.frequency) {
+ suboptimal.frequency = freq;
+ suboptimal.index = i;
+ }
+ }
+ break;
+ }
+ }
+ if (optimal.index > i) {
+ if (suboptimal.index > i)
+ return -EINVAL;
+ *index = suboptimal.index;
+ } else
+ *index = optimal.index;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(cpufreq_frequency_table_target);
+
+static struct cpufreq_frequency_table *show_table[NR_CPUS];
+/**
+ * show_scaling_governor - show the current policy for the specified CPU
+ */
+static ssize_t show_available_freqs (struct cpufreq_policy *policy, char *buf)
+{
+ unsigned int i = 0;
+ unsigned int cpu = policy->cpu;
+ ssize_t count = 0;
+ struct cpufreq_frequency_table *table;
+
+ if (!show_table[cpu])
+ return -ENODEV;
+
+ table = show_table[cpu];
+
+ for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
+ if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
+ continue;
+ count += sprintf(&buf[count], "%d ", table[i].frequency);
+ }
+ count += sprintf(&buf[count], "\n");
+
+ return count;
+
+}
+
+struct freq_attr cpufreq_freq_attr_scaling_available_freqs = {
+ .attr = { .name = "scaling_available_frequencies", .mode = 0444 },
+ .show = show_available_freqs,
+};
+EXPORT_SYMBOL_GPL(cpufreq_freq_attr_scaling_available_freqs);
+
+/*
+ * if you use these, you must assure that the frequency table is valid
+ * all the time between get_attr and put_attr!
+ */
+void cpufreq_frequency_table_get_attr(struct cpufreq_frequency_table *table,
+ unsigned int cpu)
+{
+ show_table[cpu] = table;
+}
+EXPORT_SYMBOL_GPL(cpufreq_frequency_table_get_attr);
+
+void cpufreq_frequency_table_put_attr(unsigned int cpu)
+{
+ show_table[cpu] = NULL;
+}
+EXPORT_SYMBOL_GPL(cpufreq_frequency_table_put_attr);
+
+
+MODULE_AUTHOR ("Dominik Brodowski <linux@brodo.de>");
+MODULE_DESCRIPTION ("CPUfreq frequency table helpers");
+MODULE_LICENSE ("GPL");
diff -urN linux-2.4.26/drivers/cpufreq/proc_intf.c linux-2.4.26-vrs1/drivers/cpufreq/proc_intf.c
--- linux-2.4.26/drivers/cpufreq/proc_intf.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/cpufreq/proc_intf.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,244 @@
+/*
+ * linux/drivers/cpufreq/proc_intf.c
+ *
+ * Copyright (C) 2002 - 2003 Dominik Brodowski
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/cpufreq.h>
+#include <linux/ctype.h>
+#include <linux/proc_fs.h>
+#include <asm/uaccess.h>
+
+
+/**
+ * cpufreq_parse_policy - parse a policy string
+ * @input_string: the string to parse.
+ * @policy: the policy written inside input_string
+ *
+ * This function parses a "policy string" - something the user echo'es into
+ * /proc/cpufreq or gives as boot parameter - into a struct cpufreq_policy.
+ * If there are invalid/missing entries, they are replaced with current
+ * cpufreq policy.
+ */
+static int cpufreq_parse_policy(char input_string[42], struct cpufreq_policy *policy)
+{
+ unsigned int min = 0;
+ unsigned int max = 0;
+ unsigned int cpu = 0;
+ char str_governor[16];
+ struct cpufreq_policy current_policy;
+ unsigned int result = -EFAULT;
+
+ if (!policy)
+ return -EINVAL;
+
+ policy->min = 0;
+ policy->max = 0;
+ policy->policy = 0;
+ policy->cpu = CPUFREQ_ALL_CPUS;
+
+ if (sscanf(input_string, "%d:%d:%d:%15s", &cpu, &min, &max, str_governor) == 4)
+ {
+ policy->min = min;
+ policy->max = max;
+ policy->cpu = cpu;
+ result = 0;
+ goto scan_policy;
+ }
+ if (sscanf(input_string, "%d%%%d%%%d%%%15s", &cpu, &min, &max, str_governor) == 4)
+ {
+ if (!cpufreq_get_policy(¤t_policy, cpu)) {
+ policy->min = (min * current_policy.cpuinfo.max_freq) / 100;
+ policy->max = (max * current_policy.cpuinfo.max_freq) / 100;
+ policy->cpu = cpu;
+ result = 0;
+ goto scan_policy;
+ }
+ }
+
+ if (sscanf(input_string, "%d:%d:%15s", &min, &max, str_governor) == 3)
+ {
+ policy->min = min;
+ policy->max = max;
+ result = 0;
+ goto scan_policy;
+ }
+
+ if (sscanf(input_string, "%d%%%d%%%15s", &min, &max, str_governor) == 3)
+ {
+ if (!cpufreq_get_policy(¤t_policy, cpu)) {
+ policy->min = (min * current_policy.cpuinfo.max_freq) / 100;
+ policy->max = (max * current_policy.cpuinfo.max_freq) / 100;
+ result = 0;
+ goto scan_policy;
+ }
+ }
+
+ return -EINVAL;
+
+scan_policy:
+ result = cpufreq_parse_governor(str_governor, &policy->policy, &policy->governor);
+
+ return result;
+}
+
+/**
+ * cpufreq_proc_read - read /proc/cpufreq
+ *
+ * This function prints out the current cpufreq policy.
+ */
+static int cpufreq_proc_read (
+ char *page,
+ char **start,
+ off_t off,
+ int count,
+ int *eof,
+ void *data)
+{
+ char *p = page;
+ int len = 0;
+ struct cpufreq_policy policy;
+ unsigned int min_pctg = 0;
+ unsigned int max_pctg = 0;
+ unsigned int i = 0;
+
+ if (off != 0)
+ goto end;
+
+ p += sprintf(p, " minimum CPU frequency - maximum CPU frequency - policy\n");
+ for (i=0;i<NR_CPUS;i++) {
+ if (!cpu_online(i))
+ continue;
+
+ if (cpufreq_get_policy(&policy, i))
+ continue;
+
+ if (!policy.cpuinfo.max_freq)
+ continue;
+
+ min_pctg = (policy.min * 100) / policy.cpuinfo.max_freq;
+ max_pctg = (policy.max * 100) / policy.cpuinfo.max_freq;
+
+ p += sprintf(p, "CPU%3d %9d kHz (%3d %%) - %9d kHz (%3d %%) - ",
+ i , policy.min, min_pctg, policy.max, max_pctg);
+ switch (policy.policy) {
+ case CPUFREQ_POLICY_POWERSAVE:
+ p += sprintf(p, "powersave\n");
+ break;
+ case CPUFREQ_POLICY_PERFORMANCE:
+ p += sprintf(p, "performance\n");
+ break;
+ case CPUFREQ_POLICY_GOVERNOR:
+ p += snprintf(p, CPUFREQ_NAME_LEN, "%s\n", policy.governor->name);
+ break;
+ default:
+ p += sprintf(p, "INVALID\n");
+ break;
+ }
+ }
+end:
+ len = (p - page);
+ if (len <= off+count)
+ *eof = 1;
+ *start = page + off;
+ len -= off;
+ if (len>count)
+ len = count;
+ if (len<0)
+ len = 0;
+
+ return len;
+}
+
+
+/**
+ * cpufreq_proc_write - handles writing into /proc/cpufreq
+ *
+ * This function calls the parsing script and then sets the policy
+ * accordingly.
+ */
+static int cpufreq_proc_write (
+ struct file *file,
+ const char *buffer,
+ unsigned long count,
+ void *data)
+{
+ int result = 0;
+ char proc_string[42] = {'\0'};
+ struct cpufreq_policy policy;
+ unsigned int i = 0;
+
+
+ if ((count > sizeof(proc_string) - 1))
+ return -EINVAL;
+
+ if (copy_from_user(proc_string, buffer, count))
+ return -EFAULT;
+
+ proc_string[count] = '\0';
+
+ result = cpufreq_parse_policy(proc_string, &policy);
+ if (result)
+ return -EFAULT;
+
+ if (policy.cpu == CPUFREQ_ALL_CPUS)
+ {
+ for (i=0; i<NR_CPUS; i++)
+ {
+ policy.cpu = i;
+ if (cpu_online(i))
+ cpufreq_set_policy(&policy);
+ }
+ }
+ else
+ cpufreq_set_policy(&policy);
+
+ return count;
+}
+
+
+/**
+ * cpufreq_proc_init - add "cpufreq" to the /proc root directory
+ *
+ * This function adds "cpufreq" to the /proc root directory.
+ */
+static int __init cpufreq_proc_init (void)
+{
+ struct proc_dir_entry *entry = NULL;
+
+ /* are these acceptable values? */
+ entry = create_proc_entry("cpufreq", S_IFREG|S_IRUGO|S_IWUSR,
+ &proc_root);
+
+ if (!entry) {
+ printk(KERN_ERR "unable to create /proc/cpufreq entry\n");
+ return -EIO;
+ } else {
+ entry->read_proc = cpufreq_proc_read;
+ entry->write_proc = cpufreq_proc_write;
+ }
+
+ return 0;
+}
+
+
+/**
+ * cpufreq_proc_exit - removes "cpufreq" from the /proc root directory.
+ *
+ * This function removes "cpufreq" from the /proc root directory.
+ */
+static void __exit cpufreq_proc_exit (void)
+{
+ remove_proc_entry("cpufreq", &proc_root);
+ return;
+}
+
+MODULE_AUTHOR ("Dominik Brodowski <linux@brodo.de>");
+MODULE_DESCRIPTION ("CPUfreq /proc/cpufreq interface");
+MODULE_LICENSE ("GPL");
+
+module_init(cpufreq_proc_init);
+module_exit(cpufreq_proc_exit);
diff -urN linux-2.4.26/drivers/cpufreq/userspace.c linux-2.4.26-vrs1/drivers/cpufreq/userspace.c
--- linux-2.4.26/drivers/cpufreq/userspace.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/cpufreq/userspace.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,591 @@
+/*
+ * drivers/cpufreq/userspace.c
+ *
+ * Copyright (C) 2001 Russell King
+ * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
+ *
+ * $Id: userspace.c,v 1.4 2003/03/07 10:30:20 db Exp $
+ *
+ * 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/module.h>
+#include <linux/smp.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/interrupt.h>
+#include <linux/ctype.h>
+#include <linux/cpufreq.h>
+#include <linux/sysctl.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/sysfs.h>
+
+#include <asm/uaccess.h>
+
+#define CTL_CPU_VARS_SPEED_MAX(cpunr) { \
+ .ctl_name = CPU_NR_FREQ_MAX, \
+ .data = &cpu_max_freq[cpunr], \
+ .procname = "speed-max", \
+ .maxlen = sizeof(cpu_max_freq[cpunr]),\
+ .mode = 0444, \
+ .proc_handler = proc_dointvec, }
+
+#define CTL_CPU_VARS_SPEED_MIN(cpunr) { \
+ .ctl_name = CPU_NR_FREQ_MIN, \
+ .data = &cpu_min_freq[cpunr], \
+ .procname = "speed-min", \
+ .maxlen = sizeof(cpu_min_freq[cpunr]),\
+ .mode = 0444, \
+ .proc_handler = proc_dointvec, }
+
+#define CTL_CPU_VARS_SPEED(cpunr) { \
+ .ctl_name = CPU_NR_FREQ, \
+ .procname = "speed", \
+ .mode = 0644, \
+ .proc_handler = cpufreq_procctl, \
+ .strategy = cpufreq_sysctl, \
+ .extra1 = (void*) (cpunr), }
+
+#define CTL_TABLE_CPU_VARS(cpunr) static ctl_table ctl_cpu_vars_##cpunr[] = {\
+ CTL_CPU_VARS_SPEED_MAX(cpunr), \
+ CTL_CPU_VARS_SPEED_MIN(cpunr), \
+ CTL_CPU_VARS_SPEED(cpunr), \
+ { .ctl_name = 0, }, }
+
+/* the ctl_table entry for each CPU */
+#define CPU_ENUM(s) { \
+ .ctl_name = (CPU_NR + s), \
+ .procname = #s, \
+ .mode = 0555, \
+ .child = ctl_cpu_vars_##s }
+
+/**
+ * A few values needed by the userspace governor
+ */
+static unsigned int cpu_max_freq[NR_CPUS];
+static unsigned int cpu_min_freq[NR_CPUS];
+static unsigned int cpu_cur_freq[NR_CPUS];
+static unsigned int cpu_is_managed[NR_CPUS];
+static struct cpufreq_policy current_policy[NR_CPUS];
+
+static DECLARE_MUTEX (userspace_sem);
+
+
+/* keep track of frequency transitions */
+static int
+userspace_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
+ void *data)
+{
+ struct cpufreq_freqs *freq = data;
+
+ cpu_cur_freq[freq->cpu] = freq->new;
+
+ return 0;
+}
+
+static struct notifier_block userspace_cpufreq_notifier_block = {
+ .notifier_call = userspace_cpufreq_notifier
+};
+
+
+/**
+ * cpufreq_set - set the CPU frequency
+ * @freq: target frequency in kHz
+ * @cpu: CPU for which the frequency is to be set
+ *
+ * Sets the CPU frequency to freq.
+ */
+int cpufreq_set(unsigned int freq, unsigned int cpu)
+{
+ int ret = -EINVAL;
+
+ down(&userspace_sem);
+ if (!cpu_is_managed[cpu])
+ goto err;
+
+ if (freq < cpu_min_freq[cpu])
+ freq = cpu_min_freq[cpu];
+ if (freq > cpu_max_freq[cpu])
+ freq = cpu_max_freq[cpu];
+
+ ret = cpufreq_driver_target(¤t_policy[cpu], freq,
+ CPUFREQ_RELATION_L);
+
+ err:
+ up(&userspace_sem);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(cpufreq_set);
+
+
+/**
+ * cpufreq_setmax - set the CPU to the maximum frequency
+ * @cpu - affected cpu;
+ *
+ * Sets the CPU frequency to the maximum frequency supported by
+ * this CPU.
+ */
+int cpufreq_setmax(unsigned int cpu)
+{
+ if (!cpu_is_managed[cpu] || !cpu_online(cpu))
+ return -EINVAL;
+ return cpufreq_set(cpu_max_freq[cpu], cpu);
+}
+EXPORT_SYMBOL_GPL(cpufreq_setmax);
+
+
+/**
+ * cpufreq_get - get the current CPU frequency (in kHz)
+ * @cpu: CPU number
+ *
+ * Get the CPU current (static) CPU frequency
+ */
+unsigned int cpufreq_get(unsigned int cpu)
+{
+ return cpu_cur_freq[cpu];
+}
+EXPORT_SYMBOL(cpufreq_get);
+
+
+#ifdef CONFIG_CPU_FREQ_24_API
+
+
+/*********************** cpufreq_sysctl interface ********************/
+static int
+cpufreq_procctl(ctl_table *ctl, int write, struct file *filp,
+ void *buffer, size_t *lenp)
+{
+ char buf[16], *p;
+ int cpu = (int) ctl->extra1;
+ int len, left = *lenp;
+
+ if (!left || (filp->f_pos && !write) || !cpu_online(cpu)) {
+ *lenp = 0;
+ return 0;
+ }
+
+ if (write) {
+ unsigned int freq;
+
+ len = left;
+ if (left > sizeof(buf))
+ left = sizeof(buf);
+ if (copy_from_user(buf, buffer, left))
+ return -EFAULT;
+ buf[sizeof(buf) - 1] = '\0';
+
+ freq = simple_strtoul(buf, &p, 0);
+ cpufreq_set(freq, cpu);
+ } else {
+ len = sprintf(buf, "%d\n", cpufreq_get(cpu));
+ if (len > left)
+ len = left;
+ if (copy_to_user(buffer, buf, len))
+ return -EFAULT;
+ }
+
+ *lenp = len;
+ filp->f_pos += len;
+ return 0;
+}
+
+static int
+cpufreq_sysctl(ctl_table *table, int *name, int nlen,
+ void *oldval, size_t *oldlenp,
+ void *newval, size_t newlen, void **context)
+{
+ int cpu = (int) table->extra1;
+
+ if (!cpu_online(cpu))
+ return -EINVAL;
+
+ if (oldval && oldlenp) {
+ size_t oldlen;
+
+ if (get_user(oldlen, oldlenp))
+ return -EFAULT;
+
+ if (oldlen != sizeof(unsigned int))
+ return -EINVAL;
+
+ if (put_user(cpufreq_get(cpu), (unsigned int *)oldval) ||
+ put_user(sizeof(unsigned int), oldlenp))
+ return -EFAULT;
+ }
+ if (newval && newlen) {
+ unsigned int freq;
+
+ if (newlen != sizeof(unsigned int))
+ return -EINVAL;
+
+ if (get_user(freq, (unsigned int *)newval))
+ return -EFAULT;
+
+ cpufreq_set(freq, cpu);
+ }
+ return 1;
+}
+
+/* ctl_table ctl_cpu_vars_{0,1,...,(NR_CPUS-1)} */
+/* due to NR_CPUS tweaking, a lot of if/endifs are required, sorry */
+ CTL_TABLE_CPU_VARS(0);
+#if NR_CPUS > 1
+ CTL_TABLE_CPU_VARS(1);
+#endif
+#if NR_CPUS > 2
+ CTL_TABLE_CPU_VARS(2);
+#endif
+#if NR_CPUS > 3
+ CTL_TABLE_CPU_VARS(3);
+#endif
+#if NR_CPUS > 4
+ CTL_TABLE_CPU_VARS(4);
+#endif
+#if NR_CPUS > 5
+ CTL_TABLE_CPU_VARS(5);
+#endif
+#if NR_CPUS > 6
+ CTL_TABLE_CPU_VARS(6);
+#endif
+#if NR_CPUS > 7
+ CTL_TABLE_CPU_VARS(7);
+#endif
+#if NR_CPUS > 8
+ CTL_TABLE_CPU_VARS(8);
+#endif
+#if NR_CPUS > 9
+ CTL_TABLE_CPU_VARS(9);
+#endif
+#if NR_CPUS > 10
+ CTL_TABLE_CPU_VARS(10);
+#endif
+#if NR_CPUS > 11
+ CTL_TABLE_CPU_VARS(11);
+#endif
+#if NR_CPUS > 12
+ CTL_TABLE_CPU_VARS(12);
+#endif
+#if NR_CPUS > 13
+ CTL_TABLE_CPU_VARS(13);
+#endif
+#if NR_CPUS > 14
+ CTL_TABLE_CPU_VARS(14);
+#endif
+#if NR_CPUS > 15
+ CTL_TABLE_CPU_VARS(15);
+#endif
+#if NR_CPUS > 16
+ CTL_TABLE_CPU_VARS(16);
+#endif
+#if NR_CPUS > 17
+ CTL_TABLE_CPU_VARS(17);
+#endif
+#if NR_CPUS > 18
+ CTL_TABLE_CPU_VARS(18);
+#endif
+#if NR_CPUS > 19
+ CTL_TABLE_CPU_VARS(19);
+#endif
+#if NR_CPUS > 20
+ CTL_TABLE_CPU_VARS(20);
+#endif
+#if NR_CPUS > 21
+ CTL_TABLE_CPU_VARS(21);
+#endif
+#if NR_CPUS > 22
+ CTL_TABLE_CPU_VARS(22);
+#endif
+#if NR_CPUS > 23
+ CTL_TABLE_CPU_VARS(23);
+#endif
+#if NR_CPUS > 24
+ CTL_TABLE_CPU_VARS(24);
+#endif
+#if NR_CPUS > 25
+ CTL_TABLE_CPU_VARS(25);
+#endif
+#if NR_CPUS > 26
+ CTL_TABLE_CPU_VARS(26);
+#endif
+#if NR_CPUS > 27
+ CTL_TABLE_CPU_VARS(27);
+#endif
+#if NR_CPUS > 28
+ CTL_TABLE_CPU_VARS(28);
+#endif
+#if NR_CPUS > 29
+ CTL_TABLE_CPU_VARS(29);
+#endif
+#if NR_CPUS > 30
+ CTL_TABLE_CPU_VARS(30);
+#endif
+#if NR_CPUS > 31
+ CTL_TABLE_CPU_VARS(31);
+#endif
+#if NR_CPUS > 32
+#error please extend CPU enumeration
+#endif
+
+/* due to NR_CPUS tweaking, a lot of if/endifs are required, sorry */
+static ctl_table ctl_cpu_table[NR_CPUS + 1] = {
+ CPU_ENUM(0),
+#if NR_CPUS > 1
+ CPU_ENUM(1),
+#endif
+#if NR_CPUS > 2
+ CPU_ENUM(2),
+#endif
+#if NR_CPUS > 3
+ CPU_ENUM(3),
+#endif
+#if NR_CPUS > 4
+ CPU_ENUM(4),
+#endif
+#if NR_CPUS > 5
+ CPU_ENUM(5),
+#endif
+#if NR_CPUS > 6
+ CPU_ENUM(6),
+#endif
+#if NR_CPUS > 7
+ CPU_ENUM(7),
+#endif
+#if NR_CPUS > 8
+ CPU_ENUM(8),
+#endif
+#if NR_CPUS > 9
+ CPU_ENUM(9),
+#endif
+#if NR_CPUS > 10
+ CPU_ENUM(10),
+#endif
+#if NR_CPUS > 11
+ CPU_ENUM(11),
+#endif
+#if NR_CPUS > 12
+ CPU_ENUM(12),
+#endif
+#if NR_CPUS > 13
+ CPU_ENUM(13),
+#endif
+#if NR_CPUS > 14
+ CPU_ENUM(14),
+#endif
+#if NR_CPUS > 15
+ CPU_ENUM(15),
+#endif
+#if NR_CPUS > 16
+ CPU_ENUM(16),
+#endif
+#if NR_CPUS > 17
+ CPU_ENUM(17),
+#endif
+#if NR_CPUS > 18
+ CPU_ENUM(18),
+#endif
+#if NR_CPUS > 19
+ CPU_ENUM(19),
+#endif
+#if NR_CPUS > 20
+ CPU_ENUM(20),
+#endif
+#if NR_CPUS > 21
+ CPU_ENUM(21),
+#endif
+#if NR_CPUS > 22
+ CPU_ENUM(22),
+#endif
+#if NR_CPUS > 23
+ CPU_ENUM(23),
+#endif
+#if NR_CPUS > 24
+ CPU_ENUM(24),
+#endif
+#if NR_CPUS > 25
+ CPU_ENUM(25),
+#endif
+#if NR_CPUS > 26
+ CPU_ENUM(26),
+#endif
+#if NR_CPUS > 27
+ CPU_ENUM(27),
+#endif
+#if NR_CPUS > 28
+ CPU_ENUM(28),
+#endif
+#if NR_CPUS > 29
+ CPU_ENUM(29),
+#endif
+#if NR_CPUS > 30
+ CPU_ENUM(30),
+#endif
+#if NR_CPUS > 31
+ CPU_ENUM(31),
+#endif
+#if NR_CPUS > 32
+#error please extend CPU enumeration
+#endif
+ {
+ .ctl_name = 0,
+ }
+};
+
+static ctl_table ctl_cpu[2] = {
+ {
+ .ctl_name = CTL_CPU,
+ .procname = "cpu",
+ .mode = 0555,
+ .child = ctl_cpu_table,
+ },
+ {
+ .ctl_name = 0,
+ }
+};
+
+struct ctl_table_header *cpufreq_sysctl_table;
+
+static inline void cpufreq_sysctl_init(void)
+{
+ cpufreq_sysctl_table = register_sysctl_table(ctl_cpu, 0);
+}
+
+static inline void cpufreq_sysctl_exit(void)
+{
+ unregister_sysctl_table(cpufreq_sysctl_table);
+}
+
+#else
+#define cpufreq_sysctl_init() do {} while(0)
+#define cpufreq_sysctl_exit() do {} while(0)
+#endif /* CONFIG_CPU_FREQ_24API */
+
+
+/************************** sysfs interface ************************/
+static ssize_t show_speed (struct cpufreq_policy *policy, char *buf)
+{
+ return sprintf (buf, "%u\n", cpu_cur_freq[policy->cpu]);
+}
+
+static ssize_t
+store_speed (struct cpufreq_policy *policy, const char *buf, size_t count)
+{
+ unsigned int freq = 0;
+ unsigned int ret;
+
+ ret = sscanf (buf, "%u", &freq);
+ if (ret != 1)
+ return -EINVAL;
+
+ cpufreq_set(freq, policy->cpu);
+
+ return count;
+}
+
+static struct freq_attr freq_attr_scaling_setspeed = {
+ .attr = { .name = "scaling_setspeed", .mode = 0644 },
+ .show = show_speed,
+ .store = store_speed,
+};
+
+static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
+ unsigned int event)
+{
+ unsigned int cpu = policy->cpu;
+ switch (event) {
+ case CPUFREQ_GOV_START:
+ if ((!cpu_online(cpu)) || (!try_module_get(THIS_MODULE)) ||
+ !policy->cur)
+ return -EINVAL;
+ down(&userspace_sem);
+ cpu_is_managed[cpu] = 1;
+ cpu_min_freq[cpu] = policy->min;
+ cpu_max_freq[cpu] = policy->max;
+ cpu_cur_freq[cpu] = policy->cur;
+ sysfs_create_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
+ memcpy (¤t_policy[cpu], policy, sizeof(struct cpufreq_policy));
+ up(&userspace_sem);
+ break;
+ case CPUFREQ_GOV_STOP:
+ down(&userspace_sem);
+ cpu_is_managed[cpu] = 0;
+ cpu_min_freq[cpu] = 0;
+ cpu_max_freq[cpu] = 0;
+ sysfs_remove_file (&policy->kobj, &freq_attr_scaling_setspeed.attr);
+ up(&userspace_sem);
+ module_put(THIS_MODULE);
+ break;
+ case CPUFREQ_GOV_LIMITS:
+ down(&userspace_sem);
+ cpu_min_freq[cpu] = policy->min;
+ cpu_max_freq[cpu] = policy->max;
+ if (policy->max < cpu_cur_freq[cpu])
+ cpufreq_driver_target(¤t_policy[cpu], policy->max,
+ CPUFREQ_RELATION_H);
+ else if (policy->min > cpu_cur_freq[cpu])
+ cpufreq_driver_target(¤t_policy[cpu], policy->min,
+ CPUFREQ_RELATION_L);
+ memcpy (¤t_policy[cpu], policy, sizeof(struct cpufreq_policy));
+ up(&userspace_sem);
+ break;
+ }
+ return 0;
+}
+
+/* on ARM SA1100 we need to rely on the values of cpufreq_get() - because
+ * of this, cpu_cur_freq[] needs to be set early.
+ */
+#if defined(CONFIG_ARM) && defined(CONFIG_ARCH_SA1100)
+extern unsigned int sa11x0_getspeed(void);
+
+static void cpufreq_sa11x0_compat(void)
+{
+ cpu_cur_freq[0] = sa11x0_getspeed();
+}
+#else
+#define cpufreq_sa11x0_compat() do {} while(0)
+#endif
+
+
+static struct cpufreq_governor cpufreq_gov_userspace = {
+ .name = "userspace",
+ .governor = cpufreq_governor_userspace,
+ .owner = THIS_MODULE,
+};
+EXPORT_SYMBOL(cpufreq_gov_userspace);
+
+static int already_init = 0;
+
+int cpufreq_gov_userspace_init(void)
+{
+ if (!already_init) {
+ down(&userspace_sem);
+ cpufreq_sa11x0_compat();
+ cpufreq_sysctl_init();
+ cpufreq_register_notifier(&userspace_cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
+ already_init = 1;
+ up(&userspace_sem);
+ }
+ return cpufreq_register_governor(&cpufreq_gov_userspace);
+}
+EXPORT_SYMBOL(cpufreq_gov_userspace_init);
+
+
+static void __exit cpufreq_gov_userspace_exit(void)
+{
+ cpufreq_unregister_governor(&cpufreq_gov_userspace);
+ cpufreq_unregister_notifier(&userspace_cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
+ cpufreq_sysctl_exit();
+}
+
+
+MODULE_AUTHOR ("Dominik Brodowski <linux@brodo.de>, Russell King <rmk@arm.linux.org.uk>");
+MODULE_DESCRIPTION ("CPUfreq policy governor 'userspace'");
+MODULE_LICENSE ("GPL");
+
+module_init(cpufreq_gov_userspace_init);
+module_exit(cpufreq_gov_userspace_exit);
diff -urN linux-2.4.26/drivers/i2c/Config.in linux-2.4.26-vrs1/drivers/i2c/Config.in
--- linux-2.4.26/drivers/i2c/Config.in 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/i2c/Config.in 2004-04-18 21:47:50.000000000 +0100
@@ -17,6 +17,15 @@
int ' GPIO pin used for SCL' CONFIG_SCx200_I2C_SCL 12
int ' GPIO pin used for SDA' CONFIG_SCx200_I2C_SDA 13
fi
+
+ dep_tristate ' Guide GPIO adapter' CONFIG_I2C_GUIDE $CONFIG_I2C_ALGOBIT
+ if [ "$CONFIG_ARCH_OMAHA" = "y" ]; then
+ dep_tristate ' Omaha I2C interface' CONFIG_I2C_OMAHA $CONFIG_I2C
+ fi
+ if [ "$CONFIG_ARCH_SA1100" = "y" ]; then
+ dep_tristate ' Frodo I2C adapter' CONFIG_I2C_FRODO $CONFIG_I2C_ALGOBIT
+ dep_tristate ' SA1100 I2C GPIO adapter' CONFIG_I2C_BIT_SA1100_GPIO $CONFIG_I2C_ALGOBIT
+ fi
fi
dep_tristate 'NatSemi SCx200 ACCESS.bus' CONFIG_SCx200_ACB $CONFIG_I2C
@@ -49,6 +58,10 @@
dep_tristate 'Keywest I2C interface in Apple Core99 machines' CONFIG_I2C_KEYWEST $CONFIG_I2C
fi
+ if [ "$CONFIG_ARCH_AT91RM9200" = "y" ] ; then
+ dep_tristate 'Atmel AT91RM9200 I2C Two-Wire interface (TWI)' CONFIG_I2C_AT91 $CONFIG_I2C
+ fi
+
if [ "$CONFIG_SIBYTE_SB1xxx_SOC" = "y" ]; then
dep_tristate 'SiByte SMBus interface' CONFIG_I2C_ALGO_SIBYTE $CONFIG_I2C
dep_tristate ' MAX1617 Temperature Sensor' CONFIG_I2C_MAX1617 $CONFIG_I2C_ALGO_SIBYTE
diff -urN linux-2.4.26/drivers/i2c/Makefile linux-2.4.26-vrs1/drivers/i2c/Makefile
--- linux-2.4.26/drivers/i2c/Makefile 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/i2c/Makefile 2004-02-23 22:59:17.000000000 +0000
@@ -8,12 +8,21 @@
i2c-algo-ite.o i2c-algo-sibyte.o i2c-algo-sgi.o \
i2c-proc.o
+# Init order: core, chardev, bit adapters, pcf adapters
+
obj-$(CONFIG_I2C) += i2c-core.o
obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o
+
+# Bit adapters
obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o
obj-$(CONFIG_I2C_PHILIPSPAR) += i2c-philips-par.o
obj-$(CONFIG_I2C_ELV) += i2c-elv.o
obj-$(CONFIG_I2C_VELLEMAN) += i2c-velleman.o
+obj-$(CONFIG_I2C_GUIDE) += i2c-guide.o
+obj-$(CONFIG_I2C_FRODO) += i2c-frodo.o
+obj-$(CONFIG_I2C_OMAHA) += i2c-omaha.o
+
+# PCF adapters
obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o
obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
obj-$(CONFIG_ITE_I2C_ALGO) += i2c-algo-ite.o
@@ -30,4 +39,3 @@
# This is needed for automatic patch generation: sensors code ends here
include $(TOPDIR)/Rules.make
-
diff -urN linux-2.4.26/drivers/i2c/i2c-algo-bit.c linux-2.4.26-vrs1/drivers/i2c/i2c-algo-bit.c
--- linux-2.4.26/drivers/i2c/i2c-algo-bit.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-algo-bit.c 2004-02-23 13:36:30.000000000 +0000
@@ -169,7 +169,14 @@
* 1 if the device acknowledged
* 0 if the device did not ack
* -ETIMEDOUT if an error occurred (while raising the scl line)
- */
+
+ * tsong@iders.ca: an instruction to disable any timeconsuming interrupt
+ here except the heart beat of timer2 should be added before setsda(adap, sb).
+ because when interrupt occurs during
+ scl is set high, the interrupt service routine is served and may take long,
+ after the interrupt returns, sda could be sampled by the device(slave)
+ more than once, and this cause error problem.
+*/
static int i2c_outb(struct i2c_adapter *i2c_adap, char c)
{
int i;
@@ -582,9 +589,7 @@
printk("\n");
}
-#ifdef MODULE
MOD_INC_USE_COUNT;
-#endif
i2c_add_adapter(adap);
return 0;
@@ -600,15 +605,13 @@
DEB2(printk("i2c-algo-bit.o: adapter unregistered: %s\n",adap->name));
-#ifdef MODULE
MOD_DEC_USE_COUNT;
-#endif
return 0;
}
-int __init i2c_algo_bit_init (void)
+static int __init i2c_algo_bit_init (void)
{
- printk(KERN_INFO "i2c-algo-bit.o: i2c bit algorithm module\n");
+ printk(KERN_DEBUG "i2c-algo-bit.o: i2c bit algorithm module\n");
return 0;
}
@@ -617,7 +620,6 @@
EXPORT_SYMBOL(i2c_bit_add_bus);
EXPORT_SYMBOL(i2c_bit_del_bus);
-#ifdef MODULE
MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm");
MODULE_LICENSE("GPL");
@@ -631,12 +633,4 @@
MODULE_PARM_DESC(i2c_debug,
"debug level - 0 off; 1 normal; 2,3 more verbose; 9 bit-protocol");
-int init_module(void)
-{
- return i2c_algo_bit_init();
-}
-
-void cleanup_module(void)
-{
-}
-#endif
+module_init(i2c_algo_bit_init);
diff -urN linux-2.4.26/drivers/i2c/i2c-algo-pcf.c linux-2.4.26-vrs1/drivers/i2c/i2c-algo-pcf.c
--- linux-2.4.26/drivers/i2c/i2c-algo-pcf.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-algo-pcf.c 2004-02-23 13:36:30.000000000 +0000
@@ -475,9 +475,7 @@
return i;
}
-#ifdef MODULE
MOD_INC_USE_COUNT;
-#endif
i2c_add_adapter(adap);
@@ -515,13 +513,11 @@
return res;
DEB2(printk("i2c-algo-pcf.o: adapter unregistered: %s\n",adap->name));
-#ifdef MODULE
MOD_DEC_USE_COUNT;
-#endif
return 0;
}
-int __init i2c_algo_pcf_init (void)
+static int __init i2c_algo_pcf_init (void)
{
printk("i2c-algo-pcf.o: i2c pcf8584 algorithm module\n");
return 0;
@@ -531,7 +527,6 @@
EXPORT_SYMBOL(i2c_pcf_add_bus);
EXPORT_SYMBOL(i2c_pcf_del_bus);
-#ifdef MODULE
MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm");
MODULE_LICENSE("GPL");
@@ -543,13 +538,4 @@
MODULE_PARM_DESC(i2c_debug,
"debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol");
-
-int init_module(void)
-{
- return i2c_algo_pcf_init();
-}
-
-void cleanup_module(void)
-{
-}
-#endif
+module_init(i2c_algo_pcf_init);
diff -urN linux-2.4.26/drivers/i2c/i2c-core.c linux-2.4.26-vrs1/drivers/i2c/i2c-core.c
--- linux-2.4.26/drivers/i2c/i2c-core.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-core.c 2004-02-27 22:54:22.000000000 +0000
@@ -41,7 +41,7 @@
/* exclusive access to the bus */
#define I2C_LOCK(adap) down(&adap->lock)
-#define I2C_UNLOCK(adap) up(&adap->lock)
+#define I2C_UNLOCK(adap) up(&adap->lock)
#define ADAP_LOCK() down(&adap_lock)
#define ADAP_UNLOCK() up(&adap_lock)
@@ -67,7 +67,7 @@
static int driver_count;
/**** debug level */
-static int i2c_debug=1;
+static int i2c_debug = 0;
/* ---------------------------------------------------
* /proc entry declarations
@@ -77,14 +77,14 @@
#ifdef CONFIG_PROC_FS
static int i2cproc_init(void);
-static int i2cproc_cleanup(void);
+static void i2cproc_cleanup(void);
-static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
+static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
loff_t *ppos);
static int read_bus_i2c(char *buf, char **start, off_t offset, int len,
int *eof , void *private);
-/* To implement the dynamic /proc/bus/i2c-? files, we need our own
+/* To implement the dynamic /proc/bus/i2c-? files, we need our own
implementation of the read hook */
static struct file_operations i2cproc_operations = {
read: i2cproc_bus_read,
@@ -101,8 +101,8 @@
/* ---------------------------------------------------
- * registering functions
- * ---------------------------------------------------
+ * registering functions
+ * ---------------------------------------------------
*/
/* -----
@@ -119,7 +119,7 @@
if (NULL == adapters[i])
break;
if (I2C_ADAP_MAX == i) {
- printk(KERN_WARNING
+ printk(KERN_WARNING
" i2c-core.o: register_adapter(%s) - enlarge I2C_ADAP_MAX.\n",
adap->name);
res = -ENOMEM;
@@ -129,7 +129,7 @@
adapters[i] = adap;
adap_count++;
ADAP_UNLOCK();
-
+
/* init data types */
init_MUTEX(&adap->lock);
@@ -157,18 +157,18 @@
#endif /* def CONFIG_PROC_FS */
/* inform drivers of new adapters */
- DRV_LOCK();
+ DRV_LOCK();
for (j=0;j<I2C_DRIVER_MAX;j++)
- if (drivers[j]!=NULL &&
+ if (drivers[j]!=NULL &&
(drivers[j]->flags&(I2C_DF_NOTIFY|I2C_DF_DUMMY)))
/* We ignore the return code; if it fails, too bad */
drivers[j]->attach_adapter(adap);
DRV_UNLOCK();
-
+
DEB(printk(KERN_DEBUG "i2c-core.o: adapter %s registered as adapter %d.\n",
adap->name,i));
- return 0;
+ return 0;
ERROR1:
@@ -203,13 +203,13 @@
* this or hell will break loose...
*/
DRV_LOCK();
- for (j = 0; j < I2C_DRIVER_MAX; j++)
+ for (j = 0; j < I2C_DRIVER_MAX; j++)
if (drivers[j] && (drivers[j]->flags & I2C_DF_DUMMY))
if ((res = drivers[j]->attach_adapter(adap))) {
printk(KERN_WARNING "i2c-core.o: can't detach adapter %s "
"while detaching driver %s: driver not "
"detached!",adap->name,drivers[j]->name);
- goto ERROR1;
+ goto ERROR1;
}
DRV_UNLOCK();
@@ -241,8 +241,8 @@
adapters[i] = NULL;
adap_count--;
-
- ADAP_UNLOCK();
+
+ ADAP_UNLOCK();
DEB(printk(KERN_DEBUG "i2c-core.o: adapter unregistered: %s\n",adap->name));
return 0;
@@ -269,7 +269,7 @@
if (NULL == drivers[i])
break;
if (I2C_DRIVER_MAX == i) {
- printk(KERN_WARNING
+ printk(KERN_WARNING
" i2c-core.o: register_driver(%s) "
"- enlarge I2C_DRIVER_MAX.\n",
driver->name);
@@ -279,11 +279,11 @@
drivers[i] = driver;
driver_count++;
-
+
DRV_UNLOCK(); /* driver was successfully added */
-
+
DEB(printk(KERN_DEBUG "i2c-core.o: driver %s registered.\n",driver->name));
-
+
ADAP_LOCK();
/* now look for instances of driver on our adapters
@@ -314,11 +314,11 @@
return -ENODEV;
}
/* Have a look at each adapter, if clients of this driver are still
- * attached. If so, detach them to be able to kill the driver
+ * attached. If so, detach them to be able to kill the driver
* afterwards.
*/
DEB2(printk(KERN_DEBUG "i2c-core.o: unregister_driver - looking for clients.\n"));
- /* removing clients does not depend on the notify flag, else
+ /* removing clients does not depend on the notify flag, else
* invalid operation might (will!) result, when using stale client
* pointers.
*/
@@ -333,7 +333,7 @@
/* DUMMY drivers do not register their clients, so we have to
* use a trick here: we call driver->attach_adapter to
* *detach* it! Of course, each dummy driver should know about
- * this or hell will break loose...
+ * this or hell will break loose...
*/
if ((res = driver->attach_adapter(adap))) {
printk(KERN_WARNING "i2c-core.o: while unregistering "
@@ -345,9 +345,9 @@
return res;
}
} else {
- for (j=0;j<I2C_CLIENT_MAX;j++) {
+ for (j=0;j<I2C_CLIENT_MAX;j++) {
struct i2c_client *client = adap->clients[j];
- if (client != NULL &&
+ if (client != NULL &&
client->driver == driver) {
DEB2(printk(KERN_DEBUG "i2c-core.o: "
"detaching client %s:\n",
@@ -376,7 +376,7 @@
drivers[i] = NULL;
driver_count--;
DRV_UNLOCK();
-
+
DEB(printk(KERN_DEBUG "i2c-core.o: driver unregistered: %s\n",driver->name));
return 0;
}
@@ -384,7 +384,7 @@
int i2c_check_addr (struct i2c_adapter *adapter, int addr)
{
int i;
- for (i = 0; i < I2C_CLIENT_MAX ; i++)
+ for (i = 0; i < I2C_CLIENT_MAX ; i++)
if (adapter->clients[i] && (adapter->clients[i]->addr == addr))
return -EBUSY;
return 0;
@@ -402,7 +402,7 @@
if (NULL == adapter->clients[i])
break;
if (I2C_CLIENT_MAX == i) {
- printk(KERN_WARNING
+ printk(KERN_WARNING
" i2c-core.o: attach_client(%s) - enlarge I2C_CLIENT_MAX.\n",
client->name);
return -ENOMEM;
@@ -410,9 +410,9 @@
adapter->clients[i] = client;
adapter->client_count++;
-
- if (adapter->client_register)
- if (adapter->client_register(client))
+
+ if (adapter->client_register)
+ if (adapter->client_register(client))
printk(KERN_DEBUG "i2c-core.o: warning: client_register seems "
"to have failed for client %02x at adapter %s\n",
client->addr,adapter->name);
@@ -421,7 +421,7 @@
if(client->flags & I2C_CLIENT_ALLOW_USE)
client->usage_count = 0;
-
+
return 0;
}
@@ -440,12 +440,12 @@
client->name);
return -ENODEV;
}
-
- if( (client->flags & I2C_CLIENT_ALLOW_USE) &&
+
+ if( (client->flags & I2C_CLIENT_ALLOW_USE) &&
(client->usage_count>0))
return -EBUSY;
-
- if (adapter->client_unregister != NULL)
+
+ if (adapter->client_unregister != NULL)
if ((res = adapter->client_unregister(client))) {
printk(KERN_ERR "i2c-core.o: client_unregister [%s] failed, "
"client not detached",client->name);
@@ -471,7 +471,7 @@
void i2c_dec_use_client(struct i2c_client *client)
{
-
+
if (client->driver->dec_use != NULL)
client->driver->dec_use(client);
@@ -479,65 +479,65 @@
client->adapter->dec_use(client->adapter);
}
-struct i2c_client *i2c_get_client(int driver_id, int adapter_id,
+struct i2c_client *i2c_get_client(int driver_id, int adapter_id,
struct i2c_client *prev)
{
int i,j;
-
+
/* Will iterate through the list of clients in each adapter of adapters-list
- in search for a client that matches the search criteria. driver_id or
- adapter_id are ignored if set to 0. If both are ignored this returns
+ in search for a client that matches the search criteria. driver_id or
+ adapter_id are ignored if set to 0. If both are ignored this returns
first client found. */
-
- i = j = 0;
-
- /* set starting point */
+
+ i = j = 0;
+
+ /* set starting point */
if(prev)
{
if(!(prev->adapter))
return (struct i2c_client *) -EINVAL;
-
+
for(j=0; j < I2C_ADAP_MAX; j++)
if(prev->adapter == adapters[j])
break;
-
+
/* invalid starting point? */
if (I2C_ADAP_MAX == j) {
printk(KERN_WARNING " i2c-core.o: get_client adapter for client:[%s] not found\n",
prev->name);
return (struct i2c_client *) -ENODEV;
- }
-
+ }
+
for(i=0; i < I2C_CLIENT_MAX; i++)
if(prev == adapters[j]->clients[i])
break;
-
+
/* invalid starting point? */
if (I2C_CLIENT_MAX == i) {
printk(KERN_WARNING " i2c-core.o: get_client client:[%s] not found\n",
prev->name);
return (struct i2c_client *) -ENODEV;
- }
-
+ }
+
i++; /* start from one after prev */
}
-
+
for(; j < I2C_ADAP_MAX; j++)
{
if(!adapters[j])
continue;
-
+
if(adapter_id && (adapters[j]->id != adapter_id))
continue;
-
+
for(; i < I2C_CLIENT_MAX; i++)
{
if(!adapters[j]->clients[i])
continue;
-
+
if(driver_id && (adapters[j]->clients[i]->driver->id != driver_id))
continue;
- if(adapters[j]->clients[i]->flags & I2C_CLIENT_ALLOW_USE)
+ if(adapters[j]->clients[i]->flags & I2C_CLIENT_ALLOW_USE)
return adapters[j]->clients[i];
}
i = 0;
@@ -549,12 +549,12 @@
int i2c_use_client(struct i2c_client *client)
{
if(client->flags & I2C_CLIENT_ALLOW_USE) {
- if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE)
+ if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE)
client->usage_count++;
else {
- if(client->usage_count > 0)
+ if(client->usage_count > 0)
return -EBUSY;
- else
+ else
client->usage_count++;
}
}
@@ -575,9 +575,9 @@
return -EPERM;
}
}
-
+
i2c_dec_use_client(client);
-
+
return 0;
}
@@ -589,7 +589,7 @@
#ifdef CONFIG_PROC_FS
/* This function generates the output for /proc/bus/i2c */
-int read_bus_i2c(char *buf, char **start, off_t offset, int len, int *eof,
+int read_bus_i2c(char *buf, char **start, off_t offset, int len, int *eof,
void *private)
{
int i;
@@ -615,7 +615,7 @@
}
/* This function generates the output for /proc/bus/i2c-? */
-ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
+ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,
loff_t *ppos)
{
struct inode * inode = file->f_dentry->d_inode;
@@ -626,7 +626,7 @@
int order[I2C_CLIENT_MAX];
if (count > 4000)
- return -EINVAL;
+ return -EINVAL;
len_total = file->f_pos + count;
/* Too bad if this gets longer (unlikely) */
if (len_total > 4000)
@@ -641,12 +641,12 @@
sorted by address */
order_nr=0;
for (j = 0; j < I2C_CLIENT_MAX; j++) {
- if ((client = adapters[i]->clients[j]) &&
+ if ((client = adapters[i]->clients[j]) &&
(client->driver->id != I2C_DRIVERID_I2CDEV)) {
- for(k = order_nr;
- (k > 0) &&
+ for(k = order_nr;
+ (k > 0) &&
adapters[i]->clients[order[k-1]]->
- addr > client->addr;
+ addr > client->addr;
k--)
order[k] = order[k-1];
order[k] = j;
@@ -665,7 +665,7 @@
len = len - file->f_pos;
if (len > count)
len = count;
- if (len < 0)
+ if (len < 0)
len = 0;
if (copy_to_user (buf,kbuf+file->f_pos, len)) {
kfree(kbuf);
@@ -689,7 +689,7 @@
printk("i2c-core.o: /proc/bus/ does not exist");
i2cproc_cleanup();
return -ENOENT;
- }
+ }
proc_bus_i2c = create_proc_entry("i2c",0,proc_bus);
if (!proc_bus_i2c) {
printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/i2c");
@@ -702,14 +702,13 @@
return 0;
}
-int i2cproc_cleanup(void)
+static void i2cproc_cleanup(void)
{
if (i2cproc_initialized >= 1) {
remove_proc_entry("i2c",proc_bus);
i2cproc_initialized -= 2;
}
- return 0;
}
@@ -751,10 +750,10 @@
msg.flags = client->flags & I2C_M_TEN;
msg.len = count;
(const char *)msg.buf = buf;
-
+
DEB2(printk(KERN_DEBUG "i2c-core.o: master_send: writing %d bytes on %s.\n",
count,client->adapter->name));
-
+
I2C_LOCK(adap);
ret = adap->algo->master_xfer(adap,&msg,1);
I2C_UNLOCK(adap);
@@ -784,14 +783,14 @@
DEB2(printk(KERN_DEBUG "i2c-core.o: master_recv: reading %d bytes on %s.\n",
count,client->adapter->name));
-
+
I2C_LOCK(adap);
ret = adap->algo->master_xfer(adap,&msg,1);
I2C_UNLOCK(adap);
-
+
DEB2(printk(KERN_DEBUG "i2c-core.o: master_recv: return:%d (count:%d, addr:0x%02x)\n",
ret, count, client->addr));
-
+
/* if everything went ok (i.e. 1 msg transmitted), return #bytes
* transmitted, else error code.
*/
@@ -852,7 +851,7 @@
found = 0;
for (i = 0; !found && (address_data->force[i] != I2C_CLIENT_END); i += 3) {
- if (((adap_id == address_data->force[i]) ||
+ if (((adap_id == address_data->force[i]) ||
(address_data->force[i] == ANY_I2C_BUS)) &&
(addr == address_data->force[i+1])) {
DEB2(printk(KERN_DEBUG "i2c-core.o: found force parameter for adapter %d, addr %04x\n",
@@ -862,7 +861,7 @@
found = 1;
}
}
- if (found)
+ if (found)
continue;
/* If this address is in one of the ignores, we can forget about
@@ -870,7 +869,7 @@
for (i = 0;
!found && (address_data->ignore[i] != I2C_CLIENT_END);
i += 2) {
- if (((adap_id == address_data->ignore[i]) ||
+ if (((adap_id == address_data->ignore[i]) ||
((address_data->ignore[i] == ANY_I2C_BUS))) &&
(addr == address_data->ignore[i+1])) {
DEB2(printk(KERN_DEBUG "i2c-core.o: found ignore parameter for adapter %d, "
@@ -890,11 +889,11 @@
found = 1;
}
}
- if (found)
+ if (found)
continue;
- /* Now, we will do a detection, but only if it is in the normal or
- probe entries */
+ /* Now, we will do a detection, but only if it is in the normal or
+ probe entries */
for (i = 0;
!found && (address_data->normal_i2c[i] != I2C_CLIENT_END);
i += 1) {
@@ -939,7 +938,7 @@
"addr %04x\n", adap_id,addr));
}
}
- if (!found)
+ if (!found)
continue;
/* OK, so we really should examine this address. First check
@@ -1087,11 +1086,11 @@
I2C_SMBUS_I2C_BLOCK_DATA,&data);
}
-/* Simulate a SMBus command using the i2c protocol
+/* Simulate a SMBus command using the i2c protocol
No checking of parameters is done! */
-static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
+static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
unsigned short flags,
- char read_write, u8 command, int size,
+ char read_write, u8 command, int size,
union i2c_smbus_data * data)
{
/* So we need to generate a series of msgs. In the case of writing, we
@@ -1101,7 +1100,7 @@
unsigned char msgbuf0[34];
unsigned char msgbuf1[34];
int num = read_write == I2C_SMBUS_READ?2:1;
- struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },
+ struct i2c_msg msg[2] = { { addr, flags, 1, msgbuf0 },
{ addr, flags | I2C_M_RD, 0, msgbuf1 }
};
int i;
@@ -1179,7 +1178,7 @@
case I2C_SMBUS_BYTE_DATA:
data->byte = msgbuf1[0];
break;
- case I2C_SMBUS_WORD_DATA:
+ case I2C_SMBUS_WORD_DATA:
case I2C_SMBUS_PROC_CALL:
data->word = msgbuf1[0] | (msgbuf1[1] << 8);
break;
@@ -1189,7 +1188,7 @@
s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
- char read_write, u8 command, int size,
+ char read_write, u8 command, int size,
union i2c_smbus_data * data)
{
s32 res;
@@ -1207,7 +1206,7 @@
/* You should always define `functionality'; the 'else' is just for
- backward compatibility. */
+ backward compatibility. */
u32 i2c_get_functionality (struct i2c_adapter *adap)
{
if (adap->algo->functionality)
@@ -1233,122 +1232,12 @@
init_MUTEX(&adap_lock);
init_MUTEX(&driver_lock);
-
- i2cproc_init();
-
- return 0;
-}
-#ifndef MODULE
-#ifdef CONFIG_I2C_CHARDEV
- extern int i2c_dev_init(void);
-#endif
-#ifdef CONFIG_I2C_ALGOBIT
- extern int i2c_algo_bit_init(void);
-#endif
-#ifdef CONFIG_I2C_PHILIPSPAR
- extern int i2c_bitlp_init(void);
-#endif
-#ifdef CONFIG_I2C_ELV
- extern int i2c_bitelv_init(void);
-#endif
-#ifdef CONFIG_I2C_VELLEMAN
- extern int i2c_bitvelle_init(void);
-#endif
-#ifdef CONFIG_I2C_BITVIA
- extern int i2c_bitvia_init(void);
-#endif
-
-#ifdef CONFIG_I2C_ALGOPCF
- extern int i2c_algo_pcf_init(void);
-#endif
-#ifdef CONFIG_I2C_ELEKTOR
- extern int i2c_pcfisa_init(void);
-#endif
-
-#ifdef CONFIG_I2C_ALGO8XX
- extern int i2c_algo_8xx_init(void);
-#endif
-#ifdef CONFIG_I2C_RPXLITE
- extern int i2c_rpx_init(void);
-#endif
-
-#ifdef CONFIG_I2C_ALGO_SIBYTE
- extern int i2c_algo_sibyte_init(void);
- extern int i2c_sibyte_init(void);
-#endif
-#ifdef CONFIG_I2C_MAX1617
- extern int i2c_max1617_init(void);
-#endif
-
-#ifdef CONFIG_I2C_PROC
- extern int sensors_init(void);
-#endif
-
-/* This is needed for automatic patch generation: sensors code starts here */
-/* This is needed for automatic patch generation: sensors code ends here */
-
-int __init i2c_init_all(void)
-{
- /* --------------------- global ----- */
- i2c_init();
-
-#ifdef CONFIG_I2C_CHARDEV
- i2c_dev_init();
-#endif
- /* --------------------- bit -------- */
-#ifdef CONFIG_I2C_ALGOBIT
- i2c_algo_bit_init();
-#endif
-#ifdef CONFIG_I2C_PHILIPSPAR
- i2c_bitlp_init();
-#endif
-#ifdef CONFIG_I2C_ELV
- i2c_bitelv_init();
-#endif
-#ifdef CONFIG_I2C_VELLEMAN
- i2c_bitvelle_init();
-#endif
-
- /* --------------------- pcf -------- */
-#ifdef CONFIG_I2C_ALGOPCF
- i2c_algo_pcf_init();
-#endif
-#ifdef CONFIG_I2C_ELEKTOR
- i2c_pcfisa_init();
-#endif
-
- /* --------------------- 8xx -------- */
-#ifdef CONFIG_I2C_ALGO8XX
- i2c_algo_8xx_init();
-#endif
-#ifdef CONFIG_I2C_RPXLITE
- i2c_rpx_init();
-#endif
-
- /* --------------------- SiByte -------- */
-#ifdef CONFIG_I2C_ALGO_SIBYTE
- i2c_algo_sibyte_init();
- i2c_sibyte_init();
-#endif
-#ifdef CONFIG_I2C_MAX1617
- i2c_max1617_init();
-#endif
-
- /* -------------- proc interface ---- */
-#ifdef CONFIG_I2C_PROC
- sensors_init();
-#endif
-/* This is needed for automatic patch generation: sensors code starts here */
-/* This is needed for automatic patch generation: sensors code ends here */
+ i2cproc_init();
return 0;
}
-#endif
-
-
-
EXPORT_SYMBOL(i2c_add_adapter);
EXPORT_SYMBOL(i2c_del_adapter);
EXPORT_SYMBOL(i2c_add_driver);
@@ -1385,7 +1274,6 @@
EXPORT_SYMBOL(i2c_get_functionality);
EXPORT_SYMBOL(i2c_check_functionality);
-#ifdef MODULE
MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
MODULE_DESCRIPTION("I2C-Bus main module");
MODULE_LICENSE("GPL");
@@ -1393,13 +1281,5 @@
MODULE_PARM(i2c_debug, "i");
MODULE_PARM_DESC(i2c_debug,"debug level");
-int init_module(void)
-{
- return i2c_init();
-}
-
-void cleanup_module(void)
-{
- i2cproc_cleanup();
-}
-#endif
+module_init(i2c_init);
+module_exit(i2cproc_cleanup);
diff -urN linux-2.4.26/drivers/i2c/i2c-dev.c linux-2.4.26-vrs1/drivers/i2c/i2c-dev.c
--- linux-2.4.26/drivers/i2c/i2c-dev.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-dev.c 2004-02-27 23:54:13.000000000 +0000
@@ -1,5 +1,5 @@
/*
- i2c-dev.c - i2c-bus driver, char device interface
+ i2c-dev.c - i2c-bus driver, char device interface
Copyright (C) 1995-97 Simon G. Vogl
Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
@@ -25,7 +25,7 @@
/* The I2C_RDWR ioctl code is written by Kolja Waschk <waschk@telos.de> */
-/* The devfs code is contributed by Philipp Matthias Hahn
+/* The devfs code is contributed by Philipp Matthias Hahn
<pmhahn@titan.lahn.de> */
/* $Id: i2c-dev.c,v 1.40 2001/08/25 01:28:01 mds Exp $ */
@@ -50,19 +50,14 @@
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
-#ifdef MODULE
-extern int init_module(void);
-extern int cleanup_module(void);
-#endif /* def MODULE */
-
/* struct file_operations changed too often in the 2.1 series for nice code */
-static ssize_t i2cdev_read (struct file *file, char *buf, size_t count,
+static ssize_t i2cdev_read (struct file *file, char *buf, size_t count,
loff_t *offset);
-static ssize_t i2cdev_write (struct file *file, const char *buf, size_t count,
+static ssize_t i2cdev_write (struct file *file, const char *buf, size_t count,
loff_t *offset);
-static int i2cdev_ioctl (struct inode *inode, struct file *file,
+static int i2cdev_ioctl (struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
static int i2cdev_open (struct inode *inode, struct file *file);
@@ -73,13 +68,8 @@
static int i2cdev_command(struct i2c_client *client, unsigned int cmd,
void *arg);
-#ifdef MODULE
-static
-#else
-extern
-#endif
- int __init i2c_dev_init(void);
-static int i2cdev_cleanup(void);
+static int __init i2c_dev_init(void);
+static void i2cdev_cleanup(void);
static struct file_operations i2cdev_fops = {
owner: THIS_MODULE,
@@ -185,7 +175,7 @@
return ret;
}
-int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
+int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg)
{
struct i2c_client *client = (struct i2c_client *)file->private_data;
@@ -198,14 +188,14 @@
unsigned long funcs;
#ifdef DEBUG
- printk(KERN_DEBUG "i2c-dev.o: i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n",
+ printk(KERN_DEBUG "i2c-dev.o: i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n",
MINOR(inode->i_rdev),cmd, arg);
#endif /* DEBUG */
switch ( cmd ) {
case I2C_SLAVE:
case I2C_SLAVE_FORCE:
- if ((arg > 0x3ff) ||
+ if ((arg > 0x3ff) ||
(((client->flags & I2C_M_TEN) == 0) && arg > 0x7f))
return -EINVAL;
if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg))
@@ -224,8 +214,8 @@
sizeof(unsigned long)))?-EFAULT:0;
case I2C_RDWR:
- if (copy_from_user(&rdwr_arg,
- (struct i2c_rdwr_ioctl_data *)arg,
+ if (copy_from_user(&rdwr_arg,
+ (struct i2c_rdwr_ioctl_data *)arg,
sizeof(rdwr_arg)))
return -EFAULT;
@@ -233,9 +223,9 @@
* be sent at once */
if (rdwr_arg.nmsgs > 42)
return -EINVAL;
-
+
rdwr_pa = (struct i2c_msg *)
- kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg),
+ kmalloc(rdwr_arg.nmsgs * sizeof(struct i2c_msg),
GFP_KERNEL);
if (rdwr_pa == NULL) return -ENOMEM;
@@ -312,9 +302,9 @@
(struct i2c_smbus_ioctl_data *) arg,
sizeof(struct i2c_smbus_ioctl_data)))
return -EFAULT;
- if ((data_arg.size != I2C_SMBUS_BYTE) &&
+ if ((data_arg.size != I2C_SMBUS_BYTE) &&
(data_arg.size != I2C_SMBUS_QUICK) &&
- (data_arg.size != I2C_SMBUS_BYTE_DATA) &&
+ (data_arg.size != I2C_SMBUS_BYTE_DATA) &&
(data_arg.size != I2C_SMBUS_WORD_DATA) &&
(data_arg.size != I2C_SMBUS_PROC_CALL) &&
(data_arg.size != I2C_SMBUS_BLOCK_DATA) &&
@@ -325,9 +315,9 @@
#endif
return -EINVAL;
}
- /* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1,
+ /* Note that I2C_SMBUS_READ and I2C_SMBUS_WRITE are 0 and 1,
so the check is valid if size==I2C_SMBUS_QUICK too. */
- if ((data_arg.read_write != I2C_SMBUS_READ) &&
+ if ((data_arg.read_write != I2C_SMBUS_READ) &&
(data_arg.read_write != I2C_SMBUS_WRITE)) {
#ifdef DEBUG
printk(KERN_DEBUG "i2c-dev.o: read_write out of range (%x) in ioctl I2C_SMBUS.\n",
@@ -339,7 +329,7 @@
/* Note that command values are always valid! */
if ((data_arg.size == I2C_SMBUS_QUICK) ||
- ((data_arg.size == I2C_SMBUS_BYTE) &&
+ ((data_arg.size == I2C_SMBUS_BYTE) &&
(data_arg.read_write == I2C_SMBUS_WRITE)))
/* These are special: we do not use data */
return i2c_smbus_xfer(client->adapter, client->addr,
@@ -358,13 +348,13 @@
if ((data_arg.size == I2C_SMBUS_BYTE_DATA) ||
(data_arg.size == I2C_SMBUS_BYTE))
datasize = sizeof(data_arg.data->byte);
- else if ((data_arg.size == I2C_SMBUS_WORD_DATA) ||
+ else if ((data_arg.size == I2C_SMBUS_WORD_DATA) ||
(data_arg.size == I2C_SMBUS_PROC_CALL))
datasize = sizeof(data_arg.data->word);
else /* size == I2C_SMBUS_BLOCK_DATA */
datasize = sizeof(data_arg.data->block);
- if ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
+ if ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
(data_arg.read_write == I2C_SMBUS_WRITE)) {
if (copy_from_user(&temp, data_arg.data, datasize))
return -EFAULT;
@@ -372,7 +362,7 @@
res = i2c_smbus_xfer(client->adapter,client->addr,client->flags,
data_arg.read_write,
data_arg.command,data_arg.size,&temp);
- if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
+ if (! res && ((data_arg.size == I2C_SMBUS_PROC_CALL) ||
(data_arg.read_write == I2C_SMBUS_READ))) {
if (copy_to_user(data_arg.data, &temp, datasize))
return -EFAULT;
@@ -479,7 +469,7 @@
return -1;
}
-int __init i2c_dev_init(void)
+static int __init i2c_dev_init(void)
{
int res;
@@ -509,7 +499,7 @@
return 0;
}
-int i2cdev_cleanup(void)
+static void i2cdev_cleanup(void)
{
int res;
@@ -517,9 +507,9 @@
if ((res = i2c_del_driver(&i2cdev_driver))) {
printk("i2c-dev.o: Driver deregistration failed, "
"module not removed.\n");
- return res;
+ return;
}
- i2cdev_initialized --;
+ i2cdev_initialized --;
}
if (i2cdev_initialized >= 1) {
@@ -531,30 +521,17 @@
#endif
printk("i2c-dev.o: unable to release major %d for i2c bus\n",
I2C_MAJOR);
- return res;
+ return;
}
i2cdev_initialized --;
}
- return 0;
}
EXPORT_NO_SYMBOLS;
-#ifdef MODULE
-
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Simon G. Vogl <simon@tk.uni-linz.ac.at>");
MODULE_DESCRIPTION("I2C /dev entries driver");
MODULE_LICENSE("GPL");
-int init_module(void)
-{
- return i2c_dev_init();
-}
-
-int cleanup_module(void)
-{
- return i2cdev_cleanup();
-}
-
-#endif /* def MODULE */
-
+module_init(i2c_dev_init);
+module_exit(i2cdev_cleanup);
diff -urN linux-2.4.26/drivers/i2c/i2c-elektor.c linux-2.4.26-vrs1/drivers/i2c/i2c-elektor.c
--- linux-2.4.26/drivers/i2c/i2c-elektor.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-elektor.c 2004-02-23 13:36:30.000000000 +0000
@@ -181,16 +181,12 @@
static void pcf_isa_inc_use(struct i2c_adapter *adap)
{
-#ifdef MODULE
MOD_INC_USE_COUNT;
-#endif
}
static void pcf_isa_dec_use(struct i2c_adapter *adap)
{
-#ifdef MODULE
MOD_DEC_USE_COUNT;
-#endif
}
@@ -219,7 +215,7 @@
pcf_isa_unreg,
};
-int __init i2c_pcfisa_init(void)
+static int __init i2c_pcfisa_init(void)
{
#ifdef __alpha__
/* check to see we have memory mapped PCF8584 connected to the
@@ -289,10 +285,14 @@
return 0;
}
+static void i2c_pcfisa_exit(void)
+{
+ i2c_pcf_del_bus(&pcf_isa_ops);
+ pcf_isa_exit();
+}
EXPORT_NO_SYMBOLS;
-#ifdef MODULE
MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter");
MODULE_LICENSE("GPL");
@@ -304,15 +304,5 @@
MODULE_PARM(mmapped, "i");
MODULE_PARM(i2c_debug, "i");
-int init_module(void)
-{
- return i2c_pcfisa_init();
-}
-
-void cleanup_module(void)
-{
- i2c_pcf_del_bus(&pcf_isa_ops);
- pcf_isa_exit();
-}
-
-#endif
+module_init(i2c_pcfisa_init);
+module_exit(i2c_pcfisa_exit);
diff -urN linux-2.4.26/drivers/i2c/i2c-elv.c linux-2.4.26-vrs1/drivers/i2c/i2c-elv.c
--- linux-2.4.26/drivers/i2c/i2c-elv.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-elv.c 2004-02-27 23:52:23.000000000 +0000
@@ -75,7 +75,7 @@
PortData |=2;
}
outb(PortData, DATA);
-}
+}
static int bit_elv_getscl(void *data)
{
@@ -90,7 +90,7 @@
static int bit_elv_init(void)
{
if (check_region(base,(base == 0x3bc)? 3 : 8) < 0 ) {
- return -ENODEV;
+ return -ENODEV;
} else {
/* test for ELV adap. */
if (inb(base+1) & 0x80) { /* BUSY should be high */
@@ -131,16 +131,12 @@
static void bit_elv_inc_use(struct i2c_adapter *adap)
{
-#ifdef MODULE
MOD_INC_USE_COUNT;
-#endif
}
static void bit_elv_dec_use(struct i2c_adapter *adap)
{
-#ifdef MODULE
MOD_DEC_USE_COUNT;
-#endif
}
/* ------------------------------------------------------------------------
@@ -164,10 +160,10 @@
bit_elv_inc_use,
bit_elv_dec_use,
bit_elv_reg,
- bit_elv_unreg,
+ bit_elv_unreg,
};
-int __init i2c_bitelv_init(void)
+static int __init i2c_bitelv_init(void)
{
printk(KERN_INFO "i2c-elv.o: i2c ELV parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
if (base==0) {
@@ -194,24 +190,19 @@
}
+static void __exit i2c_bitelv_exit(void)
+{
+ i2c_bit_del_bus(&bit_elv_ops);
+ bit_elv_exit();
+}
+
EXPORT_NO_SYMBOLS;
-#ifdef MODULE
MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter");
MODULE_LICENSE("GPL");
MODULE_PARM(base, "i");
-int init_module(void)
-{
- return i2c_bitelv_init();
-}
-
-void cleanup_module(void)
-{
- i2c_bit_del_bus(&bit_elv_ops);
- bit_elv_exit();
-}
-
-#endif
+module_init(i2c_bitelv_init);
+module_exit(i2c_bitelv_exit);
diff -urN linux-2.4.26/drivers/i2c/i2c-frodo.c linux-2.4.26-vrs1/drivers/i2c/i2c-frodo.c
--- linux-2.4.26/drivers/i2c/i2c-frodo.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-frodo.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,114 @@
+
+/*
+ * linux/drivers/i2c/i2c-frodo.c
+ *
+ * Author: Abraham van der Merwe <abraham@2d3d.co.za>
+ *
+ * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110
+ * Development board (Frodo).
+ *
+ * This source code 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/config.h>
+#include <linux/version.h>
+#include <linux/module.h>
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+
+#include <asm/hardware.h>
+
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+
+static void frodo_setsda (void *data,int state)
+{
+ if (state)
+ frodo_cpld_set (FRODO_CPLD_I2C,FRODO_I2C_SDA_OUT);
+ else
+ frodo_cpld_clear (FRODO_CPLD_I2C,FRODO_I2C_SDA_OUT);
+}
+
+static void frodo_setscl (void *data,int state)
+{
+ if (state)
+ frodo_cpld_set (FRODO_CPLD_I2C,FRODO_I2C_SCL_OUT);
+ else
+ frodo_cpld_clear (FRODO_CPLD_I2C,FRODO_I2C_SCL_OUT);
+}
+
+static int frodo_getsda (void *data)
+{
+ return ((frodo_cpld_read (FRODO_CPLD_I2C) & FRODO_I2C_SDA_IN) != 0);
+}
+
+static int frodo_getscl (void *data)
+{
+ return ((frodo_cpld_read (FRODO_CPLD_I2C) & FRODO_I2C_SCL_IN) != 0);
+}
+
+static struct i2c_algo_bit_data bit_frodo_data = {
+ setsda: frodo_setsda,
+ setscl: frodo_setscl,
+ getsda: frodo_getsda,
+ getscl: frodo_getscl,
+ udelay: 80,
+ mdelay: 80,
+ timeout: 100
+};
+
+static int frodo_client_register (struct i2c_client *client)
+{
+ return (0);
+}
+
+static int frodo_client_unregister (struct i2c_client *client)
+{
+ return (0);
+}
+
+static void frodo_inc_use (struct i2c_adapter *adapter)
+{
+ MOD_INC_USE_COUNT;
+}
+
+static void frodo_dec_use (struct i2c_adapter *adapter)
+{
+ MOD_DEC_USE_COUNT;
+}
+
+static struct i2c_adapter frodo_ops = {
+ name: "Frodo adapter driver",
+ id: I2C_HW_B_FRODO,
+ algo: NULL,
+ algo_data: &bit_frodo_data,
+ inc_use: frodo_inc_use,
+ dec_use: frodo_dec_use,
+ client_register: frodo_client_register,
+ client_unregister: frodo_client_unregister
+};
+
+static int __init i2c_frodo_init (void)
+{
+ return (i2c_bit_add_bus (&frodo_ops));
+}
+
+EXPORT_NO_SYMBOLS;
+
+static void __exit i2c_frodo_exit (void)
+{
+ i2c_bit_del_bus (&frodo_ops);
+}
+
+MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>");
+MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo");
+MODULE_LICENSE ("GPL");
+EXPORT_NO_SYMBOLS;
+
+module_init (i2c_frodo_init);
+module_exit (i2c_frodo_exit);
+
diff -urN linux-2.4.26/drivers/i2c/i2c-guide.c linux-2.4.26-vrs1/drivers/i2c/i2c-guide.c
--- linux-2.4.26/drivers/i2c/i2c-guide.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-guide.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,199 @@
+/************************************************************************************\
+Copyright : Copyright (C) 1995-2000 Simon G. Vogl
+ Copyright 2002 IDERs Incorporated
+File Name : i2c-guide.c
+Description : this i2c driver uses the GPIO port B pin 0 and pin 1 on the cs89712.
+Notes : To change the bit rate, change the structure i2c_algo_bit_data
+ : to 10 10 100
+Contact : tsong@iders.ca
+License : This source code 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/ioport.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/string.h> /* for 2.0 kernels to get NULL */
+#include <asm/errno.h> /* for 2.0 kernels to get ENODEV */
+#include <asm/io.h>
+
+#include <asm/hardware/cs89712.h> // io operation ep_writel()
+#include <asm/hardware/clps7111.h> // io operation clps_writel()
+#include <asm/arch-clps711x/hardware.h> // io operation clps_writel()
+
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+
+/* ----- global defines ----------------------------------------------- */
+
+#define DEB(x) /* should be reasonable open, close &c. */
+#define DEB2(x) /* low level debugging - very slow */
+#define DEBE(x) x /* error messages */
+ /* Pin Port Inverted name */
+#define I2C_SDA 0x08 /* port B ctrl pin 3 (inv) */
+#define I2C_SCL 0x04 /* port B ctrl pin 2 (inv) */
+
+#define I2C_SDAIN 0x08 /* use the same pin with output */
+#define I2C_SCLIN 0x04 /* use the same pin with output */
+
+#define I2C_DMASK 0xf7 /* inverse of I2C_SDA */
+#define I2C_CMASK 0xfb /* inverse of I2c_SCL */
+
+#define PORTB_PIN0_SDA_OUTPUT 0x08 /* pin 3 direction of port B output */
+#define PORTB_PIN0_SDA_INPUT 0xf7 /* pin 3 direction of port B input */
+
+#define PORTB_PIN1_SCL_OUTPUT 0x04 /* pin 2 direction of port B output */
+#define PORTB_PIN1_SCL_INPUT 0xfb /* pin 2 direction of port B input */
+
+int base = 0;
+#define DEFAULT_BASE PBDR
+
+/* ----- local functions --------------------------------------------------- */
+
+static void bit_guide_setscl(void* data, int state)
+{
+ if (state) {
+ // set port B pin2 input
+ clps_writeb((clps_readb(PBDDR)) & PORTB_PIN1_SCL_INPUT, PBDDR);
+ }
+ else {
+ // clear
+ clps_writeb((clps_readb(PBDR)) & I2C_CMASK, PBDR);
+ // set port B pin2 output
+ clps_writeb((clps_readb(PBDDR)) | PORTB_PIN1_SCL_OUTPUT, PBDDR);
+ }
+}
+
+static void bit_guide_setsda(void* data, int state)
+{
+ if (state) {
+ clps_writeb((clps_readb(PBDDR)) & PORTB_PIN0_SDA_INPUT, PBDDR);
+ // float pin 0 (actually drive high by pull up resistor)
+ // clps_writeb((clps_readb(PBDR)) | I2C_SDA, PBDR); // set Jan4 ori: eff
+ // printk("set sda high, state=%i\n",state);
+ }
+ else {
+ // clear
+ clps_writeb((clps_readb(PBDR)) & I2C_DMASK, PBDR);
+ // set port B pin 0 output
+ clps_writeb((clps_readb(PBDDR)) | PORTB_PIN0_SDA_OUTPUT, PBDDR);
+ }
+}
+
+static int bit_guide_getscl(void *data)
+{
+ return ( 0 != ( (clps_readb(PBDR)) & I2C_SCLIN ) );
+}
+
+static int bit_guide_getsda(void *data)
+{
+ // set port B pin 0 input Jan4 ori eff
+ clps_writeb((clps_readb(PBDDR)) & PORTB_PIN0_SDA_INPUT, PBDDR);
+ return ( 0 != ( (clps_readb(PBDR) ) & I2C_SDAIN ) );
+}
+
+static int bit_guide_init(void)
+{
+ bit_guide_setsda((void*)base,1);
+ bit_guide_setscl((void*)base,1);
+ return 0;
+}
+
+static int bit_guide_reg(struct i2c_client *client)
+{
+ return 0;
+}
+
+static int bit_guide_unreg(struct i2c_client *client)
+{
+ return 0;
+}
+
+static void bit_guide_inc_use(struct i2c_adapter *adap)
+{
+#ifdef MODULE
+ MOD_INC_USE_COUNT;
+#endif
+}
+
+static void bit_guide_dec_use(struct i2c_adapter *adap)
+{
+#ifdef MODULE
+ MOD_DEC_USE_COUNT;
+#endif
+}
+
+/* ------------------------------------------------------------------------
+ * Encapsulate the above functions in the correct operations structure.
+ * This is only done when more than one hardware adapter is supported.
+ */
+
+/* last line (us, ms, timout)
+ * us dominates the bit rate: 10us means: 100Kbit/sec(25 means 40kbps)
+ * 10ms not known
+ * 100ms timeout
+ */
+static struct i2c_algo_bit_data bit_guide_data = {
+ NULL,
+ bit_guide_setsda,
+ bit_guide_setscl,
+ bit_guide_getsda,
+ bit_guide_getscl,
+ 50, 10, 100, /* orginal (non-guide) value 10, 10, 100 */
+};
+
+static struct i2c_adapter bit_guide_ops = {
+ "Guide Port B: PIN2-SCL/PIN3-SDA",
+ I2C_HW_B_GUIDE,
+ NULL,
+ &bit_guide_data,
+ bit_guide_inc_use,
+ bit_guide_dec_use,
+ bit_guide_reg,
+ bit_guide_unreg,
+};
+
+static int __init i2c_bitguide_init(void)
+{
+ printk("i2c-guide.o: Guide i2c port B adapter module.\n");
+ clps_writeb((clps_readb(PBDDR)) & 0xfd, PBDDR); // set service reuest pb1 as input
+ if (base==0) {
+ /* probe some values */
+ base=DEFAULT_BASE;
+ bit_guide_data.data=(void*)DEFAULT_BASE;
+ if (bit_guide_init()==0) {
+ if(i2c_bit_add_bus(&bit_guide_ops) < 0)
+ return -ENODEV;
+ } else {
+ return -ENODEV;
+ }
+ } else {
+ bit_guide_data.data=(void*)base;
+ if (bit_guide_init()==0) {
+ if(i2c_bit_add_bus(&bit_guide_ops) < 0)
+ return -ENODEV;
+ } else {
+ return -ENODEV;
+ }
+ }
+ printk("i2c-guide.o: found device at %#x.\n",base);
+ return 0;
+}
+
+EXPORT_NO_SYMBOLS;
+
+MODULE_AUTHOR("T. C. Song <tsong@iders.ca>");
+MODULE_DESCRIPTION("I2C-Bus adapter routines for Guide (cs89712) GPIO port B");
+MODULE_LICENSE("GPL");
+
+MODULE_PARM(base, "i");
+
+module_init(i2c_bitguide_init);
+/* for completeness, we should have a module_exit() function, but the
+ GUIDE requires this to always be loaded. If it is unloaded, the
+ operation of the GUIDE is undefined.
+ Nobody has written the i2c_bitguide_exit() routine yet, so it is not included.
+module_exit(i2c_bitguide_exit);
+*/
diff -urN linux-2.4.26/drivers/i2c/i2c-omaha.c linux-2.4.26-vrs1/drivers/i2c/i2c-omaha.c
--- linux-2.4.26/drivers/i2c/i2c-omaha.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-omaha.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,276 @@
+/* ------------------------------------------------------------------------- *
+ Copyright ARM Limited 2002. All rights reserved.
+
+ i2c driver for Omaha
+
+ Notes:Based on i2c-elv.c
+
+ The S3C2400X01 has better support for I2C, but bit oriented operations
+ are directly supported by the other I2C layers, so we use that method
+ of performing I2C operations.
+
+ Copyright (C) 1995-2000 Simon G. Vogl
+
+ 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+/* ------------------------------------------------------------------------- */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/version.h>
+#include <linux/init.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <linux/ioport.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+
+#include <linux/i2c.h>
+#include <linux/i2c-algo-bit.h>
+
+#include <asm/io.h>
+#include <asm/hardware.h>
+
+/* ----- global defines ----------------------------------------------- */
+#define DEB(x) if (i2c_debug>=1) x;
+#define DEB2(x) if (i2c_debug>=2) x;
+#define DEB3(x) if (i2c_debug>=3) x
+#define DEBE(x) x // error messages
+#define DEBSTAT(x) if (i2c_debug>=3) x; /* print several statistical values*/
+#define DEBPROTO(x) if (i2c_debug>=9) { x; }
+ /* debug the protocol by showing transferred bits */
+
+/* Register and bitdefs for Omaha */
+
+// Port G control registers
+static volatile unsigned int pgcon = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_PGCON);
+static volatile unsigned int pgdat = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_PGDAT);
+
+static volatile unsigned int opencr = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_OPENCR);
+
+static int base = IO_ADDRESS(PLAT_PERIPHERAL_BASE+OMAHA_PGCON);
+
+// Open drain control registers
+#define OPC_CMD BIT2
+#define OPC_DAT BIT3
+
+// data bits in GPIO Port G data register
+#define OMAHA_SDA BIT5
+#define OMAHA_SCL BIT6
+#define IIC_WP BIT3 // Write Protect for EEPROM
+
+// input/out select bits in GPIO G control register
+#define IIC_BITS (BIT12|BIT10|BIT6);
+
+
+/* ----- local functions ---------------------------------------------- */
+
+
+static void bit_omaha_setscl(void *data, int state)
+{
+ unsigned int tmp;
+
+ if (state)
+ {
+ tmp = __raw_readl(pgdat);
+ tmp |= OMAHA_SCL;
+ __raw_writel(tmp,pgdat);
+ }
+ else
+ {
+ tmp = __raw_readl(pgdat);
+ tmp &= ~OMAHA_SCL;
+ __raw_writel(tmp,pgdat);
+ }
+}
+
+static void bit_omaha_setsda(void *data, int state)
+{
+ unsigned int tmp;
+
+ // ensure that sda is an output at the moment
+ tmp = __raw_readl(pgcon);
+ tmp = tmp | BIT10;
+ __raw_writel(tmp,pgcon);
+
+ if (state)
+ {
+ tmp = __raw_readl(pgdat);
+ tmp |= OMAHA_SDA;
+ __raw_writel(tmp,pgdat);
+ }
+ else
+ {
+ tmp = __raw_readl(pgdat);
+ tmp &= ~OMAHA_SDA;
+ __raw_writel(tmp,pgdat);
+ }
+}
+
+static int bit_omaha_getscl(void *data)
+{
+ if (__raw_readl(pgdat) & OMAHA_SCL)
+ return 1;
+ else
+ return 0;
+}
+
+static int bit_omaha_getsda(void *data)
+{
+ unsigned int tmp;
+
+ // ensure that sda is an output at the moment
+ tmp = __raw_readl(pgcon);
+ tmp = tmp & ~BIT10;
+ __raw_writel(tmp,pgcon);
+
+ if (__raw_readl(pgdat) & OMAHA_SDA)
+ return 1;
+ else
+ return 0;
+}
+
+static int bit_omaha_init(void)
+{
+ // Have we got some mmapped space?
+ if (request_region(base, 0x100, "i2c (omaha bus adapter)") < 0 )
+ {
+ printk("i2c-omaha.o: requested I/O region (0x%08x) is in use.\n", base);
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+
+static int bit_omaha_reg(struct i2c_client *client)
+{
+ return 0;
+}
+
+
+static int bit_omaha_unreg(struct i2c_client *client)
+{
+ return 0;
+}
+
+static void bit_omaha_inc_use(struct i2c_adapter *adap)
+{
+ MOD_INC_USE_COUNT;
+}
+
+static void bit_omaha_dec_use(struct i2c_adapter *adap)
+{
+ MOD_DEC_USE_COUNT;
+}
+
+
+
+/* ------------------------------------------------------------------------
+ * Encapsulate the above functions in the correct operations structure.
+ * This is only done when more than one hardware adapter is supported.
+ */
+static struct i2c_algo_bit_data bit_omaha_data = {
+ NULL,
+ bit_omaha_setsda,
+ bit_omaha_setscl,
+ bit_omaha_getsda,
+ bit_omaha_getscl,
+ 10, 10, 20, /* waits, timeout */
+};
+
+static struct i2c_adapter bit_omaha_ops = {
+ "BIT-Type Omaha I2C adapter",
+ I2C_HW_B_OMAHA,
+ NULL,
+ &bit_omaha_data,
+ bit_omaha_inc_use,
+ bit_omaha_dec_use,
+ bit_omaha_reg,
+ bit_omaha_unreg,
+};
+
+static int __init i2c_omaha_init (void)
+{
+ unsigned int tmp;
+
+ printk("i2c-omaha.o: i2c omaha adapter module\n");
+
+ if (bit_omaha_init() == 0) {
+ if(i2c_bit_add_bus(&bit_omaha_ops) < 0)
+ {
+ printk("Could not add bus!\n");
+ return -ENODEV;
+ }
+ } else {
+ printk("Could not pcf_omaha_init\n");
+ return -ENODEV;
+ }
+
+ // Program Port G bits to output function
+ tmp = __raw_readl(pgcon);
+ tmp |= IIC_BITS;
+ __raw_writel(tmp,pgcon);
+
+ // Ensure SDA and SCL are open-drain
+ tmp = __raw_readl(opencr);
+ tmp = tmp | OPC_CMD | OPC_DAT;
+ __raw_writel(tmp,opencr);
+
+ bit_omaha_setsda((void*)base,1);
+ bit_omaha_setscl((void*)base,1);
+
+ // Disable WP
+ tmp = __raw_readl(pgdat);
+ tmp = tmp & ~IIC_WP;
+ __raw_writel(tmp,pgdat);
+
+ return 0;
+}
+
+static void bit_omaha_exit(void)
+{
+ release_region(base , 2);
+}
+
+static void i2c_omaha_exit(void)
+{
+
+ i2c_bit_del_bus(&bit_omaha_ops);
+
+ bit_omaha_exit();
+
+}
+
+EXPORT_NO_SYMBOLS;
+
+MODULE_AUTHOR("ARM Limited <support@arm.com>");
+MODULE_DESCRIPTION("I2C-Bus adapter routines for Omaha");
+MODULE_LICENSE("GPL");
+
+MODULE_PARM(base, "i");
+MODULE_PARM(irq, "i");
+MODULE_PARM(clock, "i");
+MODULE_PARM(own, "i");
+MODULE_PARM(mmapped, "i");
+MODULE_PARM(i2c_debug, "i");
+
+
+module_init(i2c_omaha_init);
+module_exit(i2c_omaha_exit);
+
+
diff -urN linux-2.4.26/drivers/i2c/i2c-philips-par.c linux-2.4.26-vrs1/drivers/i2c/i2c-philips-par.c
--- linux-2.4.26/drivers/i2c/i2c-philips-par.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-philips-par.c 2004-02-27 23:50:14.000000000 +0000
@@ -16,7 +16,7 @@
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
-/* ------------------------------------------------------------------------- */
+/* ------------------------------------------------------------------------- */
/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
Frodo Looijaard <frodol@dds.nl> */
@@ -72,7 +72,7 @@
static void bit_lp_setscl(void *data, int state)
{
- /*be cautious about state of the control register -
+ /*be cautious about state of the control register -
touch only the one bit needed*/
if (state) {
parport_write_control((struct parport *) data,
@@ -126,7 +126,7 @@
static int bit_lp_getsda2(void *data)
{
- return (parport_read_status((struct parport *) data) &
+ return (parport_read_status((struct parport *) data) &
PARPORT_STATUS_BUSY) ? 0 : 1;
}
@@ -154,7 +154,7 @@
* Encapsulate the above functions in the correct operations structure.
* This is only done when more than one hardware adapter is supported.
*/
-
+
static struct i2c_algo_bit_data bit_lp_data = {
NULL,
bit_lp_setsda,
@@ -162,7 +162,7 @@
bit_lp_getsda,
bit_lp_getscl,
80, 80, 100, /* waits, timeout */
-};
+};
static struct i2c_algo_bit_data bit_lp_data2 = {
NULL,
@@ -171,7 +171,7 @@
bit_lp_getsda2,
NULL,
80, 80, 100, /* waits, timeout */
-};
+};
static struct i2c_adapter bit_lp_ops = {
"Philips Parallel port adapter",
@@ -197,7 +197,7 @@
printk(KERN_DEBUG "i2c-philips-par.o: attaching to %s\n", port->name);
adapter->pdev = parport_register_device(port, "i2c-philips-par",
- NULL, NULL, NULL,
+ NULL, NULL, NULL,
PARPORT_FLAG_EXCL,
NULL);
if (!adapter->pdev) {
@@ -257,16 +257,16 @@
NULL
};
-int __init i2c_bitlp_init(void)
+static int __init i2c_bitlp_init(void)
{
printk(KERN_INFO "i2c-philips-par.o: i2c Philips parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
parport_register_driver(&i2c_driver);
-
+
return 0;
}
-void __exit i2c_bitlp_exit(void)
+static void __exit i2c_bitlp_exit(void)
{
parport_unregister_driver(&i2c_driver);
}
@@ -279,14 +279,5 @@
MODULE_PARM(type, "i");
-#ifdef MODULE
-int init_module(void)
-{
- return i2c_bitlp_init();
-}
-
-void cleanup_module(void)
-{
- i2c_bitlp_exit();
-}
-#endif
+module_init(i2c_bitlp_init);
+module_exit(i2c_bitlp_exit);
diff -urN linux-2.4.26/drivers/i2c/i2c-velleman.c linux-2.4.26-vrs1/drivers/i2c/i2c-velleman.c
--- linux-2.4.26/drivers/i2c/i2c-velleman.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/i2c/i2c-velleman.c 2004-02-27 23:46:12.000000000 +0000
@@ -65,7 +65,7 @@
} else {
outb(inb(CTRL) | I2C_SCL, CTRL);
}
-
+
}
static void bit_velle_setsda(void *data, int state)
@@ -75,8 +75,8 @@
} else {
outb(inb(CTRL) | I2C_SDA, CTRL);
}
-
-}
+
+}
static int bit_velle_getscl(void *data)
{
@@ -95,7 +95,7 @@
base));
return -ENODEV;
} else {
- request_region(base, (base == 0x3bc)? 3 : 8,
+ request_region(base, (base == 0x3bc)? 3 : 8,
"i2c (Vellemann adapter)");
bit_velle_setsda((void*)base,1);
bit_velle_setscl((void*)base,1);
@@ -104,7 +104,7 @@
}
static void __exit bit_velle_exit(void)
-{
+{
release_region( base , (base == 0x3bc)? 3 : 8 );
}
@@ -121,16 +121,12 @@
static void bit_velle_inc_use(struct i2c_adapter *adap)
{
-#ifdef MODULE
MOD_INC_USE_COUNT;
-#endif
}
static void bit_velle_dec_use(struct i2c_adapter *adap)
{
-#ifdef MODULE
MOD_DEC_USE_COUNT;
-#endif
}
/* ------------------------------------------------------------------------
@@ -158,7 +154,7 @@
bit_velle_unreg,
};
-int __init i2c_bitvelle_init(void)
+static int __init i2c_bitvelle_init(void)
{
printk(KERN_INFO "i2c-velleman.o: i2c Velleman K8000 adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE);
if (base==0) {
@@ -184,24 +180,19 @@
return 0;
}
+static void __exit i2c_bitvelle_exit(void)
+{
+ i2c_bit_del_bus(&bit_velle_ops);
+ bit_velle_exit();
+}
+
EXPORT_NO_SYMBOLS;
-#ifdef MODULE
MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
MODULE_DESCRIPTION("I2C-Bus adapter routines for Velleman K8000 adapter");
MODULE_LICENSE("GPL");
MODULE_PARM(base, "i");
-int init_module(void)
-{
- return i2c_bitvelle_init();
-}
-
-void cleanup_module(void)
-{
- i2c_bit_del_bus(&bit_velle_ops);
- bit_velle_exit();
-}
-
-#endif
+module_init(i2c_bitvelle_init);
+module_exit(i2c_bitvelle_exit);
diff -urN linux-2.4.26/drivers/ide/Config.in linux-2.4.26-vrs1/drivers/ide/Config.in
--- linux-2.4.26/drivers/ide/Config.in 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ide/Config.in 2004-04-18 21:47:50.000000000 +0100
@@ -107,6 +107,9 @@
define_bool CONFIG_BLK_DEV_IDEDMA $CONFIG_BLK_DEV_IDEDMA_ICS
dep_bool ' RapIDE interface support' CONFIG_BLK_DEV_IDE_RAPIDE $CONFIG_ARCH_ACORN
fi
+ if [ "$CONFIG_ARCH_RISCSTATION" = "y" ]; then
+ dep_bool ' RiscStation IDE' CONFIG_BLK_DEV_IDE_RISCSTATION $CONFIG_ARCH_RISCSTATION
+ fi
if [ "$CONFIG_AMIGA" = "y" ]; then
dep_bool ' Amiga Gayle IDE interface support' CONFIG_BLK_DEV_GAYLE $CONFIG_AMIGA
dep_mbool ' Amiga IDE Doubler support (EXPERIMENTAL)' CONFIG_BLK_DEV_IDEDOUBLER $CONFIG_BLK_DEV_GAYLE $CONFIG_EXPERIMENTAL
diff -urN linux-2.4.26/drivers/ide/arm/Makefile linux-2.4.26-vrs1/drivers/ide/arm/Makefile
--- linux-2.4.26/drivers/ide/arm/Makefile 2003-06-13 15:51:33.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ide/arm/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -6,6 +6,7 @@
obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o
obj-$(CONFIG_BLK_DEV_IDE_RAPIDE) += rapide.o
+obj-$(CONFIG_BLK_DEV_IDE_RISCSTATION) += rstation-ide.o
EXTRA_CFLAGS := -I../
diff -urN linux-2.4.26/drivers/ide/arm/icside.c linux-2.4.26-vrs1/drivers/ide/arm/icside.c
--- linux-2.4.26/drivers/ide/arm/icside.c 2003-06-13 15:51:33.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ide/arm/icside.c 2004-01-14 21:32:25.000000000 +0000
@@ -1,7 +1,7 @@
/*
* linux/drivers/ide/arm/icside.c
*
- * Copyright (c) 1996,1997 Russell King.
+ * Copyright (c) 1996-2003 Russell King.
*
* Changelog:
* 08-Jun-1996 RMK Created
@@ -26,24 +26,6 @@
#include <asm/ecard.h>
#include <asm/io.h>
-#include "ide-noise.h"
-
-/*
- * FIXME: We want to drop the the MACRO CRAP!
- *
- * ec->iops->in{b/w/l}
- * ec->iops->in{b/w/l}_p
- * ec->iops->out{b/w/l}
- * ec->iops->out{b/w/l}_p
- *
- * the new core supports clean MMIO calls and other goodies
- */
-
-/*
- * Maximum number of interfaces per card
- */
-#define MAX_IFS 2
-
#define ICS_IDENT_OFFSET 0x8a0
#define ICS_ARCIN_V5_INTRSTAT 0x000
@@ -86,17 +68,20 @@
ICS_ARCIN_V6_IDESTEPPING
};
-static const card_ids icside_cids[] = {
- { MANU_ICS, PROD_ICS_IDE },
- { MANU_ICS2, PROD_ICS2_IDE },
- { 0xffff, 0xffff }
+struct icside_state {
+ unsigned int channel;
+ unsigned int enabled;
+ unsigned long irq_port;
+ unsigned long slot_port;
+ unsigned int type;
+ ide_hwif_t *hwif[2];
};
-typedef enum {
- ics_if_unknown,
- ics_if_arcin_v5,
- ics_if_arcin_v6
-} iftype_t;
+#define ICS_TYPE_A3IN 0
+#define ICS_TYPE_A3USER 1
+#define ICS_TYPE_V6 3
+#define ICS_TYPE_V5 15
+#define ICS_TYPE_NOTYPE ((unsigned int)-1)
/* ---------------- Version 5 PCB Support Functions --------------------- */
/* Prototype: icside_irqenable_arcin_v5 (struct expansion_card *ec, int irqnr)
@@ -104,8 +89,10 @@
*/
static void icside_irqenable_arcin_v5 (struct expansion_card *ec, int irqnr)
{
- unsigned int memc_port = (unsigned int)ec->irq_data;
- outb(0, memc_port + ICS_ARCIN_V5_INTROFFSET);
+ struct icside_state *state = ec->irq_data;
+ unsigned int base = state->irq_port;
+
+ outb(0, base + ICS_ARCIN_V5_INTROFFSET);
}
/* Prototype: icside_irqdisable_arcin_v5 (struct expansion_card *ec, int irqnr)
@@ -113,17 +100,15 @@
*/
static void icside_irqdisable_arcin_v5 (struct expansion_card *ec, int irqnr)
{
- unsigned int memc_port = (unsigned int)ec->irq_data;
- inb(memc_port + ICS_ARCIN_V5_INTROFFSET);
+ struct icside_state *state = ec->irq_data;
+ unsigned int base = state->irq_port;
+
+ inb(base + ICS_ARCIN_V5_INTROFFSET);
}
static const expansioncard_ops_t icside_ops_arcin_v5 = {
- icside_irqenable_arcin_v5,
- icside_irqdisable_arcin_v5,
- NULL,
- NULL,
- NULL,
- NULL
+ .irqenable = icside_irqenable_arcin_v5,
+ .irqdisable = icside_irqdisable_arcin_v5,
};
@@ -133,10 +118,21 @@
*/
static void icside_irqenable_arcin_v6 (struct expansion_card *ec, int irqnr)
{
- unsigned int ide_base_port = (unsigned int)ec->irq_data;
+ struct icside_state *state = ec->irq_data;
+ unsigned int base = state->irq_port;
+
+ state->enabled = 1;
- outb(0, ide_base_port + ICS_ARCIN_V6_INTROFFSET_1);
- outb(0, ide_base_port + ICS_ARCIN_V6_INTROFFSET_2);
+ switch (state->channel) {
+ case 0:
+ outb(0, base + ICS_ARCIN_V6_INTROFFSET_1);
+ inb(base + ICS_ARCIN_V6_INTROFFSET_2);
+ break;
+ case 1:
+ outb(0, base + ICS_ARCIN_V6_INTROFFSET_2);
+ inb(base + ICS_ARCIN_V6_INTROFFSET_1);
+ break;
+ }
}
/* Prototype: icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
@@ -144,10 +140,12 @@
*/
static void icside_irqdisable_arcin_v6 (struct expansion_card *ec, int irqnr)
{
- unsigned int ide_base_port = (unsigned int)ec->irq_data;
+ struct icside_state *state = ec->irq_data;
+
+ state->enabled = 0;
- inb(ide_base_port + ICS_ARCIN_V6_INTROFFSET_1);
- inb(ide_base_port + ICS_ARCIN_V6_INTROFFSET_2);
+ inb (state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+ inb (state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
}
/* Prototype: icside_irqprobe(struct expansion_card *ec)
@@ -155,70 +153,49 @@
*/
static int icside_irqpending_arcin_v6(struct expansion_card *ec)
{
- unsigned int ide_base_port = (unsigned int)ec->irq_data;
+ struct icside_state *state = ec->irq_data;
- return inb(ide_base_port + ICS_ARCIN_V6_INTRSTAT_1) & 1 ||
- inb(ide_base_port + ICS_ARCIN_V6_INTRSTAT_2) & 1;
+ return inb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_1) & 1 ||
+ inb(state->irq_port + ICS_ARCIN_V6_INTRSTAT_2) & 1;
}
static const expansioncard_ops_t icside_ops_arcin_v6 = {
- icside_irqenable_arcin_v6,
- icside_irqdisable_arcin_v6,
- icside_irqpending_arcin_v6,
- NULL,
- NULL,
- NULL
+ .irqenable = icside_irqenable_arcin_v6,
+ .irqdisable = icside_irqdisable_arcin_v6,
+ .irqpending = icside_irqpending_arcin_v6,
};
-/* Prototype: icside_identifyif (struct expansion_card *ec)
- * Purpose : identify IDE interface type
- * Notes : checks the description string
+/*
+ * Handle routing of interrupts. This is called before
+ * we write the command to the drive.
*/
-static iftype_t __init icside_identifyif (struct expansion_card *ec)
+static void icside_maskproc(ide_drive_t *drive, int mask)
{
- unsigned int addr;
- iftype_t iftype;
- int id = 0;
-
- iftype = ics_if_unknown;
-
- addr = ecard_address (ec, ECARD_IOC, ECARD_FAST) + ICS_IDENT_OFFSET;
-
- id = inb(addr) & 1;
- id |= (inb(addr + 1) & 1) << 1;
- id |= (inb(addr + 2) & 1) << 2;
- id |= (inb(addr + 3) & 1) << 3;
-
- switch (id) {
- case 0: /* A3IN */
- printk("icside: A3IN unsupported\n");
- break;
-
- case 1: /* A3USER */
- printk("icside: A3USER unsupported\n");
- break;
+ ide_hwif_t *hwif = HWIF(drive);
+ struct icside_state *state = hwif->hwif_data;
+ unsigned long flags;
- case 3: /* ARCIN V6 */
- printk(KERN_DEBUG "icside: detected ARCIN V6 in slot %d\n", ec->slot_no);
- iftype = ics_if_arcin_v6;
- break;
+ local_irq_save(flags);
- case 15:/* ARCIN V5 (no id) */
- printk(KERN_DEBUG "icside: detected ARCIN V5 in slot %d\n", ec->slot_no);
- iftype = ics_if_arcin_v5;
- break;
+ state->channel = hwif->channel;
- default:/* we don't know - complain very loudly */
- printk("icside: ***********************************\n");
- printk("icside: *** UNKNOWN ICS INTERFACE id=%d ***\n", id);
- printk("icside: ***********************************\n");
- printk("icside: please report this to linux@arm.linux.org.uk\n");
- printk("icside: defaulting to ARCIN V5\n");
- iftype = ics_if_arcin_v5;
- break;
+ if (state->enabled && !mask) {
+ switch (hwif->channel) {
+ case 0:
+ outb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+ inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+ break;
+ case 1:
+ outb(0, state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+ inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+ break;
+ }
+ } else {
+ inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+ inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
}
- return iftype;
+ local_irq_restore(flags);
}
#ifdef CONFIG_BLK_DEV_IDEDMA_ICS
@@ -234,125 +211,138 @@
#define NR_ENTRIES 256
#define TABLE_SIZE (NR_ENTRIES * 8)
-static int ide_build_sglist(ide_hwif_t *hwif, struct request *rq)
+static void ide_build_sglist(ide_drive_t *drive, struct request *rq)
{
- struct buffer_head *bh;
+ ide_hwif_t *hwif = HWIF(drive);
struct scatterlist *sg = hwif->sg_table;
+ struct buffer_head *bh;
int nents = 0;
- if (rq->cmd == READ)
- hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
- else
- hwif->sg_dma_direction = PCI_DMA_TODEVICE;
- bh = rq->bh;
- do {
- unsigned char *virt_addr = bh->b_data;
- unsigned int size = bh->b_size;
-
- while ((bh = bh->b_reqnext) != NULL) {
- if ((virt_addr + size) != (unsigned char *)bh->b_data)
- break;
- size += bh->b_size;
- }
- memset(&sg[nents], 0, sizeof(*sg));
- sg[nents].address = virt_addr;
- sg[nents].length = size;
- nents++;
- } while (bh != NULL);
+ BUG_ON(hwif->sg_dma_active);
- return pci_map_sg(NULL, sg, nents, hwif->sg_dma_direction);
-}
+ if (rq->cmd == IDE_DRIVE_TASKFILE) {
+ ide_task_t *args = rq->special;
-static int
-icside_build_dmatable(ide_drive_t *drive, int ddir)
-{
- return HWIF(drive)->sg_nents = ide_build_sglist(HWIF(drive), HWGROUP(drive)->rq, ddir);
-}
+ if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
+ hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
+ else
+ hwif->sg_dma_direction = PCI_DMA_TODEVICE;
+
+ memset(sg, 0, sizeof(*sg));
+ sg->address = rq->buffer;
+ sg->length = rq->nr_sectors * SECTOR_SIZE;
+ nents = 1;
+ } else {
+ if (rq->cmd == READ)
+ hwif->sg_dma_direction = PCI_DMA_FROMDEVICE;
+ else
+ hwif->sg_dma_direction = PCI_DMA_TODEVICE;
+
+ bh = rq->bh;
+ do {
+ unsigned long lastend;
+
+ memset(sg, 0, sizeof(*sg));
+ sg->page = bh->b_page;
+ lastend = bh_phys(bh);
+
+ do {
+ lastend += bh->b_size;
+ sg->length += bh->b_size;
+
+ bh = bh->b_reqnext;
+ if (bh == NULL)
+ break;
+ } while (lastend == bh_phys(bh));
+
+ sg++;
+ nents++;
+ } while (bh != NULL);
+ }
-/* Teardown mappings after DMA has completed. */
-static void icside_destroy_dmatable(ide_drive_t *drive)
-{
- struct scatterlist *sg = HWIF(drive)->sg_table;
- int nents = HWIF(drive)->sg_nents;
+ nents = pci_map_sg(NULL, sg, nents, hwif->sg_dma_direction);
- pci_unmap_sg(NULL, sg, nents, HWIF(drive)->sg_dma_direction);
+ hwif->sg_nents = nents;
}
-static int
-icside_config_if(ide_drive_t *drive, int xfer_mode)
+
+/*
+ * Configure the IOMD to give the appropriate timings for the transfer
+ * mode being requested. We take the advice of the ATA standards, and
+ * calculate the cycle time based on the transfer mode, and the EIDE
+ * MW DMA specs that the drive provides in the IDENTIFY command.
+ *
+ * We have the following IOMD DMA modes to choose from:
+ *
+ * Type Active Recovery Cycle
+ * A 250 (250) 312 (550) 562 (800)
+ * B 187 250 437
+ * C 125 (125) 125 (375) 250 (500)
+ * D 62 125 187
+ *
+ * (figures in brackets are actual measured timings)
+ *
+ * However, we also need to take care of the read/write active and
+ * recovery timings:
+ *
+ * Read Write
+ * Mode Active -- Recovery -- Cycle IOMD type
+ * MW0 215 50 215 480 A
+ * MW1 80 50 50 150 C
+ * MW2 70 25 25 120 C
+ */
+static int icside_set_speed(ide_drive_t *drive, u8 xfer_mode)
{
- int func = ide_dma_off;
+ int on = 0, cycle_time = 0, use_dma_info = 0;
+
+ /*
+ * Limit the transfer speed to MW_DMA_2.
+ */
+ if (xfer_mode > XFER_MW_DMA_2)
+ xfer_mode = XFER_MW_DMA_2;
switch (xfer_mode) {
case XFER_MW_DMA_2:
- /*
- * The cycle time is limited to 250ns by the r/w
- * pulse width (90ns), however we should still
- * have a maximum burst transfer rate of 8MB/s.
- */
- drive->drive_data = 250;
+ cycle_time = 250;
+ use_dma_info = 1;
break;
case XFER_MW_DMA_1:
- drive->drive_data = 250;
+ cycle_time = 250;
+ use_dma_info = 1;
break;
case XFER_MW_DMA_0:
- drive->drive_data = 480;
+ cycle_time = 480;
break;
- default:
- drive->drive_data = 0;
+ case XFER_SW_DMA_2:
+ case XFER_SW_DMA_1:
+ case XFER_SW_DMA_0:
+ cycle_time = 480;
break;
}
- if (!drive->init_speed)
- drive->init_speed = (u8) xfer_mode;
+ /*
+ * If we're going to be doing MW_DMA_1 or MW_DMA_2, we should
+ * take care to note the values in the ID...
+ */
+ if (use_dma_info && drive->id->eide_dma_time > cycle_time)
+ cycle_time = drive->id->eide_dma_time;
+
+ drive->drive_data = cycle_time;
- if (drive->drive_data &&
- ide_config_drive_speed(drive, (u8) xfer_mode) == 0)
- func = ide_dma_on;
+ if (cycle_time && ide_config_drive_speed(drive, xfer_mode) == 0)
+ on = 1;
else
drive->drive_data = 480;
printk("%s: %s selected (peak %dMB/s)\n", drive->name,
ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data);
- drive->current_speed = (u8) xfer_mode;
-
- return func;
-}
-
-static int
-icside_set_speed(ide_drive_t *drive, u8 speed)
-{
- return icside_config_if(drive, speed);
-}
-
-/*
- * dma_intr() is the handler for disk read/write DMA interrupts
- */
-static ide_startstop_t icside_dmaintr(ide_drive_t *drive)
-{
- u8 dma_stat = HWIF(drive)->ide_dma_end(drive);
- /* get drive status */
- u8 stat = HWIF(drive)->INB(IDE_STATUS_REG);
- int i;
+ drive->current_speed = xfer_mode;
- if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
- if (!dma_stat) {
- struct request *rq = HWGROUP(drive)->rq;
- rq = HWGROUP(drive)->rq;
- for (i = rq->nr_sectors; i > 0;) {
- i -= rq->current_nr_sectors;
- DRIVER(drive)->end_request(drive, 1);
- }
- return ide_stopped;
- }
- printk("%s: dma_intr: bad DMA status (dma_stat=%x)\n",
- drive->name, dma_stat);
- }
- return DRIVER(drive)->error(drive, "dma_intr", stat);
+ return on;
}
/*
@@ -361,19 +351,19 @@
* This should be defined in one place only.
*/
struct drive_list_entry {
- char * id_model;
- char * id_firmware;
+ const char * id_model;
+ const char * id_firmware;
};
-static struct drive_list_entry drive_whitelist [] = {
+static const struct drive_list_entry drive_whitelist [] = {
{ "Micropolis 2112A", "ALL" },
{ "CONNER CTMA 4000", "ALL" },
{ "CONNER CTT8000-A", "ALL" },
{ "ST34342A", "ALL" },
- { NULL, 0 }
+ { NULL, NULL }
};
-static struct drive_list_entry drive_blacklist [] = {
+static const struct drive_list_entry drive_blacklist [] = {
{ "WDC AC11000H", "ALL" },
{ "WDC AC22100H", "ALL" },
{ "WDC AC32500H", "ALL" },
@@ -407,10 +397,11 @@
{ "PLEXTOR CD-R PX-W8432T", "ALL" },
{ "ATAPI CD-ROM DRIVE 40X MAXIMUM", "ALL" },
{ "_NEC DV5800A", "ALL" },
- { NULL, 0 }
+ { NULL, NULL }
};
-static int in_drive_list(struct hd_driveid *id, struct drive_list_entry * drive_table)
+static int
+in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table)
{
for ( ; drive_table->id_model ; drive_table++)
if ((!strcmp(drive_table->id_model, id->model)) &&
@@ -420,41 +411,52 @@
return 0;
}
-/*
- * For both Blacklisted and Whitelisted drives.
- * This is setup to be called as an extern for future support
- * to other special driver code.
- */
-int check_drive_good_lists (ide_drive_t *drive)
+static int icside_dma_host_off(ide_drive_t *drive)
{
- struct hd_driveid *id = drive->id;
- return in_drive_list(id, drive_whitelist);
+ return 0;
}
-int check_drive_bad_lists (ide_drive_t *drive)
+static int icside_dma_off_quietly(ide_drive_t *drive)
{
- struct hd_driveid *id = drive->id;
- int blacklist = in_drive_list(id, drive_blacklist);
- if (blacklist)
- printk("%s: Disabling DMA for %s\n", drive->name, id->model);
- return(blacklist);
+ drive->using_dma = 0;
+ return icside_dma_host_off(drive);
+}
+
+static int icside_dma_off(ide_drive_t *drive)
+{
+ printk("%s: DMA disabled\n", drive->name);
+ return icside_dma_off_quietly(drive);
+}
+
+static int icside_dma_host_on(ide_drive_t *drive)
+{
+ return 0;
}
-int icside_dma_check(ide_drive_t *drive)
+static int icside_dma_on(ide_drive_t *drive)
+{
+ drive->using_dma = 1;
+ return icside_dma_host_on(drive);
+}
+
+static int icside_dma_check(ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
ide_hwif_t *hwif = HWIF(drive);
- int autodma = hwif->autodma;
int xfer_mode = XFER_PIO_2;
+ int on;
- if (!id || !(id->capability & 1) || !autodma)
- return hwif->ide_dma_off_quietly(drive);
+ if (!id || !(id->capability & 1) || !hwif->autodma)
+ goto out;
/*
* Consult the list of known "bad" drives
*/
- if (check_drive_bad_lists(drive))
- return hwif->ide_dma_off(drive);
+ if (in_drive_list(id, drive_blacklist)) {
+ printk("%s: Disabling DMA for %s (blacklisted)\n",
+ drive->name, id->model);
+ goto out;
+ }
/*
* Enable DMA on any drive that has multiword DMA
@@ -473,192 +475,241 @@
/*
* Consult the list of known "good" drives
*/
- if (check_drive_good_lists(drive)) {
+ if (in_drive_list(id, drive_whitelist)) {
if (id->eide_dma_time > 150)
goto out;
xfer_mode = XFER_MW_DMA_1;
}
out:
- if (icside_config_if(drive, xfer_mode))
- return hwif->ide_dma_on(drive);
- return hwif->ide_dma_off(drive);
-}
+ on = icside_set_speed(drive, xfer_mode);
-int icside_dma_verbose(ide_drive_t *drive)
-{
- printk(", DMA");
- return 1;
+ if (on)
+ return icside_dma_on(drive);
+ else
+ return icside_dma_off(drive);
}
-int icside_dma_test_irq(ide_drive_t *drive)
+static int icside_dma_end(ide_drive_t *drive)
{
ide_hwif_t *hwif = HWIF(drive);
- return inb((unsigned long)hwif->hw.priv) & 1;
-}
-int icside_dma_host_off(ide_drive_t *drive)
-{
- return 0;
-}
+ drive->waiting_for_dma = 0;
-int icside_dma_off_quietly(ide_drive_t *drive)
-{
- drive->using_dma = 0;
- return icside_dma_host_off(drive);
-}
+ disable_dma(hwif->hw.dma);
-int icside_dma_off(ide_drive_t *drive)
-{
- printk("%s: DMA disabled\n", drive->name);
- return icside_dma_off_quietly(drive);
-}
+ /* Teardown mappings after DMA has completed. */
+ pci_unmap_sg(NULL, hwif->sg_table, hwif->sg_nents,
+ hwif->sg_dma_direction);
-int icside_dma_host_on(ide_drive_t *drive)
-{
- return 0;
-}
+ hwif->sg_dma_active = 0;
-int icside_dma_on(ide_drive_t *drive)
-{
- drive->using_dma = 1;
- return icside_dma_host_on(drive);
+ return get_dma_residue(hwif->hw.dma) != 0;
}
-int icside_dma_begin(ide_drive_t *drive)
+static int icside_dma_begin(ide_drive_t *drive)
{
ide_hwif_t *hwif = HWIF(drive);
+ /* We can not enable DMA on both channels simultaneously. */
+ BUG_ON(dma_channel_active(hwif->hw.dma));
enable_dma(hwif->hw.dma);
return 0;
}
-int icside_dma_end(ide_drive_t *drive)
+static int icside_dma_count(ide_drive_t *drive)
{
- ide_hwif_t *hwif = HWIF(drive);
-
- drive->waiting_for_dma = 0;
- disable_dma(hwif->hw.dma);
- icside_destroy_dmatable(drive);
- return get_dma_residue(hwif->hw.dma) != 0;
+ return icside_dma_begin(drive);
}
-int icside_dma_count (ide_drive_t *drive)
+/*
+ * dma_intr() is the handler for disk read/write DMA interrupts
+ */
+static ide_startstop_t icside_dmaintr(ide_drive_t *drive)
{
- return icside_dma_begin(drive);
+ unsigned int stat;
+ int dma_stat;
+
+ dma_stat = icside_dma_end(drive);
+ stat = HWIF(drive)->INB(IDE_STATUS_REG);
+ if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | DRQ_STAT)) {
+ if (!dma_stat) {
+ struct request *rq = HWGROUP(drive)->rq;
+ int i;
+
+ for (i = rq->nr_sectors; i > 0; ) {
+ i -= rq->current_nr_sectors;
+ DRIVER(drive)->end_request(drive, 1);
+ }
+
+ return ide_stopped;
+ }
+ printk(KERN_ERR "%s: bad DMA status (dma_stat=%x)\n",
+ drive->name, dma_stat);
+ }
+
+ return DRIVER(drive)->error(drive, __FUNCTION__, stat);
}
-int icside_dma_read(ide_drive_t *drive)
+static int
+icside_dma_common(ide_drive_t *drive, struct request *rq,
+ unsigned int dma_mode)
{
- ide_hwif_t *hwif = HWIF(drive);
-// ide_task_t *args = HWGROUP(drive)->rq->special;
- int count = 0;
- u8 lba48 = (drive->addressing == 1) ? 1 : 0;
- task_ioreg_t command = WIN_NOP;
+ ide_hwif_t *hwif = HWIF(drive);
- count = icside_build_dmatable(drive, PCI_DMA_FROMDEVICE);
- if (!count)
- return 1;
- disable_dma(hwif->hw.dma);
+ /*
+ * We can not enable DMA on both channels.
+ */
+ BUG_ON(hwif->sg_dma_active);
+ BUG_ON(dma_channel_active(hwif->hw.dma));
+
+ ide_build_sglist(drive, rq);
- /* Route the DMA signals to
- * to the correct interface.
+ /*
+ * Ensure that we have the right interrupt routed.
*/
- HWIF(drive)->OUTB(hwif->select_data, hwif->config_data);
+ icside_maskproc(drive, 0);
- /* Select the correct timing
- * for this drive
+ /*
+ * Route the DMA signals to the correct interface.
+ */
+ outb(hwif->select_data, hwif->config_data);
+
+ /*
+ * Select the correct timing for this drive.
*/
set_dma_speed(hwif->hw.dma, drive->drive_data);
- set_dma_sg(hwif->hw.dma, HWIF(drive)->sg_table, count);
- set_dma_mode(hwif->hw.dma, DMA_MODE_READ);
+ /*
+ * Tell the DMA engine about the SG table and
+ * data direction.
+ */
+ set_dma_sg(hwif->hw.dma, hwif->sg_table, hwif->sg_nents);
+ set_dma_mode(hwif->hw.dma, dma_mode);
+
+ return 0;
+}
+
+static int icside_dma_read(ide_drive_t *drive)
+{
+ struct request *rq = HWGROUP(drive)->rq;
+ task_ioreg_t cmd;
+
+ if (icside_dma_common(drive, rq, DMA_MODE_READ))
+ return 1;
drive->waiting_for_dma = 1;
+
if (drive->media != ide_disk)
return 0;
- if (HWGROUP(drive)->handler != NULL) /* paranoia check */
- BUG();
- ide_set_handler(drive, &icside_dmaintr, WAIT_CMD, NULL);
/*
* FIX ME to use only ACB ide_task_t args Struct
*/
#if 0
{
- ide_task_t *args = HWGROUP(drive)->rq->special;
- command = args->tfRegister[IDE_COMMAND_OFFSET];
+ ide_task_t *args = rq->special;
+ cmd = args->tfRegister[IDE_COMMAND_OFFSET];
}
#else
- command = (lba48) ? WIN_READDMA_EXT : WIN_READDMA;
- if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE) {
- ide_task_t *args = HWGROUP(drive)->rq->special;
- command = args->tfRegister[IDE_COMMAND_OFFSET];
+ if (rq->cmd == IDE_DRIVE_TASKFILE) {
+ ide_task_t *args = rq->special;
+ cmd = args->tfRegister[IDE_COMMAND_OFFSET];
+ } else if (drive->addressing == 1) {
+ cmd = WIN_READDMA_EXT;
+ } else {
+ cmd = WIN_READDMA;
}
#endif
- /* issue cmd to drive */
- HWIF(drive)->OUTB(command, IDE_COMMAND_REG);
- return icside_dma_count(drive);
+ ide_execute_command(drive, cmd, icside_dmaintr, 2*WAIT_CMD, NULL);
+
+ return icside_dma_begin(drive);
}
-int icside_dma_write(ide_drive_t *drive)
+static int icside_dma_write(ide_drive_t *drive)
{
- ide_hwif_t *hwif = HWIF(drive);
-// ide_task_t *args = HWGROUP(drive)->rq->special;
- int count = 0;
- u8 lba48 = (drive->addressing == 1) ? 1 : 0;
- task_ioreg_t command = WIN_NOP;
+ struct request *rq = HWGROUP(drive)->rq;
+ task_ioreg_t cmd;
- count = icside_build_dmatable(drive, PCI_DMA_TODEVICE);
- if (!count)
+ if (icside_dma_common(drive, rq, DMA_MODE_WRITE))
return 1;
- disable_dma(hwif->hw.dma);
-
- /* Route the DMA signals to
- * to the correct interface.
- */
- HWIF(drive)->OUTB(hwif->select_data, hwif->config_data);
-
- /* Select the correct timing
- * for this drive
- */
- set_dma_speed(hwif->hw.dma, drive->drive_data);
-
- set_dma_sg(hwif->hw.dma, HWIF(drive)->sg_table, count);
- set_dma_mode(hwif->hw.dma, DMA_MODE_WRITE);
drive->waiting_for_dma = 1;
+
if (drive->media != ide_disk)
return 0;
- if (HWGROUP(drive)->handler != NULL)
- BUG();
- ide_set_handler(drive, &icside_dmaintr, WAIT_CMD, NULL);
/*
* FIX ME to use only ACB ide_task_t args Struct
*/
#if 0
{
- ide_task_t *args = HWGROUP(drive)->rq->special;
- command = args->tfRegister[IDE_COMMAND_OFFSET];
+ ide_task_t *args = rq->special;
+ cmd = args->tfRegister[IDE_COMMAND_OFFSET];
}
#else
- command = (lba48) ? WIN_WRITEDMA_EXT : WIN_WRITEDMA;
- if (HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE) {
- ide_task_t *args = HWGROUP(drive)->rq->special;
- command = args->tfRegister[IDE_COMMAND_OFFSET];
+ if (rq->cmd == IDE_DRIVE_TASKFILE) {
+ ide_task_t *args = rq->special;
+ cmd = args->tfRegister[IDE_COMMAND_OFFSET];
+ } else if (drive->addressing == 1) {
+ cmd = WIN_WRITEDMA_EXT;
+ } else {
+ cmd = WIN_WRITEDMA;
}
#endif
- /* issue cmd to drive */
- HWIF(drive)->OUTB(command, IDE_COMMAND_REG);
- return icside_dma_count(drive);
+ ide_execute_command(drive, cmd, icside_dmaintr, 2*WAIT_CMD, NULL);
+
+ return icside_dma_begin(drive);
}
-static int
-icside_setup_dma(ide_hwif_t *hwif, int autodma)
+static int icside_dma_test_irq(ide_drive_t *drive)
+{
+ ide_hwif_t *hwif = HWIF(drive);
+ struct icside_state *state = hwif->hwif_data;
+
+ return inb(state->irq_port +
+ (hwif->channel ?
+ ICS_ARCIN_V6_INTRSTAT_2 :
+ ICS_ARCIN_V6_INTRSTAT_1)) & 1;
+}
+
+static int icside_dma_verbose(ide_drive_t *drive)
+{
+ printk(", %s (peak %dMB/s)",
+ ide_xfer_verbose(drive->current_speed),
+ 2000 / drive->drive_data);
+ return 1;
+}
+
+static int icside_dma_timeout(ide_drive_t *drive)
+{
+ printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name);
+
+ if (icside_dma_test_irq(drive))
+ return 0;
+
+ ide_dump_status(drive, "DMA timeout",
+ HWIF(drive)->INB(IDE_STATUS_REG));
+
+ return icside_dma_end(drive);
+}
+
+static int icside_dma_lostirq(ide_drive_t *drive)
+{
+ printk(KERN_ERR "%s: IRQ lost\n", drive->name);
+ return 1;
+}
+
+static int icside_dma_init(ide_hwif_t *hwif)
{
+ int autodma = 0;
+
+#ifdef CONFIG_IDEDMA_ICS_AUTO
+ autodma = 1;
+#endif
+
printk(" %s: SG-DMA", hwif->name);
hwif->sg_table = kmalloc(sizeof(struct scatterlist) * NR_ENTRIES,
@@ -666,40 +717,53 @@
if (!hwif->sg_table)
goto failed;
- hwif->dmatable_cpu = NULL;
- hwif->dmatable_dma = 0;
- hwif->speedproc = icside_set_speed;
- hwif->autodma = autodma;
+ hwif->atapi_dma = 1;
+ hwif->mwdma_mask = 7; /* MW0..2 */
+ hwif->swdma_mask = 7; /* SW0..2 */
+
+ hwif->dmatable_cpu = NULL;
+ hwif->dmatable_dma = 0;
+ hwif->speedproc = icside_set_speed;
+ hwif->autodma = autodma;
- hwif->ide_dma_check = icside_dma_check;
- hwif->ide_dma_host_off = icside_dma_host_off;
+ hwif->ide_dma_check = icside_dma_check;
+ hwif->ide_dma_host_off = icside_dma_host_off;
hwif->ide_dma_off_quietly = icside_dma_off_quietly;
- hwif->ide_dma_off = icside_dma_off;
- hwif->ide_dma_host_on = icside_dma_host_on;
- hwif->ide_dma_on = icside_dma_on;
- hwif->ide_dma_read = icside_dma_read;
- hwif->ide_dma_write = icside_dma_write;
- hwif->ide_dma_count = icside_dma_count;
- hwif->ide_dma_begin = icside_dma_begin;
- hwif->ide_dma_end = icside_dma_end;
- hwif->ide_dma_verbose = icside_dma_verbose;
- hwif->ide_dma_bad_drive = check_drive_bad_lists;
- hwif->ide_dma_good_drive = check_drive_good_lists;
- hwif->ide_dma_test_irq = icside_dma_test_irq;
+ hwif->ide_dma_off = icside_dma_off;
+ hwif->ide_dma_host_on = icside_dma_host_on;
+ hwif->ide_dma_on = icside_dma_on;
+ hwif->ide_dma_read = icside_dma_read;
+ hwif->ide_dma_write = icside_dma_write;
+ hwif->ide_dma_count = icside_dma_count;
+ hwif->ide_dma_begin = icside_dma_begin;
+ hwif->ide_dma_end = icside_dma_end;
+ hwif->ide_dma_test_irq = icside_dma_test_irq;
+ hwif->ide_dma_verbose = icside_dma_verbose;
+ hwif->ide_dma_timeout = icside_dma_timeout;
+ hwif->ide_dma_lostirq = icside_dma_lostirq;
- printk(" capable%s\n", autodma ?
- ", auto-enable" : "");
+ printk(" capable%s\n", hwif->autodma ? ", auto-enable" : "");
return 1;
failed:
- printk(" -- ERROR, unable to allocate DMA table\n");
+ printk(" disabled, unable to allocate DMA table\n");
return 0;
}
+
+static void icside_dma_exit(ide_hwif_t *hwif)
+{
+ if (hwif->sg_table) {
+ kfree(hwif->sg_table);
+ hwif->sg_table = NULL;
+ }
+}
+#else
+#define icside_dma_init(hwif) (0)
+#define icside_dma_exit(hwif) do { } while (0)
#endif
-static ide_hwif_t *
-icside_find_hwif(unsigned long dataport)
+static ide_hwif_t *icside_find_hwif(unsigned long dataport)
{
ide_hwif_t *hwif;
int index;
@@ -716,13 +780,13 @@
goto found;
}
- return NULL;
+ hwif = NULL;
found:
return hwif;
}
static ide_hwif_t *
-icside_setup(unsigned long base, struct cardinfo *info, int irq)
+icside_setup(unsigned long base, struct cardinfo *info, struct expansion_card *ec)
{
unsigned long port = base + info->dataoffset;
ide_hwif_t *hwif;
@@ -740,8 +804,8 @@
}
hwif->hw.io_ports[IDE_CONTROL_OFFSET] = base + info->ctrloffset;
hwif->io_ports[IDE_CONTROL_OFFSET] = base + info->ctrloffset;
- hwif->hw.irq = irq;
- hwif->irq = irq;
+ hwif->hw.irq = ec->irq;
+ hwif->irq = ec->irq;
hwif->hw.dma = NO_DMA;
hwif->noprobe = 0;
hwif->chipset = ide_acorn;
@@ -750,33 +814,39 @@
return hwif;
}
-static int __init icside_register_v5(struct expansion_card *ec, int autodma)
+static int __init
+icside_register_v5(struct icside_state *state, struct expansion_card *ec)
{
unsigned long slot_port;
ide_hwif_t *hwif;
slot_port = ecard_address(ec, ECARD_MEMC, 0);
+ state->irq_port = slot_port;
+
ec->irqaddr = (unsigned char *)ioaddr(slot_port + ICS_ARCIN_V5_INTRSTAT);
ec->irqmask = 1;
- ec->irq_data = (void *)slot_port;
- ec->ops = (expansioncard_ops_t *)&icside_ops_arcin_v5;
+ ec->irq_data = state;
+ ec->ops = &icside_ops_arcin_v5;
/*
* Be on the safe side - disable interrupts
*/
inb(slot_port + ICS_ARCIN_V5_INTROFFSET);
- hwif = icside_setup(slot_port, &icside_cardinfo_v5, ec->irq);
+ hwif = icside_setup(slot_port, &icside_cardinfo_v5, ec);
- return hwif ? 0 : -1;
+ state->hwif[0] = hwif;
+
+ return hwif ? 0 : -ENODEV;
}
-static int __init icside_register_v6(struct expansion_card *ec, int autodma)
+static int __init
+icside_register_v6(struct icside_state *state, struct expansion_card *ec)
{
unsigned long slot_port, port;
ide_hwif_t *hwif, *mate;
- int sel = 0;
+ unsigned int sel = 0;
slot_port = ecard_address(ec, ECARD_IOC, ECARD_FAST);
port = ecard_address(ec, ECARD_EASI, ECARD_FAST);
@@ -788,88 +858,185 @@
outb(sel, slot_port);
- ec->irq_data = (void *)port;
- ec->ops = (expansioncard_ops_t *)&icside_ops_arcin_v6;
-
/*
* Be on the safe side - disable interrupts
*/
inb(port + ICS_ARCIN_V6_INTROFFSET_1);
inb(port + ICS_ARCIN_V6_INTROFFSET_2);
- hwif = icside_setup(port, &icside_cardinfo_v6_1, ec->irq);
- mate = icside_setup(port, &icside_cardinfo_v6_2, ec->irq);
+ /*
+ * Find and register the interfaces.
+ */
+ hwif = icside_setup(port, &icside_cardinfo_v6_1, ec);
+ mate = icside_setup(port, &icside_cardinfo_v6_2, ec);
+
+ if (!hwif || !mate)
+ return -ENODEV;
-#ifdef CONFIG_BLK_DEV_IDEDMA_ICS
- if (ec->dma != NO_DMA) {
- if (request_dma(ec->dma, hwif->name))
- goto no_dma;
-
- if (hwif) {
- hwif->config_data = slot_port;
- hwif->select_data = sel;
- hwif->hw.dma = ec->dma;
- hwif->hw.priv = (void *)
- (port + ICS_ARCIN_V6_INTRSTAT_1);
- hwif->channel = 0;
- icside_setup_dma(hwif, autodma);
- hwif->drives[0].autodma = autodma;
- hwif->drives[1].autodma = autodma;
- }
- if (mate) {
- mate->config_data = slot_port;
- mate->select_data = sel | 1;
- mate->hw.dma = ec->dma;
- mate->hw.priv = (void *)
- (port + ICS_ARCIN_V6_INTRSTAT_2);
- mate->channel = 1;
- icside_setup_dma(mate, autodma);
- mate->drives[0].autodma = autodma;
- mate->drives[1].autodma = autodma;
- }
+ state->irq_port = port;
+ state->slot_port = slot_port;
+ state->hwif[0] = hwif;
+ state->hwif[1] = mate;
+
+ ec->irq_data = state;
+ ec->ops = &icside_ops_arcin_v6;
+
+ hwif->maskproc = icside_maskproc;
+ hwif->channel = 0;
+ hwif->hwif_data = state;
+ hwif->mate = mate;
+ hwif->serialized = 1;
+ hwif->config_data = slot_port;
+ hwif->select_data = sel;
+ hwif->hw.dma = ec->dma;
+
+ mate->maskproc = icside_maskproc;
+ mate->channel = 1;
+ mate->hwif_data = state;
+ mate->mate = hwif;
+ mate->serialized = 1;
+ mate->config_data = slot_port;
+ mate->select_data = sel | 1;
+ mate->hw.dma = ec->dma;
+
+ if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) {
+ icside_dma_init(hwif);
+ icside_dma_init(mate);
}
-no_dma:
-#endif
- return hwif || mate ? 0 : -1;
+ return 0;
}
-int __init icside_init(void)
+static int __init icside_probe(struct expansion_card *ec, const struct ecard_id *id)
{
- int autodma = 0;
+ struct icside_state *state;
+ int ret;
-#ifdef CONFIG_IDEDMA_ICS_AUTO
- autodma = 1;
-#endif
+ state = kmalloc(sizeof(struct icside_state), GFP_KERNEL);
+ if (!state) {
+ ret = -ENOMEM;
+ goto out;
+ }
- ecard_startfind ();
+ memset(state, 0, sizeof(struct icside_state));
+ state->type = ICS_TYPE_NOTYPE;
- do {
- struct expansion_card *ec;
- int result;
+ {
+ unsigned int addr = ecard_address (ec, ECARD_IOC, ECARD_FAST) + ICS_IDENT_OFFSET;
+ unsigned int type;
- ec = ecard_find(0, icside_cids);
- if (ec == NULL)
- break;
+ type = inb(addr) & 1;
+ type |= (inb(addr + 1) & 1) << 1;
+ type |= (inb(addr + 2) & 1) << 2;
+ type |= (inb(addr + 3) & 1) << 3;
- ecard_claim(ec);
+ state->type = type;
+ }
- switch (icside_identifyif(ec)) {
- case ics_if_arcin_v5:
- result = icside_register_v5(ec, autodma);
- break;
+ switch (state->type) {
+ case ICS_TYPE_A3IN:
+ printk(KERN_WARNING "icside: A3IN unsupported\n");
+ ret = -ENODEV;
+ break;
- case ics_if_arcin_v6:
- result = icside_register_v6(ec, autodma);
- break;
+ case ICS_TYPE_A3USER:
+ printk(KERN_WARNING "icside: A3USER unsupported\n");
+ ret = -ENODEV;
+ break;
- default:
- result = -1;
- break;
- }
+ case ICS_TYPE_V5:
+ ret = icside_register_v5(state, ec);
+ break;
- if (result)
- ecard_release(ec);
- } while (1);
+ case ICS_TYPE_V6:
+ ret = icside_register_v6(state, ec);
+ break;
- return 0;
+ default:
+ printk(KERN_WARNING "icside: unknown interface type\n");
+ ret = -ENODEV;
+ break;
+ }
+
+ if (ret == 0) {
+ ecard_set_drvdata(ec, state);
+ } else {
+ kfree(state);
+ }
+ out:
+ return ret;
+}
+
+static void __devexit icside_remove(struct expansion_card *ec)
+{
+ struct icside_state *state = ecard_get_drvdata(ec);
+
+ switch (state->type) {
+ case ICS_TYPE_V5:
+ /* FIXME: tell IDE to stop using the interface */
+
+ /* Disable interrupts */
+ inb(state->slot_port + ICS_ARCIN_V5_INTROFFSET);
+ break;
+
+ case ICS_TYPE_V6:
+ /* FIXME: tell IDE to stop using the interface */
+ icside_dma_exit(state->hwif[1]);
+ icside_dma_exit(state->hwif[0]);
+
+ if (ec->dma != NO_DMA)
+ free_dma(ec->dma);
+
+ /* Disable interrupts */
+ inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+ inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+
+ /* Reset the ROM pointer/EASI selection */
+ outb(0, state->slot_port);
+ break;
+ }
+
+ ecard_set_drvdata(ec, NULL);
+ ec->ops = NULL;
+ ec->irq_data = NULL;
+
+ kfree(state);
+}
+
+static void icside_shutdown(struct expansion_card *ec)
+{
+ struct icside_state *state = ecard_get_drvdata(ec);
+
+ switch (state->type) {
+ case ICS_TYPE_V5:
+ /* Disable interrupts */
+ inb(state->slot_port + ICS_ARCIN_V5_INTROFFSET);
+ break;
+
+ case ICS_TYPE_V6:
+ /* Disable interrupts */
+ inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_1);
+ inb(state->irq_port + ICS_ARCIN_V6_INTROFFSET_2);
+
+ /* Reset the ROM pointer/EASI selection */
+ outb(0, state->slot_port);
+ break;
+ }
+}
+
+static const struct ecard_id icside_ids[] = {
+ { MANU_ICS, PROD_ICS_IDE },
+ { MANU_ICS2, PROD_ICS2_IDE },
+ { 0xffff, 0xffff }
+};
+
+static struct ecard_driver icside_driver = {
+ .probe = icside_probe,
+ .remove = __devexit_p(icside_remove),
+ .shutdown = icside_shutdown,
+ .id_table = icside_ids,
+};
+
+int __init icside_init(void)
+{
+ return ecard_register_driver(&icside_driver);
}
diff -urN linux-2.4.26/drivers/ide/arm/rstation-ide.c linux-2.4.26-vrs1/drivers/ide/arm/rstation-ide.c
--- linux-2.4.26/drivers/ide/arm/rstation-ide.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ide/arm/rstation-ide.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,78 @@
+/*
+ * linux/drivers/ide/rs-ide.c
+ *
+ * Copyright (c) 2002 Ben Dooks
+ * Copyright (c) 2002 Simtec Electronics
+ *
+ * Simple RiscStation IDE support
+*/
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/blkdev.h>
+#include <linux/errno.h>
+#include <linux/ide.h>
+#include <linux/init.h>
+
+#include <asm/hardware/iomd.h>
+#include <asm/mach-types.h>
+#include <asm/io.h>
+
+#ifndef CONFIG_ARCH_RISCSTATION
+#error "compiling this code for non-riscstation hardware is dangerous!"
+#endif
+
+#define DRV_PREFIX "ide-rs"
+
+#define IRQ_PRI (40+3)
+#define IRQ_SEC (40+4)
+
+#define PORT_BASE ((0x2b800 - 0x10000) >> 2)
+#define SEC_OFF (0x400 >> 2)
+
+int __init rside_reg(unsigned long base, unsigned int irq);
+
+int __init rside_init(void)
+{
+ int iotcr;
+
+ if (!machine_is_riscstation()) {
+ printk(DRV_PREFIX ": hardware is not a RiscStation!\n");
+ return 0;
+ }
+
+ /* select correct area cycle time */
+
+ iotcr = inb(IOMD_IOTCR);
+ outb((iotcr & ~3) | 1, IOMD_IOTCR);
+
+ /* register h/w */
+
+ rside_reg(PORT_BASE, IRQ_PRI);
+ rside_reg(PORT_BASE + SEC_OFF, IRQ_SEC);
+
+ return 0;
+}
+
+
+int __init rside_reg(unsigned long port, unsigned int irq)
+{
+ unsigned long addr, i;
+ hw_regs_t hw;
+
+ hw.irq = irq;
+
+ addr = port;
+
+ for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
+ hw.io_ports[i] = (ide_ioreg_t)addr;
+ addr += 0x40 >> 2;
+ }
+
+ hw.io_ports[IDE_CONTROL_OFFSET] = port + ((0xb80 - 0x800) >> 2);
+
+ printk(DRV_PREFIX ": registering channel at %08lx, %08lx, irq %d\n",
+ port, hw.io_ports[IDE_CONTROL_OFFSET], irq);
+
+ return ide_register_hw(&hw, NULL);
+}
diff -urN linux-2.4.26/drivers/ide/ide-probe.c linux-2.4.26-vrs1/drivers/ide/ide-probe.c
--- linux-2.4.26/drivers/ide/ide-probe.c 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ide/ide-probe.c 2004-04-18 21:47:50.000000000 +0100
@@ -1297,11 +1297,11 @@
hwif->name, hwif->major);
return (hwif->present = 0);
}
-
+
if (init_irq(hwif)) {
int i = hwif->irq;
/*
- * It failed to initialise. Find the default IRQ for
+ * It failed to initialise. Find the default IRQ for
* this port and try that.
*/
if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) {
@@ -1319,7 +1319,7 @@
printk("%s: probed IRQ %d failed, using default.\n",
hwif->name, hwif->irq);
}
-
+
init_gendisk(hwif);
blk_dev[hwif->major].data = hwif;
blk_dev[hwif->major].queue = ide_get_queue;
diff -urN linux-2.4.26/drivers/ide/ide-proc.c linux-2.4.26-vrs1/drivers/ide/ide-proc.c
--- linux-2.4.26/drivers/ide/ide-proc.c 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ide/ide-proc.c 2004-04-18 21:47:50.000000000 +0100
@@ -425,6 +425,7 @@
case ide_cy82c693: name = "cy82c693"; break;
case ide_4drives: name = "4drives"; break;
case ide_pmac: name = "pmac"; break;
+ case ide_acorn: name = "acorn"; break;
default: name = "(unknown)"; break;
}
len = sprintf(page, "%s\n", name);
diff -urN linux-2.4.26/drivers/ide/ide.c linux-2.4.26-vrs1/drivers/ide/ide.c
--- linux-2.4.26/drivers/ide/ide.c 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/ide/ide.c 2004-02-23 13:36:30.000000000 +0000
@@ -218,23 +218,14 @@
static void init_hwif_data (unsigned int index)
{
unsigned int unit;
- hw_regs_t hw;
ide_hwif_t *hwif = &ide_hwifs[index];
/* bulk initialize hwif & drive info with zeros */
memset(hwif, 0, sizeof(ide_hwif_t));
- memset(&hw, 0, sizeof(hw_regs_t));
/* fill in any non-zero initial values */
hwif->index = index;
- ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, &hwif->irq);
- memcpy(&hwif->hw, &hw, sizeof(hw));
- memcpy(hwif->io_ports, hw.io_ports, sizeof(hw.io_ports));
- hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET];
-#ifdef CONFIG_BLK_DEV_HD
- if (hwif->io_ports[IDE_DATA_OFFSET] == HD_DATA)
- hwif->noprobe = 1; /* may be overridden by ide_setup() */
-#endif /* CONFIG_BLK_DEV_HD */
+ hwif->noprobe = 1;
hwif->major = ide_hwif_to_major[index];
hwif->name[0] = 'i';
hwif->name[1] = 'd';
@@ -276,6 +267,28 @@
}
/*
+ * Old compatability function - initialise ports using ide_default_io_base
+ */
+static void ide_old_init_default_hwifs(void)
+{
+ unsigned int index;
+ ide_ioreg_t base;
+ ide_hwif_t *hwif;
+
+ for (index = 0; index < MAX_HWIFS; index++) {
+ hwif = &ide_hwifs[index];
+
+ base = ide_default_io_base(index);
+
+ if (base) {
+ ide_init_hwif_ports(&hwif->hw, base, 0, &hwif->hw.irq);
+ memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->hw.io_ports));
+ hwif->noprobe = 0;
+ }
+ }
+}
+
+/*
* init_ide_data() sets reasonable default values into all fields
* of all instances of the hwifs and drives, but only on the first call.
* Subsequent calls have no effect (they don't wipe out anything).
@@ -307,6 +320,7 @@
init_hwif_data(index);
/* Add default hw interfaces */
+ ide_old_init_default_hwifs();
ide_init_default_hwifs();
idebus_parameter = 0;
@@ -2530,6 +2544,12 @@
rapide_init();
}
#endif /* CONFIG_BLK_DEV_IDE_RAPIDE */
+#ifdef CONFIG_BLK_DEV_IDE_RISCSTATION
+ {
+ extern void rside_init(void);
+ rside_init();
+ }
+#endif /* CONFIG_BLK_DEV_IDE_RISCSTATION */
#ifdef CONFIG_BLK_DEV_GAYLE
{
extern void gayle_init(void);
diff -urN linux-2.4.26/drivers/ide/pci/Makefile linux-2.4.26-vrs1/drivers/ide/pci/Makefile
--- linux-2.4.26/drivers/ide/pci/Makefile 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ide/pci/Makefile 2004-04-18 21:47:50.000000000 +0100
@@ -16,7 +16,6 @@
obj-$(CONFIG_BLK_DEV_HPT34X) += hpt34x.o
obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o
#obj-$(CONFIG_BLK_DEV_HPT37X) += hpt37x.o
-obj-$(CONFIG_BLK_DEV_IDE_ICSIDE) += icside.o
obj-$(CONFIG_BLK_DEV_IT8172) += it8172.o
obj-$(CONFIG_BLK_DEV_NS87415) += ns87415.o
obj-$(CONFIG_BLK_DEV_OPTI621) += opti621.o
diff -urN linux-2.4.26/drivers/ide/pci/sl82c105.c linux-2.4.26-vrs1/drivers/ide/pci/sl82c105.c
--- linux-2.4.26/drivers/ide/pci/sl82c105.c 2003-06-13 15:51:33.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ide/pci/sl82c105.c 2004-01-14 21:32:25.000000000 +0000
@@ -37,7 +37,7 @@
#ifdef DEBUG
#define DBG(arg) printk arg
#else
-#define DBG(fmt,...)
+#define DBG(fmt...)
#endif
/*
* SL82C105 PCI config register 0x40 bits.
diff -urN linux-2.4.26/drivers/ide/pci/sl82c105.c.2419 linux-2.4.26-vrs1/drivers/ide/pci/sl82c105.c.2419
--- linux-2.4.26/drivers/ide/pci/sl82c105.c.2419 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ide/pci/sl82c105.c.2419 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,380 @@
+/*
+ * linux/drivers/ide/sl82c105.c
+ *
+ * SL82C105/Winbond 553 IDE driver
+ *
+ * Maintainer unknown.
+ *
+ * Changelog:
+ *
+ * 15/11/1998 RMK Drive tuning added from Rebel.com's kernel
+ * sources
+ * 30/03/2002 RMK Add fixes specified in W83C553F errata.
+ * (with special thanks to Todd Inglett)
+ */
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/timer.h>
+#include <linux/mm.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/blkdev.h>
+#include <linux/hdreg.h>
+#include <linux/pci.h>
+#include <linux/ide.h>
+
+#include <asm/io.h>
+#include <asm/dma.h>
+
+#include "ide_modes.h"
+
+extern char *ide_xfer_verbose (byte xfer_rate);
+
+/*
+ * SL82C105 PCI config register 0x40 bits.
+ */
+#define CTRL_IDE_IRQB (1 << 30)
+#define CTRL_IDE_IRQA (1 << 28)
+#define CTRL_LEGIRQ (1 << 11)
+#define CTRL_P1F16 (1 << 5)
+#define CTRL_P1EN (1 << 4)
+#define CTRL_P0F16 (1 << 1)
+#define CTRL_P0EN (1 << 0)
+
+/*
+ * Convert a PIO mode and cycle time to the required on/off
+ * times for the interface. This has protection against run-away
+ * timings.
+ */
+static unsigned int get_timing_sl82c105(ide_pio_data_t *p)
+{
+ unsigned int cmd_on;
+ unsigned int cmd_off;
+
+ cmd_on = (ide_pio_timings[p->pio_mode].active_time + 29) / 30;
+ cmd_off = (p->cycle_time - 30 * cmd_on + 29) / 30;
+
+ if (cmd_on > 32)
+ cmd_on = 32;
+ if (cmd_on == 0)
+ cmd_on = 1;
+
+ if (cmd_off > 32)
+ cmd_off = 32;
+ if (cmd_off == 0)
+ cmd_off = 1;
+
+ return (cmd_on - 1) << 8 | (cmd_off - 1) | (p->use_iordy ? 0x40 : 0x00);
+}
+
+/*
+ * Configure the drive and chipset for PIO
+ */
+static void config_for_pio(ide_drive_t *drive, int pio, int report)
+{
+ ide_hwif_t *hwif = HWIF(drive);
+ struct pci_dev *dev = hwif->pci_dev;
+ ide_pio_data_t p;
+ unsigned short drv_ctrl = 0x909;
+ unsigned int xfer_mode, reg;
+
+ reg = (hwif->channel ? 0x4c : 0x44) + (drive->select.b.unit ? 4 : 0);
+
+ pio = ide_get_best_pio_mode(drive, pio, 5, &p);
+
+ switch (pio) {
+ default:
+ case 0: xfer_mode = XFER_PIO_0; break;
+ case 1: xfer_mode = XFER_PIO_1; break;
+ case 2: xfer_mode = XFER_PIO_2; break;
+ case 3: xfer_mode = XFER_PIO_3; break;
+ case 4: xfer_mode = XFER_PIO_4; break;
+ }
+
+ if (ide_config_drive_speed(drive, xfer_mode) == 0)
+ drv_ctrl = get_timing_sl82c105(&p);
+
+ if (drive->using_dma == 0) {
+ /*
+ * If we are actually using MW DMA, then we can not
+ * reprogram the interface drive control register.
+ */
+ pci_write_config_word(dev, reg, drv_ctrl);
+ pci_read_config_word(dev, reg, &drv_ctrl);
+
+ if (report) {
+ printk("%s: selected %s (%dns) (%04X)\n", drive->name,
+ ide_xfer_verbose(xfer_mode), p.cycle_time, drv_ctrl);
+ }
+ }
+}
+
+/*
+ * Configure the drive and the chipset for DMA
+ */
+static int config_for_dma(ide_drive_t *drive)
+{
+ ide_hwif_t *hwif = HWIF(drive);
+ struct pci_dev *dev = hwif->pci_dev;
+ unsigned short drv_ctrl = 0x909;
+ unsigned int reg;
+
+ reg = (hwif->channel ? 0x4c : 0x44) + (drive->select.b.unit ? 4 : 0);
+
+ if (ide_config_drive_speed(drive, XFER_MW_DMA_2) == 0)
+ drv_ctrl = 0x0240;
+
+ pci_write_config_word(dev, reg, drv_ctrl);
+
+ return 0;
+}
+
+
+/*
+ * Check to see if the drive and
+ * chipset is capable of DMA mode
+ */
+static int sl82c105_check_drive(ide_drive_t *drive)
+{
+ ide_dma_action_t dma_func = ide_dma_off_quietly;
+
+ do {
+ struct hd_driveid *id = drive->id;
+ ide_hwif_t *hwif = HWIF(drive);
+
+ if (!hwif->autodma)
+ break;
+
+ if (!id || !(id->capability & 1))
+ break;
+
+ /* Consult the list of known "bad" drives */
+ if (ide_dmaproc(ide_dma_bad_drive, drive)) {
+ dma_func = ide_dma_off;
+ break;
+ }
+
+ if (id->field_valid & 2) {
+ if (id->dma_mword & 7 || id->dma_1word & 7)
+ dma_func = ide_dma_on;
+ break;
+ }
+
+ if (ide_dmaproc(ide_dma_good_drive, drive)) {
+ dma_func = ide_dma_on;
+ break;
+ }
+ } while (0);
+
+ return HWIF(drive)->dmaproc(dma_func, drive);
+}
+
+/*
+ * The SL82C105 holds off all IDE interrupts while in DMA mode until
+ * all DMA activity is completed. Sometimes this causes problems (eg,
+ * when the drive wants to report an error condition).
+ *
+ * 0x7e is a "chip testing" register. Bit 2 resets the DMA controller
+ * state machine. We need to kick this to work around various bugs.
+ */
+static inline void sl82c105_reset_host(struct pci_dev *dev)
+{
+ u16 val;
+
+ pci_read_config_word(dev, 0x7e, &val);
+ pci_write_config_word(dev, 0x7e, val | (1 << 2));
+ pci_write_config_word(dev, 0x7e, val & ~(1 << 2));
+}
+
+/*
+ * If we get an IRQ timeout, it might be that the DMA state machine
+ * got confused. Fix from Todd Inglett. Details from Winbond.
+ *
+ * This function is called when the IDE timer expires, the drive
+ * indicates that it is READY, and we were waiting for DMA to complete.
+ */
+static int sl82c105_lostirq(ide_drive_t *drive)
+{
+ ide_hwif_t *hwif = HWIF(drive);
+ struct pci_dev *dev = hwif->pci_dev;
+ u32 val, mask = hwif->channel ? CTRL_IDE_IRQB : CTRL_IDE_IRQA;
+ unsigned long dma_base = hwif->dma_base;
+
+ printk("sl82c105: lost IRQ: resetting host\n");
+
+ /*
+ * Check the raw interrupt from the drive.
+ */
+ pci_read_config_dword(dev, 0x40, &val);
+ if (val & mask)
+ printk("sl82c105: drive was requesting IRQ, but host lost it\n");
+
+ /*
+ * Was DMA enabled? If so, disable it - we're resetting the
+ * host. The IDE layer will be handling the drive for us.
+ */
+ val = inb(dma_base);
+ if (val & 1) {
+ outb(val & ~1, dma_base);
+ printk("sl82c105: DMA was enabled\n");
+ }
+
+ sl82c105_reset_host(dev);
+
+ /* ide_dmaproc would return 1, so we do as well */
+ return 1;
+}
+
+/*
+ * ATAPI devices can cause the SL82C105 DMA state machine to go gaga.
+ * Winbond recommend that the DMA state machine is reset prior to
+ * setting the bus master DMA enable bit.
+ *
+ * The generic IDE core will have disabled the BMEN bit before this
+ * function is called.
+ */
+static void sl82c105_before_bm_enable(ide_drive_t *drive)
+{
+ ide_hwif_t *hwif = HWIF(drive);
+ struct pci_dev *dev = hwif->pci_dev;
+
+ sl82c105_reset_host(dev);
+}
+
+/*
+ * Our very own dmaproc. We need to intercept various calls
+ * to fix up the SL82C105 specific behaviour.
+ */
+static int sl82c105_dmaproc(ide_dma_action_t func, ide_drive_t *drive)
+{
+ switch (func) {
+ case ide_dma_check:
+ return sl82c105_check_drive(drive);
+
+ case ide_dma_on:
+ if (config_for_dma(drive))
+ func = ide_dma_off;
+ /* fall through */
+
+ case ide_dma_off_quietly:
+ case ide_dma_off:
+ config_for_pio(drive, 4, 0);
+ break;
+
+ case ide_dma_read:
+ case ide_dma_write:
+ case ide_dma_begin:
+ case ide_dma_timeout:
+ sl82c105_before_bm_enable(drive);
+ break;
+
+ case ide_dma_lostirq:
+ return sl82c105_lostirq(drive);
+
+ default:
+ break;
+ }
+ return ide_dmaproc(func, drive);
+}
+
+/*
+ * We only deal with PIO mode here - DMA mode 'using_dma' is not
+ * initialised at the point that this function is called.
+ */
+static void tune_sl82c105(ide_drive_t *drive, byte pio)
+{
+ config_for_pio(drive, pio, 1);
+
+ /*
+ * We support 32-bit I/O on this interface, and it
+ * doesn't have problems with interrupts.
+ */
+ drive->io_32bit = 1;
+ drive->unmask = 1;
+}
+
+/*
+ * Return the revision of the Winbond bridge
+ * which this function is part of.
+ */
+static unsigned int sl82c105_bridge_revision(struct pci_dev *dev)
+{
+ struct pci_dev *bridge;
+ unsigned char rev;
+
+ /*
+ * The bridge should be part of the same device, but function 0.
+ */
+ bridge = pci_find_slot(dev->bus->number,
+ PCI_DEVFN(PCI_SLOT(dev->devfn), 0));
+ if (!bridge)
+ return -1;
+
+ /*
+ * Make sure it is a Winbond 553 and is an ISA bridge.
+ */
+ if (bridge->vendor != PCI_VENDOR_ID_WINBOND ||
+ bridge->device != PCI_DEVICE_ID_WINBOND_83C553 ||
+ bridge->class >> 8 != PCI_CLASS_BRIDGE_ISA)
+ return -1;
+
+ /*
+ * We need to find function 0's revision, not function 1
+ */
+ pci_read_config_byte(bridge, PCI_REVISION_ID, &rev);
+
+ return rev;
+}
+
+/*
+ * Enable the PCI device
+ */
+unsigned int __init pci_init_sl82c105(struct pci_dev *dev, const char *msg)
+{
+ u32 val;
+
+ pci_read_config_dword(dev, 0x40, &val);
+ val |= CTRL_P0EN | CTRL_P0F16 | CTRL_P1EN | CTRL_P1F16;
+ pci_write_config_dword(dev, 0x40, val);
+
+ return dev->irq;
+}
+
+void __init dma_init_sl82c105(ide_hwif_t *hwif, unsigned long dma_base)
+{
+ unsigned int bridge_rev;
+ byte dma_state;
+
+ dma_state = inb(dma_base + 2);
+ bridge_rev = sl82c105_bridge_revision(hwif->pci_dev);
+ if (bridge_rev <= 5) {
+ hwif->autodma = 0;
+ hwif->drives[0].autotune = 1;
+ hwif->drives[1].autotune = 1;
+ printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
+ hwif->name, bridge_rev);
+ dma_state &= ~0x60;
+ } else {
+ dma_state |= 0x60;
+ hwif->autodma = 1;
+ }
+ outb(dma_state, dma_base + 2);
+
+ ide_setup_dma(hwif, dma_base, 8);
+
+ if (bridge_rev <= 5)
+ hwif->dmaproc = NULL;
+ else
+ hwif->dmaproc = sl82c105_dmaproc;
+}
+
+/*
+ * Initialise the chip
+ */
+void __init ide_init_sl82c105(ide_hwif_t *hwif)
+{
+ hwif->tuneproc = tune_sl82c105;
+}
+
diff -urN linux-2.4.26/drivers/input/Config.in linux-2.4.26-vrs1/drivers/input/Config.in
--- linux-2.4.26/drivers/input/Config.in 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/input/Config.in 2004-02-23 22:53:55.000000000 +0000
@@ -15,5 +15,6 @@
dep_tristate ' Joystick support' CONFIG_INPUT_JOYDEV $CONFIG_INPUT
dep_tristate ' Event interface support' CONFIG_INPUT_EVDEV $CONFIG_INPUT
dep_tristate ' User level driver support' CONFIG_INPUT_UINPUT $CONFIG_INPUT
+dep_tristate ' MX1 touchscreen support' CONFIG_INPUT_MX1TS $CONFIG_INPUT_MOUSEDEV $CONFIG_ARCH_MX1ADS
endmenu
diff -urN linux-2.4.26/drivers/input/Makefile linux-2.4.26-vrs1/drivers/input/Makefile
--- linux-2.4.26/drivers/input/Makefile 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/input/Makefile 2004-02-23 22:53:03.000000000 +0000
@@ -24,6 +24,7 @@
obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o
obj-$(CONFIG_INPUT_JOYDEV) += joydev.o
obj-$(CONFIG_INPUT_EVDEV) += evdev.o
+obj-$(CONFIG_INPUT_MX1TS) += mx1ts.o
obj-$(CONFIG_INPUT_UINPUT) += uinput.o
# The global Rules.make.
diff -urN linux-2.4.26/drivers/input/mx1ts.c linux-2.4.26-vrs1/drivers/input/mx1ts.c
--- linux-2.4.26/drivers/input/mx1ts.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/input/mx1ts.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,508 @@
+/*
+ * linux/drivers/misc/mx1ts.c
+ *
+ * Copyright (C) 2003 Blue Mug, Inc. for Motorola, Inc.
+ *
+ * Cloned from ucb1x00_ts.c
+ *
+ * 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/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
+#include <linux/sched.h>
+#include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/pm.h>
+
+#include <asm/dma.h>
+
+#include <linux/input.h>
+
+#include "mx1ts.h"
+
+#define DEV_IRQ_ID "mx1-ts"
+
+struct mx1_ts {
+ struct input_dev idev;
+#ifdef CONFIG_PM
+ struct pm_dev *pmdev;
+#endif
+
+ wait_queue_head_t irq_wait;
+ struct completion init_exit;
+ int use_count;
+ u16 x_res;
+ u16 y_res;
+
+ int restart:1;
+};
+
+static struct mx1_ts mx1ts;
+static u8 mx1_performing_auto_calibration = 0;
+static u16 mx1_cal_auto_zero = 0;
+static u16 mx1_cal_range_x = 0;
+static u16 mx1_cal_range_y = 0;
+
+static int mx1_ts_startup(struct mx1_ts *ts);
+static void mx1_ts_shutdown(struct mx1_ts *ts);
+
+static void mx1_ts_pendata_int(int irq, void *dev_id, struct pt_regs *regs);
+static void mx1_ts_touch_int(int irq, void *dev_id, struct pt_regs *regs);
+static void mx1_ts_compare_int(int irq, void *dev_id, struct pt_regs *regs);
+
+static void mx1_ts_enable_pen_touch_interrupt(void);
+static void mx1_ts_disable_pen_touch_interrupt(void);
+static void mx1_ts_enable_pen_up_interrupt(void);
+static void mx1_ts_disable_pen_up_interrupt(void);
+static void mx1_ts_enable_auto_sample(void);
+static void mx1_ts_disable_auto_sample(void);
+static void mx1_ts_start_auto_calibration(void);
+
+static inline void mx1_reg_write(unsigned int reg, unsigned int val)
+{
+ *((volatile unsigned int *)reg) = val;
+}
+
+static inline unsigned int mx1_reg_read(unsigned int reg)
+{
+ return *((volatile unsigned int *)reg);
+}
+
+static inline void mx1_reg_clear_bit(unsigned int reg, unsigned int bit)
+{
+ *((volatile unsigned int *)reg) &= ~bit;
+}
+
+static inline void mx1_reg_set_bit(unsigned int reg, unsigned int bit)
+{
+ *((volatile unsigned int *)reg) |= bit;
+}
+
+static inline void mx1_ts_evt_add(struct mx1_ts *ts, u16 pressure, u16 x, u16 y)
+{
+ input_report_abs(&ts->idev, ABS_X, (int)x - 32768);
+ input_report_abs(&ts->idev, ABS_Y, (int)y - 32768);
+ input_report_abs(&ts->idev, ABS_PRESSURE, (int)pressure);
+}
+
+static inline void mx1_ts_flush_fifo(void)
+{
+ int i;
+ for (i = 0; i < 12; i++)
+ if (mx1_reg_read(ASP_ISTATR) & (ASP_PFF | ASP_PDR))
+ mx1_reg_read(ASP_PADFIFO);
+}
+
+static int mx1_ts_open(struct input_dev *idev)
+{
+ struct mx1_ts *ts = (struct mx1_ts *)idev;
+
+ mx1_performing_auto_calibration = 0;
+ return mx1_ts_startup(ts);
+}
+
+static void mx1_ts_close(struct input_dev *idev)
+{
+ struct mx1_ts *ts = (struct mx1_ts *)idev;
+
+ mx1_ts_shutdown(ts);
+}
+
+static inline int mx1_ts_enable_irqs(void)
+{
+ int result;
+
+ result = request_irq(ASP_PENDATA_IRQ,
+ mx1_ts_pendata_int,
+ SA_INTERRUPT,
+ DEV_IRQ_ID,
+ DEV_IRQ_ID);
+ if (result) {
+ printk("Couldn't request pen data IRQ.\n");
+ return result;
+ }
+
+ result = request_irq(ASP_TOUCH_IRQ,
+ mx1_ts_touch_int,
+ SA_INTERRUPT,
+ DEV_IRQ_ID,
+ DEV_IRQ_ID);
+ if (result) {
+ printk("Couldn't request pen touch IRQ.\n");
+ free_irq(ASP_PENDATA_IRQ, DEV_IRQ_ID);
+ return result;
+ }
+
+ return result;
+}
+
+static inline int mx1_ts_disable_irqs(void)
+{
+ free_irq(ASP_PENDATA_IRQ, DEV_IRQ_ID);
+ free_irq(ASP_TOUCH_IRQ, DEV_IRQ_ID);
+
+ return 0;
+}
+
+static inline int mx1_ts_register(struct mx1_ts *ts)
+{
+ ts->idev.name = "Touchscreen panel";
+ ts->idev.open = mx1_ts_open;
+ ts->idev.close = mx1_ts_close;
+
+ __set_bit(EV_ABS, ts->idev.evbit);
+ __set_bit(ABS_X, ts->idev.absbit);
+ __set_bit(ABS_Y, ts->idev.absbit);
+ __set_bit(ABS_PRESSURE, ts->idev.absbit);
+
+ ts->idev.absmin[ABS_X] = 0;
+ ts->idev.absmax[ABS_X] = (u32)0x0000FFFF;
+ ts->idev.absfuzz[ABS_X] = 50;
+ ts->idev.absflat[ABS_X] = 0;
+
+ ts->idev.absmin[ABS_Y] = 0;
+ ts->idev.absmax[ABS_Y] = (u32)0x0000FFFF;
+ ts->idev.absfuzz[ABS_Y] = 50;
+ ts->idev.absflat[ABS_Y] = 0;
+
+ input_register_device(&ts->idev);
+
+ return 0;
+}
+
+static inline void mx1_ts_deregister(struct mx1_ts *ts)
+{
+ input_unregister_device(&ts->idev);
+}
+
+/*
+ * Handle the touch interrupt, generated when the pen is pressed/
+ * released.
+ */
+static void mx1_ts_touch_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+ /* Clear the interrupt. */
+ mx1_reg_set_bit(ASP_ISTATR, ASP_PEN);
+
+ mx1_ts_disable_pen_touch_interrupt();
+ mx1_ts_start_auto_calibration();
+ mx1_ts_enable_pen_up_interrupt();
+}
+
+/*
+ * Handle the pen data ready interrupt, generated when pen data is
+ * in the FIFO.
+ */
+static void mx1_ts_pendata_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+ static unsigned int auto_zero, pen_x, pen_y, pen_u;
+
+ if (mx1_reg_read(ASP_ISTATR) & 0x400) {
+ mx1_reg_set_bit(ASP_ISTATR, 0x400);
+
+ mx1_ts_disable_auto_sample();
+ mx1_ts_disable_pen_up_interrupt();
+ mx1_ts_enable_pen_touch_interrupt();
+
+ mx1_ts_evt_add(&mx1ts, 0, pen_x, pen_y);
+
+ mx1_ts_flush_fifo();
+
+ return;
+ }
+
+ if (mx1_performing_auto_calibration) {
+ unsigned int value;
+
+ mx1_cal_auto_zero = mx1_reg_read(ASP_PADFIFO) & 0xFFFF;
+ mx1_cal_range_x = mx1_reg_read(ASP_PADFIFO) & 0xFFFF;
+ mx1_cal_range_y = mx1_reg_read(ASP_PADFIFO) & 0xFFFF;
+
+ if ((mx1_cal_auto_zero >= mx1_cal_range_x) ||
+ (mx1_cal_auto_zero >= mx1_cal_range_y)) {
+ /* Invalid data. */
+ mx1_ts_start_auto_calibration();
+ return;
+ }
+
+ mx1_cal_range_x -= mx1_cal_auto_zero;
+ mx1_cal_range_y -= mx1_cal_auto_zero;
+
+ value = mx1_reg_read(ASP_ACNTLCR);
+ value &= ~0x04000000; /* XXX Undocumented. */
+ mx1_reg_write(ASP_ACNTLCR, value);
+
+ mx1_performing_auto_calibration = 0;
+
+ mx1_ts_enable_auto_sample();
+ } else {
+ /* There could be more than one sample in the FIFO, but we're
+ * only going to read one per call. The interrupt will be
+ * generated as long as there is data in the FIFO. */
+
+ if ((mx1_reg_read(ASP_ISTATR) & ASP_PDR) != ASP_PDR) {
+ return;
+ }
+
+ auto_zero = mx1_reg_read(ASP_PADFIFO);
+ if (auto_zero > (mx1_cal_auto_zero + 0x200)) {
+ return;
+ }
+
+ pen_x = mx1_reg_read(ASP_PADFIFO);
+ pen_y = mx1_reg_read(ASP_PADFIFO);
+ pen_u = mx1_reg_read(ASP_PADFIFO);
+
+ pen_x = (u32)(((pen_x - mx1_cal_auto_zero) << 16) /
+ mx1_cal_range_x);
+ pen_y = (u32)(((pen_y - mx1_cal_auto_zero) << 16) /
+ mx1_cal_range_y);
+
+ mx1_ts_evt_add(&mx1ts, pen_u, pen_x, pen_y);
+ }
+}
+
+static void mx1_ts_reset_asp(void)
+{
+ unsigned int value;
+
+ mx1_ts_flush_fifo();
+
+ /* Soft reset the ASP module */
+ mx1_reg_write(ASP_ACNTLCR, ASP_SWRST);
+
+ /* Read back the reset value of the control register */
+ value = mx1_reg_read(ASP_ACNTLCR);
+
+ /* Enable the clock and wait for a short while */
+ value |= ASP_CLKEN;
+ mx1_reg_write(ASP_ACNTLCR, value);
+ udelay(100);
+
+ /* Set the value of the conrtol register. */
+ value = ASP_CLKEN | ASP_NM | ASP_SW6 | ASP_BGE;
+ mx1_reg_write(ASP_ACNTLCR, value);
+
+ /* Set the clock divide ratio to 2. */
+ mx1_reg_write(ASP_CLKDIV, 0x01);
+
+ /* Set the sample rate control register. These values should yield
+ * about 150 samples per second, which seems to give good smooth
+ * lines. */
+ value = (0x2 << ASP_DMCNT_SCALE) | /* Decimation ratio is 3 */
+ (0x1 << ASP_IDLECNT_SCALE) | /* Idle count is 1 clock */
+ (0x2 << ASP_DSCNT_SCALE); /* Data setup is 2 clocks */
+ mx1_reg_write(ASP_PSMPLRG, value);
+
+ /* Disable the compare function. */
+ mx1_reg_write(ASP_CMPCNTL, 0);
+}
+
+static void mx1_ts_enable_auto_sample(void)
+{
+ unsigned int value;
+
+ mx1_ts_flush_fifo();
+
+ value = mx1_reg_read(ASP_ACNTLCR);
+
+ /* Set the mode to X then Y */
+ value &= ~ASP_MODE_MASK;
+ value |= ASP_MODE_ONLY_Y;
+
+ /* Enable auto zero. */
+ value |= ASP_AZE;
+
+ /* Enable auto sample. */
+ value |= ASP_AUTO;
+
+ /* Enable pen A/D. */
+ value |= ASP_PADE;
+ mx1_reg_write(ASP_ACNTLCR, value);
+
+ /* Enable pen data ready and full interrupt. */
+ value = mx1_reg_read(ASP_ICNTLR);
+ value |= ASP_PFFE | ASP_PDRE;
+ mx1_reg_write(ASP_ICNTLR, value);
+}
+
+static void mx1_ts_disable_auto_sample(void)
+{
+ unsigned int value;
+
+ value = mx1_reg_read(ASP_ACNTLCR);
+
+ /* Set the mode to none */
+ value &= ~ASP_MODE_MASK;
+
+ /* Disable auto zero. */
+ value &= ~ASP_AZE;
+
+ /* Disable auto sample. */
+ value &= ~ASP_AUTO;
+
+ /* Disable pen A/D. */
+ value &= ~ASP_PADE;
+ mx1_reg_write(ASP_ACNTLCR, value);
+
+ /* Disable pen data ready and full interrupt. */
+ value = mx1_reg_read(ASP_ICNTLR);
+ value &= ~(ASP_PFFE | ASP_PDRE);
+ mx1_reg_write(ASP_ICNTLR, value);
+}
+
+static void mx1_ts_enable_pen_touch_interrupt(void)
+{
+ unsigned int value;
+
+ /* Enable pen touch interrupt. */
+ value = mx1_reg_read(ASP_ICNTLR);
+ value |= ASP_EDGE | ASP_PIRQE;
+ mx1_reg_write(ASP_ICNTLR, value);
+}
+
+static void mx1_ts_disable_pen_touch_interrupt(void)
+{
+ unsigned int value;
+
+ /* Enable pen touch interrupt. */
+ value = mx1_reg_read(ASP_ICNTLR);
+ value &= ~ASP_PIRQE;
+ mx1_reg_write(ASP_ICNTLR, value);
+}
+
+static void mx1_ts_enable_pen_up_interrupt(void)
+{
+ unsigned int value;
+
+ /* Enable pen up interrupt. XXX: This feature is undocumented. */
+ value = mx1_reg_read(ASP_ICNTLR);
+ value |= ASP_PUPE;
+ mx1_reg_write(ASP_ICNTLR, value);
+}
+
+static void mx1_ts_disable_pen_up_interrupt(void)
+{
+ unsigned int value;
+
+ /* Enable pen up interrupt. XXX: This feature is undocumented. */
+ value = mx1_reg_read(ASP_ICNTLR);
+ value &= ~ASP_PUPE;
+ mx1_reg_write(ASP_ICNTLR, value);
+}
+
+static void mx1_ts_start_auto_calibration(void)
+{
+ unsigned int value;
+
+ mx1_performing_auto_calibration = 1;
+
+ value = mx1_reg_read(ASP_ACNTLCR);
+
+ /* Set the mode to X then Y */
+ value &= ~ASP_MODE_MASK;
+ value |= ASP_MODE_ONLY_X;
+
+ /* Enable auto zero. */
+ value |= ASP_AZE;
+
+ /* Enable auto calibrate. XXX: Undocumented bitfield. */
+ value |= 0x04000000;
+
+ /* Enable auto sample. */
+ value |= ASP_AUTO;
+
+ /* Enable pen A/D. */
+ value |= ASP_PADE;
+ mx1_reg_write(ASP_ACNTLCR, value);
+
+ /* Enable pen data ready and full interrupt. */
+ value = mx1_reg_read(ASP_ICNTLR);
+ value |= ASP_PFFE | ASP_PDRE | ASP_PUPE;
+ mx1_reg_write(ASP_ICNTLR, value);
+}
+
+static int mx1_ts_startup(struct mx1_ts *ts)
+{
+ int ret = 0;
+
+ if (ts->use_count++ != 0)
+ goto out;
+
+ /*
+ * Reset the ASP.
+ */
+ mx1_ts_reset_asp();
+
+
+ /*
+ * XXX: Figure out if we need this...
+ * If we do this at all, we should allow the user to
+ * measure and read the X and Y resistance at any time.
+ */
+ //ts->x_res = mx1_ts_read_xres(ts);
+ //ts->y_res = mx1_ts_read_yres(ts);
+
+ mx1_ts_enable_pen_touch_interrupt();
+
+ out:
+ if (ret)
+ ts->use_count--;
+ return ret;
+}
+
+/*
+ * Release touchscreen resources. Disable IRQs.
+ */
+static void mx1_ts_shutdown(struct mx1_ts *ts)
+{
+ if (--ts->use_count == 0) {
+ unsigned int value;
+
+ /* Turn off the ADC and associated circuitry. */
+ value = mx1_reg_read(ASP_ACNTLCR);
+ value &= !(ASP_CLKEN | ASP_PADE | ASP_BGE);
+ mx1_reg_write(ASP_ACNTLCR, value);
+ }
+}
+
+/*
+ * Initialization.
+ */
+static int __init mx1_ts_init(void)
+{
+ int ret = 0;
+ struct mx1_ts *ts = &mx1ts;
+
+ mx1_ts_reset_asp();
+
+ /*
+ * Enable the IRQ's
+ */
+ if ((ret = mx1_ts_enable_irqs()))
+ return ret;
+
+ return mx1_ts_register(ts);
+}
+
+static void __exit mx1_ts_exit(void)
+{
+ struct mx1_ts *ts = &mx1ts;
+
+ mx1_ts_disable_irqs();
+ mx1_ts_deregister(ts);
+}
+
+module_init(mx1_ts_init);
+module_exit(mx1_ts_exit);
+
+MODULE_AUTHOR("Jon McClintock <jonm@bluemug.com>");
+MODULE_DESCRIPTION("MX1 touchscreen driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/input/mx1ts.h linux-2.4.26-vrs1/drivers/input/mx1ts.h
--- linux-2.4.26/drivers/input/mx1ts.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/input/mx1ts.h 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,108 @@
+/*
+ * linux/drivers/misc/mx1ts.h
+ *
+ * Copyright (C) 2003 Blue Mug, Inc. for Motorola, Inc.
+ *
+ * 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.
+ *
+ */
+
+/* Interrupt numbers */
+#define ASP_COMPARE_IRQ 5
+#define ASP_PENDATA_IRQ 33
+#define ASP_TOUCH_IRQ 46
+
+/* Analog signal processor (ASP) control registers */
+#define ASP_ACNTLCR 0xF0215010 /* Control register */
+#define ASP_PSMPLRG 0xF0215014 /* Pen A/D sampe rate control */
+#define ASP_CMPCNTL 0xF0215030 /* Compare control register */
+#define ASP_ICNTLR 0xF0215018 /* Interrupt control register */
+#define ASP_ISTATR 0xF021501C /* Interrupt status register */
+#define ASP_PADFIFO 0xF0215000 /* Pen sample FIFO */
+#define ASP_CLKDIV 0xF021502C /* Clock divide register */
+
+/* ASP control register bits */
+#define ASP_CLKEN (1 << 25) /* Clock enable */
+#define ASP_SWRST (1 << 23) /* Software reset */
+#define ASP_U_SEL (1 << 21) /* U-channel resistor select */
+#define ASP_AZ_SEL (1 << 20) /* Auto-zero position select */
+#define ASP_LVM (1 << 19) /* Low voltage output */
+#define ASP_NM (1 << 18) /* Normal voltage output */
+#define ASP_HPM (1 << 17) /* High voltage output */
+#define ASP_GLO (1 << 16) /* Low gain enable */
+#define ASP_AZE (1 << 15) /* Auto-zero enable */
+#define ASP_AUTO (1 << 14) /* Auto sampling */
+#define ASP_SW8 (1 << 11) /* Switch control 8 */
+#define ASP_SW7 (1 << 10)
+#define ASP_SW6 (1 << 9)
+#define ASP_SW5 (1 << 8)
+#define ASP_SW4 (1 << 7)
+#define ASP_SW3 (1 << 6)
+#define ASP_SW2 (1 << 5)
+#define ASP_SW1 (1 << 4) /* Switch control 1 */
+#define ASP_VDAE (1 << 3) /* Voice D/A enable */
+#define ASP_VADE (1 << 2) /* Voice A/D enable */
+#define ASP_PADE (1 << 1) /* Pen A/D enable */
+#define ASP_BGE (1 << 0) /* Bandgap enable */
+
+#define ASP_MODE_MASK 0x00003000
+#define ASP_MODE_NONE 0x00000000
+#define ASP_MODE_ONLY_X 0x00001000
+#define ASP_MODE_ONLY_Y 0x00002000
+#define ASP_MODE_ONLY_U 0x00003000
+
+/* ASP Pen A/D sample rate control register */
+#define ASP_DMCNT_MASK (0x00007000) /* Decimation ratio count */
+#define ASP_DMCNT_SCALE (12)
+#define ASP_BIT_SELECT_MASK (0x00000C00) /* Bit select */
+#define ASP_BIT_SELECT_SCALE (10)
+#define ASP_IDLECNT_MASK (0x000003F0) /* Idle count */
+#define ASP_IDLECNT_SCALE (4)
+#define ASP_DSCNT_MASK (0x0000000F) /* Data setup count */
+#define ASP_DSCNT_SCALE (0)
+
+/* ASP compare control register */
+#define ASP_INT (1 << 19) /* Interrupt status */
+#define ASP_CC (1 << 18) /* Trigger on greater than */
+#define ASP_INSEL_MASK (0x00030000)
+#define ASP_INSEL_DISABLE (0x00000000)
+#define ASP_INSEL_X (0x00010000)
+#define ASP_INSEL_Y (0x00020000)
+#define ASP_INSEL_U (0x00030000)
+#define ASP_COMPARE_VAL_MASK (0x0000FFFF)
+#define ASP_COMPARE_VAL_SCALE (0)
+
+/* ASP interrupt control register bits */
+#define ASP_PUPE (1 << 10) /* Pen up XXX undocumented */
+#define ASP_VDDMAE (1 << 8) /* VDAC FIFO empty DMA */
+#define ASP_VADMAE (1 << 7) /* VADC FIFO full DMA */
+#define ASP_POL (1 << 6) /* Pen interrupt polarity */
+#define ASP_EDGE (1 << 5) /* Edge trigger enable */
+#define ASP_PIRQE (1 << 4) /* Pen interrupt enable */
+#define ASP_VDAFEE (1 << 3) /* VDAC FIFO empty interrupt */
+#define ASP_VADFFE (1 << 2) /* VADC FIFO full interrupt */
+#define ASP_PFFE (1 << 1) /* Pen FIFO full interrupt */
+#define ASP_PDRE (1 << 0) /* Pen data ready interrupt */
+
+/* ASP interrupt/error status register bits */
+#define ASP_PUP (1 << 10) /* Pen up XXX undocumented */
+#define ASP_BGR (1 << 9) /* Bandgap ready */
+#define ASP_VOV (1 << 8) /* Voice sample data overflow */
+#define ASP_POV (1 << 7) /* Pen sample data overflow */
+#define ASP_PEN (1 << 6) /* Pen interrupt */
+#define ASP_VDAFF (1 << 5) /* VDAC FIFO full */
+#define ASP_VDAFE (1 << 4) /* VDAC FIFO empty */
+#define ASP_VADFF (1 << 3) /* VADC FIFO full */
+#define ASP_VADDR (1 << 2) /* VADC data ready */
+#define ASP_PFF (1 << 1) /* Pen sample FIFO full */
+#define ASP_PDR (1 << 0) /* Pen data ready */
+
+/* ASP Clock divide register */
+#define ASP_PADC_CLK_MASK (0x0000001F)
+#define ASP_PADC_CLK_SCALE (0)
+#define ASP_VADC_CLK_MASK (0x000003E0)
+#define ASP_VADC_CLK_SCALE (5)
+#define ASP_VDAC_CLK_MASK (0x00003C00)
+#define ASP_VDAC_CLK_SCALE (10)
diff -urN linux-2.4.26/drivers/l3/Config.in linux-2.4.26-vrs1/drivers/l3/Config.in
--- linux-2.4.26/drivers/l3/Config.in 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/l3/Config.in 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,21 @@
+#
+# L3 bus configuration
+#
+mainmenu_option next_comment
+comment 'L3 serial bus support'
+
+tristate 'L3 support' CONFIG_L3
+dep_bool ' L3 bit-banging interfaces' CONFIG_L3_ALGOBIT $CONFIG_L3
+dep_bool ' SA11x0 GPIO adapter' CONFIG_L3_BIT_SA1100_GPIO $CONFIG_L3_ALGOBIT $CONFIG_ARCH_SA1100
+
+comment 'Other L3 adapters'
+dep_bool ' SA1111 adapter' CONFIG_L3_SA1111 $CONFIG_L3
+endmenu
+
+# i2c must come before this
+if [ "$CONFIG_L3_BIT_SA1100_GPIO" = "y" -o \
+ "$CONFIG_I2C_BIT_SA1100_GPIO" = "y" ]; then
+ define_bool CONFIG_BIT_SA1100_GPIO y
+else
+ define_bool CONFIG_BIT_SA1100_GPIO n
+fi
diff -urN linux-2.4.26/drivers/l3/Makefile linux-2.4.26-vrs1/drivers/l3/Makefile
--- linux-2.4.26/drivers/l3/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/l3/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,23 @@
+#
+# Makefile for the L3 bus driver.
+#
+
+O_TARGET := l3.o
+
+export-objs := l3-core.o l3-algo-bit.o
+l3-y :=
+l3-n :=
+l3-drv-y :=
+l3-drv-n :=
+
+# Link order:
+# (core, adapters, algorithms, drivers) then clients
+
+l3-$(CONFIG_L3_ALGOBIT) += l3-algo-bit.o
+l3-$(CONFIG_BIT_SA1100_GPIO) += l3-bit-sa1100.o
+l3-$(CONFIG_L3_SA1111) += l3-sa1111.o
+
+obj-$(CONFIG_L3) += l3-core.o $(l3-y) $(l3-drv-y)
+
+include $(TOPDIR)/Rules.make
+
diff -urN linux-2.4.26/drivers/l3/l3-algo-bit.c linux-2.4.26-vrs1/drivers/l3/l3-algo-bit.c
--- linux-2.4.26/drivers/l3/l3-algo-bit.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/l3/l3-algo-bit.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,175 @@
+/*
+ * L3 bus algorithm module.
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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.
+ *
+ * Note that L3 buses can share the same pins as I2C buses, so we must
+ * _not_ generate an I2C start condition. An I2C start condition is
+ * defined as a high-to-low transition of the data line while the clock
+ * is high. Therefore, we must only change the data line while the
+ * clock is low.
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/l3/l3.h>
+#include <linux/l3/algo-bit.h>
+
+#define setdat(adap,val) adap->setdat(adap->data, val)
+#define setclk(adap,val) adap->setclk(adap->data, val)
+#define setmode(adap,val) adap->setmode(adap->data, val)
+#define setdatin(adap) adap->setdir(adap->data, 1)
+#define setdatout(adap) adap->setdir(adap->data, 0)
+#define getdat(adap) adap->getdat(adap->data)
+
+/*
+ * Send one byte of data to the chip. Data is latched into the chip on
+ * the rising edge of the clock.
+ */
+static void sendbyte(struct l3_algo_bit_data *adap, unsigned int byte)
+{
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ setclk(adap, 0);
+ udelay(adap->data_hold);
+ setdat(adap, byte & 1);
+ udelay(adap->data_setup);
+ setclk(adap, 1);
+ udelay(adap->clock_high);
+ byte >>= 1;
+ }
+}
+
+/*
+ * Send a set of bytes to the chip. We need to pulse the MODE line
+ * between each byte, but never at the start nor at the end of the
+ * transfer.
+ */
+static void sendbytes(struct l3_algo_bit_data *adap, const char *buf, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ if (i) {
+ udelay(adap->mode_hold);
+ setmode(adap, 0);
+ udelay(adap->mode);
+ }
+ setmode(adap, 1);
+ udelay(adap->mode_setup);
+ sendbyte(adap, buf[i]);
+ }
+}
+
+/*
+ * Read one byte of data from the chip. Data is latched into the chip on
+ * the rising edge of the clock.
+ */
+static unsigned int readbyte(struct l3_algo_bit_data *adap)
+{
+ unsigned int byte = 0;
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ setclk(adap, 0);
+ udelay(adap->data_hold + adap->data_setup);
+ setclk(adap, 1);
+ if (getdat(adap))
+ byte |= 1 << i;
+ udelay(adap->clock_high);
+ }
+
+ return byte;
+}
+
+/*
+ * Read a set of bytes from the chip. We need to pulse the MODE line
+ * between each byte, but never at the start nor at the end of the
+ * transfer.
+ */
+static void readbytes(struct l3_algo_bit_data *adap, char *buf, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++) {
+ if (i) {
+ udelay(adap->mode_hold);
+ setmode(adap, 0);
+ }
+ setmode(adap, 1);
+ udelay(adap->mode_setup);
+ buf[i] = readbyte(adap);
+ }
+}
+
+static int l3_xfer(struct l3_adapter *l3_adap, struct l3_msg msgs[], int num)
+{
+ struct l3_algo_bit_data *adap = l3_adap->algo_data;
+ int i;
+
+ /*
+ * If we share an I2C bus, ensure that it is in STOP mode
+ */
+ setclk(adap, 1);
+ setdat(adap, 1);
+ setmode(adap, 1);
+ setdatout(adap);
+ udelay(adap->mode);
+
+ for (i = 0; i < num; i++) {
+ struct l3_msg *pmsg = &msgs[i];
+
+ if (!(pmsg->flags & L3_M_NOADDR)) {
+ setmode(adap, 0);
+ udelay(adap->mode_setup);
+ sendbyte(adap, pmsg->addr);
+ udelay(adap->mode_hold);
+ }
+
+ if (pmsg->flags & L3_M_RD) {
+ setdatin(adap);
+ readbytes(adap, pmsg->buf, pmsg->len);
+ } else {
+ setdatout(adap);
+ sendbytes(adap, pmsg->buf, pmsg->len);
+ }
+ }
+
+ /*
+ * Ensure that we leave the bus in I2C stop mode.
+ */
+ setclk(adap, 1);
+ setdat(adap, 1);
+ setmode(adap, 0);
+ setdatin(adap);
+
+ return num;
+}
+
+static struct l3_algorithm l3_bit_algo = {
+ name: "L3 bit-shift algorithm",
+ xfer: l3_xfer,
+};
+
+int l3_bit_add_bus(struct l3_adapter *adap)
+{
+ adap->algo = &l3_bit_algo;
+ return l3_add_adapter(adap);
+}
+
+int l3_bit_del_bus(struct l3_adapter *adap)
+{
+ return l3_del_adapter(adap);
+}
+
+EXPORT_SYMBOL(l3_bit_add_bus);
+EXPORT_SYMBOL(l3_bit_del_bus);
diff -urN linux-2.4.26/drivers/l3/l3-bit-sa1100.c linux-2.4.26-vrs1/drivers/l3/l3-bit-sa1100.c
--- linux-2.4.26/drivers/l3/l3-bit-sa1100.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/l3/l3-bit-sa1100.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,277 @@
+/*
+ * linux/drivers/l3/l3-bit-sa1100.c
+ *
+ * Copyright (C) 2001 Russell King
+ *
+ * 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.
+ *
+ * This is a combined I2C and L3 bus driver.
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/ioport.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/i2c-algo-bit.h>
+#include <linux/l3/algo-bit.h>
+
+#include <asm/system.h>
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/arch/assabet.h>
+
+#define NAME "l3-bit-sa1100-gpio"
+
+struct bit_data {
+ unsigned int sda;
+ unsigned int scl;
+ unsigned int l3_mode;
+};
+
+static int getsda(void *data)
+{
+ struct bit_data *bits = data;
+
+ return GPLR & bits->sda;
+}
+
+#ifdef CONFIG_I2C_BIT_SA1100_GPIO
+static void i2c_setsda(void *data, int state)
+{
+ struct bit_data *bits = data;
+ unsigned long flags;
+
+ local_irq_save(flags);
+ if (state)
+ GPDR &= ~bits->sda;
+ else {
+ GPCR = bits->sda;
+ GPDR |= bits->sda;
+ }
+ local_irq_restore(flags);
+}
+
+static void i2c_setscl(void *data, int state)
+{
+ struct bit_data *bits = data;
+ unsigned long flags;
+
+ local_irq_save(flags);
+ if (state)
+ GPDR &= ~bits->scl;
+ else {
+ GPCR = bits->scl;
+ GPDR |= bits->scl;
+ }
+ local_irq_restore(flags);
+}
+
+static int i2c_getscl(void *data)
+{
+ struct bit_data *bits = data;
+
+ return GPLR & bits->scl;
+}
+
+static struct i2c_algo_bit_data i2c_bit_data = {
+ setsda: i2c_setsda,
+ setscl: i2c_setscl,
+ getsda: getsda,
+ getscl: i2c_getscl,
+ udelay: 10,
+ mdelay: 10,
+ timeout: 100,
+};
+
+static struct i2c_adapter i2c_adapter = {
+ name: NAME,
+ algo_data: &i2c_bit_data,
+// inc_use: i2c_inc_use,
+// dec_use: i2c_dec_use,
+};
+
+#define LOCK &i2c_adapter.lock
+
+static int __init i2c_init(struct bit_data *bits)
+{
+ i2c_bit_data.data = bits;
+ return i2c_bit_add_bus(&i2c_adapter);
+}
+
+static void i2c_exit(void)
+{
+ i2c_bit_del_bus(&i2c_adapter);
+}
+
+#else
+static DECLARE_MUTEX(l3_lock);
+#define LOCK &l3_lock
+#define i2c_init(bits) (0)
+#define i2c_exit() do { } while (0)
+#endif
+
+#ifdef CONFIG_L3_BIT_SA1100_GPIO
+/*
+ * iPAQs need the clock line driven hard high and low.
+ */
+static void l3_setscl(void *data, int state)
+{
+ struct bit_data *bits = data;
+ unsigned long flags;
+
+ local_irq_save(flags);
+ if (state)
+ GPSR = bits->scl;
+ else
+ GPCR = bits->scl;
+ GPDR |= bits->scl;
+ local_irq_restore(flags);
+}
+
+static void l3_setsda(void *data, int state)
+{
+ struct bit_data *bits = data;
+
+ if (state)
+ GPSR = bits->sda;
+ else
+ GPCR = bits->sda;
+}
+
+static void l3_setdir(void *data, int in)
+{
+ struct bit_data *bits = data;
+ unsigned long flags;
+
+ local_irq_save(flags);
+ if (in)
+ GPDR &= ~bits->sda;
+ else
+ GPDR |= bits->sda;
+ local_irq_restore(flags);
+}
+
+static void l3_setmode(void *data, int state)
+{
+ struct bit_data *bits = data;
+
+ if (state)
+ GPSR = bits->l3_mode;
+ else
+ GPCR = bits->l3_mode;
+}
+
+static struct l3_algo_bit_data l3_bit_data = {
+ data: NULL,
+ setdat: l3_setsda,
+ setclk: l3_setscl,
+ setmode: l3_setmode,
+ setdir: l3_setdir,
+ getdat: getsda,
+ data_hold: 1,
+ data_setup: 1,
+ clock_high: 1,
+ mode_hold: 1,
+ mode_setup: 1,
+};
+
+static struct l3_adapter l3_adapter = {
+ owner: THIS_MODULE,
+ name: NAME,
+ algo_data: &l3_bit_data,
+ lock: LOCK,
+};
+
+static int __init l3_init(struct bit_data *bits)
+{
+ l3_bit_data.data = bits;
+ return l3_bit_add_bus(&l3_adapter);
+}
+
+static void __exit l3_exit(void)
+{
+ l3_bit_del_bus(&l3_adapter);
+}
+#else
+#define l3_init(bits) (0)
+#define l3_exit() do { } while (0)
+#endif
+
+static struct bit_data bit_data;
+
+static int __init bus_init(void)
+{
+ struct bit_data *bit = &bit_data;
+ unsigned long flags;
+ int ret;
+
+ if (machine_is_assabet() || machine_is_pangolin()) {
+ bit->sda = GPIO_GPIO15;
+ bit->scl = GPIO_GPIO18;
+ bit->l3_mode = GPIO_GPIO17;
+ }
+
+#if defined(CONFIG_SA1100_H3600) || defined(CONFIG_SA1100_H3100)
+ if (machine_is_h3600() || machine_is_h3100()) {
+ bit->sda = GPIO_H3600_L3_DATA;
+ bit->scl = GPIO_H3600_L3_CLOCK;
+ bit->l3_mode = GPIO_H3600_L3_MODE;
+ }
+#endif
+
+#ifdef CONFIG_SA1100_STORK
+ if (machine_is_stork()) {
+ bit->sda = GPIO_STORK_L3_I2C_SDA;
+ bit->scl = GPIO_STORK_L3_I2C_SCL;
+ bit->l3_mode = GPIO_STORK_L3_MODE;
+ }
+#endif
+
+ if (!bit->sda)
+ return -ENODEV;
+
+ /*
+ * Default level for L3 mode is low.
+ * We set SCL and SDA high (i2c idle state).
+ */
+ local_irq_save(flags);
+ GPDR &= ~(bit->scl | bit->sda);
+ GPCR = bit->l3_mode | bit->scl | bit->sda;
+ GPDR |= bit->l3_mode;
+ local_irq_restore(flags);
+
+ if (machine_is_assabet()) {
+ /*
+ * Release reset on UCB1300, ADI7171 and UDA1341. We
+ * need to do this here so that we can communicate on
+ * the I2C/L3 buses.
+ */
+ ASSABET_BCR_set(ASSABET_BCR_CODEC_RST);
+ mdelay(1);
+ ASSABET_BCR_clear(ASSABET_BCR_CODEC_RST);
+ mdelay(1);
+ ASSABET_BCR_set(ASSABET_BCR_CODEC_RST);
+ }
+
+ ret = i2c_init(bit);
+ if (ret == 0 && bit->l3_mode) {
+ ret = l3_init(bit);
+ if (ret)
+ i2c_exit();
+ }
+
+ return ret;
+}
+
+static void __exit bus_exit(void)
+{
+ l3_exit();
+ i2c_exit();
+}
+
+module_init(bus_init);
+module_exit(bus_exit);
diff -urN linux-2.4.26/drivers/l3/l3-core.c linux-2.4.26-vrs1/drivers/l3/l3-core.c
--- linux-2.4.26/drivers/l3/l3-core.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/l3/l3-core.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,377 @@
+/*
+ * linux/drivers/l3/l3-core.c
+ *
+ * Copyright (C) 2001 Russell King
+ *
+ * General structure taken from i2c-core.c by Simon G. Vogl
+ *
+ * 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.
+ *
+ * See linux/Documentation/l3 for further documentation.
+ */
+#include <linux/module.h>
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/proc_fs.h>
+#include <linux/kmod.h>
+#include <linux/init.h>
+#include <linux/l3/l3.h>
+
+static DECLARE_MUTEX(adapter_lock);
+static LIST_HEAD(adapter_list);
+
+static DECLARE_MUTEX(driver_lock);
+static LIST_HEAD(driver_list);
+
+/**
+ * l3_add_adapter - register a new L3 bus adapter
+ * @adap: l3_adapter structure for the registering adapter
+ *
+ * Make the adapter available for use by clients using name adap->name.
+ * The adap->adapters list is initialised by this function.
+ *
+ * Returns 0;
+ */
+int l3_add_adapter(struct l3_adapter *adap)
+{
+ INIT_LIST_HEAD(&adap->clients);
+ down(&adapter_lock);
+ list_add(&adap->adapters, &adapter_list);
+ up(&adapter_lock);
+ return 0;
+}
+
+/**
+ * l3_del_adapter - unregister a L3 bus adapter
+ * @adap: l3_adapter structure to unregister
+ *
+ * Remove an adapter from the list of available L3 Bus adapters.
+ *
+ * Returns 0;
+ */
+int l3_del_adapter(struct l3_adapter *adap)
+{
+ down(&adapter_lock);
+ list_del(&adap->adapters);
+ up(&adapter_lock);
+ return 0;
+}
+
+static struct l3_adapter *__l3_get_adapter(const char *name)
+{
+ struct list_head *l;
+
+ list_for_each(l, &adapter_list) {
+ struct l3_adapter *adap = list_entry(l, struct l3_adapter, adapters);
+
+ if (strcmp(adap->name, name) == 0)
+ return adap;
+ }
+
+ return NULL;
+}
+
+/**
+ * l3_get_adapter - get a reference to an adapter
+ * @name: driver name
+ *
+ * Obtain a l3_adapter structure for the specified adapter. If the adapter
+ * is not currently load, then load it. The adapter will be locked in core
+ * until all references are released via l3_put_adapter.
+ */
+struct l3_adapter *l3_get_adapter(const char *name)
+{
+ struct l3_adapter *adap;
+ int try;
+
+ for (try = 0; try < 2; try ++) {
+ down(&adapter_lock);
+ adap = __l3_get_adapter(name);
+ if (adap && !try_inc_mod_count(adap->owner))
+ adap = NULL;
+ up(&adapter_lock);
+
+ if (adap)
+ break;
+
+ if (try == 0)
+ request_module(name);
+ }
+
+ return adap;
+}
+
+/**
+ * l3_put_adapter - release a reference to an adapter
+ * @adap: driver to release reference
+ *
+ * Indicate to the L3 core that you no longer require the adapter reference.
+ * The adapter module may be unloaded when there are no references to its
+ * data structure.
+ *
+ * You must not use the reference after calling this function.
+ */
+void l3_put_adapter(struct l3_adapter *adap)
+{
+ if (adap && adap->owner)
+ __MOD_DEC_USE_COUNT(adap->owner);
+}
+
+/**
+ * l3_add_driver - register a new L3 device driver
+ * @driver - driver structure to make available
+ *
+ * Make the driver available for use by clients using name driver->name.
+ * The driver->drivers list is initialised by this function.
+ *
+ * Returns 0;
+ */
+int l3_add_driver(struct l3_driver *driver)
+{
+ down(&driver_lock);
+ list_add(&driver->drivers, &driver_list);
+ up(&driver_lock);
+ return 0;
+}
+
+/**
+ * l3_del_driver - unregister a L3 device driver
+ * @driver: driver to remove
+ *
+ * Remove an driver from the list of available L3 Bus device drivers.
+ *
+ * Returns 0;
+ */
+int l3_del_driver(struct l3_driver *driver)
+{
+ down(&driver_lock);
+ list_del(&driver->drivers);
+ up(&driver_lock);
+ return 0;
+}
+
+static struct l3_driver *__l3_get_driver(const char *name)
+{
+ struct list_head *l;
+
+ list_for_each(l, &driver_list) {
+ struct l3_driver *drv = list_entry(l, struct l3_driver, drivers);
+
+ if (strcmp(drv->name, name) == 0)
+ return drv;
+ }
+
+ return NULL;
+}
+
+/**
+ * l3_get_driver - get a reference to a driver
+ * @name: driver name
+ *
+ * Obtain a l3_driver structure for the specified driver. If the driver is
+ * not currently load, then load it. The driver will be locked in core
+ * until all references are released via l3_put_driver.
+ */
+struct l3_driver *l3_get_driver(const char *name)
+{
+ struct l3_driver *drv;
+ int try;
+
+ for (try = 0; try < 2; try ++) {
+ down(&adapter_lock);
+ drv = __l3_get_driver(name);
+ if (drv && !try_inc_mod_count(drv->owner))
+ drv = NULL;
+ up(&adapter_lock);
+
+ if (drv)
+ break;
+
+ if (try == 0)
+ request_module(name);
+ }
+
+ return drv;
+}
+
+/**
+ * l3_put_driver - release a reference to a driver
+ * @drv: driver to release reference
+ *
+ * Indicate to the L3 core that you no longer require the driver reference.
+ * The driver module may be unloaded when there are no references to its
+ * data structure.
+ *
+ * You must not use the reference after calling this function.
+ */
+void l3_put_driver(struct l3_driver *drv)
+{
+ if (drv && drv->owner)
+ __MOD_DEC_USE_COUNT(drv->owner);
+}
+
+/**
+ * l3_attach_client - attach a client to an adapter and driver
+ * @client: client structure to attach
+ * @adap: adapter (module) name
+ * @drv: driver (module) name
+ *
+ * Attempt to attach a client (a user of a device driver) to a particular
+ * driver and adapter. If the specified driver or adapter aren't registered,
+ * request_module is used to load the relevant modules.
+ *
+ * Returns 0 on success, or negative error code.
+ */
+int l3_attach_client(struct l3_client *client, const char *adap, const char *drv)
+{
+ struct l3_adapter *adapter = l3_get_adapter(adap);
+ struct l3_driver *driver = l3_get_driver(drv);
+ int ret = -ENOENT;
+
+ if (!adapter)
+ printk(KERN_ERR "%s: unable to get adapter: %s\n",
+ __FUNCTION__, adap);
+ if (!driver)
+ printk(KERN_ERR "%s: unable to get driver: %s\n",
+ __FUNCTION__, drv);
+
+ if (adapter && driver) {
+ ret = 0;
+
+ client->adapter = adapter;
+ client->driver = driver;
+
+ list_add(&client->__adap, &adapter->clients);
+
+ if (driver->attach_client)
+ ret = driver->attach_client(client);
+ }
+
+ if (ret) {
+ l3_put_driver(driver);
+ l3_put_adapter(adapter);
+ }
+ return ret;
+}
+
+/**
+ * l3_detach_client - detach a client from an adapter and driver
+ * @client: client structure to detach
+ *
+ * Detach the client from the adapter and driver.
+ */
+int l3_detach_client(struct l3_client *client)
+{
+ struct l3_adapter *adapter = client->adapter;
+ struct l3_driver *driver = client->driver;
+
+ driver->detach_client(client);
+
+ client->adapter = NULL;
+ client->driver = NULL;
+
+ l3_put_driver(driver);
+ l3_put_adapter(adapter);
+
+ list_del(&client->__adap);
+
+ return 0;
+}
+
+/**
+ * l3_transfer - transfer information on an L3 bus
+ * @adap: adapter structure to perform transfer on
+ * @msgs: array of l3_msg structures describing transfer
+ * @num: number of l3_msg structures
+ *
+ * Transfer the specified messages to/from a device on the L3 bus.
+ *
+ * Returns number of messages successfully transferred, otherwise negative
+ * error code.
+ */
+int l3_transfer(struct l3_adapter *adap, struct l3_msg msgs[], int num)
+{
+ int ret = -ENOSYS;
+
+ if (adap->algo->xfer) {
+ down(adap->lock);
+ ret = adap->algo->xfer(adap, msgs, num);
+ up(adap->lock);
+ }
+ return ret;
+}
+
+/**
+ * l3_write - send data to a device on an L3 bus
+ * @client: registered client structure
+ * @addr: L3 bus address
+ * @buf: buffer for bytes to send
+ * @len: number of bytes to send
+ *
+ * Send len bytes pointed to by buf to device address addr on the L3 bus
+ * described by client.
+ *
+ * Returns the number of bytes transferred, or negative error code.
+ */
+int l3_write(struct l3_client *client, int addr, const char *buf, int len)
+{
+ struct l3_adapter *adap = client->adapter;
+ struct l3_msg msg;
+ int ret;
+
+ msg.addr = addr;
+ msg.flags = 0;
+ msg.buf = (char *)buf;
+ msg.len = len;
+
+ ret = l3_transfer(adap, &msg, 1);
+ return ret == 1 ? len : ret;
+}
+
+/**
+ * l3_read - receive data from a device on an L3 bus
+ * @client: registered client structure
+ * @addr: L3 bus address
+ * @buf: buffer for bytes to receive
+ * @len: number of bytes to receive
+ *
+ * Receive len bytes from device address addr on the L3 bus described by
+ * client to a buffer pointed to by buf.
+ *
+ * Returns the number of bytes transferred, or negative error code.
+ */
+int l3_read(struct l3_client *client, int addr, char *buf, int len)
+{
+ struct l3_adapter *adap = client->adapter;
+ struct l3_msg msg;
+ int ret;
+
+ msg.addr = addr;
+ msg.flags = L3_M_RD;
+ msg.buf = buf;
+ msg.len = len;
+
+ ret = l3_transfer(adap, &msg, 1);
+ return ret == 1 ? len : ret;
+}
+
+EXPORT_SYMBOL(l3_add_adapter);
+EXPORT_SYMBOL(l3_del_adapter);
+EXPORT_SYMBOL(l3_get_adapter);
+EXPORT_SYMBOL(l3_put_adapter);
+
+EXPORT_SYMBOL(l3_add_driver);
+EXPORT_SYMBOL(l3_del_driver);
+EXPORT_SYMBOL(l3_get_driver);
+EXPORT_SYMBOL(l3_put_driver);
+
+EXPORT_SYMBOL(l3_attach_client);
+EXPORT_SYMBOL(l3_detach_client);
+
+EXPORT_SYMBOL(l3_transfer);
+EXPORT_SYMBOL(l3_write);
+EXPORT_SYMBOL(l3_read);
diff -urN linux-2.4.26/drivers/l3/l3-sa1111.c linux-2.4.26-vrs1/drivers/l3/l3-sa1111.c
--- linux-2.4.26/drivers/l3/l3-sa1111.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/l3/l3-sa1111.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,118 @@
+/*
+ * L3 SA1111 algorithm/adapter module.
+ *
+ * By Russell King,
+ * gratuitously ripped from sa1111-uda1341.c by John Dorsey.
+ *
+ * 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/module.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/l3/l3.h>
+
+#include <asm/hardware.h>
+#include <asm/semaphore.h>
+#include <asm/mach-types.h>
+#include <asm/arch/assabet.h>
+#include <asm/hardware/sa1111.h>
+
+static inline unsigned char l3_sa1111_recv_byte(unsigned char addr)
+{
+ unsigned char dat;
+
+ L3_CAR = addr;
+ while ((SASR0 & SASR0_L3RD) == 0)
+ mdelay(1);
+ dat = L3_CDR;
+ SASCR = SASCR_RDD;
+ return dat;
+}
+
+static void l3_sa1111_recv_msg(struct l3_msg *msg)
+{
+ int len = msg->len;
+ char *p = msg->buf;
+
+ if (len > 1) {
+ SACR1 |= SACR1_L3MB;
+ while ((len--) > 1)
+ *p++ = l3_sa1111_recv_byte(msg->addr);
+ }
+ SACR1 &= ~SACR1_L3MB;
+ *p = l3_sa1111_recv_byte(msg->addr);
+}
+
+static inline void l3_sa1111_send_byte(unsigned char addr, unsigned char dat)
+{
+ L3_CAR = addr;
+ L3_CDR = dat;
+ while ((SASR0 & SASR0_L3WD) == 0)
+ mdelay(1);
+ SASCR = SASCR_DTS;
+}
+
+static void l3_sa1111_send_msg(struct l3_msg *msg)
+{
+ int len = msg->len;
+ char *p = msg->buf;
+
+ if (len > 1) {
+ SACR1 |= SACR1_L3MB;
+ while ((len--) > 1)
+ l3_sa1111_send_byte(msg->addr, *p++);
+ }
+ SACR1 &= ~SACR1_L3MB;
+ l3_sa1111_send_byte(msg->addr, *p);
+}
+
+static int l3_sa1111_xfer(struct l3_adapter *adap, struct l3_msg msgs[], int num)
+{
+ int i;
+
+ for (i = 0; i < num; i++) {
+ struct l3_msg *pmsg = &msgs[i];
+
+ if (pmsg->flags & L3_M_RD)
+ l3_sa1111_recv_msg(pmsg);
+ else
+ l3_sa1111_send_msg(pmsg);
+ }
+
+ return num;
+}
+
+static struct l3_algorithm l3_sa1111_algo = {
+ name: "L3 SA1111 algorithm",
+ xfer: l3_sa1111_xfer,
+};
+
+static DECLARE_MUTEX(sa1111_lock);
+
+static struct l3_adapter l3_sa1111_adapter = {
+ owner: THIS_MODULE,
+ name: "l3-sa1111",
+ algo: &l3_sa1111_algo,
+ lock: &sa1111_lock,
+};
+
+static int __init l3_sa1111_init(void)
+{
+ int ret = -ENODEV;
+ if ((machine_is_assabet() && machine_has_neponset()) ||
+ machine_is_jornada720() || machine_is_accelent_sa() ||
+ machine_is_badge4())
+ ret = l3_add_adapter(&l3_sa1111_adapter);
+ return ret;
+}
+
+static void __exit l3_sa1111_exit(void)
+{
+ l3_del_adapter(&l3_sa1111_adapter);
+}
+
+module_init(l3_sa1111_init);
+module_exit(l3_sa1111_exit);
diff -urN linux-2.4.26/drivers/media/video/Config.in linux-2.4.26-vrs1/drivers/media/video/Config.in
--- linux-2.4.26/drivers/media/video/Config.in 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/media/video/Config.in 2004-04-19 10:36:42.000000000 +0100
@@ -52,5 +52,8 @@
if [ "$CONFIG_EXPERIMENTAL" = "y" -a "$CONFIG_HIGHMEM64G" != "y" ]; then
dep_tristate ' Sony Vaio Picturebook Motion Eye Video For Linux (EXPERIMENTAL)' CONFIG_VIDEO_MEYE $CONFIG_VIDEO_DEV $CONFIG_PCI $CONFIG_SONYPI
fi
+# unfortunately, this depends on having CONFIG_FB_CYBER2000
+# set as well - we hook off of the VGA driver
+dep_tristate ' NetWinder Video for Linux (EXPERIMENTAL)' CONFIG_VIDEO_CYBERPRO $CONFIG_VIDEO_DEV $CONFIG_EXPERIMENTAL $CONFIG_ARCH_NETWINDER
endmenu
diff -urN linux-2.4.26/drivers/media/video/Makefile linux-2.4.26-vrs1/drivers/media/video/Makefile
--- linux-2.4.26/drivers/media/video/Makefile 2004-02-27 20:03:25.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/media/video/Makefile 2004-02-23 22:56:20.000000000 +0000
@@ -16,7 +16,7 @@
obj-n :=
obj- :=
-SUB_DIRS :=
+SUB_DIRS :=
MOD_SUB_DIRS := $(SUB_DIRS)
ALL_SUB_DIRS := $(SUB_DIRS)
@@ -47,7 +47,8 @@
obj-$(CONFIG_VIDEO_ZORAN) += zr36067.o i2c-old.o
obj-$(CONFIG_VIDEO_ZORAN_BUZ) += saa7111.o saa7185.o
obj-$(CONFIG_VIDEO_ZORAN_DC10) += saa7110.o adv7175.o
-obj-$(CONFIG_VIDEO_ZORAN_LML33) += bt819.o bt856.o
+obj-$(CONFIG_VIDEO_CYBERPRO) += cyberpro.o i2c-old.o saa7111.o
+obj-$(CONFIG_VIDEO_LML33) += bt856.o bt819.o
obj-$(CONFIG_VIDEO_PMS) += pms.o
obj-$(CONFIG_VIDEO_PLANB) += planb.o
obj-$(CONFIG_VIDEO_VINO) += saa7191.o indycam.o vino.o
diff -urN linux-2.4.26/drivers/media/video/cyberpro.c linux-2.4.26-vrs1/drivers/media/video/cyberpro.c
--- linux-2.4.26/drivers/media/video/cyberpro.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/media/video/cyberpro.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,2091 @@
+/*
+ * CyberPro 2000 video capture driver for the Rebel.com NetWinder
+ *
+ * (C) 1999-2000 Russell King
+ *
+ * Re-written from Rebel.com's vidcap driver.
+ *
+ * Architecture
+ * ------------
+ * The NetWinder video capture consists of a SAA7111 video decoder chip
+ * connected to the CyberPro feature bus. The video data is captured to
+ * the VGA memory, where the CyberPro can overlay (by chromakeying) the
+ * data onto the VGA display.
+ *
+ * The CyberPro also has some nifty features, including a second overlay
+ * and picture in picture mode. We do not currently use these features.
+ *
+ * Power Saving
+ * ------------
+ * Please note that rev.5 NetWinders have the ability to hold the SAA7111
+ * decoder chip into reset, which saves power. The only time at which
+ * this is done is when the driver is unloaded, which implies that this
+ * is compiled as a module.
+ *
+ * In this case, you will want the kernel to automatically load this
+ * driver when required. Place the following line in /etc/modules.conf
+ * to enable this:
+ *
+ * alias char-major-81-0 cyberpro
+ *
+ * The relevant modules will be automatically loaded by modprobe on a
+ * as and when needed basis.
+ *
+ * Capture resolution
+ * ------------------
+ * The maximum useful capture resolution is:
+ * 625-line UK: 716x576
+ * 525-line US: ?
+ *
+ * Bugs
+ * ----
+ * 1. The CyberPro chip seems to be prone to randomly scribbling over VGA
+ * memory [hopefully fixed with new capture enable/freeze stuff]
+ * 2. read()ing pauses video capture, and sometimes triggers bug 1.
+ * 3. mmap() is not supported (requires BM-DMA - see bug 4)
+ * 4. Really, we want to do scatter BM-DMA. Is the CyberPro capable of this?
+ * The Cyberpro seems to randomly scribble to various PCI addresses if you
+ * transfer >16 words.
+ * 5. We shouldn't ignore O_NONBLOCK when reading a frame.
+ * 6. The incoming stream on the NetWinder is CCIR656, which is YUV422.
+ * CyberPro docs also call the format we capture and overlay "YUV422",
+ * but we actually seem to have Y, U, Y, V bytes (is this YUYV format?)
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/videodev.h>
+#include <linux/video_decoder.h>
+#include <linux/mm.h>
+#include <linux/i2c-old.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+#include <linux/kmod.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/pgtable.h>
+#include <asm/pgalloc.h>
+
+MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
+MODULE_DESCRIPTION("CyberPro v4l video grabber");
+MODULE_LICENSE("GPL");
+
+#include "../../video/cyber2000fb.h"
+
+/*
+ * These enable various experimental features. Most of these
+ * are just plain broken or just don't work at the moment.
+ */
+/*
+ * Enable this if you want mmap() access. (see bug 4)
+ */
+#undef USE_MMAP
+
+/*
+ * Enable this if you want mmio access. (slow)
+ */
+#define USE_MMIO
+
+/*
+ * The V4L API is unclear whether VIDIOCSCAPTURE call is allowed while
+ * capture is running. The default is to disallow the call.
+ *
+ * Define this if you do want to allow the call while capture is active.
+ */
+#undef ALLOW_SCAPTURE_WHILE_CAP
+
+/*
+ * We capture two frames
+ */
+#define NR_FRAMES 2
+
+/*
+ * One frame of video is 202 pages, assuming YUV422 format, 716x576
+ */
+#define NR_PAGES 202
+
+struct src_info {
+ unsigned int offset; /* offset of source data */
+ unsigned int x; /* source x */
+ unsigned int y; /* source y */
+ unsigned int width; /* source width */
+ unsigned int height; /* source height */
+ unsigned int format; /* source format */
+};
+
+struct dst_info {
+ unsigned int x; /* destination x */
+ unsigned int y; /* destination y */
+ unsigned int width; /* destination width */
+ unsigned int height; /* destination height */
+ unsigned int chromakey; /* chromakey */
+ unsigned int flags; /* flags (eg, chromakey enable) */
+};
+
+struct cyberpro_vidinfo;
+
+struct win_info {
+ void (*init)(struct cyberpro_vidinfo *dp, struct win_info *wi);
+ void (*set_src)(struct cyberpro_vidinfo *dp, struct win_info *wi);
+ void (*set_win)(struct cyberpro_vidinfo *dp, struct win_info *wi);
+ void (*ctl)(struct cyberpro_vidinfo *dp, struct win_info *wi, int on_off);
+
+ /* public */
+ struct src_info src;
+ struct dst_info dst;
+
+ /* private */
+ unsigned short vid_fifo_ctl;
+ unsigned char vid_fmt;
+ unsigned char vid_disp_ctl1;
+ unsigned char vid_fifo_ctl1;
+ unsigned char vid_misc_ctl1;
+};
+
+struct framebuf {
+ unsigned int offset; /* mmap offset for this frame */
+ unsigned int status;
+#define FRAME_FREE 0
+#define FRAME_DONE 1
+#define FRAME_WAITING 2
+#define FRAME_GRABBING 3
+
+ /*
+ * Bus-Master DMA stuff. Note that we should
+ * probably use the kiovec stuff instead.
+ */
+ unsigned long bus_addr[NR_PAGES]; /* list of pages */
+ struct page *pages[NR_PAGES];
+ void *buffer;
+ int dbg;
+};
+
+struct cyberpro_vidinfo {
+ struct video_device *dev;
+ struct i2c_bus *bus;
+ struct cyberpro_info info; /* host information */
+ unsigned char *regs;
+ unsigned int irq; /* PCI interrupt number */
+
+ /* hardware configuration */
+ unsigned int stream_fmt; /* format of stream from decoder*/
+
+ /* software settings */
+ unsigned int decoder:1; /* decoder loaded */
+ unsigned int interlace:1; /* interlace */
+ unsigned int buf_set:1; /* VIDIOCSFBUF has been issued */
+ unsigned int win_set:1; /* VIDIOCSWIN has been issued */
+ unsigned int cap_active:1; /* capture is active */
+ unsigned int ovl_active:1; /* overlay is active */
+ unsigned int mmaped:1; /* buffer is mmap()d */
+ unsigned int unused:25;
+
+ unsigned int users; /* number of users */
+ unsigned long cap_mem_offset; /* capture framebuffer offset */
+ void * buffer; /* kernel capture buffer */
+ unsigned int norm; /* video standard */
+
+ struct video_capability cap; /* capabilities */
+ struct video_picture pic; /* current picture settings */
+ struct video_buffer buf; /* display parameters */
+ struct video_capture capt; /* video capture params */
+
+ struct win_info *ovl; /* overlay window set */
+ struct win_info ext; /* "Extended" window info */
+ struct win_info v2; /* "V2" window info */
+ struct win_info x2; /* "X2" window info */
+
+ unsigned int bm_offset; /* Cap memory bus master offset */
+ unsigned int bm_index; /* Cap page index */
+
+#ifdef USE_MMAP
+ unsigned int frame_idx; /* currently grabbing frame */
+ unsigned int frame_size;
+ struct framebuf frame[NR_FRAMES];
+ wait_queue_head_t frame_wait;
+#endif
+
+ wait_queue_head_t vbl_wait;
+
+ /*
+ * cyberpro registers
+ */
+ unsigned char cap_mode1;
+ unsigned char cap_mode2;
+ unsigned char cap_miscctl;
+ unsigned char vfac1;
+ unsigned char vfac3;
+};
+
+/*
+ * Our access methods.
+ */
+#define cyberpro_writel(val,reg,dp) writel(val, (dp)->regs + (reg))
+#define cyberpro_writew(val,reg,dp) writew(val, (dp)->regs + (reg))
+#define cyberpro_writeb(val,reg,dp) writeb(val, (dp)->regs + (reg))
+
+#define cyberpro_readb(reg,dp) readb((dp)->regs + (reg))
+
+static inline void
+cyberpro_grphw(unsigned int reg, unsigned int val, struct cyberpro_vidinfo *dp)
+{
+ cyberpro_writew((reg & 255) | val << 8, 0x3ce, dp);
+}
+
+static void cyberpro_grphw8(unsigned int reg, unsigned int val, struct cyberpro_vidinfo *dp)
+{
+ cyberpro_grphw(reg, val, dp);
+}
+
+static unsigned char cyberpro_grphr8(int reg, struct cyberpro_vidinfo *dp)
+{
+ cyberpro_writeb(reg, 0x3ce, dp);
+ return cyberpro_readb(0x3cf, dp);
+}
+
+static void cyberpro_grphw16(int reg, unsigned int val, struct cyberpro_vidinfo *dp)
+{
+ cyberpro_grphw(reg, val, dp);
+ cyberpro_grphw(reg + 1, val >> 8, dp);
+}
+
+static void cyberpro_grphw24(int reg, unsigned int val, struct cyberpro_vidinfo *dp)
+{
+ cyberpro_grphw(reg, val, dp);
+ cyberpro_grphw(reg + 1, val >> 8, dp);
+ cyberpro_grphw(reg + 2, val >> 16, dp);
+}
+
+#if 0
+static void
+cyberpro_dbg_dump(void)
+{
+ int i;
+ unsigned char idx[] =
+ { 0x30, 0x3e, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d,
+ 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad };
+ printk(KERN_DEBUG);
+ for (i = 0; i < sizeof(idx); i++)
+ printk("%02x ", idx[i]);
+ printk("\n" KERN_DEBUG);
+ for (i = 0; i < sizeof(idx); i++)
+ printk("%02x ", cyberpro_grphr8(idx[i]));
+ printk("\n");
+}
+#endif
+
+/*
+ * On the NetWinder, we can put the SAA7111 to sleep by holding
+ * it in reset.
+ *
+ * Note: once we have initialised the SAA7111, we can't put it back to
+ * sleep and expect it to keep its settings. Maybe a better solution
+ * is to register/de-register the i2c bus in open/release?
+ */
+static void
+decoder_sleep(int sleep)
+{
+#ifdef CONFIG_ARCH_NETWINDER
+ extern spinlock_t gpio_lock;
+
+ spin_lock_irq(&gpio_lock);
+ cpld_modify(CPLD_7111_DISABLE, sleep ? CPLD_7111_DISABLE : 0);
+ spin_unlock_irq(&gpio_lock);
+
+ if (!sleep) {
+ /*
+ * wait 20ms for device to wake up
+ */
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(HZ / 50);
+ }
+#endif
+}
+
+/* -------------------------------- I2C support ---------------------------- */
+
+#define I2C_DELAY 100
+
+static void
+cyberpro_i2c_setlines(struct i2c_bus *bus, int ctrl, int data)
+{
+ struct cyberpro_vidinfo *dp = bus->data;
+ int v;
+
+ v = (ctrl ? EXT_LATCH2_I2C_CLKEN : 0x00) | (data ? EXT_LATCH2_I2C_DATEN : 0x00);
+ cyberpro_grphw8(EXT_LATCH2, v, dp);
+
+ udelay(I2C_DELAY);
+}
+
+static int
+cyberpro_i2c_getdataline(struct i2c_bus *bus)
+{
+ struct cyberpro_vidinfo *dp = bus->data;
+ unsigned long flags;
+ int v;
+
+ save_flags(flags);
+ cli();
+
+ v = cyberpro_grphr8(EXT_LATCH2, dp);
+
+ restore_flags(flags);
+
+ return v & EXT_LATCH2_I2C_DAT ? 1 : 0;
+}
+
+static void
+cyberpro_i2c_attach(struct i2c_bus *bus, int id)
+{
+ struct cyberpro_vidinfo *dp = bus->data;
+ int zero = 0;
+
+ if (id == I2C_DRIVERID_VIDEODECODER) {
+ __u16 norm = dp->norm;
+ i2c_control_device(bus, id, DECODER_SET_NORM, &norm);
+ i2c_control_device(bus, id, DECODER_SET_PICTURE, &dp->pic);
+ i2c_control_device(bus, id, DECODER_ENABLE_OUTPUT, &zero);
+
+ dp->decoder = 1;
+ }
+}
+
+static void
+cyberpro_i2c_detach(struct i2c_bus *bus, int id)
+{
+ struct cyberpro_vidinfo *dp = bus->data;
+
+ if (id == I2C_DRIVERID_VIDEODECODER)
+ dp->decoder = 0;
+}
+
+static struct i2c_bus cyberpro_i2c_bus = {
+ name: "",
+ id: I2C_BUSID_CYBER2000,
+ bus_lock: SPIN_LOCK_UNLOCKED,
+ attach_inform: cyberpro_i2c_attach,
+ detach_inform: cyberpro_i2c_detach,
+ i2c_setlines: cyberpro_i2c_setlines,
+ i2c_getdataline: cyberpro_i2c_getdataline,
+};
+
+/*------------------------- Extended Overlay Window -------------------------
+ * Initialise 1st overlay window (works)
+ */
+static void
+cyberpro_ext_init(struct cyberpro_vidinfo *dp, struct win_info *wi)
+{
+ wi->vid_fifo_ctl = 0xf87c;
+ wi->vid_fmt = EXT_VID_FMT_YUV422;
+ wi->vid_disp_ctl1 = EXT_VID_DISP_CTL1_VINTERPOL_OFF |
+ EXT_VID_DISP_CTL1_NOCLIP;
+ wi->vid_fifo_ctl1 = EXT_VID_FIFO_CTL1_INTERLEAVE |
+ EXT_VID_FIFO_CTL1_OE_HIGH;
+ wi->vid_misc_ctl1 = 0;
+
+ cyberpro_grphw8 (EXT_VID_DISP_CTL1, wi->vid_disp_ctl1, dp);
+ cyberpro_grphw16(EXT_DDA_X_INIT, 0x0800, dp);
+ cyberpro_grphw16(EXT_DDA_Y_INIT, 0x0800, dp);
+ cyberpro_grphw16(EXT_VID_FIFO_CTL, wi->vid_fifo_ctl, dp);
+ cyberpro_grphw8 (EXT_VID_FIFO_CTL1, wi->vid_fifo_ctl1, dp);
+}
+
+/*
+ * Set the source parameters for the extended window
+ */
+static void
+cyberpro_ext_set_src(struct cyberpro_vidinfo *dp, struct win_info *wi)
+{
+ unsigned int phase, pitch;
+
+ pitch = (wi->src.width >> 2) & 0x0fff;
+ phase = (wi->src.width + 3) >> 2;
+
+ wi->vid_fmt &= ~7;
+ switch (wi->src.format) {
+ case VIDEO_PALETTE_RGB565: wi->vid_fmt |= EXT_VID_FMT_RGB565; break;
+ case VIDEO_PALETTE_RGB24: wi->vid_fmt |= EXT_VID_FMT_RGB888_24; break;
+ case VIDEO_PALETTE_RGB32: wi->vid_fmt |= EXT_VID_FMT_RGB888_32; break;
+ case VIDEO_PALETTE_RGB555: wi->vid_fmt |= EXT_VID_FMT_RGB555; break;
+ case VIDEO_PALETTE_YUV422: wi->vid_fmt |= EXT_VID_FMT_YUV422; break;
+ }
+
+ cyberpro_grphw24(EXT_MEM_START, wi->src.offset, dp);
+ cyberpro_grphw16(EXT_SRC_WIDTH, pitch | ((phase << 4) & 0xf000), dp);
+ cyberpro_grphw8 (EXT_SRC_WIN_WIDTH, phase, dp);
+ cyberpro_grphw8 (EXT_VID_FMT, wi->vid_fmt, dp);
+}
+
+/*
+ * Set overlay1 window
+ */
+static void
+cyberpro_ext_set_win(struct cyberpro_vidinfo *dp, struct win_info *wi)
+{
+ unsigned int xscale, yscale;
+ unsigned int xoff, yoff;
+
+ /*
+ * Note: the offset does not appear to be influenced by
+ * hardware scrolling.
+ */
+ xoff = yoff = 0;
+
+ xoff += wi->dst.x;
+ yoff += wi->dst.y;
+
+ xscale = wi->src.width;
+
+ if (wi->dst.width >= wi->src.width * 2) {
+ wi->vid_fmt |= EXT_VID_FMT_DBL_H_PIX;
+ xscale *= 2;
+ } else {
+ wi->vid_fmt &= ~EXT_VID_FMT_DBL_H_PIX;
+ }
+
+ xscale = ((xscale - /*2*/0) * 4096) / wi->dst.width;
+ yscale = ((wi->src.height - /*2*/0) * 4096) / wi->dst.height;
+
+ cyberpro_grphw16(EXT_X_START, xoff, dp);
+ cyberpro_grphw16(EXT_X_END, xoff + wi->dst.width, dp);
+ cyberpro_grphw16(EXT_Y_START, yoff, dp);
+ cyberpro_grphw16(EXT_Y_END, yoff + wi->dst.height, dp);
+ cyberpro_grphw24(EXT_COLOUR_COMPARE, wi->dst.chromakey, dp);
+ cyberpro_grphw16(EXT_DDA_X_INC, xscale, dp);
+ cyberpro_grphw16(EXT_DDA_Y_INC, yscale, dp);
+ cyberpro_grphw8(EXT_VID_FMT, wi->vid_fmt, dp);
+
+ if (wi->dst.flags & VIDEO_WINDOW_CHROMAKEY)
+ wi->vid_disp_ctl1 &= ~EXT_VID_DISP_CTL1_IGNORE_CCOMP;
+ else
+ wi->vid_disp_ctl1 |= EXT_VID_DISP_CTL1_IGNORE_CCOMP;
+}
+
+/*
+ * Enable or disable the 1st overlay window. Note that for anything
+ * useful to be displayed, we must have capture enabled.
+ */
+static void
+cyberpro_ext_ctl(struct cyberpro_vidinfo *dp, struct win_info *wi, int on)
+{
+ if (on)
+ wi->vid_disp_ctl1 |= EXT_VID_DISP_CTL1_ENABLE_WINDOW;
+ else
+ wi->vid_disp_ctl1 &= ~EXT_VID_DISP_CTL1_ENABLE_WINDOW;
+
+ cyberpro_grphw8(EXT_VID_DISP_CTL1, wi->vid_disp_ctl1, dp);
+}
+
+/*------------------------------- V2 Overlay Window -------------------------
+ * Initialise 2nd overlay window (guesswork)
+ */
+static void
+cyberpro_v2_init(struct cyberpro_vidinfo *dp, struct win_info *wi)
+{
+ wi->vid_fifo_ctl = 0xf87c;
+ wi->vid_fmt = EXT_VID_FMT_YUV422;
+ wi->vid_disp_ctl1 = EXT_VID_DISP_CTL1_VINTERPOL_OFF |
+ EXT_VID_DISP_CTL1_NOCLIP;
+ wi->vid_fifo_ctl1 = 0x06;
+ wi->vid_misc_ctl1 = 0;
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_Y, dp);
+ cyberpro_grphw8 (Y_V2_VID_DISP_CTL1, wi->vid_disp_ctl1, dp);
+ /* No DDA init values */
+ cyberpro_grphw16(Y_V2_VID_FIFO_CTL, wi->vid_fifo_ctl, dp);
+ cyberpro_grphw8 (Y_V2_VID_FIFO_CTL1, wi->vid_fifo_ctl1, dp);
+}
+
+/*
+ * Set the source parameters for the v2 window
+ */
+static void
+cyberpro_v2_set_src(struct cyberpro_vidinfo *dp, struct win_info *wi)
+{
+ unsigned int phase, pitch;
+
+ pitch = (wi->src.width >> 2) & 0x0fff;
+ phase = (wi->src.width + 3) >> 2;
+
+ wi->vid_fmt &= ~7;
+ switch (wi->src.format) {
+ case VIDEO_PALETTE_RGB565: wi->vid_fmt |= EXT_VID_FMT_RGB565; break;
+ case VIDEO_PALETTE_RGB24: wi->vid_fmt |= EXT_VID_FMT_RGB888_24; break;
+ case VIDEO_PALETTE_RGB32: wi->vid_fmt |= EXT_VID_FMT_RGB888_32; break;
+ case VIDEO_PALETTE_RGB555: wi->vid_fmt |= EXT_VID_FMT_RGB555; break;
+ case VIDEO_PALETTE_YUV422: wi->vid_fmt |= EXT_VID_FMT_YUV422; break;
+ }
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_X, dp);
+ cyberpro_grphw24(X_V2_VID_MEM_START, wi->src.offset, dp);
+ cyberpro_grphw16(X_V2_VID_SRC_WIDTH, pitch | ((phase << 4) & 0xf000), dp);
+ cyberpro_grphw8 (X_V2_VID_SRC_WIN_WIDTH, phase, dp);
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_Y, dp);
+ cyberpro_grphw8(Y_V2_VID_FMT, wi->vid_fmt, dp);
+}
+
+/*
+ * Set v2 window
+ */
+static void
+cyberpro_v2_set_win(struct cyberpro_vidinfo *dp, struct win_info *wi)
+{
+ unsigned int xscale, yscale;
+ unsigned int xoff, yoff;
+
+ /*
+ * Note: the offset does not appear to be influenced by
+ * hardware scrolling.
+ */
+ xoff = yoff = 0;
+
+ xoff += wi->dst.x;
+ yoff += wi->dst.y;
+
+ xscale = (wi->src.width * 4096) / wi->dst.width;
+ yscale = (wi->src.height * 4096) / wi->dst.height;
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_X, dp);
+ cyberpro_grphw16(X_V2_X_START, xoff, dp);
+ cyberpro_grphw16(X_V2_X_END, xoff + wi->dst.width, dp);
+ cyberpro_grphw16(X_V2_Y_START, yoff, dp);
+ cyberpro_grphw16(X_V2_Y_END, yoff + wi->dst.height, dp);
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_Y, dp);
+ cyberpro_grphw16(Y_V2_DDA_X_INC, xscale, dp);
+ cyberpro_grphw16(Y_V2_DDA_Y_INC, yscale, dp);
+}
+
+/*
+ * Enable or disable the 2nd overlay window. Note that for anything
+ * useful to be displayed, we must have capture enabled.
+ */
+static void
+cyberpro_v2_ctl(struct cyberpro_vidinfo *dp, struct win_info *wi, int on)
+{
+ if (on)
+ wi->vid_disp_ctl1 |= EXT_VID_DISP_CTL1_ENABLE_WINDOW;
+ else
+ wi->vid_disp_ctl1 &= ~EXT_VID_DISP_CTL1_ENABLE_WINDOW;
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_Y, dp);
+ cyberpro_grphw8(Y_V2_VID_DISP_CTL1, wi->vid_disp_ctl1, dp);
+}
+
+/*--------------------------- X2 Overlay Window -----------------------------
+ * Initialise 3rd overlay window (guesswork)
+ */
+static void
+cyberpro_x2_init(struct cyberpro_vidinfo *dp, struct win_info *wi)
+{
+ wi->vid_fmt = EXT_VID_FMT_YUV422;
+ wi->vid_disp_ctl1 = 0x40;
+ wi->vid_misc_ctl1 = 0;
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_K, dp);
+ cyberpro_grphw8 (K_X2_VID_DISP_CTL1, wi->vid_disp_ctl1, dp);
+ cyberpro_grphw16(K_X2_DDA_X_INIT, 0x0800, dp);
+ cyberpro_grphw16(K_X2_DDA_Y_INIT, 0x0800, dp);
+}
+
+/*
+ * Set the source parameters for the x2 window
+ */
+static void
+cyberpro_x2_set_src(struct cyberpro_vidinfo *dp, struct win_info *wi)
+{
+ unsigned int phase, pitch;
+
+ pitch = (wi->src.width >> 2) & 0x0fff;
+ phase = (wi->src.width + 3) >> 2;
+
+ wi->vid_fmt &= ~7;
+ switch (wi->src.format) {
+ case VIDEO_PALETTE_RGB565: wi->vid_fmt |= EXT_VID_FMT_RGB565; break;
+ case VIDEO_PALETTE_RGB24: wi->vid_fmt |= EXT_VID_FMT_RGB888_24; break;
+ case VIDEO_PALETTE_RGB32: wi->vid_fmt |= EXT_VID_FMT_RGB888_32; break;
+ case VIDEO_PALETTE_RGB555: wi->vid_fmt |= EXT_VID_FMT_RGB555; break;
+ case VIDEO_PALETTE_YUV422: wi->vid_fmt |= EXT_VID_FMT_YUV422; break;
+ }
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_J, dp);
+ cyberpro_grphw24(J_X2_VID_MEM_START, wi->src.offset, dp);
+ cyberpro_grphw16(J_X2_VID_SRC_WIDTH, pitch | ((phase << 4) & 0xf000), dp);
+ cyberpro_grphw8 (J_X2_VID_SRC_WIN_WIDTH, phase, dp);
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_K, dp);
+ cyberpro_grphw8(K_X2_VID_FMT, wi->vid_fmt, dp);
+}
+
+/*
+ * Set x2 window
+ */
+static void
+cyberpro_x2_set_win(struct cyberpro_vidinfo *dp, struct win_info *wi)
+{
+ unsigned int xscale, yscale;
+ unsigned int xoff, yoff;
+
+ /*
+ * Note: the offset does not appear to be influenced by
+ * hardware scrolling.
+ */
+ xoff = yoff = 0;
+
+ xoff += wi->dst.x;
+ yoff += wi->dst.y;
+
+ xscale = (wi->src.width * 4096) / wi->dst.width;
+ yscale = (wi->src.height * 4096) / wi->dst.height;
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_J, dp);
+ cyberpro_grphw16(J_X2_X_START, xoff, dp);
+ cyberpro_grphw16(J_X2_X_END, xoff + wi->dst.width, dp);
+ cyberpro_grphw16(J_X2_Y_START, yoff, dp);
+ cyberpro_grphw16(J_X2_Y_END, yoff + wi->dst.height, dp);
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_K, dp);
+ cyberpro_grphw16(K_X2_DDA_X_INC, xscale, dp);
+ cyberpro_grphw16(K_X2_DDA_Y_INC, yscale, dp);
+}
+
+/*
+ * Enable or disable the 3rd overlay window. Note that for anything
+ * useful to be displayed, we must have capture enabled.
+ */
+static void
+cyberpro_x2_ctl(struct cyberpro_vidinfo *dp, struct win_info *wi, int on)
+{
+ if (on)
+ wi->vid_disp_ctl1 |= EXT_VID_DISP_CTL1_ENABLE_WINDOW;
+ else
+ wi->vid_disp_ctl1 &= ~EXT_VID_DISP_CTL1_ENABLE_WINDOW;
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_K, dp);
+ cyberpro_grphw8(K_X2_VID_DISP_CTL1, wi->vid_disp_ctl1, dp);
+}
+
+/* ------------------------------------------------------------------------- */
+
+#if 0
+static void reset_seq(struct cyberpro_vidinfo *dp)
+{
+ unsigned char ext_mem_ctl = cyberpro_grphr8(0x70, dp);
+
+ cyberpro_grphw8(ext_mem_ctl | 0x80, 0x70, dp);
+ cyberpro_grphw8(ext_mem_ctl, 0x70, dp);
+}
+#endif
+
+#ifdef USE_MMAP
+/*
+ * Buffer support
+ */
+static int
+cyberpro_alloc_frame_buffer(struct cyberpro_vidinfo *dp,
+ struct framebuf *frame)
+{
+ unsigned long addr;
+ void *buffer;
+ int pgidx;
+
+ if (frame->buffer)
+ return 0;
+
+ /*
+ * Allocate frame buffer
+ */
+ buffer = vmalloc(NR_PAGES * PAGE_SIZE);
+
+ if (frame->buffer) {
+ vfree(buffer);
+ return 0;
+ }
+
+ if (!buffer)
+ return -ENOMEM;
+
+ printk("Buffer allocated @ %p [", buffer);
+
+ frame->buffer = buffer;
+ frame->dbg = 1;
+
+ /*
+ * Don't leak information from the kernel.
+ */
+ memset(buffer, 0x5a, NR_PAGES * PAGE_SIZE);
+
+ /*
+ * Now, reserve all the pages, and calculate
+ * each pages' bus address.
+ */
+ addr = (unsigned long)buffer;
+ for (pgidx = 0; pgidx < NR_PAGES; pgidx++, addr += PAGE_SIZE) {
+ struct page *page;
+ pgd_t *pgd;
+ pmd_t *pmd;
+ pte_t *pte;
+
+ /*
+ * The page should be present. If not,
+ * vmalloc has gone nuts.
+ */
+ pgd = pgd_offset_k(addr);
+ if (pgd_none(*pgd))
+ BUG();
+ pmd = pmd_offset(pgd, addr);
+ if (pmd_none(*pmd))
+ BUG();
+ pte = pte_offset(pmd, addr);
+ if (!pte_present(*pte))
+ BUG();
+
+ page = pte_page(*pte);
+
+ frame->bus_addr[pgidx] = virt_to_bus((void *)page_address(page));
+ frame->pages[pgidx] = page;
+ SetPageReserved(page);
+
+ printk("%08lx (%08lx) ", page_address(page), frame->bus_addr[pgidx]);
+ }
+ printk("\n");
+
+ return 0;
+}
+
+static void
+cyberpro_frames_free_one(struct cyberpro_vidinfo *dp, struct framebuf *frame)
+{
+ void *buffer;
+ int pgidx;
+
+ frame->status = FRAME_FREE;
+ buffer = frame->buffer;
+ frame->buffer = NULL;
+
+ if (buffer) {
+ for (pgidx = 0; pgidx < NR_PAGES; pgidx++) {
+ frame->bus_addr[pgidx] = 0;
+ ClearPageReserved(frame->pages[pgidx]);
+ frame->pages[pgidx] = NULL;
+ }
+ vfree(buffer);
+ }
+}
+
+static void
+cyberpro_busmaster_frame(struct cyberpro_vidinfo *dp, struct framebuf *frame)
+{
+ unsigned long bus_addr;
+
+ bus_addr = frame->bus_addr[dp->bm_index];
+
+ if (frame->dbg) {
+ printk("Frame%d: %06x -> %08lx\n",
+ dp->frame_idx,
+ dp->bm_offset,
+ bus_addr);
+ }
+
+ cyber2000_outw(dp->bm_offset, BM_VID_ADDR_LOW);
+ cyber2000_outw(dp->bm_offset >> 16, BM_VID_ADDR_HIGH);
+
+ cyber2000_outw(bus_addr, BM_ADDRESS_LOW);
+ cyber2000_outw(bus_addr >> 16, BM_ADDRESS_HIGH);
+
+ /*
+ * One page-full only
+ */
+ cyber2000_outw(1023, BM_LENGTH);
+
+ /*
+ * Load length
+ */
+ cyber2000_outw(BM_CONTROL_INIT, BM_CONTROL);
+
+ /*
+ * Enable transfer
+ */
+ cyber2000_outw(BM_CONTROL_ENABLE|BM_CONTROL_IRQEN, BM_CONTROL);
+
+ dp->bm_offset += 1024;
+ dp->bm_index += 1;
+}
+
+static void cyberpro_busmaster_interrupt(struct cyberpro_vidinfo *dp)
+{
+ struct framebuf *frame = dp->frame + dp->frame_idx;
+
+ /*
+ * Disable Busmaster operations
+ */
+ cyber2000_outw(0, BM_CONTROL);
+
+ if (frame->status == FRAME_GRABBING) {
+ /*
+ * We are still grabbing this frame to system
+ * memory. Transfer next page if there are
+ * more, or else flag this frame as complete.
+ */
+ if (dp->bm_index < NR_PAGES)
+ cyberpro_busmaster_frame(dp);
+ else {
+ unsigned int idx;
+
+ frame->status = FRAME_DONE;
+ frame->dbg = 0;
+
+ idx = dp->frame_idx + 1;
+ if (idx >= NR_FRAMES)
+ idx = 0;
+
+ dp->frame_idx = idx;
+
+ wake_up(&dp->frame_wait);
+ }
+ }
+}
+
+static void cyberpro_frames_vbl(struct cyberpro_vidinfo *dp, unsigned int stat)
+{
+ struct framebuf *frame = dp->frame + dp->frame_idx;
+
+ /*
+ * No point capturing frames if the grabber isn't active.
+ */
+ if (stat & EXT_ROM_UCB4GH_FREEZE)
+ return;
+
+ /*
+ * If the next buffer is ready for grabbing,
+ * set up the bus master registers for the
+ * transfer.
+ */
+ if (frame->status == FRAME_WAITING) {
+ frame->status = FRAME_GRABBING;
+
+ dp->bm_offset = dp->cap_mem_offset;
+ dp->bm_index = 0;
+
+ cyberpro_busmaster_frame(dp, frame);
+ }
+}
+
+static void __init cyberpro_frames_init(struct cyberpro_vidinfo *dp)
+{
+ unsigned int offset, maxsize;
+ int i;
+
+ init_waitqueue_head(&dp->frame_wait);
+
+ maxsize = 2 * dp->cap.maxwidth * dp->cap.maxheight;
+ dp->frame_size = PAGE_ALIGN(maxsize);
+ dp->frame_idx = 0;
+
+ for (i = offset = 0; i < NR_FRAMES; i++) {
+ dp->frame[i].offset = offset;
+ dp->frame[i].status = FRAME_FREE;
+ offset += dp->frame_size;
+ }
+}
+
+static void cyberpro_frames_free(struct cyberpro_vidinfo *dp)
+{
+ int i;
+
+ dp->mmaped = 0;
+
+ /*
+ * Free all frame buffers
+ */
+ for (i = 0; i < NR_FRAMES; i++)
+ cyberpro_frames_free_one(dp, dp->frame + i);
+}
+
+#else
+#define cyberpro_frames_vbl(dp,stat) do { } while (0)
+#define cyberpro_frames_init(dp) do { } while (0)
+#define cyberpro_frames_free(dp) do { } while (0)
+#endif
+
+/*
+ * CyberPro Interrupts
+ * -------------------
+ *
+ * We don't really know how to signal an IRQ clear to the chip. However,
+ * disabling and re-enabling the capture interrupt enable seems to do what
+ * we want.
+ */
+static void cyberpro_interrupt(int nr, void *dev_id, struct pt_regs *regs)
+{
+ struct cyberpro_vidinfo *dp = dev_id;
+ unsigned char old_grphidx;
+ unsigned int status;
+
+ /*
+ * Save old graphics index register
+ */
+ old_grphidx = cyberpro_readb(0x3ce, dp);
+
+ status = cyberpro_grphr8(EXT_ROM_UCB4GH, dp);
+
+ /*
+ * Was it due to the Capture VSYNC?
+ */
+ if (status & EXT_ROM_UCB4GH_INTSTAT) {
+ /*
+ * Frob the IRQ enable bit to drop the request.
+ */
+ cyberpro_grphw8(VFAC_CTL3, dp->vfac3 & ~VFAC_CTL3_CAP_IRQ, dp);
+ cyberpro_grphw8(VFAC_CTL3, dp->vfac3, dp);
+
+ cyberpro_frames_vbl(dp, status);
+ wake_up(&dp->vbl_wait);
+ }
+
+ /*
+ * Restore graphics controller index
+ */
+ cyberpro_writeb(old_grphidx, 0x3ce, dp);
+
+#ifdef USE_MMAP
+ /*
+ * Do Bus-Master IRQ stuff
+ */
+ if (cyber2000_inb(BM_CONTROL) & (1 << 7))
+ cyberpro_busmaster_interrupt(dp);
+#endif
+}
+
+static void cyberpro_capture(struct cyberpro_vidinfo *dp, int on)
+{
+ DECLARE_WAITQUEUE(wait, current);
+ unsigned int status;
+
+ status = cyberpro_grphr8(EXT_ROM_UCB4GH, dp);
+
+ add_wait_queue(&dp->vbl_wait, &wait);
+ set_current_state(TASK_UNINTERRUPTIBLE);
+
+ if (!!on ^ !(status & EXT_ROM_UCB4GH_FREEZE)) {
+ if (on) {
+ schedule_timeout(40 * HZ / 1000);
+ dp->vfac1 &= ~(VFAC_CTL1_FREEZE_CAPTURE|VFAC_CTL1_FREEZE_CAPTURE_SYNC);
+ cyberpro_grphw8(VFAC_CTL1, dp->vfac1, dp);
+
+ status = cyberpro_grphr8(EXT_ROM_UCB4GH, dp);
+ } else {
+ dp->vfac1 |= VFAC_CTL1_FREEZE_CAPTURE_SYNC;
+ cyberpro_grphw8(VFAC_CTL1, dp->vfac1, dp);
+
+ status = cyberpro_grphr8(EXT_ROM_UCB4GH, dp);
+ if (!(status & EXT_ROM_UCB4GH_FREEZE))
+ schedule_timeout(40 * HZ / 1000);
+ }
+ }
+
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dp->vbl_wait, &wait);
+}
+
+static void cyberpro_capture_one(struct cyberpro_vidinfo *dp)
+{
+ struct task_struct *tsk = current;
+ DECLARE_WAITQUEUE(wait, tsk);
+ unsigned int status;
+ unsigned long policy, rt_priority;
+
+ policy = tsk->policy;
+ rt_priority = tsk->rt_priority;
+
+ tsk->policy = SCHED_FIFO;
+ tsk->rt_priority = 1;
+
+ status = cyberpro_grphr8(EXT_ROM_UCB4GH, dp);
+
+ add_wait_queue(&dp->vbl_wait, &wait);
+ set_current_state(TASK_UNINTERRUPTIBLE);
+
+ schedule_timeout(40 * HZ / 1000);
+ dp->vfac1 &= ~(VFAC_CTL1_FREEZE_CAPTURE|VFAC_CTL1_FREEZE_CAPTURE_SYNC);
+ cyberpro_grphw8(VFAC_CTL1, dp->vfac1, dp);
+
+ status = cyberpro_grphr8(EXT_ROM_UCB4GH, dp);
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(40 * HZ / 1000);
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(40 * HZ / 1000);
+
+ dp->vfac1 |= VFAC_CTL1_FREEZE_CAPTURE_SYNC;
+ cyberpro_grphw8(VFAC_CTL1, dp->vfac1, dp);
+
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ status = cyberpro_grphr8(EXT_ROM_UCB4GH, dp);
+
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dp->vbl_wait, &wait);
+
+ tsk->policy = policy;
+ tsk->rt_priority = rt_priority;
+}
+
+static void cyberpro_capture_set_win(struct cyberpro_vidinfo *dp)
+{
+ unsigned int xstart, xend, ystart, yend;
+
+ xstart = 4 + dp->capt.x;
+ xend = xstart + dp->capt.width;
+
+ if (dp->cap_mode1 & EXT_CAP_MODE1_8BIT) {
+ /* 8-bit capture */
+ xstart *= 2;
+ xend *= 2;
+ }
+
+ xstart -= 1;
+ xend -= 1;
+
+ ystart = 18 + dp->capt.y;
+ yend = ystart + dp->capt.height / 2;
+
+ cyberpro_grphw16(CAP_X_START, xstart, dp);
+ cyberpro_grphw16(CAP_X_END, xend + 1, dp);
+ cyberpro_grphw16(CAP_Y_START, ystart, dp);
+ cyberpro_grphw16(CAP_Y_END, yend + 2, dp);
+
+ /*
+ * This should take account of capt.decimation
+ */
+ cyberpro_grphw16(CAP_DDA_X_INIT, 0x0800, dp);
+ cyberpro_grphw16(CAP_DDA_X_INC, 0x1000, dp);
+ cyberpro_grphw16(CAP_DDA_Y_INIT, 0x0800, dp);
+ cyberpro_grphw16(CAP_DDA_Y_INC, 0x1000, dp);
+
+ cyberpro_grphw8(CAP_PITCH, dp->capt.width >> 2, dp);
+}
+
+static void cyberpro_set_interlace(struct cyberpro_vidinfo *dp)
+{
+ /*
+ * set interlace mode
+ */
+ if (dp->interlace) {
+ dp->vfac3 |= VFAC_CTL3_CAP_INTERLACE;
+ dp->cap_miscctl &= ~CAP_CTL_MISC_ODDEVEN;
+ dp->ovl->src.height = dp->capt.height;
+ } else {
+ dp->vfac3 &= ~VFAC_CTL3_CAP_INTERLACE;
+ dp->cap_miscctl |= CAP_CTL_MISC_ODDEVEN;
+ dp->ovl->src.height = dp->capt.height / 2;
+ }
+
+ cyberpro_grphw8(VFAC_CTL3, dp->vfac3, dp);
+ cyberpro_grphw8(CAP_CTL_MISC, dp->cap_miscctl, dp);
+
+ dp->ovl->set_src(dp, dp->ovl);
+
+ if (dp->win_set)
+ dp->ovl->set_win(dp, dp->ovl);
+}
+
+/*
+ * Calculate and set the address of the capture buffer. Note we
+ * also update the extended memory buffer for the overlay window.
+ *
+ * base: phys base address of display
+ * width: pixel width of display
+ * height: height of display
+ * depth: depth of display (8/16/24)
+ * bytesperline: number of bytes on a line
+ *
+ * We place the capture buffer 16K after the screen.
+ */
+static int
+cyberpro_set_buffer(struct cyberpro_vidinfo *dp, struct video_buffer *b)
+{
+ unsigned long screensize, maxbufsz;
+
+ if (b->height <= 0 || b->width <= 0 || b->bytesperline <= 0)
+ return -EINVAL;
+
+ maxbufsz = dp->cap.maxwidth * dp->cap.maxheight * 2;
+ screensize = b->height * b->bytesperline + 16384;
+
+ if ((screensize + maxbufsz) >= dp->info.fb_size)
+ return -EINVAL;
+
+ dp->buf.base = b->base;
+ dp->buf.width = b->width;
+ dp->buf.height = b->height;
+ dp->buf.depth = b->depth;
+ dp->buf.bytesperline = b->bytesperline;
+ dp->cap_mem_offset = screensize >> 2;
+
+ cyberpro_grphw24(CAP_MEM_START, dp->cap_mem_offset, dp);
+
+ /*
+ * Setup the overlay source information.
+ */
+ dp->ovl->src.offset = dp->cap_mem_offset;
+ dp->ovl->set_src(dp, dp->ovl);
+
+ return 0;
+}
+
+static void cyberpro_hw_init(struct cyberpro_vidinfo *dp)
+{
+ unsigned char old;
+
+ /*
+ * Enable access to bus-master registers
+ */
+ dp->info.enable_extregs(dp->info.info);
+
+ dp->vfac1 = VFAC_CTL1_PHILIPS |
+ VFAC_CTL1_FREEZE_CAPTURE |
+ VFAC_CTL1_FREEZE_CAPTURE_SYNC;
+ dp->vfac3 = VFAC_CTL3_CAP_IRQ;
+
+ dp->cap_miscctl = CAP_CTL_MISC_DISPUSED |
+ CAP_CTL_MISC_SYNCTZOR |
+ CAP_CTL_MISC_SYNCTZHIGH;
+
+ /*
+ * Setup bus-master mode
+ */
+ cyberpro_grphw8(BM_CTRL1, 0x88, dp);
+ cyberpro_grphw8(PCI_BM_CTL, PCI_BM_CTL_ENABLE, dp);
+ cyberpro_grphw8(BM_CTRL0, 0x44, dp);
+ cyberpro_grphw8(BM_CTRL1, 0x84, dp);
+
+ cyberpro_grphw24(CAP_MEM_START, 0, dp);
+
+ cyberpro_grphw8(VFAC_CTL1, dp->vfac1, dp);
+ cyberpro_grphw8(VFAC_CTL3, dp->vfac3, dp);
+ cyberpro_grphw8(VFAC_CTL2, 0, dp);
+
+ cyberpro_grphw8(REG_BANK, REG_BANK_Y, dp);
+ cyberpro_grphw8(EXT_TV_CTL, 0x80, dp);
+
+ cyberpro_grphw8(EXT_CAP_CTL1, 0x3f, dp); /* disable PIP */
+ cyberpro_grphw8(EXT_CAP_CTL2, 0xc0 | EXT_CAP_CTL2_ODDFRAMEIRQ, dp);
+
+ /*
+ * Configure capture mode to match the
+ * external video processor format
+ */
+ cyberpro_grphw8(EXT_CAP_MODE1, dp->cap_mode1, dp);
+ cyberpro_grphw8(EXT_CAP_MODE2, dp->cap_mode2, dp);
+
+ /* setup overlay */
+ cyberpro_grphw16(EXT_FIFO_CTL, 0x1010, dp);
+// cyberpro_grphw16(EXT_FIFO_CTL, 0x1b0f, dp);
+
+ /*
+ * Always reset the capture parameters on each open.
+ */
+ dp->capt.x = 0;
+ dp->capt.y = 0;
+ dp->capt.width = dp->cap.maxwidth;
+ dp->capt.height = dp->cap.maxheight;
+ dp->capt.decimation = 0;
+ dp->capt.flags = 0;
+
+ cyberpro_capture_set_win(dp);
+
+ /*
+ * Enable VAFC
+ */
+ old = cyberpro_grphr8(EXT_LATCH1, dp);
+ cyberpro_grphw8(EXT_LATCH1, old | EXT_LATCH1_VAFC_EN, dp);
+
+ /*
+ * Enable capture (we hope that VSYNC=1)
+ */
+ dp->vfac1 |= VFAC_CTL1_CAPTURE;
+ cyberpro_grphw8(VFAC_CTL1, dp->vfac1, dp);
+
+ /*
+ * The overlay source format is always the
+ * same as the capture stream format.
+ */
+ dp->ovl->src.width = dp->capt.width;
+ dp->ovl->src.height = dp->capt.height;
+ dp->ovl->src.format = dp->stream_fmt;
+
+ /*
+ * Initialise the overlay windows
+ */
+ dp->ext.init(dp, &dp->ext);
+ dp->v2.init(dp, &dp->v2);
+ dp->x2.init(dp, &dp->x2);
+}
+
+static void cyberpro_deinit(struct cyberpro_vidinfo *dp)
+{
+ unsigned char old;
+
+ /*
+ * Stop any bus-master activity
+ */
+ cyberpro_writew(0, BM_CONTROL, dp);
+
+ /*
+ * Shut down overlay
+ */
+ if (dp->ovl_active)
+ dp->ovl->ctl(dp, dp->ovl, 0);
+ dp->ovl_active = 0;
+
+ /*
+ * Shut down capture
+ */
+ if (dp->cap_active)
+ cyberpro_capture(dp, 0);
+ dp->cap_active = 0;
+
+ /*
+ * Disable all capture
+ */
+ cyberpro_grphw8(VFAC_CTL1, 0, dp);
+
+ /*
+ * Disable VAFC
+ */
+ old = cyberpro_grphr8(EXT_LATCH1, dp);
+ cyberpro_grphw8(EXT_LATCH1, old & ~EXT_LATCH1_VAFC_EN, dp);
+
+ /*
+ * Disable interrupt (this allows it to float)
+ */
+ dp->vfac3 &= ~VFAC_CTL3_CAP_IRQ;
+ cyberpro_grphw8(VFAC_CTL3, dp->vfac3, dp);
+
+ /*
+ * Switch off bus-master mode
+ */
+ cyberpro_grphw8(PCI_BM_CTL, 0, dp);
+
+ /*
+ * Disable access to bus-master registers
+ */
+ dp->info.disable_extregs(dp->info.info);
+}
+
+static int cyberpro_grabber_open(struct video_device *dev, int flags)
+{
+ struct cyberpro_vidinfo *dp = dev->priv;
+ int ret, one = 1;
+
+ MOD_INC_USE_COUNT;
+
+ ret = -EBUSY;
+ if (flags || dp->users)
+ goto out;
+
+ dp->users += 1;
+
+ if (dp->users == 1) {
+ ret = request_irq(dp->irq, cyberpro_interrupt, SA_SHIRQ,
+ dp->info.dev_name, dp);
+
+ if (ret) {
+ dp->users -= 1;
+ goto out;
+ }
+
+ /*
+ * Initialise the VGA chip
+ */
+ cyberpro_hw_init(dp);
+
+ /*
+ * Enable the IRQ. This allows the IRQ to work as expected
+ * even if the IRQ line is missing the pull-up resistor.
+ */
+ enable_irq(dp->irq);
+
+ i2c_control_device(dp->bus, I2C_DRIVERID_VIDEODECODER,
+ DECODER_ENABLE_OUTPUT, &one);
+ }
+
+ ret = 0;
+out:
+ if (ret)
+ MOD_DEC_USE_COUNT;
+ return ret;
+}
+
+static void cyberpro_grabber_close(struct video_device *dev)
+{
+ struct cyberpro_vidinfo *dp = dev->priv;
+
+ if (dp->users == 1) {
+ int zero = 0;
+
+ /*
+ * Disable the IRQ. This prevents problems with missing
+ * pull-up resistors on the PCI interrupt line.
+ */
+ disable_irq(dp->irq);
+
+ cyberpro_frames_free(dp);
+
+ /*
+ * Turn off the SAA7111 decoder
+ */
+ i2c_control_device(dp->bus, I2C_DRIVERID_VIDEODECODER,
+ DECODER_ENABLE_OUTPUT, &zero);
+
+ /*
+ * Disable grabber
+ */
+ cyberpro_deinit(dp);
+
+ free_irq(dp->irq, dp);
+ }
+
+ dp->users -= 1;
+
+ MOD_DEC_USE_COUNT;
+}
+
+/*
+ * Our general plan here is:
+ * 1. Set the CyberPro to perform a BM-DMA of one frame to this memory
+ * 2. Copy the frame to the userspace
+ *
+ * However, BM-DMA seems to be unreliable at the moment, especially on
+ * rev. 4 NetWinders.
+ */
+static long
+cyberpro_grabber_read(struct video_device *dev, char *buf,
+ unsigned long count, int noblock)
+{
+ struct cyberpro_vidinfo *dp = dev->priv;
+ int ret = -EINVAL;
+
+#ifdef USE_MMIO
+ unsigned long maxbufsz = dp->capt.width * dp->capt.height * 2;
+ char *disp = dp->info.fb + (dp->cap_mem_offset << 2);
+
+ /*
+ * If the buffer is mmap()'d, we shouldn't be using read()
+ */
+ if (dp->mmaped)
+ return -EINVAL;
+
+ if (count > maxbufsz)
+ count = maxbufsz;
+
+ if (dp->cap_active)
+ cyberpro_capture(dp, 0);
+ else
+ cyberpro_capture_one(dp);
+
+ ret = (int)count;
+ if (copy_to_user(buf, disp, count))
+ ret = -EFAULT;
+
+ /*
+ * unfreeze capture
+ */
+ if (dp->cap_active)
+ cyberpro_capture(dp, 1);
+#endif
+
+ return ret;
+}
+
+/*
+ * We don't support writing to the grabber
+ * (In theory, we could allow writing to a separate region of VGA memory,
+ * and display this using the second overlay window. This would allow us
+ * to do video conferencing for example).
+ */
+static long
+cyberpro_grabber_write(struct video_device *dev, const char *buf,
+ unsigned long count, int noblock)
+{
+ return -EINVAL;
+}
+
+static int
+cyberpro_grabber_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
+{
+ struct cyberpro_vidinfo *dp = dev->priv;
+
+ switch (cmd) {
+ case VIDIOCGCAP:
+ return copy_to_user(arg, &dp->cap, sizeof(dp->cap))
+ ? -EFAULT : 0;
+
+ case VIDIOCGCHAN:
+ {
+ struct video_channel chan;
+
+ chan.channel = 0;
+ strcpy(chan.name, "Composite");
+ chan.tuners = 0;
+ chan.flags = 0;
+ chan.type = VIDEO_TYPE_CAMERA;
+ chan.norm = dp->norm;
+
+ return copy_to_user(arg, &chan, sizeof(chan)) ? -EFAULT : 0;
+ }
+
+ case VIDIOCGPICT:
+ return copy_to_user(arg, &dp->pic, sizeof(dp->pic))
+ ? -EINVAL : 0;
+
+ case VIDIOCGWIN:
+ {
+ struct video_window win;
+
+ win.x = dp->ovl->dst.x;
+ win.y = dp->ovl->dst.y;
+ win.width = dp->ovl->dst.width;
+ win.height = dp->ovl->dst.height;
+ win.chromakey = dp->ovl->dst.chromakey;
+ win.flags = VIDEO_WINDOW_CHROMAKEY |
+ (dp->interlace ? VIDEO_WINDOW_INTERLACE : 0);
+ win.clips = NULL;
+ win.clipcount = 0;
+
+ return copy_to_user(arg, &win, sizeof(win))
+ ? -EINVAL : 0;
+ }
+
+ case VIDIOCGFBUF:
+ return copy_to_user(arg, &dp->buf, sizeof(dp->buf))
+ ? -EINVAL : 0;
+
+ case VIDIOCGUNIT:
+ {
+ struct video_unit unit;
+
+ unit.video = dev->minor;
+ unit.vbi = VIDEO_NO_UNIT;
+ unit.radio = VIDEO_NO_UNIT;
+ unit.audio = VIDEO_NO_UNIT;
+ unit.teletext = VIDEO_NO_UNIT;
+
+ return copy_to_user(arg, &unit, sizeof(unit))
+ ? -EINVAL : 0;
+ }
+
+ case VIDIOCGCAPTURE:
+ return copy_to_user(arg, &dp->capt, sizeof(dp->capt))
+ ? -EFAULT : 0;
+
+ case VIDIOCSCHAN:
+ {
+ struct video_decoder_capability vdc;
+ struct video_channel v;
+ int ok;
+
+ if (copy_from_user(&v, arg, sizeof(v)))
+ return -EFAULT;
+
+ if (v.channel != 0)
+ return -EINVAL;
+
+ i2c_control_device(dp->bus, I2C_DRIVERID_VIDEODECODER,
+ DECODER_GET_CAPABILITIES, &vdc);
+
+ switch (v.norm) {
+ case VIDEO_MODE_PAL:
+ ok = vdc.flags & VIDEO_DECODER_PAL;
+ break;
+ case VIDEO_MODE_NTSC:
+ ok = vdc.flags & VIDEO_DECODER_NTSC;
+ break;
+ case VIDEO_MODE_AUTO:
+ ok = vdc.flags & VIDEO_DECODER_AUTO;
+ break;
+ default:
+ ok = 0;
+ }
+ if (!ok)
+ return -EINVAL;
+
+ dp->norm = v.norm;
+
+ i2c_control_device(dp->bus, I2C_DRIVERID_VIDEODECODER,
+ DECODER_SET_NORM, &v.norm);
+
+ return 0;
+ }
+
+ case VIDIOCSPICT:
+ {
+ struct video_picture p;
+
+ if (copy_from_user(&p, arg, sizeof(p)))
+ return -EFAULT;
+
+ if (p.palette != dp->stream_fmt ||
+ p.depth != 8)
+ return -EINVAL;
+
+ dp->pic = p;
+
+ /* p.depth sets the capture depth */
+ /* p.palette sets the capture palette */
+
+ i2c_control_device(dp->bus, I2C_DRIVERID_VIDEODECODER,
+ DECODER_SET_PICTURE, &p);
+
+ return 0;
+ }
+
+ case VIDIOCSWIN: /* set the size & position of the overlay window */
+ {
+ struct video_window w;
+ int diff;
+
+ if (!dp->buf_set)
+ return -EINVAL;
+
+ if (copy_from_user(&w, arg, sizeof(w)))
+ return -EFAULT;
+
+ if (w.clipcount)
+ return -EINVAL;
+
+ /*
+ * Bound the overlay window by the size of the screen
+ */
+ if (w.x < 0)
+ w.x = 0;
+ if (w.y < 0)
+ w.y = 0;
+
+ if (w.x > dp->buf.width)
+ w.x = dp->buf.width;
+ if (w.y > dp->buf.height)
+ w.y = dp->buf.height;
+
+ if (w.width < dp->capt.width)
+ w.width = dp->capt.width;
+ if (w.height < dp->capt.height)
+ w.height = dp->capt.height;
+
+ if (w.x + w.width > dp->buf.width)
+ w.width = dp->buf.width - w.x;
+ if (w.y + w.height > dp->buf.height)
+ w.height = dp->buf.height - w.y;
+
+ /*
+ * We've tried to make the values fit, but
+ * they just won't.
+ */
+ if (w.width < dp->capt.width || w.height < dp->capt.height)
+ return -EINVAL;
+
+ diff = dp->ovl->dst.x != w.x ||
+ dp->ovl->dst.y != w.y ||
+ dp->ovl->dst.width != w.width ||
+ dp->ovl->dst.height != w.height ||
+ dp->ovl->dst.chromakey != w.chromakey ||
+ dp->ovl->dst.flags != w.flags;
+
+ if (!dp->win_set || diff) {
+ dp->ovl->dst.x = w.x;
+ dp->ovl->dst.y = w.y;
+ dp->ovl->dst.width = w.width;
+ dp->ovl->dst.height = w.height;
+ dp->ovl->dst.chromakey = w.chromakey;
+ dp->ovl->dst.flags = w.flags;
+
+ if (dp->ovl_active)
+ dp->ovl->ctl(dp, dp->ovl, 0);
+
+ dp->ovl->set_win(dp, dp->ovl);
+
+ if (dp->ovl_active)
+ dp->ovl->ctl(dp, dp->ovl, 1);
+
+ diff = w.flags & VIDEO_WINDOW_INTERLACE ? 1 : 0;
+ if (!dp->win_set || dp->interlace != diff) {
+ dp->interlace = diff;
+ cyberpro_set_interlace(dp);
+ }
+ }
+
+ dp->win_set = 1;
+
+ return 0;
+ }
+
+ case VIDIOCSFBUF: /* set frame buffer info */
+ {
+ struct video_buffer b;
+ int ret;
+
+ if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO))
+ return -EPERM;
+
+ if (dp->cap_active)
+ return -EINVAL;
+
+ if (copy_from_user(&b, arg, sizeof(b)))
+ return -EFAULT;
+
+ ret = cyberpro_set_buffer(dp, &b);
+ if (ret == 0) {
+ dp->buf_set = 1;
+ dp->win_set = 0;
+ }
+
+ return ret;
+ }
+
+ case VIDIOCCAPTURE:
+ {
+ int on;
+
+ if (get_user(on, (int *)arg))
+ return -EFAULT;
+
+ if (( on && dp->ovl_active) ||
+ (!on && !dp->ovl_active))
+ return 0;
+
+ if (on && (!dp->buf_set || !dp->win_set))
+ return -EINVAL;
+
+ cyberpro_capture(dp, on);
+ dp->cap_active = on;
+ dp->ovl->ctl(dp, dp->ovl, on);
+ dp->ovl_active = on;
+
+ return 0;
+ }
+
+#ifdef USE_MMAP
+ case VIDIOCSYNC:
+ {
+ DECLARE_WAITQUEUE(wait, current);
+ int buf;
+
+ /*
+ * The buffer must have been mmaped
+ * for this call to work.
+ */
+ if (!dp->mmaped)
+ return -EINVAL;
+
+ if (get_user(buf, (int *)arg))
+ return -EFAULT;
+
+ if (buf < 0 || buf >= NR_FRAMES)
+ return -EINVAL;
+
+ switch (dp->frame[buf].status) {
+ case FRAME_FREE:
+ return -EINVAL;
+
+ case FRAME_WAITING:
+ case FRAME_GRABBING:
+ add_wait_queue(&dp->frame_wait, &wait);
+ while (1) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ if (signal_pending(current))
+ break;
+ if (dp->frame[buf].status == FRAME_DONE)
+ break;
+ schedule();
+ }
+ set_current_state(TASK_RUNNING);
+ remove_wait_queue(&dp->frame_wait, &wait);
+ if (signal_pending(current))
+ return -EINTR;
+ /*FALLTHROUGH*/
+ case FRAME_DONE:
+ dp->frame[buf].status = FRAME_FREE;
+ break;
+ }
+ return 0;
+ }
+
+ case VIDIOCMCAPTURE:
+ {
+ struct video_mmap vmap;
+
+ /*
+ * The buffer must have been mmaped
+ * for this call to work.
+ */
+ if (!dp->mmaped)
+ return -EINVAL;
+
+ if (copy_from_user(&vmap, arg, sizeof(vmap)))
+ return -EFAULT;
+
+ /*
+ * We can only capture in our source format/size.
+ */
+ if (vmap.frame >= NR_FRAMES ||
+ vmap.format != dp->stream_fmt ||
+ vmap.width != dp->capt.width ||
+ vmap.height != dp->capt.height)
+ return -EINVAL;
+
+ if (dp->frame[vmap.frame].status == FRAME_WAITING ||
+ dp->frame[vmap.frame].status == FRAME_GRABBING)
+ return -EBUSY;
+
+ dp->frame[vmap.frame].status = FRAME_WAITING;
+ return 0;
+ }
+
+ case VIDIOCGMBUF:
+ {
+ struct video_mbuf vmb;
+ unsigned int i;
+
+ vmb.frames = NR_FRAMES;
+ vmb.size = dp->frame_size * NR_FRAMES;
+
+ for (i = 0; i < NR_FRAMES; i++)
+ vmb.offsets[i] = dp->frame[i].offset;
+
+ return copy_to_user(arg, &vmb, sizeof(vmb)) ? -EFAULT : 0;
+ }
+#endif
+
+ case VIDIOCSCAPTURE:
+ {
+ struct video_capture capt;
+
+#ifndef ALLOW_SCAPTURE_WHILE_CAP
+ if (dp->cap_active)
+ return -EINVAL;
+#endif
+
+ if (copy_from_user(&capt, arg, sizeof(capt)))
+ return -EFAULT;
+
+ if (capt.x < 0 || capt.width < 0 ||
+ capt.y < 0 || capt.height < 0 ||
+ capt.x + capt.width > dp->cap.maxwidth ||
+ capt.y + capt.height > dp->cap.maxheight)
+ return -EINVAL;
+
+ /*
+ * The capture width must be a multiple of 4
+ */
+ if (dp->capt.width & 3)
+ return -EINVAL;
+
+ dp->capt.x = capt.x;
+ dp->capt.y = capt.y;
+ dp->capt.width = capt.width;
+ dp->capt.height = capt.height;
+#ifdef ALLOW_SCAPTURE_WHILE_CAP
+ if (dp->ovl_active)
+ dp->ovl->ctl(dp, dp->ovl, 0);
+ if (dp->cap_active)
+ cyberpro_capture(dp, 0);
+#endif
+ cyberpro_capture_set_win(dp);
+
+ /*
+ * Update the overlay window information
+ */
+ dp->ovl->src.width = capt.width;
+ dp->ovl->src.height = capt.height;
+
+ dp->ovl->set_src(dp, dp->ovl);
+ if (dp->win_set)
+ dp->ovl->set_win(dp, dp->ovl);
+
+#ifdef ALLOW_SCAPTURE_WHILE_CAP
+ if (dp->cap_active)
+ cyberpro_capture(dp, 1);
+ if (dp->ovl_active)
+ dp->ovl->ctl(dp, dp->ovl, 1);
+#endif
+ return 0;
+ }
+
+ case VIDIOCGTUNER: /* no tuner */
+ case VIDIOCSTUNER:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+}
+
+#ifdef USE_MMAP
+static int
+cyberpro_grabber_mmap(struct video_device *dev, const char *addr, unsigned long size)
+{
+ struct cyberpro_vidinfo *dp = dev->priv;
+ unsigned long vaddr = (unsigned long)addr;
+ pgprot_t prot;
+ int frame_idx, ret = -EINVAL;
+
+#if defined(__arm__)
+ prot = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_USER | L_PTE_WRITE | L_PTE_DIRTY);
+#elif defined(__i386__)
+ prot = __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED);
+ if (boot_cpu_data.x86 > 3)
+ pgprot_val(prot) |= _PAGE_PCD;
+#else
+#error "Unsupported architecture"
+#endif
+
+ /*
+ * The mmap() request must have the correct size.
+ */
+ if (size != NR_FRAMES * dp->frame_size)
+ goto out;
+
+ /*
+ * If it's already mapped, don't re-do
+ */
+ if (dp->mmaped)
+ goto out;
+ dp->mmaped = 1;
+
+ /*
+ * Map in each frame
+ */
+ for (frame_idx = 0; frame_idx < NR_FRAMES; frame_idx++) {
+ struct framebuf *frame;
+ int pgidx;
+
+ frame = dp->frame + frame_idx;
+
+ ret = cyberpro_alloc_frame_buffer(dp, frame);
+
+ /*
+ * If an error occurs, we can be lazy and leave what we've
+ * been able to do. Our release function will free any
+ * allocated buffers, and do_mmap_pgoff() will zap any
+ * inserted mappings.
+ */
+ if (ret)
+ goto out2;
+
+ /*
+ * Map in each page on a page by page basis. This is just
+ * a little on the inefficient side, but it's only run once.
+ */
+ for (pgidx = 0; pgidx < NR_PAGES; pgidx++) {
+ unsigned long virt;
+
+ virt = page_address(frame->pages[pgidx]);
+
+ ret = remap_page_range(vaddr, virt_to_phys((void *)virt),
+ PAGE_SIZE, prot);
+
+ if (ret)
+ goto out2;
+
+ vaddr += PAGE_SIZE;
+ }
+ }
+
+ out2:
+ if (ret)
+ dp->mmaped = 0;
+ out:
+ return ret;
+}
+#endif
+
+static int __init cyberpro_grabber_init_done(struct video_device *dev)
+{
+ struct cyberpro_vidinfo *dp;
+ struct cyberpro_info *info = dev->priv;
+ int ret;
+
+ dp = kmalloc(sizeof(*dp), GFP_KERNEL);
+ if (!dp)
+ return -ENOMEM;
+
+ memset(dp, 0, sizeof(*dp));
+
+ dev->priv = dp;
+ dp->info = *info;
+ dp->dev = dev;
+ dp->bus = &cyberpro_i2c_bus;
+ dp->regs = info->regs;
+ dp->irq = info->dev->irq;
+
+ strcpy(dp->cap.name, dev->name);
+ dp->cap.type = dev->type;
+ dp->cap.channels = 1;
+ dp->cap.audios = 0;
+ dp->cap.minwidth = 32;
+ dp->cap.maxwidth = 716;
+ dp->cap.minheight = 32;
+ dp->cap.maxheight = 576;
+
+ dp->pic.brightness = 32768;
+ dp->pic.hue = 32768;
+ dp->pic.colour = 32768;
+ dp->pic.contrast = 32768;
+ dp->pic.whiteness = 0;
+ dp->pic.depth = 8;
+ dp->pic.palette = VIDEO_PALETTE_YUV422;
+
+ /* dp->buf is setup by the user */
+ /* dp->cap_mem_offset setup by dp->buf */
+
+ dp->norm = VIDEO_MODE_AUTO;
+
+ /*
+ * The extended overlay window
+ */
+ dp->ext.init = cyberpro_ext_init;
+ dp->ext.set_src = cyberpro_ext_set_src;
+ dp->ext.set_win = cyberpro_ext_set_win;
+ dp->ext.ctl = cyberpro_ext_ctl;
+
+ /*
+ * The V2 overlay window
+ */
+ dp->v2.init = cyberpro_v2_init;
+ dp->v2.set_src = cyberpro_v2_set_src;
+ dp->v2.set_win = cyberpro_v2_set_win;
+ dp->v2.ctl = cyberpro_v2_ctl;
+
+ /*
+ * The X2 overlay window
+ */
+ dp->x2.init = cyberpro_x2_init;
+ dp->x2.set_src = cyberpro_x2_set_src;
+ dp->x2.set_win = cyberpro_x2_set_win;
+ dp->x2.ctl = cyberpro_x2_ctl;
+
+ /*
+ * Set the overlay window which we shall be using
+ */
+ dp->ovl = &dp->ext;
+
+ dp->cap_mode1 = EXT_CAP_MODE1_ALTFIFO;
+
+ /*
+ * Initialise hardware specific values.
+ * - CCIR656 8bit mode (YUV422 data)
+ * - Ignore Hgood signal
+ * - Invert Odd/Even field signal
+ */
+ dp->cap_mode1 |= EXT_CAP_MODE1_CCIR656 | EXT_CAP_MODE1_8BIT;
+ dp->cap_mode2 = EXT_CAP_MODE2_FIXSONY | EXT_CAP_MODE2_DATEND |
+ EXT_CAP_MODE2_CCIRINVOE;
+ dp->stream_fmt = VIDEO_PALETTE_YUV422;
+
+
+ init_waitqueue_head(&dp->vbl_wait);
+ cyberpro_frames_init(dp);
+
+ /*
+ * wake up the decoder
+ */
+ decoder_sleep(0);
+
+ dp->bus->data = dp;
+ strncpy(dp->bus->name, dev->name, sizeof(dp->bus->name));
+
+ pci_set_master(dp->info.dev);
+
+ ret = i2c_register_bus(dp->bus);
+
+ /*
+ * If we successfully registered the bus, but didn't initialise
+ * the decoder (because its driver is not present), request
+ * that it is loaded.
+ */
+ if (ret == 0 && !dp->decoder)
+ request_module("saa7111");
+
+ /*
+ * If that didn't work, then we're out of luck.
+ */
+ if (ret == 0 && !dp->decoder) {
+ i2c_unregister_bus(dp->bus);
+ ret = -ENXIO;
+ }
+
+ if (ret) {
+ kfree(dp);
+
+ /*
+ * put the decoder back to sleep
+ */
+ decoder_sleep(1);
+ }
+
+ return ret;
+}
+
+static struct video_device cyberpro_grabber = {
+ name: "",
+ type: VID_TYPE_CAPTURE | VID_TYPE_OVERLAY |
+ VID_TYPE_CHROMAKEY | VID_TYPE_SCALES |
+ VID_TYPE_SUBCAPTURE,
+ hardware: 0,
+ open: cyberpro_grabber_open,
+ close: cyberpro_grabber_close,
+ read: cyberpro_grabber_read,
+ write: cyberpro_grabber_write,
+ ioctl: cyberpro_grabber_ioctl,
+#ifdef USE_MMAP
+ mmap: cyberpro_grabber_mmap,
+#endif
+ initialize: cyberpro_grabber_init_done,
+};
+
+int init_cyber2000fb_viddev(void)
+{
+ struct cyberpro_info info;
+
+ if (!cyber2000fb_attach(&info, 0))
+ return -ENXIO;
+
+ strncpy(cyberpro_grabber.name, info.dev_name, sizeof(cyberpro_grabber.name));
+
+ cyberpro_grabber.priv = &info;
+
+ return video_register_device(&cyberpro_grabber, VFL_TYPE_GRABBER, -1);
+}
+
+/*
+ * This can be cleaned up when the SAA7111 code is fixed.
+ */
+#ifdef MODULE
+static int __init cyberpro_init(void)
+{
+ disable_irq(35);
+ return init_cyber2000fb_viddev();
+}
+
+static void __exit cyberpro_exit(void)
+{
+ video_unregister_device(&cyberpro_grabber);
+ kfree(cyberpro_grabber.priv);
+ i2c_unregister_bus(&cyberpro_i2c_bus);
+
+ /*
+ * put the decoder back to sleep
+ */
+ decoder_sleep(1);
+
+ cyber2000fb_detach(0);
+}
+
+module_init(cyberpro_init);
+module_exit(cyberpro_exit);
+#endif
diff -urN linux-2.4.26/drivers/media/video/i2c-old.c linux-2.4.26-vrs1/drivers/media/video/i2c-old.c
--- linux-2.4.26/drivers/media/video/i2c-old.c 2004-02-27 20:03:26.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/media/video/i2c-old.c 2004-02-27 23:41:21.000000000 +0000
@@ -36,11 +36,20 @@
static struct i2c_driver *drivers[I2C_DRIVER_MAX];
static int bus_count = 0, driver_count = 0;
+extern int saa7111_init(void);
+extern int saa7185_init(void);
+extern int bt819_init(void);
+extern int bt856_init(void);
+
int i2c_init(void)
{
printk(KERN_INFO "i2c: initialized%s\n",
scan ? " (i2c bus scan enabled)" : "");
+#if defined(CONFIG_VIDEO_CYBERPRO)
+ saa7111_init();
+#endif
+
return 0;
}
@@ -52,10 +61,10 @@
int i,j,ack=1;
unsigned char addr;
LOCK_FLAGS;
-
+
/* probe for device */
LOCK_I2C_BUS(bus);
- for (addr = driver->addr_l; addr <= driver->addr_h; addr += 2)
+ for (addr = driver->addr_l; addr <= driver->addr_h; addr += 2)
{
i2c_start(bus);
ack = i2c_sendbyte(bus,addr,0);
@@ -87,8 +96,8 @@
device->addr = addr;
/* Attach */
-
- if (driver->attach(device)!=0)
+
+ if (driver->attach(device)!=0)
{
kfree(device);
return;
@@ -114,7 +123,7 @@
for (i = 0; i < I2C_DEVICE_MAX; i++)
if (device == device->driver->devices[i])
break;
- if (I2C_DEVICE_MAX == i)
+ if (I2C_DEVICE_MAX == i)
{
printk(KERN_WARNING "i2c: detach_device #1: device not found: %s\n",
device->name);
@@ -126,7 +135,7 @@
for (i = 0; i < I2C_DEVICE_MAX; i++)
if (device == device->bus->devices[i])
break;
- if (I2C_DEVICE_MAX == i)
+ if (I2C_DEVICE_MAX == i)
{
printk(KERN_WARNING "i2c: detach_device #2: device not found: %s\n",
device->name);
@@ -158,19 +167,19 @@
busses[i] = bus;
bus_count++;
REGPRINT(printk("i2c: bus registered: %s\n",bus->name));
-
+
MOD_INC_USE_COUNT;
- if (scan)
+ if (scan)
{
/* scan whole i2c bus */
LOCK_I2C_BUS(bus);
- for (i = 0; i < 256; i+=2)
+ for (i = 0; i < 256; i+=2)
{
i2c_start(bus);
ack = i2c_sendbyte(bus,i,0);
i2c_stop(bus);
- if (!ack)
+ if (!ack)
{
printk(KERN_INFO "i2c: scanning bus %s: found device at addr=0x%02x\n",
bus->name,i);
@@ -198,20 +207,20 @@
for (i = 0; i < I2C_BUS_MAX; i++)
if (bus == busses[i])
break;
- if (I2C_BUS_MAX == i)
+ if (I2C_BUS_MAX == i)
{
printk(KERN_WARNING "i2c: unregister_bus #1: bus not found: %s\n",
bus->name);
return -ENODEV;
}
-
+
MOD_DEC_USE_COUNT;
-
+
busses[i] = NULL;
bus_count--;
REGPRINT(printk("i2c: bus unregistered: %s\n",bus->name));
- return 0;
+ return 0;
}
/* ----------------------------------------------------------------------- */
@@ -231,9 +240,9 @@
drivers[i] = driver;
driver_count++;
-
+
MOD_INC_USE_COUNT;
-
+
REGPRINT(printk("i2c: driver registered: %s\n",driver->name));
/* Probe available busses */
@@ -256,7 +265,7 @@
for (i = 0; i < I2C_DRIVER_MAX; i++)
if (driver == drivers[i])
break;
- if (I2C_DRIVER_MAX == i)
+ if (I2C_DRIVER_MAX == i)
{
printk(KERN_WARNING "i2c: unregister_driver: driver not found: %s\n",
driver->name);
@@ -264,7 +273,7 @@
}
MOD_DEC_USE_COUNT;
-
+
drivers[i] = NULL;
driver_count--;
REGPRINT(printk("i2c: driver unregistered: %s\n",driver->name));
@@ -328,7 +337,7 @@
int i2c_ack(struct i2c_bus *bus)
{
int ack;
-
+
I2C_SET(bus,0,1);
I2C_SET(bus,1,1);
ack = I2C_GET(bus);
@@ -339,7 +348,7 @@
int i2c_sendbyte(struct i2c_bus *bus,unsigned char data,int wait_for_ack)
{
int i, ack;
-
+
I2C_SET(bus,0,0);
for (i=7; i>=0; i--)
(data&(1<<i)) ? i2c_one(bus) : i2c_zero(bus);
@@ -354,9 +363,9 @@
{
int i;
unsigned char data=0;
-
+
I2C_SET(bus,0,1);
- for (i=7; i>=0; i--)
+ for (i=7; i>=0; i--)
{
I2C_SET(bus,1,1);
if (I2C_GET(bus))
@@ -373,7 +382,7 @@
int i2c_read(struct i2c_bus *bus, unsigned char addr)
{
int ret;
-
+
if (bus->i2c_read)
return bus->i2c_read(bus, addr);
diff -urN linux-2.4.26/drivers/media/video/saa7111.c linux-2.4.26-vrs1/drivers/media/video/saa7111.c
--- linux-2.4.26/drivers/media/video/saa7111.c 2001-09-30 20:26:06.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/media/video/saa7111.c 2004-01-14 21:32:25.000000000 +0000
@@ -20,9 +20,9 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
-#include <linux/module.h>
+#include <linux/config.h>
#include <linux/init.h>
+#include <linux/module.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/fs.h>
@@ -149,7 +149,11 @@
0x0d, 0x00, /* 0d - HUE=0 */
0x0e, 0x01, /* 0e - CDTO=0, CSTD=0, DCCF=0, FCTC=0, CHBW=1 */
0x0f, 0x00, /* 0f - reserved */
+#ifndef CONFIG_ARCH_NETWINDER
0x10, 0x48, /* 10 - OFTS=1, HDEL=0, VRLN=1, YDEL=0 */
+#else
+ 0x10, 0xc8, /* 10 - OFTS=YUV-CCIR656, HDEL=0, VLRN=1, YDEL=0 */
+#endif
0x11, 0x1c, /* 11 - GPSW=0, CM99=0, FECO=0, COMPO=1, OEYC=1, OEHV=1, VIPB=0, COLO=0 */
0x12, 0x00, /* 12 - output control 2 */
0x13, 0x00, /* 13 - output control 3 */
diff -urN linux-2.4.26/drivers/message/i2o/i2o_core.c linux-2.4.26-vrs1/drivers/message/i2o/i2o_core.c
--- linux-2.4.26/drivers/message/i2o/i2o_core.c 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/message/i2o/i2o_core.c 2004-01-14 21:32:25.000000000 +0000
@@ -1665,14 +1665,14 @@
}
memset(status, 0, 4);
- msg[0]=EIGHT_WORD_MSG_SIZE|SGL_OFFSET_0;
- msg[1]=I2O_CMD_ADAPTER_RESET<<24|HOST_TID<<12|ADAPTER_TID;
- msg[2]=core_context;
- msg[3]=0;
- msg[4]=0;
- msg[5]=0;
- msg[6]=virt_to_bus(status);
- msg[7]=0; /* 64bit host FIXME */
+ writel(EIGHT_WORD_MSG_SIZE|SGL_OFFSET_0, msg + 0);
+ writel(I2O_CMD_ADAPTER_RESET<<24|HOST_TID<<12|ADAPTER_TID, msg + 1);
+ writel(core_context, msg + 2);
+ writel(0, msg + 3);
+ writel(0, msg + 4);
+ writel(0, msg + 5);
+ writel(virt_to_bus(status), msg + 6);
+ writel(0, msg + 7); /* 64bit host FIXME */
i2o_post_message(c,m);
@@ -1781,15 +1781,15 @@
return -ETIMEDOUT;
msg=(u32 *)(c->mem_offset+m);
- msg[0]=NINE_WORD_MSG_SIZE|SGL_OFFSET_0;
- msg[1]=I2O_CMD_STATUS_GET<<24|HOST_TID<<12|ADAPTER_TID;
- msg[2]=core_context;
- msg[3]=0;
- msg[4]=0;
- msg[5]=0;
- msg[6]=virt_to_bus(c->status_block);
- msg[7]=0; /* 64bit host FIXME */
- msg[8]=sizeof(i2o_status_block); /* always 88 bytes */
+ writel(NINE_WORD_MSG_SIZE|SGL_OFFSET_0, msg + 0);
+ writel(I2O_CMD_STATUS_GET<<24|HOST_TID<<12|ADAPTER_TID, msg + 1);
+ writel(core_context, msg + 2);
+ writel(0, msg + 3);
+ writel(0, msg + 4);
+ writel(0, msg + 5);
+ writel(virt_to_bus(c->status_block), msg + 6);
+ writel(0, msg + 7); /* 64bit host FIXME */
+ writel(sizeof(i2o_status_block), msg + 8); /* always 88 bytes */
i2o_post_message(c,m);
@@ -2193,15 +2193,15 @@
}
memset(status, 0, 4);
- msg[0]= EIGHT_WORD_MSG_SIZE| TRL_OFFSET_6;
- msg[1]= I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID;
- msg[2]= core_context;
- msg[3]= 0x0106; /* Transaction context */
- msg[4]= 4096; /* Host page frame size */
+ writel(EIGHT_WORD_MSG_SIZE| TRL_OFFSET_6, msg + 0);
+ writel(I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID, msg + 1);
+ writel(core_context, msg + 2);
+ writel(0x0106, msg + 3); /* Transaction context */
+ writel(PAGE_SIZE, msg + 4); /* Host page frame size */
/* Frame size is in words. 256 bytes a frame for now */
- msg[5]= MSG_FRAME_SIZE<<16|0x80; /* Outbound msg frame size in words and Initcode */
- msg[6]= 0xD0000004; /* Simple SG LE, EOB */
- msg[7]= virt_to_bus(status);
+ writel(MSG_FRAME_SIZE<<16|0x80, msg + 5);/* Outbound msg frame size in words and Initcode */
+ writel(0xD0000004, msg + 6); /* Simple SG LE, EOB */
+ writel(virt_to_bus(status), msg + 7);
i2o_post_message(c,m);
diff -urN linux-2.4.26/drivers/message/i2o/i2o_pci.c linux-2.4.26-vrs1/drivers/message/i2o/i2o_pci.c
--- linux-2.4.26/drivers/message/i2o/i2o_pci.c 2002-11-28 23:53:13.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/message/i2o/i2o_pci.c 2004-01-14 21:32:25.000000000 +0000
@@ -390,4 +390,4 @@
MODULE_PARM_DESC(dpt, "Set this if you want to drive DPT cards normally handled by dpt_i2o");
module_init(i2o_pci_core_attach);
module_exit(i2o_pci_core_detach);
-
\ No newline at end of file
+
diff -urN linux-2.4.26/drivers/misc/Config.in linux-2.4.26-vrs1/drivers/misc/Config.in
--- linux-2.4.26/drivers/misc/Config.in 1999-12-25 23:04:56.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/misc/Config.in 2004-01-14 21:32:25.000000000 +0000
@@ -1,7 +1,17 @@
#
-# Misc strange devices
+# MCP drivers
#
mainmenu_option next_comment
-comment 'Misc devices'
+comment 'Multimedia Capabilities Port drivers'
+
+bool 'Multimedia drivers' CONFIG_MCP
+
+# Interface drivers
+dep_bool 'Support SA1100 MCP interface' CONFIG_MCP_SA1100 $CONFIG_MCP $CONFIG_ARCH_SA1100
+
+# Chip drivers
+dep_tristate 'Support for UCB1200 / UCB1300' CONFIG_MCP_UCB1200 $CONFIG_MCP
+dep_tristate ' Audio / Telephony interface support' CONFIG_MCP_UCB1200_AUDIO $CONFIG_MCP_UCB1200 $CONFIG_SOUND
+dep_tristate ' Touchscreen interface support' CONFIG_MCP_UCB1200_TS $CONFIG_MCP_UCB1200
endmenu
diff -urN linux-2.4.26/drivers/misc/Makefile linux-2.4.26-vrs1/drivers/misc/Makefile
--- linux-2.4.26/drivers/misc/Makefile 2000-12-29 22:07:22.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/misc/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -11,6 +11,14 @@
O_TARGET := misc.o
+export-objs := mcp-core.o mcp-sa1100.o ucb1x00-core.o
+
+obj-$(CONFIG_MCP) += mcp-core.o
+obj-$(CONFIG_MCP_SA1100) += mcp-sa1100.o
+obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o
+obj-$(CONFIG_MCP_UCB1200_AUDIO) += ucb1x00-audio.o
+obj-$(CONFIG_MCP_UCB1200_TS) += ucb1x00-ts.o
+
include $(TOPDIR)/Rules.make
fastdep:
diff -urN linux-2.4.26/drivers/misc/mcp-core.c linux-2.4.26-vrs1/drivers/misc/mcp-core.c
--- linux-2.4.26/drivers/misc/mcp-core.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/misc/mcp-core.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,155 @@
+/*
+ * linux/drivers/misc/mcp-core.c
+ *
+ * Copyright (C) 2001 Russell King
+ *
+ * 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.
+ *
+ * Generic MCP (Multimedia Communications Port) layer. All MCP locking
+ * is solely held within this file.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/smp.h>
+
+#include <asm/dma.h>
+#include <asm/system.h>
+
+#include "mcp.h"
+
+/**
+ * mcp_set_telecom_divisor - set the telecom divisor
+ * @mcp: MCP interface structure
+ * @div: SIB clock divisor
+ *
+ * Set the telecom divisor on the MCP interface. The resulting
+ * sample rate is SIBCLOCK/div.
+ */
+void mcp_set_telecom_divisor(struct mcp *mcp, unsigned int div)
+{
+ spin_lock_irq(&mcp->lock);
+ mcp->set_telecom_divisor(mcp, div);
+ spin_unlock_irq(&mcp->lock);
+}
+
+/**
+ * mcp_set_audio_divisor - set the audio divisor
+ * @mcp: MCP interface structure
+ * @div: SIB clock divisor
+ *
+ * Set the audio divisor on the MCP interface.
+ */
+void mcp_set_audio_divisor(struct mcp *mcp, unsigned int div)
+{
+ spin_lock_irq(&mcp->lock);
+ mcp->set_audio_divisor(mcp, div);
+ spin_unlock_irq(&mcp->lock);
+}
+
+/**
+ * mcp_reg_write - write a device register
+ * @mcp: MCP interface structure
+ * @reg: 4-bit register index
+ * @val: 16-bit data value
+ *
+ * Write a device register. The MCP interface must be enabled
+ * to prevent this function hanging.
+ */
+void mcp_reg_write(struct mcp *mcp, unsigned int reg, unsigned int val)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&mcp->lock, flags);
+ mcp->reg_write(mcp, reg, val);
+ spin_unlock_irqrestore(&mcp->lock, flags);
+}
+
+/**
+ * mcp_reg_read - read a device register
+ * @mcp: MCP interface structure
+ * @reg: 4-bit register index
+ *
+ * Read a device register and return its value. The MCP interface
+ * must be enabled to prevent this function hanging.
+ */
+unsigned int mcp_reg_read(struct mcp *mcp, unsigned int reg)
+{
+ unsigned long flags;
+ unsigned int val;
+
+ spin_lock_irqsave(&mcp->lock, flags);
+ val = mcp->reg_read(mcp, reg);
+ spin_unlock_irqrestore(&mcp->lock, flags);
+
+ return val;
+}
+
+/**
+ * mcp_enable - enable the MCP interface
+ * @mcp: MCP interface to enable
+ *
+ * Enable the MCP interface. Each call to mcp_enable will need
+ * a corresponding call to mcp_disable to disable the interface.
+ */
+void mcp_enable(struct mcp *mcp)
+{
+ spin_lock_irq(&mcp->lock);
+ if (mcp->use_count++ == 0)
+ mcp->enable(mcp);
+ spin_unlock_irq(&mcp->lock);
+}
+
+/**
+ * mcp_disable - disable the MCP interface
+ * @mcp: MCP interface to disable
+ *
+ * Disable the MCP interface. The MCP interface will only be
+ * disabled once the number of calls to mcp_enable matches the
+ * number of calls to mcp_disable.
+ */
+void mcp_disable(struct mcp *mcp)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&mcp->lock, flags);
+ if (--mcp->use_count == 0)
+ mcp->disable(mcp);
+ spin_unlock_irqrestore(&mcp->lock, flags);
+}
+
+
+/*
+ * This needs re-working
+ */
+static struct mcp *mcp_if;
+
+struct mcp *mcp_get(void)
+{
+ return mcp_if;
+}
+
+int mcp_register(struct mcp *mcp)
+{
+ if (mcp_if)
+ return -EBUSY;
+ if (mcp->owner)
+ __MOD_INC_USE_COUNT(mcp->owner);
+ mcp_if = mcp;
+ return 0;
+}
+
+EXPORT_SYMBOL(mcp_set_telecom_divisor);
+EXPORT_SYMBOL(mcp_set_audio_divisor);
+EXPORT_SYMBOL(mcp_reg_write);
+EXPORT_SYMBOL(mcp_reg_read);
+EXPORT_SYMBOL(mcp_enable);
+EXPORT_SYMBOL(mcp_disable);
+EXPORT_SYMBOL(mcp_get);
+EXPORT_SYMBOL(mcp_register);
+
+MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
+MODULE_DESCRIPTION("Core multimedia communications port driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/misc/mcp-sa1100.c linux-2.4.26-vrs1/drivers/misc/mcp-sa1100.c
--- linux-2.4.26/drivers/misc/mcp-sa1100.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/misc/mcp-sa1100.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,180 @@
+/*
+ * linux/drivers/misc/mcp-sa1100.c
+ *
+ * Copyright (C) 2001 Russell King
+ *
+ * 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.
+ *
+ * SA1100 MCP (Multimedia Communications Port) driver.
+ *
+ * MCP read/write timeouts from Jordi Colomer, rehacked by rmk.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/spinlock.h>
+
+#include <asm/dma.h>
+#include <asm/hardware.h>
+#include <asm/system.h>
+
+#include "mcp.h"
+
+static void
+mcp_sa1100_set_telecom_divisor(struct mcp *mcp, unsigned int divisor)
+{
+ unsigned int mccr0;
+
+ divisor /= 32;
+
+ mccr0 = Ser4MCCR0 & ~0x00007f00;
+ mccr0 |= divisor << 8;
+ Ser4MCCR0 = mccr0;
+}
+
+static void
+mcp_sa1100_set_audio_divisor(struct mcp *mcp, unsigned int divisor)
+{
+ unsigned int mccr0;
+
+ divisor /= 32;
+
+ mccr0 = Ser4MCCR0 & ~0x0000007f;
+ mccr0 |= divisor;
+ Ser4MCCR0 = mccr0;
+}
+
+/*
+ * Write data to the device. The bit should be set after 3 subframe
+ * times (each frame is 64 clocks). We wait a maximum of 6 subframes.
+ * We really should try doing something more productive while we
+ * wait.
+ */
+static void
+mcp_sa1100_write(struct mcp *mcp, unsigned int reg, unsigned int val)
+{
+ int ret = -ETIME;
+ int i;
+
+ Ser4MCDR2 = reg << 17 | MCDR2_Wr | (val & 0xffff);
+
+ for (i = 0; i < 2; i++) {
+ udelay(mcp->rw_timeout);
+ if (Ser4MCSR & MCSR_CWC) {
+ ret = 0;
+ break;
+ }
+ }
+
+ if (ret < 0)
+ printk(KERN_WARNING "mcp: write timed out\n");
+}
+
+/*
+ * Read data from the device. The bit should be set after 3 subframe
+ * times (each frame is 64 clocks). We wait a maximum of 6 subframes.
+ * We really should try doing something more productive while we
+ * wait.
+ */
+static unsigned int
+mcp_sa1100_read(struct mcp *mcp, unsigned int reg)
+{
+ int ret = -ETIME;
+ int i;
+
+ Ser4MCDR2 = reg << 17 | MCDR2_Rd;
+
+ for (i = 0; i < 2; i++) {
+ udelay(mcp->rw_timeout);
+ if (Ser4MCSR & MCSR_CRC) {
+ ret = Ser4MCDR2 & 0xffff;
+ break;
+ }
+ }
+
+ if (ret < 0)
+ printk(KERN_WARNING "mcp: read timed out\n");
+
+ return ret;
+}
+
+static void mcp_sa1100_enable(struct mcp *mcp)
+{
+ Ser4MCSR = -1;
+ Ser4MCCR0 |= MCCR0_MCE;
+}
+
+static void mcp_sa1100_disable(struct mcp *mcp)
+{
+ Ser4MCCR0 &= ~MCCR0_MCE;
+}
+
+struct mcp mcp_sa1100 = {
+ owner: THIS_MODULE,
+ lock: SPIN_LOCK_UNLOCKED,
+ sclk_rate: 11981000,
+ dma_audio_rd: DMA_Ser4MCP0Rd,
+ dma_audio_wr: DMA_Ser4MCP0Wr,
+ dma_telco_rd: DMA_Ser4MCP1Rd,
+ dma_telco_wr: DMA_Ser4MCP1Wr,
+ set_telecom_divisor: mcp_sa1100_set_telecom_divisor,
+ set_audio_divisor: mcp_sa1100_set_audio_divisor,
+ reg_write: mcp_sa1100_write,
+ reg_read: mcp_sa1100_read,
+ enable: mcp_sa1100_enable,
+ disable: mcp_sa1100_disable,
+};
+
+/*
+ * This needs re-working
+ */
+static int mcp_sa1100_init(void)
+{
+ struct mcp *mcp = &mcp_sa1100;
+ int ret = -ENODEV;
+
+ if (machine_is_accelent_sa() ||
+ machine_is_adsbitsy() || machine_is_assabet() ||
+ machine_is_cerf() || machine_is_flexanet() ||
+ machine_is_freebird() || machine_is_graphicsclient() ||
+ machine_is_graphicsmaster() || machine_is_lart() ||
+ machine_is_omnimeter() || machine_is_pfs168() ||
+ machine_is_shannon() || machine_is_simpad() ||
+ machine_is_simputer() || machine_is_yopy()) {
+ /*
+ * Setup the PPC unit correctly.
+ */
+ PPDR &= ~PPC_RXD4;
+ PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM;
+ PSDR |= PPC_RXD4;
+ PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
+ PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
+
+ Ser4MCSR = -1;
+ Ser4MCCR1 = 0;
+ Ser4MCCR0 = 0x00007f7f | MCCR0_ADM;
+
+ /*
+ * Calculate the read/write timeout (us) from the bit clock
+ * rate. This is the period for 3 64-bit frames. Always
+ * round this time up.
+ */
+ mcp->rw_timeout = (64 * 3 * 1000000 + mcp->sclk_rate - 1) /
+ mcp->sclk_rate;
+
+ ret = mcp_register(mcp);
+ }
+
+ return ret;
+}
+
+module_init(mcp_sa1100_init);
+EXPORT_SYMBOL(mcp_sa1100_init);
+
+MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
+MODULE_DESCRIPTION("SA11x0 multimedia communications port driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/misc/mcp.h linux-2.4.26-vrs1/drivers/misc/mcp.h
--- linux-2.4.26/drivers/misc/mcp.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/misc/mcp.h 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,44 @@
+/*
+ * linux/drivers/misc/mcp.h
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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.
+ */
+#ifndef MCP_H
+#define MCP_H
+
+struct mcp {
+ struct module *owner;
+ spinlock_t lock;
+ int use_count;
+ unsigned int sclk_rate;
+ unsigned int rw_timeout;
+ dma_device_t dma_audio_rd;
+ dma_device_t dma_audio_wr;
+ dma_device_t dma_telco_rd;
+ dma_device_t dma_telco_wr;
+ void (*set_telecom_divisor)(struct mcp *, unsigned int);
+ void (*set_audio_divisor)(struct mcp *, unsigned int);
+ void (*reg_write)(struct mcp *, unsigned int, unsigned int);
+ unsigned int (*reg_read)(struct mcp *, unsigned int);
+ void (*enable)(struct mcp *);
+ void (*disable)(struct mcp *);
+};
+
+void mcp_set_telecom_divisor(struct mcp *, unsigned int);
+void mcp_set_audio_divisor(struct mcp *, unsigned int);
+void mcp_reg_write(struct mcp *, unsigned int, unsigned int);
+unsigned int mcp_reg_read(struct mcp *, unsigned int);
+void mcp_enable(struct mcp *);
+void mcp_disable(struct mcp *);
+
+/* noddy implementation alert! */
+struct mcp *mcp_get(void);
+int mcp_register(struct mcp *);
+
+#define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate)
+
+#endif
diff -urN linux-2.4.26/drivers/misc/ucb1x00-audio.c linux-2.4.26-vrs1/drivers/misc/ucb1x00-audio.c
--- linux-2.4.26/drivers/misc/ucb1x00-audio.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/misc/ucb1x00-audio.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,378 @@
+/*
+ * linux/drivers/misc/ucb1x00-audio.c
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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/module.h>
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/sound.h>
+#include <linux/soundcard.h>
+#include <linux/list.h>
+
+#include <asm/dma.h>
+#include <asm/hardware.h>
+#include <asm/semaphore.h>
+#include <asm/uaccess.h>
+
+#include "ucb1x00.h"
+
+#include "../drivers/sound/sa1100-audio.h"
+
+#define MAGIC 0x41544154
+
+struct ucb1x00_audio {
+ struct file_operations fops;
+ struct file_operations mops;
+ struct ucb1x00 *ucb;
+ audio_stream_t output_stream;
+ audio_stream_t input_stream;
+ audio_state_t state;
+ unsigned int rate;
+ int dev_id;
+ int mix_id;
+ unsigned int daa_oh_bit;
+ unsigned int telecom;
+ unsigned int magic;
+ unsigned int ctrl_a;
+ unsigned int ctrl_b;
+
+ /* mixer info */
+ unsigned int mod_cnt;
+ unsigned short output_level;
+ unsigned short input_level;
+};
+
+#define REC_MASK (SOUND_MASK_VOLUME | SOUND_MASK_MIC)
+#define DEV_MASK REC_MASK
+
+static int
+ucb1x00_mixer_ioctl(struct inode *ino, struct file *filp, uint cmd, ulong arg)
+{
+ struct ucb1x00_audio *ucba;
+ unsigned int val, gain;
+ int ret = 0;
+
+ ucba = list_entry(filp->f_op, struct ucb1x00_audio, mops);
+
+ if (_IOC_TYPE(cmd) != 'M')
+ return -EINVAL;
+
+ if (cmd == SOUND_MIXER_INFO) {
+ struct mixer_info mi;
+
+ strncpy(mi.id, "UCB1x00", sizeof(mi.id));
+ strncpy(mi.name, "Philips UCB1x00", sizeof(mi.name));
+ mi.modify_counter = ucba->mod_cnt;
+ return copy_to_user((void *)arg, &mi, sizeof(mi)) ? -EFAULT : 0;
+ }
+
+ if (_IOC_DIR(cmd) & _IOC_WRITE) {
+ unsigned int left, right;
+
+ ret = get_user(val, (unsigned int *)arg);
+ if (ret)
+ goto out;
+
+ left = val & 255;
+ right = val >> 8;
+
+ if (left > 100)
+ left = 100;
+ if (right > 100)
+ right = 100;
+
+ gain = (left + right) / 2;
+
+ ret = -EINVAL;
+ if (!ucba->telecom) {
+ switch(_IOC_NR(cmd)) {
+ case SOUND_MIXER_VOLUME:
+ ucba->output_level = gain | gain << 8;
+ ucba->mod_cnt++;
+ ucba->ctrl_b = (ucba->ctrl_b & 0xff00) |
+ ((gain * 31) / 100);
+ ucb1x00_reg_write(ucba->ucb, UCB_AC_B,
+ ucba->ctrl_b);
+ ret = 0;
+ break;
+
+ case SOUND_MIXER_MIC:
+ ucba->input_level = gain | gain << 8;
+ ucba->mod_cnt++;
+ ucba->ctrl_a = (ucba->ctrl_a & 0x7f) |
+ (((gain * 31) / 100) << 7);
+ ucb1x00_reg_write(ucba->ucb, UCB_AC_A,
+ ucba->ctrl_a);
+ ret = 0;
+ break;
+ }
+ }
+ }
+
+ if (ret == 0 && _IOC_DIR(cmd) & _IOC_READ) {
+ switch (_IOC_NR(cmd)) {
+ case SOUND_MIXER_VOLUME:
+ val = ucba->output_level;
+ break;
+
+ case SOUND_MIXER_MIC:
+ val = ucba->input_level;
+ break;
+
+ case SOUND_MIXER_RECSRC:
+ case SOUND_MIXER_RECMASK:
+ val = ucba->telecom ? 0 : REC_MASK;
+ break;
+
+ case SOUND_MIXER_DEVMASK:
+ val = ucba->telecom ? 0 : DEV_MASK;
+ break;
+
+ case SOUND_MIXER_CAPS:
+ case SOUND_MIXER_STEREODEVS:
+ val = 0;
+ break;
+
+ default:
+ val = 0;
+ ret = -EINVAL;
+ break;
+ }
+
+ if (ret == 0)
+ ret = put_user(val, (int *)arg);
+ }
+ out:
+ return ret;
+}
+
+static int ucb1x00_audio_setrate(struct ucb1x00_audio *ucba, int rate)
+{
+ unsigned int div_rate = ucb1x00_clkrate(ucba->ucb) / 32;
+ unsigned int div;
+
+ div = (div_rate + (rate / 2)) / rate;
+ if (div < 6)
+ div = 6;
+ if (div > 127)
+ div = 127;
+
+ ucba->ctrl_a = (ucba->ctrl_a & ~0x7f) | div;
+
+ if (ucba->telecom) {
+ ucb1x00_reg_write(ucba->ucb, UCB_TC_B, 0);
+ ucb1x00_set_telecom_divisor(ucba->ucb, div * 32);
+ ucb1x00_reg_write(ucba->ucb, UCB_TC_A, ucba->ctrl_a);
+ ucb1x00_reg_write(ucba->ucb, UCB_TC_B, ucba->ctrl_b);
+ } else {
+ ucb1x00_reg_write(ucba->ucb, UCB_AC_B, 0);
+ ucb1x00_set_audio_divisor(ucba->ucb, div * 32);
+ ucb1x00_reg_write(ucba->ucb, UCB_AC_A, ucba->ctrl_a);
+ ucb1x00_reg_write(ucba->ucb, UCB_AC_B, ucba->ctrl_b);
+ }
+
+ ucba->rate = div_rate / div;
+
+ return ucba->rate;
+}
+
+static int ucb1x00_audio_getrate(struct ucb1x00_audio *ucba)
+{
+ return ucba->rate;
+}
+
+static void ucb1x00_audio_startup(void *data)
+{
+ struct ucb1x00_audio *ucba = data;
+
+ ucb1x00_enable(ucba->ucb);
+ ucb1x00_audio_setrate(ucba, ucba->rate);
+
+ ucb1x00_reg_write(ucba->ucb, UCB_MODE, UCB_MODE_DYN_VFLAG_ENA);
+
+ /*
+ * Take off-hook
+ */
+ if (ucba->daa_oh_bit)
+ ucb1x00_io_write(ucba->ucb, 0, ucba->daa_oh_bit);
+}
+
+static void ucb1x00_audio_shutdown(void *data)
+{
+ struct ucb1x00_audio *ucba = data;
+
+ /*
+ * Place on-hook
+ */
+ if (ucba->daa_oh_bit)
+ ucb1x00_io_write(ucba->ucb, ucba->daa_oh_bit, 0);
+
+ ucb1x00_reg_write(ucba->ucb, ucba->telecom ? UCB_TC_B : UCB_AC_B, 0);
+ ucb1x00_disable(ucba->ucb);
+}
+
+static int
+ucb1x00_audio_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
+{
+ struct ucb1x00_audio *ucba;
+ int val, ret = 0;
+
+ ucba = list_entry(file->f_op, struct ucb1x00_audio, fops);
+
+ /*
+ * Make sure we have our magic number
+ */
+ if (ucba->magic != MAGIC)
+ return -ENODEV;
+
+ switch (cmd) {
+ case SNDCTL_DSP_STEREO:
+ ret = get_user(val, (int *)arg);
+ if (ret)
+ return ret;
+ if (val != 0)
+ return -EINVAL;
+ val = 0;
+ break;
+
+ case SNDCTL_DSP_CHANNELS:
+ case SOUND_PCM_READ_CHANNELS:
+ val = 1;
+ break;
+
+ case SNDCTL_DSP_SPEED:
+ ret = get_user(val, (int *)arg);
+ if (ret)
+ return ret;
+ val = ucb1x00_audio_setrate(ucba, val);
+ break;
+
+ case SOUND_PCM_READ_RATE:
+ val = ucb1x00_audio_getrate(ucba);
+ break;
+
+ case SNDCTL_DSP_SETFMT:
+ case SNDCTL_DSP_GETFMTS:
+ val = AFMT_S16_LE;
+ break;
+
+ default:
+ return ucb1x00_mixer_ioctl(inode, file, cmd, arg);
+ }
+
+ return put_user(val, (int *)arg);
+}
+
+static int ucb1x00_audio_open(struct inode *inode, struct file *file)
+{
+ struct ucb1x00_audio *ucba;
+
+ ucba = list_entry(file->f_op, struct ucb1x00_audio, fops);
+
+ return sa1100_audio_attach(inode, file, &ucba->state);
+}
+
+static struct ucb1x00_audio *ucb1x00_audio_alloc(struct ucb1x00 *ucb)
+{
+ struct ucb1x00_audio *ucba;
+
+ ucba = kmalloc(sizeof(*ucba), GFP_KERNEL);
+ if (ucba) {
+ memset(ucba, 0, sizeof(*ucba));
+
+ ucba->magic = MAGIC;
+ ucba->ucb = ucb;
+ ucba->fops.owner = THIS_MODULE;
+ ucba->fops.open = ucb1x00_audio_open;
+ ucba->mops.owner = THIS_MODULE;
+ ucba->mops.ioctl = ucb1x00_mixer_ioctl;
+ ucba->state.output_stream = &ucba->output_stream;
+ ucba->state.input_stream = &ucba->input_stream;
+ ucba->state.data = ucba;
+ ucba->state.hw_init = ucb1x00_audio_startup;
+ ucba->state.hw_shutdown = ucb1x00_audio_shutdown;
+ ucba->state.client_ioctl = ucb1x00_audio_ioctl;
+
+ /* There is a bug in the StrongARM causes corrupt MCP data to be sent to
+ * the codec when the FIFOs are empty and writes are made to the OS timer
+ * match register 0. To avoid this we must make sure that data is always
+ * sent to the codec.
+ */
+ ucba->state.need_tx_for_rx = 1;
+
+ init_MUTEX(&ucba->state.sem);
+ ucba->rate = 8000;
+ }
+ return ucba;
+}
+
+static struct ucb1x00_audio *audio, *telecom;
+
+static int __init ucb1x00_audio_init(void)
+{
+ struct ucb1x00 *ucb = ucb1x00_get();
+ struct ucb1x00_audio *a;
+
+ if (!ucb)
+ return -ENODEV;
+
+ a = ucb1x00_audio_alloc(ucb);
+ if (a) {
+ a->state.input_dma = ucb->mcp->dma_audio_rd;
+ a->state.input_id = "UCB1x00 audio in";
+ a->state.output_dma = ucb->mcp->dma_audio_wr;
+ a->state.output_id = "UCB1x00 audio out";
+ a->dev_id = register_sound_dsp(&a->fops, -1);
+ a->mix_id = register_sound_mixer(&a->mops, -1);
+ a->ctrl_a = 0;
+ a->ctrl_b = UCB_AC_B_IN_ENA|UCB_AC_B_OUT_ENA;
+ audio = a;
+ }
+
+ a = ucb1x00_audio_alloc(ucb);
+ if (a) {
+#if 0
+ a->daa_oh_bit = UCB_IO_8;
+
+ ucb1x00_enable(ucb);
+ ucb1x00_io_write(ucb, a->daa_oh_bit, 0);
+ ucb1x00_io_set_dir(ucb, UCB_IO_7 | UCB_IO_6, a->daa_oh_bit);
+ ucb1x00_disable(ucb);
+#endif
+
+ a->telecom = 1;
+ a->state.input_dma = ucb->mcp->dma_telco_rd;
+ a->state.input_id = "UCB1x00 telco in";
+ a->state.output_dma = ucb->mcp->dma_telco_wr;
+ a->state.output_id = "UCB1x00 telco out";
+ a->dev_id = register_sound_dsp(&a->fops, -1);
+ a->mix_id = register_sound_mixer(&a->mops, -1);
+ a->ctrl_a = 0;
+ a->ctrl_b = UCB_TC_B_IN_ENA|UCB_TC_B_OUT_ENA;
+ telecom = a;
+ }
+
+ return 0;
+}
+
+static void __exit ucb1x00_audio_exit(void)
+{
+ unregister_sound_dsp(telecom->dev_id);
+ unregister_sound_dsp(audio->dev_id);
+ unregister_sound_mixer(telecom->mix_id);
+ unregister_sound_mixer(audio->mix_id);
+}
+
+module_init(ucb1x00_audio_init);
+module_exit(ucb1x00_audio_exit);
+
+MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
+MODULE_DESCRIPTION("UCB1x00 telecom/audio driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/misc/ucb1x00-core.c linux-2.4.26-vrs1/drivers/misc/ucb1x00-core.c
--- linux-2.4.26/drivers/misc/ucb1x00-core.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/misc/ucb1x00-core.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,651 @@
+/*
+ * linux/drivers/misc/ucb1x00-core.c
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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.
+ *
+ * The UCB1x00 core driver provides basic services for handling IO,
+ * the ADC, interrupts, and accessing registers. It is designed
+ * such that everything goes through this layer, thereby providing
+ * a consistent locking methodology, as well as allowing the drivers
+ * to be used on other non-MCP-enabled hardware platforms.
+ *
+ * Note that all locks are private to this file. Nothing else may
+ * touch them.
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/pm.h>
+
+#include <asm/dma.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+#include <asm/arch/shannon.h>
+
+#include "ucb1x00.h"
+
+/**
+ * ucb1x00_io_set_dir - set IO direction
+ * @ucb: UCB1x00 structure describing chip
+ * @in: bitfield of IO pins to be set as inputs
+ * @out: bitfield of IO pins to be set as outputs
+ *
+ * Set the IO direction of the ten general purpose IO pins on
+ * the UCB1x00 chip. The @in bitfield has priority over the
+ * @out bitfield, in that if you specify a pin as both input
+ * and output, it will end up as an input.
+ *
+ * ucb1x00_enable must have been called to enable the comms
+ * before using this function.
+ *
+ * This function takes a spinlock, disabling interrupts.
+ */
+void ucb1x00_io_set_dir(struct ucb1x00 *ucb, unsigned int in, unsigned int out)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&ucb->io_lock, flags);
+ ucb->io_dir |= out;
+ ucb->io_dir &= ~in;
+
+ ucb1x00_reg_write(ucb, UCB_IO_DIR, ucb->io_dir);
+ spin_unlock_irqrestore(&ucb->io_lock, flags);
+}
+
+/**
+ * ucb1x00_io_write - set or clear IO outputs
+ * @ucb: UCB1x00 structure describing chip
+ * @set: bitfield of IO pins to set to logic '1'
+ * @clear: bitfield of IO pins to set to logic '0'
+ *
+ * Set the IO output state of the specified IO pins. The value
+ * is retained if the pins are subsequently configured as inputs.
+ * The @clear bitfield has priority over the @set bitfield -
+ * outputs will be cleared.
+ *
+ * ucb1x00_enable must have been called to enable the comms
+ * before using this function.
+ *
+ * This function takes a spinlock, disabling interrupts.
+ */
+void ucb1x00_io_write(struct ucb1x00 *ucb, unsigned int set, unsigned int clear)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&ucb->io_lock, flags);
+ ucb->io_out |= set;
+ ucb->io_out &= ~clear;
+
+ ucb1x00_reg_write(ucb, UCB_IO_DATA, ucb->io_out);
+ spin_unlock_irqrestore(&ucb->io_lock, flags);
+}
+
+/**
+ * ucb1x00_io_read - read the current state of the IO pins
+ * @ucb: UCB1x00 structure describing chip
+ *
+ * Return a bitfield describing the logic state of the ten
+ * general purpose IO pins.
+ *
+ * ucb1x00_enable must have been called to enable the comms
+ * before using this function.
+ *
+ * This function does not take any semaphores or spinlocks.
+ */
+unsigned int ucb1x00_io_read(struct ucb1x00 *ucb)
+{
+ return ucb1x00_reg_read(ucb, UCB_IO_DATA);
+}
+
+/*
+ * UCB1300 data sheet says we must:
+ * 1. enable ADC => 5us (including reference startup time)
+ * 2. select input => 51*tsibclk => 4.3us
+ * 3. start conversion => 102*tsibclk => 8.5us
+ * (tsibclk = 1/11981000)
+ * Period between SIB 128-bit frames = 10.7us
+ */
+
+/**
+ * ucb1x00_adc_enable - enable the ADC converter
+ * @ucb: UCB1x00 structure describing chip
+ *
+ * Enable the ucb1x00 and ADC converter on the UCB1x00 for use.
+ * Any code wishing to use the ADC converter must call this
+ * function prior to using it.
+ *
+ * This function takes the ADC semaphore to prevent two or more
+ * concurrent uses, and therefore may sleep. As a result, it
+ * can only be called from process context, not interrupt
+ * context.
+ *
+ * You should release the ADC as soon as possible using
+ * ucb1x00_adc_disable.
+ */
+void ucb1x00_adc_enable(struct ucb1x00 *ucb)
+{
+ down(&ucb->adc_sem);
+
+ ucb->adc_cr |= UCB_ADC_ENA;
+
+ ucb1x00_enable(ucb);
+ ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr);
+}
+
+/**
+ * ucb1x00_adc_read - read the specified ADC channel
+ * @ucb: UCB1x00 structure describing chip
+ * @adc_channel: ADC channel mask
+ * @sync: wait for syncronisation pulse.
+ *
+ * Start an ADC conversion and wait for the result. Note that
+ * synchronised ADC conversions (via the ADCSYNC pin) must wait
+ * until the trigger is asserted and the conversion is finished.
+ *
+ * This function currently spins waiting for the conversion to
+ * complete (2 frames max without sync).
+ *
+ * If called for a synchronised ADC conversion, it may sleep
+ * with the ADC semaphore held.
+ */
+unsigned int ucb1x00_adc_read(struct ucb1x00 *ucb, int adc_channel, int sync)
+{
+ unsigned int val;
+
+ if (sync)
+ adc_channel |= UCB_ADC_SYNC_ENA;
+
+ ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr | adc_channel);
+ ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr | adc_channel | UCB_ADC_START);
+
+ for (;;) {
+ val = ucb1x00_reg_read(ucb, UCB_ADC_DATA);
+ if (val & UCB_ADC_DAT_VAL)
+ break;
+ /* yield to other processes */
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(1);
+ }
+
+ return UCB_ADC_DAT(val);
+}
+
+/**
+ * ucb1x00_adc_disable - disable the ADC converter
+ * @ucb: UCB1x00 structure describing chip
+ *
+ * Disable the ADC converter and release the ADC semaphore.
+ */
+void ucb1x00_adc_disable(struct ucb1x00 *ucb)
+{
+ ucb->adc_cr &= ~UCB_ADC_ENA;
+ ucb1x00_reg_write(ucb, UCB_ADC_CR, ucb->adc_cr);
+ ucb1x00_disable(ucb);
+
+ up(&ucb->adc_sem);
+}
+
+#ifdef CONFIG_PM
+static int ucb1x00_pm (struct pm_dev *dev, pm_request_t rqst, void *data)
+{
+ struct ucb1x00 *ucb = (struct ucb1x00 *)dev->data;
+ unsigned int isr;
+
+ if (rqst == PM_RESUME) {
+ ucb1x00_enable(ucb);
+ isr = ucb1x00_reg_read(ucb, UCB_IE_STATUS);
+ ucb1x00_reg_write(ucb, UCB_IE_CLEAR, isr);
+ ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0);
+ ucb1x00_disable(ucb);
+ }
+
+ return 0;
+}
+#endif
+
+/*
+ * UCB1x00 Interrupt handling.
+ *
+ * The UCB1x00 can generate interrupts when the SIBCLK is stopped.
+ * Since we need to read an internal register, we must re-enable
+ * SIBCLK to talk to the chip. We leave the clock running until
+ * we have finished processing all interrupts from the chip.
+ */
+static void ucb1x00_irq(int irqnr, void *devid, struct pt_regs *regs)
+{
+ struct ucb1x00 *ucb = devid;
+ struct ucb1x00_irq *irq;
+ unsigned int isr, i;
+
+ ucb1x00_enable(ucb);
+ isr = ucb1x00_reg_read(ucb, UCB_IE_STATUS);
+ ucb1x00_reg_write(ucb, UCB_IE_CLEAR, isr);
+ ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0);
+
+ for (i = 0, irq = ucb->irq_handler; i < 16 && isr; i++, isr >>= 1, irq++)
+ if (isr & 1 && irq->fn)
+ irq->fn(i, irq->devid);
+ ucb1x00_disable(ucb);
+}
+
+/**
+ * ucb1x00_hook_irq - hook a UCB1x00 interrupt
+ * @ucb: UCB1x00 structure describing chip
+ * @idx: interrupt index
+ * @fn: function to call when interrupt is triggered
+ * @devid: device id to pass to interrupt handler
+ *
+ * Hook the specified interrupt. You can only register one handler
+ * for each interrupt source. The interrupt source is not enabled
+ * by this function; use ucb1x00_enable_irq instead.
+ *
+ * Interrupt handlers will be called with other interrupts enabled.
+ *
+ * Returns zero on success, or one of the following errors:
+ * -EINVAL if the interrupt index is invalid
+ * -EBUSY if the interrupt has already been hooked
+ */
+int ucb1x00_hook_irq(struct ucb1x00 *ucb, unsigned int idx, void (*fn)(int, void *), void *devid)
+{
+ struct ucb1x00_irq *irq;
+ int ret = -EINVAL;
+
+ if (idx < 16) {
+ irq = ucb->irq_handler + idx;
+ ret = -EBUSY;
+
+ spin_lock_irq(&ucb->lock);
+ if (irq->fn == NULL) {
+ irq->devid = devid;
+ irq->fn = fn;
+ ret = 0;
+ }
+ spin_unlock_irq(&ucb->lock);
+ }
+ return ret;
+}
+
+/**
+ * ucb1x00_enable_irq - enable an UCB1x00 interrupt source
+ * @ucb: UCB1x00 structure describing chip
+ * @idx: interrupt index
+ * @edges: interrupt edges to enable
+ *
+ * Enable the specified interrupt to trigger on %UCB_RISING,
+ * %UCB_FALLING or both edges. The interrupt should have been
+ * hooked by ucb1x00_hook_irq.
+ */
+void ucb1x00_enable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges)
+{
+ unsigned long flags;
+
+ if (idx < 16) {
+ spin_lock_irqsave(&ucb->lock, flags);
+
+ ucb1x00_enable(ucb);
+ if (edges & UCB_RISING) {
+ ucb->irq_ris_enbl |= 1 << idx;
+ ucb1x00_reg_write(ucb, UCB_IE_RIS, ucb->irq_ris_enbl);
+ }
+ if (edges & UCB_FALLING) {
+ ucb->irq_fal_enbl |= 1 << idx;
+ ucb1x00_reg_write(ucb, UCB_IE_FAL, ucb->irq_fal_enbl);
+ }
+ ucb1x00_disable(ucb);
+ spin_unlock_irqrestore(&ucb->lock, flags);
+ }
+}
+
+/**
+ * ucb1x00_disable_irq - disable an UCB1x00 interrupt source
+ * @ucb: UCB1x00 structure describing chip
+ * @edges: interrupt edges to disable
+ *
+ * Disable the specified interrupt triggering on the specified
+ * (%UCB_RISING, %UCB_FALLING or both) edges.
+ */
+void ucb1x00_disable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges)
+{
+ unsigned long flags;
+
+ if (idx < 16) {
+ spin_lock_irqsave(&ucb->lock, flags);
+
+ ucb1x00_enable(ucb);
+ if (edges & UCB_RISING) {
+ ucb->irq_ris_enbl &= ~(1 << idx);
+ ucb1x00_reg_write(ucb, UCB_IE_RIS, ucb->irq_ris_enbl);
+ }
+ if (edges & UCB_FALLING) {
+ ucb->irq_fal_enbl &= ~(1 << idx);
+ ucb1x00_reg_write(ucb, UCB_IE_FAL, ucb->irq_fal_enbl);
+ }
+ ucb1x00_disable(ucb);
+ spin_unlock_irqrestore(&ucb->lock, flags);
+ }
+}
+
+/**
+ * ucb1x00_free_irq - disable and free the specified UCB1x00 interrupt
+ * @ucb: UCB1x00 structure describing chip
+ * @idx: interrupt index
+ * @devid: device id.
+ *
+ * Disable the interrupt source and remove the handler. devid must
+ * match the devid passed when hooking the interrupt.
+ *
+ * Returns zero on success, or one of the following errors:
+ * -EINVAL if the interrupt index is invalid
+ * -ENOENT if devid does not match
+ */
+int ucb1x00_free_irq(struct ucb1x00 *ucb, unsigned int idx, void *devid)
+{
+ struct ucb1x00_irq *irq;
+ int ret;
+
+ if (idx >= 16)
+ goto bad;
+
+ irq = ucb->irq_handler + idx;
+ ret = -ENOENT;
+
+ spin_lock_irq(&ucb->lock);
+ if (irq->devid == devid) {
+ ucb->irq_ris_enbl &= ~(1 << idx);
+ ucb->irq_fal_enbl &= ~(1 << idx);
+
+ ucb1x00_enable(ucb);
+ ucb1x00_reg_write(ucb, UCB_IE_RIS, ucb->irq_ris_enbl);
+ ucb1x00_reg_write(ucb, UCB_IE_FAL, ucb->irq_fal_enbl);
+ ucb1x00_disable(ucb);
+
+ irq->fn = NULL;
+ irq->devid = NULL;
+ ret = 0;
+ }
+ spin_unlock_irq(&ucb->lock);
+ return ret;
+
+bad:
+ printk(KERN_ERR "%s: freeing bad irq %d\n", __FUNCTION__, idx);
+ return -EINVAL;
+}
+
+/*
+ * Try to probe our interrupt, rather than relying on lots of
+ * hard-coded machine dependencies. For reference, the expected
+ * IRQ mappings are:
+ *
+ * Machine Default IRQ
+ * adsbitsy IRQ_GPCIN4
+ * cerf IRQ_GPIO_UCB1200_IRQ
+ * flexanet IRQ_GPIO_GUI
+ * freebird IRQ_GPIO_FREEBIRD_UCB1300_IRQ
+ * graphicsclient IRQ_GRAPHICSCLIENT_UCB1200
+ * graphicsmaster IRQ_GRAPHICSMASTER_UCB1200
+ * lart LART_IRQ_UCB1200
+ * omnimeter IRQ_GPIO23
+ * pfs168 IRQ_GPIO_UCB1300_IRQ
+ * simpad IRQ_GPIO_UCB1300_IRQ
+ * shannon SHANNON_IRQ_GPIO_IRQ_CODEC
+ * yopy IRQ_GPIO_UCB1200_IRQ
+ */
+static int __init ucb1x00_detect_irq(struct ucb1x00 *ucb)
+{
+ unsigned long mask;
+
+ mask = probe_irq_on();
+ if (!mask)
+ return NO_IRQ;
+
+ /*
+ * Enable the ADC interrupt.
+ */
+ ucb1x00_reg_write(ucb, UCB_IE_RIS, UCB_IE_ADC);
+ ucb1x00_reg_write(ucb, UCB_IE_FAL, UCB_IE_ADC);
+ ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0xffff);
+ ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0);
+
+ /*
+ * Cause an ADC interrupt.
+ */
+ ucb1x00_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA);
+ ucb1x00_reg_write(ucb, UCB_ADC_CR, UCB_ADC_ENA | UCB_ADC_START);
+
+ /*
+ * Wait for the conversion to complete.
+ */
+ while ((ucb1x00_reg_read(ucb, UCB_ADC_DATA) & UCB_ADC_DAT_VAL) == 0);
+ ucb1x00_reg_write(ucb, UCB_ADC_CR, 0);
+
+ /*
+ * Disable and clear interrupt.
+ */
+ ucb1x00_reg_write(ucb, UCB_IE_RIS, 0);
+ ucb1x00_reg_write(ucb, UCB_IE_FAL, 0);
+ ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0xffff);
+ ucb1x00_reg_write(ucb, UCB_IE_CLEAR, 0);
+
+ /*
+ * Read triggered interrupt.
+ */
+ return probe_irq_off(mask);
+}
+
+/*
+ * This configures the UCB1x00 layer depending on the machine type
+ * we're running on. The UCB1x00 drivers should not contain any
+ * machine dependencies.
+ *
+ * We can get rid of some of these dependencies by using existing
+ * facilities provided by the kernel - namely IRQ probing. The
+ * machine specific files are expected to setup the IRQ levels on
+ * initialisation. With any luck, we'll get rid of all the
+ * machine dependencies here.
+ */
+static int __init ucb1x00_configure(struct ucb1x00 *ucb)
+{
+ unsigned int irq_gpio_pin = 0;
+ int irq, default_irq = NO_IRQ;
+
+ if (machine_is_adsbitsy())
+ default_irq = IRQ_GPCIN4;
+
+// if (machine_is_assabet())
+// default_irq = IRQ_GPIO23;
+
+#ifdef CONFIG_SA1100_CERF
+ if (machine_is_cerf())
+ default_irq = IRQ_GPIO_UCB1200_IRQ;
+#endif
+#ifdef CONFIG_SA1100_FREEBIRD
+ if (machine_is_freebird())
+ default_irq = IRQ_GPIO_FREEBIRD_UCB1300_IRQ;
+#endif
+#if defined(CONFIG_SA1100_GRAPHICSCLIENT)
+// if (machine_is_graphicsclient())
+// default_irq = IRQ_GRAPHICSCLIENT_UCB1200;
+#endif
+#if defined(CONFIG_SA1100_GRAPICSMASTER)
+ if (machine_is_graphicsmaster())
+ default_irq = IRQ_GRAPHICSMASTER_UCB1200;
+#endif
+#ifdef CONFIG_SA1100_LART
+ if (machine_is_lart()) {
+ default_irq = LART_IRQ_UCB1200;
+ irq_gpio_pin = LART_GPIO_UCB1200;
+ }
+#endif
+ if (machine_is_omnimeter())
+ default_irq = IRQ_GPIO23;
+
+#ifdef CONFIG_SA1100_PFS168
+ if (machine_is_pfs168())
+ default_irq = IRQ_GPIO_UCB1300_IRQ;
+#endif
+#ifdef CONFIG_SA1100_SIMPAD
+ if (machine_is_simpad())
+ default_irq = IRQ_GPIO_UCB1300_IRQ;
+#endif
+#ifdef CONFIG_SA1100_SIMPUTER
+ if (machine_is_simputer()) {
+ default_irq = IRQ_GPIO_UCB1300_IRQ;
+ irq_gpio_pin = GPIO_UCB1300_IRQ;
+ }
+#endif
+ if (machine_is_shannon())
+ default_irq = SHANNON_IRQ_GPIO_IRQ_CODEC;
+#ifdef CONFIG_SA1100_YOPY
+ if (machine_is_yopy())
+ default_irq = IRQ_GPIO_UCB1200_IRQ;
+#endif
+#ifdef CONFIG_SA1100_ACCELENT
+ if (machine_is_accelent_sa()) {
+ ucb->irq = IRQ_GPIO_UCB1200_IRQ;
+ irq_gpio_pin = GPIO_UCB1200_IRQ;
+ }
+#endif
+
+ /*
+ * Eventually, this will disappear.
+ */
+ if (irq_gpio_pin)
+ set_GPIO_IRQ_edge(irq_gpio_pin, GPIO_RISING_EDGE);
+
+ irq = ucb1x00_detect_irq(ucb);
+ if (irq != NO_IRQ) {
+ if (default_irq != NO_IRQ && irq != default_irq)
+ printk(KERN_ERR "UCB1x00: probed IRQ%d != default IRQ%d\n",
+ irq, default_irq);
+ if (irq == default_irq)
+ printk(KERN_ERR "UCB1x00: probed IRQ%d correctly. "
+ "Please remove machine dependencies from "
+ "ucb1x00-core.c\n", irq);
+ ucb->irq = irq;
+ } else {
+ printk(KERN_ERR "UCB1x00: IRQ probe failed, using IRQ%d\n",
+ default_irq);
+ ucb->irq = default_irq;
+ }
+
+ return ucb->irq == NO_IRQ ? -ENODEV : 0;
+}
+
+struct ucb1x00 *my_ucb;
+
+/**
+ * ucb1x00_get - get the UCB1x00 structure describing a chip
+ * @ucb: UCB1x00 structure describing chip
+ *
+ * Return the UCB1x00 structure describing a chip.
+ *
+ * FIXME: Currently very noddy indeed, which currently doesn't
+ * matter since we only support one chip.
+ */
+struct ucb1x00 *ucb1x00_get(void)
+{
+ return my_ucb;
+}
+
+static int __init ucb1x00_init(void)
+{
+ struct mcp *mcp;
+ unsigned int id;
+ int ret = -ENODEV;
+
+ mcp = mcp_get();
+ if (!mcp)
+ goto no_mcp;
+
+ mcp_enable(mcp);
+ id = mcp_reg_read(mcp, UCB_ID);
+
+ if (id != UCB_ID_1200 && id != UCB_ID_1300) {
+ printk(KERN_WARNING "UCB1x00 ID not found: %04x\n", id);
+ goto out;
+ }
+
+ my_ucb = kmalloc(sizeof(struct ucb1x00), GFP_KERNEL);
+ ret = -ENOMEM;
+ if (!my_ucb)
+ goto out;
+
+ if (machine_is_shannon()) {
+ /* reset the codec */
+ GPDR |= SHANNON_GPIO_CODEC_RESET;
+ GPCR = SHANNON_GPIO_CODEC_RESET;
+ GPSR = SHANNON_GPIO_CODEC_RESET;
+
+ }
+
+ memset(my_ucb, 0, sizeof(struct ucb1x00));
+
+ spin_lock_init(&my_ucb->lock);
+ spin_lock_init(&my_ucb->io_lock);
+ sema_init(&my_ucb->adc_sem, 1);
+
+ my_ucb->id = id;
+ my_ucb->mcp = mcp;
+
+ ret = ucb1x00_configure(my_ucb);
+ if (ret)
+ goto out;
+
+ ret = request_irq(my_ucb->irq, ucb1x00_irq, 0, "UCB1x00", my_ucb);
+ if (ret) {
+ printk(KERN_ERR "ucb1x00: unable to grab irq%d: %d\n",
+ my_ucb->irq, ret);
+ kfree(my_ucb);
+ my_ucb = NULL;
+ goto out;
+ }
+
+#ifdef CONFIG_PM
+ my_ucb->pmdev = pm_register(PM_SYS_DEV, PM_SYS_UNKNOWN, ucb1x00_pm);
+ if (my_ucb->pmdev == NULL)
+ printk("ucb1x00: unable to register in PM.\n");
+ else
+ my_ucb->pmdev->data = my_ucb;
+#endif
+
+out:
+ mcp_disable(mcp);
+no_mcp:
+ return ret;
+}
+
+static void __exit ucb1x00_exit(void)
+{
+ free_irq(my_ucb->irq, my_ucb);
+ kfree(my_ucb);
+}
+
+module_init(ucb1x00_init);
+module_exit(ucb1x00_exit);
+
+EXPORT_SYMBOL(ucb1x00_get);
+
+EXPORT_SYMBOL(ucb1x00_io_set_dir);
+EXPORT_SYMBOL(ucb1x00_io_write);
+EXPORT_SYMBOL(ucb1x00_io_read);
+
+EXPORT_SYMBOL(ucb1x00_adc_enable);
+EXPORT_SYMBOL(ucb1x00_adc_read);
+EXPORT_SYMBOL(ucb1x00_adc_disable);
+
+EXPORT_SYMBOL(ucb1x00_hook_irq);
+EXPORT_SYMBOL(ucb1x00_free_irq);
+EXPORT_SYMBOL(ucb1x00_enable_irq);
+EXPORT_SYMBOL(ucb1x00_disable_irq);
+
+MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
+MODULE_DESCRIPTION("UCB1x00 core driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/misc/ucb1x00-ts.c linux-2.4.26-vrs1/drivers/misc/ucb1x00-ts.c
--- linux-2.4.26/drivers/misc/ucb1x00-ts.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/misc/ucb1x00-ts.c 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,664 @@
+/*
+ * linux/drivers/misc/ucb1x00-ts.c
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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.
+ *
+ * 21-Jan-2002 <jco@ict.es> :
+ *
+ * Added support for synchronous A/D mode. This mode is useful to
+ * avoid noise induced in the touchpanel by the LCD, provided that
+ * the UCB1x00 has a valid LCD sync signal routed to its ADCSYNC pin.
+ * It is important to note that the signal connected to the ADCSYNC
+ * pin should provide pulses even when the LCD is blanked, otherwise
+ * a pen touch needed to unblank the LCD will never be read.
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
+#include <linux/sched.h>
+#include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/pm.h>
+
+#include <asm/dma.h>
+#include <asm/semaphore.h>
+
+#include "ucb1x00.h"
+
+/*
+ * Define this if you want the UCB1x00 stuff to talk to the input layer
+ */
+#undef USE_INPUT
+
+#ifndef USE_INPUT
+
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/poll.h>
+
+/*
+ * This structure is nonsense - millisecs is not very useful
+ * since the field size is too small. Also, we SHOULD NOT
+ * be exposing jiffies to user space directly.
+ */
+struct ts_event {
+ u16 pressure;
+ u16 x;
+ u16 y;
+ u16 pad;
+ struct timeval stamp;
+};
+
+#define NR_EVENTS 16
+
+#else
+
+#include <linux/input.h>
+
+#endif
+
+struct ucb1x00_ts {
+#ifdef USE_INPUT
+ struct input_dev idev;
+#endif
+ struct ucb1x00 *ucb;
+#ifdef CONFIG_PM
+ struct pm_dev *pmdev;
+#endif
+
+ wait_queue_head_t irq_wait;
+ struct semaphore sem;
+ struct completion init_exit;
+ struct task_struct *rtask;
+ int use_count;
+ u16 x_res;
+ u16 y_res;
+
+#ifndef USE_INPUT
+ struct fasync_struct *fasync;
+ wait_queue_head_t read_wait;
+ u8 evt_head;
+ u8 evt_tail;
+ struct ts_event events[NR_EVENTS];
+#endif
+ int restart:1;
+ int adcsync:1;
+};
+
+static struct ucb1x00_ts ucbts;
+static int adcsync = UCB_NOSYNC;
+
+static int ucb1x00_ts_startup(struct ucb1x00_ts *ts);
+static void ucb1x00_ts_shutdown(struct ucb1x00_ts *ts);
+
+#ifndef USE_INPUT
+
+#define ucb1x00_ts_evt_pending(ts) ((volatile u8)(ts)->evt_head != (ts)->evt_tail)
+#define ucb1x00_ts_evt_get(ts) ((ts)->events + (ts)->evt_tail)
+#define ucb1x00_ts_evt_pull(ts) ((ts)->evt_tail = ((ts)->evt_tail + 1) & (NR_EVENTS - 1))
+#define ucb1x00_ts_evt_clear(ts) ((ts)->evt_head = (ts)->evt_tail = 0)
+
+static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y)
+{
+ int next_head;
+
+ next_head = (ts->evt_head + 1) & (NR_EVENTS - 1);
+ if (next_head != ts->evt_tail) {
+ ts->events[ts->evt_head].pressure = pressure;
+ ts->events[ts->evt_head].x = x;
+ ts->events[ts->evt_head].y = y;
+ do_gettimeofday(&ts->events[ts->evt_head].stamp);
+ ts->evt_head = next_head;
+
+ if (ts->fasync)
+ kill_fasync(&ts->fasync, SIGIO, POLL_IN);
+ wake_up_interruptible(&ts->read_wait);
+ }
+}
+
+static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts)
+{
+ ucb1x00_ts_evt_add(ts, 0, 0, 0);
+}
+
+/*
+ * User space driver interface.
+ */
+static ssize_t
+ucb1x00_ts_read(struct file *filp, char *buffer, size_t count, loff_t *ppos)
+{
+ DECLARE_WAITQUEUE(wait, current);
+ struct ucb1x00_ts *ts = filp->private_data;
+ char *ptr = buffer;
+ int err = 0;
+
+ add_wait_queue(&ts->read_wait, &wait);
+ while (count >= sizeof(struct ts_event)) {
+ err = -ERESTARTSYS;
+ if (signal_pending(current))
+ break;
+
+ if (ucb1x00_ts_evt_pending(ts)) {
+ struct ts_event *evt = ucb1x00_ts_evt_get(ts);
+
+ err = copy_to_user(ptr, evt, sizeof(struct ts_event));
+ ucb1x00_ts_evt_pull(ts);
+
+ if (err)
+ break;
+
+ ptr += sizeof(struct ts_event);
+ count -= sizeof(struct ts_event);
+ continue;
+ }
+
+ set_current_state(TASK_INTERRUPTIBLE);
+ err = -EAGAIN;
+ if (filp->f_flags & O_NONBLOCK)
+ break;
+ schedule();
+ }
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&ts->read_wait, &wait);
+
+ return ptr == buffer ? err : ptr - buffer;
+}
+
+static unsigned int ucb1x00_ts_poll(struct file *filp, poll_table *wait)
+{
+ struct ucb1x00_ts *ts = filp->private_data;
+ int ret = 0;
+
+ poll_wait(filp, &ts->read_wait, wait);
+ if (ucb1x00_ts_evt_pending(ts))
+ ret = POLLIN | POLLRDNORM;
+
+ return ret;
+}
+
+static int ucb1x00_ts_fasync(int fd, struct file *filp, int on)
+{
+ struct ucb1x00_ts *ts = filp->private_data;
+
+ return fasync_helper(fd, filp, on, &ts->fasync);
+}
+
+static int ucb1x00_ts_open(struct inode *inode, struct file *filp)
+{
+ struct ucb1x00_ts *ts = &ucbts;
+ int ret = 0;
+
+ ret = ucb1x00_ts_startup(ts);
+ if (ret == 0)
+ filp->private_data = ts;
+
+ return ret;
+}
+
+/*
+ * Release touchscreen resources. Disable IRQs.
+ */
+static int ucb1x00_ts_release(struct inode *inode, struct file *filp)
+{
+ struct ucb1x00_ts *ts = filp->private_data;
+
+ down(&ts->sem);
+ ucb1x00_ts_fasync(-1, filp, 0);
+ ucb1x00_ts_shutdown(ts);
+ up(&ts->sem);
+
+ return 0;
+}
+
+static struct file_operations ucb1x00_fops = {
+ owner: THIS_MODULE,
+ read: ucb1x00_ts_read,
+ poll: ucb1x00_ts_poll,
+ open: ucb1x00_ts_open,
+ release: ucb1x00_ts_release,
+ fasync: ucb1x00_ts_fasync,
+};
+
+/*
+ * The official UCB1x00 touchscreen is a miscdevice:
+ * 10 char Non-serial mice, misc features
+ * 14 = /dev/touchscreen/ucb1x00 UCB 1x00 touchscreen
+ */
+static struct miscdevice ucb1x00_ts_dev = {
+ minor: 14,
+ name: "touchscreen/ucb1x00",
+ fops: &ucb1x00_fops,
+};
+
+static inline int ucb1x00_ts_register(struct ucb1x00_ts *ts)
+{
+ init_waitqueue_head(&ts->read_wait);
+ return misc_register(&ucb1x00_ts_dev);
+}
+
+static inline void ucb1x00_ts_deregister(struct ucb1x00_ts *ts)
+{
+ misc_deregister(&ucb1x00_ts_dev);
+}
+
+#else
+
+#define ucb1x00_ts_evt_clear(ts) do { } while (0)
+
+static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y)
+{
+ input_report_abs(&ts->idev, ABS_X, x);
+ input_report_abs(&ts->idev, ABS_Y, y);
+ input_report_abs(&ts->idev, ABS_PRESSURE, pressure);
+}
+
+static int ucb1x00_ts_open(struct input_dev *idev)
+{
+ struct ucb1x00_ts *ts = (struct ucb1x00_ts *)idev;
+
+ return ucb1x00_ts_startup(ts);
+}
+
+static void ucb1x00_ts_close(struct input_dev *idev)
+{
+ struct ucb1x00_ts *ts = (struct ucb1x00_ts *)idev;
+
+ down(&ts->sem);
+ ucb1x00_ts_shutdown(ts);
+ up(&ts->sem);
+}
+
+static inline int ucb1x00_ts_register(struct ucb1x00_ts *ts)
+{
+ ts->idev.name = "Touchscreen panel";
+ ts->idev.idproduct = ts->ucb->id;
+ ts->idev.open = ucb1x00_ts_open;
+ ts->idev.close = ucb1x00_ts_close;
+
+ __set_bit(EV_ABS, ts->idev.evbit);
+ __set_bit(ABS_X, ts->idev.absbit);
+ __set_bit(ABS_Y, ts->idev.absbit);
+ __set_bit(ABS_PRESSURE, ts->idev.absbit);
+
+ input_register_device(&ts->idev);
+
+ return 0;
+}
+
+static inline void ucb1x00_ts_deregister(struct ucb1x00_ts *ts)
+{
+ input_unregister_device(&ts->idev);
+}
+
+#endif
+
+/*
+ * Switch to interrupt mode.
+ */
+static inline void ucb1x00_ts_mode_int(struct ucb1x00_ts *ts)
+{
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
+ UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
+ UCB_TS_CR_MODE_INT);
+}
+
+/*
+ * Switch to pressure mode, and read pressure. We don't need to wait
+ * here, since both plates are being driven.
+ */
+static inline unsigned int ucb1x00_ts_read_pressure(struct ucb1x00_ts *ts)
+{
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW |
+ UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND |
+ UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+
+ return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync);
+}
+
+/*
+ * Switch to X position mode and measure Y plate. We switch the plate
+ * configuration in pressure mode, then switch to position mode. This
+ * gives a faster response time. Even so, we need to wait about 55us
+ * for things to stabilise.
+ */
+static inline unsigned int ucb1x00_ts_read_xpos(struct ucb1x00_ts *ts)
+{
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
+ UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
+ UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
+ UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
+
+ udelay(55);
+
+ return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync);
+}
+
+/*
+ * Switch to Y position mode and measure X plate. We switch the plate
+ * configuration in pressure mode, then switch to position mode. This
+ * gives a faster response time. Even so, we need to wait about 55us
+ * for things to stabilise.
+ */
+static inline unsigned int ucb1x00_ts_read_ypos(struct ucb1x00_ts *ts)
+{
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
+ UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
+ UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
+ UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA);
+
+ udelay(55);
+
+ return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPX, ts->adcsync);
+}
+
+/*
+ * Switch to X plate resistance mode. Set MX to ground, PX to
+ * supply. Measure current.
+ */
+static inline unsigned int ucb1x00_ts_read_xres(struct ucb1x00_ts *ts)
+{
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW |
+ UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+ return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync);
+}
+
+/*
+ * Switch to Y plate resistance mode. Set MY to ground, PY to
+ * supply. Measure current.
+ */
+static inline unsigned int ucb1x00_ts_read_yres(struct ucb1x00_ts *ts)
+{
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR,
+ UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW |
+ UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA);
+ return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync);
+}
+
+/*
+ * This is a RT kernel thread that handles the ADC accesses
+ * (mainly so we can use semaphores in the UCB1200 core code
+ * to serialise accesses to the ADC).
+ */
+static int ucb1x00_thread(void *_ts)
+{
+ struct ucb1x00_ts *ts = _ts;
+ struct task_struct *tsk = current;
+ DECLARE_WAITQUEUE(wait, tsk);
+ int valid;
+
+ ts->rtask = tsk;
+
+ daemonize();
+ reparent_to_init();
+ strcpy(tsk->comm, "ktsd");
+ tsk->tty = NULL;
+ /*
+ * We could run as a real-time thread. However, thus far
+ * this doesn't seem to be necessary.
+ */
+// tsk->policy = SCHED_FIFO;
+// tsk->rt_priority = 1;
+
+ /* only want to receive SIGKILL */
+ spin_lock_irq(&tsk->sigmask_lock);
+ siginitsetinv(&tsk->blocked, sigmask(SIGKILL));
+ recalc_sigpending(tsk);
+ spin_unlock_irq(&tsk->sigmask_lock);
+
+ complete(&ts->init_exit);
+
+ valid = 0;
+
+ add_wait_queue(&ts->irq_wait, &wait);
+ for (;;) {
+ unsigned int x, y, p, val;
+ signed long timeout;
+
+ ts->restart = 0;
+
+ ucb1x00_adc_enable(ts->ucb);
+
+ x = ucb1x00_ts_read_xpos(ts);
+ y = ucb1x00_ts_read_ypos(ts);
+ p = ucb1x00_ts_read_pressure(ts);
+
+ /*
+ * Switch back to interrupt mode.
+ */
+ ucb1x00_ts_mode_int(ts);
+ ucb1x00_adc_disable(ts->ucb);
+
+ set_task_state(tsk, TASK_UNINTERRUPTIBLE);
+ schedule_timeout(HZ / 100);
+ if (signal_pending(tsk))
+ break;
+
+ ucb1x00_enable(ts->ucb);
+ val = ucb1x00_reg_read(ts->ucb, UCB_TS_CR);
+
+ if (val & (UCB_TS_CR_TSPX_LOW | UCB_TS_CR_TSMX_LOW)) {
+ set_task_state(tsk, TASK_INTERRUPTIBLE);
+
+ ucb1x00_enable_irq(ts->ucb, UCB_IRQ_TSPX, UCB_FALLING);
+ ucb1x00_disable(ts->ucb);
+
+ /*
+ * If we spat out a valid sample set last time,
+ * spit out a "pen off" sample here.
+ */
+ if (valid) {
+ ucb1x00_ts_event_release(ts);
+ valid = 0;
+ }
+
+ timeout = MAX_SCHEDULE_TIMEOUT;
+ } else {
+ ucb1x00_disable(ts->ucb);
+
+ /*
+ * Filtering is policy. Policy belongs in user
+ * space. We therefore leave it to user space
+ * to do any filtering they please.
+ */
+ if (!ts->restart) {
+ ucb1x00_ts_evt_add(ts, p, x, y);
+ valid = 1;
+ }
+
+ set_task_state(tsk, TASK_INTERRUPTIBLE);
+ timeout = HZ / 100;
+ }
+
+ schedule_timeout(timeout);
+ if (signal_pending(tsk))
+ break;
+ }
+
+ remove_wait_queue(&ts->irq_wait, &wait);
+
+ ts->rtask = NULL;
+ ucb1x00_ts_evt_clear(ts);
+ complete_and_exit(&ts->init_exit, 0);
+}
+
+/*
+ * We only detect touch screen _touches_ with this interrupt
+ * handler, and even then we just schedule our task.
+ */
+static void ucb1x00_ts_irq(int idx, void *id)
+{
+ struct ucb1x00_ts *ts = id;
+ ucb1x00_disable_irq(ts->ucb, UCB_IRQ_TSPX, UCB_FALLING);
+ wake_up(&ts->irq_wait);
+}
+
+static int ucb1x00_ts_startup(struct ucb1x00_ts *ts)
+{
+ int ret = 0;
+
+ if (down_interruptible(&ts->sem))
+ return -EINTR;
+
+ if (ts->use_count++ != 0)
+ goto out;
+
+ if (ts->rtask)
+ panic("ucb1x00: rtask running?");
+
+ init_waitqueue_head(&ts->irq_wait);
+ ret = ucb1x00_hook_irq(ts->ucb, UCB_IRQ_TSPX, ucb1x00_ts_irq, ts);
+ if (ret < 0)
+ goto out;
+
+ /*
+ * If we do this at all, we should allow the user to
+ * measure and read the X and Y resistance at any time.
+ */
+ ucb1x00_adc_enable(ts->ucb);
+ ts->x_res = ucb1x00_ts_read_xres(ts);
+ ts->y_res = ucb1x00_ts_read_yres(ts);
+ ucb1x00_adc_disable(ts->ucb);
+
+ init_completion(&ts->init_exit);
+ ret = kernel_thread(ucb1x00_thread, ts, 0);
+ if (ret >= 0) {
+ wait_for_completion(&ts->init_exit);
+ ret = 0;
+ } else {
+ ucb1x00_free_irq(ts->ucb, UCB_IRQ_TSPX, ts);
+ }
+
+ out:
+ if (ret)
+ ts->use_count--;
+ up(&ts->sem);
+ return ret;
+}
+
+/*
+ * Release touchscreen resources. Disable IRQs.
+ */
+static void ucb1x00_ts_shutdown(struct ucb1x00_ts *ts)
+{
+ if (--ts->use_count == 0) {
+ if (ts->rtask) {
+ send_sig(SIGKILL, ts->rtask, 1);
+ wait_for_completion(&ts->init_exit);
+ }
+
+ ucb1x00_enable(ts->ucb);
+ ucb1x00_free_irq(ts->ucb, UCB_IRQ_TSPX, ts);
+ ucb1x00_reg_write(ts->ucb, UCB_TS_CR, 0);
+ ucb1x00_disable(ts->ucb);
+ }
+}
+
+#ifdef CONFIG_PM
+static int ucb1x00_ts_pm (struct pm_dev *dev, pm_request_t rqst, void *data)
+{
+ struct ucb1x00_ts *ts = (struct ucb1x00_ts *) (dev->data);
+
+ if (rqst == PM_RESUME && ts->rtask != NULL) {
+ /*
+ * Restart the TS thread to ensure the
+ * TS interrupt mode is set up again
+ * after sleep.
+ */
+ ts->restart = 1;
+ wake_up(&ts->irq_wait);
+ }
+ return 0;
+}
+#endif
+
+
+/*
+ * Initialisation.
+ */
+static int __init ucb1x00_ts_init(void)
+{
+ struct ucb1x00_ts *ts = &ucbts;
+
+ ts->ucb = ucb1x00_get();
+ if (!ts->ucb)
+ return -ENODEV;
+
+ ts->adcsync = adcsync;
+ init_MUTEX(&ts->sem);
+
+#ifdef CONFIG_PM
+ ts->pmdev = pm_register(PM_SYS_DEV, PM_SYS_UNKNOWN, ucb1x00_ts_pm);
+ if (ts->pmdev == NULL)
+ printk("ucb1x00_ts: unable to register in PM.\n");
+ else
+ ts->pmdev->data = ts;
+#endif
+ return ucb1x00_ts_register(ts);
+}
+
+static void __exit ucb1x00_ts_exit(void)
+{
+ struct ucb1x00_ts *ts = &ucbts;
+
+ ucb1x00_ts_deregister(ts);
+
+#ifdef CONFIG_PM
+ if (ts->pmdev)
+ pm_unregister(ts->pmdev);
+#endif
+}
+
+#ifndef MODULE
+
+/*
+ * Parse kernel command-line options.
+ *
+ * syntax : ucbts=[sync|nosync],...
+ */
+static int __init ucb1x00_ts_setup(char *str)
+{
+ char *p;
+
+ while ((p = strsep(&str, ",")) != NULL) {
+ if (strcmp(p, "sync") == 0)
+ adcsync = UCB_SYNC;
+ }
+
+ return 1;
+}
+
+__setup("ucbts=", ucb1x00_ts_setup);
+
+#else
+
+MODULE_PARM(adcsync, "i");
+MODULE_PARM_DESC(adcsync, "Enable use of ADCSYNC signal");
+
+#endif
+
+module_init(ucb1x00_ts_init);
+module_exit(ucb1x00_ts_exit);
+
+MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
+MODULE_DESCRIPTION("UCB1x00 touchscreen driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/misc/ucb1x00.h linux-2.4.26-vrs1/drivers/misc/ucb1x00.h
--- linux-2.4.26/drivers/misc/ucb1x00.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/misc/ucb1x00.h 2004-01-14 21:32:25.000000000 +0000
@@ -0,0 +1,232 @@
+/*
+ * linux/drivers/misc/ucb1x00.h
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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.
+ */
+#ifndef UCB1200_H
+#define UCB1200_H
+
+#define UCB_IO_DATA 0x00
+#define UCB_IO_DIR 0x01
+
+#define UCB_IO_0 (1 << 0)
+#define UCB_IO_1 (1 << 1)
+#define UCB_IO_2 (1 << 2)
+#define UCB_IO_3 (1 << 3)
+#define UCB_IO_4 (1 << 4)
+#define UCB_IO_5 (1 << 5)
+#define UCB_IO_6 (1 << 6)
+#define UCB_IO_7 (1 << 7)
+#define UCB_IO_8 (1 << 8)
+#define UCB_IO_9 (1 << 9)
+
+#define UCB_IE_RIS 0x02
+#define UCB_IE_FAL 0x03
+#define UCB_IE_STATUS 0x04
+#define UCB_IE_CLEAR 0x04
+#define UCB_IE_ADC (1 << 11)
+#define UCB_IE_TSPX (1 << 12)
+#define UCB_IE_TSMX (1 << 13)
+#define UCB_IE_TCLIP (1 << 14)
+#define UCB_IE_ACLIP (1 << 15)
+
+#define UCB_IRQ_TSPX 12
+
+#define UCB_TC_A 0x05
+#define UCB_TC_A_LOOP (1 << 7) /* UCB1200 */
+#define UCB_TC_A_AMPL (1 << 7) /* UCB1300 */
+
+#define UCB_TC_B 0x06
+#define UCB_TC_B_VOICE_ENA (1 << 3)
+#define UCB_TC_B_CLIP (1 << 4)
+#define UCB_TC_B_ATT (1 << 6)
+#define UCB_TC_B_SIDE_ENA (1 << 11)
+#define UCB_TC_B_MUTE (1 << 13)
+#define UCB_TC_B_IN_ENA (1 << 14)
+#define UCB_TC_B_OUT_ENA (1 << 15)
+
+#define UCB_AC_A 0x07
+#define UCB_AC_B 0x08
+#define UCB_AC_B_LOOP (1 << 8)
+#define UCB_AC_B_MUTE (1 << 13)
+#define UCB_AC_B_IN_ENA (1 << 14)
+#define UCB_AC_B_OUT_ENA (1 << 15)
+
+#define UCB_TS_CR 0x09
+#define UCB_TS_CR_TSMX_POW (1 << 0)
+#define UCB_TS_CR_TSPX_POW (1 << 1)
+#define UCB_TS_CR_TSMY_POW (1 << 2)
+#define UCB_TS_CR_TSPY_POW (1 << 3)
+#define UCB_TS_CR_TSMX_GND (1 << 4)
+#define UCB_TS_CR_TSPX_GND (1 << 5)
+#define UCB_TS_CR_TSMY_GND (1 << 6)
+#define UCB_TS_CR_TSPY_GND (1 << 7)
+#define UCB_TS_CR_MODE_INT (0 << 8)
+#define UCB_TS_CR_MODE_PRES (1 << 8)
+#define UCB_TS_CR_MODE_POS (2 << 8)
+#define UCB_TS_CR_BIAS_ENA (1 << 11)
+#define UCB_TS_CR_TSPX_LOW (1 << 12)
+#define UCB_TS_CR_TSMX_LOW (1 << 13)
+
+#define UCB_ADC_CR 0x0a
+#define UCB_ADC_SYNC_ENA (1 << 0)
+#define UCB_ADC_VREFBYP_CON (1 << 1)
+#define UCB_ADC_INP_TSPX (0 << 2)
+#define UCB_ADC_INP_TSMX (1 << 2)
+#define UCB_ADC_INP_TSPY (2 << 2)
+#define UCB_ADC_INP_TSMY (3 << 2)
+#define UCB_ADC_INP_AD0 (4 << 2)
+#define UCB_ADC_INP_AD1 (5 << 2)
+#define UCB_ADC_INP_AD2 (6 << 2)
+#define UCB_ADC_INP_AD3 (7 << 2)
+#define UCB_ADC_EXT_REF (1 << 5)
+#define UCB_ADC_START (1 << 7)
+#define UCB_ADC_ENA (1 << 15)
+
+#define UCB_ADC_DATA 0x0b
+#define UCB_ADC_DAT_VAL (1 << 15)
+#define UCB_ADC_DAT(x) (((x) & 0x7fe0) >> 5)
+
+#define UCB_ID 0x0c
+#define UCB_ID_1200 0x1004
+#define UCB_ID_1300 0x1005
+
+#define UCB_MODE 0x0d
+#define UCB_MODE_DYN_VFLAG_ENA (1 << 12)
+#define UCB_MODE_AUD_OFF_CAN (1 << 13)
+
+#include "mcp.h"
+
+struct ucb1x00;
+
+struct ucb1x00_irq {
+ void *devid;
+ void (*fn)(int, void *);
+};
+
+struct ucb1x00 {
+ spinlock_t lock;
+ struct mcp *mcp;
+ struct pm_dev *pmdev;
+ unsigned int irq;
+ struct semaphore adc_sem;
+ spinlock_t io_lock;
+ u16 id;
+ u16 io_dir;
+ u16 io_out;
+ u16 adc_cr;
+ u16 irq_fal_enbl;
+ u16 irq_ris_enbl;
+ struct ucb1x00_irq irq_handler[16];
+};
+
+/**
+ * ucb1x00_clkrate - return the UCB1x00 SIB clock rate
+ * @ucb: UCB1x00 structure describing chip
+ *
+ * Return the SIB clock rate in Hz.
+ */
+static inline unsigned int ucb1x00_clkrate(struct ucb1x00 *ucb)
+{
+ return mcp_get_sclk_rate(ucb->mcp);
+}
+
+/**
+ * ucb1x00_enable - enable the UCB1x00 SIB clock
+ * @ucb: UCB1x00 structure describing chip
+ *
+ * Enable the SIB clock. This can be called multiple times.
+ */
+static inline void ucb1x00_enable(struct ucb1x00 *ucb)
+{
+ mcp_enable(ucb->mcp);
+}
+
+/**
+ * ucb1x00_disable - disable the UCB1x00 SIB clock
+ * @ucb: UCB1x00 structure describing chip
+ *
+ * Disable the SIB clock. The SIB clock will only be disabled
+ * when the number of ucb1x00_enable calls match the number of
+ * ucb1x00_disable calls.
+ */
+static inline void ucb1x00_disable(struct ucb1x00 *ucb)
+{
+ mcp_disable(ucb->mcp);
+}
+
+/**
+ * ucb1x00_reg_write - write a UCB1x00 register
+ * @ucb: UCB1x00 structure describing chip
+ * @reg: UCB1x00 4-bit register index to write
+ * @val: UCB1x00 16-bit value to write
+ *
+ * Write the UCB1x00 register @reg with value @val. The SIB
+ * clock must be running for this function to return.
+ */
+static inline void ucb1x00_reg_write(struct ucb1x00 *ucb, unsigned int reg, unsigned int val)
+{
+ mcp_reg_write(ucb->mcp, reg, val);
+}
+
+/**
+ * ucb1x00_reg_read - read a UCB1x00 register
+ * @ucb: UCB1x00 structure describing chip
+ * @reg: UCB1x00 4-bit register index to write
+ *
+ * Read the UCB1x00 register @reg and return its value. The SIB
+ * clock must be running for this function to return.
+ */
+static inline unsigned int ucb1x00_reg_read(struct ucb1x00 *ucb, unsigned int reg)
+{
+ return mcp_reg_read(ucb->mcp, reg);
+}
+/**
+ * ucb1x00_set_audio_divisor -
+ * @ucb: UCB1x00 structure describing chip
+ * @div: SIB clock divisor
+ */
+static inline void ucb1x00_set_audio_divisor(struct ucb1x00 *ucb, unsigned int div)
+{
+ mcp_set_audio_divisor(ucb->mcp, div);
+}
+
+/**
+ * ucb1x00_set_telecom_divisor -
+ * @ucb: UCB1x00 structure describing chip
+ * @div: SIB clock divisor
+ */
+static inline void ucb1x00_set_telecom_divisor(struct ucb1x00 *ucb, unsigned int div)
+{
+ mcp_set_telecom_divisor(ucb->mcp, div);
+}
+
+struct ucb1x00 *ucb1x00_get(void);
+
+void ucb1x00_io_set_dir(struct ucb1x00 *ucb, unsigned int, unsigned int);
+void ucb1x00_io_write(struct ucb1x00 *ucb, unsigned int, unsigned int);
+unsigned int ucb1x00_io_read(struct ucb1x00 *ucb);
+
+#define UCB_NOSYNC (0)
+#define UCB_SYNC (1)
+
+unsigned int ucb1x00_adc_read(struct ucb1x00 *ucb, int adc_channel, int sync);
+void ucb1x00_adc_enable(struct ucb1x00 *ucb);
+void ucb1x00_adc_disable(struct ucb1x00 *ucb);
+
+/*
+ * Which edges of the IRQ do you want to control today?
+ */
+#define UCB_RISING (1 << 0)
+#define UCB_FALLING (1 << 1)
+
+int ucb1x00_hook_irq(struct ucb1x00 *ucb, unsigned int idx, void (*fn)(int, void *), void *devid);
+void ucb1x00_enable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges);
+void ucb1x00_disable_irq(struct ucb1x00 *ucb, unsigned int idx, int edges);
+int ucb1x00_free_irq(struct ucb1x00 *ucb, unsigned int idx, void *devid);
+
+#endif
diff -urN linux-2.4.26/drivers/mtd/chips/cfi_probe.c linux-2.4.26-vrs1/drivers/mtd/chips/cfi_probe.c
--- linux-2.4.26/drivers/mtd/chips/cfi_probe.c 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/chips/cfi_probe.c 2004-01-14 21:32:25.000000000 +0000
@@ -65,6 +65,10 @@
return 0;
}
cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+
+ /* some devices don't respond to 0xF0, so send 0xFF to be sure */
+ cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+
cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL);
if (!qry_present(map,base,cfi))
@@ -84,6 +88,8 @@
/* Eep. This chip also had the QRY marker.
* Is it an alias for the new one? */
cfi_send_gen_cmd(0xF0, 0, chips[i].start, map, cfi, cfi->device_type, NULL);
+ /* some devices don't respond to 0xF0, so send 0xFF to be sure */
+ cfi_send_gen_cmd(0xFF, 0, chips[i].start, map, cfi, cfi->device_type, NULL);
/* If the QRY marker goes away, it's an alias */
if (!qry_present(map, chips[i].start, cfi)) {
@@ -96,7 +102,8 @@
* too and if it's the same, assume it's an alias. */
/* FIXME: Use other modes to do a proper check */
cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
-
+ /* some devices don't respond to 0xF0, so send 0xFF to be sure */
+ cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
if (qry_present(map, base, cfi)) {
printk(KERN_DEBUG "%s: Found an alias at 0x%x for the chip at 0x%lx\n",
map->name, base, chips[i].start);
@@ -119,6 +126,10 @@
/* Put it back into Read Mode */
cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+ /* some devices don't respond to 0xF0, so send 0xFF to be sure */
+ cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+
+
printk(KERN_INFO "%s: Found %d x%d devices at 0x%x in %d-bit mode\n",
map->name, cfi->interleave, cfi->device_type*8, base,
map->buswidth*8);
@@ -165,6 +176,20 @@
cfi->cfiq->InterfaceDesc = le16_to_cpu(cfi->cfiq->InterfaceDesc);
cfi->cfiq->MaxBufWriteSize = le16_to_cpu(cfi->cfiq->MaxBufWriteSize);
+ /*
+ * ST screwed up the CFI interface for buffer writes on their parts,
+ * so this needs to be fixed up by hand here.
+ *
+ * A possible enhancment is that instead of just reverting back
+ * to word write (as this does), we could use the ST specific double
+ * word write instead.
+ */
+
+ if (cfi_read_query(map,base) == 0x20){
+ cfi->cfiq->BufWriteTimeoutTyp = 0;
+ cfi->cfiq->BufWriteTimeoutMax = 0;
+ }
+
#ifdef DEBUG_CFI
/* Dump the information therein */
print_cfi_ident(cfi->cfiq);
@@ -182,6 +207,9 @@
/* Put it back into Read Mode */
cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+ /* some devices don't respond to 0xF0, so send 0xFF to be sure */
+ cfi_send_gen_cmd(0xFF, 0, base, map, cfi, cfi->device_type, NULL);
+
return 1;
}
diff -urN linux-2.4.26/drivers/mtd/chips/jedec_probe.c linux-2.4.26-vrs1/drivers/mtd/chips/jedec_probe.c
--- linux-2.4.26/drivers/mtd/chips/jedec_probe.c 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/chips/jedec_probe.c 2004-04-18 21:33:04.000000000 +0100
@@ -100,6 +100,8 @@
#define M29W040B 0x00E3
/* SST */
+#define SST29EE020 0x0010
+#define SST29LE020 0x0012
#define SST29EE512 0x005d
#define SST29LE512 0x003d
#define SST39LF800 0x2781
@@ -839,6 +841,24 @@
}
}, {
mfr_id: MANUFACTURER_SST,
+ dev_id: SST29EE020,
+ name: "SST 29EE020",
+ DevSize: SIZE_256KiB,
+ CmdSet: P_ID_SST_PAGE,
+ NumEraseRegions: 1,
+ regions: {ERASEINFO(0x01000,64),
+ }
+ }, {
+ mfr_id: MANUFACTURER_SST,
+ dev_id: SST29LE020,
+ name: "SST 29LE020",
+ DevSize: SIZE_256KiB,
+ CmdSet: P_ID_SST_PAGE,
+ NumEraseRegions: 1,
+ regions: {ERASEINFO(0x01000,64),
+ }
+ }, {
+ mfr_id: MANUFACTURER_SST,
dev_id: SST39LF020,
name: "SST 39LF020",
DevSize: SIZE_256KiB,
@@ -937,7 +957,20 @@
struct cfi_private *cfi)
{
/* Reset */
- cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
+
+ /* after checking the datasheets for SST, MACRONIX and ATMEL
+ * (oh and incidentaly the jedec spec - 3.5.3.3) the reset
+ * sequence is *supposed* to be 0xaa at 0x5555, 0x55 at
+ * 0x2aaa, 0xF0 at 0x5555 this will not affect the AMD chips
+ * as they will ignore the writes and dont care what address
+ * the F0 is written to */
+ if(cfi->addr_unlock1) {
+ /*printk("reset unlock called %x %x \n",cfi->addr_unlock1,cfi->addr_unlock2);*/
+ cfi_send_gen_cmd(0xaa, cfi->addr_unlock1, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
+ cfi_send_gen_cmd(0x55, cfi->addr_unlock2, base, map, cfi, CFI_DEVICETYPE_X8, NULL);
+ }
+
+ cfi_send_gen_cmd(0xF0, cfi->addr_unlock1, base, map, cfi, cfi->device_type, NULL);
/* Some misdesigned intel chips do not respond for 0xF0 for a reset,
* so ensure we're in read mode. Send both the Intel and the AMD command
* for this. Intel uses 0xff for this, AMD uses 0xff for NOP, so
diff -urN linux-2.4.26/drivers/mtd/devices/Config.in linux-2.4.26-vrs1/drivers/mtd/devices/Config.in
--- linux-2.4.26/drivers/mtd/devices/Config.in 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/devices/Config.in 2004-01-14 21:32:25.000000000 +0000
@@ -17,6 +17,15 @@
if [ "$CONFIG_SA1100_LART" = "y" ]; then
dep_tristate ' 28F160xx flash driver for LART' CONFIG_MTD_LART $CONFIG_MTD
fi
+if [ "$CONFIG_ARCH_MX1ADS" = "y" ]; then
+ dep_tristate ' SyncFlash driver for MX1ADS' CONFIG_MTD_SYNCFLASH $CONFIG_MTD
+fi
+if [ "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
+ dep_tristate ' AT91RM9200 DataFlash support' CONFIG_MTD_AT91_DATAFLASH $CONFIG_MTD
+ if [ "$CONFIG_MTD_AT91_DATAFLASH" = "y" -o "$CONFIG_MTD_AT91_DATAFLASH" = "m" ]; then
+ bool ' Enable DataFlash card? ' CONFIG_MTD_AT91_DATAFLASH_CARD
+ fi
+fi
dep_tristate ' Test driver using RAM' CONFIG_MTD_MTDRAM $CONFIG_MTD
if [ "$CONFIG_MTD_MTDRAM" = "y" -o "$CONFIG_MTD_MTDRAM" = "m" ]; then
int 'MTDRAM device size in KiB' CONFIG_MTDRAM_TOTAL_SIZE 4096
diff -urN linux-2.4.26/drivers/mtd/devices/Makefile linux-2.4.26-vrs1/drivers/mtd/devices/Makefile
--- linux-2.4.26/drivers/mtd/devices/Makefile 2002-11-28 23:53:13.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/mtd/devices/Makefile 2004-01-14 21:32:25.000000000 +0000
@@ -21,6 +21,7 @@
obj-$(CONFIG_MTD_MS02NV) += ms02-nv.o
obj-$(CONFIG_MTD_MTDRAM) += mtdram.o
obj-$(CONFIG_MTD_LART) += lart.o
+obj-$(CONFIG_MTD_SYNCFLASH) += syncflash.o
obj-$(CONFIG_MTD_BLKMTD) += blkmtd.o
include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/mtd/devices/syncflash.c linux-2.4.26-vrs1/drivers/mtd/devices/syncflash.c
--- linux-2.4.26/drivers/mtd/devices/syncflash.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/devices/syncflash.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,615 @@
+/*
+ * MTD driver for Micron SyncFlash flash memory.
+ *
+ * Author: Jon McClintock <jonm@bluemug.com>
+ *
+ * Based loosely upon the LART flash driver, authored by Abraham vd Merwe
+ * <abraham@2d3d.co.za>.
+ *
+ * Copyright 2003, Blue Mug, Inc. for Motorola, Inc.
+ *
+ * This code 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.
+ *
+ * References:
+ *
+ * [1] Micron SyncFlash homepage
+ * - http://www.syncflash.com/
+ *
+ * [2] MT28S4M16LC -- 4Mx16 SyncFlash memory datasheet
+ * - http://syncflash.com/pdfs/datasheets/mt28s4m16lc_6.pdf
+ *
+ * [3] MTD internal API documentation
+ * - http://www.linux-mtd.infradead.org/tech/
+ *
+ * Limitations:
+ *
+ * Even though this driver is written for Micron SyncFlash, it is quite
+ * specific to the Motorola MX1 ADS development board.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/version.h>
+#include <linux/errno.h>
+#include <linux/mtd/mtd.h>
+#include <asm/io.h>
+
+/* partition support */
+#define HAVE_PARTITIONS
+#ifdef HAVE_PARTITIONS
+#include <linux/mtd/partitions.h>
+#endif
+
+#ifndef CONFIG_ARCH_MX1ADS
+#error The SyncFlash driver currently only supports the MX1 ADS platform.
+#endif
+
+/*
+ * General flash configuration parameters.
+ */
+#define BUSWIDTH 4
+#define FLASH_BLOCKSIZE (256 * 1024 * BUSWIDTH)
+#define FLASH_NUMBLOCKS 16
+
+#define BUSWIDTH 4
+#define FLASH_ADDRESS IO_ADDRESS(MX1ADS_FLASH_BASE)
+
+#define FLASH_MANUFACTURER 0x002C002C
+#define FLASH_DEVICE_ID 0x00D300D3
+
+/*
+ * The size and extent of the bootloader in flash.
+ */
+#define NUM_BOOTLOADER_BLOCKS 1
+#define BOOTLOADER_START 0x00000000
+#define BOOTLOADER_LEN (NUM_BOOTLOADER_BLOCKS * FLASH_BLOCKSIZE)
+
+/*
+ * The size and extent of the kernel in flash.
+ */
+#define NUM_KERNEL_BLOCKS 1
+#define KERNEL_START (BOOTLOADER_START + BOOTLOADER_LEN)
+#define KERNEL_LEN (NUM_KERNEL_BLOCKS * FLASH_BLOCKSIZE)
+
+/* File system */
+#define NUM_FILESYSTEM_BLOCKS 14
+#define FILESYSTEM_START (KERNEL_START + KERNEL_LEN)
+#define FILESYSTEM_LEN (NUM_FILESYSTEM_BLOCKS * FLASH_BLOCKSIZE)
+
+
+/*
+ * SDRAM controller register location and values. These are very specific
+ * to the MX1.
+ */
+#define SDRAMC_REGISTER IO_ADDRESS(0x00221004)
+
+/*
+ * This the mask we use to get the start of a block from a given address.
+ */
+#define BLOCK_MASK (0xFFF00000)
+
+/*
+ * This is the A10 address line of the SyncFlash; it's used to initiate
+ * a precharge command.
+ */
+#define SYNCFLASH_A10 (0x00100000)
+
+/*
+ * SDRAM controller MODE settings.
+ */
+#define CMD_NORMAL (0x81020300) /* Normal Mode */
+#define CMD_PREC (CMD_NORMAL + 0x10000000) /* Precharge command */
+#define CMD_AUTO (CMD_NORMAL + 0x20000000) /* Auto refresh */
+#define CMD_LMR (CMD_NORMAL + 0x30000000) /* Load Mode Register */
+#define CMD_LCR (CMD_NORMAL + 0x60000000) /* LCR Command */
+#define CMD_PROGRAM (CMD_NORMAL + 0x70000000) /* SyncFlash Program */
+
+/*
+ * SyncFlash LCR Commands adjusted for the DBMX1 AHB internal address bus .
+ */
+#define LCR_READ_STATUS (0x0001C000) /* 0x70 */
+#define LCR_READ_CONFIG (0x00024000) /* 0x90 */
+#define LCR_ERASE_CONFIRM (0x00008000) /* 0x20 */
+#define LCR_ERASE_NVMODE (0x0000C000) /* 0x30 */
+#define LCR_PROG_NVMODE (0x00028000) /* 0xA0 */
+#define LCR_SR_CLEAR (0x00014000) /* 0x50 */
+
+/*
+ * Status register bits
+ */
+#define SR_VPS_ERROR (1 << 8) /* Power-Up status error */
+#define SR_ISM_READY (1 << 7) /* State machine isn't busy */
+#define SR_ERASE_ERROR (1 << 5) /* Erase/Unprotect error */
+#define SR_PROGRAM_ERROR (1 << 4) /* Program/Protect error */
+#define SR_DEVICE_PROTECTED (1 << 3) /* Device is protected */
+#define SR_ISM_STATUS_H (1 << 2) /* Bank ISM status, high bit */
+#define SR_ISM_STATUS_L (1 << 1) /* Bank ISM status, low bit */
+#define SR_DEVICE_ISM_STATUS (1 << 0) /* ISM is device-level */
+
+#define SR_ERROR (SR_VPS_ERROR|SR_ERASE_ERROR|SR_PROGRAM_ERROR|SR_DEVICE_PROTECTED)
+
+#define STATUS_VALUE(a) ((a) | ((a) << 16))
+
+/*
+ * Device configuration register offsets
+ */
+#define DC_MANUFACTURER (0 * BUSWIDTH)
+#define DC_DEVICE_ID (1 * BUSWIDTH)
+#define DC_BLOCK_PROTECT (2 * BUSWIDTH)
+#define DC_DEVICE_PROTECT (3 * BUSWIDTH)
+
+#define FL_WORD(addr) (*(volatile unsigned long*)(addr))
+
+static char module_name[] = "syncflash";
+
+inline __u8 read8 (__u32 offset)
+{
+ return *(volatile __u8 *) (FLASH_ADDRESS + offset);
+}
+
+inline __u32 read32 (__u32 offset)
+{
+ return *(volatile __u32 *) (FLASH_ADDRESS + offset);
+}
+
+inline void write32 (__u32 x,__u32 offset)
+{
+ *(volatile __u32 *) (FLASH_ADDRESS + offset) = x;
+}
+
+static __u32 read_device_configuration_register(__u32 reg_number)
+{
+ __u32 tmp;
+
+ /* Setup the SDRAM controller to issue an LCR command. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_LCR;
+
+ /* Perform a read to issue the Read Device Configuration Command. */
+ tmp = read32(LCR_READ_CONFIG);
+
+ /* Return the SDRAM controller to normal mode. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_NORMAL;
+
+ /* Return the value of the specified register. */
+ tmp = read32(reg_number);
+
+ return tmp;
+}
+
+/*
+ * Get the status of the flash devices.
+ */
+static __u32 flash_read_status()
+{
+ __u32 status, tmp;
+
+ /* Enter the SyncFlash Program READ/WRITE mode. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_PROGRAM;
+
+ /* Read the status register. */
+ status = read32(LCR_READ_STATUS);
+
+ /* Clear the status register. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_LCR;
+ tmp = read32(LCR_SR_CLEAR);
+
+ /* Return to Normal mode. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_NORMAL;
+
+ return status;
+}
+
+/*
+ * Loop until both write state machines are ready.
+ */
+static __u32 flash_status_wait()
+{
+ __u32 status;
+ do {
+ status = flash_read_status();
+ } while ((status & STATUS_VALUE(SR_ISM_READY)) !=
+ STATUS_VALUE(SR_ISM_READY));
+ return status;
+}
+
+/*
+ * Loop until the Write State machine is ready, then do a full error
+ * check. Clear status and leave the flash in Read Array mode; return
+ * 0 for no error, -1 for error.
+ */
+static int flash_status_full_check()
+{
+ __u32 status;
+
+ status = flash_status_wait() & STATUS_VALUE(SR_ERROR);
+ return status ? -EIO : 0;
+}
+
+/*
+ * Return the flash to the normal mode.
+ */
+static void flash_normal_mode()
+{
+ __u32 tmp;
+
+ /* First issue a precharge all command. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_PREC;
+ tmp = read32(SYNCFLASH_A10);
+
+ /* Now place the SDRAM controller in Normal mode. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_NORMAL;
+}
+
+/*
+ * Probe for SyncFlash memory on MX1ADS board.
+ *
+ * Returns 1 if we found SyncFlash memory, 0 otherwise.
+ */
+static int flash_probe (void)
+{
+ __u32 manufacturer, device_id;
+
+ /* For some reason, the first read doesn't work, so we do it
+ * twice. */
+ manufacturer = read_device_configuration_register(DC_MANUFACTURER);
+ manufacturer = read_device_configuration_register(DC_MANUFACTURER);
+ device_id = read_device_configuration_register(DC_DEVICE_ID);
+
+ printk("SyncFlash probe: manufacturer 0x%08lx, device_id 0x%08lx\n",
+ manufacturer, device_id);
+ return (manufacturer == FLASH_MANUFACTURER &&
+ device_id == FLASH_DEVICE_ID);
+}
+
+/*
+ * Erase one block of flash memory at offset ``offset'' which is any
+ * address within the block which should be erased.
+ *
+ * Returns 0 if successful, -1 otherwise.
+ */
+static inline int erase_block (__u32 offset)
+{
+ __u32 tmp;
+
+ /* Mask off the lower bits of the address to get the first address
+ * in the flash block. */
+ offset &= (__u32)BLOCK_MASK;
+
+ /* Perform a read and precharge of the bank before the LCR|ACT|WRIT
+ * sequence to avoid the inadvertent precharge command occurring
+ * during the LCR_ACT_WRIT sequence. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_NORMAL;
+ tmp = read32(offset);
+ FL_WORD(SDRAMC_REGISTER) = CMD_PREC;
+ tmp = read32(offset);
+
+ /* Now start the actual erase. */
+
+ /* LCR|ACT|WRIT sequence */
+ FL_WORD(SDRAMC_REGISTER) = CMD_LCR;
+ write32(0, offset + LCR_ERASE_CONFIRM);
+
+ /* Return to normal mode to issue the erase confirm. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_NORMAL;
+ write32(0xD0D0D0D0, offset);
+
+ if (flash_status_full_check()) {
+ printk (KERN_WARNING "%s: erase error at address 0x%.8x.\n",
+ module_name, offset);
+ return (-1);
+ }
+
+ flash_normal_mode();
+
+ return 0;
+}
+
+static int flash_erase (struct mtd_info *mtd,struct erase_info *instr)
+{
+ __u32 addr,len;
+ int i,first;
+
+ /* sanity checks */
+ if (instr->addr + instr->len > mtd->size) return (-EINVAL);
+
+ /*
+ * check that both start and end of the requested erase are
+ * aligned with the erasesize at the appropriate addresses.
+ *
+ * skip all erase regions which are ended before the start of
+ * the requested erase. Actually, to save on the calculations,
+ * we skip to the first erase region which starts after the
+ * start of the requested erase, and then go back one.
+ */
+ for (i = 0; (i < mtd->numeraseregions) &&
+ (instr->addr >= mtd->eraseregions[i].offset); i++) ;
+ i--;
+
+ /*
+ * ok, now i is pointing at the erase region in which this
+ * erase request starts. Check the start of the requested
+ * erase range is aligned with the erase size which is in
+ * effect here.
+ */
+ if (instr->addr & (mtd->eraseregions[i].erasesize - 1))
+ return (-EINVAL);
+
+ /* Remember the erase region we start on */
+ first = i;
+
+ /*
+ * next, check that the end of the requested erase is aligned
+ * with the erase region at that address.
+ *
+ * as before, drop back one to point at the region in which
+ * the address actually falls
+ */
+ for (;
+ (i < mtd->numeraseregions) &&
+ ((instr->addr + instr->len) >= mtd->eraseregions[i].offset) ;
+ i++) ;
+ i--;
+
+ /* is the end aligned on a block boundary? */
+ if ((instr->addr + instr->len) & (mtd->eraseregions[i].erasesize - 1))
+ return (-EINVAL);
+
+ addr = instr->addr;
+ len = instr->len;
+
+ i = first;
+
+ /* now erase those blocks */
+ while (len)
+ {
+ if (erase_block (addr))
+ {
+ instr->state = MTD_ERASE_FAILED;
+ return (-EIO);
+ }
+
+ addr += mtd->eraseregions[i].erasesize;
+ len -= mtd->eraseregions[i].erasesize;
+
+ if (addr == (mtd->eraseregions[i].offset +
+ (mtd->eraseregions[i].erasesize *
+ mtd->eraseregions[i].numblocks)))
+ i++;
+ }
+
+ instr->state = MTD_ERASE_DONE;
+ if (instr->callback) instr->callback (instr);
+
+ return (0);
+}
+
+static int flash_read (struct mtd_info *mtd, loff_t from,
+ size_t len, size_t *retlen, u_char *buf)
+{
+ /* Sanity checks. */
+ if (!len) return (0);
+ if (from + len > mtd->size) return (-EINVAL);
+
+ /* Ensure that we are in normal mode. */
+ flash_normal_mode();
+
+ /* We always read len bytes. */
+ *retlen = len;
+
+ /* first, we read bytes until we reach a dword boundary */
+ if (from & (BUSWIDTH - 1))
+ {
+ int gap = BUSWIDTH - (from & (BUSWIDTH - 1));
+ while (len && gap--) *buf++ = read8(from++), len--;
+ }
+
+ /* now we read dwords until we reach a non-dword boundary */
+ while (len >= BUSWIDTH)
+ {
+ *((__u32 *) buf) = read32(from);
+
+ buf += BUSWIDTH;
+ from += BUSWIDTH;
+ len -= BUSWIDTH;
+ }
+
+ /* top up the last unaligned bytes */
+ if (len & (BUSWIDTH - 1))
+ while (len--) *buf++ = read8(from++);
+
+ return (0);
+}
+
+/*
+ * Write one dword ``x'' to flash memory at offset ``offset''. ``offset''
+ * must be 32 bits, i.e. it must be on a dword boundary.
+ *
+ * Returns 0 if successful, -1 otherwise.
+ */
+static int flash_write_dword(__u32 offset, __u32 x)
+{
+ __u32 tmp;
+
+ /* First issue a precharge all command. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_PREC;
+ tmp = read32(SYNCFLASH_A10);
+
+ /* Enter the SyncFlash programming mode. */
+ FL_WORD(SDRAMC_REGISTER) = CMD_PROGRAM;
+ write32(x, offset);
+
+ /* Wait for the write to complete. */
+ flash_status_wait();
+
+ /* Return to normal mode. */
+ flash_normal_mode();
+
+ return 0;
+}
+
+static int flash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const u_char *buf)
+{
+ __u8 tmp[4];
+ int i,n;
+
+ *retlen = 0;
+
+ /* Sanity checks */
+ if (!len) return (0);
+ if (to + len > mtd->size) return (-EINVAL);
+
+ /* First, we write a 0xFF.... padded byte until we reach a
+ * dword boundary. */
+ if (to & (BUSWIDTH - 1))
+ {
+ __u32 aligned = to & ~(BUSWIDTH - 1);
+ int gap = to - aligned;
+
+ i = n = 0;
+
+ while (gap--) tmp[i++] = 0xFF;
+ while (len && i < BUSWIDTH) tmp[i++] = buf[n++], len--;
+ while (i < BUSWIDTH) tmp[i++] = 0xFF;
+
+ if (flash_write_dword(aligned, *((__u32 *) tmp)))
+ return (-EIO);
+
+ to += n;
+ buf += n;
+ *retlen += n;
+ }
+
+ /* Now we write dwords until we reach a non-dword boundary. */
+ while (len >= BUSWIDTH)
+ {
+ if (flash_write_dword (to,*((__u32 *) buf))) return (-EIO);
+
+ to += BUSWIDTH;
+ buf += BUSWIDTH;
+ *retlen += BUSWIDTH;
+ len -= BUSWIDTH;
+ }
+
+ /* Top up the last unaligned bytes, padded with 0xFF.... */
+ if (len & (BUSWIDTH - 1))
+ {
+ i = n = 0;
+
+ while (len--) tmp[i++] = buf[n++];
+ while (i < BUSWIDTH) tmp[i++] = 0xFF;
+
+ if (flash_write_dword (to,*((__u32 *) tmp))) return (-EIO);
+
+ *retlen += n;
+ }
+
+ return flash_status_full_check();
+}
+
+
+
+#define NB_OF(x) (sizeof (x) / sizeof (x[0]))
+
+static struct mtd_info mtd;
+
+static struct mtd_erase_region_info erase_regions[] =
+{
+ /* flash blocks */
+ {
+ offset: 0x00000000,
+ erasesize: FLASH_BLOCKSIZE,
+ numblocks: FLASH_NUMBLOCKS
+ },
+};
+
+#ifdef HAVE_PARTITIONS
+static struct mtd_partition syncflash_partitions[] =
+{
+ /* bootloader */
+ {
+ name: "bootloader",
+ offset: BOOTLOADER_START,
+ size: BOOTLOADER_LEN,
+ mask_flags: 0
+ },
+ /* Kernel */
+ {
+ name: "kernel",
+ offset: KERNEL_START, /* MTDPART_OFS_APPEND */
+ size: KERNEL_LEN,
+ mask_flags: 0
+ },
+ /* file system */
+ {
+ name: "file system",
+ offset: FILESYSTEM_START, /* MTDPART_OFS_APPEND */
+ size: FILESYSTEM_LEN, /* MTDPART_SIZ_FULL */
+ mask_flags: 0
+ }
+};
+#endif
+
+int __init syncflash_init (void)
+{
+ int result;
+
+ memset (&mtd,0,sizeof (mtd));
+
+ printk ("MTD driver for Micron SyncFlash.\n");
+ printk ("%s: Probing for SyncFlash on MX1ADS...\n",module_name);
+
+ if (!flash_probe ())
+ {
+ printk (KERN_WARNING "%s: Found no SyncFlash devices\n",
+ module_name);
+ return (-ENXIO);
+ }
+
+ printk ("%s: Found a SyncFlash device.\n",module_name);
+
+ mtd.name = module_name;
+ mtd.type = MTD_NORFLASH;
+ mtd.flags = MTD_CAP_NORFLASH;
+ mtd.size = FLASH_BLOCKSIZE * FLASH_NUMBLOCKS;
+
+ mtd.erasesize = FLASH_BLOCKSIZE;
+ mtd.numeraseregions = NB_OF(erase_regions);
+ mtd.eraseregions = erase_regions;
+
+ mtd.module = THIS_MODULE;
+
+ mtd.erase = flash_erase;
+ mtd.read = flash_read;
+ mtd.write = flash_write;
+
+#ifndef HAVE_PARTITIONS
+ result = add_mtd_device(&mtd);
+#else
+ result = add_mtd_partitions(&mtd,
+ syncflash_partitions,
+ NB_OF(syncflash_partitions));
+#endif
+
+ return (result);
+}
+
+void __exit syncflash_exit (void)
+{
+#ifndef HAVE_PARTITIONS
+ del_mtd_device (&mtd);
+#else
+ del_mtd_partitions (&mtd);
+#endif
+}
+
+module_init (syncflash_init);
+module_exit (syncflash_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Jon McClintock <jonm@bluemug.com>");
+MODULE_DESCRIPTION("MTD driver for Micron MT28S4M16LC SyncFlash on MX1ADS board");
+
+
diff -urN linux-2.4.26/drivers/mtd/maps/Config.in linux-2.4.26-vrs1/drivers/mtd/maps/Config.in
--- linux-2.4.26/drivers/mtd/maps/Config.in 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/maps/Config.in 2004-01-14 21:32:26.000000000 +0000
@@ -81,10 +81,10 @@
dep_tristate ' CFI Flash device mapped on StrongARM SA11x0' CONFIG_MTD_SA1100 $CONFIG_MTD_CFI $CONFIG_ARCH_SA1100 $CONFIG_MTD_PARTITIONS
dep_tristate ' CFI Flash device mapped on DC21285 Footbridge' CONFIG_MTD_DC21285 $CONFIG_MTD_CFI $CONFIG_ARCH_FOOTBRIDGE
dep_tristate ' CFI Flash device mapped on the XScale IQ80310 board' CONFIG_MTD_IQ80310 $CONFIG_MTD_CFI $CONFIG_ARCH_IQ80310
- dep_tristate ' CFI Flash device mapped on Epxa10db' CONFIG_MTD_EPXA10DB $CONFIG_MTD_CFI $CONFIG_MTD_PARTITIONS $CONFIG_ARCH_CAMELOT
- dep_tristate ' CFI Flash device mapped on the FortuNet board' CONFIG_MTD_FORTUNET $CONFIG_MTD_CFI $CONFIG_MTD_PARTITIONS $CONFIG_SA1100_FORTUNET
+ dep_tristate ' CFI Flash device mapped on the FortuNet board' CONFIG_MTD_FORTUNET $CONFIG_MTD_CFI $CONFIG_MTD_PARTITIONS $CONFIG_ARCH_FORTUNET
+ dep_tristate ' CFI Flash device mapped on Epxa' CONFIG_MTD_EPXA $CONFIG_MTD_CFI $CONFIG_MTD_PARTITIONS $CONFIG_ARCH_CAMELOT
dep_tristate ' NV-RAM mapping AUTCPU12 board' CONFIG_MTD_AUTCPU12 $CONFIG_ARCH_AUTCPU12
- dep_tristate ' CFI Flash device mapped on EDB7312' CONFIG_MTD_EDB7312 $CONFIG_MTD_CFI
+ dep_tristate ' CFI Flash device mapped on EDB7312' CONFIG_MTD_EDB7312 $CONFIG_ARCH_EDB7212 $CONFIG_MTD_CFI
dep_tristate ' JEDEC Flash device mapped on impA7' CONFIG_MTD_IMPA7 $CONFIG_MTD_JEDECPROBE
dep_tristate ' JEDEC Flash device mapped on Ceiva/Polaroid PhotoMax Digital Picture Frame' CONFIG_MTD_CEIVA $CONFIG_MTD_JEDECPROBE $CONFIG_ARCH_CEIVA
fi
diff -urN linux-2.4.26/drivers/mtd/maps/Makefile linux-2.4.26-vrs1/drivers/mtd/maps/Makefile
--- linux-2.4.26/drivers/mtd/maps/Makefile 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/maps/Makefile 2004-01-14 21:32:26.000000000 +0000
@@ -3,11 +3,7 @@
#
# $Id: Makefile,v 1.37 2003/01/24 14:26:38 dwmw2 Exp $
-BELOW25 := $(shell echo $(PATCHLEVEL) | sed s/[1234]/y/)
-
-ifeq ($(BELOW25),y)
O_TARGET := mapslink.o
-endif
# Chip mappings
obj-$(CONFIG_MTD_CDB89712) += cdb89712.o
@@ -17,7 +13,7 @@
obj-$(CONFIG_MTD_DC21285) += dc21285.o
obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o
obj-$(CONFIG_MTD_ELAN_104NC) += elan-104nc.o
-obj-$(CONFIG_MTD_EPXA10DB) += epxa10db-flash.o
+obj-$(CONFIG_MTD_EPXA) += epxa-flash.o
obj-$(CONFIG_MTD_IQ80310) += iq80310.o
obj-$(CONFIG_MTD_L440GX) += l440gx.o
obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o
@@ -29,9 +25,9 @@
obj-$(CONFIG_MTD_OCTAGON) += octagon-5066.o
ifneq ($(CONFIG_MTD_PHYSMAP),n)
ifeq ($(CONFIG_MTD_PHYSMAP_BUSWIDTH),8)
- obj-$(CONFIG_MTD_PHYSMAP) += physmap64.o
+ obj-$(CONFIG_MTD_PHYSMAP) += physmap64.o
else
- obj-$(CONFIG_MTD_PHYSMAP) += physmap.o
+ obj-$(CONFIG_MTD_PHYSMAP) += physmap.o
endif
endif
obj-$(CONFIG_MTD_PNC2000) += pnc2000.o
@@ -39,6 +35,9 @@
obj-$(CONFIG_MTD_RPXLITE) += rpxlite.o
obj-$(CONFIG_MTD_TQM8XXL) += tqm8xxl.o
obj-$(CONFIG_MTD_SA1100) += sa1100-flash.o
+ifeq ($(CONFIG_ASSABET_NEPONSET),y)
+ obj-$(CONFIG_MTD_SA1100) += neponset-flash.o
+endif
obj-$(CONFIG_MTD_SBC_GXX) += sbc_gxx.o
obj-$(CONFIG_MTD_SC520CDP) += sc520cdp.o
obj-$(CONFIG_MTD_NETSC520) += netsc520.o
diff -urN linux-2.4.26/drivers/mtd/maps/dc21285.c linux-2.4.26-vrs1/drivers/mtd/maps/dc21285.c
--- linux-2.4.26/drivers/mtd/maps/dc21285.c 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/maps/dc21285.c 2004-04-18 21:33:22.000000000 +0100
@@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
+#include <linux/delay.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
@@ -18,9 +19,9 @@
#include <asm/io.h>
#include <asm/hardware/dec21285.h>
+#include <asm/mach-types.h>
-
-static struct mtd_info *mymtd;
+static struct mtd_info *dc21285_mtd;
__u8 dc21285_read8(struct map_info *map, unsigned long ofs)
{
@@ -44,6 +45,9 @@
void dc21285_write8(struct map_info *map, __u8 d, unsigned long adr)
{
+ if(machine_is_netwinder()) {
+ nw_en_write();
+ }
*CSR_ROMWRITEREG = adr & 3;
adr &= ~3;
*(__u8*)(map->map_priv_1 + adr) = d;
@@ -51,6 +55,9 @@
void dc21285_write16(struct map_info *map, __u16 d, unsigned long adr)
{
+ if(machine_is_netwinder()) {
+ nw_en_write();
+ }
*CSR_ROMWRITEREG = adr & 3;
adr &= ~3;
*(__u16*)(map->map_priv_1 + adr) = d;
@@ -58,6 +65,9 @@
void dc21285_write32(struct map_info *map, __u32 d, unsigned long adr)
{
+ if(machine_is_netwinder()) {
+ nw_en_write();
+ }
*(__u32*)(map->map_priv_1 + adr) = d;
}
@@ -105,6 +115,27 @@
};
+static void
+nw_en_write(void) {
+#ifdef CONFIG_ARCH_NETWINDER
+ extern spinlock_t gpio_lock;
+ unsigned long flags;
+
+ /*
+ * we want to write a bit pattern XXX1 to Xilinx to enable
+ * the write gate, which will be open for about the next 2ms.
+ */
+ spin_lock_irqsave(&gpio_lock, flags);
+ cpld_modify(1, 1);
+ spin_unlock_irqrestore(&gpio_lock, flags);
+
+ /*
+ * let the ISA bus to catch on...
+ */
+ udelay(25);
+#endif
+}
+
/* Partition stuff */
static struct mtd_partition *dc21285_parts;
@@ -112,6 +143,9 @@
int __init init_dc21285(void)
{
+ int nr_parts = 0;
+ char *part_type = "none";
+
/* Determine buswidth */
switch (*CSR_SA110_CNTL & (3<<14)) {
case SA110_CNTL_ROMWIDTH_8:
@@ -137,24 +171,64 @@
return -EIO;
}
- mymtd = do_map_probe("cfi_probe", &dc21285_map);
- if (mymtd) {
- int nrparts = 0;
+ if(machine_is_ebsa285()) {
+ dc21285_mtd = do_map_probe("cfi_probe", &dc21285_map);
+ } else {
+ dc21285_mtd = do_map_probe("jedec_probe", &dc21285_map);
+ }
- mymtd->module = THIS_MODULE;
+ if (!dc21285_mtd) {
+ /* no recognised device so unmap and exit */
+ iounmap((void *)dc21285_map.map_priv_1);
+ return -ENXIO;
+ }
- /* partition fixup */
+ dc21285_mtd->module = THIS_MODULE;
+ /*
+ * Dynamic partition selection stuff (might override the static ones)
+ */
#ifdef CONFIG_MTD_REDBOOT_PARTS
- nrparts = parse_redboot_partitions(mymtd, &dc21285_parts);
+ if (nr_parts == 0) {
+ int ret = parse_redboot_partitions(dc21285_mtd, &dc21285_parts);
+
+ if (ret > 0) {
+ part_type = "RedBoot";
+ nr_parts = ret;
+ }
+ else
+ {
+ dc21285_parts=NULL; /* ensure partition table remains clear */
+ }
+ }
#endif
- if (nrparts > 0) {
- add_mtd_partitions(mymtd, dc21285_parts, nrparts);
- } else if (nrparts == 0) {
- printk(KERN_NOTICE "RedBoot partition table failed\n");
- add_mtd_device(mymtd);
+#ifdef CONFIG_MTD_CMDLINE_PARTS
+ if (nr_parts == 0) {
+ int ret = parse_cmdline_partitions(dc21285_mtd, &dc21285_parts, "sa1100");
+ if (ret > 0) {
+ part_type = "Command Line";
+ nr_parts = ret;
}
+ else
+ {
+ dc21285_parts=NULL; /* ensure partition table remains clear */
+ }
+ }
+#endif
+ if (nr_parts == 0) {
+ printk(KERN_NOTICE "DC21285 Flash: no partition info available, registering whole flash at once\n");
+ add_mtd_device(dc21285_mtd);
+ }
+#ifdef CONFIG_MTD_PARTITIONS
+ else
+ {
+ printk(KERN_NOTICE "DC21285 Flash: Using %s partition definition\n", part_type);
+ add_mtd_partitions(dc21285_mtd, &dc21285_parts, nr_parts);
+ }
+#endif
+
+ if(machine_is_ebsa285()) {
/*
* Flash timing is determined with bits 19-16 of the
* CSR_SA110_CNTL. The value is the number of wait cycles, or
@@ -167,20 +241,15 @@
*CSR_SA110_CNTL = ((*CSR_SA110_CNTL & ~0x00f00000) | (7 << 20));
/* tristate time */
*CSR_SA110_CNTL = ((*CSR_SA110_CNTL & ~0x0f000000) | (7 << 24));
-
- return 0;
}
-
- iounmap((void *)dc21285_map.map_priv_1);
- return -ENXIO;
}
static void __exit cleanup_dc21285(void)
{
- if (mymtd) {
- del_mtd_device(mymtd);
- map_destroy(mymtd);
- mymtd = NULL;
+ if (dc21285_mtd) {
+ del_mtd_device(dc21285_mtd);
+ map_destroy(dc21285_mtd);
+ dc21285_mtd = NULL;
}
if (dc21285_map.map_priv_1) {
iounmap((void *)dc21285_map.map_priv_1);
diff -urN linux-2.4.26/drivers/mtd/maps/epxa-flash.c linux-2.4.26-vrs1/drivers/mtd/maps/epxa-flash.c
--- linux-2.4.26/drivers/mtd/maps/epxa-flash.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/maps/epxa-flash.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,234 @@
+/*
+ * Flash memory access on EPXA based devices
+ *
+ * (C) 2000 Nicolas Pitre <nico@cam.org>
+ * Copyright (C) 2001 Altera Corporation
+ * Copyright (C) 2001 Red Hat, Inc.
+ *
+ * $Id: epxa10db-flash.c,v 1.4 2002/08/22 10:46:19 cdavies Exp $
+ *
+ * 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
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <asm/io.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/hardware.h>
+#ifdef CONFIG_EPXA10DB
+#define BOARD_NAME "EPXA10DB"
+#else
+#define BOARD_NAME "EPXA1DB"
+#endif
+
+static int nr_parts = 0;
+static struct mtd_partition *parts;
+
+static struct mtd_info *mymtd;
+
+extern int parse_redboot_partitions(struct mtd_info *, struct mtd_partition **);
+static int epxa_default_partitions(struct mtd_info *master, struct mtd_partition **pparts);
+
+static __u8 epxa_read8(struct map_info *map, unsigned long ofs)
+{
+ return __raw_readb(map->map_priv_1 + ofs);
+}
+
+static __u16 epxa_read16(struct map_info *map, unsigned long ofs)
+{
+ return __raw_readw(map->map_priv_1 + ofs);
+}
+
+static __u32 epxa_read32(struct map_info *map, unsigned long ofs)
+{
+ return __raw_readl(map->map_priv_1 + ofs);
+}
+
+static void epxa_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+{
+ memcpy_fromio(to, map->map_priv_1 + from, len);
+}
+
+static void epxa_write8(struct map_info *map, __u8 d, unsigned long adr)
+{
+ __raw_writeb(d, map->map_priv_1 + adr);
+ mb();
+}
+
+static void epxa_write16(struct map_info *map, __u16 d, unsigned long adr)
+{
+ __raw_writew(d, map->map_priv_1 + adr);
+ mb();
+}
+
+static void epxa_write32(struct map_info *map, __u32 d, unsigned long adr)
+{
+ __raw_writel(d, map->map_priv_1 + adr);
+ mb();
+}
+
+static void epxa_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
+{
+ memcpy_toio(map->map_priv_1 + to, from, len);
+}
+
+static struct map_info epxa_map = {
+ .name = "EPXA flash",
+ .size = FLASH_SIZE,
+ .buswidth = 2,
+ .read8 = epxa_read8,
+ .read16 = epxa_read16,
+ .read32 = epxa_read32,
+ .copy_from = epxa_copy_from,
+ .write8 = epxa_write8,
+ .write16 = epxa_write16,
+ .write32 = epxa_write32,
+ .copy_to = epxa_copy_to
+};
+
+static int __init epxa_mtd_init(void)
+{
+ int i;
+
+ printk(KERN_NOTICE "%s flash device: %x at %x\n", BOARD_NAME, FLASH_SIZE, FLASH_START);
+ epxa_map.map_priv_1 = (unsigned long)ioremap_nocache(FLASH_START, FLASH_SIZE);
+ if (!epxa_map.map_priv_1) {
+ printk("Failed to ioremap %s flash\n",BOARD_NAME);
+ return -EIO;
+ }
+
+ mymtd = do_map_probe("cfi_probe", &epxa_map);
+ if (!mymtd) {
+ iounmap((void *)epxa_map.map_priv_1);
+ return -ENXIO;
+ }
+
+ mymtd->module = THIS_MODULE;
+
+ /* Unlock the flash device. */
+ if(mymtd->unlock){
+ for (i=0; i<mymtd->numeraseregions;i++){
+ int j;
+ for(j=0;j<mymtd->eraseregions[i].numblocks;j++){
+ mymtd->unlock(mymtd,mymtd->eraseregions[i].offset + j * mymtd->eraseregions[i].erasesize,mymtd->eraseregions[i].erasesize);
+ }
+ }
+ }
+
+#ifdef CONFIG_MTD_REDBOOT_PARTS
+ nr_parts = parse_redboot_partitions(mymtd, &parts);
+
+ if (nr_parts > 0) {
+ add_mtd_partitions(mymtd, parts, nr_parts);
+ return 0;
+ }
+#endif
+#ifdef CONFIG_MTD_AFS_PARTS
+ nr_parts = parse_afs_partitions(mymtd, &parts);
+
+ if (nr_parts > 0) {
+ add_mtd_partitions(mymtd, parts, nr_parts);
+ return 0;
+ }
+#endif
+
+ /* No recognised partitioning schemes found - use defaults */
+ nr_parts = epxa_default_partitions(mymtd, &parts);
+ if (nr_parts > 0) {
+ add_mtd_partitions(mymtd, parts, nr_parts);
+ return 0;
+ }
+
+ /* If all else fails... */
+ add_mtd_device(mymtd);
+ return 0;
+}
+
+static void __exit epxa_mtd_cleanup(void)
+{
+ if (mymtd) {
+ if (nr_parts)
+ del_mtd_partitions(mymtd);
+ else
+ del_mtd_device(mymtd);
+ map_destroy(mymtd);
+ }
+ if (epxa_map.map_priv_1) {
+ iounmap((void *)epxa_map.map_priv_1);
+ epxa_map.map_priv_1 = 0;
+ }
+}
+
+
+/*
+ * This will do for now, once we decide which bootldr we're finally
+ * going to use then we'll remove this function and do it properly
+ *
+ * Partions are currently (as offsets from base of flash):
+ * 0x00000000 - 0x003FFFFF - bootloader (!)
+ * 0x00400000 - 0x00FFFFFF - Flashdisk
+ */
+
+static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_partition **pparts)
+{
+ struct mtd_partition *parts;
+ int ret;
+ int npartitions = 0;
+ char *names;
+ const char *name = "jffs";
+
+ printk("Using default partitions for %s\n",BOARD_NAME);
+ npartitions=1;
+ parts = kmalloc(npartitions*sizeof(*parts)+strlen(name)+1, GFP_KERNEL);
+ if (!parts) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ memzero(parts,npartitions*sizeof(*parts)+strlen(name));
+
+ names = (char *)&parts[npartitions];
+ parts[0].name = names;
+ names += strlen(name) + 1;
+ strcpy(parts[0].name, name);
+
+#ifdef CONFIG_EPXA10DB_R2
+ parts[0].size = FLASH_SIZE-0x00400000;
+ parts[0].offset = 0x00400000;
+#elif defined CONFIG_EPXA10DB_R3
+ parts[0].size = 0x00800000;
+ parts[0].offset = 0x00800000;
+#else
+ parts[0].size = FLASH_SIZE-0x00180000;
+ parts[0].offset = 0x00180000;
+#endif
+ ret = npartitions;
+
+ out:
+ *pparts = parts;
+ return ret;
+}
+
+
+module_init(epxa_mtd_init);
+module_exit(epxa_mtd_cleanup);
+
+MODULE_AUTHOR("Clive Davies");
+MODULE_DESCRIPTION("Altera epxa mtd flash map");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/mtd/maps/epxa10db-flash.c linux-2.4.26-vrs1/drivers/mtd/maps/epxa10db-flash.c
--- linux-2.4.26/drivers/mtd/maps/epxa10db-flash.c 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/maps/epxa10db-flash.c 1970-01-01 01:00:00.000000000 +0100
@@ -1,233 +0,0 @@
-/*
- * Flash memory access on EPXA based devices
- *
- * (C) 2000 Nicolas Pitre <nico@cam.org>
- * Copyright (C) 2001 Altera Corporation
- * Copyright (C) 2001 Red Hat, Inc.
- *
- * $Id: epxa10db-flash.c,v 1.4 2002/08/22 10:46:19 cdavies Exp $
- *
- * 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
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <asm/io.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/map.h>
-#include <linux/mtd/partitions.h>
-
-#include <asm/hardware.h>
-#ifdef CONFIG_EPXA10DB
-#define BOARD_NAME "EPXA10DB"
-#else
-#define BOARD_NAME "EPXA1DB"
-#endif
-
-static int nr_parts = 0;
-static struct mtd_partition *parts;
-
-static struct mtd_info *mymtd;
-
-extern int parse_redboot_partitions(struct mtd_info *, struct mtd_partition **);
-static int epxa_default_partitions(struct mtd_info *master, struct mtd_partition **pparts);
-
-static __u8 epxa_read8(struct map_info *map, unsigned long ofs)
-{
- return __raw_readb(map->map_priv_1 + ofs);
-}
-
-static __u16 epxa_read16(struct map_info *map, unsigned long ofs)
-{
- return __raw_readw(map->map_priv_1 + ofs);
-}
-
-static __u32 epxa_read32(struct map_info *map, unsigned long ofs)
-{
- return __raw_readl(map->map_priv_1 + ofs);
-}
-
-static void epxa_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
-{
- memcpy_fromio(to, (void *)(map->map_priv_1 + from), len);
-}
-
-static void epxa_write8(struct map_info *map, __u8 d, unsigned long adr)
-{
- __raw_writeb(d, map->map_priv_1 + adr);
- mb();
-}
-
-static void epxa_write16(struct map_info *map, __u16 d, unsigned long adr)
-{
- __raw_writew(d, map->map_priv_1 + adr);
- mb();
-}
-
-static void epxa_write32(struct map_info *map, __u32 d, unsigned long adr)
-{
- __raw_writel(d, map->map_priv_1 + adr);
- mb();
-}
-
-static void epxa_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
-{
- memcpy_toio((void *)(map->map_priv_1 + to), from, len);
-}
-
-
-
-static struct map_info epxa_map = {
- name: "EPXA flash",
- size: FLASH_SIZE,
- buswidth: 2,
- read8: epxa_read8,
- read16: epxa_read16,
- read32: epxa_read32,
- copy_from: epxa_copy_from,
- write8: epxa_write8,
- write16: epxa_write16,
- write32: epxa_write32,
- copy_to: epxa_copy_to
-};
-
-
-static int __init epxa_mtd_init(void)
-{
- int i;
-
- printk(KERN_NOTICE "%s flash device: %x at %x\n", BOARD_NAME, FLASH_SIZE, FLASH_START);
- epxa_map.map_priv_1 = (unsigned long)ioremap(FLASH_START, FLASH_SIZE);
- if (!epxa_map.map_priv_1) {
- printk("Failed to ioremap %s flash\n",BOARD_NAME);
- return -EIO;
- }
-
- mymtd = do_map_probe("cfi_probe", &epxa_map);
- if (!mymtd) {
- iounmap((void *)epxa_map.map_priv_1);
- return -ENXIO;
- }
-
- mymtd->module = THIS_MODULE;
-
- /* Unlock the flash device. */
- if(mymtd->unlock){
- for (i=0; i<mymtd->numeraseregions;i++){
- int j;
- for(j=0;j<mymtd->eraseregions[i].numblocks;j++){
- mymtd->unlock(mymtd,mymtd->eraseregions[i].offset + j * mymtd->eraseregions[i].erasesize,mymtd->eraseregions[i].erasesize);
- }
- }
- }
-
-#ifdef CONFIG_MTD_REDBOOT_PARTS
- nr_parts = parse_redboot_partitions(mymtd, &parts);
-
- if (nr_parts > 0) {
- add_mtd_partitions(mymtd, parts, nr_parts);
- return 0;
- }
-#endif
-#ifdef CONFIG_MTD_AFS_PARTS
- nr_parts = parse_afs_partitions(mymtd, &parts);
-
- if (nr_parts > 0) {
- add_mtd_partitions(mymtd, parts, nr_parts);
- return 0;
- }
-#endif
-
- /* No recognised partitioning schemes found - use defaults */
- nr_parts = epxa_default_partitions(mymtd, &parts);
- if (nr_parts > 0) {
- add_mtd_partitions(mymtd, parts, nr_parts);
- return 0;
- }
-
- /* If all else fails... */
- add_mtd_device(mymtd);
- return 0;
-}
-
-static void __exit epxa_mtd_cleanup(void)
-{
- if (mymtd) {
- if (nr_parts)
- del_mtd_partitions(mymtd);
- else
- del_mtd_device(mymtd);
- map_destroy(mymtd);
- }
- if (epxa_map.map_priv_1) {
- iounmap((void *)epxa_map.map_priv_1);
- epxa_map.map_priv_1 = 0;
- }
-}
-
-
-/*
- * This will do for now, once we decide which bootldr we're finally
- * going to use then we'll remove this function and do it properly
- *
- * Partions are currently (as offsets from base of flash):
- * 0x00000000 - 0x003FFFFF - bootloader (!)
- * 0x00400000 - 0x00FFFFFF - Flashdisk
- */
-
-static int __init epxa_default_partitions(struct mtd_info *master, struct mtd_partition **pparts)
-{
- struct mtd_partition *parts;
- int ret, i;
- int npartitions = 0;
- char *names;
- const char *name = "jffs";
-
- printk("Using default partitions for %s\n",BOARD_NAME);
- npartitions=1;
- parts = kmalloc(npartitions*sizeof(*parts)+strlen(name), GFP_KERNEL);
- memzero(parts,npartitions*sizeof(*parts)+strlen(name));
- if (!parts) {
- ret = -ENOMEM;
- goto out;
- }
- i=0;
- names = (char *)&parts[npartitions];
- parts[i].name = names;
- names += strlen(name) + 1;
- strcpy(parts[i].name, name);
-
-#ifdef CONFIG_EPXA10DB
- parts[i].size = FLASH_SIZE-0x00400000;
- parts[i].offset = 0x00400000;
-#else
- parts[i].size = FLASH_SIZE-0x00180000;
- parts[i].offset = 0x00180000;
-#endif
-
- out:
- *pparts = parts;
- return npartitions;
-}
-
-
-module_init(epxa_mtd_init);
-module_exit(epxa_mtd_cleanup);
-
-MODULE_AUTHOR("Clive Davies");
-MODULE_DESCRIPTION("Altera epxa mtd flash map");
-MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/mtd/maps/neponset-flash.c linux-2.4.26-vrs1/drivers/mtd/maps/neponset-flash.c
--- linux-2.4.26/drivers/mtd/maps/neponset-flash.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/maps/neponset-flash.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,109 @@
+/*
+ * Flash memory access on SA11x0 based devices
+ *
+ * (C) 2000 Nicolas Pitre <nico@cam.org>
+ *
+ * $Id: neponset-flash.c,v 1.18 2001/07/14 00:59:17 thockin Exp $
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/partitions.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/arch/assabet.h>
+
+static __u8 read8(struct map_info *map, unsigned long ofs)
+{
+ return readb(map->map_priv_1 + ofs);
+}
+
+static __u16 read16(struct map_info *map, unsigned long ofs)
+{
+ return readw(map->map_priv_1 + ofs);
+}
+
+static __u32 read32(struct map_info *map, unsigned long ofs)
+{
+ return readl(map->map_priv_1 + ofs);
+}
+
+static void copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
+{
+ memcpy_fromio(to, map->map_priv_1 + from, len);
+}
+
+static void write8(struct map_info *map, __u8 d, unsigned long adr)
+{
+ writeb(d, map->map_priv_1 + adr);
+}
+
+static void write16(struct map_info *map, __u16 d, unsigned long adr)
+{
+ writew(d, map->map_priv_1 + adr);
+}
+
+static void write32(struct map_info *map, __u32 d, unsigned long adr)
+{
+ writel(d, map->map_priv_1 + adr);
+}
+
+static void copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
+{
+ memcpy_toio(map->map_priv_1 + to, from, len);
+}
+
+#define MAX_SZ (32 * 1024 * 1024)
+
+static struct map_info neponset_map = {
+ name: "Neponset",
+ size: MAX_SZ,
+ buswidth: 4,
+ read8: read8,
+ read16: read16,
+ read32: read32,
+ copy_from: copy_from,
+ write8: write8,
+ write16: write16,
+ write32: write32,
+ copy_to: copy_to,
+};
+
+extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);
+extern int parse_bootldr_partitions(struct mtd_info *master, struct mtd_partition **pparts);
+
+static struct mtd_info *neponset_mtd;
+
+int __init neponset_mtd_init(void)
+{
+ if (!machine_is_assabet() || !machine_has_neponset())
+ return -ENODEV;
+
+ neponset_map.map_priv_1 = (unsigned int)ioremap(0x08000000, MAX_SZ);
+ if (!neponset_map.map_priv_1)
+ return -ENOMEM;
+
+ neponset_mtd = do_map_probe("cfi_probe", &neponset_map);
+ if (!neponset_mtd)
+ return -ENXIO;
+ neponset_mtd->module = THIS_MODULE;
+ add_mtd_device(neponset_mtd);
+ return 0;
+}
+
+static void __exit neponset_mtd_cleanup(void)
+{
+ if (neponset_mtd)
+ map_destroy(neponset_mtd);
+ if (neponset_map.map_priv_1)
+ iounmap((void *)neponset_map.map_priv_1);
+}
+
+module_init(neponset_mtd_init);
+module_exit(neponset_mtd_cleanup);
diff -urN linux-2.4.26/drivers/mtd/maps/sa1100-flash.c linux-2.4.26-vrs1/drivers/mtd/maps/sa1100-flash.c
--- linux-2.4.26/drivers/mtd/maps/sa1100-flash.c 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/maps/sa1100-flash.c 2004-01-14 21:32:26.000000000 +0000
@@ -97,6 +97,32 @@
* entries. Thanks.
*/
+#ifdef CONFIG_SA1100_ADSAGC
+#define ADSAGC_FLASH_SIZE 0x02000000
+static struct mtd_partition adsagc_partitions[] = {
+ {
+ name: "bootROM",
+ size: 0x80000,
+ offset: 0,
+ mask_flags: MTD_WRITEABLE, /* force read-only */
+ }, {
+ name: "zImage",
+ size: 0x100000,
+ offset: MTDPART_OFS_APPEND,
+ mask_flags: MTD_WRITEABLE, /* force read-only */
+ }, {
+ name: "ramdisk.gz",
+ size: 0x300000,
+ offset: MTDPART_OFS_APPEND,
+ mask_flags: MTD_WRITEABLE, /* force read-only */
+ }, {
+ name: "User FS",
+ size: MTDPART_SIZ_FULL,
+ offset: MTDPART_OFS_APPEND,
+ }
+};
+#endif
+
#ifdef CONFIG_SA1100_ADSBITSY
#define ADSBITSY_FLASH_SIZE 0x02000000
static struct mtd_partition adsbitsy_partitions[] = {
@@ -123,6 +149,32 @@
};
#endif
+#ifdef CONFIG_SA1100_ADSBITSYPLUS
+#define ADSBITSYPLUS_FLASH_SIZE 0x02000000
+static struct mtd_partition adsbitsyplus_partitions[] = {
+ {
+ name: "bootROM",
+ size: 0x80000,
+ offset: 0,
+ mask_flags: MTD_WRITEABLE, /* force read-only */
+ }, {
+ name: "zImage",
+ size: 0x100000,
+ offset: MTDPART_OFS_APPEND,
+ mask_flags: MTD_WRITEABLE, /* force read-only */
+ }, {
+ name: "ramdisk.gz",
+ size: 0x300000,
+ offset: MTDPART_OFS_APPEND,
+ mask_flags: MTD_WRITEABLE, /* force read-only */
+ }, {
+ name: "User FS",
+ size: MTDPART_SIZ_FULL,
+ offset: MTDPART_OFS_APPEND,
+ }
+};
+#endif
+
#ifdef CONFIG_SA1100_ASSABET
/* Phase 4 Assabet has two 28F160B3 flash parts in bank 0: */
#define ASSABET4_FLASH_SIZE 0x00400000
@@ -438,7 +490,7 @@
#endif
#ifdef CONFIG_SA1100_GRAPHICSMASTER
-#define GRAPHICSMASTER_FLASH_SIZE 0x01000000
+#define GRAPHICSMASTER_FLASH_SIZE 0x02000000
static struct mtd_partition graphicsmaster_partitions[] = {
{
name: "zImage",
@@ -507,6 +559,38 @@
}
#endif
+#ifdef CONFIG_SA1100_HACKKIT
+#define HACKKIT_FLASH_SIZE 0x01000000
+static struct mtd_partition hackkit_partitions[] = {
+ {
+ name: "BLOB",
+ size: 0x00040000,
+ offset: 0x00000000,
+ mask_flags: MTD_WRITEABLE, /* force read-only */
+ }, {
+ name: "config",
+ size: 0x00040000,
+ offset: MTDPART_OFS_APPEND,
+ }, {
+ name: "kernel",
+ size: 0x00100000,
+ offset: MTDPART_OFS_APPEND,
+ }, {
+ name: "initrd",
+ size: 0x00180000,
+ offset: MTDPART_OFS_APPEND,
+ }, {
+ name: "rootfs",
+ size: 0x700000,
+ offset: MTDPART_OFS_APPEND,
+ }, {
+ name: "data",
+ size: MTDPART_SIZ_FULL,
+ offset: MTDPART_OFS_APPEND,
+ }
+};
+#endif
+
#ifdef CONFIG_SA1100_HUW_WEBPANEL
#define HUW_WEBPANEL_FLASH_SIZE 0x01000000
static struct mtd_partition huw_webpanel_partitions[] = {
@@ -555,12 +639,12 @@
offset: 0x00540000,
}, {
name: "JORNADA720 usr local",
- size: 0 /* will expand to the end of the flash */
+ size: 0, /* will expand to the end of the flash */
offset: 0x00d00000,
}
};
-static void jornada720_set_vpp(int vpp)
+static void jornada720_set_vpp(struct map_info *map, int vpp)
{
if (vpp)
PPSR |= 0x80;
@@ -571,6 +655,27 @@
#endif
+#ifdef CONFIG_SA1100_NANOENGINE
+/* nanoEngine has one 28F320B3B Flash part in bank 0: */
+#define NANOENGINE_FLASH_SIZE 0x00400000
+static struct mtd_partition nanoengine_partitions[] = {
+ {
+ name: "nanoEngine boot firmware and parameter table",
+ size: 0x00010000, /* 32K */
+ offset: 0x00000000,
+ mask_flags: MTD_WRITEABLE, /* force read-only */
+ },{
+ name: "kernel/initrd reserved",
+ size: 0x002f0000,
+ offset: 0x00010000,
+ },{
+ name: "experimental filesystem allocation",
+ size: 0x00100000,
+ offset: 0x00300000,
+ }
+};
+#endif
+
#ifdef CONFIG_SA1100_PANGOLIN
#define PANGOLIN_FLASH_SIZE 0x04000000
static struct mtd_partition pangolin_partitions[] = {
@@ -699,6 +804,32 @@
};
#endif /* CONFIG_SA1100_SIMPAD */
+#ifdef CONFIG_SA1100_SIMPUTER
+#define SIMPUTER_FLASH_SIZE 0x02000000
+static struct mtd_partition simputer_partitions[] = {
+ {
+ name: "blob+logo",
+ offset: 0,
+ size: 0x00040000
+ },
+ {
+ name: "kernel",
+ offset: MTDPART_OFS_APPEND,
+ size: 0x000C0000
+ },
+ {
+ name: "/(cramfs)",
+ offset: MTDPART_OFS_APPEND,
+ size: 0x00200000
+ },
+ {
+ name: "/usr/local(jffs2)",
+ offset: MTDPART_OFS_APPEND,
+ size: MTDPART_SIZ_FULL /* expand till the end */
+ }
+};
+#endif
+
#ifdef CONFIG_SA1100_STORK
#define STORK_FLASH_SIZE 0x02000000
static struct mtd_partition stork_partitions[] = {
@@ -766,7 +897,7 @@
#endif
extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts);
-extern int parse_bootldr_partitions(struct mtd_info *master, struct mtd_partition **pparts);
+extern int parse_cmdline_partitions(struct mtd_info *master, struct mtd_partition **pparts, char *);
static struct mtd_partition *parsed_parts;
static struct mtd_info *mymtd;
@@ -787,6 +918,14 @@
*/
part_type = "static";
+#ifdef CONFIG_SA1100_ADSAGC
+ if (machine_is_adsagc()) {
+ parts = adsagc_partitions;
+ nb_parts = ARRAY_SIZE(adsagc_partitions);
+ sa1100_map.size = ADSAGC_FLASH_SIZE;
+ sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2 : 4;
+ }
+#endif
#ifdef CONFIG_SA1100_ADSBITSY
if (machine_is_adsbitsy()) {
parts = adsbitsy_partitions;
@@ -795,6 +934,14 @@
sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2 : 4;
}
#endif
+#ifdef CONFIG_SA1100_ADSBITSYPLUS
+ if (machine_is_adsbitsyplus()) {
+ parts = adsbitsyplus_partitions;
+ nb_parts = ARRAY_SIZE(adsbitsyplus_partitions);
+ sa1100_map.size = ADSBITSYPLUS_FLASH_SIZE;
+ sa1100_map.buswidth = (MSC1 & MSC_RBW) ? 2 : 4;
+ }
+#endif
#ifdef CONFIG_SA1100_ASSABET
if (machine_is_assabet()) {
parts = assabet_partitions;
@@ -869,6 +1016,13 @@
sa1100_map.set_vpp = h3600_set_vpp;
}
#endif
+#ifdef CONFIG_SA1100_HACKKIT
+ if (machine_is_hackkit()) {
+ parts = hackkit_partitions;
+ nb_parts = ARRAY_SIZE(hackkit_partitions);
+ sa1100_map.size = HACKKIT_FLASH_SIZE;
+ }
+#endif
#ifdef CONFIG_SA1100_HUW_WEBPANEL
if (machine_is_huw_webpanel()) {
parts = huw_webpanel_partitions;
@@ -884,6 +1038,13 @@
sa1100_map.set_vpp = jornada720_set_vpp;
}
#endif
+#ifdef CONFIG_SA1100_NANOENGINE
+ if (machine_is_nanoengine()) {
+ parts = nanoengine_partitions;
+ nb_parts = ARRAY_SIZE(nanoengine_partitions);
+ sa1100_map.size = NANOENGINE_FLASH_SIZE;
+ }
+#endif
#ifdef CONFIG_SA1100_PANGOLIN
if (machine_is_pangolin()) {
parts = pangolin_partitions;
@@ -919,6 +1080,13 @@
sa1100_map.size = SIMPAD_FLASH_SIZE;
}
#endif
+#ifdef CONFIG_SA1100_SIMPUTER
+ if (machine_is_simputer()) {
+ parts = simputer_partitions;
+ nb_parts = ARRAY_SIZE(simputer_partitions);
+ sa1100_map.size = SIMPUTER_FLASH_SIZE;
+ }
+#endif
#ifdef CONFIG_SA1100_STORK
if (machine_is_stork()) {
parts = stork_partitions;
@@ -953,7 +1121,9 @@
* specific machine settings might have been set above.
*/
printk(KERN_NOTICE "SA1100 flash: probing %d-bit flash bus\n", sa1100_map.buswidth*8);
- mymtd = do_map_probe("cfi_probe", &sa1100_map);
+ mymtd = do_map_probe("jedec_probe", &sa1100_map);
+ if (!mymtd)
+ mymtd = do_map_probe("cfi_probe", &sa1100_map);
ret = -ENXIO;
if (!mymtd)
goto out_err;
diff -urN linux-2.4.26/drivers/mtd/nand/Config.in linux-2.4.26-vrs1/drivers/mtd/nand/Config.in
--- linux-2.4.26/drivers/mtd/nand/Config.in 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/mtd/nand/Config.in 2004-04-10 12:50:22.000000000 +0100
@@ -33,4 +33,8 @@
fi
fi
+if [ "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
+ dep_tristate ' SmartMedia Card on Atmel AT91RM9200' CONFIG_MTD_AT91_SMARTMEDIA $CONFIG_MTD_NAND
+fi
+
endmenu
diff -urN linux-2.4.26/drivers/net/Config.in linux-2.4.26-vrs1/drivers/net/Config.in
--- linux-2.4.26/drivers/net/Config.in 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/Config.in 2004-04-18 21:47:50.000000000 +0100
@@ -30,9 +30,15 @@
if [ "$CONFIG_ARCH_ACORN" = "y" ]; then
source drivers/acorn/net/Config.in
fi
+ if [ "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
+ tristate ' AT91RM9200 Ethernet support' CONFIG_AT91_ETHER
+ if [ "$CONFIG_AT91_ETHER" = "y" -o "$CONFIG_AT91_ETHER" = "m" ]; then
+ bool ' RMII interface? ' CONFIG_AT91_ETHER_RMII
+ fi
+ fi
fi
if [ "$CONFIG_ARCH_CAMELOT" = "y" ]; then
- tristate ' Altera Ether00 support' CONFIG_ETHER00
+ tristate ' Altera Ether00 support' CONFIG_ETHER00
fi
if [ "$CONFIG_PPC" = "y" ]; then
dep_tristate ' MACE (Power Mac ethernet) support' CONFIG_MACE $CONFIG_ALL_PPC
diff -urN linux-2.4.26/drivers/net/Makefile linux-2.4.26-vrs1/drivers/net/Makefile
--- linux-2.4.26/drivers/net/Makefile 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/Makefile 2004-04-18 21:47:50.000000000 +0100
@@ -244,6 +244,7 @@
# non-drivers/net drivers who want mii lib
obj-$(CONFIG_PCMCIA_SMC91C92) += mii.o
obj-$(CONFIG_USB_USBNET) += mii.o
+obj-$(CONFIG_AT91_ETHER) += mii.o
ifeq ($(CONFIG_ARCH_ACORN),y)
mod-subdirs += ../acorn/net
@@ -268,4 +269,3 @@
rcpci.o: $(rcpci-objs)
$(LD) -r -o $@ $(rcpci-objs)
-
diff -urN linux-2.4.26/drivers/net/am79c961a.c linux-2.4.26-vrs1/drivers/net/am79c961a.c
--- linux-2.4.26/drivers/net/am79c961a.c 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/am79c961a.c 2004-01-14 21:32:26.000000000 +0000
@@ -54,25 +54,36 @@
#ifdef __arm__
static void write_rreg(u_long base, u_int reg, u_int val)
{
- __asm__("str%?h %1, [%2] @ NET_RAP
- str%?h %0, [%2, #-4] @ NET_RDP
- " : : "r" (val), "r" (reg), "r" (ISAIO_BASE + 0x0464));
+ __asm__("str%?h %1, [%2] @ NET_RAP\n\t"
+ "str%?h %0, [%2, #-4] @ NET_RDP"
+ : : "r" (val), "r" (reg), "r" (ISAIO_BASE + 0x0464));
}
static inline unsigned short read_rreg(u_long base_addr, u_int reg)
{
unsigned short v;
- __asm__("str%?h %1, [%2] @ NET_RAP
- ldr%?h %0, [%2, #-4] @ NET_RDP
- " : "=r" (v): "r" (reg), "r" (ISAIO_BASE + 0x0464));
+ __asm__("str%?h %1, [%2] @ NET_RAP\n\t"
+ "ldr%?h %0, [%2, #-4] @ NET_RDP"
+ : "=r" (v): "r" (reg), "r" (ISAIO_BASE + 0x0464));
return v;
}
static inline void write_ireg(u_long base, u_int reg, u_int val)
{
- __asm__("str%?h %1, [%2] @ NET_RAP
- str%?h %0, [%2, #8] @ NET_IDP
- " : : "r" (val), "r" (reg), "r" (ISAIO_BASE + 0x0464));
+ __asm__("str%?h %1, [%2] @ NET_RAP\n\t"
+ "str%?h %0, [%2, #8] @ NET_IDP"
+ : : "r" (val), "r" (reg), "r" (ISAIO_BASE + 0x0464));
+}
+
+static inline unsigned short read_ireg(u_long base_addr, u_int reg)
+{
+ u_short v;
+ __asm__(
+ "str%?h %1, [%2] @ NAT_RAP\n\t"
+ "str%?h %0, [%2, #8] @ NET_IDP\n\t"
+ : "=r" (v)
+ : "r" (reg), "r" (ISAIO_BASE + 0x0464));
+ return v;
}
#define am_writeword(dev,off,val) __raw_writew(val, ISAMEM_BASE + ((off) << 1))
@@ -91,16 +102,16 @@
}
while (length > 8) {
unsigned int tmp, tmp2;
- __asm__ __volatile__("
- ldm%?ia %1!, {%2, %3}
- str%?h %2, [%0], #4
- mov%? %2, %2, lsr #16
- str%?h %2, [%0], #4
- str%?h %3, [%0], #4
- mov%? %3, %3, lsr #16
- str%?h %3, [%0], #4
- " : "=&r" (offset), "=&r" (buf), "=r" (tmp), "=r" (tmp2)
- : "0" (offset), "1" (buf));
+ __asm__ __volatile__(
+ "ldm%?ia %1!, {%2, %3}\n\t"
+ "str%?h %2, [%0], #4\n\t"
+ "mov%? %2, %2, lsr #16\n\t"
+ "str%?h %2, [%0], #4\n\t"
+ "str%?h %3, [%0], #4\n\t"
+ "mov%? %3, %3, lsr #16\n\t"
+ "str%?h %3, [%0], #4"
+ : "=&r" (offset), "=&r" (buf), "=r" (tmp), "=r" (tmp2)
+ : "0" (offset), "1" (buf));
length -= 8;
}
while (length > 0) {
@@ -118,36 +129,36 @@
length = (length + 1) & ~1;
if ((int)buf & 2) {
unsigned int tmp;
- __asm__ __volatile__("
- ldr%?h %2, [%0], #4
- str%?b %2, [%1], #1
- mov%? %2, %2, lsr #8
- str%?b %2, [%1], #1
- " : "=&r" (offset), "=&r" (buf), "=r" (tmp): "0" (offset), "1" (buf));
+ __asm__ __volatile__(
+ "ldr%?h %2, [%0], #4\n\t"
+ "str%?b %2, [%1], #1\n\t"
+ "mov%? %2, %2, lsr #8\n\t"
+ "str%?b %2, [%1], #1"
+ : "=&r" (offset), "=&r" (buf), "=r" (tmp): "0" (offset), "1" (buf));
length -= 2;
}
while (length > 8) {
unsigned int tmp, tmp2, tmp3;
- __asm__ __volatile__("
- ldr%?h %2, [%0], #4
- ldr%?h %3, [%0], #4
- orr%? %2, %2, %3, lsl #16
- ldr%?h %3, [%0], #4
- ldr%?h %4, [%0], #4
- orr%? %3, %3, %4, lsl #16
- stm%?ia %1!, {%2, %3}
- " : "=&r" (offset), "=&r" (buf), "=r" (tmp), "=r" (tmp2), "=r" (tmp3)
- : "0" (offset), "1" (buf));
+ __asm__ __volatile__(
+ "ldr%?h %2, [%0], #4\n\t"
+ "ldr%?h %3, [%0], #4\n\t"
+ "orr%? %2, %2, %3, lsl #16\n\t"
+ "ldr%?h %3, [%0], #4\n\t"
+ "ldr%?h %4, [%0], #4\n\t"
+ "orr%? %3, %3, %4, lsl #16\n\t"
+ "stm%?ia %1!, {%2, %3}"
+ : "=&r" (offset), "=&r" (buf), "=r" (tmp), "=r" (tmp2), "=r" (tmp3)
+ : "0" (offset), "1" (buf));
length -= 8;
}
while (length > 0) {
unsigned int tmp;
- __asm__ __volatile__("
- ldr%?h %2, [%0], #4
- str%?b %2, [%1], #1
- mov%? %2, %2, lsr #8
- str%?b %2, [%1], #1
- " : "=&r" (offset), "=&r" (buf), "=r" (tmp) : "0" (offset), "1" (buf));
+ __asm__ __volatile__(
+ "ldr%?h %2, [%0], #4\n\t"
+ "str%?b %2, [%1], #1\n\t"
+ "mov%? %2, %2, lsr #8\n\t"
+ "str%?b %2, [%1], #1"
+ : "=&r" (offset), "=&r" (buf), "=r" (tmp) : "0" (offset), "1" (buf));
length -= 2;
}
}
@@ -254,9 +265,27 @@
write_rreg (dev->base_addr, BASERXH, 0);
write_rreg (dev->base_addr, CSR0, CSR0_STOP);
write_rreg (dev->base_addr, CSR3, CSR3_IDONM|CSR3_BABLM|CSR3_DXSUFLO);
+ write_rreg (dev->base_addr, CSR4, CSR4_APAD_XMIT|CSR4_MFCOM|CSR4_RCVCCOM|CSR4_TXSTRTM|CSR4_JABM);
write_rreg (dev->base_addr, CSR0, CSR0_IENA|CSR0_STRT);
}
+static void am79c961_timer(unsigned long data)
+{
+ struct net_device *dev = (struct net_device *)data;
+ struct dev_priv *priv = (struct dev_priv *)dev->priv;
+ unsigned int lnkstat, carrier;
+
+ lnkstat = read_ireg(dev->base_addr, ISALED0) & ISALED0_LNKST;
+ carrier = netif_carrier_ok(dev);
+
+ if (lnkstat && !carrier)
+ netif_carrier_on(dev);
+ else if (!lnkstat && carrier)
+ netif_carrier_off(dev);
+
+ mod_timer(&priv->timer, jiffies + 5*HZ);
+}
+
/*
* Open/initialize the board.
*/
@@ -274,6 +303,11 @@
am79c961_init_for_open(dev);
+ netif_carrier_off(dev);
+
+ priv->timer.expires = jiffies;
+ add_timer(&priv->timer);
+
netif_start_queue(dev);
return 0;
@@ -288,7 +322,10 @@
struct dev_priv *priv = (struct dev_priv *)dev->priv;
unsigned long flags;
+ del_timer_sync(&priv->timer);
+
netif_stop_queue(dev);
+ netif_carrier_off(dev);
spin_lock_irqsave(priv->chip_lock, flags);
write_rreg (dev->base_addr, CSR0, CSR0_STOP);
@@ -413,15 +450,6 @@
unsigned int hdraddr, bufaddr;
unsigned int head;
unsigned long flags;
-
- /* FIXME: I thought the 79c961 could do padding - RMK ??? */
- if(length < ETH_ZLEN)
- {
- skb = skb_padto(skb, ETH_ZLEN);
- if(skb == NULL)
- return 0;
- length = ETH_ZLEN;
- }
head = priv->txhead;
hdraddr = priv->txhdr + (head << 3);
@@ -431,7 +459,7 @@
head = 0;
am_writebuffer (dev, bufaddr, skb->data, length);
- am_writeword (dev, hdraddr + 4, -length);
+ am_writeword (dev, hdraddr + 4, -skb->len);
am_writeword (dev, hdraddr + 2, TMD_OWN|TMD_STP|TMD_ENP);
priv->txhead = head;
@@ -448,6 +476,8 @@
if (am_readword(dev, priv->txhdr + (priv->txhead << 3) + 2) & TMD_OWN)
netif_stop_queue(dev);
+ priv->stats.tx_bytes += skb->len;
+
dev_kfree_skb(skb);
return 0;
@@ -520,6 +550,7 @@
am79c961_tx(struct net_device *dev, struct dev_priv *priv)
{
do {
+ signed short len;
u_int hdraddr;
u_int status;
@@ -555,6 +586,8 @@
continue;
}
priv->stats.tx_packets ++;
+ len = am_readword (dev, hdraddr + 4);
+ priv->stats.tx_bytes += -len;
} while (priv->txtail != priv->txhead);
netif_wake_queue(dev);
@@ -565,17 +598,23 @@
{
struct net_device *dev = (struct net_device *)dev_id;
struct dev_priv *priv = (struct dev_priv *)dev->priv;
- u_int status;
+ u_int status, n = 100;
- status = read_rreg(dev->base_addr, CSR0);
- write_rreg(dev->base_addr, CSR0, status & (CSR0_TINT|CSR0_RINT|CSR0_MISS|CSR0_IENA));
-
- if (status & CSR0_RINT)
- am79c961_rx(dev, priv);
- if (status & CSR0_TINT)
- am79c961_tx(dev, priv);
- if (status & CSR0_MISS)
- priv->stats.rx_dropped ++;
+ do {
+ status = read_rreg(dev->base_addr, CSR0);
+ write_rreg(dev->base_addr, CSR0, status &
+ (CSR0_IENA|CSR0_TINT|CSR0_RINT|
+ CSR0_MERR|CSR0_MISS|CSR0_CERR|CSR0_BABL));
+
+ if (status & CSR0_RINT)
+ am79c961_rx(dev, priv);
+ if (status & CSR0_TINT)
+ am79c961_tx(dev, priv);
+ if (status & CSR0_MISS)
+ priv->stats.rx_dropped ++;
+ if (status & CSR0_CERR)
+ mod_timer(&priv->timer, jiffies);
+ } while (--n && status & (CSR0_RINT | CSR0_TINT));
}
/*
@@ -587,10 +626,10 @@
{
struct dev_priv *priv = (struct dev_priv *)dev->priv;
- spin_lock_irq(priv->chip_lock);
+ spin_lock_irq(&priv->chip_lock);
write_rreg (dev->base_addr, CSR0, CSR0_STOP);
write_rreg (dev->base_addr, CSR3, CSR3_MASKALL);
- spin_unlock_irq(priv->chip_lock);
+ spin_unlock_irq(&priv->chip_lock);
am79c961_ramtest(dev, 0x66);
am79c961_ramtest(dev, 0x99);
@@ -655,6 +694,11 @@
printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]);
}
+ spin_lock_init(&priv->chip_lock);
+ init_timer(&priv->timer);
+ priv->timer.data = (unsigned long)dev;
+ priv->timer.function = am79c961_timer;
+
if (am79c961_hw_init(dev))
goto release;
diff -urN linux-2.4.26/drivers/net/am79c961a.h linux-2.4.26-vrs1/drivers/net/am79c961a.h
--- linux-2.4.26/drivers/net/am79c961a.h 2000-09-18 23:15:22.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/am79c961a.h 2004-01-14 21:32:26.000000000 +0000
@@ -58,6 +58,18 @@
#define CSR3_BABLM 0x4000
#define CSR3_MASKALL 0x5F00
+#define CSR4 4
+#define CSR4_JABM 0x0001
+#define CSR4_JAB 0x0002
+#define CSR4_TXSTRTM 0x0004
+#define CSR4_TXSTRT 0x0008
+#define CSR4_RCVCCOM 0x0010
+#define CSR4_RCVCCO 0x0020
+#define CSR4_MFCOM 0x0100
+#define CSR4_MFCO 0x0200
+#define CSR4_ASTRP_RCV 0x0400
+#define CSR4_APAD_XMIT 0x0800
+
#define CTRL1 5
#define CTRL1_SPND 0x0001
@@ -93,6 +105,8 @@
#define SIZERXR 76
#define SIZETXR 78
+#define CSR_MFC 112
+
#define RMD_ENP 0x0100
#define RMD_STP 0x0200
#define RMD_CRC 0x0800
@@ -112,6 +126,9 @@
#define TST_UFLO 0x4000
#define TST_BUFF 0x8000
+#define ISALED0 0x0004
+#define ISALED0_LNKST 0x8000
+
struct dev_priv {
struct net_device_stats stats;
unsigned long rxbuffer[RX_BUFFERS];
@@ -123,6 +140,7 @@
unsigned long rxhdr;
unsigned long txhdr;
spinlock_t chip_lock;
+ struct timer_list timer;
};
extern int am79c961_probe (struct net_device *dev);
diff -urN linux-2.4.26/drivers/net/cirrus.c linux-2.4.26-vrs1/drivers/net/cirrus.c
--- linux-2.4.26/drivers/net/cirrus.c 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/cirrus.c 2004-01-14 21:32:26.000000000 +0000
@@ -75,6 +75,7 @@
typedef struct {
struct net_device_stats stats;
u16 txlen;
+ u16 txafter; /* Default is After5 (0) */
} cirrus_t;
typedef struct {
@@ -230,13 +231,19 @@
cirrus_t *priv = (cirrus_t *) dev->priv;
u16 status;
+ /* Tx start must be done with irq disabled
+ * else status can be wrong */
+ disable_irq (dev->irq);
+
netif_stop_queue (dev);
- cirrus_write (dev,PP_TxCMD,TxStart (After5));
+ cirrus_write (dev,PP_TxCMD,TxStart (priv->txafter));
cirrus_write (dev,PP_TxLength,skb->len);
status = cirrus_read (dev,PP_BusST);
+ enable_irq (dev->irq);
+
if ((status & TxBidErr)) {
printk (KERN_WARNING "%s: Invalid frame size %d!\n",dev->name,skb->len);
priv->stats.tx_errors++;
@@ -249,7 +256,6 @@
printk (KERN_WARNING "%s: Transmit buffer not free!\n",dev->name);
priv->stats.tx_errors++;
priv->txlen = 0;
- /* FIXME: store skb and send it in interrupt handler */
return (1);
}
@@ -310,11 +316,18 @@
}
if ((RegContent (status) & TxUnderrun)) {
priv->stats.tx_errors++;
- priv->stats.tx_fifo_errors++;
+ /* Shift start tx, if underruns come too often */
+ switch (priv->stats.tx_fifo_errors++) {
+ case 3: priv->txafter = After381; break;
+ case 6: priv->txafter = After1021; break;
+ case 9: priv->txafter = AfterAll; break;
+ }
+ }
+ /* Wakeup only for tx events ! */
+ if ((RegContent (status) & (TxUnderrun | Rdy4Tx))) {
+ priv->txlen = 0;
+ netif_wake_queue (dev);
}
- /* FIXME: if Rdy4Tx, transmit last sent packet (if any) */
- priv->txlen = 0;
- netif_wake_queue (dev);
break;
case TxCOL:
@@ -428,7 +441,7 @@
else
cirrus_clear (dev,PP_RxCTL,PromiscuousA);
- if ((dev->flags & IFF_ALLMULTI) && dev->mc_list)
+ if ((dev->flags & IFF_ALLMULTI) || dev->mc_list)
cirrus_set (dev,PP_RxCTL,MulticastA);
else
cirrus_clear (dev,PP_RxCTL,MulticastA);
diff -urN linux-2.4.26/drivers/net/cs89x0.c linux-2.4.26-vrs1/drivers/net/cs89x0.c
--- linux-2.4.26/drivers/net/cs89x0.c 2003-08-25 12:44:42.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/cs89x0.c 2004-01-14 21:39:05.000000000 +0000
@@ -115,6 +115,7 @@
*/
+#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/types.h>
@@ -427,18 +428,18 @@
/* if they give us an odd I/O address, then do ONE write to
the address port, to get it back to address zero, where we
expect to find the EISA signature word. An IO with a base of 0x3
- will skip the test for the ADD_PORT. */
+ will skip the test for the ADD_PORT. */
if (ioaddr & 1) {
if (net_debug > 1)
printk(KERN_INFO "%s: odd ioaddr 0x%x\n", dev->name, ioaddr);
- if ((ioaddr & 2) != 2)
+ if ((ioaddr & 2) != 2)
if ((inw((ioaddr & ~3)+ ADD_PORT) & ADD_MASK) != ADD_SIG) {
printk(KERN_ERR "%s: bad signature 0x%x\n",
dev->name, inw((ioaddr & ~3)+ ADD_PORT));
retval = -ENODEV;
goto out2;
}
- ioaddr &= ~3;
+ ioaddr &= ~3;
outw(PP_ChipID, ioaddr + ADD_PORT);
}
printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
@@ -446,7 +447,7 @@
if (inw(ioaddr + DATA_PORT) != CHIP_EISA_ID_SIG) {
printk(KERN_ERR "%s: incorrect signature 0x%x\n",
dev->name, inw(ioaddr + DATA_PORT));
- retval = -ENODEV;
+ retval = -ENODEV;
goto out2;
}
@@ -477,7 +478,7 @@
dev->base_addr);
reset_chip(dev);
-
+
/* Here we read the current configuration of the chip. If there
is no Extended EEPROM then the idea is to not disturb the chip
configuration, it should have been correctly setup by automatic
diff -urN linux-2.4.26/drivers/net/ether00.c linux-2.4.26-vrs1/drivers/net/ether00.c
--- linux-2.4.26/drivers/net/ether00.c 2003-06-13 15:51:34.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/ether00.c 2004-01-14 21:32:26.000000000 +0000
@@ -38,6 +38,7 @@
#include <asm/arch/ether00.h>
#include <asm/arch/tdkphy.h>
+static int ether00_get_ethernet_address(struct net_device* dev);
MODULE_AUTHOR("Clive Davies");
MODULE_DESCRIPTION("Altera Ether00 IP core driver");
@@ -734,8 +735,11 @@
int result,tmp;
struct net_priv* priv;
- if (!is_valid_ether_addr(dev->dev_addr))
- return -EINVAL;
+ if (!ether00_get_ethernet_address(dev)){
+ printk("%s: Invalid ethernet MAC address. Please set using "
+ "ifconfig\n", dev->name);
+ return -EINVAL;
+ }
dev->base_addr=(unsigned int)ioremap_nocache(base,SZ_4K);
@@ -906,10 +910,9 @@
}
-static void ether00_get_ethernet_address(struct net_device* dev)
+static int ether00_get_ethernet_address(struct net_device* dev)
{
struct mtd_info *mymtd=NULL;
- int i;
size_t retlen;
/*
@@ -926,11 +929,7 @@
#ifdef CONFIG_ARCH_CAMELOT
#ifdef CONFIG_MTD
/* get the mtd_info structure for the first mtd device*/
- for(i=0;i<MAX_MTD_DEVICES;i++){
- mymtd=get_mtd_device(NULL,i);
- if(!mymtd||!strcmp(mymtd->name,"EPXA10DB flash"))
- break;
- }
+ mymtd=get_mtd_device(NULL,0);
if(!mymtd || !mymtd->read_user_prot_reg){
printk(KERN_WARNING "%s: Failed to read MAC address from flash\n",dev->name);
@@ -947,9 +946,7 @@
#endif
#endif
- if (!is_valid_ether_addr(dev->dev_addr))
- printk("%s: Invalid ethernet MAC address. Please set using "
- "ifconfig\n", dev->name);
+ return (is_valid_ether_addr(dev->dev_addr));
}
@@ -966,8 +963,6 @@
dev->tx_timeout=ether00_tx_timeout;
dev->watchdog_timeo=TX_TIMEOUT;
- ether00_get_ethernet_address(dev);
-
SET_MODULE_OWNER(dev);
return 0;
}
diff -urN linux-2.4.26/drivers/net/irda/Config.in linux-2.4.26-vrs1/drivers/net/irda/Config.in
--- linux-2.4.26/drivers/net/irda/Config.in 2004-02-27 20:03:26.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/net/irda/Config.in 2004-02-23 23:21:17.000000000 +0000
@@ -40,7 +40,7 @@
dep_tristate 'VIA IrCC (Experimental)' CONFIG_VIA_IRCC_FIR $CONFIG_IRDA
fi
if [ "$CONFIG_ARCH_SA1100" = "y" ]; then
- dep_tristate 'SA1100 Internal IR' CONFIG_SA1100_FIR $CONFIG_IRDA
+ dep_tristate 'SA1100 Internal IR' CONFIG_SA1100_FIR $CONFIG_IRDA $CONFIG_EXPERIMENTAL
fi
endmenu
diff -urN linux-2.4.26/drivers/net/irda/sa1100_ir.c linux-2.4.26-vrs1/drivers/net/irda/sa1100_ir.c
--- linux-2.4.26/drivers/net/irda/sa1100_ir.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/irda/sa1100_ir.c 2004-01-14 21:32:26.000000000 +0000
@@ -38,11 +38,7 @@
#include <asm/arch/assabet.h>
-#ifndef CONFIG_SA1100_H3600
-#define clr_h3600_egpio(x) do { } while (0)
-#define set_h3600_egpio(x) do { } while (0)
-#endif
-
+/* Yopy wants fixing */
#ifndef GPIO_IRDA_FIR
#define GPIO_IRDA_FIR (0)
#endif
@@ -174,8 +170,8 @@
if (machine_is_assabet())
ASSABET_BCR_clear(ASSABET_BCR_IRDA_FSEL);
- if (machine_is_h3600())
- clr_h3600_egpio(EGPIO_H3600_IR_FSEL);
+ if (machine_is_h3xxx())
+ clr_h3600_egpio(IPAQ_EGPIO_IR_FSEL);
if (machine_is_yopy())
PPSR &= ~GPIO_IRDA_FIR;
@@ -199,8 +195,8 @@
if (machine_is_assabet())
ASSABET_BCR_set(ASSABET_BCR_IRDA_FSEL);
- if (machine_is_h3600())
- set_h3600_egpio(EGPIO_H3600_IR_FSEL);
+ if (machine_is_h3xxx())
+ set_h3600_egpio(IPAQ_EGPIO_IR_FSEL);
if (machine_is_yopy())
PPSR |= GPIO_IRDA_FIR;
@@ -246,10 +242,7 @@
static inline int
sa1100_irda_set_power_h3600(struct sa1100_irda *si, unsigned int state)
{
- if (state)
- set_h3600_egpio(EGPIO_H3600_IR_ON);
- else
- clr_h3600_egpio(EGPIO_H3600_IR_ON);
+ assign_h3600_egpio( IPAQ_EGPIO_IR_ON, state );
return 0;
}
@@ -283,7 +276,7 @@
if (machine_is_assabet())
ret = sa1100_irda_set_power_assabet(si, state);
- if (machine_is_h3600())
+ if (machine_is_h3xxx())
ret = sa1100_irda_set_power_h3600(si, state);
if (machine_is_yopy())
ret = sa1100_irda_set_power_yopy(si, state);
@@ -727,11 +720,6 @@
netif_wake_queue(dev);
}
-/*
- * Note that we will never build up a backlog of frames; the protocol is a
- * half duplex protocol which basically means we transmit a frame, we
- * receive a frame, we transmit the next frame etc.
- */
static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct sa1100_irda *si = dev->priv;
@@ -758,6 +746,8 @@
}
if (!IS_FIR(si)) {
+ netif_stop_queue(dev);
+
si->tx_buff.data = si->tx_buff.head;
si->tx_buff.len = async_wrap_skb(skb, si->tx_buff.data,
si->tx_buff.truesize);
diff -urN linux-2.4.26/drivers/net/irda/w83977af_ir.c linux-2.4.26-vrs1/drivers/net/irda/w83977af_ir.c
--- linux-2.4.26/drivers/net/irda/w83977af_ir.c 2002-11-28 23:53:13.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/net/irda/w83977af_ir.c 2004-01-14 21:32:26.000000000 +0000
@@ -205,7 +205,7 @@
/* FIXME: The HP HDLS-1100 does not support 1152000! */
self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
- IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8);
+ IR_115200/*|IR_576000|IR_1152000|(IR_4000000 << 8)*/;
/* The HP HDLS-1100 needs 1 ms according to the specs */
self->qos.min_turn_time.bits = qos_mtt_bits;
@@ -1341,7 +1341,7 @@
case SIOCSBANDWIDTH: /* Set bandwidth */
if (!capable(CAP_NET_ADMIN)) {
ret = -EPERM;
- goto out;
+ break;
}
w83977af_change_speed(self, irq->ifr_baudrate);
break;
diff -urN linux-2.4.26/drivers/net/smc9194.c linux-2.4.26-vrs1/drivers/net/smc9194.c
--- linux-2.4.26/drivers/net/smc9194.c 2003-06-13 15:51:35.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/smc9194.c 2004-01-14 21:32:26.000000000 +0000
@@ -12,8 +12,8 @@
. AUI/TP selection ( mine has 10Base2/10BaseT select )
.
. Arguments:
- . io = for the base address
- . irq = for the IRQ
+ . io = for the base address
+ . irq = for the IRQ
. ifport = 0 for autodetect, 1 for TP, 2 for AUI ( or 10base2 )
.
. author:
@@ -51,12 +51,21 @@
. allocation
. 08/20/00 Arnaldo Melo fix kfree(skb) in smc_hardware_send_packet
. 12/15/00 Christian Jullien fix "Warning: kfree_skb on hard IRQ"
+ . 06/23/01 Russell King Separate out IO functions for different bus
+ . types.
+ . Use dev->name instead of CARDNAME for printk
+ . Add ethtool support, full duplex support
+ . Add LAN91C96 support.
. 11/08/01 Matt Domsch Use common crc32 function
----------------------------------------------------------------------------*/
+#define DRV_NAME "smc9194"
+#define DRV_VERSION "0.15"
+
static const char version[] =
- "smc9194.c:v0.14 12/15/00 by Erik Stahlman (erik@vt.edu)\n";
+ DRV_NAME ".c:v" DRV_VERSION " 12/15/00 by Erik Stahlman (erik@vt.edu)\n";
+#include <linux/config.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
@@ -69,16 +78,26 @@
#include <linux/in.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <linux/delay.h>
#include <linux/init.h>
#include <linux/crc32.h>
-#include <asm/bitops.h>
-#include <asm/io.h>
#include <linux/errno.h>
+#include <linux/ethtool.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
+#include <asm/bitops.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+
+#ifdef CONFIG_ARCH_SA1100
+#include <asm/hardware.h>
+#include <asm/arch/assabet.h>
+#endif
+
#include "smc9194.h"
/*------------------------------------------------------------------------
.
@@ -152,29 +171,27 @@
-------------------------------------------------------------------------*/
#define CARDNAME "SMC9194"
+static const char *chip_ids[15] = {
+ NULL,
+ NULL,
+ NULL,
+ "SMC91C90/91C92", /* 3 */
+ "SMC91C94/91C96", /* 4 */
+ "SMC91C95", /* 5 */
+ NULL,
+ "SMC91C100", /* 7 */
+ "SMC91C100FD", /* 8 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
-/* store this information for the driver.. */
-struct smc_local {
- /*
- these are things that the kernel wants me to keep, so users
- can find out semi-useless statistics of how well the card is
- performing
- */
- struct net_device_stats stats;
-
- /*
- If I have to wait until memory is available to send
- a packet, I will store the skbuff here, until I get the
- desired memory. Then, I'll send it out and free it.
- */
- struct sk_buff * saved_skb;
-
- /*
- . This keeps track of how many packets that I have
- . sent out. When an TX_EMPTY interrupt comes, I know
- . that all of these have been sent.
- */
- int packets_waiting;
+static const char * interfaces[2] = {
+ "TP",
+ "AUI"
};
@@ -202,6 +219,11 @@
static int smc_open(struct net_device *dev);
/*
+ . This handles the ethtool interface
+*/
+static int smc_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
+
+/*
. Our watchdog timed out. Called by the networking layer
*/
static void smc_timeout(struct net_device *dev);
@@ -217,11 +239,11 @@
. This routine allows the proc file system to query the driver's
. statistics.
*/
-static struct net_device_stats * smc_query_statistics( struct net_device *dev);
+static struct net_device_stats * smc_query_statistics(struct net_device *dev);
/*
- . Finally, a call to set promiscuous mode ( for TCPDUMP and related
- . programs ) and multicast modes.
+ . Finally, a call to set promiscuous mode (for TCPDUMP and related
+ . programs) and multicast modes.
*/
static void smc_set_multicast_list(struct net_device *dev);
@@ -240,12 +262,12 @@
. This is a separate procedure to handle the receipt of a packet, to
. leave the interrupt code looking slightly cleaner
*/
-static inline void smc_rcv( struct net_device *dev );
+static inline void smc_rcv(struct net_device *dev);
/*
. This handles a TX interrupt, which is only called when an error
. relating to a packet is sent.
*/
-static inline void smc_tx( struct net_device * dev );
+static inline void smc_tx(struct net_device * dev);
/*
------------------------------------------------------------
@@ -261,39 +283,287 @@
*/
static int smc_probe(struct net_device *dev, int ioaddr);
-/*
- . A rather simple routine to print out a packet for debugging purposes.
-*/
-#if SMC_DEBUG > 2
-static void print_packet( byte *, int );
-#endif
-
-#define tx_done(dev) 1
-
/* this is called to actually send the packet to the chip */
-static void smc_hardware_send_packet( struct net_device * dev );
+static void smc_hardware_send_packet(struct net_device * dev);
/* Since I am not sure if I will have enough room in the chip's ram
. to store the packet, I call this routine, which either sends it
. now, or generates an interrupt when the card is ready for the
. packet */
-static int smc_wait_to_send_packet( struct sk_buff * skb, struct net_device *dev );
+static int smc_wait_to_send_packet(struct sk_buff * skb, struct net_device *dev);
/* this does a soft reset on the device */
-static void smc_reset( int ioaddr );
+static void smc_reset(struct net_device *dev);
/* Enable Interrupts, Receive, and Transmit */
-static void smc_enable( int ioaddr );
+static void smc_enable(struct net_device *dev);
/* this puts the device in an inactive state */
-static void smc_shutdown( int ioaddr );
+static void smc_shutdown(struct net_device *dev);
/* This routine will find the IRQ of the driver if one is not
. specified in the input to the device. */
-static int smc_findirq( int ioaddr );
+static int smc_findirq(struct net_device *dev);
+
+#ifndef CONFIG_ASSABET_NEPONSET
+/*
+ * These functions allow us to handle IO addressing as we wish - this
+ * ethernet controller can be connected to a variety of busses. Some
+ * busses do not support 16 bit or 32 bit transfers. --rmk
+ */
+static inline u8 smc_inb(u_int base, u_int reg)
+{
+ return inb(base + reg);
+}
+
+static inline u16 smc_inw(u_int base, u_int reg)
+{
+ return inw(base + reg);
+}
+
+static inline void smc_ins(u_int base, u_int reg, u8 *data, u_int len)
+{
+ u_int port = base + reg;
+#ifdef USE_32_BIT
+ /* QUESTION: Like in the TX routine, do I want
+ to send the DWORDs or the bytes first, or some
+ mixture. A mixture might improve already slow PIO
+ performance */
+ PRINTK3((" Reading %d dwords (and %d bytes) \n",
+ len >> 2, len & 3));
+ insl(port, data, len >> 2);
+ /* read the left over bytes */
+ insb(port, data + (len & ~3), len & 3);
+#else
+ PRINTK3((" Reading %d words and %d byte(s) \n",
+ len >> 1, len & 1));
+ insw(port, data, len >> 1);
+ if (len & 1) {
+ data += len & ~1;
+ *data = inb(port);
+ }
+#endif
+}
+
+static inline void smc_outb(u8 val, u_int base, u_int reg)
+{
+ outb(val, base + reg);
+}
+
+static inline void smc_outw(u16 val, u_int base, u_int reg)
+{
+ outw(val, base + reg);
+}
+
+static inline void smc_outl(u32 val, u_int base, u_int reg)
+{
+ u_int port = base + reg;
+#ifdef USE_32_BIT
+ outl(val, port);
+#else
+ outw(val, port);
+ outw(val >> 16, port);
+#endif
+}
+
+static inline void smc_outs(u_int base, u_int reg, u8 *data, u_int len)
+{
+ u_int port = base + reg;
+#ifdef USE_32_BIT
+ if (len & 2) {
+ outsl(port, data, len >> 2);
+ outw(*((word *)(data + (len & ~3))), port);
+ }
+ else
+ outsl(port, data, len >> 2);
+#else
+ outsw(port, data, len >> 1);
+#endif
+}
+
+
+/*-------------------------------------------------------------------------
+ . I define some macros to make it easier to do somewhat common
+ . or slightly complicated, repeated tasks.
+ --------------------------------------------------------------------------*/
+
+/* select a register bank, 0 to 3 */
+
+#define SMC_SELECT_BANK(x) \
+ { \
+ smc_outw(x, ioaddr, BANK_SELECT); \
+ }
+
+/* define a small delay for the reset */
+#define SMC_DELAY() \
+ { \
+ smc_inw(ioaddr, RCR); \
+ smc_inw(ioaddr, RCR); \
+ smc_inw(ioaddr, RCR); \
+ }
+
+/* this enables an interrupt in the interrupt mask register */
+#define SMC_ENABLE_INT(x) \
+ { \
+ byte mask; \
+ mask = smc_inb(ioaddr, INT_MASK); \
+ mask |= (x); \
+ smc_outb(mask, ioaddr, INT_MASK); \
+ }
+
+/* this sets the absolutel interrupt mask */
+#define SMC_SET_INT(x) \
+ { \
+ smc_outw((x), INT_MASK); \
+ }
+
+#else
+
+#undef SMC_IO_EXTENT
+#define SMC_IO_EXTENT (16 << 2)
+
+/*
+ * These functions allow us to handle IO addressing as we wish - this
+ * ethernet controller can be connected to a variety of busses. Some
+ * busses do not support 16 bit or 32 bit transfers. --rmk
+ */
+static inline u8 smc_inb(u_int base, u_int reg)
+{
+ u_int port = base + reg * 4;
+
+ return readb(port);
+}
+
+static inline u16 smc_inw(u_int base, u_int reg)
+{
+ u_int port = base + reg * 4;
+
+ return readb(port) | readb(port + 4) << 8;
+}
+
+static inline void smc_ins(u_int base, u_int reg, u8 *data, u_int len)
+{
+ u_int port = base + reg * 4;
+
+ insb(port, data, len);
+}
+
+static inline void smc_outb(u8 val, u_int base, u_int reg)
+{
+ u_int port = base + reg * 4;
+
+ writeb(val, port);
+}
+
+static inline void smc_outw(u16 val, u_int base, u_int reg)
+{
+ u_int port = base + reg * 4;
+
+ writeb(val, port);
+ writeb(val >> 8, port + 4);
+}
+
+static inline void smc_outl(u32 val, u_int base, u_int reg)
+{
+ u_int port = base + reg * 4;
+
+ writeb(val, port);
+ writeb(val >> 8, port + 4);
+ writeb(val >> 16, port + 8);
+ writeb(val >> 24, port + 12);
+}
+
+static inline void smc_outs(u_int base, u_int reg, u8 *data, u_int len)
+{
+ u_int port = base + reg * 4;
+
+ outsb(port, data, len & ~1);
+}
+
+/*-------------------------------------------------------------------------
+ . I define some macros to make it easier to do somewhat common
+ . or slightly complicated, repeated tasks.
+ --------------------------------------------------------------------------*/
+
+/* select a register bank, 0 to 3 */
+
+#define SMC_SELECT_BANK(x) \
+ { \
+ smc_outb(x, ioaddr, BANK_SELECT); \
+ }
+
+/* define a small delay for the reset */
+#define SMC_DELAY() \
+ { \
+ smc_inb(ioaddr, RCR); \
+ smc_inb(ioaddr, RCR); \
+ smc_inb(ioaddr, RCR); \
+ }
+
+/* this enables an interrupt in the interrupt mask register */
+#define SMC_ENABLE_INT(x) \
+ { \
+ byte mask; \
+ mask = smc_inb(ioaddr, INT_MASK); \
+ mask |= (x); \
+ smc_outb(mask, ioaddr, INT_MASK); \
+ }
+
+/* this sets the absolutel interrupt mask */
+#define SMC_SET_INT(x) \
+ { \
+ smc_outb((x), ioaddr, INT_MASK); \
+ }
+
+#endif
/*
- . Function: smc_reset( int ioaddr )
+ . A rather simple routine to print out a packet for debugging purposes.
+*/
+#if SMC_DEBUG > 2
+static void print_packet(byte * buf, int length)
+{
+ int i;
+ int remainder;
+ int lines;
+
+ printk("Packet of length %d \n", length);
+ lines = length / 16;
+ remainder = length % 16;
+
+ for (i = 0; i < lines ; i ++) {
+ int cur;
+
+ for (cur = 0; cur < 8; cur ++) {
+ byte a, b;
+
+ a = *(buf ++);
+ b = *(buf ++);
+ printk("%02x%02x ", a, b);
+ }
+ printk("\n");
+ }
+ for (i = 0; i < remainder/2 ; i++) {
+ byte a, b;
+
+ a = *(buf ++);
+ b = *(buf ++);
+ printk("%02x%02x ", a, b);
+ }
+ if (remainder & 1) {
+ byte a;
+
+ a = *buf++;
+ printk("%02x", a);
+ }
+ printk("\n");
+}
+#else
+#define print_packet(buf,len) do { } while (0)
+#endif
+
+/*
+ . Function: smc_reset(struct net_device *dev)
. Purpose:
. This sets the SMC91xx chip to its normal state, hopefully from whatever
. mess that any other DOS driver has put it in.
@@ -309,36 +579,37 @@
. 5. clear all interrupts
.
*/
-static void smc_reset( int ioaddr )
+static void smc_reset(struct net_device *dev)
{
+ u_int ioaddr = dev->base_addr;
+
/* This resets the registers mostly to defaults, but doesn't
affect EEPROM. That seems unnecessary */
- SMC_SELECT_BANK( 0 );
- outw( RCR_SOFTRESET, ioaddr + RCR );
+ SMC_SELECT_BANK(0);
+ smc_outw(RCR_SOFTRESET, ioaddr, RCR);
/* this should pause enough for the chip to be happy */
- SMC_DELAY( );
+ SMC_DELAY();
/* Set the transmit and receive configuration registers to
default values */
- outw( RCR_CLEAR, ioaddr + RCR );
- outw( TCR_CLEAR, ioaddr + TCR );
+ smc_outw(RCR_CLEAR, ioaddr, RCR);
+ smc_outw(TCR_CLEAR, ioaddr, TCR);
/* set the control register to automatically
release successfully transmitted packets, to make the best
use out of our limited memory */
- SMC_SELECT_BANK( 1 );
- outw( inw( ioaddr + CONTROL ) | CTL_AUTO_RELEASE , ioaddr + CONTROL );
+ SMC_SELECT_BANK(1);
+ smc_outw(smc_inw(ioaddr, CONTROL) | CTL_AUTO_RELEASE, ioaddr, CONTROL);
/* Reset the MMU */
- SMC_SELECT_BANK( 2 );
- outw( MC_RESET, ioaddr + MMU_CMD );
+ SMC_SELECT_BANK(2);
+ smc_outw(MC_RESET, ioaddr, MMU_CMD);
/* Note: It doesn't seem that waiting for the MMU busy is needed here,
but this is a place where future chipsets _COULD_ break. Be wary
of issuing another MMU command right after this */
-
- outb( 0, ioaddr + INT_MASK );
+ SMC_SET_INT(0);
}
/*
@@ -349,20 +620,21 @@
. 2. Enable the receiver
. 3. Enable interrupts
*/
-static void smc_enable( int ioaddr )
+static void smc_enable(struct net_device *dev)
{
- SMC_SELECT_BANK( 0 );
+ u_int ioaddr = dev->base_addr;
+ SMC_SELECT_BANK(0);
/* see the header file for options in TCR/RCR NORMAL*/
- outw( TCR_NORMAL, ioaddr + TCR );
- outw( RCR_NORMAL, ioaddr + RCR );
+ smc_outw(TCR_NORMAL, ioaddr, TCR);
+ smc_outw(RCR_NORMAL, ioaddr, RCR);
/* now, enable interrupts */
- SMC_SELECT_BANK( 2 );
- outb( SMC_INTERRUPT_MASK, ioaddr + INT_MASK );
+ SMC_SELECT_BANK(2);
+ SMC_SET_INT(SMC_INTERRUPT_MASK);
}
/*
- . Function: smc_shutdown
+ . Function: smc_shutdown(struct net_device *dev)
. Purpose: closes down the SMC91xxx chip.
. Method:
. 1. zero the interrupt mask
@@ -375,26 +647,28 @@
. the manual says that it will wake up in response to any I/O requests
. in the register space. Empirical results do not show this working.
*/
-static void smc_shutdown( int ioaddr )
+static void smc_shutdown(struct net_device *dev)
{
+ u_int ioaddr = dev->base_addr;
+
/* no more interrupts for me */
- SMC_SELECT_BANK( 2 );
- outb( 0, ioaddr + INT_MASK );
+ SMC_SELECT_BANK(2);
+ SMC_SET_INT(0);
/* and tell the card to stay away from that nasty outside world */
- SMC_SELECT_BANK( 0 );
- outb( RCR_CLEAR, ioaddr + RCR );
- outb( TCR_CLEAR, ioaddr + TCR );
+ SMC_SELECT_BANK(0);
+ smc_outb(RCR_CLEAR, ioaddr, RCR);
+ smc_outb(TCR_CLEAR, ioaddr, TCR);
#if 0
/* finally, shut the chip down */
- SMC_SELECT_BANK( 1 );
- outw( inw( ioaddr + CONTROL ), CTL_POWERDOWN, ioaddr + CONTROL );
+ SMC_SELECT_BANK(1);
+ smc_outw(smc_inw(ioaddr, CONTROL), CTL_POWERDOWN, ioaddr, CONTROL);
#endif
}
/*
- . Function: smc_setmulticast( int ioaddr, int count, dev_mc_list * adds )
+ . Function: smc_setmulticast(int ioaddr, int count, dev_mc_list * adds)
. Purpose:
. This sets the internal hardware table to filter out unwanted multicast
. packets before they take up memory.
@@ -411,26 +685,28 @@
*/
-static void smc_setmulticast( int ioaddr, int count, struct dev_mc_list * addrs ) {
+static void smc_setmulticast(struct net_device *dev, int count, struct dev_mc_list * addrs)
+{
+ u_int ioaddr = dev->base_addr;
int i;
- unsigned char multicast_table[ 8 ];
+ unsigned char multicast_table[8];
struct dev_mc_list * cur_addr;
/* table for flipping the order of 3 bits */
unsigned char invert3[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
/* start with a table of all zeros: reject all */
- memset( multicast_table, 0, sizeof( multicast_table ) );
+ memset(multicast_table, 0, sizeof(multicast_table));
cur_addr = addrs;
- for ( i = 0; i < count ; i ++, cur_addr = cur_addr->next ) {
+ for (i = 0; i < count ; i ++, cur_addr = cur_addr->next) {
int position;
/* do we have a pointer here? */
- if ( !cur_addr )
+ if (!cur_addr)
break;
/* make sure this is a multicast address - shouldn't this
be a given if we have it here ? */
- if ( !( *cur_addr->dmi_addr & 1 ) )
+ if (!(*cur_addr->dmi_addr & 1))
continue;
/* only use the low order bits */
@@ -442,15 +718,15 @@
}
/* now, the table can be loaded into the chipset */
- SMC_SELECT_BANK( 3 );
+ SMC_SELECT_BANK(3);
- for ( i = 0; i < 8 ; i++ ) {
- outb( multicast_table[i], ioaddr + MULTICAST1 + i );
+ for (i = 0; i < 8 ; i++) {
+ smc_outb(multicast_table[i], ioaddr, MULTICAST1 + i);
}
}
/*
- . Function: smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * )
+ . Function: smc_wait_to_send_packet(struct sk_buff * skb, struct net_device *)
. Purpose:
. Attempt to allocate memory for a packet, if chip-memory is not
. available, then tell the card to generate an interrupt when it
@@ -465,10 +741,10 @@
. o (NO): Enable interrupts and let the interrupt handler deal with it.
. o (YES):Send it now.
*/
-static int smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * dev )
+static int smc_wait_to_send_packet(struct sk_buff * skb, struct net_device * dev)
{
struct smc_local *lp = (struct smc_local *)dev->priv;
- unsigned short ioaddr = dev->base_addr;
+ u_int ioaddr = dev->base_addr;
word length;
unsigned short numPages;
word time_out;
@@ -477,15 +753,16 @@
/* Well, I want to send the packet.. but I don't know
if I can send it right now... */
- if ( lp->saved_skb) {
+ if (lp->saved_skb) {
/* THIS SHOULD NEVER HAPPEN. */
lp->stats.tx_aborted_errors++;
- printk(CARDNAME": Bad Craziness - sent packet while busy.\n" );
+ printk("%s: Bad Craziness - sent packet while busy.\n",
+ dev->name);
return 1;
}
length = skb->len;
-
+
if(length < ETH_ZLEN)
{
skb = skb_padto(skb, ETH_ZLEN);
@@ -497,18 +774,18 @@
length = ETH_ZLEN;
}
lp->saved_skb = skb;
-
+
/*
** The MMU wants the number of pages to be the number of 256 bytes
- ** 'pages', minus 1 ( since a packet can't ever have 0 pages :) )
+ ** 'pages', minus 1 (since a packet can't ever have 0 pages :))
**
** Pkt size for allocating is data length +6 (for additional status words,
** length and ctl!) If odd size last byte is included in this header.
*/
- numPages = ((length & 0xfffe) + 6) / 256;
+ numPages = ((length & 0xfffe) + 6) / 256;
- if (numPages > 7 ) {
- printk(CARDNAME": Far too big packet error. \n");
+ if (numPages > 7) {
+ printk("%s: Far too big packet error.\n", dev->name);
/* freeing the packet is a good thing here... but should
. any packets of this size get down here? */
dev_kfree_skb (skb);
@@ -517,12 +794,13 @@
netif_wake_queue(dev);
return 0;
}
+
/* either way, a packet is waiting now */
lp->packets_waiting++;
/* now, try to allocate the memory */
- SMC_SELECT_BANK( 2 );
- outw( MC_ALLOC | numPages, ioaddr + MMU_CMD );
+ SMC_SELECT_BANK(2);
+ smc_outw(MC_ALLOC | numPages, ioaddr, MMU_CMD);
/*
. Performance Hack
.
@@ -539,21 +817,21 @@
do {
word status;
- status = inb( ioaddr + INTERRUPT );
- if ( status & IM_ALLOC_INT ) {
+ status = smc_inb(ioaddr, INTERRUPT);
+ if (status & IM_ALLOC_INT) {
/* acknowledge the interrupt */
- outb( IM_ALLOC_INT, ioaddr + INTERRUPT );
- break;
+ smc_outb(IM_ALLOC_INT, ioaddr, INTERRUPT);
+ break;
}
- } while ( -- time_out );
+ } while (-- time_out);
- if ( !time_out ) {
+ if (!time_out) {
/* oh well, wait until the chip finds memory later */
- SMC_ENABLE_INT( IM_ALLOC_INT );
- PRINTK2((CARDNAME": memory allocation deferred. \n"));
+ SMC_ENABLE_INT(IM_ALLOC_INT);
+ PRINTK2(("%s: memory allocation deferred.\n", dev->name));
/* it's deferred, but I'll handle it later */
- return 0;
- }
+ return 0;
+ }
/* or YES! I can send the packet now.. */
smc_hardware_send_packet(dev);
netif_wake_queue(dev);
@@ -561,46 +839,46 @@
}
/*
- . Function: smc_hardware_send_packet(struct net_device * )
+ . Function: smc_hardware_send_packet(struct net_device *)
. Purpose:
. This sends the actual packet to the SMC9xxx chip.
.
. Algorithm:
. First, see if a saved_skb is available.
- . ( this should NOT be called if there is no 'saved_skb'
+ . (this should NOT be called if there is no 'saved_skb'
. Now, find the packet number that the chip allocated
. Point the data pointers at it in memory
. Set the length word in the chip's memory
. Dump the packet to chip memory
- . Check if a last byte is needed ( odd length packet )
+ . Check if a last byte is needed (odd length packet)
. if so, set the control flag right
. Tell the card to send it
. Enable the transmit interrupt, so I know if it failed
. Free the kernel data if I actually sent it.
*/
-static void smc_hardware_send_packet( struct net_device * dev )
+static void smc_hardware_send_packet(struct net_device *dev)
{
struct smc_local *lp = (struct smc_local *)dev->priv;
- byte packet_no;
- struct sk_buff * skb = lp->saved_skb;
- word length;
- unsigned short ioaddr;
- byte * buf;
-
- ioaddr = dev->base_addr;
+ struct sk_buff *skb = lp->saved_skb;
+ word length, lastword;
+ u_int ioaddr = dev->base_addr;
+ byte packet_no;
+ byte *buf;
- if ( !skb ) {
- PRINTK((CARDNAME": In XMIT with no packet to send \n"));
+ if (!skb) {
+ PRINTK(("%s: In XMIT with no packet to send\n", dev->name));
return;
}
+
length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
buf = skb->data;
/* If I get here, I _know_ there is a packet slot waiting for me */
- packet_no = inb( ioaddr + PNR_ARR + 1 );
- if ( packet_no & 0x80 ) {
+ packet_no = smc_inb(ioaddr, PNR_ARR + 1);
+ if (packet_no & 0x80) {
/* or isn't there? BAD CHIP! */
- printk(KERN_DEBUG CARDNAME": Memory allocation failed. \n");
+ printk(KERN_DEBUG "%s: Memory allocation failed.\n",
+ dev->name);
dev_kfree_skb_any(skb);
lp->saved_skb = NULL;
netif_wake_queue(dev);
@@ -608,26 +886,19 @@
}
/* we have a packet address, so tell the card to use it */
- outb( packet_no, ioaddr + PNR_ARR );
+ smc_outb(packet_no, ioaddr, PNR_ARR);
/* point to the beginning of the packet */
- outw( PTR_AUTOINC , ioaddr + POINTER );
+ smc_outw(PTR_AUTOINC, ioaddr, POINTER);
- PRINTK3((CARDNAME": Trying to xmit packet of length %x\n", length ));
-#if SMC_DEBUG > 2
- print_packet( buf, length );
-#endif
+ PRINTK3(("%s: Trying to xmit packet of length %x\n",
+ dev->name, length));
- /* send the packet length ( +6 for status, length and ctl byte )
- and the status word ( set to zeros ) */
-#ifdef USE_32_BIT
- outl( (length +6 ) << 16 , ioaddr + DATA_1 );
-#else
- outw( 0, ioaddr + DATA_1 );
- /* send the packet length ( +6 for status words, length, and ctl*/
- outb( (length+6) & 0xFF,ioaddr + DATA_1 );
- outb( (length+6) >> 8 , ioaddr + DATA_1 );
-#endif
+ print_packet(buf, length);
+
+ /* send the packet length (+6 for status, length and ctl byte)
+ and the status word (set to zeros) */
+ smc_outl((length + 6) << 16, ioaddr, DATA_1);
/* send the actual data
. I _think_ it's faster to send the longs first, and then
@@ -636,32 +907,22 @@
. a good idea to check which is optimal? But that could take
. almost as much time as is saved?
*/
-#ifdef USE_32_BIT
- if ( length & 0x2 ) {
- outsl(ioaddr + DATA_1, buf, length >> 2 );
- outw( *((word *)(buf + (length & 0xFFFFFFFC))),ioaddr +DATA_1);
- }
- else
- outsl(ioaddr + DATA_1, buf, length >> 2 );
-#else
- outsw(ioaddr + DATA_1 , buf, (length ) >> 1);
-#endif
- /* Send the last byte, if there is one. */
+ smc_outs(ioaddr, DATA_1, buf, length);
- if ( (length & 1) == 0 ) {
- outw( 0, ioaddr + DATA_1 );
- } else {
- outb( buf[length -1 ], ioaddr + DATA_1 );
- outb( 0x20, ioaddr + DATA_1);
- }
+ /* Send the last byte, if there is one. */
+ if ((length & 1) == 0)
+ lastword = 0;
+ else
+ lastword = 0x2000 | buf[length - 1];
+ smc_outw(lastword, ioaddr, DATA_1);
/* enable the interrupts */
- SMC_ENABLE_INT( (IM_TX_INT | IM_TX_EMPTY_INT) );
+ SMC_ENABLE_INT(IM_TX_INT | IM_TX_EMPTY_INT);
/* and let the chipset deal with it */
- outw( MC_ENQUEUE , ioaddr + MMU_CMD );
+ smc_outw(MC_ENQUEUE, ioaddr, MMU_CMD);
- PRINTK2((CARDNAME": Sent packet of length %d \n",length));
+ PRINTK2(("%s: Sent packet of length %d\n", dev->name, length));
lp->saved_skb = NULL;
dev_kfree_skb_any (skb);
@@ -676,7 +937,7 @@
/*-------------------------------------------------------------------------
|
- | smc_init( struct net_device * dev )
+ | smc_init(struct net_device * dev)
| Input parameters:
| dev->base_addr == 0, try to find all possible locations
| dev->base_addr == 1, return failure code
@@ -691,6 +952,65 @@
*/
int __init smc_init(struct net_device *dev)
{
+ int ret = -ENODEV;
+#if defined(CONFIG_ASSABET_NEPONSET)
+ if (machine_is_assabet() && machine_has_neponset()) {
+ unsigned int *addr;
+ unsigned char ecor;
+ unsigned long flags;
+
+ NCR_0 |= NCR_ENET_OSC_EN;
+ dev->irq = IRQ_NEPONSET_SMC9196;
+
+ /*
+ * Map the attribute space. This is overkill, but clean.
+ */
+ addr = ioremap(0x18000000 + (1 << 25), 64 * 1024 * 4);
+ if (!addr)
+ return -ENOMEM;
+
+ /*
+ * Reset the device. We must disable IRQs around this.
+ */
+ local_irq_save(flags);
+ ecor = readl(addr + ECOR) & ~ECOR_RESET;
+ writel(ecor | ECOR_RESET, addr + ECOR);
+ udelay(100);
+
+ /*
+ * The device will ignore all writes to the enable bit while
+ * reset is asserted, even if the reset bit is cleared in the
+ * same write. Must clear reset first, then enable the device.
+ */
+ writel(ecor, addr + ECOR);
+ writel(ecor | ECOR_ENABLE, addr + ECOR);
+
+ /*
+ * Force byte mode.
+ */
+ writel(readl(addr + ECSR) | ECSR_IOIS8, addr + ECSR);
+ local_irq_restore(flags);
+
+ iounmap(addr);
+
+ /*
+ * Wait for the chip to wake up.
+ */
+ mdelay(1);
+
+ /*
+ * Map the real registers.
+ */
+ addr = ioremap(0x18000000, 8 * 1024);
+ if (!addr)
+ return -ENOMEM;
+
+ ret = smc_probe(dev, (int)addr);
+ if (ret)
+ iounmap(addr);
+ }
+
+#elif defined(CONFIG_ISA)
int i;
int base_addr = dev->base_addr;
@@ -708,7 +1028,8 @@
return 0;
/* couldn't find anything */
- return -ENODEV;
+#endif
+ return ret;
}
/*----------------------------------------------------------------------
@@ -718,10 +1039,11 @@
. interrupt, so an auto-detect routine can detect it, and find the IRQ,
------------------------------------------------------------------------
*/
-int __init smc_findirq( int ioaddr )
+int __init smc_findirq(struct net_device *dev)
{
int timeout = 20;
unsigned long cookie;
+ u_int ioaddr = dev->base_addr;
/* I have to do a STI() here, because this is called from
@@ -737,26 +1059,25 @@
* when done.
*/
-
+ /* enable ALLOCation interrupts ONLY. */
SMC_SELECT_BANK(2);
- /* enable ALLOCation interrupts ONLY */
- outb( IM_ALLOC_INT, ioaddr + INT_MASK );
+ SMC_SET_INT(IM_ALLOC_INT);
/*
. Allocate 512 bytes of memory. Note that the chip was just
. reset so all the memory is available
*/
- outw( MC_ALLOC | 1, ioaddr + MMU_CMD );
+ smc_outw(MC_ALLOC | 1, ioaddr, MMU_CMD);
/*
. Wait until positive that the interrupt has been generated
*/
- while ( timeout ) {
+ while (timeout) {
byte int_status;
- int_status = inb( ioaddr + INTERRUPT );
+ int_status = smc_inb(ioaddr, INTERRUPT);
- if ( int_status & IM_ALLOC_INT )
+ if (int_status & IM_ALLOC_INT)
break; /* got the interrupt */
timeout--;
}
@@ -775,7 +1096,7 @@
SMC_DELAY();
/* and disable all interrupts again */
- outb( 0, ioaddr + INT_MASK );
+ SMC_SET_INT(0);
/* clear hardware interrupts again, because that's how it
was when I was called... */
@@ -785,8 +1106,87 @@
return probe_irq_off(cookie);
}
+static int __init smc_probe_chip(struct net_device *dev, int ioaddr)
+{
+ unsigned int temp;
+
+ /* First, see if the high byte is 0x33 */
+ temp = smc_inw(ioaddr, BANK_SELECT);
+ if ((temp & 0xFF00) != 0x3300)
+ return -ENODEV;
+
+ /* The above MIGHT indicate a device, but I need to write to further
+ test this. */
+ smc_outw(0, ioaddr, BANK_SELECT);
+ temp = smc_inw(ioaddr, BANK_SELECT);
+ if ((temp & 0xFF00) != 0x3300)
+ return -ENODEV;
+
+#ifndef CONFIG_ASSABET_NEPONSET
+ /* well, we've already written once, so hopefully another time won't
+ hurt. This time, I need to switch the bank register to bank 1,
+ so I can access the base address register */
+ SMC_SELECT_BANK(1);
+ temp = smc_inw(ioaddr, BASE);
+ if (ioaddr != (temp >> 3 & 0x3E0)) {
+ printk("%s: IOADDR %x doesn't match configuration (%x)."
+ "Probably not a SMC chip\n", dev->name,
+ ioaddr, (base_address_register >> 3) & 0x3E0);
+ /* well, the base address register didn't match. Must not have
+ been a SMC chip after all. */
+ return -ENODEV;
+ }
+#endif
+
+ return 0;
+}
+
+/*
+ . If dev->irq is 0, then the device has to be banged on to see
+ . what the IRQ is.
+ .
+ . This banging doesn't always detect the IRQ, for unknown reasons.
+ . a workaround is to reset the chip and try again.
+ .
+ . Interestingly, the DOS packet driver *SETS* the IRQ on the card to
+ . be what is requested on the command line. I don't do that, mostly
+ . because the card that I have uses a non-standard method of accessing
+ . the IRQs, and because this _should_ work in most configurations.
+ .
+ . Specifying an IRQ is done with the assumption that the user knows
+ . what (s)he is doing. No checking is done!!!!
+ .
+*/
+static int __init smc_probe_irq(struct net_device *dev)
+{
+ if (dev->irq < 2) {
+ int trials;
+
+ trials = 3;
+ while (trials--) {
+ dev->irq = smc_findirq(dev);
+ if (dev->irq)
+ break;
+ /* kick the card and try again */
+ smc_reset(dev);
+ }
+ }
+ if (dev->irq == 0) {
+ printk("%s: Couldn't autodetect your IRQ. Use irq=xx.\n",
+ dev->name);
+ return -ENODEV;
+ }
+
+ /*
+ * Some machines (eg, PCs) need to cannonicalize their IRQs.
+ */
+ dev->irq = irq_cannonicalize(dev->irq);
+
+ return 0;
+}
+
/*----------------------------------------------------------------------
- . Function: smc_probe( int ioaddr )
+ . Function: smc_probe(struct net_device *dev, int ioaddr)
.
. Purpose:
. Tests to see if a given ioaddr points to an SMC9xxx chip.
@@ -816,16 +1216,14 @@
*/
static int __init smc_probe(struct net_device *dev, int ioaddr)
{
+ struct smc_local *smc;
int i, memory, retval;
static unsigned version_printed;
- unsigned int bank;
const char *version_string;
- const char *if_string;
/* registers */
word revision_register;
- word base_address_register;
word configuration_register;
word memory_info_register;
word memory_cfg_register;
@@ -834,44 +1232,24 @@
if (!request_region(ioaddr, SMC_IO_EXTENT, dev->name))
return -EBUSY;
- /* First, see if the high byte is 0x33 */
- bank = inw( ioaddr + BANK_SELECT );
- if ( (bank & 0xFF00) != 0x3300 ) {
- retval = -ENODEV;
- goto err_out;
- }
- /* The above MIGHT indicate a device, but I need to write to further
- test this. */
- outw( 0x0, ioaddr + BANK_SELECT );
- bank = inw( ioaddr + BANK_SELECT );
- if ( (bank & 0xFF00 ) != 0x3300 ) {
- retval = -ENODEV;
- goto err_out;
- }
- /* well, we've already written once, so hopefully another time won't
- hurt. This time, I need to switch the bank register to bank 1,
- so I can access the base address register */
- SMC_SELECT_BANK(1);
- base_address_register = inw( ioaddr + BASE );
- if ( ioaddr != ( base_address_register >> 3 & 0x3E0 ) ) {
- printk(CARDNAME ": IOADDR %x doesn't match configuration (%x)."
- "Probably not a SMC chip\n",
- ioaddr, base_address_register >> 3 & 0x3E0 );
- /* well, the base address register didn't match. Must not have
- been a SMC chip after all. */
- retval = -ENODEV;
+ /*
+ * Do the basic probes.
+ */
+ retval = smc_probe_chip(dev, ioaddr);
+ if (retval)
goto err_out;
- }
/* check if the revision register is something that I recognize.
These might need to be added to later, as future revisions
could be added. */
SMC_SELECT_BANK(3);
- revision_register = inw( ioaddr + REVISION );
- if ( !chip_ids[ ( revision_register >> 4 ) & 0xF ] ) {
+ revision_register = smc_inw(ioaddr, REVISION);
+ version_string = chip_ids[(revision_register >> 4) & 15];
+ if (!version_string) {
/* I don't recognize this chip, so... */
- printk(CARDNAME ": IO %x: Unrecognized revision register:"
- " %x, Contact author. \n", ioaddr, revision_register );
+ printk("%s: IO %x: unrecognized revision register: %x, "
+ "contact author.\n", dev->name, ioaddr,
+ revision_register);
retval = -ENODEV;
goto err_out;
@@ -882,138 +1260,122 @@
against the hardware address, or do some other tests. */
if (version_printed++ == 0)
- printk("%s", version);
+ printk(KERN_INFO "%s", version);
/* fill in some of the fields */
dev->base_addr = ioaddr;
/*
- . Get the MAC address ( bank 1, regs 4 - 9 )
+ . Get the MAC address (bank 1, regs 4 - 9)
*/
- SMC_SELECT_BANK( 1 );
- for ( i = 0; i < 6; i += 2 ) {
+ SMC_SELECT_BANK(1);
+ for (i = 0; i < 6; i += 2) {
word address;
- address = inw( ioaddr + ADDR0 + i );
- dev->dev_addr[ i + 1] = address >> 8;
- dev->dev_addr[ i ] = address & 0xFF;
+ address = smc_inw(ioaddr, ADDR0 + i);
+ dev->dev_addr[i + 1] = address >> 8;
+ dev->dev_addr[i] = address & 0xFF;
}
+ if (!is_valid_ether_addr(dev->dev_addr))
+ printk("%s: Invalid ethernet MAC address. Please set using "
+ "ifconfig\n", dev->name);
+
/* get the memory information */
- SMC_SELECT_BANK( 0 );
- memory_info_register = inw( ioaddr + MIR );
- memory_cfg_register = inw( ioaddr + MCR );
- memory = ( memory_cfg_register >> 9 ) & 0x7; /* multiplier */
- memory *= 256 * ( memory_info_register & 0xFF );
+ SMC_SELECT_BANK(0);
+ memory_info_register = smc_inw(ioaddr, MIR);
+ memory_cfg_register = smc_inw(ioaddr, MCR);
+ memory = (memory_cfg_register >> 9) & 0x7; /* multiplier */
+ memory *= 256 * (memory_info_register & 0xFF);
+
+ /* now, reset the chip, and put it into a known state */
+ smc_reset(dev);
/*
- Now, I want to find out more about the chip. This is sort of
- redundant, but it's cleaner to have it in both, rather than having
- one VERY long probe procedure.
- */
- SMC_SELECT_BANK(3);
- revision_register = inw( ioaddr + REVISION );
- version_string = chip_ids[ ( revision_register >> 4 ) & 0xF ];
- if ( !version_string ) {
- /* I shouldn't get here because this call was done before.... */
- retval = -ENODEV;
+ * Ok, now that we have everything in a
+ * sane state, probe for the interrupt.
+ */
+ retval = smc_probe_irq(dev);
+ if (retval)
goto err_out;
- }
- /* is it using AUI or 10BaseT ? */
- if ( dev->if_port == 0 ) {
- SMC_SELECT_BANK(1);
- configuration_register = inw( ioaddr + CONFIG );
- if ( configuration_register & CFG_AUI_SELECT )
- dev->if_port = 2;
- else
- dev->if_port = 1;
+ /* Initialize the private structure. */
+ if (dev->priv == NULL) {
+ dev->priv = kmalloc(sizeof(struct smc_local), GFP_KERNEL);
+ if (dev->priv == NULL) {
+ retval = -ENOMEM;
+ goto err_out;
+ }
}
- if_string = interfaces[ dev->if_port - 1 ];
- /* now, reset the chip, and put it into a known state */
- smc_reset( ioaddr );
+ smc = dev->priv;
+
+ /* set the private data to zero by default */
+ memset(smc, 0, sizeof(struct smc_local));
/*
- . If dev->irq is 0, then the device has to be banged on to see
- . what the IRQ is.
- .
- . This banging doesn't always detect the IRQ, for unknown reasons.
- . a workaround is to reset the chip and try again.
- .
- . Interestingly, the DOS packet driver *SETS* the IRQ on the card to
- . be what is requested on the command line. I don't do that, mostly
- . because the card that I have uses a non-standard method of accessing
- . the IRQs, and because this _should_ work in most configurations.
- .
- . Specifying an IRQ is done with the assumption that the user knows
- . what (s)he is doing. No checking is done!!!!
- .
- */
- if ( dev->irq < 2 ) {
- int trials;
+ * Get the interface characteristics.
+ * is it using AUI or 10BaseT ?
+ */
+ switch (dev->if_port) {
+ case IF_PORT_10BASET:
+ smc->port = PORT_TP;
+ break;
+
+ case IF_PORT_AUI:
+ smc->port = PORT_AUI;
+ break;
- trials = 3;
- while ( trials-- ) {
- dev->irq = smc_findirq( ioaddr );
- if ( dev->irq )
- break;
- /* kick the card and try again */
- smc_reset( ioaddr );
+ default:
+ SMC_SELECT_BANK(1);
+ configuration_register = smc_inw(ioaddr, CONFIG);
+ if (configuration_register & CFG_AUI_SELECT) {
+ dev->if_port = IF_PORT_AUI;
+ smc->port = PORT_AUI;
+ } else {
+ dev->if_port = IF_PORT_10BASET;
+ smc->port = PORT_TP;
}
- }
- if (dev->irq == 0 ) {
- printk(CARDNAME": Couldn't autodetect your IRQ. Use irq=xx.\n");
- retval = -ENODEV;
- goto err_out;
+ break;
}
- /* now, print out the card info, in a short format.. */
+ /* all interfaces are half-duplex by default */
+ smc->duplex = DUPLEX_HALF;
- printk("%s: %s(r:%d) at %#3x IRQ:%d INTF:%s MEM:%db ", dev->name,
- version_string, revision_register & 0xF, ioaddr, dev->irq,
- if_string, memory );
+ /* now, print out the card info, in a short format.. */
+ printk("%s: %s (rev %d) at %#3x IRQ:%d INTF:%s MEM:%db ", dev->name,
+ version_string, revision_register & 15, ioaddr, dev->irq,
+ interfaces[smc->port], memory);
/*
. Print the Ethernet address
*/
printk("ADDR: ");
for (i = 0; i < 5; i++)
- printk("%2.2x:", dev->dev_addr[i] );
- printk("%2.2x \n", dev->dev_addr[5] );
-
-
- /* Initialize the private structure. */
- if (dev->priv == NULL) {
- dev->priv = kmalloc(sizeof(struct smc_local), GFP_KERNEL);
- if (dev->priv == NULL) {
- retval = -ENOMEM;
- goto err_out;
- }
- }
- /* set the private data to zero by default */
- memset(dev->priv, 0, sizeof(struct smc_local));
+ printk("%2.2x:", dev->dev_addr[i]);
+ printk("%2.2x\n", dev->dev_addr[5]);
/* Fill in the fields of the device structure with ethernet values. */
ether_setup(dev);
/* Grab the IRQ */
- retval = request_irq(dev->irq, &smc_interrupt, 0, dev->name, dev);
- if (retval) {
+ retval = request_irq(dev->irq, &smc_interrupt, 0, dev->name, dev);
+ if (retval) {
printk("%s: unable to get IRQ %d (irqval=%d).\n", dev->name,
dev->irq, retval);
kfree(dev->priv);
dev->priv = NULL;
- goto err_out;
- }
+ goto err_out;
+ }
- dev->open = smc_open;
- dev->stop = smc_close;
- dev->hard_start_xmit = smc_wait_to_send_packet;
- dev->tx_timeout = smc_timeout;
- dev->watchdog_timeo = HZ/20;
- dev->get_stats = smc_query_statistics;
- dev->set_multicast_list = smc_set_multicast_list;
+ dev->open = smc_open;
+ dev->stop = smc_close;
+ dev->hard_start_xmit = smc_wait_to_send_packet;
+ dev->tx_timeout = smc_timeout;
+ dev->watchdog_timeo = HZ/20;
+ dev->get_stats = smc_query_statistics;
+ dev->set_multicast_list = smc_set_multicast_list;
+ dev->do_ioctl = smc_ioctl;
return 0;
@@ -1022,42 +1384,43 @@
return retval;
}
-#if SMC_DEBUG > 2
-static void print_packet( byte * buf, int length )
+/*
+ * This is responsible for setting the chip appropriately
+ * for the interface type. This should only be called while
+ * the interface is up and running.
+ */
+static void smc_set_port(struct net_device *dev)
{
-#if 0
- int i;
- int remainder;
- int lines;
-
- printk("Packet of length %d \n", length );
- lines = length / 16;
- remainder = length % 16;
+ struct smc_local *smc = dev->priv;
+ u_int ioaddr = dev->base_addr;
+ u_int val;
- for ( i = 0; i < lines ; i ++ ) {
- int cur;
-
- for ( cur = 0; cur < 8; cur ++ ) {
- byte a, b;
-
- a = *(buf ++ );
- b = *(buf ++ );
- printk("%02x%02x ", a, b );
- }
- printk("\n");
+ SMC_SELECT_BANK(1);
+ val = smc_inw(ioaddr, CONFIG);
+ switch (smc->port) {
+ case PORT_TP:
+ val &= ~CFG_AUI_SELECT;
+ break;
+
+ case PORT_AUI:
+ val |= CFG_AUI_SELECT;
+ break;
}
- for ( i = 0; i < remainder/2 ; i++ ) {
- byte a, b;
+ smc_outw(val, ioaddr, CONFIG);
- a = *(buf ++ );
- b = *(buf ++ );
- printk("%02x%02x ", a, b );
+ SMC_SELECT_BANK(0);
+ val = smc_inw(ioaddr, TCR);
+ switch (smc->duplex) {
+ case DUPLEX_HALF:
+ val &= ~TCR_FDSE;
+ break;
+
+ case DUPLEX_FULL:
+ val |= TCR_FDSE;
+ break;
}
- printk("\n");
-#endif
+ smc_outw(val, ioaddr, TCR);
}
-#endif
-
/*
* Open and Initialize the board
@@ -1067,48 +1430,141 @@
*/
static int smc_open(struct net_device *dev)
{
- int ioaddr = dev->base_addr;
+ struct smc_local *smc = dev->priv;
+ u_int ioaddr = dev->base_addr;
+ int i;
- int i; /* used to set hw ethernet address */
+ /*
+ * Check that the address is valid. If its not, refuse
+ * to bring the device up. The user must specify an
+ * address using ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
+ */
+ if (!is_valid_ether_addr(dev->dev_addr))
+ return -EINVAL;
/* clear out all the junk that was put here before... */
- memset(dev->priv, 0, sizeof(struct smc_local));
+ smc->saved_skb = NULL;
+ smc->packets_waiting = 0;
/* reset the hardware */
-
- smc_reset( ioaddr );
- smc_enable( ioaddr );
+ smc_reset(dev);
+ smc_enable(dev);
/* Select which interface to use */
-
- SMC_SELECT_BANK( 1 );
- if ( dev->if_port == 1 ) {
- outw( inw( ioaddr + CONFIG ) & ~CFG_AUI_SELECT,
- ioaddr + CONFIG );
- }
- else if ( dev->if_port == 2 ) {
- outw( inw( ioaddr + CONFIG ) | CFG_AUI_SELECT,
- ioaddr + CONFIG );
- }
+ smc_set_port(dev);
/*
- According to Becker, I have to set the hardware address
+ According to Becker, I have to set the hardware address
at this point, because the (l)user can set it with an
ioctl. Easily done...
*/
- SMC_SELECT_BANK( 1 );
- for ( i = 0; i < 6; i += 2 ) {
+ SMC_SELECT_BANK(1);
+ for (i = 0; i < 6; i += 2) {
word address;
- address = dev->dev_addr[ i + 1 ] << 8 ;
- address |= dev->dev_addr[ i ];
- outw( address, ioaddr + ADDR0 + i );
+ address = dev->dev_addr[i + 1] << 8 ;
+ address |= dev->dev_addr[i];
+ smc_outw(address, ioaddr, ADDR0 + i);
}
netif_start_queue(dev);
return 0;
}
+/*
+ * This is our template. Fill the rest in at run-time
+ */
+static const struct ethtool_cmd ecmd_template = {
+ supported: SUPPORTED_10baseT_Half |
+ SUPPORTED_10baseT_Full |
+ SUPPORTED_TP |
+ SUPPORTED_AUI,
+ speed: SPEED_10,
+ autoneg: AUTONEG_DISABLE,
+ maxtxpkt: 1,
+ maxrxpkt: 1,
+ transceiver: XCVR_INTERNAL,
+};
+
+static int smc_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+ struct smc_local *smc = dev->priv;
+ u32 etcmd;
+ int ret = -EINVAL;
+
+ if (cmd != SIOCETHTOOL)
+ return -EOPNOTSUPP;
+
+ if (get_user(etcmd, (u32 *)rq->ifr_data))
+ return -EFAULT;
+
+ switch (etcmd) {
+ case ETHTOOL_GSET: {
+ struct ethtool_cmd ecmd = ecmd_template;
+
+ ecmd.cmd = etcmd;
+ ecmd.port = smc->port;
+ ecmd.duplex = smc->duplex;
+
+ ret = copy_to_user(rq->ifr_data, &ecmd, sizeof(ecmd))
+ ? -EFAULT : 0;
+ break;
+ }
+
+ case ETHTOOL_SSET: {
+ struct ethtool_cmd ecmd;
+
+ ret = -EPERM;
+ if (!capable(CAP_NET_ADMIN))
+ break;
+
+ ret = -EFAULT;
+ if (copy_from_user(&ecmd, rq->ifr_data, sizeof(ecmd)))
+ break;
+
+ /*
+ * Sanity-check the arguments.
+ */
+ ret = -EINVAL;
+ if (ecmd.autoneg != AUTONEG_DISABLE)
+ break;
+ if (ecmd.speed != SPEED_10)
+ break;
+ if (ecmd.duplex != DUPLEX_HALF && ecmd.duplex != DUPLEX_FULL)
+ break;
+ if (ecmd.port != PORT_TP && ecmd.port != PORT_AUI)
+ break;
+
+ smc->port = ecmd.port;
+ smc->duplex = ecmd.duplex;
+
+ if (netif_running(dev))
+ smc_set_port(dev);
+
+ ret = 0;
+ break;
+ }
+
+ case ETHTOOL_GDRVINFO: {
+ struct ethtool_drvinfo edrv;
+
+ memset(&edrv, 0, sizeof(edrv));
+
+ edrv.cmd = etcmd;
+ strcpy(edrv.driver, DRV_NAME);
+ strcpy(edrv.version, DRV_VERSION);
+ sprintf(edrv.bus_info, "ISA:%8.8lx:%d",
+ dev->base_addr, dev->irq);
+
+ ret = copy_to_user(rq->ifr_data, &edrv, sizeof(edrv))
+ ? -EFAULT : 0;
+ break;
+ }
+ }
+
+ return ret;
+}
+
/*--------------------------------------------------------
. Called by the kernel to send a packet out into the void
. of the net. This routine is largely based on
@@ -1120,12 +1576,10 @@
{
/* If we get here, some higher level has decided we are broken.
There should really be a "kick me" function call instead. */
- printk(KERN_WARNING CARDNAME": transmit timed out, %s?\n",
- tx_done(dev) ? "IRQ conflict" :
- "network cable problem");
+ printk(KERN_WARNING "%s: transmit timed out\n", dev->name);
/* "kick" the adaptor */
- smc_reset( dev->base_addr );
- smc_enable( dev->base_addr );
+ smc_reset(dev);
+ smc_enable(dev);
dev->trans_start = jiffies;
/* clear anything saved */
((struct smc_local *)dev->priv)->saved_skb = NULL;
@@ -1145,10 +1599,10 @@
.
---------------------------------------------------------------------*/
-static void smc_interrupt(int irq, void * dev_id, struct pt_regs * regs)
+static void smc_interrupt(int irq, void * dev_id, struct pt_regs * regs)
{
struct net_device *dev = dev_id;
- int ioaddr = dev->base_addr;
+ u_int ioaddr = dev->base_addr;
struct smc_local *lp = (struct smc_local *)dev->priv;
byte status;
@@ -1161,45 +1615,45 @@
- PRINTK3((CARDNAME": SMC interrupt started \n"));
+ PRINTK3(("%s: SMC interrupt started\n", dev->name));
- saved_bank = inw( ioaddr + BANK_SELECT );
+ saved_bank = smc_inw(ioaddr, BANK_SELECT);
SMC_SELECT_BANK(2);
- saved_pointer = inw( ioaddr + POINTER );
+ saved_pointer = smc_inw(ioaddr, POINTER);
- mask = inb( ioaddr + INT_MASK );
+ mask = smc_inb(ioaddr, INT_MASK);
/* clear all interrupts */
- outb( 0, ioaddr + INT_MASK );
+ SMC_SET_INT(0);
/* set a timeout value, so I don't stay here forever */
timeout = 4;
- PRINTK2((KERN_WARNING CARDNAME ": MASK IS %x \n", mask ));
+ PRINTK2((KERN_WARNING "%s: MASK IS %x\n", dev->name, mask));
do {
/* read the status flag, and mask it */
- status = inb( ioaddr + INTERRUPT ) & mask;
- if (!status )
+ status = smc_inb(ioaddr, INTERRUPT) & mask;
+ if (!status)
break;
- PRINTK3((KERN_WARNING CARDNAME
- ": Handling interrupt status %x \n", status ));
+ PRINTK3((KERN_WARNING "%s: handling interrupt status %x\n",
+ dev->name, status));
if (status & IM_RCV_INT) {
/* Got a packet(s). */
- PRINTK2((KERN_WARNING CARDNAME
- ": Receive Interrupt\n"));
+ PRINTK2((KERN_WARNING "%s: receive interrupt\n",
+ dev->name));
smc_rcv(dev);
- } else if (status & IM_TX_INT ) {
- PRINTK2((KERN_WARNING CARDNAME
- ": TX ERROR handled\n"));
+ } else if (status & IM_TX_INT) {
+ PRINTK2((KERN_WARNING "%s: TX ERROR handled\n",
+ dev->name));
smc_tx(dev);
- outb(IM_TX_INT, ioaddr + INTERRUPT );
- } else if (status & IM_TX_EMPTY_INT ) {
+ smc_outb(IM_TX_INT, ioaddr, INTERRUPT);
+ } else if (status & IM_TX_EMPTY_INT) {
/* update stats */
- SMC_SELECT_BANK( 0 );
- card_stats = inw( ioaddr + COUNTER );
+ SMC_SELECT_BANK(0);
+ card_stats = smc_inw(ioaddr, COUNTER);
/* single collisions */
lp->stats.collisions += card_stats & 0xF;
card_stats >>= 4;
@@ -1208,60 +1662,63 @@
/* these are for when linux supports these statistics */
- SMC_SELECT_BANK( 2 );
- PRINTK2((KERN_WARNING CARDNAME
- ": TX_BUFFER_EMPTY handled\n"));
- outb( IM_TX_EMPTY_INT, ioaddr + INTERRUPT );
+ SMC_SELECT_BANK(2);
+ PRINTK2((KERN_WARNING "%s: TX_BUFFER_EMPTY handled\n",
+ dev->name));
+ smc_outb(IM_TX_EMPTY_INT, ioaddr, INTERRUPT);
mask &= ~IM_TX_EMPTY_INT;
lp->stats.tx_packets += lp->packets_waiting;
lp->packets_waiting = 0;
- } else if (status & IM_ALLOC_INT ) {
- PRINTK2((KERN_DEBUG CARDNAME
- ": Allocation interrupt \n"));
+ } else if (status & IM_ALLOC_INT) {
+ PRINTK2((KERN_DEBUG "%s: Allocation interrupt\n",
+ dev->name));
/* clear this interrupt so it doesn't happen again */
mask &= ~IM_ALLOC_INT;
- smc_hardware_send_packet( dev );
+ smc_hardware_send_packet(dev);
/* enable xmit interrupts based on this */
- mask |= ( IM_TX_EMPTY_INT | IM_TX_INT );
+ mask |= (IM_TX_EMPTY_INT | IM_TX_INT);
/* and let the card send more packets to me */
netif_wake_queue(dev);
- PRINTK2((CARDNAME": Handoff done successfully.\n"));
- } else if (status & IM_RX_OVRN_INT ) {
+ PRINTK2(("%s: Handoff done successfully.\n",
+ dev->name));
+ } else if (status & IM_RX_OVRN_INT) {
lp->stats.rx_errors++;
lp->stats.rx_fifo_errors++;
- outb( IM_RX_OVRN_INT, ioaddr + INTERRUPT );
- } else if (status & IM_EPH_INT ) {
- PRINTK((CARDNAME ": UNSUPPORTED: EPH INTERRUPT \n"));
- } else if (status & IM_ERCV_INT ) {
- PRINTK((CARDNAME ": UNSUPPORTED: ERCV INTERRUPT \n"));
- outb( IM_ERCV_INT, ioaddr + INTERRUPT );
+ smc_outb(IM_RX_OVRN_INT, ioaddr, INTERRUPT);
+ } else if (status & IM_EPH_INT) {
+ PRINTK(("%s: UNSUPPORTED: EPH INTERRUPT\n",
+ dev->name));
+ } else if (status & IM_ERCV_INT) {
+ PRINTK(("%s: UNSUPPORTED: ERCV INTERRUPT\n",
+ dev->name));
+ smc_outb(IM_ERCV_INT, ioaddr, INTERRUPT);
}
- } while ( timeout -- );
+ } while (timeout --);
/* restore state register */
- SMC_SELECT_BANK( 2 );
- outb( mask, ioaddr + INT_MASK );
+ SMC_SELECT_BANK(2);
+ SMC_SET_INT(mask);
- PRINTK3(( KERN_WARNING CARDNAME ": MASK is now %x \n", mask ));
- outw( saved_pointer, ioaddr + POINTER );
+ PRINTK3((KERN_WARNING "%s: MASK is now %x\n", dev->name, mask));
+ smc_outw(saved_pointer, ioaddr, POINTER);
- SMC_SELECT_BANK( saved_bank );
+ SMC_SELECT_BANK(saved_bank);
- PRINTK3((CARDNAME ": Interrupt done\n"));
+ PRINTK3(("%s: Interrupt done\n", dev->name));
return;
}
/*-------------------------------------------------------------
.
- . smc_rcv - receive a packet from the card
+ . smc_rcv - receive a packet from the card
.
- . There is ( at least ) a packet waiting to be read from
+ . There is (at least) a packet waiting to be read from
. chip-memory.
.
. o Read the status
@@ -1272,55 +1729,57 @@
static void smc_rcv(struct net_device *dev)
{
struct smc_local *lp = (struct smc_local *)dev->priv;
- int ioaddr = dev->base_addr;
+ u_int ioaddr = dev->base_addr;
int packet_number;
word status;
word packet_length;
/* assume bank 2 */
- packet_number = inw( ioaddr + FIFO_PORTS );
+ packet_number = smc_inw(ioaddr, FIFO_PORTS);
- if ( packet_number & FP_RXEMPTY ) {
+ if (packet_number & FP_RXEMPTY) {
/* we got called , but nothing was on the FIFO */
- PRINTK((CARDNAME ": WARNING: smc_rcv with nothing on FIFO. \n"));
+ PRINTK(("%s: WARNING: smc_rcv with nothing on FIFO.\n",
+ dev->name));
/* don't need to restore anything */
return;
}
/* start reading from the start of the packet */
- outw( PTR_READ | PTR_RCV | PTR_AUTOINC, ioaddr + POINTER );
+ smc_outw(PTR_READ | PTR_RCV | PTR_AUTOINC, ioaddr, POINTER);
/* First two words are status and packet_length */
- status = inw( ioaddr + DATA_1 );
- packet_length = inw( ioaddr + DATA_1 );
+ status = smc_inw(ioaddr, DATA_1);
+ packet_length = smc_inw(ioaddr, DATA_1);
packet_length &= 0x07ff; /* mask off top bits */
- PRINTK2(("RCV: STATUS %4x LENGTH %4x\n", status, packet_length ));
+ PRINTK2(("RCV: STATUS %4x LENGTH %4x\n", status, packet_length));
/*
. the packet length contains 3 extra words :
. status, length, and an extra word with an odd byte .
*/
packet_length -= 6;
- if ( !(status & RS_ERRORS ) ){
+ if (!(status & RS_ERRORS)){
/* do stuff to make a new packet */
struct sk_buff * skb;
byte * data;
/* read one extra byte */
- if ( status & RS_ODDFRAME )
+ if (status & RS_ODDFRAME)
packet_length++;
/* set multicast stats */
- if ( status & RS_MULTICAST )
+ if (status & RS_MULTICAST)
lp->stats.multicast++;
- skb = dev_alloc_skb( packet_length + 5);
+ skb = dev_alloc_skb(packet_length + 5);
- if ( skb == NULL ) {
- printk(KERN_NOTICE CARDNAME ": Low memory, packet dropped.\n");
+ if (skb == NULL) {
+ printk(KERN_NOTICE "%s: Low memory, packet dropped.\n",
+ dev->name);
lp->stats.rx_dropped++;
goto done;
}
@@ -1330,36 +1789,15 @@
! in the worse case
*/
- skb_reserve( skb, 2 ); /* 16 bit alignment */
+ skb_reserve(skb, 2); /* 16 bit alignment */
skb->dev = dev;
- data = skb_put( skb, packet_length);
+ data = skb_put(skb, packet_length);
-#ifdef USE_32_BIT
- /* QUESTION: Like in the TX routine, do I want
- to send the DWORDs or the bytes first, or some
- mixture. A mixture might improve already slow PIO
- performance */
- PRINTK3((" Reading %d dwords (and %d bytes) \n",
- packet_length >> 2, packet_length & 3 ));
- insl(ioaddr + DATA_1 , data, packet_length >> 2 );
- /* read the left over bytes */
- insb( ioaddr + DATA_1, data + (packet_length & 0xFFFFFC),
- packet_length & 0x3 );
-#else
- PRINTK3((" Reading %d words and %d byte(s) \n",
- (packet_length >> 1 ), packet_length & 1 ));
- insw(ioaddr + DATA_1 , data, packet_length >> 1);
- if ( packet_length & 1 ) {
- data += packet_length & ~1;
- *(data++) = inb( ioaddr + DATA_1 );
- }
-#endif
-#if SMC_DEBUG > 2
- print_packet( data, packet_length );
-#endif
+ smc_ins(ioaddr, DATA_1, data, packet_length);
+ print_packet(data, packet_length);
- skb->protocol = eth_type_trans(skb, dev );
+ skb->protocol = eth_type_trans(skb, dev);
netif_rx(skb);
dev->last_rx = jiffies;
lp->stats.rx_packets++;
@@ -1368,15 +1806,17 @@
/* error ... */
lp->stats.rx_errors++;
- if ( status & RS_ALGNERR ) lp->stats.rx_frame_errors++;
- if ( status & (RS_TOOSHORT | RS_TOOLONG ) )
+ if (status & RS_ALGNERR)
+ lp->stats.rx_frame_errors++;
+ if (status & (RS_TOOSHORT | RS_TOOLONG))
lp->stats.rx_length_errors++;
- if ( status & RS_BADCRC) lp->stats.rx_crc_errors++;
+ if (status & RS_BADCRC)
+ lp->stats.rx_crc_errors++;
}
done:
/* error or good, tell the card to get rid of this packet */
- outw( MC_RELEASE, ioaddr + MMU_CMD );
+ smc_outw(MC_RELEASE, ioaddr, MMU_CMD);
}
@@ -1389,62 +1829,64 @@
. Algorithm:
. Save pointer and packet no
. Get the packet no from the top of the queue
- . check if it's valid ( if not, is this an error??? )
+ . check if it's valid (if not, is this an error???)
. read the status word
. record the error
- . ( resend? Not really, since we don't want old packets around )
+ . (resend? Not really, since we don't want old packets around)
. Restore saved values
************************************************************************/
-static void smc_tx( struct net_device * dev )
+static void smc_tx(struct net_device * dev)
{
- int ioaddr = dev->base_addr;
+ u_int ioaddr = dev->base_addr;
struct smc_local *lp = (struct smc_local *)dev->priv;
byte saved_packet;
byte packet_no;
word tx_status;
- /* assume bank 2 */
+ /* assume bank 2 */
- saved_packet = inb( ioaddr + PNR_ARR );
- packet_no = inw( ioaddr + FIFO_PORTS );
+ saved_packet = smc_inb(ioaddr, PNR_ARR);
+ packet_no = smc_inw(ioaddr, FIFO_PORTS);
packet_no &= 0x7F;
/* select this as the packet to read from */
- outb( packet_no, ioaddr + PNR_ARR );
+ smc_outb(packet_no, ioaddr, PNR_ARR);
/* read the first word from this packet */
- outw( PTR_AUTOINC | PTR_READ, ioaddr + POINTER );
+ smc_outw(PTR_AUTOINC | PTR_READ, ioaddr, POINTER);
- tx_status = inw( ioaddr + DATA_1 );
- PRINTK3((CARDNAME": TX DONE STATUS: %4x \n", tx_status ));
+ tx_status = smc_inw(ioaddr, DATA_1);
+ PRINTK3(("%s: TX DONE STATUS: %4x\n", dev->name, tx_status));
lp->stats.tx_errors++;
- if ( tx_status & TS_LOSTCAR ) lp->stats.tx_carrier_errors++;
- if ( tx_status & TS_LATCOL ) {
- printk(KERN_DEBUG CARDNAME
- ": Late collision occurred on last xmit.\n");
+ if (tx_status & TS_LOSTCAR)
+ lp->stats.tx_carrier_errors++;
+ if (tx_status & TS_LATCOL) {
+ printk(KERN_DEBUG "%s: Late collision occurred on "
+ "last xmit.\n", dev->name);
lp->stats.tx_window_errors++;
}
#if 0
- if ( tx_status & TS_16COL ) { ... }
+ if (tx_status & TS_16COL) { ... }
#endif
- if ( tx_status & TS_SUCCESS ) {
- printk(CARDNAME": Successful packet caused interrupt \n");
+ if (tx_status & TS_SUCCESS) {
+ printk("%s: Successful packet caused interrupt\n",
+ dev->name);
}
/* re-enable transmit */
- SMC_SELECT_BANK( 0 );
- outw( inw( ioaddr + TCR ) | TCR_ENABLE, ioaddr + TCR );
+ SMC_SELECT_BANK(0);
+ smc_outw(smc_inw(ioaddr, TCR) | TCR_ENABLE, ioaddr, TCR);
/* kill the packet */
- SMC_SELECT_BANK( 2 );
- outw( MC_FREEPKT, ioaddr + MMU_CMD );
+ SMC_SELECT_BANK(2);
+ smc_outw(MC_FREEPKT, ioaddr, MMU_CMD);
/* one less packet waiting for me */
lp->packets_waiting--;
- outb( saved_packet, ioaddr + PNR_ARR );
+ smc_outb(saved_packet, ioaddr, PNR_ARR);
return;
}
@@ -1460,7 +1902,7 @@
{
netif_stop_queue(dev);
/* clear everything */
- smc_shutdown( dev->base_addr );
+ smc_shutdown(dev);
/* Update the statistics here. */
return 0;
@@ -1481,16 +1923,16 @@
.
. This routine will, depending on the values passed to it,
. either make it accept multicast packets, go into
- . promiscuous mode ( for TCPDUMP and cousins ) or accept
+ . promiscuous mode (for TCPDUMP and cousins) or accept
. a select set of multicast packets
*/
static void smc_set_multicast_list(struct net_device *dev)
{
- short ioaddr = dev->base_addr;
+ u_int ioaddr = dev->base_addr;
SMC_SELECT_BANK(0);
- if ( dev->flags & IFF_PROMISC )
- outw( inw(ioaddr + RCR ) | RCR_PROMISC, ioaddr + RCR );
+ if (dev->flags & IFF_PROMISC)
+ smc_outw(smc_inw(ioaddr, RCR) | RCR_PROMISC, ioaddr, RCR);
/* BUG? I never disable promiscuous mode if multicasting was turned on.
Now, I turn off promiscuous mode, but I don't do anything to multicasting
@@ -1502,34 +1944,34 @@
checked before the table is
*/
else if (dev->flags & IFF_ALLMULTI)
- outw( inw(ioaddr + RCR ) | RCR_ALMUL, ioaddr + RCR );
+ smc_outw(smc_inw(ioaddr, RCR) | RCR_ALMUL, ioaddr, RCR);
/* We just get all multicast packets even if we only want them
. from one source. This will be changed at some future
. point. */
- else if (dev->mc_count ) {
+ else if (dev->mc_count) {
/* support hardware multicasting */
/* be sure I get rid of flags I might have set */
- outw( inw( ioaddr + RCR ) & ~(RCR_PROMISC | RCR_ALMUL),
- ioaddr + RCR );
+ smc_outw(smc_inw(ioaddr, RCR) & ~(RCR_PROMISC | RCR_ALMUL),
+ ioaddr, RCR);
/* NOTE: this has to set the bank, so make sure it is the
last thing called. The bank is set to zero at the top */
- smc_setmulticast( ioaddr, dev->mc_count, dev->mc_list );
+ smc_setmulticast(dev, dev->mc_count, dev->mc_list);
}
- else {
- outw( inw( ioaddr + RCR ) & ~(RCR_PROMISC | RCR_ALMUL),
- ioaddr + RCR );
+ else {
+ smc_outw(smc_inw(ioaddr, RCR) & ~(RCR_PROMISC | RCR_ALMUL),
+ ioaddr, RCR);
/*
since I'm disabling all multicast entirely, I need to
clear the multicast list
*/
- SMC_SELECT_BANK( 3 );
- outw( 0, ioaddr + MULTICAST1 );
- outw( 0, ioaddr + MULTICAST2 );
- outw( 0, ioaddr + MULTICAST3 );
- outw( 0, ioaddr + MULTICAST4 );
+ SMC_SELECT_BANK(3);
+ smc_outw(0, ioaddr, MULTICAST1);
+ smc_outw(0, ioaddr, MULTICAST2);
+ smc_outw(0, ioaddr, MULTICAST3);
+ smc_outw(0, ioaddr, MULTICAST4);
}
}
@@ -1550,21 +1992,26 @@
int init_module(void)
{
- int result;
-
if (io == 0)
- printk(KERN_WARNING
- CARDNAME": You shouldn't use auto-probing with insmod!\n" );
+ printk(KERN_WARNING CARDNAME
+ ": You shouldn't use auto-probing with insmod!\n");
+
+ /*
+ * Note: dev->if_port has changed to be 2.4 compliant.
+ * We keep the ifport insmod parameter the same though.
+ */
+ switch (ifport) {
+ case 1: devSMC9194.if_port = IF_PORT_10BASET; break;
+ case 2: devSMC9194.if_port = IF_PORT_AUI; break;
+ default: devSMC9194.if_port = 0; break;
+ }
/* copy the parameters from insmod into the device structure */
devSMC9194.base_addr = io;
devSMC9194.irq = irq;
- devSMC9194.if_port = ifport;
- devSMC9194.init = smc_init;
- if ((result = register_netdev(&devSMC9194)) != 0)
- return result;
+ devSMC9194.init = smc_init;
- return 0;
+ return register_netdev(&devSMC9194);
}
void cleanup_module(void)
diff -urN linux-2.4.26/drivers/net/smc9194.h linux-2.4.26-vrs1/drivers/net/smc9194.h
--- linux-2.4.26/drivers/net/smc9194.h 2001-09-08 20:13:55.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/net/smc9194.h 2004-01-14 21:32:26.000000000 +0000
@@ -63,10 +63,11 @@
#define TCR 0 /* transmit control register */
#define TCR_ENABLE 0x0001 /* if this is 1, we can transmit */
+#define TCR_PAD_ENABLE 0x0080 /* pads short packets to 64 bytes */
+#define TCR_MON_CNS 0x0400 /* monitors the carrier status */
#define TCR_FDUPLX 0x0800 /* receive packets sent out */
#define TCR_STP_SQET 0x1000 /* stop transmitting if Signal quality error */
-#define TCR_MON_CNS 0x0400 /* monitors the carrier status */
-#define TCR_PAD_ENABLE 0x0080 /* pads short packets to 64 bytes */
+#define TCR_FDSE 0x8000 /* full duplex, switched ethernet */
#define TCR_CLEAR 0 /* do NOTHING */
/* the normal settings for the TCR register : */
@@ -107,7 +108,10 @@
#define CTL_CR_ENABLE 0x40
#define CTL_TE_ENABLE 0x0020
#define CTL_AUTO_RELEASE 0x0800
-#define CTL_EPROM_ACCESS 0x0003 /* high if Eprom is being read */
+#define CTL_EPROM_SELECT 0x0004
+#define CTL_EPROM_RELOAD 0x0002
+#define CTL_EPROM_STORE 0x0001
+#define CTL_EPROM_ACCESS (CTL_EPROM_RELOAD | CTL_EPROM_STORE) /* high if Eprom is being read */
/* BANK 2 */
#define MMU_CMD 0
@@ -130,7 +134,6 @@
#define PTR_READ 0x2000
#define PTR_RCV 0x8000
#define PTR_AUTOINC 0x4000
-#define PTR_AUTO_INC 0x0040
#define DATA_1 8
#define DATA_2 10
@@ -162,17 +165,6 @@
#define CHIP_9195 5
#define CHIP_91100 7
-static const char * chip_ids[ 15 ] = {
- NULL, NULL, NULL,
- /* 3 */ "SMC91C90/91C92",
- /* 4 */ "SMC91C94",
- /* 5 */ "SMC91C95",
- NULL,
- /* 7 */ "SMC91C100",
- /* 8 */ "SMC91C100FD",
- NULL, NULL, NULL,
- NULL, NULL, NULL};
-
/*
. Transmit status bits
*/
@@ -192,40 +184,20 @@
#define RS_MULTICAST 0x0001
#define RS_ERRORS (RS_ALGNERR | RS_BADCRC | RS_TOOLONG | RS_TOOSHORT)
-static const char * interfaces[ 2 ] = { "TP", "AUI" };
-
-/*-------------------------------------------------------------------------
- . I define some macros to make it easier to do somewhat common
- . or slightly complicated, repeated tasks.
- --------------------------------------------------------------------------*/
-
-/* select a register bank, 0 to 3 */
-
-#define SMC_SELECT_BANK(x) { outw( x, ioaddr + BANK_SELECT ); }
-
-/* define a small delay for the reset */
-#define SMC_DELAY() { inw( ioaddr + RCR );\
- inw( ioaddr + RCR );\
- inw( ioaddr + RCR ); }
-
-/* this enables an interrupt in the interrupt mask register */
-#define SMC_ENABLE_INT(x) {\
- unsigned char mask;\
- SMC_SELECT_BANK(2);\
- mask = inb( ioaddr + INT_MASK );\
- mask |= (x);\
- outb( mask, ioaddr + INT_MASK ); \
-}
-
-/* this disables an interrupt from the interrupt mask register */
-
-#define SMC_DISABLE_INT(x) {\
- unsigned char mask;\
- SMC_SELECT_BANK(2);\
- mask = inb( ioaddr + INT_MASK );\
- mask &= ~(x);\
- outb( mask, ioaddr + INT_MASK ); \
-}
+/*
+ * SMC91C96 ethernet config and status registers.
+ * These are in the "attribute" space.
+ */
+#define ECOR 0x8000
+#define ECOR_RESET 0x80
+#define ECOR_LEVEL_IRQ 0x40
+#define ECOR_WR_ATTRIB 0x04
+#define ECOR_ENABLE 0x01
+
+#define ECSR 0x8002
+#define ECSR_IOIS8 0x20
+#define ECSR_PWRDWN 0x04
+#define ECSR_INT 0x02
/*----------------------------------------------------------------------
. Define the interrupts that I want to receive from the card
@@ -237,5 +209,36 @@
--------------------------------------------------------------------------*/
#define SMC_INTERRUPT_MASK (IM_EPH_INT | IM_RX_OVRN_INT | IM_RCV_INT)
+/* store this information for the driver.. */
+struct smc_local {
+ /*
+ these are things that the kernel wants me to keep, so users
+ can find out semi-useless statistics of how well the card is
+ performing
+ */
+ struct net_device_stats stats;
+
+ /*
+ If I have to wait until memory is available to send
+ a packet, I will store the skbuff here, until I get the
+ desired memory. Then, I'll send it out and free it.
+ */
+ struct sk_buff * saved_skb;
+
+ /*
+ . This keeps track of how many packets that I have
+ . sent out. When an TX_EMPTY interrupt comes, I know
+ . that all of these have been sent.
+ */
+ int packets_waiting;
+
+ /*
+ . Interface status. These correspond to the parameters
+ . in the ethtool_cmd structure.
+ */
+ u8 duplex;
+ u8 port;
+};
+
#endif /* _SMC_9194_H_ */
diff -urN linux-2.4.26/drivers/parport/Config.in linux-2.4.26-vrs1/drivers/parport/Config.in
--- linux-2.4.26/drivers/parport/Config.in 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/parport/Config.in 2004-02-23 23:33:11.000000000 +0000
@@ -27,7 +27,8 @@
dep_tristate ' Support for PCMCIA management for PC-style ports' CONFIG_PARPORT_PC_PCMCIA $CONFIG_PCMCIA $CONFIG_PARPORT_PC $CONFIG_HOTPLUG
fi
if [ "$CONFIG_ARM" = "y" ]; then
- dep_tristate ' Archimedes hardware' CONFIG_PARPORT_ARC $CONFIG_PARPORT
+ dep_tristate ' Archimedes hardware' CONFIG_PARPORT_ARC $CONFIG_PARPORT $CONFIG_ARCH_ARC
+ dep_tristate ' Accelent SA1110 IDP' CONFIG_PARPORT_IDP $CONFIG_PARPORT $CONFIG_SA1100_ACCELENT
fi
if [ "$CONFIG_AMIGA" = "y" ]; then
dep_tristate ' Amiga builtin port' CONFIG_PARPORT_AMIGA $CONFIG_PARPORT
diff -urN linux-2.4.26/drivers/parport/Makefile linux-2.4.26-vrs1/drivers/parport/Makefile
--- linux-2.4.26/drivers/parport/Makefile 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/parport/Makefile 2004-02-23 23:17:13.000000000 +0000
@@ -29,6 +29,7 @@
obj-$(CONFIG_PARPORT_ATARI) += parport_atari.o
obj-$(CONFIG_PARPORT_SUNBPP) += parport_sunbpp.o
obj-$(CONFIG_PARPORT_GSC) += parport_gsc.o
+obj-$(CONFIG_PARPORT_IDP) += parport_idp.o
obj-$(CONFIG_PARPORT_IP22) += parport_ip22.o
include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/parport/init.c linux-2.4.26-vrs1/drivers/parport/init.c
--- linux-2.4.26/drivers/parport/init.c 2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/parport/init.c 2004-01-14 21:32:26.000000000 +0000
@@ -164,6 +164,9 @@
#ifdef CONFIG_PARPORT_SUNBPP
parport_sunbpp_init();
#endif
+#ifdef CONFIG_PARPORT_IDP
+ parport_idp_init();
+#endif
return 0;
}
diff -urN linux-2.4.26/drivers/parport/parport_idp.c linux-2.4.26-vrs1/drivers/parport/parport_idp.c
--- linux-2.4.26/drivers/parport/parport_idp.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/parport/parport_idp.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,247 @@
+/* Low-level polled-mode parallel port routines for the Accelent IDP
+ *
+ * Author: Rich Dulabahn <rich@accelent.com>
+ *
+ * Inspiration taken from parport_amiga.c and parport_atari.c.
+ *
+ * To use, under menuconfig:
+ * 1) Turn on <*> Accelent IDP under Parallel port setup
+ * 2) Turn on <*> Parallel printer support under Character devices
+ *
+ * This will give you parport0 configured as /dev/lp0
+ *
+ * To make the correct /dev/lp* entries, enter /dev and type this:
+ *
+ * mknod lp0 c 6 0
+ * mknod lp1 c 6 1
+ * mknod lp2 c 6 2
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/parport.h>
+#include <asm/hardware.h>
+
+/*
+ * Parallel data port is port H, data
+ * Parallel data direction is port H, direction
+ * Control port is port I, data, lowest 4 bits
+ * Status port is port G, data, upper 5 bits
+ */
+
+#define INPUTPOWERHANDLER 0
+/* masks */
+#define CONTROL_MASK 0x0f
+#define STATUS_MASK 0xf8
+
+#undef DEBUG
+
+#ifdef DEBUG
+#define DPRINTK printk
+#else
+#define DPRINTK(stuff...)
+#endif
+
+static struct parport *this_port = NULL;
+
+static unsigned char
+parport_idp_read_data(struct parport *p)
+{
+ unsigned char c;
+
+ c = IDP_FPGA_PORTH_DATA;
+ DPRINTK("read_data:0x%x\n",c);
+ return c;
+}
+
+static void
+parport_idp_write_data(struct parport *p, unsigned char data)
+{
+ IDP_FPGA_PORTH_DATA = data;
+ DPRINTK("write_data:0x%x\n",data);
+}
+
+static unsigned char
+parport_idp_read_control(struct parport *p)
+{
+ unsigned char c;
+
+ c = IDP_FPGA_PORTI_DATA & CONTROL_MASK;
+ DPRINTK("read_control:0x%x\n",c);
+ return c;
+}
+
+static void
+parport_idp_write_control(struct parport *p, unsigned char control)
+{
+ unsigned int temp;
+
+ temp = IDP_FPGA_PORTH_DATA;
+ temp &= ~CONTROL_MASK;
+ IDP_FPGA_PORTI_DATA = (temp | (control & CONTROL_MASK));
+DPRINTK("write_control:0x%x\n",control);
+}
+
+static unsigned char
+parport_idp_frob_control(struct parport *p, unsigned char mask,
+ unsigned char val)
+{
+ unsigned char c;
+
+/* From the parport-lowlevel.txt file...*/
+/* This is equivalent to reading from the control register, masking out
+the bits in mask, exclusive-or'ing with the bits in val, and writing
+the result to the control register. */
+
+/* Easy enough, right? */
+
+ c = parport_idp_read_control(p);
+ parport_idp_write_control(p, (c & ~mask) ^ val);
+ DPRINTK("frob_control:0x%x\n",c);
+ return c;
+}
+
+static unsigned char
+parport_idp_read_status(struct parport *p)
+{
+ unsigned char c;
+
+ c = IDP_FPGA_PORTG_DATA & STATUS_MASK;
+ c ^= 0x80; /* toggle S7 bit, active low */
+ DPRINTK("read_status:0x%x\n",c);
+ return c;
+}
+
+static void
+parport_idp_init_state(struct pardevice *d, struct parport_state *s)
+{
+}
+
+static void
+parport_idp_save_state(struct parport *p, struct parport_state *s)
+{
+}
+
+static void
+parport_idp_restore_state(struct parport *p, struct parport_state *s)
+{
+}
+
+static void
+parport_idp_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+}
+
+static void
+parport_idp_enable_irq(struct parport *p)
+{
+}
+
+static void
+parport_idp_disable_irq(struct parport *p)
+{
+}
+
+static void
+parport_idp_data_forward(struct parport *p)
+{
+ IDP_FPGA_PORTH_DIR = 0x00; /* 0 sets to output */
+ DPRINTK("data_forward:0x%x\n",0);
+}
+
+static void
+parport_idp_data_reverse(struct parport *p)
+{
+ IDP_FPGA_PORTH_DIR = 0xff; /* and 1 sets to input */
+ DPRINTK("data_reverse:0x%x\n",0xff);
+}
+
+static void
+parport_idp_inc_use_count(void)
+{
+ MOD_INC_USE_COUNT;
+}
+
+static void
+parport_idp_dec_use_count(void)
+{
+ MOD_DEC_USE_COUNT;
+}
+
+static struct parport_operations parport_idp_ops = {
+ parport_idp_write_data,
+ parport_idp_read_data,
+
+ parport_idp_write_control,
+ parport_idp_read_control,
+ parport_idp_frob_control,
+
+ parport_idp_read_status,
+
+ parport_idp_enable_irq,
+ parport_idp_disable_irq,
+
+ parport_idp_data_forward,
+ parport_idp_data_reverse,
+
+ parport_idp_init_state,
+ parport_idp_save_state,
+ parport_idp_restore_state,
+
+ parport_idp_inc_use_count,
+ parport_idp_dec_use_count,
+
+ parport_ieee1284_epp_write_data,
+ parport_ieee1284_epp_read_data,
+ parport_ieee1284_epp_write_addr,
+ parport_ieee1284_epp_read_addr,
+
+ parport_ieee1284_ecp_write_data,
+ parport_ieee1284_ecp_read_data,
+ parport_ieee1284_ecp_write_addr,
+
+ parport_ieee1284_write_compat,
+ parport_ieee1284_read_nibble,
+ parport_ieee1284_read_byte,
+};
+
+
+int __init
+parport_idp_init(void)
+{
+ struct parport *p;
+
+ p = parport_register_port((unsigned long)0,PARPORT_IRQ_NONE,PARPORT_DMA_NONE,&parport_idp_ops);
+
+ if (!p) return 0; /* return 0 on failure */
+
+ this_port=p;
+ printk("%s: Accelent IDP parallel port registered.\n", p->name);
+ parport_proc_register(p);
+ parport_announce_port(p);
+
+ return 1;
+}
+
+#ifdef MODULE
+
+MODULE_AUTHOR("Rich Dulabahn");
+MODULE_DESCRIPTION("Parport Driver for Accelent IDP");
+MODULE_SUPPORTED_DEVICE("Accelent IDP builtin Parallel Port");
+MODULE_LICENSE("GPL");
+
+int
+init_module(void)
+{
+ return parport_idp_init() ? 0 : -ENODEV;
+}
+
+void
+cleanup_module(void)
+{
+ parport_proc_unregister(this_port);
+ parport_unregister_port(this_port);
+}
+#endif
+
diff -urN linux-2.4.26/drivers/pci/Makefile linux-2.4.26-vrs1/drivers/pci/Makefile
--- linux-2.4.26/drivers/pci/Makefile 2003-08-25 12:44:42.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pci/Makefile 2004-01-14 21:39:07.000000000 +0000
@@ -13,7 +13,7 @@
export-objs := pci.o
-obj-$(CONFIG_PCI) += pci.o quirks.o compat.o names.o
+obj-$(CONFIG_PCI) += pci.o quirks.o compat.o names.o bridge.o
obj-$(CONFIG_PROC_FS) += proc.o
ifndef CONFIG_SPARC64
diff -urN linux-2.4.26/drivers/pci/bridge.c linux-2.4.26-vrs1/drivers/pci/bridge.c
--- linux-2.4.26/drivers/pci/bridge.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pci/bridge.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,149 @@
+
+/*
+ * Copyright (c) 2001 Red Hat, Inc. All rights reserved.
+ *
+ * This software may be freely redistributed under the terms
+ * of the GNU public license.
+ *
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: Arjan van de Ven <arjanv@redhat.com>
+ *
+ */
+
+
+/*
+ * Generic PCI driver for PCI bridges for powermanagement purposes
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+
+static struct pci_device_id bridge_pci_table[] __devinitdata = {
+ {/* handle all PCI bridges */
+ class: ((PCI_CLASS_BRIDGE_PCI << 8) | 0x00),
+ class_mask: ~0,
+ vendor: PCI_ANY_ID,
+ device: PCI_ANY_ID,
+ subvendor: PCI_ANY_ID,
+ subdevice: PCI_ANY_ID,
+ },
+ {0,},
+};
+
+static int bridge_probe(struct pci_dev *pdev, const struct pci_device_id *id);
+static int pci_bridge_save_state_bus(struct pci_bus *bus, int force);
+int pci_generic_resume_compare(struct pci_dev *pdev);
+
+int pci_bridge_force_restore = 0;
+
+
+
+
+static int __init bridge_setup(char *str)
+{
+ if (!strcmp(str,"force"))
+ pci_bridge_force_restore = 1;
+ else if (!strcmp(str,"noforce"))
+ pci_bridge_force_restore = 0;
+ return 0;
+}
+
+__setup("resume=",bridge_setup);
+
+
+static int pci_bridge_save_state_bus(struct pci_bus *bus, int force)
+{
+ struct list_head *list;
+ int error = 0;
+
+ list_for_each(list, &bus->children) {
+ error = pci_bridge_save_state_bus(pci_bus_b(list),force);
+ if (error) return error;
+ }
+ list_for_each(list, &bus->devices) {
+ pci_generic_suspend_save(pci_dev_b(list),0);
+ }
+ return 0;
+}
+
+
+static int pci_bridge_restore_state_bus(struct pci_bus *bus, int force)
+{
+ struct list_head *list;
+ int error = 0;
+ static int printed_warning=0;
+
+ list_for_each(list, &bus->children) {
+ error = pci_bridge_restore_state_bus(pci_bus_b(list),force);
+ if (error) return error;
+ }
+ list_for_each(list, &bus->devices) {
+ if (force)
+ pci_generic_resume_restore(pci_dev_b(list));
+ else {
+ error = pci_generic_resume_compare(pci_dev_b(list));
+ if (error && !printed_warning++) {
+ printk(KERN_WARNING "resume warning: bios doesn't restore PCI state properly\n");
+ printk(KERN_WARNING "resume warning: if resume failed, try booting with resume=force\n");
+ }
+ if (error)
+ return error;
+ }
+ }
+ return 0;
+}
+
+static int bridge_suspend(struct pci_dev *dev, u32 force)
+{
+ pci_generic_suspend_save(dev,force);
+ if (dev->subordinate)
+ pci_bridge_save_state_bus(dev->subordinate,force);
+ return 0;
+}
+
+static int bridge_resume(struct pci_dev *dev)
+{
+
+ pci_generic_resume_restore(dev);
+ if (dev->subordinate)
+ pci_bridge_restore_state_bus(dev->subordinate,pci_bridge_force_restore);
+ return 0;
+}
+
+
+MODULE_DEVICE_TABLE(pci, bridge_pci_table);
+static struct pci_driver bridge_ops = {
+ name: "PCI Bridge",
+ id_table: bridge_pci_table,
+ probe: bridge_probe,
+ suspend: bridge_suspend,
+ resume: bridge_resume
+};
+
+static int __devinit bridge_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+ return 0;
+}
+
+static int __init bridge_init(void)
+{
+ pci_register_driver(&bridge_ops);
+ return 0;
+}
+
+static void __exit bridge_exit(void)
+{
+ pci_unregister_driver(&bridge_ops);
+}
+
+
+module_init(bridge_init)
+module_exit(bridge_exit)
+
diff -urN linux-2.4.26/drivers/pci/pci.c linux-2.4.26-vrs1/drivers/pci/pci.c
--- linux-2.4.26/drivers/pci/pci.c 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/pci/pci.c 2004-01-14 21:39:08.000000000 +0000
@@ -359,6 +359,48 @@
return 0;
}
+int
+pci_compare_state(struct pci_dev *dev, u32 *buffer)
+{
+ int i;
+ unsigned int temp;
+
+ if (buffer) {
+ for (i = 0; i < 16; i++) {
+ pci_read_config_dword(dev,i*4,&temp);
+ if (temp!=buffer[i])
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int pci_generic_suspend_save(struct pci_dev *pdev, u32 state)
+{
+ if (pdev)
+ pci_save_state(pdev,pdev->saved_state);
+ return 0;
+}
+
+int pci_generic_resume_restore(struct pci_dev *pdev)
+{
+ if (pdev)
+ pci_restore_state(pdev,pdev->saved_state);
+ return 0;
+}
+
+int pci_generic_resume_compare(struct pci_dev *pdev)
+{
+ int retval=0;
+ if (pdev)
+ retval = pci_compare_state(pdev,pdev->saved_state);
+ return retval;
+}
+
+EXPORT_SYMBOL(pci_generic_suspend_save);
+EXPORT_SYMBOL(pci_generic_resume_restore);
+EXPORT_SYMBOL(pci_generic_resume_compare);
+
/**
* pci_enable_device_bars - Initialize some of a device for use
* @dev: PCI device to be initialized
diff -urN linux-2.4.26/drivers/pci/setup-bus.c linux-2.4.26-vrs1/drivers/pci/setup-bus.c
--- linux-2.4.26/drivers/pci/setup-bus.c 2003-06-13 15:51:35.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pci/setup-bus.c 2004-01-14 21:32:26.000000000 +0000
@@ -12,6 +12,8 @@
/*
* Nov 2000, Ivan Kokshaysky <ink@jurassic.park.msu.ru>
* PCI-PCI bridges cleanup, sorted resource allocation.
+ * May 2001, Russell King <rmk@arm.linux.org.uk>
+ * Allocate prefetchable memory regions where available.
* Feb 2002, Ivan Kokshaysky <ink@jurassic.park.msu.ru>
* Converted to allocation in 3 passes, which gives
* tighter packing. Prefetchable range support.
@@ -160,8 +162,10 @@
pci_write_config_dword(bridge, PCI_PREF_MEMORY_BASE, l);
/* Check if we have VGA behind the bridge.
- Enable ISA in either case (FIXME!). */
- l = (bus->resource[0]->flags & IORESOURCE_BUS_HAS_VGA) ? 0x0c : 0x04;
+ Enable ISA in either case. */
+ l = (bus->resource[0]->flags & IORESOURCE_BUS_HAS_VGA) ?
+ PCI_BRIDGE_CTL_VGA | PCI_BRIDGE_CTL_NO_ISA :
+ PCI_BRIDGE_CTL_NO_ISA;
pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, l);
}
diff -urN linux-2.4.26/drivers/pcmcia/Config.in linux-2.4.26-vrs1/drivers/pcmcia/Config.in
--- linux-2.4.26/drivers/pcmcia/Config.in 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/pcmcia/Config.in 2004-02-23 23:29:38.000000000 +0000
@@ -14,21 +14,19 @@
tristate 'PCMCIA/CardBus support' CONFIG_PCMCIA
if [ "$CONFIG_PCMCIA" != "n" ]; then
+ # yes, I really mean the following...
+ if [ "$CONFIG_ISA" = "y" -o "$CONFIG_ARCH_SA1100" = "y" ]; then
+ define_bool CONFIG_PCMCIA_PROBE y
+ fi
if [ "$CONFIG_PCI" != "n" ]; then
bool ' CardBus support' CONFIG_CARDBUS
fi
+ dep_bool ' i82092 compatible bridge support' CONFIG_I82092 $CONFIG_PCI
+ bool ' i82365 compatible bridge support' CONFIG_I82365
bool ' Databook TCIC host bridge support' CONFIG_TCIC
if [ "$CONFIG_HD64465" = "y" ]; then
dep_tristate ' HD64465 host bridge support' CONFIG_HD64465_PCMCIA $CONFIG_PCMCIA
fi
- dep_bool ' i82092 compatible bridge support' CONFIG_I82092 $CONFIG_PCI
- bool ' i82365 compatible bridge support' CONFIG_I82365
- if [ "$CONFIG_ARCH_SA1100" = "y" ]; then
- dep_tristate ' SA1100 support' CONFIG_PCMCIA_SA1100 $CONFIG_PCMCIA
- fi
- if [ "$CONFIG_8xx" = "y" ]; then
- dep_tristate ' M8xx support' CONFIG_PCMCIA_M8XX $CONFIG_PCMCIA
- fi
if [ "$CONFIG_SOC_AU1X00" = "y" ]; then
dep_tristate ' Au1x00 PCMCIA support' CONFIG_PCMCIA_AU1X00 $CONFIG_PCMCIA
if [ "$CONFIG_PCMCIA_AU1X00" != "n" ]; then
@@ -44,5 +42,9 @@
dep_tristate ' NEC VRC4173 CARDU support' CONFIG_PCMCIA_VRC4173 $CONFIG_PCMCIA
fi
fi
+if [ "$CONFIG_ARM" = "y" ]; then
+ dep_tristate ' CLPS6700 support' CONFIG_PCMCIA_CLPS6700 $CONFIG_ARCH_CLPS711X $CONFIG_PCMCIA
+ dep_tristate ' SA1100 support' CONFIG_PCMCIA_SA1100 $CONFIG_ARCH_SA1100 $CONFIG_PCMCIA
+fi
endmenu
diff -urN linux-2.4.26/drivers/pcmcia/Makefile linux-2.4.26-vrs1/drivers/pcmcia/Makefile
--- linux-2.4.26/drivers/pcmcia/Makefile 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/pcmcia/Makefile 2004-02-23 23:19:09.000000000 +0000
@@ -65,15 +65,18 @@
au1000_ss-objs-$(CONFIG_PCMCIA_DB1X00) += au1000_db1x00.o
au1000_ss-objs-$(CONFIG_PCMCIA_XXS1500) += au1000_xxs1500.o
+obj-$(CONFIG_PCMCIA_CLPS6700) += clps6700.o
obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o
-obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o
obj-$(CONFIG_PCMCIA_SIBYTE) += sibyte_generic.o
sa1100_cs-objs-y := sa1100_generic.o
+sa1100_cs-objs-$(CONFIG_SA1100_ADSAGC) += sa1100_graphicsmaster.o sa1111_generic.o
sa1100_cs-objs-$(CONFIG_SA1100_ADSBITSY) += sa1100_adsbitsy.o sa1111_generic.o
+sa1100_cs-objs-$(CONFIG_SA1100_ADSBITSYPLUS) += sa1100_adsbitsyplus.o sa1111_generic.o
sa1100_cs-objs-$(CONFIG_SA1100_ASSABET) += sa1100_assabet.o
sa1100_cs-objs-$(CONFIG_ASSABET_NEPONSET) += sa1100_neponset.o sa1111_generic.o
sa1100_cs-objs-$(CONFIG_SA1100_BADGE4) += sa1100_badge4.o sa1111_generic.o
+sa1100_cs-objs-$(CONFIG_SA1100_CONSUS) += sa1100_neponset.o sa1111_generic.o
sa1100_cs-objs-$(CONFIG_SA1100_CERF) += sa1100_cerf.o
sa1100_cs-objs-$(CONFIG_SA1100_FLEXANET) += sa1100_flexanet.o
sa1100_cs-objs-$(CONFIG_SA1100_FREEBIRD) += sa1100_freebird.o
diff -urN linux-2.4.26/drivers/pcmcia/cistpl.c linux-2.4.26-vrs1/drivers/pcmcia/cistpl.c
--- linux-2.4.26/drivers/pcmcia/cistpl.c 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/pcmcia/cistpl.c 2004-02-23 13:36:32.000000000 +0000
@@ -286,7 +286,7 @@
s->cis_mem.flags &= ~MAP_ACTIVE;
s->ss_entry->set_mem_map(s->sock, &s->cis_mem);
if (!(s->cap.features & SS_CAP_STATIC_MAP))
- release_mem_region(s->cis_mem.sys_start, s->cap.map_size);
+ release_mem_resource(s->cis_mem.sys_start, s->cap.map_size);
bus_iounmap(s->cap.bus, s->cis_virt);
s->cis_mem.sys_start = 0;
s->cis_virt = NULL;
diff -urN linux-2.4.26/drivers/pcmcia/clps6700.c linux-2.4.26-vrs1/drivers/pcmcia/clps6700.c
--- linux-2.4.26/drivers/pcmcia/clps6700.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/clps6700.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,498 @@
+/*
+ * linux/drivers/pcmcia/clps6700.c
+ *
+ * Copyright (C) 2000 Deep Blue Solutions Ltd
+ *
+ * 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
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/proc_fs.h>
+#include <linux/spinlock.h>
+#include <linux/init.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/hardware.h>
+#include <asm/page.h>
+
+#include <asm/arch/syspld.h>
+#include <asm/hardware/clps7111.h>
+
+#include <pcmcia/version.h>
+#include <pcmcia/cs_types.h>
+#include <pcmcia/ss.h>
+
+#include "clps6700.h"
+
+#define DEBUG
+
+MODULE_AUTHOR("Russell King");
+MODULE_DESCRIPTION("CL-PS6700 PCMCIA socket driver");
+
+#define NR_CLPS6700 2
+
+struct clps6700_skt {
+ u_int nr;
+ u_int physbase;
+ u_int regbase;
+ u_int pmr;
+ u_int cpcr;
+ u_int cpcr_3v3;
+ u_int cpcr_5v0;
+ u_int cur_pmr;
+ u_int cur_cicr;
+ u_int cur_pcimr;
+ u_int cur_cpcr;
+ void (*handler)(void *, u_int);
+ void *handler_info;
+
+ u_int ev_pending;
+ spinlock_t ev_lock;
+};
+
+static struct clps6700_skt *skts[NR_CLPS6700];
+
+static int clps6700_sock_init(u_int sock)
+{
+ struct clps6700_skt *skt = skts[sock];
+
+ skt->cur_cicr = 0;
+ skt->cur_pmr = skt->pmr;
+ skt->cur_pcimr = 0;
+ skt->cur_cpcr = skt->cpcr;
+
+#ifdef DEBUG
+ printk("skt%d: sock_init()\n", sock);
+#endif
+
+ __raw_writel(skt->cur_pmr, skt->regbase + PMR);
+ __raw_writel(skt->cur_cpcr, skt->regbase + CPCR);
+ __raw_writel(0x01f8, skt->regbase + SICR);
+ __raw_writel(0x0000, skt->regbase + DMACR);
+ __raw_writel(skt->cur_cicr, skt->regbase + CICR);
+ __raw_writel(0x1f00, skt->regbase + CITR0A);
+ __raw_writel(0x0000, skt->regbase + CITR0B);
+ __raw_writel(0x1f00, skt->regbase + CITR1A);
+ __raw_writel(0x0000, skt->regbase + CITR1B);
+ __raw_writel(skt->cur_pcimr, skt->regbase + PCIMR);
+
+ /*
+ * Enable Auto Idle Mode in PM register
+ */
+ __raw_writel(-1, skt->regbase + PCIRR1);
+ __raw_writel(-1, skt->regbase + PCIRR2);
+ __raw_writel(-1, skt->regbase + PCIRR3);
+
+ return 0;
+}
+
+static int clps6700_suspend(u_int sock)
+{
+ return 0;
+}
+
+static int clps6700_register_callback(u_int sock, void (*handler)(void *, u_int), void *info)
+{
+ struct clps6700_skt *skt = skts[sock];
+
+#ifdef DEBUG
+ printk("skt%d: register_callback: %p (%p)\n", sock, handler, info);
+#endif
+
+ skt->handler_info = info;
+ skt->handler = handler;
+
+ return 0;
+}
+
+static int clps6700_inquire_socket(u_int sock, socket_cap_t *cap)
+{
+ cap->features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP | SS_CAP_MEM_ALIGN;
+ cap->irq_mask = 0; /* available IRQs for this socket */
+ cap->map_size = PAGE_SIZE; /* minimum mapping size */
+ cap->pci_irq = 0; /* PCI interrupt number */
+ cap->cb_dev = NULL;
+ cap->bus = NULL;
+ return 0;
+}
+
+static int __clps6700_get_status(struct clps6700_skt *skt)
+{
+ unsigned int v, val;
+
+ v = __raw_readl(skt->regbase + PCIILR);
+ val = 0;
+ if ((v & (PCM_CD1 | PCM_CD2)) == 0)
+ val |= SS_DETECT;
+ if ((v & (PCM_BVD2 | PCM_BVD1)) == PCM_BVD1)
+ val |= SS_BATWARN;
+ if ((v & PCM_BVD2) == 0)
+ val |= SS_BATDEAD;
+
+ if (v & PCM_RDYL)
+ val |= SS_READY;
+ if (v & PCM_VS1)
+ val |= SS_3VCARD;
+ if (v & PCM_VS2)
+ val |= SS_XVCARD;
+
+#ifdef DEBUG
+ printk("skt%d: PCIILR: %08x -> (%s %s %s %s %s %s)\n",
+ skt->nr, v,
+ val & SS_READY ? "rdy" : "---",
+ val & SS_DETECT ? "det" : "---",
+ val & SS_BATWARN ? "bw" : "--",
+ val & SS_BATDEAD ? "bd" : "--",
+ val & SS_3VCARD ? "3v" : "--",
+ val & SS_XVCARD ? "xv" : "--");
+#endif
+ return val;
+}
+
+static int clps6700_get_status(u_int sock, u_int *valp)
+{
+ struct clps6700_skt *skt = skts[sock];
+
+ *valp = __clps6700_get_status(skt);
+
+ return 0; /* not used! */
+}
+
+static int clps6700_get_socket(u_int sock, socket_state_t *state)
+{
+ return -EINVAL;
+}
+
+static int clps6700_set_socket(u_int sock, socket_state_t *state)
+{
+ struct clps6700_skt *skt = skts[sock];
+ unsigned long flags;
+ u_int cpcr = skt->cur_cpcr, pmr = skt->cur_pmr, cicr = skt->cur_cicr;
+ u_int pcimr = 0;
+
+ cicr &= ~(CICR_ENABLE | CICR_RESET | CICR_IOMODE);
+
+ if (state->flags & SS_PWR_AUTO)
+ pmr |= PMR_DCAR | PMR_PDCR;
+
+ /*
+ * Note! We must NOT assert the Card Enable bit until reset has
+ * been de-asserted. Some cards indicate not ready, which then
+ * hangs our next access. (Bug in CLPS6700?)
+ */
+ if (state->flags & SS_RESET)
+ cicr |= CICR_RESET | CICR_RESETOE;
+ else if (state->flags & SS_OUTPUT_ENA)
+ cicr |= CICR_ENABLE;
+
+ if (state->flags & SS_IOCARD) {
+ cicr |= CICR_IOMODE;
+
+/* if (state->csc_mask & SS_STSCHG)*/
+ } else {
+ if (state->csc_mask & SS_BATDEAD)
+ pcimr |= PCM_BVD2;
+ if (state->csc_mask & SS_BATWARN)
+ pcimr |= PCM_BVD1;
+ if (state->csc_mask & SS_READY)
+ pcimr |= PCM_RDYL;
+ }
+
+ if (state->csc_mask & SS_DETECT)
+ pcimr |= PCM_CD1 | PCM_CD2;
+
+ switch (state->Vcc) {
+ case 0: break;
+ case 33: cpcr |= skt->cpcr_3v3; pmr |= PMR_CPE; break;
+ case 50: cpcr |= skt->cpcr_5v0; pmr |= PMR_CPE; break;
+ default: return -EINVAL;
+ }
+
+#ifdef DEBUG
+ printk("skt%d: PMR: %04x, CPCR: %04x, CICR: %04x PCIMR: %04x "
+ "(Vcc = %d, flags = %c%c%c%c, csc = %c%c%c%c%c)\n",
+ sock, pmr, cpcr, cicr, pcimr, state->Vcc,
+ state->flags & SS_RESET ? 'r' : '-',
+ state->flags & SS_PWR_AUTO ? 'p' : '-',
+ state->flags & SS_IOCARD ? 'i' : '-',
+ state->flags & SS_OUTPUT_ENA ? 'o' : '-',
+ state->csc_mask & SS_STSCHG ? 's' : '-',
+ state->csc_mask & SS_BATDEAD ? 'd' : '-',
+ state->csc_mask & SS_BATWARN ? 'w' : '-',
+ state->csc_mask & SS_READY ? 'r' : '-',
+ state->csc_mask & SS_DETECT ? 'c' : '-');
+#endif
+
+ save_flags_cli(flags);
+
+ if (skt->cur_cpcr != cpcr) {
+ skt->cur_cpcr = cpcr;
+ __raw_writel(skt->cur_cpcr, skt->regbase + CPCR);
+ }
+
+ if (skt->cur_pmr != pmr) {
+ skt->cur_pmr = pmr;
+ __raw_writel(skt->cur_pmr, skt->regbase + PMR);
+ }
+ if (skt->cur_pcimr != pcimr) {
+ skt->cur_pcimr = pcimr;
+ __raw_writel(skt->cur_pcimr, skt->regbase + PCIMR);
+ }
+ if (skt->cur_cicr != cicr) {
+ skt->cur_cicr = cicr;
+ __raw_writel(skt->cur_cicr, skt->regbase + CICR);
+ }
+
+ restore_flags(flags);
+
+ return 0;
+}
+
+static int clps6700_get_io_map(u_int sock, struct pccard_io_map *io)
+{
+ return -EINVAL;
+}
+
+static int clps6700_set_io_map(u_int sock, struct pccard_io_map *io)
+{
+ printk("skt%d: iomap: %d: speed %d, flags %X start %X stop %X\n",
+ sock, io->map, io->speed, io->flags, io->start, io->stop);
+ return 0;
+}
+
+static int clps6700_get_mem_map(u_int sock, struct pccard_mem_map *mem)
+{
+ return -EINVAL;
+}
+
+/*
+ * Set the memory map attributes for this socket. (ie, mem->speed)
+ * Note that since we have SS_CAP_STATIC_MAP set, we don't need to do
+ * any mapping here at all; we just need to return the address (suitable
+ * for ioremap) to map the requested space in mem->sys_start.
+ *
+ * flags & MAP_ATTRIB indicates whether we want attribute space.
+ */
+static int clps6700_set_mem_map(u_int sock, struct pccard_mem_map *mem)
+{
+ struct clps6700_skt *skt = skts[sock];
+ u_int off;
+
+ printk("skt%d: memmap: %d: speed %d, flags %X start %lX stop %lX card %X\n",
+ sock, mem->map, mem->speed, mem->flags, mem->sys_start,
+ mem->sys_stop, mem->card_start);
+
+ if (mem->flags & MAP_ATTRIB)
+ off = CLPS6700_ATTRIB_BASE;
+ else
+ off = CLPS6700_MEM_BASE;
+
+ mem->sys_start = skt->physbase + off;
+ mem->sys_start += mem->card_start;
+
+ return 0;
+}
+
+static void clps6700_proc_setup(u_int sock, struct proc_dir_entry *base)
+{
+}
+
+static struct pccard_operations clps6700_operations = {
+ init: clps6700_sock_init,
+ suspend: clps6700_suspend,
+ register_callback: clps6700_register_callback,
+ inquire_socket: clps6700_inquire_socket,
+ get_status: clps6700_get_status,
+ get_socket: clps6700_get_socket,
+ set_socket: clps6700_set_socket,
+ get_io_map: clps6700_get_io_map,
+ set_io_map: clps6700_set_io_map,
+ get_mem_map: clps6700_get_mem_map,
+ set_mem_map: clps6700_set_mem_map,
+ proc_setup: clps6700_proc_setup
+};
+
+static void clps6700_bh(void *dummy)
+{
+ int i;
+
+ for (i = 0; i < NR_CLPS6700; i++) {
+ struct clps6700_skt *skt = skts[i];
+ unsigned long flags;
+ u_int events;
+
+ if (!skt)
+ continue;
+
+ /*
+ * Note! We must read the pending event state
+ * with interrupts disabled, otherwise we race
+ * with our own interrupt routine!
+ */
+ spin_lock_irqsave(&skt->ev_lock, flags);
+ events = skt->ev_pending;
+ skt->ev_pending = 0;
+ spin_unlock_irqrestore(&skt->ev_lock, flags);
+
+ if (skt->handler && events)
+ skt->handler(skt->handler_info, events);
+ }
+}
+
+static struct tq_struct clps6700_task = {
+ routine: clps6700_bh
+};
+
+static void clps6700_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct clps6700_skt *skt = dev_id;
+ u_int val, events;
+
+ val = __raw_readl(skt->regbase + PCISR);
+ if (!val)
+ return;
+
+ __raw_writel(val, skt->regbase + PCICR);
+
+ events = 0;
+ if (val & (PCM_CD1 | PCM_CD2))
+ events |= SS_DETECT;
+ if (val & PCM_BVD1)
+ events |= SS_BATWARN;
+ if (val & PCM_BVD2)
+ events |= SS_BATDEAD;
+ if (val & PCM_RDYL)
+ events |= SS_READY;
+
+ spin_lock(&skt->ev_lock);
+ skt->ev_pending |= events;
+ spin_unlock(&skt->ev_lock);
+ schedule_task(&clps6700_task);
+}
+
+static int __init clps6700_init_skt(int nr)
+{
+ struct clps6700_skt *skt;
+ int ret;
+
+ skt = kmalloc(sizeof(struct clps6700_skt), GFP_KERNEL);
+ if (!skt)
+ return -ENOMEM;
+
+ memset(skt, 0, sizeof(struct clps6700_skt));
+
+ spin_lock_init(&skt->ev_lock);
+
+ skt->nr = nr;
+ skt->physbase = nr ? CS5_PHYS_BASE : CS4_PHYS_BASE;
+ skt->pmr = PMR_AUTOIDLE | PMR_MCPE | PMR_CDWEAK;
+ skt->cpcr = CPCR_PDIR(PCTL1|PCTL0);
+ skt->cpcr_3v3 = CPCR_PON(PCTL0);
+ skt->cpcr_5v0 = CPCR_PON(PCTL0); /* we only do 3v3 */
+
+ skt->cur_pmr = skt->pmr;
+
+ skt->regbase = (u_int)ioremap(skt->physbase + CLPS6700_REG_BASE,
+ CLPS6700_REG_SIZE);
+ ret = -ENOMEM;
+ if (!skt->regbase)
+ goto err_free;
+
+ skts[nr] = skt;
+
+ ret = request_irq(IRQ_EINT3, clps6700_interrupt,
+ SA_SHIRQ, "pcmcia", skt);
+
+ if (ret) {
+ printk(KERN_ERR "clps6700: unable to grab irq%d (%d)\n",
+ IRQ_EINT3, ret);
+ goto err_unmap;
+ }
+ return 0;
+
+err_unmap:
+ iounmap((void *)skt->regbase);
+err_free:
+ kfree(skt);
+ skts[nr] = NULL;
+ return ret;
+}
+
+static void clps6700_free_resources(void)
+{
+ int i;
+
+ for (i = NR_CLPS6700; i >= 0; i--) {
+ struct clps6700_skt *skt = skts[i];
+
+ skts[i] = NULL;
+ if (skt == NULL)
+ continue;
+
+ free_irq(IRQ_EINT3, skt);
+ if (skt->regbase) {
+ __raw_writel(skt->pmr, skt->regbase + PMR);
+ __raw_writel(skt->cpcr, skt->regbase + CPCR);
+ __raw_writel(0, skt->regbase + CICR);
+ __raw_writel(0, skt->regbase + PCIMR);
+ }
+ iounmap((void *)skt->regbase);
+ kfree(skt);
+ }
+}
+
+static int __init clps6700_init(void)
+{
+ unsigned int v;
+ int err, nr;
+
+ PLD_CF = 0;
+ v = clps_readl(SYSCON2) | SYSCON2_PCCARD1 | SYSCON2_PCCARD2;
+ clps_writel(v, SYSCON2);
+ v = clps_readl(SYSCON1) | SYSCON1_EXCKEN;
+ clps_writel(v, SYSCON1);
+
+ for (nr = 0; nr < NR_CLPS6700; nr++) {
+ err = clps6700_init_skt(nr);
+ if (err)
+ goto free;
+ }
+
+ err = register_ss_entry(nr, &clps6700_operations);
+ if (err)
+ goto free;
+
+ return 0;
+
+free:
+ clps6700_free_resources();
+ /*
+ * An error occurred. Unmap and free all CLPS6700
+ */
+ return err;
+}
+
+static void __exit clps6700_exit(void)
+{
+ unregister_ss_entry(&clps6700_operations);
+ clps6700_free_resources();
+}
+
+module_init(clps6700_init);
+module_exit(clps6700_exit);
diff -urN linux-2.4.26/drivers/pcmcia/clps6700.h linux-2.4.26-vrs1/drivers/pcmcia/clps6700.h
--- linux-2.4.26/drivers/pcmcia/clps6700.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/clps6700.h 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,85 @@
+#define PCISR 0x0000 /* PC Card Interrupt Status Register */
+#define PCIMR 0x0400 /* PC Card Interrupt Mask Register */
+#define PCICR 0x0800 /* PC Card Interrupt Clear Register */
+#define PCIOSR 0x0c00 /* PC Card Interrupt Output Select Regsiter */
+#define PCIRR1 0x1000 /* PC Card Interrupt Reserved Register 1 */
+#define PCIRR2 0x1400 /* PC Card Interrupt Reserved Register 2 */
+#define PCIRR3 0x1800 /* PC Card Interrupt Reserved Register 3 */
+#define PCIILR 0x1c00 /* PC Card Interrupt Input Level Register */
+#define SICR 0x2000 /* System Interface Configuration Register */
+#define CICR 0x2400 /* Card Interface Configuration Register */
+#define PMR 0x2800 /* Power Management Register */
+#define CPCR 0x2c00 /* Card Power Control Register */
+#define CITR0A 0x3000 /* Card Interface Timing Register 0A */
+#define CITR0B 0x3400 /* Card Interface Timing Register 0B */
+#define CITR1A 0x3800 /* Card Interface Timing Register 1A */
+#define CITR1B 0x3c00 /* Card Interface Timing Register 1B */
+#define DMACR 0x4000 /* DMA Control Register */
+#define DIR 0x4400 /* Device Information Register */
+
+#define CLPS6700_ATTRIB_BASE 0x00000000
+#define CLPS6700_IO_BASE 0x04000000
+#define CLPS6700_MEM_BASE 0x08000000
+#define CLPS6700_REG_BASE 0x0c000000
+#define CLPS6700_REG_SIZE 0x00005000
+
+
+#define PMR_AUTOIDLE (1 << 0) /* auto idle mode */
+#define PMR_FORCEIDLE (1 << 1) /* force idle mode */
+#define PMR_PDCS (1 << 2) /* Power down card on standby */
+#define PMR_PDCR (1 << 3) /* Power down card on removal */
+#define PMR_DCAR (1 << 4) /* Disable card access on removal */
+#define PMR_CPE (1 << 5) /* Card power enable */
+#define PMR_MCPE (1 << 6) /* Monitor card power enable */
+#define PMR_PDREQLSEL (1 << 7) /* If set, PDREQL is a GPIO pin */
+#define PMR_DISSTBY (1 << 8) /* Disable standby */
+#define PMR_ACCSTBY (1 << 9) /* Complete card accesses before standby*/
+#define PMR_CDUNPROT (0 << 10) /* Card detect inputs unprotected */
+#define PMR_CDPROT (1 << 10) /* Card detect inputs protected */
+#define PMR_CDWEAK (2 << 10) /* Weak pullup except in standby */
+#define PMR_CDWEAKAL (3 << 10) /* Weak pullup */
+
+#define CPCR_PON(x) ((x)&7) /* PCTL[2:0] value when PMR_CPE = 1 */
+#define CPCR_POFF(x) (((x)&7)<<3) /* PCTL[2:0] value when PMR_CPE = 0 */
+#define CPCR_PDIR(x) (((x)&7)<<6) /* PCTL[2:0] direction */
+#define CPCR_CON(x) (((x)&1)<<9) /* GPIO value when PMR_CPE = 1 */
+#define CPCR_COFF(x) (((x)&1)<<10) /* GPIO value when PMR_CPE = 0 */
+#define CPCR_CDIR(x) (((x)&1)<<11) /* GPIO direction (PMR_PDREQLSEL = 1) */
+#define CPCR_VS(x) (((x)&3)<<12) /* VS[2:1] output value */
+#define CPCR_VSDIR(x) (((x)&3)<<14) /* VS[2:1] direction */
+
+#define PCTL0 (1 << 0)
+#define PCTL1 (1 << 1)
+#define PCTL2 (1 << 2)
+
+#define CICR_ASRTMR1 (1 << 0) /* Timer 1 select for attribute read */
+#define CICR_ASWTMR1 (1 << 1) /* Timer 1 select for attribute write */
+#define CICR_IOSRTMR1 (1 << 2) /* Timer 1 select for IO read */
+#define CICR_IOSWTMR1 (1 << 3) /* Timer 1 select for IO write */
+#define CICR_MEMSRTMR1 (1 << 4) /* Timer 1 select for memory read */
+#define CICR_MEMSWTMR1 (1 << 5) /* Timer 1 select for memory write */
+#define CICR_AUTOIOSZ (1 << 6) /* Auto size I/O accesses */
+#define CICR_CAW (1 << 7) /* Card access width */
+#define CICR_IOMODE (1 << 8) /* IO mode select */
+#define CICR_ENABLE (1 << 10) /* Card enable */
+#define CICR_RESETOE (1 << 11) /* Card reset output enable */
+#define CICR_RESET (1 << 12) /* Card reset */
+
+
+#define RD_FAIL (1 << 14)
+#define WR_FAIL (1 << 13)
+#define IDLE (1 << 12)
+
+#define FFOTHLD (1 << 11)
+#define PCM_RDYL (1 << 10)
+#define PCM_WP (1 << 9)
+#define PCTL (1 << 8)
+
+#define PDREQ_L (1 << 6)
+#define PCM_VS2 (1 << 5)
+#define PCM_VS1 (1 << 4)
+
+#define PCM_CD2 (1 << 3)
+#define PCM_CD1 (1 << 2)
+#define PCM_BVD2 (1 << 1)
+#define PCM_BVD1 (1 << 0)
diff -urN linux-2.4.26/drivers/pcmcia/cs.c linux-2.4.26-vrs1/drivers/pcmcia/cs.c
--- linux-2.4.26/drivers/pcmcia/cs.c 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/pcmcia/cs.c 2004-02-27 23:44:12.000000000 +0000
@@ -3,7 +3,7 @@
Kernel Card Services -- core services
cs.c 1.271 2000/10/02 20:27:49
-
+
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
@@ -28,7 +28,7 @@
and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this
file under either the MPL or the GPL.
-
+
======================================================================*/
#include <linux/module.h>
@@ -92,7 +92,7 @@
MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
MODULE_DESCRIPTION("Linux Kernel Card Services " CS_RELEASE
"\n options:" OPTIONS);
-MODULE_LICENSE("Dual MPL/GPL");
+MODULE_LICENSE("Dual MPL/GPL");
#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
@@ -123,7 +123,7 @@
static const char *version =
"cs.c 1.279 2001/10/13 00:08:28 (David Hinds)";
#endif
-
+
/*====================================================================*/
socket_state_t dead_socket = {
@@ -299,7 +299,7 @@
Low-level PC Card interface drivers need to register with Card
Services using these calls.
-
+
======================================================================*/
static int setup_socket(socket_info_t *);
@@ -331,7 +331,7 @@
s->use_bus_pm = use_bus_pm;
s->erase_busy.next = s->erase_busy.prev = &s->erase_busy;
spin_lock_init(&s->lock);
-
+
for (i = 0; i < sockets; i++)
if (socket_table[i] == NULL) break;
socket_table[i] = s;
@@ -365,7 +365,7 @@
for (ns = 0; ns < nsock; ns++) {
pcmcia_register_socket (ns, ss_entry, 0);
}
-
+
return 0;
} /* register_ss_entry */
@@ -457,7 +457,7 @@
static void shutdown_socket(socket_info_t *s)
{
client_t **c;
-
+
DEBUG(1, "cs: shutdown_socket(%p)\n", s);
/* Blank out the socket state */
@@ -561,7 +561,7 @@
have several causes: card insertion, a call to reset_socket, or
recovery from a suspend/resume cycle. Unreset_socket() sends
a CS event that matches the cause of the reset.
-
+
======================================================================*/
static void reset_socket(socket_info_t *s)
@@ -616,7 +616,7 @@
s->state &= ~SOCKET_SETUP_PENDING;
} else {
send_event(s, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW);
- if (s->reset_handle) {
+ if (s->reset_handle) {
s->reset_handle->event_callback_args.info = NULL;
EVENT(s->reset_handle, CS_EVENT_RESET_COMPLETE,
CS_EVENT_PRI_LOW);
@@ -631,7 +631,7 @@
valid clients. Parse_events() interprets the event bits from
a card status change report. Do_shutdown() handles the high
priority stuff associated with a card removal.
-
+
======================================================================*/
static int send_event(socket_info_t *s, event_t event, int priority)
@@ -641,7 +641,7 @@
DEBUG(1, "cs: send_event(sock %d, event %d, pri %d)\n",
s->sock, event, priority);
ret = 0;
- for (; client; client = client->next) {
+ for (; client; client = client->next) {
if (client->state & (CLIENT_UNBOUND|CLIENT_STALE))
continue;
if (client->EventMask & event) {
@@ -675,10 +675,17 @@
static void parse_events(void *info, u_int events)
{
socket_info_t *s = info;
+
if (events & SS_DETECT) {
int status;
get_socket_status(s, &status);
+
+ /*
+ * If our socket state indicates that a card is present and
+ * either the socket has not been suspended (for some reason)
+ * or the card has been removed, shut down the socket first.
+ */
if ((s->state & SOCKET_PRESENT) &&
(!(s->state & SOCKET_SUSPEND) ||
!(status & SS_DETECT)))
@@ -716,7 +723,7 @@
This does not comply with the latest PC Card spec for handling
power management events.
-
+
======================================================================*/
void pcmcia_suspend_socket (socket_info_t *s)
@@ -773,7 +780,7 @@
/*======================================================================
Special stuff for managing IO windows, because they are scarce.
-
+
======================================================================*/
static int alloc_io_space(socket_info_t *s, u_int attr, ioaddr_t *base,
@@ -862,7 +869,7 @@
Access_configuration_register() reads and writes configuration
registers in attribute memory. Memory window 0 is reserved for
this and the tuple reading services.
-
+
======================================================================*/
int pcmcia_access_configuration_register(client_handle_t handle,
@@ -872,7 +879,7 @@
config_t *c;
int addr;
u_char val;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
s = SOCKET(handle);
@@ -890,7 +897,7 @@
return CS_CONFIGURATION_LOCKED;
addr = (c->ConfigBase + reg->Offset) >> 1;
-
+
switch (reg->Action) {
case CS_READ:
read_cis_mem(s, 1, addr, 1, &val);
@@ -913,7 +920,7 @@
It is normally called by Driver Services after it has identified
a newly inserted card. An instance of that driver will then be
eligible to register as a client of this socket.
-
+
======================================================================*/
int pcmcia_bind_device(bind_req_t *req)
@@ -949,23 +956,23 @@
region. It is normally called by Driver Services after it has
identified a memory device type. An instance of the corresponding
driver will then be able to register to control this region.
-
+
======================================================================*/
int pcmcia_bind_mtd(mtd_bind_t *req)
{
socket_info_t *s;
memory_handle_t region;
-
+
if (CHECK_SOCKET(req->Socket))
return CS_BAD_SOCKET;
s = SOCKET(req);
-
+
if (req->Attributes & REGION_TYPE_AM)
region = s->a_region;
else
region = s->c_region;
-
+
while (region) {
if (region->info.CardOffset == req->CardOffset) break;
region = region->info.next;
@@ -973,7 +980,7 @@
if (!region || (region->mtd != NULL))
return CS_BAD_OFFSET;
strncpy(region->dev_info, (char *)req->dev_info, DEV_NAME_LEN);
-
+
DEBUG(1, "cs: bind_mtd(): attr 0x%x, offset 0x%x, dev %s\n",
req->Attributes, req->CardOffset, (char *)req->dev_info);
return CS_SUCCESS;
@@ -988,7 +995,7 @@
memory_handle_t region;
u_long flags;
int i, sn;
-
+
DEBUG(1, "cs: deregister_client(%p)\n", handle);
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
@@ -1007,7 +1014,7 @@
for (region = s->c_region; region; region = region->info.next)
if (region->mtd == handle) region->mtd = NULL;
}
-
+
sn = handle->Socket; s = socket_table[sn];
if ((handle->state & CLIENT_STALE) ||
@@ -1032,7 +1039,7 @@
if (--s->real_clients == 0)
register_callback(s, NULL, NULL);
-
+
return CS_SUCCESS;
} /* deregister_client */
@@ -1043,7 +1050,7 @@
{
socket_info_t *s;
config_t *c;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
s = SOCKET(handle);
@@ -1055,7 +1062,7 @@
return CS_BAD_ARGS;
} else
config->Function = handle->Function;
-
+
#ifdef CONFIG_CARDBUS
if (s->state & SOCKET_CARDBUS) {
u_char fn = config->Function;
@@ -1076,16 +1083,16 @@
return CS_SUCCESS;
}
#endif
-
+
c = (s->config != NULL) ? &s->config[config->Function] : NULL;
-
+
if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
config->Attributes = 0;
config->Vcc = s->socket.Vcc;
config->Vpp1 = config->Vpp2 = s->socket.Vpp;
return CS_SUCCESS;
}
-
+
/* !!! This is a hack !!! */
memcpy(&config->Attributes, &c->Attributes, sizeof(config_t));
config->Attributes |= CONF_VALID_CLIENT;
@@ -1099,14 +1106,14 @@
config->NumPorts2 = c->io.NumPorts2;
config->Attributes2 = c->io.Attributes2;
config->IOAddrLines = c->io.IOAddrLines;
-
+
return CS_SUCCESS;
} /* get_configuration_info */
/*======================================================================
Return information about this version of Card Services.
-
+
======================================================================*/
int pcmcia_get_card_services_info(servinfo_t *info)
@@ -1124,7 +1131,7 @@
Note that get_first_client() *does* recognize the Socket field
in the request structure.
-
+
======================================================================*/
int pcmcia_get_first_client(client_handle_t *handle, client_req_t *req)
@@ -1239,7 +1246,7 @@
Get the current socket state bits. We don't support the latched
SocketState yet: I haven't seen any point for it.
-
+
======================================================================*/
int pcmcia_get_status(client_handle_t handle, cs_status_t *status)
@@ -1247,7 +1254,7 @@
socket_info_t *s;
config_t *c;
int val;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
s = SOCKET(handle);
@@ -1263,7 +1270,7 @@
return CS_NO_CARD;
if (s->state & SOCKET_SETUP_PENDING)
status->CardState |= CS_EVENT_CARD_INSERTION;
-
+
/* Get info from the PRR, if necessary */
if (handle->Function == BIND_FN_ALL) {
if (status->Function && (status->Function >= s->functions))
@@ -1309,7 +1316,7 @@
/*======================================================================
Change the card address of an already open memory window.
-
+
======================================================================*/
int pcmcia_get_mem_page(window_handle_t win, memreq_t *req)
@@ -1338,7 +1345,7 @@
/*======================================================================
Modify a locked socket configuration
-
+
======================================================================*/
int pcmcia_modify_configuration(client_handle_t handle,
@@ -1346,7 +1353,7 @@
{
socket_info_t *s;
config_t *c;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
s = SOCKET(handle); c = CONFIG(handle);
@@ -1354,7 +1361,7 @@
return CS_NO_CARD;
if (!(c->state & CONFIG_LOCKED))
return CS_CONFIGURATION_LOCKED;
-
+
if (mod->Attributes & CONF_IRQ_CHANGE_VALID) {
if (mod->Attributes & CONF_ENABLE_IRQ) {
c->Attributes |= CONF_ENABLE_IRQ;
@@ -1406,7 +1413,7 @@
win->ctl.flags |= MAP_USE_WAIT;
win->ctl.speed = req->AccessSpeed;
set_mem_map(win->sock, &win->ctl);
-
+
return CS_SUCCESS;
} /* modify_window */
@@ -1416,7 +1423,7 @@
caller with a socket. The driver must have already been bound
to a socket with bind_device() -- in fact, bind_device()
allocates the client structure that will be used.
-
+
======================================================================*/
int pcmcia_register_client(client_handle_t *handle, client_reg_t *req)
@@ -1424,7 +1431,7 @@
client_t *client;
socket_info_t *s;
socket_t ns;
-
+
/* Look for unbound client with matching dev_info */
client = NULL;
for (ns = 0; ns < sockets; ns++) {
@@ -1464,7 +1471,7 @@
if (s->state & SOCKET_CARDBUS)
client->state |= CLIENT_CARDBUS;
-
+
if ((!(s->state & SOCKET_CARDBUS)) && (s->functions == 0) &&
(client->Function != BIND_FN_ALL)) {
cistpl_longlink_mfc_t mfc;
@@ -1479,7 +1486,7 @@
return CS_OUT_OF_RESOURCE;
memset(s->config, 0, sizeof(config_t) * s->functions);
}
-
+
DEBUG(1, "cs: register_client(): client 0x%p, sock %d, dev %s\n",
client, client->Socket, client->dev_info);
if (client->EventMask & CS_EVENT_REGISTRATION_COMPLETE)
@@ -1501,13 +1508,13 @@
pccard_io_map io = { 0, 0, 0, 0, 1 };
socket_info_t *s;
int i;
-
+
if (CHECK_HANDLE(handle) ||
!(handle->state & CLIENT_CONFIG_LOCKED))
return CS_BAD_HANDLE;
handle->state &= ~CLIENT_CONFIG_LOCKED;
s = SOCKET(handle);
-
+
#ifdef CONFIG_CARDBUS
if (handle->state & CLIENT_CARDBUS) {
cb_disable(s);
@@ -1515,7 +1522,7 @@
return CS_SUCCESS;
}
#endif
-
+
if (!(handle->state & CLIENT_STALE)) {
config_t *c = CONFIG(handle);
if (--(s->lock_count) == 0) {
@@ -1536,7 +1543,7 @@
}
c->state &= ~CONFIG_LOCKED;
}
-
+
return CS_SUCCESS;
} /* release_configuration */
@@ -1547,25 +1554,25 @@
the actual socket configuration, so if the client is "stale", we
don't bother checking the port ranges against the current socket
values.
-
+
======================================================================*/
int pcmcia_release_io(client_handle_t handle, io_req_t *req)
{
socket_info_t *s;
-
+
if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IO_REQ))
return CS_BAD_HANDLE;
handle->state &= ~CLIENT_IO_REQ;
s = SOCKET(handle);
-
+
#ifdef CONFIG_CARDBUS
if (handle->state & CLIENT_CARDBUS) {
cb_release(s);
return CS_SUCCESS;
}
#endif
-
+
if (!(handle->state & CLIENT_STALE)) {
config_t *c = CONFIG(handle);
if (c->state & CONFIG_LOCKED)
@@ -1581,7 +1588,7 @@
release_io_space(s, req->BasePort1, req->NumPorts1);
if (req->NumPorts2)
release_io_space(s, req->BasePort2, req->NumPorts2);
-
+
return CS_SUCCESS;
} /* release_io */
@@ -1594,7 +1601,7 @@
return CS_BAD_HANDLE;
handle->state &= ~CLIENT_IRQ_REQ;
s = SOCKET(handle);
-
+
if (!(handle->state & CLIENT_STALE)) {
config_t *c = CONFIG(handle);
if (c->state & CONFIG_LOCKED)
@@ -1608,16 +1615,16 @@
s->irq.AssignedIRQ = 0;
}
}
-
+
if (req->Attributes & IRQ_HANDLE_PRESENT) {
bus_free_irq(s->cap.bus, req->AssignedIRQ, req->Instance);
}
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
if (req->AssignedIRQ != s->cap.pci_irq)
undo_irq(req->Attributes, req->AssignedIRQ);
#endif
-
+
return CS_SUCCESS;
} /* cs_release_irq */
@@ -1626,7 +1633,7 @@
int pcmcia_release_window(window_handle_t win)
{
socket_info_t *s;
-
+
if ((win == NULL) || (win->magic != WINDOW_MAGIC))
return CS_BAD_HANDLE;
s = win->sock;
@@ -1640,11 +1647,11 @@
/* Release system memory */
if(!(s->cap.features & SS_CAP_STATIC_MAP))
- release_mem_region(win->base, win->size);
+ release_mem_resource(win->base, win->size);
win->handle->state &= ~CLIENT_WIN_REQ(win->index);
win->magic = 0;
-
+
return CS_SUCCESS;
} /* release_window */
@@ -1658,13 +1665,13 @@
socket_info_t *s;
config_t *c;
pccard_io_map iomap;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
i = handle->Socket; s = socket_table[i];
if (!(s->state & SOCKET_PRESENT))
return CS_NO_CARD;
-
+
#ifdef CONFIG_CARDBUS
if (handle->state & CLIENT_CARDBUS) {
if (!(req->IntType & INT_CARDBUS))
@@ -1677,7 +1684,7 @@
return CS_SUCCESS;
}
#endif
-
+
if (req->IntType & INT_CARDBUS)
return CS_UNSUPPORTED_MODE;
c = CONFIG(handle);
@@ -1692,9 +1699,9 @@
s->socket.Vpp = req->Vpp1;
if (set_socket(s, &s->socket))
return CS_BAD_VPP;
-
+
c->Vcc = req->Vcc; c->Vpp1 = c->Vpp2 = req->Vpp1;
-
+
/* Pick memory or I/O card, DMA mode, interrupt */
c->IntType = req->IntType;
c->Attributes = req->Attributes;
@@ -1712,7 +1719,7 @@
s->socket.io_irq = 0;
set_socket(s, &s->socket);
s->lock_count++;
-
+
/* Set up CIS configuration registers */
base = c->ConfigBase = req->ConfigBase;
c->Present = c->CardValues = req->Present;
@@ -1757,7 +1764,7 @@
u_char b = c->io.NumPorts1 + c->io.NumPorts2 - 1;
write_cis_mem(s, 1, (base + CISREG_IOSIZE)>>1, 1, &b);
}
-
+
/* Configure I/O windows */
if (c->state & CONFIG_IO_REQ) {
iomap.speed = io_speed;
@@ -1779,24 +1786,24 @@
s->io[i].Config++;
}
}
-
+
c->state |= CONFIG_LOCKED;
handle->state |= CLIENT_CONFIG_LOCKED;
return CS_SUCCESS;
} /* request_configuration */
/*======================================================================
-
+
Request_io() reserves ranges of port addresses for a socket.
I have not implemented range sharing or alias addressing.
-
+
======================================================================*/
int pcmcia_request_io(client_handle_t handle, io_req_t *req)
{
socket_info_t *s;
config_t *c;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
s = SOCKET(handle);
@@ -1855,7 +1862,7 @@
hooked, we don't guarantee that an irq will still be available
when the configuration is locked. Now that I think about it,
there might be a way to fix this using a dummy handler.
-
+
======================================================================*/
int pcmcia_request_irq(client_handle_t handle, irq_req_t *req)
@@ -1863,7 +1870,7 @@
socket_info_t *s;
config_t *c;
int ret = CS_IN_USE, irq = 0;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
s = SOCKET(handle);
@@ -1875,7 +1882,7 @@
if (c->state & CONFIG_IRQ_REQ)
return CS_IN_USE;
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
if (s->irq.AssignedIRQ != 0) {
/* If the interrupt is already assigned, it must match */
irq = s->irq.AssignedIRQ;
@@ -1909,7 +1916,7 @@
if (req->Attributes & IRQ_HANDLE_PRESENT) {
if (bus_request_irq(s->cap.bus, irq, req->Handler,
- ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) ||
+ ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) ||
(s->functions > 1) ||
(irq == s->cap.pci_irq)) ? SA_SHIRQ : 0,
handle->dev_info, req->Instance))
@@ -1919,7 +1926,7 @@
c->irq.Attributes = req->Attributes;
s->irq.AssignedIRQ = req->AssignedIRQ = irq;
s->irq.Config++;
-
+
c->state |= CONFIG_IRQ_REQ;
handle->state |= CLIENT_IRQ_REQ;
return CS_SUCCESS;
@@ -1938,7 +1945,7 @@
window_t *win;
u_long align;
int w;
-
+
if (CHECK_HANDLE(*handle))
return CS_BAD_HANDLE;
s = SOCKET(*handle);
@@ -2005,7 +2012,7 @@
/* Return window handle */
req->Base = win->ctl.sys_start;
*wh = win;
-
+
return CS_SUCCESS;
} /* request_window */
@@ -2014,14 +2021,14 @@
I'm not sure which "reset" function this is supposed to use,
but for now, it uses the low-level interface's reset, not the
CIS register.
-
+
======================================================================*/
int pcmcia_reset_card(client_handle_t handle, client_req_t *req)
{
int i, ret;
socket_info_t *s;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
i = handle->Socket; s = socket_table[i];
@@ -2049,14 +2056,14 @@
These shut down or wake up a socket. They are sort of user
initiated versions of the APM suspend and resume actions.
-
+
======================================================================*/
int pcmcia_suspend_card(client_handle_t handle, client_req_t *req)
{
int i;
socket_info_t *s;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
i = handle->Socket; s = socket_table[i];
@@ -2077,7 +2084,7 @@
{
int i;
socket_info_t *s;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
i = handle->Socket; s = socket_table[i];
@@ -2095,7 +2102,7 @@
/*======================================================================
These handle user requests to eject or insert a card.
-
+
======================================================================*/
int pcmcia_eject_card(client_handle_t handle, client_req_t *req)
@@ -2103,7 +2110,7 @@
int i, ret;
socket_info_t *s;
u_long flags;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
i = handle->Socket; s = socket_table[i];
@@ -2119,9 +2126,9 @@
spin_lock_irqsave(&s->lock, flags);
do_shutdown(s);
spin_unlock_irqrestore(&s->lock, flags);
-
+
return CS_SUCCESS;
-
+
} /* eject_card */
int pcmcia_insert_card(client_handle_t handle, client_req_t *req)
@@ -2129,7 +2136,7 @@
int i, status;
socket_info_t *s;
u_long flags;
-
+
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
i = handle->Socket; s = socket_table[i];
@@ -2157,7 +2164,7 @@
Maybe this should send a CS_EVENT_CARD_INSERTION event if we
haven't sent one to this client yet?
-
+
======================================================================*/
int pcmcia_set_event_mask(client_handle_t handle, eventmask_t *mask)
@@ -2189,7 +2196,7 @@
printk(KERN_NOTICE);
else
printk(KERN_NOTICE "%s: ", handle->dev_info);
-
+
for (i = 0; i < SERVICE_COUNT; i++)
if (service_table[i].key == err->func) break;
if (i < SERVICE_COUNT)
@@ -2347,13 +2354,13 @@
default:
return CS_UNSUPPORTED_FUNCTION; break;
}
-
+
} /* CardServices */
/*======================================================================
OS-specific module glue goes here
-
+
======================================================================*/
/* in alpha order */
EXPORT_SYMBOL(pcmcia_access_configuration_register);
@@ -2450,4 +2457,3 @@
module_exit(exit_pcmcia_cs);
/*====================================================================*/
-
diff -urN linux-2.4.26/drivers/pcmcia/ds.c linux-2.4.26-vrs1/drivers/pcmcia/ds.c
--- linux-2.4.26/drivers/pcmcia/ds.c 2001-11-12 17:39:01.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/pcmcia/ds.c 2004-01-14 21:32:26.000000000 +0000
@@ -55,6 +55,7 @@
#include <pcmcia/bulkmem.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ds.h>
+#include <linux/devfs_fs_kernel.h>
/*====================================================================*/
@@ -880,6 +881,8 @@
EXPORT_SYMBOL(register_pccard_driver);
EXPORT_SYMBOL(unregister_pccard_driver);
+static devfs_handle_t devfs_handle;
+
/*====================================================================*/
int __init init_pcmcia_ds(void)
@@ -957,8 +960,13 @@
if (i == -EBUSY)
printk(KERN_NOTICE "unable to find a free device # for "
"Driver Services\n");
- else
+ else {
major_dev = i;
+ devfs_handle = devfs_register(NULL, "pcmcia", DEVFS_FL_DEFAULT,
+ major_dev, 0,
+ S_IFCHR | S_IRUSR | S_IWUSR,
+ &ds_fops, NULL);
+ }
#ifdef CONFIG_PROC_FS
if (proc_pccard)
@@ -983,7 +991,9 @@
remove_proc_entry("drivers", proc_pccard);
#endif
if (major_dev != -1)
- unregister_chrdev(major_dev, "pcmcia");
+ devfs_unregister_chrdev(major_dev, "pcmcia");
+ devfs_unregister(devfs_handle);
+
for (i = 0; i < sockets; i++)
pcmcia_deregister_client(socket_table[i].handle);
sockets = 0;
diff -urN linux-2.4.26/drivers/pcmcia/i82365.c linux-2.4.26-vrs1/drivers/pcmcia/i82365.c
--- linux-2.4.26/drivers/pcmcia/i82365.c 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/pcmcia/i82365.c 2004-02-22 14:44:10.000000000 +0000
@@ -28,7 +28,7 @@
and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this
file under either the MPL or the GPL.
-
+
======================================================================*/
#include <linux/module.h>
@@ -65,6 +65,15 @@
#include "ricoh.h"
#include "o2micro.h"
+#ifdef CONFIG_ARCH_EBSA110
+#define I365_MASK (1 << 6)
+#define SOCKIRQ2REG(sock,irq) ((irq) ? ((sock) ? 3 : 4) : 0)
+#define REG2SOCKIRQ(sock,reg) (6)
+#else
+#define SOCKIRQ2REG(sock,irq) (irq)
+#define REG2SOCKIRQ(sock,reg) (reg)
+#endif
+
#ifdef PCMCIA_DEBUG
static int pc_debug = PCMCIA_DEBUG;
MODULE_PARM(pc_debug, "i");
@@ -173,13 +182,15 @@
} socket_info_t;
/* Where we keep track of our sockets... */
-static int sockets = 0;
-static socket_info_t socket[8] = {
- { 0, }, /* ... */
-};
+static int sockets /* = 0 */;
+static socket_info_t socket[8] /* = {
+ { 0, },
+} */;
/* Default ISA interrupt mask */
+#ifndef I365_MASK
#define I365_MASK 0xdeb8 /* irq 15,14,12,11,10,9,7,5,4,3 */
+#endif
static int grab_irq;
static spinlock_t isa_lock = SPIN_LOCK_UNLOCKED;
@@ -303,7 +314,7 @@
The VIA controllers also use these routines, as they are mostly
Cirrus lookalikes, without the timing registers.
-
+
======================================================================*/
#define flip(v,b,f) (v = ((f)<0) ? v : ((f) ? ((v)|(b)) : ((v)&(~b))))
@@ -389,7 +400,7 @@
Code to save and restore global state information for Vadem VG468
and VG469 controllers, and to set and report global configuration
options.
-
+
======================================================================*/
static void vg46x_get_state(u_short s)
@@ -411,7 +422,7 @@
static u_int __init vg46x_set_opts(u_short s, char *buf)
{
vg46x_state_t *p = &socket[s].state.vg46x;
-
+
flip(p->ctl, VG468_CTL_ASYNC, async_clock);
flip(p->ema, VG469_MODE_CABLE, cable_mode);
if (p->ctl & VG468_CTL_ASYNC)
@@ -436,7 +447,7 @@
/*======================================================================
Generic routines to get and set controller options
-
+
======================================================================*/
static void get_bridge_state(u_short s)
@@ -489,7 +500,7 @@
/*======================================================================
Interrupt testing code, for ISA and PCI interrupts
-
+
======================================================================*/
static volatile u_int irq_hits;
@@ -517,7 +528,7 @@
}
/* Generate one interrupt */
- i365_set(sock, I365_CSCINT, I365_CSC_DETECT | (irq << 4));
+ i365_set(sock, I365_CSCINT, I365_CSC_DETECT | (SOCKIRQ2REG(sock, irq) << 4));
i365_bset(sock, I365_GENCTL, I365_CTL_SW_IRQ);
udelay(1000);
@@ -526,7 +537,7 @@
/* mask all interrupts */
i365_set(sock, I365_CSCINT, 0);
DEBUG(2, " hits = %d\n", irq_hits);
-
+
return (irq_hits != 1);
}
@@ -540,7 +551,7 @@
/* Don't probe level-triggered interrupts -- reserved for PCI */
mask0 &= ~(inb(PIC) | (inb(PIC+1) << 8));
#endif
-
+
if (do_scan) {
set_bridge_state(sock);
i365_set(sock, I365_CSCINT, 0);
@@ -551,7 +562,7 @@
if ((mask1 & (1 << i)) && (test_irq(sock, i) != 0))
mask1 ^= (1 << i);
}
-
+
printk(KERN_INFO " ISA irqs (");
if (mask1) {
printk("scanned");
@@ -565,12 +576,12 @@
if (!cs_irq && (poll_interval == 0)) poll_interval = HZ;
}
printk(") = ");
-
+
for (i = 0; i < 16; i++)
if (mask1 & (1<<i))
printk("%s%d", ((mask1 & ((1<<i)-1)) ? "," : ""), i);
if (mask1 == 0) printk("none!");
-
+
return mask1;
}
@@ -598,14 +609,14 @@
/* Use the next free entry in the socket table */
socket[sockets].ioaddr = port;
socket[sockets].psock = sock;
-
+
/* Wake up a sleepy Cirrus controller */
if (wakeup) {
i365_bclr(sockets, PD67_MISC_CTL_2, PD67_MC2_SUSPEND);
/* Pause at least 50 ms */
mdelay(50);
}
-
+
if ((val = i365_get(sockets, I365_IDENT)) & 0x70)
return -1;
switch (val) {
@@ -618,7 +629,7 @@
case 0x88: case 0x89: case 0x8a:
type = IS_IBM; break;
}
-
+
/* Check for Vadem VG-468 chips */
outb(0x0e, port);
outb(0x37, port);
@@ -633,7 +644,7 @@
val = i365_get(sockets, RF5C_CHIP_ID);
if ((val == RF5C_CHIP_RF5C296) || (val == RF5C_CHIP_RF5C396))
type = IS_RF5Cx96;
-
+
/* Check for Cirrus CL-PD67xx chips */
i365_set(sockets, PD67_CHIP_INFO, 0);
val = i365_get(sockets, PD67_CHIP_INFO);
@@ -655,14 +666,14 @@
bound to a (non PC Card) Linux driver. We leave these alone.
We make an exception for cards that seem to be serial devices.
-
+
======================================================================*/
static int __init is_alive(u_short sock)
{
u_char stat;
u_short start, stop;
-
+
stat = i365_get(sock, I365_STATUS);
start = i365_get_pair(sock, I365_IO(0)+I365_W_START);
stop = i365_get_pair(sock, I365_IO(0)+I365_W_STOP);
@@ -697,7 +708,7 @@
base = sockets-ns;
if (t->ioaddr > 0) request_region(t->ioaddr, 2, "i82365");
-
+
if (base == 0) printk("\n");
printk(KERN_INFO " %s", pcic[type].name);
printk(" ISA-to-PCMCIA at port %#x ofs 0x%02x",
@@ -713,7 +724,7 @@
mask &= I365_MASK & set_bridge_opts(base, ns);
/* Scan for ISA interrupts */
mask = isa_scan(base, mask);
-
+
/* Poll if only two interrupts available */
if (!poll_interval) {
u_int tmp = (mask & 0xff20);
@@ -735,15 +746,15 @@
printk(" status change on irq %d\n", cs_irq);
}
}
-
+
if (!isa_irq) {
if (poll_interval == 0)
poll_interval = HZ;
printk(" polling interval = %d ms\n",
poll_interval * 1000 / HZ);
-
+
}
-
+
/* Update socket interrupt information, capabilities */
for (i = 0; i < ns; i++) {
t[i].cap.features |= SS_CAP_PCCARD;
@@ -866,12 +877,12 @@
events = pending_events[i];
pending_events[i] = 0;
spin_unlock_irq(&pending_event_lock);
- /*
- SS_DETECT events need a small delay here. The reason for this is that
+ /*
+ SS_DETECT events need a small delay here. The reason for this is that
the "is there a card" electronics need time to see the card after the
- "we have a card coming in" electronics have seen it.
+ "we have a card coming in" electronics have seen it.
*/
- if (events & SS_DETECT)
+ if (events & SS_DETECT)
mdelay(4);
if (socket[i].handler)
socket[i].handler(socket[i].info, events);
@@ -890,7 +901,7 @@
int i, j, csc;
u_int events, active;
u_long flags = 0;
-
+
DEBUG(4, "i82365: pcic_interrupt(%d)\n", irq);
for (j = 0; j < 20; j++) {
@@ -906,20 +917,20 @@
continue;
}
events = (csc & I365_CSC_DETECT) ? SS_DETECT : 0;
-
-
+
+
/* Several sockets will send multiple "new card detected"
- events in rapid succession. However, the rest of the pcmcia expects
+ events in rapid succession. However, the rest of the pcmcia expects
only one such event. We just ignore these events by having a
timeout */
if (events) {
- if ((jiffies - last_detect_jiffies)<(HZ/20))
+ if ((jiffies - last_detect_jiffies)<(HZ/20))
events = 0;
last_detect_jiffies = jiffies;
-
+
}
-
+
if (i365_get(i, I365_INTCTL) & I365_PC_IOCARD)
events |= (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0;
else {
@@ -980,11 +991,11 @@
static int i365_get_status(u_short sock, u_int *value)
{
u_int status;
-
+
status = i365_get(sock, I365_STATUS);
*value = ((status & I365_CS_DETECT) == I365_CS_DETECT)
? SS_DETECT : 0;
-
+
if (i365_get(sock, I365_INTCTL) & I365_PC_IOCARD)
*value |= (status & I365_CS_STSCHG) ? 0 : SS_STSCHG;
else {
@@ -1005,7 +1016,7 @@
*value |= (status & VG469_VSENSE_A_VS2) ? 0 : SS_XVCARD;
}
}
-
+
DEBUG(1, "i82365: GetStatus(%d) = %#4.4x\n", sock, *value);
return 0;
} /* i365_get_status */
@@ -1016,7 +1027,7 @@
{
socket_info_t *t = &socket[sock];
u_char reg, vcc, vpp;
-
+
reg = i365_get(sock, I365_POWER);
state->flags = (reg & I365_PWR_AUTO) ? SS_PWR_AUTO : 0;
state->flags |= (reg & I365_PWR_OUT) ? SS_OUTPUT_ENA : 0;
@@ -1057,14 +1068,14 @@
reg = i365_get(sock, I365_INTCTL);
state->flags |= (reg & I365_PC_RESET) ? 0 : SS_RESET;
if (reg & I365_PC_IOCARD) state->flags |= SS_IOCARD;
- state->io_irq = reg & I365_IRQ_MASK;
-
+ state->io_irq = REG2SOCKIRQ(sock, reg & I365_IRQ_MASK);
+
/* speaker control */
if (t->flags & IS_CIRRUS) {
if (i365_get(sock, PD67_MISC_CTL_1) & PD67_MC1_SPKR_ENA)
state->flags |= SS_SPKR_ENA;
}
-
+
/* Card status change mask */
reg = i365_get(sock, I365_CSCINT);
state->csc_mask = (reg & I365_CSC_DETECT) ? SS_DETECT : 0;
@@ -1075,7 +1086,7 @@
state->csc_mask |= (reg & I365_CSC_BVD2) ? SS_BATWARN : 0;
state->csc_mask |= (reg & I365_CSC_READY) ? SS_READY : 0;
}
-
+
DEBUG(1, "i82365: GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
"io_irq %d, csc_mask %#2.2x\n", sock, state->flags,
state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
@@ -1088,21 +1099,21 @@
{
socket_info_t *t = &socket[sock];
u_char reg;
-
+
DEBUG(1, "i82365: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
"io_irq %d, csc_mask %#2.2x)\n", sock, state->flags,
state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
-
+
/* First set global controller options */
set_bridge_state(sock);
-
+
/* IO card, RESET flag, IO interrupt */
reg = t->intr;
- reg |= state->io_irq;
+ reg |= SOCKIRQ2REG(sock, state->io_irq);
reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET;
reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0;
i365_set(sock, I365_INTCTL, reg);
-
+
reg = I365_PWR_NORESET;
if (state->flags & SS_PWR_AUTO) reg |= I365_PWR_AUTO;
if (state->flags & SS_OUTPUT_ENA) reg |= I365_PWR_OUT;
@@ -1165,7 +1176,7 @@
default: return -EINVAL;
}
}
-
+
if (reg != i365_get(sock, I365_POWER))
i365_set(sock, I365_POWER, reg);
@@ -1175,9 +1186,9 @@
i365_bflip(sock, PD67_MISC_CTL_1, PD67_MC1_SPKR_ENA,
state->flags & SS_SPKR_ENA);
}
-
+
/* Card status change interrupt mask */
- reg = t->cs_irq << 4;
+ reg = SOCKIRQ2REG(sock, t->cs_irq) << 4;
if (state->csc_mask & SS_DETECT) reg |= I365_CSC_DETECT;
if (state->flags & SS_IOCARD) {
if (state->csc_mask & SS_STSCHG) reg |= I365_CSC_STSCHG;
@@ -1188,7 +1199,7 @@
}
i365_set(sock, I365_CSCINT, reg);
i365_get(sock, I365_CSC);
-
+
return 0;
} /* i365_set_socket */
@@ -1197,7 +1208,7 @@
static int i365_get_io_map(u_short sock, struct pccard_io_map *io)
{
u_char map, ioctl, addr;
-
+
map = io->map;
if (map > 1) return -EINVAL;
io->start = i365_get_pair(sock, I365_IO(map)+I365_W_START);
@@ -1220,7 +1231,7 @@
static int i365_set_io_map(u_short sock, struct pccard_io_map *io)
{
u_char map, ioctl;
-
+
DEBUG(1, "i82365: SetIOMap(%d, %d, %#2.2x, %d ns, "
"%#4.4x-%#4.4x)\n", sock, io->map, io->flags,
io->speed, io->start, io->stop);
@@ -1250,30 +1261,30 @@
{
u_short base, i;
u_char map, addr;
-
+
map = mem->map;
if (map > 4) return -EINVAL;
addr = i365_get(sock, I365_ADDRWIN);
mem->flags = (addr & I365_ENA_MEM(map)) ? MAP_ACTIVE : 0;
base = I365_MEM(map);
-
+
i = i365_get_pair(sock, base+I365_W_START);
mem->flags |= (i & I365_MEM_16BIT) ? MAP_16BIT : 0;
mem->flags |= (i & I365_MEM_0WS) ? MAP_0WS : 0;
mem->sys_start = ((u_long)(i & 0x0fff) << 12);
-
+
i = i365_get_pair(sock, base+I365_W_STOP);
mem->speed = (i & I365_MEM_WS0) ? 1 : 0;
mem->speed += (i & I365_MEM_WS1) ? 2 : 0;
mem->speed = to_ns(mem->speed);
mem->sys_stop = ((u_long)(i & 0x0fff) << 12) + 0x0fff;
-
+
i = i365_get_pair(sock, base+I365_W_OFF);
mem->flags |= (i & I365_MEM_WRPROT) ? MAP_WRPROT : 0;
mem->flags |= (i & I365_MEM_REG) ? MAP_ATTRIB : 0;
mem->card_start = ((u_int)(i & 0x3fff) << 12) + mem->sys_start;
mem->card_start &= 0x3ffffff;
-
+
DEBUG(1, "i82365: GetMemMap(%d, %d) = %#2.2x, %d ns, %#5.5lx-%#5."
"5lx, %#5.5x\n", sock, mem->map, mem->flags, mem->speed,
mem->sys_start, mem->sys_stop, mem->card_start);
@@ -1281,12 +1292,12 @@
} /* i365_get_mem_map */
/*====================================================================*/
-
+
static int i365_set_mem_map(u_short sock, struct pccard_mem_map *mem)
{
u_short base, i;
u_char map;
-
+
DEBUG(1, "i82365: SetMemMap(%d, %d, %#2.2x, %d ns, %#5.5lx-%#5.5"
"lx, %#5.5x)\n", sock, mem->map, mem->flags, mem->speed,
mem->sys_start, mem->sys_stop, mem->card_start);
@@ -1297,17 +1308,17 @@
return -EINVAL;
if ((mem->sys_start > 0xffffff) || (mem->sys_stop > 0xffffff))
return -EINVAL;
-
+
/* Turn off the window before changing anything */
if (i365_get(sock, I365_ADDRWIN) & I365_ENA_MEM(map))
i365_bclr(sock, I365_ADDRWIN, I365_ENA_MEM(map));
-
+
base = I365_MEM(map);
i = (mem->sys_start >> 12) & 0x0fff;
if (mem->flags & MAP_16BIT) i |= I365_MEM_16BIT;
if (mem->flags & MAP_0WS) i |= I365_MEM_0WS;
i365_set_pair(sock, base+I365_W_START, i);
-
+
i = (mem->sys_stop >> 12) & 0x0fff;
switch (to_cycles(mem->speed)) {
case 0: break;
@@ -1316,12 +1327,12 @@
default: i |= I365_MEM_WS1 | I365_MEM_WS0; break;
}
i365_set_pair(sock, base+I365_W_STOP, i);
-
+
i = ((mem->card_start - mem->sys_start) >> 12) & 0x3fff;
if (mem->flags & MAP_WRPROT) i |= I365_MEM_WRPROT;
if (mem->flags & MAP_ATTRIB) i |= I365_MEM_REG;
i365_set_pair(sock, base+I365_W_OFF, i);
-
+
/* Turn on the window if necessary */
if (mem->flags & MAP_ACTIVE)
i365_bset(sock, I365_ADDRWIN, I365_ENA_MEM(map));
@@ -1332,7 +1343,7 @@
Routines for accessing socket information and register dumps via
/proc/bus/pccard/...
-
+
======================================================================*/
#ifdef CONFIG_PROC_FS
@@ -1353,7 +1364,7 @@
u_short sock = (socket_info_t *)data - socket;
char *p = buf;
int i, top;
-
+
u_long flags = 0;
ISA_LOCK(sock, flags);
top = 0x40;
@@ -1399,7 +1410,7 @@
/*====================================================================*/
-/* this is horribly ugly... proper locking needs to be done here at
+/* this is horribly ugly... proper locking needs to be done here at
* some time... */
#define LOCKED(x) do { \
int retval; \
@@ -1532,7 +1543,7 @@
/* Set up interrupt handler(s) */
if (grab_irq != 0)
request_irq(cs_irq, pcic_interrupt, 0, "i82365", pcic_interrupt);
-
+
if (register_ss_entry(sockets, &pcic_operations) != 0)
printk(KERN_NOTICE "i82365: register_ss_entry() failed\n");
@@ -1544,9 +1555,9 @@
poll_timer.expires = jiffies + poll_interval;
add_timer(&poll_timer);
}
-
+
return 0;
-
+
} /* init_i82365 */
static void __exit exit_i82365(void)
diff -urN linux-2.4.26/drivers/pcmcia/rsrc_mgr.c linux-2.4.26-vrs1/drivers/pcmcia/rsrc_mgr.c
--- linux-2.4.26/drivers/pcmcia/rsrc_mgr.c 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/pcmcia/rsrc_mgr.c 2004-02-23 13:36:32.000000000 +0000
@@ -28,7 +28,7 @@
and other provisions required by the GPL. If you do not delete
the provisions above, a recipient may use your version of this
file under either the MPL or the GPL.
-
+
======================================================================*/
#define __NO_VERSION__
@@ -55,6 +55,10 @@
#include <pcmcia/cistpl.h>
#include "cs_internal.h"
+#ifndef ISAMEM_PHYS
+#define ISAMEM_PHYS 0
+#endif
+
/*====================================================================*/
/* Parameters that can be set with 'insmod' */
@@ -62,7 +66,7 @@
#define INT_MODULE_PARM(n, v) static int n = v; MODULE_PARM(n, "i")
INT_MODULE_PARM(probe_mem, 1); /* memory probe? */
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
INT_MODULE_PARM(probe_io, 1); /* IO port probe? */
INT_MODULE_PARM(mem_limit, 0x10000);
#endif
@@ -85,7 +89,7 @@
/* IO port resource database */
static resource_map_t io_db = { 0, 0, &io_db };
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
typedef struct irq_info_t {
u_int Attributes;
@@ -133,6 +137,7 @@
static inline int check_mem_resource(unsigned long b, unsigned long n,
struct pci_dev *dev)
{
+ b += ISAMEM_PHYS;
return check_resource(resource_parent(b, n, IORESOURCE_MEM, dev), b, n);
}
@@ -169,10 +174,15 @@
static int request_mem_resource(unsigned long b, unsigned long n,
char *name, struct pci_dev *dev)
{
- struct resource *res = make_resource(b, n, IORESOURCE_MEM, name);
- struct resource *pr = resource_parent(b, n, IORESOURCE_MEM, dev);
+ struct resource *res;
+ struct resource *pr;
int err = -ENOMEM;
+ b += ISAMEM_PHYS;
+
+ res = make_resource(b, n, IORESOURCE_MEM, name);
+ pr = resource_parent(b, n, IORESOURCE_MEM, dev);
+
if (res) {
err = request_resource(pr, res);
if (err)
@@ -181,10 +191,16 @@
return err;
}
+void release_mem_resource(unsigned long b, unsigned long n)
+{
+ b += ISAMEM_PHYS;
+ release_mem_region(b, n);
+}
+
/*======================================================================
These manage the internal databases of available resources.
-
+
======================================================================*/
static int add_interval(resource_map_t *map, u_long base, u_long num)
@@ -248,25 +264,25 @@
These routines examine a region of IO or memory addresses to
determine what ranges might be genuinely available.
-
+
======================================================================*/
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
static void do_io_probe(ioaddr_t base, ioaddr_t num)
{
-
+
ioaddr_t i, j, bad, any;
u_char *b, hole, most;
-
+
printk(KERN_INFO "cs: IO port probe 0x%04x-0x%04x:",
base, base+num-1);
-
+
/* First, what does a floating port look like? */
b = kmalloc(256, GFP_KERNEL);
if (!b) {
printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes");
return;
- }
+ }
memset(b, 0, 256);
for (i = base, most = 0; i < base+num; i += 8) {
if (check_io_resource(i, 8, NULL))
@@ -308,7 +324,7 @@
printk(" %#04x-%#04x", bad, i-1);
}
}
-
+
printk(any ? "\n" : " clean.\n");
}
#endif
@@ -318,7 +334,7 @@
The memory probe. If the memory list includes a 64K-aligned block
below 1MB, we probe in 64K chunks, and as soon as we accumulate at
least mem_limit free space, we quit.
-
+
======================================================================*/
static int do_mem_probe(u_long base, u_long num,
@@ -332,7 +348,7 @@
bad = fail = 0;
step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff);
for (i = j = base; i < base+num; i = j + step) {
- if (!fail) {
+ if (!fail) {
for (j = i; j < base+num; j += step)
if ((check_mem_resource(j, step, s->cap.cb_dev) == 0) &&
is_valid(j))
@@ -356,7 +372,7 @@
return (num - bad);
}
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
static u_long inv_probe(int (*is_valid)(u_long),
int (*do_cksum)(u_long),
@@ -383,7 +399,7 @@
static u_char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 };
static int hi = 0, lo = 0;
u_long b, i, ok = 0;
-
+
if (!probe_mem) return;
/* We do up to four passes through the list */
if (!force_low) {
@@ -414,14 +430,14 @@
}
}
-#else /* CONFIG_ISA */
+#else /* CONFIG_PCMCIA_PROBE */
void validate_mem(int (*is_valid)(u_long), int (*do_cksum)(u_long),
int force_low, socket_info_t *s)
{
resource_map_t *m, *n;
static int done = 0;
-
+
if (!probe_mem || done++)
return;
@@ -432,7 +448,7 @@
}
}
-#endif /* CONFIG_ISA */
+#endif /* CONFIG_PCMCIA_PROBE */
/*======================================================================
@@ -444,7 +460,7 @@
should be a power of two, greater than or equal to 'num'. A value
of 0 means that all bits of *base are significant. *base should
also be strictly less than 'align'.
-
+
======================================================================*/
int find_io_region(ioaddr_t *base, ioaddr_t num, ioaddr_t align,
@@ -452,7 +468,7 @@
{
ioaddr_t try;
resource_map_t *m;
-
+
for (m = io_db.next; m != &io_db; m = m->next) {
try = (m->base & ~(align-1)) + *base;
for (try = (try >= m->base) ? try : try+align;
@@ -500,10 +516,10 @@
This checks to see if an interrupt is available, with support
for interrupt sharing. We don't support reserving interrupts
yet. If the interrupt is available, we allocate it.
-
+
======================================================================*/
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
static void fake_irq(int i, void *d, struct pt_regs *r) { }
static inline int check_irq(int irq)
@@ -570,7 +586,7 @@
/*====================================================================*/
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
void undo_irq(u_int Attributes, int irq)
{
@@ -600,7 +616,7 @@
The various adjust_* calls form the external interface to the
resource database.
-
+
======================================================================*/
static int adjust_memory(adjust_t *adj)
@@ -632,7 +648,7 @@
default:
ret = CS_UNSUPPORTED_FUNCTION;
}
-
+
return ret;
}
@@ -641,7 +657,7 @@
static int adjust_io(adjust_t *adj)
{
int base, num;
-
+
base = adj->resource.io.BasePort;
num = adj->resource.io.NumPorts;
if ((base < 0) || (base > 0xffff))
@@ -653,7 +669,7 @@
case ADD_MANAGED_RESOURCE:
if (add_interval(&io_db, base, num) != 0)
return CS_IN_USE;
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
if (probe_io)
do_io_probe(base, num);
#endif
@@ -673,15 +689,15 @@
static int adjust_irq(adjust_t *adj)
{
-#ifdef CONFIG_ISA
+#ifdef CONFIG_PCMCIA_PROBE
int irq;
irq_info_t *info;
-
+
irq = adj->resource.irq.IRQ;
if ((irq < 0) || (irq > 15))
return CS_BAD_IRQ;
info = &irq_table[irq];
-
+
switch (adj->Action) {
case ADD_MANAGED_RESOURCE:
if (info->Attributes & RES_REMOVED)
@@ -716,7 +732,7 @@
{
if (CHECK_HANDLE(handle))
return CS_BAD_HANDLE;
-
+
switch (adj->Resource) {
case RES_MEMORY_RANGE:
return adjust_memory(adj);
@@ -736,7 +752,7 @@
void release_resource_db(void)
{
resource_map_t *p, *q;
-
+
for (p = mem_db.next; p != &mem_db; p = q) {
q = p->next;
kfree(p);
diff -urN linux-2.4.26/drivers/pcmcia/sa1100.h linux-2.4.26-vrs1/drivers/pcmcia/sa1100.h
--- linux-2.4.26/drivers/pcmcia/sa1100.h 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100.h 2004-01-14 21:32:26.000000000 +0000
@@ -204,7 +204,9 @@
extern struct pcmcia_low_level flexanet_pcmcia_ops;
extern struct pcmcia_low_level simpad_pcmcia_ops;
extern struct pcmcia_low_level graphicsmaster_pcmcia_ops;
+extern struct pcmcia_low_level adsagc_pcmcia_ops;
extern struct pcmcia_low_level adsbitsy_pcmcia_ops;
+extern struct pcmcia_low_level adsbitsyplus_pcmcia_ops;
extern struct pcmcia_low_level stork_pcmcia_ops;
extern struct pcmcia_low_level badge4_pcmcia_ops;
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_adsbitsy.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_adsbitsy.c
--- linux-2.4.26/drivers/pcmcia/sa1100_adsbitsy.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_adsbitsy.c 2004-01-14 21:32:26.000000000 +0000
@@ -11,28 +11,156 @@
*/
#include <linux/kernel.h>
#include <linux/sched.h>
+#include <linux/ioport.h>
#include <asm/hardware.h>
+#include <asm/hardware/sa1111.h>
+#include <asm/irq.h>
#include "sa1100_generic.h"
#include "sa1111_generic.h"
+int adsbitsy_smc91111_present(void);
+
+#ifndef CONFIG_SMC91111
+#define adsbitsy_smc91111_present() 0
+#endif
+
+static struct irqs {
+ int irq;
+ const char *str;
+} irqs[] = {
+ { S0_CD_VALID, "SA1111 PCMCIA card detect" },
+ { S0_BVD1_STSCHG, "SA1111 PCMCIA BVD1" },
+ { S1_CD_VALID, "SA1111 CF card detect" },
+ { S1_BVD1_STSCHG, "SA1111 CF BVD1" },
+};
+
static int adsbitsy_pcmcia_init(struct pcmcia_init *init)
{
- /* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
- PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
+ int ret=0;
+ int nirq = 0;
+ int slots = 0;
+ int i;
+
+ /* Set GPIO_A<1:0> to be outputs for PCMCIA power controller: */
+ PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1);
+
+ /* Disable Power 3.3V/5V for PCMCIA */
+ PA_DWR |= GPIO_GPIO0 | GPIO_GPIO1;
+
+ if (!request_mem_region(_PCCR, 512, "PCMCIA"))
+ return -1;
+
+
+ INTPOL1 |= SA1111_IRQMASK_HI(S0_READY_NINT) |
+ SA1111_IRQMASK_HI(S0_CD_VALID) |
+ SA1111_IRQMASK_HI(S0_BVD1_STSCHG);
- /* Disable Power 3.3V/5V for PCMCIA/CF */
- PA_DWR |= GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3;
+ nirq = 2;
+ slots = 1;
+
+ if (!adsbitsy_smc91111_present()) {
+ /* If the SMC91111 is used CF cannot be used */
+ /* Set GPIO_A<3:2> to be outputs for CF power controller: */
+ PA_DDR &= ~(GPIO_GPIO2 | GPIO_GPIO3);
+
+ /* Disable Power 3.3V/5V for CF */
+ PA_DWR |= GPIO_GPIO2 | GPIO_GPIO3;
+
+ INTPOL1 |= SA1111_IRQMASK_HI(S1_READY_NINT) |
+ SA1111_IRQMASK_HI(S1_CD_VALID) |
+ SA1111_IRQMASK_HI(S1_BVD1_STSCHG);
+
+ nirq = 4;
+ slots = 2;
+ }
+
+ for (i = ret = 0; i < nirq; i++) {
+ ret = request_irq(irqs[i].irq, init->handler, SA_INTERRUPT,
+ irqs[i].str, NULL);
+ if (ret)
+ break;
+ }
- /* Why? */
- MECR = 0x09430943;
+ if (i < nirq) {
+ printk(KERN_ERR "sa1111_pcmcia: unable to grab IRQ%d (%d)\n",
+ irqs[i].irq, ret);
+ while (i--)
+ free_irq(irqs[i].irq, NULL);
- return sa1111_pcmcia_init(init);
+ release_mem_region(_PCCR, 16);
+ }
+
+ return ret ? -1 : slots;
+}
+
+static int adsbitsy_pcmcia_shutdown(void)
+{
+
+ free_irq(S0_CD_VALID, NULL);
+ free_irq(S0_BVD1_STSCHG, NULL);
+ INTPOL1 &= ~(SA1111_IRQMASK_HI(S0_CD_VALID) | SA1111_IRQMASK_HI(S0_BVD1_STSCHG));
+
+ if (!adsbitsy_smc91111_present()) {
+ free_irq(S1_CD_VALID, NULL);
+ free_irq(S1_BVD1_STSCHG, NULL);
+ INTPOL1 &= ~(SA1111_IRQMASK_HI(S1_CD_VALID) | SA1111_IRQMASK_HI(S1_BVD1_STSCHG));
+ }
+
+ return 0;
}
-static int
-adsbitsy_pcmcia_configure_socket(const struct pcmcia_configure *conf)
+
+static int adsbitsy_pcmcia_socket_state(struct pcmcia_state_array *state)
+{
+ unsigned long status;
+
+ if (adsbitsy_smc91111_present()) {
+ if(state->size<1) return -1;
+ }
+ else
+ if(state->size<2) return -1;
+
+ memset(state->state, 0,
+ (state->size)*sizeof(struct pcmcia_state));
+
+ status = PCSR;
+
+ state->state[0].detect = status & PCSR_S0_DETECT ? 0 : 1;
+ state->state[0].ready = status & PCSR_S0_READY ? 1 : 0;
+ state->state[0].bvd1 = status & PCSR_S0_BVD1 ? 1 : 0;
+ state->state[0].bvd2 = status & PCSR_S0_BVD2 ? 1 : 0;
+ state->state[0].wrprot = status & PCSR_S0_WP ? 1 : 0;
+ state->state[0].vs_3v = status & PCSR_S0_VS1 ? 0 : 1;
+ state->state[0].vs_Xv = status & PCSR_S0_VS2 ? 0 : 1;
+
+ if (state->size > 1) {
+ if (adsbitsy_smc91111_present()) {
+ // If there is SMC91111 on ADS Bitsy connector board
+ // it returns not detect/ready/...
+ state->state[1].detect = 0;
+ state->state[1].ready = 0;
+ state->state[1].bvd1 = 0;
+ state->state[1].bvd2 = 0;
+ state->state[1].wrprot = 0;
+ state->state[1].vs_3v = 0;
+ state->state[1].vs_Xv = 0;
+ }
+ else {
+ state->state[1].detect = status & PCSR_S1_DETECT ? 0 : 1;
+ state->state[1].ready = status & PCSR_S1_READY ? 1 : 0;
+ state->state[1].bvd1 = status & PCSR_S1_BVD1 ? 1 : 0;
+ state->state[1].bvd2 = status & PCSR_S1_BVD2 ? 1 : 0;
+ state->state[1].wrprot = status & PCSR_S1_WP ? 1 : 0;
+ state->state[1].vs_3v = status & PCSR_S1_VS1 ? 0 : 1;
+ state->state[1].vs_Xv = status & PCSR_S1_VS2 ? 0 : 1;
+ }
+ }
+ return 1;
+}
+
+static int adsbitsy_pcmcia_configure_socket(const struct pcmcia_configure *conf)
{
unsigned int pa_dwr_mask, pa_dwr_set;
int ret;
@@ -54,10 +182,11 @@
switch (conf->vcc) {
default:
- case 0: pa_dwr_set = 0; break;
+ case 0: pa_dwr_set = GPIO_GPIO2 | GPIO_GPIO3; break;
case 33: pa_dwr_set = GPIO_GPIO2; break;
case 50: pa_dwr_set = GPIO_GPIO3; break;
}
+ break;
default:
return -1;
@@ -83,8 +212,8 @@
struct pcmcia_low_level adsbitsy_pcmcia_ops = {
init: adsbitsy_pcmcia_init,
- shutdown: sa1111_pcmcia_shutdown,
- socket_state: sa1111_pcmcia_socket_state,
+ shutdown: adsbitsy_pcmcia_shutdown,
+ socket_state: adsbitsy_pcmcia_socket_state,
get_irq_info: sa1111_pcmcia_get_irq_info,
configure_socket: adsbitsy_pcmcia_configure_socket,
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_adsbitsyplus.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_adsbitsyplus.c
--- linux-2.4.26/drivers/pcmcia/sa1100_adsbitsyplus.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_adsbitsyplus.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,236 @@
+/*
+ * drivers/pcmcia/sa1100_adsbitsyplus.c
+ *
+ * PCMCIA implementation routines for ADS Bitsy Plus
+ *
+ * Created Feb 7, 2003 by Robert Whaley <rwhaley@applieddata.net>
+ *
+ * This file comes from sa1100_adsbitsy.c of Woojung Huh <whuh@applieddata.net>
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+
+#include <asm/hardware.h>
+#include <asm/hardware/sa1111.h>
+#include <asm/irq.h>
+
+#include "sa1100_generic.h"
+#include "sa1111_generic.h"
+
+int adsbitsy_smc91111_present(void);
+
+#ifndef CONFIG_SMC91111
+#define adsbitsy_smc91111_present() 0
+#endif
+
+static struct irqs {
+ int irq;
+ const char *str;
+} irqs[] = {
+ { S0_CD_VALID, "SA1111 PCMCIA card detect" },
+ { S0_BVD1_STSCHG, "SA1111 PCMCIA BVD1" },
+ { S1_CD_VALID, "SA1111 CF card detect" },
+ { S1_BVD1_STSCHG, "SA1111 CF BVD1" },
+};
+
+#define sock0_3_3_reverse_logic() ((ADS_CPLD_IO2 & ADS_IO2_CPLD_REV_MASK) >= ADS_IO2_CPLD_REV_5_MAGIC)
+
+static int adsbitsyplus_pcmcia_init(struct pcmcia_init *init)
+{
+ int ret=0;
+ int nirq = 0;
+ int slots = 0;
+ int i;
+
+ /* Set GPIO_A<1:0> to be outputs for PCMCIA power controller: */
+ PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1);
+
+ /* Disable Power 3.3V/5V for PCMCIA */
+ if (sock0_3_3_reverse_logic())
+ PA_DWR = (PA_DWR & ~GPIO_GPIO0) | GPIO_GPIO1;
+ else
+ PA_DWR |= GPIO_GPIO0 | GPIO_GPIO1;
+
+ if (!request_mem_region(_PCCR, 512, "PCMCIA"))
+ return -1;
+
+
+ INTPOL1 |= SA1111_IRQMASK_HI(S0_READY_NINT) |
+ SA1111_IRQMASK_HI(S0_CD_VALID) |
+ SA1111_IRQMASK_HI(S0_BVD1_STSCHG);
+
+ nirq = 2;
+ slots = 1;
+
+ if (!adsbitsy_smc91111_present()) {
+ /* If the SMC91111 is used CF cannot be used */
+ /* Set GPIO_A<3:2> to be outputs for CF power controller: */
+ PA_DDR &= ~(GPIO_GPIO2 | GPIO_GPIO3);
+
+ /* Disable Power 3.3V/5V for CF */
+ PA_DWR |= GPIO_GPIO2 | GPIO_GPIO3;
+
+ INTPOL1 |= SA1111_IRQMASK_HI(S1_READY_NINT) |
+ SA1111_IRQMASK_HI(S1_CD_VALID) |
+ SA1111_IRQMASK_HI(S1_BVD1_STSCHG);
+
+ nirq = 4;
+ slots = 2;
+ }
+
+ for (i = ret = 0; i < nirq; i++) {
+ ret = request_irq(irqs[i].irq, init->handler, SA_INTERRUPT,
+ irqs[i].str, NULL);
+ if (ret)
+ break;
+ }
+
+ if (i < nirq) {
+ printk(KERN_ERR "sa1111_pcmcia: unable to grab IRQ%d (%d)\n",
+ irqs[i].irq, ret);
+ while (i--)
+ free_irq(irqs[i].irq, NULL);
+
+ release_mem_region(_PCCR, 16);
+ }
+
+ return ret ? -1 : slots;
+}
+
+static int adsbitsyplus_pcmcia_shutdown(void)
+{
+
+ free_irq(S0_CD_VALID, NULL);
+ free_irq(S0_BVD1_STSCHG, NULL);
+ INTPOL1 &= ~(SA1111_IRQMASK_HI(S0_CD_VALID) | SA1111_IRQMASK_HI(S0_BVD1_STSCHG));
+
+ if (!adsbitsy_smc91111_present()) {
+ free_irq(S1_CD_VALID, NULL);
+ free_irq(S1_BVD1_STSCHG, NULL);
+ INTPOL1 &= ~(SA1111_IRQMASK_HI(S1_CD_VALID) | SA1111_IRQMASK_HI(S1_BVD1_STSCHG));
+ }
+
+ return 0;
+}
+
+
+static int adsbitsyplus_pcmcia_socket_state(struct pcmcia_state_array *state)
+{
+ unsigned long status;
+
+ if (adsbitsy_smc91111_present()) {
+ if(state->size<1) return -1;
+ }
+ else
+ if(state->size<2) return -1;
+
+ memset(state->state, 0,
+ (state->size)*sizeof(struct pcmcia_state));
+
+ status = PCSR;
+
+ state->state[0].detect = status & PCSR_S0_DETECT ? 0 : 1;
+ state->state[0].ready = status & PCSR_S0_READY ? 1 : 0;
+ state->state[0].bvd1 = status & PCSR_S0_BVD1 ? 1 : 0;
+ state->state[0].bvd2 = status & PCSR_S0_BVD2 ? 1 : 0;
+ state->state[0].wrprot = status & PCSR_S0_WP ? 1 : 0;
+ state->state[0].vs_3v = status & PCSR_S0_VS1 ? 0 : 1;
+ state->state[0].vs_Xv = status & PCSR_S0_VS2 ? 0 : 1;
+
+ if (state->size > 1) {
+ if (adsbitsy_smc91111_present()) {
+ // If there is SMC91111 on ADS Bitsy connector board
+ // it returns not detect/ready/...
+ state->state[1].detect = 0;
+ state->state[1].ready = 0;
+ state->state[1].bvd1 = 0;
+ state->state[1].bvd2 = 0;
+ state->state[1].wrprot = 0;
+ state->state[1].vs_3v = 0;
+ state->state[1].vs_Xv = 0;
+ }
+ else {
+ state->state[1].detect = status & PCSR_S1_DETECT ? 0 : 1;
+ state->state[1].ready = status & PCSR_S1_READY ? 1 : 0;
+ state->state[1].bvd1 = status & PCSR_S1_BVD1 ? 1 : 0;
+ state->state[1].bvd2 = status & PCSR_S1_BVD2 ? 1 : 0;
+ state->state[1].wrprot = status & PCSR_S1_WP ? 1 : 0;
+ state->state[1].vs_3v = status & PCSR_S1_VS1 ? 0 : 1;
+ state->state[1].vs_Xv = status & PCSR_S1_VS2 ? 0 : 1;
+ }
+ }
+ return 1;
+}
+
+static int adsbitsyplus_pcmcia_configure_socket(const struct pcmcia_configure *conf)
+{
+ unsigned int pa_dwr_mask, pa_dwr_set;
+ int ret;
+
+ switch (conf->sock) {
+ case 0:
+ pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1;
+
+ if (sock0_3_3_reverse_logic()) {
+ switch (conf->vcc) {
+ default:
+ case 0: pa_dwr_set = GPIO_GPIO1; break;
+ case 33: pa_dwr_set = GPIO_GPIO0 | GPIO_GPIO1; break;
+ case 50: pa_dwr_set = 0; break;
+ }
+ } else {
+ switch (conf->vcc) {
+ default:
+ case 0: pa_dwr_set = GPIO_GPIO0 | GPIO_GPIO1; break;
+ case 33: pa_dwr_set = GPIO_GPIO1; break;
+ case 50: pa_dwr_set = GPIO_GPIO0; break;
+ }
+ }
+ break;
+
+ case 1:
+ pa_dwr_mask = GPIO_GPIO2 | GPIO_GPIO3;
+
+ switch (conf->vcc) {
+ default:
+ case 0: pa_dwr_set = GPIO_GPIO2 | GPIO_GPIO3; break;
+ case 33: pa_dwr_set = GPIO_GPIO2; break;
+ case 50: pa_dwr_set = GPIO_GPIO3; break;
+ }
+ break;
+
+ default:
+ return -1;
+ }
+
+ if (conf->vpp != conf->vcc && conf->vpp != 0) {
+ printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n",
+ __FUNCTION__, conf->vpp);
+ return -1;
+ }
+
+ ret = sa1111_pcmcia_configure_socket(conf);
+ if (ret == 0) {
+ unsigned long flags;
+
+ local_irq_save(flags);
+ PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
+ local_irq_restore(flags);
+ }
+
+ return ret;
+}
+
+struct pcmcia_low_level adsbitsyplus_pcmcia_ops = {
+ init: adsbitsyplus_pcmcia_init,
+ shutdown: adsbitsyplus_pcmcia_shutdown,
+ socket_state: adsbitsyplus_pcmcia_socket_state,
+ get_irq_info: sa1111_pcmcia_get_irq_info,
+ configure_socket: adsbitsyplus_pcmcia_configure_socket,
+
+ socket_init: sa1111_pcmcia_socket_init,
+ socket_suspend: sa1111_pcmcia_socket_suspend,
+};
+
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_freebird.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_freebird.c
--- linux-2.4.26/drivers/pcmcia/sa1100_freebird.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_freebird.c 2004-01-14 21:32:26.000000000 +0000
@@ -67,9 +67,6 @@
if(state_array->size<2) return -1;
- memset(state_array->state, 0,
- (state_array->size)*sizeof(struct pcmcia_state));
-
levels = LINKUP_PRS;
//printk("LINKUP_PRS=%x \n",levels);
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_generic.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_generic.c
--- linux-2.4.26/drivers/pcmcia/sa1100_generic.c 2003-06-13 15:51:35.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_generic.c 2004-01-14 21:32:26.000000000 +0000
@@ -992,10 +992,18 @@
if(machine_is_graphicsmaster())
pcmcia_low_level = &graphicsmaster_pcmcia_ops;
#endif
+#ifdef CONFIG_SA1100_ADSAGC
+ if(machine_is_adsagc())
+ pcmcia_low_level = &graphicsmaster_pcmcia_ops;
+#endif
#ifdef CONFIG_SA1100_ADSBITSY
if(machine_is_adsbitsy())
pcmcia_low_level = &adsbitsy_pcmcia_ops;
#endif
+#ifdef CONFIG_SA1100_ADSBITSYPLUS
+ if(machine_is_adsbitsyplus())
+ pcmcia_low_level = &adsbitsyplus_pcmcia_ops;
+#endif
#ifdef CONFIG_SA1100_STORK
if(machine_is_stork())
pcmcia_low_level = &stork_pcmcia_ops;
@@ -1067,7 +1075,7 @@
* We initialize the MECR to default values here, because we are
* not guaranteed to see a SetIOMap operation at runtime.
*/
- mecr = 0;
+ mecr = MECR;
clock = cpufreq_get(0);
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_graphicsclient.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_graphicsclient.c
--- linux-2.4.26/drivers/pcmcia/sa1100_graphicsclient.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_graphicsclient.c 2004-01-14 21:32:26.000000000 +0000
@@ -3,6 +3,8 @@
*
* PCMCIA implementation routines for Graphics Client Plus
*
+ * Nov/14/01 Woojung
+ * Set MECR at initializing time
* 9/12/01 Woojung
* Turn power OFF at startup
* 1/31/2001 Woojung Huh
@@ -19,11 +21,6 @@
#include <asm/irq.h>
#include "sa1100_generic.h"
-#error This is broken!
-
-#define S0_CD_IRQ 60 // Socket 0 Card Detect IRQ
-#define S0_STS_IRQ 55 // Socket 0 PCMCIA IRQ
-
static volatile unsigned long *PCMCIA_Status =
((volatile unsigned long *) ADS_p2v(_ADS_CS_STATUS));
@@ -46,20 +43,23 @@
*PCMCIA_Power &= ~0x03;
/* Register interrupts */
- irq = S0_CD_IRQ;
+ irq = IRQ_GRAPHICSCLIENT_S0_CD;
res = request_irq(irq, init->handler, SA_INTERRUPT, "PCMCIA 0 CD", NULL);
if (res < 0) {
- printk(KERN_ERR "%s: Request for IRQ %lu failed\n", __FUNCTION__, irq);
+ printk(KERN_ERR "%s: Request for IRQ %u failed\n", __FUNCTION__, irq);
return -1;
}
+ // Nov/14/01 WH
+ MECR = 0x00000943;
+
return 1; // 1 PCMCIA Slot
}
static int gcplus_pcmcia_shutdown(void)
{
/* disable IRQs */
- free_irq( S0_CD_IRQ, NULL);
+ free_irq( IRQ_GRAPHICSCLIENT_S0_CD, NULL);
/* Shutdown PCMCIA power */
mdelay(2); // 2msec
@@ -74,9 +74,6 @@
if(state_array->size<1) return -1;
- memset(state_array->state, 0,
- (state_array->size)*sizeof(struct pcmcia_state));
-
levels=*PCMCIA_Status;
state_array->state[0].detect=(levels & ADS_CS_ST_A_CD)?1:0;
@@ -96,7 +93,7 @@
return -1;
if (info->sock == 0)
- info->irq = S0_STS_IRQ;
+ info->irq = IRQ_GRAPHICSCLIENT_S0_STS;
return 0;
}
@@ -143,6 +140,11 @@
restore_flags(flags);
+ if (configure->irq)
+ enable_irq(IRQ_GRAPHICSCLIENT_S0_STS);
+ else
+ disable_irq(IRQ_GRAPHICSCLIENT_S0_STS);
+
return 0;
}
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_graphicsmaster.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_graphicsmaster.c
--- linux-2.4.26/drivers/pcmcia/sa1100_graphicsmaster.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_graphicsmaster.c 2004-01-14 21:32:26.000000000 +0000
@@ -12,13 +12,13 @@
#include <linux/sched.h>
#include <asm/hardware.h>
+#include <asm/hardware/sa1111.h>
#include "sa1100_generic.h"
#include "sa1111_generic.h"
static int graphicsmaster_pcmcia_init(struct pcmcia_init *init)
{
- int return_val=0;
/* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
@@ -26,9 +26,6 @@
/* Disable Power 3.3V/5V for PCMCIA/CF */
PA_DWR |= GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3;
- /* why? */
- MECR = 0x09430943;
-
return sa1111_pcmcia_init(init);
}
@@ -59,6 +56,10 @@
case 33: pa_dwr_set = GPIO_GPIO3; break;
case 50: pa_dwr_set = GPIO_GPIO2; break;
}
+ break;
+
+ default:
+ return -1;
}
if (conf->vpp != conf->vcc && conf->vpp != 0) {
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_h3600.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_h3600.c
--- linux-2.4.26/drivers/pcmcia/sa1100_h3600.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_h3600.c 2004-01-14 21:32:26.000000000 +0000
@@ -29,6 +29,9 @@
set_GPIO_IRQ_edge(GPIO_H3600_PCMCIA_IRQ0 | GPIO_H3600_PCMCIA_IRQ1,
GPIO_FALLING_EDGE);
+ set_GPIO_IRQ_edge(GPIO_H3600_PCMCIA_CD0 | GPIO_H3600_PCMCIA_CD1,
+ GPIO_NO_EDGES);
+
/*
* Register interrupts
*/
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_jornada720.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_jornada720.c
--- linux-2.4.26/drivers/pcmcia/sa1100_jornada720.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_jornada720.c 2004-01-14 21:32:26.000000000 +0000
@@ -8,6 +8,7 @@
#include <linux/sched.h>
#include <asm/hardware.h>
+#include <asm/hardware/sa1111.h>
#include "sa1100_generic.h"
#include "sa1111_generic.h"
@@ -88,7 +89,7 @@
local_irq_save(flags);
PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
- locla_irq_restore(flags);
+ local_irq_restore(flags);
}
return ret;
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_pangolin.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_pangolin.c
--- linux-2.4.26/drivers/pcmcia/sa1100_pangolin.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_pangolin.c 2004-01-14 21:32:26.000000000 +0000
@@ -53,9 +53,6 @@
if(state_array->size<2) return -1;
- memset(state_array->state, 0,
- (state_array->size)*sizeof(struct pcmcia_state));
-
levels=GPLR;
#ifndef CONFIG_SA1100_PANGOLIN_PCMCIA_IDE
state_array->state[1].detect=((levels & GPIO_PCMCIA_CD)==0)?1:0;
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_shannon.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_shannon.c
--- linux-2.4.26/drivers/pcmcia/sa1100_shannon.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_shannon.c 2004-01-14 21:32:26.000000000 +0000
@@ -53,9 +53,6 @@
{
unsigned long levels;
- memset(state_array->state, 0,
- state_array->size * sizeof(struct pcmcia_state));
-
levels = GPLR;
state_array->state[0].detect = (levels & SHANNON_GPIO_EJECT_0) ? 0 : 1;
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_simpad.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_simpad.c
--- linux-2.4.26/drivers/pcmcia/sa1100_simpad.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_simpad.c 2004-01-14 21:32:26.000000000 +0000
@@ -63,9 +63,6 @@
if(state_array->size<2) return -1;
- memset(state_array->state, 0,
- (state_array->size)*sizeof(struct pcmcia_state));
-
levels=GPLR;
state_array->state[1].detect=((levels & GPIO_CF_CD)==0)?1:0;
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_stork.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_stork.c
--- linux-2.4.26/drivers/pcmcia/sa1100_stork.c 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_stork.c 2004-02-23 13:36:32.000000000 +0000
@@ -79,9 +79,6 @@
if(state_array->size<2) return -1;
- memset(state_array->state, 0,
- (state_array->size)*sizeof(struct pcmcia_state));
-
levels=GPLR;
if (debug > 1)
diff -urN linux-2.4.26/drivers/pcmcia/sa1100_yopy.c linux-2.4.26-vrs1/drivers/pcmcia/sa1100_yopy.c
--- linux-2.4.26/drivers/pcmcia/sa1100_yopy.c 2002-08-03 01:39:44.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pcmcia/sa1100_yopy.c 2004-01-14 21:32:26.000000000 +0000
@@ -73,9 +73,6 @@
if (state_array->size != 1)
return -1;
- memset(state_array->state, 0,
- state_array->size * sizeof(struct pcmcia_state));
-
levels = GPLR;
state_array->state[0].detect = (levels & GPIO_CF_CD) ? 0 : 1;
diff -urN linux-2.4.26/drivers/pld/Makefile linux-2.4.26-vrs1/drivers/pld/Makefile
--- linux-2.4.26/drivers/pld/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pld/Makefile 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,28 @@
+#
+# Makefile for the kernel pld device drivers.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now inherited from the
+# parent makes..
+#
+# $Id: $
+#
+
+O_TARGET := pld.o
+
+export-objs := pld_hotswap.o
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_PLD) += pld_epxa.o
+obj-$(CONFIG_PLD_HOTSWAP) += pld_hotswap.o
+
+include $(TOPDIR)/Rules.make
+
+fastdep:
+
diff -urN linux-2.4.26/drivers/pld/pld_epxa.c linux-2.4.26-vrs1/drivers/pld/pld_epxa.c
--- linux-2.4.26/drivers/pld/pld_epxa.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pld/pld_epxa.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,375 @@
+
+/*
+ * drivers/char/epxapld.c
+ *
+ * Copyright (C) 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
+ */
+
+#include <linux/config.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/arch/excalibur.h>
+#include <asm/arch/hardware.h>
+#define PLD_CONF00_TYPE (volatile unsigned int *)
+#define MODE_CTRL00_TYPE (volatile unsigned int *)
+//#define DEBUG(x) x
+#define DEBUG(x)
+
+#include <asm/arch/mode_ctrl00.h>
+#include <asm/arch/pld_conf00.h>
+#ifdef CONFIG_PLD_HOTSWAP
+#include <linux/pld/pld_hotswap.h>
+#endif
+#include <linux/pld/pld_epxa.h>
+
+/*
+ * Macros
+ */
+
+
+#define PLD_BASE (IO_ADDRESS(EXC_PLD_CONFIG00_BASE))
+#define CLOCK_DIV_RATIO ((1 + EXC_AHB2_CLK_FREQUENCY/32000000) & CONFIG_CONTROL_CLOCK_RATIO_MSK)
+/*
+ * STRUCTURES
+ */
+
+
+struct pld_sbihdr{
+ unsigned int fpos;
+ unsigned int temp;
+};
+
+static DECLARE_MUTEX(pld_sem);
+
+
+static void lock_pld (void)
+{
+ /* Lock the pld i/f */
+ unsigned int tmp;
+
+ tmp = readl(CONFIG_CONTROL(PLD_BASE));
+ tmp |= CONFIG_CONTROL_LK_MSK;
+
+ writel(tmp,CONFIG_CONTROL(PLD_BASE));
+}
+
+static void unlock_excalibur_pld (void)
+{
+ /* Unlock the pld i/f */
+
+ if (readl(CONFIG_CONTROL(PLD_BASE)) & CONFIG_CONTROL_LK_MSK ){
+ writel(CONFIG_UNLOCK_MAGIC, CONFIG_UNLOCK(PLD_BASE));
+ while (readl(CONFIG_CONTROL(PLD_BASE)) & CONFIG_CONTROL_LK_MSK);
+ }
+}
+
+
+static int place_pld_into_configure_mode (void)
+{
+ unsigned int tmp;
+
+
+ if( readl(CONFIG_CONTROL(PLD_BASE)) & CONFIG_CONTROL_CO_MSK ){
+ /*
+ * Already being configured!!!
+ */
+ printk(KERN_WARNING "pld0: Device already being configured!\n");
+ return -EBUSY;
+ }
+
+ /* Set up the config clock */
+
+ writel(CLOCK_DIV_RATIO,CONFIG_CONTROL_CLOCK(PLD_BASE));
+ while(readl(CONFIG_CONTROL_CLOCK(PLD_BASE))
+ !=CLOCK_DIV_RATIO);
+ /* Tell the device we wish to configure it */
+ tmp = readl(CONFIG_CONTROL(PLD_BASE));
+ tmp |= CONFIG_CONTROL_CO_MSK;
+ writel(tmp,CONFIG_CONTROL(PLD_BASE));
+
+
+ /*
+ * Wait for the busy bit to clear then check for errors.
+ */
+
+ while((tmp=readl(CONFIG_CONTROL(PLD_BASE))&CONFIG_CONTROL_B_MSK ));
+
+ if ( tmp & CONFIG_CONTROL_E_MSK ){
+ if ( tmp & CONFIG_CONTROL_ES_0_MSK ){
+ /* Already being programmed via JTAG */
+ printk(KERN_WARNING "pld0:JTAG configuration alreay in progress\n");
+ return -EBUSY;
+
+ }
+ if ( tmp & CONFIG_CONTROL_ES_1_MSK ){
+ /* No config clock configured */
+ printk(KERN_ERR "pld0:No config clock!\n");
+ BUG();
+ return -EBUSY;
+ }
+ if ( tmp & CONFIG_CONTROL_ES_2_MSK ){
+ /* Already being programmed via External device */
+ printk(KERN_WARNING "pld0:JTAG configuration alreay in progress\n");
+ return -EBUSY;
+ }
+ }
+
+ return 0;
+}
+
+
+static int write_pld_data_word(unsigned int config_data)
+{
+ unsigned int tmp;
+
+ do{
+ tmp = readl(CONFIG_CONTROL(PLD_BASE));
+ }
+ while ( ( tmp & CONFIG_CONTROL_B_MSK ) &&
+ !( tmp & CONFIG_CONTROL_E_MSK ));
+
+ if ( tmp & CONFIG_CONTROL_E_MSK ){
+ printk("pld0: Error writing pld data, CONFIG_CONTROL=%#x\n",tmp);
+
+ return -EILSEQ;
+ }
+
+ writel(config_data,CONFIG_CONTROL_DATA(PLD_BASE));
+ return 0;
+
+}
+
+
+static int wait_for_device_to_configure (void)
+{
+ int i=0x10000;
+
+ while(readl(CONFIG_CONTROL(PLD_BASE)) & CONFIG_CONTROL_B_MSK);
+
+ /*
+ * Wait for the config bit (CO) to go low, indicating that everything
+ * is Ok. If it doesn't, assume that is screwed up somehow and
+ * clear the CO bit to abort the configuration.
+ */
+
+ while(readl(CONFIG_CONTROL(PLD_BASE)) & CONFIG_CONTROL_B_MSK);
+
+ while (i&&(readl(CONFIG_CONTROL(PLD_BASE)) & CONFIG_CONTROL_CO_MSK)){
+ i--;
+ }
+
+ if (!i){
+ writel(0,CONFIG_CONTROL(PLD_BASE));
+ printk(KERN_WARNING "pld0: Invalid PLD config data\n");
+ return -EILSEQ;
+ }
+
+ return 0;
+}
+
+
+
+static int pld_open(struct inode* inode, struct file *filep)
+{
+
+ struct pld_sbihdr* sbihdr;
+
+ /* Check the device minor number */
+ if(minor(inode->i_rdev)){
+ DEBUG(printk("pld0: minor=%d",minor(inode->i_rdev));)
+ return -ENODEV;
+ }
+
+ /* Create our private data and link it to the file structure */
+ sbihdr=kmalloc(sizeof(struct pld_sbihdr),GFP_KERNEL);
+
+ if(!sbihdr)
+ return -ENOMEM;
+
+ filep->private_data=sbihdr;
+
+ sbihdr->fpos=0;
+ sbihdr->temp=0;
+ return 0;
+}
+
+static int pld_release(struct inode* inode, struct file *filep){
+ int ret_code;
+
+ kfree(filep->private_data);
+ ret_code=wait_for_device_to_configure();
+ lock_pld();
+ return ret_code;
+}
+
+static ssize_t pld_write(struct file* filep, const char* data, size_t count, loff_t* ppos){
+
+ struct pld_sbihdr* sbihdr=filep->private_data;
+ int bytes_left=count;
+ int result;
+ DEBUG(int i=0);
+
+
+ /* Can't seek (pwrite) on pld. */
+ if (ppos != &filep->f_pos)
+ return -ESPIPE;
+
+
+ /* Check access to the whole are in one go */
+ if(!access_ok(VERIFY_READ,(const void*)data, count)){
+ return -EFAULT;
+ }
+
+ /*
+ * We now lock against writes.
+ */
+ if (down_interruptible(&pld_sem))
+ return -ERESTARTSYS;
+
+ if(!sbihdr->fpos){
+ /*
+ * unlock the pld and place in configure mode
+ */
+ unlock_excalibur_pld();
+ result=place_pld_into_configure_mode();
+ if(result)
+ return result;
+ }
+ DEBUG(printk("data= %#x count=%#x 0ffset=%#x\n",*data, count, *ppos));
+
+ while(bytes_left){
+ char tmp;
+ __get_user(tmp,data);
+ /* read our header ! */
+ sbihdr->temp|=tmp << (8*(sbihdr->fpos&3));
+ if((sbihdr->fpos&3)==3){
+ if(write_pld_data_word(sbihdr->temp))
+ {
+ DEBUG(printk("pos=%d\n",sbihdr->fpos);)
+ return -EILSEQ;
+ }
+ DEBUG(if(i<10){)
+ DEBUG(printk("fpos2 :%#x data=%#x\n",sbihdr->fpos,sbihdr->temp));
+ DEBUG(i++);
+ DEBUG(});
+ sbihdr->temp=0;
+ DEBUG(words_written++);
+ }
+ sbihdr->fpos++;
+ data++;
+ bytes_left--;
+ }
+
+ up(&pld_sem);
+ return (count);
+}
+
+int pld_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg)
+{
+
+ switch(cmd){
+
+#ifdef CONFIG_PLD_HOTSWAP
+ case PLD_IOC_ADD_PLD_DEV:
+ {
+ struct pldhs_dev_desc desc;
+ struct pldhs_dev_info info;
+ char *name;
+ void *data;
+ int result=0;
+
+ result=copy_from_user(&desc,(const void*)arg,sizeof(struct pldhs_dev_desc));
+ if(result)
+ return -EFAULT;
+ result=copy_from_user(&info,(const void*)desc.info,sizeof(struct pldhs_dev_info));
+ if(result)
+ return -EFAULT;
+ name=kmalloc(info.nsize,GFP_KERNEL);
+ if(!name)
+ return -ENOMEM;
+
+ result=copy_from_user(name,(const void*)desc.name,info.nsize);
+ if(result){
+ result=-EFAULT;
+ goto ioctl_out;
+ }
+
+ data=kmalloc(info.pssize,GFP_KERNEL);
+ if(!data){
+ result=-ENOMEM;
+ goto ioctl_out;
+ }
+
+ result=copy_from_user(data,(const void*)desc.data,info.pssize);
+ if(result){
+ result=-EFAULT;
+ goto ioctl_out1;
+ }
+ result=pldhs_add_device(&info,name,data);
+
+ ioctl_out1:
+ kfree(data);
+ ioctl_out:
+ kfree(name);
+ return result;
+
+ }
+
+ case PLD_IOC_REMOVE_PLD_DEVS:
+ pldhs_remove_devices();
+ return 0;
+
+ case PLD_IOC_SET_INT_MODE:
+ if(cmd==3){
+ printk(KERN_INFO "Interrupt mode set to 3 (Six individual interrupts)\n");
+ return 0;
+ }else{
+ printk(KERN_INFO "There is no interrupt handler available for this mode (%d). You will need to add one\n to implement whatever scheme you require\n");
+ return -EACCES;
+ }
+#endif
+ default:
+ return -ENOTTY;
+ }
+}
+
+
+static struct file_operations pld_fops={
+ write: pld_write,
+ ioctl: pld_ioctl,
+ open: pld_open,
+ release: pld_release
+};
+
+static int __init pld_init(void){
+ int major;
+ major=register_chrdev(0,"pld",&pld_fops);
+ printk(KERN_INFO "Using PLD major num=%d\n",major);
+ if (major<0){
+ return major;
+ }
+ return 0;
+}
+
+__initcall(pld_init);
diff -urN linux-2.4.26/drivers/pld/pld_hotswap.c linux-2.4.26-vrs1/drivers/pld/pld_hotswap.c
--- linux-2.4.26/drivers/pld/pld_hotswap.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/pld/pld_hotswap.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,188 @@
+/*
+ * linux/drivers/pld/pld_hotswap.c
+ *
+ * Pld driver for Altera EPXA Excalibur devices
+ *
+ *
+ * Copyright 2001 Altera Corporation (cdavies@altera.com)
+ *
+ * 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: $
+ *
+ */
+
+/*
+ * pld_hotswap ops contains the basic operation required for adding
+ * and removing devices from the system.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/pagemap.h>
+#include <linux/slab.h>
+#include <linux/smp_lock.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/proc_fs.h>
+#include <linux/list.h>
+#include <asm/uaccess.h>
+#include <linux/pld/pld_hotswap.h>
+
+
+static struct pld_hotswap_ops pldhs_driver_list={
+ list: LIST_HEAD_INIT(pldhs_driver_list.list),
+ name: "",
+};
+
+static spinlock_t list_lock=SPIN_LOCK_UNLOCKED;
+
+
+
+static struct pld_hotswap_ops * pldhs_find_driver(char* name)
+{
+ struct pld_hotswap_ops * ptr;
+ struct list_head *list_pos;
+
+ spin_lock(&list_lock);
+ list_for_each(list_pos,&pldhs_driver_list.list){
+ ptr=(struct pld_hotswap_ops *)list_pos;
+ if(!strcmp(name, ptr->name)){
+ spin_unlock(&list_lock);
+ return ptr;
+
+ }
+ }
+ spin_unlock(&list_lock);
+ return 0;
+}
+
+
+
+int pldhs_register_driver(struct pld_hotswap_ops *drv)
+{
+
+ /* Check that the device is not already on the list
+ * if so, do nothing */
+ if(pldhs_find_driver(drv->name)){
+ return 0;
+ }
+
+ printk(KERN_INFO "PLD: Registering hotswap driver %s\n",drv->name);
+ /* Add this at the start of the list */
+ spin_lock(&list_lock);
+ list_add((struct list_head*)drv,&pldhs_driver_list.list);
+ spin_unlock(&list_lock);
+
+ return 0;
+}
+
+int pldhs_unregister_driver(char *name)
+{
+ struct pld_hotswap_ops *ptr;
+
+ ptr=pldhs_find_driver(name);
+ if(!ptr){
+ return -ENODEV;
+ }
+
+ printk(KERN_INFO "PLD: Unregistering hotswap driver%s\n",name);
+ spin_lock(&list_lock);
+ list_del((struct list_head*)ptr);
+ spin_unlock(&list_lock);
+
+ return 0;
+}
+
+int pldhs_add_device(struct pldhs_dev_info* dev_info,char *drv_name, void* dev_ps_data)
+{
+ struct pld_hotswap_ops * ptr;
+
+ ptr=pldhs_find_driver(drv_name);
+
+ if(!ptr){
+ /* try requesting this module*/
+ request_module(drv_name);
+ /* is the driver there now? */
+ ptr=pldhs_find_driver(drv_name);
+ if(!ptr){
+ printk("pld hotswap: Failed to load a driver for %s\n",drv_name);
+ return -ENODEV;
+ }
+ }
+
+ if(!ptr->add_device){
+ printk(KERN_WARNING "pldhs: no add_device() function for driver %s\n",drv_name);
+ return 0;
+ }
+
+ return ptr->add_device(dev_info,dev_ps_data);
+}
+
+int pldhs_remove_devices(void)
+{
+ struct list_head *list_pos;
+ struct pld_hotswap_ops * ptr;
+
+
+ spin_lock(&list_lock);
+ list_for_each(list_pos,&pldhs_driver_list.list){
+ ptr=(struct pld_hotswap_ops *)list_pos;
+ if(ptr->remove_devices)
+ ptr->remove_devices();
+
+ }
+ spin_unlock(&list_lock);
+
+ return 0;
+}
+
+#ifdef CONFIG_PROC_FS
+int pldhs_read_proc(char* buf,char** start,off_t offset,int count,int *eof,void *data){
+
+
+ struct list_head *list_pos;
+ struct pld_hotswap_ops * ptr;
+ int i,len=0;
+
+ *start=buf;
+ spin_lock(&list_lock);
+ list_for_each(list_pos,&pldhs_driver_list.list){
+ ptr=(struct pld_hotswap_ops *)list_pos;
+ if(ptr->proc_read){
+ i=ptr->proc_read(buf,start,offset,count,eof,data);
+ count-=i;
+ len+=i;
+ *start+=i;
+ }
+ }
+ spin_unlock(&list_lock);
+
+ *start=NULL;
+ *eof=1;
+ return len;
+}
+
+void __init pldhs_init(void){
+ create_proc_read_entry("pld",0,NULL,pldhs_read_proc,NULL);
+}
+
+__initcall(pldhs_init);
+#endif
+
+EXPORT_SYMBOL(pldhs_register_driver);
+EXPORT_SYMBOL(pldhs_unregister_driver);
diff -urN linux-2.4.26/drivers/scsi/Makefile linux-2.4.26-vrs1/drivers/scsi/Makefile
--- linux-2.4.26/drivers/scsi/Makefile 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/scsi/Makefile 2004-02-23 13:36:33.000000000 +0000
@@ -21,7 +21,7 @@
O_TARGET := scsidrv.o
-export-objs := scsi_syms.o 53c700.o
+export-objs := scsi_syms.o 53c700.o scsi_error.o
mod-subdirs := pcmcia ../acorn/scsi
diff -urN linux-2.4.26/drivers/scsi/scsi.c linux-2.4.26-vrs1/drivers/scsi/scsi.c
--- linux-2.4.26/drivers/scsi/scsi.c 2003-08-25 12:44:42.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/scsi/scsi.c 2004-01-14 21:39:12.000000000 +0000
@@ -1334,14 +1334,10 @@
*/
int scsi_retry_command(Scsi_Cmnd * SCpnt)
{
- memcpy((void *) SCpnt->cmnd, (void *) SCpnt->data_cmnd,
- sizeof(SCpnt->data_cmnd));
- SCpnt->request_buffer = SCpnt->buffer;
- SCpnt->request_bufflen = SCpnt->bufflen;
- SCpnt->use_sg = SCpnt->old_use_sg;
- SCpnt->cmd_len = SCpnt->old_cmd_len;
- SCpnt->sc_data_direction = SCpnt->sc_old_data_direction;
- SCpnt->underflow = SCpnt->old_underflow;
+ /*
+ * Restore the SCSI command state.
+ */
+ scsi_setup_cmd_retry(SCpnt);
/*
* Zero the sense information from the last time we tried
diff -urN linux-2.4.26/drivers/scsi/scsi.h linux-2.4.26-vrs1/drivers/scsi/scsi.h
--- linux-2.4.26/drivers/scsi/scsi.h 2003-08-25 12:44:42.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/scsi/scsi.h 2004-04-19 18:46:03.000000000 +0100
@@ -465,6 +465,7 @@
int sectors);
extern struct Scsi_Device_Template *scsi_get_request_dev(struct request *);
extern int scsi_init_cmd_errh(Scsi_Cmnd * SCpnt);
+extern void scsi_setup_cmd_retry(Scsi_Cmnd *SCpnt);
extern int scsi_insert_special_cmd(Scsi_Cmnd * SCpnt, int);
extern void scsi_io_completion(Scsi_Cmnd * SCpnt, int good_sectors,
int block_sectors);
@@ -588,6 +589,7 @@
unsigned changed:1; /* Data invalid due to media change */
unsigned busy:1; /* Used to prevent races */
unsigned lockable:1; /* Able to prevent media removal */
+ unsigned locked:1; /* Media removal disabled */
unsigned borken:1; /* Tell the Seagate driver to be
* painfully slow on this device */
unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */
diff -urN linux-2.4.26/drivers/scsi/scsi_dma.c linux-2.4.26-vrs1/drivers/scsi/scsi_dma.c
--- linux-2.4.26/drivers/scsi/scsi_dma.c 2002-02-25 19:38:04.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/scsi/scsi_dma.c 2004-01-14 21:32:26.000000000 +0000
@@ -30,6 +30,15 @@
typedef unsigned char FreeSectorBitmap;
#elif SECTORS_PER_PAGE <= 32
typedef unsigned int FreeSectorBitmap;
+#elif SECTORS_PER_PAGE <= 64
+#if 0
+typedef unsigned long long FreeSectorBitmap;
+#else
+typedef struct {
+ unsigned long l,h;
+} FreeSectorBitmap;
+#define LARGE_MALLOC
+#endif
#else
#error You lose.
#endif
@@ -69,6 +78,7 @@
* to allocate more memory in order to be able to write the
* data to disk, you would wedge the system.
*/
+#ifndef LARGE_MALLOC
void *scsi_malloc(unsigned int len)
{
unsigned int nbits, mask;
@@ -167,6 +177,97 @@
panic("scsi_free:Bad offset");
}
+#else
+
+void *scsi_malloc(unsigned int len)
+{
+ unsigned int nbits;
+ unsigned long maskl, maskh, flags;
+ FreeSectorBitmap *fsb;
+ int i;
+
+ if (len % SECTOR_SIZE != 0 || len > PAGE_SIZE)
+ return NULL;
+
+ save_flags_cli (flags);
+ nbits = len >> 9;
+ if (nbits < 32) {
+ maskl = (1 << nbits) - 1;
+ maskh = 0;
+ } else {
+ maskl = (unsigned long)-1;
+ maskh = (1 << (nbits - 32)) - 1;
+ }
+
+ fsb = dma_malloc_freelist;
+
+ for (i = 0; i < dma_sectors / SECTORS_PER_PAGE; i++) {
+ unsigned long mml, mmh;
+ int j;
+ mml = maskl;
+ mmh = maskh;
+ j = 0;
+ do {
+ if ((fsb->l & mml) == 0 && (fsb->h & mmh) == 0) {
+ fsb->h |= mmh;
+ fsb->l |= mml;
+ restore_flags (flags);
+ scsi_dma_free_sectors -= nbits;
+#ifdef DEBUG
+ printk("SMalloc: %d %p\n",len, dma_malloc_pages[i] + (j << 9));
+#endif
+ return (void *) ((unsigned long) dma_malloc_pages[i] + (j << 9));
+ }
+ mmh = (mmh << 1) | (mml >> 31);
+ mml <<= 1;
+ j++;
+ } while (!(mmh & (1 << 31)));
+ fsb ++;
+ }
+ return NULL; /* Nope. No more */
+}
+
+int scsi_free(void *obj, unsigned int len)
+{
+ unsigned int page, sector, nbits;
+ unsigned long maskl, maskh, flags;
+
+#ifdef DEBUG
+ printk("scsi_free %p %d\n",obj, len);
+#endif
+
+ for (page = 0; page < dma_sectors / SECTORS_PER_PAGE; page++) {
+ unsigned long page_addr = (unsigned long) dma_malloc_pages[page];
+ if ((unsigned long) obj >= page_addr &&
+ (unsigned long) obj < page_addr + PAGE_SIZE) {
+ sector = (((unsigned long) obj) - page_addr) >> 9;
+ nbits = len >> 9;
+ if (nbits < 32) {
+ maskl = (1 << nbits) - 1;
+ maskh = 0;
+ } else {
+ maskl = (unsigned long)-1;
+ maskh = (1 << (nbits - 32)) - 1;
+ }
+ if ((sector + nbits) > SECTORS_PER_PAGE)
+ panic ("scsi_free:Bad memory alignment");
+ maskh = (maskh << sector) | (maskl >> (32 - sector));
+ maskl = maskl << sector;
+ save_flags_cli(flags);
+ if (((dma_malloc_freelist[page].l & maskl) != maskl) ||
+ ((dma_malloc_freelist[page].h & maskh) != maskh))
+ panic("scsi_free:Trying to free unused memory");
+ scsi_dma_free_sectors += nbits;
+ dma_malloc_freelist[page].l &= ~maskl;
+ dma_malloc_freelist[page].h &= ~maskh;
+ restore_flags(flags);
+ return 0;
+ }
+ }
+ panic("scsi_free:Bad offset");
+}
+#endif
+
/*
* Function: scsi_resize_dma_pool
diff -urN linux-2.4.26/drivers/scsi/scsi_error.c linux-2.4.26-vrs1/drivers/scsi/scsi_error.c
--- linux-2.4.26/drivers/scsi/scsi_error.c 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/scsi/scsi_error.c 2004-04-18 21:47:51.000000000 +0100
@@ -35,6 +35,8 @@
#include "hosts.h"
#include "constants.h"
+#include <scsi/scsi_ioctl.h> /* grr */
+
/*
* We must always allow SHUTDOWN_SIGS. Even if we are not a module,
* the host drivers that we are using may be loaded as modules, and
@@ -49,6 +51,13 @@
*/
#define SHUTDOWN_SIGS (sigmask(SIGHUP))
+/*
+ * The number of times we retry a REQUEST SENSE and TEST UNIT READY
+ * respectively. This is arbitary.
+ */
+#define SENSE_RETRIES 5
+#define TUR_RETRIES 5
+
#ifdef DEBUG
#define SENSE_TIMEOUT SCSI_TIMEOUT
#define ABORT_TIMEOUT SCSI_TIMEOUT
@@ -373,16 +382,12 @@
*/
STATIC int scsi_eh_retry_command(Scsi_Cmnd * SCpnt)
{
- memcpy((void *) SCpnt->cmnd, (void *) SCpnt->data_cmnd,
- sizeof(SCpnt->data_cmnd));
- SCpnt->request_buffer = SCpnt->buffer;
- SCpnt->request_bufflen = SCpnt->bufflen;
- SCpnt->use_sg = SCpnt->old_use_sg;
- SCpnt->cmd_len = SCpnt->old_cmd_len;
- SCpnt->sc_data_direction = SCpnt->sc_old_data_direction;
- SCpnt->underflow = SCpnt->old_underflow;
+ int tries = 0;
- scsi_send_eh_cmnd(SCpnt, SCpnt->timeout_per_command);
+ do {
+ scsi_setup_cmd_retry(SCpnt);
+ scsi_send_eh_cmnd(SCpnt, SCpnt->timeout_per_command);
+ } while (SCpnt->eh_state == NEEDS_RETRY && tries++ < SCpnt->allowed);
/*
* Hey, we are done. Let's look to see what happened.
@@ -409,16 +414,10 @@
static unsigned char generic_sense[6] =
{REQUEST_SENSE, 0, 0, 0, 255, 0};
unsigned char scsi_result0[256], *scsi_result = NULL;
- int saved_result;
+ int saved_result, tries;
ASSERT_LOCK(&io_request_lock, 0);
- memcpy((void *) SCpnt->cmnd, (void *) generic_sense,
- sizeof(generic_sense));
-
- if (SCpnt->device->scsi_level <= SCSI_2)
- SCpnt->cmnd[1] = SCpnt->lun << 5;
-
scsi_result = (!SCpnt->host->hostt->unchecked_isa_dma)
? &scsi_result0[0] : kmalloc(512, GFP_ATOMIC | GFP_DMA);
@@ -426,24 +425,41 @@
printk("cannot allocate scsi_result in scsi_request_sense.\n");
return FAILED;
}
- /*
- * Zero the sense buffer. Some host adapters automatically always request
- * sense, so it is not a good idea that SCpnt->request_buffer and
- * SCpnt->sense_buffer point to the same address (DB).
- * 0 is not a valid sense code.
- */
- memset((void *) SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
- memset((void *) scsi_result, 0, 256);
saved_result = SCpnt->result;
- SCpnt->request_buffer = scsi_result;
- SCpnt->request_bufflen = 256;
- SCpnt->use_sg = 0;
- SCpnt->cmd_len = COMMAND_SIZE(SCpnt->cmnd[0]);
- SCpnt->sc_data_direction = SCSI_DATA_READ;
- SCpnt->underflow = 0;
- scsi_send_eh_cmnd(SCpnt, SENSE_TIMEOUT);
+ tries = 0;
+ do {
+ memcpy((void *) SCpnt->cmnd, (void *) generic_sense,
+ sizeof(generic_sense));
+
+ if (SCpnt->device->scsi_level <= SCSI_2)
+ SCpnt->cmnd[1] = SCpnt->lun << 5;
+
+ /*
+ * Zero the sense buffer. Some host adapters automatically
+ * always request sense, so it is not a good idea that
+ * SCpnt->request_buffer and SCpnt->sense_buffer point to
+ * the same address (DB). 0 is not a valid sense code.
+ */
+ memset((void *) SCpnt->sense_buffer, 0,
+ sizeof(SCpnt->sense_buffer));
+ memset((void *) scsi_result, 0, 256);
+
+ SCpnt->request_buffer = scsi_result;
+ SCpnt->request_bufflen = 256;
+ SCpnt->use_sg = 0;
+ SCpnt->cmd_len = COMMAND_SIZE(SCpnt->cmnd[0]);
+ SCpnt->sc_data_direction = SCSI_DATA_READ;
+ SCpnt->underflow = 0;
+
+ scsi_send_eh_cmnd(SCpnt, SENSE_TIMEOUT);
+ /*
+ * If the SCSI device responded with "logical unit
+ * is in process of becoming ready", we need to
+ * retry this command.
+ */
+ } while (SCpnt->eh_state == NEEDS_RETRY && tries++ < SENSE_RETRIES);
/* Last chance to have valid sense data */
if (!scsi_sense_valid(SCpnt))
@@ -458,15 +474,8 @@
* When we eventually call scsi_finish, we really wish to complete
* the original request, so let's restore the original data. (DB)
*/
- memcpy((void *) SCpnt->cmnd, (void *) SCpnt->data_cmnd,
- sizeof(SCpnt->data_cmnd));
SCpnt->result = saved_result;
- SCpnt->request_buffer = SCpnt->buffer;
- SCpnt->request_bufflen = SCpnt->bufflen;
- SCpnt->use_sg = SCpnt->old_use_sg;
- SCpnt->cmd_len = SCpnt->old_cmd_len;
- SCpnt->sc_data_direction = SCpnt->sc_old_data_direction;
- SCpnt->underflow = SCpnt->old_underflow;
+ scsi_setup_cmd_retry(SCpnt);
/*
* Hey, we are done. Let's look to see what happened.
@@ -484,40 +493,42 @@
{
static unsigned char tur_command[6] =
{TEST_UNIT_READY, 0, 0, 0, 0, 0};
+ int tries = 0;
- memcpy((void *) SCpnt->cmnd, (void *) tur_command,
- sizeof(tur_command));
+ do {
+ memcpy((void *) SCpnt->cmnd, (void *) tur_command,
+ sizeof(tur_command));
- if (SCpnt->device->scsi_level <= SCSI_2)
- SCpnt->cmnd[1] = SCpnt->lun << 5;
+ if (SCpnt->device->scsi_level <= SCSI_2)
+ SCpnt->cmnd[1] = SCpnt->lun << 5;
- /*
- * Zero the sense buffer. The SCSI spec mandates that any
- * untransferred sense data should be interpreted as being zero.
- */
- memset((void *) SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
+ /*
+ * Zero the sense buffer. The SCSI spec mandates that any
+ * untransferred sense data should be interpreted as being zero.
+ */
+ memset((void *) SCpnt->sense_buffer, 0,
+ sizeof(SCpnt->sense_buffer));
- SCpnt->request_buffer = NULL;
- SCpnt->request_bufflen = 0;
- SCpnt->use_sg = 0;
- SCpnt->cmd_len = COMMAND_SIZE(SCpnt->cmnd[0]);
- SCpnt->underflow = 0;
- SCpnt->sc_data_direction = SCSI_DATA_NONE;
+ SCpnt->request_buffer = NULL;
+ SCpnt->request_bufflen = 0;
+ SCpnt->use_sg = 0;
+ SCpnt->cmd_len = COMMAND_SIZE(SCpnt->cmnd[0]);
+ SCpnt->underflow = 0;
+ SCpnt->sc_data_direction = SCSI_DATA_NONE;
- scsi_send_eh_cmnd(SCpnt, SENSE_TIMEOUT);
+ scsi_send_eh_cmnd(SCpnt, SENSE_TIMEOUT);
+ /*
+ * If the SCSI device responded with "logical unit
+ * is in process of becoming ready", we need to
+ * retry this command.
+ */
+ } while (SCpnt->eh_state == NEEDS_RETRY && tries++ < TUR_RETRIES);
/*
* When we eventually call scsi_finish, we really wish to complete
* the original request, so let's restore the original data. (DB)
*/
- memcpy((void *) SCpnt->cmnd, (void *) SCpnt->data_cmnd,
- sizeof(SCpnt->data_cmnd));
- SCpnt->request_buffer = SCpnt->buffer;
- SCpnt->request_bufflen = SCpnt->bufflen;
- SCpnt->use_sg = SCpnt->old_use_sg;
- SCpnt->cmd_len = SCpnt->old_cmd_len;
- SCpnt->sc_data_direction = SCpnt->sc_old_data_direction;
- SCpnt->underflow = SCpnt->old_underflow;
+ scsi_setup_cmd_retry(SCpnt);
/*
* Hey, we are done. Let's look to see what happened.
@@ -577,7 +588,6 @@
host = SCpnt->host;
- retry:
/*
* We will use a queued command if possible, otherwise we will emulate the
* queuing and calling of completion function ourselves.
@@ -660,14 +670,13 @@
SCSI_LOG_ERROR_RECOVERY(3,
printk("scsi_send_eh_cmnd: scsi_eh_completed_normally %x\n", ret));
switch (ret) {
- case SUCCESS:
- SCpnt->eh_state = SUCCESS;
- break;
- case NEEDS_RETRY:
- goto retry;
- case FAILED:
default:
- SCpnt->eh_state = FAILED;
+ ret = FAILED;
+ /*FALLTHROUGH*/
+ case FAILED:
+ case NEEDS_RETRY:
+ case SUCCESS:
+ SCpnt->eh_state = ret;
break;
}
} else {
@@ -1208,6 +1217,82 @@
/*
+ * Function: scsi_eh_lock_done
+ *
+ * Purpose: free the command and request structures associated
+ * with the error handlers door lock request
+ *
+ * Arguments: SCpnt - the SCSI command block for the door lock request.
+ *
+ * Returns: Nothing
+ *
+ * Notes: We completed the asynchronous door lock request, and
+ * it has either locked the door or failed. We must free
+ * the command structures associated with this request.
+ */
+static void scsi_eh_lock_done(struct scsi_cmnd *SCpnt)
+{
+ struct scsi_request *SRpnt = SCpnt->sc_request;
+
+ SCpnt->sc_request = NULL;
+ SRpnt->sr_command = NULL;
+
+ scsi_release_command(SCpnt);
+ scsi_release_request(SRpnt);
+}
+
+
+/*
+ * Function: scsi_eh_lock_door
+ *
+ * Purpose: Prevent medium removal for the specified device
+ *
+ * Arguments: dev - SCSI device to prevent medium removal
+ *
+ * Locking: We must be called from process context;
+ * scsi_allocate_request() may sleep.
+ *
+ * Returns: Nothing
+ *
+ * Notes: We queue up an asynchronous "ALLOW MEDIUM REMOVAL" request
+ * on the head of the devices request queue, and continue.
+ *
+ * Bugs: scsi_allocate_request() may sleep waiting for existing
+ * requests to be processed. However, since we haven't
+ * kicked off any request processing for this host, this
+ * may deadlock.
+ *
+ * If scsi_allocate_request() fails for what ever reason,
+ * we completely forget to lock the door.
+ */
+STATIC void scsi_eh_lock_door(struct scsi_device *dev)
+{
+ struct scsi_request *SRpnt = scsi_allocate_request(dev);
+
+ if (SRpnt == NULL) {
+ /* what now? */
+ return;
+ }
+
+ SRpnt->sr_cmnd[0] = ALLOW_MEDIUM_REMOVAL;
+ SRpnt->sr_cmnd[1] = (dev->scsi_level <= SCSI_2) ? (dev->lun << 5) : 0;
+ SRpnt->sr_cmnd[2] = 0;
+ SRpnt->sr_cmnd[3] = 0;
+ SRpnt->sr_cmnd[4] = SCSI_REMOVAL_PREVENT;
+ SRpnt->sr_cmnd[5] = 0;
+ SRpnt->sr_data_direction = SCSI_DATA_NONE;
+ SRpnt->sr_bufflen = 0;
+ SRpnt->sr_buffer = NULL;
+ SRpnt->sr_allowed = 5;
+ SRpnt->sr_done = scsi_eh_lock_done;
+ SRpnt->sr_timeout_per_command = 10 * HZ;
+ SRpnt->sr_cmd_len = COMMAND_SIZE(SRpnt->sr_cmnd[0]);
+
+ scsi_insert_special_req(SRpnt, 1);
+}
+
+
+/*
* Function: scsi_restart_operations
*
* Purpose: Restart IO operations to the specified host.
@@ -1229,6 +1314,15 @@
ASSERT_LOCK(&io_request_lock, 0);
/*
+ * If the door was locked, we need to insert a door lock request
+ * onto the head of the SCSI request queue for the device. There
+ * is no point trying to lock the door of an off-line device.
+ */
+ for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next)
+ if (SDpnt->online && SDpnt->locked)
+ scsi_eh_lock_door(SDpnt);
+
+ /*
* Next free up anything directly waiting upon the host. This will be
* requests for character device operations, and also for ioctls to queued
* block devices.
@@ -1248,8 +1342,7 @@
request_queue_t *q;
if ((host->can_queue > 0 && (host->host_busy >= host->can_queue))
|| (host->host_blocked)
- || (host->host_self_blocked)
- || (SDpnt->device_blocked)) {
+ || (host->host_self_blocked)) {
break;
}
q = &SDpnt->request_queue;
@@ -1259,136 +1352,202 @@
}
/*
- * Function: scsi_unjam_host
+ * Function: scsi_eh_find_failed_command
*
- * Purpose: Attempt to fix a host which has a command that failed for
- * some reason.
+ * Purpose: Find a failed Scsi_Cmnd structure on a device.
*
- * Arguments: host - host that needs unjamming.
- *
- * Returns: Nothing
+ * Arguments: SDpnt - Scsi_Device structure
*
- * Notes: When we come in here, we *know* that all commands on the
- * bus have either completed, failed or timed out. We also
- * know that no further commands are being sent to the host,
- * so things are relatively quiet and we have freedom to
- * fiddle with things as we wish.
+ * Returns: Pointer to Scsi_Cmnd structure, or NULL on failure
+ */
+STATIC Scsi_Cmnd *scsi_eh_find_failed_command(Scsi_Device *SDpnt)
+{
+ Scsi_Cmnd *SCpnt;
+
+ for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next)
+ if (SCpnt->state == SCSI_STATE_FAILED ||
+ SCpnt->state == SCSI_STATE_TIMEOUT)
+ return SCpnt;
+
+ return NULL;
+}
+
+
+/*
+ * Function: scsi_eh_test_and_retry
*
- * Additional note: This is only the *default* implementation. It is possible
- * for individual drivers to supply their own version of this
- * function, and if the maintainer wishes to do this, it is
- * strongly suggested that this function be taken as a template
- * and modified. This function was designed to correctly handle
- * problems for about 95% of the different cases out there, and
- * it should always provide at least a reasonable amount of error
- * recovery.
+ * Purpose: Try to retry a failed command.
*
- * Note3: Any command marked 'FAILED' or 'TIMEOUT' must eventually
- * have scsi_finish_command() called for it. We do all of
- * the retry stuff here, so when we restart the host after we
- * return it should have an empty queue.
+ * Arguments: SCpnt - scsi command structure
+ * done - list of commands that have been successfully
+ * completed.
+ *
+ * Returns: SUCCESS or FAILED
+ *
+ * Note: If the TEST UNIT READY command successfully executes,
+ * but returns some form of "device not ready", we wait
+ * a while, and retry 3 times. The device could be still
+ * re-initialising.
*/
-STATIC int scsi_unjam_host(struct Scsi_Host *host)
+STATIC int scsi_eh_test_and_retry(Scsi_Cmnd *SCpnt, Scsi_Cmnd **done)
{
- int devices_failed;
- int numfailed;
- int ourrtn;
- int rtn = FALSE;
- int result;
- Scsi_Cmnd *SCloop;
- Scsi_Cmnd *SCpnt;
- Scsi_Device *SDpnt;
- Scsi_Device *SDloop;
- Scsi_Cmnd *SCdone;
- int timed_out;
+ int rtn, tries = 3;
- ASSERT_LOCK(&io_request_lock, 0);
+ do {
+ rtn = scsi_test_unit_ready(SCpnt);
+ if (rtn != SUCCESS)
+ return rtn;
- SCdone = NULL;
+ if (scsi_unit_is_ready(SCpnt))
+ break;
+
+ if (tries-- == 0)
+ return FAILED;
+
+ scsi_sleep(5 * HZ);
+ } while (1);
+
+ rtn = scsi_eh_retry_command(SCpnt);
+ if (rtn == SUCCESS) {
+ SCpnt->host->host_failed--;
+ scsi_eh_finish_command(done, SCpnt);
+ }
+
+ return rtn;
+}
- /*
- * First, protect against any sort of race condition. If any of the outstanding
- * commands are in states that indicate that we are not yet blocked (i.e. we are
- * not in a quiet state) then we got woken up in error. If we ever end up here,
- * we need to re-examine some of the assumptions.
- */
- for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
- for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) {
- if (SCpnt->state == SCSI_STATE_FAILED
- || SCpnt->state == SCSI_STATE_TIMEOUT
- || SCpnt->state == SCSI_STATE_INITIALIZING
- || SCpnt->state == SCSI_STATE_UNUSED) {
- continue;
- }
- /*
- * Rats. Something is still floating around out there. This could
- * be the result of the fact that the upper level drivers are still frobbing
- * commands that might have succeeded. There are two outcomes. One is that
- * the command block will eventually be freed, and the other one is that
- * the command will be queued and will be finished along the way.
- */
- SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler prematurely woken - commands still active (%p %x %d)\n", SCpnt, SCpnt->state, SCpnt->target));
/*
- * panic("SCSI Error handler woken too early\n");
+ * Function: scsi_eh_restart_device
*
- * This is no longer a problem, since now the code cares only about
- * SCSI_STATE_TIMEOUT and SCSI_STATE_FAILED.
- * Other states are useful only to release active commands when devices are
- * set offline. If (host->host_active == host->host_busy) we can safely assume
- * that there are no commands in state other then TIMEOUT od FAILED. (DB)
+ * Purpose: Retry all failed or timed out commands for a device
*
- * FIXME:
- * It is not easy to release correctly commands according to their state when
- * devices are set offline, when the state is neither TIMEOUT nor FAILED.
- * When a device is set offline, we can have some command with
- * rq_status=RQ_SCSY_BUSY, owner=SCSI_STATE_HIGHLEVEL,
- * state=SCSI_STATE_INITIALIZING and the driver module cannot be released.
- * (DB, 17 May 1998)
+ * Arguments: SDpnt - SCSI device to retry
+ * done - list of commands that have been successfully
+ * completed.
+ *
+ * Returns: SUCCESS or failure code
+ */
+STATIC int scsi_eh_restart_device(Scsi_Device *SDpnt, Scsi_Cmnd **done)
+{
+ Scsi_Cmnd *SCpnt, *SCnext;
+ int rtn = SUCCESS;
+
+ for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCnext) {
+ SCnext = SCpnt->next;
+
+ if (SCpnt->state == SCSI_STATE_FAILED ||
+ SCpnt->state == SCSI_STATE_TIMEOUT) {
+ rtn = scsi_eh_test_and_retry(SCpnt, done);
+ if (rtn != SUCCESS)
+ break;
+ }
+ }
+
+ return rtn;
+}
+
+/*
+ * Function: scsi_eh_set_device_offline
+ *
+ * Purpose: set a device off line
+ *
+ * Arguments: SDpnt - SCSI device to take off line
+ * done - list of commands that have been successfully
+ * completed.
+ * reason - text string describing why the device is off-line
+ *
+ * Returns: Nothing
+ *
+ * Notes: In addition, we complete each failed or timed out command
+ * attached to this device.
*/
+STATIC void scsi_eh_set_device_offline(Scsi_Device *SDpnt, Scsi_Cmnd **done,
+ const char *reason)
+{
+ Scsi_Cmnd *SCpnt, *SCnext;
+
+ printk(KERN_ERR "scsi: device set offline - %s: "
+ "host %d channel %d id %d lun %d\n",
+ reason, SDpnt->host->host_no, SDpnt->channel,
+ SDpnt->id, SDpnt->lun);
+
+ SDpnt->online = FALSE;
+
+ for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCnext) {
+ SCnext = SCpnt->next;
+
+ switch (SCpnt->state) {
+ case SCSI_STATE_TIMEOUT:
+ SCpnt->result |= DRIVER_TIMEOUT;
+ /*FALLTHROUGH*/
+
+ case SCSI_STATE_FAILED:
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("Finishing command for device %d %x\n",
+ SDpnt->id, SCpnt->result));
+
+ SDpnt->host->host_failed--;
+ scsi_eh_finish_command(done, SCpnt);
+ break;
+
+ default:
+ break;
}
}
+}
+
+static void scsi_unjam_request_sense(struct Scsi_Host *host, Scsi_Cmnd **done)
+{
+ int rtn;
+ int result;
+ Scsi_Cmnd *SCpnt;
+ Scsi_Device *SDpnt;
/*
* Next, see if we need to request sense information. if so,
* then get it now, so we have a better idea of what to do.
- * FIXME(eric) this has the unfortunate side effect that if a host
- * adapter does not automatically request sense information, that we end
- * up shutting it down before we request it. All hosts should be doing this
- * anyways, so for now all I have to say is tough noogies if you end up in here.
- * On second thought, this is probably a good idea. We *really* want to give
- * authors an incentive to automatically request this.
+ * FIXME(eric) this has the unfortunate side effect that if a
+ * host adapter does not automatically request sense information,
+ * that we end up shutting it down before we request it. All
+ * hosts should be doing this anyways, so for now all I have
+ * to say is tough noogies if you end up in here. On second
+ * thought, this is probably a good idea. We *really* want
+ * to give authors an incentive to automatically request this.
*/
- SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Checking to see if we need to request sense\n"));
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("scsi_unjam_host: Checking to see if we need to request sense\n"));
for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) {
- if (SCpnt->state != SCSI_STATE_FAILED || scsi_sense_valid(SCpnt)) {
+ if (SCpnt->state != SCSI_STATE_FAILED || scsi_sense_valid(SCpnt))
continue;
- }
- SCSI_LOG_ERROR_RECOVERY(2, printk("scsi_unjam_host: Requesting sense for %d\n",
- SCpnt->target));
+
+ SCSI_LOG_ERROR_RECOVERY(2,
+ printk("scsi_unjam_host: Requesting sense for %d\n",
+ SCpnt->target));
rtn = scsi_request_sense(SCpnt);
- if (rtn != SUCCESS) {
+ if (rtn != SUCCESS)
continue;
- }
- SCSI_LOG_ERROR_RECOVERY(3, printk("Sense requested for %p - result %x\n",
- SCpnt, SCpnt->result));
+
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("Sense requested for %p - result %x\n",
+ SCpnt, SCpnt->result));
SCSI_LOG_ERROR_RECOVERY(3, print_sense("bh", SCpnt));
result = scsi_decide_disposition(SCpnt);
/*
- * If the result was normal, then just pass it along to the
- * upper level.
+ * If the result was normal, then just pass
+ * it along to the upper level.
*/
if (result == SUCCESS) {
SCpnt->host->host_failed--;
- scsi_eh_finish_command(&SCdone, SCpnt);
+ scsi_eh_finish_command(done, SCpnt);
}
- if (result != NEEDS_RETRY) {
+ if (result != NEEDS_RETRY)
continue;
- }
+
/*
* We only come in here if we want to retry a
* command. The test to see whether the command
@@ -1398,20 +1557,29 @@
*/
SCpnt->state = NEEDS_RETRY;
rtn = scsi_eh_retry_command(SCpnt);
- if (rtn != SUCCESS) {
+ if (rtn != SUCCESS)
continue;
- }
+
/*
* We eventually hand this one back to the top level.
*/
SCpnt->host->host_failed--;
- scsi_eh_finish_command(&SCdone, SCpnt);
+ scsi_eh_finish_command(done, SCpnt);
}
}
+}
+
+static void scsi_unjam_count(struct Scsi_Host *host, Scsi_Cmnd **done)
+{
+ Scsi_Device *SDpnt;
+ Scsi_Cmnd *SCpnt;
+ int devices_failed;
+ int numfailed;
+ int timed_out;
/*
- * Go through the list of commands and figure out where we stand and how bad things
- * really are.
+ * Go through the list of commands and figure out where we
+ * stand and how bad things really are.
*/
numfailed = 0;
timed_out = 0;
@@ -1421,359 +1589,478 @@
for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) {
if (SCpnt->state == SCSI_STATE_FAILED) {
- SCSI_LOG_ERROR_RECOVERY(5, printk("Command to ID %d failed\n",
- SCpnt->target));
+ SCSI_LOG_ERROR_RECOVERY(5,
+ printk("Command to ID %d failed\n",
+ SCpnt->target));
numfailed++;
device_error++;
}
if (SCpnt->state == SCSI_STATE_TIMEOUT) {
- SCSI_LOG_ERROR_RECOVERY(5, printk("Command to ID %d timedout\n",
- SCpnt->target));
+ SCSI_LOG_ERROR_RECOVERY(5,
+ printk("Command to ID %d timedout\n",
+ SCpnt->target));
timed_out++;
device_error++;
}
}
- if (device_error > 0) {
+ if (device_error > 0)
devices_failed++;
- }
}
- SCSI_LOG_ERROR_RECOVERY(2, printk("Total of %d+%d commands on %d devices require eh work\n",
- numfailed, timed_out, devices_failed));
+ SCSI_LOG_ERROR_RECOVERY(2,
+ printk("Total of %d+%d commands on %d devices require eh work\n",
+ numfailed, timed_out, devices_failed));
+}
+
+static void scsi_unjam_abort(struct Scsi_Host *host, Scsi_Cmnd **done)
+{
+ Scsi_Device *SDpnt;
+ Scsi_Cmnd *SCpnt;
+ int rtn;
- if (host->host_failed == 0) {
- ourrtn = TRUE;
- goto leave;
- }
/*
- * Next, try and see whether or not it makes sense to try and abort
- * the running command. This only works out to be the case if we have
- * one command that has timed out. If the command simply failed, it
- * makes no sense to try and abort the command, since as far as the
- * host adapter is concerned, it isn't running.
+ * Next, try and see whether or not it makes sense to try and
+ * abort the running command. This only works out to be the
+ * case if we have one command that has timed out. If the
+ * command simply failed, it makes no sense to try and abort
+ * the command, since as far as the host adapter is concerned,
+ * it isn't running.
*/
- SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Checking to see if we want to try abort\n"));
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("scsi_unjam_host: Checking to see if we want to try abort\n"));
for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
- for (SCloop = SDpnt->device_queue; SCloop; SCloop = SCloop->next) {
- if (SCloop->state != SCSI_STATE_TIMEOUT) {
+ for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) {
+ if (SCpnt->state != SCSI_STATE_TIMEOUT)
continue;
- }
- rtn = scsi_try_to_abort_command(SCloop, ABORT_TIMEOUT);
- if (rtn == SUCCESS) {
- rtn = scsi_test_unit_ready(SCloop);
-
- if (rtn == SUCCESS && scsi_unit_is_ready(SCloop)) {
- rtn = scsi_eh_retry_command(SCloop);
-
- if (rtn == SUCCESS) {
- SCloop->host->host_failed--;
- scsi_eh_finish_command(&SCdone, SCloop);
- }
- }
- }
+
+ rtn = scsi_try_to_abort_command(SCpnt, ABORT_TIMEOUT);
+ if (rtn == SUCCESS)
+ scsi_eh_test_and_retry(SCpnt, done);
}
}
+}
+
+static void scsi_unjam_device_reset(struct Scsi_Host *host, Scsi_Cmnd **done)
+{
+ Scsi_Device *SDpnt;
+ Scsi_Cmnd *SCpnt;
+ int rtn;
- /*
- * If we have corrected all of the problems, then we are done.
- */
- if (host->host_failed == 0) {
- ourrtn = TRUE;
- goto leave;
- }
/*
* Either the abort wasn't appropriate, or it didn't succeed.
- * Now try a bus device reset. Still, look to see whether we have
- * multiple devices that are jammed or not - if we have multiple devices,
- * it makes no sense to try BUS_DEVICE_RESET - we really would need
- * to try a BUS_RESET instead.
+ * Now try a bus device reset. Still, look to see whether we
+ * have multiple devices that are jammed or not - if we have
+ * multiple devices, it makes no sense to try BUS_DEVICE_RESET
+ * - we really would need to try a BUS_RESET instead.
*
- * Does this make sense - should we try BDR on each device individually?
- * Yes, definitely.
+ * Does this make sense - should we try BDR on each device
+ * individually? Yes, definitely.
*/
- SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Checking to see if we want to try BDR\n"));
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("scsi_unjam_host: Checking to see if we want to try BDR\n"));
for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
- for (SCloop = SDpnt->device_queue; SCloop; SCloop = SCloop->next) {
- if (SCloop->state == SCSI_STATE_FAILED
- || SCloop->state == SCSI_STATE_TIMEOUT) {
- break;
- }
- }
-
- if (SCloop == NULL) {
+ SCpnt = scsi_eh_find_failed_command(SDpnt);
+ if (SCpnt == NULL)
continue;
- }
+
/*
- * OK, we have a device that is having problems. Try and send
- * a bus device reset to it.
+ * OK, we have a device that is having problems.
+ * Try and send a bus device reset to it.
+ */
+ rtn = scsi_try_bus_device_reset(SCpnt, RESET_TIMEOUT);
+
+ /*
+ * A successful bus device reset causes all commands
+ * currently executing on the device to terminate.
+ * We expect the HBA driver to "forget" all commands
+ * associated with this device.
*
- * FIXME(eric) - make sure we handle the case where multiple
- * commands to the same device have failed. They all must
- * get properly restarted.
- */
- rtn = scsi_try_bus_device_reset(SCloop, RESET_TIMEOUT);
-
- if (rtn == SUCCESS) {
- rtn = scsi_test_unit_ready(SCloop);
-
- if (rtn == SUCCESS && scsi_unit_is_ready(SCloop)) {
- rtn = scsi_eh_retry_command(SCloop);
-
- if (rtn == SUCCESS) {
- SCloop->host->host_failed--;
- scsi_eh_finish_command(&SCdone, SCloop);
- }
- }
- }
+ * Retry each failed or timed out command currently
+ * outstanding for this device.
+ *
+ * If any command fails, bail out. We will try a
+ * bus reset instead.
+ */
+ if (rtn == SUCCESS)
+ scsi_eh_restart_device(SDpnt, done);
}
+}
+
+static void scsi_unjam_bus_reset(struct Scsi_Host *host, Scsi_Cmnd **done)
+{
+ Scsi_Device *SDpnt;
+ Scsi_Cmnd *SCpnt;
+ int rtn, channel, max_channel = 0;
- if (host->host_failed == 0) {
- ourrtn = TRUE;
- goto leave;
- }
/*
- * If we ended up here, we have serious problems. The only thing left
- * to try is a full bus reset. If someone has grabbed the bus and isn't
- * letting go, then perhaps this will help.
+ * If we ended up here, we have serious problems. The only thing
+ * left to try is a full bus reset. If someone has grabbed the
+ * bus and isn't letting go, then perhaps this will help.
*/
- SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Try hard bus reset\n"));
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("scsi_unjam_host: Try hard bus reset\n"));
- /*
- * We really want to loop over the various channels, and do this on
- * a channel by channel basis. We should also check to see if any
- * of the failed commands are on soft_reset devices, and if so, skip
- * the reset.
+ /*
+ * Find the maximum channel number for this host.
*/
- for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
- next_device:
- for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) {
- if (SCpnt->state != SCSI_STATE_FAILED
- && SCpnt->state != SCSI_STATE_TIMEOUT) {
+ for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next)
+ if (SDpnt->channel > max_channel)
+ max_channel = SDpnt->channel;
+
+ /*
+ * Loop over each channel, and see if it any device on
+ * each channel has failed.
+ */
+ for (channel = 0; channel <= max_channel; channel++) {
+ Scsi_Cmnd *failed_command;
+ int soft_reset;
+
+ try_again:
+ failed_command = NULL;
+ soft_reset = 0;
+
+ /*
+ * Loop over each device on this channel locating any
+ * failed command. We need a Scsi_Cmnd structure to
+ * call the bus reset function.
+ *
+ * We also need to check if any of the failed commands
+ * are on soft_reset devices, and if so, skip the reset.
+ */
+ for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
+ if (SDpnt->channel != channel)
continue;
- }
- /*
- * We have a failed command. Make sure there are no other failed
- * commands on the same channel that are timed out and implement a
- * soft reset.
- */
- for (SDloop = host->host_queue; SDloop; SDloop = SDloop->next) {
- for (SCloop = SDloop->device_queue; SCloop; SCloop = SCloop->next) {
- if (SCloop->channel != SCpnt->channel) {
- continue;
- }
- if (SCloop->state != SCSI_STATE_FAILED
- && SCloop->state != SCSI_STATE_TIMEOUT) {
- continue;
- }
- if (SDloop->soft_reset && SCloop->state == SCSI_STATE_TIMEOUT) {
- /*
- * If this device uses the soft reset option, and this
- * is one of the devices acting up, then our only
- * option is to wait a bit, since the command is
- * supposedly still running.
- *
- * FIXME(eric) - right now we will just end up falling
- * through to the 'take device offline' case.
- *
- * FIXME(eric) - It is possible that the command completed
- * *after* the error recovery procedure started, and if this
- * is the case, we are worrying about nothing here.
- */
-
- scsi_sleep(1 * HZ);
- goto next_device;
- }
- }
- }
+
+ SCpnt = scsi_eh_find_failed_command(SDpnt);
+ if (SCpnt)
+ failed_command = SCpnt;
/*
- * We now know that we are able to perform a reset for the
- * bus that SCpnt points to. There are no soft-reset devices
- * with outstanding timed out commands.
+ * If this device has timed out or failed commands,
+ * and uses the soft_reset option.
*/
- rtn = scsi_try_bus_reset(SCpnt);
- if (rtn == SUCCESS) {
- for (SDloop = host->host_queue; SDloop; SDloop = SDloop->next) {
- for (SCloop = SDloop->device_queue; SCloop; SCloop = SCloop->next) {
- if (SCloop->channel != SCpnt->channel) {
- continue;
- }
- if (SCloop->state != SCSI_STATE_FAILED
- && SCloop->state != SCSI_STATE_TIMEOUT) {
- continue;
- }
- rtn = scsi_test_unit_ready(SCloop);
-
- if (rtn == SUCCESS && scsi_unit_is_ready(SCloop)) {
- rtn = scsi_eh_retry_command(SCloop);
-
- if (rtn == SUCCESS) {
- SCpnt->host->host_failed--;
- scsi_eh_finish_command(&SCdone, SCloop);
- }
- }
- /*
- * If the bus reset worked, but we are still unable to
- * talk to the device, take it offline.
- * FIXME(eric) - is this really the correct thing to do?
- */
- if (rtn != SUCCESS) {
- printk(KERN_INFO "scsi: device set offline - not ready or command retry failed after bus reset: host %d channel %d id %d lun %d\n", SDloop->host->host_no, SDloop->channel, SDloop->id, SDloop->lun);
-
- SDloop->online = FALSE;
- SDloop->host->host_failed--;
- scsi_eh_finish_command(&SCdone, SCloop);
- }
- }
- }
+ if (SCpnt && SDpnt->soft_reset)
+ soft_reset = 1;
+ }
+
+ /*
+ * If this channel hasn't failed, we
+ * don't need to reset it.
+ */
+ if (!failed_command)
+ continue;
+
+ /*
+ * If this device uses the soft reset option, and this
+ * is one of the devices acting up, then our only
+ * option is to wait a bit, since the command is
+ * supposedly still running.
+ *
+ * FIXME(eric) - right now we will just end up falling
+ * through to the 'take device offline' case.
+ *
+ * FIXME(eric) - It is possible that the command completed
+ * *after* the error recovery procedure started, and if
+ * this is the case, we are worrying about nothing here.
+ *
+ * FIXME(rmk) - This should be bounded; we shouldn't wait
+ * for an infinite amount of time for any device.
+ */
+ if (soft_reset) {
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("scsi_unjam_host: unable to try bus "
+ "reset for host %d channel %d\n",
+ host->host_no, channel));
+ scsi_sleep(1 * HZ);
+ goto try_again;
+ }
+
+ /*
+ * We now know that we are able to perform a reset for the
+ * bus that SCpnt points to. There are no soft-reset devices
+ * with outstanding timed out commands.
+ */
+ rtn = scsi_try_bus_reset(failed_command);
+
+ /*
+ * If we failed to reset the bus, move on to the next bus.
+ */
+ if (rtn != SUCCESS)
+ continue;
+
+ /*
+ * We succeeded. Retry each failed command.
+ */
+ for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
+ if (SDpnt->channel != channel)
+ continue;
+
+ rtn = scsi_eh_restart_device(SDpnt, done);
+
+ if (rtn != SUCCESS) {
+ SCpnt = scsi_eh_find_failed_command(SDpnt);
+
+ /*
+ * This device failed again. Since a bus
+ * reset freed it up, chances are we've
+ * hit the same problem, so try the same
+ * solution. We also need to ensure that
+ * the SCSI bus is in the BUS FREE state
+ * so we can try to talk to other devices.
+ */
+ scsi_try_bus_reset(SCpnt);
+ scsi_eh_set_device_offline(SDpnt, done,
+ "not ready or command retry "
+ "failed after bus reset");
}
}
}
+}
+
+static void scsi_unjam_host_reset(struct Scsi_Host *host, Scsi_Cmnd **done)
+{
+ Scsi_Device *SDpnt;
+ Scsi_Cmnd *SCpnt;
+ Scsi_Cmnd *failed_command = NULL;
+ int rtn, soft_reset;
- if (host->host_failed == 0) {
- ourrtn = TRUE;
- goto leave;
- }
/*
- * If we ended up here, we have serious problems. The only thing left
- * to try is a full host reset - perhaps the firmware on the device
- * crashed, or something like that.
+ * If we ended up here, we have serious problems. The only thing
+ * left to try is a full host reset - perhaps the firmware on the
+ * device crashed, or something like that.
*
- * It is assumed that a succesful host reset will cause *all* information
- * about the command to be flushed from both the host adapter *and* the
- * device.
+ * It is assumed that a succesful host reset will cause *all*
+ * information about the command to be flushed from both the host
+ * adapter *and* the device.
*
- * FIXME(eric) - it isn't clear that devices that implement the soft reset
- * option can ever be cleared except via cycling the power. The problem is
- * that sending the host reset command will cause the host to forget
- * about the pending command, but the device won't forget. For now, we
- * skip the host reset option if any of the failed devices are configured
- * to use the soft reset option.
+ * FIXME(eric) - it isn't clear that devices that implement the
+ * soft reset option can ever be cleared except via cycling the
+ * power. The problem is that sending the host reset command will
+ * cause the host to forget about the pending command, but the
+ * device won't forget. For now, we skip the host reset option
+ * if any of the failed devices are configured to use the soft
+ * reset option.
*/
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("scsi_unjam_host: Try host reset\n"));
+
+ try_again:
+ failed_command = NULL;
+ soft_reset = 0;
+
for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
- next_device2:
- for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) {
- if (SCpnt->state != SCSI_STATE_FAILED
- && SCpnt->state != SCSI_STATE_TIMEOUT) {
- continue;
- }
- if (SDpnt->soft_reset && SCpnt->state == SCSI_STATE_TIMEOUT) {
- /*
- * If this device uses the soft reset option, and this
- * is one of the devices acting up, then our only
- * option is to wait a bit, since the command is
- * supposedly still running.
- *
- * FIXME(eric) - right now we will just end up falling
- * through to the 'take device offline' case.
- */
- SCSI_LOG_ERROR_RECOVERY(3,
- printk("scsi_unjam_host: Unable to try hard host reset\n"));
+ /*
+ * Locate any failed commands for this device.
+ */
+ SCpnt = scsi_eh_find_failed_command(SDpnt);
+ if (SCpnt)
+ failed_command = SCpnt;
- /*
- * Due to the spinlock, we will never get out of this
- * loop without a proper wait. (DB)
- */
- scsi_sleep(1 * HZ);
+ /*
+ * If this device has timed out or failed commands,
+ * and uses the soft_reset option.
+ */
+ if (SCpnt && SDpnt->soft_reset)
+ soft_reset = 1;
+ }
- goto next_device2;
- }
- SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Try hard host reset\n"));
+ /*
+ * If this device uses the soft reset option, and this
+ * is one of the devices acting up, then our only
+ * option is to wait a bit, since the command is
+ * supposedly still running.
+ *
+ * FIXME(eric) - right now we will just end up falling
+ * through to the 'take device offline' case.
+ *
+ * FIXME(rmk) - This should be bounded; we shouldn't wait
+ * for an infinite amount of time for any device.
+ */
+ if (soft_reset) {
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("scsi_unjam_host: unable to try "
+ "hard host reset\n"));
/*
- * FIXME(eric) - we need to obtain a valid SCpnt to perform this call.
+ * Due to the spinlock, we will never get out of this
+ * loop without a proper wait. (DB)
*/
- rtn = scsi_try_host_reset(SCpnt);
- if (rtn == SUCCESS) {
- /*
- * FIXME(eric) we assume that all commands are flushed from the
- * controller. We should get a DID_RESET for all of the commands
- * that were pending. We should ignore these so that we can
- * guarantee that we are in a consistent state.
- *
- * I believe this to be the case right now, but this needs to be
- * tested.
- */
- for (SDloop = host->host_queue; SDloop; SDloop = SDloop->next) {
- for (SCloop = SDloop->device_queue; SCloop; SCloop = SCloop->next) {
- if (SCloop->state != SCSI_STATE_FAILED
- && SCloop->state != SCSI_STATE_TIMEOUT) {
- continue;
- }
- rtn = scsi_test_unit_ready(SCloop);
-
- if (rtn == SUCCESS && scsi_unit_is_ready(SCloop)) {
- rtn = scsi_eh_retry_command(SCloop);
-
- if (rtn == SUCCESS) {
- SCpnt->host->host_failed--;
- scsi_eh_finish_command(&SCdone, SCloop);
- }
- }
- if (rtn != SUCCESS) {
- printk(KERN_INFO "scsi: device set offline - not ready or command retry failed after host reset: host %d channel %d id %d lun %d\n", SDloop->host->host_no, SDloop->channel, SDloop->id, SDloop->lun);
- SDloop->online = FALSE;
- SDloop->host->host_failed--;
- scsi_eh_finish_command(&SCdone, SCloop);
- }
- }
- }
- }
- }
- }
+ scsi_sleep(1 * HZ);
- /*
- * If we solved all of the problems, then let's rev up the engines again.
- */
- if (host->host_failed == 0) {
- ourrtn = TRUE;
- goto leave;
+ goto try_again;
}
+
+ SCSI_LOG_ERROR_RECOVERY(3,
+ printk("scsi_unjam_host: Try hard host reset\n"));
+
/*
- * If the HOST RESET failed, then for now we assume that the entire host
- * adapter is too hosed to be of any use. For our purposes, however, it is
- * easier to simply take the devices offline that correspond to commands
- * that failed.
+ * FIXME(eric) - we need to obtain a valid SCpnt to perform this call.
*/
- SCSI_LOG_ERROR_RECOVERY(1, printk("scsi_unjam_host: Take device offline\n"));
+ rtn = scsi_try_host_reset(failed_command);
+ if (rtn == SUCCESS) {
+ /*
+ * FIXME(eric) we assume that all commands are flushed from
+ * the controller. We should get a DID_RESET for all of the
+ * commands that were pending. We should ignore these so
+ * that we can guarantee that we are in a consistent state.
+ *
+ * I believe this to be the case right now, but this needs
+ * to be tested.
+ */
+ for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
+ rtn = scsi_eh_restart_device(SDpnt, done);
- for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
- for (SCloop = SDpnt->device_queue; SCloop; SCloop = SCloop->next) {
- if (SCloop->state == SCSI_STATE_FAILED || SCloop->state == SCSI_STATE_TIMEOUT) {
- SDloop = SCloop->device;
- if (SDloop->online == TRUE) {
- printk(KERN_INFO "scsi: device set offline - command error recover failed: host %d channel %d id %d lun %d\n", SDloop->host->host_no, SDloop->channel, SDloop->id, SDloop->lun);
- SDloop->online = FALSE;
- }
+ if (rtn != SUCCESS) {
+ SCpnt = scsi_eh_find_failed_command(SDpnt);
/*
- * This should pass the failure up to the top level driver, and
- * it will have to try and do something intelligent with it.
+ * This device failed again. Since a host
+ * reset freed it up, chances are we've
+ * hit the same problem, so try the same
+ * solution. We also need to ensure that
+ * the SCSI bus is in the BUS FREE state
+ * so we can try to talk to other devices.
*/
- SCloop->host->host_failed--;
-
- if (SCloop->state == SCSI_STATE_TIMEOUT) {
- SCloop->result |= (DRIVER_TIMEOUT << 24);
- }
- SCSI_LOG_ERROR_RECOVERY(3, printk("Finishing command for device %d %x\n",
- SDloop->id, SCloop->result));
-
- scsi_eh_finish_command(&SCdone, SCloop);
+ scsi_try_host_reset(SCpnt);
+ scsi_eh_set_device_offline(SDpnt, done,
+ "not ready or command retry "
+ "failed after host reset");
}
}
}
+}
+
+static void scsi_unjam_failure(struct Scsi_Host *host, Scsi_Cmnd **done)
+{
+ Scsi_Device *SDpnt;
- if (host->host_failed != 0) {
+ /*
+ * If the HOST RESET failed, then for now we assume that the
+ * entire host adapter is too hosed to be of any use. For our
+ * purposes, however, it is easier to simply take the devices
+ * offline that correspond to commands that failed.
+ */
+ SCSI_LOG_ERROR_RECOVERY(1,
+ printk("scsi_unjam_host: Take device offline\n"));
+
+ for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next)
+ scsi_eh_set_device_offline(SDpnt, done,
+ "command error recover failed");
+
+ if (host->host_failed != 0)
panic("scsi_unjam_host: Miscount of number of failed commands.\n");
- }
+
SCSI_LOG_ERROR_RECOVERY(3, printk("scsi_unjam_host: Returning\n"));
+}
+
+static void (*unjam_method[])(struct Scsi_Host *, Scsi_Cmnd **) = {
+ scsi_unjam_request_sense,
+ scsi_unjam_count,
+ scsi_unjam_abort,
+ scsi_unjam_device_reset,
+ scsi_unjam_bus_reset,
+ scsi_unjam_host_reset,
+ scsi_unjam_failure,
+};
+
+/*
+ * Function: scsi_unjam_host
+ *
+ * Purpose: Attempt to fix a host which has a command that failed for
+ * some reason.
+ *
+ * Arguments: host - host that needs unjamming.
+ *
+ * Returns: Nothing
+ *
+ * Notes: When we come in here, we *know* that all commands on the
+ * bus have either completed, failed or timed out. We also
+ * know that no further commands are being sent to the host,
+ * so things are relatively quiet and we have freedom to
+ * fiddle with things as we wish.
+ *
+ * Additional note: This is only the *default* implementation. It is possible
+ * for individual drivers to supply their own version of this
+ * function, and if the maintainer wishes to do this, it is
+ * strongly suggested that this function be taken as a template
+ * and modified. This function was designed to correctly handle
+ * problems for about 95% of the different cases out there, and
+ * it should always provide at least a reasonable amount of error
+ * recovery.
+ *
+ * Note3: Any command marked 'FAILED' or 'TIMEOUT' must eventually
+ * have scsi_finish_command() called for it. We do all of
+ * the retry stuff here, so when we restart the host after we
+ * return it should have an empty queue.
+ */
+STATIC int scsi_unjam_host(struct Scsi_Host *host)
+{
+ Scsi_Cmnd *SCdone = NULL;
+ Scsi_Cmnd *SCpnt;
+ Scsi_Device *SDpnt;
+ int ourrtn = FALSE;
+ int i;
- ourrtn = FALSE;
+ ASSERT_LOCK(&io_request_lock, 0);
- leave:
+ /*
+ * First, protect against any sort of race condition. If any of the outstanding
+ * commands are in states that indicate that we are not yet blocked (i.e. we are
+ * not in a quiet state) then we got woken up in error. If we ever end up here,
+ * we need to re-examine some of the assumptions.
+ */
+ for (SDpnt = host->host_queue; SDpnt; SDpnt = SDpnt->next) {
+ for (SCpnt = SDpnt->device_queue; SCpnt; SCpnt = SCpnt->next) {
+ if (SCpnt->state == SCSI_STATE_FAILED
+ || SCpnt->state == SCSI_STATE_TIMEOUT
+ || SCpnt->state == SCSI_STATE_INITIALIZING
+ || SCpnt->state == SCSI_STATE_UNUSED) {
+ continue;
+ }
+ /*
+ * Rats. Something is still floating around out there. This could
+ * be the result of the fact that the upper level drivers are still frobbing
+ * commands that might have succeeded. There are two outcomes. One is that
+ * the command block will eventually be freed, and the other one is that
+ * the command will be queued and will be finished along the way.
+ */
+ SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler prematurely woken - commands still active (%p %x %d)\n", SCpnt, SCpnt->state, SCpnt->target));
+
+/*
+ * panic("SCSI Error handler woken too early\n");
+ *
+ * This is no longer a problem, since now the code cares only about
+ * SCSI_STATE_TIMEOUT and SCSI_STATE_FAILED.
+ * Other states are useful only to release active commands when devices are
+ * set offline. If (host->host_active == host->host_busy) we can safely assume
+ * that there are no commands in state other then TIMEOUT od FAILED. (DB)
+ *
+ * FIXME:
+ * It is not easy to release correctly commands according to their state when
+ * devices are set offline, when the state is neither TIMEOUT nor FAILED.
+ * When a device is set offline, we can have some command with
+ * rq_status=RQ_SCSY_BUSY, owner=SCSI_STATE_HIGHLEVEL,
+ * state=SCSI_STATE_INITIALIZING and the driver module cannot be released.
+ * (DB, 17 May 1998)
+ */
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(unjam_method); i++) {
+ unjam_method[i](host, &SCdone);
+
+ /*
+ * If we solved all of the problems, then
+ * let's rev up the engines again.
+ */
+ if (host->host_failed == 0) {
+ ourrtn = TRUE;
+ break;
+ }
+ }
/*
* We should have a list of commands that we 'finished' during the course of
@@ -2013,3 +2300,17 @@
* tab-width: 8
* End:
*/
+
+EXPORT_SYMBOL(scsi_eh_times_out);
+EXPORT_SYMBOL(scsi_eh_retry_command);
+EXPORT_SYMBOL(scsi_request_sense);
+EXPORT_SYMBOL(scsi_test_unit_ready);
+EXPORT_SYMBOL(scsi_unit_is_ready);
+EXPORT_SYMBOL(scsi_eh_finish_command);
+EXPORT_SYMBOL(scsi_try_to_abort_command);
+EXPORT_SYMBOL(scsi_try_bus_device_reset);
+EXPORT_SYMBOL(scsi_try_bus_reset);
+EXPORT_SYMBOL(scsi_try_host_reset);
+EXPORT_SYMBOL(scsi_sense_valid);
+EXPORT_SYMBOL(scsi_done);
+EXPORT_SYMBOL(scsi_decide_disposition);
diff -urN linux-2.4.26/drivers/scsi/scsi_ioctl.c linux-2.4.26-vrs1/drivers/scsi/scsi_ioctl.c
--- linux-2.4.26/drivers/scsi/scsi_ioctl.c 2003-08-25 12:44:42.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/scsi/scsi_ioctl.c 2004-01-14 21:39:12.000000000 +0000
@@ -153,6 +153,29 @@
return result;
}
+int scsi_set_medium_removal(Scsi_Device *dev, char state)
+{
+ char scsi_cmd[MAX_COMMAND_SIZE];
+ int ret;
+
+ if (!dev->removable || !dev->lockable)
+ return 0;
+
+ scsi_cmd[0] = ALLOW_MEDIUM_REMOVAL;
+ scsi_cmd[1] = (dev->scsi_level <= SCSI_2) ? (dev->lun << 5) : 0;
+ scsi_cmd[2] = 0;
+ scsi_cmd[3] = 0;
+ scsi_cmd[4] = state;
+ scsi_cmd[5] = 0;
+
+ ret = ioctl_internal_command(dev, scsi_cmd, IOCTL_NORMAL_TIMEOUT, NORMAL_RETRIES);
+
+ if (ret == 0)
+ dev->locked = state == SCSI_REMOVAL_PREVENT;
+
+ return ret;
+}
+
/*
* This interface is depreciated - users should use the scsi generic (sg)
* interface instead, as this is a more flexible approach to performing
@@ -450,24 +473,9 @@
return scsi_ioctl_send_command((Scsi_Device *) dev,
(Scsi_Ioctl_Command *) arg);
case SCSI_IOCTL_DOORLOCK:
- if (!dev->removable || !dev->lockable)
- return 0;
- scsi_cmd[0] = ALLOW_MEDIUM_REMOVAL;
- scsi_cmd[1] = cmd_byte1;
- scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[5] = 0;
- scsi_cmd[4] = SCSI_REMOVAL_PREVENT;
- return ioctl_internal_command((Scsi_Device *) dev, scsi_cmd,
- IOCTL_NORMAL_TIMEOUT, NORMAL_RETRIES);
- break;
+ return scsi_set_medium_removal(dev, SCSI_REMOVAL_PREVENT);
case SCSI_IOCTL_DOORUNLOCK:
- if (!dev->removable || !dev->lockable)
- return 0;
- scsi_cmd[0] = ALLOW_MEDIUM_REMOVAL;
- scsi_cmd[1] = cmd_byte1;
- scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[5] = 0;
- scsi_cmd[4] = SCSI_REMOVAL_ALLOW;
- return ioctl_internal_command((Scsi_Device *) dev, scsi_cmd,
- IOCTL_NORMAL_TIMEOUT, NORMAL_RETRIES);
+ return scsi_set_medium_removal(dev, SCSI_REMOVAL_ALLOW);
case SCSI_IOCTL_TEST_UNIT_READY:
scsi_cmd[0] = TEST_UNIT_READY;
scsi_cmd[1] = cmd_byte1;
diff -urN linux-2.4.26/drivers/scsi/scsi_lib.c linux-2.4.26-vrs1/drivers/scsi/scsi_lib.c
--- linux-2.4.26/drivers/scsi/scsi_lib.c 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/scsi/scsi_lib.c 2004-04-18 21:47:51.000000000 +0100
@@ -208,6 +208,30 @@
}
/*
+ * Function: scsi_setup_cmd_retry()
+ *
+ * Purpose: Restore the command state for a retry
+ *
+ * Arguments: SCpnt - command to be restored
+ *
+ * Returns: Nothing
+ *
+ * Notes: Immediately prior to retrying a command, we need
+ * to restore certain fields that we saved above.
+ */
+void scsi_setup_cmd_retry(Scsi_Cmnd *SCpnt)
+{
+ memcpy((void *) SCpnt->cmnd, (void *) SCpnt->data_cmnd,
+ sizeof(SCpnt->data_cmnd));
+ SCpnt->request_buffer = SCpnt->buffer;
+ SCpnt->request_bufflen = SCpnt->bufflen;
+ SCpnt->use_sg = SCpnt->old_use_sg;
+ SCpnt->cmd_len = SCpnt->old_cmd_len;
+ SCpnt->sc_data_direction = SCpnt->sc_old_data_direction;
+ SCpnt->underflow = SCpnt->old_underflow;
+}
+
+/*
* Function: scsi_queue_next_request()
*
* Purpose: Handle post-processing of completed commands.
@@ -731,7 +755,7 @@
printk("scsi%d: ERROR on channel %d, id %d, lun %d, CDB: ",
SCpnt->host->host_no, (int) SCpnt->channel,
(int) SCpnt->target, (int) SCpnt->lun);
- print_command(SCpnt->cmnd);
+ print_command(SCpnt->data_cmnd);
print_sense("sd", SCpnt);
SCpnt = scsi_end_request(SCpnt, 0, block_sectors);
return;
@@ -906,8 +930,17 @@
* space. Technically the error handling thread should be
* doing this crap, but the error handler isn't used by
* most hosts.
+ *
+ * (rmk)
+ * Trying to lock the door can cause deadlocks. We therefore
+ * only use this for old hosts; our door locking is now done
+ * by the error handler in scsi_restart_operations for new
+ * eh hosts.
+ *
+ * Note that we don't clear was_reset here; this is used by
+ * st.c, and either one or other has to die.
*/
- if (SDpnt->was_reset) {
+ if (SHpnt->hostt->use_new_eh_code == 0 && SDpnt->was_reset) {
/*
* We need to relock the door, but we might
* be in an interrupt handler. Only do this
@@ -918,7 +951,7 @@
* this work.
*/
SDpnt->was_reset = 0;
- if (SDpnt->removable && !in_interrupt()) {
+ if (SDpnt->removable && SDpnt->locked && !in_interrupt()) {
spin_unlock_irq(&io_request_lock);
scsi_ioctl(SDpnt, SCSI_IOCTL_DOORLOCK, 0);
spin_lock_irq(&io_request_lock);
diff -urN linux-2.4.26/drivers/scsi/scsi_syms.c linux-2.4.26-vrs1/drivers/scsi/scsi_syms.c
--- linux-2.4.26/drivers/scsi/scsi_syms.c 2004-04-19 11:44:16.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/scsi/scsi_syms.c 2004-04-18 21:47:51.000000000 +0100
@@ -104,3 +104,6 @@
extern int scsi_delete_timer(Scsi_Cmnd *);
EXPORT_SYMBOL(scsi_add_timer);
EXPORT_SYMBOL(scsi_delete_timer);
+
+extern int scsi_set_medium_removal(Scsi_Device *dev, char state);
+EXPORT_SYMBOL(scsi_set_medium_removal);
diff -urN linux-2.4.26/drivers/scsi/sd.c linux-2.4.26-vrs1/drivers/scsi/sd.c
--- linux-2.4.26/drivers/scsi/sd.c 2003-08-25 12:44:42.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/scsi/sd.c 2004-01-14 21:39:12.000000000 +0000
@@ -399,6 +399,7 @@
this_count = 0xffff;
SCpnt->cmnd[0] += READ_10 - READ_6;
+ SCpnt->cmnd[1] |= 1 << 3; /* Set FUA --rmk */
SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff;
SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff;
SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff;
@@ -524,7 +525,7 @@
if (SDev->removable)
if (SDev->access_count==1)
if (scsi_block_when_processing_errors(SDev))
- scsi_ioctl(SDev, SCSI_IOCTL_DOORLOCK, NULL);
+ scsi_set_medium_removal(SDev, SCSI_REMOVAL_PREVENT);
return 0;
@@ -553,7 +554,7 @@
if (SDev->removable) {
if (!SDev->access_count)
if (scsi_block_when_processing_errors(SDev))
- scsi_ioctl(SDev, SCSI_IOCTL_DOORUNLOCK, NULL);
+ scsi_set_medium_removal(SDev, SCSI_REMOVAL_ALLOW);
}
if (SDev->host->hostt->module)
__MOD_DEC_USE_COUNT(SDev->host->hostt->module);
diff -urN linux-2.4.26/drivers/scsi/sr_ioctl.c linux-2.4.26-vrs1/drivers/scsi/sr_ioctl.c
--- linux-2.4.26/drivers/scsi/sr_ioctl.c 2002-11-28 23:53:14.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/scsi/sr_ioctl.c 2004-01-14 21:32:26.000000000 +0000
@@ -214,9 +214,8 @@
int sr_lock_door(struct cdrom_device_info *cdi, int lock)
{
- return scsi_ioctl(scsi_CDs[MINOR(cdi->dev)].device,
- lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK,
- 0);
+ return scsi_set_medium_removal(scsi_CDs[MINOR(cdi->dev)].device,
+ lock ? SCSI_REMOVAL_PREVENT : SCSI_REMOVAL_ALLOW);
}
int sr_drive_status(struct cdrom_device_info *cdi, int slot)
diff -urN linux-2.4.26/drivers/serial/21285.c linux-2.4.26-vrs1/drivers/serial/21285.c
--- linux-2.4.26/drivers/serial/21285.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/21285.c 2004-04-04 23:11:12.000000000 +0100
@@ -0,0 +1,599 @@
+/*
+ * linux/drivers/char/serial_21285.c
+ *
+ * Driver for the serial port on the 21285 StrongArm-110 core logic chip.
+ *
+ * Based on drivers/char/serial.c
+ *
+ * $Id: 21285.c,v 1.4.2.1 2002/10/24 09:53:23 rmk Exp $
+ */
+#include <linux/config.h>
+#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/serial.h>
+#include <linux/major.h>
+#include <linux/ptrace.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/console.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+#include <asm/hardware/dec21285.h>
+#include <asm/hardware.h>
+
+#define BAUD_BASE (mem_fclk_21285/64)
+
+#ifdef CONFIG_DEVFS_FS
+#define SERIAL_21285_NAME "tts/FB%d"
+#define SERIAL_21285_AUXNAME "cua/FB%d"
+#else
+#define SERIAL_21285_NAME "ttyFB"
+#define SERIAL_21285_AUXNAME "cuafb"
+#endif
+
+#define SERIAL_21285_MAJOR 204
+#define SERIAL_21285_MINOR 4
+
+#define SERIAL_21285_AUXMAJOR 205
+#define SERIAL_21285_AUXMINOR 4
+
+#ifdef CONFIG_SERIAL_21285_OLD
+#include <asm/mach-types.h>
+/*
+ * Compatability with a mistake made a long time ago.
+ * Note - the use of "ttyI", "/dev/ttyS0" and major/minor 5,64
+ * is HIGHLY DEPRECIATED, and will be removed in the 2.5
+ * kernel series.
+ * -- rmk 15/04/2000
+ */
+#define SERIAL_21285_OLD_NAME "ttyI"
+#define SERIAL_21285_OLD_MAJOR TTY_MAJOR
+#define SERIAL_21285_OLD_MINOR 64
+
+static struct tty_driver rs285_old_driver;
+#endif
+
+static struct tty_driver rs285_driver, callout_driver;
+static int rs285_refcount;
+static struct tty_struct *rs285_table[1];
+
+static struct termios *rs285_termios[1];
+static struct termios *rs285_termios_locked[1];
+
+static char wbuf[1000], *putp = wbuf, *getp = wbuf, x_char;
+static struct tty_struct *rs285_tty;
+static DECLARE_MUTEX(rs285_sem);
+static int rs285_use_count;
+static unsigned long rs285_irq_enabled;
+
+#define TX_IRQ_BIT (0)
+#define RX_IRQ_BIT (1)
+
+static void rs285_stop_tx(void)
+{
+ if (test_and_clear_bit(TX_IRQ_BIT, &rs285_irq_enabled))
+ disable_irq(IRQ_CONTX);
+}
+
+static void rs285_start_tx(void)
+{
+ if (!test_and_set_bit(TX_IRQ_BIT, &rs285_irq_enabled))
+ enable_irq(IRQ_CONTX);
+}
+
+static void rs285_stop_rx(void)
+{
+ if (test_and_clear_bit(RX_IRQ_BIT, &rs285_irq_enabled))
+ disable_irq(IRQ_CONRX);
+}
+
+static void rs285_start_rx(void)
+{
+ if (!test_and_set_bit(RX_IRQ_BIT, &rs285_irq_enabled))
+ enable_irq(IRQ_CONRX);
+}
+
+static int rs285_write_room(struct tty_struct *tty)
+{
+ return putp >= getp ? (sizeof(wbuf) - (long) putp + (long) getp) : ((long) getp - (long) putp - 1);
+}
+
+static void rs285_rx_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+ if (!rs285_tty) {
+ rs285_stop_rx();
+ return;
+ }
+ while (!(*CSR_UARTFLG & 0x10)) {
+ int ch, flag;
+ ch = *CSR_UARTDR;
+ flag = *CSR_RXSTAT;
+ if (flag & 4)
+ tty_insert_flip_char(rs285_tty, 0, TTY_OVERRUN);
+ if (flag & 2)
+ flag = TTY_PARITY;
+ else if (flag & 1)
+ flag = TTY_FRAME;
+ tty_insert_flip_char(rs285_tty, ch, flag);
+ }
+ tty_flip_buffer_push(rs285_tty);
+}
+
+static void rs285_send_xchar(struct tty_struct *tty, char ch)
+{
+ x_char = ch;
+ rs285_start_tx();
+}
+
+static void rs285_throttle(struct tty_struct *tty)
+{
+ if (I_IXOFF(tty))
+ rs285_send_xchar(tty, STOP_CHAR(tty));
+}
+
+static void rs285_unthrottle(struct tty_struct *tty)
+{
+ if (I_IXOFF(tty)) {
+ if (x_char)
+ x_char = 0;
+ else
+ rs285_send_xchar(tty, START_CHAR(tty));
+ }
+}
+
+static void rs285_tx_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+ while (!(*CSR_UARTFLG & 0x20)) {
+ if (x_char) {
+ *CSR_UARTDR = x_char;
+ x_char = 0;
+ continue;
+ }
+ if (putp == getp) {
+ rs285_stop_tx();
+ break;
+ }
+ *CSR_UARTDR = *getp;
+ if (++getp >= wbuf + sizeof(wbuf))
+ getp = wbuf;
+ }
+ if (rs285_tty)
+ wake_up_interruptible(&rs285_tty->write_wait);
+}
+
+static inline int rs285_xmit(int ch)
+{
+ if (putp + 1 == getp || (putp + 1 == wbuf + sizeof(wbuf) && getp == wbuf))
+ return 0;
+ *putp = ch;
+ if (++putp >= wbuf + sizeof(wbuf))
+ putp = wbuf;
+ rs285_start_tx();
+ return 1;
+}
+
+static int rs285_write(struct tty_struct *tty, int from_user,
+ const u_char * buf, int count)
+{
+ int i;
+
+ if (from_user && verify_area(VERIFY_READ, buf, count))
+ return -EINVAL;
+
+ for (i = 0; i < count; i++) {
+ char ch;
+ if (from_user)
+ __get_user(ch, buf + i);
+ else
+ ch = buf[i];
+ if (!rs285_xmit(ch))
+ break;
+ }
+ return i;
+}
+
+static void rs285_put_char(struct tty_struct *tty, u_char ch)
+{
+ rs285_xmit(ch);
+}
+
+static int rs285_chars_in_buffer(struct tty_struct *tty)
+{
+ return sizeof(wbuf) - rs285_write_room(tty);
+}
+
+static void rs285_flush_buffer(struct tty_struct *tty)
+{
+ rs285_stop_tx();
+ putp = getp = wbuf;
+ if (x_char)
+ rs285_start_tx();
+}
+
+static inline void rs285_set_cflag(int cflag)
+{
+ int h_lcr, baud, quot;
+
+ switch (cflag & CSIZE) {
+ case CS5:
+ h_lcr = 0x10;
+ break;
+ case CS6:
+ h_lcr = 0x30;
+ break;
+ case CS7:
+ h_lcr = 0x50;
+ break;
+ default: /* CS8 */
+ h_lcr = 0x70;
+ break;
+
+ }
+ if (cflag & CSTOPB)
+ h_lcr |= 0x08;
+ if (cflag & PARENB)
+ h_lcr |= 0x02;
+ if (!(cflag & PARODD))
+ h_lcr |= 0x04;
+
+ switch (cflag & CBAUD) {
+ case B200: baud = 200; break;
+ case B300: baud = 300; break;
+ case B1200: baud = 1200; break;
+ case B1800: baud = 1800; break;
+ case B2400: baud = 2400; break;
+ case B4800: baud = 4800; break;
+ default:
+ case B9600: baud = 9600; break;
+ case B19200: baud = 19200; break;
+ case B38400: baud = 38400; break;
+ case B57600: baud = 57600; break;
+ case B115200: baud = 115200; break;
+ }
+
+ /*
+ * The documented expression for selecting the divisor is:
+ * BAUD_BASE / baud - 1
+ * However, typically BAUD_BASE is not divisible by baud, so
+ * we want to select the divisor that gives us the minimum
+ * error. Therefore, we want:
+ * int(BAUD_BASE / baud - 0.5) ->
+ * int(BAUD_BASE / baud - (baud >> 1) / baud) ->
+ * int((BAUD_BASE - (baud >> 1)) / baud)
+ */
+ quot = (BAUD_BASE - (baud >> 1)) / baud;
+
+ *CSR_UARTCON = 0;
+ *CSR_L_UBRLCR = quot & 0xff;
+ *CSR_M_UBRLCR = (quot >> 8) & 0x0f;
+ *CSR_H_UBRLCR = h_lcr;
+ *CSR_UARTCON = 1;
+}
+
+static void rs285_set_termios(struct tty_struct *tty, struct termios *old)
+{
+ if (old && tty->termios->c_cflag == old->c_cflag)
+ return;
+ rs285_set_cflag(tty->termios->c_cflag);
+}
+
+
+static void rs285_stop(struct tty_struct *tty)
+{
+ rs285_stop_tx();
+}
+
+static void rs285_start(struct tty_struct *tty)
+{
+ rs285_start_tx();
+}
+
+static void rs285_wait_until_sent(struct tty_struct *tty, int timeout)
+{
+ int orig_jiffies = jiffies;
+ while (*CSR_UARTFLG & 8) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(1);
+ if (signal_pending(current))
+ break;
+ if (timeout && time_after(jiffies, orig_jiffies + timeout))
+ break;
+ }
+ set_current_state(TASK_RUNNING);
+}
+
+static int rs285_open(struct tty_struct *tty, struct file *filp)
+{
+ int line, ret;
+
+ MOD_INC_USE_COUNT;
+
+ line = MINOR(tty->device) - tty->driver.minor_start;
+ if (line)
+ return -ENODEV;
+
+ ret = down_interruptible(&rs285_sem);
+ if (ret)
+ return ret;
+
+ tty->driver_data = NULL;
+ rs285_tty = tty;
+
+ if (rs285_use_count == 0) {
+ rs285_irq_enabled = 3;
+ ret = request_irq(IRQ_CONRX, rs285_rx_int, 0, "rs285", NULL);
+ if (ret == 0) {
+ ret = request_irq(IRQ_CONTX, rs285_tx_int, 0, "rs285",
+ NULL);
+ if (ret)
+ free_irq(IRQ_CONRX, NULL);
+ }
+ }
+
+ if (ret == 0)
+ rs285_use_count++;
+
+ up(&rs285_sem);
+
+ return ret;
+}
+
+static void rs285_close(struct tty_struct *tty, struct file *filp)
+{
+ down(&rs285_sem);
+ if (!--rs285_use_count) {
+ rs285_wait_until_sent(tty, 0);
+ rs285_stop_rx();
+ rs285_stop_tx();
+ rs285_tty = NULL;
+ free_irq(IRQ_CONTX, NULL);
+ free_irq(IRQ_CONRX, NULL);
+ }
+ up(&rs285_sem);
+ MOD_DEC_USE_COUNT;
+}
+
+static int __init rs285_init(void)
+{
+ int baud = B9600;
+
+ if (machine_is_personal_server())
+ baud = B57600;
+
+ rs285_driver.magic = TTY_DRIVER_MAGIC;
+ rs285_driver.driver_name = "serial_21285";
+ rs285_driver.name = SERIAL_21285_NAME;
+ rs285_driver.major = SERIAL_21285_MAJOR;
+ rs285_driver.minor_start = SERIAL_21285_MINOR;
+ rs285_driver.num = 1;
+ rs285_driver.type = TTY_DRIVER_TYPE_SERIAL;
+ rs285_driver.subtype = SERIAL_TYPE_NORMAL;
+ rs285_driver.init_termios = tty_std_termios;
+ rs285_driver.init_termios.c_cflag = baud | CS8 | CREAD | HUPCL | CLOCAL;
+ rs285_driver.flags = TTY_DRIVER_REAL_RAW;
+ rs285_driver.refcount = &rs285_refcount;
+ rs285_driver.table = rs285_table;
+ rs285_driver.termios = rs285_termios;
+ rs285_driver.termios_locked = rs285_termios_locked;
+
+ rs285_driver.open = rs285_open;
+ rs285_driver.close = rs285_close;
+ rs285_driver.write = rs285_write;
+ rs285_driver.put_char = rs285_put_char;
+ rs285_driver.write_room = rs285_write_room;
+ rs285_driver.chars_in_buffer = rs285_chars_in_buffer;
+ rs285_driver.flush_buffer = rs285_flush_buffer;
+ rs285_driver.throttle = rs285_throttle;
+ rs285_driver.unthrottle = rs285_unthrottle;
+ rs285_driver.send_xchar = rs285_send_xchar;
+ rs285_driver.set_termios = rs285_set_termios;
+ rs285_driver.stop = rs285_stop;
+ rs285_driver.start = rs285_start;
+ rs285_driver.wait_until_sent = rs285_wait_until_sent;
+
+ callout_driver = rs285_driver;
+ callout_driver.name = SERIAL_21285_AUXNAME;
+ callout_driver.major = SERIAL_21285_AUXMAJOR;
+ callout_driver.subtype = SERIAL_TYPE_CALLOUT;
+
+#ifdef CONFIG_SERIAL_21285_OLD
+ if (!machine_is_ebsa285() && !machine_is_netwinder()) {
+ rs285_old_driver = rs285_driver;
+ rs285_old_driver.name = SERIAL_21285_OLD_NAME;
+ rs285_old_driver.major = SERIAL_21285_OLD_MAJOR;
+ rs285_old_driver.minor_start = SERIAL_21285_OLD_MINOR;
+
+ if (tty_register_driver(&rs285_old_driver))
+ printk(KERN_ERR "Couldn't register old 21285 serial driver\n");
+ }
+#endif
+
+ if (tty_register_driver(&rs285_driver))
+ printk(KERN_ERR "Couldn't register 21285 serial driver\n");
+ if (tty_register_driver(&callout_driver))
+ printk(KERN_ERR "Couldn't register 21285 callout driver\n");
+
+ return 0;
+}
+
+static void __exit rs285_fini(void)
+{
+ unsigned long flags;
+ int ret;
+
+ save_flags(flags);
+ cli();
+ ret = tty_unregister_driver(&callout_driver);
+ if (ret)
+ printk(KERN_ERR "Unable to unregister 21285 callout driver "
+ "(%d)\n", ret);
+ ret = tty_unregister_driver(&rs285_driver);
+ if (ret)
+ printk(KERN_ERR "Unable to unregister 21285 driver (%d)\n",
+ ret);
+#ifdef CONFIG_SERIAL_21285_OLD
+ if (!machine_is_ebsa285() && !machine_is_netwinder()) {
+ ret = tty_unregister_driver(&rs285_old_driver);
+ if (ret)
+ printk(KERN_ERR "Unable to unregister old 21285 "
+ "driver (%d)\n", ret);
+ }
+#endif
+ free_irq(IRQ_CONTX, NULL);
+ free_irq(IRQ_CONRX, NULL);
+ restore_flags(flags);
+}
+
+module_init(rs285_init);
+module_exit(rs285_fini);
+
+#ifdef CONFIG_SERIAL_21285_CONSOLE
+/************** console driver *****************/
+
+static void rs285_console_write(struct console *co, const char *s, u_int count)
+{
+ int i;
+
+ rs285_stop_tx();
+ for (i = 0; i < count; i++) {
+ while (*CSR_UARTFLG & 0x20);
+ *CSR_UARTDR = s[i];
+ if (s[i] == '\n') {
+ while (*CSR_UARTFLG & 0x20);
+ *CSR_UARTDR = '\r';
+ }
+ }
+ rs285_start_tx();
+}
+
+static kdev_t rs285_console_device(struct console *c)
+{
+ return MKDEV(SERIAL_21285_MAJOR, SERIAL_21285_MINOR);
+}
+
+static int __init rs285_console_setup(struct console *co, char *options)
+{
+ int baud = 9600;
+ int bits = 8;
+ int parity = 'n';
+ int flow;
+ int cflag = CREAD | HUPCL | CLOCAL;
+
+ if (machine_is_personal_server())
+ baud = 57600;
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+
+ /*
+ * Now construct a cflag setting.
+ */
+ switch (baud) {
+ case 1200:
+ cflag |= B1200;
+ break;
+ case 2400:
+ cflag |= B2400;
+ break;
+ case 4800:
+ cflag |= B4800;
+ break;
+ case 9600:
+ cflag |= B9600;
+ break;
+ case 19200:
+ cflag |= B19200;
+ break;
+ case 38400:
+ cflag |= B38400;
+ break;
+ case 57600:
+ cflag |= B57600;
+ break;
+ case 115200:
+ cflag |= B115200;
+ break;
+ default:
+ cflag |= B9600;
+ break;
+ }
+ switch (bits) {
+ case 7:
+ cflag |= CS7;
+ break;
+ default:
+ cflag |= CS8;
+ break;
+ }
+ switch (parity) {
+ case 'o':
+ case 'O':
+ cflag |= PARODD;
+ break;
+ case 'e':
+ case 'E':
+ cflag |= PARENB;
+ break;
+ }
+ co->cflag = cflag;
+ rs285_set_cflag(cflag);
+ rs285_console_write(NULL, "\e[2J\e[Hboot ", 12);
+ if (options)
+ rs285_console_write(NULL, options, strlen(options));
+ else
+ rs285_console_write(NULL, "no options", 10);
+ rs285_console_write(NULL, "\n", 1);
+
+ return 0;
+}
+
+#ifdef CONFIG_SERIAL_21285_OLD
+static struct console rs285_old_cons =
+{
+ SERIAL_21285_OLD_NAME,
+ rs285_console_write,
+ NULL,
+ rs285_console_device,
+ NULL,
+ rs285_console_setup,
+ CON_PRINTBUFFER,
+ -1,
+ 0,
+ NULL
+};
+#endif
+
+static struct console rs285_cons =
+{
+ name: SERIAL_21285_NAME,
+ write: rs285_console_write,
+ device: rs285_console_device,
+ setup: rs285_console_setup,
+ flags: CON_PRINTBUFFER,
+ index: -1,
+};
+
+void __init rs285_console_init(void)
+{
+#ifdef CONFIG_SERIAL_21285_OLD
+ if (!machine_is_ebsa285() && !machine_is_netwinder())
+ register_console(&rs285_old_cons);
+#endif
+ register_console(&rs285_cons);
+}
+
+#endif /* CONFIG_SERIAL_21285_CONSOLE */
+
+EXPORT_NO_SYMBOLS;
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Intel Footbridge (21285) serial driver");
diff -urN linux-2.4.26/drivers/serial/8250.c linux-2.4.26-vrs1/drivers/serial/8250.c
--- linux-2.4.26/drivers/serial/8250.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/8250.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,2170 @@
+/*
+ * linux/drivers/serial/8250.c
+ *
+ * Driver for 8250/16550-type serial ports
+ *
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * Copyright (C) 2001 Russell King.
+ *
+ * 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.
+ *
+ * $Id: 8250.c,v 1.14.2.8 2002/10/24 14:31:31 rmk Exp $
+ *
+ * A note about mapbase / membase
+ *
+ * mapbase is the physical address of the IO port. Currently, we don't
+ * support this very well, and it may well be dropped from this driver
+ * in future. As such, mapbase should be NULL.
+ *
+ * membase is an 'ioremapped' cookie. This is compatible with the old
+ * serial.c driver, and is currently the preferred form.
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/major.h>
+#include <linux/ptrace.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/serial.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+#include <linux/serial_reg.h>
+#include <linux/serialP.h>
+#include <linux/delay.h>
+#include <linux/serial_core.h>
+#include <linux/kmod.h>
+
+#include <asm/system.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+#include <asm/bitops.h>
+
+#include "8250.h"
+
+/*
+ * Configuration:
+ * share_irqs - whether we pass SA_SHIRQ to request_irq(). This option
+ * is unsafe when used on edge-triggered interrupts.
+ */
+unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
+
+/*
+ * Debugging.
+ */
+#if 0
+#define DEBUG_AUTOCONF(fmt...) printk(fmt)
+#else
+#define DEBUG_AUTOCONF(fmt...) do { } while (0)
+#endif
+
+#if 0
+#define DEBUG_INTR(fmt...) printk(fmt)
+#else
+#define DEBUG_INTR(fmt...) do { } while (0)
+#endif
+
+#define PASS_LIMIT 256
+
+/*
+ * We default to IRQ0 for the "no irq" hack. Some
+ * machine types want others as well - they're free
+ * to redefine this in their header file.
+ */
+#define is_real_interrupt(irq) ((irq) != 0)
+
+/*
+ * This converts from our new CONFIG_ symbols to the symbols
+ * that asm/serial.h expects. You _NEED_ to comment out the
+ * linux/config.h include contained inside asm/serial.h for
+ * this to work.
+ */
+#undef CONFIG_SERIAL_MANY_PORTS
+#undef CONFIG_SERIAL_DETECT_IRQ
+#undef CONFIG_SERIAL_MULTIPORT
+#undef CONFIG_HUB6
+
+#ifdef CONFIG_SERIAL_8250_DETECT_IRQ
+#define CONFIG_SERIAL_DETECT_IRQ 1
+#endif
+#ifdef CONFIG_SERIAL_8250_MULTIPORT
+#define CONFIG_SERIAL_MULTIPORT 1
+#endif
+#ifdef CONFIG_SERIAL_8250_HUB6
+#define CONFIG_HUB6 1
+#endif
+#ifdef CONFIG_SERIAL_8250_MANY_PORTS
+#define CONFIG_SERIAL_MANY_PORTS 1
+#endif
+
+#include <asm/serial.h>
+
+static struct old_serial_port old_serial_port[] = {
+ SERIAL_PORT_DFNS /* defined in asm/serial.h */
+};
+
+#define UART_NR ARRAY_SIZE(old_serial_port)
+
+static struct tty_driver normal, callout;
+static struct tty_struct *serial8250_table[UART_NR];
+static struct termios *serial8250_termios[UART_NR], *serial8250_termios_locked[UART_NR];
+
+#if defined(CONFIG_SERIAL_8250_RSA) && defined(MODULE)
+
+#define PORT_RSA_MAX 4
+static int probe_rsa[PORT_RSA_MAX];
+static int force_rsa[PORT_RSA_MAX];
+#endif /* CONFIG_SERIAL_8250_RSA */
+
+struct uart_8250_port {
+ struct uart_port port;
+ struct timer_list timer; /* "no irq" timer */
+ struct list_head list; /* ports on this IRQ */
+ unsigned int capabilities; /* port capabilities */
+ unsigned char acr;
+ unsigned char ier;
+ unsigned short rev;
+ unsigned char lcr;
+ unsigned char mcr;
+ unsigned char mcr_mask; /* mask of user bits */
+ unsigned char mcr_force; /* mask of forced bits */
+ unsigned char efr;
+ unsigned int lsr_break_flag;
+
+ /*
+ * We provide a per-port pm hook.
+ */
+ void (*pm)(struct uart_port *port,
+ unsigned int state, unsigned int old);
+};
+
+struct irq_info {
+ spinlock_t lock;
+ struct list_head *head;
+};
+
+static struct irq_info irq_lists[NR_IRQS];
+
+/*
+ * Here we define the default xmit fifo size used for each type of UART.
+ */
+static const struct serial_uart_config uart_config[PORT_MAX_8250+1] = {
+ { "unknown", 1, 0 },
+ { "8250", 1, 0 },
+ { "16450", 1, 0 },
+ { "16550", 1, 0 },
+ { "16550A", 16, UART_CLEAR_FIFO | UART_USE_FIFO },
+ { "Cirrus", 1, 0 },
+ { "ST16650", 1, UART_CLEAR_FIFO | UART_STARTECH },
+ { "ST16650V2", 32, UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH },
+ { "TI16750", 64, UART_CLEAR_FIFO | UART_USE_FIFO },
+ { "Startech", 1, 0 },
+ { "16C950/954", 128, UART_CLEAR_FIFO | UART_USE_FIFO },
+ { "ST16654", 64, UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH },
+ { "XR16850", 128, UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH },
+ { "RSA", 2048, UART_CLEAR_FIFO | UART_USE_FIFO }
+};
+
+static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset)
+{
+ offset <<= up->port.regshift;
+
+ switch (up->port.iotype) {
+#ifdef CONFIG_SERIAL_8250_HUB6
+ case SERIAL_IO_HUB6:
+ outb(up->port.hub6 - 1 + offset, up->port.iobase);
+ return inb(up->port.iobase + 1);
+#endif
+
+ case SERIAL_IO_MEM:
+ return readb(up->port.membase + offset);
+
+ default:
+ return inb(up->port.iobase + offset);
+ }
+}
+
+static _INLINE_ void
+serial_out(struct uart_8250_port *up, int offset, int value)
+{
+ offset <<= up->port.regshift;
+
+ switch (up->port.iotype) {
+#ifdef CONFIG_SERIAL_8250_HUB6
+ case SERIAL_IO_HUB6:
+ outb(up->port.hub6 - 1 + offset, up->port.iobase);
+ outb(value, up->port.iobase + 1);
+ break;
+#endif
+
+ case SERIAL_IO_MEM:
+ writeb(value, up->port.membase + offset);
+ break;
+
+ default:
+ outb(value, up->port.iobase + offset);
+ }
+}
+
+/*
+ * We used to support using pause I/O for certain machines. We
+ * haven't supported this for a while, but just in case it's badly
+ * needed for certain old 386 machines, I've left these #define's
+ * in....
+ */
+#define serial_inp(up, offset) serial_in(up, offset)
+#define serial_outp(up, offset, value) serial_out(up, offset, value)
+
+
+/*
+ * For the 16C950
+ */
+static void serial_icr_write(struct uart_8250_port *up, int offset, int value)
+{
+ serial_out(up, UART_SCR, offset);
+ serial_out(up, UART_ICR, value);
+}
+
+static unsigned int serial_icr_read(struct uart_8250_port *up, int offset)
+{
+ unsigned int value;
+
+ serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD);
+ serial_out(up, UART_SCR, offset);
+ value = serial_in(up, UART_ICR);
+ serial_icr_write(up, UART_ACR, up->acr);
+
+ return value;
+}
+
+#ifdef CONFIG_SERIAL_8250_RSA
+/*
+ * Attempts to turn on the RSA FIFO. Returns zero on failure.
+ * We set the port uart clock rate if we succeed.
+ */
+static int __enable_rsa(struct uart_8250_port *up)
+{
+ unsigned char mode;
+ int result;
+
+ mode = serial_inp(up, UART_RSA_MSR);
+ result = mode & UART_RSA_MSR_FIFO;
+
+ if (!result) {
+ serial_outp(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO);
+ mode = serial_inp(up, UART_RSA_MSR);
+ result = mode & UART_RSA_MSR_FIFO;
+ }
+
+ if (result)
+ up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16;
+
+ return result;
+}
+
+static void enable_rsa(struct uart_8250_port *up)
+{
+ if (up->port.type == PORT_RSA) {
+ if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) {
+ spin_lock_irq(&up->port.lock);
+ __enable_rsa(up);
+ spin_unlock_irq(&up->port.lock);
+ }
+ if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16)
+ serial_outp(up, UART_RSA_FRR, 0);
+ }
+}
+
+/*
+ * Attempts to turn off the RSA FIFO. Returns zero on failure.
+ * It is unknown why interrupts were disabled in here. However,
+ * the caller is expected to preserve this behaviour by grabbing
+ * the spinlock before calling this function.
+ */
+static void disable_rsa(struct uart_8250_port *up)
+{
+ unsigned char mode;
+ int result;
+
+ if (up->port.type == PORT_RSA &&
+ up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) {
+ spin_lock_irq(&up->port.lock);
+
+ mode = serial_inp(up, UART_RSA_MSR);
+ result = !(mode & UART_RSA_MSR_FIFO);
+
+ if (!result) {
+ serial_outp(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO);
+ mode = serial_inp(up, UART_RSA_MSR);
+ result = !(mode & UART_RSA_MSR_FIFO);
+ }
+
+ if (result)
+ up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16;
+ spin_unlock_irq(&up->port.lock);
+ }
+}
+#endif /* CONFIG_SERIAL_8250_RSA */
+
+/*
+ * This is a quickie test to see how big the FIFO is.
+ * It doesn't work at all the time, more's the pity.
+ */
+static int size_fifo(struct uart_8250_port *up)
+{
+ unsigned char old_fcr, old_mcr, old_dll, old_dlm;
+ int count;
+
+ old_fcr = serial_inp(up, UART_FCR);
+ old_mcr = serial_inp(up, UART_MCR);
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO |
+ UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
+ serial_outp(up, UART_MCR, UART_MCR_LOOP);
+ serial_outp(up, UART_LCR, UART_LCR_DLAB);
+ old_dll = serial_inp(up, UART_DLL);
+ old_dlm = serial_inp(up, UART_DLM);
+ serial_outp(up, UART_DLL, 0x01);
+ serial_outp(up, UART_DLM, 0x00);
+ serial_outp(up, UART_LCR, 0x03);
+ for (count = 0; count < 256; count++)
+ serial_outp(up, UART_TX, count);
+ mdelay(20);/* FIXME - schedule_timeout */
+ for (count = 0; (serial_inp(up, UART_LSR) & UART_LSR_DR) &&
+ (count < 256); count++)
+ serial_inp(up, UART_RX);
+ serial_outp(up, UART_FCR, old_fcr);
+ serial_outp(up, UART_MCR, old_mcr);
+ serial_outp(up, UART_LCR, UART_LCR_DLAB);
+ serial_outp(up, UART_DLL, old_dll);
+ serial_outp(up, UART_DLM, old_dlm);
+
+ return count;
+}
+
+/*
+ * This is a helper routine to autodetect StarTech/Exar/Oxsemi UART's.
+ * When this function is called we know it is at least a StarTech
+ * 16650 V2, but it might be one of several StarTech UARTs, or one of
+ * its clones. (We treat the broken original StarTech 16650 V1 as a
+ * 16550, and why not? Startech doesn't seem to even acknowledge its
+ * existence.)
+ *
+ * What evil have men's minds wrought...
+ */
+static void autoconfig_has_efr(struct uart_8250_port *up)
+{
+ unsigned char id1, id2, id3, rev, saved_dll, saved_dlm;
+
+ /*
+ * First we check to see if it's an Oxford Semiconductor UART.
+ *
+ * If we have to do this here because some non-National
+ * Semiconductor clone chips lock up if you try writing to the
+ * LSR register (which serial_icr_read does)
+ */
+
+ /*
+ * Check for Oxford Semiconductor 16C950.
+ *
+ * EFR [4] must be set else this test fails.
+ *
+ * This shouldn't be necessary, but Mike Hudson (Exoray@isys.ca)
+ * claims that it's needed for 952 dual UART's (which are not
+ * recommended for new designs).
+ */
+ up->acr = 0;
+ serial_out(up, UART_LCR, 0xBF);
+ serial_out(up, UART_EFR, 0x10);
+ serial_out(up, UART_LCR, 0x00);
+ id1 = serial_icr_read(up, UART_ID1);
+ id2 = serial_icr_read(up, UART_ID2);
+ id3 = serial_icr_read(up, UART_ID3);
+ rev = serial_icr_read(up, UART_REV);
+
+ DEBUG_AUTOCONF("950id=%02x:%02x:%02x:%02x ", id1, id2, id3, rev);
+
+ if (id1 == 0x16 && id2 == 0xC9 &&
+ (id3 == 0x50 || id3 == 0x52 || id3 == 0x54)) {
+ up->port.type = PORT_16C950;
+ up->rev = rev | (id3 << 8);
+ return;
+ }
+
+ /*
+ * We check for a XR16C850 by setting DLL and DLM to 0, and then
+ * reading back DLL and DLM. The chip type depends on the DLM
+ * value read back:
+ * 0x10 - XR16C850 and the DLL contains the chip revision.
+ * 0x12 - XR16C2850.
+ * 0x14 - XR16C854.
+ */
+ serial_outp(up, UART_LCR, UART_LCR_DLAB);
+ saved_dll = serial_inp(up, UART_DLL);
+ saved_dlm = serial_inp(up, UART_DLM);
+ serial_outp(up, UART_DLL, 0);
+ serial_outp(up, UART_DLM, 0);
+ id2 = serial_inp(up, UART_DLL);
+ id1 = serial_inp(up, UART_DLM);
+ serial_outp(up, UART_DLL, saved_dll);
+ serial_outp(up, UART_DLM, saved_dlm);
+
+ DEBUG_AUTOCONF("850id=%02x:%02x ", id1, id2);
+
+ if (id1 == 0x10 || id1 == 0x12 || id1 == 0x14) {
+ if (id1 == 0x10)
+ up->rev = id2;
+ up->port.type = PORT_16850;
+ return;
+ }
+
+ /*
+ * It wasn't an XR16C850.
+ *
+ * We distinguish between the '654 and the '650 by counting
+ * how many bytes are in the FIFO. I'm using this for now,
+ * since that's the technique that was sent to me in the
+ * serial driver update, but I'm not convinced this works.
+ * I've had problems doing this in the past. -TYT
+ */
+ if (size_fifo(up) == 64)
+ up->port.type = PORT_16654;
+ else
+ up->port.type = PORT_16650V2;
+}
+
+/*
+ * We detected a chip without a FIFO. Only two fall into
+ * this category - the original 8250 and the 16450. The
+ * 16450 has a scratch register (accessible with LCR=0)
+ */
+static void autoconfig_8250(struct uart_8250_port *up)
+{
+ unsigned char scratch, status1, status2;
+
+ up->port.type = PORT_8250;
+
+ scratch = serial_in(up, UART_SCR);
+ serial_outp(up, UART_SCR, 0xa5);
+ status1 = serial_in(up, UART_SCR);
+ serial_outp(up, UART_SCR, 0x5a);
+ status2 = serial_in(up, UART_SCR);
+ serial_outp(up, UART_SCR, scratch);
+
+ if (status1 == 0xa5 && status2 == 0x5a)
+ up->port.type = PORT_16450;
+}
+
+/*
+ * We know that the chip has FIFOs. Does it have an EFR? The
+ * EFR is located in the same register position as the IIR and
+ * we know the top two bits of the IIR are currently set. The
+ * EFR should contain zero. Try to read the EFR.
+ */
+static void autoconfig_16550a(struct uart_8250_port *up)
+{
+ unsigned char status1, status2;
+
+ up->port.type = PORT_16550A;
+
+ /*
+ * Check for presence of the EFR when DLAB is set.
+ * Only ST16C650V1 UARTs pass this test.
+ */
+ serial_outp(up, UART_LCR, UART_LCR_DLAB);
+ if (serial_in(up, UART_EFR) == 0) {
+ DEBUG_AUTOCONF("EFRv1 ");
+ up->port.type = PORT_16650;
+ return;
+ }
+
+ /*
+ * Maybe it requires 0xbf to be written to the LCR.
+ * (other ST16C650V2 UARTs, TI16C752A, etc)
+ */
+ serial_outp(up, UART_LCR, 0xBF);
+ if (serial_in(up, UART_EFR) == 0) {
+ DEBUG_AUTOCONF("EFRv2 ");
+ autoconfig_has_efr(up);
+ return;
+ }
+
+ /*
+ * Check for a National Semiconductor SuperIO chip.
+ * Attempt to switch to bank 2, read the value of the LOOP bit
+ * from EXCR1. Switch back to bank 0, change it in MCR. Then
+ * switch back to bank 2, read it from EXCR1 again and check
+ * it's changed. If so, set baud_base in EXCR2 to 921600.
+ */
+ serial_outp(up, UART_LCR, 0);
+ status1 = serial_in(up, UART_MCR);
+ serial_outp(up, UART_LCR, 0xE0);
+ status2 = serial_in(up, 0x02); /* EXCR1 */
+
+ if (!((status2 ^ status1) & UART_MCR_LOOP)) {
+ serial_outp(up, UART_LCR, 0);
+ serial_outp(up, UART_MCR, status1 ^ UART_MCR_LOOP);
+ serial_outp(up, UART_LCR, 0xE0);
+ status2 = serial_in(up, 0x02); /* EXCR1 */
+ serial_outp(up, UART_LCR, 0);
+ serial_outp(up, UART_MCR, status1);
+
+ if ((status2 ^ status1) & UART_MCR_LOOP) {
+ serial_outp(up, UART_LCR, 0xE0);
+ status1 = serial_in(up, 0x04); /* EXCR1 */
+ status1 &= ~0xB0; /* Disable LOCK, mask out PRESL[01] */
+ status1 |= 0x10; /* 1.625 divisor for baud_base --> 921600 */
+ serial_outp(up, 0x04, status1);
+ serial_outp(up, UART_LCR, 0);
+
+ up->port.type = PORT_NS16550A;
+ up->port.uartclk = 921600*16;
+ return;
+ }
+ }
+
+ /*
+ * No EFR. Try to detect a TI16750, which only sets bit 5 of
+ * the IIR when 64 byte FIFO mode is enabled when DLAB is set.
+ * Try setting it with and without DLAB set. Cheap clones
+ * set bit 5 without DLAB set.
+ */
+ serial_outp(up, UART_LCR, 0);
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
+ status1 = serial_in(up, UART_IIR) >> 5;
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
+ serial_outp(up, UART_LCR, UART_LCR_DLAB);
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
+ status2 = serial_in(up, UART_IIR) >> 5;
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
+
+ DEBUG_AUTOCONF("iir1=%d iir2=%d ", status1, status2);
+
+ if (status1 == 6 && status2 == 7) {
+ up->port.type = PORT_16750;
+ return;
+ }
+}
+
+/*
+ * This routine is called by rs_init() to initialize a specific serial
+ * port. It determines what type of UART chip this serial port is
+ * using: 8250, 16450, 16550, 16550A. The important question is
+ * whether or not this UART is a 16550A or not, since this will
+ * determine whether or not we can use its FIFO features or not.
+ */
+static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
+{
+ unsigned char status1, scratch, scratch2, scratch3;
+ unsigned char save_lcr, save_mcr;
+ unsigned long flags;
+
+ if (!up->port.iobase && !up->port.mapbase && !up->port.membase)
+ return;
+
+ DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04x, 0x%p): ",
+ up->port.line, up->port.iobase, up->port.membase);
+
+ /*
+ * We really do need global IRQs disabled here - we're going to
+ * be frobbing the chips IRQ enable register to see if it exists.
+ */
+ spin_lock_irqsave(&up->port.lock, flags);
+
+ if (!(up->port.flags & UPF_BUGGY_UART)) {
+ /*
+ * Do a simple existence test first; if we fail this,
+ * there's no point trying anything else.
+ *
+ * 0x80 is used as a nonsense port to prevent against
+ * false positives due to ISA bus float. The
+ * assumption is that 0x80 is a non-existent port;
+ * which should be safe since include/asm/io.h also
+ * makes this assumption.
+ *
+ * Note: this is safe as long as MCR bit 4 is clear
+ * and the device is in "PC" mode.
+ */
+ scratch = serial_inp(up, UART_IER);
+ serial_outp(up, UART_IER, 0);
+#ifdef __i386__
+ outb(0xff, 0x080);
+#endif
+ scratch2 = serial_inp(up, UART_IER);
+ serial_outp(up, UART_IER, 0x0F);
+#ifdef __i386__
+ outb(0, 0x080);
+#endif
+ scratch3 = serial_inp(up, UART_IER);
+ serial_outp(up, UART_IER, scratch);
+ if (scratch2 != 0 || scratch3 != 0x0F) {
+ /*
+ * We failed; there's nothing here
+ */
+ DEBUG_AUTOCONF("IER test failed (%02x, %02x) ",
+ scratch2, scratch3);
+ goto out;
+ }
+ }
+
+ save_mcr = serial_in(up, UART_MCR);
+ save_lcr = serial_in(up, UART_LCR);
+
+ /*
+ * Check to see if a UART is really there. Certain broken
+ * internal modems based on the Rockwell chipset fail this
+ * test, because they apparently don't implement the loopback
+ * test mode. So this test is skipped on the COM 1 through
+ * COM 4 ports. This *should* be safe, since no board
+ * manufacturer would be stupid enough to design a board
+ * that conflicts with COM 1-4 --- we hope!
+ */
+ if (!(up->port.flags & UPF_SKIP_TEST)) {
+ serial_outp(up, UART_MCR, UART_MCR_LOOP | 0x0A);
+ status1 = serial_inp(up, UART_MSR) & 0xF0;
+ serial_outp(up, UART_MCR, save_mcr);
+ if (status1 != 0x90) {
+ DEBUG_AUTOCONF("LOOP test failed (%02x) ",
+ status1);
+ goto out;
+ }
+ }
+
+ /*
+ * We're pretty sure there's a port here. Lets find out what
+ * type of port it is. The IIR top two bits allows us to find
+ * out if its 8250 or 16450, 16550, 16550A or later. This
+ * determines what we test for next.
+ *
+ * We also initialise the EFR (if any) to zero for later. The
+ * EFR occupies the same register location as the FCR and IIR.
+ */
+ serial_outp(up, UART_LCR, 0xBF);
+ serial_outp(up, UART_EFR, 0);
+ serial_outp(up, UART_LCR, 0);
+
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
+ scratch = serial_in(up, UART_IIR) >> 6;
+
+ DEBUG_AUTOCONF("iir=%d ", scratch);
+
+ switch (scratch) {
+ case 0:
+ autoconfig_8250(up);
+ break;
+ case 1:
+ up->port.type = PORT_UNKNOWN;
+ break;
+ case 2:
+ up->port.type = PORT_16550;
+ break;
+ case 3:
+ autoconfig_16550a(up);
+ break;
+ }
+
+#if defined(CONFIG_SERIAL_8250_RSA) && defined(MODULE)
+ /*
+ * Only probe for RSA ports if we got the region.
+ */
+ if (up->port.type == PORT_16550A && probeflags & PROBE_RSA) {
+ int i;
+
+ for (i = 0 ; i < PORT_RSA_MAX ; ++i) {
+ if (!probe_rsa[i] && !force_rsa[i])
+ break;
+ if (((probe_rsa[i] != up->port.iobase) ||
+ check_region(up->port.iobase + UART_RSA_BASE, 16)) &&
+ (force_rsa[i] != up->port.iobase))
+ continue;
+ if (__enable_rsa(up)) {
+ up->port.type = PORT_RSA;
+ break;
+ }
+ }
+ }
+#endif
+ serial_outp(up, UART_LCR, save_lcr);
+
+ up->port.fifosize = uart_config[up->port.type].dfl_xmit_fifo_size;
+ up->capabilities = uart_config[up->port.type].flags;
+
+ if (up->port.type == PORT_UNKNOWN)
+ goto out;
+
+ /*
+ * Reset the UART.
+ */
+#ifdef CONFIG_SERIAL_8250_RSA
+ if (up->port.type == PORT_RSA)
+ serial_outp(up, UART_RSA_FRR, 0);
+#endif
+ serial_outp(up, UART_MCR, save_mcr);
+ serial_outp(up, UART_FCR, (UART_FCR_ENABLE_FIFO |
+ UART_FCR_CLEAR_RCVR |
+ UART_FCR_CLEAR_XMIT));
+ serial_outp(up, UART_FCR, 0);
+ (void)serial_in(up, UART_RX);
+ serial_outp(up, UART_IER, 0);
+
+ out:
+ spin_unlock_irqrestore(&up->port.lock, flags);
+
+#ifdef CONFIG_SERIAL_8250_RSA
+ if (up->port.iobase && up->port.type == PORT_RSA) {
+ release_region(up->port.iobase, 8);
+ request_region(up->port.iobase + UART_RSA_BASE, 16,
+ "serial_rsa");
+ }
+#endif
+ DEBUG_AUTOCONF("type=%s\n", uart_config[up->port.type].name);
+}
+
+static void autoconfig_irq(struct uart_8250_port *up)
+{
+ unsigned char save_mcr, save_ier;
+ unsigned char save_ICP = 0;
+ unsigned int ICP = 0;
+ unsigned long irqs;
+ int irq;
+
+ if (up->port.flags & UPF_FOURPORT) {
+ ICP = (up->port.iobase & 0xfe0) | 0x1f;
+ save_ICP = inb_p(ICP);
+ outb_p(0x80, ICP);
+ (void) inb_p(ICP);
+ }
+
+ /* forget possible initially masked and pending IRQ */
+ probe_irq_off(probe_irq_on());
+ save_mcr = serial_inp(up, UART_MCR);
+ save_ier = serial_inp(up, UART_IER);
+ serial_outp(up, UART_MCR, UART_MCR_OUT1 | UART_MCR_OUT2);
+
+ irqs = probe_irq_on();
+ serial_outp(up, UART_MCR, 0);
+ udelay (10);
+ if (up->port.flags & UPF_FOURPORT) {
+ serial_outp(up, UART_MCR,
+ UART_MCR_DTR | UART_MCR_RTS);
+ } else {
+ serial_outp(up, UART_MCR,
+ UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2);
+ }
+ serial_outp(up, UART_IER, 0x0f); /* enable all intrs */
+ (void)serial_inp(up, UART_LSR);
+ (void)serial_inp(up, UART_RX);
+ (void)serial_inp(up, UART_IIR);
+ (void)serial_inp(up, UART_MSR);
+ serial_outp(up, UART_TX, 0xFF);
+ udelay (20);
+ irq = probe_irq_off(irqs);
+
+ serial_outp(up, UART_MCR, save_mcr);
+ serial_outp(up, UART_IER, save_ier);
+
+ if (up->port.flags & UPF_FOURPORT)
+ outb_p(save_ICP, ICP);
+
+ up->port.irq = (irq > 0) ? irq : 0;
+}
+
+static void serial8250_stop_tx(struct uart_port *port, unsigned int tty_stop)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+
+ if (up->ier & UART_IER_THRI) {
+ up->ier &= ~UART_IER_THRI;
+ serial_out(up, UART_IER, up->ier);
+ }
+ if (up->port.type == PORT_16C950 && tty_stop) {
+ up->acr |= UART_ACR_TXDIS;
+ serial_icr_write(up, UART_ACR, up->acr);
+ }
+}
+
+static void serial8250_start_tx(struct uart_port *port, unsigned int tty_start)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+
+ if (!(up->ier & UART_IER_THRI)) {
+ up->ier |= UART_IER_THRI;
+ serial_out(up, UART_IER, up->ier);
+ }
+ /*
+ * We only do this from uart_start
+ */
+ if (tty_start && up->port.type == PORT_16C950) {
+ up->acr &= ~UART_ACR_TXDIS;
+ serial_icr_write(up, UART_ACR, up->acr);
+ }
+}
+
+static void serial8250_stop_rx(struct uart_port *port)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+
+ up->ier &= ~UART_IER_RLSI;
+ up->port.read_status_mask &= ~UART_LSR_DR;
+ serial_out(up, UART_IER, up->ier);
+}
+
+static void serial8250_enable_ms(struct uart_port *port)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+
+ up->ier |= UART_IER_MSI;
+ serial_out(up, UART_IER, up->ier);
+}
+
+static _INLINE_ void
+receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs)
+{
+ struct tty_struct *tty = up->port.info->tty;
+ unsigned char ch;
+ int max_count = 256;
+
+ do {
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+ /*
+ * FIXME: Deadlock can happen here if we're a
+ * low-latency port. We're holding the per-port
+ * spinlock, and we call flush_to_ldisc->
+ * n_tty_receive_buf->n_tty_receive_char->
+ * opost->uart_put_char.
+ */
+ tty->flip.tqueue.routine((void *)tty);
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+ return; // if TTY_DONT_FLIP is set
+ }
+ ch = serial_inp(up, UART_RX);
+ *tty->flip.char_buf_ptr = ch;
+ *tty->flip.flag_buf_ptr = TTY_NORMAL;
+ up->port.icount.rx++;
+
+ if (*status & (UART_LSR_BI | UART_LSR_PE |
+ UART_LSR_FE | UART_LSR_OE)) {
+ /*
+ * For statistics only
+ */
+ if (*status & UART_LSR_BI) {
+ *status &= ~(UART_LSR_FE | UART_LSR_PE);
+ up->port.icount.brk++;
+ /*
+ * We do the SysRQ and SAK checking
+ * here because otherwise the break
+ * may get masked by ignore_status_mask
+ * or read_status_mask.
+ */
+ if (uart_handle_break(&up->port))
+ goto ignore_char;
+ } else if (*status & UART_LSR_PE)
+ up->port.icount.parity++;
+ else if (*status & UART_LSR_FE)
+ up->port.icount.frame++;
+ if (*status & UART_LSR_OE)
+ up->port.icount.overrun++;
+
+ /*
+ * Mask off conditions which should be ingored.
+ */
+ *status &= up->port.read_status_mask;
+
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+ if (up->port.line == up->port.cons->index) {
+ /* Recover the break flag from console xmit */
+ *status |= up->lsr_break_flag;
+ up->lsr_break_flag = 0;
+ }
+#endif
+ if (*status & UART_LSR_BI) {
+ DEBUG_INTR("handling break....");
+ *tty->flip.flag_buf_ptr = TTY_BREAK;
+ } else if (*status & UART_LSR_PE)
+ *tty->flip.flag_buf_ptr = TTY_PARITY;
+ else if (*status & UART_LSR_FE)
+ *tty->flip.flag_buf_ptr = TTY_FRAME;
+ }
+ if (uart_handle_sysrq_char(&up->port, ch, regs))
+ goto ignore_char;
+ if ((*status & up->port.ignore_status_mask) == 0) {
+ tty->flip.flag_buf_ptr++;
+ tty->flip.char_buf_ptr++;
+ tty->flip.count++;
+ }
+ if ((*status & UART_LSR_OE) &&
+ tty->flip.count < TTY_FLIPBUF_SIZE) {
+ /*
+ * Overrun is special, since it's reported
+ * immediately, and doesn't affect the current
+ * character.
+ */
+ *tty->flip.flag_buf_ptr = TTY_OVERRUN;
+ tty->flip.flag_buf_ptr++;
+ tty->flip.char_buf_ptr++;
+ tty->flip.count++;
+ }
+ ignore_char:
+ *status = serial_inp(up, UART_LSR);
+ } while ((*status & UART_LSR_DR) && (max_count-- > 0));
+ tty_flip_buffer_push(tty);
+}
+
+static _INLINE_ void transmit_chars(struct uart_8250_port *up)
+{
+ struct circ_buf *xmit = &up->port.info->xmit;
+ int count;
+
+ if (up->port.x_char) {
+ serial_outp(up, UART_TX, up->port.x_char);
+ up->port.icount.tx++;
+ up->port.x_char = 0;
+ return;
+ }
+ if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
+ serial8250_stop_tx(&up->port, 0);
+ return;
+ }
+
+ count = up->port.fifosize;
+ do {
+ serial_out(up, UART_TX, xmit->buf[xmit->tail]);
+ xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+ up->port.icount.tx++;
+ if (uart_circ_empty(xmit))
+ break;
+ } while (--count > 0);
+
+ if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+ uart_write_wakeup(&up->port);
+
+ DEBUG_INTR("THRE...");
+
+ if (uart_circ_empty(xmit))
+ serial8250_stop_tx(&up->port, 0);
+}
+
+static _INLINE_ void check_modem_status(struct uart_8250_port *up)
+{
+ int status;
+
+ status = serial_in(up, UART_MSR);
+
+ if ((status & UART_MSR_ANY_DELTA) == 0)
+ return;
+
+ if (status & UART_MSR_TERI)
+ up->port.icount.rng++;
+ if (status & UART_MSR_DDSR)
+ up->port.icount.dsr++;
+ if (status & UART_MSR_DDCD)
+ uart_handle_dcd_change(&up->port, status & UART_MSR_DCD);
+ if (status & UART_MSR_DCTS)
+ uart_handle_cts_change(&up->port, status & UART_MSR_CTS);
+
+ wake_up_interruptible(&up->port.info->delta_msr_wait);
+}
+
+/*
+ * This handles the interrupt from one port.
+ */
+static inline void
+serial8250_handle_port(struct uart_8250_port *up, struct pt_regs *regs)
+{
+ unsigned int status = serial_inp(up, UART_LSR);
+
+ DEBUG_INTR("status = %x...", status);
+
+ if (status & UART_LSR_DR)
+ receive_chars(up, &status, regs);
+ check_modem_status(up);
+ if (status & UART_LSR_THRE)
+ transmit_chars(up);
+}
+
+/*
+ * This is the serial driver's interrupt routine.
+ *
+ * Arjan thinks the old way was overly complex, so it got simplified.
+ * Alan disagrees, saying that need the complexity to handle the weird
+ * nature of ISA shared interrupts. (This is a special exception.)
+ *
+ * In order to handle ISA shared interrupts properly, we need to check
+ * that all ports have been serviced, and therefore the ISA interrupt
+ * line has been de-asserted.
+ *
+ * This means we need to loop through all ports. checking that they
+ * don't have an interrupt pending.
+ */
+static void serial8250_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct irq_info *i = dev_id;
+ struct list_head *l, *end = NULL;
+ int pass_counter = 0;
+
+ DEBUG_INTR("serial8250_interrupt(%d)...", irq);
+
+ spin_lock(&i->lock);
+
+ l = i->head;
+ do {
+ struct uart_8250_port *up;
+ unsigned int iir;
+
+ up = list_entry(l, struct uart_8250_port, list);
+
+ iir = serial_in(up, UART_IIR);
+ if (!(iir & UART_IIR_NO_INT)) {
+ spin_lock(&up->port.lock);
+ serial8250_handle_port(up, regs);
+ spin_unlock(&up->port.lock);
+
+ end = NULL;
+ } else if (end == NULL)
+ end = l;
+
+ l = l->next;
+
+ if (l == i->head && pass_counter++ > PASS_LIMIT) {
+ /* If we hit this, we're dead. */
+ printk(KERN_ERR "serial8250: too much work for "
+ "irq%d\n", irq);
+ break;
+ }
+ } while (l != end);
+
+ spin_unlock(&i->lock);
+
+ DEBUG_INTR("end.\n");
+}
+
+/*
+ * To support ISA shared interrupts, we need to have one interrupt
+ * handler that ensures that the IRQ line has been deasserted
+ * before returning. Failing to do this will result in the IRQ
+ * line being stuck active, and, since ISA irqs are edge triggered,
+ * no more IRQs will be seen.
+ */
+static void serial_do_unlink(struct irq_info *i, struct uart_8250_port *up)
+{
+ spin_lock_irq(&i->lock);
+
+ if (!list_empty(i->head)) {
+ if (i->head == &up->list)
+ i->head = i->head->next;
+ list_del(&up->list);
+ } else {
+ BUG_ON(i->head != &up->list);
+ i->head = NULL;
+ }
+
+ spin_unlock_irq(&i->lock);
+}
+
+static int serial_link_irq_chain(struct uart_8250_port *up)
+{
+ struct irq_info *i = irq_lists + up->port.irq;
+ int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? SA_SHIRQ : 0;
+
+ spin_lock_irq(&i->lock);
+
+ if (i->head) {
+ list_add(&up->list, i->head);
+ spin_unlock_irq(&i->lock);
+
+ ret = 0;
+ } else {
+ INIT_LIST_HEAD(&up->list);
+ i->head = &up->list;
+ spin_unlock_irq(&i->lock);
+
+ ret = request_irq(up->port.irq, serial8250_interrupt,
+ irq_flags, "serial", i);
+ if (ret < 0)
+ serial_do_unlink(i, up);
+ }
+
+ return ret;
+}
+
+static void serial_unlink_irq_chain(struct uart_8250_port *up)
+{
+ struct irq_info *i = irq_lists + up->port.irq;
+
+ BUG_ON(i->head == NULL);
+
+ if (list_empty(i->head))
+ free_irq(up->port.irq, i);
+
+ serial_do_unlink(i, up);
+}
+
+/*
+ * This function is used to handle ports that do not have an
+ * interrupt. This doesn't work very well for 16450's, but gives
+ * barely passable results for a 16550A. (Although at the expense
+ * of much CPU overhead).
+ */
+static void serial8250_timeout(unsigned long data)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)data;
+ unsigned int timeout;
+ unsigned int iir;
+
+ iir = serial_in(up, UART_IIR);
+ if (!(iir & UART_IIR_NO_INT)) {
+ spin_lock(&up->port.lock);
+ serial8250_handle_port(up, NULL);
+ spin_unlock(&up->port.lock);
+ }
+
+ timeout = up->port.timeout;
+ timeout = timeout > 6 ? (timeout / 2 - 2) : 1;
+ mod_timer(&up->timer, jiffies + timeout);
+}
+
+static unsigned int serial8250_tx_empty(struct uart_port *port)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ unsigned long flags;
+ unsigned int ret;
+
+ spin_lock_irqsave(&up->port.lock, flags);
+ ret = serial_in(up, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0;
+ spin_unlock_irqrestore(&up->port.lock, flags);
+
+ return ret;
+}
+
+static unsigned int serial8250_get_mctrl(struct uart_port *port)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ unsigned long flags;
+ unsigned char status;
+ unsigned int ret;
+
+ spin_lock_irqsave(&up->port.lock, flags);
+ status = serial_in(up, UART_MSR);
+ spin_unlock_irqrestore(&up->port.lock, flags);
+
+ ret = 0;
+ if (status & UART_MSR_DCD)
+ ret |= TIOCM_CAR;
+ if (status & UART_MSR_RI)
+ ret |= TIOCM_RNG;
+ if (status & UART_MSR_DSR)
+ ret |= TIOCM_DSR;
+ if (status & UART_MSR_CTS)
+ ret |= TIOCM_CTS;
+ return ret;
+}
+
+static void serial8250_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ unsigned char mcr = 0;
+
+ if (mctrl & TIOCM_RTS)
+ mcr |= UART_MCR_RTS;
+ if (mctrl & TIOCM_DTR)
+ mcr |= UART_MCR_DTR;
+ if (mctrl & TIOCM_OUT1)
+ mcr |= UART_MCR_OUT1;
+ if (mctrl & TIOCM_OUT2)
+ mcr |= UART_MCR_OUT2;
+ if (mctrl & TIOCM_LOOP)
+ mcr |= UART_MCR_LOOP;
+
+ mcr = (mcr & up->mcr_mask) | up->mcr_force | up->mcr;
+
+ serial_out(up, UART_MCR, mcr);
+}
+
+static void serial8250_break_ctl(struct uart_port *port, int break_state)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ unsigned long flags;
+
+ spin_lock_irqsave(&up->port.lock, flags);
+ if (break_state == -1)
+ up->lcr |= UART_LCR_SBC;
+ else
+ up->lcr &= ~UART_LCR_SBC;
+ serial_out(up, UART_LCR, up->lcr);
+ spin_unlock_irqrestore(&up->port.lock, flags);
+}
+
+static int serial8250_startup(struct uart_port *port)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ unsigned long flags;
+ unsigned char lsr, iir;
+ int retval;
+
+ up->capabilities = uart_config[up->port.type].flags;
+ up->mcr = 0;
+ up->efr = 0;
+ up->ier = 0;
+
+ if (up->port.type == PORT_16C950) {
+ /* Wake up and initialize UART */
+ up->acr = 0;
+ serial_outp(up, UART_LCR, 0xBF);
+ serial_outp(up, UART_EFR, UART_EFR_ECB);
+ serial_outp(up, UART_IER, 0);
+ serial_outp(up, UART_LCR, 0);
+ serial_icr_write(up, UART_CSR, 0); /* Reset the UART */
+ serial_outp(up, UART_LCR, 0xBF);
+ serial_outp(up, UART_EFR, UART_EFR_ECB);
+ serial_outp(up, UART_LCR, 0);
+ }
+
+#ifdef CONFIG_SERIAL_8250_RSA
+ /*
+ * If this is an RSA port, see if we can kick it up to the
+ * higher speed clock.
+ */
+ enable_rsa(up);
+#endif
+
+ /*
+ * Clear the FIFO buffers and disable them.
+ * (they will be reeanbled in change_speed())
+ */
+ if (up->capabilities & UART_CLEAR_FIFO) {
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO |
+ UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
+ serial_outp(up, UART_FCR, 0);
+ }
+
+ /*
+ * Clear the interrupt registers.
+ */
+ (void) serial_inp(up, UART_LSR);
+ (void) serial_inp(up, UART_RX);
+ (void) serial_inp(up, UART_IIR);
+ (void) serial_inp(up, UART_MSR);
+
+ /*
+ * At this point, there's no way the LSR could still be 0xff;
+ * if it is, then bail out, because there's likely no UART
+ * here.
+ */
+ if (!(up->port.flags & UPF_BUGGY_UART) &&
+ (serial_inp(up, UART_LSR) == 0xff)) {
+ printk("ttyS%d: LSR safety check engaged!\n", up->port.line);
+ return -ENODEV;
+ }
+
+ /*
+ * If the "interrupt" for this port doesn't correspond with any
+ * hardware interrupt, we use a timer-based system. The original
+ * driver used to do this with IRQ0.
+ */
+ if (!is_real_interrupt(up->port.irq)) {
+ unsigned int timeout = up->port.timeout;
+
+ timeout = timeout > 6 ? (timeout / 2 - 2) : 1;
+
+ up->timer.data = (unsigned long)up;
+ mod_timer(&up->timer, jiffies + timeout);
+ } else {
+ retval = serial_link_irq_chain(up);
+ if (retval)
+ return retval;
+ }
+
+ /*
+ * Now, initialize the UART
+ */
+ serial_outp(up, UART_LCR, UART_LCR_WLEN8);
+
+ spin_lock_irqsave(&up->port.lock, flags);
+ if (up->port.flags & UPF_FOURPORT) {
+ if (!is_real_interrupt(up->port.irq))
+ up->port.mctrl |= TIOCM_OUT1;
+ } else
+ /*
+ * Most PC uarts need OUT2 raised to enable interrupts.
+ */
+ if (is_real_interrupt(up->port.irq))
+ up->port.mctrl |= TIOCM_OUT2;
+
+ serial8250_set_mctrl(&up->port, up->port.mctrl);
+
+ /*
+ * Do a quick test to see if we receive an
+ * interrupt when we enable the TX irq.
+ */
+ serial_outp(up, UART_IER, UART_IER_THRI);
+ lsr = serial_in(up, UART_LSR);
+ iir = serial_in(up, UART_IIR);
+ serial_outp(up, UART_IER, 0);
+
+ if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT) {
+ up->capabilities |= UART_BAD_TX_ENABLE;
+ printk("ttyS%d - enabling bad tx status workarounds\n",
+ port->line);
+ }
+
+ spin_unlock_irqrestore(&up->port.lock, flags);
+
+ /*
+ * Finally, enable interrupts. Note: Modem status interrupts
+ * are set via change_speed(), which will be occuring imminently
+ * anyway, so we don't enable them here.
+ */
+ up->ier = UART_IER_RLSI | UART_IER_RDI;
+ serial_outp(up, UART_IER, up->ier);
+
+ if (up->port.flags & UPF_FOURPORT) {
+ unsigned int icp;
+ /*
+ * Enable interrupts on the AST Fourport board
+ */
+ icp = (up->port.iobase & 0xfe0) | 0x01f;
+ outb_p(0x80, icp);
+ (void) inb_p(icp);
+ }
+
+ /*
+ * And clear the interrupt registers again for luck.
+ */
+ (void) serial_inp(up, UART_LSR);
+ (void) serial_inp(up, UART_RX);
+ (void) serial_inp(up, UART_IIR);
+ (void) serial_inp(up, UART_MSR);
+
+ return 0;
+}
+
+static void serial8250_shutdown(struct uart_port *port)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ unsigned long flags;
+
+ /*
+ * Disable interrupts from this port
+ */
+ up->ier = 0;
+ serial_outp(up, UART_IER, 0);
+
+ spin_lock_irqsave(&up->port.lock, flags);
+ if (up->port.flags & UPF_FOURPORT) {
+ /* reset interrupts on the AST Fourport board */
+ inb((up->port.iobase & 0xfe0) | 0x1f);
+ up->port.mctrl |= TIOCM_OUT1;
+ } else
+ up->port.mctrl &= ~TIOCM_OUT2;
+
+ serial8250_set_mctrl(&up->port, up->port.mctrl);
+ spin_unlock_irqrestore(&up->port.lock, flags);
+
+ /*
+ * Disable break condition and FIFOs
+ */
+ serial_out(up, UART_LCR, serial_inp(up, UART_LCR) & ~UART_LCR_SBC);
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO |
+ UART_FCR_CLEAR_RCVR |
+ UART_FCR_CLEAR_XMIT);
+ serial_outp(up, UART_FCR, 0);
+
+#ifdef CONFIG_SERIAL_8250_RSA
+ /*
+ * Reset the RSA board back to 115kbps compat mode.
+ */
+ disable_rsa(up);
+#endif
+
+ /*
+ * Read data port to reset things, and then unlink from
+ * the IRQ chain.
+ */
+ (void) serial_in(up, UART_RX);
+
+ if (!is_real_interrupt(up->port.irq))
+ del_timer_sync(&up->timer);
+ else
+ serial_unlink_irq_chain(up);
+}
+
+static void serial8250_change_speed(struct uart_port *port, unsigned int cflag, unsigned int iflag, unsigned int quot)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ unsigned char cval, fcr = 0;
+ unsigned long flags;
+
+ switch (cflag & CSIZE) {
+ case CS5:
+ cval = 0x00;
+ break;
+ case CS6:
+ cval = 0x01;
+ break;
+ case CS7:
+ cval = 0x02;
+ break;
+ default:
+ case CS8:
+ cval = 0x03;
+ break;
+ }
+
+ if (cflag & CSTOPB)
+ cval |= 0x04;
+ if (cflag & PARENB)
+ cval |= UART_LCR_PARITY;
+ if (!(cflag & PARODD))
+ cval |= UART_LCR_EPAR;
+#ifdef CMSPAR
+ if (cflag & CMSPAR)
+ cval |= UART_LCR_SPAR;
+#endif
+
+ /*
+ * Work around a bug in the Oxford Semiconductor 952 rev B
+ * chip which causes it to seriously miscalculate baud rates
+ * when DLL is 0.
+ */
+ if ((quot & 0xff) == 0 && up->port.type == PORT_16C950 &&
+ up->rev == 0x5201)
+ quot ++;
+
+ if (up->capabilities & UART_USE_FIFO) {
+ if ((up->port.uartclk / quot) < (2400 * 16))
+ fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
+#ifdef CONFIG_SERIAL_8250_RSA
+ else if (up->port.type == PORT_RSA)
+ fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_14;
+#endif
+ else
+ fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8;
+ }
+ if (up->port.type == PORT_16750)
+ fcr |= UART_FCR7_64BYTE;
+
+ /*
+ * Ok, we're now changing the port state. Do it with
+ * interrupts disabled.
+ */
+ spin_lock_irqsave(&up->port.lock, flags);
+
+ up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
+ if (iflag & IGNPAR)
+ up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
+ if (iflag & (BRKINT | PARMRK))
+ up->port.read_status_mask |= UART_LSR_BI;
+
+ /*
+ * Characteres to ignore
+ */
+ up->port.ignore_status_mask = 0;
+ if (iflag & IGNPAR)
+ up->port.ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
+ if (iflag & IGNBRK) {
+ up->port.ignore_status_mask |= UART_LSR_BI;
+ /*
+ * If we're ignoring parity and break indicators,
+ * ignore overruns too (for real raw support).
+ */
+ if (iflag & IGNPAR)
+ up->port.ignore_status_mask |= UART_LSR_OE;
+ }
+
+ /*
+ * ignore all characters if CREAD is not set
+ */
+ if ((cflag & CREAD) == 0)
+ up->port.ignore_status_mask |= UART_LSR_DR;
+
+ /*
+ * CTS flow control flag and modem status interrupts
+ */
+ up->ier &= ~UART_IER_MSI;
+ if (UART_ENABLE_MS(&up->port, cflag))
+ up->ier |= UART_IER_MSI;
+
+ serial_out(up, UART_IER, up->ier);
+
+ if (up->capabilities & UART_MCRAFE) {
+ /*
+ * TI16C750 hardware flow control
+ */
+ up->mcr &= ~UART_MCR_AFE;
+ if (cflag & CRTSCTS)
+ up->mcr |= UART_MCR_AFE;
+ }
+ if (up->capabilities & UART_EFRAFE) {
+ /*
+ * TI16C752/Startech hardware flow control
+ * FIXME:
+ * - TI16C752 requires control thresholds
+ * to be set for auto-RTS.
+ * - We only enable auto-CTS here.
+ * Note: ST16C654 does not allow MCR bit 1
+ * to override RTS when UART_EFR_RTS is set.
+ */
+ up->efr &= ~UART_EFR_CTS;
+ if (cflag & CRTSCTS)
+ up->efr |= UART_EFR_CTS;
+ serial_outp(up, UART_LCR, 0xBF);
+ serial_outp(up, UART_EFR, up->efr);
+ }
+
+ if (up->capabilities & UART_NATSEMI) {
+ /* Switch to bank 2 not bank 1, to avoid resetting EXCR2 */
+ serial_outp(up, UART_LCR, 0xe0);
+ } else {
+ serial_outp(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */
+ }
+ serial_outp(up, UART_DLL, quot & 0xff); /* LS of divisor */
+ serial_outp(up, UART_DLM, quot >> 8); /* MS of divisor */
+ if (up->port.type == PORT_16750)
+ serial_outp(up, UART_FCR, fcr); /* set fcr */
+ serial_outp(up, UART_LCR, cval); /* reset DLAB */
+ up->lcr = cval; /* Save LCR */
+ if (up->port.type != PORT_16750) {
+ if (fcr & UART_FCR_ENABLE_FIFO) {
+ /* emulated UARTs (Lucent Venus 167x) need two steps */
+ serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
+ }
+ serial_outp(up, UART_FCR, fcr); /* set fcr */
+ }
+ serial8250_set_mctrl(&up->port, up->port.mctrl);
+ spin_unlock_irqrestore(&up->port.lock, flags);
+}
+
+static void
+serial8250_pm(struct uart_port *port, unsigned int state,
+ unsigned int oldstate)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ if (state) {
+ /* sleep */
+ if (up->capabilities & UART_STARTECH) {
+ /* Arrange to enter sleep mode */
+ serial_outp(up, UART_LCR, 0xBF);
+ serial_outp(up, UART_EFR, UART_EFR_ECB);
+ serial_outp(up, UART_LCR, 0);
+ serial_outp(up, UART_IER, UART_IERX_SLEEP);
+ serial_outp(up, UART_LCR, 0xBF);
+ serial_outp(up, UART_EFR, 0);
+ serial_outp(up, UART_LCR, 0);
+ }
+ if (up->port.type == PORT_16750) {
+ /* Arrange to enter sleep mode */
+ serial_outp(up, UART_IER, UART_IERX_SLEEP);
+ }
+ } else {
+ /* wake */
+ if (up->capabilities & UART_STARTECH) {
+ /* Wake up UART */
+ serial_outp(up, UART_LCR, 0xBF);
+ serial_outp(up, UART_EFR, UART_EFR_ECB);
+ /*
+ * Turn off LCR == 0xBF so we actually set the IER
+ * register on the XR16C850
+ */
+ serial_outp(up, UART_LCR, 0);
+ serial_outp(up, UART_IER, 0);
+ /*
+ * Now reset LCR so we can turn off the ECB bit
+ */
+ serial_outp(up, UART_LCR, 0xBF);
+ serial_outp(up, UART_EFR, 0);
+ /*
+ * For a XR16C850, we need to set the trigger levels
+ */
+ if (up->port.type == PORT_16850) {
+ unsigned char fctr;
+
+ fctr = serial_inp(up, UART_FCTR) &
+ ~(UART_FCTR_RX | UART_FCTR_TX);
+ serial_outp(up, UART_FCTR, fctr |
+ UART_FCTR_TRGD |
+ UART_FCTR_RX);
+ serial_outp(up, UART_TRG, UART_TRG_96);
+ serial_outp(up, UART_FCTR, fctr |
+ UART_FCTR_TRGD |
+ UART_FCTR_TX);
+ serial_outp(up, UART_TRG, UART_TRG_96);
+ }
+ serial_outp(up, UART_LCR, 0);
+ }
+
+ if (up->port.type == PORT_16750) {
+ /* Wake up UART */
+ serial_outp(up, UART_IER, 0);
+ }
+ }
+}
+
+/*
+ * Resource handling. This is complicated by the fact that resources
+ * depend on the port type. Maybe we should be claiming the standard
+ * 8250 ports, and then trying to get other resources as necessary?
+ */
+static int
+serial8250_request_std_resource(struct uart_8250_port *up, struct resource **res)
+{
+ unsigned int size = 8 << up->port.regshift;
+ int ret = 0;
+
+ switch (up->port.iotype) {
+ case SERIAL_IO_MEM:
+ if (up->port.mapbase) {
+ *res = request_mem_region(up->port.mapbase, size, "serial");
+ if (!*res)
+ ret = -EBUSY;
+ }
+ break;
+
+ case SERIAL_IO_HUB6:
+ case SERIAL_IO_PORT:
+ *res = request_region(up->port.iobase, size, "serial");
+ if (!*res)
+ ret = -EBUSY;
+ break;
+ }
+ return ret;
+}
+
+static int
+serial8250_request_rsa_resource(struct uart_8250_port *up, struct resource **res)
+{
+ unsigned int size = 8 << up->port.regshift;
+ unsigned long start;
+ int ret = 0;
+
+ switch (up->port.iotype) {
+ case SERIAL_IO_MEM:
+ if (up->port.mapbase) {
+ start = up->port.mapbase;
+ start += UART_RSA_BASE << up->port.regshift;
+ *res = request_mem_region(start, size, "serial-rsa");
+ if (!*res)
+ ret = -EBUSY;
+ }
+ break;
+
+ case SERIAL_IO_HUB6:
+ case SERIAL_IO_PORT:
+ start = up->port.iobase;
+ start += UART_RSA_BASE << up->port.regshift;
+ *res = request_region(start, size, "serial-rsa");
+ if (!*res)
+ ret = -EBUSY;
+ break;
+ }
+
+ return ret;
+}
+
+static void serial8250_release_port(struct uart_port *port)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ unsigned long start, offset = 0, size = 0;
+
+ if (up->port.type == PORT_RSA) {
+ offset = UART_RSA_BASE << up->port.regshift;
+ size = 8;
+ }
+
+ size <<= up->port.regshift;
+
+ switch (up->port.iotype) {
+ case SERIAL_IO_MEM:
+ if (up->port.mapbase) {
+ /*
+ * Unmap the area.
+ */
+ if (up->port.flags & UPF_IOREMAP) {
+ iounmap(up->port.membase);
+ up->port.membase = NULL;
+ }
+
+ start = up->port.mapbase;
+
+ if (size)
+ release_mem_region(start + offset, size);
+ release_mem_region(start, 8 << up->port.regshift);
+ }
+ break;
+
+ case SERIAL_IO_HUB6:
+ case SERIAL_IO_PORT:
+ start = up->port.iobase;
+
+ if (size)
+ release_region(start + offset, size);
+ release_region(start + offset, 8 << up->port.regshift);
+ break;
+
+ default:
+ break;
+ }
+}
+
+static int serial8250_request_port(struct uart_port *port)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ struct resource *res = NULL, *res_rsa = NULL;
+ int ret = 0;
+
+ if (up->port.flags & UPF_RESOURCES) {
+ if (up->port.type == PORT_RSA) {
+ ret = serial8250_request_rsa_resource(up, &res_rsa);
+ if (ret < 0)
+ return ret;
+ }
+
+ ret = serial8250_request_std_resource(up, &res);
+ }
+
+ /*
+ * If we have a mapbase, then request that as well.
+ */
+ if (ret == 0 && up->port.flags & UPF_IOREMAP) {
+ int size = res->end - res->start + 1;
+
+ up->port.membase = ioremap(up->port.mapbase, size);
+ if (!up->port.membase)
+ ret = -ENOMEM;
+ }
+
+ if (ret < 0) {
+ if (res_rsa)
+ release_resource(res_rsa);
+ if (res)
+ release_resource(res);
+ }
+ return ret;
+}
+
+static void serial8250_config_port(struct uart_port *port, int flags)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+ struct resource *res_std = NULL, *res_rsa = NULL;
+ int probeflags = PROBE_ANY;
+ int ret;
+
+#ifdef CONFIG_MCA
+ /*
+ * Don't probe for MCA ports on non-MCA machines.
+ */
+ if (up->port.flags & UPF_BOOT_ONLYMCA && !MCA_bus)
+ return;
+#endif
+
+ /*
+ * Find the region that we can probe for. This in turn
+ * tells us whether we can probe for the type of port.
+ */
+ if (up->port.flags & UPF_RESOURCES) {
+ ret = serial8250_request_std_resource(up, &res_std);
+ if (ret < 0)
+ return;
+
+ ret = serial8250_request_rsa_resource(up, &res_rsa);
+ if (ret < 0)
+ probeflags &= ~PROBE_RSA;
+ } else {
+ probeflags &= ~PROBE_RSA;
+ }
+
+ if (flags & UART_CONFIG_TYPE)
+ autoconfig(up, probeflags);
+ if (up->port.type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ)
+ autoconfig_irq(up);
+
+ /*
+ * If the port wasn't an RSA port, release the resource.
+ */
+ if (up->port.type != PORT_RSA && res_rsa)
+ release_resource(res_rsa);
+
+ if (up->port.type == PORT_UNKNOWN && res_std)
+ release_resource(res_std);
+}
+
+static int
+serial8250_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+ if (ser->irq >= NR_IRQS || ser->irq < 0 ||
+ ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
+ ser->type > PORT_MAX_8250 || ser->type == PORT_CIRRUS ||
+ ser->type == PORT_STARTECH)
+ return -EINVAL;
+ return 0;
+}
+
+static const char *
+serial8250_type(struct uart_port *port)
+{
+ int type = port->type;
+
+ if (type >= ARRAY_SIZE(uart_config))
+ type = 0;
+ return uart_config[type].name;
+}
+
+static struct uart_ops serial8250_pops = {
+ .tx_empty = serial8250_tx_empty,
+ .set_mctrl = serial8250_set_mctrl,
+ .get_mctrl = serial8250_get_mctrl,
+ .stop_tx = serial8250_stop_tx,
+ .start_tx = serial8250_start_tx,
+ .stop_rx = serial8250_stop_rx,
+ .enable_ms = serial8250_enable_ms,
+ .break_ctl = serial8250_break_ctl,
+ .startup = serial8250_startup,
+ .shutdown = serial8250_shutdown,
+ .change_speed = serial8250_change_speed,
+ .pm = serial8250_pm,
+ .type = serial8250_type,
+ .release_port = serial8250_release_port,
+ .request_port = serial8250_request_port,
+ .config_port = serial8250_config_port,
+ .verify_port = serial8250_verify_port,
+};
+
+static struct uart_8250_port serial8250_ports[UART_NR];
+
+static void __init serial8250_isa_init_ports(void)
+{
+ struct uart_8250_port *up;
+ static int first = 1;
+ int i;
+
+ if (!first)
+ return;
+ first = 0;
+
+ for (i = 0, up = serial8250_ports; i < ARRAY_SIZE(old_serial_port);
+ i++, up++) {
+ up->port.iobase = old_serial_port[i].port;
+ up->port.irq = irq_cannonicalize(old_serial_port[i].irq);
+ up->port.uartclk = old_serial_port[i].baud_base * 16;
+ up->port.flags = old_serial_port[i].flags |
+ UPF_RESOURCES;
+ up->port.hub6 = old_serial_port[i].hub6;
+ up->port.membase = old_serial_port[i].iomem_base;
+ up->port.iotype = old_serial_port[i].io_type;
+ up->port.regshift = old_serial_port[i].iomem_reg_shift;
+ up->port.ops = &serial8250_pops;
+
+ if (up->port.iotype == UPIO_MEM && up->port.mapbase)
+ up->port.flags |= UPF_IOREMAP;
+
+ if (share_irqs)
+ up->port.flags |= UPF_SHARE_IRQ;
+ }
+}
+
+static void __init serial8250_register_ports(struct uart_driver *drv)
+{
+ int i;
+
+ serial8250_isa_init_ports();
+
+ for (i = 0; i < UART_NR; i++) {
+ struct uart_8250_port *up = &serial8250_ports[i];
+
+ up->port.line = i;
+ up->port.ops = &serial8250_pops;
+ init_timer(&up->timer);
+ up->timer.function = serial8250_timeout;
+
+ /*
+ * ALPHA_KLUDGE_MCR needs to be killed.
+ */
+ up->mcr_mask = ~ALPHA_KLUDGE_MCR;
+ up->mcr_force = ALPHA_KLUDGE_MCR;
+
+ uart_add_one_port(drv, &up->port);
+ }
+}
+
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+
+#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
+
+/*
+ * Wait for transmitter & holding register to empty
+ */
+static inline void wait_for_xmitr(struct uart_8250_port *up)
+{
+ unsigned int status, tmout = 10000;
+
+ /* Wait up to 10ms for the character(s) to be sent. */
+ do {
+ status = serial_in(up, UART_LSR);
+
+ if (status & UART_LSR_BI)
+ up->lsr_break_flag = UART_LSR_BI;
+
+ if (--tmout == 0)
+ break;
+ udelay(1);
+ } while ((status & BOTH_EMPTY) != BOTH_EMPTY);
+
+ /* Wait up to 1s for flow control if necessary */
+ if (up->port.flags & UPF_CONS_FLOW) {
+ tmout = 1000000;
+ while (--tmout &&
+ ((serial_in(up, UART_MSR) & UART_MSR_CTS) == 0))
+ udelay(1);
+ }
+}
+
+/*
+ * Print a string to the serial port trying not to disturb
+ * any possible real use of the port...
+ *
+ * The console_lock must be held when we get here.
+ */
+static void
+serial8250_console_write(struct console *co, const char *s, unsigned int count)
+{
+ struct uart_8250_port *up = &serial8250_ports[co->index];
+ unsigned int ier;
+ int i;
+
+ /*
+ * First save the UER then disable the interrupts
+ */
+ ier = serial_in(up, UART_IER);
+ serial_out(up, UART_IER, 0);
+
+ /*
+ * Now, do each character
+ */
+ for (i = 0; i < count; i++, s++) {
+ wait_for_xmitr(up);
+
+ /*
+ * Send the character out.
+ * If a LF, also do CR...
+ */
+ serial_out(up, UART_TX, *s);
+ if (*s == 10) {
+ wait_for_xmitr(up);
+ serial_out(up, UART_TX, 13);
+ }
+ }
+
+ /*
+ * Finally, wait for transmitter to become empty
+ * and restore the IER
+ */
+ wait_for_xmitr(up);
+ serial_out(up, UART_IER, ier);
+}
+
+static kdev_t serial8250_console_device(struct console *co)
+{
+ return MKDEV(TTY_MAJOR, 64 + co->index);
+}
+
+static int __init serial8250_console_setup(struct console *co, char *options)
+{
+ struct uart_port *port;
+ int baud = 9600;
+ int bits = 8;
+ int parity = 'n';
+ int flow = 'n';
+
+ /*
+ * Check whether an invalid uart number has been specified, and
+ * if so, search for the first available port that does have
+ * console support.
+ */
+ if (co->index >= UART_NR)
+ co->index = 0;
+ port = &serial8250_ports[co->index].port;
+
+ /*
+ * Temporary fix.
+ */
+ spin_lock_init(&port->lock);
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+
+ return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct console serial8250_console = {
+ .name = "ttyS",
+ .write = serial8250_console_write,
+ .device = serial8250_console_device,
+ .setup = serial8250_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = -1,
+};
+
+void __init serial8250_console_init(void)
+{
+ serial8250_isa_init_ports();
+ register_console(&serial8250_console);
+}
+
+#define SERIAL8250_CONSOLE &serial8250_console
+#else
+#define SERIAL8250_CONSOLE NULL
+#endif
+
+static struct uart_driver serial8250_reg = {
+ .owner = THIS_MODULE,
+#ifdef CONFIG_DEVFS_FS
+ .normal_name = "tts/%d",
+ .callout_name = "cua/%d",
+#else
+ .normal_name = "ttyS",
+ .callout_name = "cua",
+#endif
+ .normal_major = TTY_MAJOR,
+ .callout_major = TTYAUX_MAJOR,
+ .normal_driver = &normal,
+ .callout_driver = &callout,
+ .table = serial8250_table,
+ .termios = serial8250_termios,
+ .termios_locked = serial8250_termios_locked,
+ .minor = 64,
+ .nr = UART_NR,
+ .cons = SERIAL8250_CONSOLE,
+};
+
+/*
+ * register_serial and unregister_serial allows for 16x50 serial ports to be
+ * configured at run-time, to support PCMCIA modems.
+ */
+
+static int __register_serial(struct serial_struct *req, int line)
+{
+ struct uart_port port;
+
+ port.iobase = req->port;
+ port.membase = req->iomem_base;
+ port.irq = req->irq;
+ port.uartclk = req->baud_base * 16;
+ port.fifosize = req->xmit_fifo_size;
+ port.regshift = req->iomem_reg_shift;
+ port.iotype = req->io_type;
+ port.flags = req->flags | UPF_BOOT_AUTOCONF;
+ port.mapbase = req->iomap_base;
+ port.line = line;
+
+ if (share_irqs)
+ port.flags |= UPF_SHARE_IRQ;
+
+ if (HIGH_BITS_OFFSET)
+ port.iobase |= (long) req->port_high << HIGH_BITS_OFFSET;
+
+ /*
+ * If a clock rate wasn't specified by the low level
+ * driver, then default to the standard clock rate.
+ */
+ if (port.uartclk == 0)
+ port.uartclk = BASE_BAUD * 16;
+
+ return uart_register_port(&serial8250_reg, &port);
+}
+
+/**
+ * register_serial - configure a 16x50 serial port at runtime
+ * @req: request structure
+ *
+ * Configure the serial port specified by the request. If the
+ * port exists and is in use an error is returned. If the port
+ * is not currently in the table it is added.
+ *
+ * The port is then probed and if necessary the IRQ is autodetected
+ * If this fails an error is returned.
+ *
+ * On success the port is ready to use and the line number is returned.
+ */
+int register_serial(struct serial_struct *req)
+{
+ return __register_serial(req, -1);
+}
+
+/**
+ * unregister_serial - remove a 16x50 serial port at runtime
+ * @line: serial line number
+ *
+ * Remove one serial port. This may be called from interrupt
+ * context.
+ */
+void unregister_serial(int line)
+{
+ uart_unregister_port(&serial8250_reg, line);
+}
+
+/*
+ * This is for ISAPNP only.
+ */
+void serial8250_get_irq_map(unsigned int *map)
+{
+ int i;
+
+ for (i = 0; i < UART_NR; i++) {
+ if (serial8250_ports[i].port.type != PORT_UNKNOWN &&
+ serial8250_ports[i].port.irq < 16)
+ *map |= 1 << serial8250_ports[i].port.irq;
+ }
+}
+
+static int __init serial8250_init(void)
+{
+ int ret, i;
+
+ for (i = 0; i < NR_IRQS; i++)
+ spin_lock_init(&irq_lists[i].lock);
+
+ ret = uart_register_driver(&serial8250_reg);
+ if (ret >= 0)
+ serial8250_register_ports(&serial8250_reg);
+
+ return ret;
+}
+
+static void __exit serial8250_exit(void)
+{
+ int i;
+
+ for (i = 0; i < UART_NR; i++)
+ uart_remove_one_port(&serial8250_reg, &serial8250_ports[i].port);
+
+ uart_unregister_driver(&serial8250_reg);
+}
+
+module_init(serial8250_init);
+module_exit(serial8250_exit);
+
+EXPORT_SYMBOL(register_serial);
+EXPORT_SYMBOL(unregister_serial);
+EXPORT_SYMBOL(serial8250_get_irq_map);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Generic 8250/16x50 serial driver");
+
+MODULE_PARM(share_irqs, "i");
+MODULE_PARM_DESC(share_irqs, "Share IRQs with other non-8250/16x50 devices"
+ " (unsafe)");
+
+#if defined(CONFIG_SERIAL_8250_RSA) && defined(MODULE)
+MODULE_PARM(probe_rsa, "1-" __MODULE_STRING(PORT_RSA_MAX) "i");
+MODULE_PARM_DESC(probe_rsa, "Probe I/O ports for RSA");
+MODULE_PARM(force_rsa, "1-" __MODULE_STRING(PORT_RSA_MAX) "i");
+MODULE_PARM_DESC(force_rsa, "Force I/O ports for RSA");
+#endif /* CONFIG_SERIAL_8250_RSA */
+
diff -urN linux-2.4.26/drivers/serial/8250.h linux-2.4.26-vrs1/drivers/serial/8250.h
--- linux-2.4.26/drivers/serial/8250.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/8250.h 2004-04-19 16:49:20.000000000 +0100
@@ -0,0 +1,88 @@
+/*
+ * linux/drivers/serial/8250.h
+ *
+ * Driver for 8250/16550-type serial ports
+ *
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * Copyright (C) 2001 Russell King.
+ *
+ * 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.
+ *
+ * $Id: 8250.h,v 1.1.1.1.2.1 2002/10/24 09:53:24 rmk Exp $
+ */
+
+#include <linux/config.h>
+
+struct serial8250_probe {
+ struct module *owner;
+ int (*pci_init_one)(struct pci_dev *dev);
+ void (*pci_remove_one)(struct pci_dev *dev);
+ void (*pnp_init)(void);
+};
+
+int serial8250_register_probe(struct serial8250_probe *probe);
+void serial8250_unregister_probe(struct serial8250_probe *probe);
+void serial8250_get_irq_map(unsigned int *map);
+
+struct old_serial_port {
+ unsigned int uart;
+ unsigned int baud_base;
+ unsigned int port;
+ unsigned int irq;
+ unsigned int flags;
+ unsigned char hub6;
+ unsigned char io_type;
+ unsigned char *iomem_base;
+ unsigned short iomem_reg_shift;
+};
+
+struct serial8250_config {
+ const char *name;
+ unsigned int dfl_xmit_fifo_size;
+ unsigned int flags;
+};
+
+#define UART_CLEAR_FIFO 0x01
+#define UART_USE_FIFO 0x02
+#define UART_STARTECH 0x04
+#define UART_NATSEMI 0x08
+#define UART_MCRAFE 0x10 /* TI16C750-style auto-flow */
+#define UART_EFRAFE 0x20 /* TI16C752/startech auto-flow */
+
+#define UART_BAD_TX_ENABLE 0x80000000
+
+#if defined(__i386__) && (defined(CONFIG_M386) || defined(CONFIG_M486))
+#define SERIAL_INLINE
+#endif
+
+#ifdef SERIAL_INLINE
+#define _INLINE_ inline
+#else
+#define _INLINE_
+#endif
+
+#define PROBE_RSA (1 << 0)
+#define PROBE_ANY (~0)
+
+#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
+
+#ifdef CONFIG_SERIAL_8250_SHARE_IRQ
+#define SERIAL8250_SHARE_IRQS 1
+#else
+#define SERIAL8250_SHARE_IRQS 0
+#endif
+
+#if defined(__alpha__) && !defined(CONFIG_PCI)
+/*
+ * Digital did something really horribly wrong with the OUT1 and OUT2
+ * lines on at least some ALPHA's. The failure mode is that if either
+ * is cleared, the machine locks up with endless interrupts.
+ */
+#define ALPHA_KLUDGE_MCR (UART_MCR_OUT2 | UART_MCR_OUT1)
+#else
+#define ALPHA_KLUDGE_MCR 0
+#endif
diff -urN linux-2.4.26/drivers/serial/8250_pci.c linux-2.4.26-vrs1/drivers/serial/8250_pci.c
--- linux-2.4.26/drivers/serial/8250_pci.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/8250_pci.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,1080 @@
+/*
+ * linux/drivers/char/serial_8250_pci.c
+ *
+ * Probe module for 8250/16550-type PCI serial ports.
+ *
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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.
+ *
+ * $Id: 8250_pci.c,v 1.8.2.1 2002/10/24 09:53:24 rmk Exp $
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/serial.h>
+
+/* 2.4.6 compatibility cruft ;( */
+#define pci_board __pci_board
+#include <linux/serialP.h>
+#undef pci_board
+
+#include <asm/bitops.h>
+#include <asm/byteorder.h>
+#include <asm/serial.h>
+
+#include "8250.h"
+
+#ifndef IS_PCI_REGION_IOPORT
+#define IS_PCI_REGION_IOPORT(dev, r) (pci_resource_flags((dev), (r)) & \
+ IORESOURCE_IO)
+#endif
+#ifndef IS_PCI_REGION_IOMEM
+#define IS_PCI_REGION_IOMEM(dev, r) (pci_resource_flags((dev), (r)) & \
+ IORESOURCE_MEM)
+#endif
+#ifndef PCI_IRQ_RESOURCE
+#define PCI_IRQ_RESOURCE(dev, r) ((dev)->irq_resource[r].start)
+#endif
+
+#ifndef pci_get_subvendor
+#define pci_get_subvendor(dev) ((dev)->subsystem_vendor)
+#define pci_get_subdevice(dev) ((dev)->subsystem_device)
+#endif
+
+struct serial_private {
+ unsigned int nr;
+ struct pci_board *board;
+ int line[0];
+};
+
+struct pci_board {
+ int flags;
+ int num_ports;
+ int base_baud;
+ int uart_offset;
+ int reg_shift;
+ int (*init_fn)(struct pci_dev *dev, struct pci_board *board,
+ int enable);
+ int first_uart_offset;
+};
+
+static int
+get_pci_port(struct pci_dev *dev, struct pci_board *board,
+ struct serial_struct *req, int idx)
+{
+ unsigned long port;
+ int base_idx;
+ int max_port;
+ int offset;
+
+ base_idx = SPCI_FL_GET_BASE(board->flags);
+ if (board->flags & SPCI_FL_BASE_TABLE)
+ base_idx += idx;
+
+ if (board->flags & SPCI_FL_REGION_SZ_CAP) {
+ max_port = pci_resource_len(dev, base_idx) / 8;
+ if (idx >= max_port)
+ return 1;
+ }
+
+ offset = board->first_uart_offset;
+
+ /* Timedia/SUNIX uses a mixture of BARs and offsets */
+ /* Ugh, this is ugly as all hell --- TYT */
+ if(dev->vendor == PCI_VENDOR_ID_TIMEDIA ) /* 0x1409 */
+ switch(idx) {
+ case 0: base_idx=0;
+ break;
+ case 1: base_idx=0; offset=8;
+ break;
+ case 2: base_idx=1;
+ break;
+ case 3: base_idx=1; offset=8;
+ break;
+ case 4: /* BAR 2*/
+ case 5: /* BAR 3 */
+ case 6: /* BAR 4*/
+ case 7: base_idx=idx-2; /* BAR 5*/
+ }
+
+ /* Some Titan cards are also a little weird */
+ if (dev->vendor == PCI_VENDOR_ID_TITAN &&
+ (dev->device == PCI_DEVICE_ID_TITAN_400L ||
+ dev->device == PCI_DEVICE_ID_TITAN_800L)) {
+ switch (idx) {
+ case 0: base_idx = 1;
+ break;
+ case 1: base_idx = 2;
+ break;
+ default:
+ base_idx = 4;
+ offset = 8 * (idx - 2);
+ }
+ }
+
+ port = pci_resource_start(dev, base_idx) + offset;
+
+ if ((board->flags & SPCI_FL_BASE_TABLE) == 0)
+ port += idx * (board->uart_offset ? board->uart_offset : 8);
+
+ if (IS_PCI_REGION_IOPORT(dev, base_idx)) {
+ req->port = port;
+ if (HIGH_BITS_OFFSET)
+ req->port_high = port >> HIGH_BITS_OFFSET;
+ else
+ req->port_high = 0;
+ return 0;
+ }
+ req->io_type = SERIAL_IO_MEM;
+ req->iomem_base = ioremap(port, board->uart_offset);
+ req->iomem_reg_shift = board->reg_shift;
+ req->port = 0;
+ return 0;
+}
+
+static _INLINE_ int get_pci_irq(struct pci_dev *dev,
+ struct pci_board *board,
+ int idx)
+{
+ int base_idx;
+
+ if ((board->flags & SPCI_FL_IRQRESOURCE) == 0)
+ return dev->irq;
+
+ base_idx = SPCI_FL_GET_IRQBASE(board->flags);
+ if (board->flags & SPCI_FL_IRQ_TABLE)
+ base_idx += idx;
+
+ return PCI_IRQ_RESOURCE(dev, base_idx);
+}
+
+/*
+ * Some PCI serial cards using the PLX 9050 PCI interface chip require
+ * that the card interrupt be explicitly enabled or disabled. This
+ * seems to be mainly needed on card using the PLX which also use I/O
+ * mapped memory.
+ */
+static int __devinit
+pci_plx9050_fn(struct pci_dev *dev, struct pci_board *board, int enable)
+{
+ u8 data, *p, irq_config;
+ int pci_config;
+
+ irq_config = 0x41;
+ pci_config = PCI_COMMAND_MEMORY;
+ if (dev->vendor == PCI_VENDOR_ID_PANACOM)
+ irq_config = 0x43;
+ if ((dev->vendor == PCI_VENDOR_ID_PLX) &&
+ (dev->device == PCI_DEVICE_ID_PLX_ROMULUS)) {
+ /*
+ * As the megawolf cards have the int pins active
+ * high, and have 2 UART chips, both ints must be
+ * enabled on the 9050. Also, the UARTS are set in
+ * 16450 mode by default, so we have to enable the
+ * 16C950 'enhanced' mode so that we can use the deep
+ * FIFOs
+ */
+ irq_config = 0x5b;
+ pci_config = PCI_COMMAND_MEMORY | PCI_COMMAND_IO;
+ }
+
+ pci_read_config_byte(dev, PCI_COMMAND, &data);
+
+ if (enable)
+ pci_write_config_byte(dev, PCI_COMMAND,
+ data | pci_config);
+
+ /* enable/disable interrupts */
+ p = ioremap(pci_resource_start(dev, 0), 0x80);
+ writel(enable ? irq_config : 0x00, (unsigned long)p + 0x4c);
+ iounmap(p);
+
+ if (!enable)
+ pci_write_config_byte(dev, PCI_COMMAND,
+ data & ~pci_config);
+ return 0;
+}
+
+
+/*
+ * SIIG serial cards have an PCI interface chip which also controls
+ * the UART clocking frequency. Each UART can be clocked independently
+ * (except cards equiped with 4 UARTs) and initial clocking settings
+ * are stored in the EEPROM chip. It can cause problems because this
+ * version of serial driver doesn't support differently clocked UART's
+ * on single PCI card. To prevent this, initialization functions set
+ * high frequency clocking for all UART's on given card. It is safe (I
+ * hope) because it doesn't touch EEPROM settings to prevent conflicts
+ * with other OSes (like M$ DOS).
+ *
+ * SIIG support added by Andrey Panin <pazke@mail.tp.ru>, 10/1999
+ *
+ * There is two family of SIIG serial cards with different PCI
+ * interface chip and different configuration methods:
+ * - 10x cards have control registers in IO and/or memory space;
+ * - 20x cards have control registers in standard PCI configuration space.
+ */
+
+#define PCI_DEVICE_ID_SIIG_1S_10x (PCI_DEVICE_ID_SIIG_1S_10x_550 & 0xfffc)
+#define PCI_DEVICE_ID_SIIG_2S_10x (PCI_DEVICE_ID_SIIG_2S_10x_550 & 0xfff8)
+
+static int __devinit
+pci_siig10x_fn(struct pci_dev *dev, struct pci_board *board, int enable)
+{
+ u16 data, *p;
+
+ if (!enable) return 0;
+
+ p = ioremap(pci_resource_start(dev, 0), 0x80);
+
+ switch (dev->device & 0xfff8) {
+ case PCI_DEVICE_ID_SIIG_1S_10x: /* 1S */
+ data = 0xffdf;
+ break;
+ case PCI_DEVICE_ID_SIIG_2S_10x: /* 2S, 2S1P */
+ data = 0xf7ff;
+ break;
+ default: /* 1S1P, 4S */
+ data = 0xfffb;
+ break;
+ }
+
+ writew(readw((unsigned long) p + 0x28) & data, (unsigned long) p + 0x28);
+ iounmap(p);
+ return 0;
+}
+
+#define PCI_DEVICE_ID_SIIG_2S_20x (PCI_DEVICE_ID_SIIG_2S_20x_550 & 0xfffc)
+#define PCI_DEVICE_ID_SIIG_2S1P_20x (PCI_DEVICE_ID_SIIG_2S1P_20x_550 & 0xfffc)
+
+static int __devinit
+pci_siig20x_fn(struct pci_dev *dev, struct pci_board *board, int enable)
+{
+ u8 data;
+
+ if (!enable) return 0;
+
+ /* Change clock frequency for the first UART. */
+ pci_read_config_byte(dev, 0x6f, &data);
+ pci_write_config_byte(dev, 0x6f, data & 0xef);
+
+ /* If this card has 2 UART, we have to do the same with second UART. */
+ if (((dev->device & 0xfffc) == PCI_DEVICE_ID_SIIG_2S_20x) ||
+ ((dev->device & 0xfffc) == PCI_DEVICE_ID_SIIG_2S1P_20x)) {
+ pci_read_config_byte(dev, 0x73, &data);
+ pci_write_config_byte(dev, 0x73, data & 0xef);
+ }
+ return 0;
+}
+
+/* Added for EKF Intel i960 serial boards */
+static int __devinit
+pci_inteli960ni_fn(struct pci_dev *dev,
+ struct pci_board *board,
+ int enable)
+{
+ unsigned long oldval;
+
+ if (!(pci_get_subdevice(dev) & 0x1000))
+ return(-1);
+
+ if (!enable) /* is there something to deinit? */
+ return(0);
+
+ /* is firmware started? */
+ pci_read_config_dword(dev, 0x44, (void*) &oldval);
+ if (oldval == 0x00001000L) { /* RESET value */
+ printk(KERN_DEBUG "Local i960 firmware missing");
+ return(-1);
+ }
+ return(0);
+}
+
+/*
+ * Timedia has an explosion of boards, and to avoid the PCI table from
+ * growing *huge*, we use this function to collapse some 70 entries
+ * in the PCI table into one, for sanity's and compactness's sake.
+ */
+static unsigned short timedia_single_port[] = {
+ 0x4025, 0x4027, 0x4028, 0x5025, 0x5027, 0 };
+static unsigned short timedia_dual_port[] = {
+ 0x0002, 0x4036, 0x4037, 0x4038, 0x4078, 0x4079, 0x4085,
+ 0x4088, 0x4089, 0x5037, 0x5078, 0x5079, 0x5085, 0x6079,
+ 0x7079, 0x8079, 0x8137, 0x8138, 0x8237, 0x8238, 0x9079,
+ 0x9137, 0x9138, 0x9237, 0x9238, 0xA079, 0xB079, 0xC079,
+ 0xD079, 0 };
+static unsigned short timedia_quad_port[] = {
+ 0x4055, 0x4056, 0x4095, 0x4096, 0x5056, 0x8156, 0x8157,
+ 0x8256, 0x8257, 0x9056, 0x9156, 0x9157, 0x9158, 0x9159,
+ 0x9256, 0x9257, 0xA056, 0xA157, 0xA158, 0xA159, 0xB056,
+ 0xB157, 0 };
+static unsigned short timedia_eight_port[] = {
+ 0x4065, 0x4066, 0x5065, 0x5066, 0x8166, 0x9066, 0x9166,
+ 0x9167, 0x9168, 0xA066, 0xA167, 0xA168, 0 };
+static struct timedia_struct {
+ int num;
+ unsigned short *ids;
+} timedia_data[] = {
+ { 1, timedia_single_port },
+ { 2, timedia_dual_port },
+ { 4, timedia_quad_port },
+ { 8, timedia_eight_port },
+ { 0, 0 }
+};
+
+static int __devinit
+pci_timedia_fn(struct pci_dev *dev, struct pci_board *board, int enable)
+{
+ int i, j;
+ unsigned short *ids;
+
+ if (!enable)
+ return 0;
+
+ for (i=0; timedia_data[i].num; i++) {
+ ids = timedia_data[i].ids;
+ for (j=0; ids[j]; j++) {
+ if (pci_get_subdevice(dev) == ids[j]) {
+ board->num_ports = timedia_data[i].num;
+ return 0;
+ }
+ }
+ }
+ return 0;
+}
+
+static int __devinit
+pci_xircom_fn(struct pci_dev *dev, struct pci_board *board, int enable)
+{
+ __set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(HZ/10);
+ return 0;
+}
+
+/*
+ * This is the configuration table for all of the PCI serial boards
+ * which we support. It is directly indexed by the pci_board_num_t enum
+ * value, which is encoded in the pci_device_id PCI probe table's
+ * driver_data member.
+ */
+enum pci_board_num_t {
+ pbn_b0_1_115200,
+ pbn_default = 0,
+
+ pbn_b0_2_115200,
+ pbn_b0_4_115200,
+
+ pbn_b0_1_921600,
+ pbn_b0_2_921600,
+ pbn_b0_4_921600,
+
+ pbn_b0_bt_1_115200,
+ pbn_b0_bt_2_115200,
+ pbn_b0_bt_1_460800,
+ pbn_b0_bt_2_460800,
+
+ pbn_b1_1_115200,
+ pbn_b1_2_115200,
+ pbn_b1_4_115200,
+ pbn_b1_8_115200,
+
+ pbn_b1_2_921600,
+ pbn_b1_4_921600,
+ pbn_b1_8_921600,
+
+ pbn_b1_2_1382400,
+ pbn_b1_4_1382400,
+ pbn_b1_8_1382400,
+
+ pbn_b2_8_115200,
+ pbn_b2_4_460800,
+ pbn_b2_8_460800,
+ pbn_b2_16_460800,
+ pbn_b2_4_921600,
+ pbn_b2_8_921600,
+
+ pbn_b2_bt_1_115200,
+ pbn_b2_bt_2_115200,
+ pbn_b2_bt_4_115200,
+ pbn_b2_bt_2_921600,
+
+ pbn_panacom,
+ pbn_panacom2,
+ pbn_panacom4,
+ pbn_plx_romulus,
+ pbn_oxsemi,
+ pbn_timedia,
+ pbn_intel_i960,
+ pbn_sgi_ioc3,
+#ifdef CONFIG_DDB5074
+ pbn_nec_nile4,
+#endif
+#if 0
+ pbn_dci_pccom8,
+#endif
+ pbn_xircom_combo,
+
+ pbn_siig10x_0,
+ pbn_siig10x_1,
+ pbn_siig10x_2,
+ pbn_siig10x_4,
+ pbn_siig20x_0,
+ pbn_siig20x_2,
+ pbn_siig20x_4,
+
+ pbn_computone_4,
+ pbn_computone_6,
+ pbn_computone_8,
+};
+
+static struct pci_board pci_boards[] __devinitdata = {
+ /*
+ * PCI Flags, Number of Ports, Base (Maximum) Baud Rate,
+ * Offset to get to next UART's registers,
+ * Register shift to use for memory-mapped I/O,
+ * Initialization function, first UART offset
+ */
+
+ /* Generic serial board, pbn_b0_1_115200, pbn_default */
+ { SPCI_FL_BASE0, 1, 115200 }, /* pbn_b0_1_115200,
+ pbn_default */
+
+ { SPCI_FL_BASE0, 2, 115200 }, /* pbn_b0_2_115200 */
+ { SPCI_FL_BASE0, 4, 115200 }, /* pbn_b0_4_115200 */
+
+ { SPCI_FL_BASE0, 1, 921600 }, /* pbn_b0_1_921600 */
+ { SPCI_FL_BASE0, 2, 921600 }, /* pbn_b0_2_921600 */
+ { SPCI_FL_BASE0, 4, 921600 }, /* pbn_b0_4_921600 */
+
+ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 115200 }, /* pbn_b0_bt_1_115200 */
+ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 2, 115200 }, /* pbn_b0_bt_2_115200 */
+ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 1, 460800 }, /* pbn_b0_bt_1_460800 */
+ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 2, 460800 }, /* pbn_b0_bt_2_460800 */
+
+ { SPCI_FL_BASE1, 1, 115200 }, /* pbn_b1_1_115200 */
+ { SPCI_FL_BASE1, 2, 115200 }, /* pbn_b1_2_115200 */
+ { SPCI_FL_BASE1, 4, 115200 }, /* pbn_b1_4_115200 */
+ { SPCI_FL_BASE1, 8, 115200 }, /* pbn_b1_8_115200 */
+
+ { SPCI_FL_BASE1, 2, 921600 }, /* pbn_b1_2_921600 */
+ { SPCI_FL_BASE1, 4, 921600 }, /* pbn_b1_4_921600 */
+ { SPCI_FL_BASE1, 8, 921600 }, /* pbn_b1_8_921600 */
+
+ { SPCI_FL_BASE1, 2, 1382400 }, /* pbn_b1_2_1382400 */
+ { SPCI_FL_BASE1, 4, 1382400 }, /* pbn_b1_4_1382400 */
+ { SPCI_FL_BASE1, 8, 1382400 }, /* pbn_b1_8_1382400 */
+
+ { SPCI_FL_BASE2, 8, 115200 }, /* pbn_b2_8_115200 */
+ { SPCI_FL_BASE2, 4, 460800 }, /* pbn_b2_4_460800 */
+ { SPCI_FL_BASE2, 8, 460800 }, /* pbn_b2_8_460800 */
+ { SPCI_FL_BASE2, 16, 460800 }, /* pbn_b2_16_460800 */
+ { SPCI_FL_BASE2, 4, 921600 }, /* pbn_b2_4_921600 */
+ { SPCI_FL_BASE2, 8, 921600 }, /* pbn_b2_8_921600 */
+
+ { SPCI_FL_BASE2 | SPCI_FL_BASE_TABLE, 1, 115200 }, /* pbn_b2_bt_1_115200 */
+ { SPCI_FL_BASE2 | SPCI_FL_BASE_TABLE, 2, 115200 }, /* pbn_b2_bt_2_115200 */
+ { SPCI_FL_BASE2 | SPCI_FL_BASE_TABLE, 4, 115200 }, /* pbn_b2_bt_4_115200 */
+ { SPCI_FL_BASE2 | SPCI_FL_BASE_TABLE, 2, 921600 }, /* pbn_b2_bt_2_921600 */
+
+ { SPCI_FL_BASE2, 2, 921600, /* IOMEM */ /* pbn_panacom */
+ 0x400, 7, pci_plx9050_fn },
+ { SPCI_FL_BASE2 | SPCI_FL_BASE_TABLE, 2, 921600, /* pbn_panacom2 */
+ 0x400, 7, pci_plx9050_fn },
+ { SPCI_FL_BASE2 | SPCI_FL_BASE_TABLE, 4, 921600, /* pbn_panacom4 */
+ 0x400, 7, pci_plx9050_fn },
+ { SPCI_FL_BASE2, 4, 921600, /* pbn_plx_romulus */
+ 0x20, 2, pci_plx9050_fn, 0x03 },
+ /* This board uses the size of PCI Base region 0 to
+ * signal now many ports are available */
+ { SPCI_FL_BASE0 | SPCI_FL_REGION_SZ_CAP, 32, 115200 }, /* pbn_oxsemi */
+ { SPCI_FL_BASE_TABLE, 1, 921600, /* pbn_timedia */
+ 0, 0, pci_timedia_fn },
+ /* EKF addition for i960 Boards form EKF with serial port */
+ { SPCI_FL_BASE0, 32, 921600, /* max 256 ports */ /* pbn_intel_i960 */
+ 8<<2, 2, pci_inteli960ni_fn, 0x10000},
+ { SPCI_FL_BASE0 | SPCI_FL_IRQRESOURCE, /* pbn_sgi_ioc3 */
+ 1, 458333, 0, 0, 0, 0x20178 },
+#ifdef CONFIG_DDB5074
+ /*
+ * NEC Vrc-5074 (Nile 4) builtin UART.
+ * Conditionally compiled in since this is a motherboard device.
+ */
+ { SPCI_FL_BASE0, 1, 520833, /* pbn_nec_nile4 */
+ 64, 3, NULL, 0x300 },
+#endif
+#if 0 /* PCI_DEVICE_ID_DCI_PCCOM8 ? */ /* pbn_dci_pccom8 */
+ { SPCI_FL_BASE3, 8, 115200, 8 },
+#endif
+ { SPCI_FL_BASE0, 1, 115200, /* pbn_xircom_combo */
+ 0, 0, pci_xircom_fn },
+
+ { SPCI_FL_BASE2, 1, 460800, /* pbn_siig10x_0 */
+ 0, 0, pci_siig10x_fn },
+ { SPCI_FL_BASE2, 1, 921600, /* pbn_siig10x_1 */
+ 0, 0, pci_siig10x_fn },
+ { SPCI_FL_BASE2 | SPCI_FL_BASE_TABLE, 2, 921600, /* pbn_siig10x_2 */
+ 0, 0, pci_siig10x_fn },
+ { SPCI_FL_BASE2 | SPCI_FL_BASE_TABLE, 4, 921600, /* pbn_siig10x_4 */
+ 0, 0, pci_siig10x_fn },
+ { SPCI_FL_BASE0, 1, 921600, /* pbn_siix20x_0 */
+ 0, 0, pci_siig20x_fn },
+ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 2, 921600, /* pbn_siix20x_2 */
+ 0, 0, pci_siig20x_fn },
+ { SPCI_FL_BASE0 | SPCI_FL_BASE_TABLE, 4, 921600, /* pbn_siix20x_4 */
+ 0, 0, pci_siig20x_fn },
+
+ { SPCI_FL_BASE0, 4, 921600, /* IOMEM */ /* pbn_computone_4 */
+ 0x40, 2, NULL, 0x200 },
+ { SPCI_FL_BASE0, 6, 921600, /* IOMEM */ /* pbn_computone_6 */
+ 0x40, 2, NULL, 0x200 },
+ { SPCI_FL_BASE0, 8, 921600, /* IOMEM */ /* pbn_computone_8 */
+ 0x40, 2, NULL, 0x200 },
+};
+
+/*
+ * Given a complete unknown PCI device, try to use some heuristics to
+ * guess what the configuration might be, based on the pitiful PCI
+ * serial specs. Returns 0 on success, 1 on failure.
+ */
+static int __devinit serial_pci_guess_board(struct pci_dev *dev,
+ struct pci_board *board)
+{
+ int num_iomem = 0, num_port = 0, first_port = -1;
+ int i;
+
+ /*
+ * If it is not a communications device or the programming
+ * interface is greater than 6, give up.
+ *
+ * (Should we try to make guesses for multiport serial devices
+ * later?)
+ */
+ if ((((dev->class >> 8) != PCI_CLASS_COMMUNICATION_SERIAL) &&
+ ((dev->class >> 8) != PCI_CLASS_COMMUNICATION_MODEM)) ||
+ (dev->class & 0xff) > 6)
+ return 1;
+
+ for (i=0; i < 6; i++) {
+ if (IS_PCI_REGION_IOPORT(dev, i)) {
+ num_port++;
+ if (first_port == -1)
+ first_port = i;
+ }
+ if (IS_PCI_REGION_IOMEM(dev, i))
+ num_iomem++;
+ }
+
+ /*
+ * If there is 1 or 0 iomem regions, and exactly one port, use
+ * it.
+ */
+ if (num_iomem <= 1 && num_port == 1) {
+ board->flags = first_port;
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * return -1 to refuse
+ */
+static int pci_init_one(struct pci_dev *dev, const struct pci_device_id *ent)
+{
+ struct serial_private *priv;
+ struct pci_board *board, tmp;
+ struct serial_struct serial_req;
+ int base_baud, rc, k;
+
+ board = &pci_boards[ent->driver_data];
+
+ rc = pci_enable_device(dev);
+ if (rc)
+ return rc;
+
+ if (ent->driver_data == pbn_default &&
+ serial_pci_guess_board(dev, board))
+ return -ENODEV;
+ else if (serial_pci_guess_board(dev, &tmp) == 0) {
+ printk(KERN_INFO "Redundant entry in serial pci_table. "
+ "Please send the output of\n"
+ "lspci -vv, this message (%d,%d,%d,%d)\n"
+ "and the manufacturer and name of "
+ "serial board or modem board\n"
+ "to serial-pci-info@lists.sourceforge.net.\n",
+ dev->vendor, dev->device,
+ pci_get_subvendor(dev), pci_get_subdevice(dev));
+ }
+
+
+ priv = kmalloc(sizeof(struct serial_private) +
+ sizeof(unsigned int) * board->num_ports,
+ GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ /*
+ * Run the initialization function, if any
+ */
+ if (board->init_fn && ((board->init_fn)(dev, board, 1) != 0)) {
+ kfree(priv);
+ return -ENODEV;
+ }
+
+ base_baud = board->base_baud;
+ if (!base_baud)
+ base_baud = BASE_BAUD;
+ memset(&serial_req, 0, sizeof(serial_req));
+ for (k=0; k < board->num_ports; k++) {
+ serial_req.irq = get_pci_irq(dev, board, k);
+ if (get_pci_port(dev, board, &serial_req, k))
+ break;
+#ifdef SERIAL_DEBUG_PCI
+ printk("Setup PCI/PNP port: port %x, irq %d, type %d\n",
+ serial_req.port, serial_req.irq, serial_req.io_type);
+#endif
+ serial_req.flags = ASYNC_SKIP_TEST | ASYNC_AUTOPROBE;
+ serial_req.baud_base = base_baud;
+ priv->line[k] = register_serial(&serial_req);
+ if (priv->line[k] < 0)
+ break;
+ }
+
+ priv->board = board;
+ priv->nr = k;
+
+ pci_set_drvdata(dev, priv);
+
+ return 0;
+}
+
+static void pci_remove_one(struct pci_dev *dev)
+{
+ struct serial_private *priv = pci_get_drvdata(dev);
+ int i;
+
+ pci_set_drvdata(dev, NULL);
+
+ for (i = 0; i < priv->nr; i++)
+ unregister_serial(priv->line[i]);
+
+ priv->board->init_fn(dev, priv->board, 0);
+
+ kfree(priv);
+}
+
+static struct pci_device_id serial_pci_tbl[] __devinitdata = {
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V960,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232, 0, 0,
+ pbn_b1_8_1382400 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V960,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232, 0, 0,
+ pbn_b1_4_1382400 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V960,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_232, 0, 0,
+ pbn_b1_2_1382400 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_232, 0, 0,
+ pbn_b1_8_1382400 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_232, 0, 0,
+ pbn_b1_4_1382400 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_232, 0, 0,
+ pbn_b1_2_1382400 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485, 0, 0,
+ pbn_b1_8_921600 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_4_4, 0, 0,
+ pbn_b1_8_921600 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485, 0, 0,
+ pbn_b1_4_921600 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH4_485_2_2, 0, 0,
+ pbn_b1_4_921600 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH2_485, 0, 0,
+ pbn_b1_2_921600 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH8_485_2_6, 0, 0,
+ pbn_b1_8_921600 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH081101V1, 0, 0,
+ pbn_b1_8_921600 },
+ { PCI_VENDOR_ID_V3, PCI_DEVICE_ID_V3_V351,
+ PCI_SUBVENDOR_ID_CONNECT_TECH,
+ PCI_SUBDEVICE_ID_CONNECT_TECH_BH041101V1, 0, 0,
+ pbn_b1_4_921600 },
+
+ { PCI_VENDOR_ID_SEALEVEL, PCI_DEVICE_ID_SEALEVEL_U530,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_bt_1_115200 },
+ { PCI_VENDOR_ID_SEALEVEL, PCI_DEVICE_ID_SEALEVEL_UCOMM2,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_bt_2_115200 },
+ { PCI_VENDOR_ID_SEALEVEL, PCI_DEVICE_ID_SEALEVEL_UCOMM422,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_bt_4_115200 },
+ { PCI_VENDOR_ID_SEALEVEL, PCI_DEVICE_ID_SEALEVEL_UCOMM232,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_bt_2_115200 },
+ { PCI_VENDOR_ID_SEALEVEL, PCI_DEVICE_ID_SEALEVEL_COMM4,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_bt_4_115200 },
+ { PCI_VENDOR_ID_SEALEVEL, PCI_DEVICE_ID_SEALEVEL_COMM8,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_8_115200 },
+
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_GTEK_SERIAL2,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_bt_2_115200 },
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_SPCOM200,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_bt_2_921600 },
+ /* VScom SPCOM800, from sl@s.pl */
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_SPCOM800,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_8_921600 },
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_1077,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_4_921600 },
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+ PCI_SUBVENDOR_ID_KEYSPAN,
+ PCI_SUBDEVICE_ID_KEYSPAN_SX2, 0, 0,
+ pbn_panacom },
+ { PCI_VENDOR_ID_PANACOM, PCI_DEVICE_ID_PANACOM_QUADMODEM,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_panacom4 },
+ { PCI_VENDOR_ID_PANACOM, PCI_DEVICE_ID_PANACOM_DUALMODEM,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_panacom2 },
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+ PCI_SUBVENDOR_ID_CHASE_PCIFAST,
+ PCI_SUBDEVICE_ID_CHASE_PCIFAST4, 0, 0,
+ pbn_b2_4_460800 },
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+ PCI_SUBVENDOR_ID_CHASE_PCIFAST,
+ PCI_SUBDEVICE_ID_CHASE_PCIFAST8, 0, 0,
+ pbn_b2_8_460800 },
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+ PCI_SUBVENDOR_ID_CHASE_PCIFAST,
+ PCI_SUBDEVICE_ID_CHASE_PCIFAST16, 0, 0,
+ pbn_b2_16_460800 },
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+ PCI_SUBVENDOR_ID_CHASE_PCIFAST,
+ PCI_SUBDEVICE_ID_CHASE_PCIFAST16FMC, 0, 0,
+ pbn_b2_16_460800 },
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+ PCI_SUBVENDOR_ID_CHASE_PCIRAS,
+ PCI_SUBDEVICE_ID_CHASE_PCIRAS4, 0, 0,
+ pbn_b2_4_460800 },
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
+ PCI_SUBVENDOR_ID_CHASE_PCIRAS,
+ PCI_SUBDEVICE_ID_CHASE_PCIRAS8, 0, 0,
+ pbn_b2_8_460800 },
+ /* Megawolf Romulus PCI Serial Card, from Mike Hudson */
+ /* (Exoray@isys.ca) */
+ { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_ROMULUS,
+ 0x10b5, 0x106a, 0, 0,
+ pbn_plx_romulus },
+ { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_QSC100,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b1_4_115200 },
+ { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_DSC100,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b1_2_115200 },
+ { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_ESC100D,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b1_8_115200 },
+ { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_ESC100M,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b1_8_115200 },
+ { PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_OXSEMI_16PCI954,
+ PCI_VENDOR_ID_SPECIALIX, PCI_SUBDEVICE_ID_SPECIALIX_SPEED4, 0, 0,
+ pbn_b0_4_921600 },
+ { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_4_115200 },
+ { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_2_115200 },
+
+ /* Digitan DS560-558, from jimd@esoft.com */
+ { PCI_VENDOR_ID_ATT, PCI_DEVICE_ID_ATT_VENUS_MODEM,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b1_1_115200 },
+
+ /* 3Com US Robotics 56k Voice Internal PCI model 5610 */
+ { PCI_VENDOR_ID_USR, 0x1008,
+ PCI_ANY_ID, PCI_ANY_ID, },
+
+ /* Titan Electronic cards */
+ { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_100,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_1_921600 },
+ { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_2_921600 },
+ { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_400,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_4_921600 },
+ { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_800B,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_4_921600 },
+ { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_100L,
+ PCI_ANY_ID, PCI_ANY_ID,
+ SPCI_FL_BASE1, 1, 921600 },
+ { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_200L,
+ PCI_ANY_ID, PCI_ANY_ID,
+ SPCI_FL_BASE1 | SPCI_FL_BASE_TABLE, 2, 921600 },
+ /* The 400L and 800L have a custom hack in get_pci_port */
+ { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_400L,
+ PCI_ANY_ID, PCI_ANY_ID,
+ SPCI_FL_BASE_TABLE, 4, 921600 },
+ { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_800L,
+ PCI_ANY_ID, PCI_ANY_ID,
+ SPCI_FL_BASE_TABLE, 8, 921600 },
+
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S_10x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S_10x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S_10x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_1 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_1 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_1 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S_10x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S_10x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S_10x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S1P_10x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S1P_10x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S1P_10x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_4S_10x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_4 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_4S_10x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_4 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_4S_10x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig10x_4 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S_20x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S_20x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S_20x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_20x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_20x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_20x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2P1S_20x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2P1S_20x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2P1S_20x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_0 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S_20x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S_20x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S_20x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S1P_20x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S1P_20x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_2S1P_20x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_2 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_4S_20x_550,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_4 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_4S_20x_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_4 },
+ { PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_4S_20x_850,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_siig20x_4 },
+
+ /* Computone devices submitted by Doug McNash dmcnash@computone.com */
+ { PCI_VENDOR_ID_COMPUTONE, PCI_DEVICE_ID_COMPUTONE_PG,
+ PCI_SUBVENDOR_ID_COMPUTONE, PCI_SUBDEVICE_ID_COMPUTONE_PG4,
+ 0, 0, pbn_computone_4 },
+ { PCI_VENDOR_ID_COMPUTONE, PCI_DEVICE_ID_COMPUTONE_PG,
+ PCI_SUBVENDOR_ID_COMPUTONE, PCI_SUBDEVICE_ID_COMPUTONE_PG8,
+ 0, 0, pbn_computone_8 },
+ { PCI_VENDOR_ID_COMPUTONE, PCI_DEVICE_ID_COMPUTONE_PG,
+ PCI_SUBVENDOR_ID_COMPUTONE, PCI_SUBDEVICE_ID_COMPUTONE_PG6,
+ 0, 0, pbn_computone_6 },
+
+ { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI95N,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, pbn_oxsemi },
+ { PCI_VENDOR_ID_TIMEDIA, PCI_DEVICE_ID_TIMEDIA_1889,
+ PCI_VENDOR_ID_TIMEDIA, PCI_ANY_ID, 0, 0, pbn_timedia },
+
+ { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_DSERIAL,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_bt_2_115200 },
+ { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_QUATRO_A,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_bt_2_115200 },
+ { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_QUATRO_B,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_bt_2_115200 },
+ { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_PORT_PLUS,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_bt_2_460800 },
+ { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_QUAD_A,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_bt_2_460800 },
+ { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_QUAD_B,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_bt_2_460800 },
+ { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_SSERIAL,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_bt_1_115200 },
+ { PCI_VENDOR_ID_LAVA, PCI_DEVICE_ID_LAVA_PORT_650,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b0_bt_1_460800 },
+
+ /* RAStel 2 port modem, gerg@moreton.com.au */
+ { PCI_VENDOR_ID_MORETON, PCI_DEVICE_ID_RASTEL_2PORT,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_b2_bt_2_115200 },
+
+ /* EKF addition for i960 Boards form EKF with serial port */
+ { PCI_VENDOR_ID_INTEL, 0x1960,
+ 0xE4BF, PCI_ANY_ID, 0, 0,
+ pbn_intel_i960 },
+
+ /* Xircom Cardbus/Ethernet combos */
+ { PCI_VENDOR_ID_XIRCOM, PCI_DEVICE_ID_XIRCOM_X3201_MDM,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_xircom_combo },
+
+ /*
+ * Untested PCI modems, sent in from various folks...
+ */
+
+ /* Elsa Model 56K PCI Modem, from Andreas Rath <arh@01019freenet.de> */
+ { PCI_VENDOR_ID_ROCKWELL, 0x1004,
+ 0x1048, 0x1500, 0, 0,
+ pbn_b1_1_115200 },
+
+ { PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3,
+ 0xFF00, 0, 0, 0,
+ pbn_sgi_ioc3 },
+
+#ifdef CONFIG_DDB5074
+ /*
+ * NEC Vrc-5074 (Nile 4) builtin UART.
+ * Conditionally compiled in since this is a motherboard device.
+ */
+ { PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_NILE4,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_nec_nile4 },
+#endif
+
+#if 0 /* PCI_DEVICE_ID_DCI_PCCOM8 ? */
+ { PCI_VENDOR_ID_DCI, PCI_DEVICE_ID_DCI_PCCOM8,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+ pbn_dci_pccom8 },
+#endif
+
+ { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+ PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xffff00, },
+ { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+ PCI_CLASS_COMMUNICATION_MODEM << 8, 0xffff00, },
+ { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
+ PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00, },
+ { 0, }
+};
+
+static struct pci_driver serial_pci_driver = {
+ name: "serial",
+ probe: pci_init_one,
+ remove: pci_remove_one,
+ id_table: serial_pci_tbl,
+};
+
+static int __init serial8250_pci_init(void)
+{
+ return pci_module_init(&serial_pci_driver);
+}
+
+static void __exit serial8250_pci_exit(void)
+{
+ pci_unregister_driver(&serial_pci_driver);
+}
+
+module_init(serial8250_pci_init);
+module_exit(serial8250_pci_exit);
+
+EXPORT_NO_SYMBOLS;
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Generic 8250/16x50 PCI serial probe module");
+MODULE_GENERIC_TABLE(pci, serial_pci_tbl);
diff -urN linux-2.4.26/drivers/serial/8250_pnp.c linux-2.4.26-vrs1/drivers/serial/8250_pnp.c
--- linux-2.4.26/drivers/serial/8250_pnp.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/8250_pnp.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,553 @@
+/*
+ * linux/drivers/char/serial_8250_pnp.c
+ *
+ * Probe module for 8250/16550-type ISAPNP serial ports.
+ *
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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.
+ *
+ * $Id: 8250_pnp.c,v 1.3.2.1 2002/10/24 09:53:25 rmk Exp $
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/isapnp.h>
+#include <linux/string.h>
+#include <linux/kernel.h>
+#include <linux/serial.h>
+#include <linux/serialP.h>
+
+#include <asm/bitops.h>
+#include <asm/byteorder.h>
+#include <asm/serial.h>
+
+#include "8250.h"
+
+static struct serial_state rs_table[] = { };
+#define NR_PORTS 0
+
+struct pnpbios_device_id
+{
+ char id[8];
+ unsigned long driver_data;
+};
+
+static const struct pnpbios_device_id pnp_dev_table[] = {
+ /* Archtek America Corp. */
+ /* Archtek SmartLink Modem 3334BT Plug & Play */
+ { "AAC000F", 0 },
+ /* Anchor Datacomm BV */
+ /* SXPro 144 External Data Fax Modem Plug & Play */
+ { "ADC0001", 0 },
+ /* SXPro 288 External Data Fax Modem Plug & Play */
+ { "ADC0002", 0 },
+ /* Rockwell 56K ACF II Fax+Data+Voice Modem */
+ { "AKY1021", SPCI_FL_NO_SHIRQ },
+ /* AZT3005 PnP SOUND DEVICE */
+ { "AZT4001", 0 },
+ /* Best Data Products Inc. Smart One 336F PnP Modem */
+ { "BDP3336", 0 },
+ /* Boca Research */
+ /* Boca Complete Ofc Communicator 14.4 Data-FAX */
+ { "BRI0A49", 0 },
+ /* Boca Research 33,600 ACF Modem */
+ { "BRI1400", 0 },
+ /* Boca 33.6 Kbps Internal FD34FSVD */
+ { "BRI3400", 0 },
+ /* Boca 33.6 Kbps Internal FD34FSVD */
+ { "BRI0A49", 0 },
+ /* Best Data Products Inc. Smart One 336F PnP Modem */
+ { "BDP3336", 0 },
+ /* Computer Peripherals Inc */
+ /* EuroViVa CommCenter-33.6 SP PnP */
+ { "CPI4050", 0 },
+ /* Creative Labs */
+ /* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
+ { "CTL3001", 0 },
+ /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
+ { "CTL3011", 0 },
+ /* Creative */
+ /* Creative Modem Blaster Flash56 DI5601-1 */
+ { "DMB1032", 0 },
+ /* Creative Modem Blaster V.90 DI5660 */
+ { "DMB2001", 0 },
+ /* FUJITSU */
+ /* Fujitsu 33600 PnP-I2 R Plug & Play */
+ { "FUJ0202", 0 },
+ /* Fujitsu FMV-FX431 Plug & Play */
+ { "FUJ0205", 0 },
+ /* Fujitsu 33600 PnP-I4 R Plug & Play */
+ { "FUJ0206", 0 },
+ /* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
+ { "FUJ0209", 0 },
+ /* Archtek America Corp. */
+ /* Archtek SmartLink Modem 3334BT Plug & Play */
+ { "GVC000F", 0 },
+ /* Hayes */
+ /* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
+ { "HAY0001", 0 },
+ /* Hayes Optima 336 V.34 + FAX + Voice PnP */
+ { "HAY000C", 0 },
+ /* Hayes Optima 336B V.34 + FAX + Voice PnP */
+ { "HAY000D", 0 },
+ /* Hayes Accura 56K Ext Fax Modem PnP */
+ { "HAY5670", 0 },
+ /* Hayes Accura 56K Ext Fax Modem PnP */
+ { "HAY5674", 0 },
+ /* Hayes Accura 56K Fax Modem PnP */
+ { "HAY5675", 0 },
+ /* Hayes 288, V.34 + FAX */
+ { "HAYF000", 0 },
+ /* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
+ { "HAYF001", 0 },
+ /* IBM */
+ /* IBM Thinkpad 701 Internal Modem Voice */
+ { "IBM0033", 0 },
+ /* Intertex */
+ /* Intertex 28k8 33k6 Voice EXT PnP */
+ { "IXDC801", 0 },
+ /* Intertex 33k6 56k Voice EXT PnP */
+ { "IXDC901", 0 },
+ /* Intertex 28k8 33k6 Voice SP EXT PnP */
+ { "IXDD801", 0 },
+ /* Intertex 33k6 56k Voice SP EXT PnP */
+ { "IXDD901", 0 },
+ /* Intertex 28k8 33k6 Voice SP INT PnP */
+ { "IXDF401", 0 },
+ /* Intertex 28k8 33k6 Voice SP EXT PnP */
+ { "IXDF801", 0 },
+ /* Intertex 33k6 56k Voice SP EXT PnP */
+ { "IXDF901", 0 },
+ /* Kortex International */
+ /* KORTEX 28800 Externe PnP */
+ { "KOR4522", 0 },
+ /* KXPro 33.6 Vocal ASVD PnP */
+ { "KORF661", 0 },
+ /* Lasat */
+ /* LASAT Internet 33600 PnP */
+ { "LAS4040", 0 },
+ /* Lasat Safire 560 PnP */
+ { "LAS4540", 0 },
+ /* Lasat Safire 336 PnP */
+ { "LAS5440", 0 },
+ /* Microcom, Inc. */
+ /* Microcom TravelPorte FAST V.34 Plug & Play */
+ { "MNP0281", 0 },
+ /* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
+ { "MNP0336", 0 },
+ /* Microcom DeskPorte FAST EP 28.8 Plug & Play */
+ { "MNP0339", 0 },
+ /* Microcom DeskPorte 28.8P Plug & Play */
+ { "MNP0342", 0 },
+ /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
+ { "MNP0500", 0 },
+ /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
+ { "MNP0501", 0 },
+ /* Microcom DeskPorte 28.8S Internal Plug & Play */
+ { "MNP0502", 0 },
+ /* Motorola */
+ /* Motorola BitSURFR Plug & Play */
+ { "MOT1105", 0 },
+ /* Motorola TA210 Plug & Play */
+ { "MOT1111", 0 },
+ /* Motorola HMTA 200 (ISDN) Plug & Play */
+ { "MOT1114", 0 },
+ /* Motorola BitSURFR Plug & Play */
+ { "MOT1115", 0 },
+ /* Motorola Lifestyle 28.8 Internal */
+ { "MOT1190", 0 },
+ /* Motorola V.3400 Plug & Play */
+ { "MOT1501", 0 },
+ /* Motorola Lifestyle 28.8 V.34 Plug & Play */
+ { "MOT1502", 0 },
+ /* Motorola Power 28.8 V.34 Plug & Play */
+ { "MOT1505", 0 },
+ /* Motorola ModemSURFR External 28.8 Plug & Play */
+ { "MOT1509", 0 },
+ /* Motorola Premier 33.6 Desktop Plug & Play */
+ { "MOT150A", 0 },
+ /* Motorola VoiceSURFR 56K External PnP */
+ { "MOT150F", 0 },
+ /* Motorola ModemSURFR 56K External PnP */
+ { "MOT1510", 0 },
+ /* Motorola ModemSURFR 56K Internal PnP */
+ { "MOT1550", 0 },
+ /* Motorola ModemSURFR Internal 28.8 Plug & Play */
+ { "MOT1560", 0 },
+ /* Motorola Premier 33.6 Internal Plug & Play */
+ { "MOT1580", 0 },
+ /* Motorola OnlineSURFR 28.8 Internal Plug & Play */
+ { "MOT15B0", 0 },
+ /* Motorola VoiceSURFR 56K Internal PnP */
+ { "MOT15F0", 0 },
+ /* Com 1 */
+ /* Deskline K56 Phone System PnP */
+ { "MVX00A1", 0 },
+ /* PC Rider K56 Phone System PnP */
+ { "MVX00F2", 0 },
+ /* Pace 56 Voice Internal Plug & Play Modem */
+ { "PMC2430", 0 },
+ /* Generic */
+ /* Generic standard PC COM port */
+ { "PNP0500", 0 },
+ /* Generic 16550A-compatible COM port */
+ { "PNP0501", 0 },
+ /* Compaq 14400 Modem */
+ { "PNPC000", 0 },
+ /* Compaq 2400/9600 Modem */
+ { "PNPC001", 0 },
+ /* Dial-Up Networking Serial Cable between 2 PCs */
+ { "PNPC031", 0 },
+ /* Dial-Up Networking Parallel Cable between 2 PCs */
+ { "PNPC032", 0 },
+ /* Standard 9600 bps Modem */
+ { "PNPC100", 0 },
+ /* Standard 14400 bps Modem */
+ { "PNPC101", 0 },
+ /* Standard 28800 bps Modem*/
+ { "PNPC102", 0 },
+ /* Standard Modem*/
+ { "PNPC103", 0 },
+ /* Standard 9600 bps Modem*/
+ { "PNPC104", 0 },
+ /* Standard 14400 bps Modem*/
+ { "PNPC105", 0 },
+ /* Standard 28800 bps Modem*/
+ { "PNPC106", 0 },
+ /* Standard Modem */
+ { "PNPC107", 0 },
+ /* Standard 9600 bps Modem */
+ { "PNPC108", 0 },
+ /* Standard 14400 bps Modem */
+ { "PNPC109", 0 },
+ /* Standard 28800 bps Modem */
+ { "PNPC10A", 0 },
+ /* Standard Modem */
+ { "PNPC10B", 0 },
+ /* Standard 9600 bps Modem */
+ { "PNPC10C", 0 },
+ /* Standard 14400 bps Modem */
+ { "PNPC10D", 0 },
+ /* Standard 28800 bps Modem */
+ { "PNPC10E", 0 },
+ /* Standard Modem */
+ { "PNPC10F", 0 },
+ /* Standard PCMCIA Card Modem */
+ { "PNP2000", 0 },
+ /* Rockwell */
+ /* Modular Technology */
+ /* Rockwell 33.6 DPF Internal PnP */
+ /* Modular Technology 33.6 Internal PnP */
+ { "ROK0030", 0 },
+ /* Kortex International */
+ /* KORTEX 14400 Externe PnP */
+ { "ROK0100", 0 },
+ /* Viking Components, Inc */
+ /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
+ { "ROK4920", 0 },
+ /* Rockwell */
+ /* British Telecom */
+ /* Modular Technology */
+ /* Rockwell 33.6 DPF External PnP */
+ /* BT Prologue 33.6 External PnP */
+ /* Modular Technology 33.6 External PnP */
+ { "RSS00A0", 0 },
+ /* Viking 56K FAX INT */
+ { "RSS0262", 0 },
+ /* SupraExpress 28.8 Data/Fax PnP modem */
+ { "SUP1310", 0 },
+ /* SupraExpress 33.6 Data/Fax PnP modem */
+ { "SUP1421", 0 },
+ /* SupraExpress 33.6 Data/Fax PnP modem */
+ { "SUP1590", 0 },
+ /* SupraExpress 33.6 Data/Fax PnP modem */
+ { "SUP1760", 0 },
+ /* Phoebe Micro */
+ /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
+ { "TEX0011", 0 },
+ /* Archtek America Corp. */
+ /* Archtek SmartLink Modem 3334BT Plug & Play */
+ { "UAC000F", 0 },
+ /* 3Com Corp. */
+ /* Gateway Telepath IIvi 33.6 */
+ { "USR0000", 0 },
+ /* Sportster Vi 14.4 PnP FAX Voicemail */
+ { "USR0004", 0 },
+ /* U.S. Robotics 33.6K Voice INT PnP */
+ { "USR0006", 0 },
+ /* U.S. Robotics 33.6K Voice EXT PnP */
+ { "USR0007", 0 },
+ /* U.S. Robotics 33.6K Voice INT PnP */
+ { "USR2002", 0 },
+ /* U.S. Robotics 56K Voice INT PnP */
+ { "USR2070", 0 },
+ /* U.S. Robotics 56K Voice EXT PnP */
+ { "USR2080", 0 },
+ /* U.S. Robotics 56K FAX INT */
+ { "USR3031", 0 },
+ /* U.S. Robotics 56K Voice INT PnP */
+ { "USR3070", 0 },
+ /* U.S. Robotics 56K Voice EXT PnP */
+ { "USR3080", 0 },
+ /* U.S. Robotics 56K Voice INT PnP */
+ { "USR3090", 0 },
+ /* U.S. Robotics 56K Message */
+ { "USR9100", 0 },
+ /* U.S. Robotics 56K FAX EXT PnP*/
+ { "USR9160", 0 },
+ /* U.S. Robotics 56K FAX INT PnP*/
+ { "USR9170", 0 },
+ /* U.S. Robotics 56K Voice EXT PnP*/
+ { "USR9180", 0 },
+ /* U.S. Robotics 56K Voice INT PnP*/
+ { "USR9190", 0 },
+ { "", 0 }
+};
+
+static void inline avoid_irq_share(struct pci_dev *dev)
+{
+ int i, map = 0x1FF8;
+ struct serial_state *state = rs_table;
+ struct isapnp_irq *irq;
+ struct isapnp_resources *res = dev->sysdata;
+
+ for (i = 0; i < NR_PORTS; i++) {
+ if (state->type != PORT_UNKNOWN)
+ clear_bit(state->irq, &map);
+ state++;
+ }
+
+ for ( ; res; res = res->alt)
+ for(irq = res->irq; irq; irq = irq->next)
+ irq->map = map;
+}
+
+static char *modem_names[] __devinitdata = {
+ "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
+ "56K", "56k", "K56", "33.6", "28.8", "14.4",
+ "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
+ "33600", "28800", "14400", "V.90", "V.34", "V.32", 0
+};
+
+static int __devinit check_name(char *name)
+{
+ char **tmp;
+
+ for (tmp = modem_names; *tmp; tmp++)
+ if (strstr(name, *tmp))
+ return 1;
+
+ return 0;
+}
+
+static int inline check_compatible_id(struct pci_dev *dev)
+{
+ int i;
+ for (i = 0; i < DEVICE_COUNT_COMPATIBLE; i++)
+ if ((dev->vendor_compatible[i] ==
+ ISAPNP_VENDOR('P', 'N', 'P')) &&
+ (swab16(dev->device_compatible[i]) >= 0xc000) &&
+ (swab16(dev->device_compatible[i]) <= 0xdfff))
+ return 0;
+ return 1;
+}
+
+/*
+ * Given a complete unknown ISA PnP device, try to use some heuristics to
+ * detect modems. Currently use such heuristic set:
+ * - dev->name or dev->bus->name must contain "modem" substring;
+ * - device must have only one IO region (8 byte long) with base adress
+ * 0x2e8, 0x3e8, 0x2f8 or 0x3f8.
+ *
+ * Such detection looks very ugly, but can detect at least some of numerous
+ * ISA PnP modems, alternatively we must hardcode all modems in pnp_devices[]
+ * table.
+ */
+static int serial_pnp_guess_board(struct pci_dev *dev, int *flags)
+{
+ struct isapnp_resources *res = (struct isapnp_resources *)dev->sysdata;
+ struct isapnp_resources *resa;
+
+ if (!(check_name(dev->name) || check_name(dev->bus->name)) &&
+ !(check_compatible_id(dev)))
+ return -ENODEV;
+
+ if (!res || res->next)
+ return -ENODEV;
+
+ for (resa = res->alt; resa; resa = resa->alt) {
+ struct isapnp_port *port;
+ for (port = res->port; port; port = port->next)
+ if ((port->size == 8) &&
+ ((port->min == 0x2f8) ||
+ (port->min == 0x3f8) ||
+ (port->min == 0x2e8) ||
+ (port->min == 0x3e8)))
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
+static int
+pnp_init_one(struct pci_dev *dev, const struct pnpbios_device_id *ent,
+ char *slot_name)
+{
+ struct serial_struct serial_req;
+ int ret, line, flags = ent ? ent->driver_data : 0;
+
+ if (!ent) {
+ ret = serial_pnp_guess_board(dev, &flags);
+ if (ret)
+ return ret;
+ }
+
+ if (dev->prepare(dev) < 0) {
+ printk("serial: PNP device '%s' prepare failed\n",
+ slot_name);
+ return -ENODEV;
+ }
+
+ if (dev->active)
+ return -ENODEV;
+
+ if (flags & SPCI_FL_NO_SHIRQ)
+ avoid_irq_share(dev);
+
+ if (dev->activate(dev) < 0) {
+ printk("serial: PNP device '%s' activate failed\n",
+ slot_name);
+ return -ENODEV;
+ }
+
+ memset(&serial_req, 0, sizeof(serial_req));
+ serial_req.irq = dev->irq_resource[0].start;
+ serial_req.port = pci_resource_start(dev, 0);
+ if (HIGH_BITS_OFFSET)
+ serial_req.port = pci_resource_start(dev, 0) >> HIGH_BITS_OFFSET;
+
+#ifdef SERIAL_DEBUG_PCI
+ printk("Setup PCI/PNP port: port %x, irq %d, type %d\n",
+ serial_req.port, serial_req.irq, serial_req.io_type);
+#endif
+
+ serial_req.flags = ASYNC_SKIP_TEST | ASYNC_AUTOPROBE;
+ serial_req.baud_base = 115200;
+ line = register_serial(&serial_req);
+
+ if (line >= 0) {
+ pci_set_drvdata(dev, (void *)(line + 1));
+
+ /*
+ * Public health warning: remove this once the 2.5
+ * pnpbios_module_init() stuff is incorporated.
+ */
+ dev->driver = (void *)pnp_dev_table;
+ } else
+ dev->deactivate(dev);
+
+ return line >= 0 ? 0 : -ENODEV;
+}
+
+static void pnp_remove_one(struct pci_dev *dev)
+{
+ int line = (int)pci_get_drvdata(dev);
+
+ if (line) {
+ pci_set_drvdata(dev, NULL);
+
+ unregister_serial(line - 1);
+
+ dev->deactivate(dev);
+ }
+}
+
+static char hex[] = "0123456789ABCDEF";
+
+/*
+ * This function should vanish when 2.5 comes around and
+ * we have pnpbios_module_init()
+ */
+static void pnp_init(void)
+{
+ const struct pnpbios_device_id *id;
+ struct pci_dev *dev = NULL;
+
+#ifdef SERIAL_DEBUG_PNP
+ printk("Entered probe_serial_pnp()\n");
+#endif
+
+ isapnp_for_each_dev(dev) {
+ char slot_name[8];
+ u32 pnpid;
+
+ if (dev->active)
+ continue;
+
+ pnpid = dev->vendor << 16 | dev->device;
+ pnpid = cpu_to_le32(pnpid);
+
+#define HEX(id,a) hex[((id)>>a) & 15]
+#define CHAR(id,a) (0x40 + (((id)>>a) & 31))
+ slot_name[0] = CHAR(pnpid, 26);
+ slot_name[1] = CHAR(pnpid, 21);
+ slot_name[2] = CHAR(pnpid, 16);
+ slot_name[3] = HEX(pnpid, 12);
+ slot_name[4] = HEX(pnpid, 8);
+ slot_name[5] = HEX(pnpid, 4);
+ slot_name[6] = HEX(pnpid, 0);
+ slot_name[7] = '\0';
+
+ for (id = pnp_dev_table; id->id[0]; id++)
+ if (memcmp(id->id, slot_name, 7) == 0)
+ break;
+
+ if (id->id[0])
+ pnp_init_one(dev, id, slot_name);
+ else
+ pnp_init_one(dev, NULL, slot_name);
+ }
+
+#ifdef SERIAL_DEBUG_PNP
+ printk("Leaving probe_serial_pnp() (probe finished)\n");
+#endif
+}
+
+static int __init serial8250_pnp_init(void)
+{
+ if (!isapnp_present()) {
+#ifdef SERIAL_DEBUG_PNP
+ printk("Leaving probe_serial_pnp() (no isapnp)\n");
+#endif
+ return -ENODEV;
+ }
+ pnp_init();
+ return 0;
+}
+
+static void __exit serial8250_pnp_exit(void)
+{
+ struct pci_dev *dev = NULL;
+
+ isapnp_for_each_dev(dev) {
+ if (dev->driver != (void *)pnp_dev_table)
+ continue;
+ pnp_remove_one(dev);
+ }
+}
+
+module_init(serial8250_pnp_init);
+module_exit(serial8250_pnp_exit);
+
+EXPORT_NO_SYMBOLS;
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Generic 8250/16x50 PNPBIOS serial probe module");
+MODULE_GENERIC_TABLE(pnp, pnp_dev_table);
+
diff -urN linux-2.4.26/drivers/serial/Config.in linux-2.4.26-vrs1/drivers/serial/Config.in
--- linux-2.4.26/drivers/serial/Config.in 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/Config.in 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,91 @@
+#
+# Serial device configuration
+#
+# $Id: Config.in,v 1.4 2001/10/12 15:46:58 rmk Exp $
+#
+mainmenu_option next_comment
+comment 'Serial drivers'
+
+if [ "$CONFIG_ARM" = "y" ]; then
+ # I don't have this in my tree yet.
+ dep_bool 'Anakin serial port support' CONFIG_SERIAL_ANAKIN $CONFIG_ARCH_ANAKIN
+ dep_bool ' Console on Anakin serial port' CONFIG_SERIAL_ANAKIN_CONSOLE $CONFIG_SERIAL_ANAKIN
+ if [ "$CONFIG_SERIAL_ANAKIN" = "y" ]; then
+ int ' Default Anakin serial baudrate' CONFIG_ANAKIN_DEFAULT_BAUDRATE 9600
+ fi
+
+ dep_tristate 'ARM AMBA serial port support' CONFIG_SERIAL_AMBA $CONFIG_ARCH_INTEGRATOR
+ dep_bool ' Support for console on AMBA serial port' CONFIG_SERIAL_AMBA_CONSOLE $CONFIG_SERIAL_AMBA
+ if [ "$CONFIG_SERIAL_AMBA" = "y" ]; then
+ define_bool CONFIG_SERIAL_INTEGRATOR y
+ fi
+
+ dep_tristate 'CLPS711X serial port support' CONFIG_SERIAL_CLPS711X $CONFIG_ARCH_CLPS711X
+ dep_bool ' Support for console on CLPS711X serial port' CONFIG_SERIAL_CLPS711X_CONSOLE $CONFIG_SERIAL_CLPS711X
+
+ dep_bool 'DC21285 serial port support' CONFIG_SERIAL_21285 $CONFIG_FOOTBRIDGE
+ dep_bool ' Use /dev/ttyS0 device (OBSOLETE)' CONFIG_SERIAL_21285_OLD $CONFIG_SERIAL_21285 $CONFIG_OBSOLETE
+ dep_bool ' Console on DC21285 serial port' CONFIG_SERIAL_21285_CONSOLE $CONFIG_SERIAL_21285
+
+ dep_bool 'Excalibur serial port (uart00) support' CONFIG_SERIAL_UART00 $CONFIG_ARCH_CAMELOT
+ dep_bool ' Support for console on Excalibur serial port' CONFIG_SERIAL_UART00_CONSOLE $CONFIG_SERIAL_UART00
+
+
+ dep_bool 'SA1100 serial port support' CONFIG_SERIAL_SA1100 $CONFIG_ARCH_SA1100
+ dep_bool ' Console on SA1100 serial port' CONFIG_SERIAL_SA1100_CONSOLE $CONFIG_SERIAL_SA1100
+ if [ "$CONFIG_SERIAL_SA1100" = "y" ]; then
+ int ' Default SA1100 serial baudrate' CONFIG_SA1100_DEFAULT_BAUDRATE 9600
+ fi
+
+ dep_tristate 'ARM Omaha serial port support' CONFIG_SERIAL_OMAHA $CONFIG_ARCH_OMAHA
+ dep_bool ' Support for console on Omaha serial port' CONFIG_SERIAL_OMAHA_CONSOLE $CONFIG_SERIAL_OMAHA
+
+ dep_tristate 'AT91RM9200 serial port support' CONFIG_SERIAL_AT91 $CONFIG_ARCH_AT91RM9200
+ dep_bool ' Console on AT91RM9200 serial port' CONFIG_SERIAL_AT91_CONSOLE $CONFIG_SERIAL_AT91
+
+fi
+#
+# The new 8250/16550 serial drivers
+dep_tristate '8250/16550 and compatible serial support (EXPERIMENTAL)' CONFIG_SERIAL_8250 $CONFIG_EXPERIMENTAL
+dep_bool ' Console on 8250/16550 and compatible serial port (EXPERIMENTAL)' CONFIG_SERIAL_8250_CONSOLE $CONFIG_SERIAL_8250 $CONFIG_EXPERIMENTAL
+
+dep_mbool 'Extended 8250/16550 serial driver options' CONFIG_SERIAL_8250_EXTENDED $CONFIG_SERIAL_8250
+dep_bool ' Support more than 4 serial ports' CONFIG_SERIAL_8250_MANY_PORTS $CONFIG_SERIAL_8250_EXTENDED
+dep_bool ' Support for sharing serial interrupts' CONFIG_SERIAL_8250_SHARE_IRQ $CONFIG_SERIAL_8250_EXTENDED
+dep_bool ' Autodetect IRQ on standard ports (unsafe)' CONFIG_SERIAL_8250_DETECT_IRQ $CONFIG_SERIAL_8250_EXTENDED
+dep_bool ' Support special multiport boards' CONFIG_SERIAL_8250_MULTIPORT $CONFIG_SERIAL_8250_EXTENDED
+dep_bool ' Support Bell Technologies HUB6 card' CONFIG_SERIAL_8250_HUB6 $CONFIG_SERIAL_8250_EXTENDED
+
+if [ "$CONFIG_SERIAL_AMBA" = "y" -o \
+ "$CONFIG_SERIAL_CLPS711X" = "y" -o \
+ "$CONFIG_SERIAL_SA1100" = "y" -o \
+ "$CONFIG_SERIAL_ANAKIN" = "y" -o \
+ "$CONFIG_SERIAL_UART00" = "y" -o \
+ "$CONFIG_SERIAL_8250" = "y" -o \
+ "$CONFIG_SERIAL_OMAHA" = "y" -o \
+ "$CONFIG_SERIAL_AT91" = "y" ]; then
+ define_bool CONFIG_SERIAL_CORE y
+else
+ if [ "$CONFIG_SERIAL_AMBA" = "m" -o \
+ "$CONFIG_SERIAL_CLPS711X" = "m" -o \
+ "$CONFIG_SERIAL_SA1100" = "m" -o \
+ "$CONFIG_SERIAL_ANAKIN" = "m" -o \
+ "$CONFIG_SERIAL_UART00" = "m" -o \
+ "$CONFIG_SERIAL_8250" = "m" -o \
+ "$CONFIG_SERIAL_OMAHA" = "m" -o \
+ "$CONFIG_SERIAL_AT91" = "m" ]; then
+ define_bool CONFIG_SERIAL_CORE m
+ fi
+fi
+if [ "$CONFIG_SERIAL_AMBA_CONSOLE" = "y" -o \
+ "$CONFIG_SERIAL_CLPS711X_CONSOLE" = "y" -o \
+ "$CONFIG_SERIAL_SA1100_CONSOLE" = "y" -o \
+ "$CONFIG_SERIAL_ANAKIN_CONSOLE" = "y" -o \
+ "$CONFIG_SERIAL_UART00_CONSOLE" = "y" -o \
+ "$CONFIG_SERIAL_8250_CONSOLE" = "y" -o \
+ "$CONFIG_SERIAL_OMAHA" = "y" -o \
+ "$CONFIG_SERIAL_AT91_CONSOLE" = "y" ]; then
+ define_bool CONFIG_SERIAL_CORE_CONSOLE y
+fi
+
+endmenu
diff -urN linux-2.4.26/drivers/serial/Makefile linux-2.4.26-vrs1/drivers/serial/Makefile
--- linux-2.4.26/drivers/serial/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/Makefile 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,39 @@
+#
+# Makefile for the kernel serial device drivers.
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definitions are now inherited from the
+# parent makes..
+#
+# $Id: Makefile,v 1.2 2001/10/12 15:46:58 rmk Exp $
+#
+
+O_TARGET := serial.o
+
+export-objs := core.o 8250.o
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+serial-8250-y :=
+serial-8250-$(CONFIG_PCI) += 8250_pci.o
+serial-8250-$(CONFIG_ISAPNP) += 8250_pnp.o
+obj-$(CONFIG_SERIAL_CORE) += core.o
+obj-$(CONFIG_SERIAL_21285) += 21285.o
+obj-$(CONFIG_SERIAL_8250) += 8250.o $(serial-8250-y)
+obj-$(CONFIG_SERIAL_ANAKIN) += anakin.o
+obj-$(CONFIG_SERIAL_AMBA) += amba.o
+obj-$(CONFIG_SERIAL_CLPS711X) += clps711x.o
+obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
+obj-$(CONFIG_SERIAL_UART00) += uart00.o
+obj-$(CONFIG_SERIAL_OMAHA) += omaha.o
+obj-$(CONFIG_SERIAL_AT91US3) += at91us3.o
+
+include $(TOPDIR)/Rules.make
+
+fastdep:
+
diff -urN linux-2.4.26/drivers/serial/amba.c linux-2.4.26-vrs1/drivers/serial/amba.c
--- linux-2.4.26/drivers/serial/amba.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/amba.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,770 @@
+/*
+ * linux/drivers/char/serial_amba.c
+ *
+ * Driver for AMBA serial ports
+ *
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * Copyright 1999 ARM Limited
+ * Copyright (C) 2000 Deep Blue Solutions Ltd.
+ *
+ * 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: amba.c,v 1.9.2.2 2002/10/24 09:53:25 rmk Exp $
+ *
+ * This is a generic driver for ARM AMBA-type serial ports. They
+ * have a lot of 16550-like features, but are not register compatable.
+ * Note that although they do have CTS, DCD and DSR inputs, they do
+ * not have an RI input, nor do they have DTR or RTS outputs. If
+ * required, these have to be supplied via some other means (eg, GPIO)
+ * and hooked into this driver.
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/tty.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/serial.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+
+#if defined(CONFIG_SERIAL_AMBA_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/serial_core.h>
+
+#include <asm/hardware/serial_amba.h>
+
+#define UART_NR 2
+
+#define SERIAL_AMBA_MAJOR 204
+#define SERIAL_AMBA_MINOR 16
+#define SERIAL_AMBA_NR UART_NR
+
+#define CALLOUT_AMBA_NAME "cuaam"
+#define CALLOUT_AMBA_MAJOR 205
+#define CALLOUT_AMBA_MINOR 16
+#define CALLOUT_AMBA_NR UART_NR
+
+static struct tty_driver normal, callout;
+static struct tty_struct *amba_table[UART_NR];
+static struct termios *amba_termios[UART_NR], *amba_termios_locked[UART_NR];
+#ifdef SUPPORT_SYSRQ
+static struct console amba_console;
+#endif
+
+#define AMBA_ISR_PASS_LIMIT 256
+
+/*
+ * Access macros for the AMBA UARTs
+ */
+#define UART_GET_INT_STATUS(p) readb((p)->membase + AMBA_UARTIIR)
+#define UART_PUT_ICR(p, c) writel((c), (p)->membase + AMBA_UARTICR)
+#define UART_GET_FR(p) readb((p)->membase + AMBA_UARTFR)
+#define UART_GET_CHAR(p) readb((p)->membase + AMBA_UARTDR)
+#define UART_PUT_CHAR(p, c) writel((c), (p)->membase + AMBA_UARTDR)
+#define UART_GET_RSR(p) readb((p)->membase + AMBA_UARTRSR)
+#define UART_GET_CR(p) readb((p)->membase + AMBA_UARTCR)
+#define UART_PUT_CR(p,c) writel((c), (p)->membase + AMBA_UARTCR)
+#define UART_GET_LCRL(p) readb((p)->membase + AMBA_UARTLCR_L)
+#define UART_PUT_LCRL(p,c) writel((c), (p)->membase + AMBA_UARTLCR_L)
+#define UART_GET_LCRM(p) readb((p)->membase + AMBA_UARTLCR_M)
+#define UART_PUT_LCRM(p,c) writel((c), (p)->membase + AMBA_UARTLCR_M)
+#define UART_GET_LCRH(p) readb((p)->membase + AMBA_UARTLCR_H)
+#define UART_PUT_LCRH(p,c) writel((c), (p)->membase + AMBA_UARTLCR_H)
+#define UART_RX_DATA(s) (((s) & AMBA_UARTFR_RXFE) == 0)
+#define UART_TX_READY(s) (((s) & AMBA_UARTFR_TXFF) == 0)
+#define UART_TX_EMPTY(p) ((UART_GET_FR(p) & AMBA_UARTFR_TMSK) == 0)
+
+#define UART_DUMMY_RSR_RX 256
+#define UART_PORT_SIZE 64
+
+/*
+ * On the Integrator platform, the port RTS and DTR are provided by
+ * bits in the following SC_CTRLS register bits:
+ * RTS DTR
+ * UART0 7 6
+ * UART1 5 4
+ */
+#define SC_CTRLC (IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_CTRLC_OFFSET)
+#define SC_CTRLS (IO_ADDRESS(INTEGRATOR_SC_BASE) + INTEGRATOR_SC_CTRLS_OFFSET)
+
+/*
+ * We wrap our port structure around the generic uart_port.
+ */
+struct uart_amba_port {
+ struct uart_port port;
+ unsigned int dtr_mask;
+ unsigned int rts_mask;
+ unsigned int old_status;
+};
+
+static void ambauart_stop_tx(struct uart_port *port, unsigned int tty_stop)
+{
+ unsigned int cr;
+
+ cr = UART_GET_CR(port);
+ cr &= ~AMBA_UARTCR_TIE;
+ UART_PUT_CR(port, cr);
+}
+
+static void ambauart_start_tx(struct uart_port *port, unsigned int tty_start)
+{
+ unsigned int cr;
+
+ cr = UART_GET_CR(port);
+ cr |= AMBA_UARTCR_TIE;
+ UART_PUT_CR(port, cr);
+}
+
+static void ambauart_stop_rx(struct uart_port *port)
+{
+ unsigned int cr;
+
+ cr = UART_GET_CR(port);
+ cr &= ~(AMBA_UARTCR_RIE | AMBA_UARTCR_RTIE);
+ UART_PUT_CR(port, cr);
+}
+
+static void ambauart_enable_ms(struct uart_port *port)
+{
+ unsigned int cr;
+
+ cr = UART_GET_CR(port);
+ cr |= AMBA_UARTCR_MSIE;
+ UART_PUT_CR(port, cr);
+}
+
+static void
+#ifdef SUPPORT_SYSRQ
+ambauart_rx_chars(struct uart_port *port, struct pt_regs *regs)
+#else
+ambauart_rx_chars(struct uart_port *port)
+#endif
+{
+ struct tty_struct *tty = port->info->tty;
+ unsigned int status, ch, rsr, max_count = 256;
+
+ status = UART_GET_FR(port);
+ while (UART_RX_DATA(status) && max_count--) {
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+ tty->flip.tqueue.routine((void *)tty);
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+ printk(KERN_WARNING "TTY_DONT_FLIP set\n");
+ return;
+ }
+ }
+
+ ch = UART_GET_CHAR(port);
+
+ *tty->flip.char_buf_ptr = ch;
+ *tty->flip.flag_buf_ptr = TTY_NORMAL;
+ port->icount.rx++;
+
+ /*
+ * Note that the error handling code is
+ * out of the main execution path
+ */
+ rsr = UART_GET_RSR(port) | UART_DUMMY_RSR_RX;
+ if (rsr & AMBA_UARTRSR_ANY) {
+ if (rsr & AMBA_UARTRSR_BE) {
+ rsr &= ~(AMBA_UARTRSR_FE | AMBA_UARTRSR_PE);
+ port->icount.brk++;
+ if (uart_handle_break(port))
+ goto ignore_char;
+ } else if (rsr & AMBA_UARTRSR_PE)
+ port->icount.parity++;
+ else if (rsr & AMBA_UARTRSR_FE)
+ port->icount.frame++;
+ if (rsr & AMBA_UARTRSR_OE)
+ port->icount.overrun++;
+
+ rsr &= port->read_status_mask;
+
+ if (rsr & AMBA_UARTRSR_BE)
+ *tty->flip.flag_buf_ptr = TTY_BREAK;
+ else if (rsr & AMBA_UARTRSR_PE)
+ *tty->flip.flag_buf_ptr = TTY_PARITY;
+ else if (rsr & AMBA_UARTRSR_FE)
+ *tty->flip.flag_buf_ptr = TTY_FRAME;
+ }
+
+ if (uart_handle_sysrq_char(port, ch, regs))
+ goto ignore_char;
+
+ if ((rsr & port->ignore_status_mask) == 0) {
+ tty->flip.flag_buf_ptr++;
+ tty->flip.char_buf_ptr++;
+ tty->flip.count++;
+ }
+ if ((rsr & AMBA_UARTRSR_OE) &&
+ tty->flip.count < TTY_FLIPBUF_SIZE) {
+ /*
+ * Overrun is special, since it's reported
+ * immediately, and doesn't affect the current
+ * character
+ */
+ *tty->flip.char_buf_ptr++ = 0;
+ *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
+ tty->flip.count++;
+ }
+ ignore_char:
+ status = UART_GET_FR(port);
+ }
+ tty_flip_buffer_push(tty);
+ return;
+}
+
+static void ambauart_tx_chars(struct uart_port *port)
+{
+ struct circ_buf *xmit = &port->info->xmit;
+ int count;
+
+ if (port->x_char) {
+ UART_PUT_CHAR(port, port->x_char);
+ port->icount.tx++;
+ port->x_char = 0;
+ return;
+ }
+ if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
+ ambauart_stop_tx(port, 0);
+ return;
+ }
+
+ count = port->fifosize >> 1;
+ do {
+ 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))
+ ambauart_stop_tx(port, 0);
+}
+
+static void ambauart_modem_status(struct uart_port *port)
+{
+ struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ unsigned int status, delta;
+
+ UART_PUT_ICR(&uap->port, 0);
+
+ status = UART_GET_FR(&uap->port) & AMBA_UARTFR_MODEM_ANY;
+
+ delta = status ^ uap->old_status;
+ uap->old_status = status;
+
+ if (!delta)
+ return;
+
+ if (delta & AMBA_UARTFR_DCD)
+ uart_handle_dcd_change(&uap->port, status & AMBA_UARTFR_DCD);
+
+ if (delta & AMBA_UARTFR_DSR)
+ uap->port.icount.dsr++;
+
+ if (delta & AMBA_UARTFR_CTS)
+ uart_handle_cts_change(&uap->port, status & AMBA_UARTFR_CTS);
+
+ wake_up_interruptible(&uap->port.info->delta_msr_wait);
+}
+
+static void ambauart_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct uart_port *port = dev_id;
+ unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT;
+
+ status = UART_GET_INT_STATUS(port);
+ do {
+ if (status & (AMBA_UARTIIR_RTIS | AMBA_UARTIIR_RIS))
+#ifdef SUPPORT_SYSRQ
+ ambauart_rx_chars(port, regs);
+#else
+ ambauart_rx_chars(port);
+#endif
+ if (status & AMBA_UARTIIR_TIS)
+ ambauart_tx_chars(port);
+ if (status & AMBA_UARTIIR_MIS)
+ ambauart_modem_status(port);
+
+ if (pass_counter-- == 0)
+ break;
+
+ status = UART_GET_INT_STATUS(port);
+ } while (status & (AMBA_UARTIIR_RTIS | AMBA_UARTIIR_RIS |
+ AMBA_UARTIIR_TIS));
+}
+
+static unsigned int ambauart_tx_empty(struct uart_port *port)
+{
+ return UART_GET_FR(port) & AMBA_UARTFR_BUSY ? 0 : TIOCSER_TEMT;
+}
+
+static unsigned int ambauart_get_mctrl(struct uart_port *port)
+{
+ unsigned int result = 0;
+ unsigned int status;
+
+ status = UART_GET_FR(port);
+ if (status & AMBA_UARTFR_DCD)
+ result |= TIOCM_CAR;
+ if (status & AMBA_UARTFR_DSR)
+ result |= TIOCM_DSR;
+ if (status & AMBA_UARTFR_CTS)
+ result |= TIOCM_CTS;
+
+ return result;
+}
+
+static void ambauart_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+ struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ unsigned int ctrls = 0, ctrlc = 0;
+
+ if (mctrl & TIOCM_RTS)
+ ctrlc |= uap->rts_mask;
+ else
+ ctrls |= uap->rts_mask;
+
+ if (mctrl & TIOCM_DTR)
+ ctrlc |= uap->dtr_mask;
+ else
+ ctrls |= uap->dtr_mask;
+
+ __raw_writel(ctrls, SC_CTRLS);
+ __raw_writel(ctrlc, SC_CTRLC);
+}
+
+static void ambauart_break_ctl(struct uart_port *port, int break_state)
+{
+ unsigned long flags;
+ unsigned int lcr_h;
+
+ spin_lock_irqsave(&port->lock, flags);
+ lcr_h = UART_GET_LCRH(port);
+ if (break_state == -1)
+ lcr_h |= AMBA_UARTLCR_H_BRK;
+ else
+ lcr_h &= ~AMBA_UARTLCR_H_BRK;
+ UART_PUT_LCRH(port, lcr_h);
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static int ambauart_startup(struct uart_port *port)
+{
+ struct uart_amba_port *uap = (struct uart_amba_port *)port;
+ int retval;
+
+ /*
+ * Allocate the IRQ
+ */
+ retval = request_irq(port->irq, ambauart_int, 0, "amba", port);
+ if (retval)
+ return retval;
+
+ /*
+ * initialise the old status of the modem signals
+ */
+ uap->old_status = UART_GET_FR(port) & AMBA_UARTFR_MODEM_ANY;
+
+ /*
+ * Finally, enable interrupts
+ */
+ UART_PUT_CR(port, AMBA_UARTCR_UARTEN | AMBA_UARTCR_RIE |
+ AMBA_UARTCR_RTIE);
+
+ return 0;
+}
+
+static void ambauart_shutdown(struct uart_port *port)
+{
+ /*
+ * Free the interrupt
+ */
+ free_irq(port->irq, port);
+
+ /*
+ * disable all interrupts, disable the port
+ */
+ UART_PUT_CR(port, 0);
+
+ /* disable break condition and fifos */
+ UART_PUT_LCRH(port, UART_GET_LCRH(port) &
+ ~(AMBA_UARTLCR_H_BRK | AMBA_UARTLCR_H_FEN));
+}
+
+static void ambauart_change_speed(struct uart_port *port, unsigned int cflag, unsigned int iflag, unsigned int quot)
+{
+ unsigned int lcr_h, old_cr;
+ unsigned long flags;
+
+#if DEBUG
+ printk("ambauart_set_cflag(0x%x) called\n", cflag);
+#endif
+ /* byte size and parity */
+ switch (cflag & CSIZE) {
+ case CS5:
+ lcr_h = AMBA_UARTLCR_H_WLEN_5;
+ break;
+ case CS6:
+ lcr_h = AMBA_UARTLCR_H_WLEN_6;
+ break;
+ case CS7:
+ lcr_h = AMBA_UARTLCR_H_WLEN_7;
+ break;
+ default: // CS8
+ lcr_h = AMBA_UARTLCR_H_WLEN_8;
+ break;
+ }
+ if (cflag & CSTOPB)
+ lcr_h |= AMBA_UARTLCR_H_STP2;
+ if (cflag & PARENB) {
+ lcr_h |= AMBA_UARTLCR_H_PEN;
+ if (!(cflag & PARODD))
+ lcr_h |= AMBA_UARTLCR_H_EPS;
+ }
+ if (port->fifosize > 1)
+ lcr_h |= AMBA_UARTLCR_H_FEN;
+
+ spin_lock_irqsave(&port->lock, flags);
+
+ port->read_status_mask = AMBA_UARTRSR_OE;
+ if (iflag & INPCK)
+ port->read_status_mask |= AMBA_UARTRSR_FE | AMBA_UARTRSR_PE;
+ if (iflag & (BRKINT | PARMRK))
+ port->read_status_mask |= AMBA_UARTRSR_BE;
+
+ /*
+ * Characters to ignore
+ */
+ port->ignore_status_mask = 0;
+ if (iflag & IGNPAR)
+ port->ignore_status_mask |= AMBA_UARTRSR_FE | AMBA_UARTRSR_PE;
+ if (iflag & IGNBRK) {
+ port->ignore_status_mask |= AMBA_UARTRSR_BE;
+ /*
+ * If we're ignoring parity and break indicators,
+ * ignore overruns too (for real raw support).
+ */
+ if (iflag & IGNPAR)
+ port->ignore_status_mask |= AMBA_UARTRSR_OE;
+ }
+
+ /*
+ * Ignore all characters if CREAD is not set.
+ */
+ if ((cflag & CREAD) == 0)
+ port->ignore_status_mask |= UART_DUMMY_RSR_RX;
+
+ old_cr = UART_GET_CR(port) & ~AMBA_UARTCR_MSIE;
+
+ if (UART_ENABLE_MS(port, cflag))
+ old_cr |= AMBA_UARTCR_MSIE;
+
+ UART_PUT_CR(port, 0);
+
+ /* Set baud rate */
+ quot -= 1;
+ UART_PUT_LCRM(port, ((quot & 0xf00) >> 8));
+ UART_PUT_LCRL(port, (quot & 0xff));
+
+ /*
+ * ----------v----------v----------v----------v-----
+ * NOTE: MUST BE WRITTEN AFTER UARTLCR_M & UARTLCR_L
+ * ----------^----------^----------^----------^-----
+ */
+ UART_PUT_LCRH(port, lcr_h);
+ UART_PUT_CR(port, old_cr);
+
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static const char *ambauart_type(struct uart_port *port)
+{
+ return port->type == PORT_AMBA ? "AMBA" : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'
+ */
+static void ambauart_release_port(struct uart_port *port)
+{
+ release_mem_region(port->mapbase, UART_PORT_SIZE);
+}
+
+/*
+ * Request the memory region(s) being used by 'port'
+ */
+static int ambauart_request_port(struct uart_port *port)
+{
+ return request_mem_region(port->mapbase, UART_PORT_SIZE, "serial_amba")
+ != NULL ? 0 : -EBUSY;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void ambauart_config_port(struct uart_port *port, int flags)
+{
+ if (flags & UART_CONFIG_TYPE) {
+ port->type = PORT_AMBA;
+ ambauart_request_port(port);
+ }
+}
+
+/*
+ * verify the new serial_struct (for TIOCSSERIAL).
+ */
+static int ambauart_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+ int ret = 0;
+ if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
+ 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 amba_pops = {
+ .tx_empty = ambauart_tx_empty,
+ .set_mctrl = ambauart_set_mctrl,
+ .get_mctrl = ambauart_get_mctrl,
+ .stop_tx = ambauart_stop_tx,
+ .start_tx = ambauart_start_tx,
+ .stop_rx = ambauart_stop_rx,
+ .enable_ms = ambauart_enable_ms,
+ .break_ctl = ambauart_break_ctl,
+ .startup = ambauart_startup,
+ .shutdown = ambauart_shutdown,
+ .change_speed = ambauart_change_speed,
+ .type = ambauart_type,
+ .release_port = ambauart_release_port,
+ .request_port = ambauart_request_port,
+ .config_port = ambauart_config_port,
+ .verify_port = ambauart_verify_port,
+};
+
+static struct uart_amba_port amba_ports[UART_NR] = {
+ {
+ .port = {
+ .membase = (void *)IO_ADDRESS(INTEGRATOR_UART0_BASE),
+ .mapbase = INTEGRATOR_UART0_BASE,
+ .iotype = SERIAL_IO_MEM,
+ .irq = IRQ_UARTINT0,
+ .uartclk = 14745600,
+ .fifosize = 16,
+ .ops = &amba_pops,
+ .flags = ASYNC_BOOT_AUTOCONF,
+ .line = 0,
+ },
+ .dtr_mask = 1 << 5,
+ .rts_mask = 1 << 4,
+ },
+ {
+ .port = {
+ .membase = (void *)IO_ADDRESS(INTEGRATOR_UART1_BASE),
+ .mapbase = INTEGRATOR_UART1_BASE,
+ .iotype = SERIAL_IO_MEM,
+ .irq = IRQ_UARTINT1,
+ .uartclk = 14745600,
+ .fifosize = 16,
+ .ops = &amba_pops,
+ .flags = ASYNC_BOOT_AUTOCONF,
+ .line = 1,
+ },
+ .dtr_mask = 1 << 7,
+ .rts_mask = 1 << 6,
+ }
+};
+
+#ifdef CONFIG_SERIAL_AMBA_CONSOLE
+
+static void ambauart_console_write(struct console *co, const char *s, unsigned int count)
+{
+ struct uart_port *port = &amba_ports[co->index].port;
+ unsigned int status, old_cr;
+ int i;
+
+ /*
+ * First save the CR then disable the interrupts
+ */
+ old_cr = UART_GET_CR(port);
+ UART_PUT_CR(port, AMBA_UARTCR_UARTEN);
+
+ /*
+ * Now, do each character
+ */
+ for (i = 0; i < count; i++) {
+ do {
+ status = UART_GET_FR(port);
+ } while (!UART_TX_READY(status));
+ UART_PUT_CHAR(port, s[i]);
+ if (s[i] == '\n') {
+ do {
+ status = UART_GET_FR(port);
+ } while (!UART_TX_READY(status));
+ UART_PUT_CHAR(port, '\r');
+ }
+ }
+
+ /*
+ * Finally, wait for transmitter to become empty
+ * and restore the TCR
+ */
+ do {
+ status = UART_GET_FR(port);
+ } while (status & AMBA_UARTFR_BUSY);
+ UART_PUT_CR(port, old_cr);
+}
+
+static kdev_t ambauart_console_device(struct console *co)
+{
+ return MKDEV(SERIAL_AMBA_MAJOR, SERIAL_AMBA_MINOR + co->index);
+}
+
+static void __init
+ambauart_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
+{
+ if (UART_GET_CR(port) & AMBA_UARTCR_UARTEN) {
+ unsigned int lcr_h, quot;
+ lcr_h = UART_GET_LCRH(port);
+
+ *parity = 'n';
+ if (lcr_h & AMBA_UARTLCR_H_PEN) {
+ if (lcr_h & AMBA_UARTLCR_H_EPS)
+ *parity = 'e';
+ else
+ *parity = 'o';
+ }
+
+ if ((lcr_h & 0x60) == AMBA_UARTLCR_H_WLEN_7)
+ *bits = 7;
+ else
+ *bits = 8;
+
+ quot = UART_GET_LCRL(port) | UART_GET_LCRM(port) << 8;
+ *baud = port->uartclk / (16 * (quot + 1));
+ }
+}
+
+static int __init ambauart_console_setup(struct console *co, char *options)
+{
+ struct uart_port *port;
+ int baud = 38400;
+ int bits = 8;
+ int parity = 'n';
+ int flow = 'n';
+
+ /*
+ * Check whether an invalid uart number has been specified, and
+ * if so, search for the first available port that does have
+ * console support.
+ */
+ if (co->index >= UART_NR)
+ co->index = 0;
+ port = &amba_ports[co->index].port;
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+ else
+ ambauart_console_get_options(port, &baud, &parity, &bits);
+
+ return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct console amba_console = {
+ .name = "ttyAM",
+ .write = ambauart_console_write,
+ .device = ambauart_console_device,
+ .setup = ambauart_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = -1,
+};
+
+void __init ambauart_console_init(void)
+{
+ register_console(&amba_console);
+}
+
+#define AMBA_CONSOLE &amba_console
+#else
+#define AMBA_CONSOLE NULL
+#endif
+
+static struct uart_driver amba_reg = {
+ .owner = THIS_MODULE,
+ .normal_major = SERIAL_AMBA_MAJOR,
+#ifdef CONFIG_DEVFS_FS
+ .normal_name = "ttyAM%d",
+ .callout_name = "cuaam%d",
+#else
+ .normal_name = "ttyAM",
+ .callout_name = "cuaam",
+#endif
+ .normal_driver = &normal,
+ .callout_major = CALLOUT_AMBA_MAJOR,
+ .callout_driver = &callout,
+ .table = amba_table,
+ .termios = amba_termios,
+ .termios_locked = amba_termios_locked,
+ .minor = SERIAL_AMBA_MINOR,
+ .nr = UART_NR,
+ .cons = AMBA_CONSOLE,
+};
+
+static int __init ambauart_init(void)
+{
+ int ret;
+
+ ret = uart_register_driver(&amba_reg);
+ if (ret == 0) {
+ int i;
+
+ for (i = 0; i < UART_NR; i++)
+ uart_add_one_port(&amba_reg, &amba_ports[i].port);
+ }
+ return ret;
+}
+
+static void __exit ambauart_exit(void)
+{
+ int i;
+
+ for (i = 0; i < UART_NR; i++)
+ uart_remove_one_port(&amba_reg, &amba_ports[i].port);
+
+ uart_unregister_driver(&amba_reg);
+}
+
+module_init(ambauart_init);
+module_exit(ambauart_exit);
+
+EXPORT_NO_SYMBOLS;
+
+MODULE_AUTHOR("ARM Ltd/Deep Blue Solutions Ltd");
+MODULE_DESCRIPTION("ARM AMBA serial port driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/serial/anakin.c linux-2.4.26-vrs1/drivers/serial/anakin.c
--- linux-2.4.26/drivers/serial/anakin.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/anakin.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,545 @@
+/*
+ * linux/drivers/char/serial_anakin.c
+ *
+ * Based on driver for AMBA serial ports, by ARM Limited,
+ * Deep Blue Solutions Ltd., Linus Torvalds and Theodore Ts'o.
+ *
+ * Copyright (C) 2001 Aleph One Ltd. for Acunia N.V.
+ *
+ * Copyright (C) 2001 Blue Mug, Inc. for Acunia N.V.
+ *
+ * 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.
+ *
+ * Changelog:
+ * 20-Apr-2001 TTC Created
+ * 05-May-2001 W/TTC Updated for serial_core.c
+ * 27-Jun-2001 jonm Minor changes; add mctrl support, switch to
+ * SA_INTERRUPT. Works reliably now. No longer requires
+ * changes to the serial_core API.
+ *
+ * $Id: anakin.c,v 1.5.2.2 2002/10/24 09:53:25 rmk Exp $
+ */
+
+#include <linux/config.h>
+#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 <linux/serial_core.h>
+
+#include <asm/arch/serial_reg.h>
+
+#define UART_NR 5
+
+#define SERIAL_ANAKIN_NAME "ttyAN"
+#define SERIAL_ANAKIN_MAJOR 204
+#define SERIAL_ANAKIN_MINOR 32
+
+#define CALLOUT_ANAKIN_NAME "cuaan"
+#define CALLOUT_ANAKIN_MAJOR 205
+#define CALLOUT_ANAKIN_MINOR 32
+
+static struct tty_driver normal, callout;
+static struct tty_struct *anakin_table[UART_NR];
+static struct termios *anakin_termios[UART_NR], *anakin_termios_locked[UART_NR];
+static struct uart_state anakin_state[UART_NR];
+static u_int txenable[NR_IRQS]; /* Software interrupt register */
+
+static inline unsigned int
+anakin_in(struct uart_port *port, u_int offset)
+{
+ return __raw_readl(port->base + offset);
+}
+
+static inline void
+anakin_out(struct uart_port *port, u_int offset, unsigned int value)
+{
+ __raw_writel(value, port->base + offset);
+}
+
+static void
+anakin_stop_tx(struct uart_port *port, u_int from_tty)
+{
+ txenable[port->irq] = 0;
+}
+
+static inline void
+anakin_transmit_buffer(struct uart_info *info)
+{
+ struct uart_port *port = info->port;
+
+ while (!(anakin_in(port, 0x10) & TXEMPTY));
+ anakin_out(port, 0x14, info->xmit.buf[info->xmit.tail]);
+ anakin_out(port, 0x18, anakin_in(port, 0x18) | SENDREQUEST);
+ info->xmit.tail = (info->xmit.tail + 1) & (UART_XMIT_SIZE-1);
+ info->state->icount.tx++;
+
+ if (info->xmit.head == info->xmit.tail)
+ anakin_stop_tx(port, 0);
+}
+
+static inline void
+anakin_transmit_x_char(struct uart_info *info)
+{
+ struct uart_port *port = info->port;
+
+ anakin_out(port, 0x14, info->x_char);
+ anakin_out(port, 0x18, anakin_in(port, 0x18) | SENDREQUEST);
+ info->state->icount.tx++;
+ info->x_char = 0;
+}
+
+static void
+anakin_start_tx(struct uart_port *port, u_int nonempty, u_int from_tty)
+{
+ unsigned int flags;
+
+ save_flags_cli(flags);
+
+ // is it this... or below: if (nonempty
+ if (!txenable[port->irq]) {
+ txenable[port->irq] = TXENABLE;
+
+ if ((anakin_in(port, 0x10) & TXEMPTY) && nonempty) {
+ anakin_transmit_buffer((struct uart_info*)port->unused);
+ }
+ }
+
+ restore_flags(flags);
+}
+
+static void
+anakin_stop_rx(struct uart_port *port)
+{
+ unsigned long flags;
+
+ save_flags_cli(flags);
+ while (anakin_in(port, 0x10) & RXRELEASE)
+ anakin_in(port, 0x14);
+ anakin_out(port, 0x18, anakin_in(port, 0x18) | BLOCKRX);
+ restore_flags(flags);
+}
+
+static void
+anakin_enable_ms(struct uart_port *port)
+{
+}
+
+static inline void
+anakin_rx_chars(struct uart_info *info)
+{
+ unsigned int ch;
+ struct tty_struct *tty = info->tty;
+
+ if (!(anakin_in(info->port, 0x10) & RXRELEASE))
+ return;
+
+ ch = anakin_in(info->port, 0x14) & 0xff;
+
+ if (tty->flip.count < TTY_FLIPBUF_SIZE) {
+ *tty->flip.char_buf_ptr++ = ch;
+ *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
+ info->state->icount.rx++;
+ tty->flip.count++;
+ }
+ tty_flip_buffer_push(tty);
+}
+
+static inline void
+anakin_overrun_chars(struct uart_info *info)
+{
+ unsigned int ch;
+
+ ch = anakin_in(info->port, 0x14);
+ info->state->icount.overrun++;
+}
+
+static inline void
+anakin_tx_chars(struct uart_info *info)
+{
+ if (info->x_char) {
+ anakin_transmit_x_char(info);
+ return;
+ }
+
+ if (info->xmit.head == info->xmit.tail
+ || info->tty->stopped
+ || info->tty->hw_stopped) {
+ anakin_stop_tx(info->port, 0);
+ return;
+ }
+
+ anakin_transmit_buffer(info);
+
+ if (CIRC_CNT(info->xmit.head,
+ info->xmit.tail,
+ UART_XMIT_SIZE) < WAKEUP_CHARS)
+ uart_event(info, EVT_WRITE_WAKEUP);
+}
+
+static void
+anakin_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned int status;
+ struct uart_info *info = dev_id;
+
+ status = anakin_in(info->port, 0x1c);
+
+ if (status & RX)
+ anakin_rx_chars(info);
+
+ if (status & OVERRUN)
+ anakin_overrun_chars(info);
+
+ if (txenable[info->port->irq] && (status & TX))
+ anakin_tx_chars(info);
+}
+
+static u_int
+anakin_tx_empty(struct uart_port *port)
+{
+ return anakin_in(port, 0x10) & TXEMPTY ? TIOCSER_TEMT : 0;
+}
+
+static u_int
+anakin_get_mctrl(struct uart_port *port)
+{
+ unsigned int status = 0;
+
+ status |= (anakin_in(port, 0x10) & CTS ? TIOCM_CTS : 0);
+ status |= (anakin_in(port, 0x18) & DCD ? TIOCM_CAR : 0);
+ status |= (anakin_in(port, 0x18) & DTR ? TIOCM_DTR : 0);
+ status |= (anakin_in(port, 0x18) & RTS ? TIOCM_RTS : 0);
+
+ return status;
+}
+
+static void
+anakin_set_mctrl(struct uart_port *port, u_int mctrl)
+{
+ unsigned int status;
+
+ status = anakin_in(port, 0x18);
+
+ if (mctrl & TIOCM_RTS)
+ status |= RTS;
+ else
+ status &= ~RTS;
+
+ if (mctrl & TIOCM_CAR)
+ status |= DCD;
+ else
+ status &= ~DCD;
+
+ anakin_out(port, 0x18, status);
+}
+
+static void
+anakin_break_ctl(struct uart_port *port, int break_state)
+{
+ unsigned int status;
+
+ status = anakin_in(port, 0x20);
+
+ if (break_state == -1)
+ status |= SETBREAK;
+ else
+ status &= ~SETBREAK;
+
+ anakin_out(port, 0x20, status);
+}
+
+static int
+anakin_startup(struct uart_port *port, struct uart_info *info)
+{
+ int retval;
+ unsigned int read,write;
+
+ /*
+ * Allocate the IRQ
+ */
+ retval = request_irq(port->irq, anakin_int, SA_INTERRUPT, "serial_anakin", info);
+ if (retval)
+ return retval;
+
+ port->ops->set_mctrl(port, info->mctrl);
+
+ /*
+ * initialise the old status of the modem signals
+ */
+ port->old_status = 0;
+
+ /*
+ * Finally, disable IRQ and softIRQs for first byte)
+ */
+ txenable[port->irq] = 0;
+ read = anakin_in(port, 0x18);
+ write = (read & ~(RTS | DTR | BLOCKRX)) | IRQENABLE;
+ anakin_out(port, 0x18, write);
+
+ /* Store the uart_info pointer so we can reference it in
+ * anakin_start_tx() */
+ port->unused = (u_int)info;
+
+ return 0;
+}
+
+static void
+anakin_shutdown(struct uart_port *port, struct uart_info *info)
+{
+ /*
+ * Free the interrupt
+ */
+ free_irq(port->irq, info);
+
+ /*
+ * disable all interrupts, disable the port
+ */
+ anakin_out(port, 0x18, anakin_in(port, 0x18) & ~IRQENABLE);
+}
+
+static void
+anakin_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
+{
+ unsigned int flags;
+
+ save_flags_cli(flags);
+ while (!(anakin_in(port, 0x10) & TXEMPTY));
+ anakin_out(port, 0x10, (anakin_in(port, 0x10) & ~PRESCALER)
+ | (quot << 3));
+
+ //parity always set to none
+ anakin_out(port, 0x18, anakin_in(port, 0x18) & ~PARITY);
+ restore_flags(flags);
+}
+
+static const char *anakin_type(struct port *port)
+{
+ return port->type == PORT_ANAKIN ? "ANAKIN" : NULL;
+}
+
+static struct uart_ops anakin_pops = {
+ tx_empty: anakin_tx_empty,
+ set_mctrl: anakin_set_mctrl,
+ get_mctrl: anakin_get_mctrl,
+ stop_tx: anakin_stop_tx,
+ start_tx: anakin_start_tx,
+ stop_rx: anakin_stop_rx,
+ enable_ms: anakin_enable_ms,
+ break_ctl: anakin_break_ctl,
+ startup: anakin_startup,
+ shutdown: anakin_shutdown,
+ change_speed: anakin_change_speed,
+ type: anakin_type,
+};
+
+static struct uart_port anakin_ports[UART_NR] = {
+ {
+ base: IO_BASE + UART0,
+ irq: IRQ_UART0,
+ uartclk: 3686400,
+ fifosize: 0,
+ ops: &anakin_pops,
+ },
+ {
+ base: IO_BASE + UART1,
+ irq: IRQ_UART1,
+ uartclk: 3686400,
+ fifosize: 0,
+ ops: &anakin_pops,
+ },
+ {
+ base: IO_BASE + UART2,
+ irq: IRQ_UART2,
+ uartclk: 3686400,
+ fifosize: 0,
+ ops: &anakin_pops,
+ },
+ {
+ base: IO_BASE + UART3,
+ irq: IRQ_UART3,
+ uartclk: 3686400,
+ fifosize: 0,
+ ops: &anakin_pops,
+ },
+ {
+ base: IO_BASE + UART4,
+ irq: IRQ_UART4,
+ uartclk: 3686400,
+ fifosize: 0,
+ ops: &anakin_pops,
+ },
+};
+
+
+#ifdef CONFIG_SERIAL_ANAKIN_CONSOLE
+
+static void
+anakin_console_write(struct console *co, const char *s, u_int count)
+{
+ struct uart_port *port = anakin_ports + co->index;
+ unsigned int flags, status, i;
+
+ /*
+ * First save the status then disable the interrupts
+ */
+ save_flags_cli(flags);
+ status = anakin_in(port, 0x18);
+ anakin_out(port, 0x18, status & ~IRQENABLE);
+ restore_flags(flags);
+
+ /*
+ * Now, do each character
+ */
+ for (i = 0; i < count; i++, s++) {
+ while (!(anakin_in(port, 0x10) & TXEMPTY));
+
+ /*
+ * Send the character out.
+ * If a LF, also do CR...
+ */
+ anakin_out(port, 0x14, *s);
+ anakin_out(port, 0x18, anakin_in(port, 0x18) | SENDREQUEST);
+
+ if (*s == 10) {
+ while (!(anakin_in(port, 0x10) & TXEMPTY));
+ anakin_out(port, 0x14, 13);
+ anakin_out(port, 0x18, anakin_in(port, 0x18)
+ | SENDREQUEST);
+ }
+ }
+
+ /*
+ * Finally, wait for transmitter to become empty
+ * and restore the interrupts
+ */
+ while (!(anakin_in(port, 0x10) & TXEMPTY));
+
+ if (status & IRQENABLE)
+ save_flags_cli(flags);
+ anakin_out(port, 0x18, anakin_in(port, 0x18) | IRQENABLE);
+ restore_flags(flags);
+}
+
+static kdev_t
+anakin_console_device(struct console *co)
+{
+ return MKDEV(SERIAL_ANAKIN_MAJOR, SERIAL_ANAKIN_MINOR + co->index);
+}
+
+/*
+ * Read the current UART setup.
+ */
+static void __init
+anakin_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
+{
+ int paritycode;
+
+ *baud = GETBAUD (anakin_in(port, 0x10) & PRESCALER);
+ paritycode = GETPARITY(anakin_in(port, 0x18) & PARITY);
+ switch (paritycode) {
+ case NONEPARITY: *parity = 'n'; break;
+ case ODDPARITY: *parity = 'o'; break;
+ case EVENPARITY: *parity = 'e'; break;
+ }
+ *bits = 8;
+}
+
+static int __init
+anakin_console_setup(struct console *co, char *options)
+{
+ struct uart_port *port;
+ int baud = CONFIG_ANAKIN_DEFAULT_BAUDRATE;
+ int bits = 8;
+ int parity = 'n';
+
+ /*
+ * 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(anakin_ports, UART_NR, co);
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits);
+ else
+ anakin_console_get_options(port, &baud, &parity, &bits);
+
+ return uart_set_options(port, co, baud, parity, bits);
+}
+
+static struct console anakin_console = {
+ name: SERIAL_ANAKIN_NAME,
+ write: anakin_console_write,
+ device: anakin_console_device,
+ setup: anakin_console_setup,
+ flags: CON_PRINTBUFFER,
+ index: -1,
+};
+
+void __init
+anakin_console_init(void)
+{
+ register_console(&anakin_console);
+}
+
+#define ANAKIN_CONSOLE &anakin_console
+#else
+#define ANAKIN_CONSOLE NULL
+#endif
+
+static struct uart_register anakin_reg = {
+ normal_major: SERIAL_ANAKIN_MAJOR,
+ normal_name: SERIAL_ANAKIN_NAME,
+ normal_driver: &normal,
+ callout_major: CALLOUT_ANAKIN_MAJOR,
+ callout_name: CALLOUT_ANAKIN_NAME,
+ callout_driver: &callout,
+ table: anakin_table,
+ termios: anakin_termios,
+ termios_locked: anakin_termios_locked,
+ minor: SERIAL_ANAKIN_MINOR,
+ nr: UART_NR,
+ state: anakin_state,
+ port: anakin_ports,
+ cons: ANAKIN_CONSOLE,
+};
+
+static int __init
+anakin_init(void)
+{
+ return uart_register_port(&anakin_reg);
+}
+
+__initcall(anakin_init);
+
+MODULE_DESCRIPTION("Anakin serial driver");
+MODULE_AUTHOR("Tak-Shing Chan <chan@aleph1.co.uk>");
+MODULE_SUPPORTED_DEVICE("ttyAN");
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/serial/clps711x.c linux-2.4.26-vrs1/drivers/serial/clps711x.c
--- linux-2.4.26/drivers/serial/clps711x.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/clps711x.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,635 @@
+/*
+ * linux/drivers/char/serial_clps711x.c
+ *
+ * Driver for CLPS711x serial ports
+ *
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * Copyright 1999 ARM Limited
+ * Copyright (C) 2000 Deep Blue Solutions Ltd.
+ *
+ * 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: clps711x.c,v 1.12.2.2 2002/10/24 09:53:25 rmk Exp $
+ *
+ */
+#include <linux/config.h>
+#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/bitops.h>
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/system.h>
+#include <asm/uaccess.h>
+
+#include <linux/serial_core.h>
+
+#include <asm/hardware/clps7111.h>
+
+#define UART_NR 2
+
+#define SERIAL_CLPS711X_NAME "ttyAM"
+#define SERIAL_CLPS711X_MAJOR 204
+#define SERIAL_CLPS711X_MINOR 16
+#define SERIAL_CLPS711X_NR UART_NR
+
+#define CALLOUT_CLPS711X_NAME "cuaam"
+#define CALLOUT_CLPS711X_MAJOR 205
+#define CALLOUT_CLPS711X_MINOR 16
+#define CALLOUT_CLPS711X_NR UART_NR
+
+static struct tty_driver normal, callout;
+static struct tty_struct *clps711x_table[UART_NR];
+static struct termios *clps711x_termios[UART_NR], *clps711x_termios_locked[UART_NR];
+
+/*
+ * We use the relevant SYSCON register as a base address for these ports.
+ */
+#define UBRLCR(port) ((port)->iobase + UBRLCR1 - SYSCON1)
+#define UARTDR(port) ((port)->iobase + UARTDR1 - SYSCON1)
+#define SYSFLG(port) ((port)->iobase + SYSFLG1 - SYSCON1)
+#define SYSCON(port) ((port)->iobase + SYSCON1 - SYSCON1)
+
+#define TX_IRQ(port) ((port)->irq)
+#define RX_IRQ(port) ((port)->irq + 1)
+
+#define UART_ANY_ERR (UARTDR_FRMERR | UARTDR_PARERR | UARTDR_OVERR)
+
+#define tx_enabled(port) ((port)->unused[0])
+
+static void
+clps711xuart_stop_tx(struct uart_port *port, unsigned int tty_stop)
+{
+ if (tx_enabled(port)) {
+ disable_irq(TX_IRQ(port));
+ tx_enabled(port) = 0;
+ }
+}
+
+static void
+clps711xuart_start_tx(struct uart_port *port, unsigned int tty_start)
+{
+ if (!tx_enabled(port)) {
+ enable_irq(TX_IRQ(port));
+ tx_enabled(port) = 1;
+ }
+}
+
+static void clps711xuart_stop_rx(struct uart_port *port)
+{
+ disable_irq(RX_IRQ(port));
+}
+
+static void clps711xuart_enable_ms(struct uart_port *port)
+{
+}
+
+static void clps711xuart_int_rx(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct uart_port *port = dev_id;
+ struct tty_struct *tty = port->info->tty;
+ unsigned int status, ch, flg, ignored = 0;
+
+ status = clps_readl(SYSFLG(port));
+ while (!(status & SYSFLG_URXFE)) {
+ ch = clps_readl(UARTDR(port));
+
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+ goto ignore_char;
+ port->icount.rx++;
+
+ flg = TTY_NORMAL;
+
+ /*
+ * Note that the error handling code is
+ * out of the main execution path
+ */
+ if (ch & UART_ANY_ERR)
+ 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 = clps_readl(SYSFLG(port));
+ }
+ out:
+ tty_flip_buffer_push(tty);
+ return;
+
+ handle_error:
+ if (ch & UARTDR_PARERR)
+ port->icount.parity++;
+ else if (ch & UARTDR_FRMERR)
+ port->icount.frame++;
+ if (ch & UARTDR_OVERR)
+ port->icount.overrun++;
+
+ if (ch & port->ignore_status_mask) {
+ if (++ignored > 100)
+ goto out;
+ goto ignore_char;
+ }
+ ch &= port->read_status_mask;
+
+ if (ch & UARTDR_PARERR)
+ flg = TTY_PARITY;
+ else if (ch & UARTDR_FRMERR)
+ flg = TTY_FRAME;
+
+ if (ch & UARTDR_OVERR) {
+ /*
+ * 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 clps711xuart_int_tx(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct uart_port *port = dev_id;
+ struct circ_buf *xmit = &port->info->xmit;
+ int count;
+
+ if (port->x_char) {
+ clps_writel(port->x_char, UARTDR(port));
+ port->icount.tx++;
+ port->x_char = 0;
+ return;
+ }
+ if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
+ clps711xuart_stop_tx(port, 0);
+ return;
+ }
+
+ count = port->fifosize >> 1;
+ do {
+ clps_writel(xmit->buf[xmit->tail], UARTDR(port));
+ 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))
+ clps711xuart_stop_tx(port, 0);
+}
+
+static unsigned int clps711xuart_tx_empty(struct uart_port *port)
+{
+ unsigned int status = clps_readl(SYSFLG(port));
+ return status & SYSFLG_UBUSY ? 0 : TIOCSER_TEMT;
+}
+
+static unsigned int clps711xuart_get_mctrl(struct uart_port *port)
+{
+ unsigned int port_addr;
+ unsigned int result = 0;
+ unsigned int status;
+
+ port_addr = SYSFLG(port);
+ if (port_addr == SYSFLG1) {
+ status = clps_readl(SYSFLG1);
+ if (status & SYSFLG1_DCD)
+ result |= TIOCM_CAR;
+ if (status & SYSFLG1_DSR)
+ result |= TIOCM_DSR;
+ if (status & SYSFLG1_CTS)
+ result |= TIOCM_CTS;
+ }
+
+ return result;
+}
+
+static void
+clps711xuart_set_mctrl_null(struct uart_port *port, unsigned int mctrl)
+{
+}
+
+static void clps711xuart_break_ctl(struct uart_port *port, int break_state)
+{
+ unsigned long flags;
+ unsigned int ubrlcr;
+
+ spin_lock_irqsave(&port->lock, flags);
+ ubrlcr = clps_readl(UBRLCR(port));
+ if (break_state == -1)
+ ubrlcr |= UBRLCR_BREAK;
+ else
+ ubrlcr &= ~UBRLCR_BREAK;
+ clps_writel(ubrlcr, UBRLCR(port));
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static int clps711xuart_startup(struct uart_port *port)
+{
+ unsigned int syscon;
+ int retval;
+
+ tx_enabled(port) = 1;
+
+ /*
+ * Allocate the IRQs
+ */
+ retval = request_irq(TX_IRQ(port), clps711xuart_int_tx, 0,
+ "clps711xuart_tx", port);
+ if (retval)
+ return retval;
+
+ retval = request_irq(RX_IRQ(port), clps711xuart_int_rx, 0,
+ "clps711xuart_rx", port);
+ if (retval) {
+ free_irq(TX_IRQ(port), port);
+ return retval;
+ }
+
+ /*
+ * enable the port
+ */
+ syscon = clps_readl(SYSCON(port));
+ syscon |= SYSCON_UARTEN;
+ clps_writel(syscon, SYSCON(port));
+
+ return 0;
+}
+
+static void clps711xuart_shutdown(struct uart_port *port)
+{
+ unsigned int ubrlcr, syscon;
+
+ /*
+ * Free the interrupt
+ */
+ free_irq(TX_IRQ(port), port); /* TX interrupt */
+ free_irq(RX_IRQ(port), port); /* RX interrupt */
+
+ /*
+ * disable the port
+ */
+ syscon = clps_readl(SYSCON(port));
+ syscon &= ~SYSCON_UARTEN;
+ clps_writel(syscon, SYSCON(port));
+
+ /*
+ * disable break condition and fifos
+ */
+ ubrlcr = clps_readl(UBRLCR(port));
+ ubrlcr &= ~(UBRLCR_FIFOEN | UBRLCR_BREAK);
+ clps_writel(ubrlcr, UBRLCR(port));
+}
+
+static void clps711xuart_change_speed(struct uart_port *port, unsigned int cflag, unsigned int iflag, unsigned int quot)
+{
+ unsigned int ubrlcr;
+ unsigned long flags;
+
+#if DEBUG
+ printk("clps711xuart_change_speed(cflag=0x%x, iflag=0x%x, quot=%d) called\n",
+ cflag, iflag, quot);
+#endif
+ /* byte size and parity */
+ switch (cflag & CSIZE) {
+ case CS5:
+ ubrlcr = UBRLCR_WRDLEN5;
+ break;
+ case CS6:
+ ubrlcr = UBRLCR_WRDLEN6;
+ break;
+ case CS7:
+ ubrlcr = UBRLCR_WRDLEN7;
+ break;
+ default: // CS8
+ ubrlcr = UBRLCR_WRDLEN8;
+ break;
+ }
+ if (cflag & CSTOPB)
+ ubrlcr |= UBRLCR_XSTOP;
+ if (cflag & PARENB) {
+ ubrlcr |= UBRLCR_PRTEN;
+ if (!(cflag & PARODD))
+ ubrlcr |= UBRLCR_EVENPRT;
+ }
+ if (port->fifosize > 1)
+ ubrlcr |= UBRLCR_FIFOEN;
+
+ spin_lock_irqsave(&port->lock, flags);
+
+ port->read_status_mask = UARTDR_OVERR;
+ if (iflag & INPCK)
+ port->read_status_mask |= UARTDR_PARERR | UARTDR_FRMERR;
+
+ /*
+ * Characters to ignore
+ */
+ port->ignore_status_mask = 0;
+ if (iflag & IGNPAR)
+ port->ignore_status_mask |= UARTDR_FRMERR | UARTDR_PARERR;
+ if (iflag & IGNBRK) {
+ /*
+ * If we're ignoring parity and break indicators,
+ * ignore overruns to (for real raw support).
+ */
+ if (iflag & IGNPAR)
+ port->ignore_status_mask |= UARTDR_OVERR;
+ }
+
+ quot -= 1;
+
+ clps_writel(ubrlcr | quot, UBRLCR(port));
+
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static const char *clps711xuart_type(struct uart_port *port)
+{
+ return port->type == PORT_CLPS711X ? "CLPS711x" : NULL;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void clps711xuart_config_port(struct uart_port *port, int flags)
+{
+ if (flags & UART_CONFIG_TYPE)
+ port->type = PORT_CLPS711X;
+}
+
+static void clps711xuart_release_port(struct uart_port *port)
+{
+}
+
+static int clps711xuart_request_port(struct uart_port *port)
+{
+ return 0;
+}
+
+static struct uart_ops clps711x_pops = {
+ .tx_empty = clps711xuart_tx_empty,
+ .set_mctrl = clps711xuart_set_mctrl_null,
+ .get_mctrl = clps711xuart_get_mctrl,
+ .stop_tx = clps711xuart_stop_tx,
+ .start_tx = clps711xuart_start_tx,
+ .stop_rx = clps711xuart_stop_rx,
+ .enable_ms = clps711xuart_enable_ms,
+ .break_ctl = clps711xuart_break_ctl,
+ .startup = clps711xuart_startup,
+ .shutdown = clps711xuart_shutdown,
+ .change_speed = clps711xuart_change_speed,
+ .type = clps711xuart_type,
+ .config_port = clps711xuart_config_port,
+ .release_port = clps711xuart_release_port,
+ .request_port = clps711xuart_request_port,
+};
+
+static struct uart_port clps711x_ports[UART_NR] = {
+ {
+ .iobase = SYSCON1,
+ .irq = IRQ_UTXINT1, /* IRQ_URXINT1, IRQ_UMSINT */
+ .uartclk = 3686400,
+ .fifosize = 16,
+ .ops = &clps711x_pops,
+ .line = 0,
+ .flags = ASYNC_BOOT_AUTOCONF,
+ },
+ {
+ .iobase = SYSCON2,
+ .irq = IRQ_UTXINT2, /* IRQ_URXINT2 */
+ .uartclk = 3686400,
+ .fifosize = 16,
+ .ops = &clps711x_pops,
+ .line = 1,
+ .flags = ASYNC_BOOT_AUTOCONF,
+ }
+};
+
+#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE
+/*
+ * Print a string to the serial port trying not to disturb
+ * any possible real use of the port...
+ *
+ * The console_lock must be held when we get here.
+ *
+ * Note that this is called with interrupts already disabled
+ */
+static void
+clps711xuart_console_write(struct console *co, const char *s,
+ unsigned int count)
+{
+ struct uart_port *port = clps711x_ports + co->index;
+ unsigned int status, syscon;
+ int i;
+
+ /*
+ * Ensure that the port is enabled.
+ */
+ syscon = clps_readl(SYSCON(port));
+ clps_writel(syscon | SYSCON_UARTEN, SYSCON(port));
+
+ /*
+ * Now, do each character
+ */
+ for (i = 0; i < count; i++) {
+ do {
+ status = clps_readl(SYSFLG(port));
+ } while (status & SYSFLG_UTXFF);
+ clps_writel(s[i], UARTDR(port));
+ if (s[i] == '\n') {
+ do {
+ status = clps_readl(SYSFLG(port));
+ } while (status & SYSFLG_UTXFF);
+ clps_writel('\r', UARTDR(port));
+ }
+ }
+
+ /*
+ * Finally, wait for transmitter to become empty
+ * and restore the uart state.
+ */
+ do {
+ status = clps_readl(SYSFLG(port));
+ } while (status & SYSFLG_UBUSY);
+
+ clps_writel(syscon, SYSCON(port));
+}
+
+static kdev_t clps711xuart_console_device(struct console *co)
+{
+ return MKDEV(SERIAL_CLPS711X_MAJOR, SERIAL_CLPS711X_MINOR + co->index);
+}
+
+static void __init
+clps711xuart_console_get_options(struct uart_port *port, int *baud,
+ int *parity, int *bits)
+{
+ if (clps_readl(SYSCON(port)) & SYSCON_UARTEN) {
+ unsigned int ubrlcr, quot;
+
+ ubrlcr = clps_readl(UBRLCR(port));
+
+ *parity = 'n';
+ if (ubrlcr & UBRLCR_PRTEN) {
+ if (ubrlcr & UBRLCR_EVENPRT)
+ *parity = 'e';
+ else
+ *parity = 'o';
+ }
+
+ if ((ubrlcr & UBRLCR_WRDLEN_MASK) == UBRLCR_WRDLEN7)
+ *bits = 7;
+ else
+ *bits = 8;
+
+ quot = ubrlcr & UBRLCR_BAUD_MASK;
+ *baud = port->uartclk / (16 * (quot + 1));
+ }
+}
+
+static int __init clps711xuart_console_setup(struct console *co, char *options)
+{
+ struct uart_port *port;
+ int baud = 38400;
+ int bits = 8;
+ int parity = 'n';
+ int flow = 'n';
+
+ /*
+ * 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(clps711x_ports, UART_NR, co);
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+ else
+ clps711xuart_console_get_options(port, &baud, &parity, &bits);
+
+ return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct console clps711x_console = {
+ .name = SERIAL_CLPS711X_NAME,
+ .write = clps711xuart_console_write,
+ .device = clps711xuart_console_device,
+ .setup = clps711xuart_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = -1,
+};
+
+void __init clps711xuart_console_init(void)
+{
+ register_console(&clps711x_console);
+}
+
+#define CLPS711X_CONSOLE &clps711x_console
+#else
+#define CLPS711X_CONSOLE NULL
+#endif
+
+static struct uart_driver clps711x_reg = {
+#ifdef CONFIG_DEVFS_FS
+ .normal_name = SERIAL_CLPS711X_NAME,
+ .callout_name = CALLOUT_CLPS711X_NAME,
+#else
+ .normal_name = SERIAL_CLPS711X_NAME,
+ .callout_name = CALLOUT_CLPS711X_NAME,
+#endif
+
+ .normal_major = SERIAL_CLPS711X_MAJOR,
+ .normal_driver = &normal,
+ .callout_major = CALLOUT_CLPS711X_MAJOR,
+ .callout_driver = &callout,
+
+ .table = clps711x_table,
+ .termios = clps711x_termios,
+ .termios_locked = clps711x_termios_locked,
+
+ .minor = SERIAL_CLPS711X_MINOR,
+ .nr = UART_NR,
+
+ .cons = CLPS711X_CONSOLE,
+};
+
+static int __init clps711xuart_init(void)
+{
+ int ret, i;
+
+ printk(KERN_INFO "Serial: CLPS711x driver\n");
+
+ ret = uart_register_driver(&clps711x_reg);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < UART_NR; i++)
+ uart_add_one_port(&clps711x_reg, &clps711x_ports[i]);
+
+ return 0;
+}
+
+static void __exit clps711xuart_exit(void)
+{
+ int i;
+
+ for (i = 0; i < UART_NR; i++)
+ uart_remove_one_port(&clps711x_reg, &clps711x_ports[i]);
+
+ uart_unregister_driver(&clps711x_reg);
+}
+
+module_init(clps711xuart_init);
+module_exit(clps711xuart_exit);
+
+EXPORT_NO_SYMBOLS;
+
+MODULE_AUTHOR("Deep Blue Solutions Ltd");
+MODULE_DESCRIPTION("CLPS-711x generic serial driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/serial/core.c linux-2.4.26-vrs1/drivers/serial/core.c
--- linux-2.4.26/drivers/serial/core.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/core.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,2584 @@
+/*
+ * linux/drivers/serial/core.c
+ *
+ * Driver core for serial ports
+ *
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * Copyright 1999 ARM Limited
+ * Copyright (C) 2000-2001 Deep Blue Solutions Ltd.
+ *
+ * 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: core.c,v 1.20.2.5 2002/03/13 15:22:26 rmk Exp $
+ *
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/tty.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/console.h>
+#include <linux/sysrq.h>
+#include <linux/pm.h>
+#include <linux/serial_core.h>
+#include <linux/smp_lock.h>
+
+#include <asm/irq.h>
+#include <asm/uaccess.h>
+
+#undef DEBUG
+#ifdef DEBUG
+#define DPRINTK(x...) printk(x)
+#else
+#define DPRINTK(x...) do { } while (0)
+#endif
+
+#ifndef CONFIG_PM
+#define pm_access(pm) do { } while (0)
+#define pm_unregister(pm) do { } while (0)
+#endif
+
+/*
+ * This is used to lock changes in serial line configuration.
+ */
+static DECLARE_MUTEX(port_sem);
+
+#define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
+
+#define uart_users(state) ((state)->count + ((state)->info ? (state)->info->blocked_open : 0))
+
+#ifdef CONFIG_SERIAL_CORE_CONSOLE
+#define uart_console(port) ((port)->cons && (port)->cons->index == (port)->line)
+#else
+#define uart_console(port) (0)
+#endif
+
+static void uart_change_speed(struct uart_state *state, struct termios *old_termios);
+static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
+static void uart_change_pm(struct uart_state *state, int pm_state);
+
+/*
+ * This routine is used by the interrupt handler to schedule processing in
+ * the software interrupt portion of the driver.
+ */
+void uart_write_wakeup(struct uart_port *port)
+{
+ struct uart_info *info = port->info;
+ tasklet_schedule(&info->tlet);
+}
+
+static void uart_stop(struct tty_struct *tty)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+ unsigned long flags;
+
+ spin_lock_irqsave(&port->lock, flags);
+ port->ops->stop_tx(port, 1);
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void __uart_start(struct tty_struct *tty)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+
+ if (!uart_circ_empty(&state->info->xmit) && state->info->xmit.buf &&
+ !tty->stopped && !tty->hw_stopped)
+ port->ops->start_tx(port, 1);
+}
+
+static void uart_start(struct tty_struct *tty)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+ unsigned long flags;
+
+ pm_access(state->pm);
+
+ spin_lock_irqsave(&port->lock, flags);
+ __uart_start(tty);
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static void uart_tasklet_action(unsigned long data)
+{
+ struct uart_state *state = (struct uart_state *)data;
+ struct tty_struct *tty;
+
+ tty = state->info->tty;
+ if (tty) {
+ if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+ tty->ldisc.write_wakeup)
+ tty->ldisc.write_wakeup(tty);
+ wake_up_interruptible(&tty->write_wait);
+ }
+}
+
+static inline void
+uart_update_mctrl(struct uart_port *port, unsigned int set, unsigned int clear)
+{
+ unsigned long flags;
+ unsigned int old;
+
+ spin_lock_irqsave(&port->lock, flags);
+ old = port->mctrl;
+ port->mctrl = (old & ~clear) | set;
+ if (old != port->mctrl)
+ port->ops->set_mctrl(port, port->mctrl);
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+#define uart_set_mctrl(port,set) uart_update_mctrl(port,set,0)
+#define uart_clear_mctrl(port,clear) uart_update_mctrl(port,0,clear)
+
+static inline unsigned int uart_get_altspeed(struct uart_port *port)
+{
+ unsigned int flags = port->flags & UPF_SPD_MASK;
+ unsigned int altbaud = 0;
+
+ if (flags == ASYNC_SPD_HI)
+ altbaud = 57600;
+ if (flags == ASYNC_SPD_VHI)
+ altbaud = 115200;
+ if (flags == ASYNC_SPD_SHI)
+ altbaud = 230400;
+ if (flags == ASYNC_SPD_WARP)
+ altbaud = 460800;
+
+ return altbaud;
+}
+
+/*
+ * Startup the port. This will be called once per open. All calls
+ * will be serialised by the per-port semaphore.
+ */
+static int uart_startup(struct uart_state *state, int init_hw)
+{
+ struct uart_info *info = state->info;
+ struct uart_port *port = state->port;
+ unsigned long page;
+ int retval = 0;
+
+ if (info->flags & UIF_INITIALIZED)
+ return 0;
+
+ /*
+ * Set the TTY IO error marker - we will only clear this
+ * once we have successfully opened the port. Also set
+ * up the tty->alt_speed kludge
+ */
+ if (info->tty)
+ set_bit(TTY_IO_ERROR, &info->tty->flags);
+
+ if (port->type == PORT_UNKNOWN)
+ return 0;
+
+ /*
+ * Initialise and allocate the transmit and temporary
+ * buffer.
+ */
+ if (!info->xmit.buf) {
+ page = get_zeroed_page(GFP_KERNEL);
+ if (!page)
+ return -ENOMEM;
+
+ info->xmit.buf = (unsigned char *) page;
+ info->tmpbuf = info->xmit.buf + UART_XMIT_SIZE;
+ init_MUTEX(&info->tmpbuf_sem);
+ uart_circ_clear(&info->xmit);
+ }
+
+ port->mctrl = 0;
+
+ retval = port->ops->startup(port);
+ if (retval == 0) {
+ if (init_hw) {
+ /*
+ * Initialise the hardware port settings.
+ */
+ uart_change_speed(state, NULL);
+
+ /*
+ * Setup the RTS and DTR signals once the
+ * port is open and ready to respond.
+ */
+ if (info->tty->termios->c_cflag & CBAUD)
+ uart_set_mctrl(port, TIOCM_RTS | TIOCM_DTR);
+ }
+
+ info->flags |= UIF_INITIALIZED;
+
+ clear_bit(TTY_IO_ERROR, &info->tty->flags);
+ }
+
+ if (retval && capable(CAP_SYS_ADMIN))
+ retval = 0;
+
+ return retval;
+}
+
+/*
+ * This routine will shutdown a serial port; interrupts are disabled, and
+ * DTR is dropped if the hangup on close termio flag is on. Calls to
+ * uart_shutdown are serialised by the per-port semaphore.
+ */
+static void uart_shutdown(struct uart_state *state)
+{
+ struct uart_info *info = state->info;
+ struct uart_port *port = state->port;
+
+ if (!(info->flags & UIF_INITIALIZED))
+ return;
+
+ /*
+ * Turn off DTR and RTS early.
+ */
+ if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
+ uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
+
+ /*
+ * clear delta_msr_wait queue to avoid mem leaks: we may free
+ * the irq here so the queue might never be woken up. Note
+ * that we won't end up waiting on delta_msr_wait again since
+ * any outstanding file descriptors should be pointing at
+ * hung_up_tty_fops now.
+ */
+ wake_up_interruptible(&info->delta_msr_wait);
+
+ /*
+ * Free the IRQ and disable the port.
+ */
+ port->ops->shutdown(port);
+
+ /*
+ * Free the transmit buffer page.
+ */
+ if (info->xmit.buf) {
+ free_page((unsigned long)info->xmit.buf);
+ info->xmit.buf = NULL;
+ info->tmpbuf = NULL;
+ }
+
+ /*
+ * kill off our tasklet
+ */
+ tasklet_kill(&info->tlet);
+ if (info->tty)
+ set_bit(TTY_IO_ERROR, &info->tty->flags);
+
+ info->flags &= ~UIF_INITIALIZED;
+}
+
+/**
+ * uart_update_timeout - update per-port FIFO timeout.
+ * @port: uart_port structure describing the port.
+ * @cflag: termios cflag value
+ * @quot: uart clock divisor quotient
+ *
+ * Set the port FIFO timeout value. The @cflag value should
+ * reflect the actual hardware settings.
+ */
+void
+uart_update_timeout(struct uart_port *port, unsigned int cflag,
+ unsigned int baud)
+{
+ unsigned int bits;
+
+ /* byte size and parity */
+ switch (cflag & CSIZE) {
+ case CS5:
+ bits = 7;
+ break;
+ case CS6:
+ bits = 8;
+ break;
+ case CS7:
+ bits = 9;
+ break;
+ default:
+ bits = 10;
+ break; // CS8
+ }
+
+ if (cflag & CSTOPB)
+ bits++;
+ if (cflag & PARENB)
+ bits++;
+
+ /*
+ * The total number of bits to be transmitted in the fifo.
+ */
+ bits = bits * port->fifosize;
+
+ /*
+ * Figure the timeout to send the above number of bits.
+ * Add .02 seconds of slop
+ */
+ port->timeout = (HZ * bits) / baud + HZ/50;
+}
+
+EXPORT_SYMBOL(uart_update_timeout);
+
+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;
+
+ /* Old HI/VHI/custom speed handling */
+ if (baud == 38400 &&
+ ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
+ quot = port->custom_divisor;
+ else
+ quot = port->uartclk / (16 * baud);
+
+ return quot;
+}
+
+static void
+uart_change_speed(struct uart_state *state, struct termios *old_termios)
+{
+ struct tty_struct *tty = state->info->tty;
+ struct uart_port *port = state->port;
+ struct termios *termios;
+ unsigned int quot, baud, cflag, try;
+
+ /*
+ * If we have no tty, termios, or the port does not exist,
+ * then we can't set the parameters for this port.
+ */
+ if (!tty || !tty->termios || port->type == PORT_UNKNOWN)
+ return;
+
+ termios = tty->termios;
+
+ cflag = termios->c_cflag;
+
+ for (try = 0; try < 2; try ++) {
+ /* Determine divisor based on baud rate */
+ baud = tty_get_baud_rate(tty);
+ quot = uart_calculate_quot(port, baud);
+ if (quot)
+ break;
+
+ /*
+ * Oops, the quotient was zero. Try again with
+ * the old baud rate if possible.
+ */
+ termios->c_cflag &= ~CBAUD;
+ if (old_termios) {
+ termios->c_cflag |=
+ (old_termios->c_cflag & CBAUD);
+ old_termios = NULL;
+ continue;
+ }
+
+ /*
+ * As a last resort, if the quotient is zero,
+ * default to 9600 bps
+ */
+ termios->c_cflag |= B9600;
+ }
+
+ uart_update_timeout(port, cflag, port->uartclk / (16 * quot));
+
+ if (termios->c_cflag & CRTSCTS)
+ state->info->flags |= UIF_CTS_FLOW;
+ else
+ state->info->flags &= ~UIF_CTS_FLOW;
+ if (termios->c_cflag & CLOCAL)
+ state->info->flags &= ~UIF_CHECK_CD;
+ else
+ state->info->flags |= UIF_CHECK_CD;
+
+ /*
+ * Set up parity check flag
+ */
+ pm_access(state->pm);
+
+ port->ops->change_speed(port, cflag, termios->c_iflag, quot);
+}
+
+static inline void
+__uart_put_char(struct uart_port *port, struct circ_buf *circ, unsigned char c)
+{
+ unsigned long flags;
+
+ if (!circ->buf)
+ return;
+
+ spin_lock_irqsave(&port->lock, flags);
+ if (uart_circ_chars_free(circ) != 0) {
+ circ->buf[circ->head] = c;
+ circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1);
+ }
+ spin_unlock_irqrestore(&port->lock, flags);
+}
+
+static inline int
+__uart_user_write(struct uart_port *port, struct circ_buf *circ,
+ const unsigned char *buf, int count)
+{
+ unsigned long flags;
+ int c, ret = 0;
+
+ if (down_interruptible(&port->info->tmpbuf_sem))
+ return -EINTR;
+
+ while (1) {
+ int c1;
+ c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
+ if (count < c)
+ c = count;
+ if (c <= 0)
+ break;
+
+ c -= copy_from_user(port->info->tmpbuf, buf, c);
+ if (!c) {
+ if (!ret)
+ ret = -EFAULT;
+ break;
+ }
+ spin_lock_irqsave(&port->lock, flags);
+ c1 = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
+ if (c1 < c)
+ c = c1;
+ memcpy(circ->buf + circ->head, port->info->tmpbuf, c);
+ circ->head = (circ->head + c) & (UART_XMIT_SIZE - 1);
+ spin_unlock_irqrestore(&port->lock, flags);
+ buf += c;
+ count -= c;
+ ret += c;
+ }
+ up(&port->info->tmpbuf_sem);
+
+ return ret;
+}
+
+static inline int
+__uart_kern_write(struct uart_port *port, struct circ_buf *circ,
+ const unsigned char *buf, int count)
+{
+ unsigned long flags;
+ int c, ret = 0;
+
+ spin_lock_irqsave(&port->lock, flags);
+ while (1) {
+ c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE);
+ if (count < c)
+ c = count;
+ if (c <= 0)
+ break;
+ memcpy(circ->buf + circ->head, buf, c);
+ circ->head = (circ->head + c) & (UART_XMIT_SIZE - 1);
+ buf += c;
+ count -= c;
+ ret += c;
+ }
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ return ret;
+}
+
+static void uart_put_char(struct tty_struct *tty, unsigned char ch)
+{
+ struct uart_state *state = tty->driver_data;
+
+ __uart_put_char(state->port, &state->info->xmit, ch);
+}
+
+static void uart_flush_chars(struct tty_struct *tty)
+{
+ uart_start(tty);
+}
+
+static int
+uart_write(struct tty_struct *tty, int from_user, const unsigned char * buf,
+ int count)
+{
+ struct uart_state *state = tty->driver_data;
+ int ret;
+
+ if (!state->info->xmit.buf)
+ return 0;
+
+ if (from_user)
+ ret = __uart_user_write(state->port, &state->info->xmit, buf, count);
+ else
+ ret = __uart_kern_write(state->port, &state->info->xmit, buf, count);
+
+ uart_start(tty);
+ return ret;
+}
+
+static int uart_write_room(struct tty_struct *tty)
+{
+ struct uart_state *state = tty->driver_data;
+
+ return uart_circ_chars_free(&state->info->xmit);
+}
+
+static int uart_chars_in_buffer(struct tty_struct *tty)
+{
+ struct uart_state *state = tty->driver_data;
+
+ return uart_circ_chars_pending(&state->info->xmit);
+}
+
+static void uart_flush_buffer(struct tty_struct *tty)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+ unsigned long flags;
+
+ DPRINTK("uart_flush_buffer(%d) called\n",
+ MINOR(tty->device) - tty->driver.minor_start);
+
+ spin_lock_irqsave(&port->lock, flags);
+ uart_circ_clear(&state->info->xmit);
+ spin_unlock_irqrestore(&port->lock, flags);
+ wake_up_interruptible(&tty->write_wait);
+ if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+ tty->ldisc.write_wakeup)
+ (tty->ldisc.write_wakeup)(tty);
+}
+
+/*
+ * This function is used to send a high-priority XON/XOFF character to
+ * the device
+ */
+static void uart_send_xchar(struct tty_struct *tty, char ch)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+ unsigned long flags;
+
+ if (port->ops->send_xchar)
+ port->ops->send_xchar(port, ch);
+ else {
+ port->x_char = ch;
+ if (ch) {
+ spin_lock_irqsave(&port->lock, flags);
+ port->ops->start_tx(port, 0);
+ spin_unlock_irqrestore(&port->lock, flags);
+ }
+ }
+}
+
+static void uart_throttle(struct tty_struct *tty)
+{
+ struct uart_state *state = tty->driver_data;
+
+ if (I_IXOFF(tty))
+ uart_send_xchar(tty, STOP_CHAR(tty));
+
+ if (tty->termios->c_cflag & CRTSCTS)
+ uart_clear_mctrl(state->port, TIOCM_RTS);
+}
+
+static void uart_unthrottle(struct tty_struct *tty)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+
+ if (I_IXOFF(tty)) {
+ if (port->x_char)
+ port->x_char = 0;
+ else
+ uart_send_xchar(tty, START_CHAR(tty));
+ }
+
+ if (tty->termios->c_cflag & CRTSCTS)
+ uart_set_mctrl(port, TIOCM_RTS);
+}
+
+static int uart_get_info(struct uart_state *state, struct serial_struct *retinfo)
+{
+ struct uart_port *port = state->port;
+ struct serial_struct tmp;
+
+ memset(&tmp, 0, sizeof(tmp));
+ tmp.type = port->type;
+ tmp.line = port->line;
+ tmp.port = port->iobase;
+ if (HIGH_BITS_OFFSET)
+ tmp.port_high = (long) port->iobase >> HIGH_BITS_OFFSET;
+ tmp.irq = port->irq;
+ tmp.flags = port->flags;
+ tmp.xmit_fifo_size = port->fifosize;
+ tmp.baud_base = port->uartclk / 16;
+ tmp.close_delay = state->close_delay;
+ tmp.closing_wait = state->closing_wait;
+ tmp.custom_divisor = port->custom_divisor;
+ tmp.hub6 = port->hub6;
+ tmp.io_type = port->iotype;
+ tmp.iomem_reg_shift = port->regshift;
+ tmp.iomem_base = (void *)port->mapbase;
+
+ if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
+ return -EFAULT;
+ return 0;
+}
+
+static int
+uart_set_info(struct uart_state *state, struct serial_struct *newinfo)
+{
+ struct serial_struct new_serial;
+ struct uart_port *port = state->port;
+ unsigned long new_port;
+ unsigned int change_irq, change_port, old_flags;
+ unsigned int old_custom_divisor;
+ int retval = 0;
+
+ if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
+ return -EFAULT;
+
+ new_port = new_serial.port;
+ if (HIGH_BITS_OFFSET)
+ new_port += (unsigned long) new_serial.port_high << HIGH_BITS_OFFSET;
+
+ new_serial.irq = irq_cannonicalize(new_serial.irq);
+
+ /*
+ * This semaphore protects state->count. It is also
+ * very useful to prevent opens. Also, take the
+ * port configuration semaphore to make sure that a
+ * module insertion/removal doesn't change anything
+ * under us.
+ */
+ down(&state->sem);
+
+ change_irq = new_serial.irq != port->irq;
+
+ /*
+ * Since changing the 'type' of the port changes its resource
+ * allocations, we should treat type changes the same as
+ * IO port changes.
+ */
+ change_port = new_port != port->iobase ||
+ (unsigned long)new_serial.iomem_base != port->mapbase ||
+ new_serial.hub6 != port->hub6 ||
+ new_serial.io_type != port->iotype ||
+ new_serial.iomem_reg_shift != port->regshift ||
+ new_serial.type != port->type;
+
+ old_flags = port->flags;
+ old_custom_divisor = port->custom_divisor;
+
+ if (!capable(CAP_SYS_ADMIN)) {
+ retval = -EPERM;
+ if (change_irq || change_port ||
+ (new_serial.baud_base != port->uartclk / 16) ||
+ (new_serial.close_delay != state->close_delay) ||
+ (new_serial.closing_wait != state->closing_wait) ||
+ (new_serial.xmit_fifo_size != port->fifosize) ||
+ (((new_serial.flags ^ old_flags) & ~UPF_USR_MASK) != 0))
+ goto exit;
+ port->flags = ((port->flags & ~UPF_USR_MASK) |
+ (new_serial.flags & UPF_USR_MASK));
+ port->custom_divisor = new_serial.custom_divisor;
+ goto check_and_exit;
+ }
+
+ /*
+ * Ask the low level driver to verify the settings.
+ */
+ if (port->ops->verify_port)
+ retval = port->ops->verify_port(port, &new_serial);
+
+ if ((new_serial.irq >= NR_IRQS) || (new_serial.irq < 0) ||
+ (new_serial.baud_base < 9600))
+ retval = -EINVAL;
+
+ if (retval)
+ goto exit;
+
+ if (change_port || change_irq) {
+ retval = -EBUSY;
+
+ /*
+ * Make sure that we are the sole user of this port.
+ */
+ if (uart_users(state) > 1)
+ goto exit;
+
+ /*
+ * We need to shutdown the serial port at the old
+ * port/type/irq combination.
+ */
+ uart_shutdown(state);
+ }
+
+ if (change_port) {
+ unsigned long old_iobase, old_mapbase;
+ unsigned int old_type, old_iotype, old_hub6, old_shift;
+
+ old_iobase = port->iobase;
+ old_mapbase = port->mapbase;
+ old_type = port->type;
+ old_hub6 = port->hub6;
+ old_iotype = port->iotype;
+ old_shift = port->regshift;
+
+ /*
+ * Free and release old regions
+ */
+ if (old_type != PORT_UNKNOWN)
+ port->ops->release_port(port);
+
+ port->iobase = new_port;
+ port->type = new_serial.type;
+ port->hub6 = new_serial.hub6;
+ port->iotype = new_serial.io_type;
+ port->regshift = new_serial.iomem_reg_shift;
+ port->mapbase = (unsigned long)new_serial.iomem_base;
+
+ /*
+ * Claim and map the new regions
+ */
+ if (port->type != PORT_UNKNOWN) {
+ retval = port->ops->request_port(port);
+ } else {
+ /* Always success - Jean II */
+ retval = 0;
+ }
+
+ /*
+ * If we fail to request resources for the
+ * new port, try to restore the old settings.
+ */
+ if (retval && old_type != PORT_UNKNOWN) {
+ port->iobase = old_iobase;
+ port->type = old_type;
+ port->hub6 = old_hub6;
+ port->iotype = old_iotype;
+ port->regshift = old_shift;
+ port->mapbase = old_mapbase;
+ retval = port->ops->request_port(port);
+ /*
+ * If we failed to restore the old settings,
+ * we fail like this.
+ */
+ if (retval)
+ port->type = PORT_UNKNOWN;
+
+ /*
+ * We failed anyway.
+ */
+ retval = -EBUSY;
+ }
+ }
+
+ port->irq = new_serial.irq;
+ port->uartclk = new_serial.baud_base * 16;
+ port->flags = (port->flags & ~UPF_CHANGE_MASK) |
+ (new_serial.flags & UPF_CHANGE_MASK);
+ port->custom_divisor = new_serial.custom_divisor;
+ state->close_delay = new_serial.close_delay * HZ / 100;
+ state->closing_wait = new_serial.closing_wait * HZ / 100;
+ port->fifosize = new_serial.xmit_fifo_size;
+ if (state->info->tty)
+ state->info->tty->low_latency =
+ (port->flags & UPF_LOW_LATENCY) ? 1 : 0;
+
+ check_and_exit:
+ retval = 0;
+ if (port->type == PORT_UNKNOWN)
+ goto exit;
+ if (state->info->flags & UIF_INITIALIZED) {
+ if (((old_flags ^ port->flags) & UPF_SPD_MASK) ||
+ old_custom_divisor != port->custom_divisor) {
+ state->info->tty->alt_speed = uart_get_altspeed(port);
+ uart_change_speed(state, NULL);
+ }
+ } else
+ retval = uart_startup(state, 1);
+ exit:
+ up(&state->sem);
+ return retval;
+}
+
+
+/*
+ * uart_get_lsr_info - get line status register info.
+ * Note: uart_ioctl protects us against hangups.
+ */
+static int uart_get_lsr_info(struct uart_state *state, unsigned int *value)
+{
+ struct uart_port *port = state->port;
+ unsigned int result;
+
+ result = port->ops->tx_empty(port);
+
+ /*
+ * If we're about to load something into the transmit
+ * register, we'll pretend the transmitter isn't empty to
+ * avoid a race condition (depending on when the transmit
+ * interrupt happens).
+ */
+ if (port->x_char ||
+ ((uart_circ_chars_pending(&state->info->xmit) > 0) &&
+ !state->info->tty->stopped && !state->info->tty->hw_stopped))
+ result &= ~TIOCSER_TEMT;
+
+ return put_user(result, value);
+}
+
+static int uart_tiocmget(struct tty_struct *tty, struct file *file)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+ int result = -EIO;
+
+ down(&state->sem);
+ if ((!file || !tty_hung_up_p(file)) &&
+ !(tty->flags & (1 << TTY_IO_ERROR))) {
+ result = port->mctrl;
+ result |= port->ops->get_mctrl(port);
+ }
+ up(&state->sem);
+
+ return result;
+}
+
+static int
+uart_tiocmset(struct tty_struct *tty, struct file *file,
+ unsigned int set, unsigned int clear)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+ int ret = -EIO;
+
+ down(&state->sem);
+ if ((!file || !tty_hung_up_p(file)) &&
+ !(tty->flags & (1 << TTY_IO_ERROR))) {
+ uart_update_mctrl(port, set, clear);
+ ret = 0;
+ }
+ up(&state->sem);
+ return ret;
+}
+
+static void uart_break_ctl(struct tty_struct *tty, int break_state)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+
+ BUG_ON(!kernel_locked());
+
+ down(&state->sem);
+
+ if (port->type != PORT_UNKNOWN)
+ port->ops->break_ctl(port, break_state);
+
+ up(&state->sem);
+}
+
+static int uart_do_autoconfig(struct uart_state *state)
+{
+ struct uart_port *port = state->port;
+ int flags, ret;
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ /*
+ * Take the per-port semaphore. This prevents count from
+ * changing, and hence any extra opens of the port while
+ * we're auto-configuring.
+ */
+ if (down_interruptible(&state->sem))
+ return -ERESTARTSYS;
+
+ ret = -EBUSY;
+ if (uart_users(state) == 1) {
+ uart_shutdown(state);
+
+ /*
+ * If we already have a port type configured,
+ * we must release its resources.
+ */
+ if (port->type != PORT_UNKNOWN)
+ port->ops->release_port(port);
+
+ flags = UART_CONFIG_TYPE;
+ if (port->flags & UPF_AUTO_IRQ)
+ flags |= UART_CONFIG_IRQ;
+
+ /*
+ * This will claim the ports resources if
+ * a port is found.
+ */
+ port->ops->config_port(port, flags);
+
+ ret = uart_startup(state, 1);
+ }
+ up(&state->sem);
+ return ret;
+}
+
+/*
+ * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
+ * - mask passed in arg for lines of interest
+ * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
+ * Caller should use TIOCGICOUNT to see which one it was
+ */
+static int
+uart_wait_modem_status(struct uart_state *state, unsigned long arg)
+{
+ struct uart_port *port = state->port;
+ DECLARE_WAITQUEUE(wait, current);
+ struct uart_icount cprev, cnow;
+ int ret;
+
+ /*
+ * note the counters on entry
+ */
+ spin_lock_irq(&port->lock);
+ memcpy(&cprev, &port->icount, sizeof(struct uart_icount));
+
+ /*
+ * Force modem status interrupts on
+ */
+ port->ops->enable_ms(port);
+ spin_unlock_irq(&port->lock);
+
+ add_wait_queue(&state->info->delta_msr_wait, &wait);
+ for (;;) {
+ spin_lock_irq(&port->lock);
+ memcpy(&cnow, &port->icount, sizeof(struct uart_icount));
+ spin_unlock_irq(&port->lock);
+
+ set_current_state(TASK_INTERRUPTIBLE);
+
+ if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
+ ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
+ ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
+ ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
+ ret = 0;
+ break;
+ }
+
+ schedule();
+
+ /* see if a signal did it */
+ if (signal_pending(current)) {
+ ret = -ERESTARTSYS;
+ break;
+ }
+
+ cprev = cnow;
+ }
+
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&state->info->delta_msr_wait, &wait);
+
+ return ret;
+}
+
+/*
+ * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
+ * Return: write counters to the user passed counter struct
+ * NB: both 1->0 and 0->1 transitions are counted except for
+ * RI where only 0->1 is counted.
+ */
+static int
+uart_get_count(struct uart_state *state, struct serial_icounter_struct *icnt)
+{
+ struct serial_icounter_struct icount;
+ struct uart_icount cnow;
+ struct uart_port *port = state->port;
+
+ spin_lock_irq(&port->lock);
+ memcpy(&cnow, &port->icount, sizeof(struct uart_icount));
+ spin_unlock_irq(&port->lock);
+
+ icount.cts = cnow.cts;
+ icount.dsr = cnow.dsr;
+ icount.rng = cnow.rng;
+ icount.dcd = cnow.dcd;
+ icount.rx = cnow.rx;
+ icount.tx = cnow.tx;
+ icount.frame = cnow.frame;
+ icount.overrun = cnow.overrun;
+ icount.parity = cnow.parity;
+ icount.brk = cnow.brk;
+ icount.buf_overrun = cnow.buf_overrun;
+
+ return copy_to_user(icnt, &icount, sizeof(icount)) ? -EFAULT : 0;
+}
+
+/*
+ * Called via sys_ioctl under the BKL. We can use spin_lock_irq() here.
+ */
+static int
+uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ struct uart_state *state = tty->driver_data;
+ int ret = -ENOIOCTLCMD;
+
+ BUG_ON(!kernel_locked());
+
+ /*
+ * These ioctls don't rely on the hardware to be present.
+ */
+ switch (cmd) {
+ case TIOCGSERIAL:
+ ret = uart_get_info(state, (struct serial_struct *)arg);
+ break;
+
+ case TIOCSSERIAL:
+ ret = uart_set_info(state, (struct serial_struct *)arg);
+ break;
+
+ case TIOCSERCONFIG:
+ ret = uart_do_autoconfig(state);
+ break;
+
+ case TIOCSERGWILD: /* obsolete */
+ case TIOCSERSWILD: /* obsolete */
+ ret = 0;
+ break;
+ }
+
+ if (ret != -ENOIOCTLCMD)
+ goto out;
+
+ if (tty->flags & (1 << TTY_IO_ERROR)) {
+ ret = -EIO;
+ goto out;
+ }
+
+ /*
+ * The following should only be used when hardware is present.
+ */
+ switch (cmd) {
+ case TIOCMIWAIT:
+ ret = uart_wait_modem_status(state, arg);
+ break;
+
+ case TIOCGICOUNT:
+ ret = uart_get_count(state, (struct serial_icounter_struct *)arg);
+ break;
+
+ case TIOCMGET:
+ {
+ int val;
+ val = uart_tiocmget(tty, filp);
+ if (val >= 0) {
+ ret = put_user(val, (int *)arg);
+ } else {
+ ret = val;
+ }
+ }
+ break;
+
+ case TIOCMBIS:
+ case TIOCMBIC:
+ case TIOCMSET:
+ {
+ int val, set = 0, clear = 0;
+ ret = get_user(val, (int *)arg);
+ if (ret)
+ break;
+
+ switch (cmd) {
+ case TIOCMBIS:
+ set = val;
+ break;
+ case TIOCMBIC:
+ clear = val;
+ break;
+ case TIOCMSET:
+ set = val;
+ clear = ~val;
+ break;
+ }
+
+ set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
+ clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
+
+ ret = uart_tiocmset(tty, filp, set, clear);
+ }
+ break;
+ }
+
+ if (ret != -ENOIOCTLCMD)
+ goto out;
+
+ down(&state->sem);
+
+ if (tty_hung_up_p(filp)) {
+ ret = -EIO;
+ goto out_up;
+ }
+
+ /*
+ * All these rely on hardware being present and need to be
+ * protected against the tty being hung up.
+ */
+ switch (cmd) {
+ case TIOCSERGETLSR: /* Get line status register */
+ ret = uart_get_lsr_info(state, (unsigned int *)arg);
+ break;
+
+ default: {
+ struct uart_port *port = state->port;
+ if (port->ops->ioctl)
+ ret = port->ops->ioctl(port, cmd, arg);
+ break;
+ }
+ }
+ out_up:
+ up(&state->sem);
+ out:
+ return ret;
+}
+
+static void uart_set_termios(struct tty_struct *tty, struct termios *old_termios)
+{
+ struct uart_state *state = tty->driver_data;
+ unsigned long flags;
+ unsigned int cflag = tty->termios->c_cflag;
+
+ BUG_ON(!kernel_locked());
+
+ /*
+ * These are the bits that are used to setup various
+ * flags in the low level driver.
+ */
+#define RELEVANT_IFLAG(iflag) ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
+
+ if ((cflag ^ old_termios->c_cflag) == 0 &&
+ RELEVANT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0)
+ return;
+
+ uart_change_speed(state, old_termios);
+
+ /* Handle transition to B0 status */
+ if ((old_termios->c_cflag & CBAUD) && !(cflag & CBAUD))
+ uart_clear_mctrl(state->port, TIOCM_RTS | TIOCM_DTR);
+
+ /* Handle transition away from B0 status */
+ if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
+ unsigned int mask = TIOCM_DTR;
+ if (!(cflag & CRTSCTS) ||
+ !test_bit(TTY_THROTTLED, &tty->flags))
+ mask |= TIOCM_RTS;
+ uart_set_mctrl(state->port, mask);
+ }
+
+ /* Handle turning off CRTSCTS */
+ if ((old_termios->c_cflag & CRTSCTS) && !(cflag & CRTSCTS)) {
+ spin_lock_irqsave(&state->port->lock, flags);
+ tty->hw_stopped = 0;
+ __uart_start(tty);
+ spin_unlock_irqrestore(&state->port->lock, flags);
+ }
+
+#if 0
+ /*
+ * No need to wake up processes in open wait, since they
+ * sample the CLOCAL flag once, and don't recheck it.
+ * XXX It's not clear whether the current behavior is correct
+ * or not. Hence, this may change.....
+ */
+ if (!(old_termios->c_cflag & CLOCAL) &&
+ (tty->termios->c_cflag & CLOCAL))
+ wake_up_interruptible(&state->info->open_wait);
+#endif
+}
+
+/*
+ * In 2.4.5, calls to this will be serialized via the BKL in
+ * linux/drivers/char/tty_io.c:tty_release()
+ * linux/drivers/char/tty_io.c:do_tty_handup()
+ */
+static void uart_close(struct tty_struct *tty, struct file *filp)
+{
+ struct uart_driver *drv = (struct uart_driver *)tty->driver.driver_state;
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port;
+
+ BUG_ON(!kernel_locked());
+
+ if (!state || !state->port)
+ return;
+
+ port = state->port;
+
+ DPRINTK("uart_close(%d) called\n", port->line);
+
+ down(&state->sem);
+
+ if (tty_hung_up_p(filp))
+ goto done;
+
+ if ((tty->count == 1) && (state->count != 1)) {
+ /*
+ * Uh, oh. tty->count is 1, which means that the tty
+ * structure will be freed. state->count should always
+ * be one in these conditions. If it's greater than
+ * one, we've got real problems, since it means the
+ * serial port won't be shutdown.
+ */
+ printk("uart_close: bad serial port count; tty->count is 1, "
+ "state->count is %d\n", state->count);
+ state->count = 1;
+ }
+ if (--state->count < 0) {
+ printk("rs_close: bad serial port count for %s%d: %d\n",
+ tty->driver.name, port->line, state->count);
+ state->count = 0;
+ }
+ if (state->count)
+ goto done;
+
+ /*
+ * Save the termios structure, since this port may have
+ * separate termios for callout and dialin.
+ */
+ if (state->info->flags & UIF_NORMAL_ACTIVE)
+ state->normal_termios = *tty->termios;
+ if (state->info->flags & UIF_CALLOUT_ACTIVE)
+ state->callout_termios = *tty->termios;
+
+ /*
+ * Now we wait for the transmit buffer to clear; and we notify
+ * the line discipline to only process XON/XOFF characters by
+ * setting tty->closing.
+ */
+ tty->closing = 1;
+
+ if (state->closing_wait != USF_CLOSING_WAIT_NONE)
+ tty_wait_until_sent(tty, state->closing_wait);
+
+ /*
+ * At this point, we stop accepting input. To do this, we
+ * disable the receive line status interrupts.
+ */
+ if (state->info->flags & UIF_INITIALIZED) {
+ unsigned long flags;
+ spin_lock_irqsave(&port->lock, flags);
+ port->ops->stop_rx(port);
+ spin_unlock_irqrestore(&port->lock, flags);
+ /*
+ * Before we drop DTR, make sure the UART transmitter
+ * has completely drained; this is especially
+ * important if there is a transmit FIFO!
+ */
+ uart_wait_until_sent(tty, port->timeout);
+ }
+
+ uart_shutdown(state);
+ uart_flush_buffer(tty);
+ if (tty->ldisc.flush_buffer)
+ tty->ldisc.flush_buffer(tty);
+ tty->closing = 0;
+ state->info->tty = NULL;
+
+ if (state->info->blocked_open) {
+ if (state->close_delay) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(state->close_delay);
+ set_current_state(TASK_RUNNING);
+ }
+ } else if (!uart_console(port)) {
+ uart_change_pm(state, 3);
+ }
+
+ /*
+ * Wake up anyone trying to open this port.
+ */
+ state->info->flags &= ~(UIF_NORMAL_ACTIVE|UIF_CALLOUT_ACTIVE);
+ wake_up_interruptible(&state->info->open_wait);
+
+ done:
+ up(&state->sem);
+ if (drv->owner)
+ __MOD_DEC_USE_COUNT(drv->owner);
+}
+
+static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
+{
+ struct uart_state *state = tty->driver_data;
+ struct uart_port *port = state->port;
+ unsigned long char_time, expire;
+
+ BUG_ON(!kernel_locked());
+
+ if (port->type == PORT_UNKNOWN || port->fifosize == 0)
+ return;
+
+ /*
+ * Set the check interval to be 1/5 of the estimated time to
+ * send a single character, and make it at least 1. The check
+ * interval should also be less than the timeout.
+ *
+ * Note: we have to use pretty tight timings here to satisfy
+ * the NIST-PCTS.
+ */
+ char_time = (port->timeout - HZ/50) / port->fifosize;
+ char_time = char_time / 5;
+ if (char_time == 0)
+ char_time = 1;
+ if (timeout && timeout < char_time)
+ char_time = timeout;
+
+ /*
+ * If the transmitter hasn't cleared in twice the approximate
+ * amount of time to send the entire FIFO, it probably won't
+ * ever clear. This assumes the UART isn't doing flow
+ * control, which is currently the case. Hence, if it ever
+ * takes longer than port->timeout, this is probably due to a
+ * UART bug of some kind. So, we clamp the timeout parameter at
+ * 2*port->timeout.
+ */
+ if (timeout == 0 || timeout > 2 * port->timeout)
+ timeout = 2 * port->timeout;
+
+ expire = jiffies + timeout;
+
+ DPRINTK("uart_wait_until_sent(%d), jiffies=%lu, expire=%lu...\n",
+ port->line, jiffies, expire);
+
+ /*
+ * Check whether the transmitter is empty every 'char_time'.
+ * 'timeout' / 'expire' give us the maximum amount of time
+ * we wait.
+ */
+ while (!port->ops->tx_empty(port)) {
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(char_time);
+ if (signal_pending(current))
+ break;
+ if (time_after(jiffies, expire))
+ break;
+ }
+ set_current_state(TASK_RUNNING); /* might not be needed */
+}
+
+/*
+ * This is called with the BKL held in
+ * linux/drivers/char/tty_io.c:do_tty_hangup()
+ * We're called from the eventd thread, so we can sleep for
+ * a _short_ time only.
+ */
+static void uart_hangup(struct tty_struct *tty)
+{
+ struct uart_state *state = tty->driver_data;
+
+ BUG_ON(!kernel_locked());
+ DPRINTK("uart_hangup(%d)\n", state->port->line);
+
+ down(&state->sem);
+ if (state->info && state->info->flags & (UIF_NORMAL_ACTIVE|UIF_CALLOUT_ACTIVE)) {
+ uart_flush_buffer(tty);
+ uart_shutdown(state);
+ state->count = 0;
+ state->info->flags &= ~(UIF_NORMAL_ACTIVE|UIF_CALLOUT_ACTIVE);
+ state->info->tty = NULL;
+ wake_up_interruptible(&state->info->open_wait);
+ wake_up_interruptible(&state->info->delta_msr_wait);
+ }
+ up(&state->sem);
+}
+
+/*
+ * Copy across the serial console cflag setting into the termios settings
+ * for the initial open of the port. This allows continuity between the
+ * kernel settings, and the settings init adopts when it opens the port
+ * for the first time.
+ */
+static void uart_update_termios(struct uart_state *state)
+{
+ struct tty_struct *tty = state->info->tty;
+ struct uart_port *port = state->port;
+
+ if (uart_console(port) && port->cons->cflag) {
+ tty->termios->c_cflag = port->cons->cflag;
+ port->cons->cflag = 0;
+ }
+
+ /*
+ * If the device failed to grab its irq resources,
+ * or some other error occurred, don't try to talk
+ * to the port hardware.
+ */
+ if (!(tty->flags & (1 << TTY_IO_ERROR))) {
+ /*
+ * Make termios settings take effect.
+ */
+ uart_change_speed(state, NULL);
+
+ /*
+ * And finally enable the RTS and DTR signals.
+ */
+ if (tty->termios->c_cflag & CBAUD)
+ uart_set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
+ }
+}
+
+/*
+ * Block the open until the port is ready. We must be called with
+ * the per-port semaphore held.
+ */
+static int
+uart_block_til_ready(struct file *filp, struct uart_state *state)
+{
+ DECLARE_WAITQUEUE(wait, current);
+ struct uart_info *info = state->info;
+ struct uart_port *port = state->port;
+ struct termios *termios;
+
+ /*
+ * If this is a callout device, then just make sure the normal
+ * device isn't being used.
+ */
+ if (info->tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
+ if (info->flags & UIF_NORMAL_ACTIVE)
+ return -EBUSY;
+ if ((info->flags & UIF_CALLOUT_ACTIVE) &&
+ (info->flags & ASYNC_SESSION_LOCKOUT) &&
+ (info->session != current->session))
+ return -EBUSY;
+ if ((info->flags & UIF_CALLOUT_ACTIVE) &&
+ (info->flags & ASYNC_PGRP_LOCKOUT) &&
+ (info->pgrp != current->pgrp))
+ return -EBUSY;
+ info->flags |= UIF_CALLOUT_ACTIVE;
+ return 0;
+ }
+
+ if (info->flags & UIF_CALLOUT_ACTIVE) {
+ termios = &state->normal_termios;
+ } else {
+ termios = state->info->tty->termios;
+ }
+
+ info->blocked_open++;
+ state->count--;
+
+ add_wait_queue(&info->open_wait, &wait);
+ while (1) {
+ set_current_state(TASK_INTERRUPTIBLE);
+
+ /*
+ * If we have been hung up, tell userspace/restart open.
+ */
+ if (tty_hung_up_p(filp) || info->tty == NULL)
+ break;
+
+ /*
+ * If the port has been closed, tell userspace/restart open.
+ */
+ if (!(info->flags & UIF_INITIALIZED))
+ break;
+
+ /*
+ * If non-blocking mode is set, or CLOCAL mode is set,
+ * we don't want to wait for the modem status lines to
+ * indicate that the port is ready.
+ *
+ * Also, if the port is not enabled/configured, we want
+ * to allow the open to succeed here. Note that we will
+ * have set TTY_IO_ERROR for a non-existant port.
+ */
+ if ((filp->f_flags & O_NONBLOCK) ||
+ (termios->c_cflag & CLOCAL) ||
+ (info->tty->flags & (1 << TTY_IO_ERROR))) {
+ break;
+ }
+
+ if (!(info->flags & UIF_CALLOUT_ACTIVE)) {
+ /*
+ * Set DTR to allow modem to know we're waiting. Do
+ * not set RTS here - we want to make sure we catch
+ * the data from the modem.
+ */
+ if (info->tty->termios->c_cflag & CBAUD)
+ uart_set_mctrl(port, TIOCM_DTR);
+
+ /*
+ * and wait for the carrier to indicate that the
+ * modem is ready for us.
+ */
+ if (port->ops->get_mctrl(port) & TIOCM_CAR)
+ break;
+ }
+
+ up(&state->sem);
+ schedule();
+ down(&state->sem);
+
+ if (signal_pending(current))
+ break;
+ }
+ set_current_state(TASK_RUNNING);
+ remove_wait_queue(&info->open_wait, &wait);
+
+ state->count++;
+ info->blocked_open--;
+
+ info->flags |= UIF_NORMAL_ACTIVE;
+
+ if (signal_pending(current))
+ return -ERESTARTSYS;
+
+ if (!info->tty || tty_hung_up_p(filp))
+ return -EAGAIN;
+
+ return 0;
+}
+
+static struct uart_state *uart_get(struct uart_driver *drv, int line)
+{
+ struct uart_state *state;
+
+ down(&port_sem);
+ state = drv->state + line;
+ if (down_interruptible(&state->sem)) {
+ state = ERR_PTR(-ERESTARTSYS);
+ goto out;
+ }
+
+ state->count++;
+ if (!state->port) {
+ state->count--;
+ up(&state->sem);
+ state = ERR_PTR(-ENXIO);
+ goto out;
+ }
+
+ if (!state->info) {
+ state->info = kmalloc(sizeof(struct uart_info), GFP_KERNEL);
+ if (state->info) {
+ memset(state->info, 0, sizeof(struct uart_info));
+ init_waitqueue_head(&state->info->open_wait);
+ init_waitqueue_head(&state->info->delta_msr_wait);
+
+ /*
+ * Link the info into the other structures.
+ */
+ state->port->info = state->info;
+
+ tasklet_init(&state->info->tlet, uart_tasklet_action,
+ (unsigned long)state);
+ } else {
+ state->count--;
+ up(&state->sem);
+ state = ERR_PTR(-ENOMEM);
+ }
+ }
+
+ out:
+ up(&port_sem);
+ return state;
+}
+
+/*
+ * In 2.4.5, calls to uart_open are serialised by the BKL in
+ * linux/fs/devices.c:chrdev_open()
+ * Note that if this fails, then uart_close() _will_ be called.
+ */
+static int uart_open(struct tty_struct *tty, struct file *filp)
+{
+ struct uart_driver *drv = (struct uart_driver *)tty->driver.driver_state;
+ struct uart_state *state;
+ int retval, line = MINOR(tty->device) - tty->driver.minor_start;
+
+ BUG_ON(!kernel_locked());
+ DPRINTK("uart_open(%d) called\n", line);
+
+ /*
+ * tty->driver->num won't change, so we won't fail here with
+ * tty->driver_data set to something non-NULL (and therefore
+ * we won't get caught by uart_close()).
+ */
+ retval = -ENODEV;
+ if (line >= tty->driver.num)
+ goto fail;
+
+ if (!try_inc_mod_count(drv->owner))
+ goto fail;
+
+ /*
+ * We take the semaphore inside uart_get to guarantee that we won't
+ * be re-entered while allocating the info structure, or while we
+ * request any IRQs that the driver may need. This also has the nice
+ * side-effect that it delays the action of uart_hangup, so we can
+ * guarantee that info->tty will always contain something reasonable.
+ */
+ state = uart_get(drv, line);
+ if (IS_ERR(state)) {
+ retval = PTR_ERR(state);
+ if (!tty->driver_data)
+ goto out;
+ else
+ goto fail;
+ }
+
+ /*
+ * Once we set tty->driver_data here, we are guaranteed that
+ * uart_close() will decrement the driver module use count.
+ * Any failures from here onwards should not touch the count.
+ */
+ tty->driver_data = state;
+ tty->low_latency = (state->port->flags & UPF_LOW_LATENCY) ? 1 : 0;
+ tty->alt_speed = uart_get_altspeed(state->port);
+ state->info->tty = tty;
+
+ /*
+ * If the port is in the middle of closing, bail out now.
+ */
+ if (tty_hung_up_p(filp)) {
+ retval = -EAGAIN;
+ state->count--;
+ up(&state->sem);
+ goto fail;
+ }
+
+ /*
+ * Make sure the device is in D0 state.
+ */
+ if (state->count == 1)
+ uart_change_pm(state, 0);
+
+ /*
+ * Start up the serial port.
+ */
+ retval = uart_startup(state, 0);
+
+ /*
+ * If we succeeded, wait until the port is ready.
+ */
+ if (retval == 0)
+ retval = uart_block_til_ready(filp, state);
+
+ /*
+ * If this is the first open to succeed, adjust things to suit.
+ */
+ if (retval == 0 && state->count == 1) {
+ if (state->port->flags & UPF_SPLIT_TERMIOS) {
+ if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
+ *tty->termios = state->normal_termios;
+ else
+ *tty->termios = state->callout_termios;
+ }
+
+ uart_update_termios(state);
+
+ state->info->session = current->session;
+ state->info->pgrp = current->pgrp;
+ }
+ up(&state->sem);
+
+ return 0;
+
+ out:
+ if (drv->owner)
+ __MOD_DEC_USE_COUNT(drv->owner);
+ fail:
+ return retval;
+}
+
+static const char *uart_type(struct uart_port *port)
+{
+ const char *str = NULL;
+
+ if (port->ops->type)
+ str = port->ops->type(port);
+
+ if (!str)
+ str = "unknown";
+
+ return str;
+}
+
+#ifdef CONFIG_PROC_FS
+
+static int uart_line_info(char *buf, struct uart_driver *drv, int i)
+{
+ struct uart_state *state = drv->state + i;
+ struct uart_port *port = state->port;
+ char stat_buf[32];
+ unsigned int status;
+ int ret;
+
+ if (!port)
+ return 0;
+
+ ret = sprintf(buf, "%d: uart:%s port:%08X irq:%d",
+ port->line, uart_type(port),
+ port->iobase, port->irq);
+
+ if (port->type == PORT_UNKNOWN) {
+ strcat(buf, "\n");
+ return ret + 1;
+ }
+
+ status = port->ops->get_mctrl(port);
+
+ ret += sprintf(buf + ret, " tx:%d rx:%d",
+ port->icount.tx, port->icount.rx);
+ if (port->icount.frame)
+ ret += sprintf(buf + ret, " fe:%d",
+ port->icount.frame);
+ if (port->icount.parity)
+ ret += sprintf(buf + ret, " pe:%d",
+ port->icount.parity);
+ if (port->icount.brk)
+ ret += sprintf(buf + ret, " brk:%d",
+ port->icount.brk);
+ if (port->icount.overrun)
+ ret += sprintf(buf + ret, " oe:%d",
+ port->icount.overrun);
+
+#define INFOBIT(bit,str) \
+ if (port->mctrl & (bit)) \
+ strcat(stat_buf, (str))
+#define STATBIT(bit,str) \
+ if (status & (bit)) \
+ strcat(stat_buf, (str))
+
+ stat_buf[0] = '\0';
+ stat_buf[1] = '\0';
+ INFOBIT(TIOCM_RTS, "|RTS");
+ STATBIT(TIOCM_CTS, "|CTS");
+ INFOBIT(TIOCM_DTR, "|DTR");
+ STATBIT(TIOCM_DSR, "|DSR");
+ STATBIT(TIOCM_CAR, "|CD");
+ STATBIT(TIOCM_RNG, "|RI");
+ if (stat_buf[0])
+ stat_buf[0] = ' ';
+ strcat(stat_buf, "\n");
+
+ ret += sprintf(buf + ret, stat_buf);
+ return ret;
+}
+
+static int uart_read_proc(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct tty_driver *ttydrv = data;
+ struct uart_driver *drv = ttydrv->driver_state;
+ int i, len = 0, l;
+ off_t begin = 0;
+
+ len += sprintf(page, "serinfo:1.0 driver%s%s revision:%s\n",
+ "", "", "");
+ for (i = 0; i < drv->nr && len < PAGE_SIZE - 96; i++) {
+ l = uart_line_info(page + len, drv, i);
+ len += l;
+ if (len + begin > off + count)
+ goto done;
+ if (len + begin < off) {
+ begin += len;
+ len = 0;
+ }
+ }
+ *eof = 1;
+ done:
+ if (off >= len + begin)
+ return 0;
+ *start = page + (off - begin);
+ return (count < begin + len - off) ? count : (begin + len - off);
+}
+#endif
+
+#ifdef CONFIG_SERIAL_CORE_CONSOLE
+/*
+ * Check whether an invalid uart number has been specified, and
+ * if so, search for the first available port that does have
+ * console support.
+ */
+struct uart_port * __init
+uart_get_console(struct uart_port *ports, int nr, struct console *co)
+{
+ int idx = co->index;
+
+ if (idx < 0 || idx >= nr || (ports[idx].iobase == 0 &&
+ ports[idx].membase == NULL))
+ for (idx = 0; idx < nr; idx++)
+ if (ports[idx].iobase != 0 ||
+ ports[idx].membase != NULL)
+ break;
+
+ co->index = idx;
+
+ return ports + idx;
+}
+
+/**
+ * uart_parse_options - Parse serial port baud/parity/bits/flow contro.
+ * @options: pointer to option string
+ * @baud: pointer to an 'int' variable for the baud rate.
+ * @parity: pointer to an 'int' variable for the parity.
+ * @bits: pointer to an 'int' variable for the number of data bits.
+ * @flow: pointer to an 'int' variable for the flow control character.
+ *
+ * uart_parse_options decodes a string containing the serial console
+ * options. The format of the string is <baud><parity><bits><flow>,
+ * eg: 115200n8r
+ */
+void __init
+uart_parse_options(char *options, int *baud, int *parity, int *bits, int *flow)
+{
+ char *s = options;
+
+ *baud = simple_strtoul(s, NULL, 10);
+ while (*s >= '0' && *s <= '9')
+ s++;
+ if (*s)
+ *parity = *s++;
+ if (*s)
+ *bits = *s++ - '0';
+ if (*s)
+ *flow = *s;
+}
+
+struct baud_rates {
+ unsigned int rate;
+ unsigned int cflag;
+};
+
+static struct baud_rates baud_rates[] = {
+ { 921600, B921600 },
+ { 460800, B460800 },
+ { 230400, B230400 },
+ { 115200, B115200 },
+ { 57600, B57600 },
+ { 38400, B38400 },
+ { 19200, B19200 },
+ { 9600, B9600 },
+ { 4800, B4800 },
+ { 2400, B2400 },
+ { 1200, B1200 },
+ { 0, B38400 }
+};
+
+/**
+ * uart_set_options - setup the serial console parameters
+ * @port: pointer to the serial ports uart_port structure
+ * @co: console pointer
+ * @baud: baud rate
+ * @parity: parity character - 'n' (none), 'o' (odd), 'e' (even)
+ * @bits: number of data bits
+ * @flow: flow control character - 'r' (rts)
+ */
+int __init
+uart_set_options(struct uart_port *port, struct console *co,
+ int baud, int parity, int bits, int flow)
+{
+ struct termios termios;
+ unsigned int quot;
+ int i;
+
+ memset(&termios, 0, sizeof(struct termios));
+
+ termios.c_cflag = CREAD | HUPCL | CLOCAL;
+
+ /*
+ * Construct a cflag setting.
+ */
+ for (i = 0; baud_rates[i].rate; i++)
+ if (baud_rates[i].rate <= baud)
+ break;
+
+ termios.c_cflag |= baud_rates[i].cflag;
+ baud = baud_rates[i].rate;
+ if (baud == 0)
+ baud = 38400;
+
+ if (bits == 7)
+ termios.c_cflag |= CS7;
+ else
+ termios.c_cflag |= CS8;
+
+ switch (parity) {
+ case 'o': case 'O':
+ termios.c_cflag |= PARODD;
+ /*fall through*/
+ case 'e': case 'E':
+ termios.c_cflag |= PARENB;
+ break;
+ }
+
+ if (flow == 'r')
+ termios.c_cflag |= CRTSCTS;
+
+ quot = (port->uartclk / (16 * baud));
+ port->ops->change_speed(port, termios.c_cflag, 0, quot);
+ co->cflag = termios.c_cflag;
+
+ return 0;
+}
+
+extern void ambauart_console_init(void);
+extern void anakin_console_init(void);
+extern void clps711xuart_console_init(void);
+extern void sa1100_rs_console_init(void);
+extern void serial8250_console_init(void);
+extern void at91_console_init(void);
+
+/*
+ * Central "initialise all serial consoles" container. Needs to be killed.
+ */
+void __init uart_console_init(void)
+{
+#ifdef CONFIG_SERIAL_AMBA_CONSOLE
+ ambauart_console_init();
+#endif
+#ifdef CONFIG_SERIAL_ANAKIN_CONSOLE
+ anakin_console_init();
+#endif
+#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE
+ clps711xuart_console_init();
+#endif
+#ifdef CONFIG_SERIAL_SA1100_CONSOLE
+ sa1100_rs_console_init();
+#endif
+#ifdef CONFIG_SERIAL_AT91_CONSOLE
+ at91_console_init();
+#endif
+#ifdef CONFIG_SERIAL_8250_CONSOLE
+ serial8250_console_init();
+#endif
+#ifdef CONFIG_SERIAL_UART00_CONSOLE
+ uart00_console_init();
+#endif
+}
+#endif /* CONFIG_SERIAL_CORE_CONSOLE */
+
+static void uart_change_pm(struct uart_state *state, int pm_state)
+{
+ struct uart_port *port = state->port;
+ if (port->ops->pm)
+ port->ops->pm(port, pm_state, 0);
+}
+
+#ifdef CONFIG_PM
+int uart_suspend_port(struct uart_state *state)
+{
+ struct uart_port *port = state->port;
+
+ down(&state->sem);
+ if (port) {
+ /*
+ * Disable the console device before suspending.
+ */
+ if (uart_console(port))
+ port->cons->flags &= ~CON_ENABLED;
+
+ if (state->info && state->info->flags & UIF_INITIALIZED) {
+ struct uart_ops *ops = port->ops;
+
+ spin_lock_irq(&port->lock);
+ ops->stop_tx(port, 0);
+ ops->set_mctrl(port, 0);
+ ops->stop_rx(port);
+ spin_unlock_irq(&port->lock);
+
+ /*
+ * Wait for the transmitter to empty.
+ */
+ while (!ops->tx_empty(port)) {
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(10*HZ/1000);
+ }
+ set_current_state(TASK_RUNNING);
+
+ ops->shutdown(port);
+ }
+
+ uart_change_pm(state, 3);
+ }
+
+ up(&state->sem);
+
+ return 0;
+}
+
+int uart_resume_port(struct uart_state *state)
+{
+ struct uart_port *port = state->port;
+
+ down(&state->sem);
+ if (port) {
+ uart_change_pm(state, 0);
+
+ /*
+ * Re-enable the console device after suspending.
+ */
+ if (uart_console(port)) {
+ uart_change_speed(state, NULL);
+ port->cons->flags |= CON_ENABLED;
+ }
+
+ if (state->info && state->info->flags & UIF_INITIALIZED) {
+ struct uart_ops *ops = port->ops;
+
+ ops->set_mctrl(port, 0);
+ ops->startup(port);
+ uart_change_speed(state, NULL);
+ spin_lock_irq(&port->lock);
+ ops->set_mctrl(port, port->mctrl);
+ ops->start_tx(port, 0);
+ spin_unlock_irq(&port->lock);
+ }
+ }
+
+ up(&state->sem);
+
+ return 0;
+}
+
+/*
+ * Wakeup support.
+ */
+static int uart_pm_set_wakeup(struct uart_state *state, int data)
+{
+ int err = 0;
+
+ if (state->port->ops->set_wake)
+ err = state->port->ops->set_wake(state->port, data);
+
+ return err;
+}
+
+static int uart_pm(struct pm_dev *dev, pm_request_t rqst, void *data)
+{
+ struct uart_state *state = dev->data;
+ int err = 0;
+
+ if (state->port && state->port->type == PORT_UNKNOWN)
+ return 0;
+
+ switch (rqst) {
+ case PM_SUSPEND:
+ err = uart_suspend_port(state);
+ break;
+
+ case PM_RESUME:
+ err = uart_resume_port(state);
+ break;
+
+ case PM_SET_WAKEUP:
+ err = uart_pm_set_wakeup(state, (int)data);
+ break;
+ }
+ return err;
+}
+#endif
+
+static inline void
+uart_report_port(struct uart_driver *drv, struct uart_port *port)
+{
+ printk("%s%d at ", drv->normal_name, port->line);
+ switch (port->iotype) {
+ case UPIO_PORT:
+ printk("I/O 0x%x", port->iobase);
+ break;
+ case UPIO_HUB6:
+ printk("I/O 0x%x offset 0x%x", port->iobase, port->hub6);
+ break;
+ case UPIO_MEM:
+ printk("MMIO 0x%lx", port->mapbase);
+ break;
+ }
+ printk(" (irq = %d) is a %s\n", port->irq, uart_type(port));
+}
+
+static void
+uart_configure_port(struct uart_driver *drv, struct uart_state *state,
+ struct uart_port *port)
+{
+ unsigned int flags;
+
+ /*
+ * If there isn't a port here, don't do anything further.
+ */
+ if (!port->iobase && !port->mapbase && !port->membase)
+ return;
+
+ /*
+ * Now do the auto configuration stuff. Note that config_port
+ * is expected to claim the resources and map the port for us.
+ */
+ flags = UART_CONFIG_TYPE;
+ if (port->flags & UPF_AUTO_IRQ)
+ flags |= UART_CONFIG_IRQ;
+ if (port->flags & UPF_BOOT_AUTOCONF) {
+ port->type = PORT_UNKNOWN;
+ port->ops->config_port(port, flags);
+ }
+
+ if (port->type != PORT_UNKNOWN) {
+ unsigned long flags;
+
+ uart_report_port(drv, port);
+
+ /*
+ * Ensure that the modem control lines are de-activated.
+ * We probably don't need a spinlock around this, but
+ */
+ spin_lock_irqsave(&port->lock, flags);
+ port->ops->set_mctrl(port, 0);
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ /*
+ * Power down all ports by default, except the
+ * console if we have one.
+ */
+ if (!uart_console(port))
+ uart_change_pm(state, 3);
+ }
+}
+
+/*
+ * This reverses the effects of uart_configure_port, hanging up the
+ * port before removal.
+ */
+static void
+uart_unconfigure_port(struct uart_driver *drv, struct uart_state *state)
+{
+ struct uart_port *port = state->port;
+ struct uart_info *info = state->info;
+
+ if (info && info->tty)
+ tty_vhangup(info->tty);
+
+ down(&state->sem);
+
+ state->info = NULL;
+
+ /*
+ * Free the port IO and memory resources, if any.
+ */
+ if (port->type != PORT_UNKNOWN)
+ port->ops->release_port(port);
+
+ /*
+ * Indicate that there isn't a port here anymore.
+ */
+ port->type = PORT_UNKNOWN;
+
+ /*
+ * Kill the tasklet, and free resources.
+ */
+ if (info) {
+ tasklet_kill(&info->tlet);
+ kfree(info);
+ }
+
+ up(&state->sem);
+}
+
+/**
+ * uart_register_driver - register a driver with the uart core layer
+ * @drv: low level driver structure
+ *
+ * Register a uart driver with the core driver. We in turn register
+ * with the tty layer, and initialise the core driver per-port state.
+ *
+ * We have a proc file in /proc/tty/driver which is named after the
+ * normal driver.
+ *
+ * drv->port should be NULL, and the per-port structures should be
+ * registered using uart_add_one_port after this call has succeeded.
+ */
+int uart_register_driver(struct uart_driver *drv)
+{
+ struct tty_driver *normal, *callout;
+ int i, retval;
+
+ BUG_ON(drv->state);
+
+ /*
+ * Maybe we should be using a slab cache for this, especially if
+ * we have a large number of ports to handle. Note that we also
+ * allocate space for an integer for reference counting.
+ */
+ drv->state = kmalloc(sizeof(struct uart_state) * drv->nr +
+ sizeof(int), GFP_KERNEL);
+ retval = -ENOMEM;
+ if (!drv->state)
+ goto out;
+
+ memset(drv->state, 0, sizeof(struct uart_state) * drv->nr +
+ sizeof(int));
+
+ normal = drv->normal_driver;
+ callout = drv->callout_driver;
+
+ normal->magic = TTY_DRIVER_MAGIC;
+ normal->driver_name = drv->normal_name;
+ normal->name = drv->normal_name;
+ normal->major = drv->normal_major;
+ normal->minor_start = drv->minor;
+ normal->num = drv->nr;
+ normal->type = TTY_DRIVER_TYPE_SERIAL;
+ normal->subtype = SERIAL_TYPE_NORMAL;
+ normal->init_termios = tty_std_termios;
+ normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
+ normal->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
+ normal->refcount = (int *)(drv->state + drv->nr);
+ normal->table = drv->table;
+ normal->termios = drv->termios;
+ normal->termios_locked = drv->termios_locked;
+ normal->driver_state = drv;
+
+ normal->open = uart_open;
+ normal->close = uart_close;
+ normal->write = uart_write;
+ normal->put_char = uart_put_char;
+ normal->flush_chars = uart_flush_chars;
+ normal->write_room = uart_write_room;
+ normal->chars_in_buffer = uart_chars_in_buffer;
+ normal->flush_buffer = uart_flush_buffer;
+ normal->ioctl = uart_ioctl;
+ normal->throttle = uart_throttle;
+ normal->unthrottle = uart_unthrottle;
+ normal->send_xchar = uart_send_xchar;
+ normal->set_termios = uart_set_termios;
+ normal->stop = uart_stop;
+ normal->start = uart_start;
+ normal->hangup = uart_hangup;
+ normal->break_ctl = uart_break_ctl;
+ normal->wait_until_sent = uart_wait_until_sent;
+#ifdef CONFIG_PROC_FS
+ normal->read_proc = uart_read_proc;
+#endif
+
+ /*
+ * The callout device is just like the normal device except for
+ * the major number and the subtype code.
+ */
+ *callout = *normal;
+ callout->name = drv->callout_name;
+ callout->major = drv->callout_major;
+ callout->subtype = SERIAL_TYPE_CALLOUT;
+ callout->read_proc = NULL;
+ callout->proc_entry = NULL;
+
+ /*
+ * Initialise the UART state(s).
+ */
+ for (i = 0; i < drv->nr; i++) {
+ struct uart_state *state = drv->state + i;
+
+ state->callout_termios = callout->init_termios;
+ state->normal_termios = normal->init_termios;
+ state->close_delay = 5 * HZ / 10;
+ state->closing_wait = 30 * HZ;
+
+ init_MUTEX(&state->sem);
+ }
+
+ retval = tty_register_driver(normal);
+ if (retval)
+ goto out;
+
+ retval = tty_register_driver(callout);
+ if (retval)
+ tty_unregister_driver(normal);
+
+ out:
+ if (retval < 0) {
+ kfree(drv->state);
+ }
+ return retval;
+}
+
+/**
+ * uart_unregister_driver - remove a driver from the uart core layer
+ * @drv: low level driver structure
+ *
+ * Remove all references to a driver from the core driver. The low
+ * level driver must have removed all its ports via the
+ * uart_remove_one_port() if it registered them with uart_add_one_port().
+ * (ie, drv->port == NULL)
+ */
+void uart_unregister_driver(struct uart_driver *drv)
+{
+ tty_unregister_driver(drv->normal_driver);
+ tty_unregister_driver(drv->callout_driver);
+
+ kfree(drv->state);
+ drv->state = NULL;
+}
+
+/**
+ * uart_add_one_port - attach a driver-defined port structure
+ * @drv: pointer to the uart low level driver structure for this port
+ * @port: uart port structure to use for this port.
+ *
+ * This allows the driver to register its own uart_port structure
+ * with the core driver. The main purpose is to allow the low
+ * level uart drivers to expand uart_port, rather than having yet
+ * more levels of structures.
+ */
+int uart_add_one_port(struct uart_driver *drv, struct uart_port *port)
+{
+ struct uart_state *state;
+ int ret = 0;
+
+ BUG_ON(in_interrupt());
+
+ if (port->line >= drv->nr)
+ return -EINVAL;
+
+ state = drv->state + port->line;
+
+ down(&port_sem);
+ if (state->port) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ state->port = port;
+
+ spin_lock_init(&port->lock);
+ port->cons = drv->cons;
+ port->info = state->info;
+
+ uart_configure_port(drv, state, port);
+
+ /*
+ * Register the port whether it's detected or not. This allows
+ * setserial to be used to alter this ports parameters.
+ */
+ tty_register_devfs(drv->normal_driver, 0, drv->minor + port->line);
+ tty_register_devfs(drv->callout_driver, 0, drv->minor + port->line);
+
+#ifdef CONFIG_PM
+ port->cons = drv->cons;
+ state->pm = pm_register(PM_SYS_DEV, PM_SYS_COM, uart_pm);
+ if (state->pm)
+ state->pm->data = state;
+#endif
+
+ out:
+ up(&port_sem);
+
+ return ret;
+}
+
+/**
+ * uart_remove_one_port - detach a driver defined port structure
+ * @drv: pointer to the uart low level driver structure for this port
+ * @port: uart port structure for this port
+ *
+ * This unhooks (and hangs up) the specified port structure from the
+ * core driver. No further calls will be made to the low-level code
+ * for this port.
+ */
+int uart_remove_one_port(struct uart_driver *drv, struct uart_port *port)
+{
+ struct uart_state *state = drv->state + port->line;
+
+ BUG_ON(in_interrupt());
+
+ if (state->port != port)
+ printk(KERN_ALERT "Removing wrong port: %p != %p\n",
+ state->port, port);
+
+ down(&port_sem);
+
+ pm_unregister(state->pm);
+
+ /*
+ * Remove the devices from devfs
+ */
+ tty_unregister_devfs(drv->normal_driver, drv->minor + port->line);
+ tty_unregister_devfs(drv->callout_driver, drv->minor + port->line);
+
+ uart_unconfigure_port(drv, state);
+ state->port = NULL;
+ up(&port_sem);
+
+ return 0;
+}
+
+/*
+ * Are the two ports equivalent?
+ */
+static int uart_match_port(struct uart_port *port1, struct uart_port *port2)
+{
+ if (port1->iotype != port2->iotype)
+ return 0;
+
+ switch (port1->iotype) {
+ case UPIO_PORT:
+ return (port1->iobase == port2->iobase);
+ case UPIO_HUB6:
+ return (port1->iobase == port2->iobase) &&
+ (port1->hub6 == port2->hub6);
+ case UPIO_MEM:
+ return (port1->membase == port2->membase);
+ }
+ return 0;
+}
+
+/*
+ * Try to find an unused uart_state slot for a port.
+ */
+static struct uart_state *
+uart_find_match_or_unused(struct uart_driver *drv, struct uart_port *port)
+{
+ int i;
+
+ /*
+ * First, find a port entry which matches. Note: if we do
+ * find a matching entry, and it has a non-zero use count,
+ * then we can't register the port.
+ */
+ for (i = 0; i < drv->nr; i++)
+ if (uart_match_port(drv->state[i].port, port))
+ return &drv->state[i];
+
+ /*
+ * We didn't find a matching entry, so look for the first
+ * free entry. We look for one which hasn't been previously
+ * used (indicated by zero iobase).
+ */
+ for (i = 0; i < drv->nr; i++)
+ if (drv->state[i].port->type == PORT_UNKNOWN &&
+ drv->state[i].port->iobase == 0 &&
+ drv->state[i].count == 0)
+ return &drv->state[i];
+
+ /*
+ * That also failed. Last resort is to find any currently
+ * entry which doesn't have a real port associated with it.
+ */
+ for (i = 0; i < drv->nr; i++)
+ if (drv->state[i].port->type == PORT_UNKNOWN &&
+ drv->state[i].count == 0)
+ return &drv->state[i];
+
+ return NULL;
+}
+
+/**
+ * uart_register_port: register uart settings with a port
+ * @drv: pointer to the uart low level driver structure for this port
+ * @port: uart port structure describing the port
+ *
+ * Register UART settings with the specified low level driver. Detect
+ * the type of the port if UPF_BOOT_AUTOCONF is set, and detect the
+ * IRQ if UPF_AUTO_IRQ is set.
+ *
+ * We try to pick the same port for the same IO base address, so that
+ * when a modem is plugged in, unplugged and plugged back in, it gets
+ * allocated the same port.
+ *
+ * Returns negative error, or positive line number.
+ */
+int uart_register_port(struct uart_driver *drv, struct uart_port *port)
+{
+ struct uart_state *state;
+ int ret;
+
+ down(&port_sem);
+
+ state = uart_find_match_or_unused(drv, port);
+
+ if (state) {
+ /*
+ * Ok, we've found a line that we can use.
+ *
+ * If we find a port that matches this one, and it appears
+ * to be in-use (even if it doesn't have a type) we shouldn't
+ * alter it underneath itself - the port may be open and
+ * trying to do useful work.
+ */
+ if (uart_users(state) != 0) {
+ ret = -EBUSY;
+ goto out;
+ }
+
+ /*
+ * If the port is already initialised, don't touch it.
+ */
+ if (state->port->type == PORT_UNKNOWN) {
+ state->port->iobase = port->iobase;
+ state->port->membase = port->membase;
+ state->port->irq = port->irq;
+ state->port->uartclk = port->uartclk;
+ state->port->fifosize = port->fifosize;
+ state->port->regshift = port->regshift;
+ state->port->iotype = port->iotype;
+ state->port->flags = port->flags;
+ state->port->line = state - drv->state;
+ state->port->mapbase = port->mapbase;
+
+ uart_configure_port(drv, state, state->port);
+ }
+
+ ret = state->port->line;
+ } else
+ ret = -ENOSPC;
+ out:
+ up(&port_sem);
+ return ret;
+}
+
+/**
+ * uart_unregister_port - de-allocate a port
+ * @drv: pointer to the uart low level driver structure for this port
+ * @line: line index previously returned from uart_register_port()
+ *
+ * Hang up the specified line associated with the low level driver,
+ * and mark the port as unused.
+ */
+void uart_unregister_port(struct uart_driver *drv, int line)
+{
+ struct uart_state *state;
+
+ if (line < 0 || line >= drv->nr) {
+ printk(KERN_ERR "Attempt to unregister %s%d\n",
+ drv->normal_name, line);
+ return;
+ }
+
+ state = drv->state + line;
+
+ down(&port_sem);
+ uart_unconfigure_port(drv, state);
+ up(&port_sem);
+}
+
+EXPORT_SYMBOL(uart_write_wakeup);
+EXPORT_SYMBOL(uart_register_driver);
+EXPORT_SYMBOL(uart_unregister_driver);
+EXPORT_SYMBOL(uart_register_port);
+EXPORT_SYMBOL(uart_unregister_port);
+EXPORT_SYMBOL(uart_add_one_port);
+EXPORT_SYMBOL(uart_remove_one_port);
+
+MODULE_DESCRIPTION("Serial driver core");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/serial/omaha.c linux-2.4.26-vrs1/drivers/serial/omaha.c
--- linux-2.4.26/drivers/serial/omaha.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/omaha.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,584 @@
+/*
+ * linux/drivers/char/omaha.c
+ *
+ * Driver for Omaha serial port
+ *
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * Copyright 1999-2002 ARM Limited
+ * Copyright (C) 2000 Deep Blue Solutions Ltd.
+ *
+ * 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_amba.c,v 1.4 2001/07/17 20:34:27 rmk Exp $
+ *
+ * This is a generic driver for ARM AMBA-type serial ports. They
+ * have a lot of 16550-like features, but are not register compatable.
+ * Note that although they do have CTS, DCD and DSR inputs, they do
+ * not have an RI input, nor do they have DTR or RTS outputs. If
+ * required, these have to be supplied via some other means (eg, GPIO)
+ * and hooked into this driver.
+ */
+
+#include <linux/config.h>
+#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>
+
+#if defined(CONFIG_SERIAL_OMAHA_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/serial_core.h>
+
+#include <asm/hardware/serial_omaha.h>
+
+#define UART_NR 1
+
+#define SERIAL_OMAHA_MAJOR 204
+#define SERIAL_OMAHA_MINOR 32
+#define SERIAL_OMAHA_NR UART_NR
+
+#define CALLOUT_OMAHA_NAME "cuaom"
+#define CALLOUT_OMAHA_MAJOR 205
+#define CALLOUT_OMAHA_MINOR 32
+#define CALLOUT_OMAHA_NR UART_NR
+
+static struct tty_driver normal, callout;
+static struct tty_struct *omaha_table[UART_NR];
+static struct termios *omaha_termios[UART_NR], *omaha_termios_locked[UART_NR];
+#ifdef SUPPORT_SYSRQ
+static struct console omaha_console;
+#endif
+
+#define OMAHA_ISR_PASS_LIMIT 256
+
+/*
+ * Access macros for the Omaha UARTs
+ */
+
+#define UART_GET_FR(p) readb((p)->membase + OMAHA_UTRSTAT)
+#define UART_GET_CHAR(p) readb((p)->membase + OMAHA_URXH)
+#define UART_PUT_CHAR(p, c) writel((c), (p)->membase + OMAHA_UTXH)
+#define UART_GET_RSR(p) readb((p)->membase + OMAHA_UERSTAT)
+#define UART_FIFO_STATUS(p) (readl((p)->membase + OMAHA_UFSTAT))
+#define UART_RX_DATA(s) (((s) & OMAHA_RXFF_CNT) != 0)
+#define UART_TX_DATA(s) (!((s) & OMAHA_TXFF))
+#define UART_TX_READY(s) (((s) & OMAHA_UTX_EMPTY))
+#define UART_TX_EMPTY(p) ((UART_GET_FR(p) & OMAHA_UTXEMPTY) != 0)
+
+#define UART_DUMMY_RSR_RX 256
+#define UART_PORT_SIZE 64
+
+#define RX_IRQ(port) ((port)->irq)
+#define TX_IRQ(port) ((port)->irq + 5)
+
+/*
+ * Our private driver data mappings.
+ */
+#define drv_old_status driver_priv
+
+static void omahauart_stop_tx(struct uart_port *port, u_int from_tty)
+{
+ disable_irq(TX_IRQ(port));
+}
+
+static void omahauart_start_tx(struct uart_port *port, u_int nonempty, u_int from_tty)
+{
+ if (nonempty)
+ enable_irq(TX_IRQ(port));
+}
+
+static void omahauart_stop_rx(struct uart_port *port)
+{
+ disable_irq(RX_IRQ(port));
+}
+
+static void omahauart_enable_ms(struct uart_port *port)
+{
+ // Do nothing...
+}
+
+static void
+#ifdef SUPPORT_SYSRQ
+omahauart_rx_chars(struct uart_info *info, struct pt_regs *regs)
+#else
+omahauart_rx_chars(struct uart_info *info)
+#endif
+{
+ struct tty_struct *tty = info->tty;
+ volatile unsigned int status, data, ch, rsr, max_count = 256;
+ struct uart_port *port = info->port;
+
+ status = UART_FIFO_STATUS(port);
+ while (UART_RX_DATA(status) && max_count--) {
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+ tty->flip.tqueue.routine((void *)tty);
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+ printk(KERN_WARNING "TTY_DONT_FLIP set\n");
+ return;
+ }
+ }
+
+ ch = UART_GET_CHAR(port);
+
+ *tty->flip.char_buf_ptr = ch;
+ *tty->flip.flag_buf_ptr = TTY_NORMAL;
+ port->icount.rx++;
+
+ /*
+ * Note that the error handling code is
+ * out of the main execution path
+ */
+ rsr = UART_GET_RSR(port) | UART_DUMMY_RSR_RX;
+ if (rsr & 0xf) {
+ if (rsr & OMAHA_UART_BREAK) {
+ rsr &= ~(OMAHA_UART_FRAME | OMAHA_UART_PARITY);
+ port->icount.brk++;
+ if (uart_handle_break(info, &omaha_console))
+ goto ignore_char;
+ } else if (rsr & OMAHA_UART_PARITY)
+ port->icount.parity++;
+ else if (rsr & OMAHA_UART_FRAME)
+ port->icount.frame++;
+ if (rsr & OMAHA_UART_OVERRUN)
+ port->icount.overrun++;
+
+ rsr &= port->read_status_mask;
+
+ if (rsr & OMAHA_UART_BREAK)
+ *tty->flip.flag_buf_ptr = TTY_BREAK;
+ else if (rsr & OMAHA_UART_PARITY)
+ *tty->flip.flag_buf_ptr = TTY_PARITY;
+ else if (rsr & OMAHA_UART_FRAME)
+ *tty->flip.flag_buf_ptr = TTY_FRAME;
+ }
+
+ if (uart_handle_sysrq_char(info, ch, regs))
+ goto ignore_char;
+
+ if ((rsr & port->ignore_status_mask) == 0) {
+ tty->flip.flag_buf_ptr++;
+ tty->flip.char_buf_ptr++;
+ tty->flip.count++;
+ }
+ if ((rsr & OMAHA_UART_OVERRUN) &&
+ tty->flip.count < TTY_FLIPBUF_SIZE) {
+ /*
+ * Overrun is special, since it's reported
+ * immediately, and doesn't affect the current
+ * character
+ */
+ *tty->flip.char_buf_ptr++ = 0;
+ *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
+ tty->flip.count++;
+ }
+ ignore_char:
+ status = UART_FIFO_STATUS(port);
+ }
+ tty_flip_buffer_push(tty);
+ return;
+}
+
+static void omahauart_tx_chars(struct uart_info *info)
+{
+ struct uart_port *port = info->port;
+ volatile unsigned int status;
+
+ if (port->x_char) {
+ 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) {
+ omahauart_stop_tx(port, 0);
+ return;
+ }
+
+ status = UART_FIFO_STATUS(info->port);
+
+ // FIll FIFO as far as possible
+ while(UART_TX_DATA(UART_FIFO_STATUS(info->port)))
+ {
+ 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;
+ }
+
+ 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)
+ omahauart_stop_tx(info->port, 0);
+}
+
+static void omahauart_int_tx(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct uart_info *info = dev_id;
+ volatile unsigned int status, pass_counter = OMAHA_ISR_PASS_LIMIT;
+
+ status = UART_FIFO_STATUS(info->port);
+ do {
+ // TX if FIFO not full
+ if (UART_TX_DATA(status))
+ omahauart_tx_chars(info);
+
+ if (pass_counter-- == 0)
+ break;
+
+ status = UART_FIFO_STATUS(info->port);
+ } while (UART_TX_DATA(status));
+}
+
+static void omahauart_int_rx(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct uart_info *info = dev_id;
+ volatile unsigned int status, pass_counter = OMAHA_ISR_PASS_LIMIT;
+
+ status = UART_FIFO_STATUS(info->port);
+ do {
+ if (UART_RX_DATA(status))
+#ifdef SUPPORT_SYSRQ
+ omahauart_rx_chars(info, regs);
+#else
+ omahauart_rx_chars(info);
+#endif
+
+ if (pass_counter-- == 0)
+ break;
+
+ status = UART_FIFO_STATUS(info->port);
+ } while (UART_RX_DATA(status));
+}
+
+static u_int omahauart_tx_empty(struct uart_port *port)
+{
+ return UART_FIFO_STATUS(port) ? 0 : TIOCSER_TEMT;
+}
+
+static int omahauart_get_mctrl(struct uart_port *port)
+{
+ // Report no errors.
+
+ return 0;
+}
+
+static void omahauart_set_mctrl(struct uart_port *port, u_int mctrl)
+{
+ // Do nothing.
+}
+
+static void omahauart_break_ctl(struct uart_port *port, int break_state)
+{
+ // Do nothing.
+}
+
+static int omahauart_startup(struct uart_port *port, struct uart_info *info)
+{
+ unsigned int tmp;
+ int retval;
+
+ /*
+ * Allocate the IRQs
+ */
+ retval = request_irq(TX_IRQ(port), omahauart_int_tx, 0, "omaha_uart_tx", info);
+ if (retval)
+ return retval;
+
+ retval = request_irq(RX_IRQ(port), omahauart_int_rx, 0, "omaha_uart_rx", info);
+
+ if (retval)
+ {
+ free_irq(TX_IRQ(port), info);
+ return retval;
+ }
+
+ /*
+ * initialise the old status of the modem signals
+ */
+ info->drv_old_status = 0;
+
+ // Clear all errors
+ writel(0, port->membase + OMAHA_UERSTAT);
+
+ // Enable FIFO, 16-byte watermark, also do reset (auto-clearing)
+ writel(0xF7, port->membase + OMAHA_UFCON);
+
+ // Level driven TX/RX ints, with rx timeout enabled
+ tmp = readl(port->membase + OMAHA_UCON);
+ tmp |= 0x280; // rx is pulse driven...
+ writel(tmp, port->membase + OMAHA_UCON);
+
+ return 0;
+}
+
+static void omahauart_shutdown(struct uart_port *port, struct uart_info *info)
+{
+ /*
+ * Free the interrupt
+ */
+ free_irq(TX_IRQ(port), info); /* TX interrupt */
+ free_irq(RX_IRQ(port), info); /* RX interrupt */
+
+}
+
+static void omahauart_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
+{
+ // Do nothing.
+}
+
+static const char *omahauart_type(struct uart_port *port)
+{
+ return port->type == PORT_OMAHA ? "OMAHA" : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'
+ */
+static void omahauart_release_port(struct uart_port *port)
+{
+ release_mem_region(port->mapbase, UART_PORT_SIZE);
+}
+
+/*
+ * Request the memory region(s) being used by 'port'
+ */
+static int omahauart_request_port(struct uart_port *port)
+{
+ return request_mem_region(port->mapbase, UART_PORT_SIZE, "serial_omaha")
+ != NULL ? 0 : -EBUSY;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void omahauart_config_port(struct uart_port *port, int flags)
+{
+ if (flags & UART_CONFIG_TYPE) {
+ port->type = PORT_OMAHA;
+ omahauart_request_port(port);
+ }
+}
+
+/*
+ * verify the new serial_struct (for TIOCSSERIAL).
+ */
+static int omahauart_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+ int ret = 0;
+ if (ser->type != PORT_UNKNOWN && ser->type != PORT_OMAHA)
+ 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 omaha_pops = {
+ .tx_empty = omahauart_tx_empty,
+ .set_mctrl = omahauart_set_mctrl,
+ .get_mctrl = omahauart_get_mctrl,
+ .stop_tx = omahauart_stop_tx,
+ .start_tx = omahauart_start_tx,
+ .stop_rx = omahauart_stop_rx,
+ .enable_ms = omahauart_enable_ms,
+ .break_ctl = omahauart_break_ctl,
+ .startup = omahauart_startup,
+ .shutdown = omahauart_shutdown,
+ .change_speed = omahauart_change_speed,
+ .type = omahauart_type,
+ .release_port = omahauart_release_port,
+ .request_port = omahauart_request_port,
+ .config_port = omahauart_config_port,
+ .verify_port = omahauart_verify_port,
+};
+
+static struct uart_port omaha_ports[UART_NR] = {
+ {
+ .membase = (void *)IO_ADDRESS(OMAHA_UART0_BASE),
+ .mapbase = OMAHA_UART0_BASE,
+ .iotype = SERIAL_IO_MEM,
+ .irq = OMAHA_INT_URXD0,
+ .uartclk = 10000000,
+ .fifosize = 8,
+ .unused = { 4, 5 }, /*Udriver_priv: PORT_CTRLS(5, 4), */
+ .ops = &omaha_pops,
+ .flags = ASYNC_BOOT_AUTOCONF,
+ }
+};
+
+#ifdef CONFIG_SERIAL_OMAHA_CONSOLE
+static void omahauart_console_write(struct console *co, const char *s, u_int count)
+{
+ struct uart_port *port = omaha_ports + co->index;
+ unsigned int status;
+ int i;
+
+ /*
+ * First save the CR then disable the interrupts
+ */
+
+ /*
+ * Now, do each character
+ */
+ for (i = 0; i < count; i++) {
+ do {
+ status = UART_GET_FR(port);
+ } while ((status & OMAHA_UTX_EMPTY) == 0);
+ UART_PUT_CHAR(port, s[i]);
+ if (s[i] == '\n') {
+ do {
+ status = UART_GET_FR(port);
+ } while ((status & OMAHA_UTX_EMPTY) == 0);
+ UART_PUT_CHAR(port, '\r');
+ }
+ }
+
+ /*
+ * Finally, wait for transmitter to become empty
+ * and restore the TCR
+ */
+ do {
+ status = UART_GET_FR(port);
+ } while ((status & OMAHA_UTX_EMPTY) == 0);
+}
+
+static kdev_t omahauart_console_device(struct console *co)
+{
+ return MKDEV(SERIAL_OMAHA_MAJOR, SERIAL_OMAHA_MINOR + co->index);
+}
+
+static int omahauart_console_wait_key(struct console *co)
+{
+ struct uart_port *port = omaha_ports + co->index;
+ unsigned int status;
+
+ do {
+ status = UART_FIFO_STATUS(port);
+ } while (!UART_RX_DATA(status));
+ return UART_GET_CHAR(port);
+}
+
+static void __init
+omahauart_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
+{
+ // Do nothing.
+}
+
+static int __init omahauart_console_setup(struct console *co, char *options)
+{
+ struct uart_port *port;
+ int baud = 38400;
+ int bits = 8;
+ int parity = 'n';
+ int flow = 'n';
+
+ /*
+ * 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(omaha_ports, UART_NR, co);
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+ else
+ omahauart_console_get_options(port, &baud, &parity, &bits);
+
+ return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct console omaha_console = {
+ .write = omahauart_console_write,
+ .device = omahauart_console_device,
+ .wait_key = omahauart_console_wait_key,
+ .setup = omahauart_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = -1,
+};
+
+void __init omahauart_console_init(void)
+{
+ register_console(&omaha_console);
+}
+
+#define OMAHA_CONSOLE &omaha_console
+#else
+#define OMAHA_CONSOLE NULL
+#endif
+
+static struct uart_driver omaha_reg = {
+ .owner = THIS_MODULE,
+ .normal_major = SERIAL_OMAHA_MAJOR,
+#ifdef CONFIG_DEVFS_FS
+ .normal_name = "ttyOM%d",
+ .callout_name = "cuaom%d",
+#else
+ .normal_name = "ttyOM",
+ .callout_name = "cuaom",
+#endif
+ .normal_driver = &normal,
+ .callout_major = CALLOUT_OMAHA_MAJOR,
+ .callout_driver = &callout,
+ .table = omaha_table,
+ .termios = omaha_termios,
+ .termios_locked = omaha_termios_locked,
+ .minor = SERIAL_OMAHA_MINOR,
+ .nr = UART_NR,
+ .port = omaha_ports,
+ .cons = OMAHA_CONSOLE,
+};
+
+static int __init omahauart_init(void)
+{
+ return uart_register_driver(&omaha_reg);
+}
+
+static void __exit omahauart_exit(void)
+{
+ uart_unregister_driver(&omaha_reg);
+}
+
+module_init(omahauart_init);
+module_exit(omahauart_exit);
diff -urN linux-2.4.26/drivers/serial/sa1100.c linux-2.4.26-vrs1/drivers/serial/sa1100.c
--- linux-2.4.26/drivers/serial/sa1100.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/sa1100.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,904 @@
+/*
+ * linux/drivers/char/serial_sa1100.c
+ *
+ * Driver for SA11x0 serial ports
+ *
+ * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
+ *
+ * Copyright (C) 2000 Deep Blue Solutions Ltd.
+ *
+ * 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: sa1100.c,v 1.14.2.4 2002/10/24 09:53:25 rmk Exp $
+ *
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/tty.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/serial.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/hardware.h>
+#include <asm/mach/serial_sa1100.h>
+
+#if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/serial_core.h>
+
+/* We've been assigned a range on the "Low-density serial ports" major */
+#define SERIAL_SA1100_MAJOR 204
+#define CALLOUT_SA1100_MAJOR 205
+#define MINOR_START 5
+
+#define NR_PORTS 3
+
+#define SA1100_ISR_PASS_LIMIT 256
+
+/*
+ * Convert from ignore_status_mask or read_status_mask to UTSR[01]
+ */
+#define SM_TO_UTSR0(x) ((x) & 0xff)
+#define SM_TO_UTSR1(x) ((x) >> 8)
+#define UTSR0_TO_SM(x) ((x))
+#define UTSR1_TO_SM(x) ((x) << 8)
+
+#define UART_GET_UTCR0(sport) __raw_readl((sport)->port.membase + UTCR0)
+#define UART_GET_UTCR1(sport) __raw_readl((sport)->port.membase + UTCR1)
+#define UART_GET_UTCR2(sport) __raw_readl((sport)->port.membase + UTCR2)
+#define UART_GET_UTCR3(sport) __raw_readl((sport)->port.membase + UTCR3)
+#define UART_GET_UTSR0(sport) __raw_readl((sport)->port.membase + UTSR0)
+#define UART_GET_UTSR1(sport) __raw_readl((sport)->port.membase + UTSR1)
+#define UART_GET_CHAR(sport) __raw_readl((sport)->port.membase + UTDR)
+
+#define UART_PUT_UTCR0(sport,v) __raw_writel((v),(sport)->port.membase + UTCR0)
+#define UART_PUT_UTCR1(sport,v) __raw_writel((v),(sport)->port.membase + UTCR1)
+#define UART_PUT_UTCR2(sport,v) __raw_writel((v),(sport)->port.membase + UTCR2)
+#define UART_PUT_UTCR3(sport,v) __raw_writel((v),(sport)->port.membase + UTCR3)
+#define UART_PUT_UTSR0(sport,v) __raw_writel((v),(sport)->port.membase + UTSR0)
+#define UART_PUT_UTSR1(sport,v) __raw_writel((v),(sport)->port.membase + UTSR1)
+#define UART_PUT_CHAR(sport,v) __raw_writel((v),(sport)->port.membase + UTDR)
+
+/*
+ * This is the size of our serial port register set.
+ */
+#define UART_PORT_SIZE 0x24
+
+static struct tty_driver normal, callout;
+static struct tty_struct *sa1100_table[NR_PORTS];
+static struct termios *sa1100_termios[NR_PORTS], *sa1100_termios_locked[NR_PORTS];
+static int (*sa1100_open)(struct uart_port *);
+static void (*sa1100_close)(struct uart_port *);
+#ifdef SUPPORT_SYSRQ
+static struct console sa1100_console;
+#endif
+
+/*
+ * This determines how often we check the modem status signals
+ * for any change. They generally aren't connected to an IRQ
+ * so we have to poll them. We also check immediately before
+ * filling the TX fifo incase CTS has been dropped.
+ */
+#define MCTRL_TIMEOUT (250*HZ/1000)
+
+struct sa1100_port {
+ struct uart_port port;
+ struct timer_list timer;
+ unsigned int old_status;
+};
+
+/*
+ * Handle any change of modem status signal since we were last called.
+ */
+static void sa1100_mctrl_check(struct sa1100_port *sport)
+{
+ unsigned int status, changed;
+
+ status = sport->port.ops->get_mctrl(&sport->port);
+ changed = status ^ sport->old_status;
+
+ if (changed == 0)
+ return;
+
+ sport->old_status = status;
+
+ if (changed & TIOCM_RI)
+ sport->port.icount.rng++;
+ if (changed & TIOCM_DSR)
+ sport->port.icount.dsr++;
+ if (changed & TIOCM_CAR)
+ uart_handle_dcd_change(&sport->port, status & TIOCM_CAR);
+ if (changed & TIOCM_CTS)
+ uart_handle_cts_change(&sport->port, status & TIOCM_CTS);
+
+ wake_up_interruptible(&sport->port.info->delta_msr_wait);
+}
+
+/*
+ * This is our per-port timeout handler, for checking the
+ * modem status signals.
+ */
+static void sa1100_timeout(unsigned long data)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)data;
+ unsigned long flags;
+
+ if (sport->port.info) {
+ spin_lock_irqsave(&sport->port.lock, flags);
+ sa1100_mctrl_check(sport);
+ spin_unlock_irqrestore(&sport->port.lock, flags);
+
+ mod_timer(&sport->timer, jiffies + MCTRL_TIMEOUT);
+ }
+}
+
+/*
+ * interrupts disabled on entry
+ */
+static void sa1100_stop_tx(struct uart_port *port, unsigned int tty_stop)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+ u32 utcr3;
+
+ utcr3 = UART_GET_UTCR3(sport);
+ UART_PUT_UTCR3(sport, utcr3 & ~UTCR3_TIE);
+ sport->port.read_status_mask &= ~UTSR0_TO_SM(UTSR0_TFS);
+}
+
+/*
+ * interrupts may not be disabled on entry
+ */
+static void sa1100_start_tx(struct uart_port *port, unsigned int tty_start)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+ unsigned long flags;
+ u32 utcr3;
+
+ spin_lock_irqsave(&sport->port.lock, flags);
+ utcr3 = UART_GET_UTCR3(sport);
+ sport->port.read_status_mask |= UTSR0_TO_SM(UTSR0_TFS);
+ UART_PUT_UTCR3(sport, utcr3 | UTCR3_TIE);
+ spin_unlock_irqrestore(&sport->port.lock, flags);
+}
+
+/*
+ * Interrupts enabled
+ */
+static void sa1100_stop_rx(struct uart_port *port)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+ u32 utcr3;
+
+ utcr3 = UART_GET_UTCR3(sport);
+ UART_PUT_UTCR3(sport, utcr3 & ~UTCR3_RIE);
+}
+
+/*
+ * Set the modem control timer to fire immediately.
+ */
+static void sa1100_enable_ms(struct uart_port *port)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+
+ mod_timer(&sport->timer, jiffies);
+}
+
+static void
+sa1100_rx_chars(struct sa1100_port *sport, struct pt_regs *regs)
+{
+ struct tty_struct *tty = sport->port.info->tty;
+ unsigned int status, ch, flg, ignored = 0;
+
+ status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
+ UTSR0_TO_SM(UART_GET_UTSR0(sport));
+ while (status & UTSR1_TO_SM(UTSR1_RNE)) {
+ ch = UART_GET_CHAR(sport);
+
+ if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+ goto ignore_char;
+ sport->port.icount.rx++;
+
+ flg = TTY_NORMAL;
+
+ /*
+ * note that the error handling code is
+ * out of the main execution path
+ */
+ if (status & UTSR1_TO_SM(UTSR1_PRE | UTSR1_FRE | UTSR1_ROR))
+ goto handle_error;
+
+ if (uart_handle_sysrq_char(&sport->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 = UTSR1_TO_SM(UART_GET_UTSR1(sport)) |
+ UTSR0_TO_SM(UART_GET_UTSR0(sport));
+ }
+ out:
+ tty_flip_buffer_push(tty);
+ return;
+
+ handle_error:
+ if (status & UTSR1_TO_SM(UTSR1_PRE))
+ sport->port.icount.parity++;
+ else if (status & UTSR1_TO_SM(UTSR1_FRE))
+ sport->port.icount.frame++;
+ if (status & UTSR1_TO_SM(UTSR1_ROR))
+ sport->port.icount.overrun++;
+
+ if (status & sport->port.ignore_status_mask) {
+ if (++ignored > 100)
+ goto out;
+ goto ignore_char;
+ }
+
+ status &= sport->port.read_status_mask;
+
+ if (status & UTSR1_TO_SM(UTSR1_PRE))
+ flg = TTY_PARITY;
+ else if (status & UTSR1_TO_SM(UTSR1_FRE))
+ flg = TTY_FRAME;
+
+ if (status & UTSR1_TO_SM(UTSR1_ROR)) {
+ /*
+ * overrun does *not* affect the character
+ * we read from the FIFO
+ */
+ *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
+ sport->port.sysrq = 0;
+#endif
+ goto error_return;
+}
+
+static void sa1100_tx_chars(struct sa1100_port *sport)
+{
+ struct circ_buf *xmit = &sport->port.info->xmit;
+
+ if (sport->port.x_char) {
+ UART_PUT_CHAR(sport, sport->port.x_char);
+ sport->port.icount.tx++;
+ sport->port.x_char = 0;
+ return;
+ }
+
+ /*
+ * Check the modem control lines before
+ * transmitting anything.
+ */
+ sa1100_mctrl_check(sport);
+
+ if (uart_circ_empty(xmit) || uart_tx_stopped(&sport->port)) {
+ sa1100_stop_tx(&sport->port, 0);
+ return;
+ }
+
+ /*
+ * Tried using FIFO (not checking TNF) for fifo fill:
+ * still had the '4 bytes repeated' problem.
+ */
+ while (UART_GET_UTSR1(sport) & UTSR1_TNF) {
+ UART_PUT_CHAR(sport, xmit->buf[xmit->tail]);
+ xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+ sport->port.icount.tx++;
+ if (uart_circ_empty(xmit))
+ break;
+ }
+
+ if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+ uart_write_wakeup(&sport->port);
+
+ if (uart_circ_empty(xmit))
+ sa1100_stop_tx(&sport->port, 0);
+}
+
+static void sa1100_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct sa1100_port *sport = dev_id;
+ unsigned int status, pass_counter = 0;
+
+ spin_lock(&sport->port.lock);
+ status = UART_GET_UTSR0(sport);
+ status &= SM_TO_UTSR0(sport->port.read_status_mask) | ~UTSR0_TFS;
+ do {
+ if (status & (UTSR0_RFS | UTSR0_RID)) {
+ /* Clear the receiver idle bit, if set */
+ if (status & UTSR0_RID)
+ UART_PUT_UTSR0(sport, UTSR0_RID);
+ sa1100_rx_chars(sport, regs);
+ }
+
+ /* Clear the relevant break bits */
+ if (status & (UTSR0_RBB | UTSR0_REB))
+ UART_PUT_UTSR0(sport, status & (UTSR0_RBB | UTSR0_REB));
+
+ if (status & UTSR0_RBB)
+ sport->port.icount.brk++;
+
+ if (status & UTSR0_REB)
+ uart_handle_break(&sport->port);
+
+ if (status & UTSR0_TFS)
+ sa1100_tx_chars(sport);
+ if (pass_counter++ > SA1100_ISR_PASS_LIMIT)
+ break;
+ status = UART_GET_UTSR0(sport);
+ status &= SM_TO_UTSR0(sport->port.read_status_mask) |
+ ~UTSR0_TFS;
+ } while (status & (UTSR0_TFS | UTSR0_RFS | UTSR0_RID));
+ spin_unlock(&sport->port.lock);
+}
+
+/*
+ * Return TIOCSER_TEMT when transmitter is not busy.
+ */
+static unsigned int sa1100_tx_empty(struct uart_port *port)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+
+ return UART_GET_UTSR1(sport) & UTSR1_TBY ? 0 : TIOCSER_TEMT;
+}
+
+static unsigned int sa1100_get_mctrl(struct uart_port *port)
+{
+ return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
+}
+
+static void sa1100_set_mctrl(struct uart_port *port, unsigned int mctrl)
+{
+}
+
+/*
+ * Interrupts always disabled.
+ */
+static void sa1100_break_ctl(struct uart_port *port, int break_state)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+ unsigned long flags;
+ unsigned int utcr3;
+
+ spin_lock_irqsave(&sport->port.lock, flags);
+ utcr3 = UART_GET_UTCR3(sport);
+ if (break_state == -1)
+ utcr3 |= UTCR3_BRK;
+ else
+ utcr3 &= ~UTCR3_BRK;
+ UART_PUT_UTCR3(sport, utcr3);
+ spin_unlock_irqrestore(&sport->port.lock, flags);
+}
+
+static int sa1100_startup(struct uart_port *port)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+ int retval;
+
+ /*
+ * Allocate the IRQ
+ */
+ retval = request_irq(sport->port.irq, sa1100_int, 0,
+ "sa11x0-uart", sport);
+ if (retval)
+ return retval;
+
+ /*
+ * If there is a specific "open" function
+ * (to register control line interrupts)
+ */
+ if (sa1100_open) {
+ retval = sa1100_open(port);
+ if (retval) {
+ free_irq(sport->port.irq, sport);
+ return retval;
+ }
+ }
+
+ /*
+ * Finally, clear and enable interrupts
+ */
+ UART_PUT_UTSR0(sport, -1);
+ UART_PUT_UTCR3(sport, UTCR3_RXE | UTCR3_TXE | UTCR3_RIE);
+
+ return 0;
+}
+
+static void sa1100_shutdown(struct uart_port *port)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+
+ /*
+ * Stop our timer.
+ */
+ del_timer_sync(&sport->timer);
+
+ /*
+ * Free the interrupt
+ */
+ free_irq(sport->port.irq, sport);
+
+ /*
+ * If there is a specific "close" function (to unregister
+ * control line interrupts)
+ */
+ if (sa1100_close)
+ sa1100_close(port);
+
+ /*
+ * Disable all interrupts, port and break condition.
+ */
+ UART_PUT_UTCR3(sport, 0);
+}
+
+static void sa1100_change_speed(struct uart_port *port, unsigned int cflag, unsigned int iflag, unsigned int quot)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+ unsigned long flags;
+ unsigned int utcr0, old_utcr3;
+
+ if ((cflag & CSIZE) == CS8)
+ utcr0 = UTCR0_DSS;
+ else
+ utcr0 = 0;
+
+ if (cflag & CSTOPB)
+ utcr0 |= UTCR0_SBS;
+ if (cflag & PARENB) {
+ utcr0 |= UTCR0_PE;
+ if (!(cflag & PARODD))
+ utcr0 |= UTCR0_OES;
+ }
+
+ spin_lock_irqsave(&sport->port.lock, flags);
+
+ sport->port.read_status_mask &= UTSR0_TO_SM(UTSR0_TFS);
+ sport->port.read_status_mask |= UTSR1_TO_SM(UTSR1_ROR);
+ if (iflag & INPCK)
+ sport->port.read_status_mask |=
+ UTSR1_TO_SM(UTSR1_FRE | UTSR1_PRE);
+ if (iflag & (BRKINT | PARMRK))
+ sport->port.read_status_mask |=
+ UTSR0_TO_SM(UTSR0_RBB | UTSR0_REB);
+
+ /*
+ * Characters to ignore
+ */
+ sport->port.ignore_status_mask = 0;
+ if (iflag & IGNPAR)
+ sport->port.ignore_status_mask |=
+ UTSR1_TO_SM(UTSR1_FRE | UTSR1_PRE);
+ if (iflag & IGNBRK) {
+ sport->port.ignore_status_mask |=
+ UTSR0_TO_SM(UTSR0_RBB | UTSR0_REB);
+ /*
+ * If we're ignoring parity and break indicators,
+ * ignore overruns too (for real raw support).
+ */
+ if (iflag & IGNPAR)
+ sport->port.ignore_status_mask |=
+ UTSR1_TO_SM(UTSR1_ROR);
+ }
+
+ del_timer_sync(&sport->timer);
+
+ /*
+ * disable interrupts and drain transmitter
+ */
+ old_utcr3 = UART_GET_UTCR3(sport);
+ UART_PUT_UTCR3(sport, old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE));
+
+ while (UART_GET_UTSR1(sport) & UTSR1_TBY)
+ barrier();
+
+ /* then, disable everything */
+ UART_PUT_UTCR3(sport, 0);
+
+ /* set the parity, stop bits and data size */
+ UART_PUT_UTCR0(sport, utcr0);
+
+ /* set the baud rate */
+ quot -= 1;
+ UART_PUT_UTCR1(sport, ((quot & 0xf00) >> 8));
+ UART_PUT_UTCR2(sport, (quot & 0xff));
+
+ UART_PUT_UTSR0(sport, -1);
+
+ UART_PUT_UTCR3(sport, old_utcr3);
+
+ if (UART_ENABLE_MS(&sport->port, cflag))
+ sa1100_enable_ms(&sport->port);
+
+ spin_unlock_irqrestore(&sport->port.lock, flags);
+}
+
+static const char *sa1100_type(struct uart_port *port)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+
+ return sport->port.type == PORT_SA1100 ? "SA1100" : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'.
+ */
+static void sa1100_release_port(struct uart_port *port)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+
+ release_mem_region(sport->port.mapbase, UART_PORT_SIZE);
+}
+
+/*
+ * Request the memory region(s) being used by 'port'.
+ */
+static int sa1100_request_port(struct uart_port *port)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+
+ return request_mem_region(sport->port.mapbase, UART_PORT_SIZE,
+ "sa11x0-uart") != NULL ? 0 : -EBUSY;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void sa1100_config_port(struct uart_port *port, int flags)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+
+ if (flags & UART_CONFIG_TYPE &&
+ sa1100_request_port(&sport->port) == 0)
+ sport->port.type = PORT_SA1100;
+}
+
+/*
+ * Verify the new serial_struct (for TIOCSSERIAL).
+ * The only change we allow are to the flags and type, and
+ * even then only between PORT_SA1100 and PORT_UNKNOWN
+ */
+static int sa1100_verify_port(struct uart_port *port, struct serial_struct *ser)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+ int ret = 0;
+
+ if (ser->type != PORT_UNKNOWN && ser->type != PORT_SA1100)
+ ret = -EINVAL;
+ if (sport->port.irq != ser->irq)
+ ret = -EINVAL;
+ if (ser->io_type != SERIAL_IO_MEM)
+ ret = -EINVAL;
+ if (sport->port.uartclk / 16 != ser->baud_base)
+ ret = -EINVAL;
+ if ((void *)sport->port.mapbase != ser->iomem_base)
+ ret = -EINVAL;
+ if (sport->port.iobase != ser->port)
+ ret = -EINVAL;
+ if (ser->hub6 != 0)
+ ret = -EINVAL;
+ return ret;
+}
+
+static struct uart_ops sa1100_pops = {
+ .tx_empty = sa1100_tx_empty,
+ .set_mctrl = sa1100_set_mctrl,
+ .get_mctrl = sa1100_get_mctrl,
+ .stop_tx = sa1100_stop_tx,
+ .start_tx = sa1100_start_tx,
+ .stop_rx = sa1100_stop_rx,
+ .enable_ms = sa1100_enable_ms,
+ .break_ctl = sa1100_break_ctl,
+ .startup = sa1100_startup,
+ .shutdown = sa1100_shutdown,
+ .change_speed = sa1100_change_speed,
+ .type = sa1100_type,
+ .release_port = sa1100_release_port,
+ .request_port = sa1100_request_port,
+ .config_port = sa1100_config_port,
+ .verify_port = sa1100_verify_port,
+};
+
+static struct sa1100_port sa1100_ports[NR_PORTS];
+
+/*
+ * Setup the SA1100 serial ports. Note that we don't include the IrDA
+ * port here since we have our own SIR/FIR driver (see drivers/net/irda)
+ *
+ * Note also that we support "console=ttySAx" where "x" is either 0 or 1.
+ * Which serial port this ends up being depends on the machine you're
+ * running this kernel on. I'm not convinced that this is a good idea,
+ * but that's the way it traditionally works.
+ *
+ * Note that NanoEngine UART3 becomes UART2, and UART2 is no longer
+ * used here.
+ */
+static void __init sa1100_init_ports(void)
+{
+ static int first = 1;
+ int i;
+
+ if (!first)
+ return;
+ first = 0;
+
+ for (i = 0; i < NR_PORTS; i++) {
+ sa1100_ports[i].port.uartclk = 3686400;
+ sa1100_ports[i].port.ops = &sa1100_pops;
+ sa1100_ports[i].port.fifosize = 8;
+ sa1100_ports[i].port.line = i;
+ sa1100_ports[i].port.iotype = SERIAL_IO_MEM;
+ init_timer(&sa1100_ports[i].timer);
+ sa1100_ports[i].timer.function = sa1100_timeout;
+ sa1100_ports[i].timer.data = (unsigned long)&sa1100_ports[i];
+ }
+
+ /*
+ * make transmit lines outputs, so that when the port
+ * is closed, the output is in the MARK state.
+ */
+ PPDR |= PPC_TXD1 | PPC_TXD3;
+ PPSR |= PPC_TXD1 | PPC_TXD3;
+}
+
+void __init sa1100_register_uart_fns(struct sa1100_port_fns *fns)
+{
+ if (fns->enable_ms)
+ sa1100_pops.enable_ms = fns->enable_ms;
+ if (fns->get_mctrl)
+ sa1100_pops.get_mctrl = fns->get_mctrl;
+ if (fns->set_mctrl)
+ sa1100_pops.set_mctrl = fns->set_mctrl;
+ sa1100_open = fns->open;
+ sa1100_close = fns->close;
+ sa1100_pops.pm = fns->pm;
+ sa1100_pops.set_wake = fns->set_wake;
+}
+
+void __init sa1100_register_uart(int idx, int port)
+{
+ if (idx >= NR_PORTS) {
+ printk(KERN_ERR "%s: bad index number %d\n", __FUNCTION__, idx);
+ return;
+ }
+
+ switch (port) {
+ case 1:
+ sa1100_ports[idx].port.membase = (void *)&Ser1UTCR0;
+ sa1100_ports[idx].port.mapbase = _Ser1UTCR0;
+ sa1100_ports[idx].port.irq = IRQ_Ser1UART;
+ sa1100_ports[idx].port.flags = ASYNC_BOOT_AUTOCONF;
+ break;
+
+ case 2:
+ sa1100_ports[idx].port.membase = (void *)&Ser2UTCR0;
+ sa1100_ports[idx].port.mapbase = _Ser2UTCR0;
+ sa1100_ports[idx].port.irq = IRQ_Ser2ICP;
+ sa1100_ports[idx].port.flags = ASYNC_BOOT_AUTOCONF;
+ break;
+
+ case 3:
+ sa1100_ports[idx].port.membase = (void *)&Ser3UTCR0;
+ sa1100_ports[idx].port.mapbase = _Ser3UTCR0;
+ sa1100_ports[idx].port.irq = IRQ_Ser3UART;
+ sa1100_ports[idx].port.flags = ASYNC_BOOT_AUTOCONF;
+ break;
+
+ default:
+ printk(KERN_ERR "%s: bad port number %d\n", __FUNCTION__, port);
+ }
+}
+
+
+#ifdef CONFIG_SERIAL_SA1100_CONSOLE
+
+/*
+ * Interrupts are disabled on entering
+ */
+static void
+sa1100_console_write(struct console *co, const char *s, unsigned int count)
+{
+ struct sa1100_port *sport = &sa1100_ports[co->index];
+ unsigned int old_utcr3, status, i;
+
+ /*
+ * First, save UTCR3 and then disable interrupts
+ */
+ old_utcr3 = UART_GET_UTCR3(sport);
+ UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) |
+ UTCR3_TXE);
+
+ /*
+ * Now, do each character
+ */
+ for (i = 0; i < count; i++) {
+ do {
+ status = UART_GET_UTSR1(sport);
+ } while (!(status & UTSR1_TNF));
+ UART_PUT_CHAR(sport, s[i]);
+ if (s[i] == '\n') {
+ do {
+ status = UART_GET_UTSR1(sport);
+ } while (!(status & UTSR1_TNF));
+ UART_PUT_CHAR(sport, '\r');
+ }
+ }
+
+ /*
+ * Finally, wait for transmitter to become empty
+ * and restore UTCR3
+ */
+ do {
+ status = UART_GET_UTSR1(sport);
+ } while (status & UTSR1_TBY);
+ UART_PUT_UTCR3(sport, old_utcr3);
+}
+
+static kdev_t sa1100_console_device(struct console *co)
+{
+ return MKDEV(SERIAL_SA1100_MAJOR, MINOR_START + co->index);
+}
+
+/*
+ * If the port was already initialised (eg, by a boot loader), try to determine
+ * the current setup.
+ */
+static void __init
+sa1100_console_get_options(struct sa1100_port *sport, int *baud,
+ int *parity, int *bits)
+{
+ unsigned int utcr3;
+
+ utcr3 = UART_GET_UTCR3(sport) & (UTCR3_RXE | UTCR3_TXE);
+ if (utcr3 == (UTCR3_RXE | UTCR3_TXE)) {
+ /* ok, the port was enabled */
+ unsigned int utcr0, quot;
+
+ utcr0 = UART_GET_UTCR0(sport);
+
+ *parity = 'n';
+ if (utcr0 & UTCR0_PE) {
+ if (utcr0 & UTCR0_OES)
+ *parity = 'e';
+ else
+ *parity = 'o';
+ }
+
+ if (utcr0 & UTCR0_DSS)
+ *bits = 8;
+ else
+ *bits = 7;
+
+ quot = UART_GET_UTCR2(sport) | UART_GET_UTCR1(sport) << 8;
+ quot &= 0xfff;
+ *baud = sport->port.uartclk / (16 * (quot + 1));
+ }
+}
+
+static int __init
+sa1100_console_setup(struct console *co, char *options)
+{
+ struct sa1100_port *sport;
+ int baud = CONFIG_SA1100_DEFAULT_BAUDRATE;
+ int bits = 8;
+ int parity = 'n';
+ int flow = 'n';
+
+ /*
+ * Check whether an invalid uart number has been specified, and
+ * if so, search for the first available port that does have
+ * console support.
+ */
+ if (co->index == -1 || co->index >= NR_PORTS)
+ co->index = 0;
+ sport = &sa1100_ports[co->index];
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+ else
+ sa1100_console_get_options(sport, &baud, &parity, &bits);
+
+ return uart_set_options(&sport->port, co, baud, parity, bits, flow);
+}
+
+static struct console sa1100_console = {
+ .name = "ttySA",
+ .write = sa1100_console_write,
+ .device = sa1100_console_device,
+ .setup = sa1100_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = -1,
+};
+
+void __init sa1100_rs_console_init(void)
+{
+ sa1100_init_ports();
+ register_console(&sa1100_console);
+}
+
+#define SA1100_CONSOLE &sa1100_console
+#else
+#define SA1100_CONSOLE NULL
+#endif
+
+static struct uart_driver sa1100_reg = {
+ .owner = THIS_MODULE,
+ .normal_major = SERIAL_SA1100_MAJOR,
+#ifdef CONFIG_DEVFS_FS
+ .normal_name = "ttySA%d",
+ .callout_name = "cusa%d",
+#else
+ .normal_name = "ttySA",
+ .callout_name = "cusa",
+#endif
+ .normal_driver = &normal,
+ .callout_major = CALLOUT_SA1100_MAJOR,
+ .callout_driver = &callout,
+ .table = sa1100_table,
+ .termios = sa1100_termios,
+ .termios_locked = sa1100_termios_locked,
+ .minor = MINOR_START,
+ .nr = NR_PORTS,
+ .cons = SA1100_CONSOLE,
+};
+
+static int __init sa1100_serial_init(void)
+{
+ int i, ret;
+
+ sa1100_init_ports();
+
+ ret = uart_register_driver(&sa1100_reg);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < NR_PORTS; i++)
+ uart_add_one_port(&sa1100_reg, &sa1100_ports[i].port);
+
+ return 0;
+}
+
+static void __exit sa1100_serial_exit(void)
+{
+ int i;
+
+ for (i = 0; i < NR_PORTS; i++)
+ uart_remove_one_port(&sa1100_reg, &sa1100_ports[i].port);
+
+ uart_unregister_driver(&sa1100_reg);
+}
+
+module_init(sa1100_serial_init);
+module_exit(sa1100_serial_exit);
+
+EXPORT_NO_SYMBOLS;
+
+MODULE_AUTHOR("Deep Blue Solutions Ltd");
+MODULE_DESCRIPTION("SA1100 generic serial port driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/serial/uart00.c linux-2.4.26-vrs1/drivers/serial/uart00.c
--- linux-2.4.26/drivers/serial/uart00.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/serial/uart00.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,903 @@
+/*
+ * linux/drivers/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: uart00.c,v 1.3.2.5 2002/10/24 09:53:26 rmk Exp $
+ *
+ */
+#include <linux/config.h>
+#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/pld/pld_hotswap.h>
+#include <linux/proc_fs.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_UART00_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/serial_core.h>
+#include <asm/arch/excalibur.h>
+#define UART00_TYPE (volatile unsigned int*)
+#include <asm/arch/uart00.h>
+#include <asm/arch/int_ctrl00.h>
+
+#undef DEBUG
+#define UART_NR 2
+
+#define SERIAL_UART00_NAME "ttyUA"
+#define SERIAL_UART00_MAJOR 204
+#define SERIAL_UART00_MINOR 16 /* Temporary - will change in future */
+#define SERIAL_UART00_NR UART_NR
+#define UART_PORT_SIZE 0x50
+
+#define CALLOUT_UART00_NAME "cuaua"
+#define CALLOUT_UART00_MAJOR 205
+#define CALLOUT_UART00_MINOR 16 /* Temporary - will change in future */
+#define CALLOUT_UART00_NR UART_NR
+
+static struct tty_driver normal, callout;
+static struct tty_struct *uart00_table[UART_NR];
+static struct termios *uart00_termios[UART_NR], *uart00_termios_locked[UART_NR];
+static struct console uart00_console;
+static struct uart_driver uart00_reg;
+
+
+#define UART00_ISR_PASS_LIMIT 256
+
+/*
+ * Access macros for the UART00 UARTs
+ */
+#define UART_GET_INT_STATUS(p) inl(UART_ISR((p)->membase))
+#define UART_PUT_IES(p, c) outl(c,UART_IES((p)->membase))
+#define UART_GET_IES(p) inl(UART_IES((p)->membase))
+#define UART_PUT_IEC(p, c) outl(c,UART_IEC((p)->membase))
+#define UART_GET_IEC(p) inl(UART_IEC((p)->membase))
+#define UART_PUT_CHAR(p, c) outl(c,UART_TD((p)->membase))
+#define UART_GET_CHAR(p) inl(UART_RD((p)->membase))
+#define UART_GET_RSR(p) inl(UART_RSR((p)->membase))
+#define UART_GET_RDS(p) inl(UART_RDS((p)->membase))
+#define UART_GET_MSR(p) inl(UART_MSR((p)->membase))
+#define UART_GET_MCR(p) inl(UART_MCR((p)->membase))
+#define UART_PUT_MCR(p, c) outl(c,UART_MCR((p)->membase))
+#define UART_GET_MC(p) inl(UART_MC((p)->membase))
+#define UART_PUT_MC(p, c) outl(c,UART_MC((p)->membase))
+#define UART_GET_TSR(p) inl(UART_TSR((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_RX_DATA(s) ((s) & UART_RSR_RX_LEVEL_MSK)
+#define UART_TX_READY(s) (((s) & UART_TSR_TX_LEVEL_MSK) < 15)
+//#define UART_TX_EMPTY(p) ((UART_GET_FR(p) & UART00_UARTFR_TMSK) == 0)
+
+static void uart00_stop_tx(struct uart_port *port, u_int from_tty)
+{
+
+ UART_PUT_IEC(port, UART_IEC_TIE_MSK);
+}
+
+static void uart00_stop_rx(struct uart_port *port)
+{
+
+ UART_PUT_IEC(port, UART_IEC_RE_MSK);
+}
+
+static void uart00_enable_ms(struct uart_port *port)
+{
+
+ UART_PUT_IES(port, UART_IES_ME_MSK);
+}
+
+static void
+uart00_rx_chars(struct uart_port *port, struct pt_regs *regs)
+{
+ struct uart_info *info = port->info;
+ struct tty_struct *tty = info->tty;
+ unsigned int status, ch, rds, flg, ignored = 0;
+
+
+ status = UART_GET_RSR(port);
+ while (UART_RX_DATA(status)) {
+
+ /*
+ * We need to read rds before reading the
+ * character from the fifo
+ */
+ rds = UART_GET_RDS(port);
+ 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 (rds & (UART_RDS_BI_MSK |UART_RDS_FE_MSK|UART_RDS_PE_MSK))
+ 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_RSR(port);
+ }
+out:
+ tty_flip_buffer_push(tty);
+ return;
+
+handle_error:
+ if (rds & UART_RDS_BI_MSK) {
+ status &= ~(UART_RDS_FE_MSK | UART_RDS_PE_MSK);
+ port->icount.brk++;
+
+#ifdef SUPPORT_SYSRQ
+ if (uart_handle_break(port))
+ goto ignore_char;
+#endif
+ } else if (rds & UART_RDS_PE_MSK)
+ port->icount.parity++;
+ else if (rds & UART_RDS_FE_MSK)
+ port->icount.frame++;
+ if (rds & UART_RDS_OE_MSK)
+ port->icount.overrun++;
+
+ if (rds & port->ignore_status_mask) {
+ if (++ignored > 100)
+ goto out;
+ goto ignore_char;
+ }
+ rds &= port->read_status_mask;
+
+ if (rds & UART_RDS_BI_MSK)
+ flg = TTY_BREAK;
+ else if (rds & UART_RDS_PE_MSK)
+ flg = TTY_PARITY;
+ else if (rds & UART_RDS_FE_MSK)
+ flg = TTY_FRAME;
+
+ if (rds & UART_RDS_OE_MSK) {
+ /*
+ * 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 uart00_tx_chars(struct uart_port *port)
+{
+ int count;
+ struct uart_info *info = port->info;
+
+ if (port->x_char) {
+ while((UART_GET_TSR(port)& UART_TSR_TX_LEVEL_MSK)==15);
+ 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) {
+ uart00_stop_tx(port, 0);
+ return;
+ }
+
+ count = port->fifosize >> 1;
+ do {
+ while((UART_GET_TSR(port)& UART_TSR_TX_LEVEL_MSK)==15);
+ 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_write_wakeup(port);
+
+ if (info->xmit.head == info->xmit.tail)
+ uart00_stop_tx(port, 0);
+}
+
+static void uart00_start_tx(struct uart_port *port, u_int from_tty)
+{
+ UART_PUT_IES(port,UART_IES_TIE_MSK );
+ uart00_tx_chars(port);
+}
+
+static void uart00_modem_status(struct uart_port *port)
+{
+ unsigned int status;
+ struct uart_icount *icount = &port->icount;
+ struct uart_info *info = port->info;
+
+ status = UART_GET_MSR(port);
+
+ if (!status & (UART_MSR_DCTS_MSK | UART_MSR_DDSR_MSK |
+ UART_MSR_TERI_MSK | UART_MSR_DDCD_MSK))
+ return;
+
+ if (status & UART_MSR_DDCD_MSK) {
+ icount->dcd++;
+#ifdef CONFIG_HARD_PPS
+ if ((port->flags & ASYNC_HARDPPS_CD) &&
+ (status & UART_MSR_DCD_MSK))
+ hardpps();
+#endif
+ if (info->flags & ASYNC_CHECK_CD) {
+ if (status & UART_MSR_DCD_MSK)
+ wake_up_interruptible(&info->open_wait);
+ else if (!((info->flags & ASYNC_CALLOUT_ACTIVE) &&
+ (port->flags & ASYNC_CALLOUT_NOHUP))) {
+ if (info->tty)
+ tty_hangup(info->tty);
+ }
+ }
+ }
+
+ if (status & UART_MSR_DDSR_MSK)
+ icount->dsr++;
+
+ if (status & UART_MSR_DCTS_MSK) {
+ icount->cts++;
+
+ if (info->flags & ASYNC_CTS_FLOW) {
+ status &= UART_MSR_CTS_MSK;
+
+ if (info->tty->hw_stopped) {
+ if (status) {
+ info->tty->hw_stopped = 0;
+ port->ops->start_tx(port, 0);
+ uart_write_wakeup(port);
+ }
+ } else {
+ if (!status) {
+ info->tty->hw_stopped = 1;
+ port->ops->stop_tx(port, 0);
+ }
+ }
+ }
+ }
+ wake_up_interruptible(&info->delta_msr_wait);
+
+}
+
+static void uart00_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct uart_port *port = dev_id;
+ unsigned int status, pass_counter = 0;
+
+ status = UART_GET_INT_STATUS(port);
+ do {
+
+ if (status & UART_ISR_RI_MSK)
+ uart00_rx_chars(port, regs);
+ if (status & (UART_ISR_TI_MSK | UART_ISR_TII_MSK))
+ uart00_tx_chars(port);
+ if (status & UART_ISR_MI_MSK)
+ uart00_modem_status(port);
+ if (pass_counter++ > UART00_ISR_PASS_LIMIT)
+ break;
+
+ status = UART_GET_INT_STATUS(port);
+ } while (status);
+}
+
+static u_int uart00_tx_empty(struct uart_port *port)
+{
+ return UART_GET_TSR(port) & UART_TSR_TX_LEVEL_MSK? 0 : TIOCSER_TEMT;
+}
+
+static u_int uart00_get_mctrl(struct uart_port *port)
+{
+ unsigned int result = 0;
+ unsigned int status;
+
+ status = UART_GET_MSR(port);
+ if (status & UART_MSR_DCD_MSK)
+ result |= TIOCM_CAR;
+ if (status & UART_MSR_DSR_MSK)
+ result |= TIOCM_DSR;
+ if (status & UART_MSR_CTS_MSK)
+ result |= TIOCM_CTS;
+ if (status & UART_MCR_RI_MSK)
+ result |= TIOCM_RNG;
+
+ return result;
+}
+
+static void uart00_set_mctrl(struct uart_port *port, u_int mctrl)
+{
+ unsigned char mcr = 0;
+
+ if (mctrl & TIOCM_RTS)
+ mcr |= UART_MCR_RTS_MSK;
+ if (mctrl & TIOCM_DTR)
+ mcr |= UART_MCR_DTR_MSK;
+ if (mctrl & TIOCM_LOOP)
+ mcr |= UART_MCR_LB_MSK;
+
+ UART_PUT_MCR(port, mcr);
+}
+
+static void uart00_break_ctl(struct uart_port *port, int break_state)
+{
+ unsigned int mcr;
+
+ mcr = UART_GET_MCR(port);
+ if (break_state == -1)
+ mcr |= UART_MCR_BR_MSK;
+ else
+ mcr &= ~UART_MCR_BR_MSK;
+ UART_PUT_MCR(port, mcr);
+}
+
+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 uart00_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
+{
+ u_int uart_mc=0, old_ies;
+ unsigned long flags;
+
+#ifdef DEBUG
+ printk("uart00_set_cflag(0x%x) called\n", cflag);
+#endif
+ /* byte size and parity */
+ switch (cflag & CSIZE) {
+ case CS5: uart_mc = UART_MC_CLS_CHARLEN_5; break;
+ case CS6: uart_mc = UART_MC_CLS_CHARLEN_6; break;
+ case CS7: uart_mc = UART_MC_CLS_CHARLEN_7; break;
+ default: uart_mc = UART_MC_CLS_CHARLEN_8; break; // CS8
+ }
+ if (cflag & CSTOPB)
+ uart_mc|= UART_MC_ST_TWO;
+ if (cflag & PARENB) {
+ uart_mc |= UART_MC_PE_MSK;
+ if (!(cflag & PARODD))
+ uart_mc |= UART_MC_EP_MSK;
+ }
+
+ port->read_status_mask = UART_RDS_OE_MSK;
+ if (iflag & INPCK)
+ port->read_status_mask |= UART_RDS_FE_MSK | UART_RDS_PE_MSK;
+ if (iflag & (BRKINT | PARMRK))
+ port->read_status_mask |= UART_RDS_BI_MSK;
+
+ /*
+ * Characters to ignore
+ */
+ port->ignore_status_mask = 0;
+ if (iflag & IGNPAR)
+ port->ignore_status_mask |= UART_RDS_FE_MSK | UART_RDS_PE_MSK;
+ if (iflag & IGNBRK) {
+ port->ignore_status_mask |= UART_RDS_BI_MSK;
+ /*
+ * If we're ignoring parity and break indicators,
+ * ignore overruns to (for real raw support).
+ */
+ if (iflag & IGNPAR)
+ port->ignore_status_mask |= UART_RDS_OE_MSK;
+ }
+
+ /* first, disable everything */
+ save_flags(flags); cli();
+ old_ies = UART_GET_IES(port);
+
+ if ((port->flags & ASYNC_HARDPPS_CD) ||
+ (cflag & CRTSCTS) || !(cflag & CLOCAL))
+ old_ies |= UART_IES_ME_MSK;
+
+
+ /* Set baud rate */
+ UART_PUT_DIV_LO(port, (quot & 0xff));
+ UART_PUT_DIV_HI(port, ((quot & 0xf00) >> 8));
+
+
+ UART_PUT_MC(port, uart_mc);
+ UART_PUT_IES(port, old_ies);
+
+ restore_flags(flags);
+}
+
+static int uart00_startup(struct uart_port *port)
+{
+ int retval;
+
+ /*
+ * Allocate the IRQ
+ */
+ retval = request_irq(port->irq, uart00_int, 0, "uart00", port);
+ if (retval)
+ return retval;
+
+ /*
+ * 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_IES(port, UART_IES_RE_MSK | UART_IES_TIE_MSK);
+
+ return 0;
+}
+
+static void uart00_shutdown(struct uart_port *port)
+{
+ /*
+ * disable all interrupts, disable the port
+ */
+ UART_PUT_IEC(port, 0xff);
+
+ /* disable break condition and fifos */
+ UART_PUT_MCR(port, UART_GET_MCR(port) &~UART_MCR_BR_MSK);
+
+ /*
+ * Free the interrupt
+ */
+ free_irq(port->irq, port);
+}
+
+static const char *uart00_type(struct uart_port *port)
+{
+ return port->type == PORT_UART00 ? "Altera UART00" : NULL;
+}
+
+/*
+ * Release the memory region(s) being used by 'port'
+ */
+static void uart00_release_port(struct uart_port *port)
+{
+ release_mem_region(port->mapbase, UART_PORT_SIZE);
+
+#ifdef CONFIG_ARCH_CAMELOT
+ if(port->membase!=(void*)IO_ADDRESS(EXC_UART00_BASE)){
+ iounmap(port->membase);
+ }
+#endif
+}
+
+/*
+ * Request the memory region(s) being used by 'port'
+ */
+static int uart00_request_port(struct uart_port *port)
+{
+ int result;
+
+ result = request_mem_region(port->mapbase, UART_PORT_SIZE,
+ "serial_uart00") != NULL ? 0 : -EBUSY;
+ if (result)
+ return result;
+
+ port->membase = ioremap(port->mapbase, SZ_4K);
+ if (!port->membase) {
+ printk(KERN_ERR "serial00: cannot map io memory\n");
+ release_mem_region(port->mapbase, UART_PORT_SIZE);
+ }
+
+ return port->membase ? 0 : -ENOMEM;
+}
+
+/*
+ * Configure/autoconfigure the port.
+ */
+static void uart00_config_port(struct uart_port *port, int flags)
+{
+ if (flags & UART_CONFIG_TYPE) {
+ if (uart00_request_port(port) == 0)
+ port->type = PORT_UART00;
+ }
+}
+
+/*
+ * verify the new serial_struct (for TIOCSSERIAL).
+ */
+static int uart00_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 uart00_pops = {
+ tx_empty: uart00_tx_empty,
+ set_mctrl: uart00_set_mctrl,
+ get_mctrl: uart00_get_mctrl,
+ stop_tx: uart00_stop_tx,
+ start_tx: uart00_start_tx,
+ stop_rx: uart00_stop_rx,
+ enable_ms: uart00_enable_ms,
+ break_ctl: uart00_break_ctl,
+ startup: uart00_startup,
+ shutdown: uart00_shutdown,
+ change_speed: uart00_change_speed,
+ type: uart00_type,
+ release_port: uart00_release_port,
+ request_port: uart00_request_port,
+ config_port: uart00_config_port,
+ verify_port: uart00_verify_port,
+};
+
+static struct uart_port uart00_ports[UART_NR] = {
+
+#ifdef CONFIG_ARCH_CAMELOT
+{
+ .membase = (void*)IO_ADDRESS(EXC_UART00_BASE),
+ .mapbase = EXC_UART00_BASE,
+ .iotype = SERIAL_IO_MEM,
+ .irq = IRQ_UART,
+ .uartclk = EXC_AHB2_CLK_FREQUENCY,
+ .fifosize = 16,
+ .ops = &uart00_pops,
+ .flags = ASYNC_BOOT_AUTOCONF,
+}
+#endif
+};
+
+#ifdef CONFIG_SERIAL_UART00_CONSOLE
+static void uart00_console_write(struct console *co, const char *s, unsigned count)
+{
+#ifdef CONFIG_ARCH_CAMELOT
+ struct uart_port *port = &uart00_ports[0];
+ unsigned int status, old_ies;
+ int i;
+
+ /*
+ * First save the CR then disable the interrupts
+ */
+ old_ies = UART_GET_IES(port);
+ UART_PUT_IEC(port,0xff);
+
+ /*
+ * Now, do each character
+ */
+ for (i = 0; i < count; i++) {
+ do {
+ status = UART_GET_TSR(port);
+ } while (!UART_TX_READY(status));
+ UART_PUT_CHAR(port, s[i]);
+ if (s[i] == '\n') {
+ do {
+ status = UART_GET_TSR(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_TSR(port);
+ } while (status & UART_TSR_TX_LEVEL_MSK);
+ UART_PUT_IES(port, old_ies);
+#endif
+}
+
+static kdev_t uart00_console_device(struct console *co)
+{
+ return MKDEV(SERIAL_UART00_MAJOR, SERIAL_UART00_MINOR + co->index);
+}
+
+static void /*__init*/ uart00_console_get_options(struct uart_port *port, int *baud, int *parity, int *bits)
+{
+ u_int uart_mc, quot;
+ uart_mc= UART_GET_MC(port);
+
+ *parity = 'n';
+ if (uart_mc & UART_MC_PE_MSK) {
+ if (uart_mc & UART_MC_EP_MSK)
+ *parity = 'e';
+ else
+ *parity = 'o';
+ }
+
+ switch (uart_mc & UART_MC_CLS_MSK){
+
+ case UART_MC_CLS_CHARLEN_5:
+ *bits = 5;
+ break;
+ case UART_MC_CLS_CHARLEN_6:
+ *bits = 6;
+ break;
+ case UART_MC_CLS_CHARLEN_7:
+ *bits = 7;
+ break;
+ case UART_MC_CLS_CHARLEN_8:
+ *bits = 8;
+ break;
+ }
+ quot = UART_GET_DIV_LO(port) | (UART_GET_DIV_HI(port) << 8);
+ *baud = port->uartclk / (16 *quot );
+}
+
+static int __init uart00_console_setup(struct console *co, char *options)
+{
+ struct uart_port *port;
+ int baud = 38400;
+ int bits = 8;
+ int parity = 'n';
+ int flow= 'n';
+
+#ifdef CONFIG_ARCH_CAMELOT
+ /*
+ * Check whether an invalid uart number has been specified, and
+ * if so, search for the first available port that does have
+ * console support.
+ */
+ port = &uart00_ports[0];
+ co->index = 0;
+#else
+ return -ENODEV;
+#endif
+
+ if (options)
+ uart_parse_options(options, &baud, &parity, &bits, &flow);
+ else
+ uart00_console_get_options(port, &baud, &parity, &bits);
+
+ return uart_set_options(port, co, baud, parity, bits, flow);
+}
+
+static struct console uart00_console = {
+ .name = SERIAL_UART00_NAME,
+ .write = uart00_console_write,
+ .device = uart00_console_device,
+ .setup = uart00_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = 0,
+};
+
+void __init uart00_console_init(void)
+{
+ register_console(&uart00_console);
+}
+
+#define UART00_CONSOLE &uart00_console
+#else
+#define UART00_CONSOLE NULL
+#endif
+
+static struct uart_driver uart00_reg = {
+ .owner = NULL,
+ .normal_major = SERIAL_UART00_MAJOR,
+ .normal_name = SERIAL_UART00_NAME,
+ .normal_driver = &normal,
+ .callout_major = CALLOUT_UART00_MAJOR,
+ .callout_name = CALLOUT_UART00_NAME,
+ .callout_driver = &callout,
+ .table = uart00_table,
+ .termios = uart00_termios,
+ .termios_locked = uart00_termios_locked,
+ .minor = SERIAL_UART00_MINOR,
+ .nr = UART_NR,
+ .state = NULL,
+ .cons = UART00_CONSOLE,
+};
+
+struct dev_port_entry{
+ struct uart_port *port;
+};
+
+static struct dev_port_entry dev_port_map[UART_NR];
+
+#ifdef CONFIG_PLD_HOTSWAP
+/*
+ * Keep a mapping of dev_info addresses -> port lines to use when
+ * removing ports dev==NULL indicates unused entry
+ */
+
+struct uart00_ps_data{
+ unsigned int clk;
+ unsigned int fifosize;
+};
+
+int uart00_add_device(struct pldhs_dev_info* dev_info, void* dev_ps_data)
+{
+ struct uart00_ps_data* dev_ps=dev_ps_data;
+ struct uart_port * port;
+ int i,result;
+
+ i=0;
+ while(dev_port_map[i].port)
+ i++;
+
+ if(i==UART_NR){
+ printk(KERN_WARNING "uart00: Maximum number of ports reached\n");
+ return 0;
+ }
+
+ port=&uart00_ports[i];
+
+ printk("clk=%d fifo=%d\n",dev_ps->clk,dev_ps->fifosize);
+ port->membase=0;
+ port->mapbase=dev_info->base_addr;
+ port->iotype=SERIAL_IO_MEM;
+ port->irq=dev_info->irq;
+ port->uartclk=dev_ps->clk;
+ port->fifosize=dev_ps->fifosize;
+ port->ops=&uart00_pops;
+ port->line=i;
+ port->flags=ASYNC_BOOT_AUTOCONF;
+
+ result=uart_register_port(&uart00_reg, port);
+ if(result<0){
+ printk("uart_register_port returned %d\n",result);
+ return result;
+ }
+ dev_port_map[i].port=port;
+ printk("uart00: added device at %lx as ttyUA%d\n",dev_port_map[i].port->mapbase,i);
+ return 0;
+
+}
+
+int uart00_remove_devices(void)
+{
+ int i,result;
+
+
+ result=0;
+ for(i=1;i<UART_NR;i++){
+ if(dev_port_map[i].port){
+ uart_unregister_port(&uart00_reg,i);
+ dev_port_map[i].port=NULL;
+ }
+ }
+ return 0;
+
+}
+
+#ifdef CONFIG_PROC_FS
+
+
+int uart00_proc_read(char* buf,char** start,off_t offset,int count,int *eof,void *data){
+
+ int i,len=0;
+ struct uart_port *port;
+ int limit = count - 80;
+ char ps_data[80];
+ if(*start)
+ buf=*start;
+ for(i=0;(i<UART_NR)&&(len<limit);i++){
+ if(dev_port_map[i].port){
+ port=dev_port_map[i].port;
+ sprintf(ps_data,"clk, %dHz, fifo size, %dbytes",
+ port->uartclk,port->fifosize);
+ len+=PLDHS_READ_PROC_DATA(buf+len,"uart00",i,
+ port->mapbase,port->irq,ps_data);
+
+ }
+ }
+ *eof=1;
+ return len;
+}
+
+
+
+#endif
+struct pld_hotswap_ops uart00_pldhs_ops={
+ .name = "uart00",
+ .add_device = uart00_add_device,
+ .remove_devices = uart00_remove_devices,
+ .proc_read = uart00_proc_read
+};
+
+#endif
+
+static int __init uart00_init(void)
+{
+ int ret;
+ int i;
+
+ ret = uart_register_driver(&uart00_reg);
+ if (ret) {
+ printk(KERN_ERR "uart00: Couldn't register driver\n");
+ return ret;
+ }
+
+ unregister_console(&uart00_console);
+
+ for(i=0;i<UART_NR;i++){
+ uart00_ports[i].ops=&uart00_pops;
+ }
+
+ printk(KERN_WARNING "uart00:Using temporary major/minor pairs - these WILL change in the future\n");
+
+#ifdef CONFIG_PLD_HOTSWAP
+ pldhs_register_driver(&uart00_pldhs_ops);
+#endif
+ for (i=0; i<UART_NR; i++)
+ uart_add_one_port(&uart00_reg,&uart00_ports[i]);
+
+ uart00_console.flags = 0;
+ register_console(&uart00_console);
+#ifdef CONFIG_ARCH_CAMELOT
+ dev_port_map[0].port=uart00_ports;
+#endif
+ return ret;
+}
+
+
+__initcall(uart00_init);
+
+
diff -urN linux-2.4.26/drivers/sound/.version linux-2.4.26-vrs1/drivers/sound/.version
--- linux-2.4.26/drivers/sound/.version 1997-11-10 07:01:54.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/sound/.version 1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-3.8s
-0x030804
diff -urN linux-2.4.26/drivers/sound/Config.in linux-2.4.26-vrs1/drivers/sound/Config.in
--- linux-2.4.26/drivers/sound/Config.in 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/sound/Config.in 2004-01-14 21:39:13.000000000 +0000
@@ -131,6 +131,17 @@
dep_tristate ' VIA 82C686 Audio Codec' CONFIG_SOUND_VIA82CXXX $CONFIG_PCI
dep_mbool ' VIA 82C686 MIDI' CONFIG_MIDI_VIA82CXXX $CONFIG_SOUND_VIA82CXXX
+if [ "$CONFIG_ARCH_SA1100" = "y" ]; then
+ dep_tristate ' StrongARM-11x0 Sound Drivers' CONFIG_SOUND_SA1100 $CONFIG_ARCH_SA1100 $CONFIG_SOUND
+ dep_tristate ' UDA1341 Stereo Codec' CONFIG_SOUND_UDA1341 $CONFIG_L3 $CONFIG_SOUND_SA1100 $CONFIG_SOUND
+ dep_tristate ' Assabet audio support' CONFIG_SOUND_ASSABET_UDA1341 $CONFIG_SA1100_ASSABET $CONFIG_SOUND_UDA1341
+ dep_tristate ' Compaq iPAQ audio support' CONFIG_SOUND_H3600_UDA1341 $CONFIG_SA1100_H3600 $CONFIG_SOUND_UDA1341
+ dep_tristate ' Pangolin audio support' CONFIG_SOUND_PANGOLIN_UDA1341 $CONFIG_SA1100_PANGOLIN $CONFIG_SOUND_UDA1341
+ dep_tristate ' SA1111 audio support' CONFIG_SOUND_SA1111_UDA1341 $CONFIG_SA1111 $CONFIG_SOUND_UDA1341
+ dep_tristate ' SA1111 AC97 Sound' CONFIG_SOUND_SA1111_AC97 $CONFIG_SA1111 $CONFIG_SOUND_SA1100
+ dep_tristate ' Generic DAC on the SA11x0 SSP port' CONFIG_SOUND_SA1100SSP $CONFIG_SOUND_SA1100
+fi
+
dep_tristate ' OSS sound modules' CONFIG_SOUND_OSS $CONFIG_SOUND
if [ "$CONFIG_SOUND_OSS" = "y" -o "$CONFIG_SOUND_OSS" = "m" ]; then
@@ -220,14 +231,14 @@
bool ' Audio Excel DSP 16 (MPU401 emulation)' CONFIG_AEDSP16_MPU401
fi
fi
+
+fi
- if [ "$CONFIG_ARM" = "y" ]; then
- if [ "$CONFIG_ARCH_ACORN" = "y" -o "$CONFIG_ARCH_CLPS7500" = "y" ]; then
- dep_tristate ' VIDC 16-bit sound' CONFIG_SOUND_VIDC $CONFIG_SOUND_OSS
- fi
- dep_tristate ' Netwinder WaveArtist' CONFIG_SOUND_WAVEARTIST $CONFIG_SOUND_OSS $CONFIG_ARCH_NETWINDER
+if [ "$CONFIG_ARM" = "y" ]; then
+ if [ "$CONFIG_ARCH_ACORN" = "y" -o "$CONFIG_ARCH_CLPS7500" = "y" -o "$CONFIG_ARCH_RISCSTATION" ]; then
+ dep_tristate ' VIDC 16-bit sound' CONFIG_SOUND_VIDC $CONFIG_SOUND_OSS
fi
-
+ dep_tristate ' Netwinder WaveArtist' CONFIG_SOUND_WAVEARTIST $CONFIG_SOUND_OSS $CONFIG_ARCH_NETWINDER
fi
dep_tristate ' TV card (bt848) mixer support' CONFIG_SOUND_TVMIXER $CONFIG_SOUND $CONFIG_I2C
diff -urN linux-2.4.26/drivers/sound/Makefile linux-2.4.26-vrs1/drivers/sound/Makefile
--- linux-2.4.26/drivers/sound/Makefile 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/sound/Makefile 2004-01-14 21:39:13.000000000 +0000
@@ -10,7 +10,8 @@
export-objs := ad1848.o audio_syms.o midi_syms.o mpu401.o \
msnd.o opl3.o sb_common.o sequencer_syms.o \
sound_core.o sound_syms.o uart401.o \
- nm256_audio.o ac97.o ac97_codec.o aci.o
+ nm256_audio.o ac97.o ac97_codec.o aci.o \
+ sa1100-audio.o
# Each configuration option enables a list of files.
@@ -76,6 +77,14 @@
obj-$(CONFIG_SOUND_FORTE) += forte.o ac97_codec.o
obj-$(CONFIG_SOUND_TRIDENT) += trident.o ac97_codec.o
obj-$(CONFIG_SOUND_HARMONY) += harmony.o
+obj-$(CONFIG_SOUND_SA1100) += sa1100-audio.o
+obj-$(CONFIG_SOUND_UDA1341) += uda1341.o
+obj-$(CONFIG_SOUND_ASSABET_UDA1341) += assabet-uda1341.o
+obj-$(CONFIG_SOUND_PANGOLIN_UDA1341) += pangolin-uda1341.o
+obj-$(CONFIG_SOUND_H3600_UDA1341) += h3600-uda1341.o
+obj-$(CONFIG_SOUND_SA1111_UDA1341) += sa1111-uda1341.o
+obj-$(CONFIG_SOUND_SA1111_AC97) += sa1111-ac97.o ac97_codec.o
+obj-$(CONFIG_SOUND_SA1100SSP) += sa1100ssp.o
obj-$(CONFIG_SOUND_EMU10K1) += ac97_codec.o
obj-$(CONFIG_SOUND_BCM_CS4297A) += swarm_cs4297a.o
obj-$(CONFIG_SOUND_RME96XX) += rme96xx.o
@@ -105,7 +114,6 @@
obj-y += dmasound/dmasound.o
endif
-
# Declare multi-part drivers.
list-multi := sound.o gus.o pas2.o sb.o sb_lib.o vidc_mod.o \
diff -urN linux-2.4.26/drivers/sound/assabet-uda1341.c linux-2.4.26-vrs1/drivers/sound/assabet-uda1341.c
--- linux-2.4.26/drivers/sound/assabet-uda1341.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/assabet-uda1341.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,404 @@
+/*
+ * Glue audio driver for the SA1110 Assabet board & Philips UDA1341 codec.
+ *
+ * Copyright (c) 2000 Nicolas Pitre <nico@cam.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ *
+ * This is the machine specific part of the Assabet/UDA1341 support.
+ * This driver makes use of the UDA1341 and the sa1100-audio modules.
+ *
+ * History:
+ *
+ * 2000-05-21 Nicolas Pitre Initial release.
+ *
+ * 2001-06-03 Nicolas Pitre Made this file a separate module, based on
+ * the former sa1100-uda1341.c driver.
+ *
+ * 2001-07-17 Nicolas Pitre Supports 44100Hz and 22050Hz samplerate now.
+ *
+ * 2001-08-03 Russell King Fix left/right channel swap.
+ * Attempt to reduce power consumption when idle.
+ *
+ * 2001-09-23 Russell King Remove old L3 bus driver.
+ *
+ * Please note that fiddling too much with MDREFR results in oopses, so we don't
+ * touch MDREFR unnecessarily, which means we don't touch it on close.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/errno.h>
+#include <linux/sound.h>
+#include <linux/soundcard.h>
+#include <linux/cpufreq.h>
+#include <linux/l3/l3.h>
+#include <linux/l3/uda1341.h>
+
+#include <asm/semaphore.h>
+#include <asm/uaccess.h>
+#include <asm/hardware.h>
+#include <asm/dma.h>
+#include <asm/arch/assabet.h>
+
+#include "sa1100-audio.h"
+
+/*
+ * Define this to fix the power drain on early Assabets
+ */
+#define FIX_POWER_DRAIN
+
+/*
+ * Debugging?
+ */
+#undef DEBUG
+
+
+#ifdef DEBUG
+#define DPRINTK( x... ) printk( ##x )
+#else
+#define DPRINTK( x... )
+#endif
+
+
+#define AUDIO_RATE_DEFAULT 44100
+
+/*
+ * Mixer (UDA1341) interface
+ */
+
+static struct l3_client uda1341;
+
+static int
+mixer_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
+{
+ /*
+ * We only accept mixer (type 'M') ioctls.
+ */
+ if (_IOC_TYPE(cmd) != 'M')
+ return -EINVAL;
+
+ return l3_command(&uda1341, cmd, (void *)arg);
+}
+
+static struct file_operations assabet_mixer_fops = {
+ ioctl: mixer_ioctl,
+ owner: THIS_MODULE
+};
+
+
+/*
+ * Audio interface
+ */
+static long audio_samplerate = AUDIO_RATE_DEFAULT;
+
+/*
+ * FIXME: what about SFRM going high when SSP is disabled?
+ */
+static void assabet_set_samplerate(long val)
+{
+ struct uda1341_cfg cfg;
+ u_int clk_ref, clk_div;
+
+ /* We don't want to mess with clocks when frames are in flight */
+ Ser4SSCR0 &= ~SSCR0_SSE;
+ /* wait for any frame to complete */
+ udelay(125);
+
+ /*
+ * Our clock source is derived from the CPLD on which we don't have
+ * much control unfortunately. This was intended for a fixed 48000 Hz
+ * samplerate assuming a core clock of 221.2 MHz. The CPLD appears
+ * to divide the memory clock so there is a ratio of 4608 between
+ * the core clock and the resulting samplerate (obtained by
+ * measurements, the CPLD equations should confirm that).
+ *
+ * Still we can play with the SA1110's clock divisor for the SSP port
+ * to get half the samplerate as well.
+ *
+ * Apparently the clock sent to the SA1110 for the SSP port is further
+ * more divided from the clock sent to the UDA1341 (some people tried
+ * to be too clever in their design, or simply failed to read the
+ * SA1110 manual). If it was the same clock we would have been able
+ * to support a third samplerate with the UDA1341's 384FS mode.
+ *
+ * At least it would have been a minimum acceptable solution to be
+ * able to set the CPLD divisor by software. The iPAQ design is
+ * certainly a better example to follow for a new design.
+ */
+ clk_ref = cpufreq_get(0) * 1000 / 4608;
+ if (val > clk_ref*4/7) {
+ audio_samplerate = clk_ref;
+ cfg.fs = 256;
+ clk_div = SSCR0_SerClkDiv(2);
+ } else {
+ audio_samplerate = clk_ref/2;
+ cfg.fs = 512;
+ clk_div = SSCR0_SerClkDiv(4);
+ }
+
+ cfg.format = FMT_LSB16;
+ l3_command(&uda1341, L3_UDA1341_CONFIGURE, &cfg);
+
+ Ser4SSCR0 = (Ser4SSCR0 & ~0xff00) + clk_div + SSCR0_SSE;
+}
+
+/*
+ * Initialise the Assabet audio driver.
+ *
+ * Note that we have to be careful with the order that we do things here;
+ * there is a D-type flip flop which is clocked from the SFRM line which
+ * indicates whether the same is for the left or right channel to the
+ * UDA1341.
+ *
+ * When you disable the SSP (by clearing SSCR0_SSE) it appears that the
+ * SFRM signal can float high. When you re-enable the SSP, you clock the
+ * flip flop once, and end up swapping the left and right channels.
+ *
+ * The ASSABET_BCR_CODEC_RST line will force this flip flop into a known
+ * state, but this line resets other devices as well!
+ *
+ * In addition to the above, it appears that powering down the UDA1341 on
+ * early Assabets leaves the UDA_WS actively driving a logic '1' into the
+ * chip, wasting power! (you can tell this by D11 being half-on). We
+ * attempt to correct this by kicking the flip flop on init/open/close.
+ * We should probably do this on PM resume as well.
+ *
+ * (Note the ordering of ASSABET_BCR_AUDIO_ON, SFRM and ASSABET_BCR_CODEC_RST
+ * is important).
+ */
+static void assabet_audio_init(void *dummy)
+{
+ unsigned long flags;
+ unsigned int mdrefr;
+
+ local_irq_save(flags);
+
+ /*
+ * Enable the power for the UDA1341 before driving any signals.
+ * We leave the audio amp (LM4880) disabled for now.
+ */
+ ASSABET_BCR_set(ASSABET_BCR_AUDIO_ON);
+
+#ifdef FIX_POWER_DRAIN
+ GPSR = GPIO_SSP_SFRM;
+ GPCR = GPIO_SSP_SFRM;
+#endif
+
+ ASSABET_BCR_set(ASSABET_BCR_CODEC_RST);
+ ASSABET_BCR_clear(ASSABET_BCR_STEREO_LB);
+
+ /*
+ * Setup the SSP uart.
+ */
+ PPAR |= PPAR_SPR;
+ Ser4SSCR0 = SSCR0_DataSize(16) + SSCR0_TI + SSCR0_SerClkDiv(2);
+ Ser4SSCR1 = SSCR1_SClkIactL + SSCR1_SClk1P + SSCR1_ExtClk;
+ GAFR |= GPIO_SSP_TXD | GPIO_SSP_RXD | GPIO_SSP_SCLK | GPIO_SSP_CLK;
+ GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
+ GPDR &= ~(GPIO_SSP_RXD | GPIO_SSP_CLK);
+ Ser4SSCR0 |= SSCR0_SSE;
+
+ /*
+ * Only give SFRM to the SSP after it has been enabled.
+ */
+ GAFR |= GPIO_SSP_SFRM;
+
+ /*
+ * The assabet board uses the SDRAM clock as the source clock for
+ * audio. This is supplied to the SA11x0 from the CPLD on pin 19.
+ * At 206MHz we need to run the audio clock (SDRAM bank 2)
+ * at half speed. This clock will scale with core frequency so
+ * the audio sample rate will also scale. The CPLD on Assabet
+ * will need to be programmed to match the core frequency.
+ */
+ mdrefr = MDREFR;
+ if ((mdrefr & (MDREFR_K2DB2 | MDREFR_K2RUN | MDREFR_EAPD |
+ MDREFR_KAPD)) != (MDREFR_K2DB2 | MDREFR_K2RUN)) {
+ mdrefr |= MDREFR_K2DB2 | MDREFR_K2RUN;
+ mdrefr &= ~(MDREFR_EAPD | MDREFR_KAPD);
+ MDREFR = mdrefr;
+ (void) MDREFR;
+ }
+ local_irq_restore(flags);
+
+ /* Wait for the UDA1341 to wake up */
+ mdelay(1);
+
+ l3_open(&uda1341);
+
+ assabet_set_samplerate(audio_samplerate);
+
+ /* Enable the audio power */
+ ASSABET_BCR_clear(ASSABET_BCR_QMUTE | ASSABET_BCR_SPK_OFF);
+}
+
+/*
+ * Shutdown the Assabet audio driver.
+ *
+ * We have to be careful about the SFRM line here for the same reasons
+ * described in the initialisation comments above. This basically means
+ * that we must hand the SSP pins back to the GPIO module before disabling
+ * the SSP.
+ *
+ * In addition, to reduce power drain, we toggle the SFRM line once so
+ * that the UDA_WS line is at logic 0.
+ *
+ * We can't clear ASSABET_BCR_CODEC_RST without knowing if the UCB1300 or
+ * ADV7171 driver is still active. If it is, then we still need to play
+ * games, so we might as well leave ASSABET_BCR_CODEC_RST set.
+ */
+static void assabet_audio_shutdown(void *dummy)
+{
+ ASSABET_BCR_set(ASSABET_BCR_STEREO_LB | ASSABET_BCR_QMUTE |
+ ASSABET_BCR_SPK_OFF);
+
+ l3_close(&uda1341);
+
+ GAFR &= ~(GPIO_SSP_TXD | GPIO_SSP_RXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM);
+ Ser4SSCR0 = 0;
+
+#ifdef FIX_POWER_DRAIN
+ GPSR = GPIO_SSP_SFRM;
+ GPCR = GPIO_SSP_SFRM;
+#endif
+
+ /* disable the audio power */
+ ASSABET_BCR_clear(ASSABET_BCR_AUDIO_ON);
+}
+
+static int assabet_audio_ioctl( struct inode *inode, struct file *file,
+ uint cmd, ulong arg)
+{
+ long val;
+ int ret = 0;
+
+ /*
+ * These are platform dependent ioctls which are not handled by the
+ * generic sa1100-audio module.
+ */
+ switch (cmd) {
+ case SNDCTL_DSP_STEREO:
+ ret = get_user(val, (int *) arg);
+ if (ret)
+ return ret;
+ /* the UDA1341 is stereo only */
+ ret = (val == 0) ? -EINVAL : 1;
+ return put_user(ret, (int *) arg);
+
+ case SNDCTL_DSP_CHANNELS:
+ case SOUND_PCM_READ_CHANNELS:
+ /* the UDA1341 is stereo only */
+ return put_user(2, (long *) arg);
+
+ case SNDCTL_DSP_SPEED:
+ ret = get_user(val, (long *) arg);
+ if (ret) break;
+ assabet_set_samplerate(val);
+ /* fall through */
+
+ case SOUND_PCM_READ_RATE:
+ return put_user(audio_samplerate, (long *) arg);
+
+ case SNDCTL_DSP_SETFMT:
+ case SNDCTL_DSP_GETFMTS:
+ /* we can do signed 16-bit only */
+ return put_user(AFMT_S16_LE, (long *) arg);
+
+ default:
+ /* Maybe this is meant for the mixer (As per OSS Docs) */
+ return mixer_ioctl(inode, file, cmd, arg);
+ }
+
+ return ret;
+}
+
+static audio_stream_t output_stream, input_stream;
+
+static audio_state_t audio_state = {
+ output_stream: &output_stream,
+ output_dma: DMA_Ser4SSPWr,
+ output_id: "Assabet UDA1341 out",
+ input_stream: &input_stream,
+ input_dma: DMA_Ser4SSPRd,
+ input_id: "Assabet UDA1341 in",
+ need_tx_for_rx: 1,
+ hw_init: assabet_audio_init,
+ hw_shutdown: assabet_audio_shutdown,
+ client_ioctl: assabet_audio_ioctl,
+ sem: __MUTEX_INITIALIZER(audio_state.sem),
+};
+
+static int assabet_audio_open(struct inode *inode, struct file *file)
+{
+ return sa1100_audio_attach(inode, file, &audio_state);
+}
+
+/*
+ * Missing fields of this structure will be patched with the call
+ * to sa1100_audio_attach().
+ */
+static struct file_operations assabet_audio_fops = {
+ open: assabet_audio_open,
+ owner: THIS_MODULE
+};
+
+
+static int audio_dev_id, mixer_dev_id;
+
+static int __init assabet_uda1341_init(void)
+{
+ int ret;
+
+ if (!machine_is_assabet())
+ return -ENODEV;
+
+ ret = l3_attach_client(&uda1341, "l3-bit-sa1100-gpio", "uda1341");
+ if (ret)
+ goto out;
+
+ /* register devices */
+ audio_dev_id = register_sound_dsp(&assabet_audio_fops, -1);
+ mixer_dev_id = register_sound_mixer(&assabet_mixer_fops, -1);
+
+#ifdef FIX_POWER_DRAIN
+ {
+ unsigned long flags;
+ local_irq_save(flags);
+ ASSABET_BCR_set(ASSABET_BCR_CODEC_RST);
+ GPSR = GPIO_SSP_SFRM;
+ GPDR |= GPIO_SSP_SFRM;
+ GPCR = GPIO_SSP_SFRM;
+ local_irq_restore(flags);
+ }
+#endif
+
+ printk(KERN_INFO "Sound: Assabet UDA1341: dsp id %d mixer id %d\n",
+ audio_dev_id, mixer_dev_id);
+ return 0;
+
+release_l3:
+ l3_detach_client(&uda1341);
+out:
+ return ret;
+}
+
+static void __exit assabet_uda1341_exit(void)
+{
+ unregister_sound_dsp(audio_dev_id);
+ unregister_sound_mixer(mixer_dev_id);
+ l3_detach_client(&uda1341);
+}
+
+module_init(assabet_uda1341_init);
+module_exit(assabet_uda1341_exit);
+
+MODULE_AUTHOR("Nicolas Pitre");
+MODULE_DESCRIPTION("Glue audio driver for the SA1110 Assabet board & Philips UDA1341 codec.");
+
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/sound/h3600-uda1341.c linux-2.4.26-vrs1/drivers/sound/h3600-uda1341.c
--- linux-2.4.26/drivers/sound/h3600-uda1341.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/h3600-uda1341.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,352 @@
+/*
+ * Glue audio driver for the Compaq iPAQ H3600 & Philips UDA1341 codec.
+ *
+ * Copyright (c) 2000 Nicolas Pitre <nico@cam.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ *
+ * This is the machine specific part of the Compaq iPAQ (aka Bitsy) support.
+ * This driver makes use of the UDA1341 and the sa1100-audio modules.
+ *
+ * History:
+ *
+ * 2000-05-21 Nicolas Pitre Initial UDA1341 driver release.
+ *
+ * 2000-07-?? George France Bitsy support.
+ *
+ * 2000-12-13 Deborah Wallach Fixed power handling for iPAQ/h3600
+ *
+ * 2001-06-03 Nicolas Pitre Made this file a separate module, based on
+ * the former sa1100-uda1341.c driver.
+ *
+ * 2001-07-13 Nicolas Pitre Fixes for all supported samplerates.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/errno.h>
+#include <linux/sound.h>
+#include <linux/soundcard.h>
+#include <linux/l3/l3.h>
+#include <linux/l3/uda1341.h>
+
+#include <asm/semaphore.h>
+#include <asm/uaccess.h>
+#include <asm/hardware.h>
+#include <asm/dma.h>
+//#include <asm/arch/h3600_hal.h>
+
+#include "sa1100-audio.h"
+
+
+#undef DEBUG
+#ifdef DEBUG
+#define DPRINTK( x... ) printk( ##x )
+#else
+#define DPRINTK( x... )
+#endif
+
+
+#define AUDIO_NAME "Bitsy_UDA1341"
+
+#define AUDIO_RATE_DEFAULT 44100
+
+
+static struct l3_client uda1341;
+
+static int
+mixer_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
+{
+ /*
+ * We only accept mixer (type 'M') ioctls.
+ */
+ if (_IOC_TYPE(cmd) != 'M')
+ return -EINVAL;
+
+ return l3_command(&uda1341, cmd, (void *)arg);
+}
+
+static struct file_operations h3600_mixer_fops = {
+ ioctl: mixer_ioctl,
+ owner: THIS_MODULE
+};
+
+
+/*
+ * Audio interface
+ */
+
+static long audio_samplerate = AUDIO_RATE_DEFAULT;
+
+/*
+ * Stop-gap solution until rest of hh.org HAL stuff is merged.
+ */
+#define GPIO_H3600_CLK_SET0 GPIO_GPIO (12)
+#define GPIO_H3600_CLK_SET1 GPIO_GPIO (13)
+static void h3600_set_audio_clock(long val)
+{
+ switch (val) {
+ case 24000: case 32000: case 48000: /* 00: 12.288 MHz */
+ GPCR = GPIO_H3600_CLK_SET0 | GPIO_H3600_CLK_SET1;
+ break;
+
+ case 22050: case 29400: case 44100: /* 01: 11.2896 MHz */
+ GPSR = GPIO_H3600_CLK_SET0;
+ GPCR = GPIO_H3600_CLK_SET1;
+ break;
+
+ case 8000: case 10666: case 16000: /* 10: 4.096 MHz */
+ GPCR = GPIO_H3600_CLK_SET0;
+ GPSR = GPIO_H3600_CLK_SET1;
+ break;
+
+ case 10985: case 14647: case 21970: /* 11: 5.6245 MHz */
+ GPSR = GPIO_H3600_CLK_SET0 | GPIO_H3600_CLK_SET1;
+ break;
+ }
+}
+
+static void h3600_set_samplerate(long val)
+{
+ struct uda1341_cfg cfg;
+ int clk_div = 0;
+
+ /* We don't want to mess with clocks when frames are in flight */
+ Ser4SSCR0 &= ~SSCR0_SSE;
+ /* wait for any frame to complete */
+ udelay(125);
+
+ /*
+ * We have the following clock sources:
+ * 4.096 MHz, 5.6245 MHz, 11.2896 MHz, 12.288 MHz
+ * Those can be divided either by 256, 384 or 512.
+ * This makes up 12 combinations for the following samplerates...
+ */
+ if (val >= 48000)
+ val = 48000;
+ else if (val >= 44100)
+ val = 44100;
+ else if (val >= 32000)
+ val = 32000;
+ else if (val >= 29400)
+ val = 29400;
+ else if (val >= 24000)
+ val = 24000;
+ else if (val >= 22050)
+ val = 22050;
+ else if (val >= 21970)
+ val = 21970;
+ else if (val >= 16000)
+ val = 16000;
+ else if (val >= 14647)
+ val = 14647;
+ else if (val >= 10985)
+ val = 10985;
+ else if (val >= 10666)
+ val = 10666;
+ else
+ val = 8000;
+
+ /* Set the external clock generator */
+ h3600_set_audio_clock(val);
+
+ /* Select the clock divisor */
+ switch (val) {
+ case 8000:
+ case 10985:
+ case 22050:
+ case 24000:
+ cfg.fs = 512;
+ clk_div = SSCR0_SerClkDiv(16);
+ break;
+ case 16000:
+ case 21970:
+ case 44100:
+ case 48000:
+ cfg.fs = 256;
+ clk_div = SSCR0_SerClkDiv(8);
+ break;
+ case 10666:
+ case 14647:
+ case 29400:
+ case 32000:
+ cfg.fs = 384;
+ clk_div = SSCR0_SerClkDiv(12);
+ break;
+ }
+
+ cfg.format = FMT_LSB16;
+ l3_command(&uda1341, L3_UDA1341_CONFIGURE, &cfg);
+ Ser4SSCR0 = (Ser4SSCR0 & ~0xff00) + clk_div + SSCR0_SSE;
+ audio_samplerate = val;
+}
+
+static void h3600_audio_init(void *dummy)
+{
+ unsigned long flags;
+
+ /* Setup the uarts */
+ local_irq_save(flags);
+ GAFR |= (GPIO_SSP_CLK);
+ GPDR &= ~(GPIO_SSP_CLK);
+ Ser4SSCR0 = 0;
+ Ser4SSCR0 = SSCR0_DataSize(16) + SSCR0_TI + SSCR0_SerClkDiv(8);
+ Ser4SSCR1 = SSCR1_SClkIactL + SSCR1_SClk1P + SSCR1_ExtClk;
+ Ser4SSCR0 |= SSCR0_SSE;
+
+ /* Enable the audio power */
+
+ clr_h3600_egpio(IPAQ_EGPIO_CODEC_NRESET);
+ set_h3600_egpio(IPAQ_EGPIO_AUDIO_ON);
+ set_h3600_egpio(IPAQ_EGPIO_QMUTE);
+ local_irq_restore(flags);
+
+ /* external clock configuration */
+ h3600_set_samplerate(audio_samplerate);
+
+ /* Wait for the UDA1341 to wake up */
+ set_h3600_egpio(IPAQ_EGPIO_CODEC_NRESET);
+ mdelay(1);
+
+ /* make the left and right channels unswapped (flip the WS latch ) */
+ Ser4SSDR = 0;
+
+ /* Initialize the UDA1341 internal state */
+ l3_open(&uda1341);
+
+ clr_h3600_egpio(IPAQ_EGPIO_QMUTE);
+}
+
+static void h3600_audio_shutdown(void *dummy)
+{
+ /* disable the audio power and all signals leading to the audio chip */
+ l3_close(&uda1341);
+ Ser4SSCR0 = 0;
+ clr_h3600_egpio(IPAQ_EGPIO_CODEC_NRESET);
+ clr_h3600_egpio(IPAQ_EGPIO_AUDIO_ON);
+ clr_h3600_egpio(IPAQ_EGPIO_QMUTE);
+}
+
+static int h3600_audio_ioctl(struct inode *inode, struct file *file,
+ uint cmd, ulong arg)
+{
+ long val;
+ int ret = 0;
+
+ /*
+ * These are platform dependent ioctls which are not handled by the
+ * generic sa1100-audio module.
+ */
+ switch (cmd) {
+ case SNDCTL_DSP_STEREO:
+ ret = get_user(val, (int *) arg);
+ if (ret)
+ return ret;
+ /* the UDA1341 is stereo only */
+ ret = (val == 0) ? -EINVAL : 1;
+ return put_user(ret, (int *) arg);
+
+ case SNDCTL_DSP_CHANNELS:
+ case SOUND_PCM_READ_CHANNELS:
+ /* the UDA1341 is stereo only */
+ return put_user(2, (long *) arg);
+
+ case SNDCTL_DSP_SPEED:
+ ret = get_user(val, (long *) arg);
+ if (ret) break;
+ h3600_set_samplerate(val);
+ /* fall through */
+
+ case SOUND_PCM_READ_RATE:
+ return put_user(audio_samplerate, (long *) arg);
+
+ case SNDCTL_DSP_SETFMT:
+ case SNDCTL_DSP_GETFMTS:
+ /* we can do 16-bit only */
+ return put_user(AFMT_S16_LE, (long *) arg);
+
+ default:
+ /* Maybe this is meant for the mixer (As per OSS Docs) */
+ return mixer_ioctl(inode, file, cmd, arg);
+ }
+
+ return ret;
+}
+
+static audio_stream_t output_stream, input_stream;
+
+static audio_state_t audio_state = {
+ output_stream: &output_stream,
+ output_dma: DMA_Ser4SSPWr,
+ output_id: "UDA1341 out",
+ input_stream: &input_stream,
+ input_dma: DMA_Ser4SSPRd,
+ input_id: "UDA1341 in",
+ need_tx_for_rx: 1,
+ hw_init: h3600_audio_init,
+ hw_shutdown: h3600_audio_shutdown,
+ client_ioctl: h3600_audio_ioctl,
+ sem: __MUTEX_INITIALIZER(audio_state.sem),
+};
+
+static int h3600_audio_open(struct inode *inode, struct file *file)
+{
+ return sa1100_audio_attach(inode, file, &audio_state);
+}
+
+/*
+ * Missing fields of this structure will be patched with the call
+ * to sa1100_audio_attach().
+ */
+static struct file_operations h3600_audio_fops = {
+ open: h3600_audio_open,
+ owner: THIS_MODULE
+};
+
+
+static int audio_dev_id, mixer_dev_id;
+
+static int __init h3600_uda1341_init(void)
+{
+ int ret;
+
+ if (!machine_is_h3xxx())
+ return -ENODEV;
+
+ ret = l3_attach_client(&uda1341, "l3-bit-sa1100-gpio", "uda1341");
+ if (ret)
+ goto out;
+
+ /* register devices */
+ audio_dev_id = register_sound_dsp(&h3600_audio_fops, -1);
+ mixer_dev_id = register_sound_mixer(&h3600_mixer_fops, -1);
+
+ printk( KERN_INFO "iPAQ audio support initialized\n" );
+ return 0;
+
+release_l3:
+ l3_detach_client(&uda1341);
+out:
+ return ret;
+}
+
+static void __exit h3600_uda1341_exit(void)
+{
+ unregister_sound_dsp(audio_dev_id);
+ unregister_sound_mixer(mixer_dev_id);
+ l3_detach_client(&uda1341);
+}
+
+module_init(h3600_uda1341_init);
+module_exit(h3600_uda1341_exit);
+
+MODULE_AUTHOR("Nicolas Pitre, George France");
+MODULE_DESCRIPTION("Glue audio driver for the Compaq iPAQ H3600 & Philips UDA1341 codec.");
+
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/sound/pangolin-uda1341.c linux-2.4.26-vrs1/drivers/sound/pangolin-uda1341.c
--- linux-2.4.26/drivers/sound/pangolin-uda1341.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/pangolin-uda1341.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,322 @@
+/*
+ * Glue audio driver for the SA1110 Pangolin board & Philips UDA1341 codec.
+ *
+ * Copyright (c) 2000 Nicolas Pitre <nico@cam.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ *
+ * This is the machine specific part of the Pangolin/UDA1341 support.
+ * This driver makes use of the UDA1341 and the sa1100-audio modules.
+ *
+ * History:
+ *
+ * 2000-05-21 Nicolas Pitre Initial release.
+ *
+ * 2001-06-03 Nicolas Pitre Made this file a separate module, based on
+ * the former sa1100-uda1341.c driver.
+ *
+ * 2001-07-17 Nicolas Pitre Supports 44100Hz and 22050Hz samplerate now.
+ *
+ * 2001-08-06 Richard Fan Pangolin Support
+ *
+ * 2001-09-23 Russell King Update inline with Assabet driver
+ * Remove old L3 bus driver
+ *
+ * Note: this should probably be merged with the Assabet audio driver,
+ * and become the "SDRAM-clock driven" SA1100 audio driver.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/errno.h>
+#include <linux/sound.h>
+#include <linux/soundcard.h>
+#include <linux/l3/l3.h>
+#include <linux/l3/uda1341.h>
+
+#include <asm/semaphore.h>
+#include <asm/uaccess.h>
+#include <asm/hardware.h>
+#include <asm/dma.h>
+
+#include "sa1100-audio.h"
+
+/*
+ * Debugging?
+ */
+#undef DEBUG
+
+
+#ifdef DEBUG
+#define DPRINTK( x... ) printk( ##x )
+#else
+#define DPRINTK( x... )
+#endif
+
+
+#define AUDIO_RATE_DEFAULT 44100
+
+#define QmutePin GPIO_GPIO(4)
+#define SpeakerOffPin GPIO_GPIO(5)
+
+/*
+ * Mixer (UDA1341) interface
+ */
+
+static struct l3_client uda1341;
+
+static int
+mixer_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
+{
+ /*
+ * We only accept mixer (type 'M') ioctls.
+ */
+ if (_IOC_TYPE(cmd) != 'M')
+ return -EINVAL;
+
+ return l3_command(&uda1341, cmd, (void *)arg);
+}
+
+static struct file_operations pangolin_mixer_fops = {
+ ioctl: mixer_ioctl,
+ owner: THIS_MODULE
+};
+
+
+/*
+ * Audio interface
+ */
+static long audio_samplerate = AUDIO_RATE_DEFAULT;
+
+static void pangolin_set_samplerate(long val)
+{
+ struct uda1341_cfg cfg;
+ int clk_div;
+
+ /* We don't want to mess with clocks when frames are in flight */
+ Ser4SSCR0 &= ~SSCR0_SSE;
+ /* wait for any frame to complete */
+ udelay(125);
+
+ /*
+ * Our clock source is derived from the CPLD on which we don't have
+ * much control unfortunately. This was intended for a fixed 44100Hz
+ * samplerate assuming a core clock of 206 MHz. Still we can play
+ * with the SA1110's clock divisor for the SSP port to get a 22050Hz
+ * samplerate.
+ *
+ * Apparently the clock sent to the SA1110 for the SSP port is
+ * divided from the clock sent to the UDA1341 (some people tried to
+ * be too clever in their design, or simply failed to read the SA1110
+ * manual). If it was the same source we would have been able to
+ * support a third samplerate.
+ *
+ * At least it would have been a minimum acceptable solution to be
+ * able to set the CPLD divisor by software. The iPAQ design is
+ * certainly a better example to follow for a new design.
+ */
+ if (val >= 44100) {
+ audio_samplerate = 44100;
+ cfg.fs = 256;
+ clk_div = SSCR0_SerClkDiv(2);
+ } else {
+ audio_samplerate = 22050;
+ cfg.fs = 512;
+ clk_div = SSCR0_SerClkDiv(4);
+ }
+
+ cfg.format = FMT_LSB16;
+ l3_command(&uda1341, L3_UDA1341_CONFIGURE, &cfg);
+
+ Ser4SSCR0 = (Ser4SSCR0 & ~0xff00) + clk_div + SSCR0_SSE;
+}
+
+static void pangolin_audio_init(void *dummy)
+{
+ unsigned long flags;
+ unsigned int mdrefr;
+
+ local_irq_save(flags);
+
+ /*
+ * Setup the SSP uart.
+ */
+ PPAR |= PPAR_SPR;
+ Ser4SSCR0 = SSCR0_DataSize(16) + SSCR0_TI + SSCR0_SerClkDiv(2);
+ Ser4SSCR1 = SSCR1_SClkIactL + SSCR1_SClk1P + SSCR1_ExtClk;
+ GAFR |= GPIO_SSP_TXD | GPIO_SSP_RXD | GPIO_SSP_SCLK | GPIO_SSP_CLK |
+ GPIO_SSP_SFRM;
+ GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
+ GPDR &= ~(GPIO_SSP_RXD | GPIO_SSP_CLK);
+ Ser4SSCR0 |= SSCR0_SSE;
+
+ GAFR &= ~(SpeakerOffPin | QmutePin);
+ GPDR |= (SpeakerOffPin | QmutePin);
+ GPCR = SpeakerOffPin;
+
+ /*
+ * The assabet board uses the SDRAM clock as the source clock for
+ * audio. This is supplied to the SA11x0 from the CPLD on pin 19.
+ * At 206MHz we need to run the audio clock (SDRAM bank 2)
+ * at half speed. This clock will scale with core frequency so
+ * the audio sample rate will also scale. The CPLD on Assabet
+ * will need to be programmed to match the core frequency.
+ */
+ mdrefr = MDREFR;
+ if ((mdrefr & (MDREFR_K2DB2 | MDREFR_K2RUN | MDREFR_EAPD |
+ MDREFR_KAPD)) != (MDREFR_K2DB2 | MDREFR_K2RUN)) {
+ mdrefr |= MDREFR_K2DB2 | MDREFR_K2RUN;
+ mdrefr &= ~(MDREFR_EAPD | MDREFR_KAPD);
+ MDREFR = mdrefr;
+ (void) MDREFR;
+ }
+ local_irq_restore(flags);
+
+ /* Wait for the UDA1341 to wake up */
+ mdelay(100);
+
+ l3_open(&uda1341);
+
+ pangolin_set_samplerate(audio_samplerate);
+
+ GPCR = QmutePin;
+}
+
+static void pangolin_audio_shutdown(void *dummy)
+{
+ GPSR = QmutePin;
+
+ l3_close(&uda1341);
+
+ Ser4SSCR0 = 0;
+ MDREFR &= ~(MDREFR_K2DB2 | MDREFR_K2RUN);
+}
+
+static int pangolin_audio_ioctl( struct inode *inode, struct file *file,
+ uint cmd, ulong arg)
+{
+ long val;
+ int ret = 0;
+
+ /*
+ * These are platform dependent ioctls which are not handled by the
+ * generic sa1100-audio module.
+ */
+ switch (cmd) {
+ case SNDCTL_DSP_STEREO:
+ ret = get_user(val, (int *) arg);
+ if (ret)
+ return ret;
+ /* the UDA1341 is stereo only */
+ ret = (val == 0) ? -EINVAL : 1;
+ return put_user(ret, (int *) arg);
+
+ case SNDCTL_DSP_CHANNELS:
+ case SOUND_PCM_READ_CHANNELS:
+ /* the UDA1341 is stereo only */
+ return put_user(2, (long *) arg);
+
+ case SNDCTL_DSP_SPEED:
+ ret = get_user(val, (long *) arg);
+ if (ret) break;
+ pangolin_set_samplerate(val);
+ /* fall through */
+
+ case SOUND_PCM_READ_RATE:
+ return put_user(audio_samplerate, (long *) arg);
+
+ case SNDCTL_DSP_SETFMT:
+ case SNDCTL_DSP_GETFMTS:
+ /* we can do signed 16-bit only */
+ return put_user(AFMT_S16_LE, (long *) arg);
+
+ default:
+ /* Maybe this is meant for the mixer (As per OSS Docs) */
+ return mixer_ioctl(inode, file, cmd, arg);
+ }
+
+ return ret;
+}
+
+static audio_stream_t output_stream, input_stream;
+
+static audio_state_t audio_state = {
+ output_stream: &output_stream,
+ output_dma: DMA_Ser4SSPWr,
+ output_id: "Pangolin UDA1341 out",
+ input_stream: &input_stream,
+ input_dma: DMA_Ser4SSPRd,
+ input_id: "Pangolin UDA1341 in",
+ need_tx_for_rx: 1,
+ hw_init: pangolin_audio_init,
+ hw_shutdown: pangolin_audio_shutdown,
+ client_ioctl: pangolin_audio_ioctl,
+ sem: __MUTEX_INITIALIZER(audio_state.sem),
+};
+
+static int pangolin_audio_open(struct inode *inode, struct file *file)
+{
+ return sa1100_audio_attach(inode, file, &audio_state);
+}
+
+/*
+ * Missing fields of this structure will be patched with the call
+ * to sa1100_audio_attach().
+ */
+static struct file_operations pangolin_audio_fops = {
+ open: pangolin_audio_open,
+ owner: THIS_MODULE
+};
+
+
+static int audio_dev_id, mixer_dev_id;
+
+static int __init pangolin_uda1341_init(void)
+{
+ unsigned long flags;
+ int ret;
+
+ if (!machine_is_pangolin())
+ return -ENODEV;
+
+ ret = l3_attach_client(&uda1341, "l3-bit-sa1100-gpio", "uda1341");
+ if (ret)
+ goto out;
+
+ /* register devices */
+ audio_dev_id = register_sound_dsp(&pangolin_audio_fops, -1);
+ mixer_dev_id = register_sound_mixer(&pangolin_mixer_fops, -1);
+
+ local_irq_save(flags);
+ GAFR &= ~(SpeakerOffPin | QmutePin);
+ GPDR |= (SpeakerOffPin | QmutePin);
+ local_irq_restore(flags);
+
+ printk(KERN_INFO "Pangolin UDA1341 audio driver initialized\n");
+ return 0;
+
+release_l3:
+ l3_detach_client(&uda1341);
+out:
+ return ret;
+}
+
+static void __exit pangolin_uda1341_exit(void)
+{
+ unregister_sound_dsp(audio_dev_id);
+ unregister_sound_mixer(mixer_dev_id);
+ l3_detach_client(&uda1341);
+}
+
+module_init(pangolin_uda1341_init);
+module_exit(pangolin_uda1341_exit);
+
+MODULE_AUTHOR("Nicolas Pitre");
+MODULE_DESCRIPTION("Glue audio driver for the SA1110 Pangolin board & Philips UDA1341 codec.");
+
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/sound/sa1100-audio.c linux-2.4.26-vrs1/drivers/sound/sa1100-audio.c
--- linux-2.4.26/drivers/sound/sa1100-audio.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/sa1100-audio.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,976 @@
+/*
+ * Common audio handling for the SA11x0 processor
+ *
+ * Copyright (C) 2000, 2001 Nicolas Pitre <nico@cam.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ *
+ *
+ * This module handles the generic buffering/DMA/mmap audio interface for
+ * codecs connected to the SA1100 chip. All features depending on specific
+ * hardware implementations like supported audio formats or samplerates are
+ * relegated to separate specific modules.
+ *
+ *
+ * History:
+ *
+ * 2000-05-21 Nicolas Pitre Initial release.
+ *
+ * 2000-06-10 Erik Bunce Add initial poll support.
+ *
+ * 2000-08-22 Nicolas Pitre Removed all DMA stuff. Now using the
+ * generic SA1100 DMA interface.
+ *
+ * 2000-11-30 Nicolas Pitre - Validation of opened instances;
+ * - Power handling at open/release time instead
+ * of driver load/unload;
+ *
+ * 2001-06-03 Nicolas Pitre Made this file a separate module, based on
+ * the former sa1100-uda1341.c driver.
+ *
+ * 2001-07-22 Nicolas Pitre - added mmap() and realtime support
+ * - corrected many details to better comply
+ * with the OSS API
+ *
+ * 2001-10-19 Nicolas Pitre - brought DMA registration processing
+ * into this module for better ressource
+ * management. This also fixes a bug
+ * with the suspend/resume logic.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/poll.h>
+#include <linux/pm.h>
+#include <linux/errno.h>
+#include <linux/sound.h>
+#include <linux/soundcard.h>
+#include <linux/sysrq.h>
+
+#include <asm/uaccess.h>
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/semaphore.h>
+#include <asm/dma.h>
+
+#include "sa1100-audio.h"
+
+
+#undef DEBUG
+/* #define DEBUG 1 */
+#ifdef DEBUG
+#define DPRINTK( x... ) printk( ##x )
+#else
+#define DPRINTK( x... )
+#endif
+
+
+#define AUDIO_NAME "sa1100-audio"
+#define AUDIO_NBFRAGS_DEFAULT 8
+#define AUDIO_FRAGSIZE_DEFAULT 8192
+
+#define NEXT_BUF(_s_,_b_) { \
+ (_s_)->_b_##_idx++; \
+ (_s_)->_b_##_idx %= (_s_)->nbfrags; \
+ (_s_)->_b_ = (_s_)->buffers + (_s_)->_b_##_idx; }
+
+#define AUDIO_ACTIVE(state) ((state)->rd_ref || (state)->wr_ref)
+
+/*
+ * This function frees all buffers
+ */
+
+static void audio_clear_buf(audio_stream_t * s)
+{
+ DPRINTK("audio_clear_buf\n");
+
+ /* ensure DMA won't run anymore */
+ s->active = 0;
+ s->stopped = 0;
+ sa1100_dma_flush_all(s->dma_ch);
+
+ if (s->buffers) {
+ int frag;
+ for (frag = 0; frag < s->nbfrags; frag++) {
+ if (!s->buffers[frag].master)
+ continue;
+ consistent_free(s->buffers[frag].start,
+ s->buffers[frag].master,
+ s->buffers[frag].dma_addr);
+ }
+ kfree(s->buffers);
+ s->buffers = NULL;
+ }
+
+ s->buf_idx = 0;
+ s->buf = NULL;
+}
+
+
+/*
+ * This function allocates the buffer structure array and buffer data space
+ * according to the current number of fragments and fragment size.
+ */
+
+static int audio_setup_buf(audio_stream_t * s)
+{
+ int frag;
+ int dmasize = 0;
+ char *dmabuf = NULL;
+ dma_addr_t dmaphys = 0;
+
+ if (s->buffers)
+ return -EBUSY;
+
+ s->buffers = (audio_buf_t *)
+ kmalloc(sizeof(audio_buf_t) * s->nbfrags, GFP_KERNEL);
+ if (!s->buffers)
+ goto err;
+ memset(s->buffers, 0, sizeof(audio_buf_t) * s->nbfrags);
+
+ for (frag = 0; frag < s->nbfrags; frag++) {
+ audio_buf_t *b = &s->buffers[frag];
+
+ /*
+ * Let's allocate non-cached memory for DMA buffers.
+ * We try to allocate all memory at once.
+ * If this fails (a common reason is memory fragmentation),
+ * then we allocate more smaller buffers.
+ */
+ if (!dmasize) {
+ dmasize = (s->nbfrags - frag) * s->fragsize;
+ do {
+ dmabuf = consistent_alloc(GFP_KERNEL|GFP_DMA,
+ dmasize,
+ &dmaphys);
+ if (!dmabuf)
+ dmasize -= s->fragsize;
+ } while (!dmabuf && dmasize);
+ if (!dmabuf)
+ goto err;
+ b->master = dmasize;
+ memzero(dmabuf, dmasize);
+ }
+
+ b->start = dmabuf;
+ b->dma_addr = dmaphys;
+ b->stream = s;
+ sema_init(&b->sem, 1);
+ DPRINTK("buf %d: start %p dma %p\n", frag, b->start,
+ b->dma_addr);
+
+ dmabuf += s->fragsize;
+ dmaphys += s->fragsize;
+ dmasize -= s->fragsize;
+ }
+
+ s->buf_idx = 0;
+ s->buf = &s->buffers[0];
+ s->bytecount = 0;
+ s->getptrCount = 0;
+ s->fragcount = 0;
+
+ return 0;
+
+err:
+ printk(AUDIO_NAME ": unable to allocate audio memory\n ");
+ audio_clear_buf(s);
+ return -ENOMEM;
+}
+
+
+/*
+ * This function yanks all buffers from the DMA code's control and
+ * resets them ready to be used again.
+ */
+
+static void audio_reset_buf(audio_stream_t * s)
+{
+ int frag;
+
+ s->active = 0;
+ s->stopped = 0;
+ sa1100_dma_flush_all(s->dma_ch);
+ if (s->buffers) {
+ for (frag = 0; frag < s->nbfrags; frag++) {
+ audio_buf_t *b = &s->buffers[frag];
+ b->size = 0;
+ sema_init(&b->sem, 1);
+ }
+ }
+ s->bytecount = 0;
+ s->getptrCount = 0;
+ s->fragcount = 0;
+}
+
+
+/*
+ * DMA callback functions
+ */
+
+static void audio_dmaout_done_callback(void *buf_id, int size)
+{
+ audio_buf_t *b = (audio_buf_t *) buf_id;
+ audio_stream_t *s = b->stream;
+
+ /* Accounting */
+ s->bytecount += size;
+ s->fragcount++;
+
+ /* Recycle buffer */
+ if (s->mapped)
+ sa1100_dma_queue_buffer(s->dma_ch, buf_id,
+ b->dma_addr, s->fragsize);
+ else
+ up(&b->sem);
+
+ /* And any process polling on write. */
+ wake_up(&s->wq);
+}
+
+static void audio_dmain_done_callback(void *buf_id, int size)
+{
+ audio_buf_t *b = (audio_buf_t *) buf_id;
+ audio_stream_t *s = b->stream;
+
+ /* Accounting */
+ s->bytecount += size;
+ s->fragcount++;
+
+ /* Recycle buffer */
+ if (s->mapped) {
+ sa1100_dma_queue_buffer(s->dma_ch, buf_id,
+ b->dma_addr, s->fragsize);
+ } else {
+ b->size = size;
+ up(&b->sem);
+ }
+
+ /* And any process polling on write. */
+ wake_up(&s->wq);
+}
+
+static int audio_sync(struct file *file)
+{
+ audio_state_t *state = (audio_state_t *)file->private_data;
+ audio_stream_t *s = state->output_stream;
+ audio_buf_t *b;
+
+ DPRINTK("audio_sync\n");
+
+ if (!(file->f_mode & FMODE_WRITE) || !s->buffers || s->mapped)
+ return 0;
+
+ /*
+ * Send current buffer if it contains data. Be sure to send
+ * a full sample count.
+ */
+ b = s->buf;
+ if (b->size &= ~3) {
+ down(&b->sem);
+ sa1100_dma_queue_buffer(s->dma_ch, (void *) b,
+ b->dma_addr, b->size);
+ b->size = 0;
+ NEXT_BUF(s, buf);
+ }
+
+ /*
+ * Let's wait for the last buffer we sent i.e. the one before the
+ * current buf_idx. When we acquire the semaphore, this means either:
+ * - DMA on the buffer completed or
+ * - the buffer was already free thus nothing else to sync.
+ */
+ b = s->buffers + ((s->nbfrags + s->buf_idx - 1) % s->nbfrags);
+ if (down_interruptible(&b->sem))
+ return -EINTR;
+ up(&b->sem);
+ return 0;
+}
+
+
+static int audio_write(struct file *file, const char *buffer,
+ size_t count, loff_t * ppos)
+{
+ const char *buffer0 = buffer;
+ audio_state_t *state = (audio_state_t *)file->private_data;
+ audio_stream_t *s = state->output_stream;
+ int chunksize, ret = 0;
+
+ DPRINTK("audio_write: count=%d\n", count);
+
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+ if (s->mapped)
+ return -ENXIO;
+ if (!s->buffers && audio_setup_buf(s))
+ return -ENOMEM;
+
+ while (count > 0) {
+ audio_buf_t *b = s->buf;
+
+ /* Wait for a buffer to become free */
+ if (file->f_flags & O_NONBLOCK) {
+ ret = -EAGAIN;
+ if (down_trylock(&b->sem))
+ break;
+ } else {
+ ret = -ERESTARTSYS;
+ if (down_interruptible(&b->sem))
+ break;
+ }
+
+ /* Feed the current buffer */
+ chunksize = s->fragsize - b->size;
+ if (chunksize > count)
+ chunksize = count;
+ DPRINTK("write %d to %d\n", chunksize, s->buf_idx);
+ if (copy_from_user(b->start + b->size, buffer, chunksize)) {
+ up(&b->sem);
+ return -EFAULT;
+ }
+ b->size += chunksize;
+ buffer += chunksize;
+ count -= chunksize;
+ if (b->size < s->fragsize) {
+ up(&b->sem);
+ break;
+ }
+
+ /* Send current buffer to dma */
+ s->active = 1;
+ sa1100_dma_queue_buffer(s->dma_ch, (void *) b,
+ b->dma_addr, b->size);
+ b->size = 0; /* indicate that the buffer has been sent */
+ NEXT_BUF(s, buf);
+ }
+
+ if ((buffer - buffer0))
+ ret = buffer - buffer0;
+ DPRINTK("audio_write: return=%d\n", ret);
+ return ret;
+}
+
+
+static inline void audio_check_tx_spin(audio_state_t *state)
+{
+ /*
+ * With some codecs like the Philips UDA1341 we must ensure
+ * there is an output stream at any time while recording since
+ * this is how the UDA1341 gets its clock from the SA1100.
+ * So while there is no playback data to send, the output DMA
+ * will spin with all zeroes. We use the cache flush special
+ * area for that.
+ */
+ if (state->need_tx_for_rx && !state->tx_spinning) {
+ sa1100_dma_set_spin(state->output_stream->dma_ch,
+ (dma_addr_t)FLUSH_BASE_PHYS, 2048);
+ state->tx_spinning = 1;
+ }
+}
+
+
+static void audio_prime_dma(audio_stream_t *s)
+{
+ int i;
+
+ s->active = 1;
+ for (i = 0; i < s->nbfrags; i++) {
+ audio_buf_t *b = s->buf;
+ down(&b->sem);
+ sa1100_dma_queue_buffer(s->dma_ch, (void *) b,
+ b->dma_addr, s->fragsize);
+ NEXT_BUF(s, buf);
+ }
+}
+
+
+static int audio_read(struct file *file, char *buffer,
+ size_t count, loff_t * ppos)
+{
+ char *buffer0 = buffer;
+ audio_state_t *state = (audio_state_t *)file->private_data;
+ audio_stream_t *s = state->input_stream;
+ int chunksize, ret = 0;
+
+ DPRINTK("audio_read: count=%d\n", count);
+
+ if (ppos != &file->f_pos)
+ return -ESPIPE;
+ if (s->mapped)
+ return -ENXIO;
+
+ if (!s->active) {
+ if (!s->buffers && audio_setup_buf(s))
+ return -ENOMEM;
+ audio_check_tx_spin(state);
+ audio_prime_dma(s);
+ }
+
+ while (count > 0) {
+ audio_buf_t *b = s->buf;
+
+ /* Wait for a buffer to become full */
+ if (file->f_flags & O_NONBLOCK) {
+ ret = -EAGAIN;
+ if (down_trylock(&b->sem))
+ break;
+ } else {
+ ret = -ERESTARTSYS;
+ if (down_interruptible(&b->sem))
+ break;
+ }
+
+ /* Grab data from the current buffer */
+ chunksize = b->size;
+ if (chunksize > count)
+ chunksize = count;
+ DPRINTK("read %d from %d\n", chunksize, s->buf_idx);
+ if (copy_to_user(buffer,
+ b->start + s->fragsize - b->size,
+ chunksize)) {
+ up(&b->sem);
+ return -EFAULT;
+ }
+ b->size -= chunksize;
+ buffer += chunksize;
+ count -= chunksize;
+ if (b->size > 0) {
+ up(&b->sem);
+ break;
+ }
+
+ /* Make current buffer available for DMA again */
+ sa1100_dma_queue_buffer(s->dma_ch, (void *) b,
+ b->dma_addr, s->fragsize);
+ NEXT_BUF(s, buf);
+ }
+
+ if ((buffer - buffer0))
+ ret = buffer - buffer0;
+ DPRINTK("audio_read: return=%d\n", ret);
+ return ret;
+}
+
+
+static int audio_mmap(struct file *file, struct vm_area_struct *vma)
+{
+ audio_state_t *state = (audio_state_t *)file->private_data;
+ audio_stream_t *s;
+ unsigned long size, vma_addr;
+ int i, ret;
+
+ if (vma->vm_pgoff != 0)
+ return -EINVAL;
+
+ if (vma->vm_flags & VM_WRITE) {
+ if (!state->wr_ref)
+ return -EINVAL;;
+ s = state->output_stream;
+ } else if (vma->vm_flags & VM_READ) {
+ if (!state->rd_ref)
+ return -EINVAL;
+ s = state->input_stream;
+ } else return -EINVAL;
+
+ if (s->mapped)
+ return -EINVAL;
+ size = vma->vm_end - vma->vm_start;
+ if (size != s->fragsize * s->nbfrags)
+ return -EINVAL;
+ if (!s->buffers && audio_setup_buf(s))
+ return -ENOMEM;
+ vma_addr = vma->vm_start;
+ for (i = 0; i < s->nbfrags; i++) {
+ audio_buf_t *buf = &s->buffers[i];
+ if (!buf->master)
+ continue;
+ ret = remap_page_range(vma_addr, buf->dma_addr, buf->master, vma->vm_page_prot);
+ if (ret)
+ return ret;
+ vma_addr += buf->master;
+ }
+ s->mapped = 1;
+
+ return 0;
+}
+
+
+static unsigned int audio_poll(struct file *file,
+ struct poll_table_struct *wait)
+{
+ audio_state_t *state = (audio_state_t *)file->private_data;
+ audio_stream_t *is = state->input_stream;
+ audio_stream_t *os = state->output_stream;
+ unsigned int mask = 0;
+ int i;
+
+ DPRINTK("audio_poll(): mode=%s%s\n",
+ (file->f_mode & FMODE_READ) ? "r" : "",
+ (file->f_mode & FMODE_WRITE) ? "w" : "");
+
+ if (file->f_mode & FMODE_READ) {
+ /* Start audio input if not already active */
+ if (!is->active) {
+ if (!is->buffers && audio_setup_buf(is))
+ return -ENOMEM;
+ audio_check_tx_spin(state);
+ audio_prime_dma(is);
+ }
+ poll_wait(file, &is->wq, wait);
+ }
+
+ if (file->f_mode & FMODE_WRITE) {
+ if (!os->buffers && audio_setup_buf(os))
+ return -ENOMEM;
+ poll_wait(file, &os->wq, wait);
+ }
+
+ if (file->f_mode & FMODE_READ) {
+ if (is->mapped) {
+/* if the buffer is mapped assume we care that there are more bytes available than
+ when we last asked using SNDCTL_DSP_GETxPTR */
+ if (is->bytecount != is->getptrCount)
+ mask |= POLLIN | POLLRDNORM;
+ } else {
+ for (i = 0; i < is->nbfrags; i++) {
+ if (atomic_read(&is->buffers[i].sem.count) > 0) {
+ mask |= POLLIN | POLLRDNORM;
+ break;
+ }
+ }
+ }
+ }
+ if (file->f_mode & FMODE_WRITE) {
+ if (os->mapped) {
+ if (os->bytecount != os->getptrCount)
+ mask |= POLLOUT | POLLWRNORM;
+ } else {
+ for (i = 0; i < os->nbfrags; i++) {
+ if (atomic_read(&os->buffers[i].sem.count) > 0) {
+ mask |= POLLOUT | POLLWRNORM;
+ break;
+ }
+ }
+ }
+ }
+
+ DPRINTK("audio_poll() returned mask of %s%s\n",
+ (mask & POLLIN) ? "r" : "",
+ (mask & POLLOUT) ? "w" : "");
+
+ return mask;
+}
+
+
+static loff_t audio_llseek(struct file *file, loff_t offset, int origin)
+{
+ return -ESPIPE;
+}
+
+
+static int audio_set_fragments(audio_stream_t *s, int val)
+{
+ if (s->active)
+ return -EBUSY;
+ if (s->buffers)
+ audio_clear_buf(s);
+ s->nbfrags = (val >> 16) & 0x7FFF;
+ val &= 0xffff;
+ if (val < 4)
+ val = 4;
+ if (val > 15)
+ val = 15;
+ s->fragsize = 1 << val;
+ if (s->nbfrags < 2)
+ s->nbfrags = 2;
+ if (s->nbfrags * s->fragsize > 128 * 1024)
+ s->nbfrags = 128 * 1024 / s->fragsize;
+ if (audio_setup_buf(s))
+ return -ENOMEM;
+ return val|(s->nbfrags << 16);
+}
+
+static int audio_ioctl(struct inode *inode, struct file *file,
+ uint cmd, ulong arg)
+{
+ audio_state_t *state = (audio_state_t *)file->private_data;
+ audio_stream_t *os = state->output_stream;
+ audio_stream_t *is = state->input_stream;
+ long val;
+
+ /* dispatch based on command */
+ switch (cmd) {
+ case OSS_GETVERSION:
+ return put_user(SOUND_VERSION, (int *)arg);
+
+ case SNDCTL_DSP_GETBLKSIZE:
+ if (file->f_mode & FMODE_WRITE)
+ return put_user(os->fragsize, (int *)arg);
+ else
+ return put_user(is->fragsize, (int *)arg);
+
+ case SNDCTL_DSP_GETCAPS:
+ val = DSP_CAP_REALTIME|DSP_CAP_TRIGGER|DSP_CAP_MMAP;
+ if (is && os)
+ val |= DSP_CAP_DUPLEX;
+ return put_user(val, (int *)arg);
+
+ case SNDCTL_DSP_SETFRAGMENT:
+ if (get_user(val, (long *) arg))
+ return -EFAULT;
+ if (file->f_mode & FMODE_READ) {
+ int ret = audio_set_fragments(is, val);
+ if (ret < 0)
+ return ret;
+ ret = put_user(ret, (int *)arg);
+ if (ret)
+ return ret;
+ }
+ if (file->f_mode & FMODE_WRITE) {
+ int ret = audio_set_fragments(os, val);
+ if (ret < 0)
+ return ret;
+ ret = put_user(ret, (int *)arg);
+ if (ret)
+ return ret;
+ }
+ return 0;
+
+ case SNDCTL_DSP_SYNC:
+ return audio_sync(file);
+
+ case SNDCTL_DSP_SETDUPLEX:
+ return 0;
+
+ case SNDCTL_DSP_POST:
+ return 0;
+
+ case SNDCTL_DSP_GETTRIGGER:
+ val = 0;
+ if (file->f_mode & FMODE_READ && is->active && !is->stopped)
+ val |= PCM_ENABLE_INPUT;
+ if (file->f_mode & FMODE_WRITE && os->active && !os->stopped)
+ val |= PCM_ENABLE_OUTPUT;
+ return put_user(val, (int *)arg);
+
+ case SNDCTL_DSP_SETTRIGGER:
+ if (get_user(val, (int *)arg))
+ return -EFAULT;
+ if (file->f_mode & FMODE_READ) {
+ if (val & PCM_ENABLE_INPUT) {
+ if (!is->active) {
+ if (!is->buffers && audio_setup_buf(is))
+ return -ENOMEM;
+ audio_prime_dma(is);
+ }
+ audio_check_tx_spin(state);
+ if (is->stopped) {
+ is->stopped = 0;
+ sa1100_dma_resume(is->dma_ch);
+ }
+ } else {
+ sa1100_dma_stop(is->dma_ch);
+ is->stopped = 1;
+ }
+ }
+ if (file->f_mode & FMODE_WRITE) {
+ if (val & PCM_ENABLE_OUTPUT) {
+ if (!os->active) {
+ if (!os->buffers && audio_setup_buf(os))
+ return -ENOMEM;
+ if (os->mapped)
+ audio_prime_dma(os);
+ }
+ if (os->stopped) {
+ os->stopped = 0;
+ sa1100_dma_resume(os->dma_ch);
+ }
+ } else {
+ sa1100_dma_stop(os->dma_ch);
+ os->stopped = 1;
+ }
+ }
+ return 0;
+
+ case SNDCTL_DSP_GETOPTR:
+ case SNDCTL_DSP_GETIPTR:
+ {
+ count_info inf = { 0, };
+ audio_stream_t *s = (cmd == SNDCTL_DSP_GETOPTR) ? os : is;
+ audio_buf_t *b;
+ dma_addr_t ptr;
+ int bytecount, offset, flags;
+
+ if ((s == is && !(file->f_mode & FMODE_READ)) ||
+ (s == os && !(file->f_mode & FMODE_WRITE)))
+ return -EINVAL;
+ if (s->active) {
+ save_flags_cli(flags);
+ if (sa1100_dma_get_current(s->dma_ch, (void *)&b, &ptr) == 0) {
+ offset = ptr - b->dma_addr;
+ inf.ptr = (b - s->buffers) * s->fragsize + offset;
+ } else offset = 0;
+ bytecount = s->bytecount + offset;
+ s->getptrCount = s->bytecount; /* so poll can tell if it changes */
+ inf.blocks = s->fragcount;
+ s->fragcount = 0;
+ restore_flags(flags);
+ if (bytecount < 0)
+ bytecount = 0;
+ inf.bytes = bytecount;
+ }
+ return copy_to_user((void *)arg, &inf, sizeof(inf));
+ }
+
+ case SNDCTL_DSP_GETOSPACE:
+ {
+ audio_buf_info inf = { 0, };
+ int i;
+
+ if (!(file->f_mode & FMODE_WRITE))
+ return -EINVAL;
+ if (!os->buffers && audio_setup_buf(os))
+ return -ENOMEM;
+ for (i = 0; i < os->nbfrags; i++) {
+ if (atomic_read(&os->buffers[i].sem.count) > 0) {
+ if (os->buffers[i].size == 0)
+ inf.fragments++;
+ inf.bytes += os->fragsize - os->buffers[i].size;
+ }
+ }
+ inf.fragstotal = os->nbfrags;
+ inf.fragsize = os->fragsize;
+ return copy_to_user((void *)arg, &inf, sizeof(inf));
+ }
+
+ case SNDCTL_DSP_GETISPACE:
+ {
+ audio_buf_info inf = { 0, };
+ int i;
+
+ if (!(file->f_mode & FMODE_READ))
+ return -EINVAL;
+ if (!is->buffers && audio_setup_buf(is))
+ return -ENOMEM;
+ for (i = 0; i < is->nbfrags; i++) {
+ if (atomic_read(&is->buffers[i].sem.count) > 0) {
+ if (is->buffers[i].size == is->fragsize)
+ inf.fragments++;
+ inf.bytes += is->buffers[i].size;
+ }
+ }
+ inf.fragstotal = is->nbfrags;
+ inf.fragsize = is->fragsize;
+ return copy_to_user((void *)arg, &inf, sizeof(inf));
+ }
+
+ case SNDCTL_DSP_NONBLOCK:
+ file->f_flags |= O_NONBLOCK;
+ return 0;
+
+ case SNDCTL_DSP_RESET:
+ if (file->f_mode & FMODE_READ) {
+ if (state->tx_spinning) {
+ sa1100_dma_set_spin(os->dma_ch, 0, 0);
+ state->tx_spinning = 0;
+ }
+ audio_reset_buf(is);
+ }
+ if (file->f_mode & FMODE_WRITE) {
+ audio_reset_buf(os);
+ }
+ return 0;
+
+ default:
+ /*
+ * Let the client of this module handle the
+ * non generic ioctls
+ */
+ return state->client_ioctl(inode, file, cmd, arg);
+ }
+
+ return 0;
+}
+
+
+static int audio_release(struct inode *inode, struct file *file)
+{
+ audio_state_t *state = (audio_state_t *)file->private_data;
+ DPRINTK("audio_release\n");
+
+ down(&state->sem);
+
+ if (file->f_mode & FMODE_READ) {
+ if (state->tx_spinning) {
+ sa1100_dma_set_spin(state->output_stream->dma_ch, 0, 0);
+ state->tx_spinning = 0;
+ }
+ audio_clear_buf(state->input_stream);
+ if (!state->skip_dma_init) {
+ sa1100_free_dma(state->input_stream->dma_ch);
+ if (state->need_tx_for_rx && !state->wr_ref)
+ sa1100_free_dma(state->output_stream->dma_ch);
+ }
+ state->rd_ref = 0;
+ }
+
+ if (file->f_mode & FMODE_WRITE) {
+ audio_sync(file);
+ audio_clear_buf(state->output_stream);
+ if (!state->skip_dma_init)
+ if (!state->need_tx_for_rx || !state->rd_ref)
+ sa1100_free_dma(state->output_stream->dma_ch);
+ state->wr_ref = 0;
+ }
+
+ if (!AUDIO_ACTIVE(state)) {
+ if (state->hw_shutdown)
+ state->hw_shutdown(state->data);
+#ifdef CONFIG_PM
+ pm_unregister(state->pm_dev);
+#endif
+ }
+
+ up(&state->sem);
+ return 0;
+}
+
+
+#ifdef CONFIG_PM
+
+static int audio_pm_callback(struct pm_dev *pm_dev, pm_request_t req, void *data)
+{
+ audio_state_t *state = (audio_state_t *)pm_dev->data;
+
+ switch (req) {
+ case PM_SUSPEND: /* enter D1-D3 */
+ if (state->output_stream)
+ sa1100_dma_sleep(state->output_stream->dma_ch);
+ if (state->input_stream)
+ sa1100_dma_sleep(state->input_stream->dma_ch);
+ if (AUDIO_ACTIVE(state) && state->hw_shutdown)
+ state->hw_shutdown(state->data);
+ break;
+ case PM_RESUME: /* enter D0 */
+ if (AUDIO_ACTIVE(state) && state->hw_init)
+ state->hw_init(state->data);
+ if (state->input_stream)
+ sa1100_dma_wakeup(state->input_stream->dma_ch);
+ if (state->output_stream)
+ sa1100_dma_wakeup(state->output_stream->dma_ch);
+ break;
+ }
+ return 0;
+}
+
+#endif
+
+
+int sa1100_audio_attach(struct inode *inode, struct file *file,
+ audio_state_t *state)
+{
+ int err, need_tx_dma;
+
+ DPRINTK("audio_open\n");
+
+ down(&state->sem);
+
+ /* access control */
+ err = -ENODEV;
+ if ((file->f_mode & FMODE_WRITE) && !state->output_stream)
+ goto out;
+ if ((file->f_mode & FMODE_READ) && !state->input_stream)
+ goto out;
+ err = -EBUSY;
+ if ((file->f_mode & FMODE_WRITE) && state->wr_ref)
+ goto out;
+ if ((file->f_mode & FMODE_READ) && state->rd_ref)
+ goto out;
+ err = -EINVAL;
+ if ((file->f_mode & FMODE_READ) && state->need_tx_for_rx && !state->output_stream)
+ goto out;
+
+ /* request DMA channels */
+ if (state->skip_dma_init)
+ goto skip_dma;
+ need_tx_dma = ((file->f_mode & FMODE_WRITE) ||
+ ((file->f_mode & FMODE_READ) && state->need_tx_for_rx));
+ if (state->wr_ref || (state->rd_ref && state->need_tx_for_rx))
+ need_tx_dma = 0;
+ if (need_tx_dma) {
+ err = sa1100_request_dma(&state->output_stream->dma_ch,
+ state->output_id,
+ state->output_dma);
+ if (err)
+ goto out;
+ }
+ if (file->f_mode & FMODE_READ) {
+ err = sa1100_request_dma(&state->input_stream->dma_ch,
+ state->input_id,
+ state->input_dma);
+ if (err) {
+ if (need_tx_dma)
+ sa1100_free_dma(state->output_stream->dma_ch);
+ goto out;
+ }
+ }
+skip_dma:
+
+ /* now complete initialisation */
+ if (!AUDIO_ACTIVE(state)) {
+ if (state->hw_init)
+ state->hw_init(state->data);
+#ifdef CONFIG_PM
+ state->pm_dev = pm_register(PM_SYS_DEV, 0, audio_pm_callback);
+ if (state->pm_dev)
+ state->pm_dev->data = state;
+#endif
+ }
+
+ if ((file->f_mode & FMODE_WRITE)) {
+ state->wr_ref = 1;
+ audio_clear_buf(state->output_stream);
+ state->output_stream->fragsize = AUDIO_FRAGSIZE_DEFAULT;
+ state->output_stream->nbfrags = AUDIO_NBFRAGS_DEFAULT;
+ state->output_stream->mapped = 0;
+ sa1100_dma_set_callback(state->output_stream->dma_ch,
+ audio_dmaout_done_callback);
+ init_waitqueue_head(&state->output_stream->wq);
+ }
+ if (file->f_mode & FMODE_READ) {
+ state->rd_ref = 1;
+ audio_clear_buf(state->input_stream);
+ state->input_stream->fragsize = AUDIO_FRAGSIZE_DEFAULT;
+ state->input_stream->nbfrags = AUDIO_NBFRAGS_DEFAULT;
+ state->input_stream->mapped = 0;
+ sa1100_dma_set_callback(state->input_stream->dma_ch,
+ audio_dmain_done_callback);
+ init_waitqueue_head(&state->input_stream->wq);
+ }
+
+ file->private_data = state;
+ file->f_op->release = audio_release;
+ file->f_op->write = audio_write;
+ file->f_op->read = audio_read;
+ file->f_op->mmap = audio_mmap;
+ file->f_op->poll = audio_poll;
+ file->f_op->ioctl = audio_ioctl;
+ file->f_op->llseek = audio_llseek;
+ err = 0;
+
+out:
+ up(&state->sem);
+ return err;
+}
+
+EXPORT_SYMBOL(sa1100_audio_attach);
+
+MODULE_AUTHOR("Nicolas Pitre");
+MODULE_DESCRIPTION("Common audio handling for the SA11x0 processor");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/sound/sa1100-audio.h linux-2.4.26-vrs1/drivers/sound/sa1100-audio.h
--- linux-2.4.26/drivers/sound/sa1100-audio.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/sa1100-audio.h 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,68 @@
+/*
+ * Common audio handling for the SA11x0
+ *
+ * Copyright (c) 2000 Nicolas Pitre <nico@cam.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ */
+
+
+/*
+ * Buffer Management
+ */
+
+typedef struct {
+ int size; /* buffer size */
+ char *start; /* points to actual buffer */
+ dma_addr_t dma_addr; /* physical buffer address */
+ struct semaphore sem; /* down before touching the buffer */
+ int master; /* owner for buffer allocation, contain size when true */
+ struct audio_stream_s *stream; /* owning stream */
+} audio_buf_t;
+
+typedef struct audio_stream_s {
+ audio_buf_t *buffers; /* pointer to audio buffer structures */
+ audio_buf_t *buf; /* current buffer used by read/write */
+ u_int buf_idx; /* index for the pointer above... */
+ u_int fragsize; /* fragment i.e. buffer size */
+ u_int nbfrags; /* nbr of fragments i.e. buffers */
+ int bytecount; /* nbr of processed bytes */
+ int getptrCount; /* value of bytecount last time anyone asked via GETxPTR */
+ int fragcount; /* nbr of fragment transitions */
+ dmach_t dma_ch; /* DMA channel ID */
+ wait_queue_head_t wq; /* for poll */
+ int mapped:1; /* mmap()'ed buffers */
+ int active:1; /* actually in progress */
+ int stopped:1; /* might be active but stopped */
+} audio_stream_t;
+
+/*
+ * State structure for one instance
+ */
+
+typedef struct {
+ audio_stream_t *output_stream;
+ audio_stream_t *input_stream;
+ dma_device_t output_dma;
+ dma_device_t input_dma;
+ char *output_id;
+ char *input_id;
+ int rd_ref:1; /* open reference for recording */
+ int wr_ref:1; /* open reference for playback */
+ int need_tx_for_rx:1; /* if data must be sent while receiving */
+ int tx_spinning:1; /* tx spinning active */
+ int skip_dma_init:1; /* hack for the SA1111 */
+ void *data;
+ void (*hw_init)(void *);
+ void (*hw_shutdown)(void *);
+ int (*client_ioctl)(struct inode *, struct file *, uint, ulong);
+ struct pm_dev *pm_dev;
+ struct semaphore sem; /* to protect against races in attach() */
+} audio_state_t;
+
+/*
+ * Functions exported by this module
+ */
+extern int sa1100_audio_attach( struct inode *inode, struct file *file,
+ audio_state_t *state);
diff -urN linux-2.4.26/drivers/sound/sa1100ssp.c linux-2.4.26-vrs1/drivers/sound/sa1100ssp.c
--- linux-2.4.26/drivers/sound/sa1100ssp.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/sa1100ssp.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,182 @@
+/*
+ * Glue audio driver for a simple DAC on the SA1100's SSP port
+ *
+ * Copyright (c) 2001 Nicolas Pitre <nico@cam.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ *
+ * History:
+ *
+ * 2001-06-04 Nicolas Pitre Initial release.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/errno.h>
+#include <linux/sound.h>
+#include <linux/soundcard.h>
+
+#include <asm/semaphore.h>
+#include <asm/uaccess.h>
+#include <asm/hardware.h>
+#include <asm/dma.h>
+
+#include "sa1100-audio.h"
+
+
+#undef DEBUG
+#ifdef DEBUG
+#define DPRINTK( x... ) printk( ##x )
+#else
+#define DPRINTK( x... )
+#endif
+
+
+#define AUDIO_NAME "SA1100 SSP audio"
+
+#define AUDIO_FMT AFMT_S16_LE
+#define AUDIO_CHANNELS 2
+
+static int sample_rate = 44100;
+
+
+static void ssp_audio_init(void)
+{
+ if (machine_is_lart()) {
+ unsigned long flags;
+ local_irq_save(flags);
+
+ /* LART has the SSP port rewired to GPIO 10-13, 19 */
+ /* alternate functions for the GPIOs */
+ GAFR |= ( GPIO_SSP_TXD | GPIO_SSP_RXD | GPIO_SSP_SCLK |
+ GPIO_SSP_SFRM | GPIO_SSP_CLK );
+
+ /* Set the direction: 10, 12, 13 output; 11, 19 input */
+ GPDR |= ( GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM );
+ GPDR &= ~( GPIO_SSP_RXD | GPIO_SSP_CLK );
+
+ /* enable SSP pin swap */
+ PPAR |= PPAR_SPR;
+
+ local_irq_restore(flags);
+ }
+
+ /* turn on the SSP */
+ Ser4SSCR0 = 0;
+ Ser4SSCR0 = (SSCR0_DataSize(16) | SSCR0_TI | SSCR0_SerClkDiv(2) |
+ SSCR0_SSE);
+ Ser4SSCR1 = (SSCR1_SClkIactL | SSCR1_SClk1P | SSCR1_ExtClk);
+}
+
+static void ssp_audio_shutdown(void)
+{
+ Ser4SSCR0 = 0;
+}
+
+static int ssp_audio_ioctl( struct inode *inode, struct file *file,
+ uint cmd, ulong arg)
+{
+ long val;
+ int ret = 0;
+
+ /*
+ * These are platform dependent ioctls which are not handled by the
+ * generic sa1100-audio module.
+ */
+ switch (cmd) {
+ case SNDCTL_DSP_STEREO:
+ ret = get_user(val, (int *) arg);
+ if (ret)
+ return ret;
+ /* Simple standard DACs are stereo only */
+ ret = (val == 0) ? -EINVAL : 1;
+ return put_user(ret, (int *) arg);
+
+ case SNDCTL_DSP_CHANNELS:
+ case SOUND_PCM_READ_CHANNELS:
+ /* Simple standard DACs are stereo only */
+ return put_user(AUDIO_CHANNELS, (long *) arg);
+
+ case SNDCTL_DSP_SPEED:
+ case SOUND_PCM_READ_RATE:
+ /* We assume the clock doesn't change */
+ return put_user(sample_rate, (long *) arg);
+
+ case SNDCTL_DSP_SETFMT:
+ case SNDCTL_DSP_GETFMTS:
+ /* Simple standard DACs are 16-bit only */
+ return put_user(AUDIO_FMT, (long *) arg);
+
+ default:
+ return -EINVAL;
+ }
+
+ return ret;
+}
+
+static audio_stream_t output_stream;
+
+static audio_state_t audio_state = {
+ output_stream: &output_stream,
+ output_dma: DMA_Ser4SSPWr,
+ output_id: "Generic SSP sound",
+ hw_init: ssp_audio_init,
+ hw_shutdown: ssp_audio_shutdown,
+ client_ioctl: ssp_audio_ioctl,
+ sem: __MUTEX_INITIALIZER(audio_state.sem),
+};
+
+static int ssp_audio_open(struct inode *inode, struct file *file)
+{
+ return sa1100_audio_attach(inode, file, &audio_state);
+}
+
+/*
+ * Missing fields of this structure will be patched with the call
+ * to sa1100_audio_attach().
+ */
+static struct file_operations ssp_audio_fops = {
+ open: ssp_audio_open,
+ owner: THIS_MODULE
+};
+
+static int audio_dev_id;
+
+static int __init sa1100ssp_audio_init(void)
+{
+ int ret;
+
+ if (!machine_is_lart()) {
+ printk(KERN_ERR AUDIO_NAME ": no support for this SA-1100 design!\n");
+ /* look at ssp_audio_init() for specific initialisations */
+ return -ENODEV;
+ }
+
+ /* register devices */
+ audio_dev_id = register_sound_dsp(&ssp_audio_fops, -1);
+
+ printk( KERN_INFO AUDIO_NAME " initialized\n" );
+ return 0;
+}
+
+static void __exit sa1100ssp_audio_exit(void)
+{
+ unregister_sound_dsp(audio_dev_id);
+}
+
+module_init(sa1100ssp_audio_init);
+module_exit(sa1100ssp_audio_exit);
+
+MODULE_AUTHOR("Nicolas Pitre");
+MODULE_DESCRIPTION("Glue audio driver for a simple DAC on the SA1100's SSP port");
+
+MODULE_PARM(sample_rate, "i");
+MODULE_PARM_DESC(sample_rate, "Sample rate of the audio DAC, default is 44100");
+
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/sound/sa1111-ac97.c linux-2.4.26-vrs1/drivers/sound/sa1111-ac97.c
--- linux-2.4.26/drivers/sound/sa1111-ac97.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/sa1111-ac97.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,518 @@
+/*
+ * Glue audio driver for the CS4205 and CS4201 AC'97 codecs.
+ * largely based on the framework provided by sa1111-uda1341.c.
+ *
+ * Copyright (c) 2002 Bertrik Sikken (bertrik.sikken@technolution.nl)
+ * Copyright (c) 2002 Robert Whaley (rwhaley@applieddata.net)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ *
+ * This driver makes use of the ac97_codec module (for mixer registers)
+ * and the sa1100-audio module (for DMA).
+ *
+ * History:
+ *
+ * 2002-04-04 Initial version.
+ * 2002-04-10 Updated mtd_audio_init to improve choppy sound
+ * and hanging sound issue.
+ * 2002-05-16 Updated for ADS Bitsy+ Robert Whaley
+ * 2002-06-28 Cleanup and added retry for read register timeouts
+ * 2002-08-14 Updated for ADS AGC Robert Whaley
+ * 2002-12-26 Cleanup, remove CONFIG_PM (it's handled by sa1100-audio.c)
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <linux/pm.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/sound.h>
+#include <linux/soundcard.h>
+#include <linux/ac97_codec.h>
+
+#include <asm/semaphore.h>
+#include <asm/uaccess.h>
+#include <asm/dma.h>
+#include <asm/hardware/sa1111.h>
+
+#include "sa1100-audio.h"
+
+/* SAC FIFO depth, low nibble is transmit fifo, high nibble is receive FIFO */
+#define SAC_FIFO_DEPTH 0x77
+
+// #define DEBUG
+
+#ifdef DEBUG
+#define DPRINTK( x... ) printk( ##x )
+#else
+#define DPRINTK( x... )
+#endif
+
+/*
+ Our codec data
+*/
+static struct ac97_codec ac97codec;
+static int audio_dev_id, mixer_dev_id;
+static audio_stream_t output_stream, input_stream;
+
+/* proc info */
+
+struct proc_dir_entry *ac97_ps;
+
+static int sa1111_ac97_set_adc_rate(long rate);
+static void sa1111_ac97_write_reg(struct ac97_codec *dev, u8 reg, u16 val);
+static u16 sa1111_ac97_read_reg(struct ac97_codec *dev, u8 reg);
+
+static int
+mixer_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
+{
+ /*
+ * We only accept mixer (type 'M') ioctls.
+ */
+ if (_IOC_TYPE(cmd) != 'M') {
+ return -EINVAL;
+ }
+
+ /* pass the ioctl to the ac97 mixer */
+ return ac97codec.mixer_ioctl(&ac97codec, cmd, arg);
+}
+
+
+static struct file_operations sa1111_ac97_mixer_fops = {
+ ioctl: mixer_ioctl,
+ owner: THIS_MODULE
+};
+
+static void sa1111_ac97_power_off(void *dummy)
+{
+#ifdef CONFIG_SA1100_ADSBITSYPLUS
+ /* turn off audio and audio amp */
+ ADS_CPLD_PCON |= (ADS_PCON_AUDIO_ON | ADS_PCON_AUDIOPA_ON);
+
+ /* make GPIO11 high impeadence */
+ GPDR &= ~GPIO_GPIO11;
+
+ /* disable SACR0 so we can make these pins high impeadence */
+ SACR0 &= ~SACR0_ENB;
+
+ /* make BIT_CLK, SDATA_OUT, and SYNC high impeadence */
+ PC_DDR |= (GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
+
+#endif
+
+#ifdef CONFIG_SA1100_ADSAGC
+ /* turn off audio and audio amp */
+ ADS_CR1 &= ~(ADS_CR1_CODEC | ADS_CR1_AMP);
+
+ /* disable SACR0 so we can make these pins high impeadence */
+ SACR0 &= ~SACR0_ENB;
+
+ /* make BIT_CLK, SDATA_OUT, and SYNC high impeadence */
+ PC_DDR |= (GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
+
+#endif
+}
+
+
+static void sa1111_ac97_power_on(void *dummy)
+{
+ int ret, i;
+
+ /* disable L3 */
+ SACR1 = 0;
+
+ SKPCR |= (SKPCR_ACCLKEN); /* enable ac97 clock */
+ udelay(50);
+
+ /* BIT_CLK is input to SA1111, DMA thresholds 9 (both dirs) */
+ SACR0 |= SACR0_BCKD | (SAC_FIFO_DEPTH << 8);
+
+ /* reset SAC registers */
+ SACR0 &= ~SACR0_RST;
+ udelay(50);
+ SACR0 |= SACR0_RST;
+ udelay(50);
+ SACR0 &= ~SACR0_RST;
+
+ /* setup SA1111 to use AC'97 */
+ SBI_SKCR |= SKCR_SELAC; /* select ac97 */
+ udelay(50);
+
+ /* issue a cold AC97 reset */
+#ifdef CONFIG_SA1100_ADSBITSYPLUS
+
+ /* initialize reset line */
+ GAFR &= ~GPIO_GPIO11;
+ GPDR |= GPIO_GPIO11;
+ GPSR = GPIO_GPIO11;
+
+ /* turn on audio and audio amp */
+ ADS_CPLD_PCON &= ~(ADS_PCON_AUDIO_ON | ADS_PCON_AUDIOPA_ON);
+ mdelay(5);
+
+ /* reset by lowering the reset pin momentarily */
+ DPRINTK("reseting codec via GPIO11\n");
+ GPCR = GPIO_GPIO11;
+ udelay(5);
+ GPSR = GPIO_GPIO11;
+ udelay(10);
+
+#endif
+#ifdef CONFIG_SA1100_ADSAGC
+
+ /* turn on audio and audio amp */
+ DPRINTK("before turning on power. ADS_CR1: %x\n", ADS_CR1);
+ ADS_CR1 |= (ADS_CR1_AMP | ADS_CR1_CODEC);
+ DPRINTK("after turnning on power. ADS_CR1: %x\n", ADS_CR1);
+ mdelay(5);
+
+ /* reset by lowering the reset pin momentarily */
+ DPRINTK("reseting codec via CPLD\n");
+ ADS_CR1 |= ADS_CR1_AUDIO_RST;
+ DPRINTK("after reset1. ADS_CR1: %x\n", ADS_CR1);
+ udelay(5);
+ ADS_CR1 &= ~ADS_CR1_AUDIO_RST;
+ DPRINTK("after reset2. ADS_CR1: %x\n", ADS_CR1);
+ udelay(10);
+
+#endif
+ SACR2 = 0;
+ udelay(50);
+
+ DPRINTK("before SW reset: SACR2: %x\n", SACR2);
+ SACR2 = SACR2_RESET;
+ DPRINTK("after SW reset: SACR2: %x\n", SACR2);
+ udelay(50);
+
+ /* set AC97 slot 3 and 4 (PCM out) to valid */
+ SACR2 = (SACR2_RESET | SACR2_TS3V | SACR2_TS4V);
+
+ /* enable SAC */
+ SACR0 |= SACR0_ENB;
+
+ i = 100;
+ while (!(SASR1 & SASR1_CRDY)) {
+ if (!i--) {
+ printk("Didn't get CRDY. SASR1=%x SKID=%x\n", SASR1, SBI_SKID);
+ break;
+ }
+ udelay(50);
+ }
+
+ if (!(ret = ac97_probe_codec(&ac97codec))) {
+ printk("ac97_probe_codec failed (%d)\n", ret);
+ return;
+ }
+
+ /* mic ADC on, disable VRA, disable VRM */
+ sa1111_ac97_write_reg(&ac97codec, AC97_EXTENDED_STATUS, 0x0200);
+}
+
+
+/*
+ * Audio interface
+ */
+
+
+static int sa1111_ac97_audio_ioctl(struct inode *inode, struct file *file,
+ uint cmd, ulong arg)
+{
+ long val;
+ int ret = 0;
+
+ DPRINTK("sa1111_ac97_audio_ioctl\n");
+
+ /*
+ * These are platform dependent ioctls which are not handled by the
+ * generic sa1100-audio module.
+ */
+ switch (cmd) {
+ case SNDCTL_DSP_STEREO:
+ ret = get_user(val, (int *) arg);
+ if (ret) {
+ return ret;
+ }
+ /* the cs42xx is stereo only */
+ ret = (val == 0) ? -EINVAL : 1;
+ return put_user(ret, (int *) arg);
+
+ case SNDCTL_DSP_CHANNELS:
+ case SOUND_PCM_READ_CHANNELS:
+ /* the cs42xx is stereo only */
+ return put_user(2, (long *) arg);
+
+#define SA1100_AC97_IOCTL_EXTRAS
+
+#ifdef SA1100_AC97_IOCTL_EXTRAS
+
+#define SNDCTL_DSP_AC97_CMD _SIOWR('P', 99, int)
+#define SNDCTL_DSP_INPUT_SPEED _SIOWR('P', 98, int)
+#define SOUND_PCM_READ_INPUT_RATE _SIOWR('P', 97, int)
+
+ case SNDCTL_DSP_AC97_CMD:
+
+ ret = get_user(val, (long *) arg);
+ if (ret) {
+ break;
+ }
+ sa1111_ac97_write_reg(&ac97codec, (u8) ((val & 0xff000000) >> 24), (u16) (val & 0xffff));
+ return 0;
+
+
+ case SNDCTL_DSP_INPUT_SPEED:
+ ret = get_user(val, (long *) arg);
+ // acc code here to set the speed
+ if (ret) {
+ break;
+ }
+ // note that this only changes the ADC rate, not the
+ // rate of the DAC.
+ ret = sa1111_ac97_set_adc_rate(val);
+ if (ret)
+ break;
+ return put_user(val, (long *) arg);
+
+ case SOUND_PCM_READ_INPUT_RATE:
+
+ return put_user((long) sa1111_ac97_read_reg(&ac97codec, 0x32), (long *) arg);
+
+
+#endif
+
+ case SNDCTL_DSP_SPEED:
+ ret = get_user(val, (long *) arg);
+ if (ret) {
+ break;
+ }
+
+ case SOUND_PCM_READ_RATE:
+ /* only 48 kHz playback is supported by the SA1111 */
+ return put_user(48000L, (long *) arg);
+
+ case SNDCTL_DSP_SETFMT:
+ case SNDCTL_DSP_GETFMTS:
+ /* we can do 16-bit only */
+ return put_user(AFMT_S16_LE, (long *) arg);
+
+ default:
+ /* Maybe this is meant for the mixer (As per OSS Docs) */
+ return mixer_ioctl(inode, file, cmd, arg);
+ }
+
+ return ret;
+}
+
+
+static audio_state_t audio_state = {
+ output_stream: &output_stream,
+ input_stream: &input_stream,
+ skip_dma_init: 1, /* done locally */
+ hw_init: sa1111_ac97_power_on,
+ hw_shutdown: sa1111_ac97_power_off,
+ client_ioctl: sa1111_ac97_audio_ioctl,
+ sem: __MUTEX_INITIALIZER(audio_state.sem),
+};
+
+
+static int sa1111_ac97_audio_open(struct inode *inode, struct file *file)
+{
+ return sa1100_audio_attach(inode, file, &audio_state);
+}
+
+
+/*
+ * Missing fields of this structure will be patched with the call
+ * to sa1100_audio_attach().
+ */
+static struct file_operations sa1111_ac97_audio_fops = {
+ open: sa1111_ac97_audio_open,
+ owner: THIS_MODULE
+};
+
+
+static void sa1111_ac97_write_reg(struct ac97_codec *dev, u8 reg, u16 val)
+{
+ int i;
+
+ /* reset status bits */
+ SASCR = SASCR_DTS;
+
+ /* write command and data registers */
+ ACCAR = reg << 12;
+ ACCDR = val << 4;
+
+ /* wait for data to be transmitted */
+ i = 0;
+ while ((SASR1 & SASR1_CADT) == 0) {
+ udelay(50);
+ if (++i > 10) {
+ DPRINTK("sa1111_ac97_write_reg failed (data not transmitted. SASR1: %x)\n", SASR1);
+ break;
+ }
+ }
+
+ DPRINTK("<%03d> sa1111_ac97_write_reg, [%02X]=%04X\n", i, reg, val);
+}
+
+
+static u16 sa1111_ac97_read_reg(struct ac97_codec *dev, u8 reg)
+{
+ u16 val;
+ int i;
+ int retry = 10;
+
+ do {
+ /* reset status bits */
+ SASCR = SASCR_RDD | SASCR_STO;
+
+ /* write command register */
+ ACCAR = (reg | 0x80) << 12;
+ ACCDR = 0;
+
+ /* wait for SADR bit in SASR1 */
+ i = 0;
+ while ((SASR1 & SASR1_SADR) == 0) {
+ udelay(50);
+ if (++i > 10) {
+ DPRINTK("<---> sa1111_ac97_read_reg failed\n");
+ retry--;
+ break;
+ }
+ if ((SASR1 & SASR1_RSTO) != 0) {
+ DPRINTK("sa1111_ac97_read_reg *timeout*\n");
+ retry--;
+ break;
+ }
+ }
+
+ } while ((SASR1 & SASR1_SADR) == 0 && retry > 0);
+
+ val = ACSDR >> 4;
+
+ DPRINTK("<%03d> sa1111_ac97_read_reg, [%02X]=%04X\n", i, reg, val);
+ return val;
+}
+
+
+/* wait for codec ready */
+static void sa1111_ac97_ready(struct ac97_codec *dev)
+{
+ int i;
+ u16 val;
+
+ i = 0;
+ while ((SASR1 & SASR1_CRDY) == 0) {
+ udelay(50);
+ if (++i > 10) {
+ DPRINTK("sa1111_ac97_ready failed\n");
+ return;
+ }
+ }
+ DPRINTK("codec_ready bit took %d cycles\n", i);
+
+ /* Wait for analog parts of codec to initialise */
+ i = 0;
+ do {
+ val = sa1111_ac97_read_reg(&ac97codec, AC97_POWER_CONTROL);
+ if (++i > 100) {
+ break;
+ }
+ mdelay(10);
+ } while ((val & 0xF) != 0xF || val == 0xFFFF);
+
+ /* the cs42xx typically takes 150 ms to initialise */
+
+ DPRINTK("analog init took %d cycles\n", i);
+}
+
+
+static int __init sa1111_ac97_init(void)
+{
+ int ret;
+
+ // SBI_SKCR |= SKCR_RCLKEN;
+
+ DPRINTK("sa1111_ac97_init\n");
+
+ /* install the ac97 mixer module */
+ ac97codec.codec_read = sa1111_ac97_read_reg;
+ ac97codec.codec_write = sa1111_ac97_write_reg;
+ ac97codec.codec_wait = sa1111_ac97_ready;
+
+ /* Acquire and initialize DMA */
+ ret = sa1111_sac_request_dma(&output_stream.dma_ch, "SA1111 audio out",
+ SA1111_SAC_XMT_CHANNEL);
+ if (ret < 0) {
+ printk("DMA request for SAC output failed\n");
+ return ret;
+ }
+
+ ret = sa1111_sac_request_dma(&input_stream.dma_ch, "SA1111 audio in",
+ SA1111_SAC_RCV_CHANNEL);
+ if (ret < 0) {
+ printk("DMA request for SAC input failed\n");
+ sa1100_free_dma(output_stream.dma_ch);
+ return ret;
+ }
+ /* register devices */
+ audio_dev_id = register_sound_dsp(&sa1111_ac97_audio_fops, -1);
+ mixer_dev_id = register_sound_mixer(&sa1111_ac97_mixer_fops, -1);
+
+
+ /* setup proc entry */
+ ac97_ps = create_proc_read_entry ("driver/sa1111-ac97", 0, NULL,
+ ac97_read_proc, &ac97codec);
+
+ return 0;
+}
+
+
+static void __exit sa1111_ac97_exit(void)
+{
+ SKPCR &= ~SKPCR_ACCLKEN; /* disable ac97 clock */
+ SBI_SKCR &= ~SKCR_SELAC; /* deselect ac97 */
+
+ unregister_sound_dsp(audio_dev_id);
+ unregister_sound_mixer(mixer_dev_id);
+ sa1100_free_dma(output_stream.dma_ch);
+ sa1100_free_dma(input_stream.dma_ch);
+}
+
+static int sa1111_ac97_set_adc_rate(long rate)
+{
+
+ // note this only changes the rate of the ADC, the DAC is fixed at 48K.
+ // this is due to limitations of the SA1111 chip
+
+ u16 code = rate;
+
+ switch (rate) {
+ case 8000:
+ case 11025:
+ case 16000:
+ case 22050:
+ case 32000:
+ case 44100:
+ case 48000:
+ break;
+ default:
+ return -1;
+ }
+ sa1111_ac97_write_reg(&ac97codec, 0x2A, 0x0001);
+ sa1111_ac97_write_reg(&ac97codec, 0x32, code);
+ return 0;
+}
+
+module_init(sa1111_ac97_init);
+module_exit(sa1111_ac97_exit);
+
+MODULE_AUTHOR("Bertrik Sikken, Technolution B.V., Netherlands");
+MODULE_DESCRIPTION("Glue audio driver for AC'97 codec");
+MODULE_LICENSE("GPL");
+
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/sound/sa1111-uda1341.c linux-2.4.26-vrs1/drivers/sound/sa1111-uda1341.c
--- linux-2.4.26/drivers/sound/sa1111-uda1341.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/sa1111-uda1341.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,282 @@
+/*
+ * Glue audio driver for the SA1111 compagnon chip & Philips UDA1341 codec.
+ *
+ * Copyright (c) 2000 John Dorsey
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ *
+ * History:
+ *
+ * 2000-09-04 John Dorsey SA-1111 Serial Audio Controller support
+ * was initially added to the sa1100-uda1341.c
+ * driver.
+ *
+ * 2001-06-03 Nicolas Pitre Made this file a separate module, based on
+ * the former sa1100-uda1341.c driver.
+ *
+ * 2001-09-23 Russell King Remove old L3 bus driver.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/fs.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/sound.h>
+#include <linux/soundcard.h>
+#include <linux/ioport.h>
+#include <linux/pm.h>
+#include <linux/l3/l3.h>
+#include <linux/l3/uda1341.h>
+
+#include <asm/semaphore.h>
+#include <asm/mach-types.h>
+#include <asm/uaccess.h>
+#include <asm/hardware.h>
+#include <asm/dma.h>
+#include <asm/arch/assabet.h>
+#include <asm/hardware/sa1111.h>
+
+#include "sa1100-audio.h"
+
+#undef DEBUG
+#ifdef DEBUG
+#define DPRINTK( x... ) printk( ##x )
+#else
+#define DPRINTK( x... )
+#endif
+
+
+/*
+ * Definitions
+ */
+
+#define AUDIO_RATE_DEFAULT 22050
+
+#define AUDIO_CLK_BASE 561600
+
+
+
+/*
+ * Mixer interface
+ */
+
+static struct l3_client uda1341;
+
+static int
+mixer_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
+{
+ /*
+ * We only accept mixer (type 'M') ioctls.
+ */
+ if (_IOC_TYPE(cmd) != 'M')
+ return -EINVAL;
+
+ return l3_command(&uda1341, cmd, (void *)arg);
+}
+
+static struct file_operations uda1341_mixer_fops = {
+ ioctl: mixer_ioctl,
+ owner: THIS_MODULE
+};
+
+
+/*
+ * Audio interface
+ */
+
+static int audio_clk_div = (AUDIO_CLK_BASE + AUDIO_RATE_DEFAULT/2)/AUDIO_RATE_DEFAULT;
+
+static void sa1111_audio_init(void *dummy)
+{
+#ifdef CONFIG_ASSABET_NEPONSET
+ if (machine_is_assabet()) {
+ /* Select I2S audio (instead of AC-Link) */
+ AUD_CTL = AUD_SEL_1341;
+ }
+#endif
+#ifdef CONFIG_SA1100_JORNADA720
+ if (machine_is_jornada720()) {
+ /* LDD4 is speaker, LDD3 is microphone */
+ PPSR &= ~(PPC_LDD3 | PPC_LDD4);
+ PPDR |= PPC_LDD3 | PPC_LDD4;
+ PPSR |= PPC_LDD4; /* enable speaker */
+ PPSR |= PPC_LDD3; /* enable microphone */
+ }
+#endif
+
+ SBI_SKCR &= ~SKCR_SELAC;
+
+ /* Enable the I2S clock and L3 bus clock: */
+ SKPCR |= (SKPCR_I2SCLKEN | SKPCR_L3CLKEN);
+
+ /* Activate and reset the Serial Audio Controller */
+ SACR0 |= (SACR0_ENB | SACR0_RST);
+ mdelay(5);
+ SACR0 &= ~SACR0_RST;
+
+ /* For I2S, BIT_CLK is supplied internally. The "SA-1111
+ * Specification Update" mentions that the BCKD bit should
+ * be interpreted as "0 = output". Default clock divider
+ * is 22.05kHz.
+ *
+ * Select I2S, L3 bus. "Recording" and "Replaying"
+ * (receive and transmit) are enabled.
+ */
+ SACR1 = SACR1_L3EN;
+ SKAUD = audio_clk_div - 1;
+
+ /* Initialize the UDA1341 internal state */
+ l3_open(&uda1341);
+}
+
+static void sa1111_audio_shutdown(void *dummy)
+{
+ l3_close(&uda1341);
+ SACR0 &= ~SACR0_ENB;
+}
+
+static int sa1111_audio_ioctl( struct inode *inode, struct file *file,
+ uint cmd, ulong arg)
+{
+ long val;
+ int ret = 0;
+
+ switch (cmd) {
+ case SNDCTL_DSP_STEREO:
+ ret = get_user(val, (int *) arg);
+ if (ret)
+ return ret;
+ /* the UDA1341 is stereo only */
+ ret = (val == 0) ? -EINVAL : 1;
+ return put_user(ret, (int *) arg);
+
+ case SNDCTL_DSP_CHANNELS:
+ case SOUND_PCM_READ_CHANNELS:
+ /* the UDA1341 is stereo only */
+ return put_user(2, (long *) arg);
+
+ case SNDCTL_DSP_SPEED:
+ ret = get_user(val, (long *) arg);
+ if (ret) break;
+ if (val < 8000) val = 8000;
+ if (val > 48000) val = 48000;
+ audio_clk_div = (AUDIO_CLK_BASE + val/2)/val;
+ SKAUD = audio_clk_div - 1;
+ /* fall through */
+
+ case SOUND_PCM_READ_RATE:
+ return put_user(AUDIO_CLK_BASE/audio_clk_div, (long *) arg);
+
+ case SNDCTL_DSP_SETFMT:
+ case SNDCTL_DSP_GETFMTS:
+ /* we can do 16-bit only */
+ return put_user(AFMT_S16_LE, (long *) arg);
+
+ default:
+ /* Maybe this is meant for the mixer (as per OSS Docs) */
+ return mixer_ioctl(inode, file, cmd, arg);
+ }
+
+ return ret;
+}
+
+static audio_stream_t output_stream, input_stream;
+
+static audio_state_t audio_state = {
+ output_stream: &output_stream,
+ input_stream: &input_stream,
+ skip_dma_init: 1, /* done locally */
+ hw_init: sa1111_audio_init,
+ hw_shutdown: sa1111_audio_shutdown,
+ client_ioctl: sa1111_audio_ioctl,
+ sem: __MUTEX_INITIALIZER(audio_state.sem),
+};
+
+static int sa1111_audio_open(struct inode *inode, struct file *file)
+{
+ return sa1100_audio_attach(inode, file, &audio_state);
+}
+
+/*
+ * Missing fields of this structure will be patched with the call
+ * to sa1100_audio_attach().
+ */
+static struct file_operations sa1111_audio_fops = {
+ open: sa1111_audio_open,
+ owner: THIS_MODULE
+};
+
+static int audio_dev_id, mixer_dev_id;
+
+static int __init sa1111_uda1341_init(void)
+{
+ struct uda1341_cfg cfg;
+ int ret;
+
+ if ( !( (machine_is_assabet() && machine_has_neponset()) ||
+ machine_is_jornada720() ||
+ machine_is_badge4() ))
+ return -ENODEV;
+
+ if (!request_mem_region(_SACR0, 512, "sound"))
+ return -EBUSY;
+
+ ret = l3_attach_client(&uda1341, "l3-sa1111", "uda1341");
+ if (ret)
+ goto out;
+
+ /* Acquire and initialize DMA */
+ ret = sa1111_sac_request_dma(&output_stream.dma_ch, "SA1111 audio out",
+ SA1111_SAC_XMT_CHANNEL);
+ if (ret < 0)
+ goto release_l3;
+
+ ret = sa1111_sac_request_dma(&input_stream.dma_ch, "SA1111 audio in",
+ SA1111_SAC_RCV_CHANNEL);
+ if (ret < 0)
+ goto release_dma;
+
+ cfg.fs = 256;
+ cfg.format = FMT_I2S;
+ l3_command(&uda1341, L3_UDA1341_CONFIGURE, &cfg);
+
+ /* register devices */
+ audio_dev_id = register_sound_dsp(&sa1111_audio_fops, -1);
+ mixer_dev_id = register_sound_mixer(&uda1341_mixer_fops, -1);
+
+ printk(KERN_INFO "Sound: SA1111 UDA1341: dsp id %d mixer id %d\n",
+ audio_dev_id, mixer_dev_id);
+ return 0;
+
+release_dma:
+ sa1100_free_dma(output_stream.dma_ch);
+release_l3:
+ l3_detach_client(&uda1341);
+out:
+ release_mem_region(_SACR0, 512);
+ return ret;
+}
+
+static void __exit sa1111_uda1341_exit(void)
+{
+ unregister_sound_dsp(audio_dev_id);
+ unregister_sound_mixer(mixer_dev_id);
+ sa1100_free_dma(output_stream.dma_ch);
+ sa1100_free_dma(input_stream.dma_ch);
+ l3_detach_client(&uda1341);
+
+ release_mem_region(_SACR0, 512);
+}
+
+module_init(sa1111_uda1341_init);
+module_exit(sa1111_uda1341_exit);
+
+MODULE_AUTHOR("John Dorsey, Nicolas Pitre");
+MODULE_DESCRIPTION("Glue audio driver for the SA1111 compagnon chip & Philips UDA1341 codec.");
+
+EXPORT_NO_SYMBOLS;
diff -urN linux-2.4.26/drivers/sound/uda1341.c linux-2.4.26-vrs1/drivers/sound/uda1341.c
--- linux-2.4.26/drivers/sound/uda1341.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/uda1341.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,511 @@
+/*
+ * Philips UDA1341 mixer device driver
+ *
+ * Copyright (c) 2000 Nicolas Pitre <nico@cam.org>
+ *
+ * Portions are Copyright (C) 2000 Lernout & Hauspie Speech Products, N.V.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ *
+ * History:
+ *
+ * 2000-05-21 Nicolas Pitre Initial release.
+ *
+ * 2000-08-19 Erik Bunce More inline w/ OSS API and UDA1341 docs
+ * including fixed AGC and audio source handling
+ *
+ * 2000-11-30 Nicolas Pitre - More mixer functionalities.
+ *
+ * 2001-06-03 Nicolas Pitre Made this file a separate module, based on
+ * the former sa1100-uda1341.c driver.
+ *
+ * 2001-08-13 Russell King Re-written as part of the L3 interface
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/ioctl.h>
+#include <linux/soundcard.h>
+#include <linux/l3/l3.h>
+#include <linux/l3/uda1341.h>
+
+#include <asm/uaccess.h>
+
+#define DEF_VOLUME 65
+
+/*
+ * UDA1341 L3 address and command types
+ */
+#define UDA1341_L3ADDR 5
+#define UDA1341_DATA0 (UDA1341_L3ADDR << 2 | 0)
+#define UDA1341_DATA1 (UDA1341_L3ADDR << 2 | 1)
+#define UDA1341_STATUS (UDA1341_L3ADDR << 2 | 2)
+
+struct uda1341_regs {
+ unsigned char stat0;
+#define STAT0 0x00
+#define STAT0_RST (1 << 6)
+#define STAT0_SC_MASK (3 << 4)
+#define STAT0_SC_512FS (0 << 4)
+#define STAT0_SC_384FS (1 << 4)
+#define STAT0_SC_256FS (2 << 4)
+#define STAT0_IF_MASK (7 << 1)
+#define STAT0_IF_I2S (0 << 1)
+#define STAT0_IF_LSB16 (1 << 1)
+#define STAT0_IF_LSB18 (2 << 1)
+#define STAT0_IF_LSB20 (3 << 1)
+#define STAT0_IF_MSB (4 << 1)
+#define STAT0_IF_LSB16MSB (5 << 1)
+#define STAT0_IF_LSB18MSB (6 << 1)
+#define STAT0_IF_LSB20MSB (7 << 1)
+#define STAT0_DC_FILTER (1 << 0)
+
+ unsigned char stat1;
+#define STAT1 0x80
+#define STAT1_DAC_GAIN (1 << 6) /* gain of DAC */
+#define STAT1_ADC_GAIN (1 << 5) /* gain of ADC */
+#define STAT1_ADC_POL (1 << 4) /* polarity of ADC */
+#define STAT1_DAC_POL (1 << 3) /* polarity of DAC */
+#define STAT1_DBL_SPD (1 << 2) /* double speed playback */
+#define STAT1_ADC_ON (1 << 1) /* ADC powered */
+#define STAT1_DAC_ON (1 << 0) /* DAC powered */
+
+ unsigned char data0_0;
+#define DATA0 0x00
+#define DATA0_VOLUME_MASK 0x3f
+#define DATA0_VOLUME(x) (x)
+
+ unsigned char data0_1;
+#define DATA1 0x40
+#define DATA1_BASS(x) ((x) << 2)
+#define DATA1_BASS_MASK (15 << 2)
+#define DATA1_TREBLE(x) ((x))
+#define DATA1_TREBLE_MASK (3)
+
+ unsigned char data0_2;
+#define DATA2 0x80
+#define DATA2_PEAKAFTER (1 << 5)
+#define DATA2_DEEMP_NONE (0 << 3)
+#define DATA2_DEEMP_32KHz (1 << 3)
+#define DATA2_DEEMP_44KHz (2 << 3)
+#define DATA2_DEEMP_48KHz (3 << 3)
+#define DATA2_MUTE (1 << 2)
+#define DATA2_FILTER_FLAT (0 << 0)
+#define DATA2_FILTER_MIN (1 << 0)
+#define DATA2_FILTER_MAX (3 << 0)
+
+#define EXTADDR(n) (0xc0 | (n))
+#define EXTDATA(d) (0xe0 | (d))
+
+ unsigned char ext0;
+#define EXT0 0
+#define EXT0_CH1_GAIN(x) (x)
+
+ unsigned char ext1;
+#define EXT1 1
+#define EXT1_CH2_GAIN(x) (x)
+
+ unsigned char ext2;
+#define EXT2 2
+#define EXT2_MIC_GAIN_MASK (7 << 2)
+#define EXT2_MIC_GAIN(x) ((x) << 2)
+#define EXT2_MIXMODE_DOUBLEDIFF (0)
+#define EXT2_MIXMODE_CH1 (1)
+#define EXT2_MIXMODE_CH2 (2)
+#define EXT2_MIXMODE_MIX (3)
+
+ unsigned char ext4;
+#define EXT4 4
+#define EXT4_AGC_ENABLE (1 << 4)
+#define EXT4_INPUT_GAIN_MASK (3)
+#define EXT4_INPUT_GAIN(x) ((x) & 3)
+
+ unsigned char ext5;
+#define EXT5 5
+#define EXT5_INPUT_GAIN(x) ((x) >> 2)
+
+ unsigned char ext6;
+#define EXT6 6
+#define EXT6_AGC_CONSTANT_MASK (7 << 2)
+#define EXT6_AGC_CONSTANT(x) ((x) << 2)
+#define EXT6_AGC_LEVEL_MASK (3)
+#define EXT6_AGC_LEVEL(x) (x)
+};
+
+#define REC_MASK (SOUND_MASK_LINE | SOUND_MASK_MIC)
+#define DEV_MASK (REC_MASK | SOUND_MASK_VOLUME | SOUND_MASK_BASS | SOUND_MASK_TREBLE)
+
+struct uda1341 {
+ struct uda1341_regs regs;
+ int active;
+ unsigned short volume;
+ unsigned short bass;
+ unsigned short treble;
+ unsigned short line;
+ unsigned short mic;
+ int mod_cnt;
+};
+
+#define ADD_FIELD(reg,field) \
+ *p++ = reg | uda->regs.field
+
+#define ADD_EXTFIELD(reg,field) \
+ *p++ = EXTADDR(reg); \
+ *p++ = EXTDATA(uda->regs.field);
+
+static void uda1341_sync(struct l3_client *clnt)
+{
+ struct uda1341 *uda = clnt->driver_data;
+ char buf[24], *p = buf;
+
+ ADD_FIELD(STAT0, stat0);
+ ADD_FIELD(STAT1, stat1);
+
+ if (p != buf)
+ l3_write(clnt, UDA1341_STATUS, buf, p - buf);
+
+ p = buf;
+ ADD_FIELD(DATA0, data0_0);
+ ADD_FIELD(DATA1, data0_1);
+ ADD_FIELD(DATA2, data0_2);
+ ADD_EXTFIELD(EXT0, ext0);
+ ADD_EXTFIELD(EXT1, ext1);
+ ADD_EXTFIELD(EXT2, ext2);
+ ADD_EXTFIELD(EXT4, ext4);
+ ADD_EXTFIELD(EXT5, ext5);
+ ADD_EXTFIELD(EXT6, ext6);
+
+ if (p != buf)
+ l3_write(clnt, UDA1341_DATA0, buf, p - buf);
+}
+
+static void uda1341_cmd_init(struct l3_client *clnt)
+{
+ struct uda1341 *uda = clnt->driver_data;
+ char buf[2];
+
+ uda->active = 1;
+
+ buf[0] = uda->regs.stat0 | STAT0_RST;
+ buf[1] = uda->regs.stat0;
+
+ l3_write(clnt, UDA1341_STATUS, buf, 2);
+
+ /* resend all parameters */
+ uda1341_sync(clnt);
+}
+
+static int uda1341_configure(struct l3_client *clnt, struct uda1341_cfg *conf)
+{
+ struct uda1341 *uda = clnt->driver_data;
+ int ret = 0;
+
+ uda->regs.stat0 &= ~(STAT0_SC_MASK | STAT0_IF_MASK);
+
+ switch (conf->fs) {
+ case 512: uda->regs.stat0 |= STAT0_SC_512FS; break;
+ case 384: uda->regs.stat0 |= STAT0_SC_384FS; break;
+ case 256: uda->regs.stat0 |= STAT0_SC_256FS; break;
+ default: ret = -EINVAL; break;
+ }
+
+ switch (conf->format) {
+ case FMT_I2S: uda->regs.stat0 |= STAT0_IF_I2S; break;
+ case FMT_LSB16: uda->regs.stat0 |= STAT0_IF_LSB16; break;
+ case FMT_LSB18: uda->regs.stat0 |= STAT0_IF_LSB18; break;
+ case FMT_LSB20: uda->regs.stat0 |= STAT0_IF_LSB20; break;
+ case FMT_MSB: uda->regs.stat0 |= STAT0_IF_MSB; break;
+ case FMT_LSB16MSB: uda->regs.stat0 |= STAT0_IF_LSB16MSB; break;
+ case FMT_LSB18MSB: uda->regs.stat0 |= STAT0_IF_LSB18MSB; break;
+ case FMT_LSB20MSB: uda->regs.stat0 |= STAT0_IF_LSB20MSB; break;
+ }
+
+ if (ret == 0 && uda->active) {
+ char buf = uda->regs.stat0 | STAT0;
+ l3_write(clnt, UDA1341_STATUS, &buf, 1);
+ }
+ return ret;
+}
+
+static int uda1341_update_direct(struct l3_client *clnt, int cmd, void *arg)
+{
+ struct uda1341 *uda = clnt->driver_data;
+ struct l3_gain *v = arg;
+ char newreg;
+ int val;
+
+ switch (cmd) {
+ case L3_SET_VOLUME: /* set volume. val = 0 to 100 => 62 to 1 */
+ uda->regs.data0_0 = DATA0_VOLUME(62 - ((v->left * 61) / 100));
+ newreg = uda->regs.data0_0 | DATA0;
+ break;
+
+ case L3_SET_BASS: /* set bass. val = 50 to 100 => 0 to 12 */
+ val = v->left - 50;
+ if (val < 0)
+ val = 0;
+ uda->regs.data0_1 &= ~DATA1_BASS_MASK;
+ uda->regs.data0_1 |= DATA1_BASS((val * 12) / 50);
+ newreg = uda->regs.data0_1 | DATA1;
+ break;
+
+ case L3_SET_TREBLE: /* set treble. val = 50 to 100 => 0 to 3 */
+ val = v->left - 50;
+ if (val < 0)
+ val = 0;
+ uda->regs.data0_1 &= ~DATA1_TREBLE_MASK;
+ uda->regs.data0_1 |= DATA1_TREBLE((val * 3) / 50);
+ newreg = uda->regs.data0_1 | DATA1;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ if (uda->active)
+ l3_write(clnt, UDA1341_DATA0, &newreg, 1);
+ return 0;
+}
+
+static int uda1341_update_indirect(struct l3_client *clnt, int cmd, void *arg)
+{
+ struct uda1341 *uda = clnt->driver_data;
+ struct l3_gain *gain = arg;
+ struct l3_agc *agc = arg;
+ char buf[8], *p = buf;
+ int val, ret = 0;
+
+ switch (cmd) {
+ case L3_SET_GAIN:
+ val = 31 - (gain->left * 31 / 100);
+ switch (gain->channel) {
+ case 1:
+ uda->regs.ext0 = EXT0_CH1_GAIN(val);
+ ADD_EXTFIELD(EXT0, ext0);
+ break;
+
+ case 2:
+ uda->regs.ext1 = EXT1_CH2_GAIN(val);
+ ADD_EXTFIELD(EXT1, ext1);
+ break;
+
+ default:
+ ret = -EINVAL;
+ }
+ break;
+
+ case L3_INPUT_AGC:
+ if (agc->channel == 2) {
+ if (agc->enable)
+ uda->regs.ext4 |= EXT4_AGC_ENABLE;
+ else
+ uda->regs.ext4 &= ~EXT4_AGC_ENABLE;
+#if 0
+ agc->level
+ agc->attack
+ agc->decay
+#endif
+ ADD_EXTFIELD(EXT4, ext4);
+ } else
+ ret = -EINVAL;
+ break;
+
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ if (ret == 0 && uda->active)
+ l3_write(clnt, UDA1341_DATA0, buf, p - buf);
+
+ return ret;
+}
+
+static int uda1341_mixer_ioctl(struct l3_client *clnt, int cmd, void *arg)
+{
+ struct uda1341 *uda = clnt->driver_data;
+ struct l3_gain gain;
+ int val, nr = _IOC_NR(cmd), ret = 0;
+
+ if (cmd == SOUND_MIXER_INFO) {
+ struct mixer_info mi;
+
+ strncpy(mi.id, "UDA1341", sizeof(mi.id));
+ strncpy(mi.name, "Philips UDA1341", sizeof(mi.name));
+ mi.modify_counter = uda->mod_cnt;
+ return copy_to_user(arg, &mi, sizeof(mi));
+ }
+
+ if (_IOC_DIR(cmd) & _IOC_WRITE) {
+ ret = get_user(val, (int *)arg);
+ if (ret)
+ goto out;
+
+ gain.left = val & 255;
+ gain.right = val >> 8;
+ gain.channel = 0;
+
+ switch (nr) {
+ case SOUND_MIXER_VOLUME:
+ uda->volume = val;
+ uda->mod_cnt++;
+ uda1341_update_direct(clnt, L3_SET_VOLUME, &gain);
+ break;
+
+ case SOUND_MIXER_BASS:
+ uda->bass = val;
+ uda->mod_cnt++;
+ uda1341_update_direct(clnt, L3_SET_BASS, &gain);
+ break;
+
+ case SOUND_MIXER_TREBLE:
+ uda->treble = val;
+ uda->mod_cnt++;
+ uda1341_update_direct(clnt, L3_SET_TREBLE, &gain);
+ break;
+
+ case SOUND_MIXER_LINE:
+ uda->line = val;
+ gain.channel = 1;
+ uda->mod_cnt++;
+ uda1341_update_indirect(clnt, L3_SET_GAIN, &gain);
+ break;
+
+ case SOUND_MIXER_MIC:
+ uda->mic = val;
+ gain.channel = 2;
+ uda->mod_cnt++;
+ uda1341_update_indirect(clnt, L3_SET_GAIN, &gain);
+ break;
+
+ case SOUND_MIXER_RECSRC:
+ break;
+
+ default:
+ ret = -EINVAL;
+ }
+ }
+
+ if (ret == 0 && _IOC_DIR(cmd) & _IOC_READ) {
+ int nr = _IOC_NR(cmd);
+ ret = 0;
+
+ switch (nr) {
+ case SOUND_MIXER_VOLUME: val = uda->volume; break;
+ case SOUND_MIXER_BASS: val = uda->bass; break;
+ case SOUND_MIXER_TREBLE: val = uda->treble; break;
+ case SOUND_MIXER_LINE: val = uda->line; break;
+ case SOUND_MIXER_MIC: val = uda->mic; break;
+ case SOUND_MIXER_RECSRC: val = REC_MASK; break;
+ case SOUND_MIXER_RECMASK: val = REC_MASK; break;
+ case SOUND_MIXER_DEVMASK: val = DEV_MASK; break;
+ case SOUND_MIXER_CAPS: val = 0; break;
+ case SOUND_MIXER_STEREODEVS: val = 0; break;
+ default: val = 0; ret = -EINVAL; break;
+ }
+
+ if (ret == 0)
+ ret = put_user(val, (int *)arg);
+ }
+out:
+ return ret;
+}
+
+static int uda1341_attach(struct l3_client *clnt)
+{
+ struct uda1341 *uda;
+
+ uda = kmalloc(sizeof(*uda), GFP_KERNEL);
+ if (!uda)
+ return -ENOMEM;
+
+ memset(uda, 0, sizeof(*uda));
+
+ uda->volume = DEF_VOLUME | DEF_VOLUME << 8;
+ uda->bass = 50 | 50 << 8;
+ uda->treble = 50 | 50 << 8;
+ uda->line = 88 | 88 << 8;
+ uda->mic = 88 | 88 << 8;
+
+ uda->regs.stat0 = STAT0_SC_256FS | STAT0_IF_LSB16;
+ uda->regs.stat1 = STAT1_DAC_GAIN | STAT1_ADC_GAIN |
+ STAT1_ADC_ON | STAT1_DAC_ON;
+ uda->regs.data0_0 = DATA0_VOLUME(62 - ((DEF_VOLUME * 61) / 100));
+ uda->regs.data0_1 = DATA1_BASS(0) | DATA1_TREBLE(0);
+ uda->regs.data0_2 = DATA2_PEAKAFTER | DATA2_DEEMP_NONE |
+ DATA2_FILTER_MAX;
+ uda->regs.ext0 = EXT0_CH1_GAIN(4);
+ uda->regs.ext1 = EXT1_CH2_GAIN(4);
+ uda->regs.ext2 = EXT2_MIXMODE_MIX | EXT2_MIC_GAIN(4);
+ uda->regs.ext4 = EXT4_AGC_ENABLE | EXT4_INPUT_GAIN(0);
+ uda->regs.ext5 = EXT5_INPUT_GAIN(0);
+ uda->regs.ext6 = EXT6_AGC_CONSTANT(3) | EXT6_AGC_LEVEL(0);
+
+ clnt->driver_data = uda;
+
+ return 0;
+}
+
+static void uda1341_detach(struct l3_client *clnt)
+{
+ kfree(clnt->driver_data);
+}
+
+static int
+uda1341_command(struct l3_client *clnt, int cmd, void *arg)
+{
+ int ret = -EINVAL;
+
+ if (_IOC_TYPE(cmd) == 'M')
+ ret = uda1341_mixer_ioctl(clnt, cmd, arg);
+ else if (cmd == L3_UDA1341_CONFIGURE)
+ ret = uda1341_configure(clnt, arg);
+
+ return ret;
+}
+
+static int uda1341_open(struct l3_client *clnt)
+{
+ uda1341_cmd_init(clnt);
+ return 0;
+}
+
+static void uda1341_close(struct l3_client *clnt)
+{
+ struct uda1341 *uda = clnt->driver_data;
+ uda->active = 0;
+}
+
+static struct l3_ops uda1341_ops = {
+ open: uda1341_open,
+ command: uda1341_command,
+ close: uda1341_close,
+};
+
+static struct l3_driver uda1341 = {
+ name: UDA1341_NAME,
+ attach_client: uda1341_attach,
+ detach_client: uda1341_detach,
+ ops: &uda1341_ops,
+ owner: THIS_MODULE,
+};
+
+static int __init uda1341_init(void)
+{
+ return l3_add_driver(&uda1341);
+}
+
+static void __exit uda1341_exit(void)
+{
+ l3_del_driver(&uda1341);
+}
+
+module_init(uda1341_init);
+module_exit(uda1341_exit);
+
+MODULE_AUTHOR("Nicolas Pitre");
+MODULE_DESCRIPTION("Philips UDA1341 CODEC driver");
diff -urN linux-2.4.26/drivers/sound/vidc.c linux-2.4.26-vrs1/drivers/sound/vidc.c
--- linux-2.4.26/drivers/sound/vidc.c 2001-10-11 17:43:30.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/vidc.c 2004-01-14 21:32:26.000000000 +0000
@@ -40,6 +40,7 @@
#endif
#define VIDC_SOUND_CLOCK (250000)
+#define VIDC_SOUND_CLOCK_EXT (176400)
/*
* When using SERIAL SOUND mode (external DAC), the number of physical
@@ -192,28 +193,43 @@
return vidc_audio_format;
}
+#define my_abs(i) ((i)<0 ? -(i) : (i))
+
static int vidc_audio_set_speed(int dev, int rate)
{
if (rate) {
- unsigned int hwctrl, hwrate;
+ unsigned int hwctrl, hwrate, hwrate_ext, rate_int, rate_ext;
unsigned int newsize, new2size;
- /*
- * If we have selected 44.1kHz, use the DAC clock.
- */
- if (0 && rate == 44100) {
- hwctrl = 0x00000002;
- hwrate = 3;
- } else {
- hwctrl = 0x00000003;
+ hwctrl = 0x00000003;
- hwrate = (((VIDC_SOUND_CLOCK * 2) / rate) + 1) >> 1;
- if (hwrate < 3)
- hwrate = 3;
- if (hwrate > 255)
- hwrate = 255;
+ /* Using internal clock */
+ hwrate = (((VIDC_SOUND_CLOCK * 2) / rate) + 1) >> 1;
+ if (hwrate < 3)
+ hwrate = 3;
+ if (hwrate > 255)
+ hwrate = 255;
- rate = VIDC_SOUND_CLOCK / hwrate;
+ /* Using exernal clock */
+ hwrate_ext = (((VIDC_SOUND_CLOCK_EXT * 2) / rate) + 1) >> 1;
+ if (hwrate_ext < 3)
+ hwrate_ext = 3;
+ if (hwrate_ext > 255)
+ hwrate_ext = 255;
+
+ rate_int = VIDC_SOUND_CLOCK / hwrate;
+ rate_ext = VIDC_SOUND_CLOCK_EXT / hwrate_ext;
+
+ /* Chose between external and internal clock */
+ if (my_abs(rate_ext-rate) < my_abs(rate_int-rate)) {
+ /*printk("VIDC: external %d %d %d\n", rate, rate_ext, hwrate_ext);*/
+ hwrate=hwrate_ext;
+ hwctrl=0x00000002;
+ rate=rate_ext;
+ } else {
+ /*printk("VIDC: internal %d %d %d\n", rate, rate_int, hwrate);*/
+ hwctrl=0x00000003;
+ rate=rate_int;
}
vidc_writel(0xb0000000 | (hwrate - 2));
@@ -225,13 +241,14 @@
if (newsize > 4096)
newsize = 4096;
for (new2size = 128; new2size < newsize; new2size <<= 1);
- if (new2size - newsize > newsize - (new2size >> 1))
- new2size >>= 1;
+ if (new2size - newsize > newsize - (new2size >> 1))
+ new2size >>= 1;
if (new2size > 4096) {
printk(KERN_ERR "VIDC: error: dma buffer (%d) %d > 4K\n",
newsize, new2size);
new2size = 4096;
}
+ /*printk("VIDC: dma size %d\n", new2size);*/
dma_bufsize = new2size;
vidc_audio_rate = rate;
}
diff -urN linux-2.4.26/drivers/sound/waveartist.c linux-2.4.26-vrs1/drivers/sound/waveartist.c
--- linux-2.4.26/drivers/sound/waveartist.c 2001-10-25 21:53:52.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/sound/waveartist.c 2004-01-14 21:32:26.000000000 +0000
@@ -247,17 +247,15 @@
printk("\n");
}
- if (inb(io_base + STATR) & CMD_RF) {
- int old_data;
-
- /* flush the port
- */
+ /*
+ * flush any stale command data from the port.
+ */
+ while (inb(io_base + STATR) & CMD_RF) {
+ unsigned int old_data;
old_data = inw(io_base + CMDR);
-
- if (debug_flg & DEBUG_CMD)
- printk("flushed %04X...", old_data);
-
+ printk("waveartist: flushing stale command data: 0x%04x pc=%p\n",
+ old_data, __builtin_return_address(0));
udelay(10);
}
@@ -287,16 +285,19 @@
resp[i] = inw(io_base + CMDR);
}
- if (debug_flg & DEBUG_CMD) {
- if (!timed_out) {
- printk("waveartist_cmd: resp=");
-
- for (i = 0; i < nr_resp; i++)
- printk("%04X ", resp[i]);
-
- printk("\n");
- } else
- printk("waveartist_cmd: timed out\n");
+ if (debug_flg & DEBUG_CMD && !timed_out) {
+ printk("waveartist_cmd: resp=");
+
+ for (i = 0; i < nr_resp; i++)
+ printk("%04X ", resp[i]);
+ printk("\n");
+ }
+
+ if (timed_out) {
+ printk(KERN_ERR "waveartist_cmd: command timed out:");
+ for (i = 0; i < nr_cmd; i++)
+ printk(" %04x", cmd[i]);
+ printk("\n");
}
return timed_out ? 1 : 0;
@@ -495,7 +496,6 @@
audio_devs[dev]->flags & DMA_AUTOMODE &&
intrflag &&
count == devc->xfer_count) {
- devc->audio_mode |= PCM_ENABLE_INPUT;
return; /*
* Auto DMA mode on. No need to react
*/
@@ -571,9 +571,6 @@
wavnc_port_info *portc = (wavnc_port_info *) audio_devs[dev]->portc;
unsigned int speed, bits;
- if (devc->audio_mode)
- return 0;
-
speed = waveartist_get_speed(portc);
bits = waveartist_get_bits(portc);
diff -urN linux-2.4.26/drivers/ssi/Config.in linux-2.4.26-vrs1/drivers/ssi/Config.in
--- linux-2.4.26/drivers/ssi/Config.in 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ssi/Config.in 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,11 @@
+
+mainmenu_option next_comment
+comment 'Synchronous Serial Interface'
+tristate 'Synchronous Serial Interface Support' CONFIG_SSI
+
+comment 'SSI Bus Drivers'
+dep_tristate ' CLPS711X SSI support' CONFIG_SSI_CLPS711X $CONFIG_SSI $CONFIG_ARCH_CLPS711X
+
+comment 'SSI Device Drivers'
+dep_tristate ' JUNO keyboard support' CONFIG_SSI_JUNO $CONFIG_SSI
+endmenu
diff -urN linux-2.4.26/drivers/ssi/Makefile linux-2.4.26-vrs1/drivers/ssi/Makefile
--- linux-2.4.26/drivers/ssi/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ssi/Makefile 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,50 @@
+#
+# Makefile for the SSI drivers
+#
+# Note! Dependencies are done automagically by 'make dep', which also
+# removes any old dependencies. DON'T put your own dependencies here
+# unless it's something special (ie not a .c file).
+#
+# Note 2! The CFLAGS definition is now inherited from the
+# parent makefile.
+#
+
+O_TARGET := ssi.o
+
+obj-y :=
+obj-m :=
+obj-n :=
+obj- :=
+
+export-objs :=
+list-multi :=
+
+obj-$(CONFIG_SSI) += ssi_core.o
+obj-$(CONFIG_SSI_CLPS711X) += clps711x_ssi1.o
+obj-y += juno.o
+
+# Extract lists of the multi-part drivers.
+# The 'int-*' lists are intermediate files used to build the multi's.
+
+multi-y := $(filter $(list-multi), $(obj-y))
+multi-m := $(filter $(list-multi), $(obj-m))
+int-y := $(sort $(foreach m, $(multi-y), $($(basename $(m))-objs)))
+int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs)))
+
+# Files that are both resident and modular; remove from modular.
+
+obj-m := $(filter-out $(obj-y), $(obj-m))
+int-m := $(filter-out $(int-y), $(int-m))
+
+# Take multi-part drivers out of obj-y and put components in.
+
+obj-y := $(filter-out $(list-multi), $(obj-y)) $(int-y)
+
+# Translate to Rules.make lists.
+
+O_OBJS := $(filter-out $(export-objs), $(obj-y))
+OX_OBJS := $(filter $(export-objs), $(obj-y))
+M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m)))
+MX_OBJS := $(sort $(filter $(export-objs), $(obj-m)))
+
+include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/drivers/ssi/README linux-2.4.26-vrs1/drivers/ssi/README
--- linux-2.4.26/drivers/ssi/README 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ssi/README 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,86 @@
+ Synchronous Serial Interface bus driver
+ ---------------------------------------
+
+ EEEEE X X PPPP EEEEE RRRR IIIII M M EEEEE N N TTTTT AAA L
+ E X X P P E R R I MM MM E NN N T A A L
+ EEEE X PPPP EEEE RRRR I M M M EEEE N N N T AAAAA L
+ E X X P E R R I M M E N NN T A A L
+ EEEEE X X P EEEEE R R IIIII M M EEEEE N N T A A LLLLL
+
+This directory holds the SSI bus drivers. Basically, a SSI bus consists
+of the following signals:
+
+ stxd Transmit data
+ srxd Receive data
+ sclk Clock
+ sfrm Frame
+ Chip selects (1 - n)
+
+There may be more than one device on a SSI bus, and each device can
+have different timing requirements. There are several frame formats:
+
+1. Texas Instruments Synchronous Serial Frame format
+
+ sclk ____~_~_~_~_~_~_~_~____
+ sfrm ____~~_________________
+ stxd ------bn..........b0---
+ srxd ------bn..........b0---
+
+ - data latched in on the falling edge of the clock
+ - data shifted out on the rising edge of the clock
+
+2. Motorola SPI frame format
+
+ sclk ______~_~_~_~_~_~_~____
+ sfrm ~~~~________________~~~
+ stxd -----bn..........b0----
+ srxd ----.bn..........b0----
+
+ - data latched in on the rising edge of the clock
+ - data shifted out on the falling edge of the clock, or falling edge
+ of sfrm
+
+3. National Microwire format
+
+ sclk ______~_~_~_~_~_~_~_~_~_~_~_~_~_____
+ sfrm ~~~~_____________________________~~~
+ stxd -----bn......b0---------------------
+ srxd -----------------bn..........b0.----
+
+ - data latched in on the rising edge of the clock
+ - data shifted out on the falling edge of the clock
+ - half duplex, one clock between transmission and reception
+
+Types of devices
+----------------
+
+The following types of devices can be found on a SSP bus:
+
+ Sound chips
+ Keyboard devices
+ Touch screen devices
+
+Keyboard
+--------
+
+TX:
+0. Format: cfglen = 8, framelen = 8, clkpol = 1, clk < 250kHz
+1. select device
+2. keyboard responds asserting key_atn
+3. wait 0.1ms to 5ms
+4. transmit data byte
+5. wait >= 150us
+6. repeat step 4 until all data sent
+7. deselect device
+8. keyboard responds de-asserting key_atn
+9. wait >= 120us
+
+RX:
+0. Format: cfglen = 8, framelen = 8, clkpol = 1, clk < 250kHz
+1. keyboard asserts key_atn
+2. select device after 0.1ms < 5ms
+3. read data byte
+4. wait 150us
+5. if key_atn still asserted, goto 3
+6. deselect device
+7. wait >= 120us
diff -urN linux-2.4.26/drivers/ssi/clps711x_ssi1.c linux-2.4.26-vrs1/drivers/ssi/clps711x_ssi1.c
--- linux-2.4.26/drivers/ssi/clps711x_ssi1.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ssi/clps711x_ssi1.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,237 @@
+/*
+ * linux/drivers/ssi/clps711x_ssi1.c
+ *
+ * SSI bus driver for the CLPS711x SSI1 bus. We support EP7212
+ * extensions as well.
+ *
+ * Frame sizes can be between 4 and 24 bits.
+ * Config sizes can be between 4 and 16 bits.
+ */
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+
+#include <asm/mach-types.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+
+#include <asm/hardware/ep7212.h>
+
+#include "ssi_bus.h"
+#include "ssi_dev.h"
+
+#define EP7212
+
+/*
+ * Port E on the P720T is used for the SPI bus chip selects
+ * 0 - Keyboard
+ * 1 - Touch screen
+ * 2 - CS4224 ADC/DAC
+ * 7 - idle
+ */
+
+#if 0
+/*
+ * we place in the transmit buffer:
+ * <control>
+ * received data (binary):
+ * 0xxxxxxxxxxxx000
+ * where 'x' is the value
+ */
+struct ssi_dev ads7846_dev = {
+ name: "ADS7846",
+ id: 1,
+ proto: SSI_SPI,
+ cfglen: 8,
+ framelen: 24,
+ clkpol: 0,
+ clkfreq: 2500000,
+};
+
+/*
+ * we place in the transmit buffer:
+ * write: <20> <map> <data>...
+ * received data discarded
+ */
+struct ssi_dev cs4224_dev = {
+ name: "CS4224",
+ id: 2,
+ proto: SSI_SPI,
+ cfglen: 8,
+ framelen: 8,
+ clkpol: 0,
+ clkfreq: 6000000,
+};
+#endif
+
+/*
+ * Supplement with whatever method your board requires
+ */
+static void ssi1_select_id(int id)
+{
+ if (machine_is_p720t()) {
+ clps_writel(7, PEDDR);
+ clps_writel(id, PEDR);
+ }
+}
+
+/*
+ * Select the specified device. The upper layers will have already
+ * checked that the bus transmit queue is idle. We need to make sure
+ * that the interface itself is idle.
+ */
+static int ssi1_select(struct ssi_bus *bus, struct ssi_dev *dev)
+{
+ u_int id = dev ? dev->id : 7;
+ u_int val;
+
+ /*
+ * Make sure that the interface is idle
+ */
+ do {
+ val = clps_readl(SYSFLG1);
+ } while (val & SYSFLG1_SSIBUSY);
+
+ ssi1_select_id(7);
+
+ if (dev) {
+ /*
+ * Select clock frequency. This is very rough,
+ * and assumes that we're operating in PLL mode.
+ */
+ val = clps_readl(SYSCON1) & ~SYSCON1_ADCKSEL_MASK;
+// if (dev->clkfreq <= 16000) /* <16kHz */
+// val |= SYSCON1_ADCKSEL(0);
+// else if (dev->clkfreq < 64000) /* <64kHz */
+// val |= SYSCON1_ADCKSEL(1);
+// else if (dev->clkfreq < 128000) /* <128kHz */
+ val |= SYSCON1_ADCKSEL(2);
+// else /* >= 128kHz */
+// val |= SYSCON1_ADCKSEL(3);
+ clps_writel(val, SYSCON1);
+
+ bus->cfglen = dev->cfglen;
+ bus->framelen = dev->framelen;
+ bus->clkpol = dev->clkpol;
+ bus->proto = dev->proto;
+
+#ifdef EP7212
+ /*
+ * Set the clock edge according to the device.
+ * (set clkpol if the device reads data on the
+ * falling edge of the clock signal).
+ */
+ val = ep_readl(SYSCON3) & ~SYSCON3_ADCCKNSEN;
+ if (bus->clkpol && dev->proto != SSI_USAR)
+ val |= SYSCON3_ADCCKNSEN;
+ ep_writel(val, SYSCON3);
+#endif
+
+ /*
+ * Select the device
+ */
+ ssi1_select_id(id);
+
+#ifdef EP7212
+ /*
+ * If we are doing USAR, wait 30us, then set
+ * the clock line low.
+ */
+ if (dev->proto == SSI_USAR) {
+ udelay(150);
+
+ val |= SYSCON3_ADCCKNSEN;
+ ep_writel(val, SYSCON3);
+ }
+#endif
+ }
+
+ return 0;
+}
+
+static void ssi1_int(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct ssi_bus *bus = (struct ssi_bus *)dev_id;
+
+ /*
+ * Read the data word and queue it.
+ */
+ ssi_core_rcv(bus, clps_readl(SYNCIO));
+}
+
+/*
+ * Enable transmission and/or of some bytes
+ */
+static int ssi1_trans(struct ssi_bus *bus, u_int data)
+{
+ u_int syncio;
+
+#ifdef EP7212
+ data <<= 32 - bus->cfglen;
+ syncio = bus->cfglen | bus->framelen << 7 | data;
+#else
+ syncio = data | bus->framelen << 8;
+#endif
+
+ clps_writel(syncio, SYNCIO);
+ clps_writel(syncio | SYNCIO_TXFRMEN, SYNCIO);
+ return 0;
+}
+
+/*
+ * Initialise the SSI bus.
+ */
+static int ssi1_bus_init(struct ssi_bus *bus)
+{
+ int retval, val;
+
+ retval = request_irq(IRQ_SSEOTI, ssi1_int, 0, "ssi1", bus);
+ if (retval)
+ return retval;
+
+#ifdef EP7212
+ /*
+ * EP7212 only! Set the configuration command length.
+ * On the CLPS711x chips, it is fixed at 8 bits.
+ */
+ val = ep_readl(SYSCON3);
+ val |= SYSCON3_ADCCON;
+ ep_writel(val, SYSCON3);
+#endif
+
+ ssi1_select(bus, NULL);
+
+ PLD_SPI |= PLD_SPI_EN;
+
+ return 0;
+}
+
+static void ssi1_bus_exit(struct ssi_bus *bus)
+{
+ ssi1_select(bus, NULL);
+
+ PLD_SPI &= ~PLD_SPI_EN;
+
+ free_irq(IRQ_SSEOTI, bus);
+}
+
+struct ssi_bus clps711x_ssi1_bus = {
+ name: "clps711x_ssi1",
+ init: ssi1_bus_init,
+ exit: ssi1_bus_exit,
+ select: ssi1_select,
+ trans: ssi1_trans,
+};
+
+static int __init clps711x_ssi1_init(void)
+{
+ return ssi_register_bus(&clps711x_ssi1_bus);
+}
+
+static void __exit clps711x_ssi1_exit(void)
+{
+ ssi_unregister_bus(&clps711x_ssi1_bus);
+}
+
+module_init(clps711x_ssi1_init);
+module_exit(clps711x_ssi1_exit);
diff -urN linux-2.4.26/drivers/ssi/juno.c linux-2.4.26-vrs1/drivers/ssi/juno.c
--- linux-2.4.26/drivers/ssi/juno.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ssi/juno.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,131 @@
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+
+#include <asm/arch/syspld.h>
+
+#include "ssi_bus.h"
+#include "ssi_dev.h"
+
+extern struct ssi_bus clps711x_ssi1_bus;
+
+static u_int recvbuf[16];
+static volatile u_int ptr, rxed;
+
+static inline void juno_enable_irq(void)
+{
+ enable_irq(IRQ_EINT1);
+}
+
+static inline void juno_disable_irq(void)
+{
+ disable_irq(IRQ_EINT1);
+}
+
+static void juno_rcv(struct ssi_dev *dev, u_int data)
+{
+ if (ptr < 16) {
+ recvbuf[ptr] = data;
+ ptr++;
+ } else
+ printk("juno_rcv: %04x\n", data);
+ rxed = 1;
+}
+
+static void juno_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct ssi_dev *dev = dev_id;
+
+ printk("juno_irq\n");
+
+ ssi_select_device(dev->bus, dev);
+
+ ptr = 0;
+ do {
+ rxed = 0;
+ ssi_transmit_data(dev, 0xff);
+ while (rxed == 0);
+ udelay(150);
+ } while (PLD_INT & PLD_INT_KBD_ATN);
+
+ ssi_select_device(dev->bus, NULL);
+
+ { int i;
+ printk("juno_rcv: ");
+ for (i = 0; i < ptr; i++)
+ printk("%04x ", recvbuf[i]);
+ printk("\n");
+ }
+}
+
+static void juno_command(struct ssi_dev *dev, int cmd, int data)
+{
+ ssi_transmit_data(dev, cmd);
+ mdelay(1);
+ ssi_transmit_data(dev, data);
+ mdelay(1);
+ ssi_transmit_data(dev, 0xa0 ^ 0xc0);
+ mdelay(1);
+}
+
+static int juno_dev_init(struct ssi_dev *dev)
+{
+ int retval;
+
+ PLD_KBD |= PLD_KBD_EN;
+ ptr = 16;
+
+ mdelay(20);
+
+ retval = request_irq(IRQ_EINT1, juno_irq, 0, dev->name, dev);
+ if (retval)
+ return retval;
+
+ juno_disable_irq();
+
+ if (ssi_select_device(dev->bus, dev) != 0) {
+ printk("juno: ssi_select_dev failed\n");
+ return -EBUSY;
+ }
+
+ mdelay(1);
+
+ juno_command(dev, 0x80, 0x20);
+
+ ssi_select_device(dev->bus, NULL);
+
+ juno_enable_irq();
+
+ return 0;
+}
+
+static struct ssi_dev juno_dev = {
+ name: "Juno",
+ id: 0,
+ proto: SSI_USAR,
+ cfglen: 8,
+ framelen: 8,
+ clkpol: 1,
+ clkfreq: 250000,
+ rcv: juno_rcv,
+ init: juno_dev_init,
+};
+
+static int __init juno_init(void)
+{
+ return ssi_register_device(&clps711x_ssi1_bus, &juno_dev);
+}
+
+static void __exit juno_exit(void)
+{
+ ssi_unregister_device(&juno_dev);
+}
+
+module_init(juno_init);
+module_exit(juno_exit);
+
diff -urN linux-2.4.26/drivers/ssi/ssi_bus.h linux-2.4.26-vrs1/drivers/ssi/ssi_bus.h
--- linux-2.4.26/drivers/ssi/ssi_bus.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ssi/ssi_bus.h 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,21 @@
+#include <linux/circ_buf.h>
+
+struct ssi_dev;
+
+struct ssi_bus {
+ u_char cfglen;
+ u_char framelen;
+ u_char clkpol;
+ u_char proto;
+ struct ssi_dev *dev; /* current device */
+ int (*select)(struct ssi_bus *, struct ssi_dev *);
+ int (*trans)(struct ssi_bus *, u_int data);
+ int (*init)(struct ssi_bus *);
+ void (*exit)(struct ssi_bus *);
+ char *name;
+ u_int devices;
+};
+
+extern int ssi_core_rcv(struct ssi_bus *bus, u_int data);
+extern int ssi_register_bus(struct ssi_bus *bus);
+extern int ssi_unregister_bus(struct ssi_bus *bus);
diff -urN linux-2.4.26/drivers/ssi/ssi_core.c linux-2.4.26-vrs1/drivers/ssi/ssi_core.c
--- linux-2.4.26/drivers/ssi/ssi_core.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ssi/ssi_core.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,175 @@
+/*
+ * linux/drivers/ssi/ssi_core.c
+ *
+ * This file provides a common framework to allow multiple SSI devices
+ * to work together on a single SSI bus.
+ *
+ * You can use this in two ways:
+ * 1. select the device, queue up data, flush the data to the device,
+ * (optionally) purge the received data, deselect the device.
+ * 2. select the device, queue up one data word, flush to the device
+ * read data word, queue up next data word, flush to the device...
+ * deselect the device.
+ */
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/malloc.h>
+#include <linux/init.h>
+
+#include <asm/errno.h>
+
+#include "ssi_bus.h"
+#include "ssi_dev.h"
+
+#define DEBUG
+
+/**
+ * ssi_core_rcv - pass received SSI data to the device
+ * @bus: the bus that the data was received from
+ * @data: the data word that was received
+ *
+ * This function is intended to be called by SSI bus device
+ * drivers to pass received data to the device driver.
+ */
+int ssi_core_rcv(struct ssi_bus *bus, u_int data)
+{
+ struct ssi_dev *dev = bus->dev;
+
+ if (dev && dev->rcv)
+ dev->rcv(dev, data);
+
+ return 0;
+}
+
+/**
+ * ssi_transmit_data - queue SSI data for later transmission
+ * @dev: device requesting data to be transmitted
+ * @data: data word to be transmitted.
+ *
+ * Queue one data word of SSI data for later transmission.
+ */
+int ssi_transmit_data(struct ssi_dev *dev, u_int data)
+{
+ struct ssi_bus *bus = dev->bus;
+
+ /*
+ * Make sure that we currently own the bus
+ */
+ if (bus->dev != dev)
+ BUG();
+
+ bus->trans(bus, data);
+ return 0;
+}
+
+/**
+ * ssi_select_device - select a SSI device for later transactions
+ * @dev: device to be selected
+ */
+int ssi_select_device(struct ssi_bus *bus, struct ssi_dev *dev)
+{
+ int retval;
+
+#ifdef DEBUG
+ printk("SSI: selecting device %s on bus %s\n",
+ dev ? dev->name : "<none>", bus->name);
+#endif
+
+ /*
+ * Select the device if it wasn't already selected.
+ */
+ retval = 0;
+ if (bus->dev != dev) {
+ retval = bus->select(bus, dev);
+ bus->dev = dev;
+ }
+
+ return retval;
+}
+
+/**
+ * ssi_register_device - register a SSI device with a SSI bus
+ * @bus: bus
+ * @dev: SSI device
+ */
+int ssi_register_device(struct ssi_bus *bus, struct ssi_dev *dev)
+{
+ int retval;
+
+ dev->bus = bus;
+ bus->devices++;
+ retval = dev->init(dev);
+ if (retval != 0) {
+ dev->bus = NULL;
+ bus->devices--;
+ } else {
+#ifdef DEBUG
+ printk("SSI: registered new device %s on bus %s\n", dev->name, bus->name);
+#endif
+ }
+ return retval;
+}
+
+/**
+ * ssi_unregister_device - unregister a SSI device from a SSI bus
+ * @dev: SSI device
+ */
+int ssi_unregister_device(struct ssi_dev *dev)
+{
+ struct ssi_bus *bus = dev->bus;
+
+ if (bus->dev == dev)
+ bus->dev = NULL;
+
+ dev->bus = NULL;
+ bus->devices--;
+#ifdef DEBUG
+ printk("SSI: unregistered device %s on bus %s\n", dev->name, bus->name);
+#endif
+ return 0;
+}
+
+/**
+ * ssi_register_bus - register a SSI bus driver
+ * @bus: bus
+ */
+int ssi_register_bus(struct ssi_bus *bus)
+{
+ int retval;
+
+ retval = bus->init(bus);
+ if (retval == 0) {
+ bus->devices = 0;
+#ifdef DEBUG
+ printk("SSI: registered new bus %s\n", bus->name);
+#endif
+ }
+
+ return retval;
+}
+
+/**
+ * ssi_unregister_bus - unregister a SSI bus driver
+ * @bus: bus
+ */
+int ssi_unregister_bus(struct ssi_bus *bus)
+{
+ int retval = -EBUSY;
+ if (bus->devices == 0) {
+ retval = 0;
+ }
+ return retval;
+}
+
+static int __init ssi_init(void)
+{
+ return 0;
+}
+
+static void __exit ssi_exit(void)
+{
+}
+
+module_init(ssi_init);
+module_exit(ssi_exit);
diff -urN linux-2.4.26/drivers/ssi/ssi_dev.h linux-2.4.26-vrs1/drivers/ssi/ssi_dev.h
--- linux-2.4.26/drivers/ssi/ssi_dev.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/ssi/ssi_dev.h 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,21 @@
+struct ssi_bus;
+
+#define SSI_SPI 1
+#define SSI_MICROWIRE 2
+#define SSI_TISSF 3
+#define SSI_USAR 4
+
+struct ssi_dev {
+ char *name;
+ u_int id;
+ u_int clkfreq;
+ u_char cfglen;
+ u_char framelen;
+ u_char clkpol;
+ u_char proto;
+ void (*rcv)(struct ssi_dev *, u_int);
+ int (*init)(struct ssi_dev *);
+ struct ssi_bus *bus;
+};
+
+
diff -urN linux-2.4.26/drivers/usb/Config.in linux-2.4.26-vrs1/drivers/usb/Config.in
--- linux-2.4.26/drivers/usb/Config.in 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/usb/Config.in 2004-02-23 13:36:33.000000000 +0000
@@ -4,7 +4,13 @@
mainmenu_option next_comment
comment 'USB support'
-dep_tristate 'Support for USB' CONFIG_USB $CONFIG_PCI
+# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
+if [ "$CONFIG_PCI" = "y" -o "$CONFIG_SA1111" = "y" -o "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
+ tristate 'Support for USB' CONFIG_USB
+else
+ define_bool CONFIG_USB n
+fi
+
if [ "$CONFIG_USB" = "y" -o "$CONFIG_USB" = "m" ]; then
bool ' USB verbose debug messages' CONFIG_USB_DEBUG
diff -urN linux-2.4.26/drivers/usb/Makefile linux-2.4.26-vrs1/drivers/usb/Makefile
--- linux-2.4.26/drivers/usb/Makefile 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/usb/Makefile 2004-02-23 13:36:33.000000000 +0000
@@ -74,6 +74,14 @@
subdir-$(CONFIG_USB_OHCI) += host
ifeq ($(CONFIG_USB_OHCI),y)
+ obj-y += host/usb-ohci.o host/usb-ohci-pci.o
+endif
+subdir-$(CONFIG_USB_OHCI_SA1111)+= host
+ifeq ($(CONFIG_USB_OHCI),y)
+ obj-y += host/usb-ohci.o host/usb-ohci-sa1111.o
+endif
+subdir-$(CONFIG_USB_OHCI_AT91) += host
+ifeq ($(CONFIG_USB_OHCI_AT91),y)
obj-y += host/usb-ohci.o
endif
@@ -85,8 +93,6 @@
obj-$(CONFIG_USB_KBD) += usbkbd.o
obj-$(CONFIG_USB_AIPTEK) += aiptek.o
obj-$(CONFIG_USB_WACOM) += wacom.o
-obj-$(CONFIG_USB_KBTAB) += kbtab.o
-obj-$(CONFIG_USB_POWERMATE) += powermate.o
obj-$(CONFIG_USB_SCANNER) += scanner.o
obj-$(CONFIG_USB_ACM) += acm.o
diff -urN linux-2.4.26/drivers/usb/hcd.c linux-2.4.26-vrs1/drivers/usb/hcd.c
--- linux-2.4.26/drivers/usb/hcd.c 2004-04-19 11:44:27.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/usb/hcd.c 2004-04-19 10:22:01.000000000 +0100
@@ -96,7 +96,7 @@
/* used when updating hcd data */
static spinlock_t hcd_data_lock = SPIN_LOCK_UNLOCKED;
-static struct usb_operations hcd_operations;
+/*static*/ struct usb_operations hcd_operations;
/*-------------------------------------------------------------------------*/
@@ -1208,13 +1208,21 @@
} else {
if (usb_pipecontrol (urb->pipe))
urb->setup_dma = pci_map_single (
+#ifdef CONFIG_PCI
hcd->pdev,
+#else
+ NULL,
+#endif
urb->setup_packet,
sizeof (struct usb_ctrlrequest),
PCI_DMA_TODEVICE);
if (urb->transfer_buffer_length != 0)
urb->transfer_dma = pci_map_single (
+#ifdef CONFIG_PCI
hcd->pdev,
+#else
+ NULL,
+#endif
urb->transfer_buffer,
urb->transfer_buffer_length,
usb_pipein (urb->pipe)
@@ -1424,7 +1432,7 @@
return 0;
}
-static struct usb_operations hcd_operations = {
+/*static*/ struct usb_operations hcd_operations = {
allocate: hcd_alloc_dev,
get_frame_number: hcd_get_frame_number,
submit_urb: hcd_submit_urb,
@@ -1434,7 +1442,7 @@
/*-------------------------------------------------------------------------*/
-static void hcd_irq (int irq, void *__hcd, struct pt_regs * r)
+/*static*/ void hcd_irq (int irq, void *__hcd, struct pt_regs * r)
{
struct usb_hcd *hcd = __hcd;
int start = hcd->state;
@@ -1490,12 +1498,24 @@
/* For 2.4, don't unmap bounce buffer if it's a root hub operation. */
if (usb_pipecontrol (urb->pipe) && !is_root_hub_operation)
- pci_unmap_single (hcd->pdev, urb->setup_dma,
+ pci_unmap_single (
+#ifdef CONFIG_PCI
+ hcd->pdev,
+#else
+ NULL,
+#endif
+ urb->setup_dma,
sizeof (struct usb_ctrlrequest),
PCI_DMA_TODEVICE);
if ((urb->transfer_buffer_length != 0) && !is_root_hub_operation)
- pci_unmap_single (hcd->pdev, urb->transfer_dma,
+ pci_unmap_single (
+#ifdef CONFIG_PCI
+ hcd->pdev,
+#else
+ NULL,
+#endif
+ urb->transfer_dma,
urb->transfer_buffer_length,
usb_pipein (urb->pipe)
? PCI_DMA_FROMDEVICE
diff -urN linux-2.4.26/drivers/usb/host/Config.in linux-2.4.26-vrs1/drivers/usb/host/Config.in
--- linux-2.4.26/drivers/usb/host/Config.in 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/usb/host/Config.in 2004-02-11 01:35:27.000000000 +0000
@@ -12,8 +12,13 @@
define_bool CONFIG_USB_UHCI_ALT n
fi
dep_tristate ' OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support' CONFIG_USB_OHCI $CONFIG_USB
+dep_tristate ' SA1111 OHCI-compatible host interface support' CONFIG_USB_OHCI_SA1111 $CONFIG_USB
if [ "$CONFIG_ARM" = "y" -o "$CONFIG_X86" = "y" -a "$CONFIG_X86_64" != "y" ]; then
# Cypress embedded USB controller on StrongARM or on x86 in PC/104
dep_tristate ' SL811HS Alternate (x86, StrongARM, isosynchronous mode)' CONFIG_USB_SL811HS_ALT $CONFIG_USB $CONFIG_EXPERIMENTAL
dep_tristate ' SL811HS (x86, StrongARM) support, old driver' CONFIG_USB_SL811HS $CONFIG_USB $CONFIG_EXPERIMENTAL
fi
+if [ "$CONFIG_ARCH_AT91RM9200" = "y" ]; then
+ dep_tristate ' AT91RM9200 OHCI-compatible host interface support' CONFIG_USB_OHCI_AT91 $CONFIG_USB
+fi
+
diff -urN linux-2.4.26/drivers/usb/host/Makefile linux-2.4.26-vrs1/drivers/usb/host/Makefile
--- linux-2.4.26/drivers/usb/host/Makefile 2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/usb/host/Makefile 2004-02-11 01:29:25.000000000 +0000
@@ -8,9 +8,11 @@
obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
obj-$(CONFIG_USB_UHCI_ALT) += uhci.o
obj-$(CONFIG_USB_UHCI) += usb-uhci.o
-obj-$(CONFIG_USB_OHCI) += usb-ohci.o
+obj-$(CONFIG_USB_OHCI) += usb-ohci.o usb-ohci-pci.o
obj-$(CONFIG_USB_SL811HS_ALT) += sl811.o
obj-$(CONFIG_USB_SL811HS) += hc_sl811.o
+obj-$(CONFIG_USB_OHCI_SA1111) += usb-ohci.o usb-ohci-sa1111.o
+obj-$(CONFIG_USB_OHCI_AT91) += usb-ohci.o
# Extract lists of the multi-part drivers.
# The 'int-*' lists are the intermediate files used to build the multi's.
diff -urN linux-2.4.26/drivers/usb/host/usb-ohci-pci.c linux-2.4.26-vrs1/drivers/usb/host/usb-ohci-pci.c
--- linux-2.4.26/drivers/usb/host/usb-ohci-pci.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/usb/host/usb-ohci-pci.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,436 @@
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h> /* for in_interrupt() */
+#undef DEBUG
+#include <linux/usb.h>
+
+#include "usb-ohci.h"
+
+#ifdef CONFIG_PMAC_PBOOK
+#include <asm/machdep.h>
+#include <asm/pmac_feature.h>
+#include <asm/pci-bridge.h>
+#ifndef CONFIG_PM
+#define CONFIG_PM
+#endif
+#endif
+
+
+/*-------------------------------------------------------------------------*/
+
+/* Increment the module usage count, start the control thread and
+ * return success. */
+
+static struct pci_driver ohci_pci_driver;
+extern spinlock_t usb_ed_lock;
+int __devinit
+hc_add_ohci(struct pci_dev *dev, int irq, void *membase, unsigned long flags,
+ const char *name, const char *slot_name);
+extern void hc_remove_ohci(ohci_t *ohci);
+
+static int __devinit
+hc_found_ohci (struct pci_dev *dev, int irq,
+ void *mem_base, const struct pci_device_id *id)
+{
+ unsigned long flags = id->driver_data;
+
+ printk(KERN_INFO __FILE__ ": usb-%s, %s\n", dev->slot_name, dev->name);
+
+ /* Check for NSC87560. We have to look at the bridge (fn1) to identify
+ the USB (fn2). This quirk might apply to more or even all NSC stuff
+ I don't know.. */
+
+ if(dev->vendor == PCI_VENDOR_ID_NS)
+ {
+ struct pci_dev *fn1 = pci_find_slot(dev->bus->number, PCI_DEVFN(PCI_SLOT(dev->devfn), 1));
+ if(fn1 && fn1->vendor == PCI_VENDOR_ID_NS && fn1->device == PCI_DEVICE_ID_NS_87560_LIO)
+ flags |= OHCI_QUIRK_SUCKYIO;
+
+ }
+
+ if (flags & OHCI_QUIRK_SUCKYIO)
+ printk (KERN_INFO __FILE__ ": Using NSC SuperIO setup\n");
+ if (flags & OHCI_QUIRK_AMD756)
+ printk (KERN_INFO __FILE__ ": AMD756 erratum 4 workaround\n");
+
+ return hc_add_ohci(dev, irq, mem_base, flags,
+ ohci_pci_driver.name, dev->slot_name);
+}
+
+/*-------------------------------------------------------------------------*/
+
+#ifdef CONFIG_PM
+
+/* controller died; cleanup debris, then restart */
+/* must not be called from interrupt context */
+
+static void hc_restart (ohci_t *ohci)
+{
+ int temp;
+ int i;
+
+ if (ohci->pci_latency)
+ pci_write_config_byte (ohci->ohci_dev, PCI_LATENCY_TIMER, ohci->pci_latency);
+
+ ohci->disabled = 1;
+ ohci->sleeping = 0;
+ if (ohci->bus->root_hub)
+ usb_disconnect (&ohci->bus->root_hub);
+
+ /* empty the interrupt branches */
+ for (i = 0; i < NUM_INTS; i++) ohci->ohci_int_load[i] = 0;
+ for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table[i] = 0;
+
+ /* no EDs to remove */
+ ohci->ed_rm_list [0] = NULL;
+ ohci->ed_rm_list [1] = NULL;
+
+ /* empty control and bulk lists */
+ ohci->ed_isotail = NULL;
+ ohci->ed_controltail = NULL;
+ ohci->ed_bulktail = NULL;
+
+ if ((temp = hc_reset (ohci)) < 0 || (temp = hc_start (ohci)) < 0) {
+ err ("can't restart usb-%s, %d", ohci->ohci_dev->slot_name, temp);
+ } else
+ dbg ("restart usb-%s completed", ohci->ohci_dev->slot_name);
+}
+
+#endif /* CONFIG_PM */
+
+/*-------------------------------------------------------------------------*/
+
+/* configured so that an OHCI device is always provided */
+/* always called with process context; sleeping is OK */
+
+static int __devinit
+ohci_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
+{
+ unsigned long mem_resource, mem_len;
+ void *mem_base;
+ int status;
+
+ if (pci_enable_device(dev) < 0)
+ return -ENODEV;
+
+ if (!dev->irq) {
+ err("found OHCI device with no IRQ assigned. check BIOS settings!");
+ pci_disable_device (dev);
+ return -ENODEV;
+ }
+
+ /* we read its hardware registers as memory */
+ mem_resource = pci_resource_start(dev, 0);
+ mem_len = pci_resource_len(dev, 0);
+ if (!request_mem_region (mem_resource, mem_len, ohci_pci_driver.name)) {
+ dbg ("controller already in use");
+ pci_disable_device (dev);
+ return -EBUSY;
+ }
+
+ mem_base = ioremap_nocache (mem_resource, mem_len);
+ if (!mem_base) {
+ err("Error mapping OHCI memory");
+ release_mem_region (mem_resource, mem_len);
+ pci_disable_device (dev);
+ return -EFAULT;
+ }
+
+ /* controller writes into our memory */
+ pci_set_master (dev);
+
+ status = hc_found_ohci (dev, dev->irq, mem_base, id);
+ if (status < 0) {
+ iounmap (mem_base);
+ release_mem_region (mem_resource, mem_len);
+ pci_disable_device (dev);
+ }
+ return status;
+}
+
+/*-------------------------------------------------------------------------*/
+
+/* may be called from interrupt context [interface spec] */
+/* may be called without controller present */
+/* may be called with controller, bus, and devices active */
+
+static void __devexit
+ohci_pci_remove (struct pci_dev *dev)
+{
+ ohci_t *ohci = (ohci_t *) pci_get_drvdata(dev);
+
+ dbg ("remove %s controller usb-%s%s%s",
+ hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS),
+ dev->slot_name,
+ ohci->disabled ? " (disabled)" : "",
+ in_interrupt () ? " in interrupt" : ""
+ );
+
+ hc_remove_ohci(ohci);
+
+ release_mem_region (pci_resource_start (dev, 0), pci_resource_len (dev, 0));
+ pci_disable_device (dev);
+}
+
+
+#ifdef CONFIG_PM
+
+/*-------------------------------------------------------------------------*/
+
+static int
+ohci_pci_suspend (struct pci_dev *dev, u32 state)
+{
+ ohci_t *ohci = (ohci_t *) pci_get_drvdata(dev);
+ unsigned long flags;
+ u16 cmd;
+
+ if ((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER) {
+ dbg ("can't suspend usb-%s (state is %s)", dev->slot_name,
+ hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS));
+ return -EIO;
+ }
+
+ /* act as if usb suspend can always be used */
+ info ("USB suspend: usb-%s", dev->slot_name);
+ ohci->sleeping = 1;
+
+ /* First stop processing */
+ spin_lock_irqsave (&usb_ed_lock, flags);
+ ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_IE);
+ writel (ohci->hc_control, &ohci->regs->control);
+ writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
+ (void) readl (&ohci->regs->intrstatus);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
+
+ /* Wait a frame or two */
+ mdelay(1);
+ if (!readl (&ohci->regs->intrstatus) & OHCI_INTR_SF)
+ mdelay (1);
+
+#ifdef CONFIG_PMAC_PBOOK
+ if (_machine == _MACH_Pmac)
+ disable_irq (ohci->irq);
+ /* else, 2.4 assumes shared irqs -- don't disable */
+#endif
+ /* Enable remote wakeup */
+ writel (readl(&ohci->regs->intrenable) | OHCI_INTR_RD, &ohci->regs->intrenable);
+
+ /* Suspend chip and let things settle down a bit */
+ ohci->hc_control = OHCI_USB_SUSPEND;
+ writel (ohci->hc_control, &ohci->regs->control);
+ (void) readl (&ohci->regs->control);
+ mdelay (500); /* No schedule here ! */
+ switch (readl (&ohci->regs->control) & OHCI_CTRL_HCFS) {
+ case OHCI_USB_RESET:
+ dbg("Bus in reset phase ???");
+ break;
+ case OHCI_USB_RESUME:
+ dbg("Bus in resume phase ???");
+ break;
+ case OHCI_USB_OPER:
+ dbg("Bus in operational phase ???");
+ break;
+ case OHCI_USB_SUSPEND:
+ dbg("Bus suspended");
+ break;
+ }
+ /* In some rare situations, Apple's OHCI have happily trashed
+ * memory during sleep. We disable it's bus master bit during
+ * suspend
+ */
+ pci_read_config_word (dev, PCI_COMMAND, &cmd);
+ cmd &= ~PCI_COMMAND_MASTER;
+ pci_write_config_word (dev, PCI_COMMAND, cmd);
+#ifdef CONFIG_PMAC_PBOOK
+ {
+ struct device_node *of_node;
+
+ /* Disable USB PAD & cell clock */
+ of_node = pci_device_to_OF_node (ohci->ohci_dev);
+ if (of_node)
+ pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0);
+ }
+#endif
+ return 0;
+}
+
+/*-------------------------------------------------------------------------*/
+
+static int
+ohci_pci_resume (struct pci_dev *dev)
+{
+ ohci_t *ohci = (ohci_t *) pci_get_drvdata(dev);
+ int temp;
+ unsigned long flags;
+
+ /* guard against multiple resumes */
+ atomic_inc (&ohci->resume_count);
+ if (atomic_read (&ohci->resume_count) != 1) {
+ err ("concurrent PCI resumes for usb-%s", dev->slot_name);
+ atomic_dec (&ohci->resume_count);
+ return 0;
+ }
+
+#ifdef CONFIG_PMAC_PBOOK
+ {
+ struct device_node *of_node;
+
+ /* Re-enable USB PAD & cell clock */
+ of_node = pci_device_to_OF_node (ohci->ohci_dev);
+ if (of_node)
+ pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 1);
+ }
+#endif
+
+ /* did we suspend, or were we powered off? */
+ ohci->hc_control = readl (&ohci->regs->control);
+ temp = ohci->hc_control & OHCI_CTRL_HCFS;
+
+#ifdef DEBUG
+ /* the registers may look crazy here */
+ ohci_dump_status (ohci);
+#endif
+
+ /* Re-enable bus mastering */
+ pci_set_master(ohci->ohci_dev);
+
+ switch (temp) {
+
+ case OHCI_USB_RESET: // lost power
+ info ("USB restart: usb-%s", dev->slot_name);
+ hc_restart (ohci);
+ break;
+
+ case OHCI_USB_SUSPEND: // host wakeup
+ case OHCI_USB_RESUME: // remote wakeup
+ info ("USB continue: usb-%s from %s wakeup", dev->slot_name,
+ (temp == OHCI_USB_SUSPEND)
+ ? "host" : "remote");
+ ohci->hc_control = OHCI_USB_RESUME;
+ writel (ohci->hc_control, &ohci->regs->control);
+ (void) readl (&ohci->regs->control);
+ mdelay (20); /* no schedule here ! */
+ /* Some controllers (lucent) need a longer delay here */
+ mdelay (15);
+ temp = readl (&ohci->regs->control);
+ temp = ohci->hc_control & OHCI_CTRL_HCFS;
+ if (temp != OHCI_USB_RESUME) {
+ err ("controller usb-%s won't resume", dev->slot_name);
+ ohci->disabled = 1;
+ return -EIO;
+ }
+
+ /* Some chips likes being resumed first */
+ writel (OHCI_USB_OPER, &ohci->regs->control);
+ (void) readl (&ohci->regs->control);
+ mdelay (3);
+
+ /* Then re-enable operations */
+ spin_lock_irqsave (&usb_ed_lock, flags);
+ ohci->disabled = 0;
+ ohci->sleeping = 0;
+ ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER;
+ if (!ohci->ed_rm_list[0] && !ohci->ed_rm_list[1]) {
+ if (ohci->ed_controltail)
+ ohci->hc_control |= OHCI_CTRL_CLE;
+ if (ohci->ed_bulktail)
+ ohci->hc_control |= OHCI_CTRL_BLE;
+ }
+ writel (ohci->hc_control, &ohci->regs->control);
+ writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
+ writel (OHCI_INTR_SF, &ohci->regs->intrenable);
+ /* Check for a pending done list */
+ writel (OHCI_INTR_WDH, &ohci->regs->intrdisable);
+ (void) readl (&ohci->regs->intrdisable);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
+#ifdef CONFIG_PMAC_PBOOK
+ if (_machine == _MACH_Pmac)
+ enable_irq (ohci->irq);
+#endif
+ if (ohci->hcca->done_head)
+ dl_done_list (ohci, dl_reverse_done_list (ohci));
+ writel (OHCI_INTR_WDH, &ohci->regs->intrenable);
+ writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
+ writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
+ break;
+
+ default:
+ warn ("odd PCI resume for usb-%s", dev->slot_name);
+ }
+
+ /* controller is operational, extra resumes are harmless */
+ atomic_dec (&ohci->resume_count);
+
+ return 0;
+}
+
+#endif /* CONFIG_PM */
+
+
+/*-------------------------------------------------------------------------*/
+
+static const struct pci_device_id __devinitdata ohci_pci_ids [] = { {
+
+ /*
+ * AMD-756 [Viper] USB has a serious erratum when used with
+ * lowspeed devices like mice.
+ */
+ vendor: 0x1022,
+ device: 0x740c,
+ subvendor: PCI_ANY_ID,
+ subdevice: PCI_ANY_ID,
+
+ driver_data: OHCI_QUIRK_AMD756,
+
+} , {
+
+ /* handle any USB OHCI controller */
+ class: ((PCI_CLASS_SERIAL_USB << 8) | 0x10),
+ class_mask: ~0,
+
+ /* no matter who makes it */
+ vendor: PCI_ANY_ID,
+ device: PCI_ANY_ID,
+ subvendor: PCI_ANY_ID,
+ subdevice: PCI_ANY_ID,
+
+ }, { /* end: all zeroes */ }
+};
+
+MODULE_DEVICE_TABLE (pci, ohci_pci_ids);
+
+static struct pci_driver ohci_pci_driver = {
+ name: "usb-ohci",
+ id_table: &ohci_pci_ids [0],
+
+ probe: ohci_pci_probe,
+ remove: __devexit_p(ohci_pci_remove),
+
+#ifdef CONFIG_PM
+ suspend: ohci_pci_suspend,
+ resume: ohci_pci_resume,
+#endif /* PM */
+};
+
+
+/*-------------------------------------------------------------------------*/
+
+static int __init ohci_hcd_init (void)
+{
+ return pci_module_init (&ohci_pci_driver);
+}
+
+/*-------------------------------------------------------------------------*/
+
+static void __exit ohci_hcd_cleanup (void)
+{
+ pci_unregister_driver (&ohci_pci_driver);
+}
+
+module_init (ohci_hcd_init);
+module_exit (ohci_hcd_cleanup);
+
diff -urN linux-2.4.26/drivers/usb/host/usb-ohci-sa1111.c linux-2.4.26-vrs1/drivers/usb/host/usb-ohci-sa1111.c
--- linux-2.4.26/drivers/usb/host/usb-ohci-sa1111.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/usb/host/usb-ohci-sa1111.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,118 @@
+/*
+ * linux/drivers/usb/usb-ohci-sa1111.c
+ *
+ * The outline of this code was taken from Brad Parkers <brad@heeltoe.com>
+ * original OHCI driver modifications, and reworked into a cleaner form
+ * by Russell King <rmk@arm.linux.org.uk>.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/ioport.h>
+#include <linux/interrupt.h>
+#include <linux/slab.h>
+#include <linux/usb.h>
+
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/pci.h>
+#include <asm/arch/assabet.h>
+#include <asm/arch/badge4.h>
+#include <asm/hardware/sa1111.h>
+
+#include "usb-ohci.h"
+
+int __devinit
+hc_add_ohci(struct pci_dev *dev, int irq, void *membase, unsigned long flags,
+ const char *name, const char *slot_name);
+extern void hc_remove_ohci(ohci_t *ohci);
+
+static ohci_t *sa1111_ohci;
+
+static void __init sa1111_ohci_configure(void)
+{
+ unsigned int usb_rst = 0;
+
+ if (machine_is_xp860() ||
+ machine_has_neponset() ||
+ machine_is_accelent_sa() ||
+ machine_is_pfs168() ||
+ machine_is_badge4())
+ usb_rst = USB_RESET_PWRSENSELOW | USB_RESET_PWRCTRLLOW;
+
+ /*
+ * Configure the power sense and control lines. Place the USB
+ * host controller in reset.
+ */
+ USB_RESET = usb_rst | USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET;
+
+ /*
+ * Now, carefully enable the USB clock, and take
+ * the USB host controller out of reset.
+ */
+ SKPCR |= SKPCR_UCLKEN;
+ udelay(11);
+ USB_RESET = usb_rst;
+}
+
+static int __init sa1111_ohci_init(void)
+{
+ int ret;
+
+ /*
+ * Request memory resources.
+ */
+// if (!request_mem_region(_USB_OHCI_OP_BASE, _USB_EXTENT, "usb-ohci"))
+// return -EBUSY;
+
+ sa1111_ohci_configure();
+
+ /*
+ * Initialise the generic OHCI driver.
+ */
+ ret = hc_add_ohci(SA1111_FAKE_PCIDEV, NIRQHCIM,
+ (void *)&USB_OHCI_OP_BASE, 0, &sa1111_ohci,
+ "usb-ohci", "sa1111");
+
+// if (ret)
+// release_mem_region(_USB_OHCI_OP_BASE, _USB_EXTENT);
+
+#ifdef CONFIG_SA1100_BADGE4
+ if (machine_is_badge4() && (!ret)) {
+ /* found the controller, so now power the bus */
+ badge4_set_5V(BADGE4_5V_USB, 1);
+ }
+#endif
+
+ return ret;
+}
+
+static void __exit sa1111_ohci_exit(void)
+{
+ hc_remove_ohci(sa1111_ohci);
+
+ /*
+ * Put the USB host controller into reset.
+ */
+ USB_RESET |= USB_RESET_FORCEIFRESET | USB_RESET_FORCEHCRESET;
+
+ /*
+ * Stop the USB clock.
+ */
+ SKPCR &= ~SKPCR_UCLKEN;
+
+ /*
+ * Release memory resources.
+ */
+// release_mem_region(_USB_OHCI_OP_BASE, _USB_EXTENT);
+
+#ifdef CONFIG_SA1100_BADGE4
+ if (machine_is_badge4()) {
+ badge4_set_5V(BADGE4_5V_USB, 0);
+ }
+#endif
+}
+
+module_init(sa1111_ohci_init);
+module_exit(sa1111_ohci_exit);
diff -urN linux-2.4.26/drivers/usb/host/usb-ohci.c linux-2.4.26-vrs1/drivers/usb/host/usb-ohci.c
--- linux-2.4.26/drivers/usb/host/usb-ohci.c 2004-04-19 11:44:27.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/usb/host/usb-ohci.c 2004-04-19 15:27:57.000000000 +0100
@@ -12,7 +12,6 @@
*
* History:
*
- * 2002/10/22 OHCI_USB_OPER for ALi lockup in IBM i1200 (ALEX <thchou@ali>)
* 2002/03/08 interrupt unlink fix (Matt Hughes), better cleanup on
* load failure (Matthew Frederickson)
* 2002/01/20 async unlink fixes: return -EINPROGRESS (per spec) and
@@ -81,16 +80,6 @@
#include "../hcd.h"
-#ifdef CONFIG_PMAC_PBOOK
-#include <asm/machdep.h>
-#include <asm/pmac_feature.h>
-#include <asm/pci-bridge.h>
-#ifndef CONFIG_PM
-#define CONFIG_PM
-#endif
-#endif
-
-
/*
* Version Information
*/
@@ -98,12 +87,12 @@
#define DRIVER_AUTHOR "Roman Weissgaerber <weissg@vienna.at>, David Brownell"
#define DRIVER_DESC "USB OHCI Host Controller Driver"
-/* For initializing controller (mask in an HCFS mode too) */
-#define OHCI_CONTROL_INIT \
- (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE
-
#define OHCI_UNLINK_TIMEOUT (HZ / 10)
+static LIST_HEAD (ohci_hcd_list);
+spinlock_t usb_ed_lock = SPIN_LOCK_UNLOCKED;
+
+
/*-------------------------------------------------------------------------*/
/* AMD-756 (D2 rev) reports corrupt register contents in some cases.
@@ -130,57 +119,6 @@
/*-------------------------------------------------------------------------*
* URB support functions
*-------------------------------------------------------------------------*/
-
-static void ohci_complete_add(struct ohci *ohci, struct urb *urb)
-{
-
- if (urb->hcpriv != NULL) {
- printk("completing with non-null priv!\n");
- return;
- }
-
- if (ohci->complete_tail == NULL) {
- ohci->complete_head = urb;
- ohci->complete_tail = urb;
- } else {
- ohci->complete_head->hcpriv = urb;
- ohci->complete_tail = urb;
- }
-}
-
-static inline struct urb *ohci_complete_get(struct ohci *ohci)
-{
- struct urb *urb;
-
- if ((urb = ohci->complete_head) == NULL)
- return NULL;
- if (urb == ohci->complete_tail) {
- ohci->complete_tail = NULL;
- ohci->complete_head = NULL;
- } else {
- ohci->complete_head = urb->hcpriv;
- }
- urb->hcpriv = NULL;
- return urb;
-}
-
-static inline void ohci_complete(struct ohci *ohci)
-{
- struct urb *urb;
-
- spin_lock(&ohci->ohci_lock);
- while ((urb = ohci_complete_get(ohci)) != NULL) {
- spin_unlock(&ohci->ohci_lock);
- if (urb->dev) {
- usb_dec_dev_use (urb->dev);
- urb->dev = NULL;
- }
- if (urb->complete)
- (*urb->complete)(urb);
- spin_lock(&ohci->ohci_lock);
- }
- spin_unlock(&ohci->ohci_lock);
-}
/* free HCD-private data associated with this URB */
@@ -256,14 +194,20 @@
}
urb_free_priv ((struct ohci *)urb->dev->bus->hcpriv, urb_priv);
- } else {
- if (urb->dev != NULL) {
- err ("Non-null dev at rm_priv time");
- // urb->dev = NULL;
- }
+ usb_dec_dev_use (urb->dev);
+ urb->dev = NULL;
}
}
+static void urb_rm_priv (struct urb * urb)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave (&usb_ed_lock, flags);
+ urb_rm_priv_locked (urb);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
+}
+
/*-------------------------------------------------------------------------*/
#ifdef DEBUG
@@ -484,7 +428,7 @@
static void ohci_dump (ohci_t *controller, int verbose)
{
- dbg ("OHCI controller usb-%s state", controller->ohci_dev->slot_name);
+ dbg ("OHCI controller usb-%s state", controller->slot_name);
// dumps some of the state we know about
ohci_dump_status (controller);
@@ -507,6 +451,7 @@
{
urb_priv_t * urb_priv = urb->hcpriv;
struct urb * urbt;
+ unsigned long flags;
int i;
if (!urb_priv)
@@ -514,8 +459,7 @@
/* just to be sure */
if (!urb->complete) {
- urb_rm_priv_locked (urb);
- ohci_complete_add(hc, urb); /* Just usb_dec_dev_use */
+ urb_rm_priv (urb);
return -1;
}
@@ -531,18 +475,20 @@
usb_pipeout (urb->pipe)
? PCI_DMA_TODEVICE
: PCI_DMA_FROMDEVICE);
+
if (urb->interval) {
urb->complete (urb);
-
+
/* implicitly requeued */
urb->actual_length = 0;
urb->status = -EINPROGRESS;
td_submit_urb (urb);
} else {
- urb_rm_priv_locked (urb);
- ohci_complete_add(hc, urb);
+ urb_rm_priv(urb);
+ urb->complete (urb);
}
- break;
+ break;
+
case PIPE_ISOCHRONOUS:
for (urbt = urb->next; urbt && (urbt != urb); urbt = urbt->next);
@@ -554,6 +500,7 @@
? PCI_DMA_TODEVICE
: PCI_DMA_FROMDEVICE);
urb->complete (urb);
+ spin_lock_irqsave (&usb_ed_lock, flags);
urb->actual_length = 0;
urb->status = USB_ST_URB_PENDING;
urb->start_frame = urb_priv->ed->last_iso + 1;
@@ -564,17 +511,18 @@
}
td_submit_urb (urb);
}
-
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
+
} else { /* unlink URB, call complete */
- urb_rm_priv_locked (urb);
- ohci_complete_add(hc, urb);
+ urb_rm_priv (urb);
+ urb->complete (urb);
}
break;
case PIPE_BULK:
case PIPE_CONTROL: /* unlink URB, call complete */
- urb_rm_priv_locked (urb);
- ohci_complete_add(hc, urb);
+ urb_rm_priv (urb);
+ urb->complete (urb);
break;
}
return 0;
@@ -594,7 +542,7 @@
int i, size = 0;
unsigned long flags;
int bustime = 0;
- int mem_flags = GFP_ATOMIC;
+ int mem_flags = ALLOC_FLAGS;
if (!urb->dev || !urb->dev->bus)
return -ENODEV;
@@ -611,24 +559,20 @@
#ifdef DEBUG
urb_print (urb, "SUB", usb_pipein (pipe));
#endif
-
+
/* handle a request to the virtual root hub */
if (usb_pipedevice (pipe) == ohci->rh.devnum)
return rh_submit_urb (urb);
-
- spin_lock_irqsave(&ohci->ohci_lock, flags);
-
+
/* when controller's hung, permit only roothub cleanup attempts
* such as powering down ports */
if (ohci->disabled) {
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
usb_dec_dev_use (urb->dev);
return -ESHUTDOWN;
}
/* every endpoint has a ed, locate and fill it */
if (!(ed = ep_add_ed (urb->dev, pipe, urb->interval, 1, mem_flags))) {
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
usb_dec_dev_use (urb->dev);
return -ENOMEM;
}
@@ -650,7 +594,6 @@
case PIPE_ISOCHRONOUS: /* number of packets from URB */
size = urb->number_of_packets;
if (size <= 0) {
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
usb_dec_dev_use (urb->dev);
return -EINVAL;
}
@@ -670,9 +613,8 @@
/* allocate the private part of the URB */
urb_priv = kmalloc (sizeof (urb_priv_t) + size * sizeof (td_t *),
- GFP_ATOMIC);
+ in_interrupt() ? GFP_ATOMIC : GFP_NOIO);
if (!urb_priv) {
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
usb_dec_dev_use (urb->dev);
return -ENOMEM;
}
@@ -683,12 +625,13 @@
urb_priv->ed = ed;
/* allocate the TDs (updating hash chains) */
+ spin_lock_irqsave (&usb_ed_lock, flags);
for (i = 0; i < size; i++) {
urb_priv->td[i] = td_alloc (ohci, SLAB_ATOMIC);
if (!urb_priv->td[i]) {
urb_priv->length = i;
urb_free_priv (ohci, urb_priv);
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
usb_dec_dev_use (urb->dev);
return -ENOMEM;
}
@@ -696,7 +639,7 @@
if (ed->state == ED_NEW || (ed->state & ED_DEL)) {
urb_free_priv (ohci, urb_priv);
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
usb_dec_dev_use (urb->dev);
return -EINVAL;
}
@@ -718,7 +661,7 @@
}
if (bustime < 0) {
urb_free_priv (ohci, urb_priv);
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
usb_dec_dev_use (urb->dev);
return bustime;
}
@@ -744,6 +687,9 @@
if (urb->timeout) {
struct list_head *entry;
+ // FIXME: usb-uhci uses relative timeouts (like this),
+ // while uhci uses absolute ones (probably better).
+ // Pick one solution and change the affected drivers.
urb->timeout += jiffies;
list_for_each (entry, &ohci->timeout_list) {
@@ -757,11 +703,10 @@
/* drive timeouts by SF (messy, but works) */
writel (OHCI_INTR_SF, &ohci->regs->intrenable);
- (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
}
#endif
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
return 0;
}
@@ -792,7 +737,6 @@
if (usb_pipedevice (urb->pipe) == ohci->rh.devnum)
return rh_unlink_urb (urb);
- spin_lock_irqsave(&ohci->ohci_lock, flags);
if (urb->hcpriv && (urb->status == USB_ST_URB_PENDING)) {
if (!ohci->disabled) {
urb_priv_t * urb_priv;
@@ -802,7 +746,6 @@
*/
if (!(urb->transfer_flags & USB_ASYNC_UNLINK)
&& in_interrupt ()) {
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
err ("bug in call from %p; use async!",
__builtin_return_address(0));
return -EWOULDBLOCK;
@@ -811,10 +754,11 @@
/* flag the urb and its TDs for deletion in some
* upcoming SF interrupt delete list processing
*/
+ spin_lock_irqsave (&usb_ed_lock, flags);
urb_priv = urb->hcpriv;
if (!urb_priv || (urb_priv->state == URB_DEL)) {
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
return 0;
}
@@ -829,36 +773,26 @@
add_wait_queue (&unlink_wakeup, &wait);
urb_priv->wait = &unlink_wakeup;
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
/* wait until all TDs are deleted */
set_current_state(TASK_UNINTERRUPTIBLE);
- while (timeout && (urb->status == USB_ST_URB_PENDING)) {
+ while (timeout && (urb->status == USB_ST_URB_PENDING))
timeout = schedule_timeout (timeout);
- set_current_state(TASK_UNINTERRUPTIBLE);
- }
set_current_state(TASK_RUNNING);
remove_wait_queue (&unlink_wakeup, &wait);
if (urb->status == USB_ST_URB_PENDING) {
err ("unlink URB timeout");
return -ETIMEDOUT;
}
-
- usb_dec_dev_use (urb->dev);
- urb->dev = NULL;
- if (urb->complete)
- urb->complete (urb);
} else {
/* usb_dec_dev_use done in dl_del_list() */
urb->status = -EINPROGRESS;
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
return -EINPROGRESS;
}
} else {
- urb_rm_priv_locked (urb);
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
- usb_dec_dev_use (urb->dev);
- urb->dev = NULL;
+ urb_rm_priv (urb);
if (urb->transfer_flags & USB_ASYNC_UNLINK) {
urb->status = -ECONNRESET;
if (urb->complete)
@@ -866,8 +800,6 @@
} else
urb->status = -ENOENT;
}
- } else {
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
}
return 0;
}
@@ -910,14 +842,14 @@
* (freeing all the TDs, unlinking EDs) but we need
* to defend against bugs that prevent that.
*/
- spin_lock_irqsave(&ohci->ohci_lock, flags);
+ spin_lock_irqsave (&usb_ed_lock, flags);
for(i = 0; i < NUM_EDS; i++) {
ed = &(dev->ed[i]);
if (ed->state != ED_NEW) {
if (ed->state == ED_OPER) {
/* driver on that interface didn't unlink an urb */
dbg ("driver usb-%s dev %d ed 0x%x unfreed URB",
- ohci->ohci_dev->slot_name, usb_dev->devnum, i);
+ ohci->slot_name, usb_dev->devnum, i);
ep_unlink (ohci, ed);
}
ep_rm_ed (usb_dev, ed);
@@ -925,7 +857,7 @@
cnt++;
}
}
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
/* if the controller is running, tds for those unlinked
* urbs get freed by dl_del_list at the next SF interrupt
@@ -962,7 +894,7 @@
} else {
/* likely some interface's driver has a refcount bug */
err ("bus %s devnum %d deletion in interrupt",
- ohci->ohci_dev->slot_name, usb_dev->devnum);
+ ohci->slot_name, usb_dev->devnum);
BUG ();
}
}
@@ -1259,12 +1191,17 @@
td_t * td;
ed_t * ed_ret;
volatile ed_t * ed;
+ unsigned long flags;
+
+
+ spin_lock_irqsave (&usb_ed_lock, flags);
ed = ed_ret = &(usb_to_ohci (usb_dev)->ed[(usb_pipeendpoint (pipe) << 1) |
(usb_pipecontrol (pipe)? 0: usb_pipeout (pipe))]);
if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) {
/* pending delete request */
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
return NULL;
}
@@ -1277,6 +1214,7 @@
/* out of memory */
if (td)
td_free(ohci, td);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
return NULL;
}
ed->hwTailP = cpu_to_le32 (td->td_dma);
@@ -1299,7 +1237,8 @@
ed->int_period = interval;
ed->int_load = load;
}
-
+
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
return ed_ret;
}
@@ -1340,7 +1279,6 @@
/* enable SOF interrupt */
writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
writel (OHCI_INTR_SF, &ohci->regs->intrenable);
- (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
}
}
@@ -1362,7 +1300,11 @@
err("internal OHCI error: TD index > length");
return;
}
-
+#ifdef CONFIG_SA1111
+ if (data & (1 << 20))
+ panic("td_fill: A20 = 1: %08x\n", data);
+#endif
+
/* use this td as the next dummy */
td_pt = urb_priv->td [index];
td_pt->hwNextTD = 0;
@@ -1461,7 +1403,6 @@
if (!ohci->sleeping) {
wmb();
writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
- (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
}
break;
@@ -1490,7 +1431,6 @@
if (!ohci->sleeping) {
wmb();
writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
- (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
}
break;
@@ -1558,7 +1498,7 @@
/* handle an urb that is being unlinked */
-static void dl_del_urb (ohci_t *ohci, struct urb * urb)
+static void dl_del_urb (struct urb * urb)
{
wait_queue_head_t * wait_head = ((urb_priv_t *)(urb->hcpriv))->wait;
@@ -1566,9 +1506,12 @@
if (urb->transfer_flags & USB_ASYNC_UNLINK) {
urb->status = -ECONNRESET;
- ohci_complete_add(ohci, urb);
+ if (urb->complete)
+ urb->complete (urb);
} else {
urb->status = -ENOENT;
+ if (urb->complete)
+ urb->complete (urb);
/* unblock sohci_unlink_urb */
if (wait_head)
@@ -1587,7 +1530,10 @@
td_t * td_rev = NULL;
td_t * td_list = NULL;
urb_priv_t * urb_priv = NULL;
-
+ unsigned long flags;
+
+ spin_lock_irqsave (&usb_ed_lock, flags);
+
td_list_hc = le32_to_cpup (&ohci->hcca->done_head) & 0xfffffff0;
ohci->hcca->done_head = 0;
@@ -1613,6 +1559,7 @@
td_rev = td_list;
td_list_hc = le32_to_cpup (&td_list->hwNextTD) & 0xfffffff0;
}
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
return td_list;
}
@@ -1624,6 +1571,7 @@
static void dl_del_list (ohci_t * ohci, unsigned int frame)
{
+ unsigned long flags;
ed_t * ed;
__u32 edINFO;
__u32 tdINFO;
@@ -1631,6 +1579,8 @@
__u32 * td_p;
int ctrl = 0, bulk = 0;
+ spin_lock_irqsave (&usb_ed_lock, flags);
+
for (ed = ohci->ed_rm_list[frame]; ed != NULL; ed = ed->ed_rm_list) {
tdTailP = dma_to_td (ohci, le32_to_cpup (&ed->hwTailP) & 0xfffffff0);
@@ -1651,7 +1601,7 @@
/* URB is done; clean up */
if (++(urb_priv->td_cnt) == urb_priv->length)
- dl_del_urb (ohci, urb);
+ dl_del_urb (urb);
} else {
td_p = &td->hwNextTD;
}
@@ -1708,6 +1658,7 @@
}
ohci->ed_rm_list[frame] = NULL;
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
}
@@ -1724,7 +1675,9 @@
struct urb * urb;
urb_priv_t * urb_priv;
__u32 tdINFO, edHeadP, edTailP;
-
+
+ unsigned long flags;
+
while (td_list) {
td_list_next = td_list->next_dl_td;
@@ -1753,10 +1706,13 @@
urb->status = cc_to_error[cc];
sohci_return_urb (ohci, urb);
} else {
- dl_del_urb (ohci, urb);
+ spin_lock_irqsave (&usb_ed_lock, flags);
+ dl_del_urb (urb);
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
}
}
+ spin_lock_irqsave (&usb_ed_lock, flags);
if (ed->state != ED_NEW) {
edHeadP = le32_to_cpup (&ed->hwHeadP) & 0xfffffff0;
edTailP = le32_to_cpup (&ed->hwTailP);
@@ -1765,6 +1721,7 @@
if ((edHeadP == edTailP) && (ed->state == ED_OPER))
ep_unlink (ohci, ed);
}
+ spin_unlock_irqrestore (&usb_ed_lock, flags);
td_list = td_list_next;
}
@@ -1855,7 +1812,7 @@
num_ports = roothub_a (ohci) & RH_A_NDP;
if (num_ports > MAX_ROOT_PORTS) {
err ("bogus NDP=%d for OHCI usb-%s", num_ports,
- ohci->ohci_dev->slot_name);
+ ohci->slot_name);
err ("rereads as NDP=%d",
readl (&ohci->regs->roothub.a) & RH_A_NDP);
/* retry later; "should not happen" */
@@ -1955,8 +1912,7 @@
int leni = urb->transfer_buffer_length;
int len = 0;
int status = TD_CC_NOERROR;
- unsigned long flags;
-
+
__u32 datab[4];
__u8 * data_buf = (__u8 *) datab;
@@ -1965,16 +1921,13 @@
__u16 wIndex;
__u16 wLength;
- spin_lock_irqsave(&ohci->ohci_lock, flags);
-
if (usb_pipeint(pipe)) {
ohci->rh.urb = urb;
ohci->rh.send = 1;
ohci->rh.interval = urb->interval;
rh_init_int_timer(urb);
urb->status = cc_to_error [TD_CC_NOERROR];
-
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
+
return 0;
}
@@ -2146,7 +2099,6 @@
#endif
urb->hcpriv = NULL;
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
usb_dec_dev_use (usb_dev);
urb->dev = NULL;
if (urb->complete)
@@ -2159,16 +2111,13 @@
static int rh_unlink_urb (struct urb * urb)
{
ohci_t * ohci = urb->dev->bus->hcpriv;
- unsigned int flags;
- spin_lock_irqsave(&ohci->ohci_lock, flags);
if (ohci->rh.urb == urb) {
ohci->rh.send = 0;
del_timer (&ohci->rh.rh_int_timer);
ohci->rh.urb = NULL;
urb->hcpriv = NULL;
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
usb_dec_dev_use(urb->dev);
urb->dev = NULL;
if (urb->transfer_flags & USB_ASYNC_UNLINK) {
@@ -2177,8 +2126,6 @@
urb->complete (urb);
} else
urb->status = -ENOENT;
- } else {
- spin_unlock_irqrestore(&ohci->ohci_lock, flags);
}
return 0;
}
@@ -2213,16 +2160,12 @@
writel (OHCI_INTR_MIE, &ohci->regs->intrdisable);
dbg("USB HC reset_hc usb-%s: ctrl = 0x%x ;",
- ohci->ohci_dev->slot_name,
+ ohci->slot_name,
readl (&ohci->regs->control));
/* Reset USB (needed by some controllers) */
writel (0, &ohci->regs->control);
-
- /* Force a state change from USBRESET to USBOPERATIONAL for ALi */
- (void) readl (&ohci->regs->control); /* PCI posting */
- writel (ohci->hc_control = OHCI_USB_OPER, &ohci->regs->control);
-
+
/* HC Reset requires max 10 ms delay */
writel (OHCI_HCR, &ohci->regs->cmdstatus);
while ((readl (&ohci->regs->cmdstatus) & OHCI_HCR) != 0) {
@@ -2291,8 +2234,6 @@
writel (RH_HS_LPSC, &ohci->regs->roothub.status);
#endif /* OHCI_USE_NPS */
- (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
-
// POTPGT delay is bits 24-31, in 2 ms units.
mdelay ((roothub_a (ohci) >> 23) & 0x1fe);
@@ -2322,7 +2263,7 @@
static void check_timeouts (struct ohci *ohci)
{
- spin_lock (&ohci->ohci_lock);
+ spin_lock (&usb_ed_lock);
while (!list_empty (&ohci->timeout_list)) {
struct urb *urb;
@@ -2335,15 +2276,15 @@
continue;
urb->transfer_flags |= USB_TIMEOUT_KILLED | USB_ASYNC_UNLINK;
- spin_unlock (&ohci->ohci_lock);
+ spin_unlock (&usb_ed_lock);
// outside the interrupt handler (in a timer...)
// this reference would race interrupts
sohci_unlink_urb (urb);
- spin_lock (&ohci->ohci_lock);
+ spin_lock (&usb_ed_lock);
}
- spin_unlock (&ohci->ohci_lock);
+ spin_unlock (&usb_ed_lock);
}
@@ -2357,8 +2298,6 @@
struct ohci_regs * regs = ohci->regs;
int ints;
- spin_lock (&ohci->ohci_lock);
-
/* avoid (slow) readl if only WDH happened */
if ((ohci->hcca->done_head != 0)
&& !(le32_to_cpup (&ohci->hcca->done_head) & 0x01)) {
@@ -2367,22 +2306,20 @@
/* cardbus/... hardware gone before remove() */
} else if ((ints = readl (®s->intrstatus)) == ~(u32)0) {
ohci->disabled++;
- spin_unlock (&ohci->ohci_lock);
err ("%s device removed!", ohci->ohci_dev->slot_name);
return;
/* interrupt for some other device? */
} else if ((ints &= readl (®s->intrenable)) == 0) {
- spin_unlock (&ohci->ohci_lock);
return;
- }
+ }
// dbg("Interrupt: %x frame: %x", ints, le16_to_cpu (ohci->hcca->frame_no));
if (ints & OHCI_INTR_UE) {
ohci->disabled++;
err ("OHCI Unrecoverable Error, controller usb-%s disabled",
- ohci->ohci_dev->slot_name);
+ ohci->slot_name);
// e.g. due to PCI Master/Target Abort
#ifdef DEBUG
@@ -2398,39 +2335,26 @@
if (ints & OHCI_INTR_WDH) {
writel (OHCI_INTR_WDH, ®s->intrdisable);
- (void)readl (®s->intrdisable); /* PCI posting flush */
dl_done_list (ohci, dl_reverse_done_list (ohci));
writel (OHCI_INTR_WDH, ®s->intrenable);
- (void)readl (®s->intrdisable); /* PCI posting flush */
}
if (ints & OHCI_INTR_SO) {
dbg("USB Schedule overrun");
writel (OHCI_INTR_SO, ®s->intrenable);
- (void)readl (®s->intrdisable); /* PCI posting flush */
}
// FIXME: this assumes SOF (1/ms) interrupts don't get lost...
if (ints & OHCI_INTR_SF) {
unsigned int frame = le16_to_cpu (ohci->hcca->frame_no) & 1;
writel (OHCI_INTR_SF, ®s->intrdisable);
- (void)readl (®s->intrdisable); /* PCI posting flush */
if (ohci->ed_rm_list[!frame] != NULL) {
dl_del_list (ohci, !frame);
}
- if (ohci->ed_rm_list[frame] != NULL) {
+ if (ohci->ed_rm_list[frame] != NULL)
writel (OHCI_INTR_SF, ®s->intrenable);
- (void)readl (®s->intrdisable); /* PCI posting flush */
- }
}
- /*
- * Finally, we are done with trashing about our hardware lists
- * and other CPUs are allowed in. The festive flipping of the lock
- * ensues as we struggle with the check_timeouts disaster.
- */
- spin_unlock (&ohci->ohci_lock);
-
if (!list_empty (&ohci->timeout_list)) {
check_timeouts (ohci);
// FIXME: enable SF as needed in a timer;
@@ -2442,9 +2366,6 @@
writel (ints, ®s->intrstatus);
writel (OHCI_INTR_MIE, ®s->intrenable);
- (void)readl (®s->intrdisable); /* PCI posting flush */
-
- ohci_complete(ohci);
}
/*-------------------------------------------------------------------------*/
@@ -2475,10 +2396,14 @@
ohci->regs = mem_base;
ohci->ohci_dev = dev;
+#ifdef CONFIG_PCI
pci_set_drvdata(dev, ohci);
+#endif
+ INIT_LIST_HEAD (&ohci->ohci_hcd_list);
+ list_add (&ohci->ohci_hcd_list, &ohci_hcd_list);
+
INIT_LIST_HEAD (&ohci->timeout_list);
- spin_lock_init(&ohci->ohci_lock);
ohci->bus = usb_alloc_bus (&sohci_device_operations);
if (!ohci->bus) {
@@ -2501,7 +2426,7 @@
static void hc_release_ohci (ohci_t * ohci)
{
- dbg ("USB HC release ohci usb-%s", ohci->ohci_dev->slot_name);
+ dbg ("USB HC release ohci usb-%s", ohci->slot_name);
/* disconnect all devices */
if (ohci->bus->root_hub)
@@ -2514,7 +2439,9 @@
free_irq (ohci->irq, ohci);
ohci->irq = -1;
}
- pci_set_drvdata(ohci->ohci_dev, NULL);
+#ifdef CONFIG_PCI
+ pci_set_drvdata(ohci->ohci_dev, 0);
+#endif
if (ohci->bus) {
if (ohci->bus->busnum != -1)
usb_deregister_bus (ohci->bus);
@@ -2522,6 +2449,9 @@
usb_free_bus (ohci->bus);
}
+ list_del (&ohci->ohci_hcd_list);
+ INIT_LIST_HEAD (&ohci->ohci_hcd_list);
+
ohci_mem_cleanup (ohci);
/* unmap the IO address space */
@@ -2534,17 +2464,15 @@
/*-------------------------------------------------------------------------*/
-/* Increment the module usage count, start the control thread and
- * return success. */
-
-static struct pci_driver ohci_pci_driver;
-
-static int __devinit
-hc_found_ohci (struct pci_dev *dev, int irq,
- void *mem_base, const struct pci_device_id *id)
+/*
+ * Host bus independent add one OHCI host controller.
+ */
+int __devinit
+hc_add_ohci(struct pci_dev *dev, int irq, void *mem_base, unsigned long flags,
+ const char *name, const char *slot_name)
{
- ohci_t * ohci;
char buf[8], *bufp = buf;
+ ohci_t * ohci;
int ret;
#ifndef __sparc__
@@ -2554,34 +2482,17 @@
#endif
printk(KERN_INFO __FILE__ ": USB OHCI at membase 0x%lx, IRQ %s\n",
(unsigned long) mem_base, bufp);
- printk(KERN_INFO __FILE__ ": usb-%s, %s\n", dev->slot_name, dev->name);
-
+
ohci = hc_alloc_ohci (dev, mem_base);
if (!ohci) {
return -ENOMEM;
}
+ ohci->slot_name = slot_name;
if ((ret = ohci_mem_init (ohci)) < 0) {
hc_release_ohci (ohci);
return ret;
}
- ohci->flags = id->driver_data;
-
- /* Check for NSC87560. We have to look at the bridge (fn1) to identify
- the USB (fn2). This quirk might apply to more or even all NSC stuff
- I don't know.. */
-
- if(dev->vendor == PCI_VENDOR_ID_NS)
- {
- struct pci_dev *fn1 = pci_find_slot(dev->bus->number, PCI_DEVFN(PCI_SLOT(dev->devfn), 1));
- if(fn1 && fn1->vendor == PCI_VENDOR_ID_NS && fn1->device == PCI_DEVICE_ID_NS_87560_LIO)
- ohci->flags |= OHCI_QUIRK_SUCKYIO;
-
- }
-
- if (ohci->flags & OHCI_QUIRK_SUCKYIO)
- printk (KERN_INFO __FILE__ ": Using NSC SuperIO setup\n");
- if (ohci->flags & OHCI_QUIRK_AMD756)
- printk (KERN_INFO __FILE__ ": AMD756 erratum 4 workaround\n");
+ ohci->flags = flags;
if (hc_reset (ohci) < 0) {
hc_release_ohci (ohci);
@@ -2590,13 +2501,11 @@
/* FIXME this is a second HC reset; why?? */
writel (ohci->hc_control = OHCI_USB_RESET, &ohci->regs->control);
- (void)readl (&ohci->regs->intrdisable); /* PCI posting flush */
wait_ms (10);
usb_register_bus (ohci->bus);
- if (request_irq (irq, hc_interrupt, SA_SHIRQ,
- ohci_pci_driver.name, ohci) != 0) {
+ if (request_irq (irq, hc_interrupt, SA_SHIRQ, name, ohci) != 0) {
err ("request interrupt %s failed", bufp);
hc_release_ohci (ohci);
return -EBUSY;
@@ -2604,7 +2513,7 @@
ohci->irq = irq;
if (hc_start (ohci) < 0) {
- err ("can't start usb-%s", dev->slot_name);
+ err ("can't start usb-%s", ohci->slot_name);
hc_release_ohci (ohci);
return -EBUSY;
}
@@ -2615,114 +2524,11 @@
return 0;
}
-/*-------------------------------------------------------------------------*/
-
-#ifdef CONFIG_PM
-
-/* controller died; cleanup debris, then restart */
-/* must not be called from interrupt context */
-
-static void hc_restart (ohci_t *ohci)
-{
- int temp;
- int i;
-
- if (ohci->pci_latency)
- pci_write_config_byte (ohci->ohci_dev, PCI_LATENCY_TIMER, ohci->pci_latency);
-
- ohci->disabled = 1;
- ohci->sleeping = 0;
- if (ohci->bus->root_hub)
- usb_disconnect (&ohci->bus->root_hub);
-
- /* empty the interrupt branches */
- for (i = 0; i < NUM_INTS; i++) ohci->ohci_int_load[i] = 0;
- for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table[i] = 0;
-
- /* no EDs to remove */
- ohci->ed_rm_list [0] = NULL;
- ohci->ed_rm_list [1] = NULL;
-
- /* empty control and bulk lists */
- ohci->ed_isotail = NULL;
- ohci->ed_controltail = NULL;
- ohci->ed_bulktail = NULL;
-
- if ((temp = hc_reset (ohci)) < 0 || (temp = hc_start (ohci)) < 0) {
- err ("can't restart usb-%s, %d", ohci->ohci_dev->slot_name, temp);
- } else
- dbg ("restart usb-%s completed", ohci->ohci_dev->slot_name);
-}
-
-#endif /* CONFIG_PM */
-
-/*-------------------------------------------------------------------------*/
-
-/* configured so that an OHCI device is always provided */
-/* always called with process context; sleeping is OK */
-
-static int __devinit
-ohci_pci_probe (struct pci_dev *dev, const struct pci_device_id *id)
+/*
+ * Host bus independent remove one OHCI host controller.
+ */
+void __devexit hc_remove_ohci(ohci_t *ohci)
{
- unsigned long mem_resource, mem_len;
- void *mem_base;
- int status;
-
- if (pci_enable_device(dev) < 0)
- return -ENODEV;
-
- if (!dev->irq) {
- err("found OHCI device with no IRQ assigned. check BIOS settings!");
- pci_disable_device (dev);
- return -ENODEV;
- }
-
- /* we read its hardware registers as memory */
- mem_resource = pci_resource_start(dev, 0);
- mem_len = pci_resource_len(dev, 0);
- if (!request_mem_region (mem_resource, mem_len, ohci_pci_driver.name)) {
- dbg ("controller already in use");
- pci_disable_device (dev);
- return -EBUSY;
- }
-
- mem_base = ioremap_nocache (mem_resource, mem_len);
- if (!mem_base) {
- err("Error mapping OHCI memory");
- release_mem_region (mem_resource, mem_len);
- pci_disable_device (dev);
- return -EFAULT;
- }
-
- /* controller writes into our memory */
- pci_set_master (dev);
-
- status = hc_found_ohci (dev, dev->irq, mem_base, id);
- if (status < 0) {
- iounmap (mem_base);
- release_mem_region (mem_resource, mem_len);
- pci_disable_device (dev);
- }
- return status;
-}
-
-/*-------------------------------------------------------------------------*/
-
-/* may be called from interrupt context [interface spec] */
-/* may be called without controller present */
-/* may be called with controller, bus, and devices active */
-
-static void __devexit
-ohci_pci_remove (struct pci_dev *dev)
-{
- ohci_t *ohci = pci_get_drvdata(dev);
-
- dbg ("remove %s controller usb-%s%s%s",
- hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS),
- dev->slot_name,
- ohci->disabled ? " (disabled)" : "",
- in_interrupt () ? " in interrupt" : ""
- );
#ifdef DEBUG
ohci_dump (ohci, 1);
#endif
@@ -2739,270 +2545,8 @@
&ohci->regs->control);
hc_release_ohci (ohci);
-
- release_mem_region (pci_resource_start (dev, 0), pci_resource_len (dev, 0));
- pci_disable_device (dev);
-}
-
-
-#ifdef CONFIG_PM
-
-/*-------------------------------------------------------------------------*/
-
-static int
-ohci_pci_suspend (struct pci_dev *dev, u32 state)
-{
- ohci_t *ohci = pci_get_drvdata(dev);
- unsigned long flags;
- u16 cmd;
-
- if ((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER) {
- dbg ("can't suspend usb-%s (state is %s)", dev->slot_name,
- hcfs2string (ohci->hc_control & OHCI_CTRL_HCFS));
- return -EIO;
- }
-
- /* act as if usb suspend can always be used */
- info ("USB suspend: usb-%s", dev->slot_name);
- ohci->sleeping = 1;
-
- /* First stop processing */
- spin_lock_irqsave (&ohci->ohci_lock, flags);
- ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_CLE|OHCI_CTRL_BLE|OHCI_CTRL_IE);
- writel (ohci->hc_control, &ohci->regs->control);
- writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
- (void) readl (&ohci->regs->intrstatus);
- spin_unlock_irqrestore (&ohci->ohci_lock, flags);
-
- /* Wait a frame or two */
- mdelay(1);
- if (!readl (&ohci->regs->intrstatus) & OHCI_INTR_SF)
- mdelay (1);
-
-#ifdef CONFIG_PMAC_PBOOK
- if (_machine == _MACH_Pmac)
- disable_irq (ohci->irq);
- /* else, 2.4 assumes shared irqs -- don't disable */
-#endif
- /* Enable remote wakeup */
- writel (readl(&ohci->regs->intrenable) | OHCI_INTR_RD, &ohci->regs->intrenable);
-
- /* Suspend chip and let things settle down a bit */
- ohci->hc_control = OHCI_USB_SUSPEND;
- writel (ohci->hc_control, &ohci->regs->control);
- (void) readl (&ohci->regs->control);
- mdelay (500); /* No schedule here ! */
- switch (readl (&ohci->regs->control) & OHCI_CTRL_HCFS) {
- case OHCI_USB_RESET:
- dbg("Bus in reset phase ???");
- break;
- case OHCI_USB_RESUME:
- dbg("Bus in resume phase ???");
- break;
- case OHCI_USB_OPER:
- dbg("Bus in operational phase ???");
- break;
- case OHCI_USB_SUSPEND:
- dbg("Bus suspended");
- break;
- }
- /* In some rare situations, Apple's OHCI have happily trashed
- * memory during sleep. We disable it's bus master bit during
- * suspend
- */
- pci_read_config_word (dev, PCI_COMMAND, &cmd);
- cmd &= ~PCI_COMMAND_MASTER;
- pci_write_config_word (dev, PCI_COMMAND, cmd);
-#ifdef CONFIG_PMAC_PBOOK
- {
- struct device_node *of_node;
-
- /* Disable USB PAD & cell clock */
- of_node = pci_device_to_OF_node (ohci->ohci_dev);
- if (of_node)
- pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0);
- }
-#endif
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-static int
-ohci_pci_resume (struct pci_dev *dev)
-{
- ohci_t *ohci = pci_get_drvdata(dev);
- int temp;
- unsigned long flags;
-
- /* guard against multiple resumes */
- atomic_inc (&ohci->resume_count);
- if (atomic_read (&ohci->resume_count) != 1) {
- err ("concurrent PCI resumes for usb-%s", dev->slot_name);
- atomic_dec (&ohci->resume_count);
- return 0;
- }
-
-#ifdef CONFIG_PMAC_PBOOK
- {
- struct device_node *of_node;
-
- /* Re-enable USB PAD & cell clock */
- of_node = pci_device_to_OF_node (ohci->ohci_dev);
- if (of_node)
- pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 1);
- }
-#endif
-
- /* did we suspend, or were we powered off? */
- ohci->hc_control = readl (&ohci->regs->control);
- temp = ohci->hc_control & OHCI_CTRL_HCFS;
-
-#ifdef DEBUG
- /* the registers may look crazy here */
- ohci_dump_status (ohci);
-#endif
-
- /* Re-enable bus mastering */
- pci_set_master(ohci->ohci_dev);
-
- switch (temp) {
-
- case OHCI_USB_RESET: // lost power
- info ("USB restart: usb-%s", dev->slot_name);
- hc_restart (ohci);
- break;
-
- case OHCI_USB_SUSPEND: // host wakeup
- case OHCI_USB_RESUME: // remote wakeup
- info ("USB continue: usb-%s from %s wakeup", dev->slot_name,
- (temp == OHCI_USB_SUSPEND)
- ? "host" : "remote");
- ohci->hc_control = OHCI_USB_RESUME;
- writel (ohci->hc_control, &ohci->regs->control);
- (void) readl (&ohci->regs->control);
- mdelay (20); /* no schedule here ! */
- /* Some controllers (lucent) need a longer delay here */
- mdelay (15);
- temp = readl (&ohci->regs->control);
- temp = ohci->hc_control & OHCI_CTRL_HCFS;
- if (temp != OHCI_USB_RESUME) {
- err ("controller usb-%s won't resume", dev->slot_name);
- ohci->disabled = 1;
- return -EIO;
- }
-
- /* Some chips likes being resumed first */
- writel (OHCI_USB_OPER, &ohci->regs->control);
- (void) readl (&ohci->regs->control);
- mdelay (3);
-
- /* Then re-enable operations */
- spin_lock_irqsave (&ohci->ohci_lock, flags);
- ohci->disabled = 0;
- ohci->sleeping = 0;
- ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER;
- if (!ohci->ed_rm_list[0] && !ohci->ed_rm_list[1]) {
- if (ohci->ed_controltail)
- ohci->hc_control |= OHCI_CTRL_CLE;
- if (ohci->ed_bulktail)
- ohci->hc_control |= OHCI_CTRL_BLE;
- }
- writel (ohci->hc_control, &ohci->regs->control);
- writel (OHCI_INTR_SF, &ohci->regs->intrstatus);
- writel (OHCI_INTR_SF, &ohci->regs->intrenable);
- /* Check for a pending done list */
- writel (OHCI_INTR_WDH, &ohci->regs->intrdisable);
- (void) readl (&ohci->regs->intrdisable);
-#ifdef CONFIG_PMAC_PBOOK
- if (_machine == _MACH_Pmac)
- enable_irq (ohci->irq);
-#endif
- if (ohci->hcca->done_head)
- dl_done_list (ohci, dl_reverse_done_list (ohci));
- writel (OHCI_INTR_WDH, &ohci->regs->intrenable);
- writel (OHCI_BLF, &ohci->regs->cmdstatus); /* start bulk list */
- writel (OHCI_CLF, &ohci->regs->cmdstatus); /* start Control list */
- spin_unlock_irqrestore (&ohci->ohci_lock, flags);
- break;
-
- default:
- warn ("odd PCI resume for usb-%s", dev->slot_name);
- }
-
- /* controller is operational, extra resumes are harmless */
- atomic_dec (&ohci->resume_count);
-
- return 0;
-}
-
-#endif /* CONFIG_PM */
-
-
-/*-------------------------------------------------------------------------*/
-
-static const struct pci_device_id __devinitdata ohci_pci_ids [] = { {
-
- /*
- * AMD-756 [Viper] USB has a serious erratum when used with
- * lowspeed devices like mice.
- */
- vendor: 0x1022,
- device: 0x740c,
- subvendor: PCI_ANY_ID,
- subdevice: PCI_ANY_ID,
-
- driver_data: OHCI_QUIRK_AMD756,
-
-} , {
-
- /* handle any USB OHCI controller */
- class: ((PCI_CLASS_SERIAL_USB << 8) | 0x10),
- class_mask: ~0,
-
- /* no matter who makes it */
- vendor: PCI_ANY_ID,
- device: PCI_ANY_ID,
- subvendor: PCI_ANY_ID,
- subdevice: PCI_ANY_ID,
-
- }, { /* end: all zeroes */ }
-};
-
-MODULE_DEVICE_TABLE (pci, ohci_pci_ids);
-
-static struct pci_driver ohci_pci_driver = {
- name: "usb-ohci",
- id_table: &ohci_pci_ids [0],
-
- probe: ohci_pci_probe,
- remove: __devexit_p(ohci_pci_remove),
-
-#ifdef CONFIG_PM
- suspend: ohci_pci_suspend,
- resume: ohci_pci_resume,
-#endif /* PM */
-};
-
-
-/*-------------------------------------------------------------------------*/
-
-static int __init ohci_hcd_init (void)
-{
- return pci_module_init (&ohci_pci_driver);
}
-/*-------------------------------------------------------------------------*/
-
-static void __exit ohci_hcd_cleanup (void)
-{
- pci_unregister_driver (&ohci_pci_driver);
-}
-
-module_init (ohci_hcd_init);
-module_exit (ohci_hcd_cleanup);
-
-
MODULE_AUTHOR( DRIVER_AUTHOR );
MODULE_DESCRIPTION( DRIVER_DESC );
MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/usb/host/usb-ohci.h linux-2.4.26-vrs1/drivers/usb/host/usb-ohci.h
--- linux-2.4.26/drivers/usb/host/usb-ohci.h 2004-04-19 11:44:27.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/usb/host/usb-ohci.h 2004-04-19 17:13:29.000000000 +0100
@@ -384,12 +384,13 @@
#define OHCI_QUIRK_SUCKYIO 0x02 /* NSC superio */
struct ohci_regs * regs; /* OHCI controller's memory */
+ struct list_head ohci_hcd_list; /* list of all ohci_hcd */
+ struct ohci * next; // chain of ohci device contexts
struct list_head timeout_list;
// struct list_head urb_list; // list of all pending urbs
- spinlock_t ohci_lock; /* Covers all fields up & down */
- struct urb *complete_head, *complete_tail;
-
+ // spinlock_t urb_list_lock; // lock to keep consistency
+
int ohci_int_load[32]; /* load of the 32 Interrupt Chains (for load balancing)*/
ed_t * ed_rm_list[2]; /* lists of all endpoints to be removed */
ed_t * ed_bulktail; /* last endpoint of bulk list */
@@ -403,6 +404,7 @@
/* PCI device handle, settings, ... */
struct pci_dev *ohci_dev;
+ const char *slot_name;
u8 pci_latency;
struct pci_pool *td_cache;
struct pci_pool *dev_cache;
@@ -448,7 +450,7 @@
#endif
#ifndef CONFIG_PCI
-# error "usb-ohci currently requires PCI-based controllers"
+//# error "usb-ohci currently requires PCI-based controllers"
/* to support non-PCI OHCIs, you need custom bus/mem/... glue */
#endif
@@ -641,3 +643,6 @@
pci_pool_free (hc->dev_cache, dev, dev->dma);
}
+/* For initializing controller (mask in an HCFS mode too) */
+#define OHCI_CONTROL_INIT \
+ (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE
diff -urN linux-2.4.26/drivers/video/Config.in linux-2.4.26-vrs1/drivers/video/Config.in
--- linux-2.4.26/drivers/video/Config.in 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/video/Config.in 2004-02-23 23:25:16.000000000 +0000
@@ -30,13 +30,28 @@
tristate ' Permedia3 support (EXPERIMENTAL)' CONFIG_FB_PM3
fi
fi
- if [ "$CONFIG_ARCH_ACORN" = "y" ]; then
- bool ' Acorn VIDC support' CONFIG_FB_ACORN
- fi
- dep_tristate ' Cyber2000 support' CONFIG_FB_CYBER2000 $CONFIG_PCI
- if [ "$CONFIG_ARCH_SA1100" = "y" ]; then
- bool ' SA-1100 LCD support' CONFIG_FB_SA1100
+ if [ "$CONFIG_ARM" = "y" ]; then
+ if [ "$CONFIG_ARCH_ACORN" -o "$CONFIG_ARCH_RISCSTATION" ]; then
+ bool ' Acorn VIDC support' CONFIG_FB_ACORN
+ else
+ define_bool CONFIG_FB_ACORN n
+ fi
+ dep_bool ' Anakin LCD support' CONFIG_FB_ANAKIN $CONFIG_ARCH_ANAKIN
+ dep_bool ' CLPS711X LCD support' CONFIG_FB_CLPS711X $CONFIG_ARCH_CLPS711X
+ dep_bool ' SA-1100 LCD support' CONFIG_FB_SA1100 $CONFIG_ARCH_SA1100
+ dep_bool ' MX1ADS LCD support' CONFIG_FB_DBMX1 $CONFIG_ARCH_MX1ADS
+ if [ "$CONFIG_FB_SA1100" = "y" -a "$CONFIG_SA1100_CERF" = "y" ]; then
+ choice 'CerfBoard LCD Display Size' \
+ "3.8_Color CONFIG_CERF_LCD_38_A \
+ 3.8_Mono CONFIG_CERF_LCD_38_B \
+ 5.7 CONFIG_CERF_LCD_57_A \
+ 7.2 CONFIG_CERF_LCD_72_A" 5.7
+ fi
+ if [ "$CONFIG_FB_SA1100" = "y" -a "$CONFIG_SA1100_CERF_CPLD" = "y" ]; then
+ bool 'Cerfboard Backlight (CerfPDA)' CONFIG_SA1100_CERF_LCD_BACKLIGHT
+ fi
fi
+ dep_tristate ' CyberPro 2000/2010/5000 support' CONFIG_FB_CYBER2000 $CONFIG_PCI
if [ "$CONFIG_APOLLO" = "y" ]; then
define_bool CONFIG_FB_APOLLO y
fi
@@ -265,7 +280,7 @@
"$CONFIG_FB_MAC" = "y" -o "$CONFIG_FB_RETINAZ3" = "y" -o \
"$CONFIG_FB_VIRGE" = "y" -o "$CONFIG_FB_VIRTUAL" = "y" -o \
"$CONFIG_FB_BWTWO" = "y" -o "$CONFIG_FB_CLGEN" = "y" -o \
- "$CONFIG_FB_TX3912" = "y" ]; then
+ "$CONFIG_FB_TX3912" = "y" -o "$CONFIG_FB_CLPS711X" = "y" ]; then
define_tristate CONFIG_FBCON_MFB y
else
if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_AMIGA" = "m" -o \
@@ -273,19 +288,20 @@
"$CONFIG_FB_MAC" = "m" -o "$CONFIG_FB_RETINAZ3" = "m" -o \
"$CONFIG_FB_VIRGE" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" -o \
"$CONFIG_FB_BWTWO" = "m" -o "$CONFIG_FB_CLGEN" = "m" -o \
- "$CONFIG_FB_TX3912" = "m" ]; then
+ "$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_CLPS711X" = "m" ]; then
define_tristate CONFIG_FBCON_MFB m
fi
fi
if [ "$CONFIG_FB_ACORN" = "y" -o "$CONFIG_FB_MAC" = "y" -o \
"$CONFIG_FB_SA1100" = "y" -o "$CONFIG_FB_VIRTUAL" = "y" -o \
- "$CONFIG_FB_TX3912" = "y" ]; then
+ "$CONFIG_FB_TX3912" = "y" -o "$CONFIG_FB_CLPS711X" = "y" -o \
+ "$CONFIG_FB_DBMX1" = "y" ]; then
define_tristate CONFIG_FBCON_CFB2 y
define_tristate CONFIG_FBCON_CFB4 y
else
if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_MAC" = "m" -o \
"$CONFIG_FB_SA1100" = "m" -o "$CONFIG_FB_VIRTUAL" = "m" -o \
- "$CONFIG_FB_TX3912" = "m" ]; then
+ "$CONFIG_FB_TX3912" = "m" -o "$CONFIG_FB_CLPS711X" = "m" ]; then
define_tristate CONFIG_FBCON_CFB2 m
define_tristate CONFIG_FBCON_CFB4 m
fi
@@ -312,7 +328,8 @@
"$CONFIG_FB_TX3912" = "y" -o \
"$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_NEOMAGIC" = "y" -o \
"$CONFIG_FB_STI" = "y" -o "$CONFIG_FB_HP300" = "y" -o \
- "$CONFIG_FB_INTEL" = "y" ]; then
+ "$CONFIG_FB_INTEL" = "y" -o \
+ "$CONFIG_FB_DBMX1" = "y" ]; then
define_tristate CONFIG_FBCON_CFB8 y
else
if [ "$CONFIG_FB_ACORN" = "m" -o "$CONFIG_FB_ATARI" = "m" -o \
@@ -354,7 +371,9 @@
"$CONFIG_FB_CYBER2000" = "y" -o "$CONFIG_FB_3DFX" = "y" -o \
"$CONFIG_FB_SIS" = "y" -o "$CONFIG_FB_SA1100" = "y" -o \
"$CONFIG_FB_PVR2" = "y" -o "$CONFIG_FB_VOODOO1" = "y" -o \
- "$CONFIG_FB_NEOMAGIC" = "y" -o "$CONFIG_FB_INTEL" = "y" ]; then
+ "$CONFIG_FB_NEOMAGIC" = "y" -o "$CONFIG_FB_INTEL" = "y" -o \
+ "$CONFIG_FB_ANAKIN" = "y" -o \
+ "$CONFIG_FB_DBMX1" = "y" ]; then
define_tristate CONFIG_FBCON_CFB16 y
else
if [ "$CONFIG_FB_ATARI" = "m" -o "$CONFIG_FB_ATY" = "m" -o \
@@ -509,6 +528,9 @@
if [ "$CONFIG_AMIGA" = "y" ]; then
define_bool CONFIG_FONT_PEARL_8x8 y
fi
+ if [ "$CONFIG_ARM" = "y" -a "$CONFIG_ARCH_RISCSTATION" = "y" ]; then
+ define_bool CONFIG_FONT_ACORN_8x8 y
+ fi
if [ "$CONFIG_ARM" = "y" -a "$CONFIG_ARCH_ACORN" = "y" ]; then
define_bool CONFIG_FONT_ACORN_8x8 y
fi
diff -urN linux-2.4.26/drivers/video/Makefile linux-2.4.26-vrs1/drivers/video/Makefile
--- linux-2.4.26/drivers/video/Makefile 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/video/Makefile 2004-02-23 13:36:35.000000000 +0000
@@ -55,6 +55,7 @@
obj-$(CONFIG_FB_PLATINUM) += platinumfb.o
obj-$(CONFIG_FB_VALKYRIE) += valkyriefb.o
obj-$(CONFIG_FB_CT65550) += chipsfb.o
+obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o
obj-$(CONFIG_FB_CYBER) += cyberfb.o
obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o
obj-$(CONFIG_FB_SGIVW) += sgivwfb.o
@@ -68,7 +69,7 @@
obj-$(CONFIG_FB_TRIDENT) += tridentfb.o fbgen.o
obj-$(CONFIG_FB_S3TRIO) += S3triofb.o
obj-$(CONFIG_FB_TGA) += tgafb.o fbgen.o
-obj-$(CONFIG_FB_VESA) += vesafb.o
+obj-$(CONFIG_FB_VESA) += vesafb.o
obj-$(CONFIG_FB_VGA16) += vga16fb.o fbcon-vga-planes.o
obj-$(CONFIG_FB_VIRGE) += virgefb.o
obj-$(CONFIG_FB_G364) += g364fb.o
@@ -126,14 +127,16 @@
obj-$(CONFIG_FB_SUN3) += sun3fb.o
obj-$(CONFIG_FB_BWTWO) += bwtwofb.o
-obj-$(CONFIG_FB_HGA) += hgafb.o
+obj-$(CONFIG_FB_HGA) += hgafb.o
obj-$(CONFIG_FB_SA1100) += sa1100fb.o
-obj-$(CONFIG_FB_VIRTUAL) += vfb.o
+obj-$(CONFIG_FB_DBMX1) += dbmx1fb.o
+obj-$(CONFIG_FB_VIRTUAL) += vfb.o
obj-$(CONFIG_FB_HIT) += hitfb.o fbgen.o
obj-$(CONFIG_FB_E1355) += epson1355fb.o fbgen.o
obj-$(CONFIG_FB_E1356) += epson1356fb.o
obj-$(CONFIG_FB_PVR2) += pvr2fb.o
obj-$(CONFIG_FB_VOODOO1) += sstfb.o
+obj-$(CONFIG_FB_ANAKIN) += anakinfb.o
# Generic Low Level Drivers
@@ -169,4 +172,3 @@
-e 's/dfont\(_uni.*\]\)/promfont\1 __initdata/' > promcon_tbl.c
promcon_tbl.o: promcon_tbl.c $(TOPDIR)/include/linux/types.h
-
diff -urN linux-2.4.26/drivers/video/acornfb.c linux-2.4.26-vrs1/drivers/video/acornfb.c
--- linux-2.4.26/drivers/video/acornfb.c 2002-08-03 01:39:45.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/acornfb.c 2004-01-14 21:32:26.000000000 +0000
@@ -752,11 +752,12 @@
}
#endif
#ifdef FBCON_HAS_CFB16
- if (bpp == 16 && regno < 16) {
+ if (bpp == 16) {
int i;
- current_par.cmap.cfb16[regno] =
- regno | regno << 5 | regno << 10;
+ if (regno < 16)
+ current_par.cmap.cfb16[regno] =
+ regno | regno << 5 | regno << 10;
pal.p = 0;
vidc_writel(0x10000000);
@@ -1215,7 +1216,7 @@
p.vidc20.green = current_par.palette[(i >> 1) & 31].vidc20.green;
p.vidc20.blue = current_par.palette[(i >> 2) & 31].vidc20.blue;
}
- acornfb_palette_write(i, current_par.palette[i]);
+ acornfb_palette_write(i, p);
}
} else
#endif
diff -urN linux-2.4.26/drivers/video/anakinfb.c linux-2.4.26-vrs1/drivers/video/anakinfb.c
--- linux-2.4.26/drivers/video/anakinfb.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/anakinfb.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,221 @@
+/*
+ * linux/drivers/video/anakinfb.c
+ *
+ * Copyright (C) 2001 Aleph One Ltd. for Acunia N.V.
+ *
+ * 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.
+ *
+ * Changelog:
+ * 23-Apr-2001 TTC Created
+ */
+
+#include <linux/types.h>
+#include <linux/fb.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/module.h>
+
+#include <asm/io.h>
+
+#include <video/fbcon.h>
+#include <video/fbcon-cfb16.h>
+
+static u16 colreg[16];
+static int currcon = 0;
+static struct fb_info fb_info;
+static struct display display;
+
+static int
+anakinfb_getcolreg(u_int regno, u_int *red, u_int *green, u_int *blue,
+ u_int *transp, struct fb_info *info)
+{
+ if (regno > 15)
+ return 1;
+
+ *red = colreg[regno] & 0xf800;
+ *green = colreg[regno] & 0x7e0 << 5;
+ *blue = colreg[regno] & 0x1f << 11;
+ *transp = 0;
+ return 0;
+}
+
+static int
+anakinfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
+ u_int transp, struct fb_info *info)
+{
+ if (regno > 15)
+ return 1;
+
+ colreg[regno] = (red & 0xf800) | (green & 0xfc00 >> 5) |
+ (blue & 0xf800 >> 11);
+ return 0;
+}
+
+static int
+anakinfb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
+{
+ memset(fix, 0, sizeof(struct fb_fix_screeninfo));
+ strcpy(fix->id, "AnakinFB");
+ fix->smem_start = VGA_START;
+ fix->smem_len = VGA_SIZE;
+ fix->type = FB_TYPE_PACKED_PIXELS;
+ fix->type_aux = 0;
+ fix->visual = FB_VISUAL_TRUECOLOR;
+ fix->xpanstep = 0;
+ fix->ypanstep = 0;
+ fix->ywrapstep = 0;
+ fix->line_length = 400 * 2;
+ fix->accel = FB_ACCEL_NONE;
+ return 0;
+}
+
+static int
+anakinfb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
+{
+ memset(var, 0, sizeof(struct fb_var_screeninfo));
+ var->xres = 400;
+ var->yres = 234;
+ var->xres_virtual = 400;
+ var->yres_virtual = 234;
+ var->xoffset = 0;
+ var->yoffset = 0;
+ var->bits_per_pixel = 16;
+ var->grayscale = 0;
+ var->red.offset = 11;
+ var->red.length = 5;
+ var->green.offset = 5;
+ var->green.length = 6;
+ var->blue.offset = 0;
+ var->blue.length = 5;
+ var->transp.offset = 0;
+ var->transp.length = 0;
+ var->nonstd = 0;
+ var->activate = FB_ACTIVATE_NOW;
+ var->height = -1;
+ var->width = -1;
+ var->pixclock = 0;
+ var->left_margin = 0;
+ var->right_margin = 0;
+ var->upper_margin = 0;
+ var->lower_margin = 0;
+ var->hsync_len = 0;
+ var->vsync_len = 0;
+ var->sync = 0;
+ var->vmode = FB_VMODE_NONINTERLACED;
+ return 0;
+}
+
+static int
+anakinfb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
+{
+ return -EINVAL;
+}
+
+static int
+anakinfb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
+ struct fb_info *info)
+{
+ if (con == currcon)
+ return fb_get_cmap(cmap, kspc, anakinfb_getcolreg, info);
+ else if (fb_display[con].cmap.len)
+ fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
+ else
+ fb_copy_cmap(fb_default_cmap(16), cmap, kspc ? 0 : 2);
+ return 0;
+}
+
+static int
+anakinfb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
+ struct fb_info *info)
+{
+ int err;
+
+ if (!fb_display[con].cmap.len) {
+ if ((err = fb_alloc_cmap(&fb_display[con].cmap, 16, 0)))
+ return err;
+ }
+ if (con == currcon)
+ return fb_set_cmap(cmap, kspc, anakinfb_setcolreg, info);
+ else
+ fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);
+ return 0;
+}
+
+static int
+anakinfb_switch_con(int con, struct fb_info *info)
+{
+ currcon = con;
+ return 0;
+
+}
+
+static int
+anakinfb_updatevar(int con, struct fb_info *info)
+{
+ return 0;
+}
+
+static void
+anakinfb_blank(int blank, struct fb_info *info)
+{
+ /*
+ * TODO: use I2C to blank/unblank the screen
+ */
+}
+
+static struct fb_ops anakinfb_ops = {
+ owner: THIS_MODULE,
+ fb_get_fix: anakinfb_get_fix,
+ fb_get_var: anakinfb_get_var,
+ fb_set_var: anakinfb_set_var,
+ fb_get_cmap: anakinfb_get_cmap,
+ fb_set_cmap: anakinfb_set_cmap,
+};
+
+int __init
+anakinfb_init(void)
+{
+ memset(&fb_info, 0, sizeof(struct fb_info));
+ strcpy(fb_info.modename, "AnakinFB");
+ fb_info.node = -1;
+ fb_info.flags = FBINFO_FLAG_DEFAULT;
+ fb_info.fbops = &anakinfb_ops;
+ fb_info.disp = &display;
+ strcpy(fb_info.fontname, "VGA8x16");
+ fb_info.changevar = NULL;
+ fb_info.switch_con = &anakinfb_switch_con;
+ fb_info.updatevar = &anakinfb_updatevar;
+ fb_info.blank = &anakinfb_blank;
+
+ memset(&display, 0, sizeof(struct display));
+ anakinfb_get_var(&display.var, 0, &fb_info);
+ display.screen_base = ioremap(VGA_START, VGA_SIZE);
+ display.visual = FB_VISUAL_TRUECOLOR;
+ display.type = FB_TYPE_PACKED_PIXELS;
+ display.type_aux = 0;
+ display.ypanstep = 0;
+ display.ywrapstep = 0;
+ display.line_length = 400 * 2;
+ display.can_soft_blank = 1;
+ display.inverse = 0;
+
+#ifdef FBCON_HAS_CFB16
+ display.dispsw = &fbcon_cfb16;
+ display.dispsw_data = colreg;
+#else
+ display.dispsw = &fbcon_dummy;
+#endif
+
+ if (register_framebuffer(&fb_info) < 0)
+ return -EINVAL;
+
+ MOD_INC_USE_COUNT;
+ return 0;
+}
+
+MODULE_AUTHOR("Tak-Shing Chan <chan@aleph1.co.uk>");
+MODULE_DESCRIPTION("Anakin framebuffer driver");
+MODULE_SUPPORTED_DEVICE("fb");
diff -urN linux-2.4.26/drivers/video/clps711xfb.c linux-2.4.26-vrs1/drivers/video/clps711xfb.c
--- linux-2.4.26/drivers/video/clps711xfb.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/clps711xfb.c 2004-01-14 21:32:26.000000000 +0000
@@ -0,0 +1,677 @@
+/*
+ * linux/drivers/video/clps711xfb.c
+ *
+ * Copyright (C) 2000-2001 Deep Blue Solutions Ltd.
+ *
+ * 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
+ *
+ * Framebuffer driver for the CLPS7111 and EP7212 processors.
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/fb.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/delay.h>
+
+#include <video/fbcon.h>
+#include <video/fbcon-cfb4.h>
+#include <video/fbcon-cfb2.h>
+#include <video/fbcon-mfb.h>
+
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/uaccess.h>
+
+#include <asm/hardware/clps7111.h>
+#include <asm/arch/syspld.h>
+
+static struct clps7111fb_info {
+ struct fb_info fb;
+ int currcon;
+} *cfb;
+
+#define CMAP_MAX_SIZE 16
+
+/* The /proc entry for the backlight. */
+static struct proc_dir_entry *clps7111fb_backlight_proc_entry = NULL;
+
+static int clps7111fb_proc_backlight_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+static int clps7111fb_proc_backlight_write(struct file *file,
+ const char *buffer, unsigned long count, void *data);
+
+/*
+ * LCD AC Prescale. This comes from the LCD panel manufacturers specifications.
+ * This determines how many clocks + 1 of CL1 before the M signal toggles.
+ * The number of lines on the display must not be divisible by this number.
+ */
+static unsigned int lcd_ac_prescale = 13;
+
+/*
+ * Set a single color register. Return != 0 for invalid regno.
+ */
+static int
+clps7111fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
+ u_int transp, struct fb_info *info)
+{
+ unsigned int level, mask, shift, pal;
+
+ if (regno >= (1 << info->var.bits_per_pixel))
+ return 1;
+
+ /* gray = 0.30*R + 0.58*G + 0.11*B */
+ level = (red * 77 + green * 151 + blue * 28) >> 20;
+
+ /*
+ * On an LCD, a high value is dark, while a low value is light.
+ * So we invert the level.
+ *
+ * This isn't true on all machines, so we only do it on EDB7211.
+ * --rmk
+ */
+ if (machine_is_edb7211() || machine_is_guidea07()) {
+ level = 15 - level;
+ }
+
+ shift = 4 * (regno & 7);
+ level <<= shift;
+ mask = 15 << shift;
+ level &= mask;
+
+ regno = regno < 8 ? PALLSW : PALMSW;
+
+ pal = clps_readl(regno);
+ pal = (pal & ~mask) | level;
+ clps_writel(pal, regno);
+
+ return 0;
+}
+
+/*
+ * Set the colormap
+ */
+static int
+clps7111fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
+ struct fb_info *info)
+{
+ struct clps7111fb_info *cfb = (struct clps7111fb_info *)info;
+ struct fb_cmap *dcmap = &fb_display[con].cmap;
+ int err = 0;
+
+ /* no colormap allocated? */
+ if (!dcmap->len)
+ err = fb_alloc_cmap(dcmap, CMAP_MAX_SIZE, 0);
+
+ if (!err && con == cfb->currcon) {
+ err = fb_set_cmap(cmap, kspc, clps7111fb_setcolreg, &cfb->fb);
+ dcmap = &cfb->fb.cmap;
+ }
+
+ if (!err)
+ fb_copy_cmap(cmap, dcmap, kspc ? 0 : 1);
+
+ return err;
+}
+
+/*
+ * Set the User Defined Part of the Display
+ */
+static int
+clps7111fb_set_var(struct fb_var_screeninfo *var, int con,
+ struct fb_info *info)
+{
+ struct display *display;
+ unsigned int lcdcon, syscon, pixclock;
+ int chgvar = 0;
+
+ if (var->activate & FB_ACTIVATE_TEST)
+ return 0;
+
+ if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW)
+ return -EINVAL;
+
+ if (cfb->fb.var.xres != var->xres)
+ chgvar = 1;
+ if (cfb->fb.var.yres != var->yres)
+ chgvar = 1;
+ if (cfb->fb.var.xres_virtual != var->xres_virtual)
+ chgvar = 1;
+ if (cfb->fb.var.yres_virtual != var->yres_virtual)
+ chgvar = 1;
+ if (cfb->fb.var.bits_per_pixel != var->bits_per_pixel)
+ chgvar = 1;
+
+ if (con < 0) {
+ display = cfb->fb.disp;
+ chgvar = 0;
+ } else {
+ display = fb_display + con;
+ }
+
+ var->transp.msb_right = 0;
+ var->transp.offset = 0;
+ var->transp.length = 0;
+ var->red.msb_right = 0;
+ var->red.offset = 0;
+ var->red.length = var->bits_per_pixel;
+ var->green = var->red;
+ var->blue = var->red;
+
+ switch (var->bits_per_pixel) {
+#ifdef FBCON_HAS_MFB
+ case 1:
+ cfb->fb.fix.visual = FB_VISUAL_MONO01;
+ display->dispsw = &fbcon_mfb;
+ display->dispsw_data = NULL;
+ break;
+#endif
+#ifdef FBCON_HAS_CFB2
+ case 2:
+ cfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ display->dispsw = &fbcon_cfb2;
+ display->dispsw_data = NULL;
+ break;
+#endif
+#ifdef FBCON_HAS_CFB4
+ case 4:
+ cfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ display->dispsw = &fbcon_cfb4;
+ display->dispsw_data = NULL;
+ break;
+#endif
+ default:
+ return -EINVAL;
+ }
+
+ display->next_line = var->xres_virtual * var->bits_per_pixel / 8;
+
+ cfb->fb.fix.line_length = display->next_line;
+
+ display->screen_base = cfb->fb.screen_base;
+ display->line_length = cfb->fb.fix.line_length;
+ display->visual = cfb->fb.fix.visual;
+ display->type = cfb->fb.fix.type;
+ display->type_aux = cfb->fb.fix.type_aux;
+ display->ypanstep = cfb->fb.fix.ypanstep;
+ display->ywrapstep = cfb->fb.fix.ywrapstep;
+ display->can_soft_blank = 1;
+ display->inverse = 0;
+
+ cfb->fb.var = *var;
+ cfb->fb.var.activate &= ~FB_ACTIVATE_ALL;
+
+ /*
+ * Update the old var. The fbcon drivers still use this.
+ * Once they are using cfb->fb.var, this can be dropped.
+ * --rmk
+ */
+ display->var = cfb->fb.var;
+
+ /*
+ * If we are setting all the virtual consoles, also set the
+ * defaults used to create new consoles.
+ */
+ if (var->activate & FB_ACTIVATE_ALL)
+ cfb->fb.disp->var = cfb->fb.var;
+
+ if (chgvar && info && cfb->fb.changevar)
+ cfb->fb.changevar(con);
+
+ lcdcon = (var->xres_virtual * var->yres_virtual * var->bits_per_pixel) / 128 - 1;
+ lcdcon |= ((var->xres_virtual / 16) - 1) << 13;
+ lcdcon |= lcd_ac_prescale << 25;
+
+ /*
+ * Calculate pixel prescale value from the pixclock. This is:
+ * 36.864MHz / pixclock_mhz - 1.
+ * However, pixclock is in picoseconds, so this ends up being:
+ * 36864000 * pixclock_ps / 10^12 - 1
+ * and this will overflow the 32-bit math. We perform this as
+ * (9 * 4096000 == 36864000):
+ * pixclock_ps * 9 * (4096000 / 10^12) - 1
+ */
+ pixclock = 9 * info->var.pixclock / 244140 - 1;
+ lcdcon |= pixclock << 19;
+
+ if (info->var.bits_per_pixel == 4)
+ lcdcon |= LCDCON_GSMD;
+ if (info->var.bits_per_pixel >= 2)
+ lcdcon |= LCDCON_GSEN;
+
+ /*
+ * LCDCON must only be changed while the LCD is disabled
+ */
+ syscon = clps_readl(SYSCON1);
+ clps_writel(syscon & ~SYSCON1_LCDEN, SYSCON1);
+ clps_writel(lcdcon, LCDCON);
+ clps_writel(syscon | SYSCON1_LCDEN, SYSCON1);
+
+ fb_set_cmap(&cfb->fb.cmap, 1, clps7111fb_setcolreg, &cfb->fb);
+
+ return 0;
+}
+
+/*
+ * Get the currently displayed virtual consoles colormap.
+ */
+static int
+gen_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info)
+{
+ fb_copy_cmap(&info->cmap, cmap, kspc ? 0 : 2);
+ return 0;
+}
+
+/*
+ * Get the currently displayed virtual consoles fixed part of the display.
+ */
+static int
+gen_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
+{
+ *fix = info->fix;
+ return 0;
+}
+
+/*
+ * Get the current user defined part of the display.
+ */
+static int
+gen_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
+{
+ *var = info->var;
+ return 0;
+}
+
+static struct fb_ops clps7111fb_ops = {
+ owner: THIS_MODULE,
+ fb_set_var: clps7111fb_set_var,
+ fb_set_cmap: clps7111fb_set_cmap,
+ fb_get_fix: gen_get_fix,
+ fb_get_var: gen_get_var,
+ fb_get_cmap: gen_get_cmap,
+};
+
+static int clps7111fb_switch(int con, struct fb_info *info)
+{
+ struct clps7111fb_info *cfb = (struct clps7111fb_info *)info;
+ struct display *disp;
+ struct fb_cmap *cmap;
+
+ if (cfb->currcon >= 0) {
+ disp = fb_display + cfb->currcon;
+
+ /*
+ * Save the old colormap and video mode.
+ */
+ disp->var = cfb->fb.var;
+ if (disp->cmap.len)
+ fb_copy_cmap(&cfb->fb.cmap, &disp->cmap, 0);
+ }
+
+ cfb->currcon = con;
+ disp = fb_display + con;
+
+ /*
+ * Install the new colormap and change the video mode. By default,
+ * fbcon sets all the colormaps and video modes to the default
+ * values at bootup.
+ */
+ if (disp->cmap.len)
+ cmap = &disp->cmap;
+ else
+ cmap = fb_default_cmap(CMAP_MAX_SIZE);
+
+ fb_copy_cmap(cmap, &cfb->fb.cmap, 0);
+
+ cfb->fb.var = disp->var;
+ cfb->fb.var.activate = FB_ACTIVATE_NOW;
+
+ clps7111fb_set_var(&cfb->fb.var, con, &cfb->fb);
+
+ return 0;
+}
+
+static int clps7111fb_updatevar(int con, struct fb_info *info)
+{
+ return -EINVAL;
+}
+
+static void clps7111fb_blank(int blank, struct fb_info *info)
+{
+ if (blank) {
+ if (machine_is_edb7211()) {
+ /* Turn off the LCD backlight. */
+ clps_writeb(clps_readb(PDDR) & ~EDB_PD3_LCDBL, PDDR);
+
+ /* Power off the LCD DC-DC converter. */
+ clps_writeb(clps_readb(PDDR) & ~EDB_PD1_LCD_DC_DC_EN, PDDR);
+
+ /* Delay for a little while (half a second). */
+ udelay(100);
+
+ /* Power off the LCD panel. */
+ clps_writeb(clps_readb(PDDR) & ~EDB_PD2_LCDEN, PDDR);
+
+ /* Power off the LCD controller. */
+ clps_writel(clps_readl(SYSCON1) & ~SYSCON1_LCDEN,
+ SYSCON1);
+ }
+ } else {
+ if (machine_is_edb7211()) {
+ /* Power up the LCD controller. */
+ clps_writel(clps_readl(SYSCON1) | SYSCON1_LCDEN,
+ SYSCON1);
+
+ /* Power up the LCD panel. */
+ clps_writeb(clps_readb(PDDR) | EDB_PD2_LCDEN, PDDR);
+
+ /* Delay for a little while. */
+ udelay(100);
+
+ /* Power up the LCD DC-DC converter. */
+ clps_writeb(clps_readb(PDDR) | EDB_PD1_LCD_DC_DC_EN,
+ PDDR);
+
+ /* Turn on the LCD backlight. */
+ clps_writeb(clps_readb(PDDR) | EDB_PD3_LCDBL, PDDR);
+ }
+ }
+}
+
+static int
+clps7111fb_proc_backlight_read(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ /* We need at least two characters, one for the digit, and one for
+ * the terminating NULL. */
+ if (count < 2)
+ return -EINVAL;
+
+ if (machine_is_edb7211()) {
+ return sprintf(page, "%d\n",
+ (clps_readb(PDDR) & EDB_PD3_LCDBL) ? 1 : 0);
+ }
+
+ return 0;
+}
+
+static int
+clps7111fb_proc_backlight_write(struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ unsigned char char_value;
+ int value;
+
+ if (count < 1) {
+ return -EINVAL;
+ }
+
+ if (copy_from_user(&char_value, buffer, 1))
+ return -EFAULT;
+
+ value = char_value - '0';
+
+ if (machine_is_edb7211()) {
+ unsigned char port_d;
+
+ port_d = clps_readb(PDDR);
+
+ if (value) {
+ port_d |= EDB_PD3_LCDBL;
+ } else {
+ port_d &= ~EDB_PD3_LCDBL;
+ }
+
+ clps_writeb(port_d, PDDR);
+ }
+
+ return count;
+}
+
+static void __init clps711x_guess_lcd_params(struct fb_info *info)
+{
+ unsigned int lcdcon, syscon, size;
+ unsigned long phys_base = PHYS_OFFSET;
+ void *virt_base = (void *)PAGE_OFFSET;
+
+ info->var.xres_virtual = 640;
+ info->var.yres_virtual = 240;
+ info->var.bits_per_pixel = 4;
+ info->var.activate = FB_ACTIVATE_NOW;
+ info->var.height = -1;
+ info->var.width = -1;
+ info->var.pixclock = 93006; /* 10.752MHz pixel clock */
+
+ /*
+ * If the LCD controller is already running, decode the values
+ * in LCDCON to xres/yres/bpp/pixclock/acprescale
+ */
+ syscon = clps_readl(SYSCON1);
+ if (syscon & SYSCON1_LCDEN) {
+ lcdcon = clps_readl(LCDCON);
+
+ /*
+ * Decode GSMD and GSEN bits to bits per pixel
+ * (in cs89712 docs, GSEN is GSMD1, GSMD is GSMD2)
+ */
+ switch (lcdcon & (LCDCON_GSMD | LCDCON_GSEN)) {
+ case LCDCON_GSMD | LCDCON_GSEN:
+ info->var.bits_per_pixel = 4;
+ break;
+
+ case LCDCON_GSEN:
+ info->var.bits_per_pixel = 2;
+ break;
+
+ default:
+ info->var.bits_per_pixel = 1;
+ break;
+ }
+
+ /*
+ * Decode xres/yres
+ */
+ info->var.xres_virtual = (((lcdcon >> 13) & 0x3f) + 1) * 16;
+ info->var.yres_virtual = (((lcdcon & 0x1fff) + 1) * 128) /
+ (info->var.xres_virtual *
+ info->var.bits_per_pixel);
+
+ /*
+ * Calculate pixclock
+ */
+ info->var.pixclock = (((lcdcon >> 19) & 0x3f) + 1) * 244140 / 9;
+
+ /*
+ * Grab AC prescale
+ */
+ lcd_ac_prescale = (lcdcon >> 25) & 0x1f;
+ }
+
+ info->var.xres = info->var.xres_virtual;
+ info->var.yres = info->var.yres_virtual;
+ info->var.grayscale = info->var.bits_per_pixel > 1;
+
+ size = info->var.xres * info->var.yres * info->var.bits_per_pixel / 8;
+
+ /*
+ * Might be worth checking to see if we can use the on-board
+ * RAM if size here...
+ * CLPS7110 - no on-board SRAM
+ * EP7212 - 38400 bytes
+ */
+ if (size <= 38400) {
+ printk(KERN_INFO "CLPS711xFB: could use on-board SRAM?\n");
+ }
+
+ if ((syscon & SYSCON1_LCDEN) == 0) {
+ /*
+ * The display isn't running. Ensure that
+ * the display memory is empty.
+ */
+ memset(virt_base, 0, size);
+ }
+
+ info->screen_base = virt_base;
+ info->fix.smem_start = phys_base;
+ info->fix.smem_len = PAGE_ALIGN(size);
+ info->fix.type = FB_TYPE_PACKED_PIXELS;
+}
+
+/* this function initializes the LCD registers as required by the Guide A07
+*/
+int __init clps711xfb_guidea07_init(void)
+{
+ unsigned long videomem, videosize;
+ unsigned int lcdcon, syscon;
+
+ //LCDCON must only be changed while the LCD is disabled
+ syscon = clps_readl(SYSCON1);
+ clps_writel(syscon & ~SYSCON1_LCDEN, SYSCON1);
+
+ printk(KERN_INFO "CLPS711xFB: setting up cs89712 SRAM as QVGA video framebuffer\n");
+ clps_writel(0x6, FBADDR); //internal SRAM location
+ videomem = (unsigned long)ioremap(SRAM_START, SRAM_SIZE);
+ if (!videomem) {
+ printk("ioremap failed!\n");
+ kfree(cfb);
+ return -EIO;
+ }
+
+ videosize = (320*240 * 4 / 8); //ie. 38400 or 0x9600
+ memset((void *)videomem, 0, videosize); //clear the vid memory
+
+ cfb->fb.screen_base = (void *)videomem;
+ cfb->fb.fix.smem_start = SRAM_START; //must be physical address
+ cfb->fb.fix.smem_len = videosize;
+
+ cfb->fb.var.grayscale = 1;
+ cfb->fb.var.bits_per_pixel = 4;
+ cfb->fb.var.xres_virtual = 320;
+ cfb->fb.var.activate = FB_ACTIVATE_NOW;
+
+ // change to 4bpp mode
+ lcdcon = clps_readl(LCDCON);
+ lcdcon |= LCDCON_GSMD | LCDCON_GSEN; //4bpp
+ //lcdcon |= 5 << 19; //pixel prescale value (pixclock)
+ //lcdcon |= 13 << 25; //AC prescale value
+ clps_writel(lcdcon, LCDCON);
+
+ //reenable LCD
+ clps_writel(syscon | SYSCON1_LCDEN, SYSCON1);
+
+ return 0;
+}
+
+int __init clps711xfb_init(void)
+{
+ int err = -ENOMEM;
+
+ cfb = kmalloc(sizeof(*cfb) + sizeof(struct display), GFP_KERNEL);
+ if (!cfb)
+ goto out;
+
+ memset(cfb, 0, sizeof(*cfb) + sizeof(struct display));
+ strcpy(cfb->fb.fix.id, "clps7111");
+
+ cfb->currcon = -1;
+ cfb->fb.screen_base = (void *)PAGE_OFFSET;
+ cfb->fb.fix.smem_start = PAGE_OFFSET;
+ cfb->fb.fix.smem_len = 0x14000;
+ cfb->fb.fix.type = FB_TYPE_PACKED_PIXELS;
+
+ cfb->fb.fbops = &clps7111fb_ops;
+ cfb->fb.changevar = NULL;
+ cfb->fb.switch_con = clps7111fb_switch;
+ cfb->fb.updatevar = clps7111fb_updatevar;
+ cfb->fb.blank = clps7111fb_blank;
+ cfb->fb.flags = FBINFO_FLAG_DEFAULT;
+ cfb->fb.disp = (struct display *)(cfb + 1);
+
+ clps711x_guess_lcd_params(&cfb->fb);
+
+ if (machine_is_guidea07()) {
+ clps711xfb_guidea07_init();
+ }
+
+ if (machine_is_fortunet()) {
+ cfb->fb.fix.smem_len = 0x20000;
+ }
+
+ fb_alloc_cmap(&cfb->fb.cmap, CMAP_MAX_SIZE, 0);
+
+ /* Register the /proc entries. */
+ clps7111fb_backlight_proc_entry = create_proc_entry("backlight", 0444,
+ &proc_root);
+ if (clps7111fb_backlight_proc_entry == NULL) {
+ printk("Couldn't create the /proc entry for the backlight.\n");
+ return -EINVAL;
+ }
+
+ clps7111fb_backlight_proc_entry->read_proc =
+ &clps7111fb_proc_backlight_read;
+ clps7111fb_backlight_proc_entry->write_proc =
+ &clps7111fb_proc_backlight_write;
+
+ /*
+ * Power up the LCD
+ */
+ if (machine_is_p720t()) {
+ PLD_LCDEN = PLD_LCDEN_EN;
+ PLD_PWR |= (PLD_S4_ON|PLD_S3_ON|PLD_S2_ON|PLD_S1_ON);
+ }
+
+ if (machine_is_edb7211()) {
+ /* Power up the LCD panel. */
+ clps_writeb(clps_readb(PDDR) | EDB_PD2_LCDEN, PDDR);
+
+ /* Delay for a little while. */
+ udelay(100);
+
+ /* Power up the LCD DC-DC converter. */
+ clps_writeb(clps_readb(PDDR) | EDB_PD1_LCD_DC_DC_EN, PDDR);
+
+ /* Turn on the LCD backlight. */
+ clps_writeb(clps_readb(PDDR) | EDB_PD3_LCDBL, PDDR);
+ }
+
+ clps7111fb_set_var(&cfb->fb.var, -1, &cfb->fb);
+ err = register_framebuffer(&cfb->fb);
+
+out: return err;
+}
+
+static void __exit clps711xfb_exit(void)
+{
+ unregister_framebuffer(&cfb->fb);
+ kfree(cfb);
+
+ /*
+ * Power down the LCD
+ */
+ if (machine_is_p720t()) {
+ PLD_LCDEN = 0;
+ PLD_PWR &= ~(PLD_S4_ON|PLD_S3_ON|PLD_S2_ON|PLD_S1_ON);
+ }
+}
+
+#ifdef MODULE
+module_init(clps711xfb_init);
+#endif
+module_exit(clps711xfb_exit);
+
+MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
+MODULE_DESCRIPTION("CLPS711x framebuffer driver");
+MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/video/cyber2000fb.c linux-2.4.26-vrs1/drivers/video/cyber2000fb.c
--- linux-2.4.26/drivers/video/cyber2000fb.c 2002-08-03 01:39:45.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/cyber2000fb.c 2004-01-14 21:32:27.000000000 +0000
@@ -1,7 +1,7 @@
/*
* linux/drivers/video/cyber2000fb.c
*
- * Copyright (C) 1998-2000 Russell King
+ * Copyright (C) 1998-2002 Russell King
*
* MIPS and 50xx clock support
* Copyright (C) 2001 Bradley D. LaRonde <brad@ltc.com>
@@ -13,22 +13,28 @@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
- * Intergraphics CyberPro 2000, 2010 and 5000 frame buffer device
+ * Integraphics CyberPro 2000, 2010 and 5000 frame buffer device
*
* Based on cyberfb.c.
*
- * Note that we now use the new fbcon fix, var and cmap scheme. We do still
- * have to check which console is the currently displayed one however, since
- * especially for the colourmap stuff. Once fbcon has been fully migrated,
- * we can kill the last 5 references to cfb->currcon.
+ * Note that we now use the new fbcon fix, var and cmap scheme. We do
+ * still have to check which console is the currently displayed one
+ * however, especially for the colourmap stuff.
*
- * We also use the new hotplug PCI subsystem. I'm not sure if there are any
- * such cards, but I'm erring on the side of caution. We don't want to go
- * pop just because someone does have one.
+ * We also use the new hotplug PCI subsystem. I'm not sure if there
+ * are any such cards, but I'm erring on the side of caution. We don't
+ * want to go pop just because someone does have one.
*
- * Note that this doesn't work fully in the case of multiple CyberPro cards
- * with grabbers. We currently can only attach to the first CyberPro card
- * found.
+ * Note that this doesn't work fully in the case of multiple CyberPro
+ * cards with grabbers. We currently can only attach to the first
+ * CyberPro card found.
+ *
+ * When we're in truecolour mode, we power down the LUT RAM as a power
+ * saving feature. Also, when we enter any of the powersaving modes
+ * (except soft blanking) we power down the RAMDACs. This saves about
+ * 1W, which is roughly 8% of the power consumption of a NetWinder
+ * (which, incidentally, is about the same saving as a 2.5in hard disk
+ * entering standby mode.)
*/
#include <linux/config.h>
#include <linux/module.h>
@@ -55,20 +61,16 @@
#include <video/fbcon-cfb24.h>
#include <video/fbcon-cfb32.h>
-/*
- * Define this if you don't want RGB565, but RGB555 for 16bpp displays.
- */
-/*#define CFB16_IS_CFB15*/
-
#include "cyber2000fb.h"
struct cfb_info {
struct fb_info fb;
struct display_switch *dispsw;
+ struct display *display;
struct pci_dev *dev;
unsigned char *region;
unsigned char *regs;
- signed int currcon;
+ u_int id;
int func_use_count;
u_long ref_ps;
@@ -81,10 +83,16 @@
u8 red, green, blue;
} palette[NR_PALETTE];
+ u_char mem_ctl0;
u_char mem_ctl1;
u_char mem_ctl2;
u_char mclk_mult;
u_char mclk_div;
+ /*
+ * RAMDAC control register is both of these or'ed together
+ */
+ u_char ramdac_ctrl;
+ u_char ramdac_powerdown;
};
static char default_font_storage[40];
@@ -144,7 +152,7 @@
{
int count = 100000;
- while (cyber2000fb_readb(CO_REG_CONTROL, cfb) & 0x80) {
+ while (cyber2000fb_readb(CO_REG_CONTROL, cfb) & CO_CTRL_BUSY) {
if (!count--) {
debug_printf("accel_wait timed out\n");
cyber2000fb_writeb(0, CO_REG_CONTROL, cfb);
@@ -154,24 +162,23 @@
}
}
-static void cyber2000_accel_setup(struct display *p)
+static void cyber2000_accel_setup(struct display *display)
{
- struct cfb_info *cfb = (struct cfb_info *)p->fb_info;
+ struct cfb_info *cfb = (struct cfb_info *)display->fb_info;
- cfb->dispsw->setup(p);
+ cfb->dispsw->setup(display);
}
static void
-cyber2000_accel_bmove(struct display *p, int sy, int sx, int dy, int dx,
+cyber2000_accel_bmove(struct display *display, int sy, int sx, int dy, int dx,
int height, int width)
{
- struct cfb_info *cfb = (struct cfb_info *)p->fb_info;
- struct fb_var_screeninfo *var = &p->fb_info->var;
+ struct cfb_info *cfb = (struct cfb_info *)display->fb_info;
+ struct fb_var_screeninfo *var = &display->var;
u_long src, dst;
- u_int fh, fw;
- int cmd = CO_CMD_L_PATTERN_FGCOL;
+ u_int fh, fw, cmd = CO_CMD_L_PATTERN_FGCOL;
- fw = fontwidth(p);
+ fw = fontwidth(display);
sx *= fw;
dx *= fw;
width *= fw;
@@ -183,7 +190,7 @@
cmd |= CO_CMD_L_INC_LEFT;
}
- fh = fontheight(p);
+ fh = fontheight(display);
sy *= fh;
dy *= fh;
height *= fh;
@@ -199,227 +206,265 @@
dst = dx + dy * var->xres_virtual;
cyber2000_accel_wait(cfb);
- cyber2000fb_writeb(0x00, CO_REG_CONTROL, cfb);
- cyber2000fb_writeb(0x03, CO_REG_FORE_MIX, cfb);
- cyber2000fb_writew(width, CO_REG_WIDTH, cfb);
-
- if (var->bits_per_pixel != 24) {
- cyber2000fb_writel(dst, CO_REG_DEST_PTR, cfb);
- cyber2000fb_writel(src, CO_REG_SRC_PTR, cfb);
- } else {
- cyber2000fb_writel(dst * 3, CO_REG_DEST_PTR, cfb);
- cyber2000fb_writeb(dst, CO_REG_X_PHASE, cfb);
- cyber2000fb_writel(src * 3, CO_REG_SRC_PTR, cfb);
+ cyber2000fb_writeb(0x00, CO_REG_CONTROL, cfb);
+ cyber2000fb_writew(width, CO_REG_PIXWIDTH, cfb);
+ cyber2000fb_writew(height, CO_REG_PIXHEIGHT, cfb);
+
+ if (var->bits_per_pixel == 24) {
+ cyber2000fb_writeb(dst, CO_REG_X_PHASE, cfb);
+ dst *= 3;
+ src *= 3;
}
- cyber2000fb_writew(height, CO_REG_HEIGHT, cfb);
- cyber2000fb_writew(cmd, CO_REG_CMD_L, cfb);
- cyber2000fb_writew(0x2800, CO_REG_CMD_H, cfb);
+ cyber2000fb_writel(src, CO_REG_SRC1_PTR, cfb);
+ cyber2000fb_writel(dst, CO_REG_DEST_PTR, cfb);
+ cyber2000fb_writeb(CO_FG_MIX_SRC, CO_REG_FGMIX, cfb);
+ cyber2000fb_writew(cmd, CO_REG_CMD_L, cfb);
+ cyber2000fb_writew(CO_CMD_H_FGSRCMAP|CO_CMD_H_BLITTER, CO_REG_CMD_H, cfb);
}
static void
-cyber2000_accel_clear(struct vc_data *conp, struct display *p, int sy, int sx,
- int height, int width)
+cyber2000_accel_clear(struct vc_data *conp, struct display *display, int sy,
+ int sx, int height, int width)
{
- struct cfb_info *cfb = (struct cfb_info *)p->fb_info;
- struct fb_var_screeninfo *var = &p->fb_info->var;
+ struct cfb_info *cfb = (struct cfb_info *)display->fb_info;
+ struct fb_var_screeninfo *var = &display->var;
u_long dst;
u_int fw, fh;
- u32 bgx = attr_bgcol_ec(p, conp);
+ u32 bgx = attr_bgcol_ec(display, conp);
- fw = fontwidth(p);
- fh = fontheight(p);
+ fw = fontwidth(display);
+ fh = fontheight(display);
dst = sx * fw + sy * var->xres_virtual * fh;
width = width * fw - 1;
height = height * fh - 1;
cyber2000_accel_wait(cfb);
- cyber2000fb_writeb(0x00, CO_REG_CONTROL, cfb);
- cyber2000fb_writeb(0x03, CO_REG_FORE_MIX, cfb);
- cyber2000fb_writew(width, CO_REG_WIDTH, cfb);
- cyber2000fb_writew(height, CO_REG_HEIGHT, cfb);
+ cyber2000fb_writeb(0x00, CO_REG_CONTROL, cfb);
+ cyber2000fb_writew(width, CO_REG_PIXWIDTH, cfb);
+ cyber2000fb_writew(height, CO_REG_PIXHEIGHT, cfb);
- switch (var->bits_per_pixel) {
- case 15:
- case 16:
- bgx = ((u16 *)p->dispsw_data)[bgx];
- case 8:
- cyber2000fb_writel(dst, CO_REG_DEST_PTR, cfb);
- break;
-
- case 24:
- cyber2000fb_writel(dst * 3, CO_REG_DEST_PTR, cfb);
+ if (var->bits_per_pixel == 24) {
cyber2000fb_writeb(dst, CO_REG_X_PHASE, cfb);
- bgx = ((u32 *)p->dispsw_data)[bgx];
- break;
-
- case 32:
- bgx = ((u32 *)p->dispsw_data)[bgx];
- cyber2000fb_writel(dst, CO_REG_DEST_PTR, cfb);
- break;
+ dst *= 3;
}
- cyber2000fb_writel(bgx, CO_REG_FOREGROUND, cfb);
+ if (var->bits_per_pixel == 16)
+ bgx = ((u16 *)display->dispsw_data)[bgx];
+ else if (var->bits_per_pixel >= 24)
+ bgx = ((u32 *)display->dispsw_data)[bgx];
+
+ cyber2000fb_writel(bgx, CO_REG_FGCOLOUR, cfb);
+ cyber2000fb_writel(dst, CO_REG_DEST_PTR, cfb);
+ cyber2000fb_writeb(CO_FG_MIX_SRC, CO_REG_FGMIX, cfb);
cyber2000fb_writew(CO_CMD_L_PATTERN_FGCOL, CO_REG_CMD_L, cfb);
- cyber2000fb_writew(0x0800, CO_REG_CMD_H, cfb);
+ cyber2000fb_writew(CO_CMD_H_BLITTER, CO_REG_CMD_H, cfb);
}
static void
-cyber2000_accel_putc(struct vc_data *conp, struct display *p, int c,
+cyber2000_accel_putc(struct vc_data *conp, struct display *display, int c,
int yy, int xx)
{
- struct cfb_info *cfb = (struct cfb_info *)p->fb_info;
+ struct cfb_info *cfb = (struct cfb_info *)display->fb_info;
cyber2000_accel_wait(cfb);
- cfb->dispsw->putc(conp, p, c, yy, xx);
+ cfb->dispsw->putc(conp, display, c, yy, xx);
}
static void
-cyber2000_accel_putcs(struct vc_data *conp, struct display *p,
+cyber2000_accel_putcs(struct vc_data *conp, struct display *display,
const unsigned short *s, int count, int yy, int xx)
{
- struct cfb_info *cfb = (struct cfb_info *)p->fb_info;
+ struct cfb_info *cfb = (struct cfb_info *)display->fb_info;
cyber2000_accel_wait(cfb);
- cfb->dispsw->putcs(conp, p, s, count, yy, xx);
+ cfb->dispsw->putcs(conp, display, s, count, yy, xx);
}
-static void cyber2000_accel_revc(struct display *p, int xx, int yy)
+static void cyber2000_accel_revc(struct display *display, int xx, int yy)
{
- struct cfb_info *cfb = (struct cfb_info *)p->fb_info;
+ struct cfb_info *cfb = (struct cfb_info *)display->fb_info;
cyber2000_accel_wait(cfb);
- cfb->dispsw->revc(p, xx, yy);
+ cfb->dispsw->revc(display, xx, yy);
}
static void
-cyber2000_accel_clear_margins(struct vc_data *conp, struct display *p,
+cyber2000_accel_clear_margins(struct vc_data *conp, struct display *display,
int bottom_only)
{
- struct cfb_info *cfb = (struct cfb_info *)p->fb_info;
+ struct cfb_info *cfb = (struct cfb_info *)display->fb_info;
- cfb->dispsw->clear_margins(conp, p, bottom_only);
+ cfb->dispsw->clear_margins(conp, display, bottom_only);
}
static struct display_switch fbcon_cyber_accel = {
- setup: cyber2000_accel_setup,
- bmove: cyber2000_accel_bmove,
- clear: cyber2000_accel_clear,
- putc: cyber2000_accel_putc,
- putcs: cyber2000_accel_putcs,
- revc: cyber2000_accel_revc,
- clear_margins: cyber2000_accel_clear_margins,
- fontwidthmask: FONTWIDTH(8)|FONTWIDTH(16)
+ .setup = cyber2000_accel_setup,
+ .bmove = cyber2000_accel_bmove,
+ .clear = cyber2000_accel_clear,
+ .putc = cyber2000_accel_putc,
+ .putcs = cyber2000_accel_putcs,
+ .revc = cyber2000_accel_revc,
+ .clear_margins = cyber2000_accel_clear_margins,
+ .fontwidthmask = FONTWIDTH(8)|FONTWIDTH(16)
};
+static inline u32 convert_bitfield(u_int val, struct fb_bitfield *bf)
+{
+ u_int mask = (1 << bf->length) - 1;
+
+ return (val >> (16 - bf->length) & mask) << bf->offset;
+}
+
/*
* Set a single color register. Return != 0 for invalid regno.
*/
static int
-cyber2000_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
- u_int transp, struct fb_info *info)
+cyber2000fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
+ u_int transp, struct fb_info *info)
{
struct cfb_info *cfb = (struct cfb_info *)info;
+ struct fb_var_screeninfo *var = &cfb->display->var;
+ u32 pseudo_val;
+ int ret = 1;
- u_int alpha = transp ^ 0xFFFF;
-
- if (regno >= NR_PALETTE)
+ switch (cfb->fb.fix.visual) {
+ default:
return 1;
- red >>= 8;
- green >>= 8;
- blue >>= 8;
- alpha >>= 8;
-
- cfb->palette[regno].red = red;
- cfb->palette[regno].green = green;
- cfb->palette[regno].blue = blue;
-
- switch (cfb->fb.var.bits_per_pixel) {
#ifdef FBCON_HAS_CFB8
- case 8:
+ /*
+ * Pseudocolour:
+ * 8 8
+ * pixel --/--+--/--> red lut --> red dac
+ * | 8
+ * +--/--> green lut --> green dac
+ * | 8
+ * +--/--> blue lut --> blue dac
+ */
+ case FB_VISUAL_PSEUDOCOLOR:
+ if (regno >= NR_PALETTE)
+ return 1;
+
+ red >>= 8;
+ green >>= 8;
+ blue >>= 8;
+
+ cfb->palette[regno].red = red;
+ cfb->palette[regno].green = green;
+ cfb->palette[regno].blue = blue;
+
cyber2000fb_writeb(regno, 0x3c8, cfb);
- cyber2000fb_writeb(red, 0x3c9, cfb);
+ cyber2000fb_writeb(red, 0x3c9, cfb);
cyber2000fb_writeb(green, 0x3c9, cfb);
- cyber2000fb_writeb(blue, 0x3c9, cfb);
- break;
+ cyber2000fb_writeb(blue, 0x3c9, cfb);
+ return 0;
#endif
-#ifdef FBCON_HAS_CFB16
- case 16:
-#ifndef CFB16_IS_CFB15
- if (regno < 64) {
- /* write green */
+ /*
+ * Direct colour:
+ * n rl
+ * pixel --/--+--/--> red lut --> red dac
+ * | gl
+ * +--/--> green lut --> green dac
+ * | bl
+ * +--/--> blue lut --> blue dac
+ * n = bpp, rl = red length, gl = green length, bl = blue length
+ */
+ case FB_VISUAL_DIRECTCOLOR:
+ red >>= 8;
+ green >>= 8;
+ blue >>= 8;
+
+ if (var->green.length == 6 && regno < 64) {
+ cfb->palette[regno << 2].green = green;
+
+ /*
+ * The 6 bits of the green component are applied
+ * to the high 6 bits of the LUT.
+ */
cyber2000fb_writeb(regno << 2, 0x3c8, cfb);
cyber2000fb_writeb(cfb->palette[regno >> 1].red, 0x3c9, cfb);
cyber2000fb_writeb(green, 0x3c9, cfb);
cyber2000fb_writeb(cfb->palette[regno >> 1].blue, 0x3c9, cfb);
+
+ green = cfb->palette[regno << 3].green;
+
+ ret = 0;
}
- if (regno < 32) {
- /* write red,blue */
+ if (var->green.length >= 5 && regno < 32) {
+ cfb->palette[regno << 3].red = red;
+ cfb->palette[regno << 3].green = green;
+ cfb->palette[regno << 3].blue = blue;
+
+ /*
+ * The 5 bits of each colour component are
+ * applied to the high 5 bits of the LUT.
+ */
cyber2000fb_writeb(regno << 3, 0x3c8, cfb);
cyber2000fb_writeb(red, 0x3c9, cfb);
- cyber2000fb_writeb(cfb->palette[regno << 1].green, 0x3c9, cfb);
+ cyber2000fb_writeb(green, 0x3c9, cfb);
cyber2000fb_writeb(blue, 0x3c9, cfb);
+ ret = 0;
}
- if (regno < 16)
- ((u16 *)cfb->fb.pseudo_palette)[regno] =
- ((red << 8) & 0xf800) |
- ((green << 3) & 0x07e0) |
- ((blue >> 3));
- break;
-#endif
-
- case 15:
- if (regno < 32) {
- cyber2000fb_writeb(regno << 3, 0x3c8, cfb);
+ if (var->green.length == 4 && regno < 16) {
+ cfb->palette[regno << 4].red = red;
+ cfb->palette[regno << 4].green = green;
+ cfb->palette[regno << 4].blue = blue;
+
+ /*
+ * The 5 bits of each colour component are
+ * applied to the high 5 bits of the LUT.
+ */
+ cyber2000fb_writeb(regno << 4, 0x3c8, cfb);
cyber2000fb_writeb(red, 0x3c9, cfb);
cyber2000fb_writeb(green, 0x3c9, cfb);
cyber2000fb_writeb(blue, 0x3c9, cfb);
+ ret = 0;
}
- if (regno < 16)
- ((u16 *)cfb->fb.pseudo_palette)[regno] =
- ((red << 7) & 0x7c00) |
- ((green << 2) & 0x03e0) |
- ((blue >> 3));
- break;
-
-#endif
-
-#ifdef FBCON_HAS_CFB24
- case 24:
- cyber2000fb_writeb(regno, 0x3c8, cfb);
- cyber2000fb_writeb(red, 0x3c9, cfb);
- cyber2000fb_writeb(green, 0x3c9, cfb);
- cyber2000fb_writeb(blue, 0x3c9, cfb);
- if (regno < 16)
- ((u32 *)cfb->fb.pseudo_palette)[regno] =
- (red << 16) | (green << 8) | blue;
+ /*
+ * Since this is only used for the first 16 colours, we
+ * don't have to care about overflowing for regno >= 32
+ */
+ pseudo_val = regno << var->red.offset |
+ regno << var->green.offset |
+ regno << var->blue.offset;
break;
-#endif
-
-#ifdef FBCON_HAS_CFB32
- case 32:
- cyber2000fb_writeb(regno, 0x3c8, cfb);
- cyber2000fb_writeb(red, 0x3c9, cfb);
- cyber2000fb_writeb(green, 0x3c9, cfb);
- cyber2000fb_writeb(blue, 0x3c9, cfb);
- if (regno < 16)
- ((u32 *)cfb->fb.pseudo_palette)[regno] =
- (alpha << 24) | (red << 16) | (green << 8) | blue;
+ /*
+ * True colour:
+ * n rl
+ * pixel --/--+--/--> red dac
+ * | gl
+ * +--/--> green dac
+ * | bl
+ * +--/--> blue dac
+ * n = bpp, rl = red length, gl = green length, bl = blue length
+ */
+ case FB_VISUAL_TRUECOLOR:
+ pseudo_val = convert_bitfield(transp ^ 0xffff, &var->transp);
+ pseudo_val |= convert_bitfield(red, &var->red);
+ pseudo_val |= convert_bitfield(green, &var->green);
+ pseudo_val |= convert_bitfield(blue, &var->blue);
break;
-#endif
+ }
- default:
- return 1;
+ /*
+ * Now set our pseudo palette for the CFB16/24/32 drivers.
+ */
+ if (regno < 16) {
+ if (var->bits_per_pixel == 16)
+ ((u16 *)cfb->fb.pseudo_palette)[regno] = pseudo_val;
+ else
+ ((u32 *)cfb->fb.pseudo_palette)[regno] = pseudo_val;
+ ret = 0;
}
- return 0;
+ return ret;
}
struct par_info {
@@ -428,8 +473,8 @@
*/
u_char clock_mult;
u_char clock_div;
- u_char visualid;
- u_char pixformat;
+ u_char extseqmisc;
+ u_char co_pixfmt;
u_char crtc_ofl;
u_char crtc[19];
u_int width;
@@ -439,8 +484,7 @@
/*
* Other
*/
- u_char palette_ctrl;
- u_int vmode;
+ u_char ramdac;
};
static const u_char crtc_idx[] = {
@@ -449,6 +493,18 @@
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18
};
+static void cyber2000fb_write_ramdac_ctrl(struct cfb_info *cfb)
+{
+ unsigned int i;
+ unsigned int val = cfb->ramdac_ctrl | cfb->ramdac_powerdown;
+
+ cyber2000fb_writeb(0x56, 0x3ce, cfb);
+ i = cyber2000fb_readb(0x3cf, cfb);
+ cyber2000fb_writeb(i | 4, 0x3cf, cfb);
+ cyber2000fb_writeb(val, 0x3c6, cfb);
+ cyber2000fb_writeb(i, 0x3cf, cfb);
+}
+
static void cyber2000fb_set_timing(struct cfb_info *cfb, struct par_info *hw)
{
u_int i;
@@ -480,7 +536,7 @@
for (i = 0x0a; i < 0x10; i++)
cyber2000_crtcw(i, 0, cfb);
- cyber2000_grphw(0x11, hw->crtc_ofl, cfb);
+ cyber2000_grphw(EXT_CRT_VRTOFL, hw->crtc_ofl, cfb);
cyber2000_grphw(0x00, 0x00, cfb);
cyber2000_grphw(0x01, 0x00, cfb);
cyber2000_grphw(0x02, 0x00, cfb);
@@ -501,30 +557,17 @@
cyber2000_attrw(0x13, 0x00, cfb);
cyber2000_attrw(0x14, 0x00, cfb);
- /* woody: set the interlaced bit... */
- /* FIXME: what about doublescan? */
- cyber2000fb_writeb(0x11, 0x3ce, cfb);
- i = cyber2000fb_readb(0x3cf, cfb);
- if (hw->vmode == FB_VMODE_INTERLACED)
- i |= 0x20;
- else
- i &= ~0x20;
- cyber2000fb_writeb(i, 0x3cf, cfb);
-
/* PLL registers */
- cyber2000_grphw(DCLK_MULT, hw->clock_mult, cfb);
- cyber2000_grphw(DCLK_DIV, hw->clock_div, cfb);
- cyber2000_grphw(MCLK_MULT, cfb->mclk_mult, cfb);
- cyber2000_grphw(MCLK_DIV, cfb->mclk_div, cfb);
+ cyber2000_grphw(EXT_DCLK_MULT, hw->clock_mult, cfb);
+ cyber2000_grphw(EXT_DCLK_DIV, hw->clock_div, cfb);
+ cyber2000_grphw(EXT_MCLK_MULT, cfb->mclk_mult, cfb);
+ cyber2000_grphw(EXT_MCLK_DIV, cfb->mclk_div, cfb);
cyber2000_grphw(0x90, 0x01, cfb);
cyber2000_grphw(0xb9, 0x80, cfb);
cyber2000_grphw(0xb9, 0x00, cfb);
- cyber2000fb_writeb(0x56, 0x3ce, cfb);
- i = cyber2000fb_readb(0x3cf, cfb);
- cyber2000fb_writeb(i | 4, 0x3cf, cfb);
- cyber2000fb_writeb(hw->palette_ctrl, 0x3c6, cfb);
- cyber2000fb_writeb(i, 0x3cf, cfb);
+ cfb->ramdac_ctrl = hw->ramdac;
+ cyber2000fb_write_ramdac_ctrl(cfb);
cyber2000fb_writeb(0x20, 0x3c0, cfb);
cyber2000fb_writeb(0xff, 0x3c6, cfb);
@@ -532,31 +575,32 @@
cyber2000_grphw(0x14, hw->fetch, cfb);
cyber2000_grphw(0x15, ((hw->fetch >> 8) & 0x03) |
((hw->pitch >> 4) & 0x30), cfb);
- cyber2000_grphw(0x77, hw->visualid, cfb);
+ cyber2000_grphw(EXT_SEQ_MISC, hw->extseqmisc, cfb);
- /* make sure we stay in linear mode */
- cyber2000_grphw(0x33, 0x0d, cfb);
+// cyber2000_grphw(EXT_BIU_MISC, EXT_BIU_MISC_LIN_ENABLE |
+// EXT_BIU_MISC_COP_ENABLE |
+// EXT_BIU_MISC_COP_BFC, cfb);
/*
* Set up accelerator registers
*/
cyber2000fb_writew(hw->width, CO_REG_SRC_WIDTH, cfb);
cyber2000fb_writew(hw->width, CO_REG_DEST_WIDTH, cfb);
- cyber2000fb_writeb(hw->pixformat, CO_REG_PIX_FORMAT, cfb);
+ cyber2000fb_writeb(hw->co_pixfmt, CO_REG_PIXFMT, cfb);
}
static inline int
cyber2000fb_update_start(struct cfb_info *cfb, struct fb_var_screeninfo *var)
{
- u_int base;
+ u_int base = var->yoffset * var->xres_virtual + var->xoffset;
- base = var->yoffset * var->xres_virtual + var->xoffset;
+ base *= var->bits_per_pixel;
- /* have to be careful, because bits_per_pixel might be 15
- in this version of the driver -- dok@directfb.org 2002/06/13 */
- base *= (var->bits_per_pixel + 7) >> 3;
-
- base >>= 2;
+ /*
+ * Convert to bytes and shift two extra bits because DAC
+ * can only start on 4 byte aligned data.
+ */
+ base >>= 5;
if (base >= 1 << 20)
return -EINVAL;
@@ -576,27 +620,20 @@
struct fb_info *info)
{
struct cfb_info *cfb = (struct cfb_info *)info;
- struct fb_cmap *dcmap = &fb_display[con].cmap;
+ struct display *display = fb_display + con;
+ struct fb_cmap *dcmap = &display->cmap;
int err = 0;
/* no colormap allocated? */
- if (!dcmap->len) {
- int size;
-
- if (cfb->fb.var.bits_per_pixel == 16)
- size = 32;
- else
- size = 256;
-
- err = fb_alloc_cmap(dcmap, size, 0);
- }
+ if (!dcmap->len)
+ err = fb_alloc_cmap(dcmap, 256, 0);
/*
* we should be able to remove this test once fbcon has been
* "improved" --rmk
*/
- if (!err && con == cfb->currcon) {
- err = fb_set_cmap(cmap, kspc, cyber2000_setcolreg, &cfb->fb);
+ if (!err && display == cfb->display) {
+ err = fb_set_cmap(cmap, kspc, cyber2000fb_setcolreg, &cfb->fb);
dcmap = &cfb->fb.cmap;
}
@@ -672,8 +709,9 @@
hw->crtc[16] = Vblankend;
hw->crtc[18] = 0xff;
- /* overflow - graphics reg 0x11 */
- /* 0=VTOTAL:10 1=VDEND:10 2=VRSTART:10 3=VBSTART:10
+ /*
+ * overflow - graphics reg 0x11
+ * 0=VTOTAL:10 1=VDEND:10 2=VRSTART:10 3=VBSTART:10
* 4=LINECOMP:10 5-IVIDEO 6=FIXCNT
*/
hw->crtc_ofl =
@@ -681,7 +719,12 @@
BIT(Vdispend, 10, 0x01, 1) |
BIT(Vsyncstart, 10, 0x01, 2) |
BIT(Vblankstart,10, 0x01, 3) |
- 1 << 4;
+ EXT_CRT_VRTOFL_LINECOMP10;
+
+ /* woody: set the interlaced bit... */
+ /* FIXME: what about doublescan? */
+ if ((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED)
+ hw->crtc_ofl |= EXT_CRT_VRTOFL_INTERLACE;
return 0;
}
@@ -787,7 +830,7 @@
vco = ref_ps * best_div1 / best_mult;
if ((ref_ps == 40690) && (vco < 5556))
/* Set VFSEL when VCO > 180MHz (5.556 ps). */
- hw->clock_div |= DCLK_DIV_VFSEL;
+ hw->clock_div |= EXT_DCLK_DIV_VFSEL;
return 0;
}
@@ -801,58 +844,131 @@
cyber2000fb_decode_var(struct fb_var_screeninfo *var, struct cfb_info *cfb,
struct par_info *hw)
{
+ unsigned int mem;
int err;
hw->width = var->xres_virtual;
- hw->palette_ctrl = 0x06;
- hw->vmode = var->vmode;
+ hw->ramdac = RAMDAC_VREFEN | RAMDAC_DAC8BIT;
+
+ var->transp.msb_right = 0;
+ var->red.msb_right = 0;
+ var->green.msb_right = 0;
+ var->blue.msb_right = 0;
switch (var->bits_per_pixel) {
#ifdef FBCON_HAS_CFB8
case 8: /* PSEUDOCOLOUR, 256 */
- hw->pixformat = PIXFORMAT_8BPP;
- hw->visualid = VISUALID_256;
+ hw->co_pixfmt = CO_PIXFMT_8BPP;
hw->pitch = hw->width >> 3;
+ hw->extseqmisc = EXT_SEQ_MISC_8;
+
+ var->transp.offset = 0;
+ var->transp.length = 0;
+ var->red.offset = 0;
+ var->red.length = 8;
+ var->green.offset = 0;
+ var->green.length = 8;
+ var->blue.offset = 0;
+ var->blue.length = 8;
break;
#endif
#ifdef FBCON_HAS_CFB16
- case 16:/* DIRECTCOLOUR, 64k */
-#ifndef CFB16_IS_CFB15
- hw->pixformat = PIXFORMAT_16BPP;
- hw->visualid = VISUALID_64K;
- hw->pitch = hw->width >> 2;
- hw->palette_ctrl |= 0x10;
- break;
-#endif
- case 15:/* DIRECTCOLOUR, 32k */
- hw->pixformat = PIXFORMAT_16BPP;
- hw->visualid = VISUALID_32K;
+ case 16:/* DIRECTCOLOUR, 64k or 32k */
+ hw->co_pixfmt = CO_PIXFMT_16BPP;
hw->pitch = hw->width >> 2;
- hw->palette_ctrl |= 0x10;
- break;
+ switch (var->green.length) {
+ case 6: /* RGB565, 64k */
+ hw->extseqmisc = EXT_SEQ_MISC_16_RGB565;
+
+ var->transp.offset = 0;
+ var->transp.length = 0;
+ var->red.offset = 11;
+ var->red.length = 5;
+ var->green.offset = 5;
+ var->green.length = 6;
+ var->blue.offset = 0;
+ var->blue.length = 5;
+ break;
+
+ default:
+ case 5: /* RGB555, 32k */
+ hw->extseqmisc = EXT_SEQ_MISC_16_RGB555;
+
+ var->transp.offset = 0;
+ var->transp.length = 0;
+ var->red.offset = 10;
+ var->red.length = 5;
+ var->green.offset = 5;
+ var->green.length = 5;
+ var->blue.offset = 0;
+ var->blue.length = 5;
+ break;
+
+ case 4: /* RGB444, 4k + transparency? */
+ hw->extseqmisc = EXT_SEQ_MISC_16_RGB444;
+
+ var->transp.offset = 12;
+ var->transp.length = 4;
+ var->red.offset = 8;
+ var->red.length = 4;
+ var->green.offset = 4;
+ var->green.length = 4;
+ var->blue.offset = 0;
+ var->blue.length = 4;
+ break;
+ }
+ break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:/* TRUECOLOUR, 16m */
- hw->pixformat = PIXFORMAT_24BPP;
- hw->visualid = VISUALID_16M;
+ hw->co_pixfmt = CO_PIXFMT_24BPP;
hw->width *= 3;
hw->pitch = hw->width >> 3;
- hw->palette_ctrl |= 0x10;
+ hw->ramdac |= (RAMDAC_BYPASS | RAMDAC_RAMPWRDN);
+ hw->extseqmisc = EXT_SEQ_MISC_24_RGB888;
+
+ var->transp.offset = 0;
+ var->transp.length = 0;
+ var->red.offset = 16;
+ var->red.length = 8;
+ var->green.offset = 8;
+ var->green.length = 8;
+ var->blue.offset = 0;
+ var->blue.length = 8;
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:/* TRUECOLOUR, 16m */
- hw->pixformat = PIXFORMAT_32BPP;
- hw->visualid = VISUALID_16M_32;
+ hw->co_pixfmt = CO_PIXFMT_32BPP;
hw->pitch = hw->width >> 1;
- hw->palette_ctrl |= 0x10;
+ hw->ramdac |= (RAMDAC_BYPASS | RAMDAC_RAMPWRDN);
+ hw->extseqmisc = EXT_SEQ_MISC_32;
+
+ var->transp.offset = 24;
+ var->transp.length = 8;
+ var->red.offset = 16;
+ var->red.length = 8;
+ var->green.offset = 8;
+ var->green.length = 8;
+ var->blue.offset = 0;
+ var->blue.length = 8;
break;
#endif
default:
return -EINVAL;
}
+ mem = var->xres_virtual * var->yres_virtual * (var->bits_per_pixel / 8);
+ if (mem > cfb->fb.fix.smem_len)
+ var->yres_virtual = cfb->fb.fix.smem_len * 8 /
+ (var->bits_per_pixel * var->xres_virtual);
+
+ if (var->yres > var->yres_virtual)
+ var->yres = var->yres_virtual;
+ if (var->xres > var->xres_virtual)
+ var->xres = var->xres_virtual;
+
err = cyber2000fb_decode_clock(hw, cfb, var);
if (err)
return err;
@@ -880,7 +996,7 @@
struct cfb_info *cfb = (struct cfb_info *)info;
struct display *display;
struct par_info hw;
- int err, chgvar = 0;
+ int err, chgvar;
/*
* CONUPDATE and SMOOTH_XPAN are equal. However,
@@ -888,11 +1004,11 @@
*/
if (var->vmode & FB_VMODE_CONUPDATE) {
var->vmode |= FB_VMODE_YWRAP;
- var->xoffset = cfb->fb.var.xoffset;
- var->yoffset = cfb->fb.var.yoffset;
+ var->xoffset = cfb->display->var.xoffset;
+ var->yoffset = cfb->display->var.yoffset;
}
- err = cyber2000fb_decode_var(var, (struct cfb_info *)info, &hw);
+ err = cyber2000fb_decode_var(var, cfb, &hw);
if (err)
return err;
@@ -902,105 +1018,61 @@
if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW)
return -EINVAL;
- if (cfb->fb.var.xres != var->xres)
- chgvar = 1;
- if (cfb->fb.var.yres != var->yres)
- chgvar = 1;
- if (cfb->fb.var.xres_virtual != var->xres_virtual)
- chgvar = 1;
- if (cfb->fb.var.yres_virtual != var->yres_virtual)
- chgvar = 1;
- if (cfb->fb.var.bits_per_pixel != var->bits_per_pixel)
- chgvar = 1;
-
if (con < 0) {
display = cfb->fb.disp;
- chgvar = 0;
} else {
display = fb_display + con;
}
- var->red.msb_right = 0;
- var->green.msb_right = 0;
- var->blue.msb_right = 0;
+ chgvar = cfb->fb.var.xres != var->xres ||
+ cfb->fb.var.yres != var->yres ||
+ cfb->fb.var.xres_virtual != var->xres_virtual ||
+ cfb->fb.var.yres_virtual != var->yres_virtual ||
+ cfb->fb.var.bits_per_pixel != var->bits_per_pixel;
+
+ if (memcmp(&cfb->fb.var.red, &var->red, sizeof(var->red)) ||
+ memcmp(&cfb->fb.var.green, &var->green, sizeof(var->green)) ||
+ memcmp(&cfb->fb.var.blue, &var->blue, sizeof(var->blue)))
+ chgvar = 1;
+
+ if (con < 0)
+ chgvar = 0;
+
+ /*
+ * If we are setting all the virtual consoles, also set the
+ * defaults used to create new consoles.
+ */
+ err = var->activate;
+ var->activate = FB_ACTIVATE_NOW;
+ if (err & FB_ACTIVATE_ALL)
+ cfb->fb.disp->var = *var;
+
+ cfb->fb.var = *var;
+ cfb->fb.fix.line_length = var->xres_virtual * var->bits_per_pixel / 8;
switch (var->bits_per_pixel) {
#ifdef FBCON_HAS_CFB8
case 8: /* PSEUDOCOLOUR, 256 */
- var->red.offset = 0;
- var->red.length = 8;
- var->green.offset = 0;
- var->green.length = 8;
- var->blue.offset = 0;
- var->blue.length = 8;
-
- cfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
cfb->dispsw = &fbcon_cfb8;
display->dispsw_data = NULL;
- display->next_line = var->xres_virtual;
break;
#endif
#ifdef FBCON_HAS_CFB16
- case 16:/* DIRECTCOLOUR, 64k */
-#ifndef CFB16_IS_CFB15
- var->red.offset = 11;
- var->red.length = 5;
- var->green.offset = 5;
- var->green.length = 6;
- var->blue.offset = 0;
- var->blue.length = 5;
-
- cfb->fb.fix.visual = FB_VISUAL_DIRECTCOLOR;
- cfb->dispsw = &fbcon_cfb16;
- display->dispsw_data = cfb->fb.pseudo_palette;
- display->next_line = var->xres_virtual * 2;
- break;
-#endif
- case 15:/* DIRECTCOLOUR, 32k */
- var->bits_per_pixel = 15;
- var->red.offset = 10;
- var->red.length = 5;
- var->green.offset = 5;
- var->green.length = 5;
- var->blue.offset = 0;
- var->blue.length = 5;
-
- cfb->fb.fix.visual = FB_VISUAL_DIRECTCOLOR;
+ case 16:/* DIRECTCOLOUR */
cfb->dispsw = &fbcon_cfb16;
display->dispsw_data = cfb->fb.pseudo_palette;
- display->next_line = var->xres_virtual * 2;
break;
#endif
#ifdef FBCON_HAS_CFB24
case 24:/* TRUECOLOUR, 16m */
- var->red.offset = 16;
- var->red.length = 8;
- var->green.offset = 8;
- var->green.length = 8;
- var->blue.offset = 0;
- var->blue.length = 8;
-
- cfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
cfb->dispsw = &fbcon_cfb24;
display->dispsw_data = cfb->fb.pseudo_palette;
- display->next_line = var->xres_virtual * 3;
break;
#endif
#ifdef FBCON_HAS_CFB32
case 32:/* TRUECOLOUR, 16m */
- var->transp.offset = 24;
- var->transp.length = 8;
- var->red.offset = 16;
- var->red.length = 8;
- var->green.offset = 8;
- var->green.length = 8;
- var->blue.offset = 0;
- var->blue.length = 8;
-
- cfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
cfb->dispsw = &fbcon_cfb32;
display->dispsw_data = cfb->fb.pseudo_palette;
- display->next_line = var->xres_virtual * 4;
break;
#endif
default:/* in theory this should never happen */
@@ -1010,15 +1082,27 @@
break;
}
+ /*
+ * 8bpp displays are always pseudo colour.
+ * 16bpp and above are direct colour or true colour, depending
+ * on whether the RAMDAC palettes are bypassed. (Direct colour
+ * has palettes, true colour does not.)
+ */
+ if (var->bits_per_pixel == 8)
+ cfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ else if (hw.ramdac & RAMDAC_BYPASS)
+ cfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
+ else
+ cfb->fb.fix.visual = FB_VISUAL_DIRECTCOLOR;
+
if (var->accel_flags & FB_ACCELF_TEXT && cfb->dispsw != &fbcon_dummy)
display->dispsw = &fbcon_cyber_accel;
else
display->dispsw = cfb->dispsw;
- cfb->fb.fix.line_length = display->next_line;
-
display->screen_base = cfb->fb.screen_base;
display->line_length = cfb->fb.fix.line_length;
+ display->next_line = cfb->fb.fix.line_length;
display->visual = cfb->fb.fix.visual;
display->type = cfb->fb.fix.type;
display->type_aux = cfb->fb.fix.type_aux;
@@ -1026,31 +1110,15 @@
display->ywrapstep = cfb->fb.fix.ywrapstep;
display->can_soft_blank = 1;
display->inverse = 0;
+ display->var = *var;
- cfb->fb.var = *var;
- cfb->fb.var.activate &= ~FB_ACTIVATE_ALL;
-
- /*
- * Update the old var. The fbcon drivers still use this.
- * Once they are using cfb->fb.var, this can be dropped.
- * --rmk
- */
- display->var = cfb->fb.var;
-
- /*
- * If we are setting all the virtual consoles, also set the
- * defaults used to create new consoles.
- */
- if (var->activate & FB_ACTIVATE_ALL)
- cfb->fb.disp->var = cfb->fb.var;
+ cyber2000fb_set_timing(cfb, &hw);
+ cyber2000fb_update_start(cfb, var);
+ fb_set_cmap(&cfb->fb.cmap, 1, cyber2000fb_setcolreg, &cfb->fb);
- if (chgvar && info && cfb->fb.changevar)
+ if (chgvar && cfb->fb.changevar)
cfb->fb.changevar(con);
- cyber2000fb_update_start(cfb, var);
- cyber2000fb_set_timing(cfb, &hw);
- fb_set_cmap(&cfb->fb.cmap, 1, cyber2000_setcolreg, &cfb->fb);
-
return 0;
}
@@ -1072,18 +1140,18 @@
if (var->xoffset > (var->xres_virtual - var->xres))
return -EINVAL;
- if (y_bottom > cfb->fb.var.yres_virtual)
+ if (y_bottom > cfb->display->var.yres_virtual)
return -EINVAL;
if (cyber2000fb_update_start(cfb, var))
return -EINVAL;
- cfb->fb.var.xoffset = var->xoffset;
- cfb->fb.var.yoffset = var->yoffset;
+ cfb->display->var.xoffset = var->xoffset;
+ cfb->display->var.yoffset = var->yoffset;
if (var->vmode & FB_VMODE_YWRAP) {
- cfb->fb.var.vmode |= FB_VMODE_YWRAP;
+ cfb->display->var.vmode |= FB_VMODE_YWRAP;
} else {
- cfb->fb.var.vmode &= ~FB_VMODE_YWRAP;
+ cfb->display->var.vmode &= ~FB_VMODE_YWRAP;
}
return 0;
@@ -1106,22 +1174,18 @@
static int cyber2000fb_switch(int con, struct fb_info *info)
{
struct cfb_info *cfb = (struct cfb_info *)info;
- struct display *disp;
+ struct display *display = cfb->display;
struct fb_cmap *cmap;
- if (cfb->currcon >= 0) {
- disp = fb_display + cfb->currcon;
-
+ if (display) {
/*
* Save the old colormap and video mode.
*/
- disp->var = cfb->fb.var;
- if (disp->cmap.len)
- fb_copy_cmap(&cfb->fb.cmap, &disp->cmap, 0);
+ if (display->cmap.len)
+ fb_copy_cmap(&cfb->fb.cmap, &display->cmap, 0);
}
- cfb->currcon = con;
- disp = fb_display + con;
+ cfb->display = display = fb_display + con;
/*
* Install the new colormap and change the video mode. By default,
@@ -1132,73 +1196,88 @@
* depth of the new video mode. For now, we leave it at its
* default 256 entry.
*/
- if (disp->cmap.len)
- cmap = &disp->cmap;
+ if (display->cmap.len)
+ cmap = &display->cmap;
else
- cmap = fb_default_cmap(1 << disp->var.bits_per_pixel);
+ cmap = fb_default_cmap(1 << display->var.bits_per_pixel);
fb_copy_cmap(cmap, &cfb->fb.cmap, 0);
- cfb->fb.var = disp->var;
- cfb->fb.var.activate = FB_ACTIVATE_NOW;
-
- cyber2000fb_set_var(&cfb->fb.var, con, &cfb->fb);
+ display->var.activate = FB_ACTIVATE_NOW;
+ cyber2000fb_set_var(&display->var, con, &cfb->fb);
return 0;
}
/*
* (Un)Blank the display.
+ *
+ * Blank the screen if blank_mode != 0, else unblank. If
+ * blank == NULL then the caller blanks by setting the CLUT
+ * (Color Look Up Table) to all black. Return 0 if blanking
+ * succeeded, != 0 if un-/blanking failed due to e.g. a
+ * video mode which doesn't support it. Implements VESA
+ * suspend and powerdown modes on hardware that supports
+ * disabling hsync/vsync:
+ * blank_mode == 2: suspend vsync
+ * blank_mode == 3: suspend hsync
+ * blank_mode == 4: powerdown
+ *
+ * wms...Enable VESA DMPS compatible powerdown mode
+ * run "setterm -powersave powerdown" to take advantage
*/
static void cyber2000fb_blank(int blank, struct fb_info *info)
{
struct cfb_info *cfb = (struct cfb_info *)info;
+ unsigned int sync = 0;
int i;
- /*
- * Blank the screen if blank_mode != 0, else unblank. If
- * blank == NULL then the caller blanks by setting the CLUT
- * (Color Look Up Table) to all black. Return 0 if blanking
- * succeeded, != 0 if un-/blanking failed due to e.g. a
- * video mode which doesn't support it. Implements VESA
- * suspend and powerdown modes on hardware that supports
- * disabling hsync/vsync:
- * blank_mode == 2: suspend vsync
- * blank_mode == 3: suspend hsync
- * blank_mode == 4: powerdown
- *
- * wms...Enable VESA DMPS compatible powerdown mode
- * run "setterm -powersave powerdown" to take advantage
- */
-
switch (blank) {
case 4: /* powerdown - both sync lines down */
- cyber2000_grphw(0x16, 0x05, cfb);
+ sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_0;
break;
case 3: /* hsync off */
- cyber2000_grphw(0x16, 0x01, cfb);
+ sync = EXT_SYNC_CTL_VS_NORMAL | EXT_SYNC_CTL_HS_0;
break;
case 2: /* vsync off */
- cyber2000_grphw(0x16, 0x04, cfb);
- break;
+ sync = EXT_SYNC_CTL_VS_0 | EXT_SYNC_CTL_HS_NORMAL;
+ break;
case 1: /* soft blank */
- cyber2000_grphw(0x16, 0x00, cfb);
+ default: /* unblank */
+ break;
+ }
+
+ cyber2000_grphw(EXT_SYNC_CTL, sync, cfb);
+
+ if (blank <= 1) {
+ /* turn on ramdacs */
+ cfb->ramdac_powerdown &= ~(RAMDAC_DACPWRDN | RAMDAC_BYPASS | RAMDAC_RAMPWRDN);
+ cyber2000fb_write_ramdac_ctrl(cfb);
+ }
+
+ /*
+ * Soft blank/unblank the display.
+ */
+ if (blank) { /* soft blank */
for (i = 0; i < NR_PALETTE; i++) {
cyber2000fb_writeb(i, 0x3c8, cfb);
cyber2000fb_writeb(0, 0x3c9, cfb);
cyber2000fb_writeb(0, 0x3c9, cfb);
cyber2000fb_writeb(0, 0x3c9, cfb);
}
- break;
- default: /* unblank */
- cyber2000_grphw(0x16, 0x00, cfb);
+ } else { /* unblank */
for (i = 0; i < NR_PALETTE; i++) {
cyber2000fb_writeb(i, 0x3c8, cfb);
cyber2000fb_writeb(cfb->palette[i].red, 0x3c9, cfb);
cyber2000fb_writeb(cfb->palette[i].green, 0x3c9, cfb);
cyber2000fb_writeb(cfb->palette[i].blue, 0x3c9, cfb);
}
- break;
+ }
+
+ if (blank >= 2) {
+ /* turn off ramdacs */
+ cfb->ramdac_powerdown |= RAMDAC_DACPWRDN | RAMDAC_BYPASS | RAMDAC_RAMPWRDN;
+ cyber2000fb_write_ramdac_ctrl(cfb);
}
}
@@ -1233,51 +1312,61 @@
}
static struct fb_ops cyber2000fb_ops = {
- owner: THIS_MODULE,
- fb_set_var: cyber2000fb_set_var,
- fb_set_cmap: cyber2000fb_set_cmap,
- fb_pan_display: cyber2000fb_pan_display,
- fb_get_fix: gen_get_fix,
- fb_get_var: gen_get_var,
- fb_get_cmap: gen_get_cmap,
+ .owner = THIS_MODULE,
+ .fb_set_var = cyber2000fb_set_var,
+ .fb_set_cmap = cyber2000fb_set_cmap,
+ .fb_pan_display = cyber2000fb_pan_display,
+ .fb_get_fix = gen_get_fix,
+ .fb_get_var = gen_get_var,
+ .fb_get_cmap = gen_get_cmap,
};
/*
+ * This is the only "static" reference to the internal data structures
+ * of this driver. It is here solely at the moment to support the other
+ * CyberPro modules external to this driver.
+ */
+static struct cfb_info *int_cfb_info;
+
+/*
* Enable access to the extended registers
*/
-static void cyber2000fb_enable_extregs(struct cfb_info *cfb)
+void cyber2000fb_enable_extregs(struct cfb_info *cfb)
{
cfb->func_use_count += 1;
if (cfb->func_use_count == 1) {
int old;
- old = cyber2000_grphr(FUNC_CTL, cfb);
- cyber2000_grphw(FUNC_CTL, old | FUNC_CTL_EXTREGENBL, cfb);
+ old = cyber2000_grphr(EXT_FUNC_CTL, cfb);
+ old |= EXT_FUNC_CTL_EXTREGENBL;
+ cyber2000_grphw(EXT_FUNC_CTL, old, cfb);
}
}
/*
* Disable access to the extended registers
*/
-static void cyber2000fb_disable_extregs(struct cfb_info *cfb)
+void cyber2000fb_disable_extregs(struct cfb_info *cfb)
{
if (cfb->func_use_count == 1) {
int old;
- old = cyber2000_grphr(FUNC_CTL, cfb);
- cyber2000_grphw(FUNC_CTL, old & ~FUNC_CTL_EXTREGENBL, cfb);
+ old = cyber2000_grphr(EXT_FUNC_CTL, cfb);
+ old &= ~EXT_FUNC_CTL_EXTREGENBL;
+ cyber2000_grphw(EXT_FUNC_CTL, old, cfb);
}
- cfb->func_use_count -= 1;
+ if (cfb->func_use_count == 0)
+ printk(KERN_ERR "disable_extregs: count = 0\n");
+ else
+ cfb->func_use_count -= 1;
}
-/*
- * This is the only "static" reference to the internal data structures
- * of this driver. It is here solely at the moment to support the other
- * CyberPro modules external to this driver.
- */
-static struct cfb_info *int_cfb_info;
+void cyber2000fb_get_fb_var(struct cfb_info *cfb, struct fb_var_screeninfo *var)
+{
+ memcpy(var, &cfb->display->var, sizeof(struct fb_var_screeninfo));
+}
/*
* Attach a capture/tv driver to the core CyberX0X0 driver.
@@ -1311,164 +1400,102 @@
EXPORT_SYMBOL(cyber2000fb_attach);
EXPORT_SYMBOL(cyber2000fb_detach);
+EXPORT_SYMBOL(cyber2000fb_enable_extregs);
+EXPORT_SYMBOL(cyber2000fb_disable_extregs);
+EXPORT_SYMBOL(cyber2000fb_get_fb_var);
/*
* These parameters give
* 640x480, hsync 31.5kHz, vsync 60Hz
*/
static struct fb_videomode __devinitdata cyber2000fb_default_mode = {
- refresh: 60,
- xres: 640,
- yres: 480,
- pixclock: 39722,
- left_margin: 56,
- right_margin: 16,
- upper_margin: 34,
- lower_margin: 9,
- hsync_len: 88,
- vsync_len: 2,
- sync: FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
- vmode: FB_VMODE_NONINTERLACED
+ .refresh = 60,
+ .xres = 640,
+ .yres = 480,
+ .pixclock = 39722,
+ .left_margin = 56,
+ .right_margin = 16,
+ .upper_margin = 34,
+ .lower_margin = 9,
+ .hsync_len = 88,
+ .vsync_len = 2,
+ .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+ .vmode = FB_VMODE_NONINTERLACED
};
+/* static register programming for all chips */
static char igs_regs[] __devinitdata = {
- 0x12, 0x00, 0x13, 0x00,
- 0x16, 0x00,
- 0x31, 0x00, 0x32, 0x00,
- 0x50, 0x00, 0x51, 0x00, 0x52, 0x00, 0x53, 0x00,
- 0x54, 0x00, 0x55, 0x00, 0x56, 0x00, 0x57, 0x01,
- 0x58, 0x00, 0x59, 0x00, 0x5a, 0x00,
- 0x70, 0x0b, 0x73, 0x30,
- 0x74, 0x0b, 0x75, 0x17, 0x76, 0x00, 0x7a, 0xc8
+ EXT_CRT_IRQ, 0,
+ EXT_CRT_TEST, 0,
+ EXT_SYNC_CTL, 0,
+ EXT_SEG_WRITE_PTR, 0,
+ EXT_SEG_READ_PTR, 0,
+ EXT_BIU_MISC, EXT_BIU_MISC_LIN_ENABLE |
+ EXT_BIU_MISC_COP_ENABLE |
+ EXT_BIU_MISC_COP_BFC,
+ EXT_FUNC_CTL, 0,
+ CURS_H_START, 0,
+ CURS_H_START + 1, 0,
+ CURS_H_PRESET, 0,
+ CURS_V_START, 0,
+ CURS_V_START + 1, 0,
+ CURS_V_PRESET, 0,
+ CURS_CTL, 0,
+ EXT_ATTRIB_CTL, EXT_ATTRIB_CTL_EXT,
+ EXT_OVERSCAN_RED, 0,
+ EXT_OVERSCAN_GREEN, 0,
+ EXT_OVERSCAN_BLUE, 0,
+};
+
+/* specific register setting for the 2000 series */
+static char igs_2000_regs[] __devinitdata = {
+ /* some of these are questionable when we have a BIOS */
+ EXT_MEM_CTL0, EXT_MEM_CTL0_7CLK |
+ EXT_MEM_CTL0_RAS_1 |
+ EXT_MEM_CTL0_MULTCAS,
+ EXT_HIDDEN_CTL1, 0x30,
+ EXT_FIFO_CTL, 0x0b,
+ EXT_FIFO_CTL + 1, 0x17,
+ 0x76, 0x00,
+ EXT_HIDDEN_CTL4, 0xc8
};
/*
- * We need to wake up the CyberPro, and make sure its in linear memory
- * mode. Unfortunately, this is specific to the platform and card that
- * we are running on.
- *
- * On x86 and ARM, should we be initialising the CyberPro first via the
- * IO registers, and then the MMIO registers to catch all cases? Can we
- * end up in the situation where the chip is in MMIO mode, but not awake
- * on an x86 system?
- *
- * Note that on the NetWinder, the firmware automatically detects the
- * type, width and size, and leaves this in extended registers 0x71 and
- * 0x72 for us.
+ * Initialise the CyberPro hardware.
*/
-static inline void cyberpro_init_hw(struct cfb_info *cfb, int at_boot)
+static void cyberpro_init_hw(struct cfb_info *cfb)
{
int i;
- /*
- * Wake up the CyberPro.
- */
-#ifdef __sparc__
-#ifdef __sparc_v9__
-#error "You loose, consult DaveM."
-#else
- /*
- * SPARC does not have an "outb" instruction, so we generate
- * I/O cycles storing into a reserved memory space at
- * physical address 0x3000000
- */
- {
- unsigned char *iop;
-
- iop = ioremap(0x3000000, 0x5000);
- if (iop == NULL) {
- prom_printf("iga5000: cannot map I/O\n");
- return -ENOMEM;
- }
-
- writeb(0x18, iop + 0x46e8);
- writeb(0x01, iop + 0x102);
- writeb(0x08, iop + 0x46e8);
- writeb(0x33, iop + 0x3ce);
- writeb(0x01, iop + 0x3cf);
-
- iounmap((void *)iop);
- }
-#endif
-
- if (at_boot) {
- /*
- * Use mclk from BIOS. Only read this if we're
- * initialising this card for the first time.
- * FIXME: what about hotplug?
- */
- cfb->mclk_mult = cyber2000_grphr(MCLK_MULT, cfb);
- cfb->mclk_div = cyber2000_grphr(MCLK_DIV, cfb);
- }
-#endif
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
- /*
- * x86 and MIPS are simple, we just do regular
- * outb's instead of cyber2000fb_writeb.
- */
- outb(0x18, 0x46e8);
- outb(0x01, 0x102);
- outb(0x08, 0x46e8);
- outb(0x33, 0x3ce);
- outb(0x01, 0x3cf);
-
- if (at_boot) {
- /*
- * Use mclk from BIOS. Only read this if we're
- * initialising this card for the first time.
- * FIXME: what about hotplug?
- */
- cfb->mclk_mult = cyber2000_grphr(MCLK_MULT, cfb);
- cfb->mclk_div = cyber2000_grphr(MCLK_DIV, cfb);
- }
-#endif
-#ifdef __arm__
- cyber2000fb_writeb(0x18, 0x46e8, cfb);
- cyber2000fb_writeb(0x01, 0x102, cfb);
- cyber2000fb_writeb(0x08, 0x46e8, cfb);
- cyber2000fb_writeb(0x33, 0x3ce, cfb);
- cyber2000fb_writeb(0x01, 0x3cf, cfb);
-
- /*
- * MCLK on the NetWinder and the Shark is fixed at 75MHz
- */
- cfb->mclk_mult = 0xdb;
- cfb->mclk_div = 0x54;
-#endif
-
- /*
- * Initialise the CyberPro
- */
for (i = 0; i < sizeof(igs_regs); i += 2)
cyber2000_grphw(igs_regs[i], igs_regs[i+1], cfb);
- if (at_boot) {
+ if (cfb->id == ID_CYBERPRO_5000) {
/*
- * get the video RAM size and width from the VGA register.
- * This should have been already initialised by the BIOS,
- * but if it's garbage, claim default 1MB VRAM (woody)
+ * On the CyberPro5XXXX, ensure that we're using the correct
+ * PLL (5XXX's may be programmed to use an additional set of
+ * PLLs.)
*/
- cfb->mem_ctl1 = cyber2000_grphr(MEM_CTL1, cfb);
- cfb->mem_ctl2 = cyber2000_grphr(MEM_CTL2, cfb);
+ unsigned char val;
+ cyber2000fb_writeb(0xba, 0x3ce, cfb);
+ val = cyber2000fb_readb(0x3cf, cfb) & 0x80;
+ cyber2000fb_writeb(val, 0x3cf, cfb);
+ cyber2000fb_ops.fb_pan_display = NULL; /* FIXME: panning broken */
} else {
/*
- * Reprogram the MEM_CTL1 and MEM_CTL2 registers
+ * Other supported chips (2000 series) appear to need
+ * these registers programming
*/
- cyber2000_grphw(MEM_CTL1, cfb->mem_ctl1, cfb);
- cyber2000_grphw(MEM_CTL2, cfb->mem_ctl2, cfb);
+ for (i = 0; i < sizeof(igs_2000_regs); i += 2)
+ cyber2000_grphw(igs_2000_regs[i],
+ igs_2000_regs[i+1],
+ cfb);
}
- /*
- * Ensure thatwe are using the correct PLL.
- * (CyberPro 5000's may be programmed to use
- * an additional set of PLLs.
- */
- cyber2000fb_writeb(0xba, 0x3ce, cfb);
- cyber2000fb_writeb(cyber2000fb_readb(0x3cf, cfb) & 0x80, 0x3cf, cfb);
}
static struct cfb_info * __devinit
-cyberpro_alloc_fb_info(struct pci_dev *dev, const struct pci_device_id *id, char *name)
+cyberpro_alloc_fb_info(unsigned int id, char *name)
{
struct cfb_info *cfb;
@@ -1480,10 +1507,9 @@
memset(cfb, 0, sizeof(struct cfb_info) + sizeof(struct display));
- cfb->currcon = -1;
- cfb->dev = dev;
+ cfb->id = id;
- if (id->driver_data == FB_ACCEL_IGS_CYBER5000)
+ if (id == ID_CYBERPRO_5000)
cfb->ref_ps = 40690; // 24.576 MHz
else
cfb->ref_ps = 69842; // 14.31818 MHz (69841?)
@@ -1492,7 +1518,7 @@
cfb->divisors[1] = 2;
cfb->divisors[2] = 4;
- if (id->driver_data == FB_ACCEL_IGS_CYBER2000)
+ if (id == ID_CYBERPRO_2000)
cfb->divisors[3] = 8;
else
cfb->divisors[3] = 6;
@@ -1504,7 +1530,24 @@
cfb->fb.fix.xpanstep = 0;
cfb->fb.fix.ypanstep = 1;
cfb->fb.fix.ywrapstep = 0;
- cfb->fb.fix.accel = id->driver_data;
+
+ switch (id) {
+ case ID_IGA_1682:
+ cfb->fb.fix.accel = 0;
+ break;
+
+ case ID_CYBERPRO_2000:
+ cfb->fb.fix.accel = FB_ACCEL_IGS_CYBER2000;
+ break;
+
+ case ID_CYBERPRO_2010:
+ cfb->fb.fix.accel = FB_ACCEL_IGS_CYBER2010;
+ break;
+
+ case ID_CYBERPRO_5000:
+ cfb->fb.fix.accel = FB_ACCEL_IGS_CYBER5000;
+ break;
+ }
cfb->fb.var.nonstd = 0;
cfb->fb.var.activate = FB_ACTIVATE_NOW;
@@ -1569,55 +1612,46 @@
return 0;
}
-static int __devinit
-cyberpro_probe(struct pci_dev *dev, const struct pci_device_id *id)
+/*
+ * The CyberPro chips can be placed on many different bus types.
+ * This probe function is common to all bus types. The bus-specific
+ * probe function is expected to have:
+ * - enabled access to the linear memory region
+ * - memory mapped access to the registers
+ * - initialised mem_ctl1 and mem_ctl2 appropriately.
+ */
+static int __devinit cyberpro_common_probe(struct cfb_info *cfb)
{
- struct cfb_info *cfb;
- u_int h_sync, v_sync;
u_long smem_size;
- char name[16];
+ u_int h_sync, v_sync;
int err;
- sprintf(name, "CyberPro%4X", id->device);
-
- err = pci_enable_device(dev);
- if (err)
- return err;
-
- err = pci_request_regions(dev, name);
- if (err)
- return err;
-
- err = -ENOMEM;
- cfb = cyberpro_alloc_fb_info(dev, id, name);
- if (!cfb)
- goto failed_release;
-
- cfb->region = ioremap(pci_resource_start(dev, 0),
- pci_resource_len(dev, 0));
- if (!cfb->region)
- goto failed_ioremap;
-
- cfb->regs = cfb->region + MMIO_OFFSET;
+ cyberpro_init_hw(cfb);
- cyberpro_init_hw(cfb, 1);
+ /*
+ * Get the video RAM size and width from the VGA register.
+ * This should have been already initialised by the BIOS,
+ * but if it's garbage, claim default 1MB VRAM (woody)
+ */
+ cfb->mem_ctl0 = cyber2000_grphr(EXT_MEM_CTL0, cfb);
+ cfb->mem_ctl1 = cyber2000_grphr(EXT_MEM_CTL1, cfb);
+ cfb->mem_ctl2 = cyber2000_grphr(EXT_MEM_CTL2, cfb);
+ /*
+ * Determine the size of the memory.
+ */
switch (cfb->mem_ctl2 & MEM_CTL2_SIZE_MASK) {
case MEM_CTL2_SIZE_4MB: smem_size = 0x00400000; break;
case MEM_CTL2_SIZE_2MB: smem_size = 0x00200000; break;
+ case MEM_CTL2_SIZE_1MB: smem_size = 0x00100000; break;
default: smem_size = 0x00100000; break;
}
- /*
- * Hmm, we _need_ a portable way of finding the address for
- * the remap stuff, both for mmio and for smem.
- */
- cfb->fb.fix.mmio_start = pci_resource_start(dev, 0) + MMIO_OFFSET;
- cfb->fb.fix.smem_start = pci_resource_start(dev, 0);
- cfb->fb.fix.mmio_len = MMIO_SIZE;
cfb->fb.fix.smem_len = smem_size;
+ cfb->fb.fix.mmio_len = MMIO_SIZE;
cfb->fb.screen_base = cfb->region;
+ err = -EINVAL;
if (!fb_find_mode(&cfb->fb.var, &cfb->fb, NULL, NULL, 0,
&cyber2000fb_default_mode, 8)) {
printk("%s: no valid mode found\n", cfb->fb.fix.id);
@@ -1644,13 +1678,181 @@
v_sync = h_sync / (cfb->fb.var.yres + cfb->fb.var.upper_margin +
cfb->fb.var.lower_margin + cfb->fb.var.vsync_len);
- printk(KERN_INFO "%s: %dkB VRAM, using %dx%d, %d.%03dkHz, %dHz\n",
+ printk(KERN_INFO "%s: %dKiB VRAM, using %dx%d, %d.%03dkHz, %dHz\n",
cfb->fb.fix.id, cfb->fb.fix.smem_len >> 10,
cfb->fb.var.xres, cfb->fb.var.yres,
h_sync / 1000, h_sync % 1000, v_sync);
err = register_framebuffer(&cfb->fb);
- if (err < 0)
+
+failed:
+ return err;
+}
+
+static void cyberpro_common_resume(struct cfb_info *cfb)
+{
+ cyberpro_init_hw(cfb);
+
+ /*
+ * Reprogram the MEM_CTL0, 1 and 2 registers
+ */
+ cyber2000_grphw(EXT_MEM_CTL0, cfb->mem_ctl0, cfb);
+ cyber2000_grphw(EXT_MEM_CTL1, cfb->mem_ctl1, cfb);
+ cyber2000_grphw(EXT_MEM_CTL2, cfb->mem_ctl2, cfb);
+
+ /*
+ * Restore the old video mode and the palette.
+ * We also need to tell fbcon to redraw the console.
+ */
+ cfb->fb.var.activate = FB_ACTIVATE_NOW;
+ cyber2000fb_set_var(&cfb->fb.var, -1, &cfb->fb);
+}
+
+
+
+
+/*
+ * PCI specific support.
+ */
+
+/*
+ * We need to wake up the CyberPro, and make sure its in linear memory
+ * mode. Unfortunately, this is specific to the platform and card that
+ * we are running on.
+ *
+ * On x86 and ARM, should we be initialising the CyberPro first via the
+ * IO registers, and then the MMIO registers to catch all cases? Can we
+ * end up in the situation where the chip is in MMIO mode, but not awake
+ * on an x86 system?
+ */
+static int cyberpro_pci_enable_mmio(struct cfb_info *cfb)
+{
+ unsigned char val;
+
+#if defined(__sparc_v9__)
+#error "You loose, consult DaveM."
+#elif defined(__sparc__)
+ /*
+ * SPARC does not have an "outb" instruction, so we generate
+ * I/O cycles storing into a reserved memory space at
+ * physical address 0x3000000
+ */
+ unsigned char *iop;
+
+ iop = ioremap(0x3000000, 0x5000);
+ if (iop == NULL) {
+ prom_printf("iga5000: cannot map I/O\n");
+ return -ENOMEM;
+ }
+
+ writeb(0x18, iop + 0x46e8);
+ writeb(0x01, iop + 0x102);
+ writeb(0x08, iop + 0x46e8);
+ writeb(EXT_BIU_MISC, iop + 0x3ce);
+ writeb(EXT_BIU_MISC_LIN_ENABLE, iop + 0x3cf);
+
+ iounmap((void *)iop);
+#elif defined(CONFIG_ARCH_SHARK)
+ /*
+ * Shark probably needs to do it this way rather than use the
+ * IO method below. Since the CyberPro on the Shark isn't a
+ * PCI device, we probably want to move this to a bus-specific
+ * probe function. Do we even need to do this?
+ */
+ cyber2000fb_writeb(0x18, 0x46e8, cfb);
+ cyber2000fb_writeb(0x01, 0x102, cfb);
+ cyber2000fb_writeb(0x08, 0x46e8, cfb);
+ cyber2000fb_writeb(EXT_BIU_MISC, 0x3ce, cfb);
+ cyber2000fb_writeb(EXT_BIU_MISC_LIN_ENABLE, 0x3cf, cfb);
+#else
+ /*
+ * Most other machine types are "normal", so
+ * we use the standard IO-based wakeup.
+ */
+ outb(0x18, 0x46e8);
+ outb(0x01, 0x102);
+ outb(0x08, 0x46e8);
+ outb(EXT_BIU_MISC, 0x3ce);
+ outb(EXT_BIU_MISC_LIN_ENABLE, 0x3cf);
+#endif
+
+ /*
+ * Allow the CyberPro to accept PCI burst accesses
+ */
+ val = cyber2000_grphr(EXT_BUS_CTL, cfb);
+ if (!(val & EXT_BUS_CTL_PCIBURST_WRITE)) {
+ printk(KERN_INFO "%s: enabling PCI bursts\n", cfb->fb.fix.id);
+
+ val |= EXT_BUS_CTL_PCIBURST_WRITE;
+
+ if (cfb->id == ID_CYBERPRO_5000)
+ val |= EXT_BUS_CTL_PCIBURST_READ;
+
+ cyber2000_grphw(EXT_BUS_CTL, val, cfb);
+ }
+
+ return 0;
+}
+
+static int __devinit
+cyberpro_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
+{
+ struct cfb_info *cfb;
+ char name[16];
+ int err;
+
+ sprintf(name, "CyberPro%4X", id->device);
+
+ err = pci_enable_device(dev);
+ if (err)
+ return err;
+
+ err = pci_request_regions(dev, name);
+ if (err)
+ return err;
+
+ err = -ENOMEM;
+ cfb = cyberpro_alloc_fb_info(id->driver_data, name);
+ if (!cfb)
+ goto failed_release;
+
+ cfb->dev = dev;
+ cfb->region = ioremap(pci_resource_start(dev, 0),
+ pci_resource_len(dev, 0));
+ if (!cfb->region)
+ goto failed_ioremap;
+
+ cfb->regs = cfb->region + MMIO_OFFSET;
+ cfb->fb.fix.mmio_start = pci_resource_start(dev, 0) + MMIO_OFFSET;
+ cfb->fb.fix.smem_start = pci_resource_start(dev, 0);
+
+ /*
+ * Bring up the hardware. This is expected to enable access
+ * to the linear memory region, and allow access to the memory
+ * mapped registers. Also, mem_ctl1 and mem_ctl2 must be
+ * initialised.
+ */
+ err = cyberpro_pci_enable_mmio(cfb);
+ if (err)
+ goto failed;
+
+ /*
+ * Use MCLK from BIOS. FIXME: what about hotplug?
+ */
+ cfb->mclk_mult = cyber2000_grphr(EXT_MCLK_MULT, cfb);
+ cfb->mclk_div = cyber2000_grphr(EXT_MCLK_DIV, cfb);
+#ifdef __arm__
+ if (machine_is_netwinder() || machine_is_shark()) {
+ /*
+ * MCLK on the NetWinder and the Shark is fixed at 75MHz
+ */
+ cfb->mclk_mult = 0xdb;
+ cfb->mclk_div = 0x54;
+ }
+#endif
+
+ err = cyberpro_common_probe(cfb);
+ if (err)
goto failed;
/*
@@ -1672,7 +1874,7 @@
return err;
}
-static void __devexit cyberpro_remove(struct pci_dev *dev)
+static void __devexit cyberpro_pci_remove(struct pci_dev *dev)
{
struct cfb_info *cfb = pci_get_drvdata(dev);
@@ -1701,7 +1903,7 @@
}
}
-static int cyberpro_suspend(struct pci_dev *dev, u32 state)
+static int cyberpro_pci_suspend(struct pci_dev *dev, u32 state)
{
return 0;
}
@@ -1709,41 +1911,44 @@
/*
* Re-initialise the CyberPro hardware
*/
-static int cyberpro_resume(struct pci_dev *dev)
+static int cyberpro_pci_resume(struct pci_dev *dev)
{
struct cfb_info *cfb = pci_get_drvdata(dev);
if (cfb) {
- cyberpro_init_hw(cfb, 0);
-
- /*
- * Restore the old video mode and the palette.
- * We also need to tell fbcon to redraw the console.
- */
- cfb->fb.var.activate = FB_ACTIVATE_NOW;
- cyber2000fb_set_var(&cfb->fb.var, -1, &cfb->fb);
+ cyberpro_pci_enable_mmio(cfb);
+ cyberpro_common_resume(cfb);
}
return 0;
}
static struct pci_device_id cyberpro_pci_table[] __devinitdata = {
+// Not yet
+// { PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_1682,
+// PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_IGA_1682 },
{ PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2000,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_IGS_CYBER2000 },
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_CYBERPRO_2000 },
{ PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_2010,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_IGS_CYBER2010 },
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_CYBERPRO_2010 },
{ PCI_VENDOR_ID_INTERG, PCI_DEVICE_ID_INTERG_5000,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, FB_ACCEL_IGS_CYBER5000 },
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, ID_CYBERPRO_5000 },
{ 0, }
};
+MODULE_DEVICE_TABLE(pci,cyberpro_pci_table);
+
+#ifndef __devexit_p
+#define __devexit_p(x) (x)
+#endif
+
static struct pci_driver cyberpro_driver = {
- name: "CyberPro",
- probe: cyberpro_probe,
- remove: __devexit_p(cyberpro_remove),
- suspend: cyberpro_suspend,
- resume: cyberpro_resume,
- id_table: cyberpro_pci_table
+ .name = "CyberPro",
+ .probe = cyberpro_pci_probe,
+ .remove = __devexit_p(cyberpro_pci_remove),
+ .suspend = cyberpro_pci_suspend,
+ .resume = cyberpro_pci_resume,
+ .id_table = cyberpro_pci_table
};
/*
@@ -1768,5 +1973,4 @@
MODULE_AUTHOR("Russell King");
MODULE_DESCRIPTION("CyberPro 2000, 2010 and 5000 framebuffer driver");
-MODULE_DEVICE_TABLE(pci,cyberpro_pci_table);
MODULE_LICENSE("GPL");
diff -urN linux-2.4.26/drivers/video/cyber2000fb.h linux-2.4.26-vrs1/drivers/video/cyber2000fb.h
--- linux-2.4.26/drivers/video/cyber2000fb.h 2002-08-03 01:39:45.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/cyber2000fb.h 2004-04-19 16:49:24.000000000 +0100
@@ -36,24 +36,55 @@
#define debug_printf(x...) do { } while (0)
#endif
-#define PIXFORMAT_8BPP 0
-#define PIXFORMAT_16BPP 1
-#define PIXFORMAT_24BPP 2
-#define PIXFORMAT_32BPP 3
-
-#define VISUALID_256 1
-#define VISUALID_64K 2
-#define VISUALID_16M_32 3
-#define VISUALID_16M 4
-#define VISUALID_32K 6
-
-#define FUNC_CTL 0x3c
-#define FUNC_CTL_EXTREGENBL 0x80 /* enable access to 0xbcxxx */
-
-#define BIU_BM_CONTROL 0x3e
-#define BIU_BM_CONTROL_ENABLE 0x01 /* enable bus-master */
-#define BIU_BM_CONTROL_BURST 0x02 /* enable burst */
-#define BIU_BM_CONTROL_BACK2BACK 0x04 /* enable back to back */
+#define RAMDAC_RAMPWRDN 0x01
+#define RAMDAC_DAC8BIT 0x02
+#define RAMDAC_VREFEN 0x04
+#define RAMDAC_BYPASS 0x10
+#define RAMDAC_DACPWRDN 0x40
+
+#define EXT_CRT_VRTOFL 0x11
+#define EXT_CRT_VRTOFL_LINECOMP10 0x10
+#define EXT_CRT_VRTOFL_INTERLACE 0x20
+
+#define EXT_CRT_IRQ 0x12
+#define EXT_CRT_IRQ_ENABLE 0x01
+#define EXT_CRT_IRQ_ACT_HIGH 0x04
+
+#define EXT_CRT_TEST 0x13
+
+#define EXT_SYNC_CTL 0x16
+#define EXT_SYNC_CTL_HS_NORMAL 0x00
+#define EXT_SYNC_CTL_HS_0 0x01
+#define EXT_SYNC_CTL_HS_1 0x02
+#define EXT_SYNC_CTL_HS_HSVS 0x03
+#define EXT_SYNC_CTL_VS_NORMAL 0x00
+#define EXT_SYNC_CTL_VS_0 0x04
+#define EXT_SYNC_CTL_VS_1 0x08
+#define EXT_SYNC_CTL_VS_COMP 0x0c
+
+#define EXT_BUS_CTL 0x30
+#define EXT_BUS_CTL_LIN_1MB 0x00
+#define EXT_BUS_CTL_LIN_2MB 0x01
+#define EXT_BUS_CTL_LIN_4MB 0x02
+#define EXT_BUS_CTL_ZEROWAIT 0x04
+#define EXT_BUS_CTL_PCIBURST_WRITE 0x20
+#define EXT_BUS_CTL_PCIBURST_READ 0x80 /* CyberPro 5000 only */
+
+#define EXT_SEG_WRITE_PTR 0x31
+#define EXT_SEG_READ_PTR 0x32
+#define EXT_BIU_MISC 0x33
+#define EXT_BIU_MISC_LIN_ENABLE 0x01
+#define EXT_BIU_MISC_COP_ENABLE 0x04
+#define EXT_BIU_MISC_COP_BFC 0x08
+
+#define EXT_FUNC_CTL 0x3c
+#define EXT_FUNC_CTL_EXTREGENBL 0x80 /* enable access to 0xbcxxx */
+
+#define PCI_BM_CTL 0x3e
+#define PCI_BM_CTL_ENABLE 0x01 /* enable bus-master */
+#define PCI_BM_CTL_BURST 0x02 /* enable burst */
+#define PCI_BM_CTL_BACK2BACK 0x04 /* enable back to back */
+#define PCI_BM_CTL_DUMMY 0x08 /* insert dummy cycle */
#define X_V2_VID_MEM_START 0x40
#define X_V2_VID_SRC_WIDTH 0x43
@@ -87,6 +118,19 @@
#define K_CAP_X2_CTL1 0x49
+#define CURS_H_START 0x50
+#define CURS_H_PRESET 0x52
+#define CURS_V_START 0x53
+#define CURS_V_PRESET 0x55
+#define CURS_CTL 0x56
+
+#define EXT_ATTRIB_CTL 0x57
+#define EXT_ATTRIB_CTL_EXT 0x01
+
+#define EXT_OVERSCAN_RED 0x58
+#define EXT_OVERSCAN_GREEN 0x59
+#define EXT_OVERSCAN_BLUE 0x5a
+
#define CAP_X_START 0x60
#define CAP_X_END 0x62
#define CAP_Y_START 0x64
@@ -96,46 +140,112 @@
#define CAP_DDA_Y_INIT 0x6c
#define CAP_DDA_Y_INC 0x6e
-#define MEM_CTL1 0x71
+#define EXT_MEM_CTL0 0x70
+#define EXT_MEM_CTL0_7CLK 0x01
+#define EXT_MEM_CTL0_RAS_1 0x02
+#define EXT_MEM_CTL0_RAS2CAS_1 0x04
+#define EXT_MEM_CTL0_MULTCAS 0x08
+#define EXT_MEM_CTL0_ASYM 0x10
+#define EXT_MEM_CTL0_CAS1ON 0x20
+#define EXT_MEM_CTL0_FIFOFLUSH 0x40
+#define EXT_MEM_CTL0_SEQRESET 0x80
+
+#define EXT_MEM_CTL1 0x71
+#define EXT_MEM_CTL1_PAR 0x00
+#define EXT_MEM_CTL1_SERPAR 0x01
+#define EXT_MEM_CTL1_SER 0x03
+#define EXT_MEM_CTL1_SYNC 0x04
+#define EXT_MEM_CTL1_VRAM 0x08
+#define EXT_MEM_CTL1_4K_REFRESH 0x10
+#define EXT_MEM_CTL1_256Kx4 0x00
+#define EXT_MEM_CTL1_512Kx8 0x40
+#define EXT_MEM_CTL1_1Mx16 0x60
-#define MEM_CTL2 0x72
+#define EXT_MEM_CTL2 0x72
+#define MEM_CTL2_SIZE_1MB 0x00
#define MEM_CTL2_SIZE_2MB 0x01
#define MEM_CTL2_SIZE_4MB 0x02
#define MEM_CTL2_SIZE_MASK 0x03
#define MEM_CTL2_64BIT 0x04
+#define EXT_HIDDEN_CTL1 0x73
+
#define EXT_FIFO_CTL 0x74
+#define EXT_SEQ_MISC 0x77
+#define EXT_SEQ_MISC_8 0x01
+#define EXT_SEQ_MISC_16_RGB565 0x02
+#define EXT_SEQ_MISC_32 0x03
+#define EXT_SEQ_MISC_24_RGB888 0x04
+#define EXT_SEQ_MISC_16_RGB555 0x06
+#define EXT_SEQ_MISC_8_RGB332 0x09
+#define EXT_SEQ_MISC_16_RGB444 0x0a
+
+#define EXT_HIDDEN_CTL4 0x7a
+
+#define CURS_MEM_START 0x7e /* bits 23..12 */
+
#define CAP_PIP_X_START 0x80
#define CAP_PIP_X_END 0x82
#define CAP_PIP_Y_START 0x84
#define CAP_PIP_Y_END 0x86
-#define CAP_NEW_CTL1 0x88
+#define EXT_CAP_CTL1 0x88
-#define CAP_NEW_CTL2 0x89
+#define EXT_CAP_CTL2 0x89
+#define EXT_CAP_CTL2_ODDFRAMEIRQ 0x01
+#define EXT_CAP_CTL2_ANYFRAMEIRQ 0x02
#define BM_CTRL0 0x9c
#define BM_CTRL1 0x9d
-#define CAP_MODE1 0xa4
-#define CAP_MODE1_8BIT 0x01 /* enable 8bit capture mode */
-#define CAP_MODE1_CCIR656 0x02 /* CCIR656 mode */
-#define CAP_MODE1_IGNOREVGT 0x04 /* ignore VGT */
-#define CAP_MODE1_ALTFIFO 0x10 /* use alternate FIFO for capture */
-#define CAP_MODE1_SWAPUV 0x20 /* swap UV bytes */
-#define CAP_MODE1_MIRRORY 0x40 /* mirror vertically */
-#define CAP_MODE1_MIRRORX 0x80 /* mirror horizontally */
-
-#define DCLK_MULT 0xb0
-#define DCLK_DIV 0xb1
-#define DCLK_DIV_VFSEL 0x20
-#define MCLK_MULT 0xb2
-#define MCLK_DIV 0xb3
-
-#define CAP_MODE2 0xa5
-
-#define Y_TV_CTL 0xae
+#define EXT_CAP_MODE1 0xa4
+#define EXT_CAP_MODE1_8BIT 0x01 /* enable 8bit capture mode */
+#define EXT_CAP_MODE1_CCIR656 0x02 /* CCIR656 mode */
+#define EXT_CAP_MODE1_IGNOREVGT 0x04 /* ignore VGT */
+#define EXT_CAP_MODE1_ALTFIFO 0x10 /* use alternate FIFO for capture */
+#define EXT_CAP_MODE1_SWAPUV 0x20 /* swap UV bytes */
+#define EXT_CAP_MODE1_MIRRORY 0x40 /* mirror vertically */
+#define EXT_CAP_MODE1_MIRRORX 0x80 /* mirror horizontally */
+
+#define EXT_CAP_MODE2 0xa5
+#define EXT_CAP_MODE2_CCIRINVOE 0x01
+#define EXT_CAP_MODE2_CCIRINVVGT 0x02
+#define EXT_CAP_MODE2_CCIRINVHGT 0x04
+#define EXT_CAP_MODE2_CCIRINVDG 0x08
+#define EXT_CAP_MODE2_DATEND 0x10
+#define EXT_CAP_MODE2_CCIRDGH 0x20
+#define EXT_CAP_MODE2_FIXSONY 0x40
+#define EXT_CAP_MODE2_SYNCFREEZE 0x80
+
+#define EXT_TV_CTL 0xae
+
+#define EXT_DCLK_MULT 0xb0
+#define EXT_DCLK_DIV 0xb1
+#define EXT_DCLK_DIV_VFSEL 0x20
+#define EXT_MCLK_MULT 0xb2
+#define EXT_MCLK_DIV 0xb3
+
+#define EXT_LATCH1 0xb5
+#define EXT_LATCH1_VAFC_EN 0x01 /* enable VAFC */
+
+#define EXT_FEATURE 0xb7
+#define EXT_FEATURE_BUS_MASK 0x07 /* host bus mask */
+#define EXT_FEATURE_BUS_PCI 0x00
+#define EXT_FEATURE_BUS_VL_STD 0x04
+#define EXT_FEATURE_BUS_VL_LINEAR 0x05
+#define EXT_FEATURE_1682 0x20 /* IGS 1682 compatibility */
+
+#define EXT_LATCH2 0xb6
+#define EXT_LATCH2_I2C_CLKEN 0x10
+#define EXT_LATCH2_I2C_CLK 0x20
+#define EXT_LATCH2_I2C_DATEN 0x40
+#define EXT_LATCH2_I2C_DAT 0x80
+
+#define EXT_XT_CTL 0xbe
+#define EXT_XT_CAP16 0x04
+#define EXT_XT_LINEARFB 0x08
+#define EXT_XT_PAL 0x10
#define EXT_MEM_START 0xc0 /* ext start address 21 bits */
#define HOR_PHASE_SHIFT 0xc2 /* high 3 bits */
@@ -160,25 +270,37 @@
#define EXT_VID_FMT_RGB565 0x02
#define EXT_VID_FMT_RGB888_24 0x03
#define EXT_VID_FMT_RGB888_32 0x04
+#define EXT_VID_FMT_RGB8 0x05
+#define EXT_VID_FMT_RGB4444 0x06
+#define EXT_VID_FMT_RGB8T 0x07
#define EXT_VID_FMT_DUP_PIX_ZOON 0x08 /* duplicate pixel zoom */
#define EXT_VID_FMT_MOD_3RD_PIX 0x20 /* modify 3rd duplicated pixel */
#define EXT_VID_FMT_DBL_H_PIX 0x40 /* double horiz pixels */
-#define EXT_VID_FMT_UV128 0x80 /* UV data offset by 128 */
+#define EXT_VID_FMT_YUV128 0x80 /* YUV data offset by 128 */
#define EXT_VID_DISP_CTL1 0xdc
#define EXT_VID_DISP_CTL1_INTRAM 0x01 /* video pixels go to internal RAM */
#define EXT_VID_DISP_CTL1_IGNORE_CCOMP 0x02 /* ignore colour compare registers */
#define EXT_VID_DISP_CTL1_NOCLIP 0x04 /* do not clip to 16235,16240 */
#define EXT_VID_DISP_CTL1_UV_AVG 0x08 /* U/V data is averaged */
-#define EXT_VID_DISP_CTL1_Y128 0x10 /* Y data offset by 128 */
-#define EXT_VID_DISP_CTL1_VINTERPOL_OFF 0x20 /* vertical interpolation off */
+#define EXT_VID_DISP_CTL1_Y128 0x10 /* Y data offset by 128 (if YUV128 set) */
+#define EXT_VID_DISP_CTL1_VINTERPOL_OFF 0x20 /* disable vertical interpolation */
#define EXT_VID_DISP_CTL1_FULL_WIN 0x40 /* video out window full */
#define EXT_VID_DISP_CTL1_ENABLE_WINDOW 0x80 /* enable video window */
#define EXT_VID_FIFO_CTL1 0xdd
+#define EXT_VID_FIFO_CTL1_OE_HIGH 0x02
+#define EXT_VID_FIFO_CTL1_INTERLEAVE 0x04 /* enable interleaved memory read */
+
+#define EXT_ROM_UCB4GH 0xe5
+#define EXT_ROM_UCB4GH_FREEZE 0x02 /* capture frozen */
+#define EXT_ROM_UCB4GH_ODDFRAME 0x04 /* 1 = odd frame captured */
+#define EXT_ROM_UCB4GH_1HL 0x08 /* first horizonal line after VGT falling edge */
+#define EXT_ROM_UCB4GH_ODD 0x10 /* odd frame indicator */
+#define EXT_ROM_UCB4GH_INTSTAT 0x20 /* video interrupt */
#define VFAC_CTL1 0xe8
-#define VFAC_CTL1_CAPTURE 0x01 /* capture enable */
+#define VFAC_CTL1_CAPTURE 0x01 /* capture enable (only when VSYNC high)*/
#define VFAC_CTL1_VFAC_ENABLE 0x02 /* vfac enable */
#define VFAC_CTL1_FREEZE_CAPTURE 0x04 /* freeze capture */
#define VFAC_CTL1_FREEZE_CAPTURE_SYNC 0x08 /* sync freeze capture */
@@ -197,6 +319,13 @@
#define VFAC_CTL2_INVERT_OVSYNC 0x80 /* invert other vsync input */
#define VFAC_CTL3 0xea
+#define VFAC_CTL3_CAP_LARGE_FIFO 0x01 /* large capture fifo */
+#define VFAC_CTL3_CAP_INTERLACE 0x02 /* capture odd and even fields */
+#define VFAC_CTL3_CAP_HOLD_4NS 0x00 /* hold capture data for 4ns */
+#define VFAC_CTL3_CAP_HOLD_2NS 0x04 /* hold capture data for 2ns */
+#define VFAC_CTL3_CAP_HOLD_6NS 0x08 /* hold capture data for 6ns */
+#define VFAC_CTL3_CAP_HOLD_0NS 0x0c /* hold capture data for 0ns */
+#define VFAC_CTL3_CHROMAKEY 0x20 /* capture data will be chromakeyed */
#define VFAC_CTL3_CAP_IRQ 0x40 /* enable capture interrupt */
#define CAP_MEM_START 0xeb /* 18 bits */
@@ -235,26 +364,98 @@
#define BM_COUNT 0xbc090 /* read-only */
/*
- * Graphics Co-processor
+ * TV registers
*/
-#define CO_CMD_L_PATTERN_FGCOL 0x8000
-#define CO_CMD_L_INC_LEFT 0x0004
-#define CO_CMD_L_INC_UP 0x0002
-
-#define CO_CMD_H_SRC_PIXMAP 0x2000
-#define CO_CMD_H_BLITTER 0x0800
+#define TV_VBLANK_EVEN_START 0xbe43c
+#define TV_VBLANK_EVEN_END 0xbe440
+#define TV_VBLANK_ODD_START 0xbe444
+#define TV_VBLANK_ODD_END 0xbe448
+#define TV_SYNC_YGAIN 0xbe44c
+#define TV_UV_GAIN 0xbe450
+#define TV_PED_UVDET 0xbe454
+#define TV_UV_BURST_AMP 0xbe458
+#define TV_HSYNC_START 0xbe45c
+#define TV_HSYNC_END 0xbe460
+#define TV_Y_DELAY1 0xbe464
+#define TV_Y_DELAY2 0xbe468
+#define TV_UV_DELAY1 0xbe46c
+#define TV_BURST_START 0xbe470
+#define TV_BURST_END 0xbe474
+#define TV_HBLANK_START 0xbe478
+#define TV_HBLANK_END 0xbe47c
+#define TV_PED_EVEN_START 0xbe480
+#define TV_PED_EVEN_END 0xbe484
+#define TV_PED_ODD_START 0xbe488
+#define TV_PED_ODD_END 0xbe48c
+#define TV_VSYNC_EVEN_START 0xbe490
+#define TV_VSYNC_EVEN_END 0xbe494
+#define TV_VSYNC_ODD_START 0xbe498
+#define TV_VSYNC_ODD_END 0xbe49c
+#define TV_SCFL 0xbe4a0
+#define TV_SCFH 0xbe4a4
+#define TV_SCP 0xbe4a8
+#define TV_DELAYBYPASS 0xbe4b4
+#define TV_EQL_END 0xbe4bc
+#define TV_SERR_START 0xbe4c0
+#define TV_SERR_END 0xbe4c4
+#define TV_CTL 0xbe4dc /* reflects a previous register- MVFCLR, MVPCLR etc P241*/
+#define TV_VSYNC_VGA_HS 0xbe4e8
+#define TV_FLICK_XMIN 0xbe514
+#define TV_FLICK_XMAX 0xbe518
+#define TV_FLICK_YMIN 0xbe51c
+#define TV_FLICK_YMAX 0xbe520
+/*
+ * Graphics Co-processor
+ */
#define CO_REG_CONTROL 0xbf011
+#define CO_CTRL_BUSY 0x80
+#define CO_CTRL_CMDFULL 0x04
+#define CO_CTRL_FIFOEMPTY 0x02
+#define CO_CTRL_READY 0x01
+
#define CO_REG_SRC_WIDTH 0xbf018
-#define CO_REG_PIX_FORMAT 0xbf01c
-#define CO_REG_FORE_MIX 0xbf048
-#define CO_REG_FOREGROUND 0xbf058
-#define CO_REG_WIDTH 0xbf060
-#define CO_REG_HEIGHT 0xbf062
+#define CO_REG_PIXFMT 0xbf01c
+#define CO_PIXFMT_32BPP 0x03
+#define CO_PIXFMT_24BPP 0x02
+#define CO_PIXFMT_16BPP 0x01
+#define CO_PIXFMT_8BPP 0x00
+
+#define CO_REG_FGMIX 0xbf048
+#define CO_FG_MIX_ZERO 0x00
+#define CO_FG_MIX_SRC_AND_DST 0x01
+#define CO_FG_MIX_SRC_AND_NDST 0x02
+#define CO_FG_MIX_SRC 0x03
+#define CO_FG_MIX_NSRC_AND_DST 0x04
+#define CO_FG_MIX_DST 0x05
+#define CO_FG_MIX_SRC_XOR_DST 0x06
+#define CO_FG_MIX_SRC_OR_DST 0x07
+#define CO_FG_MIX_NSRC_AND_NDST 0x08
+#define CO_FG_MIX_SRC_XOR_NDST 0x09
+#define CO_FG_MIX_NDST 0x0a
+#define CO_FG_MIX_SRC_OR_NDST 0x0b
+#define CO_FG_MIX_NSRC 0x0c
+#define CO_FG_MIX_NSRC_OR_DST 0x0d
+#define CO_FG_MIX_NSRC_OR_NDST 0x0e
+#define CO_FG_MIX_ONES 0x0f
+
+#define CO_REG_FGCOLOUR 0xbf058
+#define CO_REG_BGCOLOUR 0xbf05c
+#define CO_REG_PIXWIDTH 0xbf060
+#define CO_REG_PIXHEIGHT 0xbf062
#define CO_REG_X_PHASE 0xbf078
#define CO_REG_CMD_L 0xbf07c
+#define CO_CMD_L_PATTERN_FGCOL 0x8000
+#define CO_CMD_L_INC_LEFT 0x0004
+#define CO_CMD_L_INC_UP 0x0002
+
#define CO_REG_CMD_H 0xbf07e
-#define CO_REG_SRC_PTR 0xbf170
+#define CO_CMD_H_BGSRCMAP 0x8000 /* otherwise bg colour */
+#define CO_CMD_H_FGSRCMAP 0x2000 /* otherwise fg colour */
+#define CO_CMD_H_BLITTER 0x0800
+
+#define CO_REG_SRC1_PTR 0xbf170
+#define CO_REG_SRC2_PTR 0xbf174
#define CO_REG_DEST_PTR 0xbf178
#define CO_REG_DEST_WIDTH 0xbf218
@@ -269,6 +470,7 @@
char *fb;
char dev_name[32];
unsigned int fb_size;
+ unsigned int chip_id;
/*
* The following is a pointer to be passed into the
@@ -288,10 +490,19 @@
void (*disable_extregs)(struct cfb_info *);
};
+#define ID_IGA_1682 0
+#define ID_CYBERPRO_2000 1
+#define ID_CYBERPRO_2010 2
+#define ID_CYBERPRO_5000 3
+
+struct fb_var_screeninfo;
+
/*
* Note! Writing to the Cyber20x0 registers from an interrupt
* routine is definitely a bad idea atm.
*/
int cyber2000fb_attach(struct cyberpro_info *info, int idx);
void cyber2000fb_detach(int idx);
-
+void cyber2000fb_enable_extregs(struct cfb_info *cfb);
+void cyber2000fb_disable_extregs(struct cfb_info *cfb);
+void cyber2000fb_get_fb_var(struct cfb_info *cfb, struct fb_var_screeninfo *var);
diff -urN linux-2.4.26/drivers/video/dbmx1fb.c linux-2.4.26-vrs1/drivers/video/dbmx1fb.c
--- linux-2.4.26/drivers/video/dbmx1fb.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/dbmx1fb.c 2004-01-14 21:32:27.000000000 +0000
@@ -0,0 +1,2002 @@
+/******************************************************************************
+ Copyright (C) 2002 Motorola GSG-China
+
+ 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.
+*******************************************************************************/
+/*****************************************************************************
+ * File Name: dbmx1fb.c
+ *
+ * Progammers: Chen Ning, Zhang Juan
+ *
+ * Date of Creations: 10 DEC,2001
+ *
+ * Synopsis:
+ *
+ * Descirption: DB-MX1 LCD controller Linux frame buffer driver
+ * This file is subject to the terms and conditions of the
+ * GNU General Public License. See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ * Modification History:
+ * 10 DEC, 2001, initialization version, frame work for frame buffer driver
+ *
+*******************************************************************************/
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+#include <linux/mm.h>
+#include <linux/tty.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/fb.h>
+#include <linux/delay.h>
+#include <linux/wrapper.h>
+#include <linux/selection.h>
+#include <linux/console.h>
+#include <linux/kd.h>
+#include <linux/vt_kern.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+#include <asm/uaccess.h>
+#include <asm/proc/pgtable.h>
+
+#include <video/fbcon.h>
+#include <video/fbcon-mfb.h>
+#include <video/fbcon-cfb4.h>
+#include <video/fbcon-cfb8.h>
+#include <video/fbcon-cfb16.h>
+
+#include "asm/arch/hardware.h"
+#include "asm/arch/platform.h"
+#include "asm/arch/memory.h"
+
+#include "dbmx1fb.h"
+
+#undef SUP_TTY0
+
+#define LCD_PM
+#ifdef LCD_PM
+#include <linux/pm.h>
+struct pm_dev *pm;
+#endif
+
+// PLAM - make sure fbmem.c also has this defined for full screen frame
+// buffer support in SDRAM
+#define FULL_SCREEN
+
+#undef HARDWARE_CURSOR
+// #undef HARDWARE_CURSOR
+#undef DEBUG
+
+
+/********************************************************************************/
+#ifdef DEBUG
+# define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ## args)
+#define FUNC_START DPRINTK(KERN_ERR"start\n");
+#define FUNC_END DPRINTK(KERN_ERR"end\n");
+#else
+# define DPRINTK(fmt, args...)
+#define FUNC_START
+#define FUNC_END
+#endif
+
+#define _IO_ADDRESS(r) ((r)+0xf0000000)
+unsigned int READREG(unsigned int r)
+{
+ volatile unsigned int * reg;
+ reg = (volatile unsigned int*) _IO_ADDRESS(r);
+ return *reg;
+}
+void WRITEREG(unsigned int r, unsigned int val)
+{
+ volatile unsigned int *reg;
+ reg = (volatile unsigned int*) _IO_ADDRESS(r);
+ *reg = val;
+ return;
+}
+
+#define FONT_DATA ((unsigned char *)font->data)
+struct fbcon_font_desc *font;
+
+/* Local LCD controller parameters */
+struct dbmx1fb_par{
+ u_char *screen_start_address; /* Screen Start Address */
+ u_char *v_screen_start_address;/* Virtul Screen Start Address */
+ unsigned long screen_memory_size; /* screen memory size */
+ unsigned int palette_size;
+ unsigned int max_xres;
+ unsigned int max_yres;
+ unsigned int xres;
+ unsigned int yres;
+ unsigned int xres_virtual;
+ unsigned int yres_virtual;
+ unsigned int max_bpp;
+ unsigned int bits_per_pixel;
+ unsigned int currcon;
+ unsigned int visual;
+ unsigned int TFT :1;
+ unsigned int color :1 ;
+ unsigned int sharp :1 ;
+
+ unsigned short cfb16[16];
+};
+
+#ifdef HARDWARE_CURSOR
+/* hardware cursor parameters */
+struct dbmx1fb_cursor{
+ // int enable;
+ int startx;
+ int starty;
+ int blinkenable;
+ int blink_rate;
+ int width;
+ int height;
+ int color[3];
+ int state;
+};
+
+/* Frame buffer of LCD information */
+struct dbmx1fb_info{
+ struct display_switch dispsw;
+ struct dbmx1fb_cursor cursor;
+};
+#endif // HARDWARE_CURSOR
+
+static u_char* p_framebuffer_memory_address;
+static u_char* v_framebuffer_memory_address;
+
+/* Fake monspecs to fill in fbinfo structure */
+static struct fb_monspecs monspecs __initdata = {
+ 30000, 70000, 50, 65, 0 /* Generic */
+};
+
+/* color map initial */
+static unsigned short __attribute__((unused)) color4map[16] = {
+ 0x0000, 0x000f, 0x00f0, 0x0f2a, 0x0f00, 0x0f0f, 0x0f88, 0x0ccc,
+ 0x0888, 0x00ff, 0x00f8, 0x0f44, 0x0fa6, 0x0f22, 0x0ff0, 0x0fff
+};
+
+static unsigned short gray4map[16] = {
+ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
+ 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f
+};
+
+static struct display global_disp; /* Initial (default) Display Settings */
+static struct fb_info fb_info;
+static struct fb_var_screeninfo init_var = {};
+static struct dbmx1fb_par current_par={ };
+
+/* Frame buffer device API */
+static int dbmx1fb_get_fix(struct fb_fix_screeninfo *fix, int con,
+ struct fb_info *info);
+static int dbmx1fb_get_var(struct fb_var_screeninfo *var, int con,
+ struct fb_info *info);
+static int dbmx1fb_set_var(struct fb_var_screeninfo *var, int con,
+ struct fb_info *info);
+static int dbmx1fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
+ struct fb_info *info);
+static int dbmx1fb_set_cmap(struct fb_cmap *cmap, int kspc, int con,
+ struct fb_info *info);
+
+/* Interface to the low level driver */
+static int dbmx1fb_switch(int con, struct fb_info *info);
+static void dbmx1fb_blank(int blank, struct fb_info *info);
+static int dbmx1fb_updatevar(int con, struct fb_info *info);
+
+/* Internal routines */
+static int _reserve_fb_memory(void);
+static void _install_cmap(int con, struct fb_info *info);
+static void _enable_lcd_controller(void);
+static void _disable_lcd_controller(void);
+static int _encode_var(struct fb_var_screeninfo *var,
+ struct dbmx1fb_par *par);
+static int _decode_var(struct fb_var_screeninfo *var,
+ struct dbmx1fb_par *par);
+
+/* initialization routines */
+static void __init _init_lcd_system(void);
+static int __init _init_lcd(void);
+static void __init _init_fbinfo(void);
+static int __init _reserve_fb_memory(void);
+
+/* frame buffer ops */
+static struct fb_ops dbmx1fb_ops = {
+ owner: THIS_MODULE,
+ fb_get_fix: dbmx1fb_get_fix,
+ fb_get_var: dbmx1fb_get_var,
+ fb_set_var: dbmx1fb_set_var,
+ fb_get_cmap: dbmx1fb_get_cmap,
+ fb_set_cmap: dbmx1fb_set_cmap,
+};
+
+#ifdef HARDWARE_CURSOR
+/* Hardware Cursor */
+static void dbmx1fb_cursor(struct display *p, int mode, int x, int y);
+static int dbmx1fb_set_font(struct display *d, int width, int height);
+static UINT8 cursor_color_map[] = {0xf8};
+static void dbmx1fb_set_cursor_state(struct dbmx1fb_info *fb,UINT32 state);
+static void dbmx1fb_set_cursor(struct dbmx1fb_info *fb);
+static void dbmx1fb_set_cursor_blink(struct dbmx1fb_info *fb,int blink);
+
+struct display_switch dbmx1fb_cfb4 = {
+ setup: fbcon_cfb4_setup,
+ bmove: fbcon_cfb4_bmove,
+ clear: fbcon_cfb4_clear,
+ putc: fbcon_cfb4_putc,
+ putcs: fbcon_cfb4_putcs,
+ revc: fbcon_cfb4_revc,
+ cursor: dbmx1fb_cursor,
+ set_font: dbmx1fb_set_font,
+ fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(16)
+};
+
+struct display_switch dbmx1fb_cfb8 = {
+ setup: fbcon_cfb8_setup,
+ bmove: fbcon_cfb8_bmove,
+ clear: fbcon_cfb8_clear,
+ putc: fbcon_cfb8_putc,
+ putcs: fbcon_cfb8_putcs,
+ revc: fbcon_cfb8_revc,
+ cursor: dbmx1fb_cursor,
+ set_font: dbmx1fb_set_font,
+ fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(16)
+};
+
+struct display_switch dbmx1fb_cfb16 = {
+ setup: fbcon_cfb16_setup,
+ bmove: fbcon_cfb16_bmove,
+ clear: fbcon_cfb16_clear,
+ putc: fbcon_cfb16_putc,
+ putcs: fbcon_cfb16_putcs,
+ revc: fbcon_cfb16_revc,
+ cursor: dbmx1fb_cursor,
+ set_font: dbmx1fb_set_font,
+ fontwidthmask: FONTWIDTH(4)|FONTWIDTH(8)|FONTWIDTH(16)
+};
+#endif // HARDWARE_CURSOR
+
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_getcolreg()
+ *
+ * Input: regno : Color register ID
+ * red : Color map red[]
+ * green : Color map green[]
+ * blue : Color map blue[]
+ * transparent : Flag
+ * info : Fb_info database
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Description: Transfer to fb_xxx_cmap handlers as parameters to
+ * control color registers
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+#define RED 0xf00
+#define GREEN 0xf0
+#define BLUE 0x0f
+static int dbmx1fb_getcolreg(u_int regno, u_int *red, u_int *green,
+ u_int *blue, u_int *trans, struct fb_info *info)
+{
+ unsigned int val;
+
+ FUNC_START;
+
+ if(regno >= current_par.palette_size)
+ return 1;
+
+ val = READREG(DBMX1_LCD_MAPRAM+regno);
+
+ if((current_par.bits_per_pixel == 4)&&(!current_par.color))
+ {
+ *red = *green = *blue = (val & BLUE) << 4;//TODO:
+ *trans = 0;
+ }
+ else
+ {
+ *red = (val & RED) << 4;
+ *green = (val & GREEN) << 8;
+ *blue = (val & BLUE) << 12;
+ *trans = 0;
+ }
+
+ FUNC_END;
+ return 0;
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_setcolreg()
+ *
+ * Input: regno : Color register ID
+ * red : Color map red[]
+ * green : Color map green[]
+ * blue : Color map blue[]
+ * transparent : Flag
+ * info : Fb_info database
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Description: Transfer to fb_xxx_cmap handlers as parameters to
+ * control color registers
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+ *****************************************************************************/
+static int
+dbmx1fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
+ u_int trans, struct fb_info *info)
+{
+ unsigned int val=0;
+ FUNC_START
+ if(regno >= current_par.palette_size)
+ return 1;
+
+ if((current_par.bits_per_pixel == 4)&&(!current_par.color))
+ val = (blue & 0x00f) << 12;//TODO:
+ else
+ {
+ val = (blue >> 12 ) & BLUE;
+ val |= (green >> 8) & GREEN;
+ val |= (red >> 4) & RED;
+ }
+
+ if (regno < 16) {
+ current_par.cfb16[regno] =
+ regno | regno << 5 | regno << 10;
+}
+
+ WRITEREG(DBMX1_LCD_MAPRAM+regno, val);
+ FUNC_END;
+ return 0;
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_get_cmap()
+ *
+ * Input: cmap : Ouput data pointer
+ * kspc : Kernel space flag
+ * con : Console ID
+ * info : Frame buffer information
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Description: Data is copied from hardware or local or system DISPAY,
+ * and copied to cmap.
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int
+dbmx1fb_get_cmap(struct fb_cmap *cmap, int kspc, int con,
+ struct fb_info *info)
+{
+ int err = 0;
+
+ FUNC_START;
+ DPRINTK("current_par.visual=%d\n", current_par.visual);
+ if (con == current_par.currcon)
+ err = fb_get_cmap(cmap, kspc, dbmx1fb_getcolreg, info);
+ else if (fb_display[con].cmap.len)
+ fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2);
+ else
+ fb_copy_cmap(fb_default_cmap(current_par.palette_size),
+ cmap, kspc ? 0 : 2);
+ FUNC_END;
+ return err;
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_set_cmap()
+ *
+ * Input: cmap : Ouput data pointer
+ * kspc : Kernel space flag
+ * con : Console ID
+ * info : Frame buffer information
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Description: Copy data from cmap and copy to DISPLAY. If DISPLAy has no cmap,
+ * allocate memory for it. If DISPLAY is current console and visible,
+ * then hardware color map shall be set.
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int
+dbmx1fb_set_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info)
+{
+ int err = 0;
+
+ FUNC_START;
+ DPRINTK("current_par.visual=%d\n", current_par.visual);
+ if (!fb_display[con].cmap.len)
+ err = fb_alloc_cmap(&fb_display[con].cmap,
+ current_par.palette_size, 0);
+
+ if (!err) {
+ if (con == current_par.currcon)
+ err = fb_set_cmap(cmap, kspc, dbmx1fb_setcolreg,
+ info);
+ fb_copy_cmap(cmap, &fb_display[con].cmap, kspc ? 0 : 1);
+ }
+ FUNC_END;
+ return err;
+}
+/*****************************************************************************
+ * Function Name: dbmx1fb_get_var()
+ *
+ * Input: var : Iuput data pointer
+ * con : Console ID
+ * info : Frame buffer information
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Functions Called: _encode_var()
+ *
+ * Description: Get color map from current, or global display[console]
+ * used by ioctl
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int
+dbmx1fb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
+{
+ if (con == -1) {
+ _encode_var(var, ¤t_par);
+ } else
+ *var = fb_display[con].var;
+ return 0;
+}
+
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_updatevar()
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: Fill in display switch with LCD information,
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int dbmx1fb_updatevar(int con, struct fb_info *info)
+{
+ DPRINTK("entered\n");
+ return 0;
+}
+
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_set_dispsw()
+ *
+ * Input: display : Iuput data pointer
+ * dbmx1fb_info : Frame buffer of LCD information
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: Fill in display switch with LCD information,
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static void dbmx1fb_set_dispsw(struct display *disp
+#ifdef HARDWARE_CURSOR
+ ,struct dbmx1fb_info *info
+#endif
+ )
+{
+ FUNC_START;
+ switch (disp->var.bits_per_pixel) {
+#ifdef HARDWARE_CURSOR
+#ifdef FBCON_HAS_CFB4
+ case 4:
+ fb_info.fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ info->dispsw = dbmx1fb_cfb4;
+ disp->dispsw = &info->dispsw;
+ disp->dispsw_data = NULL;
+ break;
+#endif
+#ifdef FBCON_HAS_CFB8
+ case 8:
+ fb_info.fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ info->dispsw = dbmx1fb_cfb8;
+ disp->dispsw = &info->dispsw;
+ disp->dispsw_data = NULL;
+ break;
+#endif
+#ifdef FBCON_HAS_CFB16
+ case 12:
+ case 16:
+ fb_info.fix.visual = FB_VISUAL_DIRECTCOLOR;
+ info->dispsw = dbmx1fb_cfb16;
+ disp->dispsw = &info->dispsw;
+ disp->dispsw_data = current_par.cfb16;
+ break;
+#endif
+#else //!HARDWARE_CURSOR
+ /* first step disable the hardware cursor */
+#ifdef FBCON_HAS_CFB4
+ case 4:
+ fb_info.fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ disp->dispsw = &fbcon_cfb4;
+ disp->dispsw_data = NULL;
+ break;
+#endif
+#ifdef FBCON_HAS_CFB8
+ case 8:
+ fb_info.fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ disp->dispsw = &fbcon_cfb8;
+ disp->dispsw_data = NULL;
+ break;
+#endif
+#ifdef FBCON_HAS_CFB16
+ case 12:
+ case 16:
+ fb_info.fix.visual = FB_VISUAL_DIRECTCOLOR;
+ disp->dispsw = &fbcon_cfb16;
+ disp->dispsw_data = current_par.cfb16;
+ break;
+#endif
+
+#endif // HARDWARE_CURSOR
+ default:
+ disp->dispsw = &fbcon_dummy;
+ disp->dispsw_data = NULL;
+ }
+#ifdef HARDWARE_CURSOR
+ if (&info->cursor)
+ {
+ info->dispsw.cursor = dbmx1fb_cursor;
+ info->dispsw.set_font = dbmx1fb_set_font;
+ }
+#endif // HARDWARE_CURSOR
+ FUNC_END;
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_set_var()
+ *
+ * Input: var : Iuput data pointer
+ * con : Console ID
+ * info : Frame buffer information
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Functions Called: dbmx1fb_decode_var()
+ * dbmx1fb_encode_var()
+ * dbmx1fb_set_dispsw()
+ *
+ * Description: set current_par by var, also set display data, specially the console
+ * related fileops, then enable the lcd controller, and set cmap to
+ * hardware.
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int
+dbmx1fb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info)
+{
+ struct display *display;
+ int err, chgvar = 0;
+ struct dbmx1fb_par par;
+
+ FUNC_START;
+ if (con >= 0)
+ display = &fb_display[con]; /* Display settings for console */
+ else
+ display = &global_disp; /* Default display settings */
+
+ /* Decode var contents into a par structure, adjusting any */
+ /* out of range values. */
+ if ((err = _decode_var(var, &par))){
+ DPRINTK("decode var error!");
+ return err;
+ }
+
+ // Store adjusted par values into var structure
+ _encode_var(var, &par);
+
+ if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_TEST)
+ return 0;
+
+ else if (((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW) &&
+ ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NXTOPEN))
+ return -EINVAL;
+
+ if (con >= 0) {
+ if ((display->var.xres != var->xres) ||
+ (display->var.yres != var->yres) ||
+ (display->var.xres_virtual != var->xres_virtual) ||
+ (display->var.yres_virtual != var->yres_virtual) ||
+ (display->var.sync != var->sync) ||
+ (display->var.bits_per_pixel != var->bits_per_pixel) ||
+ (memcmp(&display->var.red, &var->red, sizeof(var->red))) ||
+ (memcmp(&display->var.green, &var->green, sizeof(var->green)
+ )) ||
+ (memcmp(&display->var.blue, &var->blue, sizeof(var->blue))))
+ chgvar = 1;
+ }
+
+ display->var = *var;
+ display->screen_base = par.v_screen_start_address;
+ display->visual = par.visual;
+ display->type = FB_TYPE_PACKED_PIXELS;
+ display->type_aux = 0;
+ display->ypanstep = 0;
+ display->ywrapstep = 0;
+ display->line_length =
+ display->next_line = (var->xres * 16) / 8;
+
+ display->can_soft_blank = 1;
+ display->inverse = 0;
+
+ dbmx1fb_set_dispsw(display
+#ifdef HARDWARE_CURSOR
+ , (struct dbmx1fb_info *)info
+#endif // HARDWARE_CURSOR
+ );
+
+ /* If the console has changed and the console has defined */
+ /* a changevar function, call that function. */
+ if (chgvar && info && info->changevar)
+ info->changevar(con); // TODO:
+
+ /* If the current console is selected and it's not truecolor,
+ * update the palette
+ */
+ if ((con == current_par.currcon) &&
+ (current_par.visual != FB_VISUAL_TRUECOLOR)) {
+ struct fb_cmap *cmap;
+
+ current_par = par; // TODO ?
+ if (display->cmap.len)
+ cmap = &display->cmap;
+ else
+ cmap = fb_default_cmap(current_par.palette_size);
+
+ fb_set_cmap(cmap, 1, dbmx1fb_setcolreg, info);
+ }
+
+ /* If the current console is selected, activate the new var. */
+ if (con == current_par.currcon){
+ init_var = *var; // TODO:gcc support structure copy?
+ _enable_lcd_controller();
+ }
+
+ FUNC_END;
+ return 0;
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_get_fix()
+ *
+ * Input: fix : Ouput data pointer
+ * con : Console ID
+ * info : Frame buffer information
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Functions Called: VOID
+ *
+ * Description: get fix from display data, current_par data
+ * used by ioctl
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int
+dbmx1fb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info)
+{
+ struct display *display;
+
+ FUNC_START;
+ memset(fix, 0, sizeof(struct fb_fix_screeninfo));
+ strcpy(fix->id, DBMX1_NAME);
+
+ if (con >= 0)
+ {
+ DPRINTK("Using console specific display for con=%d\n",con);
+ display = &fb_display[con]; /* Display settings for console */
+ }
+ else
+ display = &global_disp; /* Default display settings */
+
+ fix->smem_start = (unsigned long)current_par.screen_start_address;
+ fix->smem_len = current_par.screen_memory_size;
+//printk("dbmx1fb_get_fix, pointer fix: 0x%08x, smem_len: 0x%08x\n",fix,fix->smem_len);
+ fix->type = display->type;
+ fix->type_aux = display->type_aux;
+ fix->xpanstep = 0;
+ fix->ypanstep = display->ypanstep;
+ fix->ywrapstep = display->ywrapstep;
+ fix->visual = display->visual;
+ fix->line_length = display->line_length;
+ fix->accel = FB_ACCEL_NONE;
+
+ FUNC_END;
+ return 0;
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_inter_handler()
+ *
+ * Input:
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: Interrupt handler
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static void dbmx1fb_inter_handler(int irq, void *dev_id, struct pt_regs *regs)
+{
+ unsigned int intsr;
+ FUNC_START;
+ intsr = READREG(DBMX1_LCD_INTSR); // read to clear status
+ printk(KERN_ERR"lcd interrupt!\n");
+ FUNC_END;
+ // handle
+}
+
+#ifdef LCD_PM
+#define PM_OPT " [pm]"
+#define LCD_PMST_RESUME 0
+#define LCD_PMST_SUSPEND 1
+static unsigned int lcd_pm_status = LCD_PMST_RESUME;
+
+void lcd_pm_resume(void)
+{
+ if(lcd_pm_status == LCD_PMST_RESUME)
+ return;
+ WRITEREG(0x21c21c, 0x10000); // light on
+ WRITEREG(DBMX1_LCD_REFMCR, 0xf000002);
+ WRITEREG(DBMX1_LCD_PWMR, 0x00a9008a);
+ lcd_pm_status = LCD_PMST_RESUME;
+// printk(KERN_ERR"lcd resumed\n");
+}
+
+void lcd_pm_suspend(void)
+{
+ unsigned val;
+ if(lcd_pm_status == LCD_PMST_SUSPEND)
+ return;
+ val = READREG(0x20502c);
+ val |= 0x8000;
+ WRITEREG(0x20502c, val);
+ //To produce enough dealy time before trun off the LCDC.
+ for(val=0;val<=600000;val++);
+ val = READREG(0x21c21c);
+ val &= ~0x10000;
+ WRITEREG(0x21c21c, val); // light off
+ WRITEREG(DBMX1_LCD_REFMCR, 0x0);
+ lcd_pm_status = LCD_PMST_SUSPEND;
+// printk(KERN_ERR"lcd suspended\n");
+}
+
+int lcd_pm_handler(struct pm_dev *dev, pm_request_t rqst, void *data)
+{
+ switch(rqst){
+ case PM_RESUME:
+ lcd_pm_resume();
+ break;
+ case PM_SUSPEND:
+ lcd_pm_suspend();
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+#endif // LCD_PM
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_init()
+ *
+ * Input: VOID
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Functions Called: _init_fbinfo()
+ * disable_irq()
+ * enable_irq()
+ * _init_lcd()
+ * dbmx1fb_init_cursor()
+ *
+ * Description: initialization module, all of init routine's entry point
+ * initialize fb_info, init_var, current_par
+ * and setup interrupt, memory, lcd controller
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+int __init dbmx1fb_init(void)
+{
+ int ret;
+#ifdef HARDWARE_CURSOR
+ struct dbmx1fb_info *info;
+#endif // HARDWARE_CURSOR
+
+ _init_lcd_system();
+
+ _init_fbinfo();
+
+ if ((ret = _reserve_fb_memory()) != 0){
+ printk(KERN_ERR"failed for reserved DBMX frame buffer memory\n");
+ return ret;
+ }
+
+#if 0
+ if (request_irq(IRQ_LCD,
+ dbmx1fb_inter_handler,
+ SA_INTERRUPT,
+ DEV_NAME,
+ NULL) != 0) {
+ printk(KERN_ERR "dbmx1fb: failed in request_irq\n");
+ return -EBUSY;
+ }
+
+ disable_irq(IRQ_LCD);
+#endif
+ if (dbmx1fb_set_var(&init_var, -1, &fb_info))
+ ; //current_par.allow_modeset = 0;
+
+ _init_lcd();
+ _enable_lcd_controller();
+
+#ifdef HARDWARE_CURSOR
+ info = kmalloc(sizeof(struct dbmx1fb_info), GFP_KERNEL);
+ if(info == NULL){
+ printk(KERN_ERR"can not kmalloc dbmx1fb_info memory\n");
+ return -1;
+ }
+
+ memset(info,0,sizeof(struct dbmx1fb_info));
+
+ info->cursor.blink_rate = DEFAULT_CURSOR_BLINK_RATE;
+ info->cursor.blinkenable = 0;
+ info->cursor.state = LCD_CURSOR_OFF;
+ WRITEREG(DBMX1_LCD_LCXYP,0x90010001);
+ WRITEREG(DBMX1_LCD_CURBLKCR,0x1F1F0000);
+ WRITEREG(DBMX1_LCD_LCHCC,0x0000F800);
+
+ DPRINTK(KERN_ERR"LCXYP = %x\n",READREG(DBMX1_LCD_LCXYP));
+ DPRINTK(KERN_ERR"CURBLICR = %x\n",READREG(DBMX1_LCD_CURBLKCR));
+ DPRINTK(KERN_ERR"LCHCC = %x\n",READREG(DBMX1_LCD_LCHCC));
+
+ //dbmx1fb_set_cursor(info);
+ //info->cursor = dbmx1fb_init_cursor(info);
+#endif // HARDWARE_CURSOR
+
+ register_framebuffer(&fb_info);
+
+#ifdef LCD_PM
+ pm = pm_register(PM_SYS_DEV, PM_SYS_VGA, lcd_pm_handler);
+ printk("register LCD power management successfully.\n");
+#endif
+#if 0
+ enable_irq(IRQ_LCD); // TODO:
+#endif
+ /* This driver cannot be unloaded at the moment */
+ MOD_INC_USE_COUNT;
+
+ return 0;
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_setup()
+ *
+ * Input: info : VOID
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Functions Called: VOID
+ *
+ * Description: basically, this routine used to parse command line parameters, which
+ * is initialization parameters for lcd controller, such as freq, xres,
+ * yres, and so on
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+int __init dbmx1fb_setup(char *options)
+{
+ FUNC_START;
+ FUNC_END;
+ return 0;
+}
+
+/*****************************************************************************
+ * Function Name: _init_fbinfo()
+ *
+ * Input: VOID
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: while 16bpp is used to store a 12 bits pixels packet, but
+ * it is not a really 16bpp system. maybe in-compatiable with
+ * other system or GUI.There are some field in var which specify
+ * the red/green/blue offset in a 16bit word, just little endian is
+ * concerned
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static void __init _init_fbinfo(void)
+{
+// Thomas Wong add this for debugging
+// *((unsigned char *)0xF5000008) = '&';
+
+ FUNC_START;
+ strcpy(fb_info.modename, DBMX1_NAME);
+ strcpy(fb_info.fontname, "Acorn8x8");
+
+ fb_info.node = -1;
+ fb_info.flags = FBINFO_FLAG_DEFAULT; // Low-level driver is not a module
+ fb_info.fbops = &dbmx1fb_ops;
+ fb_info.monspecs = monspecs;
+ fb_info.disp = &global_disp;
+ fb_info.changevar = NULL;
+ fb_info.switch_con = dbmx1fb_switch;
+ fb_info.updatevar = dbmx1fb_updatevar;
+ fb_info.blank = dbmx1fb_blank;
+
+/*
+ * * setup initial parameters
+ * */
+ memset(&init_var, 0, sizeof(init_var));
+
+ init_var.transp.length = 0;
+ init_var.nonstd = 0;
+ init_var.activate = FB_ACTIVATE_NOW;
+ init_var.xoffset = 0;
+ init_var.yoffset = 0;
+ init_var.height = -1;
+ init_var.width = -1;
+ init_var.vmode = FB_VMODE_NONINTERLACED;
+
+ if (1) {
+ current_par.max_xres = LCD_MAXX;
+ current_par.max_yres = LCD_MAXY;
+ current_par.max_bpp = LCD_MAX_BPP; // 12
+ init_var.red.length = 5; // 5;
+ init_var.green.length = 6; // 6;
+ init_var.blue.length = 5; // 5;
+#ifdef __LITTLE_ENDIAN
+ init_var.red.offset = 11;
+ init_var.green.offset = 5;
+ init_var.blue.offset = 0;
+#endif //__LITTLE_ENDIAN
+ init_var.grayscale = 16; // i suppose, TODO
+ init_var.sync = 0;
+ init_var.pixclock = 171521; // TODO
+ }
+
+ current_par.screen_start_address = NULL;
+ current_par.v_screen_start_address = NULL;
+ current_par.screen_memory_size = MAX_PIXEL_MEM_SIZE;
+// Thomas Wong add this for debugging
+//printk("_init_fbinfo, pointer to current_par: 0x%08x, screen_memory_size: 0x%08x\n", ¤t_par,current_par.screen_memory_size);
+ current_par.currcon = -1; // TODO
+
+ init_var.xres = current_par.max_xres;
+ init_var.yres = current_par.max_yres;
+ init_var.xres_virtual = init_var.xres;
+ init_var.yres_virtual = init_var.yres;
+ init_var.bits_per_pixel = current_par.max_bpp;
+
+ FUNC_END;
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_blank()
+ *
+ * Input: blank : Blank flag
+ * info : Frame buffer database
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: _enable_lcd_controller()
+ * _disable_lcd_controller()
+ *
+ * Description: blank the screen, if blank, disable lcd controller, while if no blank
+ * set cmap and enable lcd controller
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static void
+dbmx1fb_blank(int blank, struct fb_info *info)
+{
+#ifdef SUP_TTY0
+ int i;
+
+ FUNC_START;
+ DPRINTK("blank=%d info->modename=%s\n", blank, info->modename);
+ if (blank) {
+ if (current_par.visual != FB_VISUAL_TRUECOLOR)
+ for (i = 0; i < current_par.palette_size; i++)
+ ; // TODO
+//printk("Disable LCD\n");
+ _disable_lcd_controller();
+ }
+ else {
+ if (current_par.visual != FB_VISUAL_TRUECOLOR)
+ dbmx1fb_set_cmap(&fb_display[current_par.currcon].cmap,
+ 1,
+ current_par.currcon, info);
+//printk("Enable LCD\n");
+ _enable_lcd_controller();
+ }
+ FUNC_END;
+#endif //SUP_TTY0
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_switch()
+ *
+ * Input: info : Frame buffer database
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called:
+ *
+ * Description: Switch to another console
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int dbmx1fb_switch(int con, struct fb_info *info)
+{
+ FUNC_START;
+ if (current_par.visual != FB_VISUAL_TRUECOLOR) {
+ struct fb_cmap *cmap;
+ if (current_par.currcon >= 0) {
+ // Get the colormap for the selected console
+ cmap = &fb_display[current_par.currcon].cmap;
+
+ if (cmap->len)
+ fb_get_cmap(cmap, 1, dbmx1fb_getcolreg, info);
+ }
+ }
+
+ current_par.currcon = con;
+ fb_display[con].var.activate = FB_ACTIVATE_NOW;
+ dbmx1fb_set_var(&fb_display[con].var, con, info);
+ FUNC_END;
+ return 0;
+}
+
+/*****************************************************************************
+ * Function Name: _encode_par()
+ *
+ * Input: var : Input var data
+ * par : LCD controller parameters
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called:
+ *
+ * Description: use current_par to set a var structure
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int _encode_var(struct fb_var_screeninfo *var,
+ struct dbmx1fb_par *par)
+{
+ // Don't know if really want to zero var on entry.
+ // Look at set_var to see. If so, may need to add extra params to par
+
+ // memset(var, 0, sizeof(struct fb_var_screeninfo));
+
+ var->xres = par->xres;
+ var->yres = par->yres;
+ var->xres_virtual = par->xres_virtual;
+ var->yres_virtual = par->yres_virtual;
+
+ var->bits_per_pixel = par->bits_per_pixel;
+
+ DPRINTK("var->bits_per_pixel=%d\n", var->bits_per_pixel);
+ switch(var->bits_per_pixel) {
+ case 2:
+ case 4:
+ case 8:
+ var->red.length = 4;
+ var->green = var->red;
+ var->blue = var->red;
+ var->transp.length = 0;
+ break;
+ case 12: // This case should differ for Active/Passive mode
+ case 16:
+ if (1) {
+ var->red.length = 4;
+ var->blue.length = 4;
+ var->green.length = 4;
+ var->transp.length = 0;
+#ifdef __LITTLE_ENDIAN
+ var->red.offset = 8;
+ var->green.offset = 4;
+ var->blue.offset = 0;
+ var->transp.offset = 0;
+#endif // __LITTLE_ENDIAN
+ }
+ else
+ {
+ var->red.length = 5;
+ var->blue.length = 5;
+ var->green.length = 6;
+ var->transp.length = 0;
+ var->red.offset = 11;
+ var->green.offset = 5;
+ var->blue.offset = 0;
+ var->transp.offset = 0;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+/*****************************************************************************
+ * Function Name: _decode_var
+ *
+ * Input: var : Input var data
+ * par : LCD controller parameters
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: Get the video params out of 'var'. If a value doesn't fit,
+ * round it up,if it's too big, return -EINVAL.
+ *
+ * Cautions: Round up in the following order: bits_per_pixel, xres,
+ * yres, xres_virtual, yres_virtual, xoffset, yoffset, grayscale,
+ * bitfields, horizontal timing, vertical timing.
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int _decode_var(struct fb_var_screeninfo *var,
+ struct dbmx1fb_par *par)
+{
+ *par = current_par;
+
+ if ((par->xres = var->xres) < MIN_XRES)
+ par->xres = MIN_XRES;
+ if ((par->yres = var->yres) < MIN_YRES)
+ par->yres = MIN_YRES;
+ if (par->xres > current_par.max_xres)
+ par->xres = current_par.max_xres;
+ if (par->yres > current_par.max_yres)
+ par->yres = current_par.max_yres;
+ par->xres_virtual =
+ var->xres_virtual < par->xres ? par->xres : var->xres_virtual;
+ par->yres_virtual =
+ var->yres_virtual < par->yres ? par->yres : var->yres_virtual;
+ par->bits_per_pixel = var->bits_per_pixel;
+
+ switch (par->bits_per_pixel) {
+#ifdef FBCON_HAS_CFB4
+ case 4:
+ par->visual = FB_VISUAL_PSEUDOCOLOR;
+ par->palette_size = 16;
+ break;
+#endif
+#ifdef FBCON_HAS_CFB8
+ case 8:
+ par->visual = FB_VISUAL_PSEUDOCOLOR;
+ par->palette_size = 256;
+ break;
+#endif
+#ifdef FBCON_HAS_CFB16
+ case 12: // RGB 444
+ case 16: /* RGB 565 */
+ par->visual = FB_VISUAL_TRUECOLOR;
+ par->palette_size = 0;
+ break;
+#endif
+ default:
+ return -EINVAL;
+ }
+
+ par->screen_start_address =(u_char*)(
+ (u_long)p_framebuffer_memory_address+PAGE_SIZE);
+ par->v_screen_start_address =(u_char*)(
+ (u_long)v_framebuffer_memory_address+PAGE_SIZE);
+
+// Thomas Wong - try to change start address here (map to SRAM, instead of SDRAM)
+#ifndef FULL_SCREEN
+ par->screen_start_address =(u_char*)(0x00300000);
+ par->v_screen_start_address =(u_char*)(0xF0300000);
+#endif
+
+// par->screen_start_address =(u_char*)(0x0BE00000);
+// par->v_screen_start_address =(u_char*)(0xFBE00000);
+
+// par->screen_start_address =(u_char*)(0x12000000);
+// par->v_screen_start_address =(u_char*)(0xF2000000);
+
+ return 0;
+}
+
+
+/*****************************************************************************
+ * Function Name: _reserve_fb_memory()
+ *
+ * Input: VOID
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called:
+ *
+ * Description: get data out of var structure and set related LCD controller registers
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int __init _reserve_fb_memory(void)
+{
+ u_int required_pages;
+ u_int extra_pages;
+ u_int order;
+ struct page *page;
+ char *allocated_region;
+
+ DPRINTK("frame buffer memory size = %x\n", (unsigned int)ALLOCATED_FB_MEM_SIZE);
+ if (v_framebuffer_memory_address != NULL)
+ return -EINVAL;
+
+ /* Find order required to allocate enough memory for framebuffer */
+ required_pages = ALLOCATED_FB_MEM_SIZE >> PAGE_SHIFT;
+ for (order = 0 ; required_pages >> order ; order++) {;}
+ extra_pages = (1 << order) - required_pages;
+
+ if ((allocated_region =
+ (char *)__get_free_pages(GFP_KERNEL | GFP_DMA, order)) == NULL){
+
+ DPRINTK("can not allocated memory\n");
+ return -ENOMEM;
+ }
+
+
+ v_framebuffer_memory_address = (u_char *)allocated_region +
+ (extra_pages << PAGE_SHIFT);
+ p_framebuffer_memory_address = (u_char *)__virt_to_phys(
+ (u_long)v_framebuffer_memory_address);
+#if 0
+ printk(KERN_ERR"Frame buffer __get_free_pages vd:= %x, pd= %x",
+ (unsigned int)v_framebuffer_memory_address,
+ (unsigned int)p_framebuffer_memory_address);
+#endif
+ /* Free all pages that we don't need but were given to us because */
+ /* __get_free_pages() works on powers of 2. */
+ for (;extra_pages;extra_pages--)
+ free_page((u_int)allocated_region + ((extra_pages-1) << PAGE_SHIFT));
+
+ /* Set reserved flag for fb memory to allow it to be remapped into */
+ /* user space by the common fbmem driver using remap_page_range(). */
+ for(page = virt_to_page(v_framebuffer_memory_address);
+ page < virt_to_page(v_framebuffer_memory_address
+ + ALLOCATED_FB_MEM_SIZE);
+ page++)
+ mem_map_reserve(page);
+#if 0
+ /* Remap the fb memory to a non-buffered, non-cached region */
+ v_framebuffer_memory_address = (u_char *)__ioremap(
+ (u_long)p_framebuffer_memory_address,
+ ALLOCATED_FB_MEM_SIZE,
+ L_PTE_PRESENT |
+ L_PTE_YOUNG |
+ L_PTE_DIRTY |
+ L_PTE_WRITE);
+#endif
+ current_par.screen_start_address =(u_char*)(
+ (u_long)p_framebuffer_memory_address+PAGE_SIZE);
+ current_par.v_screen_start_address =(u_char*)(
+ (u_long)v_framebuffer_memory_address+PAGE_SIZE);
+
+ DPRINTK("physical screen start addres: %x\n",
+ (u_long)p_framebuffer_memory_address+PAGE_SIZE);
+
+#ifndef FULL_SCREEN
+// Thomas Wong - we'll try to change the screen start address here
+// printk("\n\rMap LCD screen to SDRAM.\n\r");
+
+ printk("\n\rMap LCD screen to embedded SRAM.\n\r");
+ current_par.screen_start_address =(u_char*)(0x00300000);
+ current_par.v_screen_start_address =(u_char*)(0xF0300000);
+#endif
+
+// printk("\n\rMap LCD screen to SDRAM 0xFBE00000.\n\r");
+// current_par.screen_start_address =(u_char*)(0x0BE00000);
+// current_par.v_screen_start_address =(u_char*)(0xFBE00000);
+
+// printk("\n\rMap LCD screen to SRAM 0x12000000.\n\r");
+// current_par.screen_start_address =(u_char*)(0x12000000);
+// current_par.v_screen_start_address =(u_char*)(0xF2000000);
+
+ return (v_framebuffer_memory_address == NULL ? -EINVAL : 0);
+}
+
+/*****************************************************************************
+ * Function Name: _enable_lcd_controller()
+ *
+ * Input: VOID
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called:
+ *
+ * Description: enable Lcd controller, setup registers,
+ * base on current_par value
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static void _enable_lcd_controller(void)
+{
+ unsigned int val;
+#if 0
+ int i;
+ val =0;
+
+ FUNC_START;
+ _decode_var(&init_var, ¤t_par);
+
+ val = current_par.xres/16;
+ val <<= 20;
+ val += current_par.yres;
+ WRITEREG(DBMX1_LCD_XYMAX, val);
+
+ val=0;
+ val=current_par.xres_virtual /2;
+ WRITEREG(DBMX1_LCD_VPW, val);
+
+ switch(current_par.bits_per_pixel ){
+ case 4: // for gray only
+ for(i=0; i<16; i++){
+ WRITEREG(DBMX1_LCD_MAPRAM+i, gray4map[i]);
+ }
+ WRITEREG(DBMX1_LCD_PANELCFG, PANELCFG_VAL_4);
+ WRITEREG(DBMX1_LCD_VCFG, VCFG_VAL_4);
+ WRITEREG(DBMX1_LCD_HCFG, HCFG_VAL_4);
+ WRITEREG(DBMX1_LCD_INTCR, INTCR_VAL_4); // no interrupt
+ WRITEREG(DBMX1_LCD_REFMCR, REFMCR_VAL_4);
+ WRITEREG(DBMX1_LCD_DMACR, DMACR_VAL_4);
+ WRITEREG(DBMX1_LCD_PWMR, PWMR_VAL);
+ break;
+ case 12:
+ case 16:
+ WRITEREG(DBMX1_LCD_PANELCFG, PANELCFG_VAL_12);
+ WRITEREG(DBMX1_LCD_HCFG, HCFG_VAL_12);
+ WRITEREG(DBMX1_LCD_VCFG, VCFG_VAL_12);
+ WRITEREG(DBMX1_LCD_REFMCR, 0x0);
+ WRITEREG(DBMX1_LCD_DMACR, DMACR_VAL_12);
+ WRITEREG(DBMX1_LCD_PWMR, 0x00008200);
+ WRITEREG(DBMX1_LCD_REFMCR, 0x0f000002);
+ WRITEREG(DBMX1_LCD_PWMR, 0x0000008a);
+
+ break;
+ }
+#else
+ val = READREG(0x21c21c);
+ val |= 0x0010000;
+ WRITEREG(0x21c21c, val);
+
+ WRITEREG(DBMX1_LCD_PWMR, 0x8200);
+ WRITEREG(DBMX1_LCD_REFMCR, 0xf000002);
+
+ // Thomas Wong - we want 0x8A not 0x200
+// WRITEREG(DBMX1_LCD_PWMR, 0x200);
+// PLAM -- for rev2 (endian bit)
+// WRITEREG(DBMX1_LCD_PWMR, 0x0000008A);
+ WRITEREG(DBMX1_LCD_PWMR, 0x00A9008A);
+// end PLAM
+#endif
+
+ FUNC_END;
+}
+
+/*****************************************************************************
+ * Function Name: _disable_lcd_controller()
+ *
+ * Input: VOID
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: just disable the LCD controller
+ * disable lcd interrupt. others, i have no ideas
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static void _disable_lcd_controller(void)
+{
+ unsigned int val;
+ val = READREG(0x21c21c);
+ val &= ~0x0010000;
+ WRITEREG(0x21c21c, val);
+
+ WRITEREG(DBMX1_LCD_PWMR, 0x8200);
+// WRITEREG(DBMX1_LCD_REFMCR, DISABLELCD_VAL);
+ WRITEREG(0x205034, 0x0);
+}
+
+/*****************************************************************************
+ * Function Name: _install_cmap
+ *
+ * Input: VOID
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called:
+ *
+ * Description: set color map to hardware
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static void _install_cmap(int con, struct fb_info *info)
+{
+ if (con != current_par.currcon)
+ return ;
+ if (fb_display[con].cmap.len)
+ fb_set_cmap(&fb_display[con].cmap, 1, dbmx1fb_setcolreg, info);
+ else
+ fb_set_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel),
+ 1,
+ dbmx1fb_setcolreg,
+ info);
+ return ;
+}
+
+/*****************************************************************************
+ * Function Name: _init_lcd_system
+ *
+ * Input: VOID
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called:
+ *
+ * Description: initialize the gpio port C and port D with DMA enable
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static void __init _init_lcd_system(void)
+{
+unsigned int val;
+
+/* Thomas Wong - we don't need DMA here
+ // dma reset & enable
+ val = READREG(0x209000);
+ val |= 0x02;
+ WRITEREG(0x209000, val);
+ val = READREG(0x209000);
+ val |= 0x01;
+ WRITEREG(0x209000, val);
+*/
+ // gpio
+ //clear port D for LCD signal
+ WRITEREG(0x21c320, 0x0);
+ WRITEREG(0x21c338, 0x0);
+
+ val = READREG(0x21c220);
+ val |= 0x10000;
+ WRITEREG(0x21c220, val);
+ val = READREG(0x21c208);
+ val |= 0x03;
+ WRITEREG(0x21c208, val);
+ val = READREG(0x21c200);
+ val |= 0x10000;
+ WRITEREG(0x21c200, val);
+ val = READREG(0x21c238);
+ val |= 0x10000;
+ WRITEREG(0x21c238, val);
+ val = READREG(0x21c21c);
+ val |= 0x10000;
+ WRITEREG(0x21c21c, val);
+
+}
+
+static void set_pclk(unsigned int fmhz)
+{
+ unsigned int div= 96/fmhz;
+ unsigned int reg;
+ reg = READREG(0x21b020);
+ reg &= ~0xf0;
+ WRITEREG(0x21b020, reg);
+ reg |= ((div-1)<<4) &0xf0;
+ WRITEREG(0x21b020, reg);
+}
+
+/*****************************************************************************
+ * Function Name: _init_lcd
+ *
+ * Input: VOID
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: _decode_var()
+ *
+ * Description: initialize the LCD controller, use current_par for 12bpp
+ *
+ * Modification History:
+ * 10 DEC,2001, Chen Ning
+******************************************************************************/
+static int __init _init_lcd()
+{
+
+ unsigned int val, rate;
+ int i;
+ unsigned char * pscr;
+ //unsigned long pclk,temp,PCLKDIV2;
+ //unsigned long MFI,MFN,PD,MFD,tempReg,MCUPLLCLK;
+
+
+ _decode_var(&init_var, ¤t_par);
+
+ // gpio begin
+ val = READREG(0x21c21c);
+ val &= ~0x00010000;
+ WRITEREG(0x21c21c, val);
+ DPRINTK(KERN_ERR"DR=%x\n", READREG(0x21c21c));
+
+ // LCD regs
+ DPRINTK(KERN_ERR"write SSA by %x\n",
+ (unsigned int)current_par.screen_start_address);
+ WRITEREG(DBMX1_LCD_SSA, (unsigned int)current_par.screen_start_address);
+ DPRINTK(KERN_ERR"SSA=%x\n", READREG(DBMX1_LCD_SSA));
+
+ val =0;
+ val = current_par.xres/16;
+ val = val<<20;
+ val += current_par.yres;
+ DPRINTK(KERN_ERR"par.x=%x, y=%x\n",
+ current_par.xres,
+ current_par.yres);
+ WRITEREG(DBMX1_LCD_XYMAX, val);
+ DPRINTK(KERN_ERR"XYMAX=%x\n", READREG(DBMX1_LCD_XYMAX));
+
+ val=0;
+ val=current_par.xres_virtual/2;
+ WRITEREG(DBMX1_LCD_VPW, val);
+ DPRINTK(KERN_ERR"VPW=%x\n", READREG(DBMX1_LCD_VPW));
+
+ set_pclk(4);
+
+ DPRINTK(KERN_ERR"DBMX1_LCD_PANELCFG=%x\n",
+ READREG(DBMX1_LCD_PANELCFG));
+
+ WRITEREG(DBMX1_LCD_HCFG, 0x04000f06);
+ DPRINTK(KERN_ERR"DBMX1_LCD_HCFG=%x\n",
+ READREG(DBMX1_LCD_HCFG));
+
+ WRITEREG(DBMX1_LCD_VCFG, 0x04000907);
+ DPRINTK(KERN_ERR"DBMX1_LCD_VCFG=%x\n",
+ READREG(DBMX1_LCD_VCFG));
+
+ WRITEREG(DBMX1_LCD_REFMCR, 0x0);
+ DPRINTK(KERN_ERR"DBMX1_LCD_REFMCR=%x\n",
+ READREG(DBMX1_LCD_REFMCR));
+
+ WRITEREG(DBMX1_LCD_DMACR, DMACR_VAL_12);
+ DPRINTK(KERN_ERR"DBMX1_LCD_DMACR=%x\n",
+ READREG(DBMX1_LCD_DMACR));
+
+ WRITEREG(DBMX1_LCD_PWMR, 0x00008200);
+ DPRINTK(KERN_ERR"DBMX1_LCD_PWMR=%x\n",
+ READREG(DBMX1_LCD_PWMR));
+
+ // Thomas Wong - we don't want to turn it on here
+ /*
+ WRITEREG(DBMX1_LCD_REFMCR, 0x0f000002)
+ DPRINTK(KERN_ERR"DBMX1_LCD_REFMCR=%x\n",
+ READREG(DBMX1_LCD_REFMCR));
+ */
+
+ WRITEREG(DBMX1_LCD_PWMR, 0x0000008a);
+ DPRINTK(KERN_ERR"DBMX1_LCD_PWMR=%x\n",
+ READREG(DBMX1_LCD_PWMR));
+
+ // Thomas Wong
+ WRITEREG(0x21B020, 0x000B005B);
+// PLAM -- for rev2 (new register and endian bits)
+ WRITEREG(DBMX1_LCD_PANELCFG, 0xF8008B42); // little endian
+// WRITEREG(DBMX1_LCD_PANELCFG, 0xF8048B42); // big endian
+ WRITEREG(DBMX1_LCD_LGPMR, 0x00090300);
+// WRITEREG(DBMX1_LCD_PWMR, 0x0000008A);
+ WRITEREG (DBMX1_LCD_PWMR, 0x009A008A);
+// end PLAM
+
+// PLAM -- for rev2 (new DMACR setting)
+// WRITEREG(DBMX1_LCD_DMACR, 0x800C0002);
+ WRITEREG(DBMX1_LCD_DMACR, 0x00040008);
+//end PLAM
+
+
+#define DMACR_VAL_12 0x800C0002
+
+
+// WRITEREG(DBMX1_LCD_INTCR, INTCR_VAL_12);
+// DPRINTK(KERN_ERR"DBMX1_LCD_INTCR=%x\n",
+// READREG(DBMX1_LCD_INTCR));
+
+ // warm up LCD
+ for(i=0;i<10000000;i++) ;
+
+ // gpio end
+ val = READREG(0x21c21c);
+ val |= 0x00010000;
+ WRITEREG(0x21c21c, val);
+ DPRINTK(KERN_ERR"DR=%x\n",
+ READREG(0x21c21c));
+#if 0
+ // clear screen
+ pscr = current_par.v_screen_start_address;
+ for(i=0; i< (current_par.screen_memory_size - 2*PAGE_SIZE); i++){
+ *pscr++ = 0xff;
+ }
+#endif
+ DPRINTK(KERN_ERR"_init_lcd end \n");
+
+ return 0;
+}
+
+#ifdef HARDWARE_CURSOR
+
+/*
+ * Hardware cursor support
+ */
+ /*****************************************************************************
+ * Function Name: dbmx1fb_set_cursor_color()
+ *
+ * Input: fb : frame buffer database
+ * red : red component level in the cursor
+ * green : green component level in the cursor
+ * blue : blue component level in the cursor
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: Set color of hardware cursor
+ *
+ * Modification History:
+ * 10 DEC,2001, Zhang Juan
+******************************************************************************/
+static void dbmx1fb_set_cursor_color(struct dbmx1fb_info *fb, UINT8 *red, UINT8 *green, UINT8 *blue)
+{
+ struct dbmx1fb_cursor *c = &fb->cursor;
+ UINT32 color;
+
+ FUNC_START;
+ c->color[0] = *red;
+ c->color[1] = *green;
+ c->color[2] = *blue;
+ color = (UINT32)*red;
+ color |= (UINT32)(*green>>5);
+ color |= (UINT32)(*blue>>11);
+
+ WRITEREG(DBMX1_LCD_LCHCC, color);
+ FUNC_END;
+}
+
+ /*****************************************************************************
+ * Function Name: dbmx1fb_set_cursor()
+ *
+ * Input: fb : frame buffer database
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: Load information of hardware cursor
+ *
+ * Modification History:
+ * 10 DEC,2001, Zhang Juan
+******************************************************************************/
+static void dbmx1fb_set_cursor(struct dbmx1fb_info *fb)
+{
+ struct dbmx1fb_cursor *c = &fb->cursor;
+ UINT32 temp,tempReg,x,y;
+
+ FUNC_START;
+ //DPRINTK(KERN_ERR"BLINK_RATE=%x\n",c->blink_rate);
+// DPRINTK(KERN_ERR"width=%x\n",c->width);
+// DPRINTK(KERN_ERR"height=%x\n",c->height);
+
+ x = c->startx << 16;
+ if (c->state == LCD_CURSOR_ON)
+ x |= CURSOR_ON_MASK;
+
+#ifdef FBCON_HAS_CFB4
+ else if(c->state == LCD_CURSOR_REVERSED)
+ x |= CURSOR_REVERSED_MASK;
+ else if(c->state == LCD_CURSOR_ON_WHITE)
+ x |= CURSOR_WHITE_MASK;
+#elif defined(FBCON_HAS_CFB8)||defined(FBCON_HAS_CFB16)
+ else if(c->state == LCD_CURSOR_INVERT_BGD)
+ x |= CURSOR_INVERT_MASK;
+ else if(c->state == LCD_CURSOR_AND_BGD)
+ x |= CURSOR_AND_BGD_MASK;
+ else if(c->state == LCD_CURSOR_OR_BGD)
+ x |= CURSOR_OR_BGD_MASK;
+ else if(c->state == LCD_CURSOR_XOR_BGD)
+ x |= CURSOR_XOR_BGD_MASK;
+#endif
+ else
+ x = c->startx;
+
+ y = c->starty;
+
+ temp = (UINT32)x | (UINT32)y;
+ WRITEREG(DBMX1_LCD_LCXYP, temp);
+ //DPRINTK(KERN_ERR"lcxyp=%x\n",READREG(DBMX1_LCD_LCXYP));
+
+ temp = (UINT32)((c->width<<8) | (c->height));
+ tempReg = (UINT32)((temp<<16) | c->blink_rate);
+
+ WRITEREG(DBMX1_LCD_CURBLKCR, tempReg);
+
+ //c->blink_rate = 10;
+ if (c->blinkenable)
+ dbmx1fb_set_cursor_blink(fb,c->blink_rate);
+ DPRINTK(KERN_ERR"CURBLKCR=%x\n",READREG(DBMX1_LCD_CURBLKCR));
+ FUNC_END;
+}
+
+ /*****************************************************************************
+ * Function Name: dbmx1fb_set_cursor_blink()
+ *
+ * Input: fb : frame buffer database
+ * blink : input blink frequency of cursor
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: Set blink frequency of hardware cursor
+ *
+ * Modification History:
+ * 10 DEC,2001, Zhang Juan
+******************************************************************************/
+static void dbmx1fb_set_cursor_blink(struct dbmx1fb_info *fb,int blink)
+{
+ struct dbmx1fb_cursor *c = &fb->cursor;
+
+ unsigned long temp,tempReg;
+ unsigned long PCD, XMAX, YMAX, PCLKDIV2;
+ unsigned long tempMicroPeriod;
+
+ FUNC_START;
+ DPRINTK(KERN_ERR"dbmx1fb_set_cursor_blink\n");
+
+ if(!c){
+ DPRINTK(KERN_ERR"dangerouts, for c == null\n");
+ }
+ c->blink_rate = blink;
+
+ tempReg = READREG(DBMX1_LCD_XYMAX);
+ XMAX = (tempReg & XMAX_MASK) >> 20;
+ YMAX = tempReg & YMAX_MASK;
+ //XMAX = 240;
+ //YMAX = 320;
+ tempReg = READREG(PCDR);
+ PCLKDIV2 = (tempReg & PCLKDIV2_MASK) >> 4;
+ tempReg = READREG(DBMX1_LCD_PANELCFG);
+ PCD = tempReg & PCD_MASK;
+
+ temp = (PCLKDIV2 + 1);
+
+ if (!blink)
+ {
+ /* disable the blinking cursor function when frequency is 0 */
+ tempReg = READREG(DBMX1_LCD_CURBLKCR);
+ tempReg &= CURSORBLINK_DIS_MASK;
+ WRITEREG(DBMX1_LCD_CURBLKCR,tempReg);
+ }
+ else
+ {
+
+ tempMicroPeriod = temp * XMAX * YMAX * (PCD + 1);
+ temp = 96*10000000/(blink * tempMicroPeriod);
+ tempReg = READREG(DBMX1_LCD_CURBLKCR);
+ tempReg |= CURSORBLINK_EN_MASK;
+ tempReg |= temp;
+ WRITEREG(DBMX1_LCD_CURBLKCR,tempReg);
+ DPRINTK(KERN_ERR"Inter_CURBLKCR=%x\n",READREG(DBMX1_LCD_CURBLKCR));
+ }
+
+ FUNC_END;
+}
+
+ /*****************************************************************************
+ * Function Name: dbmx1fb_set_cursor_state()
+ *
+ * Input: fb : frame buffer database
+ * state : The status of the cursor to be set. e.g.
+ * LCD_CURSOR_OFF
+ * LCD_CURSOR_ON
+ * LCD_CURSOR_REVERSED
+ * LCD_CURSOR_ON_WHITE
+ * LCD_CURSOR_OR_BGD
+ * LCD_CURSOR_XOR_BGD
+ * LCD_CURSOR_AND_BGD
+ *
+ * Value Returned: VOID
+ *
+ * Functions Called: VOID
+ *
+ * Description: Set state of cursor
+ *
+ * Modification History:
+ * 10 DEC,2001, Zhang Juan
+******************************************************************************/
+static void dbmx1fb_set_cursor_state(struct dbmx1fb_info *fb,UINT32 state)
+{
+ struct dbmx1fb_cursor *c = &fb->cursor;
+ UINT32 temp;
+
+ FUNC_START;
+ c->state = state;
+ temp = READREG(DBMX1_LCD_LCXYP);
+ temp &= CURSOR_OFF_MASK;
+
+ if (state == LCD_CURSOR_OFF)
+ temp = temp;
+ else if (state == LCD_CURSOR_ON)
+ temp |= CURSOR_ON_MASK;
+#ifdef FBCON_HAS_CFB4
+ else if (state == LCD_CURSOR_REVERSED)
+ temp |= CURSOR_REVERSED_MASK;
+ else if (state == LCD_CURSOR_ON_WHITE)
+ temp |= CURSOR_WHITE_MASK;
+#elif defined(FBCON_HAS_CFB8)||defined(FBCON_HAS_CFB16)
+ else if(state == LCD_CURSOR_INVERT_BGD)
+ temp |= CURSOR_INVERT_MASK;
+ else if (state == LCD_CURSOR_OR_BGD)
+ temp |= CURSOR_OR_BGD_MASK;
+ else if (state == LCD_CURSOR_XOR_BGD)
+ temp |= CURSOR_XOR_BGD_MASK;
+ else if (state == LCD_CURSOR_AND_BGD)
+ temp |= CURSOR_AND_BGD_MASK;
+#endif
+ WRITEREG(DBMX1_LCD_LCXYP,temp);
+ DPRINTK(KERN_ERR"LCDXYP=%x\n",READREG(DBMX1_LCD_LCXYP));
+ FUNC_END;
+}
+
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_cursor()
+ *
+ * Input: fb : frame buffer database
+ *
+ * Value Returned: cursor : The structure of hardware cursor
+ *
+ * Functions Called: dbmx1fb_set_cursor()
+ * dbmx1fb_set_cursor_state()
+ *
+ * Description: The entry for display switch to operate hardware cursor
+ *
+ * Modification History:
+ * 10 DEC,2001, Zhang Juan
+******************************************************************************/
+static void dbmx1fb_cursor(struct display *p, int mode, int x, int y)
+{
+ struct dbmx1fb_info *fb = (struct dbmx1fb_info *)p->fb_info;
+ struct dbmx1fb_cursor *c = &fb->cursor;
+
+ FUNC_START;
+ if (c==0) return;
+
+
+ x *= fontwidth(p);
+ y *= fontheight(p);
+
+ c->startx = x;
+ c->starty = y;
+
+ switch (mode) {
+ case CM_ERASE:
+ dbmx1fb_set_cursor_state(fb,LCD_CURSOR_OFF);
+ break;
+
+ case CM_DRAW:
+ case CM_MOVE:
+ c->state = LCD_CURSOR_ON;
+ dbmx1fb_set_cursor(fb);
+ dbmx1fb_set_cursor_state(fb, c->state);
+ break;
+ }
+ FUNC_END;
+}
+
+/*****************************************************************************
+ * Function Name: dbmx1fb_set_font()
+ *
+ * Input: display : console datebase
+ * width : The new width of cursor to be set.
+ * height : The new height of cursor position to be set
+ *
+ * Value Returned: int : Return status.If no error, return 0.
+ *
+ * Functions Called: dbmx1fb_set_cursor()
+ * dbmx1fb_set_cursor_color()
+ *
+ * Description: Set font for cursor
+ *
+ * Modification History:
+ * 10 DEC,2001, Zhang Juan
+******************************************************************************/
+static int dbmx1fb_set_font(struct display *d, int width, int height)
+{
+ struct dbmx1fb_info *fb=(struct dbmx1fb_info *)d->fb_info;
+ struct dbmx1fb_cursor *c = &fb->cursor;
+
+ FUNC_START;
+ if(!d){
+ printk(KERN_ERR"dbmx1fb_set_font d=null\n");
+ return -1;
+ }
+
+ if (c) {
+ if (!width || !height) {
+ width = 16;
+ height = 16;
+ }
+
+ c->width = width;
+ c->height = height;
+
+ DPRINTK(KERN_ERR"set cursor\n");
+ dbmx1fb_set_cursor(fb);
+ DPRINTK(KERN_ERR"set color cursor\n");
+ dbmx1fb_set_cursor_color(fb, cursor_color_map,
+ cursor_color_map, cursor_color_map);
+ }else{
+ DPRINTK(KERN_ERR"set cursor failed, cursor == null\n");
+ }
+
+ FUNC_END;
+ return 1;
+}
+#endif // HARDWARE_CURSOR
+/* end of file */
+
diff -urN linux-2.4.26/drivers/video/dbmx1fb.h linux-2.4.26-vrs1/drivers/video/dbmx1fb.h
--- linux-2.4.26/drivers/video/dbmx1fb.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/dbmx1fb.h 2004-01-14 21:32:27.000000000 +0000
@@ -0,0 +1,213 @@
+/****************************************************************************
+ *
+ * Copyright (C) 2001, Chen Ning All Rights Reserved
+ *
+ * File Name: dbmx1fb.h
+ *
+ * Progammers: Chen Ning, Zhang Juan
+ *
+ * Date of Creations: 10 DEC,2001
+ *
+ * Synopsis:
+ *
+ * Descirption:
+ *
+ * Modification History:
+ * 10 DEC, 2001, initialization version, frame work for frame buffer driver
+ *
+*******************************************************************************/
+
+#ifndef LCDFB_H
+#define LCDFB_H
+#include "asm/arch/hardware.h"
+#include "asm/arch/platform.h"
+
+typedef signed char BOOLEAN;
+typedef unsigned char UINT8; /* Unsigned 8 bit quantity */
+typedef signed char SINT8; /* Signed 8 bit quantity */
+typedef unsigned short UINT16; /* Unsigned 16 bit quantity */
+typedef signed short SINT16; /* Signed 16 bit quantity */
+typedef unsigned long UINT32; /* Unsigned 32 bit quantity */
+typedef signed long SINT32; /* Signed 32 bit quantity */
+
+typedef volatile BOOLEAN VBOOLEAN;
+typedef volatile UINT8 VUINT8; /* Unsigned 8 bit quantity */
+typedef volatile SINT8 VSINT8; /* Signed 8 bit quantity */
+typedef volatile UINT16 VUINT16; /* Unsigned 16 bit quantity */
+typedef volatile SINT16 VSINT16; /* Signed 16 bit quantity */
+typedef volatile UINT32 VUINT32; /* Unsigned 32 bit quantity */
+typedef volatile SINT32 VSINT32; /* Signed 32 bit quantity */
+
+#define LCDBASE 0x00205000
+#define LCD_REGIONSIZE 0xc00
+
+#define DBMX1_LCD_SSA 0x00205000
+#define DBMX1_LCD_XYMAX 0x00205004
+#define DBMX1_LCD_VPW 0x00205008
+#define DBMX1_LCD_LCXYP 0x0020500c
+#define DBMX1_LCD_CURBLKCR 0x00205010
+#define DBMX1_LCD_LCHCC 0x00205014
+#define DBMX1_LCD_PANELCFG 0x00205018
+#define DBMX1_LCD_HCFG 0x0020501c
+#define DBMX1_LCD_VCFG 0x00205020
+#define DBMX1_LCD_POS 0x00205024
+#define DBMX1_LCD_LGPMR 0x00205028
+#define DBMX1_LCD_PWMR 0x0020502c
+#define DBMX1_LCD_DMACR 0x00205030
+#define DBMX1_LCD_REFMCR 0x00205034
+#define DBMX1_LCD_INTCR 0x00205038
+#define DBMX1_LCD_INTSR 0x00205040
+#define DBMX1_LCD_MAPRAM 0x00205800
+
+#define MPCTL0 0x0021B004
+#define PCDR 0X0021B020
+
+#define SSA DBMX1_LCD_SSA
+#define XYMAX DBMX1_LCD_XYMAX
+#define VPW DBMX1_LCD_VPW
+#define LCXYP DBMX1_LCD_LCXYP
+#define CURBLKCR DBMX1_LCD_CURBLKCR
+#define LCHCC DBMX1_LCD_LCHCC
+#define PANELCFG DBMX1_LCD_PANELCFG
+#define VCFG DBMX1_LCD_VCFG
+#define HCFG DBMX1_LCD_HCFG
+#define POS DBMX1_LCD_POS
+#define LGPMR DBMX1_LCD_LGPMR
+#define PWMR DBMX1_LCD_PWMR
+#define DMACR DBMX1_LCD_DMACR
+#define REFMCR DBMX1_LCD_REFMCR
+#define INTCR DBMX1_LCD_INTCR
+#define INTSR DBMX1_LCD_INTSR
+#define MAPRAM DBMX1_LCD_MAPRAM
+// default value
+#define SHARP_TFT_240x320
+
+#ifdef SHARP_TFT_240x320
+#define PANELCFG_VAL_12 0xf8008b48
+#define HCFG_VAL_12 0x04000f06
+#define VCFG_VAL_12 0x04000907
+#define PWMR_VAL 0x0000008a
+#define LCD_MAXX 240
+#define LCD_MAXY 320
+#else //SHARP_TFT_240x320
+
+#define PANELCFG_VAL_12 0xf8088c6b
+#define HCFG_VAL_12 0x04000f06
+#define VCFG_VAL_12 0x04010c03
+#define PWMR_VAL 0x00000200
+#define LCD_MAXX 320
+#define LCD_MAXY 240
+#endif // SHARP_TFT_240x320
+
+#define PANELCFG_VAL_4 0x20008c09
+#define PANELCFG_VAL_4C 0x60008c09
+
+#define HCFG_VAL_4 0x04000f07
+
+#define VCFG_VAL_4 0x04010c03
+
+
+#define REFMCR_VAL_4 0x00000003
+#define REFMCR_VAL_12 0x00000003
+#define DISABLELCD_VAL 0x00000000
+
+#define DMACR_VAL_4 0x800c0003 // 12 & 3 TRIGGER
+#define DMACR_VAL_12 0x00020008
+
+#define INTCR_VAL_4 0x00000000
+#define INTCR_VAL_12 0x00000000
+
+#define INTSR_UDRERR 0x00000008
+#define INTSR_ERRRESP 0x00000004
+#define INTSR_EOF 0x00000002
+#define INTSR_BOF 0x00000001
+
+#define MIN_XRES 64
+#define MIN_YRES 64
+
+#define LCD_MAX_BPP 16
+
+#if 0
+#define READREG(r) \
+ inl(IO_ADDRESS(r))
+
+#define WRITEREG(r, val) \
+ outl(val, IO_ADDRESS(r))
+#else
+#endif // 0
+
+#define MAX_PALETTE_NUM_ENTRIES 256
+#define MAX_PIXEL_MEM_SIZE \
+ ((current_par.max_xres * current_par.max_yres * current_par.max_bpp)/8)
+#define MAX_FRAMEBUFFER_MEM_SIZE \
+ (MAX_PIXEL_MEM_SIZE + 32)
+#define ALLOCATED_FB_MEM_SIZE \
+ (PAGE_ALIGN(MAX_FRAMEBUFFER_MEM_SIZE + PAGE_SIZE * 2))
+
+ // TODO:
+#define FBCON_HAS_CFB4
+#define FBCON_HAS_CFB8
+#define FBCON_HAS_CFB16
+
+#define IRQ_LCD 12 // TODO: which irq?
+#define DBMX1_NAME "DBMX1FB"
+#define DEV_NAME DBMX1_NAME
+#define MAX_PALETTE_NUM_ENTRIES 256
+#define DEFAULT_CURSOR_BLINK_RATE (20)
+#define CURSOR_DRAW_DELAY (2)
+/*cursor status*/
+#define LCD_CURSOR_OFF 0
+#define LCD_CURSOR_ON 1
+
+#ifdef FBCON_HAS_CFB4
+ #define LCD_CURSOR_REVERSED 2
+ #define LCD_CURSOR_ON_WHITE 3
+#elif defined(FBCON_HAS_CFB8) || defined(FBCON_HAS_CFB16)
+ #define LCD_CURSOR_INVERT_BGD 2
+ #define LCD_CURSOR_AND_BGD 3
+ #define LCD_CURSOR_OR_BGD 4
+ #define LCD_CURSOR_XOR_BGD 5
+#endif //FBCON_HAS_CFB4
+
+/* MASK use for caculating MCDUPLLCLK */
+#define MFI_MASK 0x00003C00
+#define MFN_MASK 0x000003FF
+#define PD_MASK 0x3C000000
+#define MFD_MASK 0x03FF0000
+#define PCLKDIV2_MASK 0x000000F0
+#define PCD_MASK 0x0000003F
+#define XMAX_MASK 0xF3F00000
+#define YMAX_MASK 0x000001FF
+#define HWAIT1_MASK 0x0000FF00
+#define HWAIT2_MASK 0x000000FF
+#define HWIDTH_MASK 0xFC000000
+#define PASSDIV_MASK 0x00FF0000
+#define VWAIT1_MASK 0x0000FF00
+#define VWAIT2_MASK 0x000000FF
+#define VWIDTH_MASK 0xFC000000
+#define CURSORBLINK_DIS_MASK 0x80000000
+
+#define DISPLAY_MODE_MASK 0x80000000
+
+#define MCU_FREQUENCE 32768
+#define COLOR_MASK 0x40000000
+
+/* MASK use for indicating the cursor status */
+#define CURSOR_ON_MASK 0x40000000
+#define CURSOR_OFF_MASK 0x0FFFFFFF
+#define MAX_CURSOR_WIDTH 31
+#define MAX_CURSOR_HEIGHT 31
+#define CURSORBLINK_EN_MASK 0x80000000
+
+#ifdef FBCON_HAS_CFB4
+#define CURSOR_REVERSED_MASK 0x80000000
+#define CURSOR_WHITE_MASK 0xC0000000
+#else
+#define CURSOR_INVERT_MASK 0x80000000
+#define CURSOR_AND_BGD_MASK 0xC0000000
+#define CURSOR_OR_BGD_MASK 0x50000000
+#define CURSOR_XOR_BGD_MASK 0x90000000
+#endif // FBCON_HAS_CFB4
+
+#endif //LCDFB_H
+
diff -urN linux-2.4.26/drivers/video/fbmem.c linux-2.4.26-vrs1/drivers/video/fbmem.c
--- linux-2.4.26/drivers/video/fbmem.c 2004-02-27 20:03:27.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/video/fbmem.c 2004-02-27 22:56:39.000000000 +0000
@@ -61,7 +61,9 @@
extern int pm2fb_setup(char*);
extern int pm3fb_init(void);
extern int pm3fb_setup(char*);
+extern int clps711xfb_init(void);
extern int cyber2000fb_init(void);
+extern int cyber2000fb_setup(char*);
extern int retz3fb_init(void);
extern int retz3fb_setup(char*);
extern int clgenfb_init(void);
@@ -145,6 +147,8 @@
extern int sstfb_setup(char*);
extern int it8181fb_init(void);
extern int it8181fb_setup(char*);
+extern int anakinfb_init(void);
+extern int dbmx1fb_init(void);
static struct {
const char *name;
@@ -170,11 +174,14 @@
#ifdef CONFIG_FB_AMIGA
{ "amifb", amifb_init, amifb_setup },
#endif
+#ifdef CONFIG_FB_CLPS711X
+ { "clps711xfb", clps711xfb_init, NULL },
+#endif
#ifdef CONFIG_FB_CYBER
{ "cyber", cyberfb_init, cyberfb_setup },
#endif
#ifdef CONFIG_FB_CYBER2000
- { "cyber2000", cyber2000fb_init, NULL },
+ { "cyber2000", cyber2000fb_init, cyber2000fb_setup },
#endif
#ifdef CONFIG_FB_PM2
{ "pm2fb", pm2fb_init, pm2fb_setup },
@@ -226,10 +233,10 @@
#endif
#ifdef CONFIG_FB_S3TRIO
{ "s3trio", s3triofb_init, NULL },
-#endif
+#endif
#ifdef CONFIG_FB_FM2
{ "fm2fb", fm2fb_init, fm2fb_setup },
-#endif
+#endif
#ifdef CONFIG_FB_SIS
{ "sisfb", sisfb_init, sisfb_setup },
#endif
@@ -242,7 +249,7 @@
/*
* Generic drivers that are used as fallbacks
- *
+ *
* These depend on resource management and must be initialized
* _after_ all other frame buffer devices that use resource
* management!
@@ -253,7 +260,7 @@
#endif
#ifdef CONFIG_FB_VESA
{ "vesa", vesafb_init, vesafb_setup },
-#endif
+#endif
/*
* Chipset specific drivers that don't use resource management (yet)
@@ -276,7 +283,7 @@
#endif
#ifdef CONFIG_FB_HGA
{ "hga", hgafb_init, hgafb_setup },
-#endif
+#endif
#ifdef CONFIG_FB_IGA
{ "igafb", igafb_init, igafb_setup },
#endif
@@ -291,7 +298,7 @@
#endif
#ifdef CONFIG_FB_HP300
{ "hpfb", hpfb_init, NULL },
-#endif
+#endif
#ifdef CONFIG_FB_G364
{ "g364", g364fb_init, NULL },
#endif
@@ -307,6 +314,9 @@
#ifdef CONFIG_FB_TX3912
{ "tx3912", tx3912fb_init, NULL },
#endif
+#ifdef CONFIG_FB_ANAKIN
+ { "anakinfb", anakinfb_init, NULL },
+#endif
#ifdef CONFIG_FB_E1355
{ "e1355fb", e1355fb_init, e1355fb_setup },
#endif
@@ -330,10 +340,13 @@
#endif
#ifdef CONFIG_FB_AU1100
{ "au1100fb", au1100fb_init, au1100fb_setup },
-#endif
+#endif
#ifdef CONFIG_FB_IT8181
{ "it8181fb", it8181fb_init, it8181fb_setup },
#endif
+#ifdef CONFIG_FB_DBMX1
+ { "dbmx1fb", dbmx1fb_init, NULL },
+#endif
/*
@@ -342,7 +355,7 @@
#ifdef CONFIG_FB_VGA16
{ "vga16", vga16fb_init, vga16fb_setup },
-#endif
+#endif
#ifdef CONFIG_FB_STI
{ "stifb", stifb_init, stifb_setup },
#endif
@@ -371,7 +384,7 @@
struct fb_info *registered_fb[FB_MAX];
int num_registered_fb;
-extern int fbcon_softback_size;
+extern int fbcon_softback_size;
static int first_fb_vc;
static int last_fb_vc = MAX_NR_CONSOLES-1;
@@ -480,7 +493,7 @@
}
#endif /* CONFIG_KMOD */
-static int
+static int
fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg)
{
@@ -492,7 +505,7 @@
struct fb_fix_screeninfo fix;
struct fb_con2fbmap con2fb;
int i;
-
+
if (! fb)
return -ENODEV;
switch (cmd) {
@@ -576,7 +589,7 @@
}
}
-static int
+static int
fb_mmap(struct file *file, struct vm_area_struct * vma)
{
int fbidx = GET_FB_IDX(file->f_dentry->d_inode->i_rdev);
@@ -667,11 +680,11 @@
#elif defined(__sh__)
pgprot_val(vma->vm_page_prot) &= ~_PAGE_CACHABLE;
#elif defined(__hppa__)
- pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
+ pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
#elif defined(__ia64__)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
#elif defined(__hppa__)
- pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
+ pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
#else
#warning What do we have to do here??
#endif
@@ -724,7 +737,7 @@
return res;
}
-static int
+static int
fb_release(struct inode *inode, struct file *file)
{
int fbidx = GET_FB_IDX(inode->i_rdev);
@@ -856,7 +869,7 @@
*
*/
-void __init
+void __init
fbmem_init(void)
{
int i;
@@ -904,7 +917,7 @@
if (!options || !*options)
return 0;
-
+
if (!strncmp(options, "scrollback:", 11)) {
options += 11;
if (*options) {
@@ -930,7 +943,7 @@
}
return 0;
}
-
+
if (!strncmp(options, "vc:", 3)) {
options += 3;
if (*options)
diff -urN linux-2.4.26/drivers/video/font_acorn_8x8.c linux-2.4.26-vrs1/drivers/video/font_acorn_8x8.c
--- linux-2.4.26/drivers/video/font_acorn_8x8.c 1998-09-30 04:56:33.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/font_acorn_8x8.c 2004-01-14 21:32:27.000000000 +0000
@@ -11,33 +11,33 @@
/* 03 */ 0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00, /* ^C */
/* 04 */ 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, /* ^D */
/* 05 */ 0x00, 0x18, 0x3c, 0xe7, 0xe7, 0x3c, 0x18, 0x00, /* ^E */
-/* 06 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 08 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 09 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 0A */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 0B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 0C */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 0D */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 0E */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 0F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* 06 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 07 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 08 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 09 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 0A */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 0B */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 0C */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 0D */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 0E */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 0F */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
/* 10 */ 0x00, 0x60, 0x78, 0x7e, 0x7e, 0x78, 0x60, 0x00, /* |> */
/* 11 */ 0x00, 0x06, 0x1e, 0x7e, 0x7e, 0x1e, 0x06, 0x00, /* <| */
-/* 12 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 13 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 14 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 15 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 16 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 18 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 19 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 1A */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 1B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 1C */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 1D */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* 12 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 13 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 14 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 15 */ 0x3c, 0x60, 0x3c, 0x66, 0x3c, 0x06, 0x3c, 0x00,
+/* 16 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 17 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 18 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 19 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 1A */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 1B */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 1C */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 1D */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
/* 1E */ 0x00, 0x18, 0x18, 0x3c, 0x3c, 0x7e, 0x7e, 0x00, /* /\ */
/* 1F */ 0x00, 0x7e, 0x7e, 0x3c, 0x3c, 0x18, 0x18, 0x00, /* \/ */
-/* 20 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* */
+/* 20 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* */
/* 21 */ 0x18, 0x3c, 0x3c, 0x18, 0x18, 0x00, 0x18, 0x00, /* ! */
/* 22 */ 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, /* " */
/* 23 */ 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00, /* # */
@@ -132,55 +132,55 @@
/* 7C */ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, /* | */
/* 7D */ 0x30, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x30, 0x00, /* } */
/* 7E */ 0x31, 0x6B, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, /* ~ */
-/* 7F */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* */
-/* 80 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 81 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 82 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 83 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 84 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 85 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 86 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 88 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 89 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 8A */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 8B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 8C */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 8D */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 8E */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 8F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 90 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 91 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 92 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 93 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 94 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 95 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 98 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 99 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 9A */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 9B */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 9C */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 9D */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 9E */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* 9F */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A2 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A4 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A5 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A6 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* A9 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* AA */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* AB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* AC */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* AD */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* AE */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* AF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* 7F */ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /* */
+/* 80 */ 0x3c, 0x66, 0x60, 0x60, 0x66, 0x3c, 0x30, 0x60,
+/* 81 */ 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3e, 0x00,
+/* 82 */ 0x0c, 0x18, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
+/* 83 */ 0x18, 0x66, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
+/* 84 */ 0x66, 0x00, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
+/* 85 */ 0x30, 0x18, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
+/* 86 */ 0x3c, 0x66, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
+/* 87 */ 0x00, 0x00, 0x3c, 0x66, 0x60, 0x66, 0x3c, 0x60,
+/* 88 */ 0x3c, 0x66, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
+/* 89 */ 0x66, 0x00, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
+/* 8A */ 0x30, 0x18, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
+/* 8B */ 0x66, 0x00, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00,
+/* 8C */ 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00,
+/* 8D */ 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00,
+/* 8E */ 0x66, 0x66, 0x00, 0x3c, 0x66, 0x7e, 0x66, 0x00,
+/* 8F */ 0x18, 0x66, 0x00, 0x3c, 0x66, 0x7e, 0x66, 0x00,
+/* 90 */ 0x0c, 0x18, 0x7e, 0x60, 0x7c, 0x60, 0x7e, 0x00,
+/* 91 */ 0x00, 0x00, 0x3f, 0x0d, 0x3f, 0x6c, 0x3f, 0x00,
+/* 92 */ 0x3f, 0x66, 0x66, 0x7f, 0x66, 0x66, 0x67, 0x00,
+/* 93 */ 0x3c, 0x66, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x00,
+/* 94 */ 0x66, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x00,
+/* 95 */ 0x30, 0x18, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x00,
+/* 96 */ 0x3c, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3e, 0x00,
+/* 97 */ 0x30, 0x18, 0x00, 0x66, 0x66, 0x66, 0x3e, 0x00,
+/* 98 */ 0x66, 0x00, 0x66, 0x66, 0x66, 0x3e, 0x06, 0x3c,
+/* 99 */ 0x66, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00,
+/* 9A */ 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
+/* 9B */ 0x08, 0x3e, 0x6b, 0x68, 0x6b, 0x3e, 0x08, 0x00,
+/* 9C */ 0x1c, 0x36, 0x30, 0x7c, 0x30, 0x30, 0x7e, 0x00,
+/* 9D */ 0x66, 0x3c, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00,
+/* 9E */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* 9F */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* A0 */ 0x0c, 0x18, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
+/* A1 */ 0x0c, 0x18, 0x00, 0x38, 0x18, 0x18, 0x3c, 0x00,
+/* A2 */ 0x0c, 0x18, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x00,
+/* A3 */ 0x0c, 0x18, 0x00, 0x66, 0x66, 0x66, 0x3e, 0x00,
+/* A4 */ 0x36, 0x6c, 0x00, 0x7c, 0x66, 0x66, 0x66, 0x00,
+/* A5 */ 0x36, 0x6c, 0x00, 0x66, 0x76, 0x6e, 0x66, 0x00,
+/* A6 */ 0x1c, 0x06, 0x1e, 0x36, 0x1e, 0x00, 0x3e, 0x00,
+/* A7 */ 0x1c, 0x36, 0x36, 0x36, 0x1c, 0x00, 0x3e, 0x00,
+/* A8 */ 0x18, 0x00, 0x18, 0x18, 0x30, 0x66, 0x3c, 0x00,
+/* A9 */ 0x7e, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* AA */ 0x7e, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* AB */ 0x40, 0xc0, 0x40, 0x4f, 0x41, 0x0f, 0x08, 0x0f,
+/* AC */ 0x40, 0xc0, 0x40, 0x48, 0x48, 0x0a, 0x0f, 0x02,
+/* AD */ 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,
+/* AE */ 0x00, 0x33, 0x66, 0xcc, 0xcc, 0x66, 0x33, 0x00,
+/* AF */ 0x00, 0xcc, 0x66, 0x33, 0x33, 0x66, 0xcc, 0x00,
/* B0 */ 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88,
/* B1 */ 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa,
/* B2 */ 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77,
@@ -229,37 +229,37 @@
/* DD */ 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0,
/* DE */ 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
/* DF */ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
-/* E0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* E1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* E2 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* E3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* E4 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* E5 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* E6 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* E7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* E8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* E9 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* EA */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* EB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* EC */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* ED */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* EE */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* EF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F2 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F4 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F5 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F6 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F8 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* F9 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* FA */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* FB */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* FC */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* FD */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-/* FE */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* E0 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* E1 */ 0x3c, 0x66, 0x66, 0x6c, 0x66, 0x66, 0x6c, 0xc0,
+/* E2 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* E3 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* E4 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* E5 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* E6 */ 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x3e, 0x60,
+/* E7 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* E8 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* E9 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* EA */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* EB */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* EC */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* ED */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* EE */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* EF */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* F0 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* F1 */ 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00,
+/* F2 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* F3 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* F4 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* F5 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* F6 */ 0x00, 0x18, 0x00, 0xff, 0x00, 0x18, 0x00, 0x00,
+/* F7 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* F8 */ 0x3c, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
+/* F9 */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* FA */ 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00,
+/* FB */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* FC */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
+/* FD */ 0x38, 0x04, 0x18, 0x20, 0x3c, 0x00, 0x00, 0x00,
+/* FE */ 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00,
/* FF */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
diff -urN linux-2.4.26/drivers/video/pm3fb.c linux-2.4.26-vrs1/drivers/video/pm3fb.c
--- linux-2.4.26/drivers/video/pm3fb.c 2004-04-19 11:44:28.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/pm3fb.c 2004-04-19 17:24:12.000000000 +0100
@@ -5,7 +5,6 @@
* Based on code written by:
* Sven Luther, <luther@dpt-info.u-strasbg.fr>
* Alan Hourihane, <alanh@fairlite.demon.co.uk>
- * Russel King, <rmk@arm.linux.org.uk>
* Based on linux/drivers/video/skeletonfb.c:
* Copyright (C) 1997 Geert Uytterhoeven
* Based on linux/driver/video/pm2fb.c:
@@ -16,14 +15,9 @@
* License. See the file COPYING in the main directory of this archive for
* more details.
*
- * $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $
+ * $Header: /home/pm3fb/pm3fb/pm3fb.c,v 1.139 2001/08/28 08:13:54 dolbeau Exp $
*
* CHANGELOG:
- * Wed Nov 13 11:19:34 MET 2002, v 1.4.11C: option flatpanel: wasn't available in module, fixed.
- * Mon Feb 11 10:35:48 MET 2002, v 1.4.11B: Cosmetic update.
- * Wed Jan 23 14:16:59 MET 2002, v 1.4.11: Preliminary 2.5.x support, patch for 2.5.2.
- * Wed Nov 28 11:08:29 MET 2001, v 1.4.10: potential bug fix for SDRAM-based board, patch for 2.4.16.
- * Thu Sep 20 10:24:42 MET DST 2001, v 1.4.9: sync bug fix, preliminary flatpanel support, better timings.
* Tue Aug 28 10:13:01 MET DST 2001, v 1.4.8: memory timings check, minor bug fixes.
* Wed Jul 18 19:06:14 CEST 2001, v 1.4.7: Mode fix (800x600-100, 1024x768-100 changed), using HW panning + accel bug fix.
* Mon Jun 25 10:33:56 MET DST 2001, v 1.4.6: Depth 12 fix, chip reset ioctl, moved memory erase ioctl to DEBUG.
@@ -54,8 +48,8 @@
*/
#include <linux/config.h>
-#include <linux/module.h>
#include <linux/version.h>
+#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/string.h>
@@ -81,7 +75,6 @@
#include <asm/io.h>
#include <asm/uaccess.h>
-
#ifdef CONFIG_FB_OF
#include <asm/prom.h>
#endif
@@ -129,7 +122,6 @@
unsigned long refresh;
unsigned long powerdown;
};
-typedef enum pm3fb_timing_result { pm3fb_timing_ok, pm3fb_timing_problem, pm3fb_timing_retry } pm3fb_timing_result;
#define PM3FB_UNKNOWN_TIMING_VALUE ((unsigned long)-1)
#define PM3FB_UNKNOWN_TIMINGS { PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE, PM3FB_UNKNOWN_TIMING_VALUE }
@@ -192,21 +184,13 @@
PM3VideoControl_VSYNC_ACTIVE_HIGH
| PM3VideoControl_PIXELSIZE_8BIT}}, {
"1024x768-74-32", {
- 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
- 806, 1024, 0, 32,
- PM3VideoControl_ENABLE |
- PM3VideoControl_HSYNC_ACTIVE_HIGH
- |
- PM3VideoControl_VSYNC_ACTIVE_HIGH
- | PM3VideoControl_PIXELSIZE_32BIT}},
-/* Generated mode : "1600x1024", for the SGI 1600SW flat panel*/
- {
- "SGI1600SW", {
- 108000, 1600, 1024, 16, 56, 104, 1704, 3, 6, 32,
- 1056, 1600, 0, 8,
- PM3VideoControl_ENABLE|
- PM3VideoControl_HSYNC_ACTIVE_LOW|PM3VideoControl_VSYNC_ACTIVE_LOW|
- PM3VideoControl_PIXELSIZE_32BIT}},
+ 78752, 1024, 768, 32, 128, 304, 1328, 1, 4, 38,
+ 806, 1024, 0, 32,
+ PM3VideoControl_ENABLE |
+ PM3VideoControl_HSYNC_ACTIVE_HIGH
+ |
+ PM3VideoControl_VSYNC_ACTIVE_HIGH
+ | PM3VideoControl_PIXELSIZE_32BIT}},
/* ##### auto-generated mode, by fbtimings2pm3 */
/* Generated mode : "640x480-60" */
{
@@ -555,11 +539,9 @@
short noaccel[PM3_MAX_BOARD];
char fontn[PM3_MAX_BOARD][PM3_FONTNAME_SIZE];
short depth[PM3_MAX_BOARD];
-short flatpanel[PM3_MAX_BOARD];
static struct display disp[PM3_MAX_BOARD];
static char g_options[PM3_OPTIONS_SIZE] __initdata = "pm3fb,dummy";
short printtimings = 0;
-short forcesize[PM3_MAX_BOARD];
/* ********************* */
/* ***** prototype ***** */
@@ -567,8 +549,7 @@
/* card-specific */
static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info);
/* permedia3-specific */
-static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info);
-static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info);
+static int pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info);
static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info);
static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info,
unsigned long r);
@@ -684,7 +665,7 @@
NULL, NULL
};
#endif /* KERNEL_2_2 */
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5)
+#ifdef KERNEL_2_4
struct fbgen_hwswitch pm3fb_switch = {
pm3fb_detect, pm3fb_encode_fix, pm3fb_decode_var, pm3fb_encode_var,
pm3fb_get_par, pm3fb_set_par, pm3fb_getcolreg, pm3fb_setcolreg,
@@ -697,7 +678,7 @@
fbgen_get_fix, fbgen_get_var, fbgen_set_var,
fbgen_get_cmap, fbgen_set_cmap, fbgen_pan_display, pm3fb_ioctl, NULL, NULL
};
-#endif /* KERNEL_2_4 or KERNEL_2_5 */
+#endif /* KERNEL_2_4 */
#ifdef PM3FB_USE_ACCEL
#ifdef FBCON_HAS_CFB32
static struct display_switch pm3fb_cfb32 = {
@@ -728,75 +709,52 @@
#endif /* FBCON_HAS_CFB8 */
#endif /* PM3FB_USE_ACCEL */
-/* ****************************** */
-/* ***** card-specific data ***** */
-/* ****************************** */
-struct pm3fb_card_timings {
- unsigned long memsize; /* 0 for last value (i.e. default) */
- struct pm3fb_timings memt;
-};
-
-static struct pm3fb_card_timings t_FormacProFormance3[] = {
- { 16, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} },
- { 0, { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} } /* from 16 MB PF3 */
-};
-
-static struct pm3fb_card_timings t_AppianJeronimo2000[] = {
- { 32, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} },
- { 0, { 0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} } /* from 32MB J2000 */
-};
-
-static struct pm3fb_card_timings t_3DLabsOxygenVX1[] = {
- { 32, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} },
- { 0, { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000} } /* from 32MB VX1 */
-};
-
+/* ********************************** */
+/* ***** card-specific function ***** */
+/* ********************************** */
static struct {
char cardname[32]; /* recognized card name */
u16 subvendor; /* subvendor of the card */
u16 subdevice; /* subdevice of the card */
u8 func; /* function of the card to which the extra init apply */
void (*specific_setup)(struct pm3fb_info *l_fb_info); /* card/func specific setup, done before _any_ FB access */
- struct pm3fb_card_timings *c_memt; /* defauls timings for the boards */
+ struct pm3fb_timings memt; /* default timing for the board WARNING : might be *card* - specific */
} cardbase[] = {
- { "Unknown Permedia3 board", 0xFFFF, 0xFFFF, 0xFF, NULL, NULL },
- { "Appian Jeronimo 2000 head 1", 0x1097, 0x3d32, 1, NULL,
- t_AppianJeronimo2000
- },
+ { "Unknown Permedia3 board", 0xFFFF, 0xFFFF, 0xFF, NULL, PM3FB_UNKNOWN_TIMINGS },
+ { "Appian Jeronimo 2000 head 1", 0x1097, 0x3d32, 1, NULL, PM3FB_UNKNOWN_TIMINGS },
{ "Appian Jeronimo 2000 head 2", 0x1097, 0x3d32, 2, pm3fb_j2000_setup,
- t_AppianJeronimo2000
+ {0x02e311B8, 0x07424905, 0x0c000003, 0x00000061, 0x00000000} /* also in pm3fb_j2000_setup */
},
{ "Formac ProFormance 3", PCI_VENDOR_ID_3DLABS, 0x000a, 0, NULL, /* Formac use 3DLabs ID ?!? */
- t_FormacProFormance3
+ { 0x02e311b8, 0x06100205, 0x08000002, 0x00000079, 0x00000000} /* from the 16Mb ProFormance 3 */
},
- { "3DLabs Permedia3 Create!", PCI_VENDOR_ID_3DLABS, 0x0127, 0, NULL, NULL },
+ { "3DLabs Permedia3 Create!", PCI_VENDOR_ID_3DLABS, 0x0127, 0, NULL, PM3FB_UNKNOWN_TIMINGS },
{ "3DLabs Oxygen VX1 PCI", PCI_VENDOR_ID_3DLABS, 0x0121, 0, NULL,
- t_3DLabsOxygenVX1
+ { 0x30e311b8, 0x08501204, 0x08000002, 0x0000006b, 0x00000000 }
},
- { "3DLabs Oxygen VX1 AGP", PCI_VENDOR_ID_3DLABS, 0x0125, 0, NULL, NULL },
- { "3DLabs Oxygen VX1-16 AGP", PCI_VENDOR_ID_3DLABS, 0x0140, 0, NULL, NULL },
- { "3DLabs Oxygen VX1-1600SW PCI", PCI_VENDOR_ID_3DLABS, 0x0800, 0, NULL, NULL },
- { "\0", 0x0, 0x0, 0, NULL, NULL }
+ { "3DLabs Oxygen VX1 AGP", PCI_VENDOR_ID_3DLABS, 0x0125, 0, NULL, PM3FB_UNKNOWN_TIMINGS },
+ { "3DLabs Oxygen VX1-16 AGP", PCI_VENDOR_ID_3DLABS, 0x0140, 0, NULL, PM3FB_UNKNOWN_TIMINGS },
+ { "3DLabs Oxygen VX1-1600SW PCI", PCI_VENDOR_ID_3DLABS, 0x0800, 0, NULL, PM3FB_UNKNOWN_TIMINGS },
+ { "\0", 0x0, 0x0, 0, NULL, PM3FB_UNKNOWN_TIMINGS }
};
-/* ********************************** */
-/* ***** card-specific function ***** */
-/* ********************************** */
static void pm3fb_j2000_setup(struct pm3fb_info *l_fb_info)
{ /* the appian j2000 require more initialization of the second head */
/* l_fb_info must point to the _second_ head of the J2000 */
DTRACE;
-
- l_fb_info->memt = t_AppianJeronimo2000[0].memt; /* 32 MB, first and only j2000 ? */
+
+ /* Memory timings for the Appian J2000 board. also in cardbase */
+ l_fb_info->memt.caps = 0x02e311B8;
+ l_fb_info->memt.timings = 0x07424905;
+ l_fb_info->memt.control = 0x0c000003;
+ l_fb_info->memt.refresh = 0x00000061;
+ l_fb_info->memt.powerdown = 0x00000000;
pm3fb_write_memory_timings(l_fb_info);
}
-/* *************************************** */
-/* ***** permedia3-specific function ***** */
-/* *************************************** */
-static pm3fb_timing_result pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info)
+static int pm3fb_preserve_memory_timings(struct pm3fb_info *l_fb_info)
{
l_fb_info->memt.caps = PM3_READ_REG(PM3LocalMemCaps);
l_fb_info->memt.timings = PM3_READ_REG(PM3LocalMemTimings);
@@ -811,35 +769,20 @@
(l_fb_info->memt.powerdown == PM3FB_UNKNOWN_TIMING_VALUE))
{
printk(KERN_ERR "pm3fb: invalid memory timings in permedia3 board #%ld\n", l_fb_info->board_num);
- return(pm3fb_try_memory_timings(l_fb_info));
- }
- return(pm3fb_timing_ok);
-}
-
-static pm3fb_timing_result pm3fb_try_memory_timings(struct pm3fb_info *l_fb_info)
-{
- if (cardbase[l_fb_info->board_type].c_memt)
- {
- int i = 0, done = 0;
- while (!done)
+ if ((cardbase[l_fb_info->board_type].memt.caps != PM3FB_UNKNOWN_TIMING_VALUE) &&
+ (cardbase[l_fb_info->board_type].memt.timings != PM3FB_UNKNOWN_TIMING_VALUE) &&
+ (cardbase[l_fb_info->board_type].memt.control != PM3FB_UNKNOWN_TIMING_VALUE) &&
+ (cardbase[l_fb_info->board_type].memt.refresh != PM3FB_UNKNOWN_TIMING_VALUE) &&
+ (cardbase[l_fb_info->board_type].memt.powerdown != PM3FB_UNKNOWN_TIMING_VALUE))
{
- if ((cardbase[l_fb_info->board_type].c_memt[i].memsize == l_fb_info->fb_size)
- || !(cardbase[l_fb_info->board_type].c_memt[i].memsize))
- { /* will use the 0-sized timings by default */
- done = 1;
- l_fb_info->memt = cardbase[l_fb_info->board_type].c_memt[i].memt;
- printk(KERN_WARNING "pm3fb: trying to use predefined memory timings for permedia3 board #%ld (%s, %ld MB)\n",
- l_fb_info->board_num,
- cardbase[l_fb_info->board_type].cardname,
- cardbase[l_fb_info->board_type].c_memt[i].memsize);
- pm3fb_write_memory_timings(l_fb_info);
- return(pm3fb_timing_retry);
- }
- i++;
+ l_fb_info->memt = cardbase[l_fb_info->board_type].memt;
+ printk(KERN_WARNING "pm3fb: trying to use predefined memory timings for permedia3 board #%ld (%s)\n", l_fb_info->board_num, cardbase[l_fb_info->board_type].cardname);
+ pm3fb_write_memory_timings(l_fb_info);
}
- } else
- return(pm3fb_timing_problem);
- return(pm3fb_timing_ok);
+ else
+ return(1);
+ }
+ return(0);
}
static void pm3fb_write_memory_timings(struct pm3fb_info *l_fb_info)
@@ -874,6 +817,10 @@
PM3RD_SClkControl_ENABLE);
}
+/* *************************************** */
+/* ***** permedia3-specific function ***** */
+/* *************************************** */
+
static unsigned long pm3fb_read_dac_reg(struct pm3fb_info *l_fb_info,
unsigned long r)
{
@@ -1068,7 +1015,6 @@
/* write the mode to registers */
static void pm3fb_write_mode(struct pm3fb_info *l_fb_info)
{
- char tempsync = 0x00, tempmisc = 0x00;
DTRACE;
PM3_SLOW_WRITE_REG(PM3MemBypassWriteMask, 0xffffffff);
@@ -1198,26 +1144,22 @@
/*
PM3_SLOW_WRITE_REG(PM3RD_IndexControl, 0x00);
*/
- if ((l_fb_info->current_par->video & PM3VideoControl_HSYNC_MASK) ==
- PM3VideoControl_HSYNC_ACTIVE_HIGH)
- tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH;
- if ((l_fb_info->current_par->video & PM3VideoControl_VSYNC_MASK) ==
- PM3VideoControl_VSYNC_ACTIVE_HIGH)
- tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH;
-
- PM3_WRITE_DAC_REG(PM3RD_SyncControl, tempsync);
- DPRINTK(2, "PM3RD_SyncControl: %d\n", tempsync);
-
- if (flatpanel[l_fb_info->board_num])
{
- PM3_WRITE_DAC_REG(PM3RD_DACControl, PM3RD_DACControl_BLANK_PEDESTAL_ENABLE);
- PM3_WAIT(2);
- PM3_WRITE_REG(PM3VSConfiguration, 0x06);
- PM3_WRITE_REG(0x5a00, 1 << 14); /* black magic... */
- tempmisc = PM3RD_MiscControl_VSB_OUTPUT_ENABLE;
+ char tempsync = 0x00;
+
+ if ((l_fb_info->current_par->
+ video & PM3VideoControl_HSYNC_MASK) ==
+ PM3VideoControl_HSYNC_ACTIVE_HIGH)
+ tempsync |= PM3RD_SyncControl_HSYNC_ACTIVE_HIGH;
+ if ((l_fb_info->current_par->
+ video & PM3VideoControl_VSYNC_MASK) ==
+ PM3VideoControl_VSYNC_ACTIVE_HIGH)
+ tempsync |= PM3RD_SyncControl_VSYNC_ACTIVE_HIGH;
+
+ PM3_WRITE_DAC_REG(PM3RD_SyncControl, tempsync);
+ DPRINTK(2, "PM3RD_SyncControl: %d\n", tempsync);
}
- else
- PM3_WRITE_DAC_REG(PM3RD_DACControl, 0x00);
+ PM3_WRITE_DAC_REG(PM3RD_DACControl, 0x00);
switch (l_fb_info->current_par->depth) {
case 8:
@@ -1226,7 +1168,8 @@
PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
PM3RD_ColorFormat_CI8_COLOR |
PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
- tempmisc |= PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
+ PM3_WRITE_DAC_REG(PM3RD_MiscControl,
+ PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE);
break;
case 12:
PM3_WRITE_DAC_REG(PM3RD_PixelSize,
@@ -1235,8 +1178,9 @@
PM3RD_ColorFormat_4444_COLOR |
PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
- tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
- PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
+ PM3_WRITE_DAC_REG(PM3RD_MiscControl,
+ PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
+ PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE);
break;
case 15:
PM3_WRITE_DAC_REG(PM3RD_PixelSize,
@@ -1245,8 +1189,9 @@
PM3RD_ColorFormat_5551_FRONT_COLOR |
PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
- tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
- PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
+ PM3_WRITE_DAC_REG(PM3RD_MiscControl,
+ PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
+ PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE);
break;
case 16:
PM3_WRITE_DAC_REG(PM3RD_PixelSize,
@@ -1255,8 +1200,9 @@
PM3RD_ColorFormat_565_FRONT_COLOR |
PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW |
PM3RD_ColorFormat_LINEAR_COLOR_EXT_ENABLE);
- tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
- PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
+ PM3_WRITE_DAC_REG(PM3RD_MiscControl,
+ PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
+ PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE);
break;
case 32:
PM3_WRITE_DAC_REG(PM3RD_PixelSize,
@@ -1264,12 +1210,12 @@
PM3_WRITE_DAC_REG(PM3RD_ColorFormat,
PM3RD_ColorFormat_8888_COLOR |
PM3RD_ColorFormat_COLOR_ORDER_BLUE_LOW);
- tempmisc |= PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
- PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE;
+ PM3_WRITE_DAC_REG(PM3RD_MiscControl,
+ PM3RD_MiscControl_DIRECTCOLOR_ENABLE |
+ PM3RD_MiscControl_HIGHCOLOR_RES_ENABLE);
break;
}
- PM3_WRITE_DAC_REG(PM3RD_MiscControl, tempmisc);
-
+
PM3_SHOW_CUR_MODE;
}
@@ -1391,9 +1337,8 @@
static unsigned long pm3fb_size_memory(struct pm3fb_info *l_fb_info)
{
- unsigned long memsize = 0, tempBypass, i, temp1, temp2;
+ unsigned long memsize, tempBypass, i, temp1, temp2;
u16 subvendor, subdevice;
- pm3fb_timing_result ptr;
DTRACE;
@@ -1439,7 +1384,7 @@
/* card-specific setup is done, we preserve the final
memory timing for future reference */
- if ((ptr = pm3fb_preserve_memory_timings(l_fb_info)) == pm3fb_timing_problem) { /* memory timings were wrong ! oops.... */
+ if (pm3fb_preserve_memory_timings(l_fb_info)) { /* memory timings were wrong ! oops.... */
return(0);
}
@@ -1465,12 +1410,12 @@
temp1 = readl((l_fb_info->v_fb + (i * 1048576)));
#endif
#endif /* KERNEL_2_2 */
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5)
+#ifdef KERNEL_2_4
fb_writel(i * 0x00345678,
(l_fb_info->v_fb + (i * 1048576)));
mb();
temp1 = fb_readl((l_fb_info->v_fb + (i * 1048576)));
-#endif /* KERNEL_2_4 or KERNEL_2_5 */
+#endif /* KERNEL_2_4 */
/* Let's check for wrapover, write will fail at 16MB boundary */
if (temp1 == (i * 0x00345678))
memsize = i;
@@ -1513,7 +1458,7 @@
((i - 32) * 1048576)));
#endif
#endif /* KERNEL_2_2 */
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5)
+#ifdef KERNEL_2_4
fb_writel(i * 0x00345678,
(l_fb_info->v_fb + (i * 1048576)));
mb();
@@ -1522,7 +1467,7 @@
temp2 =
fb_readl((l_fb_info->v_fb +
((i - 32) * 1048576)));
-#endif /* KERNEL_2_4 or KERNEL_2_5 */
+#endif /* KERNEL_2_4 */
if ((temp1 == (i * 0x00345678)) && (temp2 == 0)) /* different value, different RAM... */
memsize = i;
else
@@ -1539,21 +1484,8 @@
DPRINTK(2, "Returning 0x%08lx bytes\n", memsize);
- if (forcesize[l_fb_info->board_num] && ((forcesize[l_fb_info->board_num] * 1048576) != memsize))
- {
- printk(KERN_WARNING "pm3fb: mismatch between probed (%ld MB) and specified (%hd MB) memory size, using SPECIFIED !\n", memsize, forcesize[l_fb_info->board_num]);
- memsize = 1048576 * forcesize[l_fb_info->board_num];
- }
-
l_fb_info->fb_size = memsize;
-
- if (ptr == pm3fb_timing_retry)
- {
- printk(KERN_WARNING "pm3fb: retrying memory timings check");
- if (pm3fb_try_memory_timings(l_fb_info) == pm3fb_timing_problem)
- return(0);
- }
-
+
return (memsize);
}
@@ -1572,7 +1504,7 @@
writel(cc, (l_fb_info->v_fb + (i * sizeof(u32))));
#endif
#endif
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5)
+#ifdef KERNEL_2_4
fb_writel(cc, (l_fb_info->v_fb + (i * sizeof(u32))));
#endif
}
@@ -1601,7 +1533,7 @@
disp[l_fb_info->board_num].scrollmode = 0; /* SCROLL_YNOMOVE; *//* 0 means "let fbcon choose" */
l_fb_info->gen.parsize = sizeof(struct pm3fb_par);
l_fb_info->gen.info.changevar = NULL;
- l_fb_info->gen.info.node = B_FREE;
+ l_fb_info->gen.info.node = -1;
l_fb_info->gen.info.fbops = &pm3fb_ops;
l_fb_info->gen.info.disp = &(disp[l_fb_info->board_num]);
if (fontn[l_fb_info->board_num][0])
@@ -1766,7 +1698,6 @@
}
PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xffffffff);
- PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xffffffff);
PM3_SLOW_WRITE_REG(PM3FBWriteMode,
PM3FBWriteMode_WriteEnable |
PM3FBWriteMode_OpaqueSpan |
@@ -1787,7 +1718,9 @@
PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, 4095);
else
PM3_SLOW_WRITE_REG(PM3SizeOfFramebuffer, sofb);
-
+
+ PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xffffffff);
+
switch (l_fb_info->current_par->depth) {
case 8:
PM3_SLOW_WRITE_REG(PM3DitherMode,
@@ -1843,10 +1776,7 @@
height = height * fontheight(p);
c = ((u32 *) p->dispsw_data)[attr_bgcol_ec(p, conp)];
- /* block fills in 32bpp are hard, but in low res (width <= 1600 :-)
- we can use 16bpp operations, but not if NoWriteMask is on (SDRAM) */
- if ((l_fb_info->current_par->width > 1600) ||
- (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)) {
+ if (l_fb_info->current_par->width > 1600) {
PM3_WAIT(4);
PM3_WRITE_REG(PM3Config2D,
@@ -1868,7 +1798,7 @@
PM3Render2D_SpanOperation |
(PM3Render2D_Width(width)) |
(PM3Render2D_Height(height)));
- } else {
+ } else { /* block fills in 32bpp are hard, but in low res (width <= 1600 :-) we can use 16bpp operations */
PM3_WAIT(8);
PM3_WRITE_REG(PM3FBBlockColor, c);
@@ -1993,10 +1923,7 @@
PM3_WAIT(4);
- if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
- PM3_WRITE_REG(PM3ForegroundColor, c);
- else
- PM3_WRITE_REG(PM3FBBlockColor, c);
+ PM3_WRITE_REG(PM3FBBlockColor, c);
PM3_WRITE_REG(PM3Config2D,
PM3Config2D_UseConstantSource |
@@ -2007,23 +1934,14 @@
PM3_WRITE_REG(PM3RectanglePosition,
(PM3RectanglePosition_XOffset(sx)) |
(PM3RectanglePosition_YOffset(sy)));
-
- if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
- PM3_WRITE_REG(PM3Render2D,
- PM3Render2D_XPositive |
- PM3Render2D_YPositive |
- PM3Render2D_Operation_Normal |
- PM3Render2D_SpanOperation |
- (PM3Render2D_Width(width)) |
- (PM3Render2D_Height(height)));
- else
- PM3_WRITE_REG(PM3Render2D,
- PM3Render2D_XPositive |
- PM3Render2D_YPositive |
- PM3Render2D_Operation_Normal |
- (PM3Render2D_Width(width)) |
- (PM3Render2D_Height(height)));
-
+
+ PM3_WRITE_REG(PM3Render2D,
+ PM3Render2D_XPositive |
+ PM3Render2D_YPositive |
+ PM3Render2D_Operation_Normal |
+ (PM3Render2D_Width(width)) |
+ (PM3Render2D_Height(height)));
+
pm3fb_wait_pm3(l_fb_info);
}
@@ -2049,69 +1967,45 @@
PM3Config2D_ForegroundROPEnable |
(PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
PM3Config2D_FBWriteEnable);
-
- if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
- PM3_WRITE_REG(PM3ForegroundColor, c);
- else
- PM3_WRITE_REG(PM3FBBlockColor, c);
-
+
+ PM3_WRITE_REG(PM3FBBlockColor, c);
+
PM3_WRITE_REG(PM3RectanglePosition,
(PM3RectanglePosition_XOffset
(p->var.xoffset +
sx)) | (PM3RectanglePosition_YOffset(p->
var.
yoffset)));
- if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
- PM3_WRITE_REG(PM3Render2D,
- PM3Render2D_XPositive |
- PM3Render2D_YPositive |
- PM3Render2D_Operation_Normal |
- PM3Render2D_SpanOperation |
- (PM3Render2D_Width(p->var.xres - sx)) |
- (PM3Render2D_Height(p->var.yres)));
- else
- PM3_WRITE_REG(PM3Render2D,
- PM3Render2D_XPositive |
- PM3Render2D_YPositive |
- PM3Render2D_Operation_Normal |
- (PM3Render2D_Width(p->var.xres - sx)) |
- (PM3Render2D_Height(p->var.yres)));
+
+ PM3_WRITE_REG(PM3Render2D,
+ PM3Render2D_XPositive |
+ PM3Render2D_YPositive |
+ PM3Render2D_Operation_Normal |
+ (PM3Render2D_Width(p->var.xres - sx)) |
+ (PM3Render2D_Height(p->var.yres)));
}
-
+
/* bottom margin left -> right */
PM3_WAIT(4);
-
+
PM3_WRITE_REG(PM3Config2D,
- PM3Config2D_UseConstantSource |
- PM3Config2D_ForegroundROPEnable |
- (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
- PM3Config2D_FBWriteEnable);
-
- if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
- PM3_WRITE_REG(PM3ForegroundColor, c);
- else
- PM3_WRITE_REG(PM3FBBlockColor, c);
-
-
+ PM3Config2D_UseConstantSource |
+ PM3Config2D_ForegroundROPEnable |
+ (PM3Config2D_ForegroundROP(0x3)) | /* Ox3 is GXcopy */
+ PM3Config2D_FBWriteEnable);
+
+ PM3_WRITE_REG(PM3FBBlockColor, c);
+
PM3_WRITE_REG(PM3RectanglePosition,
(PM3RectanglePosition_XOffset(p->var.xoffset)) |
(PM3RectanglePosition_YOffset(p->var.yoffset + sy)));
-
- if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
- PM3_WRITE_REG(PM3Render2D,
- PM3Render2D_XPositive |
- PM3Render2D_YPositive |
- PM3Render2D_Operation_Normal |
- PM3Render2D_SpanOperation |
- (PM3Render2D_Width(p->var.xres)) |
- (PM3Render2D_Height(p->var.yres - sy)));
- else
- PM3_WRITE_REG(PM3Render2D,
- PM3Render2D_XPositive |
- PM3Render2D_YPositive |
- PM3Render2D_Operation_Normal |
- (PM3Render2D_Width(p->var.xres)) |
- (PM3Render2D_Height(p->var.yres - sy)));
+
+ PM3_WRITE_REG(PM3Render2D,
+ PM3Render2D_XPositive |
+ PM3Render2D_YPositive |
+ PM3Render2D_Operation_Normal |
+ (PM3Render2D_Width(p->var.xres)) |
+ (PM3Render2D_Height(p->var.yres - sy)));
pm3fb_wait_pm3(l_fb_info);
}
@@ -2289,7 +2183,7 @@
int c, int yy, int xx)
{
struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
- u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0;
+ u8 *cdat, asx = 0, asy = 0, o_x, o_y;
u32 fgx, bgx, ldat;
int sx, sy, i;
@@ -2399,7 +2293,7 @@
int xx)
{
struct pm3fb_info *l_fb_info = (struct pm3fb_info *) p->fb_info;
- u8 *cdat, asx = 0, asy = 0, o_x = 0, o_y = 0;
+ u8 *cdat, asx = 0, asy = 0, o_x, o_y;
u32 fgx, bgx, ldat;
int sx, sy, i, j;
u16 sc;
@@ -2517,12 +2411,7 @@
yy = yy * fontheight(p);
if (l_fb_info->current_par->depth == 8)
- {
- if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
- PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0x0F0F0F0F);
- else
- PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0x0F0F0F0F);
- }
+ PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0x0F0F0F0F);
PM3_WAIT(3);
@@ -2548,12 +2437,7 @@
pm3fb_wait_pm3(l_fb_info);
if (l_fb_info->current_par->depth == 8)
- {
- if (l_fb_info->memt.caps & PM3LocalMemCaps_NoWriteMask)
- PM3_SLOW_WRITE_REG(PM3FBSoftwareWriteMask, 0xFFFFFFFF);
- else
- PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xFFFFFFFF);
- }
+ PM3_SLOW_WRITE_REG(PM3FBHardwareWriteMask, 0xFFFFFFFF);
}
#endif /* FBCON_HAS_CFB8 || FBCON_HAS_CFB16 || FBCON_HAS_CFB32 */
@@ -2641,25 +2525,12 @@
unsigned long bd = simple_strtoul(bds, (char **) NULL, 10);
if (!(depth_supported(bd))) {
- printk(KERN_WARNING "pm3fb: ignoring invalid depth %s for board #%ld\n",
- bds, board_num);
+ DPRINTK(1, "Invalid depth: %s\n", bds);
return;
}
depth[board_num] = bd;
}
-static void pm3fb_forcesize_setup(char *bds, unsigned long board_num)
-{
- unsigned long bd = simple_strtoul(bds, (char **) NULL, 10);
-
- if (bd > 64) {
- printk(KERN_WARNING "pm3fb: ignoring invalid memory size %s for board #%ld\n",
- bds, board_num);
- return;
- }
- forcesize[board_num] = bd;
-}
-
static char *pm3fb_boardnum_setup(char *options, unsigned long *bn)
{
char *next;
@@ -2753,12 +2624,6 @@
pm3fb_bootdepth_setup(options, bn);
} else if (!strncmp(options, "printtimings", 12)) {
printtimings = 1;
- } else if (!strncmp(options, "flatpanel:", 10)) {
- options = pm3fb_boardnum_setup(options + 10, &bn);
- flatpanel[bn] = 1;
- } else if (!strncmp(options, "forcesize:", 10)) {
- options = pm3fb_boardnum_setup(options + 10, &bn);
- pm3fb_forcesize_setup(options, bn);
}
options = next;
}
@@ -3496,7 +3361,7 @@
pci_resource_start(l_fb_info->dev, 1);
l_fb_info->v_fb = (unsigned char *) -1;
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5) /* full resource management, new in linux-2.4.x */
+#ifdef KERNEL_2_4 /* full resource management, new in linux-2.4.x */
if (!request_mem_region
((unsigned long)l_fb_info->p_fb, 64 * 1024 * 1024, /* request full aperture size */
"pm3fb")) {
@@ -3513,10 +3378,8 @@
l_fb_info->board_num);
continue;
}
-#endif /* KERNEL_2_4 or KERNEL_2_5 */
- if (forcesize[l_fb_info->board_num])
- l_fb_info->fb_size = forcesize[l_fb_info->board_num];
-
+#endif /* KERNEL_2_4 */
+
l_fb_info->fb_size =
pm3fb_size_memory(l_fb_info);
@@ -3612,7 +3475,7 @@
/* ***** standard FB API init functions ***** */
/* ****************************************** */
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5)
+#ifdef KERNEL_2_4
int __init pm3fb_setup(char *options)
#endif
#ifdef KERNEL_2_2
@@ -3628,12 +3491,12 @@
PM3_OPTIONS_SIZE) ? PM3_OPTIONS_SIZE : (opsi + 1));
g_options[PM3_OPTIONS_SIZE - 1] = 0;
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5)
+#ifdef KERNEL_2_4
return (0);
#endif
}
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5)
+#ifdef KERNEL_2_4
int __init pm3fb_init(void)
#endif
#ifdef KERNEL_2_2
@@ -3642,7 +3505,7 @@
{
DTRACE;
- DPRINTK(2, "This is pm3fb.c, CVS version: $Header: /cvsroot/linux/drivers/video/pm3fb.c,v 1.1 2002/02/25 19:11:06 marcelo Exp $");
+ DPRINTK(2, "This is pm3fb.c, CVS version: $Header: /home/pm3fb/pm3fb/pm3fb.c,v 1.139 2001/08/28 08:13:54 dolbeau Exp $");
pm3fb_real_setup(g_options);
@@ -3651,7 +3514,7 @@
if (!fb_info[0].dev) { /* not even one board ??? */
DPRINTK(1, "No PCI Permedia3 board detected\n");
}
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5)
+#ifdef KERNEL_2_4
return (0);
#endif
}
@@ -3754,11 +3617,7 @@
MODULE_PARM(depth,PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
MODULE_PARM_DESC(depth,"boot-time depth");
MODULE_PARM(printtimings, "h");
-MODULE_PARM_DESC(printtimings, "print the memory timings of the card(s)");
-MODULE_PARM(forcesize, PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
-MODULE_PARM_DESC(forcesize, "force specified memory size");
-MODULE_PARM(flatpanel, PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
-MODULE_PARM_DESC(flatpanel, "flatpanel (LCD) support (preliminary)");
+MODULE_PARM_DESC(printtimings, "print the memory timngs of the card(s)");
/*
MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards")
MODULE_GENERIC_TABLE(gtype,name)
@@ -3803,11 +3662,6 @@
sprintf(ts, ",depth:%d:%d", i, depth[i]);
strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
}
- if (flatpanel[i])
- {
- sprintf(ts, ",flatpanel:%d:", i);
- strncat(g_options, ts, PM3_OPTIONS_SIZE - strlen(g_options));
- }
}
g_options[PM3_OPTIONS_SIZE - 1] = '\0';
DPRINTK(1, "pm3fb use options: %s\n", g_options);
@@ -3837,14 +3691,14 @@
if (l_fb_info->vIOBase !=
(unsigned char *) -1) {
pm3fb_unmapIO(l_fb_info);
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5)
+#ifdef KERNEL_2_4
release_mem_region(l_fb_info->p_fb,
l_fb_info->
fb_size);
release_mem_region(l_fb_info->
pIOBase,
PM3_REGS_SIZE);
-#endif /* KERNEL_2_4 or KERNEL_2_5 */
+#endif /* KERNEL_2_4 */
}
unregister_framebuffer(&l_fb_info->gen.
info);
diff -urN linux-2.4.26/drivers/video/pm3fb.h linux-2.4.26-vrs1/drivers/video/pm3fb.h
--- linux-2.4.26/drivers/video/pm3fb.h 2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/video/pm3fb.h 2004-01-14 21:32:27.000000000 +0000
@@ -8,7 +8,7 @@
* License. See the file COPYING in the main directory of this archive for
* more details.
*
- * $Header: /cvsroot/linux/drivers/video/pm3fb.h,v 1.1 2002/02/25 19:11:06 marcelo Exp $
+ * $Header: /home/pm3fb/pm3fb/pm3fb.h,v 1.30 2001/08/22 09:13:46 dolbeau Exp $
*
*/
@@ -92,7 +92,6 @@
#define PM3MemBypassWriteMask 0x1008
#define PM3MemScratch 0x1010
#define PM3LocalMemCaps 0x1018
- #define PM3LocalMemCaps_NoWriteMask (1 << 28)
#define PM3LocalMemTimings 0x1020
#define PM3LocalMemControl 0x1028
#define PM3LocalMemRefresh 0x1030
@@ -1121,10 +1120,6 @@
/* kernel -specific definitions */
/* what kernel is this ? */
-#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)))
-#define KERNEL_2_5
-#endif
-
#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)))
#define KERNEL_2_4
#endif
@@ -1138,8 +1133,8 @@
#endif
#endif
-#if (!defined(KERNEL_2_2)) && (!defined(KERNEL_2_4)) && (!defined(KERNEL_2_5))
-#error "Only kernel 2.2.x, kernel 2.4.y and kernel 2.5.z might work"
+#if (!defined(KERNEL_2_2)) && (!defined(KERNEL_2_4))
+#error "Only kernel 2.2.x and kernel 2.4.y might work"
#endif
/* not sure if/why it's needed. doesn't work without on my PowerMac... */
@@ -1147,11 +1142,6 @@
#define MUST_BYTESWAP
#endif
-/* for compatibility between 2.5, 2.4 and 2.2 */
-#ifndef B_FREE
-#define B_FREE -1
-#endif
-
/* permedia3 -specific definitions */
#define PM3_SCALE_TO_CLOCK(pr, fe, po) ((2 * PM3_REF_CLOCK * fe) / (pr * (1 << (po))))
#define PICOS2KHZ(a) (1000000000UL/(a))
@@ -1219,10 +1209,10 @@
#define PM3_READ_REG(r) readl((l_fb_info->vIOBase + r))
#endif /* MUST_BYTESWAP */
#endif /* KERNEL_2_2 */
-#if (defined KERNEL_2_4) || (defined KERNEL_2_5) /* native-endian access */
+#ifdef KERNEL_2_4 /* native-endian access */
#define PM3_WRITE_REG(r, v) fb_writel(v, (l_fb_info->vIOBase + r))
#define PM3_READ_REG(r) fb_readl((l_fb_info->vIOBase + r))
-#endif /* KERNEL_2_4 or KERNEL_2_5 */
+#endif /* KERNEL_2_4 */
#define depth2bpp(d) ((d + 7L) & ~7L)
diff -urN linux-2.4.26/drivers/video/sa1100fb.c linux-2.4.26-vrs1/drivers/video/sa1100fb.c
--- linux-2.4.26/drivers/video/sa1100fb.c 2001-11-14 22:52:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/video/sa1100fb.c 2004-01-14 21:32:27.000000000 +0000
@@ -23,11 +23,11 @@
* Thank you.
*
* Known problems:
- * - With the Neponset plugged into an Assabet, LCD powerdown
- * doesn't work (LCD stays powered up). Therefore we shouldn't
- * blank the screen.
- * - We don't limit the CPU clock rate nor the mode selection
- * according to the available SDRAM bandwidth.
+ * - With the Neponset plugged into an Assabet, LCD powerdown
+ * doesn't work (LCD stays powered up). Therefore we shouldn't
+ * blank the screen.
+ * - We don't limit the CPU clock rate nor the mode selection
+ * according to the available SDRAM bandwidth.
*
* Other notes:
* - Linear grayscale palettes and the kernel.
@@ -41,6 +41,17 @@
* David Neuer. It's around 8 lines of C code, plus another 4 to
* detect if we are using grayscale.
*
+ * - The following must never be specified in a panel definition:
+ * LCCR0_LtlEnd, LCCR3_PixClkDiv, LCCR3_VrtSnchL, LCCR3_HorSnchL
+ *
+ * - The following should be specified:
+ * either LCCR0_Color or LCCR0_Mono
+ * either LCCR0_Sngl or LCCR0_Dual
+ * either LCCR0_Act or LCCR0_Pas
+ * either LCCR3_OutEnH or LCCD3_OutEnL
+ * either LCCR3_PixRsEdg or LCCR3_PixFlEdg
+ * either LCCR3_ACBsDiv or LCCR3_ACBsCntOff
+ *
* Code Status:
* 1999/04/01:
* - Driver appears to be working for Brutus 320x200x8bpp mode. Other
@@ -147,6 +158,10 @@
*
* 2001/10/12: <rmk@arm.linux.org.uk>
* - Add patch 681/1 and clean up stork definitions.
+ *
+ * 2002/02/21: <abraham@2d3d.co.za>
+ * - Added support for ICP LCD-Kit01 on Frodo.
+ * - Added support for backlight via CPLDs on Frodo.
*/
#include <linux/config.h>
@@ -169,6 +184,7 @@
#include <asm/mach-types.h>
#include <asm/uaccess.h>
#include <asm/arch/assabet.h>
+#include <asm/arch/shannon.h>
#include <video/fbcon.h>
#include <video/fbcon-mfb.h>
@@ -177,11 +193,6 @@
#include <video/fbcon-cfb16.h>
/*
- * enable this if your panel appears to have broken
- */
-#undef CHECK_COMPAT
-
-/*
* debugging?
*/
#define DEBUG 0
@@ -197,243 +208,6 @@
void (*sa1100fb_blank_helper)(int blank);
EXPORT_SYMBOL(sa1100fb_blank_helper);
-
-#ifdef CHECK_COMPAT
-static void
-sa1100fb_check_shadow(struct sa1100fb_lcd_reg *new_regs,
- struct fb_var_screeninfo *var, u_int pcd)
-{
- struct sa1100fb_lcd_reg shadow;
- int different = 0;
-
- /*
- * These machines are good machines!
- */
- if (machine_is_assabet() || machine_is_h3600())
- return;
-
- /*
- * The following ones are bad, bad, bad.
- * Please make yours good!
- */
- if (machine_is_pangolin()) {
- DPRINTK("Configuring Pangolin LCD\n");
- shadow.lccr0 =
- LCCR0_LEN + LCCR0_Color + LCCR0_LDM +
- LCCR0_BAM + LCCR0_ERM + LCCR0_Act +
- LCCR0_LtlEnd + LCCR0_DMADel(0);
- shadow.lccr1 =
- LCCR1_DisWdth(var->xres) + LCCR1_HorSnchWdth(64) +
- LCCR1_BegLnDel(160) + LCCR1_EndLnDel(24);
- shadow.lccr2 =
- LCCR2_DisHght(var->yres) + LCCR2_VrtSnchWdth(7) +
- LCCR2_BegFrmDel(7) + LCCR2_EndFrmDel(1);
- shadow.lccr3 =
- LCCR3_PixClkDiv(pcd) + LCCR3_HorSnchH +
- LCCR3_VrtSnchH + LCCR3_PixFlEdg + LCCR3_OutEnH;
-
- DPRINTK("pcd = %x, PixCldDiv(pcd)=%x\n",
- pcd, LCCR3_PixClkDiv(pcd));
- }
- if (machine_is_freebird()) {
- DPRINTK("Configuring Freebird LCD\n");
-#if 1
- shadow.lccr0 = 0x00000038;
- shadow.lccr1 = 0x010108e0;
- shadow.lccr2 = 0x0000053f;
- shadow.lccr3 = 0x00000c20;
-#else
- shadow.lccr0 =
- LCCR0_LEN + LCCR0_Color + LCCR0_Sngl +
- LCCR0_LDM + LCCR0_BAM + LCCR0_ERM + LCCR0_Pas +
- LCCR0_LtlEnd + LCCR0_DMADel(0);
- /* Check ,Chester */
- shadow.lccr1 =
- LCCR1_DisWdth(var->xres) + LCCR1_HorSnchWdth(5) +
- LCCR1_BegLnDel(61) + LCCR1_EndLnDel(9);
- /* Check ,Chester */
- shadow.lccr2 =
- LCCR2_DisHght(var->yres) + LCCR2_VrtSnchWdth(1) +
- LCCR2_BegFrmDel(3) + LCCR2_EndFrmDel(0);
- /* Check ,Chester */
- shadow.lccr3 =
- LCCR3_OutEnH + LCCR3_PixFlEdg + LCCR3_VrtSnchH +
- LCCR3_HorSnchH + LCCR3_ACBsCntOff +
- LCCR3_ACBsDiv(2) + LCCR3_PixClkDiv(pcd);
-#endif
- }
- if (machine_is_brutus()) {
- DPRINTK("Configuring Brutus LCD\n");
- shadow.lccr0 =
- LCCR0_LEN + LCCR0_Color + LCCR0_Sngl + LCCR0_Pas +
- LCCR0_LtlEnd + LCCR0_LDM + LCCR0_BAM + LCCR0_ERM +
- LCCR0_DMADel(0);
- shadow.lccr1 =
- LCCR1_DisWdth(var->xres) + LCCR1_HorSnchWdth(3) +
- LCCR1_BegLnDel(41) + LCCR1_EndLnDel(101);
- shadow.lccr2 =
- LCCR2_DisHght(var->yres) + LCCR2_VrtSnchWdth(1) +
- LCCR2_BegFrmDel(0) + LCCR2_EndFrmDel(0);
- shadow.lccr3 =
- LCCR3_OutEnH + LCCR3_PixRsEdg + LCCR3_VrtSnchH +
- LCCR3_HorSnchH + LCCR3_ACBsCntOff +
- LCCR3_ACBsDiv(2) + LCCR3_PixClkDiv(44);
- }
- if (machine_is_huw_webpanel()) {
- DPRINTK("Configuring HuW LCD\n");
- shadow.lccr0 = LCCR0_LEN + LCCR0_Dual + LCCR0_LDM;
- shadow.lccr1 = LCCR1_DisWdth(var->xres) +
- LCCR1_HorSnchWdth(3) +
- LCCR1_BegLnDel(41) + LCCR1_EndLnDel(101);
- shadow.lccr2 = 239 + LCCR2_VrtSnchWdth(1);
- shadow.lccr3 = 8 + LCCR3_OutEnH +
- LCCR3_PixRsEdg + LCCR3_VrtSnchH +
- LCCR3_HorSnchH + LCCR3_ACBsCntOff + LCCR3_ACBsDiv(2);
- }
- if (machine_is_lart()) {
- DPRINTK("Configuring LART LCD\n");
-#if defined LART_GREY_LCD
- shadow.lccr0 =
- LCCR0_LEN + LCCR0_Mono + LCCR0_Sngl + LCCR0_Pas +
- LCCR0_LtlEnd + LCCR0_LDM + LCCR0_BAM + LCCR0_ERM +
- LCCR0_DMADel(0);
- shadow.lccr1 =
- LCCR1_DisWdth(var->xres) + LCCR1_HorSnchWdth(1) +
- LCCR1_BegLnDel(4) + LCCR1_EndLnDel(2);
- shadow.lccr2 =
- LCCR2_DisHght(var->yres) + LCCR2_VrtSnchWdth(1) +
- LCCR2_BegFrmDel(0) + LCCR2_EndFrmDel(0);
- shadow.lccr3 =
- LCCR3_PixClkDiv(34) + LCCR3_ACBsDiv(512) +
- LCCR3_ACBsCntOff + LCCR3_HorSnchH + LCCR3_VrtSnchH;
-#endif
-#if defined LART_COLOR_LCD
- shadow.lccr0 =
- LCCR0_LEN + LCCR0_Color + LCCR0_Sngl + LCCR0_Act +
- LCCR0_LtlEnd + LCCR0_LDM + LCCR0_BAM + LCCR0_ERM +
- LCCR0_DMADel(0);
- shadow.lccr1 =
- LCCR1_DisWdth(var->xres) + LCCR1_HorSnchWdth(2) +
- LCCR1_BegLnDel(69) + LCCR1_EndLnDel(8);
- shadow.lccr2 =
- LCCR2_DisHght(var->yres) + LCCR2_VrtSnchWdth(3) +
- LCCR2_BegFrmDel(14) + LCCR2_EndFrmDel(4);
- shadow.lccr3 =
- LCCR3_PixClkDiv(34) + LCCR3_ACBsDiv(512) +
- LCCR3_ACBsCntOff + LCCR3_HorSnchL + LCCR3_VrtSnchL +
- LCCR3_PixFlEdg;
-#endif
-#if defined LART_VIDEO_OUT
- shadow.lccr0 =
- LCCR0_LEN + LCCR0_Color + LCCR0_Sngl + LCCR0_Act +
- LCCR0_LtlEnd + LCCR0_LDM + LCCR0_BAM + LCCR0_ERM +
- LCCR0_DMADel(0);
- shadow.lccr1 =
- LCCR1_DisWdth(640) + LCCR1_HorSnchWdth(95) +
- LCCR1_BegLnDel(40) + LCCR1_EndLnDel(24);
- shadow.lccr2 =
- LCCR2_DisHght(480) + LCCR2_VrtSnchWdth(2) +
- LCCR2_BegFrmDel(32) + LCCR2_EndFrmDel(11);
- shadow.lccr3 =
- LCCR3_PixClkDiv(8) + LCCR3_ACBsDiv(512) +
- LCCR3_ACBsCntOff + LCCR3_HorSnchH + LCCR3_VrtSnchH +
- LCCR3_PixFlEdg + LCCR3_OutEnL;
-#endif
- }
- if (machine_is_graphicsclient()) {
- DPRINTK("Configuring GraphicsClient LCD\n");
- shadow.lccr0 =
- LCCR0_LEN + LCCR0_Color + LCCR0_Sngl + LCCR0_Act;
- shadow.lccr1 =
- LCCR1_DisWdth(var->xres) + LCCR1_HorSnchWdth(9) +
- LCCR1_EndLnDel(54) + LCCR1_BegLnDel(54);
- shadow.lccr2 =
- LCCR2_DisHght(var->yres) + LCCR2_VrtSnchWdth(9) +
- LCCR2_EndFrmDel(32) + LCCR2_BegFrmDel(24);
- shadow.lccr3 =
- LCCR3_PixClkDiv(10) + LCCR3_ACBsDiv(2) +
- LCCR3_ACBsCntOff + LCCR3_HorSnchL + LCCR3_VrtSnchL;
- }
- if (machine_is_omnimeter()) {
- DPRINTK("Configuring OMNI LCD\n");
- shadow.lccr0 = LCCR0_LEN | LCCR0_CMS | LCCR0_DPD;
- shadow.lccr1 =
- LCCR1_BegLnDel(10) + LCCR1_EndLnDel(10) +
- LCCR1_HorSnchWdth(1) + LCCR1_DisWdth(var->xres);
- shadow.lccr2 = LCCR2_DisHght(var->yres);
- shadow.lccr3 =
- LCCR3_ACBsDiv(0xFF) + LCCR3_PixClkDiv(44);
-//jca (GetPCD(25) << LCD3_V_PCD);
- }
- if (machine_is_xp860()) {
- DPRINTK("Configuring XP860 LCD\n");
- shadow.lccr0 =
- LCCR0_LEN + LCCR0_Color + LCCR0_Sngl + LCCR0_Act +
- LCCR0_LtlEnd + LCCR0_LDM + LCCR0_ERM + LCCR0_DMADel(0);
- shadow.lccr1 =
- LCCR1_DisWdth(var->xres) +
- LCCR1_HorSnchWdth(var->hsync_len) +
- LCCR1_BegLnDel(var->left_margin) +
- LCCR1_EndLnDel(var->right_margin);
- shadow.lccr2 =
- LCCR2_DisHght(var->yres) +
- LCCR2_VrtSnchWdth(var->vsync_len) +
- LCCR2_BegFrmDel(var->upper_margin) +
- LCCR2_EndFrmDel(var->lower_margin);
- shadow.lccr3 =
- LCCR3_PixClkDiv(6) + LCCR3_HorSnchL + LCCR3_VrtSnchL;
- }
-
- /*
- * Ok, since we're calculating these values, we want to know
- * if the calculation is correct. If you see any of these
- * messages _PLEASE_ report the incident to me for diagnosis,
- * including details about what was happening when the
- * messages appeared. --rmk, 30 March 2001
- */
- if (shadow.lccr0 != new_regs->lccr0) {
- printk(KERN_ERR "LCCR1 mismatch: 0x%08x != 0x%08x\n",
- shadow.lccr1, new_regs->lccr1);
- different = 1;
- }
- if (shadow.lccr1 != new_regs->lccr1) {
- printk(KERN_ERR "LCCR1 mismatch: 0x%08x != 0x%08x\n",
- shadow.lccr1, new_regs->lccr1);
- different = 1;
- }
- if (shadow.lccr2 != new_regs->lccr2) {
- printk(KERN_ERR "LCCR2 mismatch: 0x%08x != 0x%08x\n",
- shadow.lccr2, new_regs->lccr2);
- different = 1;
- }
- if (shadow.lccr3 != new_regs->lccr3) {
- printk(KERN_ERR "LCCR3 mismatch: 0x%08x != 0x%08x\n",
- shadow.lccr3, new_regs->lccr3);
- different = 1;
- }
- if (different) {
- printk(KERN_ERR "var: xres=%d hslen=%d lm=%d rm=%d\n",
- var->xres, var->hsync_len,
- var->left_margin, var->right_margin);
- printk(KERN_ERR "var: yres=%d vslen=%d um=%d bm=%d\n",
- var->yres, var->vsync_len,
- var->upper_margin, var->lower_margin);
-
- printk(KERN_ERR "Please report this to Russell King "
- "<rmk@arm.linux.org.uk>\n");
- }
-
- DPRINTK("olccr0 = 0x%08x\n", shadow.lccr0);
- DPRINTK("olccr1 = 0x%08x\n", shadow.lccr1);
- DPRINTK("olccr2 = 0x%08x\n", shadow.lccr2);
- DPRINTK("olccr3 = 0x%08x\n", shadow.lccr3);
-}
-#else
-#define sa1100fb_check_shadow(regs,var,pcd)
-#endif
-
-
-
/*
* IMHO this looks wrong. In 8BPP, length should be 8.
*/
@@ -488,42 +262,56 @@
#endif
#endif
-#ifdef CONFIG_SA1100_H3600
-static struct sa1100fb_mach_info h3600_info __initdata = {
-#ifdef CONFIG_IPAQ_H3100
- pixclock: 407766, bpp: 4,
+#ifdef CONFIG_SA1100_H3XXX
+static struct sa1100fb_mach_info h3800_info __initdata = {
+ pixclock: 174757, bpp: 16,
xres: 320, yres: 240,
- hsync_len: 26, vsync_len: 41,
- left_margin: 4, upper_margin: 0,
- right_margin: 4, lower_margin: 0,
+ hsync_len: 3, vsync_len: 3,
+ left_margin: 12, upper_margin: 10,
+ right_margin: 17, lower_margin: 1,
- sync: FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
- cmap_greyscale: 1, cmap_static: 1,
- cmap_inverse: 1,
+ sync: 0, cmap_static: 1,
- lccr0: LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas,
- lccr3: LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
-#else
- pixclock: 174757, bpp: 16,
+ lccr0: LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
+ lccr3: LCCR3_ACBsCntOff | LCCR3_PixFlEdg | LCCR3_OutEnH,
+};
+
+static struct sa1100fb_mach_info h3600_info __initdata = {
+ pixclock: 174757, bpp: 16,
xres: 320, yres: 240,
hsync_len: 3, vsync_len: 3,
left_margin: 12, upper_margin: 10,
right_margin: 17, lower_margin: 1,
- sync: 0,
+ sync: 0, cmap_static: 1,
lccr0: LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
- lccr3: LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
-#endif
+ lccr3: LCCR3_ACBsCntOff | LCCR3_OutEnH | LCCR3_PixFlEdg,
};
static struct sa1100fb_rgb h3600_rgb_16 = {
red: { offset: 12, length: 4, },
green: { offset: 7, length: 4, },
blue: { offset: 1, length: 4, },
- transp: { offset: 0, length: 0, },
+ transp: { offset: 0, length: 0, },
+};
+
+static struct sa1100fb_mach_info h3100_info __initdata = {
+ pixclock: 406977, bpp: 4,
+ xres: 320, yres: 240,
+
+ hsync_len: 26, vsync_len: 41,
+ left_margin: 4, upper_margin: 0,
+ right_margin: 4, lower_margin: 0,
+
+ sync: FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+ cmap_greyscale: 1,
+ cmap_inverse: 1,
+
+ lccr0: LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas,
+ lccr3: LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
};
#endif
@@ -618,6 +406,58 @@
#ifdef CONFIG_SA1100_GRAPHICSCLIENT
static struct sa1100fb_mach_info graphicsclient_info __initdata = {
+// for LQ64D343
+ pixclock: 53500, bpp: 8,
+ xres: 640, yres: 480,
+
+ hsync_len: 9, vsync_len: 9,
+ left_margin: 54, upper_margin: 24,
+ right_margin: 54, lower_margin: 32,
+
+ sync: 0,
+
+ lccr0: LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
+ lccr3: LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
+};
+#endif
+
+#ifdef CONFIG_SA1100_GRAPHICSMASTER
+static struct sa1100fb_mach_info graphicsmaster_info __initdata = {
+// for LQ64D343
+ pixclock: 53500, bpp: 8,
+ xres: 640, yres: 480,
+
+ hsync_len: 9, vsync_len: 9,
+ left_margin: 54, upper_margin: 24,
+ right_margin: 54, lower_margin: 32,
+
+ sync: 0,
+
+ lccr0: LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
+ lccr3: LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
+};
+#endif
+
+#ifdef CONFIG_SA1100_ADSBITSY
+static struct sa1100fb_mach_info adsbitsy_info __initdata = {
+// for LQ64D343
+ pixclock: 53500, bpp: 8,
+ xres: 640, yres: 480,
+
+ hsync_len: 9, vsync_len: 9,
+ left_margin: 54, upper_margin: 24,
+ right_margin: 54, lower_margin: 32,
+
+ sync: 0,
+
+ lccr0: LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
+ lccr3: LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
+};
+#endif
+
+#ifdef CONFIG_SA1100_ADSBITSYPLUS
+static struct sa1100fb_mach_info adsbitsyplus_info __initdata = {
+// for LQ64D343
pixclock: 53500, bpp: 8,
xres: 640, yres: 480,
@@ -699,7 +539,6 @@
lccr3: LCCR3_OutEnL | LCCR3_PixFlEdg | LCCR3_ACBsDiv(512),
};
#endif
-
#ifdef LART_KIT01_LCD
static struct sa1100fb_mach_info lart_kit01_info __initdata =
{
@@ -707,7 +546,7 @@
xres: 640, yres: 480,
hsync_len: 64, vsync_len: 3,
- left_margin: 122, upper_margin: 45,
+ left_margin: 122, upper_margin: 45,
right_margin: 10, lower_margin: 10,
sync: 0,
@@ -717,6 +556,40 @@
};
#endif
+#ifdef CONFIG_SA1100_FRODO
+static struct sa1100fb_mach_info frodo_kit01_info __initdata =
+{
+ /* best would be 41731 (25.8mhz), but we can only do 14.743mhz at 191.7mhz clock speed */
+ pixclock: 73030, bpp: 16,
+ xres: 640, yres: 480,
+
+ hsync_len: 32, vsync_len: 19,
+ left_margin: 120, upper_margin: 33,
+ right_margin: 17, lower_margin: 12,
+
+ sync: 0,
+
+ lccr0: LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
+ lccr3: LCCR3_OutEnH | LCCR3_PixFlEdg
+};
+#endif
+
+#ifdef CONFIG_SA1100_SHANNON
+static struct sa1100fb_mach_info shannon_info __initdata = {
+ pixclock: 152500, bpp: 8,
+ xres: 640, yres: 480,
+
+ hsync_len: 4, vsync_len: 3,
+ left_margin: 2, upper_margin: 0,
+ right_margin: 1, lower_margin: 0,
+
+ sync: FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+
+ lccr0: LCCR0_Color | LCCR0_Dual | LCCR0_Pas,
+ lccr3: LCCR3_ACBsDiv(512),
+};
+#endif
+
#ifdef CONFIG_SA1100_OMNIMETER
static struct sa1100fb_mach_info omnimeter_info __initdata = {
pixclock: 0, bpp: 4,
@@ -752,7 +625,24 @@
sync: FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
lccr0: LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
- lccr3: LCCR3_OutEnH | LCCR3_PixFlEdg,
+ lccr3: LCCR3_OutEnH | LCCR3_PixFlEdg | LCCR3_ACBsCntOff,
+};
+#endif
+
+#ifdef CONFIG_SA1100_SIMPUTER
+static struct sa1100fb_mach_info simputer_info __initdata = {
+ pixclock: 70000, bpp: 4,
+ xres: 320, yres: 240,
+
+ hsync_len: 9, vsync_len: 2,
+ left_margin: 9, upper_margin: 0,
+ right_margin: 2, lower_margin: 0,
+
+ cmap_greyscale: 1,
+ sync: FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT ,
+
+ lccr0: LCCR0_Mono | LCCR0_Sngl | LCCR0_Pas | LCCR0_4PixMono,
+ lccr3: LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(202),
};
#endif
@@ -828,7 +718,6 @@
#endif
-
static struct sa1100fb_mach_info * __init
sa1100fb_get_machine_info(struct sa1100fb_info *fbi)
{
@@ -849,11 +738,17 @@
#endif
}
#endif
-#ifdef CONFIG_SA1100_H3600
+#ifdef CONFIG_SA1100_H3XXX
if (machine_is_h3600()) {
inf = &h3600_info;
fbi->rgb[RGB_16] = &h3600_rgb_16;
}
+ if (machine_is_h3100()) {
+ inf = &h3100_info;
+ }
+ if (machine_is_h3800()) {
+ inf = &h3800_info;
+ }
#endif
#ifdef CONFIG_SA1100_BRUTUS
if (machine_is_brutus()) {
@@ -876,6 +771,22 @@
inf = &graphicsclient_info;
}
#endif
+#ifdef CONFIG_SA1100_GRAPHICSMASTER
+ if (machine_is_graphicsmaster()) {
+ inf = &graphicsmaster_info;
+ }
+#endif
+#ifdef CONFIG_SA1100_ADSBITSY
+ if (machine_is_adsbitsy()) {
+ inf = &adsbitsy_info;
+ }
+#endif
+#ifdef CONFIG_SA1100_ADSBITSYPLUS
+ if (machine_is_adsbitsyplus()) {
+ inf = &adsbitsyplus_info;
+ }
+ }
+#endif
#ifdef CONFIG_SA1100_HUW_WEBPANEL
if (machine_is_huw_webpanel()) {
inf = &huw_webpanel_info;
@@ -897,6 +808,21 @@
#endif
}
#endif
+#ifdef CONFIG_SA1100_FRODO
+ if (machine_is_frodo()) {
+ inf = &frodo_kit01_info;
+ }
+#endif
+#ifdef CONFIG_SA1100_SHANNON
+ if (machine_is_shannon()) {
+ inf = &shannon_info;
+ }
+#endif
+#ifdef CONFIG_SA1100_SIMPUTER
+ if (machine_is_simputer()) {
+ inf = &simputer_info;
+ }
+#endif
#ifdef CONFIG_SA1100_OMNIMETER
if (machine_is_omnimeter()) {
inf = &omnimeter_info;
@@ -1556,7 +1482,8 @@
unsigned int pcd;
if (pixclock) {
- pcd = get_cclk_frequency() * pixclock;
+ pcd = cpufreq_get(0) / 100;
+ pcd *= pixclock;
pcd /= 10000000;
pcd += 1; /* make up for integer math truncations */
} else {
@@ -1580,6 +1507,7 @@
return pcd;
}
+
/*
* sa1100fb_activate_var():
* Configures LCD Controller based on entries in var parameter. Settings are
@@ -1659,8 +1587,6 @@
if (pcd)
new_regs.lccr3 |= LCCR3_PixClkDiv(pcd);
- sa1100fb_check_shadow(&new_regs, var, pcd);
-
DPRINTK("nlccr0 = 0x%08x\n", new_regs.lccr0);
DPRINTK("nlccr1 = 0x%08x\n", new_regs.lccr1);
DPRINTK("nlccr2 = 0x%08x\n", new_regs.lccr2);
@@ -1733,6 +1659,10 @@
if (machine_is_omnimeter())
LEDBacklightOn();
#endif
+#ifdef CONFIG_SA1100_FRODO
+ if (machine_is_frodo())
+ frodo_cpld_set (FRODO_CPLD_GENERAL,FRODO_LCD_BACKLIGHT);
+#endif
}
/*
@@ -1755,6 +1685,10 @@
if (machine_is_omnimeter())
LEDBacklightOff();
#endif
+#ifdef CONFIG_SA1100_FRODO
+ if (machine_is_frodo())
+ frodo_cpld_clear (FRODO_CPLD_GENERAL,FRODO_LCD_BACKLIGHT);
+#endif
}
static void sa1100fb_power_up_lcd(struct sa1100fb_info *fbi)
@@ -1773,20 +1707,25 @@
if (machine_is_omnimeter())
LCDPowerOn();
#endif
-#ifdef CONFIG_SA1100_H3600
- if (machine_is_h3600()) {
- set_h3600_egpio(EGPIO_H3600_LCD_ON |
- EGPIO_H3600_LCD_PCI |
- EGPIO_H3600_LCD_5V_ON |
- EGPIO_H3600_LVDD_ON);
- }
-#endif
+ if (machine_is_h3xxx())
+ set_h3600_egpio( IPAQ_EGPIO_LCD_ON ); /* Turn on power to the LCD */
#ifdef CONFIG_SA1100_STORK
if (machine_is_stork()) {
storkSetLCDCPLD(0, 1);
storkSetLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON);
}
#endif
+#ifdef CONFIG_SA1100_FRODO
+ if (machine_is_frodo())
+ sa1100fb_backlight_on(fbi);
+#endif
+#ifdef CONFIG_SA1100_ADSBITSYPLUS
+ if (machine_is_adsbitsyplus()) {
+ ADS_CPLD_PCON &= ~ADS_PCON_PANEL_ON;
+ ADS_CPLD_SUPPC |= ADS_SUPPC_VEE_ON;
+ }
+#endif
+
}
static void sa1100fb_power_down_lcd(struct sa1100fb_info *fbi)
@@ -1802,20 +1741,24 @@
if (machine_is_huw_webpanel())
BCR_set(BCR_TFT_NPWR);
#endif
-#ifdef CONFIG_SA1100_H3600
- if (machine_is_h3600()) {
- clr_h3600_egpio(EGPIO_H3600_LCD_ON |
- EGPIO_H3600_LCD_PCI |
- EGPIO_H3600_LCD_5V_ON |
- EGPIO_H3600_LVDD_ON);
- }
-#endif
+ if (machine_is_h3xxx())
+ clr_h3600_egpio( IPAQ_EGPIO_LCD_ON );
#ifdef CONFIG_SA1100_STORK
if (machine_is_stork()) {
storkSetLCDCPLD(0, 0);
storkClearLatchA(STORK_LCD_BACKLIGHT_INVERTER_ON);
}
#endif
+#ifdef CONFIG_SA1100_FRODO
+ if (machine_is_frodo())
+ sa1100fb_backlight_off(fbi);
+#endif
+#ifdef CONFIG_SA1100_ADSBITSYPLUS
+ if (machine_is_adsbitsyplus()) {
+ ADS_CPLD_PCON |= ADS_PCON_PANEL_ON;
+ ADS_CPLD_SUPPC &= ~ADS_SUPPC_VEE_ON;
+ }
+#endif
}
static void sa1100fb_setup_gpio(struct sa1100fb_info *fbi)
@@ -1911,15 +1854,29 @@
LCCR0 |= LCCR0_LEN;
#ifdef CONFIG_SA1100_GRAPHICSCLIENT
-#error Where is GPIO24 set as an output? Can we fit this in somewhere else?
if (machine_is_graphicsclient()) {
// From ADS doc again...same as disable
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(20 * HZ / 1000);
- GPSR |= GPIO_GPIO24;
+ GPDR |= GPIO_GPIO24;
+ GPSR = GPIO_GPIO24;
+ }
+#endif
+#ifdef CONFIG_SA1100_GRAPHICSMASTER
+ if (machine_is_graphicsmaster()) {
+ // From ADS doc again...same as disable
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(20 * HZ / 1000);
+ GPDR |= GPIO_GPIO24;
+ GPSR = GPIO_GPIO24;
}
#endif
+ if (machine_is_shannon()) {
+ GPDR |= SHANNON_GPIO_DISP_EN;
+ GPSR |= SHANNON_GPIO_DISP_EN;
+ }
+
DPRINTK("DBAR1 = %p\n", DBAR1);
DPRINTK("DBAR2 = %p\n", DBAR2);
DPRINTK("LCCR0 = 0x%08x\n", LCCR0);
@@ -1935,7 +1892,6 @@
DPRINTK("Disabling LCD controller\n");
#ifdef CONFIG_SA1100_GRAPHICSCLIENT
-#error Where is GPIO24 set as an output? Can we fit this in somewhere else?
if (machine_is_graphicsclient()) {
/*
* From ADS internal document:
@@ -1944,6 +1900,22 @@
*
* We'll wait 20msec.
*/
+ GPDR |= GPIO_GPIO24;
+ GPCR |= GPIO_GPIO24;
+ set_current_state(TASK_UNINTERRUPTIBLE);
+ schedule_timeout(20 * HZ / 1000);
+ }
+#endif
+#ifdef CONFIG_SA1100_GRAPHICSMASTER
+ if (machine_is_graphicsmaster()) {
+ /*
+ * From ADS internal document:
+ * GPIO24 should be LOW at least 10msec prior to disabling
+ * the LCD interface.
+ *
+ * We'll wait 20msec.
+ */
+ GPDR |= GPIO_GPIO24;
GPCR |= GPIO_GPIO24;
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(20 * HZ / 1000);
@@ -1958,12 +1930,15 @@
}
#endif
+ if (machine_is_shannon()) {
+ GPCR |= SHANNON_GPIO_DISP_EN;
+ }
+
add_wait_queue(&fbi->ctrlr_wait, &wait);
set_current_state(TASK_UNINTERRUPTIBLE);
LCSR = 0xffffffff; /* Clear LCD Status Register */
LCCR0 &= ~LCCR0_LDM; /* Enable LCD Disable Done Interrupt */
- enable_irq(IRQ_LCD); /* Enable LCD IRQ */
LCCR0 &= ~LCCR0_LEN; /* Disable LCD Controller */
schedule_timeout(20 * HZ / 1000);
@@ -2006,12 +1981,13 @@
* Disable controller for clock change. If the
* controller is already disabled, then do nothing.
*/
- if (old_state != C_DISABLE) {
+ if (old_state != C_DISABLE && old_state != C_DISABLE_PM) {
fbi->state = state;
sa1100fb_disable_controller(fbi);
}
break;
+ case C_DISABLE_PM:
case C_DISABLE:
/*
* Disable controller
@@ -2050,6 +2026,16 @@
}
break;
+ case C_ENABLE_PM:
+ /*
+ * Re-enable the controller after PM. This is not
+ * perfect - think about the case where we were doing
+ * a clock change, and we suspended half-way through.
+ */
+ if (old_state != C_DISABLE_PM)
+ break;
+ /* fall through */
+
case C_ENABLE:
/*
* Power up the LCD screen, enable controller, and
@@ -2162,10 +2148,10 @@
if (state == 0) {
/* Enter D0. */
- set_ctrlr_state(fbi, C_ENABLE);
+ set_ctrlr_state(fbi, C_ENABLE_PM);
} else {
/* Enter D1-D3. Disable the LCD controller. */
- set_ctrlr_state(fbi, C_DISABLE);
+ set_ctrlr_state(fbi, C_DISABLE_PM);
}
}
DPRINTK("done\n");
@@ -2304,7 +2290,7 @@
goto failed;
ret = request_irq(IRQ_LCD, sa1100fb_handle_irq, SA_INTERRUPT,
- fbi->fb.fix.id, fbi);
+ "LCD", fbi);
if (ret) {
printk(KERN_ERR "sa1100fb: request_irq failed: %d\n", ret);
goto failed;
diff -urN linux-2.4.26/drivers/video/sa1100fb.h linux-2.4.26-vrs1/drivers/video/sa1100fb.h
--- linux-2.4.26/drivers/video/sa1100fb.h 2001-10-25 21:53:52.000000000 +0100
+++ linux-2.4.26-vrs1/drivers/video/sa1100fb.h 2004-01-14 21:32:27.000000000 +0000
@@ -127,6 +127,8 @@
#define C_DISABLE_CLKCHANGE (2)
#define C_ENABLE_CLKCHANGE (3)
#define C_REENABLE (4)
+#define C_DISABLE_PM (5)
+#define C_ENABLE_PM (6)
#define SA1100_NAME "SA1100"
diff -urN linux-2.4.26/drivers/video/vga16fb.c linux-2.4.26-vrs1/drivers/video/vga16fb.c
--- linux-2.4.26/drivers/video/vga16fb.c 2001-11-14 22:52:20.000000000 +0000
+++ linux-2.4.26-vrs1/drivers/video/vga16fb.c 2004-04-04 22:51:02.000000000 +0100
@@ -142,7 +142,7 @@
memset(fix, 0, sizeof(struct fb_fix_screeninfo));
strcpy(fix->id,"VGA16 VGA");
- fix->smem_start = VGA_FB_PHYS;
+ fix->smem_start = VGA_MAP_MEM(VGA_FB_PHYS);
fix->smem_len = VGA_FB_PHYS_LEN;
fix->type = FB_TYPE_VGA_PLANES;
fix->visual = FB_VISUAL_PSEUDOCOLOR;
@@ -896,7 +896,7 @@
/* XXX share VGA_FB_PHYS region with vgacon */
- vga16fb.video_vbase = ioremap(VGA_FB_PHYS, VGA_FB_PHYS_LEN);
+ vga16fb.video_vbase = ioremap(VGA_MAP_MEM(VGA_FB_PHYS), VGA_FB_PHYS_LEN);
if (!vga16fb.video_vbase) {
printk(KERN_ERR "vga16fb: unable to map device\n");
return -ENOMEM;
diff -urN linux-2.4.26/fs/adfs/dir.c linux-2.4.26-vrs1/fs/adfs/dir.c
--- linux-2.4.26/fs/adfs/dir.c 2000-09-18 23:14:06.000000000 +0100
+++ linux-2.4.26-vrs1/fs/adfs/dir.c 2004-01-14 21:32:27.000000000 +0000
@@ -23,7 +23,7 @@
/*
* For future. This should probably be per-directory.
*/
-static rwlock_t adfs_dir_lock;
+static rwlock_t adfs_dir_lock = RW_LOCK_UNLOCKED;
static int
adfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
diff -urN linux-2.4.26/fs/adfs/map.c linux-2.4.26-vrs1/fs/adfs/map.c
--- linux-2.4.26/fs/adfs/map.c 2001-10-25 21:53:53.000000000 +0100
+++ linux-2.4.26-vrs1/fs/adfs/map.c 2004-01-14 21:32:27.000000000 +0000
@@ -13,24 +13,27 @@
#include <linux/adfs_fs.h>
#include <linux/spinlock.h>
+#include <asm/unaligned.h>
+
#include "adfs.h"
/*
* For the future...
*/
-static rwlock_t adfs_map_lock;
+static rwlock_t adfs_map_lock = RW_LOCK_UNLOCKED;
+/*
+ * This is fun. We need to load up to 19 bits from the map at an
+ * arbitary bit alignment. (We're limited to 19 bits by F+ version
+ * 2).
+ */
#define GET_FRAG_ID(_map,_start,_idmask) \
({ \
- unsigned long _v2, _frag; \
- unsigned int _tmp; \
- _tmp = _start >> 5; \
- _frag = le32_to_cpu(_map[_tmp]); \
- _v2 = le32_to_cpu(_map[_tmp + 1]); \
- _tmp = start & 31; \
- _frag = (_frag >> _tmp) | (_v2 << (32 - _tmp)); \
+ unsigned char *_m = _map + (_start >> 3); \
+ u32 _frag = get_unaligned((u32 *)_m); \
+ _frag >>= (_start & 7); \
_frag & _idmask; \
- })
+ })
/*
* return the map bit offset of the fragment frag_id in
@@ -44,14 +47,13 @@
const unsigned int frag_id, unsigned int *offset)
{
const unsigned int mapsize = dm->dm_endbit;
- const unsigned int idmask = (1 << idlen) - 1;
- unsigned long *map = ((unsigned long *)dm->dm_bh->b_data) + 1;
+ const u32 idmask = (1 << idlen) - 1;
+ unsigned char *map = dm->dm_bh->b_data + 4;
unsigned int start = dm->dm_startbit;
unsigned int mapptr;
+ u32 frag;
do {
- unsigned long frag;
-
frag = GET_FRAG_ID(map, start, idmask);
mapptr = start + idlen;
@@ -59,15 +61,17 @@
* find end of fragment
*/
{
- unsigned long v2;
+ u32 v, *_map = (u32 *)map;
- while ((v2 = map[mapptr >> 5] >> (mapptr & 31)) == 0) {
+ v = le32_to_cpu(_map[mapptr >> 5]) >> (mapptr & 31);
+ while (v == 0) {
mapptr = (mapptr & ~31) + 32;
if (mapptr >= mapsize)
goto error;
+ v = le32_to_cpu(_map[mapptr >> 5]);
}
- mapptr += 1 + ffz(~v2);
+ mapptr += 1 + ffz(~v);
}
if (frag == frag_id)
@@ -75,8 +79,11 @@
again:
start = mapptr;
} while (mapptr < mapsize);
+ return -1;
error:
+ printk(KERN_ERR "adfs: oversized fragment 0x%x at 0x%x-0x%x\n",
+ frag, start, mapptr);
return -1;
found:
@@ -102,10 +109,10 @@
const unsigned int mapsize = dm->dm_endbit + 32;
const unsigned int idlen = asb->s_idlen;
const unsigned int frag_idlen = idlen <= 15 ? idlen : 15;
- const unsigned int idmask = (1 << frag_idlen) - 1;
- unsigned long *map = (unsigned long *)dm->dm_bh->b_data;
+ const u32 idmask = (1 << frag_idlen) - 1;
+ unsigned char *map = dm->dm_bh->b_data;
unsigned int start = 8, mapptr;
- unsigned long frag;
+ u32 frag;
unsigned long total = 0;
/*
@@ -133,15 +140,17 @@
* find end of fragment
*/
{
- unsigned long v2;
+ u32 v, *_map = (u32 *)map;
- while ((v2 = map[mapptr >> 5] >> (mapptr & 31)) == 0) {
+ v = le32_to_cpu(_map[mapptr >> 5]) >> (mapptr & 31);
+ while (v == 0) {
mapptr = (mapptr & ~31) + 32;
if (mapptr >= mapsize)
goto error;
+ v = le32_to_cpu(_map[mapptr >> 5]);
}
- mapptr += 1 + ffz(~v2);
+ mapptr += 1 + ffz(~v);
}
total += mapptr - start;
diff -urN linux-2.4.26/fs/adfs/super.c linux-2.4.26-vrs1/fs/adfs/super.c
--- linux-2.4.26/fs/adfs/super.c 2002-02-25 19:38:07.000000000 +0000
+++ linux-2.4.26-vrs1/fs/adfs/super.c 2004-01-14 21:32:27.000000000 +0000
@@ -386,6 +386,14 @@
sb->u.adfs_sb.s_size = adfs_discsize(dr, sb->s_blocksize_bits);
sb->u.adfs_sb.s_version = dr->format_version;
sb->u.adfs_sb.s_log2sharesize = dr->log2sharesize;
+
+ printk(KERN_DEBUG "ADFS: idlen %d map bit size %d sector size %d\n",
+ dr->idlen, 1 << dr->log2bpmb, 1 << dr->log2secsize);
+ printk(KERN_DEBUG "ADFS: map size %d map2blk %d version %d share size %d\n",
+ sb->u.adfs_sb.s_map_size,
+ sb->u.adfs_sb.s_map2blk,
+ sb->u.adfs_sb.s_version,
+ 1 << sb->u.adfs_sb.s_log2sharesize);
sb->u.adfs_sb.s_map = adfs_read_map(sb, dr);
if (!sb->u.adfs_sb.s_map)
@@ -393,6 +401,8 @@
brelse(bh);
+ printk(KERN_DEBUG "ADFS: ids per zone %d\n", sb->u.adfs_sb.s_ids_per_zone);
+
/*
* set up enough so that we can read an inode
*/
diff -urN linux-2.4.26/fs/binfmt_aout.c linux-2.4.26-vrs1/fs/binfmt_aout.c
--- linux-2.4.26/fs/binfmt_aout.c 2001-11-03 01:39:20.000000000 +0000
+++ linux-2.4.26-vrs1/fs/binfmt_aout.c 2004-01-14 21:32:27.000000000 +0000
@@ -422,7 +422,11 @@
start_thread(regs, ex.a_entry, current->mm->start_stack);
if (current->ptrace & PT_PTRACED)
send_sig(SIGTRAP, current, 0);
+#ifndef __arm__
return 0;
+#else
+ return regs->ARM_r0;
+#endif
}
static int load_aout_library(struct file *file)
@@ -452,8 +456,11 @@
/* For QMAGIC, the starting address is 0x20 into the page. We mask
this off to get the starting address for the page */
-
- start_addr = ex.a_entry & 0xfffff000;
+#ifndef __arm__
+ start_addr = ex.a_entry & 0xfffff000;
+#else
+ start_addr = ex.a_entry & 0xffff8000;
+#endif
if ((N_TXTOFF(ex) & ~PAGE_MASK) != 0) {
static unsigned long error_time;
diff -urN linux-2.4.26/fs/binfmt_elf.c linux-2.4.26-vrs1/fs/binfmt_elf.c
--- linux-2.4.26/fs/binfmt_elf.c 2004-04-19 11:44:28.000000000 +0100
+++ linux-2.4.26-vrs1/fs/binfmt_elf.c 2004-04-18 21:47:51.000000000 +0100
@@ -636,7 +636,6 @@
}
current->mm->start_stack = bprm->p;
-
/* Now we do a little grungy work by mmaping the ELF image into
the correct location in memory. At this point, we assume that
the image should be loaded at fixed address, not at a variable
diff -urN linux-2.4.26/fs/exec.c linux-2.4.26-vrs1/fs/exec.c
--- linux-2.4.26/fs/exec.c 2004-02-27 20:03:28.000000000 +0000
+++ linux-2.4.26-vrs1/fs/exec.c 2004-02-23 13:36:36.000000000 +0000
@@ -315,6 +315,7 @@
spin_unlock(&tsk->mm->page_table_lock);
/* no need for flush_tlb */
+ memc_update_addr(tsk->mm, *pte, address);
return;
out:
spin_unlock(&tsk->mm->page_table_lock);
diff -urN linux-2.4.26/fs/jffs/inode-v23.c linux-2.4.26-vrs1/fs/jffs/inode-v23.c
--- linux-2.4.26/fs/jffs/inode-v23.c 2001-10-04 23:14:35.000000000 +0100
+++ linux-2.4.26-vrs1/fs/jffs/inode-v23.c 2004-01-14 21:32:27.000000000 +0000
@@ -10,7 +10,7 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * $Id: inode-v23.c,v 1.70 2001/10/02 09:16:02 dwmw2 Exp $
+ * $Id: inode-v23.c,v 1.72 2002/01/31 11:42:57 cdavies Exp $
*
* Ported to Linux 2.3.x and MTD:
* Copyright (C) 2000 Alexander Larsson (alex@cendio.se), Cendio Systems AB
@@ -48,6 +48,7 @@
#include <linux/stat.h>
#include <linux/blkdev.h>
#include <linux/quotaops.h>
+#include <linux/compatmac.h>
#include <asm/semaphore.h>
#include <asm/byteorder.h>
#include <asm/uaccess.h>
@@ -58,6 +59,11 @@
#include "jffs_proc.h"
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,2)
+#define minor(x) MINOR(x)
+#define major(x) MAJOR(x)
+#endif
+
static int jffs_remove(struct inode *dir, struct dentry *dentry, int type);
static struct super_operations jffs_ops;
@@ -81,7 +87,7 @@
D1(printk(KERN_NOTICE "JFFS: Trying to mount device %s.\n",
kdevname(dev)));
- if (MAJOR(dev) != MTD_BLOCK_MAJOR) {
+ if (major(dev) != MTD_BLOCK_MAJOR) {
printk(KERN_WARNING "JFFS: Trying to mount a "
"non-mtd device.\n");
return 0;
@@ -358,7 +364,7 @@
inode->i_nlink = raw_inode->nlink;
inode->i_uid = raw_inode->uid;
inode->i_gid = raw_inode->gid;
- inode->i_rdev = 0;
+ inode->i_rdev = NODEV;
inode->i_size = raw_inode->dsize;
inode->i_atime = raw_inode->atime;
inode->i_mtime = raw_inode->mtime;
diff -urN linux-2.4.26/fs/jffs/intrep.c linux-2.4.26-vrs1/fs/jffs/intrep.c
--- linux-2.4.26/fs/jffs/intrep.c 2003-06-13 15:51:37.000000000 +0100
+++ linux-2.4.26-vrs1/fs/jffs/intrep.c 2004-01-14 21:32:27.000000000 +0000
@@ -10,7 +10,7 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * $Id: intrep.c,v 1.102 2001/09/23 23:28:36 dwmw2 Exp $
+ * $Id: intrep.c,v 1.104 2002/03/05 14:07:39 dwmw2 Exp $
*
* Ported to Linux 2.3.x and MTD:
* Copyright (C) 2000 Alexander Larsson (alex@cendio.se), Cendio Systems AB
@@ -772,6 +772,9 @@
__u32 free_chunk_size1;
__u32 free_chunk_size2;
+ __u32 largest_hole = 0;
+ __u32 hole_end_offset = 0;
+ __u32 head_offset;
#define NUMFREEALLOWED 2 /* 2 chunks of at least erase size space allowed */
int num_free_space = 0; /* Flag err if more than TWO
@@ -884,6 +887,21 @@
(unsigned int) start,
(unsigned int)(test_start - start)));
+ D1(printk("Reducing start to 0x%x from 0x%x\n",
+ test_start, start));
+ if (largest_hole < test_start - start){
+
+ D3(printk("was hole = %x end_offset = %x\n",
+ largest_hole, hole_end_offset));
+ if (fmc->head) {
+ largest_hole = test_start - start;
+ hole_end_offset = test_start;
+ }
+ }
+
+ D3(printk("now = %x end_offset = %x\n",
+ largest_hole, hole_end_offset));
+
/* below, space from "start" to "pos" will be marked dirty. */
start = test_start;
@@ -956,6 +974,19 @@
num_free_space++;
D1(printk("Free space accepted: Starting 0x%x for 0x%x bytes\n",
(unsigned int) start, (unsigned int) (pos - start)));
+
+ if (largest_hole < pos - start) {
+
+ D3(printk("was hole = %x end_offset = %x\n",
+ largest_hole, hole_end_offset));
+ if (fmc->head){
+ largest_hole = pos - start;
+ hole_end_offset = pos;
+ }
+
+ D3(printk("now = %x end_offset = %x\n",
+ largest_hole, hole_end_offset));
+ }
}else{
num_free_spc_not_accp++;
D1(printk("Free space (#%i) found but *Not* accepted: Starting "
@@ -968,7 +999,7 @@
(unsigned int) start, (unsigned int) (pos - start)));
jffs_fmalloced(fmc, (__u32) start,
(__u32) (pos - start), 0);
- }
+ }
}
if(num_free_space > NUMFREEALLOWED){
@@ -1002,9 +1033,11 @@
to scan for the magic pattern. */
D1(printk("*************** Dirty flash memory or "
"bad inode: "
- "hexdump(pos = 0x%lx, len = 128):\n",
- (long)pos));
- D1(jffs_hexdump(fmc->mtd, pos, 128));
+ "hexdump(pos = 0x%lx, len = %d):\n",
+ (long)pos,
+ end - pos > 128 ? 128 : end - pos));
+ D1(jffs_hexdump(fmc->mtd, pos,
+ end - pos > 128 ? 128 : end - pos));
for (pos += 4; pos < end; pos += 4) {
switch (flash_read_u32(fmc->mtd, pos)) {
@@ -1197,12 +1230,6 @@
return -ENOMEM;
}
- if ((err = jffs_insert_node(c, 0, &raw_inode,
- name, node)) < 0) {
- printk("JFFS: Failed to handle raw inode. "
- "(err = %d)\n", err);
- break;
- }
if (raw_inode.rename) {
struct jffs_delete_list *dl
= (struct jffs_delete_list *)
@@ -1226,6 +1253,12 @@
c->delete_list = dl;
node->data_size = 0;
}
+ if ((err = jffs_insert_node(c, 0, &raw_inode,
+ name, node)) < 0) {
+ printk("JFFS: Failed to handle raw inode. "
+ "(err = %d)\n", err);
+ break;
+ }
D3(jffs_print_node(node));
node = 0; /* Don't free the node! */
}
@@ -1242,7 +1275,19 @@
jffs_free_node(node);
DJM(no_jffs_node--);
}
- jffs_build_end(fmc);
+ if (fmc->head && fmc->tail_extra &&
+ fmc->head->offset + fmc->flash_size -
+ fmc->tail_extra->offset - fmc->tail_extra->size > largest_hole) {
+ head_offset = fmc->head->offset;
+ }
+ else {
+ head_offset = hole_end_offset;
+ }
+
+ if (jffs_build_end(fmc, head_offset) < 0) {
+ D(printk("jffs_build_end() failed\n"));
+ return -ENOMEM;
+ }
/* Free read buffer */
kfree (read_buf);
diff -urN linux-2.4.26/fs/jffs/jffs_fm.c linux-2.4.26-vrs1/fs/jffs/jffs_fm.c
--- linux-2.4.26/fs/jffs/jffs_fm.c 2001-10-04 23:13:18.000000000 +0100
+++ linux-2.4.26-vrs1/fs/jffs/jffs_fm.c 2004-01-14 21:32:27.000000000 +0000
@@ -10,7 +10,7 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * $Id: jffs_fm.c,v 1.27 2001/09/20 12:29:47 dwmw2 Exp $
+ * $Id: jffs_fm.c,v 1.29 2002/01/22 09:48:16 cdavies Exp $
*
* Ported to Linux 2.3.x and MTD:
* Copyright (C) 2000 Alexander Larsson (alex@cendio.se), Cendio Systems AB
@@ -20,8 +20,14 @@
#include <linux/slab.h>
#include <linux/blkdev.h>
#include <linux/jffs.h>
+#include <linux/compatmac.h>
#include "jffs_fm.h"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,2)
+#define minor(x) MINOR(x)
+#define major(x) MAJOR(x)
+#endif
+
#if defined(JFFS_MARK_OBSOLETE) && JFFS_MARK_OBSOLETE
static int jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset);
#endif
@@ -46,7 +52,7 @@
}
DJM(no_jffs_fmcontrol++);
- mtd = get_mtd_device(NULL, MINOR(dev));
+ mtd = get_mtd_device(NULL, minor(dev));
if (!mtd) {
kfree(fmc);
@@ -89,8 +95,8 @@
/* When the flash memory scan has completed, this function should be called
before use of the control structure. */
-void
-jffs_build_end(struct jffs_fmcontrol *fmc)
+int
+jffs_build_end(struct jffs_fmcontrol *fmc, __u32 head_offset)
{
D3(printk("jffs_build_end()\n"));
@@ -99,13 +105,100 @@
fmc->tail = fmc->tail_extra;
}
else if (fmc->head_extra) {
- fmc->tail_extra->next = fmc->head;
- fmc->head->prev = fmc->tail_extra;
- fmc->head = fmc->head_extra;
+ struct jffs_fm *fm, *cur;
+
+ if (head_offset == fmc->head->offset){
+ fmc->tail->next = fmc->head_extra;
+ fmc->head_extra->prev = fmc->tail;
+ fmc->tail = fmc->tail_extra;
+ }
+ else {
+ fmc->tail_extra->next = fmc->head;
+ fmc->head->prev = fmc->tail_extra;
+ fmc->head = fmc->head_extra;
+ while (fmc->head->offset != head_offset){
+ fmc->tail->next = fmc->head;
+ fmc->head = fmc->head->next;
+ fmc->head->prev = 0;
+ fmc->tail->next->prev = fmc->tail;
+ fmc->tail = fmc->tail->next;
+ fmc->tail->next = 0;
+ }
+ }
+ /* Make sure the only free space we have is between tail and head.
+ */
+ for (cur = fmc->head; cur && cur != fmc->tail;) {
+ if (cur->offset + cur->size < cur->next->offset) {
+ if (!(fm = kmalloc(sizeof(struct jffs_fm), GFP_KERNEL))) {
+ D(printk("jffs_buid_end(): kmalloc failed!\n"));
+ return -ENOMEM;
+ }
+ DJM(no_jffs_fm++);
+ fm->size = cur->next->offset - cur->offset - cur->size;
+ fm->offset = cur->offset + cur->size;
+ fm->nodes = 0;
+ fm->next = cur->next;
+ fm->prev = cur;
+ cur->next->prev = fm;
+ cur->next = fm;
+ cur = fm->next;
+ fmc->free_size -= fm->size;
+ fmc->dirty_size += fm->size;
+ }
+ else if (cur->offset > cur->next->offset) {
+ if (cur->offset + cur->size < fmc->flash_size){
+ if (!(fm = kmalloc(sizeof(struct jffs_fm), GFP_KERNEL))){
+
+ D(printk("jffs_buid_end(): kmalloc failed!\n"));
+ return -ENOMEM;
+ }
+ DJM(no_jffs_fm++);
+ fm->size = fmc->flash_size -
+ cur->offset - cur->size;
+ fm->nodes = 0;
+ fm->offset = cur->offset + cur->size;
+ fm->next = cur->next;
+ fm->prev = cur;
+ cur->next->prev = fm;
+ cur->next = fm;
+ cur = fm->next;
+ fmc->free_size -= fm->size;
+ fmc->dirty_size += fm->size;
+ }
+ else {
+ cur = cur->next;
+ }
+ if (cur->offset > 0) {
+
+ if (!(fm = kmalloc(sizeof(struct jffs_fm), GFP_KERNEL))) {
+ D(printk("jffs_buid_end(): kmalloc failed!\n"));
+ return -ENOMEM;
+ }
+ DJM(no_jffs_fm++);
+ fm->size = cur->offset;
+ fm->nodes = 0;
+ fm->offset = 0;
+ fm->next = cur;
+ fm->prev = cur->prev;
+ cur->prev->next = fm;
+ cur->prev = fm;
+ fmc->free_size -= fm->size;
+ fmc->dirty_size += fm->size;
+ }
+ }
+ else if (cur->offset + cur->size != cur->next->offset) {
+ printk("jffs_build_end(): Internal error.\n");
+ return -EINVAL;
+ }
+ else {
+ cur = cur->next;
+ }
+ }
}
fmc->head_extra = 0; /* These two instructions should be omitted. */
fmc->tail_extra = 0;
D3(jffs_print_fmcontrol(fmc));
+ return 0;
}
diff -urN linux-2.4.26/fs/jffs/jffs_fm.h linux-2.4.26-vrs1/fs/jffs/jffs_fm.h
--- linux-2.4.26/fs/jffs/jffs_fm.h 2001-10-04 23:13:18.000000000 +0100
+++ linux-2.4.26-vrs1/fs/jffs/jffs_fm.h 2004-04-19 17:25:23.000000000 +0100
@@ -10,7 +10,7 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
- * $Id: jffs_fm.h,v 1.13 2001/01/11 12:03:25 dwmw2 Exp $
+ * $Id: jffs_fm.h,v 1.14 2001/12/10 17:37:12 asanochkin Exp $
*
* Ported to Linux 2.3.x and MTD:
* Copyright (C) 2000 Alexander Larsson (alex@cendio.se), Cendio Systems AB
@@ -123,7 +123,7 @@
struct jffs_fmcontrol *jffs_build_begin(struct jffs_control *c, kdev_t dev);
-void jffs_build_end(struct jffs_fmcontrol *fmc);
+int jffs_build_end(struct jffs_fmcontrol *fmc, __u32 head_offset);
void jffs_cleanup_fmcontrol(struct jffs_fmcontrol *fmc);
int jffs_fmalloc(struct jffs_fmcontrol *fmc, __u32 size,
diff -urN linux-2.4.26/fs/partitions/Config.in linux-2.4.26-vrs1/fs/partitions/Config.in
--- linux-2.4.26/fs/partitions/Config.in 2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.26-vrs1/fs/partitions/Config.in 2004-01-14 21:32:27.000000000 +0000
@@ -6,6 +6,7 @@
bool ' Acorn partition support' CONFIG_ACORN_PARTITION
if [ "$CONFIG_ACORN_PARTITION" != "n" ]; then
# bool ' Cumana partition support' CONFIG_ACORN_PARTITION_CUMANA
+ bool ' EESOX partition support' CONFIG_ACORN_PARTITION_EESOX
bool ' ICS partition support' CONFIG_ACORN_PARTITION_ICS
bool ' Native filecore partition support' CONFIG_ACORN_PARTITION_ADFS
bool ' PowerTec partition support' CONFIG_ACORN_PARTITION_POWERTEC
@@ -52,6 +53,7 @@
define_bool CONFIG_ACORN_PARTITION y
define_bool CONFIG_ACORN_PARTITION_ADFS y
# define_bool CONFIG_ACORN_PARTITION_CUMANA y
+ define_bool CONFIG_ACORN_PARTITION_EESOX y
define_bool CONFIG_ACORN_PARTITION_ICS y
define_bool CONFIG_ACORN_PARTITION_POWERTEC y
define_bool CONFIG_ACORN_PARTITION_RISCIX y
diff -urN linux-2.4.26/fs/partitions/acorn.c linux-2.4.26-vrs1/fs/partitions/acorn.c
--- linux-2.4.26/fs/partitions/acorn.c 2002-08-03 01:39:45.000000000 +0100
+++ linux-2.4.26-vrs1/fs/partitions/acorn.c 2004-01-14 21:32:27.000000000 +0000
@@ -7,7 +7,10 @@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
- * Scan ADFS partitions on hard disk drives.
+ * Scan ADFS partitions on hard disk drives. Unfortunately, there
+ * isn't a standard for partitioning drives on Acorn machines, so
+ * every single manufacturer of SCSI and IDE cards created their own
+ * method.
*/
#include <linux/config.h>
#include <linux/kernel.h>
@@ -18,10 +21,18 @@
#include <linux/genhd.h>
#include <linux/fs.h>
#include <linux/pagemap.h>
+#include <linux/adfs_fs.h>
#include "check.h"
#include "acorn.h"
+/*
+ * Partition types. (Oh for reusability)
+ */
+#define PARTITION_RISCIX_MFM 1
+#define PARTITION_RISCIX_SCSI 2
+#define PARTITION_LINUX 9
+
static void
adfspart_setgeometry(kdev_t dev, unsigned int secspertrack, unsigned int heads)
{
@@ -61,6 +72,21 @@
}
#ifdef CONFIG_ACORN_PARTITION_RISCIX
+
+struct riscix_part {
+ __u32 start;
+ __u32 length;
+ __u32 one;
+ char name[16];
+};
+
+struct riscix_record {
+ __u32 magic;
+#define RISCIX_MAGIC (0x4a657320)
+ __u32 date;
+ struct riscix_part part[8];
+};
+
static int
riscix_partition(struct gendisk *hd, struct block_device *bdev,
unsigned long first_sect, int minor, unsigned long nr_sects)
@@ -102,6 +128,15 @@
}
#endif
+#define LINUX_NATIVE_MAGIC 0xdeafa1de
+#define LINUX_SWAP_MAGIC 0xdeafab1e
+
+struct linux_part {
+ __u32 magic;
+ __u32 start_sect;
+ __u32 nr_sects;
+};
+
static int
linux_partition(struct gendisk *hd, struct block_device *bdev,
unsigned long first_sect, int minor, unsigned long nr_sects)
@@ -136,7 +171,7 @@
}
#ifdef CONFIG_ACORN_PARTITION_CUMANA
-static int
+int
adfspart_check_CUMANA(struct gendisk *hd, struct block_device *bdev,
unsigned long first_sector, int minor)
{
@@ -147,7 +182,7 @@
int first = 1;
/*
- * Try Cumana style partitions - sector 3 contains ADFS boot block
+ * Try Cumana style partitions - sector 6 contains ADFS boot block
* with pointer to next 'drive'.
*
* There are unknowns in this code - is the 'cylinder number' of the
@@ -163,13 +198,13 @@
struct adfs_discrecord *dr;
unsigned int nr_sects;
- if (!(minor & mask))
- break;
-
data = read_dev_sector(bdev, start_blk * 2 + 6, §);
if (!data)
return -1;
+ if (!(minor & mask))
+ break;
+
dr = adfs_partition(hd, name, data, first_sector, minor++);
if (!dr)
break;
@@ -229,7 +264,7 @@
* hda1 = ADFS partition on first drive.
* hda2 = non-ADFS partition.
*/
-static int
+int
adfspart_check_ADFS(struct gendisk *hd, struct block_device *bdev,
unsigned long first_sector, int minor)
{
@@ -282,11 +317,18 @@
break;
}
}
+ printk("\n");
return 1;
}
#endif
#ifdef CONFIG_ACORN_PARTITION_ICS
+
+struct ics_part {
+ __u32 start;
+ __s32 size;
+};
+
static int adfspart_check_ICSLinux(struct block_device *bdev, unsigned long block)
{
Sector sect;
@@ -303,6 +345,22 @@
}
/*
+ * Check for a valid ICS partition using the checksum.
+ */
+static inline int valid_ics_sector(const unsigned char *data)
+{
+ unsigned long sum;
+ int i;
+
+ for (i = 0, sum = 0x50617274; i < 508; i++)
+ sum += data[i];
+
+ sum -= le32_to_cpu(*(__u32 *)(&data[508]));
+
+ return sum == 0;
+}
+
+/*
* Purpose: allocate ICS partitions.
* Params : hd - pointer to gendisk structure to store partition info.
* dev - device number to access.
@@ -314,15 +372,14 @@
* hda2 = ADFS partition 1 on first drive.
* ..etc..
*/
-static int
+int
adfspart_check_ICS(struct gendisk *hd, struct block_device *bdev,
unsigned long first_sector, int minor)
{
+ const unsigned char *data;
+ const struct ics_part *p;
+ unsigned int mask = (1 << hd->minor_shift) - 1;
Sector sect;
- unsigned char *data;
- unsigned long sum;
- unsigned int i, mask = (1 << hd->minor_shift) - 1;
- struct ics_part *p;
/*
* Try ICS style partitions - sector 0 contains partition info.
@@ -331,21 +388,14 @@
if (!data)
return -1;
- /*
- * check for a valid checksum
- */
- for (i = 0, sum = 0x50617274; i < 508; i++)
- sum += data[i];
-
- sum -= le32_to_cpu(*(__u32 *)(&data[508]));
- if (sum) {
- put_dev_sector(sect);
- return 0; /* not ICS partition table */
+ if (!valid_ics_sector(data)) {
+ put_dev_sector(sect);
+ return 0;
}
printk(" [ICS]");
- for (p = (struct ics_part *)data; p->size; p++) {
+ for (p = (const struct ics_part *)data; p->size; p++) {
unsigned long start;
long size;
@@ -355,12 +405,19 @@
start = le32_to_cpu(p->start);
size = le32_to_cpu(p->size);
+ /*
+ * Negative sizes tell the RISC OS ICS driver to ignore
+ * this partition - in effect it says that this does not
+ * contain an ADFS filesystem.
+ */
if (size < 0) {
size = -size;
/*
- * We use the first sector to identify what type
- * this partition is...
+ * Our own extension - We use the first sector
+ * of the partition to identify what type this
+ * partition is. We must not make this visible
+ * to the filesystem.
*/
if (size > 1 && adfspart_check_ICSLinux(bdev, start)) {
start += 1;
@@ -375,10 +432,32 @@
}
put_dev_sector(sect);
+ printk("\n");
return 1;
}
#endif
+#ifdef CONFIG_ACORN_PARTITION_POWERTEC
+struct ptec_part {
+ __u32 unused1;
+ __u32 unused2;
+ __u32 start;
+ __u32 size;
+ __u32 unused5;
+ char type[8];
+};
+
+static inline int valid_ptec_sector(const unsigned char *data)
+{
+ unsigned char checksum = 0x2a;
+ int i;
+
+ for (i = 0; i < 511; i++)
+ checksum += data[i];
+
+ return checksum == data[511];
+}
+
/*
* Purpose: allocate ICS partitions.
* Params : hd - pointer to gendisk structure to store partition info.
@@ -391,32 +470,27 @@
* hda2 = ADFS partition 1 on first drive.
* ..etc..
*/
-#ifdef CONFIG_ACORN_PARTITION_POWERTEC
-static int
+int
adfspart_check_POWERTEC(struct gendisk *hd, struct block_device *bdev,
unsigned long first_sector, int minor)
{
Sector sect;
- unsigned char *data;
- struct ptec_partition *p;
- unsigned char checksum;
+ const unsigned char *data;
+ const struct ptec_part *p;
int i;
data = read_dev_sector(bdev, 0, §);
if (!data)
return -1;
- for (checksum = 0x2a, i = 0; i < 511; i++)
- checksum += data[i];
-
- if (checksum != data[511]) {
+ if (!valid_ptec_sector(data)) {
put_dev_sector(sect);
return 0;
}
printk(" [POWERTEC]");
- for (i = 0, p = (struct ptec_partition *)data; i < 12; i++, p++) {
+ for (i = 0, p = (const struct ptec_part *)data; i < 12; i++, p++) {
unsigned long start;
unsigned long size;
@@ -430,49 +504,82 @@
}
put_dev_sector(sect);
+ printk("\n");
return 1;
}
#endif
-static int (*partfn[])(struct gendisk *, struct block_device *, unsigned long, int) = {
-#ifdef CONFIG_ACORN_PARTITION_ICS
- adfspart_check_ICS,
-#endif
-#ifdef CONFIG_ACORN_PARTITION_POWERTEC
- adfspart_check_POWERTEC,
-#endif
-#ifdef CONFIG_ACORN_PARTITION_CUMANA
- adfspart_check_CUMANA,
-#endif
-#ifdef CONFIG_ACORN_PARTITION_ADFS
- adfspart_check_ADFS,
-#endif
- NULL
+#ifdef CONFIG_ACORN_PARTITION_EESOX
+struct eesox_part {
+ char magic[6];
+ char name[10];
+ u32 start;
+ u32 unused6;
+ u32 unused7;
+ u32 unused8;
};
+
/*
- * Purpose: initialise all the partitions on an ADFS drive.
- * These may be other ADFS partitions or a Linux/RiscBSD/RISCiX
- * partition.
+ * Guess who created this format?
+ */
+static const char eesox_name[] = {
+ 'N', 'e', 'i', 'l', ' ',
+ 'C', 'r', 'i', 't', 'c', 'h', 'e', 'l', 'l', ' ', ' '
+};
+
+/*
+ * EESOX SCSI partition format.
*
- * Params : hd - pointer to gendisk structure
- * dev - device number to access
- * first_sect - first available sector on the disk.
- * first_minor - first available minor on this device.
+ * This is a goddamned awful partition format. We don't seem to store
+ * the size of the partition in this table, only the start addresses.
*
- * Returns: -1 on error, 0 if not ADFS format, 1 if ok.
+ * There are two possibilities where the size comes from:
+ * 1. The individual ADFS boot block entries that are placed on the disk.
+ * 2. The start address of the next entry.
*/
-int acorn_partition(struct gendisk *hd, struct block_device *bdev,
- unsigned long first_sect, int first_minor)
+int
+adfspart_check_EESOX(struct gendisk *hd, struct block_device *bdev,
+ unsigned long first_sector, int minor)
{
+ Sector sect;
+ const unsigned char *data;
+ unsigned char buffer[256];
+ struct eesox_part *p;
+ u32 start = first_sector;
int i;
- for (i = 0; partfn[i]; i++) {
- int r = partfn[i](hd, bdev, first_sect, first_minor);
- if (r) {
- if (r > 0)
- printk("\n");
- return r;
- }
+ data = read_dev_sector(bdev, 7, §);
+ if (!data)
+ return -1;
+
+ /*
+ * "Decrypt" the partition table. God knows why...
+ */
+ for (i = 0; i < 256; i++)
+ buffer[i] = data[i] ^ eesox_name[i & 15];
+
+ put_dev_sector(sect);
+
+ for (i = 0, p = (struct eesox_part *)buffer; i < 8; i++, p++) {
+ u32 next;
+
+ if (memcmp(p->magic, "Eesox", 6))
+ break;
+
+ next = le32_to_cpu(p->start) + first_sector;
+ if (i)
+ add_gd_partition(hd, minor++, start, next - start);
+ start = next;
}
- return 0;
+
+ if (i != 0) {
+ unsigned long size;
+
+ size = hd->part[MINOR(to_kdev_t(bdev->bd_dev))].nr_sects;
+ add_gd_partition(hd, minor++, start, size - start);
+ printk("\n");
+ }
+
+ return i ? 1 : 0;
}
+#endif
diff -urN linux-2.4.26/fs/partitions/acorn.h linux-2.4.26-vrs1/fs/partitions/acorn.h
--- linux-2.4.26/fs/partitions/acorn.h 2001-11-22 19:48:07.000000000 +0000
+++ linux-2.4.26-vrs1/fs/partitions/acorn.h 2004-01-14 21:32:27.000000000 +0000
@@ -1,55 +1,28 @@
/*
- * fs/partitions/acorn.h
+ * linux/fs/partitions/acorn.h
*
- * Copyright (C) 1996-1998 Russell King
- */
-#include <linux/adfs_fs.h>
-
-/*
- * Partition types. (Oh for reusability)
+ * Copyright (C) 1996-2001 Russell King.
+ *
+ * I _hate_ this partitioning mess - why can't we have one defined
+ * format, and everyone stick to it?
*/
-#define PARTITION_RISCIX_MFM 1
-#define PARTITION_RISCIX_SCSI 2
-#define PARTITION_LINUX 9
-
-struct riscix_part {
- __u32 start;
- __u32 length;
- __u32 one;
- char name[16];
-};
-
-struct riscix_record {
- __u32 magic;
-#define RISCIX_MAGIC (0x4a657320)
- __u32 date;
- struct riscix_part part[8];
-};
-
-#define LINUX_NATIVE_MAGIC 0xdeafa1de
-#define LINUX_SWAP_MAGIC 0xdeafab1e
-
-struct linux_part {
- __u32 magic;
- __u32 start_sect;
- __u32 nr_sects;
-};
-
-struct ics_part {
- __u32 start;
- __s32 size;
-};
-
-struct ptec_partition {
- __u32 unused1;
- __u32 unused2;
- __u32 start;
- __u32 size;
- __u32 unused5;
- char type[8];
-};
-
-
-int acorn_partition(struct gendisk *hd, struct block_device *bdev,
- unsigned long first_sect, int first_minor);
+int
+adfspart_check_CUMANA(struct gendisk *hd, struct block_device *bdev,
+ unsigned long first_sector, int minor);
+
+int
+adfspart_check_ADFS(struct gendisk *hd, struct block_device *bdev,
+ unsigned long first_sector, int minor);
+
+int
+adfspart_check_ICS(struct gendisk *hd, struct block_device *bdev,
+ unsigned long first_sector, int minor);
+
+int
+adfspart_check_POWERTEC(struct gendisk *hd, struct block_device *bdev,
+ unsigned long first_sector, int minor);
+
+int
+adfspart_check_EESOX(struct gendisk *hd, struct block_device *bdev,
+ unsigned long first_sector, int minor);
diff -urN linux-2.4.26/fs/partitions/check.c linux-2.4.26-vrs1/fs/partitions/check.c
--- linux-2.4.26/fs/partitions/check.c 2004-02-27 20:03:28.000000000 +0000
+++ linux-2.4.26-vrs1/fs/partitions/check.c 2004-02-24 09:37:29.000000000 +0000
@@ -40,8 +40,30 @@
int warn_no_part = 1; /*This is ugly: should make genhd removable media aware*/
static int (*check_part[])(struct gendisk *hd, struct block_device *bdev, unsigned long first_sect, int first_minor) = {
-#ifdef CONFIG_ACORN_PARTITION
- acorn_partition,
+ /*
+ * Probe partition formats with tables at disk address 0
+ * that also have an ADFS boot block at 0xdc0.
+ */
+#ifdef CONFIG_ACORN_PARTITION_ICS
+ adfspart_check_ICS,
+#endif
+#ifdef CONFIG_ACORN_PARTITION_POWERTEC
+ adfspart_check_POWERTEC,
+#endif
+#ifdef CONFIG_ACORN_PARTITION_EESOX
+ adfspart_check_EESOX,
+#endif
+
+ /*
+ * Now move on to formats that only have partition info at
+ * disk address 0xdc0. These should come before MSDOS
+ * partition tables.
+ */
+#ifdef CONFIG_ACORN_PARTITION_CUMANA
+ adfspart_check_CUMANA,
+#endif
+#ifdef CONFIG_ACORN_PARTITION_ADFS
+ adfspart_check_ADFS,
#endif
#ifdef CONFIG_SGI_PARTITION
sgi_partition,
@@ -79,13 +101,25 @@
NULL
};
+static char *raid_name (struct gendisk *hd, unsigned int unit, unsigned int part,
+ int major_base, char *buf)
+{
+ int ctlr = hd->major - major_base;
+ if (part == 0)
+ sprintf(buf, "%s/c%dd%d", hd->major_name, ctlr, unit);
+ else
+ sprintf(buf, "%s/c%dd%dp%d", hd->major_name, ctlr, unit,
+ part);
+ return buf;
+}
+
/*
* This is ucking fugly but its probably the best thing for 2.4.x
* Take it as a clear reminder that: 1) we should put the device name
* generation in the object kdev_t points to in 2.5.
* and 2) ioctls better work on half-opened devices.
*/
-
+
#ifdef CONFIG_ARCH_S390
int (*genhd_dasd_name)(char*,int,int,struct gendisk*) = NULL;
int (*genhd_dasd_ioctl)(struct inode *inp, struct file *filp,
@@ -104,10 +138,11 @@
char *disk_name (struct gendisk *hd, int minor, char *buf)
{
const char *maj = hd->major_name;
- unsigned int unit = (minor >> hd->minor_shift);
- unsigned int part = (minor & ((1 << hd->minor_shift) -1 ));
+ unsigned int unit = minor >> hd->minor_shift;
+ unsigned int part = minor & (( 1 << hd->minor_shift) - 1);
+ char *p;
- if ((unit < hd->nr_real) && hd->part[minor].de) {
+ if (unit < hd->nr_real && hd->part[minor].de) {
int pos;
pos = devfs_generate_path (hd->part[minor].de, buf, 64);
@@ -153,51 +188,32 @@
}
if (hd->major >= SCSI_DISK1_MAJOR && hd->major <= SCSI_DISK7_MAJOR) {
unit = unit + (hd->major - SCSI_DISK1_MAJOR + 1) * 16;
- if (unit+'a' > 'z') {
- unit -= 26;
- sprintf(buf, "sd%c%c", 'a' + unit / 26, 'a' + unit % 26);
- if (part)
- sprintf(buf + 4, "%d", part);
- return buf;
- }
}
if (hd->major >= COMPAQ_SMART2_MAJOR && hd->major <= COMPAQ_SMART2_MAJOR+7) {
- int ctlr = hd->major - COMPAQ_SMART2_MAJOR;
- if (part == 0)
- sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
- else
- sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part);
- return buf;
- }
+ return raid_name(hd, unit, part, COMPAQ_SMART2_MAJOR, buf);
+ }
if (hd->major >= COMPAQ_CISS_MAJOR && hd->major <= COMPAQ_CISS_MAJOR+7) {
- int ctlr = hd->major - COMPAQ_CISS_MAJOR;
- if (part == 0)
- sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
- else
- sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part);
- return buf;
+ return raid_name(hd, unit, part, COMPAQ_CISS_MAJOR, buf);
}
if (hd->major >= DAC960_MAJOR && hd->major <= DAC960_MAJOR+7) {
- int ctlr = hd->major - DAC960_MAJOR;
+ return raid_name(hd, unit, part, DAC960_MAJOR, buf);
+ }
+ if (hd->major == ATARAID_MAJOR) {
+ int disk = minor >> hd->minor_shift;
+ int part = minor & (( 1 << hd->minor_shift) - 1);
if (part == 0)
- sprintf(buf, "%s/c%dd%d", maj, ctlr, unit);
+ sprintf(buf, "%s/d%d", maj, disk);
else
- sprintf(buf, "%s/c%dd%dp%d", maj, ctlr, unit, part);
+ sprintf(buf, "%s/d%dp%d", maj, disk, part);
return buf;
}
- if (hd->major == ATARAID_MAJOR) {
- int disk = minor >> hd->minor_shift;
- int part = minor & (( 1 << hd->minor_shift) - 1);
- if (part == 0)
- sprintf(buf, "%s/d%d", maj, disk);
- else
- sprintf(buf, "%s/d%dp%d", maj, disk, part);
- return buf;
- }
- if (part)
- sprintf(buf, "%s%c%d", maj, unit+'a', part);
+ p = buf;
+ if (unit <= 26)
+ p += sprintf(buf, "%s%c", maj, 'a' + unit);
else
- sprintf(buf, "%s%c", maj, unit+'a');
+ p += sprintf(buf, "%s%c%c", maj, 'a' + unit / 26, 'a' + unit % 26);
+ if (part)
+ sprintf(p, "%d", part);
return buf;
}
@@ -207,7 +223,7 @@
void add_gd_partition(struct gendisk *hd, int minor, int start, int size)
{
#ifndef CONFIG_DEVFS_FS
- char buf[40];
+ char buf[MAX_DISKNAME_LEN];
#endif
hd->part[minor].start_sect = start;
@@ -229,7 +245,7 @@
static int first_time = 1;
unsigned long first_sector;
struct block_device *bdev;
- char buf[64];
+ char buf[MAX_DISKNAME_LEN];
int i;
if (first_time)
diff -urN linux-2.4.26/fs/proc/array.c linux-2.4.26-vrs1/fs/proc/array.c
--- linux-2.4.26/fs/proc/array.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/fs/proc/array.c 2004-01-14 21:39:17.000000000 +0000
@@ -362,15 +362,15 @@
task->cmin_flt,
task->maj_flt,
task->cmaj_flt,
- task->times.tms_utime,
- task->times.tms_stime,
- task->times.tms_cutime,
- task->times.tms_cstime,
+ hz_to_std(task->times.tms_utime),
+ hz_to_std(task->times.tms_stime),
+ hz_to_std(task->times.tms_cutime),
+ hz_to_std(task->times.tms_cstime),
priority,
nice,
0UL /* removed */,
task->it_real_value,
- task->start_time,
+ hz_to_std(task->start_time),
vsize,
mm ? mm->rss : 0, /* you might want to shift this left 3 */
task->rlim[RLIMIT_RSS].rlim_cur,
@@ -417,6 +417,7 @@
end = PMD_SIZE;
do {
pte_t page = *pte;
+ unsigned long pfn;
struct page *ptpage;
address += PAGE_SIZE;
@@ -426,8 +427,11 @@
++*total;
if (!pte_present(page))
continue;
- ptpage = pte_page(page);
- if ((!VALID_PAGE(ptpage)) || PageReserved(ptpage))
+ pfn = pte_pfn(page);
+ if (!pfn_valid(pfn))
+ continue;
+ ptpage = pfn_to_page(pfn);
+ if (PageReserved(ptpage))
continue;
++*pages;
if (pte_dirty(page))
@@ -609,14 +613,14 @@
len = sprintf(buffer,
"cpu %lu %lu\n",
- task->times.tms_utime,
- task->times.tms_stime);
+ hz_to_std(task->times.tms_utime),
+ hz_to_std(task->times.tms_stime));
for (i = 0 ; i < smp_num_cpus; i++)
len += sprintf(buffer + len, "cpu%d %lu %lu\n",
i,
- task->per_cpu_utime[cpu_logical_map(i)],
- task->per_cpu_stime[cpu_logical_map(i)]);
+ hz_to_std(task->per_cpu_utime[cpu_logical_map(i)]),
+ hz_to_std(task->per_cpu_stime[cpu_logical_map(i)]));
return len;
}
diff -urN linux-2.4.26/fs/proc/proc_misc.c linux-2.4.26-vrs1/fs/proc/proc_misc.c
--- linux-2.4.26/fs/proc/proc_misc.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/fs/proc/proc_misc.c 2004-01-26 00:27:12.000000000 +0000
@@ -308,16 +308,16 @@
{
int i, len = 0;
extern unsigned long total_forks;
- unsigned long jif = jiffies;
+ unsigned long jif = hz_to_std(jiffies);
unsigned int sum = 0, user = 0, nice = 0, system = 0;
int major, disk;
for (i = 0 ; i < smp_num_cpus; i++) {
int cpu = cpu_logical_map(i), j;
- user += kstat.per_cpu_user[cpu];
- nice += kstat.per_cpu_nice[cpu];
- system += kstat.per_cpu_system[cpu];
+ user += hz_to_std(kstat.per_cpu_user[cpu]);
+ nice += hz_to_std(kstat.per_cpu_nice[cpu]);
+ system += hz_to_std(kstat.per_cpu_system[cpu]);
#if !defined(CONFIG_ARCH_S390)
for (j = 0 ; j < NR_IRQS ; j++)
sum += kstat.irqs[cpu][j];
@@ -331,10 +331,10 @@
proc_sprintf(page, &off, &len,
"cpu%d %u %u %u %lu\n",
i,
- kstat.per_cpu_user[cpu_logical_map(i)],
- kstat.per_cpu_nice[cpu_logical_map(i)],
- kstat.per_cpu_system[cpu_logical_map(i)],
- jif - ( kstat.per_cpu_user[cpu_logical_map(i)] \
+ hz_to_std(kstat.per_cpu_user[cpu_logical_map(i)]),
+ hz_to_std(kstat.per_cpu_nice[cpu_logical_map(i)]),
+ hz_to_std(kstat.per_cpu_system[cpu_logical_map(i)]),
+ jif - hz_to_std( kstat.per_cpu_user[cpu_logical_map(i)] \
+ kstat.per_cpu_nice[cpu_logical_map(i)] \
+ kstat.per_cpu_system[cpu_logical_map(i)]));
proc_sprintf(page, &off, &len,
@@ -440,12 +440,14 @@
return proc_calc_metrics(page, start, off, count, eof, len);
}
+#ifdef CONFIG_GENERIC_ISA_DMA
static int dma_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = get_dma_list(page);
return proc_calc_metrics(page, start, off, count, eof, len);
}
+#endif
static int cmdline_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
@@ -613,7 +615,9 @@
{"interrupts", interrupts_read_proc},
#endif
{"filesystems", filesystems_read_proc},
+#ifdef CONFIG_GENERIC_ISA_DMA
{"dma", dma_read_proc},
+#endif
{"cmdline", cmdline_read_proc},
#ifdef CONFIG_SGI_DS1286
{"rtc", ds1286_read_proc},
diff -urN linux-2.4.26/fs/stat.c linux-2.4.26-vrs1/fs/stat.c
--- linux-2.4.26/fs/stat.c 2004-02-27 20:03:28.000000000 +0000
+++ linux-2.4.26-vrs1/fs/stat.c 2004-02-27 23:57:43.000000000 +0000
@@ -26,7 +26,9 @@
}
-#if !defined(__alpha__) && !defined(__sparc__) && !defined(__ia64__) && !defined(CONFIG_ARCH_S390) && !defined(__hppa__) && !defined(__x86_64__) && !defined(__mips__)
+#if !defined(__alpha__) && !defined(__sparc__) && !defined(__ia64__) && \
+ !defined(CONFIG_ARCH_S390) && !defined(__hppa__) && !defined(__arm__) && \
+ !defined(__x86_64__) && !defined(__mips__)
/*
* For backward compatibility? Maybe this should be moved
@@ -38,7 +40,7 @@
struct __old_kernel_stat tmp;
memset(&tmp, 0, sizeof(struct __old_kernel_stat));
-
+
if (warncount > 0) {
warncount--;
printk(KERN_WARNING "VFS: Warning: %s using old stat() call. Recompile your binary.\n",
@@ -58,7 +60,7 @@
#if BITS_PER_LONG == 32
if (inode->i_size > MAX_NON_LFS)
return -EOVERFLOW;
-#endif
+#endif
tmp.st_size = inode->i_size;
tmp.st_atime = inode->i_atime;
tmp.st_mtime = inode->i_mtime;
@@ -84,7 +86,7 @@
#if BITS_PER_LONG == 32
if (inode->i_size > MAX_NON_LFS)
return -EOVERFLOW;
-#endif
+#endif
tmp.st_size = inode->i_size;
tmp.st_atime = inode->i_atime;
tmp.st_mtime = inode->i_mtime;
@@ -129,7 +131,9 @@
}
-#if !defined(__alpha__) && !defined(__sparc__) && !defined(__ia64__) && !defined(CONFIG_ARCH_S390) && !defined(__hppa__) && !defined(__x86_64__) && !defined(__mips__)
+#if !defined(__alpha__) && !defined(__sparc__) && !defined(__ia64__) && \
+ !defined(CONFIG_ARCH_S390) && !defined(__hppa__) && !defined(__arm__) && \
+ !defined(__x86_64__) && !defined(__mips__)
/*
* For backward compatibility? Maybe this should be moved
* into arch/i386 instead?
@@ -165,7 +169,9 @@
return error;
}
-#if !defined(__alpha__) && !defined(__sparc__) && !defined(__ia64__) && !defined(CONFIG_ARCH_S390) && !defined(__hppa__) && !defined(__x86_64__) && !defined(__mips__)
+#if !defined(__alpha__) && !defined(__sparc__) && !defined(__ia64__) && \
+ !defined(CONFIG_ARCH_S390) && !defined(__hppa__) && !defined(__arm__) && \
+ !defined(__x86_64__) && !defined(__mips__)
/*
* For backward compatibility? Maybe this should be moved
@@ -203,7 +209,9 @@
return error;
}
-#if !defined(__alpha__) && !defined(__sparc__) && !defined(__ia64__) && !defined(CONFIG_ARCH_S390) && !defined(__hppa__) && !defined(__x86_64__) && !defined(__mips__)
+#if !defined(__alpha__) && !defined(__sparc__) && !defined(__ia64__) && \
+ !defined(CONFIG_ARCH_S390) && !defined(__hppa__) && !defined(__arm__) && \
+ !defined(__x86_64__) && !defined(__mips__)
/*
* For backward compatibility? Maybe this should be moved
diff -urN linux-2.4.26/include/asm-alpha/ide.h linux-2.4.26-vrs1/include/asm-alpha/ide.h
--- linux-2.4.26/include/asm-alpha/ide.h 2003-06-13 15:51:38.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-alpha/ide.h 2004-01-14 21:32:27.000000000 +0000
@@ -19,35 +19,15 @@
#define MAX_HWIFS 4
#endif
-static __inline__ int ide_default_irq(ide_ioreg_t base)
-{
- switch (base) {
- case 0x1f0: return 14;
- case 0x170: return 15;
- case 0x1e8: return 11;
- case 0x168: return 10;
- default:
- return 0;
- }
-}
-
-static __inline__ ide_ioreg_t ide_default_io_base(int index)
-{
- switch (index) {
- case 0: return 0x1f0;
- case 1: return 0x170;
- case 2: return 0x1e8;
- case 3: return 0x168;
- default:
- return 0;
- }
-}
+#define ide_default_io_base(i) ((ide_ioreg_t)0)
+#define ide_default_irq(b) (0)
static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
{
ide_ioreg_t reg = data_port;
int i;
+ memset(hw, 0, sizeof(*hw));
for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
hw->io_ports[i] = reg;
reg += 1;
@@ -55,7 +35,7 @@
if (ctrl_port) {
hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
} else {
- hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206;
+ hw->io_ports[IDE_CONTROL_OFFSET] = data_port + 0x206;
}
if (irq != NULL)
*irq = 0;
@@ -70,13 +50,19 @@
{
#ifndef CONFIG_BLK_DEV_IDEPCI
hw_regs_t hw;
- int index;
- for (index = 0; index < MAX_HWIFS; index++) {
- ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
- hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
- }
+ ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
+ hw.irq = 14;
+ ide_register_hw(&hw, NULL);
+ ide_init_hwif_ports(&hw, 0x170, 0x376, NULL);
+ hw.irq = 15;
+ ide_register_hw(&hw, NULL);
+ ide_init_hwif_ports(&hw, 0x1e8, 0x3ee, NULL);
+ hw.irq = 11;
+ ide_register_hw(&hw, NULL);
+ ide_init_hwif_ports(&hw, 0x168, 0x36e, NULL);
+ hw.irq = 10;
+ ide_register_hw(&hw, NULL);
#endif /* CONFIG_BLK_DEV_IDEPCI */
}
diff -urN linux-2.4.26/include/asm-alpha/param.h linux-2.4.26-vrs1/include/asm-alpha/param.h
--- linux-2.4.26/include/asm-alpha/param.h 2000-11-08 07:37:31.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-alpha/param.h 2004-01-14 21:32:27.000000000 +0000
@@ -13,6 +13,9 @@
# else
# define HZ 1200
# endif
+#ifdef __KERNEL__
+# define hz_to_std(a) (a)
+#endif
#endif
#define EXEC_PAGESIZE 8192
diff -urN linux-2.4.26/include/asm-arm/arch-at91rm9200/AT91RM9200.h linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/AT91RM9200.h
--- linux-2.4.26/include/asm-arm/arch-at91rm9200/AT91RM9200.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/AT91RM9200.h 2004-04-10 12:28:14.000000000 +0100
@@ -171,7 +171,7 @@
#define AT91C_PA23_TXD2 (AT91C_PIO_PA23) // USART 2 Transmit Data
#define AT91C_PA23_IRQ3 (AT91C_PIO_PA23) // Interrupt input 3
#define AT91C_PIO_PA24 (1 << 24)
-#define AT91C_PA24_SCK2 (AT91C_PIO_PA24) // USART2 Serial Clock
+#define AT91C_PA24_SCK2 (AT91C_PIO_PA24) // USART 2 Serial Clock
#define AT91C_PA24_PCK1 (AT91C_PIO_PA24) // PMC Programmable Clock Output 1
#define AT91C_PIO_PA25 (1 << 25)
#define AT91C_PA25_TWD (AT91C_PIO_PA25) // TWI Two-wire Serial Data
@@ -260,7 +260,7 @@
#define AT91C_PIO_PB21 (1 << 21)
#define AT91C_PB21_RXD1 (AT91C_PIO_PB21) // USART 1 Receive Data
#define AT91C_PIO_PB22 (1 << 22)
-#define AT91C_PB22_SCK1 (AT91C_PIO_PB22) // USART1 Serial Clock
+#define AT91C_PB22_SCK1 (AT91C_PIO_PB22) // USART 1 Serial Clock
#define AT91C_PIO_PB23 (1 << 23)
#define AT91C_PB23_DCD1 (AT91C_PIO_PB23) // USART 1 Data Carrier Detect
#define AT91C_PIO_PB24 (1 << 24)
diff -urN linux-2.4.26/include/asm-arm/arch-at91rm9200/AT91RM9200_MCI.h linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/AT91RM9200_MCI.h
--- linux-2.4.26/include/asm-arm/arch-at91rm9200/AT91RM9200_MCI.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/AT91RM9200_MCI.h 2004-03-04 21:44:12.000000000 +0000
@@ -0,0 +1,127 @@
+// ----------------------------------------------------------------------------
+// ATMEL Microcontroller Software Support - ROUSSET -
+// ----------------------------------------------------------------------------
+// The software is delivered "AS IS" without warranty or condition of any
+// kind, either express, implied or statutory. This includes without
+// limitation any warranty or condition with respect to merchantability or
+// fitness for any particular purpose, or against the infringements of
+// intellectual property rights of others.
+// ----------------------------------------------------------------------------
+// File Name : AT91RM9200.h
+// Object : AT91RM9200 / MCI definitions
+// Generated : AT91 SW Application Group 12/03/2002 (10:48:02)
+//
+// ----------------------------------------------------------------------------
+
+#ifndef AT91RM9200_MCI_H
+#define AT91RM9200_MCI_H
+
+// *****************************************************************************
+// SOFTWARE API DEFINITION FOR Multimedia Card Interface
+// *****************************************************************************
+#ifndef __ASSEMBLY__
+
+typedef struct _AT91S_MCI {
+ AT91_REG MCI_CR; // MCI Control Register
+ AT91_REG MCI_MR; // MCI Mode Register
+ AT91_REG MCI_DTOR; // MCI Data Timeout Register
+ AT91_REG MCI_SDCR; // MCI SD Card Register
+ AT91_REG MCI_ARGR; // MCI Argument Register
+ AT91_REG MCI_CMDR; // MCI Command Register
+ AT91_REG Reserved0[2]; //
+ AT91_REG MCI_RSPR[4]; // MCI Response Register
+ AT91_REG MCI_RDR; // MCI Receive Data Register
+ AT91_REG MCI_TDR; // MCI Transmit Data Register
+ AT91_REG Reserved1[2]; //
+ AT91_REG MCI_SR; // MCI Status Register
+ AT91_REG MCI_IER; // MCI Interrupt Enable Register
+ AT91_REG MCI_IDR; // MCI Interrupt Disable Register
+ AT91_REG MCI_IMR; // MCI Interrupt Mask Register
+ AT91_REG Reserved2[44]; //
+ AT91_REG MCI_RPR; // Receive Pointer Register
+ AT91_REG MCI_RCR; // Receive Counter Register
+ AT91_REG MCI_TPR; // Transmit Pointer Register
+ AT91_REG MCI_TCR; // Transmit Counter Register
+ AT91_REG MCI_RNPR; // Receive Next Pointer Register
+ AT91_REG MCI_RNCR; // Receive Next Counter Register
+ AT91_REG MCI_TNPR; // Transmit Next Pointer Register
+ AT91_REG MCI_TNCR; // Transmit Next Counter Register
+ AT91_REG MCI_PTCR; // PDC Transfer Control Register
+ AT91_REG MCI_PTSR; // PDC Transfer Status Register
+} AT91S_MCI, *AT91PS_MCI;
+
+#endif
+
+// -------- MCI_CR : (MCI Offset: 0x0) MCI Control Register --------
+#define AT91C_MCI_MCIEN ((unsigned int) 0x1 << 0) // (MCI) Multimedia Interface Enable
+#define AT91C_MCI_MCIDIS ((unsigned int) 0x1 << 1) // (MCI) Multimedia Interface Disable
+#define AT91C_MCI_PWSEN ((unsigned int) 0x1 << 2) // (MCI) Power Save Mode Enable
+#define AT91C_MCI_PWSDIS ((unsigned int) 0x1 << 3) // (MCI) Power Save Mode Disable
+// -------- MCI_MR : (MCI Offset: 0x4) MCI Mode Register --------
+#define AT91C_MCI_CLKDIV ((unsigned int) 0x1 << 0) // (MCI) Clock Divider
+#define AT91C_MCI_PWSDIV ((unsigned int) 0x1 << 8) // (MCI) Power Saving Divider
+#define AT91C_MCI_PDCPADV ((unsigned int) 0x1 << 14) // (MCI) PDC Padding Value
+#define AT91C_MCI_PDCMODE ((unsigned int) 0x1 << 15) // (MCI) PDC Oriented Mode
+#define AT91C_MCI_BLKLEN ((unsigned int) 0x1 << 18) // (MCI) Data Block Length
+// -------- MCI_DTOR : (MCI Offset: 0x8) MCI Data Timeout Register --------
+#define AT91C_MCI_DTOCYC ((unsigned int) 0x1 << 0) // (MCI) Data Timeout Cycle Number
+#define AT91C_MCI_DTOMUL ((unsigned int) 0x7 << 4) // (MCI) Data Timeout Multiplier
+#define AT91C_MCI_DTOMUL_1 ((unsigned int) 0x0 << 4) // (MCI) DTOCYC x 1
+#define AT91C_MCI_DTOMUL_16 ((unsigned int) 0x1 << 4) // (MCI) DTOCYC x 16
+#define AT91C_MCI_DTOMUL_128 ((unsigned int) 0x2 << 4) // (MCI) DTOCYC x 128
+#define AT91C_MCI_DTOMUL_256 ((unsigned int) 0x3 << 4) // (MCI) DTOCYC x 256
+#define AT91C_MCI_DTOMUL_1024 ((unsigned int) 0x4 << 4) // (MCI) DTOCYC x 1024
+#define AT91C_MCI_DTOMUL_4096 ((unsigned int) 0x5 << 4) // (MCI) DTOCYC x 4096
+#define AT91C_MCI_DTOMUL_65536 ((unsigned int) 0x6 << 4) // (MCI) DTOCYC x 65536
+#define AT91C_MCI_DTOMUL_1048576 ((unsigned int) 0x7 << 4) // (MCI) DTOCYC x 1048576
+// -------- MCI_SDCR : (MCI Offset: 0xc) MCI SD Card Register --------
+#define AT91C_MCI_SCDSEL ((unsigned int) 0x1 << 0) // (MCI) SD Card Selector
+#define AT91C_MCI_SCDBUS ((unsigned int) 0x1 << 7) // (MCI) SD Card Bus Width
+// -------- MCI_CMDR : (MCI Offset: 0x14) MCI Command Register --------
+#define AT91C_MCI_CMDNB ((unsigned int) 0x1F << 0) // (MCI) Command Number
+#define AT91C_MCI_RSPTYP ((unsigned int) 0x3 << 6) // (MCI) Response Type
+#define AT91C_MCI_RSPTYP_NO ((unsigned int) 0x0 << 6) // (MCI) No response
+#define AT91C_MCI_RSPTYP_48 ((unsigned int) 0x1 << 6) // (MCI) 48-bit response
+#define AT91C_MCI_RSPTYP_136 ((unsigned int) 0x2 << 6) // (MCI) 136-bit response
+#define AT91C_MCI_SPCMD ((unsigned int) 0x7 << 8) // (MCI) Special CMD
+#define AT91C_MCI_SPCMD_NONE ((unsigned int) 0x0 << 8) // (MCI) Not a special CMD
+#define AT91C_MCI_SPCMD_INIT ((unsigned int) 0x1 << 8) // (MCI) Initialization CMD
+#define AT91C_MCI_SPCMD_SYNC ((unsigned int) 0x2 << 8) // (MCI) Synchronized CMD
+#define AT91C_MCI_SPCMD_IT_CMD ((unsigned int) 0x4 << 8) // (MCI) Interrupt command
+#define AT91C_MCI_SPCMD_IT_REP ((unsigned int) 0x5 << 8) // (MCI) Interrupt response
+#define AT91C_MCI_OPDCMD ((unsigned int) 0x1 << 11) // (MCI) Open Drain Command
+#define AT91C_MCI_MAXLAT ((unsigned int) 0x1 << 12) // (MCI) Maximum Latency for Command to respond
+#define AT91C_MCI_TRCMD ((unsigned int) 0x3 << 16) // (MCI) Transfer CMD
+#define AT91C_MCI_TRCMD_NO ((unsigned int) 0x0 << 16) // (MCI) No transfer
+#define AT91C_MCI_TRCMD_START ((unsigned int) 0x1 << 16) // (MCI) Start transfer
+#define AT91C_MCI_TRCMD_STOP ((unsigned int) 0x2 << 16) // (MCI) Stop transfer
+#define AT91C_MCI_TRDIR ((unsigned int) 0x1 << 18) // (MCI) Transfer Direction
+#define AT91C_MCI_TRTYP ((unsigned int) 0x3 << 19) // (MCI) Transfer Type
+#define AT91C_MCI_TRTYP_BLOCK ((unsigned int) 0x0 << 19) // (MCI) Block Transfer type
+#define AT91C_MCI_TRTYP_MULTIPLE ((unsigned int) 0x1 << 19) // (MCI) Multiple Block transfer type
+#define AT91C_MCI_TRTYP_STREAM ((unsigned int) 0x2 << 19) // (MCI) Stream transfer type
+// -------- MCI_SR : (MCI Offset: 0x40) MCI Status Register --------
+#define AT91C_MCI_CMDRDY ((unsigned int) 0x1 << 0) // (MCI) Command Ready flag
+#define AT91C_MCI_RXRDY ((unsigned int) 0x1 << 1) // (MCI) RX Ready flag
+#define AT91C_MCI_TXRDY ((unsigned int) 0x1 << 2) // (MCI) TX Ready flag
+#define AT91C_MCI_BLKE ((unsigned int) 0x1 << 3) // (MCI) Data Block Transfer Ended flag
+#define AT91C_MCI_DTIP ((unsigned int) 0x1 << 4) // (MCI) Data Transfer in Progress flag
+#define AT91C_MCI_NOTBUSY ((unsigned int) 0x1 << 5) // (MCI) Data Line Not Busy flag
+#define AT91C_MCI_ENDRX ((unsigned int) 0x1 << 6) // (MCI) End of RX Buffer flag
+#define AT91C_MCI_ENDTX ((unsigned int) 0x1 << 7) // (MCI) End of TX Buffer flag
+#define AT91C_MCI_RXBUFF ((unsigned int) 0x1 << 14) // (MCI) RX Buffer Full flag
+#define AT91C_MCI_TXBUFE ((unsigned int) 0x1 << 15) // (MCI) TX Buffer Empty flag
+#define AT91C_MCI_RINDE ((unsigned int) 0x1 << 16) // (MCI) Response Index Error flag
+#define AT91C_MCI_RDIRE ((unsigned int) 0x1 << 17) // (MCI) Response Direction Error flag
+#define AT91C_MCI_RCRCE ((unsigned int) 0x1 << 18) // (MCI) Response CRC Error flag
+#define AT91C_MCI_RENDE ((unsigned int) 0x1 << 19) // (MCI) Response End Bit Error flag
+#define AT91C_MCI_RTOE ((unsigned int) 0x1 << 20) // (MCI) Response Time-out Error flag
+#define AT91C_MCI_DCRCE ((unsigned int) 0x1 << 21) // (MCI) data CRC Error flag
+#define AT91C_MCI_DTOE ((unsigned int) 0x1 << 22) // (MCI) Data timeout Error flag
+#define AT91C_MCI_OVRE ((unsigned int) 0x1 << 30) // (MCI) Overrun flag
+#define AT91C_MCI_UNRE ((unsigned int) 0x1 << 31) // (MCI) Underrun flag
+// -------- MCI_IER : (MCI Offset: 0x44) MCI Interrupt Enable Register --------
+// -------- MCI_IDR : (MCI Offset: 0x48) MCI Interrupt Disable Register --------
+// -------- MCI_IMR : (MCI Offset: 0x4c) MCI Interrupt Mask Register --------
+
+#endif
diff -urN linux-2.4.26/include/asm-arm/arch-at91rm9200/AT91RM9200_SSC.h linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/AT91RM9200_SSC.h
--- linux-2.4.26/include/asm-arm/arch-at91rm9200/AT91RM9200_SSC.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/AT91RM9200_SSC.h 2004-03-04 21:44:12.000000000 +0000
@@ -0,0 +1,129 @@
+// ----------------------------------------------------------------------------
+// ATMEL Microcontroller Software Support - ROUSSET -
+// ----------------------------------------------------------------------------
+// The software is delivered "AS IS" without warranty or condition of any
+// kind, either express, implied or statutory. This includes without
+// limitation any warranty or condition with respect to merchantability or
+// fitness for any particular purpose, or against the infringements of
+// intellectual property rights of others.
+// ----------------------------------------------------------------------------
+// File Name : AT91RM9200.h
+// Object : AT91RM9200 / SSC definitions
+// Generated : AT91 SW Application Group 12/03/2002 (10:48:02)
+//
+// ----------------------------------------------------------------------------
+
+#ifndef AT91RM9200_SSC_H
+#define AT91RM9200_SSC_H
+
+// *****************************************************************************
+// SOFTWARE API DEFINITION FOR Synchronous Serial Controller Interface
+// *****************************************************************************
+#ifndef __ASSEMBLY__
+
+typedef struct _AT91S_SSC {
+ AT91_REG SSC_CR; // Control Register
+ AT91_REG SSC_CMR; // Clock Mode Register
+ AT91_REG Reserved0[2]; //
+ AT91_REG SSC_RCMR; // Receive Clock ModeRegister
+ AT91_REG SSC_RFMR; // Receive Frame Mode Register
+ AT91_REG SSC_TCMR; // Transmit Clock Mode Register
+ AT91_REG SSC_TFMR; // Transmit Frame Mode Register
+ AT91_REG SSC_RHR; // Receive Holding Register
+ AT91_REG SSC_THR; // Transmit Holding Register
+ AT91_REG Reserved1[2]; //
+ AT91_REG SSC_RSHR; // Receive Sync Holding Register
+ AT91_REG SSC_TSHR; // Transmit Sync Holding Register
+ AT91_REG SSC_RC0R; // Receive Compare 0 Register
+ AT91_REG SSC_RC1R; // Receive Compare 1 Register
+ AT91_REG SSC_SR; // Status Register
+ AT91_REG SSC_IER; // Interrupt Enable Register
+ AT91_REG SSC_IDR; // Interrupt Disable Register
+ AT91_REG SSC_IMR; // Interrupt Mask Register
+ AT91_REG Reserved2[44]; //
+ AT91_REG SSC_RPR; // Receive Pointer Register
+ AT91_REG SSC_RCR; // Receive Counter Register
+ AT91_REG SSC_TPR; // Transmit Pointer Register
+ AT91_REG SSC_TCR; // Transmit Counter Register
+ AT91_REG SSC_RNPR; // Receive Next Pointer Register
+ AT91_REG SSC_RNCR; // Receive Next Counter Register
+ AT91_REG SSC_TNPR; // Transmit Next Pointer Register
+ AT91_REG SSC_TNCR; // Transmit Next Counter Register
+ AT91_REG SSC_PTCR; // PDC Transfer Control Register
+ AT91_REG SSC_PTSR; // PDC Transfer Status Register
+} AT91S_SSC, *AT91PS_SSC;
+
+#endif
+
+// -------- SSC_CR : (SSC Offset: 0x0) SSC Control Register --------
+#define AT91C_SSC_RXEN ( 0x1 << 0) // (SSC) Receive Enable
+#define AT91C_SSC_RXDIS ( 0x1 << 1) // (SSC) Receive Disable
+#define AT91C_SSC_TXEN ( 0x1 << 8) // (SSC) Transmit Enable
+#define AT91C_SSC_TXDIS ( 0x1 << 9) // (SSC) Transmit Disable
+#define AT91C_SSC_SWRST ( 0x1 << 15) // (SSC) Software Reset
+// -------- SSC_RCMR : (SSC Offset: 0x10) SSC Receive Clock Mode Register --------
+#define AT91C_SSC_CKS ( 0x3 << 0) // (SSC) Receive/Transmit Clock Selection
+#define AT91C_SSC_CKS_DIV ( 0x0) // (SSC) Divided Clock
+#define AT91C_SSC_CKS_TK ( 0x1) // (SSC) TK Clock signal
+#define AT91C_SSC_CKS_RK ( 0x2) // (SSC) RK pin
+#define AT91C_SSC_CKO ( 0x7 << 2) // (SSC) Receive/Transmit Clock Output Mode Selection
+#define AT91C_SSC_CKO_NONE ( 0x0 << 2) // (SSC) Receive/Transmit Clock Output Mode: None RK pin: Input-only
+#define AT91C_SSC_CKO_CONTINOUS ( 0x1 << 2) // (SSC) Continuous Receive/Transmit Clock RK pin: Output
+#define AT91C_SSC_CKO_DATA_TX ( 0x2 << 2) // (SSC) Receive/Transmit Clock only during data transfers RK pin: Output
+#define AT91C_SSC_CKI ( 0x1 << 5) // (SSC) Receive/Transmit Clock Inversion
+#define AT91C_SSC_CKG ( 0x3 << 6) // (SSC) Receive/Transmit Clock Gating Selection
+#define AT91C_SSC_CKG_NONE ( 0x0 << 6) // (SSC) Receive/Transmit Clock Gating: None, continuous clock
+#define AT91C_SSC_CKG_LOW ( 0x1 << 6) // (SSC) Receive/Transmit Clock enabled only if RF Low
+#define AT91C_SSC_CKG_HIGH ( 0x2 << 6) // (SSC) Receive/Transmit Clock enabled only if RF High
+#define AT91C_SSC_START ( 0xF << 8) // (SSC) Receive/Transmit Start Selection
+#define AT91C_SSC_START_CONTINOUS ( 0x0 << 8) // (SSC) Continuous, as soon as the receiver is enabled, and immediately after the end of transfer of the previous data.
+#define AT91C_SSC_START_TX ( 0x1 << 8) // (SSC) Transmit/Receive start
+#define AT91C_SSC_START_LOW_RF ( 0x2 << 8) // (SSC) Detection of a low level on RF input
+#define AT91C_SSC_START_HIGH_RF ( 0x3 << 8) // (SSC) Detection of a high level on RF input
+#define AT91C_SSC_START_FALL_RF ( 0x4 << 8) // (SSC) Detection of a falling edge on RF input
+#define AT91C_SSC_START_RISE_RF ( 0x5 << 8) // (SSC) Detection of a rising edge on RF input
+#define AT91C_SSC_START_LEVEL_RF ( 0x6 << 8) // (SSC) Detection of any level change on RF input
+#define AT91C_SSC_START_EDGE_RF ( 0x7 << 8) // (SSC) Detection of any edge on RF input
+#define AT91C_SSC_START_0 ( 0x8 << 8) // (SSC) Compare 0
+#define AT91C_SSC_STOP ( 0x1 << 12) // (SSC) Receive Stop Selection
+#define AT91C_SSC_STTOUT ( 0x1 << 15) // (SSC) Receive/Transmit Start Output Selection
+#define AT91C_SSC_STTDLY ( 0xFF << 16) // (SSC) Receive/Transmit Start Delay
+#define AT91C_SSC_PERIOD ( 0xFF << 24) // (SSC) Receive/Transmit Period Divider Selection
+// -------- SSC_RFMR : (SSC Offset: 0x14) SSC Receive Frame Mode Register --------
+#define AT91C_SSC_DATLEN ( 0x1F << 0) // (SSC) Data Length
+#define AT91C_SSC_LOOP ( 0x1 << 5) // (SSC) Loop Mode
+#define AT91C_SSC_MSBF ( 0x1 << 7) // (SSC) Most Significant Bit First
+#define AT91C_SSC_DATNB ( 0xF << 8) // (SSC) Data Number per Frame
+#define AT91C_SSC_FSLEN ( 0xF << 16) // (SSC) Receive/Transmit Frame Sync length
+#define AT91C_SSC_FSOS ( 0x7 << 20) // (SSC) Receive/Transmit Frame Sync Output Selection
+#define AT91C_SSC_FSOS_NONE ( 0x0 << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: None RK pin Input-only
+#define AT91C_SSC_FSOS_NEGATIVE ( 0x1 << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Negative Pulse
+#define AT91C_SSC_FSOS_POSITIVE ( 0x2 << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Positive Pulse
+#define AT91C_SSC_FSOS_LOW ( 0x3 << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Driver Low during data transfer
+#define AT91C_SSC_FSOS_HIGH ( 0x4 << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Driver High during data transfer
+#define AT91C_SSC_FSOS_TOGGLE ( 0x5 << 20) // (SSC) Selected Receive/Transmit Frame Sync Signal: Toggling at each start of data transfer
+#define AT91C_SSC_FSEDGE ( 0x1 << 24) // (SSC) Frame Sync Edge Detection
+// -------- SSC_TCMR : (SSC Offset: 0x18) SSC Transmit Clock Mode Register --------
+// -------- SSC_TFMR : (SSC Offset: 0x1c) SSC Transmit Frame Mode Register --------
+#define AT91C_SSC_DATDEF ( 0x1 << 5) // (SSC) Data Default Value
+#define AT91C_SSC_FSDEN ( 0x1 << 23) // (SSC) Frame Sync Data Enable
+// -------- SSC_SR : (SSC Offset: 0x40) SSC Status Register --------
+#define AT91C_SSC_TXRDY ( 0x1 << 0) // (SSC) Transmit Ready
+#define AT91C_SSC_TXEMPTY ( 0x1 << 1) // (SSC) Transmit Empty
+#define AT91C_SSC_ENDTX ( 0x1 << 2) // (SSC) End Of Transmission
+#define AT91C_SSC_TXBUFE ( 0x1 << 3) // (SSC) Transmit Buffer Empty
+#define AT91C_SSC_RXRDY ( 0x1 << 4) // (SSC) Receive Ready
+#define AT91C_SSC_OVRUN ( 0x1 << 5) // (SSC) Receive Overrun
+#define AT91C_SSC_ENDRX ( 0x1 << 6) // (SSC) End of Reception
+#define AT91C_SSC_RXBUFF ( 0x1 << 7) // (SSC) Receive Buffer Full
+#define AT91C_SSC_CP0 ( 0x1 << 8) // (SSC) Compare 0
+#define AT91C_SSC_CP1 ( 0x1 << 9) // (SSC) Compare 1
+#define AT91C_SSC_TXSYN ( 0x1 << 10) // (SSC) Transmit Sync
+#define AT91C_SSC_RXSYN ( 0x1 << 11) // (SSC) Receive Sync
+#define AT91C_SSC_TXENA ( 0x1 << 16) // (SSC) Transmit Enable
+#define AT91C_SSC_RXENA ( 0x1 << 17) // (SSC) Receive Enable
+// -------- SSC_IER : (SSC Offset: 0x44) SSC Interrupt Enable Register --------
+// -------- SSC_IDR : (SSC Offset: 0x48) SSC Interrupt Disable Register --------
+// -------- SSC_IMR : (SSC Offset: 0x4c) SSC Interrupt Mask Register --------
+
+#endif
diff -urN linux-2.4.26/include/asm-arm/arch-at91rm9200/AT91RM9200_TC.h linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/AT91RM9200_TC.h
--- linux-2.4.26/include/asm-arm/arch-at91rm9200/AT91RM9200_TC.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/AT91RM9200_TC.h 2004-03-04 21:44:12.000000000 +0000
@@ -0,0 +1,165 @@
+// ----------------------------------------------------------------------------
+// ATMEL Microcontroller Software Support - ROUSSET -
+// ----------------------------------------------------------------------------
+// The software is delivered "AS IS" without warranty or condition of any
+// kind, either express, implied or statutory. This includes without
+// limitation any warranty or condition with respect to merchantability or
+// fitness for any particular purpose, or against the infringements of
+// intellectual property rights of others.
+// ----------------------------------------------------------------------------
+// File Name : AT91RM9200.h
+// Object : AT91RM9200 definitions
+// Generated : AT91 SW Application Group 12/03/2002 (10:48:02)
+//
+// ----------------------------------------------------------------------------
+
+#ifndef AT91RM9200_TC_H
+#define AT91RM9200_TC_H
+
+// *****************************************************************************
+// SOFTWARE API DEFINITION FOR Timer Counter Channel Interface
+// *****************************************************************************
+#ifndef __ASSEMBLY__
+
+typedef struct _AT91S_TC {
+ AT91_REG TC_CCR; // Channel Control Register
+ AT91_REG TC_CMR; // Channel Mode Register
+ AT91_REG Reserved0[2]; //
+ AT91_REG TC_CV; // Counter Value
+ AT91_REG TC_RA; // Register A
+ AT91_REG TC_RB; // Register B
+ AT91_REG TC_RC; // Register C
+ AT91_REG TC_SR; // Status Register
+ AT91_REG TC_IER; // Interrupt Enable Register
+ AT91_REG TC_IDR; // Interrupt Disable Register
+ AT91_REG TC_IMR; // Interrupt Mask Register
+} AT91S_TC, *AT91PS_TC;
+
+typedef struct _AT91S_TCB {
+ AT91S_TC TCB_TC0; // TC Channel 0
+ AT91_REG Reserved0[4]; //
+ AT91S_TC TCB_TC1; // TC Channel 1
+ AT91_REG Reserved1[4]; //
+ AT91S_TC TCB_TC2; // TC Channel 2
+ AT91_REG Reserved2[4]; //
+ AT91_REG TCB_BCR; // TC Block Control Register
+ AT91_REG TCB_BMR; // TC Block Mode Register
+} AT91S_TCB, *AT91PS_TCB;
+
+#endif
+
+// -------- TC_CCR : (TC Offset: 0x0) TC Channel Control Register --------
+#define AT91C_TC_CLKEN ( 0x1 << 0) // (TC) Counter Clock Enable Command
+#define AT91C_TC_CLKDIS ( 0x1 << 1) // (TC) Counter Clock Disable Command
+#define AT91C_TC_SWTRG ( 0x1 << 2) // (TC) Software Trigger Command
+// -------- TC_CMR : (TC Offset: 0x4) TC Channel Mode Register: Capture Mode / Waveform Mode --------
+#define AT91C_TC_TCCLKS ( 0x7 << 0) // (TC) Clock Selection
+#define AT91C_TC_TIMER_DIV1_CLOCK ( 0x0 << 0) // (TC) MCK/2
+#define AT91C_TC_TIMER_DIV2_CLOCK ( 0x1 << 0) // (TC) MCK/8
+#define AT91C_TC_TIMER_DIV3_CLOCK ( 0x2 << 0) // (TC) MCK/32
+#define AT91C_TC_TIMER_DIV4_CLOCK ( 0x3 << 0) // (TC) MCK/128
+#define AT91C_TC_TIMER_DIV5_CLOCK ( 0x4 << 0) // (TC) MCK/256 = SLOW CLOCK
+#define AT91C_TC_TIMER_XC0 ( 0x5 << 0) // (TC) XC0
+#define AT91C_TC_TIMER_XC1 ( 0x6 << 0) // (TC) XC1
+#define AT91C_TC_TIMER_XC2 ( 0x7 << 0) // (TC) XC2
+#define AT91C_TC_CLKI ( 0x1 << 3) // (TC) Clock Invert
+#define AT91C_TC_BURST ( 0x3 << 4) // (TC) Burst Signal Selection
+#define AT91C_TC_CPCSTOP ( 0x1 << 6) // (TC) Counter Clock Stopped with RC Compare
+#define AT91C_TC_CPCDIS ( 0x1 << 7) // (TC) Counter Clock Disable with RC Compare
+#define AT91C_TC_EEVTEDG ( 0x3 << 8) // (TC) External Event Edge Selection
+#define AT91C_TC_EEVTEDG_NONE ( 0x0 << 8) // (TC) Edge: None
+#define AT91C_TC_EEVTEDG_RISING ( 0x1 << 8) // (TC) Edge: rising edge
+#define AT91C_TC_EEVTEDG_FALLING ( 0x2 << 8) // (TC) Edge: falling edge
+#define AT91C_TC_EEVTEDG_BOTH ( 0x3 << 8) // (TC) Edge: each edge
+#define AT91C_TC_EEVT ( 0x3 << 10) // (TC) External Event Selection
+#define AT91C_TC_EEVT_NONE ( 0x0 << 10) // (TC) Signal selected as external event: TIOB TIOB direction: input
+#define AT91C_TC_EEVT_RISING ( 0x1 << 10) // (TC) Signal selected as external event: XC0 TIOB direction: output
+#define AT91C_TC_EEVT_FALLING ( 0x2 << 10) // (TC) Signal selected as external event: XC1 TIOB direction: output
+#define AT91C_TC_EEVT_BOTH ( 0x3 << 10) // (TC) Signal selected as external event: XC2 TIOB direction: output
+#define AT91C_TC_ENETRG ( 0x1 << 12) // (TC) External Event Trigger enable
+#define AT91C_TC_WAVESEL ( 0x3 << 13) // (TC) Waveform Selection
+#define AT91C_TC_WAVESEL_UP ( 0x0 << 13) // (TC) UP mode without atomatic trigger on RC Compare
+#define AT91C_TC_WAVESEL_UP_AUTO ( 0x1 << 13) // (TC) UP mode with automatic trigger on RC Compare
+#define AT91C_TC_WAVESEL_UPDOWN ( 0x2 << 13) // (TC) UPDOWN mode without automatic trigger on RC Compare
+#define AT91C_TC_WAVESEL_UPDOWN_AUTO ( 0x3 << 13) // (TC) UPDOWN mode with automatic trigger on RC Compare
+#define AT91C_TC_CPCTRG ( 0x1 << 14) // (TC) RC Compare Trigger Enable
+#define AT91C_TC_WAVE ( 0x1 << 15) // (TC)
+#define AT91C_TC_ACPA ( 0x3 << 16) // (TC) RA Compare Effect on TIOA
+#define AT91C_TC_ACPA_NONE ( 0x0 << 16) // (TC) Effect: none
+#define AT91C_TC_ACPA_SET ( 0x1 << 16) // (TC) Effect: set
+#define AT91C_TC_ACPA_CLEAR ( 0x2 << 16) // (TC) Effect: clear
+#define AT91C_TC_ACPA_TOGGLE ( 0x3 << 16) // (TC) Effect: toggle
+#define AT91C_TC_ACPC ( 0x3 << 18) // (TC) RC Compare Effect on TIOA
+#define AT91C_TC_ACPC_NONE ( 0x0 << 18) // (TC) Effect: none
+#define AT91C_TC_ACPC_SET ( 0x1 << 18) // (TC) Effect: set
+#define AT91C_TC_ACPC_CLEAR ( 0x2 << 18) // (TC) Effect: clear
+#define AT91C_TC_ACPC_TOGGLE ( 0x3 << 18) // (TC) Effect: toggle
+#define AT91C_TC_AEEVT ( 0x3 << 20) // (TC) External Event Effect on TIOA
+#define AT91C_TC_AEEVT_NONE ( 0x0 << 20) // (TC) Effect: none
+#define AT91C_TC_AEEVT_SET ( 0x1 << 20) // (TC) Effect: set
+#define AT91C_TC_AEEVT_CLEAR ( 0x2 << 20) // (TC) Effect: clear
+#define AT91C_TC_AEEVT_TOGGLE ( 0x3 << 20) // (TC) Effect: toggle
+#define AT91C_TC_ASWTRG ( 0x3 << 22) // (TC) Software Trigger Effect on TIOA
+#define AT91C_TC_ASWTRG_NONE ( 0x0 << 22) // (TC) Effect: none
+#define AT91C_TC_ASWTRG_SET ( 0x1 << 22) // (TC) Effect: set
+#define AT91C_TC_ASWTRG_CLEAR ( 0x2 << 22) // (TC) Effect: clear
+#define AT91C_TC_ASWTRG_TOGGLE ( 0x3 << 22) // (TC) Effect: toggle
+#define AT91C_TC_BCPB ( 0x3 << 24) // (TC) RB Compare Effect on TIOB
+#define AT91C_TC_BCPB_NONE ( 0x0 << 24) // (TC) Effect: none
+#define AT91C_TC_BCPB_SET ( 0x1 << 24) // (TC) Effect: set
+#define AT91C_TC_BCPB_CLEAR ( 0x2 << 24) // (TC) Effect: clear
+#define AT91C_TC_BCPB_TOGGLE ( 0x3 << 24) // (TC) Effect: toggle
+#define AT91C_TC_BCPC ( 0x3 << 26) // (TC) RC Compare Effect on TIOB
+#define AT91C_TC_BCPC_NONE ( 0x0 << 26) // (TC) Effect: none
+#define AT91C_TC_BCPC_SET ( 0x1 << 26) // (TC) Effect: set
+#define AT91C_TC_BCPC_CLEAR ( 0x2 << 26) // (TC) Effect: clear
+#define AT91C_TC_BCPC_TOGGLE ( 0x3 << 26) // (TC) Effect: toggle
+#define AT91C_TC_BEEVT ( 0x3 << 28) // (TC) External Event Effect on TIOB
+#define AT91C_TC_BEEVT_NONE ( 0x0 << 28) // (TC) Effect: none
+#define AT91C_TC_BEEVT_SET ( 0x1 << 28) // (TC) Effect: set
+#define AT91C_TC_BEEVT_CLEAR ( 0x2 << 28) // (TC) Effect: clear
+#define AT91C_TC_BEEVT_TOGGLE ( 0x3 << 28) // (TC) Effect: toggle
+#define AT91C_TC_BSWTRG ( 0x3 << 30) // (TC) Software Trigger Effect on TIOB
+#define AT91C_TC_BSWTRG_NONE ( 0x0 << 30) // (TC) Effect: none
+#define AT91C_TC_BSWTRG_SET ( 0x1 << 30) // (TC) Effect: set
+#define AT91C_TC_BSWTRG_CLEAR ( 0x2 << 30) // (TC) Effect: clear
+#define AT91C_TC_BSWTRG_TOGGLE ( 0x3 << 30) // (TC) Effect: toggle
+// -------- TC_SR : (TC Offset: 0x20) TC Channel Status Register --------
+#define AT91C_TC_COVFS ( 0x1 << 0) // (TC) Counter Overflow
+#define AT91C_TC_LOVRS ( 0x1 << 1) // (TC) Load Overrun
+#define AT91C_TC_CPAS ( 0x1 << 2) // (TC) RA Compare
+#define AT91C_TC_CPBS ( 0x1 << 3) // (TC) RB Compare
+#define AT91C_TC_CPCS ( 0x1 << 4) // (TC) RC Compare
+#define AT91C_TC_LDRAS ( 0x1 << 5) // (TC) RA Loading
+#define AT91C_TC_LDRBS ( 0x1 << 6) // (TC) RB Loading
+#define AT91C_TC_ETRCS ( 0x1 << 7) // (TC) External Trigger
+#define AT91C_TC_ETRGS ( 0x1 << 16) // (TC) Clock Enabling
+#define AT91C_TC_MTIOA ( 0x1 << 17) // (TC) TIOA Mirror
+#define AT91C_TC_MTIOB ( 0x1 << 18) // (TC) TIOA Mirror
+// -------- TC_IER : (TC Offset: 0x24) TC Channel Interrupt Enable Register --------
+// -------- TC_IDR : (TC Offset: 0x28) TC Channel Interrupt Disable Register --------
+// -------- TC_IMR : (TC Offset: 0x2c) TC Channel Interrupt Mask Register --------
+
+// *****************************************************************************
+// SOFTWARE API DEFINITION FOR Timer Counter Interface
+// *****************************************************************************
+// -------- TCB_BCR : (TCB Offset: 0xc0) TC Block Control Register --------
+#define AT91C_TCB_SYNC ( 0x1 << 0) // (TCB) Synchro Command
+// -------- TCB_BMR : (TCB Offset: 0xc4) TC Block Mode Register --------
+#define AT91C_TCB_TC0XC0S ( 0x1 << 0) // (TCB) External Clock Signal 0 Selection
+#define AT91C_TCB_TC0XC0S_TCLK0 ( 0x0) // (TCB) TCLK0 connected to XC0
+#define AT91C_TCB_TC0XC0S_NONE ( 0x1) // (TCB) None signal connected to XC0
+#define AT91C_TCB_TC0XC0S_TIOA1 ( 0x2) // (TCB) TIOA1 connected to XC0
+#define AT91C_TCB_TC0XC0S_TIOA2 ( 0x3) // (TCB) TIOA2 connected to XC0
+#define AT91C_TCB_TC1XC1S ( 0x1 << 2) // (TCB) External Clock Signal 1 Selection
+#define AT91C_TCB_TC1XC1S_TCLK1 ( 0x0 << 2) // (TCB) TCLK1 connected to XC1
+#define AT91C_TCB_TC1XC1S_NONE ( 0x1 << 2) // (TCB) None signal connected to XC1
+#define AT91C_TCB_TC1XC1S_TIOA0 ( 0x2 << 2) // (TCB) TIOA0 connected to XC1
+#define AT91C_TCB_TC1XC1S_TIOA2 ( 0x3 << 2) // (TCB) TIOA2 connected to XC1
+#define AT91C_TCB_TC2XC2S ( 0x1 << 4) // (TCB) External Clock Signal 2 Selection
+#define AT91C_TCB_TC2XC2S_TCLK2 ( 0x0 << 4) // (TCB) TCLK2 connected to XC2
+#define AT91C_TCB_TC2XC2S_NONE ( 0x1 << 4) // (TCB) None signal connected to XC2
+#define AT91C_TCB_TC2XC2S_TIOA0 ( 0x2 << 4) // (TCB) TIOA0 connected to XC2
+#define AT91C_TCB_TC2XC2S_TIOA2 ( 0x3 << 4) // (TCB) TIOA2 connected to XC2
+
+#endif
diff -urN linux-2.4.26/include/asm-arm/arch-at91rm9200/at91rm9200dk.h linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/at91rm9200dk.h
--- linux-2.4.26/include/asm-arm/arch-at91rm9200/at91rm9200dk.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/at91rm9200dk.h 2004-04-10 12:40:23.000000000 +0100
@@ -17,9 +17,9 @@
/* AT91RM92000 clocks */
#define AT91C_MAIN_CLOCK 179712000 /* from 18.432 MHz crystal (18432000 / 4 * 39) */
-#define AT91C_MASTER_CLOCK 59904000 /* peripheral clock (AT91C_MASTER_CLOCK / 3) */
+#define AT91C_MASTER_CLOCK 59904000 /* peripheral clock (AT91C_MAIN_CLOCK / 3) */
#define AT91C_SLOW_CLOCK 32768 /* slow clock */
-
+#define AT91_PLLB_INIT 0x1048be0e /* (18.432 / 14 * 73) /2 = 47.9714 *
/* FLASH */
#define AT91_FLASH_BASE 0x10000000 // NCS0: Flash physical base address
@@ -68,6 +68,7 @@
#define AT91_SMR_IRQ5 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (IRQ5)
#define AT91_SMR_IRQ6 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (IRQ6)
+#define AT91C_CONSOLE_DEFAULT_BAUDRATE 115200 /* default serial console baud-rate */
/*
* Serial port configuration.
diff -urN linux-2.4.26/include/asm-arm/arch-at91rm9200/csb337.h linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/csb337.h
--- linux-2.4.26/include/asm-arm/arch-at91rm9200/csb337.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/csb337.h 2004-04-10 12:42:27.000000000 +0100
@@ -0,0 +1,82 @@
+/*
+ * linux/include/asm-arm/arch-at91rm9200/csb337.h
+ *
+ * Copyright (c) 2003 Christopher Bahns & David Knickerbocker
+ * Polaroid 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.
+ *
+ */
+
+#ifndef __ASM_ARCH_HARDWARE_CSB337_H
+#define __ASM_ARCH_HARDWARE_CSB337_H
+
+
+/* AT91RM92000 clocks on CSB337 */
+#define AT91C_MAIN_CLOCK 184320000
+#define AT91C_MASTER_CLOCK 46080000 /* peripheral clock (AT91C_MAIN_CLOCK / 4) */
+#define AT91C_SLOW_CLOCK 32768 /* slow clock */
+#define AT91_PLLB_INIT 0x1257be17 /* (3.68 / 23 * 600) /2 = 96/2 = 48 */
+
+/* FLASH */
+#define AT91_FLASH_BASE 0x10000000 // NCS0: Flash physical base address
+
+/* SDRAM */
+#define AT91_SDRAM_BASE 0x20000000 // NCS1: SDRAM physical base address
+
+/* SmartMedia */
+#define AT91_SMARTMEDIA_BASE 0x40000000 // NCS3: Smartmedia physical base address
+
+/* Multi-Master Memory controller */
+#define AT91_UHP_BASE 0x00300000 // USB Host controller
+
+
+/* Peripheral interrupt configuration */
+#define AT91_SMR_FIQ (AT91C_AIC_PRIOR_HIGHEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (FIQ)
+#define AT91_SMR_SYS (AT91C_AIC_PRIOR_HIGHEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // System Peripheral
+#define AT91_SMR_PIOA (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Parallel IO Controller A
+#define AT91_SMR_PIOB (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Parallel IO Controller B
+#define AT91_SMR_PIOC (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Parallel IO Controller C
+#define AT91_SMR_PIOD (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Parallel IO Controller D
+#define AT91_SMR_US0 (AT91C_AIC_PRIOR_6 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // USART 0
+#define AT91_SMR_US1 (AT91C_AIC_PRIOR_6 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // USART 1
+#define AT91_SMR_US2 (AT91C_AIC_PRIOR_6 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // USART 2
+#define AT91_SMR_US3 (AT91C_AIC_PRIOR_6 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // USART 3
+#define AT91_SMR_MCI (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Multimedia Card Interface
+#define AT91_SMR_UDP (AT91C_AIC_PRIOR_4 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // USB Device Port
+#define AT91_SMR_TWI (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Two-Wire Interface
+#define AT91_SMR_SPI (AT91C_AIC_PRIOR_6 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Serial Peripheral Interface
+#define AT91_SMR_SSC0 (AT91C_AIC_PRIOR_5 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Serial Synchronous Controller 0
+#define AT91_SMR_SSC1 (AT91C_AIC_PRIOR_5 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Serial Synchronous Controller 1
+#define AT91_SMR_SSC2 (AT91C_AIC_PRIOR_5 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Serial Synchronous Controller 2
+#define AT91_SMR_TC0 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Timer Counter 0
+#define AT91_SMR_TC1 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Timer Counter 1
+#define AT91_SMR_TC2 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Timer Counter 2
+#define AT91_SMR_TC3 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Timer Counter 3
+#define AT91_SMR_TC4 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Timer Counter 4
+#define AT91_SMR_TC5 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Timer Counter 5
+#define AT91_SMR_UHP (AT91C_AIC_PRIOR_3 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // USB Host port
+#define AT91_SMR_EMAC (AT91C_AIC_PRIOR_3 | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Ethernet MAC
+#define AT91_SMR_IRQ0 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (IRQ0)
+#define AT91_SMR_IRQ1 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (IRQ1)
+#define AT91_SMR_IRQ2 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (IRQ2)
+#define AT91_SMR_IRQ3 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (IRQ3)
+#define AT91_SMR_IRQ4 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (IRQ4)
+#define AT91_SMR_IRQ5 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (IRQ5)
+#define AT91_SMR_IRQ6 (AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE) // Advanced Interrupt Controller (IRQ6)
+
+
+#define AT91C_CONSOLE_DEFAULT_BAUDRATE 38400
+
+/*
+ * Serial port configuration.
+ * 0 .. 3 = USART0 .. USART3
+ * 4 = DBGU
+ */
+#define AT91C_UART_MAP { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
+#define AT91C_CONSOLE 0 /* ttyS0 */
+
+#endif
diff -urN linux-2.4.26/include/asm-arm/arch-at91rm9200/hardware.h linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/hardware.h
--- linux-2.4.26/include/asm-arm/arch-at91rm9200/hardware.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/hardware.h 2004-04-10 12:28:14.000000000 +0100
@@ -60,6 +60,7 @@
#define AT91C_BASE_SRAM 0x00200000 /* Internal SRAM base address */
+#define AT91C_SRAM_SIZE 0x00004000 /* Internal SRAM SIZE (16Kb) */
#define AT91C_NR_UART 5 /* 4 USART3's and one DBGU port */
@@ -82,5 +83,8 @@
#include <asm/arch/at91rm9200dk.h>
#endif
+#ifdef CONFIG_MACH_CSB337
+#include <asm/arch/csb337.h>
+#endif
#endif
diff -urN linux-2.4.26/include/asm-arm/arch-at91rm9200/pio.h linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/pio.h
--- linux-2.4.26/include/asm-arm/arch-at91rm9200/pio.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/pio.h 2004-03-04 22:06:48.000000000 +0000
@@ -66,6 +66,18 @@
}
/*
+ * Configure interrupt from Ethernet PHY.
+ */
+static inline void AT91_CfgPIO_EMAC_PHY(void) {
+ AT91_SYS->PMC_PCER = 1 << AT91C_ID_PIOC; /* enable peripheral clock */
+#ifdef CONFIG_MACH_CSB337
+ AT91_SYS->PIOC_ODR = AT91C_PIO_PC2;
+#else
+ AT91_SYS->PIOC_ODR = AT91C_PIO_PC4;
+#endif
+}
+
+/*
* Enable the Two-Wire interface.
*/
static inline void AT91_CfgPIO_TWI(void) {
diff -urN linux-2.4.26/include/asm-arm/arch-at91rm9200/time.h linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/time.h
--- linux-2.4.26/include/asm-arm/arch-at91rm9200/time.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-at91rm9200/time.h 2004-04-10 12:21:08.000000000 +0100
@@ -27,6 +27,21 @@
extern unsigned long (*gettimeoffset)(void);
/*
+ * The ST_CRTR is updated asynchronously to the master clock. It is therefore
+ * necessary to read it twice (with the same value) to ensure accuracy.
+ */
+static inline unsigned long read_CRTR(void) {
+ unsigned long x1, x2;
+
+ do {
+ x1 = AT91_SYS->ST_CRTR;
+ x2 = AT91_SYS->ST_CRTR;
+ } while (x1 != x2);
+
+ return x1;
+}
+
+/*
* Returns number of microseconds since last timer interrupt. Note that interrupts
* will have been disabled by do_gettimeofday()
* 'LATCH' is hwclock ticks (see CLOCK_TICK_RATE in timex.h) per jiffy.
@@ -36,7 +51,7 @@
{
unsigned long elapsed;
- elapsed = (AT91_SYS->ST_CRTR - AT91_SYS->ST_RTAR) & AT91C_ST_ALMV;
+ elapsed = (read_CRTR() - AT91_SYS->ST_RTAR) & AT91C_ST_ALMV;
return (unsigned long)(elapsed * tick) / LATCH;
}
@@ -48,11 +63,12 @@
{
if (AT91_SYS->ST_SR & AT91C_ST_PITS) { /* This is a shared interrupt */
do {
+ do_leds();
do_timer(regs);
AT91_SYS->ST_RTAR = (AT91_SYS->ST_RTAR + LATCH) & AT91C_ST_ALMV;
- } while (((AT91_SYS->ST_CRTR - AT91_SYS->ST_RTAR) & AT91C_ST_ALMV) >= LATCH);
+ } while (((read_CRTR() - AT91_SYS->ST_RTAR) & AT91C_ST_ALMV) >= LATCH);
do_profile(regs);
}
diff -urN linux-2.4.26/include/asm-arm/arch-clps711x/system.h linux-2.4.26-vrs1/include/asm-arm/arch-clps711x/system.h
--- linux-2.4.26/include/asm-arm/arch-clps711x/system.h 2003-06-13 15:51:38.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-clps711x/system.h 2004-01-14 21:32:27.000000000 +0000
@@ -28,8 +28,8 @@
{
clps_writel(1, HALT);
__asm__ __volatile__(
- "mov r0, r0
- mov r0, r0");
+ "mov r0, r0\n\t"
+ "mov r0, r0");
}
static inline void arch_reset(char mode)
diff -urN linux-2.4.26/include/asm-arm/arch-integrator/uncompress.h linux-2.4.26-vrs1/include/asm-arm/arch-integrator/uncompress.h
--- linux-2.4.26/include/asm-arm/arch-integrator/uncompress.h 2002-08-03 01:39:45.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-integrator/uncompress.h 2004-01-14 21:32:29.000000000 +0000
@@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <asm/hardware/serial_amba.h>
+
#define AMBA_UART_DR (*(volatile unsigned char *)0x16000000)
#define AMBA_UART_LCRH (*(volatile unsigned char *)0x16000008)
#define AMBA_UART_LCRM (*(volatile unsigned char *)0x1600000c)
@@ -30,21 +32,25 @@
*/
static void puts(const char *s)
{
+ /* Do nothing if the UART is not enabled. */
+ if (!(AMBA_UART_CR & AMBA_UARTCR_UARTEN))
+ return;
+
while (*s) {
- while (AMBA_UART_FR & (1 << 5))
+ while (AMBA_UART_FR & AMBA_UARTFR_TXFF)
barrier();
AMBA_UART_DR = *s;
if (*s == '\n') {
- while (AMBA_UART_FR & (1 << 5))
+ while (AMBA_UART_FR & AMBA_UARTFR_TXFF)
barrier();
AMBA_UART_DR = '\r';
}
s++;
}
- while (AMBA_UART_FR & (1 << 3));
+ while (AMBA_UART_FR & AMBA_UARTFR_BUSY);
}
/*
diff -urN linux-2.4.26/include/asm-arm/arch-riscstation/system.h linux-2.4.26-vrs1/include/asm-arm/arch-riscstation/system.h
--- linux-2.4.26/include/asm-arm/arch-riscstation/system.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-riscstation/system.h 2004-04-19 20:40:16.000000000 +0100
@@ -1,5 +1,5 @@
/*
- * linux/include/asm-arm/arch-rpc/system.h
+ * linux/include/asm-arm/arch-riscstation/system.h
*
* Copyright (C) 1996-1999 Russell King.
*
@@ -18,7 +18,7 @@
static inline void arch_reset(char mode)
{
- iomd_writeb(0, IOMD_ROMCR0);
+ iomd_writeb(0x40, IOMD_ROMCR0);
/*
* Jump into the ROM
diff -urN linux-2.4.26/include/asm-arm/arch-rpc/uncompress.h linux-2.4.26-vrs1/include/asm-arm/arch-rpc/uncompress.h
--- linux-2.4.26/include/asm-arm/arch-rpc/uncompress.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-rpc/uncompress.h 2004-04-09 19:29:57.000000000 +0100
@@ -11,29 +11,12 @@
#include <asm/hardware.h>
#include <asm/io.h>
+#include <asm/setup.h>
int video_num_columns, video_num_lines, video_size_row;
int white, bytes_per_char_h;
extern unsigned long con_charconvtable[256];
-struct param_struct {
- unsigned long page_size;
- unsigned long nr_pages;
- unsigned long ramdisk_size;
- unsigned long mountrootrdonly;
- unsigned long rootdev;
- unsigned long video_num_cols;
- unsigned long video_num_rows;
- unsigned long video_x;
- unsigned long video_y;
- unsigned long memc_control_reg;
- unsigned char sounddefault;
- unsigned char adfsdrives;
- unsigned char bytes_per_char_h;
- unsigned char bytes_per_char_v;
- unsigned long unused[256/4-11];
-};
-
static const unsigned long palette_4[16] = {
0x00000000,
0x000000cc,
@@ -69,8 +52,12 @@
unsigned char c;
char *ptr;
- x = params->video_x;
- y = params->video_y;
+ /* Don't bother when using a tagged list */
+ if (((struct tag *)params)->hdr.tag == ATAG_CORE)
+ return;
+
+ x = params->u1.s.video_x;
+ y = params->u1.s.video_y;
while ( ( c = *(unsigned char *)s++ ) != '\0' ) {
if ( c == '\n' ) {
@@ -79,7 +66,7 @@
y--;
}
} else {
- ptr = VIDMEM + ((y*video_num_columns*params->bytes_per_char_v+x)*bytes_per_char_h);
+ ptr = VIDMEM + ((y*video_num_columns*params->u1.s.bytes_per_char_v+x)*bytes_per_char_h);
ll_write_char(ptr, c, white);
if ( ++x >= video_num_columns ) {
x = 0;
@@ -90,8 +77,6 @@
}
}
- params->video_x = x;
- params->video_y = y;
}
static void error(char *x);
@@ -103,9 +88,13 @@
{
int i;
- video_num_lines = params->video_num_rows;
- video_num_columns = params->video_num_cols;
- bytes_per_char_h = params->bytes_per_char_h;
+ /* Don't bother when using a tagged list */
+ if (((struct tag *)params)->hdr.tag == ATAG_CORE)
+ return;
+
+ video_num_lines = params->u1.s.video_num_rows;
+ video_num_columns = params->u1.s.video_num_cols;
+ bytes_per_char_h = params->u1.s.bytes_per_char_h;
video_size_row = video_num_columns * bytes_per_char_h;
if (bytes_per_char_h == 4)
for (i = 0; i < 256; i++)
@@ -140,7 +129,7 @@
white = 7;
}
- if (params->nr_pages * params->page_size < 4096*1024) error("<4M of mem\n");
+ if (params->u1.s.nr_pages * params->u1.s.page_size < 4096*1024) error("<4M of mem\n");
}
#endif
diff -urN linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-clock.h linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-clock.h
--- linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-clock.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-clock.h 2004-03-07 13:04:06.000000000 +0000
@@ -0,0 +1,76 @@
+/* linux/include/asm-arm/arch-s3c2410/S3C2410-clock.h
+ *
+ * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
+ * http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ * S3C2410 clock register definitions
+ *
+ * Changelog:
+ * 19-06-2003 BJD Created file
+ */
+
+#ifndef ASMARM_ARCH_S3C2410_CLOCK_H
+#define ASMARM_ARCH_S3C2410_CLOCK_H
+
+#define S3C2410_CLKREG(x) ((x) + S3C2410_VA_CLKPWR)
+
+#define S3C2410_PLLVAL(_m,_p,_s) ((_m) << 12 | ((_p) << 4) | ((_s)))
+
+#define S3C2410_LOCKTIME S3C2410_CLKREG(0x00)
+#define S3C2410_MPLLCON S3C2410_CLKREG(0x04)
+#define S3C2410_UPLLCON S3C2410_CLKREG(0x08)
+#define S3C2410_CLKCON S3C2410_CLKREG(0x0C)
+#define S3C2410_CLKSLOW S3C2410_CLKREG(0x10)
+#define S3C2410_CLKDIVN S3C2410_CLKREG(0x14)
+
+#define S3C2410_PLLCON_MDIVSHIFT 12
+#define S3C2410_PLLCON_PDIVSHIFT 4
+#define S3C2410_PLLCON_SDIVSHIFT 0
+#define S3C2410_PLLCON_MDIVMASK ((1<<(1+(19-12)))-1)
+#define S3C2410_PLLCON_PDIVMASK ((1<<5)-1)
+#define S3C2410_PLLCON_SDIVMASK 3
+
+/* DCLKCON register addresses in gpio.h */
+
+#define S3C2410_DCLKCON_DCLK0EN (1<<0)
+#define S3C2410_DCLKCON_DCLK0_PCLK (0<<1)
+#define S3C2410_DCLKCON_DCLK0_UCLK (1<<1)
+#define S3C2410_DCLKCON_DCLK0_DIV(x) (((x) - 1 )<<4)
+#define S3C2410_DCLKCON_DCLK0_CMP(x) (((x) - 1 )<<8)
+
+#define S3C2410_DCLKCON_DCLK1EN (1<<16)
+#define S3C2410_DCLKCON_DCLK1_PCLK (0<<17)
+#define S3C2410_DCLKCON_DCLK1_UCLK (1<<17)
+#define S3C2410_DCLKCON_DCLK1_DIV(x) (((x) - 1) <<20)
+
+#define S3C2410_CLKDIVN_PDIVN (1<<0)
+#define S3C2410_CLKDIVN_HDIVN (1<<1)
+
+static inline unsigned int
+s3c2410_get_pll(int pllval, int baseclk)
+{
+ int mdiv, pdiv, sdiv;
+
+ mdiv = pllval >> S3C2410_PLLCON_MDIVSHIFT;
+ pdiv = pllval >> S3C2410_PLLCON_PDIVSHIFT;
+ sdiv = pllval >> S3C2410_PLLCON_SDIVSHIFT;
+
+ mdiv &= S3C2410_PLLCON_MDIVMASK;
+ pdiv &= S3C2410_PLLCON_PDIVMASK;
+ sdiv &= S3C2410_PLLCON_SDIVMASK;
+
+ return (baseclk * (mdiv + 8)) / ((pdiv + 2) << sdiv);
+}
+
+#endif /* ASMARM_ARCH_S3C2410_CLOCK_H */
+
+
+
+
+
+
+
diff -urN linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-gpio.h linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-gpio.h
--- linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-gpio.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-gpio.h 2004-03-07 13:01:28.000000000 +0000
@@ -0,0 +1,602 @@
+/* linux/include/asm-arm/arch-s3c2410/S3C2410-gpio.h
+ *
+ * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
+ * http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ * S3C2410 GPIO register definitions
+ *
+ * Changelog:
+ * 19-06-2003 BJD Created file
+ * 23-06-2003 BJD Updated GSTATUS registers
+ */
+
+#ifndef ASMARM_ARCH_S3C2410_GPIO_H
+#define ASMARM_ARCH_S3C2410_GPIO_H
+
+/* configure GPIO ports A..G */
+
+#define S3C2410_GPIOREG(x) ((x) + S3C2410_VA_GPIO)
+
+/* port A - 22bits, zero in bit X makes pin X output
+ * 1 makes port special function, this is default
+*/
+#define S3C2410_GPACON S3C2410_GPIOREG(0x00)
+#define S3C2410_GPADAT S3C2410_GPIOREG(0x04)
+
+/* 0x08 and 0x0c are reserved */
+
+/* GPB is 10 IO pins, each configured by 2 bits each in GPBCON.
+ * 00 = input, 01 = output, 10=special function, 11=reserved
+ * bit 0,1 = pin 0, 2,3= pin 1...
+ *
+ * CPBUP = pull up resistor control, 1=disabled, 0=enabled
+*/
+
+#define S3C2410_GPBCON S3C2410_GPIOREG(0x10)
+#define S3C2410_GPBDAT S3C2410_GPIOREG(0x14)
+#define S3C2410_GPBUP S3C2410_GPIOREG(0x18)
+
+/* no i/o pin in port b can have value 3! */
+
+#define S3C2410_GPB0_INP (0x00 << 0)
+#define S3C2410_GPB0_OUTP (0x01 << 0)
+#define S3C2410_GPB0_TOUT0 (0x02 << 0)
+
+#define S3C2410_GPB1_INP (0x00 << 2)
+#define S3C2410_GPB1_OUTP (0x01 << 2)
+#define S3C2410_GPB1_TOUT1 (0x02 << 2)
+
+#define S3C2410_GPB2_INP (0x00 << 4)
+#define S3C2410_GPB2_OUTP (0x01 << 4)
+#define S3C2410_GPB2_TOUT2 (0x02 << 4)
+
+#define S3C2410_GPB3_INP (0x00 << 6)
+#define S3C2410_GPB3_OUTP (0x01 << 6)
+#define S3C2410_GPB3_TOUT3 (0x02 << 6)
+
+#define S3C2410_GPB4_INP (0x00 << 8)
+#define S3C2410_GPB4_OUTP (0x01 << 8)
+#define S3C2410_GPB4_TCLK0 (0x02 << 8)
+#define S3C2410_GPB4_MASK (0x03 << 8)
+
+#define S3C2410_GPB5_INP (0x00 << 10)
+#define S3C2410_GPB5_OUTP (0x01 << 10)
+#define S3C2410_GPB5_nXBACK (0x02 << 10)
+
+#define S3C2410_GPB6_INP (0x00 << 12)
+#define S3C2410_GPB6_OUTP (0x01 << 12)
+#define S3C2410_GPB6_nXBREQ (0x02 << 12)
+
+#define S3C2410_GPB7_INP (0x00 << 14)
+#define S3C2410_GPB7_OUTP (0x01 << 14)
+#define S3C2410_GPB7_nXDACK1 (0x02 << 14)
+
+#define S3C2410_GPB8_INP (0x00 << 16)
+#define S3C2410_GPB8_OUTP (0x01 << 16)
+#define S3C2410_GPB8_nXDREQ1 (0x02 << 16)
+
+#define S3C2410_GPB9_INP (0x00 << 18)
+#define S3C2410_GPB9_OUTP (0x01 << 18)
+#define S3C2410_GPB9_nXDACK0 (0x02 << 18)
+
+#define S3C2410_GPB10_INP (0x00 << 18)
+#define S3C2410_GPB10_OUTP (0x01 << 18)
+#define S3C2410_GPB10_nXDRE0 (0x02 << 18)
+
+/* Port C consits of 16 GPIO/Special function
+ *
+ * almost identical setup to port b, but the special functions are mostly
+ * to do with the video system's sync/etc.
+*/
+
+#define S3C2410_GPCCON S3C2410_GPIOREG(0x20)
+#define S3C2410_GPCDAT S3C2410_GPIOREG(0x24)
+#define S3C2410_GPCUP S3C2410_GPIOREG(0x28)
+
+#define S3C2410_GPC0_INP (0x00 << 0)
+#define S3C2410_GPC0_OUTP (0x01 << 0)
+#define S3C2410_GPC0_LEND (0x02 << 0)
+
+#define S3C2410_GPC1_INP (0x00 << 2)
+#define S3C2410_GPC1_OUTP (0x01 << 2)
+#define S3C2410_GPC1_VCLK (0x02 << 2)
+
+#define S3C2410_GPC2_INP (0x00 << 4)
+#define S3C2410_GPC2_OUTP (0x01 << 4)
+#define S3C2410_GPC2_VLINE (0x02 << 4)
+
+#define S3C2410_GPC3_INP (0x00 << 6)
+#define S3C2410_GPC3_OUTP (0x01 << 6)
+#define S3C2410_GPC3_VFRAME (0x02 << 6)
+
+#define S3C2410_GPC4_INP (0x00 << 8)
+#define S3C2410_GPC4_OUTP (0x01 << 8)
+#define S3C2410_GPC4_VM (0x02 << 8)
+
+#define S3C2410_GPC5_INP (0x00 << 10)
+#define S3C2410_GPC5_OUTP (0x01 << 10)
+#define S3C2410_GPC5_LCDVF0 (0x02 << 10)
+
+#define S3C2410_GPC6_INP (0x00 << 12)
+#define S3C2410_GPC6_OUTP (0x01 << 12)
+#define S3C2410_GPC6_LCDVF1 (0x02 << 12)
+
+#define S3C2410_GPC7_INP (0x00 << 14)
+#define S3C2410_GPC7_OUTP (0x01 << 14)
+#define S3C2410_GPC7_LCDVF2 (0x02 << 14)
+
+#define S3C2410_GPC8_INP (0x00 << 16)
+#define S3C2410_GPC8_OUTP (0x01 << 16)
+#define S3C2410_GPC8_VD0 (0x02 << 16)
+
+#define S3C2410_GPC9_INP (0x00 << 18)
+#define S3C2410_GPC9_OUTP (0x01 << 18)
+#define S3C2410_GPC9_VD1 (0x02 << 18)
+
+#define S3C2410_GPC10_INP (0x00 << 20)
+#define S3C2410_GPC10_OUTP (0x01 << 20)
+#define S3C2410_GPC10_VD2 (0x02 << 20)
+
+#define S3C2410_GPC11_INP (0x00 << 22)
+#define S3C2410_GPC11_OUTP (0x01 << 22)
+#define S3C2410_GPC11_VD3 (0x02 << 22)
+
+#define S3C2410_GPC12_INP (0x00 << 24)
+#define S3C2410_GPC12_OUTP (0x01 << 24)
+#define S3C2410_GPC12_VD4 (0x02 << 24)
+
+#define S3C2410_GPC13_INP (0x00 << 26)
+#define S3C2410_GPC13_OUTP (0x01 << 26)
+#define S3C2410_GPC13_VD5 (0x02 << 26)
+
+#define S3C2410_GPC14_INP (0x00 << 28)
+#define S3C2410_GPC14_OUTP (0x01 << 28)
+#define S3C2410_GPC14_VD6 (0x02 << 28)
+
+#define S3C2410_GPC15_INP (0x00 << 30)
+#define S3C2410_GPC15_OUTP (0x01 << 30)
+#define S3C2410_GPC15_VD7 (0x02 << 30)
+
+/* Port D consists of 16 GPIO/Special function
+ *
+ * almost identical setup to port b, but the special functions are mostly
+ * to do with the video system's data.
+*/
+
+#define S3C2410_GPDCON S3C2410_GPIOREG(0x30)
+#define S3C2410_GPDDAT S3C2410_GPIOREG(0x34)
+#define S3C2410_GPDUP S3C2410_GPIOREG(0x38)
+
+#define S3C2410_GPD0_INP (0x00 << 0)
+#define S3C2410_GPD0_OUTP (0x01 << 0)
+#define S3C2410_GPD0_VD8 (0x02 << 0)
+
+#define S3C2410_GPD1_INP (0x00 << 2)
+#define S3C2410_GPD1_OUTP (0x01 << 2)
+#define S3C2410_GPD1_VD9 (0x02 << 2)
+
+#define S3C2410_GPD2_INP (0x00 << 4)
+#define S3C2410_GPD2_OUTP (0x01 << 4)
+#define S3C2410_GPD2_VD10 (0x02 << 4)
+
+#define S3C2410_GPD3_INP (0x00 << 6)
+#define S3C2410_GPD3_OUTP (0x01 << 6)
+#define S3C2410_GPD3_VD11 (0x02 << 6)
+
+#define S3C2410_GPD4_INP (0x00 << 8)
+#define S3C2410_GPD4_OUTP (0x01 << 8)
+#define S3C2410_GPD4_VD12 (0x02 << 8)
+
+#define S3C2410_GPD5_INP (0x00 << 10)
+#define S3C2410_GPD5_OUTP (0x01 << 10)
+#define S3C2410_GPD5_VD13 (0x02 << 10)
+
+#define S3C2410_GPD6_INP (0x00 << 12)
+#define S3C2410_GPD6_OUTP (0x01 << 12)
+#define S3C2410_GPD6_VD14 (0x02 << 12)
+
+#define S3C2410_GPD7_INP (0x00 << 14)
+#define S3C2410_GPD7_OUTP (0x01 << 14)
+#define S3C2410_GPD7_VD15 (0x02 << 14)
+
+#define S3C2410_GPD8_INP (0x00 << 16)
+#define S3C2410_GPD8_OUTP (0x01 << 16)
+#define S3C2410_GPD8_VD16 (0x02 << 16)
+
+#define S3C2410_GPD9_INP (0x00 << 18)
+#define S3C2410_GPD9_OUTP (0x01 << 18)
+#define S3C2410_GPD9_VD17 (0x02 << 18)
+
+#define S3C2410_GPD10_INP (0x00 << 20)
+#define S3C2410_GPD10_OUTP (0x01 << 20)
+#define S3C2410_GPD10_VD18 (0x02 << 20)
+
+#define S3C2410_GPD11_INP (0x00 << 22)
+#define S3C2410_GPD11_OUTP (0x01 << 22)
+#define S3C2410_GPD11_VD19 (0x02 << 22)
+
+#define S3C2410_GPD12_INP (0x00 << 24)
+#define S3C2410_GPD12_OUTP (0x01 << 24)
+#define S3C2410_GPD12_VD20 (0x02 << 24)
+
+#define S3C2410_GPD13_INP (0x00 << 26)
+#define S3C2410_GPD13_OUTP (0x01 << 26)
+#define S3C2410_GPD13_VD21 (0x02 << 26)
+
+#define S3C2410_GPD14_INP (0x00 << 28)
+#define S3C2410_GPD14_OUTP (0x01 << 28)
+#define S3C2410_GPD14_VD22 (0x02 << 28)
+
+#define S3C2410_GPD15_INP (0x00 << 30)
+#define S3C2410_GPD15_OUTP (0x01 << 30)
+#define S3C2410_GPD15_VD23 (0x02 << 30)
+
+/* Port E consists of 16 GPIO/Special function
+ *
+ * again, the same as port B, but dealing with I2S, SDI, and
+ * more miscellaneous functions
+*/
+
+#define S3C2410_GPECON S3C2410_GPIOREG(0x40)
+#define S3C2410_GPEDAT S3C2410_GPIOREG(0x44)
+#define S3C2410_GPEUP S3C2410_GPIOREG(0x48)
+
+#define S3C2410_GPE0_INP (0x00 << 0)
+#define S3C2410_GPE0_OUTP (0x01 << 0)
+#define S3C2410_GPE0_I2SLRCK (0x02 << 0)
+#define S3C2410_GPE0_MASK (0x03 << 0)
+
+#define S3C2410_GPE1_INP (0x00 << 2)
+#define S3C2410_GPE1_OUTP (0x01 << 2)
+#define S3C2410_GPE1_I2SSCLK (0x02 << 2)
+#define S3C2410_GPE1_MASK (0x03 << 2)
+
+#define S3C2410_GPE2_INP (0x00 << 4)
+#define S3C2410_GPE2_OUTP (0x01 << 4)
+#define S3C2410_GPE2_CDCLK (0x02 << 4)
+
+#define S3C2410_GPE3_INP (0x00 << 6)
+#define S3C2410_GPE3_OUTP (0x01 << 6)
+#define S3C2410_GPE3_I2SSDI (0x02 << 6)
+#define S3C2410_GPE3_MASK (0x03 << 6)
+
+#define S3C2410_GPE4_INP (0x00 << 8)
+#define S3C2410_GPE4_OUTP (0x01 << 8)
+#define S3C2410_GPE4_I2SSDO (0x02 << 8)
+#define S3C2410_GPE4_MASK (0x03 << 8)
+
+#define S3C2410_GPE5_INP (0x00 << 10)
+#define S3C2410_GPE5_OUTP (0x01 << 10)
+#define S3C2410_GPE5_SDCLK (0x02 << 10)
+
+#define S3C2410_GPE6_INP (0x00 << 12)
+#define S3C2410_GPE6_OUTP (0x01 << 12)
+#define S3C2410_GPE6_SDCLK (0x02 << 12)
+
+#define S3C2410_GPE7_INP (0x00 << 14)
+#define S3C2410_GPE7_OUTP (0x01 << 14)
+#define S3C2410_GPE7_SDCMD (0x02 << 14)
+
+#define S3C2410_GPE8_INP (0x00 << 16)
+#define S3C2410_GPE8_OUTP (0x01 << 16)
+#define S3C2410_GPE8_SDDAT1 (0x02 << 16)
+
+#define S3C2410_GPE9_INP (0x00 << 18)
+#define S3C2410_GPE9_OUTP (0x01 << 18)
+#define S3C2410_GPE9_SDDAT2 (0x02 << 18)
+
+#define S3C2410_GPE10_INP (0x00 << 20)
+#define S3C2410_GPE10_OUTP (0x01 << 20)
+#define S3C2410_GPE10_SDDAT3 (0x02 << 20)
+
+#define S3C2410_GPE11_INP (0x00 << 22)
+#define S3C2410_GPE11_OUTP (0x01 << 22)
+#define S3C2410_GPE11_SPIMISO0 (0x02 << 22)
+
+#define S3C2410_GPE12_INP (0x00 << 24)
+#define S3C2410_GPE12_OUTP (0x01 << 24)
+#define S3C2410_GPE12_SPIMOSI0 (0x02 << 24)
+
+#define S3C2410_GPE13_INP (0x00 << 26)
+#define S3C2410_GPE13_OUTP (0x01 << 26)
+#define S3C2410_GPE13_SPICLK0 (0x02 << 26)
+
+#define S3C2410_GPE14_INP (0x00 << 28)
+#define S3C2410_GPE14_OUTP (0x01 << 28)
+#define S3C2410_GPE14_IICSCL (0x02 << 28)
+#define S3C2410_GPE14_MASK (0x03 << 28)
+
+#define S3C2410_GPE15_INP (0x00 << 30)
+#define S3C2410_GPE15_OUTP (0x01 << 30)
+#define S3C2410_GPE15_IICSDA (0x02 << 30)
+#define S3C2410_GPE15_MASK (0x03 << 30)
+
+#define S3C2410_GPE_PUPDIS(x) (1<<(x))
+
+/* Port F consists of 8 GPIO/Special function
+ *
+ * GPIO / interrupt inputs
+ *
+ * GPFCON has 2 bits for each of the input pins on port F
+ * 00 = 0 input, 1 output, 2 interrupt (EINT0..7), 3 undefined
+ *
+ * pull up works like all other ports.
+*/
+
+#define S3C2410_GPFCON S3C2410_GPIOREG(0x50)
+#define S3C2410_GPFDAT S3C2410_GPIOREG(0x54)
+#define S3C2410_GPFUP S3C2410_GPIOREG(0x58)
+
+
+#define S3C2410_GPF0_INP (0x00 << 0)
+#define S3C2410_GPF0_OUTP (0x01 << 0)
+#define S3C2410_GPF0_EINT0 (0x02 << 0)
+
+#define S3C2410_GPF1_INP (0x00 << 2)
+#define S3C2410_GPF1_OUTP (0x01 << 2)
+#define S3C2410_GPF1_EINT1 (0x02 << 2)
+
+#define S3C2410_GPF2_INP (0x00 << 4)
+#define S3C2410_GPF2_OUTP (0x01 << 4)
+#define S3C2410_GPF2_EINT2 (0x02 << 4)
+
+#define S3C2410_GPF3_INP (0x00 << 6)
+#define S3C2410_GPF3_OUTP (0x01 << 6)
+#define S3C2410_GPF3_EINT3 (0x02 << 6)
+
+#define S3C2410_GPF4_INP (0x00 << 8)
+#define S3C2410_GPF4_OUTP (0x01 << 8)
+#define S3C2410_GPF4_EINT4 (0x02 << 8)
+
+#define S3C2410_GPF5_INP (0x00 << 10)
+#define S3C2410_GPF5_OUTP (0x01 << 10)
+#define S3C2410_GPF5_EINT5 (0x02 << 10)
+
+#define S3C2410_GPF6_INP (0x00 << 12)
+#define S3C2410_GPF6_OUTP (0x01 << 12)
+#define S3C2410_GPF6_EINT6 (0x02 << 12)
+
+#define S3C2410_GPF7_INP (0x00 << 14)
+#define S3C2410_GPF7_OUTP (0x01 << 14)
+#define S3C2410_GPF7_EINT7 (0x02 << 14)
+
+/* Port G consists of 8 GPIO/IRQ/Special function
+ *
+ * GPGCON has 2 bits for each of the input pins on port F
+ * 00 = 0 input, 1 output, 2 interrupt (EINT0..7), 3 special func
+ *
+ * pull up works like all other ports.
+*/
+
+#define S3C2410_GPGCON S3C2410_GPIOREG(0x60)
+#define S3C2410_GPGDAT S3C2410_GPIOREG(0x64)
+#define S3C2410_GPGUP S3C2410_GPIOREG(0x68)
+
+#define S3C2410_GPG0_INP (0x00 << 0)
+#define S3C2410_GPG0_OUTP (0x01 << 0)
+#define S3C2410_GPG0_EINT8 (0x02 << 0)
+
+#define S3C2410_GPG1_INP (0x00 << 2)
+#define S3C2410_GPG1_OUTP (0x01 << 2)
+#define S3C2410_GPG1_EINT9 (0x02 << 2)
+
+#define S3C2410_GPG2_INP (0x00 << 4)
+#define S3C2410_GPG2_OUTP (0x01 << 4)
+#define S3C2410_GPG2_EINT10 (0x02 << 4)
+
+#define S3C2410_GPG3_INP (0x00 << 6)
+#define S3C2410_GPG3_OUTP (0x01 << 6)
+#define S3C2410_GPG3_EINT11 (0x02 << 6)
+
+#define S3C2410_GPG4_INP (0x00 << 8)
+#define S3C2410_GPG4_OUTP (0x01 << 8)
+#define S3C2410_GPG4_EINT12 (0x02 << 8)
+#define S3C2410_GPG4_LCDPWREN (0x03 << 8)
+
+#define S3C2410_GPG5_INP (0x00 << 10)
+#define S3C2410_GPG5_OUTP (0x01 << 10)
+#define S3C2410_GPG5_EINT13 (0x02 << 10)
+#define S3C2410_GPG5_SPIMISO1 (0x03 << 10)
+
+#define S3C2410_GPG6_INP (0x00 << 12)
+#define S3C2410_GPG6_OUTP (0x01 << 12)
+#define S3C2410_GPG6_EINT14 (0x02 << 12)
+#define S3C2410_GPG6_SPIMOSI1 (0x03 << 12)
+
+#define S3C2410_GPG7_INP (0x00 << 14)
+#define S3C2410_GPG7_OUTP (0x01 << 14)
+#define S3C2410_GPG7_EINT15 (0x02 << 14)
+#define S3C2410_GPG7_SPICLK1 (0x03 << 14)
+
+#define S3C2410_GPG8_INP (0x00 << 16)
+#define S3C2410_GPG8_OUTP (0x01 << 16)
+#define S3C2410_GPG8_EINT16 (0x02 << 16)
+
+#define S3C2410_GPG9_INP (0x00 << 18)
+#define S3C2410_GPG9_OUTP (0x01 << 18)
+#define S3C2410_GPG9_EINT17 (0x02 << 18)
+
+#define S3C2410_GPG10_INP (0x00 << 20)
+#define S3C2410_GPG10_OUTP (0x01 << 20)
+#define S3C2410_GPG10_EINT18 (0x02 << 20)
+
+#define S3C2410_GPG11_INP (0x00 << 22)
+#define S3C2410_GPG11_OUTP (0x01 << 22)
+#define S3C2410_GPG11_EINT19 (0x02 << 22)
+#define S3C2410_GPG11_TCLK1 (0x03 << 22)
+
+#define S3C2410_GPG12_INP (0x00 << 24)
+#define S3C2410_GPG12_OUTP (0x01 << 24)
+#define S3C2410_GPG12_EINT18 (0x02 << 24)
+#define S3C2410_GPG12_XMON (0x03 << 24)
+
+#define S3C2410_GPG13_INP (0x00 << 26)
+#define S3C2410_GPG13_OUTP (0x01 << 26)
+#define S3C2410_GPG13_EINT18 (0x02 << 26)
+#define S3C2410_GPG13_nXPON (0x03 << 26)
+
+#define S3C2410_GPG14_INP (0x00 << 28)
+#define S3C2410_GPG14_OUTP (0x01 << 28)
+#define S3C2410_GPG14_EINT18 (0x02 << 28)
+#define S3C2410_GPG14_YMON (0x03 << 28)
+
+#define S3C2410_GPG15_INP (0x00 << 30)
+#define S3C2410_GPG15_OUTP (0x01 << 30)
+#define S3C2410_GPG15_EINT18 (0x02 << 30)
+#define S3C2410_GPG15_nYPON (0x03 << 30)
+
+
+#define S3C2410_GPG_PUPDIS(x) (1<<(x))
+
+/* Port H consists of11 GPIO/serial/Misc pins
+ *
+ * GPGCON has 2 bits for each of the input pins on port F
+ * 00 = 0 input, 1 output, 2 interrupt (EINT0..7), 3 special func
+ *
+ * pull up works like all other ports.
+*/
+
+#define S3C2410_GPHCON S3C2410_GPIOREG(0x70)
+#define S3C2410_GPHDAT S3C2410_GPIOREG(0x74)
+#define S3C2410_GPHUP S3C2410_GPIOREG(0x78)
+
+#define S3C2410_GPH0_INP (0x00 << 0)
+#define S3C2410_GPH0_OUTP (0x01 << 0)
+#define S3C2410_GPH0_nCTS0 (0x02 << 0)
+
+#define S3C2410_GPH1_INP (0x00 << 2)
+#define S3C2410_GPH1_OUTP (0x01 << 2)
+#define S3C2410_GPH1_nRTS0 (0x02 << 2)
+
+#define S3C2410_GPH2_INP (0x00 << 4)
+#define S3C2410_GPH2_OUTP (0x01 << 4)
+#define S3C2410_GPH2_TXD0 (0x02 << 4)
+
+#define S3C2410_GPH3_INP (0x00 << 6)
+#define S3C2410_GPH3_OUTP (0x01 << 6)
+#define S3C2410_GPH3_RXD0 (0x02 << 6)
+
+#define S3C2410_GPH4_INP (0x00 << 8)
+#define S3C2410_GPH4_OUTP (0x01 << 8)
+#define S3C2410_GPH4_TXD1 (0x02 << 8)
+
+#define S3C2410_GPH5_INP (0x00 << 10)
+#define S3C2410_GPH5_OUTP (0x01 << 10)
+#define S3C2410_GPH5_RXD1 (0x02 << 10)
+
+#define S3C2410_GPH6_INP (0x00 << 12)
+#define S3C2410_GPH6_OUTP (0x01 << 12)
+#define S3C2410_GPH6_TXD2 (0x02 << 12)
+#define S3C2410_GPH6_nRTS1 (0x03 << 12)
+
+#define S3C2410_GPH7_INP (0x00 << 14)
+#define S3C2410_GPH7_OUTP (0x01 << 14)
+#define S3C2410_GPH7_RXD2 (0x02 << 14)
+#define S3C2410_GPH7_nCTS1 (0x03 << 14)
+
+#define S3C2410_GPH8_INP (0x00 << 16)
+#define S3C2410_GPH8_OUTP (0x01 << 16)
+#define S3C2410_GPH8_UCLK (0x02 << 16)
+
+#define S3C2410_GPH9_INP (0x00 << 18)
+#define S3C2410_GPH9_OUTP (0x01 << 18)
+#define S3C2410_GPH9_CLKOUT0 (0x02 << 18)
+
+#define S3C2410_GPH10_INP (0x00 << 20)
+#define S3C2410_GPH10_OUTP (0x01 << 20)
+#define S3C2410_GPH10_CLKOUT1 (0x02 << 20)
+
+/* miscellaneous control */
+
+#define S3C2410_MISCCR S3C2410_GPIOREG(0x80)
+#define S3C2410_DCLKCON S3C2410_GPIOREG(0x84)
+
+/* see clock.h for dclk definitions */
+
+/* pullup control on databus */
+#define S3C2410_MISCCR_SPUCR_HEN (0)
+#define S3C2410_MISCCR_SPUCR_HDIS (1<<0)
+#define S3C2410_MISCCR_SPUCR_LEN (0)
+#define S3C2410_MISCCR_SPUCR_LDIS (1<<1)
+
+#define S3C2410_MISCCR_USBDEV (0)
+#define S3C2410_MISCCR_USBHOST (1<<3)
+
+#define S3C2410_MISCCR_CLK0_MPLL (0<<4)
+#define S3C2410_MISCCR_CLK0_UPLL (1<<4)
+#define S3C2410_MISCCR_CLK0_FCLK (2<<4)
+#define S3C2410_MISCCR_CLK0_HCLK (3<<4)
+#define S3C2410_MISCCR_CLK0_PCLK (4<<4)
+#define S3C2410_MISCCR_CLK0_DCLK0 (5<<4)
+
+#define S3C2410_MISCCR_CLK1_MPLL (0<<8)
+#define S3C2410_MISCCR_CLK1_UPLL (1<<8)
+#define S3C2410_MISCCR_CLK1_FCLK (2<<8)
+#define S3C2410_MISCCR_CLK1_HCLK (3<<8)
+#define S3C2410_MISCCR_CLK1_PCLK (4<<8)
+#define S3C2410_MISCCR_CLK1_DCLK1 (5<<8)
+
+#define S3C2410_MISCCR_USBSUSPND0 (1<<12)
+#define S3C2410_MISCCR_USBSUSPND1 (1<<13)
+
+#define S3C2410_MISCCR_nRSTCON (1<<16)
+
+/* external interrupt control... */
+/* S3C2410_EXTINT0 -> irq sense control for EINT0..EINT7
+ * S3C2410_EXTINT1 -> irq sense control for EINT8..EINT15
+ * S3C2410_EXTINT2 -> irq sense control for EINT16..EINT23
+ *
+ * note S3C2410_EXTINT2 has filtering options for EINT16..EINT23
+ *
+ * Samsung datasheet p9-25
+*/
+
+#define S3C2410_EXTINT0 S3C2410_GPIOREG(0x88)
+#define S3C2410_EXTINT1 S3C2410_GPIOREG(0x8C)
+#define S3C2410_EXTINT2 S3C2410_GPIOREG(0x90)
+
+/* values for S3C2410_EXTINT0/1/2 */
+#define S3C2410_EXTINT_LOWLEV (0x00)
+#define S3C2410_EXTINT_HILEV (0x01)
+#define S3C2410_EXTINT_FALLEDGE (0x02)
+#define S3C2410_EXTINT_RISEEDGE (0x04)
+#define S3C2410_EXTINT_BOTHEDGE (0x06)
+
+/* interrupt filtering conrrol for EINT16..EINT23 */
+#define S3C2410_EINFLT0 S3C2410_GPIOREG(0x94)
+#define S3C2410_EINFLT1 S3C2410_GPIOREG(0x98)
+#define S3C2410_EINFLT2 S3C2410_GPIOREG(0x9C)
+#define S3C2410_EINFLT3 S3C2410_GPIOREG(0xA0)
+
+/* mask: 0=enable, 1=disable
+ * 1 bit EINT, 4=EINT4, 23=EINT23
+ * EINT0,1,2,3 are not handled here.
+*/
+#define S3C2410_EINTMASK S3C2410_GPIOREG(0xA4)
+#define S3C2410_EINTPEND S3C2410_GPIOREG(0xA8)
+
+/* GSTATUS have miscellaneous information in them
+ *
+ */
+
+#define S3C2410_GSTATUS0 S3C2410_GPIOREG(0x0AC)
+#define S3C2410_GSTATUS1 S3C2410_GPIOREG(0x0B0)
+#define S3C2410_GSTATUS2 S3C2410_GPIOREG(0x0B4)
+#define S3C2410_GSTATUS3 S3C2410_GPIOREG(0x0B8)
+#define S3C2410_GSTATUS4 S3C2410_GPIOREG(0x0BC)
+
+#define S3C2410_GSTATUS0_nWAIT (1<<3)
+#define S3C2410_GSTATUS0_NCON (1<<2)
+#define S3C2410_GSTATUS0_RnB (1<<1)
+#define S3C2410_GSTATUS0_nBATTFLT (1<<0)
+
+#define S3C2410_GSTATUS2_WTRESET (1<<2)
+#define S3C2410_GSTATUs2_OFFRESET (1<<1)
+#define S3C2410_GSTATUS2_PONRESET (1<<0)
+
+#endif /* ASMARM_ARCH_S3C2410_GPIO_H */
+
diff -urN linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-iis.h linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-iis.h
--- linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-iis.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-iis.h 2004-03-07 13:00:06.000000000 +0000
@@ -0,0 +1,61 @@
+/* linux/include/asm/hardware/s3c2410/iis.h
+ *
+ * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
+ * http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ * S3C2410 IIS register definition
+ *
+ * Changelog:
+ * 19-06-2003 BJD Created file
+ * 26-06-2003 BJD Finished off definitions for register addresses
+ */
+
+#ifndef ASMARM_ARCH_S3C2410_IIS_H
+#define ASMARM_ARCH_S3C2410_IIS_H
+
+#define S3C2410_IISCON (S3C2410_VA_IIS + 0x00)
+
+#define S3C2410_IISCON_LRINDEX (1<<8)
+#define S3C2410_IISCON_TXFIFORDY (1<<7)
+#define S3C2410_IISCON_RXFIFORDY (1<<6)
+#define S3C2410_IISCON_TXDMAEN (1<<5)
+#define S3C2410_IISCON_RXDMAEN (1<<4)
+#define S3C2410_IISCON_TXIDLE (1<<3)
+#define S3C2410_IISCON_RXIDLE (1<<2)
+#define S3C2410_IISCON_IISEN (1<<0)
+
+#define S3C2410_IISMOD (S3C2410_VA_IIS + 0x04)
+
+#define S3C2410_IISMOD_SLAVE (1<<8)
+#define S3C2410_IISMOD_NOXFER (0<<6)
+#define S3C2410_IISMOD_RXMODE (1<<6)
+#define S3C2410_IISMOD_TXMODE (2<<6)
+#define S3C2410_IISMOD_TXRXMODE (3<<6)
+#define S3C2410_IISMOD_LR_LLOW (0<<5)
+#define S3C2410_IISMOD_LR_RLOW (1<<5)
+#define S3C2410_IISMOD_IIS (0<<4)
+#define S3C2410_IISMOD_MSB (1<<4)
+#define S3C2410_IISMOD_8BIT (0<<3)
+#define S3C2410_IISMOD_16BIT (1<<3)
+#define S3C2410_IISMOD_256FS (0<<1)
+#define S3C2410_IISMOD_384FS (1<<1)
+#define S3C2410_IISMOD_16FS (0<<0)
+#define S3C2410_IISMOD_32FS (1<<0)
+#define S3C2410_IISMOD_48FS (2<<0)
+
+#define S3C2410_IISPSR (S3C2410_VA_IIS + 0x08)
+
+#define S3C2410_IISFCON (S3C2410_VA_IIS + 0x0c)
+
+#define S3C2410_IISFCON_TXDMA (1<<15)
+#define S3C2410_IISFCON_RXDMA (1<<14)
+#define S3C2410_IISFCON_TXENABLE (1<<13)
+#define S3C2410_IISFCON_RXENABLE (1<<12)
+
+#define S3C2410_IISFIFO (S3C2410_VA_IIS + 0x10)
+
+#endif /* ASMARM_ARCH_S3C2410_IIS_H */
diff -urN linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-irq.h linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-irq.h
--- linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-irq.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-irq.h 2004-03-07 12:59:08.000000000 +0000
@@ -0,0 +1,34 @@
+/* linux/include/asm-arm/arch-s3c2410/S3C2410-irq.h
+ *
+ * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
+ * http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ * Changelog:
+ * 19-06-2003 BJD Created file
+ */
+
+#ifndef ASMARM_ARCH_S3C2410_IRQ_H
+#define ASMARM_ARCH_S3C2410_IRQ_H
+
+/* interrupt controller */
+
+#define S3C2410_IRQREG(x) ((x) + S3C2410_VA_IRQ)
+#define S3C2410_EINTREG(x) ((x) + S3C2410_VA_GPIO)
+
+#define S3C2410_SRCPND S3C2410_IRQREG(0x000)
+#define S3C2410_INTMOD S3C2410_IRQREG(0x004)
+#define S3C2410_INTMSK S3C2410_IRQREG(0x008)
+#define S3C2410_PRIORITY S3C2410_IRQREG(0x00C)
+#define S3C2410_INTPND S3C2410_IRQREG(0x010)
+#define S3C2410_INTOFFSET S3C2410_IRQREG(0x014)
+#define S3C2410_SUBSRCPND S3C2410_IRQREG(0x018)
+#define S3C2410_INTSUBMSK S3C2410_IRQREG(0x01C)
+
+#define S3C2410_EINTMASK S3C2410_EINTREG(0x0A4)
+#define S3C2410_EINTPEND S3C2410_EINTREG(0X0A8)
+
+#endif /* ASMARM_ARCH_S3C2410_IRQ_H */
diff -urN linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-lcd.h linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-lcd.h
--- linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-lcd.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-lcd.h 2004-03-07 13:05:04.000000000 +0000
@@ -0,0 +1,107 @@
+/* linux/include/asm-arm/arch-s3c2410/S3C2410-lcd.h
+ *
+ * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
+ * http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ *
+ *
+ * Changelog:
+ * 12-06-2003 BJD Created file
+ * 26-06-2003 BJD Updated LCDCON register definitions
+*/
+
+#ifndef ASMARM_ARCH_S3C2410_LCD_H
+#define ASMARM_ARCH_S3C2410_LCD_H
+
+#define S3C2410_LCDREG(x) ((x) + S3C2410_VA_LCD)
+
+/* LCD control registers */
+#define S3C2410_LCDCON1 S3C2410_LCDREG(0x00)
+#define S3C2410_LCDCON2 S3C2410_LCDREG(0x04)
+#define S3C2410_LCDCON3 S3C2410_LCDREG(0x08)
+#define S3C2410_LCDCON4 S3C2410_LCDREG(0x0C)
+#define S3C2410_LCDCON5 S3C2410_LCDREG(0x10)
+
+#define S3C2410_LCDCON1_CLKVAL(x) ((x) << 8)
+#define S3C2410_LCDCON1_MMODE (1<<7)
+#define S3C2410_LCDCON1_DSCAN4 (0<<5)
+#define S3C2410_LCDCON1_STN4 (1<<5)
+#define S3C2410_LCDCON1_STN8 (2<<5)
+#define S3C2410_LCDCON1_TFT (3<<5)
+
+#define S3C2410_LCDCON1_STN1BPP (0<<1)
+#define S3C2410_LCDCON1_STN2GREY (1<<1)
+#define S3C2410_LCDCON1_STN4GREY (2<<1)
+#define S3C2410_LCDCON1_STN8BPP (3<<1)
+#define S3C2410_LCDCON1_STN12BPP (4<<1)
+
+#define S3C2410_LCDCON1_TFT1BPP (8<<1)
+#define S3C2410_LCDCON1_TFT2BPP (9<<1)
+#define S3C2410_LCDCON1_TFT4BPP (10<<1)
+#define S3C2410_LCDCON1_TFT8BPP (11<<1)
+#define S3C2410_LCDCON1_TFT16BPP (12<<1)
+#define S3C2410_LCDCON1_TFT24BPP (13<<1)
+
+#define S3C2410_LCDCON1_ENVDI (1)
+
+#define S3C2410_LCDCON2_VBPD(x) ((x) << 24)
+#define S3C2410_LCDCON2_LINEVAL(x) ((x) << 14)
+#define S3C2410_LCDCON2_VFPD(x) ((x) << 6)
+#define S3C2410_LCDCON2_VSPW(x) ((x) << 0)
+
+#define S3C2410_LCDCON3_HBPD(x) ((x) << 19)
+#define S3C2410_LCDCON3_WDLY(x) ((x) << 19)
+#define S3C2410_LCDCON3_HOZVAL(x) ((x) << 8)
+#define S3C2410_LCDCON3_HFPD(x) ((x) << 0)
+#define S3C2410_LCDCON3_LINEBLANK(x)((x) << 0)
+
+#define S3C2410_LCDCON4_MVAL(x) ((x) << 8)
+#define S3C2410_LCDCON4_HSPW(x) ((x) << 0)
+#define S3C2410_LCDCON4_WLH(x) ((x) << 0)
+
+#define S3C2410_LCDCON5_BPP24BL (1<<12)
+#define S3C2410_LCDCON5_FRM565 (1<<11)
+#define S3C2410_LCDCON5_INVVCLK (1<<10)
+#define S3C2410_LCDCON5_INVVLINE (1<<9)
+#define S3C2410_LCDCON5_INVVFRAME (1<<8)
+#define S3C2410_LCDCON5_INVVD (1<<7)
+#define S3C2410_LCDCON5_INVVSYNC (1<<8)
+#define S3C2410_LCDCON5_INVHSYNC (1<<9)
+#define S3C2410_LCDCON5_INVVDEN (1<<6)
+#define S3C2410_LCDCON5_INVPWREN (1<<5)
+#define S3C2410_LCDCON5_INVLEND (1<<4)
+#define S3C2410_LCDCON5_PWREN (1<<3)
+#define S3C2410_LCDCON5_ENLEND (1<<2)
+#define S3C2410_LCDCON5_BSWP (1<<1)
+#define S3C2410_LCDCON5_HWSWP (1<<0)
+
+/* framebuffer start addressed */
+#define S3C2410_LCDSADDR1 S3C2410_LCDREG(0x14)
+#define S3C2410_LCDSADDR2 S3C2410_LCDREG(0x18)
+#define S3C2410_LCDSADDR3 S3C2410_LCDREG(0x1C)
+
+/* colour lookup and miscellaneous controls */
+
+#define S3C2410_REDLUT S3C2410_LCDREG(0x20)
+#define S3C2410_GREENLUT S3C2410_LCDREG(0x24)
+#define S3C2410_BLUELUT S3C2410_LCDREG(0x28)
+
+#define S3C2410_DITHMODE S3C2410_LCDREG(0x4C)
+#define S3C2410_TPAL S3C2410_LCDREG(0x50)
+
+/* interrupt info */
+#define S3C2410_LCDINTPND S3C2410_LCDREG(0x54)
+#define S3C2410_LCDSRCPND S3C2410_LCDREG(0x58)
+#define S3C2410_LCDINTMSK S3C2410_LCDREG(0x5C)
+#define S3C2410_LPCSEL S3C2410_LCDREG(0x60)
+
+#define S3C2410_TFTPAL(x) S3C2410_LCDREG((0x400 + (x)*4))
+
+#endif /* ASMARM_ARCH_S3C2410_LCD_H */
+
+
+
diff -urN linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-rtc.h linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-rtc.h
--- linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-rtc.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-rtc.h 2004-03-07 12:56:48.000000000 +0000
@@ -0,0 +1,61 @@
+/* linux/include/asm-arm/arch-s3c2410/S3C2410-rtc.h
+ *
+ * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
+ * http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ * S3C2410 Timer configuration
+ *
+ * Changelog:
+ * 05-06-2003 BJD Created file
+ */
+
+#ifndef ASMARM_ARCH_S3C2410_RTC_H
+#define ASMARM_ARCH_S3C2410_RTC_H
+
+#define S3C2410_RTCREG(x) ((x) + S3C2410_VA_RTC)
+
+#define S3C2410_RTCCON S3C2410_RTCREG(0x40)
+#define S3C2410_RTCCON_RTCEN (1<<0)
+#define S3C2410_RTCCON_CLKRST (1<<3)
+
+#define S3C2410_TICNT S3C2410_RTCREG(0x44)
+#define S3C2410_TICNT_ENABLE (1<<7)
+
+#define S3C2410_RTCALM S3C2410_RTCREG(0x50)
+#define S3C2410_RTCALM_ALMEN (1<<6)
+#define S3C2410_RTCALM_YEAREN (1<<5)
+#define S3C2410_RTCALM_MONEN (1<<4)
+#define S3C2410_RTCALM_DAYEN (1<<3)
+#define S3C2410_RTCALM_HOUREN (1<<2)
+#define S3C2410_RTCALM_MINEN (1<<1)
+#define S3C2410_RTCALM_SECEN (1<<0)
+
+#define S3C2410_RTCALM_ALL \
+ S3C2410_RTCALM_ALMEN | S3C2410_RTCALM_YEAREN | S3C2410_RTCALM_MONEN |\
+ S3C2410_RTCALM_DAYEN | S3C2410_RTCALM_HOUREN | S3C2410_RTCALM_MINEN |\
+ S3C2410_RTCALM_SECEN
+
+
+#define S3C2410_ALMSEC S3C2410_RTCREG(0x54)
+#define S3C2410_ALMMIN S3C2410_RTCREG(0x58)
+#define S3C2410_ALMHOUR S3C2410_RTCREG(0x5c)
+
+#define S3C2410_ALMDATE S3C2410_RTCREG(0x60)
+#define S3C2410_ALMMON S3C2410_RTCREG(0x64)
+#define S3C2410_ALMYEAR S3C2410_RTCREG(0x68)
+
+#define S3C2410_RTCRST S3C2410_RTCREG(0x6c)
+
+#define S3C2410_RTCSEC S3C2410_RTCREG(0x70)
+#define S3C2410_RTCMIN S3C2410_RTCREG(0x74)
+#define S3C2410_RTCHOUR S3C2410_RTCREG(0x78)
+#define S3C2410_RTCDATE S3C2410_RTCREG(0x7c)
+#define S3C2410_RTCDAY S3C2410_RTCREG(0x80)
+#define S3C2410_RTCMON S3C2410_RTCREG(0x84)
+#define S3C2410_RTCYEAR S3C2410_RTCREG(0x88)
+
+#endif /* ASMARM_ARCH_S3C2410_RTC_H */
diff -urN linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-serial.h linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-serial.h
--- linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-serial.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-serial.h 2004-03-07 12:55:58.000000000 +0000
@@ -0,0 +1,98 @@
+/*
+ * linux/include/asm-arm/arch-s3c2410/S3C2410-serial.h
+ *
+ * Internal header file for Samsung S3C2410 serial ports (UART0-2)
+ *
+ * Copyright (C) 2002 Shane Nay (shane@minirl.com)
+ *
+ * Additional defines, (c) 2003 Simtec Electronics (linux@simtec.co.uk)
+ *
+ * Adapted from:
+ *
+ * Internal header file for MX1ADS serial ports (UART1 & 2)
+ *
+ * Copyright (C) 2002 Shane Nay (shane@minirl.com)
+ *
+ * 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
+ */
+
+#ifndef ASMARM_ARCH_S3C2410_SERIAL_H
+#define ASMARM_ARCH_S3C2410_SERIAL_H
+
+#define S3C2410_UARTRXH0_OFF (0x24)
+#define S3C2410_UARTTXH0_OFF (0x20)
+#define S3C2410_UARTLCON_OFF (0x00)
+#define S3C2410_UARTCON_OFF (0x04)
+#define S3C2410_UARTFCON_OFF (0x08)
+#define S3C2410_UARTMCON_OFF (0x0C)
+#define S3C2410_UARTBRDIV_OFF (0x28)
+#define S3C2410_UARTTRSTAT_OFF (0x10)
+#define S3C2410_UARTERSTAT_OFF (0x14)
+#define S3C2410_UARTFSTAT_OFF (0x18)
+#define S3C2410_UARTMSTAT_OFF (0x1C)
+
+
+#define S3C2410_UART1_OFF (0x4000)
+#define S3C2410_UART2_OFF (0x8000)
+
+#define S3C2410_LCON_CFGMASK ((0xF<<3)|(0x3))
+
+#define S3C2410_LCON_CS5 (0x0)
+#define S3C2410_LCON_CS6 (0x1)
+#define S3C2410_LCON_CS7 (0x2)
+#define S3C2410_LCON_CS8 (0x3)
+
+#define S3C2410_LCON_PNONE (0x0)
+#define S3C2410_LCON_PEVEN ((0x5)<<3)
+#define S3C2410_LCON_PODD ((0x4)<<3)
+
+#define S3C2410_UMCON_AFC (0x10)
+#define S3C2410_UMCON_RTS (0x1)
+
+#define S3C2410_UMSTAT_CTS (0x1)
+
+#define S3C2410_UCON_SBREAK (1<<4)
+
+#define S3C2410_UCON_TXILEVEL (1<<9)
+#define S3C2410_UCON_RXILEVEL (1<<8)
+#define S3C2410_UCON_TXIRQMODE (1<<2)
+#define S3C2410_UCON_RXIRQMODE (1<<0)
+#define S3C2410_UCON_RXFIFO_TOI (1<<7)
+
+#define S3C2410_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | S3C2410_UCON_RXILEVEL \
+ | S3C2410_UCON_TXIRQMODE | S3C2410_UCON_RXIRQMODE \
+ | S3C2410_UCON_RXFIFO_TOI)
+
+#define S3C2410_UFCON_FIFOMODE (1<<0)
+#define S3C2410_UFCON_TXTRIG0 (0<<6)
+#define S3C2410_UFCON_RXTRIG8 (1<<4)
+#define S3C2410_UFCON_RXTRIG12 (2<<4)
+
+#define S3C2410_UFCON_RESETBOTH (3<<1)
+
+#define S3C2410_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | S3C2410_UFCON_TXTRIG0 \
+ | S3C2410_UFCON_RXTRIG8 )
+
+#define S3C2410_UFSTAT_TXFULL (1<<9)
+#define S3C2410_UFSTAT_RXFULL (1<<8)
+#define S3C2410_UFSTAT_TXMASK (15<<4)
+#define S3C2410_UFSTAT_TXSHIFT (4)
+#define S3C2410_UFSTAT_RXMASK (15<<0)
+#define S3C2410_UFSTAT_RXSHIFT (0)
+
+#define S3C2410_UTRSTAT_TXFE (1<<1)
+#define S3C2410_UTRSTAT_RXDR (1<<0)
+
+#endif /* ASMARM_ARCH_S3C2410_SERIAL_H */
diff -urN linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-timer.h linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-timer.h
--- linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-timer.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-timer.h 2004-03-07 12:55:07.000000000 +0000
@@ -0,0 +1,81 @@
+/* linux/include/asm-arm/arch-s3c2410/S3C2410-timer.h
+ *
+ * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
+ * http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ * S3C2410 Timer configuration
+ *
+ * Changelog:
+ * 05-06-2003 BJD Created file
+ * 26-06-2003 BJD Added more timer definitions to mux / control
+ */
+
+#ifndef ASMARM_ARCH_S3C2410_TIMER_H
+#define ASMARM_ARCH_S3C2410_TIMER_H
+
+#define S3C2410_TIMERREG(x) (S3C2410_VA_TIMER + (x))
+#define S3C2410_TIMERREG2(tmr,reg) S3C2410_TIMERREG((reg)+0x0c+((tmr)*0x0c))
+
+#define S3C2410_TCFG0 S3C2410_TIMERREG(0x00)
+#define S3C2410_TCFG1 S3C2410_TIMERREG(0x04)
+#define S3C2410_TCON S3C2410_TIMERREG(0x08)
+
+
+#define S3C2410_TCFG1_MUX4_TCLK1 (4<<16)
+#define S3C2410_TCFG1_MUX4_MASK (15<<16)
+
+#define S3C2410_TCFG1_MUX3_TCLK1 (4<<12)
+#define S3C2410_TCFG1_MUX3_MASK (15<<12)
+
+#define S3C2410_TCFG1_MUX2_TCLK1 (4<<8)
+#define S3C2410_TCFG1_MUX2_MASK (15<<8)
+
+#define S3C2410_TCFG1_MUX1_TCLK0 (4<<4)
+#define S3C2410_TCFG1_MUX1_MASK (15<<4)
+
+#define S3C2410_TCFG1_MUX0_TCLK0 (4<<0)
+#define S3C2410_TCFG1_MUX0_MASK (15<<0)
+
+/* for each timer, we have an count buffer, an compare buffer and an
+ * observation buffer
+ */
+
+/* WARNING - timer 4 has no buffer reg, and it's observation is at +4 */
+
+#define S3C2410_TCNTB(tmr) S3C2410_TIMERREG2(tmr, 0x00)
+#define S3C2410_TCMPB(tmr) S3C2410_TIMERREG2(tmr, 0x04)
+#define S3C2410_TCNTO(tmr) S3C2410_TIMERREG2(tmr, (((tmr) == 4) ? 0x04 : 0x08))
+
+#define S3C2410_TCON_T4RELOAD (1<<22)
+#define S3C2410_TCON_T4MANUALUPD (1<<21)
+#define S3C2410_TCON_T4START (1<<20)
+
+#define S3C2410_TCON_T3RELOAD (1<<19)
+#define S3C2410_TCON_T3INVERT (1<<18)
+#define S3C2410_TCON_T3MANUALUPD (1<<17)
+#define S3C2410_TCON_T3START (1<<16)
+
+#define S3C2410_TCON_T2RELOAD (1<<15)
+#define S3C2410_TCON_T2INVERT (1<<14)
+#define S3C2410_TCON_T2MANUALUPD (1<<13)
+#define S3C2410_TCON_T2START (1<<12)
+
+#define S3C2410_TCON_T1RELOAD (1<<11)
+#define S3C2410_TCON_T1INVERT (1<<10)
+#define S3C2410_TCON_T1MANUALUPD (1<<9)
+#define S3C2410_TCON_T1START (1<<8)
+
+#define S3C2410_TCON_T0DEADZONE (1<<4)
+#define S3C2410_TCON_T0RELOAD (1<<3)
+#define S3C2410_TCON_T0INVERT (1<<2)
+#define S3C2410_TCON_T0MANUALUPD (1<<1)
+#define S3C2410_TCON_T0START (1<<0)
+
+#endif /* ASMARM_ARCH_S3C2410_TIMER_H */
+
+
+
diff -urN linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-watchdog.h linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-watchdog.h
--- linux-2.4.26/include/asm-arm/arch-s3c2410/S3C2410-watchdog.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/arch-s3c2410/S3C2410-watchdog.h 2004-03-07 12:37:53.000000000 +0000
@@ -0,0 +1,40 @@
+/* linux/include/asm-arm/arch-s3c2410/S3C2410-watchdog.h
+ *
+ * Copyright (c) 2003 Simtec Electronics <linux@simtec.co.uk>
+ * http://www.simtec.co.uk/products/SWLINUX/
+ *
+ * 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.
+ *
+ * S3C2410 Watchdog timer control
+ *
+ * Changelog:
+ * 21-06-2003 BJD Created file
+*/
+
+#ifndef ASMARM_ARCH_S3C2410_WATCHDOG_H
+#define ASMARM_ARCH_S3C2410_WATCHDOG_H
+
+#define S3C2410_WDOGREG(x) ((x) + S3C2410_VA_WATCHDOG)
+
+#define S3C2410_WTCON S3C2410_WDOGREG(0x00)
+#define S3C2410_WTDAT S3C2410_WDOGREG(0x04)
+#define S3C2410_WTCNT S3C2410_WDOGREG(0x08)
+
+/* the watchdog can either generate a reset pulse, or an interrupt. */
+
+#define S3C2410_WTCON_RSTEN (0x01)
+#define S3C2410_WTCON_INTEN (1<<2)
+#define S3C2410_WTCON_ENABLE (1<<5)
+
+#define S3C2410_WTCON_DIV16 (0<<3)
+#define S3C2410_WTCON_DIV32 (1<<3)
+#define S3C2410_WTCON_DIV64 (2<<3)
+#define S3C2410_WTCON_DIV128 (3<<3)
+
+#define S3C2410_WTCON_PRESCALE(x) ((x) << 8)
+
+#endif /* ASMARM_ARCH_S3C2410_WATCHDOG_H */
+
+
diff -urN linux-2.4.26/include/asm-arm/bugs.h linux-2.4.26-vrs1/include/asm-arm/bugs.h
--- linux-2.4.26/include/asm-arm/bugs.h 2000-09-18 23:15:23.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/bugs.h 2004-02-23 01:01:28.000000000 +0000
@@ -10,8 +10,17 @@
#ifndef __ASM_BUGS_H
#define __ASM_BUGS_H
+#include <linux/config.h>
#include <asm/proc-fns.h>
-#define check_bugs() cpu_check_bugs()
+extern void check_writebuffer_bugs(void);
+
+static inline void check_bugs(void)
+{
+#ifdef CONFIG_CPU_32
+ check_writebuffer_bugs();
+#endif
+ cpu_check_bugs();
+}
#endif
diff -urN linux-2.4.26/include/asm-arm/div64.h linux-2.4.26-vrs1/include/asm-arm/div64.h
--- linux-2.4.26/include/asm-arm/div64.h 2000-01-13 21:30:31.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-arm/div64.h 2004-01-14 21:32:29.000000000 +0000
@@ -4,9 +4,13 @@
/* We're not 64-bit, but... */
#define do_div(n,base) \
({ \
- int __res; \
- __res = ((unsigned long)n) % (unsigned int)base; \
- n = ((unsigned long)n) / (unsigned int)base; \
+ register int __res asm("r2") = base; \
+ register unsigned long long __n asm("r0") = n; \
+ asm("bl do_div64" \
+ : "=r" (__n), "=r" (__res) \
+ : "0" (__n), "1" (__res) \
+ : "r3", "ip", "lr", "cc"); \
+ n = __n; \
__res; \
})
diff -urN linux-2.4.26/include/asm-arm/elf.h linux-2.4.26-vrs1/include/asm-arm/elf.h
--- linux-2.4.26/include/asm-arm/elf.h 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-arm/elf.h 2004-04-19 20:37:56.000000000 +0100
@@ -45,8 +45,8 @@
#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
-/* When the program starts, a1 contains a pointer to a function to be
- registered with atexit, as per the SVR4 ABI. A value of 0 means we
+/* When the program starts, a1 contains a pointer to a function to be
+ registered with atexit, as per the SVR4 ABI. A value of 0 means we
have no such handler. */
#define ELF_PLAT_INIT(_r, load_addr) (_r)->ARM_r0 = 0
diff -urN linux-2.4.26/include/asm-arm/mach/dma.h linux-2.4.26-vrs1/include/asm-arm/mach/dma.h
--- linux-2.4.26/include/asm-arm/mach/dma.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/mach/dma.h 2004-03-04 21:39:05.000000000 +0000
@@ -41,6 +41,7 @@
unsigned int dma_base; /* Controller base address */
int dma_irq; /* Controller IRQ */
struct scatterlist cur_sg; /* Current controller buffer */
+ unsigned int state; /* RiscPC DMA status */
struct dma_ops *d_ops;
};
diff -urN linux-2.4.26/include/asm-arm/mach/serial_at91rm9200.h linux-2.4.26-vrs1/include/asm-arm/mach/serial_at91rm9200.h
--- linux-2.4.26/include/asm-arm/mach/serial_at91rm9200.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/mach/serial_at91rm9200.h 2004-03-04 21:52:13.000000000 +0000
@@ -10,7 +10,6 @@
#include <linux/config.h>
struct uart_port;
-struct uart_info;
/*
* This is a temporary structure for registering these
@@ -22,11 +21,11 @@
void (*enable_ms)(struct uart_port *);
void (*pm)(struct uart_port *, u_int, u_int);
int (*set_wake)(struct uart_port *, u_int);
- int (*open)(struct uart_port *, struct uart_info *);
- void (*close)(struct uart_port *, struct uart_info *);
+ int (*open)(struct uart_port *);
+ void (*close)(struct uart_port *);
};
-#if defined(CONFIG_SERIAL_AT91RM9200)
+#if defined(CONFIG_SERIAL_AT91)
void at91rm9200_register_uart_fns(struct at91rm9200_port_fns *fns);
void at91rm9200_register_uart(int idx, int port);
#else
diff -urN linux-2.4.26/include/asm-arm/pci.h linux-2.4.26-vrs1/include/asm-arm/pci.h
--- linux-2.4.26/include/asm-arm/pci.h 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-arm/pci.h 2004-04-19 20:38:16.000000000 +0100
@@ -113,6 +113,28 @@
/* nothing to do */
}
+/*
+ * pci_{map,unmap}_page maps a kernel page to a dma_addr_t. identical
+ * to pci_map_single, but takes a struct page instead of a virtual address
+ */
+static inline dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
+ unsigned long offset, size_t size,
+ int direction)
+{
+ void *start;
+ BUG_ON(direction == PCI_DMA_NONE);
+ start = page_address(page) + offset;
+ consistent_sync(start, size, direction);
+ return virt_to_bus(start);
+}
+
+static inline void pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,
+ size_t size, int direction)
+{
+ BUG_ON(direction == PCI_DMA_NONE);
+ /* Nothing to do */
+}
+
/* Whether pci_unmap_{single,page} is a nop depends upon the
* configuration.
*/
diff -urN linux-2.4.26/include/asm-arm/proc-armv/processor.h linux-2.4.26-vrs1/include/asm-arm/proc-armv/processor.h
--- linux-2.4.26/include/asm-arm/proc-armv/processor.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/proc-armv/processor.h 2004-02-22 23:56:12.000000000 +0000
@@ -54,7 +54,9 @@
regs->ARM_cpsr = USR_MODE; \
else \
regs->ARM_cpsr = USR26_MODE; \
- regs->ARM_pc = pc; /* pc */ \
+ if (elf_hwcap & HWCAP_THUMB && pc & 1) \
+ regs->ARM_cpsr |= PSR_T_BIT; \
+ regs->ARM_pc = pc & ~1; /* pc */ \
regs->ARM_sp = sp; /* sp */ \
regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
diff -urN linux-2.4.26/include/asm-arm/proc-armv/ptrace.h linux-2.4.26-vrs1/include/asm-arm/proc-armv/ptrace.h
--- linux-2.4.26/include/asm-arm/proc-armv/ptrace.h 2000-11-28 01:07:59.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-arm/proc-armv/ptrace.h 2004-01-14 21:32:29.000000000 +0000
@@ -33,6 +33,16 @@
#define CC_N_BIT (1 << 31)
#define PCMASK 0
+/* 2.5 versions */
+#define PSR_T_BIT 0x00000020
+#define PSR_F_BIT 0x00000040
+#define PSR_I_BIT 0x00000080
+#define PSR_J_BIT 0x01000000
+#define PSR_V_BIT 0x10000000
+#define PSR_C_BIT 0x20000000
+#define PSR_Z_BIT 0x40000000
+#define PSR_N_BIT 0x80000000
+
#ifndef __ASSEMBLY__
/* this struct defines the way the registers are stored on the
diff -urN linux-2.4.26/include/asm-arm/proc-armv/uaccess.h linux-2.4.26-vrs1/include/asm-arm/proc-armv/uaccess.h
--- linux-2.4.26/include/asm-arm/proc-armv/uaccess.h 2001-10-25 21:53:55.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/proc-armv/uaccess.h 2004-04-19 20:37:56.000000000 +0100
@@ -12,12 +12,11 @@
* Note that this is actually 0x1,0000,0000
*/
#define KERNEL_DS 0x00000000
-#define USER_DS PAGE_OFFSET
+#define USER_DS TASK_SIZE
static inline void set_fs (mm_segment_t fs)
{
current->addr_limit = fs;
-
modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
}
@@ -38,7 +37,7 @@
: "cc"); \
(flag == 0); })
-#define __put_user_asm_byte(x,addr,err) \
+#define __put_user_asm_byte(x,__pu_addr,err) \
__asm__ __volatile__( \
"1: strbt %1,[%2],#0\n" \
"2:\n" \
@@ -51,18 +50,18 @@
" .align 3\n" \
" .long 1b, 3b\n" \
" .previous" \
- : "=r" (err) \
- : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err))
+ : "+r" (err) \
+ : "r" (x), "r" (__pu_addr), "i" (-EFAULT) \
+ : "cc")
-#define __put_user_asm_half(x,addr,err) \
+#define __put_user_asm_half(x,__pu_addr,err) \
({ \
unsigned long __temp = (unsigned long)(x); \
- unsigned long __ptr = (unsigned long)(addr); \
- __put_user_asm_byte(__temp, __ptr, err); \
- __put_user_asm_byte(__temp >> 8, __ptr + 1, err); \
+ __put_user_asm_byte(__temp, __pu_addr, err); \
+ __put_user_asm_byte(__temp >> 8, __pu_addr + 1, err); \
})
-#define __put_user_asm_word(x,addr,err) \
+#define __put_user_asm_word(x,__pu_addr,err) \
__asm__ __volatile__( \
"1: strt %1,[%2],#0\n" \
"2:\n" \
@@ -75,8 +74,28 @@
" .align 3\n" \
" .long 1b, 3b\n" \
" .previous" \
- : "=r" (err) \
- : "r" (x), "r" (addr), "i" (-EFAULT), "0" (err))
+ : "+r" (err) \
+ : "r" (x), "r" (__pu_addr), "i" (-EFAULT) \
+ : "cc")
+
+#define __put_user_asm_dword(x,__pu_addr,err) \
+ __asm__ __volatile__( \
+ "1: strt %R2, [%1], #4\n" \
+ "2: strt %Q2, [%1], #0\n" \
+ "3:\n" \
+ " .section .fixup,\"ax\"\n" \
+ " .align 2\n" \
+ "4: mov %0, %3\n" \
+ " b 3b\n" \
+ " .previous\n" \
+ " .section __ex_table,\"a\"\n" \
+ " .align 3\n" \
+ " .long 1b, 4b\n" \
+ " .long 2b, 4b\n" \
+ " .previous" \
+ : "+r" (err), "+r" (__pu_addr) \
+ : "r" (x), "i" (-EFAULT) \
+ : "cc")
#define __get_user_asm_byte(x,addr,err) \
__asm__ __volatile__( \
@@ -92,18 +111,18 @@
" .align 3\n" \
" .long 1b, 3b\n" \
" .previous" \
- : "=r" (err), "=&r" (x) \
- : "r" (addr), "i" (-EFAULT), "0" (err))
+ : "+r" (err), "=&r" (x) \
+ : "r" (addr), "i" (-EFAULT) \
+ : "cc")
-#define __get_user_asm_half(x,addr,err) \
+#define __get_user_asm_half(x,__gu_addr,err) \
({ \
- unsigned long __b1, __b2, __ptr = (unsigned long)addr; \
- __get_user_asm_byte(__b1, __ptr, err); \
- __get_user_asm_byte(__b2, __ptr + 1, err); \
+ unsigned long __b1, __b2; \
+ __get_user_asm_byte(__b1, __gu_addr, err); \
+ __get_user_asm_byte(__b2, __gu_addr + 1, err); \
(x) = __b1 | (__b2 << 8); \
})
-
#define __get_user_asm_word(x,addr,err) \
__asm__ __volatile__( \
"1: ldrt %1,[%2],#0\n" \
@@ -118,8 +137,9 @@
" .align 3\n" \
" .long 1b, 3b\n" \
" .previous" \
- : "=r" (err), "=&r" (x) \
- : "r" (addr), "i" (-EFAULT), "0" (err))
+ : "+r" (err), "=&r" (x) \
+ : "r" (addr), "i" (-EFAULT) \
+ : "cc")
extern unsigned long __arch_copy_from_user(void *to, const void *from, unsigned long n);
#define __do_copy_from_user(to,from,n) \
diff -urN linux-2.4.26/include/asm-arm/proc-fns.h linux-2.4.26-vrs1/include/asm-arm/proc-fns.h
--- linux-2.4.26/include/asm-arm/proc-fns.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/proc-fns.h 2004-04-19 20:37:56.000000000 +0100
@@ -76,6 +76,30 @@
# define CPU_NAME arm926
# endif
# endif
+# ifdef CONFIG_CPU_ARM1020
+# ifdef CPU_NAME
+# undef MULTI_CPU
+# define MULTI_CPU
+# else
+# define CPU_NAME arm1020
+# endif
+# endif
+# ifdef CONFIG_CPU_ARM1020E
+# ifdef CPU_NAME
+# undef MULTI_CPU
+# define MULTI_CPU
+# else
+# define CPU_NAME arm1020E
+# endif
+# endif
+# ifdef CONFIG_CPU_ARM1022
+# ifdef CPU_NAME
+# undef MULTI_CPU
+# define MULTI_CPU
+# else
+# define CPU_NAME arm1022
+# endif
+# endif
# ifdef CONFIG_CPU_ARM1026
# ifdef CPU_NAME
# undef MULTI_CPU
diff -urN linux-2.4.26/include/asm-arm/processor.h linux-2.4.26-vrs1/include/asm-arm/processor.h
--- linux-2.4.26/include/asm-arm/processor.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/processor.h 2004-04-19 20:37:56.000000000 +0100
@@ -43,6 +43,7 @@
#include <asm/atomic.h>
#include <asm/ptrace.h>
#include <asm/arch/memory.h>
+#include <asm/elf.h>
#include <asm/proc/processor.h>
#include <asm/types.h>
diff -urN linux-2.4.26/include/asm-arm/system.h linux-2.4.26-vrs1/include/asm-arm/system.h
--- linux-2.4.26/include/asm-arm/system.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/system.h 2004-04-19 20:37:56.000000000 +0100
@@ -29,6 +29,10 @@
void die_if_kernel(const char *str, struct pt_regs *regs, int err);
+void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
+ struct pt_regs *),
+ int sig, const char *name);
+
#include <asm/proc-fns.h>
#define xchg(ptr,x) \
@@ -89,6 +93,14 @@
#define sti() local_irq_enable()
#define clf() __clf()
#define stf() __stf()
+
+#define irqs_disabled() \
+({ \
+ unsigned long flags; \
+ local_save_flags(flags); \
+ flags & PSR_I_BIT; \
+})
+
#define save_flags(x) local_save_flags(x)
#define restore_flags(x) local_irq_restore(x)
#define save_flags_cli(x) local_irq_save(x)
diff -urN linux-2.4.26/include/asm-arm/termios.h linux-2.4.26-vrs1/include/asm-arm/termios.h
--- linux-2.4.26/include/asm-arm/termios.h 2001-06-12 03:15:27.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/termios.h 2004-01-14 21:32:29.000000000 +0000
@@ -47,6 +47,8 @@
#define TIOCM_OUT2 0x4000
#define TIOCM_LOOP 0x8000
+#define TIOCM_MODEM_BITS TIOCM_OUT2 /* IRDA support */
+
/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
/* line disciplines */
diff -urN linux-2.4.26/include/asm-arm/uaccess.h linux-2.4.26-vrs1/include/asm-arm/uaccess.h
--- linux-2.4.26/include/asm-arm/uaccess.h 2001-10-25 21:53:55.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/uaccess.h 2004-04-19 20:37:56.000000000 +0100
@@ -74,14 +74,14 @@
__asm__ __volatile__ ("bl __get_user_" #__s \
: "=&r" (__e), "=r" (__r1) \
: "0" (__p) \
- : __i)
+ : __i, "cc")
#define get_user(x,p) \
({ \
const register typeof(*(p)) *__p asm("r0") = (p); \
register typeof(*(p)) __r1 asm("r1"); \
register int __e asm("r0"); \
- switch (sizeof(*(p))) { \
+ switch (sizeof(*(__p))) { \
case 1: \
__get_user_x(__r1, __p, __e, 1, "lr"); \
break; \
@@ -100,8 +100,31 @@
__e; \
})
-#define __get_user(x,p) __get_user_nocheck((x),(p),sizeof(*(p)))
-#define __get_user_error(x,p,e) __get_user_nocheck_error((x),(p),sizeof(*(p)),(e))
+#define __get_user(x,ptr) \
+({ \
+ long __gu_err = 0; \
+ __get_user_err((x),(ptr),__gu_err); \
+ __gu_err; \
+})
+
+#define __get_user_error(x,ptr,err) \
+({ \
+ __get_user_err((x),(ptr),err); \
+ (void) 0; \
+})
+
+#define __get_user_err(x,ptr,err) \
+do { \
+ unsigned long __gu_addr = (unsigned long)(ptr); \
+ unsigned long __gu_val; \
+ switch (sizeof(*(ptr))) { \
+ case 1: __get_user_asm_byte(__gu_val,__gu_addr,err); break; \
+ case 2: __get_user_asm_half(__gu_val,__gu_addr,err); break; \
+ case 4: __get_user_asm_word(__gu_val,__gu_addr,err); break; \
+ default: (__gu_val) = __get_user_bad(); \
+ } \
+ (x) = (__typeof__(*(ptr)))__gu_val; \
+} while (0)
extern int __put_user_1(void *, unsigned int);
extern int __put_user_2(void *, unsigned int);
@@ -113,22 +136,22 @@
__asm__ __volatile__ ("bl __put_user_" #__s \
: "=&r" (__e) \
: "0" (__p), "r" (__r1) \
- : __i)
+ : __i, "cc")
#define put_user(x,p) \
({ \
const register typeof(*(p)) __r1 asm("r1") = (x); \
const register typeof(*(p)) *__p asm("r0") = (p); \
register int __e asm("r0"); \
- switch (sizeof(*(p))) { \
+ switch (sizeof(*(__p))) { \
case 1: \
- __put_user_x(__r1, __p, __e, 1, "r2", "lr"); \
+ __put_user_x(__r1, __p, __e, 1, "ip", "lr"); \
break; \
case 2: \
- __put_user_x(__r1, __p, __e, 2, "r2", "lr"); \
+ __put_user_x(__r1, __p, __e, 2, "ip", "lr"); \
break; \
case 4: \
- __put_user_x(__r1, __p, __e, 4, "r2", "lr"); \
+ __put_user_x(__r1, __p, __e, 4, "ip", "lr"); \
break; \
case 8: \
__put_user_x(__r1, __p, __e, 8, "ip", "lr"); \
@@ -138,8 +161,31 @@
__e; \
})
-#define __put_user(x,p) __put_user_nocheck((__typeof(*(p)))(x),(p),sizeof(*(p)))
-#define __put_user_error(x,p,e) __put_user_nocheck_error((x),(p),sizeof(*(p)),(e))
+#define __put_user(x,ptr) \
+({ \
+ long __pu_err = 0; \
+ __put_user_err((x),(ptr),__pu_err); \
+ __pu_err; \
+})
+
+#define __put_user_error(x,ptr,err) \
+({ \
+ __put_user_err((x),(ptr),err); \
+ (void) 0; \
+})
+
+#define __put_user_err(x,ptr,err) \
+do { \
+ unsigned long __pu_addr = (unsigned long)(ptr); \
+ __typeof__(*(ptr)) __pu_val = (x); \
+ switch (sizeof(*(ptr))) { \
+ case 1: __put_user_asm_byte(__pu_val,__pu_addr,err); break; \
+ case 2: __put_user_asm_half(__pu_val,__pu_addr,err); break; \
+ case 4: __put_user_asm_word(__pu_val,__pu_addr,err); break; \
+ case 8: __put_user_asm_dword(__pu_val,__pu_addr,err); break; \
+ default: __put_user_bad(); \
+ } \
+} while (0)
static __inline__ unsigned long copy_from_user(void *to, const void *from, unsigned long n)
{
@@ -209,82 +255,4 @@
return res;
}
-/*
- * These are the work horses of the get/put_user functions
- */
-#if 0
-#define __get_user_check(x,ptr,size) \
-({ \
- long __gu_err = -EFAULT, __gu_val = 0; \
- const __typeof__(*(ptr)) *__gu_addr = (ptr); \
- if (access_ok(VERIFY_READ,__gu_addr,size)) { \
- __gu_err = 0; \
- __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \
- } \
- (x) = (__typeof__(*(ptr)))__gu_val; \
- __gu_err; \
-})
-#endif
-
-#define __get_user_nocheck(x,ptr,size) \
-({ \
- long __gu_err = 0, __gu_val; \
- __get_user_size(__gu_val,(ptr),(size),__gu_err); \
- (x) = (__typeof__(*(ptr)))__gu_val; \
- __gu_err; \
-})
-
-#define __get_user_nocheck_error(x,ptr,size,err) \
-({ \
- long __gu_val; \
- __get_user_size(__gu_val,(ptr),(size),(err)); \
- (x) = (__typeof__(*(ptr)))__gu_val; \
- (void) 0; \
-})
-
-#define __put_user_check(x,ptr,size) \
-({ \
- long __pu_err = -EFAULT; \
- __typeof__(*(ptr)) *__pu_addr = (ptr); \
- if (access_ok(VERIFY_WRITE,__pu_addr,size)) { \
- __pu_err = 0; \
- __put_user_size((x),__pu_addr,(size),__pu_err); \
- } \
- __pu_err; \
-})
-
-#define __put_user_nocheck(x,ptr,size) \
-({ \
- long __pu_err = 0; \
- __typeof__(*(ptr)) *__pu_addr = (ptr); \
- __put_user_size((x),__pu_addr,(size),__pu_err); \
- __pu_err; \
-})
-
-#define __put_user_nocheck_error(x,ptr,size,err) \
-({ \
- __put_user_size((x),(ptr),(size),err); \
- (void) 0; \
-})
-
-#define __get_user_size(x,ptr,size,retval) \
-do { \
- switch (size) { \
- case 1: __get_user_asm_byte(x,ptr,retval); break; \
- case 2: __get_user_asm_half(x,ptr,retval); break; \
- case 4: __get_user_asm_word(x,ptr,retval); break; \
- default: (x) = __get_user_bad(); \
- } \
-} while (0)
-
-#define __put_user_size(x,ptr,size,retval) \
-do { \
- switch (size) { \
- case 1: __put_user_asm_byte(x,ptr,retval); break; \
- case 2: __put_user_asm_half(x,ptr,retval); break; \
- case 4: __put_user_asm_word(x,ptr,retval); break; \
- default: __put_user_bad(); \
- } \
-} while (0)
-
#endif /* _ASMARM_UACCESS_H */
diff -urN linux-2.4.26/include/asm-arm/unistd.h linux-2.4.26-vrs1/include/asm-arm/unistd.h
--- linux-2.4.26/include/asm-arm/unistd.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-arm/unistd.h 2004-03-05 15:14:07.000000000 +0000
@@ -31,7 +31,7 @@
#define __NR_write (__NR_SYSCALL_BASE+ 4)
#define __NR_open (__NR_SYSCALL_BASE+ 5)
#define __NR_close (__NR_SYSCALL_BASE+ 6)
-#define __NR_waitpid (__NR_SYSCALL_BASE+ 7)
+ /* 7 was sys_waitpid */
#define __NR_creat (__NR_SYSCALL_BASE+ 8)
#define __NR_link (__NR_SYSCALL_BASE+ 9)
#define __NR_unlink (__NR_SYSCALL_BASE+ 10)
@@ -41,8 +41,8 @@
#define __NR_mknod (__NR_SYSCALL_BASE+ 14)
#define __NR_chmod (__NR_SYSCALL_BASE+ 15)
#define __NR_lchown (__NR_SYSCALL_BASE+ 16)
-#define __NR_break (__NR_SYSCALL_BASE+ 17)
-
+ /* 17 was sys_break */
+ /* 18 was sys_stat */
#define __NR_lseek (__NR_SYSCALL_BASE+ 19)
#define __NR_getpid (__NR_SYSCALL_BASE+ 20)
#define __NR_mount (__NR_SYSCALL_BASE+ 21)
@@ -52,14 +52,14 @@
#define __NR_stime (__NR_SYSCALL_BASE+ 25)
#define __NR_ptrace (__NR_SYSCALL_BASE+ 26)
#define __NR_alarm (__NR_SYSCALL_BASE+ 27)
-
+ /* 28 was sys_fstat */
#define __NR_pause (__NR_SYSCALL_BASE+ 29)
#define __NR_utime (__NR_SYSCALL_BASE+ 30)
-#define __NR_stty (__NR_SYSCALL_BASE+ 31)
-#define __NR_gtty (__NR_SYSCALL_BASE+ 32)
+ /* 31 was sys_stty */
+ /* 32 was sys_gtty */
#define __NR_access (__NR_SYSCALL_BASE+ 33)
#define __NR_nice (__NR_SYSCALL_BASE+ 34)
-#define __NR_ftime (__NR_SYSCALL_BASE+ 35)
+ /* 35 was sys_ftime */
#define __NR_sync (__NR_SYSCALL_BASE+ 36)
#define __NR_kill (__NR_SYSCALL_BASE+ 37)
#define __NR_rename (__NR_SYSCALL_BASE+ 38)
@@ -68,22 +68,23 @@
#define __NR_dup (__NR_SYSCALL_BASE+ 41)
#define __NR_pipe (__NR_SYSCALL_BASE+ 42)
#define __NR_times (__NR_SYSCALL_BASE+ 43)
-#define __NR_prof (__NR_SYSCALL_BASE+ 44)
+ /* 44 was sys_prof */
#define __NR_brk (__NR_SYSCALL_BASE+ 45)
#define __NR_setgid (__NR_SYSCALL_BASE+ 46)
#define __NR_getgid (__NR_SYSCALL_BASE+ 47)
-#define __NR_signal (__NR_SYSCALL_BASE+ 48)
+ /* 48 was sys_signal */
#define __NR_geteuid (__NR_SYSCALL_BASE+ 49)
#define __NR_getegid (__NR_SYSCALL_BASE+ 50)
#define __NR_acct (__NR_SYSCALL_BASE+ 51)
#define __NR_umount2 (__NR_SYSCALL_BASE+ 52)
-#define __NR_lock (__NR_SYSCALL_BASE+ 53)
+ /* 53 was sys_lock */
#define __NR_ioctl (__NR_SYSCALL_BASE+ 54)
#define __NR_fcntl (__NR_SYSCALL_BASE+ 55)
-#define __NR_mpx (__NR_SYSCALL_BASE+ 56)
+ /* 56 was sys_mpx */
#define __NR_setpgid (__NR_SYSCALL_BASE+ 57)
#define __NR_ulimit (__NR_SYSCALL_BASE+ 58)
-
+ /* 58 was sys_ulimit */
+ /* 59 was sys_olduname */
#define __NR_umask (__NR_SYSCALL_BASE+ 60)
#define __NR_chroot (__NR_SYSCALL_BASE+ 61)
#define __NR_ustat (__NR_SYSCALL_BASE+ 62)
@@ -92,8 +93,8 @@
#define __NR_getpgrp (__NR_SYSCALL_BASE+ 65)
#define __NR_setsid (__NR_SYSCALL_BASE+ 66)
#define __NR_sigaction (__NR_SYSCALL_BASE+ 67)
-#define __NR_sgetmask (__NR_SYSCALL_BASE+ 68)
-#define __NR_ssetmask (__NR_SYSCALL_BASE+ 69)
+ /* 68 was sys_sgetmask */
+ /* 69 was sys_ssetmask */
#define __NR_setreuid (__NR_SYSCALL_BASE+ 70)
#define __NR_setregid (__NR_SYSCALL_BASE+ 71)
#define __NR_sigsuspend (__NR_SYSCALL_BASE+ 72)
@@ -108,7 +109,7 @@
#define __NR_setgroups (__NR_SYSCALL_BASE+ 81)
#define __NR_select (__NR_SYSCALL_BASE+ 82)
#define __NR_symlink (__NR_SYSCALL_BASE+ 83)
-
+ /* 84 was sys_lstat */
#define __NR_readlink (__NR_SYSCALL_BASE+ 85)
#define __NR_uselib (__NR_SYSCALL_BASE+ 86)
#define __NR_swapon (__NR_SYSCALL_BASE+ 87)
@@ -122,10 +123,10 @@
#define __NR_fchown (__NR_SYSCALL_BASE+ 95)
#define __NR_getpriority (__NR_SYSCALL_BASE+ 96)
#define __NR_setpriority (__NR_SYSCALL_BASE+ 97)
-#define __NR_profil (__NR_SYSCALL_BASE+ 98)
+ /* 98 was sys_profil */
#define __NR_statfs (__NR_SYSCALL_BASE+ 99)
#define __NR_fstatfs (__NR_SYSCALL_BASE+100)
-#define __NR_ioperm (__NR_SYSCALL_BASE+101)
+ /* 101 was sys_ioperm */
#define __NR_socketcall (__NR_SYSCALL_BASE+102)
#define __NR_syslog (__NR_SYSCALL_BASE+103)
#define __NR_setitimer (__NR_SYSCALL_BASE+104)
@@ -133,10 +134,10 @@
#define __NR_stat (__NR_SYSCALL_BASE+106)
#define __NR_lstat (__NR_SYSCALL_BASE+107)
#define __NR_fstat (__NR_SYSCALL_BASE+108)
-
-
+ /* 109 was sys_uname */
+ /* 110 was sys_iopl */
#define __NR_vhangup (__NR_SYSCALL_BASE+111)
-#define __NR_idle (__NR_SYSCALL_BASE+112)
+ /* 112 was sys_idle */
#define __NR_syscall (__NR_SYSCALL_BASE+113) /* syscall to call a syscall! */
#define __NR_wait4 (__NR_SYSCALL_BASE+114)
#define __NR_swapoff (__NR_SYSCALL_BASE+115)
@@ -147,7 +148,7 @@
#define __NR_clone (__NR_SYSCALL_BASE+120)
#define __NR_setdomainname (__NR_SYSCALL_BASE+121)
#define __NR_uname (__NR_SYSCALL_BASE+122)
-#define __NR_modify_ldt (__NR_SYSCALL_BASE+123)
+ /* 123 was sys_modify_ldt */
#define __NR_adjtimex (__NR_SYSCALL_BASE+124)
#define __NR_mprotect (__NR_SYSCALL_BASE+125)
#define __NR_sigprocmask (__NR_SYSCALL_BASE+126)
@@ -161,7 +162,7 @@
#define __NR_bdflush (__NR_SYSCALL_BASE+134)
#define __NR_sysfs (__NR_SYSCALL_BASE+135)
#define __NR_personality (__NR_SYSCALL_BASE+136)
-#define __NR_afs_syscall (__NR_SYSCALL_BASE+137) /* Syscall for Andrew File System */
+ /* 137 was sys_afs_syscall */
#define __NR_setfsuid (__NR_SYSCALL_BASE+138)
#define __NR_setfsgid (__NR_SYSCALL_BASE+139)
#define __NR__llseek (__NR_SYSCALL_BASE+140)
@@ -190,7 +191,7 @@
#define __NR_mremap (__NR_SYSCALL_BASE+163)
#define __NR_setresuid (__NR_SYSCALL_BASE+164)
#define __NR_getresuid (__NR_SYSCALL_BASE+165)
-#define __NR_vm86 (__NR_SYSCALL_BASE+166)
+ /* 166 was sys_vm86 */
#define __NR_query_module (__NR_SYSCALL_BASE+167)
#define __NR_poll (__NR_SYSCALL_BASE+168)
#define __NR_nfsservctl (__NR_SYSCALL_BASE+169)
diff -urN linux-2.4.26/include/asm-i386/ide.h linux-2.4.26-vrs1/include/asm-i386/ide.h
--- linux-2.4.26/include/asm-i386/ide.h 2003-06-13 15:51:38.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-i386/ide.h 2004-01-14 21:32:29.000000000 +0000
@@ -23,39 +23,15 @@
# endif
#endif
-static __inline__ int ide_default_irq(ide_ioreg_t base)
-{
- switch (base) {
- case 0x1f0: return 14;
- case 0x170: return 15;
- case 0x1e8: return 11;
- case 0x168: return 10;
- case 0x1e0: return 8;
- case 0x160: return 12;
- default:
- return 0;
- }
-}
-
-static __inline__ ide_ioreg_t ide_default_io_base(int index)
-{
- switch (index) {
- case 0: return 0x1f0;
- case 1: return 0x170;
- case 2: return 0x1e8;
- case 3: return 0x168;
- case 4: return 0x1e0;
- case 5: return 0x160;
- default:
- return 0;
- }
-}
+#define ide_default_io_base(i) ((ide_ioreg_t)0)
+#define ide_default_irq(b) (0)
static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
{
ide_ioreg_t reg = data_port;
int i;
+ memset(hw, 0, sizeof(*hw));
for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
hw->io_ports[i] = reg;
reg += 1;
@@ -63,7 +39,7 @@
if (ctrl_port) {
hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
} else {
- hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206;
+ hw->io_ports[IDE_CONTROL_OFFSET] = data_port + 0x206;
}
if (irq != NULL)
*irq = 0;
@@ -74,14 +50,25 @@
{
#ifndef CONFIG_BLK_DEV_IDEPCI
hw_regs_t hw;
- int index;
- for(index = 0; index < MAX_HWIFS; index++) {
- memset(&hw, 0, sizeof hw);
- ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
- hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
- }
+ ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
+ hw.irq = 14;
+ ide_register_hw(&hw, NULL);
+ ide_init_hwif_ports(&hw, 0x170, 0x376, NULL);
+ hw.irq = 15;
+ ide_register_hw(&hw, NULL);
+ ide_init_hwif_ports(&hw, 0x1e8, 0x3ee, NULL);
+ hw.irq = 11;
+ ide_register_hw(&hw, NULL);
+ ide_init_hwif_ports(&hw, 0x168, 0x36e, NULL);
+ hw.irq = 10;
+ ide_register_hw(&hw, NULL);
+ ide_init_hwif_ports(&hw, 0x1e0, 0x3e6, NULL);
+ hw.irq = 8;
+ ide_register_hw(&hw, NULL);
+ ide_init_hwif_ports(&hw, 0x160, 0x366, NULL);
+ hw.irq = 12;
+ ide_register_hw(&hw, NULL);
#endif /* CONFIG_BLK_DEV_IDEPCI */
}
diff -urN linux-2.4.26/include/asm-i386/param.h linux-2.4.26-vrs1/include/asm-i386/param.h
--- linux-2.4.26/include/asm-i386/param.h 2000-10-27 19:04:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-i386/param.h 2004-01-14 21:32:29.000000000 +0000
@@ -3,6 +3,16 @@
#ifndef HZ
#define HZ 100
+#ifdef __KERNEL__
+#if HZ == 100
+/* X86 is defined to provide userspace with a world where HZ=100
+ We have to do this, (x*const)/const2 isnt optimised out because its not
+ a null operation as it might overflow.. */
+#define hz_to_std(a) (a)
+#else
+#define hz_to_std(a) ((a)*(100/HZ)+((a)*(100%HZ))/HZ)
+#endif
+#endif
#endif
#define EXEC_PAGESIZE 4096
diff -urN linux-2.4.26/include/asm-i386/pgtable.h linux-2.4.26-vrs1/include/asm-i386/pgtable.h
--- linux-2.4.26/include/asm-i386/pgtable.h 2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-i386/pgtable.h 2004-01-14 21:32:29.000000000 +0000
@@ -361,7 +361,6 @@
#endif /* !__ASSEMBLY__ */
/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
-#define PageSkip(page) (0)
#define kern_addr_valid(addr) (1)
#define io_remap_page_range remap_page_range
diff -urN linux-2.4.26/include/asm-ia64/param.h linux-2.4.26-vrs1/include/asm-ia64/param.h
--- linux-2.4.26/include/asm-ia64/param.h 2004-04-19 11:44:28.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-ia64/param.h 2004-04-18 21:47:52.000000000 +0100
@@ -4,12 +4,14 @@
/*
* Fundamental kernel parameters.
*
- * Based on <asm-i386/param.h>.
- *
- * Modified 1998, 1999, 2002-2003
- * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
+ * Copyright (C) 1998, 1999, 2002-2003 Hewlett-Packard Co
+ * David Mosberger-Tang <davidm@hpl.hp.com>
*/
+#ifdef __KERNEL__
+#define hz_to_std(a) (a)
+#endif
+
#define EXEC_PAGESIZE 65536
#ifndef NGROUPS
diff -urN linux-2.4.26/include/asm-m68k/param.h linux-2.4.26-vrs1/include/asm-m68k/param.h
--- linux-2.4.26/include/asm-m68k/param.h 2001-01-04 21:00:55.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-m68k/param.h 2004-01-14 21:32:30.000000000 +0000
@@ -3,6 +3,9 @@
#ifndef HZ
#define HZ 100
+#ifdef __KERNEL__
+#define hz_to_std(a) (a)
+#endif
#endif
#define EXEC_PAGESIZE 8192
diff -urN linux-2.4.26/include/asm-mips/ide.h linux-2.4.26-vrs1/include/asm-mips/ide.h
--- linux-2.4.26/include/asm-mips/ide.h 2003-08-25 12:44:43.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-mips/ide.h 2004-01-14 21:39:23.000000000 +0000
@@ -27,7 +27,7 @@
int (*ide_default_irq)(ide_ioreg_t base);
ide_ioreg_t (*ide_default_io_base)(int index);
void (*ide_init_hwif_ports)(hw_regs_t *hw, ide_ioreg_t data_port,
- ide_ioreg_t ctrl_port, int *irq);
+ ide_ioreg_t ctrl_port, int *irq);
};
extern struct ide_ops *ide_ops;
diff -urN linux-2.4.26/include/asm-ppc/param.h linux-2.4.26-vrs1/include/asm-ppc/param.h
--- linux-2.4.26/include/asm-ppc/param.h 2003-06-13 15:51:38.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-ppc/param.h 2004-01-14 21:32:30.000000000 +0000
@@ -3,6 +3,9 @@
#ifndef HZ
#define HZ 100
+#ifdef __KERNEL__
+#define hz_to_std(a) (a)
+#endif
#endif
#define EXEC_PAGESIZE 4096
diff -urN linux-2.4.26/include/asm-s390/param.h linux-2.4.26-vrs1/include/asm-s390/param.h
--- linux-2.4.26/include/asm-s390/param.h 2001-02-13 22:13:44.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-s390/param.h 2004-01-14 21:32:30.000000000 +0000
@@ -11,6 +11,9 @@
#ifndef HZ
#define HZ 100
+#ifdef __KERNEL__
+#define hz_to_std(a) (a)
+#endif
#endif
#define EXEC_PAGESIZE 4096
diff -urN linux-2.4.26/include/asm-sh/param.h linux-2.4.26-vrs1/include/asm-sh/param.h
--- linux-2.4.26/include/asm-sh/param.h 2001-01-04 21:19:13.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-sh/param.h 2004-01-14 21:32:30.000000000 +0000
@@ -3,6 +3,9 @@
#ifndef HZ
#define HZ 100
+#ifdef __KERNEL__
+#define hz_to_std(a) (a)
+#endif
#endif
#define EXEC_PAGESIZE 4096
diff -urN linux-2.4.26/include/asm-sparc/param.h linux-2.4.26-vrs1/include/asm-sparc/param.h
--- linux-2.4.26/include/asm-sparc/param.h 2000-10-30 22:34:12.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-sparc/param.h 2004-01-14 21:32:30.000000000 +0000
@@ -4,6 +4,9 @@
#ifndef HZ
#define HZ 100
+#ifdef __KERNEL__
+#define hz_to_std(a) (a)
+#endif
#endif
#define EXEC_PAGESIZE 8192 /* Thanks for sun4's we carry baggage... */
diff -urN linux-2.4.26/include/asm-sparc64/ide.h linux-2.4.26-vrs1/include/asm-sparc64/ide.h
--- linux-2.4.26/include/asm-sparc64/ide.h 2003-06-13 15:51:38.000000000 +0100
+++ linux-2.4.26-vrs1/include/asm-sparc64/ide.h 2004-01-14 21:32:30.000000000 +0000
@@ -25,21 +25,12 @@
# endif
#endif
-static __inline__ int ide_default_irq(ide_ioreg_t base)
-{
- return 0;
-}
-
-static __inline__ ide_ioreg_t ide_default_io_base(int index)
-{
- return 0;
-}
-
static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
{
- ide_ioreg_t reg = data_port;
+ ide_ioreg_t reg = data_port;
int i;
+ memset(&hw, 0, sizeof(hw));
for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
hw->io_ports[i] = reg;
reg += 1;
@@ -60,16 +51,6 @@
*/
static __inline__ void ide_init_default_hwifs(void)
{
-#ifndef CONFIG_BLK_DEV_IDEPCI
- hw_regs_t hw;
- int index;
-
- for (index = 0; index < MAX_HWIFS; index++) {
- ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
- hw.irq = ide_default_irq(ide_default_io_base(index));
- ide_register_hw(&hw, NULL);
- }
-#endif /* CONFIG_BLK_DEV_IDEPCI */
}
#undef SUPPORT_SLOW_DATA_PORTS
diff -urN linux-2.4.26/include/asm-sparc64/param.h linux-2.4.26-vrs1/include/asm-sparc64/param.h
--- linux-2.4.26/include/asm-sparc64/param.h 2000-10-30 22:34:12.000000000 +0000
+++ linux-2.4.26-vrs1/include/asm-sparc64/param.h 2004-01-14 21:32:30.000000000 +0000
@@ -4,6 +4,9 @@
#ifndef HZ
#define HZ 100
+#ifdef __KERNEL__
+#define hz_to_std(a) (a)
+#endif
#endif
#define EXEC_PAGESIZE 8192 /* Thanks for sun4's we carry baggage... */
diff -urN linux-2.4.26/include/linux/console_struct.h linux-2.4.26-vrs1/include/linux/console_struct.h
--- linux-2.4.26/include/linux/console_struct.h 2003-06-13 15:51:38.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/console_struct.h 2004-01-14 21:32:30.000000000 +0000
@@ -7,6 +7,8 @@
* Fields marked with [#] must be set by the low-level driver.
* Fields marked with [!] can be changed by the low-level driver
* to achieve effects such as fast scrolling by changing the origin.
+ *
+ * 11/07/1998 RMK Changed vc_state to be a function pointer
*/
#ifndef _LINUX_CONSOLE_STRUCT_H_
@@ -34,7 +36,11 @@
unsigned short vc_s_complement_mask; /* Saved mouse pointer mask */
unsigned int vc_x, vc_y; /* Cursor position */
unsigned int vc_top, vc_bottom; /* Scrolling region */
+#ifdef CONSOLE_WIP
+ int (*vc_state)(int currcons, struct tty_struct *tty, unsigned int c);
+#else
unsigned int vc_state; /* Escape sequence parser state */
+#endif
unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */
unsigned long vc_origin; /* [!] Start of real screen */
unsigned long vc_scr_end; /* [!] End of real screen */
diff -urN linux-2.4.26/include/linux/cpufreq.h linux-2.4.26-vrs1/include/linux/cpufreq.h
--- linux-2.4.26/include/linux/cpufreq.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/cpufreq.h 2004-01-14 21:32:30.000000000 +0000
@@ -0,0 +1,94 @@
+/*
+ * linux/include/linux/cpufreq.h
+ *
+ * Copyright (C) 2001 Russell King
+ *
+ * $Id: cpufreq.h,v 1.5.2.1 2002/05/03 13:26:27 rmk Exp $
+ *
+ * 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.
+ */
+#ifndef _LINUX_CPUFREQ_H
+#define _LINUX_CPUFREQ_H
+
+#include <linux/config.h>
+#include <linux/notifier.h>
+
+#ifndef CONFIG_SMP
+#define cpufreq_current(cpu) ((void)(cpu), __cpufreq_cur)
+#define cpufreq_max(cpu) ((void)(cpu), __cpufreq_max)
+#define cpufreq_min(cpu) ((void)(cpu), __cpufreq_min)
+#else
+/*
+ * Should be something like:
+ *
+ * typedef struct {
+ * u_int current;
+ * u_int max;
+ * u_int min;
+ * } __cacheline_aligned cpufreq_info_t;
+ *
+ * static cpufreq_info_t cpufreq_info;
+ *
+ * #define cpufreq_current(cpu) (cpufreq_info[cpu].current)
+ * #define cpufreq_max(cpu) (cpufreq_info[cpu].max)
+ * #define cpufreq_min(cpu) (cpufreq_info[cpu].min)
+ *
+ * Maybe we should find some other per-cpu structure to
+ * bury this in?
+ */
+#error fill in SMP version
+#endif
+
+struct cpufreq_info {
+ unsigned int old_freq;
+ unsigned int new_freq;
+};
+
+/*
+ * The max and min frequency rates that the registered device
+ * can tolerate. Never set any element this structure directly -
+ * always use cpu_updateminmax.
+ */
+struct cpufreq_minmax {
+ unsigned int min_freq;
+ unsigned int max_freq;
+ unsigned int cur_freq;
+ unsigned int new_freq;
+};
+
+static inline
+void cpufreq_updateminmax(void *arg, unsigned int min, unsigned int max)
+{
+ struct cpufreq_minmax *minmax = arg;
+
+ if (minmax->min_freq < min)
+ minmax->min_freq = min;
+ if (minmax->max_freq > max)
+ minmax->max_freq = max;
+}
+
+#define CPUFREQ_MINMAX (0)
+#define CPUFREQ_PRECHANGE (1)
+#define CPUFREQ_POSTCHANGE (2)
+
+int cpufreq_register_notifier(struct notifier_block *nb);
+int cpufreq_unregister_notifier(struct notifier_block *nb);
+
+int cpufreq_setmax(void);
+int cpufreq_restore(void);
+int cpufreq_set(unsigned int khz);
+unsigned int cpufreq_get(int cpu);
+
+/*
+ * These two functions are only available at init time.
+ */
+void cpufreq_init(unsigned int khz,
+ unsigned int min_freq,
+ unsigned int max_freq);
+
+void cpufreq_setfunctions(unsigned int (*validate)(unsigned int),
+ void (*setspeed)(unsigned int));
+
+#endif
diff -urN linux-2.4.26/include/linux/i2c-id.h linux-2.4.26-vrs1/include/linux/i2c-id.h
--- linux-2.4.26/include/linux/i2c-id.h 2004-02-27 20:03:29.000000000 +0000
+++ linux-2.4.26-vrs1/include/linux/i2c-id.h 2004-02-27 22:47:10.000000000 +0000
@@ -20,16 +20,16 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* ------------------------------------------------------------------------- */
-/* $Id: i2c-id.h,v 1.35 2001/08/12 17:22:20 mds Exp $ */
+/* $Id: i2c-id.h,v 1.52 2002/07/10 13:28:44 abz Exp $ */
#ifndef I2C_ID_H
#define I2C_ID_H
/*
* This file is part of the i2c-bus package and contains the identifier
* values for drivers, adapters and other folk populating these serial
- * worlds.
+ * worlds.
*
- * These will change often (i.e. additions) , therefore this has been
+ * These will change often (i.e. additions) , therefore this has been
* separated from the functional interface definitions of the i2c api.
*
*/
@@ -38,10 +38,10 @@
* ---- Driver types -----------------------------------------------------
* device id name + number function description, i2c address(es)
*
- * Range 1000-1999 range is defined in sensors/sensors.h
- * Range 0x100 - 0x1ff is for V4L2 Common Components
+ * Range 1000-1999 range is defined in sensors/sensors.h
+ * Range 0x100 - 0x1ff is for V4L2 Common Components
* Range 0xf000 - 0xffff is reserved for local experimentation, and should
- * never be used in official drivers
+ * never be used in official drivers
*/
#define I2C_DRIVERID_MSP3400 1
@@ -90,7 +90,12 @@
#define I2C_DRIVERID_DRP3510 43 /* ADR decoder (Astra Radio) */
#define I2C_DRIVERID_SP5055 44 /* Satellite tuner */
#define I2C_DRIVERID_STV0030 45 /* Multipurpose switch */
+#define I2C_DRIVERID_SAA7108 46 /* video decoder, image scaler */
+#define I2C_DRIVERID_DS1307 47 /* DS1307 real time clock */
#define I2C_DRIVERID_ADV7175 48 /* ADV 7175/7176 video encoder */
+#define I2C_DRIVERID_ZR36067 49 /* Zoran 36067 video encoder */
+#define I2C_DRIVERID_ZR36120 50 /* Zoran 36120 video encoder */
+#define I2C_DRIVERID_24LC32A 51 /* Microchip 24LC32A 32k EEPROM */
#define I2C_DRIVERID_MAX1617 56 /* temp sensor */
#define I2C_DRIVERID_SAA7191 57 /* video decoder */
#define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */
@@ -102,8 +107,10 @@
#define I2C_DRIVERID_I2CDEV 900
#define I2C_DRIVERID_I2CPROC 901
+#define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */
+#define I2C_DRIVERID_ALERT 903 /* SMBus Alert Responder Client */
-/* IDs -- Use DRIVERIDs 1000-1999 for sensors.
+/* IDs -- Use DRIVERIDs 1000-1999 for sensors.
These were originally in sensors.h in the lm_sensors package */
#define I2C_DRIVERID_LM78 1002
#define I2C_DRIVERID_LM75 1003
@@ -131,6 +138,12 @@
#define I2C_DRIVERID_ADM1024 1025
#define I2C_DRIVERID_IT87 1026
#define I2C_DRIVERID_CH700X 1027 /* single driver for CH7003-7009 digital pc to tv encoders */
+#define I2C_DRIVERID_FSCPOS 1028
+#define I2C_DRIVERID_FSCSCY 1029
+#define I2C_DRIVERID_PCF8591 1030
+#define I2C_DRIVERID_SMSC47M1 1031
+#define I2C_DRIVERID_VT1211 1032
+#define I2C_DRIVERID_LM92 1033
/*
* ---- Adapter types ----------------------------------------------------
@@ -147,7 +160,8 @@
#define I2C_ALGO_ISA 0x050000 /* lm_sensors ISA pseudo-adapter */
#define I2C_ALGO_SAA7146 0x060000 /* SAA 7146 video decoder bus */
#define I2C_ALGO_ACB 0x070000 /* ACCESS.bus algorithm */
-
+#define I2C_ALGO_IIC 0x080000 /* ITE IIC bus */
+#define I2C_ALGO_SAA7134 0x090000
#define I2C_ALGO_EC 0x100000 /* ACPI embedded controller */
#define I2C_ALGO_MPC8XX 0x110000 /* MPC8xx PowerPC I2C algorithm */
@@ -156,13 +170,15 @@
#define I2C_ALGO_SGI 0x130000 /* SGI algorithm */
+#define I2C_ALGO_OCP 0x120000 /* IBM or otherwise On-chip I2C algorithm */
+
#define I2C_ALGO_EXP 0x800000 /* experimental */
#define I2C_ALGO_MASK 0xff0000 /* Mask for algorithms */
#define I2C_ALGO_SHIFT 0x10 /* right shift to get index values */
#define I2C_HW_ADAPS 0x10000 /* # adapter types */
-#define I2C_HW_MASK 0xffff
+#define I2C_HW_MASK 0xffff
/* hw specific modules that are defined per algorithm layer
@@ -182,9 +198,13 @@
#define I2C_HW_B_I810 0x0a /* Intel I810 */
#define I2C_HW_B_VOO 0x0b /* 3dfx Voodoo 3 / Banshee */
#define I2C_HW_B_PPORT 0x0c /* Primitive parallel port adapter */
+#define I2C_HW_B_SAVG 0x0d /* Savage 4 */
#define I2C_HW_B_RIVA 0x10 /* Riva based graphics cards */
#define I2C_HW_B_IOC 0x11 /* IOC bit-wiggling */
#define I2C_HW_B_TSUNA 0x12 /* DEC Tsunami chipset */
+#define I2C_HW_B_FRODO 0x13 /* 2d3D, Inc. SA-1110 Development Board */
+#define I2C_HW_B_OMAHA 0x14 /* Omaha I2C interface */
+#define I2C_HW_B_GUIDE 0x15 /* Guide bit-basher */
/* --- PCF 8584 based algorithms */
#define I2C_HW_P_LP 0x00 /* Parallel port interface */
@@ -197,6 +217,12 @@
/* --- MPC8xx PowerPC adapters */
#define I2C_HW_MPC8XX_EPON 0x00 /* Eponymous MPC8xx I2C adapter */
+/* --- ITE based algorithms */
+#define I2C_HW_I_IIC 0x00 /* controller on the ITE */
+
+/* --- PowerPC on-chip adapters */
+#define I2C_HW_OCP 0x00 /* IBM on-chip I2C adapter */
+
/* --- Broadcom SiByte adapters */
#define I2C_HW_SIBYTE 0x00
diff -urN linux-2.4.26/include/linux/ide.h linux-2.4.26-vrs1/include/linux/ide.h
--- linux-2.4.26/include/linux/ide.h 2004-04-19 11:44:28.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/ide.h 2004-04-19 20:38:18.000000000 +0100
@@ -287,7 +287,9 @@
* Check for an interrupt and acknowledge the interrupt status
*/
struct hwif_s;
+struct ide_drive_s;
typedef int (ide_ack_intr_t)(struct hwif_s *);
+typedef void (ide_xfer_data_t)(struct ide_drive_s *, void *, unsigned int);
#ifndef NO_DMA
#define NO_DMA 255
@@ -311,10 +313,14 @@
typedef struct hw_regs_s {
ide_ioreg_t io_ports[IDE_NR_PORTS]; /* task file registers */
int irq; /* our irq number */
- int dma; /* our dma entry */
+ int dma; /* our dma number */
ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
+ ide_xfer_data_t *ide_output_data; /* write data to i/face */
+ ide_xfer_data_t *ide_input_data; /* read data from i/face */
+ ide_xfer_data_t *atapi_output_bytes; /* write bytes to i/face */
+ ide_xfer_data_t *atapi_input_bytes; /* read bytes from i/face */
void *priv; /* interface specific data */
- hwif_chipset_t chipset;
+ hwif_chipset_t chipset;
sata_ioreg_t sata_scr[SATA_NR_PORTS];
sata_ioreg_t sata_misc[SATA_NR_PORTS];
} hw_regs_t;
diff -urN linux-2.4.26/include/linux/l3/algo-bit.h linux-2.4.26-vrs1/include/linux/l3/algo-bit.h
--- linux-2.4.26/include/linux/l3/algo-bit.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/l3/algo-bit.h 2004-01-14 21:32:30.000000000 +0000
@@ -0,0 +1,39 @@
+/*
+ * linux/include/linux/l3/algo-bit.h
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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.
+ *
+ * L3 Bus bit-banging algorithm. Derived from i2c-algo-bit.h by
+ * Simon G. Vogl.
+ */
+#ifndef L3_ALGO_BIT_H
+#define L3_ALGO_BIT_H 1
+
+#include <linux/l3/l3.h>
+
+struct l3_algo_bit_data {
+ void (*setdat) (void *data, int state);
+ void (*setclk) (void *data, int state);
+ void (*setmode)(void *data, int state);
+ void (*setdir) (void *data, int in); /* set data direction */
+ int (*getdat) (void *data);
+
+ void *data;
+
+ /* bus timings (us) */
+ int data_hold;
+ int data_setup;
+ int clock_high;
+ int mode_hold;
+ int mode_setup;
+ int mode;
+};
+
+int l3_bit_add_bus(struct l3_adapter *);
+int l3_bit_del_bus(struct l3_adapter *);
+
+#endif
diff -urN linux-2.4.26/include/linux/l3/l3.h linux-2.4.26-vrs1/include/linux/l3/l3.h
--- linux-2.4.26/include/linux/l3/l3.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/l3/l3.h 2004-04-19 20:42:23.000000000 +0100
@@ -0,0 +1,208 @@
+/*
+ * linux/include/linux/l3/l3.h
+ *
+ * Copyright (C) 2001 Russell King, All Rights Reserved.
+ *
+ * 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.
+ *
+ * Derived from i2c.h by Simon G. Vogl
+ */
+#ifndef L3_H
+#define L3_H
+
+struct l3_msg {
+ unsigned char addr; /* slave address */
+ unsigned char flags;
+#define L3_M_RD 0x01
+#define L3_M_NOADDR 0x02
+ unsigned short len; /* msg length */
+ unsigned char *buf; /* pointer to msg data */
+};
+
+#ifdef __KERNEL__
+
+#include <linux/types.h>
+#include <linux/list.h>
+
+struct l3_client;
+
+struct l3_ops {
+ int (*open)(struct l3_client *);
+ int (*command)(struct l3_client *, int cmd, void *arg);
+ void (*close)(struct l3_client *);
+};
+
+/*
+ * A driver is capable of handling one or more physical devices present on
+ * L3 adapters. This information is used to inform the driver of adapter
+ * events.
+ */
+struct l3_driver {
+ /*
+ * This name is used to uniquely identify the driver.
+ * It should be the same as the module name.
+ */
+ char name[32];
+
+ /*
+ * Notifies the driver that a new client wishes to use its
+ * services. Note that the module use count will be increased
+ * prior to this function being called. In addition, the
+ * clients driver and adapter fields will have been setup.
+ */
+ int (*attach_client)(struct l3_client *);
+
+ /*
+ * Notifies the driver that the client has finished with its
+ * services, and any memory that it allocated for this client
+ * should be cleaned up. In addition the chip should be
+ * shut down.
+ */
+ void (*detach_client)(struct l3_client *);
+
+ /*
+ * Possible operations on the driver.
+ */
+ struct l3_ops *ops;
+
+ /*
+ * Module structure, if any.
+ */
+ struct module *owner;
+
+ /*
+ * drivers list
+ */
+ struct list_head drivers;
+};
+
+struct l3_adapter;
+
+struct l3_algorithm {
+ /* textual description */
+ char name[32];
+
+ /* perform bus transactions */
+ int (*xfer)(struct l3_adapter *, struct l3_msg msgs[], int num);
+};
+
+struct semaphore;
+
+/*
+ * l3_adapter is the structure used to identify a physical L3 bus along
+ * with the access algorithms necessary to access it.
+ */
+struct l3_adapter {
+ /*
+ * This name is used to uniquely identify the adapter.
+ * It should be the same as the module name.
+ */
+ char name[32];
+
+ /*
+ * the algorithm to access the bus
+ */
+ struct l3_algorithm *algo;
+
+ /*
+ * Algorithm specific data
+ */
+ void *algo_data;
+
+ /*
+ * This may be NULL, or should point to the module struct
+ */
+ struct module *owner;
+
+ /*
+ * private data for the adapter
+ */
+ void *data;
+
+ /*
+ * Our lock. Unlike the i2c layer, we allow this to be used for
+ * other stuff, like the i2c layer lock. Some people implement
+ * i2c stuff using the same signals as the l3 bus.
+ */
+ struct semaphore *lock;
+
+ /*
+ * List of attached clients.
+ */
+ struct list_head clients;
+
+ /*
+ * List of all adapters.
+ */
+ struct list_head adapters;
+};
+
+/*
+ * l3_client identifies a single device (i.e. chip) that is connected to an
+ * L3 bus. The behaviour is defined by the routines of the driver. This
+ * function is mainly used for lookup & other admin. functions.
+ */
+struct l3_client {
+ struct l3_adapter *adapter; /* the adapter we sit on */
+ struct l3_driver *driver; /* and our access routines */
+ void *driver_data; /* private driver data */
+ struct list_head __adap;
+};
+
+
+extern int l3_add_adapter(struct l3_adapter *);
+extern int l3_del_adapter(struct l3_adapter *);
+
+extern int l3_add_driver(struct l3_driver *);
+extern int l3_del_driver(struct l3_driver *);
+
+extern int l3_attach_client(struct l3_client *, const char *, const char *);
+extern int l3_detach_client(struct l3_client *);
+
+extern int l3_transfer(struct l3_adapter *, struct l3_msg msgs[], int);
+extern int l3_write(struct l3_client *, int, const char *, int);
+extern int l3_read(struct l3_client *, int, char *, int);
+
+/**
+ * l3_command - send a command to a L3 device driver
+ * @client: registered client structure
+ * @cmd: device driver command
+ * @arg: device driver arguments
+ *
+ * Ask the L3 device driver to perform some function. Further information
+ * should be sought from the device driver in question.
+ *
+ * Returns negative error code on failure.
+ */
+static inline int l3_command(struct l3_client *clnt, int cmd, void *arg)
+{
+ struct l3_ops *ops = clnt->driver->ops;
+ int ret = -EINVAL;
+
+ if (ops && ops->command)
+ ret = ops->command(clnt, cmd, arg);
+
+ return ret;
+}
+
+static inline int l3_open(struct l3_client *clnt)
+{
+ struct l3_ops *ops = clnt->driver->ops;
+ int ret = 0;
+
+ if (ops && ops->open)
+ ret = ops->open(clnt);
+ return ret;
+}
+
+static inline void l3_close(struct l3_client *clnt)
+{
+ struct l3_ops *ops = clnt->driver->ops;
+ if (ops && ops->close)
+ ops->close(clnt);
+}
+#endif
+
+#endif /* L3_H */
diff -urN linux-2.4.26/include/linux/l3/uda1341.h linux-2.4.26-vrs1/include/linux/l3/uda1341.h
--- linux-2.4.26/include/linux/l3/uda1341.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/l3/uda1341.h 2004-01-14 21:32:30.000000000 +0000
@@ -0,0 +1,50 @@
+/*
+ * linux/include/linux/l3/uda1341.h
+ *
+ * Philips UDA1341 mixer device driver
+ *
+ * Copyright (c) 2000 Nicolas Pitre <nico@cam.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ */
+
+#define UDA1341_NAME "uda1341"
+
+struct uda1341_cfg {
+ unsigned int fs:16;
+ unsigned int format:3;
+};
+
+#define FMT_I2S 0
+#define FMT_LSB16 1
+#define FMT_LSB18 2
+#define FMT_LSB20 3
+#define FMT_MSB 4
+#define FMT_LSB16MSB 5
+#define FMT_LSB18MSB 6
+#define FMT_LSB20MSB 7
+
+#define L3_UDA1341_CONFIGURE 0x13410001
+
+struct l3_gain {
+ unsigned int left:8;
+ unsigned int right:8;
+ unsigned int unused:8;
+ unsigned int channel:8;
+};
+
+#define L3_SET_VOLUME 0x13410002
+#define L3_SET_TREBLE 0x13410003
+#define L3_SET_BASS 0x13410004
+#define L3_SET_GAIN 0x13410005
+
+struct l3_agc {
+ unsigned int level:8;
+ unsigned int enable:1;
+ unsigned int attack:7;
+ unsigned int decay:8;
+ unsigned int channel:8;
+};
+
+#define L3_INPUT_AGC 0x13410006
diff -urN linux-2.4.26/include/linux/mm.h linux-2.4.26-vrs1/include/linux/mm.h
--- linux-2.4.26/include/linux/mm.h 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/include/linux/mm.h 2004-04-19 20:37:56.000000000 +0100
@@ -685,6 +685,12 @@
extern struct page * vmalloc_to_page(void *addr);
+#ifndef __arm__
+#define memc_update_addr(x,y,z)
+#define memc_update_mm(x)
+#define memc_clear(x,y)
+#endif
+
#endif /* __KERNEL__ */
#endif
diff -urN linux-2.4.26/include/linux/mtd/cfi.h linux-2.4.26-vrs1/include/linux/mtd/cfi.h
--- linux-2.4.26/include/linux/mtd/cfi.h 2003-06-13 15:51:38.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/mtd/cfi.h 2004-04-19 16:49:02.000000000 +0100
@@ -287,8 +287,10 @@
#define P_ID_AMD_STD 2
#define P_ID_INTEL_STD 3
#define P_ID_AMD_EXT 4
+#define P_ID_ST_ADV 32
#define P_ID_MITSUBISHI_STD 256
#define P_ID_MITSUBISHI_EXT 257
+#define P_ID_SST_PAGE 258
#define P_ID_RESERVED 65535
diff -urN linux-2.4.26/include/linux/pci.h linux-2.4.26-vrs1/include/linux/pci.h
--- linux-2.4.26/include/linux/pci.h 2004-04-19 11:44:28.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/pci.h 2004-04-19 20:38:16.000000000 +0100
@@ -411,6 +411,7 @@
char name[90]; /* device name */
char slot_name[8]; /* slot name */
+ u32 saved_state[16]; /* for saving the config space before suspend */
int active; /* ISAPnP: device is active */
int ro; /* ISAPnP: read only */
unsigned short regs; /* ISAPnP: supported registers */
@@ -497,6 +498,8 @@
struct pbus_set_ranges_data
{
+ int found_vga:1;
+ int prefetch_valid:1;
unsigned long io_start, io_end;
unsigned long mem_start, mem_end;
unsigned long prefetch_start, prefetch_end;
@@ -638,6 +641,8 @@
int pci_restore_state(struct pci_dev *dev, u32 *buffer);
int pci_set_power_state(struct pci_dev *dev, int state);
int pci_enable_wake(struct pci_dev *dev, u32 state, int enable);
+int pci_generic_suspend_save(struct pci_dev *pdev, u32 state);
+int pci_generic_resume_restore(struct pci_dev *pdev);
/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
diff -urN linux-2.4.26/include/linux/pld/pld_epxa.h linux-2.4.26-vrs1/include/linux/pld/pld_epxa.h
--- linux-2.4.26/include/linux/pld/pld_epxa.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/pld/pld_epxa.h 2004-01-14 21:32:30.000000000 +0000
@@ -0,0 +1,35 @@
+#ifndef __LINUX_EPXAPLD_H
+#define __LINUX_EPXAPLD_H
+
+/*
+ * linux/drivers/char/pld/epxapld.h
+ *
+ * Pld driver for Altera EPXA Excalibur devices
+ *
+ * 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: $
+ *
+ */
+#define PLD_IOC_MAGIC 'p'
+#if !defined(KERNEL) || defined(CONFIG_PLD_HOTSWAP)
+#define PLD_IOC_ADD_PLD_DEV _IOW(PLD_IOC_MAGIC, 0xa0, struct pldhs_dev_desc)
+#define PLD_IOC_REMOVE_PLD_DEVS _IO(PLD_IOC_MAGIC, 0xa1)
+#define PLD_IOC_SET_INT_MODE _IOW(PLD_IOC_MAGIC, 0xa2, int)
+#endif
+
+#endif
diff -urN linux-2.4.26/include/linux/pld/pld_hotswap.h linux-2.4.26-vrs1/include/linux/pld/pld_hotswap.h
--- linux-2.4.26/include/linux/pld/pld_hotswap.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/pld/pld_hotswap.h 2004-01-14 21:32:30.000000000 +0000
@@ -0,0 +1,87 @@
+#ifndef __LINUX_PLD_HOTSWAP_H
+#define __LINUX_PLD_HOTSWAP_H
+/*
+ * linux/drivers/char/pld/pld_hotswap.h
+ *
+ * Pld driver for Altera EPXA Excalibur devices
+ *
+ * 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: $
+ *
+ */
+
+/*
+ * The pld_hotswap ops contain the basic operation required for adding
+ * and removing devices from the system.
+ */
+
+struct pldhs_dev_info{
+ unsigned int size;
+ unsigned short vendor_id;
+ unsigned short product_id;
+ unsigned char fsize;
+ unsigned char nsize;
+ unsigned short pssize;
+ unsigned short cmdsize;
+ unsigned char irq;
+ unsigned char version;
+ unsigned int base_addr;
+ unsigned int reg_size;
+};
+
+struct pldhs_dev_desc{
+ struct pldhs_dev_info* info;
+ char* name;
+ void* data;
+};
+
+#include <linux/pld/pld_epxa.h>
+
+
+#ifdef __KERNEL__
+struct pld_hotswap_ops{
+ struct list_head list;
+ char* name;
+ int (*add_device)(struct pldhs_dev_info *dev_info, void* dev_ps_data);
+ int (*remove_devices)(void);
+ int (*proc_read)(char* buf,char** start,off_t offset,int count,int *eof,void *data);
+};
+
+/*
+ * These functions are called by the device drivers to register functions
+ * which should be called when devices are added and removed
+ */
+extern int pldhs_register_driver(struct pld_hotswap_ops *drv);
+extern int pldhs_unregister_driver(char *driver);
+
+/*
+ * These functions are called by the pld loader to add and remove
+ * device instances from the system. The call the functions regsistered
+ * the the particular deriver for this purpose
+ */
+extern int pldhs_add_device(struct pldhs_dev_info* dev_info,char *drv_name, void* dev_ps_data);
+extern int pldhs_remove_devices(void);
+
+/* Macro for formatting data to appear in the proc/pld file */
+#define PLDHS_READ_PROC_DATA(buf,name,index,base,irq,ps_string) \
+ sprintf(buf,":%s:%d Base Address, %#lx, IRQ, %d#\n%s\n",\
+ name,index,base,irq,ps_string)
+
+#endif
+
+#endif
diff -urN linux-2.4.26/include/linux/serial.h linux-2.4.26-vrs1/include/linux/serial.h
--- linux-2.4.26/include/linux/serial.h 2002-08-03 01:39:45.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/serial.h 2004-04-19 20:38:03.000000000 +0100
@@ -48,7 +48,7 @@
unsigned char *iomem_base;
unsigned short iomem_reg_shift;
unsigned int port_high;
- int reserved[1];
+ unsigned long iomap_base; /* cookie passed into ioremap */
};
/*
diff -urN linux-2.4.26/include/linux/serialP.h linux-2.4.26-vrs1/include/linux/serialP.h
--- linux-2.4.26/include/linux/serialP.h 2002-08-03 01:39:45.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/serialP.h 2004-04-19 20:38:16.000000000 +0100
@@ -157,8 +157,8 @@
struct pci_dev *dev;
};
-extern int pci_siig10x_fn(struct pci_dev *dev, struct pci_board *board, int enable);
-extern int pci_siig20x_fn(struct pci_dev *dev, struct pci_board *board, int enable);
+//extern int pci_siig10x_fn(struct pci_dev *dev, struct pci_board *board, int enable);
+//extern int pci_siig20x_fn(struct pci_dev *dev, struct pci_board *board, int enable);
#ifndef PCI_ANY_ID
#define PCI_ANY_ID (~0)
diff -urN linux-2.4.26/include/linux/serial_core.h linux-2.4.26-vrs1/include/linux/serial_core.h
--- linux-2.4.26/include/linux/serial_core.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/serial_core.h 2004-04-19 16:49:19.000000000 +0100
@@ -0,0 +1,441 @@
+/*
+ * linux/drivers/char/serial_core.h
+ *
+ * Copyright (C) 2000 Deep Blue Solutions Ltd.
+ *
+ * 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_core.h,v 1.9.2.3 2001/11/26 22:32:45 rmk Exp $
+ */
+
+/*
+ * The type definitions. These are from Ted Ts'o's serial.h
+ */
+#define PORT_UNKNOWN 0
+#define PORT_8250 1
+#define PORT_16450 2
+#define PORT_16550 3
+#define PORT_16550A 4
+#define PORT_CIRRUS 5
+#define PORT_16650 6
+#define PORT_16650V2 7
+#define PORT_16750 8
+#define PORT_STARTECH 9
+#define PORT_16C950 10
+#define PORT_16654 11
+#define PORT_16850 12
+#define PORT_RSA 13
+#define PORT_NS16550A 14
+#define PORT_MAX_8250 14 /* max port ID */
+
+/*
+ * ARM specific type numbers. These are not currently guaranteed
+ * to be implemented, and will change in the future. These are
+ * separate so any additions to the old serial.c that occur before
+ * we are merged can be easily merged here.
+ */
+#define PORT_AMBA 32
+#define PORT_CLPS711X 33
+#define PORT_SA1100 34
+#define PORT_UART00 35
+#define PORT_21285 37
+
+/* Sparc type numbers. */
+#define PORT_SUNZILOG 38
+#define PORT_SUNSAB 39
+
+/* NEC v850. */
+#define PORT_NB85E_UART 40
+
+/* NEC PC-9800 */
+#define PORT_8251_PC98 41
+#define PORT_19K_PC98 42
+#define PORT_FIFO_PC98 43
+#define PORT_VFAST_PC98 44
+#define PORT_PC9861 45
+#define PORT_PC9801_101 46
+
+/* DZ */
+#define PORT_DZ 47
+
+#define PORT_OMAHA 48
+#define PORT_AT91RM9200 49
+
+
+#ifdef __KERNEL__
+
+#include <linux/config.h>
+#include <linux/interrupt.h>
+#include <linux/circ_buf.h>
+#include <linux/serial.h>
+#include <linux/spinlock.h>
+
+struct uart_port;
+struct uart_info;
+struct serial_struct;
+
+/*
+ * This structure describes all the operations that can be
+ * done on the physical hardware.
+ */
+struct uart_ops {
+ unsigned int (*tx_empty)(struct uart_port *);
+ void (*set_mctrl)(struct uart_port *, unsigned int mctrl);
+ unsigned int (*get_mctrl)(struct uart_port *);
+ void (*stop_tx)(struct uart_port *, unsigned int tty_stop);
+ void (*start_tx)(struct uart_port *, unsigned int tty_start);
+ void (*send_xchar)(struct uart_port *, char ch);
+ void (*stop_rx)(struct uart_port *);
+ void (*enable_ms)(struct uart_port *);
+ void (*break_ctl)(struct uart_port *, int ctl);
+ int (*startup)(struct uart_port *);
+ void (*shutdown)(struct uart_port *);
+ void (*change_speed)(struct uart_port *, unsigned int cflag, unsigned int iflag, unsigned int quot);
+ void (*pm)(struct uart_port *, unsigned int state, unsigned int oldstate);
+ int (*set_wake)(struct uart_port *, unsigned int state);
+
+ /*
+ * Return a string describing the type of the port
+ */
+ const char *(*type)(struct uart_port *);
+
+ /*
+ * Release IO and memory resources used by the port.
+ * This includes iounmap if necessary.
+ */
+ void (*release_port)(struct uart_port *);
+
+ /*
+ * Request IO and memory resources used by the port.
+ * This includes iomapping the port if necessary.
+ */
+ int (*request_port)(struct uart_port *);
+ void (*config_port)(struct uart_port *, int);
+ int (*verify_port)(struct uart_port *, struct serial_struct *);
+ int (*ioctl)(struct uart_port *, unsigned int, unsigned long);
+};
+
+#define UART_CONFIG_TYPE (1 << 0)
+#define UART_CONFIG_IRQ (1 << 1)
+
+struct uart_icount {
+ __u32 cts;
+ __u32 dsr;
+ __u32 rng;
+ __u32 dcd;
+ __u32 rx;
+ __u32 tx;
+ __u32 frame;
+ __u32 overrun;
+ __u32 parity;
+ __u32 brk;
+ __u32 buf_overrun;
+};
+
+struct uart_port {
+ spinlock_t lock; /* port lock */
+ unsigned int iobase; /* in/out[bwl] */
+ char *membase; /* read/write[bwl] */
+ unsigned char fifosize; /* tx fifo size */
+ unsigned char x_char; /* xon/xoff char */
+ unsigned char regshift; /* reg offset shift */
+ unsigned char iotype; /* io access style */
+
+#define UPIO_PORT (0)
+#define UPIO_HUB6 (1)
+#define UPIO_MEM (2)
+
+ unsigned int read_status_mask; /* driver specific */
+ unsigned int ignore_status_mask; /* driver specific */
+
+ struct uart_info *info; /* pointer to parent info */
+ struct uart_icount icount; /* statistics */
+
+ struct console *cons; /* struct console, if any */
+ unsigned long sysrq; /* sysrq timeout */
+
+ unsigned int flags;
+
+#define UPF_HUP_NOTIFY ASYNC_HUP_NOTIFY
+#define UPF_FOURPORT ASYNC_FOURPORT
+#define UPF_SAK ASYNC_SAK
+#define UPF_SPLIT_TERMIOS ASYNC_SPLIT_TERMIOS
+#define UPF_SPD_MASK (0x1030)
+#define UPF_SPD_HI (0x0010)
+#define UPF_SPD_VHI (0x0020)
+#define UPF_SPD_CUST (0x0030)
+#define UPF_SPD_SHI (0x1000)
+#define UPF_SPD_WARP (0x1010)
+#define UPF_SKIP_TEST ASYNC_SKIP_TEST
+#define UPF_AUTO_IRQ ASYNC_AUTO_IRQ
+#define UPF_SESSION_LOCKOUT ASYNC_SESSION_LOCKOUT
+#define UPF_PGRP_LOCKOUT ASYNCPGRP_LOCKOUT
+#define UPF_CALLOUT_NOHUP ASYNC_CALLOUT_NOHUP
+#define UPF_HARDPPS_CD ASYNC_HARDPPS_CD
+ /* 12 */
+#define UPF_LOW_LATENCY ASYNC_LOW_LATENCY
+#define UPF_BUGGY_UART ASYNC_BUGGY_UART
+#define UPF_AUTOPROBE ASYNC_AUTOPROBE
+#define UPF_MAGIC_MULTIPLIER (1 << 16)
+#define UPF_BOOT_ONLYMCA ASYNC_BOOT_ONLYMCA
+#define UPF_CONS_FLOW ASYNC_CONS_FLOW
+#define UPF_SHARE_IRQ ASYNC_SHARE_IRQ
+#define UPF_BOOT_AUTOCONF ASYNC_BOOT_AUTOCONF
+#define UPF_RESOURCES (1 << 30)
+#define UPF_IOREMAP (1 << 31)
+
+#define UPF_CHANGE_MASK (0x17fff)
+#define UPF_USR_MASK (UPF_SPD_MASK|UPF_LOW_LATENCY)
+
+ unsigned int mctrl; /* current modem ctrl settings */
+ unsigned int timeout; /* character-based timeout */
+ unsigned int type; /* port type */
+ struct uart_ops *ops;
+ unsigned int uartclk; /* base uart clock */
+ unsigned int custom_divisor;
+ unsigned int irq; /* irq number */
+ unsigned int line; /* port index */
+ unsigned long mapbase; /* for ioremap */
+ unsigned char hub6; /* this should be in the 8250 driver */
+ unsigned char unused[7];
+};
+
+/*
+ * This is the state information which is persistent across opens.
+ * The low level driver must not to touch any elements contained
+ * within.
+ */
+struct uart_state {
+ unsigned int close_delay;
+ unsigned int closing_wait;
+
+#define USF_CLOSING_WAIT_INF (0)
+#define USF_CLOSING_WAIT_NONE (65535)
+
+ struct termios normal_termios;
+ struct termios callout_termios;
+
+ int count;
+ struct uart_info *info;
+ struct uart_port *port;
+
+ struct semaphore sem;
+#ifdef CONFIG_PM
+ struct pm_dev *pm;
+#endif
+};
+
+#define UART_XMIT_SIZE 1024
+/*
+ * This is the state information which is only valid when the port
+ * is open; it may be freed by the core driver once the device has
+ * been closed. Either the low level driver or the core can modify
+ * stuff here.
+ */
+struct uart_info {
+ struct tty_struct *tty;
+ struct circ_buf xmit;
+ unsigned int flags;
+
+/*
+ * These are the flags that specific to info->flags, and reflect our
+ * internal state. They can not be accessed via port->flags. Low
+ * level drivers must not change these, but may query them instead.
+ */
+#define UIF_CHECK_CD ASYNC_CHECK_CD
+#define UIF_CTS_FLOW ASYNC_CTS_FLOW
+#define UIF_CALLOUT_ACTIVE ASYNC_CALLOUT_ACTIVE
+#define UIF_NORMAL_ACTIVE ASYNC_NORMAL_ACTIVE
+#define UIF_INITIALIZED ASYNC_INITIALIZED
+
+ unsigned char *tmpbuf;
+ struct semaphore tmpbuf_sem;
+
+ unsigned int driver_priv;
+ int blocked_open;
+ pid_t session;
+ pid_t pgrp;
+
+ struct tasklet_struct tlet;
+
+ wait_queue_head_t open_wait;
+ wait_queue_head_t delta_msr_wait;
+};
+
+/* number of characters left in xmit buffer before we ask for more */
+#define WAKEUP_CHARS 256
+
+struct module;
+struct tty_driver;
+
+struct uart_driver {
+ struct module *owner;
+ int normal_major;
+ const char *normal_name;
+ struct tty_driver *normal_driver;
+ int callout_major;
+ const char *callout_name;
+ struct tty_driver *callout_driver;
+ struct tty_struct **table;
+ struct termios **termios;
+ struct termios **termios_locked;
+ int minor;
+ int nr;
+ struct console *cons;
+
+ /*
+ * these are private; the low level driver should not
+ * touch these; they should be initialised to NULL
+ */
+ struct uart_state *state;
+};
+
+void uart_write_wakeup(struct uart_port *port);
+struct uart_port *uart_get_console(struct uart_port *ports, int nr,
+ struct console *c);
+void uart_parse_options(char *options, int *baud, int *parity, int *bits,
+ int *flow);
+int uart_set_options(struct uart_port *port, struct console *co, int baud,
+ int parity, int bits, int flow);
+
+/*
+ * Port/driver registration/removal
+ */
+int uart_register_driver(struct uart_driver *uart);
+void uart_unregister_driver(struct uart_driver *uart);
+void uart_unregister_port(struct uart_driver *reg, int line);
+int uart_register_port(struct uart_driver *reg, struct uart_port *port);
+int uart_add_one_port(struct uart_driver *reg, struct uart_port *port);
+int uart_remove_one_port(struct uart_driver *reg, struct uart_port *port);
+
+#define uart_circ_empty(circ) ((circ)->head == (circ)->tail)
+#define uart_circ_clear(circ) ((circ)->head = (circ)->tail = 0)
+
+#define uart_circ_chars_pending(circ) \
+ (CIRC_CNT((circ)->head, (circ)->tail, UART_XMIT_SIZE))
+
+#define uart_circ_chars_free(circ) \
+ (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE))
+
+#define uart_tx_stopped(port) \
+ ((port)->info->tty->stopped || (port)->info->tty->hw_stopped)
+
+/*
+ * The following are helper functions for the low level drivers.
+ */
+#ifdef SUPPORT_SYSRQ
+static inline int
+uart_handle_sysrq_char(struct uart_port *port, unsigned int ch,
+ struct pt_regs *regs)
+{
+ if (port->sysrq) {
+ if (ch && time_before(jiffies, port->sysrq)) {
+ handle_sysrq(ch, regs, NULL, NULL);
+ port->sysrq = 0;
+ return 1;
+ }
+ port->sysrq = 0;
+ }
+ return 0;
+}
+#else
+#define uart_handle_sysrq_char(port,ch,regs) (0)
+#endif
+
+/*
+ * We do the SysRQ and SAK checking like this...
+ */
+static inline int uart_handle_break(struct uart_port *port)
+{
+ struct uart_info *info = port->info;
+#ifdef SUPPORT_SYSRQ
+ if (port->cons && port->cons->index == port->line) {
+ if (!port->sysrq) {
+ port->sysrq = jiffies + HZ*5;
+ return 1;
+ }
+ port->sysrq = 0;
+ }
+#endif
+ if (port->flags & UPF_SAK)
+ do_SAK(info->tty);
+ return 0;
+}
+
+/**
+ * uart_handle_dcd_change - handle a change of carrier detect state
+ * @port: uart_port structure for the open port
+ * @status: new carrier detect status, nonzero if active
+ */
+static inline void
+uart_handle_dcd_change(struct uart_port *port, unsigned int status)
+{
+ struct uart_info *info = port->info;
+
+ port->icount.dcd++;
+
+#ifdef CONFIG_HARD_PPS
+ if ((port->flags & UPF_HARDPPS_CD) && status)
+ hardpps();
+#endif
+
+ if (info->flags & UIF_CHECK_CD) {
+ if (status)
+ wake_up_interruptible(&info->open_wait);
+ else if (!((info->flags & UIF_CALLOUT_ACTIVE) &&
+ (port->flags & UPF_CALLOUT_NOHUP))) {
+ if (info->tty)
+ tty_hangup(info->tty);
+ }
+ }
+}
+
+/**
+ * uart_handle_cts_change - handle a change of clear-to-send state
+ * @port: uart_port structure for the open port
+ * @status: new clear to send status, nonzero if active
+ */
+static inline void
+uart_handle_cts_change(struct uart_port *port, unsigned int status)
+{
+ struct uart_info *info = port->info;
+ struct tty_struct *tty = info->tty;
+
+ port->icount.cts++;
+
+ if (info->flags & UIF_CTS_FLOW) {
+ if (tty->hw_stopped) {
+ if (status) {
+ tty->hw_stopped = 0;
+ port->ops->start_tx(port, 0);
+ uart_write_wakeup(port);
+ }
+ } else {
+ if (!status) {
+ tty->hw_stopped = 1;
+ port->ops->stop_tx(port, 0);
+ }
+ }
+ }
+}
+
+/*
+ * UART_ENABLE_MS - determine if port should enable modem status irqs
+ */
+#define UART_ENABLE_MS(port,cflag) ((port)->flags & UPF_HARDPPS_CD || \
+ (cflag) & CRTSCTS || \
+ !((cflag) & CLOCAL))
+
+#endif
diff -urN linux-2.4.26/include/linux/serial_reg.h linux-2.4.26-vrs1/include/linux/serial_reg.h
--- linux-2.4.26/include/linux/serial_reg.h 2001-05-02 00:05:00.000000000 +0100
+++ linux-2.4.26-vrs1/include/linux/serial_reg.h 2004-01-14 21:32:30.000000000 +0000
@@ -121,6 +121,7 @@
/*
* These are the definitions for the Modem Control Register
*/
+#define UART_MCR_AFE 0x20 /* Enable auto-RTS/CTS (TI16C750) */
#define UART_MCR_LOOP 0x10 /* Enable loopback test mode */
#define UART_MCR_OUT2 0x08 /* Out2 complement */
#define UART_MCR_OUT1 0x04 /* Out1 complement */
diff -urN linux-2.4.26/include/linux/zlib.h linux-2.4.26-vrs1/include/linux/zlib.h
--- linux-2.4.26/include/linux/zlib.h 2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.26-vrs1/include/linux/zlib.h 2004-01-14 21:32:30.000000000 +0000
@@ -31,7 +31,7 @@
#ifndef _ZLIB_H
#define _ZLIB_H
-#include <linux/zconf.h>
+#include "zconf.h"
#ifdef __cplusplus
extern "C" {
diff -urN linux-2.4.26/init/do_mounts.c linux-2.4.26-vrs1/init/do_mounts.c
--- linux-2.4.26/init/do_mounts.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/init/do_mounts.c 2004-01-14 21:39:29.000000000 +0000
@@ -888,7 +888,7 @@
*/
void prepare_namespace(void)
{
- int is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
+ int is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR || MAJOR(ROOT_DEV) == 31;
#ifdef CONFIG_ALL_PPC
extern void arch_discover_root(void);
arch_discover_root();
@@ -951,6 +951,7 @@
static unsigned inptr; /* index of next byte to be processed in inbuf */
static unsigned outcnt; /* bytes in output buffer */
static int exit_code;
+static int unzip_error;
static long bytes_out;
static int crd_infd, crd_outfd;
@@ -998,13 +999,17 @@
/* ===========================================================================
* Fill the input buffer. This is called only when the buffer is empty
* and at least one byte is really needed.
+ * Returning -1 does not guarantee that gunzip() will ever return.
*/
static int __init fill_inbuf(void)
{
if (exit_code) return -1;
insize = read(crd_infd, inbuf, INBUFSIZ);
- if (insize == 0) return -1;
+ if (insize == 0) {
+ error("RAMDISK: ran out of compressed data\n");
+ return -1;
+ }
inptr = 1;
@@ -1018,10 +1023,15 @@
static void __init flush_window(void)
{
ulg c = crc; /* temporary variable */
- unsigned n;
+ unsigned n, written;
uch *in, ch;
- write(crd_outfd, window, outcnt);
+ written = write(crd_outfd, window, outcnt);
+ if (written != outcnt && unzip_error == 0) {
+ printk(KERN_ERR "RAMDISK: incomplete write (%d != %d), "
+ "only wrote %ld\n", written, outcnt, bytes_out);
+ unzip_error = 1;
+ }
in = window;
for (n = 0; n < outcnt; n++) {
ch = *in++;
@@ -1036,6 +1046,7 @@
{
printk(KERN_ERR "%s", x);
exit_code = 1;
+ unzip_error = 1;
}
static int __init crd_load(int in_fd, int out_fd)
@@ -1064,6 +1075,8 @@
}
makecrc();
result = gunzip();
+ if (unzip_error)
+ result = 1;
kfree(inbuf);
kfree(window);
return result;
diff -urN linux-2.4.26/kernel/Makefile linux-2.4.26-vrs1/kernel/Makefile
--- linux-2.4.26/kernel/Makefile 2001-09-17 05:22:40.000000000 +0100
+++ linux-2.4.26-vrs1/kernel/Makefile 2004-01-14 21:32:30.000000000 +0000
@@ -9,16 +9,19 @@
O_TARGET := kernel.o
-export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o printk.o
+export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o \
+ printk.o fork.o cpufreq.o
-obj-y = sched.o dma.o fork.o exec_domain.o panic.o printk.o \
+obj-y = sched.o fork.o exec_domain.o panic.o printk.o \
module.o exit.o itimer.o info.o time.o softirq.o resource.o \
sysctl.o acct.o capability.o ptrace.o timer.o user.o \
signal.o sys.o kmod.o context.o
+obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
obj-$(CONFIG_UID16) += uid16.o
obj-$(CONFIG_MODULES) += ksyms.o
obj-$(CONFIG_PM) += pm.o
+obj-$(CONFIG_CPU_FREQ) += cpufreq.o
ifneq ($(CONFIG_IA64),y)
# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
diff -urN linux-2.4.26/kernel/cpufreq.c linux-2.4.26-vrs1/kernel/cpufreq.c
--- linux-2.4.26/kernel/cpufreq.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/kernel/cpufreq.c 2004-01-14 21:32:30.000000000 +0000
@@ -0,0 +1,536 @@
+/*
+ * linux/kernel/cpufreq.c
+ *
+ * Copyright (C) 2001 Russell King
+ *
+ * $Id: cpufreq.c,v 1.17.2.2 2002/05/03 13:26:27 rmk Exp $
+ *
+ * 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.
+ *
+ * CPU speed changing core functionality. We provide the following
+ * services to the system:
+ * - notifier lists to inform other code of the freq change both
+ * before and after the freq change.
+ * - the ability to change the freq speed
+ *
+ * ** You'll need to add CTL_CPU = 10 to include/linux/sysctl.h if
+ * it's not already present.
+ *
+ * When this appears in the kernel, the sysctl enums will move to
+ * include/linux/sysctl.h
+ */
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/notifier.h>
+#include <linux/cpufreq.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/smp.h>
+#include <linux/fs.h>
+#include <linux/sysctl.h>
+
+#include <asm/semaphore.h>
+#include <asm/system.h>
+#include <asm/uaccess.h>
+#include <linux/interrupt.h> /* requires system.h */
+
+/*
+ * This list is for kernel code that needs to handle
+ * changes to devices when the CPU clock speed changes.
+ */
+static struct notifier_block *cpufreq_notifier_list;
+static DECLARE_MUTEX_LOCKED(cpufreq_sem);
+static unsigned long cpufreq_ref_loops;
+static unsigned int cpufreq_ref_freq;
+static int cpufreq_initialised;
+static unsigned int (*cpufreq_validatespeed)(unsigned int);
+static void (*cpufreq_setspeed)(unsigned int);
+
+#ifndef CONFIG_SMP
+static unsigned int __cpufreq_max;
+static unsigned int __cpufreq_min;
+static unsigned int __cpufreq_cur;
+#endif
+
+static unsigned long scale(unsigned long ref, u_int div, u_int mult)
+{
+ unsigned long new_jiffy_l, new_jiffy_h;
+
+ /*
+ * Recalculate loops_per_jiffy. We do it this way to
+ * avoid math overflow on 32-bit machines. Maybe we
+ * should make this architecture dependent? If you have
+ * a better way of doing this, please replace!
+ *
+ * new = old * mult / div
+ */
+ new_jiffy_h = ref / div;
+ new_jiffy_l = (ref % div) / 100;
+ new_jiffy_h *= mult;
+ new_jiffy_l = new_jiffy_l * mult / div;
+
+ return new_jiffy_h + new_jiffy_l * 100;
+}
+
+/*
+ * cpufreq_max command line parameter. Use:
+ * cpufreq=59000-221000
+ * to set the CPU frequency to 59 to 221MHz.
+ */
+static int __init cpufreq_setup(char *str)
+{
+ unsigned int min, max;
+ int i;
+
+ min = 0;
+ max = simple_strtoul(str, &str, 0);
+ if (*str == '-') {
+ min = max;
+ max = simple_strtoul(str + 1, NULL, 0);
+ }
+
+ for (i = 0; i < smp_num_cpus; i++) {
+ cpufreq_max(i) = max;
+ cpufreq_min(i) = min;
+ }
+
+ return 1;
+}
+
+__setup("cpufreq=", cpufreq_setup);
+
+/**
+ * cpufreq_register_notifier - register a driver with cpufreq
+ * @nb: notifier function to register
+ *
+ * Add a driver to the list of drivers that which to be notified about
+ * CPU clock rate changes. The driver will be called three times on
+ * clock change.
+ *
+ * This function may sleep, and has the same return conditions as
+ * notifier_chain_register.
+ */
+int cpufreq_register_notifier(struct notifier_block *nb)
+{
+ int ret;
+
+ down(&cpufreq_sem);
+ ret = notifier_chain_register(&cpufreq_notifier_list, nb);
+ up(&cpufreq_sem);
+
+ return ret;
+}
+
+EXPORT_SYMBOL(cpufreq_register_notifier);
+
+/**
+ * cpufreq_unregister_notifier - unregister a driver with cpufreq
+ * @nb: notifier block to be unregistered
+ *
+ * Remove a driver from the CPU frequency notifier lists.
+ *
+ * This function may sleep, and has the same return conditions as
+ * notifier_chain_unregister.
+ */
+int cpufreq_unregister_notifier(struct notifier_block *nb)
+{
+ int ret;
+
+ down(&cpufreq_sem);
+ ret = notifier_chain_unregister(&cpufreq_notifier_list, nb);
+ up(&cpufreq_sem);
+
+ return ret;
+}
+
+EXPORT_SYMBOL(cpufreq_unregister_notifier);
+
+/*
+ * This notifier alters the system "loops_per_jiffy" for the clock
+ * speed change. We ignore CPUFREQ_MINMAX here.
+ */
+static void adjust_jiffies(unsigned long val, struct cpufreq_info *ci)
+{
+ if ((val == CPUFREQ_PRECHANGE && ci->old_freq < ci->new_freq) ||
+ (val == CPUFREQ_POSTCHANGE && ci->old_freq > ci->new_freq))
+ loops_per_jiffy = scale(cpufreq_ref_loops, cpufreq_ref_freq,
+ ci->new_freq);
+}
+
+#ifdef CONFIG_PM
+/**
+ * cpufreq_restore - restore the CPU clock frequency after resume
+ *
+ * Restore the CPU clock frequency so that our idea of the current
+ * frequency reflects the actual hardware.
+ */
+int cpufreq_restore(void)
+{
+ unsigned long old_cpus;
+ int cpu = smp_processor_id();
+ int ret;
+
+ if (!cpufreq_initialised)
+ panic("cpufreq_restore() called before initialisation!");
+ if (in_interrupt())
+ panic("cpufreq_restore() called from interrupt context!");
+
+ /*
+ * Bind to the current CPU.
+ */
+ old_cpus = current->cpus_allowed;
+ current->cpus_allowed = 1UL << cpu_logical_map(cpu);
+
+ down(&cpufreq_sem);
+
+ ret = -ENXIO;
+ if (cpufreq_setspeed) {
+ cpufreq_setspeed(cpufreq_current(cpu));
+ ret = 0;
+ }
+
+ up(&cpufreq_sem);
+
+ current->cpus_allowed = old_cpus;
+
+ return ret;
+}
+
+EXPORT_SYMBOL_GPL(cpufreq_restore);
+#endif
+
+/**
+ * cpu_setfreq - change the CPU clock frequency.
+ * @freq: frequency (in kHz) at which we should run.
+ *
+ * Set the CPU clock frequency, informing all registered users of
+ * the change. We bound the frequency according to the cpufreq_max
+ * command line parameter, and the parameters the registered users
+ * will allow.
+ *
+ * This function must be called from process context, and on the
+ * cpu that we wish to change the frequency of.
+ *
+ * We return 0 if successful. (we are currently always successful).
+ */
+int cpufreq_set(unsigned int freq)
+{
+ unsigned long old_cpus;
+ struct cpufreq_info clkinfo;
+ struct cpufreq_minmax minmax;
+ int cpu = smp_processor_id();
+ int ret;
+
+ if (!cpufreq_initialised)
+ panic("cpufreq_set() called before initialisation!");
+ if (in_interrupt())
+ panic("cpufreq_set() called from interrupt context!");
+
+ /*
+ * Bind to the current CPU.
+ */
+ old_cpus = current->cpus_allowed;
+ current->cpus_allowed = 1UL << cpu_logical_map(cpu);
+
+ down(&cpufreq_sem);
+ ret = -ENXIO;
+ if (!cpufreq_setspeed || !cpufreq_validatespeed)
+ goto out;
+
+ /*
+ * Don't allow the CPU to be clocked over the limit.
+ */
+ minmax.min_freq = cpufreq_min(cpu);
+ minmax.max_freq = cpufreq_max(cpu);
+ minmax.cur_freq = cpufreq_current(cpu);
+ minmax.new_freq = freq;
+
+ /*
+ * Find out what the registered devices will currently tolerate,
+ * and limit the requested clock rate to these values. Drivers
+ * must not rely on the 'new_freq' value - it is only a guide.
+ */
+ notifier_call_chain(&cpufreq_notifier_list, CPUFREQ_MINMAX, &minmax);
+ if (freq < minmax.min_freq)
+ freq = minmax.min_freq;
+ if (freq > minmax.max_freq)
+ freq = minmax.max_freq;
+
+ /*
+ * Ask the CPU specific code to validate the speed. If the speed
+ * is not acceptable, make it acceptable. Current policy is to
+ * round the frequency down to the value the processor actually
+ * supports.
+ */
+ freq = cpufreq_validatespeed(freq);
+
+ if (cpufreq_current(cpu) != freq) {
+ clkinfo.old_freq = cpufreq_current(cpu);
+ clkinfo.new_freq = freq;
+
+ notifier_call_chain(&cpufreq_notifier_list, CPUFREQ_PRECHANGE,
+ &clkinfo);
+
+ adjust_jiffies(CPUFREQ_PRECHANGE, &clkinfo);
+
+ /*
+ * Actually set the CPU frequency.
+ */
+ cpufreq_setspeed(freq);
+ cpufreq_current(cpu) = freq;
+ adjust_jiffies(CPUFREQ_POSTCHANGE, &clkinfo);
+
+ notifier_call_chain(&cpufreq_notifier_list, CPUFREQ_POSTCHANGE,
+ &clkinfo);
+ }
+
+ ret = 0;
+
+ out:
+ up(&cpufreq_sem);
+
+ current->cpus_allowed = old_cpus;
+
+ return ret;
+}
+
+EXPORT_SYMBOL_GPL(cpufreq_set);
+
+/**
+ * cpufreq_setmax - set the CPU to maximum frequency
+ *
+ * Sets the CPU this function is executed on to maximum frequency.
+ */
+int cpufreq_setmax(void)
+{
+ return cpufreq_set(cpufreq_max(smp_processor_id()));
+}
+
+EXPORT_SYMBOL_GPL(cpufreq_setmax);
+
+/**
+ * cpufreq_get - return the current CPU clock frequency in 1kHz
+ * @cpu: cpu number to obtain frequency for
+ *
+ * Returns the specified CPUs frequency in kHz.
+ */
+unsigned int cpufreq_get(int cpu)
+{
+ if (!cpufreq_initialised)
+ panic("cpufreq_get() called before initialisation!");
+ return cpufreq_current(cpu);
+}
+
+EXPORT_SYMBOL(cpufreq_get);
+
+#ifdef CONFIG_SYSCTL
+
+static int
+cpufreq_procctl(ctl_table *ctl, int write, struct file *filp,
+ void *buffer, size_t *lenp)
+{
+ char buf[16], *p;
+ int cpu = 0, len, left = *lenp;
+
+ if (!left || (filp->f_pos && !write)) {
+ *lenp = 0;
+ return 0;
+ }
+
+ if (write) {
+ unsigned int freq;
+
+ len = left;
+ if (left > sizeof(buf))
+ left = sizeof(buf);
+ if (copy_from_user(buf, buffer, left))
+ return -EFAULT;
+ buf[sizeof(buf) - 1] = '\0';
+
+ freq = simple_strtoul(buf, &p, 0);
+ cpufreq_set(freq);
+ } else {
+ len = sprintf(buf, "%d\n", cpufreq_get(cpu));
+ if (len > left)
+ len = left;
+ if (copy_to_user(buffer, buf, len))
+ return -EFAULT;
+ }
+
+ *lenp = len;
+ filp->f_pos += len;
+ return 0;
+}
+
+static int
+cpufreq_sysctl(ctl_table *table, int *name, int nlen,
+ void *oldval, size_t *oldlenp,
+ void *newval, size_t newlen, void **context)
+{
+ int cpu = 0;
+
+ if (oldval && oldlenp) {
+ size_t oldlen;
+
+ if (get_user(oldlen, oldlenp))
+ return -EFAULT;
+
+ if (oldlen != sizeof(unsigned int))
+ return -EINVAL;
+
+ if (put_user(cpufreq_get(cpu), (unsigned int *)oldval) ||
+ put_user(sizeof(unsigned int), oldlenp))
+ return -EFAULT;
+ }
+ if (newval && newlen) {
+ unsigned int freq;
+
+ if (newlen != sizeof(unsigned int))
+ return -EINVAL;
+
+ if (get_user(freq, (unsigned int *)newval))
+ return -EFAULT;
+
+ cpufreq_set(freq);
+ }
+ return 1;
+}
+
+enum {
+ CPU_NR_FREQ_MAX = 1,
+ CPU_NR_FREQ_MIN = 2,
+ CPU_NR_FREQ = 3
+};
+
+static ctl_table ctl_cpu_vars[4] = {
+ {
+ ctl_name: CPU_NR_FREQ_MAX,
+ procname: "speed-max",
+ data: &cpufreq_max(0),
+ maxlen: sizeof(cpufreq_max(0)),
+ mode: 0444,
+ proc_handler: proc_dointvec,
+ },
+ {
+ ctl_name: CPU_NR_FREQ_MIN,
+ procname: "speed-min",
+ data: &cpufreq_min(0),
+ maxlen: sizeof(cpufreq_min(0)),
+ mode: 0444,
+ proc_handler: proc_dointvec,
+ },
+ {
+ ctl_name: CPU_NR_FREQ,
+ procname: "speed",
+ mode: 0644,
+ proc_handler: cpufreq_procctl,
+ strategy: cpufreq_sysctl,
+ },
+ {
+ ctl_name: 0,
+ }
+};
+
+enum {
+ CPU_NR = 1,
+};
+
+static ctl_table ctl_cpu_nr[2] = {
+ {
+ ctl_name: CPU_NR,
+ procname: "0",
+ mode: 0555,
+ child: ctl_cpu_vars,
+ },
+ {
+ ctl_name: 0,
+ }
+};
+
+static ctl_table ctl_cpu[2] = {
+ {
+ ctl_name: CTL_CPU,
+ procname: "cpu",
+ mode: 0555,
+ child: ctl_cpu_nr,
+ },
+ {
+ ctl_name: 0,
+ }
+};
+
+static inline void cpufreq_sysctl_init(void)
+{
+ register_sysctl_table(ctl_cpu, 0);
+}
+
+#else
+#define cpufreq_sysctl_init()
+#endif
+
+/**
+ * cpufreq_setfunctions - Set CPU clock functions
+ * @validate: pointer to validation function
+ * @setspeed: pointer to setspeed function
+ */
+void
+cpufreq_setfunctions(unsigned int (*validate)(unsigned int),
+ void (*setspeed)(unsigned int))
+{
+ down(&cpufreq_sem);
+ cpufreq_validatespeed = validate;
+ cpufreq_setspeed = setspeed;
+ up(&cpufreq_sem);
+}
+
+EXPORT_SYMBOL_GPL(cpufreq_setfunctions);
+
+/**
+ * cpufreq_init - Initialise the cpufreq core
+ * @freq: current CPU clock speed.
+ * @min_freq: minimum CPU clock speed.
+ * @max_freq: maximum CPU clock speed.
+ *
+ * Initialise the cpufreq core. If the cpufreq_max command line
+ * parameter has not been specified, we set the maximum clock rate
+ * to the current CPU clock rate.
+ */
+void cpufreq_init(unsigned int freq,
+ unsigned int min_freq,
+ unsigned int max_freq)
+{
+ /*
+ * If the user doesn't tell us their maximum frequency,
+ * or if it is invalid, use the values determined
+ * by the cpufreq-arch-specific initialization functions.
+ * The validatespeed code is responsible for limiting
+ * this further.
+ */
+ if (max_freq && ((cpufreq_max(0) == 0) || (cpufreq_max(0) > max_freq)))
+ cpufreq_max(0) = max_freq;
+ if (min_freq && ((cpufreq_min(0) == 0) || (cpufreq_min(0) < min_freq)))
+ cpufreq_min(0) = min_freq;
+
+ if (cpufreq_max(0) == 0)
+ cpufreq_max(0) = freq;
+
+ printk(KERN_INFO "CPU clock: %d.%03d MHz (%d.%03d-%d.%03d MHz)\n",
+ freq / 1000, freq % 1000,
+ cpufreq_min(0) / 1000, cpufreq_min(0) % 1000,
+ cpufreq_max(0) / 1000, cpufreq_max(0) % 1000);
+
+ cpufreq_ref_loops = loops_per_jiffy;
+ cpufreq_ref_freq = freq;
+ cpufreq_current(smp_processor_id()) = freq;
+
+ cpufreq_initialised = 1;
+ up(&cpufreq_sem);
+
+ cpufreq_sysctl_init();
+}
+
+EXPORT_SYMBOL_GPL(cpufreq_init);
diff -urN linux-2.4.26/kernel/exit.c linux-2.4.26-vrs1/kernel/exit.c
--- linux-2.4.26/kernel/exit.c 2002-11-28 23:53:15.000000000 +0000
+++ linux-2.4.26-vrs1/kernel/exit.c 2004-01-14 21:32:30.000000000 +0000
@@ -587,7 +587,7 @@
return retval;
}
-#if !defined(__alpha__) && !defined(__ia64__)
+#if !defined(__alpha__) && !defined(__ia64__) && !defined(__arm__)
/*
* sys_waitpid() remains for compatibility. waitpid() should be
diff -urN linux-2.4.26/kernel/fork.c linux-2.4.26-vrs1/kernel/fork.c
--- linux-2.4.26/kernel/fork.c 2004-04-19 11:44:28.000000000 +0100
+++ linux-2.4.26-vrs1/kernel/fork.c 2004-04-18 21:47:52.000000000 +0100
@@ -75,7 +75,11 @@
* value: the thread structures can take up at most half
* of memory.
*/
+#if THREAD_SIZE > PAGE_SIZE
max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 8;
+#else
+ max_threads = (mempages * PAGE_SIZE) / (8 * THREAD_SIZE);
+#endif
init_task.rlim[RLIMIT_NPROC].rlim_cur = max_threads/2;
init_task.rlim[RLIMIT_NPROC].rlim_max = max_threads/2;
@@ -220,6 +224,7 @@
fail_nomem:
flush_tlb_mm(current->mm);
+ memc_update_mm(mm);
return retval;
}
diff -urN linux-2.4.26/kernel/ksyms.c linux-2.4.26-vrs1/kernel/ksyms.c
--- linux-2.4.26/kernel/ksyms.c 2004-02-27 20:03:29.000000000 +0000
+++ linux-2.4.26-vrs1/kernel/ksyms.c 2004-02-23 13:36:41.000000000 +0000
@@ -345,6 +345,7 @@
/* tty routines */
EXPORT_SYMBOL(tty_hangup);
+EXPORT_SYMBOL(tty_vhangup);
EXPORT_SYMBOL(tty_wait_until_sent);
EXPORT_SYMBOL(tty_check_change);
EXPORT_SYMBOL(tty_hung_up_p);
@@ -439,9 +440,11 @@
EXPORT_SYMBOL(kiobuf_wait_for_io);
/* dma handling */
+#ifdef CONFIG_GENERIC_ISA_DMA
EXPORT_SYMBOL(request_dma);
EXPORT_SYMBOL(free_dma);
EXPORT_SYMBOL(dma_spin_lock);
+#endif
#ifdef HAVE_DISABLE_HLT
EXPORT_SYMBOL(disable_hlt);
EXPORT_SYMBOL(enable_hlt);
diff -urN linux-2.4.26/kernel/signal.c linux-2.4.26-vrs1/kernel/signal.c
--- linux-2.4.26/kernel/signal.c 2004-02-27 20:03:29.000000000 +0000
+++ linux-2.4.26-vrs1/kernel/signal.c 2004-02-23 13:36:41.000000000 +0000
@@ -778,8 +778,8 @@
info.si_uid = tsk->uid;
/* FIXME: find out whether or not this is supposed to be c*time. */
- info.si_utime = tsk->times.tms_utime;
- info.si_stime = tsk->times.tms_stime;
+ info.si_utime = hz_to_std(tsk->times.tms_utime);
+ info.si_stime = hz_to_std(tsk->times.tms_stime);
status = tsk->exit_code & 0x7f;
why = SI_KERNEL; /* shouldn't happen */
@@ -1277,7 +1277,7 @@
#endif /* __sparc__ */
#endif
-#if !defined(__alpha__) && !defined(__ia64__)
+#if !defined(__alpha__) && !defined(__ia64__) && !defined(__arm__)
/*
* For backwards compatibility. Functionality superseded by sigprocmask.
*/
@@ -1305,7 +1305,8 @@
}
#endif /* !defined(__alpha__) */
-#if !defined(__alpha__) && !defined(__ia64__) && !defined(__mips__)
+#if !defined(__alpha__) && !defined(__ia64__) && !defined(__mips__) && \
+ !defined(__arm__)
/*
* For backwards compatibility. Functionality superseded by sigaction.
*/
@@ -1322,4 +1323,4 @@
return ret ? ret : (unsigned long)old_sa.sa.sa_handler;
}
-#endif /* !alpha && !__ia64__ && !defined(__mips__) */
+#endif /* !alpha && !__ia64__ && !defined(__mips__) && !defined(__arm__) */
diff -urN linux-2.4.26/kernel/sys.c linux-2.4.26-vrs1/kernel/sys.c
--- linux-2.4.26/kernel/sys.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/kernel/sys.c 2004-01-14 21:39:29.000000000 +0000
@@ -801,16 +801,23 @@
asmlinkage long sys_times(struct tms * tbuf)
{
+ struct tms temp;
+
/*
* In the SMP world we might just be unlucky and have one of
* the times increment as we use it. Since the value is an
* atomically safe type this is just fine. Conceptually its
* as if the syscall took an instant longer to occur.
*/
- if (tbuf)
- if (copy_to_user(tbuf, ¤t->times, sizeof(struct tms)))
+ if (tbuf) {
+ temp.tms_utime = hz_to_std(current->times.tms_utime);
+ temp.tms_stime = hz_to_std(current->times.tms_stime);
+ temp.tms_cutime = hz_to_std(current->times.tms_cutime);
+ temp.tms_cstime = hz_to_std(current->times.tms_cstime);
+ if (copy_to_user(tbuf, &temp, sizeof(struct tms)))
return -EFAULT;
- return jiffies;
+ }
+ return hz_to_std(jiffies);
}
/*
diff -urN linux-2.4.26/lib/string.c linux-2.4.26-vrs1/lib/string.c
--- linux-2.4.26/lib/string.c 2002-08-03 01:39:46.000000000 +0100
+++ linux-2.4.26-vrs1/lib/string.c 2004-01-14 21:32:30.000000000 +0000
@@ -188,10 +188,10 @@
*/
char * strchr(const char * s, int c)
{
- for(; *s != (char) c; ++s)
- if (*s == '\0')
- return NULL;
- return (char *) s;
+ for(; *s != '\0'; ++s)
+ if (*s == (char) c)
+ return (char *) s;
+ return NULL;
}
#endif
diff -urN linux-2.4.26/mm/Makefile linux-2.4.26-vrs1/mm/Makefile
--- linux-2.4.26/mm/Makefile 2002-08-03 01:39:46.000000000 +0100
+++ linux-2.4.26-vrs1/mm/Makefile 2004-01-14 21:32:30.000000000 +0000
@@ -18,4 +18,5 @@
obj-$(CONFIG_HIGHMEM) += highmem.o
+obj-y += debug.o
include $(TOPDIR)/Rules.make
diff -urN linux-2.4.26/mm/debug.c linux-2.4.26-vrs1/mm/debug.c
--- linux-2.4.26/mm/debug.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.4.26-vrs1/mm/debug.c 2004-02-23 00:34:41.000000000 +0000
@@ -0,0 +1,159 @@
+/*
+ * linux/mm/debug.c
+ *
+ * Copyright (C) 2001 Russell King.
+ *
+ * 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.
+ *
+ * Dump out page information on SysRQ-G, and provide show_page_info()
+ *
+ * You are advised to use a serial console with this patch - it
+ * saturates a 38400baud link for 1 minute on a 32MB machine.
+ */
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/pagemap.h>
+#include <linux/sysrq.h>
+#include <linux/init.h>
+
+/*
+ * We print out the following information for each page in the system:
+ * address: use count, age, mapping, [RSsr] rD [acd]
+ *
+ * The flags are:
+ * R - reserved
+ * S - in swapcache
+ * s - slab page
+ *
+ * r - referenced
+ * D - dirty
+ *
+ * a - active page
+ */
+static void page_detail(struct page *page)
+{
+ if (!page)
+ return;
+
+ printk("%p: %2d %p [%c%c%c] %c%c [%c]\n",
+ page_address(page),
+ page_count(page),
+ page->mapping,
+
+ PageReserved(page) ? 'R' : '-',
+ PageSwapCache(page) ? 'S' : '-',
+ PageSlab(page) ? 's' : '-',
+
+ PageReferenced(page) ? 'r' : '-',
+ PageDirty(page) ? 'D' : '-',
+
+ PageActive(page) ? 'a' : '-');
+}
+
+/*
+ * This version collects statistics
+ */
+static int anon_pages, slab_pages, resvd_pages, unused_pages;
+
+static void page_statistics(struct page *page)
+{
+ if (page) {
+ if (PageReserved(page))
+ resvd_pages++;
+ else if (PageSlab(page))
+ slab_pages++;
+ else if (!page_count(page))
+ unused_pages ++;
+ else if (!page->mapping)
+ anon_pages ++;
+ return;
+ }
+
+ printk(" anon: %d, slab: %d, reserved: %d, free: %d\n",
+ anon_pages, slab_pages, resvd_pages, unused_pages);
+}
+
+static void show_zone_info(zone_t *zone, void (*fn)(struct page *))
+{
+ int i;
+
+ printk(" total %ld, free %ld\n",
+ zone->size, zone->free_pages);
+
+ anon_pages = 0;
+ slab_pages = 0;
+ resvd_pages = 0;
+ unused_pages = 0;
+
+ for (i = 0; i < zone->size; i++) {
+ struct page *page = zone->zone_mem_map + i;
+
+ fn(page);
+ }
+
+ fn(NULL);
+}
+
+static void show_node_info(pg_data_t *pg, void (*fn)(struct page *))
+{
+ int type;
+
+ for (type = 0; type < MAX_NR_ZONES; type++) {
+ zone_t *zone = pg->node_zones + type;
+
+ if (zone->size == 0)
+ continue;
+
+ printk("----- Zone %d ------\n", type);
+
+ show_zone_info(zone, fn);
+ }
+}
+
+static void __show_page_info(void (*fn)(struct page *))
+{
+ pg_data_t *pg;
+ int pgdat = 0;
+
+ for (pg = pgdat_list; pg; pg = pg->node_next) {
+
+ printk("===== Node %d =====\n", pgdat++);
+
+ show_node_info(pg, fn);
+ }
+}
+
+void show_page_info(void)
+{
+ __show_page_info(page_detail);
+}
+
+static void
+show_pg_info(int key, struct pt_regs *regs, struct kbd_struct *kd,
+ struct tty_struct *tty)
+{
+ void (*fn)(struct page *);
+ show_mem();
+ if (key == 'g')
+ fn = page_detail;
+ else
+ fn = page_statistics;
+ __show_page_info(fn);
+}
+
+static struct sysrq_key_op page_info_op = {
+ handler: show_pg_info,
+ help_msg: "paGeinfo",
+ action_msg: "Page Info",
+};
+
+static int __init debug_mm_init(void)
+{
+ register_sysrq_key('g', &page_info_op);
+ register_sysrq_key('h', &page_info_op);
+ return 0;
+}
+
+__initcall(debug_mm_init);
diff -urN linux-2.4.26/mm/filemap.c linux-2.4.26-vrs1/mm/filemap.c
--- linux-2.4.26/mm/filemap.c 2004-04-19 11:44:28.000000000 +0100
+++ linux-2.4.26-vrs1/mm/filemap.c 2004-04-18 21:47:52.000000000 +0100
@@ -2210,10 +2210,14 @@
pte_t pte = *ptep;
if (pte_present(pte)) {
- struct page *page = pte_page(pte);
- if (VALID_PAGE(page) && !PageReserved(page) && ptep_test_and_clear_dirty(ptep)) {
- flush_tlb_page(vma, address);
- set_page_dirty(page);
+ unsigned long pfn = pte_pfn(pte);
+
+ if (pfn_valid(pfn)) {
+ struct page *page = pfn_to_page(pfn);
+ if (!PageReserved(page) && ptep_test_and_clear_dirty(ptep)) {
+ flush_tlb_page(vma, address);
+ set_page_dirty(page);
+ }
}
}
return 0;
diff -urN linux-2.4.26/mm/memory.c linux-2.4.26-vrs1/mm/memory.c
--- linux-2.4.26/mm/memory.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/mm/memory.c 2004-01-14 21:39:29.000000000 +0000
@@ -77,8 +77,13 @@
*/
void __free_pte(pte_t pte)
{
- struct page *page = pte_page(pte);
- if ((!VALID_PAGE(page)) || PageReserved(page))
+ unsigned long pfn = pte_pfn(pte);
+ struct page *page;
+
+ if (!pfn_valid(pfn))
+ return;
+ page = pfn_to_page(pfn);
+ if (PageReserved(page))
return;
if (pte_dirty(pte))
set_page_dirty(page);
@@ -232,6 +237,7 @@
do {
pte_t pte = *src_pte;
struct page *ptepage;
+ unsigned long pfn;
/* copy_one_pte */
@@ -241,9 +247,11 @@
swap_duplicate(pte_to_swp_entry(pte));
goto cont_copy_pte_range;
}
- ptepage = pte_page(pte);
- if ((!VALID_PAGE(ptepage)) ||
- PageReserved(ptepage))
+ pfn = pte_pfn(pte);
+ if (!pfn_valid(pfn))
+ goto cont_copy_pte_range;
+ ptepage = pfn_to_page(pfn);
+ if (PageReserved(ptepage))
goto cont_copy_pte_range;
/* If it's a COW mapping, write protect it both in the parent and the child */
@@ -314,9 +322,13 @@
if (pte_none(pte))
continue;
if (pte_present(pte)) {
- struct page *page = pte_page(pte);
- if (VALID_PAGE(page) && !PageReserved(page))
- freed ++;
+ unsigned long pfn = pte_pfn(pte);
+
+ if (pfn_valid(pfn)) {
+ struct page *page = pfn_to_page(pfn);
+ if (!PageReserved(page))
+ freed ++;
+ }
/* This will eventually call __free_pte on the pte. */
tlb_remove_page(tlb, ptep, address + offset);
} else {
@@ -354,17 +366,37 @@
return freed;
}
+void unmap_page_range(mmu_gather_t *tlb, struct mm_struct *mm, unsigned long address, unsigned long end)
+{
+ int freed = 0;
+ pgd_t * dir;
+
+ if (address >= end)
+ BUG();
+ dir = pgd_offset(mm, address);
+ do {
+ freed += zap_pmd_range(tlb, dir, address, end - address);
+ address = (address + PGDIR_SIZE) & PGDIR_MASK;
+ dir++;
+ } while (address && (address < end));
+
+ /*
+ * Update rss for the mm_struct (not necessarily current->mm)
+ * Notice that rss is an unsigned long.
+ */
+ if (mm->rss > freed)
+ mm->rss -= freed;
+ else
+ mm->rss = 0;
+}
+
/*
* remove user pages in a given range.
*/
void zap_page_range(struct mm_struct *mm, unsigned long address, unsigned long size)
{
- mmu_gather_t *tlb;
- pgd_t * dir;
unsigned long start = address, end = address + size;
- int freed = 0;
-
- dir = pgd_offset(mm, address);
+ mmu_gather_t *tlb;
/*
* This is a long-lived spinlock. That's fine.
@@ -377,25 +409,10 @@
BUG();
spin_lock(&mm->page_table_lock);
flush_cache_range(mm, address, end);
- tlb = tlb_gather_mmu(mm);
-
- do {
- freed += zap_pmd_range(tlb, dir, address, end - address);
- address = (address + PGDIR_SIZE) & PGDIR_MASK;
- dir++;
- } while (address && (address < end));
- /* this will flush any remaining tlb entries */
+ tlb = tlb_gather_mmu(mm);
+ unmap_page_range(tlb, mm, address, end);
tlb_finish_mmu(tlb, start, end);
-
- /*
- * Update rss for the mm_struct (not necessarily current->mm)
- * Notice that rss is an unsigned long.
- */
- if (mm->rss > freed)
- mm->rss -= freed;
- else
- mm->rss = 0;
spin_unlock(&mm->page_table_lock);
}
@@ -407,6 +424,7 @@
pgd_t *pgd;
pmd_t *pmd;
pte_t *ptep, pte;
+ unsigned long pfn;
pgd = pgd_offset(mm, address);
if (pgd_none(*pgd) || pgd_bad(*pgd))
@@ -423,8 +441,11 @@
pte = *ptep;
if (pte_present(pte)) {
if (!write ||
- (pte_write(pte) && pte_dirty(pte)))
- return pte_page(pte);
+ (pte_write(pte) && pte_dirty(pte))) {
+ pfn = pte_pfn(pte);
+ if (pfn_valid(pfn))
+ return pfn_to_page(pfn);
+ }
}
out:
@@ -439,7 +460,8 @@
static inline struct page * get_page_map(struct page *page)
{
- if (!VALID_PAGE(page))
+ unsigned long pfn = page_to_pfn(page);
+ if (!pfn_valid(pfn))
return 0;
return page;
}
@@ -826,22 +848,22 @@
unsigned long phys_addr, pgprot_t prot)
{
unsigned long end;
+ unsigned long pfn;
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
+ pfn = phys_addr >> PAGE_SHIFT;
do {
- struct page *page;
pte_t oldpage;
oldpage = ptep_get_and_clear(pte);
- page = virt_to_page(__va(phys_addr));
- if ((!VALID_PAGE(page)) || PageReserved(page))
- set_pte(pte, mk_pte_phys(phys_addr, prot));
+ if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
+ set_pte(pte, pfn_pte(pfn, prot));
forget_pte(oldpage);
address += PAGE_SIZE;
- phys_addr += PAGE_SIZE;
+ pfn++;
pte++;
} while (address && (address < end));
}
@@ -949,10 +971,11 @@
unsigned long address, pte_t *page_table, pte_t pte)
{
struct page *old_page, *new_page;
+ unsigned long pfn = pte_pfn(pte);
- old_page = pte_page(pte);
- if (!VALID_PAGE(old_page))
+ if (!pfn_valid(pfn))
goto bad_wp_page;
+ old_page = pte_page(pte);
if (!TryLockPage(old_page)) {
int reuse = can_share_swap_page(old_page);
@@ -996,7 +1019,7 @@
bad_wp_page:
spin_unlock(&mm->page_table_lock);
- printk("do_wp_page: bogus page at address %08lx (page 0x%lx)\n",address,(unsigned long)old_page);
+ printk("do_wp_page: bogus page at address %08lx\n", address);
return -1;
no_mem:
page_cache_release(old_page);
diff -urN linux-2.4.26/mm/mmap.c linux-2.4.26-vrs1/mm/mmap.c
--- linux-2.4.26/mm/mmap.c 2004-02-27 20:03:29.000000000 +0000
+++ linux-2.4.26-vrs1/mm/mmap.c 2004-02-23 13:36:41.000000000 +0000
@@ -18,6 +18,9 @@
#include <asm/uaccess.h>
#include <asm/pgalloc.h>
+#include <asm/tlb.h>
+
+extern void unmap_page_range(mmu_gather_t *tlb, struct mm_struct *mm, unsigned long start, unsigned long end);
/*
* WARNING: the debugging will use recursive algorithms so never enable this
@@ -915,6 +918,8 @@
* old method of shifting the VA >> by PGDIR_SHIFT doesn't work.
*/
start_index = pgd_index(first);
+ if (start_index < FIRST_USER_PGD_NR)
+ start_index = FIRST_USER_PGD_NR;
end_index = pgd_index(last);
if (end_index > start_index) {
clear_page_tables(mm, start_index, end_index - start_index);
@@ -1046,7 +1051,6 @@
len = PAGE_ALIGN(len);
if (!len)
return addr;
-
if ((addr + len) > TASK_SIZE || (addr + len) < addr)
return -EINVAL;
@@ -1135,45 +1139,58 @@
/* Release all mmaps. */
void exit_mmap(struct mm_struct * mm)
{
+ mmu_gather_t *tlb;
struct vm_area_struct * mpnt;
release_segments(mm);
spin_lock(&mm->page_table_lock);
+
+ tlb = tlb_gather_mmu(mm);
+
+ flush_cache_mm(mm);
+ mpnt = mm->mmap;
+ while (mpnt) {
+ unsigned long start = mpnt->vm_start;
+ unsigned long end = mpnt->vm_end;
+
+ mm->map_count--;
+ remove_shared_vm_struct(mpnt);
+ unmap_page_range(tlb, mm, start, end);
+ mpnt = mpnt->vm_next;
+ }
+
+ /* This is just debugging */
+ if (mm->map_count)
+ BUG();
+
+ tlb_finish_mmu(tlb, 0, TASK_SIZE);
+
mpnt = mm->mmap;
mm->mmap = mm->mmap_cache = NULL;
mm->mm_rb = RB_ROOT;
mm->rss = 0;
- spin_unlock(&mm->page_table_lock);
mm->total_vm = 0;
mm->locked_vm = 0;
- flush_cache_mm(mm);
+ spin_unlock(&mm->page_table_lock);
+
+ clear_page_tables(mm, FIRST_USER_PGD_NR, USER_PTRS_PER_PGD);
+
+ /*
+ * Walk the list again, actually closing and freeing it
+ * without holding any MM locks.
+ */
while (mpnt) {
struct vm_area_struct * next = mpnt->vm_next;
- unsigned long start = mpnt->vm_start;
- unsigned long end = mpnt->vm_end;
- unsigned long size = end - start;
-
if (mpnt->vm_ops) {
if (mpnt->vm_ops->close)
mpnt->vm_ops->close(mpnt);
}
- mm->map_count--;
- remove_shared_vm_struct(mpnt);
- zap_page_range(mm, start, size);
if (mpnt->vm_file)
fput(mpnt->vm_file);
kmem_cache_free(vm_area_cachep, mpnt);
mpnt = next;
}
-
- /* This is just debugging */
- if (mm->map_count)
- BUG();
-
- clear_page_tables(mm, FIRST_USER_PGD_NR, USER_PTRS_PER_PGD);
-
- flush_tlb_mm(mm);
}
/* Insert vm structure into process list sorted by address
diff -urN linux-2.4.26/mm/slab.c linux-2.4.26-vrs1/mm/slab.c
--- linux-2.4.26/mm/slab.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/mm/slab.c 2004-01-14 21:39:29.000000000 +0000
@@ -1391,7 +1391,7 @@
#if DEBUG
# define CHECK_NR(pg) \
do { \
- if (!VALID_PAGE(pg)) { \
+ if (!virt_addr_valid(pg)) { \
printk(KERN_ERR "kfree: out of range ptr %lxh.\n", \
(unsigned long)objp); \
BUG(); \
@@ -1950,12 +1950,12 @@
name = cachep->name;
{
char tmp;
- mm_segment_t old_fs;
+ mm_segment_t old_fs;
old_fs = get_fs();
set_fs(KERNEL_DS);
if (__get_user(tmp, name))
name = "broken";
- set_fs(old_fs);
+ set_fs (old_fs);
}
seq_printf(m, "%-17s %6lu %6lu %6u %4lu %4lu %4u",
diff -urN linux-2.4.26/mm/vmalloc.c linux-2.4.26-vrs1/mm/vmalloc.c
--- linux-2.4.26/mm/vmalloc.c 2004-04-19 11:44:28.000000000 +0100
+++ linux-2.4.26-vrs1/mm/vmalloc.c 2004-04-18 21:47:52.000000000 +0100
@@ -44,8 +44,13 @@
if (pte_none(page))
continue;
if (pte_present(page)) {
- struct page *ptpage = pte_page(page);
- if (VALID_PAGE(ptpage) && (!PageReserved(ptpage)))
+ unsigned long pfn = pte_pfn(page);
+ struct page *ptpage;
+
+ if (!pfn_valid(pfn))
+ continue;
+ ptpage = pfn_to_page(pfn);
+ if (!PageReserved(ptpage))
__free_page(ptpage);
continue;
}
diff -urN linux-2.4.26/mm/vmscan.c linux-2.4.26-vrs1/mm/vmscan.c
--- linux-2.4.26/mm/vmscan.c 2004-02-27 20:03:29.000000000 +0000
+++ linux-2.4.26-vrs1/mm/vmscan.c 2004-02-23 13:36:41.000000000 +0000
@@ -121,6 +121,7 @@
drop_pte:
mm->rss--;
UnlockPage(page);
+ memc_clear(vma->vm_mm, page);
{
int freeable = page_count(page) - !!page->buffers <= 2;
page_cache_release(page);
@@ -206,13 +207,16 @@
do {
if (pte_present(*pte)) {
- struct page *page = pte_page(*pte);
+ unsigned long pfn = pte_pfn(*pte);
- if (VALID_PAGE(page) && !PageReserved(page)) {
- count -= try_to_swap_out(mm, vma, address, pte, page, classzone);
- if (!count) {
- address += PAGE_SIZE;
- break;
+ if (pfn_valid(pfn)) {
+ struct page *page = pfn_to_page(pfn);
+ if (!PageReserved(page)) {
+ count -= try_to_swap_out(mm, vma, address, pte, page, classzone);
+ if (!count) {
+ address += PAGE_SIZE;
+ break;
+ }
}
}
}
diff -urN linux-2.4.26/net/irda/af_irda.c linux-2.4.26-vrs1/net/irda/af_irda.c
--- linux-2.4.26/net/irda/af_irda.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/net/irda/af_irda.c 2004-01-14 21:39:30.000000000 +0000
@@ -1176,7 +1176,7 @@
#endif /* CONFIG_IRDA_ULTRA */
kfree(self);
MOD_DEC_USE_COUNT;
-
+
return;
}
@@ -2571,19 +2571,15 @@
sock_register(&irda_family_ops);
irda_packet_type.type = htons(ETH_P_IRDA);
- dev_add_pack(&irda_packet_type);
+ dev_add_pack(&irda_packet_type);
register_netdevice_notifier(&irda_dev_notifier);
-
irda_init();
#ifdef MODULE
- irda_device_init(); /* Called by init/main.c when non-modular */
+ irda_device_init(); /* Called by init/main.c when non-modular */
#endif
return 0;
}
-#ifdef MODULE
-module_init(irda_proto_init); /* If non-module, called from init/main.c */
-#endif
/*
* Function irda_proto_cleanup (void)
@@ -2591,25 +2587,27 @@
* Remove IrDA protocol layer
*
*/
-#ifdef MODULE
-void irda_proto_cleanup(void)
+static void __exit irda_proto_cleanup(void)
{
irda_packet_type.type = htons(ETH_P_IRDA);
- dev_remove_pack(&irda_packet_type);
+ dev_remove_pack(&irda_packet_type);
+
+ unregister_netdevice_notifier(&irda_dev_notifier);
- unregister_netdevice_notifier(&irda_dev_notifier);
-
sock_unregister(PF_IRDA);
+
irda_cleanup();
-
- return;
}
+
+#ifdef MODULE
+module_init(irda_proto_init);
module_exit(irda_proto_cleanup);
-
+
MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
-MODULE_DESCRIPTION("The Linux IrDA Protocol Subsystem");
+MODULE_DESCRIPTION("The Linux IrDA Protocol Subsystem");
MODULE_LICENSE("GPL");
#ifdef CONFIG_IRDA_DEBUG
MODULE_PARM(irda_debug, "1l");
#endif
-#endif /* MODULE */
+#endif
+
diff -urN linux-2.4.26/net/irda/iriap.c linux-2.4.26-vrs1/net/irda/iriap.c
--- linux-2.4.26/net/irda/iriap.c 2002-11-28 23:53:16.000000000 +0000
+++ linux-2.4.26-vrs1/net/irda/iriap.c 2004-01-14 21:32:30.000000000 +0000
@@ -1004,18 +1004,20 @@
switch (attrib->value->type) {
case IAS_INTEGER:
- len += sprintf(buf+len, "%d\n",
+ len += sprintf(buf+len, "%d",
attrib->value->t.integer);
break;
case IAS_STRING:
- len += sprintf(buf+len, "\"%s\"\n",
+ len += sprintf(buf+len, "\"%s\"",
attrib->value->t.string);
break;
case IAS_OCT_SEQ:
- len += sprintf(buf+len, "octet sequence (%d bytes)\n", attrib->value->len);
+ len += sprintf(buf+len,
+ "octet sequence (%d bytes)",
+ attrib->value->len);
break;
case IAS_MISSING:
- len += sprintf(buf+len, "missing\n");
+ len += sprintf(buf+len, "missing");
break;
default:
IRDA_DEBUG(0, "%s(), Unknown value type!\n", __FUNCTION__);
@@ -1027,6 +1029,7 @@
hashbin_get_next(obj->attribs);
}
obj = (struct ias_object *) hashbin_get_next(objects);
+ len += sprintf(buf+len, "\n");
}
restore_flags(flags);
diff -urN linux-2.4.26/net/irda/irlan/irlan_common.c linux-2.4.26-vrs1/net/irda/irlan/irlan_common.c
--- linux-2.4.26/net/irda/irlan/irlan_common.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/net/irda/irlan/irlan_common.c 2004-01-14 21:39:31.000000000 +0000
@@ -317,6 +317,9 @@
del_timer(&self->watchdog_timer);
+ /* since irlan_do_*_event gobble the skb, we must get it once -- rmk */
+ skb_get(skb);
+
/* If you want to pass the skb to *both* state machines, you will
* need to skb_clone() it, so that you don't free it twice.
* As the state machines don't need it, git rid of it here...
diff -urN linux-2.4.26/net/irda/irlap_event.c linux-2.4.26-vrs1/net/irda/irlap_event.c
--- linux-2.4.26/net/irda/irlap_event.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/net/irda/irlap_event.c 2004-01-14 21:39:31.000000000 +0000
@@ -532,7 +532,7 @@
#endif /* CONFIG_IRDA_ULTRA */
case RECV_TEST_CMD:
/* Remove test frame header */
- skb_pull(skb, sizeof(struct test_frame));
+ skb_pull(skb, 10 /*sizeof(struct test_frame)*/);
/*
* Send response. This skb will not be sent out again, and
@@ -740,7 +740,7 @@
switch (event) {
case CONNECT_RESPONSE:
- skb_pull(skb, sizeof(struct snrm_frame));
+ skb_pull(skb, 11 /*sizeof(struct snrm_frame)*/);
ASSERT(self->netdev != NULL, return -1;);
@@ -870,7 +870,7 @@
ASSERT(self->netdev != NULL, return -1;);
- skb_pull(skb, sizeof(struct snrm_frame));
+ skb_pull(skb, 11 /*sizeof(struct snrm_frame)*/);
irlap_qos_negotiate(self, skb);
@@ -902,7 +902,7 @@
/* Negotiate connection parameters */
ASSERT(skb->len > 10, return -1;);
- skb_pull(skb, sizeof(struct ua_frame));
+ skb_pull(skb, 10 /*sizeof(struct ua_frame)*/);
ASSERT(self->netdev != NULL, return -1;);
diff -urN linux-2.4.26/net/irda/irlap_frame.c linux-2.4.26-vrs1/net/irda/irlap_frame.c
--- linux-2.4.26/net/irda/irlap_frame.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/net/irda/irlap_frame.c 2004-02-22 11:42:55.000000000 +0000
@@ -1,5 +1,5 @@
/*********************************************************************
- *
+ *
* Filename: irlap_frame.c
* Version: 1.0
* Description: Build and transmit IrLAP frames
@@ -8,18 +8,18 @@
* Created at: Tue Aug 19 10:27:26 1997
* Modified at: Wed Jan 5 08:59:04 2000
* Modified by: Dag Brattli <dagb@cs.uit.no>
- *
- * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>,
+ *
+ * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>,
* All Rights Reserved.
* Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
- *
- * 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
+ *
+ * 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.
*
* Neither Dag Brattli nor University of Tromsø admit liability nor
- * provide warranty for any of this software. This material is
+ * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge.
*
********************************************************************/
@@ -29,11 +29,12 @@
#include <linux/if_ether.h>
#include <linux/netdevice.h>
#include <linux/irda.h>
-
+
#include <net/pkt_sched.h>
#include <net/sock.h>
-
+
#include <asm/byteorder.h>
+#include <asm/unaligned.h>
#include <net/irda/irda.h>
#include <net/irda/irda_device.h>
@@ -46,18 +47,18 @@
/*
* Function irlap_insert_info (self, skb)
*
- * Insert minimum turnaround time and speed information into the skb. We
+ * Insert minimum turnaround time and speed information into the skb. We
* need to do this since it's per packet relevant information. Safe to
* have this function inlined since it's only called from one place
*/
-static inline void irlap_insert_info(struct irlap_cb *self,
+static inline void irlap_insert_info(struct irlap_cb *self,
struct sk_buff *skb)
{
struct irda_skb_cb *cb = (struct irda_skb_cb *) skb->cb;
- /*
+ /*
* Insert MTT (min. turn time) and speed into skb, so that the
- * device driver knows which settings to use
+ * device driver knows which settings to use
*/
cb->magic = LAP_MAGIC;
cb->mtt = self->mtt_required;
@@ -65,15 +66,15 @@
/* Reset */
self->mtt_required = 0;
-
- /*
- * Delay equals negotiated BOFs count, plus the number of BOFs to
- * force the negotiated minimum turnaround time
+
+ /*
+ * Delay equals negotiated BOFs count, plus the number of BOFs to
+ * force the negotiated minimum turnaround time
*/
cb->xbofs = self->bofs_count;
cb->next_xbofs = self->next_bofs;
cb->xbofs_delay = self->xbofs_delay;
-
+
/* Reset XBOF's delay (used only for getting min turn time) */
self->xbofs_delay = 0;
/* Put the correct xbofs value for the next packet */
@@ -104,7 +105,7 @@
*
* Transmits a connect SNRM command frame
*/
-void irlap_send_snrm_frame(struct irlap_cb *self, struct qos_info *qos)
+void irlap_send_snrm_frame(struct irlap_cb *self, struct qos_info *qos)
{
struct sk_buff *skb;
struct snrm_frame *frame;
@@ -118,7 +119,7 @@
if (!skb)
return;
- frame = (struct snrm_frame *) skb_put(skb, 2);
+ frame = (struct snrm_frame *) skb_put(skb, 2);
/* Insert connection address field */
if (qos)
@@ -128,17 +129,17 @@
/* Insert control field */
frame->control = SNRM_CMD | PF_BIT;
-
+
/*
- * If we are establishing a connection then insert QoS paramerters
+ * If we are establishing a connection then insert QoS paramerters
*/
if (qos) {
skb_put(skb, 9); /* 21 left */
- frame->saddr = cpu_to_le32(self->saddr);
- frame->daddr = cpu_to_le32(self->daddr);
+ put_unaligned(cpu_to_le32(self->saddr), &frame->saddr);
+ put_unaligned(cpu_to_le32(self->daddr), &frame->daddr);
frame->ncaddr = self->caddr;
-
+
ret = irlap_insert_qos_negotiation_params(self, skb);
if (ret < 0) {
dev_kfree_skb(skb);
@@ -154,13 +155,13 @@
* Received SNRM (Set Normal Response Mode) command frame
*
*/
-static void irlap_recv_snrm_cmd(struct irlap_cb *self, struct sk_buff *skb,
- struct irlap_info *info)
+static void irlap_recv_snrm_cmd(struct irlap_cb *self, struct sk_buff *skb,
+ struct irlap_info *info)
{
struct snrm_frame *frame;
frame = (struct snrm_frame *) skb->data;
-
+
if (skb->len >= sizeof(struct snrm_frame)) {
/* Copy the new connection address ignoring the C/R bit */
info->caddr = frame->ncaddr & 0xFE;
@@ -170,11 +171,11 @@
IRDA_DEBUG(3, "%s(), invalid connection address!\n", __FUNCTION__);
return;
}
-
+
/* Copy peer device address */
- info->daddr = le32_to_cpu(frame->saddr);
- info->saddr = le32_to_cpu(frame->daddr);
-
+ info->daddr = le32_to_cpu(get_unaligned(&frame->saddr));
+ info->saddr = le32_to_cpu(get_unaligned(&frame->daddr));
+
/* Only accept if addressed directly to us */
if (info->saddr != self->saddr) {
IRDA_DEBUG(2, "%s(), not addressed to us!\n", __FUNCTION__);
@@ -198,9 +199,9 @@
struct sk_buff *skb;
struct ua_frame *frame;
int ret;
-
+
IRDA_DEBUG(2, "%s() <%ld>\n", __FUNCTION__, jiffies);
-
+
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
@@ -212,13 +213,13 @@
return;
frame = (struct ua_frame *) skb_put(skb, 10);
-
+
/* Build UA response */
frame->caddr = self->caddr;
frame->control = UA_RSP | PF_BIT;
- frame->saddr = cpu_to_le32(self->saddr);
- frame->daddr = cpu_to_le32(self->daddr);
+ put_unaligned(cpu_to_le32(self->saddr), &frame->saddr);
+ put_unaligned(cpu_to_le32(self->daddr), &frame->daddr);
/* Should we send QoS negotiation parameters? */
if (qos) {
@@ -243,7 +244,7 @@
{
struct sk_buff *skb = NULL;
__u8 *frame;
-
+
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
@@ -252,7 +253,7 @@
return;
frame = skb_put( skb, 2);
-
+
if (self->state == LAP_NDM)
frame[0] = CBROADCAST;
else
@@ -260,7 +261,7 @@
frame[1] = DM_RSP | PF_BIT;
- irlap_queue_xmit(self, skb);
+ irlap_queue_xmit(self, skb);
}
/*
@@ -269,11 +270,11 @@
* Send disconnect (DISC) frame
*
*/
-void irlap_send_disc_frame(struct irlap_cb *self)
+void irlap_send_disc_frame(struct irlap_cb *self)
{
struct sk_buff *skb = NULL;
__u8 *frame;
-
+
IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
ASSERT(self != NULL, return;);
@@ -284,7 +285,7 @@
return;
frame = skb_put(skb, 2);
-
+
frame[0] = self->caddr | CMD_FRAME;
frame[1] = DISC_CMD | PF_BIT;
@@ -295,17 +296,17 @@
* Function irlap_send_discovery_xid_frame (S, s, command)
*
* Build and transmit a XID (eXchange station IDentifier) discovery
- * frame.
+ * frame.
*/
-void irlap_send_discovery_xid_frame(struct irlap_cb *self, int S, __u8 s,
- __u8 command, discovery_t *discovery)
+void irlap_send_discovery_xid_frame(struct irlap_cb *self, int S, __u8 s,
+ __u8 command, discovery_t *discovery)
{
struct sk_buff *skb = NULL;
struct xid_frame *frame;
- __u32 bcast = BROADCAST;
+ __u32 bcast = BROADCAST, daddr;
__u8 *info;
- IRDA_DEBUG(4, "%s(), s=%d, S=%d, command=%d\n", __FUNCTION__, s, S,
+ IRDA_DEBUG(4, "%s(), s=%d, S=%d, command=%d\n", __FUNCTION__, s, S,
command);
ASSERT(self != NULL, return;);
@@ -328,13 +329,14 @@
}
frame->ident = XID_FORMAT;
- frame->saddr = cpu_to_le32(self->saddr);
-
if (command)
- frame->daddr = cpu_to_le32(bcast);
+ daddr = bcast;
else
- frame->daddr = cpu_to_le32(discovery->daddr);
-
+ daddr = discovery->daddr;
+
+ put_unaligned(cpu_to_le32(self->saddr), &frame->saddr);
+ put_unaligned(cpu_to_le32(daddr), &frame->daddr);
+
switch (S) {
case 1:
frame->flags = 0x00;
@@ -353,10 +355,10 @@
break;
}
- frame->slotnr = s;
+ frame->slotnr = s;
frame->version = 0x00;
- /*
+ /*
* Provide info for final slot only in commands, and for all
* responses. Send the second byte of the hint only if the
* EXTENSION bit is set in the first byte.
@@ -365,7 +367,7 @@
int len;
if (discovery->hints.byte[0] & HINT_EXTENSION) {
- info = skb_put(skb, 2);
+ info = skb_put(skb, 2);
info[0] = discovery->hints.byte[0];
info[1] = discovery->hints.byte[1];
} else {
@@ -378,7 +380,7 @@
len = IRDA_MIN(discovery->name_len, skb_tailroom(skb));
info = skb_put(skb, len);
memcpy(info, discovery->nickname, len);
- }
+ }
irlap_queue_xmit(self, skb);
}
@@ -388,9 +390,9 @@
* Received a XID discovery response
*
*/
-static void irlap_recv_discovery_xid_rsp(struct irlap_cb *self,
- struct sk_buff *skb,
- struct irlap_info *info)
+static void irlap_recv_discovery_xid_rsp(struct irlap_cb *self,
+ struct sk_buff *skb,
+ struct irlap_info *info)
{
struct xid_frame *xid;
discovery_t *discovery = NULL;
@@ -404,8 +406,8 @@
xid = (struct xid_frame *) skb->data;
- info->daddr = le32_to_cpu(xid->saddr);
- info->saddr = le32_to_cpu(xid->daddr);
+ info->daddr = le32_to_cpu(get_unaligned(&xid->saddr));
+ info->saddr = le32_to_cpu(get_unaligned(&xid->daddr));
/* Make sure frame is addressed to us */
if ((info->saddr != self->saddr) && (info->saddr != BROADCAST)) {
@@ -439,11 +441,11 @@
discovery->charset = discovery_info[1];
text = (char *) &discovery_info[2];
}
- /*
- * Terminate info string, should be safe since this is where the
+ /*
+ * Terminate info string, should be safe since this is where the
* FCS bytes resides.
*/
- skb->data[skb->len] = '\0';
+ skb->data[skb->len] = '\0';
strncpy(discovery->nickname, text, NICKNAME_MAX_LEN);
discovery->name_len = strlen(discovery->nickname);
@@ -458,9 +460,9 @@
* Received a XID discovery command
*
*/
-static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
- struct sk_buff *skb,
- struct irlap_info *info)
+static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
+ struct sk_buff *skb,
+ struct irlap_info *info)
{
struct xid_frame *xid;
discovery_t *discovery = NULL;
@@ -469,8 +471,8 @@
xid = (struct xid_frame *) skb->data;
- info->daddr = le32_to_cpu(xid->saddr);
- info->saddr = le32_to_cpu(xid->daddr);
+ info->daddr = le32_to_cpu(get_unaligned(&xid->saddr));
+ info->saddr = le32_to_cpu(get_unaligned(&xid->daddr));
/* Make sure frame is addressed to us */
if ((info->saddr != self->saddr) && (info->saddr != BROADCAST)) {
@@ -497,11 +499,11 @@
return;
}
info->s = xid->slotnr;
-
+
discovery_info = skb_pull(skb, sizeof(struct xid_frame));
- /*
- * Check if last frame
+ /*
+ * Check if last frame
*/
if (info->s == 0xff) {
/* Check if things are sane at this point... */
@@ -518,7 +520,7 @@
WARNING("%s(), unable to malloc!\n", __FUNCTION__);
return;
}
-
+
discovery->daddr = info->daddr;
discovery->saddr = self->saddr;
discovery->timestamp = jiffies;
@@ -533,11 +535,11 @@
discovery->charset = discovery_info[1];
text = (char *) &discovery_info[2];
}
- /*
- * Terminate string, should be safe since this is where the
+ /*
+ * Terminate string, should be safe since this is where the
* FCS bytes resides.
*/
- skb->data[skb->len] = '\0';
+ skb->data[skb->len] = '\0';
strncpy(discovery->nickname, text, NICKNAME_MAX_LEN);
discovery->name_len = strlen(discovery->nickname);
@@ -554,7 +556,7 @@
* Build and transmit RR (Receive Ready) frame. Notice that it is currently
* only possible to send RR frames with the poll bit set.
*/
-void irlap_send_rr_frame(struct irlap_cb *self, int command)
+void irlap_send_rr_frame(struct irlap_cb *self, int command)
{
struct sk_buff *skb;
__u8 *frame;
@@ -562,9 +564,9 @@
skb = dev_alloc_skb(16);
if (!skb)
return;
-
+
frame = skb_put(skb, 2);
-
+
frame[0] = self->caddr;
frame[0] |= (command) ? CMD_FRAME : 0;
@@ -576,7 +578,7 @@
/*
* Function irlap_send_rd_frame (self)
*
- * Request disconnect. Used by a secondary station to request the
+ * Request disconnect. Used by a secondary station to request the
* disconnection of the link.
*/
void irlap_send_rd_frame(struct irlap_cb *self)
@@ -587,9 +589,9 @@
skb = dev_alloc_skb(16);
if (!skb)
return;
-
+
frame = skb_put(skb, 2);
-
+
frame[0] = self->caddr;
frame[1] = RD_RSP | PF_BIT;
@@ -603,8 +605,8 @@
* making it inline since its called only from one single place
* (irlap_driver_rcv).
*/
-static inline void irlap_recv_rr_frame(struct irlap_cb *self,
- struct sk_buff *skb,
+static inline void irlap_recv_rr_frame(struct irlap_cb *self,
+ struct sk_buff *skb,
struct irlap_info *info, int command)
{
info->nr = skb->data[1] >> 5;
@@ -620,7 +622,7 @@
{
struct sk_buff *skb = NULL;
__u8 *frame;
-
+
ASSERT( self != NULL, return;);
ASSERT( self->magic == LAP_MAGIC, return;);
@@ -629,7 +631,7 @@
return;
frame = skb_put( skb, 2);
-
+
frame[0] = self->caddr;
frame[0] |= (command) ? CMD_FRAME : 0;
@@ -639,7 +641,7 @@
frame[2] = 0;
- IRDA_DEBUG(4, "%s(), vr=%d, %ld\n", __FUNCTION__, self->vr, jiffies);
+ IRDA_DEBUG(4, "%s(), vr=%d, %ld\n", __FUNCTION__, self->vr, jiffies);
irlap_queue_xmit(self, skb);
}
@@ -650,8 +652,8 @@
* Received RNR (Receive Not Ready) frame from peer station
*
*/
-static void irlap_recv_rnr_frame(struct irlap_cb *self, struct sk_buff *skb,
- struct irlap_info *info, int command)
+static void irlap_recv_rnr_frame(struct irlap_cb *self, struct sk_buff *skb,
+ struct irlap_info *info, int command)
{
info->nr = skb->data[1] >> 5;
@@ -663,13 +665,13 @@
irlap_do_event(self, RECV_RNR_RSP, skb, info);
}
-static void irlap_recv_rej_frame(struct irlap_cb *self, struct sk_buff *skb,
+static void irlap_recv_rej_frame(struct irlap_cb *self, struct sk_buff *skb,
struct irlap_info *info, int command)
{
IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
info->nr = skb->data[1] >> 5;
-
+
/* Check if this is a command or a response frame */
if (command)
irlap_do_event(self, RECV_REJ_CMD, skb, info);
@@ -677,13 +679,13 @@
irlap_do_event(self, RECV_REJ_RSP, skb, info);
}
-static void irlap_recv_srej_frame(struct irlap_cb *self, struct sk_buff *skb,
+static void irlap_recv_srej_frame(struct irlap_cb *self, struct sk_buff *skb,
struct irlap_info *info, int command)
{
IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
info->nr = skb->data[1] >> 5;
-
+
/* Check if this is a command or a response frame */
if (command)
irlap_do_event(self, RECV_SREJ_CMD, skb, info);
@@ -691,7 +693,7 @@
irlap_do_event(self, RECV_SREJ_RSP, skb, info);
}
-static void irlap_recv_disc_frame(struct irlap_cb *self, struct sk_buff *skb,
+static void irlap_recv_disc_frame(struct irlap_cb *self, struct sk_buff *skb,
struct irlap_info *info, int command)
{
IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
@@ -709,9 +711,9 @@
* Received UA (Unnumbered Acknowledgement) frame
*
*/
-static inline void irlap_recv_ua_frame(struct irlap_cb *self,
- struct sk_buff *skb,
- struct irlap_info *info)
+static inline void irlap_recv_ua_frame(struct irlap_cb *self,
+ struct sk_buff *skb,
+ struct irlap_info *info)
{
irlap_do_event(self, RECV_UA_RSP, skb, info);
}
@@ -728,25 +730,25 @@
if (skb->data[1] == I_FRAME) {
- /*
+ /*
* Insert frame sequence number (Vs) in control field before
* inserting into transmit window queue.
*/
skb->data[1] = I_FRAME | (self->vs << 1);
-
+
/* Copy buffer */
tx_skb = skb_clone(skb, GFP_ATOMIC);
if (tx_skb == NULL) {
return;
}
-
- /*
- * Insert frame in store, in case of retransmissions
+
+ /*
+ * Insert frame in store, in case of retransmissions
*/
skb_queue_tail(&self->wx_list, skb_get(skb));
-
+
self->vs = (self->vs + 1) % 8;
- self->ack_required = FALSE;
+ self->ack_required = FALSE;
self->window -= 1;
irlap_send_i_frame( self, tx_skb, CMD_FRAME);
@@ -761,40 +763,40 @@
*
* Send I(nformation) frame as primary with poll bit set
*/
-void irlap_send_data_primary_poll(struct irlap_cb *self, struct sk_buff *skb)
+void irlap_send_data_primary_poll(struct irlap_cb *self, struct sk_buff *skb)
{
struct sk_buff *tx_skb;
/* Stop P timer */
del_timer(&self->poll_timer);
-
+
/* Is this reliable or unreliable data? */
if (skb->data[1] == I_FRAME) {
-
- /*
+
+ /*
* Insert frame sequence number (Vs) in control field before
* inserting into transmit window queue.
*/
skb->data[1] = I_FRAME | (self->vs << 1);
-
+
/* Copy buffer */
tx_skb = skb_clone(skb, GFP_ATOMIC);
if (tx_skb == NULL) {
return;
}
-
- /*
- * Insert frame in store, in case of retransmissions
+
+ /*
+ * Insert frame in store, in case of retransmissions
*/
skb_queue_tail(&self->wx_list, skb_get(skb));
-
- /*
+
+ /*
* Set poll bit if necessary. We do this to the copied
* skb, since retransmitted need to set or clear the poll
- * bit depending on when they are sent.
+ * bit depending on when they are sent.
*/
tx_skb->data[1] |= PF_BIT;
-
+
self->vs = (self->vs + 1) % 8;
self->ack_required = FALSE;
@@ -827,8 +829,8 @@
* Send I(nformation) frame as secondary with final bit set
*
*/
-void irlap_send_data_secondary_final(struct irlap_cb *self,
- struct sk_buff *skb)
+void irlap_send_data_secondary_final(struct irlap_cb *self,
+ struct sk_buff *skb)
{
struct sk_buff *tx_skb = NULL;
@@ -839,26 +841,26 @@
/* Is this reliable or unreliable data? */
if (skb->data[1] == I_FRAME) {
- /*
+ /*
* Insert frame sequence number (Vs) in control field before
* inserting into transmit window queue.
*/
skb->data[1] = I_FRAME | (self->vs << 1);
-
+
tx_skb = skb_clone(skb, GFP_ATOMIC);
if (tx_skb == NULL) {
return;
- }
+ }
/* Insert frame in store */
skb_queue_tail(&self->wx_list, skb_get(skb));
-
+
tx_skb->data[1] |= PF_BIT;
-
- self->vs = (self->vs + 1) % 8;
+
+ self->vs = (self->vs + 1) % 8;
self->ack_required = FALSE;
-
- irlap_send_i_frame(self, tx_skb, RSP_FRAME);
+
+ irlap_send_i_frame(self, tx_skb, RSP_FRAME);
} else {
if (self->ack_required) {
irlap_send_ui_frame(self, skb_get(skb), self->caddr, RSP_FRAME);
@@ -885,32 +887,32 @@
* Send I(nformation) frame as secondary without final bit set
*
*/
-void irlap_send_data_secondary(struct irlap_cb *self, struct sk_buff *skb)
+void irlap_send_data_secondary(struct irlap_cb *self, struct sk_buff *skb)
{
struct sk_buff *tx_skb = NULL;
/* Is this reliable or unreliable data? */
if (skb->data[1] == I_FRAME) {
-
- /*
+
+ /*
* Insert frame sequence number (Vs) in control field before
* inserting into transmit window queue.
*/
skb->data[1] = I_FRAME | (self->vs << 1);
-
+
tx_skb = skb_clone(skb, GFP_ATOMIC);
if (tx_skb == NULL) {
return;
- }
-
+ }
+
/* Insert frame in store */
skb_queue_tail(&self->wx_list, skb_get(skb));
-
+
self->vs = (self->vs + 1) % 8;
- self->ack_required = FALSE;
+ self->ack_required = FALSE;
self->window -= 1;
- irlap_send_i_frame(self, tx_skb, RSP_FRAME);
+ irlap_send_i_frame(self, tx_skb, RSP_FRAME);
} else {
irlap_send_ui_frame(self, skb_get(skb), self->caddr, RSP_FRAME);
self->window -= 1;
@@ -920,8 +922,8 @@
/*
* Function irlap_resend_rejected_frames (nr)
*
- * Resend frames which has not been acknowledged. Should be safe to
- * traverse the list without locking it since this function will only be
+ * Resend frames which has not been acknowledged. Should be safe to
+ * traverse the list without locking it since this function will only be
* called from interrupt context (BH)
*/
void irlap_resend_rejected_frames(struct irlap_cb *self, int command)
@@ -943,8 +945,8 @@
while (skb != NULL) {
irlap_wait_min_turn_around(self, &self->qos_tx);
- /* We copy the skb to be retransmitted since we will have to
- * modify it. Cloning will confuse packet sniffers
+ /* We copy the skb to be retransmitted since we will have to
+ * modify it. Cloning will confuse packet sniffers
*/
/* tx_skb = skb_clone( skb, GFP_ATOMIC); */
tx_skb = skb_copy(skb, GFP_ATOMIC);
@@ -959,17 +961,17 @@
/* Clear old Nr field + poll bit */
tx_skb->data[1] &= 0x0f;
- /*
+ /*
* Set poll bit on the last frame retransmitted
*/
if (count-- == 1)
tx_skb->data[1] |= PF_BIT; /* Set p/f bit */
else
tx_skb->data[1] &= ~PF_BIT; /* Clear p/f bit */
-
+
irlap_send_i_frame(self, tx_skb, command);
- /*
+ /*
* If our skb is the last buffer in the list, then
* we are finished, if not, move to the next sk-buffer
*/
@@ -979,23 +981,23 @@
skb = skb->next;
}
#if 0 /* Not yet */
- /*
+ /*
* We can now fill the window with additinal data frames
*/
while (skb_queue_len( &self->txq) > 0) {
-
+
IRDA_DEBUG(0, "%s(), sending additional frames!\n", __FUNCTION__);
- if ((skb_queue_len( &self->txq) > 0) &&
+ if ((skb_queue_len( &self->txq) > 0) &&
(self->window > 0)) {
- skb = skb_dequeue( &self->txq);
+ skb = skb_dequeue( &self->txq);
ASSERT(skb != NULL, return;);
/*
- * If send window > 1 then send frame with pf
+ * If send window > 1 then send frame with pf
* bit cleared
- */
- if ((self->window > 1) &&
- skb_queue_len(&self->txq) > 0)
+ */
+ if ((self->window > 1) &&
+ skb_queue_len(&self->txq) > 0)
{
irlap_send_data_primary(self, skb);
} else {
@@ -1023,14 +1025,14 @@
if (skb != NULL) {
irlap_wait_min_turn_around(self, &self->qos_tx);
- /* We copy the skb to be retransmitted since we will have to
- * modify it. Cloning will confuse packet sniffers
+ /* We copy the skb to be retransmitted since we will have to
+ * modify it. Cloning will confuse packet sniffers
*/
/* tx_skb = skb_clone( skb, GFP_ATOMIC); */
tx_skb = skb_copy(skb, GFP_ATOMIC);
if (!tx_skb) {
IRDA_DEBUG(0, "%s(), unable to copy\n", __FUNCTION__);
- return;
+ return;
}
/* Unlink tx_skb from list */
tx_skb->next = tx_skb->prev = NULL;
@@ -1041,7 +1043,7 @@
/* Set poll/final bit */
tx_skb->data[1] |= PF_BIT; /* Set p/f bit */
-
+
irlap_send_i_frame(self, tx_skb, command);
}
}
@@ -1052,15 +1054,15 @@
* Contruct and transmit an Unnumbered Information (UI) frame
*
*/
-void irlap_send_ui_frame(struct irlap_cb *self, struct sk_buff *skb,
+void irlap_send_ui_frame(struct irlap_cb *self, struct sk_buff *skb,
__u8 caddr, int command)
{
IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
-
+
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
ASSERT(skb != NULL, return;);
-
+
/* Insert connection address */
skb->data[0] = caddr | ((command) ? CMD_FRAME : 0);
@@ -1072,13 +1074,13 @@
*
* Contruct and transmit Information (I) frame
*/
-void irlap_send_i_frame(struct irlap_cb *self, struct sk_buff *skb,
- int command)
+void irlap_send_i_frame(struct irlap_cb *self, struct sk_buff *skb,
+ int command)
{
/* Insert connection address */
skb->data[0] = self->caddr;
skb->data[0] |= (command) ? CMD_FRAME : 0;
-
+
/* Insert next to receive (Vr) */
skb->data[1] |= (self->vr << 5); /* insert nr */
@@ -1091,9 +1093,9 @@
* Receive and parse an I (Information) frame, no harm in making it inline
* since it's called only from one single place (irlap_driver_rcv).
*/
-static inline void irlap_recv_i_frame(struct irlap_cb *self,
- struct sk_buff *skb,
- struct irlap_info *info, int command)
+static inline void irlap_recv_i_frame(struct irlap_cb *self,
+ struct sk_buff *skb,
+ struct irlap_info *info, int command)
{
info->nr = skb->data[1] >> 5; /* Next to receive */
info->pf = skb->data[1] & PF_BIT; /* Final bit */
@@ -1112,7 +1114,7 @@
* Receive and parse an Unnumbered Information (UI) frame
*
*/
-static void irlap_recv_ui_frame(struct irlap_cb *self, struct sk_buff *skb,
+static void irlap_recv_ui_frame(struct irlap_cb *self, struct sk_buff *skb,
struct irlap_info *info)
{
IRDA_DEBUG( 4, "%s()\n", __FUNCTION__);
@@ -1128,19 +1130,19 @@
* Received Frame Reject response.
*
*/
-static void irlap_recv_frmr_frame(struct irlap_cb *self, struct sk_buff *skb,
- struct irlap_info *info)
+static void irlap_recv_frmr_frame(struct irlap_cb *self, struct sk_buff *skb,
+ struct irlap_info *info)
{
__u8 *frame;
int w, x, y, z;
IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
-
+
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
ASSERT(skb != NULL, return;);
ASSERT(info != NULL, return;);
-
+
frame = skb->data;
info->nr = frame[2] >> 5; /* Next to receive */
@@ -1151,11 +1153,11 @@
x = frame[3] & 0x02;
y = frame[3] & 0x04;
z = frame[3] & 0x08;
-
+
if (w) {
IRDA_DEBUG(0, "Rejected control field is undefined or not "
"implemented.\n");
- }
+ }
if (x) {
IRDA_DEBUG(0, "Rejected control field was invalid because it "
"contained a non permitted I field.\n");
@@ -1178,7 +1180,7 @@
* Send a test frame response
*
*/
-void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr,
+void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr,
struct sk_buff *cmd)
{
struct sk_buff *skb;
@@ -1191,7 +1193,7 @@
/* Broadcast frames must include saddr and daddr fields */
if (caddr == CBROADCAST) {
- frame = (struct test_frame *)
+ frame = (struct test_frame *)
skb_put(skb, sizeof(struct test_frame));
/* Insert the swapped addresses */
@@ -1218,28 +1220,28 @@
* Receive a test frame
*
*/
-static void irlap_recv_test_frame(struct irlap_cb *self, struct sk_buff *skb,
+static void irlap_recv_test_frame(struct irlap_cb *self, struct sk_buff *skb,
struct irlap_info *info, int command)
{
struct test_frame *frame;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
-
+
frame = (struct test_frame *) skb->data;
-
+
/* Broadcast frames must carry saddr and daddr fields */
if (info->caddr == CBROADCAST) {
if (skb->len < sizeof(struct test_frame)) {
IRDA_DEBUG(0, "%s() test frame to short!\n", __FUNCTION__);
return;
}
-
+
/* Read and swap addresses */
- info->daddr = le32_to_cpu(frame->saddr);
- info->saddr = le32_to_cpu(frame->daddr);
+ info->daddr = le32_to_cpu(get_unaligned(&frame->saddr));
+ info->saddr = le32_to_cpu(get_unaligned(&frame->daddr));
/* Make sure frame is addressed to us */
- if ((info->saddr != self->saddr) &&
+ if ((info->saddr != self->saddr) &&
(info->saddr != BROADCAST)) {
return;
}
@@ -1254,18 +1256,18 @@
/*
* Function irlap_driver_rcv (skb, netdev, ptype)
*
- * Called when a frame is received. Dispatches the right receive function
+ * Called when a frame is received. Dispatches the right receive function
* for processing of the frame.
*
*/
-int irlap_driver_rcv(struct sk_buff *skb, struct net_device *dev,
+int irlap_driver_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype)
{
struct irlap_info info;
struct irlap_cb *self;
int command;
__u8 control;
-
+
/* FIXME: should we get our own field? */
self = (struct irlap_cb *) dev->atalk_ptr;
@@ -1281,10 +1283,10 @@
dev_kfree_skb(skb);
return -1;
}
-
+
command = skb->data[0] & CMD_FRAME;
info.caddr = skb->data[0] & CBROADCAST;
-
+
info.pf = skb->data[1] & PF_BIT;
info.control = skb->data[1] & ~PF_BIT; /* Mask away poll/final bit */
@@ -1295,7 +1297,7 @@
IRDA_DEBUG(0, "%s(), wrong connection address!\n", __FUNCTION__);
goto out;
}
- /*
+ /*
* Optimize for the common case and check if the frame is an
* I(nformation) frame. Only I-frames have bit 0 set to 0
*/
@@ -1304,11 +1306,11 @@
goto out;
}
/*
- * We now check is the frame is an S(upervisory) frame. Only
+ * We now check is the frame is an S(upervisory) frame. Only
* S-frames have bit 0 set to 1 and bit 1 set to 0
*/
if (~control & 0x02) {
- /*
+ /*
* Received S(upervisory) frame, check which frame type it is
* only the first nibble is of interest
*/
@@ -1332,8 +1334,8 @@
}
goto out;
}
- /*
- * This must be a C(ontrol) frame
+ /*
+ * This must be a C(ontrol) frame
*/
switch (control) {
case XID_RSP:
@@ -1369,6 +1371,6 @@
break;
}
out:
- dev_kfree_skb(skb);
+ dev_kfree_skb(skb);
return 0;
}
diff -urN linux-2.4.26/net/irda/irttp.c linux-2.4.26-vrs1/net/irda/irttp.c
--- linux-2.4.26/net/irda/irttp.c 2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.26-vrs1/net/irda/irttp.c 2004-01-14 21:39:31.000000000 +0000
@@ -1665,8 +1665,8 @@
}
self->rx_sdu_size = 0;
}
-
- /*
+
+ /*
* It's not trivial to keep track of how many credits are available
* by incrementing at each packet, because delivery may fail
* (irttp_do_data_indication() may requeue the frame) and because
@@ -1676,7 +1676,7 @@
* to send remote_credit.
* No need to spinlock, write is atomic and self correcting...
* Jean II
- */
+ */
self->avail_credit = (self->initial_credit -
(self->remote_credit +
skb_queue_len(&self->rx_queue) +
diff -urN linux-2.4.26/net/sched/Config.in linux-2.4.26-vrs1/net/sched/Config.in
--- linux-2.4.26/net/sched/Config.in 2004-04-19 11:44:28.000000000 +0100
+++ linux-2.4.26-vrs1/net/sched/Config.in 2004-04-18 21:47:52.000000000 +0100
@@ -3,9 +3,9 @@
#
tristate ' CBQ packet scheduler' CONFIG_NET_SCH_CBQ
tristate ' HTB packet scheduler' CONFIG_NET_SCH_HTB
-tristate ' CSZ packet scheduler' CONFIG_NET_SCH_CSZ
+dep_tristate ' CSZ packet scheduler (experimental)' CONFIG_NET_SCH_CSZ $CONFIG_EXPERIMENTAL
#tristate ' H-PFQ packet scheduler' CONFIG_NET_SCH_HPFQ
-tristate ' H-FSC packet scheduler' CONFIG_NET_SCH_HFSC
+tristate ' H-FSC packet scheduler' CONFIG_NET_SCH_HFCS
if [ "$CONFIG_ATM" = "y" -o "$CONFIG_ATM" = "m" ]; then
dep_tristate ' ATM pseudo-scheduler' CONFIG_NET_SCH_ATM $CONFIG_ATM
fi
|