blob: d099d7779ad5f496ac05d054ec27f920729e2d6a [file] [log] [blame]
Lijian Zhao6cf501c2017-10-10 18:26:18 -07001/*
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älkki13f66502019-03-03 08:01:05 +020018#include <device/mmio.h>
Lijian Zhao6cf501c2017-10-10 18:26:18 -070019#include <bootstate.h>
Lijian Zhao6cf501c2017-10-10 18:26:18 -070020#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 Banik7bc4dc52018-05-17 18:40:32 +053026#include <intelblocks/tco.h>
Lijian Zhao6cf501c2017-10-10 18:26:18 -070027#include <reg_script.h>
28#include <spi-generic.h>
29#include <soc/p2sb.h>
30#include <soc/pci_devs.h>
31#include <soc/pcr_ids.h>
32#include <soc/pm.h>
33#include <soc/smbus.h>
34#include <soc/systemagent.h>
35#include <stdlib.h>
36
Elyes HAOUASc3385072019-03-21 15:38:06 +010037#include "chip.h"
38
Lijian Zhao1b64ae12018-01-22 20:08:15 -080039#define CAMERA1_CLK 0x8000 /* Camera 1 Clock */
40#define CAMERA2_CLK 0x8080 /* Camera 2 Clock */
41#define CAM_CLK_EN (1 << 1)
42#define MIPI_CLK (1 << 0)
43#define HDPLL_CLK (0 << 0)
44
Lijian Zhao1b64ae12018-01-22 20:08:15 -080045static void pch_enable_isclk(void)
46{
47 pcr_or32(PID_ISCLK, CAMERA1_CLK, CAM_CLK_EN | MIPI_CLK);
48 pcr_or32(PID_ISCLK, CAMERA2_CLK, CAM_CLK_EN | MIPI_CLK);
49}
50
51static void pch_handle_sideband(config_t *config)
52{
Lijian Zhao1b64ae12018-01-22 20:08:15 -080053 if (config->pch_isclk)
54 pch_enable_isclk();
Lijian Zhao6cf501c2017-10-10 18:26:18 -070055}
56
57static void pch_finalize(void)
58{
Elyes HAOUAS3c8b5d02018-05-27 16:57:24 +020059 struct device *dev;
Lijian Zhao6cf501c2017-10-10 18:26:18 -070060 uint32_t reg32;
Lijian Zhao6cf501c2017-10-10 18:26:18 -070061 uint8_t *pmcbase;
62 config_t *config;
63 uint8_t reg8;
64
Subrata Banik7bc4dc52018-05-17 18:40:32 +053065 tco_lockdown();
Lijian Zhao6cf501c2017-10-10 18:26:18 -070066 /*
67 * Disable ACPI PM timer based on dt policy
68 *
69 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
70 * Disabling ACPI PM timer also switches off TCO
Furquan Shaikha913b3d2019-07-06 22:09:28 -070071 *
72 * SA_DEV_ROOT device is used here instead of PCH_DEV_PMC since it is
73 * just required to get to chip config. PCH_DEV_PMC is hidden by this
74 * point and hence removed from the root bus. pcidev_path_on_root thus
75 * returns NULL for PCH_DEV_PMC device.
Lijian Zhao6cf501c2017-10-10 18:26:18 -070076 */
Furquan Shaikha913b3d2019-07-06 22:09:28 -070077 dev = SA_DEV_ROOT;
Lijian Zhao6cf501c2017-10-10 18:26:18 -070078 config = dev->chip_info;
79 pmcbase = pmc_mmio_regs();
80 if (config->PmTimerDisabled) {
81 reg8 = read8(pmcbase + PCH_PWRM_ACPI_TMR_CTL);
82 reg8 |= (1 << 1);
83 write8(pmcbase + PCH_PWRM_ACPI_TMR_CTL, reg8);
84 }
85
86 /* Disable XTAL shutdown qualification for low power idle. */
87 if (config->s0ix_enable) {
88 reg32 = read32(pmcbase + CPPMVRIC);
89 reg32 |= XTALSDQDIS;
90 write32(pmcbase + CPPMVRIC, reg32);
91 }
92
Lijian Zhao1b64ae12018-01-22 20:08:15 -080093 pch_handle_sideband(config);
Krishna Prasad Bhat2de19032019-03-14 23:23:22 +053094
95 pmc_clear_pmcon_sts();
Lijian Zhao6cf501c2017-10-10 18:26:18 -070096}
97
98static void soc_finalize(void *unused)
99{
100 printk(BIOS_DEBUG, "Finalizing chipset.\n");
101
Lijian Zhao6cf501c2017-10-10 18:26:18 -0700102 pch_finalize();
103
104 printk(BIOS_DEBUG, "Finalizing SMM.\n");
105 outb(APM_CNT_FINALIZE, APM_CNT);
106
107 /* Indicate finalize step with post code */
108 post_code(POST_OS_BOOT);
109}
110
111BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, soc_finalize, NULL);
112BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, soc_finalize, NULL);