@@ -20,6 +20,11 @@ static const struct reg_default cs35l41_reg[] = {
2020 { CS35L41_PWR_CTRL2 , 0x00000000 },
2121 { CS35L41_PWR_CTRL3 , 0x01000010 },
2222 { 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 },
2328 { CS35L41_SP_ENABLES , 0x00000000 },
2429 { CS35L41_SP_RATE_CTRL , 0x00000028 },
2530 { CS35L41_SP_FORMAT , 0x18180200 },
@@ -48,11 +53,16 @@ static const struct reg_default cs35l41_reg[] = {
4853 { CS35L41_WKFET_CFG , 0x00000111 },
4954 { CS35L41_NG_CFG , 0x00000033 },
5055 { 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 },
5160 { CS35L41_GPIO1_CTRL1 , 0xE1000001 },
5261 { CS35L41_GPIO2_CTRL1 , 0xE1000001 },
5362 { CS35L41_MIXER_NGATE_CFG , 0x00000000 },
5463 { CS35L41_MIXER_NGATE_CH1_CFG , 0x00000303 },
5564 { CS35L41_MIXER_NGATE_CH2_CFG , 0x00000303 },
65+ { CS35L41_DSP1_CCM_CORE_CTRL , 0x00000101 },
5666};
5767
5868static 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)
8090 case CS35L41_PROTECT_REL_ERR_IGN :
8191 case CS35L41_GPIO_PAD_CONTROL :
8292 case CS35L41_JTAG_CONTROL :
93+ case CS35L41_PWRMGT_CTL :
94+ case CS35L41_WAKESRC_CTL :
95+ case CS35L41_PWRMGT_STS :
8396 case CS35L41_PLL_CLK_CTRL :
8497 case CS35L41_DSP_CLK_CTRL :
8598 case CS35L41_GLOBAL_CLK_CTRL :
8699 case CS35L41_DATA_FS_SEL :
100+ case CS35L41_TST_FS_MON0 :
87101 case CS35L41_MDSYNC_EN :
88102 case CS35L41_MDSYNC_TX_ID :
89103 case CS35L41_MDSYNC_PWR_CTRL :
@@ -342,7 +356,10 @@ static bool cs35l41_readable_reg(struct device *dev, unsigned int reg)
342356static bool cs35l41_precious_reg (struct device * dev , unsigned int reg )
343357{
344358 switch (reg ) {
359+ case CS35L41_TEST_KEY_CTL :
360+ case CS35L41_USER_KEY_CTL :
345361 case CS35L41_OTP_MEM0 ... CS35L41_OTP_MEM31 :
362+ case CS35L41_TST_FS_MON0 :
346363 case CS35L41_DSP1_XMEM_PACK_0 ... CS35L41_DSP1_XMEM_PACK_3068 :
347364 case CS35L41_DSP1_YMEM_PACK_0 ... CS35L41_DSP1_YMEM_PACK_1532 :
348365 case CS35L41_DSP1_PMEM_0 ... CS35L41_DSP1_PMEM_5114 :
@@ -359,6 +376,12 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
359376 case CS35L41_SFT_RESET :
360377 case CS35L41_FABID :
361378 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 :
362385 case CS35L41_DTEMP_EN :
363386 case CS35L41_IRQ1_STATUS :
364387 case CS35L41_IRQ1_STATUS1 :
@@ -369,17 +392,6 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
369392 case CS35L41_IRQ1_RAW_STATUS2 :
370393 case CS35L41_IRQ1_RAW_STATUS3 :
371394 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 :
383395 case CS35L41_IRQ2_STATUS :
384396 case CS35L41_IRQ2_STATUS1 :
385397 case CS35L41_IRQ2_STATUS2 :
@@ -389,54 +401,7 @@ static bool cs35l41_volatile_reg(struct device *dev, unsigned int reg)
389401 case CS35L41_IRQ2_RAW_STATUS2 :
390402 case CS35L41_IRQ2_RAW_STATUS3 :
391403 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 :
403404 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 :
440405 case CS35L41_DSP_MBOX_1 ... CS35L41_DSP_VIRT2_MBOX_8 :
441406 case CS35L41_DSP1_XMEM_PACK_0 ... CS35L41_DSP1_XMEM_PACK_3068 :
442407 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)
445410 case CS35L41_DSP1_YMEM_UNPACK32_0 ... CS35L41_DSP1_YMEM_UNPACK32_1022 :
446411 case CS35L41_DSP1_YMEM_UNPACK24_0 ... CS35L41_DSP1_YMEM_UNPACK24_2045 :
447412 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 :
449418 case CS35L41_OTP_MEM0 ... CS35L41_OTP_MEM31 :
450419 return true;
451420 default :
@@ -660,8 +629,6 @@ static const struct cs35l41_otp_packed_element_t otp_map_2[CS35L41_NUM_OTP_ELEM]
660629};
661630
662631static const struct reg_sequence cs35l41_reva0_errata_patch [] = {
663- { 0x00000040 , 0x00005555 },
664- { 0x00000040 , 0x0000AAAA },
665632 { 0x00003854 , 0x05180240 },
666633 { CS35L41_VIMON_SPKMON_RESYNC , 0x00000000 },
667634 { 0x00004310 , 0x00000000 },
@@ -674,38 +641,28 @@ static const struct reg_sequence cs35l41_reva0_errata_patch[] = {
674641 { CS35L41_IRQ2_DB3 , 0x00000000 },
675642 { CS35L41_DSP1_YM_ACCEL_PL0_PRI , 0x00000000 },
676643 { CS35L41_DSP1_XM_ACCEL_PL0_PRI , 0x00000000 },
677- { 0x00000040 , 0x0000CCCC },
678- { 0x00000040 , 0x00003333 },
679644 { CS35L41_PWR_CTRL2 , 0x00000000 },
680645 { CS35L41_AMP_GAIN_CTRL , 0x00000000 },
681646};
682647
683648static const struct reg_sequence cs35l41_revb0_errata_patch [] = {
684- { 0x00000040 , 0x00005555 },
685- { 0x00000040 , 0x0000AAAA },
686649 { CS35L41_VIMON_SPKMON_RESYNC , 0x00000000 },
687650 { 0x00004310 , 0x00000000 },
688651 { CS35L41_VPVBST_FS_SEL , 0x00000000 },
689652 { CS35L41_BSTCVRT_DCM_CTRL , 0x00000051 },
690653 { CS35L41_DSP1_YM_ACCEL_PL0_PRI , 0x00000000 },
691654 { CS35L41_DSP1_XM_ACCEL_PL0_PRI , 0x00000000 },
692- { 0x00000040 , 0x0000CCCC },
693- { 0x00000040 , 0x00003333 },
694655 { CS35L41_PWR_CTRL2 , 0x00000000 },
695656 { CS35L41_AMP_GAIN_CTRL , 0x00000000 },
696657};
697658
698659static const struct reg_sequence cs35l41_revb2_errata_patch [] = {
699- { 0x00000040 , 0x00005555 },
700- { 0x00000040 , 0x0000AAAA },
701660 { CS35L41_VIMON_SPKMON_RESYNC , 0x00000000 },
702661 { 0x00004310 , 0x00000000 },
703662 { CS35L41_VPVBST_FS_SEL , 0x00000000 },
704663 { CS35L41_BSTCVRT_DCM_CTRL , 0x00000051 },
705664 { CS35L41_DSP1_YM_ACCEL_PL0_PRI , 0x00000000 },
706665 { CS35L41_DSP1_XM_ACCEL_PL0_PRI , 0x00000000 },
707- { 0x00000040 , 0x0000CCCC },
708- { 0x00000040 , 0x00003333 },
709666 { CS35L41_PWR_CTRL2 , 0x00000000 },
710667 { CS35L41_AMP_GAIN_CTRL , 0x00000000 },
711668};
@@ -793,6 +750,39 @@ static const struct cs35l41_otp_map_element_t *cs35l41_find_otp_map(u32 otp_id)
793750 return NULL ;
794751}
795752
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 */
796786int cs35l41_otp_unpack (struct device * dev , struct regmap * regmap )
797787{
798788 const struct cs35l41_otp_map_element_t * otp_map_match ;
@@ -831,17 +821,6 @@ int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap)
831821 bit_offset = otp_map_match -> bit_offset ;
832822 word_offset = otp_map_match -> word_offset ;
833823
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-
845824 for (i = 0 ; i < otp_map_match -> num_elements ; i ++ ) {
846825 dev_dbg (dev , "bitoffset= %d, word_offset=%d, bit_sum mod 32=%d\n" ,
847826 bit_offset , word_offset , bit_sum % 32 );
@@ -877,16 +856,6 @@ int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap)
877856 }
878857 }
879858
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- }
890859 ret = 0 ;
891860
892861err_otp_unpack :
@@ -896,6 +865,7 @@ int cs35l41_otp_unpack(struct device *dev, struct regmap *regmap)
896865}
897866EXPORT_SYMBOL_GPL (cs35l41_otp_unpack );
898867
868+ /* Must be called with the TEST_KEY unlocked */
899869int cs35l41_register_errata_patch (struct device * dev , struct regmap * reg , unsigned int reg_revid )
900870{
901871 char * rev ;
0 commit comments