blob: be058d013b29b4f1a0dc052275bc4364eb836140 [file] [log] [blame]
Angel Ponsc3f58f62020-04-05 15:46:41 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbinfd039f72013-10-04 11:11:52 -05002
Elyes HAOUASbd42b062020-07-10 10:48:11 +02003#include <stdint.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02004#include <device/pci_ops.h>
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -08005#include <console/console.h>
6#include <device/device.h>
7#include <device/pci_def.h>
Julius Werner18ea2d32014-10-07 16:42:17 -07008#include <soc/iomap.h>
9#include <soc/iosf.h>
10#include <soc/lpc.h>
11#include <soc/pci_devs.h>
Angel Ponsb5320b22020-07-07 18:27:30 +020012#include <soc/pm.h>
Julius Werner18ea2d32014-10-07 16:42:17 -070013#include <soc/romstage.h>
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080014#include "../chip.h"
Aaron Durbinfd039f72013-10-04 11:11:52 -050015
Aaron Durbin189aa3e2013-10-04 11:17:45 -050016/* This sequence signals the PUNIT to start running. */
17void punit_init(void)
18{
19 uint32_t reg;
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080020 uint8_t rid;
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080021 const struct soc_intel_baytrail_config *cfg = NULL;
Aaron Durbin189aa3e2013-10-04 11:17:45 -050022
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080023 rid = pci_read_config8(IOSF_PCI_DEV, REVID);
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080024
Kyösti Mälkki459f4932019-09-28 13:47:58 +030025 cfg = config_of_soc();
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080026
27 reg = iosf_punit_read(SB_BIOS_CONFIG);
Aaron Durbin189aa3e2013-10-04 11:17:45 -050028 /* Write bits 17:16 of SB_BIOS_CONFIG in the PUNIT. */
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080029 reg |= SB_BIOS_CONFIG_PERF_MODE | SB_BIOS_CONFIG_PDM_MODE;
30 /* Configure VR low power mode for C0 and above. */
31 if (rid >= RID_C_STEPPING_START && cfg != NULL &&
32 (cfg->vnn_ps2_enable || cfg->vcc_ps2_enable)) {
Paul Menzel63ebb5b2018-09-06 09:05:25 +020033 printk(BIOS_DEBUG, "Enabling VR PS2 mode:");
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080034 if (cfg->vnn_ps2_enable) {
35 reg |= SB_BIOS_CONFIG_PS2_EN_VNN;
Paul Menzel63ebb5b2018-09-06 09:05:25 +020036 printk(BIOS_DEBUG, " VNN");
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080037 }
38 if (cfg->vcc_ps2_enable) {
39 reg |= SB_BIOS_CONFIG_PS2_EN_VCC;
Paul Menzel63ebb5b2018-09-06 09:05:25 +020040 printk(BIOS_DEBUG, " VCC");
Shawn Nematbakhsh51d787a2014-01-16 17:52:21 -080041 }
42 printk(BIOS_DEBUG, "\n");
43 }
44 iosf_punit_write(SB_BIOS_CONFIG, reg);
Aaron Durbin189aa3e2013-10-04 11:17:45 -050045
46 /* Write bits 1:0 of BIOS_RESET_CPL in the PUNIT. */
47 reg = BIOS_RESET_CPL_ALL_DONE | BIOS_RESET_CPL_RESET_DONE;
48 pci_write_config32(IOSF_PCI_DEV, MDR_REG, reg);
49 reg = IOSF_OPCODE(IOSF_OP_WRITE_PMC) | IOSF_PORT(IOSF_PORT_PMC) |
50 IOSF_REG(BIOS_RESET_CPL) | IOSF_BYTE_EN_0;
51 pci_write_config32(IOSF_PCI_DEV, MCR_REG, reg);
52}