blob: b1a37a9ce3b850f15d00b8d9ffea6aabd37c8289 [file] [log] [blame]
Angel Pons80d92382020-04-05 15:47:00 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Mariusz Szafranskia4041332017-08-02 17:28:17 +02002
Furquan Shaikh76cedd22020-05-02 10:24:23 -07003#include <acpi/acpi.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02004#include <device/pci_ops.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02005#include <console/console.h>
Subrata Banikfac11d02022-02-17 20:40:55 +05306#include <cpu/x86/smm.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02007#include <device/device.h>
Michael Niewöhner68bacc22021-09-24 23:57:37 +02008#include <device/mmio.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +02009#include <device/pci.h>
10#include <device/pci_ids.h>
Subrata Banikfac11d02022-02-17 20:40:55 +053011#include <intelblocks/pmc.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020012#include <soc/iomap.h>
Subrata Banikfac11d02022-02-17 20:40:55 +053013#include <soc/pm.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020014#include <soc/pmc.h>
15#include <soc/pci_devs.h>
16#include <soc/ramstage.h>
Mariusz Szafranskia4041332017-08-02 17:28:17 +020017
Elyes HAOUAS2ec41832018-05-27 17:40:58 +020018static void pch_power_options(struct device *dev) { /* TODO */ }
Mariusz Szafranskia4041332017-08-02 17:28:17 +020019
Subrata Banikfac11d02022-02-17 20:40:55 +053020/* Fill up PMC resource structure */
21int pmc_soc_get_resources(struct pmc_resource_config *cfg)
22{
23 cfg->pwrmbase_offset = PMC_PWRM_BASE;
24 cfg->pwrmbase_addr = DEFAULT_PWRM_BASE;
25 cfg->pwrmbase_size = DEFAULT_PWRM_SIZE;
26 cfg->abase_offset = PMC_ACPI_BASE;
27 cfg->abase_addr = DEFAULT_PMBASE;
28 cfg->abase_size = DEFAULT_PMBASE_SIZE;
29
30 return 0;
31}
32
Mariusz Szafranskia4041332017-08-02 17:28:17 +020033static void pch_set_acpi_mode(void)
34{
Kyösti Mälkkiad882c32020-06-02 05:05:30 +030035 if (!acpi_is_wakeup_s3()) {
Kyösti Mälkkib6585482020-06-01 15:11:14 +030036 apm_control(APM_CNT_ACPI_DISABLE);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020037 }
38}
39
Subrata Banikfac11d02022-02-17 20:40:55 +053040void pmc_soc_init(struct device *dev)
Mariusz Szafranskia4041332017-08-02 17:28:17 +020041{
Subrata Banikfac11d02022-02-17 20:40:55 +053042 uint32_t pwrm_base = pci_read_config32(dev, PMC_PWRM_BASE) & MASK_PMC_PWRM_BASE;
Mariusz Szafranskia4041332017-08-02 17:28:17 +020043
Subrata Banikfac11d02022-02-17 20:40:55 +053044 printk(BIOS_DEBUG, "pch: %s\n", __func__);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020045
46 /* Set the value for PCI command register. */
47 pci_write_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER |
48 PCI_COMMAND_MEMORY |
49 PCI_COMMAND_IO);
50
51 /* Setup power options. */
52 pch_power_options(dev);
53
54 /* Configure ACPI mode. */
55 pch_set_acpi_mode();
Michael Niewöhner68bacc22021-09-24 23:57:37 +020056
57 /*
58 * Disable ACPI PM timer based on Kconfig
59 *
60 * Disabling ACPI PM timer is necessary for XTAL OSC shutdown.
61 * Disabling ACPI PM timer also switches off TCO.
62 */
63 if (!CONFIG(USE_PM_ACPI_TIMER))
64 setbits8((volatile void *)(uintptr_t)(pwrm_base + PCH_PWRM_ACPI_TMR_CTL),
65 ACPI_TIM_DIS);
Mariusz Szafranskia4041332017-08-02 17:28:17 +020066}