blob: 1aa5fb2745e762d1076e86b5b2242aa305ecd6cb [file] [log] [blame]
Angel Pons6ad91762020-04-03 01:23:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Mario Scheithauer66038c82018-09-25 17:26:32 +02003
4#include <bootstate.h>
5#include <console/console.h>
6#include <device/pci_def.h>
7#include <device/pci_ids.h>
8#include <device/pci_ops.h>
9#include <hwilib.h>
10#include <intelblocks/lpc_lib.h>
11#include <timer.h>
12#include <timestamp.h>
13#include <baseboard/variants.h>
Werner Zeh42065f82019-05-02 12:45:21 +020014#include <soc/pci_devs.h>
Elyes HAOUASe39db682019-05-15 21:12:31 +020015#include <types.h>
Werner Zeh42065f82019-05-02 12:45:21 +020016
Mario Scheithauer66038c82018-09-25 17:26:32 +020017void variant_mainboard_final(void)
18{
19 struct device *dev;
20 uint16_t cmd = 0;
21
22 /* Set Master Enable for on-board PCI device. */
23 dev = dev_find_device(PCI_VENDOR_ID_SIEMENS, 0x403e, 0);
24 if (dev) {
25 cmd = pci_read_config16(dev, PCI_COMMAND);
26 cmd |= PCI_COMMAND_MASTER;
27 pci_write_config16(dev, PCI_COMMAND, cmd);
28 }
Mario Scheithauer66038c82018-09-25 17:26:32 +020029}
30
31static void wait_for_legacy_dev(void *unused)
32{
33 uint32_t legacy_delay, us_since_boot;
34 struct stopwatch sw;
35
36 /* Open main hwinfo block. */
37 if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS)
38 return;
39
40 /* Get legacy delay parameter from hwinfo. */
41 if (hwilib_get_field(LegacyDelay, (uint8_t *) &legacy_delay,
42 sizeof(legacy_delay)) != sizeof(legacy_delay))
43 return;
44
45 us_since_boot = get_us_since_boot();
46 /* No need to wait if the time since boot is already long enough.*/
47 if (us_since_boot > legacy_delay)
48 return;
49 stopwatch_init_msecs_expire(&sw, (legacy_delay - us_since_boot) / 1000);
50 printk(BIOS_NOTICE, "Wait remaining %d of %d us for legacy devices...",
51 legacy_delay - us_since_boot, legacy_delay);
52 stopwatch_wait_until_expired(&sw);
53 printk(BIOS_NOTICE, "done!\n");
54}
55
56BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL);