AudDrv_Ana.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright (C) 2007 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*******************************************************************************
  17. *
  18. * Filename:
  19. * ---------
  20. * AudDrv_Ana.c
  21. *
  22. * Project:
  23. * --------
  24. * MT6583 Audio Driver ana Register setting
  25. *
  26. * Description:
  27. * ------------
  28. * Audio register
  29. *
  30. * Author:
  31. * -------
  32. * Chipeng Chang
  33. *
  34. *------------------------------------------------------------------------------
  35. *
  36. *
  37. *******************************************************************************/
  38. /*****************************************************************************
  39. * C O M P I L E R F L A G S
  40. *****************************************************************************/
  41. /*****************************************************************************
  42. * E X T E R N A L R E F E R E N C E S
  43. *****************************************************************************/
  44. #include "AudDrv_Common.h"
  45. #include "AudDrv_Ana.h"
  46. #include "AudDrv_Clk.h"
  47. /* define this to use wrapper to control */
  48. #ifndef CONFIG_MTK_FPGA
  49. #define AUDIO_USING_WRAP_DRIVER
  50. #endif
  51. #ifdef AUDIO_USING_WRAP_DRIVER
  52. #include <mach/mt_pmic_wrap.h>
  53. #endif
  54. static DEFINE_SPINLOCK(ana_set_reg_lock);
  55. /*****************************************************************************
  56. * D A T A T Y P E S
  57. *****************************************************************************/
  58. void Ana_Set_Reg(uint32 offset, uint32 value, uint32 mask)
  59. {
  60. /* set pmic register or analog CONTROL_IFACE_PATH */
  61. int ret = 0;
  62. uint32 Reg_Value;
  63. unsigned long flags = 0;
  64. PRINTK_ANA_REG("Ana_Set_Reg offset= 0x%x , value = 0x%x mask = 0x%x\n", offset,
  65. value, mask);
  66. #ifdef AUDIO_USING_WRAP_DRIVER
  67. spin_lock_irqsave(&ana_set_reg_lock, flags);
  68. Reg_Value = Ana_Get_Reg(offset);
  69. Reg_Value &= (~mask);
  70. Reg_Value |= (value & mask);
  71. ret = pwrap_write(offset, Reg_Value);
  72. spin_unlock_irqrestore(&ana_set_reg_lock, flags);
  73. Reg_Value = Ana_Get_Reg(offset);
  74. if ((Reg_Value & mask) != (value & mask))
  75. pr_debug("Ana_Set_Reg mask = 0x%x ret = %d Reg_Value = 0x%x\n", mask, ret,
  76. Reg_Value);
  77. #endif
  78. }
  79. /* export symbols for other module using */
  80. EXPORT_SYMBOL(Ana_Set_Reg);
  81. uint32 Ana_Get_Reg(uint32 offset)
  82. {
  83. /* get pmic register */
  84. int ret = 0;
  85. uint32 Rdata = 0;
  86. #ifdef AUDIO_USING_WRAP_DRIVER
  87. ret = pwrap_read(offset, &Rdata);
  88. #endif
  89. PRINTK_ANA_REG("Ana_Get_Reg offset= 0x%x Rdata = 0x%x ret = %d\n", offset, Rdata, ret);
  90. return Rdata;
  91. }
  92. /* export symbols for other module using */
  93. EXPORT_SYMBOL(Ana_Get_Reg);
  94. void Ana_Log_Print(void)
  95. {
  96. pr_debug("Ana_Log_Print++\n");
  97. AudDrv_ANA_Clk_On();
  98. pr_debug("ABB_AFE_CON0 = 0x%x, CON1 = 0x%x, CON2 = 0x%x, CON3 = 0x%x, CON4 = 0x%x, CON5 = 0x%x\n",
  99. Ana_Get_Reg(ABB_AFE_CON0), Ana_Get_Reg(ABB_AFE_CON1), Ana_Get_Reg(ABB_AFE_CON2), Ana_Get_Reg(ABB_AFE_CON3),
  100. Ana_Get_Reg(ABB_AFE_CON4), Ana_Get_Reg(ABB_AFE_CON5));
  101. pr_debug("ABB_AFE_CON6 = 0x%x, CON7 = 0x%x, CON8 = 0x%x, CON9 = 0x%x, CON10 = 0x%x, CON11 = 0x%x\n",
  102. Ana_Get_Reg(ABB_AFE_CON6), Ana_Get_Reg(ABB_AFE_CON7), Ana_Get_Reg(ABB_AFE_CON8), Ana_Get_Reg(ABB_AFE_CON9),
  103. Ana_Get_Reg(ABB_AFE_CON10), Ana_Get_Reg(ABB_AFE_CON11));
  104. pr_debug("ABB_AFE_STA0=0x%x,STA1=0x%x,STA2=0x%x,AFE_UP8X_FIFO_CFG0=0x%x,LOG_MON0=0x%x,MON1= 0x%x\n",
  105. Ana_Get_Reg(ABB_AFE_STA0), Ana_Get_Reg(ABB_AFE_STA1), Ana_Get_Reg(ABB_AFE_STA2),
  106. Ana_Get_Reg(AFE_UP8X_FIFO_CFG0), Ana_Get_Reg(AFE_PMIC_NEWIF_CFG1), Ana_Get_Reg(AFE_PMIC_NEWIF_CFG2));
  107. pr_debug("AFE_PMIC_NEWIF_CFG0=0x%x,CFG1=0x%x,CFG2=0x%x,CFG3=0x%x,ABB_AFE_TOP_CON0=0x%x,DEBUG0=0x%x\n",
  108. Ana_Get_Reg(AFE_PMIC_NEWIF_CFG0), Ana_Get_Reg(AFE_PMIC_NEWIF_CFG1), Ana_Get_Reg(AFE_PMIC_NEWIF_CFG2),
  109. Ana_Get_Reg(AFE_PMIC_NEWIF_CFG3), Ana_Get_Reg(ABB_AFE_TOP_CON0), Ana_Get_Reg(ABB_MON_DEBUG0));
  110. pr_debug("SPK_CON0=0x%x,CON1=0x%x,CON2=0x%x,CON6=0x%x,CON7=0x%x,CON8=0x%x,CON9=0x%x,CON10=0x%x\n",
  111. Ana_Get_Reg(SPK_CON0), Ana_Get_Reg(SPK_CON1), Ana_Get_Reg(SPK_CON2), Ana_Get_Reg(SPK_CON6),
  112. Ana_Get_Reg(SPK_CON7), Ana_Get_Reg(SPK_CON8), Ana_Get_Reg(SPK_CON9), Ana_Get_Reg(SPK_CON10));
  113. pr_debug("SPK_CON11=0x%x,CON12=0x%x,CID=0x%x,TOP_CKPDN0=0x%x,CKPDN0_SET=0x%x,CKPDN0_CLR=0x%x\n",
  114. Ana_Get_Reg(SPK_CON11), Ana_Get_Reg(SPK_CON12), Ana_Get_Reg(CID), Ana_Get_Reg(TOP_CKPDN0),
  115. Ana_Get_Reg(TOP_CKPDN0_SET), Ana_Get_Reg(TOP_CKPDN0_CLR));
  116. pr_debug("TOP_CKPDN1=0x%x,SET=0x%x,CLR=0x%x,TOP_CKPDN2=0x%x,SET=0x%x,CLR=0x%x, TOP_CKCON1 = 0x%x\n",
  117. Ana_Get_Reg(TOP_CKPDN1), Ana_Get_Reg(TOP_CKPDN1_SET), Ana_Get_Reg(TOP_CKPDN1_CLR), Ana_Get_Reg(TOP_CKPDN2),
  118. Ana_Get_Reg(TOP_CKPDN2_SET), Ana_Get_Reg(TOP_CKPDN2_CLR), Ana_Get_Reg(TOP_CKCON1));
  119. pr_debug("AUDTOP_CON0=0x%x,CON1=0x%x,CON2=0x%x,CON3=0x%x,CON4=0x%x,CON5=0x%x,CON6=0x%x\n",
  120. Ana_Get_Reg(AUDTOP_CON0), Ana_Get_Reg(AUDTOP_CON1), Ana_Get_Reg(AUDTOP_CON2), Ana_Get_Reg(AUDTOP_CON3),
  121. Ana_Get_Reg(AUDTOP_CON4), Ana_Get_Reg(AUDTOP_CON5), Ana_Get_Reg(AUDTOP_CON6));
  122. pr_debug("AUDTOP_CON7 = 0x%x, AUDTOP_CON8 = 0x%x, AUDTOP_CON9 = 0x%x\n",
  123. Ana_Get_Reg(AUDTOP_CON7), Ana_Get_Reg(AUDTOP_CON8), Ana_Get_Reg(AUDTOP_CON9));
  124. AudDrv_ANA_Clk_Off();
  125. pr_debug("-Ana_Log_Print\n");
  126. }
  127. /* export symbols for other module using */
  128. EXPORT_SYMBOL(Ana_Log_Print);