mb/system76/cml-u/dt: Make use of chipset devicetree
[coreboot.git] / src / soc / mediatek / common / mtcmos.c
blob2f4bd22d54d1f351a72da539d915a1a86466210f
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <delay.h>
4 #include <device/mmio.h>
5 #include <soc/spm.h>
7 enum {
8 SRAM_ISOINT_B = 1U << 6,
9 SRAM_CKISO = 1U << 5,
10 PWR_CLK_DIS = 1U << 4,
11 PWR_ON_2ND = 1U << 3,
12 PWR_ON = 1U << 2,
13 PWR_ISO = 1U << 1,
14 PWR_RST_B = 1U << 0
17 __weak void mtcmos_set_scpd_ext_buck_iso(const struct power_domain_data *pd)
19 /* do nothing */
22 void mtcmos_power_on(const struct power_domain_data *pd)
24 write32(&mtk_spm->poweron_config_set,
25 (SPM_PROJECT_CODE << 16) | (1U << 0));
27 if (pd->caps & SCPD_EXT_BUCK_ISO)
28 mtcmos_set_scpd_ext_buck_iso(pd);
30 setbits32(pd->pwr_con, PWR_ON);
31 setbits32(pd->pwr_con, PWR_ON_2ND);
33 while (!(read32(&mtk_spm->pwr_status) & pd->pwr_sta_mask) ||
34 !(read32(&mtk_spm->pwr_status_2nd) & pd->pwr_sta_mask))
35 continue;
37 clrbits32(pd->pwr_con, PWR_CLK_DIS);
38 clrbits32(pd->pwr_con, PWR_ISO);
39 setbits32(pd->pwr_con, PWR_RST_B);
40 clrbits32(pd->pwr_con, pd->sram_pdn_mask);
42 while (read32(pd->pwr_con) & pd->sram_ack_mask)
43 continue;
45 if (pd->caps & SCPD_SRAM_ISO) {
46 setbits32(pd->pwr_con, SRAM_ISOINT_B);
47 udelay(1);
48 clrbits32(pd->pwr_con, SRAM_CKISO);
52 void mtcmos_display_power_on(void)
54 int i;
56 for (i = 0; i < ARRAY_SIZE(disp); i++)
57 mtcmos_power_on(&disp[i]);
60 void mtcmos_audio_power_on(void)
62 int i;
64 for (i = 0; i < ARRAY_SIZE(audio); i++)
65 mtcmos_power_on(&audio[i]);