From 1197f0832de1838d7a875251652292bc132ec47d Mon Sep 17 00:00:00 2001 From: Kane Chen Date: Tue, 13 Aug 2024 16:40:08 +0800 Subject: [PATCH] chipset_enable.c: Use PCI_ACCESS_ECAM to access pci register In the latest pciutils(v3.13.0), it supports accessing pci registers by ecam. This patch uses libpci version check to decide whether flashrom calls libpci and use 0xcf8/0xcfc or ecam to access pci registers. BUG=b:359813524 TEST=with libpci >= 3.13.0, flashrom is working with ECAM access Change-Id: I4549f87c8b01da0a1d3d8ce0b3b75c1f5fa2cbab Signed-off-by: Kane Chen Reviewed-on: https://review.coreboot.org/c/flashrom/+/83896 Tested-by: build bot (Jenkins) Reviewed-by: Hsuan-ting Chen Reviewed-by: Peter Marheine --- chipset_enable.c | 6 ++++++ doc/release_notes/devel.rst | 10 +++++++++- meson.build | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/chipset_enable.c b/chipset_enable.c index facf29e50..9f0a0bba7 100644 --- a/chipset_enable.c +++ b/chipset_enable.c @@ -938,7 +938,13 @@ static int enable_flash_pch100_or_c620(const struct programmer_cfg *cfg, msg_perr("Can't allocate PCI accessor.\n"); return ret; } +#if CONFIG_USE_LIBPCI_ECAM == 1 + pci_acc->method = PCI_ACCESS_ECAM; + msg_pdbg("Using libpci PCI_ACCESS_ECAM\n"); +#else pci_acc->method = PCI_ACCESS_I386_TYPE1; + msg_pdbg("Using libpci PCI_ACCESS_I386_TYPE1\n"); +#endif pci_init(pci_acc); register_shutdown(enable_flash_pch100_shutdown, pci_acc); diff --git a/doc/release_notes/devel.rst b/doc/release_notes/devel.rst index e28e347de..5243f7c6e 100644 --- a/doc/release_notes/devel.rst +++ b/doc/release_notes/devel.rst @@ -22,4 +22,12 @@ Build only supported with Meson As documented in the :doc:`v1.4 release notes `, support for building flashrom with make has been removed; all Makefiles have been deleted. Meson is -now the only supported tool for building flashrom from source. \ No newline at end of file +now the only supported tool for building flashrom from source. + +New Feature +=========== +Libpci 3.13.0 and onwards support ECAM to access pci registers. Flashrom will +be moved to ECAM from IO port 0xcf8/0xcfc if the libpci version is >= 3.13.0. +The ECAM has been supported for a very long time, most platforms should support +it. For those platforms don't support ECAM, libpci will terminate the process by +exit. diff --git a/meson.build b/meson.build index 85d69b8d5..26d96d932 100644 --- a/meson.build +++ b/meson.build @@ -165,6 +165,13 @@ libusb1 = dependency('libusb-1.0', required : group_usb) libftdi1 = dependency('libftdi1', required : group_ftdi) libjaylink = dependency('libjaylink', required : group_jlink, version : '>=0.3.0') +# ECAM is supported in libpci after 3.13.0 +if libpci.version().version_compare('>=3.13.0') + add_project_arguments('-DCONFIG_USE_LIBPCI_ECAM=1', language: 'c') +else + add_project_arguments('-DCONFIG_USE_LIBPCI_ECAM=0', language: 'c') +endif + if host_machine.system() == 'windows' # Specifying an include_path that doesn't exist is an error, # but we only use this if the library is found in the same directory.