Angel Pons | 6ad9176 | 2020-04-03 01:23:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 2 | |
| 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 Zeh | 42065f8 | 2019-05-02 12:45:21 +0200 | [diff] [blame] | 13 | #include <soc/pci_devs.h> |
Elyes HAOUAS | e39db68 | 2019-05-15 21:12:31 +0200 | [diff] [blame] | 14 | #include <types.h> |
Werner Zeh | 42065f8 | 2019-05-02 12:45:21 +0200 | [diff] [blame] | 15 | |
Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 16 | void variant_mainboard_final(void) |
| 17 | { |
| 18 | struct device *dev; |
Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 19 | |
| 20 | /* Set Master Enable for on-board PCI device. */ |
| 21 | dev = dev_find_device(PCI_VENDOR_ID_SIEMENS, 0x403e, 0); |
| 22 | if (dev) { |
Angel Pons | 28ed787 | 2020-11-10 20:07:33 +0100 | [diff] [blame^] | 23 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 24 | } |
Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | static 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 | |
| 52 | BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL); |