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> |
| 20 | #include <reg_script.h> |
| 21 | #include <spi-generic.h> |
| 22 | #include <soc/p2sb.h> |
| 23 | #include <soc/pci_devs.h> |
| 24 | #include <soc/pcr_ids.h> |
| 25 | #include <soc/pm.h> |
| 26 | #include <soc/smbus.h> |
| 27 | #include <soc/soc_chip.h> |
| 28 | #include <soc/systemagent.h> |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 29 | |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 30 | static void pch_finalize(void) |
| 31 | { |
| 32 | uint32_t reg32; |
| 33 | uint8_t *pmcbase; |
| 34 | config_t *config; |
| 35 | uint8_t reg8; |
| 36 | |
| 37 | /* TCO Lock down */ |
| 38 | tco_lockdown(); |
| 39 | |
Subrata Banik | 2fff391 | 2020-01-16 10:13:28 +0530 | [diff] [blame] | 40 | /* TODO: Add Thermal Configuration */ |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 41 | |
| 42 | /* |
| 43 | * Disable ACPI PM timer based on dt policy |
| 44 | * |
| 45 | * Disabling ACPI PM timer is necessary for XTAL OSC shutdown. |
| 46 | * Disabling ACPI PM timer also switches off TCO |
| 47 | * |
| 48 | * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is |
| 49 | * just required to get to chip config. PCH_DEV_PMC is hidden by this |
| 50 | * point and hence removed from the root bus. pcidev_path_on_root thus |
| 51 | * returns NULL for PCH_DEV_PMC device. |
| 52 | */ |
| 53 | config = config_of_soc(); |
| 54 | pmcbase = pmc_mmio_regs(); |
| 55 | if (config->PmTimerDisabled) { |
| 56 | reg8 = read8(pmcbase + PCH_PWRM_ACPI_TMR_CTL); |
| 57 | reg8 |= (1 << 1); |
| 58 | write8(pmcbase + PCH_PWRM_ACPI_TMR_CTL, reg8); |
| 59 | } |
| 60 | |
| 61 | /* Disable XTAL shutdown qualification for low power idle. */ |
| 62 | if (config->s0ix_enable) { |
| 63 | reg32 = read32(pmcbase + CPPMVRIC); |
| 64 | reg32 |= XTALSDQDIS; |
| 65 | write32(pmcbase + CPPMVRIC, reg32); |
| 66 | } |
| 67 | |
Subrata Banik | 91e89c5 | 2019-11-01 18:30:01 +0530 | [diff] [blame] | 68 | pmc_clear_pmcon_sts(); |
| 69 | } |
| 70 | |
| 71 | static void soc_finalize(void *unused) |
| 72 | { |
| 73 | printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
| 74 | |
| 75 | pch_finalize(); |
| 76 | |
| 77 | printk(BIOS_DEBUG, "Finalizing SMM.\n"); |
| 78 | outb(APM_CNT_FINALIZE, APM_CNT); |
| 79 | |
| 80 | /* Indicate finalize step with post code */ |
| 81 | post_code(POST_OS_BOOT); |
| 82 | } |
| 83 | |
| 84 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL); |
| 85 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL); |