Angel Pons | 6ad9176 | 2020-04-03 01:23:24 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 3 | |
| 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 Zeh | 42065f8 | 2019-05-02 12:45:21 +0200 | [diff] [blame] | 14 | #include <soc/pci_devs.h> |
Elyes HAOUAS | e39db68 | 2019-05-15 21:12:31 +0200 | [diff] [blame] | 15 | #include <types.h> |
Werner Zeh | 42065f8 | 2019-05-02 12:45:21 +0200 | [diff] [blame] | 16 | |
Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 17 | void 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 Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | static 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 | |
| 56 | BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL); |