blob: e6aff800553aab897f7514208a10cb431afe4a12 [file] [log] [blame]
Mario Scheithauer66038c82018-09-25 17:26:32 +02001/*
2 * This file is part of the coreboot project.
3 *
Mario Scheithauer66038c82018-09-25 17:26:32 +02004 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <bootstate.h>
16#include <console/console.h>
17#include <device/pci_def.h>
18#include <device/pci_ids.h>
19#include <device/pci_ops.h>
20#include <hwilib.h>
21#include <intelblocks/lpc_lib.h>
22#include <timer.h>
23#include <timestamp.h>
24#include <baseboard/variants.h>
Werner Zeh42065f82019-05-02 12:45:21 +020025#include <soc/pci_devs.h>
Elyes HAOUASe39db682019-05-15 21:12:31 +020026#include <types.h>
Werner Zeh42065f82019-05-02 12:45:21 +020027
Mario Scheithauer66038c82018-09-25 17:26:32 +020028void variant_mainboard_final(void)
29{
30 struct device *dev;
31 uint16_t cmd = 0;
32
33 /* Set Master Enable for on-board PCI device. */
34 dev = dev_find_device(PCI_VENDOR_ID_SIEMENS, 0x403e, 0);
35 if (dev) {
36 cmd = pci_read_config16(dev, PCI_COMMAND);
37 cmd |= PCI_COMMAND_MASTER;
38 pci_write_config16(dev, PCI_COMMAND, cmd);
39 }
Mario Scheithauer66038c82018-09-25 17:26:32 +020040}
41
42static void wait_for_legacy_dev(void *unused)
43{
44 uint32_t legacy_delay, us_since_boot;
45 struct stopwatch sw;
46
47 /* Open main hwinfo block. */
48 if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS)
49 return;
50
51 /* Get legacy delay parameter from hwinfo. */
52 if (hwilib_get_field(LegacyDelay, (uint8_t *) &legacy_delay,
53 sizeof(legacy_delay)) != sizeof(legacy_delay))
54 return;
55
56 us_since_boot = get_us_since_boot();
57 /* No need to wait if the time since boot is already long enough.*/
58 if (us_since_boot > legacy_delay)
59 return;
60 stopwatch_init_msecs_expire(&sw, (legacy_delay - us_since_boot) / 1000);
61 printk(BIOS_NOTICE, "Wait remaining %d of %d us for legacy devices...",
62 legacy_delay - us_since_boot, legacy_delay);
63 stopwatch_wait_until_expired(&sw);
64 printk(BIOS_NOTICE, "done!\n");
65}
66
67BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL);