diff options
author | Peeyush Gupta | 2020-05-13 12:23:58 -0500 |
---|---|---|
committer | Peeyush Gupta | 2020-05-13 12:23:58 -0500 |
commit | 3d6ec1a41904463303a249605addddd48ca907e2 (patch) | |
tree | e503528c66542a142eec1fc2801ae25d49a0b7b3 | |
parent | 0a04d429a8ae9657cf2da5485ec640298567b353 (diff) | |
download | tas2562-stereo-android-driver-3d6ec1a41904463303a249605addddd48ca907e2.tar.gz tas2562-stereo-android-driver-3d6ec1a41904463303a249605addddd48ca907e2.tar.xz tas2562-stereo-android-driver-3d6ec1a41904463303a249605addddd48ca907e2.zip |
Samsung LSI specfic TDM Clock Error Fix Integrated, Bus Keeper mode is enabled for stereo mode
-rw-r--r-- | dsp/smart_amp.h | 1 | ||||
-rw-r--r-- | dts.readme | 4 | ||||
-rw-r--r-- | sound/smart_amp.h | 1 | ||||
-rw-r--r-- | tas2562-codec.c | 241 | ||||
-rw-r--r-- | tas2562-regmap.c | 90 | ||||
-rw-r--r-- | tas2562.h | 9 | ||||
-rw-r--r-- | tas25xx-algo.c | 2 |
7 files changed, 222 insertions, 126 deletions
diff --git a/dsp/smart_amp.h b/dsp/smart_amp.h index 5331264..8ff3b39 100644 --- a/dsp/smart_amp.h +++ b/dsp/smart_amp.h | |||
@@ -65,6 +65,7 @@ | |||
65 | typedef enum { | 65 | typedef enum { |
66 | IV_SENSE_FORMAT_NO_VBAT = 0, | 66 | IV_SENSE_FORMAT_NO_VBAT = 0, |
67 | IV_SENSE_FORMAT_12_BIT_WITH_8BIT_VBAT = 1, | 67 | IV_SENSE_FORMAT_12_BIT_WITH_8BIT_VBAT = 1, |
68 | IV_SENSE_FORMAT_8_BIT_WITH_8BIT_VBAT = 2, | ||
68 | } ti_smartamp_iv_vbat_format_t; | 69 | } ti_smartamp_iv_vbat_format_t; |
69 | 70 | ||
70 | #ifdef INSTANCE_ID_0 | 71 | #ifdef INSTANCE_ID_0 |
@@ -31,6 +31,6 @@ b. for stereo tas2562 | |||
31 | ti,irq-gpio = <&gpio1 15 0>; | 31 | ti,irq-gpio = <&gpio1 15 0>; |
32 | ti,irq-gpio2 = <&gpio1 14 0>; | 32 | ti,irq-gpio2 = <&gpio1 14 0>; |
33 | status = "ok"; | 33 | status = "ok"; |
34 | ti,iv-width = <16>; /* IV sense by default is set to 16 bit, in case of power Limiter it should be 12*/ | 34 | ti,iv-width = <8>; /* IV sense by default is set to 16 bit, in case of power Limiter it should be 12*/ |
35 | ti,vbat-mon = <0>; /* By default Vbat should be 0, in case os power limiter it should be 1*/ | 35 | ti,vbat-mon = <1>; /* By default Vbat should be 0, in case os power limiter it should be 1*/ |
36 | }; | 36 | }; |
diff --git a/sound/smart_amp.h b/sound/smart_amp.h index b4d3392..728dfd4 100644 --- a/sound/smart_amp.h +++ b/sound/smart_amp.h | |||
@@ -63,6 +63,7 @@ | |||
63 | typedef enum { | 63 | typedef enum { |
64 | IV_SENSE_FORMAT_NO_VBAT = 0, | 64 | IV_SENSE_FORMAT_NO_VBAT = 0, |
65 | IV_SENSE_FORMAT_12_BIT_WITH_8BIT_VBAT = 1, | 65 | IV_SENSE_FORMAT_12_BIT_WITH_8BIT_VBAT = 1, |
66 | IV_SENSE_FORMAT_8_BIT_WITH_8BIT_VBAT = 2, | ||
66 | } ti_smartamp_iv_vbat_format_t; | 67 | } ti_smartamp_iv_vbat_format_t; |
67 | 68 | ||
68 | struct afe_smartamp_set_params_t { | 69 | struct afe_smartamp_set_params_t { |
diff --git a/tas2562-codec.c b/tas2562-codec.c index f37e8e1..a416f88 100644 --- a/tas2562-codec.c +++ b/tas2562-codec.c | |||
@@ -19,7 +19,6 @@ | |||
19 | * | 19 | * |
20 | * ============================================================================= | 20 | * ============================================================================= |
21 | */ | 21 | */ |
22 | |||
23 | #ifdef CONFIG_TAS2562_CODEC | 22 | #ifdef CONFIG_TAS2562_CODEC |
24 | #define DEBUG 5 | 23 | #define DEBUG 5 |
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
@@ -59,6 +58,9 @@ | |||
59 | #define TAS2562_IVSENSER_DISABLE 0 | 58 | #define TAS2562_IVSENSER_DISABLE 0 |
60 | /* #define TAS2558_CODEC */ | 59 | /* #define TAS2558_CODEC */ |
61 | 60 | ||
61 | static char p_icn_threshold[] = {0x00, 0x01, 0x2f, 0x2c}; | ||
62 | static char p_icn_hysteresis[] = {0x00, 0x01, 0x5d, 0xc0}; | ||
63 | |||
62 | static char const *iv_enable_text[] = {"Off", "On"}; | 64 | static char const *iv_enable_text[] = {"Off", "On"}; |
63 | static int tas2562iv_enable; | 65 | static int tas2562iv_enable; |
64 | static int mb_mute; | 66 | static int mb_mute; |
@@ -66,6 +68,7 @@ static int mb_mute; | |||
66 | static const struct soc_enum tas2562_enum[] = { | 68 | static const struct soc_enum tas2562_enum[] = { |
67 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(iv_enable_text), iv_enable_text), | 69 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(iv_enable_text), iv_enable_text), |
68 | }; | 70 | }; |
71 | |||
69 | static int tas2562_set_fmt(struct tas2562_priv *p_tas2562, | 72 | static int tas2562_set_fmt(struct tas2562_priv *p_tas2562, |
70 | unsigned int fmt); | 73 | unsigned int fmt); |
71 | static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562, | 74 | static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562, |
@@ -166,7 +169,7 @@ static int tas2562iv_put(struct snd_kcontrol *kcontrol, | |||
166 | } | 169 | } |
167 | 170 | ||
168 | #if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE | 171 | #if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE |
169 | p_tas2562 = snd_soc_component_get_drvdata(codec); | 172 | p_tas2562 = snd_soc_component_get_drvdata(codec); |
170 | #else | 173 | #else |
171 | p_tas2562 = snd_soc_codec_get_drvdata(codec); | 174 | p_tas2562 = snd_soc_codec_get_drvdata(codec); |
172 | #endif | 175 | #endif |
@@ -201,7 +204,7 @@ static int tas2562iv_get(struct snd_kcontrol *kcontrol, | |||
201 | } | 204 | } |
202 | 205 | ||
203 | #if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE | 206 | #if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE |
204 | p_tas2562 = snd_soc_component_get_drvdata(codec); | 207 | p_tas2562 = snd_soc_component_get_drvdata(codec); |
205 | #else | 208 | #else |
206 | p_tas2562 = snd_soc_codec_get_drvdata(codec); | 209 | p_tas2562 = snd_soc_codec_get_drvdata(codec); |
207 | #endif | 210 | #endif |
@@ -261,8 +264,7 @@ static int tas2562_codec_write(struct snd_soc_codec *codec, | |||
261 | #endif | 264 | #endif |
262 | 265 | ||
263 | static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562, | 266 | static int tas2562_i2c_load_data(struct tas2562_priv *p_tas2562, |
264 | enum channel chn, | 267 | enum channel chn, unsigned int *p_data) |
265 | unsigned int *p_data) | ||
266 | { | 268 | { |
267 | unsigned int n_register; | 269 | unsigned int n_register; |
268 | unsigned int *n_data; | 270 | unsigned int *n_data; |
@@ -377,12 +379,69 @@ static int tas2562_codec_resume(struct snd_soc_codec *codec) | |||
377 | #endif | 379 | #endif |
378 | #endif | 380 | #endif |
379 | 381 | ||
382 | static int irq_tas2562_power_up(struct tas2562_priv *p_tas2562, | ||
383 | enum channel chn) | ||
384 | { | ||
385 | int n_result = 0; | ||
386 | |||
387 | if ((p_tas2562->spk_l_control == 1) | ||
388 | && (p_tas2562->spk_r_control == 1) | ||
389 | && (p_tas2562->mn_channels == 2)) | ||
390 | chn = channel_both; | ||
391 | else if (p_tas2562->spk_l_control == 1) | ||
392 | chn = channel_left; | ||
393 | else if ((p_tas2562->spk_r_control == 1) | ||
394 | && (p_tas2562->mn_channels == 2)) | ||
395 | chn = channel_right; | ||
396 | else | ||
397 | chn = channel_left; | ||
398 | |||
399 | /*Added Interrupt Disable to fix TDM clock error*/ | ||
400 | n_result = p_tas2562->write(p_tas2562, channel_both, | ||
401 | TAS2562_INTERRUPTMASKREG0, | ||
402 | TAS2562_INTERRUPTMASKREG0_DISABLE); | ||
403 | n_result = p_tas2562->write(p_tas2562, channel_both, | ||
404 | TAS2562_INTERRUPTMASKREG1, | ||
405 | TAS2562_INTERRUPTMASKREG1_DISABLE); | ||
406 | |||
407 | /* Clear latched IRQ before power on */ | ||
408 | p_tas2562->update_bits(p_tas2562, channel_both, | ||
409 | TAS2562_INTERRUPTCONFIGURATION, | ||
410 | TAS2562_INTERRUPTCONFIGURATION_LTCHINTCLEAR_MASK, | ||
411 | TAS2562_INTERRUPTCONFIGURATION_LTCHINTCLEAR); | ||
412 | |||
413 | /*Power up sequence*/ | ||
414 | n_result = p_tas2562->update_bits(p_tas2562, | ||
415 | chn, TAS2562_POWERCONTROL, | ||
416 | TAS2562_POWERCONTROL_OPERATIONALMODE10_MASK | | ||
417 | TAS2562_POWERCONTROL_ISNSPOWER_MASK | | ||
418 | TAS2562_POWERCONTROL_VSNSPOWER_MASK, | ||
419 | TAS2562_POWERCONTROL_OPERATIONALMODE10_ACTIVE | | ||
420 | TAS2562_POWERCONTROL_ISNSPOWER_ACTIVE | | ||
421 | TAS2562_POWERCONTROL_VSNSPOWER_ACTIVE); | ||
422 | |||
423 | dev_info(p_tas2562->dev, "set ICN to -80dB\n"); | ||
424 | n_result = p_tas2562->bulk_write(p_tas2562, chn, | ||
425 | TAS2562_ICN_THRESHOLD_REG, | ||
426 | p_icn_threshold, | ||
427 | sizeof(p_icn_threshold)); | ||
428 | n_result = p_tas2562->bulk_write(p_tas2562, chn, | ||
429 | TAS2562_ICN_HYSTERESIS_REG, | ||
430 | p_icn_hysteresis, | ||
431 | sizeof(p_icn_hysteresis)); | ||
432 | |||
433 | p_tas2562->write(p_tas2562, channel_both, | ||
434 | TAS2562_INTERRUPTMASKREG0, 0xf8); | ||
435 | p_tas2562->write(p_tas2562, channel_both, | ||
436 | TAS2562_INTERRUPTMASKREG1, 0xb1); | ||
437 | |||
438 | return n_result; | ||
439 | } | ||
440 | |||
380 | static int tas2562_set_power_state(struct tas2562_priv *p_tas2562, | 441 | static int tas2562_set_power_state(struct tas2562_priv *p_tas2562, |
381 | enum channel chn, int state) | 442 | enum channel chn, int state) |
382 | { | 443 | { |
383 | int n_result = 0; | 444 | int n_result = 0; |
384 | int irqreg; | ||
385 | /*unsigned int n_value;*/ | ||
386 | 445 | ||
387 | if ((p_tas2562->mb_mute) && (state == TAS2562_POWER_ACTIVE)) | 446 | if ((p_tas2562->mb_mute) && (state == TAS2562_POWER_ACTIVE)) |
388 | state = TAS2562_POWER_MUTE; | 447 | state = TAS2562_POWER_MUTE; |
@@ -404,27 +463,39 @@ static int tas2562_set_power_state(struct tas2562_priv *p_tas2562, | |||
404 | tas25xx_set_iv_bit_fomat (p_tas2562->mn_iv_width, | 463 | tas25xx_set_iv_bit_fomat (p_tas2562->mn_iv_width, |
405 | p_tas2562->mn_vbat, 1); | 464 | p_tas2562->mn_vbat, 1); |
406 | #endif | 465 | #endif |
407 | /* Clear latched IRQ before power on */ | 466 | /*Added Interrupt Disable to fix TDM clock error*/ |
408 | 467 | n_result = p_tas2562->write(p_tas2562, channel_both, | |
409 | p_tas2562->update_bits(p_tas2562, chn, | 468 | TAS2562_INTERRUPTMASKREG0, |
410 | TAS2562_INTERRUPTCONFIGURATION, | 469 | TAS2562_INTERRUPTMASKREG0_DISABLE); |
411 | TAS2562_INTERRUPTCONFIGURATION_LTCHINTCLEAR_MASK, | 470 | n_result = p_tas2562->write(p_tas2562, channel_both, |
412 | TAS2562_INTERRUPTCONFIGURATION_LTCHINTCLEAR); | 471 | TAS2562_INTERRUPTMASKREG1, |
413 | 472 | TAS2562_INTERRUPTMASKREG1_DISABLE); | |
414 | p_tas2562->read(p_tas2562, channel_left, | 473 | |
415 | TAS2562_LATCHEDINTERRUPTREG0, &irqreg); | 474 | /*Power up sequence*/ |
416 | dev_info(p_tas2562->dev, "IRQ reg is: %s %d, %d\n", | 475 | n_result = p_tas2562->update_bits(p_tas2562, |
417 | __func__, irqreg, __LINE__); | 476 | chn, TAS2562_POWERCONTROL, |
418 | p_tas2562->read(p_tas2562, channel_right, | 477 | TAS2562_POWERCONTROL_OPERATIONALMODE10_MASK | |
419 | TAS2562_LATCHEDINTERRUPTREG0, &irqreg); | 478 | TAS2562_POWERCONTROL_ISNSPOWER_MASK | |
420 | dev_info(p_tas2562->dev, "IRQ reg is: %s %d, %d\n", | 479 | TAS2562_POWERCONTROL_VSNSPOWER_MASK, |
421 | __func__, irqreg, __LINE__); | 480 | TAS2562_POWERCONTROL_OPERATIONALMODE10_ACTIVE | |
422 | 481 | TAS2562_POWERCONTROL_ISNSPOWER_ACTIVE | | |
423 | 482 | TAS2562_POWERCONTROL_VSNSPOWER_ACTIVE); | |
483 | |||
484 | dev_info(p_tas2562->dev, "set ICN to -80dB\n"); | ||
485 | n_result = p_tas2562->bulk_write(p_tas2562, chn, | ||
486 | TAS2562_ICN_THRESHOLD_REG, | ||
487 | p_icn_threshold, | ||
488 | sizeof(p_icn_threshold)); | ||
489 | n_result = p_tas2562->bulk_write(p_tas2562, chn, | ||
490 | TAS2562_ICN_HYSTERESIS_REG, | ||
491 | p_icn_hysteresis, | ||
492 | sizeof(p_icn_hysteresis)); | ||
493 | |||
494 | /* Schedule routine enable interrupt after 100ms */ | ||
424 | p_tas2562->mb_power_up = true; | 495 | p_tas2562->mb_power_up = true; |
425 | p_tas2562->mn_power_state = TAS2562_POWER_ACTIVE; | 496 | p_tas2562->mn_power_state = TAS2562_POWER_ACTIVE; |
426 | schedule_delayed_work(&p_tas2562->irq_work, | 497 | schedule_delayed_work(&p_tas2562->init_work, |
427 | msecs_to_jiffies(40)); | 498 | msecs_to_jiffies(200)); |
428 | break; | 499 | break; |
429 | 500 | ||
430 | case TAS2562_POWER_MUTE: | 501 | case TAS2562_POWER_MUTE: |
@@ -441,11 +512,15 @@ static int tas2562_set_power_state(struct tas2562_priv *p_tas2562, | |||
441 | break; | 512 | break; |
442 | 513 | ||
443 | case TAS2562_POWER_SHUTDOWN: | 514 | case TAS2562_POWER_SHUTDOWN: |
444 | 515 | /*Included IV Sense Power Down*/ | |
445 | n_result = p_tas2562->update_bits(p_tas2562, chn, | 516 | n_result = p_tas2562->update_bits(p_tas2562, chn, |
446 | TAS2562_POWERCONTROL, | 517 | TAS2562_POWERCONTROL, |
447 | TAS2562_POWERCONTROL_OPERATIONALMODE10_MASK, | 518 | TAS2562_POWERCONTROL_OPERATIONALMODE10_MASK | |
448 | TAS2562_POWERCONTROL_OPERATIONALMODE10_SHUTDOWN); | 519 | TAS2562_POWERCONTROL_ISNSPOWER_MASK | |
520 | TAS2562_POWERCONTROL_VSNSPOWER_MASK, | ||
521 | TAS2562_POWERCONTROL_OPERATIONALMODE10_SHUTDOWN | | ||
522 | TAS2562_POWERCONTROL_VSNSPOWER_POWEREDDOWN | | ||
523 | TAS2562_POWERCONTROL_ISNSPOWER_POWEREDDOWN); | ||
449 | p_tas2562->mb_power_up = false; | 524 | p_tas2562->mb_power_up = false; |
450 | p_tas2562->mn_power_state = TAS2562_POWER_SHUTDOWN; | 525 | p_tas2562->mn_power_state = TAS2562_POWER_SHUTDOWN; |
451 | msleep(20); | 526 | msleep(20); |
@@ -622,18 +697,39 @@ static int tas2562_iv_slot_config(struct tas2562_priv *p_tas2562) | |||
622 | p_tas2562->update_bits(p_tas2562, channel_right, | 697 | p_tas2562->update_bits(p_tas2562, channel_right, |
623 | TAS2562_TDMCONFIGURATIONREG6, 0xff, 0x42); | 698 | TAS2562_TDMCONFIGURATIONREG6, 0xff, 0x42); |
624 | } else { | 699 | } else { |
700 | if (p_tas2562->mn_iv_width == 8) { | ||
701 | p_tas2562->update_bits(p_tas2562, channel_left, | ||
702 | TAS2562_TDMCONFIGURATIONREG5, 0xff, 0x41); | ||
625 | 703 | ||
626 | p_tas2562->update_bits(p_tas2562, channel_left, | 704 | p_tas2562->update_bits(p_tas2562, channel_left, |
627 | TAS2562_TDMCONFIGURATIONREG5, 0xff, 0x42); | 705 | TAS2562_TDMCONFIGURATIONREG6, 0xff, 0x40); |
628 | 706 | ||
629 | p_tas2562->update_bits(p_tas2562, channel_left, | 707 | p_tas2562->update_bits(p_tas2562, channel_right, |
630 | TAS2562_TDMCONFIGURATIONREG6, 0xff, 0x40); | 708 | TAS2562_TDMCONFIGURATIONREG5, 0xff, 0x45); |
631 | 709 | ||
632 | p_tas2562->update_bits(p_tas2562, channel_right, | 710 | p_tas2562->update_bits(p_tas2562, channel_right, |
633 | TAS2562_TDMCONFIGURATIONREG5, 0xff, 0x46); | 711 | TAS2562_TDMCONFIGURATIONREG6, 0xff, 0x44); |
634 | 712 | ||
635 | p_tas2562->update_bits(p_tas2562, channel_right, | 713 | if (p_tas2562->mn_vbat == 1) { |
636 | TAS2562_TDMCONFIGURATIONREG6, 0xff, 0x44); | 714 | p_tas2562->update_bits(p_tas2562, channel_left, |
715 | TAS2562_TDMCONFIGURATIONREG7, 0xff, 0x42); | ||
716 | |||
717 | p_tas2562->update_bits(p_tas2562, channel_right, | ||
718 | TAS2562_TDMCONFIGURATIONREG7, 0xff, 0x46); | ||
719 | } | ||
720 | } else { | ||
721 | p_tas2562->update_bits(p_tas2562, channel_left, | ||
722 | TAS2562_TDMCONFIGURATIONREG5, 0xff, 0x42); | ||
723 | |||
724 | p_tas2562->update_bits(p_tas2562, channel_left, | ||
725 | TAS2562_TDMCONFIGURATIONREG6, 0xff, 0x40); | ||
726 | |||
727 | p_tas2562->update_bits(p_tas2562, channel_right, | ||
728 | TAS2562_TDMCONFIGURATIONREG5, 0xff, 0x46); | ||
729 | |||
730 | p_tas2562->update_bits(p_tas2562, channel_right, | ||
731 | TAS2562_TDMCONFIGURATIONREG6, 0xff, 0x44); | ||
732 | } | ||
637 | } | 733 | } |
638 | } else if ((p_tas2562->mn_channels == 1) | 734 | } else if ((p_tas2562->mn_channels == 1) |
639 | && (p_tas2562->mn_slot_width == 32)) { | 735 | && (p_tas2562->mn_slot_width == 32)) { |
@@ -702,6 +798,11 @@ static int tas2562_iv_bitwidth_config(struct tas2562_priv *p_tas2562) | |||
702 | TAS2562_TDMCONFIGURATIONREG2, | 798 | TAS2562_TDMCONFIGURATIONREG2, |
703 | TAS2562_TDMCONFIGURATIONREG2_IVMONLEN76_MASK, | 799 | TAS2562_TDMCONFIGURATIONREG2_IVMONLEN76_MASK, |
704 | TAS2562_TDMCONFIGURATIONREG2_IVMONLEN76_8BITS); | 800 | TAS2562_TDMCONFIGURATIONREG2_IVMONLEN76_8BITS); |
801 | } else { /*mn_iv_width == 12 || 16*/ | ||
802 | p_tas2562->update_bits(p_tas2562, channel_left, | ||
803 | TAS2562_TDMCONFIGURATIONREG2, | ||
804 | TAS2562_TDMCONFIGURATIONREG2_IVLEN76_MASK, | ||
805 | TAS2562_TDMCONFIGURATIONREG2_IVLENCFG76_16BITS); | ||
705 | } | 806 | } |
706 | 807 | ||
707 | return ret; | 808 | return ret; |
@@ -927,8 +1028,8 @@ static int tas2562_mute_ctrl_get(struct snd_kcontrol *pKcontrol, | |||
927 | #endif | 1028 | #endif |
928 | pValue->value.integer.value[0] = p_tas2562->mb_mute; | 1029 | pValue->value.integer.value[0] = p_tas2562->mb_mute; |
929 | 1030 | ||
930 | if((p_tas2562->mb_power_up == true)&& | 1031 | if ((p_tas2562->mb_power_up == true) |
931 | (p_tas2562->mn_power_state == TAS2562_POWER_ACTIVE)) | 1032 | && (p_tas2562->mn_power_state == TAS2562_POWER_ACTIVE)) |
932 | pValue->value.integer.value[0] = 0; | 1033 | pValue->value.integer.value[0] = 0; |
933 | else | 1034 | else |
934 | pValue->value.integer.value[0] = 1; | 1035 | pValue->value.integer.value[0] = 1; |
@@ -948,7 +1049,7 @@ static int tas2562_mute_ctrl_put(struct snd_kcontrol *pKcontrol, | |||
948 | #else | 1049 | #else |
949 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); | 1050 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); |
950 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); | 1051 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); |
951 | #endif | 1052 | #endif |
952 | enum channel chn; | 1053 | enum channel chn; |
953 | int mute = pValue->value.integer.value[0]; | 1054 | int mute = pValue->value.integer.value[0]; |
954 | 1055 | ||
@@ -988,7 +1089,7 @@ static int tas2562_hw_params(struct snd_pcm_substream *substream, | |||
988 | #else | 1089 | #else |
989 | struct snd_soc_codec *codec = dai->codec; | 1090 | struct snd_soc_codec *codec = dai->codec; |
990 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); | 1091 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); |
991 | #endif | 1092 | #endif |
992 | /* int blr_clk_ratio; */ | 1093 | /* int blr_clk_ratio; */ |
993 | int n_result = 0; | 1094 | int n_result = 0; |
994 | 1095 | ||
@@ -1093,7 +1194,7 @@ static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
1093 | #else | 1194 | #else |
1094 | struct snd_soc_codec *codec = dai->codec; | 1195 | struct snd_soc_codec *codec = dai->codec; |
1095 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); | 1196 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); |
1096 | #endif | 1197 | #endif |
1097 | int ret = 0; | 1198 | int ret = 0; |
1098 | 1199 | ||
1099 | dev_dbg(p_tas2562->dev, "%s, format=0x%x\n", __func__, fmt); | 1200 | dev_dbg(p_tas2562->dev, "%s, format=0x%x\n", __func__, fmt); |
@@ -1187,9 +1288,14 @@ static int tas2562_load_init(struct tas2562_priv *p_tas2562) | |||
1187 | TAS2562_MISCCONFIGURATIONREG0, 0xcf); | 1288 | TAS2562_MISCCONFIGURATIONREG0, 0xcf); |
1188 | if (ret < 0) | 1289 | if (ret < 0) |
1189 | return ret; | 1290 | return ret; |
1291 | |||
1190 | #ifdef CONFIG_PLATFORM_EXYNOS | 1292 | #ifdef CONFIG_PLATFORM_EXYNOS |
1191 | if(p_tas2562->mn_channels == 2) { | 1293 | if (p_tas2562->mn_channels == 2) { |
1192 | ret = p_tas2562->write(p_tas2562, channel_both, | 1294 | ret = p_tas2562->write(p_tas2562, channel_left, |
1295 | TAS2562_TDMConfigurationReg4, 0xf3); | ||
1296 | if (ret < 0) | ||
1297 | return ret; | ||
1298 | ret = p_tas2562->write(p_tas2562, channel_right, | ||
1193 | TAS2562_TDMConfigurationReg4, 0x13); | 1299 | TAS2562_TDMConfigurationReg4, 0x13); |
1194 | if (ret < 0) | 1300 | if (ret < 0) |
1195 | return ret; | 1301 | return ret; |
@@ -1201,17 +1307,22 @@ static int tas2562_load_init(struct tas2562_priv *p_tas2562) | |||
1201 | } | 1307 | } |
1202 | #else | 1308 | #else |
1203 | if (p_tas2562->mn_channels == 2) { | 1309 | if (p_tas2562->mn_channels == 2) { |
1204 | ret = p_tas2562->write(p_tas2562, channel_both, | 1310 | ret = p_tas2562->write(p_tas2562, channel_left, |
1205 | TAS2562_TDMConfigurationReg4, 0x11); | 1311 | TAS2562_TDMConfigurationReg4, 0xf1); |
1312 | if (ret < 0) | ||
1313 | return ret; | ||
1314 | ret = p_tas2562->write(p_tas2562, channel_right, | ||
1315 | TAS2562_TDMConfigurationReg4, 0x11); | ||
1206 | if (ret < 0) | 1316 | if (ret < 0) |
1207 | return ret; | 1317 | return ret; |
1208 | } else { | 1318 | } else { |
1209 | ret = p_tas2562->write(p_tas2562, channel_both, | 1319 | ret = p_tas2562->write(p_tas2562, channel_both, |
1210 | TAS2562_TDMConfigurationReg4, 0x01); | 1320 | TAS2562_TDMConfigurationReg4, 0x01); |
1211 | if (ret < 0) | 1321 | if (ret < 0) |
1212 | return ret; | 1322 | return ret; |
1213 | } | 1323 | } |
1214 | #endif | 1324 | #endif |
1325 | |||
1215 | ret = p_tas2562->write(p_tas2562, channel_both, | 1326 | ret = p_tas2562->write(p_tas2562, channel_both, |
1216 | TAS2562_CLOCKCONFIGURATION, 0x0c); | 1327 | TAS2562_CLOCKCONFIGURATION, 0x0c); |
1217 | if (ret < 0) | 1328 | if (ret < 0) |
@@ -1219,6 +1330,13 @@ static int tas2562_load_init(struct tas2562_priv *p_tas2562) | |||
1219 | ret = tas2562_i2c_load_data(p_tas2562, channel_both, | 1330 | ret = tas2562_i2c_load_data(p_tas2562, channel_both, |
1220 | p_tas2562_classh_d_data); | 1331 | p_tas2562_classh_d_data); |
1221 | 1332 | ||
1333 | /* Increase the clock halt timer to 838ms to avoid | ||
1334 | TDM Clock errors during playback start/stop */ | ||
1335 | ret = p_tas2562->update_bits(p_tas2562, channel_both, | ||
1336 | TAS2562_INTERRUPTCONFIGURATION, | ||
1337 | TAS2562_CLOCK_HALT_TIMER_MASK, | ||
1338 | TAS2562_CLOCK_HALT_838MS); | ||
1339 | |||
1222 | return ret; | 1340 | return ret; |
1223 | } | 1341 | } |
1224 | 1342 | ||
@@ -1288,6 +1406,7 @@ static const struct soc_enum icn_sw_enum[] = { | |||
1288 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(icn_sw_text), | 1406 | SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(icn_sw_text), |
1289 | icn_sw_text), | 1407 | icn_sw_text), |
1290 | }; | 1408 | }; |
1409 | |||
1291 | static int tas2562_get_icn_switch(struct snd_kcontrol *pKcontrol, | 1410 | static int tas2562_get_icn_switch(struct snd_kcontrol *pKcontrol, |
1292 | struct snd_ctl_elem_value *p_u_control) | 1411 | struct snd_ctl_elem_value *p_u_control) |
1293 | { | 1412 | { |
@@ -1295,10 +1414,11 @@ static int tas2562_get_icn_switch(struct snd_kcontrol *pKcontrol, | |||
1295 | struct snd_soc_component *codec | 1414 | struct snd_soc_component *codec |
1296 | = snd_soc_kcontrol_component(pKcontrol); | 1415 | = snd_soc_kcontrol_component(pKcontrol); |
1297 | struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec); | 1416 | struct tas2562_priv *p_tas2562 = snd_soc_component_get_drvdata(codec); |
1298 | #else | 1417 | #else |
1299 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); | 1418 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol); |
1300 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); | 1419 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); |
1301 | #endif | 1420 | #endif |
1421 | |||
1302 | dev_info(p_tas2562->dev, "%s, icn_sw = %ld\n", | 1422 | dev_info(p_tas2562->dev, "%s, icn_sw = %ld\n", |
1303 | __func__, p_u_control->value.integer.value[0]); | 1423 | __func__, p_u_control->value.integer.value[0]); |
1304 | p_u_control->value.integer.value[0] = p_tas2562->icn_sw; | 1424 | p_u_control->value.integer.value[0] = p_tas2562->icn_sw; |
@@ -1316,23 +1436,21 @@ static int tas2562_set_icn_switch(struct snd_kcontrol *pKcontrol, | |||
1316 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); | 1436 | struct tas2562_priv *p_tas2562 = snd_soc_codec_get_drvdata(codec); |
1317 | #endif | 1437 | #endif |
1318 | p_tas2562->icn_sw = p_u_control->value.integer.value[0]; | 1438 | p_tas2562->icn_sw = p_u_control->value.integer.value[0]; |
1319 | if (p_tas2562->icn_sw == 0) { | 1439 | if (p_tas2562->icn_sw == 0) { |
1320 | p_tas2562->update_bits(p_tas2562, channel_both, | 1440 | p_tas2562->update_bits(p_tas2562, channel_both, |
1321 | TAS2562_ICN_SW_REG, | 1441 | TAS2562_ICN_SW_REG, |
1322 | TAS2562_ICN_SW_MASK, | 1442 | TAS2562_ICN_SW_MASK, |
1323 | TAS2562_ICN_SW_ENABLE); | 1443 | TAS2562_ICN_SW_ENABLE); |
1324 | dev_info(p_tas2562->dev, "%s: ICN Enable!\n", __func__); | 1444 | dev_info(p_tas2562->dev, "%s: ICN Enable!\n", __func__); |
1325 | } else { | 1445 | } else { |
1326 | p_tas2562->update_bits(p_tas2562, channel_both, | 1446 | p_tas2562->update_bits(p_tas2562, channel_both, |
1327 | TAS2562_ICN_SW_REG, | 1447 | TAS2562_ICN_SW_REG, |
1328 | TAS2562_ICN_SW_MASK, | 1448 | TAS2562_ICN_SW_MASK, |
1329 | TAS2562_ICN_SW_DISABLE); | 1449 | TAS2562_ICN_SW_DISABLE); |
1330 | dev_info(p_tas2562->dev, "%s: ICN Disable!\n", __func__); | 1450 | dev_info(p_tas2562->dev, "%s: ICN Disable!\n", __func__); |
1331 | } | 1451 | } |
1332 | return 0; | 1452 | return 0; |
1333 | } | 1453 | } |
1334 | |||
1335 | |||
1336 | static int tas2562_dac_mute_ctrl_get(struct snd_kcontrol *pKcontrol, | 1454 | static int tas2562_dac_mute_ctrl_get(struct snd_kcontrol *pKcontrol, |
1337 | struct snd_ctl_elem_value *pValue) | 1455 | struct snd_ctl_elem_value *pValue) |
1338 | { | 1456 | { |
@@ -1391,17 +1509,17 @@ static int tas2562_dac_mute_ctrl_put(struct snd_kcontrol *pKcontrol, | |||
1391 | TAS2562_POWERCONTROL_OPERATIONALMODE10_ACTIVE); | 1509 | TAS2562_POWERCONTROL_OPERATIONALMODE10_ACTIVE); |
1392 | } | 1510 | } |
1393 | 1511 | ||
1394 | p_tas2562->dac_mute = mute; | 1512 | p_tas2562->dac_mute = mute; |
1395 | mutex_unlock(&p_tas2562->codec_lock); | 1513 | mutex_unlock(&p_tas2562->codec_lock); |
1396 | 1514 | ||
1397 | return n_result; | 1515 | return n_result; |
1398 | } | 1516 | } |
1399 | static const struct snd_kcontrol_new tas2562_snd_controls[] = { | 1517 | static const struct snd_kcontrol_new tas2562_snd_controls[] = { |
1400 | SOC_SINGLE_TLV("Amp Output Level", TAS2562_PLAYBACKCONFIGURATIONREG0, | 1518 | SOC_SINGLE_TLV("Amp Output Level", TAS2562_PLAYBACKCONFIGURATIONREG0, |
1401 | 1, 0x16, 0, | 1519 | 1, 0x16, 0, tas2562_digital_tlv), |
1402 | tas2562_digital_tlv), | ||
1403 | SOC_SINGLE_EXT("SmartPA System Mute", SND_SOC_NOPM, 0, 0x0001, 0, | 1520 | SOC_SINGLE_EXT("SmartPA System Mute", SND_SOC_NOPM, 0, 0x0001, 0, |
1404 | tas2562_system_mute_ctrl_get, tas2562_system_mute_ctrl_put), | 1521 | tas2562_system_mute_ctrl_get, |
1522 | tas2562_system_mute_ctrl_put), | ||
1405 | SOC_SINGLE_EXT("SmartPA Mute", SND_SOC_NOPM, 0, 0x0001, 0, | 1523 | SOC_SINGLE_EXT("SmartPA Mute", SND_SOC_NOPM, 0, 0x0001, 0, |
1406 | tas2562_mute_ctrl_get, tas2562_mute_ctrl_put), | 1524 | tas2562_mute_ctrl_get, tas2562_mute_ctrl_put), |
1407 | SOC_SINGLE_EXT("TAS2562 DAC Mute", SND_SOC_NOPM, 0, 0x0001, 0, | 1525 | SOC_SINGLE_EXT("TAS2562 DAC Mute", SND_SOC_NOPM, 0, 0x0001, 0, |
@@ -1481,6 +1599,7 @@ int tas2562_deregister_codec(struct tas2562_priv *p_tas2562) | |||
1481 | #ifdef CONFIG_TAS25XX_ALGO | 1599 | #ifdef CONFIG_TAS25XX_ALGO |
1482 | smartamp_remove_algo(); | 1600 | smartamp_remove_algo(); |
1483 | #endif /*CONFIG_TAS25XX_ALGO*/ | 1601 | #endif /*CONFIG_TAS25XX_ALGO*/ |
1602 | |||
1484 | #if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE | 1603 | #if KERNEL_VERSION(4, 19, 0) <= LINUX_VERSION_CODE |
1485 | snd_soc_unregister_component(p_tas2562->dev); | 1604 | snd_soc_unregister_component(p_tas2562->dev); |
1486 | #else | 1605 | #else |
@@ -1500,9 +1619,8 @@ void tas2562_load_config(struct tas2562_priv *p_tas2562) | |||
1500 | msleep(20); | 1619 | msleep(20); |
1501 | 1620 | ||
1502 | ret = tas2562_iv_slot_config(p_tas2562); | 1621 | ret = tas2562_iv_slot_config(p_tas2562); |
1503 | if(ret < 0) { | 1622 | if (ret < 0) |
1504 | goto end; | 1623 | goto end; |
1505 | } | ||
1506 | 1624 | ||
1507 | tas2562_load_init(p_tas2562); | 1625 | tas2562_load_init(p_tas2562); |
1508 | tas2562_iv_enable(p_tas2562, tas2562iv_enable); | 1626 | tas2562_iv_enable(p_tas2562, tas2562iv_enable); |
@@ -1523,8 +1641,7 @@ void tas2562_load_config(struct tas2562_priv *p_tas2562) | |||
1523 | if (ret < 0) | 1641 | if (ret < 0) |
1524 | goto end; | 1642 | goto end; |
1525 | 1643 | ||
1526 | ret = tas2562_set_power_state(p_tas2562, channel_both, | 1644 | ret = irq_tas2562_power_up(p_tas2562, channel_both); |
1527 | p_tas2562->mn_power_state); | ||
1528 | if (ret < 0) | 1645 | if (ret < 0) |
1529 | goto end; | 1646 | goto end; |
1530 | 1647 | ||
diff --git a/tas2562-regmap.c b/tas2562-regmap.c index 1d0672d..3bb6e41 100644 --- a/tas2562-regmap.c +++ b/tas2562-regmap.c | |||
@@ -47,9 +47,6 @@ | |||
47 | #endif | 47 | #endif |
48 | #endif /*CONFIG_TAS25XX_ALGO*/ | 48 | #endif /*CONFIG_TAS25XX_ALGO*/ |
49 | 49 | ||
50 | static char p_icn_threshold[] = {0x00, 0x01, 0x2f, 0x2c}; | ||
51 | static char p_icn_hysteresis[] = {0x00, 0x01, 0x5d, 0xc0}; | ||
52 | |||
53 | static int tas2562_regmap_write(struct tas2562_priv *p_tas2562, | 50 | static int tas2562_regmap_write(struct tas2562_priv *p_tas2562, |
54 | unsigned int reg, unsigned int value) | 51 | unsigned int reg, unsigned int value) |
55 | { | 52 | { |
@@ -166,7 +163,6 @@ static int tas2562_change_book_page(struct tas2562_priv *p_tas2562, | |||
166 | { | 163 | { |
167 | int n_result = 0; | 164 | int n_result = 0; |
168 | 165 | ||
169 | |||
170 | if ((chn&channel_left) || (p_tas2562->mn_channels == 1)) { | 166 | if ((chn&channel_left) || (p_tas2562->mn_channels == 1)) { |
171 | p_tas2562->client->addr = p_tas2562->mn_l_addr; | 167 | p_tas2562->client->addr = p_tas2562->mn_l_addr; |
172 | if (p_tas2562->mn_l_current_book != book) { | 168 | if (p_tas2562->mn_l_current_book != book) { |
@@ -475,30 +471,22 @@ static void tas2562_hw_reset(struct tas2562_priv *p_tas2562) | |||
475 | { | 471 | { |
476 | if (gpio_is_valid(p_tas2562->mn_reset_gpio)) { | 472 | if (gpio_is_valid(p_tas2562->mn_reset_gpio)) { |
477 | gpio_direction_output(p_tas2562->mn_reset_gpio, 0); | 473 | gpio_direction_output(p_tas2562->mn_reset_gpio, 0); |
478 | if (p_tas2562->mn_channels != 1) { | 474 | |
479 | dev_dbg(p_tas2562->dev, | 475 | if (p_tas2562->mn_channels == 2) { |
480 | "Reset gpio: not mono case, resetting second gpio"); | ||
481 | if (gpio_is_valid(p_tas2562->mn_reset_gpio2)) | 476 | if (gpio_is_valid(p_tas2562->mn_reset_gpio2)) |
482 | gpio_direction_output(p_tas2562->mn_reset_gpio2, 0); | 477 | gpio_direction_output(p_tas2562->mn_reset_gpio2, 0); |
483 | } else { | ||
484 | dev_dbg(p_tas2562->dev, | ||
485 | "Reset gpio: mono case, not resetting second gpio"); | ||
486 | } | 478 | } |
479 | |||
487 | msleep(20); | 480 | msleep(20); |
488 | 481 | ||
489 | gpio_direction_output(p_tas2562->mn_reset_gpio, 1); | 482 | gpio_direction_output(p_tas2562->mn_reset_gpio, 1); |
490 | 483 | ||
491 | if (p_tas2562->mn_channels != 1) { | 484 | if (p_tas2562->mn_channels == 2) { |
492 | dev_dbg(p_tas2562->dev, | ||
493 | "Reset gpio: not mono case, resetting second gpio"); | ||
494 | if (gpio_is_valid(p_tas2562->mn_reset_gpio2)) | 485 | if (gpio_is_valid(p_tas2562->mn_reset_gpio2)) |
495 | gpio_direction_output(p_tas2562->mn_reset_gpio2, 1); | 486 | gpio_direction_output(p_tas2562->mn_reset_gpio2, 1); |
496 | } else { | ||
497 | dev_dbg(p_tas2562->dev, | ||
498 | "Reset gpio: mono case, not resetting second gpio"); | ||
499 | } | 487 | } |
500 | 488 | ||
501 | msleep(20); | 489 | msleep(20); |
502 | } | 490 | } |
503 | dev_info(p_tas2562->dev, "reset gpio up !!\n"); | 491 | dev_info(p_tas2562->dev, "reset gpio up !!\n"); |
504 | 492 | ||
@@ -513,6 +501,7 @@ void tas2562_enable_irq(struct tas2562_priv *p_tas2562, bool enable) | |||
513 | static int irq1_enabled; | 501 | static int irq1_enabled; |
514 | static int irq2_enabled; | 502 | static int irq2_enabled; |
515 | struct irq_desc *desc = NULL; | 503 | struct irq_desc *desc = NULL; |
504 | |||
516 | if (enable) { | 505 | if (enable) { |
517 | if (p_tas2562->mb_irq_eable) | 506 | if (p_tas2562->mb_irq_eable) |
518 | return; | 507 | return; |
@@ -617,7 +606,7 @@ static void irq_work_routine(struct work_struct *work) | |||
617 | goto reload; | 606 | goto reload; |
618 | 607 | ||
619 | dev_dbg(p_tas2562->dev, "IRQ status : 0x%x, 0x%x, 0x%x, 0x%x\n", | 608 | dev_dbg(p_tas2562->dev, "IRQ status : 0x%x, 0x%x, 0x%x, 0x%x\n", |
620 | nDevInt3Status, nDevInt4Status, | 609 | nDevInt1Status, nDevInt2Status, |
621 | nDevInt3Status, nDevInt4Status); | 610 | nDevInt3Status, nDevInt4Status); |
622 | 611 | ||
623 | if (((nDevInt1Status & 0x7) != 0) | 612 | if (((nDevInt1Status & 0x7) != 0) |
@@ -627,15 +616,14 @@ static void irq_work_routine(struct work_struct *work) | |||
627 | /* in case of INT_CLK, INT_OC, INT_OT, | 616 | /* in case of INT_CLK, INT_OC, INT_OT, |
628 | * INT_OVLT, INT_UVLT, INT_BO | 617 | * INT_OVLT, INT_UVLT, INT_BO |
629 | */ | 618 | */ |
630 | 619 | if ((nDevInt1Status & | |
631 | if ((nDevInt1Status & | ||
632 | TAS2562_LATCHEDINTERRUPTREG0_TDMCLOCKERRORSTICKY_INTERRUPT) || | 620 | TAS2562_LATCHEDINTERRUPTREG0_TDMCLOCKERRORSTICKY_INTERRUPT) || |
633 | (nDevInt3Status & | 621 | (nDevInt3Status & |
634 | TAS2562_LATCHEDINTERRUPTREG0_TDMCLOCKERRORSTICKY_INTERRUPT)) { | 622 | TAS2562_LATCHEDINTERRUPTREG0_TDMCLOCKERRORSTICKY_INTERRUPT)) { |
635 | p_tas2562->mn_err_code |= ERROR_CLOCK; | 623 | p_tas2562->mn_err_code |= ERROR_CLOCK; |
636 | dev_err(p_tas2562->dev, "TDM clock error!\n"); | 624 | dev_err(p_tas2562->dev, "TDM clock error!\n"); |
637 | } else | 625 | } else |
638 | p_tas2562->mn_err_code &= ~ERROR_OVER_CURRENT; | 626 | p_tas2562->mn_err_code &= ~ERROR_CLOCK; |
639 | 627 | ||
640 | if ((nDevInt1Status & | 628 | if ((nDevInt1Status & |
641 | TAS2562_LATCHEDINTERRUPTREG0_OCEFLAGSTICKY_INTERRUPT) || | 629 | TAS2562_LATCHEDINTERRUPTREG0_OCEFLAGSTICKY_INTERRUPT) || |
@@ -729,23 +717,6 @@ static void irq_work_routine(struct work_struct *work) | |||
729 | dev_info(p_tas2562->dev, "IRQ reg is: %s %d, %d\n", | 717 | dev_info(p_tas2562->dev, "IRQ reg is: %s %d, %d\n", |
730 | __func__, irqreg, __LINE__); | 718 | __func__, irqreg, __LINE__); |
731 | 719 | ||
732 | n_result = p_tas2562->update_bits(p_tas2562, | ||
733 | chn, TAS2562_POWERCONTROL, | ||
734 | TAS2562_POWERCONTROL_OPERATIONALMODE10_MASK, | ||
735 | TAS2562_POWERCONTROL_OPERATIONALMODE10_ACTIVE); | ||
736 | if (n_result < 0) | ||
737 | goto reload; | ||
738 | |||
739 | dev_info(p_tas2562->dev, "set ICN to -80dB\n"); | ||
740 | n_result = p_tas2562->bulk_write(p_tas2562, chn, | ||
741 | TAS2562_ICN_THRESHOLD_REG, | ||
742 | p_icn_threshold, | ||
743 | sizeof(p_icn_threshold)); | ||
744 | n_result = p_tas2562->bulk_write(p_tas2562, chn, | ||
745 | TAS2562_ICN_HYSTERESIS_REG, | ||
746 | p_icn_hysteresis, | ||
747 | sizeof(p_icn_hysteresis)); | ||
748 | |||
749 | p_tas2562->read(p_tas2562, channel_left, | 720 | p_tas2562->read(p_tas2562, channel_left, |
750 | TAS2562_LATCHEDINTERRUPTREG0, &irqreg); | 721 | TAS2562_LATCHEDINTERRUPTREG0, &irqreg); |
751 | dev_info(p_tas2562->dev, "IRQ reg is: %s, %d, %d\n", | 722 | dev_info(p_tas2562->dev, "IRQ reg is: %s, %d, %d\n", |
@@ -754,7 +725,6 @@ static void irq_work_routine(struct work_struct *work) | |||
754 | TAS2562_LATCHEDINTERRUPTREG0, &irqreg); | 725 | TAS2562_LATCHEDINTERRUPTREG0, &irqreg); |
755 | dev_info(p_tas2562->dev, "IRQ reg is: %s %d, %d\n", | 726 | dev_info(p_tas2562->dev, "IRQ reg is: %s %d, %d\n", |
756 | __func__, irqreg, __LINE__); | 727 | __func__, irqreg, __LINE__); |
757 | |||
758 | n_counter--; | 728 | n_counter--; |
759 | if (n_counter > 0) { | 729 | if (n_counter > 0) { |
760 | /* in case check pow status just after power on TAS2562 */ | 730 | /* in case check pow status just after power on TAS2562 */ |
@@ -782,12 +752,12 @@ static void irq_work_routine(struct work_struct *work) | |||
782 | p_tas2562->mn_err_code &= ~ERROR_CLASSD_PWR; | 752 | p_tas2562->mn_err_code &= ~ERROR_CLASSD_PWR; |
783 | } | 753 | } |
784 | 754 | ||
785 | n_result = p_tas2562->write(p_tas2562, channel_left, | 755 | n_result = p_tas2562->write(p_tas2562, channel_both, |
786 | TAS2562_INTERRUPTMASKREG0, 0xf8); | 756 | TAS2562_INTERRUPTMASKREG0, 0xf8); |
787 | if (n_result < 0) | 757 | if (n_result < 0) |
788 | goto reload; | 758 | goto reload; |
789 | 759 | ||
790 | n_result = p_tas2562->write(p_tas2562, channel_left, | 760 | n_result = p_tas2562->write(p_tas2562, channel_both, |
791 | TAS2562_INTERRUPTMASKREG1, 0xb1); | 761 | TAS2562_INTERRUPTMASKREG1, 0xb1); |
792 | if (n_result < 0) | 762 | if (n_result < 0) |
793 | goto reload; | 763 | goto reload; |
@@ -809,29 +779,23 @@ static void init_work_routine(struct work_struct *work) | |||
809 | { | 779 | { |
810 | struct tas2562_priv *p_tas2562 = | 780 | struct tas2562_priv *p_tas2562 = |
811 | container_of(work, struct tas2562_priv, init_work.work); | 781 | container_of(work, struct tas2562_priv, init_work.work); |
812 | int nResult = 0; | 782 | |
813 | //int irqreg; | 783 | dev_info(p_tas2562->dev, "%s\n", __func__); |
814 | //dev_info(p_tas2562->dev, "%s\n", __func__); | ||
815 | #ifdef CONFIG_TAS2562_CODEC | 784 | #ifdef CONFIG_TAS2562_CODEC |
816 | mutex_lock(&p_tas2562->codec_lock); | 785 | mutex_lock(&p_tas2562->codec_lock); |
817 | #endif | 786 | #endif |
787 | /* Clear latched IRQ before power on */ | ||
788 | p_tas2562->update_bits(p_tas2562, channel_both, | ||
789 | TAS2562_INTERRUPTCONFIGURATION, | ||
790 | TAS2562_INTERRUPTCONFIGURATION_LTCHINTCLEAR_MASK, | ||
791 | TAS2562_INTERRUPTCONFIGURATION_LTCHINTCLEAR); | ||
818 | 792 | ||
819 | p_tas2562->update_bits(p_tas2562, channel_both, TAS2562_POWERCONTROL, | 793 | p_tas2562->write(p_tas2562, channel_both, |
820 | TAS2562_POWERCONTROL_OPERATIONALMODE10_MASK, | 794 | TAS2562_INTERRUPTMASKREG0, 0xf8); |
821 | TAS2562_POWERCONTROL_OPERATIONALMODE10_ACTIVE); | 795 | p_tas2562->write(p_tas2562, channel_both, |
822 | 796 | TAS2562_INTERRUPTMASKREG1, 0xb1); | |
823 | //dev_info(p_tas2562->dev, "set ICN to -80dB\n"); | ||
824 | p_tas2562->bulk_write(p_tas2562, channel_both, | ||
825 | TAS2562_ICN_THRESHOLD_REG, | ||
826 | p_icn_threshold, | ||
827 | sizeof(p_icn_threshold)); | ||
828 | p_tas2562->bulk_write(p_tas2562, channel_both, | ||
829 | TAS2562_ICN_HYSTERESIS_REG, | ||
830 | p_icn_hysteresis, | ||
831 | sizeof(p_icn_hysteresis)); | ||
832 | 797 | ||
833 | nResult = gpio_get_value(p_tas2562->mn_irq_gpio); | 798 | p_tas2562->enable_irq(p_tas2562, true); |
834 | //dev_info(p_tas2562->dev, "%s, irq GPIO state: %d\n", __func__, nResult); | ||
835 | 799 | ||
836 | #ifdef CONFIG_TAS2562_CODEC | 800 | #ifdef CONFIG_TAS2562_CODEC |
837 | mutex_unlock(&p_tas2562->codec_lock); | 801 | mutex_unlock(&p_tas2562->codec_lock); |
@@ -875,7 +839,7 @@ static int tas2562_pm_suspend(struct device *dev) | |||
875 | struct tas2562_priv *p_tas2562 = dev_get_drvdata(dev); | 839 | struct tas2562_priv *p_tas2562 = dev_get_drvdata(dev); |
876 | 840 | ||
877 | if (!p_tas2562) { | 841 | if (!p_tas2562) { |
878 | dev_err(p_tas2562->dev, "drvdata is NULL\n"); | 842 | pr_err("drvdata is NULL\n"); |
879 | return -EINVAL; | 843 | return -EINVAL; |
880 | } | 844 | } |
881 | 845 | ||
@@ -890,9 +854,10 @@ static int tas2562_pm_resume(struct device *dev) | |||
890 | struct tas2562_priv *p_tas2562 = dev_get_drvdata(dev); | 854 | struct tas2562_priv *p_tas2562 = dev_get_drvdata(dev); |
891 | 855 | ||
892 | if (!p_tas2562) { | 856 | if (!p_tas2562) { |
893 | dev_err(p_tas2562->dev, "drvdata is NULL\n"); | 857 | pr_err("drvdata is NULL\n"); |
894 | return -EINVAL; | 858 | return -EINVAL; |
895 | } | 859 | } |
860 | |||
896 | mutex_lock(&p_tas2562->codec_lock); | 861 | mutex_lock(&p_tas2562->codec_lock); |
897 | tas2562_runtime_resume(p_tas2562); | 862 | tas2562_runtime_resume(p_tas2562); |
898 | mutex_unlock(&p_tas2562->codec_lock); | 863 | mutex_unlock(&p_tas2562->codec_lock); |
@@ -937,6 +902,7 @@ static int tas2562_parse_dt(struct device *dev, | |||
937 | p_tas2562->mn_r_addr); | 902 | p_tas2562->mn_r_addr); |
938 | } | 903 | } |
939 | } | 904 | } |
905 | |||
940 | p_tas2562->mn_reset_gpio = of_get_named_gpio(np, "ti,reset-gpio", 0); | 906 | p_tas2562->mn_reset_gpio = of_get_named_gpio(np, "ti,reset-gpio", 0); |
941 | if (!gpio_is_valid(p_tas2562->mn_reset_gpio)) { | 907 | if (!gpio_is_valid(p_tas2562->mn_reset_gpio)) { |
942 | dev_err(p_tas2562->dev, | 908 | dev_err(p_tas2562->dev, |
@@ -947,6 +913,7 @@ static int tas2562_parse_dt(struct device *dev, | |||
947 | dev_dbg(p_tas2562->dev, "ti,reset-gpio=%d", | 913 | dev_dbg(p_tas2562->dev, "ti,reset-gpio=%d", |
948 | p_tas2562->mn_reset_gpio); | 914 | p_tas2562->mn_reset_gpio); |
949 | } | 915 | } |
916 | |||
950 | if (p_tas2562->mn_channels != 1) { | 917 | if (p_tas2562->mn_channels != 1) { |
951 | p_tas2562->mn_reset_gpio2 | 918 | p_tas2562->mn_reset_gpio2 |
952 | = of_get_named_gpio(np, "ti,reset-gpio2", 0); | 919 | = of_get_named_gpio(np, "ti,reset-gpio2", 0); |
@@ -1141,7 +1108,6 @@ static int tas2562_i2c_probe(struct i2c_client *p_client, | |||
1141 | } | 1108 | } |
1142 | disable_irq_nosync(p_tas2562->mn_irq2); | 1109 | disable_irq_nosync(p_tas2562->mn_irq2); |
1143 | } | 1110 | } |
1144 | tas2562_enable_irq(p_tas2562, true); | ||
1145 | INIT_DELAYED_WORK(&p_tas2562->init_work, init_work_routine); | 1111 | INIT_DELAYED_WORK(&p_tas2562->init_work, init_work_routine); |
1146 | 1112 | ||
1147 | #ifdef CONFIG_TAS2562_CODEC | 1113 | #ifdef CONFIG_TAS2562_CODEC |
@@ -462,6 +462,15 @@ TAS2562_INTERRUPTCONFIGURATION_PININTCONFIG10_ASSERT2MSONLIVEINTERRUPTS \ | |||
462 | #define \ | 462 | #define \ |
463 | TAS2562_INTERRUPTCONFIGURATION_PININTCONFIG10_ASSERT2MSONLATCHEDINTERRUPTS \ | 463 | TAS2562_INTERRUPTCONFIGURATION_PININTCONFIG10_ASSERT2MSONLATCHEDINTERRUPTS \ |
464 | (0x3 << 0) | 464 | (0x3 << 0) |
465 | #define TAS2562_CLOCK_HALT_TIMER_MASK (0x7 << 3) | ||
466 | #define TAS2562_CLOCK_HALT_1MS (0x0 << 3) | ||
467 | #define TAS2562_CLOCK_HALT_3MS (0x1 << 3) | ||
468 | #define TAS2562_CLOCK_HALT_26MS (0x2 << 3) | ||
469 | #define TAS2562_CLOCK_HALT_52MS (0x3 << 3) | ||
470 | #define TAS2562_CLOCK_HALT_104MS (0x4 << 3) | ||
471 | #define TAS2562_CLOCK_HALT_209MS (0x5 << 3) | ||
472 | #define TAS2562_CLOCK_HALT_419MS (0x6 << 3) | ||
473 | #define TAS2562_CLOCK_HALT_838MS (0x7 << 3) | ||
465 | 474 | ||
466 | /* Digital Input Pin Pull Down */ | 475 | /* Digital Input Pin Pull Down */ |
467 | #define TAS2562_DIGITALINPUTPINPULLDOWN TAS2562_REG(0x0, 0x0, 0x31) | 476 | #define TAS2562_DIGITALINPUTPINPULLDOWN TAS2562_REG(0x0, 0x0, 0x31) |
diff --git a/tas25xx-algo.c b/tas25xx-algo.c index c58a6a0..d2ab108 100644 --- a/tas25xx-algo.c +++ b/tas25xx-algo.c | |||
@@ -250,6 +250,8 @@ bool tas25xx_set_iv_bit_fomat(int iv_data_with, int vbat, int update_now) | |||
250 | 250 | ||
251 | if ((vbat == 1) && (iv_data_with == 12)) { | 251 | if ((vbat == 1) && (iv_data_with == 12)) { |
252 | g_iv_vbat_fmt = IV_SENSE_FORMAT_12_BIT_WITH_8BIT_VBAT; | 252 | g_iv_vbat_fmt = IV_SENSE_FORMAT_12_BIT_WITH_8BIT_VBAT; |
253 | } else if ((vbat == 1) && (iv_data_with == 8)) { | ||
254 | g_iv_vbat_fmt = IV_SENSE_FORMAT_8_BIT_WITH_8BIT_VBAT; | ||
253 | } else { | 255 | } else { |
254 | g_iv_vbat_fmt = IV_SENSE_FORMAT_NO_VBAT; | 256 | g_iv_vbat_fmt = IV_SENSE_FORMAT_NO_VBAT; |
255 | } | 257 | } |