blob: b61f32df49ce39558f86c2942cc6b97d18749876 [file] [log] [blame]
Angel Pons6ad91762020-04-03 01:23:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Mario Scheithauer58bf3e72018-10-30 09:57:44 +01002
Kyösti Mälkkibdaec072019-03-02 23:18:29 +02003#include <arch/io.h>
Mario Scheithauer58bf3e72018-10-30 09:57:44 +01004#include <bootstate.h>
Mario Scheithauer04ea73e2018-11-07 12:58:28 +01005#include <cf9_reset.h>
Mario Scheithauerd985cdc2018-11-07 08:50:45 +01006#include <device/pci_def.h>
Mario Scheithauer58bf3e72018-10-30 09:57:44 +01007#include <device/pci_ids.h>
8#include <device/pci_ops.h>
9#include <gpio.h>
10#include <hwilib.h>
11#include <intelblocks/lpc_lib.h>
12#include <intelblocks/pcr.h>
13#include <soc/pcr_ids.h>
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010014#include <baseboard/variants.h>
Elyes HAOUASe39db682019-05-15 21:12:31 +020015#include <types.h>
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010016
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010017void variant_mainboard_final(void)
18{
19 struct device *dev = NULL;
20
Mario Scheithauer98689df2018-11-06 14:59:11 +010021 /* PIR6 register mapping for PCIe root ports
Mario Scheithauer08706a32023-05-09 13:34:05 +020022 INTA#->PIRQD#, INTB#->PIRQA#, INTC#->PIRQB#, INTD#-> PIRQC# */
Mario Scheithauer98689df2018-11-06 14:59:11 +010023 pcr_write16(PID_ITSS, 0x314c, 0x2103);
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010024
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010025 /* Enable CLKRUN_EN for power gating LPC */
26 lpc_enable_pci_clk_cntl();
27
28 /*
Mario Scheithauer08706a32023-05-09 13:34:05 +020029 * Enable LPC PCE (Power Control Enable) by setting IOSF-SB port 0xD2 offset 0x341D
30 * bit3 and bit0.
31 * Enable LPC CCE (Clock Control Enable) by setting IOSF-SB port 0xD2 offset 0x341C bit
32 * [3:0].
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010033 */
34 pcr_or32(PID_LPC, PCR_LPC_PRC, (PCR_LPC_CCE_EN | PCR_LPC_PCE_EN));
Mario Scheithauerd985cdc2018-11-07 08:50:45 +010035
Werner Zeh1412ffa2021-07-20 07:33:20 +020036 /* Set Master Enable for on-board PCI device if allowed. */
Felix Singer43b7f412022-03-07 04:34:52 +010037 dev = dev_find_device(PCI_VID_SIEMENS, 0x403e, 0);
Mario Scheithauerd985cdc2018-11-07 08:50:45 +010038 if (dev) {
Werner Zehe8fc8f32021-07-22 06:44:01 +020039 if (CONFIG(PCI_ALLOW_BUS_MASTER_ANY_DEVICE))
Werner Zeh1412ffa2021-07-20 07:33:20 +020040 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
Mario Scheithauer49468042018-11-08 13:49:24 +010041
Mario Scheithauer08706a32023-05-09 13:34:05 +020042 /* Disable clock outputs 0 and 2-4 (CLKOUT) for upstream XIO2001 PCIe to PCI
43 Bridge. */
Mario Scheithauer49468042018-11-08 13:49:24 +010044 struct device *parent = dev->bus->dev;
Felix Singer43b7f412022-03-07 04:34:52 +010045 if (parent && parent->device == PCI_DID_TI_XIO2001)
Mario Scheithauer49468042018-11-08 13:49:24 +010046 pci_write_config8(parent, 0xd8, 0x1d);
47 }
48
Mario Scheithauer08706a32023-05-09 13:34:05 +020049 /* Disable clock outputs 2-5 (CLKOUT) for another XIO2001 PCIe to PCI Bridge on this
50 mainboard. */
Felix Singer43b7f412022-03-07 04:34:52 +010051 dev = dev_find_device(PCI_VID_SIEMENS, 0x403f, 0);
Mario Scheithauer49468042018-11-08 13:49:24 +010052 if (dev) {
53 struct device *parent = dev->bus->dev;
Felix Singer43b7f412022-03-07 04:34:52 +010054 if (parent && parent->device == PCI_DID_TI_XIO2001)
Mario Scheithauer49468042018-11-08 13:49:24 +010055 pci_write_config8(parent, 0xd8, 0x3c);
Mario Scheithauerd985cdc2018-11-07 08:50:45 +010056 }
Mario Scheithauer04ea73e2018-11-07 12:58:28 +010057
Mario Scheithauer08706a32023-05-09 13:34:05 +020058 /* Set Full Reset Bit in Reset Control Register (I/O port CF9h). When Bit 3 is set to 1
59 and then the reset button is pressed the PCH will drive SLP_S3 active (low). SLP_S3
60 is then used on the mainboard to generate the right reset timing. */
Mario Scheithauer04ea73e2018-11-07 12:58:28 +010061 outb(FULL_RST, RST_CNT);
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010062}
63
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010064static void finalize_boot(void *unused)
65{
66 /* Set coreboot ready LED. */
67 gpio_output(CNV_RGI_DT, 1);
68}
69
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010070BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, finalize_boot, NULL);