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