summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/rt5663.h
blob: c5a9b69579ad216d9b039359910e8c10acfa1832 (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
/*
 * rt5663.h  --  RT5663 ALSA SoC audio driver
 *
 * Copyright 2016 Realtek Microelectronics
 * Author: Jack Yu <jack.yu@realtek.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef __RT5663_H__
#define __RT5663_H__

#include <sound/rt5663.h>

/* Info */
#define RT5663_RESET				0x0000
#define RT5663_VENDOR_ID			0x00fd
#define RT5663_VENDOR_ID_1			0x00fe
#define RT5663_VENDOR_ID_2			0x00ff

#define RT5663_LOUT_CTRL			0x0001
#define RT5663_HP_AMP_2				0x0003
#define RT5663_MONO_OUT				0x0004
#define RT5663_MONO_GAIN			0x0007

#define RT5663_AEC_BST				0x000b
#define RT5663_IN1_IN2				0x000c
#define RT5663_IN3_IN4				0x000d
#define RT5663_INL1_INR1			0x000f
#define RT5663_CBJ_TYPE_2			0x0011
#define RT5663_CBJ_TYPE_3			0x0012
#define RT5663_CBJ_TYPE_4			0x0013
#define RT5663_CBJ_TYPE_5			0x0014
#define RT5663_CBJ_TYPE_8			0x0017

/* I/O - ADC/DAC/DMIC */
#define RT5663_DAC3_DIG_VOL			0x001a
#define RT5663_DAC3_CTRL			0x001b
#define RT5663_MONO_ADC_DIG_VOL			0x001d
#define RT5663_STO2_ADC_DIG_VOL			0x001e
#define RT5663_MONO_ADC_BST_GAIN		0x0020
#define RT5663_STO2_ADC_BST_GAIN		0x0021
#define RT5663_SIDETONE_CTRL			0x0024
/* Mixer - D-D */
#define RT5663_MONO1_ADC_MIXER			0x0027
#define RT5663_STO2_ADC_MIXER			0x0028
#define RT5663_MONO_DAC_MIXER			0x002b
#define RT5663_DAC2_SRC_CTRL			0x002e
#define RT5663_IF_3_4_DATA_CTL			0x002f
#define RT5663_IF_5_DATA_CTL			0x0030
#define RT5663_PDM_OUT_CTL			0x0031
#define RT5663_PDM_I2C_DATA_CTL1		0x0032
#define RT5663_PDM_I2C_DATA_CTL2		0x0033
#define RT5663_PDM_I2C_DATA_CTL3		0x0034
#define RT5663_PDM_I2C_DATA_CTL4		0x0035

/*Mixer - Analog*/
#define RT5663_RECMIX1_NEW			0x003a
#define RT5663_RECMIX1L_0			0x003b
#define RT5663_RECMIX1L				0x003c
#define RT5663_RECMIX1R_0			0x003d
#define RT5663_RECMIX1R				0x003e
#define RT5663_RECMIX2_NEW			0x003f
#define RT5663_RECMIX2_L_2			0x0041
#define RT5663_RECMIX2_R			0x0042
#define RT5663_RECMIX2_R_2			0x0043
#define RT5663_CALIB_REC_LR			0x0044
#define RT5663_ALC_BK_GAIN			0x0049
#define RT5663_MONOMIX_GAIN			0x004a
#define RT5663_MONOMIX_IN_GAIN			0x004b
#define RT5663_OUT_MIXL_GAIN			0x004d
#define RT5663_OUT_LMIX_IN_GAIN			0x004e
#define RT5663_OUT_RMIX_IN_GAIN			0x004f
#define RT5663_OUT_RMIX_IN_GAIN1		0x0050
#define RT5663_LOUT_MIXER_CTRL			0x0052
/* Power */
#define RT5663_PWR_VOL				0x0067

#define RT5663_ADCDAC_RST			0x006d
/* Format - ADC/DAC */
#define RT5663_I2S34_SDP			0x0071
#define RT5663_I2S5_SDP				0x0072

/* Function - Analog */
#define RT5663_ASRC_3				0x0085
#define RT5663_ASRC_6				0x0088
#define RT5663_ASRC_7				0x0089
#define RT5663_PLL_TRK_13			0x0099
#define RT5663_I2S_M_CLK_CTL			0x00a0
#define RT5663_FDIV_I2S34_M_CLK			0x00a1
#define RT5663_FDIV_I2S34_M_CLK2		0x00a2
#define RT5663_FDIV_I2S5_M_CLK			0x00a3
#define RT5663_FDIV_I2S5_M_CLK2			0x00a4

/* Function - Digital */
#define RT5663_V2_IRQ_4				0x00b9
#define RT5663_GPIO_3				0x00c2
#define RT5663_GPIO_4				0x00c3
#define RT5663_GPIO_STA2			0x00c4
#define RT5663_HP_AMP_DET1			0x00d0
#define RT5663_HP_AMP_DET2			0x00d1
#define RT5663_HP_AMP_DET3			0x00d2
#define RT5663_MID_BD_HP_AMP			0x00d3
#define RT5663_LOW_BD_HP_AMP			0x00d4
#define RT5663_SOF_VOL_ZC2			0x00da
#define RT5663_ADC_STO2_ADJ1			0x00ee
#define RT5663_ADC_STO2_ADJ2			0x00ef
/* General Control */
#define RT5663_A_JD_CTRL			0x00f0
#define RT5663_JD1_TRES_CTRL			0x00f1
#define RT5663_JD2_TRES_CTRL			0x00f2
#define RT5663_V2_JD_CTRL2			0x00f7
#define RT5663_DUM_REG_2			0x00fb
#define RT5663_DUM_REG_3			0x00fc


#define RT5663_DACADC_DIG_VOL2			0x0101
#define RT5663_DIG_IN_PIN2			0x0133
#define RT5663_PAD_DRV_CTL1			0x0136
#define RT5663_SOF_RAM_DEPOP			0x0138
#define RT5663_VOL_TEST				0x013f
#define RT5663_MONO_DYNA_1			0x0170
#define RT5663_MONO_DYNA_2			0x0171
#define RT5663_MONO_DYNA_3			0x0172
#define RT5663_MONO_DYNA_4			0x0173
#define RT5663_MONO_DYNA_5			0x0174
#define RT5663_MONO_DYNA_6			0x0175
#define RT5663_STO1_SIL_DET			0x0190
#define RT5663_MONOL_SIL_DET			0x0191
#define RT5663_MONOR_SIL_DET			0x0192
#define RT5663_STO2_DAC_SIL			0x0193
#define RT5663_PWR_SAV_CTL1			0x0194
#define RT5663_PWR_SAV_CTL2			0x0195
#define RT5663_PWR_SAV_CTL3			0x0196
#define RT5663_PWR_SAV_CTL4			0x0197
#define RT5663_PWR_SAV_CTL5			0x0198
#define RT5663_PWR_SAV_CTL6			0x0199
#define RT5663_MONO_AMP_CAL1			0x01a0
#define RT5663_MONO_AMP_CAL2			0x01a1
#define RT5663_MONO_AMP_CAL3			0x01a2
#define RT5663_MONO_AMP_CAL4			0x01a3
#define RT5663_MONO_AMP_CAL5			0x01a4
#define RT5663_MONO_AMP_CAL6			0x01a5
#define RT5663_MONO_AMP_CAL7			0x01a6
#define RT5663_MONO_AMP_CAL_ST1			0x01a7
#define RT5663_MONO_AMP_CAL_ST2			0x01a8
#define RT5663_MONO_AMP_CAL_ST3			0x01a9
#define RT5663_MONO_AMP_CAL_ST4			0x01aa
#define RT5663_MONO_AMP_CAL_ST5			0x01ab
#define RT5663_V2_HP_IMP_SEN_13			0x01b9
#define RT5663_V2_HP_IMP_SEN_14			0x01ba
#define RT5663_V2_HP_IMP_SEN_6			0x01bb
#define RT5663_V2_HP_IMP_SEN_7			0x01bc
#define RT5663_V2_HP_IMP_SEN_8			0x01bd
#define RT5663_V2_HP_IMP_SEN_9			0x01be
#define RT5663_V2_HP_IMP_SEN_10			0x01bf
#define RT5663_HP_LOGIC_3			0x01dc
#define RT5663_HP_CALIB_ST10			0x01f3
#define RT5663_HP_CALIB_ST11			0x01f4
#define RT5663_PRO_REG_TBL_4			0x0203
#define RT5663_PRO_REG_TBL_5			0x0204
#define RT5663_PRO_REG_TBL_6			0x0205
#define RT5663_PRO_REG_TBL_7			0x0206
#define RT5663_PRO_REG_TBL_8			0x0207
#define RT5663_PRO_REG_TBL_9			0x0208
#define RT5663_SAR_ADC_INL_1			0x0210
#define RT5663_SAR_ADC_INL_2			0x0211
#define RT5663_SAR_ADC_INL_3			0x0212
#define RT5663_SAR_ADC_INL_4			0x0213
#define RT5663_SAR_ADC_INL_5			0x0214
#define RT5663_SAR_ADC_INL_6			0x0215
#define RT5663_SAR_ADC_INL_7			0x0216
#define RT5663_SAR_ADC_INL_8			0x0217
#define RT5663_SAR_ADC_INL_9			0x0218
#define RT5663_SAR_ADC_INL_10			0x0219
#define RT5663_SAR_ADC_INL_11			0x021a
#define RT5663_SAR_ADC_INL_12			0x021b
#define RT5663_DRC_CTRL_1			0x02ff
#define RT5663_DRC1_CTRL_2			0x0301
#define RT5663_DRC1_CTRL_3			0x0302
#define RT5663_DRC1_CTRL_4			0x0303
#define RT5663_DRC1_CTRL_5			0x0304
#define RT5663_DRC1_CTRL_6			0x0305
#define RT5663_DRC1_HD_CTRL_1			0x0306
#define RT5663_DRC1_HD_CTRL_2			0x0307
#define RT5663_DRC1_PRI_REG_1			0x0310
#define RT5663_DRC1_PRI_REG_2			0x0311
#define RT5663_DRC1_PRI_REG_3			0x0312
#define RT5663_DRC1_PRI_REG_4			0x0313
#define RT5663_DRC1_PRI_REG_5			0x0314
#define RT5663_DRC1_PRI_REG_6			0x0315
#define RT5663_DRC1_PRI_REG_7			0x0316
#define RT5663_DRC1_PRI_REG_8			0x0317
#define RT5663_ALC_PGA_CTL_1			0x0330
#define RT5663_ALC_PGA_CTL_2			0x0331
#define RT5663_ALC_PGA_CTL_3			0x0332
#define RT5663_ALC_PGA_CTL_4			0x0333
#define RT5663_ALC_PGA_CTL_5			0x0334
#define RT5663_ALC_PGA_CTL_6			0x0335
#define RT5663_ALC_PGA_CTL_7			0x0336
#define RT5663_ALC_PGA_CTL_8			0x0337
#define RT5663_ALC_PGA_REG_1			0x0338
#define RT5663_ALC_PGA_REG_2			0x0339
#define RT5663_ALC_PGA_REG_3			0x033a
#define RT5663_ADC_EQ_RECOV_1			0x03c0
#define RT5663_ADC_EQ_RECOV_2			0x03c1
#define RT5663_ADC_EQ_RECOV_3			0x03c2
#define RT5663_ADC_EQ_RECOV_4			0x03c3
#define RT5663_ADC_EQ_RECOV_5			0x03c4
#define RT5663_ADC_EQ_RECOV_6			0x03c5
#define RT5663_ADC_EQ_RECOV_7			0x03c6
#define RT5663_ADC_EQ_RECOV_8			0x03c7
#define RT5663_ADC_EQ_RECOV_9			0x03c8
#define RT5663_ADC_EQ_RECOV_10			0x03c9
#define RT5663_ADC_EQ_RECOV_11			0x03ca
#define RT5663_ADC_EQ_RECOV_12			0x03cb
#define RT5663_ADC_EQ_RECOV_13			0x03cc
#define RT5663_VID_HIDDEN			0x03fe
#define RT5663_VID_CUSTOMER			0x03ff
#define RT5663_SCAN_MODE			0x07f0
#define RT5663_I2C_BYPA				0x07fa

/* Headphone Amp Control 2 (0x0003) */
#define RT5663_EN_DAC_HPO_MASK			(0x1 << 14)
#define RT5663_EN_DAC_HPO_SHIFT			14
#define RT5663_EN_DAC_HPO_DIS			(0x0 << 14)
#define RT5663_EN_DAC_HPO_EN			(0x1 << 14)

/*Headphone Amp L/R Analog Gain and Digital NG2 Gain Control (0x0005 0x0006)*/
#define RT5663_GAIN_HP				(0x1f << 8)
#define RT5663_GAIN_HP_SHIFT			8

/* AEC BST Control (0x000b) */
#define RT5663_GAIN_CBJ_MASK			(0xf << 8)
#define RT5663_GAIN_CBJ_SHIFT			8

/* IN1 Control / MIC GND REF (0x000c) */
#define RT5663_IN1_DF_MASK			(0x1 << 15)
#define RT5663_IN1_DF_SHIFT			15

/* Combo Jack and Type Detection Control 1 (0x0010) */
#define RT5663_CBJ_DET_MASK			(0x1 << 15)
#define RT5663_CBJ_DET_SHIFT			15
#define RT5663_CBJ_DET_DIS			(0x0 << 15)
#define RT5663_CBJ_DET_EN			(0x1 << 15)
#define RT5663_DET_TYPE_MASK			(0x1 << 12)
#define RT5663_DET_TYPE_SHIFT			12
#define RT5663_DET_TYPE_WLCSP			(0x0 << 12)
#define RT5663_DET_TYPE_QFN			(0x1 << 12)
#define RT5663_VREF_BIAS_MASK			(0x1 << 6)
#define RT5663_VREF_BIAS_SHIFT			6
#define RT5663_VREF_BIAS_FSM			(0x0 << 6)
#define RT5663_VREF_BIAS_REG			(0x1 << 6)

/* REC Left Mixer Control 2 (0x003c) */
#define RT5663_RECMIX1L_BST1_CBJ		(0x1 << 7)
#define RT5663_RECMIX1L_BST1_CBJ_SHIFT		7
#define RT5663_RECMIX1L_BST2			(0x1 << 4)
#define RT5663_RECMIX1L_BST2_SHIFT		4

/* REC Right Mixer Control 2 (0x003e) */
#define RT5663_RECMIX1R_BST2			(0x1 << 4)
#define RT5663_RECMIX1R_BST2_SHIFT		4

/* DAC1 Digital Volume (0x0019) */
#define RT5663_DAC_L1_VOL_MASK			(0xff << 8)
#define RT5663_DAC_L1_VOL_SHIFT			8
#define RT5663_DAC_R1_VOL_MASK			(0xff)
#define RT5663_DAC_R1_VOL_SHIFT			0

/* ADC Digital Volume Control (0x001c) */
#define RT5663_ADC_L_MUTE_MASK			(0x1 << 15)
#define RT5663_ADC_L_MUTE_SHIFT			15
#define RT5663_ADC_L_VOL_MASK			(0x7f << 8)
#define RT5663_ADC_L_VOL_SHIFT			8
#define RT5663_ADC_R_MUTE_MASK			(0x1 << 7)
#define RT5663_ADC_R_MUTE_SHIFT			7
#define RT5663_ADC_R_VOL_MASK			(0x7f)
#define RT5663_ADC_R_VOL_SHIFT			0

/* Stereo ADC Mixer Control (0x0026) */
#define RT5663_M_STO1_ADC_L1			(0x1 << 15)
#define RT5663_M_STO1_ADC_L1_SHIFT		15
#define RT5663_M_STO1_ADC_L2			(0x1 << 14)
#define RT5663_M_STO1_ADC_L2_SHIFT		14
#define RT5663_STO1_ADC_L1_SRC			(0x1 << 13)
#define RT5663_STO1_ADC_L1_SRC_SHIFT		13
#define RT5663_STO1_ADC_L2_SRC			(0x1 << 12)
#define RT5663_STO1_ADC_L2_SRC_SHIFT		12
#define RT5663_STO1_ADC_L_SRC			(0x3 << 10)
#define RT5663_STO1_ADC_L_SRC_SHIFT		10
#define RT5663_M_STO1_ADC_R1			(0x1 << 7)
#define RT5663_M_STO1_ADC_R1_SHIFT		7
#define RT5663_M_STO1_ADC_R2			(0x1 << 6)
#define RT5663_M_STO1_ADC_R2_SHIFT		6
#define RT5663_STO1_ADC_R1_SRC			(0x1 << 5)
#define RT5663_STO1_ADC_R1_SRC_SHIFT		5
#define RT5663_STO1_ADC_R2_SRC			(0x1 << 4)
#define RT5663_STO1_ADC_R2_SRC_SHIFT		4
#define RT5663_STO1_ADC_R_SRC			(0x3 << 2)
#define RT5663_STO1_ADC_R_SRC_SHIFT		2

/* ADC Mixer to DAC Mixer Control (0x0029) */
#define RT5663_M_ADCMIX_L			(0x1 << 15)
#define RT5663_M_ADCMIX_L_SHIFT			15
#define RT5663_M_DAC1_L				(0x1 << 14)
#define RT5663_M_DAC1_L_SHIFT			14
#define RT5663_M_ADCMIX_R			(0x1 << 7)
#define RT5663_M_ADCMIX_R_SHIFT			7
#define RT5663_M_DAC1_R				(0x1 << 6)
#define RT5663_M_DAC1_R_SHIFT			6

/* Stereo DAC Mixer Control (0x002a) */