blob: bf87109add02d171baf41d35722b8b26ab1deb0e [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
17#define TX_DWORD3 0xa8c
18
19void variant_mainboard_final(void)
20{
21 struct device *dev = NULL;
22
Mario Scheithauer98689df2018-11-06 14:59:11 +010023 /* PIR6 register mapping for PCIe root ports
24 * INTA#->PIRQD#, INTB#->PIRQA#, INTC#->PIRQB#, INTD#-> PIRQC#
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010025 */
Mario Scheithauer98689df2018-11-06 14:59:11 +010026 pcr_write16(PID_ITSS, 0x314c, 0x2103);
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010027
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010028 /* Enable CLKRUN_EN for power gating LPC */
29 lpc_enable_pci_clk_cntl();
30
31 /*
32 * Enable LPC PCE (Power Control Enable) by setting IOSF-SB port 0xD2
33 * offset 0x341D bit3 and bit0.
34 * Enable LPC CCE (Clock Control Enable) by setting IOSF-SB port 0xD2
35 * offset 0x341C bit [3:0].
36 */
37 pcr_or32(PID_LPC, PCR_LPC_PRC, (PCR_LPC_CCE_EN | PCR_LPC_PCE_EN));
Mario Scheithauerd985cdc2018-11-07 08:50:45 +010038
Werner Zeh1412ffa2021-07-20 07:33:20 +020039 /* Set Master Enable for on-board PCI device if allowed. */
Felix Singer43b7f412022-03-07 04:34:52 +010040 dev = dev_find_device(PCI_VID_SIEMENS, 0x403e, 0);
Mario Scheithauerd985cdc2018-11-07 08:50:45 +010041 if (dev) {
Werner Zehe8fc8f32021-07-22 06:44:01 +020042 if (CONFIG(PCI_ALLOW_BUS_MASTER_ANY_DEVICE))
Werner Zeh1412ffa2021-07-20 07:33:20 +020043 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
Mario Scheithauer49468042018-11-08 13:49:24 +010044
45 /* Disable clock outputs 0 and 2-4 (CLKOUT) for upstream
46 * XIO2001 PCIe to PCI Bridge.
47 */
48 struct device *parent = dev->bus->dev;
Felix Singer43b7f412022-03-07 04:34:52 +010049 if (parent && parent->device == PCI_DID_TI_XIO2001)
Mario Scheithauer49468042018-11-08 13:49:24 +010050 pci_write_config8(parent, 0xd8, 0x1d);
51 }
52
53 /* Disable clock outputs 2-5 (CLKOUT) for another XIO2001 PCIe to PCI
54 * Bridge on this mainboard.
55 */
Felix Singer43b7f412022-03-07 04:34:52 +010056 dev = dev_find_device(PCI_VID_SIEMENS, 0x403f, 0);
Mario Scheithauer49468042018-11-08 13:49:24 +010057 if (dev) {
58 struct device *parent = dev->bus->dev;
Felix Singer43b7f412022-03-07 04:34:52 +010059 if (parent && parent->device == PCI_DID_TI_XIO2001)
Mario Scheithauer49468042018-11-08 13:49:24 +010060 pci_write_config8(parent, 0xd8, 0x3c);
Mario Scheithauerd985cdc2018-11-07 08:50:45 +010061 }
Mario Scheithauer04ea73e2018-11-07 12:58:28 +010062
63 /* Set Full Reset Bit in Reset Control Register (I/O port CF9h).
64 * When Bit 3 is set to 1 and then the reset button is pressed the PCH
65 * will drive SLP_S3 active (low). SLP_S3 is then used on the mainboard
66 * to generate the right reset timing.
67 */
68 outb(FULL_RST, RST_CNT);
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010069}
70
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010071static void finalize_boot(void *unused)
72{
73 /* Set coreboot ready LED. */
74 gpio_output(CNV_RGI_DT, 1);
75}
76
Mario Scheithauer58bf3e72018-10-30 09:57:44 +010077BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, finalize_boot, NULL);