summaryrefslogtreecommitdiffstats
path: root/sound/soc/sti/uniperif.h
blob: a8d9e94d804105fc2df31f4cf0e16242ff1d3bb5 (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
/*
 * Copyright (C) STMicroelectronics SA 2015
 * Authors: Arnaud Pouliquen <arnaud.pouliquen@st.com>
 *          for STMicroelectronics.
 * License terms:  GNU General Public License (GPL), version 2
 */

#ifndef __SND_ST_AUD_UNIPERIF_H
#define __SND_ST_AUD_UNIPERIF_H

#include <linux/regmap.h>

#include <sound/dmaengine_pcm.h>

/*
 * Register access macros
 */

#define GET_UNIPERIF_REG(ip, offset, shift, mask) \
	((readl_relaxed(ip->base + offset) >> shift) & mask)
#define SET_UNIPERIF_REG(ip, offset, shift, mask, value) \
	writel_relaxed(((readl_relaxed(ip->base + offset) & \
	~(mask << shift)) | (((value) & mask) << shift)), ip->base + offset)
#define SET_UNIPERIF_BIT_REG(ip, offset, shift, mask, value) \
	writel_relaxed((((value) & mask) << shift), ip->base + offset)

/*
 * AUD_UNIPERIF_SOFT_RST reg
 */

#define UNIPERIF_SOFT_RST_OFFSET(ip) 0x0000
#define GET_UNIPERIF_SOFT_RST(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
		readl_relaxed(ip->base + UNIPERIF_SOFT_RST_OFFSET(ip)) : 0)
#define SET_UNIPERIF_SOFT_RST(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_SOFT_RST_OFFSET(ip))

/* SOFT_RST */
#define UNIPERIF_SOFT_RST_SOFT_RST_SHIFT(ip) 0x0
#define UNIPERIF_SOFT_RST_SOFT_RST_MASK(ip) 0x1
#define SET_UNIPERIF_SOFT_RST_SOFT_RST(ip) \
	SET_UNIPERIF_BIT_REG(ip, \
		UNIPERIF_SOFT_RST_OFFSET(ip), \
		UNIPERIF_SOFT_RST_SOFT_RST_SHIFT(ip), \
		UNIPERIF_SOFT_RST_SOFT_RST_MASK(ip), 1)
#define GET_UNIPERIF_SOFT_RST_SOFT_RST(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_SOFT_RST_OFFSET(ip), \
		UNIPERIF_SOFT_RST_SOFT_RST_SHIFT(ip), \
		UNIPERIF_SOFT_RST_SOFT_RST_MASK(ip))

/*
 * AUD_UNIPERIF_FIFO_DATA reg
 */

#define UNIPERIF_FIFO_DATA_OFFSET(ip) 0x0004
#define SET_UNIPERIF_DATA(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_FIFO_DATA_OFFSET(ip))

/*
 * AUD_UNIPERIF_CHANNEL_STA_REGN reg
 */

#define UNIPERIF_CHANNEL_STA_REGN(ip, n) (0x0060 + (4 * n))
#define GET_UNIPERIF_CHANNEL_STA_REGN(ip) \
	readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REGN(ip, n))
#define SET_UNIPERIF_CHANNEL_STA_REGN(ip, n, value) \
	writel_relaxed(value, ip->base + \
			UNIPERIF_CHANNEL_STA_REGN(ip, n))

#define UNIPERIF_CHANNEL_STA_REG0_OFFSET(ip) 0x0060
#define GET_UNIPERIF_CHANNEL_STA_REG0(ip) \
	readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG0_OFFSET(ip))
#define SET_UNIPERIF_CHANNEL_STA_REG0(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG0_OFFSET(ip))

#define UNIPERIF_CHANNEL_STA_REG1_OFFSET(ip) 0x0064
#define GET_UNIPERIF_CHANNEL_STA_REG1(ip) \
	readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG1_OFFSET(ip))
#define SET_UNIPERIF_CHANNEL_STA_REG1(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG1_OFFSET(ip))

#define UNIPERIF_CHANNEL_STA_REG2_OFFSET(ip) 0x0068
#define GET_UNIPERIF_CHANNEL_STA_REG2(ip) \
	readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG2_OFFSET(ip))
#define SET_UNIPERIF_CHANNEL_STA_REG2(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG2_OFFSET(ip))

#define UNIPERIF_CHANNEL_STA_REG3_OFFSET(ip) 0x006C
#define GET_UNIPERIF_CHANNEL_STA_REG3(ip) \
	readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG3_OFFSET(ip))
#define SET_UNIPERIF_CHANNEL_STA_REG3(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG3_OFFSET(ip))

#define UNIPERIF_CHANNEL_STA_REG4_OFFSET(ip) 0x0070
#define GET_UNIPERIF_CHANNEL_STA_REG4(ip) \
	readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG4_OFFSET(ip))
#define SET_UNIPERIF_CHANNEL_STA_REG4(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG4_OFFSET(ip))

#define UNIPERIF_CHANNEL_STA_REG5_OFFSET(ip) 0x0074
#define GET_UNIPERIF_CHANNEL_STA_REG5(ip) \
	readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REG5_OFFSET(ip))
#define SET_UNIPERIF_CHANNEL_STA_REG5(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_CHANNEL_STA_REG5_OFFSET(ip))

/*
 *  AUD_UNIPERIF_ITS reg
 */

#define UNIPERIF_ITS_OFFSET(ip) 0x000C
#define GET_UNIPERIF_ITS(ip) \
	readl_relaxed(ip->base + UNIPERIF_ITS_OFFSET(ip))

/* MEM_BLK_READ */
#define UNIPERIF_ITS_MEM_BLK_READ_SHIFT(ip) 5
#define UNIPERIF_ITS_MEM_BLK_READ_MASK(ip) \
	(BIT(UNIPERIF_ITS_MEM_BLK_READ_SHIFT(ip)))

/* FIFO_ERROR */
#define UNIPERIF_ITS_FIFO_ERROR_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
#define UNIPERIF_ITS_FIFO_ERROR_MASK(ip) \
	(BIT(UNIPERIF_ITS_FIFO_ERROR_SHIFT(ip)))

/* DMA_ERROR */
#define UNIPERIF_ITS_DMA_ERROR_SHIFT(ip) 9
#define UNIPERIF_ITS_DMA_ERROR_MASK(ip) \
	(BIT(UNIPERIF_ITS_DMA_ERROR_SHIFT(ip)))

/* UNDERFLOW_REC_DONE */
#define UNIPERIF_ITS_UNDERFLOW_REC_DONE_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 12)
#define UNIPERIF_ITS_UNDERFLOW_REC_DONE_MASK(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
		0 : (BIT(UNIPERIF_ITS_UNDERFLOW_REC_DONE_SHIFT(ip))))

/* UNDERFLOW_REC_FAILED */
#define UNIPERIF_ITS_UNDERFLOW_REC_FAILED_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 13)
#define UNIPERIF_ITS_UNDERFLOW_REC_FAILED_MASK(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
		0 : (BIT(UNIPERIF_ITS_UNDERFLOW_REC_FAILED_SHIFT(ip))))

/*
 *  AUD_UNIPERIF_ITS_BCLR reg
 */

/* FIFO_ERROR */
#define UNIPERIF_ITS_BCLR_FIFO_ERROR_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
#define UNIPERIF_ITS_BCLR_FIFO_ERROR_MASK(ip) \
	(BIT(UNIPERIF_ITS_BCLR_FIFO_ERROR_SHIFT(ip)))
#define SET_UNIPERIF_ITS_BCLR_FIFO_ERROR(ip) \
	SET_UNIPERIF_ITS_BCLR(ip, \
		UNIPERIF_ITS_BCLR_FIFO_ERROR_MASK(ip))

#define UNIPERIF_ITS_BCLR_OFFSET(ip) 0x0010
#define SET_UNIPERIF_ITS_BCLR(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_ITS_BCLR_OFFSET(ip))

/*
 *  AUD_UNIPERIF_ITM reg
 */

#define UNIPERIF_ITM_OFFSET(ip) 0x0018
#define GET_UNIPERIF_ITM(ip) \
	readl_relaxed(ip->base + UNIPERIF_ITM_OFFSET(ip))

/* FIFO_ERROR */
#define UNIPERIF_ITM_FIFO_ERROR_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
#define UNIPERIF_ITM_FIFO_ERROR_MASK(ip) \
	(BIT(UNIPERIF_ITM_FIFO_ERROR_SHIFT(ip)))

/* UNDERFLOW_REC_DONE */
#define UNIPERIF_ITM_UNDERFLOW_REC_DONE_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 12)
#define UNIPERIF_ITM_UNDERFLOW_REC_DONE_MASK(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
		0 : (BIT(UNIPERIF_ITM_UNDERFLOW_REC_DONE_SHIFT(ip))))

/* UNDERFLOW_REC_FAILED */
#define UNIPERIF_ITM_UNDERFLOW_REC_FAILED_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 13)
#define UNIPERIF_ITM_UNDERFLOW_REC_FAILED_MASK(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
		0 : (BIT(UNIPERIF_ITM_UNDERFLOW_REC_FAILED_SHIFT(ip))))

/*
 *  AUD_UNIPERIF_ITM_BCLR reg
 */

#define UNIPERIF_ITM_BCLR_OFFSET(ip) 0x001c
#define SET_UNIPERIF_ITM_BCLR(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_ITM_BCLR_OFFSET(ip))

/* FIFO_ERROR */
#define UNIPERIF_ITM_BCLR_FIFO_ERROR_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
#define UNIPERIF_ITM_BCLR_FIFO_ERROR_MASK(ip) \
	(BIT(UNIPERIF_ITM_BCLR_FIFO_ERROR_SHIFT(ip)))
#define SET_UNIPERIF_ITM_BCLR_FIFO_ERROR(ip) \
	SET_UNIPERIF_ITM_BCLR(ip, \
		UNIPERIF_ITM_BCLR_FIFO_ERROR_MASK(ip))

/* DMA_ERROR */
#define UNIPERIF_ITM_BCLR_DMA_ERROR_SHIFT(ip) 9
#define UNIPERIF_ITM_BCLR_DMA_ERROR_MASK(ip) \
	(BIT(UNIPERIF_ITM_BCLR_DMA_ERROR_SHIFT(ip)))
#define SET_UNIPERIF_ITM_BCLR_DMA_ERROR(ip) \
	SET_UNIPERIF_ITM_BCLR(ip, \
		UNIPERIF_ITM_BCLR_DMA_ERROR_MASK(ip))

/*
 *  AUD_UNIPERIF_ITM_BSET reg
 */

#define UNIPERIF_ITM_BSET_OFFSET(ip) 0x0020
#define SET_UNIPERIF_ITM_BSET(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_ITM_BSET_OFFSET(ip))

/* FIFO_ERROR */
#define UNIPERIF_ITM_BSET_FIFO_ERROR_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 8)
#define UNIPERIF_ITM_BSET_FIFO_ERROR_MASK(ip) \
	(BIT(UNIPERIF_ITM_BSET_FIFO_ERROR_SHIFT(ip)))
#define SET_UNIPERIF_ITM_BSET_FIFO_ERROR(ip) \
	SET_UNIPERIF_ITM_BSET(ip, \
		UNIPERIF_ITM_BSET_FIFO_ERROR_MASK(ip))

/* MEM_BLK_READ */
#define UNIPERIF_ITM_BSET_MEM_BLK_READ_SHIFT(ip) 5
#define UNIPERIF_ITM_BSET_MEM_BLK_READ_MASK(ip) \
	(BIT(UNIPERIF_ITM_BSET_MEM_BLK_READ_SHIFT(ip)))
#define SET_UNIPERIF_ITM_BSET_MEM_BLK_READ(ip) \
	SET_UNIPERIF_ITM_BSET(ip, \
		UNIPERIF_ITM_BSET_MEM_BLK_READ_MASK(ip))

/* DMA_ERROR */
#define UNIPERIF_ITM_BSET_DMA_ERROR_SHIFT(ip) 9
#define UNIPERIF_ITM_BSET_DMA_ERROR_MASK(ip) \
	(BIT(UNIPERIF_ITM_BSET_DMA_ERROR_SHIFT(ip)))
#define SET_UNIPERIF_ITM_BSET_DMA_ERROR(ip) \
	SET_UNIPERIF_ITM_BSET(ip, \
		UNIPERIF_ITM_BSET_DMA_ERROR_MASK(ip))

/* UNDERFLOW_REC_DONE */
#define UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 12)
#define UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE_MASK(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
		0 : (BIT(UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE_SHIFT(ip))))
#define SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE(ip) \
	SET_UNIPERIF_ITM_BSET(ip, \
		UNIPERIF_ITM_BSET_UNDERFLOW_REC_DONE_MASK(ip))

/* UNDERFLOW_REC_FAILED */
#define UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 13)
#define UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED_MASK(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? \
		0 : (BIT(UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED_SHIFT(ip))))
#define SET_UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED(ip) \
	SET_UNIPERIF_ITM_BSET(ip, \
		UNIPERIF_ITM_BSET_UNDERFLOW_REC_FAILED_MASK(ip))

/*
 * UNIPERIF_CONFIG reg
 */

#define UNIPERIF_CONFIG_OFFSET(ip) 0x0040
#define GET_UNIPERIF_CONFIG(ip) \
	readl_relaxed(ip->base + UNIPERIF_CONFIG_OFFSET(ip))
#define SET_UNIPERIF_CONFIG(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_CONFIG_OFFSET(ip))

/* PARITY_CNTR */
#define UNIPERIF_CONFIG_PARITY_CNTR_SHIFT(ip) 0
#define UNIPERIF_CONFIG_PARITY_CNTR_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_PARITY_CNTR(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_PARITY_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_PARITY_CNTR_MASK(ip))
#define SET_UNIPERIF_CONFIG_PARITY_CNTR_BY_HW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_PARITY_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_PARITY_CNTR_MASK(ip), 0)
#define SET_UNIPERIF_CONFIG_PARITY_CNTR_BY_SW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_PARITY_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_PARITY_CNTR_MASK(ip), 1)

/* CHANNEL_STA_CNTR */
#define UNIPERIF_CONFIG_CHANNEL_STA_CNTR_SHIFT(ip) 1
#define UNIPERIF_CONFIG_CHANNEL_STA_CNTR_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_CHANNEL_STA_CNTR(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_CHANNEL_STA_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_CHANNEL_STA_CNTR_MASK(ip))
#define SET_UNIPERIF_CONFIG_CHANNEL_STA_CNTR_BY_SW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_CHANNEL_STA_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_CHANNEL_STA_CNTR_MASK(ip), 0)
#define SET_UNIPERIF_CONFIG_CHANNEL_STA_CNTR_BY_HW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip),    \
		UNIPERIF_CONFIG_CHANNEL_STA_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_CHANNEL_STA_CNTR_MASK(ip), 1)

/* USER_DAT_CNTR */
#define UNIPERIF_CONFIG_USER_DAT_CNTR_SHIFT(ip) 2
#define UNIPERIF_CONFIG_USER_DAT_CNTR_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_USER_DAT_CNTR(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_USER_DAT_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_USER_DAT_CNTR_MASK(ip))
#define SET_UNIPERIF_CONFIG_USER_DAT_CNTR_BY_HW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_USER_DAT_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_USER_DAT_CNTR_MASK(ip), 1)
#define SET_UNIPERIF_CONFIG_USER_DAT_CNTR_BY_SW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_USER_DAT_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_USER_DAT_CNTR_MASK(ip), 0)

/* VALIDITY_DAT_CNTR */
#define UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_SHIFT(ip) 3
#define UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_VALIDITY_DAT_CNTR(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_MASK(ip))
#define SET_UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_BY_SW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_MASK(ip), 0)
#define SET_UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_BY_HW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_SHIFT(ip), \
		UNIPERIF_CONFIG_VALIDITY_DAT_CNTR_MASK(ip), 1)

/* ONE_BIT_AUD_SUPPORT */
#define UNIPERIF_CONFIG_ONE_BIT_AUD_SHIFT(ip) 4
#define UNIPERIF_CONFIG_ONE_BIT_AUD_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_ONE_BIT_AUD(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_ONE_BIT_AUD_SHIFT(ip), \
		UNIPERIF_CONFIG_ONE_BIT_AUD_MASK(ip))
#define SET_UNIPERIF_CONFIG_ONE_BIT_AUD_DISABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_ONE_BIT_AUD_SHIFT(ip), \
		UNIPERIF_CONFIG_ONE_BIT_AUD_MASK(ip), 0)
#define SET_UNIPERIF_CONFIG_ONE_BIT_AUD_ENABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_ONE_BIT_AUD_SHIFT(ip), \
		UNIPERIF_CONFIG_ONE_BIT_AUD_MASK(ip), 1)

/* MEMORY_FMT */
#define UNIPERIF_CONFIG_MEM_FMT_SHIFT(ip) 5
#define UNIPERIF_CONFIG_MEM_FMT_MASK(ip) 0x1
#define VALUE_UNIPERIF_CONFIG_MEM_FMT_16_0(ip) 0
#define VALUE_UNIPERIF_CONFIG_MEM_FMT_16_16(ip) 1
#define GET_UNIPERIF_CONFIG_MEM_FMT(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_MEM_FMT_SHIFT(ip), \
		UNIPERIF_CONFIG_MEM_FMT_MASK(ip))
#define SET_UNIPERIF_CONFIG_MEM_FMT(ip, value)	\
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_MEM_FMT_SHIFT(ip), \
		UNIPERIF_CONFIG_MEM_FMT_MASK(ip), value)
#define SET_UNIPERIF_CONFIG_MEM_FMT_16_0(ip)   \
	SET_UNIPERIF_CONFIG_MEM_FMT(ip, \
		VALUE_UNIPERIF_CONFIG_MEM_FMT_16_0(ip))
#define SET_UNIPERIF_CONFIG_MEM_FMT_16_16(ip) \
	SET_UNIPERIF_CONFIG_MEM_FMT(ip, \
		VALUE_UNIPERIF_CONFIG_MEM_FMT_16_16(ip))

/* REPEAT_CHL_STS */
#define UNIPERIF_CONFIG_REPEAT_CHL_STS_SHIFT(ip) 6
#define UNIPERIF_CONFIG_REPEAT_CHL_STS_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_REPEAT_CHL_STS(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_REPEAT_CHL_STS_SHIFT(ip), \
		UNIPERIF_CONFIG_REPEAT_CHL_STS_MASK(ip))
#define SET_UNIPERIF_CONFIG_REPEAT_CHL_STS_ENABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_REPEAT_CHL_STS_SHIFT(ip), \
		UNIPERIF_CONFIG_REPEAT_CHL_STS_MASK(ip), 0)
#define SET_UNIPERIF_CONFIG_REPEAT_CHL_STS_DISABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_REPEAT_CHL_STS_SHIFT(ip), \
		UNIPERIF_CONFIG_REPEAT_CHL_STS_MASK(ip), 1)

/* BACK_STALL_REQ */
#define UNIPERIF_CONFIG_BACK_STALL_REQ_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 7 : -1)
#define UNIPERIF_CONFIG_BACK_STALL_REQ_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_BACK_STALL_REQ(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_BACK_STALL_REQ_SHIFT(ip), \
		UNIPERIF_CONFIG_BACK_STALL_REQ_MASK(ip))
#define SET_UNIPERIF_CONFIG_BACK_STALL_REQ_DISABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_BACK_STALL_REQ_SHIFT(ip), \
		UNIPERIF_CONFIG_BACK_STALL_REQ_MASK(ip), 0)
#define SET_UNIPERIF_CONFIG_BACK_STALL_REQ_ENABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_BACK_STALL_REQ_SHIFT(ip), \
		UNIPERIF_CONFIG_BACK_STALL_REQ_MASK(ip), 1)

/* FDMA_TRIGGER_LIMIT */
#define UNIPERIF_CONFIG_DMA_TRIG_LIMIT_SHIFT(ip) 8
#define UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(ip) 0x7F
#define GET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_DMA_TRIG_LIMIT_SHIFT(ip), \
		UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(ip))
#define SET_UNIPERIF_CONFIG_DMA_TRIG_LIMIT(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_DMA_TRIG_LIMIT_SHIFT(ip), \
		UNIPERIF_CONFIG_DMA_TRIG_LIMIT_MASK(ip), value)

/* CHL_STS_UPDATE */
#define UNIPERIF_CONFIG_CHL_STS_UPDATE_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 16 : -1)
#define UNIPERIF_CONFIG_CHL_STS_UPDATE_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_CHL_STS_UPDATE(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip),  \
		UNIPERIF_CONFIG_CHL_STS_UPDATE_SHIFT(ip), \
		UNIPERIF_CONFIG_CHL_STS_UPDATE_MASK(ip))
#define SET_UNIPERIF_CONFIG_CHL_STS_UPDATE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_CHL_STS_UPDATE_SHIFT(ip), \
		UNIPERIF_CONFIG_CHL_STS_UPDATE_MASK(ip), 1)

/* IDLE_MOD */
#define UNIPERIF_CONFIG_IDLE_MOD_SHIFT(ip) 18
#define UNIPERIF_CONFIG_IDLE_MOD_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_IDLE_MOD(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_IDLE_MOD_SHIFT(ip), \
		UNIPERIF_CONFIG_IDLE_MOD_MASK(ip))
#define SET_UNIPERIF_CONFIG_IDLE_MOD_DISABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_IDLE_MOD_SHIFT(ip), \
		UNIPERIF_CONFIG_IDLE_MOD_MASK(ip), 0)
#define SET_UNIPERIF_CONFIG_IDLE_MOD_ENABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_IDLE_MOD_SHIFT(ip), \
		UNIPERIF_CONFIG_IDLE_MOD_MASK(ip), 1)

/* SUBFRAME_SELECTION */
#define UNIPERIF_CONFIG_SUBFRAME_SEL_SHIFT(ip) 19
#define UNIPERIF_CONFIG_SUBFRAME_SEL_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_SUBFRAME_SEL(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_SUBFRAME_SEL_SHIFT(ip), \
		UNIPERIF_CONFIG_SUBFRAME_SEL_MASK(ip))
#define SET_UNIPERIF_CONFIG_SUBFRAME_SEL_SUBF1_SUBF0(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_SUBFRAME_SEL_SHIFT(ip), \
		UNIPERIF_CONFIG_SUBFRAME_SEL_MASK(ip), 1)
#define SET_UNIPERIF_CONFIG_SUBFRAME_SEL_SUBF0_SUBF1(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_SUBFRAME_SEL_SHIFT(ip), \
		UNIPERIF_CONFIG_SUBFRAME_SEL_MASK(ip), 0)

/* FULL_SW_CONTROL */
#define UNIPERIF_CONFIG_SPDIF_SW_CTRL_SHIFT(ip) 20
#define UNIPERIF_CONFIG_SPDIF_SW_CTRL_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_SPDIF_SW_CTRL(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_SPDIF_SW_CTRL_SHIFT(ip), \
		UNIPERIF_CONFIG_SPDIF_SW_CTRL_MASK(ip))
#define SET_UNIPERIF_CONFIG_SPDIF_SW_CTRL_ENABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_SPDIF_SW_CTRL_SHIFT(ip), \
		UNIPERIF_CONFIG_SPDIF_SW_CTRL_MASK(ip), 1)
#define SET_UNIPERIF_CONFIG_SPDIF_SW_CTRL_DISABLE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_SPDIF_SW_CTRL_SHIFT(ip), \
		UNIPERIF_CONFIG_SPDIF_SW_CTRL_MASK(ip), 0)

/* MASTER_CLKEDGE */
#define UNIPERIF_CONFIG_MSTR_CLKEDGE_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 24 : -1)
#define UNIPERIF_CONFIG_MSTR_CLKEDGE_MASK(ip) 0x1
#define GET_UNIPERIF_CONFIG_MSTR_CLKEDGE(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_MSTR_CLKEDGE_SHIFT(ip), \
		UNIPERIF_CONFIG_MSTR_CLKEDGE_MASK(ip))
#define SET_UNIPERIF_CONFIG_MSTR_CLKEDGE_FALLING(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_MSTR_CLKEDGE_SHIFT(ip), \
		UNIPERIF_CONFIG_MSTR_CLKEDGE_MASK(ip), 1)
#define SET_UNIPERIF_CONFIG_MSTR_CLKEDGE_RISING(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CONFIG_OFFSET(ip), \
		UNIPERIF_CONFIG_MSTR_CLKEDGE_SHIFT(ip), \
		UNIPERIF_CONFIG_MSTR_CLKEDGE_MASK(ip), 0)

/*
 * UNIPERIF_CTRL reg
 */

#define UNIPERIF_CTRL_OFFSET(ip) 0x0044
#define GET_UNIPERIF_CTRL(ip) \
	readl_relaxed(ip->base + UNIPERIF_CTRL_OFFSET(ip))
#define SET_UNIPERIF_CTRL(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_CTRL_OFFSET(ip))

/* OPERATION */
#define UNIPERIF_CTRL_OPERATION_SHIFT(ip) 0
#define UNIPERIF_CTRL_OPERATION_MASK(ip) 0x7
#define GET_UNIPERIF_CTRL_OPERATION(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
		UNIPERIF_CTRL_OPERATION_MASK(ip))
#define VALUE_UNIPERIF_CTRL_OPERATION_OFF(ip) 0
#define SET_UNIPERIF_CTRL_OPERATION_OFF(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
		UNIPERIF_CTRL_OPERATION_MASK(ip), \
		VALUE_UNIPERIF_CTRL_OPERATION_OFF(ip))
#define VALUE_UNIPERIF_CTRL_OPERATION_MUTE_PCM_NULL(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 1 : -1)
#define SET_UNIPERIF_CTRL_OPERATION_MUTE_PCM_NULL(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
		UNIPERIF_CTRL_OPERATION_MASK(ip), \
		VALUE_UNIPERIF_CTRL_OPERATION_MUTE_PCM_NULL(ip))
#define VALUE_UNIPERIF_CTRL_OPERATION_MUTE_PAUSE_BURST(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 2 : -1)
#define SET_UNIPERIF_CTRL_OPERATION_MUTE_PAUSE_BURST(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
		UNIPERIF_CTRL_OPERATION_MASK(ip), \
		VALUE_UNIPERIF_CTRL_OPERATION_MUTE_PAUSE_BURST(ip))
#define VALUE_UNIPERIF_CTRL_OPERATION_PCM_DATA(ip) 3
#define SET_UNIPERIF_CTRL_OPERATION_PCM_DATA(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
		UNIPERIF_CTRL_OPERATION_MASK(ip), \
		VALUE_UNIPERIF_CTRL_OPERATION_PCM_DATA(ip))
/* This is the same as above! */
#define VALUE_UNIPERIF_CTRL_OPERATION_AUDIO_DATA(ip) 3
#define SET_UNIPERIF_CTRL_OPERATION_AUDIO_DATA(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
		UNIPERIF_CTRL_OPERATION_MASK(ip), \
		VALUE_UNIPERIF_CTRL_OPERATION_AUDIO_DATA(ip))
#define VALUE_UNIPERIF_CTRL_OPERATION_ENC_DATA(ip) 4
#define SET_UNIPERIF_CTRL_OPERATION_ENC_DATA(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
		UNIPERIF_CTRL_OPERATION_MASK(ip), \
		VALUE_UNIPERIF_CTRL_OPERATION_ENC_DATA(ip))
#define VALUE_UNIPERIF_CTRL_OPERATION_CD_DATA(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 5 : -1)
#define SET_UNIPERIF_CTRL_OPERATION_CD_DATA(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
		UNIPERIF_CTRL_OPERATION_MASK(ip), \
		VALUE_UNIPERIF_CTRL_OPERATION_CD_DATA(ip))
#define VALUE_UNIPERIF_CTRL_OPERATION_STANDBY(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 7)
#define SET_UNIPERIF_CTRL_OPERATION_STANDBY(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_OPERATION_SHIFT(ip), \
		UNIPERIF_CTRL_OPERATION_MASK(ip), \
		VALUE_UNIPERIF_CTRL_OPERATION_STANDBY(ip))

/* EXIT_STBY_ON_EOBLOCK */
#define UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 3)
#define UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_MASK(ip) 0x1
#define GET_UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_SHIFT(ip), \
		UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_MASK(ip))
#define SET_UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_OFF(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_SHIFT(ip), \
		UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_MASK(ip), 0)
#define SET_UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_ON(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_SHIFT(ip), \
		UNIPERIF_CTRL_EXIT_STBY_ON_EOBLOCK_MASK(ip), 1)

/* ROUNDING */
#define UNIPERIF_CTRL_ROUNDING_SHIFT(ip) 4
#define UNIPERIF_CTRL_ROUNDING_MASK(ip) 0x1
#define GET_UNIPERIF_CTRL_ROUNDING(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_ROUNDING_SHIFT(ip), \
		UNIPERIF_CTRL_ROUNDING_MASK(ip))
#define SET_UNIPERIF_CTRL_ROUNDING_OFF(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_ROUNDING_SHIFT(ip), \
		UNIPERIF_CTRL_ROUNDING_MASK(ip), 0)
#define SET_UNIPERIF_CTRL_ROUNDING_ON(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_ROUNDING_SHIFT(ip), \
		UNIPERIF_CTRL_ROUNDING_MASK(ip), 1)

/* DIVIDER */
#define UNIPERIF_CTRL_DIVIDER_SHIFT(ip) 5
#define UNIPERIF_CTRL_DIVIDER_MASK(ip) 0xff
#define GET_UNIPERIF_CTRL_DIVIDER(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_DIVIDER_SHIFT(ip), \
		UNIPERIF_CTRL_DIVIDER_MASK(ip))
#define SET_UNIPERIF_CTRL_DIVIDER(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_DIVIDER_SHIFT(ip), \
		UNIPERIF_CTRL_DIVIDER_MASK(ip), value)

/* BYTE_SWAP */
#define UNIPERIF_CTRL_BYTE_SWP_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 13 : -1)
#define UNIPERIF_CTRL_BYTE_SWP_MASK(ip) 0x1
#define GET_UNIPERIF_CTRL_BYTE_SWP(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_BYTE_SWP_SHIFT(ip), \
		UNIPERIF_CTRL_BYTE_SWP_MASK(ip))
#define SET_UNIPERIF_CTRL_BYTE_SWP_OFF(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_BYTE_SWP_SHIFT(ip), \
		UNIPERIF_CTRL_BYTE_SWP_MASK(ip), 0)
#define SET_UNIPERIF_CTRL_BYTE_SWP_ON(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_BYTE_SWP_SHIFT(ip), \
		UNIPERIF_CTRL_BYTE_SWP_MASK(ip), 1)

/* ZERO_STUFFING_HW_SW */
#define UNIPERIF_CTRL_ZERO_STUFF_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 14 : -1)
#define UNIPERIF_CTRL_ZERO_STUFF_MASK(ip) 0x1
#define GET_UNIPERIF_CTRL_ZERO_STUFF(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_ZERO_STUFF_SHIFT(ip), \
		UNIPERIF_CTRL_ZERO_STUFF_MASK(ip))
#define SET_UNIPERIF_CTRL_ZERO_STUFF_HW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_ZERO_STUFF_SHIFT(ip), \
		UNIPERIF_CTRL_ZERO_STUFF_MASK(ip), 1)
#define SET_UNIPERIF_CTRL_ZERO_STUFF_SW(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_ZERO_STUFF_SHIFT(ip), \
		UNIPERIF_CTRL_ZERO_STUFF_MASK(ip), 0)

/* SPDIF_LAT */
#define UNIPERIF_CTRL_SPDIF_LAT_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 16 : -1)
#define UNIPERIF_CTRL_SPDIF_LAT_MASK(ip) 0x1
#define GET_UNIPERIF_CTRL_SPDIF_LAT(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_SPDIF_LAT_SHIFT(ip), \
		UNIPERIF_CTRL_SPDIF_LAT_MASK(ip))
#define SET_UNIPERIF_CTRL_SPDIF_LAT_ON(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_SPDIF_LAT_SHIFT(ip), \
		UNIPERIF_CTRL_SPDIF_LAT_MASK(ip), 1)
#define SET_UNIPERIF_CTRL_SPDIF_LAT_OFF(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_SPDIF_LAT_SHIFT(ip), \
		UNIPERIF_CTRL_SPDIF_LAT_MASK(ip), 0)

/* EN_SPDIF_FORMATTING */
#define UNIPERIF_CTRL_SPDIF_FMT_SHIFT(ip) 17
#define UNIPERIF_CTRL_SPDIF_FMT_MASK(ip) 0x1
#define GET_UNIPERIF_CTRL_SPDIF_FMT(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_SPDIF_FMT_SHIFT(ip), \
		UNIPERIF_CTRL_SPDIF_FMT_MASK(ip))
#define SET_UNIPERIF_CTRL_SPDIF_FMT_ON(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_SPDIF_FMT_SHIFT(ip), \
		UNIPERIF_CTRL_SPDIF_FMT_MASK(ip), 1)
#define SET_UNIPERIF_CTRL_SPDIF_FMT_OFF(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_SPDIF_FMT_SHIFT(ip), \
		UNIPERIF_CTRL_SPDIF_FMT_MASK(ip), 0)

/* READER_OUT_SELECT */
#define UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 18 : -1)
#define UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip) 0x1
#define GET_UNIPERIF_CTRL_READER_OUT_SEL(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip), \
		UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip))
#define SET_UNIPERIF_CTRL_READER_OUT_SEL_IN_MEM(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip), \
		UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip), 0)
#define SET_UNIPERIF_CTRL_READER_OUT_SEL_ON_I2S_LINE(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_READER_OUT_SEL_SHIFT(ip), \
		CORAUD_UNIPERIF_CTRL_READER_OUT_SEL_MASK(ip), 1)

/* UNDERFLOW_REC_WINDOW */
#define UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_SHIFT(ip) 20
#define UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_MASK(ip) 0xff
#define GET_UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_SHIFT(ip), \
		UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_MASK(ip))
#define SET_UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_CTRL_OFFSET(ip), \
		UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_SHIFT(ip), \
		UNIPERIF_CTRL_UNDERFLOW_REC_WINDOW_MASK(ip), value)

/*
 * UNIPERIF_I2S_FMT a.k.a UNIPERIF_FORMAT reg
 */

#define UNIPERIF_I2S_FMT_OFFSET(ip) 0x0048
#define GET_UNIPERIF_I2S_FMT(ip) \
	readl_relaxed(ip->base + UNIPERIF_I2S_FMT_OFFSET(ip))
#define SET_UNIPERIF_I2S_FMT(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_I2S_FMT_OFFSET(ip))

/* NBIT */
#define UNIPERIF_I2S_FMT_NBIT_SHIFT(ip) 0
#define UNIPERIF_I2S_FMT_NBIT_MASK(ip) 0x1
#define GET_UNIPERIF_I2S_FMT_NBIT(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_NBIT_SHIFT(ip), \
		UNIPERIF_I2S_FMT_NBIT_MASK(ip))
#define SET_UNIPERIF_I2S_FMT_NBIT_32(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_NBIT_SHIFT(ip), \
		UNIPERIF_I2S_FMT_NBIT_MASK(ip), 0)
#define SET_UNIPERIF_I2S_FMT_NBIT_16(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_NBIT_SHIFT(ip), \
		UNIPERIF_I2S_FMT_NBIT_MASK(ip), 1)

/* DATA_SIZE */
#define UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip) 1
#define UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip) 0x7
#define GET_UNIPERIF_I2S_FMT_DATA_SIZE(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip))
#define SET_UNIPERIF_I2S_FMT_DATA_SIZE_16(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 0)
#define SET_UNIPERIF_I2S_FMT_DATA_SIZE_18(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 1)
#define SET_UNIPERIF_I2S_FMT_DATA_SIZE_20(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 2)
#define SET_UNIPERIF_I2S_FMT_DATA_SIZE_24(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 3)
#define SET_UNIPERIF_I2S_FMTL_DATA_SIZE_28(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 4)
#define SET_UNIPERIF_I2S_FMT_DATA_SIZE_32(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_DATA_SIZE_MASK(ip), 5)

/* LR_POL */
#define UNIPERIF_I2S_FMT_LR_POL_SHIFT(ip) 4
#define UNIPERIF_I2S_FMT_LR_POL_MASK(ip) 0x1
#define VALUE_UNIPERIF_I2S_FMT_LR_POL_LOW(ip) 0x0
#define VALUE_UNIPERIF_I2S_FMT_LR_POL_HIG(ip) 0x1
#define GET_UNIPERIF_I2S_FMT_LR_POL(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_LR_POL_SHIFT(ip), \
		UNIPERIF_I2S_FMT_LR_POL_MASK(ip))
#define SET_UNIPERIF_I2S_FMT_LR_POL(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_LR_POL_SHIFT(ip), \
		UNIPERIF_I2S_FMT_LR_POL_MASK(ip), value)
#define SET_UNIPERIF_I2S_FMT_LR_POL_LOW(ip) \
	SET_UNIPERIF_I2S_FMT_LR_POL(ip, \
		VALUE_UNIPERIF_I2S_FMT_LR_POL_LOW(ip))
#define SET_UNIPERIF_I2S_FMT_LR_POL_HIG(ip) \
	SET_UNIPERIF_I2S_FMT_LR_POL(ip, \
		VALUE_UNIPERIF_I2S_FMT_LR_POL_HIG(ip))

/* SCLK_EDGE */
#define UNIPERIF_I2S_FMT_SCLK_EDGE_SHIFT(ip) 5
#define UNIPERIF_I2S_FMT_SCLK_EDGE_MASK(ip) 0x1
#define GET_UNIPERIF_I2S_FMT_SCLK_EDGE(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_SCLK_EDGE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_SCLK_EDGE_MASK(ip))
#define SET_UNIPERIF_I2S_FMT_SCLK_EDGE_RISING(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_SCLK_EDGE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_SCLK_EDGE_MASK(ip), 0)
#define SET_UNIPERIF_I2S_FMT_SCLK_EDGE_FALLING(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_SCLK_EDGE_SHIFT(ip), \
		UNIPERIF_I2S_FMT_SCLK_EDGE_MASK(ip), 1)

/* PADDING */
#define UNIPERIF_I2S_FMT_PADDING_SHIFT(ip) 6
#define UNIPERIF_I2S_FMT_PADDING_MASK(ip) 0x1
#define UNIPERIF_I2S_FMT_PADDING_MASK(ip) 0x1
#define VALUE_UNIPERIF_I2S_FMT_PADDING_I2S_MODE(ip) 0x0
#define VALUE_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(ip) 0x1
#define GET_UNIPERIF_I2S_FMT_PADDING(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_PADDING_SHIFT(ip), \
		UNIPERIF_I2S_FMT_PADDING_MASK(ip))
#define SET_UNIPERIF_I2S_FMT_PADDING(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_PADDING_SHIFT(ip), \
		UNIPERIF_I2S_FMT_PADDING_MASK(ip), value)
#define SET_UNIPERIF_I2S_FMT_PADDING_I2S_MODE(ip) \
	SET_UNIPERIF_I2S_FMT_PADDING(ip, \
		VALUE_UNIPERIF_I2S_FMT_PADDING_I2S_MODE(ip))
#define SET_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(ip) \
	SET_UNIPERIF_I2S_FMT_PADDING(ip, \
		VALUE_UNIPERIF_I2S_FMT_PADDING_SONY_MODE(ip))

/* ALIGN */
#define UNIPERIF_I2S_FMT_ALIGN_SHIFT(ip) 7
#define UNIPERIF_I2S_FMT_ALIGN_MASK(ip) 0x1
#define GET_UNIPERIF_I2S_FMT_ALIGN(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_ALIGN_SHIFT(ip), \
		UNIPERIF_I2S_FMT_ALIGN_MASK(ip))
#define SET_UNIPERIF_I2S_FMT_ALIGN_LEFT(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_ALIGN_SHIFT(ip), \
		UNIPERIF_I2S_FMT_ALIGN_MASK(ip), 0)
#define SET_UNIPERIF_I2S_FMT_ALIGN_RIGHT(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_ALIGN_SHIFT(ip), \
		UNIPERIF_I2S_FMT_ALIGN_MASK(ip), 1)

/* ORDER */
#define UNIPERIF_I2S_FMT_ORDER_SHIFT(ip) 8
#define UNIPERIF_I2S_FMT_ORDER_MASK(ip) 0x1
#define GET_UNIPERIF_I2S_FMT_ORDER(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_ORDER_SHIFT(ip), \
		UNIPERIF_I2S_FMT_ORDER_MASK(ip))
#define SET_UNIPERIF_I2S_FMT_ORDER_LSB(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_ORDER_SHIFT(ip), \
		UNIPERIF_I2S_FMT_ORDER_MASK(ip), 0)
#define SET_UNIPERIF_I2S_FMT_ORDER_MSB(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_ORDER_SHIFT(ip), \
		UNIPERIF_I2S_FMT_ORDER_MASK(ip), 1)

/* NUM_CH */
#define UNIPERIF_I2S_FMT_NUM_CH_SHIFT(ip) 9
#define UNIPERIF_I2S_FMT_NUM_CH_MASK(ip) 0x7
#define GET_UNIPERIF_I2S_FMT_NUM_CH(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_NUM_CH_SHIFT(ip), \
		UNIPERIF_I2S_FMT_NUM_CH_MASK(ip))
#define SET_UNIPERIF_I2S_FMT_NUM_CH(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_NUM_CH_SHIFT(ip), \
		UNIPERIF_I2S_FMT_NUM_CH_MASK(ip), value)

/* NO_OF_SAMPLES_TO_READ */
#define UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_SHIFT(ip) 12
#define UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_MASK(ip) 0xfffff
#define GET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_SHIFT(ip), \
		UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_MASK(ip))
#define SET_UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_I2S_FMT_OFFSET(ip), \
		UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_SHIFT(ip), \
		UNIPERIF_I2S_FMT_NO_OF_SAMPLES_TO_READ_MASK(ip), value)

/*
 * UNIPERIF_BIT_CONTROL reg
 */

#define UNIPERIF_BIT_CONTROL_OFFSET(ip)  \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 0x004c)
#define GET_UNIPERIF_BIT_CONTROL(ip) \
	readl_relaxed(ip->base + UNIPERIF_BIT_CONTROL_OFFSET(ip))
#define SET_UNIPERIF_BIT_CONTROL(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_BIT_CONTROL_OFFSET(ip))

/* CLR_UNDERFLOW_DURATION */
#define UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_SHIFT(ip) 0
#define UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_MASK(ip) 0x1
#define GET_UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_BIT_CONTROL_OFFSET(ip), \
		UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_SHIFT(ip), \
		UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_MASK(ip))
#define SET_UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION(ip) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_BIT_CONTROL_OFFSET(ip), \
		UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_SHIFT(ip), \
		UNIPERIF_BIT_CONTROL_CLR_UNDERFLOW_DURATION_MASK(ip), 1)

/* CHL_STS_UPDATE */
#define UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_SHIFT(ip) 1
#define UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_MASK(ip) 0x1
#define GET_UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_BIT_CONTROL_OFFSET(ip), \
		UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_SHIFT(ip), \
		UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_MASK(ip))
#define SET_UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE(ip) \
	SET_UNIPERIF_BIT_REG(ip, \
		UNIPERIF_BIT_CONTROL_OFFSET(ip), \
		UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_SHIFT(ip), \
		UNIPERIF_BIT_CONTROL_CHL_STS_UPDATE_MASK(ip), 1)

/*
 * UNIPERIF_STATUS_1 reg
 */

#define UNIPERIF_STATUS_1_OFFSET(ip) 0x0050
#define GET_UNIPERIF_STATUS_1(ip) \
	readl_relaxed(ip->base + UNIPERIF_STATUS_1_OFFSET(ip))
#define SET_UNIPERIF_STATUS_1(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_STATUS_1_OFFSET(ip))

/* UNDERFLOW_DURATION */
#define UNIPERIF_STATUS_1_UNDERFLOW_DURATION_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 0)
#define UNIPERIF_STATUS_1_UNDERFLOW_DURATION_MASK(ip) 0xff
#define GET_UNIPERIF_STATUS_1_UNDERFLOW_DURATION(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_STATUS_1_OFFSET(ip), \
		UNIPERIF_STATUS_1_UNDERFLOW_DURATION_SHIFT(ip), \
		UNIPERIF_STATUS_1_UNDERFLOW_DURATION_MASK(ip))
#define SET_UNIPERIF_STATUS_1_UNDERFLOW_DURATION(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_STATUS_1_OFFSET(ip), \
		UNIPERIF_STATUS_1_UNDERFLOW_DURATION_SHIFT(ip), \
		UNIPERIF_STATUS_1_UNDERFLOW_DURATION_MASK(ip), value)

/*
 * AUD_UNIPERIF_CHANNEL_STA_REGN reg
 */

#define UNIPERIF_CHANNEL_STA_REGN(ip, n) (0x0060 + (4 * n))
#define GET_UNIPERIF_CHANNEL_STA_REGN(ip) \
	readl_relaxed(ip->base + UNIPERIF_CHANNEL_STA_REGN(ip, n))
#define SET_UNIPERIF_CHANNEL_STA_REGN(ip, n, value) \
	writel_relaxed(value, ip->base + \
			UNIPERIF_CHANNEL_STA_REGN(ip, n))

/*
 * AUD_UNIPERIF_USER_VALIDITY reg
 */

#define UNIPERIF_USER_VALIDITY_OFFSET(ip) 0x0090
#define GET_UNIPERIF_USER_VALIDITY(ip) \
	readl_relaxed(ip->base + UNIPERIF_USER_VALIDITY_OFFSET(ip))
#define SET_UNIPERIF_USER_VALIDITY(ip, value) \
	writel_relaxed(value, ip->base + UNIPERIF_USER_VALIDITY_OFFSET(ip))

/* VALIDITY_LEFT_AND_RIGHT */
#define UNIPERIF_USER_VALIDITY_VALIDITY_LR_SHIFT(ip) 0
#define UNIPERIF_USER_VALIDITY_VALIDITY_LR_MASK(ip) 0x3
#define GET_UNIPERIF_USER_VALIDITY_VALIDITY_LR(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_USER_VALIDITY_OFFSET(ip), \
		UNIPERIF_USER_VALIDITY_VALIDITY_LR_SHIFT(ip), \
		UNIPERIF_USER_VALIDITY_VALIDITY_LR_MASK(ip))
#define SET_UNIPERIF_USER_VALIDITY_VALIDITY_LR(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_USER_VALIDITY_OFFSET(ip), \
		UNIPERIF_USER_VALIDITY_VALIDITY_LR_SHIFT(ip), \
		UNIPERIF_USER_VALIDITY_VALIDITY_LR_MASK(ip), \
		value ? 0x3 : 0)

/*
 * UNIPERIF_DBG_STANDBY_LEFT_SP reg
 */
#define UNIPERIF_DBG_STANDBY_LEFT_SP_OFFSET(ip) 0x0150
#define UNIPERIF_DBG_STANDBY_LEFT_SP_SHIFT(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? -1 : 0)
#define UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip) \
	((ip)->ver < SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0 ? 0 : 0xFFFFFF)
#define GET_UNIPERIF_DBG_STANDBY_LEFT_SP(ip) \
	GET_UNIPERIF_REG(ip, \
		UNIPERIF_DBG_STANDBY_LEFT_SP_OFFSET(ip), \
		UNIPERIF_DBG_STANDBY_LEFT_SP_SHIFT(ip), \
		UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip))
#define SET_UNIPERIF_DBG_STANDBY_LEFT_SP(ip, value) \
	SET_UNIPERIF_REG(ip, \
		UNIPERIF_DBG_STANDBY_LEFT_SP_OFFSET(ip), \
		UNIPERIF_DBG_STANDBY_LEFT_SP_SHIFT(ip), \
		UNIPERIF_DBG_STANDBY_LEFT_SP_MASK(ip), value)

/*
 * uniperipheral IP capabilities
 */

#define UNIPERIF_FIFO_SIZE		70 /* FIFO is 70 cells deep */
#define UNIPERIF_FIFO_FRAMES		4  /* FDMA trigger limit in frames */

/*
 * Uniperipheral IP revisions
 */
enum uniperif_version {
	SND_ST_UNIPERIF_VERSION_UNKNOWN,
	/* SASG1 (Orly), Newman */
	SND_ST_UNIPERIF_VERSION_C6AUD0_UNI_1_0,
	/* SASC1, SASG2 (Orly2) */
	SND_ST_UNIPERIF_VERSION_UNI_PLR_1_0,
	/* SASC1, SASG2 (Orly2), TELSS, Cannes */
	SND_ST_UNIPERIF_VERSION_UNI_RDR_1_0,
	/* TELSS (SASC1) */
	SND_ST_UNIPERIF_VERSION_TDM_PLR_1_0,
	/* Cannes/Monaco */
	SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0
};

enum uniperif_type {
	SND_ST_UNIPERIF_PLAYER_TYPE_NONE,
	SND_ST_UNIPERIF_PLAYER_TYPE_HDMI,
	SND_ST_UNIPERIF_PLAYER_TYPE_PCM,
	SND_ST_UNIPERIF_PLAYER_TYPE_SPDIF
};

enum uniperif_state {
	UNIPERIF_STATE_STOPPED,
	UNIPERIF_STATE_STARTED,
	UNIPERIF_STATE_STANDBY,
	UNIPERIF_STATE_UNDERFLOW,
	UNIPERIF_STATE_OVERFLOW = UNIPERIF_STATE_UNDERFLOW,
	UNIPERIF_STATE_XRUN
};

enum uniperif_iec958_encoding_mode {
	UNIPERIF_IEC958_ENCODING_MODE_PCM,
	UNIPERIF_IEC958_ENCODING_MODE_ENCODED
};

struct uniperif_info {
	int id; /* instance value of the uniperipheral IP */
	enum uniperif_type player_type;
	int underflow_enabled;		/* Underflow recovery mode */
};

struct uniperif_iec958_settings {
	enum uniperif_iec958_encoding_mode encoding_mode;
	struct snd_aes_iec958 iec958;
};

struct uniperif {
	/* System information */
	struct uniperif_info *info;
	struct device *dev;
	int ver; /* IP version, used by register access macros */
	struct regmap_field *clk_sel;

	/* capabilities */
	const struct snd_pcm_hardware *hw;

	/* Resources */
	struct resource *mem_region;
	void *base;
	unsigned long fifo_phys_address;
	int irq;

	/* Clocks */
	struct clk *clk;
	int mclk;

	/* Runtime data */
	enum uniperif_state state;

	struct snd_pcm_substream *substream;

	/* Specific to IEC958 player */
	struct uniperif_iec958_settings stream_settings;

	/*alsa ctrl*/
	struct snd_kcontrol_new *snd_ctrls;
	int num_ctrls;

	/* dai properties */
	unsigned int daifmt;

	/* DAI callbacks */
	const struct snd_soc_dai_ops *dai_ops;
};

struct sti_uniperiph_dai {
	int stream;
	struct uniperif *uni;
	struct snd_dmaengine_dai_dma_data dma_data;
};

struct sti_uniperiph_data {
	struct platform_device *pdev;
	struct snd_soc_dai_driver *dai;
	struct sti_uniperiph_dai dai_data;
};

/* uniperiph player*/
int uni_player_init(struct platform_device *pdev,
		    struct uniperif *uni_player);
int uni_player_resume(struct uniperif *player);

#endif
OpenPOWER on IntegriCloud