Angel Pons | c3f58f6 | 2020-04-05 15:46:41 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | fd039f7 | 2013-10-04 11:11:52 -0500 | [diff] [blame] | 2 | |
Elyes HAOUAS | bd42b06 | 2020-07-10 10:48:11 +0200 | [diff] [blame] | 3 | #include <stdint.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <device/device.h> |
| 7 | #include <device/pci_def.h> |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 8 | #include <soc/iomap.h> |
| 9 | #include <soc/iosf.h> |
| 10 | #include <soc/lpc.h> |
| 11 | #include <soc/pci_devs.h> |
Angel Pons | b5320b2 | 2020-07-07 18:27:30 +0200 | [diff] [blame] | 12 | #include <soc/pm.h> |
Julius Werner | 18ea2d3 | 2014-10-07 16:42:17 -0700 | [diff] [blame] | 13 | #include <soc/romstage.h> |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 14 | #include "../chip.h" |
Aaron Durbin | fd039f7 | 2013-10-04 11:11:52 -0500 | [diff] [blame] | 15 | |
Aaron Durbin | 189aa3e | 2013-10-04 11:17:45 -0500 | [diff] [blame] | 16 | /* This sequence signals the PUNIT to start running. */ |
| 17 | void punit_init(void) |
| 18 | { |
| 19 | uint32_t reg; |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 20 | uint8_t rid; |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 21 | const struct soc_intel_baytrail_config *cfg = NULL; |
Aaron Durbin | 189aa3e | 2013-10-04 11:17:45 -0500 | [diff] [blame] | 22 | |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 23 | rid = pci_read_config8(IOSF_PCI_DEV, REVID); |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 24 | |
Kyösti Mälkki | 459f493 | 2019-09-28 13:47:58 +0300 | [diff] [blame] | 25 | cfg = config_of_soc(); |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 26 | |
| 27 | reg = iosf_punit_read(SB_BIOS_CONFIG); |
Aaron Durbin | 189aa3e | 2013-10-04 11:17:45 -0500 | [diff] [blame] | 28 | /* Write bits 17:16 of SB_BIOS_CONFIG in the PUNIT. */ |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 29 | 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 Menzel | 63ebb5b | 2018-09-06 09:05:25 +0200 | [diff] [blame] | 33 | printk(BIOS_DEBUG, "Enabling VR PS2 mode:"); |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 34 | if (cfg->vnn_ps2_enable) { |
| 35 | reg |= SB_BIOS_CONFIG_PS2_EN_VNN; |
Paul Menzel | 63ebb5b | 2018-09-06 09:05:25 +0200 | [diff] [blame] | 36 | printk(BIOS_DEBUG, " VNN"); |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 37 | } |
| 38 | if (cfg->vcc_ps2_enable) { |
| 39 | reg |= SB_BIOS_CONFIG_PS2_EN_VCC; |
Paul Menzel | 63ebb5b | 2018-09-06 09:05:25 +0200 | [diff] [blame] | 40 | printk(BIOS_DEBUG, " VCC"); |
Shawn Nematbakhsh | 51d787a | 2014-01-16 17:52:21 -0800 | [diff] [blame] | 41 | } |
| 42 | printk(BIOS_DEBUG, "\n"); |
| 43 | } |
| 44 | iosf_punit_write(SB_BIOS_CONFIG, reg); |
Aaron Durbin | 189aa3e | 2013-10-04 11:17:45 -0500 | [diff] [blame] | 45 | |
| 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 | } |