Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83390?usp=email )
Change subject: nb/via/cx700: Implement PCI function disablement ......................................................................
nb/via/cx700: Implement PCI function disablement
Change-Id: I97ac61bca336465ce64e1c2b57d40e7ddd7f2643 Signed-off-by: Nico Huber nico.h@gmx.de --- M src/northbridge/via/cx700/chip.c 1 file changed, 50 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/90/83390/1
diff --git a/src/northbridge/via/cx700/chip.c b/src/northbridge/via/cx700/chip.c index 57583b8..55651d7 100644 --- a/src/northbridge/via/cx700/chip.c +++ b/src/northbridge/via/cx700/chip.c @@ -1,5 +1,54 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <stdbool.h> #include <device/device.h> +#include <device/pci_ops.h> +#include <static_devices.h>
-struct chip_operations northbridge_via_cx700_ops = { NULL }; +#define FUNCTION_ENABLE_1 0x50 +#define DISABLE_MC97_BIT 7 +#define DISABLE_UHCI1_BIT 5 +#define DISABLE_UHCI0_BIT 4 +#define DISABLE_ATA_BIT 3 +#define DISABLE_UHCI2_BIT 2 +#define DISABLE_EHCI_BIT 1 + +#define PCIE_DEVICE_ENABLE 0x42 +#define DISABLE_HDA_BIT 3 + +static void function_enable_1(unsigned int bit, bool enable) +{ + pci_update_config8(_dev_lpc_ptr, FUNCTION_ENABLE_1, ~(1 << bit), !enable << bit); +} + +static void pcie_device_enable(unsigned int bit, bool enable) +{ + pci_update_config8(_dev_pcie_ptr, PCIE_DEVICE_ENABLE, ~(1 << bit), !enable << bit); +} + +static void enable_dev(struct device *const dev) +{ + if (dev == _dev_ata_ptr) + function_enable_1(DISABLE_ATA_BIT, dev->enabled); + + if (dev == _dev_uhci0_ptr) + function_enable_1(DISABLE_UHCI0_BIT, /* keep function 0 enabled if needed: */ + dev->enabled || _dev_uhci1_ptr->enabled || + _dev_uhci2_ptr->enabled || _dev_ehci_ptr->enabled); + if (dev == _dev_uhci1_ptr) + function_enable_1(DISABLE_UHCI1_BIT, dev->enabled); + if (dev == _dev_uhci2_ptr) + function_enable_1(DISABLE_UHCI2_BIT, dev->enabled); + if (dev == _dev_ehci_ptr) + function_enable_1(DISABLE_EHCI_BIT, dev->enabled); + + if (dev == _dev_mc97_ptr) + function_enable_1(DISABLE_MC97_BIT, dev->enabled); + + if (dev == _dev_hda_ptr) + pcie_device_enable(DISABLE_HDA_BIT, dev->enabled); +} + +struct chip_operations northbridge_via_cx700_ops = { + .enable_dev = enable_dev, +};