summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Li2017-02-16 16:41:48 -0600
committerPeter Li2017-02-16 16:41:48 -0600
commit069176132c5f5cb5df7dcbba37114460152128d9 (patch)
tree254160861861cc4c8a71ed4eef0f2787afbeb5b2
parent3f8c8cfd6a6574d0c4ab6f498b8aaa355f493a04 (diff)
downloadtas2555-android-driver-069176132c5f5cb5df7dcbba37114460152128d9.tar.gz
tas2555-android-driver-069176132c5f5cb5df7dcbba37114460152128d9.tar.xz
tas2555-android-driver-069176132c5f5cb5df7dcbba37114460152128d9.zip
update for disable clock error detection
-rwxr-xr-xtas2555-codec.c92
-rwxr-xr-xtas2555-core.c41
-rwxr-xr-xtas2555-core.h16
-rwxr-xr-xtas2555-regmap.c4
-rwxr-xr-xtas2555.h8
5 files changed, 67 insertions, 94 deletions
diff --git a/tas2555-codec.c b/tas2555-codec.c
index 92dcbc5..a6d36e2 100755
--- a/tas2555-codec.c
+++ b/tas2555-codec.c
@@ -68,10 +68,7 @@ static unsigned int tas2555_codec_read(struct snd_soc_codec *pCodec,
68 int ret = 0; 68 int ret = 0;
69 unsigned int Value = 0; 69 unsigned int Value = 0;
70 70
71 mutex_lock(&pTAS2555->codec_lock);
72 ret = pTAS2555->read(pTAS2555, nRegister, &Value); 71 ret = pTAS2555->read(pTAS2555, nRegister, &Value);
73 mutex_unlock(&pTAS2555->codec_lock);
74
75 if (ret < 0) { 72 if (ret < 0) {
76 dev_err(pTAS2555->dev, "%s, %d, ERROR happen=%d\n", __FUNCTION__, 73 dev_err(pTAS2555->dev, "%s, %d, ERROR happen=%d\n", __FUNCTION__,
77 __LINE__, ret); 74 __LINE__, ret);
@@ -85,10 +82,9 @@ static int tas2555_codec_write(struct snd_soc_codec *pCodec, unsigned int nRegis
85{ 82{
86 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(pCodec); 83 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(pCodec);
87 int ret = 0; 84 int ret = 0;
88 mutex_lock(&pTAS2555->codec_lock); 85
89 ret = pTAS2555->write(pTAS2555, nRegister, nValue); 86 ret = pTAS2555->write(pTAS2555, nRegister, nValue);
90 mutex_unlock(&pTAS2555->codec_lock); 87
91
92 return ret; 88 return ret;
93} 89}
94 90
@@ -140,12 +136,10 @@ static int tas2555_mute(struct snd_soc_dai *dai, int mute)
140{ 136{
141 struct snd_soc_codec *codec = dai->codec; 137 struct snd_soc_codec *codec = dai->codec;
142 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 138 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
143 139
144 dev_dbg(pTAS2555->dev, "%s\n", __func__); 140 dev_dbg(pTAS2555->dev, "%s\n", __func__);
145 mutex_lock(&pTAS2555->codec_lock);
146 tas2555_enable(pTAS2555, !mute); 141 tas2555_enable(pTAS2555, !mute);
147 mutex_unlock(&pTAS2555->codec_lock); 142
148
149 return 0; 143 return 0;
150} 144}
151 145
@@ -167,10 +161,8 @@ static int tas2555_hw_params(struct snd_pcm_substream *pSubstream,
167 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(pCodec); 161 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(pCodec);
168 162
169 dev_dbg(pCodec->dev, "%s\n", __func__); 163 dev_dbg(pCodec->dev, "%s\n", __func__);
170 164
171 mutex_lock(&pTAS2555->codec_lock);
172 tas2555_set_sampling_rate(pTAS2555, params_rate(pParams)); 165 tas2555_set_sampling_rate(pTAS2555, params_rate(pParams));
173 mutex_unlock(&pTAS2555->codec_lock);
174 166
175 return 0; 167 return 0;
176} 168}
@@ -179,9 +171,9 @@ static int tas2555_set_dai_fmt(struct snd_soc_dai *pDAI, unsigned int nFormat)
179{ 171{
180 struct snd_soc_codec *codec = pDAI->codec; 172 struct snd_soc_codec *codec = pDAI->codec;
181 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 173 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
182 174
183 dev_dbg(pTAS2555->dev, "%s\n", __func__); 175 dev_dbg(pTAS2555->dev, "%s\n", __func__);
184 176
185 return 0; 177 return 0;
186} 178}
187 179
@@ -190,9 +182,9 @@ static int tas2555_prepare(struct snd_pcm_substream *pSubstream,
190{ 182{
191 struct snd_soc_codec *codec = pDAI->codec; 183 struct snd_soc_codec *codec = pDAI->codec;
192 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 184 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
193 185
194 dev_dbg(pTAS2555->dev, "%s\n", __func__); 186 dev_dbg(pTAS2555->dev, "%s\n", __func__);
195 187
196 return 0; 188 return 0;
197} 189}
198 190
@@ -200,7 +192,7 @@ static int tas2555_set_bias_level(struct snd_soc_codec *pCodec,
200 enum snd_soc_bias_level eLevel) 192 enum snd_soc_bias_level eLevel)
201{ 193{
202 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(pCodec); 194 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(pCodec);
203 195
204 dev_dbg(pTAS2555->dev, "%s: %d\n", __func__, eLevel); 196 dev_dbg(pTAS2555->dev, "%s: %d\n", __func__, eLevel);
205 197
206 return 0; 198 return 0;
@@ -272,8 +264,6 @@ static int tas2555_get_reg_value(struct snd_kcontrol *pKcontrol,
272 unsigned int reg; 264 unsigned int reg;
273 unsigned int nValue; 265 unsigned int nValue;
274 266
275 mutex_lock(&pTAS2555->codec_lock);
276
277 if (TAS2555_REG_IS_VALID(register_addr.book, 267 if (TAS2555_REG_IS_VALID(register_addr.book,
278 register_addr.page, register_addr.reg)) { 268 register_addr.page, register_addr.reg)) {
279 reg = TAS2555_REG((unsigned int) register_addr.book, 269 reg = TAS2555_REG((unsigned int) register_addr.book,
@@ -289,8 +279,7 @@ static int tas2555_get_reg_value(struct snd_kcontrol *pKcontrol,
289 dev_dbg(pTAS2555->dev, "%s: Read [%d, %d, %d] = %ld\n", __func__, 279 dev_dbg(pTAS2555->dev, "%s: Read [%d, %d, %d] = %ld\n", __func__,
290 register_addr.book, register_addr.page, register_addr.reg, 280 register_addr.book, register_addr.page, register_addr.reg,
291 pUcontrol->value.integer.value[0]); 281 pUcontrol->value.integer.value[0]);
292 282
293 mutex_unlock(&pTAS2555->codec_lock);
294 return 0; 283 return 0;
295} 284}
296 285
@@ -305,8 +294,6 @@ static int tas2555_put_reg_value(struct snd_kcontrol *pKcontrol,
305 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 294 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
306 unsigned int reg; 295 unsigned int reg;
307 296
308 mutex_lock(&pTAS2555->codec_lock);
309
310 if (TAS2555_REG_IS_VALID(register_addr.book, 297 if (TAS2555_REG_IS_VALID(register_addr.book,
311 register_addr.page, register_addr.reg)) { 298 register_addr.page, register_addr.reg)) {
312 reg = TAS2555_REG((unsigned int) register_addr.book, 299 reg = TAS2555_REG((unsigned int) register_addr.book,
@@ -321,7 +308,6 @@ static int tas2555_put_reg_value(struct snd_kcontrol *pKcontrol,
321 register_addr.book, register_addr.page, register_addr.reg, 308 register_addr.book, register_addr.page, register_addr.reg,
322 pUcontrol->value.integer.value[0]); 309 pUcontrol->value.integer.value[0]);
323 310
324 mutex_unlock(&pTAS2555->codec_lock);
325 return 0; 311 return 0;
326} 312}
327 313
@@ -335,13 +321,10 @@ static int tas2555_power_ctrl_get(struct snd_kcontrol *pKcontrol,
335#endif 321#endif
336 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 322 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
337 323
338 mutex_lock(&pTAS2555->codec_lock);
339
340 pValue->value.integer.value[0] = pTAS2555->mnPowerCtrl; 324 pValue->value.integer.value[0] = pTAS2555->mnPowerCtrl;
341 dev_dbg(pTAS2555->dev, "tas2555_power_ctrl_get = %d\n", 325 dev_dbg(pTAS2555->dev, "tas2555_power_ctrl_get = %d\n",
342 pTAS2555->mnPowerCtrl); 326 pTAS2555->mnPowerCtrl);
343 327
344 mutex_unlock(&pTAS2555->codec_lock);
345 return 0; 328 return 0;
346} 329}
347 330
@@ -355,7 +338,6 @@ static int tas2555_power_ctrl_put(struct snd_kcontrol *pKcontrol,
355#endif 338#endif
356 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 339 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
357 340
358 mutex_lock(&pTAS2555->codec_lock);
359 pTAS2555->mnPowerCtrl = pValue->value.integer.value[0]; 341 pTAS2555->mnPowerCtrl = pValue->value.integer.value[0];
360 342
361 dev_dbg(pTAS2555->dev, "tas2555_power_ctrl_put = %d\n", 343 dev_dbg(pTAS2555->dev, "tas2555_power_ctrl_put = %d\n",
@@ -365,8 +347,7 @@ static int tas2555_power_ctrl_put(struct snd_kcontrol *pKcontrol,
365 tas2555_enable(pTAS2555, true); 347 tas2555_enable(pTAS2555, true);
366 if (pTAS2555->mnPowerCtrl == 0) 348 if (pTAS2555->mnPowerCtrl == 0)
367 tas2555_enable(pTAS2555, false); 349 tas2555_enable(pTAS2555, false);
368 350
369 mutex_unlock(&pTAS2555->codec_lock);
370 return 0; 351 return 0;
371} 352}
372 353
@@ -379,18 +360,13 @@ static int tas2555_fs_get(struct snd_kcontrol *pKcontrol,
379 struct snd_soc_codec *codec = snd_kcontrol_chip(pKcontrol); 360 struct snd_soc_codec *codec = snd_kcontrol_chip(pKcontrol);
380#endif 361#endif
381 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 362 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
382
383 int nFS = 48000; 363 int nFS = 48000;
384 364
385 mutex_lock(&pTAS2555->codec_lock);
386
387 if (pTAS2555->mpFirmware->mnConfigurations) 365 if (pTAS2555->mpFirmware->mnConfigurations)
388 nFS = pTAS2555->mpFirmware->mpConfigurations[pTAS2555->mnCurrentConfiguration].mnSamplingRate; 366 nFS = pTAS2555->mpFirmware->mpConfigurations[pTAS2555->mnCurrentConfiguration].mnSamplingRate;
389 367
390 pValue->value.integer.value[0] = nFS; 368 pValue->value.integer.value[0] = nFS;
391 369
392 mutex_unlock(&pTAS2555->codec_lock);
393
394 dev_dbg(pTAS2555->dev, "tas2555_fs_get = %d\n", nFS); 370 dev_dbg(pTAS2555->dev, "tas2555_fs_get = %d\n", nFS);
395 return 0; 371 return 0;
396} 372}
@@ -406,13 +382,11 @@ static int tas2555_fs_put(struct snd_kcontrol *pKcontrol,
406 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 382 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
407 int ret = 0; 383 int ret = 0;
408 int nFS = pValue->value.integer.value[0]; 384 int nFS = pValue->value.integer.value[0];
409 385
410 dev_info(pTAS2555->dev, "tas2555_fs_put = %d\n", nFS); 386 dev_info(pTAS2555->dev, "tas2555_fs_put = %d\n", nFS);
411 387
412 mutex_lock(&pTAS2555->codec_lock);
413 ret = tas2555_set_sampling_rate(pTAS2555, nFS); 388 ret = tas2555_set_sampling_rate(pTAS2555, nFS);
414 389
415 mutex_unlock(&pTAS2555->codec_lock);
416 return ret; 390 return ret;
417} 391}
418 392
@@ -425,10 +399,8 @@ static int tas2555_nRe_get(struct snd_kcontrol *pKcontrol,
425 struct snd_soc_codec *codec = snd_kcontrol_chip(pKcontrol); 399 struct snd_soc_codec *codec = snd_kcontrol_chip(pKcontrol);
426#endif 400#endif
427 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 401 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
428 unsigned int nRe; 402 unsigned int nRe = 0;
429 int ret; 403 int ret = 0;
430
431 mutex_lock(&pTAS2555->codec_lock);
432 404
433 if ((pTAS2555->mpFirmware->mnConfigurations > 0) && pTAS2555->mbPowerUp) { 405 if ((pTAS2555->mpFirmware->mnConfigurations > 0) && pTAS2555->mbPowerUp) {
434 ret = tas2555_get_Re(pTAS2555, &nRe); 406 ret = tas2555_get_Re(pTAS2555, &nRe);
@@ -438,8 +410,6 @@ static int tas2555_nRe_get(struct snd_kcontrol *pKcontrol,
438 pValue->value.integer.value[0] = 0; 410 pValue->value.integer.value[0] = 0;
439 } 411 }
440 412
441 mutex_unlock(&pTAS2555->codec_lock);
442
443 dev_dbg(pTAS2555->dev, "tas2555_nRe_get = %d\n", nRe); 413 dev_dbg(pTAS2555->dev, "tas2555_nRe_get = %d\n", nRe);
444 return 0; 414 return 0;
445} 415}
@@ -456,14 +426,10 @@ static int tas2555_errcode_get(struct snd_kcontrol *pKcontrol,
456 unsigned int errCode = 0; 426 unsigned int errCode = 0;
457 int nResult; 427 int nResult;
458 428
459 mutex_lock(&pTAS2555->codec_lock);
460
461 nResult = tas2555_get_errcode(pTAS2555, &errCode); 429 nResult = tas2555_get_errcode(pTAS2555, &errCode);
462 if (nResult >= 0) 430 if (nResult >= 0)
463 pValue->value.integer.value[0] = errCode; 431 pValue->value.integer.value[0] = errCode;
464 432
465 mutex_unlock(&pTAS2555->codec_lock);
466
467 dev_dbg(pTAS2555->dev, "tas2555_errcode_get = 0x%x\n", errCode); 433 dev_dbg(pTAS2555->dev, "tas2555_errcode_get = 0x%x\n", errCode);
468 return 0; 434 return 0;
469} 435}
@@ -477,11 +443,10 @@ static int tas2555_program_get(struct snd_kcontrol *pKcontrol,
477 struct snd_soc_codec *codec = snd_kcontrol_chip(pKcontrol); 443 struct snd_soc_codec *codec = snd_kcontrol_chip(pKcontrol);
478#endif 444#endif
479 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 445 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
480 mutex_lock(&pTAS2555->codec_lock); 446
481 pValue->value.integer.value[0] = pTAS2555->mnCurrentProgram; 447 pValue->value.integer.value[0] = pTAS2555->mnCurrentProgram;
482 dev_dbg(pTAS2555->dev, "tas2555_program_get = %d\n", 448 dev_dbg(pTAS2555->dev, "tas2555_program_get = %d\n",
483 pTAS2555->mnCurrentProgram); 449 pTAS2555->mnCurrentProgram);
484 mutex_unlock(&pTAS2555->codec_lock);
485 return 0; 450 return 0;
486} 451}
487 452
@@ -496,9 +461,8 @@ static int tas2555_program_put(struct snd_kcontrol *pKcontrol,
496 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 461 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
497 unsigned int nProgram = pValue->value.integer.value[0]; 462 unsigned int nProgram = pValue->value.integer.value[0];
498 int ret = 0; 463 int ret = 0;
499 mutex_lock(&pTAS2555->codec_lock); 464
500 ret = tas2555_set_program(pTAS2555, nProgram, -1); 465 ret = tas2555_set_program(pTAS2555, nProgram, -1);
501 mutex_unlock(&pTAS2555->codec_lock);
502 return ret; 466 return ret;
503} 467}
504 468
@@ -512,11 +476,9 @@ static int tas2555_configuration_get(struct snd_kcontrol *pKcontrol,
512#endif 476#endif
513 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 477 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
514 478
515 mutex_lock(&pTAS2555->codec_lock);
516 pValue->value.integer.value[0] = pTAS2555->mnCurrentConfiguration; 479 pValue->value.integer.value[0] = pTAS2555->mnCurrentConfiguration;
517 dev_dbg(pTAS2555->dev, "tas2555_configuration_get = %d\n", 480 dev_dbg(pTAS2555->dev, "tas2555_configuration_get = %d\n",
518 pTAS2555->mnCurrentConfiguration); 481 pTAS2555->mnCurrentConfiguration);
519 mutex_unlock(&pTAS2555->codec_lock);
520 return 0; 482 return 0;
521} 483}
522 484
@@ -532,9 +494,7 @@ static int tas2555_configuration_put(struct snd_kcontrol *pKcontrol,
532 unsigned int nConfiguration = pValue->value.integer.value[0]; 494 unsigned int nConfiguration = pValue->value.integer.value[0];
533 int ret = 0; 495 int ret = 0;
534 496
535 mutex_lock(&pTAS2555->codec_lock);
536 ret = tas2555_set_config(pTAS2555, nConfiguration); 497 ret = tas2555_set_config(pTAS2555, nConfiguration);
537 mutex_unlock(&pTAS2555->codec_lock);
538 return ret; 498 return ret;
539} 499}
540 500
@@ -548,12 +508,10 @@ static int tas2555_calibration_get(struct snd_kcontrol *pKcontrol,
548#endif 508#endif
549 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec); 509 struct tas2555_priv *pTAS2555 = snd_soc_codec_get_drvdata(codec);
550 510
551 mutex_lock(&pTAS2555->codec_lock);
552 pValue->value.integer.value[0] = pTAS2555->mnCurrentCalibration; 511 pValue->value.integer.value[0] = pTAS2555->mnCurrentCalibration;
553 dev_info(pTAS2555->dev, 512 dev_info(pTAS2555->dev,
554 "tas2555_calibration_get = %d\n", 513 "tas2555_calibration_get = %d\n",
555 pTAS2555->mnCurrentCalibration); 514 pTAS2555->mnCurrentCalibration);
556 mutex_unlock(&pTAS2555->codec_lock);
557 return 0; 515 return 0;
558} 516}
559 517
@@ -569,9 +527,7 @@ static int tas2555_calibration_put(struct snd_kcontrol *pKcontrol,
569 unsigned int nCalibration = pValue->value.integer.value[0]; 527 unsigned int nCalibration = pValue->value.integer.value[0];
570 int ret = 0; 528 int ret = 0;
571 529
572 mutex_lock(&pTAS2555->codec_lock);
573 ret = tas2555_set_calibration(pTAS2555, nCalibration); 530 ret = tas2555_set_calibration(pTAS2555, nCalibration);
574 mutex_unlock(&pTAS2555->codec_lock);
575 531
576 return ret; 532 return ret;
577} 533}
@@ -717,14 +673,14 @@ int tas2555_register_codec(struct tas2555_priv *pTAS2555)
717 nResult = snd_soc_register_codec(pTAS2555->dev, 673 nResult = snd_soc_register_codec(pTAS2555->dev,
718 &soc_codec_driver_tas2555, 674 &soc_codec_driver_tas2555,
719 tas2555_dai_driver, ARRAY_SIZE(tas2555_dai_driver)); 675 tas2555_dai_driver, ARRAY_SIZE(tas2555_dai_driver));
720 676
721 return nResult; 677 return nResult;
722} 678}
723 679
724int tas2555_deregister_codec(struct tas2555_priv *pTAS2555) 680int tas2555_deregister_codec(struct tas2555_priv *pTAS2555)
725{ 681{
726 snd_soc_unregister_codec(pTAS2555->dev); 682 snd_soc_unregister_codec(pTAS2555->dev);
727 683
728 return 0; 684 return 0;
729} 685}
730 686
diff --git a/tas2555-core.c b/tas2555-core.c
index 541e01e..9bb1e35 100755
--- a/tas2555-core.c
+++ b/tas2555-core.c
@@ -108,6 +108,8 @@ static unsigned int p_tas2555_default_data[] = {
108 108
109static unsigned int p_tas2555_irq_config[] = { 109static unsigned int p_tas2555_irq_config[] = {
110 /* TAS2555_GPIO4_PIN_REG, 0x07, set GPIO4 as int1, default */ 110 /* TAS2555_GPIO4_PIN_REG, 0x07, set GPIO4 as int1, default */
111// TAS2555_CLK_ERR_CTRL2, 0x11, //enable clock error detection on PLL
112// TAS2555_CLK_ERR_CTRL3, 0x11, //enable clock error detection on PLL
111 TAS2555_INT_GEN1_REG, 0x11, /* enable spk OC and OV */ 113 TAS2555_INT_GEN1_REG, 0x11, /* enable spk OC and OV */
112 TAS2555_INT_GEN2_REG, 0x11, /* enable clk err1 and die OT */ 114 TAS2555_INT_GEN2_REG, 0x11, /* enable clk err1 and die OT */
113 TAS2555_INT_GEN3_REG, 0x11, /* enable clk err2 and brownout */ 115 TAS2555_INT_GEN3_REG, 0x11, /* enable clk err2 and brownout */
@@ -118,7 +120,7 @@ static unsigned int p_tas2555_irq_config[] = {
118 120
119#define TAS2555_STARTUP_DATA_PLL_CLKIN_INDEX 3 121#define TAS2555_STARTUP_DATA_PLL_CLKIN_INDEX 3
120static unsigned int p_tas2555_startup_data[] = { 122static unsigned int p_tas2555_startup_data[] = {
121 TAS2555_CLK_ERR_CTRL, 0x0b, //enable clock error detection on PLL 123 TAS2555_CLK_ERR_CTRL1, 0x00, //disable clock error detection on PLL
122 TAS2555_PLL_CLKIN_REG, TAS2555_DEFAULT_PLL_CLKIN, 124 TAS2555_PLL_CLKIN_REG, TAS2555_DEFAULT_PLL_CLKIN,
123 TAS2555_POWER_CTRL2_REG, 0xA0, //Class-D, Boost power up 125 TAS2555_POWER_CTRL2_REG, 0xA0, //Class-D, Boost power up
124 TAS2555_POWER_CTRL2_REG, 0xA3, //Class-D, Boost, IV sense power up 126 TAS2555_POWER_CTRL2_REG, 0xA3, //Class-D, Boost, IV sense power up
@@ -134,6 +136,7 @@ static unsigned int p_tas2555_unmute_data[] = {
134}; 136};
135 137
136static unsigned int p_tas2555_shutdown_data[] = { 138static unsigned int p_tas2555_shutdown_data[] = {
139 TAS2555_CLK_ERR_CTRL1, 0x00, //disable clock error detection
137 TAS2555_SOFT_MUTE_REG, 0x01, //soft mute 140 TAS2555_SOFT_MUTE_REG, 0x01, //soft mute
138 TAS2555_UDELAY, 10000, //delay 10ms 141 TAS2555_UDELAY, 10000, //delay 10ms
139 TAS2555_MUTE_REG, 0x03, //mute 142 TAS2555_MUTE_REG, 0x03, //mute
@@ -153,6 +156,7 @@ static unsigned int p_tas2555_shutdown_clk_err[] = {
153#endif 156#endif
154 157
155static unsigned int p_tas2555_mute_DSP_down_data[] = { 158static unsigned int p_tas2555_mute_DSP_down_data[] = {
159 TAS2555_CLK_ERR_CTRL1, 0x00, //disable clock error detection
156 TAS2555_MUTE_REG, 0x03, //mute 160 TAS2555_MUTE_REG, 0x03, //mute
157 TAS2555_PLL_CLKIN_REG, 0x0F, //PLL clock input = osc 161 TAS2555_PLL_CLKIN_REG, 0x0F, //PLL clock input = osc
158 TAS2555_POWER_CTRL1_REG, 0x60, //DSP power down 162 TAS2555_POWER_CTRL1_REG, 0x60, //DSP power down
@@ -239,14 +243,16 @@ static void failsafe(struct tas2555_priv *pTAS2555)
239{ 243{
240 dev_err(pTAS2555->dev, "%s\n", __func__); 244 dev_err(pTAS2555->dev, "%s\n", __func__);
241 pTAS2555->mnErrorCode |= TAS2555_ERROR_FAILSAFE; 245 pTAS2555->mnErrorCode |= TAS2555_ERROR_FAILSAFE;
242 tas2555_enable(pTAS2555, false); 246 dev_dbg(pTAS2555->dev, "Enable: load shutdown sequence\n");
247 tas2555_dev_load_data(pTAS2555, p_tas2555_shutdown_data);
248 //tas2555_dev_load_data(pTAS2555, p_tas2555_shutdown_clk_err);
249 if (pTAS2555->mpFirmware != NULL)
250 tas2555_clear_firmware(pTAS2555->mpFirmware);
251 pTAS2555->mbPowerUp = false;
243 pTAS2555->hw_reset(pTAS2555); 252 pTAS2555->hw_reset(pTAS2555);
244 pTAS2555->write(pTAS2555, TAS2555_SW_RESET_REG, 0x01); 253 pTAS2555->write(pTAS2555, TAS2555_SW_RESET_REG, 0x01);
245 udelay(1000); 254 udelay(1000);
246 pTAS2555->write(pTAS2555, TAS2555_SPK_CTRL_REG, 0x04); 255 pTAS2555->write(pTAS2555, TAS2555_SPK_CTRL_REG, 0x04);
247 if(pTAS2555->mpFirmware != NULL){
248 tas2555_clear_firmware(pTAS2555->mpFirmware);
249 }
250} 256}
251 257
252#define Q_FACTOR 0x08000000 258#define Q_FACTOR 0x08000000
@@ -257,10 +263,15 @@ static bool chkReBoundary(struct tas2555_priv *pTAS2555,
257 bool nResult = false; 263 bool nResult = false;
258 unsigned int ReHigh_calc, ReLow_calc, Re_calc = 0; 264 unsigned int ReHigh_calc, ReLow_calc, Re_calc = 0;
259 static unsigned int counter = 3; 265 static unsigned int counter = 3;
260 266
261 if (ReOrginal < Q_FACTOR) 267 if (ReOrginal < Q_FACTOR)
262 goto end; 268 goto end;
263 269
270 if (ReDelta == 0) {
271 dev_err(pTAS2555->dev, "need to set ReDelta!");
272 goto end;
273 }
274
264 switch (scale) { 275 switch (scale) {
265 case 0: 276 case 0:
266 /* 8Ohm speaker */ 277 /* 8Ohm speaker */
@@ -302,7 +313,8 @@ static bool chkReBoundary(struct tas2555_priv *pTAS2555,
302 counter = 3; 313 counter = 3;
303 314
304 if (counter == 0) { 315 if (counter == 0) {
305 counter = 3; 316 dev_err(pTAS2555->dev, "will failsafe, OrigRe=%d, Delta_Re=%d, Re=%d, scale=%d\n",
317 ReOrginal, ReDelta, Re, scale);
306 nResult = true; 318 nResult = true;
307 } 319 }
308 } 320 }
@@ -373,7 +385,7 @@ int tas2555_get_errcode(struct tas2555_priv *pTAS2555, unsigned int *pErrCode)
373 385
374 if (nValue & 0x04) { 386 if (nValue & 0x04) {
375 errcode |= TAS2555_ERROR_CLKPRESENT; 387 errcode |= TAS2555_ERROR_CLKPRESENT;
376 nResult = pTAS2555->write(pTAS2555, TAS2555_CLK_ERR_CTRL, 0x00); 388 nResult = pTAS2555->write(pTAS2555, TAS2555_CLK_ERR_CTRL1, 0x00);
377 } 389 }
378 if (nValue & 0x08) 390 if (nValue & 0x08)
379 errcode |= TAS2555_ERROR_BROWNOUT; 391 errcode |= TAS2555_ERROR_BROWNOUT;
@@ -423,8 +435,15 @@ int tas2555_load_default(struct tas2555_priv *pTAS2555)
423int tas2555_enable(struct tas2555_priv *pTAS2555, bool bEnable) 435int tas2555_enable(struct tas2555_priv *pTAS2555, bool bEnable)
424{ 436{
425 int nResult = 0; 437 int nResult = 0;
426 438
427 dev_dbg(pTAS2555->dev, "Enable: %d\n", bEnable); 439 dev_dbg(pTAS2555->dev, "Enable: %d\n", bEnable);
440
441 if ((pTAS2555->mpFirmware->mnPrograms == 0)
442 ||(pTAS2555->mpFirmware->mnConfigurations == 0)) {
443 pTAS2555->mnErrorCode |= TAS2555_ERROR_FWNOTLOAD;
444 goto end;
445 }
446
428 if (bEnable) { 447 if (bEnable) {
429 if (!pTAS2555->mbPowerUp) { 448 if (!pTAS2555->mbPowerUp) {
430 TConfiguration *pConfiguration; 449 TConfiguration *pConfiguration;
@@ -1775,8 +1794,10 @@ int tas2555_set_calibration(struct tas2555_priv *pTAS2555,
1775 if(pTAS2555->mbPowerUp){ 1794 if(pTAS2555->mbPowerUp){
1776 nResult = tas2555_load_block(pTAS2555, 1795 nResult = tas2555_load_block(pTAS2555,
1777 &(pTAS2555->mpCalFirmware->mpCalibrations[pTAS2555->mnCurrentCalibration].mBlock)); 1796 &(pTAS2555->mpCalFirmware->mpCalibrations[pTAS2555->mnCurrentCalibration].mBlock));
1778 if (nResult >= 0) 1797 if (nResult >= 0) {
1779 pTAS2555->mbLoadCalibrationPostPowerUp = false; 1798 pTAS2555->mbLoadCalibrationPostPowerUp = false;
1799 nResult = tas2555_get_ReCoefficient(pTAS2555, &pTAS2555->mnReOrignal);
1800 }
1780 }else{ 1801 }else{
1781 pTAS2555->mbLoadCalibrationPostPowerUp = true; 1802 pTAS2555->mbLoadCalibrationPostPowerUp = true;
1782 } 1803 }
diff --git a/tas2555-core.h b/tas2555-core.h
index d8779bd..bbf5559 100755
--- a/tas2555-core.h
+++ b/tas2555-core.h
@@ -28,19 +28,19 @@
28 28
29#include "tas2555.h" 29#include "tas2555.h"
30 30
31#define TAS2555_YRAM_BOOK 140 31#define TAS2555_YRAM_BOOK 140 /* BOOK: 0x8c */
32#define TAS2555_YRAM1_PAGE 42 32#define TAS2555_YRAM1_PAGE 42 /* Page: 0x2a */
33#define TAS2555_YRAM1_START_REG 88 33#define TAS2555_YRAM1_START_REG 88 /* Reg: 0x58 */
34#define TAS2555_YRAM1_END_REG 127 34#define TAS2555_YRAM1_END_REG 127 /* Reg: 0x7f */
35 35
36#define TAS2555_YRAM2_START_PAGE 43 36#define TAS2555_YRAM2_START_PAGE 43 /* Page: 0x2b */
37#define TAS2555_YRAM2_END_PAGE 52 37#define TAS2555_YRAM2_END_PAGE 52 /* Page: 0x34 */
38#define TAS2555_YRAM2_START_REG 8 38#define TAS2555_YRAM2_START_REG 8
39#define TAS2555_YRAM2_END_REG 127 39#define TAS2555_YRAM2_END_REG 127
40 40
41#define TAS2555_YRAM3_PAGE 53 41#define TAS2555_YRAM3_PAGE 53 /* Page: 0x35 */
42#define TAS2555_YRAM3_START_REG 8 42#define TAS2555_YRAM3_START_REG 8
43#define TAS2555_YRAM3_END_REG 55 43#define TAS2555_YRAM3_END_REG 55 /* Reg: 0x37 */
44 44
45typedef struct { 45typedef struct {
46 unsigned char mnOffset; 46 unsigned char mnOffset;
diff --git a/tas2555-regmap.c b/tas2555-regmap.c
index 6a857b2..47a6cc7 100755
--- a/tas2555-regmap.c
+++ b/tas2555-regmap.c
@@ -335,7 +335,7 @@ static void irq_work_routine(struct work_struct *work)
335 dev_err(pTAS2555->dev, "critical error INT Status: 0x%x\n", nDevInt1Status); 335 dev_err(pTAS2555->dev, "critical error INT Status: 0x%x\n", nDevInt1Status);
336 if (nDevInt1Status & 0x04) { 336 if (nDevInt1Status & 0x04) {
337 pTAS2555->mnErrorCode |= TAS2555_ERROR_CLKPRESENT; 337 pTAS2555->mnErrorCode |= TAS2555_ERROR_CLKPRESENT;
338 nResult = pTAS2555->write(pTAS2555, TAS2555_CLK_ERR_CTRL, 0x00); 338 nResult = pTAS2555->write(pTAS2555, TAS2555_CLK_ERR_CTRL1, 0x00);
339 } 339 }
340 if (nDevInt1Status & 0x08) 340 if (nDevInt1Status & 0x08)
341 pTAS2555->mnErrorCode |= TAS2555_ERROR_BROWNOUT; 341 pTAS2555->mnErrorCode |= TAS2555_ERROR_BROWNOUT;
@@ -483,7 +483,6 @@ static int tas2555_i2c_probe(struct i2c_client *pClient,
483 pTAS2555->mbTILoadActive = false; 483 pTAS2555->mbTILoadActive = false;
484 484
485#ifdef CONFIG_TAS2555_CODEC 485#ifdef CONFIG_TAS2555_CODEC
486 mutex_init(&pTAS2555->codec_lock);
487 tas2555_register_codec(pTAS2555); 486 tas2555_register_codec(pTAS2555);
488#endif 487#endif
489 488
@@ -512,7 +511,6 @@ static int tas2555_i2c_remove(struct i2c_client *pClient)
512 511
513#ifdef CONFIG_TAS2555_CODEC 512#ifdef CONFIG_TAS2555_CODEC
514 tas2555_deregister_codec(pTAS2555); 513 tas2555_deregister_codec(pTAS2555);
515 mutex_destroy(&pTAS2555->codec_lock);
516#endif 514#endif
517 515
518#ifdef CONFIG_TAS2555_MISC 516#ifdef CONFIG_TAS2555_MISC
diff --git a/tas2555.h b/tas2555.h
index 7c1a920..904cd07 100755
--- a/tas2555.h
+++ b/tas2555.h
@@ -68,7 +68,9 @@
68#define TAS2555_CRC_RESET_REG TAS2555_REG(0, 0, 33) 68#define TAS2555_CRC_RESET_REG TAS2555_REG(0, 0, 33)
69#define TAS2555_DSP_MODE_SELECT_REG TAS2555_REG(0, 0, 34) 69#define TAS2555_DSP_MODE_SELECT_REG TAS2555_REG(0, 0, 34)
70#define TAS2555_NONAME42_REG TAS2555_REG(0, 0, 42) 70#define TAS2555_NONAME42_REG TAS2555_REG(0, 0, 42)
71#define TAS2555_CLK_ERR_CTRL TAS2555_REG(0, 0, 44) 71#define TAS2555_CLK_ERR_CTRL1 TAS2555_REG(0, 0, 44)
72#define TAS2555_CLK_ERR_CTRL2 TAS2555_REG(0, 0, 45)
73#define TAS2555_CLK_ERR_CTRL3 TAS2555_REG(0, 0, 46)
72#define TAS2555_POWER_UP_FLAG_REG TAS2555_REG(0, 0, 100) 74#define TAS2555_POWER_UP_FLAG_REG TAS2555_REG(0, 0, 100)
73#define TAS2555_FLAGS_1 TAS2555_REG(0, 0, 104) /* B0_P0_R0x68*/ 75#define TAS2555_FLAGS_1 TAS2555_REG(0, 0, 104) /* B0_P0_R0x68*/
74#define TAS2555_FLAGS_2 TAS2555_REG(0, 0, 108) /* B0_P0_R0x6c*/ 76#define TAS2555_FLAGS_2 TAS2555_REG(0, 0, 108) /* B0_P0_R0x6c*/
@@ -418,10 +420,6 @@ struct tas2555_priv {
418 int (*set_config)(struct tas2555_priv *pTAS2555, int config); 420 int (*set_config)(struct tas2555_priv *pTAS2555, int config);
419 int (*set_calibration)(struct tas2555_priv *pTAS2555, int calibration); 421 int (*set_calibration)(struct tas2555_priv *pTAS2555, int calibration);
420 422
421#ifdef CONFIG_TAS2555_CODEC
422 struct mutex codec_lock;
423#endif
424
425#ifdef CONFIG_TAS2555_MISC 423#ifdef CONFIG_TAS2555_MISC
426 int mnDBGCmd; 424 int mnDBGCmd;
427 int mnCurrentReg; 425 int mnCurrentReg;