|
| 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 <allen-kh.cheng@mediatek.com> |
| 6 | +// Tinghan Shen <tinghan.shen@mediatek.com> |
| 7 | +// |
| 8 | +// Hardware interface for mt8186 DSP code loader |
| 9 | + |
| 10 | +#include <sound/sof.h> |
| 11 | +#include "mt8186.h" |
| 12 | +#include "../../ops.h" |
| 13 | + |
| 14 | +void sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr) |
| 15 | +{ |
| 16 | + /* set RUNSTALL to stop core */ |
| 17 | + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_HIFI_IO_CONFIG, |
| 18 | + RUNSTALL, RUNSTALL); |
| 19 | + |
| 20 | + /* set core boot address */ |
| 21 | + snd_sof_dsp_write(sdev, DSP_SECREG_BAR, ADSP_ALTVEC_C0, boot_addr); |
| 22 | + snd_sof_dsp_write(sdev, DSP_SECREG_BAR, ADSP_ALTVECSEL, ADSP_ALTVECSEL_C0); |
| 23 | + |
| 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 | + |
| 29 | + /* hardware requirement */ |
| 30 | + udelay(1); |
| 31 | + |
| 32 | + /* release core reset */ |
| 33 | + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_CFGREG_SW_RSTN, |
| 34 | + SW_RSTN_C0 | SW_DBG_RSTN_C0, |
| 35 | + 0); |
| 36 | + |
| 37 | + /* clear RUNSTALL (bit31) to start core */ |
| 38 | + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_HIFI_IO_CONFIG, |
| 39 | + RUNSTALL, 0); |
| 40 | +} |
| 41 | + |
| 42 | +void sof_hifixdsp_shutdown(struct snd_sof_dev *sdev) |
| 43 | +{ |
| 44 | + /* set RUNSTALL to stop core */ |
| 45 | + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_HIFI_IO_CONFIG, |
| 46 | + RUNSTALL, RUNSTALL); |
| 47 | + |
| 48 | + /* assert core reset */ |
| 49 | + snd_sof_dsp_update_bits(sdev, DSP_REG_BAR, ADSP_CFGREG_SW_RSTN, |
| 50 | + SW_RSTN_C0 | SW_DBG_RSTN_C0, |
| 51 | + SW_RSTN_C0 | SW_DBG_RSTN_C0); |
| 52 | +} |
| 53 | + |
0 commit comments