From 0c22084ec0eb11cf6922f07ebfc6f434ab17892f Mon Sep 17 00:00:00 2001 From: CC Ma Date: Fri, 31 Jul 2015 17:10:59 +0800 Subject: mediatek/mt8173: Add mtcmos power-on control for audio and display BRANCH=none BUG=none TEST=none Change-Id: Ic046c66c8e314bd61f96c2edbc5d832260590afe Signed-off-by: Patrick Georgi Original-Commit-Id: 84de3a6f1a726938e2318814d6faaf6a7dd29ac0 Original-Change-Id: If29f28a092617532dd73e71e0dbe24fd930c3bf8 Original-Signed-off-by: CC Ma Original-Reviewed-on: https://chromium-review.googlesource.com/292677 Original-Commit-Ready: Yidi Lin Original-Tested-by: Yidi Lin Original-Reviewed-by: Julius Werner Reviewed-on: https://review.coreboot.org/12617 Reviewed-by: Stefan Reinauer Tested-by: build bot (Jenkins) --- src/soc/mediatek/mt8173/include/soc/mtcmos.h | 21 ++++++++ src/soc/mediatek/mt8173/mtcmos.c | 72 ++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 src/soc/mediatek/mt8173/include/soc/mtcmos.h create mode 100644 src/soc/mediatek/mt8173/mtcmos.c (limited to 'src') diff --git a/src/soc/mediatek/mt8173/include/soc/mtcmos.h b/src/soc/mediatek/mt8173/include/soc/mtcmos.h new file mode 100644 index 0000000000..a2b4f6554c --- /dev/null +++ b/src/soc/mediatek/mt8173/include/soc/mtcmos.h @@ -0,0 +1,21 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2015 MediaTek Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __SOC_MEDIATEK_MT8173_MTCMOS_H__ +#define __SOC_MEDIATEK_MT8173_MTCMOS_H__ + +void mtcmos_audio_power_on(void); +void mtcmos_display_power_on(void); +#endif /* __SOC_MEDIATEK_MT8173_MTCMOS_H__ */ diff --git a/src/soc/mediatek/mt8173/mtcmos.c b/src/soc/mediatek/mt8173/mtcmos.c new file mode 100644 index 0000000000..b9b8ceb3b5 --- /dev/null +++ b/src/soc/mediatek/mt8173/mtcmos.c @@ -0,0 +1,72 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2015 MediaTek Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +enum { + SRAM_ISOINT_B = 1U << 6, + SRAM_CKISO = 1U << 5, + PWR_CLK_DIS = 1U << 4, + PWR_ON_2ND = 1U << 3, + PWR_ON = 1U << 2, + PWR_ISO = 1U << 1, + PWR_RST_B = 1U << 0 +}; + +enum { + SRAM_PDN = 0xf << 8, + DIS_SRAM_ACK = 0x1 << 12, + AUD_SRAM_ACK = 0xf << 12, +}; + +enum { + DIS_PWR_STA_MASK = 0x1 << 3, + AUD_PWR_STA_MASK = 0x1 << 24, +}; + +static void mtcmos_power_on(u32 *pwr_con, u32 pwr_sta_mask) +{ + write32(&mt8173_spm->poweron_config_set, + (SPM_PROJECT_CODE << 16) | (1U << 0)); + + setbits_le32(pwr_con, PWR_ON); + setbits_le32(pwr_con, PWR_ON_2ND); + + while (!(read32(&mt8173_spm->pwr_status) & pwr_sta_mask) || + !(read32(&mt8173_spm->pwr_status_2nd) & pwr_sta_mask)) + continue; + + clrbits_le32(pwr_con, PWR_CLK_DIS); + clrbits_le32(pwr_con, PWR_ISO); + setbits_le32(pwr_con, PWR_RST_B); + clrbits_le32(pwr_con, SRAM_PDN); +} + +void mtcmos_audio_power_on(void) +{ + mtcmos_power_on(&mt8173_spm->audio_pwr_con, AUD_PWR_STA_MASK); + while (read32(&mt8173_spm->audio_pwr_con) & AUD_SRAM_ACK) + continue; +} + +void mtcmos_display_power_on(void) +{ + mtcmos_power_on(&mt8173_spm->dis_pwr_con, DIS_PWR_STA_MASK); + while (read32(&mt8173_spm->dis_pwr_con) & DIS_SRAM_ACK) + continue; +} + -- cgit v1.2.3