mt8195-loader.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
  2. //
  3. // Copyright (c) 2021 Mediatek Corporation. All rights reserved.
  4. //
  5. // Author: YC Hung <[email protected]>
  6. //
  7. // Hardware interface for mt8195 DSP code loader
  8. #include <sound/sof.h>
  9. #include "mt8195.h"
  10. #include "../../ops.h"
  11. void sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr)
  12. {
  13. /* ADSP bootup base */
  14. snd_sof_dsp_write(sdev, DSP_REG_BAR, DSP_ALTRESETVEC, boot_addr);
  15. /* pull high RunStall (set bit3 to 1) */
  16. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
  17. ADSP_RUNSTALL, ADSP_RUNSTALL);
  18. /* pull high StatVectorSel to use AltResetVec (set bit4 to 1) */
  19. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
  20. STATVECTOR_SEL, STATVECTOR_SEL);
  21. /* toggle DReset & BReset */
  22. /* pull high DReset & BReset */
  23. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
  24. ADSP_BRESET_SW | ADSP_DRESET_SW,
  25. ADSP_BRESET_SW | ADSP_DRESET_SW);
  26. /* delay 10 DSP cycles at 26M about 1us by IP vendor's suggestion */
  27. udelay(1);
  28. /* pull low DReset & BReset */
  29. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
  30. ADSP_BRESET_SW | ADSP_DRESET_SW,
  31. 0);
  32. /* Enable PDebug */
  33. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_PDEBUGBUS0,
  34. PDEBUG_ENABLE,
  35. PDEBUG_ENABLE);
  36. /* release RunStall (set bit3 to 0) */
  37. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
  38. ADSP_RUNSTALL, 0);
  39. }
  40. void sof_hifixdsp_shutdown(struct snd_sof_dev *sdev)
  41. {
  42. /* RUN_STALL pull high again to reset */
  43. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
  44. ADSP_RUNSTALL, ADSP_RUNSTALL);
  45. /* pull high DReset & BReset */
  46. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, DSP_RESET_SW,
  47. ADSP_BRESET_SW | ADSP_DRESET_SW,
  48. ADSP_BRESET_SW | ADSP_DRESET_SW);
  49. }