| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <delay.h> |
| 5 |
#include <device/mmio.h> |
| 6 |
#include <soc/dpm_v1.h> |
| 7 |
#include <soc/dramc_soc.h> |
| 8 |
#include <soc/spm.h> |
| 9 |
|
| 10 |
static struct dpm_regs *const mtk_dpm2 = (void *)DPM_CFG_BASE2; |
| 11 |
|
| 12 |
static int wake_dpm_sram_up(void) |
| 13 |
{ |
| 14 |
int loop = 100; |
| 15 |
|
| 16 |
|
| 17 |
setbits32(&mtk_spm->dramc_mcu_sram_con, DRAMC_MCU_SRAM_SLEEP_B_LSB); |
| 18 |
setbits32(&mtk_spm->dramc_mcu2_sram_con, DRAMC_MCU2_SRAM_SLEEP_B_LSB); |
| 19 |
|
| 20 |
while (loop > 0 && |
| 21 |
((read32(&mtk_spm->dramc_mcu_sram_con) & |
| 22 |
DRAMC_MCU_SRAM_SLEEP_B_LSB) == 0 || |
| 23 |
(read32(&mtk_spm->dramc_mcu2_sram_con) & |
| 24 |
DRAMC_MCU2_SRAM_SLEEP_B_LSB) == 0)) { |
| 25 |
mdelay(1); |
| 26 |
--loop; |
| 27 |
} |
| 28 |
|
| 29 |
if (loop == 0) { |
| 30 |
printk(BIOS_ERR, "failed to wake DPM up.\n"); |
| 31 |
return -1; |
| 32 |
} |
| 33 |
|
| 34 |
setbits32(&mtk_spm->dramc_mcu_sram_con, DRAMC_MCU_SRAM_ISOINT_B_LSB); |
| 35 |
setbits32(&mtk_spm->dramc_mcu2_sram_con, DRAMC_MCU2_SRAM_ISOINT_B_LSB); |
| 36 |
|
| 37 |
return 0; |
| 38 |
} |
| 39 |
|
| 40 |
static void dpm_mtcoms_sleep_on(void) |
| 41 |
{ |
| 42 |
|
| 43 |
write32(&mtk_spm->dpm0_pwr_con, 0x0000204d); |
| 44 |
write32(&mtk_spm->dpm1_pwr_con, 0x0000204d); |
| 45 |
mdelay(1); |
| 46 |
write32(&mtk_spm->dpm0_pwr_con, 0x0000224d); |
| 47 |
write32(&mtk_spm->dpm1_pwr_con, 0x0000224d); |
| 48 |
mdelay(1); |
| 49 |
clrbits32(&mtk_dpm->sw_rstn, DPM_SW_RSTN_RESET); |
| 50 |
clrbits32(&mtk_dpm2->sw_rstn, DPM_SW_RSTN_RESET); |
| 51 |
} |
| 52 |
|
| 53 |
static struct mtk_mcu dpm_mcu_4ch[] = { |
| 54 |
{ |
| 55 |
.firmware_name = CONFIG_DPM_DM_FIRMWARE, |
| 56 |
.run_address = (void *)DPM_DM_SRAM_BASE2, |
| 57 |
}, |
| 58 |
{ |
| 59 |
.firmware_name = CONFIG_DPM_PM_FIRMWARE, |
| 60 |
.run_address = (void *)DPM_PM_SRAM_BASE2, |
| 61 |
.priv = mtk_dpm2, |
| 62 |
.reset = dpm_reset, |
| 63 |
}, |
| 64 |
{}, |
| 65 |
}; |
| 66 |
|
| 67 |
int dpm_4ch_init(void) |
| 68 |
{ |
| 69 |
dpm_mtcoms_sleep_on(); |
| 70 |
if (wake_dpm_sram_up()) |
| 71 |
return -1; |
| 72 |
return 0; |
| 73 |
} |
| 74 |
|
| 75 |
int dpm_4ch_para_setting(void) |
| 76 |
{ |
| 77 |
return dpm_init_mcu(dpm_mcu_4ch); |
| 78 |
} |