mt8186-loader.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
  2. //
  3. // Copyright (c) 2022 Mediatek Corporation. All rights reserved.
  4. //
  5. // Author: Allen-KH Cheng <[email protected]>
  6. // Tinghan Shen <[email protected]>
  7. //
  8. // Hardware interface for mt8186 DSP code loader
  9. #include <sound/sof.h>
  10. #include "mt8186.h"
  11. #include "../../ops.h"
  12. void mt8186_sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr)
  13. {
  14. /* set RUNSTALL to stop core */
  15. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_HIFI_IO_CONFIG,
  16. RUNSTALL, RUNSTALL);
  17. /* enable mbox 0 & 1 IRQ */
  18. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_MBOX_IRQ_EN,
  19. DSP_MBOX0_IRQ_EN | DSP_MBOX1_IRQ_EN,
  20. DSP_MBOX0_IRQ_EN | DSP_MBOX1_IRQ_EN);
  21. /* set core boot address */
  22. snd_sof_dsp_write(sdev, DSP_SECREG_BAR, ADSP_ALTVEC_C0, boot_addr);
  23. snd_sof_dsp_write(sdev, DSP_SECREG_BAR, ADSP_ALTVECSEL, ADSP_ALTVECSEL_C0);
  24. /* assert core reset */
  25. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_CFGREG_SW_RSTN,
  26. SW_RSTN_C0 | SW_DBG_RSTN_C0,
  27. SW_RSTN_C0 | SW_DBG_RSTN_C0);
  28. /* hardware requirement */
  29. udelay(1);
  30. /* release core reset */
  31. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_CFGREG_SW_RSTN,
  32. SW_RSTN_C0 | SW_DBG_RSTN_C0,
  33. 0);
  34. /* clear RUNSTALL (bit31) to start core */
  35. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_HIFI_IO_CONFIG,
  36. RUNSTALL, 0);
  37. }
  38. void mt8186_sof_hifixdsp_shutdown(struct snd_sof_dev *sdev)
  39. {
  40. /* set RUNSTALL to stop core */
  41. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_HIFI_IO_CONFIG,
  42. RUNSTALL, RUNSTALL);
  43. /* assert core reset */
  44. snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_CFGREG_SW_RSTN,
  45. SW_RSTN_C0 | SW_DBG_RSTN_C0,
  46. SW_RSTN_C0 | SW_DBG_RSTN_C0);
  47. }