board_audio.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (c) 2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #include "sdk.h"
  31. #include "registers/regsccm.h"
  32. #include "registers/regsesai.h"
  33. ////////////////////////////////////////////////////////////////////////////////
  34. // Code
  35. ////////////////////////////////////////////////////////////////////////////////
  36. void SGTL5000PowerUp_and_clockinit(void)
  37. {
  38. }
  39. /*!
  40. *
  41. * Additional code related to clock configuration
  42. *
  43. */
  44. unsigned int spdif_get_tx_clk_freq(void)
  45. {
  46. return 30000000;
  47. }
  48. /*! From obds
  49. * Audio Codec Power on
  50. */
  51. void audio_codec_power_on (void)
  52. {
  53. #ifdef BOARD_SMART_DEVICE
  54. //CODEC PWR_EN, key_col12
  55. gpio_set_gpio(GPIO_PORT4, 10);
  56. gpio_set_direction(GPIO_PORT4, 10, GPIO_GDIR_OUTPUT);
  57. gpio_set_level(GPIO_PORT4, 10, GPIO_HIGH_LEVEL);
  58. #endif
  59. }
  60. /*! From obds
  61. * Audio Clock Config
  62. */
  63. void audio_clock_config(void)
  64. {
  65. #if defined(BOARD_SMART_DEVICE)
  66. ccm_iomux_config();
  67. HW_CCM_CCOSR_WR(BF_CCM_CCOSR_CLKO2_EN(1)
  68. | BF_CCM_CCOSR_CLKO2_DIV(6)
  69. | BF_CCM_CCOSR_CLKO2_SEL(0x13)
  70. | BF_CCM_CCOSR_CLKO_SEL(1));
  71. #endif
  72. }
  73. /*!
  74. * @brief SPDIF clock configuration
  75. *
  76. * Use the default setting as follow:
  77. * CDCDR[spdif0_clk_sel](PLL3)->CDCDR[spdif0_clk_pred](div2)->CDCDR[spdif0_clk_podf](div8)-> spdif0_clk_root, so
  78. * the freqency of spdif0_clk should be 480/2/8 = 30MHz.
  79. */
  80. void spdif_clk_cfg(void)
  81. {
  82. HW_CCM_CDCDR.B.SPDIF0_CLK_SEL = 3; // PLL3
  83. HW_CCM_CDCDR.B.SPDIF0_CLK_PODF = 7; // div 8
  84. HW_CCM_CDCDR.B.SPDIF0_CLK_PRED = 1; // div 2
  85. clock_gating_config(SPDIF_BASE_ADDR, CLOCK_ON);
  86. return;
  87. }
  88. /*!
  89. * Power no esai codec.
  90. */
  91. int esai_codec_power_on(void)
  92. {
  93. // No need to do anything for BOARD_SABRE_AI
  94. return 0;
  95. }
  96. void esai_clk_sel_gate_on()
  97. {
  98. // source from PLL3_508
  99. HW_CCM_CSCMR2.B.ESAI_CLK_SEL = 1;
  100. clock_gating_config(REGS_ESAI_BASE, CLOCK_ON);
  101. }
  102. ////////////////////////////////////////////////////////////////////////////////
  103. // EOF
  104. ////////////////////////////////////////////////////////////////////////////////