@@ -20,6 +20,11 @@ static const struct reg_default cs35l41_reg[] = {
20
20
{ CS35L41_PWR_CTRL2 , 0x00000000 },
21
21
{ CS35L41_PWR_CTRL3 , 0x01000010 },
22
22
{ CS35L41_GPIO_PAD_CONTROL , 0x00000000 },
23
+ { CS35L41_GLOBAL_CLK_CTRL , 0x00000003 },
24
+ { CS35L41_TST_FS_MON0 , 0x00020016 },
25
+ { CS35L41_BSTCVRT_COEFF , 0x00002424 },
26
+ { CS35L41_BSTCVRT_SLOPE_LBST , 0x00007500 },
27
+ { CS35L41_BSTCVRT_PEAK_CUR , 0x0000004A },
23
28
{ CS35L41_SP_ENABLES , 0x00000000 },
24
29
{ CS35L41_SP_RATE_CTRL , 0x00000028 },
25
30
{ CS35L41_SP_FORMAT , 0x18180200 },
@@ -48,11 +53,16 @@ static const struct reg_default cs35l41_reg[] = {
48
53
{ CS35L41_WKFET_CFG , 0x00000111 },
49
54
{ CS35L41_NG_CFG , 0x00000033 },
50
55
{ CS35L41_AMP_GAIN_CTRL , 0x00000000 },
56
+ { CS35L41_IRQ1_MASK1 , 0xFFFFFFFF },
57
+ { CS35L41_IRQ1_MASK2 , 0xFFFFFFFF },
58
+ { CS35L41_IRQ1_MASK3 , 0xFFFF87FF },
59
+ { CS35L41_IRQ1_MASK4 , 0xFEFFFFFF },
51
60
{ CS35L41_GPIO1_CTRL1 , 0xE1000001 },
52
61
{ CS35L41_GPIO2_CTRL1 , 0xE1000001 },
53
62
{ CS35L41_MIXER_NGATE_CFG , 0x00000000 },
54
63
{ CS35L41_MIXER_NGATE_CH1_CFG , 0x00000303 },
55
64
{ CS35L41_MIXER_NGATE_CH2_CFG , 0x00000303 },
65
+ { CS35L41_DSP1_CCM_CORE_CTRL , 0x00000101 },
56
66
};
57
67
58
68
static bool cs35l41_readable_reg (struct device * dev , unsigned int reg )
@@ -80,10 +90,14 @@ static bool cs35l41_readable_reg(struct device *dev, unsigned int reg)
80
90
case CS35L41_PROTECT_REL_ERR_IGN :
81
91
case CS35L41_GPIO_PAD_CONTROL :
82
92
case CS35L41_JTAG_CONTROL :
93
+ case CS35L41_PWRMGT_CTL :
94
+ case CS35L41_WAKESRC_CTL :
95
+ case CS35L41_PWRMGT_STS :
83
96
case CS35L41_PLL_CLK_CTRL :
84
97
case CS35L41_DSP_CLK_CTRL :
85
98
case CS35L41_GLOBAL_CLK_CTRL :
86
99
case CS35L41_DATA_FS_SEL :
100
+ case CS35L41_TST_FS_MON0 :
87
101
case CS35L41_MDSYNC_EN :
88
102
case CS35L41_MDSYNC_TX_ID :
89
103
case CS35L41_MDSYNC_PWR_CTRL :
@@ -342,7 +356,10 @@ static bool cs35l41_readable_reg(struct device *dev, unsigned int reg)
342
356
static bool cs35l41_precious_reg (struct device * dev , unsigned int reg )
343
357
{
344
358
switch (reg ) {
359
+ case CS35L41_TEST_KEY_CTL :
360
+ case CS35L41_USER_KEY_CTL :
345
361
case CS35L41_OTP_MEM0 ... CS35L41_OTP_MEM31 :
362
+ case CS35L41_TST_FS_MON0 :
346
363
case CS35L41_DSP1_XMEM_PACK_0 ... CS35L41_DSP1_XMEM_PACK_3068 :
347
364
case CS35L41_DSP1_YMEM_PACK_0 ... CS35L41_DSP1_YMEM_PACK_1532 :
348
365
case CS35L41_DSP1_PMEM_0 ... CS35L41_DSP1_PMEM_5114 :
@@ -359,6 +376,12 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
359
376
case CS35L41_SFT_RESET :
360
377
case CS35L41_FABID :
361
378
case CS35L41_REVID :
379
+ case CS35L41_OTPID :
380
+ case CS35L41_TEST_KEY_CTL :
381
+ case CS35L41_USER_KEY_CTL :
382
+ case CS35L41_PWRMGT_CTL :
383
+ case CS35L41_WAKESRC_CTL :
384
+ case CS35L41_PWRMGT_STS :
362
385
case CS35L41_DTEMP_EN :
363
386
case CS35L41_IRQ1_STATUS :
364
387
case CS35L41_IRQ1_STATUS1 :
@@ -369,17 +392,6 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
369
392
case CS35L41_IRQ1_RAW_STATUS2 :
370
393
case CS35L41_IRQ1_RAW_STATUS3 :
371
394
case CS35L41_IRQ1_RAW_STATUS4 :
372
- case CS35L41_IRQ1_FRC1 :
373
- case CS35L41_IRQ1_FRC2 :
374
- case CS35L41_IRQ1_FRC3 :
375
- case CS35L41_IRQ1_FRC4 :
376
- case CS35L41_IRQ1_EDGE1 :
377
- case CS35L41_IRQ1_EDGE4 :
378
- case CS35L41_IRQ1_POL1 :
379
- case CS35L41_IRQ1_POL2 :
380
- case CS35L41_IRQ1_POL3 :
381
- case CS35L41_IRQ1_POL4 :
382
- case CS35L41_IRQ1_DB3 :
383
395
case CS35L41_IRQ2_STATUS :
384
396
case CS35L41_IRQ2_STATUS1 :
385
397
case CS35L41_IRQ2_STATUS2 :
@@ -389,54 +401,7 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
389
401
case CS35L41_IRQ2_RAW_STATUS2 :
390
402
case CS35L41_IRQ2_RAW_STATUS3 :
391
403
case CS35L41_IRQ2_RAW_STATUS4 :
392
- case CS35L41_IRQ2_FRC1 :
393
- case CS35L41_IRQ2_FRC2 :
394
- case CS35L41_IRQ2_FRC3 :
395
- case CS35L41_IRQ2_FRC4 :
396
- case CS35L41_IRQ2_EDGE1 :
397
- case CS35L41_IRQ2_EDGE4 :
398
- case CS35L41_IRQ2_POL1 :
399
- case CS35L41_IRQ2_POL2 :
400
- case CS35L41_IRQ2_POL3 :
401
- case CS35L41_IRQ2_POL4 :
402
- case CS35L41_IRQ2_DB3 :
403
404
case CS35L41_GPIO_STATUS1 :
404
- case CS35L41_OTP_TRIM_1 :
405
- case CS35L41_OTP_TRIM_2 :
406
- case CS35L41_OTP_TRIM_3 :
407
- case CS35L41_OTP_TRIM_4 :
408
- case CS35L41_OTP_TRIM_5 :
409
- case CS35L41_OTP_TRIM_6 :
410
- case CS35L41_OTP_TRIM_7 :
411
- case CS35L41_OTP_TRIM_8 :
412
- case CS35L41_OTP_TRIM_9 :
413
- case CS35L41_OTP_TRIM_10 :
414
- case CS35L41_OTP_TRIM_11 :
415
- case CS35L41_OTP_TRIM_12 :
416
- case CS35L41_OTP_TRIM_13 :
417
- case CS35L41_OTP_TRIM_14 :
418
- case CS35L41_OTP_TRIM_15 :
419
- case CS35L41_OTP_TRIM_16 :
420
- case CS35L41_OTP_TRIM_17 :
421
- case CS35L41_OTP_TRIM_18 :
422
- case CS35L41_OTP_TRIM_19 :
423
- case CS35L41_OTP_TRIM_20 :
424
- case CS35L41_OTP_TRIM_21 :
425
- case CS35L41_OTP_TRIM_22 :
426
- case CS35L41_OTP_TRIM_23 :
427
- case CS35L41_OTP_TRIM_24 :
428
- case CS35L41_OTP_TRIM_25 :
429
- case CS35L41_OTP_TRIM_26 :
430
- case CS35L41_OTP_TRIM_27 :
431
- case CS35L41_OTP_TRIM_28 :
432
- case CS35L41_OTP_TRIM_29 :
433
- case CS35L41_OTP_TRIM_30 :
434
- case CS35L41_OTP_TRIM_31 :
435
- case CS35L41_OTP_TRIM_32 :
436
- case CS35L41_OTP_TRIM_33 :
437
- case CS35L41_OTP_TRIM_34 :
438
- case CS35L41_OTP_TRIM_35 :
439
- case CS35L41_OTP_TRIM_36 :
440
405
case CS35L41_DSP_MBOX_1 ... CS35L41_DSP_VIRT2_MBOX_8 :
441
406
case CS35L41_DSP1_XMEM_PACK_0 ... CS35L41_DSP1_XMEM_PACK_3068 :
442
407
case CS35L41_DSP1_XMEM_UNPACK32_0 ... CS35L41_DSP1_XMEM_UNPACK32_2046 :
@@ -445,7 +410,11 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
445
410
case CS35L41_DSP1_YMEM_UNPACK32_0 ... CS35L41_DSP1_YMEM_UNPACK32_1022 :
446
411
case CS35L41_DSP1_YMEM_UNPACK24_0 ... CS35L41_DSP1_YMEM_UNPACK24_2045 :
447
412
case CS35L41_DSP1_PMEM_0 ... CS35L41_DSP1_PMEM_5114 :
448
- case CS35L41_DSP1_CCM_CORE_CTRL ... CS35L41_DSP1_WDT_STATUS :
413
+ case CS35L41_DSP1_SCRATCH1 :
414
+ case CS35L41_DSP1_SCRATCH2 :
415
+ case CS35L41_DSP1_SCRATCH3 :
416
+ case CS35L41_DSP1_SCRATCH4 :
417
+ case CS35L41_DSP1_CCM_CLK_OVERRIDE ... CS35L41_DSP1_WDT_STATUS :
449
418
case CS35L41_OTP_MEM0 ... CS35L41_OTP_MEM31 :
450
419
return true;
451
420
default :
@@ -660,8 +629,6 @@ static const struct cs35l41_otp_packed_element_t otp_map_2[CS35L41_NUM_OTP_ELEM]
660
629
};
661
630
662
631
static const struct reg_sequence cs35l41_reva0_errata_patch [] = {
663
- { 0x00000040 , 0x00005555 },
664
- { 0x00000040 , 0x0000AAAA },
665
632
{ 0x00003854 , 0x05180240 },
666
633
{ CS35L41_VIMON_SPKMON_RESYNC , 0x00000000 },
667
634
{ 0x00004310 , 0x00000000 },
@@ -674,38 +641,28 @@ static const struct reg_sequence cs35l41_reva0_errata_patch[] = {
674
641
{ CS35L41_IRQ2_DB3 , 0x00000000 },
675
642
{ CS35L41_DSP1_YM_ACCEL_PL0_PRI , 0x00000000 },
676
643
{ CS35L41_DSP1_XM_ACCEL_PL0_PRI , 0x00000000 },
677
- { 0x00000040 , 0x0000CCCC },
678
- { 0x00000040 , 0x00003333 },
679
644
{ CS35L41_PWR_CTRL2 , 0x00000000 },
680
645
{ CS35L41_AMP_GAIN_CTRL , 0x00000000 },
681
646
};
682
647
683
648
static const struct reg_sequence cs35l41_revb0_errata_patch [] = {
684
- { 0x00000040 , 0x00005555 },
685
- { 0x00000040 , 0x0000AAAA },
686
649
{ CS35L41_VIMON_SPKMON_RESYNC , 0x00000000 },
687
650
{ 0x00004310 , 0x00000000 },
688
651
{ CS35L41_VPVBST_FS_SEL , 0x00000000 },
689
652
{ CS35L41_BSTCVRT_DCM_CTRL , 0x00000051 },
690
653
{ CS35L41_DSP1_YM_ACCEL_PL0_PRI , 0x00000000 },
691
654
{ CS35L41_DSP1_XM_ACCEL_PL0_PRI , 0x00000000 },
692
- { 0x00000040 , 0x0000CCCC },
693
- { 0x00000040 , 0x00003333 },
694
655
{ CS35L41_PWR_CTRL2 , 0x00000000 },
695
656
{ CS35L41_AMP_GAIN_CTRL , 0x00000000 },
696
657
};
697
658
698
659
static const struct reg_sequence cs35l41_revb2_errata_patch [] = {
699
- { 0x00000040 , 0x00005555 },
700
- { 0x00000040 , 0x0000AAAA },
701
660
{ CS35L41_VIMON_SPKMON_RESYNC , 0x00000000 },
702
661
{ 0x00004310 , 0x00000000 },
703
662
{ CS35L41_VPVBST_FS_SEL , 0x00000000 },
704
663
{ CS35L41_BSTCVRT_DCM_CTRL , 0x00000051 },
705
664
{ CS35L41_DSP1_YM_ACCEL_PL0_PRI , 0x00000000 },
706
665
{ CS35L41_DSP1_XM_ACCEL_PL0_PRI , 0x00000000 },
707
- { 0x00000040 , 0x0000CCCC },
708
- { 0x00000040 , 0x00003333 },
709
666
{ CS35L41_PWR_CTRL2 , 0x00000000 },
710
667
{ CS35L41_AMP_GAIN_CTRL , 0x00000000 },
711
668
};
@@ -793,6 +750,39 @@ static const struct cs35l41_otp_map_element_t *cs35l41_find_otp_map(u32 otp_id)
793
750
return NULL ;
794
751
}
795
752
753
+ int cs35l41_test_key_unlock (struct device * dev , struct regmap * regmap )
754
+ {
755
+ static const struct reg_sequence unlock [] = {
756
+ { CS35L41_TEST_KEY_CTL , 0x00000055 },
757
+ { CS35L41_TEST_KEY_CTL , 0x000000AA },
758
+ };
759
+ int ret ;
760
+
761
+ ret = regmap_multi_reg_write (regmap , unlock , ARRAY_SIZE (unlock ));
762
+ if (ret )
763
+ dev_err (dev , "Failed to unlock test key: %d\n" , ret );
764
+
765
+ return ret ;
766
+ }
767
+ EXPORT_SYMBOL_GPL (cs35l41_test_key_unlock );
768
+
769
+ int cs35l41_test_key_lock (struct device * dev , struct regmap * regmap )
770
+ {
771
+ static const struct reg_sequence unlock [] = {
772
+ { CS35L41_TEST_KEY_CTL , 0x000000CC },
773
+ { CS35L41_TEST_KEY_CTL , 0x00000033 },
774
+ };
775
+ int ret ;
776
+
777
+ ret = regmap_multi_reg_write (regmap , unlock , ARRAY_SIZE (unlock ));
778
+ if (ret )
779
+ dev_err (dev , "Failed to lock test key: %d\n" , ret );
780
+
781
+ return ret ;
782
+ }
783
+ EXPORT_SYMBOL_GPL (cs35l41_test_key_lock );
784
+
785
+ /* Must be called with the TEST_KEY unlocked */
796
786
int cs35l41_otp_unpack (struct device * dev , struct regmap * regmap )
797
787
{
798
788
const struct cs35l41_otp_map_element_t * otp_map_match ;
@@ -831,17 +821,6 @@ int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap)
831
821
bit_offset = otp_map_match -> bit_offset ;
832
822
word_offset = otp_map_match -> word_offset ;
833
823
834
- ret = regmap_write (regmap , CS35L41_TEST_KEY_CTL , 0x00000055 );
835
- if (ret ) {
836
- dev_err (dev , "Write Unlock key failed 1/2: %d\n" , ret );
837
- goto err_otp_unpack ;
838
- }
839
- ret = regmap_write (regmap , CS35L41_TEST_KEY_CTL , 0x000000AA );
840
- if (ret ) {
841
- dev_err (dev , "Write Unlock key failed 2/2: %d\n" , ret );
842
- goto err_otp_unpack ;
843
- }
844
-
845
824
for (i = 0 ; i < otp_map_match -> num_elements ; i ++ ) {
846
825
dev_dbg (dev , "bitoffset= %d, word_offset=%d, bit_sum mod 32=%d\n" ,
847
826
bit_offset , word_offset , bit_sum % 32 );
@@ -877,16 +856,6 @@ int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap)
877
856
}
878
857
}
879
858
880
- ret = regmap_write (regmap , CS35L41_TEST_KEY_CTL , 0x000000CC );
881
- if (ret ) {
882
- dev_err (dev , "Write Lock key failed 1/2: %d\n" , ret );
883
- goto err_otp_unpack ;
884
- }
885
- ret = regmap_write (regmap , CS35L41_TEST_KEY_CTL , 0x00000033 );
886
- if (ret ) {
887
- dev_err (dev , "Write Lock key failed 2/2: %d\n" , ret );
888
- goto err_otp_unpack ;
889
- }
890
859
ret = 0 ;
891
860
892
861
err_otp_unpack :
@@ -896,6 +865,7 @@ int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap)
896
865
}
897
866
EXPORT_SYMBOL_GPL (cs35l41_otp_unpack );
898
867
868
+ /* Must be called with the TEST_KEY unlocked */
899
869
int cs35l41_register_errata_patch (struct device * dev , struct regmap * reg , unsigned int reg_revid )
900
870
{
901
871
char * rev ;
0 commit comments