summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/linux/linux-netbook-2.6.33.2/linux-2.6.34-moorestown-langwell-dma-driver-3.0.patch
blob: d539b6092002e54404f7af2507410b4c17471b24 (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
Index: linux-2.6.33/drivers/dma/Kconfig
===================================================================
--- linux-2.6.33.orig/drivers/dma/Kconfig
+++ linux-2.6.33/drivers/dma/Kconfig
@@ -20,6 +20,37 @@ comment "DMA Devices"
 config ASYNC_TX_DISABLE_CHANNEL_SWITCH
 	bool
 
+config INTEL_LNW_DMAC1
+	bool "Intel MID DMA support for LPE DMA"
+	depends on PCI && X86 && (SND_INTEL_SST||SND_INTEL_LPE)
+	select DMA_ENGINE
+	help
+	  Enable support for the Intel(R) MID DMA1 engine present
+	  in Intel MID chipsets.
+
+	  Say Y here if you have such a chipset.
+
+	  If unsure, say N.
+
+config INTEL_LNW_DMAC2
+	bool "Intel MID DMA support for SC DMA"
+	depends on PCI && X86
+	select DMA_ENGINE
+	help
+	  Enable support for the Intel(R) MID DMA2 engine present
+	  in Intel MID chipsets.
+
+	  Say Y here if you have such a chipset.
+
+	  If unsure, say N.
+
+config LNW_DMA_DEBUG
+	bool "LNW DMA Debugging Enable"
+	depends on INTEL_LNW_DMAC1 || INTEL_LNW_DMAC2
+	default N
+	help
+	  Enable logging in the LNW DMA drivers
+
 config INTEL_IOATDMA
 	tristate "Intel I/OAT DMA support"
 	depends on PCI && X86
Index: linux-2.6.33/drivers/dma/Makefile
===================================================================
--- linux-2.6.33.orig/drivers/dma/Makefile
+++ linux-2.6.33/drivers/dma/Makefile
@@ -1,5 +1,7 @@
 obj-$(CONFIG_DMA_ENGINE) += dmaengine.o
 obj-$(CONFIG_NET_DMA) += iovlock.o
+obj-$(CONFIG_INTEL_LNW_DMAC2) += lnw_dmac2.o
+obj-$(CONFIG_INTEL_LNW_DMAC1) += lnw_dmac1.o
 obj-$(CONFIG_DMATEST) += dmatest.o
 obj-$(CONFIG_INTEL_IOATDMA) += ioat/
 obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
Index: linux-2.6.33/drivers/dma/lnw_dma_regs.h
===================================================================
--- /dev/null
+++ linux-2.6.33/drivers/dma/lnw_dma_regs.h
@@ -0,0 +1,176 @@
+/*
+ *  lnw_dma.c - Intel Langwell DMA Drivers
+ *
+ *  Copyright (C) 2008-09 Intel Corp
+ *  Author: Vinod Koul <vinod.koul@intel.com>
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *
+ */
+#ifndef __LNW_DMA_REGS_H__
+#define __LNW_DMA_REGS_H__
+
+#include <linux/dmaengine.h>
+#include <linux/dmapool.h>
+#include <linux/pci_ids.h>
+
+#define LNW_DMA_DRIVER_VERSION "0.3.1"
+
+#define DMA_DEBUG
+
+#define	REG_BIT0 		0x00000001
+#define	REG_BIT8 		0x00000100
+
+#define UNMASK_INTR_REG(chan_num) \
+	((REG_BIT0 << chan_num) | (REG_BIT8 << chan_num))
+#define MASK_INTR_REG(chan_num) (REG_BIT8 << chan_num)
+
+#define ENABLE_CHANNEL(chan_num) \
+	((REG_BIT0 << chan_num) | (REG_BIT8 << chan_num))
+
+#define DESCS_PER_CHANNEL 	16
+/*DMA Registers*/
+/*registers associated with channel programming*/
+#define DMA_REG_SIZE 		0x400
+#define DMA_CH_SIZE		0x58
+
+/*CH X REG = (DMA_CH_SIZE)*CH_NO + REG*/
+#define SAR			0x00 /* Source Address Register*/
+#define DAR			0x08 /* Destination Address Register*/
+#define CTL_LOW  		0x18 /* Control Register*/
+#define CTL_HIGH		0x1C /* Control Register*/
+#define CFG_LOW 		0x40 /* Configuration Register Low*/
+#define CFG_HIGH		0x44 /* Configuration Register high*/
+
+#define STATUS_TFR		0x2E8
+#define STATUS_BLOCK 		0x2F0
+#define STATUS_ERR		0x308
+
+#define RAW_TFR 		0x2C0
+#define RAW_BLOCK		0x2C8
+#define RAW_ERR   		0x2E0
+
+#define MASK_TFR		0x310
+#define MASK_BLOCK		0x318
+#define MASK_SRC_TRAN  		0x320
+#define MASK_DST_TRAN  		0x328
+#define MASK_ERR		0x330
+
+#define CLEAR_TFR		0x338
+#define CLEAR_BLOCK		0x340
+#define CLEAR_SRC_TRAN  	0x348
+#define CLEAR_DST_TRAN  	0x350
+#define CLEAR_ERR		0x358
+
+#define INTR_STATUS		0x360
+#define DMA_CFG    		0x398
+#define DMA_CHAN_EN		0x3A0
+
+/**
+ * struct lnw_dma_chan - internal representation of a DMA channel
+ */
+struct lnw_dma_chan {
+	struct dma_chan  	chan;
+	void __iomem		*ch_regs;
+	void __iomem		*dma_base;
+	int			ch_id;
+	spinlock_t		lock;
+	dma_cookie_t		completed;
+	struct list_head	active_list;
+	struct list_head	queue;
+	struct list_head	free_list;
+	struct lnw_dma_slave	*slave;
+	unsigned int		descs_allocated;
+	struct lnwdma_device	*dma;
+	bool			in_use;
+};
+static inline struct lnw_dma_chan *to_lnw_dma_chan(struct dma_chan *chan)
+{
+	return container_of(chan, struct lnw_dma_chan, chan);
+}
+
+/**
+ * struct lnwdma_device - internal representation of a DMA device
+ * @pdev: PCI device
+ * @dma_base: MMIO register space base address of DMA
+ * @lpe_base: MMIO register space base address of LPE
+ * @dma_pool: for allocating DMA descriptors
+ * @common: embedded struct dma_device
+ * @idx: per channel data
+ */
+struct lnwdma_device {
+	struct pci_dev  	*pdev;
+	void __iomem		*dma_base;
+	struct pci_pool 	*dma_pool;
+	struct dma_device 	common;
+	struct tasklet_struct   tasklet;
+	struct lnw_dma_chan 	ch[MAX_CHAN];
+};
+
+static inline struct lnwdma_device *to_lnwdma_device(struct dma_device *common)
+{
+	return container_of(common, struct lnwdma_device, common);
+}
+
+struct lnw_dma_desc {
+	void __iomem			*block; /*ch ptr*/
+	struct list_head		desc_node;
+	struct dma_async_tx_descriptor	txd;
+	size_t				len;
+	dma_addr_t			sar;
+	dma_addr_t			dar;
+	u32				cfg_hi;
+	u32				cfg_lo;
+	u32				ctl_lo;
+	u32				ctl_hi;
+	dma_addr_t			next;
+	enum dma_data_direction  	dirn;
+	enum dma_status  		status;
+	dma_async_tx_callback   	callback;
+	void 				*callback_param;
+	enum lnw_dma_width		width; /*width of DMA txn*/
+	enum lnw_dma_mode		cfg_mode; /*mode configuration*/
+
+};
+
+static inline int test_ch_en(void __iomem *dma, u32 ch_no)
+{
+	u32 en_reg = ioread32(dma + DMA_CHAN_EN);
+	return (en_reg >> ch_no) & 0x1;
+}
+
+static inline struct lnw_dma_desc *to_lnw_dma_desc
+		(struct dma_async_tx_descriptor *txd)
+{
+	return container_of(txd, struct lnw_dma_desc, txd);
+}
+
+#define _dma_printk(level, format, arg...)  \
+	printk(level "LNW_DMA: %s %d " format, __func__, __LINE__, ## arg)
+
+#ifdef CONFIG_LNW_DMA_DEBUG
+#define dma_dbg(format, arg...) _dma_printk(KERN_DEBUG, "DBG " format , ## arg)
+#else
+#define dma_dbg(format, arg...) do {} while (0);
+#endif
+
+#define dma_err(format, arg...) _dma_printk(KERN_ERR, "ERR " format , ## arg)
+#define dma_info(format, arg...) \
+	_dma_printk(KERN_INFO , "INFO " format , ## arg)
+
+#endif /*__LNW_DMA_REGS_H__*/
Index: linux-2.6.33/drivers/dma/lnw_dmac1.c
===================================================================
--- /dev/null
+++ linux-2.6.33/drivers/dma/lnw_dmac1.c
@@ -0,0 +1,957 @@
+/*
+ *  lnw_dmac1.c - Intel Langwell DMA Drivers
+ *
+ *  Copyright (C) 2008-09 Intel Corp
+ *  Authhor: Vinod Koul <vinod.koul@intel.com>
+ *  The driver design is based on dw_dmac driver
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  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; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <sound/intel_lpe.h>
+#include <linux/lnw_dma.h>
+
+#define MAX_CHAN 	2
+#include "lnw_dma_regs.h"
+
+MODULE_AUTHOR("Vinod Koul <vinod.koul@intel.com>");
+MODULE_DESCRIPTION("Intel (R) Moorestown Langwell DMAC1 Driver");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(LNW_DMA_DRIVER_VERSION);
+
+#define DMA_CH0		6
+#define DMA_CH1		7
+#define CH_BLOCK_SIZE	4095
+
+static int __devinit lnw_dma1_probe(struct pci_dev *pdev,
+				const struct pci_device_id *id);
+static void __devexit lnw_dma1_remove(struct pci_dev *pdev);
+static void enable_dma1_interrupt(struct lnw_dma_chan *lnwc);
+static void disable_dma1_interrupt(struct lnw_dma_chan *lnwc);
+
+struct lnw_device {
+	struct pci_dev		*pdev;
+	void __iomem		*dma_base;
+	struct lnwdma_device	*dma;
+};
+
+/*CH dep code, if ch no's mapping changes only change here*/
+static int get_ch_id(int index)
+{
+	if (index == 0)
+		return DMA_CH0;
+	else if (index == 1)
+		return DMA_CH1;
+	else
+		return -1;
+}
+
+static int get_ch_index(int ch_id)
+{
+	if (ch_id == DMA_CH0)
+		return 0;
+	if (ch_id == DMA_CH1)
+		return 1;
+	else
+		return -1;
+}
+
+static int get_ch_num(int *status)
+{
+	if (*status & (1 << DMA_CH0)) {
+		*status = *status & (~(1 << DMA_CH0));
+		return DMA_CH0;
+	} else if (*status & (1 << DMA_CH1)) {
+		*status = *status & (~(1 << DMA_CH1));
+		return DMA_CH1;
+	} else
+		return -1;
+}
+
+static int get_block_ts(int len, int tx_width)
+{
+	int byte_width = 0, block_ts = 0;
+
+	switch (tx_width) {
+	case LNW_DMA_WIDTH_8BIT:
+		byte_width = 1;
+		break;
+	case LNW_DMA_WIDTH_16BIT:
+		byte_width = 2;
+		break;
+	case LNW_DMA_WIDTH_32BIT:
+	default:
+		byte_width = 4;
+		break;
+	}
+
+	block_ts = len/byte_width;
+	if (block_ts > CH_BLOCK_SIZE)
+		block_ts = 0xFFFF;
+	return block_ts;
+}
+
+static struct lnw_dma_desc *lnwc_desc_get1(struct lnw_dma_chan *lnwc)
+{
+	struct lnw_dma_desc *desc, *_desc;
+	struct lnw_dma_desc *ret = NULL;
+
+	dma_dbg("called \n");
+	spin_lock_bh(&lnwc->lock);
+	list_for_each_entry_safe(desc, _desc, &lnwc->free_list, desc_node) {
+		if (async_tx_test_ack(&desc->txd)) {
+			list_del(&desc->desc_node);
+			ret = desc;
+			dma_dbg("got free desc \n");
+			break;
+		}
+	}
+	spin_unlock_bh(&lnwc->lock);
+	return ret;
+}
+
+
+static void lnwc_desc_put1(struct lnw_dma_chan *lnwc, struct lnw_dma_desc *desc)
+{
+	if (desc) {
+		spin_lock_bh(&lnwc->lock);
+		list_add_tail(&desc->desc_node, &lnwc->free_list);
+		spin_unlock_bh(&lnwc->lock);
+	}
+}
+
+/* Called with dwc->lock held and bh disabled */
+static void lnwc_dostart1(struct lnw_dma_chan *lnwc, struct lnw_dma_desc *first)
+{
+	struct lnwdma_device *lnw = to_lnwdma_device(lnwc->chan.device);
+
+	dma_dbg("called \n");
+	/* ASSERT:  channel is idle */
+	if (lnwc->in_use && test_ch_en(lnwc->dma_base, lnwc->ch_id)) {
+		/*error*/
+		dma_err("channel is busy \n");
+		/* The tasklet will hopefully advance the queue... */
+		return;
+	}
+
+	/*write registers and en*/
+	iowrite32(first->sar, lnwc->ch_regs + SAR);
+	iowrite32(first->dar, lnwc->ch_regs + DAR);
+	iowrite32(first->cfg_hi, lnwc->ch_regs + CFG_HIGH);
+	iowrite32(first->cfg_lo, lnwc->ch_regs + CFG_LOW);
+	iowrite32(first->ctl_lo, lnwc->ch_regs + CTL_LOW);
+	iowrite32(first->ctl_hi, lnwc->ch_regs + CTL_HIGH);
+	dma_dbg("TX SAR %lx, DAR %lx, CFGL %x, CFGH %x, CTLH %x, CTLL %x \n",
+		first->sar, first->dar, first->cfg_hi,
+		first->cfg_lo, first->ctl_hi, first->ctl_lo);
+
+	iowrite32(ENABLE_CHANNEL(lnwc->ch_id), lnw->dma_base + DMA_CHAN_EN);
+	first->status = DMA_IN_PROGRESS;
+}
+
+static void
+lnwc_descriptor_complete1(struct lnw_dma_chan *lnwc, struct lnw_dma_desc *desc)
+{
+	struct dma_async_tx_descriptor	*txd = &desc->txd;
+	dma_async_tx_callback callback = NULL;
+	dma_async_tx_callback callback_txd = NULL;
+	void *param = NULL;
+	void *param_txd = NULL;
+	u32 sar, dar, len;
+	union lnw_dma_ctl_hi ctl_hi;
+
+	dma_dbg("called \n");
+
+	/*check if full tx is complete or not*/
+	sar = ioread32(lnwc->ch_regs + SAR);
+	dar = ioread32(lnwc->ch_regs + DAR);
+
+	if (desc->dirn == DMA_FROM_DEVICE)
+		len = dar - desc->dar;
+	else
+		len = sar - desc->sar;
+
+	dma_dbg("SAR %x DAR %x, DMA done: %x \n", sar, dar, len);
+	if (desc->len > len) {
+		dma_dbg("dirn = %d\n", desc->dirn);
+		dma_dbg("SAR %x DAR %x, len: %x \n", sar, dar, len);
+		/*we have to copy more bytes*/
+		desc->len -= len;
+		ctl_hi.ctl_hi = desc->ctl_hi;
+		ctl_hi.ctlx.block_ts = get_block_ts(desc->len, desc->width);
+		dma_dbg("setting for %x bytes \n", ctl_hi.ctlx.block_ts);
+		desc->ctl_hi = ctl_hi.ctl_hi;
+		if (desc->cfg_mode == LNW_DMA_MEM_TO_MEM) {
+			sar++;
+			dar++;
+		} else if (desc->dirn == DMA_TO_DEVICE)
+			sar++;
+		else if (desc->dirn == DMA_FROM_DEVICE)
+			dar++;
+		desc->sar = sar;
+		desc->dar = dar;
+		dma_dbg("New SAR %x DAR %x \n", sar, dar);
+		lnwc_dostart1(lnwc, desc);
+		return;
+	}
+
+	lnwc->completed = txd->cookie;
+	callback = desc->callback;
+	param = desc->callback_param;
+	callback_txd = txd->callback;
+	param_txd = txd->callback_param;
+
+	list_move(&desc->desc_node, &lnwc->free_list);
+
+	spin_unlock_bh(&lnwc->lock);
+	dma_dbg("Now we are calling callback \n");
+	if (callback_txd) {
+		dma_dbg("lnw TXD callback set ... calling \n");
+		callback_txd(param_txd);
+		spin_lock_bh(&lnwc->lock);
+		return;
+	}
+	if (callback) {
+		dma_dbg("lnw callback set ... calling \n");
+		callback(param);
+	}
+	spin_lock_bh(&lnwc->lock);
+}
+
+/*check desc, mark as complete when tx is complete*/
+static void
+lnwc_scan_descriptors1(struct lnwdma_device *lnw, struct lnw_dma_chan *lnwc)
+{
+	struct lnw_dma_desc *desc = NULL, *_desc = NULL;
+	u32 status_xfer;
+
+	dma_dbg("called \n");
+	status_xfer = ioread32(lnwc->dma_base + RAW_BLOCK);
+	status_xfer = (status_xfer >> lnwc->ch_id) & 0x1;
+	dma_dbg("ch[%d]:  status_xfer %x \n", lnwc->ch_id, status_xfer);
+	if (!status_xfer)
+		return;
+
+	list_for_each_entry_safe(desc, _desc, &lnwc->active_list, desc_node) {
+		if (desc == NULL)
+			continue;
+		if (desc->status == DMA_IN_PROGRESS)  {
+			desc->status = DMA_SUCCESS;
+			lnwc_descriptor_complete1(lnwc, desc);
+		}
+	}
+	return;
+}
+
+/*****************************************************************************
+DMA Functions*/
+static dma_cookie_t lnw_dma1_tx_submit(struct dma_async_tx_descriptor *tx)
+{
+	struct lnw_dma_desc	*desc = to_lnw_dma_desc(tx);
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(tx->chan);
+	dma_cookie_t		cookie;
+
+	dma_dbg("called \n");
+	spin_lock_bh(&lnwc->lock);
+	cookie = lnwc->chan.cookie;
+
+	if (++cookie < 0)
+		cookie = 1;
+
+	lnwc->chan.cookie = cookie;
+	desc->txd.cookie = cookie;
+
+
+	if (list_empty(&lnwc->active_list)) {
+		lnwc_dostart1(lnwc, desc);
+		list_add_tail(&desc->desc_node, &lnwc->active_list);
+	} else {
+		list_add_tail(&desc->desc_node, &lnwc->queue);
+	}
+	spin_unlock_bh(&lnwc->lock);
+
+	return cookie;
+}
+
+static void lnw_dma1_issue_pending(struct dma_chan *chan)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+
+	spin_lock_bh(&lnwc->lock);
+	if (!list_empty(&lnwc->queue))
+		lnwc_scan_descriptors1(to_lnwdma_device(chan->device), lnwc);
+	spin_unlock_bh(&lnwc->lock);
+}
+
+static enum dma_status
+lnw_dma1_tx_is_complete(struct dma_chan *chan,
+		dma_cookie_t cookie,
+		dma_cookie_t *done,
+		dma_cookie_t *used)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+	dma_cookie_t		last_used;
+	dma_cookie_t		last_complete;
+	int				ret;
+
+	last_complete = lnwc->completed;
+	last_used = chan->cookie;
+
+	ret = dma_async_is_complete(cookie, last_complete, last_used);
+	if (ret != DMA_SUCCESS) {
+		lnwc_scan_descriptors1(to_lnwdma_device(chan->device), lnwc);
+
+		last_complete = lnwc->completed;
+		last_used = chan->cookie;
+
+		ret = dma_async_is_complete(cookie, last_complete, last_used);
+	}
+
+	if (done)
+		*done = last_complete;
+	if (used)
+		*used = last_used;
+
+	return ret;
+}
+
+static void lnw_dma1_terminate_all(struct dma_chan *chan)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+	struct lnwdma_device	*lnw = to_lnwdma_device(chan->device);
+	struct lnw_dma_desc	*desc, *_desc;
+	LIST_HEAD(list);
+
+	/* ASSERT:  channel is idle */
+	if (lnwc->in_use == false) {
+		/*ch is not in use, wrong call*/
+		return;
+	}
+	spin_lock_bh(&lnwc->lock);
+	list_splice_init(&lnwc->free_list, &list);
+	lnwc->descs_allocated = 0;
+	lnwc->slave = NULL;
+
+	/* Disable interrupts */
+	disable_dma1_interrupt(lnwc);
+
+	spin_unlock_bh(&lnwc->lock);
+	list_for_each_entry_safe(desc, _desc, &list, desc_node) {
+		dma_dbg("freeing descriptor %p\n", desc);
+		pci_pool_free(lnw->dma_pool, desc, desc->txd.phys);
+	}
+	return;
+}
+
+static struct dma_async_tx_descriptor *
+lnw_dma1_prep_slave_sg(struct dma_chan *chan,
+		struct scatterlist *sgl, unsigned int sg_len,
+		enum dma_data_direction direction,
+		unsigned long flags)
+{
+	/*not supported now*/
+	return NULL;
+}
+
+static struct dma_async_tx_descriptor *
+lnw_dma1_prep_memcpy(struct dma_chan *chan, dma_addr_t dest,
+		dma_addr_t src, size_t len, unsigned long flags)
+{
+	struct lnw_dma_chan *lnwc;
+	struct lnw_dma_desc *desc = NULL;
+	struct lnw_dma_slave *lnws;
+	union lnw_dma_ctl_lo ctl_lo;
+	union lnw_dma_ctl_hi ctl_hi;
+	union lnw_dma_cfg_lo cfg_lo;
+	union lnw_dma_cfg_hi cfg_hi;
+	enum lnw_dma_width width = 0;
+
+	dma_dbg("called \n");
+	WARN_ON(!chan);
+	if (!len)
+		return NULL;
+
+	lnws = chan->private;
+	WARN_ON(!lnws);
+
+	lnwc = to_lnw_dma_chan(chan);
+	WARN_ON(!lnwc);
+
+	dma_dbg("called for CH %d\n", lnwc->ch_id);
+	dma_dbg("Cfg passed Mode %x, Dirn %x, HS %x, Width %x \n",
+		lnws->cfg_mode, lnws->dirn, lnws->hs_mode, lnws->src_width);
+
+	/*calculate CFG_LO*/
+	if (lnws->hs_mode == LNW_DMA_SW_HS) {
+		cfg_lo.cfg_lo = 0;
+		cfg_lo.cfgx.hs_sel_dst = 1;
+		cfg_lo.cfgx.hs_sel_src = 1;
+	} else if (lnws->hs_mode == LNW_DMA_HW_HS)
+		cfg_lo.cfg_lo = 0x00000;
+
+	/*calculate CFG_HI*/
+	if (lnws->cfg_mode == LNW_DMA_MEM_TO_MEM) {
+		/*SW HS only*/
+		dma_dbg("CFG: Mem to mem dma \n");
+		cfg_hi.cfg_hi = 0;
+	} else {
+		dma_dbg("HW DMA \n");
+		cfg_hi.cfg_hi = 0;
+		cfg_hi.cfgx.protctl = 0x0; /*default value*/
+		cfg_hi.cfgx.fifo_mode = 1;
+		if (lnws->dirn == DMA_TO_DEVICE) {
+			cfg_hi.cfgx.src_per = 0;
+			cfg_hi.cfgx.dst_per = 3;
+		} else if (lnws->dirn == DMA_FROM_DEVICE) {
+			cfg_hi.cfgx.src_per = 2;
+			cfg_hi.cfgx.dst_per = 0;
+		}
+	}
+
+	/*calculate CTL_HI*/
+	ctl_hi.ctlx.reser = 0;
+	width = lnws->src_width;
+
+	ctl_hi.ctlx.block_ts = get_block_ts(len, width);
+
+	/*calculate CTL_LO*/
+	ctl_lo.ctl_lo = 0;
+	ctl_lo.ctlx.int_en = 1;
+	ctl_lo.ctlx.dst_tr_width = lnws->dst_width;
+	ctl_lo.ctlx.src_tr_width = lnws->src_width;
+	ctl_lo.ctlx.dst_msize = lnws->src_msize;
+	ctl_lo.ctlx.src_msize = lnws->dst_msize;
+
+	if (lnws->cfg_mode == LNW_DMA_MEM_TO_MEM) {
+		dma_dbg("CTL: Mem to mem dma \n");
+		ctl_lo.ctlx.tt_fc = 0;
+		ctl_lo.ctlx.sinc = 0;
+		ctl_lo.ctlx.dinc = 0;
+	} else {
+		if (lnws->dirn == DMA_TO_DEVICE) {
+			dma_dbg("CTL: DMA_TO_DEVICE \n");
+			ctl_lo.ctlx.sinc = 0;
+			ctl_lo.ctlx.dinc = 2;
+			ctl_lo.ctlx.tt_fc = 1;
+		} else if (lnws->dirn == DMA_FROM_DEVICE) {
+			dma_dbg("CTL: DMA_FROM_DEVICE \n");
+			ctl_lo.ctlx.sinc = 2;
+			ctl_lo.ctlx.dinc = 0;
+			ctl_lo.ctlx.tt_fc = 2;
+		}
+	}
+
+	dma_dbg("Calc CTL LO %x, CTL HI %x, CFG LO %x, CFG HI %x\n",
+		ctl_lo.ctl_lo, ctl_hi.ctl_hi, cfg_lo.cfg_lo, cfg_hi.cfg_hi);
+
+	enable_dma1_interrupt(lnwc);
+
+	desc = lnwc_desc_get1(lnwc);
+	if (desc == NULL)
+		goto err_desc_get;
+	desc->sar = src;
+	desc->dar = dest ;
+	desc->len = len;
+	desc->cfg_hi = cfg_hi.cfg_hi;
+	desc->cfg_lo = cfg_lo.cfg_lo;
+	desc->ctl_lo = ctl_lo.ctl_lo;
+	desc->ctl_hi = ctl_hi.ctl_hi;
+	desc->width = width;
+	desc->dirn = lnws->dirn;
+	if (lnws->callback) {
+		desc->callback = lnws->callback;
+		desc->callback_param = lnws->callback_param;
+		dma_dbg("Callback passed... setting\n");
+	} else
+		desc->callback = NULL;
+	return &desc->txd;
+
+err_desc_get:
+	dma_err("Failed to get desc \n");
+	lnwc_desc_put1(lnwc, desc);
+	return NULL;
+}
+
+static void lnw_dma1_free_chan_resources(struct dma_chan *chan)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+	struct lnwdma_device	*lnw = to_lnwdma_device(chan->device);
+	struct lnw_dma_desc	*desc, *_desc;
+
+	dma_dbg("..called for ch_id %d, lnwch_id %d\n",
+			chan->chan_id, lnwc->ch_id);
+	if (true == lnwc->in_use) {
+		/*trying to free ch in use!!!!!*/
+		dma_err("trying to free ch in use \n");
+	}
+
+	spin_lock_bh(&lnwc->lock);
+	lnwc->descs_allocated = 0;
+	list_for_each_entry_safe(desc, _desc, &lnwc->active_list, desc_node) {
+		dma_dbg("del active \n");
+		list_del(&desc->desc_node);
+		pci_pool_free(lnw->dma_pool, desc, desc->txd.phys);
+	}
+	list_for_each_entry_safe(desc, _desc, &lnwc->free_list, desc_node) {
+		list_del(&desc->desc_node);
+		pci_pool_free(lnw->dma_pool, desc, desc->txd.phys);
+	}
+	list_for_each_entry_safe(desc, _desc, &lnwc->queue, desc_node) {
+		dma_dbg("del queue \n");
+		list_del(&desc->desc_node);
+		pci_pool_free(lnw->dma_pool, desc, desc->txd.phys);
+	}
+	spin_unlock_bh(&lnwc->lock);
+	lnwc->in_use = false;
+	chan->client_count--;
+	/* Disable CH interrupts */
+	iowrite32(MASK_INTR_REG(lnwc->ch_id), lnw->dma_base + MASK_BLOCK);
+	iowrite32(MASK_INTR_REG(lnwc->ch_id), lnw->dma_base + MASK_ERR);
+	dma_dbg("done \n");
+}
+
+static int lnw_dma1_alloc_chan_resources(struct dma_chan *chan)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+	struct lnwdma_device	*lnw = to_lnwdma_device(chan->device);
+	struct lnw_dma_desc	*desc;
+	dma_addr_t		phys;
+	int	i = 0;
+
+	dma_dbg("called \n");
+
+	/* ASSERT:  channel is idle */
+	if (test_ch_en(lnw->dma_base, lnwc->ch_id)) {
+		/*ch is not idle*/
+		dma_err(".ch not idle\n");
+		return -EIO;
+	}
+	dma_dbg("..called for ch_id %d, lnwch_id %d\n",
+			chan->chan_id, lnwc->ch_id);
+	lnwc->completed = chan->cookie = 1;
+
+	chan->client_count++;
+
+	spin_lock_bh(&lnwc->lock);
+	while (lnwc->descs_allocated < DESCS_PER_CHANNEL) {
+		spin_unlock_bh(&lnwc->lock);
+		desc = pci_pool_alloc(lnw->dma_pool, GFP_KERNEL, &phys);
+		if (!desc) {
+			dma_err("desc failed\n");
+			return -ENOMEM;
+			/*check*/
+		}
+		dma_async_tx_descriptor_init(&desc->txd, chan);
+		desc->txd.tx_submit = lnw_dma1_tx_submit;
+		desc->txd.flags = DMA_CTRL_ACK;
+		desc->txd.phys = phys;
+		spin_lock_bh(&lnwc->lock);
+		i = ++lnwc->descs_allocated;
+		list_add_tail(&desc->desc_node, &lnwc->free_list);
+	}
+	spin_unlock_bh(&lnwc->lock);
+	lnwc->in_use = false;
+	dma_dbg("Desc alloc done ret: %d desc\n", i);
+	return i;
+}
+
+static void lnwc_handle_error1(struct lnwdma_device *lnw,
+		struct lnw_dma_chan *lnwc)
+{
+	lnwc_scan_descriptors1(lnw, lnwc);
+}
+
+/******************************************************************************
+* PCI stuff
+*/
+static struct pci_device_id lnw_dma1_ids[] = {
+	{ PCI_VENDOR_ID_INTEL, 0x0814, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, lnw_dma1_ids);
+
+static struct pci_driver lnw_dma1_pci = {
+	.name 		=	"Intel LNW DMA1",
+	.id_table 	=	lnw_dma1_ids,
+	.probe 		=	lnw_dma1_probe,
+	.remove 	=	__devexit_p(lnw_dma1_remove),
+};
+
+static void dma_tasklet1(unsigned long data)
+{
+	struct lnwdma_device *lnw = NULL;
+	struct lnw_dma_chan *lnwc = NULL;
+	u32 status;
+	int i, ch_no;
+
+	dma_dbg("called \n");
+	lnw = (struct lnwdma_device *)data;
+	if (lnw == NULL) {
+		dma_err("Null param \n");
+		return;
+	}
+	status = ioread32(lnw->dma_base + RAW_BLOCK);
+	dma_dbg("RAW_TFR %x \n", status);
+	status &= 0xC0;
+	while (status) {
+		/*txn interrupt*/
+		ch_no = get_ch_num(&status);
+		if (ch_no < 0) {
+			dma_err("Ch no is invalid %x, abort!\n", ch_no);
+			return;
+		}
+		dma_dbg("Got Ch %x, new Status %x \n", ch_no, status);
+		i = get_ch_index(ch_no);
+		if (i < 0) {
+			dma_err("Invalid ch index %x\n", i);
+			return;
+		}
+		dma_dbg("Tx complete interrupt %x, Ch No %d Index %d \n",
+				status, ch_no, i);
+		lnwc = &lnw->ch[i];
+		if (lnwc == NULL) {
+			dma_err("Null param lnwc\n");
+			return;
+		}
+		dma_dbg("CH %x \n", lnwc->ch_id);
+		spin_lock_bh(&lnwc->lock);
+		lnwc_scan_descriptors1(lnw, lnwc);
+		dma_dbg("Scan of desc... complete, unmasking\n");
+		iowrite32((1 << lnwc->ch_id),
+				lnw->dma_base + CLEAR_TFR);
+		dma_dbg("Wrote to clear %x\n", (1 << lnwc->ch_id));
+		iowrite32((1 << lnwc->ch_id),
+				lnw->dma_base + CLEAR_BLOCK);
+		iowrite32(UNMASK_INTR_REG(lnwc->ch_id),
+				lnw->dma_base + MASK_TFR);
+		spin_unlock_bh(&lnwc->lock);
+	}
+
+	dma_dbg("Trf interrupt done... \n");
+	status = ioread32(lnw->dma_base + RAW_ERR);
+	status &= 0xC0;
+	while (status) {
+		/*err interrupt*/
+		ch_no = get_ch_num(&status);
+		if (ch_no < 0) {
+			dma_err("Ch no is invalid %x, abort!\n", ch_no);
+			return;
+		}
+		dma_dbg("Got Ch %x, new Status %x \n", ch_no, status);
+		i = get_ch_index(ch_no);
+		if (i < 0) {
+			dma_err("Invalid CH lnwc\n");
+			return;
+		}
+		dma_dbg("Tx error interrupt %x, No %d Index %d \n",
+				status, ch_no, i);
+		lnwc = &lnw->ch[i];
+		if (lnwc == NULL) {
+			dma_err("Null param lnwc\n");
+			return;
+		}
+		spin_lock_bh(&lnwc->lock);
+		lnwc_handle_error1(lnw, lnwc);
+		iowrite32((1 << lnwc->ch_id),
+				lnw->dma_base + CLEAR_ERR);
+		iowrite32(UNMASK_INTR_REG(lnwc->ch_id),
+				lnw->dma_base + MASK_ERR);
+		spin_unlock_bh(&lnwc->lock);
+	}
+	dma_dbg("Exiting takslet... \n");
+	return;
+}
+
+static irqreturn_t lnw_dma1_interrupt(int irq, void *data)
+{
+	struct lnw_device *lnw = data;
+	u32 status;
+	int call_tasklet = 0;
+
+	/*check interrupt src*/
+	lpe_periphral_intr_status(LPE_DMA, &status);
+	if (!status) {
+		/*not our interrupt*/
+		return IRQ_NONE;
+	}
+
+	/*DMA Interrupt*/
+	status = ioread32(lnw->dma_base + RAW_TFR);
+	status &= 0xC0;
+	if (status) {
+		iowrite32((status << 8), lnw->dma_base + MASK_TFR);
+		call_tasklet = 1;
+	}
+	status = ioread32(lnw->dma_base + RAW_ERR);
+	status &= 0xC0;
+	if (status) {
+		iowrite32(MASK_INTR_REG(status), lnw->dma_base + MASK_ERR);
+		call_tasklet = 1;
+	}
+
+	if (call_tasklet)
+		tasklet_schedule(&lnw->dma->tasklet);
+
+	return IRQ_HANDLED;
+}
+
+static void enable_dma1_interrupt(struct lnw_dma_chan *lnwc)
+{
+	dma_dbg("Called for ch_id %d\n", lnwc->ch_id);
+
+	lpe_unmask_periphral_intr(LPE_DMA);
+
+	/*en ch interrupts*/
+	iowrite32(UNMASK_INTR_REG(lnwc->ch_id), lnwc->dma_base + MASK_TFR);
+	iowrite32(UNMASK_INTR_REG(lnwc->ch_id), lnwc->dma_base + MASK_ERR);
+	return;
+}
+
+static void disable_dma1_interrupt(struct lnw_dma_chan *lnwc)
+{
+	/*Check LPE PISR, make sure fwd is disabled*/
+	lpe_mask_periphral_intr(LPE_DMA);
+	iowrite32(MASK_INTR_REG(lnwc->ch_id), lnwc->dma_base + MASK_BLOCK);
+	iowrite32(MASK_INTR_REG(lnwc->ch_id), lnwc->dma_base + MASK_TFR);
+	iowrite32(MASK_INTR_REG(lnwc->ch_id), lnwc->dma_base + MASK_ERR);
+	dma_dbg(" called \n");
+	return;
+}
+
+static int lnw_setup_dma1(struct pci_dev *pdev)
+{
+	struct lnw_device *device = pci_get_drvdata(pdev);
+	struct lnwdma_device *dma = NULL;
+	int err, i;
+
+	dma_dbg("setup_dma called \n");
+	dma = kzalloc(sizeof(*dma), GFP_KERNEL);
+	if (NULL == dma) {
+		dma_err("kzalloc failed \n");
+		err = -ENOMEM;
+		goto err_kzalloc;
+	}
+	device->dma = dma;
+	dma->pdev = pdev;
+	dma->dma_base = device->dma_base;
+
+	/* DMA coherent memory pool for DMA descriptor allocations */
+	dma->dma_pool = pci_pool_create("dma_desc_pool", pdev,
+					sizeof(struct lnw_dma_desc),
+					32, 0);
+	if (NULL == dma->dma_pool) {
+		dma_err("pci_pool_create failed \n");
+		err = -ENOMEM;
+		kfree(dma);
+		goto err_dma_pool;
+	}
+
+	INIT_LIST_HEAD(&dma->common.channels);
+
+
+	/*init CH structures*/
+	for (i = 0; i < MAX_CHAN; i++) {
+		struct lnw_dma_chan *lnwch = &dma->ch[i];
+
+		lnwch->chan.device = &dma->common;
+		lnwch->chan.cookie =  1;
+		lnwch->chan.chan_id = i;
+		lnwch->ch_id = get_ch_id(i);
+		dma_dbg("Init CH %d, ID %d \n", i, lnwch->ch_id);
+
+		lnwch->dma_base = dma->dma_base;
+		lnwch->ch_regs = dma->dma_base + DMA_CH_SIZE * lnwch->ch_id;
+		lnwch->dma = dma;
+		spin_lock_init(&lnwch->lock);
+
+		INIT_LIST_HEAD(&lnwch->active_list);
+		INIT_LIST_HEAD(&lnwch->queue);
+		INIT_LIST_HEAD(&lnwch->free_list);
+		/*mask interrupts*/
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_BLOCK);
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_SRC_TRAN);
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_DST_TRAN);
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_ERR);
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_TFR);
+
+		disable_dma1_interrupt(lnwch);
+		list_add_tail(&lnwch->chan.device_node, &dma->common.channels);
+	}
+
+	/*init dma structure*/
+	dma_cap_zero(dma->common.cap_mask);
+	dma_cap_set(DMA_MEMCPY, dma->common.cap_mask);
+	dma_cap_set(DMA_SLAVE, dma->common.cap_mask);
+	dma_cap_set(DMA_PRIVATE, dma->common.cap_mask);
+	dma->common.dev = &pdev->dev;
+	dma->common.chancnt = MAX_CHAN;
+
+	dma->common.device_alloc_chan_resources =
+					lnw_dma1_alloc_chan_resources;
+	dma->common.device_free_chan_resources =
+					lnw_dma1_free_chan_resources;
+
+	dma->common.device_is_tx_complete = lnw_dma1_tx_is_complete;
+	dma->common.device_prep_dma_memcpy = lnw_dma1_prep_memcpy;
+	dma->common.device_issue_pending = lnw_dma1_issue_pending;
+	dma->common.device_prep_slave_sg = lnw_dma1_prep_slave_sg;
+	dma->common.device_terminate_all = lnw_dma1_terminate_all;
+
+	/*enable dma cntrl*/
+	iowrite32(REG_BIT0, dma->dma_base + DMA_CFG);
+
+	/*register irq*/
+	err = request_irq(pdev->irq, lnw_dma1_interrupt,
+			IRQF_SHARED, lnw_dma1_pci.name, device);
+	if (0 != err)
+		goto err_irq;
+
+	/*register device w/ engine*/
+	err = dma_async_device_register(&dma->common);
+	if (0 != err) {
+		dma_err("device_register failed: %d \n", err);
+		goto err_engine;
+	}
+	tasklet_init(&dma->tasklet, dma_tasklet1, (unsigned long)dma);
+	dma_dbg("...done \n");
+	return 0;
+
+err_engine:
+	free_irq(pdev->irq, device);
+err_irq:
+	pci_pool_destroy(dma->dma_pool);
+	kfree(dma);
+err_dma_pool:
+err_kzalloc:
+	dma_err("setup_dma failed: %d \n", err);
+	return err;
+
+}
+
+static void lnwdma_shutdown1(struct pci_dev *pdev)
+{
+	struct lnw_device *device = pci_get_drvdata(pdev);
+
+	dma_dbg("shutdown called \n");
+	dma_async_device_unregister(&device->dma->common);
+	pci_pool_destroy(device->dma->dma_pool);
+	if (device->dma_base)
+		iounmap(device->dma_base);
+	free_irq(pdev->irq, device);
+	return;
+}
+
+static int __devinit
+lnw_dma1_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+	struct lnw_device *device = NULL;
+	u32 base_addr = 0, bar_size = 0;
+	int err = 0;
+
+	dma_info("probe called for %x \n", pdev->device);
+	err = pci_enable_device(pdev);
+	if (err)
+		goto err_enable_device;
+
+	err = pci_request_regions(pdev, lnw_dma1_pci.name);
+	if (err)
+		goto err_request_regions;
+
+	err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+	if (err)
+		goto err_set_dma_mask;
+
+	err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+	if (err)
+		goto err_set_dma_mask;
+
+	device = kzalloc(sizeof(*device), GFP_KERNEL);
+	if (!device) {
+		dma_err("kzalloc failed \n");
+		err = -ENOMEM;
+		goto err_kzalloc;
+	}
+	device->pdev = pci_dev_get(pdev);
+
+	base_addr = pci_resource_start(pdev, 0);
+	bar_size  = pci_resource_len(pdev, 0);
+	dma_dbg("BAR0 %x Size %x \n", base_addr, bar_size);
+	device->dma_base = ioremap_nocache(base_addr, DMA_REG_SIZE);
+	if (!device->dma_base) {
+		dma_err("ioremap failed \n");
+		err = -ENOMEM;
+		goto err_ioremap1;
+	}
+	pci_set_drvdata(pdev, device);
+	pci_set_master(pdev);
+
+	err = lnw_setup_dma1(pdev);
+	if (err)
+		goto err_dma;
+
+	return 0;
+
+err_dma:
+	iounmap(device->dma_base);
+err_ioremap1:
+	pci_dev_put(pdev);
+	kfree(device);
+err_kzalloc:
+err_set_dma_mask:
+	pci_release_regions(pdev);
+	pci_disable_device(pdev);
+err_request_regions:
+err_enable_device:
+	dma_err("Probe failed %d\n", err);
+	return err;
+}
+
+static void __devexit lnw_dma1_remove(struct pci_dev *pdev)
+{
+	struct lnw_device *device = pci_get_drvdata(pdev);
+
+	lnwdma_shutdown1(pdev);
+	pci_dev_put(pdev);
+	kfree(device);
+	pci_release_regions(pdev);
+	pci_disable_device(pdev);
+}
+
+static int __init lnw_dma1_init(void)
+{
+	dma_info("LNW DMA Driver\n Version %s \n", LNW_DMA_DRIVER_VERSION);
+	return pci_register_driver(&lnw_dma1_pci);
+}
+late_initcall(lnw_dma1_init);
+
+static void __exit lnw_dma1_exit(void)
+{
+	pci_unregister_driver(&lnw_dma1_pci);
+}
+module_exit(lnw_dma1_exit);
+
Index: linux-2.6.33/drivers/dma/lnw_dmac2.c
===================================================================
--- /dev/null
+++ linux-2.6.33/drivers/dma/lnw_dmac2.c
@@ -0,0 +1,947 @@
+/*
+ *  lnw_dmac2.c - Intel Langwell DMA Drivers
+ *
+ *  Copyright (C) 2008-09 Intel Corp
+ *  Author: Vinod Koul <vinod.koul@intel.com>
+ *  The driver design is based on dw_dmac driver
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  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; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/interrupt.h>
+#include <linux/lnw_dma.h>
+
+#define MAX_CHAN 	2
+#include "lnw_dma_regs.h"
+
+MODULE_AUTHOR("Vinod Koul <vinod.koul@intel.com>");
+MODULE_DESCRIPTION("Intel (R) Moorestown Langwell DMAC2 Driver");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(LNW_DMA_DRIVER_VERSION);
+
+#define DMA_CH0		0
+#define DMA_CH1		1
+#define CH_BLOCK_SIZE	2047
+
+static int __devinit lnw_dma2_probe(struct pci_dev *pdev,
+				const struct pci_device_id *id);
+static void __devexit lnw_dma2_remove(struct pci_dev *pdev);
+static void enable_dma2_interrupt(struct lnw_dma_chan *lnwc);
+
+struct lnw_device {
+	struct pci_dev 		*pdev;
+	void __iomem		*dma_base;
+	struct lnwdma_device	*dma;
+};
+
+/*CH dep code, if ch no's mapping changes only change here*/
+static int get_ch_id(int index)
+{
+	if (index == 0)
+		return DMA_CH0;
+	else if (index == 1)
+		return DMA_CH1;
+	else
+		return -1;
+}
+
+static int get_ch_index(int ch_id)
+{
+	if (ch_id == DMA_CH0)
+		return 0;
+	if (ch_id == DMA_CH1)
+		return 1;
+	else
+		return -1;
+}
+
+static int get_ch_num(int *status)
+{
+	if (*status & (1 << DMA_CH0)) {
+		*status = *status & (~(1 << DMA_CH0));
+		return DMA_CH0;
+	} else if (*status & (1 << DMA_CH1)) {
+		*status = *status & (~(1 << DMA_CH1));
+		return DMA_CH1;
+	} else
+		return -1;
+}
+
+static int get_block_ts(int len, int tx_width)
+{
+	int byte_width = 0, block_ts = 0;
+
+	switch (tx_width) {
+	case LNW_DMA_WIDTH_8BIT:
+		byte_width = 1;
+		break;
+	case LNW_DMA_WIDTH_16BIT:
+		byte_width = 2;
+		break;
+	case LNW_DMA_WIDTH_32BIT:
+	default:
+		byte_width = 4;
+		break;
+	}
+
+	block_ts = len/byte_width;
+	if (block_ts > CH_BLOCK_SIZE)
+		block_ts = 0xFFFF;
+	return block_ts;
+}
+
+static struct lnw_dma_desc *lnwc_desc_get(struct lnw_dma_chan *lnwc)
+{
+	struct lnw_dma_desc *desc, *_desc;
+	struct lnw_dma_desc *ret = NULL;
+
+	dma_dbg("called \n");
+	spin_lock_bh(&lnwc->lock);
+	list_for_each_entry_safe(desc, _desc, &lnwc->free_list, desc_node) {
+		if (async_tx_test_ack(&desc->txd)) {
+			list_del(&desc->desc_node);
+			ret = desc;
+			dma_dbg("got free desc \n");
+			break;
+		}
+	}
+	spin_unlock_bh(&lnwc->lock);
+	return ret;
+}
+
+static void lnwc_desc_put(struct lnw_dma_chan *lnwc, struct lnw_dma_desc *desc)
+{
+	if (desc) {
+		spin_lock_bh(&lnwc->lock);
+		list_add_tail(&desc->desc_node, &lnwc->free_list);
+		spin_unlock_bh(&lnwc->lock);
+	}
+}
+
+/* Called with lock held and bh disabled */
+static void lnwc_dostart(struct lnw_dma_chan *lnwc, struct lnw_dma_desc *first)
+{
+	struct lnwdma_device *lnw = to_lnwdma_device(lnwc->chan.device);
+
+	dma_dbg("called \n");
+	/*  channel is idle */
+	if (lnwc->in_use && test_ch_en(lnwc->dma_base, lnwc->ch_id)) {
+		/*error*/
+		dma_err("channel is busy \n");
+		/* The tasklet will hopefully advance the queue... */
+		return;
+	}
+
+	/*write registers and en*/
+	iowrite32(first->sar, lnwc->ch_regs + SAR);
+	iowrite32(first->dar, lnwc->ch_regs + DAR);
+	iowrite32(first->cfg_hi, lnwc->ch_regs + CFG_HIGH);
+	iowrite32(first->cfg_lo, lnwc->ch_regs + CFG_LOW);
+	iowrite32(first->ctl_lo, lnwc->ch_regs + CTL_LOW);
+	iowrite32(first->ctl_hi, lnwc->ch_regs + CTL_HIGH);
+	dma_dbg("TX SAR %lx, DAR %lx, CFGL %x, CFGH %x, CTLH %x, CTLL %x \n",
+		first->sar, first->dar, first->cfg_hi,
+		first->cfg_lo, first->ctl_hi, first->ctl_lo);
+
+	iowrite32(ENABLE_CHANNEL(lnwc->ch_id), lnw->dma_base + DMA_CHAN_EN);
+	first->status = DMA_IN_PROGRESS;
+}
+
+static void
+lnwc_descriptor_complete(struct lnw_dma_chan *lnwc, struct lnw_dma_desc *desc)
+{
+	struct dma_async_tx_descriptor	*txd = &desc->txd;
+	dma_async_tx_callback callback = NULL;
+	dma_async_tx_callback callback_txd = NULL;
+	void *param = NULL;
+	void *param_txd = NULL;
+	u32 sar, dar, len;
+	union lnw_dma_ctl_hi ctl_hi;
+
+	dma_dbg("called \n");
+
+	/*check if full tx is complete or not*/
+	sar = ioread32(lnwc->ch_regs + SAR);
+	dar = ioread32(lnwc->ch_regs + DAR);
+
+	if (desc->dirn == DMA_FROM_DEVICE)
+		len = dar - desc->dar;
+	else
+		len = sar - desc->sar;
+
+	dma_dbg("SAR %x DAR %x, DMA done: %x \n", sar, dar, len);
+	if (desc->len > len) {
+		dma_dbg("dirn = %d\n", desc->dirn);
+		dma_dbg("SAR %x DAR %x, len: %x \n", sar, dar, len);
+		/*we have to copy more bytes*/
+		desc->len -= len;
+		ctl_hi.ctl_hi = desc->ctl_hi;
+		ctl_hi.ctlx.block_ts = get_block_ts(desc->len, desc->width);
+		dma_dbg("setting for %x bytes \n", ctl_hi.ctlx.block_ts);
+		desc->ctl_hi = ctl_hi.ctl_hi;
+		if (desc->cfg_mode == LNW_DMA_MEM_TO_MEM) {
+			sar++;
+			dar++;
+		} else if (desc->dirn == DMA_TO_DEVICE)
+			sar++;
+		else if (desc->dirn == DMA_FROM_DEVICE)
+			dar++;
+		desc->sar = sar;
+		desc->dar = dar;
+		dma_dbg("New SAR %x DAR %x \n", sar, dar);
+		lnwc_dostart(lnwc, desc);
+		return;
+	}
+
+	lnwc->completed = txd->cookie;
+	callback = desc->callback;
+	param = desc->callback_param;
+	callback_txd = txd->callback;
+	param_txd = txd->callback_param;
+
+	list_move(&desc->desc_node, &lnwc->free_list);
+
+	spin_unlock_bh(&lnwc->lock);
+	dma_dbg("Now we are calling callback \n");
+	if (callback_txd) {
+		dma_dbg("lnw TXD callback set ... calling \n");
+		callback_txd(param_txd);
+		spin_lock_bh(&lnwc->lock);
+		return;
+	}
+	if (callback) {
+		dma_dbg("lnw callback set ... calling \n");
+		callback(param);
+	}
+	spin_lock_bh(&lnwc->lock);
+
+}
+
+/*check desc, mark as complete when tx is complete*/
+static void
+lnwc_scan_descriptors(struct lnwdma_device *lnw, struct lnw_dma_chan *lnwc)
+{
+	struct lnw_dma_desc *desc = NULL, *_desc = NULL;
+	u32 status_xfer;
+
+	dma_dbg("called \n");
+	status_xfer = ioread32(lnwc->dma_base + RAW_TFR);
+	status_xfer = (status_xfer >> lnwc->ch_id) & 0x1;
+	dma_dbg("ch[%d]:  status_xfer %x \n", lnwc->ch_id, status_xfer);
+	if (!status_xfer)
+		return;
+
+	/*tx is complete*/
+	list_for_each_entry_safe(desc, _desc, &lnwc->active_list, desc_node) {
+		if (desc == NULL)
+			continue;
+		if (desc->status == DMA_IN_PROGRESS)  {
+			desc->status = DMA_SUCCESS;
+			lnwc_descriptor_complete(lnwc, desc);
+		}
+	}
+	return;
+}
+
+/*****************************************************************************
+DMA Functions*/
+static dma_cookie_t lnw_dma2_tx_submit(struct dma_async_tx_descriptor *tx)
+{
+	struct lnw_dma_desc	*desc = to_lnw_dma_desc(tx);
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(tx->chan);
+	dma_cookie_t		cookie;
+
+	dma_dbg("called \n");
+
+	spin_lock_bh(&lnwc->lock);
+	cookie = lnwc->chan.cookie;
+
+	if (++cookie < 0)
+		cookie = 1;
+
+	lnwc->chan.cookie = cookie;
+	desc->txd.cookie = cookie;
+
+	if (list_empty(&lnwc->active_list)) {
+		lnwc_dostart(lnwc, desc);
+		list_add_tail(&desc->desc_node, &lnwc->active_list);
+	} else {
+		list_add_tail(&desc->desc_node, &lnwc->queue);
+	}
+	spin_unlock_bh(&lnwc->lock);
+
+	return cookie;
+}
+
+static void lnw_dma2_issue_pending(struct dma_chan *chan)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+
+	spin_lock_bh(&lnwc->lock);
+	if (!list_empty(&lnwc->queue))
+		lnwc_scan_descriptors(to_lnwdma_device(chan->device), lnwc);
+	spin_unlock_bh(&lnwc->lock);
+}
+
+static enum dma_status
+lnw_dma2_tx_is_complete(struct dma_chan *chan,
+		dma_cookie_t cookie,
+		dma_cookie_t *done,
+		dma_cookie_t *used)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+	dma_cookie_t		last_used;
+	dma_cookie_t		last_complete;
+	int				ret;
+
+	last_complete = lnwc->completed;
+	last_used = chan->cookie;
+
+	ret = dma_async_is_complete(cookie, last_complete, last_used);
+	if (ret != DMA_SUCCESS) {
+		lnwc_scan_descriptors(to_lnwdma_device(chan->device), lnwc);
+
+		last_complete = lnwc->completed;
+		last_used = chan->cookie;
+
+		ret = dma_async_is_complete(cookie, last_complete, last_used);
+	}
+
+	if (done)
+		*done = last_complete;
+	if (used)
+		*used = last_used;
+
+	return ret;
+}
+
+static void lnw_dma2_terminate_all(struct dma_chan *chan)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+	struct lnwdma_device	*lnw = to_lnwdma_device(chan->device);
+	struct lnw_dma_desc	*desc, *_desc;
+	LIST_HEAD(list);
+
+	/* ASSERT:  channel is idle */
+	if (lnwc->in_use == false) {
+		/*ch is not in use, wrong call*/
+		return;
+	}
+	spin_lock_bh(&lnwc->lock);
+	list_splice_init(&lnwc->free_list, &list);
+	lnwc->descs_allocated = 0;
+	lnwc->slave = NULL;
+
+	/* Disable interrupts*/
+	iowrite32(MASK_INTR_REG(lnwc->ch_id), lnw->dma_base + MASK_BLOCK);
+	iowrite32(MASK_INTR_REG(lnwc->ch_id), lnw->dma_base + MASK_ERR);
+
+	spin_unlock_bh(&lnwc->lock);
+	list_for_each_entry_safe(desc, _desc, &list, desc_node) {
+		dma_dbg("freeing descriptor %p\n", desc);
+		pci_pool_free(lnw->dma_pool, desc, desc->txd.phys);
+	}
+
+	return;
+}
+
+static struct dma_async_tx_descriptor *
+lnw_dma2_prep_slave_sg(struct dma_chan *chan,
+		struct scatterlist *sgl, unsigned int sg_len,
+		enum dma_data_direction direction,
+		unsigned long flags)
+{
+	/*not supported now*/
+	return NULL;
+}
+
+static struct dma_async_tx_descriptor *
+lnw_dma2_prep_memcpy(struct dma_chan *chan, dma_addr_t dest,
+		dma_addr_t src, size_t len, unsigned long flags)
+{
+	struct lnw_dma_chan *lnwc;
+	struct lnw_dma_desc *desc = NULL;
+	struct lnw_dma_slave *lnws;
+	union lnw_dma_ctl_lo ctl_lo;
+	union lnw_dma_ctl_hi ctl_hi;
+	union lnw_dma_cfg_lo cfg_lo;
+	union lnw_dma_cfg_hi cfg_hi;
+	enum lnw_dma_width width = 0;
+
+	dma_dbg("called \n");
+	WARN_ON(!chan);
+	if (!len)
+		return NULL;
+
+	lnws = chan->private;
+	WARN_ON(!lnws);
+
+	lnwc = to_lnw_dma_chan(chan);
+	WARN_ON(!lnwc);
+
+	dma_dbg("called for CH %d\n", lnwc->ch_id);
+	dma_dbg("Cfg passed Mode %x, Dirn %x, HS %x, Width %x \n",
+		lnws->cfg_mode, lnws->dirn, lnws->hs_mode, lnws->src_width);
+
+	/*calculate CFG_LO*/
+	if (lnws->hs_mode == LNW_DMA_SW_HS) {
+		cfg_lo.cfg_lo = 0;
+		cfg_lo.cfgx.hs_sel_dst = 1;
+		cfg_lo.cfgx.hs_sel_src = 1;
+	} else if (lnws->hs_mode == LNW_DMA_HW_HS)
+		cfg_lo.cfg_lo = 0x00000;
+
+	/*calculate CFG_HI*/
+	if (lnws->cfg_mode == LNW_DMA_MEM_TO_MEM) {
+		/*SW HS only*/
+		dma_dbg("CFG: Mem to mem dma \n");
+		cfg_hi.cfg_hi = 0;
+	} else {
+		dma_dbg("HW DMA \n");
+		cfg_hi.cfg_hi = 0;
+		cfg_hi.cfgx.protctl = 0x1; /*default value*/
+		cfg_hi.cfgx.src_per = get_ch_index(lnwc->ch_id);
+		cfg_hi.cfgx.dst_per = get_ch_index(lnwc->ch_id);
+	}
+
+	/*calculate CTL_HI*/
+	ctl_hi.ctlx.reser = 0;
+		width = lnws->src_width;
+	ctl_hi.ctlx.block_ts = get_block_ts(len, width);
+
+	/*calculate CTL_LO*/
+	ctl_lo.ctl_lo = 0;
+	ctl_lo.ctlx.int_en = 1;
+	ctl_lo.ctlx.dst_tr_width = lnws->dst_width;
+	ctl_lo.ctlx.src_tr_width = lnws->src_width;
+	ctl_lo.ctlx.dst_msize = lnws->src_msize;
+	ctl_lo.ctlx.src_msize = lnws->dst_msize;
+
+	if (lnws->cfg_mode == LNW_DMA_MEM_TO_MEM) {
+		dma_dbg("CTL: Mem to mem dma \n");
+		ctl_lo.ctlx.tt_fc = 0;
+		ctl_lo.ctlx.sinc = 0;
+		ctl_lo.ctlx.dinc = 0;
+	} else {
+		if (lnws->dirn == DMA_TO_DEVICE) {
+			dma_dbg("CTL: DMA_TO_DEVICE \n");
+			ctl_lo.ctlx.sinc = 0;
+			ctl_lo.ctlx.dinc = 2;
+			ctl_lo.ctlx.tt_fc = 1;
+		} else if (lnws->dirn == DMA_FROM_DEVICE) {
+			dma_dbg("CTL: DMA_FROM_DEVICE \n");
+			ctl_lo.ctlx.sinc = 2;
+			ctl_lo.ctlx.dinc = 0;
+			ctl_lo.ctlx.tt_fc = 2;
+		}
+	}
+
+	dma_dbg("Calc CTL LO %x, CTL HI %x, CFG LO %x, CFG HI %x\n",
+		ctl_lo.ctl_lo, ctl_hi.ctl_hi, cfg_lo.cfg_lo, cfg_hi.cfg_hi);
+
+	enable_dma2_interrupt(lnwc);
+
+	desc = lnwc_desc_get(lnwc);
+	if (desc == NULL)
+		goto err_desc_get;
+	desc->sar = src;
+	desc->dar = dest ;
+	desc->len = len;
+	desc->cfg_hi = cfg_hi.cfg_hi;
+	desc->cfg_lo = cfg_lo.cfg_lo;
+	desc->ctl_lo = ctl_lo.ctl_lo;
+	desc->ctl_hi = ctl_hi.ctl_hi;
+	desc->width = width;
+	desc->dirn = lnws->dirn;
+	if (lnws->callback) {
+		desc->callback = lnws->callback;
+		desc->callback_param = lnws->callback_param;
+		dma_dbg("Callback passed... setting\n");
+	} else
+		desc->callback = NULL;
+	return &desc->txd;
+
+err_desc_get:
+	dma_err("Failed to get desc \n");
+	lnwc_desc_put(lnwc, desc);
+	return NULL;
+}
+
+
+static void lnw_dma2_free_chan_resources(struct dma_chan *chan)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+	struct lnwdma_device	*lnw = to_lnwdma_device(chan->device);
+	struct lnw_dma_desc	*desc, *_desc;
+
+	dma_dbg("..called for ch_id %d, lnwch_id %d\n",
+			chan->chan_id, lnwc->ch_id);
+	if (true == lnwc->in_use) {
+		/*trying to free ch in use!!!!!*/
+		dma_err("trying to free ch in use \n");
+	}
+
+	spin_lock_bh(&lnwc->lock);
+	lnwc->descs_allocated = 0;
+	list_for_each_entry_safe(desc, _desc, &lnwc->active_list, desc_node) {
+		dma_dbg("del active \n");
+		list_del(&desc->desc_node);
+		pci_pool_free(lnw->dma_pool, desc, desc->txd.phys);
+	}
+	list_for_each_entry_safe(desc, _desc, &lnwc->free_list, desc_node) {
+		list_del(&desc->desc_node);
+		pci_pool_free(lnw->dma_pool, desc, desc->txd.phys);
+	}
+	list_for_each_entry_safe(desc, _desc, &lnwc->queue, desc_node) {
+		dma_dbg("del queue \n");
+		list_del(&desc->desc_node);
+		pci_pool_free(lnw->dma_pool, desc, desc->txd.phys);
+	}
+	spin_unlock_bh(&lnwc->lock);
+	lnwc->in_use = false;
+	chan->client_count--;
+	/* Disable CH interrupts*/
+	iowrite32(MASK_INTR_REG(lnwc->ch_id), lnw->dma_base + MASK_BLOCK);
+	iowrite32(MASK_INTR_REG(lnwc->ch_id), lnw->dma_base + MASK_ERR);
+	dma_dbg("done \n");
+}
+
+static int lnw_dma2_alloc_chan_resources(struct dma_chan *chan)
+{
+	struct lnw_dma_chan	*lnwc = to_lnw_dma_chan(chan);
+	struct lnwdma_device	*lnw = to_lnwdma_device(chan->device);
+	struct lnw_dma_desc	*desc;
+	dma_addr_t		phys;
+	int	i = 0;
+
+	dma_dbg("called \n");
+
+	/* ASSERT:  channel is idle */
+	if (test_ch_en(lnw->dma_base, lnwc->ch_id)) {
+		/*ch is not idle*/
+		dma_err(".ch not idle\n");
+		return -EIO;
+	}
+	dma_dbg("..called for ch_id %d, lnwch_id %d\n",
+			chan->chan_id, lnwc->ch_id);
+	lnwc->completed = chan->cookie = 1;
+
+	chan->client_count++;
+
+	spin_lock_bh(&lnwc->lock);
+	while (lnwc->descs_allocated < DESCS_PER_CHANNEL) {
+		spin_unlock_bh(&lnwc->lock);
+		desc = pci_pool_alloc(lnw->dma_pool, GFP_KERNEL, &phys);
+		if (!desc) {
+			dma_err("desc failed\n");
+			return -ENOMEM;
+			/*check*/
+		}
+		dma_async_tx_descriptor_init(&desc->txd, chan);
+		desc->txd.tx_submit = lnw_dma2_tx_submit;
+		desc->txd.flags = DMA_CTRL_ACK;
+		desc->txd.phys = phys;
+		spin_lock_bh(&lnwc->lock);
+		i = ++lnwc->descs_allocated;
+		list_add_tail(&desc->desc_node, &lnwc->free_list);
+	}
+	spin_unlock_bh(&lnwc->lock);
+	lnwc->in_use = false;
+	dma_dbg("Desc alloc done ret: %d desc\n", i);
+	return i;
+}
+
+static void lnwc_handle_error(struct lnwdma_device *lnw,
+		struct lnw_dma_chan *lnwc)
+{
+	lnwc_scan_descriptors(lnw, lnwc);
+}
+
+/******************************************************************************
+* PCI stuff
+*/
+static struct pci_device_id lnw_dma2_ids[] = {
+	{ PCI_VENDOR_ID_INTEL, 0x0813, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+	{ 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, lnw_dma2_ids);
+
+static struct pci_driver lnw_dma2_pci = {
+	.name		=	"Intel LNW DMA2",
+	.id_table	=	lnw_dma2_ids,
+	.probe		=	lnw_dma2_probe,
+	.remove		=	__devexit_p(lnw_dma2_remove),
+};
+
+static void dma_tasklet(unsigned long data)
+{
+	struct lnwdma_device *lnw = NULL;
+	struct lnw_dma_chan *lnwc = NULL;
+	u32 status;
+	int i, ch_no;
+
+	dma_dbg("called \n");
+	lnw = (struct lnwdma_device *)data;
+	if (lnw == NULL) {
+		dma_err("Null param \n");
+		return;
+	}
+
+	status = ioread32(lnw->dma_base + RAW_TFR);
+	dma_dbg("RAW_TFR %x \n", status);
+	while (status) {
+		/*txn interrupt*/
+		ch_no = get_ch_num(&status);
+		if (ch_no < 0) {
+			dma_err("Ch no is invalid %x, abort!\n", ch_no);
+			return;
+		}
+		dma_dbg("Got Ch %x, new Status %x \n", ch_no, status);
+		i = get_ch_index(ch_no);
+		if (i < 0) {
+			dma_err("Invalid ch index %x\n", i);
+			return;
+		}
+		dma_dbg("Tx complete interrupt %x, Ch No %d Index %d \n",
+				status, ch_no, i);
+		lnwc = &lnw->ch[i];
+		if (lnwc == NULL) {
+			dma_err("Null param lnwc\n");
+			return;
+		}
+		dma_dbg("CH %x \n", lnwc->ch_id);
+		spin_lock_bh(&lnwc->lock);
+		lnwc_scan_descriptors(lnw, lnwc);
+		dma_dbg("Scan of desc... complete, unmasking\n");
+		iowrite32((1 << lnwc->ch_id),
+				lnw->dma_base + CLEAR_TFR);
+		dma_dbg("Wrote to clear %x\n", (1 << lnwc->ch_id));
+		iowrite32((1 << lnwc->ch_id),
+				lnw->dma_base + CLEAR_BLOCK);
+		iowrite32(UNMASK_INTR_REG(lnwc->ch_id),
+				lnw->dma_base + MASK_TFR);
+		spin_unlock_bh(&lnwc->lock);
+	}
+
+	dma_dbg("Trf interrupt done... \n");
+	status = ioread32(lnw->dma_base + RAW_ERR);
+	while (status) {
+		/*err interrupt*/
+		ch_no = get_ch_num(&status);
+		if (ch_no < 0) {
+			dma_err("Ch no is invalid %x, abort!\n", ch_no);
+			return;
+		}
+		dma_dbg("Got Ch %x, new Status %x \n", ch_no, status);
+		i = get_ch_index(ch_no);
+		if (i < 0) {
+			dma_err("Invalid CH lnwc\n");
+			return;
+		}
+		dma_dbg("Tx error interrupt %x, No %d Index %d \n",
+				status, ch_no, i);
+		lnwc = &lnw->ch[i];
+		if (lnwc == NULL) {
+			dma_err("Null param lnwc\n");
+			return;
+		}
+		spin_lock_bh(&lnwc->lock);
+		lnwc_handle_error(lnw, lnwc);
+		iowrite32((1 << lnwc->ch_id),
+				lnw->dma_base + CLEAR_ERR);
+		iowrite32(UNMASK_INTR_REG(lnwc->ch_id),
+				lnw->dma_base + MASK_ERR);
+		spin_unlock_bh(&lnwc->lock);
+	}
+	dma_dbg("Exiting takslet... \n");
+	return;
+}
+
+static irqreturn_t lnw_dma2_interrupt(int irq, void *data)
+{
+	struct lnw_device *lnw = data;
+	u32 status;
+	int call_tasklet = 0;
+
+	/*will mask interrupt for now and schedule tasklet
+	tasklet shud unmask and clear*/
+	status = ioread32(lnw->dma_base + STATUS_TFR);
+	status &= 0x03;
+	if (status) {
+		iowrite32((status << 8), lnw->dma_base + MASK_TFR);
+		call_tasklet = 1;
+	}
+	status = ioread32(lnw->dma_base + STATUS_ERR);
+	status &= 0x03;
+	if (status) {
+		iowrite32(MASK_INTR_REG(status), lnw->dma_base + MASK_ERR);
+		call_tasklet = 1;
+	}
+
+	if (call_tasklet)
+		tasklet_schedule(&lnw->dma->tasklet);
+
+	return IRQ_HANDLED;
+}
+
+static void enable_dma2_interrupt(struct lnw_dma_chan *lnwc)
+{
+	dma_dbg("Called for ch_id %d\n", lnwc->ch_id);
+
+	iowrite32(REG_BIT0, lnwc->dma->dma_base + DMA_CFG);
+	/*en ch interrupts */
+	iowrite32(UNMASK_INTR_REG(lnwc->ch_id), lnwc->dma_base + MASK_TFR);
+	iowrite32(UNMASK_INTR_REG(lnwc->ch_id), lnwc->dma_base + MASK_ERR);
+	return;
+}
+
+static void disable_dma2_interrupt(struct lnw_device *device)
+{
+	u32 status = 0;
+
+	/*todo*/
+	dma_dbg(" called \n");
+	status = 1;
+	return;
+
+}
+
+static int lnw_setup_dma2(struct pci_dev *pdev)
+{
+	struct lnw_device *device = pci_get_drvdata(pdev);
+	struct lnwdma_device *dma = NULL;
+	int err, i;
+
+	dma_dbg("setup_dma called \n");
+	dma = kzalloc(sizeof(*dma), GFP_KERNEL);
+	if (NULL == dma) {
+		dma_err("kzalloc failed \n");
+		err = -ENOMEM;
+		goto err_kzalloc;
+	}
+	device->dma = dma;
+	dma->pdev = pdev;
+	dma->dma_base = device->dma_base;
+
+	/* DMA coherent memory pool for DMA descriptor allocations */
+	dma->dma_pool = pci_pool_create("dma_desc_pool", pdev,
+					sizeof(struct lnw_dma_desc),
+					32, 0);
+	if (NULL == dma->dma_pool) {
+		dma_err("pci_pool_create failed \n");
+		err = -ENOMEM;
+		kfree(dma);
+		goto err_dma_pool;
+	}
+
+	INIT_LIST_HEAD(&dma->common.channels);
+
+
+	/*init CH structures*/
+	for (i = 0; i < MAX_CHAN; i++) {
+		struct lnw_dma_chan *lnwch = &dma->ch[i];
+
+		lnwch->chan.device = &dma->common;
+		lnwch->chan.cookie =  1;
+		lnwch->chan.chan_id = i;
+		lnwch->ch_id = get_ch_id(i);
+		dma_dbg("Init CH %d, ID %d \n", i, lnwch->ch_id);
+
+		lnwch->dma_base = dma->dma_base;
+		lnwch->ch_regs = dma->dma_base + DMA_CH_SIZE * lnwch->ch_id;
+		lnwch->dma = dma;
+		spin_lock_init(&lnwch->lock);
+
+		INIT_LIST_HEAD(&lnwch->active_list);
+		INIT_LIST_HEAD(&lnwch->queue);
+		INIT_LIST_HEAD(&lnwch->free_list);
+
+		/*mask interrupts*/
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_BLOCK);
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_SRC_TRAN);
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_DST_TRAN);
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_ERR);
+		iowrite32(MASK_INTR_REG(lnwch->ch_id),
+			dma->dma_base + MASK_TFR);
+
+		dma_dbg("Init CH %d, ID %d \n", i, lnwch->ch_id);
+		list_add_tail(&lnwch->chan.device_node, &dma->common.channels);
+	}
+
+	/*init dma structure*/
+	dma_cap_zero(dma->common.cap_mask);
+	dma_cap_set(DMA_MEMCPY, dma->common.cap_mask);
+	dma_cap_set(DMA_SLAVE, dma->common.cap_mask);
+	dma_cap_set(DMA_PRIVATE, dma->common.cap_mask);
+	dma->common.dev = &pdev->dev;
+	dma->common.chancnt = MAX_CHAN;
+
+	dma->common.device_alloc_chan_resources =
+					lnw_dma2_alloc_chan_resources;
+	dma->common.device_free_chan_resources =
+					lnw_dma2_free_chan_resources;
+
+	dma->common.device_is_tx_complete = lnw_dma2_tx_is_complete;
+	dma->common.device_prep_dma_memcpy = lnw_dma2_prep_memcpy;
+	dma->common.device_issue_pending = lnw_dma2_issue_pending;
+	dma->common.device_prep_slave_sg = lnw_dma2_prep_slave_sg;
+	dma->common.device_terminate_all = lnw_dma2_terminate_all;
+
+	/*enable dma cntrl*/
+	iowrite32(REG_BIT0, dma->dma_base + DMA_CFG);
+
+	disable_dma2_interrupt(device);
+
+	/*register irq*/
+	err = request_irq(pdev->irq, lnw_dma2_interrupt,
+			0, lnw_dma2_pci.name, device);
+	if (0 != err)
+		goto err_irq;
+
+	/*register device w/ engine*/
+	err = dma_async_device_register(&dma->common);
+	if (0 != err) {
+		dma_err("device_register failed: %d \n", err);
+		goto err_engine;
+	}
+	tasklet_init(&dma->tasklet, dma_tasklet, (unsigned long)dma);
+	dma_dbg("...done\n");
+	return 0;
+
+err_engine:
+	free_irq(pdev->irq, device);
+err_irq:
+	pci_pool_destroy(dma->dma_pool);
+	kfree(dma);
+err_dma_pool:
+err_kzalloc:
+	dma_err("setup_dma failed: %d \n", err);
+	return err;
+
+}
+
+static void lnwdma_shutdown(struct pci_dev *pdev)
+{
+	struct lnw_device *device = pci_get_drvdata(pdev);
+
+	dma_dbg("shutdown called \n");
+	dma_async_device_unregister(&device->dma->common);
+	pci_pool_destroy(device->dma->dma_pool);
+	if (device->dma_base)
+		iounmap(device->dma_base);
+	free_irq(pdev->irq, device);
+	return;
+}
+static int __devinit
+lnw_dma2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+	struct lnw_device *device = NULL;
+	u32 base_addr = 0, bar_size = 0;
+	int err = 0;
+
+	dma_info("probe called for %x \n", pdev->device);
+	err = pci_enable_device(pdev);
+	if (err)
+		goto err_enable_device;
+
+	err = pci_request_regions(pdev, lnw_dma2_pci.name);
+	if (err)
+		goto err_request_regions;
+
+	err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+	if (err)
+		goto err_set_dma_mask;
+
+	err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+	if (err)
+		goto err_set_dma_mask;
+
+	device = kzalloc(sizeof(*device), GFP_KERNEL);
+	if (!device) {
+		dma_err("kzalloc failed \n");
+		err = -ENOMEM;
+		goto err_kzalloc;
+	}
+	device->pdev = pci_dev_get(pdev);
+
+	base_addr = pci_resource_start(pdev, 0);
+	bar_size  = pci_resource_len(pdev, 0);
+	dma_dbg("BAR0 %x Size %x \n", base_addr, bar_size);
+	device->dma_base = ioremap_nocache(base_addr, DMA_REG_SIZE);
+	if (!device->dma_base) {
+		dma_err("ioremap failed \n");
+		err = -ENOMEM;
+		goto err_ioremap;
+	}
+
+	pci_set_drvdata(pdev, device);
+	pci_set_master(pdev);
+
+	err = lnw_setup_dma2(pdev);
+	if (err)
+		goto err_dma;
+
+	return 0;
+
+err_dma:
+	iounmap(device->dma_base);
+err_ioremap:
+	pci_dev_put(pdev);
+	kfree(device);
+err_kzalloc:
+err_set_dma_mask:
+	pci_release_regions(pdev);
+	pci_disable_device(pdev);
+err_request_regions:
+err_enable_device:
+	dma_err("Probe failed %d\n", err);
+	return err;
+}
+
+static void __devexit lnw_dma2_remove(struct pci_dev *pdev)
+{
+	struct lnw_device *device = pci_get_drvdata(pdev);
+
+	lnwdma_shutdown(pdev);
+	pci_dev_put(pdev);
+	kfree(device);
+	pci_release_regions(pdev);
+	pci_disable_device(pdev);
+}
+
+static int __init lnw_dma2_init(void)
+{
+	dma_info("LNW DMA Driver\n Version %s \n", LNW_DMA_DRIVER_VERSION);
+	return pci_register_driver(&lnw_dma2_pci);
+}
+fs_initcall(lnw_dma2_init);
+
+static void __exit lnw_dma2_exit(void)
+{
+	pci_unregister_driver(&lnw_dma2_pci);
+}
+module_exit(lnw_dma2_exit);
+
Index: linux-2.6.33/include/linux/lnw_dma.h
===================================================================
--- /dev/null
+++ linux-2.6.33/include/linux/lnw_dma.h
@@ -0,0 +1,166 @@
+/*
+ *  lnw_dma.c - Intel Langwell DMA Drivers
+ *
+ *  Copyright (C) 2008i-09 Intel Corp
+ *  Author: Vinod Koul <vinod.koul@intel.com>
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *
+ */
+#ifndef __LNW_DMA_H__
+#define __LNW_DMA_H__
+
+#include <linux/dmaengine.h>
+
+/*DMA transaction width, src and dstn width would be same
+The DMA length must be width aligned,
+for 32 bit width the length must be 32 bit (4bytes) aligned only*/
+enum lnw_dma_width {
+	LNW_DMA_WIDTH_8BIT = 0x0,
+	LNW_DMA_WIDTH_16BIT = 0x1,
+	LNW_DMA_WIDTH_32BIT = 0x2,
+};
+
+/*DMA mode configurations*/
+enum lnw_dma_mode {
+	LNW_DMA_PER_TO_MEM = 0, /*periphral to memory configuration*/
+	LNW_DMA_MEM_TO_PER,	/*memory to periphral configuration*/
+	LNW_DMA_MEM_TO_MEM,	/*mem to mem confg (testing only)*/
+};
+
+/*DMA handshaking*/
+enum lnw_dma_hs_mode {
+	LNW_DMA_HW_HS = 0,	/*HW Handshaking only*/
+	LNW_DMA_SW_HS = 1,	/*SW Handshaking not recommended*/
+};
+
+/*Burst size configuration*/
+enum lnw_dma_msize {
+	LNW_DMA_MSIZE_1 = 0x0,
+	LNW_DMA_MSIZE_4 = 0x1,
+	LNW_DMA_MSIZE_8 = 0x2,
+	LNW_DMA_MSIZE_16 = 0x3,
+	LNW_DMA_MSIZE_32 = 0x4,
+	LNW_DMA_MSIZE_64 = 0x5,
+};
+
+/**
+ * struct lnw_dma_slave - DMA slave structure
+ *
+ * @dma_dev: DMA master client
+ * @tx_reg: physical address of data register used for
+ *	memory-to-peripheral transfers
+ * @rx_reg: physical address of data register used for
+ *	peripheral-to-memory transfers
+ * @tx_width: tx register width
+ * @rx_width: rx register width
+ * @dirn: DMA trf direction
+
+ * @cfg_hi: Platform-specific initializer for the CFG_HI register
+ * @cfg_lo: Platform-specific initializer for the CFG_LO register
+
+ * @ tx_width: width of src and dstn
+ * @ hs_mode: SW or HW handskaking mode
+ * @ cfg_mode: Mode configuration, DMA mem to mem to dev & mem
+ */
+struct lnw_dma_slave {
+	enum dma_data_direction	dirn;
+	enum lnw_dma_width	src_width; /*width of DMA src txn*/
+	enum lnw_dma_width	dst_width; /*width of DMA dst txn*/
+	enum lnw_dma_hs_mode	hs_mode;  /*handshaking*/
+	enum lnw_dma_mode	cfg_mode; /*mode configuration*/
+	enum lnw_dma_msize	src_msize; /*size if src burst*/
+	enum lnw_dma_msize	dst_msize; /*size of dst burst*/
+	dma_async_tx_callback 	callback; /*callback function*/
+	void 			*callback_param; /*param for callback*/
+};
+
+/*DMA channel control registers*/
+union lnw_dma_ctl_lo {
+	struct 	{
+		u32	int_en:1;	/*enable or disable interrupts*/
+					/*should be 0*/
+		u32	dst_tr_width:3;	/*destination transfer width*/
+					/*usually 32 bits = 010*/
+		u32	src_tr_width:3; /*source transfer width*/
+					/*usually 32 bits = 010*/
+		u32	dinc:2;		/*destination address inc/dec*/
+					/*For mem:INC=00, Periphral NoINC=11*/
+		u32	sinc:2;		/*source address inc or dec, as above*/
+		u32	dst_msize:3;	/*destination burst transaction length*/
+					/*always = 16 ie 011*/
+		u32	src_msize:3;	/*source burst transaction length*/
+					/*always = 16 ie 011*/
+		u32	reser1:3;
+		u32	tt_fc:3;	/*transfer type and flow controller*/
+					/*M-M = 000
+					  P-M = 010
+					  M-P = 001*/
+		u32	dms:2;		/*destination master select = 0*/
+		u32	sms:2;		/*source master select = 0*/
+		u32	llp_dst_en:1;	/*enable/disable destination LLP = 0*/
+		u32	llp_src_en:1;	/*enable/disable source LLP = 0*/
+		u32	reser2:3;
+	} ctlx;
+	u32	ctl_lo;
+};
+
+union lnw_dma_ctl_hi {
+	struct {
+		u32	block_ts:12;	/*block transfer size*/
+					/*configured by DMAC*/
+		u32	reser:20;
+	} ctlx;
+	u32	ctl_hi;
+
+};
+
+/*DMA channel configuration registers*/
+union lnw_dma_cfg_lo {
+	struct {
+		u32	reser1:5;
+		u32	ch_prior:3;	/*channel priority = 0*/
+		u32	ch_susp:1;	/*channel suspend = 0*/
+		u32	fifo_empty:1;	/*FIFO empty or not R bit = 0*/
+		u32	hs_sel_dst:1;	/*select HW/SW destn handshaking*/
+					/*HW = 0, SW = 1*/
+		u32	hs_sel_src:1;	/*select HW/SW src handshaking*/
+		u32	reser2:6;
+		u32	dst_hs_pol:1;	/*dest HS interface polarity*/
+		u32	src_hs_pol:1;	/*src HS interface polarity*/
+		u32	max_abrst:10;	/*max AMBA burst len = 0 (no sw limit*/
+		u32	reload_src:1;	/*auto reload src addr =1 if src is P*/
+		u32	reload_dst:1;	/*AR destn addr =1 if dstn is P*/
+	} cfgx;
+	u32	cfg_lo;
+};
+
+union lnw_dma_cfg_hi {
+	struct {
+		u32	fcmode:1;	/*flow control mode = 1*/
+		u32	fifo_mode:1;	/*FIFO mode select = 1*/
+		u32	protctl:3;	/*protection control = 0*/
+		u32	rsvd:2;
+		u32	src_per:4;	/*src hw HS interface*/
+		u32	dst_per:4;	/*dstn hw HS interface*/
+		u32	reser2:17;
+	} cfgx;
+	u32	cfg_hi;
+};
+
+#endif /*__LNW_DMA_H__*/
Index: linux-2.6.33/include/linux/intel_mid.h
===================================================================
--- /dev/null
+++ linux-2.6.33/include/linux/intel_mid.h
@@ -0,0 +1,144 @@
+/*
+ *  intel_mid.h - Netlink multicast interface definition for OSPM.
+ *
+ *  Copyright (C) 2009 Intel Corp
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  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; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * Authors: 	Sujith Thomas
+ *		Rajeev D Muralidhar
+ *		Vishwesh M Rudramuni
+ *		Nithish Mahalingam
+ * Contact information:
+ *		Sujith Thomas <sujith.thomas@intel.com>
+ *		Rajeev D Muralidhar <rajeev.d.muralidhar@intel.com>
+ * 		Vishwesh M Rudramuni <vishwesh.m.rudramuni@intel.com>
+ * 		Nithish Mahalingam <nithish.mahalingam@intel.com>
+ *
+ */
+
+#ifndef INTEL_MID_H
+#define INTEL_MID_H
+
+#define PMU1_MAX_DEVS   2
+#define PMU2_MAX_DEVS   12
+#define PERIPH_MAX_DEVS 3
+#define MAX_DEVICES   	(PMU1_MAX_DEVS + PMU2_MAX_DEVS + PERIPH_MAX_DEVS)
+#define WAKE_CAPABLE	0x80000000
+
+struct pci_dev_info {
+	u16 vendor_id;
+	u16 device_id;
+	u16 log_subsysid;
+	u16 phy_susbsysid;
+	u32 capability;
+	struct pci_dev *dev_driver;
+	char *dev_name;
+};
+
+struct mid_ospm {
+	u32 *pmu1_base;
+	u32 *pmu1_pm_base;
+	void __iomem *pmu2_base;
+	u32 *pm_table_base;
+	u32 pmu1_sub_systems;
+	u32 pmu2_sub_systems;
+	u32 pmu_wake_cfg;
+	u32 pmu_wake_ss_states;
+	u32 perepheral_sub_systems;
+	int pmu2_states;
+	int platform_sx_state;
+	int s0ix_retry_enb;
+	int fast_retry_exit;
+	u32 pmode;
+};
+
+extern struct pci_dev_info platform_pci_devices[MAX_DEVICES];
+extern unsigned long g_intel_mid_wakeup_address;
+
+enum pmu_ss_state {
+	SS_STATE_D0I0 = 0,
+	SS_STATE_D0I1 = 1,
+	SS_STATE_D0I2 = 2,
+	SS_STATE_D0I3 = 3
+};
+
+enum eospm_events {
+	OSPM_EVENT_SUBSYS_INACTIVITY,
+	OSPM_EVENT_SUBSYS_WAKE,
+	OSPM_EVENT_SUBSYS_START_PLAY,
+	OSPM_EVENT_SUBSYS_STOP_PLAY,
+	OSPM_EVENT_CMD_SUCCESS,
+	OSPM_EVENT_CMD_ERROR,
+	OSPM_EVENT_CMD_NO_C6_ERROR,
+	OSPM_EVENT_AUDIO_BUF_EMPTY,
+	OSPM_EVENT_AUDIO_BUF_FULL,
+	OSPM_EVENT_THERMAL_AUX0,
+	OSPM_EVENT_THERMAL_AUX1,
+	OSPM_EVENT_THERMAL_CRITICAL,
+	OSPM_EVENT_THERMAL_DEV_FAULT,
+	__OSPM_EVENT_COUNT,
+};
+
+#define AUDIO_SUBSYTEM_ID	25
+#define MID_S0I1_STATE  	1
+#define MID_S0I3_STATE  	3
+/* Thermal device Id */
+#define TEMP_DEV_ID1     40
+#define TEMP_DEV_ID2     41
+#define TEMP_DEV_ID3     42
+
+/* First 32 (0-31) originators are subsystems
+   Next 8 (0-7) are cmd IDs */
+#define OSPM_CMDID_OFFSET 32
+#define OSPM_MAX_CMD_ID 8
+
+struct ospm_genl_event {
+	u32 orig;
+	enum eospm_events event;
+};
+
+/* attributes of ospm_genl_family */
+enum {
+	OSPM_GENL_ATTR_UNSPEC,
+	OSPM_GENL_ATTR_EVENT,	/* OSPM event info needed by user space */
+	__OSPM_GENL_ATTR_MAX,
+};
+#define OSPM_GENL_ATTR_MAX (__OSPM_GENL_ATTR_MAX - 1)
+
+/* commands supported by the ospm_genl_family */
+
+enum {
+	OSPM_GENL_CMD_UNSPEC,
+	OSPM_GENL_CMD_EVENT,	/* kernel->user notifications for OSPM events */
+	__OSPM_GENL_CMD_MAX,
+};
+#define OSPM_GENL_CMD_MAX (__OSPM_GENL_CMD_MAX - 1)
+
+#define OSPM_GENL_FAMILY_NAME		"ospm_event"
+#define OSPM_GENL_VERSION		0x01
+#define OSPM_GENL_MCAST_GROUP_NAME 	"ospm_mc_group"
+
+int ospm_generate_netlink_event(u32 orig, enum eospm_events event);
+int ospm_event_genetlink_init(void);
+void ospm_event_genetlink_exit(void);
+
+extern void intel_mid_reserve_bootmem(void);
+extern unsigned long g_intel_mid_wakeup_address;
+extern void find_pci_info(u32 device_id, u32 vendor_id, u32 *index);
+extern int s0ix_non_bsp_init(void);
+
+#endif