Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Google Inc. |
| 5 | * Copyright (C) 2017 Intel Corporation. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 18 | #include <device/mmio.h> |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 19 | #include <bootstate.h> |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 20 | #include <console/console.h> |
| 21 | #include <console/post_codes.h> |
| 22 | #include <cpu/x86/smm.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <intelblocks/lpc_lib.h> |
| 25 | #include <intelblocks/pcr.h> |
Subrata Banik | 7bc4dc5 | 2018-05-17 18:40:32 +0530 | [diff] [blame] | 26 | #include <intelblocks/tco.h> |
Sumeet Pawnikar | 810527a | 2019-07-23 22:02:16 +0530 | [diff] [blame] | 27 | #include <intelblocks/thermal.h> |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 28 | #include <reg_script.h> |
| 29 | #include <spi-generic.h> |
| 30 | #include <soc/p2sb.h> |
| 31 | #include <soc/pci_devs.h> |
| 32 | #include <soc/pcr_ids.h> |
| 33 | #include <soc/pm.h> |
| 34 | #include <soc/smbus.h> |
| 35 | #include <soc/systemagent.h> |
| 36 | #include <stdlib.h> |
| 37 | |
Elyes HAOUAS | c338507 | 2019-03-21 15:38:06 +0100 | [diff] [blame] | 38 | #include "chip.h" |
| 39 | |
Lijian Zhao | 1b64ae1 | 2018-01-22 20:08:15 -0800 | [diff] [blame] | 40 | #define CAMERA1_CLK 0x8000 /* Camera 1 Clock */ |
| 41 | #define CAMERA2_CLK 0x8080 /* Camera 2 Clock */ |
| 42 | #define CAM_CLK_EN (1 << 1) |
| 43 | #define MIPI_CLK (1 << 0) |
| 44 | #define HDPLL_CLK (0 << 0) |
| 45 | |
Lijian Zhao | 1b64ae1 | 2018-01-22 20:08:15 -0800 | [diff] [blame] | 46 | static void pch_enable_isclk(void) |
| 47 | { |
| 48 | pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK); |
| 49 | pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK); |
| 50 | } |
| 51 | |
| 52 | static void pch_handle_sideband(config_t *config) |
| 53 | { |
Lijian Zhao | 1b64ae1 | 2018-01-22 20:08:15 -0800 | [diff] [blame] | 54 | if (config->pch_isclk) |
| 55 | pch_enable_isclk(); |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | static void pch_finalize(void) |
| 59 | { |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 60 | uint32_t reg32; |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 61 | uint8_t *pmcbase; |
| 62 | config_t *config; |
| 63 | uint8_t reg8; |
| 64 | |
Subrata Banik | 7bc4dc5 | 2018-05-17 18:40:32 +0530 | [diff] [blame] | 65 | tco_lockdown(); |
Sumeet Pawnikar | 810527a | 2019-07-23 22:02:16 +0530 | [diff] [blame] | 66 | |
| 67 | /* |
| 68 | * Set low maximum temp threshold value used for dynamic thermal sensor |
| 69 | * shutdown consideration. |
| 70 | * |
| 71 | * If Dynamic Thermal Shutdown is enabled then PMC logic shuts down the |
| 72 | * thermal sensor when CPU is in a C-state and DTS Temp <= LTT. |
| 73 | */ |
| 74 | pch_thermal_configuration(); |
| 75 | |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 76 | /* |
| 77 | * Disable ACPI PM timer based on dt policy |
| 78 | * |
| 79 | * Disabling ACPI PM timer is necessary for XTAL OSC shutdown. |
| 80 | * Disabling ACPI PM timer also switches off TCO |
Furquan Shaikh | a913b3d | 2019-07-06 22:09:28 -0700 | [diff] [blame] | 81 | * |
| 82 | * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is |
| 83 | * just required to get to chip config. PCH_DEV_PMC is hidden by this |
| 84 | * point and hence removed from the root bus. pcidev_path_on_root thus |
| 85 | * returns NULL for PCH_DEV_PMC device. |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 86 | */ |
Kyösti Mälkki | d5f645c | 2019-09-28 00:20:27 +0300 | [diff] [blame^] | 87 | config = config_of_soc(); |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 88 | pmcbase = pmc_mmio_regs(); |
| 89 | if (config->PmTimerDisabled) { |
| 90 | reg8 = read8(pmcbase + PCH_PWRM_ACPI_TMR_CTL); |
| 91 | reg8 |= (1 << 1); |
| 92 | write8(pmcbase + PCH_PWRM_ACPI_TMR_CTL, reg8); |
| 93 | } |
| 94 | |
| 95 | /* Disable XTAL shutdown qualification for low power idle. */ |
| 96 | if (config->s0ix_enable) { |
| 97 | reg32 = read32(pmcbase + CPPMVRIC); |
| 98 | reg32 |= XTALSDQDIS; |
| 99 | write32(pmcbase + CPPMVRIC, reg32); |
| 100 | } |
| 101 | |
Lijian Zhao | 1b64ae1 | 2018-01-22 20:08:15 -0800 | [diff] [blame] | 102 | pch_handle_sideband(config); |
Krishna Prasad Bhat | 2de1903 | 2019-03-14 23:23:22 +0530 | [diff] [blame] | 103 | |
| 104 | pmc_clear_pmcon_sts(); |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | static void soc_finalize(void *unused) |
| 108 | { |
| 109 | printk(BIOS_DEBUG, "Finalizing chipset.\n"); |
| 110 | |
Lijian Zhao | 6cf501c | 2017-10-10 18:26:18 -0700 | [diff] [blame] | 111 | pch_finalize(); |
| 112 | |
| 113 | printk(BIOS_DEBUG, "Finalizing SMM.\n"); |
| 114 | outb(APM_CNT_FINALIZE, APM_CNT); |
| 115 | |
| 116 | /* Indicate finalize step with post code */ |
| 117 | post_code(POST_OS_BOOT); |
| 118 | } |
| 119 | |
| 120 | BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL); |
| 121 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL); |