summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/lpass-rx-macro.c
blob: c9c21d22c2c454ef6f2e49b30bf54e4ada971fd4 (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
// SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.

#include <linux/module.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <sound/soc.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc-dapm.h>
#include <sound/tlv.h>
#include <linux/of_clk.h>
#include <linux/clk-provider.h>

#define CDC_RX_TOP_TOP_CFG0		(0x0000)
#define CDC_RX_TOP_SWR_CTRL		(0x0008)
#define CDC_RX_TOP_DEBUG		(0x000C)
#define CDC_RX_TOP_DEBUG_BUS		(0x0010)
#define CDC_RX_TOP_DEBUG_EN0		(0x0014)
#define CDC_RX_TOP_DEBUG_EN1		(0x0018)
#define CDC_RX_TOP_DEBUG_EN2		(0x001C)
#define CDC_RX_TOP_HPHL_COMP_WR_LSB	(0x0020)
#define CDC_RX_TOP_HPHL_COMP_WR_MSB	(0x0024)
#define CDC_RX_TOP_HPHL_COMP_LUT	(0x0028)
#define CDC_RX_TOP_HPH_LUT_BYPASS_MASK	BIT(7)
#define CDC_RX_TOP_HPHL_COMP_RD_LSB	(0x002C)
#define CDC_RX_TOP_HPHL_COMP_RD_MSB	(0x0030)
#define CDC_RX_TOP_HPHR_COMP_WR_LSB	(0x0034)
#define CDC_RX_TOP_HPHR_COMP_WR_MSB	(0x0038)
#define CDC_RX_TOP_HPHR_COMP_LUT	(0x003C)
#define CDC_RX_TOP_HPHR_COMP_RD_LSB	(0x0040)
#define CDC_RX_TOP_HPHR_COMP_RD_MSB	(0x0044)
#define CDC_RX_TOP_DSD0_DEBUG_CFG0	(0x0070)
#define CDC_RX_TOP_DSD0_DEBUG_CFG1	(0x0074)
#define CDC_RX_TOP_DSD0_DEBUG_CFG2	(0x0078)
#define CDC_RX_TOP_DSD0_DEBUG_CFG3	(0x007C)
#define CDC_RX_TOP_DSD1_DEBUG_CFG0	(0x0080)
#define CDC_RX_TOP_DSD1_DEBUG_CFG1	(0x0084)
#define CDC_RX_TOP_DSD1_DEBUG_CFG2	(0x0088)
#define CDC_RX_TOP_DSD1_DEBUG_CFG3	(0x008C)
#define CDC_RX_TOP_RX_I2S_CTL		(0x0090)
#define CDC_RX_TOP_TX_I2S2_CTL		(0x0094)
#define CDC_RX_TOP_I2S_CLK		(0x0098)
#define CDC_RX_TOP_I2S_RESET		(0x009C)
#define CDC_RX_TOP_I2S_MUX		(0x00A0)
#define CDC_RX_CLK_RST_CTRL_MCLK_CONTROL	(0x0100)
#define CDC_RX_CLK_MCLK_EN_MASK		BIT(0)
#define CDC_RX_CLK_MCLK_ENABLE		BIT(0)
#define CDC_RX_CLK_MCLK2_EN_MASK	BIT(1)
#define CDC_RX_CLK_MCLK2_ENABLE		BIT(1)
#define CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL	(0x0104)
#define CDC_RX_FS_MCLK_CNT_EN_MASK	BIT(0)
#define CDC_RX_FS_MCLK_CNT_ENABLE	BIT(0)
#define CDC_RX_FS_MCLK_CNT_CLR_MASK	BIT(1)
#define CDC_RX_FS_MCLK_CNT_CLR		BIT(1)
#define CDC_RX_CLK_RST_CTRL_SWR_CONTROL	(0x0108)
#define CDC_RX_SWR_CLK_EN_MASK		BIT(0)
#define CDC_RX_SWR_RESET_MASK		BIT(1)
#define CDC_RX_SWR_RESET		BIT(1)
#define CDC_RX_CLK_RST_CTRL_DSD_CONTROL	(0x010C)
#define CDC_RX_CLK_RST_CTRL_ASRC_SHARE_CONTROL	(0x0110)
#define CDC_RX_SOFTCLIP_CRC		(0x0140)
#define CDC_RX_SOFTCLIP_CLK_EN_MASK	BIT(0)
#define CDC_RX_SOFTCLIP_SOFTCLIP_CTRL	(0x0144)
#define CDC_RX_SOFTCLIP_EN_MASK		BIT(0)
#define CDC_RX_INP_MUX_RX_INT0_CFG0	(0x0180)
#define CDC_RX_INTX_1_MIX_INP0_SEL_MASK	GENMASK(3, 0)
#define CDC_RX_INTX_1_MIX_INP1_SEL_MASK	GENMASK(7, 4)
#define CDC_RX_INP_MUX_RX_INT0_CFG1	(0x0184)
#define CDC_RX_INTX_2_SEL_MASK		GENMASK(3, 0)
#define CDC_RX_INTX_1_MIX_INP2_SEL_MASK	GENMASK(7, 4)
#define CDC_RX_INP_MUX_RX_INT1_CFG0	(0x0188)
#define CDC_RX_INP_MUX_RX_INT1_CFG1	(0x018C)
#define CDC_RX_INP_MUX_RX_INT2_CFG0	(0x0190)
#define CDC_RX_INP_MUX_RX_INT2_CFG1	(0x0194)
#define CDC_RX_INP_MUX_RX_MIX_CFG4	(0x0198)
#define CDC_RX_INP_MUX_RX_MIX_CFG5	(0x019C)
#define CDC_RX_INP_MUX_SIDETONE_SRC_CFG0	(0x01A0)
#define CDC_RX_CLSH_CRC			(0x0200)
#define CDC_RX_CLSH_CLK_EN_MASK		BIT(0)
#define CDC_RX_CLSH_DLY_CTRL		(0x0204)
#define CDC_RX_CLSH_DECAY_CTRL		(0x0208)
#define CDC_RX_CLSH_DECAY_RATE_MASK	GENMASK(2, 0)
#define CDC_RX_CLSH_HPH_V_PA		(0x020C)
#define CDC_RX_CLSH_HPH_V_PA_MIN_MASK	GENMASK(5, 0)
#define CDC_RX_CLSH_EAR_V_PA		(0x0210)
#define CDC_RX_CLSH_HPH_V_HD		(0x0214)
#define CDC_RX_CLSH_EAR_V_HD		(0x0218)
#define CDC_RX_CLSH_K1_MSB		(0x021C)
#define CDC_RX_CLSH_K1_MSB_COEFF_MASK	GENMASK(3, 0)
#define CDC_RX_CLSH_K1_LSB		(0x0220)
#define CDC_RX_CLSH_K2_MSB		(0x0224)
#define CDC_RX_CLSH_K2_LSB		(0x0228)
#define CDC_RX_CLSH_IDLE_CTRL		(0x022C)
#define CDC_RX_CLSH_IDLE_HPH		(0x0230)
#define CDC_RX_CLSH_IDLE_EAR		(0x0234)
#define CDC_RX_CLSH_TEST0		(0x0238)
#define CDC_RX_CLSH_TEST1		(0x023C)
#define CDC_RX_CLSH_OVR_VREF		(0x0240)
#define CDC_RX_CLSH_CLSG_CTL		(0x0244)
#define CDC_RX_CLSH_CLSG_CFG1		(0x0248)
#define CDC_RX_CLSH_CLSG_CFG2		(0x024C)
#define CDC_RX_BCL_VBAT_PATH_CTL	(0x0280)
#define CDC_RX_BCL_VBAT_CFG		(0x0284)
#define CDC_RX_BCL_VBAT_ADC_CAL1	(0x0288)
#define CDC_RX_BCL_VBAT_ADC_CAL2	(0x028C)
#define CDC_RX_BCL_VBAT_ADC_CAL3	(0x0290)
#define CDC_RX_BCL_VBAT_PK_EST1		(0x0294)
#define CDC_RX_BCL_VBAT_PK_EST2		(0x0298)
#define CDC_RX_BCL_VBAT_PK_EST3		(0x029C)
#define CDC_RX_BCL_VBAT_RF_PROC1	(0x02A0)
#define CDC_RX_BCL_VBAT_RF_PROC2	(0x02A4)
#define CDC_RX_BCL_VBAT_TAC1		(0x02A8)
#define CDC_RX_BCL_VBAT_TAC2		(0x02AC)
#define CDC_RX_BCL_VBAT_TAC3		(0x02B0)
#define CDC_RX_BCL_VBAT_TAC4		(0x02B4)
#define CDC_RX_BCL_VBAT_GAIN_UPD1	(0x02B8)
#define CDC_RX_BCL_VBAT_GAIN_UPD2	(0x02BC)
#define CDC_RX_BCL_VBAT_GAIN_UPD3	(0x02C0)
#define CDC_RX_BCL_VBAT_GAIN_UPD4	(0x02C4)
#define CDC_RX_BCL_VBAT_GAIN_UPD5	(0x02C8)
#define CDC_RX_BCL_VBAT_DEBUG1		(0x02CC)
#define CDC_RX_BCL_VBAT_GAIN_UPD_MON	(0x02D0)
#define CDC_RX_BCL_VBAT_GAIN_MON_VAL	(0x02D4)
#define CDC_RX_BCL_VBAT_BAN		(0x02D8)
#define CDC_RX_BCL_VBAT_BCL_GAIN_UPD1	(0x02DC)
#define CDC_RX_BCL_VBAT_BCL_GAIN_UPD2	(0x02E0)
#define CDC_RX_BCL_VBAT_BCL_GAIN_UPD3	(0x02E4)
#define CDC_RX_BCL_VBAT_BCL_GAIN_UPD4	(0x02E8)
#define CDC_RX_BCL_VBAT_BCL_GAIN_UPD5	(0x02EC)
#define CDC_RX_BCL_VBAT_BCL_GAIN_UPD6	(0x02F0)
#define CDC_RX_BCL_VBAT_BCL_GAIN_UPD7	(0x02F4)
#define CDC_RX_BCL_VBAT_BCL_GAIN_UPD8	(0x02F8)
#define CDC_RX_BCL_VBAT_BCL_GAIN_UPD9	(0x02FC)
#define CDC_RX_BCL_VBAT_ATTN1		(0x0300)
#define CDC_RX_BCL_VBAT_ATTN2		(0x0304)
#define CDC_RX_BCL_VBAT_ATTN3		(0x0308)
#define CDC_RX_BCL_VBAT_DECODE_CTL1	(0x030C)
#define CDC_RX_BCL_VBAT_DECODE_CTL2	(0x0310)
#define CDC_RX_BCL_VBAT_DECODE_CFG1	(0x0314)
#define CDC_RX_BCL_VBAT_DECODE_CFG2	(0x0318)
#define CDC_RX_BCL_VBAT_DECODE_CFG3	(0x031C)
#define CDC_RX_BCL_VBAT_DECODE_CFG4	(0x0320)
#define CDC_RX_BCL_VBAT_DECODE_ST	(0x0324)
#define CDC_RX_INTR_CTRL_CFG		(0x0340)
#define CDC_RX_INTR_CTRL_CLR_COMMIT	(0x0344)
#define CDC_RX_INTR_CTRL_PIN1_MASK0	(0x0360)
#define CDC_RX_INTR_CTRL_PIN1_STATUS0	(0x0368)
#define CDC_RX_INTR_CTRL_PIN1_CLEAR0	(0x0370)
#define CDC_RX_INTR_CTRL_PIN2_MASK0	(0x0380)
#define CDC_RX_INTR_CTRL_PIN2_STATUS0	(0x0388)
#define CDC_RX_INTR_CTRL_PIN2_CLEAR0	(0x0390)
#define CDC_RX_INTR_CTRL_LEVEL0		(0x03C0)
#define CDC_RX_INTR_CTRL_BYPASS0	(0x03C8)
#define CDC_RX_INTR_CTRL_SET0		(0x03D0)
#define CDC_RX_RXn_RX_PATH_CTL(n)	(0x0400 + 0x80 * n)
#define CDC_RX_RX0_RX_PATH_CTL		(0x0400)
#define CDC_RX_PATH_RESET_EN_MASK	BIT(6)
#define CDC_RX_PATH_CLK_EN_MASK		BIT(5)
#define CDC_RX_PATH_CLK_ENABLE		BIT(5)
#define CDC_RX_PATH_PGA_MUTE_MASK	BIT(4)
#define CDC_RX_PATH_PGA_MUTE_ENABLE	BIT(4)
#define CDC_RX_PATH_PCM_RATE_MASK	GENMASK(3, 0)
#define CDC_RX_RXn_RX_PATH_CFG0(n)	(0x0404 + 0x80 * n)
#define CDC_RX_RXn_COMP_EN_MASK		BIT(1)
#define CDC_RX_RX0_RX_PATH_CFG0		(0x0404)
#define CDC_RX_RXn_CLSH_EN_MASK		BIT(6)
#define CDC_RX_DLY_ZN_EN_MASK		BIT(3)
#define CDC_RX_DLY_ZN_ENABLE		BIT(3)
#define CDC_RX_RXn_HD2_EN_MASK		BIT(2)
#define CDC_RX_RXn_RX_PATH_CFG1(n)	(0x0408 + 0x80 * n)
#define CDC_RX_RXn_SIDETONE_EN_MASK	BIT(4)
#define CDC_RX_RX0_RX_PATH_CFG1		(0x0408)
#define CDC_RX_RX0_HPH_L_EAR_SEL_MASK	BIT(1)
#define CDC_RX_RXn_RX_PATH_CFG2(n)	(0x040C + 0x80 * n)
#define CDC_RX_RXn_HPF_CUT_FREQ_MASK	GENMASK(1, 0)
#define CDC_RX_RX0_RX_PATH_CFG2		(0x040C)
#define CDC_RX_RXn_RX_PATH_CFG3(n)	(0x0410 + 0x80 * n)
#define CDC_RX_RX0_RX_PATH_CFG3		(0x0410)
#define CDC_RX_DC_COEFF_SEL_MASK	GENMASK(1, 0)
#define CDC_RX_DC_COEFF_SEL_TWO		0x2
#define CDC_RX_RXn_RX_VOL_CTL(n)	(0x0414 + 0x80 * n)
#define CDC_RX_RX0_RX_VOL_CTL		(0x0414)
#define CDC_RX_RXn_RX_PATH_MIX_CTL(n)	(0x0418 + 0x80 * n)
#define CDC_RX_RXn_MIX_PCM_RATE_MASK	GENMASK(3, 0)
#define CDC_RX_RXn_MIX_RESET_MASK	BIT(6)
#define CDC_RX_RXn_MIX_RESET		BIT(6)
#define CDC_RX_RXn_MIX_CLK_EN_MASK	BIT(5)
#define CDC_RX_RX0_RX_PATH_MIX_CTL	(0x0418)
#define CDC_RX_RX0_RX_PATH_MIX_CFG	(0x041C)
#define CDC_RX_RXn_RX_VOL_MIX_CTL(n)	(0x0420 + 0x80 * n)
#define CDC_RX_RX0_RX_VOL_MIX_CTL	(0x0420)
#define CDC_RX_RX0_RX_PATH_SEC1		(0x0424)
#define CDC_RX_RX0_RX_PATH_SEC2		(0x0428)
#define CDC_RX_RX0_RX_PATH_SEC3		(0x042C)
#define CDC_RX_RX0_RX_PATH_SEC4		(0x0430)
#define CDC_RX_RX0_RX_PATH_SEC7		(0x0434)
#define CDC_RX_DSM_OUT_DELAY_SEL_MASK	GENMASK(2, 0)
#define CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE	0x2
#define CDC_RX_RX0_RX_PATH_MIX_SEC0	(0x0438)
#define CDC_RX_RX0_RX_PATH_MIX_SEC1	(0x043C)
#define CDC_RX_RXn_RX_PATH_DSM_CTL(n)	(0x0440 + 0x80 * n)
#define CDC_RX_RXn_DSM_CLK_EN_MASK	BIT(0)
#define CDC_RX_RX0_RX_PATH_DSM_CTL	(0x0440)
#define CDC_RX_RX0_RX_PATH_DSM_DATA1	(0x0444)
#define CDC_RX_RX0_RX_PATH_DSM_DATA2	(0x0448)
#define CDC_RX_RX0_RX_PATH_DSM_DATA3	(0x044C)
#define CDC_RX_RX0_RX_PATH_DSM_DATA4	(0x0450)
#define CDC_RX_RX0_RX_PATH_DSM_DATA5	(0x0454)
#define CDC_RX_RX0_RX_PATH_DSM_DATA6	(0x0458)
#define CDC_RX_RX1_RX_PATH_CTL		(0x0480)
#define CDC_RX_RX1_RX_PATH_CFG0		(0x0484)
#define CDC_RX_RX1_RX_PATH_CFG1		(0x0488)
#define CDC_RX_RX1_RX_PATH_CFG2		(0x048C)
#define CDC_RX_RX1_RX_PATH_CFG3		(0x0490)
#define CDC_RX_RX1_RX_VOL_CTL		(0x0494)
#define CDC_RX_RX1_RX_PATH_MIX_CTL	(0x0498)
#define CDC_RX_RX1_RX_PATH_MIX_CFG	(0x049C)
#define CDC_RX_RX1_RX_VOL_MIX_CTL	(0x04A0)
#define CDC_RX_RX1_RX_PATH_SEC1		(0x04A4)
#define CDC_RX_RX1_RX_PATH_SEC2		(0x04A8)
#define CDC_RX_RX1_RX_PATH_SEC3		(0x04AC)
#define CDC_RX_RXn_HD2_ALPHA_MASK	GENMASK(5, 2)
#define CDC_RX_RX1_RX_PATH_SEC4		(0x04B0)
#define CDC_RX_RX1_RX_PATH_SEC7		(0x04B4)
#define CDC_RX_RX1_RX_PATH_MIX_SEC0	(0x04B8)
#define CDC_RX_RX1_RX_PATH_MIX_SEC1	(0x04BC)
#define CDC_RX_RX1_RX_PATH_DSM_CTL	(0x04C0)
#define CDC_RX_RX1_RX_PATH_DSM_DATA1	(0x04C4)
#define CDC_RX_RX1_RX_PATH_DSM_DATA2	(0x04C8)
#define CDC_RX_RX1_RX_PATH_DSM_DATA3	(0x04CC)
#define CDC_RX_RX1_RX_PATH_DSM_DATA4	(0x04D0)
#define CDC_RX_RX1_RX_PATH_DSM_DATA5	(0x04D4)
#define CDC_RX_RX1_RX_PATH_DSM_DATA6	(0x04D8)
#define CDC_RX_RX2_RX_PATH_CTL		(0x0500)
#define CDC_RX_RX2_RX_PATH_CFG0		(0x0504)
#define CDC_RX_RX2_CLSH_EN_MASK		BIT(4)
#define CDC_RX_RX2_DLY_Z_EN_MASK	BIT(3)
#define CDC_RX_RX2_RX_PATH_CFG1		(0x0508)
#define CDC_RX_RX2_RX_PATH_CFG2		(0x050C)
#define CDC_RX_RX2_RX_PATH_CFG3		(0x0510)
#define CDC_RX_RX2_RX_VOL_CTL		(0x0514)
#define CDC_RX_RX2_RX_PATH_MIX_CTL	(0x0518)
#define CDC_RX_RX2_RX_PATH_MIX_CFG	(0x051C)
#define CDC_RX_RX2_RX_VOL_MIX_CTL	(0x0520)
#define CDC_RX_RX2_RX_PATH_SEC0		(0x0524)
#define CDC_RX_RX2_RX_PATH_SEC1		(0x0528)
#define CDC_RX_RX2_RX_PATH_SEC2		(0x052C)
#define CDC_RX_RX2_RX_PATH_SEC3		(0x0530)
#define CDC_RX_RX2_RX_PATH_SEC4		(0x0534)
#define CDC_RX_RX2_RX_PATH_SEC5		(0x0538)
#define CDC_RX_RX2_RX_PATH_SEC6		(0x053C)
#define CDC_RX_RX2_RX_PATH_SEC7		(0x0540)
#define CDC_RX_RX2_RX_PATH_MIX_SEC0	(0x0544)
#define CDC_RX_RX2_RX_PATH_MIX_SEC1	(0x0548)
#define CDC_RX_RX2_RX_PATH_DSM_CTL	(0x054C)
#define CDC_RX_IDLE_DETECT_PATH_CTL	(0x0780)
#define CDC_RX_IDLE_DETECT_CFG0		(0x0784)
#define CDC_RX_IDLE_DETECT_CFG1		(0x0788)
#define CDC_RX_IDLE_DETECT_CFG2		(0x078C)
#define CDC_RX_IDLE_DETECT_CFG3		(0x0790)
#define CDC_RX_COMPANDERn_CTL0(n)	(0x0800 + 0x40 * n)
#define CDC_RX_COMPANDERn_CLK_EN_MASK	BIT(0)
#define CDC_RX_COMPANDERn_SOFT_RST_MASK	BIT(1)
#define CDC_RX_COMPANDERn_HALT_MASK	BIT(2)
#define CDC_RX_COMPANDER0_CTL0		(0x0800)
#define CDC_RX_COMPANDER0_CTL1		(0x0804)
#define CDC_RX_COMPANDER0_CTL2		(0x0808)
#define CDC_RX_COMPANDER0_CTL3		(0x080C)
#define CDC_RX_COMPANDER0_CTL4		(0x0810)
#define CDC_RX_COMPANDER0_CTL5		(0x0814)
#define CDC_RX_COMPANDER0_CTL6		(0x0818)
#define CDC_RX_COMPANDER0_CTL7		(0x081C)
#define CDC_RX_COMPANDER1_CTL0		(0x0840)
#define CDC_RX_COMPANDER1_CTL1		(0x0844)
#define CDC_RX_COMPANDER1_CTL2		(0x0848)
#define CDC_RX_COMPANDER1_CTL3		(0x084C)
#define CDC_RX_COMPANDER1_CTL4		(0x0850)
#define CDC_RX_COMPANDER1_CTL5		(0x0854)
#define CDC_RX_COMPANDER1_CTL6		(0x0858)
#define CDC_RX_COMPANDER1_CTL7		(0x085C)
#define CDC_RX_COMPANDER1_HPH_LOW_PWR_MODE_MASK	BIT(5)
#define CDC_RX_SIDETONE_IIR0_IIR_PATH_CTL	(0x0A00)
#define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL	(0x0A04)
#define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL	(0x0A08)
#define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL	(0x0A0C)
#define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL	(0x0A10)
#define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B5_CTL	(0x0A14)
#define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B6_CTL	(0x0A18)
#define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B7_CTL	(0x0A1C)
#define CDC_RX_SIDETONE_IIR0_IIR_GAIN_B8_CTL	(0x0A20)
#define CDC_RX_SIDETONE_IIR0_IIR_CTL		(0x0A24)
#define CDC_RX_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL	(0x0A28)
#define CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL	(0x0A2C)
#define CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL	(0x0A30)
#define CDC_RX_SIDETONE_IIR1_IIR_PATH_CTL	(0x0A80)
#define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL	(0x0A84)
#define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL	(0x0A88)
#define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL	(0x0A8C)
#define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL	(0x0A90)
#define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B5_CTL	(0x0A94)
#define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B6_CTL	(0x0A98)
#define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B7_CTL	(0x0A9C)
#define CDC_RX_SIDETONE_IIR1_IIR_GAIN_B8_CTL	(0x0AA0)
#define CDC_RX_SIDETONE_IIR1_IIR_CTL		(0x0AA4)
#define CDC_RX_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL	(0x0AA8)
#define CDC_RX_SIDETONE_IIR1_IIR_COEF_B1_CTL	(0x0AAC)
#define CDC_RX_SIDETONE_IIR1_IIR_COEF_B2_CTL	(0x0AB0)
#define CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG0	(0x0B00)
#define CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG1	(0x0B04)
#define CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG2	(0x0B08)
#define CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG3	(0x0B0C)
#define CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG0	(0x0B10)
#define CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG1	(0x0B14)
#define CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG2	(0x0B18)
#define CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG3	(0x0B1C)
#define CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CTL	(0x0B40)
#define CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CFG1	(0x0B44)
#define CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CTL	(0x0B50)
#define CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CFG1	(0x0B54)
#define CDC_RX_EC_REF_HQ0_EC_REF_HQ_PATH_CTL	(0x0C00)
#define CDC_RX_EC_REF_HQ0_EC_REF_HQ_CFG0	(0x0C04)
#define CDC_RX_EC_REF_HQ1_EC_REF_HQ_PATH_CTL	(0x0C40)
#define CDC_RX_EC_REF_HQ1_EC_REF_HQ_CFG0	(0x0C44)
#define CDC_RX_EC_REF_HQ2_EC_REF_HQ_PATH_CTL	(0x0C80)
#define CDC_RX_EC_REF_HQ2_EC_REF_HQ_CFG0	(0x0C84)
#define CDC_RX_EC_ASRC0_CLK_RST_CTL		(0x0D00)
#define CDC_RX_EC_ASRC0_CTL0			(0x0D04)
#define CDC_RX_EC_ASRC0_CTL1			(0x0D08)
#define CDC_RX_EC_ASRC0_FIFO_CTL		(0x0D0C)
#define CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_LSB	(0x0D10)
#define CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_MSB	(0x0D14)
#define CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_LSB	(0x0D18)
#define CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_MSB	(0x0D1C)
#define CDC_RX_EC_ASRC0_STATUS_FIFO		(0x0D20)
#define CDC_RX_EC_ASRC1_CLK_RST_CTL		(0x0D40)
#define CDC_RX_EC_ASRC1_CTL0			(0x0D44)
#define CDC_RX_EC_ASRC1_CTL1			(0x0D48)
#define CDC_RX_EC_ASRC1_FIFO_CTL		(0x0D4C)
#define CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_LSB	(0x0D50)
#define CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_MSB	(0x0D54)
#define CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_LSB	(0x0D58)
#define CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_MSB	(0x0D5C)
#define CDC_RX_EC_ASRC1_STATUS_FIFO		(0x0D60)
#define CDC_RX_EC_ASRC2_CLK_RST_CTL		(0x0D80)
#define CDC_RX_EC_ASRC2_CTL0			(0x0D84)
#define CDC_RX_EC_ASRC2_CTL1			(0x0D88)
#define CDC_RX_EC_ASRC2_FIFO_CTL		(0x0D8C)
#define CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_LSB	(0x0D90)
#define CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_MSB	(0x0D94)
#define CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_LSB	(0x0D98)
#define CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_MSB	(0x0D9C)
#define CDC_RX_EC_ASRC2_STATUS_FIFO		(0x0DA0)
#define CDC_RX_DSD0_PATH_CTL			(0x0F00)
#define CDC_RX_DSD0_CFG0			(0x0F04)
#define CDC_RX_DSD0_CFG1			(0x0F08)
#define CDC_RX_DSD0_CFG2			(0x0F0C)
#define CDC_RX_DSD1_PATH_CTL			(0x0F80)
#define CDC_RX_DSD1_CFG0			(0x0F84)
#define CDC_RX_DSD1_CFG1			(0x0F88)
#define CDC_RX_DSD1_CFG2			(0x0F8C)
#define RX_MAX_OFFSET				(0x0F8C)

#define MCLK_FREQ		9600000

#define RX_MACRO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
			SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000 |\
			SNDRV_PCM_RATE_384000)
/* Fractional Rates */
#define RX_MACRO_FRAC_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\
				SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_352800)

#define RX_MACRO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
		SNDRV_PCM_FMTBIT_S24_LE |\
		SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE)

#define RX_MACRO_ECHO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
			SNDRV_PCM_RATE_48000)
#define RX_MACRO_ECHO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
		SNDRV_PCM_FMTBIT_S24_LE |\
		SNDRV_PCM_FMTBIT_S24_3LE)

#define RX_MACRO_MAX_DMA_CH_PER_PORT 2

#define RX_MACRO_EC_MIX_TX0_MASK 0xf0
#define RX_MACRO_EC_MIX_TX1_MASK 0x0f
#define RX_MACRO_EC_MIX_TX2_MASK 0x0f

#define COMP_MAX_COEFF 25
#define RX_NUM_CLKS_MAX	5

struct comp_coeff_val {
	u8 lsb;
	u8 msb;
};

enum {
	HPH_ULP,
	HPH_LOHIFI,
	HPH_MODE_MAX,
};

static const struct comp_coeff_val comp_coeff_table[HPH_MODE_MAX][COMP_MAX_COEFF] = {
	{
		{0x40, 0x00},
		{0x4C, 0x00},
		{0x5A, 0x00},
		{0x6B, 0x00},
		{0x7F, 0x00},
		{0x97, 0x00},
		{0xB3, 0x00},
		{0xD5, 0x00},
		{0xFD, 0x00},
		{0x2D, 0x01},
		{0x66, 0x01},
		{0xA7, 0x01},
		{0xF8, 0x01},
		{0x57, 0x02},
		{0xC7, 0x02},
		{0x4B, 0x03},
		{0xE9, 0x03},
		{0xA3, 0x04},
		{0x7D, 0x05},
		{0x90, 0x06},
		{0xD1, 0x07},
		{0x49, 0x09},
		{0x00, 0x0B},
		{0x01, 0x0D},
		{0x59, 0x0F},
	},
	{
		{0x40, 0x00},
		{0x4C, 0x00},
		{0x5A, 0x00},
		{0x6B, 0x00},
		{0x80, 0x00},
		{0x98, 0x00},
		{0xB4, 0x00},
		{0xD5, 0x00},
		{0xFE, 0x00},
		{0x2E, 0x01},
		{0x66, 0x01},
		{0xA9, 0x01},
		{0xF8, 0x01},
		{0x56, 0x02},
		{0xC4, 0x02},
		{0x4F, 0x03},
		{0xF0, 0x03},
		{0xAE, 0x04},
		{0x8B, 0x05},
		{0x8E, 0x06},
		{0xBC, 0x07},
		{0x56, 0x09},
		{0x0F, 0x0B},
		{0x13, 0x0D},
		{0x6F, 0x0F},
	},
};

struct rx_macro_reg_mask_val {
	u16 reg;
	u8 mask;
	u8 val;
};

enum {
	INTERP_HPHL,
	INTERP_HPHR,
	INTERP_AUX,
	INTERP_MAX
};

enum {
	RX_MACRO_RX0,
	RX_MACRO_RX1,
	RX_MACRO_RX2,
	RX_MACRO_RX3,
	RX_MACRO_RX4,
	RX_MACRO_RX5,
	RX_MACRO_PORTS_MAX
};

enum {
	RX_MACRO_COMP1, /* HPH_L */
	RX_MACRO_COMP2, /* HPH_R */
	RX_MACRO_COMP_MAX
};

enum {
	RX_MACRO_EC0_MUX = 0,
	RX_MACRO_EC1_MUX,
	RX_MACRO_EC2_MUX,
	RX_MACRO_EC_MUX_MAX,
};

enum {
	INTn_1_INP_SEL_ZERO = 0,
	INTn_1_INP_SEL_DEC0,
	INTn_1_INP_SEL_DEC1,
	INTn_1_INP_SEL_IIR0,
	INTn_1_INP_SEL_IIR1,
	INTn_1_INP_SEL_RX0,
	INTn_1_INP_SEL_RX1,
	INTn_1_INP_SEL_RX2,
	INTn_1_INP_SEL_RX3,
	INTn_1_INP_SEL_RX4,
	INTn_1_INP_SEL_RX5,
};

enum {
	INTn_2_INP_SEL_ZERO = 0,
	INTn_2_INP_SEL_RX0,
	INTn_2_INP_SEL_RX1,
	INTn_2_INP_SEL_RX2,
	INTn_2_INP_SEL_RX3,
	INTn_2_INP_SEL_RX4,
	INTn_2_INP_SEL_RX5,
};

enum {
	INTERP_MAIN_PATH,
	INTERP_MIX_PATH,
};

/* Codec supports 2 IIR filters */
enum {
	IIR0 = 0,
	IIR1,
	IIR_MAX,
};

/* Each IIR has 5 Filter Stages */
enum {
	BAND1 = 0,
	BAND2,
	BAND3,
	BAND4,
	BAND5,
	BAND_MAX,
};

#define RX_MACRO_IIR_FILTER_SIZE	(sizeof(u32) * BAND_MAX)

#define RX_MACRO_IIR_FILTER_CTL(xname, iidx, bidx) \
{ \
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
	.info = rx_macro_iir_filter_info, \
	.get = rx_macro_get_iir_band_audio_mixer, \
	.put = rx_macro_put_iir_band_audio_mixer, \
	.private_value = (unsigned long)&(struct wcd_iir_filter_ctl) { \
		.iir_idx = iidx, \
		.band_idx = bidx, \
		.bytes_ext = {.max = RX_MACRO_IIR_FILTER_SIZE, }, \
	} \
}

struct interp_sample_rate {
	int sample_rate;
	int rate_val;
};

static struct interp_sample_rate sr_val_tbl[] = {
	{8000, 0x0}, {16000, 0x1}, {32000, 0x3}, {48000, 0x4}, {96000, 0x5},
	{192000, 0x6}, {384000, 0x7}, {44100, 0x9}, {88200, 0xA},
	{176400, 0xB}, {352800, 0xC},
};

enum {
	RX_MACRO_AIF_INVALID = 0,
	RX_MACRO_AIF1_PB,
	RX_MACRO_AIF2_PB,
	RX_MACRO_AIF3_PB,
	RX_MACRO_AIF4_PB,
	RX_MACRO_AIF_ECHO,
	RX_MACRO_MAX_DAIS,
};

enum {
	RX_MACRO_AIF1_CAP = 0,
	RX_MACRO_AIF2_CAP,
	RX_MACRO_AIF3_CAP,
	RX_MACRO_MAX_AIF_CAP_DAIS
};

struct rx_macro {
	struct device *dev;
	int comp_enabled[RX_MACRO_COMP_MAX];
	/* Main path clock users count */
	int main_clk_users[INTERP_MAX];
	int rx_port_value[RX_MACRO_PORTS_MAX];
	u16 prim_int_users[INTERP_MAX];
	int rx_mclk_users;
	bool reset_swr;
	int clsh_users;
	int rx_mclk_cnt;
	bool is_ear_mode_on;
	bool hph_pwr_mode;
	bool hph_hd2_mode;
	struct snd_soc_component *component;
	unsigned long active_ch_mask[RX_MACRO_MAX_DAIS];
	unsigned long active_ch_cnt[RX_MACRO_MAX_DAIS];
	u16 bit_width[RX_MACRO_MAX_DAIS];
	int is_softclip_on;
	int is_aux_hpf_on;
	int softclip_clk_users;

	struct regmap *regmap;
	struct clk_bulk_data clks[RX_NUM_CLKS_MAX];
	struct clk_hw hw;
};
#define to_rx_macro(_hw) container_of(_hw, struct rx_macro, hw)

struct wcd_iir_filter_ctl {
	unsigned int iir_idx;
	unsigned int band_idx;
	struct soc_bytes_ext bytes_ext;
};

static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);

static const char * const rx_int_mix_mux_text[] = {
	"ZERO", "RX0", "RX1", "RX2", "RX3", "RX4", "RX5"
};

static const char * const rx_prim_mix_text[] = {
	"ZERO", "DEC0", "DEC1", "IIR0", "IIR1", "RX0", "RX1", "RX2",
	"RX3", "RX4", "RX5"
};

static const char * const rx_sidetone_mix_text[] = {
	"ZERO", "SRC0", "SRC1", "SRC_SUM"
};

static const char * const iir_inp_mux_text[] = {
	"ZERO", "DEC0", "DEC1", "DEC2", "DEC3",
	"RX0", "RX1", "RX2", "RX3", "RX4", "RX5"
};

static const char * const rx_int_dem_inp_mux_text[] = {
	"NORMAL_DSM_OUT", "CLSH_DSM_OUT",
};

static const char * const rx_int0_1_interp_mux_text[] = {
	"ZERO", "RX INT0_1 MIX1",
};

static const char * const rx_int1_1_interp_mux_text[] = {
	"ZERO", "RX INT1_1 MIX1",
};

static const char * const rx_int2_1_interp_mux_text[] = {
	"ZERO", "RX INT2_1 MIX1",
};

static const char * const rx_int0_2_interp_mux_text[] = {
	"ZERO", "RX INT0_2 MUX",
};

static const char * const rx_int1_2_interp_mux_text[] = {
	"ZERO", "RX INT1_2 MUX",
};

static const char * const rx_int2_2_interp_mux_text[] = {
	"ZERO", "RX INT2_2 MUX",
};

static const char *const rx_macro_mux_text[] = {
	"ZERO", "AIF1_PB", "AIF2_PB", "AIF3_PB", "AIF4_PB"
};

static const char *const rx_macro_hph_pwr_mode_text[] = {
	"ULP", "LOHIFI"
};

static const char * const rx_echo_mux_text[] = {
	"ZERO", "RX_MIX0", "RX_MIX1", "RX_MIX2"
};

static const struct soc_enum rx_macro_hph_pwr_mode_enum =
		SOC_ENUM_SINGLE_EXT(2, rx_macro_hph_pwr_mode_text);
static const struct soc_enum rx_mix_tx2_mux_enum =
		SOC_ENUM_SINGLE(CDC_RX_INP_MUX_RX_MIX_CFG5, 0, 4, rx_echo_mux_text);
static const struct soc_enum rx_mix_tx1_mux_enum =
		SOC_ENUM_SINGLE(CDC_RX_INP_MUX_RX_MIX_CFG4, 0, 4, rx_echo_mux_text);
static const struct soc_enum rx_mix_tx0_mux_enum =
		SOC_ENUM_SINGLE(CDC_RX_INP_MUX_RX_MIX_CFG4, 4, 4, rx_echo_mux_text);

static SOC_ENUM_SINGLE_DECL(rx_int0_2_enum, CDC_RX_INP_MUX_RX_INT0_CFG1, 0,
			    rx_int_mix_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_int1_2_enum, CDC_RX_INP_MUX_RX_INT1_CFG1, 0,
			    rx_int_mix_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_int2_2_enum, CDC_RX_INP_MUX_RX_INT2_CFG1, 0,
			    rx_int_mix_mux_text);

static SOC_ENUM_SINGLE_DECL(rx_int0_1_mix_inp0_enum, CDC_RX_INP_MUX_RX_INT0_CFG0, 0,
			    rx_prim_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int0_1_mix_inp1_enum, CDC_RX_INP_MUX_RX_INT0_CFG0, 4,
			    rx_prim_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int0_1_mix_inp2_enum, CDC_RX_INP_MUX_RX_INT0_CFG1, 4,
			    rx_prim_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int1_1_mix_inp0_enum, CDC_RX_INP_MUX_RX_INT1_CFG0, 0,
			    rx_prim_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int1_1_mix_inp1_enum, CDC_RX_INP_MUX_RX_INT1_CFG0, 4,
			    rx_prim_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int1_1_mix_inp2_enum, CDC_RX_INP_MUX_RX_INT1_CFG1, 4,
			    rx_prim_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int2_1_mix_inp0_enum, CDC_RX_INP_MUX_RX_INT2_CFG0, 0,
			    rx_prim_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int2_1_mix_inp1_enum, CDC_RX_INP_MUX_RX_INT2_CFG0, 4,
			    rx_prim_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int2_1_mix_inp2_enum, CDC_RX_INP_MUX_RX_INT2_CFG1, 4,
			    rx_prim_mix_text);

static SOC_ENUM_SINGLE_DECL(rx_int0_mix2_inp_enum, CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 2,
			    rx_sidetone_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int1_mix2_inp_enum, CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 4,
			    rx_sidetone_mix_text);
static SOC_ENUM_SINGLE_DECL(rx_int2_mix2_inp_enum, CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 6,
			    rx_sidetone_mix_text);
static SOC_ENUM_SINGLE_DECL(iir0_inp0_enum, CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG0, 0,
			    iir_inp_mux_text);
static SOC_ENUM_SINGLE_DECL(iir0_inp1_enum, CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG1, 0,
			    iir_inp_mux_text);
static SOC_ENUM_SINGLE_DECL(iir0_inp2_enum, CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG2, 0,
			    iir_inp_mux_text);
static SOC_ENUM_SINGLE_DECL(iir0_inp3_enum, CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG3, 0,
			    iir_inp_mux_text);
static SOC_ENUM_SINGLE_DECL(iir1_inp0_enum, CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG0, 0,
			    iir_inp_mux_text);
static SOC_ENUM_SINGLE_DECL(iir1_inp1_enum, CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG1, 0,
			    iir_inp_mux_text);
static SOC_ENUM_SINGLE_DECL(iir1_inp2_enum, CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG2, 0,
			    iir_inp_mux_text);
static SOC_ENUM_SINGLE_DECL(iir1_inp3_enum, CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG3, 0,
			    iir_inp_mux_text);

static SOC_ENUM_SINGLE_DECL(rx_int0_1_interp_enum, SND_SOC_NOPM, 0,
			    rx_int0_1_interp_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_int1_1_interp_enum, SND_SOC_NOPM, 0,
			    rx_int1_1_interp_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_int2_1_interp_enum, SND_SOC_NOPM, 0,
			    rx_int2_1_interp_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_int0_2_interp_enum, SND_SOC_NOPM, 0,
			    rx_int0_2_interp_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_int1_2_interp_enum, SND_SOC_NOPM, 0,
			    rx_int1_2_interp_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_int2_2_interp_enum, SND_SOC_NOPM, 0,
			    rx_int2_2_interp_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_int0_dem_inp_enum, CDC_RX_RX0_RX_PATH_CFG1, 0,
			    rx_int_dem_inp_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_int1_dem_inp_enum, CDC_RX_RX1_RX_PATH_CFG1, 0,
			    rx_int_dem_inp_mux_text);

static SOC_ENUM_SINGLE_DECL(rx_macro_rx0_enum, SND_SOC_NOPM, 0, rx_macro_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_macro_rx1_enum, SND_SOC_NOPM, 0, rx_macro_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_macro_rx2_enum, SND_SOC_NOPM, 0, rx_macro_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_macro_rx3_enum, SND_SOC_NOPM, 0, rx_macro_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_macro_rx4_enum, SND_SOC_NOPM, 0, rx_macro_mux_text);
static SOC_ENUM_SINGLE_DECL(rx_macro_rx5_enum, SND_SOC_NOPM, 0, rx_macro_mux_text);

static const struct snd_kcontrol_new rx_mix_tx1_mux =
		SOC_DAPM_ENUM("RX MIX TX1_MUX Mux", rx_mix_tx1_mux_enum);
static const struct snd_kcontrol_new rx_mix_tx2_mux = 
		SOC_DAPM_ENUM("RX MIX TX2_MUX Mux", rx_mix_tx2_mux_enum);
static const struct snd_kcontrol_new rx_int0_2_mux =
		SOC_DAPM_ENUM("rx_int0_2", rx_int0_2_enum);
static const struct snd_kcontrol_new rx_int1_2_mux =
		SOC_DAPM_ENUM("rx_int1_2", rx_int1_2_enum);
static const struct snd_kcontrol_new rx_int2_2_mux =
		SOC_DAPM_ENUM("rx_int2_2", rx_int2_2_enum);
static const struct snd_kcontrol_new rx_int0_1_mix_inp0_mux =
		SOC_DAPM_ENUM("rx_int0_1_mix_inp0", rx_int0_1_mix_inp0_enum);
static const struct snd_kcontrol_new rx_int0_1_mix_inp1_mux =
		SOC_DAPM_ENUM("rx_int0_1_mix_inp1", rx_int0_1_mix_inp1_enum);
static const struct snd_kcontrol_new rx_int0_1_mix_inp2_mux =
		SOC_DAPM_ENUM("rx_int0_1_mix_inp2", rx_int0_1_mix_inp2_enum);
static const struct snd_kcontrol_new rx_int1_1_mix_inp0_mux =
		SOC_DAPM_ENUM("rx_int1_1_mix_inp0", rx_int1_1_mix_inp0_enum);
static const struct snd_kcontrol_new rx_int1_1_mix_inp1_mux =
		SOC_DAPM_ENUM("rx_int1_1_mix_inp1", rx_int1_1_mix_inp1_enum);
static const struct snd_kcontrol_new rx_int1_1_mix_inp2_mux =
		SOC_DAPM_ENUM("rx_int1_1_mix_inp2", rx_int1_1_mix_inp2_enum);
static const struct snd_kcontrol_new rx_int2_1_mix_inp0_mux =
		SOC_DAPM_ENUM("rx_int2_1_mix_inp0", rx_int2_1_mix_inp0_enum);
static const struct snd_kcontrol_new rx_int2_1_mix_inp1_mux =
		SOC_DAPM_ENUM("rx_int2_1_mix_inp1", rx_int2_1_mix_inp1_enum);
static const struct snd_kcontrol_new rx_int2_1_mix_inp2_mux =
		SOC_DAPM_ENUM("rx_int2_1_mix_inp2", rx_int2_1_mix_inp2_enum);
static const struct snd_kcontrol_new rx_int0_mix2_inp_mux =
		SOC_DAPM_ENUM("rx_int0_mix2_inp", rx_int0_mix2_inp_enum);
static const struct snd_kcontrol_new rx_int1_mix2_inp_mux =
		SOC_DAPM_ENUM("rx_int1_mix2_inp", rx_int1_mix2_inp_enum);
static const struct snd_kcontrol_new rx_int2_mix2_inp_mux =
		SOC_DAPM_ENUM("rx_int2_mix2_inp", rx_int2_mix2_inp_enum);
static const struct snd_kcontrol_new iir0_inp0_mux =
		SOC_DAPM_ENUM("iir0_inp0", iir0_inp0_enum);
static const struct snd_kcontrol_new iir0_inp1_mux =
		SOC_DAPM_ENUM("iir0_inp1", iir0_inp1_enum);
static const struct snd_kcontrol_new iir0_inp2_mux =
		SOC_DAPM_ENUM("iir0_inp2", iir0_inp2_enum);
static const struct snd_kcontrol_new iir0_inp3_mux =
		SOC_DAPM_ENUM("iir0_inp3", iir0_inp3_enum);
static const struct snd_kcontrol_new iir1_inp0_mux =
		SOC_DAPM_ENUM("iir1_inp0", iir1_inp0_enum);
static const struct snd_kcontrol_new iir1_inp1_mux =
		SOC_DAPM_ENUM("iir1_inp1", iir1_inp1_enum);
static const struct snd_kcontrol_new iir1_inp2_mux =
		SOC_DAPM_ENUM("iir1_inp2", iir1_inp2_enum);
static const struct snd_kcontrol_new iir1_inp3_mux =
		SOC_DAPM_ENUM("iir1_inp3", iir1_inp3_enum);
static const struct snd_kcontrol_new rx_int0_1_interp_mux =
		SOC_DAPM_ENUM("rx_int0_1_interp", rx_int0_1_interp_enum);
static const struct snd_kcontrol_new rx_int1_1_interp_mux =
		SOC_DAPM_ENUM("rx_int1_1_interp", rx_int1_1_interp_enum);
static const struct snd_kcontrol_new rx_int2_1_interp_mux =
		SOC_DAPM_ENUM("rx_int2_1_interp", rx_int2_1_interp_enum);
static const struct snd_kcontrol_new rx_int0_2_interp_mux =
		SOC_DAPM_ENUM("rx_int0_2_interp", rx_int0_2_interp_enum);
static const struct snd_kcontrol_new rx_int1_2_interp_mux =
		SOC_DAPM_ENUM("rx_int1_2_interp", rx_int1_2_interp_enum);
static const struct snd_kcontrol_new rx_int2_2_interp_mux =
		SOC_DAPM_ENUM("rx_int2_2_interp", rx_int2_2_interp_enum);
static const struct snd_kcontrol_new rx_mix_tx0_mux =
		SOC_DAPM_ENUM("RX MIX TX0_MUX Mux", rx_mix_tx0_mux_enum);

static const struct reg_default rx_defaults[] = {
	/* RX Macro */
	{ CDC_RX_TOP_TOP_CFG0, 0x00 },
	{ CDC_RX_TOP_SWR_CTRL, 0x00 },
	{ CDC_RX_TOP_DEBUG, 0x00 },
	{ CDC_RX_TOP_DEBUG_BUS, 0x00 },
	{ CDC_RX_TOP_DEBUG_EN0, 0x00 },
	{ CDC_RX_TOP_DEBUG_EN1, 0x00 },
	{ CDC_RX_TOP_DEBUG_EN2, 0x00 },
	{ CDC_RX_TOP_HPHL_COMP_WR_LSB, 0x00 },
	{ CDC_RX_TOP_HPHL_COMP_WR_MSB, 0x00 },
	{ CDC_RX_TOP_HPHL_COMP_LUT, 0x00 },
	{ CDC_RX_TOP_HPHL_COMP_RD_LSB, 0x00 },
	{ CDC_RX_TOP_HPHL_COMP_RD_MSB, 0x00 },
	{ CDC_RX_TOP_HPHR_COMP_WR_LSB, 0x00 },
	{ CDC_RX_TOP_HPHR_COMP_WR_MSB, 0x00 },
	{ CDC_RX_TOP_HPHR_COMP_LUT, 0x00 },
	{ CDC_RX_TOP_HPHR_COMP_RD_LSB, 0x00 },
	{ CDC_RX_TOP_HPHR_COMP_RD_MSB, 0x00 },
	{ CDC_RX_TOP_DSD0_DEBUG_CFG0, 0x11 },
	{ CDC_RX_TOP_DSD0_DEBUG_CFG1, 0x20 },
	{ CDC_RX_TOP_DSD0_DEBUG_CFG2, 0x00 },
	{ CDC_RX_TOP_DSD0_DEBUG_CFG3, 0x00 },
	{ CDC_RX_TOP_DSD1_DEBUG_CFG0, 0x11 },
	{ CDC_RX_TOP_DSD1_DEBUG_CFG1, 0x20 },
	{ CDC_RX_TOP_DSD1_DEBUG_CFG2, 0x00 },
	{ CDC_RX_TOP_DSD1_DEBUG_CFG3, 0x00 },
	{ CDC_RX_TOP_RX_I2S_CTL, 0x0C },
	{ CDC_RX_TOP_TX_I2S2_CTL, 0x0C },
	{ CDC_RX_TOP_I2S_CLK, 0x0C },
	{ CDC_RX_TOP_I2S_RESET, 0x00 },
	{ CDC_RX_TOP_I2S_MUX, 0x00 },
	{ CDC_RX_CLK_RST_CTRL_MCLK_CONTROL, 0x00 },
	{ CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL, 0x00 },
	{ CDC_RX_CLK_RST_CTRL_SWR_CONTROL, 0x00 },
	{ CDC_RX_CLK_RST_CTRL_DSD_CONTROL, 0x00 },
	{ CDC_RX_CLK_RST_CTRL_ASRC_SHARE_CONTROL, 0x08 },
	{ CDC_RX_SOFTCLIP_CRC, 0x00 },
	{ CDC_RX_SOFTCLIP_SOFTCLIP_CTRL, 0x38 },
	{ CDC_RX_INP_MUX_RX_INT0_CFG0, 0x00 },
	{ CDC_RX_INP_MUX_RX_INT0_CFG1, 0x00 },
	{ CDC_RX_INP_MUX_RX_INT1_CFG0, 0x00 },
	{ CDC_RX_INP_MUX_RX_INT1_CFG1, 0x00 },
	{ CDC_RX_INP_MUX_RX_INT2_CFG0, 0x00 },
	{ CDC_RX_INP_MUX_RX_INT2_CFG1, 0x00 },
	{ CDC_RX_INP_MUX_RX_MIX_CFG4, 0x00 },
	{ CDC_RX_INP_MUX_RX_MIX_CFG5, 0x00 },
	{ CDC_RX_INP_MUX_SIDETONE_SRC_CFG0, 0x00 },
	{ CDC_RX_CLSH_CRC, 0x00 },
	{ CDC_RX_CLSH_DLY_CTRL, 0x03 },
	{ CDC_RX_CLSH_DECAY_CTRL, 0x02 },
	{ CDC_RX_CLSH_HPH_V_PA, 0x1C },
	{ CDC_RX_CLSH_EAR_V_PA, 0x39 },
	{ CDC_RX_CLSH_HPH_V_HD, 0x0C },
	{ CDC_RX_CLSH_EAR_V_HD, 0x0C },
	{ CDC_RX_CLSH_K1_MSB, 0x01 },
	{ CDC_RX_CLSH_K1_LSB, 0x00 },
	{ CDC_RX_CLSH_K2_MSB, 0x00 },
	{ CDC_RX_CLSH_K2_LSB, 0x80 },
	{ CDC_RX_CLSH_IDLE_CTRL, 0x00 },
	{ CDC_RX_CLSH_IDLE_HPH, 0x00 },
	{ CDC_RX_CLSH_IDLE_EAR, 0x00 },
	{ CDC_RX_CLSH_TEST0, 0x07 },
	{ CDC_RX_CLSH_TEST1, 0x00 },
	{ CDC_RX_CLSH_OVR_VREF, 0x00 },
	{ CDC_RX_CLSH_CLSG_CTL, 0x02 },
	{ CDC_RX_CLSH_CLSG_CFG1, 0x9A },
	{ CDC_RX_CLSH_CLSG_CFG2, 0x10 },
	{ CDC_RX_BCL_VBAT_PATH_CTL, 0x00 },
	{ CDC_RX_BCL_VBAT_CFG, 0x10 },
	{ CDC_RX_BCL_VBAT_ADC_CAL1, 0x00 },
	{ CDC_RX_BCL_VBAT_ADC_CAL2, 0x00 },
	{ CDC_RX_BCL_VBAT_ADC_CAL3, 0x04 },
	{ CDC_RX_BCL_VBAT_PK_EST1, 0xE0 },
	{ CDC_RX_BCL_VBAT_PK_EST2, 0x01 },
	{ CDC_RX_BCL_VBAT_PK_EST3, 0x40 },
	{ CDC_RX_BCL_VBAT_RF_PROC1, 0x2A },
	{ CDC_RX_BCL_VBAT_RF_PROC1, 0x00 },
	{ CDC_RX_BCL_VBAT_TAC1, 0x00 },
	{ CDC_RX_BCL_VBAT_TAC2, 0x18 },
	{ CDC_RX_BCL_VBAT_TAC3, 0x18 },
	{ CDC_RX_BCL_VBAT_TAC4, 0x03 },
	{ CDC_RX_BCL_VBAT_GAIN_UPD1, 0x01 },
	{ CDC_RX_BCL_VBAT_GAIN_UPD2, 0x00 },
	{ CDC_RX_BCL_VBAT_GAIN_UPD3, 0x00 },
	{ CDC_RX_BCL_VBAT_GAIN_UPD4, 0x64 },
	{ CDC_RX_BCL_VBAT_GAIN_UPD5, 0x01 },
	{ CDC_RX_BCL_VBAT_DEBUG1, 0x00 },
	{ CDC_RX_BCL_VBAT_GAIN_UPD_MON, 0x00 },
	{ CDC_RX_BCL_VBAT_GAIN_MON_VAL, 0x00 },
	{ CDC_RX_BCL_VBAT_BAN, 0x0C },
	{ CDC_RX_BCL_VBAT_BCL_GAIN_UPD1, 0x00 },
	{ CDC_RX_BCL_VBAT_BCL_GAIN_UPD2, 0x77 },
	{ CDC_RX_BCL_VBAT_BCL_GAIN_UPD3, 0x01 },
	{ CDC_RX_BCL_VBAT_BCL_GAIN_UPD4, 0x00 },
	{ CDC_RX_BCL_VBAT_BCL_GAIN_UPD5, 0x4B },
	{ CDC_RX_BCL_VBAT_BCL_GAIN_UPD6, 0x00 },
	{ CDC_RX_BCL_VBAT_BCL_GAIN_UPD7, 0x01 },
	{ CDC_RX_BCL_VBAT_BCL_GAIN_UPD8, 0x00 },
	{ CDC_RX_BCL_VBAT_BCL_GAIN_UPD9, 0x00 },
	{ CDC_RX_BCL_VBAT_ATTN1, 0x04 },
	{ CDC_RX_BCL_VBAT_ATTN2, 0x08 },
	{ CDC_RX_BCL_VBAT_ATTN3, 0x0C },
	{ CDC_RX_BCL_VBAT_DECODE_CTL1, 0xE0 },
	{ CDC_RX_BCL_VBAT_DECODE_CTL2, 0x00 },
	{ CDC_RX_BCL_VBAT_DECODE_CFG1, 0x00 },
	{ CDC_RX_BCL_VBAT_DECODE_CFG2, 0x00 },
	{ CDC_RX_BCL_VBAT_DECODE_CFG3, 0x00 },
	{ CDC_RX_BCL_VBAT_DECODE_CFG4, 0x00 },
	{ CDC_RX_BCL_VBAT_DECODE_ST, 0x00 },
	{ CDC_RX_INTR_CTRL_CFG, 0x00 },
	{ CDC_RX_INTR_CTRL_CLR_COMMIT, 0x00 },
	{ CDC_RX_INTR_CTRL_PIN1_MASK0, 0xFF },
	{ CDC_RX_INTR_CTRL_PIN1_STATUS0, 0x00 },
	{ CDC_RX_INTR_CTRL_PIN1_CLEAR0, 0x00 },
	{ CDC_RX_INTR_CTRL_PIN2_MASK0, 0xFF },
	{ CDC_RX_INTR_CTRL_PIN2_STATUS0, 0x00 },
	{ CDC_RX_INTR_CTRL_PIN2_CLEAR0, 0x00 },
	{ CDC_RX_INTR_CTRL_LEVEL0, 0x00 },
	{ CDC_RX_INTR_CTRL_BYPASS0, 0x00 },
	{ CDC_RX_INTR_CTRL_SET0, 0x00 },
	{ CDC_RX_RX0_RX_PATH_CTL, 0x04 },
	{ CDC_RX_RX0_RX_PATH_CFG0, 0x00 },
	{ CDC_RX_RX0_RX_PATH_CFG1, 0x64 },
	{ CDC_RX_RX0_RX_PATH_CFG2, 0x8F },
	{ CDC_RX_RX0_RX_PATH_CFG3, 0x00 },
	{ CDC_RX_RX0_RX_VOL_CTL, 0x00 },
	{ CDC_RX_RX0_RX_PATH_MIX_CTL, 0x04 },
	{ CDC_RX_RX0_RX_PATH_MIX_CFG, 0x7E },
	{ CDC_RX_RX0_RX_VOL_MIX_CTL, 0x00 },
	{ CDC_RX_RX0_RX_PATH_SEC1, 0x08 },
	{ CDC_RX_RX0_RX_PATH_SEC2, 0x00 },
	{ CDC_RX_RX0_RX_PATH_SEC3, 0x00 },
	{ CDC_RX_RX0_RX_PATH_SEC4, 0x00 },
	{ CDC_RX_RX0_RX_PATH_SEC7, 0x00 },
	{ CDC_RX_RX0_RX_PATH_MIX_SEC0, 0x08 },
	{ CDC_RX_RX0_RX_PATH_MIX_SEC1, 0x00 },
	{ CDC_RX_RX0_RX_PATH_DSM_CTL, 0x08 },
	{ CDC_RX_RX0_RX_PATH_DSM_DATA1, 0x00 },
	{ CDC_RX_RX0_RX_PATH_DSM_DATA2, 0x00 },
	{ CDC_RX_RX0_RX_PATH_DSM_DATA3, 0x00 },
	{ CDC_RX_RX0_RX_PATH_DSM_DATA4, 0x55 },
	{ CDC_RX_RX0_RX_PATH_DSM_DATA5, 0x55 },
	{ CDC_RX_RX0_RX_PATH_DSM_DATA6, 0x55 },
	{ CDC_RX_RX1_RX_PATH_CTL, 0x04 },
	{ CDC_RX_RX1_RX_PATH_CFG0, 0x00 },
	{ CDC_RX_RX1_RX_PATH_CFG1, 0x64 },
	{ CDC_RX_RX1_RX_PATH_CFG2, 0x8F },
	{ CDC_RX_RX1_RX_PATH_CFG3, 0x00 },
	{ CDC_RX_RX1_RX_VOL_CTL, 0x00 },
	{ CDC_RX_RX1_RX_PATH_MIX_CTL, 0x04 },
	{ CDC_RX_RX1_RX_PATH_MIX_CFG, 0x7E },
	{ CDC_RX_RX1_RX_VOL_MIX_CTL, 0x00 },
	{ CDC_RX_RX1_RX_PATH_SEC1, 0x08 },
	{ CDC_RX_RX1_RX_PATH_SEC2, 0x00 },
	{ CDC_RX_RX1_RX_PATH_SEC3, 0x00 },
	{ CDC_RX_RX1_RX_PATH_SEC4, 0x00 },
	{ CDC_RX_RX1_RX_PATH_SEC7, 0x00 },
	{ CDC_RX_RX1_RX_PATH_MIX_SEC0, 0x08 },
	{ CDC_RX_RX1_RX_PATH_MIX_SEC1, 0x00 },
	{ CDC_RX_RX1_RX_PATH_DSM_CTL, 0x08 },
	{ CDC_RX_RX1_RX_PATH_DSM_DATA1, 0x00 },
	{ CDC_RX_RX1_RX_PATH_DSM_DATA2, 0x00 },
	{ CDC_RX_RX1_RX_PATH_DSM_DATA3, 0x00 },
	{ CDC_RX_RX1_RX_PATH_DSM_DATA4, 0x55 },
	{ CDC_RX_RX1_RX_PATH_DSM_DATA5, 0x55 },
	{ CDC_RX_RX1_RX_PATH_DSM_DATA6, 0x55 },
	{ CDC_RX_RX2_RX_PATH_CTL, 0x04 },
	{ CDC_RX_RX2_RX_PATH_CFG0, 0x00 },
	{ CDC_RX_RX2_RX_PATH_CFG1, 0x64 },
	{ CDC_RX_RX2_RX_PATH_CFG2, 0x8F },
	{ CDC_RX_RX2_RX_PATH_CFG3, 0x00 },
	{ CDC_RX_RX2_RX_VOL_CTL, 0x00 },
	{ CDC_RX_RX2_RX_PATH_MIX_CTL, 0x04 },
	{ CDC_RX_RX2_RX_PATH_MIX_CFG, 0x7E },
	{ CDC_RX_RX2_RX_VOL_MIX_CTL, 0x00 },
	{ CDC_RX_RX2_RX_PATH_SEC0, 0x04 },
	{ CDC_RX_RX2_RX_PATH_SEC1, 0x08 },
	{ CDC_RX_RX2_RX_PATH_SEC2, 0x00 },
	{ CDC_RX_RX2_RX_PATH_SEC3, 0x00 },
	{ CDC_RX_RX2_RX_PATH_SEC4, 0x00 },
	{ CDC_RX_RX2_RX_PATH_SEC5, 0x00 },
	{ CDC_RX_RX2_RX_PATH_SEC6, 0x00 },
	{ CDC_RX_RX2_RX_PATH_SEC7, 0x00 },
	{ CDC_RX_RX2_RX_PATH_MIX_SEC0, 0x08 },
	{ CDC_RX_RX2_RX_PATH_MIX_SEC1, 0x00 },
	{ CDC_RX_RX2_RX_PATH_DSM_CTL, 0x00 },
	{ CDC_RX_IDLE_DETECT_PATH_CTL, 0x00 },
	{ CDC_RX_IDLE_DETECT_CFG0, 0x07 },
	{ CDC_RX_IDLE_DETECT_CFG1, 0x3C },
	{ CDC_RX_IDLE_DETECT_CFG2, 0x00 },
	{ CDC_RX_IDLE_DETECT_CFG3, 0x00 },
	{ CDC_RX_COMPANDER0_CTL0, 0x60 },
	{ CDC_RX_COMPANDER0_CTL1, 0xDB },
	{ CDC_RX_COMPANDER0_CTL2, 0xFF },
	{ CDC_RX_COMPANDER0_CTL3, 0x35 },
	{ CDC_RX_COMPANDER0_CTL4, 0xFF },
	{ CDC_RX_COMPANDER0_CTL5, 0x00 },
	{ CDC_RX_COMPANDER0_CTL6, 0x01 },
	{ CDC_RX_COMPANDER0_CTL7, 0x28 },
	{ CDC_RX_COMPANDER1_CTL0, 0x60 },
	{ CDC_RX_COMPANDER1_CTL1, 0xDB },
	{ CDC_RX_COMPANDER1_CTL2, 0xFF },
	{ CDC_RX_COMPANDER1_CTL3, 0x35 },
	{ CDC_RX_COMPANDER1_CTL4, 0xFF },
	{ CDC_RX_COMPANDER1_CTL5, 0x00 },
	{ CDC_RX_COMPANDER1_CTL6, 0x01 },
	{ CDC_RX_COMPANDER1_CTL7, 0x28 },
	{ CDC_RX_SIDETONE_IIR0_IIR_PATH_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_GAIN_B5_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_GAIN_B6_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_GAIN_B7_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_GAIN_B8_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_CTL, 0x40 },
	{ CDC_RX_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_PATH_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_GAIN_B5_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_GAIN_B6_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_GAIN_B7_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_GAIN_B8_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_CTL, 0x40 },
	{ CDC_RX_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_COEF_B1_CTL, 0x00 },
	{ CDC_RX_SIDETONE_IIR1_IIR_COEF_B2_CTL, 0x00 },
	{ CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG0, 0x00 },
	{ CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG1, 0x00 },
	{ CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG2, 0x00 },
	{ CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG3, 0x00 },
	{ CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG0, 0x00 },
	{ CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG1, 0x00 },
	{ CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG2, 0x00 },
	{ CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG3, 0x00 },
	{ CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CTL, 0x04 },
	{ CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CFG1, 0x00 },
	{ CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CTL, 0x04 },
	{ CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CFG1, 0x00 },
	{ CDC_RX_EC_REF_HQ0_EC_REF_HQ_PATH_CTL, 0x00 },
	{ CDC_RX_EC_REF_HQ0_EC_REF_HQ_CFG0, 0x01 },
	{ CDC_RX_EC_REF_HQ1_EC_REF_HQ_PATH_CTL, 0x00 },
	{ CDC_RX_EC_REF_HQ1_EC_REF_HQ_CFG0, 0x01 },
	{ CDC_RX_EC_REF_HQ2_EC_REF_HQ_PATH_CTL, 0x00 },
	{ CDC_RX_EC_REF_HQ2_EC_REF_HQ_CFG0, 0x01 },
	{ CDC_RX_EC_ASRC0_CLK_RST_CTL, 0x00 },
	{ CDC_RX_EC_ASRC0_CTL0, 0x00 },
	{ CDC_RX_EC_ASRC0_CTL1, 0x00 },
	{ CDC_RX_EC_ASRC0_FIFO_CTL, 0xA8 },
	{ CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_LSB, 0x00 },
	{ CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_MSB, 0x00 },
	{ CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_LSB, 0x00 },
	{ CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_MSB, 0x00 },
	{ CDC_RX_EC_ASRC0_STATUS_FIFO, 0x00 },
	{ CDC_RX_EC_ASRC1_CLK_RST_CTL, 0x00 },
	{ CDC_RX_EC_ASRC1_CTL0, 0x00 },
	{ CDC_RX_EC_ASRC1_CTL1, 0x00 },
	{ CDC_RX_EC_ASRC1_FIFO_CTL, 0xA8 },
	{ CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_LSB, 0x00 },
	{ CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_MSB, 0x00 },
	{ CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_LSB, 0x00 },
	{ CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_MSB, 0x00 },
	{ CDC_RX_EC_ASRC1_STATUS_FIFO, 0x00 },
	{ CDC_RX_EC_ASRC2_CLK_RST_CTL, 0x00 },
	{ CDC_RX_EC_ASRC2_CTL0, 0x00 },
	{ CDC_RX_EC_ASRC2_CTL1, 0x00 },
	{ CDC_RX_EC_ASRC2_FIFO_CTL, 0xA8 },
	{ CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_LSB, 0x00 },
	{ CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_MSB, 0x00 },
	{ CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_LSB, 0x00 },
	{ CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_MSB, 0x00 },
	{ CDC_RX_EC_ASRC2_STATUS_FIFO, 0x00 },
	{ CDC_RX_DSD0_PATH_CTL, 0x00 },
	{ CDC_RX_DSD0_CFG0, 0x00 },
	{ CDC_RX_DSD0_CFG1, 0x62 },
	{ CDC_RX_DSD0_CFG2, 0x96 },
	{ CDC_RX_DSD1_PATH_CTL, 0x00 },
	{ CDC_RX_DSD1_CFG0, 0x00 },
	{ CDC_RX_DSD1_CFG1, 0x62 },
	{ CDC_RX_DSD1_CFG2, 0x96 },
};

static bool rx_is_wronly_register(struct device *dev,
					unsigned int reg)
{
	switch (reg) {
	case CDC_RX_BCL_VBAT_GAIN_UPD_MON:
	case CDC_RX_INTR_CTRL_CLR_COMMIT:
	case CDC_RX_INTR_CTRL_PIN1_CLEAR0:
	case CDC_RX_INTR_CTRL_PIN2_CLEAR0:
		return true;
	}

	return false;
}

static bool rx_is_volatile_register(struct device *dev, unsigned int reg)
{
	/* Update volatile list for rx/tx macros */
	switch (reg) {
	case CDC_RX_TOP_HPHL_COMP_RD_LSB:
	case CDC_RX_TOP_HPHL_COMP_WR_LSB:
	case CDC_RX_TOP_HPHL_COMP_RD_MSB:
	case CDC_RX_TOP_HPHL_COMP_WR_MSB:
	case CDC_RX_TOP_HPHR_COMP_RD_LSB:
	case CDC_RX_TOP_HPHR_COMP_WR_LSB:
	case CDC_RX_TOP_HPHR_COMP_RD_MSB:
	case CDC_RX_TOP_HPHR_COMP_WR_MSB:
	case CDC_RX_TOP_DSD0_DEBUG_CFG2:
	case CDC_RX_TOP_DSD1_DEBUG_CFG2:
	case CDC_RX_BCL_VBAT_GAIN_MON_VAL:
	case CDC_RX_BCL_VBAT_DECODE_ST:
	case CDC_RX_INTR_CTRL_PIN1_STATUS0:
	case CDC_RX_INTR_CTRL_PIN2_STATUS0:
	case CDC_RX_COMPANDER0_CTL6:
	case CDC_RX_COMPANDER1_CTL6:
	case CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_LSB:
	case CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_MSB:
	case CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_LSB:
	case CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_MSB:
	case CDC_RX_EC_ASRC0_STATUS_FIFO:
	case CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_LSB:
	case CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_MSB:
	case CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_LSB:
	case CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_MSB:
	case CDC_RX_EC_ASRC1_STATUS_FIFO:
	case CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_LSB:
	case CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_MSB:
	case CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_LSB:
	case CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_MSB:
	case CDC_RX_EC_ASRC2_STATUS_FIFO:
		return true;
	}
	return false;
}

static bool rx_is_rw_register(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case CDC_RX_TOP_TOP_CFG0:
	case CDC_RX_TOP_SWR_CTRL:
	case CDC_RX_TOP_DEBUG:
	case CDC_RX_TOP_DEBUG_BUS:
	case CDC_RX_TOP_DEBUG_EN0:
	case CDC_RX_TOP_DEBUG_EN1:
	case CDC_RX_TOP_DEBUG_EN2:
	case CDC_RX_TOP_HPHL_COMP_WR_LSB:
	case CDC_RX_TOP_HPHL_COMP_WR_MSB:
	case CDC_RX_TOP_HPHL_COMP_LUT:
	case CDC_RX_TOP_HPHR_COMP_WR_LSB:
	case CDC_RX_TOP_HPHR_COMP_WR_MSB:
	case CDC_RX_TOP_HPHR_COMP_LUT:
	case CDC_RX_TOP_DSD0_DEBUG_CFG0:
	case CDC_RX_TOP_DSD0_DEBUG_CFG1:
	case CDC_RX_TOP_DSD0_DEBUG_CFG3:
	case CDC_RX_TOP_DSD1_DEBUG_CFG0:
	case CDC_RX_TOP_DSD1_DEBUG_CFG1:
	case CDC_RX_TOP_DSD1_DEBUG_CFG3:
	case CDC_RX_TOP_RX_I2S_CTL:
	case CDC_RX_TOP_TX_I2S2_CTL:
	case CDC_RX_TOP_I2S_CLK:
	case CDC_RX_TOP_I2S_RESET:
	case CDC_RX_TOP_I2S_MUX:
	case CDC_RX_CLK_RST_CTRL_MCLK_CONTROL:
	case CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL:
	case CDC_RX_CLK_RST_CTRL_SWR_CONTROL:
	case CDC_RX_CLK_RST_CTRL_DSD_CONTROL:
	case CDC_RX_CLK_RST_CTRL_ASRC_SHARE_CONTROL:
	case CDC_RX_SOFTCLIP_CRC:
	case CDC_RX_SOFTCLIP_SOFTCLIP_CTRL:
	case CDC_RX_INP_MUX_RX_INT0_CFG0:
	case CDC_RX_INP_MUX_RX_INT0_CFG1:
	case CDC_RX_INP_MUX_RX_INT1_CFG0:
	case CDC_RX_INP_MUX_RX_INT1_CFG1:
	case CDC_RX_INP_MUX_RX_INT2_CFG0:
	case CDC_RX_INP_MUX_RX_INT2_CFG1:
	case CDC_RX_INP_MUX_RX_MIX_CFG4:
	case CDC_RX_INP_MUX_RX_MIX_CFG5:
	case CDC_RX_INP_MUX_SIDETONE_SRC_CFG0:
	case CDC_RX_CLSH_CRC:
	case CDC_RX_CLSH_DLY_CTRL:
	case CDC_RX_CLSH_DECAY_CTRL:
	case CDC_RX_CLSH_HPH_V_PA:
	case CDC_RX_CLSH_EAR_V_PA:
	case CDC_RX_CLSH_HPH_V_HD:
	case CDC_RX_CLSH_EAR_V_HD:
	case CDC_RX_CLSH_K1_MSB:
	case CDC_RX_CLSH_K1_LSB:
	case CDC_RX_CLSH_K2_MSB:
	case CDC_RX_CLSH_K2_LSB:
	case CDC_RX_CLSH_IDLE_CTRL:
	case CDC_RX_CLSH_IDLE_HPH:
	case CDC_RX_CLSH_IDLE_EAR:
	case CDC_RX_CLSH_TEST0:
	case CDC_RX_CLSH_TEST1:
	case CDC_RX_CLSH_OVR_VREF:
	case CDC_RX_CLSH_CLSG_CTL:
	case CDC_RX_CLSH_CLSG_CFG1:
	case CDC_RX_CLSH_CLSG_CFG2:
	case CDC_RX_BCL_VBAT_PATH_CTL:
	case CDC_RX_BCL_VBAT_CFG:
	case CDC_RX_BCL_VBAT_ADC_CAL1:
	case CDC_RX_BCL_VBAT_ADC_CAL2:
	case CDC_RX_BCL_VBAT_ADC_CAL3:
	case CDC_RX_BCL_VBAT_PK_EST1:
	case CDC_RX_BCL_VBAT_PK_EST2:
	case CDC_RX_BCL_VBAT_PK_EST3:
	case CDC_RX_BCL_VBAT_RF_PROC1:
	case CDC_RX_BCL_VBAT_RF_PROC2:
	case CDC_RX_BCL_VBAT_TAC1:
	case CDC_RX_BCL_VBAT_TAC2:
	case CDC_RX_BCL_VBAT_TAC3:
	case CDC_RX_BCL_VBAT_TAC4:
	case CDC_RX_BCL_VBAT_GAIN_UPD1:
	case CDC_RX_BCL_VBAT_GAIN_UPD2:
	case CDC_RX_BCL_VBAT_GAIN_UPD3:
	case CDC_RX_BCL_VBAT_GAIN_UPD4:
	case CDC_RX_BCL_VBAT_GAIN_UPD5:
	case CDC_RX_BCL_VBAT_DEBUG1:
	case CDC_RX_BCL_VBAT_BAN:
	case CDC_RX_BCL_VBAT_BCL_GAIN_UPD1:
	case CDC_RX_BCL_VBAT_BCL_GAIN_UPD2:
	case CDC_RX_BCL_VBAT_BCL_GAIN_UPD3:
	case CDC_RX_BCL_VBAT_BCL_GAIN_UPD4:
	case CDC_RX_BCL_VBAT_BCL_GAIN_UPD5:
	case CDC_RX_BCL_VBAT_BCL_GAIN_UPD6:
	case CDC_RX_BCL_VBAT_BCL_GAIN_UPD7:
	case CDC_RX_BCL_VBAT_BCL_GAIN_UPD8:
	case CDC_RX_BCL_VBAT_BCL_GAIN_UPD9:
	case CDC_RX_BCL_VBAT_ATTN1:
	case CDC_RX_BCL_VBAT_ATTN2:
	case CDC_RX_BCL_VBAT_ATTN3:
	case CDC_RX_BCL_VBAT_DECODE_CTL1:
	case CDC_RX_BCL_VBAT_DECODE_CTL2:
	case CDC_RX_BCL_VBAT_DECODE_CFG1:
	case CDC_RX_BCL_VBAT_DECODE_CFG2:
	case CDC_RX_BCL_VBAT_DECODE_CFG3:
	case CDC_RX_BCL_VBAT_DECODE_CFG4:
	case CDC_RX_INTR_CTRL_CFG:
	case CDC_RX_INTR_CTRL_PIN1_MASK0:
	case CDC_RX_INTR_CTRL_PIN2_MASK0:
	case CDC_RX_INTR_CTRL_LEVEL0:
	case CDC_RX_INTR_CTRL_BYPASS0:
	case CDC_RX_INTR_CTRL_SET0:
	case CDC_RX_RX0_RX_PATH_CTL:
	case CDC_RX_RX0_RX_PATH_CFG0:
	case CDC_RX_RX0_RX_PATH_CFG1:
	case CDC_RX_RX0_RX_PATH_CFG2:
	case CDC_RX_RX0_RX_PATH_CFG3:
	case CDC_RX_RX0_RX_VOL_CTL:
	case CDC_RX_RX0_RX_PATH_MIX_CTL:
	case CDC_RX_RX0_RX_PATH_MIX_CFG:
	case CDC_RX_RX0_RX_VOL_MIX_CTL:
	case CDC_RX_RX0_RX_PATH_SEC1:
	case CDC_RX_RX0_RX_PATH_SEC2:
	case CDC_RX_RX0_RX_PATH_SEC3:
	case CDC_RX_RX0_RX_PATH_SEC4:
	case CDC_RX_RX0_RX_PATH_SEC7:
	case CDC_RX_RX0_RX_PATH_MIX_SEC0:
	case CDC_RX_RX0_RX_PATH_MIX_SEC1:
	case CDC_RX_RX0_RX_PATH_DSM_CTL:
	case CDC_RX_RX0_RX_PATH_DSM_DATA1:
	case CDC_RX_RX0_RX_PATH_DSM_DATA2:
	case CDC_RX_RX0_RX_PATH_DSM_DATA3:
	case CDC_RX_RX0_RX_PATH_DSM_DATA4:
	case CDC_RX_RX0_RX_PATH_DSM_DATA5:
	case CDC_RX_RX0_RX_PATH_DSM_DATA6:
	case CDC_RX_RX1_RX_PATH_CTL:
	case CDC_RX_RX1_RX_PATH_CFG0:
	case CDC_RX_RX1_RX_PATH_CFG1:
	case CDC_RX_RX1_RX_PATH_CFG2:
	case CDC_RX_RX1_RX_PATH_CFG3:
	case CDC_RX_RX1_RX_VOL_CTL:
	case CDC_RX_RX1_RX_PATH_MIX_CTL:
	case CDC_RX_RX1_RX_PATH_MIX_CFG:
	case CDC_RX_RX1_RX_VOL_MIX_CTL:
	case CDC_RX_RX1_RX_PATH_SEC1:
	case CDC_RX_RX1_RX_PATH_SEC2:
	case CDC_RX_RX1_RX_PATH_SEC3:
	case CDC_RX_RX1_RX_PATH_SEC4:
	case CDC_RX_RX1_RX_PATH_SEC7:
	case CDC_RX_RX1_RX_PATH_MIX_SEC0:
	case CDC_RX_RX1_RX_PATH_MIX_SEC1:
	case CDC_RX_RX1_RX_PATH_DSM_CTL:
	case CDC_RX_RX1_RX_PATH_DSM_DATA1:
	case CDC_RX_RX1_RX_PATH_DSM_DATA2:
	case CDC_RX_RX1_RX_PATH_DSM_DATA3:
	case CDC_RX_RX1_RX_PATH_DSM_DATA4:
	case CDC_RX_RX1_RX_PATH_DSM_DATA5:
	case CDC_RX_RX1_RX_PATH_DSM_DATA6:
	case CDC_RX_RX2_RX_PATH_CTL:
	case CDC_RX_RX2_RX_PATH_CFG0:
	case CDC_RX_RX2_RX_PATH_CFG1:
	case CDC_RX_RX2_RX_PATH_CFG2:
	case CDC_RX_RX2_RX_PATH_CFG3:
	case CDC_RX_RX2_RX_VOL_CTL:
	case CDC_RX_RX2_RX_PATH_MIX_CTL:
	case CDC_RX_RX2_RX_PATH_MIX_CFG:
	case CDC_RX_RX2_RX_VOL_MIX_CTL:
	case CDC_RX_RX2_RX_PATH_SEC0:
	case CDC_RX_RX2_RX_PATH_SEC1:
	case CDC_RX_RX2_RX_PATH_SEC2:
	case CDC_RX_RX2_RX_PATH_SEC3:
	case CDC_RX_RX2_RX_PATH_SEC4:
	case CDC_RX_RX2_RX_PATH_SEC5:
	case CDC_RX_RX2_RX_PATH_SEC6:
	case CDC_RX_RX2_RX_PATH_SEC7:
	case CDC_RX_RX2_RX_PATH_MIX_SEC0:
	case CDC_RX_RX2_RX_PATH_MIX_SEC1:
	case CDC_RX_RX2_RX_PATH_DSM_CTL:
	case CDC_RX_IDLE_DETECT_PATH_CTL:
	case CDC_RX_IDLE_DETECT_CFG0:
	case CDC_RX_IDLE_DETECT_CFG1:
	case CDC_RX_IDLE_DETECT_CFG2:
	case CDC_RX_IDLE_DETECT_CFG3:
	case CDC_RX_COMPANDER0_CTL0:
	case CDC_RX_COMPANDER0_CTL1:
	case CDC_RX_COMPANDER0_CTL2:
	case CDC_RX_COMPANDER0_CTL3:
	case CDC_RX_COMPANDER0_CTL4:
	case CDC_RX_COMPANDER0_CTL5:
	case CDC_RX_COMPANDER0_CTL7:
	case CDC_RX_COMPANDER1_CTL0:
	case CDC_RX_COMPANDER1_CTL1:
	case CDC_RX_COMPANDER1_CTL2:
	case CDC_RX_COMPANDER1_CTL3:
	case CDC_RX_COMPANDER1_CTL4:
	case CDC_RX_COMPANDER1_CTL5:
	case CDC_RX_COMPANDER1_CTL7:
	case CDC_RX_SIDETONE_IIR0_IIR_PATH_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B5_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B6_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B7_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_GAIN_B8_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_GAIN_TIMER_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL:
	case CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_PATH_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B5_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B6_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B7_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_GAIN_B8_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_GAIN_TIMER_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_COEF_B1_CTL:
	case CDC_RX_SIDETONE_IIR1_IIR_COEF_B2_CTL:
	case CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG0:
	case CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG1:
	case CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG2:
	case CDC_RX_IIR_INP_MUX_IIR0_MIX_CFG3:
	case CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG0:
	case CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG1:
	case CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG2:
	case CDC_RX_IIR_INP_MUX_IIR1_MIX_CFG3:
	case CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CTL:
	case CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CFG1:
	case CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CTL:
	case CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CFG1:
	case CDC_RX_EC_REF_HQ0_EC_REF_HQ_PATH_CTL:
	case CDC_RX_EC_REF_HQ0_EC_REF_HQ_CFG0:
	case CDC_RX_EC_REF_HQ1_EC_REF_HQ_PATH_CTL:
	case CDC_RX_EC_REF_HQ1_EC_REF_HQ_CFG0:
	case CDC_RX_EC_REF_HQ2_EC_REF_HQ_PATH_CTL:
	case CDC_RX_EC_REF_HQ2_EC_REF_HQ_CFG0:
	case CDC_RX_EC_ASRC0_CLK_RST_CTL:
	case CDC_RX_EC_ASRC0_CTL0:
	case CDC_RX_EC_ASRC0_CTL1:
	case CDC_RX_EC_ASRC0_FIFO_CTL:
	case CDC_RX_EC_ASRC1_CLK_RST_CTL:
	case CDC_RX_EC_ASRC1_CTL0:
	case CDC_RX_EC_ASRC1_CTL1:
	case CDC_RX_EC_ASRC1_FIFO_CTL:
	case CDC_RX_EC_ASRC2_CLK_RST_CTL:
	case CDC_RX_EC_ASRC2_CTL0:
	case CDC_RX_EC_ASRC2_CTL1:
	case CDC_RX_EC_ASRC2_FIFO_CTL:
	case CDC_RX_DSD0_PATH_CTL:
	case CDC_RX_DSD0_CFG0:
	case CDC_RX_DSD0_CFG1:
	case CDC_RX_DSD0_CFG2:
	case CDC_RX_DSD1_PATH_CTL:
	case CDC_RX_DSD1_CFG0:
	case CDC_RX_DSD1_CFG1:
	case CDC_RX_DSD1_CFG2:
		return true;
	}

	return false;
}

static bool rx_is_writeable_register(struct device *dev, unsigned int reg)
{
	bool ret;

	ret = rx_is_rw_register(dev, reg);
	if (!ret)
		return rx_is_wronly_register(dev, reg);

	return ret;
}

static bool rx_is_readable_register(struct device *dev, unsigned int reg)
{
	switch (reg) {
	case CDC_RX_TOP_HPHL_COMP_RD_LSB:
	case CDC_RX_TOP_HPHL_COMP_RD_MSB:
	case CDC_RX_TOP_HPHR_COMP_RD_LSB:
	case CDC_RX_TOP_HPHR_COMP_RD_MSB:
	case CDC_RX_TOP_DSD0_DEBUG_CFG2:
	case CDC_RX_TOP_DSD1_DEBUG_CFG2:
	case CDC_RX_BCL_VBAT_GAIN_MON_VAL:
	case CDC_RX_BCL_VBAT_DECODE_ST:
	case CDC_RX_INTR_CTRL_PIN1_STATUS0:
	case CDC_RX_INTR_CTRL_PIN2_STATUS0:
	case CDC_RX_COMPANDER0_CTL6:
	case CDC_RX_COMPANDER1_CTL6:
	case CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_LSB:
	case CDC_RX_EC_ASRC0_STATUS_FMIN_CNTR_MSB:
	case CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_LSB:
	case CDC_RX_EC_ASRC0_STATUS_FMAX_CNTR_MSB:
	case CDC_RX_EC_ASRC0_STATUS_FIFO:
	case CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_LSB:
	case CDC_RX_EC_ASRC1_STATUS_FMIN_CNTR_MSB:
	case CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_LSB:
	case CDC_RX_EC_ASRC1_STATUS_FMAX_CNTR_MSB:
	case CDC_RX_EC_ASRC1_STATUS_FIFO:
	case CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_LSB:
	case CDC_RX_EC_ASRC2_STATUS_FMIN_CNTR_MSB:
	case CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_LSB:
	case CDC_RX_EC_ASRC2_STATUS_FMAX_CNTR_MSB:
	case CDC_RX_EC_ASRC2_STATUS_FIFO:
		return true;
	}

	return rx_is_rw_register(dev, reg);
}

static const struct regmap_config rx_regmap_config = {
	.name = "rx_macro",
	.reg_bits = 16,
	.val_bits = 32, /* 8 but with 32 bit read/write */
	.reg_stride = 4,
	.cache_type = REGCACHE_FLAT,
	.reg_defaults = rx_defaults,
	.num_reg_defaults = ARRAY_SIZE(rx_defaults),
	.max_register = RX_MAX_OFFSET,
	.writeable_reg = rx_is_writeable_register,
	.volatile_reg = rx_is_volatile_register,
	.readable_reg = rx_is_readable_register,
};

static int rx_macro_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
					struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol);
	struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
	unsigned short look_ahead_dly_reg;
	unsigned int val;

	val = ucontrol->value.enumerated.item[0];

	if (e->reg == CDC_RX_RX0_RX_PATH_CFG1)
		look_ahead_dly_reg = CDC_RX_RX0_RX_PATH_CFG0;
	else if (e->reg == CDC_RX_RX1_RX_PATH_CFG1)
		look_ahead_dly_reg = CDC_RX_RX1_RX_PATH_CFG0;

	/* Set Look Ahead Delay */
	if (val)
		snd_soc_component_update_bits(component, look_ahead_dly_reg,
					      CDC_RX_DLY_ZN_EN_MASK,
					      CDC_RX_DLY_ZN_ENABLE);
	else
		snd_soc_component_update_bits(component, look_ahead_dly_reg,
					      CDC_RX_DLY_ZN_EN_MASK, 0);
	/* Set DEM INP Select */
	return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
}

static const struct snd_kcontrol_new rx_int0_dem_inp_mux =
		SOC_DAPM_ENUM_EXT("rx_int0_dem_inp", rx_int0_dem_inp_enum,
		  snd_soc_dapm_get_enum_double, rx_macro_int_dem_inp_mux_put);
static const struct snd_kcontrol_new rx_int1_dem_inp_mux =
		SOC_DAPM_ENUM_EXT("rx_int1_dem_inp", rx_int1_dem_inp_enum,
		  snd_soc_dapm_get_enum_double, rx_macro_int_dem_inp_mux_put);

static int rx_macro_set_prim_interpolator_rate(struct snd_soc_dai *dai,
					       int rate_reg_val, u32 sample_rate)
{

	u8 int_1_mix1_inp;
	u32 j, port;
	u16 int_mux_cfg0, int_mux_cfg1;
	u16 int_fs_reg;
	u8 inp0_sel, inp1_sel, inp2_sel;
	struct snd_soc_component *component = dai->component;
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	for_each_set_bit(port, &rx->active_ch_mask[dai->id], RX_MACRO_PORTS_MAX) {
		int_1_mix1_inp = port;
		int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0;
		/*
		 * Loop through all interpolator MUX inputs and find out
		 * to which interpolator input, the rx port
		 * is connected
		 */
		for (j = 0; j < INTERP_MAX; j++) {
			int_mux_cfg1 = int_mux_cfg0 + 4;

			inp0_sel = snd_soc_component_read_field(component, int_mux_cfg0,
								CDC_RX_INTX_1_MIX_INP0_SEL_MASK);
			inp1_sel = snd_soc_component_read_field(component, int_mux_cfg0,
								CDC_RX_INTX_1_MIX_INP1_SEL_MASK);
			inp2_sel = snd_soc_component_read_field(component, int_mux_cfg1,
								CDC_RX_INTX_1_MIX_INP2_SEL_MASK);

			if ((inp0_sel == int_1_mix1_inp + INTn_1_INP_SEL_RX0) ||
			    (inp1_sel == int_1_mix1_inp + INTn_1_INP_SEL_RX0) ||
			    (inp2_sel == int_1_mix1_inp + INTn_1_INP_SEL_RX0)) {
				int_fs_reg = CDC_RX_RXn_RX_PATH_CTL(j);
				/* sample_rate is in Hz */
				snd_soc_component_update_bits(component, int_fs_reg,
							      CDC_RX_PATH_PCM_RATE_MASK,
							      rate_reg_val);
			}
			int_mux_cfg0 += 8;
		}
	}

	return 0;
}

static int rx_macro_set_mix_interpolator_rate(struct snd_soc_dai *dai,
					      int rate_reg_val, u32 sample_rate)
{

	u8 int_2_inp;
	u32 j, port;
	u16 int_mux_cfg1, int_fs_reg;
	u8 int_mux_cfg1_val;
	struct snd_soc_component *component = dai->component;
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	for_each_set_bit(port, &rx->active_ch_mask[dai->id], RX_MACRO_PORTS_MAX) {
		int_2_inp = port;

		int_mux_cfg1 = CDC_RX_INP_MUX_RX_INT0_CFG1;
		for (j = 0; j < INTERP_MAX; j++) {
			int_mux_cfg1_val = snd_soc_component_read_field(component, int_mux_cfg1,
									CDC_RX_INTX_2_SEL_MASK);

			if (int_mux_cfg1_val == int_2_inp + INTn_2_INP_SEL_RX0) {
				int_fs_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(j);
				snd_soc_component_update_bits(component, int_fs_reg,
							      CDC_RX_RXn_MIX_PCM_RATE_MASK,
							      rate_reg_val);
			}
			int_mux_cfg1 += 8;
		}
	}
	return 0;
}

static int rx_macro_set_interpolator_rate(struct snd_soc_dai *dai,
					  u32 sample_rate)
{
	int rate_val = 0;
	int i, ret;

	for (i = 0; i < ARRAY_SIZE(sr_val_tbl); i++)
		if (sample_rate == sr_val_tbl[i].sample_rate)
			rate_val = sr_val_tbl[i].rate_val;

	ret = rx_macro_set_prim_interpolator_rate(dai, rate_val, sample_rate);
	if (ret)
		return ret;

	ret = rx_macro_set_mix_interpolator_rate(dai, rate_val, sample_rate);
	if (ret)
		return ret;

	return ret;
}

static int rx_macro_hw_params(struct snd_pcm_substream *substream,
			      struct snd_pcm_hw_params *params,
			      struct snd_soc_dai *dai)
{
	struct snd_soc_component *component = dai->component;
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
	int ret;

	switch (substream->stream) {
	case SNDRV_PCM_STREAM_PLAYBACK:
		ret = rx_macro_set_interpolator_rate(dai, params_rate(params));
		if (ret) {
			dev_err(component->dev, "%s: cannot set sample rate: %u\n",
				__func__, params_rate(params));
			return ret;
		}
		rx->bit_width[dai->id] = params_width(params);
		break;
	default:
		break;
	}
	return 0;
}

static int rx_macro_get_channel_map(struct snd_soc_dai *dai,
				    unsigned int *tx_num, unsigned int *tx_slot,
				    unsigned int *rx_num, unsigned int *rx_slot)
{
	struct snd_soc_component *component = dai->component;
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
	u16 val, mask = 0, cnt = 0, temp;

	switch (dai->id) {
	case RX_MACRO_AIF1_PB:
	case RX_MACRO_AIF2_PB:
	case RX_MACRO_AIF3_PB:
	case RX_MACRO_AIF4_PB:
		for_each_set_bit(temp, &rx->active_ch_mask[dai->id],
			 RX_MACRO_PORTS_MAX) {
			mask |= (1 << temp);
			if (++cnt == RX_MACRO_MAX_DMA_CH_PER_PORT)
				break;
		}
		/*
		 * CDC_DMA_RX_0 port drives RX0/RX1 -- ch_mask 0x1/0x2/0x3
		 * CDC_DMA_RX_1 port drives RX2/RX3 -- ch_mask 0x1/0x2/0x3
		 * CDC_DMA_RX_2 port drives RX4     -- ch_mask 0x1
		 * CDC_DMA_RX_3 port drives RX5     -- ch_mask 0x1
		 * AIFn can pair to any CDC_DMA_RX_n port.
		 * In general, below convention is used::
		 * CDC_DMA_RX_0(AIF1)/CDC_DMA_RX_1(AIF2)/
		 * CDC_DMA_RX_2(AIF3)/CDC_DMA_RX_3(AIF4)
		 */
		if (mask & 0x0C)
			mask = mask >> 2;
		if ((mask & 0x10) || (mask & 0x20))
			mask = 0x1;
		*rx_slot = mask;
		*rx_num = rx->active_ch_cnt[dai->id];
		break;
	case RX_MACRO_AIF_ECHO:
		val = snd_soc_component_read(component,	CDC_RX_INP_MUX_RX_MIX_CFG4);
		if (val & RX_MACRO_EC_MIX_TX0_MASK) {
			mask |= 0x1;
			cnt++;
		}
		if (val & RX_MACRO_EC_MIX_TX1_MASK) {
			mask |= 0x2;
			cnt++;
		}
		val = snd_soc_component_read(component,
			CDC_RX_INP_MUX_RX_MIX_CFG5);
		if (val & RX_MACRO_EC_MIX_TX2_MASK) {
			mask |= 0x4;
			cnt++;
		}
		*tx_slot = mask;
		*tx_num = cnt;
		break;
	default:
		dev_err(component->dev, "%s: Invalid AIF\n", __func__);
		break;
	}
	return 0;
}

static int rx_macro_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
{
	struct snd_soc_component *component = dai->component;
	uint16_t j, reg, mix_reg, dsm_reg;
	u16 int_mux_cfg0, int_mux_cfg1;
	u8 int_mux_cfg0_val, int_mux_cfg1_val;

	switch (dai->id) {
	case RX_MACRO_AIF1_PB:
	case RX_MACRO_AIF2_PB:
	case RX_MACRO_AIF3_PB:
	case RX_MACRO_AIF4_PB:
	for (j = 0; j < INTERP_MAX; j++) {
		reg = CDC_RX_RXn_RX_PATH_CTL(j);
		mix_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(j);
		dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(j);

		if (mute) {
			snd_soc_component_update_bits(component, reg,
						      CDC_RX_PATH_PGA_MUTE_MASK,
						      CDC_RX_PATH_PGA_MUTE_ENABLE);
			snd_soc_component_update_bits(component, mix_reg,
						      CDC_RX_PATH_PGA_MUTE_MASK,
						      CDC_RX_PATH_PGA_MUTE_ENABLE);
		} else {
			snd_soc_component_update_bits(component, reg,
						      CDC_RX_PATH_PGA_MUTE_MASK, 0x0);
			snd_soc_component_update_bits(component, mix_reg,
						      CDC_RX_PATH_PGA_MUTE_MASK, 0x0);
		}

		if (j == INTERP_AUX)
			dsm_reg = CDC_RX_RX2_RX_PATH_DSM_CTL;

		int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0 + j * 8;
		int_mux_cfg1 = int_mux_cfg0 + 4;
		int_mux_cfg0_val = snd_soc_component_read(component, int_mux_cfg0);
		int_mux_cfg1_val = snd_soc_component_read(component, int_mux_cfg1);

		if (snd_soc_component_read(component, dsm_reg) & 0x01) {
			if (int_mux_cfg0_val || (int_mux_cfg1_val & 0xF0))
				snd_soc_component_update_bits(component, reg, 0x20, 0x20);
			if (int_mux_cfg1_val & 0x0F) {
				snd_soc_component_update_bits(component, reg, 0x20, 0x20);
				snd_soc_component_update_bits(component, mix_reg, 0x20, 0x20);
			}
		}
	}
		break;
	default:
		break;
	}
	return 0;
}

static struct snd_soc_dai_ops rx_macro_dai_ops = {
	.hw_params = rx_macro_hw_params,
	.get_channel_map = rx_macro_get_channel_map,
	.mute_stream = rx_macro_digital_mute,
};

static struct snd_soc_dai_driver rx_macro_dai[] = {
	{
		.name = "rx_macro_rx1",
		.id = RX_MACRO_AIF1_PB,
		.playback = {
			.stream_name = "RX_MACRO_AIF1 Playback",
			.rates = RX_MACRO_RATES | RX_MACRO_FRAC_RATES,
			.formats = RX_MACRO_FORMATS,
			.rate_max = 384000,
			.rate_min = 8000,
			.channels_min = 1,
			.channels_max = 2,
		},
		.ops = &rx_macro_dai_ops,
	},
	{
		.name = "rx_macro_rx2",
		.id = RX_MACRO_AIF2_PB,
		.playback = {
			.stream_name = "RX_MACRO_AIF2 Playback",
			.rates = RX_MACRO_RATES | RX_MACRO_FRAC_RATES,
			.formats = RX_MACRO_FORMATS,
			.rate_max = 384000,
			.rate_min = 8000,
			.channels_min = 1,
			.channels_max = 2,
		},
		.ops = &rx_macro_dai_ops,
	},
	{
		.name = "rx_macro_rx3",
		.id = RX_MACRO_AIF3_PB,
		.playback = {
			.stream_name = "RX_MACRO_AIF3 Playback",
			.rates = RX_MACRO_RATES | RX_MACRO_FRAC_RATES,
			.formats = RX_MACRO_FORMATS,
			.rate_max = 384000,
			.rate_min = 8000,
			.channels_min = 1,
			.channels_max = 2,
		},
		.ops = &rx_macro_dai_ops,
	},
	{
		.name = "rx_macro_rx4",
		.id = RX_MACRO_AIF4_PB,
		.playback = {
			.stream_name = "RX_MACRO_AIF4 Playback",
			.rates = RX_MACRO_RATES | RX_MACRO_FRAC_RATES,
			.formats = RX_MACRO_FORMATS,
			.rate_max = 384000,
			.rate_min = 8000,
			.channels_min = 1,
			.channels_max = 2,
		},
		.ops = &rx_macro_dai_ops,
	},
	{
		.name = "rx_macro_echo",
		.id = RX_MACRO_AIF_ECHO,
		.capture = {
			.stream_name = "RX_AIF_ECHO Capture",
			.rates = RX_MACRO_ECHO_RATES,
			.formats = RX_MACRO_ECHO_FORMATS,
			.rate_max = 48000,
			.rate_min = 8000,
			.channels_min = 1,
			.channels_max = 3,
		},
		.ops = &rx_macro_dai_ops,
	},
};

static void rx_macro_mclk_enable(struct rx_macro *rx, bool mclk_enable)
{
	struct regmap *regmap = rx->regmap;

	if (mclk_enable) {
		if (rx->rx_mclk_users == 0) {
			regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_MCLK_CONTROL,
					   CDC_RX_CLK_MCLK_EN_MASK |
					   CDC_RX_CLK_MCLK2_EN_MASK,
					   CDC_RX_CLK_MCLK_ENABLE |
					   CDC_RX_CLK_MCLK2_ENABLE);
			regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
					   CDC_RX_FS_MCLK_CNT_CLR_MASK, 0x00);
			regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
					   CDC_RX_FS_MCLK_CNT_EN_MASK,
					   CDC_RX_FS_MCLK_CNT_ENABLE);
			regcache_mark_dirty(regmap);
			regcache_sync(regmap);
		}
		rx->rx_mclk_users++;
	} else {
		if (rx->rx_mclk_users <= 0) {
			dev_err(rx->dev, "%s: clock already disabled\n", __func__);
			rx->rx_mclk_users = 0;
			return;
		}
		rx->rx_mclk_users--;
		if (rx->rx_mclk_users == 0) {
			regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
					   CDC_RX_FS_MCLK_CNT_EN_MASK, 0x0);
			regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_FS_CNT_CONTROL,
					   CDC_RX_FS_MCLK_CNT_CLR_MASK,
					   CDC_RX_FS_MCLK_CNT_CLR);
			regmap_update_bits(regmap, CDC_RX_CLK_RST_CTRL_MCLK_CONTROL,
					   CDC_RX_CLK_MCLK_EN_MASK |
					   CDC_RX_CLK_MCLK2_EN_MASK, 0x0);
		}
	}
}

static int rx_macro_mclk_event(struct snd_soc_dapm_widget *w,
			       struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);
	int ret = 0;

	switch (event) {
	case SND_SOC_DAPM_PRE_PMU:
		rx_macro_mclk_enable(rx, true);
		break;
	case SND_SOC_DAPM_POST_PMD:
		rx_macro_mclk_enable(rx, false);
		break;
	default:
		dev_err(component->dev, "%s: invalid DAPM event %d\n", __func__, event);
		ret = -EINVAL;
	}
	return ret;
}

static bool rx_macro_adie_lb(struct snd_soc_component *component,
			     int interp_idx)
{
	u16 int_mux_cfg0, int_mux_cfg1;
	u8 int_n_inp0, int_n_inp1, int_n_inp2;

	int_mux_cfg0 = CDC_RX_INP_MUX_RX_INT0_CFG0 + interp_idx * 8;
	int_mux_cfg1 = int_mux_cfg0 + 4;

	int_n_inp0 = snd_soc_component_read_field(component, int_mux_cfg0,
						  CDC_RX_INTX_1_MIX_INP0_SEL_MASK);
	int_n_inp1 = snd_soc_component_read_field(component, int_mux_cfg0,
						  CDC_RX_INTX_1_MIX_INP1_SEL_MASK);
	int_n_inp2 = snd_soc_component_read_field(component, int_mux_cfg1,
						  CDC_RX_INTX_1_MIX_INP2_SEL_MASK);

	if (int_n_inp0 == INTn_1_INP_SEL_DEC0 ||
		int_n_inp0 == INTn_1_INP_SEL_DEC1 ||
		int_n_inp0 == INTn_1_INP_SEL_IIR0 ||
		int_n_inp0 == INTn_1_INP_SEL_IIR1)
		return true;

	if (int_n_inp1 == INTn_1_INP_SEL_DEC0 ||
		int_n_inp1 == INTn_1_INP_SEL_DEC1 ||
		int_n_inp1 == INTn_1_INP_SEL_IIR0 ||
		int_n_inp1 == INTn_1_INP_SEL_IIR1)
		return true;

	if (int_n_inp2 == INTn_1_INP_SEL_DEC0 ||
		int_n_inp2 == INTn_1_INP_SEL_DEC1 ||
		int_n_inp2 == INTn_1_INP_SEL_IIR0 ||
		int_n_inp2 == INTn_1_INP_SEL_IIR1)
		return true;

	return false;
}

static int rx_macro_enable_interp_clk(struct snd_soc_component *component,
				      int event, int interp_idx);
static int rx_macro_enable_main_path(struct snd_soc_dapm_widget *w,
					struct snd_kcontrol *kcontrol,
					int event)
{
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
	u16 gain_reg, reg;

	reg = CDC_RX_RXn_RX_PATH_CTL(w->shift);
	gain_reg = CDC_RX_RXn_RX_VOL_CTL(w->shift);

	switch (event) {
	case SND_SOC_DAPM_PRE_PMU:
		rx_macro_enable_interp_clk(component, event, w->shift);
		if (rx_macro_adie_lb(component, w->shift))
			snd_soc_component_update_bits(component, reg,
						      CDC_RX_PATH_CLK_EN_MASK,
						      CDC_RX_PATH_CLK_ENABLE);
		break;
	case SND_SOC_DAPM_POST_PMU:
		snd_soc_component_write(component, gain_reg,
			snd_soc_component_read(component, gain_reg));
		break;
	case SND_SOC_DAPM_POST_PMD:
		rx_macro_enable_interp_clk(component, event, w->shift);
		break;
	}

	return 0;
}

static int rx_macro_config_compander(struct snd_soc_component *component,
				struct rx_macro *rx,
				int comp, int event)
{
	u8 pcm_rate, val;

	/* AUX does not have compander */
	if (comp == INTERP_AUX)
		return 0;

	pcm_rate = snd_soc_component_read(component, CDC_RX_RXn_RX_PATH_CTL(comp)) & 0x0F;
	if (pcm_rate < 0x06)
		val = 0x03;
	else if (pcm_rate < 0x08)
		val = 0x01;
	else if (pcm_rate < 0x0B)
		val = 0x02;
	else
		val = 0x00;

	if (SND_SOC_DAPM_EVENT_ON(event))
		snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_CFG3(comp),
					      CDC_RX_DC_COEFF_SEL_MASK, val);

	if (SND_SOC_DAPM_EVENT_OFF(event))
		snd_soc_component_update_bits(component, CDC_RX_RXn_RX_PATH_CFG3(comp),
					      CDC_RX_DC_COEFF_SEL_MASK, 0x3);
	if (!rx->comp_enabled[comp])
		return 0;

	if (SND_SOC_DAPM_EVENT_ON(event)) {
		/* Enable Compander Clock */
		snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp),
					      CDC_RX_COMPANDERn_CLK_EN_MASK, 0x1);
		snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp),
					      CDC_RX_COMPANDERn_SOFT_RST_MASK, 0x1);
		snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp),
					      CDC_RX_COMPANDERn_SOFT_RST_MASK, 0x0);
		snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CFG0(comp),
					      CDC_RX_RXn_COMP_EN_MASK, 0x1);
	}

	if (SND_SOC_DAPM_EVENT_OFF(event)) {
		snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp),
					      CDC_RX_COMPANDERn_HALT_MASK, 0x1);
		snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CFG0(comp),
					      CDC_RX_RXn_COMP_EN_MASK, 0x0);
		snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp),
					      CDC_RX_COMPANDERn_CLK_EN_MASK, 0x0);
		snd_soc_component_write_field(component, CDC_RX_COMPANDERn_CTL0(comp),
					      CDC_RX_COMPANDERn_HALT_MASK, 0x0);
	}

	return 0;
}

static int rx_macro_load_compander_coeff(struct snd_soc_component *component,
					 struct rx_macro *rx,
					 int comp, int event)
{
	u16 comp_coeff_lsb_reg, comp_coeff_msb_reg;
	int i;
	int hph_pwr_mode = HPH_LOHIFI;

	if (!rx->comp_enabled[comp])
		return 0;

	if (comp == INTERP_HPHL) {
		comp_coeff_lsb_reg = CDC_RX_TOP_HPHL_COMP_WR_LSB;
		comp_coeff_msb_reg = CDC_RX_TOP_HPHL_COMP_WR_MSB;
	} else if (comp == INTERP_HPHR) {
		comp_coeff_lsb_reg = CDC_RX_TOP_HPHR_COMP_WR_LSB;
		comp_coeff_msb_reg = CDC_RX_TOP_HPHR_COMP_WR_MSB;
	} else {
		/* compander coefficients are loaded only for hph path */
		return 0;
	}

	hph_pwr_mode = rx->hph_pwr_mode;

	if (SND_SOC_DAPM_EVENT_ON(event)) {
		/* Load Compander Coeff */
		for (i = 0; i < COMP_MAX_COEFF; i++) {
			snd_soc_component_write(component, comp_coeff_lsb_reg,
					comp_coeff_table[hph_pwr_mode][i].lsb);
			snd_soc_component_write(component, comp_coeff_msb_reg,
					comp_coeff_table[hph_pwr_mode][i].msb);
		}
	}

	return 0;
}

static void rx_macro_enable_softclip_clk(struct snd_soc_component *component,
					 struct rx_macro *rx, bool enable)
{
	if (enable) {
		if (rx->softclip_clk_users == 0)
			snd_soc_component_write_field(component, CDC_RX_SOFTCLIP_CRC,
						      CDC_RX_SOFTCLIP_CLK_EN_MASK, 1);
		rx->softclip_clk_users++;
	} else {
		rx->softclip_clk_users--;
		if (rx->softclip_clk_users == 0)
			snd_soc_component_write_field(component, CDC_RX_SOFTCLIP_CRC,
						      CDC_RX_SOFTCLIP_CLK_EN_MASK, 0);
	}
}

static int rx_macro_config_softclip(struct snd_soc_component *component,
				    struct rx_macro *rx, int event)
{

	if (!rx->is_softclip_on)
		return 0;

	if (SND_SOC_DAPM_EVENT_ON(event)) {
		/* Enable Softclip clock */
		rx_macro_enable_softclip_clk(component, rx, true);
		/* Enable Softclip control */
		snd_soc_component_write_field(component, CDC_RX_SOFTCLIP_SOFTCLIP_CTRL,
					     CDC_RX_SOFTCLIP_EN_MASK, 0x01);
	}

	if (SND_SOC_DAPM_EVENT_OFF(event)) {
		snd_soc_component_write_field(component, CDC_RX_SOFTCLIP_SOFTCLIP_CTRL,
					     CDC_RX_SOFTCLIP_EN_MASK, 0x0);
		rx_macro_enable_softclip_clk(component, rx, false);
	}

	return 0;
}

static int rx_macro_config_aux_hpf(struct snd_soc_component *component,
				   struct rx_macro *rx, int event)
{
	if (SND_SOC_DAPM_EVENT_ON(event)) {
		/* Update Aux HPF control */
		if (!rx->is_aux_hpf_on)
			snd_soc_component_update_bits(component,
				CDC_RX_RX2_RX_PATH_CFG1, 0x04, 0x00);
	}

	if (SND_SOC_DAPM_EVENT_OFF(event)) {
		/* Reset to default (HPF=ON) */
		snd_soc_component_update_bits(component,
			CDC_RX_RX2_RX_PATH_CFG1, 0x04, 0x04);
	}

	return 0;
}

static inline void rx_macro_enable_clsh_block(struct rx_macro *rx, bool enable)
{
	if ((enable && ++rx->clsh_users == 1) || (!enable && --rx->clsh_users == 0))
		snd_soc_component_update_bits(rx->component, CDC_RX_CLSH_CRC,
					     CDC_RX_CLSH_CLK_EN_MASK, enable);
	if (rx->clsh_users < 0)
		rx->clsh_users = 0;
}

static int rx_macro_config_classh(struct snd_soc_component *component,
				struct rx_macro *rx,
				int interp_n, int event)
{
	if (SND_SOC_DAPM_EVENT_OFF(event)) {
		rx_macro_enable_clsh_block(rx, false);
		return 0;
	}

	if (!SND_SOC_DAPM_EVENT_ON(event))
		return 0;

	rx_macro_enable_clsh_block(rx, true);
	if (interp_n == INTERP_HPHL ||
		interp_n == INTERP_HPHR) {
		/*
		 * These K1 values depend on the Headphone Impedance
		 * For now it is assumed to be 16 ohm
		 */
		snd_soc_component_write(component, CDC_RX_CLSH_K1_LSB, 0xc0);
		snd_soc_component_write_field(component, CDC_RX_CLSH_K1_MSB,
					      CDC_RX_CLSH_K1_MSB_COEFF_MASK, 0);
	}
	switch (interp_n) {
	case INTERP_HPHL:
		if (rx->is_ear_mode_on)
			snd_soc_component_update_bits(component,
				CDC_RX_CLSH_HPH_V_PA,
				CDC_RX_CLSH_HPH_V_PA_MIN_MASK, 0x39);
		else
			snd_soc_component_update_bits(component,
				CDC_RX_CLSH_HPH_V_PA,
				CDC_RX_CLSH_HPH_V_PA_MIN_MASK, 0x1c);
		snd_soc_component_update_bits(component,
				CDC_RX_CLSH_DECAY_CTRL,
				CDC_RX_CLSH_DECAY_RATE_MASK, 0x0);
		snd_soc_component_write_field(component,
				CDC_RX_RX0_RX_PATH_CFG0,
				CDC_RX_RXn_CLSH_EN_MASK, 0x1);
		break;
	case INTERP_HPHR:
		if (rx->is_ear_mode_on)
			snd_soc_component_update_bits(component,
				CDC_RX_CLSH_HPH_V_PA,
				CDC_RX_CLSH_HPH_V_PA_MIN_MASK, 0x39);
		else
			snd_soc_component_update_bits(component,
				CDC_RX_CLSH_HPH_V_PA,
				CDC_RX_CLSH_HPH_V_PA_MIN_MASK, 0x1c);
		snd_soc_component_update_bits(component,
				CDC_RX_CLSH_DECAY_CTRL,
				CDC_RX_CLSH_DECAY_RATE_MASK, 0x0);
		snd_soc_component_update_bits(component,
				CDC_RX_RX1_RX_PATH_CFG0,
				CDC_RX_RXn_CLSH_EN_MASK, 0x1);
		break;
	case INTERP_AUX:
		snd_soc_component_update_bits(component,
				CDC_RX_RX2_RX_PATH_CFG0,
				CDC_RX_RX2_DLY_Z_EN_MASK, 1);
		snd_soc_component_write_field(component,
				CDC_RX_RX2_RX_PATH_CFG0,
				CDC_RX_RX2_CLSH_EN_MASK, 1);
		break;
	}

	return 0;
}

static void rx_macro_hd2_control(struct snd_soc_component *component,
				 u16 interp_idx, int event)
{
	u16 hd2_scale_reg, hd2_enable_reg;

	switch (interp_idx) {
	case INTERP_HPHL:
		hd2_scale_reg = CDC_RX_RX0_RX_PATH_SEC3;
		hd2_enable_reg = CDC_RX_RX0_RX_PATH_CFG0;
		break;
	case INTERP_HPHR:
		hd2_scale_reg = CDC_RX_RX1_RX_PATH_SEC3;
		hd2_enable_reg = CDC_RX_RX1_RX_PATH_CFG0;
		break;
	}

	if (hd2_enable_reg && SND_SOC_DAPM_EVENT_ON(event)) {
		snd_soc_component_update_bits(component, hd2_scale_reg,
				CDC_RX_RXn_HD2_ALPHA_MASK, 0x14);
		snd_soc_component_write_field(component, hd2_enable_reg,
					      CDC_RX_RXn_HD2_EN_MASK, 1);
	}

	if (hd2_enable_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
		snd_soc_component_write_field(component, hd2_enable_reg,
					      CDC_RX_RXn_HD2_EN_MASK, 0);
		snd_soc_component_update_bits(component, hd2_scale_reg,
				CDC_RX_RXn_HD2_ALPHA_MASK, 0x0);
	}
}

static int rx_macro_get_compander(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component =
				snd_soc_kcontrol_component(kcontrol);
	int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift;
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	ucontrol->value.integer.value[0] = rx->comp_enabled[comp];
	return 0;
}

static int rx_macro_set_compander(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	int comp = ((struct soc_mixer_control *)  kcontrol->private_value)->shift;
	int value = ucontrol->value.integer.value[0];
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	rx->comp_enabled[comp] = value;

	return 0;
}

static int rx_macro_mux_get(struct snd_kcontrol *kcontrol,
			  struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol);
	struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	ucontrol->value.integer.value[0] =
			rx->rx_port_value[widget->shift];
	return 0;
}

static int rx_macro_mux_put(struct snd_kcontrol *kcontrol,
			    struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_dapm_widget *widget = snd_soc_dapm_kcontrol_widget(kcontrol);
	struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm);
	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
	struct snd_soc_dapm_update *update = NULL;
	u32 rx_port_value = ucontrol->value.integer.value[0];
	u32 aif_rst;
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	aif_rst = rx->rx_port_value[widget->shift];
	if (!rx_port_value) {
		if (aif_rst == 0) {
			dev_err(component->dev, "%s:AIF reset already\n", __func__);
			return 0;
		}
		if (aif_rst > RX_MACRO_AIF4_PB) {
			dev_err(component->dev, "%s: Invalid AIF reset\n", __func__);
			return 0;
		}
	}
	rx->rx_port_value[widget->shift] = rx_port_value;

	switch (rx_port_value) {
	case 0:
		if (rx->active_ch_cnt[aif_rst]) {
			clear_bit(widget->shift,
				&rx->active_ch_mask[aif_rst]);
			rx->active_ch_cnt[aif_rst]--;
		}
		break;
	case 1:
	case 2:
	case 3:
	case 4:
		set_bit(widget->shift,
			&rx->active_ch_mask[rx_port_value]);
		rx->active_ch_cnt[rx_port_value]++;
		break;
	default:
		dev_err(component->dev,
			"%s:Invalid AIF_ID for RX_MACRO MUX %d\n",
			__func__, rx_port_value);
		goto err;
	}

	snd_soc_dapm_mux_update_power(widget->dapm, kcontrol,
					rx_port_value, e, update);
	return 0;
err:
	return -EINVAL;
}

static const struct snd_kcontrol_new rx_macro_rx0_mux =
		SOC_DAPM_ENUM_EXT("rx_macro_rx0", rx_macro_rx0_enum,
		  rx_macro_mux_get, rx_macro_mux_put);
static const struct snd_kcontrol_new rx_macro_rx1_mux =
		SOC_DAPM_ENUM_EXT("rx_macro_rx1", rx_macro_rx1_enum,
		  rx_macro_mux_get, rx_macro_mux_put);
static const struct snd_kcontrol_new rx_macro_rx2_mux =
		SOC_DAPM_ENUM_EXT("rx_macro_rx2", rx_macro_rx2_enum,
		  rx_macro_mux_get, rx_macro_mux_put);
static const struct snd_kcontrol_new rx_macro_rx3_mux =
		SOC_DAPM_ENUM_EXT("rx_macro_rx3", rx_macro_rx3_enum,
		  rx_macro_mux_get, rx_macro_mux_put);
static const struct snd_kcontrol_new rx_macro_rx4_mux =
		SOC_DAPM_ENUM_EXT("rx_macro_rx4", rx_macro_rx4_enum,
		  rx_macro_mux_get, rx_macro_mux_put);
static const struct snd_kcontrol_new rx_macro_rx5_mux =
		SOC_DAPM_ENUM_EXT("rx_macro_rx5", rx_macro_rx5_enum,
		  rx_macro_mux_get, rx_macro_mux_put);

static int rx_macro_get_ear_mode(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	ucontrol->value.integer.value[0] = rx->is_ear_mode_on;
	return 0;
}

static int rx_macro_put_ear_mode(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	rx->is_ear_mode_on = (!ucontrol->value.integer.value[0] ? false : true);
	return 0;
}

static int rx_macro_get_hph_hd2_mode(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	ucontrol->value.integer.value[0] = rx->hph_hd2_mode;
	return 0;
}

static int rx_macro_put_hph_hd2_mode(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	rx->hph_hd2_mode = ucontrol->value.integer.value[0];
	return 0;
}

static int rx_macro_get_hph_pwr_mode(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	ucontrol->value.integer.value[0] = rx->hph_pwr_mode;
	return 0;
}

static int rx_macro_put_hph_pwr_mode(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	rx->hph_pwr_mode = ucontrol->value.integer.value[0];
	return 0;
}

static int rx_macro_soft_clip_enable_get(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	ucontrol->value.integer.value[0] = rx->is_softclip_on;

	return 0;
}

static int rx_macro_soft_clip_enable_put(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	rx->is_softclip_on = ucontrol->value.integer.value[0];

	return 0;
}

static int rx_macro_aux_hpf_mode_get(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	ucontrol->value.integer.value[0] = rx->is_aux_hpf_on;

	return 0;
}

static int rx_macro_aux_hpf_mode_put(struct snd_kcontrol *kcontrol,
					  struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	rx->is_aux_hpf_on = ucontrol->value.integer.value[0];

	return 0;
}

static int rx_macro_hphdelay_lutbypass(struct snd_soc_component *component,
					struct rx_macro *rx,
					u16 interp_idx, int event)
{
	u16 hph_lut_bypass_reg;
	u16 hph_comp_ctrl7;

	switch (interp_idx) {
	case INTERP_HPHL:
		hph_lut_bypass_reg = CDC_RX_TOP_HPHL_COMP_LUT;
		hph_comp_ctrl7 = CDC_RX_COMPANDER0_CTL7;
		break;
	case INTERP_HPHR:
		hph_lut_bypass_reg = CDC_RX_TOP_HPHR_COMP_LUT;
		hph_comp_ctrl7 = CDC_RX_COMPANDER1_CTL7;
		break;
	default:
		return -EINVAL;
	}

	if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_ON(event)) {
		if (interp_idx == INTERP_HPHL) {
			if (rx->is_ear_mode_on)
				snd_soc_component_write_field(component,
					CDC_RX_RX0_RX_PATH_CFG1,
					CDC_RX_RX0_HPH_L_EAR_SEL_MASK, 0x1);
			else
				snd_soc_component_write_field(component,
					hph_lut_bypass_reg,
					CDC_RX_TOP_HPH_LUT_BYPASS_MASK, 1);
		} else {
			snd_soc_component_write_field(component, hph_lut_bypass_reg,
					CDC_RX_TOP_HPH_LUT_BYPASS_MASK, 1);
		}
		if (rx->hph_pwr_mode)
			snd_soc_component_write_field(component, hph_comp_ctrl7,
					CDC_RX_COMPANDER1_HPH_LOW_PWR_MODE_MASK, 0x0);
	}

	if (hph_lut_bypass_reg && SND_SOC_DAPM_EVENT_OFF(event)) {
		snd_soc_component_write_field(component,
					CDC_RX_RX0_RX_PATH_CFG1,
					CDC_RX_RX0_HPH_L_EAR_SEL_MASK, 0x0);
		snd_soc_component_update_bits(component, hph_lut_bypass_reg,
					CDC_RX_TOP_HPH_LUT_BYPASS_MASK, 0);
		snd_soc_component_write_field(component, hph_comp_ctrl7,
					CDC_RX_COMPANDER1_HPH_LOW_PWR_MODE_MASK, 0x1);
	}

	return 0;
}

static int rx_macro_enable_interp_clk(struct snd_soc_component *component,
				      int event, int interp_idx)
{
	u16 main_reg, dsm_reg, rx_cfg2_reg;
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	main_reg = CDC_RX_RXn_RX_PATH_CTL(interp_idx);
	dsm_reg = CDC_RX_RXn_RX_PATH_DSM_CTL(interp_idx);
	if (interp_idx == INTERP_AUX)
		dsm_reg = CDC_RX_RX2_RX_PATH_DSM_CTL;
	rx_cfg2_reg = CDC_RX_RXn_RX_PATH_CFG2(interp_idx);

	if (SND_SOC_DAPM_EVENT_ON(event)) {
		if (rx->main_clk_users[interp_idx] == 0) {
			/* Main path PGA mute enable */
			snd_soc_component_write_field(component, main_reg,
						      CDC_RX_PATH_PGA_MUTE_MASK, 0x1);
			snd_soc_component_write_field(component, dsm_reg,
						      CDC_RX_RXn_DSM_CLK_EN_MASK, 0x1);
			snd_soc_component_update_bits(component, rx_cfg2_reg,
					CDC_RX_RXn_HPF_CUT_FREQ_MASK, 0x03);
			rx_macro_load_compander_coeff(component, rx, interp_idx, event);
			if (rx->hph_hd2_mode)
				rx_macro_hd2_control(component, interp_idx, event);
			rx_macro_hphdelay_lutbypass(component, rx, interp_idx, event);
			rx_macro_config_compander(component, rx, interp_idx, event);
			if (interp_idx == INTERP_AUX) {
				rx_macro_config_softclip(component, rx,	event);
				rx_macro_config_aux_hpf(component, rx, event);
			}
			rx_macro_config_classh(component, rx, interp_idx, event);
		}
		rx->main_clk_users[interp_idx]++;
	}

	if (SND_SOC_DAPM_EVENT_OFF(event)) {
		rx->main_clk_users[interp_idx]--;
		if (rx->main_clk_users[interp_idx] <= 0) {
			rx->main_clk_users[interp_idx] = 0;
			/* Main path PGA mute enable */
			snd_soc_component_write_field(component, main_reg,
						      CDC_RX_PATH_PGA_MUTE_MASK, 0x1);
			/* Clk Disable */
			snd_soc_component_write_field(component, dsm_reg,
						      CDC_RX_RXn_DSM_CLK_EN_MASK, 0);
			snd_soc_component_write_field(component, main_reg,
						      CDC_RX_PATH_CLK_EN_MASK, 0);
			/* Reset enable and disable */
			snd_soc_component_write_field(component, main_reg,
						      CDC_RX_PATH_RESET_EN_MASK, 1);
			snd_soc_component_write_field(component, main_reg,
						      CDC_RX_PATH_RESET_EN_MASK, 0);
			/* Reset rate to 48K*/
			snd_soc_component_update_bits(component, main_reg,
						      CDC_RX_PATH_PCM_RATE_MASK,
						      0x04);
			snd_soc_component_update_bits(component, rx_cfg2_reg,
						      CDC_RX_RXn_HPF_CUT_FREQ_MASK, 0x00);
			rx_macro_config_classh(component, rx, interp_idx, event);
			rx_macro_config_compander(component, rx, interp_idx, event);
			if (interp_idx ==  INTERP_AUX) {
				rx_macro_config_softclip(component, rx,	event);
				rx_macro_config_aux_hpf(component, rx, event);
			}
			rx_macro_hphdelay_lutbypass(component, rx, interp_idx, event);
			if (rx->hph_hd2_mode)
				rx_macro_hd2_control(component, interp_idx, event);
		}
	}

	return rx->main_clk_users[interp_idx];
}

static int rx_macro_enable_mix_path(struct snd_soc_dapm_widget *w,
				    struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
	u16 gain_reg, mix_reg;

	gain_reg = CDC_RX_RXn_RX_VOL_MIX_CTL(w->shift);
	mix_reg = CDC_RX_RXn_RX_PATH_MIX_CTL(w->shift);

	switch (event) {
	case SND_SOC_DAPM_PRE_PMU:
		rx_macro_enable_interp_clk(component, event, w->shift);
		break;
	case SND_SOC_DAPM_POST_PMU:
		snd_soc_component_write(component, gain_reg,
					snd_soc_component_read(component, gain_reg));
		break;
	case SND_SOC_DAPM_POST_PMD:
		/* Clk Disable */
		snd_soc_component_update_bits(component, mix_reg,
					      CDC_RX_RXn_MIX_CLK_EN_MASK, 0x00);
		rx_macro_enable_interp_clk(component, event, w->shift);
		/* Reset enable and disable */
		snd_soc_component_update_bits(component, mix_reg,
					      CDC_RX_RXn_MIX_RESET_MASK,
					      CDC_RX_RXn_MIX_RESET);
		snd_soc_component_update_bits(component, mix_reg,
					      CDC_RX_RXn_MIX_RESET_MASK, 0x00);
		break;
	}

	return 0;
}

static int rx_macro_enable_rx_path_clk(struct snd_soc_dapm_widget *w,
				       struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);

	switch (event) {
	case SND_SOC_DAPM_PRE_PMU:
		rx_macro_enable_interp_clk(component, event, w->shift);
		snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CFG1(w->shift),
					      CDC_RX_RXn_SIDETONE_EN_MASK, 1);
		snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CTL(w->shift),
					      CDC_RX_PATH_CLK_EN_MASK, 1);
		break;
	case SND_SOC_DAPM_POST_PMD:
		snd_soc_component_write_field(component, CDC_RX_RXn_RX_PATH_CFG1(w->shift),
					      CDC_RX_RXn_SIDETONE_EN_MASK, 0);
		rx_macro_enable_interp_clk(component, event, w->shift);
		break;
	default:
		break;
	};
	return 0;
}

static int rx_macro_set_iir_gain(struct snd_soc_dapm_widget *w,
				 struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);

	switch (event) {
	case SND_SOC_DAPM_POST_PMU: /* fall through */
	case SND_SOC_DAPM_PRE_PMD:
		if (strnstr(w->name, "IIR0", sizeof("IIR0"))) {
			snd_soc_component_write(component,
				CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL,
			snd_soc_component_read(component,
				CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL));
			snd_soc_component_write(component,
				CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL,
			snd_soc_component_read(component,
				CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL));
			snd_soc_component_write(component,
				CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL,
			snd_soc_component_read(component,
				CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL));
			snd_soc_component_write(component,
				CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL,
			snd_soc_component_read(component,
				CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL));
		} else {
			snd_soc_component_write(component,
				CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL,
			snd_soc_component_read(component,
				CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL));
			snd_soc_component_write(component,
				CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL,
			snd_soc_component_read(component,
				CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL));
			snd_soc_component_write(component,
				CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL,
			snd_soc_component_read(component,
				CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL));
			snd_soc_component_write(component,
				CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL,
			snd_soc_component_read(component,
				CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL));
		}
		break;
	}
	return 0;
}

static uint32_t get_iir_band_coeff(struct snd_soc_component *component,
				   int iir_idx, int band_idx, int coeff_idx)
{
	u32 value;
	int reg, b2_reg;

	/* Address does not automatically update if reading */
	reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx;
	b2_reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx;

	snd_soc_component_write(component, reg,
				((band_idx * BAND_MAX + coeff_idx) *
				 sizeof(uint32_t)) & 0x7F);

	value = snd_soc_component_read(component, b2_reg);
	snd_soc_component_write(component, reg,
				((band_idx * BAND_MAX + coeff_idx)
				 * sizeof(uint32_t) + 1) & 0x7F);

	value |= (snd_soc_component_read(component, b2_reg) << 8);
	snd_soc_component_write(component, reg,
				((band_idx * BAND_MAX + coeff_idx)
				 * sizeof(uint32_t) + 2) & 0x7F);

	value |= (snd_soc_component_read(component, b2_reg) << 16);
	snd_soc_component_write(component, reg,
		((band_idx * BAND_MAX + coeff_idx)
		* sizeof(uint32_t) + 3) & 0x7F);

	/* Mask bits top 2 bits since they are reserved */
	value |= (snd_soc_component_read(component, b2_reg) << 24);
	return value;
}

static void set_iir_band_coeff(struct snd_soc_component *component,
			       int iir_idx, int band_idx, uint32_t value)
{
	int reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx;

	snd_soc_component_write(component, reg, (value & 0xFF));
	snd_soc_component_write(component, reg, (value >> 8) & 0xFF);
	snd_soc_component_write(component, reg, (value >> 16) & 0xFF);
	/* Mask top 2 bits, 7-8 are reserved */
	snd_soc_component_write(component, reg, (value >> 24) & 0x3F);
}

static int rx_macro_put_iir_band_audio_mixer(
					struct snd_kcontrol *kcontrol,
					struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component =
			snd_soc_kcontrol_component(kcontrol);
	struct wcd_iir_filter_ctl *ctl =
			(struct wcd_iir_filter_ctl *)kcontrol->private_value;
	struct soc_bytes_ext *params = &ctl->bytes_ext;
	int iir_idx = ctl->iir_idx;
	int band_idx = ctl->band_idx;
	u32 coeff[BAND_MAX];
	int reg = CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx;

	memcpy(&coeff[0], ucontrol->value.bytes.data, params->max);

	/* Mask top bit it is reserved */
	/* Updates addr automatically for each B2 write */
	snd_soc_component_write(component, reg, (band_idx * BAND_MAX *
						 sizeof(uint32_t)) & 0x7F);

	set_iir_band_coeff(component, iir_idx, band_idx, coeff[0]);
	set_iir_band_coeff(component, iir_idx, band_idx, coeff[1]);
	set_iir_band_coeff(component, iir_idx, band_idx, coeff[2]);
	set_iir_band_coeff(component, iir_idx, band_idx, coeff[3]);
	set_iir_band_coeff(component, iir_idx, band_idx, coeff[4]);

	return 0;
}

static int rx_macro_get_iir_band_audio_mixer(struct snd_kcontrol *kcontrol,
				    struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component =
			snd_soc_kcontrol_component(kcontrol);
	struct wcd_iir_filter_ctl *ctl =
			(struct wcd_iir_filter_ctl *)kcontrol->private_value;
	struct soc_bytes_ext *params = &ctl->bytes_ext;
	int iir_idx = ctl->iir_idx;
	int band_idx = ctl->band_idx;
	u32 coeff[BAND_MAX];

	coeff[0] = get_iir_band_coeff(component, iir_idx, band_idx, 0);
	coeff[1] = get_iir_band_coeff(component, iir_idx, band_idx, 1);
	coeff[2] = get_iir_band_coeff(component, iir_idx, band_idx, 2);
	coeff[3] = get_iir_band_coeff(component, iir_idx, band_idx, 3);
	coeff[4] = get_iir_band_coeff(component, iir_idx, band_idx, 4);

	memcpy(ucontrol->value.bytes.data, &coeff[0], params->max);

	return 0;
}

static int rx_macro_iir_filter_info(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_info *ucontrol)
{
	struct wcd_iir_filter_ctl *ctl =
		(struct wcd_iir_filter_ctl *)kcontrol->private_value;
	struct soc_bytes_ext *params = &ctl->bytes_ext;

	ucontrol->type = SNDRV_CTL_ELEM_TYPE_BYTES;
	ucontrol->count = params->max;

	return 0;
}

static const struct snd_kcontrol_new rx_macro_snd_controls[] = {
	SOC_SINGLE_S8_TLV("RX_RX0 Digital Volume", CDC_RX_RX0_RX_VOL_CTL,
			  -84, 40, digital_gain),
	SOC_SINGLE_S8_TLV("RX_RX1 Digital Volume", CDC_RX_RX1_RX_VOL_CTL,
			  -84, 40, digital_gain),
	SOC_SINGLE_S8_TLV("RX_RX2 Digital Volume", CDC_RX_RX2_RX_VOL_CTL,
			  -84, 40, digital_gain),
	SOC_SINGLE_S8_TLV("RX_RX0 Mix Digital Volume", CDC_RX_RX0_RX_VOL_MIX_CTL,
			  -84, 40, digital_gain),
	SOC_SINGLE_S8_TLV("RX_RX1 Mix Digital Volume", CDC_RX_RX1_RX_VOL_MIX_CTL,
			  -84, 40, digital_gain),
	SOC_SINGLE_S8_TLV("RX_RX2 Mix Digital Volume", CDC_RX_RX2_RX_VOL_MIX_CTL,
			  -84, 40, digital_gain),

	SOC_SINGLE_EXT("RX_COMP1 Switch", SND_SOC_NOPM, RX_MACRO_COMP1, 1, 0,
		rx_macro_get_compander, rx_macro_set_compander),
	SOC_SINGLE_EXT("RX_COMP2 Switch", SND_SOC_NOPM, RX_MACRO_COMP2, 1, 0,
		rx_macro_get_compander, rx_macro_set_compander),

	SOC_SINGLE_EXT("RX_EAR Mode Switch", SND_SOC_NOPM, 0, 1, 0,
		rx_macro_get_ear_mode, rx_macro_put_ear_mode),

	SOC_SINGLE_EXT("RX_HPH HD2 Mode Switch", SND_SOC_NOPM, 0, 1, 0,
		rx_macro_get_hph_hd2_mode, rx_macro_put_hph_hd2_mode),

	SOC_ENUM_EXT("RX_HPH PWR Mode", rx_macro_hph_pwr_mode_enum,
		rx_macro_get_hph_pwr_mode, rx_macro_put_hph_pwr_mode),

	SOC_SINGLE_EXT("RX_Softclip Switch", SND_SOC_NOPM, 0, 1, 0,
		     rx_macro_soft_clip_enable_get,
		     rx_macro_soft_clip_enable_put),
	SOC_SINGLE_EXT("AUX_HPF Switch", SND_SOC_NOPM, 0, 1, 0,
			rx_macro_aux_hpf_mode_get,
			rx_macro_aux_hpf_mode_put),

	SOC_SINGLE_S8_TLV("IIR0 INP0 Volume",
		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40,
		digital_gain),
	SOC_SINGLE_S8_TLV("IIR0 INP1 Volume",
		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B2_CTL, -84, 40,
		digital_gain),
	SOC_SINGLE_S8_TLV("IIR0 INP2 Volume",
		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B3_CTL, -84, 40,
		digital_gain),
	SOC_SINGLE_S8_TLV("IIR0 INP3 Volume",
		CDC_RX_SIDETONE_IIR0_IIR_GAIN_B4_CTL, -84, 40,
		digital_gain),
	SOC_SINGLE_S8_TLV("IIR1 INP0 Volume",
		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B1_CTL, -84, 40,
		digital_gain),
	SOC_SINGLE_S8_TLV("IIR1 INP1 Volume",
		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B2_CTL, -84, 40,
		digital_gain),
	SOC_SINGLE_S8_TLV("IIR1 INP2 Volume",
		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B3_CTL, -84, 40,
		digital_gain),
	SOC_SINGLE_S8_TLV("IIR1 INP3 Volume",
		CDC_RX_SIDETONE_IIR1_IIR_GAIN_B4_CTL, -84, 40,
		digital_gain),

	SOC_SINGLE("IIR1 Band1 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL,
		   0, 1, 0),
	SOC_SINGLE("IIR1 Band2 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL,
		   1, 1, 0),
	SOC_SINGLE("IIR1 Band3 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL,
		   2, 1, 0),
	SOC_SINGLE("IIR1 Band4 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL,
		   3, 1, 0),
	SOC_SINGLE("IIR1 Band5 Switch", CDC_RX_SIDETONE_IIR0_IIR_CTL,
		   4, 1, 0),
	SOC_SINGLE("IIR2 Band1 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL,
		   0, 1, 0),
	SOC_SINGLE("IIR2 Band2 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL,
		   1, 1, 0),
	SOC_SINGLE("IIR2 Band3 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL,
		   2, 1, 0),
	SOC_SINGLE("IIR2 Band4 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL,
		   3, 1, 0),
	SOC_SINGLE("IIR2 Band5 Switch", CDC_RX_SIDETONE_IIR1_IIR_CTL,
		   4, 1, 0),

	RX_MACRO_IIR_FILTER_CTL("IIR0 Band1", IIR0, BAND1),
	RX_MACRO_IIR_FILTER_CTL("IIR0 Band2", IIR0, BAND2),
	RX_MACRO_IIR_FILTER_CTL("IIR0 Band3", IIR0, BAND3),
	RX_MACRO_IIR_FILTER_CTL("IIR0 Band4", IIR0, BAND4),
	RX_MACRO_IIR_FILTER_CTL("IIR0 Band5", IIR0, BAND5),

	RX_MACRO_IIR_FILTER_CTL("IIR1 Band1", IIR1, BAND1),
	RX_MACRO_IIR_FILTER_CTL("IIR1 Band2", IIR1, BAND2),
	RX_MACRO_IIR_FILTER_CTL("IIR1 Band3", IIR1, BAND3),
	RX_MACRO_IIR_FILTER_CTL("IIR1 Band4", IIR1, BAND4),
	RX_MACRO_IIR_FILTER_CTL("IIR1 Band5", IIR1, BAND5),

};

static int rx_macro_enable_echo(struct snd_soc_dapm_widget *w,
				struct snd_kcontrol *kcontrol,
				int event)
{
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
	u16 val, ec_hq_reg;
	int ec_tx;

	val = snd_soc_component_read(component,
			CDC_RX_INP_MUX_RX_MIX_CFG4);
	if (!(strcmp(w->name, "RX MIX TX0 MUX")))
		ec_tx = ((val & 0xf0) >> 0x4) - 1;
	else if (!(strcmp(w->name, "RX MIX TX1 MUX")))
		ec_tx = (val & 0x0f) - 1;

	val = snd_soc_component_read(component,
			CDC_RX_INP_MUX_RX_MIX_CFG5);
	if (!(strcmp(w->name, "RX MIX TX2 MUX")))
		ec_tx = (val & 0x0f) - 1;

	if (ec_tx < 0 || (ec_tx >= RX_MACRO_EC_MUX_MAX)) {
		dev_err(component->dev, "%s: EC mix control not set correctly\n",
			__func__);
		return -EINVAL;
	}
	ec_hq_reg = CDC_RX_EC_REF_HQ0_EC_REF_HQ_PATH_CTL +
			    0x40 * ec_tx;
	snd_soc_component_update_bits(component, ec_hq_reg, 0x01, 0x01);
	ec_hq_reg = CDC_RX_EC_REF_HQ0_EC_REF_HQ_CFG0 +
				0x40 * ec_tx;
	/* default set to 48k */
	snd_soc_component_update_bits(component, ec_hq_reg, 0x1E, 0x08);

	return 0;
}

static const struct snd_soc_dapm_widget rx_macro_dapm_widgets[] = {
	SND_SOC_DAPM_AIF_IN("RX AIF1 PB", "RX_MACRO_AIF1 Playback", 0,
		SND_SOC_NOPM, 0, 0),

	SND_SOC_DAPM_AIF_IN("RX AIF2 PB", "RX_MACRO_AIF2 Playback", 0,
		SND_SOC_NOPM, 0, 0),

	SND_SOC_DAPM_AIF_IN("RX AIF3 PB", "RX_MACRO_AIF3 Playback", 0,
		SND_SOC_NOPM, 0, 0),

	SND_SOC_DAPM_AIF_IN("RX AIF4 PB", "RX_MACRO_AIF4 Playback", 0,
		SND_SOC_NOPM, 0, 0),

	SND_SOC_DAPM_AIF_OUT("RX AIF_ECHO", "RX_AIF_ECHO Capture", 0,
		SND_SOC_NOPM, 0, 0),

	SND_SOC_DAPM_MUX("RX_MACRO RX0 MUX", SND_SOC_NOPM, RX_MACRO_RX0, 0,
			 &rx_macro_rx0_mux),
	SND_SOC_DAPM_MUX("RX_MACRO RX1 MUX", SND_SOC_NOPM, RX_MACRO_RX1, 0,
			 &rx_macro_rx1_mux),
	SND_SOC_DAPM_MUX("RX_MACRO RX2 MUX", SND_SOC_NOPM, RX_MACRO_RX2, 0,
			 &rx_macro_rx2_mux),
	SND_SOC_DAPM_MUX("RX_MACRO RX3 MUX", SND_SOC_NOPM, RX_MACRO_RX3, 0,
			 &rx_macro_rx3_mux),
	SND_SOC_DAPM_MUX("RX_MACRO RX4 MUX", SND_SOC_NOPM, RX_MACRO_RX4, 0,
			 &rx_macro_rx4_mux),
	SND_SOC_DAPM_MUX("RX_MACRO RX5 MUX", SND_SOC_NOPM, RX_MACRO_RX5, 0,
			 &rx_macro_rx5_mux),

	SND_SOC_DAPM_MIXER("RX_RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX_RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX_RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX_RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX_RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX_RX5", SND_SOC_NOPM, 0, 0, NULL, 0),

	SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
	SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
	SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
	SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
	SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
	SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
	SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
	SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),

	SND_SOC_DAPM_MUX_E("RX MIX TX0 MUX", SND_SOC_NOPM,
			   RX_MACRO_EC0_MUX, 0,
			   &rx_mix_tx0_mux, rx_macro_enable_echo,
			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MUX_E("RX MIX TX1 MUX", SND_SOC_NOPM,
			   RX_MACRO_EC1_MUX, 0,
			   &rx_mix_tx1_mux, rx_macro_enable_echo,
			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MUX_E("RX MIX TX2 MUX", SND_SOC_NOPM,
			   RX_MACRO_EC2_MUX, 0,
			   &rx_mix_tx2_mux, rx_macro_enable_echo,
			   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),

	SND_SOC_DAPM_MIXER_E("IIR0", CDC_RX_SIDETONE_IIR0_IIR_PATH_CTL,
		4, 0, NULL, 0, rx_macro_set_iir_gain,
		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
	SND_SOC_DAPM_MIXER_E("IIR1", CDC_RX_SIDETONE_IIR1_IIR_PATH_CTL,
		4, 0, NULL, 0, rx_macro_set_iir_gain,
		SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
	SND_SOC_DAPM_MIXER("SRC0", CDC_RX_SIDETONE_SRC0_ST_SRC_PATH_CTL,
		4, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("SRC1", CDC_RX_SIDETONE_SRC1_ST_SRC_PATH_CTL,
		4, 0, NULL, 0),

	SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
			 &rx_int0_dem_inp_mux),
	SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
			 &rx_int1_dem_inp_mux),

	SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", SND_SOC_NOPM, INTERP_HPHL, 0,
		&rx_int0_2_mux, rx_macro_enable_mix_path,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
		SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", SND_SOC_NOPM, INTERP_HPHR, 0,
		&rx_int1_2_mux, rx_macro_enable_mix_path,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
		SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", SND_SOC_NOPM, INTERP_AUX, 0,
		&rx_int2_2_mux, rx_macro_enable_mix_path,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
		SND_SOC_DAPM_POST_PMD),

	SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, &rx_int0_1_mix_inp0_mux),
	SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx_int0_1_mix_inp1_mux),
	SND_SOC_DAPM_MUX("RX INT0_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx_int0_1_mix_inp2_mux),
	SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, &rx_int1_1_mix_inp0_mux),
	SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx_int1_1_mix_inp1_mux),
	SND_SOC_DAPM_MUX("RX INT1_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx_int1_1_mix_inp2_mux),
	SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP0", SND_SOC_NOPM, 0, 0, &rx_int2_1_mix_inp0_mux),
	SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP1", SND_SOC_NOPM, 0, 0, &rx_int2_1_mix_inp1_mux),
	SND_SOC_DAPM_MUX("RX INT2_1 MIX1 INP2", SND_SOC_NOPM, 0, 0, &rx_int2_1_mix_inp2_mux),

	SND_SOC_DAPM_MUX_E("RX INT0_1 INTERP", SND_SOC_NOPM, INTERP_HPHL, 0,
		&rx_int0_1_interp_mux, rx_macro_enable_main_path,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
		SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MUX_E("RX INT1_1 INTERP", SND_SOC_NOPM, INTERP_HPHR, 0,
		&rx_int1_1_interp_mux, rx_macro_enable_main_path,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
		SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MUX_E("RX INT2_1 INTERP", SND_SOC_NOPM, INTERP_AUX, 0,
		&rx_int2_1_interp_mux, rx_macro_enable_main_path,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
		SND_SOC_DAPM_POST_PMD),

	SND_SOC_DAPM_MUX("RX INT0_2 INTERP", SND_SOC_NOPM, 0, 0,
			 &rx_int0_2_interp_mux),
	SND_SOC_DAPM_MUX("RX INT1_2 INTERP", SND_SOC_NOPM, 0, 0,
			 &rx_int1_2_interp_mux),
	SND_SOC_DAPM_MUX("RX INT2_2 INTERP", SND_SOC_NOPM, 0, 0,
			 &rx_int2_2_interp_mux),

	SND_SOC_DAPM_MIXER("RX INT0_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX INT1_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX INT2_1 MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX INT2 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),

	SND_SOC_DAPM_MUX_E("RX INT0 MIX2 INP", SND_SOC_NOPM, INTERP_HPHL,
		0, &rx_int0_mix2_inp_mux, rx_macro_enable_rx_path_clk,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MUX_E("RX INT1 MIX2 INP", SND_SOC_NOPM, INTERP_HPHR,
		0, &rx_int1_mix2_inp_mux, rx_macro_enable_rx_path_clk,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
	SND_SOC_DAPM_MUX_E("RX INT2 MIX2 INP", SND_SOC_NOPM, INTERP_AUX,
		0, &rx_int2_mix2_inp_mux, rx_macro_enable_rx_path_clk,
		SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),

	SND_SOC_DAPM_MIXER("RX INT0 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX INT1 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),
	SND_SOC_DAPM_MIXER("RX INT2 MIX2", SND_SOC_NOPM, 0, 0, NULL, 0),

	SND_SOC_DAPM_OUTPUT("HPHL_OUT"),
	SND_SOC_DAPM_OUTPUT("HPHR_OUT"),
	SND_SOC_DAPM_OUTPUT("AUX_OUT"),

	SND_SOC_DAPM_INPUT("RX_TX DEC0_INP"),
	SND_SOC_DAPM_INPUT("RX_TX DEC1_INP"),
	SND_SOC_DAPM_INPUT("RX_TX DEC2_INP"),
	SND_SOC_DAPM_INPUT("RX_TX DEC3_INP"),

	SND_SOC_DAPM_SUPPLY_S("RX_MCLK", 0, SND_SOC_NOPM, 0, 0,
	rx_macro_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
};

static const struct snd_soc_dapm_route rx_audio_map[] = {
	{"RX AIF1 PB", NULL, "RX_MCLK"},
	{"RX AIF2 PB", NULL, "RX_MCLK"},
	{"RX AIF3 PB", NULL, "RX_MCLK"},
	{"RX AIF4 PB", NULL, "RX_MCLK"},

	{"RX_MACRO RX0 MUX", "AIF1_PB", "RX AIF1 PB"},
	{"RX_MACRO RX1 MUX", "AIF1_PB", "RX AIF1 PB"},
	{"RX_MACRO RX2 MUX", "AIF1_PB", "RX AIF1 PB"},
	{"RX_MACRO RX3 MUX", "AIF1_PB", "RX AIF1 PB"},
	{"RX_MACRO RX4 MUX", "AIF1_PB", "RX AIF1 PB"},
	{"RX_MACRO RX5 MUX", "AIF1_PB", "RX AIF1 PB"},

	{"RX_MACRO RX0 MUX", "AIF2_PB", "RX AIF2 PB"},
	{"RX_MACRO RX1 MUX", "AIF2_PB", "RX AIF2 PB"},
	{"RX_MACRO RX2 MUX", "AIF2_PB", "RX AIF2 PB"},
	{"RX_MACRO RX3 MUX", "AIF2_PB", "RX AIF2 PB"},
	{"RX_MACRO RX4 MUX", "AIF2_PB", "RX AIF2 PB"},
	{"RX_MACRO RX5 MUX", "AIF2_PB", "RX AIF2 PB"},

	{"RX_MACRO RX0 MUX", "AIF3_PB", "RX AIF3 PB"},
	{"RX_MACRO RX1 MUX", "AIF3_PB", "RX AIF3 PB"},
	{"RX_MACRO RX2 MUX", "AIF3_PB", "RX AIF3 PB"},
	{"RX_MACRO RX3 MUX", "AIF3_PB", "RX AIF3 PB"},
	{"RX_MACRO RX4 MUX", "AIF3_PB", "RX AIF3 PB"},
	{"RX_MACRO RX5 MUX", "AIF3_PB", "RX AIF3 PB"},

	{"RX_MACRO RX0 MUX", "AIF4_PB", "RX AIF4 PB"},
	{"RX_MACRO RX1 MUX", "AIF4_PB", "RX AIF4 PB"},
	{"RX_MACRO RX2 MUX", "AIF4_PB", "RX AIF4 PB"},
	{"RX_MACRO RX3 MUX", "AIF4_PB", "RX AIF4 PB"},
	{"RX_MACRO RX4 MUX", "AIF4_PB", "RX AIF4 PB"},
	{"RX_MACRO RX5 MUX", "AIF4_PB", "RX AIF4 PB"},

	{"RX_RX0", NULL, "RX_MACRO RX0 MUX"},
	{"RX_RX1", NULL, "RX_MACRO RX1 MUX"},
	{"RX_RX2", NULL, "RX_MACRO RX2 MUX"},
	{"RX_RX3", NULL, "RX_MACRO RX3 MUX"},
	{"RX_RX4", NULL, "RX_MACRO RX4 MUX"},
	{"RX_RX5", NULL, "RX_MACRO RX5 MUX"},

	{"RX INT0_1 MIX1 INP0", "RX0", "RX_RX0"},
	{"RX INT0_1 MIX1 INP0", "RX1", "RX_RX1"},
	{"RX INT0_1 MIX1 INP0", "RX2", "RX_RX2"},
	{"RX INT0_1 MIX1 INP0", "RX3", "RX_RX3"},
	{"RX INT0_1 MIX1 INP0", "RX4", "RX_RX4"},
	{"RX INT0_1 MIX1 INP0", "RX5", "RX_RX5"},
	{"RX INT0_1 MIX1 INP0", "IIR0", "IIR0"},
	{"RX INT0_1 MIX1 INP0", "IIR1", "IIR1"},
	{"RX INT0_1 MIX1 INP0", "DEC0", "RX_TX DEC0_INP"},
	{"RX INT0_1 MIX1 INP0", "DEC1", "RX_TX DEC1_INP"},
	{"RX INT0_1 MIX1 INP1", "RX0", "RX_RX0"},
	{"RX INT0_1 MIX1 INP1", "RX1", "RX_RX1"},
	{"RX INT0_1 MIX1 INP1", "RX2", "RX_RX2"},
	{"RX INT0_1 MIX1 INP1", "RX3", "RX_RX3"},
	{"RX INT0_1 MIX1 INP1", "RX4", "RX_RX4"},
	{"RX INT0_1 MIX1 INP1", "RX5", "RX_RX5"},
	{"RX INT0_1 MIX1 INP1", "IIR0", "IIR0"},
	{"RX INT0_1 MIX1 INP1", "IIR1", "IIR1"},
	{"RX INT0_1 MIX1 INP1", "DEC0", "RX_TX DEC0_INP"},
	{"RX INT0_1 MIX1 INP1", "DEC1", "RX_TX DEC1_INP"},
	{"RX INT0_1 MIX1 INP2", "RX0", "RX_RX0"},
	{"RX INT0_1 MIX1 INP2", "RX1", "RX_RX1"},
	{"RX INT0_1 MIX1 INP2", "RX2", "RX_RX2"},
	{"RX INT0_1 MIX1 INP2", "RX3", "RX_RX3"},
	{"RX INT0_1 MIX1 INP2", "RX4", "RX_RX4"},
	{"RX INT0_1 MIX1 INP2", "RX5", "RX_RX5"},
	{"RX INT0_1 MIX1 INP2", "IIR0", "IIR0"},
	{"RX INT0_1 MIX1 INP2", "IIR1", "IIR1"},
	{"RX INT0_1 MIX1 INP2", "DEC0", "RX_TX DEC0_INP"},
	{"RX INT0_1 MIX1 INP2", "DEC1", "RX_TX DEC1_INP"},

	{"RX INT1_1 MIX1 INP0", "RX0", "RX_RX0"},
	{"RX INT1_1 MIX1 INP0", "RX1", "RX_RX1"},
	{"RX INT1_1 MIX1 INP0", "RX2", "RX_RX2"},
	{"RX INT1_1 MIX1 INP0", "RX3", "RX_RX3"},
	{"RX INT1_1 MIX1 INP0", "RX4", "RX_RX4"},
	{"RX INT1_1 MIX1 INP0", "RX5", "RX_RX5"},
	{"RX INT1_1 MIX1 INP0", "IIR0", "IIR0"},
	{"RX INT1_1 MIX1 INP0", "IIR1", "IIR1"},
	{"RX INT1_1 MIX1 INP0", "DEC0", "RX_TX DEC0_INP"},
	{"RX INT1_1 MIX1 INP0", "DEC1", "RX_TX DEC1_INP"},
	{"RX INT1_1 MIX1 INP1", "RX0", "RX_RX0"},
	{"RX INT1_1 MIX1 INP1", "RX1", "RX_RX1"},
	{"RX INT1_1 MIX1 INP1", "RX2", "RX_RX2"},
	{"RX INT1_1 MIX1 INP1", "RX3", "RX_RX3"},
	{"RX INT1_1 MIX1 INP1", "RX4", "RX_RX4"},
	{"RX INT1_1 MIX1 INP1", "RX5", "RX_RX5"},
	{"RX INT1_1 MIX1 INP1", "IIR0", "IIR0"},
	{"RX INT1_1 MIX1 INP1", "IIR1", "IIR1"},
	{"RX INT1_1 MIX1 INP1", "DEC0", "RX_TX DEC0_INP"},
	{"RX INT1_1 MIX1 INP1", "DEC1", "RX_TX DEC1_INP"},
	{"RX INT1_1 MIX1 INP2", "RX0", "RX_RX0"},
	{"RX INT1_1 MIX1 INP2", "RX1", "RX_RX1"},
	{"RX INT1_1 MIX1 INP2", "RX2", "RX_RX2"},
	{"RX INT1_1 MIX1 INP2", "RX3", "RX_RX3"},
	{"RX INT1_1 MIX1 INP2", "RX4", "RX_RX4"},
	{"RX INT1_1 MIX1 INP2", "RX5", "RX_RX5"},
	{"RX INT1_1 MIX1 INP2", "IIR0", "IIR0"},
	{"RX INT1_1 MIX1 INP2", "IIR1", "IIR1"},
	{"RX INT1_1 MIX1 INP2", "DEC0", "RX_TX DEC0_INP"},
	{"RX INT1_1 MIX1 INP2", "DEC1", "RX_TX DEC1_INP"},

	{"RX INT2_1 MIX1 INP0", "RX0", "RX_RX0"},
	{"RX INT2_1 MIX1 INP0", "RX1", "RX_RX1"},
	{"RX INT2_1 MIX1 INP0", "RX2", "RX_RX2"},
	{"RX INT2_1 MIX1 INP0", "RX3", "RX_RX3"},
	{"RX INT2_1 MIX1 INP0", "RX4", "RX_RX4"},
	{"RX INT2_1 MIX1 INP0", "RX5", "RX_RX5"},
	{"RX INT2_1 MIX1 INP0", "IIR0", "IIR0"},
	{"RX INT2_1 MIX1 INP0", "IIR1", "IIR1"},
	{"RX INT2_1 MIX1 INP0", "DEC0", "RX_TX DEC0_INP"},
	{"RX INT2_1 MIX1 INP0", "DEC1", "RX_TX DEC1_INP"},
	{"RX INT2_1 MIX1 INP1", "RX0", "RX_RX0"},
	{"RX INT2_1 MIX1 INP1", "RX1", "RX_RX1"},
	{"RX INT2_1 MIX1 INP1", "RX2", "RX_RX2"},
	{"RX INT2_1 MIX1 INP1", "RX3", "RX_RX3"},
	{"RX INT2_1 MIX1 INP1", "RX4", "RX_RX4"},
	{"RX INT2_1 MIX1 INP1", "RX5", "RX_RX5"},
	{"RX INT2_1 MIX1 INP1", "IIR0", "IIR0"},
	{"RX INT2_1 MIX1 INP1", "IIR1", "IIR1"},
	{"RX INT2_1 MIX1 INP1", "DEC0", "RX_TX DEC0_INP"},
	{"RX INT2_1 MIX1 INP1", "DEC1", "RX_TX DEC1_INP"},
	{"RX INT2_1 MIX1 INP2", "RX0", "RX_RX0"},
	{"RX INT2_1 MIX1 INP2", "RX1", "RX_RX1"},
	{"RX INT2_1 MIX1 INP2", "RX2", "RX_RX2"},
	{"RX INT2_1 MIX1 INP2", "RX3", "RX_RX3"},
	{"RX INT2_1 MIX1 INP2", "RX4", "RX_RX4"},
	{"RX INT2_1 MIX1 INP2", "RX5", "RX_RX5"},
	{"RX INT2_1 MIX1 INP2", "IIR0", "IIR0"},
	{"RX INT2_1 MIX1 INP2", "IIR1", "IIR1"},
	{"RX INT2_1 MIX1 INP2", "DEC0", "RX_TX DEC0_INP"},
	{"RX INT2_1 MIX1 INP2", "DEC1", "RX_TX DEC1_INP"},

	{"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP0"},
	{"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP1"},
	{"RX INT0_1 MIX1", NULL, "RX INT0_1 MIX1 INP2"},
	{"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP0"},
	{"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP1"},
	{"RX INT1_1 MIX1", NULL, "RX INT1_1 MIX1 INP2"},
	{"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP0"},
	{"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP1"},
	{"RX INT2_1 MIX1", NULL, "RX INT2_1 MIX1 INP2"},

	{"RX MIX TX0 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
	{"RX MIX TX0 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
	{"RX MIX TX0 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
	{"RX MIX TX1 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
	{"RX MIX TX1 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
	{"RX MIX TX1 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
	{"RX MIX TX2 MUX", "RX_MIX0", "RX INT0 SEC MIX"},
	{"RX MIX TX2 MUX", "RX_MIX1", "RX INT1 SEC MIX"},
	{"RX MIX TX2 MUX", "RX_MIX2", "RX INT2 SEC MIX"},
	{"RX AIF_ECHO", NULL, "RX MIX TX0 MUX"},
	{"RX AIF_ECHO", NULL, "RX MIX TX1 MUX"},
	{"RX AIF_ECHO", NULL, "RX MIX TX2 MUX"},
	{"RX AIF_ECHO", NULL, "RX_MCLK"},

	/* Mixing path INT0 */
	{"RX INT0_2 MUX", "RX0", "RX_RX0"},
	{"RX INT0_2 MUX", "RX1", "RX_RX1"},
	{"RX INT0_2 MUX", "RX2", "RX_RX2"},
	{"RX INT0_2 MUX", "RX3", "RX_RX3"},
	{"RX INT0_2 MUX", "RX4", "RX_RX4"},
	{"RX INT0_2 MUX", "RX5", "RX_RX5"},
	{"RX INT0_2 INTERP", NULL, "RX INT0_2 MUX"},
	{"RX INT0 SEC MIX", NULL, "RX INT0_2 INTERP"},

	/* Mixing path INT1 */
	{"RX INT1_2 MUX", "RX0", "RX_RX0"},
	{"RX INT1_2 MUX", "RX1", "RX_RX1"},
	{"RX INT1_2 MUX", "RX2", "RX_RX2"},
	{"RX INT1_2 MUX", "RX3", "RX_RX3"},
	{"RX INT1_2 MUX", "RX4", "RX_RX4"},
	{"RX INT1_2 MUX", "RX5", "RX_RX5"},
	{"RX INT1_2 INTERP", NULL, "RX INT1_2 MUX"},
	{"RX INT1 SEC MIX", NULL, "RX INT1_2 INTERP"},

	/* Mixing path INT2 */
	{"RX INT2_2 MUX", "RX0", "RX_RX0"},
	{"RX INT2_2 MUX", "RX1", "RX_RX1"},
	{"RX INT2_2 MUX", "RX2", "RX_RX2"},
	{"RX INT2_2 MUX", "RX3", "RX_RX3"},
	{"RX INT2_2 MUX", "RX4", "RX_RX4"},
	{"RX INT2_2 MUX", "RX5", "RX_RX5"},
	{"RX INT2_2 INTERP", NULL, "RX INT2_2 MUX"},
	{"RX INT2 SEC MIX", NULL, "RX INT2_2 INTERP"},

	{"RX INT0_1 INTERP", NULL, "RX INT0_1 MIX1"},
	{"RX INT0 SEC MIX", NULL, "RX INT0_1 INTERP"},
	{"RX INT0 MIX2", NULL, "RX INT0 SEC MIX"},
	{"RX INT0 MIX2", NULL, "RX INT0 MIX2 INP"},
	{"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 MIX2"},
	{"HPHL_OUT", NULL, "RX INT0 DEM MUX"},
	{"HPHL_OUT", NULL, "RX_MCLK"},

	{"RX INT1_1 INTERP", NULL, "RX INT1_1 MIX1"},
	{"RX INT1 SEC MIX", NULL, "RX INT1_1 INTERP"},
	{"RX INT1 MIX2", NULL, "RX INT1 SEC MIX"},
	{"RX INT1 MIX2", NULL, "RX INT1 MIX2 INP"},
	{"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 MIX2"},
	{"HPHR_OUT", NULL, "RX INT1 DEM MUX"},
	{"HPHR_OUT", NULL, "RX_MCLK"},

	{"RX INT2_1 INTERP", NULL, "RX INT2_1 MIX1"},

	{"RX INT2 SEC MIX", NULL, "RX INT2_1 INTERP"},
	{"RX INT2 MIX2", NULL, "RX INT2 SEC MIX"},
	{"RX INT2 MIX2", NULL, "RX INT2 MIX2 INP"},
	{"AUX_OUT", NULL, "RX INT2 MIX2"},
	{"AUX_OUT", NULL, "RX_MCLK"},

	{"IIR0", NULL, "RX_MCLK"},
	{"IIR0", NULL, "IIR0 INP0 MUX"},
	{"IIR0 INP0 MUX", "DEC0", "RX_TX DEC0_INP"},
	{"IIR0 INP0 MUX", "DEC1", "RX_TX DEC1_INP"},
	{"IIR0 INP0 MUX", "DEC2", "RX_TX DEC2_INP"},
	{"IIR0 INP0 MUX", "DEC3", "RX_TX DEC3_INP"},
	{"IIR0 INP0 MUX", "RX0", "RX_RX0"},
	{"IIR0 INP0 MUX", "RX1", "RX_RX1"},
	{"IIR0 INP0 MUX", "RX2", "RX_RX2"},
	{"IIR0 INP0 MUX", "RX3", "RX_RX3"},
	{"IIR0 INP0 MUX", "RX4", "RX_RX4"},
	{"IIR0 INP0 MUX", "RX5", "RX_RX5"},
	{"IIR0", NULL, "IIR0 INP1 MUX"},
	{"IIR0 INP1 MUX", "DEC0", "RX_TX DEC0_INP"},
	{"IIR0 INP1 MUX", "DEC1", "RX_TX DEC1_INP"},
	{"IIR0 INP1 MUX", "DEC2", "RX_TX DEC2_INP"},
	{"IIR0 INP1 MUX", "DEC3", "RX_TX DEC3_INP"},
	{"IIR0 INP1 MUX", "RX0", "RX_RX0"},
	{"IIR0 INP1 MUX", "RX1", "RX_RX1"},
	{"IIR0 INP1 MUX", "RX2", "RX_RX2"},
	{"IIR0 INP1 MUX", "RX3", "RX_RX3"},
	{"IIR0 INP1 MUX", "RX4", "RX_RX4"},
	{"IIR0 INP1 MUX", "RX5", "RX_RX5"},
	{"IIR0", NULL, "IIR0 INP2 MUX"},
	{"IIR0 INP2 MUX", "DEC0", "RX_TX DEC0_INP"},
	{"IIR0 INP2 MUX", "DEC1", "RX_TX DEC1_INP"},
	{"IIR0 INP2 MUX", "DEC2", "RX_TX DEC2_INP"},
	{"IIR0 INP2 MUX", "DEC3", "RX_TX DEC3_INP"},
	{"IIR0 INP2 MUX", "RX0", "RX_RX0"},
	{"IIR0 INP2 MUX", "RX1", "RX_RX1"},
	{"IIR0 INP2 MUX", "RX2", "RX_RX2"},
	{"IIR0 INP2 MUX", "RX3", "RX_RX3"},
	{"IIR0 INP2 MUX", "RX4", "RX_RX4"},
	{"IIR0 INP2 MUX", "RX5", "RX_RX5"},
	{"IIR0", NULL, "IIR0 INP3 MUX"},
	{"IIR0 INP3 MUX", "DEC0", "RX_TX DEC0_INP"},
	{"IIR0 INP3 MUX", "DEC1", "RX_TX DEC1_INP"},
	{"IIR0 INP3 MUX", "DEC2", "RX_TX DEC2_INP"},
	{"IIR0 INP3 MUX", "DEC3", "RX_TX DEC3_INP"},
	{"IIR0 INP3 MUX", "RX0", "RX_RX0"},
	{"IIR0 INP3 MUX", "RX1", "RX_RX1"},
	{"IIR0 INP3 MUX", "RX2", "RX_RX2"},
	{"IIR0 INP3 MUX", "RX3", "RX_RX3"},
	{"IIR0 INP3 MUX", "RX4", "RX_RX4"},
	{"IIR0 INP3 MUX", "RX5", "RX_RX5"},

	{"IIR1", NULL, "RX_MCLK"},
	{"IIR1", NULL, "IIR1 INP0 MUX"},
	{"IIR1 INP0 MUX", "DEC0", "RX_TX DEC0_INP"},
	{"IIR1 INP0 MUX", "DEC1", "RX_TX DEC1_INP"},
	{"IIR1 INP0 MUX", "DEC2", "RX_TX DEC2_INP"},
	{"IIR1 INP0 MUX", "DEC3", "RX_TX DEC3_INP"},
	{"IIR1 INP0 MUX", "RX0", "RX_RX0"},
	{"IIR1 INP0 MUX", "RX1", "RX_RX1"},
	{"IIR1 INP0 MUX", "RX2", "RX_RX2"},
	{"IIR1 INP0 MUX", "RX3", "RX_RX3"},
	{"IIR1 INP0 MUX", "RX4", "RX_RX4"},
	{"IIR1 INP0 MUX", "RX5", "RX_RX5"},
	{"IIR1", NULL, "IIR1 INP1 MUX"},
	{"IIR1 INP1 MUX", "DEC0", "RX_TX DEC0_INP"},
	{"IIR1 INP1 MUX", "DEC1", "RX_TX DEC1_INP"},
	{"IIR1 INP1 MUX", "DEC2", "RX_TX DEC2_INP"},
	{"IIR1 INP1 MUX", "DEC3", "RX_TX DEC3_INP"},
	{"IIR1 INP1 MUX", "RX0", "RX_RX0"},
	{"IIR1 INP1 MUX", "RX1", "RX_RX1"},
	{"IIR1 INP1 MUX", "RX2", "RX_RX2"},
	{"IIR1 INP1 MUX", "RX3", "RX_RX3"},
	{"IIR1 INP1 MUX", "RX4", "RX_RX4"},
	{"IIR1 INP1 MUX", "RX5", "RX_RX5"},
	{"IIR1", NULL, "IIR1 INP2 MUX"},
	{"IIR1 INP2 MUX", "DEC0", "RX_TX DEC0_INP"},
	{"IIR1 INP2 MUX", "DEC1", "RX_TX DEC1_INP"},
	{"IIR1 INP2 MUX", "DEC2", "RX_TX DEC2_INP"},
	{"IIR1 INP2 MUX", "DEC3", "RX_TX DEC3_INP"},
	{"IIR1 INP2 MUX", "RX0", "RX_RX0"},
	{"IIR1 INP2 MUX", "RX1", "RX_RX1"},
	{"IIR1 INP2 MUX", "RX2", "RX_RX2"},
	{"IIR1 INP2 MUX", "RX3", "RX_RX3"},
	{"IIR1 INP2 MUX", "RX4", "RX_RX4"},
	{"IIR1 INP2 MUX", "RX5", "RX_RX5"},
	{"IIR1", NULL, "IIR1 INP3 MUX"},
	{"IIR1 INP3 MUX", "DEC0", "RX_TX DEC0_INP"},
	{"IIR1 INP3 MUX", "DEC1", "RX_TX DEC1_INP"},
	{"IIR1 INP3 MUX", "DEC2", "RX_TX DEC2_INP"},
	{"IIR1 INP3 MUX", "DEC3", "RX_TX DEC3_INP"},
	{"IIR1 INP3 MUX", "RX0", "RX_RX0"},
	{"IIR1 INP3 MUX", "RX1", "RX_RX1"},
	{"IIR1 INP3 MUX", "RX2", "RX_RX2"},
	{"IIR1 INP3 MUX", "RX3", "RX_RX3"},
	{"IIR1 INP3 MUX", "RX4", "RX_RX4"},
	{"IIR1 INP3 MUX", "RX5", "RX_RX5"},

	{"SRC0", NULL, "IIR0"},
	{"SRC1", NULL, "IIR1"},
	{"RX INT0 MIX2 INP", "SRC0", "SRC0"},
	{"RX INT0 MIX2 INP", "SRC1", "SRC1"},
	{"RX INT1 MIX2 INP", "SRC0", "SRC0"},
	{"RX INT1 MIX2 INP", "SRC1", "SRC1"},
	{"RX INT2 MIX2 INP", "SRC0", "SRC0"},
	{"RX INT2 MIX2 INP", "SRC1", "SRC1"},
};

static int rx_macro_component_probe(struct snd_soc_component *component)
{
	struct rx_macro *rx = snd_soc_component_get_drvdata(component);

	snd_soc_component_init_regmap(component, rx->regmap);

	snd_soc_component_update_bits(component, CDC_RX_RX0_RX_PATH_SEC7,
				      CDC_RX_DSM_OUT_DELAY_SEL_MASK,
				      CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE);
	snd_soc_component_update_bits(component, CDC_RX_RX1_RX_PATH_SEC7,
				      CDC_RX_DSM_OUT_DELAY_SEL_MASK,
				      CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE);
	snd_soc_component_update_bits(component, CDC_RX_RX2_RX_PATH_SEC7,
				      CDC_RX_DSM_OUT_DELAY_SEL_MASK,
				      CDC_RX_DSM_OUT_DELAY_TWO_SAMPLE);
	snd_soc_component_update_bits(component, CDC_RX_RX0_RX_PATH_CFG3,
				      CDC_RX_DC_COEFF_SEL_MASK,
				      CDC_RX_DC_COEFF_SEL_TWO);
	snd_soc_component_update_bits(component, CDC_RX_RX1_RX_PATH_CFG3,
				      CDC_RX_DC_COEFF_SEL_MASK,
				      CDC_RX_DC_COEFF_SEL_TWO);
	snd_soc_component_update_bits(component, CDC_RX_RX2_RX_PATH_CFG3,
				      CDC_RX_DC_COEFF_SEL_MASK,
				      CDC_RX_DC_COEFF_SEL_TWO);

	rx->component = component;

	return 0;
}

static int swclk_gate_enable(struct clk_hw *hw)
{
	struct rx_macro *rx = to_rx_macro(hw);

	rx_macro_mclk_enable(rx, true);
	if (rx->reset_swr)
		regmap_update_bits(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL,
				   CDC_RX_SWR_RESET_MASK,
				   CDC_RX_SWR_RESET);

	regmap_update_bits(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL,
			   CDC_RX_SWR_CLK_EN_MASK, 1);

	if (rx->reset_swr)
		regmap_update_bits(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL,
				   CDC_RX_SWR_RESET_MASK, 0);
	rx->reset_swr = false;

	return 0;
}

static void swclk_gate_disable(struct clk_hw *hw)
{
	struct rx_macro *rx = to_rx_macro(hw);

	regmap_update_bits(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL, 
			   CDC_RX_SWR_CLK_EN_MASK, 0);

	rx_macro_mclk_enable(rx, false);
}

static int swclk_gate_is_enabled(struct clk_hw *hw)
{
	struct rx_macro *rx = to_rx_macro(hw);
	int ret, val;

	regmap_read(rx->regmap, CDC_RX_CLK_RST_CTRL_SWR_CONTROL, &val);
	ret = val & BIT(0);

	return ret;
}

static unsigned long swclk_recalc_rate(struct clk_hw *hw,
				       unsigned long parent_rate)
{
	return parent_rate / 2;
}

static const struct clk_ops swclk_gate_ops = {
	.prepare = swclk_gate_enable,
	.unprepare = swclk_gate_disable,
	.is_enabled = swclk_gate_is_enabled,
	.recalc_rate = swclk_recalc_rate,

};

static struct clk *rx_macro_register_mclk_output(struct rx_macro *rx)
{
	struct device *dev = rx->dev;
	struct device_node *np = dev->of_node;
	const char *parent_clk_name = NULL;
	const char *clk_name = "lpass-rx-mclk";
	struct clk_hw *hw;
	struct clk_init_data init;
	int ret;

	parent_clk_name = __clk_get_name(rx->clks[2].clk);

	init.name = clk_name;
	init.ops = &swclk_gate_ops;
	init.flags = 0;
	init.parent_names = &parent_clk_name;
	init.num_parents = 1;
	rx->hw.init = &init;
	hw = &rx->hw;
	ret = clk_hw_register(rx->dev, hw);
	if (ret)
		return ERR_PTR(ret);

	of_clk_add_provider(np, of_clk_src_simple_get, hw->clk);

	return NULL;
}

static const struct snd_soc_component_driver rx_macro_component_drv = {
	.name = "RX-MACRO",
	.probe = rx_macro_component_probe,
	.controls = rx_macro_snd_controls,
	.num_controls = ARRAY_SIZE(rx_macro_snd_controls),
	.dapm_widgets = rx_macro_dapm_widgets,
	.num_dapm_widgets = ARRAY_SIZE(rx_macro_dapm_widgets),
	.dapm_routes = rx_audio_map,
	.num_dapm_routes = ARRAY_SIZE(rx_audio_map),
};

static int rx_macro_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct rx_macro *rx;
	void __iomem *base;
	int ret;

	rx = devm_kzalloc(dev, sizeof(*rx), GFP_KERNEL);
	if (!rx)
		return -ENOMEM;

	rx->clks[0].id = "macro";
	rx->clks[1].id = "dcodec";
	rx->clks[2].id = "mclk";
	rx->clks[3].id = "npl";
	rx->clks[4].id = "fsgen";

	ret = devm_clk_bulk_get(dev, RX_NUM_CLKS_MAX, rx->clks);
	if (ret) {
		dev_err(dev, "Error getting RX Clocks (%d)\n", ret);
		return ret;
	}

	base = devm_platform_ioremap_resource(pdev, 0);
	if (IS_ERR(base))
		return PTR_ERR(base);

	rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config);

	dev_set_drvdata(dev, rx);

	rx->reset_swr = true;
	rx->dev = dev;

	/* set MCLK and NPL rates */
	clk_set_rate(rx->clks[2].clk, MCLK_FREQ);
	clk_set_rate(rx->clks[3].clk, MCLK_FREQ);

	ret = clk_bulk_prepare_enable(RX_NUM_CLKS_MAX, rx->clks);
	if (ret)
		return ret;

	rx_macro_register_mclk_output(rx);

	ret = devm_snd_soc_register_component(dev, &rx_macro_component_drv,
					      rx_macro_dai,
					      ARRAY_SIZE(rx_macro_dai));
	if (ret)
		clk_bulk_disable_unprepare(RX_NUM_CLKS_MAX, rx->clks);

	return ret;
}

static int rx_macro_remove(struct platform_device *pdev)
{
	struct rx_macro *rx = dev_get_drvdata(&pdev->dev);

	of_clk_del_provider(pdev->dev.of_node);
	clk_bulk_disable_unprepare(RX_NUM_CLKS_MAX, rx->clks);
	return 0;
}

static const struct of_device_id rx_macro_dt_match[] = {
	{ .compatible = "qcom,sm8250-lpass-rx-macro" },
	{ }
};

static struct platform_driver rx_macro_driver = {
	.driver = {
		.name = "rx_macro",
		.owner = THIS_MODULE,
		.of_match_table = rx_macro_dt_match,
		.suppress_bind_attrs = true,
	},
	.probe = rx_macro_probe,
	.remove = rx_macro_remove,
};

module_platform_driver(rx_macro_driver);

MODULE_DESCRIPTION("RX macro driver");
MODULE_LICENSE("GPL");