aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/lantiq/patches-4.1/0001-MIPS-lantiq-add-pcie-driver.patch
blob: e65e9826b86b8f41f7f311302bcb225c83db4bf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
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
From 6f933347d0b4ed02d9534f5fa07f7b99f13eeaa1 Mon Sep 17 00:00:00 2001
From: John Crispin <blogic@openwrt.org>
Date: Thu, 7 Aug 2014 18:12:28 +0200
Subject: [PATCH 01/36] MIPS: lantiq: add pcie driver

Signed-off-by: John Crispin <blogic@openwrt.org>
---
 arch/mips/lantiq/Kconfig           |   10 +
 arch/mips/lantiq/xway/sysctrl.c    |    2 +
 arch/mips/pci/Makefile             |    2 +
 arch/mips/pci/fixup-lantiq-pcie.c  |   82 +++
 arch/mips/pci/fixup-lantiq.c       |    5 +-
 arch/mips/pci/ifxmips_pci_common.h |   57 ++
 arch/mips/pci/ifxmips_pcie.c       | 1099 ++++++++++++++++++++++++++++++
 arch/mips/pci/ifxmips_pcie.h       |  135 ++++
 arch/mips/pci/ifxmips_pcie_ar10.h  |  290 ++++++++
 arch/mips/pci/ifxmips_pcie_msi.c   |  392 +++++++++++
 arch/mips/pci/ifxmips_pcie_phy.c   |  478 +++++++++++++
 arch/mips/pci/ifxmips_pcie_pm.c    |  176 +++++
 arch/mips/pci/ifxmips_pcie_pm.h    |   36 +
 arch/mips/pci/ifxmips_pcie_reg.h   | 1001 +++++++++++++++++++++++++++
 arch/mips/pci/ifxmips_pcie_vr9.h   |  271 ++++++++
 arch/mips/pci/pci.c                |   25 +
 arch/mips/pci/pcie-lantiq.h        | 1305 ++++++++++++++++++++++++++++++++++++
 drivers/pci/pcie/aer/Kconfig       |    2 +-
 include/linux/pci.h                |    2 +
 include/linux/pci_ids.h            |    6 +
 20 files changed, 5374 insertions(+), 2 deletions(-)
 create mode 100644 arch/mips/pci/fixup-lantiq-pcie.c
 create mode 100644 arch/mips/pci/ifxmips_pci_common.h
 create mode 100644 arch/mips/pci/ifxmips_pcie.c
 create mode 100644 arch/mips/pci/ifxmips_pcie.h
 create mode 100644 arch/mips/pci/ifxmips_pcie_ar10.h
 create mode 100644 arch/mips/pci/ifxmips_pcie_msi.c
 create mode 100644 arch/mips/pci/ifxmips_pcie_phy.c
 create mode 100644 arch/mips/pci/ifxmips_pcie_pm.c
 create mode 100644 arch/mips/pci/ifxmips_pcie_pm.h
 create mode 100644 arch/mips/pci/ifxmips_pcie_reg.h
 create mode 100644 arch/mips/pci/ifxmips_pcie_vr9.h
 create mode 100644 arch/mips/pci/pcie-lantiq.h

--- a/arch/mips/lantiq/Kconfig
+++ b/arch/mips/lantiq/Kconfig
@@ -17,6 +17,7 @@ config SOC_XWAY
 	bool "XWAY"
 	select SOC_TYPE_XWAY
 	select HW_HAS_PCI
+	select ARCH_SUPPORTS_MSI
 
 config SOC_FALCON
 	bool "FALCON"
@@ -37,6 +38,15 @@ config PCI_LANTIQ
 	bool "PCI Support"
 	depends on SOC_XWAY && PCI
 
+config PCIE_LANTIQ
+	bool "PCIE Support"
+	depends on SOC_XWAY && PCI
+
+config PCIE_LANTIQ_MSI
+	bool
+	depends on PCIE_LANTIQ && PCI_MSI
+	default y
+
 config XRX200_PHY_FW
 	bool "XRX200 PHY firmware loader"
 	depends on SOC_XWAY
--- a/arch/mips/lantiq/xway/sysctrl.c
+++ b/arch/mips/lantiq/xway/sysctrl.c
@@ -377,6 +377,8 @@ void __init ltq_soc_init(void)
 				PMU_PPE_EMA | PMU_PPE_TC | PMU_PPE_SLL01 |
 				PMU_PPE_QSB | PMU_PPE_TOP);
 		clkdev_add_pmu("1f203000.rcu", "gphy", 0, PMU_GPHY);
+		pmu_w32(~0, PMU_PWDSR1);
+		pmu_w32(pmu_r32(PMU_PWDSR) & ~PMU_PCIE_CLK, PMU_PWDSR);
 	} else if (of_machine_is_compatible("lantiq,ar9")) {
 		clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(),
 				ltq_ar9_fpi_hz(), CLOCK_250M);
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -45,6 +45,8 @@ obj-$(CONFIG_LANTIQ)		+= fixup-lantiq.o
 obj-$(CONFIG_PCI_LANTIQ)	+= pci-lantiq.o ops-lantiq.o
 obj-$(CONFIG_SOC_RT288X)	+= pci-rt2880.o
 obj-$(CONFIG_SOC_RT3883)	+= pci-rt3883.o
+obj-$(CONFIG_PCIE_LANTIQ)	+= ifxmips_pcie_phy.o ifxmips_pcie.o fixup-lantiq-pcie.o
+obj-$(CONFIG_PCIE_LANTIQ_MSI)	+= pcie-lantiq-msi.o
 obj-$(CONFIG_TANBAC_TB0219)	+= fixup-tb0219.o
 obj-$(CONFIG_TANBAC_TB0226)	+= fixup-tb0226.o
 obj-$(CONFIG_TANBAC_TB0287)	+= fixup-tb0287.o
--- /dev/null
+++ b/arch/mips/pci/fixup-lantiq-pcie.c
@@ -0,0 +1,82 @@
+/******************************************************************************
+**
+** FILE NAME    : ifxmips_fixup_pcie.c
+** PROJECT      : IFX UEIP for VRX200
+** MODULES      : PCIe 
+**
+** DATE         : 02 Mar 2009
+** AUTHOR       : Lei Chuanhua
+** DESCRIPTION  : PCIe Root Complex Driver
+** COPYRIGHT    :       Copyright (c) 2009
+**                      Infineon Technologies AG
+**                      Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+**    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.
+** HISTORY
+** $Version $Date        $Author         $Comment
+** 0.0.1    17 Mar,2009  Lei Chuanhua    Initial version
+*******************************************************************************/
+/*!
+ \file ifxmips_fixup_pcie.c
+ \ingroup IFX_PCIE  
+ \brief PCIe Fixup functions source file
+*/
+#include <linux/pci.h>
+#include <linux/pci_regs.h>
+#include <linux/pci_ids.h>
+
+#include <lantiq_soc.h>
+
+#include "pcie-lantiq.h"
+
+#define PCI_VENDOR_ID_INFINEON         0x15D1
+#define PCI_DEVICE_ID_INFINEON_DANUBE  0x000F
+#define PCI_DEVICE_ID_INFINEON_PCIE    0x0011
+#define PCI_VENDOR_ID_LANTIQ        0x1BEF
+#define PCI_DEVICE_ID_LANTIQ_PCIE       0x0011
+
+
+
+static void
+ifx_pcie_fixup_resource(struct pci_dev *dev)
+{
+    u32 reg;
+
+    IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: enter\n", __func__, pci_name(dev));
+
+    printk("%s: fixup host controller %s (%04x:%04x)\n", 
+        __func__, pci_name(dev), dev->vendor, dev->device); 
+
+   /* Setup COMMAND register */
+    reg = PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER /* | 
+          PCI_COMMAND_INTX_DISABLE */| PCI_COMMAND_SERR;
+    pci_write_config_word(dev, PCI_COMMAND, reg);
+    IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: exit\n", __func__, pci_name(dev));
+}
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INFINEON, PCI_DEVICE_ID_INFINEON_PCIE, ifx_pcie_fixup_resource);
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LANTIQ, PCI_VENDOR_ID_LANTIQ, ifx_pcie_fixup_resource);
+
+static void
+ifx_pcie_rc_class_early_fixup(struct pci_dev *dev)
+{
+    IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: enter\n", __func__, pci_name(dev));
+
+    if (dev->devfn == PCI_DEVFN(0, 0) &&
+        (dev->class >> 8) == PCI_CLASS_BRIDGE_HOST) {
+
+        dev->class = (PCI_CLASS_BRIDGE_PCI << 8) | (dev->class & 0xff);
+
+        printk(KERN_INFO "%s: fixed pcie host bridge to pci-pci bridge\n", __func__);
+    }
+    IFX_PCIE_PRINT(PCIE_MSG_FIXUP, "%s dev %s: exit\n", __func__, pci_name(dev));
+    mdelay(10);
+}
+
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INFINEON, PCI_DEVICE_ID_INFINEON_PCIE,
+     ifx_pcie_rc_class_early_fixup);
+
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LANTIQ, PCI_DEVICE_ID_LANTIQ_PCIE,
+     ifx_pcie_rc_class_early_fixup);
--- a/arch/mips/pci/fixup-lantiq.c
+++ b/arch/mips/pci/fixup-lantiq.c
@@ -8,12 +8,18 @@
 
 #include <linux/of_irq.h>
 #include <linux/of_pci.h>
+#include "ifxmips_pci_common.h"
 
 int (*ltq_pci_plat_arch_init)(struct pci_dev *dev) = NULL;
 int (*ltq_pci_plat_dev_init)(struct pci_dev *dev) = NULL;
 
 int pcibios_plat_dev_init(struct pci_dev *dev)
 {
+#ifdef CONFIG_PCIE_LANTIQ
+	if (pci_find_capability(dev, PCI_CAP_ID_EXP))
+		ifx_pcie_bios_plat_dev_init(dev);
+#endif
+
 	if (ltq_pci_plat_arch_init)
 		return ltq_pci_plat_arch_init(dev);
 
@@ -25,5 +31,10 @@ int pcibios_plat_dev_init(struct pci_dev
 
 int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
+#ifdef CONFIG_PCIE_LANTIQ
+	if (pci_find_capability(dev, PCI_CAP_ID_EXP))
+		return ifx_pcie_bios_map_irq(dev, slot, pin);
+#endif
+
 	return of_irq_parse_and_map_pci(dev, slot, pin);
 }
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pci_common.h
@@ -0,0 +1,57 @@
+/******************************************************************************
+**
+** FILE NAME    : ifxmips_pci_common.h
+** PROJECT      : IFX UEIP
+** MODULES      : PCI subsystem
+**
+** DATE         : 30 June 2009
+** AUTHOR       : Lei Chuanhua
+** DESCRIPTION  : PCIe Root Complex Driver
+** COPYRIGHT    :       Copyright (c) 2009
+**                      Infineon Technologies AG
+**                      Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+**    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.
+** HISTORY
+** $Version $Date        $Author         $Comment
+** 0.0.1    30 June,2009  Lei Chuanhua    Initial version
+*******************************************************************************/
+
+#ifndef IFXMIPS_PCI_COMMON_H
+#define IFXMIPS_PCI_COMMON_H
+#include <linux/version.h>
+/*!
+ \defgroup IFX_PCI_COM  IFX PCI/PCIe common parts for OS integration  
+ \brief  PCI/PCIe common parts
+*/
+
+/*!
+ \defgroup IFX_PCI_COM_OS OS APIs
+ \ingroup IFX_PCI_COM
+ \brief PCI/PCIe bus driver OS interface functions
+*/
+/*!
+  \file ifxmips_pci_common.h
+  \ingroup IFX_PCI_COM
+  \brief PCI/PCIe bus driver common OS header file
+*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
+#define IFX_PCI_CONST
+#else
+#define IFX_PCI_CONST const
+#endif
+#ifdef CONFIG_IFX_PCI
+extern int ifx_pci_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin);
+extern int ifx_pci_bios_plat_dev_init(struct pci_dev *dev);
+#endif /* COFNIG_IFX_PCI */
+
+#ifdef CONFIG_PCIE_LANTIQ
+extern int ifx_pcie_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin);
+extern int ifx_pcie_bios_plat_dev_init(struct pci_dev *dev);
+#endif
+
+#endif /* IFXMIPS_PCI_COMMON_H */
+
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pcie.c
@@ -0,0 +1,1092 @@
+/*
+ *  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.
+ *
+ *  Copyright (C) 2009 Lei Chuanhua <chuanhua.lei@infineon.com>
+ *  Copyright (C) 2013 John Crispin <blogic@openwrt.org>
+ */
+
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/mm.h>
+#include <asm/paccess.h>
+#include <linux/pci.h>
+#include <linux/pci_regs.h>
+#include <linux/module.h>
+
+#include "ifxmips_pcie.h"
+#include "ifxmips_pcie_reg.h"
+
+/* Enable 32bit io due to its mem mapped io nature */
+#define IFX_PCIE_ERROR_INT
+#define IFX_PCIE_IO_32BIT
+
+#define IFX_PCIE_IR                     (INT_NUM_IM4_IRL0 + 25)
+#define IFX_PCIE_INTA                   (INT_NUM_IM4_IRL0 + 8)
+#define IFX_PCIE_INTB                   (INT_NUM_IM4_IRL0 + 9)
+#define IFX_PCIE_INTC                   (INT_NUM_IM4_IRL0 + 10)
+#define IFX_PCIE_INTD                   (INT_NUM_IM4_IRL0 + 11)
+#define MS(_v, _f)  (((_v) & (_f)) >> _f##_S)
+#define SM(_v, _f)  (((_v) << _f##_S) & (_f))
+#define IFX_REG_SET_BIT(_f, _r) \
+	IFX_REG_W32((IFX_REG_R32((_r)) &~ (_f)) | (_f), (_r))
+
+#define IFX_PCIE_LTSSM_ENABLE_TIMEOUT 10
+
+static DEFINE_SPINLOCK(ifx_pcie_lock);
+
+u32 g_pcie_debug_flag = PCIE_MSG_ANY & (~PCIE_MSG_CFG);
+
+static ifx_pcie_irq_t pcie_irqs[IFX_PCIE_CORE_NR] = {
+    {
+        .ir_irq = {
+            .irq  = IFX_PCIE_IR,
+            .name = "ifx_pcie_rc0",
+        },
+
+        .legacy_irq = {
+            {
+                .irq_bit = PCIE_IRN_INTA,
+                .irq     = IFX_PCIE_INTA,
+            },
+            {
+                .irq_bit = PCIE_IRN_INTB,
+                .irq     = IFX_PCIE_INTB,
+            },
+            {
+                .irq_bit = PCIE_IRN_INTC,
+                .irq     = IFX_PCIE_INTC,
+            },
+            {
+                .irq_bit = PCIE_IRN_INTD,
+                .irq     = IFX_PCIE_INTD,
+            },
+        },
+    },
+
+};
+
+void ifx_pcie_debug(const char *fmt, ...)
+{
+	static char buf[256] = {0};      /* XXX */
+	va_list ap;
+
+	va_start(ap, fmt);
+	vsnprintf(buf, sizeof(buf), fmt, ap);
+	va_end(ap);
+
+	printk("%s", buf);
+}
+
+
+static inline int pcie_ltssm_enable(int pcie_port)
+{
+	int i;
+
+	/* Enable LTSSM */
+	IFX_REG_W32(PCIE_RC_CCR_LTSSM_ENABLE, PCIE_RC_CCR(pcie_port));
+
+	/* Wait for the link to come up */
+	for (i = 0; i < IFX_PCIE_LTSSM_ENABLE_TIMEOUT; i++) {
+		if (!(IFX_REG_R32(PCIE_LCTLSTS(pcie_port)) & PCIE_LCTLSTS_RETRAIN_PENDING))
+			return 0;
+		udelay(10);
+	}
+
+	printk("%s link timeout!!!!!\n", __func__);
+	return -1;
+}
+
+static inline void pcie_status_register_clear(int pcie_port)
+{
+	IFX_REG_W32(0, PCIE_RC_DR(pcie_port));
+	IFX_REG_W32(0, PCIE_PCICMDSTS(pcie_port));
+	IFX_REG_W32(0, PCIE_DCTLSTS(pcie_port));
+	IFX_REG_W32(0, PCIE_LCTLSTS(pcie_port));
+	IFX_REG_W32(0, PCIE_SLCTLSTS(pcie_port));
+	IFX_REG_W32(0, PCIE_RSTS(pcie_port));
+	IFX_REG_W32(0, PCIE_UES_R(pcie_port));
+	IFX_REG_W32(0, PCIE_UEMR(pcie_port));
+	IFX_REG_W32(0, PCIE_UESR(pcie_port));
+	IFX_REG_W32(0, PCIE_CESR(pcie_port));
+	IFX_REG_W32(0, PCIE_CEMR(pcie_port));
+	IFX_REG_W32(0, PCIE_RESR(pcie_port));
+	IFX_REG_W32(0, PCIE_PVCCRSR(pcie_port));
+	IFX_REG_W32(0, PCIE_VC0_RSR0(pcie_port));
+	IFX_REG_W32(0, PCIE_TPFCS(pcie_port));
+	IFX_REG_W32(0, PCIE_TNPFCS(pcie_port));
+	IFX_REG_W32(0, PCIE_TCFCS(pcie_port));
+	IFX_REG_W32(0, PCIE_QSR(pcie_port));
+	IFX_REG_W32(0, PCIE_IOBLSECS(pcie_port));
+}
+
+static inline int ifx_pcie_link_up(int pcie_port)
+{
+    return (IFX_REG_R32(PCIE_PHY_SR(pcie_port)) & PCIE_PHY_SR_PHY_LINK_UP) ? 1 : 0;
+}
+
+
+static inline void pcie_mem_io_setup(int pcie_port)
+{
+    u32 reg;
+    /*
+     * BAR[0:1] readonly register 
+     * RC contains only minimal BARs for packets mapped to this device 
+     * Mem/IO filters defines a range of memory occupied by memory mapped IO devices that
+     * reside on the downstream side fo the bridge.
+     */
+    reg = SM((PCIE_MEM_PHY_PORT_TO_END(pcie_port) >> 20), PCIE_MBML_MEM_LIMIT_ADDR)
+        | SM((PCIE_MEM_PHY_PORT_TO_BASE(pcie_port) >> 20), PCIE_MBML_MEM_BASE_ADDR);
+
+    IFX_REG_W32(reg, PCIE_MBML(pcie_port));
+
+
+#ifdef IFX_PCIE_PREFETCH_MEM_64BIT
+    reg = SM((PCIE_MEM_PHY_PORT_TO_END(pcie_port) >> 20), PCIE_PMBL_END_ADDR)
+        | SM((PCIE_MEM_PHY_PORT_TO_BASE(pcie_port) >> 20), PCIE_PMBL_UPPER_12BIT)
+        | PCIE_PMBL_64BIT_ADDR;
+    IFX_REG_W32(reg, PCIE_PMBL(pcie_port));
+
+    /* Must configure upper 32bit */
+    IFX_REG_W32(0, PCIE_PMBU32(pcie_port));
+    IFX_REG_W32(0, PCIE_PMLU32(pcie_port));
+#else
+    /* PCIe_PBML, same as MBML */
+    IFX_REG_W32(IFX_REG_R32(PCIE_MBML(pcie_port)), PCIE_PMBL(pcie_port));
+#endif 
+
+    /* IO Address Range */
+    reg = SM((PCIE_IO_PHY_PORT_TO_END(pcie_port) >> 12), PCIE_IOBLSECS_IO_LIMIT_ADDR)
+        | SM((PCIE_IO_PHY_PORT_TO_BASE(pcie_port) >> 12), PCIE_IOBLSECS_IO_BASE_ADDR);
+#ifdef IFX_PCIE_IO_32BIT    
+    reg |= PCIE_IOBLSECS_32BIT_IO_ADDR;
+#endif /* IFX_PCIE_IO_32BIT */
+    IFX_REG_W32(reg, PCIE_IOBLSECS(pcie_port));
+
+#ifdef IFX_PCIE_IO_32BIT
+    reg = SM((PCIE_IO_PHY_PORT_TO_END(pcie_port) >> 16), PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT)
+        | SM((PCIE_IO_PHY_PORT_TO_BASE(pcie_port) >> 16), PCIE_IO_BANDL_UPPER_16BIT_IO_BASE);
+    IFX_REG_W32(reg, PCIE_IO_BANDL(pcie_port));
+
+#endif /* IFX_PCIE_IO_32BIT */
+}
+
+static inline void
+pcie_device_setup(int pcie_port)
+{
+    u32 reg;
+
+    /* Device capability register, set up Maximum payload size */
+    reg = IFX_REG_R32(PCIE_DCAP(pcie_port));
+    reg |= PCIE_DCAP_ROLE_BASE_ERR_REPORT;
+    reg |= SM(PCIE_MAX_PAYLOAD_128, PCIE_DCAP_MAX_PAYLOAD_SIZE);
+
+    /* Only available for EP */
+    reg &= ~(PCIE_DCAP_EP_L0S_LATENCY | PCIE_DCAP_EP_L1_LATENCY);
+    IFX_REG_W32(reg, PCIE_DCAP(pcie_port));
+
+    /* Device control and status register */
+    /* Set Maximum Read Request size for the device as a Requestor */
+    reg = IFX_REG_R32(PCIE_DCTLSTS(pcie_port));
+
+    /* 
+     * Request size can be larger than the MPS used, but the completions returned 
+     * for the read will be bounded by the MPS size.
+     * In our system, Max request size depends on AHB burst size. It is 64 bytes.
+     * but we set it as 128 as minimum one.
+     */
+    reg |= SM(PCIE_MAX_PAYLOAD_128, PCIE_DCTLSTS_MAX_READ_SIZE)
+            | SM(PCIE_MAX_PAYLOAD_128, PCIE_DCTLSTS_MAX_PAYLOAD_SIZE);
+
+    /* Enable relaxed ordering, no snoop, and all kinds of errors */
+    reg |= PCIE_DCTLSTS_RELAXED_ORDERING_EN | PCIE_DCTLSTS_ERR_EN | PCIE_DCTLSTS_NO_SNOOP_EN;
+
+    IFX_REG_W32(reg, PCIE_DCTLSTS(pcie_port));
+}
+
+static inline void
+pcie_link_setup(int pcie_port)
+{
+    u32 reg;
+
+    /*
+     * XXX, Link capability register, bit 18 for EP CLKREQ# dynamic clock management for L1, L2/3 CPM 
+     * L0s is reported during link training via TS1 order set by N_FTS
+     */
+    reg = IFX_REG_R32(PCIE_LCAP(pcie_port));
+    reg &= ~PCIE_LCAP_L0S_EIXT_LATENCY;
+    reg |= SM(3, PCIE_LCAP_L0S_EIXT_LATENCY);
+    IFX_REG_W32(reg, PCIE_LCAP(pcie_port));
+
+    /* Link control and status register */
+    reg = IFX_REG_R32(PCIE_LCTLSTS(pcie_port));
+
+    /* Link Enable, ASPM enabled  */
+    reg &= ~PCIE_LCTLSTS_LINK_DISABLE;
+
+#ifdef CONFIG_PCIEASPM
+    /*  
+     * We use the same physical reference clock that the platform provides on the connector 
+     * It paved the way for ASPM to calculate the new exit Latency
+     */
+    reg |= PCIE_LCTLSTS_SLOT_CLK_CFG;
+    reg |= PCIE_LCTLSTS_COM_CLK_CFG;
+    /*
+     * We should disable ASPM by default except that we have dedicated power management support
+     * Enable ASPM will cause the system hangup/instability, performance degration
+     */
+    reg |= PCIE_LCTLSTS_ASPM_ENABLE;
+#else
+    reg &= ~PCIE_LCTLSTS_ASPM_ENABLE;
+#endif /* CONFIG_PCIEASPM */
+
+    /* 
+     * The maximum size of any completion with data packet is bounded by the MPS setting 
+     * in  device control register 
+     */
+
+    /* RCB may cause multiple split transactions, two options available, we use 64 byte RCB */
+    reg &= ~ PCIE_LCTLSTS_RCB128;
+
+    IFX_REG_W32(reg, PCIE_LCTLSTS(pcie_port));
+}
+
+static inline void pcie_error_setup(int pcie_port)
+{
+	u32 reg;
+
+	/* 
+	* Forward ERR_COR, ERR_NONFATAL, ERR_FATAL to the backbone 
+	* Poisoned write TLPs and completions indicating poisoned TLPs will set the PCIe_PCICMDSTS.MDPE 
+	*/
+	reg = IFX_REG_R32(PCIE_INTRBCTRL(pcie_port));
+	reg |= PCIE_INTRBCTRL_SERR_ENABLE | PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE;
+
+	IFX_REG_W32(reg, PCIE_INTRBCTRL(pcie_port));
+
+	/* Uncorrectable Error Mask Register, Unmask <enable> all bits in PCIE_UESR */
+	reg = IFX_REG_R32(PCIE_UEMR(pcie_port));
+	reg &= ~PCIE_ALL_UNCORRECTABLE_ERR;
+	IFX_REG_W32(reg, PCIE_UEMR(pcie_port));
+
+	/* Uncorrectable Error Severity Register, ALL errors are FATAL */
+	IFX_REG_W32(PCIE_ALL_UNCORRECTABLE_ERR, PCIE_UESR(pcie_port));
+
+	/* Correctable Error Mask Register, unmask <enable> all bits */
+	reg = IFX_REG_R32(PCIE_CEMR(pcie_port));
+	reg &= ~PCIE_CORRECTABLE_ERR;
+	IFX_REG_W32(reg, PCIE_CEMR(pcie_port));
+
+	/* Advanced Error Capabilities and Control Registr */
+	reg = IFX_REG_R32(PCIE_AECCR(pcie_port));
+	reg |= PCIE_AECCR_ECRC_CHECK_EN | PCIE_AECCR_ECRC_GEN_EN;
+	IFX_REG_W32(reg, PCIE_AECCR(pcie_port));
+
+	/* Root Error Command Register, Report all types of errors */
+	reg = IFX_REG_R32(PCIE_RECR(pcie_port));
+	reg |= PCIE_RECR_ERR_REPORT_EN;
+	IFX_REG_W32(reg, PCIE_RECR(pcie_port));
+
+	/* Clear the Root status register */
+	reg = IFX_REG_R32(PCIE_RESR(pcie_port));
+	IFX_REG_W32(reg, PCIE_RESR(pcie_port));
+}
+
+static inline void pcie_port_logic_setup(int pcie_port)
+{
+	u32 reg;
+
+	/* FTS number, default 12, increase to 63, may increase time from/to L0s to L0  */
+	reg = IFX_REG_R32(PCIE_AFR(pcie_port));
+	reg &= ~(PCIE_AFR_FTS_NUM | PCIE_AFR_COM_FTS_NUM);
+	reg |= SM(PCIE_AFR_FTS_NUM_DEFAULT, PCIE_AFR_FTS_NUM)
+		| SM(PCIE_AFR_FTS_NUM_DEFAULT, PCIE_AFR_COM_FTS_NUM);
+	/* L0s and L1 entry latency */
+	reg &= ~(PCIE_AFR_L0S_ENTRY_LATENCY | PCIE_AFR_L1_ENTRY_LATENCY);
+	reg |= SM(PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT, PCIE_AFR_L0S_ENTRY_LATENCY)
+		| SM(PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT, PCIE_AFR_L1_ENTRY_LATENCY);
+	IFX_REG_W32(reg, PCIE_AFR(pcie_port));
+
+
+	/* Port Link Control Register */
+	reg = IFX_REG_R32(PCIE_PLCR(pcie_port));
+	reg |= PCIE_PLCR_DLL_LINK_EN;  /* Enable the DLL link */
+	IFX_REG_W32(reg, PCIE_PLCR(pcie_port));
+
+	/* Lane Skew Register */
+	reg = IFX_REG_R32(PCIE_LSR(pcie_port));
+	/* Enable ACK/NACK and FC */
+	reg &= ~(PCIE_LSR_ACKNAK_DISABLE | PCIE_LSR_FC_DISABLE);
+	IFX_REG_W32(reg, PCIE_LSR(pcie_port));
+
+	/* Symbol Timer Register and Filter Mask Register 1 */
+	reg = IFX_REG_R32(PCIE_STRFMR(pcie_port));
+
+	/* Default SKP interval is very accurate already, 5us */
+	/* Enable IO/CFG transaction */
+	reg |= PCIE_STRFMR_RX_CFG_TRANS_ENABLE | PCIE_STRFMR_RX_IO_TRANS_ENABLE;
+	/* Disable FC WDT */
+	reg &= ~PCIE_STRFMR_FC_WDT_DISABLE;
+	IFX_REG_W32(reg, PCIE_STRFMR(pcie_port));
+
+	/* Filter Masker Register 2 */
+	reg = IFX_REG_R32(PCIE_FMR2(pcie_port));
+	reg |= PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 | PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1;
+	IFX_REG_W32(reg, PCIE_FMR2(pcie_port));
+
+	/* VC0 Completion Receive Queue Control Register */
+	reg = IFX_REG_R32(PCIE_VC0_CRQCR(pcie_port));
+	reg &= ~PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE;
+	reg |= SM(PCIE_VC0_TLP_QUEUE_MODE_BYPASS, PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE);
+	IFX_REG_W32(reg, PCIE_VC0_CRQCR(pcie_port));
+}
+
+static inline void pcie_rc_cfg_reg_setup(int pcie_port)
+{
+	u32 reg;
+
+	/* Disable LTSSM */
+	IFX_REG_W32(0, PCIE_RC_CCR(pcie_port)); /* Disable LTSSM */
+
+	pcie_mem_io_setup(pcie_port);
+
+	/* XXX, MSI stuff should only apply to EP */
+	/* MSI Capability: Only enable 32-bit addresses */
+	reg = IFX_REG_R32(PCIE_MCAPR(pcie_port));
+	reg &= ~PCIE_MCAPR_ADDR64_CAP;
+
+	reg |= PCIE_MCAPR_MSI_ENABLE;
+
+	/* Disable multiple message */
+	reg &= ~(PCIE_MCAPR_MULTI_MSG_CAP | PCIE_MCAPR_MULTI_MSG_ENABLE);
+	IFX_REG_W32(reg, PCIE_MCAPR(pcie_port));
+
+
+	/* Enable PME, Soft reset enabled */
+	reg = IFX_REG_R32(PCIE_PM_CSR(pcie_port));
+	reg |= PCIE_PM_CSR_PME_ENABLE | PCIE_PM_CSR_SW_RST;
+	IFX_REG_W32(reg, PCIE_PM_CSR(pcie_port));
+
+	/* setup the bus */
+	reg = SM(0, PCIE_BNR_PRIMARY_BUS_NUM) | SM(1, PCIE_PNR_SECONDARY_BUS_NUM) | SM(0xFF, PCIE_PNR_SUB_BUS_NUM);
+	IFX_REG_W32(reg, PCIE_BNR(pcie_port));
+
+
+	pcie_device_setup(pcie_port);
+	pcie_link_setup(pcie_port);
+	pcie_error_setup(pcie_port);
+
+	/* Root control and capabilities register */
+	reg = IFX_REG_R32(PCIE_RCTLCAP(pcie_port));
+	reg |= PCIE_RCTLCAP_SERR_ENABLE | PCIE_RCTLCAP_PME_INT_EN;
+	IFX_REG_W32(reg, PCIE_RCTLCAP(pcie_port));
+
+	/* Port VC Capability Register 2 */
+	reg = IFX_REG_R32(PCIE_PVC2(pcie_port));
+	reg &= ~PCIE_PVC2_VC_ARB_WRR;
+	reg |= PCIE_PVC2_VC_ARB_16P_FIXED_WRR;
+	IFX_REG_W32(reg, PCIE_PVC2(pcie_port));
+
+	/* VC0 Resource Capability Register */
+	reg = IFX_REG_R32(PCIE_VC0_RC(pcie_port));
+	reg &= ~PCIE_VC0_RC_REJECT_SNOOP;
+	IFX_REG_W32(reg, PCIE_VC0_RC(pcie_port));
+
+	pcie_port_logic_setup(pcie_port);
+}
+
+static int ifx_pcie_wait_phy_link_up(int pcie_port)
+{
+#define IFX_PCIE_PHY_LINK_UP_TIMEOUT  1000 /* XXX, tunable */
+    int i;
+
+    /* Wait for PHY link is up */
+    for (i = 0; i < IFX_PCIE_PHY_LINK_UP_TIMEOUT; i++) {
+        if (ifx_pcie_link_up(pcie_port)) {
+            break;
+        }
+        udelay(100);
+    }
+    if (i >= IFX_PCIE_PHY_LINK_UP_TIMEOUT) {
+        printk(KERN_ERR "%s timeout\n", __func__);
+        return -1;
+    }
+
+    /* Check data link up or not */
+    if (!(IFX_REG_R32(PCIE_RC_DR(pcie_port)) & PCIE_RC_DR_DLL_UP)) {
+        printk(KERN_ERR "%s DLL link is still down\n", __func__);
+        return -1;
+    }
+
+    /* Check Data link active or not */
+    if (!(IFX_REG_R32(PCIE_LCTLSTS(pcie_port)) & PCIE_LCTLSTS_DLL_ACTIVE)) {
+        printk(KERN_ERR "%s DLL is not active\n", __func__);
+        return -1;
+    }
+    return 0;
+}
+
+static inline int pcie_app_loigc_setup(int pcie_port)
+{
+	/* supress ahb bus errrors */
+	IFX_REG_W32(PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS, PCIE_AHB_CTRL(pcie_port));
+
+	/* Pull PCIe EP out of reset */
+	pcie_device_rst_deassert(pcie_port);
+
+	/* Start LTSSM training between RC and EP */
+	pcie_ltssm_enable(pcie_port);
+
+	/* Check PHY status after enabling LTSSM */
+	if (ifx_pcie_wait_phy_link_up(pcie_port) != 0)
+		return -1;
+
+	return 0;
+}
+
+/*
+ * The numbers below are directly from the PCIe spec table 3-4/5. 
+ */
+static inline void pcie_replay_time_update(int pcie_port)
+{
+	u32 reg;
+	int nlw;
+	int rtl;
+
+	reg = IFX_REG_R32(PCIE_LCTLSTS(pcie_port));
+
+	nlw = MS(reg, PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH);
+	switch (nlw) {
+	case PCIE_MAX_LENGTH_WIDTH_X1:
+		rtl = 1677;
+		break;
+	case PCIE_MAX_LENGTH_WIDTH_X2:
+		rtl = 867;
+		break;
+	case PCIE_MAX_LENGTH_WIDTH_X4:
+		rtl = 462;
+		break;
+	case PCIE_MAX_LENGTH_WIDTH_X8:
+		rtl = 258;
+		break;
+	default:
+		rtl = 1677;
+		break;
+	}
+	reg = IFX_REG_R32(PCIE_ALTRT(pcie_port));
+	reg &= ~PCIE_ALTRT_REPLAY_TIME_LIMIT;
+	reg |= SM(rtl, PCIE_ALTRT_REPLAY_TIME_LIMIT);
+	IFX_REG_W32(reg, PCIE_ALTRT(pcie_port));
+}
+
+/*
+ * Table 359 Enhanced Configuration Address Mapping1)
+ * 1) This table is defined in Table 7-1, page 341, PCI Express Base Specification v1.1
+ * Memory Address PCI Express Configuration Space
+ * A[(20+n-1):20] Bus Number 1 < n < 8
+ * A[19:15] Device Number
+ * A[14:12] Function Number
+ * A[11:8] Extended Register Number
+ * A[7:2] Register Number
+ * A[1:0] Along with size of the access, used to generate Byte Enables
+ * For VR9, only the address bits [22:0] are mapped to the configuration space:
+ * . Address bits [22:20] select the target bus (1-of-8)1)
+ * . Address bits [19:15] select the target device (1-of-32) on the bus
+ * . Address bits [14:12] select the target function (1-of-8) within the device.
+ * . Address bits [11:2] selects the target dword (1-of-1024) within the selected function.s configuration space
+ * . Address bits [1:0] define the start byte location within the selected dword.
+ */
+static inline u32 pcie_bus_addr(u8 bus_num, u16 devfn, int where)
+{
+	u32 addr;
+	u8  bus;
+
+	if (!bus_num) {
+		/* type 0 */
+		addr = ((PCI_SLOT(devfn) & 0x1F) << 15) | ((PCI_FUNC(devfn) & 0x7) << 12) | ((where & 0xFFF)& ~3);
+	} else {
+		bus = bus_num;
+		/* type 1, only support 8 buses  */
+		addr = ((bus & 0x7) << 20) | ((PCI_SLOT(devfn) & 0x1F) << 15) |
+			((PCI_FUNC(devfn) & 0x7) << 12) | ((where & 0xFFF) & ~3);
+	}
+	return addr;
+}
+
+static int pcie_valid_config(int pcie_port, int bus, int dev)
+{
+	/* RC itself */
+	if ((bus == 0) && (dev == 0)) {
+		return 1;
+	}
+
+	/* No physical link */
+	if (!ifx_pcie_link_up(pcie_port)) {
+		return 0;
+	}
+
+	/* Bus zero only has RC itself
+	* XXX, check if EP will be integrated 
+	*/
+	if ((bus == 0) && (dev != 0)) {
+		return 0;
+	}
+
+	/* Maximum 8 buses supported for VRX */
+	if (bus > 9) {
+		return 0;
+	}
+
+	/* 
+	 * PCIe is PtP link, one bus only supports only one device 
+	 * except bus zero and PCIe switch which is virtual bus device
+	 * The following two conditions really depends on the system design
+	 * and attached the device.
+	 * XXX, how about more new switch
+	*/
+	if ((bus == 1) && (dev != 0)) {
+		return 0;
+	}
+
+	if ((bus >= 3) && (dev != 0)) {
+		return 0;
+	}
+	return 1;
+}
+
+static inline u32 ifx_pcie_cfg_rd(int pcie_port, u32 reg)
+{
+    return IFX_REG_R32((volatile u32 *)(PCIE_CFG_PORT_TO_BASE(pcie_port) + reg));
+}
+
+static inline void ifx_pcie_cfg_wr(int pcie_port, unsigned int reg, u32 val)
+{
+    IFX_REG_W32( val, (volatile u32 *)(PCIE_CFG_PORT_TO_BASE(pcie_port) + reg));
+}
+
+static inline u32 ifx_pcie_rc_cfg_rd(int pcie_port, u32 reg)
+{
+    return IFX_REG_R32((volatile u32 *)(PCIE_RC_PORT_TO_BASE(pcie_port) + reg));
+}
+
+static inline void ifx_pcie_rc_cfg_wr(int pcie_port, unsigned int reg, u32 val)
+{
+	IFX_REG_W32(val, (volatile u32 *)(PCIE_RC_PORT_TO_BASE(pcie_port) + reg));
+}
+
+u32 ifx_pcie_bus_enum_read_hack(int where, u32 value)
+{
+	u32 tvalue = value;
+
+	if (where == PCI_PRIMARY_BUS) {
+		u8 primary, secondary, subordinate;
+
+		primary = tvalue & 0xFF;
+		secondary = (tvalue >> 8) & 0xFF;
+		subordinate = (tvalue >> 16) & 0xFF;
+		primary += pcibios_1st_host_bus_nr();
+		secondary += pcibios_1st_host_bus_nr();
+		subordinate += pcibios_1st_host_bus_nr();
+		tvalue = (tvalue & 0xFF000000) | (u32)primary | (u32)(secondary << 8) | (u32)(subordinate << 16);
+	}
+	return tvalue;
+}
+
+u32 ifx_pcie_bus_enum_write_hack(int where, u32 value)
+{
+    u32 tvalue = value;
+
+    if (where == PCI_PRIMARY_BUS) {
+        u8 primary, secondary, subordinate;
+
+        primary = tvalue & 0xFF;
+        secondary = (tvalue >> 8) & 0xFF;
+        subordinate = (tvalue >> 16) & 0xFF;
+        if (primary > 0 && primary != 0xFF) {
+            primary -= pcibios_1st_host_bus_nr();
+        }
+
+        if (secondary > 0 && secondary != 0xFF) {
+            secondary -= pcibios_1st_host_bus_nr();
+        }
+        if (subordinate > 0 && subordinate != 0xFF) {
+            subordinate -= pcibios_1st_host_bus_nr();
+        }
+        tvalue = (tvalue & 0xFF000000) | (u32)primary | (u32)(secondary << 8) | (u32)(subordinate << 16);
+    }
+    else if (where == PCI_SUBORDINATE_BUS) {
+        u8 subordinate = tvalue & 0xFF;
+
+        subordinate = subordinate > 0 ? subordinate - pcibios_1st_host_bus_nr() : 0;
+        tvalue = subordinate;
+    }
+    return tvalue;
+}
+
+static int ifx_pcie_read_config(struct pci_bus *bus, u32 devfn,
+				int where, int size, u32 *value)
+{
+    u32 data = 0;
+    int bus_number = bus->number;
+    static const u32 mask[8] = {0, 0xff, 0xffff, 0, 0xffffffff, 0, 0, 0};
+    int ret = PCIBIOS_SUCCESSFUL;
+    struct ifx_pci_controller *ctrl = bus->sysdata;
+    int pcie_port = ctrl->port;
+
+    if (unlikely(size != 1 && size != 2 && size != 4)){
+        ret = PCIBIOS_BAD_REGISTER_NUMBER;
+        goto out;
+    }
+
+    /* Make sure the address is aligned to natural boundary */
+    if (unlikely(((size - 1) & where))) {
+        ret = PCIBIOS_BAD_REGISTER_NUMBER;
+        goto out;
+    }
+
+    /* 
+     * If we are second controller, we have to cheat OS so that it assume 
+     * its bus number starts from 0 in host controller
+     */
+    bus_number = ifx_pcie_bus_nr_deduct(bus_number, pcie_port);
+
+    /* 
+     * We need to force the bus number to be zero on the root 
+     * bus. Linux numbers the 2nd root bus to start after all 
+     * busses on root 0. 
+     */ 
+    if (bus->parent == NULL) {
+        bus_number = 0; 
+    }
+
+    /* 
+     * PCIe only has a single device connected to it. It is 
+     * always device ID 0. Don't bother doing reads for other 
+     * device IDs on the first segment. 
+     */ 
+    if ((bus_number == 0) && (PCI_SLOT(devfn) != 0)) {
+        ret = PCIBIOS_FUNC_NOT_SUPPORTED;
+        goto out; 
+    }
+
+    if (pcie_valid_config(pcie_port, bus_number, PCI_SLOT(devfn)) == 0) {
+        *value = 0xffffffff;
+        ret = PCIBIOS_DEVICE_NOT_FOUND;
+        goto out;
+    }
+
+    PCIE_IRQ_LOCK(ifx_pcie_lock);
+    if (bus_number == 0) { /* RC itself */
+        u32 t;
+
+        t = (where & ~3);
+        data = ifx_pcie_rc_cfg_rd(pcie_port, t);
+    } else {
+        u32 addr = pcie_bus_addr(bus_number, devfn, where);
+
+        data = ifx_pcie_cfg_rd(pcie_port, addr);
+    #ifdef CONFIG_IFX_PCIE_HW_SWAP
+            data = le32_to_cpu(data);
+    #endif /* CONFIG_IFX_PCIE_HW_SWAP */
+    }
+    /* To get a correct PCI topology, we have to restore the bus number to OS */
+    data = ifx_pcie_bus_enum_hack(bus, devfn, where, data, pcie_port, 1);
+
+    PCIE_IRQ_UNLOCK(ifx_pcie_lock);
+
+    *value = (data >> (8 * (where & 3))) & mask[size & 7];
+out:
+    return ret;
+}
+
+static u32 ifx_pcie_size_to_value(int where, int size, u32 data, u32 value)
+{
+	u32 shift;
+	u32 tdata = data;
+
+	switch (size) {
+	case 1:
+		shift = (where & 0x3) << 3;
+		tdata &= ~(0xffU << shift);
+		tdata |= ((value & 0xffU) << shift);
+		break;
+	case 2:
+		shift = (where & 3) << 3;
+		tdata &= ~(0xffffU << shift);
+		tdata |= ((value & 0xffffU) << shift);
+		break;
+	case 4:
+		tdata = value;
+		break;
+	}
+	return tdata;
+}
+
+static int ifx_pcie_write_config(struct pci_bus *bus, u32 devfn,
+				int where, int size, u32 value)
+{
+	int bus_number = bus->number;
+	int ret = PCIBIOS_SUCCESSFUL;
+	struct ifx_pci_controller *ctrl = bus->sysdata;
+	int pcie_port = ctrl->port;
+	u32 tvalue = value;
+	u32 data;
+
+	/* Make sure the address is aligned to natural boundary */
+	if (unlikely(((size - 1) & where))) {
+		ret = PCIBIOS_BAD_REGISTER_NUMBER;
+		goto out;
+	}
+	/* 
+	* If we are second controller, we have to cheat OS so that it assume 
+	* its bus number starts from 0 in host controller
+	*/
+	bus_number = ifx_pcie_bus_nr_deduct(bus_number, pcie_port);
+
+	/* 
+	* We need to force the bus number to be zero on the root 
+	* bus. Linux numbers the 2nd root bus to start after all 
+	* busses on root 0. 
+	*/ 
+	if (bus->parent == NULL) {
+		bus_number = 0; 
+	}
+
+	if (pcie_valid_config(pcie_port, bus_number, PCI_SLOT(devfn)) == 0) {
+		ret = PCIBIOS_DEVICE_NOT_FOUND;
+		goto out;
+	}
+
+	/* XXX, some PCIe device may need some delay */
+	PCIE_IRQ_LOCK(ifx_pcie_lock);
+
+	/* 
+	* To configure the correct bus topology using native way, we have to cheat Os so that
+	* it can configure the PCIe hardware correctly.
+	*/
+	tvalue = ifx_pcie_bus_enum_hack(bus, devfn, where, value, pcie_port, 0);
+
+	if (bus_number == 0) { /* RC itself */
+		u32 t;
+
+		t = (where & ~3);
+		data = ifx_pcie_rc_cfg_rd(pcie_port, t);
+
+		data = ifx_pcie_size_to_value(where, size, data, tvalue);
+
+		ifx_pcie_rc_cfg_wr(pcie_port, t, data);
+	} else {
+		u32 addr = pcie_bus_addr(bus_number, devfn, where);
+
+		data = ifx_pcie_cfg_rd(pcie_port, addr);
+#ifdef CONFIG_IFX_PCIE_HW_SWAP
+		data = le32_to_cpu(data);
+#endif
+
+		data = ifx_pcie_size_to_value(where, size, data, tvalue);
+#ifdef CONFIG_IFX_PCIE_HW_SWAP
+		data = cpu_to_le32(data);
+#endif
+		ifx_pcie_cfg_wr(pcie_port, addr, data);
+	}
+	PCIE_IRQ_UNLOCK(ifx_pcie_lock);
+out:
+	return ret;
+}
+
+static struct resource ifx_pcie_io_resource = {
+	.name	= "PCIe0 I/O space",
+	.start	= PCIE_IO_PHY_BASE,
+	.end	= PCIE_IO_PHY_END,
+	.flags	= IORESOURCE_IO,
+};
+
+static struct resource ifx_pcie_mem_resource = {
+	.name	= "PCIe0 Memory space",
+	.start	= PCIE_MEM_PHY_BASE,
+	.end	= PCIE_MEM_PHY_END,
+	.flags	= IORESOURCE_MEM,
+};
+
+static struct pci_ops ifx_pcie_ops = {
+	.read	= ifx_pcie_read_config,
+	.write	= ifx_pcie_write_config,
+};
+
+static struct ifx_pci_controller ifx_pcie_controller[IFX_PCIE_CORE_NR] = {
+    {
+        .pcic = {
+            .pci_ops      = &ifx_pcie_ops,
+            .mem_resource = &ifx_pcie_mem_resource,
+            .io_resource  = &ifx_pcie_io_resource,
+         },
+         .port = IFX_PCIE_PORT0,
+    },
+};
+
+#ifdef IFX_PCIE_ERROR_INT
+
+static irqreturn_t pcie_rc_core_isr(int irq, void *dev_id)
+{
+	struct ifx_pci_controller *ctrl = (struct ifx_pci_controller *)dev_id;
+	int pcie_port = ctrl->port;
+	u32 reg;
+
+	pr_debug("PCIe RC error intr %d\n", irq);
+	reg = IFX_REG_R32(PCIE_IRNCR(pcie_port));
+	reg &= PCIE_RC_CORE_COMBINED_INT;
+	IFX_REG_W32(reg, PCIE_IRNCR(pcie_port));
+
+	return IRQ_HANDLED;
+}
+
+static int
+pcie_rc_core_int_init(int pcie_port)
+{
+	int ret;
+
+	/* Enable core interrupt */
+	IFX_REG_SET_BIT(PCIE_RC_CORE_COMBINED_INT, PCIE_IRNEN(pcie_port));
+
+	/* Clear it first */
+	IFX_REG_SET_BIT(PCIE_RC_CORE_COMBINED_INT, PCIE_IRNCR(pcie_port));
+	ret = request_irq(pcie_irqs[pcie_port].ir_irq.irq, pcie_rc_core_isr, 0,
+		pcie_irqs[pcie_port].ir_irq.name, &ifx_pcie_controller[pcie_port]);
+	if (ret)
+		printk(KERN_ERR "%s request irq %d failed\n", __func__, IFX_PCIE_IR);
+
+	return ret;
+}
+#endif
+
+int ifx_pcie_bios_map_irq(IFX_PCI_CONST struct pci_dev *dev, u8 slot, u8 pin)
+{
+	u32 irq_bit = 0;
+	int irq = 0;
+	struct ifx_pci_controller *ctrl = dev->bus->sysdata;
+	int pcie_port = ctrl->port;
+
+	printk("%s port %d dev %s slot %d pin %d \n", __func__, pcie_port, pci_name(dev), slot, pin);
+
+	if ((pin == PCIE_LEGACY_DISABLE) || (pin > PCIE_LEGACY_INT_MAX)) {
+		printk(KERN_WARNING "WARNING: dev %s: invalid interrupt pin %d\n", pci_name(dev), pin);
+		return -1;
+	}
+
+	/* Pin index so minus one */
+	irq_bit = pcie_irqs[pcie_port].legacy_irq[pin - 1].irq_bit;
+	irq = pcie_irqs[pcie_port].legacy_irq[pin - 1].irq;
+	IFX_REG_SET_BIT(irq_bit, PCIE_IRNEN(pcie_port));
+	IFX_REG_SET_BIT(irq_bit, PCIE_IRNCR(pcie_port));
+	printk("%s dev %s irq %d assigned\n", __func__, pci_name(dev), irq);
+	return irq;
+}
+
+int  ifx_pcie_bios_plat_dev_init(struct pci_dev *dev)
+{
+    u16 config;
+#ifdef IFX_PCIE_ERROR_INT
+    u32 dconfig; 
+    int pos;
+#endif
+
+    /* Enable reporting System errors and parity errors on all devices */ 
+    /* Enable parity checking and error reporting */ 
+    pci_read_config_word(dev, PCI_COMMAND, &config);
+    config |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR /*| PCI_COMMAND_INVALIDATE |
+          PCI_COMMAND_FAST_BACK*/;
+    pci_write_config_word(dev, PCI_COMMAND, config);
+
+    if (dev->subordinate) {
+        /* Set latency timers on sub bridges */
+        pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 0x40); /* XXX, */
+        /* More bridge error detection */
+        pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &config);
+        config |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
+        pci_write_config_word(dev, PCI_BRIDGE_CONTROL, config);
+    }
+#ifdef IFX_PCIE_ERROR_INT
+    /* Enable the PCIe normal error reporting */
+    pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
+    if (pos) {
+
+        /* Disable system error generation in response to error messages */
+        pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &config);
+        config &= ~(PCI_EXP_RTCTL_SECEE | PCI_EXP_RTCTL_SENFEE | PCI_EXP_RTCTL_SEFEE);
+        pci_write_config_word(dev, pos + PCI_EXP_RTCTL, config);
+
+        /* Clear PCIE Capability's Device Status */
+        pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &config);
+        pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, config);
+
+        /* Update Device Control */ 
+        pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &config);
+        /* Correctable Error Reporting */
+        config |= PCI_EXP_DEVCTL_CERE;
+        /* Non-Fatal Error Reporting */
+        config |= PCI_EXP_DEVCTL_NFERE;
+        /* Fatal Error Reporting */
+        config |= PCI_EXP_DEVCTL_FERE;
+        /* Unsupported Request */
+        config |= PCI_EXP_DEVCTL_URRE;
+        pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, config);
+    }
+
+    /* Find the Advanced Error Reporting capability */
+    pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
+    if (pos) {
+        /* Clear Uncorrectable Error Status */ 
+        pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &dconfig);
+        pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, dconfig);
+        /* Enable reporting of all uncorrectable errors */
+        /* Uncorrectable Error Mask - turned on bits disable errors */
+        pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, 0);
+        /* 
+        * Leave severity at HW default. This only controls if 
+        * errors are reported as uncorrectable or 
+        * correctable, not if the error is reported. 
+        */ 
+        /* PCI_ERR_UNCOR_SEVER - Uncorrectable Error Severity */
+        /* Clear Correctable Error Status */
+        pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &dconfig);
+        pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, dconfig);
+        /* Enable reporting of all correctable errors */
+        /* Correctable Error Mask - turned on bits disable errors */
+        pci_write_config_dword(dev, pos + PCI_ERR_COR_MASK, 0);
+        /* Advanced Error Capabilities */ 
+        pci_read_config_dword(dev, pos + PCI_ERR_CAP, &dconfig);
+        /* ECRC Generation Enable */
+        if (dconfig & PCI_ERR_CAP_ECRC_GENC) {
+            dconfig |= PCI_ERR_CAP_ECRC_GENE;
+        }
+        /* ECRC Check Enable */
+        if (dconfig & PCI_ERR_CAP_ECRC_CHKC) {
+            dconfig |= PCI_ERR_CAP_ECRC_CHKE;
+        }
+        pci_write_config_dword(dev, pos + PCI_ERR_CAP, dconfig);
+
+        /* PCI_ERR_HEADER_LOG - Header Log Register (16 bytes) */
+        /* Enable Root Port's interrupt in response to error messages */
+        pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND,
+              PCI_ERR_ROOT_CMD_COR_EN |
+              PCI_ERR_ROOT_CMD_NONFATAL_EN |
+              PCI_ERR_ROOT_CMD_FATAL_EN); 
+        /* Clear the Root status register */
+        pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &dconfig);
+        pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, dconfig);
+    }
+#endif /* IFX_PCIE_ERROR_INT */
+    /* WAR, only 128 MRRS is supported, force all EPs to support this value */
+    pcie_set_readrq(dev, 128);
+    return 0;
+}
+
+static int
+pcie_rc_initialize(int pcie_port)
+{
+	int i;
+#define IFX_PCIE_PHY_LOOP_CNT  5
+
+	pcie_rcu_endian_setup(pcie_port);
+
+	pcie_ep_gpio_rst_init(pcie_port);
+
+	/* 
+	* XXX, PCIe elastic buffer bug will cause not to be detected. One more 
+	* reset PCIe PHY will solve this issue 
+	*/
+	for (i = 0; i < IFX_PCIE_PHY_LOOP_CNT; i++) {
+		/* Disable PCIe PHY Analog part for sanity check */
+		pcie_phy_pmu_disable(pcie_port);
+
+		pcie_phy_rst_assert(pcie_port);
+		pcie_phy_rst_deassert(pcie_port);
+
+		/* Make sure PHY PLL is stable */
+		udelay(20);
+
+		/* PCIe Core reset enabled, low active, sw programmed */
+		pcie_core_rst_assert(pcie_port);
+
+		/* Put PCIe EP in reset status */
+		pcie_device_rst_assert(pcie_port);
+
+		/* PCI PHY & Core reset disabled, high active, sw programmed */
+		pcie_core_rst_deassert(pcie_port);
+
+		/* Already in a quiet state, program PLL, enable PHY, check ready bit */
+		pcie_phy_clock_mode_setup(pcie_port);
+
+		/* Enable PCIe PHY and Clock */
+		pcie_core_pmu_setup(pcie_port);
+
+		/* Clear status registers */
+		pcie_status_register_clear(pcie_port);
+
+#ifdef CONFIG_PCI_MSI
+		pcie_msi_init(pcie_port);
+#endif /* CONFIG_PCI_MSI */
+		pcie_rc_cfg_reg_setup(pcie_port);
+
+		/* Once link is up, break out */
+		if (pcie_app_loigc_setup(pcie_port) == 0)
+			break;
+	}
+	if (i >= IFX_PCIE_PHY_LOOP_CNT) {
+		printk(KERN_ERR "%s link up failed!!!!!\n", __func__);
+		return -EIO;
+	}
+	/* NB, don't increase ACK/NACK timer timeout value, which will cause a lot of COR errors */
+	pcie_replay_time_update(pcie_port);
+	return 0;
+}
+
+static int __init ifx_pcie_bios_init(void)
+{
+    void __iomem *io_map_base;
+    int pcie_port;
+    int startup_port;
+
+    /* Enable AHB Master/ Slave */
+    pcie_ahb_pmu_setup();
+
+    startup_port = IFX_PCIE_PORT0;
+    
+    for (pcie_port = startup_port; pcie_port < IFX_PCIE_CORE_NR; pcie_port++){
+	if (pcie_rc_initialize(pcie_port) == 0) {
+	    IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: ifx_pcie_cfg_base 0x%p\n", 
+                 __func__, PCIE_CFG_PORT_TO_BASE(pcie_port));
+            /* Otherwise, warning will pop up */
+            io_map_base = ioremap(PCIE_IO_PHY_PORT_TO_BASE(pcie_port), PCIE_IO_SIZE);
+            if (io_map_base == NULL) {
+                IFX_PCIE_PRINT(PCIE_MSG_ERR, "%s io space ioremap failed\n", __func__);
+                return -ENOMEM;
+            }
+            ifx_pcie_controller[pcie_port].pcic.io_map_base = (unsigned long)io_map_base;
+
+            register_pci_controller(&ifx_pcie_controller[pcie_port].pcic);
+            /* XXX, clear error status */
+
+            IFX_PCIE_PRINT(PCIE_MSG_INIT, "%s: mem_resource 0x%p, io_resource 0x%p\n", 
+                              __func__, &ifx_pcie_controller[pcie_port].pcic.mem_resource, 
+                              &ifx_pcie_controller[pcie_port].pcic.io_resource);
+
+        #ifdef IFX_PCIE_ERROR_INT
+            pcie_rc_core_int_init(pcie_port);
+        #endif /* IFX_PCIE_ERROR_INT */
+        }
+    }
+
+    return 0;
+}
+arch_initcall(ifx_pcie_bios_init);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Chuanhua.Lei@infineon.com");
+MODULE_SUPPORTED_DEVICE("Infineon builtin PCIe RC module");
+MODULE_DESCRIPTION("Infineon builtin PCIe RC driver");
+
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pcie.h
@@ -0,0 +1,135 @@
+/******************************************************************************
+**
+** FILE NAME    : ifxmips_pcie.h
+** PROJECT      : IFX UEIP for VRX200
+** MODULES      : PCIe module
+**
+** DATE         : 02 Mar 2009
+** AUTHOR       : Lei Chuanhua
+** DESCRIPTION  : PCIe Root Complex Driver
+** COPYRIGHT    :       Copyright (c) 2009
+**                      Infineon Technologies AG
+**                      Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+**    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.
+** HISTORY
+** $Version $Date        $Author         $Comment
+** 0.0.1    17 Mar,2009  Lei Chuanhua    Initial version
+*******************************************************************************/
+#ifndef IFXMIPS_PCIE_H
+#define IFXMIPS_PCIE_H
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include "ifxmips_pci_common.h"
+#include "ifxmips_pcie_reg.h"
+
+/*!
+ \defgroup IFX_PCIE  PCI Express bus driver module   
+ \brief  PCI Express IP module support VRX200 
+*/
+
+/*!
+ \defgroup IFX_PCIE_OS OS APIs
+ \ingroup IFX_PCIE
+ \brief PCIe bus driver OS interface functions
+*/
+
+/*!
+ \file ifxmips_pcie.h
+ \ingroup IFX_PCIE  
+ \brief header file for PCIe module common header file
+*/
+#define PCIE_IRQ_LOCK(lock) do {             \
+    unsigned long flags;                     \
+    spin_lock_irqsave(&(lock), flags);
+#define PCIE_IRQ_UNLOCK(lock)                \
+    spin_unlock_irqrestore(&(lock), flags);  \
+} while (0)
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+#define IRQF_SHARED SA_SHIRQ
+#endif
+
+#define PCIE_MSG_MSI        0x00000001
+#define PCIE_MSG_ISR        0x00000002
+#define PCIE_MSG_FIXUP      0x00000004
+#define PCIE_MSG_READ_CFG   0x00000008
+#define PCIE_MSG_WRITE_CFG  0x00000010
+#define PCIE_MSG_CFG        (PCIE_MSG_READ_CFG | PCIE_MSG_WRITE_CFG)
+#define PCIE_MSG_REG        0x00000020
+#define PCIE_MSG_INIT       0x00000040
+#define PCIE_MSG_ERR        0x00000080
+#define PCIE_MSG_PHY        0x00000100
+#define PCIE_MSG_ANY        0x000001ff
+
+#define IFX_PCIE_PORT0      0
+#define IFX_PCIE_PORT1      1
+
+#ifdef CONFIG_IFX_PCIE_2ND_CORE
+#define IFX_PCIE_CORE_NR    2
+#else
+#define IFX_PCIE_CORE_NR    1
+#endif
+
+#define IFX_PCIE_ERROR_INT
+
+//#define IFX_PCIE_DBG
+
+#if defined(IFX_PCIE_DBG)
+#define IFX_PCIE_PRINT(_m, _fmt, args...) do {   \
+        ifx_pcie_debug((_fmt), ##args);          \
+} while (0)
+
+#define INLINE 
+#else
+#define IFX_PCIE_PRINT(_m, _fmt, args...)   \
+    do {} while(0)
+#define INLINE inline
+#endif
+
+struct ifx_pci_controller {
+	struct pci_controller   pcic;
+    
+	/* RC specific, per host bus information */
+	u32   port;  /* Port index, 0 -- 1st core, 1 -- 2nd core */
+};
+
+typedef struct ifx_pcie_ir_irq {
+    const unsigned int irq;
+    const char name[16];
+}ifx_pcie_ir_irq_t;
+
+typedef struct ifx_pcie_legacy_irq{
+    const u32 irq_bit;
+    const int irq;
+}ifx_pcie_legacy_irq_t;
+
+typedef struct ifx_pcie_irq {
+    ifx_pcie_ir_irq_t ir_irq;
+    ifx_pcie_legacy_irq_t legacy_irq[PCIE_LEGACY_INT_MAX];
+}ifx_pcie_irq_t;
+
+extern u32 g_pcie_debug_flag;
+extern void ifx_pcie_debug(const char *fmt, ...);
+extern void pcie_phy_clock_mode_setup(int pcie_port);
+extern void pcie_msi_pic_init(int pcie_port);
+extern u32 ifx_pcie_bus_enum_read_hack(int where, u32 value);
+extern u32 ifx_pcie_bus_enum_write_hack(int where, u32 value);
+
+#define CONFIG_VR9
+
+#ifdef CONFIG_VR9
+#include "ifxmips_pcie_vr9.h"
+#elif defined (CONFIG_AR10)
+#include "ifxmips_pcie_ar10.h"
+#else
+#error "PCIE: platform not defined"
+#endif /* CONFIG_VR9 */
+
+#endif  /* IFXMIPS_PCIE_H */
+
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pcie_ar10.h
@@ -0,0 +1,290 @@
+/****************************************************************************
+                              Copyright (c) 2010
+                            Lantiq Deutschland GmbH
+                     Am Campeon 3; 85579 Neubiberg, Germany
+
+  For licensing information, see the file 'LICENSE' in the root folder of
+  this software module.
+
+ *****************************************************************************/
+/*!
+  \file ifxmips_pcie_ar10.h
+  \ingroup IFX_PCIE
+  \brief PCIe RC driver ar10 specific file
+*/
+
+#ifndef IFXMIPS_PCIE_AR10_H
+#define IFXMIPS_PCIE_AR10_H
+#ifndef AUTOCONF_INCLUDED
+#include <linux/config.h>
+#endif /* AUTOCONF_INCLUDED */
+#include <linux/types.h>
+#include <linux/delay.h>
+
+/* Project header file */
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/ifx_pmu.h>
+#include <asm/ifx/ifx_gpio.h>
+#include <asm/ifx/ifx_ebu_led.h>
+
+static inline void pcie_ep_gpio_rst_init(int pcie_port)
+{
+    ifx_ebu_led_enable();
+    if (pcie_port == 0) {
+        ifx_ebu_led_set_data(11, 1);        
+    }
+    else {
+        ifx_ebu_led_set_data(12, 1);  
+    }
+}
+
+static inline void pcie_ahb_pmu_setup(void) 
+{
+    /* XXX, moved to CGU to control AHBM */
+}
+
+static inline void pcie_rcu_endian_setup(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
+    /* Inbound, big endian */
+    reg |= IFX_RCU_BE_AHB4S;
+    if (pcie_port == 0) {
+        reg |= IFX_RCU_BE_PCIE0M;
+
+    #ifdef CONFIG_IFX_PCIE_HW_SWAP
+        /* Outbound, software swap needed */
+        reg |= IFX_RCU_BE_AHB3M;
+        reg &= ~IFX_RCU_BE_PCIE0S;
+    #else
+        /* Outbound little endian  */
+        reg &= ~IFX_RCU_BE_AHB3M;
+        reg &= ~IFX_RCU_BE_PCIE0S;
+    #endif
+    }
+    else {
+        reg |= IFX_RCU_BE_PCIE1M;
+    #ifdef CONFIG_IFX_PCIE1_HW_SWAP
+        /* Outbound, software swap needed */
+        reg |= IFX_RCU_BE_AHB3M;
+        reg &= ~IFX_RCU_BE_PCIE1S;
+    #else
+        /* Outbound little endian  */
+        reg &= ~IFX_RCU_BE_AHB3M;
+        reg &= ~IFX_RCU_BE_PCIE1S;
+    #endif
+    }
+
+    IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
+    IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
+}
+
+static inline void pcie_phy_pmu_enable(int pcie_port)
+{
+    if (pcie_port == 0) { /* XXX, should use macro*/
+        PCIE0_PHY_PMU_SETUP(IFX_PMU_ENABLE);
+    }
+    else {
+        PCIE1_PHY_PMU_SETUP(IFX_PMU_ENABLE);
+    }
+}
+
+static inline void pcie_phy_pmu_disable(int pcie_port)
+{
+    if (pcie_port == 0) { /* XXX, should use macro*/
+        PCIE0_PHY_PMU_SETUP(IFX_PMU_DISABLE);
+    }
+    else {
+        PCIE1_PHY_PMU_SETUP(IFX_PMU_DISABLE);
+    }
+}
+
+static inline void pcie_pdi_big_endian(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
+    if (pcie_port == 0) {
+        /* Config AHB->PCIe and PDI endianness */
+        reg |= IFX_RCU_BE_PCIE0_PDI;
+    }
+    else {
+        /* Config AHB->PCIe and PDI endianness */
+        reg |= IFX_RCU_BE_PCIE1_PDI;
+    }
+    IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
+}
+
+static inline void pcie_pdi_pmu_enable(int pcie_port)
+{
+    if (pcie_port == 0) {
+        /* Enable PDI to access PCIe PHY register */
+        PDI0_PMU_SETUP(IFX_PMU_ENABLE);
+    }
+    else {
+        PDI1_PMU_SETUP(IFX_PMU_ENABLE);
+    }
+}
+
+static inline void pcie_core_rst_assert(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+
+    /* Reset Core, bit 22 */
+    if (pcie_port == 0) {
+        reg |= 0x00400000;
+    }
+    else {
+        reg |= 0x08000000; /* Bit 27 */
+    }
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_core_rst_deassert(int pcie_port)
+{
+    u32 reg;
+
+    /* Make sure one micro-second delay */
+    udelay(1);
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+    if (pcie_port == 0) {
+        reg &= ~0x00400000; /* bit 22 */
+    }
+    else {
+        reg &= ~0x08000000; /* Bit 27 */
+    }
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_phy_rst_assert(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+    if (pcie_port == 0) {
+        reg |= 0x00001000; /* Bit 12 */
+    }
+    else {
+        reg |= 0x00002000; /* Bit 13 */
+    }
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_phy_rst_deassert(int pcie_port)
+{
+    u32 reg;
+
+    /* Make sure one micro-second delay */
+    udelay(1);
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+    if (pcie_port == 0) {
+        reg &= ~0x00001000; /* Bit 12 */
+    }
+    else {
+        reg &= ~0x00002000; /* Bit 13 */
+    }
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_device_rst_assert(int pcie_port)
+{
+    if (pcie_port == 0) {
+        ifx_ebu_led_set_data(11, 0);
+    }
+    else {
+        ifx_ebu_led_set_data(12, 0);
+    }
+}
+
+static inline void pcie_device_rst_deassert(int pcie_port)
+{
+    mdelay(100);
+    if (pcie_port == 0) {
+        ifx_ebu_led_set_data(11, 1);
+    }
+    else {
+        ifx_ebu_led_set_data(12, 1);
+    }
+    ifx_ebu_led_disable();
+}
+
+static inline void pcie_core_pmu_setup(int pcie_port)
+{
+    if (pcie_port == 0) {
+        PCIE0_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
+    }
+    else {
+        PCIE1_CTRL_PMU_SETUP(IFX_PMU_ENABLE); 
+    }
+}
+
+static inline void pcie_msi_init(int pcie_port)
+{
+    pcie_msi_pic_init(pcie_port);
+    if (pcie_port == 0) {
+        MSI0_PMU_SETUP(IFX_PMU_ENABLE);
+    }
+    else {
+        MSI1_PMU_SETUP(IFX_PMU_ENABLE);
+    }
+}
+
+static inline u32
+ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
+{
+    u32 tbus_number = bus_number;
+
+#ifdef CONFIG_IFX_PCIE_2ND_CORE
+    if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
+        if (pcibios_host_nr() > 1) {
+            tbus_number -= pcibios_1st_host_bus_nr();
+        }        
+    }
+#endif /* CONFIG_IFX_PCI */
+    return tbus_number;
+}
+
+static inline u32
+ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
+{
+    struct pci_dev *pdev;
+    u32 tvalue = value;
+
+    /* Sanity check */
+    pdev = pci_get_slot(bus, devfn);
+    if (pdev == NULL) {
+        return tvalue;
+    }
+
+    /* Only care about PCI bridge */
+    if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
+        return tvalue;
+    }
+
+    if (read) { /* Read hack */
+    #ifdef CONFIG_IFX_PCIE_2ND_CORE
+        if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
+            if (pcibios_host_nr() > 1) {
+                tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
+            }
+        }
+    #endif /* CONFIG_IFX_PCIE_2ND_CORE */
+    }
+    else { /* Write hack */
+    #ifdef CONFIG_IFX_PCIE_2ND_CORE
+        if (pcie_port == IFX_PCIE_PORT1) { /* Port 1 must check if there are two cores enabled */
+            if (pcibios_host_nr() > 1) {
+                tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
+            }
+        }
+    #endif
+    }
+    return tvalue;
+}
+
+#endif /* IFXMIPS_PCIE_AR10_H */
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pcie_msi.c
@@ -0,0 +1,392 @@
+/******************************************************************************
+**
+** FILE NAME    : ifxmips_pcie_msi.c
+** PROJECT      : IFX UEIP for VRX200
+** MODULES      : PCI MSI sub module
+**
+** DATE         : 02 Mar 2009
+** AUTHOR       : Lei Chuanhua
+** DESCRIPTION  : PCIe MSI Driver
+** COPYRIGHT    :       Copyright (c) 2009
+**                      Infineon Technologies AG
+**                      Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+**    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.
+** HISTORY
+** $Date        $Author         $Comment
+** 02 Mar,2009  Lei Chuanhua    Initial version
+*******************************************************************************/
+/*!
+ \defgroup IFX_PCIE_MSI MSI OS APIs
+ \ingroup IFX_PCIE
+ \brief PCIe bus driver OS interface functions
+*/
+
+/*!
+ \file ifxmips_pcie_msi.c
+ \ingroup IFX_PCIE 
+ \brief PCIe MSI OS interface file
+*/
+
+#ifndef AUTOCONF_INCLUDED
+#include <linux/config.h>
+#endif /* AUTOCONF_INCLUDED */
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/interrupt.h>
+#include <linux/kernel_stat.h>
+#include <linux/pci.h>
+#include <linux/msi.h>
+#include <linux/module.h>
+#include <asm/bootinfo.h>
+#include <asm/irq.h>
+#include <asm/traps.h>
+
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/common_routines.h>
+#include <asm/ifx/irq.h>
+
+#include "ifxmips_pcie_reg.h"
+#include "ifxmips_pcie.h"
+
+#define IFX_MSI_IRQ_NUM    16
+
+enum {
+    IFX_PCIE_MSI_IDX0 = 0,
+    IFX_PCIE_MSI_IDX1,
+    IFX_PCIE_MSI_IDX2,
+    IFX_PCIE_MSI_IDX3,
+};
+
+typedef struct ifx_msi_irq_idx {
+    const int irq;
+    const int idx;
+}ifx_msi_irq_idx_t;
+
+struct ifx_msi_pic {
+    volatile u32  pic_table[IFX_MSI_IRQ_NUM];
+    volatile u32  pic_endian;    /* 0x40  */
+};
+typedef struct ifx_msi_pic *ifx_msi_pic_t;
+
+typedef struct ifx_msi_irq {
+    const volatile ifx_msi_pic_t msi_pic_p;
+    const u32 msi_phy_base;
+    const ifx_msi_irq_idx_t msi_irq_idx[IFX_MSI_IRQ_NUM];
+    /*
+     * Each bit in msi_free_irq_bitmask represents a MSI interrupt that is 
+     * in use.
+     */
+    u16 msi_free_irq_bitmask;
+
+    /*
+     * Each bit in msi_multiple_irq_bitmask tells that the device using 
+     * this bit in msi_free_irq_bitmask is also using the next bit. This 
+     * is used so we can disable all of the MSI interrupts when a device 
+     * uses multiple.
+     */
+    u16 msi_multiple_irq_bitmask;
+}ifx_msi_irq_t;
+
+static ifx_msi_irq_t msi_irqs[IFX_PCIE_CORE_NR] = {
+    {
+        .msi_pic_p = (const volatile ifx_msi_pic_t)IFX_MSI_PIC_REG_BASE,
+        .msi_phy_base = PCIE_MSI_PHY_BASE,
+        .msi_irq_idx = {
+            {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
+            {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
+            {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
+            {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
+            {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
+            {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
+            {IFX_PCIE_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE_MSI_IR1, IFX_PCIE_MSI_IDX1},
+            {IFX_PCIE_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE_MSI_IR3, IFX_PCIE_MSI_IDX3},
+        },
+        .msi_free_irq_bitmask = 0,
+        .msi_multiple_irq_bitmask= 0,
+    },
+#ifdef CONFIG_IFX_PCIE_2ND_CORE
+    {
+        .msi_pic_p = (const volatile ifx_msi_pic_t)IFX_MSI1_PIC_REG_BASE,
+        .msi_phy_base = PCIE1_MSI_PHY_BASE,
+        .msi_irq_idx = {
+            {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
+            {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
+            {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
+            {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
+            {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
+            {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
+            {IFX_PCIE1_MSI_IR0, IFX_PCIE_MSI_IDX0}, {IFX_PCIE1_MSI_IR1, IFX_PCIE_MSI_IDX1},
+            {IFX_PCIE1_MSI_IR2, IFX_PCIE_MSI_IDX2}, {IFX_PCIE1_MSI_IR3, IFX_PCIE_MSI_IDX3},
+        },
+        .msi_free_irq_bitmask = 0,
+        .msi_multiple_irq_bitmask= 0,
+
+    },
+#endif /* CONFIG_IFX_PCIE_2ND_CORE */
+};
+
+/* 
+ * This lock controls updates to msi_free_irq_bitmask, 
+ * msi_multiple_irq_bitmask and pic register settting
+ */ 
+static DEFINE_SPINLOCK(ifx_pcie_msi_lock);
+
+void pcie_msi_pic_init(int pcie_port)
+{
+    spin_lock(&ifx_pcie_msi_lock);
+    msi_irqs[pcie_port].msi_pic_p->pic_endian = IFX_MSI_PIC_BIG_ENDIAN;
+    spin_unlock(&ifx_pcie_msi_lock);
+}
+
+/** 
+ * \fn int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
+ * \brief Called when a driver request MSI interrupts instead of the 
+ * legacy INT A-D. This routine will allocate multiple interrupts 
+ * for MSI devices that support them. A device can override this by 
+ * programming the MSI control bits [6:4] before calling 
+ * pci_enable_msi(). 
+ * 
+ * \param[in] pdev   Device requesting MSI interrupts 
+ * \param[in] desc   MSI descriptor 
+ * 
+ * \return   -EINVAL Invalid pcie root port or invalid msi bit
+ * \return    0        OK
+ * \ingroup IFX_PCIE_MSI
+ */
+int 
+arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
+{
+    int  irq, pos;
+    u16  control;
+    int  irq_idx;
+    int  irq_step;
+    int configured_private_bits;
+    int request_private_bits;
+    struct msi_msg msg;
+    u16 search_mask;
+    struct ifx_pci_controller *ctrl = pdev->bus->sysdata;
+    int pcie_port = ctrl->port;
+
+    IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s %s enter\n", __func__, pci_name(pdev));
+
+    /* XXX, skip RC MSI itself */
+    if (pdev->pcie_type == PCI_EXP_TYPE_ROOT_PORT) {
+        IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s RC itself doesn't use MSI interrupt\n", __func__);
+        return -EINVAL;
+    }
+
+    /*
+     * Read the MSI config to figure out how many IRQs this device 
+     * wants.  Most devices only want 1, which will give 
+     * configured_private_bits and request_private_bits equal 0. 
+     */
+    pci_read_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS, &control);
+
+    /*
+     * If the number of private bits has been configured then use 
+     * that value instead of the requested number. This gives the 
+     * driver the chance to override the number of interrupts 
+     * before calling pci_enable_msi(). 
+     */
+    configured_private_bits = (control & PCI_MSI_FLAGS_QSIZE) >> 4; 
+    if (configured_private_bits == 0) {
+        /* Nothing is configured, so use the hardware requested size */
+        request_private_bits = (control & PCI_MSI_FLAGS_QMASK) >> 1;
+    }
+    else {
+        /*
+         * Use the number of configured bits, assuming the 
+         * driver wanted to override the hardware request 
+         * value.
+         */
+        request_private_bits = configured_private_bits;
+    }
+
+    /*
+     * The PCI 2.3 spec mandates that there are at most 32
+     * interrupts. If this device asks for more, only give it one.
+     */
+    if (request_private_bits > 5) {
+        request_private_bits = 0;
+    }
+again:
+    /*
+     * The IRQs have to be aligned on a power of two based on the
+     * number being requested.
+     */
+    irq_step = (1 << request_private_bits);
+
+    /* Mask with one bit for each IRQ */
+    search_mask = (1 << irq_step) - 1;
+
+    /*
+     * We're going to search msi_free_irq_bitmask_lock for zero 
+     * bits. This represents an MSI interrupt number that isn't in 
+     * use.
+     */
+    spin_lock(&ifx_pcie_msi_lock);
+    for (pos = 0; pos < IFX_MSI_IRQ_NUM; pos += irq_step) {
+        if ((msi_irqs[pcie_port].msi_free_irq_bitmask & (search_mask << pos)) == 0) {
+            msi_irqs[pcie_port].msi_free_irq_bitmask |= search_mask << pos; 
+            msi_irqs[pcie_port].msi_multiple_irq_bitmask |= (search_mask >> 1) << pos;
+            break; 
+        }
+    }
+    spin_unlock(&ifx_pcie_msi_lock); 
+
+    /* Make sure the search for available interrupts didn't fail */ 
+    if (pos >= IFX_MSI_IRQ_NUM) {
+        if (request_private_bits) {
+            IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s: Unable to find %d free "
+                  "interrupts, trying just one", __func__, 1 << request_private_bits);
+            request_private_bits = 0;
+            goto again;
+        }
+        else {
+            printk(KERN_ERR "%s: Unable to find a free MSI interrupt\n", __func__);
+            return -EINVAL;
+        }
+    } 
+    irq = msi_irqs[pcie_port].msi_irq_idx[pos].irq;
+    irq_idx = msi_irqs[pcie_port].msi_irq_idx[pos].idx;
+
+    IFX_PCIE_PRINT(PCIE_MSG_MSI, "pos %d, irq %d irq_idx %d\n", pos, irq, irq_idx);
+
+    /*
+     * Initialize MSI. This has to match the memory-write endianess from the device 
+     * Address bits [23:12]
+     */
+    spin_lock(&ifx_pcie_msi_lock); 
+    msi_irqs[pcie_port].msi_pic_p->pic_table[pos] = SM(irq_idx, IFX_MSI_PIC_INT_LINE) |
+                    SM((msi_irqs[pcie_port].msi_phy_base >> 12), IFX_MSI_PIC_MSG_ADDR) |
+                    SM((1 << pos), IFX_MSI_PIC_MSG_DATA);
+
+    /* Enable this entry */
+    msi_irqs[pcie_port].msi_pic_p->pic_table[pos] &= ~IFX_MSI_PCI_INT_DISABLE;
+    spin_unlock(&ifx_pcie_msi_lock);
+
+    IFX_PCIE_PRINT(PCIE_MSG_MSI, "pic_table[%d]: 0x%08x\n",
+        pos, msi_irqs[pcie_port].msi_pic_p->pic_table[pos]);
+
+    /* Update the number of IRQs the device has available to it */
+    control &= ~PCI_MSI_FLAGS_QSIZE;
+    control |= (request_private_bits << 4);
+    pci_write_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS, control);
+
+    set_irq_msi(irq, desc);
+    msg.address_hi = 0x0;
+    msg.address_lo = msi_irqs[pcie_port].msi_phy_base;
+    msg.data = SM((1 << pos), IFX_MSI_PIC_MSG_DATA);
+    IFX_PCIE_PRINT(PCIE_MSG_MSI, "msi_data: pos %d 0x%08x\n", pos, msg.data);
+
+    write_msi_msg(irq, &msg);
+    IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s exit\n", __func__);
+    return 0;
+}
+
+static int
+pcie_msi_irq_to_port(unsigned int irq, int *port)
+{
+    int ret = 0;
+
+    if (irq == IFX_PCIE_MSI_IR0 || irq == IFX_PCIE_MSI_IR1 ||
+        irq == IFX_PCIE_MSI_IR2 || irq == IFX_PCIE_MSI_IR3) {
+        *port = IFX_PCIE_PORT0;
+    }
+#ifdef CONFIG_IFX_PCIE_2ND_CORE
+    else if (irq == IFX_PCIE1_MSI_IR0 || irq == IFX_PCIE1_MSI_IR1 ||
+        irq == IFX_PCIE1_MSI_IR2 || irq == IFX_PCIE1_MSI_IR3) {
+        *port = IFX_PCIE_PORT1;
+    }
+#endif /* CONFIG_IFX_PCIE_2ND_CORE */
+    else {
+        printk(KERN_ERR "%s: Attempted to teardown illegal " 
+            "MSI interrupt (%d)\n", __func__, irq);
+        ret = -EINVAL;
+    }
+    return ret;
+}
+
+/** 
+ * \fn void arch_teardown_msi_irq(unsigned int irq)
+ * \brief Called when a device no longer needs its MSI interrupts. All 
+ * MSI interrupts for the device are freed. 
+ * 
+ * \param irq   The devices first irq number. There may be multple in sequence.
+ * \return none
+ * \ingroup IFX_PCIE_MSI
+ */
+void 
+arch_teardown_msi_irq(unsigned int irq)
+{
+    int pos;
+    int number_irqs; 
+    u16 bitmask;
+    int pcie_port;
+
+    IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s enter\n", __func__);
+
+    BUG_ON(irq > INT_NUM_IM4_IRL31);
+
+    if (pcie_msi_irq_to_port(irq, &pcie_port) != 0) {
+        return;
+    }
+
+    /* Shift the mask to the correct bit location, not always correct 
+     * Probally, the first match will be chosen.
+     */
+    for (pos = 0; pos < IFX_MSI_IRQ_NUM; pos++) {
+        if ((msi_irqs[pcie_port].msi_irq_idx[pos].irq == irq) 
+            && (msi_irqs[pcie_port].msi_free_irq_bitmask & ( 1 << pos))) {
+            break;
+        }
+    }
+    if (pos >= IFX_MSI_IRQ_NUM) {
+        printk(KERN_ERR "%s: Unable to find a matched MSI interrupt\n", __func__);
+        return;
+    }
+    spin_lock(&ifx_pcie_msi_lock);
+    /* Disable this entry */
+    msi_irqs[pcie_port].msi_pic_p->pic_table[pos] |= IFX_MSI_PCI_INT_DISABLE;
+    msi_irqs[pcie_port].msi_pic_p->pic_table[pos] &= ~(IFX_MSI_PIC_INT_LINE | IFX_MSI_PIC_MSG_ADDR | IFX_MSI_PIC_MSG_DATA);
+    spin_unlock(&ifx_pcie_msi_lock); 
+    /*
+     * Count the number of IRQs we need to free by looking at the
+     * msi_multiple_irq_bitmask. Each bit set means that the next
+     * IRQ is also owned by this device.
+     */ 
+    number_irqs = 0; 
+    while (((pos + number_irqs) < IFX_MSI_IRQ_NUM) && 
+        (msi_irqs[pcie_port].msi_multiple_irq_bitmask & (1 << (pos + number_irqs)))) {
+        number_irqs++;
+    }
+    number_irqs++;
+
+    /* Mask with one bit for each IRQ */
+    bitmask = (1 << number_irqs) - 1;
+
+    bitmask <<= pos;
+    if ((msi_irqs[pcie_port].msi_free_irq_bitmask & bitmask) != bitmask) {
+        printk(KERN_ERR "%s: Attempted to teardown MSI "
+             "interrupt (%d) not in use\n", __func__, irq);
+        return;
+    }
+    /* Checks are done, update the in use bitmask */
+    spin_lock(&ifx_pcie_msi_lock);
+    msi_irqs[pcie_port].msi_free_irq_bitmask &= ~bitmask;
+    msi_irqs[pcie_port].msi_multiple_irq_bitmask &= ~(bitmask >> 1);
+    spin_unlock(&ifx_pcie_msi_lock);
+    IFX_PCIE_PRINT(PCIE_MSG_MSI, "%s exit\n", __func__);
+}
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Chuanhua.Lei@infineon.com");
+MODULE_SUPPORTED_DEVICE("Infineon PCIe IP builtin MSI PIC module");
+MODULE_DESCRIPTION("Infineon PCIe IP builtin MSI PIC driver");
+
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pcie_phy.c
@@ -0,0 +1,478 @@
+/******************************************************************************
+**
+** FILE NAME    : ifxmips_pcie_phy.c
+** PROJECT      : IFX UEIP for VRX200
+** MODULES      : PCIe PHY sub module
+**
+** DATE         : 14 May 2009
+** AUTHOR       : Lei Chuanhua
+** DESCRIPTION  : PCIe Root Complex Driver
+** COPYRIGHT    :       Copyright (c) 2009
+**                      Infineon Technologies AG
+**                      Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+**    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.
+** HISTORY
+** $Version $Date        $Author         $Comment
+** 0.0.1    14 May,2009  Lei Chuanhua    Initial version
+*******************************************************************************/
+/*!
+ \file ifxmips_pcie_phy.c
+ \ingroup IFX_PCIE  
+ \brief PCIe PHY PLL register programming source file
+*/
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <asm/paccess.h>
+#include <linux/delay.h>
+
+#include "ifxmips_pcie_reg.h"
+#include "ifxmips_pcie.h"
+
+/* PCIe PDI only supports 16 bit operation */
+
+#define IFX_PCIE_PHY_REG_WRITE16(__addr, __data) \
+    ((*(volatile u16 *) (__addr)) = (__data))
+    
+#define IFX_PCIE_PHY_REG_READ16(__addr)  \
+    (*(volatile u16 *) (__addr))
+
+#define IFX_PCIE_PHY_REG16(__addr)   \
+    (*(volatile u16 *) (__addr))
+
+#define IFX_PCIE_PHY_REG(__reg, __value, __mask) do { \
+    u16 read_data;                                    \
+    u16 write_data;                                   \
+    read_data = IFX_PCIE_PHY_REG_READ16((__reg));      \
+    write_data = (read_data & ((u16)~(__mask))) | (((u16)(__value)) & ((u16)(__mask)));\
+    IFX_PCIE_PHY_REG_WRITE16((__reg), write_data);               \
+} while (0)
+
+#define IFX_PCIE_PLL_TIMEOUT 1000 /* Tunnable */
+
+//#define IFX_PCI_PHY_REG_DUMP
+
+#ifdef IFX_PCI_PHY_REG_DUMP
+static void
+pcie_phy_reg_dump(int pcie_port) 
+{
+    printk("PLL REGFILE\n");
+    printk("PCIE_PHY_PLL_CTRL1    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL1(pcie_port)));
+    printk("PCIE_PHY_PLL_CTRL2    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL2(pcie_port)));
+    printk("PCIE_PHY_PLL_CTRL3    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL3(pcie_port)));
+    printk("PCIE_PHY_PLL_CTRL4    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL4(pcie_port)));
+    printk("PCIE_PHY_PLL_CTRL5    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL5(pcie_port)));
+    printk("PCIE_PHY_PLL_CTRL6    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL6(pcie_port)));
+    printk("PCIE_PHY_PLL_CTRL7    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_CTRL7(pcie_port)));
+    printk("PCIE_PHY_PLL_A_CTRL1  0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL1(pcie_port)));
+    printk("PCIE_PHY_PLL_A_CTRL2  0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL2(pcie_port)));
+    printk("PCIE_PHY_PLL_A_CTRL3  0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_A_CTRL3(pcie_port)));
+    printk("PCIE_PHY_PLL_STATUS   0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_STATUS(pcie_port)));
+
+    printk("TX1 REGFILE\n");
+    printk("PCIE_PHY_TX1_CTRL1    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL1(pcie_port)));
+    printk("PCIE_PHY_TX1_CTRL2    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL2(pcie_port)));
+    printk("PCIE_PHY_TX1_CTRL3    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_CTRL3(pcie_port)));
+    printk("PCIE_PHY_TX1_A_CTRL1  0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_A_CTRL1(pcie_port)));
+    printk("PCIE_PHY_TX1_A_CTRL2  0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_A_CTRL2(pcie_port)));
+    printk("PCIE_PHY_TX1_MOD1     0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD1(pcie_port)));
+    printk("PCIE_PHY_TX1_MOD2     0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD2(pcie_port)));
+    printk("PCIE_PHY_TX1_MOD3     0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX1_MOD3(pcie_port)));
+
+    printk("TX2 REGFILE\n");
+    printk("PCIE_PHY_TX2_CTRL1    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_CTRL1(pcie_port)));
+    printk("PCIE_PHY_TX2_CTRL2    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_CTRL2(pcie_port)));
+    printk("PCIE_PHY_TX2_A_CTRL1  0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_A_CTRL1(pcie_port)));
+    printk("PCIE_PHY_TX2_A_CTRL2  0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_A_CTRL2(pcie_port)));
+    printk("PCIE_PHY_TX2_MOD1     0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD1(pcie_port)));
+    printk("PCIE_PHY_TX2_MOD2     0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD2(pcie_port)));
+    printk("PCIE_PHY_TX2_MOD3     0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_TX2_MOD3(pcie_port)));
+
+    printk("RX1 REGFILE\n");
+    printk("PCIE_PHY_RX1_CTRL1    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CTRL1(pcie_port)));
+    printk("PCIE_PHY_RX1_CTRL2    0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CTRL2(pcie_port)));
+    printk("PCIE_PHY_RX1_CDR      0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_CDR(pcie_port)));
+    printk("PCIE_PHY_RX1_EI       0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_EI(pcie_port)));
+    printk("PCIE_PHY_RX1_A_CTRL   0x%04x\n", IFX_PCIE_PHY_REG16(PCIE_PHY_RX1_A_CTRL(pcie_port)));
+}
+#endif /* IFX_PCI_PHY_REG_DUMP */
+
+static void
+pcie_phy_comm_setup(int pcie_port)
+{
+   /* PLL Setting */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL1(pcie_port), 0x120e, 0xFFFF);
+
+    /* increase the bias reference voltage */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x39D7, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x0900, 0xFFFF);
+
+    /* Endcnt */
+    IFX_PCIE_PHY_REG(PCIE_PHY_RX1_EI(pcie_port), 0x0004, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_RX1_A_CTRL(pcie_port), 0x6803, 0xFFFF);
+
+    /* force */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0008, 0x0008);
+
+    /* predrv_ser_en */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL2(pcie_port), 0x0706, 0xFFFF);
+
+    /* ctrl_lim */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL3(pcie_port), 0x1FFF, 0xFFFF);
+
+    /* ctrl */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL1(pcie_port), 0x0800, 0xFF00);
+
+    /* predrv_ser_en */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4702, 0x7F00);
+
+    /* RTERM*/
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL2(pcie_port), 0x2e00, 0xFFFF);
+
+    /* Improved 100MHz clock output  */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL2(pcie_port), 0x3096, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4707, 0xFFFF);
+
+    /* Reduced CDR BW to avoid glitches */
+    IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CDR(pcie_port), 0x0235, 0xFFFF);
+}
+
+#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_MODE
+static void 
+pcie_phy_36mhz_mode_setup(int pcie_port) 
+{
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
+#ifdef IFX_PCI_PHY_REG_DUMP
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
+    pcie_phy_reg_dump(pcie_port);
+#endif
+
+    /* en_ext_mmd_div_ratio */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
+
+    /* ext_mmd_div_ratio*/
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
+
+    /* pll_ensdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
+
+    /* en_const_sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
+
+    /* mmd */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
+
+    /* lf_mode */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
+
+    /* const_sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
+
+    /* const sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
+
+    /* pllmod */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1b72, 0xFFFF);
+
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
+}
+#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_MODE */
+
+#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE
+static void 
+pcie_phy_36mhz_ssc_mode_setup(int pcie_port) 
+{
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
+#ifdef IFX_PCI_PHY_REG_DUMP
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
+    pcie_phy_reg_dump(pcie_port);
+#endif
+
+    /* PLL Setting */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL1(pcie_port), 0x120e, 0xFFFF);
+
+    /* Increase the bias reference voltage */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x39D7, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x0900, 0xFFFF);
+
+    /* Endcnt */
+    IFX_PCIE_PHY_REG(PCIE_PHY_RX1_EI(pcie_port), 0x0004, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_RX1_A_CTRL(pcie_port), 0x6803, 0xFFFF);
+
+    /* Force */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0008, 0x0008);
+
+    /* Predrv_ser_en */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL2(pcie_port), 0x0706, 0xFFFF);
+
+    /* ctrl_lim */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL3(pcie_port), 0x1FFF, 0xFFFF);
+
+    /* ctrl */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_A_CTRL1(pcie_port), 0x0800, 0xFF00);
+
+    /* predrv_ser_en */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4702, 0x7F00);
+
+    /* RTERM*/
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL2(pcie_port), 0x2e00, 0xFFFF);
+
+    /* en_ext_mmd_div_ratio */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
+
+    /* ext_mmd_div_ratio*/
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
+
+    /* pll_ensdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0400, 0x0400);
+
+    /* en_const_sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
+
+    /* mmd */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
+
+    /* lf_mode */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
+
+    /* const_sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
+
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0000, 0x0100);
+    /* const sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
+
+    /* pllmod */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1c72, 0xFFFF);
+
+    /* improved 100MHz clock output  */
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL2(pcie_port), 0x3096, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_A_CTRL2(pcie_port), 0x4707, 0xFFFF);
+
+    /* reduced CDR BW to avoid glitches */
+    IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CDR(pcie_port), 0x0235, 0xFFFF);
+    
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
+}
+#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE */
+
+#ifdef CONFIG_IFX_PCIE_PHY_25MHZ_MODE
+static void 
+pcie_phy_25mhz_mode_setup(int pcie_port) 
+{
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
+#ifdef IFX_PCI_PHY_REG_DUMP
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
+    pcie_phy_reg_dump(pcie_port);
+#endif
+    /* en_const_sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
+
+    /* pll_ensdm */    
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0000, 0x0200);
+
+    /* en_ext_mmd_div_ratio*/
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0002, 0x0002);
+
+    /* ext_mmd_div_ratio*/
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0040, 0x0070);
+
+    /* mmd */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x6000, 0xe000);
+
+    /* lf_mode */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x4000, 0x4000);
+
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
+}
+#endif /* CONFIG_IFX_PCIE_PHY_25MHZ_MODE */
+
+#ifdef CONFIG_IFX_PCIE_PHY_100MHZ_MODE
+static void 
+pcie_phy_100mhz_mode_setup(int pcie_port) 
+{
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d enter\n", __func__, pcie_port);
+#ifdef IFX_PCI_PHY_REG_DUMP
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "Initial PHY register dump\n");
+    pcie_phy_reg_dump(pcie_port);
+#endif 
+    /* en_ext_mmd_div_ratio */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0002);
+
+    /* ext_mmd_div_ratio*/
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL3(pcie_port), 0x0000, 0x0070);
+
+    /* pll_ensdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0200, 0x0200);
+
+    /* en_const_sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x0100, 0x0100);
+
+    /* mmd */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL3(pcie_port), 0x2000, 0xe000);
+
+    /* lf_mode */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_A_CTRL2(pcie_port), 0x0000, 0x4000);
+
+    /* const_sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL1(pcie_port), 0x38e4, 0xFFFF);
+
+    /* const sdm */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL2(pcie_port), 0x00ee, 0x00FF);
+
+    /* pllmod */
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL7(pcie_port), 0x0002, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL6(pcie_port), 0x3a04, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL5(pcie_port), 0xfae3, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_PLL_CTRL4(pcie_port), 0x1b72, 0xFFFF);
+
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "%s pcie_port %d exit\n", __func__, pcie_port);
+}
+#endif /* CONFIG_IFX_PCIE_PHY_100MHZ_MODE */
+
+static int
+pcie_phy_wait_startup_ready(int pcie_port)
+{
+    int i;
+
+    for (i = 0; i < IFX_PCIE_PLL_TIMEOUT; i++) {
+        if ((IFX_PCIE_PHY_REG16(PCIE_PHY_PLL_STATUS(pcie_port)) & 0x0040) != 0) {
+            break;
+        }
+        udelay(10);
+    }
+    if (i >= IFX_PCIE_PLL_TIMEOUT) {
+        printk(KERN_ERR "%s PLL Link timeout\n", __func__);
+        return -1;
+    }
+    return 0;
+}
+
+static void 
+pcie_phy_load_enable(int pcie_port, int slice) 
+{
+    /* Set the load_en of tx/rx slice to '1' */
+    switch (slice) {
+        case 1:
+            IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0010, 0x0010);
+            break;
+        case 2:
+            IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL1(pcie_port), 0x0010, 0x0010);
+            break;
+        case 3:
+            IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CTRL1(pcie_port), 0x0002, 0x0002);
+            break;
+    }
+}
+
+static void 
+pcie_phy_load_disable(int pcie_port, int slice) 
+{ 
+    /* set the load_en of tx/rx slice to '0' */ 
+    switch (slice) {
+        case 1:
+            IFX_PCIE_PHY_REG(PCIE_PHY_TX1_CTRL1(pcie_port), 0x0000, 0x0010);
+            break;
+        case 2:
+            IFX_PCIE_PHY_REG(PCIE_PHY_TX2_CTRL1(pcie_port), 0x0000, 0x0010);
+            break;
+        case 3: 
+            IFX_PCIE_PHY_REG(PCIE_PHY_RX1_CTRL1(pcie_port), 0x0000, 0x0002);
+            break;
+    }
+}
+
+static void 
+pcie_phy_load_war(int pcie_port)
+{
+    int slice;
+
+    for (slice = 1; slice < 4; slice++) {
+        pcie_phy_load_enable(pcie_port, slice);
+        udelay(1);
+        pcie_phy_load_disable(pcie_port, slice);
+    }
+}
+
+static void 
+pcie_phy_tx2_modulation(int pcie_port)
+{
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD1(pcie_port), 0x1FFE, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD2(pcie_port), 0xFFFE, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD3(pcie_port), 0x0601, 0xFFFF);
+    mdelay(1);
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX2_MOD3(pcie_port), 0x0001, 0xFFFF);
+}
+
+static void 
+pcie_phy_tx1_modulation(int pcie_port)
+{
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD1(pcie_port), 0x1FFE, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD2(pcie_port), 0xFFFE, 0xFFFF);
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD3(pcie_port), 0x0601, 0xFFFF);
+    mdelay(1);
+    IFX_PCIE_PHY_REG(PCIE_PHY_TX1_MOD3(pcie_port), 0x0001, 0xFFFF);
+}
+
+static void
+pcie_phy_tx_modulation_war(int pcie_port)
+{
+    int i;
+
+#define PCIE_PHY_MODULATION_NUM 5 
+    for (i = 0; i < PCIE_PHY_MODULATION_NUM; i++) {
+        pcie_phy_tx2_modulation(pcie_port);
+        pcie_phy_tx1_modulation(pcie_port);
+    }
+#undef PCIE_PHY_MODULATION_NUM
+}
+
+void
+pcie_phy_clock_mode_setup(int pcie_port)
+{
+    pcie_pdi_big_endian(pcie_port);
+
+    /* Enable PDI to access PCIe PHY register */
+    pcie_pdi_pmu_enable(pcie_port);
+
+    /* Configure PLL and PHY clock */
+    pcie_phy_comm_setup(pcie_port);
+
+#ifdef CONFIG_IFX_PCIE_PHY_36MHZ_MODE
+    pcie_phy_36mhz_mode_setup(pcie_port);
+#elif defined(CONFIG_IFX_PCIE_PHY_36MHZ_SSC_MODE)
+    pcie_phy_36mhz_ssc_mode_setup(pcie_port);
+#elif defined(CONFIG_IFX_PCIE_PHY_25MHZ_MODE)
+    pcie_phy_25mhz_mode_setup(pcie_port);
+#elif defined (CONFIG_IFX_PCIE_PHY_100MHZ_MODE)
+    pcie_phy_100mhz_mode_setup(pcie_port);
+#else
+    #error "PCIE PHY Clock Mode must be chosen first!!!!"
+#endif /* CONFIG_IFX_PCIE_PHY_36MHZ_MODE */
+
+    /* Enable PCIe PHY and make PLL setting take effect */
+    pcie_phy_pmu_enable(pcie_port);
+
+    /* Check if we are in startup_ready status */
+    pcie_phy_wait_startup_ready(pcie_port);
+
+    pcie_phy_load_war(pcie_port);
+
+    /* Apply TX modulation workarounds */
+    pcie_phy_tx_modulation_war(pcie_port);
+
+#ifdef IFX_PCI_PHY_REG_DUMP
+    IFX_PCIE_PRINT(PCIE_MSG_PHY, "Modified PHY register dump\n");
+    pcie_phy_reg_dump(pcie_port);
+#endif
+}
+
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pcie_pm.c
@@ -0,0 +1,176 @@
+/******************************************************************************
+**
+** FILE NAME    : ifxmips_pcie_pm.c
+** PROJECT      : IFX UEIP
+** MODULES      : PCIE Root Complex Driver
+**
+** DATE         : 21 Dec 2009
+** AUTHOR       : Lei Chuanhua
+** DESCRIPTION  : PCIE Root Complex Driver Power Managment
+** COPYRIGHT    :       Copyright (c) 2009
+**                      Lantiq Deutschland GmbH
+**                      Am Campeon 3, 85579 Neubiberg, Germany
+**
+**    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.
+**
+** HISTORY
+** $Date        $Author         $Comment
+** 21 Dec,2009   Lei Chuanhua    First UEIP release
+*******************************************************************************/
+/*!
+  \defgroup IFX_PCIE_PM Power Management functions
+  \ingroup IFX_PCIE
+  \brief IFX PCIE Root Complex Driver power management functions
+*/
+
+/*!
+ \file ifxmips_pcie_pm.c
+ \ingroup IFX_PCIE    
+ \brief source file for PCIE Root Complex Driver Power Management
+*/
+
+#ifndef EXPORT_SYMTAB
+#define EXPORT_SYMTAB
+#endif
+#ifndef AUTOCONF_INCLUDED
+#include <linux/config.h>
+#endif /* AUTOCONF_INCLUDED */
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <asm/system.h>
+
+/* Project header */
+#include <asm/ifx/ifx_types.h>
+#include <asm/ifx/ifx_regs.h>
+#include <asm/ifx/common_routines.h>
+#include <asm/ifx/ifx_pmcu.h>
+#include "ifxmips_pcie_pm.h"
+
+/** 
+ * \fn static IFX_PMCU_RETURN_t ifx_pcie_pmcu_state_change(IFX_PMCU_STATE_t pmcuState)
+ * \brief the callback function to request pmcu state in the power management hardware-dependent module
+ *
+ * \param pmcuState This parameter is a PMCU state.
+ *
+ * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
+ * \return IFX_PMCU_RETURN_ERROR   Failed to set power state.
+ * \return IFX_PMCU_RETURN_DENIED  Not allowed to operate power state
+ * \ingroup IFX_PCIE_PM
+ */
+static IFX_PMCU_RETURN_t 
+ifx_pcie_pmcu_state_change(IFX_PMCU_STATE_t pmcuState)
+{
+    switch(pmcuState) 
+    {
+        case IFX_PMCU_STATE_D0:
+            return IFX_PMCU_RETURN_SUCCESS;
+        case IFX_PMCU_STATE_D1: // Not Applicable
+            return IFX_PMCU_RETURN_DENIED;
+        case IFX_PMCU_STATE_D2: // Not Applicable
+            return IFX_PMCU_RETURN_DENIED;
+        case IFX_PMCU_STATE_D3: // Module clock gating and Power gating
+            return IFX_PMCU_RETURN_SUCCESS;
+        default:
+            return IFX_PMCU_RETURN_DENIED;
+    }
+}
+
+/** 
+ * \fn static IFX_PMCU_RETURN_t ifx_pcie_pmcu_state_get(IFX_PMCU_STATE_t *pmcuState)
+ * \brief the callback function to get pmcu state in the power management hardware-dependent module
+
+ * \param pmcuState Pointer to return power state.
+ *
+ * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
+ * \return IFX_PMCU_RETURN_ERROR   Failed to set power state.
+ * \return IFX_PMCU_RETURN_DENIED  Not allowed to operate power state
+ * \ingroup IFX_PCIE_PM
+ */
+static IFX_PMCU_RETURN_t 
+ifx_pcie_pmcu_state_get(IFX_PMCU_STATE_t *pmcuState)
+{
+    return IFX_PMCU_RETURN_SUCCESS;
+}
+
+/**
+ * \fn IFX_PMCU_RETURN_t ifx_pcie_pmcu_prechange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ * \brief Apply all callbacks registered to be executed before a state change for pmcuModule
+ * 
+ * \param   pmcuModule      Module
+ * \param   newState        New state
+ * \param   oldState        Old state
+ * \return  IFX_PMCU_RETURN_SUCCESS Set Power State successfully
+ * \return  IFX_PMCU_RETURN_ERROR   Failed to set power state.
+ * \ingroup IFX_PCIE_PM
+ */
+static IFX_PMCU_RETURN_t 
+ifx_pcie_pmcu_prechange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+{
+    return IFX_PMCU_RETURN_SUCCESS;
+}
+
+/**
+ * \fn IFX_PMCU_RETURN_t ifx_pcie_pmcu_postchange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+ * \brief Apply all callbacks registered to be executed before a state change for pmcuModule
+ * 
+ * \param   pmcuModule      Module
+ * \param   newState        New state
+ * \param   oldState        Old state
+ * \return IFX_PMCU_RETURN_SUCCESS Set Power State successfully
+ * \return IFX_PMCU_RETURN_ERROR   Failed to set power state.
+ * \ingroup IFX_PCIE_PM
+ */
+static IFX_PMCU_RETURN_t 
+ifx_pcie_pmcu_postchange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
+{
+    return IFX_PMCU_RETURN_SUCCESS;
+}
+
+/** 
+ * \fn static void ifx_pcie_pmcu_init(void)
+ * \brief Register with central PMCU module
+ * \return none
+ * \ingroup IFX_PCIE_PM
+ */
+void
+ifx_pcie_pmcu_init(void)
+{
+    IFX_PMCU_REGISTER_t pmcuRegister;
+
+    /* XXX, hook driver context */
+
+    /* State function register */
+    memset(&pmcuRegister, 0, sizeof(IFX_PMCU_REGISTER_t));
+    pmcuRegister.pmcuModule = IFX_PMCU_MODULE_PCIE;
+    pmcuRegister.pmcuModuleNr = 0;
+    pmcuRegister.ifx_pmcu_state_change = ifx_pcie_pmcu_state_change;
+    pmcuRegister.ifx_pmcu_state_get = ifx_pcie_pmcu_state_get;
+    pmcuRegister.pre = ifx_pcie_pmcu_prechange;
+    pmcuRegister.post= ifx_pcie_pmcu_postchange;
+    ifx_pmcu_register(&pmcuRegister); 
+}
+
+/** 
+ * \fn static void ifx_pcie_pmcu_exit(void)
+ * \brief Unregister with central PMCU module
+ *
+ * \return none
+ * \ingroup IFX_PCIE_PM
+ */
+void
+ifx_pcie_pmcu_exit(void)
+{
+    IFX_PMCU_REGISTER_t pmcuUnRegister;
+
+   /* XXX, hook driver context */
+   
+    pmcuUnRegister.pmcuModule = IFX_PMCU_MODULE_PCIE;
+    pmcuUnRegister.pmcuModuleNr = 0;
+    ifx_pmcu_unregister(&pmcuUnRegister);
+}
+
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pcie_pm.h
@@ -0,0 +1,36 @@
+/******************************************************************************
+**
+** FILE NAME    : ifxmips_pcie_pm.h
+** PROJECT      : IFX UEIP
+** MODULES      : PCIe Root Complex Driver
+**
+** DATE         : 21 Dec 2009
+** AUTHOR       : Lei Chuanhua
+** DESCRIPTION  : PCIe Root Complex Driver Power Managment
+** COPYRIGHT    :       Copyright (c) 2009
+**                      Lantiq Deutschland GmbH
+**                      Am Campeon 3, 85579 Neubiberg, Germany
+**
+**    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.
+**
+** HISTORY
+** $Date        $Author         $Comment
+** 21 Dec,2009   Lei Chuanhua    First UEIP release
+*******************************************************************************/
+/*!
+ \file ifxmips_pcie_pm.h
+ \ingroup IFX_PCIE 
+ \brief header file for PCIe Root Complex Driver Power Management
+*/
+
+#ifndef IFXMIPS_PCIE_PM_H
+#define IFXMIPS_PCIE_PM_H
+
+void ifx_pcie_pmcu_init(void);
+void ifx_pcie_pmcu_exit(void);
+
+#endif /* IFXMIPS_PCIE_PM_H  */
+
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pcie_reg.h
@@ -0,0 +1,1001 @@
+/******************************************************************************
+**
+** FILE NAME    : ifxmips_pcie_reg.h
+** PROJECT      : IFX UEIP for VRX200
+** MODULES      : PCIe module
+**
+** DATE         : 02 Mar 2009
+** AUTHOR       : Lei Chuanhua
+** DESCRIPTION  : PCIe Root Complex Driver
+** COPYRIGHT    :       Copyright (c) 2009
+**                      Infineon Technologies AG
+**                      Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+**    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.
+** HISTORY
+** $Version $Date        $Author         $Comment
+** 0.0.1    17 Mar,2009  Lei Chuanhua    Initial version
+*******************************************************************************/
+#ifndef IFXMIPS_PCIE_REG_H
+#define IFXMIPS_PCIE_REG_H
+/*!
+ \file ifxmips_pcie_reg.h
+ \ingroup IFX_PCIE  
+ \brief header file for PCIe module register definition
+*/
+/* PCIe Address Mapping Base */
+#define PCIE_CFG_PHY_BASE        0x1D000000UL
+#define PCIE_CFG_BASE           (KSEG1 + PCIE_CFG_PHY_BASE)
+#define PCIE_CFG_SIZE           (8 * 1024 * 1024)
+
+#define PCIE_MEM_PHY_BASE        0x1C000000UL
+#define PCIE_MEM_BASE           (KSEG1 + PCIE_MEM_PHY_BASE)
+#define PCIE_MEM_SIZE           (16 * 1024 * 1024)
+#define PCIE_MEM_PHY_END        (PCIE_MEM_PHY_BASE + PCIE_MEM_SIZE - 1)
+
+#define PCIE_IO_PHY_BASE         0x1D800000UL
+#define PCIE_IO_BASE            (KSEG1 + PCIE_IO_PHY_BASE)
+#define PCIE_IO_SIZE            (1 * 1024 * 1024)
+#define PCIE_IO_PHY_END         (PCIE_IO_PHY_BASE + PCIE_IO_SIZE - 1)
+
+#define PCIE_RC_CFG_BASE        (KSEG1 + 0x1D900000)
+#define PCIE_APP_LOGIC_REG      (KSEG1 + 0x1E100900)
+#define PCIE_MSI_PHY_BASE        0x1F600000UL
+
+#define PCIE_PDI_PHY_BASE        0x1F106800UL
+#define PCIE_PDI_BASE           (KSEG1 + PCIE_PDI_PHY_BASE)
+#define PCIE_PDI_SIZE            0x400
+
+#define PCIE1_CFG_PHY_BASE        0x19000000UL
+#define PCIE1_CFG_BASE           (KSEG1 + PCIE1_CFG_PHY_BASE)
+#define PCIE1_CFG_SIZE           (8 * 1024 * 1024)
+
+#define PCIE1_MEM_PHY_BASE        0x18000000UL
+#define PCIE1_MEM_BASE           (KSEG1 + PCIE1_MEM_PHY_BASE)
+#define PCIE1_MEM_SIZE           (16 * 1024 * 1024)
+#define PCIE1_MEM_PHY_END        (PCIE1_MEM_PHY_BASE + PCIE1_MEM_SIZE - 1)
+
+#define PCIE1_IO_PHY_BASE         0x19800000UL
+#define PCIE1_IO_BASE            (KSEG1 + PCIE1_IO_PHY_BASE)
+#define PCIE1_IO_SIZE            (1 * 1024 * 1024)
+#define PCIE1_IO_PHY_END         (PCIE1_IO_PHY_BASE + PCIE1_IO_SIZE - 1)
+
+#define PCIE1_RC_CFG_BASE        (KSEG1 + 0x19900000)
+#define PCIE1_APP_LOGIC_REG      (KSEG1 + 0x1E100700)
+#define PCIE1_MSI_PHY_BASE        0x1F400000UL
+
+#define PCIE1_PDI_PHY_BASE        0x1F700400UL
+#define PCIE1_PDI_BASE           (KSEG1 + PCIE1_PDI_PHY_BASE)
+#define PCIE1_PDI_SIZE            0x400
+
+#define PCIE_CFG_PORT_TO_BASE(X)     ((X) > 0 ? (PCIE1_CFG_BASE) : (PCIE_CFG_BASE))
+#define PCIE_MEM_PORT_TO_BASE(X)     ((X) > 0 ? (PCIE1_MEM_BASE) : (PCIE_MEM_BASE))
+#define PCIE_IO_PORT_TO_BASE(X)      ((X) > 0 ? (PCIE1_IO_BASE) : (PCIE_IO_BASE))
+#define PCIE_MEM_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_PHY_BASE) : (PCIE_MEM_PHY_BASE))
+#define PCIE_MEM_PHY_PORT_TO_END(X)  ((X) > 0 ? (PCIE1_MEM_PHY_END) : (PCIE_MEM_PHY_END))
+#define PCIE_IO_PHY_PORT_TO_BASE(X)  ((X) > 0 ? (PCIE1_IO_PHY_BASE) : (PCIE_IO_PHY_BASE))
+#define PCIE_IO_PHY_PORT_TO_END(X)   ((X) > 0 ? (PCIE1_IO_PHY_END) : (PCIE_IO_PHY_END))
+#define PCIE_APP_PORT_TO_BASE(X)     ((X) > 0 ? (PCIE1_APP_LOGIC_REG) : (PCIE_APP_LOGIC_REG))
+#define PCIE_RC_PORT_TO_BASE(X)      ((X) > 0 ? (PCIE1_RC_CFG_BASE) : (PCIE_RC_CFG_BASE))
+#define PCIE_PHY_PORT_TO_BASE(X)     ((X) > 0 ? (PCIE1_PDI_BASE) : (PCIE_PDI_BASE))
+
+/* PCIe Application Logic Register */
+/* RC Core Control Register */
+#define PCIE_RC_CCR(X)                      (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x10)
+/* This should be enabled after initializing configuratin registers
+ * Also should check link status retraining bit
+ */
+#define PCIE_RC_CCR_LTSSM_ENABLE             0x00000001    /* Enable LTSSM to continue link establishment */
+
+/* RC Core Debug Register */
+#define PCIE_RC_DR(X)                       (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x14)
+#define PCIE_RC_DR_DLL_UP                    0x00000001  /* Data Link Layer Up */
+#define PCIE_RC_DR_CURRENT_POWER_STATE       0x0000000E  /* Current Power State */
+#define PCIE_RC_DR_CURRENT_POWER_STATE_S     1
+#define PCIE_RC_DR_CURRENT_LTSSM_STATE       0x000001F0  /* Current LTSSM State */
+#define PCIE_RC_DR_CURRENT_LTSSM_STATE_S     4
+
+#define PCIE_RC_DR_PM_DEV_STATE              0x00000E00  /* Power Management D-State */
+#define PCIE_RC_DR_PM_DEV_STATE_S            9
+
+#define PCIE_RC_DR_PM_ENABLED                0x00001000  /* Power Management State from PMU */
+#define PCIE_RC_DR_PME_EVENT_ENABLED         0x00002000  /* Power Management Event Enable State */
+#define PCIE_RC_DR_AUX_POWER_ENABLED         0x00004000  /* Auxiliary Power Enable */
+
+/* Current Power State Definition */
+enum {
+    PCIE_RC_DR_D0 = 0,
+    PCIE_RC_DR_D1,   /* Not supported */
+    PCIE_RC_DR_D2,   /* Not supported */
+    PCIE_RC_DR_D3,
+    PCIE_RC_DR_UN,
+};
+
+/* PHY Link Status Register */
+#define PCIE_PHY_SR(X)                      (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x18)
+#define PCIE_PHY_SR_PHY_LINK_UP              0x00000001   /* PHY Link Up/Down Indicator */
+
+/* Electromechanical Control Register */
+#define PCIE_EM_CR(X)                       (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x1C)
+#define PCIE_EM_CR_CARD_IS_PRESENT           0x00000001  /* Card Presence Detect State */
+#define PCIE_EM_CR_MRL_OPEN                  0x00000002  /* MRL Sensor State */
+#define PCIE_EM_CR_POWER_FAULT_SET           0x00000004  /* Power Fault Detected */
+#define PCIE_EM_CR_MRL_SENSOR_SET            0x00000008  /* MRL Sensor Changed */
+#define PCIE_EM_CR_PRESENT_DETECT_SET        0x00000010  /* Card Presense Detect Changed */
+#define PCIE_EM_CR_CMD_CPL_INT_SET           0x00000020  /* Command Complete Interrupt */
+#define PCIE_EM_CR_SYS_INTERLOCK_SET         0x00000040  /* System Electromechanical IterLock Engaged */
+#define PCIE_EM_CR_ATTENTION_BUTTON_SET      0x00000080  /* Attention Button Pressed */
+
+/* Interrupt Status Register */
+#define PCIE_IR_SR(X)                       (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x20)
+#define PCIE_IR_SR_PME_CAUSE_MSI             0x00000002  /* MSI caused by PME */
+#define PCIE_IR_SR_HP_PME_WAKE_GEN           0x00000004  /* Hotplug PME Wake Generation */
+#define PCIE_IR_SR_HP_MSI                    0x00000008  /* Hotplug MSI */
+#define PCIE_IR_SR_AHB_LU_ERR                0x00000030  /* AHB Bridge Lookup Error Signals */
+#define PCIE_IR_SR_AHB_LU_ERR_S              4
+#define PCIE_IR_SR_INT_MSG_NUM               0x00003E00  /* Interrupt Message Number */
+#define PCIE_IR_SR_INT_MSG_NUM_S             9
+#define PCIE_IR_SR_AER_INT_MSG_NUM           0xF8000000  /* Advanced Error Interrupt Message Number */
+#define PCIE_IR_SR_AER_INT_MSG_NUM_S         27
+
+/* Message Control Register */
+#define PCIE_MSG_CR(X)                      (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x30)
+#define PCIE_MSG_CR_GEN_PME_TURN_OFF_MSG     0x00000001  /* Generate PME Turn Off Message */
+#define PCIE_MSG_CR_GEN_UNLOCK_MSG           0x00000002  /* Generate Unlock Message */
+
+#define PCIE_VDM_DR(X)                      (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x34)
+
+/* Vendor-Defined Message Requester ID Register */
+#define PCIE_VDM_RID(X)                     (PCIE_APP_PORT_TO_BASE (X) + 0x38)
+#define PCIE_VDM_RID_VENROR_MSG_REQ_ID       0x0000FFFF
+#define PCIE_VDM_RID_VDMRID_S                0
+
+/* ASPM Control Register */
+#define PCIE_ASPM_CR(X)                     (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x40)
+#define PCIE_ASPM_CR_HOT_RST                 0x00000001  /* Hot Reset Request to the downstream device */
+#define PCIE_ASPM_CR_REQ_EXIT_L1             0x00000002  /* Request to Exit L1 */
+#define PCIE_ASPM_CR_REQ_ENTER_L1            0x00000004  /* Request to Enter L1 */
+
+/* Vendor Message DW0 Register */
+#define PCIE_VM_MSG_DW0(X)                  (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x50)
+#define PCIE_VM_MSG_DW0_TYPE                 0x0000001F  /* Message type */
+#define PCIE_VM_MSG_DW0_TYPE_S               0
+#define PCIE_VM_MSG_DW0_FORMAT               0x00000060  /* Format */
+#define PCIE_VM_MSG_DW0_FORMAT_S             5
+#define PCIE_VM_MSG_DW0_TC                   0x00007000  /* Traffic Class */
+#define PCIE_VM_MSG_DW0_TC_S                 12
+#define PCIE_VM_MSG_DW0_ATTR                 0x000C0000  /* Atrributes */
+#define PCIE_VM_MSG_DW0_ATTR_S               18
+#define PCIE_VM_MSG_DW0_EP_TLP               0x00100000  /* Poisoned TLP */
+#define PCIE_VM_MSG_DW0_TD                   0x00200000  /* TLP Digest */
+#define PCIE_VM_MSG_DW0_LEN                  0xFFC00000  /* Length */
+#define PCIE_VM_MSG_DW0_LEN_S                22
+
+/* Format Definition */
+enum {
+    PCIE_VM_MSG_FORMAT_00 = 0,  /* 3DW Hdr, no data*/
+    PCIE_VM_MSG_FORMAT_01,      /* 4DW Hdr, no data */
+    PCIE_VM_MSG_FORMAT_10,      /* 3DW Hdr, with data */
+    PCIE_VM_MSG_FORMAT_11,      /* 4DW Hdr, with data */
+};
+
+/* Traffic Class Definition */
+enum {
+    PCIE_VM_MSG_TC0 = 0,
+    PCIE_VM_MSG_TC1,
+    PCIE_VM_MSG_TC2,
+    PCIE_VM_MSG_TC3,
+    PCIE_VM_MSG_TC4,
+    PCIE_VM_MSG_TC5,
+    PCIE_VM_MSG_TC6,
+    PCIE_VM_MSG_TC7,
+};
+
+/* Attributes Definition */
+enum {
+    PCIE_VM_MSG_ATTR_00 = 0,   /* RO and No Snoop cleared */
+    PCIE_VM_MSG_ATTR_01,       /* RO cleared , No Snoop set */
+    PCIE_VM_MSG_ATTR_10,       /* RO set, No Snoop cleared*/
+    PCIE_VM_MSG_ATTR_11,       /* RO and No Snoop set */
+};
+
+/* Payload Size Definition */
+#define PCIE_VM_MSG_LEN_MIN  0
+#define PCIE_VM_MSG_LEN_MAX  1024
+
+/* Vendor Message DW1 Register */
+#define PCIE_VM_MSG_DW1(X)                 (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x54)
+#define PCIE_VM_MSG_DW1_FUNC_NUM            0x00000070  /* Function Number */
+#define PCIE_VM_MSG_DW1_FUNC_NUM_S          8
+#define PCIE_VM_MSG_DW1_CODE                0x00FF0000  /* Message Code */
+#define PCIE_VM_MSG_DW1_CODE_S              16
+#define PCIE_VM_MSG_DW1_TAG                 0xFF000000  /* Tag */
+#define PCIE_VM_MSG_DW1_TAG_S               24
+
+#define PCIE_VM_MSG_DW2(X)                  (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x58)
+#define PCIE_VM_MSG_DW3(X)                  (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x5C)
+
+/* Vendor Message Request Register */
+#define PCIE_VM_MSG_REQR(X)                 (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x60)
+#define PCIE_VM_MSG_REQR_REQ                 0x00000001  /* Vendor Message Request */
+
+
+/* AHB Slave Side Band Control Register */
+#define PCIE_AHB_SSB(X)                     (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x70)
+#define PCIE_AHB_SSB_REQ_BCM                0x00000001 /* Slave Reques BCM filed */
+#define PCIE_AHB_SSB_REQ_EP                 0x00000002 /* Slave Reques EP filed */
+#define PCIE_AHB_SSB_REQ_TD                 0x00000004 /* Slave Reques TD filed */
+#define PCIE_AHB_SSB_REQ_ATTR               0x00000018 /* Slave Reques Attribute number */
+#define PCIE_AHB_SSB_REQ_ATTR_S             3
+#define PCIE_AHB_SSB_REQ_TC                 0x000000E0 /* Slave Request TC Field */
+#define PCIE_AHB_SSB_REQ_TC_S               5
+
+/* AHB Master SideBand Ctrl Register */
+#define PCIE_AHB_MSB(X)                     (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x74)
+#define PCIE_AHB_MSB_RESP_ATTR               0x00000003 /* Master Response Attribute number */
+#define PCIE_AHB_MSB_RESP_ATTR_S             0
+#define PCIE_AHB_MSB_RESP_BAD_EOT            0x00000004 /* Master Response Badeot filed */
+#define PCIE_AHB_MSB_RESP_BCM                0x00000008 /* Master Response BCM filed */
+#define PCIE_AHB_MSB_RESP_EP                 0x00000010 /* Master Response EP filed */
+#define PCIE_AHB_MSB_RESP_TD                 0x00000020 /* Master Response TD filed */
+#define PCIE_AHB_MSB_RESP_FUN_NUM            0x000003C0 /* Master Response Function number */
+#define PCIE_AHB_MSB_RESP_FUN_NUM_S          6
+
+/* AHB Control Register, fixed bus enumeration exception */
+#define PCIE_AHB_CTRL(X)                     (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x78)
+#define PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS     0x00000001 
+
+/* Interrupt Enalbe Register */
+#define PCIE_IRNEN(X)                        (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF4)
+#define PCIE_IRNCR(X)                        (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF8)
+#define PCIE_IRNICR(X)                       (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xFC)
+
+/* PCIe interrupt enable/control/capture register definition */
+#define PCIE_IRN_AER_REPORT                 0x00000001  /* AER Interrupt */
+#define PCIE_IRN_AER_MSIX                   0x00000002  /* Advanced Error MSI-X Interrupt */
+#define PCIE_IRN_PME                        0x00000004  /* PME Interrupt */
+#define PCIE_IRN_HOTPLUG                    0x00000008  /* Hotplug Interrupt */
+#define PCIE_IRN_RX_VDM_MSG                 0x00000010  /* Vendor-Defined Message Interrupt */
+#define PCIE_IRN_RX_CORRECTABLE_ERR_MSG     0x00000020  /* Correctable Error Message Interrupt */
+#define PCIE_IRN_RX_NON_FATAL_ERR_MSG       0x00000040  /* Non-fatal Error Message */
+#define PCIE_IRN_RX_FATAL_ERR_MSG           0x00000080  /* Fatal Error Message */
+#define PCIE_IRN_RX_PME_MSG                 0x00000100  /* PME Message Interrupt */
+#define PCIE_IRN_RX_PME_TURNOFF_ACK         0x00000200  /* PME Turnoff Ack Message Interrupt */
+#define PCIE_IRN_AHB_BR_FATAL_ERR           0x00000400  /* AHB Fatal Error Interrupt */
+#define PCIE_IRN_LINK_AUTO_BW_STATUS        0x00000800  /* Link Auto Bandwidth Status Interrupt */
+#define PCIE_IRN_BW_MGT                     0x00001000  /* Bandwidth Managment Interrupt */
+#define PCIE_IRN_INTA                       0x00002000  /* INTA */
+#define PCIE_IRN_INTB                       0x00004000  /* INTB */
+#define PCIE_IRN_INTC                       0x00008000  /* INTC */
+#define PCIE_IRN_INTD                       0x00010000  /* INTD */
+#define PCIE_IRN_WAKEUP                     0x00020000  /* Wake up Interrupt */
+
+#define PCIE_RC_CORE_COMBINED_INT    (PCIE_IRN_AER_REPORT |  PCIE_IRN_AER_MSIX | PCIE_IRN_PME | \
+                                      PCIE_IRN_HOTPLUG | PCIE_IRN_RX_VDM_MSG | PCIE_IRN_RX_CORRECTABLE_ERR_MSG |\
+                                      PCIE_IRN_RX_NON_FATAL_ERR_MSG | PCIE_IRN_RX_FATAL_ERR_MSG | \
+                                      PCIE_IRN_RX_PME_MSG | PCIE_IRN_RX_PME_TURNOFF_ACK | PCIE_IRN_AHB_BR_FATAL_ERR | \
+                                      PCIE_IRN_LINK_AUTO_BW_STATUS | PCIE_IRN_BW_MGT)
+/* PCIe RC Configuration Register */
+#define PCIE_VDID(X)                (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x00)
+
+/* Bit definition from pci_reg.h */
+#define PCIE_PCICMDSTS(X)           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x04)
+#define PCIE_CCRID(X)               (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x08)
+#define PCIE_CLSLTHTBR(X)           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x0C) /* EP only */
+/* BAR0, BAR1,Only necessary if the bridges implements a device-specific register set or memory buffer */
+#define PCIE_BAR0(X)                (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10) /* Not used*/
+#define PCIE_BAR1(X)                (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14) /* Not used */
+
+#define PCIE_BNR(X)                 (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x18) /* Mandatory */
+/* Bus Number Register bits */
+#define PCIE_BNR_PRIMARY_BUS_NUM             0x000000FF
+#define PCIE_BNR_PRIMARY_BUS_NUM_S           0
+#define PCIE_PNR_SECONDARY_BUS_NUM           0x0000FF00
+#define PCIE_PNR_SECONDARY_BUS_NUM_S         8
+#define PCIE_PNR_SUB_BUS_NUM                 0x00FF0000
+#define PCIE_PNR_SUB_BUS_NUM_S               16
+
+/* IO Base/Limit Register bits */
+#define PCIE_IOBLSECS(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x1C)  /* RC only */
+#define PCIE_IOBLSECS_32BIT_IO_ADDR             0x00000001
+#define PCIE_IOBLSECS_IO_BASE_ADDR              0x000000F0
+#define PCIE_IOBLSECS_IO_BASE_ADDR_S            4
+#define PCIE_IOBLSECS_32BIT_IOLIMT              0x00000100
+#define PCIE_IOBLSECS_IO_LIMIT_ADDR             0x0000F000
+#define PCIE_IOBLSECS_IO_LIMIT_ADDR_S           12
+
+/* Non-prefetchable Memory Base/Limit Register bit */
+#define PCIE_MBML(X)                           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x20)  /* RC only */
+#define PCIE_MBML_MEM_BASE_ADDR                 0x0000FFF0
+#define PCIE_MBML_MEM_BASE_ADDR_S               4
+#define PCIE_MBML_MEM_LIMIT_ADDR                0xFFF00000
+#define PCIE_MBML_MEM_LIMIT_ADDR_S              20
+
+/* Prefetchable Memory Base/Limit Register bit */
+#define PCIE_PMBL(X)                           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x24)  /* RC only */
+#define PCIE_PMBL_64BIT_ADDR                    0x00000001
+#define PCIE_PMBL_UPPER_12BIT                   0x0000FFF0
+#define PCIE_PMBL_UPPER_12BIT_S                 4
+#define PCIE_PMBL_E64MA                         0x00010000
+#define PCIE_PMBL_END_ADDR                      0xFFF00000
+#define PCIE_PMBL_END_ADDR_S                    20
+#define PCIE_PMBU32(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x28)  /* RC only */
+#define PCIE_PMLU32(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x2C)  /* RC only */
+
+/* I/O Base/Limit Upper 16 bits register */
+#define PCIE_IO_BANDL(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x30)  /* RC only */
+#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE        0x0000FFFF
+#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE_S      0
+#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT       0xFFFF0000
+#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT_S     16
+
+#define PCIE_CPR(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x34)
+#define PCIE_EBBAR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x38)
+
+/* Interrupt and Secondary Bridge Control Register */
+#define PCIE_INTRBCTRL(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x3C)
+
+#define PCIE_INTRBCTRL_INT_LINE                 0x000000FF
+#define PCIE_INTRBCTRL_INT_LINE_S               0
+#define PCIE_INTRBCTRL_INT_PIN                  0x0000FF00
+#define PCIE_INTRBCTRL_INT_PIN_S                8
+#define PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE   0x00010000    /* #PERR */
+#define PCIE_INTRBCTRL_SERR_ENABLE              0x00020000    /* #SERR */
+#define PCIE_INTRBCTRL_ISA_ENABLE               0x00040000    /* ISA enable, IO 64KB only */
+#define PCIE_INTRBCTRL_VGA_ENABLE               0x00080000    /* VGA enable */
+#define PCIE_INTRBCTRL_VGA_16BIT_DECODE         0x00100000    /* VGA 16bit decode */
+#define PCIE_INTRBCTRL_RST_SECONDARY_BUS        0x00400000    /* Secondary bus rest, hot rest, 1ms */
+/* Others are read only */
+enum {
+    PCIE_INTRBCTRL_INT_NON = 0,
+    PCIE_INTRBCTRL_INTA,
+    PCIE_INTRBCTRL_INTB,
+    PCIE_INTRBCTRL_INTC,
+    PCIE_INTRBCTRL_INTD,
+};
+
+#define PCIE_PM_CAPR(X)                  (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x40)
+
+/* Power Management Control and Status Register */
+#define PCIE_PM_CSR(X)                   (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x44)
+
+#define PCIE_PM_CSR_POWER_STATE           0x00000003   /* Power State */
+#define PCIE_PM_CSR_POWER_STATE_S         0
+#define PCIE_PM_CSR_SW_RST                0x00000008   /* Soft Reset Enabled */
+#define PCIE_PM_CSR_PME_ENABLE            0x00000100   /* PME Enable */
+#define PCIE_PM_CSR_PME_STATUS            0x00008000   /* PME status */
+
+/* MSI Capability Register for EP */
+#define PCIE_MCAPR(X)                    (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x50)
+
+#define PCIE_MCAPR_MSI_CAP_ID             0x000000FF  /* MSI Capability ID */
+#define PCIE_MCAPR_MSI_CAP_ID_S           0
+#define PCIE_MCAPR_MSI_NEXT_CAP_PTR       0x0000FF00  /* Next Capability Pointer */
+#define PCIE_MCAPR_MSI_NEXT_CAP_PTR_S     8
+#define PCIE_MCAPR_MSI_ENABLE             0x00010000  /* MSI Enable */
+#define PCIE_MCAPR_MULTI_MSG_CAP          0x000E0000  /* Multiple Message Capable */
+#define PCIE_MCAPR_MULTI_MSG_CAP_S        17
+#define PCIE_MCAPR_MULTI_MSG_ENABLE       0x00700000  /* Multiple Message Enable */
+#define PCIE_MCAPR_MULTI_MSG_ENABLE_S     20
+#define PCIE_MCAPR_ADDR64_CAP             0X00800000  /* 64-bit Address Capable */
+
+/* MSI Message Address Register */
+#define PCIE_MA(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x54)
+
+#define PCIE_MA_ADDR_MASK                 0xFFFFFFFC  /* Message Address */
+
+/* MSI Message Upper Address Register */
+#define PCIE_MUA(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x58)
+
+/* MSI Message Data Register */
+#define PCIE_MD(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x5C)
+
+#define PCIE_MD_DATA                      0x0000FFFF  /* Message Data */
+#define PCIE_MD_DATA_S                    0
+
+/* PCI Express Capability Register */
+#define PCIE_XCAP(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70)
+
+#define PCIE_XCAP_ID                      0x000000FF  /* PCI Express Capability ID */
+#define PCIE_XCAP_ID_S                    0
+#define PCIE_XCAP_NEXT_CAP                0x0000FF00  /* Next Capability Pointer */
+#define PCIE_XCAP_NEXT_CAP_S              8
+#define PCIE_XCAP_VER                     0x000F0000  /* PCI Express Capability Version */
+#define PCIE_XCAP_VER_S                   16
+#define PCIE_XCAP_DEV_PORT_TYPE           0x00F00000  /* Device Port Type */
+#define PCIE_XCAP_DEV_PORT_TYPE_S         20
+#define PCIE_XCAP_SLOT_IMPLEMENTED        0x01000000  /* Slot Implemented */
+#define PCIE_XCAP_MSG_INT_NUM             0x3E000000  /* Interrupt Message Number */
+#define PCIE_XCAP_MSG_INT_NUM_S           25
+
+/* Device Capability Register */
+#define PCIE_DCAP(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74)
+
+#define PCIE_DCAP_MAX_PAYLOAD_SIZE        0x00000007   /* Max Payload size */
+#define PCIE_DCAP_MAX_PAYLOAD_SIZE_S      0
+#define PCIE_DCAP_PHANTOM_FUNC            0x00000018   /* Phanton Function, not supported */
+#define PCIE_DCAP_PHANTOM_FUNC_S          3
+#define PCIE_DCAP_EXT_TAG                 0x00000020   /* Extended Tag Field */
+#define PCIE_DCAP_EP_L0S_LATENCY          0x000001C0   /* EP L0s latency only */
+#define PCIE_DCAP_EP_L0S_LATENCY_S        6
+#define PCIE_DCAP_EP_L1_LATENCY           0x00000E00   /* EP L1 latency only */
+#define PCIE_DCAP_EP_L1_LATENCY_S         9
+#define PCIE_DCAP_ROLE_BASE_ERR_REPORT    0x00008000   /* Role Based ERR */
+
+/* Maximum payload size supported */
+enum {
+    PCIE_MAX_PAYLOAD_128 = 0,
+    PCIE_MAX_PAYLOAD_256,
+    PCIE_MAX_PAYLOAD_512,
+    PCIE_MAX_PAYLOAD_1024,
+    PCIE_MAX_PAYLOAD_2048,
+    PCIE_MAX_PAYLOAD_4096,
+};
+
+/* Device Control and Status Register */
+#define PCIE_DCTLSTS(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x78)
+
+#define PCIE_DCTLSTS_CORRECTABLE_ERR_EN        0x00000001   /* COR-ERR */
+#define PCIE_DCTLSTS_NONFATAL_ERR_EN           0x00000002   /* Non-fatal ERR */
+#define PCIE_DCTLSTS_FATAL_ERR_EN              0x00000004   /* Fatal ERR */
+#define PCIE_DCTLSYS_UR_REQ_EN                 0x00000008   /* UR ERR */
+#define PCIE_DCTLSTS_RELAXED_ORDERING_EN       0x00000010   /* Enable relaxing ordering */
+#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE          0x000000E0   /* Max payload mask */
+#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE_S        5
+#define PCIE_DCTLSTS_EXT_TAG_EN                0x00000100   /* Extended tag field */
+#define PCIE_DCTLSTS_PHANTOM_FUNC_EN           0x00000200   /* Phantom Function Enable */
+#define PCIE_DCTLSTS_AUX_PM_EN                 0x00000400   /* AUX Power PM Enable */
+#define PCIE_DCTLSTS_NO_SNOOP_EN               0x00000800   /* Enable no snoop, except root port*/
+#define PCIE_DCTLSTS_MAX_READ_SIZE             0x00007000   /* Max Read Request size*/
+#define PCIE_DCTLSTS_MAX_READ_SIZE_S           12
+#define PCIE_DCTLSTS_CORRECTABLE_ERR           0x00010000   /* COR-ERR Detected */
+#define PCIE_DCTLSTS_NONFATAL_ERR              0x00020000   /* Non-Fatal ERR Detected */
+#define PCIE_DCTLSTS_FATAL_ER                  0x00040000   /* Fatal ERR Detected */
+#define PCIE_DCTLSTS_UNSUPPORTED_REQ           0x00080000   /* UR Detected */
+#define PCIE_DCTLSTS_AUX_POWER                 0x00100000   /* Aux Power Detected */
+#define PCIE_DCTLSTS_TRANSACT_PENDING          0x00200000   /* Transaction pending */
+
+#define PCIE_DCTLSTS_ERR_EN      (PCIE_DCTLSTS_CORRECTABLE_ERR_EN | \
+                                  PCIE_DCTLSTS_NONFATAL_ERR_EN | PCIE_DCTLSTS_FATAL_ERR_EN | \
+                                  PCIE_DCTLSYS_UR_REQ_EN)
+
+/* Link Capability Register */
+#define PCIE_LCAP(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7C)
+#define PCIE_LCAP_MAX_LINK_SPEED               0x0000000F  /* Max link speed, 0x1 by default */
+#define PCIE_LCAP_MAX_LINK_SPEED_S             0
+#define PCIE_LCAP_MAX_LENGTH_WIDTH             0x000003F0  /* Maxium Length Width */
+#define PCIE_LCAP_MAX_LENGTH_WIDTH_S           4
+#define PCIE_LCAP_ASPM_LEVEL                   0x00000C00  /* Active State Link PM Support */
+#define PCIE_LCAP_ASPM_LEVEL_S                 10
+#define PCIE_LCAP_L0S_EIXT_LATENCY             0x00007000  /* L0s Exit Latency */
+#define PCIE_LCAP_L0S_EIXT_LATENCY_S           12
+#define PCIE_LCAP_L1_EXIT_LATENCY              0x00038000  /* L1 Exit Latency */
+#define PCIE_LCAP_L1_EXIT_LATENCY_S            15
+#define PCIE_LCAP_CLK_PM                       0x00040000  /* Clock Power Management */
+#define PCIE_LCAP_SDER                         0x00080000  /* Surprise Down Error Reporting */
+#define PCIE_LCAP_DLL_ACTIVE_REPROT            0x00100000  /* Data Link Layer Active Reporting Capable */
+#define PCIE_LCAP_PORT_NUM                     0xFF0000000  /* Port number */
+#define PCIE_LCAP_PORT_NUM_S                   24
+
+/* Maximum Length width definition */
+#define PCIE_MAX_LENGTH_WIDTH_RES  0x00
+#define PCIE_MAX_LENGTH_WIDTH_X1   0x01  /* Default */
+#define PCIE_MAX_LENGTH_WIDTH_X2   0x02
+#define PCIE_MAX_LENGTH_WIDTH_X4   0x04
+#define PCIE_MAX_LENGTH_WIDTH_X8   0x08
+#define PCIE_MAX_LENGTH_WIDTH_X12  0x0C
+#define PCIE_MAX_LENGTH_WIDTH_X16  0x10
+#define PCIE_MAX_LENGTH_WIDTH_X32  0x20
+
+/* Active State Link PM definition */
+enum {
+    PCIE_ASPM_RES0                = 0,
+    PCIE_ASPM_L0S_ENTRY_SUPPORT,        /* L0s */
+    PCIE_ASPM_RES1,
+    PCIE_ASPM_L0S_L1_ENTRY_SUPPORT,     /* L0s and L1, default */
+};
+
+/* L0s Exit Latency definition */
+enum {
+    PCIE_L0S_EIXT_LATENCY_L64NS    = 0, /* < 64 ns */
+    PCIE_L0S_EIXT_LATENCY_B64A128,      /* > 64 ns < 128 ns */
+    PCIE_L0S_EIXT_LATENCY_B128A256,     /* > 128 ns < 256 ns */
+    PCIE_L0S_EIXT_LATENCY_B256A512,     /* > 256 ns < 512 ns */
+    PCIE_L0S_EIXT_LATENCY_B512TO1U,     /* > 512 ns < 1 us */
+    PCIE_L0S_EIXT_LATENCY_B1A2U,        /* > 1 us < 2 us */
+    PCIE_L0S_EIXT_LATENCY_B2A4U,        /* > 2 us < 4 us */
+    PCIE_L0S_EIXT_LATENCY_M4US,         /* > 4 us  */
+};
+
+/* L1 Exit Latency definition */
+enum {
+    PCIE_L1_EXIT_LATENCY_L1US  = 0,  /* < 1 us */
+    PCIE_L1_EXIT_LATENCY_B1A2,       /* > 1 us < 2 us */
+    PCIE_L1_EXIT_LATENCY_B2A4,       /* > 2 us < 4 us */
+    PCIE_L1_EXIT_LATENCY_B4A8,       /* > 4 us < 8 us */
+    PCIE_L1_EXIT_LATENCY_B8A16,      /* > 8 us < 16 us */
+    PCIE_L1_EXIT_LATENCY_B16A32,     /* > 16 us < 32 us */
+    PCIE_L1_EXIT_LATENCY_B32A64,     /* > 32 us < 64 us */
+    PCIE_L1_EXIT_LATENCY_M64US,      /* > 64 us */
+};
+
+/* Link Control and Status Register */
+#define PCIE_LCTLSTS(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x80)
+#define PCIE_LCTLSTS_ASPM_ENABLE            0x00000003  /* Active State Link PM Control */
+#define PCIE_LCTLSTS_ASPM_ENABLE_S          0
+#define PCIE_LCTLSTS_RCB128                 0x00000008  /* Read Completion Boundary 128*/
+#define PCIE_LCTLSTS_LINK_DISABLE           0x00000010  /* Link Disable */
+#define PCIE_LCTLSTS_RETRIAN_LINK           0x00000020  /* Retrain Link */
+#define PCIE_LCTLSTS_COM_CLK_CFG            0x00000040  /* Common Clock Configuration */
+#define PCIE_LCTLSTS_EXT_SYNC               0x00000080  /* Extended Synch */
+#define PCIE_LCTLSTS_CLK_PM_EN              0x00000100  /* Enable Clock Powerm Management */
+#define PCIE_LCTLSTS_LINK_SPEED             0x000F0000  /* Link Speed */
+#define PCIE_LCTLSTS_LINK_SPEED_S           16
+#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH  0x03F00000  /* Negotiated Link Width */
+#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH_S 20
+#define PCIE_LCTLSTS_RETRAIN_PENDING        0x08000000  /* Link training is ongoing */
+#define PCIE_LCTLSTS_SLOT_CLK_CFG           0x10000000  /* Slot Clock Configuration */
+#define PCIE_LCTLSTS_DLL_ACTIVE             0x20000000  /* Data Link Layer Active */
+
+/* Slot Capabilities Register */
+#define PCIE_SLCAP(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x84)
+
+/* Slot Capabilities */
+#define PCIE_SLCTLSTS(X)                    (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x88)
+
+/* Root Control and Capability Register */
+#define PCIE_RCTLCAP(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x8C)
+#define PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR  0x00000001   /* #SERR on COR-ERR */
+#define PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR     0x00000002   /* #SERR on Non-Fatal ERR */
+#define PCIE_RCTLCAP_SERR_ON_FATAL_ERR        0x00000004   /* #SERR on Fatal ERR */
+#define PCIE_RCTLCAP_PME_INT_EN               0x00000008   /* PME Interrupt Enable */
+#define PCIE_RCTLCAP_SERR_ENABLE    (PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR | \
+                                     PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR | PCIE_RCTLCAP_SERR_ON_FATAL_ERR)
+/* Root Status Register */
+#define PCIE_RSTS(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x90)
+#define PCIE_RSTS_PME_REQ_ID                   0x0000FFFF   /* PME Request ID */
+#define PCIE_RSTS_PME_REQ_ID_S                 0
+#define PCIE_RSTS_PME_STATUS                   0x00010000   /* PME Status */
+#define PCIE_RSTS_PME_PENDING                  0x00020000   /* PME Pending */
+
+/* PCI Express Enhanced Capability Header */
+#define PCIE_ENHANCED_CAP(X)                (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x100)
+#define PCIE_ENHANCED_CAP_ID                 0x0000FFFF  /* PCI Express Extended Capability ID */
+#define PCIE_ENHANCED_CAP_ID_S               0
+#define PCIE_ENHANCED_CAP_VER                0x000F0000  /* Capability Version */
+#define PCIE_ENHANCED_CAP_VER_S              16
+#define PCIE_ENHANCED_CAP_NEXT_OFFSET        0xFFF00000  /* Next Capability Offset */
+#define PCIE_ENHANCED_CAP_NEXT_OFFSET_S      20
+
+/* Uncorrectable Error Status Register */
+#define PCIE_UES_R(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x104)
+#define PCIE_DATA_LINK_PROTOCOL_ERR          0x00000010  /* Data Link Protocol Error Status */
+#define PCIE_SURPRISE_DOWN_ERROR             0x00000020  /* Surprise Down Error Status */
+#define PCIE_POISONED_TLP                    0x00001000  /* Poisoned TLP Status */
+#define PCIE_FC_PROTOCOL_ERR                 0x00002000  /* Flow Control Protocol Error Status */
+#define PCIE_COMPLETION_TIMEOUT              0x00004000  /* Completion Timeout Status */
+#define PCIE_COMPLETOR_ABORT                 0x00008000  /* Completer Abort Error */
+#define PCIE_UNEXPECTED_COMPLETION           0x00010000  /* Unexpected Completion Status */
+#define PCIE_RECEIVER_OVERFLOW               0x00020000  /* Receive Overflow Status */
+#define PCIE_MALFORNED_TLP                   0x00040000  /* Malformed TLP Stauts */
+#define PCIE_ECRC_ERR                        0x00080000  /* ECRC Error Stauts */
+#define PCIE_UR_REQ                          0x00100000  /* Unsupported Request Error Status */
+#define PCIE_ALL_UNCORRECTABLE_ERR    (PCIE_DATA_LINK_PROTOCOL_ERR | PCIE_SURPRISE_DOWN_ERROR | \
+                         PCIE_POISONED_TLP | PCIE_FC_PROTOCOL_ERR | PCIE_COMPLETION_TIMEOUT |   \
+                         PCIE_COMPLETOR_ABORT | PCIE_UNEXPECTED_COMPLETION | PCIE_RECEIVER_OVERFLOW |\
+                         PCIE_MALFORNED_TLP | PCIE_ECRC_ERR | PCIE_UR_REQ)
+
+/* Uncorrectable Error Mask Register, Mask means no report */
+#define PCIE_UEMR(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x108)
+
+/* Uncorrectable Error Severity Register */
+#define PCIE_UESR(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10C)
+
+/* Correctable Error Status Register */
+#define PCIE_CESR(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x110)
+#define PCIE_RX_ERR                          0x00000001  /* Receive Error Status */
+#define PCIE_BAD_TLP                         0x00000040  /* Bad TLP Status */
+#define PCIE_BAD_DLLP                        0x00000080  /* Bad DLLP Status */
+#define PCIE_REPLAY_NUM_ROLLOVER             0x00000100  /* Replay Number Rollover Status */
+#define PCIE_REPLAY_TIMER_TIMEOUT_ERR        0x00001000  /* Reply Timer Timeout Status */
+#define PCIE_ADVISORY_NONFTAL_ERR            0x00002000  /* Advisory Non-Fatal Error Status */
+#define PCIE_CORRECTABLE_ERR        (PCIE_RX_ERR | PCIE_BAD_TLP | PCIE_BAD_DLLP | PCIE_REPLAY_NUM_ROLLOVER |\
+                                     PCIE_REPLAY_TIMER_TIMEOUT_ERR | PCIE_ADVISORY_NONFTAL_ERR)
+
+/* Correctable Error Mask Register */
+#define PCIE_CEMR(X)                        (volatile u32*)(PCIE_RC_CFG_BASE + 0x114)
+
+/* Advanced Error Capabilities and Control Register */
+#define PCIE_AECCR(X)                       (volatile u32*)(PCIE_RC_CFG_BASE + 0x118)
+#define PCIE_AECCR_FIRST_ERR_PTR            0x0000001F  /* First Error Pointer */
+#define PCIE_AECCR_FIRST_ERR_PTR_S          0
+#define PCIE_AECCR_ECRC_GEN_CAP             0x00000020  /* ECRC Generation Capable */
+#define PCIE_AECCR_ECRC_GEN_EN              0x00000040  /* ECRC Generation Enable */
+#define PCIE_AECCR_ECRC_CHECK_CAP           0x00000080  /* ECRC Check Capable */
+#define PCIE_AECCR_ECRC_CHECK_EN            0x00000100  /* ECRC Check Enable */
+
+/* Header Log Register 1 */
+#define PCIE_HLR1(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x11C)
+
+/* Header Log Register 2 */
+#define PCIE_HLR2(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x120)
+
+/* Header Log Register 3 */
+#define PCIE_HLR3(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x124)
+
+/* Header Log Register 4 */
+#define PCIE_HLR4(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x128)
+
+/* Root Error Command Register */
+#define PCIE_RECR(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x12C)
+#define PCIE_RECR_CORRECTABLE_ERR_REPORT_EN  0x00000001 /* COR-ERR */
+#define PCIE_RECR_NONFATAL_ERR_REPORT_EN     0x00000002 /* Non-Fatal ERR */
+#define PCIE_RECR_FATAL_ERR_REPORT_EN        0x00000004 /* Fatal ERR */
+#define PCIE_RECR_ERR_REPORT_EN  (PCIE_RECR_CORRECTABLE_ERR_REPORT_EN | \
+                PCIE_RECR_NONFATAL_ERR_REPORT_EN | PCIE_RECR_FATAL_ERR_REPORT_EN)
+
+/* Root Error Status Register */
+#define PCIE_RESR(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x130)
+#define PCIE_RESR_CORRECTABLE_ERR                0x00000001   /* COR-ERR Receveid */
+#define PCIE_RESR_MULTI_CORRECTABLE_ERR          0x00000002   /* Multiple COR-ERR Received */
+#define PCIE_RESR_FATAL_NOFATAL_ERR              0x00000004   /* ERR Fatal/Non-Fatal Received */
+#define PCIE_RESR_MULTI_FATAL_NOFATAL_ERR        0x00000008   /* Multiple ERR Fatal/Non-Fatal Received */
+#define PCIE_RESR_FIRST_UNCORRECTABLE_FATAL_ERR  0x00000010   /* First UN-COR Fatal */
+#define PCIR_RESR_NON_FATAL_ERR                  0x00000020   /* Non-Fatal Error Message Received */
+#define PCIE_RESR_FATAL_ERR                      0x00000040   /* Fatal Message Received */
+#define PCIE_RESR_AER_INT_MSG_NUM                0xF8000000   /* Advanced Error Interrupt Message Number */
+#define PCIE_RESR_AER_INT_MSG_NUM_S              27
+
+/* Error Source Indentification Register */
+#define PCIE_ESIR(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x134)
+#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID         0x0000FFFF
+#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID_S       0
+#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID         0xFFFF0000
+#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID_S       16
+
+/* VC Enhanced Capability Header */
+#define PCIE_VC_ECH(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x140)
+
+/* Port VC Capability Register */
+#define PCIE_PVC1(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x144)
+#define PCIE_PVC1_EXT_VC_CNT                    0x00000007  /* Extended VC Count */
+#define PCIE_PVC1_EXT_VC_CNT_S                  0
+#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT            0x00000070  /* Low Priority Extended VC Count */
+#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT_S          4
+#define PCIE_PVC1_REF_CLK                       0x00000300  /* Reference Clock */
+#define PCIE_PVC1_REF_CLK_S                     8
+#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE       0x00000C00  /* Port Arbitration Table Entry Size */
+#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE_S     10
+
+/* Extended Virtual Channel Count Defintion */
+#define PCIE_EXT_VC_CNT_MIN   0
+#define PCIE_EXT_VC_CNT_MAX   7
+
+/* Port Arbitration Table Entry Size Definition */
+enum {
+    PCIE_PORT_ARB_TAB_ENTRY_SIZE_S1BIT = 0,
+    PCIE_PORT_ARB_TAB_ENTRY_SIZE_S2BIT,
+    PCIE_PORT_ARB_TAB_ENTRY_SIZE_S4BIT,
+    PCIE_PORT_ARB_TAB_ENTRY_SIZE_S8BIT,
+};
+
+/* Port VC Capability Register 2 */
+#define PCIE_PVC2(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x148)
+#define PCIE_PVC2_VC_ARB_16P_FIXED_WRR      0x00000001  /* HW Fixed arbitration, 16 phase WRR */
+#define PCIE_PVC2_VC_ARB_32P_WRR            0x00000002  /* 32 phase WRR */
+#define PCIE_PVC2_VC_ARB_64P_WRR            0x00000004  /* 64 phase WRR */
+#define PCIE_PVC2_VC_ARB_128P_WRR           0x00000008  /* 128 phase WRR */
+#define PCIE_PVC2_VC_ARB_WRR                0x0000000F
+#define PCIE_PVC2_VC_ARB_TAB_OFFSET         0xFF000000  /* VC arbitration table offset, not support */
+#define PCIE_PVC2_VC_ARB_TAB_OFFSET_S       24
+
+/* Port VC Control and Status Register */     
+#define PCIE_PVCCRSR(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14C)
+#define PCIE_PVCCRSR_LOAD_VC_ARB_TAB         0x00000001  /* Load VC Arbitration Table */
+#define PCIE_PVCCRSR_VC_ARB_SEL              0x0000000E  /* VC Arbitration Select */
+#define PCIE_PVCCRSR_VC_ARB_SEL_S            1
+#define PCIE_PVCCRSR_VC_ARB_TAB_STATUS       0x00010000  /* Arbitration Status */
+
+/* VC0 Resource Capability Register */
+#define PCIE_VC0_RC(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x150)
+#define PCIE_VC0_RC_PORT_ARB_HW_FIXED        0x00000001  /* HW Fixed arbitration */
+#define PCIE_VC0_RC_PORT_ARB_32P_WRR         0x00000002  /* 32 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB_64P_WRR         0x00000004  /* 64 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB_128P_WRR        0x00000008  /* 128 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB_TM_128P_WRR     0x00000010  /* Time-based 128 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB_TM_256P_WRR     0x00000020  /* Time-based 256 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB          (PCIE_VC0_RC_PORT_ARB_HW_FIXED | PCIE_VC0_RC_PORT_ARB_32P_WRR |\
+                        PCIE_VC0_RC_PORT_ARB_64P_WRR | PCIE_VC0_RC_PORT_ARB_128P_WRR | \
+                        PCIE_VC0_RC_PORT_ARB_TM_128P_WRR | PCIE_VC0_RC_PORT_ARB_TM_256P_WRR)
+
+#define PCIE_VC0_RC_REJECT_SNOOP             0x00008000  /* Reject Snoop Transactioin */
+#define PCIE_VC0_RC_MAX_TIMESLOTS            0x007F0000  /* Maximum time Slots */
+#define PCIE_VC0_RC_MAX_TIMESLOTS_S          16
+#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET      0xFF000000  /* Port Arbitration Table Offset */
+#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET_S    24
+
+/* VC0 Resource Control Register */
+#define PCIE_VC0_RC0(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x154)
+#define PCIE_VC0_RC0_TVM0                    0x00000001  /* TC0 and VC0 */
+#define PCIE_VC0_RC0_TVM1                    0x00000002  /* TC1 and VC1 */
+#define PCIE_VC0_RC0_TVM2                    0x00000004  /* TC2 and VC2 */
+#define PCIE_VC0_RC0_TVM3                    0x00000008  /* TC3 and VC3 */
+#define PCIE_VC0_RC0_TVM4                    0x00000010  /* TC4 and VC4 */
+#define PCIE_VC0_RC0_TVM5                    0x00000020  /* TC5 and VC5 */
+#define PCIE_VC0_RC0_TVM6                    0x00000040  /* TC6 and VC6 */
+#define PCIE_VC0_RC0_TVM7                    0x00000080  /* TC7 and VC7 */
+#define PCIE_VC0_RC0_TC_VC                   0x000000FF  /* TC/VC mask */
+
+#define PCIE_VC0_RC0_LOAD_PORT_ARB_TAB       0x00010000  /* Load Port Arbitration Table */
+#define PCIE_VC0_RC0_PORT_ARB_SEL            0x000E0000  /* Port Arbitration Select */
+#define PCIE_VC0_RC0_PORT_ARB_SEL_S          17
+#define PCIE_VC0_RC0_VC_ID                   0x07000000  /* VC ID */
+#define PCIE_VC0_RC0_VC_ID_S                 24
+#define PCIE_VC0_RC0_VC_EN                   0x80000000  /* VC Enable */
+
+/* VC0 Resource Status Register */
+#define PCIE_VC0_RSR0(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x158)
+#define PCIE_VC0_RSR0_PORT_ARB_TAB_STATUS    0x00010000  /* Port Arbitration Table Status,not used */
+#define PCIE_VC0_RSR0_VC_NEG_PENDING         0x00020000  /* VC Negotiation Pending */
+
+/* Ack Latency Timer and Replay Timer Register */
+#define PCIE_ALTRT(X)                         (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x700)
+#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT   0x0000FFFF  /* Round Trip Latency Time Limit */
+#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT_S 0
+#define PCIE_ALTRT_REPLAY_TIME_LIMIT          0xFFFF0000  /* Replay Time Limit */
+#define PCIE_ALTRT_REPLAY_TIME_LIMIT_S        16
+
+/* Other Message Register */
+#define PCIE_OMR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x704)
+
+/* Port Force Link Register */
+#define PCIE_PFLR(X)                         (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x708)
+#define PCIE_PFLR_LINK_NUM                   0x000000FF  /* Link Number */
+#define PCIE_PFLR_LINK_NUM_S                 0
+#define PCIE_PFLR_FORCE_LINK                 0x00008000  /* Force link */
+#define PCIE_PFLR_LINK_STATE                 0x003F0000  /* Link State */
+#define PCIE_PFLR_LINK_STATE_S               16
+#define PCIE_PFLR_LOW_POWER_ENTRY_CNT        0xFF000000  /* Low Power Entrance Count, only for EP */
+#define PCIE_PFLR_LOW_POWER_ENTRY_CNT_S      24
+
+/* Ack Frequency Register */
+#define PCIE_AFR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70C)
+#define PCIE_AFR_AF                          0x000000FF  /* Ack Frequency */
+#define PCIE_AFR_AF_S                        0
+#define PCIE_AFR_FTS_NUM                     0x0000FF00  /* The number of Fast Training Sequence from L0S to L0 */
+#define PCIE_AFR_FTS_NUM_S                   8
+#define PCIE_AFR_COM_FTS_NUM                 0x00FF0000  /* N_FTS; when common clock is used*/
+#define PCIE_AFR_COM_FTS_NUM_S               16
+#define PCIE_AFR_L0S_ENTRY_LATENCY           0x07000000  /* L0s Entrance Latency */
+#define PCIE_AFR_L0S_ENTRY_LATENCY_S         24
+#define PCIE_AFR_L1_ENTRY_LATENCY            0x38000000  /* L1 Entrance Latency */
+#define PCIE_AFR_L1_ENTRY_LATENCY_S          27
+#define PCIE_AFR_FTS_NUM_DEFAULT             32
+#define PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT   7
+#define PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT    5
+
+/* Port Link Control Register */
+#define PCIE_PLCR(X)                         (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x710)
+#define PCIE_PLCR_OTHER_MSG_REQ              0x00000001  /* Other Message Request */
+#define PCIE_PLCR_SCRAMBLE_DISABLE           0x00000002  /* Scramble Disable */  
+#define PCIE_PLCR_LOOPBACK_EN                0x00000004  /* Loopback Enable */
+#define PCIE_PLCR_LTSSM_HOT_RST              0x00000008  /* Force LTSSM to the hot reset */
+#define PCIE_PLCR_DLL_LINK_EN                0x00000020  /* Enable Link initialization */
+#define PCIE_PLCR_FAST_LINK_SIM_EN           0x00000080  /* Sets all internal timers to fast mode for simulation purposes */
+#define PCIE_PLCR_LINK_MODE                  0x003F0000  /* Link Mode Enable Mask */
+#define PCIE_PLCR_LINK_MODE_S                16
+#define PCIE_PLCR_CORRUPTED_CRC_EN           0x02000000  /* Enabled Corrupt CRC */
+
+/* Lane Skew Register */
+#define PCIE_LSR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x714)
+#define PCIE_LSR_LANE_SKEW_NUM               0x00FFFFFF  /* Insert Lane Skew for Transmit, not applicable */
+#define PCIE_LSR_LANE_SKEW_NUM_S             0
+#define PCIE_LSR_FC_DISABLE                  0x01000000  /* Disable of Flow Control */
+#define PCIE_LSR_ACKNAK_DISABLE              0x02000000  /* Disable of Ack/Nak */
+#define PCIE_LSR_LANE_DESKEW_DISABLE         0x80000000  /* Disable of Lane-to-Lane Skew */
+
+/* Symbol Number Register */
+#define PCIE_SNR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x718)
+#define PCIE_SNR_TS                          0x0000000F  /* Number of TS Symbol */
+#define PCIE_SNR_TS_S                        0
+#define PCIE_SNR_SKP                         0x00000700  /* Number of SKP Symbol */
+#define PCIE_SNR_SKP_S                       8
+#define PCIE_SNR_REPLAY_TIMER                0x0007C000  /* Timer Modifier for Replay Timer */
+#define PCIE_SNR_REPLAY_TIMER_S              14
+#define PCIE_SNR_ACKNAK_LATENCY_TIMER        0x00F80000  /* Timer Modifier for Ack/Nak Latency Timer */
+#define PCIE_SNR_ACKNAK_LATENCY_TIMER_S      19
+#define PCIE_SNR_FC_TIMER                    0x1F000000  /* Timer Modifier for Flow Control Watchdog Timer */
+#define PCIE_SNR_FC_TIMER_S                  28
+
+/* Symbol Timer Register and Filter Mask Register 1 */
+#define PCIE_STRFMR(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x71C)
+#define PCIE_STRFMR_SKP_INTERVAL            0x000007FF  /* SKP lnterval Value */
+#define PCIE_STRFMR_SKP_INTERVAL_S          0
+#define PCIE_STRFMR_FC_WDT_DISABLE          0x00008000  /* Disable of FC Watchdog Timer */
+#define PCIE_STRFMR_TLP_FUNC_MISMATCH_OK    0x00010000  /* Mask Function Mismatch Filtering for Incoming Requests */
+#define PCIE_STRFMR_POISONED_TLP_OK         0x00020000  /* Mask Poisoned TLP Filtering */
+#define PCIE_STRFMR_BAR_MATCH_OK            0x00040000  /* Mask BAR Match Filtering */
+#define PCIE_STRFMR_TYPE1_CFG_REQ_OK        0x00080000  /* Mask Type 1 Configuration Request Filtering */
+#define PCIE_STRFMR_LOCKED_REQ_OK           0x00100000  /* Mask Locked Request Filtering */
+#define PCIE_STRFMR_CPL_TAG_ERR_RULES_OK    0x00200000  /* Mask Tag Error Rules for Received Completions */
+#define PCIE_STRFMR_CPL_REQUESTOR_ID_MISMATCH_OK 0x00400000  /* Mask Requester ID Mismatch Error for Received Completions */
+#define PCIE_STRFMR_CPL_FUNC_MISMATCH_OK         0x00800000  /* Mask Function Mismatch Error for Received Completions */
+#define PCIE_STRFMR_CPL_TC_MISMATCH_OK           0x01000000  /* Mask Traffic Class Mismatch Error for Received Completions */
+#define PCIE_STRFMR_CPL_ATTR_MISMATCH_OK         0x02000000  /* Mask Attribute Mismatch Error for Received Completions */
+#define PCIE_STRFMR_CPL_LENGTH_MISMATCH_OK       0x04000000  /* Mask Length Mismatch Error for Received Completions */
+#define PCIE_STRFMR_TLP_ECRC_ERR_OK              0x08000000  /* Mask ECRC Error Filtering */
+#define PCIE_STRFMR_CPL_TLP_ECRC_OK              0x10000000  /* Mask ECRC Error Filtering for Completions */
+#define PCIE_STRFMR_RX_TLP_MSG_NO_DROP           0x20000000  /* Send Message TLPs */
+#define PCIE_STRFMR_RX_IO_TRANS_ENABLE           0x40000000  /* Mask Filtering of received I/O Requests */
+#define PCIE_STRFMR_RX_CFG_TRANS_ENABLE          0x80000000  /* Mask Filtering of Received Configuration Requests */
+
+#define PCIE_DEF_SKP_INTERVAL    700             /* 1180 ~1538 , 125MHz * 2, 250MHz * 1 */
+
+/* Filter Masker Register 2 */
+#define PCIE_FMR2(X)                             (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x720)
+#define PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1    0x00000001  /* Mask RADM Filtering and Error Handling Rules */
+#define PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1    0x00000002  /* Mask RADM Filtering and Error Handling Rules */
+
+/* Debug Register 0 */
+#define PCIE_DBR0(X)                              (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x728)
+
+/* Debug Register 1 */
+#define PCIE_DBR1(X)                              (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x72C)
+
+/* Transmit Posted FC Credit Status Register */
+#define PCIE_TPFCS(X)                             (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x730)
+#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS           0x00000FFF /* Transmit Posted Data FC Credits */
+#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS_S         0
+#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS            0x000FF000 /* Transmit Posted Header FC Credits */
+#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS_S          12
+
+/* Transmit Non-Posted FC Credit Status */
+#define PCIE_TNPFCS(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x734)
+#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS         0x00000FFF /* Transmit Non-Posted Data FC Credits */
+#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS_S       0
+#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS          0x000FF000 /* Transmit Non-Posted Header FC Credits */
+#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS_S        12
+
+/* Transmit Complete FC Credit Status Register */
+#define PCIE_TCFCS(X)                             (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x738)
+#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS         0x00000FFF /* Transmit Completion Data FC Credits */
+#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS_S       0
+#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS          0x000FF000 /* Transmit Completion Header FC Credits */
+#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS_S        12
+
+/* Queue Status Register */
+#define PCIE_QSR(X)                              (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x73C)
+#define PCIE_QSR_WAIT_UPDATE_FC_DLL               0x00000001 /* Received TLP FC Credits Not Returned */
+#define PCIE_QSR_TX_RETRY_BUF_NOT_EMPTY           0x00000002 /* Transmit Retry Buffer Not Empty */
+#define PCIE_QSR_RX_QUEUE_NOT_EMPTY               0x00000004 /* Received Queue Not Empty */
+
+/* VC Transmit Arbitration Register 1 */
+#define PCIE_VCTAR1(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x740)
+#define PCIE_VCTAR1_WRR_WEIGHT_VC0               0x000000FF /* WRR Weight for VC0 */
+#define PCIE_VCTAR1_WRR_WEIGHT_VC1               0x0000FF00 /* WRR Weight for VC1 */
+#define PCIE_VCTAR1_WRR_WEIGHT_VC2               0x00FF0000 /* WRR Weight for VC2 */
+#define PCIE_VCTAR1_WRR_WEIGHT_VC3               0xFF000000 /* WRR Weight for VC3 */
+
+/* VC Transmit Arbitration Register 2 */
+#define PCIE_VCTAR2(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x744)
+#define PCIE_VCTAR2_WRR_WEIGHT_VC4               0x000000FF /* WRR Weight for VC4 */
+#define PCIE_VCTAR2_WRR_WEIGHT_VC5               0x0000FF00 /* WRR Weight for VC5 */
+#define PCIE_VCTAR2_WRR_WEIGHT_VC6               0x00FF0000 /* WRR Weight for VC6 */
+#define PCIE_VCTAR2_WRR_WEIGHT_VC7               0xFF000000 /* WRR Weight for VC7 */
+
+/* VC0 Posted Receive Queue Control Register */
+#define PCIE_VC0_PRQCR(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x748)
+#define PCIE_VC0_PRQCR_P_DATA_CREDITS            0x00000FFF /* VC0 Posted Data Credits */
+#define PCIE_VC0_PRQCR_P_DATA_CREDITS_S          0
+#define PCIE_VC0_PRQCR_P_HDR_CREDITS             0x000FF000 /* VC0 Posted Header Credits */
+#define PCIE_VC0_PRQCR_P_HDR_CREDITS_S           12
+#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE          0x00E00000 /* VC0 Posted TLP Queue Mode */
+#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE_S        20
+#define PCIE_VC0_PRQCR_TLP_RELAX_ORDER           0x40000000 /* TLP Type Ordering for VC0 */    
+#define PCIE_VC0_PRQCR_VC_STRICT_ORDER           0x80000000 /* VC0 Ordering for Receive Queues */
+
+/* VC0 Non-Posted Receive Queue Control */
+#define PCIE_VC0_NPRQCR(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74C)
+#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS          0x00000FFF /* VC0 Non-Posted Data Credits */
+#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS_S        0
+#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS           0x000FF000 /* VC0 Non-Posted Header Credits */
+#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS_S         12
+#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE        0x00E00000 /* VC0 Non-Posted TLP Queue Mode */
+#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE_S      20
+
+/* VC0 Completion Receive Queue Control */
+#define PCIE_VC0_CRQCR(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x750)
+#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS          0x00000FFF /* VC0 Completion TLP Queue Mode */
+#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS_S        0
+#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS           0x000FF000 /* VC0 Completion Header Credits */
+#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS_S         12
+#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE        0x00E00000 /* VC0 Completion Data Credits */
+#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE_S      21
+
+/* Applicable to the above three registers */
+enum {
+    PCIE_VC0_TLP_QUEUE_MODE_STORE_FORWARD = 1,
+    PCIE_VC0_TLP_QUEUE_MODE_CUT_THROUGH   = 2,
+    PCIE_VC0_TLP_QUEUE_MODE_BYPASS        = 4,
+};
+
+/* VC0 Posted Buffer Depth Register */
+#define PCIE_VC0_PBD(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7A8)
+#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES       0x00003FFF /* VC0 Posted Data Queue Depth */
+#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES_S     0
+#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES        0x03FF0000 /* VC0 Posted Header Queue Depth */
+#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES_S      16
+
+/* VC0 Non-Posted Buffer Depth Register */
+#define PCIE_VC0_NPBD(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7AC)
+#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES     0x00003FFF /* VC0 Non-Posted Data Queue Depth */
+#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES_S   0
+#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES      0x03FF0000 /* VC0 Non-Posted Header Queue Depth */
+#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES_S    16
+
+/* VC0 Completion Buffer Depth Register */
+#define PCIE_VC0_CBD(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7B0)
+#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES     0x00003FFF /* C0 Completion Data Queue Depth */
+#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES_S   0
+#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES      0x03FF0000 /* VC0 Completion Header Queue Depth */
+#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES_S    16
+
+/* PHY Status Register, all zeros in VR9 */
+#define PCIE_PHYSR(X)                           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x810)
+
+/* PHY Control Register, all zeros in VR9 */
+#define PCIE_PHYCR(X)                           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x814)
+
+/* 
+ * PCIe PDI PHY register definition, suppose all the following 
+ * stuff is confidential. 
+ * XXX, detailed bit definition
+ */
+#define	PCIE_PHY_PLL_CTRL1(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x22 << 1))
+#define	PCIE_PHY_PLL_CTRL2(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x23 << 1))
+#define	PCIE_PHY_PLL_CTRL3(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x24 << 1))
+#define	PCIE_PHY_PLL_CTRL4(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x25 << 1))
+#define	PCIE_PHY_PLL_CTRL5(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x26 << 1))
+#define	PCIE_PHY_PLL_CTRL6(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x27 << 1))
+#define	PCIE_PHY_PLL_CTRL7(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x28 << 1))
+#define	PCIE_PHY_PLL_A_CTRL1(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x29 << 1))
+#define	PCIE_PHY_PLL_A_CTRL2(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x2A << 1))
+#define	PCIE_PHY_PLL_A_CTRL3(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x2B << 1))
+#define	PCIE_PHY_PLL_STATUS(X)      (PCIE_PHY_PORT_TO_BASE(X) + (0x2C << 1))
+ 
+#define PCIE_PHY_TX1_CTRL1(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x30 << 1))
+#define PCIE_PHY_TX1_CTRL2(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x31 << 1))
+#define PCIE_PHY_TX1_CTRL3(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x32 << 1))
+#define PCIE_PHY_TX1_A_CTRL1(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x33 << 1))
+#define PCIE_PHY_TX1_A_CTRL2(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x34 << 1))
+#define PCIE_PHY_TX1_MOD1(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x35 << 1))
+#define PCIE_PHY_TX1_MOD2(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x36 << 1))
+#define PCIE_PHY_TX1_MOD3(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x37 << 1))
+
+#define PCIE_PHY_TX2_CTRL1(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x38 << 1))
+#define PCIE_PHY_TX2_CTRL2(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x39 << 1))
+#define PCIE_PHY_TX2_A_CTRL1(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x3B << 1))
+#define PCIE_PHY_TX2_A_CTRL2(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x3C << 1))
+#define PCIE_PHY_TX2_MOD1(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x3D << 1))
+#define PCIE_PHY_TX2_MOD2(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x3E << 1))
+#define PCIE_PHY_TX2_MOD3(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x3F << 1))
+
+#define PCIE_PHY_RX1_CTRL1(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x50 << 1))
+#define PCIE_PHY_RX1_CTRL2(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x51 << 1))
+#define PCIE_PHY_RX1_CDR(X)         (PCIE_PHY_PORT_TO_BASE(X) + (0x52 << 1))
+#define PCIE_PHY_RX1_EI(X)          (PCIE_PHY_PORT_TO_BASE(X) + (0x53 << 1))
+#define PCIE_PHY_RX1_A_CTRL(X)      (PCIE_PHY_PORT_TO_BASE(X) + (0x55 << 1))
+
+/* Interrupt related stuff */
+#define PCIE_LEGACY_DISABLE 0
+#define PCIE_LEGACY_INTA  1
+#define PCIE_LEGACY_INTB  2
+#define PCIE_LEGACY_INTC  3
+#define PCIE_LEGACY_INTD  4
+#define PCIE_LEGACY_INT_MAX PCIE_LEGACY_INTD
+
+#endif /* IFXMIPS_PCIE_REG_H */
+
--- /dev/null
+++ b/arch/mips/pci/ifxmips_pcie_vr9.h
@@ -0,0 +1,269 @@
+/****************************************************************************
+                              Copyright (c) 2010
+                            Lantiq Deutschland GmbH
+                     Am Campeon 3; 85579 Neubiberg, Germany
+
+  For licensing information, see the file 'LICENSE' in the root folder of
+  this software module.
+
+ *****************************************************************************/
+/*!
+  \file ifxmips_pcie_vr9.h
+  \ingroup IFX_PCIE
+  \brief PCIe RC driver vr9 specific file
+*/
+
+#ifndef IFXMIPS_PCIE_VR9_H
+#define IFXMIPS_PCIE_VR9_H
+
+#include <linux/types.h>
+#include <linux/delay.h>
+
+#include <linux/gpio.h>
+#include <lantiq_soc.h>
+
+#define IFX_PCIE_GPIO_RESET  494
+
+#define IFX_REG_R32    ltq_r32
+#define IFX_REG_W32    ltq_w32
+#define CONFIG_IFX_PCIE_HW_SWAP
+#define IFX_RCU_AHB_ENDIAN                      ((volatile u32*)(IFX_RCU + 0x004C))
+#define IFX_RCU_RST_REQ                         ((volatile u32*)(IFX_RCU + 0x0010))
+#define IFX_RCU_AHB_BE_PCIE_PDI                  0x00000080  /* Configure PCIE PDI module in big endian*/
+
+#define IFX_RCU                                 (KSEG1 | 0x1F203000)
+#define IFX_RCU_AHB_BE_PCIE_M                    0x00000001  /* Configure AHB master port that connects to PCIe RC in big endian */
+#define IFX_RCU_AHB_BE_PCIE_S                    0x00000010  /* Configure AHB slave port that connects to PCIe RC in little endian */
+#define IFX_RCU_AHB_BE_XBAR_M                    0x00000002  /* Configure AHB master port that connects to XBAR in big endian */
+#define CONFIG_IFX_PCIE_PHY_36MHZ_MODE
+
+#define IFX_PMU1_MODULE_PCIE_PHY   (0)
+#define IFX_PMU1_MODULE_PCIE_CTRL  (1)
+#define IFX_PMU1_MODULE_PDI        (4)
+#define IFX_PMU1_MODULE_MSI        (5)
+
+#define IFX_PMU_MODULE_PCIE_L0_CLK (31)
+
+
+#define IFX_GPIO				(KSEG1 | 0x1E100B00)
+#define ALT0			((volatile u32*)(IFX_GPIO + 0x007c))
+#define ALT1			((volatile u32*)(IFX_GPIO + 0x0080))
+#define OD			((volatile u32*)(IFX_GPIO + 0x0084))
+#define DIR			((volatile u32*)(IFX_GPIO + 0x0078))
+#define OUT			((volatile u32*)(IFX_GPIO + 0x0070))
+
+
+static inline void pcie_ep_gpio_rst_init(int pcie_port)
+{
+
+	gpio_request(IFX_PCIE_GPIO_RESET, "pcie-reset");
+	gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
+	gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
+
+/*    ifx_gpio_pin_reserve(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
+    ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
+    ifx_gpio_dir_out_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
+    ifx_gpio_altsel0_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
+    ifx_gpio_altsel1_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
+    ifx_gpio_open_drain_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);*/
+}
+
+static inline void pcie_ahb_pmu_setup(void) 
+{
+	/* Enable AHB bus master/slave */
+	struct clk *clk;
+	clk = clk_get_sys("1d900000.pcie", "ahb");
+	clk_enable(clk);
+
+    //AHBM_PMU_SETUP(IFX_PMU_ENABLE);
+    //AHBS_PMU_SETUP(IFX_PMU_ENABLE);
+}
+
+static inline void pcie_rcu_endian_setup(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
+#ifdef CONFIG_IFX_PCIE_HW_SWAP
+    reg |= IFX_RCU_AHB_BE_PCIE_M;
+    reg |= IFX_RCU_AHB_BE_PCIE_S;
+    reg &= ~IFX_RCU_AHB_BE_XBAR_M;
+#else 
+    reg |= IFX_RCU_AHB_BE_PCIE_M;
+    reg &= ~IFX_RCU_AHB_BE_PCIE_S;
+    reg &= ~IFX_RCU_AHB_BE_XBAR_M;
+#endif /* CONFIG_IFX_PCIE_HW_SWAP */
+    IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
+    IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
+}
+
+static inline void pcie_phy_pmu_enable(int pcie_port)
+{
+	struct clk *clk;
+	clk = clk_get_sys("1d900000.pcie", "phy");
+	clk_enable(clk);
+
+	//PCIE_PHY_PMU_SETUP(IFX_PMU_ENABLE);
+}
+
+static inline void pcie_phy_pmu_disable(int pcie_port)
+{
+	struct clk *clk;
+	clk = clk_get_sys("1d900000.pcie", "phy");
+	clk_disable(clk);
+
+//    PCIE_PHY_PMU_SETUP(IFX_PMU_DISABLE);
+}
+
+static inline void pcie_pdi_big_endian(int pcie_port)
+{
+    u32 reg;
+
+    /* SRAM2PDI endianness control. */
+    reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
+    /* Config AHB->PCIe and PDI endianness */
+    reg |= IFX_RCU_AHB_BE_PCIE_PDI;
+    IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
+}
+
+static inline void pcie_pdi_pmu_enable(int pcie_port)
+{
+    /* Enable PDI to access PCIe PHY register */
+	struct clk *clk;
+	clk = clk_get_sys("1d900000.pcie", "pdi");
+	clk_enable(clk);
+    //PDI_PMU_SETUP(IFX_PMU_ENABLE);
+}
+
+static inline void pcie_core_rst_assert(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+
+    /* Reset PCIe PHY & Core, bit 22, bit 26 may be affected if write it directly  */
+    reg |= 0x00400000;
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_core_rst_deassert(int pcie_port)
+{
+    u32 reg;
+
+    /* Make sure one micro-second delay */
+    udelay(1);
+
+    /* Reset PCIe PHY & Core, bit 22 */
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+    reg &= ~0x00400000;
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_phy_rst_assert(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+    reg |= 0x00001000; /* Bit 12 */
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_phy_rst_deassert(int pcie_port)
+{
+    u32 reg;
+
+    /* Make sure one micro-second delay */
+    udelay(1);
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+    reg &= ~0x00001000; /* Bit 12 */
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_device_rst_assert(int pcie_port)
+{
+	gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
+//    ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
+}
+
+static inline void pcie_device_rst_deassert(int pcie_port)
+{
+    mdelay(100);
+	gpio_direction_output(IFX_PCIE_GPIO_RESET, 1);
+//    gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
+    //ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
+}
+
+static inline void pcie_core_pmu_setup(int pcie_port)
+{
+	struct clk *clk;
+	clk = clk_get_sys("1d900000.pcie", "ctl");
+	clk_enable(clk);
+	clk = clk_get_sys("1d900000.pcie", "bus");
+	clk_enable(clk);
+
+    /* PCIe Core controller enabled */
+//    PCIE_CTRL_PMU_SETUP(IFX_PMU_ENABLE);
+
+    /* Enable PCIe L0 Clock */
+//  PCIE_L0_CLK_PMU_SETUP(IFX_PMU_ENABLE);
+}
+
+static inline void pcie_msi_init(int pcie_port)
+{
+	struct clk *clk;
+	pcie_msi_pic_init(pcie_port);
+	clk = clk_get_sys("ltq_pcie", "msi");
+	clk_enable(clk);
+//    MSI_PMU_SETUP(IFX_PMU_ENABLE);
+}
+
+static inline u32
+ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
+{
+    u32 tbus_number = bus_number;
+
+#ifdef CONFIG_PCI_LANTIQ
+    if (pcibios_host_nr() > 1) {
+        tbus_number -= pcibios_1st_host_bus_nr();
+    }
+#endif /* CONFIG_PCI_LANTIQ */
+    return tbus_number;
+}
+
+static inline u32
+ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
+{
+    struct pci_dev *pdev;
+    u32 tvalue = value;
+
+    /* Sanity check */
+    pdev = pci_get_slot(bus, devfn);
+    if (pdev == NULL) {
+        return tvalue;
+    }
+
+    /* Only care about PCI bridge */
+    if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
+        return tvalue;
+    }
+
+    if (read) { /* Read hack */
+    #ifdef CONFIG_PCI_LANTIQ
+        if (pcibios_host_nr() > 1) {
+            tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
+        }
+    #endif /* CONFIG_PCI_LANTIQ */
+    }
+    else { /* Write hack */
+    #ifdef CONFIG_PCI_LANTIQ
+        if (pcibios_host_nr() > 1) {
+            tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
+        }
+    #endif
+    }
+    return tvalue;
+}
+
+#endif /* IFXMIPS_PCIE_VR9_H */
+
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -256,6 +256,31 @@ static int __init pcibios_init(void)
 
 subsys_initcall(pcibios_init);
 
+int pcibios_host_nr(void)
+{
+    int count;
+    struct pci_controller *hose;
+    for (count = 0, hose = hose_head; hose; hose = hose->next, count++) {
+        ;
+    }
+    return count;
+}
+EXPORT_SYMBOL(pcibios_host_nr);
+
+int pcibios_1st_host_bus_nr(void)
+{
+    int bus_nr = 0;
+    struct pci_controller *hose = hose_head;
+
+    if (hose != NULL) {
+        if (hose->bus != NULL) {
+            bus_nr = hose->bus->number + 1;
+        }
+    }
+    return bus_nr;
+}
+EXPORT_SYMBOL(pcibios_1st_host_bus_nr);
+
 static int pcibios_enable_resources(struct pci_dev *dev, int mask)
 {
 	u16 cmd, old_cmd;
--- /dev/null
+++ b/arch/mips/pci/pcie-lantiq.h
@@ -0,0 +1,1305 @@
+/******************************************************************************
+**
+** FILE NAME    : ifxmips_pcie_reg.h
+** PROJECT      : IFX UEIP for VRX200
+** MODULES      : PCIe module
+**
+** DATE         : 02 Mar 2009
+** AUTHOR       : Lei Chuanhua
+** DESCRIPTION  : PCIe Root Complex Driver
+** COPYRIGHT    :       Copyright (c) 2009
+**                      Infineon Technologies AG
+**                      Am Campeon 1-12, 85579 Neubiberg, Germany
+**
+**    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.
+** HISTORY
+** $Version $Date        $Author         $Comment
+** 0.0.1    17 Mar,2009  Lei Chuanhua    Initial version
+*******************************************************************************/
+#ifndef IFXMIPS_PCIE_REG_H
+#define IFXMIPS_PCIE_REG_H
+#include <linux/version.h>
+#include <linux/types.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+/*!
+ \file ifxmips_pcie_reg.h
+ \ingroup IFX_PCIE  
+ \brief header file for PCIe module register definition
+*/
+/* PCIe Address Mapping Base */
+#define PCIE_CFG_PHY_BASE        0x1D000000UL
+#define PCIE_CFG_BASE           (KSEG1 + PCIE_CFG_PHY_BASE)
+#define PCIE_CFG_SIZE           (8 * 1024 * 1024)
+
+#define PCIE_MEM_PHY_BASE        0x1C000000UL
+#define PCIE_MEM_BASE           (KSEG1 + PCIE_MEM_PHY_BASE)
+#define PCIE_MEM_SIZE           (16 * 1024 * 1024)
+#define PCIE_MEM_PHY_END        (PCIE_MEM_PHY_BASE + PCIE_MEM_SIZE - 1)
+
+#define PCIE_IO_PHY_BASE         0x1D800000UL
+#define PCIE_IO_BASE            (KSEG1 + PCIE_IO_PHY_BASE)
+#define PCIE_IO_SIZE            (1 * 1024 * 1024)
+#define PCIE_IO_PHY_END         (PCIE_IO_PHY_BASE + PCIE_IO_SIZE - 1)
+
+#define PCIE_RC_CFG_BASE        (KSEG1 + 0x1D900000)
+#define PCIE_APP_LOGIC_REG      (KSEG1 + 0x1E100900)
+#define PCIE_MSI_PHY_BASE        0x1F600000UL
+
+#define PCIE_PDI_PHY_BASE        0x1F106800UL
+#define PCIE_PDI_BASE           (KSEG1 + PCIE_PDI_PHY_BASE)
+#define PCIE_PDI_SIZE            0x400
+
+#define PCIE1_CFG_PHY_BASE        0x19000000UL
+#define PCIE1_CFG_BASE           (KSEG1 + PCIE1_CFG_PHY_BASE)
+#define PCIE1_CFG_SIZE           (8 * 1024 * 1024)
+
+#define PCIE1_MEM_PHY_BASE        0x18000000UL
+#define PCIE1_MEM_BASE           (KSEG1 + PCIE1_MEM_PHY_BASE)
+#define PCIE1_MEM_SIZE           (16 * 1024 * 1024)
+#define PCIE1_MEM_PHY_END        (PCIE1_MEM_PHY_BASE + PCIE1_MEM_SIZE - 1)
+
+#define PCIE1_IO_PHY_BASE         0x19800000UL
+#define PCIE1_IO_BASE            (KSEG1 + PCIE1_IO_PHY_BASE)
+#define PCIE1_IO_SIZE            (1 * 1024 * 1024)
+#define PCIE1_IO_PHY_END         (PCIE1_IO_PHY_BASE + PCIE1_IO_SIZE - 1)
+
+#define PCIE1_RC_CFG_BASE        (KSEG1 + 0x19900000)
+#define PCIE1_APP_LOGIC_REG      (KSEG1 + 0x1E100700)
+#define PCIE1_MSI_PHY_BASE        0x1F400000UL
+
+#define PCIE1_PDI_PHY_BASE        0x1F700400UL
+#define PCIE1_PDI_BASE           (KSEG1 + PCIE1_PDI_PHY_BASE)
+#define PCIE1_PDI_SIZE            0x400
+
+#define PCIE_CFG_PORT_TO_BASE(X)     ((X) > 0 ? (PCIE1_CFG_BASE) : (PCIE_CFG_BASE))
+#define PCIE_MEM_PORT_TO_BASE(X)     ((X) > 0 ? (PCIE1_MEM_BASE) : (PCIE_MEM_BASE))
+#define PCIE_IO_PORT_TO_BASE(X)      ((X) > 0 ? (PCIE1_IO_BASE) : (PCIE_IO_BASE))
+#define PCIE_MEM_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_PHY_BASE) : (PCIE_MEM_PHY_BASE))
+#define PCIE_MEM_PHY_PORT_TO_END(X)  ((X) > 0 ? (PCIE1_MEM_PHY_END) : (PCIE_MEM_PHY_END))
+#define PCIE_IO_PHY_PORT_TO_BASE(X)  ((X) > 0 ? (PCIE1_IO_PHY_BASE) : (PCIE_IO_PHY_BASE))
+#define PCIE_IO_PHY_PORT_TO_END(X)   ((X) > 0 ? (PCIE1_IO_PHY_END) : (PCIE_IO_PHY_END))
+#define PCIE_APP_PORT_TO_BASE(X)     ((X) > 0 ? (PCIE1_APP_LOGIC_REG) : (PCIE_APP_LOGIC_REG))
+#define PCIE_RC_PORT_TO_BASE(X)      ((X) > 0 ? (PCIE1_RC_CFG_BASE) : (PCIE_RC_CFG_BASE))
+#define PCIE_PHY_PORT_TO_BASE(X)     ((X) > 0 ? (PCIE1_PDI_BASE) : (PCIE_PDI_BASE))
+
+/* PCIe Application Logic Register */
+/* RC Core Control Register */
+#define PCIE_RC_CCR(X)                      (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x10)
+/* This should be enabled after initializing configuratin registers
+ * Also should check link status retraining bit
+ */
+#define PCIE_RC_CCR_LTSSM_ENABLE             0x00000001    /* Enable LTSSM to continue link establishment */
+
+/* RC Core Debug Register */
+#define PCIE_RC_DR(X)                       (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x14)
+#define PCIE_RC_DR_DLL_UP                    0x00000001  /* Data Link Layer Up */
+#define PCIE_RC_DR_CURRENT_POWER_STATE       0x0000000E  /* Current Power State */
+#define PCIE_RC_DR_CURRENT_POWER_STATE_S     1
+#define PCIE_RC_DR_CURRENT_LTSSM_STATE       0x000001F0  /* Current LTSSM State */
+#define PCIE_RC_DR_CURRENT_LTSSM_STATE_S     4
+
+#define PCIE_RC_DR_PM_DEV_STATE              0x00000E00  /* Power Management D-State */
+#define PCIE_RC_DR_PM_DEV_STATE_S            9
+
+#define PCIE_RC_DR_PM_ENABLED                0x00001000  /* Power Management State from PMU */
+#define PCIE_RC_DR_PME_EVENT_ENABLED         0x00002000  /* Power Management Event Enable State */
+#define PCIE_RC_DR_AUX_POWER_ENABLED         0x00004000  /* Auxiliary Power Enable */
+
+/* Current Power State Definition */
+enum {
+    PCIE_RC_DR_D0 = 0,
+    PCIE_RC_DR_D1,   /* Not supported */
+    PCIE_RC_DR_D2,   /* Not supported */
+    PCIE_RC_DR_D3,
+    PCIE_RC_DR_UN,
+};
+
+/* PHY Link Status Register */
+#define PCIE_PHY_SR(X)                      (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x18)
+#define PCIE_PHY_SR_PHY_LINK_UP              0x00000001   /* PHY Link Up/Down Indicator */
+
+/* Electromechanical Control Register */
+#define PCIE_EM_CR(X)                       (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x1C)
+#define PCIE_EM_CR_CARD_IS_PRESENT           0x00000001  /* Card Presence Detect State */
+#define PCIE_EM_CR_MRL_OPEN                  0x00000002  /* MRL Sensor State */
+#define PCIE_EM_CR_POWER_FAULT_SET           0x00000004  /* Power Fault Detected */
+#define PCIE_EM_CR_MRL_SENSOR_SET            0x00000008  /* MRL Sensor Changed */
+#define PCIE_EM_CR_PRESENT_DETECT_SET        0x00000010  /* Card Presense Detect Changed */
+#define PCIE_EM_CR_CMD_CPL_INT_SET           0x00000020  /* Command Complete Interrupt */
+#define PCIE_EM_CR_SYS_INTERLOCK_SET         0x00000040  /* System Electromechanical IterLock Engaged */
+#define PCIE_EM_CR_ATTENTION_BUTTON_SET      0x00000080  /* Attention Button Pressed */
+
+/* Interrupt Status Register */
+#define PCIE_IR_SR(X)                       (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x20)
+#define PCIE_IR_SR_PME_CAUSE_MSI             0x00000002  /* MSI caused by PME */
+#define PCIE_IR_SR_HP_PME_WAKE_GEN           0x00000004  /* Hotplug PME Wake Generation */
+#define PCIE_IR_SR_HP_MSI                    0x00000008  /* Hotplug MSI */
+#define PCIE_IR_SR_AHB_LU_ERR                0x00000030  /* AHB Bridge Lookup Error Signals */
+#define PCIE_IR_SR_AHB_LU_ERR_S              4
+#define PCIE_IR_SR_INT_MSG_NUM               0x00003E00  /* Interrupt Message Number */
+#define PCIE_IR_SR_INT_MSG_NUM_S             9
+#define PCIE_IR_SR_AER_INT_MSG_NUM           0xF8000000  /* Advanced Error Interrupt Message Number */
+#define PCIE_IR_SR_AER_INT_MSG_NUM_S         27
+
+/* Message Control Register */
+#define PCIE_MSG_CR(X)                      (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x30)
+#define PCIE_MSG_CR_GEN_PME_TURN_OFF_MSG     0x00000001  /* Generate PME Turn Off Message */
+#define PCIE_MSG_CR_GEN_UNLOCK_MSG           0x00000002  /* Generate Unlock Message */
+
+#define PCIE_VDM_DR(X)                      (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x34)
+
+/* Vendor-Defined Message Requester ID Register */
+#define PCIE_VDM_RID(X)                     (PCIE_APP_PORT_TO_BASE (X) + 0x38)
+#define PCIE_VDM_RID_VENROR_MSG_REQ_ID       0x0000FFFF
+#define PCIE_VDM_RID_VDMRID_S                0
+
+/* ASPM Control Register */
+#define PCIE_ASPM_CR(X)                     (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x40)
+#define PCIE_ASPM_CR_HOT_RST                 0x00000001  /* Hot Reset Request to the downstream device */
+#define PCIE_ASPM_CR_REQ_EXIT_L1             0x00000002  /* Request to Exit L1 */
+#define PCIE_ASPM_CR_REQ_ENTER_L1            0x00000004  /* Request to Enter L1 */
+
+/* Vendor Message DW0 Register */
+#define PCIE_VM_MSG_DW0(X)                  (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x50)
+#define PCIE_VM_MSG_DW0_TYPE                 0x0000001F  /* Message type */
+#define PCIE_VM_MSG_DW0_TYPE_S               0
+#define PCIE_VM_MSG_DW0_FORMAT               0x00000060  /* Format */
+#define PCIE_VM_MSG_DW0_FORMAT_S             5
+#define PCIE_VM_MSG_DW0_TC                   0x00007000  /* Traffic Class */
+#define PCIE_VM_MSG_DW0_TC_S                 12
+#define PCIE_VM_MSG_DW0_ATTR                 0x000C0000  /* Atrributes */
+#define PCIE_VM_MSG_DW0_ATTR_S               18
+#define PCIE_VM_MSG_DW0_EP_TLP               0x00100000  /* Poisoned TLP */
+#define PCIE_VM_MSG_DW0_TD                   0x00200000  /* TLP Digest */
+#define PCIE_VM_MSG_DW0_LEN                  0xFFC00000  /* Length */
+#define PCIE_VM_MSG_DW0_LEN_S                22
+
+/* Format Definition */
+enum {
+    PCIE_VM_MSG_FORMAT_00 = 0,  /* 3DW Hdr, no data*/
+    PCIE_VM_MSG_FORMAT_01,      /* 4DW Hdr, no data */
+    PCIE_VM_MSG_FORMAT_10,      /* 3DW Hdr, with data */
+    PCIE_VM_MSG_FORMAT_11,      /* 4DW Hdr, with data */
+};
+
+/* Traffic Class Definition */
+enum {
+    PCIE_VM_MSG_TC0 = 0,
+    PCIE_VM_MSG_TC1,
+    PCIE_VM_MSG_TC2,
+    PCIE_VM_MSG_TC3,
+    PCIE_VM_MSG_TC4,
+    PCIE_VM_MSG_TC5,
+    PCIE_VM_MSG_TC6,
+    PCIE_VM_MSG_TC7,
+};
+
+/* Attributes Definition */
+enum {
+    PCIE_VM_MSG_ATTR_00 = 0,   /* RO and No Snoop cleared */
+    PCIE_VM_MSG_ATTR_01,       /* RO cleared , No Snoop set */
+    PCIE_VM_MSG_ATTR_10,       /* RO set, No Snoop cleared*/
+    PCIE_VM_MSG_ATTR_11,       /* RO and No Snoop set */
+};
+
+/* Payload Size Definition */
+#define PCIE_VM_MSG_LEN_MIN  0
+#define PCIE_VM_MSG_LEN_MAX  1024
+
+/* Vendor Message DW1 Register */
+#define PCIE_VM_MSG_DW1(X)                 (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x54)
+#define PCIE_VM_MSG_DW1_FUNC_NUM            0x00000070  /* Function Number */
+#define PCIE_VM_MSG_DW1_FUNC_NUM_S          8
+#define PCIE_VM_MSG_DW1_CODE                0x00FF0000  /* Message Code */
+#define PCIE_VM_MSG_DW1_CODE_S              16
+#define PCIE_VM_MSG_DW1_TAG                 0xFF000000  /* Tag */
+#define PCIE_VM_MSG_DW1_TAG_S               24
+
+#define PCIE_VM_MSG_DW2(X)                  (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x58)
+#define PCIE_VM_MSG_DW3(X)                  (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x5C)
+
+/* Vendor Message Request Register */
+#define PCIE_VM_MSG_REQR(X)                 (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x60)
+#define PCIE_VM_MSG_REQR_REQ                 0x00000001  /* Vendor Message Request */
+
+
+/* AHB Slave Side Band Control Register */
+#define PCIE_AHB_SSB(X)                     (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x70)
+#define PCIE_AHB_SSB_REQ_BCM                0x00000001 /* Slave Reques BCM filed */
+#define PCIE_AHB_SSB_REQ_EP                 0x00000002 /* Slave Reques EP filed */
+#define PCIE_AHB_SSB_REQ_TD                 0x00000004 /* Slave Reques TD filed */
+#define PCIE_AHB_SSB_REQ_ATTR               0x00000018 /* Slave Reques Attribute number */
+#define PCIE_AHB_SSB_REQ_ATTR_S             3
+#define PCIE_AHB_SSB_REQ_TC                 0x000000E0 /* Slave Request TC Field */
+#define PCIE_AHB_SSB_REQ_TC_S               5
+
+/* AHB Master SideBand Ctrl Register */
+#define PCIE_AHB_MSB(X)                     (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x74)
+#define PCIE_AHB_MSB_RESP_ATTR               0x00000003 /* Master Response Attribute number */
+#define PCIE_AHB_MSB_RESP_ATTR_S             0
+#define PCIE_AHB_MSB_RESP_BAD_EOT            0x00000004 /* Master Response Badeot filed */
+#define PCIE_AHB_MSB_RESP_BCM                0x00000008 /* Master Response BCM filed */
+#define PCIE_AHB_MSB_RESP_EP                 0x00000010 /* Master Response EP filed */
+#define PCIE_AHB_MSB_RESP_TD                 0x00000020 /* Master Response TD filed */
+#define PCIE_AHB_MSB_RESP_FUN_NUM            0x000003C0 /* Master Response Function number */
+#define PCIE_AHB_MSB_RESP_FUN_NUM_S          6
+
+/* AHB Control Register, fixed bus enumeration exception */
+#define PCIE_AHB_CTRL(X)                     (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x78)
+#define PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS     0x00000001 
+
+/* Interrupt Enalbe Register */
+#define PCIE_IRNEN(X)                        (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF4)
+#define PCIE_IRNCR(X)                        (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF8)
+#define PCIE_IRNICR(X)                       (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xFC)
+
+/* PCIe interrupt enable/control/capture register definition */
+#define PCIE_IRN_AER_REPORT                 0x00000001  /* AER Interrupt */
+#define PCIE_IRN_AER_MSIX                   0x00000002  /* Advanced Error MSI-X Interrupt */
+#define PCIE_IRN_PME                        0x00000004  /* PME Interrupt */
+#define PCIE_IRN_HOTPLUG                    0x00000008  /* Hotplug Interrupt */
+#define PCIE_IRN_RX_VDM_MSG                 0x00000010  /* Vendor-Defined Message Interrupt */
+#define PCIE_IRN_RX_CORRECTABLE_ERR_MSG     0x00000020  /* Correctable Error Message Interrupt */
+#define PCIE_IRN_RX_NON_FATAL_ERR_MSG       0x00000040  /* Non-fatal Error Message */
+#define PCIE_IRN_RX_FATAL_ERR_MSG           0x00000080  /* Fatal Error Message */
+#define PCIE_IRN_RX_PME_MSG                 0x00000100  /* PME Message Interrupt */
+#define PCIE_IRN_RX_PME_TURNOFF_ACK         0x00000200  /* PME Turnoff Ack Message Interrupt */
+#define PCIE_IRN_AHB_BR_FATAL_ERR           0x00000400  /* AHB Fatal Error Interrupt */
+#define PCIE_IRN_LINK_AUTO_BW_STATUS        0x00000800  /* Link Auto Bandwidth Status Interrupt */
+#define PCIE_IRN_BW_MGT                     0x00001000  /* Bandwidth Managment Interrupt */
+#define PCIE_IRN_INTA                       0x00002000  /* INTA */
+#define PCIE_IRN_INTB                       0x00004000  /* INTB */
+#define PCIE_IRN_INTC                       0x00008000  /* INTC */
+#define PCIE_IRN_INTD                       0x00010000  /* INTD */
+#define PCIE_IRN_WAKEUP                     0x00020000  /* Wake up Interrupt */
+
+#define PCIE_RC_CORE_COMBINED_INT    (PCIE_IRN_AER_REPORT |  PCIE_IRN_AER_MSIX | PCIE_IRN_PME | \
+                                      PCIE_IRN_HOTPLUG | PCIE_IRN_RX_VDM_MSG | PCIE_IRN_RX_CORRECTABLE_ERR_MSG |\
+                                      PCIE_IRN_RX_NON_FATAL_ERR_MSG | PCIE_IRN_RX_FATAL_ERR_MSG | \
+                                      PCIE_IRN_RX_PME_MSG | PCIE_IRN_RX_PME_TURNOFF_ACK | PCIE_IRN_AHB_BR_FATAL_ERR | \
+                                      PCIE_IRN_LINK_AUTO_BW_STATUS | PCIE_IRN_BW_MGT)
+/* PCIe RC Configuration Register */
+#define PCIE_VDID(X)                (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x00)
+
+/* Bit definition from pci_reg.h */
+#define PCIE_PCICMDSTS(X)           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x04)
+#define PCIE_CCRID(X)               (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x08)
+#define PCIE_CLSLTHTBR(X)           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x0C) /* EP only */
+/* BAR0, BAR1,Only necessary if the bridges implements a device-specific register set or memory buffer */
+#define PCIE_BAR0(X)                (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10) /* Not used*/
+#define PCIE_BAR1(X)                (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14) /* Not used */
+
+#define PCIE_BNR(X)                 (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x18) /* Mandatory */
+/* Bus Number Register bits */
+#define PCIE_BNR_PRIMARY_BUS_NUM             0x000000FF
+#define PCIE_BNR_PRIMARY_BUS_NUM_S           0
+#define PCIE_PNR_SECONDARY_BUS_NUM           0x0000FF00
+#define PCIE_PNR_SECONDARY_BUS_NUM_S         8
+#define PCIE_PNR_SUB_BUS_NUM                 0x00FF0000
+#define PCIE_PNR_SUB_BUS_NUM_S               16
+
+/* IO Base/Limit Register bits */
+#define PCIE_IOBLSECS(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x1C)  /* RC only */
+#define PCIE_IOBLSECS_32BIT_IO_ADDR             0x00000001
+#define PCIE_IOBLSECS_IO_BASE_ADDR              0x000000F0
+#define PCIE_IOBLSECS_IO_BASE_ADDR_S            4
+#define PCIE_IOBLSECS_32BIT_IOLIMT              0x00000100
+#define PCIE_IOBLSECS_IO_LIMIT_ADDR             0x0000F000
+#define PCIE_IOBLSECS_IO_LIMIT_ADDR_S           12
+
+/* Non-prefetchable Memory Base/Limit Register bit */
+#define PCIE_MBML(X)                           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x20)  /* RC only */
+#define PCIE_MBML_MEM_BASE_ADDR                 0x0000FFF0
+#define PCIE_MBML_MEM_BASE_ADDR_S               4
+#define PCIE_MBML_MEM_LIMIT_ADDR                0xFFF00000
+#define PCIE_MBML_MEM_LIMIT_ADDR_S              20
+
+/* Prefetchable Memory Base/Limit Register bit */
+#define PCIE_PMBL(X)                           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x24)  /* RC only */
+#define PCIE_PMBL_64BIT_ADDR                    0x00000001
+#define PCIE_PMBL_UPPER_12BIT                   0x0000FFF0
+#define PCIE_PMBL_UPPER_12BIT_S                 4
+#define PCIE_PMBL_E64MA                         0x00010000
+#define PCIE_PMBL_END_ADDR                      0xFFF00000
+#define PCIE_PMBL_END_ADDR_S                    20
+#define PCIE_PMBU32(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x28)  /* RC only */
+#define PCIE_PMLU32(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x2C)  /* RC only */
+
+/* I/O Base/Limit Upper 16 bits register */
+#define PCIE_IO_BANDL(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x30)  /* RC only */
+#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE        0x0000FFFF
+#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE_S      0
+#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT       0xFFFF0000
+#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT_S     16
+
+#define PCIE_CPR(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x34)
+#define PCIE_EBBAR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x38)
+
+/* Interrupt and Secondary Bridge Control Register */
+#define PCIE_INTRBCTRL(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x3C)
+
+#define PCIE_INTRBCTRL_INT_LINE                 0x000000FF
+#define PCIE_INTRBCTRL_INT_LINE_S               0
+#define PCIE_INTRBCTRL_INT_PIN                  0x0000FF00
+#define PCIE_INTRBCTRL_INT_PIN_S                8
+#define PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE   0x00010000    /* #PERR */
+#define PCIE_INTRBCTRL_SERR_ENABLE              0x00020000    /* #SERR */
+#define PCIE_INTRBCTRL_ISA_ENABLE               0x00040000    /* ISA enable, IO 64KB only */
+#define PCIE_INTRBCTRL_VGA_ENABLE               0x00080000    /* VGA enable */
+#define PCIE_INTRBCTRL_VGA_16BIT_DECODE         0x00100000    /* VGA 16bit decode */
+#define PCIE_INTRBCTRL_RST_SECONDARY_BUS        0x00400000    /* Secondary bus rest, hot rest, 1ms */
+/* Others are read only */
+enum {
+    PCIE_INTRBCTRL_INT_NON = 0,
+    PCIE_INTRBCTRL_INTA,
+    PCIE_INTRBCTRL_INTB,
+    PCIE_INTRBCTRL_INTC,
+    PCIE_INTRBCTRL_INTD,
+};
+
+#define PCIE_PM_CAPR(X)                  (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x40)
+
+/* Power Management Control and Status Register */
+#define PCIE_PM_CSR(X)                   (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x44)
+
+#define PCIE_PM_CSR_POWER_STATE           0x00000003   /* Power State */
+#define PCIE_PM_CSR_POWER_STATE_S         0
+#define PCIE_PM_CSR_SW_RST                0x00000008   /* Soft Reset Enabled */
+#define PCIE_PM_CSR_PME_ENABLE            0x00000100   /* PME Enable */
+#define PCIE_PM_CSR_PME_STATUS            0x00008000   /* PME status */
+
+/* MSI Capability Register for EP */
+#define PCIE_MCAPR(X)                    (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x50)
+
+#define PCIE_MCAPR_MSI_CAP_ID             0x000000FF  /* MSI Capability ID */
+#define PCIE_MCAPR_MSI_CAP_ID_S           0
+#define PCIE_MCAPR_MSI_NEXT_CAP_PTR       0x0000FF00  /* Next Capability Pointer */
+#define PCIE_MCAPR_MSI_NEXT_CAP_PTR_S     8
+#define PCIE_MCAPR_MSI_ENABLE             0x00010000  /* MSI Enable */
+#define PCIE_MCAPR_MULTI_MSG_CAP          0x000E0000  /* Multiple Message Capable */
+#define PCIE_MCAPR_MULTI_MSG_CAP_S        17
+#define PCIE_MCAPR_MULTI_MSG_ENABLE       0x00700000  /* Multiple Message Enable */
+#define PCIE_MCAPR_MULTI_MSG_ENABLE_S     20
+#define PCIE_MCAPR_ADDR64_CAP             0X00800000  /* 64-bit Address Capable */
+
+/* MSI Message Address Register */
+#define PCIE_MA(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x54)
+
+#define PCIE_MA_ADDR_MASK                 0xFFFFFFFC  /* Message Address */
+
+/* MSI Message Upper Address Register */
+#define PCIE_MUA(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x58)
+
+/* MSI Message Data Register */
+#define PCIE_MD(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x5C)
+
+#define PCIE_MD_DATA                      0x0000FFFF  /* Message Data */
+#define PCIE_MD_DATA_S                    0
+
+/* PCI Express Capability Register */
+#define PCIE_XCAP(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70)
+
+#define PCIE_XCAP_ID                      0x000000FF  /* PCI Express Capability ID */
+#define PCIE_XCAP_ID_S                    0
+#define PCIE_XCAP_NEXT_CAP                0x0000FF00  /* Next Capability Pointer */
+#define PCIE_XCAP_NEXT_CAP_S              8
+#define PCIE_XCAP_VER                     0x000F0000  /* PCI Express Capability Version */
+#define PCIE_XCAP_VER_S                   16
+#define PCIE_XCAP_DEV_PORT_TYPE           0x00F00000  /* Device Port Type */
+#define PCIE_XCAP_DEV_PORT_TYPE_S         20
+#define PCIE_XCAP_SLOT_IMPLEMENTED        0x01000000  /* Slot Implemented */
+#define PCIE_XCAP_MSG_INT_NUM             0x3E000000  /* Interrupt Message Number */
+#define PCIE_XCAP_MSG_INT_NUM_S           25
+
+/* Device Capability Register */
+#define PCIE_DCAP(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74)
+
+#define PCIE_DCAP_MAX_PAYLOAD_SIZE        0x00000007   /* Max Payload size */
+#define PCIE_DCAP_MAX_PAYLOAD_SIZE_S      0
+#define PCIE_DCAP_PHANTOM_FUNC            0x00000018   /* Phanton Function, not supported */
+#define PCIE_DCAP_PHANTOM_FUNC_S          3
+#define PCIE_DCAP_EXT_TAG                 0x00000020   /* Extended Tag Field */
+#define PCIE_DCAP_EP_L0S_LATENCY          0x000001C0   /* EP L0s latency only */
+#define PCIE_DCAP_EP_L0S_LATENCY_S        6
+#define PCIE_DCAP_EP_L1_LATENCY           0x00000E00   /* EP L1 latency only */
+#define PCIE_DCAP_EP_L1_LATENCY_S         9
+#define PCIE_DCAP_ROLE_BASE_ERR_REPORT    0x00008000   /* Role Based ERR */
+
+/* Maximum payload size supported */
+enum {
+    PCIE_MAX_PAYLOAD_128 = 0,
+    PCIE_MAX_PAYLOAD_256,
+    PCIE_MAX_PAYLOAD_512,
+    PCIE_MAX_PAYLOAD_1024,
+    PCIE_MAX_PAYLOAD_2048,
+    PCIE_MAX_PAYLOAD_4096,
+};
+
+/* Device Control and Status Register */
+#define PCIE_DCTLSTS(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x78)
+
+#define PCIE_DCTLSTS_CORRECTABLE_ERR_EN        0x00000001   /* COR-ERR */
+#define PCIE_DCTLSTS_NONFATAL_ERR_EN           0x00000002   /* Non-fatal ERR */
+#define PCIE_DCTLSTS_FATAL_ERR_EN              0x00000004   /* Fatal ERR */
+#define PCIE_DCTLSYS_UR_REQ_EN                 0x00000008   /* UR ERR */
+#define PCIE_DCTLSTS_RELAXED_ORDERING_EN       0x00000010   /* Enable relaxing ordering */
+#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE          0x000000E0   /* Max payload mask */
+#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE_S        5
+#define PCIE_DCTLSTS_EXT_TAG_EN                0x00000100   /* Extended tag field */
+#define PCIE_DCTLSTS_PHANTOM_FUNC_EN           0x00000200   /* Phantom Function Enable */
+#define PCIE_DCTLSTS_AUX_PM_EN                 0x00000400   /* AUX Power PM Enable */
+#define PCIE_DCTLSTS_NO_SNOOP_EN               0x00000800   /* Enable no snoop, except root port*/
+#define PCIE_DCTLSTS_MAX_READ_SIZE             0x00007000   /* Max Read Request size*/
+#define PCIE_DCTLSTS_MAX_READ_SIZE_S           12
+#define PCIE_DCTLSTS_CORRECTABLE_ERR           0x00010000   /* COR-ERR Detected */
+#define PCIE_DCTLSTS_NONFATAL_ERR              0x00020000   /* Non-Fatal ERR Detected */
+#define PCIE_DCTLSTS_FATAL_ER                  0x00040000   /* Fatal ERR Detected */
+#define PCIE_DCTLSTS_UNSUPPORTED_REQ           0x00080000   /* UR Detected */
+#define PCIE_DCTLSTS_AUX_POWER                 0x00100000   /* Aux Power Detected */
+#define PCIE_DCTLSTS_TRANSACT_PENDING          0x00200000   /* Transaction pending */
+
+#define PCIE_DCTLSTS_ERR_EN      (PCIE_DCTLSTS_CORRECTABLE_ERR_EN | \
+                                  PCIE_DCTLSTS_NONFATAL_ERR_EN | PCIE_DCTLSTS_FATAL_ERR_EN | \
+                                  PCIE_DCTLSYS_UR_REQ_EN)
+
+/* Link Capability Register */
+#define PCIE_LCAP(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7C)
+#define PCIE_LCAP_MAX_LINK_SPEED               0x0000000F  /* Max link speed, 0x1 by default */
+#define PCIE_LCAP_MAX_LINK_SPEED_S             0
+#define PCIE_LCAP_MAX_LENGTH_WIDTH             0x000003F0  /* Maxium Length Width */
+#define PCIE_LCAP_MAX_LENGTH_WIDTH_S           4
+#define PCIE_LCAP_ASPM_LEVEL                   0x00000C00  /* Active State Link PM Support */
+#define PCIE_LCAP_ASPM_LEVEL_S                 10
+#define PCIE_LCAP_L0S_EIXT_LATENCY             0x00007000  /* L0s Exit Latency */
+#define PCIE_LCAP_L0S_EIXT_LATENCY_S           12
+#define PCIE_LCAP_L1_EXIT_LATENCY              0x00038000  /* L1 Exit Latency */
+#define PCIE_LCAP_L1_EXIT_LATENCY_S            15
+#define PCIE_LCAP_CLK_PM                       0x00040000  /* Clock Power Management */
+#define PCIE_LCAP_SDER                         0x00080000  /* Surprise Down Error Reporting */
+#define PCIE_LCAP_DLL_ACTIVE_REPROT            0x00100000  /* Data Link Layer Active Reporting Capable */
+#define PCIE_LCAP_PORT_NUM                     0xFF0000000  /* Port number */
+#define PCIE_LCAP_PORT_NUM_S                   24
+
+/* Maximum Length width definition */
+#define PCIE_MAX_LENGTH_WIDTH_RES  0x00
+#define PCIE_MAX_LENGTH_WIDTH_X1   0x01  /* Default */
+#define PCIE_MAX_LENGTH_WIDTH_X2   0x02
+#define PCIE_MAX_LENGTH_WIDTH_X4   0x04
+#define PCIE_MAX_LENGTH_WIDTH_X8   0x08
+#define PCIE_MAX_LENGTH_WIDTH_X12  0x0C
+#define PCIE_MAX_LENGTH_WIDTH_X16  0x10
+#define PCIE_MAX_LENGTH_WIDTH_X32  0x20
+
+/* Active State Link PM definition */
+enum {
+    PCIE_ASPM_RES0                = 0,
+    PCIE_ASPM_L0S_ENTRY_SUPPORT,        /* L0s */
+    PCIE_ASPM_RES1,
+    PCIE_ASPM_L0S_L1_ENTRY_SUPPORT,     /* L0s and L1, default */
+};
+
+/* L0s Exit Latency definition */
+enum {
+    PCIE_L0S_EIXT_LATENCY_L64NS    = 0, /* < 64 ns */
+    PCIE_L0S_EIXT_LATENCY_B64A128,      /* > 64 ns < 128 ns */
+    PCIE_L0S_EIXT_LATENCY_B128A256,     /* > 128 ns < 256 ns */
+    PCIE_L0S_EIXT_LATENCY_B256A512,     /* > 256 ns < 512 ns */
+    PCIE_L0S_EIXT_LATENCY_B512TO1U,     /* > 512 ns < 1 us */
+    PCIE_L0S_EIXT_LATENCY_B1A2U,        /* > 1 us < 2 us */
+    PCIE_L0S_EIXT_LATENCY_B2A4U,        /* > 2 us < 4 us */
+    PCIE_L0S_EIXT_LATENCY_M4US,         /* > 4 us  */
+};
+
+/* L1 Exit Latency definition */
+enum {
+    PCIE_L1_EXIT_LATENCY_L1US  = 0,  /* < 1 us */
+    PCIE_L1_EXIT_LATENCY_B1A2,       /* > 1 us < 2 us */
+    PCIE_L1_EXIT_LATENCY_B2A4,       /* > 2 us < 4 us */
+    PCIE_L1_EXIT_LATENCY_B4A8,       /* > 4 us < 8 us */
+    PCIE_L1_EXIT_LATENCY_B8A16,      /* > 8 us < 16 us */
+    PCIE_L1_EXIT_LATENCY_B16A32,     /* > 16 us < 32 us */
+    PCIE_L1_EXIT_LATENCY_B32A64,     /* > 32 us < 64 us */
+    PCIE_L1_EXIT_LATENCY_M64US,      /* > 64 us */
+};
+
+/* Link Control and Status Register */
+#define PCIE_LCTLSTS(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x80)
+#define PCIE_LCTLSTS_ASPM_ENABLE            0x00000003  /* Active State Link PM Control */
+#define PCIE_LCTLSTS_ASPM_ENABLE_S          0
+#define PCIE_LCTLSTS_RCB128                 0x00000008  /* Read Completion Boundary 128*/
+#define PCIE_LCTLSTS_LINK_DISABLE           0x00000010  /* Link Disable */
+#define PCIE_LCTLSTS_RETRIAN_LINK           0x00000020  /* Retrain Link */
+#define PCIE_LCTLSTS_COM_CLK_CFG            0x00000040  /* Common Clock Configuration */
+#define PCIE_LCTLSTS_EXT_SYNC               0x00000080  /* Extended Synch */
+#define PCIE_LCTLSTS_CLK_PM_EN              0x00000100  /* Enable Clock Powerm Management */
+#define PCIE_LCTLSTS_LINK_SPEED             0x000F0000  /* Link Speed */
+#define PCIE_LCTLSTS_LINK_SPEED_S           16
+#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH  0x03F00000  /* Negotiated Link Width */
+#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH_S 20
+#define PCIE_LCTLSTS_RETRAIN_PENDING        0x08000000  /* Link training is ongoing */
+#define PCIE_LCTLSTS_SLOT_CLK_CFG           0x10000000  /* Slot Clock Configuration */
+#define PCIE_LCTLSTS_DLL_ACTIVE             0x20000000  /* Data Link Layer Active */
+
+/* Slot Capabilities Register */
+#define PCIE_SLCAP(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x84)
+
+/* Slot Capabilities */
+#define PCIE_SLCTLSTS(X)                    (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x88)
+
+/* Root Control and Capability Register */
+#define PCIE_RCTLCAP(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x8C)
+#define PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR  0x00000001   /* #SERR on COR-ERR */
+#define PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR     0x00000002   /* #SERR on Non-Fatal ERR */
+#define PCIE_RCTLCAP_SERR_ON_FATAL_ERR        0x00000004   /* #SERR on Fatal ERR */
+#define PCIE_RCTLCAP_PME_INT_EN               0x00000008   /* PME Interrupt Enable */
+#define PCIE_RCTLCAP_SERR_ENABLE    (PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR | \
+                                     PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR | PCIE_RCTLCAP_SERR_ON_FATAL_ERR)
+/* Root Status Register */
+#define PCIE_RSTS(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x90)
+#define PCIE_RSTS_PME_REQ_ID                   0x0000FFFF   /* PME Request ID */
+#define PCIE_RSTS_PME_REQ_ID_S                 0
+#define PCIE_RSTS_PME_STATUS                   0x00010000   /* PME Status */
+#define PCIE_RSTS_PME_PENDING                  0x00020000   /* PME Pending */
+
+/* PCI Express Enhanced Capability Header */
+#define PCIE_ENHANCED_CAP(X)                (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x100)
+#define PCIE_ENHANCED_CAP_ID                 0x0000FFFF  /* PCI Express Extended Capability ID */
+#define PCIE_ENHANCED_CAP_ID_S               0
+#define PCIE_ENHANCED_CAP_VER                0x000F0000  /* Capability Version */
+#define PCIE_ENHANCED_CAP_VER_S              16
+#define PCIE_ENHANCED_CAP_NEXT_OFFSET        0xFFF00000  /* Next Capability Offset */
+#define PCIE_ENHANCED_CAP_NEXT_OFFSET_S      20
+
+/* Uncorrectable Error Status Register */
+#define PCIE_UES_R(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x104)
+#define PCIE_DATA_LINK_PROTOCOL_ERR          0x00000010  /* Data Link Protocol Error Status */
+#define PCIE_SURPRISE_DOWN_ERROR             0x00000020  /* Surprise Down Error Status */
+#define PCIE_POISONED_TLP                    0x00001000  /* Poisoned TLP Status */
+#define PCIE_FC_PROTOCOL_ERR                 0x00002000  /* Flow Control Protocol Error Status */
+#define PCIE_COMPLETION_TIMEOUT              0x00004000  /* Completion Timeout Status */
+#define PCIE_COMPLETOR_ABORT                 0x00008000  /* Completer Abort Error */
+#define PCIE_UNEXPECTED_COMPLETION           0x00010000  /* Unexpected Completion Status */
+#define PCIE_RECEIVER_OVERFLOW               0x00020000  /* Receive Overflow Status */
+#define PCIE_MALFORNED_TLP                   0x00040000  /* Malformed TLP Stauts */
+#define PCIE_ECRC_ERR                        0x00080000  /* ECRC Error Stauts */
+#define PCIE_UR_REQ                          0x00100000  /* Unsupported Request Error Status */
+#define PCIE_ALL_UNCORRECTABLE_ERR    (PCIE_DATA_LINK_PROTOCOL_ERR | PCIE_SURPRISE_DOWN_ERROR | \
+                         PCIE_POISONED_TLP | PCIE_FC_PROTOCOL_ERR | PCIE_COMPLETION_TIMEOUT |   \
+                         PCIE_COMPLETOR_ABORT | PCIE_UNEXPECTED_COMPLETION | PCIE_RECEIVER_OVERFLOW |\
+                         PCIE_MALFORNED_TLP | PCIE_ECRC_ERR | PCIE_UR_REQ)
+
+/* Uncorrectable Error Mask Register, Mask means no report */
+#define PCIE_UEMR(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x108)
+
+/* Uncorrectable Error Severity Register */
+#define PCIE_UESR(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10C)
+
+/* Correctable Error Status Register */
+#define PCIE_CESR(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x110)
+#define PCIE_RX_ERR                          0x00000001  /* Receive Error Status */
+#define PCIE_BAD_TLP                         0x00000040  /* Bad TLP Status */
+#define PCIE_BAD_DLLP                        0x00000080  /* Bad DLLP Status */
+#define PCIE_REPLAY_NUM_ROLLOVER             0x00000100  /* Replay Number Rollover Status */
+#define PCIE_REPLAY_TIMER_TIMEOUT_ERR        0x00001000  /* Reply Timer Timeout Status */
+#define PCIE_ADVISORY_NONFTAL_ERR            0x00002000  /* Advisory Non-Fatal Error Status */
+#define PCIE_CORRECTABLE_ERR        (PCIE_RX_ERR | PCIE_BAD_TLP | PCIE_BAD_DLLP | PCIE_REPLAY_NUM_ROLLOVER |\
+                                     PCIE_REPLAY_TIMER_TIMEOUT_ERR | PCIE_ADVISORY_NONFTAL_ERR)
+
+/* Correctable Error Mask Register */
+#define PCIE_CEMR(X)                        (volatile u32*)(PCIE_RC_CFG_BASE + 0x114)
+
+/* Advanced Error Capabilities and Control Register */
+#define PCIE_AECCR(X)                       (volatile u32*)(PCIE_RC_CFG_BASE + 0x118)
+#define PCIE_AECCR_FIRST_ERR_PTR            0x0000001F  /* First Error Pointer */
+#define PCIE_AECCR_FIRST_ERR_PTR_S          0
+#define PCIE_AECCR_ECRC_GEN_CAP             0x00000020  /* ECRC Generation Capable */
+#define PCIE_AECCR_ECRC_GEN_EN              0x00000040  /* ECRC Generation Enable */
+#define PCIE_AECCR_ECRC_CHECK_CAP           0x00000080  /* ECRC Check Capable */
+#define PCIE_AECCR_ECRC_CHECK_EN            0x00000100  /* ECRC Check Enable */
+
+/* Header Log Register 1 */
+#define PCIE_HLR1(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x11C)
+
+/* Header Log Register 2 */
+#define PCIE_HLR2(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x120)
+
+/* Header Log Register 3 */
+#define PCIE_HLR3(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x124)
+
+/* Header Log Register 4 */
+#define PCIE_HLR4(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x128)
+
+/* Root Error Command Register */
+#define PCIE_RECR(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x12C)
+#define PCIE_RECR_CORRECTABLE_ERR_REPORT_EN  0x00000001 /* COR-ERR */
+#define PCIE_RECR_NONFATAL_ERR_REPORT_EN     0x00000002 /* Non-Fatal ERR */
+#define PCIE_RECR_FATAL_ERR_REPORT_EN        0x00000004 /* Fatal ERR */
+#define PCIE_RECR_ERR_REPORT_EN  (PCIE_RECR_CORRECTABLE_ERR_REPORT_EN | \
+                PCIE_RECR_NONFATAL_ERR_REPORT_EN | PCIE_RECR_FATAL_ERR_REPORT_EN)
+
+/* Root Error Status Register */
+#define PCIE_RESR(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x130)
+#define PCIE_RESR_CORRECTABLE_ERR                0x00000001   /* COR-ERR Receveid */
+#define PCIE_RESR_MULTI_CORRECTABLE_ERR          0x00000002   /* Multiple COR-ERR Received */
+#define PCIE_RESR_FATAL_NOFATAL_ERR              0x00000004   /* ERR Fatal/Non-Fatal Received */
+#define PCIE_RESR_MULTI_FATAL_NOFATAL_ERR        0x00000008   /* Multiple ERR Fatal/Non-Fatal Received */
+#define PCIE_RESR_FIRST_UNCORRECTABLE_FATAL_ERR  0x00000010   /* First UN-COR Fatal */
+#define PCIR_RESR_NON_FATAL_ERR                  0x00000020   /* Non-Fatal Error Message Received */
+#define PCIE_RESR_FATAL_ERR                      0x00000040   /* Fatal Message Received */
+#define PCIE_RESR_AER_INT_MSG_NUM                0xF8000000   /* Advanced Error Interrupt Message Number */
+#define PCIE_RESR_AER_INT_MSG_NUM_S              27
+
+/* Error Source Indentification Register */
+#define PCIE_ESIR(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x134)
+#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID         0x0000FFFF
+#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID_S       0
+#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID         0xFFFF0000
+#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID_S       16
+
+/* VC Enhanced Capability Header */
+#define PCIE_VC_ECH(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x140)
+
+/* Port VC Capability Register */
+#define PCIE_PVC1(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x144)
+#define PCIE_PVC1_EXT_VC_CNT                    0x00000007  /* Extended VC Count */
+#define PCIE_PVC1_EXT_VC_CNT_S                  0
+#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT            0x00000070  /* Low Priority Extended VC Count */
+#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT_S          4
+#define PCIE_PVC1_REF_CLK                       0x00000300  /* Reference Clock */
+#define PCIE_PVC1_REF_CLK_S                     8
+#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE       0x00000C00  /* Port Arbitration Table Entry Size */
+#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE_S     10
+
+/* Extended Virtual Channel Count Defintion */
+#define PCIE_EXT_VC_CNT_MIN   0
+#define PCIE_EXT_VC_CNT_MAX   7
+
+/* Port Arbitration Table Entry Size Definition */
+enum {
+    PCIE_PORT_ARB_TAB_ENTRY_SIZE_S1BIT = 0,
+    PCIE_PORT_ARB_TAB_ENTRY_SIZE_S2BIT,
+    PCIE_PORT_ARB_TAB_ENTRY_SIZE_S4BIT,
+    PCIE_PORT_ARB_TAB_ENTRY_SIZE_S8BIT,
+};
+
+/* Port VC Capability Register 2 */
+#define PCIE_PVC2(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x148)
+#define PCIE_PVC2_VC_ARB_16P_FIXED_WRR      0x00000001  /* HW Fixed arbitration, 16 phase WRR */
+#define PCIE_PVC2_VC_ARB_32P_WRR            0x00000002  /* 32 phase WRR */
+#define PCIE_PVC2_VC_ARB_64P_WRR            0x00000004  /* 64 phase WRR */
+#define PCIE_PVC2_VC_ARB_128P_WRR           0x00000008  /* 128 phase WRR */
+#define PCIE_PVC2_VC_ARB_WRR                0x0000000F
+#define PCIE_PVC2_VC_ARB_TAB_OFFSET         0xFF000000  /* VC arbitration table offset, not support */
+#define PCIE_PVC2_VC_ARB_TAB_OFFSET_S       24
+
+/* Port VC Control and Status Register */     
+#define PCIE_PVCCRSR(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14C)
+#define PCIE_PVCCRSR_LOAD_VC_ARB_TAB         0x00000001  /* Load VC Arbitration Table */
+#define PCIE_PVCCRSR_VC_ARB_SEL              0x0000000E  /* VC Arbitration Select */
+#define PCIE_PVCCRSR_VC_ARB_SEL_S            1
+#define PCIE_PVCCRSR_VC_ARB_TAB_STATUS       0x00010000  /* Arbitration Status */
+
+/* VC0 Resource Capability Register */
+#define PCIE_VC0_RC(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x150)
+#define PCIE_VC0_RC_PORT_ARB_HW_FIXED        0x00000001  /* HW Fixed arbitration */
+#define PCIE_VC0_RC_PORT_ARB_32P_WRR         0x00000002  /* 32 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB_64P_WRR         0x00000004  /* 64 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB_128P_WRR        0x00000008  /* 128 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB_TM_128P_WRR     0x00000010  /* Time-based 128 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB_TM_256P_WRR     0x00000020  /* Time-based 256 phase WRR */
+#define PCIE_VC0_RC_PORT_ARB          (PCIE_VC0_RC_PORT_ARB_HW_FIXED | PCIE_VC0_RC_PORT_ARB_32P_WRR |\
+                        PCIE_VC0_RC_PORT_ARB_64P_WRR | PCIE_VC0_RC_PORT_ARB_128P_WRR | \
+                        PCIE_VC0_RC_PORT_ARB_TM_128P_WRR | PCIE_VC0_RC_PORT_ARB_TM_256P_WRR)
+
+#define PCIE_VC0_RC_REJECT_SNOOP             0x00008000  /* Reject Snoop Transactioin */
+#define PCIE_VC0_RC_MAX_TIMESLOTS            0x007F0000  /* Maximum time Slots */
+#define PCIE_VC0_RC_MAX_TIMESLOTS_S          16
+#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET      0xFF000000  /* Port Arbitration Table Offset */
+#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET_S    24
+
+/* VC0 Resource Control Register */
+#define PCIE_VC0_RC0(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x154)
+#define PCIE_VC0_RC0_TVM0                    0x00000001  /* TC0 and VC0 */
+#define PCIE_VC0_RC0_TVM1                    0x00000002  /* TC1 and VC1 */
+#define PCIE_VC0_RC0_TVM2                    0x00000004  /* TC2 and VC2 */
+#define PCIE_VC0_RC0_TVM3                    0x00000008  /* TC3 and VC3 */
+#define PCIE_VC0_RC0_TVM4                    0x00000010  /* TC4 and VC4 */
+#define PCIE_VC0_RC0_TVM5                    0x00000020  /* TC5 and VC5 */
+#define PCIE_VC0_RC0_TVM6                    0x00000040  /* TC6 and VC6 */
+#define PCIE_VC0_RC0_TVM7                    0x00000080  /* TC7 and VC7 */
+#define PCIE_VC0_RC0_TC_VC                   0x000000FF  /* TC/VC mask */
+
+#define PCIE_VC0_RC0_LOAD_PORT_ARB_TAB       0x00010000  /* Load Port Arbitration Table */
+#define PCIE_VC0_RC0_PORT_ARB_SEL            0x000E0000  /* Port Arbitration Select */
+#define PCIE_VC0_RC0_PORT_ARB_SEL_S          17
+#define PCIE_VC0_RC0_VC_ID                   0x07000000  /* VC ID */
+#define PCIE_VC0_RC0_VC_ID_S                 24
+#define PCIE_VC0_RC0_VC_EN                   0x80000000  /* VC Enable */
+
+/* VC0 Resource Status Register */
+#define PCIE_VC0_RSR0(X)                     (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x158)
+#define PCIE_VC0_RSR0_PORT_ARB_TAB_STATUS    0x00010000  /* Port Arbitration Table Status,not used */
+#define PCIE_VC0_RSR0_VC_NEG_PENDING         0x00020000  /* VC Negotiation Pending */
+
+/* Ack Latency Timer and Replay Timer Register */
+#define PCIE_ALTRT(X)                         (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x700)
+#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT   0x0000FFFF  /* Round Trip Latency Time Limit */
+#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT_S 0
+#define PCIE_ALTRT_REPLAY_TIME_LIMIT          0xFFFF0000  /* Replay Time Limit */
+#define PCIE_ALTRT_REPLAY_TIME_LIMIT_S        16
+
+/* Other Message Register */
+#define PCIE_OMR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x704)
+
+/* Port Force Link Register */
+#define PCIE_PFLR(X)                         (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x708)
+#define PCIE_PFLR_LINK_NUM                   0x000000FF  /* Link Number */
+#define PCIE_PFLR_LINK_NUM_S                 0
+#define PCIE_PFLR_FORCE_LINK                 0x00008000  /* Force link */
+#define PCIE_PFLR_LINK_STATE                 0x003F0000  /* Link State */
+#define PCIE_PFLR_LINK_STATE_S               16
+#define PCIE_PFLR_LOW_POWER_ENTRY_CNT        0xFF000000  /* Low Power Entrance Count, only for EP */
+#define PCIE_PFLR_LOW_POWER_ENTRY_CNT_S      24
+
+/* Ack Frequency Register */
+#define PCIE_AFR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70C)
+#define PCIE_AFR_AF                          0x000000FF  /* Ack Frequency */
+#define PCIE_AFR_AF_S                        0
+#define PCIE_AFR_FTS_NUM                     0x0000FF00  /* The number of Fast Training Sequence from L0S to L0 */
+#define PCIE_AFR_FTS_NUM_S                   8
+#define PCIE_AFR_COM_FTS_NUM                 0x00FF0000  /* N_FTS; when common clock is used*/
+#define PCIE_AFR_COM_FTS_NUM_S               16
+#define PCIE_AFR_L0S_ENTRY_LATENCY           0x07000000  /* L0s Entrance Latency */
+#define PCIE_AFR_L0S_ENTRY_LATENCY_S         24
+#define PCIE_AFR_L1_ENTRY_LATENCY            0x38000000  /* L1 Entrance Latency */
+#define PCIE_AFR_L1_ENTRY_LATENCY_S          27
+#define PCIE_AFR_FTS_NUM_DEFAULT             32
+#define PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT   7
+#define PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT    5
+
+/* Port Link Control Register */
+#define PCIE_PLCR(X)                         (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x710)
+#define PCIE_PLCR_OTHER_MSG_REQ              0x00000001  /* Other Message Request */
+#define PCIE_PLCR_SCRAMBLE_DISABLE           0x00000002  /* Scramble Disable */  
+#define PCIE_PLCR_LOOPBACK_EN                0x00000004  /* Loopback Enable */
+#define PCIE_PLCR_LTSSM_HOT_RST              0x00000008  /* Force LTSSM to the hot reset */
+#define PCIE_PLCR_DLL_LINK_EN                0x00000020  /* Enable Link initialization */
+#define PCIE_PLCR_FAST_LINK_SIM_EN           0x00000080  /* Sets all internal timers to fast mode for simulation purposes */
+#define PCIE_PLCR_LINK_MODE                  0x003F0000  /* Link Mode Enable Mask */
+#define PCIE_PLCR_LINK_MODE_S                16
+#define PCIE_PLCR_CORRUPTED_CRC_EN           0x02000000  /* Enabled Corrupt CRC */
+
+/* Lane Skew Register */
+#define PCIE_LSR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x714)
+#define PCIE_LSR_LANE_SKEW_NUM               0x00FFFFFF  /* Insert Lane Skew for Transmit, not applicable */
+#define PCIE_LSR_LANE_SKEW_NUM_S             0
+#define PCIE_LSR_FC_DISABLE                  0x01000000  /* Disable of Flow Control */
+#define PCIE_LSR_ACKNAK_DISABLE              0x02000000  /* Disable of Ack/Nak */
+#define PCIE_LSR_LANE_DESKEW_DISABLE         0x80000000  /* Disable of Lane-to-Lane Skew */
+
+/* Symbol Number Register */
+#define PCIE_SNR(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x718)
+#define PCIE_SNR_TS                          0x0000000F  /* Number of TS Symbol */
+#define PCIE_SNR_TS_S                        0
+#define PCIE_SNR_SKP                         0x00000700  /* Number of SKP Symbol */
+#define PCIE_SNR_SKP_S                       8
+#define PCIE_SNR_REPLAY_TIMER                0x0007C000  /* Timer Modifier for Replay Timer */
+#define PCIE_SNR_REPLAY_TIMER_S              14
+#define PCIE_SNR_ACKNAK_LATENCY_TIMER        0x00F80000  /* Timer Modifier for Ack/Nak Latency Timer */
+#define PCIE_SNR_ACKNAK_LATENCY_TIMER_S      19
+#define PCIE_SNR_FC_TIMER                    0x1F000000  /* Timer Modifier for Flow Control Watchdog Timer */
+#define PCIE_SNR_FC_TIMER_S                  28
+
+/* Symbol Timer Register and Filter Mask Register 1 */
+#define PCIE_STRFMR(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x71C)
+#define PCIE_STRFMR_SKP_INTERVAL            0x000007FF  /* SKP lnterval Value */
+#define PCIE_STRFMR_SKP_INTERVAL_S          0
+#define PCIE_STRFMR_FC_WDT_DISABLE          0x00008000  /* Disable of FC Watchdog Timer */
+#define PCIE_STRFMR_TLP_FUNC_MISMATCH_OK    0x00010000  /* Mask Function Mismatch Filtering for Incoming Requests */
+#define PCIE_STRFMR_POISONED_TLP_OK         0x00020000  /* Mask Poisoned TLP Filtering */
+#define PCIE_STRFMR_BAR_MATCH_OK            0x00040000  /* Mask BAR Match Filtering */
+#define PCIE_STRFMR_TYPE1_CFG_REQ_OK        0x00080000  /* Mask Type 1 Configuration Request Filtering */
+#define PCIE_STRFMR_LOCKED_REQ_OK           0x00100000  /* Mask Locked Request Filtering */
+#define PCIE_STRFMR_CPL_TAG_ERR_RULES_OK    0x00200000  /* Mask Tag Error Rules for Received Completions */
+#define PCIE_STRFMR_CPL_REQUESTOR_ID_MISMATCH_OK 0x00400000  /* Mask Requester ID Mismatch Error for Received Completions */
+#define PCIE_STRFMR_CPL_FUNC_MISMATCH_OK         0x00800000  /* Mask Function Mismatch Error for Received Completions */
+#define PCIE_STRFMR_CPL_TC_MISMATCH_OK           0x01000000  /* Mask Traffic Class Mismatch Error for Received Completions */
+#define PCIE_STRFMR_CPL_ATTR_MISMATCH_OK         0x02000000  /* Mask Attribute Mismatch Error for Received Completions */
+#define PCIE_STRFMR_CPL_LENGTH_MISMATCH_OK       0x04000000  /* Mask Length Mismatch Error for Received Completions */
+#define PCIE_STRFMR_TLP_ECRC_ERR_OK              0x08000000  /* Mask ECRC Error Filtering */
+#define PCIE_STRFMR_CPL_TLP_ECRC_OK              0x10000000  /* Mask ECRC Error Filtering for Completions */
+#define PCIE_STRFMR_RX_TLP_MSG_NO_DROP           0x20000000  /* Send Message TLPs */
+#define PCIE_STRFMR_RX_IO_TRANS_ENABLE           0x40000000  /* Mask Filtering of received I/O Requests */
+#define PCIE_STRFMR_RX_CFG_TRANS_ENABLE          0x80000000  /* Mask Filtering of Received Configuration Requests */
+
+#define PCIE_DEF_SKP_INTERVAL    700             /* 1180 ~1538 , 125MHz * 2, 250MHz * 1 */
+
+/* Filter Masker Register 2 */
+#define PCIE_FMR2(X)                             (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x720)
+#define PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1    0x00000001  /* Mask RADM Filtering and Error Handling Rules */
+#define PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1    0x00000002  /* Mask RADM Filtering and Error Handling Rules */
+
+/* Debug Register 0 */
+#define PCIE_DBR0(X)                              (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x728)
+
+/* Debug Register 1 */
+#define PCIE_DBR1(X)                              (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x72C)
+
+/* Transmit Posted FC Credit Status Register */
+#define PCIE_TPFCS(X)                             (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x730)
+#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS           0x00000FFF /* Transmit Posted Data FC Credits */
+#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS_S         0
+#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS            0x000FF000 /* Transmit Posted Header FC Credits */
+#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS_S          12
+
+/* Transmit Non-Posted FC Credit Status */
+#define PCIE_TNPFCS(X)                            (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x734)
+#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS         0x00000FFF /* Transmit Non-Posted Data FC Credits */
+#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS_S       0
+#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS          0x000FF000 /* Transmit Non-Posted Header FC Credits */
+#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS_S        12
+
+/* Transmit Complete FC Credit Status Register */
+#define PCIE_TCFCS(X)                             (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x738)
+#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS         0x00000FFF /* Transmit Completion Data FC Credits */
+#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS_S       0
+#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS          0x000FF000 /* Transmit Completion Header FC Credits */
+#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS_S        12
+
+/* Queue Status Register */
+#define PCIE_QSR(X)                              (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x73C)
+#define PCIE_QSR_WAIT_UPDATE_FC_DLL               0x00000001 /* Received TLP FC Credits Not Returned */
+#define PCIE_QSR_TX_RETRY_BUF_NOT_EMPTY           0x00000002 /* Transmit Retry Buffer Not Empty */
+#define PCIE_QSR_RX_QUEUE_NOT_EMPTY               0x00000004 /* Received Queue Not Empty */
+
+/* VC Transmit Arbitration Register 1 */
+#define PCIE_VCTAR1(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x740)
+#define PCIE_VCTAR1_WRR_WEIGHT_VC0               0x000000FF /* WRR Weight for VC0 */
+#define PCIE_VCTAR1_WRR_WEIGHT_VC1               0x0000FF00 /* WRR Weight for VC1 */
+#define PCIE_VCTAR1_WRR_WEIGHT_VC2               0x00FF0000 /* WRR Weight for VC2 */
+#define PCIE_VCTAR1_WRR_WEIGHT_VC3               0xFF000000 /* WRR Weight for VC3 */
+
+/* VC Transmit Arbitration Register 2 */
+#define PCIE_VCTAR2(X)                          (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x744)
+#define PCIE_VCTAR2_WRR_WEIGHT_VC4               0x000000FF /* WRR Weight for VC4 */
+#define PCIE_VCTAR2_WRR_WEIGHT_VC5               0x0000FF00 /* WRR Weight for VC5 */
+#define PCIE_VCTAR2_WRR_WEIGHT_VC6               0x00FF0000 /* WRR Weight for VC6 */
+#define PCIE_VCTAR2_WRR_WEIGHT_VC7               0xFF000000 /* WRR Weight for VC7 */
+
+/* VC0 Posted Receive Queue Control Register */
+#define PCIE_VC0_PRQCR(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x748)
+#define PCIE_VC0_PRQCR_P_DATA_CREDITS            0x00000FFF /* VC0 Posted Data Credits */
+#define PCIE_VC0_PRQCR_P_DATA_CREDITS_S          0
+#define PCIE_VC0_PRQCR_P_HDR_CREDITS             0x000FF000 /* VC0 Posted Header Credits */
+#define PCIE_VC0_PRQCR_P_HDR_CREDITS_S           12
+#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE          0x00E00000 /* VC0 Posted TLP Queue Mode */
+#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE_S        20
+#define PCIE_VC0_PRQCR_TLP_RELAX_ORDER           0x40000000 /* TLP Type Ordering for VC0 */    
+#define PCIE_VC0_PRQCR_VC_STRICT_ORDER           0x80000000 /* VC0 Ordering for Receive Queues */
+
+/* VC0 Non-Posted Receive Queue Control */
+#define PCIE_VC0_NPRQCR(X)                      (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74C)
+#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS          0x00000FFF /* VC0 Non-Posted Data Credits */
+#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS_S        0
+#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS           0x000FF000 /* VC0 Non-Posted Header Credits */
+#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS_S         12
+#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE        0x00E00000 /* VC0 Non-Posted TLP Queue Mode */
+#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE_S      20
+
+/* VC0 Completion Receive Queue Control */
+#define PCIE_VC0_CRQCR(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x750)
+#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS          0x00000FFF /* VC0 Completion TLP Queue Mode */
+#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS_S        0
+#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS           0x000FF000 /* VC0 Completion Header Credits */
+#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS_S         12
+#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE        0x00E00000 /* VC0 Completion Data Credits */
+#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE_S      21
+
+/* Applicable to the above three registers */
+enum {
+    PCIE_VC0_TLP_QUEUE_MODE_STORE_FORWARD = 1,
+    PCIE_VC0_TLP_QUEUE_MODE_CUT_THROUGH   = 2,
+    PCIE_VC0_TLP_QUEUE_MODE_BYPASS        = 4,
+};
+
+/* VC0 Posted Buffer Depth Register */
+#define PCIE_VC0_PBD(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7A8)
+#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES       0x00003FFF /* VC0 Posted Data Queue Depth */
+#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES_S     0
+#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES        0x03FF0000 /* VC0 Posted Header Queue Depth */
+#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES_S      16
+
+/* VC0 Non-Posted Buffer Depth Register */
+#define PCIE_VC0_NPBD(X)                       (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7AC)
+#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES     0x00003FFF /* VC0 Non-Posted Data Queue Depth */
+#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES_S   0
+#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES      0x03FF0000 /* VC0 Non-Posted Header Queue Depth */
+#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES_S    16
+
+/* VC0 Completion Buffer Depth Register */
+#define PCIE_VC0_CBD(X)                        (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7B0)
+#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES     0x00003FFF /* C0 Completion Data Queue Depth */
+#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES_S   0
+#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES      0x03FF0000 /* VC0 Completion Header Queue Depth */
+#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES_S    16
+
+/* PHY Status Register, all zeros in VR9 */
+#define PCIE_PHYSR(X)                           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x810)
+
+/* PHY Control Register, all zeros in VR9 */
+#define PCIE_PHYCR(X)                           (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x814)
+
+/* 
+ * PCIe PDI PHY register definition, suppose all the following 
+ * stuff is confidential. 
+ * XXX, detailed bit definition
+ */
+#define	PCIE_PHY_PLL_CTRL1(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x22 << 1))
+#define	PCIE_PHY_PLL_CTRL2(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x23 << 1))
+#define	PCIE_PHY_PLL_CTRL3(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x24 << 1))
+#define	PCIE_PHY_PLL_CTRL4(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x25 << 1))
+#define	PCIE_PHY_PLL_CTRL5(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x26 << 1))
+#define	PCIE_PHY_PLL_CTRL6(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x27 << 1))
+#define	PCIE_PHY_PLL_CTRL7(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x28 << 1))
+#define	PCIE_PHY_PLL_A_CTRL1(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x29 << 1))
+#define	PCIE_PHY_PLL_A_CTRL2(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x2A << 1))
+#define	PCIE_PHY_PLL_A_CTRL3(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x2B << 1))
+#define	PCIE_PHY_PLL_STATUS(X)      (PCIE_PHY_PORT_TO_BASE(X) + (0x2C << 1))
+ 
+#define PCIE_PHY_TX1_CTRL1(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x30 << 1))
+#define PCIE_PHY_TX1_CTRL2(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x31 << 1))
+#define PCIE_PHY_TX1_CTRL3(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x32 << 1))
+#define PCIE_PHY_TX1_A_CTRL1(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x33 << 1))
+#define PCIE_PHY_TX1_A_CTRL2(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x34 << 1))
+#define PCIE_PHY_TX1_MOD1(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x35 << 1))
+#define PCIE_PHY_TX1_MOD2(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x36 << 1))
+#define PCIE_PHY_TX1_MOD3(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x37 << 1))
+
+#define PCIE_PHY_TX2_CTRL1(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x38 << 1))
+#define PCIE_PHY_TX2_CTRL2(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x39 << 1))
+#define PCIE_PHY_TX2_A_CTRL1(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x3B << 1))
+#define PCIE_PHY_TX2_A_CTRL2(X)     (PCIE_PHY_PORT_TO_BASE(X) + (0x3C << 1))
+#define PCIE_PHY_TX2_MOD1(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x3D << 1))
+#define PCIE_PHY_TX2_MOD2(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x3E << 1))
+#define PCIE_PHY_TX2_MOD3(X)        (PCIE_PHY_PORT_TO_BASE(X) + (0x3F << 1))
+
+#define PCIE_PHY_RX1_CTRL1(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x50 << 1))
+#define PCIE_PHY_RX1_CTRL2(X)       (PCIE_PHY_PORT_TO_BASE(X) + (0x51 << 1))
+#define PCIE_PHY_RX1_CDR(X)         (PCIE_PHY_PORT_TO_BASE(X) + (0x52 << 1))
+#define PCIE_PHY_RX1_EI(X)          (PCIE_PHY_PORT_TO_BASE(X) + (0x53 << 1))
+#define PCIE_PHY_RX1_A_CTRL(X)      (PCIE_PHY_PORT_TO_BASE(X) + (0x55 << 1))
+
+/* Interrupt related stuff */
+#define PCIE_LEGACY_DISABLE 0
+#define PCIE_LEGACY_INTA  1
+#define PCIE_LEGACY_INTB  2
+#define PCIE_LEGACY_INTC  3
+#define PCIE_LEGACY_INTD  4
+#define PCIE_LEGACY_INT_MAX PCIE_LEGACY_INTD
+
+#define PCIE_IRQ_LOCK(lock) do {             \
+    unsigned long flags;                     \
+    spin_lock_irqsave(&(lock), flags);
+#define PCIE_IRQ_UNLOCK(lock)                \
+    spin_unlock_irqrestore(&(lock), flags);  \
+} while (0)
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
+#define IRQF_SHARED SA_SHIRQ
+#endif
+
+#define PCIE_MSG_MSI        0x00000001
+#define PCIE_MSG_ISR        0x00000002
+#define PCIE_MSG_FIXUP      0x00000004
+#define PCIE_MSG_READ_CFG   0x00000008
+#define PCIE_MSG_WRITE_CFG  0x00000010
+#define PCIE_MSG_CFG        (PCIE_MSG_READ_CFG | PCIE_MSG_WRITE_CFG)
+#define PCIE_MSG_REG        0x00000020
+#define PCIE_MSG_INIT       0x00000040
+#define PCIE_MSG_ERR        0x00000080
+#define PCIE_MSG_PHY        0x00000100
+#define PCIE_MSG_ANY        0x000001ff
+
+#define IFX_PCIE_PORT0      0
+#define IFX_PCIE_PORT1      1
+
+#ifdef CONFIG_IFX_PCIE_2ND_CORE
+#define IFX_PCIE_CORE_NR    2
+#else
+#define IFX_PCIE_CORE_NR    1
+#endif
+
+//#define IFX_PCIE_ERROR_INT
+
+//#define IFX_PCIE_DBG
+
+#if defined(IFX_PCIE_DBG)
+#define IFX_PCIE_PRINT(_m, _fmt, args...) do {   \
+    if (g_pcie_debug_flag & (_m)) {              \
+        ifx_pcie_debug((_fmt), ##args);          \
+    }                                            \
+} while (0)
+
+#define INLINE 
+#else
+#define IFX_PCIE_PRINT(_m, _fmt, args...)   \
+    do {} while(0)
+#define INLINE inline
+#endif
+
+struct ifx_pci_controller {
+	struct pci_controller   pcic;
+    
+	/* RC specific, per host bus information */
+	u32   port;  /* Port index, 0 -- 1st core, 1 -- 2nd core */
+};
+
+typedef struct ifx_pcie_ir_irq {
+    const unsigned int irq;
+    const char name[16];
+}ifx_pcie_ir_irq_t;
+
+typedef struct ifx_pcie_legacy_irq{
+    const u32 irq_bit;
+    const int irq;
+}ifx_pcie_legacy_irq_t;
+
+typedef struct ifx_pcie_irq {
+    ifx_pcie_ir_irq_t ir_irq;
+    ifx_pcie_legacy_irq_t legacy_irq[PCIE_LEGACY_INT_MAX];
+}ifx_pcie_irq_t;
+
+extern u32 g_pcie_debug_flag;
+extern void ifx_pcie_debug(const char *fmt, ...);
+extern void pcie_phy_clock_mode_setup(int pcie_port);
+extern void pcie_msi_pic_init(int pcie_port);
+extern u32 ifx_pcie_bus_enum_read_hack(int where, u32 value);
+extern u32 ifx_pcie_bus_enum_write_hack(int where, u32 value);
+
+
+#include <linux/types.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/clk.h>
+
+#include <lantiq_soc.h>
+
+#define IFX_PCIE_GPIO_RESET  38
+#define IFX_REG_R32	ltq_r32
+#define IFX_REG_W32	ltq_w32
+#define CONFIG_IFX_PCIE_HW_SWAP
+#define IFX_RCU_AHB_ENDIAN                      ((volatile u32*)(IFX_RCU + 0x004C))
+#define IFX_RCU_RST_REQ                         ((volatile u32*)(IFX_RCU + 0x0010))
+#define IFX_RCU_AHB_BE_PCIE_PDI                  0x00000080  /* Configure PCIE PDI module in big endian*/
+
+#define IFX_RCU                                 (KSEG1 | 0x1F203000)
+#define IFX_RCU_AHB_BE_PCIE_M                    0x00000001  /* Configure AHB master port that connects to PCIe RC in big endian */
+#define IFX_RCU_AHB_BE_PCIE_S                    0x00000010  /* Configure AHB slave port that connects to PCIe RC in little endian */
+#define IFX_RCU_AHB_BE_XBAR_M                    0x00000002  /* Configure AHB master port that connects to XBAR in big endian */
+#define CONFIG_IFX_PCIE_PHY_36MHZ_MODE
+
+#define IFX_PMU1_MODULE_PCIE_PHY   (0)
+#define IFX_PMU1_MODULE_PCIE_CTRL  (1)
+#define IFX_PMU1_MODULE_PDI        (4)
+#define IFX_PMU1_MODULE_MSI        (5)
+
+#define IFX_PMU_MODULE_PCIE_L0_CLK (31)
+
+
+static inline void pcie_ep_gpio_rst_init(int pcie_port)
+{
+}
+
+static inline void pcie_ahb_pmu_setup(void)
+{
+	struct clk *clk;
+	clk = clk_get_sys("ltq_pcie", "ahb");
+	clk_enable(clk);
+	//ltq_pmu_enable(PMU_AHBM | PMU_AHBS);
+}
+
+static inline void pcie_rcu_endian_setup(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
+#ifdef CONFIG_IFX_PCIE_HW_SWAP
+    reg |= IFX_RCU_AHB_BE_PCIE_M;
+    reg |= IFX_RCU_AHB_BE_PCIE_S;
+    reg &= ~IFX_RCU_AHB_BE_XBAR_M;
+#else 
+    reg |= IFX_RCU_AHB_BE_PCIE_M;
+    reg &= ~IFX_RCU_AHB_BE_PCIE_S;
+    reg &= ~IFX_RCU_AHB_BE_XBAR_M;
+#endif /* CONFIG_IFX_PCIE_HW_SWAP */
+    IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
+    IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN));
+}
+
+static inline void pcie_phy_pmu_enable(int pcie_port)
+{
+	struct clk *clk;
+	clk = clk_get_sys("ltq_pcie", "phy");
+	clk_enable(clk);
+	//ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PCIE_PHY);
+}
+
+static inline void pcie_phy_pmu_disable(int pcie_port)
+{
+	struct clk *clk;
+	clk = clk_get_sys("ltq_pcie", "phy");
+	clk_disable(clk);
+	//ltq_pmu1_disable(1<<IFX_PMU1_MODULE_PCIE_PHY);
+}
+
+static inline void pcie_pdi_big_endian(int pcie_port)
+{
+    u32 reg;
+
+    /* SRAM2PDI endianness control. */
+    reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN);
+    /* Config AHB->PCIe and PDI endianness */
+    reg |= IFX_RCU_AHB_BE_PCIE_PDI;
+    IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN);
+}
+
+static inline void pcie_pdi_pmu_enable(int pcie_port)
+{
+	struct clk *clk;
+	clk = clk_get_sys("ltq_pcie", "pdi");
+	clk_enable(clk);
+	//ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PDI);
+}
+
+static inline void pcie_core_rst_assert(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+
+    /* Reset PCIe PHY & Core, bit 22, bit 26 may be affected if write it directly  */
+    reg |= 0x00400000;
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_core_rst_deassert(int pcie_port)
+{
+    u32 reg;
+
+    /* Make sure one micro-second delay */
+    udelay(1);
+
+    /* Reset PCIe PHY & Core, bit 22 */
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+    reg &= ~0x00400000;
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_phy_rst_assert(int pcie_port)
+{
+    u32 reg;
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+    reg |= 0x00001000; /* Bit 12 */
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_phy_rst_deassert(int pcie_port)
+{
+    u32 reg;
+
+    /* Make sure one micro-second delay */
+    udelay(1);
+
+    reg = IFX_REG_R32(IFX_RCU_RST_REQ);
+    reg &= ~0x00001000; /* Bit 12 */
+    IFX_REG_W32(reg, IFX_RCU_RST_REQ);
+}
+
+static inline void pcie_device_rst_assert(int pcie_port)
+{
+	gpio_set_value(IFX_PCIE_GPIO_RESET, 0);
+  //  ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
+}
+
+static inline void pcie_device_rst_deassert(int pcie_port)
+{
+    mdelay(100);
+	gpio_set_value(IFX_PCIE_GPIO_RESET, 1);
+//    ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id);
+}
+
+static inline void pcie_core_pmu_setup(int pcie_port)
+{
+	struct clk *clk;
+	clk = clk_get_sys("ltq_pcie", "ctl");
+	clk_enable(clk);
+	clk = clk_get_sys("ltq_pcie", "bus");
+	clk_enable(clk);
+
+	//ltq_pmu1_enable(1 << IFX_PMU1_MODULE_PCIE_CTRL);
+	//ltq_pmu_enable(1 << IFX_PMU_MODULE_PCIE_L0_CLK);
+}
+
+static inline void pcie_msi_init(int pcie_port)
+{
+	struct clk *clk;
+    pcie_msi_pic_init(pcie_port);
+	clk = clk_get_sys("ltq_pcie", "msi");
+	clk_enable(clk);
+	//ltq_pmu1_enable(1 << IFX_PMU1_MODULE_MSI);
+}
+
+static inline u32
+ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port)
+{
+    u32 tbus_number = bus_number;
+
+#ifdef CONFIG_PCI_LANTIQ
+    if (pcibios_host_nr() > 1) {
+        tbus_number -= pcibios_1st_host_bus_nr();
+    }
+#endif /* CONFIG_PCI_LANTIQ */
+    return tbus_number;
+}
+
+static inline u32
+ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read)
+{
+    struct pci_dev *pdev;
+    u32 tvalue = value;
+
+    /* Sanity check */
+    pdev = pci_get_slot(bus, devfn);
+    if (pdev == NULL) {
+        return tvalue;
+    }
+
+    /* Only care about PCI bridge */
+    if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
+        return tvalue;
+    }
+
+    if (read) { /* Read hack */
+    #ifdef CONFIG_PCI_LANTIQ
+        if (pcibios_host_nr() > 1) {
+            tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue);
+        }
+    #endif /* CONFIG_PCI_LANTIQ */
+    }
+    else { /* Write hack */
+    #ifdef CONFIG_PCI_LANTIQ
+        if (pcibios_host_nr() > 1) {
+            tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue);
+        }
+    #endif
+    }
+    return tvalue;
+}
+
+#endif /* IFXMIPS_PCIE_VR9_H */
+
--- a/drivers/pci/pcie/aer/Kconfig
+++ b/drivers/pci/pcie/aer/Kconfig
@@ -19,6 +19,7 @@ config PCIEAER
 config PCIE_ECRC
 	bool "PCI Express ECRC settings control"
 	depends on PCIEAER
+	default n
 	help
 	  Used to override firmware/bios settings for PCI Express ECRC
 	  (transaction layer end-to-end CRC checking).
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1179,6 +1179,8 @@ void pci_walk_bus(struct pci_bus *top, i
 		  void *userdata);
 int pci_cfg_space_size(struct pci_dev *dev);
 unsigned char pci_bus_max_busnr(struct pci_bus *bus);
+int pcibios_host_nr(void);
+int pcibios_1st_host_bus_nr(void);
 void pci_setup_bridge(struct pci_bus *bus);
 resource_size_t pcibios_window_alignment(struct pci_bus *bus,
 					 unsigned long type);
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1053,6 +1053,12 @@
 #define PCI_DEVICE_ID_SGI_LITHIUM	0x1002
 #define PCI_DEVICE_ID_SGI_IOC4		0x100a
 
+#define PCI_VENDOR_ID_INFINEON		0x15D1
+#define PCI_DEVICE_ID_INFINEON_DANUBE	0x000F
+#define PCI_DEVICE_ID_INFINEON_PCIE	0x0011
+#define PCI_VENDOR_ID_LANTIQ		0x1BEF
+#define PCI_DEVICE_ID_LANTIQ_PCIE	0x00
+
 #define PCI_VENDOR_ID_WINBOND		0x10ad
 #define PCI_DEVICE_ID_WINBOND_82C105	0x0105
 #define PCI_DEVICE_ID_WINBOND_83C553	0x0565