Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 4 | * |
| 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 Zeh | 42065f8 | 2019-05-02 12:45:21 +0200 | [diff] [blame] | 25 | #include <soc/pci_devs.h> |
Elyes HAOUAS | e39db68 | 2019-05-15 21:12:31 +0200 | [diff] [blame] | 26 | #include <types.h> |
Werner Zeh | 42065f8 | 2019-05-02 12:45:21 +0200 | [diff] [blame] | 27 | |
Mario Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 28 | void 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 Scheithauer | 66038c8 | 2018-09-25 17:26:32 +0200 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | static 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 | |
| 67 | BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL); |