blob: 82b8c5bf0f0a440ecb9223796af3ed8058ff39dd [file] [log] [blame]
Angel Pons6ad91762020-04-03 01:23:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Mario Scheithauer5716b4c2018-11-14 13:27:05 +01002
3#include <bootstate.h>
Mario Scheithauera94a1532018-11-28 09:13:28 +01004#include <device/pci_def.h>
Mario Scheithauer5716b4c2018-11-14 13:27:05 +01005#include <device/pci_ids.h>
6#include <device/pci_ops.h>
7#include <gpio.h>
8#include <hwilib.h>
9#include <intelblocks/lpc_lib.h>
10#include <intelblocks/pcr.h>
11#include <soc/pcr_ids.h>
Mario Scheithauer5716b4c2018-11-14 13:27:05 +010012#include <baseboard/variants.h>
Elyes HAOUASe39db682019-05-15 21:12:31 +020013#include <types.h>
Mario Scheithauer5716b4c2018-11-14 13:27:05 +010014
15#define TX_DWORD3 0xa8c
16
17void variant_mainboard_final(void)
18{
Mario Scheithauer5716b4c2018-11-14 13:27:05 +010019 struct device *dev = NULL;
20
21 /*
Mario Scheithauer5716b4c2018-11-14 13:27:05 +010022 * PIR6 register mapping for PCIe root ports
23 * INTA#->PIRQB#, INTB#->PIRQC#, INTC#->PIRQD#, INTD#-> PIRQA#
24 */
25 pcr_write16(PID_ITSS, 0x314c, 0x0321);
26
Mario Scheithauer5716b4c2018-11-14 13:27:05 +010027 /* Enable CLKRUN_EN for power gating LPC */
28 lpc_enable_pci_clk_cntl();
29
30 /*
31 * Enable LPC PCE (Power Control Enable) by setting IOSF-SB port 0xD2
32 * offset 0x341D bit3 and bit0.
33 * Enable LPC CCE (Clock Control Enable) by setting IOSF-SB port 0xD2
34 * offset 0x341C bit [3:0].
35 */
36 pcr_or32(PID_LPC, PCR_LPC_PRC, (PCR_LPC_CCE_EN | PCR_LPC_PCE_EN));
37
38 /*
39 * Correct the SATA transmit signal via the High Speed I/O Transmit
40 * Control Register 3.
41 * Bit [23:16] set the output voltage swing for TX line.
42 * The value 0x4a sets the swing level to 0.58 V.
43 */
44 pcr_rmw32(PID_MODPHY, TX_DWORD3, (0x00 << 16), (0x4a << 16));
Mario Scheithauera94a1532018-11-28 09:13:28 +010045
Werner Zeh1412ffa2021-07-20 07:33:20 +020046 /* Set Master Enable for on-board PCI device if allowed. */
Felix Singer43b7f412022-03-07 04:34:52 +010047 dev = dev_find_device(PCI_VID_SIEMENS, 0x403e, 0);
Mario Scheithauera94a1532018-11-28 09:13:28 +010048 if (dev) {
Werner Zehe8fc8f32021-07-22 06:44:01 +020049 if (CONFIG(PCI_ALLOW_BUS_MASTER_ANY_DEVICE))
Werner Zeh1412ffa2021-07-20 07:33:20 +020050 pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER);
Mario Scheithauer1a5ce952018-11-28 09:21:58 +010051
52 /* Disable clock outputs 0-3 (CLKOUT) for upstream XIO2001 PCIe
53 * to PCI Bridge. */
54 struct device *parent = dev->bus->dev;
Felix Singer43b7f412022-03-07 04:34:52 +010055 if (parent && parent->device == PCI_DID_TI_XIO2001)
Mario Scheithauer1a5ce952018-11-28 09:21:58 +010056 pci_write_config8(parent, 0xd8, 0x0f);
57 }
58
59 /* Disable clock outputs 1-5 (CLKOUT) for another XIO2001 PCIe to PCI
60 * Bridge on this mainboard.
61 */
Felix Singer43b7f412022-03-07 04:34:52 +010062 dev = dev_find_device(PCI_VID_SIEMENS, 0x403f, 0);
Mario Scheithauer1a5ce952018-11-28 09:21:58 +010063 if (dev) {
64 struct device *parent = dev->bus->dev;
Felix Singer43b7f412022-03-07 04:34:52 +010065 if (parent && parent->device == PCI_DID_TI_XIO2001)
Mario Scheithauer1a5ce952018-11-28 09:21:58 +010066 pci_write_config8(parent, 0xd8, 0x3e);
Mario Scheithauera94a1532018-11-28 09:13:28 +010067 }
Mario Scheithauer5716b4c2018-11-14 13:27:05 +010068}
69
Mario Scheithauer5716b4c2018-11-14 13:27:05 +010070static void finalize_boot(void *unused)
71{
72 /* Set coreboot ready LED. */
73 gpio_output(CNV_RGI_DT, 1);
74}
75
Mario Scheithauer5716b4c2018-11-14 13:27:05 +010076BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, finalize_boot, NULL);