Angel Pons | 16f6aa8 | 2020-04-05 15:47:21 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * This file is created based on Intel Tiger Lake Processor PCH Datasheet |
| 5 | * Document number: 575857 |
| 6 | * Chapter number: 4, 29 |
| 7 | */ |
| 8 | |
| 9 | #include <arch/io.h> |
| 10 | #include <device/mmio.h> |
| 11 | #include <bootstate.h> |
| 12 | #include <console/console.h> |
| 13 | #include <console/post_codes.h> |
| 14 | #include <cpu/x86/smm.h> |
| 15 | #include <device/pci.h> |
| 16 | #include <intelblocks/lpc_lib.h> |
| 17 | #include <intelblocks/pcr.h> |
| 18 | #include <intelblocks/tco.h> |
| 19 | #include <intelblocks/thermal.h> |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 20 | #include <spi-generic.h> |
| 21 | #include <soc/p2sb.h> |
| 22 | #include <soc/pci_devs.h> |
| 23 | #include <soc/pcr_ids.h> |
| 24 | #include <soc/pm.h> |
| 25 | #include <soc/smbus.h> |
| 26 | #include <soc/soc_chip.h> |
| 27 | #include <soc/systemagent.h> |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 28 | |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 29 | static void pch_finalize(void) |
| 30 | { |
| 31 | uint32_t reg32; |
| 32 | uint8_t *pmcbase; |
| 33 | config_t *config; |
| 34 | uint8_t reg8; |
| 35 | |
| 36 | /* TCO Lock down */ |
| 37 | tco_lockdown(); |
| 38 | |
Subrata Banik | 2fff391 | 2020-01-16 10:13:28 +0530 | [diff] [blame] | 39 | /* TODO: Add Thermal Configuration */ |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 40 | |
| 41 | /* |
| 42 | * Disable ACPI PM timer based on dt policy |
| 43 | * |
| 44 | * Disabling ACPI PM timer is necessary for XTAL OSC shutdown. |
| 45 | * Disabling ACPI PM timer also switches off TCO |
| 46 | * |
| 47 | * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is |
| 48 | * just required to get to chip config. PCH_DEV_PMC is hidden by this |
| 49 | * point and hence removed from the root bus. pcidev_path_on_root thus |
| 50 | * returns NULL for PCH_DEV_PMC device. |
| 51 | */ |
| 52 | config = config_of_soc(); |
| 53 | pmcbase = pmc_mmio_regs(); |
| 54 | if (config->PmTimerDisabled) { |
| 55 | reg8 = read8(pmcbase + PCH_PWRM_ACPI_TMR_CTL); |
| 56 | reg8 |= (1 << 1); |
| 57 | write8(pmcbase + PCH_PWRM_ACPI_TMR_CTL, reg8); |
| 58 | } |
| 59 | |
| 60 | /* Disable XTAL shutdown qualification for low power idle. */ |
| 61 | if (config->s0ix_enable) { |
| 62 | reg32 = read32(pmcbase + CPPMVRIC); |
| 63 | reg32 |= XTALSDQDIS; |
| 64 | write32(pmcbase + CPPMVRIC, reg32); |
| 65 | } |
| 66 | |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 67 | pmc_clear_pmcon_sts(); |
| 68 | } |
| 69 | |
John Zhao | 5d16a25 | 2020-05-01 22:04:00 -0700 | [diff] [blame] | 70 | static void tbt_finalize(void) |
| 71 | { |
| 72 | int i; |
| 73 | const struct device *dev; |
| 74 | |
| 75 | /* Disable Thunderbolt PCIe root ports bus master */ |
| 76 | for (i = 0; i < NUM_TBT_FUNCTIONS; i++) { |
| 77 | dev = pcidev_path_on_root(SA_DEVFN_TBT(i)); |
| 78 | if (dev) |
| 79 | pci_dev_disable_bus_master(dev); |
| 80 | } |
| 81 | } |
| 82 | |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 83 | static void soc_finalize(void *unused) |
| 84 | { |
| 85 | printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
| 86 | |
| 87 | pch_finalize(); |
Kyösti Mälkki | b658548 | 2020-06-01 15:11:14 +0300 | [diff] [blame] | 88 | apm_control(APM_CNT_FINALIZE); |
John Zhao | 5d16a25 | 2020-05-01 22:04:00 -0700 | [diff] [blame] | 89 | tbt_finalize(); |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 90 | |
| 91 | /* Indicate finalize step with post code */ |
| 92 | post_code(POST_OS_BOOT); |
| 93 | } |
| 94 | |
| 95 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL); |
| 96 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL); |